1import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{n}from"./i18n-CqUQop_T.js";import{t as r}from"./jsx-runtime-NZYk81nU.js";import{t as i}from"./clsx-DB0hHKMi.js";import{E as a,k as o}from"./main-CurxK63a.js";var s=()=>{if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=e=>e.toString(16).padStart(2,`0`);return t(e[0])+t(e[1])+t(e[2])+t(e[3])+`-`+t(e[4])+t(e[5])+`-`+t(e[6])+t(e[7])+`-`+t(e[8])+t(e[9])+`-`+t(e[10])+t(e[11])+t(e[12])+t(e[13])+t(e[14])+t(e[15])},c=e(t(),1);function l(e){return[...e].map(e=>[...e.toLowerCase()][0]??e)}function u(e,t){let n=l(t.trim());if(n.length===0)return[{text:e,match:!1}];let r=[...e],i=l(e),a=[],o=``,s=0,c=()=>{o&&=(a.push({text:o,match:!1}),``)};for(;s<r.length;){let e=s+n.length;e<=r.length&&i.slice(s,e).every((e,t)=>e===n[t])?(c(),a.push({text:r.slice(s,e).join(``),match:!0}),s=e):(o+=r[s],s+=1)}return c(),a}var d={toolbars:`_toolbars_uxut1_11`,toolbarCluster:`_toolbarCluster_uxut1_82`,save:`_save_uxut1_47`,saveGlyph:`_saveGlyph_uxut1_264`,saveState:`_saveState_uxut1_278`,saveLabelRest:`_saveLabelRest_uxut1_279`,saveLabel:`_saveLabel_uxut1_97`,saveLabelGhost:`_saveLabelGhost_uxut1_290`,"retire-said":`_retire-said_uxut1_1`,"return-label":`_return-label_uxut1_1`,editor:`_editor_uxut1_385`,pane:`_pane_uxut1_411`,active:`_active_uxut1_431`,layoutPane:`_layoutPane_uxut1_487`,inactive:`_inactive_uxut1_459`,properties:`_properties_uxut1_503`,crossFade:`_crossFade_uxut1_509`,tabStack:`_tabStack_uxut1_526`,tabPanel:`_tabPanel_uxut1_533`,dateField:`_dateField_uxut1_590`,dateFieldIcon:`_dateFieldIcon_uxut1_626`,dateStep:`_dateStep_uxut1_633`,dateStepBack:`_dateStepBack_uxut1_639`,whenRow:`_whenRow_uxut1_663`,timeField:`_timeField_uxut1_676`,zoneLine:`_zoneLine_uxut1_728`,presentationRow:`_presentationRow_uxut1_739`,presentationWords:`_presentationWords_uxut1_746`,presentationLabel:`_presentationLabel_uxut1_751`,presentationHint:`_presentationHint_uxut1_759`,translations:`_translations_uxut1_774`,translationActions:`_translationActions_uxut1_785`,quietAction:`_quietAction_uxut1_797`,stepHint:`_stepHint_uxut1_818`,stepNotice:`_stepNotice_uxut1_826`,stepError:`_stepError_uxut1_841`,languageList:`_languageList_uxut1_849`,languageName:`_languageName_uxut1_862`,languageCode:`_languageCode_uxut1_868`,offlineNotice:`_offlineNotice_uxut1_893`,saveError:`_saveError_uxut1_888`,saveErrorIcon:`_saveErrorIcon_uxut1_918`,postRefSearch:`_postRefSearch_uxut1_948`,postRefList:`_postRefList_uxut1_959`,postRefOption:`_postRefOption_uxut1_969`,postRefOptionSelected:`_postRefOptionSelected_uxut1_999`,postRefOptionTitle:`_postRefOptionTitle_uxut1_1004`,postRefOptionBadge:`_postRefOptionBadge_uxut1_1017`,postRefModes:`_postRefModes_uxut1_1034`,postRefMode:`_postRefMode_uxut1_1034`,postRefModeSelected:`_postRefModeSelected_uxut1_1057`,openBlockControls:`_openBlockControls_uxut1_1079`,paperTitle:`_paperTitle_uxut1_1085`},f=r(),p=e=>JSON.stringify({postId:e.postId,title:e.title??null,display:e.display??`card`}),m=e=>{if(!e||typeof e!=`string`)return null;try{let t=JSON.parse(e);return!t||typeof t!=`object`||!t.postId?null:{postId:String(t.postId),title:t.title??null,display:t.display===`link`?`link`:`card`}}catch{return{postId:e}}},h=({value:e,onChange:t,placed:r})=>{let[o,s]=(0,c.useState)([]),[l,p]=(0,c.useState)(!0),[m,h]=(0,c.useState)(!1),[g,_]=(0,c.useState)(``);(0,c.useEffect)(()=>{let e=!1;return p(!0),h(!1),fetch(`/api/posts?offset=0&limit=100`,{headers:{Accept:`application/json`},credentials:`same-origin`}).then(e=>{if(!e.ok)throw Error(String(e.status));return e.json()}).then(t=>{if(e)return;let n=new DOMParser().parseFromString(t.html??``,`text/html`),r=[];n.querySelectorAll(`.post[id^="post-"]`).forEach(e=>{let t=e.id.slice(5);if(!t||r.some(e=>e.publicId===t))return;let n=e.querySelector(`[data-role="post-title"]`);r.push({publicId:t,title:(n?.textContent??``).trim()||`Untitled`,published:e.getAttribute(`data-published`)!==`false`})}),s(r),p(!1)}).catch(()=>{e||(h(!0),p(!1))}),()=>{e=!0}},[]);let v=(0,c.useMemo)(()=>{let e=g.trim().toLowerCase();return e?o.filter(t=>t.title.toLowerCase().includes(e)):o},[o,g]);return(0,f.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[l&&(0,f.jsxs)(`div`,{className:`flex items-center gap-3 py-6`,children:[(0,f.jsx)(`span`,{className:`load-spinner`,"aria-hidden":`true`}),(0,f.jsx)(`span`,{className:`text-sm opacity-60`,children:n(`post_editor.logged_in.post_ref.loading`)})]}),m&&(0,f.jsx)(`p`,{className:`text-sm m-0 opacity-70`,children:n(`post_editor.logged_in.post_ref.failed`)}),!l&&!m&&o.length===0&&(0,f.jsx)(`p`,{className:`text-sm m-0 opacity-70`,children:n(`post_editor.logged_in.post_ref.empty`)}),!l&&!m&&o.length>0&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`input`,{...a,type:`search`,className:d.postRefSearch,placeholder:n(`post_editor.logged_in.post_ref.search`),value:g,onChange:e=>_(e.target.value)}),(0,f.jsx)(`div`,{className:d.postRefList,children:v.map(a=>{let o=e?.postId===a.publicId,s=r?.has(a.publicId)??!1;return(0,f.jsxs)(`button`,{type:`button`,className:i(d.postRefOption,o&&d.postRefOptionSelected),"aria-pressed":o,disabled:s,"data-on-page":s||void 0,onClick:()=>t({postId:a.publicId,title:a.title,display:e?.display??`card`}),children:[(0,f.jsx)(`span`,{className:d.postRefOptionTitle,children:u(a.title,g).map((e,t)=>e.match?(0,f.jsx)(`mark`,{className:`post-match`,children:e.text},t):(0,f.jsx)(`span`,{children:e.text},t))}),s?(0,f.jsx)(`span`,{className:d.postRefOptionBadge,children:n(`composer.on_page`)}):!a.published&&(0,f.jsx)(`span`,{className:d.postRefOptionBadge,children:n(`reach.only_you`)})]},a.publicId)})})]})]})}
1,g=({value:e,onChange:t,onDone:r})=>(0,f.jsxs)(f.Fragment,{children:[e?.postId&&(0,f.jsx)(`div`,{className:d.postRefModes,role:`group`,children:[`card`,`link`].map(r=>(0,f.jsx)(`button`,{type:`button`,className:i(d.postRefMode,(e.display??`card`)===r&&d.postRefModeSelected),"aria-pressed":(e.display??`card`)===r,onClick:()=>t({...e,display:r}),children:n(`post_editor.logged_in.post_ref.display_${r}`)},r))}),(0,f.jsx)(`div`,{className:`ml-auto`,children:(0,f.jsx)(o,{variant:`primary`,onClick:r,disabled:!e?.postId,children:n(`common.done`)})})]});export{d as a,p as i,g as n,s as o,m as r,h as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.