import{d as e,l as t,s as n,t as r}from"./hooks.module-BrXTvcfS.js";import{a as i}from"./i18n-BaLR3UdQ.js";import{t as a}from"./jsxRuntime.module-Cao1NCKs.js";import{o}from"./react_utils-Bz0ffU2Y.js";import{J as s}from"./hooks-ClTXKdUl.js";import{a as c,i as l,r as u}from"./FormList-CnuOJg6b.js";import{t as d}from"./Modal-hBkTa-Ee.js";import{r as f}from"./Badge-B9svkCt1.js";import{n as p}from"./note_types-DBtsBNjr.js";import{t as m}from"./NoteAutocomplete-Cpc7J_0A.js";import{t as h}from"./FormGroup-DqPd4bBP.js";e();var g=[i(`note_type_chooser.builtin_templates`),i(`note_type_chooser.templates`)];function _(){let[e,_]=n(),[v,y]=n(!1),[b,x]=n(),[S,C]=n([]),w=r(null),T=r(null);s(`chooseNoteType`,({callback:e})=>{_(()=>e),y(!0)}),t(()=>{p.getNoteTypeItems().then(e=>{let t=-1;C((e??[]).map(e=>`kind`in e&&e.kind===`separator`?(t++,{kind:`header`,title:g[t]}):e))})},[]);function E(t){let[n,r]=t.split(`,`);e?.({success:!0,noteType:n,templateNoteId:r,notePath:b?.notePath}),y(!1)}return a(d,{modalRef:w,title:i(`note_type_chooser.modal_title`),className:`note-type-chooser-dialog`,size:`md`,zIndex:1100,scrollable:!0,onShown:()=>{o(T).trigger(`focus`).trigger(`select`)},onHidden:()=>{e?.({success:!1}),y(!1)},show:v,stackable:!0,children:[a(h,{name:`parent-note`,label:i(`note_type_chooser.change_path_prompt`),children:a(m,{inputRef:T,onChange:x,placeholder:i(`note_type_chooser.search_placeholder`),opts:{allowCreatingNotes:!1,hideGoToSelectedNoteButton:!0,allowJumpToSearchNotes:!1}})}),a(h,{name:`note-type`,label:i(`note_type_chooser.modal_body`),children:a(u,{onSelect:E,children:S.map(e=>{if(`kind`in e&&e.kind===`separator`)return;let t=e;return`kind`in t&&t.kind===`header`?a(l,{text:t.title}):a(c,{value:[t.type,t.templateNoteId].join(`,`),icon:t.uiIcon,children:[t.title,t.badges&&t.badges.map(e=>a(f,{...e}))]})})})})]})}export{_ as default};