living-ai-documentation 3.53.0 → 3.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -88,7 +88,7 @@ Texte`};case`link`:return{text:ut(`snip-link-text`),textFallback:Y(`snippet.link
88
88
 
89
89
  `,t+1);return n>=0?n:e.length}s=s.previousElementSibling}let c=a.nextElementSibling;for(;c;){let t=zd(e,c,r);if(t!==null){let n=e.lastIndexOf(`
90
90
 
91
- `,t);return n>=0?n:0}c=c.nextElementSibling}return e.length}function Vd(e,t,n){if(!e||typeof t!=`string`)return()=>{};let r=Ad(t);Md(e,r);let i=i=>{let a=i.target?.closest(`[data-inline-snippet-index]`);if(a&&e.contains(a)){let e=r[Number(a.dataset.inlineSnippetIndex)];if(!e)return;i.preventDefault();let t=yd(e.type),o=xd(e.type);Pd(i,[{iconClass:t.iconClass,labelKey:t.labelKey,dataAction:`edit`,dataType:e.type,onActivate:()=>n.onEdit(e)},{iconClass:o.iconClass,labelKey:o.labelKey,dataAction:`delete`,dataType:e.type,onActivate:()=>n.onDelete(e)}]);return}if(!e.contains(i.target))return;let o=Bd(t,e,i.target,r,i.clientY);o!==null&&(i.preventDefault(),Pd(i,{iconClass:`fa-solid fa-plus`,labelKey:`snippet.inline_insert_btn`,dataAction:`insert`,onActivate:()=>n.onInsert(o)}))};e.addEventListener(`contextmenu`,i);let a=t=>{let i=t.target?.closest(`[data-inline-snippet-index]`);if(!i||!e.contains(i))return;let a=r[Number(i.dataset.inlineSnippetIndex)];a?.type===`table`&&(t.preventDefault(),t.stopPropagation(),Nd(),n.onEdit({...a,tableFocusCell:Id(t.target,i)||void 0}))};e.addEventListener(`dblclick`,a);let o=e.closest(`#home-content-area`)||e.closest(`main`),s=null;o&&(s=r=>{r.defaultPrevented||e.offsetParent!==null&&(r.target?.closest(`textarea, input, [data-inline-snippet-index]`)||e.contains(r.target)||(r.preventDefault(),Pd(r,{iconClass:`fa-solid fa-plus`,labelKey:`snippet.inline_insert_btn`,dataAction:`insert`,onActivate:()=>n.onInsert(t.length)})))},o.addEventListener(`contextmenu`,s));let c=e=>{Cd&&!Cd.contains(e.target)&&Nd()},l=e=>{e.key===`Escape`&&Nd()};return document.addEventListener(`click`,c),document.addEventListener(`keydown`,l),()=>{e.removeEventListener(`contextmenu`,i),e.removeEventListener(`dblclick`,a),o&&s&&o.removeEventListener(`contextmenu`,s),document.removeEventListener(`click`,c),document.removeEventListener(`keydown`,l),Nd(),e.querySelectorAll(`[data-inline-snippet-index]`).forEach(e=>{e.removeAttribute(`data-inline-snippet-index`),e.classList.remove(`ld-inline-snippet-target`)})}}var Hd=U(`<textarea id="doc-editor" data-testid="doc-editor" spellcheck="false" class="w-full min-h-[70vh] px-4 py-3 text-sm font-mono leading-relaxed rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-y"></textarea>`),Ud=U(`<div id="doc-content" data-testid="doc-content"></div>`),Wd=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-sm mx-4 p-6 space-y-5"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"> </h3> <div class="space-y-1.5"><label for="img-paste-name" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> <span class="font-normal text-gray-400"> </span></label> <div class="flex items-center gap-2"><input id="img-paste-name" type="text" class="flex-1 px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono focus:outline-none focus:ring-2 focus:ring-blue-500"/> <span class="text-xs text-gray-400 shrink-0"> </span></div></div> <div class="flex justify-end gap-3 pt-1"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div></div>`),Gd=U(`<div data-testid="content-lightbox" class="fixed inset-0 z-50 bg-white flex items-center justify-center cursor-pointer p-4"><img data-testid="lightbox-image" class="max-w-full max-h-full object-contain select-none"/> <button class="absolute top-4 right-4 text-gray-500 hover:text-gray-950 text-2xl leading-none">×</button></div>`),Kd=U(`<!> <!> <!> <!>`,1);function qd(e,t){qe(t,!0);let n=Wi(t,`onopen`,3,()=>{}),r=Wi(t,`onanchor`,3,D),i=Wi(t,`onconfirmdelete`,3,void 0),a=Wi(t,`oncontentwired`,3,void 0),o=Wi(t,`rewireSignal`,3,void 0),s=Wi(t,`editing`,15,!1),c=Wi(t,`saveMsg`,15,null),l=P(null),u=P(null),d=P(``),f=null,p=P(!1),m=P(`insert`),h=P(null),g=P(0),_=P(!1),v=P(``),y=P(`png`),b=null,x=0,S=0,C=P(null),w=P(``),T=/[̀-ͯ]/g;function E(e){return(e||``).normalize(`NFD`).replace(T,``).toLowerCase().replace(/[^a-z0-9]/g,`_`)}function D(e){document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})}Gi(()=>{let e=window;return e.openSnippetsModal=()=>{F(m,`insert`),F(p,!0)},e.openSnippetsModalForInlineInsert=e=>{F(m,`inline-insert`),F(g,Math.max(0,Number(e)||0),!0),F(p,!0)},()=>{delete e.openSnippetsModal,delete e.openSnippetsModalForInlineInsert}}),kn(()=>{if(o(),t.html,t.content,f?.(),f=null,!(s()||!V(l)))return Tu(V(l),t.html,{content:t.content,codeBlockMaxHeight:X.codeBlockMaxHeight,t:Y,onDocLink:(e,t)=>n()(e,t),onAnchor:r(),docId:t.docId,docs:X.allDocs,docsFolder:X.docsFolder,folderPaths:X.allFolderPaths,onKanbanDocsChange:e=>{X.allDocs=e},onKanbanFolderPathsChange:e=>{X.allFolderPaths=e}})||(f=Vd(V(l),t.content,{onEdit:e=>{F(m,`inline-edit`),F(h,e,!0),F(p,!0)},onInsert:e=>{F(m,`inline-insert`),F(g,e,!0),F(p,!0)},onDelete:async e=>{(i()?await i()():confirm(Y(`snippet.inline_delete_message`)))&&await t.onsave(t.content.slice(0,e.start)+t.content.slice(e.end))}})),a()?.(V(l)),()=>{f?.(),f=null}});function ee(){F(d,t.content,!0),s(!0),c(null),requestAnimationFrame(()=>V(u)?.focus())}function te(){s(!1),c(null)}async function O(){c({text:Y(`doc.saving`),cls:`text-gray-400`});try{await t.onsave(V(d)),s(!1),c(null)}catch(e){c({text:Y(`error.save`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}}function ne(){F(m,`insert`),F(p,!0)}function re(){let e=ru(t.content);e&&(F(m,`inline-edit`),F(h,e,!0),F(p,!0))}function k(){return s()}function ie(e){let t=Array.from(e.clipboardData?.items??[]).find(e=>e.type.startsWith(`image/`));if(t){e.preventDefault(),x=V(u).selectionStart,S=V(u).selectionEnd,F(y,t.type.split(`/`)[1].replace(`jpeg`,`jpg`)||`png`,!0);let n=t.getAsFile();if(!n)return;b=n,F(v,E(Date.now().toString()),!0),F(_,!0);return}let n=Array.from(e.clipboardData?.files??[]).filter(e=>!e.type.startsWith(`image/`));if(n.length){e.preventDefault();let t=V(u).selectionStart,r=V(u).selectionEnd;(async()=>{for(let e of n)await le(e,t,r)})()}}function ae(e){let t=Array.from(e.dataTransfer?.files??[]).filter(e=>!e.type.startsWith(`image/`));if(!t.length)return;e.preventDefault(),e.stopPropagation();let n=V(u).selectionStart,r=V(u).selectionEnd;(async()=>{for(let e of t)await le(e,n,r)})()}function oe(e){e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}function se(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function ce(e,t,n){let r=V(d).slice(0,t),i=V(d).slice(n);F(d,r+e+i),requestAnimationFrame(()=>{V(u).selectionStart=V(u).selectionEnd=t+e.length,V(u).focus()})}async function le(e,n,r){if(e.size>19922944){c({text:Y(`doc.file_too_large`)+` (${(e.size/1024/1024).toFixed(1)} MB, max 19 MB)`,cls:`text-red-500 dark:text-red-400`});return}c({text:Y(`doc.uploading_file`),cls:`text-gray-400`});try{let i=await se(e),a=await fetch(`/api/files/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:i,name:e.name,documentId:t.docId})});if(!a.ok){let e=``;try{e=(await a.json()).error||``}catch{e=await a.text()}throw Error(e||`HTTP ${a.status}`)}let{url:o,originalName:s}=await a.json();ce(`[📎 ${s||e.name}](${o})`,n,r),c(null)}catch(e){c({text:Y(`doc.file_upload_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}}function ue(){F(_,!1),b=null}async function de(){let e=E(V(v))||Date.now().toString();if(F(_,!1),b){c({text:Y(`doc.uploading_image`),cls:`text-gray-400`});try{let t=await se(b),n=await fetch(`/api/images/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:t,ext:V(y),name:e})});if(!n.ok)throw Error(await n.text());let{filename:r}=await n.json();ce(`![image](/images/${r})`,x,S),c(null)}catch(e){c({text:Y(`doc.image_upload_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}finally{b=null}}}function fe(){F(C,null),F(w,``)}function pe(e){if(!e.shiftKey&&!e.metaKey)return;let t=e.target,n=t.closest(`img`),r=t.closest(`.mermaid`)?.querySelector(`svg`);if(!n&&!r)return;if(e.preventDefault(),e.stopPropagation(),n){F(C,n.src,!0),F(w,n.alt||``,!0);return}let i=new XMLSerializer().serializeToString(r);F(C,`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),F(w,Y(`doc.mermaid_diagram_alt`),!0)}function me(e){e.key===`Escape`&&V(C)&&fe()}var he={enterEdit:ee,cancelEdit:te,save:O,openSnippets:ne,openKanbanColumnsEditor:re,isEditing:k},ge=Kd();Nr(`keydown`,on,me);var _e=R(ge),ve=e=>{var t=Hd();yn(t),Vi(t,e=>F(u,e),()=>V(u)),Nr(`paste`,t,ie),Nr(`drop`,t,ae),Nr(`dragover`,t,oe),Ni(t,()=>V(d),e=>F(d,e)),W(e,t)},ye=e=>{var t=Ud();Vi(t,e=>F(l,e),()=>V(l)),B(()=>gi(t,1,`prose prose-gray dark:prose-invert max-w-none prose-headings:scroll-mt-4 prose-headings:font-semibold prose-h1:text-[2.1875rem] prose-h2:text-[1.8125rem] prose-h3:text-[1.5rem] prose-h4:text-[1.25rem] prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-code:before:content-none prose-code:after:content-none ${X.codeBlockLightTheme?`prose-pre:bg-[#f6f8fa] prose-pre:text-gray-800 prose-pre:border prose-pre:border-gray-200 prose-pre:rounded-lg dark:prose-pre:bg-[#0d1117] dark:prose-pre:text-gray-100 dark:prose-pre:border-gray-700`:`prose-pre:bg-[#0d1117] prose-pre:border prose-pre:border-gray-700`} ${X.imageRoundedCorners?`[&_img]:rounded-xl`:``} ${X.imageCentered?`[&_img]:mx-auto [&_img]:block`:``} ${X.imageBorder?`[&_img]:[box-shadow:0_0_0_1px_rgba(0,0,0,0.10),0_4px_12px_rgba(0,0,0,0.04)] dark:[&_img]:[box-shadow:0_0_0_1px_rgba(255,255,255,0.08),0_4px_12px_rgba(255,255,255,0.25)]`:``}`)),H(`click`,t,pe),W(e,t)};K(_e,e=>{s()?e(ve):e(ye,-1)});var be=z(_e,2);gd(be,{get open(){return V(p)},get editor(){return V(u)},get mode(){return V(m)},get docId(){return t.docId},get content(){return t.content},get range(){return V(h)},get insertPos(){return V(g)},get onsave(){return t.onsave},onclose:()=>F(p,!1)});var xe=z(be,2),Se=e=>{var t=Wd(),n=L(t),r=L(n),i=L(r);j(r);var a=z(r,2),o=L(a),s=L(o),c=z(s),l=L(c,!0);j(c),j(o);var u=z(o,2),d=L(u);Di(d);var f=z(d,2),p=L(f);j(f),j(u),j(a);var m=z(a,2),h=L(m),g=L(h,!0);j(h);var _=z(h,2),b=L(_,!0);j(_),j(m),j(n),j(t),B((e,t,n,r,a)=>{G(i,`🖼️ ${e??``}`),G(s,`${t??``} `),G(l,n),Oi(d,V(v)),G(p,`.${V(y)??``}`),G(g,r),G(b,a)},[()=>Y(`modal.img_paste.title`),()=>Y(`modal.img_paste.filename_label`),()=>Y(`modal.img_paste.saved_hint`),()=>Y(`common.cancel`),()=>Y(`modal.img_paste.paste_btn`)]),H(`input`,d,e=>F(v,E(e.target.value),!0)),H(`click`,h,ue),H(`click`,_,de),W(e,t)};K(xe,e=>{V(_)&&e(Se)});var Ce=z(xe,2),A=e=>{var t=Gd(),n=L(t),r=z(n,2);j(t),B(()=>{J(n,`src`,V(C)),J(n,`alt`,V(w))}),H(`click`,t,fe),H(`click`,n,e=>e.stopPropagation()),H(`click`,r,fe),W(e,t)};return K(Ce,e=>{V(C)&&e(A)}),W(e,ge),Je(he)}Pr([`click`,`input`]);var Jd=U(`<span> </span> <code> </code>`,1),Yd=U(`<button type="button" data-testid="bp-copy-doc-id"><i aria-hidden="true"></i></button>`),Xd=U(`<button class="bpadr-icon-btn" data-testid="bp-edit" type="button">✏️</button> <button class="bpadr-icon-btn" data-testid="bp-delete" type="button">🗑️</button>`,1),Zd=U(`<span> </span>`),Qd=U(`<footer class="bpadr-footer bpadr-doc-footer"><!> <button type="button" class="bpadr-btn-ghost" data-testid="bp-cancel"> </button> <button type="button" class="bpadr-btn-ghost" data-testid="bp-snippets"> </button> <button type="button" class="bpadr-btn-primary" data-testid="bp-save"> </button></footer>`),$d=U(`<div class="bpadr-read"><!></div> <!>`,1),ef=U(`<form class="bpadr-form"><input type="hidden" name="category"/> <input type="hidden" name="folder"/> <div class="bpadr-field"><label for="adr-title"> </label> <input id="adr-title" type="text" class="bpadr-input"/></div> <div class="bpadr-field bpadr-field-grow"><label for="adr-content"> </label> <textarea id="adr-content" class="bpadr-textarea"></textarea></div> <footer class="bpadr-footer"><button type="button" class="bpadr-btn-ghost"> </button> <button type="button" data-testid="bp-form-snippets" class="bpadr-btn-ghost"> </button> <button type="submit" class="bpadr-btn-primary"> </button></footer></form> <!>`,1),tf=U(`<div class="bpadr-folder-confirm"><p></p> <p class="bpadr-muted"> </p> <footer class="bpadr-footer"><button type="button" class="bpadr-btn-ghost"> </button> <button type="button" class="bpadr-btn-primary"> </button></footer></div>`),nf=U(`<div class="bpadr-overlay"><div class="bpadr-modal"><header class="bpadr-header"><div class="bpadr-title-row"><h2 class="bpadr-title"><!></h2> <!></div> <div class="bpadr-header-actions"><!> <button class="bpadr-icon-btn" type="button" title="Close">×</button></div></header> <!></div></div>`),rf=U(`<div class="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4"><div class="w-full max-w-sm bg-white dark:bg-gray-900 border border-red-200 dark:border-red-700 rounded-xl shadow-2xl p-5 flex flex-col gap-3"><p class="text-sm text-gray-700 dark:text-gray-200"> </p> <p class="text-xs text-gray-500 dark:text-gray-400 italic truncate"> </p> <div class="flex justify-end gap-2 mt-2"><button type="button" data-testid="bp-delete-cancel" class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button type="button" data-testid="bp-delete-confirm" class="text-sm px-4 py-1.5 rounded-lg bg-red-500 hover:bg-red-600 text-white font-semibold transition-colors"> </button></div></div></div>`),af=U(`<!> <!>`,1);function of(e,t){qe(t,!0);let n=Wi(t,`onchanged`,3,()=>{}),r=`001_BLUEPRINT`;function i(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toUpperCase().replace(/[^A-Z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`FOLDER`}function a(e){return`/${(e.folder.path||e.folder.name).replace(/^\/+|\/+$/g,``)||e.folder.name}`}let o=P(`closed`),s=P(``),c=P(``),l=P(``),u=P(``),d=P(``),f=P(``),p=P(``),m=P(``),h=P(null),g=P(null),_=P(null),v=P(!1),y=P(null),b=P(null),x=P(!1),S=P(!1),C=P(!1);async function w(e){F(g,e,!0),F(h,null),F(v,!1),F(y,null);let t=i(e.folder.name);if(F(l,t,!0),F(c,e.folder.name,!0),F(u,``),F(d,``),F(f,``),F(m,a(e),!0),F(s,Y(`blueprint.adr.new_title`,{folder:e.folder.name}),!0),F(o,`form`),!(await fetch(`/api/blueprint/blueprint-folder`).then(e=>e.json())).exists){F(p,r),F(o,`folder-confirm`);return}await E(e,t)}async function T(e){return fetch(`/api/documents/${encodeURIComponent(e)}`).then(e=>e.json())}async function E(e,t){let n=await fetch(`/api/blueprint/blueprint-adr?category=${encodeURIComponent(t)}`).then(e=>e.json());if(n.found&&n.doc){F(h,n.doc.id,!0);let e=await T(n.doc.id);F(c,e.title,!0),F(d,e.content,!0),F(f,e.html,!0),F(s,e.title,!0),F(v,!1),F(o,`doc`)}else F(c,e.folder.name,!0),F(u,``),F(o,`form`)}function D(){F(o,`closed`),F(v,!1),F(h,null),F(g,null),F(m,``),F(C,!1)}async function ee(){if(V(h))try{await navigator.clipboard.writeText(decodeURIComponent(V(h))),F(C,!0),setTimeout(()=>F(C,!1),1800)}catch{}}async function te(){await fetch(`/api/blueprint/blueprint-folder`,{method:`POST`}),V(g)&&await E(V(g),i(V(g).folder.name))}async function O(e){if(!V(h))return;await fetch(`/api/documents/${encodeURIComponent(V(h))}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:V(c).trim()||V(g)?.folder.name||Y(`common.untitled`),category:V(l),folder:r,content:e})});let t=await T(V(h));F(s,t.title,!0),F(d,t.content,!0),F(f,t.html,!0)}async function ne(e){e.preventDefault();let t={title:V(c).trim()||V(g)?.folder.name||Y(`common.untitled`),category:V(l),folder:r},i=await fetch(`/api/documents/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}).then(e=>e.json());F(h,i.id,!0);let a=await T(i.id);F(s,a.title,!0),F(d,a.content,!0),F(f,a.html,!0),F(v,!1),F(o,`doc`),n()()}async function re(){F(S,!1),V(h)&&(await fetch(`/api/documents/${encodeURIComponent(V(h))}`,{method:`DELETE`}),D(),n()())}var k={open:w},ie=af(),ae=R(ie),oe=e=>{var t=nf(),n=L(t),i=L(n),a=L(i),g=L(a),w=L(g),T=e=>{var t=Jd(),n=R(t),r=L(n,!0);j(n);var i=z(n,2),a=L(i,!0);j(i),B(e=>{G(r,e),G(a,V(m))},[()=>Y(`blueprint.adr.folder_title`)]),W(e,t)},E=e=>{var t=Ur();B(()=>G(t,V(s))),W(e,t)};K(w,e=>{V(m)?e(T):e(E,-1)}),j(g);var re=z(g,2),k=e=>{var t=Yd(),n=L(t);j(t),B(e=>{J(t,`title`,e),gi(t,1,`bpadr-copy-btn ${V(C)?`copied`:``}`),gi(n,1,`fa-${V(C)?`solid fa-check`:`regular fa-copy`}`)},[()=>Y(`doc.copy_mcp_id`)]),H(`click`,t,ee),W(e,t)};K(re,e=>{V(h)&&e(k)}),j(a);var ie=z(a,2),ae=L(ie),oe=e=>{var t=Xd(),n=R(t),r=z(n,2);B((e,t)=>{J(n,`title`,e),J(r,`title`,t)},[()=>Y(`doc.edit`),()=>Y(`doc.delete`)]),H(`click`,n,()=>V(_).enterEdit()),H(`click`,r,()=>F(S,!0)),W(e,t)};K(ae,e=>{V(o)===`doc`&&!V(v)&&e(oe)});var se=z(ae,2);j(ie),j(i);var ce=z(i,2),le=e=>{var t=$d(),n=R(t),r=L(n);{let e=N(()=>V(h)??``);Vi(qd(r,{get docId(){return V(e)},get content(){return V(d)},get html(){return V(f)},onsave:O,get editing(){return V(v)},set editing(e){F(v,e,!0)},get saveMsg(){return V(y)},set saveMsg(e){F(y,e,!0)}}),e=>F(_,e,!0),()=>V(_))}j(n);var i=z(n,2),a=e=>{var t=Qd(),n=L(t),r=e=>{var t=Zd(),n=L(t,!0);j(t),B(()=>{gi(t,1,`text-xs ${V(y).cls??``}`),G(n,V(y).text)}),W(e,t)};K(n,e=>{V(y)&&e(r)});var i=z(n,2),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(t),B((e,t,n)=>{G(a,e),G(s,t),G(l,n)},[()=>Y(`common.cancel`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),H(`click`,i,()=>V(_).cancelEdit()),H(`click`,o,()=>V(_).openSnippets()),H(`click`,c,()=>V(_).save()),W(e,t)};K(i,e=>{V(v)&&e(a)}),W(e,t)},ue=e=>{var t=ef(),n=R(t),i=L(n);Di(i);var a=z(i,2);Di(a),Oi(a,r);var s=z(a,2),d=L(s),f=L(d,!0);j(d);var p=z(d,2);Di(p),j(s);var m=z(s,2),g=L(m),_=L(g,!0);j(g);var v=z(g,2);yn(v),Vi(v,e=>F(b,e),()=>V(b)),j(m);var y=z(m,2),S=L(y),C=L(S,!0);j(S);var w=z(S,2),T=L(w,!0);j(w);var E=z(w,2),ee=L(E,!0);j(E),j(y),j(n),gd(z(n,2),{get open(){return V(x)},get editor(){return V(b)},mode:`insert`,get content(){return V(u)},onclose:()=>F(x,!1)}),B((e,t,n,r,a)=>{Oi(i,V(l)),G(f,e),G(_,t),G(C,n),G(T,r),G(ee,a)},[()=>Y(`blueprint.adr.title_label`),()=>Y(`blueprint.adr.content_label`),()=>Y(`common.cancel`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),Nr(`submit`,n,ne),Ni(p,()=>V(c),e=>F(c,e)),Ni(v,()=>V(u),e=>F(u,e)),H(`click`,S,()=>{V(h)?F(o,`doc`):D()}),H(`click`,w,()=>F(x,!0)),W(e,t)},de=e=>{var t=tf(),n=L(t);ai(n,()=>Y(`blueprint.adr.folder_missing`,{name:V(p)}),!0),j(n);var r=z(n,2),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(a),j(t),B((e,t,n)=>{G(i,e),G(s,t),G(l,n)},[()=>Y(`blueprint.adr.folder_create_prompt`),()=>Y(`common.cancel`),()=>Y(`blueprint.adr.create_folder_btn`)]),H(`click`,o,D),H(`click`,c,te),W(e,t)};K(ce,e=>{V(o)===`doc`?e(le):V(o)===`form`?e(ue,1):V(o)===`folder-confirm`&&e(de,2)}),j(n),j(t),H(`click`,t,e=>{e.target===e.currentTarget&&D()}),H(`click`,se,D),W(e,t)};K(ae,e=>{V(o)!==`closed`&&e(oe)});var se=z(ae,2),ce=e=>{var t=rf(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var c=z(a,2),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d,!0);j(d),j(c),j(n),j(t),B((e,t,n)=>{G(i,e),G(o,V(s)),G(u,t),G(f,n)},[()=>Y(`doc.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`doc.confirm_delete_btn`)]),H(`click`,t,e=>{e.target===e.currentTarget&&F(S,!1)}),H(`click`,l,()=>F(S,!1)),H(`click`,d,re),W(e,t)};return K(se,e=>{V(S)&&e(ce)}),W(e,ie),Je(k)}Pr([`click`]);var sf=U(`<span class="breadcrumb-sep">›</span>`),cf=U(`<span class="breadcrumb-item current"> </span>`),lf=U(`<button class="breadcrumb-item" type="button"> </button>`),uf=U(`<!> <!>`,1),df=U(`<nav class="breadcrumb"></nav>`),ff=U(`<div class="app-shell"><!> <section class="workspace-shell"><!> <!></section></div> <!>`,1);function pf(e,t){qe(t,!0),Gi(async()=>{try{await ha((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}});let n=P(I([])),r=P(null),i=P(null),a=P(null),o=P(null);function s(e){l(),V(i).loadPath(e,!0)}async function c(e){F(r,e.folder.path,!0),await xr(),await V(a).open(e.folder.path)}function l(){F(r,null)}async function u(e){await V(i).navigateToFolder(e)}var d=ff(),f=R(d),p=L(f);{let e=N(()=>Y(`blueprint.subtitle`));so(p,{title:`Blueprint`,get subtitle(){return V(e)},children:(e,t)=>{var r=df();q(r,21,()=>V(n),Xr,(e,t,r)=>{var i=uf(),a=R(i),o=e=>{W(e,sf())};K(a,e=>{r>0&&e(o)});var c=z(a,2),l=e=>{var n=cf(),r=L(n,!0);j(n),B(()=>G(r,V(t).name)),W(e,n)},u=e=>{var n=lf(),r=L(n,!0);j(n),B(()=>G(r,V(t).name)),H(`click`,n,()=>s(V(t).path)),W(e,n)};K(c,e=>{r===V(n).length-1?e(l):e(u,-1)}),W(e,i)}),j(r),W(e,r)},$$slots:{default:!0}})}var m=z(p,2),h=L(m);Vi(zo(h,{get activeExplorerPath(){return V(r)},onbreadcrumbchange:e=>F(n,e,!0),onopenexplorer:c,onclosefilerexplorer:l,onopenAdr:e=>V(o).open(e)}),e=>F(i,e,!0),()=>V(i));var g=z(h,2),_=e=>{Vi(as(e,{onclose:l,onnavigate:u}),e=>F(a,e,!0),()=>V(a))};K(g,e=>{V(r)!==null&&e(_)}),j(m),j(f),Vi(of(z(f,2),{onchanged:()=>V(i).loadPath(V(n).at(-1)?.path??``,!1)}),e=>F(o,e,!0),()=>V(o)),W(e,d),Je()}Pr([`click`]);var mf=164,hf=64,gf=132,_f=78,vf=6,yf=24,bf=96,xf=540,Sf=780,Cf=1/2,wf=9999,Tf=44,Ef=255,Df=178,Of=Math.PI*.7,kf=Math.PI*1.1,Af=Math.PI*1.45,jf=Math.PI*1.75,Mf=14,Nf=260,Pf=56,Ff=32,If=[`pointerdown`,`mousedown`,`click`,`dblclick`,`touchstart`,`wheel`],Lf=.35,Rf=2.2,zf=.0018,Bf=4,Vf=46,Hf=4,Uf=44,Wf=360,Gf=300,Kf=44,qf=48,Jf=7,Yf=875,Xf=450,Zf=600*1e3,Qf,Z,$f,ep,tp,np,rp,ip,ap,op,sp,cp,lp,up,dp,fp,pp,mp,hp,gp,_p,vp,yp,bp,xp,Sp,Cp,wp,Tp=null,Ep=null,Dp=null,Q,$,Op,kp=!1;function Ap(){return Qf=document.getElementById(`workspaceCanvas`),Z=Qf.getContext(`2d`),$f=document.getElementById(`apiStatus`),ep=document.getElementById(`addButton`),tp=document.getElementById(`fitButton`),np=document.getElementById(`testNodeButton`),rp=document.getElementById(`loadModelsButton`),ip=document.getElementById(`closePanelButton`),ap=document.getElementById(`deleteNodeButton`),op=document.getElementById(`renameConfirmOverlay`),sp=document.getElementById(`renameConfirmMessage`),cp=document.getElementById(`cancelRenameButton`),lp=document.getElementById(`confirmRenameButton`),up=document.getElementById(`deleteConfirmOverlay`),dp=document.getElementById(`deleteConfirmMessage`),fp=document.getElementById(`cancelDeleteButton`),pp=document.getElementById(`confirmDeleteButton`),mp=document.getElementById(`agentRunOverlay`),hp=document.getElementById(`agentRunTitle`),gp=document.getElementById(`agentRunHint`),_p=document.getElementById(`agentRunInputField`),vp=document.getElementById(`agentRunInput`),yp=document.getElementById(`agentRunResult`),bp=document.getElementById(`cancelAgentRunButton`),xp=document.getElementById(`executeAgentRunButton`),Sp=document.getElementById(`fallbackPanelHost`),Cp=document.getElementById(`configSurface`),wp=Cp,Tp=null,Ep=null,Dp=null,Q={name:document.getElementById(`nodeName`),kind:document.getElementById(`nodeKind`),providerIdField:document.getElementById(`providerIdField`),providerId:document.getElementById(`nodeProviderId`),copyProviderId:document.getElementById(`copyProviderIdButton`),endpoint:document.getElementById(`nodeEndpoint`),token:document.getElementById(`nodeToken`),model:document.getElementById(`nodeModel`),providerTypeChat:document.getElementById(`nodeProviderTypeChat`),providerTypeImage:document.getElementById(`nodeProviderTypeImage`),toolModeField:document.getElementById(`toolModeField`),toolModeTools:document.getElementById(`nodeToolModeTools`),toolModeChat:document.getElementById(`nodeToolModeChat`),workspaceField:document.getElementById(`agentWorkspaceField`),workspaceFolder:document.getElementById(`nodeWorkspaceFolder`),timeout:document.getElementById(`nodeTimeout`),description:document.getElementById(`nodeDescription`),typeBadge:document.getElementById(`nodeTypeBadge`),llmFields:document.getElementById(`llmFields`),mcpInventory:document.getElementById(`mcpInventory`),mcpInventoryStatus:document.getElementById(`mcpInventoryStatus`),mcpToolsList:document.getElementById(`mcpToolsList`),mcpPromptsList:document.getElementById(`mcpPromptsList`),agentSection:document.getElementById(`agentSection`),agentProvider:document.getElementById(`nodeAgentProvider`),systemPrompt:document.getElementById(`nodeSystemPrompt`),requiresUserInput:document.getElementById(`nodeRequiresUserInput`),userInputDescriptionField:document.getElementById(`agentUserInputDescriptionField`),userInputDescription:document.getElementById(`nodeUserInputDescription`),expectedOutputMarker:document.getElementById(`nodeExpectedOutputMarker`)},$={entities:Xp([Yp(`root`,`Living AI Documentation`,`system`,null),Yp(`mcp`,`MCP`,`mcp`,`root`)]),selectedId:null,cameraX:0,cameraY:0,zoom:1,isPanning:!1,panStartX:0,panStartY:0,panStartCameraX:0,panStartCameraY:0,didPan:!1,viewAnimationId:null,dpr:window.devicePixelRatio||1,apiMode:`fallback`,lastSaveAt:null,pendingDeleteId:null,panelShiftX:0,saveTimerId:null,panelDirty:!1,isHydrated:!1},kp=!!Qf.requestPaint&&typeof Z.drawElementImage==`function`,kp?($.apiMode=`html-in-canvas`,$f.textContent=`HTML-in-Canvas active`,$f.classList.add(`is-live`),Qf.onpaint=eh):(Sp.appendChild(Cp),$f.textContent=`DOM fallback`,$f.classList.add(`is-fallback`)),Op=new ResizeObserver(([e])=>{let t=e.devicePixelContentBoxSize?.[0],n=e.contentRect.width,r=e.contentRect.height;$.dpr=t?t.inlineSize/n:window.devicePixelRatio||1,Qf.width=t?t.inlineSize:Math.floor(n*$.dpr),Qf.height=t?t.blockSize:Math.floor(r*$.dpr),im(),uh(!1,!$.cameraX&&!$.cameraY),$m()}),Op.observe(Qf,{box:`device-pixel-content-box`}),jp(),Mp(),ep.addEventListener(`click`,()=>{tm()}),tp.addEventListener(`click`,()=>{im(),uh(!0,!0),Lp(),$m()}),Qf.addEventListener(`pointerdown`,e=>{if(e.target!==Qf)return;let t=Nh(e),n=bh(t),r=[...$.entities].reverse().find(e=>Eh(e,n));if(r){r.id!==`root`&&gm(r.id);return}$.isPanning=!0,$.didPan=!1,$.panStartX=t.x,$.panStartY=t.y,$.panStartCameraX=$.cameraX,$.panStartCameraY=$.cameraY,Qf.classList.add(`is-panning`),Qf.setPointerCapture?.(e.pointerId)}),Qf.addEventListener(`pointermove`,e=>{if(!$.isPanning)return;let t=Nh(e),n=t.x-$.panStartX,r=t.y-$.panStartY;Math.hypot(n,r)>Bf&&($.didPan=!0),$.cameraX=$.panStartCameraX+n,$.cameraY=$.panStartCameraY+r,$m()}),Qf.addEventListener(`pointerup`,e=>{$.isPanning&&($.isPanning=!1,Qf.classList.remove(`is-panning`),Qf.releasePointerCapture?.(e.pointerId),!$.didPan&&$.selectedId?gm(null):$.didPan&&Lp())}),Qf.addEventListener(`pointercancel`,e=>{$.isPanning=!1,Qf.classList.remove(`is-panning`),Qf.releasePointerCapture?.(e.pointerId)}),Qf.addEventListener(`wheel`,e=>{e.target===Qf&&(e.preventDefault(),yh(Nh(e),Math.exp(-e.deltaY*zf)),Lp())},{passive:!1}),wp.addEventListener(`submit`,e=>{e.preventDefault(),wm(),$.lastSaveAt=new Date,im(),zp(!0),$m()}),wp.addEventListener(`input`,()=>{wm(),im(),$.panelDirty=!0,$m()}),ip.addEventListener(`click`,()=>{gm(null)}),ap.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let t=$.selectedId,n=t?Ym(t):null;!n||Xm(t)||_m(n)}),fp.addEventListener(`click`,vm),up.addEventListener(`click`,e=>{e.target===up&&vm()}),pp.addEventListener(`click`,()=>{$.pendingDeleteId&&ym($.pendingDeleteId),vm()}),np.addEventListener(`click`,()=>{if(Jm()?.kind===`agent`){Am();return}Um()}),rp.addEventListener(`click`,()=>{Hm()}),Q.copyProviderId.addEventListener(`click`,()=>{Gm()}),Q.name.addEventListener(`blur`,()=>{if(Jm()?.kind!==`agent`)return;let e=Q.name.value.trim();if(!e||!Tp||!Ep||e===Tp)return;let t=Qp(e);t!==Ep&&(sp.textContent=`Renommer le dossier "${Ep}" en "${t}" ?`,op.hidden=!1,cp.focus())}),cp.addEventListener(`click`,()=>{op.hidden=!0;let e=Jm();e&&Tp&&(e.label=Tp,Q.name.value=Tp,im(),$m())}),lp.addEventListener(`click`,()=>{op.hidden=!0;let e=Jm();if(!e||!Ep)return;e.config.workspaceFolder=Ep,Q.workspaceFolder.value=Ep;let t=Q.name.value.trim();t&&(Tp=t),Ep=Qp(t),Lp()}),Q.model.addEventListener(`change`,()=>{np.disabled=!Q.model.value;let e=Jm();e&&(e.config.model=Q.model.value)}),Q.agentProvider.addEventListener(`change`,()=>{Em(Q.agentProvider.value)}),bp.addEventListener(`click`,()=>{jm()}),xp.addEventListener(`click`,()=>{Mm()}),mp.addEventListener(`click`,e=>{e.target===mp&&jm()}),Pp(),()=>{Rp(),Op.disconnect(),$?.saveTimerId&&clearTimeout($.saveTimerId)}}function jp(){for(let e of If)Cp.addEventListener(e,Np),Sp.addEventListener(e,Np)}function Mp(){for(let e of If)up.addEventListener(e,Np),op.addEventListener(e,Np),mp.addEventListener(e,Np)}function Np(e){e.stopPropagation()}async function Pp(){let e=await La();e?.entities?.length&&($.entities=Fp(e.entities),$.cameraX=Jp(e.camera?.x,$.cameraX),$.cameraY=Jp(e.camera?.y,$.cameraY),$.zoom=xh(Jp(e.camera?.zoom,$.zoom),Lf,Rf),$.lastSaveAt=e.updatedAt?new Date(e.updatedAt):null),$.isHydrated=!0,im(),e?.entities?.length||uh(!1,!0),Cm(),$m()}function Fp(e){let t=e.map(Ip).filter(e=>!!e),n=t.some(e=>e.id===`root`),r=t.some(e=>e.id===`mcp`),i=[...n?[]:[Yp(`root`,`Living AI Documentation`,`system`,null)],...t,...r?[]:[Yp(`mcp`,`MCP`,`mcp`,`root`)]],a=new Set(i.map(e=>e.id));return i.map(e=>{let t=e.id===`root`?`system`:e.id===`mcp`?`mcp`:e.kind,n=e.id===`root`?null:e.id===`mcp`?`root`:e.parentId&&a.has(e.parentId)?e.parentId:null;return{...e,kind:t,parentId:n,config:{...Yp(e.id,e.label,t,n).config,...e.config}}})}function Ip(e){if(!Up(e))return null;let t=Wp(e.id),n=Wp(e.label),r=Gp(e.kind);if(!t||!n||!r)return null;let i=e.parentId===null?null:Wp(e.parentId),a=Up(e.config)?e.config:{};return{id:t,label:n,kind:r,parentId:i,x:Jp(e.x,0),y:Jp(e.y,0),angle:Jp(e.angle,0),config:{endpoint:Wp(a.endpoint)||Zp(t,r),token:Wp(a.token),model:Wp(a.model),providerType:qp(a.providerType),toolMode:Kp(a.toolMode),timeout:Jp(a.timeout,180),description:Wp(a.description)||em(r),workspaceFolder:Wp(a.workspaceFolder)||(r===`agent`?Qp(n):``),systemPrompt:Wp(a.systemPrompt),requiresUserInput:a.requiresUserInput===!0,userInputDescription:Wp(a.userInputDescription),expectedOutputMarker:Wp(a.expectedOutputMarker)}}}function Lp(){$.isHydrated&&($.saveTimerId&&clearTimeout($.saveTimerId),$.saveTimerId=window.setTimeout(()=>{$.saveTimerId=null,zp(!1)},Xf))}function Rp(){$.panelDirty&&zp(!1)}async function zp(e=!1){if(!$.isHydrated)return;$.panelDirty=!1,$.saveTimerId&&(clearTimeout($.saveTimerId),$.saveTimerId=null);let t=$.selectedId&&document.activeElement===Q.token&&zm(Q.token.value)?{entityId:$.selectedId,value:Q.token.value,selectionStart:Q.token.selectionStart,selectionEnd:Q.token.selectionEnd}:null,n=await Ra(Hp());if(n){if($.entities=Fp(n.entities),t&&$.selectedId===t.entityId){let e=Jm();e?.kind===`llm`&&(e.config.token=t.value)}$.lastSaveAt=new Date(n.updatedAt),Jm()&&!wp.contains(document.activeElement)&&Cm(),t&&$.selectedId===t.entityId&&(Q.token.value=t.value,Q.token.setSelectionRange(t.selectionStart,t.selectionEnd)),e&&Vp(`Workspace saved`)}else e&&Vp(`Save failed`)}function Bp(e,t){return Pa(e,t)}function Vp(e,t=`success`,n,r){return Fa(e,t,n,r)}function Hp(){return{version:1,updatedAt:new Date().toISOString(),entities:$.entities.map(e=>{let t={...e.config,token:Bm(e.config.token)};return{id:e.id,label:e.label,kind:e.kind,parentId:e.parentId,x:e.x,y:e.y,angle:e.angle,config:t}}),camera:{x:$.cameraX,y:$.cameraY,zoom:$.zoom}}}function Up(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Wp(e){return typeof e==`string`?e:``}function Gp(e){return e===`system`||e===`llm`||e===`agent`||e===`mcp`?e:null}function Kp(e){return e===`chat`?`chat`:`tools`}function qp(e){return e===`image`?`image`:`chat`}function Jp(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function Yp(e,t,n,r){return{id:e,label:t,kind:n,parentId:r,x:0,y:0,angle:0,config:{endpoint:Zp(e,n),token:``,model:``,providerType:`chat`,toolMode:`tools`,timeout:180,description:em(n),workspaceFolder:n===`agent`?Qp(t):``,systemPrompt:``,requiresUserInput:!1,userInputDescription:``,expectedOutputMarker:``}}}function Xp(e){return e.map(e=>({...e,config:{...e.config}}))}function Zp(e,t){return t===`llm`?`http://localhost:11434`:t===`mcp`?`http://localhost:4321/mcp`:``}function Qp(e){return`AI/WORKSPACE/${$p(e)}`}function $p(e){return e.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`llm_provider`}function em(e){let t={system:`Owns the documentation workspace, MCP access, providers, and agent topology.`,llm:`Routes model calls and hosts the agents assigned to this provider.`,agent:`Runs focused automation against documentation, source, or quality signals.`,mcp:`Exposes the local Living Documentation MCP consultation panel to agents.`};return t[e]||t.agent}function tm(){let e=Jm(),t=e?.kind===`llm`?e:Ym(e?.parentId);if(t?.kind===`llm`&&t.config.providerType!==`image`){rm(t.id);return}nm()}function nm(){let e=!!$.selectedId,t=Zm(`root`).filter(e=>e.kind===`llm`).length+1,n=Yp(`provider-${Date.now().toString(36)}`,`LLM Provider ${t}`,`llm`,`root`);$.entities=[...$.entities,n],$.selectedId=n.id,im(),dh(e,!0,!0),Cm(),Lp(),$m()}function rm(e){let t=!!$.selectedId,n=Zm(e).filter(e=>e.kind===`agent`).length+1,r=Yp(`agent-${Date.now().toString(36)}`,`Agent ${n}`,`agent`,e);$.entities=[...$.entities,r],$.selectedId=r.id,im(),dh(t,!0,!0),Cm(),Lp(),$m()}function im(){let e=Ym(`root`);e.x=0,e.y=0,e.angle=0,am(e)}function am(e){let t=Zm(e.id),n=dm(t,gf,Ef,{spread:Math.PI*2,includeSubtree:!1}),r=new Map(t.map(e=>[e.id,lm(e,n)]));for(let n=0;n<=Jf;n+=1)if(om(e,t,r),sm(),!cm(t,r))return;om(e,t,r),sm()}function om(e,t,n){let r=Math.max(1,t.length);t.forEach((t,i)=>{let a=-Math.PI/2+i/r*Math.PI*2,o=n.get(t.id)||Ef;t.angle=a,t.x=e.x+Math.cos(a)*o,t.y=e.y+Math.sin(a)*o})}function sm(){for(let e of $.entities.filter(e=>e.kind===`llm`))um(e)}function cm(e,t){let n=!1;for(let r=0;r<e.length;r+=1)for(let i=r+1;i<e.length;i+=1){let a=e[r],o=e[i];Mh(kh(a),kh(o),Kf)&&(t.set(a.id,Math.min(Yf,t.get(a.id)+qf)),t.set(o.id,Math.min(Yf,t.get(o.id)+qf)),n=!0)}return n}function lm(e,t){if(e.kind!==`llm`)return t;let n=Zm(e.id).length;if(n<=Hf)return t;let r=(n-Hf)*Uf,i=Math.max(0,mm(e)-Gf)*.65;return t+Math.min(Wf,Math.max(r,i))}function um(e){let t=Zm(e.id);if(!t.length)return;let n=Math.atan2(e.y,e.x),r=fm(t.length),i=dm(t,_f,Df,{spread:r,includeSubtree:!1});t.forEach((a,o)=>{let s=pm(n,r,o,t.length);a.angle=s,a.x=e.x+Math.cos(s)*i,a.y=e.y+Math.sin(s)*i})}function dm(e,t,n,r={}){if(!e.length)return n;let i=!!r.includeSubtree,a=r.spread||Math.PI*2,o=Math.max(...e.map(e=>i?mm(e):hm(e))),s=t+o+Vf;if(e.length===1)return Math.max(n,s);let c=o*2+Vf,l=a>=Math.PI*2-.001?Math.PI*2/e.length:a/(e.length-1),u=c/(2*Math.sin(l/2));return Math.max(n,s,u)}function fm(e){return e<=1?0:e<=2?Of:e<=4?kf:e<=7?Af:jf}function pm(e,t,n,r){return r<=1||t===0?e:e-t/2+n/(r-1)*t}function mm(e){if(e.kind!==`llm`)return hm(e);let t=Zm(e.id);return t.length?dm(t,_f,Df,{spread:fm(t.length),includeSubtree:!1})+Math.max(...t.map(e=>hm(e))):_f}function hm(e){if(e.kind===`system`)return gf;if(e.kind===`llm`)return _f;let{width:t,height:n}=Oh(e);return Math.hypot(t/2,n/2)}function gm(e){e!==$.selectedId&&Rp();let t=!!$.selectedId;$.selectedId=e;let n=e?Ym(e):null;Tp=n?.kind===`agent`?n.label:null,Ep=n?.kind===`agent`?n.config.workspaceFolder||Qp(n.label):null,im(),dh(t,!!e,!0),Cm(),$m()}function _m(e){let t=Qm(e.id),n=Zm(e.id).length,r=t.length?` This node has ${n} direct child${n===1?``:`ren`} and ${t.length} total descendant${t.length===1?``:`s`}; they will also be deleted.`:` This node has no children.`;$.pendingDeleteId=e.id,dp.textContent=`You are about to delete "${e.label}".${r} This action cannot be undone.`,up.hidden=!1,pp.focus()}function vm(){$.pendingDeleteId=null,up.hidden=!0}function ym(e){let t=Ym(e);if(!t||Xm(e))return;let n=t.parentId||`root`,r=!!$.selectedId,i=new Set([e,...Qm(e)]);$.entities=$.entities.filter(e=>!i.has(e.id)),$.selectedId=Ym(n)?n:null,im(),dh(r,!!$.selectedId,!0),Cm(),Lp(),$m()}var bm=0;async function xm(e){let t=++bm,n=e.config.endpoint.trim(),r=Q.mcpInventoryStatus;if(Q.mcpToolsList.replaceChildren(),Q.mcpPromptsList.replaceChildren(),!n){r.hidden=!1,r.textContent=`Set an endpoint to load the MCP tools and prompts.`;return}r.hidden=!1,r.textContent=`Loading MCP tools and prompts…`;let i=await Ba({endpoint:n});if(t===bm){if(!i.ok){r.hidden=!1,r.textContent=i.error?`Failed to load MCP inventory: ${i.error}`:`Failed to load MCP inventory.`;return}r.hidden=!0,Sm(Q.mcpToolsList,i.tools??[],`No tools exposed.`),Sm(Q.mcpPromptsList,i.prompts??[],`No prompts exposed.`)}}function Sm(e,t,n){if(e.replaceChildren(),t.length===0){let t=document.createElement(`li`);t.className=`inventory-empty`,t.textContent=n,e.appendChild(t);return}for(let n of t){let t=document.createElement(`li`);t.textContent=n,e.appendChild(t)}}function Cm(){let e=Jm(),t=!!e;if(Cp.hidden=!t,Sp.hidden=!t||kp,!e){ep.title=`Add LLM provider`,np.textContent=`Test`,np.hidden=!0,np.disabled=!0;return}Q.name.value=e.label,Q.kind.value=e.kind,Q.providerId.value=e.kind===`llm`?e.id:``,Q.endpoint.value=e.config.endpoint,Q.token.value=e.config.token,km(e.config.model),Q.providerTypeChat.checked=e.config.providerType!==`image`,Q.providerTypeImage.checked=e.config.providerType===`image`,Q.toolModeTools.checked=e.config.toolMode!==`chat`,Q.toolModeChat.checked=e.config.toolMode===`chat`,Q.workspaceFolder.value=e.config.workspaceFolder,Q.workspaceField.hidden=e.kind!==`agent`,Q.timeout.value=String(e.config.timeout),Q.description.value=e.config.description,Q.typeBadge.textContent=qm(e),Q.kind.disabled=!0,Q.llmFields.hidden=e.kind===`mcp`||e.kind===`agent`,Om(e),Q.mcpInventory.hidden=e.kind!==`mcp`,e.kind===`mcp`?xm(e):bm+=1,Q.agentSection.hidden=e.kind!==`agent`,e.kind===`agent`&&Tm(e),Q.systemPrompt.value=e.config.systemPrompt,Q.requiresUserInput.checked=e.config.requiresUserInput,Dm(),Q.userInputDescription.value=e.config.userInputDescription,Q.expectedOutputMarker.value=e.config.expectedOutputMarker,ap.hidden=Xm(e.id),np.textContent=`Test`,np.hidden=e.kind!==`llm`&&e.kind!==`agent`,np.disabled=e.kind===`llm`?!e.config.model:e.kind!==`agent`;let n=e.kind===`llm`?e:Ym(e.parentId);ep.title=n?.kind===`llm`&&n.config.providerType!==`image`?`Add agent`:`Add LLM provider`}function wm(){let e=Jm();if(e&&(e.label=Q.name.value.trim()||`Untitled node`,e.kind=Q.kind.value,e.config.endpoint=Q.endpoint.value,e.config.token=Q.token.value,e.config.model=Q.model.value,e.config.providerType=Q.providerTypeImage.checked?`image`:`chat`,e.config.toolMode=Q.toolModeChat.checked?`chat`:`tools`,e.config.timeout=Number(Q.timeout.value||30),e.config.description=Q.description.value,e.config.systemPrompt=Q.systemPrompt.value,e.config.requiresUserInput=Q.requiresUserInput.checked,e.config.userInputDescription=Q.userInputDescription.value,e.config.expectedOutputMarker=Q.expectedOutputMarker.value,Dm(),Om(e),Q.typeBadge.textContent=qm(e),e.kind===`llm`))for(let t of $.entities)t.parentId===e.id&&t.kind===`agent`&&(t.config.model=e.config.model,t.config.timeout=e.config.timeout)}function Tm(e){let t=Q.agentProvider;t.innerHTML=``;let n=$.entities.filter(e=>e.kind===`llm`&&e.config.providerType!==`image`);for(let e of n){let n=document.createElement(`option`);n.value=e.id,n.textContent=e.label,t.appendChild(n)}t.value=e.parentId??``}function Em(e){let t=Jm();if(t?.kind!==`agent`)return;let n=Ym(e);n?.kind===`llm`&&t.parentId!==e&&(t.parentId=e,t.config.model=n.config.model,t.config.timeout=n.config.timeout,im(),Lp(),$m())}function Dm(){let e=Jm()?.kind===`agent`&&Q.requiresUserInput.checked;Q.userInputDescriptionField.hidden=!e,Q.userInputDescription.required=e}function Om(e){let t=e.kind===`llm`,n=e.config.providerType===`image`;Q.providerIdField.hidden=!t,Q.toolModeField.hidden=!t||n,rp.title=n?`Load image models from endpoint`:`Load chat models from endpoint`,np.title=n?`Test image provider configuration`:`Test chat provider configuration`}function km(e){let t=Array.from(Q.model.options).map(e=>e.value);if(e&&!t.includes(e)){Q.model.innerHTML=``;let t=document.createElement(`option`);t.value=e,t.textContent=e,Q.model.appendChild(t)}Q.model.value=e||(t[0]??``)}function Am(){let e=Jm();if(e?.kind!==`agent`)return;wm();let t=Ym(e.parentId??``);if(t?.kind!==`llm`){Vp(`No parent LLM found for this agent.`,`error`);return}if(!t.config.model){Vp(`Parent LLM has no model selected.`,`error`);return}if(!e.config.systemPrompt.trim()){Vp(`Write a system prompt first.`,`error`);return}if(e.config.requiresUserInput&&!e.config.userInputDescription.trim()){Vp(`Describe the required user input first.`,`error`);return}Dp=e.id,hp.textContent=`Test ${e.label}`,gp.textContent=e.config.requiresUserInput?e.config.userInputDescription:`Run this agent with its configured system prompt.`,_p.hidden=!e.config.requiresUserInput,vp.required=e.config.requiresUserInput,vp.value=``,yp.hidden=!0,yp.textContent=``,xp.disabled=!1,xp.textContent=`Run`,mp.hidden=!1,e.config.requiresUserInput?window.setTimeout(()=>vp.focus(),0):window.setTimeout(()=>xp.focus(),0)}function jm(){mp.hidden=!0,Dp=null}async function Mm(){if(vp.required&&!vp.value.trim()){vp.reportValidity();return}let e=Dp?Ym(Dp):null;if(e?.kind!==`agent`){Lm(`error`,`The selected agent is no longer available.`);return}let t=Ym(e.parentId??``);if(t?.kind!==`llm`){Lm(`error`,`No parent LLM found for this agent.`);return}xp.disabled=!0,xp.textContent=`Running…`;let n=Bp(`Running agent…`);Pm();let r=$.entities.find(e=>e.kind===`mcp`),i=!1,a=await Va({providerId:t.id,endpoint:t.config.endpoint,model:t.config.model,systemPrompt:e.config.systemPrompt,userInput:vp.value.trim()||void 0,timeout:t.config.timeout,mcpEndpoint:t.config.toolMode===`chat`?void 0:r?.config.endpoint||void 0,toolMode:t.config.toolMode,expectedOutputMarker:e.config.expectedOutputMarker||void 0},e=>{e.type===`error`&&(i=!0),e.type!==`final`&&e.type!==`error`&&Bp(Nm(e),n),Fm(e)});xp.disabled=!1,xp.textContent=`Run`,a.ok&&a.content?(Im(a.content),Vp(`Agent responded. Result saved in AI/WORKSPACE.`,`success`,Zf,n)):(i||Fm({type:`error`,message:a.error??`Agent failed.`}),yp.dataset.state=`error`,Vp(a.error??`Agent failed.`,`error`,Zf,n))}function Nm(e){return e.type===`tool_call`&&e.toolName?`Agent tool call: ${e.toolName}`:e.type===`tool_result`&&e.toolName?`Agent tool result: ${e.toolName}`:`Agent: ${e.message}`}function Pm(){yp.hidden=!1,yp.dataset.state=`loading`,yp.textContent=``,Fm({type:`status`,message:`Preparing agent request`})}function Fm(e){yp.hidden=!1,e.type===`error`&&(yp.dataset.state=`error`);let t=document.createElement(`div`);t.className=`agent-run-event agent-run-event-${e.type.replace(`_`,`-`)}`;let n=document.createElement(`span`);n.className=`agent-run-event-dot`,n.setAttribute(`aria-hidden`,`true`);let r=document.createElement(`div`);r.className=`agent-run-event-body`;let i=document.createElement(`p`);i.className=`agent-run-event-title`,i.textContent=e.message,r.appendChild(i);let a=[];if(e.turn&&a.push(`Turn ${e.turn}`),e.toolName&&a.push(e.toolName),e.detail&&a.push(e.detail),a.length){let e=document.createElement(`p`);e.className=`agent-run-event-meta`,e.textContent=a.join(` · `),r.appendChild(e)}t.append(n,r),yp.appendChild(t),yp.scrollTop=yp.scrollHeight}function Im(e){yp.dataset.state=`success`;let t=document.createElement(`section`);t.className=`agent-run-final`;let n=document.createElement(`h3`);n.textContent=`Final response`;let r=document.createElement(`pre`);r.textContent=e,t.append(n,r),yp.appendChild(t),yp.scrollTop=yp.scrollHeight}function Lm(e,t){yp.hidden=!1,yp.dataset.state=e,yp.textContent=t}var Rm=/^(?:env:[A-Za-z_][A-Za-z0-9_]*|\$\{[A-Za-z_][A-Za-z0-9_]*\})$/;function zm(e){let t=e.trim();return t!==``&&!Rm.test(t)}function Bm(e){let t=e.trim();return zm(t)?``:t}var Vm=`API token must reference an environment variable, e.g. env:LLM_API_KEY`;async function Hm(){let e=Jm();if(e?.kind!==`llm`)return;wm();let t=e.config.endpoint;if(!t){Vp(`Set an endpoint first.`);return}if(zm(e.config.token)){Vp(Vm);return}rp.classList.add(`loading`),rp.disabled=!0,Q.model.disabled=!0;let n=await za({endpoint:t,token:e.config.token,providerType:e.config.providerType});if(rp.classList.remove(`loading`),rp.disabled=!1,Q.model.disabled=!1,!n.ok||!n.models?.length){Vp(n.error??`No models found.`);return}let r=Q.model.value;Q.model.innerHTML=``;for(let e of n.models){let t=document.createElement(`option`);t.value=e,t.textContent=e,Q.model.appendChild(t)}Q.model.value=n.models.includes(r)?r:n.models[0],e.config.model=Q.model.value,np.disabled=!Q.model.value,Vp(`${n.models.length} model${n.models.length===1?``:`s`} loaded.`),$m()}async function Um(){let e=Jm();if(e?.kind!==`llm`)return;if(wm(),zm(e.config.token)){Vp(Vm);return}np.disabled=!0,Bp(`Testing ${e.config.model}…`),$m();let t=e.config.providerType===`image`?await Wm(e):await Ua({endpoint:e.config.endpoint,token:e.config.token,model:e.config.model,timeout:e.config.timeout});np.disabled=!1,t.ok?Vp(t.detail??`Connection OK`,`success`):Vp(t.error||`Connection failed (${t.status||`no status`})`,`error`),$m()}async function Wm(e){let t=await za({endpoint:e.config.endpoint,token:e.config.token,providerType:`image`});if(!t.ok)return{ok:!1,error:t.error??`Image provider test failed`};let n=e.config.model.trim();return n&&t.models?.length&&!t.models.includes(n)?{ok:!1,error:`Image models loaded, but "${n}" was not found.`}:{ok:!0,detail:`${t.models?.length??0} image model${t.models?.length===1?``:`s`} available`}}async function Gm(){let e=Jm();if(e?.kind===`llm`)try{await navigator.clipboard.writeText(e.id),Vp(`Provider ID copied`,`success`)}catch{Q.providerId.select(),Vp(`Provider ID selected`,`success`)}}function Km(e){return{system:`System`,llm:`LLM provider`,agent:`Agent`,mcp:`MCP`}[e]||`Node`}function qm(e){return e.kind===`llm`&&e.config.providerType===`image`?`Image provider`:Km(e.kind)}function Jm(){return $.selectedId?Ym($.selectedId):null}function Ym(e){return $.entities.find(t=>t.id===e)}function Xm(e){return e===`root`||e===`mcp`}function Zm(e){return $.entities.filter(t=>t.parentId===e)}function Qm(e){let t=[];for(let n of Zm(e))t.push(n.id,...Qm(n.id));return t}function $m(){kp?Qf.requestPaint():requestAnimationFrame(eh)}function eh(){let e=Qf.width/$.dpr,t=Qf.height/$.dpr;Z.reset(),Z.setTransform($.dpr,0,0,$.dpr,0,0),Z.clearRect(0,0,e,t),Z.save(),Z.translate($.cameraX,$.cameraY),Z.scale($.zoom,$.zoom),th(e,t),nh(),Z.restore(),kp&&lh(e,t)}function th(e,t){Z.save(),Z.lineWidth=1/$.zoom;let n=bh({x:0,y:0}),r=bh({x:e,y:t}),i=Math.floor(n.x/yf)*yf,a=Math.ceil(r.x/yf)*yf,o=Math.floor(n.y/yf)*yf,s=Math.ceil(r.y/yf)*yf;for(let e=i;e<=a;e+=yf)Z.strokeStyle=e%bf===0?`#d7dce5`:`#edf0f4`,Lh(e,o,e,s);for(let e=o;e<=s;e+=yf)Z.strokeStyle=e%bf===0?`#d7dce5`:`#edf0f4`,Lh(i,e,a,e);Z.restore()}function nh(){rh();for(let e of $.entities)ih(e)}function rh(){Z.save(),Z.lineWidth=2/$.zoom;for(let e of $.entities){let t=Ym(e.parentId);if(!t)continue;let n=Math.atan2(e.y-t.y,e.x-t.x),r=Sh(t,n),i=Sh(e,n+Math.PI);Z.strokeStyle=sh(e).connection,Z.beginPath(),Z.moveTo(r.x,r.y),Z.lineTo(i.x,i.y),Z.stroke()}Z.restore()}function ih(e){if(e.kind===`system`||e.kind===`llm`){ah(e);return}oh(e)}function ah(e){let t=e.id===$.selectedId,n=sh(e),r=e.kind===`system`?gf:_f,i=Zm(e.id),a=Math.max(vf,i.length),o=Ph(e.x,e.y,r,a);Z.save(),Z.beginPath(),o.forEach((e,t)=>{t===0?Z.moveTo(e.x,e.y):Z.lineTo(e.x,e.y)}),Z.closePath(),Z.fillStyle=t?n.selectedFill:n.fill,Z.strokeStyle=t?n.selectedStroke:n.stroke,Z.lineWidth=(t?3:2)/$.zoom,Z.shadowColor=n.shadow,Z.shadowBlur=e.kind===`system`?20:14,Z.shadowOffsetY=e.kind===`system`?8:5,Z.fill(),Z.shadowColor=`transparent`,Z.stroke(),Z.fillStyle=t?n.selectedText:n.text,Z.textAlign=`center`,Z.textBaseline=`middle`,Z.font=e.kind===`system`?`800 21px Inter, system-ui, sans-serif`:`800 16px Inter, system-ui, sans-serif`,Ih(e.label,e.x,e.y-8,r*1.32,e.kind===`system`?26:20),ch(e,t,r),Z.restore()}function oh(e){let t=e.id===$.selectedId,n=sh(e),r=e.kind===`mcp`?116:mf,i=e.kind===`mcp`?58:hf;Z.save(),Fh(e.x-r/2,e.y-i/2,r,i,20),Z.fillStyle=t?n.selectedFill:n.fill,Z.strokeStyle=t?n.selectedStroke:n.stroke,Z.lineWidth=(t?3:2)/$.zoom,Z.shadowColor=n.shadow,Z.shadowBlur=10,Z.shadowOffsetY=4,Z.fill(),Z.shadowColor=`transparent`,Z.stroke(),Z.fillStyle=t?n.selectedText:n.text,Z.font=`760 15px Inter, system-ui, sans-serif`,Z.textAlign=`center`,Z.textBaseline=`middle`,Ih(e.label,e.x,e.y,r*.78,18),ch(e,t,Math.max(r,i)/2),Z.restore()}function sh(e){if(e.kind===`system`)return{fill:`#111827`,stroke:`#111827`,selectedFill:`#111827`,selectedStroke:`#111827`,text:`#ffffff`,selectedText:`#ffffff`,shadow:`rgb(17 24 39 / 18%)`,connection:`#475569`};if(e.kind===`llm`&&e.config.providerType===`image`)return{fill:`#facc15`,stroke:`#ca8a04`,selectedFill:`#eab308`,selectedStroke:`#a16207`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(250 204 21 / 22%)`,connection:`#ca8a04`};if(e.kind===`llm`&&e.config.toolMode===`chat`)return{fill:`#f472b6`,stroke:`#db2777`,selectedFill:`#ec4899`,selectedStroke:`#be185d`,text:`#500724`,selectedText:`#500724`,shadow:`rgb(244 114 182 / 20%)`,connection:`#db2777`};if(e.kind===`llm`)return{fill:`#f97316`,stroke:`#ea580c`,selectedFill:`#fb923c`,selectedStroke:`#c2410c`,text:`#431407`,selectedText:`#431407`,shadow:`rgb(249 115 22 / 20%)`,connection:`#ea580c`};if(e.kind===`mcp`)return{fill:`#64748b`,stroke:`#475569`,selectedFill:`#475569`,selectedStroke:`#334155`,text:`#ffffff`,selectedText:`#ffffff`,shadow:`rgb(100 116 139 / 18%)`,connection:`#64748b`};if(e.kind===`agent`){let t=Ym(e.parentId);return t?.kind===`llm`&&t.config.toolMode===`chat`?{fill:`#f9a8d4`,stroke:`#f472b6`,selectedFill:`#ec4899`,selectedStroke:`#db2777`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(244 114 182 / 18%)`,connection:`#f472b6`}:{fill:`#fdba74`,stroke:`#f97316`,selectedFill:`#fb923c`,selectedStroke:`#ea580c`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(249 115 22 / 18%)`,connection:`#f97316`}}return{fill:`#ffffff`,stroke:`#0f172a`,selectedFill:`#111827`,selectedStroke:`#0f172a`,text:`#111827`,selectedText:`#ffffff`,shadow:`rgb(15 23 42 / 8%)`,connection:`#111827`}}function ch(e,t,n){t&&(Z.beginPath(),Z.arc(e.x+n*.62,e.y-n*.66,5,0,Math.PI*2),Z.fillStyle=`#34d399`,Z.fill())}function lh(e,t){if(!Jm())return;let n=Dh(e),r=Math.min(wf,t-118),i=e-n-24,a=Math.max(24,(t-r)/2);try{let e=Z.drawElementImage(Cp,i,a,n,r);Cp.style.transform=e.toString()}catch{$f.textContent=`Waiting for HTML snapshot`}}function uh(e,t){let n=Qf.clientWidth,r=Qf.clientHeight,i=Jm()?Dh(n)+Tf:0,a=Math.max(360,n-i),o=gh(),s=_h(o,a,r),c=t?s:Math.min($.zoom,s),l=(o.minX+o.maxX)/2,u=(o.minY+o.maxY)/2,d=a*.5-l*c,f=r*.5-u*c;if(!e||!$.cameraX||!$.cameraY){vh(),$.cameraX=d,$.cameraY=f,$.zoom=c,$.panelShiftX=i;return}$.panelShiftX=i,hh(d,f,c)}function dh(e,t,n){if(t){if(e){let e=fh();$.panelShiftX+=Math.max(0,-e),mh(e,n)}else{let e=Jm();if(e){let t=Dh(Qf.clientWidth)+Tf,n=(Qf.clientWidth-t)/2-e.x*$.zoom,r=n-$.cameraX;$.panelShiftX=-r,hh(n,$.cameraY,$.zoom)}}return}if(!e)return;let r=$.panelShiftX;$.panelShiftX=0,mh(r,n)}function fh(){let e=Jm();if(!e)return 0;let t=Qf.clientWidth-Dh(Qf.clientWidth)-24-Ff,n=ph(e);return n.right<=t?0:t-n.right}function ph(e){let t=Ah(e);return{left:t.left*$.zoom+$.cameraX,top:t.top*$.zoom+$.cameraY,right:t.right*$.zoom+$.cameraX,bottom:t.bottom*$.zoom+$.cameraY}}function mh(e,t){if(vh(),!e)return;let n=$.cameraX+e;if(!t){$.cameraX=n;return}hh(n,$.cameraY,$.zoom)}function hh(e,t,n){vh();let r=$.cameraX,i=$.cameraY,a=$.zoom,o=performance.now();function s(c){let l=Math.min(1,(c-o)/Nf),u=1-(1-l)**3;$.cameraX=r+(e-r)*u,$.cameraY=i+(t-i)*u,$.zoom=a+(n-a)*u,im(),$m(),l<1?$.viewAnimationId=requestAnimationFrame(s):$.viewAnimationId=null}$.viewAnimationId=requestAnimationFrame(s)}function gh(){return $.entities.reduce((e,t)=>{let n=hm(t);return{minX:Math.min(e.minX,t.x-n),minY:Math.min(e.minY,t.y-n),maxX:Math.max(e.maxX,t.x+n),maxY:Math.max(e.maxY,t.y+n)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0})}function _h(e,t,n){let r=e.maxX-e.minX,i=e.maxY-e.minY;if(!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0)return 1;let a=Math.max(1,t-Pf*2),o=Math.max(1,n-Pf*2);return xh(Math.min(1,a/r,o/i),Lf,1)}function vh(){$.viewAnimationId&&(cancelAnimationFrame($.viewAnimationId),$.viewAnimationId=null)}function yh(e,t){vh();let n=bh(e);$.zoom=xh($.zoom*t,Lf,Rf),$.cameraX=e.x-n.x*$.zoom,$.cameraY=e.y-n.y*$.zoom,$m()}function bh(e){return{x:(e.x-$.cameraX)/$.zoom,y:(e.y-$.cameraY)/$.zoom}}function xh(e,t,n){return Math.min(n,Math.max(t,e))}function Sh(e,t){if(e.kind!==`system`&&e.kind!==`llm`)return Th(e,t);let n=e.kind===`system`?gf:_f,r=Zm(e.id);return Ch(e,n,Math.max(vf,r.length),t)||{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function Ch(e,t,n,r){let i={x:Math.cos(r),y:Math.sin(r)},a=Ph(e.x,e.y,t,n),o=null;for(let t=0;t<a.length;t+=1){let n=a[t],r=a[(t+1)%a.length],s={x:r.x-n.x,y:r.y-n.y},c={x:n.x-e.x,y:n.y-e.y},l=wh(i,s);if(Math.abs(l)<1e-4)continue;let u=wh(c,s)/l,d=wh(c,i)/l;if(u>=0&&d>=0&&d<=1){let t={x:e.x+i.x*u,y:e.y+i.y*u};(!o||u<o.rayDistance)&&(o={...t,rayDistance:u})}}return o?{x:o.x,y:o.y}:null}function wh(e,t){return e.x*t.y-e.y*t.x}function Th(e,t){let n=Oh(e),r=n.width/2,i=n.height/2,a=Math.cos(t),o=Math.sin(t),s=Math.min(Math.abs(r/(a||2**-52)),Math.abs(i/(o||2**-52)));return{x:e.x+a*s,y:e.y+o*s}}function Eh(e,t){if(e.kind===`system`||e.kind===`llm`){let n=e.kind===`system`?gf:_f;return Math.hypot(t.x-e.x,t.y-e.y)<=n+Mf}let{width:n,height:r}=Oh(e);return Math.abs(t.x-e.x)<=n/2+Mf&&Math.abs(t.y-e.y)<=r/2+Mf}function Dh(e){return Math.min(Sf,Math.max(xf,Math.floor(e*Cf)))}function Oh(e){return e.kind===`mcp`?{width:116,height:58}:{width:mf,height:hf}}function kh(e){return[e,...Qm(e.id).map(Ym)].filter(Boolean).map(Ah).reduce(jh)}function Ah(e){if(e.kind===`system`||e.kind===`llm`){let t=e.kind===`system`?gf:_f;return{left:e.x-t,top:e.y-t,right:e.x+t,bottom:e.y+t}}let{width:t,height:n}=Oh(e);return{left:e.x-t/2,top:e.y-n/2,right:e.x+t/2,bottom:e.y+n/2}}function jh(e,t){return{left:Math.min(e.left,t.left),top:Math.min(e.top,t.top),right:Math.max(e.right,t.right),bottom:Math.max(e.bottom,t.bottom)}}function Mh(e,t,n){return!(e.right+n<t.left||e.left-n>t.right||e.bottom+n<t.top||e.top-n>t.bottom)}function Nh(e){let t=Qf.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function Ph(e,t,n,r){return Array.from({length:r},(i,a)=>{let o=-Math.PI/2+a/r*Math.PI*2;return{x:e+Math.cos(o)*n,y:t+Math.sin(o)*n}})}function Fh(e,t,n,r,i){let a=e+n,o=t+r;Z.beginPath(),Z.moveTo(e+i,t),Z.lineTo(a-i,t),Z.quadraticCurveTo(a,t,a,t+i),Z.lineTo(a,o-i),Z.quadraticCurveTo(a,o,a-i,o),Z.lineTo(e+i,o),Z.quadraticCurveTo(e,o,e,o-i),Z.lineTo(e,t+i),Z.quadraticCurveTo(e,t,e+i,t),Z.closePath()}function Ih(e,t,n,r,i){let a=e.split(/\s+/),o=[],s=``;for(let e of a){let t=s?`${s} ${e}`:e;Z.measureText(t).width>r&&s?(o.push(s),s=e):s=t}o.push(s);let c=n-(o.length-1)*i/2;o.forEach((e,n)=>{Z.fillText(e,t,c+n*i)})}function Lh(e,t,n,r){Z.beginPath(),Z.moveTo(e,t),Z.lineTo(n,r),Z.stroke()}var Rh=U(`<div class="status-row"><span id="apiStatus"></span></div>`),zh=U('<div class="app-shell"><!> <section class="workspace-shell" aria-label="Configuration graph workspace"><nav class="rail" aria-label="Workspace tools"><button id="addButton" class="tool-button primary" type="button" title="Add node">+</button> <button id="fitButton" class="tool-button" type="button" title="Fit view">⌖</button></nav> <canvas id="workspaceCanvas" class="workspace-canvas" layoutsubtree=""><form id="configSurface" class="config-surface" autocomplete="off"><div class="panel-kicker"><span id="nodeTypeBadge">Provider</span> <button id="closePanelButton" class="icon-button close" type="button" title="Close panel">×</button></div> <div class="panel-title-row"><label class="eyebrow" for="nodeName">Node name</label> <input id="nodeName" name="nodeName" class="title-input" type="text"/></div> <div class="form-grid"><label class="field"><span>Kind</span> <select id="nodeKind" name="nodeKind"><option>System</option><option>LLM provider</option><option>Agent</option><option>MCP</option></select></label> <div id="llmFields" class="contents"><div id="providerIdField" class="field wide"><span>Provider ID</span> <div class="model-select-wrap"><input id="nodeProviderId" name="nodeProviderId" type="text" readonly=""/> <button id="copyProviderIdButton" class="icon-button" type="button" title="Copy provider ID">⧉</button></div> <small class="field-note">Technical node id. Use it when a tool or agent workflow needs to reference this provider, for example as <code>imageProviderId</code> with <code>generate_image</code>.</small></div> <label class="field wide"><span>Endpoint</span> <input id="nodeEndpoint" name="nodeEndpoint" type="url" placeholder="http://localhost:11434"/></label> <label class="field wide"><span>API token</span> <input id="nodeToken" name="nodeToken" type="text" autocomplete="off" spellcheck="false" placeholder="env:LLM_API_KEY"/> <small class="field-note">Reference an environment variable only — <code>env:VAR_NAME</code> (or <code>&#123;VAR_NAME&#125;</code>). The secret is read from the server environment at request time; literal tokens are not stored (the workspace file is tracked by git).</small></label> <div class="field wide model-field-row"><span>Model</span> <div class="model-select-wrap"><select id="nodeModel" name="nodeModel"><option disabled="" selected="">— click ↻ to load models —</option></select> <button id="loadModelsButton" class="icon-button" type="button" title="Load models from endpoint">↻</button></div></div> <fieldset class="field wide tool-mode-field"><legend>Provider type</legend> <label class="radio-card"><input id="nodeProviderTypeChat" name="nodeProviderType" type="radio" value="chat"/> <span><strong>Chat completion</strong> <small>Uses OpenAI-compatible <code>/chat/completions</code>.</small></span></label> <label class="radio-card"><input id="nodeProviderTypeImage" name="nodeProviderType" type="radio" value="image"/> <span><strong>Image generation</strong> <small>Used by <code>generate_image</code> with the provider id above.</small></span></label></fieldset> <fieldset id="toolModeField" class="field wide tool-mode-field"><legend>Tool calling</legend> <label class="radio-card"><input id="nodeToolModeTools" name="nodeToolMode" type="radio" value="tools"/> <span><strong>Allow MCP tools</strong> <small>Agents can send OpenAI-compatible <code>tools</code> payloads.</small></span></label> <label class="radio-card"><input id="nodeToolModeChat" name="nodeToolMode" type="radio" value="chat"/> <span><strong>Chat only</strong> <small>Agents never send tools, even when an MCP endpoint exists.</small></span></label></fieldset> <label class="field"><span>Timeout</span> <input id="nodeTimeout" name="nodeTimeout" type="number" min="1" max="600" step="1"/></label></div> <label class="field wide"><span>Description</span> <textarea id="nodeDescription" name="nodeDescription" rows="3"></textarea></label></div> <section id="agentSection" class="agent-section" hidden=""><label id="agentProviderField" class="field wide"><span>LLM provider</span> <select id="nodeAgentProvider" name="nodeAgentProvider"></select> <small class="field-note">Move this agent to another LLM provider. It inherits the target provider\'s model and timeout.</small></label> <label id="agentWorkspaceField" class="field wide"><span>Workspace folder</span> <input id="nodeWorkspaceFolder" name="nodeWorkspaceFolder" type="text" readonly=""/></label> <label class="field wide"><span>System prompt</span> <textarea id="nodeSystemPrompt" name="nodeSystemPrompt" rows="5" placeholder="You are a helpful assistant…"></textarea></label> <label class="field wide checkbox-field"><input id="nodeRequiresUserInput" name="nodeRequiresUserInput" type="checkbox"/> <span>Require a user input</span></label> <label id="agentUserInputDescriptionField" class="field wide" hidden=""><span>Describe User input</span> <textarea id="nodeUserInputDescription" name="nodeUserInputDescription" rows="3" placeholder="Describe exactly what the user must provide before running this agent."></textarea></label> <label class="field wide"><span>Required output marker</span> <input id="nodeExpectedOutputMarker" name="nodeExpectedOutputMarker" type="text" placeholder="Optional, e.g. ```mermaid"/></label></section> <section id="mcpInventory" class="mcp-inventory" hidden=""><div class="inventory-header"><span>MCP consultation surface</span> <strong>Streamable HTTP</strong></div> <p id="mcpInventoryStatus" class="inventory-status" hidden=""></p> <div class="inventory-grid"><article><h2>Tools</h2> <ul id="mcpToolsList"></ul></article> <article><h2>Prompts</h2> <ul id="mcpPromptsList"></ul></article></div></section> <footer class="panel-actions"><div class="panel-actions-left"><button id="testNodeButton" class="secondary-button" type="button">Test</button></div> <div class="panel-actions-right"><button id="deleteNodeButton" class="danger-button" type="button">Delete</button></div></footer></form></canvas> <div id="fallbackPanelHost" class="fallback-panel-host" hidden=""></div></section> <div id="deleteConfirmOverlay" class="confirm-overlay" hidden=""><section class="confirm-dialog" role="dialog" aria-modal="true" aria-labelledby="deleteConfirmTitle"><div><p class="confirm-kicker">Destructive change</p> <h2 id="deleteConfirmTitle">Delete node?</h2> <p id="deleteConfirmMessage" class="confirm-message"></p></div> <footer class="confirm-actions"><button id="cancelDeleteButton" class="secondary-button" type="button">Cancel</button> <button id="confirmDeleteButton" class="danger-button" type="button">Delete</button></footer></section></div> <div id="renameConfirmOverlay" class="confirm-overlay" hidden=""><section class="confirm-dialog" role="dialog" aria-modal="true" aria-labelledby="renameConfirmTitle"><div><p class="confirm-kicker">Renommage de dossier</p> <h2 id="renameConfirmTitle">Renommer le dossier ?</h2> <p id="renameConfirmMessage" class="confirm-message"></p></div> <footer class="confirm-actions"><button id="cancelRenameButton" class="secondary-button" type="button">Annuler</button> <button id="confirmRenameButton" class="primary-button" type="button">Renommer</button></footer></section></div> <div id="agentRunOverlay" class="confirm-overlay" hidden=""><section class="agent-run-dialog" role="dialog" aria-modal="true" aria-labelledby="agentRunTitle"><div><p class="confirm-kicker">Agent test</p> <h2 id="agentRunTitle">Run agent</h2> <p id="agentRunHint" class="confirm-message"></p></div> <label id="agentRunInputField" class="field wide agent-run-input-field"><span>User input</span> <textarea id="agentRunInput" name="agentRunInput" rows="6" placeholder="Document ID, question, or any input for the agent…"></textarea></label> <div id="agentRunResult" class="agent-run-result" hidden=""></div> <footer class="confirm-actions"><button id="cancelAgentRunButton" class="secondary-button" type="button">Close</button> <button id="executeAgentRunButton" class="primary-button" type="button">Run</button></footer></section></div></div>');function Bh(e,t){qe(t,!0),Gi(async()=>{try{await ha((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}return Ap()});var n=zh(),r=L(n);so(r,{title:`Living AI Documentation`,subtitle:`Graph-native configuration workspace`,children:(e,t)=>{var n=Rh(),r=L(n);gi(r,1,`status-pill `),r.textContent=`Detecting canvas API`,j(n),W(e,n)},$$slots:{default:!0}});var i=z(r,2),a=z(L(i),2),o=L(a),s=z(L(o),4),c=L(s),l=z(L(c),2),u=L(l);u.value=u.__value=`system`;var d=z(u);d.value=d.__value=`llm`;var f=z(d);f.value=f.__value=`agent`;var p=z(f);p.value=p.__value=`mcp`,j(l),j(c);var m=z(c,2),h=z(L(m),6),g=z(L(h),2),_=L(g),v=L(_);v.value=v.__value=``,j(_),Ie(2),j(g),j(h),Ie(6),j(m),Ie(2),j(s),Ie(6),j(o),j(a),Ie(2),j(i),Ie(6),j(n),W(e,n),Je()}var Vh=U(`<p class="files-msg svelte-4q2lov"> </p>`),Hh=U(`<p class="files-msg files-msg--error svelte-4q2lov"> </p>`),Uh=U(`<p class="files-msg files-msg--empty svelte-4q2lov"> </p>`),Wh=U(`<option> </option>`),Gh=U(`<div class="files-toolbar svelte-4q2lov"><label for="files-folder-filter" class="svelte-4q2lov"> </label> <select id="files-folder-filter" data-testid="files-folder-filter" class="svelte-4q2lov"><option> </option><!></select></div>`),Kh=U(`<span class="files-folder svelte-4q2lov"> </span> ·`,1),qh=U(`<p class="files-row-error svelte-4q2lov"> </p>`),Jh=U(`<li class="files-row svelte-4q2lov"><span class="files-icon svelte-4q2lov">📎</span> <div class="files-info svelte-4q2lov"><a target="_blank" rel="noopener" class="files-name svelte-4q2lov"> </a> <div class="files-meta svelte-4q2lov"><!><!> </div> <!></div> <div class="files-actions svelte-4q2lov"><button type="button" class="files-btn svelte-4q2lov"> </button> <button type="button" class="files-btn files-btn--danger svelte-4q2lov"> </button></div></li>`),Yh=U(`<ul class="files-list svelte-4q2lov"></ul>`),Xh=U(`<!> <!>`,1),Zh=U(`<!> <div class="app-shell"><!> <div class="files-page svelte-4q2lov"><!></div></div>`,1);function Qh(e,t){qe(t,!0);let n=P(null),r=P(I([])),i=P(I([])),a=P(``),o=P(!0),s=P(``),c=P(I({})),l=P(I({})),u=P(I({})),d=N(()=>V(a)?V(r).filter(e=>e.folder===V(a)||e.folder.startsWith(V(a)+`/`)):V(r));function f(e){return e<1024?Y(`files.size_bytes`).replace(`{n}`,String(e)):e<1024*1024?Y(`files.size_kb`).replace(`{n}`,(e/1024).toFixed(1)):Y(`files.size_mb`).replace(`{n}`,(e/1024/1024).toFixed(2))}function p(e){if(!e)return``;let t=new Date(e);if(isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}async function m(){F(o,!0),F(s,``);try{let e=await fetch(`/api/files`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();F(r,Array.isArray(t.files)?t.files:[],!0),F(i,Array.isArray(t.folders)?t.folders:[],!0),V(a)&&!V(i).includes(V(a))&&F(a,``)}catch(e){F(s,Y(`files.error_load`)+(e instanceof Error?e.message:String(e)))}finally{F(o,!1)}}function h(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function g(e){let t=document.createElement(`input`);t.type=`file`,t.style.display=`none`,document.body.appendChild(t),t.addEventListener(`change`,async()=>{let r=t.files?.[0];if(t.remove(),r&&await V(n).show({kicker:Y(`files.confirm_replace_title`),title:Y(`files.confirm_replace_message`).replace(`{name}`,e.displayName||e.filename).replace(`{newName}`,r.name),message:Y(`files.confirm_replace_detail`),confirmLabel:Y(`files.replace`),cancelLabel:Y(`common.cancel`),danger:!0})){if(r.size>19922944){F(c,{...V(c),[e.filename]:Y(`files.error_replace`)+`${(r.size/1024/1024).toFixed(1)} MB (max 19 MB)`},!0);return}F(l,{...V(l),[e.filename]:!0},!0),F(c,{...V(c),[e.filename]:``},!0);try{let t=await h(r),n=await fetch(`/api/files/${encodeURIComponent(e.filename)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`HTTP ${n.status}`)}await m()}catch(t){F(c,{...V(c),[e.filename]:Y(`files.error_replace`)+(t instanceof Error?t.message:String(t))},!0)}finally{F(l,{...V(l),[e.filename]:!1},!0)}}}),t.click()}async function _(e){if(await V(n).show({kicker:Y(`files.confirm_delete_title`),title:Y(`files.confirm_delete_message`).replace(`{name}`,e.displayName||e.filename),message:Y(`files.confirm_delete_detail`),confirmLabel:Y(`files.delete`),cancelLabel:Y(`common.cancel`),danger:!0})){F(u,{...V(u),[e.filename]:!0},!0),F(c,{...V(c),[e.filename]:``},!0);try{let t=await fetch(`/api/files/${encodeURIComponent(e.filename)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`HTTP ${t.status}`)}await m()}catch(t){F(c,{...V(c),[e.filename]:Y(`files.error_delete`)+(t instanceof Error?t.message:String(t))},!0)}finally{F(u,{...V(u),[e.filename]:!1},!0)}}}Gi(async()=>{try{await ha((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}await m()});var v=Zh(),y=R(v);Vi(ad(y,{}),e=>F(n,e,!0),()=>V(n));var b=z(y,2),x=L(b);{let e=N(()=>Y(`files.title`));so(x,{get title(){return V(e)},subtitle:``})}var S=z(x,2),C=L(S),w=e=>{var t=Vh(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},T=e=>{var t=Hh(),n=L(t,!0);j(t),B(()=>G(n,V(s))),W(e,t)},E=e=>{var t=Uh(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`files.empty`)]),W(e,t)},D=e=>{var t=Xh(),n=R(t),r=e=>{var t=Gh(),n=L(t),r=L(n,!0);j(n);var o=z(n,2),s=L(o),c=L(s,!0);j(s),s.value=s.__value=``,q(z(s),16,()=>V(i),e=>e,(e,t)=>{var n=Wh(),r=L(n,!0);j(n);var i={};B(()=>{G(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),W(e,n)}),j(o);var l;bi(o),j(t),B((e,t)=>{G(r,e),G(c,t),l!==(l=V(a))&&(o.value=(o.__value=V(a))??``,yi(o,V(a)))},[()=>Y(`files.filter_label`),()=>Y(`files.filter_all`)]),H(`change`,o,e=>F(a,e.target.value,!0)),W(e,t)};K(n,e=>{V(i).length>0&&e(r)});var o=z(n,2),s=e=>{var t=Uh(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`files.empty_filter`)]),W(e,t)},m=e=>{var t=Yh();q(t,21,()=>V(d),Xr,(e,t)=>{var n=Jh(),r=z(L(n),2),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o),d=e=>{var n=Kh(),r=R(n),i=L(r,!0);j(r),Ie(),B(()=>G(i,V(t).folder)),W(e,n)};K(s,e=>{V(t).folder&&e(d)});var m=z(s),h=e=>{var n=Ur();B(e=>G(n,`${e??``} ·`),[()=>p(V(t).uploadedAt)]),W(e,n)};K(m,e=>{V(t).uploadedAt&&e(h)});var v=z(m,1,!0);j(o);var y=z(o,2),b=e=>{var n=qh(),r=L(n,!0);j(n),B(()=>G(r,V(c)[V(t).filename])),W(e,n)};K(y,e=>{V(c)[V(t).filename]&&e(b)}),j(r);var x=z(r,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2),T=L(w,!0);j(w),j(x),j(n),B((e,n,r)=>{J(i,`href`,V(t).url),G(a,V(t).displayName||V(t).filename),G(v,e),S.disabled=V(l)[V(t).filename]||V(u)[V(t).filename],G(C,n),w.disabled=V(l)[V(t).filename]||V(u)[V(t).filename],G(T,r)},[()=>f(V(t).size||0),()=>V(l)[V(t).filename]?Y(`files.replacing`):Y(`files.replace`),()=>V(u)[V(t).filename]?Y(`files.deleting`):Y(`files.delete`)]),H(`click`,S,()=>g(V(t))),H(`click`,w,()=>_(V(t))),W(e,n)}),j(t),W(e,t)};K(o,e=>{V(d).length===0?e(s):e(m,-1)}),W(e,t)};K(C,e=>{V(o)?e(w):V(s)?e(T,1):V(r).length===0?e(E,2):e(D,-1)}),j(S),j(b),W(e,v),Je()}Pr([`change`,`click`]);var $h=U(`<p class="browser-msg"> </p>`),eg=U(`<p class="browser-msg browser-msg--error"> </p>`),tg=U(`<button class="browser-row browser-row--dir"><span class="browser-row-name"> </span></button>`),ng=U(`<span class="badge-added"> </span>`),rg=U(`<button class="link-btn"> </button>`),ig=U(`<div class="browser-row browser-row--file"><span class="browser-row-name"> </span> <!></div>`),ag=U(`<!> <!>`,1),og=U(`<div class="file-browser"><div class="file-browser-toolbar"><button class="link-btn"> </button> <span class="file-browser-path"> </span></div> <div class="file-browser-list" data-testid="instruction-browse-list"><!></div></div>`),sg=U(`<p class="empty-msg svelte-e5jhdq"> </p>`),cg=U(`<button class="remove-btn"> </button>`),lg=U(`<div class="instruction-row svelte-e5jhdq"><div class="instruction-info svelte-e5jhdq"><a class="instruction-path svelte-e5jhdq"> </a> <div class="instruction-meta svelte-e5jhdq"> <!></div></div> <div class="instruction-actions svelte-e5jhdq"><span> </span> <!></div></div>`),ug=U(`<div class="section-card svelte-e5jhdq"><div class="section-header svelte-e5jhdq"><span class="section-title svelte-e5jhdq"> </span> <div class="header-actions svelte-e5jhdq"><span class="count-label svelte-e5jhdq"> </span> <button class="secondary-button btn-sm"> </button></div></div> <!> <div class="instruction-list svelte-e5jhdq" data-testid="instruction-list"><!></div></div>`);function dg(e,t){qe(t,!0);let n=Wi(t,`items`,27,()=>I([])),r=P(!1),i=P(``),a=P(``),o=P(I([])),s=P(I([])),c=P(!1),l=P(!1),u=N(()=>new Set(n().map(e=>d(e.path))));function d(e){return String(e||``).split(/[/\\]/).pop()||``}function f(e){let t=encodeURIComponent(String(e||``).replace(/\.md$/i,``));return`/?doc=`+encodeURIComponent(t)}function p(e){return Y(`context.root.${e}`)}function m(e){return Y(`context.type.${e}`)}async function h(e){F(c,!0),F(l,!1);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(i,t.current,!0),F(a,t.parent||``,!0),F(o,t.dirs||[],!0),F(s,t.files||[],!0)}catch{F(l,!0)}finally{F(c,!1)}}async function g(){F(r,!V(r)),V(r)&&!V(i)&&await h((await fetch(`/api/context/orientation`).then(e=>e.json()).catch(()=>({}))).sourceRoot||``)}async function _(e){await t.onAdd(e),V(r)&&V(i)&&await h(V(i))}var v=ug(),y=L(v),b=L(y),x=L(b,!0);j(b);var S=z(b,2),C=L(S),w=L(C);j(C);var T=z(C,2),E=L(T,!0);j(T),j(S),j(y);var D=z(y,2),ee=e=>{var t=og(),n=L(t),r=L(n),d=L(r,!0);j(r);var f=z(r,2),p=L(f,!0);j(f),j(n);var m=z(n,2),g=L(m),v=e=>{var t=$h(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},y=e=>{var t=eg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.cannot_read_dir`)]),W(e,t)},b=e=>{var t=$h(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.empty_dir`)]),W(e,t)},x=e=>{var t=ag(),n=R(t);q(n,17,()=>V(o),Xr,(e,t)=>{var n=tg(),r=L(n),i=L(r);j(r),j(n),B(()=>G(i,`📁 ${V(t).name??``}`)),H(`click`,n,()=>h(V(t).path)),W(e,n)}),q(z(n,2),17,()=>V(s),Xr,(e,t)=>{var n=ig(),r=L(n),i=L(r);j(r);var a=z(r,2),o=e=>{var t=ng(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.added`)]),W(e,t)},s=N(()=>V(u).has(V(t).name)),c=e=>{var n=rg(),r=L(n,!0);j(n),B(e=>G(r,e),[()=>Y(`context.add_file_action`)]),H(`click`,n,()=>_(V(t).path)),W(e,n)};K(a,e=>{V(s)?e(o):e(c,-1)}),j(n),B(()=>G(i,`📄 ${V(t).name??``}`)),W(e,n)}),W(e,t)};K(g,e=>{V(c)?e(v):V(l)?e(y,1):!V(o).length&&!V(s).length?e(b,2):e(x,-1)}),j(m),j(t),B(e=>{r.disabled=!V(a),G(d,e),G(p,V(i))},[()=>Y(`common.up`)]),H(`click`,r,()=>V(a)&&h(V(a))),W(e,t)};K(D,e=>{V(r)&&e(ee)});var te=z(D,2),O=L(te),ne=e=>{var t=sg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.no_instructions`)]),W(e,t)},re=e=>{var r=Wr();q(R(r),17,n,Xr,(e,n)=>{var r=lg(),i=L(r),a=L(i),o=L(a,!0);j(a);var s=z(a,2),c=L(s),l=z(c),u=e=>{var t=Ur();B(e=>G(t,`· ${e??``} KB`),[()=>Math.round(V(n).size/1024)]),W(e,t)};K(l,e=>{V(n).size!==null&&e(u)}),j(s),j(i);var h=z(i,2),g=L(h),_=L(g,!0);j(g);var v=z(g,2),y=e=>{var r=cg(),i=L(r,!0);j(r),B(e=>G(i,e),[()=>Y(`common.remove`)]),H(`click`,r,()=>t.onRemove(d(V(n).path))),W(e,r)};K(v,e=>{V(n).exists&&e(y)}),j(h),j(r),B((e,t,r,i)=>{J(a,`href`,e),G(o,V(n).path),G(c,`${t??``} · ${r??``} `),gi(g,1,ui(V(n).exists?`status-ok`:`status-missing`),`svelte-e5jhdq`),G(_,i)},[()=>f(V(n).path),()=>p(V(n).root),()=>m(V(n).type),()=>V(n).exists?Y(`context.exists`):Y(`context.missing`)]),W(e,r)}),W(e,r)};K(O,e=>{n().length?e(re,-1):e(ne)}),j(te),j(v),B((e,t,r)=>{G(x,e),G(w,`${t??``}/${n().length??``}`),G(E,r)},[()=>Y(`context.instructions_title`),()=>n().filter(e=>e.exists).length,()=>V(r)?Y(`context.hide_instruction_browser`):Y(`context.add_instruction_file`)]),H(`click`,T,g),W(e,v),Je()}Pr([`click`]);var fg=U(`<span class="rules-folder svelte-1r3tey2"> </span>`),pg=U(`<p class="empty-msg svelte-1r3tey2"> </p>`),mg=U(`<span class="tag svelte-1r3tey2"> </span>`),hg=U(`<div class="rule-tags svelte-1r3tey2"></div>`),gg=U(`<div class="rule-applies svelte-1r3tey2"> </div>`),_g=U(`<article class="rule-row svelte-1r3tey2"><div class="rule-top svelte-1r3tey2"><div class="rule-title-wrap svelte-1r3tey2"><h3 class="rule-title svelte-1r3tey2"><a class="rule-link svelte-1r3tey2"> </a></h3> <a class="rule-path svelte-1r3tey2"> </a></div> <span class="severity-badge svelte-1r3tey2"> </span></div> <p class="rule-desc svelte-1r3tey2"> </p> <!> <!></article>`),vg=U(`<div class="rules-layout svelte-1r3tey2"><div class="section-card svelte-1r3tey2"><div class="section-header svelte-1r3tey2"><span class="section-title svelte-1r3tey2" data-testid="rules-title"> </span> <!></div> <div class="rule-list svelte-1r3tey2" data-testid="rule-list"><!></div></div> <div class="section-card aside-card svelte-1r3tey2"><span class="section-title svelte-1r3tey2" data-testid="add-rule-title"> </span> <div class="field-group"><label class="field-label" for="ruleTitle"> </label> <input id="ruleTitle" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleSeverity"> </label> <select id="ruleSeverity" class="field-input"><option> </option><option> </option><option> </option></select></div> <div class="field-group"><label class="field-label" for="ruleDescription"> </label> <input id="ruleDescription" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleTags"> </label> <input id="ruleTags" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleAppliesTo"> </label> <input id="ruleAppliesTo" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleBody"> </label> <textarea id="ruleBody" rows="7" class="field-input"></textarea></div> <button class="btn-primary" style="width:100%"> </button></div></div>`);function yg(e,t){qe(t,!0);let n=Wi(t,`rules`,19,()=>[]),r=Wi(t,`rulesFolder`,3,``),i=P(``),a=P(`guideline`),o=P(``),s=P(``),c=P(``),l=P(``),u=P(!1);function d(e){let t=encodeURIComponent(String(e||``).replace(/\.md$/i,``));return`/?doc=`+encodeURIComponent(t)}function f(e){let t=`context.rule_severity_${e}`,n=Y(t);return n===t?e:n}function p(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}async function m(){if(V(i).trim()){F(u,!0);try{await t.onAdd({title:V(i).trim(),severity:V(a),description:V(o).trim(),tags:p(V(s)),appliesTo:p(V(c)),body:V(l).trim()}),F(i,``),F(o,``),F(s,``),F(c,``),F(l,``)}finally{F(u,!1)}}}var h=vg(),g=L(h),_=L(g),v=L(_),y=L(v,!0);j(v);var b=z(v,2),x=e=>{var t=fg(),n=L(t,!0);j(t),B(()=>G(n,r())),W(e,t)};K(b,e=>{r()&&e(x)}),j(_);var S=z(_,2),C=L(S),w=e=>{var t=pg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.no_rules`)]),W(e,t)},T=e=>{var t=Wr();q(R(t),17,n,Xr,(e,t)=>{var n=_g(),r=L(n),i=L(r),a=L(i),o=L(a),s=L(o,!0);j(o),j(a);var c=z(a,2),l=L(c,!0);j(c),j(i);var u=z(i,2),p=L(u,!0);j(u),j(r);var m=z(r,2),h=L(m,!0);j(m);var g=z(m,2),_=e=>{var n=hg();q(n,21,()=>V(t).tags,Xr,(e,t)=>{var n=mg(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(n),W(e,n)};K(g,e=>{V(t).tags?.length&&e(_)});var v=z(g,2),y=e=>{var n=gg(),r=L(n,!0);j(n),B(e=>G(r,e),[()=>V(t).appliesTo.join(`, `)]),W(e,n)};K(v,e=>{V(t).appliesTo?.length&&e(y)}),j(n),B((e,n,r)=>{J(o,`href`,e),G(s,V(t).title),J(c,`href`,n),G(l,V(t).path),G(p,r),G(h,V(t).description)},[()=>d(V(t).path),()=>d(V(t).path),()=>f(V(t).severity)]),W(e,n)}),W(e,t)};K(C,e=>{n().length?e(T,-1):e(w)}),j(S),j(g);var E=z(g,2),D=L(E),ee=L(D,!0);j(D);var te=z(D,2),O=L(te),ne=L(O,!0);j(O);var re=z(O,2);Di(re),j(te);var k=z(te,2),ie=L(k),ae=L(ie,!0);j(ie);var oe=z(ie,2),se=L(oe),ce=L(se,!0);j(se),se.value=se.__value=`guideline`;var le=z(se),ue=L(le,!0);j(le),le.value=le.__value=`warning`;var de=z(le),fe=L(de,!0);j(de),de.value=de.__value=`required`,j(oe),j(k);var pe=z(k,2),me=L(pe),he=L(me,!0);j(me);var ge=z(me,2);Di(ge),j(pe);var _e=z(pe,2),ve=L(_e),ye=L(ve,!0);j(ve);var be=z(ve,2);Di(be),j(_e);var xe=z(_e,2),Se=L(xe),Ce=L(Se,!0);j(Se);var A=z(Se,2);Di(A),j(xe);var we=z(xe,2),Te=L(we),Ee=L(Te,!0);j(Te);var De=z(Te,2);yn(De),j(we);var Oe=z(we,2),ke=L(Oe,!0);j(Oe),j(E),j(h),B((e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)=>{G(y,e),G(ee,t),G(ne,n),J(re,`placeholder`,r),G(ae,i),G(ce,a),G(ue,o),G(fe,s),G(he,c),J(ge,`placeholder`,l),G(ye,u),J(be,`placeholder`,d),G(Ce,f),J(A,`placeholder`,p),G(Ee,m),J(De,`placeholder`,h),Oe.disabled=g,G(ke,_)},[()=>Y(`context.rules_title`),()=>Y(`context.add_rule_title`),()=>Y(`context.rule_title_label`),()=>Y(`context.rule_title_placeholder`),()=>Y(`context.rule_severity_label`),()=>Y(`context.rule_severity_guideline`),()=>Y(`context.rule_severity_warning`),()=>Y(`context.rule_severity_required`),()=>Y(`context.rule_description_label`),()=>Y(`context.rule_description_placeholder`),()=>Y(`context.rule_tags_label`),()=>Y(`context.rule_tags_placeholder`),()=>Y(`context.rule_applies_to_label`),()=>Y(`context.rule_applies_to_placeholder`),()=>Y(`context.rule_body_label`),()=>Y(`context.rule_body_placeholder`),()=>V(u)||!V(i).trim(),()=>Y(`context.add_rule_button`)]),Ni(re,()=>V(i),e=>F(i,e)),xi(oe,()=>V(a),e=>F(a,e)),Ni(ge,()=>V(o),e=>F(o,e)),Ni(be,()=>V(s),e=>F(s,e)),Ni(A,()=>V(c),e=>F(c,e)),Ni(De,()=>V(l),e=>F(l,e)),H(`click`,Oe,m),W(e,h),Je()}Pr([`click`]);var bg=U(`<p class="empty-msg svelte-1ui2b6s"> </p>`),xg=U(`<p class="mcp-desc svelte-1ui2b6s"> </p>`),Sg=U(`<div class="mcp-schema-wrap svelte-1ui2b6s"><h4 class="mcp-schema-title svelte-1ui2b6s"> </h4> <pre class="mcp-schema-pre svelte-1ui2b6s"> </pre></div>`),Cg=U(`<div class="mcp-result svelte-1ui2b6s" data-testid="mcp-result"></div>`),wg=U(`<details class="mcp-detail svelte-1ui2b6s"><summary class="mcp-summary svelte-1ui2b6s"> </summary> <!> <!> <div class="mcp-run-area svelte-1ui2b6s"><label class="mcp-run-label svelte-1ui2b6s"> </label> <textarea rows="4" spellcheck="false" class="field-input mcp-textarea svelte-1ui2b6s" data-testid="mcp-args"></textarea> <div class="mcp-run-footer svelte-1ui2b6s"><span class="mcp-error-text svelte-1ui2b6s" data-testid="mcp-error"> </span> <button class="btn-primary btn-sm"> </button></div> <!></div></details>`),Tg=U(`<p class="mcp-arg-desc svelte-1ui2b6s"> </p>`),Eg=U(`<li class="mcp-arg-item svelte-1ui2b6s"><div class="mcp-arg-name-row svelte-1ui2b6s"><span class="mcp-arg-name svelte-1ui2b6s"> </span> <span class="mcp-arg-req svelte-1ui2b6s"> </span></div> <!></li>`),Dg=U(`<div class="mcp-schema-wrap svelte-1ui2b6s"><h4 class="mcp-schema-title svelte-1ui2b6s"> </h4> <ul class="mcp-args-list svelte-1ui2b6s"></ul></div>`),Og=U(`<div class="section-card svelte-1ui2b6s"><div class="section-header svelte-1ui2b6s"><span class="section-title svelte-1ui2b6s" data-testid="mcp-title"> </span> <button class="secondary-button btn-sm"> </button></div> <p class="section-desc svelte-1ui2b6s"> </p> <div class="mcp-info-grid svelte-1ui2b6s"><div class="mcp-info-cell svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div> </div></div> <div class="mcp-info-cell svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div class="mcp-info-value mono svelte-1ui2b6s"> </div></div> <div class="mcp-info-cell wide svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div class="mcp-info-value mono break svelte-1ui2b6s" data-testid="mcp-endpoint"> </div></div></div> <div><div class="subsection-header svelte-1ui2b6s"><span class="subsection-title svelte-1ui2b6s"> </span> <div class="subsection-actions svelte-1ui2b6s"><span class="count-label svelte-1ui2b6s"> </span> <button class="secondary-button btn-sm"> </button></div></div> <div class="mcp-items svelte-1ui2b6s" data-testid="mcp-tool-list"><!></div></div> <div><div class="subsection-header svelte-1ui2b6s"><span class="subsection-title svelte-1ui2b6s"> </span> <div class="subsection-actions svelte-1ui2b6s"><span class="count-label svelte-1ui2b6s"> </span> <button class="secondary-button btn-sm"> </button></div></div> <div class="mcp-items svelte-1ui2b6s" data-testid="mcp-prompt-list"><!></div></div></div>`);function kg(e,t){qe(t,!0);let n=P(`-`),r=P(!1),i=P(`-`),a=P(`-`),o=P(I([])),s=P(I([])),c=P(!1),l=P(I(new Map)),u=P(I(new Map));function d(e,t){let n=V(e===`tool`?l:u);return n.has(t)||n.set(t,{argsJson:`{}`,running:!1,error:``,resultHtml:``}),n.get(t)}function f(e,t,n){let r=V(e===`tool`?l:u).get(t)??{argsJson:`{}`,running:!1,error:``,resultHtml:``};e===`tool`?F(l,new Map(V(l)).set(t,{...r,...n}),!0):F(u,new Map(V(u)).set(t,{...r,...n}),!0)}function p(e){if(!e||typeof e!=`object`)return null;if(e.type===`string`)return``;if(e.type===`number`||e.type===`integer`)return 0;if(e.type===`boolean`)return!1;if(e.type===`array`)return[];if(e.type===`object`||e.properties){let t={},n=e.properties||{};return(Array.isArray(e.required)?e.required:[]).forEach(e=>{t[e]=p(n[e])??``}),t}return null}function m(e){let t=p(e.inputSchema)??{},n=JSON.stringify(t,null,2);F(l,new Map(V(l)).set(e.name,{argsJson:n,running:!1,error:``,resultHtml:``}),!0)}function h(e){let t={};(e.arguments||[]).forEach(e=>{e.required&&(t[e.name]=``)});let n=JSON.stringify(t,null,2);F(u,new Map(V(u)).set(e.name,{argsJson:n,running:!1,error:``,resultHtml:``}),!0)}function g(e){let t=e.match(/^data:\s*(\{.*\})\s*$/m);if(!t)throw Error(e.slice(0,300)||`No MCP response body`);return JSON.parse(t[1])}async function _(e,t,n){let r=await fetch(`/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json, text/event-stream`},body:JSON.stringify({jsonrpc:`2.0`,id:e,method:t,params:n})}),i=await r.text();if(!r.ok)throw Error(i||`HTTP ${r.status}`);return g(i)}async function v(){await _(1,`initialize`,{protocolVersion:`2025-03-26`,capabilities:{},clientInfo:{name:`living-ai-documentation-context`,version:`1.0.0`}})}function y(e){return"```json\n"+JSON.stringify(e,null,2).replaceAll("```","`\\`\\`")+"\n```"}function b(e){if(typeof e!=`string`)return y(e);try{return y(JSON.parse(e))}catch{return e}}function x(e){if(typeof e==`string`)return e;if(!e||typeof e!=`object`)return String(e??``);if(e.error)return y(e.error);let t=e.result;return!t||typeof t!=`object`?y(e):Array.isArray(t.messages)?t.messages.map(e=>`${e.role?`[${e.role}]`:``}\n${b(e.content?.text??e.content??e)}`.trim()).join(`
91
+ `,t);return n>=0?n:0}c=c.nextElementSibling}return e.length}function Vd(e,t,n){if(!e||typeof t!=`string`)return()=>{};let r=Ad(t);Md(e,r);let i=i=>{let a=i.target?.closest(`[data-inline-snippet-index]`);if(a&&e.contains(a)){let e=r[Number(a.dataset.inlineSnippetIndex)];if(!e)return;i.preventDefault();let t=yd(e.type),o=xd(e.type);Pd(i,[{iconClass:t.iconClass,labelKey:t.labelKey,dataAction:`edit`,dataType:e.type,onActivate:()=>n.onEdit(e)},{iconClass:o.iconClass,labelKey:o.labelKey,dataAction:`delete`,dataType:e.type,onActivate:()=>n.onDelete(e)}]);return}if(!e.contains(i.target))return;let o=Bd(t,e,i.target,r,i.clientY);o!==null&&(i.preventDefault(),Pd(i,{iconClass:`fa-solid fa-plus`,labelKey:`snippet.inline_insert_btn`,dataAction:`insert`,onActivate:()=>n.onInsert(o)}))};e.addEventListener(`contextmenu`,i);let a=t=>{let i=t.target?.closest(`[data-inline-snippet-index]`);if(!i||!e.contains(i))return;let a=r[Number(i.dataset.inlineSnippetIndex)];a?.type===`table`&&(t.preventDefault(),t.stopPropagation(),Nd(),n.onEdit({...a,tableFocusCell:Id(t.target,i)||void 0}))};e.addEventListener(`dblclick`,a);let o=e.closest(`#home-content-area`)||e.closest(`main`),s=null;o&&(s=r=>{r.defaultPrevented||e.offsetParent!==null&&(r.target?.closest(`textarea, input, [data-inline-snippet-index]`)||e.contains(r.target)||(r.preventDefault(),Pd(r,{iconClass:`fa-solid fa-plus`,labelKey:`snippet.inline_insert_btn`,dataAction:`insert`,onActivate:()=>n.onInsert(t.length)})))},o.addEventListener(`contextmenu`,s));let c=e=>{Cd&&!Cd.contains(e.target)&&Nd()},l=e=>{e.key===`Escape`&&Nd()};return document.addEventListener(`click`,c),document.addEventListener(`keydown`,l),()=>{e.removeEventListener(`contextmenu`,i),e.removeEventListener(`dblclick`,a),o&&s&&o.removeEventListener(`contextmenu`,s),document.removeEventListener(`click`,c),document.removeEventListener(`keydown`,l),Nd(),e.querySelectorAll(`[data-inline-snippet-index]`).forEach(e=>{e.removeAttribute(`data-inline-snippet-index`),e.classList.remove(`ld-inline-snippet-target`)})}}var Hd=200*1024*1024,Ud=Math.round(Hd/1024/1024);Math.ceil(Hd*1.4);var Wd=U(`<textarea id="doc-editor" data-testid="doc-editor" spellcheck="false" class="w-full min-h-[70vh] px-4 py-3 text-sm font-mono leading-relaxed rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-y"></textarea>`),Gd=U(`<div id="doc-content" data-testid="doc-content"></div>`),Kd=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-sm mx-4 p-6 space-y-5"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"> </h3> <div class="space-y-1.5"><label for="img-paste-name" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> <span class="font-normal text-gray-400"> </span></label> <div class="flex items-center gap-2"><input id="img-paste-name" type="text" class="flex-1 px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono focus:outline-none focus:ring-2 focus:ring-blue-500"/> <span class="text-xs text-gray-400 shrink-0"> </span></div></div> <div class="flex justify-end gap-3 pt-1"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div></div>`),qd=U(`<div data-testid="content-lightbox" class="fixed inset-0 z-50 bg-white flex items-center justify-center cursor-pointer p-4"><img data-testid="lightbox-image" class="max-w-full max-h-full object-contain select-none"/> <button class="absolute top-4 right-4 text-gray-500 hover:text-gray-950 text-2xl leading-none">×</button></div>`),Jd=U(`<!> <!> <!> <!>`,1);function Yd(e,t){qe(t,!0);let n=Wi(t,`onopen`,3,()=>{}),r=Wi(t,`onanchor`,3,D),i=Wi(t,`onconfirmdelete`,3,void 0),a=Wi(t,`oncontentwired`,3,void 0),o=Wi(t,`rewireSignal`,3,void 0),s=Wi(t,`editing`,15,!1),c=Wi(t,`saveMsg`,15,null),l=P(null),u=P(null),d=P(``),f=null,p=P(!1),m=P(`insert`),h=P(null),g=P(0),_=P(!1),v=P(``),y=P(`png`),b=null,x=0,S=0,C=P(null),w=P(``),T=/[̀-ͯ]/g;function E(e){return(e||``).normalize(`NFD`).replace(T,``).toLowerCase().replace(/[^a-z0-9]/g,`_`)}function D(e){document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})}Gi(()=>{let e=window;return e.openSnippetsModal=()=>{F(m,`insert`),F(p,!0)},e.openSnippetsModalForInlineInsert=e=>{F(m,`inline-insert`),F(g,Math.max(0,Number(e)||0),!0),F(p,!0)},()=>{delete e.openSnippetsModal,delete e.openSnippetsModalForInlineInsert}}),kn(()=>{if(o(),t.html,t.content,f?.(),f=null,!(s()||!V(l)))return Tu(V(l),t.html,{content:t.content,codeBlockMaxHeight:X.codeBlockMaxHeight,t:Y,onDocLink:(e,t)=>n()(e,t),onAnchor:r(),docId:t.docId,docs:X.allDocs,docsFolder:X.docsFolder,folderPaths:X.allFolderPaths,onKanbanDocsChange:e=>{X.allDocs=e},onKanbanFolderPathsChange:e=>{X.allFolderPaths=e}})||(f=Vd(V(l),t.content,{onEdit:e=>{F(m,`inline-edit`),F(h,e,!0),F(p,!0)},onInsert:e=>{F(m,`inline-insert`),F(g,e,!0),F(p,!0)},onDelete:async e=>{(i()?await i()():confirm(Y(`snippet.inline_delete_message`)))&&await t.onsave(t.content.slice(0,e.start)+t.content.slice(e.end))}})),a()?.(V(l)),()=>{f?.(),f=null}});function ee(){F(d,t.content,!0),s(!0),c(null),requestAnimationFrame(()=>V(u)?.focus())}function te(){s(!1),c(null)}async function O(){c({text:Y(`doc.saving`),cls:`text-gray-400`});try{await t.onsave(V(d)),s(!1),c(null)}catch(e){c({text:Y(`error.save`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}}function ne(){F(m,`insert`),F(p,!0)}function re(){let e=ru(t.content);e&&(F(m,`inline-edit`),F(h,e,!0),F(p,!0))}function k(){return s()}function ie(e){let t=Array.from(e.clipboardData?.items??[]).find(e=>e.type.startsWith(`image/`));if(t){e.preventDefault(),x=V(u).selectionStart,S=V(u).selectionEnd,F(y,t.type.split(`/`)[1].replace(`jpeg`,`jpg`)||`png`,!0);let n=t.getAsFile();if(!n)return;b=n,F(v,E(Date.now().toString()),!0),F(_,!0);return}let n=Array.from(e.clipboardData?.files??[]).filter(e=>!e.type.startsWith(`image/`));if(n.length){e.preventDefault();let t=V(u).selectionStart,r=V(u).selectionEnd;(async()=>{for(let e of n)await ue(e,t,r)})()}}function ae(e){let t=Array.from(e.dataTransfer?.files??[]).filter(e=>!e.type.startsWith(`image/`));if(!t.length)return;e.preventDefault(),e.stopPropagation();let n=V(u).selectionStart,r=V(u).selectionEnd;(async()=>{for(let e of t)await ue(e,n,r)})()}function oe(e){e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}function se(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function ce(e,t,n){let r=V(d).slice(0,t),i=V(d).slice(n);F(d,r+e+i),requestAnimationFrame(()=>{V(u).selectionStart=V(u).selectionEnd=t+e.length,V(u).focus()})}let le=Hd;async function ue(e,n,r){if(e.size>le){c({text:Y(`doc.file_too_large`)+` (${(e.size/1024/1024).toFixed(1)} MB, max ${Ud} MB)`,cls:`text-red-500 dark:text-red-400`});return}c({text:Y(`doc.uploading_file`),cls:`text-gray-400`});try{let i=await se(e),a=await fetch(`/api/files/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:i,name:e.name,documentId:t.docId})});if(!a.ok){let e=``;try{e=(await a.json()).error||``}catch{e=await a.text()}throw Error(e||`HTTP ${a.status}`)}let{url:o,originalName:s}=await a.json();ce(`[📎 ${s||e.name}](${o})`,n,r),c(null)}catch(e){c({text:Y(`doc.file_upload_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}}function de(){F(_,!1),b=null}async function fe(){let e=E(V(v))||Date.now().toString();if(F(_,!1),b){c({text:Y(`doc.uploading_image`),cls:`text-gray-400`});try{let t=await se(b),n=await fetch(`/api/images/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:t,ext:V(y),name:e})});if(!n.ok)throw Error(await n.text());let{filename:r}=await n.json();ce(`![image](/images/${r})`,x,S),c(null)}catch(e){c({text:Y(`doc.image_upload_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}finally{b=null}}}function pe(){F(C,null),F(w,``)}function me(e){if(!e.shiftKey&&!e.metaKey)return;let t=e.target,n=t.closest(`img`),r=t.closest(`.mermaid`)?.querySelector(`svg`);if(!n&&!r)return;if(e.preventDefault(),e.stopPropagation(),n){F(C,n.src,!0),F(w,n.alt||``,!0);return}let i=new XMLSerializer().serializeToString(r);F(C,`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),F(w,Y(`doc.mermaid_diagram_alt`),!0)}function he(e){e.key===`Escape`&&V(C)&&pe()}var ge={enterEdit:ee,cancelEdit:te,save:O,openSnippets:ne,openKanbanColumnsEditor:re,isEditing:k},_e=Jd();Nr(`keydown`,on,he);var ve=R(_e),ye=e=>{var t=Wd();yn(t),Vi(t,e=>F(u,e),()=>V(u)),Nr(`paste`,t,ie),Nr(`drop`,t,ae),Nr(`dragover`,t,oe),Ni(t,()=>V(d),e=>F(d,e)),W(e,t)},be=e=>{var t=Gd();Vi(t,e=>F(l,e),()=>V(l)),B(()=>gi(t,1,`prose prose-gray dark:prose-invert max-w-none prose-headings:scroll-mt-4 prose-headings:font-semibold prose-h1:text-[2.1875rem] prose-h2:text-[1.8125rem] prose-h3:text-[1.5rem] prose-h4:text-[1.25rem] prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-code:before:content-none prose-code:after:content-none ${X.codeBlockLightTheme?`prose-pre:bg-[#f6f8fa] prose-pre:text-gray-800 prose-pre:border prose-pre:border-gray-200 prose-pre:rounded-lg dark:prose-pre:bg-[#0d1117] dark:prose-pre:text-gray-100 dark:prose-pre:border-gray-700`:`prose-pre:bg-[#0d1117] prose-pre:border prose-pre:border-gray-700`} ${X.imageRoundedCorners?`[&_img]:rounded-xl`:``} ${X.imageCentered?`[&_img]:mx-auto [&_img]:block`:``} ${X.imageBorder?`[&_img]:[box-shadow:0_0_0_1px_rgba(0,0,0,0.10),0_4px_12px_rgba(0,0,0,0.04)] dark:[&_img]:[box-shadow:0_0_0_1px_rgba(255,255,255,0.08),0_4px_12px_rgba(255,255,255,0.25)]`:``}`)),H(`click`,t,me),W(e,t)};K(ve,e=>{s()?e(ye):e(be,-1)});var xe=z(ve,2);gd(xe,{get open(){return V(p)},get editor(){return V(u)},get mode(){return V(m)},get docId(){return t.docId},get content(){return t.content},get range(){return V(h)},get insertPos(){return V(g)},get onsave(){return t.onsave},onclose:()=>F(p,!1)});var Se=z(xe,2),Ce=e=>{var t=Kd(),n=L(t),r=L(n),i=L(r);j(r);var a=z(r,2),o=L(a),s=L(o),c=z(s),l=L(c,!0);j(c),j(o);var u=z(o,2),d=L(u);Di(d);var f=z(d,2),p=L(f);j(f),j(u),j(a);var m=z(a,2),h=L(m),g=L(h,!0);j(h);var _=z(h,2),b=L(_,!0);j(_),j(m),j(n),j(t),B((e,t,n,r,a)=>{G(i,`🖼️ ${e??``}`),G(s,`${t??``} `),G(l,n),Oi(d,V(v)),G(p,`.${V(y)??``}`),G(g,r),G(b,a)},[()=>Y(`modal.img_paste.title`),()=>Y(`modal.img_paste.filename_label`),()=>Y(`modal.img_paste.saved_hint`),()=>Y(`common.cancel`),()=>Y(`modal.img_paste.paste_btn`)]),H(`input`,d,e=>F(v,E(e.target.value),!0)),H(`click`,h,de),H(`click`,_,fe),W(e,t)};K(Se,e=>{V(_)&&e(Ce)});var A=z(Se,2),we=e=>{var t=qd(),n=L(t),r=z(n,2);j(t),B(()=>{J(n,`src`,V(C)),J(n,`alt`,V(w))}),H(`click`,t,pe),H(`click`,n,e=>e.stopPropagation()),H(`click`,r,pe),W(e,t)};return K(A,e=>{V(C)&&e(we)}),W(e,_e),Je(ge)}Pr([`click`,`input`]);var Xd=U(`<span> </span> <code> </code>`,1),Zd=U(`<button type="button" data-testid="bp-copy-doc-id"><i aria-hidden="true"></i></button>`),Qd=U(`<button class="bpadr-icon-btn" data-testid="bp-edit" type="button">✏️</button> <button class="bpadr-icon-btn" data-testid="bp-delete" type="button">🗑️</button>`,1),$d=U(`<span> </span>`),ef=U(`<footer class="bpadr-footer bpadr-doc-footer"><!> <button type="button" class="bpadr-btn-ghost" data-testid="bp-cancel"> </button> <button type="button" class="bpadr-btn-ghost" data-testid="bp-snippets"> </button> <button type="button" class="bpadr-btn-primary" data-testid="bp-save"> </button></footer>`),tf=U(`<div class="bpadr-read"><!></div> <!>`,1),nf=U(`<form class="bpadr-form"><input type="hidden" name="category"/> <input type="hidden" name="folder"/> <div class="bpadr-field"><label for="adr-title"> </label> <input id="adr-title" type="text" class="bpadr-input"/></div> <div class="bpadr-field bpadr-field-grow"><label for="adr-content"> </label> <textarea id="adr-content" class="bpadr-textarea"></textarea></div> <footer class="bpadr-footer"><button type="button" class="bpadr-btn-ghost"> </button> <button type="button" data-testid="bp-form-snippets" class="bpadr-btn-ghost"> </button> <button type="submit" class="bpadr-btn-primary"> </button></footer></form> <!>`,1),rf=U(`<div class="bpadr-folder-confirm"><p></p> <p class="bpadr-muted"> </p> <footer class="bpadr-footer"><button type="button" class="bpadr-btn-ghost"> </button> <button type="button" class="bpadr-btn-primary"> </button></footer></div>`),af=U(`<div class="bpadr-overlay"><div class="bpadr-modal"><header class="bpadr-header"><div class="bpadr-title-row"><h2 class="bpadr-title"><!></h2> <!></div> <div class="bpadr-header-actions"><!> <button class="bpadr-icon-btn" type="button" title="Close">×</button></div></header> <!></div></div>`),of=U(`<div class="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4"><div class="w-full max-w-sm bg-white dark:bg-gray-900 border border-red-200 dark:border-red-700 rounded-xl shadow-2xl p-5 flex flex-col gap-3"><p class="text-sm text-gray-700 dark:text-gray-200"> </p> <p class="text-xs text-gray-500 dark:text-gray-400 italic truncate"> </p> <div class="flex justify-end gap-2 mt-2"><button type="button" data-testid="bp-delete-cancel" class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button type="button" data-testid="bp-delete-confirm" class="text-sm px-4 py-1.5 rounded-lg bg-red-500 hover:bg-red-600 text-white font-semibold transition-colors"> </button></div></div></div>`),sf=U(`<!> <!>`,1);function cf(e,t){qe(t,!0);let n=Wi(t,`onchanged`,3,()=>{}),r=`001_BLUEPRINT`;function i(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toUpperCase().replace(/[^A-Z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`FOLDER`}function a(e){return`/${(e.folder.path||e.folder.name).replace(/^\/+|\/+$/g,``)||e.folder.name}`}let o=P(`closed`),s=P(``),c=P(``),l=P(``),u=P(``),d=P(``),f=P(``),p=P(``),m=P(``),h=P(null),g=P(null),_=P(null),v=P(!1),y=P(null),b=P(null),x=P(!1),S=P(!1),C=P(!1);async function w(e){F(g,e,!0),F(h,null),F(v,!1),F(y,null);let t=i(e.folder.name);if(F(l,t,!0),F(c,e.folder.name,!0),F(u,``),F(d,``),F(f,``),F(m,a(e),!0),F(s,Y(`blueprint.adr.new_title`,{folder:e.folder.name}),!0),F(o,`form`),!(await fetch(`/api/blueprint/blueprint-folder`).then(e=>e.json())).exists){F(p,r),F(o,`folder-confirm`);return}await E(e,t)}async function T(e){return fetch(`/api/documents/${encodeURIComponent(e)}`).then(e=>e.json())}async function E(e,t){let n=await fetch(`/api/blueprint/blueprint-adr?category=${encodeURIComponent(t)}`).then(e=>e.json());if(n.found&&n.doc){F(h,n.doc.id,!0);let e=await T(n.doc.id);F(c,e.title,!0),F(d,e.content,!0),F(f,e.html,!0),F(s,e.title,!0),F(v,!1),F(o,`doc`)}else F(c,e.folder.name,!0),F(u,``),F(o,`form`)}function D(){F(o,`closed`),F(v,!1),F(h,null),F(g,null),F(m,``),F(C,!1)}async function ee(){if(V(h))try{await navigator.clipboard.writeText(decodeURIComponent(V(h))),F(C,!0),setTimeout(()=>F(C,!1),1800)}catch{}}async function te(){await fetch(`/api/blueprint/blueprint-folder`,{method:`POST`}),V(g)&&await E(V(g),i(V(g).folder.name))}async function O(e){if(!V(h))return;await fetch(`/api/documents/${encodeURIComponent(V(h))}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:V(c).trim()||V(g)?.folder.name||Y(`common.untitled`),category:V(l),folder:r,content:e})});let t=await T(V(h));F(s,t.title,!0),F(d,t.content,!0),F(f,t.html,!0)}async function ne(e){e.preventDefault();let t={title:V(c).trim()||V(g)?.folder.name||Y(`common.untitled`),category:V(l),folder:r},i=await fetch(`/api/documents/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}).then(e=>e.json());F(h,i.id,!0);let a=await T(i.id);F(s,a.title,!0),F(d,a.content,!0),F(f,a.html,!0),F(v,!1),F(o,`doc`),n()()}async function re(){F(S,!1),V(h)&&(await fetch(`/api/documents/${encodeURIComponent(V(h))}`,{method:`DELETE`}),D(),n()())}var k={open:w},ie=sf(),ae=R(ie),oe=e=>{var t=af(),n=L(t),i=L(n),a=L(i),g=L(a),w=L(g),T=e=>{var t=Xd(),n=R(t),r=L(n,!0);j(n);var i=z(n,2),a=L(i,!0);j(i),B(e=>{G(r,e),G(a,V(m))},[()=>Y(`blueprint.adr.folder_title`)]),W(e,t)},E=e=>{var t=Ur();B(()=>G(t,V(s))),W(e,t)};K(w,e=>{V(m)?e(T):e(E,-1)}),j(g);var re=z(g,2),k=e=>{var t=Zd(),n=L(t);j(t),B(e=>{J(t,`title`,e),gi(t,1,`bpadr-copy-btn ${V(C)?`copied`:``}`),gi(n,1,`fa-${V(C)?`solid fa-check`:`regular fa-copy`}`)},[()=>Y(`doc.copy_mcp_id`)]),H(`click`,t,ee),W(e,t)};K(re,e=>{V(h)&&e(k)}),j(a);var ie=z(a,2),ae=L(ie),oe=e=>{var t=Qd(),n=R(t),r=z(n,2);B((e,t)=>{J(n,`title`,e),J(r,`title`,t)},[()=>Y(`doc.edit`),()=>Y(`doc.delete`)]),H(`click`,n,()=>V(_).enterEdit()),H(`click`,r,()=>F(S,!0)),W(e,t)};K(ae,e=>{V(o)===`doc`&&!V(v)&&e(oe)});var se=z(ae,2);j(ie),j(i);var ce=z(i,2),le=e=>{var t=tf(),n=R(t),r=L(n);{let e=N(()=>V(h)??``);Vi(Yd(r,{get docId(){return V(e)},get content(){return V(d)},get html(){return V(f)},onsave:O,get editing(){return V(v)},set editing(e){F(v,e,!0)},get saveMsg(){return V(y)},set saveMsg(e){F(y,e,!0)}}),e=>F(_,e,!0),()=>V(_))}j(n);var i=z(n,2),a=e=>{var t=ef(),n=L(t),r=e=>{var t=$d(),n=L(t,!0);j(t),B(()=>{gi(t,1,`text-xs ${V(y).cls??``}`),G(n,V(y).text)}),W(e,t)};K(n,e=>{V(y)&&e(r)});var i=z(n,2),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(t),B((e,t,n)=>{G(a,e),G(s,t),G(l,n)},[()=>Y(`common.cancel`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),H(`click`,i,()=>V(_).cancelEdit()),H(`click`,o,()=>V(_).openSnippets()),H(`click`,c,()=>V(_).save()),W(e,t)};K(i,e=>{V(v)&&e(a)}),W(e,t)},ue=e=>{var t=nf(),n=R(t),i=L(n);Di(i);var a=z(i,2);Di(a),Oi(a,r);var s=z(a,2),d=L(s),f=L(d,!0);j(d);var p=z(d,2);Di(p),j(s);var m=z(s,2),g=L(m),_=L(g,!0);j(g);var v=z(g,2);yn(v),Vi(v,e=>F(b,e),()=>V(b)),j(m);var y=z(m,2),S=L(y),C=L(S,!0);j(S);var w=z(S,2),T=L(w,!0);j(w);var E=z(w,2),ee=L(E,!0);j(E),j(y),j(n),gd(z(n,2),{get open(){return V(x)},get editor(){return V(b)},mode:`insert`,get content(){return V(u)},onclose:()=>F(x,!1)}),B((e,t,n,r,a)=>{Oi(i,V(l)),G(f,e),G(_,t),G(C,n),G(T,r),G(ee,a)},[()=>Y(`blueprint.adr.title_label`),()=>Y(`blueprint.adr.content_label`),()=>Y(`common.cancel`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),Nr(`submit`,n,ne),Ni(p,()=>V(c),e=>F(c,e)),Ni(v,()=>V(u),e=>F(u,e)),H(`click`,S,()=>{V(h)?F(o,`doc`):D()}),H(`click`,w,()=>F(x,!0)),W(e,t)},de=e=>{var t=rf(),n=L(t);ai(n,()=>Y(`blueprint.adr.folder_missing`,{name:V(p)}),!0),j(n);var r=z(n,2),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(a),j(t),B((e,t,n)=>{G(i,e),G(s,t),G(l,n)},[()=>Y(`blueprint.adr.folder_create_prompt`),()=>Y(`common.cancel`),()=>Y(`blueprint.adr.create_folder_btn`)]),H(`click`,o,D),H(`click`,c,te),W(e,t)};K(ce,e=>{V(o)===`doc`?e(le):V(o)===`form`?e(ue,1):V(o)===`folder-confirm`&&e(de,2)}),j(n),j(t),H(`click`,t,e=>{e.target===e.currentTarget&&D()}),H(`click`,se,D),W(e,t)};K(ae,e=>{V(o)!==`closed`&&e(oe)});var se=z(ae,2),ce=e=>{var t=of(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var c=z(a,2),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d,!0);j(d),j(c),j(n),j(t),B((e,t,n)=>{G(i,e),G(o,V(s)),G(u,t),G(f,n)},[()=>Y(`doc.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`doc.confirm_delete_btn`)]),H(`click`,t,e=>{e.target===e.currentTarget&&F(S,!1)}),H(`click`,l,()=>F(S,!1)),H(`click`,d,re),W(e,t)};return K(se,e=>{V(S)&&e(ce)}),W(e,ie),Je(k)}Pr([`click`]);var lf=U(`<span class="breadcrumb-sep">›</span>`),uf=U(`<span class="breadcrumb-item current"> </span>`),df=U(`<button class="breadcrumb-item" type="button"> </button>`),ff=U(`<!> <!>`,1),pf=U(`<nav class="breadcrumb"></nav>`),mf=U(`<div class="app-shell"><!> <section class="workspace-shell"><!> <!></section></div> <!>`,1);function hf(e,t){qe(t,!0),Gi(async()=>{try{await ha((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}});let n=P(I([])),r=P(null),i=P(null),a=P(null),o=P(null);function s(e){l(),V(i).loadPath(e,!0)}async function c(e){F(r,e.folder.path,!0),await xr(),await V(a).open(e.folder.path)}function l(){F(r,null)}async function u(e){await V(i).navigateToFolder(e)}var d=mf(),f=R(d),p=L(f);{let e=N(()=>Y(`blueprint.subtitle`));so(p,{title:`Blueprint`,get subtitle(){return V(e)},children:(e,t)=>{var r=pf();q(r,21,()=>V(n),Xr,(e,t,r)=>{var i=ff(),a=R(i),o=e=>{W(e,lf())};K(a,e=>{r>0&&e(o)});var c=z(a,2),l=e=>{var n=uf(),r=L(n,!0);j(n),B(()=>G(r,V(t).name)),W(e,n)},u=e=>{var n=df(),r=L(n,!0);j(n),B(()=>G(r,V(t).name)),H(`click`,n,()=>s(V(t).path)),W(e,n)};K(c,e=>{r===V(n).length-1?e(l):e(u,-1)}),W(e,i)}),j(r),W(e,r)},$$slots:{default:!0}})}var m=z(p,2),h=L(m);Vi(zo(h,{get activeExplorerPath(){return V(r)},onbreadcrumbchange:e=>F(n,e,!0),onopenexplorer:c,onclosefilerexplorer:l,onopenAdr:e=>V(o).open(e)}),e=>F(i,e,!0),()=>V(i));var g=z(h,2),_=e=>{Vi(as(e,{onclose:l,onnavigate:u}),e=>F(a,e,!0),()=>V(a))};K(g,e=>{V(r)!==null&&e(_)}),j(m),j(f),Vi(cf(z(f,2),{onchanged:()=>V(i).loadPath(V(n).at(-1)?.path??``,!1)}),e=>F(o,e,!0),()=>V(o)),W(e,d),Je()}Pr([`click`]);var gf=164,_f=64,vf=132,yf=78,bf=6,xf=24,Sf=96,Cf=540,wf=780,Tf=1/2,Ef=9999,Df=44,Of=255,kf=178,Af=Math.PI*.7,jf=Math.PI*1.1,Mf=Math.PI*1.45,Nf=Math.PI*1.75,Pf=14,Ff=260,If=56,Lf=32,Rf=[`pointerdown`,`mousedown`,`click`,`dblclick`,`touchstart`,`wheel`],zf=.35,Bf=2.2,Vf=.0018,Hf=4,Uf=46,Wf=4,Gf=44,Kf=360,qf=300,Jf=44,Yf=48,Xf=7,Zf=875,Qf=450,$f=600*1e3,ep,Z,tp,np,rp,ip,ap,op,sp,cp,lp,up,dp,fp,pp,mp,hp,gp,_p,vp,yp,bp,xp,Sp,Cp,wp,Tp,Ep,Dp=null,Op=null,kp=null,Q,$,Ap,jp=!1;function Mp(){return ep=document.getElementById(`workspaceCanvas`),Z=ep.getContext(`2d`),tp=document.getElementById(`apiStatus`),np=document.getElementById(`addButton`),rp=document.getElementById(`fitButton`),ip=document.getElementById(`testNodeButton`),ap=document.getElementById(`loadModelsButton`),op=document.getElementById(`closePanelButton`),sp=document.getElementById(`deleteNodeButton`),cp=document.getElementById(`renameConfirmOverlay`),lp=document.getElementById(`renameConfirmMessage`),up=document.getElementById(`cancelRenameButton`),dp=document.getElementById(`confirmRenameButton`),fp=document.getElementById(`deleteConfirmOverlay`),pp=document.getElementById(`deleteConfirmMessage`),mp=document.getElementById(`cancelDeleteButton`),hp=document.getElementById(`confirmDeleteButton`),gp=document.getElementById(`agentRunOverlay`),_p=document.getElementById(`agentRunTitle`),vp=document.getElementById(`agentRunHint`),yp=document.getElementById(`agentRunInputField`),bp=document.getElementById(`agentRunInput`),xp=document.getElementById(`agentRunResult`),Sp=document.getElementById(`cancelAgentRunButton`),Cp=document.getElementById(`executeAgentRunButton`),wp=document.getElementById(`fallbackPanelHost`),Tp=document.getElementById(`configSurface`),Ep=Tp,Dp=null,Op=null,kp=null,Q={name:document.getElementById(`nodeName`),kind:document.getElementById(`nodeKind`),providerIdField:document.getElementById(`providerIdField`),providerId:document.getElementById(`nodeProviderId`),copyProviderId:document.getElementById(`copyProviderIdButton`),endpoint:document.getElementById(`nodeEndpoint`),token:document.getElementById(`nodeToken`),model:document.getElementById(`nodeModel`),providerTypeChat:document.getElementById(`nodeProviderTypeChat`),providerTypeImage:document.getElementById(`nodeProviderTypeImage`),toolModeField:document.getElementById(`toolModeField`),toolModeTools:document.getElementById(`nodeToolModeTools`),toolModeChat:document.getElementById(`nodeToolModeChat`),workspaceField:document.getElementById(`agentWorkspaceField`),workspaceFolder:document.getElementById(`nodeWorkspaceFolder`),timeout:document.getElementById(`nodeTimeout`),description:document.getElementById(`nodeDescription`),typeBadge:document.getElementById(`nodeTypeBadge`),llmFields:document.getElementById(`llmFields`),mcpInventory:document.getElementById(`mcpInventory`),mcpInventoryStatus:document.getElementById(`mcpInventoryStatus`),mcpToolsList:document.getElementById(`mcpToolsList`),mcpPromptsList:document.getElementById(`mcpPromptsList`),agentSection:document.getElementById(`agentSection`),agentProvider:document.getElementById(`nodeAgentProvider`),systemPrompt:document.getElementById(`nodeSystemPrompt`),requiresUserInput:document.getElementById(`nodeRequiresUserInput`),userInputDescriptionField:document.getElementById(`agentUserInputDescriptionField`),userInputDescription:document.getElementById(`nodeUserInputDescription`),expectedOutputMarker:document.getElementById(`nodeExpectedOutputMarker`)},$={entities:Qp([Zp(`root`,`Living AI Documentation`,`system`,null),Zp(`mcp`,`MCP`,`mcp`,`root`)]),selectedId:null,cameraX:0,cameraY:0,zoom:1,isPanning:!1,panStartX:0,panStartY:0,panStartCameraX:0,panStartCameraY:0,didPan:!1,viewAnimationId:null,dpr:window.devicePixelRatio||1,apiMode:`fallback`,lastSaveAt:null,pendingDeleteId:null,panelShiftX:0,saveTimerId:null,panelDirty:!1,isHydrated:!1},jp=!!ep.requestPaint&&typeof Z.drawElementImage==`function`,jp?($.apiMode=`html-in-canvas`,tp.textContent=`HTML-in-Canvas active`,tp.classList.add(`is-live`),ep.onpaint=nh):(wp.appendChild(Tp),tp.textContent=`DOM fallback`,tp.classList.add(`is-fallback`)),Ap=new ResizeObserver(([e])=>{let t=e.devicePixelContentBoxSize?.[0],n=e.contentRect.width,r=e.contentRect.height;$.dpr=t?t.inlineSize/n:window.devicePixelRatio||1,ep.width=t?t.inlineSize:Math.floor(n*$.dpr),ep.height=t?t.blockSize:Math.floor(r*$.dpr),om(),fh(!1,!$.cameraX&&!$.cameraY),th()}),Ap.observe(ep,{box:`device-pixel-content-box`}),Np(),Pp(),np.addEventListener(`click`,()=>{rm()}),rp.addEventListener(`click`,()=>{om(),fh(!0,!0),zp(),th()}),ep.addEventListener(`pointerdown`,e=>{if(e.target!==ep)return;let t=Fh(e),n=Sh(t),r=[...$.entities].reverse().find(e=>Oh(e,n));if(r){r.id!==`root`&&vm(r.id);return}$.isPanning=!0,$.didPan=!1,$.panStartX=t.x,$.panStartY=t.y,$.panStartCameraX=$.cameraX,$.panStartCameraY=$.cameraY,ep.classList.add(`is-panning`),ep.setPointerCapture?.(e.pointerId)}),ep.addEventListener(`pointermove`,e=>{if(!$.isPanning)return;let t=Fh(e),n=t.x-$.panStartX,r=t.y-$.panStartY;Math.hypot(n,r)>Hf&&($.didPan=!0),$.cameraX=$.panStartCameraX+n,$.cameraY=$.panStartCameraY+r,th()}),ep.addEventListener(`pointerup`,e=>{$.isPanning&&($.isPanning=!1,ep.classList.remove(`is-panning`),ep.releasePointerCapture?.(e.pointerId),!$.didPan&&$.selectedId?vm(null):$.didPan&&zp())}),ep.addEventListener(`pointercancel`,e=>{$.isPanning=!1,ep.classList.remove(`is-panning`),ep.releasePointerCapture?.(e.pointerId)}),ep.addEventListener(`wheel`,e=>{e.target===ep&&(e.preventDefault(),xh(Fh(e),Math.exp(-e.deltaY*Vf)),zp())},{passive:!1}),Ep.addEventListener(`submit`,e=>{e.preventDefault(),Em(),$.lastSaveAt=new Date,om(),Vp(!0),th()}),Ep.addEventListener(`input`,()=>{Em(),om(),$.panelDirty=!0,th()}),op.addEventListener(`click`,()=>{vm(null)}),sp.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let t=$.selectedId,n=t?Zm(t):null;!n||Qm(t)||ym(n)}),mp.addEventListener(`click`,bm),fp.addEventListener(`click`,e=>{e.target===fp&&bm()}),hp.addEventListener(`click`,()=>{$.pendingDeleteId&&xm($.pendingDeleteId),bm()}),ip.addEventListener(`click`,()=>{if(Xm()?.kind===`agent`){Mm();return}Gm()}),ap.addEventListener(`click`,()=>{Wm()}),Q.copyProviderId.addEventListener(`click`,()=>{qm()}),Q.name.addEventListener(`blur`,()=>{if(Xm()?.kind!==`agent`)return;let e=Q.name.value.trim();if(!e||!Dp||!Op||e===Dp)return;let t=em(e);t!==Op&&(lp.textContent=`Renommer le dossier "${Op}" en "${t}" ?`,cp.hidden=!1,up.focus())}),up.addEventListener(`click`,()=>{cp.hidden=!0;let e=Xm();e&&Dp&&(e.label=Dp,Q.name.value=Dp,om(),th())}),dp.addEventListener(`click`,()=>{cp.hidden=!0;let e=Xm();if(!e||!Op)return;e.config.workspaceFolder=Op,Q.workspaceFolder.value=Op;let t=Q.name.value.trim();t&&(Dp=t),Op=em(t),zp()}),Q.model.addEventListener(`change`,()=>{ip.disabled=!Q.model.value;let e=Xm();e&&(e.config.model=Q.model.value)}),Q.agentProvider.addEventListener(`change`,()=>{Om(Q.agentProvider.value)}),Sp.addEventListener(`click`,()=>{Nm()}),Cp.addEventListener(`click`,()=>{Pm()}),gp.addEventListener(`click`,e=>{e.target===gp&&Nm()}),Ip(),()=>{Bp(),Ap.disconnect(),$?.saveTimerId&&clearTimeout($.saveTimerId)}}function Np(){for(let e of Rf)Tp.addEventListener(e,Fp),wp.addEventListener(e,Fp)}function Pp(){for(let e of Rf)fp.addEventListener(e,Fp),cp.addEventListener(e,Fp),gp.addEventListener(e,Fp)}function Fp(e){e.stopPropagation()}async function Ip(){let e=await La();e?.entities?.length&&($.entities=Lp(e.entities),$.cameraX=Xp(e.camera?.x,$.cameraX),$.cameraY=Xp(e.camera?.y,$.cameraY),$.zoom=Ch(Xp(e.camera?.zoom,$.zoom),zf,Bf),$.lastSaveAt=e.updatedAt?new Date(e.updatedAt):null),$.isHydrated=!0,om(),e?.entities?.length||fh(!1,!0),Tm(),th()}function Lp(e){let t=e.map(Rp).filter(e=>!!e),n=t.some(e=>e.id===`root`),r=t.some(e=>e.id===`mcp`),i=[...n?[]:[Zp(`root`,`Living AI Documentation`,`system`,null)],...t,...r?[]:[Zp(`mcp`,`MCP`,`mcp`,`root`)]],a=new Set(i.map(e=>e.id));return i.map(e=>{let t=e.id===`root`?`system`:e.id===`mcp`?`mcp`:e.kind,n=e.id===`root`?null:e.id===`mcp`?`root`:e.parentId&&a.has(e.parentId)?e.parentId:null;return{...e,kind:t,parentId:n,config:{...Zp(e.id,e.label,t,n).config,...e.config}}})}function Rp(e){if(!Gp(e))return null;let t=Kp(e.id),n=Kp(e.label),r=qp(e.kind);if(!t||!n||!r)return null;let i=e.parentId===null?null:Kp(e.parentId),a=Gp(e.config)?e.config:{};return{id:t,label:n,kind:r,parentId:i,x:Xp(e.x,0),y:Xp(e.y,0),angle:Xp(e.angle,0),config:{endpoint:Kp(a.endpoint)||$p(t,r),token:Kp(a.token),model:Kp(a.model),providerType:Yp(a.providerType),toolMode:Jp(a.toolMode),timeout:Xp(a.timeout,180),description:Kp(a.description)||nm(r),workspaceFolder:Kp(a.workspaceFolder)||(r===`agent`?em(n):``),systemPrompt:Kp(a.systemPrompt),requiresUserInput:a.requiresUserInput===!0,userInputDescription:Kp(a.userInputDescription),expectedOutputMarker:Kp(a.expectedOutputMarker)}}}function zp(){$.isHydrated&&($.saveTimerId&&clearTimeout($.saveTimerId),$.saveTimerId=window.setTimeout(()=>{$.saveTimerId=null,Vp(!1)},Qf))}function Bp(){$.panelDirty&&Vp(!1)}async function Vp(e=!1){if(!$.isHydrated)return;$.panelDirty=!1,$.saveTimerId&&(clearTimeout($.saveTimerId),$.saveTimerId=null);let t=$.selectedId&&document.activeElement===Q.token&&Vm(Q.token.value)?{entityId:$.selectedId,value:Q.token.value,selectionStart:Q.token.selectionStart,selectionEnd:Q.token.selectionEnd}:null,n=await Ra(Wp());if(n){if($.entities=Lp(n.entities),t&&$.selectedId===t.entityId){let e=Xm();e?.kind===`llm`&&(e.config.token=t.value)}$.lastSaveAt=new Date(n.updatedAt),Xm()&&!Ep.contains(document.activeElement)&&Tm(),t&&$.selectedId===t.entityId&&(Q.token.value=t.value,Q.token.setSelectionRange(t.selectionStart,t.selectionEnd)),e&&Up(`Workspace saved`)}else e&&Up(`Save failed`)}function Hp(e,t){return Pa(e,t)}function Up(e,t=`success`,n,r){return Fa(e,t,n,r)}function Wp(){return{version:1,updatedAt:new Date().toISOString(),entities:$.entities.map(e=>{let t={...e.config,token:Hm(e.config.token)};return{id:e.id,label:e.label,kind:e.kind,parentId:e.parentId,x:e.x,y:e.y,angle:e.angle,config:t}}),camera:{x:$.cameraX,y:$.cameraY,zoom:$.zoom}}}function Gp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Kp(e){return typeof e==`string`?e:``}function qp(e){return e===`system`||e===`llm`||e===`agent`||e===`mcp`?e:null}function Jp(e){return e===`chat`?`chat`:`tools`}function Yp(e){return e===`image`?`image`:`chat`}function Xp(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function Zp(e,t,n,r){return{id:e,label:t,kind:n,parentId:r,x:0,y:0,angle:0,config:{endpoint:$p(e,n),token:``,model:``,providerType:`chat`,toolMode:`tools`,timeout:180,description:nm(n),workspaceFolder:n===`agent`?em(t):``,systemPrompt:``,requiresUserInput:!1,userInputDescription:``,expectedOutputMarker:``}}}function Qp(e){return e.map(e=>({...e,config:{...e.config}}))}function $p(e,t){return t===`llm`?`http://localhost:11434`:t===`mcp`?`http://localhost:4321/mcp`:``}function em(e){return`AI/WORKSPACE/${tm(e)}`}function tm(e){return e.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`llm_provider`}function nm(e){let t={system:`Owns the documentation workspace, MCP access, providers, and agent topology.`,llm:`Routes model calls and hosts the agents assigned to this provider.`,agent:`Runs focused automation against documentation, source, or quality signals.`,mcp:`Exposes the local Living Documentation MCP consultation panel to agents.`};return t[e]||t.agent}function rm(){let e=Xm(),t=e?.kind===`llm`?e:Zm(e?.parentId);if(t?.kind===`llm`&&t.config.providerType!==`image`){am(t.id);return}im()}function im(){let e=!!$.selectedId,t=$m(`root`).filter(e=>e.kind===`llm`).length+1,n=Zp(`provider-${Date.now().toString(36)}`,`LLM Provider ${t}`,`llm`,`root`);$.entities=[...$.entities,n],$.selectedId=n.id,om(),ph(e,!0,!0),Tm(),zp(),th()}function am(e){let t=!!$.selectedId,n=$m(e).filter(e=>e.kind===`agent`).length+1,r=Zp(`agent-${Date.now().toString(36)}`,`Agent ${n}`,`agent`,e);$.entities=[...$.entities,r],$.selectedId=r.id,om(),ph(t,!0,!0),Tm(),zp(),th()}function om(){let e=Zm(`root`);e.x=0,e.y=0,e.angle=0,sm(e)}function sm(e){let t=$m(e.id),n=pm(t,vf,Of,{spread:Math.PI*2,includeSubtree:!1}),r=new Map(t.map(e=>[e.id,dm(e,n)]));for(let n=0;n<=Xf;n+=1)if(cm(e,t,r),lm(),!um(t,r))return;cm(e,t,r),lm()}function cm(e,t,n){let r=Math.max(1,t.length);t.forEach((t,i)=>{let a=-Math.PI/2+i/r*Math.PI*2,o=n.get(t.id)||Of;t.angle=a,t.x=e.x+Math.cos(a)*o,t.y=e.y+Math.sin(a)*o})}function lm(){for(let e of $.entities.filter(e=>e.kind===`llm`))fm(e)}function um(e,t){let n=!1;for(let r=0;r<e.length;r+=1)for(let i=r+1;i<e.length;i+=1){let a=e[r],o=e[i];Ph(jh(a),jh(o),Jf)&&(t.set(a.id,Math.min(Zf,t.get(a.id)+Yf)),t.set(o.id,Math.min(Zf,t.get(o.id)+Yf)),n=!0)}return n}function dm(e,t){if(e.kind!==`llm`)return t;let n=$m(e.id).length;if(n<=Wf)return t;let r=(n-Wf)*Gf,i=Math.max(0,gm(e)-qf)*.65;return t+Math.min(Kf,Math.max(r,i))}function fm(e){let t=$m(e.id);if(!t.length)return;let n=Math.atan2(e.y,e.x),r=mm(t.length),i=pm(t,yf,kf,{spread:r,includeSubtree:!1});t.forEach((a,o)=>{let s=hm(n,r,o,t.length);a.angle=s,a.x=e.x+Math.cos(s)*i,a.y=e.y+Math.sin(s)*i})}function pm(e,t,n,r={}){if(!e.length)return n;let i=!!r.includeSubtree,a=r.spread||Math.PI*2,o=Math.max(...e.map(e=>i?gm(e):_m(e))),s=t+o+Uf;if(e.length===1)return Math.max(n,s);let c=o*2+Uf,l=a>=Math.PI*2-.001?Math.PI*2/e.length:a/(e.length-1),u=c/(2*Math.sin(l/2));return Math.max(n,s,u)}function mm(e){return e<=1?0:e<=2?Af:e<=4?jf:e<=7?Mf:Nf}function hm(e,t,n,r){return r<=1||t===0?e:e-t/2+n/(r-1)*t}function gm(e){if(e.kind!==`llm`)return _m(e);let t=$m(e.id);return t.length?pm(t,yf,kf,{spread:mm(t.length),includeSubtree:!1})+Math.max(...t.map(e=>_m(e))):yf}function _m(e){if(e.kind===`system`)return vf;if(e.kind===`llm`)return yf;let{width:t,height:n}=Ah(e);return Math.hypot(t/2,n/2)}function vm(e){e!==$.selectedId&&Bp();let t=!!$.selectedId;$.selectedId=e;let n=e?Zm(e):null;Dp=n?.kind===`agent`?n.label:null,Op=n?.kind===`agent`?n.config.workspaceFolder||em(n.label):null,om(),ph(t,!!e,!0),Tm(),th()}function ym(e){let t=eh(e.id),n=$m(e.id).length,r=t.length?` This node has ${n} direct child${n===1?``:`ren`} and ${t.length} total descendant${t.length===1?``:`s`}; they will also be deleted.`:` This node has no children.`;$.pendingDeleteId=e.id,pp.textContent=`You are about to delete "${e.label}".${r} This action cannot be undone.`,fp.hidden=!1,hp.focus()}function bm(){$.pendingDeleteId=null,fp.hidden=!0}function xm(e){let t=Zm(e);if(!t||Qm(e))return;let n=t.parentId||`root`,r=!!$.selectedId,i=new Set([e,...eh(e)]);$.entities=$.entities.filter(e=>!i.has(e.id)),$.selectedId=Zm(n)?n:null,om(),ph(r,!!$.selectedId,!0),Tm(),zp(),th()}var Sm=0;async function Cm(e){let t=++Sm,n=e.config.endpoint.trim(),r=Q.mcpInventoryStatus;if(Q.mcpToolsList.replaceChildren(),Q.mcpPromptsList.replaceChildren(),!n){r.hidden=!1,r.textContent=`Set an endpoint to load the MCP tools and prompts.`;return}r.hidden=!1,r.textContent=`Loading MCP tools and prompts…`;let i=await Ba({endpoint:n});if(t===Sm){if(!i.ok){r.hidden=!1,r.textContent=i.error?`Failed to load MCP inventory: ${i.error}`:`Failed to load MCP inventory.`;return}r.hidden=!0,wm(Q.mcpToolsList,i.tools??[],`No tools exposed.`),wm(Q.mcpPromptsList,i.prompts??[],`No prompts exposed.`)}}function wm(e,t,n){if(e.replaceChildren(),t.length===0){let t=document.createElement(`li`);t.className=`inventory-empty`,t.textContent=n,e.appendChild(t);return}for(let n of t){let t=document.createElement(`li`);t.textContent=n,e.appendChild(t)}}function Tm(){let e=Xm(),t=!!e;if(Tp.hidden=!t,wp.hidden=!t||jp,!e){np.title=`Add LLM provider`,ip.textContent=`Test`,ip.hidden=!0,ip.disabled=!0;return}Q.name.value=e.label,Q.kind.value=e.kind,Q.providerId.value=e.kind===`llm`?e.id:``,Q.endpoint.value=e.config.endpoint,Q.token.value=e.config.token,jm(e.config.model),Q.providerTypeChat.checked=e.config.providerType!==`image`,Q.providerTypeImage.checked=e.config.providerType===`image`,Q.toolModeTools.checked=e.config.toolMode!==`chat`,Q.toolModeChat.checked=e.config.toolMode===`chat`,Q.workspaceFolder.value=e.config.workspaceFolder,Q.workspaceField.hidden=e.kind!==`agent`,Q.timeout.value=String(e.config.timeout),Q.description.value=e.config.description,Q.typeBadge.textContent=Ym(e),Q.kind.disabled=!0,Q.llmFields.hidden=e.kind===`mcp`||e.kind===`agent`,Am(e),Q.mcpInventory.hidden=e.kind!==`mcp`,e.kind===`mcp`?Cm(e):Sm+=1,Q.agentSection.hidden=e.kind!==`agent`,e.kind===`agent`&&Dm(e),Q.systemPrompt.value=e.config.systemPrompt,Q.requiresUserInput.checked=e.config.requiresUserInput,km(),Q.userInputDescription.value=e.config.userInputDescription,Q.expectedOutputMarker.value=e.config.expectedOutputMarker,sp.hidden=Qm(e.id),ip.textContent=`Test`,ip.hidden=e.kind!==`llm`&&e.kind!==`agent`,ip.disabled=e.kind===`llm`?!e.config.model:e.kind!==`agent`;let n=e.kind===`llm`?e:Zm(e.parentId);np.title=n?.kind===`llm`&&n.config.providerType!==`image`?`Add agent`:`Add LLM provider`}function Em(){let e=Xm();if(e&&(e.label=Q.name.value.trim()||`Untitled node`,e.kind=Q.kind.value,e.config.endpoint=Q.endpoint.value,e.config.token=Q.token.value,e.config.model=Q.model.value,e.config.providerType=Q.providerTypeImage.checked?`image`:`chat`,e.config.toolMode=Q.toolModeChat.checked?`chat`:`tools`,e.config.timeout=Number(Q.timeout.value||30),e.config.description=Q.description.value,e.config.systemPrompt=Q.systemPrompt.value,e.config.requiresUserInput=Q.requiresUserInput.checked,e.config.userInputDescription=Q.userInputDescription.value,e.config.expectedOutputMarker=Q.expectedOutputMarker.value,km(),Am(e),Q.typeBadge.textContent=Ym(e),e.kind===`llm`))for(let t of $.entities)t.parentId===e.id&&t.kind===`agent`&&(t.config.model=e.config.model,t.config.timeout=e.config.timeout)}function Dm(e){let t=Q.agentProvider;t.innerHTML=``;let n=$.entities.filter(e=>e.kind===`llm`&&e.config.providerType!==`image`);for(let e of n){let n=document.createElement(`option`);n.value=e.id,n.textContent=e.label,t.appendChild(n)}t.value=e.parentId??``}function Om(e){let t=Xm();if(t?.kind!==`agent`)return;let n=Zm(e);n?.kind===`llm`&&t.parentId!==e&&(t.parentId=e,t.config.model=n.config.model,t.config.timeout=n.config.timeout,om(),zp(),th())}function km(){let e=Xm()?.kind===`agent`&&Q.requiresUserInput.checked;Q.userInputDescriptionField.hidden=!e,Q.userInputDescription.required=e}function Am(e){let t=e.kind===`llm`,n=e.config.providerType===`image`;Q.providerIdField.hidden=!t,Q.toolModeField.hidden=!t||n,ap.title=n?`Load image models from endpoint`:`Load chat models from endpoint`,ip.title=n?`Test image provider configuration`:`Test chat provider configuration`}function jm(e){let t=Array.from(Q.model.options).map(e=>e.value);if(e&&!t.includes(e)){Q.model.innerHTML=``;let t=document.createElement(`option`);t.value=e,t.textContent=e,Q.model.appendChild(t)}Q.model.value=e||(t[0]??``)}function Mm(){let e=Xm();if(e?.kind!==`agent`)return;Em();let t=Zm(e.parentId??``);if(t?.kind!==`llm`){Up(`No parent LLM found for this agent.`,`error`);return}if(!t.config.model){Up(`Parent LLM has no model selected.`,`error`);return}if(!e.config.systemPrompt.trim()){Up(`Write a system prompt first.`,`error`);return}if(e.config.requiresUserInput&&!e.config.userInputDescription.trim()){Up(`Describe the required user input first.`,`error`);return}kp=e.id,_p.textContent=`Test ${e.label}`,vp.textContent=e.config.requiresUserInput?e.config.userInputDescription:`Run this agent with its configured system prompt.`,yp.hidden=!e.config.requiresUserInput,bp.required=e.config.requiresUserInput,bp.value=``,xp.hidden=!0,xp.textContent=``,Cp.disabled=!1,Cp.textContent=`Run`,gp.hidden=!1,e.config.requiresUserInput?window.setTimeout(()=>bp.focus(),0):window.setTimeout(()=>Cp.focus(),0)}function Nm(){gp.hidden=!0,kp=null}async function Pm(){if(bp.required&&!bp.value.trim()){bp.reportValidity();return}let e=kp?Zm(kp):null;if(e?.kind!==`agent`){zm(`error`,`The selected agent is no longer available.`);return}let t=Zm(e.parentId??``);if(t?.kind!==`llm`){zm(`error`,`No parent LLM found for this agent.`);return}Cp.disabled=!0,Cp.textContent=`Running…`;let n=Hp(`Running agent…`);Im();let r=$.entities.find(e=>e.kind===`mcp`),i=!1,a=await Va({providerId:t.id,endpoint:t.config.endpoint,model:t.config.model,systemPrompt:e.config.systemPrompt,userInput:bp.value.trim()||void 0,timeout:t.config.timeout,mcpEndpoint:t.config.toolMode===`chat`?void 0:r?.config.endpoint||void 0,toolMode:t.config.toolMode,expectedOutputMarker:e.config.expectedOutputMarker||void 0},e=>{e.type===`error`&&(i=!0),e.type!==`final`&&e.type!==`error`&&Hp(Fm(e),n),Lm(e)});Cp.disabled=!1,Cp.textContent=`Run`,a.ok&&a.content?(Rm(a.content),Up(`Agent responded. Result saved in AI/WORKSPACE.`,`success`,$f,n)):(i||Lm({type:`error`,message:a.error??`Agent failed.`}),xp.dataset.state=`error`,Up(a.error??`Agent failed.`,`error`,$f,n))}function Fm(e){return e.type===`tool_call`&&e.toolName?`Agent tool call: ${e.toolName}`:e.type===`tool_result`&&e.toolName?`Agent tool result: ${e.toolName}`:`Agent: ${e.message}`}function Im(){xp.hidden=!1,xp.dataset.state=`loading`,xp.textContent=``,Lm({type:`status`,message:`Preparing agent request`})}function Lm(e){xp.hidden=!1,e.type===`error`&&(xp.dataset.state=`error`);let t=document.createElement(`div`);t.className=`agent-run-event agent-run-event-${e.type.replace(`_`,`-`)}`;let n=document.createElement(`span`);n.className=`agent-run-event-dot`,n.setAttribute(`aria-hidden`,`true`);let r=document.createElement(`div`);r.className=`agent-run-event-body`;let i=document.createElement(`p`);i.className=`agent-run-event-title`,i.textContent=e.message,r.appendChild(i);let a=[];if(e.turn&&a.push(`Turn ${e.turn}`),e.toolName&&a.push(e.toolName),e.detail&&a.push(e.detail),a.length){let e=document.createElement(`p`);e.className=`agent-run-event-meta`,e.textContent=a.join(` · `),r.appendChild(e)}t.append(n,r),xp.appendChild(t),xp.scrollTop=xp.scrollHeight}function Rm(e){xp.dataset.state=`success`;let t=document.createElement(`section`);t.className=`agent-run-final`;let n=document.createElement(`h3`);n.textContent=`Final response`;let r=document.createElement(`pre`);r.textContent=e,t.append(n,r),xp.appendChild(t),xp.scrollTop=xp.scrollHeight}function zm(e,t){xp.hidden=!1,xp.dataset.state=e,xp.textContent=t}var Bm=/^(?:env:[A-Za-z_][A-Za-z0-9_]*|\$\{[A-Za-z_][A-Za-z0-9_]*\})$/;function Vm(e){let t=e.trim();return t!==``&&!Bm.test(t)}function Hm(e){let t=e.trim();return Vm(t)?``:t}var Um=`API token must reference an environment variable, e.g. env:LLM_API_KEY`;async function Wm(){let e=Xm();if(e?.kind!==`llm`)return;Em();let t=e.config.endpoint;if(!t){Up(`Set an endpoint first.`);return}if(Vm(e.config.token)){Up(Um);return}ap.classList.add(`loading`),ap.disabled=!0,Q.model.disabled=!0;let n=await za({endpoint:t,token:e.config.token,providerType:e.config.providerType});if(ap.classList.remove(`loading`),ap.disabled=!1,Q.model.disabled=!1,!n.ok||!n.models?.length){Up(n.error??`No models found.`);return}let r=Q.model.value;Q.model.innerHTML=``;for(let e of n.models){let t=document.createElement(`option`);t.value=e,t.textContent=e,Q.model.appendChild(t)}Q.model.value=n.models.includes(r)?r:n.models[0],e.config.model=Q.model.value,ip.disabled=!Q.model.value,Up(`${n.models.length} model${n.models.length===1?``:`s`} loaded.`),th()}async function Gm(){let e=Xm();if(e?.kind!==`llm`)return;if(Em(),Vm(e.config.token)){Up(Um);return}ip.disabled=!0,Hp(`Testing ${e.config.model}…`),th();let t=e.config.providerType===`image`?await Km(e):await Ua({endpoint:e.config.endpoint,token:e.config.token,model:e.config.model,timeout:e.config.timeout});ip.disabled=!1,t.ok?Up(t.detail??`Connection OK`,`success`):Up(t.error||`Connection failed (${t.status||`no status`})`,`error`),th()}async function Km(e){let t=await za({endpoint:e.config.endpoint,token:e.config.token,providerType:`image`});if(!t.ok)return{ok:!1,error:t.error??`Image provider test failed`};let n=e.config.model.trim();return n&&t.models?.length&&!t.models.includes(n)?{ok:!1,error:`Image models loaded, but "${n}" was not found.`}:{ok:!0,detail:`${t.models?.length??0} image model${t.models?.length===1?``:`s`} available`}}async function qm(){let e=Xm();if(e?.kind===`llm`)try{await navigator.clipboard.writeText(e.id),Up(`Provider ID copied`,`success`)}catch{Q.providerId.select(),Up(`Provider ID selected`,`success`)}}function Jm(e){return{system:`System`,llm:`LLM provider`,agent:`Agent`,mcp:`MCP`}[e]||`Node`}function Ym(e){return e.kind===`llm`&&e.config.providerType===`image`?`Image provider`:Jm(e.kind)}function Xm(){return $.selectedId?Zm($.selectedId):null}function Zm(e){return $.entities.find(t=>t.id===e)}function Qm(e){return e===`root`||e===`mcp`}function $m(e){return $.entities.filter(t=>t.parentId===e)}function eh(e){let t=[];for(let n of $m(e))t.push(n.id,...eh(n.id));return t}function th(){jp?ep.requestPaint():requestAnimationFrame(nh)}function nh(){let e=ep.width/$.dpr,t=ep.height/$.dpr;Z.reset(),Z.setTransform($.dpr,0,0,$.dpr,0,0),Z.clearRect(0,0,e,t),Z.save(),Z.translate($.cameraX,$.cameraY),Z.scale($.zoom,$.zoom),rh(e,t),ih(),Z.restore(),jp&&dh(e,t)}function rh(e,t){Z.save(),Z.lineWidth=1/$.zoom;let n=Sh({x:0,y:0}),r=Sh({x:e,y:t}),i=Math.floor(n.x/xf)*xf,a=Math.ceil(r.x/xf)*xf,o=Math.floor(n.y/xf)*xf,s=Math.ceil(r.y/xf)*xf;for(let e=i;e<=a;e+=xf)Z.strokeStyle=e%Sf===0?`#d7dce5`:`#edf0f4`,zh(e,o,e,s);for(let e=o;e<=s;e+=xf)Z.strokeStyle=e%Sf===0?`#d7dce5`:`#edf0f4`,zh(i,e,a,e);Z.restore()}function ih(){ah();for(let e of $.entities)oh(e)}function ah(){Z.save(),Z.lineWidth=2/$.zoom;for(let e of $.entities){let t=Zm(e.parentId);if(!t)continue;let n=Math.atan2(e.y-t.y,e.x-t.x),r=wh(t,n),i=wh(e,n+Math.PI);Z.strokeStyle=lh(e).connection,Z.beginPath(),Z.moveTo(r.x,r.y),Z.lineTo(i.x,i.y),Z.stroke()}Z.restore()}function oh(e){if(e.kind===`system`||e.kind===`llm`){sh(e);return}ch(e)}function sh(e){let t=e.id===$.selectedId,n=lh(e),r=e.kind===`system`?vf:yf,i=$m(e.id),a=Math.max(bf,i.length),o=Ih(e.x,e.y,r,a);Z.save(),Z.beginPath(),o.forEach((e,t)=>{t===0?Z.moveTo(e.x,e.y):Z.lineTo(e.x,e.y)}),Z.closePath(),Z.fillStyle=t?n.selectedFill:n.fill,Z.strokeStyle=t?n.selectedStroke:n.stroke,Z.lineWidth=(t?3:2)/$.zoom,Z.shadowColor=n.shadow,Z.shadowBlur=e.kind===`system`?20:14,Z.shadowOffsetY=e.kind===`system`?8:5,Z.fill(),Z.shadowColor=`transparent`,Z.stroke(),Z.fillStyle=t?n.selectedText:n.text,Z.textAlign=`center`,Z.textBaseline=`middle`,Z.font=e.kind===`system`?`800 21px Inter, system-ui, sans-serif`:`800 16px Inter, system-ui, sans-serif`,Rh(e.label,e.x,e.y-8,r*1.32,e.kind===`system`?26:20),uh(e,t,r),Z.restore()}function ch(e){let t=e.id===$.selectedId,n=lh(e),r=e.kind===`mcp`?116:gf,i=e.kind===`mcp`?58:_f;Z.save(),Lh(e.x-r/2,e.y-i/2,r,i,20),Z.fillStyle=t?n.selectedFill:n.fill,Z.strokeStyle=t?n.selectedStroke:n.stroke,Z.lineWidth=(t?3:2)/$.zoom,Z.shadowColor=n.shadow,Z.shadowBlur=10,Z.shadowOffsetY=4,Z.fill(),Z.shadowColor=`transparent`,Z.stroke(),Z.fillStyle=t?n.selectedText:n.text,Z.font=`760 15px Inter, system-ui, sans-serif`,Z.textAlign=`center`,Z.textBaseline=`middle`,Rh(e.label,e.x,e.y,r*.78,18),uh(e,t,Math.max(r,i)/2),Z.restore()}function lh(e){if(e.kind===`system`)return{fill:`#111827`,stroke:`#111827`,selectedFill:`#111827`,selectedStroke:`#111827`,text:`#ffffff`,selectedText:`#ffffff`,shadow:`rgb(17 24 39 / 18%)`,connection:`#475569`};if(e.kind===`llm`&&e.config.providerType===`image`)return{fill:`#facc15`,stroke:`#ca8a04`,selectedFill:`#eab308`,selectedStroke:`#a16207`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(250 204 21 / 22%)`,connection:`#ca8a04`};if(e.kind===`llm`&&e.config.toolMode===`chat`)return{fill:`#f472b6`,stroke:`#db2777`,selectedFill:`#ec4899`,selectedStroke:`#be185d`,text:`#500724`,selectedText:`#500724`,shadow:`rgb(244 114 182 / 20%)`,connection:`#db2777`};if(e.kind===`llm`)return{fill:`#f97316`,stroke:`#ea580c`,selectedFill:`#fb923c`,selectedStroke:`#c2410c`,text:`#431407`,selectedText:`#431407`,shadow:`rgb(249 115 22 / 20%)`,connection:`#ea580c`};if(e.kind===`mcp`)return{fill:`#64748b`,stroke:`#475569`,selectedFill:`#475569`,selectedStroke:`#334155`,text:`#ffffff`,selectedText:`#ffffff`,shadow:`rgb(100 116 139 / 18%)`,connection:`#64748b`};if(e.kind===`agent`){let t=Zm(e.parentId);return t?.kind===`llm`&&t.config.toolMode===`chat`?{fill:`#f9a8d4`,stroke:`#f472b6`,selectedFill:`#ec4899`,selectedStroke:`#db2777`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(244 114 182 / 18%)`,connection:`#f472b6`}:{fill:`#fdba74`,stroke:`#f97316`,selectedFill:`#fb923c`,selectedStroke:`#ea580c`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(249 115 22 / 18%)`,connection:`#f97316`}}return{fill:`#ffffff`,stroke:`#0f172a`,selectedFill:`#111827`,selectedStroke:`#0f172a`,text:`#111827`,selectedText:`#ffffff`,shadow:`rgb(15 23 42 / 8%)`,connection:`#111827`}}function uh(e,t,n){t&&(Z.beginPath(),Z.arc(e.x+n*.62,e.y-n*.66,5,0,Math.PI*2),Z.fillStyle=`#34d399`,Z.fill())}function dh(e,t){if(!Xm())return;let n=kh(e),r=Math.min(Ef,t-118),i=e-n-24,a=Math.max(24,(t-r)/2);try{let e=Z.drawElementImage(Tp,i,a,n,r);Tp.style.transform=e.toString()}catch{tp.textContent=`Waiting for HTML snapshot`}}function fh(e,t){let n=ep.clientWidth,r=ep.clientHeight,i=Xm()?kh(n)+Df:0,a=Math.max(360,n-i),o=vh(),s=yh(o,a,r),c=t?s:Math.min($.zoom,s),l=(o.minX+o.maxX)/2,u=(o.minY+o.maxY)/2,d=a*.5-l*c,f=r*.5-u*c;if(!e||!$.cameraX||!$.cameraY){bh(),$.cameraX=d,$.cameraY=f,$.zoom=c,$.panelShiftX=i;return}$.panelShiftX=i,_h(d,f,c)}function ph(e,t,n){if(t){if(e){let e=mh();$.panelShiftX+=Math.max(0,-e),gh(e,n)}else{let e=Xm();if(e){let t=kh(ep.clientWidth)+Df,n=(ep.clientWidth-t)/2-e.x*$.zoom,r=n-$.cameraX;$.panelShiftX=-r,_h(n,$.cameraY,$.zoom)}}return}if(!e)return;let r=$.panelShiftX;$.panelShiftX=0,gh(r,n)}function mh(){let e=Xm();if(!e)return 0;let t=ep.clientWidth-kh(ep.clientWidth)-24-Lf,n=hh(e);return n.right<=t?0:t-n.right}function hh(e){let t=Mh(e);return{left:t.left*$.zoom+$.cameraX,top:t.top*$.zoom+$.cameraY,right:t.right*$.zoom+$.cameraX,bottom:t.bottom*$.zoom+$.cameraY}}function gh(e,t){if(bh(),!e)return;let n=$.cameraX+e;if(!t){$.cameraX=n;return}_h(n,$.cameraY,$.zoom)}function _h(e,t,n){bh();let r=$.cameraX,i=$.cameraY,a=$.zoom,o=performance.now();function s(c){let l=Math.min(1,(c-o)/Ff),u=1-(1-l)**3;$.cameraX=r+(e-r)*u,$.cameraY=i+(t-i)*u,$.zoom=a+(n-a)*u,om(),th(),l<1?$.viewAnimationId=requestAnimationFrame(s):$.viewAnimationId=null}$.viewAnimationId=requestAnimationFrame(s)}function vh(){return $.entities.reduce((e,t)=>{let n=_m(t);return{minX:Math.min(e.minX,t.x-n),minY:Math.min(e.minY,t.y-n),maxX:Math.max(e.maxX,t.x+n),maxY:Math.max(e.maxY,t.y+n)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0})}function yh(e,t,n){let r=e.maxX-e.minX,i=e.maxY-e.minY;if(!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0)return 1;let a=Math.max(1,t-If*2),o=Math.max(1,n-If*2);return Ch(Math.min(1,a/r,o/i),zf,1)}function bh(){$.viewAnimationId&&(cancelAnimationFrame($.viewAnimationId),$.viewAnimationId=null)}function xh(e,t){bh();let n=Sh(e);$.zoom=Ch($.zoom*t,zf,Bf),$.cameraX=e.x-n.x*$.zoom,$.cameraY=e.y-n.y*$.zoom,th()}function Sh(e){return{x:(e.x-$.cameraX)/$.zoom,y:(e.y-$.cameraY)/$.zoom}}function Ch(e,t,n){return Math.min(n,Math.max(t,e))}function wh(e,t){if(e.kind!==`system`&&e.kind!==`llm`)return Dh(e,t);let n=e.kind===`system`?vf:yf,r=$m(e.id);return Th(e,n,Math.max(bf,r.length),t)||{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function Th(e,t,n,r){let i={x:Math.cos(r),y:Math.sin(r)},a=Ih(e.x,e.y,t,n),o=null;for(let t=0;t<a.length;t+=1){let n=a[t],r=a[(t+1)%a.length],s={x:r.x-n.x,y:r.y-n.y},c={x:n.x-e.x,y:n.y-e.y},l=Eh(i,s);if(Math.abs(l)<1e-4)continue;let u=Eh(c,s)/l,d=Eh(c,i)/l;if(u>=0&&d>=0&&d<=1){let t={x:e.x+i.x*u,y:e.y+i.y*u};(!o||u<o.rayDistance)&&(o={...t,rayDistance:u})}}return o?{x:o.x,y:o.y}:null}function Eh(e,t){return e.x*t.y-e.y*t.x}function Dh(e,t){let n=Ah(e),r=n.width/2,i=n.height/2,a=Math.cos(t),o=Math.sin(t),s=Math.min(Math.abs(r/(a||2**-52)),Math.abs(i/(o||2**-52)));return{x:e.x+a*s,y:e.y+o*s}}function Oh(e,t){if(e.kind===`system`||e.kind===`llm`){let n=e.kind===`system`?vf:yf;return Math.hypot(t.x-e.x,t.y-e.y)<=n+Pf}let{width:n,height:r}=Ah(e);return Math.abs(t.x-e.x)<=n/2+Pf&&Math.abs(t.y-e.y)<=r/2+Pf}function kh(e){return Math.min(wf,Math.max(Cf,Math.floor(e*Tf)))}function Ah(e){return e.kind===`mcp`?{width:116,height:58}:{width:gf,height:_f}}function jh(e){return[e,...eh(e.id).map(Zm)].filter(Boolean).map(Mh).reduce(Nh)}function Mh(e){if(e.kind===`system`||e.kind===`llm`){let t=e.kind===`system`?vf:yf;return{left:e.x-t,top:e.y-t,right:e.x+t,bottom:e.y+t}}let{width:t,height:n}=Ah(e);return{left:e.x-t/2,top:e.y-n/2,right:e.x+t/2,bottom:e.y+n/2}}function Nh(e,t){return{left:Math.min(e.left,t.left),top:Math.min(e.top,t.top),right:Math.max(e.right,t.right),bottom:Math.max(e.bottom,t.bottom)}}function Ph(e,t,n){return!(e.right+n<t.left||e.left-n>t.right||e.bottom+n<t.top||e.top-n>t.bottom)}function Fh(e){let t=ep.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function Ih(e,t,n,r){return Array.from({length:r},(i,a)=>{let o=-Math.PI/2+a/r*Math.PI*2;return{x:e+Math.cos(o)*n,y:t+Math.sin(o)*n}})}function Lh(e,t,n,r,i){let a=e+n,o=t+r;Z.beginPath(),Z.moveTo(e+i,t),Z.lineTo(a-i,t),Z.quadraticCurveTo(a,t,a,t+i),Z.lineTo(a,o-i),Z.quadraticCurveTo(a,o,a-i,o),Z.lineTo(e+i,o),Z.quadraticCurveTo(e,o,e,o-i),Z.lineTo(e,t+i),Z.quadraticCurveTo(e,t,e+i,t),Z.closePath()}function Rh(e,t,n,r,i){let a=e.split(/\s+/),o=[],s=``;for(let e of a){let t=s?`${s} ${e}`:e;Z.measureText(t).width>r&&s?(o.push(s),s=e):s=t}o.push(s);let c=n-(o.length-1)*i/2;o.forEach((e,n)=>{Z.fillText(e,t,c+n*i)})}function zh(e,t,n,r){Z.beginPath(),Z.moveTo(e,t),Z.lineTo(n,r),Z.stroke()}var Bh=U(`<div class="status-row"><span id="apiStatus"></span></div>`),Vh=U('<div class="app-shell"><!> <section class="workspace-shell" aria-label="Configuration graph workspace"><nav class="rail" aria-label="Workspace tools"><button id="addButton" class="tool-button primary" type="button" title="Add node">+</button> <button id="fitButton" class="tool-button" type="button" title="Fit view">⌖</button></nav> <canvas id="workspaceCanvas" class="workspace-canvas" layoutsubtree=""><form id="configSurface" class="config-surface" autocomplete="off"><div class="panel-kicker"><span id="nodeTypeBadge">Provider</span> <button id="closePanelButton" class="icon-button close" type="button" title="Close panel">×</button></div> <div class="panel-title-row"><label class="eyebrow" for="nodeName">Node name</label> <input id="nodeName" name="nodeName" class="title-input" type="text"/></div> <div class="form-grid"><label class="field"><span>Kind</span> <select id="nodeKind" name="nodeKind"><option>System</option><option>LLM provider</option><option>Agent</option><option>MCP</option></select></label> <div id="llmFields" class="contents"><div id="providerIdField" class="field wide"><span>Provider ID</span> <div class="model-select-wrap"><input id="nodeProviderId" name="nodeProviderId" type="text" readonly=""/> <button id="copyProviderIdButton" class="icon-button" type="button" title="Copy provider ID">⧉</button></div> <small class="field-note">Technical node id. Use it when a tool or agent workflow needs to reference this provider, for example as <code>imageProviderId</code> with <code>generate_image</code>.</small></div> <label class="field wide"><span>Endpoint</span> <input id="nodeEndpoint" name="nodeEndpoint" type="url" placeholder="http://localhost:11434"/></label> <label class="field wide"><span>API token</span> <input id="nodeToken" name="nodeToken" type="text" autocomplete="off" spellcheck="false" placeholder="env:LLM_API_KEY"/> <small class="field-note">Reference an environment variable only — <code>env:VAR_NAME</code> (or <code>&#123;VAR_NAME&#125;</code>). The secret is read from the server environment at request time; literal tokens are not stored (the workspace file is tracked by git).</small></label> <div class="field wide model-field-row"><span>Model</span> <div class="model-select-wrap"><select id="nodeModel" name="nodeModel"><option disabled="" selected="">— click ↻ to load models —</option></select> <button id="loadModelsButton" class="icon-button" type="button" title="Load models from endpoint">↻</button></div></div> <fieldset class="field wide tool-mode-field"><legend>Provider type</legend> <label class="radio-card"><input id="nodeProviderTypeChat" name="nodeProviderType" type="radio" value="chat"/> <span><strong>Chat completion</strong> <small>Uses OpenAI-compatible <code>/chat/completions</code>.</small></span></label> <label class="radio-card"><input id="nodeProviderTypeImage" name="nodeProviderType" type="radio" value="image"/> <span><strong>Image generation</strong> <small>Used by <code>generate_image</code> with the provider id above.</small></span></label></fieldset> <fieldset id="toolModeField" class="field wide tool-mode-field"><legend>Tool calling</legend> <label class="radio-card"><input id="nodeToolModeTools" name="nodeToolMode" type="radio" value="tools"/> <span><strong>Allow MCP tools</strong> <small>Agents can send OpenAI-compatible <code>tools</code> payloads.</small></span></label> <label class="radio-card"><input id="nodeToolModeChat" name="nodeToolMode" type="radio" value="chat"/> <span><strong>Chat only</strong> <small>Agents never send tools, even when an MCP endpoint exists.</small></span></label></fieldset> <label class="field"><span>Timeout</span> <input id="nodeTimeout" name="nodeTimeout" type="number" min="1" max="600" step="1"/></label></div> <label class="field wide"><span>Description</span> <textarea id="nodeDescription" name="nodeDescription" rows="3"></textarea></label></div> <section id="agentSection" class="agent-section" hidden=""><label id="agentProviderField" class="field wide"><span>LLM provider</span> <select id="nodeAgentProvider" name="nodeAgentProvider"></select> <small class="field-note">Move this agent to another LLM provider. It inherits the target provider\'s model and timeout.</small></label> <label id="agentWorkspaceField" class="field wide"><span>Workspace folder</span> <input id="nodeWorkspaceFolder" name="nodeWorkspaceFolder" type="text" readonly=""/></label> <label class="field wide"><span>System prompt</span> <textarea id="nodeSystemPrompt" name="nodeSystemPrompt" rows="5" placeholder="You are a helpful assistant…"></textarea></label> <label class="field wide checkbox-field"><input id="nodeRequiresUserInput" name="nodeRequiresUserInput" type="checkbox"/> <span>Require a user input</span></label> <label id="agentUserInputDescriptionField" class="field wide" hidden=""><span>Describe User input</span> <textarea id="nodeUserInputDescription" name="nodeUserInputDescription" rows="3" placeholder="Describe exactly what the user must provide before running this agent."></textarea></label> <label class="field wide"><span>Required output marker</span> <input id="nodeExpectedOutputMarker" name="nodeExpectedOutputMarker" type="text" placeholder="Optional, e.g. ```mermaid"/></label></section> <section id="mcpInventory" class="mcp-inventory" hidden=""><div class="inventory-header"><span>MCP consultation surface</span> <strong>Streamable HTTP</strong></div> <p id="mcpInventoryStatus" class="inventory-status" hidden=""></p> <div class="inventory-grid"><article><h2>Tools</h2> <ul id="mcpToolsList"></ul></article> <article><h2>Prompts</h2> <ul id="mcpPromptsList"></ul></article></div></section> <footer class="panel-actions"><div class="panel-actions-left"><button id="testNodeButton" class="secondary-button" type="button">Test</button></div> <div class="panel-actions-right"><button id="deleteNodeButton" class="danger-button" type="button">Delete</button></div></footer></form></canvas> <div id="fallbackPanelHost" class="fallback-panel-host" hidden=""></div></section> <div id="deleteConfirmOverlay" class="confirm-overlay" hidden=""><section class="confirm-dialog" role="dialog" aria-modal="true" aria-labelledby="deleteConfirmTitle"><div><p class="confirm-kicker">Destructive change</p> <h2 id="deleteConfirmTitle">Delete node?</h2> <p id="deleteConfirmMessage" class="confirm-message"></p></div> <footer class="confirm-actions"><button id="cancelDeleteButton" class="secondary-button" type="button">Cancel</button> <button id="confirmDeleteButton" class="danger-button" type="button">Delete</button></footer></section></div> <div id="renameConfirmOverlay" class="confirm-overlay" hidden=""><section class="confirm-dialog" role="dialog" aria-modal="true" aria-labelledby="renameConfirmTitle"><div><p class="confirm-kicker">Renommage de dossier</p> <h2 id="renameConfirmTitle">Renommer le dossier ?</h2> <p id="renameConfirmMessage" class="confirm-message"></p></div> <footer class="confirm-actions"><button id="cancelRenameButton" class="secondary-button" type="button">Annuler</button> <button id="confirmRenameButton" class="primary-button" type="button">Renommer</button></footer></section></div> <div id="agentRunOverlay" class="confirm-overlay" hidden=""><section class="agent-run-dialog" role="dialog" aria-modal="true" aria-labelledby="agentRunTitle"><div><p class="confirm-kicker">Agent test</p> <h2 id="agentRunTitle">Run agent</h2> <p id="agentRunHint" class="confirm-message"></p></div> <label id="agentRunInputField" class="field wide agent-run-input-field"><span>User input</span> <textarea id="agentRunInput" name="agentRunInput" rows="6" placeholder="Document ID, question, or any input for the agent…"></textarea></label> <div id="agentRunResult" class="agent-run-result" hidden=""></div> <footer class="confirm-actions"><button id="cancelAgentRunButton" class="secondary-button" type="button">Close</button> <button id="executeAgentRunButton" class="primary-button" type="button">Run</button></footer></section></div></div>');function Hh(e,t){qe(t,!0),Gi(async()=>{try{await ha((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}return Mp()});var n=Vh(),r=L(n);so(r,{title:`Living AI Documentation`,subtitle:`Graph-native configuration workspace`,children:(e,t)=>{var n=Bh(),r=L(n);gi(r,1,`status-pill `),r.textContent=`Detecting canvas API`,j(n),W(e,n)},$$slots:{default:!0}});var i=z(r,2),a=z(L(i),2),o=L(a),s=z(L(o),4),c=L(s),l=z(L(c),2),u=L(l);u.value=u.__value=`system`;var d=z(u);d.value=d.__value=`llm`;var f=z(d);f.value=f.__value=`agent`;var p=z(f);p.value=p.__value=`mcp`,j(l),j(c);var m=z(c,2),h=z(L(m),6),g=z(L(h),2),_=L(g),v=L(_);v.value=v.__value=``,j(_),Ie(2),j(g),j(h),Ie(6),j(m),Ie(2),j(s),Ie(6),j(o),j(a),Ie(2),j(i),Ie(6),j(n),W(e,n),Je()}var Uh=U(`<p class="files-msg svelte-4q2lov"> </p>`),Wh=U(`<p class="files-msg files-msg--error svelte-4q2lov"> </p>`),Gh=U(`<p class="files-msg files-msg--empty svelte-4q2lov"> </p>`),Kh=U(`<option> </option>`),qh=U(`<div class="files-toolbar svelte-4q2lov"><label for="files-folder-filter" class="svelte-4q2lov"> </label> <select id="files-folder-filter" data-testid="files-folder-filter" class="svelte-4q2lov"><option> </option><!></select></div>`),Jh=U(`<span class="files-folder svelte-4q2lov"> </span> ·`,1),Yh=U(`<p class="files-row-error svelte-4q2lov"> </p>`),Xh=U(`<li class="files-row svelte-4q2lov"><span class="files-icon svelte-4q2lov">📎</span> <div class="files-info svelte-4q2lov"><a target="_blank" rel="noopener" class="files-name svelte-4q2lov"> </a> <div class="files-meta svelte-4q2lov"><!><!> </div> <!></div> <div class="files-actions svelte-4q2lov"><button type="button" class="files-btn svelte-4q2lov"> </button> <button type="button" class="files-btn files-btn--danger svelte-4q2lov"> </button></div></li>`),Zh=U(`<ul class="files-list svelte-4q2lov"></ul>`),Qh=U(`<!> <!>`,1),$h=U(`<!> <div class="app-shell"><!> <div class="files-page svelte-4q2lov"><!></div></div>`,1);function eg(e,t){qe(t,!0);let n=P(null),r=P(I([])),i=P(I([])),a=P(``),o=P(!0),s=P(``),c=P(I({})),l=P(I({})),u=P(I({})),d=Hd,f=N(()=>V(a)?V(r).filter(e=>e.folder===V(a)||e.folder.startsWith(V(a)+`/`)):V(r));function p(e){return e<1024?Y(`files.size_bytes`).replace(`{n}`,String(e)):e<1024*1024?Y(`files.size_kb`).replace(`{n}`,(e/1024).toFixed(1)):Y(`files.size_mb`).replace(`{n}`,(e/1024/1024).toFixed(2))}function m(e){if(!e)return``;let t=new Date(e);if(isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}async function h(){F(o,!0),F(s,``);try{let e=await fetch(`/api/files`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();F(r,Array.isArray(t.files)?t.files:[],!0),F(i,Array.isArray(t.folders)?t.folders:[],!0),V(a)&&!V(i).includes(V(a))&&F(a,``)}catch(e){F(s,Y(`files.error_load`)+(e instanceof Error?e.message:String(e)))}finally{F(o,!1)}}function g(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function _(e){let t=document.createElement(`input`);t.type=`file`,t.style.display=`none`,document.body.appendChild(t),t.addEventListener(`change`,async()=>{let r=t.files?.[0];if(t.remove(),r&&await V(n).show({kicker:Y(`files.confirm_replace_title`),title:Y(`files.confirm_replace_message`).replace(`{name}`,e.displayName||e.filename).replace(`{newName}`,r.name),message:Y(`files.confirm_replace_detail`),confirmLabel:Y(`files.replace`),cancelLabel:Y(`common.cancel`),danger:!0})){if(r.size>d){F(c,{...V(c),[e.filename]:Y(`files.error_replace`)+`${(r.size/1024/1024).toFixed(1)} MB (max ${Ud} MB)`},!0);return}F(l,{...V(l),[e.filename]:!0},!0),F(c,{...V(c),[e.filename]:``},!0);try{let t=await g(r),n=await fetch(`/api/files/${encodeURIComponent(e.filename)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`HTTP ${n.status}`)}await h()}catch(t){F(c,{...V(c),[e.filename]:Y(`files.error_replace`)+(t instanceof Error?t.message:String(t))},!0)}finally{F(l,{...V(l),[e.filename]:!1},!0)}}}),t.click()}async function v(e){if(await V(n).show({kicker:Y(`files.confirm_delete_title`),title:Y(`files.confirm_delete_message`).replace(`{name}`,e.displayName||e.filename),message:Y(`files.confirm_delete_detail`),confirmLabel:Y(`files.delete`),cancelLabel:Y(`common.cancel`),danger:!0})){F(u,{...V(u),[e.filename]:!0},!0),F(c,{...V(c),[e.filename]:``},!0);try{let t=await fetch(`/api/files/${encodeURIComponent(e.filename)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`HTTP ${t.status}`)}await h()}catch(t){F(c,{...V(c),[e.filename]:Y(`files.error_delete`)+(t instanceof Error?t.message:String(t))},!0)}finally{F(u,{...V(u),[e.filename]:!1},!0)}}}Gi(async()=>{try{await ha((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}await h()});var y=$h(),b=R(y);Vi(ad(b,{}),e=>F(n,e,!0),()=>V(n));var x=z(b,2),S=L(x);{let e=N(()=>Y(`files.title`));so(S,{get title(){return V(e)},subtitle:``})}var C=z(S,2),w=L(C),T=e=>{var t=Uh(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},E=e=>{var t=Wh(),n=L(t,!0);j(t),B(()=>G(n,V(s))),W(e,t)},D=e=>{var t=Gh(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`files.empty`)]),W(e,t)},ee=e=>{var t=Qh(),n=R(t),r=e=>{var t=qh(),n=L(t),r=L(n,!0);j(n);var o=z(n,2),s=L(o),c=L(s,!0);j(s),s.value=s.__value=``,q(z(s),16,()=>V(i),e=>e,(e,t)=>{var n=Kh(),r=L(n,!0);j(n);var i={};B(()=>{G(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),W(e,n)}),j(o);var l;bi(o),j(t),B((e,t)=>{G(r,e),G(c,t),l!==(l=V(a))&&(o.value=(o.__value=V(a))??``,yi(o,V(a)))},[()=>Y(`files.filter_label`),()=>Y(`files.filter_all`)]),H(`change`,o,e=>F(a,e.target.value,!0)),W(e,t)};K(n,e=>{V(i).length>0&&e(r)});var o=z(n,2),s=e=>{var t=Gh(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`files.empty_filter`)]),W(e,t)},d=e=>{var t=Zh();q(t,21,()=>V(f),Xr,(e,t)=>{var n=Xh(),r=z(L(n),2),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o),d=e=>{var n=Jh(),r=R(n),i=L(r,!0);j(r),Ie(),B(()=>G(i,V(t).folder)),W(e,n)};K(s,e=>{V(t).folder&&e(d)});var f=z(s),h=e=>{var n=Ur();B(e=>G(n,`${e??``} ·`),[()=>m(V(t).uploadedAt)]),W(e,n)};K(f,e=>{V(t).uploadedAt&&e(h)});var g=z(f,1,!0);j(o);var y=z(o,2),b=e=>{var n=Yh(),r=L(n,!0);j(n),B(()=>G(r,V(c)[V(t).filename])),W(e,n)};K(y,e=>{V(c)[V(t).filename]&&e(b)}),j(r);var x=z(r,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2),T=L(w,!0);j(w),j(x),j(n),B((e,n,r)=>{J(i,`href`,V(t).url),G(a,V(t).displayName||V(t).filename),G(g,e),S.disabled=V(l)[V(t).filename]||V(u)[V(t).filename],G(C,n),w.disabled=V(l)[V(t).filename]||V(u)[V(t).filename],G(T,r)},[()=>p(V(t).size||0),()=>V(l)[V(t).filename]?Y(`files.replacing`):Y(`files.replace`),()=>V(u)[V(t).filename]?Y(`files.deleting`):Y(`files.delete`)]),H(`click`,S,()=>_(V(t))),H(`click`,w,()=>v(V(t))),W(e,n)}),j(t),W(e,t)};K(o,e=>{V(f).length===0?e(s):e(d,-1)}),W(e,t)};K(w,e=>{V(o)?e(T):V(s)?e(E,1):V(r).length===0?e(D,2):e(ee,-1)}),j(C),j(x),W(e,y),Je()}Pr([`change`,`click`]);var tg=U(`<p class="browser-msg"> </p>`),ng=U(`<p class="browser-msg browser-msg--error"> </p>`),rg=U(`<button class="browser-row browser-row--dir"><span class="browser-row-name"> </span></button>`),ig=U(`<span class="badge-added"> </span>`),ag=U(`<button class="link-btn"> </button>`),og=U(`<div class="browser-row browser-row--file"><span class="browser-row-name"> </span> <!></div>`),sg=U(`<!> <!>`,1),cg=U(`<div class="file-browser"><div class="file-browser-toolbar"><button class="link-btn"> </button> <span class="file-browser-path"> </span></div> <div class="file-browser-list" data-testid="instruction-browse-list"><!></div></div>`),lg=U(`<p class="empty-msg svelte-e5jhdq"> </p>`),ug=U(`<button class="remove-btn"> </button>`),dg=U(`<div class="instruction-row svelte-e5jhdq"><div class="instruction-info svelte-e5jhdq"><a class="instruction-path svelte-e5jhdq"> </a> <div class="instruction-meta svelte-e5jhdq"> <!></div></div> <div class="instruction-actions svelte-e5jhdq"><span> </span> <!></div></div>`),fg=U(`<div class="section-card svelte-e5jhdq"><div class="section-header svelte-e5jhdq"><span class="section-title svelte-e5jhdq"> </span> <div class="header-actions svelte-e5jhdq"><span class="count-label svelte-e5jhdq"> </span> <button class="secondary-button btn-sm"> </button></div></div> <!> <div class="instruction-list svelte-e5jhdq" data-testid="instruction-list"><!></div></div>`);function pg(e,t){qe(t,!0);let n=Wi(t,`items`,27,()=>I([])),r=P(!1),i=P(``),a=P(``),o=P(I([])),s=P(I([])),c=P(!1),l=P(!1),u=N(()=>new Set(n().map(e=>d(e.path))));function d(e){return String(e||``).split(/[/\\]/).pop()||``}function f(e){let t=encodeURIComponent(String(e||``).replace(/\.md$/i,``));return`/?doc=`+encodeURIComponent(t)}function p(e){return Y(`context.root.${e}`)}function m(e){return Y(`context.type.${e}`)}async function h(e){F(c,!0),F(l,!1);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(i,t.current,!0),F(a,t.parent||``,!0),F(o,t.dirs||[],!0),F(s,t.files||[],!0)}catch{F(l,!0)}finally{F(c,!1)}}async function g(){F(r,!V(r)),V(r)&&!V(i)&&await h((await fetch(`/api/context/orientation`).then(e=>e.json()).catch(()=>({}))).sourceRoot||``)}async function _(e){await t.onAdd(e),V(r)&&V(i)&&await h(V(i))}var v=fg(),y=L(v),b=L(y),x=L(b,!0);j(b);var S=z(b,2),C=L(S),w=L(C);j(C);var T=z(C,2),E=L(T,!0);j(T),j(S),j(y);var D=z(y,2),ee=e=>{var t=cg(),n=L(t),r=L(n),d=L(r,!0);j(r);var f=z(r,2),p=L(f,!0);j(f),j(n);var m=z(n,2),g=L(m),v=e=>{var t=tg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},y=e=>{var t=ng(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.cannot_read_dir`)]),W(e,t)},b=e=>{var t=tg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.empty_dir`)]),W(e,t)},x=e=>{var t=sg(),n=R(t);q(n,17,()=>V(o),Xr,(e,t)=>{var n=rg(),r=L(n),i=L(r);j(r),j(n),B(()=>G(i,`📁 ${V(t).name??``}`)),H(`click`,n,()=>h(V(t).path)),W(e,n)}),q(z(n,2),17,()=>V(s),Xr,(e,t)=>{var n=og(),r=L(n),i=L(r);j(r);var a=z(r,2),o=e=>{var t=ig(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.added`)]),W(e,t)},s=N(()=>V(u).has(V(t).name)),c=e=>{var n=ag(),r=L(n,!0);j(n),B(e=>G(r,e),[()=>Y(`context.add_file_action`)]),H(`click`,n,()=>_(V(t).path)),W(e,n)};K(a,e=>{V(s)?e(o):e(c,-1)}),j(n),B(()=>G(i,`📄 ${V(t).name??``}`)),W(e,n)}),W(e,t)};K(g,e=>{V(c)?e(v):V(l)?e(y,1):!V(o).length&&!V(s).length?e(b,2):e(x,-1)}),j(m),j(t),B(e=>{r.disabled=!V(a),G(d,e),G(p,V(i))},[()=>Y(`common.up`)]),H(`click`,r,()=>V(a)&&h(V(a))),W(e,t)};K(D,e=>{V(r)&&e(ee)});var te=z(D,2),O=L(te),ne=e=>{var t=lg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.no_instructions`)]),W(e,t)},re=e=>{var r=Wr();q(R(r),17,n,Xr,(e,n)=>{var r=dg(),i=L(r),a=L(i),o=L(a,!0);j(a);var s=z(a,2),c=L(s),l=z(c),u=e=>{var t=Ur();B(e=>G(t,`· ${e??``} KB`),[()=>Math.round(V(n).size/1024)]),W(e,t)};K(l,e=>{V(n).size!==null&&e(u)}),j(s),j(i);var h=z(i,2),g=L(h),_=L(g,!0);j(g);var v=z(g,2),y=e=>{var r=ug(),i=L(r,!0);j(r),B(e=>G(i,e),[()=>Y(`common.remove`)]),H(`click`,r,()=>t.onRemove(d(V(n).path))),W(e,r)};K(v,e=>{V(n).exists&&e(y)}),j(h),j(r),B((e,t,r,i)=>{J(a,`href`,e),G(o,V(n).path),G(c,`${t??``} · ${r??``} `),gi(g,1,ui(V(n).exists?`status-ok`:`status-missing`),`svelte-e5jhdq`),G(_,i)},[()=>f(V(n).path),()=>p(V(n).root),()=>m(V(n).type),()=>V(n).exists?Y(`context.exists`):Y(`context.missing`)]),W(e,r)}),W(e,r)};K(O,e=>{n().length?e(re,-1):e(ne)}),j(te),j(v),B((e,t,r)=>{G(x,e),G(w,`${t??``}/${n().length??``}`),G(E,r)},[()=>Y(`context.instructions_title`),()=>n().filter(e=>e.exists).length,()=>V(r)?Y(`context.hide_instruction_browser`):Y(`context.add_instruction_file`)]),H(`click`,T,g),W(e,v),Je()}Pr([`click`]);var mg=U(`<span class="rules-folder svelte-1r3tey2"> </span>`),hg=U(`<p class="empty-msg svelte-1r3tey2"> </p>`),gg=U(`<span class="tag svelte-1r3tey2"> </span>`),_g=U(`<div class="rule-tags svelte-1r3tey2"></div>`),vg=U(`<div class="rule-applies svelte-1r3tey2"> </div>`),yg=U(`<article class="rule-row svelte-1r3tey2"><div class="rule-top svelte-1r3tey2"><div class="rule-title-wrap svelte-1r3tey2"><h3 class="rule-title svelte-1r3tey2"><a class="rule-link svelte-1r3tey2"> </a></h3> <a class="rule-path svelte-1r3tey2"> </a></div> <span class="severity-badge svelte-1r3tey2"> </span></div> <p class="rule-desc svelte-1r3tey2"> </p> <!> <!></article>`),bg=U(`<div class="rules-layout svelte-1r3tey2"><div class="section-card svelte-1r3tey2"><div class="section-header svelte-1r3tey2"><span class="section-title svelte-1r3tey2" data-testid="rules-title"> </span> <!></div> <div class="rule-list svelte-1r3tey2" data-testid="rule-list"><!></div></div> <div class="section-card aside-card svelte-1r3tey2"><span class="section-title svelte-1r3tey2" data-testid="add-rule-title"> </span> <div class="field-group"><label class="field-label" for="ruleTitle"> </label> <input id="ruleTitle" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleSeverity"> </label> <select id="ruleSeverity" class="field-input"><option> </option><option> </option><option> </option></select></div> <div class="field-group"><label class="field-label" for="ruleDescription"> </label> <input id="ruleDescription" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleTags"> </label> <input id="ruleTags" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleAppliesTo"> </label> <input id="ruleAppliesTo" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleBody"> </label> <textarea id="ruleBody" rows="7" class="field-input"></textarea></div> <button class="btn-primary" style="width:100%"> </button></div></div>`);function xg(e,t){qe(t,!0);let n=Wi(t,`rules`,19,()=>[]),r=Wi(t,`rulesFolder`,3,``),i=P(``),a=P(`guideline`),o=P(``),s=P(``),c=P(``),l=P(``),u=P(!1);function d(e){let t=encodeURIComponent(String(e||``).replace(/\.md$/i,``));return`/?doc=`+encodeURIComponent(t)}function f(e){let t=`context.rule_severity_${e}`,n=Y(t);return n===t?e:n}function p(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}async function m(){if(V(i).trim()){F(u,!0);try{await t.onAdd({title:V(i).trim(),severity:V(a),description:V(o).trim(),tags:p(V(s)),appliesTo:p(V(c)),body:V(l).trim()}),F(i,``),F(o,``),F(s,``),F(c,``),F(l,``)}finally{F(u,!1)}}}var h=bg(),g=L(h),_=L(g),v=L(_),y=L(v,!0);j(v);var b=z(v,2),x=e=>{var t=mg(),n=L(t,!0);j(t),B(()=>G(n,r())),W(e,t)};K(b,e=>{r()&&e(x)}),j(_);var S=z(_,2),C=L(S),w=e=>{var t=hg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.no_rules`)]),W(e,t)},T=e=>{var t=Wr();q(R(t),17,n,Xr,(e,t)=>{var n=yg(),r=L(n),i=L(r),a=L(i),o=L(a),s=L(o,!0);j(o),j(a);var c=z(a,2),l=L(c,!0);j(c),j(i);var u=z(i,2),p=L(u,!0);j(u),j(r);var m=z(r,2),h=L(m,!0);j(m);var g=z(m,2),_=e=>{var n=_g();q(n,21,()=>V(t).tags,Xr,(e,t)=>{var n=gg(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(n),W(e,n)};K(g,e=>{V(t).tags?.length&&e(_)});var v=z(g,2),y=e=>{var n=vg(),r=L(n,!0);j(n),B(e=>G(r,e),[()=>V(t).appliesTo.join(`, `)]),W(e,n)};K(v,e=>{V(t).appliesTo?.length&&e(y)}),j(n),B((e,n,r)=>{J(o,`href`,e),G(s,V(t).title),J(c,`href`,n),G(l,V(t).path),G(p,r),G(h,V(t).description)},[()=>d(V(t).path),()=>d(V(t).path),()=>f(V(t).severity)]),W(e,n)}),W(e,t)};K(C,e=>{n().length?e(T,-1):e(w)}),j(S),j(g);var E=z(g,2),D=L(E),ee=L(D,!0);j(D);var te=z(D,2),O=L(te),ne=L(O,!0);j(O);var re=z(O,2);Di(re),j(te);var k=z(te,2),ie=L(k),ae=L(ie,!0);j(ie);var oe=z(ie,2),se=L(oe),ce=L(se,!0);j(se),se.value=se.__value=`guideline`;var le=z(se),ue=L(le,!0);j(le),le.value=le.__value=`warning`;var de=z(le),fe=L(de,!0);j(de),de.value=de.__value=`required`,j(oe),j(k);var pe=z(k,2),me=L(pe),he=L(me,!0);j(me);var ge=z(me,2);Di(ge),j(pe);var _e=z(pe,2),ve=L(_e),ye=L(ve,!0);j(ve);var be=z(ve,2);Di(be),j(_e);var xe=z(_e,2),Se=L(xe),Ce=L(Se,!0);j(Se);var A=z(Se,2);Di(A),j(xe);var we=z(xe,2),Te=L(we),Ee=L(Te,!0);j(Te);var De=z(Te,2);yn(De),j(we);var Oe=z(we,2),ke=L(Oe,!0);j(Oe),j(E),j(h),B((e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)=>{G(y,e),G(ee,t),G(ne,n),J(re,`placeholder`,r),G(ae,i),G(ce,a),G(ue,o),G(fe,s),G(he,c),J(ge,`placeholder`,l),G(ye,u),J(be,`placeholder`,d),G(Ce,f),J(A,`placeholder`,p),G(Ee,m),J(De,`placeholder`,h),Oe.disabled=g,G(ke,_)},[()=>Y(`context.rules_title`),()=>Y(`context.add_rule_title`),()=>Y(`context.rule_title_label`),()=>Y(`context.rule_title_placeholder`),()=>Y(`context.rule_severity_label`),()=>Y(`context.rule_severity_guideline`),()=>Y(`context.rule_severity_warning`),()=>Y(`context.rule_severity_required`),()=>Y(`context.rule_description_label`),()=>Y(`context.rule_description_placeholder`),()=>Y(`context.rule_tags_label`),()=>Y(`context.rule_tags_placeholder`),()=>Y(`context.rule_applies_to_label`),()=>Y(`context.rule_applies_to_placeholder`),()=>Y(`context.rule_body_label`),()=>Y(`context.rule_body_placeholder`),()=>V(u)||!V(i).trim(),()=>Y(`context.add_rule_button`)]),Ni(re,()=>V(i),e=>F(i,e)),xi(oe,()=>V(a),e=>F(a,e)),Ni(ge,()=>V(o),e=>F(o,e)),Ni(be,()=>V(s),e=>F(s,e)),Ni(A,()=>V(c),e=>F(c,e)),Ni(De,()=>V(l),e=>F(l,e)),H(`click`,Oe,m),W(e,h),Je()}Pr([`click`]);var Sg=U(`<p class="empty-msg svelte-1ui2b6s"> </p>`),Cg=U(`<p class="mcp-desc svelte-1ui2b6s"> </p>`),wg=U(`<div class="mcp-schema-wrap svelte-1ui2b6s"><h4 class="mcp-schema-title svelte-1ui2b6s"> </h4> <pre class="mcp-schema-pre svelte-1ui2b6s"> </pre></div>`),Tg=U(`<div class="mcp-result svelte-1ui2b6s" data-testid="mcp-result"></div>`),Eg=U(`<details class="mcp-detail svelte-1ui2b6s"><summary class="mcp-summary svelte-1ui2b6s"> </summary> <!> <!> <div class="mcp-run-area svelte-1ui2b6s"><label class="mcp-run-label svelte-1ui2b6s"> </label> <textarea rows="4" spellcheck="false" class="field-input mcp-textarea svelte-1ui2b6s" data-testid="mcp-args"></textarea> <div class="mcp-run-footer svelte-1ui2b6s"><span class="mcp-error-text svelte-1ui2b6s" data-testid="mcp-error"> </span> <button class="btn-primary btn-sm"> </button></div> <!></div></details>`),Dg=U(`<p class="mcp-arg-desc svelte-1ui2b6s"> </p>`),Og=U(`<li class="mcp-arg-item svelte-1ui2b6s"><div class="mcp-arg-name-row svelte-1ui2b6s"><span class="mcp-arg-name svelte-1ui2b6s"> </span> <span class="mcp-arg-req svelte-1ui2b6s"> </span></div> <!></li>`),kg=U(`<div class="mcp-schema-wrap svelte-1ui2b6s"><h4 class="mcp-schema-title svelte-1ui2b6s"> </h4> <ul class="mcp-args-list svelte-1ui2b6s"></ul></div>`),Ag=U(`<div class="section-card svelte-1ui2b6s"><div class="section-header svelte-1ui2b6s"><span class="section-title svelte-1ui2b6s" data-testid="mcp-title"> </span> <button class="secondary-button btn-sm"> </button></div> <p class="section-desc svelte-1ui2b6s"> </p> <div class="mcp-info-grid svelte-1ui2b6s"><div class="mcp-info-cell svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div> </div></div> <div class="mcp-info-cell svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div class="mcp-info-value mono svelte-1ui2b6s"> </div></div> <div class="mcp-info-cell wide svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div class="mcp-info-value mono break svelte-1ui2b6s" data-testid="mcp-endpoint"> </div></div></div> <div><div class="subsection-header svelte-1ui2b6s"><span class="subsection-title svelte-1ui2b6s"> </span> <div class="subsection-actions svelte-1ui2b6s"><span class="count-label svelte-1ui2b6s"> </span> <button class="secondary-button btn-sm"> </button></div></div> <div class="mcp-items svelte-1ui2b6s" data-testid="mcp-tool-list"><!></div></div> <div><div class="subsection-header svelte-1ui2b6s"><span class="subsection-title svelte-1ui2b6s"> </span> <div class="subsection-actions svelte-1ui2b6s"><span class="count-label svelte-1ui2b6s"> </span> <button class="secondary-button btn-sm"> </button></div></div> <div class="mcp-items svelte-1ui2b6s" data-testid="mcp-prompt-list"><!></div></div></div>`);function jg(e,t){qe(t,!0);let n=P(`-`),r=P(!1),i=P(`-`),a=P(`-`),o=P(I([])),s=P(I([])),c=P(!1),l=P(I(new Map)),u=P(I(new Map));function d(e,t){let n=V(e===`tool`?l:u);return n.has(t)||n.set(t,{argsJson:`{}`,running:!1,error:``,resultHtml:``}),n.get(t)}function f(e,t,n){let r=V(e===`tool`?l:u).get(t)??{argsJson:`{}`,running:!1,error:``,resultHtml:``};e===`tool`?F(l,new Map(V(l)).set(t,{...r,...n}),!0):F(u,new Map(V(u)).set(t,{...r,...n}),!0)}function p(e){if(!e||typeof e!=`object`)return null;if(e.type===`string`)return``;if(e.type===`number`||e.type===`integer`)return 0;if(e.type===`boolean`)return!1;if(e.type===`array`)return[];if(e.type===`object`||e.properties){let t={},n=e.properties||{};return(Array.isArray(e.required)?e.required:[]).forEach(e=>{t[e]=p(n[e])??``}),t}return null}function m(e){let t=p(e.inputSchema)??{},n=JSON.stringify(t,null,2);F(l,new Map(V(l)).set(e.name,{argsJson:n,running:!1,error:``,resultHtml:``}),!0)}function h(e){let t={};(e.arguments||[]).forEach(e=>{e.required&&(t[e.name]=``)});let n=JSON.stringify(t,null,2);F(u,new Map(V(u)).set(e.name,{argsJson:n,running:!1,error:``,resultHtml:``}),!0)}function g(e){let t=e.match(/^data:\s*(\{.*\})\s*$/m);if(!t)throw Error(e.slice(0,300)||`No MCP response body`);return JSON.parse(t[1])}async function _(e,t,n){let r=await fetch(`/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json, text/event-stream`},body:JSON.stringify({jsonrpc:`2.0`,id:e,method:t,params:n})}),i=await r.text();if(!r.ok)throw Error(i||`HTTP ${r.status}`);return g(i)}async function v(){await _(1,`initialize`,{protocolVersion:`2025-03-26`,capabilities:{},clientInfo:{name:`living-ai-documentation-context`,version:`1.0.0`}})}function y(e){return"```json\n"+JSON.stringify(e,null,2).replaceAll("```","`\\`\\`")+"\n```"}function b(e){if(typeof e!=`string`)return y(e);try{return y(JSON.parse(e))}catch{return e}}function x(e){if(typeof e==`string`)return e;if(!e||typeof e!=`object`)return String(e??``);if(e.error)return y(e.error);let t=e.result;return!t||typeof t!=`object`?y(e):Array.isArray(t.messages)?t.messages.map(e=>`${e.role?`[${e.role}]`:``}\n${b(e.content?.text??e.content??e)}`.trim()).join(`
92
92
 
93
93
  `):Array.isArray(t.content)?t.content.map(e=>e&&e.type===`text`&&typeof e.text==`string`?b(e.text):y(e)).join(`
94
94
 
@@ -96,75 +96,75 @@ Texte`};case`link`:return{text:ut(`snip-link-text`),textFallback:Y(`snippet.link
96
96
  `)}function T(e){if(typeof e==`string`)return e;if(!e||typeof e!=`object`)return String(e??``);if(e.error)return JSON.stringify(e.error,null,2);let t=e.result;return t?.isError?(Array.isArray(t.content)?t.content.map(e=>e&&e.type===`text`&&typeof e.text==`string`?e.text:JSON.stringify(e,null,2)).filter(Boolean):[]).join(`
97
97
 
98
98
  `)||JSON.stringify(t,null,2):JSON.stringify(e,null,2)}async function E(e,t,n){let r=await fetch(`/api/context/mcp-result`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,content:t,kind:n})});if(!r.ok)throw Error(await r.text()||`HTTP ${r.status}`);return r.json()}function D(e){let t=encodeURIComponent(String(e||``).replace(/\.md$/i,``));return`/?doc=`+encodeURIComponent(t)}async function ee(e,t){let n=d(e,t),r={};try{r=n.argsJson.trim()?JSON.parse(n.argsJson):{}}catch{f(e,t,{error:Y(`context.mcp_invalid_json`)});return}f(e,t,{running:!0,error:``,resultHtml:`<span class="mcp-running">${Y(`context.mcp_running`)}</span>`});try{await v();let n=e===`tool`?await _(2,`tools/call`,{name:t,arguments:r}):await _(2,`prompts/get`,{name:t,arguments:r});if(n.error||n.result?.isError){let r=T(n);f(e,t,{running:!1,error:Y(`context.mcp_error`),resultHtml:r?`<pre class="mcp-error-pre">${O(r)}</pre>`:``});return}let i=e===`tool`?V(o).find(e=>e.name===t):null,{path:a}=await E(t,e===`tool`&&i?w(i,r,n):x(n),e),s=D(a);f(e,t,{running:!1,error:``,resultHtml:`<div class="mcp-saved-label">${O(Y(`context.mcp_saved_to`))}</div>
99
- <a href="${O(s)}" target="_blank" rel="noopener" class="mcp-saved-link">📄 ${O(a)}</a>`})}catch(n){f(e,t,{running:!1,error:n.message||String(n),resultHtml:``})}}async function te(e){let n=V(e===`tool`?o:s);if(!n.length)return;F(c,!0);let r=n.length;try{for(let i=0;i<n.length;i++)t.onStatus(Y(`context.mcp_running_all`).replace(`{current}`,String(i+1)).replace(`{total}`,String(r))),await ee(e,n[i].name);t.onStatus(Y(`context.mcp_done_all`).replace(`{total}`,String(r)))}finally{F(c,!1)}}function O(e){return String(e??``).replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e])}async function ne(){try{let e=await fetch(`/mcp`);if(!e.ok)throw Error(await e.text());let t=await e.json(),c=Array.isArray(t.tools)?t.tools:[],l=Array.isArray(t.prompts)?t.prompts:[];F(n,Y(`context.mcp_available`),!0),F(r,!0),F(i,t.transport||`-`,!0),F(a,t.endpoint||`POST /mcp`,!0),F(o,c,!0),F(s,l,!0),c.forEach(m),l.forEach(h)}catch{F(n,Y(`context.mcp_unavailable`),!0),F(r,!1),F(i,`-`),F(a,`/mcp`),F(o,[],!0),F(s,[],!0)}}var re={load:ne},k=Og(),ie=L(k),ae=L(ie),oe=L(ae,!0);j(ae);var se=z(ae,2),ce=L(se,!0);j(se),j(ie);var le=z(ie,2),ue=L(le,!0);j(le);var de=z(le,2),fe=L(de),pe=L(fe),me=L(pe,!0);j(pe);var he=z(pe,2),ge=L(he,!0);j(he),j(fe);var _e=z(fe,2),ve=L(_e),ye=L(ve,!0);j(ve);var be=z(ve,2),xe=L(be,!0);j(be),j(_e);var Se=z(_e,2),Ce=L(Se),A=L(Ce,!0);j(Ce);var we=z(Ce,2),Te=L(we,!0);j(we),j(Se),j(de);var Ee=z(de,2),De=L(Ee),Oe=L(De),ke=L(Oe,!0);j(Oe);var Ae=z(Oe,2),je=L(Ae),Me=L(je,!0);j(je);var Ne=z(je,2),Pe=L(Ne,!0);j(Ne),j(Ae),j(De);var Fe=z(De,2),Ie=L(Fe),Le=e=>{var t=bg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.mcp_no_tools`)]),W(e,t)},Re=e=>{var t=Wr();q(R(t),17,()=>V(o),Xr,(e,t)=>{let n=N(()=>V(l).get(V(t).name)??{argsJson:`{}`,running:!1,error:``,resultHtml:``});var r=wg(),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=e=>{var n=xg(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(o,e=>{V(t).description&&e(s)});var c=z(o,2),u=e=>{var n=Sg(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n),B((e,t)=>{G(i,e),G(o,t)},[()=>Y(`context.mcp_input_schema`),()=>JSON.stringify(V(t).inputSchema,null,2)]),W(e,n)};K(c,e=>{V(t).inputSchema&&e(u)});var d=z(c,2),p=L(d),m=L(p,!0);j(p);var h=z(p,2);yn(h);var g=z(h,2),_=L(g),v=L(_,!0);j(_);var y=z(_,2),b=L(y,!0);j(y),j(g);var x=z(g,2),S=e=>{var t=Cg();ai(t,()=>V(n).resultHtml,!0),j(t),W(e,t)};K(x,e=>{V(n).resultHtml&&e(S)}),j(d),j(r),B((e,r)=>{G(a,V(t).name),G(m,e),Oi(h,V(n).argsJson),G(v,V(n).error),y.disabled=V(n).running,G(b,r)},[()=>Y(`context.mcp_request_json`),()=>Y(`context.mcp_run_tool`)]),H(`input`,h,e=>f(`tool`,V(t).name,{argsJson:e.target.value})),H(`click`,y,()=>ee(`tool`,V(t).name)),W(e,r)}),W(e,t)};K(Ie,e=>{V(o).length?e(Re,-1):e(Le)}),j(Fe),j(Ee);var ze=z(Ee,2),Be=L(ze),Ve=L(Be),He=L(Ve,!0);j(Ve);var Ue=z(Ve,2),We=L(Ue),Ge=L(We,!0);j(We);var Ke=z(We,2),Ye=L(Ke,!0);j(Ke),j(Ue),j(Be);var Xe=z(Be,2),Ze=L(Xe),Qe=e=>{var t=bg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.mcp_no_prompts`)]),W(e,t)},$e=e=>{var t=Wr();q(R(t),17,()=>V(s),Xr,(e,t)=>{let n=N(()=>V(u).get(V(t).name)??{argsJson:`{}`,running:!1,error:``,resultHtml:``});var r=wg(),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=e=>{var n=xg(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(o,e=>{V(t).description&&e(s)});var c=z(o,2),l=e=>{var n=Dg(),r=L(n),i=L(r,!0);j(r);var a=z(r,2);q(a,21,()=>V(t).arguments,Xr,(e,t)=>{var n=Eg(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=e=>{var n=Tg(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(c,e=>{V(t).description&&e(l)}),j(n),B(e=>{G(a,V(t).name),G(s,e)},[()=>V(t).required?Y(`context.mcp_required`):Y(`context.mcp_optional`)]),W(e,n)}),j(a),j(n),B(e=>G(i,e),[()=>Y(`context.mcp_arguments`)]),W(e,n)};K(c,e=>{V(t).arguments?.length&&e(l)});var d=z(c,2),p=L(d),m=L(p,!0);j(p);var h=z(p,2);yn(h);var g=z(h,2),_=L(g),v=L(_,!0);j(_);var y=z(_,2),b=L(y,!0);j(y),j(g);var x=z(g,2),S=e=>{var t=Cg();ai(t,()=>V(n).resultHtml,!0),j(t),W(e,t)};K(x,e=>{V(n).resultHtml&&e(S)}),j(d),j(r),B((e,r)=>{G(a,V(t).name),G(m,e),Oi(h,V(n).argsJson),G(v,V(n).error),y.disabled=V(n).running,G(b,r)},[()=>Y(`context.mcp_request_json`),()=>Y(`context.mcp_get_prompt`)]),H(`input`,h,e=>f(`prompt`,V(t).name,{argsJson:e.target.value})),H(`click`,y,()=>ee(`prompt`,V(t).name)),W(e,r)}),W(e,t)};return K(Ze,e=>{V(s).length?e($e,-1):e(Qe)}),j(Xe),j(ze),j(k),B((e,t,l,u,d,f,p,m,h,g)=>{G(oe,e),G(ce,t),G(ue,l),G(me,u),gi(he,1,ui(V(r)?`mcp-info-value ok`:`mcp-info-value err`),`svelte-1ui2b6s`),G(ge,V(n)),G(ye,d),G(xe,V(i)),G(A,f),G(Te,V(a)),G(ke,p),G(Me,V(o).length),Ne.disabled=V(c)||!V(o).length,G(Pe,m),G(He,h),G(Ge,V(s).length),Ke.disabled=V(c)||!V(s).length,G(Ye,g)},[()=>Y(`context.mcp_title`),()=>Y(`context.mcp_refresh`),()=>Y(`context.mcp_intro`),()=>Y(`context.mcp_status`),()=>Y(`context.mcp_transport`),()=>Y(`context.mcp_endpoint`),()=>Y(`context.mcp_tools`),()=>Y(`context.mcp_run_all_tools`),()=>Y(`context.mcp_prompts`),()=>Y(`context.mcp_get_all_prompts`)]),H(`click`,se,ne),H(`click`,Ne,()=>te(`tool`)),H(`click`,Ke,()=>te(`prompt`)),W(e,k),Je(re)}Pr([`click`,`input`]);var Ag=U(`<p class="status-text svelte-rpj1e5"> </p>`),jg=U(`<div class="app-shell"><!> <main class="context-scroll svelte-rpj1e5"><div class="context-inner svelte-rpj1e5"><section class="page-intro svelte-rpj1e5"><h2 class="page-title svelte-rpj1e5"> </h2> <p class="page-desc svelte-rpj1e5"> </p> <!></section> <!> <!> <!></div></main></div> <!>`,1);function Mg(e,t){qe(t,!0);let n=P(``),r=P(I([])),i=P(I([])),a=P(``),o=P(null),s=P(null),c=P(null);function l(e){F(n,e,!0)}async function u(){l(Y(`context.loading`));let e=await fetch(`/api/context/orientation`);if(!e.ok)throw Error(await e.text());let t=await e.json();F(o,t,!0),F(r,t.instructions||[],!0),F(i,t.rules||[],!0),F(a,t.rulesFolder||``,!0),l(``)}async function d(e){l(Y(`context.adding_instruction_file`));let t=await fetch(`/api/context/instructions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})});if(!t.ok)throw Error(await t.text());await u()}async function f(e){if(!await V(s).show({kicker:Y(`context.remove_instruction_title`),title:Y(`context.remove_instruction_title`),message:Y(`context.remove_instruction_message`).replace(`{name}`,e),confirmLabel:Y(`common.remove`),cancelLabel:Y(`common.cancel`)||`Cancel`,danger:!0}))return;l(Y(`context.removing_instruction_file`));let t=await fetch(`/api/context/instructions/`+encodeURIComponent(e),{method:`DELETE`});if(!t.ok)throw Error(await t.text());await u()}async function p(e){l(Y(`context.saving_rule`));let t=await fetch(`/api/context/rules`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await t.text());await u()}Gi(async()=>{try{let e=await fetch(`/api/config`);await ha((e.ok?await e.json():{}).language||`en`)}catch{await ha(`en`)}document.title=Y(`context.title`),await u().catch(e=>l(e.message)),await V(c).load().catch(()=>{})});var m=jg(),h=R(m),g=L(h);so(g,{get navigate(){return t.navigate}});var _=z(g,2),v=L(_),y=L(v),b=L(y),x=L(b,!0);j(b);var S=z(b,2),C=L(S,!0);j(S);var w=z(S,2),T=e=>{var t=Ag(),r=L(t,!0);j(t),B(()=>G(r,V(n))),W(e,t)};K(w,e=>{V(n)&&e(T)}),j(y);var E=z(y,2);dg(E,{onAdd:d,onRemove:f,get items(){return V(r)},set items(e){F(r,e,!0)}});var D=z(E,2);yg(D,{get rules(){return V(i)},get rulesFolder(){return V(a)},onAdd:p}),Vi(kg(z(D,2),{onStatus:l}),e=>F(c,e,!0),()=>V(c)),j(v),j(_),j(h),Vi(ad(z(h,2),{}),e=>F(s,e,!0),()=>V(s)),B((e,t)=>{G(x,e),G(C,t)},[()=>Y(`context.orientation_title`),()=>Y(`context.orientation_intro`)]),W(e,m),Je()}async function Ng(){return fetch(`/api/config`).then(e=>e.json())}async function Pg(){return fetch(`/api/documents`).then(e=>e.json())}async function Fg(e){return fetch(`/api/browse/alldirs?path=${encodeURIComponent(e)}`).then(e=>e.json())}async function Ig(e){let t=await fetch(`/api/documents/${e}`);if(!t.ok)throw Error(t.statusText);return t.json()}async function Lg(){try{let e=await fetch(`/api/annotations`).then(e=>e.json()),t={};for(let[n,r]of Object.entries(e||{})){t[n]=r;try{t[encodeURIComponent(n)]=r}catch{}}return t}catch{return{}}}async function Rg(){try{return await fetch(`/api/documents/file-counts`).then(e=>e.json())}catch{return{}}}async function zg(){try{return await fetch(`/api/documents/statuses`).then(e=>e.json())}catch{return{}}}async function Bg(e){return fetch(`/api/documents/search?q=${encodeURIComponent(e)}`).then(e=>e.json())}function Vg(e){return((e.filename||``).split(`/`).pop()??``).match(/^(\d{4}_\d{2}_\d{2}(?:_\d{2}_\d{2})?)/)?.[1]??``}function Hg(e){return e===`alphabetical`?(e,t)=>(e.title||e.filename||``).localeCompare(t.title||t.filename||``):(t,n)=>{let r=Vg(t),i=Vg(n);return r&&i?e===`oldest`?r.localeCompare(i):i.localeCompare(r):r?-1:i?1:(t.filename||``).localeCompare(n.filename||``)}}function Ug(e,t){for(let n of Object.values(e.categories))n.sort(t);for(let n of Object.values(e.children))Ug(n,t)}function Wg(e,t,n,r=`recent`){let i={categories:{},children:{}};for(let t of e){let e=i;for(let n of t.folder||[])e.children[n]||(e.children[n]={categories:{},children:{}}),e=e.children[n];e.categories[t.category]||(e.categories[t.category]=[]),e.categories[t.category].push(t)}if(n)for(let e of t){let t=e.split(`/`).filter(Boolean),n=i;for(let e of t)n.children[e]||(n.children[e]={categories:{},children:{}}),n=n.children[e]}return Ug(i,Hg(r)),i}function Gg(e){let t=Object.values(e.categories).reduce((e,t)=>e+t.length,0);for(let n of Object.values(e.children))t+=Gg(n);return t}function Kg(e,t){let n=0;for(let r of Object.values(e.categories))for(let e of r)t[e.id]>0&&(n+=1);for(let r of Object.values(e.children))n+=Kg(r,t);return n}function qg(e,t){let n=0;for(let r of Object.values(e.categories))for(let e of r)t[e.id]>0&&(n+=1);for(let r of Object.values(e.children))n+=qg(r,t);return n}function Jg(e){return e.replace(/^\d+_/,``).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Yg(e){return Object.keys(e.children).sort((e,t)=>e.localeCompare(t))}function Xg(e){return Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t))}function Zg(e,t=`recent`){return Object.values(e.categories).flat().sort(Hg(t))}var Qg=U(`<span class="inline-flex items-center justify-center w-5 h-5 rounded-full bg-green-500 text-[10px] font-bold text-white border border-green-600 shadow-sm">V</span>`),$g=U(`<span class="inline-flex items-center justify-center w-5 h-5 rounded-full bg-orange-500 text-[10px] font-bold text-white border border-orange-600 shadow-sm">S</span>`),e_=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-yellow-300 dark:bg-yellow-400 text-[10px] font-bold text-yellow-900 border border-yellow-500 shadow-sm"> </span>`),t_=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-sky-200 dark:bg-sky-300 text-[10px] font-bold text-sky-900 border border-sky-500 shadow-sm"> </span>`),n_=U(`<div class="text-xs text-gray-400 dark:text-gray-500 mt-0.5"> </div>`),r_=U(`<button><div class="leading-snug flex items-center justify-between gap-2"><span class="truncate"> </span> <span class="flex items-center gap-1 shrink-0"><!> <!> <!></span></div> <!></button>`),i_=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-orange-400 dark:bg-orange-500 text-[10px] font-bold text-white border border-orange-600 shadow-sm"> </span>`),a_=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-slate-400 dark:bg-slate-500 text-[10px] font-bold text-white border border-slate-600 shadow-sm"> </span>`),o_=U(`<div class="pl-2"></div>`),s_=U(`<div class="mb-0.5"><button class="w-full flex items-center justify-between px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider hover:bg-gray-50 dark:hover:bg-gray-800/60 rounded-md transition-colors"><span class="flex items-center gap-2"><span> </span> <!> <!></span> <span class="flex items-center gap-1.5"><span class="font-normal normal-case text-gray-400"> </span> <span>▸</span></span></button> <!></div>`),c_=U(`<div class="pl-3"><!></div>`),l_=U(`<div class="mb-1"><button class="w-full flex items-center justify-between px-3 py-1.5 text-xs font-semibold text-violet-600 dark:text-violet-400 uppercase tracking-wider hover:bg-gray-50 dark:hover:bg-gray-800/60 rounded-md transition-colors"><span class="flex items-center gap-2 min-w-0"><span class="truncate"> </span> <!> <!></span> <span class="flex items-center gap-1.5"><span class="font-normal normal-case text-gray-400"> </span> <span>▸</span></span></button> <!></div>`),u_=U(`<!> <!>`,1),d_=U(`<!> <!> <!>`,1);function f_(e,t){qe(t,!0);let n=(e,n=f)=>{let r=N(()=>X.annotationCounts[n().id]||0),i=N(()=>X.fileAttachmentCounts[n().id]||0),a=N(()=>c(n()));var o=r_(),l=L(o),u=L(l),d=L(u,!0);j(u);var p=z(u,2),m=L(p),h=e=>{var t=Qg();B(e=>J(t,`title`,e),[()=>Y(`sidebar.status_to_validate`)]),W(e,t)},g=e=>{var t=$g();B(e=>J(t,`title`,e),[()=>Y(`sidebar.status_superseeded`)]),W(e,t)};K(m,e=>{V(a)===`V`?e(h):V(a)===`S`&&e(g,1)});var _=z(m,2),v=e=>{var t=e_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(r))},[()=>s(V(r),`sidebar.annotation_badge`)]),W(e,t)};K(_,e=>{V(r)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=t_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(i))},[()=>s(V(i),`sidebar.file_attachment_badge`)]),W(e,t)};K(y,e=>{V(i)>0&&!X.hideAttachments&&e(b)}),j(p),j(l);var x=z(l,2),S=e=>{var t=n_(),r=L(t,!0);j(t),B(()=>G(r,n().formattedDate)),W(e,t)};K(x,e=>{n().formattedDate&&e(S)}),j(o),B(()=>{J(o,`id`,`item-${n().id??``}`),gi(o,1,`doc-item w-full text-left px-3 py-1.5 rounded-md text-sm transition-colors text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800/60 ${n().id===X.currentDocId?`active`:``}`),G(d,n().title)}),H(`click`,o,()=>t.onopen(n().id)),W(e,o)},r=(e,r=f)=>{let i=N(()=>a(r())),o=N(()=>X.expandedCategories.has(V(i))),c=N(()=>t.node.categories[r()]),l=N(()=>V(c).reduce((e,t)=>e+ +(X.annotationCounts[t.id]>0),0)),u=N(()=>V(c).reduce((e,t)=>e+ +(X.fileAttachmentCounts[t.id]>0),0));var d=s_(),p=L(d),m=L(p),h=L(m),g=L(h,!0);j(h);var _=z(h,2),v=e=>{var t=i_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(l))},[()=>s(V(l),`sidebar.annotated_docs_badge`)]),W(e,t)};K(_,e=>{V(l)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=a_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(u))},[()=>s(V(u),`sidebar.file_attached_docs_badge`)]),W(e,t)};K(y,e=>{V(u)>0&&!X.hideAttachments&&e(b)}),j(m);var x=z(m,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2);j(x),j(p);var T=z(p,2),E=e=>{var t=o_();q(t,21,()=>V(c),e=>e.id,(e,t)=>{n(e,()=>V(t))}),j(t),W(e,t)};K(T,e=>{V(o)&&e(E)}),j(d),B(()=>{G(g,r()),G(C,V(c).length),gi(w,1,`transition-transform duration-200 ${V(o)?`rotate-90`:``}`)}),H(`click`,p,()=>X.toggleCategory(V(i))),W(e,d)},i=(e,n=f)=>{let r=N(()=>o(n())),i=N(()=>X.expandedFolders.has(V(r))),a=N(()=>t.node.children[n()]),c=N(()=>Gg(V(a))),l=N(()=>Kg(V(a),X.annotationCounts)),u=N(()=>qg(V(a),X.fileAttachmentCounts));var d=l_(),p=L(d),m=L(p),h=L(m),g=L(h);j(h);var _=z(h,2),v=e=>{var t=i_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(l))},[()=>s(V(l),`sidebar.annotated_docs_badge`)]),W(e,t)};K(_,e=>{V(l)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=a_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(u))},[()=>s(V(u),`sidebar.file_attached_docs_badge`)]),W(e,t)};K(y,e=>{V(u)>0&&!X.hideAttachments&&e(b)}),j(m);var x=z(m,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2);j(x),j(p);var T=z(p,2),E=e=>{var r=c_(),i=L(r);{let e=N(()=>[...t.folderPath,n()]);f_(i,{get node(){return V(a)},get folderPath(){return V(e)},get onopen(){return t.onopen}})}j(r),W(e,r)};K(T,e=>{V(i)&&e(E)}),j(d),B(e=>{J(h,`title`,n()),G(g,`📁 ${e??``}`),G(C,V(c)),gi(w,1,`transition-transform duration-200 ${V(i)?`rotate-90`:``}`)},[()=>Jg(n())]),H(`click`,p,()=>X.toggleFolder(V(r))),W(e,d)};function a(e){return[...t.folderPath,e].join(`|`)}function o(e){return[...t.folderPath,e].join(`|`)}function s(e,t){return`${e} ${Y(t)}${e>1?`s`:``}`}function c(e){if(!X.highlightStatusState)return null;let t=String(X.docStatuses[e.id]||``).trim().toLowerCase();return t===`to be validated`?`V`:X.highlightStatusState===2&&t===`superseeded`?`S`:null}var l=Wr(),u=R(l),d=e=>{var r=u_(),a=R(r);q(a,17,()=>Zg(t.node,X.sidebarSort),e=>e.id,(e,t)=>{n(e,()=>V(t))}),q(z(a,2),16,()=>Yg(t.node),e=>e,(e,t)=>{i(e,()=>t)}),W(e,r)},p=e=>{var n=d_(),a=R(n),o=e=>{r(e,()=>`General`)};K(a,e=>{t.node.categories.General&&e(o)});var s=z(a,2);q(s,16,()=>Yg(t.node),e=>e,(e,t)=>{i(e,()=>t)}),q(z(s,2),16,()=>Xg(t.node),e=>e,(e,t)=>{r(e,()=>t)}),W(e,n)};K(u,e=>{X.hideCategories?e(d):e(p,-1)}),W(e,l),Je()}Pr([`click`]);var p_=U(`<p class="px-4 py-8 text-sm text-gray-400 text-center"> </p>`),m_=U(`<aside><div class="sticky top-0 z-10 bg-white dark:bg-gray-900 p-3 border-b border-gray-100 dark:border-gray-800"><div class="relative sm:hidden"><input type="search" class="w-full pl-8 pr-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"/> <span class="absolute left-2.5 top-2 text-gray-400 text-sm pointer-events-none">🔍</span></div> <div class="flex items-center justify-between mt-2 sm:mt-0"><p class="text-xs text-gray-400 dark:text-gray-500"> </p> <div class="flex items-center gap-2"><button><i class="fa-solid fa-certificate"></i></button> <button><i class="fa-solid fa-paperclip"></i></button> <button><i class="fa-solid fa-tags"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-file-export"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-folder-plus"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-file-circle-plus"></i></button></div></div></div> <nav data-testid="category-tree" class="flex-1 py-2 space-y-0.5"><!></nav> <div aria-hidden="true"></div></aside>`);function h_(e,t){qe(t,!0);let n=N(()=>Wg(X.filteredDocs,X.allFolderPaths,!X.searchQuery,X.sidebarSort)),r=N(()=>X.filteredDocs.length),i=N(()=>X.filteredDocs.length===0&&X.allFolderPaths.length===0),a=`ld-sidebar-w`,o=P(null),s=P(!1),c=P(null);kn(()=>{let e=parseInt(localStorage.getItem(a)||``,10);Number.isFinite(e)&&F(o,Math.max(200,Math.min(600,e)),!0)});function l(e){e.preventDefault();let t=e.clientX,n=V(c).getBoundingClientRect().width;F(s,!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let r=e=>{F(o,Math.max(200,Math.min(600,n+e.clientX-t)),!0)},i=()=>{if(document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),document.body.style.cursor=``,document.body.style.userSelect=``,F(s,!1),V(o)!=null)try{localStorage.setItem(a,String(V(o)))}catch{}};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)}var u=m_(),d=L(u),f=L(d),p=L(f);Di(p),Ie(2),j(f);var m=z(f,2),h=L(m),g=L(h);j(h);var _=z(h,2),v=L(_),y=z(v,2),b=z(y,2),x=z(b,2),S=z(x,2),C=z(S,2);j(_),j(m),j(d);var w=z(d,2),T=L(w),E=e=>{var t=p_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`sidebar.no_docs`)]),W(e,t)},D=e=>{f_(e,{get node(){return V(n)},folderPath:[],get onopen(){return t.onopen}})};K(T,e=>{V(i)?e(E):e(D,-1)}),j(w);var ee=z(w,2);j(u),Vi(u,e=>F(c,e),()=>V(c)),B((e,t,n,i,a,c,l)=>{gi(u,1,`no-print ${V(o)==null?`w-72`:``} shrink-0 flex flex-col border-r border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 overflow-y-auto relative`),vi(u,V(o)==null?``:`width:${V(o)}px`),J(p,`placeholder`,e),Oi(p,X.searchQuery),G(g,`${V(r)??``} document${V(r)===1?``:`s`}`),J(v,`title`,t),gi(v,1,`hover:opacity-80 transition-colors leading-none ${X.highlightStatusState===0?`text-gray-400 dark:text-gray-500`:X.highlightStatusState===1?`text-green-500 dark:text-green-400`:`text-orange-500 dark:text-orange-400`}`),J(y,`title`,n),gi(y,1,`transition-colors leading-none ${X.hideAttachments?`text-gray-400 dark:text-gray-500`:`text-blue-500 dark:text-blue-400`}`),J(b,`title`,i),gi(b,1,`transition-colors leading-none ${X.hideCategories?`text-gray-400 dark:text-gray-500`:`text-blue-500 dark:text-blue-400`}`),J(x,`title`,a),J(S,`title`,c),J(C,`title`,l),gi(ee,1,`absolute top-0 right-[-2px] w-1.5 h-full cursor-col-resize z-20 select-none transition-colors ${V(s)?`bg-blue-500/55`:`hover:bg-blue-500/35`}`)},[()=>Y(`nav.search_mobile_placeholder`),()=>Y(`nav.toggle_status_highlight`),()=>Y(`nav.toggle_attachments`),()=>Y(`nav.toggle_categories`),()=>Y(`nav.export`),()=>Y(`nav.new_folder`),()=>Y(`nav.new_document`)]),H(`input`,p,e=>t.onsearch(e.target.value)),H(`click`,v,()=>X.cycleHighlightStatus()),H(`click`,y,()=>X.toggleHideAttachments()),H(`click`,b,()=>X.toggleHideCategories()),H(`click`,x,function(...e){t.onexport?.apply(this,e)}),H(`click`,S,function(...e){t.onnewfolder?.apply(this,e)}),H(`click`,C,function(...e){t.onnewdoc?.apply(this,e)}),H(`mousedown`,ee,l),W(e,u),Je()}Pr([`input`,`click`,`mousedown`]);var g_=`background:rgba(250,204,21,0.5);border-radius:2px;cursor:pointer;padding:0 1px;`;function __(e,t,n){e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{let t=e.parentNode;t&&(t.replaceChild(document.createTextNode(e.textContent||``),e),t.normalize())});for(let n of t)y_(e,n);e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{(e.textContent||``).trim()||e.remove()}),n&&v_(e,!1)}function v_(e,t){e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{let n=e;n.style.background=t?`rgba(250,204,21,0.5)`:`transparent`,n.style.cursor=t?`pointer`:`default`,n.style.pointerEvents=t?`auto`:`none`})}function y_(e,t){let n=(t.selectedText||``).replace(/\s+/g,` `).trim(),r=(t.contextBefore||``).replace(/\s+/g,` `).trim(),i=(t.contextAfter||``).replace(/\s+/g,` `).trim();if(!n)return;let a=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),o=e=>e.split(/\s+/).filter(Boolean).map(a).join(`\\s+`),s=e.textContent||``,c=o(n),l=null;if(r||i){let e=(r?`${o(r)}\\s*`:``)+`(`+c+`)`+(i?`\\s*${o(i)}`:``);try{l=new RegExp(e,`d`).exec(s)}catch{}}if(!l)try{l=RegExp(`(${c})`,`d`).exec(s)}catch{return}let u=l&&l.indices;if(!l||!u?.[1])return;let[d,f]=u[1],p=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),m=[],h=0;for(;p.nextNode();){let e=p.currentNode,t=e.nodeValue?.length,n=h,r=h+t;if(h=r,r<=d)continue;if(n>=f)break;let i=Math.max(0,d-n),a=Math.min(t,f-n);i<a&&m.push({node:e,start:i,end:a})}for(let{node:e,start:n,end:r}of m){let i=e;n>0&&n<i.nodeValue?.length&&(i=i.splitText(n));let a=r-n;a>0&&a<i.nodeValue?.length&&i.splitText(a);let o=document.createElement(`mark`);o.setAttribute(`data-annotation-id`,t.id),o.setAttribute(`style`,g_),i.parentNode?.insertBefore(o,i),o.appendChild(i)}}var b_=U(`<div class="fixed z-50 w-80 bg-yellow-50 dark:bg-yellow-900/80 border-2 border-yellow-300 dark:border-yellow-600 rounded-xl shadow-2xl p-4 flex flex-col gap-3"><div class="text-xs font-semibold text-yellow-700 dark:text-yellow-300 flex items-center gap-2"><span>✎</span><span> </span></div> <div class="text-xs text-yellow-800 dark:text-yellow-200 bg-yellow-100 dark:bg-yellow-800/50 rounded px-2 py-1 italic max-h-16 overflow-y-auto border border-yellow-200 dark:border-yellow-700"> </div> <textarea rows="4" class="w-full text-sm rounded-lg border border-yellow-300 dark:border-yellow-600 bg-white dark:bg-yellow-950 text-gray-900 dark:text-gray-100 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-yellow-400 resize-none"></textarea> <div class="flex justify-end gap-2"><button class="text-sm px-3 py-1.5 rounded-lg border border-yellow-300 dark:border-yellow-600 text-yellow-700 dark:text-yellow-300 hover:bg-yellow-100 dark:hover:bg-yellow-800 transition-colors"> </button> <button class="text-sm px-4 py-1.5 rounded-lg bg-yellow-400 hover:bg-yellow-500 dark:bg-yellow-600 dark:hover:bg-yellow-500 text-yellow-900 dark:text-white font-semibold transition-colors"> </button></div></div>`),x_=U(`<div class="text-xs font-semibold text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-700 rounded px-2 py-1"> </div>`),S_=U(`<div class="fixed z-50 w-80 bg-yellow-50 dark:bg-yellow-900/80 border-2 border-yellow-300 dark:border-yellow-600 rounded-xl shadow-2xl p-4 flex flex-col gap-2"><div class="text-xs font-semibold text-yellow-700 dark:text-yellow-300 flex items-center gap-2"><span>✎</span><span class="font-normal text-yellow-600 dark:text-yellow-400"> </span></div> <!> <div class="text-sm text-gray-800 dark:text-gray-100 whitespace-pre-wrap max-h-48 overflow-y-auto"> </div> <div class="flex justify-end pt-1 border-t border-yellow-200 dark:border-yellow-700"><button class="text-xs px-3 py-1.5 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors flex items-center gap-1"> </button></div></div>`),C_=U(`<div class="fixed z-50 w-72 bg-white dark:bg-gray-900 border border-red-200 dark:border-red-700 rounded-xl shadow-2xl p-4 flex flex-col gap-3"><p class="text-sm text-gray-700 dark:text-gray-200"> </p> <div class="flex justify-end gap-2"><button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-1.5 rounded-lg bg-red-500 hover:bg-red-600 text-white font-semibold transition-colors"> </button></div></div>`),w_=U(`<button> </button>`),T_=U(`<div class="fixed top-14 right-0 w-10 flex flex-col items-center py-2 gap-2 z-40 overflow-y-auto" style="max-height: calc(100vh - 3.5rem)"></div>`),E_=U(`<!> <!> <!> <!>`,1);function D_(e,t){qe(t,!0);let n=P(I([])),r=P(null),i=P(``),a=P(null),o=P(null),s=P(I([])),c=null;Gi(()=>{let e=document.getElementById(`home-content-area`);if(!e)return;let t=()=>{c&&clearTimeout(c),F(a,null)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)});function l(e,t,n=320,r=260){let i=window.innerWidth,a=window.innerHeight,o=e;return o+n>i-16&&(o=i-n-16),o<8&&(o=8),{x:o,y:Math.min(t,a-r)}}async function u(e){F(n,[],!0);try{F(n,await fetch(`/api/annotations/`+encodeURIComponent(e)).then(e=>e.json()),!0)}catch{F(n,[],!0)}d()}function d(){t.contentEl&&(__(t.contentEl,V(n),X.markerHidden),f())}kn(()=>{t.contentEl&&v_(t.contentEl,!X.markerHidden)});function f(){if(!t.contentEl){F(s,[],!0);return}F(s,V(n).map(e=>({id:e.id,note:e.note.length>60?e.note.slice(0,60)+`…`:e.note,orphan:!t.contentEl.querySelector(`mark[data-annotation-id="${e.id}"]`)})),!0)}function p(){if(!X.markerActive||V(r)||!t.contentEl)return;let e=window.getSelection();if(!e||e.isCollapsed||!e.toString().trim()||!t.contentEl.contains(e.anchorNode))return;let n=e.getRangeAt(0),a=document.createRange();a.selectNodeContents(t.contentEl),a.setEnd(n.startContainer,n.startOffset);let o=a.toString().length,s=n.toString(),c=t.contentEl.textContent||``,u=e=>e.replace(/\s+/g,` `).trim(),d=u(s),f=u(c.slice(Math.max(0,o-30),o)),p=u(c.slice(o+s.length,o+s.length+30)),m=n.getBoundingClientRect(),h=l(m.left,m.bottom+8);F(r,{x:h.x,y:h.y,preview:d.length>120?d.slice(0,120)+`…`:d,selectedText:d,contextBefore:f,contextAfter:p},!0),F(i,``)}function m(){F(r,null),window.getSelection()?.removeAllRanges()}async function h(){if(!V(r)||!t.docId)return;let e=V(i).trim();if(e)try{let i=await fetch(`/api/annotations/`+encodeURIComponent(t.docId),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({selectedText:V(r).selectedText,contextBefore:V(r).contextBefore,contextAfter:V(r).contextAfter,note:e})}).then(e=>e.json());F(n,[...V(n),i],!0),m(),d(),X.annotationCounts={...X.annotationCounts,[t.docId]:(X.annotationCounts[t.docId]||0)+1}}catch{}}kn(()=>{if(!t.contentEl)return;let e=t.contentEl,r=e=>{let t=e.target.closest(`mark[data-annotation-id]`);if(!t)return;let r=V(n).find(e=>e.id===t.dataset.annotationId);r&&g(r,t)},i=e=>{let t=e;t.target.closest(`mark[data-annotation-id]`)&&(t.relatedTarget&&t.relatedTarget.closest?.(`mark[data-annotation-id]`)||_())};return e.addEventListener(`mouseover`,r),e.addEventListener(`mouseout`,i),()=>{e.removeEventListener(`mouseover`,r),e.removeEventListener(`mouseout`,i)}});function g(e,n){c&&clearTimeout(c);let r=!t.contentEl?.querySelector(`mark[data-annotation-id="${e.id}"]`),i=n.getBoundingClientRect(),o=l(i.left,i.bottom+8);F(a,{ann:e,x:o.x,y:o.y,orphan:r},!0)}function _(){c=window.setTimeout(()=>{F(a,null)},1500)}function v(){V(a)&&(F(o,{id:V(a).ann.id,x:V(a).x,y:V(a).y},!0),F(a,null))}async function y(){if(!V(o)||!t.docId)return;let e=V(o).id;try{await fetch(`/api/annotations/${encodeURIComponent(t.docId)}/${e}`,{method:`DELETE`}),F(n,V(n).filter(t=>t.id!==e),!0),F(o,null),d();let r=(X.annotationCounts[t.docId]||0)-1,i={...X.annotationCounts};r<=0?delete i[t.docId]:i[t.docId]=r,X.annotationCounts=i}catch{}}function b(e,t){return e.getBoundingClientRect().top+t.scrollTop-t.getBoundingClientRect().top}function x(e,t){let n=e.parentElement;for(;n&&n!==t;)n.tagName===`DETAILS`&&(n.open=!0),n=n.parentElement}function S(e,r){let i=t.contentEl?.querySelector(`mark[data-annotation-id="${e}"]`),o=document.getElementById(`home-content-area`);if(i&&o){if(V(a)?.ann.id===e){c&&clearTimeout(c);return}x(i,o),o.scrollTo({top:b(i,o)-o.clientHeight/2,behavior:`smooth`})}else{let t=V(n).find(t=>t.id===e);t&&g(t,r.currentTarget)}}function C(e,r){c&&clearTimeout(c);let i=V(n).find(t=>t.id===e);if(!i)return;let a=t.contentEl?.querySelector(`mark[data-annotation-id="${e}"]`),o=document.getElementById(`home-content-area`);if(!a||!o){g(i,r.currentTarget);return}x(a,o),o.scrollTo({top:b(a,o)-o.clientHeight/2,behavior:`smooth`});let s,l=()=>{clearTimeout(s),s=window.setTimeout(()=>{o.removeEventListener(`scroll`,l),g(i,a)},80)};o.addEventListener(`scroll`,l),s=window.setTimeout(()=>{o.removeEventListener(`scroll`,l),g(i,a)},600)}function w(e){let t=V(a)?.ann.id===e.id;return e.orphan?t?`#b91c1c`:`#ef4444`:t?`#f97316`:`#facc15`}function T(e){return new Date(e).toLocaleDateString(`fr-FR`,{day:`2-digit`,month:`short`,year:`numeric`})}var E={load:u,apply:d},D=E_();Nr(`mouseup`,on,p);var ee=R(D),te=e=>{var t=b_(),n=L(t),a=z(L(n)),o=L(a,!0);j(a),j(n);var s=z(n,2),c=L(s,!0);j(s);var l=z(s,2);yn(l),vn(l,!0);var u=z(l,2),d=L(u),f=L(d,!0);j(d);var p=z(d,2),g=L(p,!0);j(p),j(u),j(t),B((e,n,i,a)=>{vi(t,`left:${V(r).x??``}px;top:${V(r).y??``}px`),G(o,e),G(c,V(r).preview),J(l,`placeholder`,n),G(f,i),G(g,a)},[()=>Y(`annotation.title`),()=>Y(`annotation.placeholder`),()=>Y(`common.cancel`),()=>Y(`annotation.save_btn`)]),Ni(l,()=>V(i),e=>F(i,e)),H(`click`,d,m),H(`click`,p,h),W(e,t)};K(ee,e=>{V(r)&&e(te)});var O=z(ee,2),ne=e=>{var t=S_(),n=L(t),r=z(L(n)),i=L(r,!0);j(r),j(n);var o=z(n,2),s=e=>{var t=x_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`annotation.orphan`)]),W(e,t)};K(o,e=>{V(a).orphan&&e(s)});var l=z(o,2),u=L(l,!0);j(l);var d=z(l,2),f=L(d),p=L(f,!0);j(f),j(d),j(t),B((e,n)=>{vi(t,`left:${V(a).x??``}px;top:${V(a).y??``}px`),G(i,e),G(u,V(a).ann.note),G(p,n)},[()=>T(V(a).ann.createdAt),()=>Y(`annotation.delete_btn`)]),Nr(`mouseenter`,t,()=>{c&&clearTimeout(c)}),Nr(`mouseleave`,t,_),H(`click`,f,v),W(e,t)};K(O,e=>{V(a)&&e(ne)});var re=z(O,2),k=e=>{var t=C_(),n=L(t),r=L(n,!0);j(n);var i=z(n,2),a=L(i),s=L(a,!0);j(a);var c=z(a,2),l=L(c,!0);j(c),j(i),j(t),B((e,n,i)=>{vi(t,`left:${V(o).x??``}px;top:${V(o).y??``}px`),G(r,e),G(s,n),G(l,i)},[()=>Y(`annotation.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`annotation.confirm_btn`)]),H(`click`,a,()=>F(o,null)),H(`click`,c,y),W(e,t)};K(re,e=>{V(o)&&e(k)});var ie=z(re,2),ae=e=>{var t=T_();q(t,21,()=>V(s),e=>e.id,(e,t)=>{var n=w_(),r=L(n,!0);j(n),B((e,i)=>{J(n,`title`,e),gi(n,1,`w-8 h-8 rounded border-2 shadow text-xs flex items-center justify-center transition-colors shrink-0 ${V(t).orphan?`border-red-600 text-white`:`border-yellow-500`}`),vi(n,`background:${i??``}`),G(r,V(t).orphan?`⚠`:`✎`)},[()=>V(t).orphan?`${Y(`annotation.orphan`)}\n\n${V(t).note}`:V(t).note,()=>w(V(t))]),H(`click`,n,e=>S(V(t).id,e)),Nr(`mouseenter`,n,e=>C(V(t).id,e)),Nr(`mouseleave`,n,_),W(e,n)}),j(t),W(e,t)};return K(ie,e=>{V(s).length>0&&!X.markerHidden&&e(ae)}),W(e,D),Je(E)}Pr([`click`]);var O_=`#dc2626`,k_=`#eab308`,A_=`#16a34a`;function j_(e){let t=Math.max(0,Math.min(1,e))*100;return t>80?A_:t>=60?k_:t>=40?`#f97316`:O_}function M_(e){let t=Math.max(0,Math.min(1,e))*100;return t>=100?A_:t<30?O_:t<60?`linear-gradient(to right, ${O_} 0%, ${O_} 60%, ${k_} 100%)`:t<80?`linear-gradient(to right, ${O_} 0%, ${k_} 40%, ${k_} 100%)`:`linear-gradient(to right, ${k_} 0%, ${A_} 40%, ${A_} 100%)`}var N_=new class{#e=P(null);get report(){return V(this.#e)}set report(e){F(this.#e,e,!0)}async load(e){if(!e)return this.report=null,null;try{let t=await fetch(`/api/metadata/${encodeURIComponent(e)}`);if(!t.ok)throw Error(t.statusText);this.report=await t.json()}catch{this.report=null}return this.report}async refresh(e){let t=await fetch(`/api/metadata/${encodeURIComponent(e)}/refresh`,{method:`POST`});if(!t.ok)throw Error(t.statusText);this.report=await t.json()}async addPath(e,t){let n=await fetch(`/api/metadata/${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||n.statusText)}this.report=await n.json()}async removePath(e,t){let n=await fetch(`/api/metadata/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!n.ok)throw Error(n.statusText);this.report=await n.json()}},P_=U(`<div data-testid="accuracy-gauge" class="no-print mt-5 flex items-center gap-3 mr-auto w-full sm:w-80 cursor-pointer select-none"><span class="text-xs text-gray-500 dark:text-gray-400 shrink-0"> </span> <div class="flex-1 h-4 rounded-full bg-gray-200 dark:bg-gray-700 overflow-hidden"><div class="h-full w-full transition-all"></div></div> <span data-testid="accuracy-gauge-value" class="text-xs font-semibold shrink-0 tabular-nums"> </span></div>`);function F_(e,t){qe(t,!0);let n=N(()=>N_.report),r=N(()=>V(n)?Math.round(V(n).accuracy*100):0),i=N(()=>V(n)?Y(`accuracy.tooltip`).replace(`{unchanged}`,String(V(n).unchanged)).replace(`{modified}`,String(V(n).modified)).replace(`{missing}`,String(V(n).missing)).replace(`{total}`,String(V(n).total)):``);var a=Wr(),o=R(a),s=e=>{var a=P_(),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c);j(c);var u=z(c,2),d=L(u);j(u),j(a),B((e,t,n)=>{J(a,`title`,V(i)),G(s,e),vi(l,`background:${t??``}`),vi(u,`color:${n??``}`),G(d,`${V(r)??``}%`)},[()=>Y(`accuracy.label`),()=>M_(V(n).accuracy),()=>j_(V(n).accuracy)]),H(`click`,a,function(...e){t.onopen?.apply(this,e)}),W(e,a)};K(o,e=>{V(n)&&V(n).total>0&&e(s)}),W(e,a),Je()}Pr([`click`]);var I_=/^(\s*(?:\*\*status:\*\*|status:)\s*).+?\s*$/im;function L_(e){if(typeof e!=`string`)return null;let t=e.match(/^---\s*\n([\s\S]*?)\n---/);if(!t)return null;let n=t[1].match(/^\s*(?:\*\*status:\*\*|status:)\s*(.+?)\s*$/im);return n?n[1].trim():null}function R_(e,t){return e.replace(I_,`$1${t}`)}function z_(e){return/%5BWORKLOG%5D/i.test(e)}var B_=U(`<div data-testid="metadata-readonly-banner" class="text-xs text-amber-800 dark:text-amber-200 bg-amber-50 dark:bg-amber-900/30 border-l-4 border-amber-500 rounded-r px-3 py-2"> </div>`),V_=U(`<div class="px-3 py-4 text-center text-xs text-gray-400"> </div>`),H_=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300"><i class="fa-solid fa-check"></i> </span>`),U_=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300"><i class="fa-solid fa-triangle-exclamation"></i> </span>`),W_=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300"><i class="fa-solid fa-circle-xmark"></i> </span>`),G_=U(`<button class="metadata-row-remove text-xs px-2 py-1 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors"><i class="fa-solid fa-trash"></i></button>`),K_=U(`<div class="flex items-center gap-2 px-3 py-2 border-b border-gray-100 dark:border-gray-800"><div class="flex-1 min-w-0"><div class="text-sm font-mono truncate text-gray-800 dark:text-gray-200"> </div></div> <!> <!></div>`),q_=U(`<div class="flex items-center gap-2 flex-wrap"><button data-testid="metadata-add-btn" class="text-sm px-3 py-1.5 rounded-lg border border-blue-200 dark:border-blue-700 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 transition-colors"><i class="fa-solid fa-plus"></i> </button> <button data-testid="metadata-refresh-btn" class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><i class="fa-solid fa-arrows-rotate"></i> </button></div>`),J_=U(`<div class="px-3 py-2 text-xs text-gray-400"> </div>`),Y_=U(`<div class="px-3 py-2 text-xs text-red-500"> </div>`),X_=U(`<button class="w-full text-left px-3 py-1.5 text-sm hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center gap-2"><i class="fa-solid fa-folder text-yellow-500"></i> <span class="truncate"> </span></button>`),Z_=U(`<button class="w-full text-left px-3 py-1.5 text-sm hover:bg-blue-50 dark:hover:bg-blue-900/30 flex items-center gap-2"><i class="fa-solid fa-file text-gray-400"></i> <span class="truncate"> </span> <i class="fa-solid fa-plus ml-auto text-blue-500 text-xs"></i></button>`),Q_=U(`<!> <!>`,1),$_=U(`<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden text-sm"><div class="flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"><button class="text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-30 disabled:pointer-events-none shrink-0"> </button> <span class="text-xs text-gray-500 dark:text-gray-400 font-mono truncate flex-1"> </span></div> <div class="max-h-56 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800"><!></div></div>`),ev=U(`<p class="text-xs text-red-500"> </p>`),tv=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div data-testid="metadata-modal" class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-2xl mx-4 p-6 space-y-4"><div class="flex items-start justify-between gap-4"><div><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-code-compare mr-1"></i> </h3> <p class="text-xs text-gray-500 dark:text-gray-400 mt-1"> </p></div> <button class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-colors"><i class="fa-solid fa-xmark text-lg"></i></button></div> <div class="text-xs text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-800 rounded-lg px-3 py-2"></div> <!> <div data-testid="metadata-list" class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden"><div class="max-h-64 overflow-y-auto"><!></div></div> <!> <!> <!> <div class="flex justify-end"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button></div></div></div>`);function nv(e,t){qe(t,!0);let n=N(()=>N_.report),r=N(()=>L_(t.content)===`SuperSeeded`),i=P(``),a=P(!1),o=P(!1),s=P(``),c=P(null),l=P(I([])),u=P(I([])),d=P(!1),f=P(``);kn(()=>{t.open||(F(o,!1),F(s,``),F(i,``))});function p(e){F(i,Y(`common.error_prefix`)+e),setTimeout(()=>{F(i,``)},5e3)}function m(){return!V(n)||V(n).total===0?``:`<span class="font-semibold">${Math.round(V(n).accuracy*100)}%</span> · ${V(n).unchanged}/${V(n).total} ${Y(`metadata.status.unchanged`)} · ${V(n).modified} ${Y(`metadata.status.modified`)} · ${V(n).missing} ${Y(`metadata.status.missing`)}`}async function h(){F(a,!0);try{await N_.refresh(t.docId)}catch(e){p(e instanceof Error?e.message:String(e))}finally{F(a,!1)}}async function g(e){try{await N_.removePath(t.docId,e),V(o)&&y(V(s))}catch(e){p(e instanceof Error?e.message:String(e))}}async function _(e){try{await N_.addPath(t.docId,e),V(o)&&y(V(s))}catch(e){p(e instanceof Error?e.message:String(e))}}function v(){F(o,!V(o)),V(o)&&y(``)}async function y(e){F(d,!0),F(f,``);try{let t=await fetch(`/api/browse-source?path=`+encodeURIComponent(e||``));if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||t.statusText)}let r=await t.json();F(s,r.current||``,!0),F(c,r.parent,!0),F(l,r.dirs||[],!0);let i=new Set((V(n)?.items||[]).map(e=>e.path));F(u,(r.files||[]).filter(e=>!i.has(e.path)),!0)}catch(e){F(f,e instanceof Error?e.message:String(e),!0)}finally{F(d,!1)}}function b(){V(c)!==null&&y(V(c))}var x=Wr(),S=R(x),C=e=>{var p=tv(),x=L(p),S=L(x),C=L(S),w=L(C),T=z(L(w));j(w);var E=z(w,2),D=L(E,!0);j(E),j(C);var ee=z(C,2);j(S);var te=z(S,2);ai(te,m,!0),j(te);var O=z(te,2),ne=e=>{var t=B_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`metadata.readonly_banner`)]),W(e,t)};K(O,e=>{V(r)&&e(ne)});var re=z(O,2),k=L(re),ie=L(k),ae=e=>{var t=V_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`metadata.empty`)]),W(e,t)},oe=e=>{var t=Wr();q(R(t),17,()=>V(n).items,e=>e.path,(e,t)=>{var n=K_(),i=L(n),a=L(i),o=L(a,!0);j(a),j(i);var s=z(i,2),c=e=>{var t=H_(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.unchanged`)]),W(e,t)},l=e=>{var t=U_(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.modified`)]),W(e,t)},u=e=>{var t=W_(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.missing`)]),W(e,t)};K(s,e=>{V(t).status===`unchanged`?e(c):V(t).status===`modified`?e(l,1):e(u,-1)});var d=z(s,2),f=e=>{var n=G_();B(e=>J(n,`title`,e),[()=>Y(`metadata.remove`)]),H(`click`,n,()=>g(V(t).path)),W(e,n)};K(d,e=>{V(r)||e(f)}),j(n),B(()=>{J(a,`title`,V(t).path),G(o,V(t).path)}),W(e,n)}),W(e,t)};K(ie,e=>{!V(n)||V(n).items.length===0?e(ae):e(oe,-1)}),j(k),j(re);var se=z(re,2),ce=e=>{var t=q_(),n=L(t),r=z(L(n));j(n);var i=z(n,2),o=z(L(i));j(i),j(t),B((e,t)=>{G(r,` ${e??``}`),i.disabled=V(a),G(o,` ${t??``}`)},[()=>Y(`metadata.add`),()=>Y(`metadata.refresh`)]),H(`click`,n,v),H(`click`,i,h),W(e,t)};K(se,e=>{V(r)||e(ce)});var le=z(se,2),ue=e=>{var t=$_(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n);var p=z(n,2),m=L(p),h=e=>{var t=J_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},g=e=>{var t=Y_(),n=L(t,!0);j(t),B(()=>G(n,V(f))),W(e,t)},v=e=>{var t=J_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.empty_dir`)]),W(e,t)},x=e=>{var t=Q_(),n=R(t);q(n,17,()=>V(l),e=>e.path,(e,t)=>{var n=X_(),r=z(L(n),2),i=L(r,!0);j(r),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>y(V(t).path)),W(e,n)}),q(z(n,2),17,()=>V(u),e=>e.path,(e,t)=>{var n=Z_(),r=z(L(n),2),i=L(r,!0);j(r),Ie(2),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>_(V(t).path)),W(e,n)}),W(e,t)};K(m,e=>{V(d)?e(h):V(f)?e(g,1):V(l).length===0&&V(u).length===0?e(v,2):e(x,-1)}),j(p),j(t),B(e=>{r.disabled=V(c)===null,G(i,e),G(o,V(s)?`/`+V(s):`/ (sourceRoot)`)},[()=>Y(`common.up`)]),H(`click`,r,b),W(e,t)};K(le,e=>{V(o)&&e(ue)});var de=z(le,2),fe=e=>{var t=ev(),n=L(t,!0);j(t),B(()=>G(n,V(i))),W(e,t)};K(de,e=>{V(i)&&e(fe)});var pe=z(de,2),me=L(pe),he=L(me,!0);j(me),j(pe),j(x),j(p),B((e,t,n,r)=>{G(T,` ${e??``}`),G(D,t),J(ee,`title`,n),G(he,r)},[()=>Y(`metadata.title`),()=>Y(`metadata.subtitle`),()=>Y(`common.close`),()=>Y(`common.close`)]),H(`click`,p,e=>{e.target===e.currentTarget&&t.onclose()}),H(`click`,ee,function(...e){t.onclose?.apply(this,e)}),H(`click`,me,function(...e){t.onclose?.apply(this,e)}),W(e,p)};K(S,e=>{t.open&&e(C)}),W(e,x),Je()}Pr([`click`]);var rv=U(`<div class="text-xs font-medium text-amber-700 dark:text-amber-300"> </div>`),iv=U(`<div> </div>`),av=U(`<button type="button"><div class="flex items-center gap-2 font-semibold text-gray-800 dark:text-gray-100"><span class="font-mono text-blue-600 dark:text-blue-400"> </span> <span class="truncate"> </span></div> <div class="mt-1 text-gray-500 dark:text-gray-400"> </div></button>`),ov=U(`<div class="mt-3 flex gap-2 overflow-x-auto pb-1"></div>`),sv=U(`<p class="mt-3 text-sm text-gray-500 dark:text-gray-400"> </p>`),cv=U(`<div class="flex h-full items-center justify-center text-sm text-gray-500 dark:text-gray-400"> </div>`),lv=U(`<div class="m-5 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-950/30 dark:text-red-300"> </div>`),uv=U(`<div class="mx-5 mt-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-200"> </div>`),dv=U(`<button type="button" class="mt-0.5 inline-flex h-7 w-8 items-center justify-center rounded-md border border-blue-200 bg-white font-mono text-sm font-bold text-blue-600 transition-colors hover:bg-blue-50 disabled:cursor-wait disabled:opacity-50 dark:border-blue-800 dark:bg-gray-950 dark:text-blue-300 dark:hover:bg-blue-950/40"> </button>`),fv=U(`<div><span> </span> <pre class="m-0 whitespace-pre-wrap break-words px-2 py-0.5 font-mono"> </pre></div> <div class="flex items-start justify-center border-r border-gray-200 bg-gray-50 px-1 py-0.5 dark:border-gray-800 dark:bg-gray-900/70"><!></div> <div><span> </span> <pre class="m-0 whitespace-pre-wrap break-words px-2 py-0.5 font-mono"> </pre></div>`,1),pv=U(`<!> <div class="h-full overflow-auto p-5"><div class="grid min-w-[980px] grid-cols-[minmax(0,1fr)_3.25rem_minmax(0,1fr)] overflow-hidden rounded-lg border border-gray-200 text-xs dark:border-gray-800"><div class="border-b border-r border-gray-200 bg-gray-100 px-3 py-2 font-semibold text-gray-700 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-200"> </div> <div class="border-b border-r border-gray-200 bg-gray-100 px-2 py-2 text-center font-semibold text-gray-400 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-500"></div> <div class="border-b border-gray-200 bg-gray-100 px-3 py-2 font-semibold text-gray-700 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-200"> </div> <!></div></div>`,1),mv=U(`<div data-testid="versions-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"><div class="flex h-[90vh] w-full max-w-7xl flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-2xl dark:border-gray-700 dark:bg-gray-950"><header class="flex shrink-0 items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"><div><h2 class="text-lg font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-code-branch mr-2"></i> </h2> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400"> </p></div> <button type="button" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm text-gray-600 transition-colors hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"><i class="fa-solid fa-xmark"></i></button></header> <div class="shrink-0 border-b border-gray-200 px-5 py-3 dark:border-gray-800"><div class="flex flex-wrap items-end gap-3"><label class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"> <input type="number" class="mt-1 block w-28 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-800 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100"/></label> <button type="button" class="rounded-lg bg-blue-600 px-3 py-1.5 text-sm font-semibold text-white transition-colors hover:bg-blue-700 disabled:opacity-50"><i class="fa-solid fa-arrows-rotate mr-1"></i> </button> <button type="button" class="rounded-lg bg-green-600 px-3 py-1.5 text-sm font-semibold text-white transition-colors hover:bg-green-700 disabled:cursor-not-allowed disabled:opacity-50"><i class="fa-solid fa-floppy-disk mr-1"></i> </button> <div class="text-xs text-gray-500 dark:text-gray-400"> </div> <!> <!></div> <!></div> <section class="min-h-0 flex-1 overflow-hidden"><!></section></div></div>`);function hv(e,t){qe(t,!0);let n=3650,r=P(30),i=P(30),a=P(!1),o=P(``),s=P(null),c=P(null),l=P(null),u=P(``),d=``,f=P(``),p=P(!1),m=N(()=>V(l)?.headContent??t.content),h=N(()=>V(f)),g=N(()=>V(f)!==V(m)),_=N(()=>T(V(l)?.baseContent??``,V(h))),v=N(()=>V(_).rows),y=N(()=>V(l)?.baseContent!==null&&V(l)?.baseContent!==void 0);kn(()=>{t.docId,F(f,t.content,!0)});function b(e){return Number.isFinite(e)?Math.max(1,Math.min(n,Math.floor(e))):30}function x(e){return e.length?e.replace(/\r\n/g,`
99
+ <a href="${O(s)}" target="_blank" rel="noopener" class="mcp-saved-link">📄 ${O(a)}</a>`})}catch(n){f(e,t,{running:!1,error:n.message||String(n),resultHtml:``})}}async function te(e){let n=V(e===`tool`?o:s);if(!n.length)return;F(c,!0);let r=n.length;try{for(let i=0;i<n.length;i++)t.onStatus(Y(`context.mcp_running_all`).replace(`{current}`,String(i+1)).replace(`{total}`,String(r))),await ee(e,n[i].name);t.onStatus(Y(`context.mcp_done_all`).replace(`{total}`,String(r)))}finally{F(c,!1)}}function O(e){return String(e??``).replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e])}async function ne(){try{let e=await fetch(`/mcp`);if(!e.ok)throw Error(await e.text());let t=await e.json(),c=Array.isArray(t.tools)?t.tools:[],l=Array.isArray(t.prompts)?t.prompts:[];F(n,Y(`context.mcp_available`),!0),F(r,!0),F(i,t.transport||`-`,!0),F(a,t.endpoint||`POST /mcp`,!0),F(o,c,!0),F(s,l,!0),c.forEach(m),l.forEach(h)}catch{F(n,Y(`context.mcp_unavailable`),!0),F(r,!1),F(i,`-`),F(a,`/mcp`),F(o,[],!0),F(s,[],!0)}}var re={load:ne},k=Ag(),ie=L(k),ae=L(ie),oe=L(ae,!0);j(ae);var se=z(ae,2),ce=L(se,!0);j(se),j(ie);var le=z(ie,2),ue=L(le,!0);j(le);var de=z(le,2),fe=L(de),pe=L(fe),me=L(pe,!0);j(pe);var he=z(pe,2),ge=L(he,!0);j(he),j(fe);var _e=z(fe,2),ve=L(_e),ye=L(ve,!0);j(ve);var be=z(ve,2),xe=L(be,!0);j(be),j(_e);var Se=z(_e,2),Ce=L(Se),A=L(Ce,!0);j(Ce);var we=z(Ce,2),Te=L(we,!0);j(we),j(Se),j(de);var Ee=z(de,2),De=L(Ee),Oe=L(De),ke=L(Oe,!0);j(Oe);var Ae=z(Oe,2),je=L(Ae),Me=L(je,!0);j(je);var Ne=z(je,2),Pe=L(Ne,!0);j(Ne),j(Ae),j(De);var Fe=z(De,2),Ie=L(Fe),Le=e=>{var t=Sg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.mcp_no_tools`)]),W(e,t)},Re=e=>{var t=Wr();q(R(t),17,()=>V(o),Xr,(e,t)=>{let n=N(()=>V(l).get(V(t).name)??{argsJson:`{}`,running:!1,error:``,resultHtml:``});var r=Eg(),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=e=>{var n=Cg(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(o,e=>{V(t).description&&e(s)});var c=z(o,2),u=e=>{var n=wg(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n),B((e,t)=>{G(i,e),G(o,t)},[()=>Y(`context.mcp_input_schema`),()=>JSON.stringify(V(t).inputSchema,null,2)]),W(e,n)};K(c,e=>{V(t).inputSchema&&e(u)});var d=z(c,2),p=L(d),m=L(p,!0);j(p);var h=z(p,2);yn(h);var g=z(h,2),_=L(g),v=L(_,!0);j(_);var y=z(_,2),b=L(y,!0);j(y),j(g);var x=z(g,2),S=e=>{var t=Tg();ai(t,()=>V(n).resultHtml,!0),j(t),W(e,t)};K(x,e=>{V(n).resultHtml&&e(S)}),j(d),j(r),B((e,r)=>{G(a,V(t).name),G(m,e),Oi(h,V(n).argsJson),G(v,V(n).error),y.disabled=V(n).running,G(b,r)},[()=>Y(`context.mcp_request_json`),()=>Y(`context.mcp_run_tool`)]),H(`input`,h,e=>f(`tool`,V(t).name,{argsJson:e.target.value})),H(`click`,y,()=>ee(`tool`,V(t).name)),W(e,r)}),W(e,t)};K(Ie,e=>{V(o).length?e(Re,-1):e(Le)}),j(Fe),j(Ee);var ze=z(Ee,2),Be=L(ze),Ve=L(Be),He=L(Ve,!0);j(Ve);var Ue=z(Ve,2),We=L(Ue),Ge=L(We,!0);j(We);var Ke=z(We,2),Ye=L(Ke,!0);j(Ke),j(Ue),j(Be);var Xe=z(Be,2),Ze=L(Xe),Qe=e=>{var t=Sg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.mcp_no_prompts`)]),W(e,t)},$e=e=>{var t=Wr();q(R(t),17,()=>V(s),Xr,(e,t)=>{let n=N(()=>V(u).get(V(t).name)??{argsJson:`{}`,running:!1,error:``,resultHtml:``});var r=Eg(),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=e=>{var n=Cg(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(o,e=>{V(t).description&&e(s)});var c=z(o,2),l=e=>{var n=kg(),r=L(n),i=L(r,!0);j(r);var a=z(r,2);q(a,21,()=>V(t).arguments,Xr,(e,t)=>{var n=Og(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=e=>{var n=Dg(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(c,e=>{V(t).description&&e(l)}),j(n),B(e=>{G(a,V(t).name),G(s,e)},[()=>V(t).required?Y(`context.mcp_required`):Y(`context.mcp_optional`)]),W(e,n)}),j(a),j(n),B(e=>G(i,e),[()=>Y(`context.mcp_arguments`)]),W(e,n)};K(c,e=>{V(t).arguments?.length&&e(l)});var d=z(c,2),p=L(d),m=L(p,!0);j(p);var h=z(p,2);yn(h);var g=z(h,2),_=L(g),v=L(_,!0);j(_);var y=z(_,2),b=L(y,!0);j(y),j(g);var x=z(g,2),S=e=>{var t=Tg();ai(t,()=>V(n).resultHtml,!0),j(t),W(e,t)};K(x,e=>{V(n).resultHtml&&e(S)}),j(d),j(r),B((e,r)=>{G(a,V(t).name),G(m,e),Oi(h,V(n).argsJson),G(v,V(n).error),y.disabled=V(n).running,G(b,r)},[()=>Y(`context.mcp_request_json`),()=>Y(`context.mcp_get_prompt`)]),H(`input`,h,e=>f(`prompt`,V(t).name,{argsJson:e.target.value})),H(`click`,y,()=>ee(`prompt`,V(t).name)),W(e,r)}),W(e,t)};return K(Ze,e=>{V(s).length?e($e,-1):e(Qe)}),j(Xe),j(ze),j(k),B((e,t,l,u,d,f,p,m,h,g)=>{G(oe,e),G(ce,t),G(ue,l),G(me,u),gi(he,1,ui(V(r)?`mcp-info-value ok`:`mcp-info-value err`),`svelte-1ui2b6s`),G(ge,V(n)),G(ye,d),G(xe,V(i)),G(A,f),G(Te,V(a)),G(ke,p),G(Me,V(o).length),Ne.disabled=V(c)||!V(o).length,G(Pe,m),G(He,h),G(Ge,V(s).length),Ke.disabled=V(c)||!V(s).length,G(Ye,g)},[()=>Y(`context.mcp_title`),()=>Y(`context.mcp_refresh`),()=>Y(`context.mcp_intro`),()=>Y(`context.mcp_status`),()=>Y(`context.mcp_transport`),()=>Y(`context.mcp_endpoint`),()=>Y(`context.mcp_tools`),()=>Y(`context.mcp_run_all_tools`),()=>Y(`context.mcp_prompts`),()=>Y(`context.mcp_get_all_prompts`)]),H(`click`,se,ne),H(`click`,Ne,()=>te(`tool`)),H(`click`,Ke,()=>te(`prompt`)),W(e,k),Je(re)}Pr([`click`,`input`]);var Mg=U(`<p class="status-text svelte-rpj1e5"> </p>`),Ng=U(`<div class="app-shell"><!> <main class="context-scroll svelte-rpj1e5"><div class="context-inner svelte-rpj1e5"><section class="page-intro svelte-rpj1e5"><h2 class="page-title svelte-rpj1e5"> </h2> <p class="page-desc svelte-rpj1e5"> </p> <!></section> <!> <!> <!></div></main></div> <!>`,1);function Pg(e,t){qe(t,!0);let n=P(``),r=P(I([])),i=P(I([])),a=P(``),o=P(null),s=P(null),c=P(null);function l(e){F(n,e,!0)}async function u(){l(Y(`context.loading`));let e=await fetch(`/api/context/orientation`);if(!e.ok)throw Error(await e.text());let t=await e.json();F(o,t,!0),F(r,t.instructions||[],!0),F(i,t.rules||[],!0),F(a,t.rulesFolder||``,!0),l(``)}async function d(e){l(Y(`context.adding_instruction_file`));let t=await fetch(`/api/context/instructions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})});if(!t.ok)throw Error(await t.text());await u()}async function f(e){if(!await V(s).show({kicker:Y(`context.remove_instruction_title`),title:Y(`context.remove_instruction_title`),message:Y(`context.remove_instruction_message`).replace(`{name}`,e),confirmLabel:Y(`common.remove`),cancelLabel:Y(`common.cancel`)||`Cancel`,danger:!0}))return;l(Y(`context.removing_instruction_file`));let t=await fetch(`/api/context/instructions/`+encodeURIComponent(e),{method:`DELETE`});if(!t.ok)throw Error(await t.text());await u()}async function p(e){l(Y(`context.saving_rule`));let t=await fetch(`/api/context/rules`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await t.text());await u()}Gi(async()=>{try{let e=await fetch(`/api/config`);await ha((e.ok?await e.json():{}).language||`en`)}catch{await ha(`en`)}document.title=Y(`context.title`),await u().catch(e=>l(e.message)),await V(c).load().catch(()=>{})});var m=Ng(),h=R(m),g=L(h);so(g,{get navigate(){return t.navigate}});var _=z(g,2),v=L(_),y=L(v),b=L(y),x=L(b,!0);j(b);var S=z(b,2),C=L(S,!0);j(S);var w=z(S,2),T=e=>{var t=Mg(),r=L(t,!0);j(t),B(()=>G(r,V(n))),W(e,t)};K(w,e=>{V(n)&&e(T)}),j(y);var E=z(y,2);pg(E,{onAdd:d,onRemove:f,get items(){return V(r)},set items(e){F(r,e,!0)}});var D=z(E,2);xg(D,{get rules(){return V(i)},get rulesFolder(){return V(a)},onAdd:p}),Vi(jg(z(D,2),{onStatus:l}),e=>F(c,e,!0),()=>V(c)),j(v),j(_),j(h),Vi(ad(z(h,2),{}),e=>F(s,e,!0),()=>V(s)),B((e,t)=>{G(x,e),G(C,t)},[()=>Y(`context.orientation_title`),()=>Y(`context.orientation_intro`)]),W(e,m),Je()}async function Fg(){return fetch(`/api/config`).then(e=>e.json())}async function Ig(){return fetch(`/api/documents`).then(e=>e.json())}async function Lg(e){return fetch(`/api/browse/alldirs?path=${encodeURIComponent(e)}`).then(e=>e.json())}async function Rg(e){let t=await fetch(`/api/documents/${e}`);if(!t.ok)throw Error(t.statusText);return t.json()}async function zg(){try{let e=await fetch(`/api/annotations`).then(e=>e.json()),t={};for(let[n,r]of Object.entries(e||{})){t[n]=r;try{t[encodeURIComponent(n)]=r}catch{}}return t}catch{return{}}}async function Bg(){try{return await fetch(`/api/documents/file-counts`).then(e=>e.json())}catch{return{}}}async function Vg(){try{return await fetch(`/api/documents/statuses`).then(e=>e.json())}catch{return{}}}async function Hg(e){return fetch(`/api/documents/search?q=${encodeURIComponent(e)}`).then(e=>e.json())}function Ug(e){return((e.filename||``).split(`/`).pop()??``).match(/^(\d{4}_\d{2}_\d{2}(?:_\d{2}_\d{2})?)/)?.[1]??``}function Wg(e){return e===`alphabetical`?(e,t)=>(e.title||e.filename||``).localeCompare(t.title||t.filename||``):(t,n)=>{let r=Ug(t),i=Ug(n);return r&&i?e===`oldest`?r.localeCompare(i):i.localeCompare(r):r?-1:i?1:(t.filename||``).localeCompare(n.filename||``)}}function Gg(e,t){for(let n of Object.values(e.categories))n.sort(t);for(let n of Object.values(e.children))Gg(n,t)}function Kg(e,t,n,r=`recent`){let i={categories:{},children:{}};for(let t of e){let e=i;for(let n of t.folder||[])e.children[n]||(e.children[n]={categories:{},children:{}}),e=e.children[n];e.categories[t.category]||(e.categories[t.category]=[]),e.categories[t.category].push(t)}if(n)for(let e of t){let t=e.split(`/`).filter(Boolean),n=i;for(let e of t)n.children[e]||(n.children[e]={categories:{},children:{}}),n=n.children[e]}return Gg(i,Wg(r)),i}function qg(e){let t=Object.values(e.categories).reduce((e,t)=>e+t.length,0);for(let n of Object.values(e.children))t+=qg(n);return t}function Jg(e,t){let n=0;for(let r of Object.values(e.categories))for(let e of r)t[e.id]>0&&(n+=1);for(let r of Object.values(e.children))n+=Jg(r,t);return n}function Yg(e,t){let n=0;for(let r of Object.values(e.categories))for(let e of r)t[e.id]>0&&(n+=1);for(let r of Object.values(e.children))n+=Yg(r,t);return n}function Xg(e){return e.replace(/^\d+_/,``).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Zg(e){return Object.keys(e.children).sort((e,t)=>e.localeCompare(t))}function Qg(e){return Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t))}function $g(e,t=`recent`){return Object.values(e.categories).flat().sort(Wg(t))}var e_=U(`<span class="inline-flex items-center justify-center w-5 h-5 rounded-full bg-green-500 text-[10px] font-bold text-white border border-green-600 shadow-sm">V</span>`),t_=U(`<span class="inline-flex items-center justify-center w-5 h-5 rounded-full bg-orange-500 text-[10px] font-bold text-white border border-orange-600 shadow-sm">S</span>`),n_=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-yellow-300 dark:bg-yellow-400 text-[10px] font-bold text-yellow-900 border border-yellow-500 shadow-sm"> </span>`),r_=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-sky-200 dark:bg-sky-300 text-[10px] font-bold text-sky-900 border border-sky-500 shadow-sm"> </span>`),i_=U(`<div class="text-xs text-gray-400 dark:text-gray-500 mt-0.5"> </div>`),a_=U(`<button><div class="leading-snug flex items-center justify-between gap-2"><span class="truncate"> </span> <span class="flex items-center gap-1 shrink-0"><!> <!> <!></span></div> <!></button>`),o_=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-orange-400 dark:bg-orange-500 text-[10px] font-bold text-white border border-orange-600 shadow-sm"> </span>`),s_=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-slate-400 dark:bg-slate-500 text-[10px] font-bold text-white border border-slate-600 shadow-sm"> </span>`),c_=U(`<div class="pl-2"></div>`),l_=U(`<div class="mb-0.5"><button class="w-full flex items-center justify-between px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider hover:bg-gray-50 dark:hover:bg-gray-800/60 rounded-md transition-colors"><span class="flex items-center gap-2"><span> </span> <!> <!></span> <span class="flex items-center gap-1.5"><span class="font-normal normal-case text-gray-400"> </span> <span>▸</span></span></button> <!></div>`),u_=U(`<div class="pl-3"><!></div>`),d_=U(`<div class="mb-1"><button class="w-full flex items-center justify-between px-3 py-1.5 text-xs font-semibold text-violet-600 dark:text-violet-400 uppercase tracking-wider hover:bg-gray-50 dark:hover:bg-gray-800/60 rounded-md transition-colors"><span class="flex items-center gap-2 min-w-0"><span class="truncate"> </span> <!> <!></span> <span class="flex items-center gap-1.5"><span class="font-normal normal-case text-gray-400"> </span> <span>▸</span></span></button> <!></div>`),f_=U(`<!> <!>`,1),p_=U(`<!> <!> <!>`,1);function m_(e,t){qe(t,!0);let n=(e,n=f)=>{let r=N(()=>X.annotationCounts[n().id]||0),i=N(()=>X.fileAttachmentCounts[n().id]||0),a=N(()=>c(n()));var o=a_(),l=L(o),u=L(l),d=L(u,!0);j(u);var p=z(u,2),m=L(p),h=e=>{var t=e_();B(e=>J(t,`title`,e),[()=>Y(`sidebar.status_to_validate`)]),W(e,t)},g=e=>{var t=t_();B(e=>J(t,`title`,e),[()=>Y(`sidebar.status_superseeded`)]),W(e,t)};K(m,e=>{V(a)===`V`?e(h):V(a)===`S`&&e(g,1)});var _=z(m,2),v=e=>{var t=n_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(r))},[()=>s(V(r),`sidebar.annotation_badge`)]),W(e,t)};K(_,e=>{V(r)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=r_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(i))},[()=>s(V(i),`sidebar.file_attachment_badge`)]),W(e,t)};K(y,e=>{V(i)>0&&!X.hideAttachments&&e(b)}),j(p),j(l);var x=z(l,2),S=e=>{var t=i_(),r=L(t,!0);j(t),B(()=>G(r,n().formattedDate)),W(e,t)};K(x,e=>{n().formattedDate&&e(S)}),j(o),B(()=>{J(o,`id`,`item-${n().id??``}`),gi(o,1,`doc-item w-full text-left px-3 py-1.5 rounded-md text-sm transition-colors text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800/60 ${n().id===X.currentDocId?`active`:``}`),G(d,n().title)}),H(`click`,o,()=>t.onopen(n().id)),W(e,o)},r=(e,r=f)=>{let i=N(()=>a(r())),o=N(()=>X.expandedCategories.has(V(i))),c=N(()=>t.node.categories[r()]),l=N(()=>V(c).reduce((e,t)=>e+ +(X.annotationCounts[t.id]>0),0)),u=N(()=>V(c).reduce((e,t)=>e+ +(X.fileAttachmentCounts[t.id]>0),0));var d=l_(),p=L(d),m=L(p),h=L(m),g=L(h,!0);j(h);var _=z(h,2),v=e=>{var t=o_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(l))},[()=>s(V(l),`sidebar.annotated_docs_badge`)]),W(e,t)};K(_,e=>{V(l)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=s_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(u))},[()=>s(V(u),`sidebar.file_attached_docs_badge`)]),W(e,t)};K(y,e=>{V(u)>0&&!X.hideAttachments&&e(b)}),j(m);var x=z(m,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2);j(x),j(p);var T=z(p,2),E=e=>{var t=c_();q(t,21,()=>V(c),e=>e.id,(e,t)=>{n(e,()=>V(t))}),j(t),W(e,t)};K(T,e=>{V(o)&&e(E)}),j(d),B(()=>{G(g,r()),G(C,V(c).length),gi(w,1,`transition-transform duration-200 ${V(o)?`rotate-90`:``}`)}),H(`click`,p,()=>X.toggleCategory(V(i))),W(e,d)},i=(e,n=f)=>{let r=N(()=>o(n())),i=N(()=>X.expandedFolders.has(V(r))),a=N(()=>t.node.children[n()]),c=N(()=>qg(V(a))),l=N(()=>Jg(V(a),X.annotationCounts)),u=N(()=>Yg(V(a),X.fileAttachmentCounts));var d=d_(),p=L(d),m=L(p),h=L(m),g=L(h);j(h);var _=z(h,2),v=e=>{var t=o_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(l))},[()=>s(V(l),`sidebar.annotated_docs_badge`)]),W(e,t)};K(_,e=>{V(l)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=s_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(u))},[()=>s(V(u),`sidebar.file_attached_docs_badge`)]),W(e,t)};K(y,e=>{V(u)>0&&!X.hideAttachments&&e(b)}),j(m);var x=z(m,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2);j(x),j(p);var T=z(p,2),E=e=>{var r=u_(),i=L(r);{let e=N(()=>[...t.folderPath,n()]);m_(i,{get node(){return V(a)},get folderPath(){return V(e)},get onopen(){return t.onopen}})}j(r),W(e,r)};K(T,e=>{V(i)&&e(E)}),j(d),B(e=>{J(h,`title`,n()),G(g,`📁 ${e??``}`),G(C,V(c)),gi(w,1,`transition-transform duration-200 ${V(i)?`rotate-90`:``}`)},[()=>Xg(n())]),H(`click`,p,()=>X.toggleFolder(V(r))),W(e,d)};function a(e){return[...t.folderPath,e].join(`|`)}function o(e){return[...t.folderPath,e].join(`|`)}function s(e,t){return`${e} ${Y(t)}${e>1?`s`:``}`}function c(e){if(!X.highlightStatusState)return null;let t=String(X.docStatuses[e.id]||``).trim().toLowerCase();return t===`to be validated`?`V`:X.highlightStatusState===2&&t===`superseeded`?`S`:null}var l=Wr(),u=R(l),d=e=>{var r=f_(),a=R(r);q(a,17,()=>$g(t.node,X.sidebarSort),e=>e.id,(e,t)=>{n(e,()=>V(t))}),q(z(a,2),16,()=>Zg(t.node),e=>e,(e,t)=>{i(e,()=>t)}),W(e,r)},p=e=>{var n=p_(),a=R(n),o=e=>{r(e,()=>`General`)};K(a,e=>{t.node.categories.General&&e(o)});var s=z(a,2);q(s,16,()=>Zg(t.node),e=>e,(e,t)=>{i(e,()=>t)}),q(z(s,2),16,()=>Qg(t.node),e=>e,(e,t)=>{r(e,()=>t)}),W(e,n)};K(u,e=>{X.hideCategories?e(d):e(p,-1)}),W(e,l),Je()}Pr([`click`]);var h_=U(`<p class="px-4 py-8 text-sm text-gray-400 text-center"> </p>`),g_=U(`<aside><div class="sticky top-0 z-10 bg-white dark:bg-gray-900 p-3 border-b border-gray-100 dark:border-gray-800"><div class="relative sm:hidden"><input type="search" class="w-full pl-8 pr-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"/> <span class="absolute left-2.5 top-2 text-gray-400 text-sm pointer-events-none">🔍</span></div> <div class="flex items-center justify-between mt-2 sm:mt-0"><p class="text-xs text-gray-400 dark:text-gray-500"> </p> <div class="flex items-center gap-2"><button><i class="fa-solid fa-certificate"></i></button> <button><i class="fa-solid fa-paperclip"></i></button> <button><i class="fa-solid fa-tags"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-file-export"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-folder-plus"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-file-circle-plus"></i></button></div></div></div> <nav data-testid="category-tree" class="flex-1 py-2 space-y-0.5"><!></nav> <div aria-hidden="true"></div></aside>`);function __(e,t){qe(t,!0);let n=N(()=>Kg(X.filteredDocs,X.allFolderPaths,!X.searchQuery,X.sidebarSort)),r=N(()=>X.filteredDocs.length),i=N(()=>X.filteredDocs.length===0&&X.allFolderPaths.length===0),a=`ld-sidebar-w`,o=P(null),s=P(!1),c=P(null);kn(()=>{let e=parseInt(localStorage.getItem(a)||``,10);Number.isFinite(e)&&F(o,Math.max(200,Math.min(600,e)),!0)});function l(e){e.preventDefault();let t=e.clientX,n=V(c).getBoundingClientRect().width;F(s,!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let r=e=>{F(o,Math.max(200,Math.min(600,n+e.clientX-t)),!0)},i=()=>{if(document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),document.body.style.cursor=``,document.body.style.userSelect=``,F(s,!1),V(o)!=null)try{localStorage.setItem(a,String(V(o)))}catch{}};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)}var u=g_(),d=L(u),f=L(d),p=L(f);Di(p),Ie(2),j(f);var m=z(f,2),h=L(m),g=L(h);j(h);var _=z(h,2),v=L(_),y=z(v,2),b=z(y,2),x=z(b,2),S=z(x,2),C=z(S,2);j(_),j(m),j(d);var w=z(d,2),T=L(w),E=e=>{var t=h_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`sidebar.no_docs`)]),W(e,t)},D=e=>{m_(e,{get node(){return V(n)},folderPath:[],get onopen(){return t.onopen}})};K(T,e=>{V(i)?e(E):e(D,-1)}),j(w);var ee=z(w,2);j(u),Vi(u,e=>F(c,e),()=>V(c)),B((e,t,n,i,a,c,l)=>{gi(u,1,`no-print ${V(o)==null?`w-72`:``} shrink-0 flex flex-col border-r border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 overflow-y-auto relative`),vi(u,V(o)==null?``:`width:${V(o)}px`),J(p,`placeholder`,e),Oi(p,X.searchQuery),G(g,`${V(r)??``} document${V(r)===1?``:`s`}`),J(v,`title`,t),gi(v,1,`hover:opacity-80 transition-colors leading-none ${X.highlightStatusState===0?`text-gray-400 dark:text-gray-500`:X.highlightStatusState===1?`text-green-500 dark:text-green-400`:`text-orange-500 dark:text-orange-400`}`),J(y,`title`,n),gi(y,1,`transition-colors leading-none ${X.hideAttachments?`text-gray-400 dark:text-gray-500`:`text-blue-500 dark:text-blue-400`}`),J(b,`title`,i),gi(b,1,`transition-colors leading-none ${X.hideCategories?`text-gray-400 dark:text-gray-500`:`text-blue-500 dark:text-blue-400`}`),J(x,`title`,a),J(S,`title`,c),J(C,`title`,l),gi(ee,1,`absolute top-0 right-[-2px] w-1.5 h-full cursor-col-resize z-20 select-none transition-colors ${V(s)?`bg-blue-500/55`:`hover:bg-blue-500/35`}`)},[()=>Y(`nav.search_mobile_placeholder`),()=>Y(`nav.toggle_status_highlight`),()=>Y(`nav.toggle_attachments`),()=>Y(`nav.toggle_categories`),()=>Y(`nav.export`),()=>Y(`nav.new_folder`),()=>Y(`nav.new_document`)]),H(`input`,p,e=>t.onsearch(e.target.value)),H(`click`,v,()=>X.cycleHighlightStatus()),H(`click`,y,()=>X.toggleHideAttachments()),H(`click`,b,()=>X.toggleHideCategories()),H(`click`,x,function(...e){t.onexport?.apply(this,e)}),H(`click`,S,function(...e){t.onnewfolder?.apply(this,e)}),H(`click`,C,function(...e){t.onnewdoc?.apply(this,e)}),H(`mousedown`,ee,l),W(e,u),Je()}Pr([`input`,`click`,`mousedown`]);var v_=`background:rgba(250,204,21,0.5);border-radius:2px;cursor:pointer;padding:0 1px;`;function y_(e,t,n){e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{let t=e.parentNode;t&&(t.replaceChild(document.createTextNode(e.textContent||``),e),t.normalize())});for(let n of t)x_(e,n);e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{(e.textContent||``).trim()||e.remove()}),n&&b_(e,!1)}function b_(e,t){e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{let n=e;n.style.background=t?`rgba(250,204,21,0.5)`:`transparent`,n.style.cursor=t?`pointer`:`default`,n.style.pointerEvents=t?`auto`:`none`})}function x_(e,t){let n=(t.selectedText||``).replace(/\s+/g,` `).trim(),r=(t.contextBefore||``).replace(/\s+/g,` `).trim(),i=(t.contextAfter||``).replace(/\s+/g,` `).trim();if(!n)return;let a=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),o=e=>e.split(/\s+/).filter(Boolean).map(a).join(`\\s+`),s=e.textContent||``,c=o(n),l=null;if(r||i){let e=(r?`${o(r)}\\s*`:``)+`(`+c+`)`+(i?`\\s*${o(i)}`:``);try{l=new RegExp(e,`d`).exec(s)}catch{}}if(!l)try{l=RegExp(`(${c})`,`d`).exec(s)}catch{return}let u=l&&l.indices;if(!l||!u?.[1])return;let[d,f]=u[1],p=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),m=[],h=0;for(;p.nextNode();){let e=p.currentNode,t=e.nodeValue?.length,n=h,r=h+t;if(h=r,r<=d)continue;if(n>=f)break;let i=Math.max(0,d-n),a=Math.min(t,f-n);i<a&&m.push({node:e,start:i,end:a})}for(let{node:e,start:n,end:r}of m){let i=e;n>0&&n<i.nodeValue?.length&&(i=i.splitText(n));let a=r-n;a>0&&a<i.nodeValue?.length&&i.splitText(a);let o=document.createElement(`mark`);o.setAttribute(`data-annotation-id`,t.id),o.setAttribute(`style`,v_),i.parentNode?.insertBefore(o,i),o.appendChild(i)}}var S_=U(`<div class="fixed z-50 w-80 bg-yellow-50 dark:bg-yellow-900/80 border-2 border-yellow-300 dark:border-yellow-600 rounded-xl shadow-2xl p-4 flex flex-col gap-3"><div class="text-xs font-semibold text-yellow-700 dark:text-yellow-300 flex items-center gap-2"><span>✎</span><span> </span></div> <div class="text-xs text-yellow-800 dark:text-yellow-200 bg-yellow-100 dark:bg-yellow-800/50 rounded px-2 py-1 italic max-h-16 overflow-y-auto border border-yellow-200 dark:border-yellow-700"> </div> <textarea rows="4" class="w-full text-sm rounded-lg border border-yellow-300 dark:border-yellow-600 bg-white dark:bg-yellow-950 text-gray-900 dark:text-gray-100 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-yellow-400 resize-none"></textarea> <div class="flex justify-end gap-2"><button class="text-sm px-3 py-1.5 rounded-lg border border-yellow-300 dark:border-yellow-600 text-yellow-700 dark:text-yellow-300 hover:bg-yellow-100 dark:hover:bg-yellow-800 transition-colors"> </button> <button class="text-sm px-4 py-1.5 rounded-lg bg-yellow-400 hover:bg-yellow-500 dark:bg-yellow-600 dark:hover:bg-yellow-500 text-yellow-900 dark:text-white font-semibold transition-colors"> </button></div></div>`),C_=U(`<div class="text-xs font-semibold text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-700 rounded px-2 py-1"> </div>`),w_=U(`<div class="fixed z-50 w-80 bg-yellow-50 dark:bg-yellow-900/80 border-2 border-yellow-300 dark:border-yellow-600 rounded-xl shadow-2xl p-4 flex flex-col gap-2"><div class="text-xs font-semibold text-yellow-700 dark:text-yellow-300 flex items-center gap-2"><span>✎</span><span class="font-normal text-yellow-600 dark:text-yellow-400"> </span></div> <!> <div class="text-sm text-gray-800 dark:text-gray-100 whitespace-pre-wrap max-h-48 overflow-y-auto"> </div> <div class="flex justify-end pt-1 border-t border-yellow-200 dark:border-yellow-700"><button class="text-xs px-3 py-1.5 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors flex items-center gap-1"> </button></div></div>`),T_=U(`<div class="fixed z-50 w-72 bg-white dark:bg-gray-900 border border-red-200 dark:border-red-700 rounded-xl shadow-2xl p-4 flex flex-col gap-3"><p class="text-sm text-gray-700 dark:text-gray-200"> </p> <div class="flex justify-end gap-2"><button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-1.5 rounded-lg bg-red-500 hover:bg-red-600 text-white font-semibold transition-colors"> </button></div></div>`),E_=U(`<button> </button>`),D_=U(`<div class="fixed top-14 right-0 w-10 flex flex-col items-center py-2 gap-2 z-40 overflow-y-auto" style="max-height: calc(100vh - 3.5rem)"></div>`),O_=U(`<!> <!> <!> <!>`,1);function k_(e,t){qe(t,!0);let n=P(I([])),r=P(null),i=P(``),a=P(null),o=P(null),s=P(I([])),c=null;Gi(()=>{let e=document.getElementById(`home-content-area`);if(!e)return;let t=()=>{c&&clearTimeout(c),F(a,null)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)});function l(e,t,n=320,r=260){let i=window.innerWidth,a=window.innerHeight,o=e;return o+n>i-16&&(o=i-n-16),o<8&&(o=8),{x:o,y:Math.min(t,a-r)}}async function u(e){F(n,[],!0);try{F(n,await fetch(`/api/annotations/`+encodeURIComponent(e)).then(e=>e.json()),!0)}catch{F(n,[],!0)}d()}function d(){t.contentEl&&(y_(t.contentEl,V(n),X.markerHidden),f())}kn(()=>{t.contentEl&&b_(t.contentEl,!X.markerHidden)});function f(){if(!t.contentEl){F(s,[],!0);return}F(s,V(n).map(e=>({id:e.id,note:e.note.length>60?e.note.slice(0,60)+`…`:e.note,orphan:!t.contentEl.querySelector(`mark[data-annotation-id="${e.id}"]`)})),!0)}function p(){if(!X.markerActive||V(r)||!t.contentEl)return;let e=window.getSelection();if(!e||e.isCollapsed||!e.toString().trim()||!t.contentEl.contains(e.anchorNode))return;let n=e.getRangeAt(0),a=document.createRange();a.selectNodeContents(t.contentEl),a.setEnd(n.startContainer,n.startOffset);let o=a.toString().length,s=n.toString(),c=t.contentEl.textContent||``,u=e=>e.replace(/\s+/g,` `).trim(),d=u(s),f=u(c.slice(Math.max(0,o-30),o)),p=u(c.slice(o+s.length,o+s.length+30)),m=n.getBoundingClientRect(),h=l(m.left,m.bottom+8);F(r,{x:h.x,y:h.y,preview:d.length>120?d.slice(0,120)+`…`:d,selectedText:d,contextBefore:f,contextAfter:p},!0),F(i,``)}function m(){F(r,null),window.getSelection()?.removeAllRanges()}async function h(){if(!V(r)||!t.docId)return;let e=V(i).trim();if(e)try{let i=await fetch(`/api/annotations/`+encodeURIComponent(t.docId),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({selectedText:V(r).selectedText,contextBefore:V(r).contextBefore,contextAfter:V(r).contextAfter,note:e})}).then(e=>e.json());F(n,[...V(n),i],!0),m(),d(),X.annotationCounts={...X.annotationCounts,[t.docId]:(X.annotationCounts[t.docId]||0)+1}}catch{}}kn(()=>{if(!t.contentEl)return;let e=t.contentEl,r=e=>{let t=e.target.closest(`mark[data-annotation-id]`);if(!t)return;let r=V(n).find(e=>e.id===t.dataset.annotationId);r&&g(r,t)},i=e=>{let t=e;t.target.closest(`mark[data-annotation-id]`)&&(t.relatedTarget&&t.relatedTarget.closest?.(`mark[data-annotation-id]`)||_())};return e.addEventListener(`mouseover`,r),e.addEventListener(`mouseout`,i),()=>{e.removeEventListener(`mouseover`,r),e.removeEventListener(`mouseout`,i)}});function g(e,n){c&&clearTimeout(c);let r=!t.contentEl?.querySelector(`mark[data-annotation-id="${e.id}"]`),i=n.getBoundingClientRect(),o=l(i.left,i.bottom+8);F(a,{ann:e,x:o.x,y:o.y,orphan:r},!0)}function _(){c=window.setTimeout(()=>{F(a,null)},1500)}function v(){V(a)&&(F(o,{id:V(a).ann.id,x:V(a).x,y:V(a).y},!0),F(a,null))}async function y(){if(!V(o)||!t.docId)return;let e=V(o).id;try{await fetch(`/api/annotations/${encodeURIComponent(t.docId)}/${e}`,{method:`DELETE`}),F(n,V(n).filter(t=>t.id!==e),!0),F(o,null),d();let r=(X.annotationCounts[t.docId]||0)-1,i={...X.annotationCounts};r<=0?delete i[t.docId]:i[t.docId]=r,X.annotationCounts=i}catch{}}function b(e,t){return e.getBoundingClientRect().top+t.scrollTop-t.getBoundingClientRect().top}function x(e,t){let n=e.parentElement;for(;n&&n!==t;)n.tagName===`DETAILS`&&(n.open=!0),n=n.parentElement}function S(e,r){let i=t.contentEl?.querySelector(`mark[data-annotation-id="${e}"]`),o=document.getElementById(`home-content-area`);if(i&&o){if(V(a)?.ann.id===e){c&&clearTimeout(c);return}x(i,o),o.scrollTo({top:b(i,o)-o.clientHeight/2,behavior:`smooth`})}else{let t=V(n).find(t=>t.id===e);t&&g(t,r.currentTarget)}}function C(e,r){c&&clearTimeout(c);let i=V(n).find(t=>t.id===e);if(!i)return;let a=t.contentEl?.querySelector(`mark[data-annotation-id="${e}"]`),o=document.getElementById(`home-content-area`);if(!a||!o){g(i,r.currentTarget);return}x(a,o),o.scrollTo({top:b(a,o)-o.clientHeight/2,behavior:`smooth`});let s,l=()=>{clearTimeout(s),s=window.setTimeout(()=>{o.removeEventListener(`scroll`,l),g(i,a)},80)};o.addEventListener(`scroll`,l),s=window.setTimeout(()=>{o.removeEventListener(`scroll`,l),g(i,a)},600)}function w(e){let t=V(a)?.ann.id===e.id;return e.orphan?t?`#b91c1c`:`#ef4444`:t?`#f97316`:`#facc15`}function T(e){return new Date(e).toLocaleDateString(`fr-FR`,{day:`2-digit`,month:`short`,year:`numeric`})}var E={load:u,apply:d},D=O_();Nr(`mouseup`,on,p);var ee=R(D),te=e=>{var t=S_(),n=L(t),a=z(L(n)),o=L(a,!0);j(a),j(n);var s=z(n,2),c=L(s,!0);j(s);var l=z(s,2);yn(l),vn(l,!0);var u=z(l,2),d=L(u),f=L(d,!0);j(d);var p=z(d,2),g=L(p,!0);j(p),j(u),j(t),B((e,n,i,a)=>{vi(t,`left:${V(r).x??``}px;top:${V(r).y??``}px`),G(o,e),G(c,V(r).preview),J(l,`placeholder`,n),G(f,i),G(g,a)},[()=>Y(`annotation.title`),()=>Y(`annotation.placeholder`),()=>Y(`common.cancel`),()=>Y(`annotation.save_btn`)]),Ni(l,()=>V(i),e=>F(i,e)),H(`click`,d,m),H(`click`,p,h),W(e,t)};K(ee,e=>{V(r)&&e(te)});var O=z(ee,2),ne=e=>{var t=w_(),n=L(t),r=z(L(n)),i=L(r,!0);j(r),j(n);var o=z(n,2),s=e=>{var t=C_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`annotation.orphan`)]),W(e,t)};K(o,e=>{V(a).orphan&&e(s)});var l=z(o,2),u=L(l,!0);j(l);var d=z(l,2),f=L(d),p=L(f,!0);j(f),j(d),j(t),B((e,n)=>{vi(t,`left:${V(a).x??``}px;top:${V(a).y??``}px`),G(i,e),G(u,V(a).ann.note),G(p,n)},[()=>T(V(a).ann.createdAt),()=>Y(`annotation.delete_btn`)]),Nr(`mouseenter`,t,()=>{c&&clearTimeout(c)}),Nr(`mouseleave`,t,_),H(`click`,f,v),W(e,t)};K(O,e=>{V(a)&&e(ne)});var re=z(O,2),k=e=>{var t=T_(),n=L(t),r=L(n,!0);j(n);var i=z(n,2),a=L(i),s=L(a,!0);j(a);var c=z(a,2),l=L(c,!0);j(c),j(i),j(t),B((e,n,i)=>{vi(t,`left:${V(o).x??``}px;top:${V(o).y??``}px`),G(r,e),G(s,n),G(l,i)},[()=>Y(`annotation.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`annotation.confirm_btn`)]),H(`click`,a,()=>F(o,null)),H(`click`,c,y),W(e,t)};K(re,e=>{V(o)&&e(k)});var ie=z(re,2),ae=e=>{var t=D_();q(t,21,()=>V(s),e=>e.id,(e,t)=>{var n=E_(),r=L(n,!0);j(n),B((e,i)=>{J(n,`title`,e),gi(n,1,`w-8 h-8 rounded border-2 shadow text-xs flex items-center justify-center transition-colors shrink-0 ${V(t).orphan?`border-red-600 text-white`:`border-yellow-500`}`),vi(n,`background:${i??``}`),G(r,V(t).orphan?`⚠`:`✎`)},[()=>V(t).orphan?`${Y(`annotation.orphan`)}\n\n${V(t).note}`:V(t).note,()=>w(V(t))]),H(`click`,n,e=>S(V(t).id,e)),Nr(`mouseenter`,n,e=>C(V(t).id,e)),Nr(`mouseleave`,n,_),W(e,n)}),j(t),W(e,t)};return K(ie,e=>{V(s).length>0&&!X.markerHidden&&e(ae)}),W(e,D),Je(E)}Pr([`click`]);var A_=`#dc2626`,j_=`#eab308`,M_=`#16a34a`;function N_(e){let t=Math.max(0,Math.min(1,e))*100;return t>80?M_:t>=60?j_:t>=40?`#f97316`:A_}function P_(e){let t=Math.max(0,Math.min(1,e))*100;return t>=100?M_:t<30?A_:t<60?`linear-gradient(to right, ${A_} 0%, ${A_} 60%, ${j_} 100%)`:t<80?`linear-gradient(to right, ${A_} 0%, ${j_} 40%, ${j_} 100%)`:`linear-gradient(to right, ${j_} 0%, ${M_} 40%, ${M_} 100%)`}var F_=new class{#e=P(null);get report(){return V(this.#e)}set report(e){F(this.#e,e,!0)}async load(e){if(!e)return this.report=null,null;try{let t=await fetch(`/api/metadata/${encodeURIComponent(e)}`);if(!t.ok)throw Error(t.statusText);this.report=await t.json()}catch{this.report=null}return this.report}async refresh(e){let t=await fetch(`/api/metadata/${encodeURIComponent(e)}/refresh`,{method:`POST`});if(!t.ok)throw Error(t.statusText);this.report=await t.json()}async addPath(e,t){let n=await fetch(`/api/metadata/${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||n.statusText)}this.report=await n.json()}async removePath(e,t){let n=await fetch(`/api/metadata/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!n.ok)throw Error(n.statusText);this.report=await n.json()}},I_=U(`<div data-testid="accuracy-gauge" class="no-print mt-5 flex items-center gap-3 mr-auto w-full sm:w-80 cursor-pointer select-none"><span class="text-xs text-gray-500 dark:text-gray-400 shrink-0"> </span> <div class="flex-1 h-4 rounded-full bg-gray-200 dark:bg-gray-700 overflow-hidden"><div class="h-full w-full transition-all"></div></div> <span data-testid="accuracy-gauge-value" class="text-xs font-semibold shrink-0 tabular-nums"> </span></div>`);function L_(e,t){qe(t,!0);let n=N(()=>F_.report),r=N(()=>V(n)?Math.round(V(n).accuracy*100):0),i=N(()=>V(n)?Y(`accuracy.tooltip`).replace(`{unchanged}`,String(V(n).unchanged)).replace(`{modified}`,String(V(n).modified)).replace(`{missing}`,String(V(n).missing)).replace(`{total}`,String(V(n).total)):``);var a=Wr(),o=R(a),s=e=>{var a=I_(),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c);j(c);var u=z(c,2),d=L(u);j(u),j(a),B((e,t,n)=>{J(a,`title`,V(i)),G(s,e),vi(l,`background:${t??``}`),vi(u,`color:${n??``}`),G(d,`${V(r)??``}%`)},[()=>Y(`accuracy.label`),()=>P_(V(n).accuracy),()=>N_(V(n).accuracy)]),H(`click`,a,function(...e){t.onopen?.apply(this,e)}),W(e,a)};K(o,e=>{V(n)&&V(n).total>0&&e(s)}),W(e,a),Je()}Pr([`click`]);var R_=/^(\s*(?:\*\*status:\*\*|status:)\s*).+?\s*$/im;function z_(e){if(typeof e!=`string`)return null;let t=e.match(/^---\s*\n([\s\S]*?)\n---/);if(!t)return null;let n=t[1].match(/^\s*(?:\*\*status:\*\*|status:)\s*(.+?)\s*$/im);return n?n[1].trim():null}function B_(e,t){return e.replace(R_,`$1${t}`)}function V_(e){return/%5BWORKLOG%5D/i.test(e)}var H_=U(`<div data-testid="metadata-readonly-banner" class="text-xs text-amber-800 dark:text-amber-200 bg-amber-50 dark:bg-amber-900/30 border-l-4 border-amber-500 rounded-r px-3 py-2"> </div>`),U_=U(`<div class="px-3 py-4 text-center text-xs text-gray-400"> </div>`),W_=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300"><i class="fa-solid fa-check"></i> </span>`),G_=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300"><i class="fa-solid fa-triangle-exclamation"></i> </span>`),K_=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300"><i class="fa-solid fa-circle-xmark"></i> </span>`),q_=U(`<button class="metadata-row-remove text-xs px-2 py-1 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors"><i class="fa-solid fa-trash"></i></button>`),J_=U(`<div class="flex items-center gap-2 px-3 py-2 border-b border-gray-100 dark:border-gray-800"><div class="flex-1 min-w-0"><div class="text-sm font-mono truncate text-gray-800 dark:text-gray-200"> </div></div> <!> <!></div>`),Y_=U(`<div class="flex items-center gap-2 flex-wrap"><button data-testid="metadata-add-btn" class="text-sm px-3 py-1.5 rounded-lg border border-blue-200 dark:border-blue-700 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 transition-colors"><i class="fa-solid fa-plus"></i> </button> <button data-testid="metadata-refresh-btn" class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><i class="fa-solid fa-arrows-rotate"></i> </button></div>`),X_=U(`<div class="px-3 py-2 text-xs text-gray-400"> </div>`),Z_=U(`<div class="px-3 py-2 text-xs text-red-500"> </div>`),Q_=U(`<button class="w-full text-left px-3 py-1.5 text-sm hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center gap-2"><i class="fa-solid fa-folder text-yellow-500"></i> <span class="truncate"> </span></button>`),$_=U(`<button class="w-full text-left px-3 py-1.5 text-sm hover:bg-blue-50 dark:hover:bg-blue-900/30 flex items-center gap-2"><i class="fa-solid fa-file text-gray-400"></i> <span class="truncate"> </span> <i class="fa-solid fa-plus ml-auto text-blue-500 text-xs"></i></button>`),ev=U(`<!> <!>`,1),tv=U(`<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden text-sm"><div class="flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"><button class="text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-30 disabled:pointer-events-none shrink-0"> </button> <span class="text-xs text-gray-500 dark:text-gray-400 font-mono truncate flex-1"> </span></div> <div class="max-h-56 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800"><!></div></div>`),nv=U(`<p class="text-xs text-red-500"> </p>`),rv=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div data-testid="metadata-modal" class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-2xl mx-4 p-6 space-y-4"><div class="flex items-start justify-between gap-4"><div><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-code-compare mr-1"></i> </h3> <p class="text-xs text-gray-500 dark:text-gray-400 mt-1"> </p></div> <button class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-colors"><i class="fa-solid fa-xmark text-lg"></i></button></div> <div class="text-xs text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-800 rounded-lg px-3 py-2"></div> <!> <div data-testid="metadata-list" class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden"><div class="max-h-64 overflow-y-auto"><!></div></div> <!> <!> <!> <div class="flex justify-end"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button></div></div></div>`);function iv(e,t){qe(t,!0);let n=N(()=>F_.report),r=N(()=>z_(t.content)===`SuperSeeded`),i=P(``),a=P(!1),o=P(!1),s=P(``),c=P(null),l=P(I([])),u=P(I([])),d=P(!1),f=P(``);kn(()=>{t.open||(F(o,!1),F(s,``),F(i,``))});function p(e){F(i,Y(`common.error_prefix`)+e),setTimeout(()=>{F(i,``)},5e3)}function m(){return!V(n)||V(n).total===0?``:`<span class="font-semibold">${Math.round(V(n).accuracy*100)}%</span> · ${V(n).unchanged}/${V(n).total} ${Y(`metadata.status.unchanged`)} · ${V(n).modified} ${Y(`metadata.status.modified`)} · ${V(n).missing} ${Y(`metadata.status.missing`)}`}async function h(){F(a,!0);try{await F_.refresh(t.docId)}catch(e){p(e instanceof Error?e.message:String(e))}finally{F(a,!1)}}async function g(e){try{await F_.removePath(t.docId,e),V(o)&&y(V(s))}catch(e){p(e instanceof Error?e.message:String(e))}}async function _(e){try{await F_.addPath(t.docId,e),V(o)&&y(V(s))}catch(e){p(e instanceof Error?e.message:String(e))}}function v(){F(o,!V(o)),V(o)&&y(``)}async function y(e){F(d,!0),F(f,``);try{let t=await fetch(`/api/browse-source?path=`+encodeURIComponent(e||``));if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||t.statusText)}let r=await t.json();F(s,r.current||``,!0),F(c,r.parent,!0),F(l,r.dirs||[],!0);let i=new Set((V(n)?.items||[]).map(e=>e.path));F(u,(r.files||[]).filter(e=>!i.has(e.path)),!0)}catch(e){F(f,e instanceof Error?e.message:String(e),!0)}finally{F(d,!1)}}function b(){V(c)!==null&&y(V(c))}var x=Wr(),S=R(x),C=e=>{var p=rv(),x=L(p),S=L(x),C=L(S),w=L(C),T=z(L(w));j(w);var E=z(w,2),D=L(E,!0);j(E),j(C);var ee=z(C,2);j(S);var te=z(S,2);ai(te,m,!0),j(te);var O=z(te,2),ne=e=>{var t=H_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`metadata.readonly_banner`)]),W(e,t)};K(O,e=>{V(r)&&e(ne)});var re=z(O,2),k=L(re),ie=L(k),ae=e=>{var t=U_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`metadata.empty`)]),W(e,t)},oe=e=>{var t=Wr();q(R(t),17,()=>V(n).items,e=>e.path,(e,t)=>{var n=J_(),i=L(n),a=L(i),o=L(a,!0);j(a),j(i);var s=z(i,2),c=e=>{var t=W_(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.unchanged`)]),W(e,t)},l=e=>{var t=G_(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.modified`)]),W(e,t)},u=e=>{var t=K_(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.missing`)]),W(e,t)};K(s,e=>{V(t).status===`unchanged`?e(c):V(t).status===`modified`?e(l,1):e(u,-1)});var d=z(s,2),f=e=>{var n=q_();B(e=>J(n,`title`,e),[()=>Y(`metadata.remove`)]),H(`click`,n,()=>g(V(t).path)),W(e,n)};K(d,e=>{V(r)||e(f)}),j(n),B(()=>{J(a,`title`,V(t).path),G(o,V(t).path)}),W(e,n)}),W(e,t)};K(ie,e=>{!V(n)||V(n).items.length===0?e(ae):e(oe,-1)}),j(k),j(re);var se=z(re,2),ce=e=>{var t=Y_(),n=L(t),r=z(L(n));j(n);var i=z(n,2),o=z(L(i));j(i),j(t),B((e,t)=>{G(r,` ${e??``}`),i.disabled=V(a),G(o,` ${t??``}`)},[()=>Y(`metadata.add`),()=>Y(`metadata.refresh`)]),H(`click`,n,v),H(`click`,i,h),W(e,t)};K(se,e=>{V(r)||e(ce)});var le=z(se,2),ue=e=>{var t=tv(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n);var p=z(n,2),m=L(p),h=e=>{var t=X_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},g=e=>{var t=Z_(),n=L(t,!0);j(t),B(()=>G(n,V(f))),W(e,t)},v=e=>{var t=X_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.empty_dir`)]),W(e,t)},x=e=>{var t=ev(),n=R(t);q(n,17,()=>V(l),e=>e.path,(e,t)=>{var n=Q_(),r=z(L(n),2),i=L(r,!0);j(r),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>y(V(t).path)),W(e,n)}),q(z(n,2),17,()=>V(u),e=>e.path,(e,t)=>{var n=$_(),r=z(L(n),2),i=L(r,!0);j(r),Ie(2),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>_(V(t).path)),W(e,n)}),W(e,t)};K(m,e=>{V(d)?e(h):V(f)?e(g,1):V(l).length===0&&V(u).length===0?e(v,2):e(x,-1)}),j(p),j(t),B(e=>{r.disabled=V(c)===null,G(i,e),G(o,V(s)?`/`+V(s):`/ (sourceRoot)`)},[()=>Y(`common.up`)]),H(`click`,r,b),W(e,t)};K(le,e=>{V(o)&&e(ue)});var de=z(le,2),fe=e=>{var t=nv(),n=L(t,!0);j(t),B(()=>G(n,V(i))),W(e,t)};K(de,e=>{V(i)&&e(fe)});var pe=z(de,2),me=L(pe),he=L(me,!0);j(me),j(pe),j(x),j(p),B((e,t,n,r)=>{G(T,` ${e??``}`),G(D,t),J(ee,`title`,n),G(he,r)},[()=>Y(`metadata.title`),()=>Y(`metadata.subtitle`),()=>Y(`common.close`),()=>Y(`common.close`)]),H(`click`,p,e=>{e.target===e.currentTarget&&t.onclose()}),H(`click`,ee,function(...e){t.onclose?.apply(this,e)}),H(`click`,me,function(...e){t.onclose?.apply(this,e)}),W(e,p)};K(S,e=>{t.open&&e(C)}),W(e,x),Je()}Pr([`click`]);var av=U(`<div class="text-xs font-medium text-amber-700 dark:text-amber-300"> </div>`),ov=U(`<div> </div>`),sv=U(`<button type="button"><div class="flex items-center gap-2 font-semibold text-gray-800 dark:text-gray-100"><span class="font-mono text-blue-600 dark:text-blue-400"> </span> <span class="truncate"> </span></div> <div class="mt-1 text-gray-500 dark:text-gray-400"> </div></button>`),cv=U(`<div class="mt-3 flex gap-2 overflow-x-auto pb-1"></div>`),lv=U(`<p class="mt-3 text-sm text-gray-500 dark:text-gray-400"> </p>`),uv=U(`<div class="flex h-full items-center justify-center text-sm text-gray-500 dark:text-gray-400"> </div>`),dv=U(`<div class="m-5 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-950/30 dark:text-red-300"> </div>`),fv=U(`<div class="mx-5 mt-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-200"> </div>`),pv=U(`<button type="button" class="mt-0.5 inline-flex h-7 w-8 items-center justify-center rounded-md border border-blue-200 bg-white font-mono text-sm font-bold text-blue-600 transition-colors hover:bg-blue-50 disabled:cursor-wait disabled:opacity-50 dark:border-blue-800 dark:bg-gray-950 dark:text-blue-300 dark:hover:bg-blue-950/40"> </button>`),mv=U(`<div><span> </span> <pre class="m-0 whitespace-pre-wrap break-words px-2 py-0.5 font-mono"> </pre></div> <div class="flex items-start justify-center border-r border-gray-200 bg-gray-50 px-1 py-0.5 dark:border-gray-800 dark:bg-gray-900/70"><!></div> <div><span> </span> <pre class="m-0 whitespace-pre-wrap break-words px-2 py-0.5 font-mono"> </pre></div>`,1),hv=U(`<!> <div class="h-full overflow-auto p-5"><div class="grid min-w-[980px] grid-cols-[minmax(0,1fr)_3.25rem_minmax(0,1fr)] overflow-hidden rounded-lg border border-gray-200 text-xs dark:border-gray-800"><div class="border-b border-r border-gray-200 bg-gray-100 px-3 py-2 font-semibold text-gray-700 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-200"> </div> <div class="border-b border-r border-gray-200 bg-gray-100 px-2 py-2 text-center font-semibold text-gray-400 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-500"></div> <div class="border-b border-gray-200 bg-gray-100 px-3 py-2 font-semibold text-gray-700 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-200"> </div> <!></div></div>`,1),gv=U(`<div data-testid="versions-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"><div class="flex h-[90vh] w-full max-w-7xl flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-2xl dark:border-gray-700 dark:bg-gray-950"><header class="flex shrink-0 items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"><div><h2 class="text-lg font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-code-branch mr-2"></i> </h2> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400"> </p></div> <button type="button" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm text-gray-600 transition-colors hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"><i class="fa-solid fa-xmark"></i></button></header> <div class="shrink-0 border-b border-gray-200 px-5 py-3 dark:border-gray-800"><div class="flex flex-wrap items-end gap-3"><label class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"> <input type="number" class="mt-1 block w-28 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-800 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100"/></label> <button type="button" class="rounded-lg bg-blue-600 px-3 py-1.5 text-sm font-semibold text-white transition-colors hover:bg-blue-700 disabled:opacity-50"><i class="fa-solid fa-arrows-rotate mr-1"></i> </button> <button type="button" class="rounded-lg bg-green-600 px-3 py-1.5 text-sm font-semibold text-white transition-colors hover:bg-green-700 disabled:cursor-not-allowed disabled:opacity-50"><i class="fa-solid fa-floppy-disk mr-1"></i> </button> <div class="text-xs text-gray-500 dark:text-gray-400"> </div> <!> <!></div> <!></div> <section class="min-h-0 flex-1 overflow-hidden"><!></section></div></div>`);function _v(e,t){qe(t,!0);let n=3650,r=P(30),i=P(30),a=P(!1),o=P(``),s=P(null),c=P(null),l=P(null),u=P(``),d=``,f=P(``),p=P(!1),m=N(()=>V(l)?.headContent??t.content),h=N(()=>V(f)),g=N(()=>V(f)!==V(m)),_=N(()=>T(V(l)?.baseContent??``,V(h))),v=N(()=>V(_).rows),y=N(()=>V(l)?.baseContent!==null&&V(l)?.baseContent!==void 0);kn(()=>{t.docId,F(f,t.content,!0)});function b(e){return Number.isFinite(e)?Math.max(1,Math.min(n,Math.floor(e))):30}function x(e){return e.length?e.replace(/\r\n/g,`
100
100
  `).split(`
101
101
  `):[]}function S(){return{text:``,lineNumber:null,kind:`empty`}}function C(e,t){let n=[],r=[],i=Math.max(e.length,t.length);for(let a=0;a<i;a+=1){let i=e[a],o=t[a];if(i===o)n.push({left:{text:i??``,lineNumber:i===void 0?null:a+1,kind:i===void 0?`empty`:`context`},right:{text:o??``,lineNumber:o===void 0?null:a+1,kind:o===void 0?`empty`:`context`},hunkId:null,showApply:!1});else{let e={id:r.length,oldStart:a,oldDeleteCount:i===void 0?0:1,newStart:a,newDeleteCount:o===void 0?0:1,oldLines:i===void 0?[]:[i],newLines:o===void 0?[]:[o]};r.push(e),n.push({left:i===void 0?S():{text:i,lineNumber:a+1,kind:`removed`},right:o===void 0?S():{text:o,lineNumber:a+1,kind:`added`},hunkId:e.id,showApply:!0})}}return{rows:n,hunks:r}}function w(e,t,n){let r=n.filter(e=>e.kind===`removed`),i=n.filter(e=>e.kind===`added`),a={id:t.length,oldStart:r[0]?r[0].oldLine-1:i[0]?.oldIndex??0,oldDeleteCount:r.length,newStart:i[0]?i[0].newLine-1:r[0]?.newIndex??0,newDeleteCount:i.length,oldLines:r.map(e=>e.text),newLines:i.map(e=>e.text)};t.push(a);let o=Math.max(r.length,i.length);for(let t=0;t<o;t+=1){let n=r[t],o=i[t];e.push({left:n?{text:n.text,lineNumber:n.oldLine,kind:`removed`}:S(),right:o?{text:o.text,lineNumber:o.newLine,kind:`added`}:S(),hunkId:a.id,showApply:t===0})}}function T(e,t){let n=x(e),r=x(t);if(n.length*r.length>4e6)return C(n,r);let i=r.length+1,a=new Uint32Array((n.length+1)*i);for(let e=n.length-1;e>=0;--e)for(let t=r.length-1;t>=0;--t){let o=e*i+t;a[o]=n[e]===r[t]?a[(e+1)*i+t+1]+1:Math.max(a[(e+1)*i+t],a[e*i+t+1])}let o=[],s=0,c=0;for(;s<n.length||c<r.length;)s<n.length&&c<r.length&&n[s]===r[c]?(o.push({kind:`context`,oldText:n[s],newText:r[c],oldLine:s+1,newLine:c+1}),s+=1,c+=1):c<r.length&&(s===n.length||a[s*i+c+1]>=a[(s+1)*i+c])?(o.push({kind:`added`,text:r[c],newLine:c+1,oldIndex:s}),c+=1):s<n.length&&(o.push({kind:`removed`,text:n[s],oldLine:s+1,newIndex:c}),s+=1);let l=[],u=[],d=[];for(let e of o)e.kind===`context`?(d.length&&(w(l,u,d),d=[]),l.push({left:{text:e.oldText,lineNumber:e.oldLine,kind:`context`},right:{text:e.newText,lineNumber:e.newLine,kind:`context`},hunkId:null,showApply:!1})):d.push(e);return d.length&&w(l,u,d),{rows:l,hunks:u}}function E(e){return e===`added`?`bg-green-50 text-green-900 dark:bg-green-950/40 dark:text-green-100`:e===`removed`?`bg-red-50 text-red-900 dark:bg-red-950/40 dark:text-red-100`:e===`empty`?`bg-gray-50 dark:bg-gray-900/60`:`bg-white text-gray-800 dark:bg-gray-950 dark:text-gray-200`}function D(e){return e===`added`?`bg-green-100 text-green-700 dark:bg-green-950 dark:text-green-300`:e===`removed`?`bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300`:`bg-gray-100 text-gray-400 dark:bg-gray-900 dark:text-gray-500`}function ee(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function te(e){return V(u)===e||V(l)?.baseRef===e}function O(e){return e===null?null:V(_).hunks.find(t=>t.id===e)||null}async function ne(e){if(V(c)!==null)return;let n=x(V(f)||t.content);if(n.slice(e.newStart,e.newStart+e.newDeleteCount).join(`
102
102
  `)!==e.newLines.join(`
103
103
  `)){F(s,{text:Y(`versions.apply_stale`),cls:`text-red-600 dark:text-red-400`},!0);return}F(c,e.id,!0),F(s,null);try{F(f,[...n.slice(0,e.newStart),...e.oldLines,...n.slice(e.newStart+e.newDeleteCount)].join(`
104
- `),!0),F(s,{text:Y(`versions.apply_success`),cls:`text-green-600 dark:text-green-400`},!0)}catch(e){F(s,{text:Y(`versions.apply_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-600 dark:text-red-400`},!0)}finally{F(c,null)}}async function re(){if(!(!V(g)||V(p))){F(p,!0),F(s,null);try{await t.onsave(V(f)),d=``,await ae(V(u)),F(s,{text:Y(`versions.save_success`),cls:`text-green-600 dark:text-green-400`},!0)}catch(e){F(s,{text:Y(`versions.save_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-600 dark:text-red-400`},!0)}finally{F(p,!1)}}}function k(){F(f,t.content,!0),F(s,null),F(c,null),F(p,!1)}function ie(){k(),t.onclose()}async function ae(e=V(u)){let n=b(V(i)),r=`${t.docId}:${n}:${e||`default`}`;if(!t.open||V(a)||r===d)return;F(a,!0),F(o,``);let c=V(g);c||F(s,null);try{let i=new URLSearchParams({documentId:t.docId,sinceDays:String(n)});e&&i.set(`baseRef`,e);let a=await fetch(`/api/git/document-versions?${i.toString()}`),o=await a.json();if(!a.ok||!o.ok)throw Error(o.message||o.error||Y(`versions.load_failed`));let s=o;F(l,s,!0),F(u,s.baseRef,!0),c||F(f,s.headContent??t.content,!0),d=r}catch(e){F(o,e instanceof Error?e.message:String(e),!0),F(l,null),d=``}finally{F(a,!1)}}function oe(){F(i,b(Number(V(r))),!0),F(r,V(i),!0),F(u,``),d=``,ae(``)}function se(e){F(u,e,!0),d=``,ae(e)}kn(()=>{if(!t.open){k(),d=``,F(u,``);return}t.docId,V(i),ae()});var ce=Wr(),le=R(ce),ue=e=>{var t=mv(),i=L(t),u=L(i),d=L(u),f=L(d),m=z(L(f),1,!0);j(f);var h=z(f,2),_=L(h,!0);j(h),j(d);var b=z(d,2);j(u);var x=z(u,2),S=L(x),C=L(S),w=L(C),T=z(w);Di(T),J(T,`min`,1),J(T,`max`,n),j(C);var k=z(C,2),ae=z(L(k),1,!0);j(k);var ce=z(k,2),le=z(L(ce),1,!0);j(ce);var ue=z(ce,2),de=L(ue,!0);j(ue);var fe=z(ue,2),pe=e=>{var t=rv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.unsaved_changes`)]),W(e,t)};K(fe,e=>{V(g)&&e(pe)});var me=z(fe,2),he=e=>{var t=iv(),n=L(t,!0);j(t),B(()=>{gi(t,1,`text-xs font-medium ${V(s).cls??``}`),G(n,V(s).text)}),W(e,t)};K(me,e=>{V(s)&&e(he)}),j(S);var ge=z(S,2),_e=e=>{var t=ov();q(t,21,()=>V(l).commits,e=>e.hash,(e,t)=>{var n=av(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=L(c);j(c),j(n),B((e,r,i)=>{J(n,`title`,e),gi(n,1,`min-w-64 rounded-lg border px-3 py-2 text-left text-xs transition-colors ${r??``}`),G(a,V(t).shortHash),G(s,V(t).subject),G(l,`${i??``} · ${V(t).author??``}`)},[()=>Y(`versions.select_commit`).replace(`{hash}`,V(t).shortHash),()=>te(V(t).hash)?`border-blue-500 bg-blue-50 ring-2 ring-blue-500/30 dark:border-blue-400 dark:bg-blue-950/40`:`border-gray-200 bg-gray-50 hover:border-blue-300 hover:bg-blue-50/70 dark:border-gray-700 dark:bg-gray-900 dark:hover:border-blue-700 dark:hover:bg-blue-950/30`,()=>ee(V(t).date)]),H(`click`,n,()=>se(V(t).hash)),W(e,n)}),j(t),W(e,t)},ve=e=>{var t=sv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.no_commits`)]),W(e,t)};K(ge,e=>{V(l)?.commits?.length?e(_e):V(l)&&!V(a)&&e(ve,1)}),j(x);var ye=z(x,2),be=L(ye),xe=e=>{var t=cv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},Se=e=>{var t=lv(),n=L(t,!0);j(t),B(()=>G(n,V(o))),W(e,t)},Ce=e=>{var t=pv(),n=R(t),r=e=>{var t=uv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.no_head_content`)]),W(e,t)};K(n,e=>{V(y)||e(r)});var i=z(n,2),a=L(i),o=L(a),s=L(o,!0);j(o);var u=z(o,4),d=L(u,!0);j(u),q(z(u,2),17,()=>V(v),Xr,(e,t)=>{var n=fv(),r=R(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var l=z(r,2),u=L(l),d=e=>{let n=N(()=>O(V(t).hunkId));var r=Wr(),i=R(r),a=e=>{var t=dv(),r=L(t,!0);j(t),B(e=>{t.disabled=V(c)!==null,J(t,`title`,e),G(r,V(c)===V(n).id?`...`:`<`)},[()=>Y(`versions.apply_hunk`)]),H(`click`,t,()=>ne(V(n))),W(e,t)};K(i,e=>{V(n)&&e(a)}),W(e,r)};K(u,e=>{V(t).showApply&&e(d)}),j(l);var f=z(l,2),p=L(f),m=L(p,!0);j(p);var h=z(p,2),g=L(h,!0);j(h),j(f),B((e,n,o,c)=>{gi(r,1,`grid grid-cols-[4rem_1fr] border-r border-gray-200 font-mono leading-5 dark:border-gray-800 ${e??``}`),gi(i,1,`select-none px-2 py-0.5 text-right ${n??``}`),G(a,V(t).right.lineNumber??``),G(s,V(t).right.text),gi(f,1,`grid grid-cols-[4rem_1fr] font-mono leading-5 ${o??``}`),gi(p,1,`select-none px-2 py-0.5 text-right ${c??``}`),G(m,V(t).left.lineNumber??``),G(g,V(t).left.text)},[()=>E(V(t).right.kind),()=>D(V(t).right.kind),()=>E(V(t).left.kind),()=>D(V(t).left.kind)]),W(e,n)}),j(a),j(i),B((e,t)=>{G(s,e),G(d,t)},[()=>Y(V(g)?`versions.right_title_draft`:`versions.right_title`),()=>Y(`versions.left_title`).replace(`{ref}`,V(l).baseRef)]),W(e,t)},A=e=>{var t=cv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.path_pending`)]),W(e,t)};K(be,e=>{V(a)?e(xe):V(o)?e(Se,1):V(l)?e(Ce,2):e(A,-1)}),j(ye),j(i),j(t),B((e,t,n,r,i,o,s)=>{G(m,e),G(_,t),J(b,`title`,n),G(w,`${r??``} `),k.disabled=V(a),G(ae,i),ce.disabled=!V(g)||V(p)||V(a),G(le,o),G(de,s)},[()=>Y(`versions.title`),()=>V(l)?.relativePath||Y(`versions.path_pending`),()=>Y(`common.close`),()=>Y(`versions.period_label`),()=>Y(`versions.refresh`),()=>V(p)?Y(`versions.saving`):Y(`common.save`),()=>Y(`versions.base_ref`).replace(`{ref}`,V(l)?.baseRef||`HEAD`)]),H(`click`,t,e=>{e.target===e.currentTarget&&ie()}),H(`click`,b,ie),Ni(T,()=>V(r),e=>F(r,e)),H(`click`,k,oe),H(`click`,ce,re),W(e,t)};K(le,e=>{t.open&&e(ue)}),W(e,ce),Je()}Pr([`click`]);function gv(e){let t=``,n=[],r=!0;for(let i=0;i<e.length;i++){let a=e[i].normalize(`NFD`);for(let e=0;e<a.length;e++){let o=a.charCodeAt(e);if(!(o>=768&&o<=879))if(o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122){let e=o>=65&&o<=90?o+32:o;t+=String.fromCharCode(e),n.push(i),r=!1}else r||=(t+=` `,n.push(i),!0)}}return n.push(e.length),t.endsWith(` `)&&(t=t.slice(0,-1),n.splice(n.length-2,1)),{normalized:t,map:n}}function _v(e){return gv(e).normalized}function vv(e,t,n){if(e===t)return 0;let r=e.length,i=t.length;if(Math.abs(r-i)>n)return n+1;let a=null,o=Array(i+1),s=Array(i+1);for(let e=0;e<=i;e++)o[e]=e;for(let c=1;c<=r;c++){s[0]=c;let r=c;for(let n=1;n<=i;n++){let i=e.charCodeAt(c-1)===t.charCodeAt(n-1)?0:1,l=Math.min(o[n]+1,s[n-1]+1,o[n-1]+i);c>1&&n>1&&e.charCodeAt(c-1)===t.charCodeAt(n-2)&&e.charCodeAt(c-2)===t.charCodeAt(n-1)&&(l=Math.min(l,a?.[n-2]+1)),s[n]=l,l<r&&(r=l)}if(r>n)return n+1;a=o,o=s,s=Array(i+1)}return o[i]}function yv(e){return e>=7?2:+(e>=4)}function bv(e){return String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function xv(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Sv(e,t,n){t.innerHTML=``,t.classList.add(`hidden`);let r=e.querySelectorAll(`[data-ld-local-search]`);if(!r.length)return;r.forEach(e=>{e.remove()});let i=(()=>{let t=new Set;return _v(e.textContent||``).split(` `).forEach(e=>{e.length>=3&&t.add(e)}),Array.from(t)})(),a=n(`local_search.placeholder`)||`Search in this document…`,o=n(`local_search.clear`)||`Clear`,s=document.createElement(`div`);s.className=`no-print mt-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 overflow-hidden`,s.innerHTML=`
104
+ `),!0),F(s,{text:Y(`versions.apply_success`),cls:`text-green-600 dark:text-green-400`},!0)}catch(e){F(s,{text:Y(`versions.apply_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-600 dark:text-red-400`},!0)}finally{F(c,null)}}async function re(){if(!(!V(g)||V(p))){F(p,!0),F(s,null);try{await t.onsave(V(f)),d=``,await ae(V(u)),F(s,{text:Y(`versions.save_success`),cls:`text-green-600 dark:text-green-400`},!0)}catch(e){F(s,{text:Y(`versions.save_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-600 dark:text-red-400`},!0)}finally{F(p,!1)}}}function k(){F(f,t.content,!0),F(s,null),F(c,null),F(p,!1)}function ie(){k(),t.onclose()}async function ae(e=V(u)){let n=b(V(i)),r=`${t.docId}:${n}:${e||`default`}`;if(!t.open||V(a)||r===d)return;F(a,!0),F(o,``);let c=V(g);c||F(s,null);try{let i=new URLSearchParams({documentId:t.docId,sinceDays:String(n)});e&&i.set(`baseRef`,e);let a=await fetch(`/api/git/document-versions?${i.toString()}`),o=await a.json();if(!a.ok||!o.ok)throw Error(o.message||o.error||Y(`versions.load_failed`));let s=o;F(l,s,!0),F(u,s.baseRef,!0),c||F(f,s.headContent??t.content,!0),d=r}catch(e){F(o,e instanceof Error?e.message:String(e),!0),F(l,null),d=``}finally{F(a,!1)}}function oe(){F(i,b(Number(V(r))),!0),F(r,V(i),!0),F(u,``),d=``,ae(``)}function se(e){F(u,e,!0),d=``,ae(e)}kn(()=>{if(!t.open){k(),d=``,F(u,``);return}t.docId,V(i),ae()});var ce=Wr(),le=R(ce),ue=e=>{var t=gv(),i=L(t),u=L(i),d=L(u),f=L(d),m=z(L(f),1,!0);j(f);var h=z(f,2),_=L(h,!0);j(h),j(d);var b=z(d,2);j(u);var x=z(u,2),S=L(x),C=L(S),w=L(C),T=z(w);Di(T),J(T,`min`,1),J(T,`max`,n),j(C);var k=z(C,2),ae=z(L(k),1,!0);j(k);var ce=z(k,2),le=z(L(ce),1,!0);j(ce);var ue=z(ce,2),de=L(ue,!0);j(ue);var fe=z(ue,2),pe=e=>{var t=av(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.unsaved_changes`)]),W(e,t)};K(fe,e=>{V(g)&&e(pe)});var me=z(fe,2),he=e=>{var t=ov(),n=L(t,!0);j(t),B(()=>{gi(t,1,`text-xs font-medium ${V(s).cls??``}`),G(n,V(s).text)}),W(e,t)};K(me,e=>{V(s)&&e(he)}),j(S);var ge=z(S,2),_e=e=>{var t=cv();q(t,21,()=>V(l).commits,e=>e.hash,(e,t)=>{var n=sv(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=L(c);j(c),j(n),B((e,r,i)=>{J(n,`title`,e),gi(n,1,`min-w-64 rounded-lg border px-3 py-2 text-left text-xs transition-colors ${r??``}`),G(a,V(t).shortHash),G(s,V(t).subject),G(l,`${i??``} · ${V(t).author??``}`)},[()=>Y(`versions.select_commit`).replace(`{hash}`,V(t).shortHash),()=>te(V(t).hash)?`border-blue-500 bg-blue-50 ring-2 ring-blue-500/30 dark:border-blue-400 dark:bg-blue-950/40`:`border-gray-200 bg-gray-50 hover:border-blue-300 hover:bg-blue-50/70 dark:border-gray-700 dark:bg-gray-900 dark:hover:border-blue-700 dark:hover:bg-blue-950/30`,()=>ee(V(t).date)]),H(`click`,n,()=>se(V(t).hash)),W(e,n)}),j(t),W(e,t)},ve=e=>{var t=lv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.no_commits`)]),W(e,t)};K(ge,e=>{V(l)?.commits?.length?e(_e):V(l)&&!V(a)&&e(ve,1)}),j(x);var ye=z(x,2),be=L(ye),xe=e=>{var t=uv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},Se=e=>{var t=dv(),n=L(t,!0);j(t),B(()=>G(n,V(o))),W(e,t)},Ce=e=>{var t=hv(),n=R(t),r=e=>{var t=fv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.no_head_content`)]),W(e,t)};K(n,e=>{V(y)||e(r)});var i=z(n,2),a=L(i),o=L(a),s=L(o,!0);j(o);var u=z(o,4),d=L(u,!0);j(u),q(z(u,2),17,()=>V(v),Xr,(e,t)=>{var n=mv(),r=R(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var l=z(r,2),u=L(l),d=e=>{let n=N(()=>O(V(t).hunkId));var r=Wr(),i=R(r),a=e=>{var t=pv(),r=L(t,!0);j(t),B(e=>{t.disabled=V(c)!==null,J(t,`title`,e),G(r,V(c)===V(n).id?`...`:`<`)},[()=>Y(`versions.apply_hunk`)]),H(`click`,t,()=>ne(V(n))),W(e,t)};K(i,e=>{V(n)&&e(a)}),W(e,r)};K(u,e=>{V(t).showApply&&e(d)}),j(l);var f=z(l,2),p=L(f),m=L(p,!0);j(p);var h=z(p,2),g=L(h,!0);j(h),j(f),B((e,n,o,c)=>{gi(r,1,`grid grid-cols-[4rem_1fr] border-r border-gray-200 font-mono leading-5 dark:border-gray-800 ${e??``}`),gi(i,1,`select-none px-2 py-0.5 text-right ${n??``}`),G(a,V(t).right.lineNumber??``),G(s,V(t).right.text),gi(f,1,`grid grid-cols-[4rem_1fr] font-mono leading-5 ${o??``}`),gi(p,1,`select-none px-2 py-0.5 text-right ${c??``}`),G(m,V(t).left.lineNumber??``),G(g,V(t).left.text)},[()=>E(V(t).right.kind),()=>D(V(t).right.kind),()=>E(V(t).left.kind),()=>D(V(t).left.kind)]),W(e,n)}),j(a),j(i),B((e,t)=>{G(s,e),G(d,t)},[()=>Y(V(g)?`versions.right_title_draft`:`versions.right_title`),()=>Y(`versions.left_title`).replace(`{ref}`,V(l).baseRef)]),W(e,t)},A=e=>{var t=uv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.path_pending`)]),W(e,t)};K(be,e=>{V(a)?e(xe):V(o)?e(Se,1):V(l)?e(Ce,2):e(A,-1)}),j(ye),j(i),j(t),B((e,t,n,r,i,o,s)=>{G(m,e),G(_,t),J(b,`title`,n),G(w,`${r??``} `),k.disabled=V(a),G(ae,i),ce.disabled=!V(g)||V(p)||V(a),G(le,o),G(de,s)},[()=>Y(`versions.title`),()=>V(l)?.relativePath||Y(`versions.path_pending`),()=>Y(`common.close`),()=>Y(`versions.period_label`),()=>Y(`versions.refresh`),()=>V(p)?Y(`versions.saving`):Y(`common.save`),()=>Y(`versions.base_ref`).replace(`{ref}`,V(l)?.baseRef||`HEAD`)]),H(`click`,t,e=>{e.target===e.currentTarget&&ie()}),H(`click`,b,ie),Ni(T,()=>V(r),e=>F(r,e)),H(`click`,k,oe),H(`click`,ce,re),W(e,t)};K(le,e=>{t.open&&e(ue)}),W(e,ce),Je()}Pr([`click`]);function vv(e){let t=``,n=[],r=!0;for(let i=0;i<e.length;i++){let a=e[i].normalize(`NFD`);for(let e=0;e<a.length;e++){let o=a.charCodeAt(e);if(!(o>=768&&o<=879))if(o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122){let e=o>=65&&o<=90?o+32:o;t+=String.fromCharCode(e),n.push(i),r=!1}else r||=(t+=` `,n.push(i),!0)}}return n.push(e.length),t.endsWith(` `)&&(t=t.slice(0,-1),n.splice(n.length-2,1)),{normalized:t,map:n}}function yv(e){return vv(e).normalized}function bv(e,t,n){if(e===t)return 0;let r=e.length,i=t.length;if(Math.abs(r-i)>n)return n+1;let a=null,o=Array(i+1),s=Array(i+1);for(let e=0;e<=i;e++)o[e]=e;for(let c=1;c<=r;c++){s[0]=c;let r=c;for(let n=1;n<=i;n++){let i=e.charCodeAt(c-1)===t.charCodeAt(n-1)?0:1,l=Math.min(o[n]+1,s[n-1]+1,o[n-1]+i);c>1&&n>1&&e.charCodeAt(c-1)===t.charCodeAt(n-2)&&e.charCodeAt(c-2)===t.charCodeAt(n-1)&&(l=Math.min(l,a?.[n-2]+1)),s[n]=l,l<r&&(r=l)}if(r>n)return n+1;a=o,o=s,s=Array(i+1)}return o[i]}function xv(e){return e>=7?2:+(e>=4)}function Sv(e){return String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Cv(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function wv(e,t,n){t.innerHTML=``,t.classList.add(`hidden`);let r=e.querySelectorAll(`[data-ld-local-search]`);if(!r.length)return;r.forEach(e=>{e.remove()});let i=(()=>{let t=new Set;return yv(e.textContent||``).split(` `).forEach(e=>{e.length>=3&&t.add(e)}),Array.from(t)})(),a=n(`local_search.placeholder`)||`Search in this document…`,o=n(`local_search.clear`)||`Clear`,s=document.createElement(`div`);s.className=`no-print mt-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 overflow-hidden`,s.innerHTML=`
105
105
  <div class="flex items-center gap-2 px-3 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50">
106
106
  <span class="text-gray-400 select-none" aria-hidden="true">🔎</span>
107
107
  <input type="text" id="ld-local-search-input" autocomplete="off"
108
108
  class="flex-1 bg-transparent border-0 text-sm text-gray-700 dark:text-gray-300 placeholder:text-gray-400 focus:outline-none focus:ring-0"
109
- placeholder="${bv(a)}" />
109
+ placeholder="${Sv(a)}" />
110
110
  <button type="button" id="ld-local-search-clear"
111
111
  class="hidden text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 shrink-0 px-1"
112
- title="${bv(o)}" aria-label="${bv(o)}">✕</button>
112
+ title="${Sv(o)}" aria-label="${Sv(o)}">✕</button>
113
113
  </div>
114
114
  <div id="ld-local-search-results" class="hidden">
115
115
  <div id="ld-local-search-title" class="px-3 py-1.5 text-xs font-medium text-gray-500 dark:text-gray-400 border-b border-gray-100 dark:border-gray-800"></div>
116
116
  <ol id="ld-local-search-list" class="max-h-40 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800 list-none m-0 p-0"></ol>
117
- </div>`,t.appendChild(s),t.classList.remove(`hidden`);let c=s.querySelector(`#ld-local-search-input`),l=s.querySelector(`#ld-local-search-clear`),u=s.querySelector(`#ld-local-search-results`),d=s.querySelector(`#ld-local-search-title`),f=s.querySelector(`#ld-local-search-list`),p=null;function m(){e.querySelectorAll(`mark.ld-local-mark`).forEach(e=>{let t=e.parentNode;for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}),e.normalize()}function h(e,t){let n=new Set;t.includes(e)&&n.add(e);let r=yv(e.length);if(r===0)return n;let a=e[0];for(let t of i)t!==e&&(Math.abs(t.length-e.length)>r||e.length>=3&&t[0]!==a||vv(e,t,r)<=r&&n.add(t));return n}function g(t){if(m(),!t){u.classList.add(`hidden`),l.classList.add(`hidden`),f.innerHTML=``;return}l.classList.remove(`hidden`);let r=_v(t),i=r.split(` `).filter(Boolean);if(!i.length){u.classList.add(`hidden`);return}let a=_v(e.textContent||``),o=i.map(e=>h(e,a));if(!o.some(e=>e.size>0)){d.textContent=n(`local_search.no_results`)||`No matches found.`,f.innerHTML=``,u.classList.remove(`hidden`);return}let s=new Set;o.forEach((e,t)=>{e.forEach(e=>{let n=e===i[t];s.add(n?e:`\\b${xv(e)}\\b`)})});let c=Array.from(s).sort((e,t)=>t.length-e.length),p=RegExp(`(${c.map(e=>e.startsWith(`\\b`)?e:xv(e)).join(`|`)})`,`g`),g=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){return e.parentElement?.closest(`mark`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),v=[];for(;g.nextNode();)v.push(g.currentNode);let y=0,b=new Map;v.forEach(e=>{let t=e.textContent||``,{normalized:n,map:r}=gv(t);if(!n)return;let i=[],a;for(p.lastIndex=0;(a=p.exec(n))!==null;){if(a[0].length===0){p.lastIndex++;continue}i.push({start:a.index,end:a.index+a[0].length,term:a[0]})}if(!i.length)return;let s=e.parentElement?.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement,c=``,l=0;i.forEach(e=>{let n=r[e.start],i=r[e.end];if(!(n<l)&&(c+=bv(t.slice(l,n)),c+=`<mark class="ld-local-mark" id="ld-local-match-${y++}">${bv(t.slice(n,i))}</mark>`,l=i,s)){b.has(s)||b.set(s,new Set);let t=b.get(s);o.forEach((n,r)=>{n.has(e.term)&&t.add(r)})}}),c+=bv(t.slice(l));let u=document.createElement(`span`);u.innerHTML=c,e.parentNode?.replaceChild(u,e)});let x=i.length,S=[];for(let[e,t]of b.entries())t.size===x&&S.push(e);let C;if(S.length>0){let t=new Set(S);C=Array.from(e.querySelectorAll(`mark.ld-local-mark`)).filter(e=>{let n=e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement;return t.has(n)})}else C=Array.from(e.querySelectorAll(`mark.ld-local-mark`));if(!C.length){d.textContent=n(`local_search.no_results`)||`No matches found.`,f.innerHTML=``,u.classList.remove(`hidden`);return}d.textContent=(C.length===1?n(`local_search.count_singular`)||`{count} match`:n(`local_search.count_plural`)||`{count} matches`).replace(`{count}`,String(C.length)),f.innerHTML=C.map((e,t)=>{let n=e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement,i=(n?n.textContent||``:e.textContent||``).trim(),a=_v(i),s=-1;for(let e of o)for(let t of e){let e=a.indexOf(t);e>=0&&(s<0||e<s)&&(s=e)}s<0&&(s=a.indexOf(r.split(` `)[0])),s<0&&(s=0);let c=Math.max(0,s-40),l=Math.min(i.length,s+80),u=(c>0?`…`:``)+i.slice(c,l)+(l<i.length?`…`:``);return`<li><button type="button" data-target="${e.id}" class="ld-local-item w-full text-left px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors text-xs"><span class="text-gray-400 font-mono mr-2">${t+1}.</span>${bv(u)}</button></li>`}).join(``),u.classList.remove(`hidden`),f.querySelectorAll(`.ld-local-item`).forEach(e=>{e.addEventListener(`click`,()=>_(e.dataset.target))})}function _(t){let n=document.getElementById(t),r=document.getElementById(`home-content-area`);if(!n||!r)return;let i=n.parentElement;for(;i&&i!==r;)i.tagName===`DETAILS`&&!i.open&&(i.open=!0),i=i.parentElement;e.querySelectorAll(`mark.ld-local-mark.ld-local-active`).forEach(e=>e.classList.remove(`ld-local-active`)),n.classList.add(`ld-local-active`),f.querySelectorAll(`.ld-local-item`).forEach(e=>{e.classList.toggle(`ld-local-item-active`,e.dataset.target===t)});let a=document.querySelector(`#home-doc-view header`),o=a?a.getBoundingClientRect().height:0,s=n.getBoundingClientRect().top,c=r.getBoundingClientRect().top,l=o+(r.clientHeight-o)/3;r.scrollTop+=s-c-l}c.addEventListener(`input`,()=>{p&&clearTimeout(p),p=window.setTimeout(()=>g(c.value.trim()),250)}),l.addEventListener(`click`,()=>{c.value=``,g(``),c.focus()}),c.addEventListener(`keydown`,e=>{e.key===`Escape`&&(c.value=``,g(``),c.blur())})}var Cv={codeLabel:`Code block.`,imageLabel:`Image: {alt}.`,diagramLabel:`Diagram.`,tableLabel:`Table.`,readCode:!1},wv=new Set([`H1`,`H2`,`H3`,`H4`,`H5`,`H6`]);function Tv(e){return e.classList.contains(`mermaid`)||e.querySelector(`.mermaid`)!==null}function Ev(e){let t=[];for(let n of e.matchAll(/[^.!?…\n]*(?:[.!?…]+|\n+|$)/g)){let e=n[0];if(e.length===0)continue;let r=e.length-e.trimStart().length,i=e.trim();if(i){let e=n.index+r;t.push({text:i,start:e,end:e+i.length})}}return t}function Dv(e,t){let n=(e.textContent??``).replace(/\s+/g,` `).trim();if(!n)return null;let r=Ev(n);return{type:t,el:e,spokenText:n,sentences:r.length?r:[{text:n,start:0,end:n.length}],highlightWhole:!1}}function Ov(e,t,n){let r=n.trim();return r?{type:t,el:e,spokenText:r,sentences:[{text:r,start:0,end:r.length}],highlightWhole:!0}:null}function kv(e,t,n){for(let r of Array.from(e.children)){let e=r.tagName;if(Tv(r)){Av(n,Ov(r,`diagram`,t.diagramLabel));continue}if(e===`PRE`||e===`DIV`&&r.querySelector(`:scope > pre`)){Av(n,t.readCode?Dv(r,`code`):Ov(r,`code`,t.codeLabel));continue}if(e===`TABLE`){Av(n,Ov(r,`table`,t.tableLabel));continue}if(e===`IMG`||e===`FIGURE`&&r.querySelector(`img`)){let i=(e===`IMG`?r:r.querySelector(`img`))?.getAttribute(`alt`)?.trim()??``;Av(n,Ov(r,`image`,t.imageLabel.includes(`{alt}`)?i?t.imageLabel.replace(`{alt}`,i):t.imageLabel.replace(/:?\s*\{alt\}/,``).trim()||`Image.`:t.imageLabel));continue}if(wv.has(e)){Av(n,Dv(r,`heading`));continue}if(e===`P`){Av(n,Dv(r,`paragraph`));continue}if(e===`LI`){Av(n,Dv(r,`list-item`));continue}if(e===`BLOCKQUOTE`){r.querySelector(`:scope > p, :scope > ul, :scope > ol`)?kv(r,t,n):Av(n,Dv(r,`quote`));continue}if(e===`UL`||e===`OL`||e===`DIV`||e===`SECTION`||e===`DETAILS`){kv(r,t,n);continue}}}function Av(e,t){t&&e.push(t)}function jv(e,t={}){let n={...Cv,...t},r=[];return kv(e,n,r),r}var Mv=`tts-sentence`;function Nv(){if(typeof document>`u`||document.getElementById(`tts-highlight-style`))return;let e=document.createElement(`style`);e.id=`tts-highlight-style`,e.textContent=`::highlight(${Mv}){background-color:rgba(250,204,21,0.45);color:inherit;}.dark ::highlight(${Mv}){background-color:rgba(250,204,21,0.35);}`,document.head.appendChild(e)}function Pv(e,t,n){let r=[],i=!0,a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=a.nextNode();for(;o;){let e=o.data;for(let t=0;t<e.length;t++)/\s/.test(e[t])?i||=(r.push({node:o,offset:t}),!0):(r.push({node:o,offset:t}),i=!1);o=a.nextNode()}if(t>=r.length)return null;let s=r[t],c=document.createRange();if(c.setStart(s.node,s.offset),n<r.length){let e=r[n];c.setEnd(e.node,e.offset)}else{let e=r[r.length-1];c.setEnd(e.node,e.offset+1)}return c}var Fv=new class{#e=P(`idle`);get status(){return V(this.#e)}set status(e){F(this.#e,e,!0)}#t=P(-1);get index(){return V(this.#t)}set index(e){F(this.#t,e,!0)}#n=P(0);get total(){return V(this.#n)}set total(e){F(this.#n,e,!0)}#r=P(null);get error(){return V(this.#r)}set error(e){F(this.#r,e,!0)}units=[];ctx=null;source=null;cache=new Map;token=0;voice;speed;language=`en`;fallbackEl=null;get active(){return this.status===`playing`||this.status===`paused`||this.status===`loading`}async start(e,t={}){this.stop();let{voice:n,speed:r,language:i,...a}=t;this.voice=n,this.speed=r,this.language=i??`en`;let o=jv(e,a);if(this.units=o.flatMap(e=>e.highlightWhole?[{seg:e,text:e.spokenText,start:0,end:e.spokenText.length,whole:!0}]:e.sentences.map(t=>({seg:e,text:t.text,start:t.start,end:t.end,whole:!1}))),this.total=this.units.length,this.units.length===0)return;this.ctx=new AudioContext,this.error=null;let s=++this.token;this.status=`loading`,await this.playFrom(0,s)}async playFrom(e,t){if(t!==this.token)return;if(e>=this.units.length){this.stop();return}this.index=e,this.highlight(this.units[e]);let n;try{n=await this.audioFor(e)}catch(e){if(t!==this.token)return;this.error=e instanceof Error?e.message:String(e),this.stop(!1);return}if(t!==this.token||!this.ctx)return;this.prefetch(e+1);let r=this.ctx.createBufferSource();r.buffer=n,r.connect(this.ctx.destination),r.onended=()=>{t===this.token&&(this.source=null,this.playFrom(e+1,t))},this.source=r,this.status=`playing`,r.start()}audioFor(e){let t=this.cache.get(e);return t||(t=this.fetchAudio(this.units[e].text),this.cache.set(e,t)),t}prefetch(e){e<this.units.length&&!this.cache.has(e)&&this.cache.set(e,this.fetchAudio(this.units[e].text).catch(e=>Promise.reject(e)))}async fetchAudio(e){let t=await fetch(`/api/tts`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,voice:this.voice,speed:this.speed,language:this.language})});if(!t.ok){let e=`HTTP ${t.status}`;try{e=(await t.json()).error||e}catch{}throw Error(e)}let n=await t.arrayBuffer();return this.ctx?.decodeAudioData(n)}pause(){this.status===`playing`&&this.ctx&&(this.ctx.suspend(),this.status=`paused`)}resume(){this.status===`paused`&&this.ctx&&(this.ctx.resume(),this.status=`playing`)}toggle(){this.status===`playing`?this.pause():this.status===`paused`&&this.resume()}stop(e=!0){if(this.token++,this.source){try{this.source.onended=null,this.source.stop()}catch{}this.source=null}this.ctx&&=(this.ctx.close(),null),this.cache.clear(),this.clearHighlight(),this.status=`idle`,this.index=-1,this.total=0,e&&(this.error=null)}highlight(e){Nv(),this.clearHighlight();let t=typeof CSS<`u`&&`highlights`in CSS&&typeof Highlight<`u`;if(t&&!e.whole){let t=Pv(e.seg.el,e.start,e.end);t?CSS.highlights.set(Mv,new Highlight(t)):this.fallbackHighlight(e.seg.el)}else if(t){let t=document.createRange();t.selectNodeContents(e.seg.el),CSS.highlights.set(Mv,new Highlight(t))}else this.fallbackHighlight(e.seg.el);e.seg.el.scrollIntoView({block:`center`,behavior:`smooth`})}fallbackHighlight(e){e.classList.add(`tts-active`),this.fallbackEl=e}clearHighlight(){typeof CSS<`u`&&`highlights`in CSS&&CSS.highlights.delete(Mv),this.fallbackEl&&=(this.fallbackEl.classList.remove(`tts-active`),null)}},Iv=Symbol.for(`yaml.alias`),Lv=Symbol.for(`yaml.document`),Rv=Symbol.for(`yaml.map`),zv=Symbol.for(`yaml.pair`),Bv=Symbol.for(`yaml.scalar`),Vv=Symbol.for(`yaml.seq`),Hv=Symbol.for(`yaml.node.type`),Uv=e=>!!e&&typeof e==`object`&&e[Hv]===Iv,Wv=e=>!!e&&typeof e==`object`&&e[Hv]===Lv,Gv=e=>!!e&&typeof e==`object`&&e[Hv]===Rv,Kv=e=>!!e&&typeof e==`object`&&e[Hv]===zv,qv=e=>!!e&&typeof e==`object`&&e[Hv]===Bv,Jv=e=>!!e&&typeof e==`object`&&e[Hv]===Vv;function Yv(e){if(e&&typeof e==`object`)switch(e[Hv]){case Rv:case Vv:return!0}return!1}function Xv(e){if(e&&typeof e==`object`)switch(e[Hv]){case Iv:case Rv:case Bv:case Vv:return!0}return!1}var Zv=e=>(qv(e)||Yv(e))&&!!e.anchor,Qv=Symbol(`break visit`),$v=Symbol(`skip children`),ey=Symbol(`remove node`);function ty(e,t){let n=ay(t);Wv(e)?ny(null,e.contents,n,Object.freeze([e]))===ey&&(e.contents=null):ny(null,e,n,Object.freeze([]))}ty.BREAK=Qv,ty.SKIP=$v,ty.REMOVE=ey;function ny(e,t,n,r){let i=oy(e,t,n,r);if(Xv(i)||Kv(i))return sy(e,r,i),ny(e,i,n,r);if(typeof i!=`symbol`){if(Yv(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=ny(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Qv)return Qv;else i===ey&&(t.items.splice(e,1),--e)}}else if(Kv(t)){r=Object.freeze(r.concat(t));let e=ny(`key`,t.key,n,r);if(e===Qv)return Qv;e===ey&&(t.key=null);let i=ny(`value`,t.value,n,r);if(i===Qv)return Qv;i===ey&&(t.value=null)}}return i}async function ry(e,t){let n=ay(t);Wv(e)?await iy(null,e.contents,n,Object.freeze([e]))===ey&&(e.contents=null):await iy(null,e,n,Object.freeze([]))}ry.BREAK=Qv,ry.SKIP=$v,ry.REMOVE=ey;async function iy(e,t,n,r){let i=await oy(e,t,n,r);if(Xv(i)||Kv(i))return sy(e,r,i),iy(e,i,n,r);if(typeof i!=`symbol`){if(Yv(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await iy(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Qv)return Qv;else i===ey&&(t.items.splice(e,1),--e)}}else if(Kv(t)){r=Object.freeze(r.concat(t));let e=await iy(`key`,t.key,n,r);if(e===Qv)return Qv;e===ey&&(t.key=null);let i=await iy(`value`,t.value,n,r);if(i===Qv)return Qv;i===ey&&(t.value=null)}}return i}function ay(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function oy(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(Gv(t))return n.Map?.(e,t,r);if(Jv(t))return n.Seq?.(e,t,r);if(Kv(t))return n.Pair?.(e,t,r);if(qv(t))return n.Scalar?.(e,t,r);if(Uv(t))return n.Alias?.(e,t,r)}function sy(e,t,n){let r=t[t.length-1];if(Yv(r))r.items[e]=n;else if(Kv(r))e===`key`?r.key=n:r.value=n;else if(Wv(r))r.contents=n;else{let e=Uv(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var cy={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},ly=e=>e.replace(/[!,[\]{}]/g,e=>cy[e]),uy=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+ly(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Xv(e.contents)){let t={};ty(e.contents,(e,n)=>{Xv(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
118
- `)}};uy.defaultYaml={explicit:!1,version:`1.2`},uy.defaultTags={"!!":`tag:yaml.org,2002:`};function dy(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function fy(e){let t=new Set;return ty(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function py(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function my(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i||=fy(e);let a=py(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(qv(t.node)||Yv(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function hy(e,t,n,r){if(r&&typeof r==`object`)if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=hy(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=hy(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=hy(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=hy(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function gy(e,t,n){if(Array.isArray(e))return e.map((e,t)=>gy(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!Zv(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var _y=class{constructor(e){Object.defineProperty(this,Hv,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Wv(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=gy(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?hy(i,{"":o},``,o):o}},vy=class extends _y{constructor(e){super(Iv),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e){let t;return ty(e,{Node:(e,n)=>{if(n===this)return ty.BREAK;n.anchor===this.source&&(t=n)}}),t}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(gy(a,null,t),n.get(a)),!o||o.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=yy(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(dy(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function yy(e,t,n){if(Uv(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(Yv(t)){let r=0;for(let i of t.items){let t=yy(e,i,n);t>r&&(r=t)}return r}else if(Kv(t)){let r=yy(e,t.key,n),i=yy(e,t.value,n);return Math.max(r,i)}return 1}var by=e=>!e||typeof e!=`function`&&typeof e!=`object`,xy=class extends _y{constructor(e){super(Bv),this.value=e}toJSON(e,t){return t?.keep?this.value:gy(this.value,e,t)}toString(){return String(this.value)}};xy.BLOCK_FOLDED=`BLOCK_FOLDED`,xy.BLOCK_LITERAL=`BLOCK_LITERAL`,xy.PLAIN=`PLAIN`,xy.QUOTE_DOUBLE=`QUOTE_DOUBLE`,xy.QUOTE_SINGLE=`QUOTE_SINGLE`;var Sy=`tag:yaml.org,2002:`;function Cy(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function wy(e,t,n){if(Wv(e)&&(e=e.contents),Xv(e))return e;if(Kv(e)){let t=n.schema[Rv].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor||=i(e),new vy(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=Sy+t.slice(2));let l=Cy(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new xy(e);return c&&(c.node=t),t}l=e instanceof Map?o[Rv]:Symbol.iterator in Object(e)?o[Vv]:o[Rv]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new xy(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Ty(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return wy(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var Ey=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,Dy=class extends _y{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>Xv(t)||Kv(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Ey(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(Yv(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Ty(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(Yv(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&qv(i)?i.value:i:Yv(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!Kv(t))return!1;let n=t.value;return n==null||e&&qv(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return Yv(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(Yv(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Ty(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},Oy=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function ky(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Ay=(e,t,n)=>e.endsWith(`
119
- `)?ky(n,t):n.includes(`
117
+ </div>`,t.appendChild(s),t.classList.remove(`hidden`);let c=s.querySelector(`#ld-local-search-input`),l=s.querySelector(`#ld-local-search-clear`),u=s.querySelector(`#ld-local-search-results`),d=s.querySelector(`#ld-local-search-title`),f=s.querySelector(`#ld-local-search-list`),p=null;function m(){e.querySelectorAll(`mark.ld-local-mark`).forEach(e=>{let t=e.parentNode;for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}),e.normalize()}function h(e,t){let n=new Set;t.includes(e)&&n.add(e);let r=xv(e.length);if(r===0)return n;let a=e[0];for(let t of i)t!==e&&(Math.abs(t.length-e.length)>r||e.length>=3&&t[0]!==a||bv(e,t,r)<=r&&n.add(t));return n}function g(t){if(m(),!t){u.classList.add(`hidden`),l.classList.add(`hidden`),f.innerHTML=``;return}l.classList.remove(`hidden`);let r=yv(t),i=r.split(` `).filter(Boolean);if(!i.length){u.classList.add(`hidden`);return}let a=yv(e.textContent||``),o=i.map(e=>h(e,a));if(!o.some(e=>e.size>0)){d.textContent=n(`local_search.no_results`)||`No matches found.`,f.innerHTML=``,u.classList.remove(`hidden`);return}let s=new Set;o.forEach((e,t)=>{e.forEach(e=>{let n=e===i[t];s.add(n?e:`\\b${Cv(e)}\\b`)})});let c=Array.from(s).sort((e,t)=>t.length-e.length),p=RegExp(`(${c.map(e=>e.startsWith(`\\b`)?e:Cv(e)).join(`|`)})`,`g`),g=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){return e.parentElement?.closest(`mark`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),v=[];for(;g.nextNode();)v.push(g.currentNode);let y=0,b=new Map;v.forEach(e=>{let t=e.textContent||``,{normalized:n,map:r}=vv(t);if(!n)return;let i=[],a;for(p.lastIndex=0;(a=p.exec(n))!==null;){if(a[0].length===0){p.lastIndex++;continue}i.push({start:a.index,end:a.index+a[0].length,term:a[0]})}if(!i.length)return;let s=e.parentElement?.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement,c=``,l=0;i.forEach(e=>{let n=r[e.start],i=r[e.end];if(!(n<l)&&(c+=Sv(t.slice(l,n)),c+=`<mark class="ld-local-mark" id="ld-local-match-${y++}">${Sv(t.slice(n,i))}</mark>`,l=i,s)){b.has(s)||b.set(s,new Set);let t=b.get(s);o.forEach((n,r)=>{n.has(e.term)&&t.add(r)})}}),c+=Sv(t.slice(l));let u=document.createElement(`span`);u.innerHTML=c,e.parentNode?.replaceChild(u,e)});let x=i.length,S=[];for(let[e,t]of b.entries())t.size===x&&S.push(e);let C;if(S.length>0){let t=new Set(S);C=Array.from(e.querySelectorAll(`mark.ld-local-mark`)).filter(e=>{let n=e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement;return t.has(n)})}else C=Array.from(e.querySelectorAll(`mark.ld-local-mark`));if(!C.length){d.textContent=n(`local_search.no_results`)||`No matches found.`,f.innerHTML=``,u.classList.remove(`hidden`);return}d.textContent=(C.length===1?n(`local_search.count_singular`)||`{count} match`:n(`local_search.count_plural`)||`{count} matches`).replace(`{count}`,String(C.length)),f.innerHTML=C.map((e,t)=>{let n=e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement,i=(n?n.textContent||``:e.textContent||``).trim(),a=yv(i),s=-1;for(let e of o)for(let t of e){let e=a.indexOf(t);e>=0&&(s<0||e<s)&&(s=e)}s<0&&(s=a.indexOf(r.split(` `)[0])),s<0&&(s=0);let c=Math.max(0,s-40),l=Math.min(i.length,s+80),u=(c>0?`…`:``)+i.slice(c,l)+(l<i.length?`…`:``);return`<li><button type="button" data-target="${e.id}" class="ld-local-item w-full text-left px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors text-xs"><span class="text-gray-400 font-mono mr-2">${t+1}.</span>${Sv(u)}</button></li>`}).join(``),u.classList.remove(`hidden`),f.querySelectorAll(`.ld-local-item`).forEach(e=>{e.addEventListener(`click`,()=>_(e.dataset.target))})}function _(t){let n=document.getElementById(t),r=document.getElementById(`home-content-area`);if(!n||!r)return;let i=n.parentElement;for(;i&&i!==r;)i.tagName===`DETAILS`&&!i.open&&(i.open=!0),i=i.parentElement;e.querySelectorAll(`mark.ld-local-mark.ld-local-active`).forEach(e=>e.classList.remove(`ld-local-active`)),n.classList.add(`ld-local-active`),f.querySelectorAll(`.ld-local-item`).forEach(e=>{e.classList.toggle(`ld-local-item-active`,e.dataset.target===t)});let a=document.querySelector(`#home-doc-view header`),o=a?a.getBoundingClientRect().height:0,s=n.getBoundingClientRect().top,c=r.getBoundingClientRect().top,l=o+(r.clientHeight-o)/3;r.scrollTop+=s-c-l}c.addEventListener(`input`,()=>{p&&clearTimeout(p),p=window.setTimeout(()=>g(c.value.trim()),250)}),l.addEventListener(`click`,()=>{c.value=``,g(``),c.focus()}),c.addEventListener(`keydown`,e=>{e.key===`Escape`&&(c.value=``,g(``),c.blur())})}var Tv={codeLabel:`Code block.`,imageLabel:`Image: {alt}.`,diagramLabel:`Diagram.`,tableLabel:`Table.`,readCode:!1},Ev=new Set([`H1`,`H2`,`H3`,`H4`,`H5`,`H6`]);function Dv(e){return e.classList.contains(`mermaid`)||e.querySelector(`.mermaid`)!==null}function Ov(e){let t=[];for(let n of e.matchAll(/[^.!?…\n]*(?:[.!?…]+|\n+|$)/g)){let e=n[0];if(e.length===0)continue;let r=e.length-e.trimStart().length,i=e.trim();if(i){let e=n.index+r;t.push({text:i,start:e,end:e+i.length})}}return t}function kv(e,t){let n=(e.textContent??``).replace(/\s+/g,` `).trim();if(!n)return null;let r=Ov(n);return{type:t,el:e,spokenText:n,sentences:r.length?r:[{text:n,start:0,end:n.length}],highlightWhole:!1}}function Av(e,t,n){let r=n.trim();return r?{type:t,el:e,spokenText:r,sentences:[{text:r,start:0,end:r.length}],highlightWhole:!0}:null}function jv(e,t,n){for(let r of Array.from(e.children)){let e=r.tagName;if(Dv(r)){Mv(n,Av(r,`diagram`,t.diagramLabel));continue}if(e===`PRE`||e===`DIV`&&r.querySelector(`:scope > pre`)){Mv(n,t.readCode?kv(r,`code`):Av(r,`code`,t.codeLabel));continue}if(e===`TABLE`){Mv(n,Av(r,`table`,t.tableLabel));continue}if(e===`IMG`||e===`FIGURE`&&r.querySelector(`img`)){let i=(e===`IMG`?r:r.querySelector(`img`))?.getAttribute(`alt`)?.trim()??``;Mv(n,Av(r,`image`,t.imageLabel.includes(`{alt}`)?i?t.imageLabel.replace(`{alt}`,i):t.imageLabel.replace(/:?\s*\{alt\}/,``).trim()||`Image.`:t.imageLabel));continue}if(Ev.has(e)){Mv(n,kv(r,`heading`));continue}if(e===`P`){Mv(n,kv(r,`paragraph`));continue}if(e===`LI`){Mv(n,kv(r,`list-item`));continue}if(e===`BLOCKQUOTE`){r.querySelector(`:scope > p, :scope > ul, :scope > ol`)?jv(r,t,n):Mv(n,kv(r,`quote`));continue}if(e===`UL`||e===`OL`||e===`DIV`||e===`SECTION`||e===`DETAILS`){jv(r,t,n);continue}}}function Mv(e,t){t&&e.push(t)}function Nv(e,t={}){let n={...Tv,...t},r=[];return jv(e,n,r),r}var Pv=`tts-sentence`;function Fv(){if(typeof document>`u`||document.getElementById(`tts-highlight-style`))return;let e=document.createElement(`style`);e.id=`tts-highlight-style`,e.textContent=`::highlight(${Pv}){background-color:rgba(250,204,21,0.45);color:inherit;}.dark ::highlight(${Pv}){background-color:rgba(250,204,21,0.35);}`,document.head.appendChild(e)}function Iv(e,t,n){let r=[],i=!0,a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=a.nextNode();for(;o;){let e=o.data;for(let t=0;t<e.length;t++)/\s/.test(e[t])?i||=(r.push({node:o,offset:t}),!0):(r.push({node:o,offset:t}),i=!1);o=a.nextNode()}if(t>=r.length)return null;let s=r[t],c=document.createRange();if(c.setStart(s.node,s.offset),n<r.length){let e=r[n];c.setEnd(e.node,e.offset)}else{let e=r[r.length-1];c.setEnd(e.node,e.offset+1)}return c}var Lv=new class{#e=P(`idle`);get status(){return V(this.#e)}set status(e){F(this.#e,e,!0)}#t=P(-1);get index(){return V(this.#t)}set index(e){F(this.#t,e,!0)}#n=P(0);get total(){return V(this.#n)}set total(e){F(this.#n,e,!0)}#r=P(null);get error(){return V(this.#r)}set error(e){F(this.#r,e,!0)}units=[];ctx=null;source=null;cache=new Map;token=0;voice;speed;language=`en`;fallbackEl=null;get active(){return this.status===`playing`||this.status===`paused`||this.status===`loading`}async start(e,t={}){this.stop();let{voice:n,speed:r,language:i,...a}=t;this.voice=n,this.speed=r,this.language=i??`en`;let o=Nv(e,a);if(this.units=o.flatMap(e=>e.highlightWhole?[{seg:e,text:e.spokenText,start:0,end:e.spokenText.length,whole:!0}]:e.sentences.map(t=>({seg:e,text:t.text,start:t.start,end:t.end,whole:!1}))),this.total=this.units.length,this.units.length===0)return;this.ctx=new AudioContext,this.error=null;let s=++this.token;this.status=`loading`,await this.playFrom(0,s)}async playFrom(e,t){if(t!==this.token)return;if(e>=this.units.length){this.stop();return}this.index=e,this.highlight(this.units[e]);let n;try{n=await this.audioFor(e)}catch(e){if(t!==this.token)return;this.error=e instanceof Error?e.message:String(e),this.stop(!1);return}if(t!==this.token||!this.ctx)return;this.prefetch(e+1);let r=this.ctx.createBufferSource();r.buffer=n,r.connect(this.ctx.destination),r.onended=()=>{t===this.token&&(this.source=null,this.playFrom(e+1,t))},this.source=r,this.status=`playing`,r.start()}audioFor(e){let t=this.cache.get(e);return t||(t=this.fetchAudio(this.units[e].text),this.cache.set(e,t)),t}prefetch(e){e<this.units.length&&!this.cache.has(e)&&this.cache.set(e,this.fetchAudio(this.units[e].text).catch(e=>Promise.reject(e)))}async fetchAudio(e){let t=await fetch(`/api/tts`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,voice:this.voice,speed:this.speed,language:this.language})});if(!t.ok){let e=`HTTP ${t.status}`;try{e=(await t.json()).error||e}catch{}throw Error(e)}let n=await t.arrayBuffer();return this.ctx?.decodeAudioData(n)}pause(){this.status===`playing`&&this.ctx&&(this.ctx.suspend(),this.status=`paused`)}resume(){this.status===`paused`&&this.ctx&&(this.ctx.resume(),this.status=`playing`)}toggle(){this.status===`playing`?this.pause():this.status===`paused`&&this.resume()}stop(e=!0){if(this.token++,this.source){try{this.source.onended=null,this.source.stop()}catch{}this.source=null}this.ctx&&=(this.ctx.close(),null),this.cache.clear(),this.clearHighlight(),this.status=`idle`,this.index=-1,this.total=0,e&&(this.error=null)}highlight(e){Fv(),this.clearHighlight();let t=typeof CSS<`u`&&`highlights`in CSS&&typeof Highlight<`u`;if(t&&!e.whole){let t=Iv(e.seg.el,e.start,e.end);t?CSS.highlights.set(Pv,new Highlight(t)):this.fallbackHighlight(e.seg.el)}else if(t){let t=document.createRange();t.selectNodeContents(e.seg.el),CSS.highlights.set(Pv,new Highlight(t))}else this.fallbackHighlight(e.seg.el);e.seg.el.scrollIntoView({block:`center`,behavior:`smooth`})}fallbackHighlight(e){e.classList.add(`tts-active`),this.fallbackEl=e}clearHighlight(){typeof CSS<`u`&&`highlights`in CSS&&CSS.highlights.delete(Pv),this.fallbackEl&&=(this.fallbackEl.classList.remove(`tts-active`),null)}},Rv=Symbol.for(`yaml.alias`),zv=Symbol.for(`yaml.document`),Bv=Symbol.for(`yaml.map`),Vv=Symbol.for(`yaml.pair`),Hv=Symbol.for(`yaml.scalar`),Uv=Symbol.for(`yaml.seq`),Wv=Symbol.for(`yaml.node.type`),Gv=e=>!!e&&typeof e==`object`&&e[Wv]===Rv,Kv=e=>!!e&&typeof e==`object`&&e[Wv]===zv,qv=e=>!!e&&typeof e==`object`&&e[Wv]===Bv,Jv=e=>!!e&&typeof e==`object`&&e[Wv]===Vv,Yv=e=>!!e&&typeof e==`object`&&e[Wv]===Hv,Xv=e=>!!e&&typeof e==`object`&&e[Wv]===Uv;function Zv(e){if(e&&typeof e==`object`)switch(e[Wv]){case Bv:case Uv:return!0}return!1}function Qv(e){if(e&&typeof e==`object`)switch(e[Wv]){case Rv:case Bv:case Hv:case Uv:return!0}return!1}var $v=e=>(Yv(e)||Zv(e))&&!!e.anchor,ey=Symbol(`break visit`),ty=Symbol(`skip children`),ny=Symbol(`remove node`);function ry(e,t){let n=sy(t);Kv(e)?iy(null,e.contents,n,Object.freeze([e]))===ny&&(e.contents=null):iy(null,e,n,Object.freeze([]))}ry.BREAK=ey,ry.SKIP=ty,ry.REMOVE=ny;function iy(e,t,n,r){let i=cy(e,t,n,r);if(Qv(i)||Jv(i))return ly(e,r,i),iy(e,i,n,r);if(typeof i!=`symbol`){if(Zv(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=iy(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===ey)return ey;else i===ny&&(t.items.splice(e,1),--e)}}else if(Jv(t)){r=Object.freeze(r.concat(t));let e=iy(`key`,t.key,n,r);if(e===ey)return ey;e===ny&&(t.key=null);let i=iy(`value`,t.value,n,r);if(i===ey)return ey;i===ny&&(t.value=null)}}return i}async function ay(e,t){let n=sy(t);Kv(e)?await oy(null,e.contents,n,Object.freeze([e]))===ny&&(e.contents=null):await oy(null,e,n,Object.freeze([]))}ay.BREAK=ey,ay.SKIP=ty,ay.REMOVE=ny;async function oy(e,t,n,r){let i=await cy(e,t,n,r);if(Qv(i)||Jv(i))return ly(e,r,i),oy(e,i,n,r);if(typeof i!=`symbol`){if(Zv(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await oy(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===ey)return ey;else i===ny&&(t.items.splice(e,1),--e)}}else if(Jv(t)){r=Object.freeze(r.concat(t));let e=await oy(`key`,t.key,n,r);if(e===ey)return ey;e===ny&&(t.key=null);let i=await oy(`value`,t.value,n,r);if(i===ey)return ey;i===ny&&(t.value=null)}}return i}function sy(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function cy(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(qv(t))return n.Map?.(e,t,r);if(Xv(t))return n.Seq?.(e,t,r);if(Jv(t))return n.Pair?.(e,t,r);if(Yv(t))return n.Scalar?.(e,t,r);if(Gv(t))return n.Alias?.(e,t,r)}function ly(e,t,n){let r=t[t.length-1];if(Zv(r))r.items[e]=n;else if(Jv(r))e===`key`?r.key=n:r.value=n;else if(Kv(r))r.contents=n;else{let e=Gv(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var uy={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},dy=e=>e.replace(/[!,[\]{}]/g,e=>uy[e]),fy=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+dy(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Qv(e.contents)){let t={};ry(e.contents,(e,n)=>{Qv(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
118
+ `)}};fy.defaultYaml={explicit:!1,version:`1.2`},fy.defaultTags={"!!":`tag:yaml.org,2002:`};function py(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function my(e){let t=new Set;return ry(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function hy(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function gy(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i||=my(e);let a=hy(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(Yv(t.node)||Zv(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function _y(e,t,n,r){if(r&&typeof r==`object`)if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=_y(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=_y(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=_y(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=_y(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function vy(e,t,n){if(Array.isArray(e))return e.map((e,t)=>vy(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!$v(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var yy=class{constructor(e){Object.defineProperty(this,Wv,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Kv(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=vy(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?_y(i,{"":o},``,o):o}},by=class extends yy{constructor(e){super(Rv),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e){let t;return ry(e,{Node:(e,n)=>{if(n===this)return ry.BREAK;n.anchor===this.source&&(t=n)}}),t}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(vy(a,null,t),n.get(a)),!o||o.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=xy(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(py(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function xy(e,t,n){if(Gv(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(Zv(t)){let r=0;for(let i of t.items){let t=xy(e,i,n);t>r&&(r=t)}return r}else if(Jv(t)){let r=xy(e,t.key,n),i=xy(e,t.value,n);return Math.max(r,i)}return 1}var Sy=e=>!e||typeof e!=`function`&&typeof e!=`object`,Cy=class extends yy{constructor(e){super(Hv),this.value=e}toJSON(e,t){return t?.keep?this.value:vy(this.value,e,t)}toString(){return String(this.value)}};Cy.BLOCK_FOLDED=`BLOCK_FOLDED`,Cy.BLOCK_LITERAL=`BLOCK_LITERAL`,Cy.PLAIN=`PLAIN`,Cy.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Cy.QUOTE_SINGLE=`QUOTE_SINGLE`;var wy=`tag:yaml.org,2002:`;function Ty(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Ey(e,t,n){if(Kv(e)&&(e=e.contents),Qv(e))return e;if(Jv(e)){let t=n.schema[Bv].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor||=i(e),new by(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=wy+t.slice(2));let l=Ty(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new Cy(e);return c&&(c.node=t),t}l=e instanceof Map?o[Bv]:Symbol.iterator in Object(e)?o[Uv]:o[Bv]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new Cy(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Dy(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return Ey(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var Oy=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,ky=class extends yy{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>Qv(t)||Jv(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Oy(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(Zv(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Dy(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(Zv(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&Yv(i)?i.value:i:Zv(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!Jv(t))return!1;let n=t.value;return n==null||e&&Yv(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return Zv(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(Zv(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Dy(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},Ay=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function jy(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var My=(e,t,n)=>e.endsWith(`
119
+ `)?jy(n,t):n.includes(`
120
120
  `)?`
121
- `+ky(n,t):(e.endsWith(` `)?``:` `)+n,jy=`flow`,My=`block`,Ny=`quoted`;function Py(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=Fy(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
122
- `)n===`block`&&(h=Fy(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
121
+ `+jy(n,t):(e.endsWith(` `)?``:` `)+n,Ny=`flow`,Py=`block`,Fy=`quoted`;function Iy(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=Ly(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
122
+ `)n===`block`&&(h=Ly(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
123
123
  `&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
124
- `&&t!==` `&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function Fy(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
125
- `);r=t,i=t+1,a=e[i]}return r}var Iy=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Ly=e=>/^(%|---|\.\.\.)/m.test(e);function Ry(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
126
- `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function zy(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(Ly(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
124
+ `&&t!==` `&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function Ly(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
125
+ `);r=t,i=t+1,a=e[i]}return r}var Ry=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),zy=e=>/^(%|---|\.\.\.)/m.test(e);function By(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
126
+ `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function Vy(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(zy(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
127
127
 
128
128
  `;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
129
- `,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:Py(o,a,Ny,Iy(t,!1))}function By(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
130
- `)||/[ \t]\n|\n[ \t]/.test(e))return zy(e,t);let n=t.indent||(Ly(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:Py(r,n,jy,Iy(t,!1))}function Vy(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=zy;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?By:i&&!t?zy:n?By:zy}return r(e,t)}var Hy;try{Hy=RegExp(`(^|(?<!
129
+ `,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:Iy(o,a,Fy,Ry(t,!1))}function Hy(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
130
+ `)||/[ \t]\n|\n[ \t]/.test(e))return Vy(e,t);let n=t.indent||(zy(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:Iy(r,n,Ny,Ry(t,!1))}function Uy(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=Vy;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?Hy:i&&!t?Vy:n?Hy:Vy}return r(e,t)}var Wy;try{Wy=RegExp(`(^|(?<!
131
131
  ))
132
132
  +(?!
133
- |$)`,`g`)}catch{Hy=/\n+(?!\n|$)/g}function Uy({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n)||/^\s*$/.test(n))return Vy(n,r);let l=r.indent||(r.forceBlockIndent||Ly(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===xy.BLOCK_FOLDED?!1:t===xy.BLOCK_LITERAL?!0:!Ry(n,c,l.length);if(!n)return u?`|
133
+ |$)`,`g`)}catch{Wy=/\n+(?!\n|$)/g}function Gy({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n)||/^\s*$/.test(n))return Uy(n,r);let l=r.indent||(r.forceBlockIndent||zy(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===Cy.BLOCK_FOLDED?!1:t===Cy.BLOCK_LITERAL?!0:!By(n,c,l.length);if(!n)return u?`|
134
134
  `:`>
135
135
  `;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
136
136
  `&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
137
137
  `);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
138
- `&&(p=p.slice(0,-1)),p.replace(Hy,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
138
+ `&&(p=p.slice(0,-1)),p.replace(Wy,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
139
139
  `)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(u?`|`:`>`)+(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),u)return n=n.replace(/\n+/g,`$&${l}`),`${y}\n${l}${v}${n}${p}`;n=n.replace(/\n+/g,`
140
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`);let b=Py(`${v}${n}${p}`,l,My,Iy(r,!0));return`${y}\n${l}${b}`}function Wy(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
141
- `)||u&&/[[\]{},]/.test(a))return Vy(a,t);if(!a||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
142
- `)?Vy(a,t):Uy(e,t,n,r);if(!s&&!u&&i!==xy.PLAIN&&a.includes(`
143
- `))return Uy(e,t,n,r);if(Ly(a)){if(c===``)return t.forceBlockIndent=!0,Uy(e,t,n,r);if(s&&c===l)return Vy(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return Vy(a,t)}return s?d:Py(d,c,jy,Iy(t,!1))}function Gy(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==xy.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=xy.QUOTE_DOUBLE);let c=e=>{switch(e){case xy.BLOCK_FOLDED:case xy.BLOCK_LITERAL:return i||a?Vy(o.value,t):Uy(o,t,n,r);case xy.QUOTE_DOUBLE:return zy(o.value,t);case xy.QUOTE_SINGLE:return By(o.value,t);case xy.PLAIN:return Wy(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function Ky(e,t){let n=Object.assign({blockQuote:!0,commentString:Oy,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function qy(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(qv(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??typeof r;throw Error(`Tag not resolved for ${e} value`)}return n}function Jy(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(qv(e)||Yv(e))&&e.anchor;a&&dy(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag?e.tag:t.default?null:t.tag;return o&&i.push(r.directives.tagString(o)),i.join(` `)}function Yy(e,t,n,r){if(Kv(e))return e.toString(t,n,r);if(Uv(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=Xv(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i||=qy(t.doc.schema.tags,a);let o=Jy(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):qv(a)?Gy(a,t,n,r):a.toString(t,n,r);return o?qv(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function Xy({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=Xv(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(Yv(e)||!Xv(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||Yv(e)||(qv(e)?e.type===xy.BLOCK_FOLDED||e.type===xy.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=Yy(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=Ay(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=Ay(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=Ay(g,n.indent,l(f))));let _,v,y;Xv(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&qv(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Jv(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=Yy(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
144
- `:``,v){let e=l(v);S+=`\n${ky(e,n.indent)}`}x===``&&!n.inFlow?S===`
140
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`);let b=Iy(`${v}${n}${p}`,l,Py,Ry(r,!0));return`${y}\n${l}${b}`}function Ky(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
141
+ `)||u&&/[[\]{},]/.test(a))return Uy(a,t);if(!a||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
142
+ `)?Uy(a,t):Gy(e,t,n,r);if(!s&&!u&&i!==Cy.PLAIN&&a.includes(`
143
+ `))return Gy(e,t,n,r);if(zy(a)){if(c===``)return t.forceBlockIndent=!0,Gy(e,t,n,r);if(s&&c===l)return Uy(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return Uy(a,t)}return s?d:Iy(d,c,Ny,Ry(t,!1))}function qy(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==Cy.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Cy.QUOTE_DOUBLE);let c=e=>{switch(e){case Cy.BLOCK_FOLDED:case Cy.BLOCK_LITERAL:return i||a?Uy(o.value,t):Gy(o,t,n,r);case Cy.QUOTE_DOUBLE:return Vy(o.value,t);case Cy.QUOTE_SINGLE:return Hy(o.value,t);case Cy.PLAIN:return Ky(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function Jy(e,t){let n=Object.assign({blockQuote:!0,commentString:Ay,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function Yy(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(Yv(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??typeof r;throw Error(`Tag not resolved for ${e} value`)}return n}function Xy(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(Yv(e)||Zv(e))&&e.anchor;a&&py(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag?e.tag:t.default?null:t.tag;return o&&i.push(r.directives.tagString(o)),i.join(` `)}function Zy(e,t,n,r){if(Jv(e))return e.toString(t,n,r);if(Gv(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=Qv(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i||=Yy(t.doc.schema.tags,a);let o=Xy(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):Yv(a)?qy(a,t,n,r):a.toString(t,n,r);return o?Yv(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function Qy({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=Qv(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(Zv(e)||!Qv(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||Zv(e)||(Yv(e)?e.type===Cy.BLOCK_FOLDED||e.type===Cy.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=Zy(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=My(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=My(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=My(g,n.indent,l(f))));let _,v,y;Qv(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&Yv(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Xv(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=Zy(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
144
+ `:``,v){let e=l(v);S+=`\n${jy(e,n.indent)}`}x===``&&!n.inFlow?S===`
145
145
  `&&(S=`
146
146
 
147
- `):S+=`\n${n.indent}`}else if(!p&&Yv(t)){let e=x[0],r=x.indexOf(`
147
+ `):S+=`\n${n.indent}`}else if(!p&&Zv(t)){let e=x[0],r=x.indexOf(`
148
148
  `),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
149
- `)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=Ay(g,n.indent,l(y)):h&&i&&i(),g}function Zy(e,t){(e===`debug`||e===`warn`)&&(typeof process<`u`&&process.emitWarning?process.emitWarning(t):console.warn(t))}var Qy=`<<`;function $y(e,t,{key:n,value:r}){if(e?.doc.schema.merge&&eb(n))if(r=Uv(r)?r.resolve(e.doc):r,Jv(r))for(let n of r.items)tb(e,t,n);else if(Array.isArray(r))for(let n of r)tb(e,t,n);else tb(e,t,r);else{let i=gy(n,``,e);if(t instanceof Map)t.set(i,gy(r,i,e));else if(t instanceof Set)t.add(i);else{let a=nb(n,i,e),o=gy(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}var eb=e=>e===Qy||qv(e)&&e.value===Qy&&(!e.type||e.type===xy.PLAIN);function tb(e,t,n){let r=e&&Uv(n)?n.resolve(e.doc):n;if(!Gv(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function nb(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(Xv(e)&&n?.doc){let t=Ky(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),Zy(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function rb(e,t,n){return new ib(wy(e,void 0,n),wy(t,void 0,n))}var ib=class e{constructor(e,t=null){Object.defineProperty(this,Hv,{value:zv}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return Xv(n)&&(n=n.clone(t)),Xv(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return $y(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?Xy(this,e,t,n):JSON.stringify(this)}};function ab(e,t,n){return(t.inFlow??e.flow?sb:ob)(e,t,n)}function ob({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(Xv(i))!d&&i.spaceBefore&&f.push(``),cb(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(Kv(i)){let e=Xv(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),cb(n,f,e.commentBefore,d))}d=!1;let s=Yy(i,u,()=>o=null,()=>d=!0);o&&(s+=Ay(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
149
+ `)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=My(g,n.indent,l(y)):h&&i&&i(),g}function $y(e,t){(e===`debug`||e===`warn`)&&(typeof process<`u`&&process.emitWarning?process.emitWarning(t):console.warn(t))}var eb=`<<`;function tb(e,t,{key:n,value:r}){if(e?.doc.schema.merge&&nb(n))if(r=Gv(r)?r.resolve(e.doc):r,Xv(r))for(let n of r.items)rb(e,t,n);else if(Array.isArray(r))for(let n of r)rb(e,t,n);else rb(e,t,r);else{let i=vy(n,``,e);if(t instanceof Map)t.set(i,vy(r,i,e));else if(t instanceof Set)t.add(i);else{let a=ib(n,i,e),o=vy(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}var nb=e=>e===eb||Yv(e)&&e.value===eb&&(!e.type||e.type===Cy.PLAIN);function rb(e,t,n){let r=e&&Gv(n)?n.resolve(e.doc):n;if(!qv(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function ib(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(Qv(e)&&n?.doc){let t=Jy(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),$y(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function ab(e,t,n){return new ob(Ey(e,void 0,n),Ey(t,void 0,n))}var ob=class e{constructor(e,t=null){Object.defineProperty(this,Wv,{value:Vv}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return Qv(n)&&(n=n.clone(t)),Qv(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return tb(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?Qy(this,e,t,n):JSON.stringify(this)}};function sb(e,t,n){return(t.inFlow??e.flow?lb:cb)(e,t,n)}function cb({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(Qv(i))!d&&i.spaceBefore&&f.push(``),ub(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(Jv(i)){let e=Qv(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),ub(n,f,e.commentBefore,d))}d=!1;let s=Zy(i,u,()=>o=null,()=>d=!0);o&&(s+=My(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
150
150
  `}}return e?(p+=`
151
- `+ky(l(e),c),s&&s()):d&&o&&o(),p}function sb({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(Xv(i))i.spaceBefore&&d.push(``),cb(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(Kv(i)){let e=Xv(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),cb(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=Xv(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Yy(i,c,()=>a=null);n<e.length-1&&(o+=`,`),a&&(o+=Ay(o,r,s(a))),!l&&(d.length>u||o.includes(`
151
+ `+jy(l(e),c),s&&s()):d&&o&&o(),p}function lb({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(Qv(i))i.spaceBefore&&d.push(``),ub(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(Jv(i)){let e=Qv(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),ub(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=Qv(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Zy(i,c,()=>a=null);n<e.length-1&&(o+=`,`),a&&(o+=My(o,r,s(a))),!l&&(d.length>u||o.includes(`
152
152
  `))&&(l=!0),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
153
- `;return`${e}\n${i}${p}`}else return`${f}${o}${d.join(` `)}${o}${p}`}function cb({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=ky(t(r),e);n.push(i.trimStart())}}function lb(e,t){let n=qv(t)?t.value:t;for(let r of e)if(Kv(r)&&(r.key===t||r.key===n||qv(r.key)&&r.key.value===n))return r}var ub=class extends Dy{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Rv,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(rb(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=Kv(e)?e:!e||typeof e!=`object`||!(`key`in e)?new ib(e,e?.value):new ib(e.key,e.value);let r=lb(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);qv(r.value)&&by(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=lb(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=lb(this.items,e)?.value;return(!t&&qv(n)?n.value:n)??void 0}has(e){return!!lb(this.items,e)}set(e,t){this.add(new ib(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)$y(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!Kv(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),ab(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},db={collection:`map`,default:!0,nodeClass:ub,tag:`tag:yaml.org,2002:map`,resolve(e,t){return Gv(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>ub.from(e,t,n)},fb=class extends Dy{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Vv,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=pb(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=pb(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&qv(r)?r.value:r}has(e){let t=pb(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=pb(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];qv(r)&&by(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(gy(e,String(r++),t));return n}toString(e,t,n){return e?ab(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(wy(a,void 0,n))}}return i}};function pb(e){let t=qv(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var mb={collection:`seq`,default:!0,nodeClass:fb,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Jv(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>fb.from(e,t,n)},hb={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),Gy(e,t,n,r)}},gb={identify:e=>e==null,createNode:()=>new xy(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new xy(null),stringify:({source:e},t)=>typeof e==`string`&&gb.test.test(e)?e:t.options.nullStr},_b={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new xy(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&_b.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function vb({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var yb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:vb},bb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():vb(e)}},xb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new xy(parseFloat(e)),n=e.indexOf(`.`);return n!==-1&&e[e.length-1]===`0`&&(t.minFractionDigits=e.length-n-1),t},stringify:vb},Sb=e=>typeof e==`bigint`||Number.isInteger(e),Cb=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function wb(e,t,n){let{value:r}=e;return Sb(r)&&r>=0?n+r.toString(t):vb(e)}var Tb={identify:e=>Sb(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>Cb(e,2,8,n),stringify:e=>wb(e,8,`0o`)},Eb={identify:Sb,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Cb(e,0,10,n),stringify:vb},Db={identify:e=>Sb(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Cb(e,2,16,n),stringify:e=>wb(e,16,`0x`)},Ob=[db,mb,hb,gb,_b,Tb,Eb,Db,yb,bb,xb];function kb(e){return typeof e==`bigint`||Number.isInteger(e)}var Ab=({value:e})=>JSON.stringify(e),jb=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:Ab},{identify:e=>e==null,createNode:()=>new xy(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:Ab},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true|false$/,resolve:e=>e===`true`,stringify:Ab},{identify:kb,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>kb(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Ab}],Mb=[db,mb].concat(jb,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),Nb={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,t){if(typeof Buffer==`function`)return Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}else return t(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:t,value:n},r,i,a){let o=n,s;if(typeof Buffer==`function`)s=o instanceof Buffer?o.toString(`base64`):Buffer.from(o.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);s=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(t||=xy.BLOCK_LITERAL,t!==xy.QUOTE_DOUBLE){let e=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),n=Math.ceil(s.length/e),i=Array(n);for(let t=0,r=0;t<n;++t,r+=e)i[t]=s.substr(r,e);s=i.join(t===xy.BLOCK_LITERAL?`
154
- `:` `)}return Gy({comment:e,type:t,value:s},r,i,a)}};function Pb(e,t){if(Jv(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!Kv(r)){if(Gv(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new ib(new xy(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=Kv(r)?r:new ib(r)}}else t(`Expected a sequence for this tag`);return e}function Fb(e,t,n){let{replacer:r}=n,i=new fb(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e))if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(rb(o,s,n))}return i}var Ib={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:Pb,createNode:Fb},Lb=class e extends fb{constructor(){super(),this.add=ub.prototype.add.bind(this),this.delete=ub.prototype.delete.bind(this),this.get=ub.prototype.get.bind(this),this.has=ub.prototype.has.bind(this),this.set=ub.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(Kv(e)?(r=gy(e.key,``,t),i=gy(e.value,r,t)):r=gy(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=Fb(e,t,n),i=new this;return i.items=r.items,i}};Lb.tag=`tag:yaml.org,2002:omap`;var Rb={collection:`seq`,identify:e=>e instanceof Map,nodeClass:Lb,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=Pb(e,t),r=[];for(let{key:e}of n.items)qv(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new Lb,n)},createNode:(e,t,n)=>Lb.from(e,t,n)};function zb({value:e,source:t},n){return t&&(e?Bb:Vb).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var Bb={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new xy(!0),stringify:zb},Vb={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new xy(!1),stringify:zb},Hb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:vb},Ub={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():vb(e)}},Wb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new xy(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:vb},Gb=e=>typeof e==`bigint`||Number.isInteger(e);function Kb(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function qb(e,t,n){let{value:r}=e;if(Gb(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return vb(e)}var Jb={identify:Gb,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Kb(e,2,2,n),stringify:e=>qb(e,2,`0b`)},Yb={identify:Gb,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Kb(e,1,8,n),stringify:e=>qb(e,8,`0`)},Xb={identify:Gb,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Kb(e,0,10,n),stringify:vb},Zb={identify:Gb,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Kb(e,2,16,n),stringify:e=>qb(e,16,`0x`)},Qb=class e extends ub{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=Kv(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new ib(e.key,null):new ib(e,null),lb(this.items,t.key)||this.items.push(t)}get(e,t){let n=lb(this.items,e);return!t&&Kv(n)?qv(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=lb(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new ib(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(rb(e,null,n));return i}};Qb.tag=`tag:yaml.org,2002:set`;var $b={collection:`map`,identify:e=>e instanceof Set,nodeClass:Qb,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>Qb.from(e,t,n),resolve(e,t){if(Gv(e)){if(e.hasAllNullValues(!0))return Object.assign(new Qb,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function ex(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function tx(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return vb(e);let r=``;t<0&&(r=`-`,t*=n(-1));let i=n(60),a=[t%i];return t<60?a.unshift(0):(t=(t-a[0])/i,a.unshift(t%i),t>=60&&(t=(t-a[0])/i,a.unshift(t))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}var nx={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>ex(e,n),stringify:tx},rx={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>ex(e,!1),stringify:tx},ix={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(ix.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,i,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+`00`).substr(1,3)):0,l=Date.UTC(n,r-1,i,a||0,o||0,s||0,c),u=t[8];if(u&&u!==`Z`){let e=ex(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e.toISOString().replace(/((T00:00)?:00)?\.000Z$/,``)},ax=[db,mb,hb,gb,Bb,Vb,Jb,Yb,Xb,Zb,Hb,Ub,Wb,Nb,Rb,Ib,$b,nx,rx,ix],ox=new Map([[`core`,Ob],[`failsafe`,[db,mb,hb]],[`json`,Mb],[`yaml11`,ax],[`yaml-1.1`,ax]]),sx={binary:Nb,bool:_b,float:xb,floatExp:bb,floatNaN:yb,floatTime:rx,int:Eb,intHex:Db,intOct:Tb,intTime:nx,map:db,null:gb,omap:Rb,pairs:Ib,seq:mb,set:$b,timestamp:ix},cx={"tag:yaml.org,2002:binary":Nb,"tag:yaml.org,2002:omap":Rb,"tag:yaml.org,2002:pairs":Ib,"tag:yaml.org,2002:set":$b,"tag:yaml.org,2002:timestamp":ix};function lx(e,t){let n=ox.get(t);if(!n)if(Array.isArray(e))n=[];else{let e=Array.from(ox.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)n=n.concat(t);else typeof e==`function`&&(n=e(n.slice()));return n.map(e=>{if(typeof e!=`string`)return e;let t=sx[e];if(t)return t;let n=Object.keys(sx).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag "${e}"; use one of ${n}`)})}var ux=(e,t)=>e.key<t.key?-1:+(e.key>t.key),dx=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?lx(e,`compat`):e?lx(null,e):null,this.merge=!!n,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?cx:{},this.tags=lx(t,this.name),this.toStringOptions=o??null,Object.defineProperty(this,Rv,{value:db}),Object.defineProperty(this,Bv,{value:hb}),Object.defineProperty(this,Vv,{value:mb}),this.sortMapEntries=typeof a==`function`?a:a===!0?ux:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function fx(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(n.push(t),r=!0):e.directives.docStart&&(r=!0)}r&&n.push(`---`);let i=Ky(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(ky(t,``))}let o=!1,s=null;if(e.contents){if(Xv(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(ky(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=Yy(e.contents,i,()=>s=null,t);s&&(c+=Ay(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Yy(e.contents,i));if(e.directives?.docEnd)if(e.comment){let t=a(e.comment);t.includes(`
155
- `)?(n.push(`...`),n.push(ky(t,``))):n.push(`... ${t}`)}else n.push(`...`);else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(ky(a(t),``)))}return n.join(`
153
+ `;return`${e}\n${i}${p}`}else return`${f}${o}${d.join(` `)}${o}${p}`}function ub({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=jy(t(r),e);n.push(i.trimStart())}}function db(e,t){let n=Yv(t)?t.value:t;for(let r of e)if(Jv(r)&&(r.key===t||r.key===n||Yv(r.key)&&r.key.value===n))return r}var fb=class extends ky{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Bv,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(ab(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=Jv(e)?e:!e||typeof e!=`object`||!(`key`in e)?new ob(e,e?.value):new ob(e.key,e.value);let r=db(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);Yv(r.value)&&Sy(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=db(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=db(this.items,e)?.value;return(!t&&Yv(n)?n.value:n)??void 0}has(e){return!!db(this.items,e)}set(e,t){this.add(new ob(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)tb(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!Jv(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),sb(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},pb={collection:`map`,default:!0,nodeClass:fb,tag:`tag:yaml.org,2002:map`,resolve(e,t){return qv(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>fb.from(e,t,n)},mb=class extends ky{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Uv,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=hb(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=hb(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&Yv(r)?r.value:r}has(e){let t=hb(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=hb(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];Yv(r)&&Sy(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(vy(e,String(r++),t));return n}toString(e,t,n){return e?sb(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(Ey(a,void 0,n))}}return i}};function hb(e){let t=Yv(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var gb={collection:`seq`,default:!0,nodeClass:mb,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Xv(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>mb.from(e,t,n)},_b={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),qy(e,t,n,r)}},vb={identify:e=>e==null,createNode:()=>new Cy(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Cy(null),stringify:({source:e},t)=>typeof e==`string`&&vb.test.test(e)?e:t.options.nullStr},yb={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Cy(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&yb.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function bb({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var xb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:bb},Sb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():bb(e)}},Cb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new Cy(parseFloat(e)),n=e.indexOf(`.`);return n!==-1&&e[e.length-1]===`0`&&(t.minFractionDigits=e.length-n-1),t},stringify:bb},wb=e=>typeof e==`bigint`||Number.isInteger(e),Tb=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function Eb(e,t,n){let{value:r}=e;return wb(r)&&r>=0?n+r.toString(t):bb(e)}var Db={identify:e=>wb(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>Tb(e,2,8,n),stringify:e=>Eb(e,8,`0o`)},Ob={identify:wb,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Tb(e,0,10,n),stringify:bb},kb={identify:e=>wb(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Tb(e,2,16,n),stringify:e=>Eb(e,16,`0x`)},Ab=[pb,gb,_b,vb,yb,Db,Ob,kb,xb,Sb,Cb];function jb(e){return typeof e==`bigint`||Number.isInteger(e)}var Mb=({value:e})=>JSON.stringify(e),Nb=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:Mb},{identify:e=>e==null,createNode:()=>new Cy(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:Mb},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true|false$/,resolve:e=>e===`true`,stringify:Mb},{identify:jb,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>jb(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Mb}],Pb=[pb,gb].concat(Nb,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),Fb={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,t){if(typeof Buffer==`function`)return Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}else return t(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:t,value:n},r,i,a){let o=n,s;if(typeof Buffer==`function`)s=o instanceof Buffer?o.toString(`base64`):Buffer.from(o.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);s=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(t||=Cy.BLOCK_LITERAL,t!==Cy.QUOTE_DOUBLE){let e=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),n=Math.ceil(s.length/e),i=Array(n);for(let t=0,r=0;t<n;++t,r+=e)i[t]=s.substr(r,e);s=i.join(t===Cy.BLOCK_LITERAL?`
154
+ `:` `)}return qy({comment:e,type:t,value:s},r,i,a)}};function Ib(e,t){if(Xv(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!Jv(r)){if(qv(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new ob(new Cy(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=Jv(r)?r:new ob(r)}}else t(`Expected a sequence for this tag`);return e}function Lb(e,t,n){let{replacer:r}=n,i=new mb(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e))if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(ab(o,s,n))}return i}var Rb={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:Ib,createNode:Lb},zb=class e extends mb{constructor(){super(),this.add=fb.prototype.add.bind(this),this.delete=fb.prototype.delete.bind(this),this.get=fb.prototype.get.bind(this),this.has=fb.prototype.has.bind(this),this.set=fb.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(Jv(e)?(r=vy(e.key,``,t),i=vy(e.value,r,t)):r=vy(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=Lb(e,t,n),i=new this;return i.items=r.items,i}};zb.tag=`tag:yaml.org,2002:omap`;var Bb={collection:`seq`,identify:e=>e instanceof Map,nodeClass:zb,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=Ib(e,t),r=[];for(let{key:e}of n.items)Yv(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new zb,n)},createNode:(e,t,n)=>zb.from(e,t,n)};function Vb({value:e,source:t},n){return t&&(e?Hb:Ub).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var Hb={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Cy(!0),stringify:Vb},Ub={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Cy(!1),stringify:Vb},Wb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:bb},Gb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():bb(e)}},Kb={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Cy(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:bb},qb=e=>typeof e==`bigint`||Number.isInteger(e);function Jb(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function Yb(e,t,n){let{value:r}=e;if(qb(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return bb(e)}var Xb={identify:qb,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Jb(e,2,2,n),stringify:e=>Yb(e,2,`0b`)},Zb={identify:qb,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Jb(e,1,8,n),stringify:e=>Yb(e,8,`0`)},Qb={identify:qb,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Jb(e,0,10,n),stringify:bb},$b={identify:qb,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Jb(e,2,16,n),stringify:e=>Yb(e,16,`0x`)},ex=class e extends fb{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=Jv(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new ob(e.key,null):new ob(e,null),db(this.items,t.key)||this.items.push(t)}get(e,t){let n=db(this.items,e);return!t&&Jv(n)?Yv(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=db(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new ob(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(ab(e,null,n));return i}};ex.tag=`tag:yaml.org,2002:set`;var tx={collection:`map`,identify:e=>e instanceof Set,nodeClass:ex,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>ex.from(e,t,n),resolve(e,t){if(qv(e)){if(e.hasAllNullValues(!0))return Object.assign(new ex,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function nx(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function rx(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return bb(e);let r=``;t<0&&(r=`-`,t*=n(-1));let i=n(60),a=[t%i];return t<60?a.unshift(0):(t=(t-a[0])/i,a.unshift(t%i),t>=60&&(t=(t-a[0])/i,a.unshift(t))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}var ix={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>nx(e,n),stringify:rx},ax={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>nx(e,!1),stringify:rx},ox={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(ox.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,i,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+`00`).substr(1,3)):0,l=Date.UTC(n,r-1,i,a||0,o||0,s||0,c),u=t[8];if(u&&u!==`Z`){let e=nx(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e.toISOString().replace(/((T00:00)?:00)?\.000Z$/,``)},sx=[pb,gb,_b,vb,Hb,Ub,Xb,Zb,Qb,$b,Wb,Gb,Kb,Fb,Bb,Rb,tx,ix,ax,ox],cx=new Map([[`core`,Ab],[`failsafe`,[pb,gb,_b]],[`json`,Pb],[`yaml11`,sx],[`yaml-1.1`,sx]]),lx={binary:Fb,bool:yb,float:Cb,floatExp:Sb,floatNaN:xb,floatTime:ax,int:Ob,intHex:kb,intOct:Db,intTime:ix,map:pb,null:vb,omap:Bb,pairs:Rb,seq:gb,set:tx,timestamp:ox},ux={"tag:yaml.org,2002:binary":Fb,"tag:yaml.org,2002:omap":Bb,"tag:yaml.org,2002:pairs":Rb,"tag:yaml.org,2002:set":tx,"tag:yaml.org,2002:timestamp":ox};function dx(e,t){let n=cx.get(t);if(!n)if(Array.isArray(e))n=[];else{let e=Array.from(cx.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)n=n.concat(t);else typeof e==`function`&&(n=e(n.slice()));return n.map(e=>{if(typeof e!=`string`)return e;let t=lx[e];if(t)return t;let n=Object.keys(lx).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag "${e}"; use one of ${n}`)})}var fx=(e,t)=>e.key<t.key?-1:+(e.key>t.key),px=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?dx(e,`compat`):e?dx(null,e):null,this.merge=!!n,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?ux:{},this.tags=dx(t,this.name),this.toStringOptions=o??null,Object.defineProperty(this,Bv,{value:pb}),Object.defineProperty(this,Hv,{value:_b}),Object.defineProperty(this,Uv,{value:gb}),this.sortMapEntries=typeof a==`function`?a:a===!0?fx:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function mx(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(n.push(t),r=!0):e.directives.docStart&&(r=!0)}r&&n.push(`---`);let i=Jy(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(jy(t,``))}let o=!1,s=null;if(e.contents){if(Qv(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(jy(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=Zy(e.contents,i,()=>s=null,t);s&&(c+=My(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Zy(e.contents,i));if(e.directives?.docEnd)if(e.comment){let t=a(e.comment);t.includes(`
155
+ `)?(n.push(`...`),n.push(jy(t,``))):n.push(`... ${t}`)}else n.push(`...`);else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(jy(a(t),``)))}return n.join(`
156
156
  `)+`
157
- `}var px=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Hv,{value:Lv});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new uy({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[Hv]:{value:Lv}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Xv(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){mx(this.contents)&&this.contents.add(e)}addIn(e,t){mx(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=fy(this);e.anchor=!t||n.has(t)?py(t||`a`,n):t}return new vy(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=my(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=wy(e,l,p);return o&&Yv(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new ib(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return mx(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Ey(e)?this.contents==null?!1:(this.contents=null,!0):mx(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Yv(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Ey(e)?!t&&qv(this.contents)?this.contents.value:this.contents:Yv(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Yv(this.contents)?this.contents.has(e):!1}hasIn(e){return Ey(e)?this.contents!==void 0:Yv(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Ty(this.schema,[e],t):mx(this.contents)&&this.contents.set(e,t)}setIn(e,t){Ey(e)?this.contents=t:this.contents==null?this.contents=Ty(this.schema,Array.from(e),t):mx(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new uy({version:`1.1`}),n={merge:!0,resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new uy({version:e}),n={merge:!1,resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new dx(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=gy(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?hy(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return fx(this,e)}};function mx(e){if(Yv(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var hx=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},gx=class extends hx{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},_x=class extends hx{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},vx=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
158
- `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t&&t.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function yx(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:c=!0:f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x===null&&(x=i.offset),l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x===null&&(x=i.offset),l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function bx(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
159
- `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(bx(t.key)||bx(t.value))return!0}return!1;default:return!0}}function xx(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&bx(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function Sx(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(t,n)=>t===n||qv(t)&&qv(n)&&t.value===n.value&&!(t.value===`<<`&&e.schema.merge);return t.some(e=>i(e.key,n))}var Cx=`All mapping items must start at the same column`;function wx({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??ub)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=yx(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,Cx)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
160
- `+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||bx(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,Cx);let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&xx(r.indent,u,i),Sx(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=yx(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&xx(r.indent,f,i),s=c.range[2];let l=new ib(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
161
- `+_.comment:g.comment=_.comment);let e=new ib(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function Tx({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??fb)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=yx(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||l)l&&l.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&xx(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function Ex(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var Dx=`Block collections are not allowed within flow collections`,Ox=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function kx({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?ub:fb))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1);let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=yx(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
162
- `+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&bx(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];Kv(t)&&(t=t.value??t.key),t.comment?t.comment+=`
163
- `+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],Ox(m)&&i(r.range,`BLOCK_IN_FLOW`,Dx)}else{let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);Ox(f)&&i(g.range,`BLOCK_IN_FLOW`,Dx);let _=yx(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source&&m.source[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?Ox(m)&&i(v.range,`BLOCK_IN_FLOW`,Dx):_.comment&&(g.comment?g.comment+=`
164
- `+_.comment:g.comment=_.comment);let y=new ib(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;Sx(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new ub(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f&&f.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=Ex(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
165
- `+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function Ax(e,t,n,r,i,a){let o=n.type===`block-map`?wx(e,t,n,r,a):n.type===`block-seq`?Tx(e,t,n,r,a):kx(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function jx(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===ub.tagName&&s===`map`||o===fb.tagName&&s===`seq`)return Ax(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r&&r.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?.collection?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),Ax(e,t,n,i,o)}let l=Ax(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=Xv(u)?u:new xy(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function Mx(e,t,n){let r=t.offset,i=Nx(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?xy.BLOCK_FOLDED:xy.BLOCK_LITERAL,o=t.source?Px(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
157
+ `}var hx=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Wv,{value:zv});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new fy({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[Wv]:{value:zv}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Qv(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){gx(this.contents)&&this.contents.add(e)}addIn(e,t){gx(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=my(this);e.anchor=!t||n.has(t)?hy(t||`a`,n):t}return new by(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=gy(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=Ey(e,l,p);return o&&Zv(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new ob(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return gx(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Oy(e)?this.contents==null?!1:(this.contents=null,!0):gx(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Zv(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Oy(e)?!t&&Yv(this.contents)?this.contents.value:this.contents:Zv(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Zv(this.contents)?this.contents.has(e):!1}hasIn(e){return Oy(e)?this.contents!==void 0:Zv(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Dy(this.schema,[e],t):gx(this.contents)&&this.contents.set(e,t)}setIn(e,t){Oy(e)?this.contents=t:this.contents==null?this.contents=Dy(this.schema,Array.from(e),t):gx(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new fy({version:`1.1`}),n={merge:!0,resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new fy({version:e}),n={merge:!1,resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new px(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=vy(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?_y(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return mx(this,e)}};function gx(e){if(Zv(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var _x=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},vx=class extends _x{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},yx=class extends _x{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},bx=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
158
+ `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t&&t.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function xx(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:c=!0:f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x===null&&(x=i.offset),l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x===null&&(x=i.offset),l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function Sx(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
159
+ `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(Sx(t.key)||Sx(t.value))return!0}return!1;default:return!0}}function Cx(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&Sx(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function wx(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(t,n)=>t===n||Yv(t)&&Yv(n)&&t.value===n.value&&!(t.value===`<<`&&e.schema.merge);return t.some(e=>i(e.key,n))}var Tx=`All mapping items must start at the same column`;function Ex({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??fb)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=xx(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,Tx)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
160
+ `+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||Sx(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,Tx);let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&Cx(r.indent,u,i),wx(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=xx(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&Cx(r.indent,f,i),s=c.range[2];let l=new ob(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
161
+ `+_.comment:g.comment=_.comment);let e=new ob(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function Dx({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??mb)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=xx(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||l)l&&l.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&Cx(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function Ox(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var kx=`Block collections are not allowed within flow collections`,Ax=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function jx({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?fb:mb))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1);let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=xx(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
162
+ `+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&Sx(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];Jv(t)&&(t=t.value??t.key),t.comment?t.comment+=`
163
+ `+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],Ax(m)&&i(r.range,`BLOCK_IN_FLOW`,kx)}else{let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);Ax(f)&&i(g.range,`BLOCK_IN_FLOW`,kx);let _=xx(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source&&m.source[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?Ax(m)&&i(v.range,`BLOCK_IN_FLOW`,kx):_.comment&&(g.comment?g.comment+=`
164
+ `+_.comment:g.comment=_.comment);let y=new ob(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;wx(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new fb(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f&&f.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=Ox(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
165
+ `+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function Mx(e,t,n,r,i,a){let o=n.type===`block-map`?Ex(e,t,n,r,a):n.type===`block-seq`?Dx(e,t,n,r,a):jx(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function Nx(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===fb.tagName&&s===`map`||o===mb.tagName&&s===`seq`)return Mx(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r&&r.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?.collection?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),Mx(e,t,n,i,o)}let l=Mx(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=Qv(u)?u:new Cy(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function Px(e,t,n){let r=t.offset,i=Fx(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?Cy.BLOCK_FOLDED:Cy.BLOCK_LITERAL,o=t.source?Ix(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
166
166
  `.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
167
- `;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===xy.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
167
+ `;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===Cy.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
168
168
  `):t.length>c||r[0]===` `?(f===` `?f=`
169
169
  `:!p&&f===`
170
170
  `&&(f=`
@@ -177,51 +177,51 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
177
177
  `+o[e][0].slice(c);d[d.length-1]!==`
178
178
  `&&(d+=`
179
179
  `);break;default:d+=`
180
- `}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function Nx({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function Px(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function Fx(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=xy.PLAIN,c=Ix(a,l);break;case`single-quoted-scalar`:s=xy.QUOTE_SINGLE,c=Lx(a,l);break;case`double-quoted-scalar`:s=xy.QUOTE_DOUBLE,c=zx(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=Ex(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function Ix(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`;break}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),Rx(e)}function Lx(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),Rx(e.slice(1,-1)).replace(/''/g,`'`)}function Rx(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
180
+ `}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function Fx({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function Ix(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function Lx(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=Cy.PLAIN,c=Rx(a,l);break;case`single-quoted-scalar`:s=Cy.QUOTE_SINGLE,c=zx(a,l);break;case`double-quoted-scalar`:s=Cy.QUOTE_DOUBLE,c=Vx(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=Ox(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function Rx(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`;break}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),Bx(e)}function zx(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),Bx(e.slice(1,-1)).replace(/''/g,`'`)}function Bx(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
181
181
  `,`sy`),n=RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
182
182
  `,`sy`)}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let i=r[1],a=` `,o=t.lastIndex;for(n.lastIndex=o;r=n.exec(e);)r[1]===``?a===`
183
183
  `?i+=a:a=`
184
- `:(i+=a+r[1],a=` `),o=n.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),i+a+(r?.[1]??``)}function zx(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(!(i===`\r`&&e[r+1]===`
184
+ `:(i+=a+r[1],a=` `),o=n.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),i+a+(r?.[1]??``)}function Vx(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(!(i===`\r`&&e[r+1]===`
185
185
  `))if(i===`
186
- `){let{fold:t,offset:i}=Bx(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=Vx[i];if(a)n+=a;else if(i===`
186
+ `){let{fold:t,offset:i}=Hx(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=Ux[i];if(a)n+=a;else if(i===`
187
187
  `)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
188
- `)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a={x:2,u:4,U:8}[i];n+=Hx(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
188
+ `)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a={x:2,u:4,U:8}[i];n+=Wx(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
189
189
  `&&!(a===`\r`&&e[r+2]===`
190
- `)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function Bx(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
190
+ `)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function Hx(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
191
191
  `||r===`\r`)&&!(r===`\r`&&e[t+2]!==`
192
192
  `);)r===`
193
193
  `&&(n+=`
194
- `),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var Vx={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
195
- `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function Hx(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}function Ux(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?Mx(e,t,r):Fx(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l=n&&c?Wx(e.schema,i,c,n,r):t.type===`scalar`?Gx(e,i,t,r):e.schema[Bv],u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=qv(a)?a:new xy(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new xy(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function Wx(e,t,n,r,i){if(n===`!`)return e[Bv];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n)if(t.default&&t.test)a.push(t);else return t;for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[Bv])}function Gx({directives:e,schema:t},n,r,i){let a=t.tags.find(e=>e.default&&e.test?.test(n))||t[Bv];if(t.compat){let o=t.compat.find(e=>e.default&&e.test?.test(n))??t[Bv];a.tag!==o.tag&&i(r,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${e.tagString(a.tag)} or ${e.tagString(o.tag)}`,!0)}return a}function Kx(e,t,n){if(t){n===null&&(n=t.length);for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var qx={composeNode:Jx,composeEmptyNode:Yx};function Jx(e,t,n,r){let{spaceBefore:i,comment:a,anchor:o,tag:s}=n,c,l=!0;switch(t.type){case`alias`:c=Xx(e,t,r),(o||s)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:c=Ux(e,t,s,r),o&&(c.anchor=o.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:c=jx(qx,e,t,n,r),o&&(c.anchor=o.source.substring(1));break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),c=Yx(e,t.offset,void 0,null,n,r),l=!1}return o&&c.anchor===``&&r(o,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&(c.spaceBefore=!0),a&&(t.type===`scalar`&&t.source===``?c.comment=a:c.commentBefore=a),e.options.keepSourceTokens&&l&&(c.srcToken=t),c}function Yx(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=Ux(e,{type:`scalar`,offset:Kx(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function Xx({options:e},{offset:t,source:n,end:r},i){let a=new vy(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=Ex(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function Zx(e,t,{offset:n,start:r,value:i,end:a},o){let s=new px(void 0,Object.assign({_directives:t},e)),c={atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=yx(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?Jx(c,i,l,o):Yx(c,l.end,r,null,l,o);let u=s.contents.range[2],d=Ex(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function Qx(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function $x(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
194
+ `),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var Ux={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
195
+ `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function Wx(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}function Gx(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?Px(e,t,r):Lx(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l=n&&c?Kx(e.schema,i,c,n,r):t.type===`scalar`?qx(e,i,t,r):e.schema[Hv],u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=Yv(a)?a:new Cy(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new Cy(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function Kx(e,t,n,r,i){if(n===`!`)return e[Hv];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n)if(t.default&&t.test)a.push(t);else return t;for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[Hv])}function qx({directives:e,schema:t},n,r,i){let a=t.tags.find(e=>e.default&&e.test?.test(n))||t[Hv];if(t.compat){let o=t.compat.find(e=>e.default&&e.test?.test(n))??t[Hv];a.tag!==o.tag&&i(r,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${e.tagString(a.tag)} or ${e.tagString(o.tag)}`,!0)}return a}function Jx(e,t,n){if(t){n===null&&(n=t.length);for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var Yx={composeNode:Xx,composeEmptyNode:Zx};function Xx(e,t,n,r){let{spaceBefore:i,comment:a,anchor:o,tag:s}=n,c,l=!0;switch(t.type){case`alias`:c=Qx(e,t,r),(o||s)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:c=Gx(e,t,s,r),o&&(c.anchor=o.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:c=Nx(Yx,e,t,n,r),o&&(c.anchor=o.source.substring(1));break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),c=Zx(e,t.offset,void 0,null,n,r),l=!1}return o&&c.anchor===``&&r(o,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&(c.spaceBefore=!0),a&&(t.type===`scalar`&&t.source===``?c.comment=a:c.commentBefore=a),e.options.keepSourceTokens&&l&&(c.srcToken=t),c}function Zx(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=Gx(e,{type:`scalar`,offset:Jx(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function Qx({options:e},{offset:t,source:n,end:r},i){let a=new by(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=Ox(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function $x(e,t,{offset:n,start:r,value:i,end:a},o){let s=new hx(void 0,Object.assign({_directives:t},e)),c={atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=xx(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?Xx(c,i,l,o):Zx(c,l.end,r,null,l,o);let u=s.contents.range[2],d=Ox(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function eS(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function tS(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
196
196
 
197
197
  `:`
198
- `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var eS=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=Qx(e);r?this.warnings.push(new _x(i,t,n)):this.errors.push(new gx(i,t,n))},this.directives=new uy({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=$x(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(Yv(i)&&!i.flow&&i.items.length>0){let e=i.items[0];Kv(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:$x(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=Qx(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=Zx(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new gx(Qx(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new gx(Qx(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=Ex(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new gx(Qx(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new px(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},tS=Symbol(`break visit`),nS=Symbol(`skip children`),rS=Symbol(`remove item`);function iS(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),aS(Object.freeze([]),e,t)}iS.BREAK=tS,iS.SKIP=nS,iS.REMOVE=rS,iS.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},iS.parentCollection=(e,t)=>{let n=iS.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function aS(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=aS(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===tS)return tS;else r===rS&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function oS(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
198
+ `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var nS=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=eS(e);r?this.warnings.push(new yx(i,t,n)):this.errors.push(new vx(i,t,n))},this.directives=new fy({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=tS(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(Zv(i)&&!i.flow&&i.items.length>0){let e=i.items[0];Jv(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:tS(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=eS(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=$x(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new vx(eS(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new vx(eS(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=Ox(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new vx(eS(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new hx(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},rS=Symbol(`break visit`),iS=Symbol(`skip children`),aS=Symbol(`remove item`);function oS(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),sS(Object.freeze([]),e,t)}oS.BREAK=rS,oS.SKIP=iS,oS.REMOVE=aS,oS.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},oS.parentCollection=(e,t)=>{let n=oS.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function sS(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=sS(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===rS)return rS;else r===aS&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function cS(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
199
199
  `:case`\r
200
- `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function sS(e){switch(e){case void 0:case` `:case`
201
- `:case`\r`:case` `:return!0;default:return!1}}var cS=new Set(`0123456789ABCDEFabcdef`),lS=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),uS=new Set(`,[]{}`),dS=new Set(` ,[]{}
202
- \r `),fS=e=>!e||dS.has(e),pS=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
200
+ `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function lS(e){switch(e){case void 0:case` `:case`
201
+ `:case`\r`:case` `:return!0;default:return!1}}var uS=new Set(`0123456789ABCDEFabcdef`),dS=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),fS=new Set(`,[]{}`),pS=new Set(` ,[]{}
202
+ \r `),mS=e=>!e||pS.has(e),hS=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
203
203
  `?!0:t===`\r`?this.buffer[e+1]===`
204
204
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
205
205
  `||!t&&!this.atEnd)return e+n+1}return t===`
206
- `||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&sS(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
207
- `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}else n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&sS(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!sS(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&sS(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,yield*this.parseBlockStart()}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(fS),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&sS(r[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(r[0]===`]`||r[0]===`}`)))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(fS),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||sS(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
206
+ `||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&lS(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
207
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}else n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&lS(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!lS(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&lS(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,yield*this.parseBlockStart()}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(mS),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&lS(r[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(r[0]===`]`||r[0]===`}`)))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(mS),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||lS(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
208
208
  `,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
209
- `,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>sS(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
209
+ `,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>lS(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
210
210
  `:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
211
211
  `)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
212
212
  `,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
213
213
  `;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
214
- `&&n>=this.pos&&n+1+t>i)e=n;else break}while(!0);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(sS(r)||e&&uS.has(r))break;t=n}else if(sS(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
214
+ `&&n>=this.pos&&n+1+t>i)e=n;else break}while(!0);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(lS(r)||e&&fS.has(r))break;t=n}else if(lS(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
215
215
  `?(n+=1,r=`
216
- `,i=this.buffer[n+1]):t=n),i===`#`||e&&uS.has(i))break;if(r===`
217
- `){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&uS.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){switch(this.charAt(0)){case`!`:return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`&`:return(yield*this.pushUntil(fS))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`-`:case`?`:case`:`:{let e=this.flowLevel>0,t=this.charAt(1);if(sS(t)||e&&uS.has(t))return e?this.flowKey&&=!1:this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!sS(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(lS.has(t))t=this.buffer[++e];else if(t===`%`&&cS.has(this.buffer[e+1])&&cS.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
216
+ `,i=this.buffer[n+1]):t=n),i===`#`||e&&fS.has(i))break;if(r===`
217
+ `){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&fS.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){switch(this.charAt(0)){case`!`:return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`&`:return(yield*this.pushUntil(mS))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`-`:case`?`:case`:`:{let e=this.flowLevel>0,t=this.charAt(1);if(lS(t)||e&&fS.has(t))return e?this.flowKey&&=!1:this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!lS(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(dS.has(t))t=this.buffer[++e];else if(t===`%`&&uS.has(this.buffer[e+1])&&uS.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
218
218
  `?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
219
- `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},mS=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function hS(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function gS(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function _S(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function vS(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function yS(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function bS(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!hS(t.start,`explicit-key-ind`)&&!hS(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,_S(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}var xS=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new pS,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=oS(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&(!e||e.type!==`doc-end`)){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&bS(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&gS(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:gS(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=yS(vS(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
219
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},gS=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function _S(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function vS(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function yS(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function bS(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function xS(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function SS(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!_S(t.start,`explicit-key-ind`)&&!_S(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,yS(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}var CS=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new hS,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=cS(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&(!e||e.type!==`doc-end`)){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&SS(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&vS(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:vS(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=xS(bS(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
220
220
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
221
- `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(hS(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=yS(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(hS(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(_S(t.key)&&!hS(t.sep,`newline`)){let e=yS(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):hS(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let t=this.startBlockValue(e);if(t){n&&t.type!==`block-seq`&&e.items.push({start:i}),this.stack.push(t);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||hS(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e&&e.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=yS(vS(t));bS(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
221
+ `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(_S(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=xS(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(_S(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(yS(t.key)&&!_S(t.sep,`newline`)){let e=xS(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):_S(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let t=this.startBlockValue(e);if(t){n&&t.type!==`block-seq`&&e.items.push({start:i}),this.stack.push(t);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||_S(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e&&e.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=xS(bS(t));SS(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
222
222
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
223
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=yS(vS(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=yS(vS(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function SS(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new mS||null,prettyErrors:t}}function CS(e,t={}){let{lineCounter:n,prettyErrors:r}=SS(t),i=new xS(n?.addNewLine),a=new eS(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new gx(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(vx(e,n)),o.warnings.forEach(vx(e,n))),o}function wS(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=CS(e,n);if(!i)return null;if(i.warnings.forEach(e=>Zy(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}var TS=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,ES=/^\s*\*\*[A-Za-z0-9_-]+\s*:\s*\*\*/m,DS=/^\s*(?:\*\*)?([A-Za-z0-9_-]+)(?:\*\*)?\s*:\s*(?:\*\*)?\s*(.*?)\s*$/;function OS(e){if(typeof e!=`string`)return{data:{},body:``,format:`none`,raw:``};let t=e.match(TS);if(!t)return{data:{},body:e,format:`none`,raw:``};let n=t[1],r=e.slice(t[0].length);if(ES.test(n))return{data:kS(n),body:r,format:`legacy`,raw:n};try{let e=wS(n);return{data:e&&typeof e==`object`&&!Array.isArray(e)?e:{},body:r,format:`yaml`,raw:n}}catch{return{data:kS(n),body:r,format:`legacy`,raw:n}}}function kS(e){let t={};for(let n of e.split(/\r?\n/)){let e=DS.exec(n);if(!e)continue;let r=e[1],i=e[2];r.toLowerCase()===`tags`?t[r]=i.split(`,`).map(e=>e.trim()).filter(Boolean):t[r]=i}return t}function AS(e,t){let n=t.toLowerCase();for(let t of Object.keys(e))if(t.toLowerCase()===n)return e[t]}function jS(e){return e==null?null:Array.isArray(e)?e.map(e=>String(e)).join(`, `):String(e)}function MS(e,t){let{data:n}=OS(e);for(let e of t){let t=AS(n,e);if(t!=null)return jS(t)}return null}var NS=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,PS=/^(\s*(?:\*\*)?(?:language|lang|locale|langue)(?:\*\*)?\s*:\s*(?:\*\*)?\s*)(.+?)\s*$/i;function FS(e){let t=(e??``).trim().toLowerCase();return t?t===`en`||t.startsWith(`en-`)||t===`english`||t===`anglais`?`en`:t===`fr`||t.startsWith(`fr-`)||t===`french`||t===`francais`||t===`français`?`fr`:null:null}function IS(e){return FS(MS(e,[`language`,`lang`,`locale`,`langue`]))}function LS(e,t){let n=e.match(NS);if(!n)return`---\n**language:** ${t}\n---\n\n${e}`;let r=n[0],i=n[1].split(/\r?\n/),a=i.findIndex(e=>PS.test(e));if(a>=0)i[a]=i[a].replace(PS,`$1${t}`);else{let e=i.findIndex(e=>/^\s*(?:\*\*)?date(?:\*\*)?\s*:\s*(?:\*\*)?/i.test(e)),n=e>=0?e+1:i.length;i.splice(n,0,`**language:** ${t}`)}return`---\n${i.join(`
224
- `)}\n---\n`+e.slice(r.length)}var RS=e=>e.normalize(`NFC`).normalize(`NFD`).replace(/[̀-ͯ]/g,``).toLowerCase();function zS(e,t){let n=RS(t);if(!n)return[];let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=[];for(;r.nextNode();)i.push(r.currentNode);let a=0;i.forEach(e=>{let t=(e.textContent||``).normalize(`NFC`),r=RS(t);if(!r.includes(n))return;let i=``,o=0;for(;o<=r.length;){let e=r.indexOf(n,o);if(e===-1){i+=t.slice(o);break}i+=t.slice(o,e),i+=`<mark id="match-${a++}">${t.slice(e,e+n.length)}</mark>`,o=e+n.length}let s=document.createElement(`span`);s.innerHTML=i,e.parentNode?.replaceChild(s,e)});let o=[];return e.querySelectorAll(`mark[id^='match-']`).forEach(e=>{let r=((e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre`)||e.parentElement).textContent||``).trim(),i=RS(r).indexOf(n),a=Math.max(0,i-40),s=Math.min(r.length,i+t.length+40),c=(a>0?`…`:``)+r.slice(a,s)+(s<r.length?`…`:``);o.push({id:e.id,snippet:c})}),o}function BS(e){let t=document.getElementById(e),n=document.getElementById(`home-content-area`);if(!t||!n)return;let r=t.parentElement;for(;r&&r!==n;)r.tagName===`DETAILS`&&!r.open&&(r.open=!0),r=r.parentElement;document.querySelectorAll(`mark.match-active`).forEach(e=>{e.classList.remove(`match-active`)}),t.classList.add(`match-active`);let i=document.querySelector(`#home-doc-view header`),a=i?i.getBoundingClientRect().height:0,o=t.getBoundingClientRect().top,s=n.getBoundingClientRect().top,c=a+(n.clientHeight-a)/3;n.scrollTop+=o-s-c}var VS=U(`<span class="inline-block text-xs font-semibold px-2.5 py-0.5 rounded-full bg-violet-100 text-violet-700 dark:bg-violet-900/40 dark:text-violet-300"> </span>`),HS=U(`<span class="text-xs text-gray-400 dark:text-gray-500"> </span>`),US=U(`<button type="button" data-testid="copy-doc-id-btn"><i aria-hidden="true"></i></button>`),WS=U(`<span class="inline-block text-[11px] px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 border border-gray-200 dark:border-gray-700"> </span>`),GS=U(`<div class="mt-1.5 flex items-center gap-1.5 flex-wrap" data-testid="doc-tags"></div>`),KS=U(`<span> </span>`),qS=U(`<div data-testid="edit-actions" class="flex items-center gap-2"><!> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-1.5 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div>`),JS=U(`<button data-testid="validate-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-green-700 bg-green-600 text-white font-semibold hover:bg-green-700 transition-colors"><i class="fa-solid fa-check" style="margin-right:4px"></i> </button>`),YS=U(`<button data-testid="tts-toggle" class="no-print text-sm px-3 py-1.5 rounded-lg border border-blue-300 dark:border-blue-700 bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 hover:bg-blue-100 dark:hover:bg-blue-900/50 transition-colors"><i></i></button> <button data-testid="tts-stop" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-stop"></i></button>`,1),XS=U(`<button data-testid="tts-play" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-headphones" style="margin-right:4px"></i> </button>`),ZS=Hr(`<g><line x1="8" y1="8" x2="92" y2="92" stroke="currentColor" stroke-width="8" stroke-linecap="round"></line><line x1="92" y1="8" x2="8" y2="92" stroke="currentColor" stroke-width="8" stroke-linecap="round"></line></g>`),QS=U(`<button data-testid="versions-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-code-branch"></i> </button>`),$S=U(`<!> <button data-testid="marker-doc-btn"><svg width="18" height="18" viewBox="0 0 100 100" fill="none" style="display:inline-block;vertical-align:middle;margin-right:4px"><rect x="28" y="10" width="44" height="52" rx="6" transform="rotate(40 50 50)" stroke="currentColor" stroke-width="6"></rect><rect x="52" y="8" width="22" height="30" rx="6" transform="rotate(40 50 50)" stroke="currentColor" stroke-width="6"></rect><polygon points="28,60 10,80 30,80 38,72" stroke="currentColor" stroke-width="5" stroke-linejoin="round"></polygon><polygon points="28,48 19,70 36,75 55,70" stroke="currentColor" stroke-width="5" stroke-linejoin="round"></polygon><line x1="10" y1="90" x2="72" y2="90" stroke="currentColor" stroke-width="6" stroke-linecap="round"></line><!></svg> </button> <button data-testid="export-pdf-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"> </button> <button data-testid="metadata-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-code-compare"></i> </button> <!> <button data-testid="edit-doc-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-file-pen"></i> </button>`,1),eC=U(`<button data-testid="kanban-edit-columns" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-gear"></i> </button>`),tC=U(`<button data-testid="toc-toggle-btn"><i class="fa-solid fa-list-ul"></i></button>`),nC=U(`<div data-testid="view-actions" class="flex items-center gap-2"><button data-testid="favorite-doc-btn"><i style="margin-right:4px"></i> </button> <!> <!> <!> <button data-testid="delete-doc-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors"><i class="fa-solid fa-trash"></i> </button> <!></div>`),rC=U(`<span class="text-gray-300 dark:text-gray-600 mx-1">·</span>`),iC=U(`<!> <button class="text-blue-600 dark:text-blue-400 hover:underline"> </button>`,1),aC=U(`<div class="no-print mt-2 flex flex-wrap gap-1 text-xs"></div>`),oC=U(`<li><button class="w-full text-left px-3 py-1.5 hover:bg-yellow-100 dark:hover:bg-yellow-900/30 transition-colors"><span class="text-yellow-600 dark:text-yellow-500 font-mono text-xs mr-2"> </span><span class="text-xs"> </span></button></li>`),sC=U(`<div class="mt-4 rounded-lg bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 text-sm text-yellow-800 dark:text-yellow-300 overflow-hidden"><div class="px-3 py-2 font-medium border-b border-yellow-200 dark:border-yellow-800"> </div> <ol class="max-h-40 overflow-y-auto divide-y divide-yellow-100 dark:divide-yellow-900/40 list-none m-0 p-0"></ol></div>`),cC=U(`<div data-testid="tts-error" class="mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300"> </div>`),lC=U(`<div class="hidden no-print"></div>`),uC=U(`<li class="m-0 p-0"><button type="button" class="block w-full text-left bg-transparent border-0 cursor-pointer text-xs text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:underline py-0.5 leading-snug transition-colors truncate"> </button></li>`),dC=U(`<div></div> <aside class="no-print shrink-0 sticky self-start overflow-y-auto py-8 pr-4 pl-3 ld-toc-aside"><p class="text-xs font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500 mb-3"> </p> <nav><ul class="space-y-1 list-none m-0 p-0"></ul></nav></aside>`,1),fC=U(`<div data-testid="tts-language-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"><div class="w-full max-w-sm rounded-xl border border-gray-200 bg-white p-5 shadow-2xl dark:border-gray-700 dark:bg-gray-900"><h2 class="text-base font-semibold text-gray-900 dark:text-gray-50"> </h2> <p class="mt-2 text-sm text-gray-600 dark:text-gray-300"> </p> <div class="mt-4 grid grid-cols-2 gap-2"><button type="button" data-testid="tts-language-en" class="rounded-lg border border-gray-200 px-3 py-2 text-sm font-semibold text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800"> </button> <button type="button" data-testid="tts-language-fr" class="rounded-lg border border-gray-200 px-3 py-2 text-sm font-semibold text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800"> </button></div> <div class="mt-3 flex justify-end"><button type="button" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"> </button></div></div></div>`),pC=U(`<div class="fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-4"><div class="w-full max-w-sm bg-white dark:bg-gray-900 border border-red-200 dark:border-red-700 rounded-xl shadow-2xl p-5 flex flex-col gap-3"><p class="text-sm text-gray-700 dark:text-gray-200"> </p> <p class="text-xs text-gray-500 dark:text-gray-400 italic truncate"> </p> <div class="flex justify-end gap-2 mt-2"><button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-1.5 rounded-lg bg-red-500 hover:bg-red-600 text-white font-semibold transition-colors"> </button></div></div></div>`),mC=U(`<header id="home-doc-header" class="sticky top-0 z-10 bg-gray-50 dark:bg-gray-950 px-6 pt-8 pb-6 border-b border-gray-300 dark:border-gray-800"><div class="flex items-start gap-4 flex-wrap"><div class="shrink min-w-0"><div class="flex items-center gap-2 flex-wrap"><span class="flex items-center gap-2 flex-wrap"><!> <span class="inline-block text-xs font-semibold px-2.5 py-0.5 rounded-full bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"> </span></span> <!> <h1 data-testid="doc-title" class="min-w-0 text-xs font-normal text-gray-900 dark:text-gray-50 leading-tight"> </h1> <!></div> <!></div> <div class="flex items-center gap-2 flex-wrap ml-auto"><!></div></div> <!> <!> <!> <!> <!></header> <div class="flex min-h-full items-start"><article id="home-doc-view" data-testid="doc-view" class="flex-1 min-w-0 px-6 pt-8 pb-8"><!></article> <!></div> <!> <!> <!> <!> <!> <!>`,1);function hC(e,t){qe(t,!0);let n=/<div\s+data-ld-kanban\b/i,r=Wi(t,`navHistory`,19,()=>[]),i=P(null),a=P(null),o=P(null),s=P(null),c=P(!1),l=P(!1),u=P(!1),d=P(null),f=P(I([])),p=``,m=N(()=>V(f).length?Y(V(f).length===1?`search.notice_singular`:`search.notice_plural`).replace(`{count}`,String(V(f).length)).replace(`{query}`,X.searchQuery):``),h=N(()=>L_(t.doc.content)),g=N(()=>n.test(t.doc.content)),_=N(()=>$a.has(t.doc.id)),v=N(()=>(V(h)||``).toUpperCase()===`TO BE VALIDATED`),y=P(!1),b=P(null),x=P(!1),S=P(!1),C=P(!1),w=P(!1),T=P(!1);async function E(){try{let e=await(await fetch(`/api/git/status`)).json();F(u,e.mode===`enabled`&&e.ok===!0,!0)}catch{F(u,!1)}}kn(()=>{if(t.doc.id,V(g),V(g)){F(u,!1);return}E()}),kn(()=>{V(g)&&V(y)&&(F(y,!1),F(b,null))});function D(e,t){let n=document.getElementById(`home-content-area`);if(!n)return;let r=document.getElementById(`home-doc-header`),i=r?r.getBoundingClientRect().height:0,a=e.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop;n.scrollTo({top:Math.max(0,a-i-16),behavior:t?`smooth`:`auto`})}function ee(e){let t=document.getElementById(e);t&&D(t,!1)}function te(e){F(i,e,!0);let n=t.doc.id,r=X.searchQuery;if(V(g)){F(f,[],!0),F(k,[],!0),p=n;return}let a=typeof r==`string`&&r.toLowerCase().startsWith(`metadata://`);F(f,r&&!a?zS(e,r):[],!0),V(d)&&Sv(e,V(d),Y),n===p?V(o)?.apply():(p=n,V(o)?.load(n),N_.load(n)),F(k,Array.from(e.querySelectorAll(`h1,h2,h3,h4,h5,h6`)).map(e=>({id:e.id,text:e.textContent?.trim()??``,level:parseInt(e.tagName[1])})).filter(e=>e.id&&e.text),!0)}function O(){return V(s).show({title:Y(`snippet.inline_delete_title`),message:Y(`snippet.inline_delete_message`),confirmLabel:Y(`snippet.inline_delete_confirm_btn`),cancelLabel:Y(`common.cancel`),danger:!0})}async function ne(){let e=1;try{let n=await N_.load(t.doc.id);n&&typeof n.accuracy==`number`&&(e=n.accuracy)}catch{}let n=Math.round(e*100),r=n<100,i=z_(t.doc.id),a=Y(i?`doc.validate_worklog_message`:`doc.validate_message`),o=r?Y(`doc.validate_detail_low_accuracy`).replace(`{accuracy}`,n+`%`):void 0;if(!await V(s).show({title:Y(`doc.validate_title`),message:a,detail:o,confirmLabel:Y(`doc.validate_confirm`),cancelLabel:Y(`common.cancel`)}))return;let c=R_(t.doc.content,i?`Done`:`Accepted`);if(c!==t.doc.content)try{await t.onsave(c),r&&await fetch(`/api/metadata/`+encodeURIComponent(t.doc.id)+`/refresh`,{method:`POST`}),await N_.load(t.doc.id),X.docStatuses={...X.docStatuses,[t.doc.id]:i?`Done`:`Accepted`}}catch(e){F(b,{text:Y(`doc.validate_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`},!0)}}kn(()=>{try{F(x,localStorage.getItem(`ld-full-width`)===`1`)}catch{}});let re=P(!1),k=P(I([])),ie=N(()=>!V(g)&&V(re)&&V(k).length>0),ae=`ld-toc-w`,oe=P(!1),se=P(null),ce=P(null),le=P(0);kn(()=>{if(!V(ce))return;let e=new ResizeObserver(()=>{F(le,V(ce).offsetHeight,!0)});return e.observe(V(ce)),F(le,V(ce).offsetHeight,!0),()=>e.disconnect()});function ue(e){if(e.preventDefault(),!V(se))return;let t=e.clientX,n=V(se).getBoundingClientRect().width;F(oe,!0),V(se).style.transition=`none`,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let r=e=>{let r=Math.max(160,Math.min(400,n-(e.clientX-t)));V(se).style.width=r+`px`},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),document.body.style.cursor=``,document.body.style.userSelect=``,F(oe,!1),V(se).style.transition=``;try{localStorage.setItem(ae,String(parseInt(V(se).style.width,10)))}catch{}};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)}kn(()=>{try{F(re,localStorage.getItem(`ld-toc-open`)===`1`)}catch{}try{let e=parseInt(localStorage.getItem(ae)||``,10);V(se)&&e>=160&&e<=400&&(V(se).style.width=e+`px`)}catch{}});function de(){F(re,!V(re));try{localStorage.setItem(`ld-toc-open`,V(re)?`1`:`0`)}catch{}}function fe(e){let t=document.getElementById(e),n=document.getElementById(`home-content-area`);if(!t||!n)return;let r=t.parentElement;for(;r&&r!==n;)r.tagName===`DETAILS`&&(r.open=!0),r=r.parentElement;D(t,!0)}async function pe(){try{await navigator.clipboard.writeText(decodeURIComponent(t.doc.id)),F(C,!0),setTimeout(()=>F(C,!1),1800)}catch{}}function me(){window.print()}function he(e){V(i)&&Fv.start(V(i),{language:e,codeLabel:Y(`tts.code_label`),imageLabel:Y(`tts.image_label`),diagramLabel:Y(`tts.diagram_label`),tableLabel:Y(`tts.table_label`)})}function ge(){let e=IS(t.doc.content);if(!e){F(w,!0);return}he(e)}async function _e(e){F(T,!0);try{let n=LS(t.doc.content,e);n!==t.doc.content&&await t.onsave(n),F(w,!1),he(e)}catch(e){F(b,{text:Y(`tts.language_save_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`},!0)}finally{F(T,!1)}}kn(()=>(t.doc.id,V(y),()=>{F(w,!1),Fv.stop()}));var ve=mC(),ye=R(ve),be=L(ye),xe=L(be),Se=L(xe),Ce=L(Se),A=L(Ce);q(A,17,()=>t.doc.folder||[],Xr,(e,t)=>{var n=VS(),r=L(n,!0);j(n),B(e=>{J(n,`title`,V(t)),G(r,e)},[()=>Jg(V(t))]),W(e,n)});var we=z(A,2),Te=L(we,!0);j(we),j(Ce);var Ee=z(Ce,2),De=e=>{var n=HS(),r=L(n,!0);j(n),B(()=>G(r,t.doc.formattedDate)),W(e,n)};K(Ee,e=>{t.doc.formattedDate&&e(De)});var Oe=z(Ee,2),ke=L(Oe,!0);j(Oe);var Ae=z(Oe,2),je=e=>{var t=US(),n=L(t);j(t),B(e=>{J(t,`title`,e),gi(t,1,`no-print inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-gray-200 text-xs text-gray-500 transition-colors hover:bg-gray-50 hover:text-blue-600 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-blue-400 ${V(C)?`text-green-600 dark:text-green-400`:``}`),gi(n,1,`fa-${V(C)?`solid fa-check`:`regular fa-copy`}`)},[()=>Y(`doc.copy_mcp_id`)]),H(`click`,t,pe),W(e,t)};K(Ae,e=>{V(g)||e(je)}),j(Se);var Me=z(Se,2),Ne=e=>{var n=GS();q(n,20,()=>t.doc.tags,e=>e,(e,t)=>{var n=WS(),r=L(n);j(n),B(()=>G(r,`#${t??``}`)),W(e,n)}),j(n),W(e,n)};K(Me,e=>{t.doc.tags&&t.doc.tags.length&&e(Ne)}),j(xe);var Pe=z(xe,2),Fe=L(Pe),Ie=e=>{var t=qS(),n=L(t),r=e=>{var t=KS(),n=L(t,!0);j(t),B(()=>{gi(t,1,`text-xs ${V(b).cls??``}`),G(n,V(b).text)}),W(e,t)};K(n,e=>{V(b)&&e(r)});var i=z(n,2),o=L(i,!0);j(i);var s=z(i,2),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(t),B((e,t,n,r)=>{G(o,e),J(s,`title`,t),G(c,n),G(u,r)},[()=>Y(`common.cancel`),()=>Y(`doc.snippets`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),H(`click`,i,()=>V(a).cancelEdit()),H(`click`,s,()=>V(a).openSnippets()),H(`click`,l,()=>V(a).save()),W(e,t)},Le=e=>{let n=N(()=>X.markerActive?`#fef08a`:`#bfdbfe`),r=N(()=>X.markerActive?`#fef08a`:`#93c5fd`),i=N(()=>X.markerActive?`#fde047`:`#93c5fd`);var o=nC(),s=L(o),d=L(s),f=z(d,1,!0);j(s);var p=z(s,2),m=e=>{var t=JS(),n=z(L(t),1,!0);j(t),B((e,r)=>{J(t,`title`,e),G(n,r)},[()=>Y(`doc.validate_mode`),()=>Y(`doc.validate_btn`)]),H(`click`,t,ne),W(e,t)};K(p,e=>{V(v)&&!V(g)&&e(m)});var h=z(p,2),y=e=>{var t=$S(),o=R(t),s=e=>{var t=YS(),n=R(t),r=L(n);j(n);var i=z(n,2);B((e,t)=>{J(n,`title`,e),gi(r,1,`fa-solid ${Fv.status===`playing`?`fa-pause`:`fa-play`}`),J(i,`title`,t)},[()=>Fv.status===`playing`?Y(`tts.pause`):Y(`tts.resume`),()=>Y(`tts.stop`)]),H(`click`,n,()=>Fv.toggle()),H(`click`,i,()=>Fv.stop()),W(e,t)},d=e=>{var t=XS(),n=z(L(t),1,!0);j(t),B((e,r)=>{J(t,`title`,e),G(n,r)},[()=>Y(`tts.play`),()=>Y(`tts.play_btn`)]),H(`click`,t,ge),W(e,t)};K(o,e=>{Fv.active?e(s):e(d,-1)});var f=z(o,2),p=L(f),m=L(p),h=z(m),g=z(h),_=z(g),v=z(_,2),y=e=>{W(e,ZS())};K(v,e=>{X.markerHidden&&e(y)}),j(p);var b=z(p,1,!0);j(f);var x=z(f,2),S=L(x);j(x);var C=z(x,2),w=z(L(C));j(C);var T=z(C,2),E=e=>{var t=QS(),n=z(L(t));j(t),B((e,r)=>{J(t,`title`,e),G(n,` ${r??``}`)},[()=>Y(`versions.button_title`),()=>Y(`versions.button`)]),H(`click`,t,()=>F(l,!0)),W(e,t)};K(T,e=>{V(u)&&e(E)});var D=z(T,2),ee=z(L(D));j(D),B((e,t,a,o,s,c,l,u)=>{J(f,`title`,e),gi(f,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${X.markerActive?`border-yellow-400 bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`),J(m,`fill`,V(n)),J(h,`fill`,V(r)),J(g,`fill`,V(i)),J(_,`fill`,V(i)),G(b,t),J(x,`title`,a),G(S,`📄 ${o??``}`),J(C,`title`,s),G(w,` ${c??``}`),J(D,`title`,l),G(ee,` ${u??``}`)},[()=>Y(`doc.marker_mode`),()=>Y(`doc.marker_btn`),()=>Y(`doc.export_pdf`),()=>Y(`doc.export_pdf_btn`),()=>Y(`metadata.button_title`),()=>Y(`metadata.button`),()=>Y(`doc.edit`),()=>Y(`doc.edit_btn`)]),H(`click`,f,()=>X.toggleMarker()),H(`click`,x,me),H(`click`,C,()=>F(c,!0)),H(`click`,D,()=>V(a).enterEdit()),W(e,t)};K(h,e=>{V(g)||e(y)});var b=z(h,2),x=e=>{var t=eC(),n=z(L(t));j(t),B((e,r)=>{J(t,`title`,e),G(n,` ${r??``}`)},[()=>Y(`kanban.edit_columns`),()=>Y(`kanban.edit_columns`)]),H(`click`,t,()=>V(a).openKanbanColumnsEditor()),W(e,t)};K(b,e=>{V(g)&&e(x)});var C=z(b,2),w=z(L(C));j(C);var T=z(C,2),E=e=>{var t=tC();B(e=>{J(t,`title`,e),gi(t,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${V(re)?`border-blue-400 bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`)},[()=>Y(`doc.toc_toggle`)]),H(`click`,t,de),W(e,t)};K(T,e=>{V(g)||e(E)}),j(o),B((e,t,n,r)=>{J(s,`aria-pressed`,V(_)),J(s,`title`,e),gi(s,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${V(_)?`border-amber-300 bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`),gi(d,1,`fa-${V(_)?`solid`:`regular`} fa-star`),G(f,t),J(C,`title`,n),G(w,` ${r??``}`)},[()=>V(_)?Y(`favorites.remove`):Y(`favorites.add`),()=>Y(`favorites.button`),()=>Y(`doc.delete`),()=>Y(`doc.delete_btn`)]),H(`click`,s,()=>$a.toggle({id:t.doc.id,title:t.doc.title})),H(`click`,C,()=>F(S,!0)),W(e,o)};K(Fe,e=>{V(y)?e(Ie):e(Le,-1)}),j(Pe),j(be);var Re=z(be,2),ze=e=>{F_(e,{onopen:()=>F(c,!0)})};K(Re,e=>{!V(y)&&!V(g)&&e(ze)});var Be=z(Re,2),Ve=e=>{var n=aC();q(n,21,r,Xr,(e,n,r)=>{var i=iC(),a=R(i),o=e=>{W(e,rC())};K(a,e=>{r>0&&e(o)});var s=z(a,2),c=L(s);j(s),B(()=>G(c,`← ${V(n).title??``}`)),H(`click`,s,()=>t.ongoback?.(r)),W(e,i)}),j(n),W(e,n)};K(Be,e=>{!V(y)&&r().length&&e(Ve)});var He=z(Be,2),Ue=e=>{var t=sC(),n=L(t),r=L(n,!0);j(n);var i=z(n,2);q(i,23,()=>V(f),e=>e.id,(e,t,n)=>{var r=oC(),i=L(r),a=L(i),o=L(a);j(a);var s=z(a),c=L(s,!0);j(s),j(i),j(r),B(()=>{G(o,`${V(n)+1}.`),G(c,V(t).snippet)}),H(`click`,i,()=>BS(V(t).id)),W(e,r)}),j(i),j(t),B(()=>G(r,V(m))),W(e,t)};K(He,e=>{!V(y)&&!V(g)&&V(f).length&&X.searchQuery&&e(Ue)});var We=z(He,2),Ge=e=>{var t=cC(),n=L(t,!0);j(t),B(()=>G(n,Fv.error)),W(e,t)};K(We,e=>{!V(y)&&!V(g)&&Fv.error&&e(Ge)});var Ke=z(We,2),Ye=e=>{var t=lC();Vi(t,e=>F(d,e),()=>V(d)),W(e,t)};K(Ke,e=>{V(g)||e(Ye)}),j(ye),Vi(ye,e=>F(ce,e),()=>V(ce));var Xe=z(ye,2),Ze=L(Xe);Vi(qd(L(Ze),{get docId(){return t.doc.id},get content(){return t.doc.content},get html(){return t.doc.html},get onsave(){return t.onsave},get onopen(){return t.onopen},onanchor:ee,onconfirmdelete:O,oncontentwired:te,get rewireSignal(){return X.searchQuery},get editing(){return V(y)},set editing(e){F(y,e,!0)},get saveMsg(){return V(b)},set saveMsg(e){F(b,e,!0)}}),e=>F(a,e,!0),()=>V(a)),j(Ze);var Qe=z(Ze,2),$e=e=>{var t=dC(),n=R(t),r=z(n,2),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o);q(s,21,()=>V(k),Xr,(e,t)=>{var n=uC(),r=L(n),i=L(r,!0);j(r),j(n),B(()=>{vi(n,`padding-left: ${(V(t).level-1)*.75}rem`),J(r,`title`,V(t).text),G(i,V(t).text)}),H(`click`,r,()=>fe(V(t).id)),W(e,n)}),j(s),j(o),j(r),Vi(r,e=>F(se,e),()=>V(se)),B(e=>{gi(n,1,`no-print w-1 shrink-0 self-stretch cursor-col-resize select-none transition-colors ${V(oe)?`bg-blue-500/60`:`bg-transparent hover:bg-blue-500/40`}`),vi(r,`width: 224px; top: ${V(le)??``}px; min-height: calc(100vh - ${V(le)??``}px); max-height: calc(100vh - ${V(le)??``}px)`),G(a,e)},[()=>Y(`doc.toc_title`)]),H(`mousedown`,n,ue),W(e,t)};K(Qe,e=>{V(ie)&&e($e)}),j(Xe);var et=z(Xe,2),tt=e=>{Vi(D_(e,{get contentEl(){return V(i)},get docId(){return t.doc.id}}),e=>F(o,e,!0),()=>V(o))};K(et,e=>{V(g)||e(tt)});var nt=z(et,2);nv(nt,{get open(){return V(c)},get docId(){return t.doc.id},get content(){return t.doc.content},onclose:()=>F(c,!1)});var rt=z(nt,2);hv(rt,{get open(){return V(l)},get docId(){return t.doc.id},get content(){return t.doc.content},get onsave(){return t.onsave},onclose:()=>F(l,!1)});var it=z(rt,2);Vi(ad(it,{}),e=>F(s,e,!0),()=>V(s));var at=z(it,2),ot=e=>{var t=fC(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var s=z(a,2),c=L(s),l=L(c,!0);j(c);var u=z(c,2),d=L(u,!0);j(u),j(s);var f=z(s,2),p=L(f),m=L(p,!0);j(p),j(f),j(n),j(t),B((e,t,n,r,a)=>{G(i,e),G(o,t),c.disabled=V(T),G(l,n),u.disabled=V(T),G(d,r),p.disabled=V(T),G(m,a)},[()=>Y(`tts.language_title`),()=>Y(`tts.language_message`),()=>Y(`tts.language_en`),()=>Y(`tts.language_fr`),()=>Y(`common.cancel`)]),H(`click`,t,e=>{e.target===e.currentTarget&&!V(T)&&F(w,!1)}),H(`click`,c,()=>_e(`en`)),H(`click`,u,()=>_e(`fr`)),H(`click`,p,()=>F(w,!1)),W(e,t)};K(at,e=>{V(w)&&e(ot)});var st=z(at,2),ct=e=>{var n=pC(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d,!0);j(d),j(c),j(r),j(n),B((e,n,r)=>{G(a,e),G(s,t.doc.title),G(u,n),G(f,r)},[()=>Y(`doc.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`doc.confirm_delete_btn`)]),H(`click`,n,e=>{e.target===e.currentTarget&&F(S,!1)}),H(`click`,l,()=>F(S,!1)),H(`click`,d,async()=>{F(S,!1),await t.ondelete()}),W(e,n)};K(st,e=>{V(S)&&e(ct)}),B(()=>{G(Te,t.doc.category),G(ke,t.doc.title)}),W(e,ve),Je()}Pr([`click`,`mousedown`]);var gC=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),_C=U(`<p class="px-3 py-3 text-xs text-red-400 text-center"> </p>`),vC=U(`<p class="px-3 py-3 text-xs text-gray-400 text-center"> </p>`),yC=U(`<button class="w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><span class="text-gray-400 shrink-0">&#128193;</span> <span class="truncate text-gray-700 dark:text-gray-300"> </span></button>`),bC=U(`<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden text-sm"><div class="flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"><button class="text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-30 disabled:pointer-events-none shrink-0"> </button> <span class="text-xs text-gray-500 dark:text-gray-400 font-mono truncate flex-1"> </span></div> <div class="max-h-40 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800"><!></div></div>`),xC=U(`<p class="text-xs text-red-500"> </p>`),SC=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-md mx-4 p-6 space-y-4"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><svg width="16" height="16" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="inline-block mr-1 align-text-bottom"><path d="M2 5a2 2 0 012-2h3.586a1 1 0 01.707.293L9.707 4.707A1 1 0 0010.414 5H16a2 2 0 012 2v8a2 2 0 01-2 2H4a2 2 0 01-2-2V5z" stroke="currentColor" stroke-width="1.5" fill="none"></path><line x1="10" y1="8" x2="10" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></line><line x1="7" y1="11" x2="13" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></line></svg> <span> </span></h3> <div class="space-y-1.5"><label for="new-folder-name" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <input id="new-folder-name" type="text" class="w-full px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"/></div> <div class="space-y-1.5"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <div class="flex items-center gap-2"><span class="flex-1 text-sm text-gray-600 dark:text-gray-300 font-mono truncate"> </span> <button class="text-xs px-2 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0"> </button></div> <!></div> <div class="space-y-1"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <p class="text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 truncate"> </p></div> <!> <div class="flex justify-end gap-3 pt-1"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div></div>`);function CC(e,t){qe(t,!0);let n=P(``),r=P(null),i=P(null),a=P(``),o=P(``),s=P(`/ (root)`),c=P(!1),l=P(``),u=P(I([])),d=P(!1),f=P(!1),p=P(``),m=P(!1),h=P(null),g=!1;kn(()=>{t.open&&!g?(g=!0,_()):t.open||(g=!1)});async function _(){try{F(n,(await fetch(`/api/config`).then(e=>e.json())).docsFolder||``,!0)}catch{F(n,``)}let e=``;if(X.currentDocId){let t=decodeURIComponent(X.currentDocId);if(!t.startsWith(`/`)){let n=t.split(`/`);n.length>1&&(e=n.slice(0,-1).join(`/`))}}F(a,e?V(n)+`/`+e:V(n),!0),F(r,V(a),!0),F(i,null),F(o,``),F(s,e?`/`+e:`/ (root)`,!0),F(c,!1),F(p,``),F(m,!1),setTimeout(()=>V(h)?.focus(),50)}let v=N(()=>{let e=uc(V(o));if(!e)return Y(`modal.new_folder.enter_name`);let t=V(a)||V(n),r=t.startsWith(V(n))?t.slice(V(n).length).replace(/^\//,``):``;return(r?r+`/`:``)+e});function y(e){let t=e.currentTarget,n=uc(t.value);t.value!==n&&(t.value=n),V(o)!==n&&F(o,n,!0)}function b(){F(c,!V(c)),V(c)&&x(V(r)||V(n))}async function x(e){F(d,!0),F(f,!1);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(r,t.current,!0),F(i,t.parent,!0),F(a,t.current,!0),F(l,t.current,!0),F(s,(t.current.startsWith(V(n)+`/`)?t.current.slice(V(n).length):t.current===V(n)?``:t.current)||`/ (root)`,!0),F(u,t.dirs||[],!0)}catch{F(f,!0),F(u,[],!0)}finally{F(d,!1)}}let S=N(()=>V(r)===V(n));function C(){V(i)&&x(V(i))}async function w(){let e=uc(V(o));if(F(p,``),!e){F(p,Y(`modal.new_folder.error_empty`),!0);return}if(!/^[a-zA-Z0-9_.-]+$/.test(e)){F(p,Y(`modal.new_folder.error_invalid_chars`),!0);return}let r=V(a)||V(n);if(r===V(n)&&(e===`files`||e===`images`)){F(p,Y(`modal.new_folder.error_reserved`),!0);return}let i=r.endsWith(`/`)?r+e:r+`/`+e;F(m,!0);try{let e=await fetch(`/api/browse/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:i})});if(!e.ok)throw Error(await e.text());t.onclose(),t.onsuccess()}catch(e){F(m,!1),F(p,Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}}var T=Wr(),E=R(T),D=e=>{var n=SC(),r=L(n),i=L(r),a=z(L(i),2),g=L(a,!0);j(a),j(i);var _=z(i,2),T=L(_),E=L(T,!0);j(T);var D=z(T,2);Di(D),Vi(D,e=>F(h,e),()=>V(h)),j(_);var ee=z(_,2),te=L(ee),O=L(te,!0);j(te);var ne=z(te,2),re=L(ne),k=L(re,!0);j(re);var ie=z(re,2),ae=L(ie,!0);j(ie),j(ne);var oe=z(ne,2),se=e=>{var t=bC(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n);var s=z(n,2),c=L(s),p=e=>{var t=gC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},m=e=>{var t=_C(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`modal.new_folder.error_loading`)]),W(e,t)},h=e=>{var t=vC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`modal.new_folder.no_subfolders`)]),W(e,t)},g=e=>{var t=Wr();q(R(t),17,()=>V(u),e=>e.path,(e,t)=>{var n=yC(),r=z(L(n),2),i=L(r,!0);j(r),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>x(V(t).path)),W(e,n)}),W(e,t)};K(c,e=>{V(d)?e(p):V(f)?e(m,1):V(u).length===0?e(h,2):e(g,-1)}),j(s),j(t),B(e=>{r.disabled=V(S),G(i,e),G(o,V(l))},[()=>Y(`common.up`)]),H(`click`,r,C),W(e,t)};K(oe,e=>{V(c)&&e(se)}),j(ee);var ce=z(ee,2),le=L(ce),ue=L(le,!0);j(le);var de=z(le,2),fe=L(de,!0);j(de),j(ce);var pe=z(ce,2),me=e=>{var t=xC(),n=L(t,!0);j(t),B(()=>G(n,V(p))),W(e,t)};K(pe,e=>{V(p)&&e(me)});var he=z(pe,2),ge=L(he),_e=L(ge,!0);j(ge);var ve=z(ge,2),ye=L(ve,!0);j(ve),j(he),j(r),j(n),B((e,t,n,r,i,a,o,c)=>{G(g,e),G(E,t),J(D,`placeholder`,n),G(O,r),G(k,V(s)),G(ae,i),G(ue,a),G(fe,V(v)),G(_e,o),ve.disabled=V(m),G(ye,c)},[()=>Y(`modal.new_folder.title`),()=>Y(`modal.new_folder.name_label`),()=>Y(`modal.new_folder.name_placeholder`),()=>Y(`modal.new_folder.location_label`),()=>Y(`modal.new_folder.browse_btn`),()=>Y(`modal.new_folder.will_be_created`),()=>Y(`common.cancel`),()=>V(m)?Y(`modal.new_folder.creating_btn`):Y(`modal.new_folder.create_btn`)]),H(`click`,n,e=>{e.target===e.currentTarget&&t.onclose()}),H(`input`,D,y),Ni(D,()=>V(o),e=>F(o,e)),H(`click`,ie,b),H(`click`,ge,function(...e){t.onclose?.apply(this,e)}),H(`click`,ve,w),W(e,n)};K(E,e=>{t.open&&e(D)}),W(e,T),Je()}Pr([`click`,`input`]);var wC=U(`<option></option>`),TC=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),EC=U(`<p class="px-3 py-4 text-xs text-red-400 text-center"> </p>`),DC=U(`<p class="px-3 py-3 text-xs text-gray-400 text-center"> </p>`),OC=U(`<button class="w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><span class="text-gray-400 shrink-0">&#128193;</span> <span class="text-gray-700 dark:text-gray-300 truncate"> </span></button>`),kC=U(`<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden"><div class="flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"><button class="text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-30 disabled:pointer-events-none shrink-0"> </button> <span class="font-mono text-xs text-gray-400 dark:text-gray-500 truncate flex-1 text-right"> </span></div> <div class="divide-y divide-gray-100 dark:divide-gray-800 max-h-40 overflow-y-auto"><!></div> <div class="border-t border-gray-200 dark:border-gray-700 flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800/50"><input type="text" class="flex-1 px-2 py-1 text-xs rounded border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-blue-400"/> <button class="text-xs px-2 py-1 rounded bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shrink-0"> </button></div></div>`),AC=U(`<p class="text-xs text-red-500"> </p>`),jC=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-lg mx-4 p-6 space-y-4"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50">&#10133; <span> </span></h3> <div class="space-y-1.5"><label for="new-doc-title" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <input id="new-doc-title" type="text" class="w-full px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"/></div> <div class="space-y-1.5"><label for="new-doc-category" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <input id="new-doc-category" type="text" list="new-doc-category-options" autocomplete="off" placeholder="GENERAL" class="w-full px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"/> <datalist id="new-doc-category-options"></datalist></div> <div class="space-y-1.5"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <div class="flex items-center gap-2"><span class="flex-1 px-3 py-2 text-xs rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-500 dark:text-gray-400 font-mono truncate"> </span> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0">&#128193; <span> </span></button></div> <!></div> <div class="space-y-1.5"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <p class="text-xs bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 font-mono text-gray-600 dark:text-gray-300 break-all"> </p></div> <!> <div class="flex justify-end gap-3 pt-1"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div></div>`);function MC(e,t){qe(t,!0);let n=P(``),r=P(`YYYY_MM_DD_HH_mm_[Category]_title`),i=P(null),a=P(null),o=P(``),s=P(``),c=P(``),l=P(`/ (root)`),u=P(!1),d=P(``),f=P(I([])),p=P(!1),m=P(!1),h=P(``),g=P(I([])),_=P(``),v=P(!1),y=P(null);function b(e){return(e||``).normalize(`NFD`).replace(/[̀-ͯ]/g,``).toUpperCase().replace(/[^A-Z0-9_-]/g,``)}function x(e){let t=V(n);return e===t?``:e.startsWith(t+`/`)?e.slice(t.length+1):e}let S=!1;kn(()=>{t.open&&!S?(S=!0,C()):t.open||(S=!1)});async function C(){try{let e=await fetch(`/api/config`).then(e=>e.json());F(n,e.docsFolder||``,!0),F(r,e.filenamePattern||`YYYY_MM_DD_HH_mm_[Category]_title`,!0)}catch{F(n,``),F(r,`YYYY_MM_DD_HH_mm_[Category]_title`)}let e=X.currentDocId&&X.allDocs.find(e=>e.id===X.currentDocId),t=b(e&&e.category||`General`)||`GENERAL`,d=``;if(X.currentDocId){let e=decodeURIComponent(X.currentDocId);if(!e.startsWith(`/`)){let t=e.split(`/`);t.length>1&&(d=t.slice(0,-1).join(`/`))}}let f=d?V(n)+`/`+d:``;F(o,d,!0),F(i,f||null,!0),F(a,null),w(),F(s,``),F(c,t,!0),F(l,d?`/`+d:`/ (root)`,!0),F(u,!1),F(h,``),F(_,``),F(v,!1),setTimeout(()=>V(y)?.focus(),50)}function w(){let e=new Set;(X.allDocs||[]).forEach(t=>{let n=b(t.category||``);n&&e.add(n)}),F(g,Array.from(e).sort((e,t)=>e.localeCompare(t)),!0)}function T(){let e=b(V(c));V(c)!==e&&F(c,e,!0)}function E(e){let t=e.currentTarget,n=uc(t.value);t.value!==n&&(t.value=n),V(h)!==n&&F(h,n,!0)}let D=N(()=>{let e=V(s).trim();if(!e)return Y(`modal.new_doc.title_placeholder`);let t=b(V(c))||`GENERAL`,n=new Date,i=n.getFullYear(),a=String(n.getMonth()+1).padStart(2,`0`),l=String(n.getDate()).padStart(2,`0`),u=String(n.getHours()).padStart(2,`0`),d=String(n.getMinutes()).padStart(2,`0`),f=e.toLowerCase().replace(/\s+/g,`_`).replace(/[^a-z0-9_]/g,``).replace(/_+/g,`_`).replace(/^_|_$/g,``)||`document`,p=V(r).replace(`YYYY`,String(i)).replace(`MM`,a).replace(`DD`,l).replace(`HH`,u).replace(`mm`,d).replace(/\[Category\]/i,`[${t}]`).replace(/(?<![a-z0-9])(?:title_words|title)(?![a-z0-9])/i,f)+`.md`;return V(o)?V(o)+`/`+p:p});function ee(){F(u,!V(u)),V(u)&&te(V(i)||V(n))}async function te(e){F(p,!0),F(m,!1);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(i,t.current,!0),F(a,t.parent,!0),F(o,x(t.current),!0),F(d,t.current,!0),F(l,V(o)?`/`+V(o):`/ (root)`,!0),F(f,t.dirs||[],!0)}catch{F(m,!0),F(f,[],!0)}finally{F(p,!1)}}let O=N(()=>V(i)===V(n));function ne(){V(i)!==V(n)&&V(a)&&te(V(a))}function re(){let e=uc(V(h));if(!e)return;let t=V(i)||V(n);if(t===V(n)&&(e===`files`||e===`images`)){F(_,Y(`modal.new_folder.error_reserved`),!0);return}F(_,``);let r=(x(t)?x(t)+`/`:``)+e;F(o,r),F(l,`/`+r),F(h,``)}async function k(){let e=V(s).trim(),n=b(V(c))||`GENERAL`;if(!e){F(_,Y(`modal.new_doc.error_empty_title`),!0);return}F(_,``),F(v,!0);try{let r=await fetch(`/api/documents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:e,category:n,folder:V(o)})});if(!r.ok){let e=await r.json();throw Error(e.error||`Creation failed`)}let i=await r.json();t.onclose(),t.onsuccess(i.id)}catch(e){F(_,Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e))),F(v,!1)}}function ie(e){e.key===`Enter`&&k(),e.key===`Escape`&&t.onclose()}var ae=Wr(),oe=R(ae),se=e=>{var n=jC(),r=L(n),i=L(r),a=z(L(i)),o=L(a,!0);j(a),j(i);var b=z(i,2),x=L(b),S=L(x,!0);j(x);var C=z(x,2);Di(C),Vi(C,e=>F(y,e),()=>V(y)),j(b);var w=z(b,2),ae=L(w),oe=L(ae,!0);j(ae);var se=z(ae,2);Di(se);var ce=z(se,2);q(ce,20,()=>V(g),e=>e,(e,t)=>{var n=wC(),r={};B(()=>{r!==(r=t)&&(n.value=(n.__value=t)??``)}),W(e,n)}),j(ce),j(w);var le=z(w,2),ue=L(le),de=L(ue,!0);j(ue);var fe=z(ue,2),pe=L(fe),me=L(pe,!0);j(pe);var he=z(pe,2),ge=z(L(he)),_e=L(ge,!0);j(ge),j(he),j(fe);var ve=z(fe,2),ye=e=>{var t=kC(),n=L(t),r=L(n),i=L(r);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n);var s=z(n,2),c=L(s),l=e=>{var t=TC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},u=e=>{var t=EC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.cannot_read_dir`)]),W(e,t)},g=e=>{var t=DC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`modal.new_doc.no_subfolders`)]),W(e,t)},_=e=>{var t=Wr();q(R(t),17,()=>V(f),e=>e.path,(e,t)=>{var n=OC(),r=z(L(n),2),i=L(r,!0);j(r),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>te(V(t).path)),W(e,n)}),W(e,t)};K(c,e=>{V(p)?e(l):V(m)?e(u,1):V(f).length===0?e(g,2):e(_,-1)}),j(s);var v=z(s,2),y=L(v);Di(y);var b=z(y,2),x=L(b,!0);j(b),j(v),j(t),B((e,t,n)=>{r.disabled=V(O),G(i,`↑ ${e??``}`),G(o,V(d)),J(y,`placeholder`,t),G(x,n)},[()=>Y(`common.up`),()=>Y(`modal.new_doc.new_folder_placeholder`),()=>Y(`modal.new_doc.create_folder_btn`)]),H(`click`,r,ne),H(`input`,y,E),H(`keydown`,y,e=>{e.key===`Enter`&&re()}),Ni(y,()=>V(h),e=>F(h,e)),H(`click`,b,re),W(e,t)};K(ve,e=>{V(u)&&e(ye)}),j(le);var be=z(le,2),xe=L(be),Se=L(xe,!0);j(xe);var Ce=z(xe,2),A=L(Ce,!0);j(Ce),j(be);var we=z(be,2),Te=e=>{var t=AC(),n=L(t,!0);j(t),B(()=>G(n,V(_))),W(e,t)};K(we,e=>{V(_)&&e(Te)});var Ee=z(we,2),De=L(Ee),Oe=L(De,!0);j(De);var ke=z(De,2),Ae=L(ke,!0);j(ke),j(Ee),j(r),j(n),B((e,t,n,r,i,a,s,c,u)=>{G(o,e),G(S,t),J(C,`placeholder`,n),G(oe,r),G(de,i),G(me,V(l)),G(_e,a),G(Se,s),G(A,V(D)),G(Oe,c),ke.disabled=V(v),G(Ae,u)},[()=>Y(`modal.new_doc.title`),()=>Y(`modal.new_doc.title_label`),()=>Y(`modal.new_doc.title_placeholder`),()=>Y(`modal.new_doc.category_label`),()=>Y(`modal.new_doc.location_label`),()=>Y(`modal.new_doc.browse_btn`),()=>Y(`modal.new_doc.filename_label`),()=>Y(`common.cancel`),()=>V(v)?Y(`modal.new_folder.creating_btn`):Y(`common.create`)]),H(`click`,n,e=>{e.target===e.currentTarget&&t.onclose()}),H(`keydown`,C,ie),Ni(C,()=>V(s),e=>F(s,e)),H(`input`,se,T),H(`keydown`,se,ie),Ni(se,()=>V(c),e=>F(c,e)),H(`click`,he,ee),H(`click`,De,function(...e){t.onclose?.apply(this,e)}),H(`click`,ke,k),W(e,n)};K(oe,e=>{t.open&&e(se)}),W(e,ae),Je()}Pr([`click`,`keydown`,`input`]);var NC=U(`<p class="text-sm text-gray-400 py-2"> </p>`),PC=U(`<p class="text-sm text-red-500"> </p>`),FC=U(`<label class="flex items-center gap-3 px-1 py-1.5 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer"><input type="checkbox" class="w-4 h-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"/> <span class="text-sm text-gray-700 dark:text-gray-300"> </span></label>`),IC=U(`<div><div class="max-h-48 overflow-y-auto space-y-0.5 border border-gray-200 dark:border-gray-700 rounded-lg p-2"><!></div></div>`),LC=U(`<div><p class="text-xs text-gray-500 dark:text-gray-400"> </p> <div class="flex justify-end gap-3 pt-2"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div>`),RC=U(`<div><p class="text-xs text-gray-500 dark:text-gray-400"> </p> <div class="flex justify-end gap-3 pt-2"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg border border-blue-500 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 font-semibold transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div>`),zC=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-sm mx-4 p-6 space-y-4"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-file-export mr-2 text-blue-500"></i> <span> </span></h3> <div class="flex gap-0 border-b border-gray-200 dark:border-gray-700"><button> </button> <button> </button> <button> </button></div> <!> <!> <!> <!></div></div>`);function BC(e,t){qe(t,!0);let n=P(`markdown`),r=!1,i=P(!1),a=P(!1),o=P(I([])),s=P(I({})),c=P(!1),l=P(!1),u=P(!1),d=P(!1),f=!1;kn(()=>{t.open&&!f?(f=!0,F(n,`markdown`),r=!1,F(o,[],!0),F(s,{},!0)):t.open||(f=!1)});function p(e){return String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function m(e){F(n,e,!0),e===`html`&&h()}async function h(){if(!r){F(i,!0),F(a,!1);try{let e=await fetch(`/api/documents`).then(e=>e.json()),t=new Set;e.forEach(e=>t.add(e.folder?.[0]??e.category??`General`)),F(o,[...t].sort((e,t)=>e===`General`?-1:t===`General`?1:e.localeCompare(t)),!0),r=!0}catch{F(a,!0)}finally{F(i,!1)}}}async function g(){F(c,!0);try{let e=await fetch(`/api/export/markdown`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!e.ok)throw Error(await e.text());let n=await e.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`export-markdown.zip`,i.click(),URL.revokeObjectURL(r),t.onclose()}catch(e){alert(Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}finally{F(c,!1)}}async function _(e){let n=V(o).filter(e=>V(s)[e]);if(n.length){F(e===`confluence`?u:l,!0);try{let r=await fetch(`/api/export/html`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({folders:n,mode:e})});if(!r.ok)throw Error(await r.text());let i=await r.blob(),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`export-${e}.zip`,o.click(),URL.revokeObjectURL(a),t.onclose()}catch(e){alert(Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}finally{F(u,!1),F(l,!1)}}}async function v(){F(d,!0);try{let e=X.allDocs&&X.allDocs.length?X.allDocs:await fetch(`/api/documents`).then(e=>e.json()),n={};for(let t=0;t<e.length;t+=5){let r=e.slice(t,t+5),i=await Promise.all(r.map(e=>fetch(`/api/documents/`+e.id).then(e=>e.ok?e.json():null).catch(()=>null)));for(let r of i)r&&(n[r.id??e[t]?.id]=r);r.forEach((e,t)=>{i[t]&&(n[e.id]=i[t])})}function r(e){let t={categories:{},children:{}};for(let n of e){let e=t;for(let t of n.folder||[])e.children[t]||(e.children[t]={categories:{},children:{}}),e=e.children[t];e.categories[n.category]||(e.categories[n.category]=[]),e.categories[n.category].push(n)}return t}function i(e){let t=[];e.categories.General&&t.push(...e.categories.General);let n=Object.keys(e.children).sort((e,t)=>e.localeCompare(t));for(let r of n)t.push(...i(e.children[r]));let r=Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t));for(let n of r)t.push(...e.categories[n]);return t}function a(e){return e.replace(/^\d+_/,``).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function o(e,t){let n=``,r=t*1.25,i=(e,i)=>{let a=t===0&&e===`General`?`General`:e;n+=`<li style="margin-left:${r}rem;margin-top:${t===0?`0.75`:`0.4`}rem;">`,n+=`<span style="font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.05em;color:#6b7280;">${a}</span>`,n+=`<ul style="margin:0.2rem 0 0 0;padding:0;list-style:none;">`;for(let e of i)n+=`<li style="margin-left:${r+.75}rem;padding:0.15rem 0;">`,n+=`<a href="#doc-${e.id}" style="color:#1d4ed8;text-decoration:none;font-size:0.875rem;">${p(e.title)}</a>`,e.formattedDate&&(n+=`<span style="color:#9ca3af;font-size:0.7rem;margin-left:0.5rem;">${p(e.formattedDate)}</span>`),n+=`</li>`;n+=`</ul></li>`};e.categories.General&&i(`General`,e.categories.General);let s=Object.keys(e.children).sort((e,t)=>e.localeCompare(t));for(let i of s)n+=`<li style="margin-left:${r}rem;margin-top:0.75rem;">`,n+=`<span style="font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.05em;color:#7c3aed;">&#128193; ${a(i)}</span>`,n+=`<ul style="margin:0.2rem 0 0 0;padding:0;list-style:none;">`,n+=o(e.children[i],t+1),n+=`</ul></li>`;let c=Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t));for(let t of c)i(t,e.categories[t]);return n}function s(e){return e.replace(/href="[^"]*\?doc=([^"&#]+)(?:#[^"]*)?"/g,(e,t)=>`href="#doc-${t}"`)}let c=p(document.title||`Living Documentation`),l=r(e),u=i(l),d=`<!DOCTYPE html>
223
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=xS(bS(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=xS(bS(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function wS(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new gS||null,prettyErrors:t}}function TS(e,t={}){let{lineCounter:n,prettyErrors:r}=wS(t),i=new CS(n?.addNewLine),a=new nS(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new vx(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(bx(e,n)),o.warnings.forEach(bx(e,n))),o}function ES(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=TS(e,n);if(!i)return null;if(i.warnings.forEach(e=>$y(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}var DS=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,OS=/^\s*\*\*[A-Za-z0-9_-]+\s*:\s*\*\*/m,kS=/^\s*(?:\*\*)?([A-Za-z0-9_-]+)(?:\*\*)?\s*:\s*(?:\*\*)?\s*(.*?)\s*$/;function AS(e){if(typeof e!=`string`)return{data:{},body:``,format:`none`,raw:``};let t=e.match(DS);if(!t)return{data:{},body:e,format:`none`,raw:``};let n=t[1],r=e.slice(t[0].length);if(OS.test(n))return{data:jS(n),body:r,format:`legacy`,raw:n};try{let e=ES(n);return{data:e&&typeof e==`object`&&!Array.isArray(e)?e:{},body:r,format:`yaml`,raw:n}}catch{return{data:jS(n),body:r,format:`legacy`,raw:n}}}function jS(e){let t={};for(let n of e.split(/\r?\n/)){let e=kS.exec(n);if(!e)continue;let r=e[1],i=e[2];r.toLowerCase()===`tags`?t[r]=i.split(`,`).map(e=>e.trim()).filter(Boolean):t[r]=i}return t}function MS(e,t){let n=t.toLowerCase();for(let t of Object.keys(e))if(t.toLowerCase()===n)return e[t]}function NS(e){return e==null?null:Array.isArray(e)?e.map(e=>String(e)).join(`, `):String(e)}function PS(e,t){let{data:n}=AS(e);for(let e of t){let t=MS(n,e);if(t!=null)return NS(t)}return null}var FS=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,IS=/^(\s*(?:\*\*)?(?:language|lang|locale|langue)(?:\*\*)?\s*:\s*(?:\*\*)?\s*)(.+?)\s*$/i;function LS(e){let t=(e??``).trim().toLowerCase();return t?t===`en`||t.startsWith(`en-`)||t===`english`||t===`anglais`?`en`:t===`fr`||t.startsWith(`fr-`)||t===`french`||t===`francais`||t===`français`?`fr`:null:null}function RS(e){return LS(PS(e,[`language`,`lang`,`locale`,`langue`]))}function zS(e,t){let n=e.match(FS);if(!n)return`---\n**language:** ${t}\n---\n\n${e}`;let r=n[0],i=n[1].split(/\r?\n/),a=i.findIndex(e=>IS.test(e));if(a>=0)i[a]=i[a].replace(IS,`$1${t}`);else{let e=i.findIndex(e=>/^\s*(?:\*\*)?date(?:\*\*)?\s*:\s*(?:\*\*)?/i.test(e)),n=e>=0?e+1:i.length;i.splice(n,0,`**language:** ${t}`)}return`---\n${i.join(`
224
+ `)}\n---\n`+e.slice(r.length)}var BS=e=>e.normalize(`NFC`).normalize(`NFD`).replace(/[̀-ͯ]/g,``).toLowerCase();function VS(e,t){let n=BS(t);if(!n)return[];let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=[];for(;r.nextNode();)i.push(r.currentNode);let a=0;i.forEach(e=>{let t=(e.textContent||``).normalize(`NFC`),r=BS(t);if(!r.includes(n))return;let i=``,o=0;for(;o<=r.length;){let e=r.indexOf(n,o);if(e===-1){i+=t.slice(o);break}i+=t.slice(o,e),i+=`<mark id="match-${a++}">${t.slice(e,e+n.length)}</mark>`,o=e+n.length}let s=document.createElement(`span`);s.innerHTML=i,e.parentNode?.replaceChild(s,e)});let o=[];return e.querySelectorAll(`mark[id^='match-']`).forEach(e=>{let r=((e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre`)||e.parentElement).textContent||``).trim(),i=BS(r).indexOf(n),a=Math.max(0,i-40),s=Math.min(r.length,i+t.length+40),c=(a>0?`…`:``)+r.slice(a,s)+(s<r.length?`…`:``);o.push({id:e.id,snippet:c})}),o}function HS(e){let t=document.getElementById(e),n=document.getElementById(`home-content-area`);if(!t||!n)return;let r=t.parentElement;for(;r&&r!==n;)r.tagName===`DETAILS`&&!r.open&&(r.open=!0),r=r.parentElement;document.querySelectorAll(`mark.match-active`).forEach(e=>{e.classList.remove(`match-active`)}),t.classList.add(`match-active`);let i=document.querySelector(`#home-doc-view header`),a=i?i.getBoundingClientRect().height:0,o=t.getBoundingClientRect().top,s=n.getBoundingClientRect().top,c=a+(n.clientHeight-a)/3;n.scrollTop+=o-s-c}var US=U(`<span class="inline-block text-xs font-semibold px-2.5 py-0.5 rounded-full bg-violet-100 text-violet-700 dark:bg-violet-900/40 dark:text-violet-300"> </span>`),WS=U(`<span class="text-xs text-gray-400 dark:text-gray-500"> </span>`),GS=U(`<button type="button" data-testid="copy-doc-id-btn"><i aria-hidden="true"></i></button>`),KS=U(`<span class="inline-block text-[11px] px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 border border-gray-200 dark:border-gray-700"> </span>`),qS=U(`<div class="mt-1.5 flex items-center gap-1.5 flex-wrap" data-testid="doc-tags"></div>`),JS=U(`<span> </span>`),YS=U(`<div data-testid="edit-actions" class="flex items-center gap-2"><!> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-1.5 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div>`),XS=U(`<button data-testid="validate-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-green-700 bg-green-600 text-white font-semibold hover:bg-green-700 transition-colors"><i class="fa-solid fa-check" style="margin-right:4px"></i> </button>`),ZS=U(`<button data-testid="tts-toggle" class="no-print text-sm px-3 py-1.5 rounded-lg border border-blue-300 dark:border-blue-700 bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 hover:bg-blue-100 dark:hover:bg-blue-900/50 transition-colors"><i></i></button> <button data-testid="tts-stop" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-stop"></i></button>`,1),QS=U(`<button data-testid="tts-play" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-headphones" style="margin-right:4px"></i> </button>`),$S=Hr(`<g><line x1="8" y1="8" x2="92" y2="92" stroke="currentColor" stroke-width="8" stroke-linecap="round"></line><line x1="92" y1="8" x2="8" y2="92" stroke="currentColor" stroke-width="8" stroke-linecap="round"></line></g>`),eC=U(`<button data-testid="versions-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-code-branch"></i> </button>`),tC=U(`<!> <button data-testid="marker-doc-btn"><svg width="18" height="18" viewBox="0 0 100 100" fill="none" style="display:inline-block;vertical-align:middle;margin-right:4px"><rect x="28" y="10" width="44" height="52" rx="6" transform="rotate(40 50 50)" stroke="currentColor" stroke-width="6"></rect><rect x="52" y="8" width="22" height="30" rx="6" transform="rotate(40 50 50)" stroke="currentColor" stroke-width="6"></rect><polygon points="28,60 10,80 30,80 38,72" stroke="currentColor" stroke-width="5" stroke-linejoin="round"></polygon><polygon points="28,48 19,70 36,75 55,70" stroke="currentColor" stroke-width="5" stroke-linejoin="round"></polygon><line x1="10" y1="90" x2="72" y2="90" stroke="currentColor" stroke-width="6" stroke-linecap="round"></line><!></svg> </button> <button data-testid="export-pdf-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"> </button> <button data-testid="metadata-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-code-compare"></i> </button> <!> <button data-testid="edit-doc-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-file-pen"></i> </button>`,1),nC=U(`<button data-testid="kanban-edit-columns" class="no-print text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-gear"></i> </button>`),rC=U(`<button data-testid="toc-toggle-btn"><i class="fa-solid fa-list-ul"></i></button>`),iC=U(`<div data-testid="view-actions" class="flex items-center gap-2"><button data-testid="favorite-doc-btn"><i style="margin-right:4px"></i> </button> <!> <!> <!> <button data-testid="delete-doc-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors"><i class="fa-solid fa-trash"></i> </button> <!></div>`),aC=U(`<span class="text-gray-300 dark:text-gray-600 mx-1">·</span>`),oC=U(`<!> <button class="text-blue-600 dark:text-blue-400 hover:underline"> </button>`,1),sC=U(`<div class="no-print mt-2 flex flex-wrap gap-1 text-xs"></div>`),cC=U(`<li><button class="w-full text-left px-3 py-1.5 hover:bg-yellow-100 dark:hover:bg-yellow-900/30 transition-colors"><span class="text-yellow-600 dark:text-yellow-500 font-mono text-xs mr-2"> </span><span class="text-xs"> </span></button></li>`),lC=U(`<div class="mt-4 rounded-lg bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 text-sm text-yellow-800 dark:text-yellow-300 overflow-hidden"><div class="px-3 py-2 font-medium border-b border-yellow-200 dark:border-yellow-800"> </div> <ol class="max-h-40 overflow-y-auto divide-y divide-yellow-100 dark:divide-yellow-900/40 list-none m-0 p-0"></ol></div>`),uC=U(`<div data-testid="tts-error" class="mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300"> </div>`),dC=U(`<div class="hidden no-print"></div>`),fC=U(`<li class="m-0 p-0"><button type="button" class="block w-full text-left bg-transparent border-0 cursor-pointer text-xs text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:underline py-0.5 leading-snug transition-colors truncate"> </button></li>`),pC=U(`<div></div> <aside class="no-print shrink-0 sticky self-start overflow-y-auto py-8 pr-4 pl-3 ld-toc-aside"><p class="text-xs font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500 mb-3"> </p> <nav><ul class="space-y-1 list-none m-0 p-0"></ul></nav></aside>`,1),mC=U(`<div data-testid="tts-language-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"><div class="w-full max-w-sm rounded-xl border border-gray-200 bg-white p-5 shadow-2xl dark:border-gray-700 dark:bg-gray-900"><h2 class="text-base font-semibold text-gray-900 dark:text-gray-50"> </h2> <p class="mt-2 text-sm text-gray-600 dark:text-gray-300"> </p> <div class="mt-4 grid grid-cols-2 gap-2"><button type="button" data-testid="tts-language-en" class="rounded-lg border border-gray-200 px-3 py-2 text-sm font-semibold text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800"> </button> <button type="button" data-testid="tts-language-fr" class="rounded-lg border border-gray-200 px-3 py-2 text-sm font-semibold text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800"> </button></div> <div class="mt-3 flex justify-end"><button type="button" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"> </button></div></div></div>`),hC=U(`<div class="fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-4"><div class="w-full max-w-sm bg-white dark:bg-gray-900 border border-red-200 dark:border-red-700 rounded-xl shadow-2xl p-5 flex flex-col gap-3"><p class="text-sm text-gray-700 dark:text-gray-200"> </p> <p class="text-xs text-gray-500 dark:text-gray-400 italic truncate"> </p> <div class="flex justify-end gap-2 mt-2"><button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-1.5 rounded-lg bg-red-500 hover:bg-red-600 text-white font-semibold transition-colors"> </button></div></div></div>`),gC=U(`<header id="home-doc-header" class="sticky top-0 z-10 bg-gray-50 dark:bg-gray-950 px-6 pt-8 pb-6 border-b border-gray-300 dark:border-gray-800"><div class="flex items-start gap-4 flex-wrap"><div class="shrink min-w-0"><div class="flex items-center gap-2 flex-wrap"><span class="flex items-center gap-2 flex-wrap"><!> <span class="inline-block text-xs font-semibold px-2.5 py-0.5 rounded-full bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"> </span></span> <!> <h1 data-testid="doc-title" class="min-w-0 text-xs font-normal text-gray-900 dark:text-gray-50 leading-tight"> </h1> <!></div> <!></div> <div class="flex items-center gap-2 flex-wrap ml-auto"><!></div></div> <!> <!> <!> <!> <!></header> <div class="flex min-h-full items-start"><article id="home-doc-view" data-testid="doc-view" class="flex-1 min-w-0 px-6 pt-8 pb-8"><!></article> <!></div> <!> <!> <!> <!> <!> <!>`,1);function _C(e,t){qe(t,!0);let n=/<div\s+data-ld-kanban\b/i,r=Wi(t,`navHistory`,19,()=>[]),i=P(null),a=P(null),o=P(null),s=P(null),c=P(!1),l=P(!1),u=P(!1),d=P(null),f=P(I([])),p=``,m=N(()=>V(f).length?Y(V(f).length===1?`search.notice_singular`:`search.notice_plural`).replace(`{count}`,String(V(f).length)).replace(`{query}`,X.searchQuery):``),h=N(()=>z_(t.doc.content)),g=N(()=>n.test(t.doc.content)),_=N(()=>$a.has(t.doc.id)),v=N(()=>(V(h)||``).toUpperCase()===`TO BE VALIDATED`),y=P(!1),b=P(null),x=P(!1),S=P(!1),C=P(!1),w=P(!1),T=P(!1);async function E(){try{let e=await(await fetch(`/api/git/status`)).json();F(u,e.mode===`enabled`&&e.ok===!0,!0)}catch{F(u,!1)}}kn(()=>{if(t.doc.id,V(g),V(g)){F(u,!1);return}E()}),kn(()=>{V(g)&&V(y)&&(F(y,!1),F(b,null))});function D(e,t){let n=document.getElementById(`home-content-area`);if(!n)return;let r=document.getElementById(`home-doc-header`),i=r?r.getBoundingClientRect().height:0,a=e.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop;n.scrollTo({top:Math.max(0,a-i-16),behavior:t?`smooth`:`auto`})}function ee(e){let t=document.getElementById(e);t&&D(t,!1)}function te(e){F(i,e,!0);let n=t.doc.id,r=X.searchQuery;if(V(g)){F(f,[],!0),F(k,[],!0),p=n;return}let a=typeof r==`string`&&r.toLowerCase().startsWith(`metadata://`);F(f,r&&!a?VS(e,r):[],!0),V(d)&&wv(e,V(d),Y),n===p?V(o)?.apply():(p=n,V(o)?.load(n),F_.load(n)),F(k,Array.from(e.querySelectorAll(`h1,h2,h3,h4,h5,h6`)).map(e=>({id:e.id,text:e.textContent?.trim()??``,level:parseInt(e.tagName[1])})).filter(e=>e.id&&e.text),!0)}function O(){return V(s).show({title:Y(`snippet.inline_delete_title`),message:Y(`snippet.inline_delete_message`),confirmLabel:Y(`snippet.inline_delete_confirm_btn`),cancelLabel:Y(`common.cancel`),danger:!0})}async function ne(){let e=1;try{let n=await F_.load(t.doc.id);n&&typeof n.accuracy==`number`&&(e=n.accuracy)}catch{}let n=Math.round(e*100),r=n<100,i=V_(t.doc.id),a=Y(i?`doc.validate_worklog_message`:`doc.validate_message`),o=r?Y(`doc.validate_detail_low_accuracy`).replace(`{accuracy}`,n+`%`):void 0;if(!await V(s).show({title:Y(`doc.validate_title`),message:a,detail:o,confirmLabel:Y(`doc.validate_confirm`),cancelLabel:Y(`common.cancel`)}))return;let c=B_(t.doc.content,i?`Done`:`Accepted`);if(c!==t.doc.content)try{await t.onsave(c),r&&await fetch(`/api/metadata/`+encodeURIComponent(t.doc.id)+`/refresh`,{method:`POST`}),await F_.load(t.doc.id),X.docStatuses={...X.docStatuses,[t.doc.id]:i?`Done`:`Accepted`}}catch(e){F(b,{text:Y(`doc.validate_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`},!0)}}kn(()=>{try{F(x,localStorage.getItem(`ld-full-width`)===`1`)}catch{}});let re=P(!1),k=P(I([])),ie=N(()=>!V(g)&&V(re)&&V(k).length>0),ae=`ld-toc-w`,oe=P(!1),se=P(null),ce=P(null),le=P(0);kn(()=>{if(!V(ce))return;let e=new ResizeObserver(()=>{F(le,V(ce).offsetHeight,!0)});return e.observe(V(ce)),F(le,V(ce).offsetHeight,!0),()=>e.disconnect()});function ue(e){if(e.preventDefault(),!V(se))return;let t=e.clientX,n=V(se).getBoundingClientRect().width;F(oe,!0),V(se).style.transition=`none`,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let r=e=>{let r=Math.max(160,Math.min(400,n-(e.clientX-t)));V(se).style.width=r+`px`},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),document.body.style.cursor=``,document.body.style.userSelect=``,F(oe,!1),V(se).style.transition=``;try{localStorage.setItem(ae,String(parseInt(V(se).style.width,10)))}catch{}};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)}kn(()=>{try{F(re,localStorage.getItem(`ld-toc-open`)===`1`)}catch{}try{let e=parseInt(localStorage.getItem(ae)||``,10);V(se)&&e>=160&&e<=400&&(V(se).style.width=e+`px`)}catch{}});function de(){F(re,!V(re));try{localStorage.setItem(`ld-toc-open`,V(re)?`1`:`0`)}catch{}}function fe(e){let t=document.getElementById(e),n=document.getElementById(`home-content-area`);if(!t||!n)return;let r=t.parentElement;for(;r&&r!==n;)r.tagName===`DETAILS`&&(r.open=!0),r=r.parentElement;D(t,!0)}async function pe(){try{await navigator.clipboard.writeText(decodeURIComponent(t.doc.id)),F(C,!0),setTimeout(()=>F(C,!1),1800)}catch{}}function me(){window.print()}function he(e){V(i)&&Lv.start(V(i),{language:e,codeLabel:Y(`tts.code_label`),imageLabel:Y(`tts.image_label`),diagramLabel:Y(`tts.diagram_label`),tableLabel:Y(`tts.table_label`)})}function ge(){let e=RS(t.doc.content);if(!e){F(w,!0);return}he(e)}async function _e(e){F(T,!0);try{let n=zS(t.doc.content,e);n!==t.doc.content&&await t.onsave(n),F(w,!1),he(e)}catch(e){F(b,{text:Y(`tts.language_save_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`},!0)}finally{F(T,!1)}}kn(()=>(t.doc.id,V(y),()=>{F(w,!1),Lv.stop()}));var ve=gC(),ye=R(ve),be=L(ye),xe=L(be),Se=L(xe),Ce=L(Se),A=L(Ce);q(A,17,()=>t.doc.folder||[],Xr,(e,t)=>{var n=US(),r=L(n,!0);j(n),B(e=>{J(n,`title`,V(t)),G(r,e)},[()=>Xg(V(t))]),W(e,n)});var we=z(A,2),Te=L(we,!0);j(we),j(Ce);var Ee=z(Ce,2),De=e=>{var n=WS(),r=L(n,!0);j(n),B(()=>G(r,t.doc.formattedDate)),W(e,n)};K(Ee,e=>{t.doc.formattedDate&&e(De)});var Oe=z(Ee,2),ke=L(Oe,!0);j(Oe);var Ae=z(Oe,2),je=e=>{var t=GS(),n=L(t);j(t),B(e=>{J(t,`title`,e),gi(t,1,`no-print inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-gray-200 text-xs text-gray-500 transition-colors hover:bg-gray-50 hover:text-blue-600 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-blue-400 ${V(C)?`text-green-600 dark:text-green-400`:``}`),gi(n,1,`fa-${V(C)?`solid fa-check`:`regular fa-copy`}`)},[()=>Y(`doc.copy_mcp_id`)]),H(`click`,t,pe),W(e,t)};K(Ae,e=>{V(g)||e(je)}),j(Se);var Me=z(Se,2),Ne=e=>{var n=qS();q(n,20,()=>t.doc.tags,e=>e,(e,t)=>{var n=KS(),r=L(n);j(n),B(()=>G(r,`#${t??``}`)),W(e,n)}),j(n),W(e,n)};K(Me,e=>{t.doc.tags&&t.doc.tags.length&&e(Ne)}),j(xe);var Pe=z(xe,2),Fe=L(Pe),Ie=e=>{var t=YS(),n=L(t),r=e=>{var t=JS(),n=L(t,!0);j(t),B(()=>{gi(t,1,`text-xs ${V(b).cls??``}`),G(n,V(b).text)}),W(e,t)};K(n,e=>{V(b)&&e(r)});var i=z(n,2),o=L(i,!0);j(i);var s=z(i,2),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(t),B((e,t,n,r)=>{G(o,e),J(s,`title`,t),G(c,n),G(u,r)},[()=>Y(`common.cancel`),()=>Y(`doc.snippets`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),H(`click`,i,()=>V(a).cancelEdit()),H(`click`,s,()=>V(a).openSnippets()),H(`click`,l,()=>V(a).save()),W(e,t)},Le=e=>{let n=N(()=>X.markerActive?`#fef08a`:`#bfdbfe`),r=N(()=>X.markerActive?`#fef08a`:`#93c5fd`),i=N(()=>X.markerActive?`#fde047`:`#93c5fd`);var o=iC(),s=L(o),d=L(s),f=z(d,1,!0);j(s);var p=z(s,2),m=e=>{var t=XS(),n=z(L(t),1,!0);j(t),B((e,r)=>{J(t,`title`,e),G(n,r)},[()=>Y(`doc.validate_mode`),()=>Y(`doc.validate_btn`)]),H(`click`,t,ne),W(e,t)};K(p,e=>{V(v)&&!V(g)&&e(m)});var h=z(p,2),y=e=>{var t=tC(),o=R(t),s=e=>{var t=ZS(),n=R(t),r=L(n);j(n);var i=z(n,2);B((e,t)=>{J(n,`title`,e),gi(r,1,`fa-solid ${Lv.status===`playing`?`fa-pause`:`fa-play`}`),J(i,`title`,t)},[()=>Lv.status===`playing`?Y(`tts.pause`):Y(`tts.resume`),()=>Y(`tts.stop`)]),H(`click`,n,()=>Lv.toggle()),H(`click`,i,()=>Lv.stop()),W(e,t)},d=e=>{var t=QS(),n=z(L(t),1,!0);j(t),B((e,r)=>{J(t,`title`,e),G(n,r)},[()=>Y(`tts.play`),()=>Y(`tts.play_btn`)]),H(`click`,t,ge),W(e,t)};K(o,e=>{Lv.active?e(s):e(d,-1)});var f=z(o,2),p=L(f),m=L(p),h=z(m),g=z(h),_=z(g),v=z(_,2),y=e=>{W(e,$S())};K(v,e=>{X.markerHidden&&e(y)}),j(p);var b=z(p,1,!0);j(f);var x=z(f,2),S=L(x);j(x);var C=z(x,2),w=z(L(C));j(C);var T=z(C,2),E=e=>{var t=eC(),n=z(L(t));j(t),B((e,r)=>{J(t,`title`,e),G(n,` ${r??``}`)},[()=>Y(`versions.button_title`),()=>Y(`versions.button`)]),H(`click`,t,()=>F(l,!0)),W(e,t)};K(T,e=>{V(u)&&e(E)});var D=z(T,2),ee=z(L(D));j(D),B((e,t,a,o,s,c,l,u)=>{J(f,`title`,e),gi(f,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${X.markerActive?`border-yellow-400 bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`),J(m,`fill`,V(n)),J(h,`fill`,V(r)),J(g,`fill`,V(i)),J(_,`fill`,V(i)),G(b,t),J(x,`title`,a),G(S,`📄 ${o??``}`),J(C,`title`,s),G(w,` ${c??``}`),J(D,`title`,l),G(ee,` ${u??``}`)},[()=>Y(`doc.marker_mode`),()=>Y(`doc.marker_btn`),()=>Y(`doc.export_pdf`),()=>Y(`doc.export_pdf_btn`),()=>Y(`metadata.button_title`),()=>Y(`metadata.button`),()=>Y(`doc.edit`),()=>Y(`doc.edit_btn`)]),H(`click`,f,()=>X.toggleMarker()),H(`click`,x,me),H(`click`,C,()=>F(c,!0)),H(`click`,D,()=>V(a).enterEdit()),W(e,t)};K(h,e=>{V(g)||e(y)});var b=z(h,2),x=e=>{var t=nC(),n=z(L(t));j(t),B((e,r)=>{J(t,`title`,e),G(n,` ${r??``}`)},[()=>Y(`kanban.edit_columns`),()=>Y(`kanban.edit_columns`)]),H(`click`,t,()=>V(a).openKanbanColumnsEditor()),W(e,t)};K(b,e=>{V(g)&&e(x)});var C=z(b,2),w=z(L(C));j(C);var T=z(C,2),E=e=>{var t=rC();B(e=>{J(t,`title`,e),gi(t,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${V(re)?`border-blue-400 bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`)},[()=>Y(`doc.toc_toggle`)]),H(`click`,t,de),W(e,t)};K(T,e=>{V(g)||e(E)}),j(o),B((e,t,n,r)=>{J(s,`aria-pressed`,V(_)),J(s,`title`,e),gi(s,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${V(_)?`border-amber-300 bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`),gi(d,1,`fa-${V(_)?`solid`:`regular`} fa-star`),G(f,t),J(C,`title`,n),G(w,` ${r??``}`)},[()=>V(_)?Y(`favorites.remove`):Y(`favorites.add`),()=>Y(`favorites.button`),()=>Y(`doc.delete`),()=>Y(`doc.delete_btn`)]),H(`click`,s,()=>$a.toggle({id:t.doc.id,title:t.doc.title})),H(`click`,C,()=>F(S,!0)),W(e,o)};K(Fe,e=>{V(y)?e(Ie):e(Le,-1)}),j(Pe),j(be);var Re=z(be,2),ze=e=>{L_(e,{onopen:()=>F(c,!0)})};K(Re,e=>{!V(y)&&!V(g)&&e(ze)});var Be=z(Re,2),Ve=e=>{var n=sC();q(n,21,r,Xr,(e,n,r)=>{var i=oC(),a=R(i),o=e=>{W(e,aC())};K(a,e=>{r>0&&e(o)});var s=z(a,2),c=L(s);j(s),B(()=>G(c,`← ${V(n).title??``}`)),H(`click`,s,()=>t.ongoback?.(r)),W(e,i)}),j(n),W(e,n)};K(Be,e=>{!V(y)&&r().length&&e(Ve)});var He=z(Be,2),Ue=e=>{var t=lC(),n=L(t),r=L(n,!0);j(n);var i=z(n,2);q(i,23,()=>V(f),e=>e.id,(e,t,n)=>{var r=cC(),i=L(r),a=L(i),o=L(a);j(a);var s=z(a),c=L(s,!0);j(s),j(i),j(r),B(()=>{G(o,`${V(n)+1}.`),G(c,V(t).snippet)}),H(`click`,i,()=>HS(V(t).id)),W(e,r)}),j(i),j(t),B(()=>G(r,V(m))),W(e,t)};K(He,e=>{!V(y)&&!V(g)&&V(f).length&&X.searchQuery&&e(Ue)});var We=z(He,2),Ge=e=>{var t=uC(),n=L(t,!0);j(t),B(()=>G(n,Lv.error)),W(e,t)};K(We,e=>{!V(y)&&!V(g)&&Lv.error&&e(Ge)});var Ke=z(We,2),Ye=e=>{var t=dC();Vi(t,e=>F(d,e),()=>V(d)),W(e,t)};K(Ke,e=>{V(g)||e(Ye)}),j(ye),Vi(ye,e=>F(ce,e),()=>V(ce));var Xe=z(ye,2),Ze=L(Xe);Vi(Yd(L(Ze),{get docId(){return t.doc.id},get content(){return t.doc.content},get html(){return t.doc.html},get onsave(){return t.onsave},get onopen(){return t.onopen},onanchor:ee,onconfirmdelete:O,oncontentwired:te,get rewireSignal(){return X.searchQuery},get editing(){return V(y)},set editing(e){F(y,e,!0)},get saveMsg(){return V(b)},set saveMsg(e){F(b,e,!0)}}),e=>F(a,e,!0),()=>V(a)),j(Ze);var Qe=z(Ze,2),$e=e=>{var t=pC(),n=R(t),r=z(n,2),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o);q(s,21,()=>V(k),Xr,(e,t)=>{var n=fC(),r=L(n),i=L(r,!0);j(r),j(n),B(()=>{vi(n,`padding-left: ${(V(t).level-1)*.75}rem`),J(r,`title`,V(t).text),G(i,V(t).text)}),H(`click`,r,()=>fe(V(t).id)),W(e,n)}),j(s),j(o),j(r),Vi(r,e=>F(se,e),()=>V(se)),B(e=>{gi(n,1,`no-print w-1 shrink-0 self-stretch cursor-col-resize select-none transition-colors ${V(oe)?`bg-blue-500/60`:`bg-transparent hover:bg-blue-500/40`}`),vi(r,`width: 224px; top: ${V(le)??``}px; min-height: calc(100vh - ${V(le)??``}px); max-height: calc(100vh - ${V(le)??``}px)`),G(a,e)},[()=>Y(`doc.toc_title`)]),H(`mousedown`,n,ue),W(e,t)};K(Qe,e=>{V(ie)&&e($e)}),j(Xe);var et=z(Xe,2),tt=e=>{Vi(k_(e,{get contentEl(){return V(i)},get docId(){return t.doc.id}}),e=>F(o,e,!0),()=>V(o))};K(et,e=>{V(g)||e(tt)});var nt=z(et,2);iv(nt,{get open(){return V(c)},get docId(){return t.doc.id},get content(){return t.doc.content},onclose:()=>F(c,!1)});var rt=z(nt,2);_v(rt,{get open(){return V(l)},get docId(){return t.doc.id},get content(){return t.doc.content},get onsave(){return t.onsave},onclose:()=>F(l,!1)});var it=z(rt,2);Vi(ad(it,{}),e=>F(s,e,!0),()=>V(s));var at=z(it,2),ot=e=>{var t=mC(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var s=z(a,2),c=L(s),l=L(c,!0);j(c);var u=z(c,2),d=L(u,!0);j(u),j(s);var f=z(s,2),p=L(f),m=L(p,!0);j(p),j(f),j(n),j(t),B((e,t,n,r,a)=>{G(i,e),G(o,t),c.disabled=V(T),G(l,n),u.disabled=V(T),G(d,r),p.disabled=V(T),G(m,a)},[()=>Y(`tts.language_title`),()=>Y(`tts.language_message`),()=>Y(`tts.language_en`),()=>Y(`tts.language_fr`),()=>Y(`common.cancel`)]),H(`click`,t,e=>{e.target===e.currentTarget&&!V(T)&&F(w,!1)}),H(`click`,c,()=>_e(`en`)),H(`click`,u,()=>_e(`fr`)),H(`click`,p,()=>F(w,!1)),W(e,t)};K(at,e=>{V(w)&&e(ot)});var st=z(at,2),ct=e=>{var n=hC(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d,!0);j(d),j(c),j(r),j(n),B((e,n,r)=>{G(a,e),G(s,t.doc.title),G(u,n),G(f,r)},[()=>Y(`doc.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`doc.confirm_delete_btn`)]),H(`click`,n,e=>{e.target===e.currentTarget&&F(S,!1)}),H(`click`,l,()=>F(S,!1)),H(`click`,d,async()=>{F(S,!1),await t.ondelete()}),W(e,n)};K(st,e=>{V(S)&&e(ct)}),B(()=>{G(Te,t.doc.category),G(ke,t.doc.title)}),W(e,ve),Je()}Pr([`click`,`mousedown`]);var vC=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),yC=U(`<p class="px-3 py-3 text-xs text-red-400 text-center"> </p>`),bC=U(`<p class="px-3 py-3 text-xs text-gray-400 text-center"> </p>`),xC=U(`<button class="w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><span class="text-gray-400 shrink-0">&#128193;</span> <span class="truncate text-gray-700 dark:text-gray-300"> </span></button>`),SC=U(`<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden text-sm"><div class="flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"><button class="text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-30 disabled:pointer-events-none shrink-0"> </button> <span class="text-xs text-gray-500 dark:text-gray-400 font-mono truncate flex-1"> </span></div> <div class="max-h-40 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800"><!></div></div>`),CC=U(`<p class="text-xs text-red-500"> </p>`),wC=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-md mx-4 p-6 space-y-4"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><svg width="16" height="16" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="inline-block mr-1 align-text-bottom"><path d="M2 5a2 2 0 012-2h3.586a1 1 0 01.707.293L9.707 4.707A1 1 0 0010.414 5H16a2 2 0 012 2v8a2 2 0 01-2 2H4a2 2 0 01-2-2V5z" stroke="currentColor" stroke-width="1.5" fill="none"></path><line x1="10" y1="8" x2="10" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></line><line x1="7" y1="11" x2="13" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></line></svg> <span> </span></h3> <div class="space-y-1.5"><label for="new-folder-name" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <input id="new-folder-name" type="text" class="w-full px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"/></div> <div class="space-y-1.5"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <div class="flex items-center gap-2"><span class="flex-1 text-sm text-gray-600 dark:text-gray-300 font-mono truncate"> </span> <button class="text-xs px-2 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0"> </button></div> <!></div> <div class="space-y-1"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <p class="text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 truncate"> </p></div> <!> <div class="flex justify-end gap-3 pt-1"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div></div>`);function TC(e,t){qe(t,!0);let n=P(``),r=P(null),i=P(null),a=P(``),o=P(``),s=P(`/ (root)`),c=P(!1),l=P(``),u=P(I([])),d=P(!1),f=P(!1),p=P(``),m=P(!1),h=P(null),g=!1;kn(()=>{t.open&&!g?(g=!0,_()):t.open||(g=!1)});async function _(){try{F(n,(await fetch(`/api/config`).then(e=>e.json())).docsFolder||``,!0)}catch{F(n,``)}let e=``;if(X.currentDocId){let t=decodeURIComponent(X.currentDocId);if(!t.startsWith(`/`)){let n=t.split(`/`);n.length>1&&(e=n.slice(0,-1).join(`/`))}}F(a,e?V(n)+`/`+e:V(n),!0),F(r,V(a),!0),F(i,null),F(o,``),F(s,e?`/`+e:`/ (root)`,!0),F(c,!1),F(p,``),F(m,!1),setTimeout(()=>V(h)?.focus(),50)}let v=N(()=>{let e=uc(V(o));if(!e)return Y(`modal.new_folder.enter_name`);let t=V(a)||V(n),r=t.startsWith(V(n))?t.slice(V(n).length).replace(/^\//,``):``;return(r?r+`/`:``)+e});function y(e){let t=e.currentTarget,n=uc(t.value);t.value!==n&&(t.value=n),V(o)!==n&&F(o,n,!0)}function b(){F(c,!V(c)),V(c)&&x(V(r)||V(n))}async function x(e){F(d,!0),F(f,!1);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(r,t.current,!0),F(i,t.parent,!0),F(a,t.current,!0),F(l,t.current,!0),F(s,(t.current.startsWith(V(n)+`/`)?t.current.slice(V(n).length):t.current===V(n)?``:t.current)||`/ (root)`,!0),F(u,t.dirs||[],!0)}catch{F(f,!0),F(u,[],!0)}finally{F(d,!1)}}let S=N(()=>V(r)===V(n));function C(){V(i)&&x(V(i))}async function w(){let e=uc(V(o));if(F(p,``),!e){F(p,Y(`modal.new_folder.error_empty`),!0);return}if(!/^[a-zA-Z0-9_.-]+$/.test(e)){F(p,Y(`modal.new_folder.error_invalid_chars`),!0);return}let r=V(a)||V(n);if(r===V(n)&&(e===`files`||e===`images`)){F(p,Y(`modal.new_folder.error_reserved`),!0);return}let i=r.endsWith(`/`)?r+e:r+`/`+e;F(m,!0);try{let e=await fetch(`/api/browse/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:i})});if(!e.ok)throw Error(await e.text());t.onclose(),t.onsuccess()}catch(e){F(m,!1),F(p,Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}}var T=Wr(),E=R(T),D=e=>{var n=wC(),r=L(n),i=L(r),a=z(L(i),2),g=L(a,!0);j(a),j(i);var _=z(i,2),T=L(_),E=L(T,!0);j(T);var D=z(T,2);Di(D),Vi(D,e=>F(h,e),()=>V(h)),j(_);var ee=z(_,2),te=L(ee),O=L(te,!0);j(te);var ne=z(te,2),re=L(ne),k=L(re,!0);j(re);var ie=z(re,2),ae=L(ie,!0);j(ie),j(ne);var oe=z(ne,2),se=e=>{var t=SC(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n);var s=z(n,2),c=L(s),p=e=>{var t=vC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},m=e=>{var t=yC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`modal.new_folder.error_loading`)]),W(e,t)},h=e=>{var t=bC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`modal.new_folder.no_subfolders`)]),W(e,t)},g=e=>{var t=Wr();q(R(t),17,()=>V(u),e=>e.path,(e,t)=>{var n=xC(),r=z(L(n),2),i=L(r,!0);j(r),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>x(V(t).path)),W(e,n)}),W(e,t)};K(c,e=>{V(d)?e(p):V(f)?e(m,1):V(u).length===0?e(h,2):e(g,-1)}),j(s),j(t),B(e=>{r.disabled=V(S),G(i,e),G(o,V(l))},[()=>Y(`common.up`)]),H(`click`,r,C),W(e,t)};K(oe,e=>{V(c)&&e(se)}),j(ee);var ce=z(ee,2),le=L(ce),ue=L(le,!0);j(le);var de=z(le,2),fe=L(de,!0);j(de),j(ce);var pe=z(ce,2),me=e=>{var t=CC(),n=L(t,!0);j(t),B(()=>G(n,V(p))),W(e,t)};K(pe,e=>{V(p)&&e(me)});var he=z(pe,2),ge=L(he),_e=L(ge,!0);j(ge);var ve=z(ge,2),ye=L(ve,!0);j(ve),j(he),j(r),j(n),B((e,t,n,r,i,a,o,c)=>{G(g,e),G(E,t),J(D,`placeholder`,n),G(O,r),G(k,V(s)),G(ae,i),G(ue,a),G(fe,V(v)),G(_e,o),ve.disabled=V(m),G(ye,c)},[()=>Y(`modal.new_folder.title`),()=>Y(`modal.new_folder.name_label`),()=>Y(`modal.new_folder.name_placeholder`),()=>Y(`modal.new_folder.location_label`),()=>Y(`modal.new_folder.browse_btn`),()=>Y(`modal.new_folder.will_be_created`),()=>Y(`common.cancel`),()=>V(m)?Y(`modal.new_folder.creating_btn`):Y(`modal.new_folder.create_btn`)]),H(`click`,n,e=>{e.target===e.currentTarget&&t.onclose()}),H(`input`,D,y),Ni(D,()=>V(o),e=>F(o,e)),H(`click`,ie,b),H(`click`,ge,function(...e){t.onclose?.apply(this,e)}),H(`click`,ve,w),W(e,n)};K(E,e=>{t.open&&e(D)}),W(e,T),Je()}Pr([`click`,`input`]);var EC=U(`<option></option>`),DC=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),OC=U(`<p class="px-3 py-4 text-xs text-red-400 text-center"> </p>`),kC=U(`<p class="px-3 py-3 text-xs text-gray-400 text-center"> </p>`),AC=U(`<button class="w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><span class="text-gray-400 shrink-0">&#128193;</span> <span class="text-gray-700 dark:text-gray-300 truncate"> </span></button>`),jC=U(`<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden"><div class="flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"><button class="text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-30 disabled:pointer-events-none shrink-0"> </button> <span class="font-mono text-xs text-gray-400 dark:text-gray-500 truncate flex-1 text-right"> </span></div> <div class="divide-y divide-gray-100 dark:divide-gray-800 max-h-40 overflow-y-auto"><!></div> <div class="border-t border-gray-200 dark:border-gray-700 flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800/50"><input type="text" class="flex-1 px-2 py-1 text-xs rounded border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-blue-400"/> <button class="text-xs px-2 py-1 rounded bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shrink-0"> </button></div></div>`),MC=U(`<p class="text-xs text-red-500"> </p>`),NC=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-lg mx-4 p-6 space-y-4"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50">&#10133; <span> </span></h3> <div class="space-y-1.5"><label for="new-doc-title" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <input id="new-doc-title" type="text" class="w-full px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"/></div> <div class="space-y-1.5"><label for="new-doc-category" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <input id="new-doc-category" type="text" list="new-doc-category-options" autocomplete="off" placeholder="GENERAL" class="w-full px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"/> <datalist id="new-doc-category-options"></datalist></div> <div class="space-y-1.5"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <div class="flex items-center gap-2"><span class="flex-1 px-3 py-2 text-xs rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-500 dark:text-gray-400 font-mono truncate"> </span> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0">&#128193; <span> </span></button></div> <!></div> <div class="space-y-1.5"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <p class="text-xs bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 font-mono text-gray-600 dark:text-gray-300 break-all"> </p></div> <!> <div class="flex justify-end gap-3 pt-1"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div></div>`);function PC(e,t){qe(t,!0);let n=P(``),r=P(`YYYY_MM_DD_HH_mm_[Category]_title`),i=P(null),a=P(null),o=P(``),s=P(``),c=P(``),l=P(`/ (root)`),u=P(!1),d=P(``),f=P(I([])),p=P(!1),m=P(!1),h=P(``),g=P(I([])),_=P(``),v=P(!1),y=P(null);function b(e){return(e||``).normalize(`NFD`).replace(/[̀-ͯ]/g,``).toUpperCase().replace(/[^A-Z0-9_-]/g,``)}function x(e){let t=V(n);return e===t?``:e.startsWith(t+`/`)?e.slice(t.length+1):e}let S=!1;kn(()=>{t.open&&!S?(S=!0,C()):t.open||(S=!1)});async function C(){try{let e=await fetch(`/api/config`).then(e=>e.json());F(n,e.docsFolder||``,!0),F(r,e.filenamePattern||`YYYY_MM_DD_HH_mm_[Category]_title`,!0)}catch{F(n,``),F(r,`YYYY_MM_DD_HH_mm_[Category]_title`)}let e=X.currentDocId&&X.allDocs.find(e=>e.id===X.currentDocId),t=b(e&&e.category||`General`)||`GENERAL`,d=``;if(X.currentDocId){let e=decodeURIComponent(X.currentDocId);if(!e.startsWith(`/`)){let t=e.split(`/`);t.length>1&&(d=t.slice(0,-1).join(`/`))}}let f=d?V(n)+`/`+d:``;F(o,d,!0),F(i,f||null,!0),F(a,null),w(),F(s,``),F(c,t,!0),F(l,d?`/`+d:`/ (root)`,!0),F(u,!1),F(h,``),F(_,``),F(v,!1),setTimeout(()=>V(y)?.focus(),50)}function w(){let e=new Set;(X.allDocs||[]).forEach(t=>{let n=b(t.category||``);n&&e.add(n)}),F(g,Array.from(e).sort((e,t)=>e.localeCompare(t)),!0)}function T(){let e=b(V(c));V(c)!==e&&F(c,e,!0)}function E(e){let t=e.currentTarget,n=uc(t.value);t.value!==n&&(t.value=n),V(h)!==n&&F(h,n,!0)}let D=N(()=>{let e=V(s).trim();if(!e)return Y(`modal.new_doc.title_placeholder`);let t=b(V(c))||`GENERAL`,n=new Date,i=n.getFullYear(),a=String(n.getMonth()+1).padStart(2,`0`),l=String(n.getDate()).padStart(2,`0`),u=String(n.getHours()).padStart(2,`0`),d=String(n.getMinutes()).padStart(2,`0`),f=e.toLowerCase().replace(/\s+/g,`_`).replace(/[^a-z0-9_]/g,``).replace(/_+/g,`_`).replace(/^_|_$/g,``)||`document`,p=V(r).replace(`YYYY`,String(i)).replace(`MM`,a).replace(`DD`,l).replace(`HH`,u).replace(`mm`,d).replace(/\[Category\]/i,`[${t}]`).replace(/(?<![a-z0-9])(?:title_words|title)(?![a-z0-9])/i,f)+`.md`;return V(o)?V(o)+`/`+p:p});function ee(){F(u,!V(u)),V(u)&&te(V(i)||V(n))}async function te(e){F(p,!0),F(m,!1);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(i,t.current,!0),F(a,t.parent,!0),F(o,x(t.current),!0),F(d,t.current,!0),F(l,V(o)?`/`+V(o):`/ (root)`,!0),F(f,t.dirs||[],!0)}catch{F(m,!0),F(f,[],!0)}finally{F(p,!1)}}let O=N(()=>V(i)===V(n));function ne(){V(i)!==V(n)&&V(a)&&te(V(a))}function re(){let e=uc(V(h));if(!e)return;let t=V(i)||V(n);if(t===V(n)&&(e===`files`||e===`images`)){F(_,Y(`modal.new_folder.error_reserved`),!0);return}F(_,``);let r=(x(t)?x(t)+`/`:``)+e;F(o,r),F(l,`/`+r),F(h,``)}async function k(){let e=V(s).trim(),n=b(V(c))||`GENERAL`;if(!e){F(_,Y(`modal.new_doc.error_empty_title`),!0);return}F(_,``),F(v,!0);try{let r=await fetch(`/api/documents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:e,category:n,folder:V(o)})});if(!r.ok){let e=await r.json();throw Error(e.error||`Creation failed`)}let i=await r.json();t.onclose(),t.onsuccess(i.id)}catch(e){F(_,Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e))),F(v,!1)}}function ie(e){e.key===`Enter`&&k(),e.key===`Escape`&&t.onclose()}var ae=Wr(),oe=R(ae),se=e=>{var n=NC(),r=L(n),i=L(r),a=z(L(i)),o=L(a,!0);j(a),j(i);var b=z(i,2),x=L(b),S=L(x,!0);j(x);var C=z(x,2);Di(C),Vi(C,e=>F(y,e),()=>V(y)),j(b);var w=z(b,2),ae=L(w),oe=L(ae,!0);j(ae);var se=z(ae,2);Di(se);var ce=z(se,2);q(ce,20,()=>V(g),e=>e,(e,t)=>{var n=EC(),r={};B(()=>{r!==(r=t)&&(n.value=(n.__value=t)??``)}),W(e,n)}),j(ce),j(w);var le=z(w,2),ue=L(le),de=L(ue,!0);j(ue);var fe=z(ue,2),pe=L(fe),me=L(pe,!0);j(pe);var he=z(pe,2),ge=z(L(he)),_e=L(ge,!0);j(ge),j(he),j(fe);var ve=z(fe,2),ye=e=>{var t=jC(),n=L(t),r=L(n),i=L(r);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n);var s=z(n,2),c=L(s),l=e=>{var t=DC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},u=e=>{var t=OC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.cannot_read_dir`)]),W(e,t)},g=e=>{var t=kC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`modal.new_doc.no_subfolders`)]),W(e,t)},_=e=>{var t=Wr();q(R(t),17,()=>V(f),e=>e.path,(e,t)=>{var n=AC(),r=z(L(n),2),i=L(r,!0);j(r),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>te(V(t).path)),W(e,n)}),W(e,t)};K(c,e=>{V(p)?e(l):V(m)?e(u,1):V(f).length===0?e(g,2):e(_,-1)}),j(s);var v=z(s,2),y=L(v);Di(y);var b=z(y,2),x=L(b,!0);j(b),j(v),j(t),B((e,t,n)=>{r.disabled=V(O),G(i,`↑ ${e??``}`),G(o,V(d)),J(y,`placeholder`,t),G(x,n)},[()=>Y(`common.up`),()=>Y(`modal.new_doc.new_folder_placeholder`),()=>Y(`modal.new_doc.create_folder_btn`)]),H(`click`,r,ne),H(`input`,y,E),H(`keydown`,y,e=>{e.key===`Enter`&&re()}),Ni(y,()=>V(h),e=>F(h,e)),H(`click`,b,re),W(e,t)};K(ve,e=>{V(u)&&e(ye)}),j(le);var be=z(le,2),xe=L(be),Se=L(xe,!0);j(xe);var Ce=z(xe,2),A=L(Ce,!0);j(Ce),j(be);var we=z(be,2),Te=e=>{var t=MC(),n=L(t,!0);j(t),B(()=>G(n,V(_))),W(e,t)};K(we,e=>{V(_)&&e(Te)});var Ee=z(we,2),De=L(Ee),Oe=L(De,!0);j(De);var ke=z(De,2),Ae=L(ke,!0);j(ke),j(Ee),j(r),j(n),B((e,t,n,r,i,a,s,c,u)=>{G(o,e),G(S,t),J(C,`placeholder`,n),G(oe,r),G(de,i),G(me,V(l)),G(_e,a),G(Se,s),G(A,V(D)),G(Oe,c),ke.disabled=V(v),G(Ae,u)},[()=>Y(`modal.new_doc.title`),()=>Y(`modal.new_doc.title_label`),()=>Y(`modal.new_doc.title_placeholder`),()=>Y(`modal.new_doc.category_label`),()=>Y(`modal.new_doc.location_label`),()=>Y(`modal.new_doc.browse_btn`),()=>Y(`modal.new_doc.filename_label`),()=>Y(`common.cancel`),()=>V(v)?Y(`modal.new_folder.creating_btn`):Y(`common.create`)]),H(`click`,n,e=>{e.target===e.currentTarget&&t.onclose()}),H(`keydown`,C,ie),Ni(C,()=>V(s),e=>F(s,e)),H(`input`,se,T),H(`keydown`,se,ie),Ni(se,()=>V(c),e=>F(c,e)),H(`click`,he,ee),H(`click`,De,function(...e){t.onclose?.apply(this,e)}),H(`click`,ke,k),W(e,n)};K(oe,e=>{t.open&&e(se)}),W(e,ae),Je()}Pr([`click`,`keydown`,`input`]);var FC=U(`<p class="text-sm text-gray-400 py-2"> </p>`),IC=U(`<p class="text-sm text-red-500"> </p>`),LC=U(`<label class="flex items-center gap-3 px-1 py-1.5 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer"><input type="checkbox" class="w-4 h-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"/> <span class="text-sm text-gray-700 dark:text-gray-300"> </span></label>`),RC=U(`<div><div class="max-h-48 overflow-y-auto space-y-0.5 border border-gray-200 dark:border-gray-700 rounded-lg p-2"><!></div></div>`),zC=U(`<div><p class="text-xs text-gray-500 dark:text-gray-400"> </p> <div class="flex justify-end gap-3 pt-2"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div>`),BC=U(`<div><p class="text-xs text-gray-500 dark:text-gray-400"> </p> <div class="flex justify-end gap-3 pt-2"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg border border-blue-500 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 font-semibold transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div>`),VC=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-sm mx-4 p-6 space-y-4"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-file-export mr-2 text-blue-500"></i> <span> </span></h3> <div class="flex gap-0 border-b border-gray-200 dark:border-gray-700"><button> </button> <button> </button> <button> </button></div> <!> <!> <!> <!></div></div>`);function HC(e,t){qe(t,!0);let n=P(`markdown`),r=!1,i=P(!1),a=P(!1),o=P(I([])),s=P(I({})),c=P(!1),l=P(!1),u=P(!1),d=P(!1),f=!1;kn(()=>{t.open&&!f?(f=!0,F(n,`markdown`),r=!1,F(o,[],!0),F(s,{},!0)):t.open||(f=!1)});function p(e){return String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function m(e){F(n,e,!0),e===`html`&&h()}async function h(){if(!r){F(i,!0),F(a,!1);try{let e=await fetch(`/api/documents`).then(e=>e.json()),t=new Set;e.forEach(e=>t.add(e.folder?.[0]??e.category??`General`)),F(o,[...t].sort((e,t)=>e===`General`?-1:t===`General`?1:e.localeCompare(t)),!0),r=!0}catch{F(a,!0)}finally{F(i,!1)}}}async function g(){F(c,!0);try{let e=await fetch(`/api/export/markdown`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!e.ok)throw Error(await e.text());let n=await e.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`export-markdown.zip`,i.click(),URL.revokeObjectURL(r),t.onclose()}catch(e){alert(Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}finally{F(c,!1)}}async function _(e){let n=V(o).filter(e=>V(s)[e]);if(n.length){F(e===`confluence`?u:l,!0);try{let r=await fetch(`/api/export/html`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({folders:n,mode:e})});if(!r.ok)throw Error(await r.text());let i=await r.blob(),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`export-${e}.zip`,o.click(),URL.revokeObjectURL(a),t.onclose()}catch(e){alert(Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}finally{F(u,!1),F(l,!1)}}}async function v(){F(d,!0);try{let e=X.allDocs&&X.allDocs.length?X.allDocs:await fetch(`/api/documents`).then(e=>e.json()),n={};for(let t=0;t<e.length;t+=5){let r=e.slice(t,t+5),i=await Promise.all(r.map(e=>fetch(`/api/documents/`+e.id).then(e=>e.ok?e.json():null).catch(()=>null)));for(let r of i)r&&(n[r.id??e[t]?.id]=r);r.forEach((e,t)=>{i[t]&&(n[e.id]=i[t])})}function r(e){let t={categories:{},children:{}};for(let n of e){let e=t;for(let t of n.folder||[])e.children[t]||(e.children[t]={categories:{},children:{}}),e=e.children[t];e.categories[n.category]||(e.categories[n.category]=[]),e.categories[n.category].push(n)}return t}function i(e){let t=[];e.categories.General&&t.push(...e.categories.General);let n=Object.keys(e.children).sort((e,t)=>e.localeCompare(t));for(let r of n)t.push(...i(e.children[r]));let r=Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t));for(let n of r)t.push(...e.categories[n]);return t}function a(e){return e.replace(/^\d+_/,``).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function o(e,t){let n=``,r=t*1.25,i=(e,i)=>{let a=t===0&&e===`General`?`General`:e;n+=`<li style="margin-left:${r}rem;margin-top:${t===0?`0.75`:`0.4`}rem;">`,n+=`<span style="font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.05em;color:#6b7280;">${a}</span>`,n+=`<ul style="margin:0.2rem 0 0 0;padding:0;list-style:none;">`;for(let e of i)n+=`<li style="margin-left:${r+.75}rem;padding:0.15rem 0;">`,n+=`<a href="#doc-${e.id}" style="color:#1d4ed8;text-decoration:none;font-size:0.875rem;">${p(e.title)}</a>`,e.formattedDate&&(n+=`<span style="color:#9ca3af;font-size:0.7rem;margin-left:0.5rem;">${p(e.formattedDate)}</span>`),n+=`</li>`;n+=`</ul></li>`};e.categories.General&&i(`General`,e.categories.General);let s=Object.keys(e.children).sort((e,t)=>e.localeCompare(t));for(let i of s)n+=`<li style="margin-left:${r}rem;margin-top:0.75rem;">`,n+=`<span style="font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.05em;color:#7c3aed;">&#128193; ${a(i)}</span>`,n+=`<ul style="margin:0.2rem 0 0 0;padding:0;list-style:none;">`,n+=o(e.children[i],t+1),n+=`</ul></li>`;let c=Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t));for(let t of c)i(t,e.categories[t]);return n}function s(e){return e.replace(/href="[^"]*\?doc=([^"&#]+)(?:#[^"]*)?"/g,(e,t)=>`href="#doc-${t}"`)}let c=p(document.title||`Living Documentation`),l=r(e),u=i(l),d=`<!DOCTYPE html>
225
225
  <html>
226
226
  <head>
227
227
  <meta charset="UTF-8">
@@ -275,17 +275,17 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
275
275
  setTimeout(() => window.print(), 800);
276
276
  <\/script>
277
277
  </body>
278
- </html>`,f=window.open(``,`_blank`);if(!f){alert(Y(`error.pdf_popup`));return}f.document.write(d),f.document.close(),t.onclose()}catch(e){alert(Y(`error.pdf_export`)+(e instanceof Error?e.message:String(e)))}finally{F(d,!1)}}let y=`px-4 py-2 text-sm border-b-2 border-blue-500 text-blue-600 dark:text-blue-400 font-semibold transition-colors`,b=`px-4 py-2 text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors`;var x=Wr(),S=R(x),C=e=>{var r=zC(),f=L(r),p=L(f),h=z(L(p),2),x=L(h,!0);j(h),j(p);var S=z(p,2),C=L(S),w=L(C,!0);j(C);var T=z(C,2),E=L(T,!0);j(T);var D=z(T,2),ee=L(D,!0);j(D),j(S);var te=z(S,2),O=e=>{var t=IC(),n=L(t),r=L(n),c=e=>{var t=NC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},l=e=>{var t=PC(),n=L(t);j(t),B(e=>G(n,`${e??``}failed to load folders`),[()=>Y(`common.error_prefix`)]),W(e,t)},u=e=>{var t=Wr();q(R(t),16,()=>V(o),e=>e,(e,t)=>{var n=FC(),r=L(n);Di(r);var i,a=z(r,2),o=L(a,!0);j(a),j(n),B(()=>{i!==(i=t)&&(r.value=(r.__value=t)??``),G(o,t)}),Ii(r,()=>V(s)[t],e=>V(s)[t]=e),W(e,n)}),W(e,t)};K(r,e=>{V(i)?e(c):V(a)?e(l,1):e(u,-1)}),j(n),j(t),W(e,t)};K(te,e=>{V(n)===`html`&&e(O)});var ne=z(te,2),re=e=>{var n=LC(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var l=z(o,2),u=L(l,!0);j(l),j(a),j(n),B((e,t,n)=>{G(i,e),G(s,t),l.disabled=V(c),G(u,n)},[()=>Y(`modal.export.markdown_hint`),()=>Y(`common.cancel`),()=>V(c)?`⏳`:Y(`modal.export.markdown_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),H(`click`,l,g),W(e,n)};K(ne,e=>{V(n)===`markdown`&&e(re)});var k=z(ne,2),ie=e=>{var n=RC(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),d=L(c,!0);j(c);var f=z(c,2),p=L(f,!0);j(f),j(a),j(n),B((e,t,n,r)=>{G(i,e),G(s,t),c.disabled=V(l),G(d,n),f.disabled=V(u),G(p,r)},[()=>Y(`modal.export_html.hint`),()=>Y(`common.cancel`),()=>V(l)?`⏳`:Y(`modal.export_html.notion_btn`),()=>V(u)?`⏳`:Y(`modal.export_html.confluence_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),H(`click`,c,()=>_(`notion`)),H(`click`,f,()=>_(`confluence`)),W(e,n)};K(k,e=>{V(n)===`html`&&e(ie)});var ae=z(k,2),oe=e=>{var n=LC(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(a),j(n),B((e,t,n)=>{G(i,e),G(s,t),c.disabled=V(d),G(l,n)},[()=>Y(`modal.export.pdf_hint`),()=>Y(`common.cancel`),()=>V(d)?`⏳`:Y(`modal.export.pdf_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),H(`click`,c,v),W(e,n)};K(ae,e=>{V(n)===`pdf`&&e(oe)}),j(f),j(r),B((e,t,r,i)=>{G(x,e),gi(C,1,ui(V(n)===`markdown`?y:b)),G(w,t),gi(T,1,ui(V(n)===`html`?y:b)),G(E,r),gi(D,1,ui(V(n)===`pdf`?y:b)),G(ee,i)},[()=>Y(`modal.export.title`),()=>Y(`modal.export.tab_markdown`),()=>Y(`modal.export.tab_html`),()=>Y(`modal.export.tab_pdf`)]),H(`click`,r,e=>{e.target===e.currentTarget&&t.onclose()}),H(`click`,C,()=>m(`markdown`)),H(`click`,T,()=>m(`html`)),H(`click`,D,()=>m(`pdf`)),W(e,r)};K(S,e=>{t.open&&e(C)}),W(e,x),Je()}Pr([`click`]);var VC=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),HC=U(`<p> </p>`),UC=U(`<div class="group flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><button class="flex-1 flex items-center gap-2 px-3 py-2 text-sm text-left"><span class="text-gray-400 shrink-0">&#128193;</span> <span class="text-gray-700 dark:text-gray-300 truncate"> </span></button> <button title="Add to exclusions" class="shrink-0 text-red-400 hover:text-red-600 px-3 py-2 text-sm font-bold transition-colors">⊖</button></div>`),WC=U(`<div class="group flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><span class="flex-1 flex items-center gap-2 px-3 py-2 text-sm text-gray-500 dark:text-gray-400"><span class="shrink-0 opacity-40">&#128196;</span> <span class="truncate font-mono"> </span></span> <button title="Add to exclusions" class="shrink-0 text-red-400 hover:text-red-600 px-3 py-2 text-sm font-bold transition-colors">⊖</button></div>`),GC=U(`<div class="border-t border-gray-200 dark:border-gray-700"><div class="flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"><button class="text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-30 disabled:pointer-events-none shrink-0">&#8593; Up</button> <span class="font-mono text-xs text-gray-400 dark:text-gray-500 truncate flex-1 text-right"> </span></div> <div class="divide-y divide-gray-100 dark:divide-gray-800 max-h-52 overflow-y-auto"><!></div></div>`),KC=U(`<label class="flex items-center gap-1.5 text-xs text-gray-700 dark:text-gray-300 cursor-pointer"><input type="checkbox"/> </label>`),qC=U(`<div class="group flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><button class="flex-1 flex items-center gap-2 px-3 py-2 text-sm text-left"><span class="text-gray-400 shrink-0">&#128193;</span> <span class="text-gray-700 dark:text-gray-300 truncate"> </span></button> <button title="Exclude this folder" class="shrink-0 opacity-0 group-hover:opacity-100 text-red-400 hover:text-red-600 px-3 py-2 text-sm transition-opacity">⊖</button></div>`),JC=U(`<button class="w-full px-3 py-2 text-xs text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-950/30 text-left font-medium border-t border-gray-100 dark:border-gray-800">&#10003; Select: <span class="font-mono"> </span></button>`),YC=U(`<!> <!>`,1),XC=U(`<div> </div>`),ZC=U(`<div> </div> <div> </div> <div> </div> <!>`,1),QC=U(`<div role="button" tabindex="0" class="flex items-center gap-2 px-3 py-1 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors"><span class="text-gray-400 dark:text-gray-600 w-5 text-right shrink-0 tabular-nums text-xs"></span> <div class="flex-1 min-w-0"><div class="flex items-center justify-between gap-1"><span class="text-gray-800 dark:text-gray-200 font-medium truncate text-xs"> </span> <span class="text-gray-400 dark:text-gray-600 tabular-nums shrink-0 text-xs"> </span></div> <div class="h-1 bg-gray-100 dark:bg-gray-800 rounded-full mt-0.5"><div class="h-1 bg-blue-400 dark:bg-blue-600 rounded-full"></div></div></div></div>`),$C=U(`<div class="w-56 shrink-0 border-r border-gray-200 dark:border-gray-800 flex flex-col bg-white dark:bg-gray-900 overflow-hidden"><div class="px-3 py-2 text-xs text-gray-500 dark:text-gray-400 space-y-0.5 border-b border-gray-100 dark:border-gray-800"><!></div> <div class="px-3 py-2 border-b border-gray-100 dark:border-gray-800 flex items-center gap-2"><span class="text-xs text-gray-500 dark:text-gray-400 shrink-0 cursor-help"> </span> <input type="number" min="1" max="20" class="w-12 px-1.5 py-0.5 text-xs rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-800 dark:text-gray-200 focus:outline-none"/> <button class="text-xs text-blue-600 dark:text-blue-400 hover:underline"> </button></div> <p class="px-3 pt-2 pb-1 text-xs font-semibold text-gray-400 dark:text-gray-600 uppercase tracking-wider"> </p> <div class="flex-1 overflow-y-auto"></div></div>`),ew=U(`<p class="absolute inset-0 flex items-center justify-center text-gray-400 dark:text-gray-500 text-sm animate-pulse"> </p>`),tw=U(`<div class="flex items-center gap-1 group py-0.5"><span class="text-gray-600 dark:text-gray-400 break-all font-mono flex-1 text-xs"> </span> <button title="Exclude this file" class="shrink-0 opacity-0 group-hover:opacity-100 text-red-400 hover:text-red-600 text-xs leading-none px-1 transition-opacity">⊖</button></div>`),nw=U(`<div class="text-gray-400 text-center py-2">—</div>`),rw=U(`<div class="w-80 shrink-0 border-l border-gray-200 dark:border-gray-800 flex flex-col bg-white dark:bg-gray-900 overflow-hidden"><div class="px-3 py-2 border-b border-gray-100 dark:border-gray-800 flex items-center justify-between"><span class="font-bold text-sm text-gray-900 dark:text-gray-100"> </span> <button class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 text-xs leading-none">✕</button></div> <p class="px-3 pt-2 pb-1 text-xs font-semibold text-gray-400 dark:text-gray-600 uppercase tracking-wider"> </p> <div class="flex-1 overflow-y-auto px-3 py-1 space-y-1 text-xs"><!></div></div>`),iw=U(`<div class="fixed inset-0 z-50 flex flex-col bg-white dark:bg-gray-950"><div class="flex items-center justify-between px-6 h-14 border-b border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shrink-0"><h2 class="font-semibold text-base"> </h2> <button class="text-sm px-3 py-1.5 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"> </button></div> <div class="border-b border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shrink-0"><div class="flex items-center gap-3 px-6 py-3"><label class="text-xs font-medium text-gray-500 dark:text-gray-400 shrink-0"> </label> <input type="text" readonly="" spellcheck="false" class="flex-1 px-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono cursor-default focus:outline-none"/> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0">&#128193; <span> </span></button> <button class="text-sm px-4 py-1.5 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors shrink-0"> </button></div> <div class="flex items-start gap-3 px-6 pb-2"><label class="text-xs font-medium text-gray-500 dark:text-gray-400 shrink-0 pt-1.5"> </label> <textarea rows="3" spellcheck="false" class="flex-1 px-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono focus:outline-none focus:ring-1 focus:ring-blue-400 resize-y"></textarea> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0">&#128193; <span> </span></button></div> <!> <div class="flex items-center gap-x-4 gap-y-2 px-6 pb-3 flex-wrap"><span class="text-xs font-medium text-gray-500 dark:text-gray-400 shrink-0"> </span> <label class="flex items-center gap-1.5 text-xs font-medium text-blue-600 dark:text-blue-400 cursor-pointer shrink-0"><input type="checkbox"/> </label> <!></div> <!></div> <div class="flex-1 overflow-hidden flex"><!> <div class="flex-1 relative overflow-hidden"><!> <canvas style="position: absolute; inset: 0"></canvas></div> <!></div></div>`);function aw(e,t){qe(t,!0);let n=new Set(`the.a.an.and.or.but.not.nor.so.yet.both.either.neither.is.are.was.were.be.been.being.have.has.had.do.does.did.will.would.shall.should.may.might.can.could.must.need.dare.ought.used.to.of.in.for.on.with.at.by.from.up.about.into.through.during.before.after.above.below.between.out.off.over.under.again.further.then.once.here.there.when.where.why.how.all.each.few.more.most.other.some.such.no.only.own.same.than.too.very.just.also.still.already.always.never.often.sometimes.usually.this.that.these.those.its.your.our.their.his.her.him.she.you.they.we.me.my.it.who.which.what.whose.whom.if.though.although.because.since.while.unless.until.whether.as.like.via.per.i.am.he.us.see.now.new.old.got.let.put.say.said.says.get.use.make.made.take.come.came.go.went.know.think.look.want.give.seem.back.down.even.much.well.good.work.tell.keep.hold.turn.move.play.live.help.run.start.off.way.too.few.show.hear.etc.eg.ie.one.two.three.four.five.six.seven.eight.nine.ten.le.la.les.un.une.des.du.de.d.l.au.aux.ce.ci.cet.cette.ces.mon.ma.mes.ton.ta.tes.son.sa.ses.notre.nos.votre.vos.leur.leurs.je.tu.il.elle.on.nous.vous.ils.elles.me.te.se.lui.y.en.qui.que.quoi.dont.où.et.ou.mais.donc.or.ni.car.si.ne.pas.plus.moins.très.bien.mal.peu.beaucoup.trop.assez.aussi.comme.pour.par.avec.sans.dans.sur.sous.entre.vers.chez.contre.avant.après.pendant.depuis.selon.malgré.sauf.est.sont.était.être.avoir.fait.faire.dit.dire.peut.pouvoir.doit.devoir.veut.vouloir.sait.savoir.va.aller.vient.venir.tout.tous.toute.toutes.autre.autres.même.chaque.quel.quelle.quels.quelles.aucun.aucune.certain.certaine.plusieurs.quelque.quelques.tel.telle.tels.telles.cela.ceci.ça.celui.celle.ceux.celles.ici.voici.voilà.alors.ainsi.encore.déjà.jamais.toujours.souvent.parfois.rien.personne.chose.fois.jour.temps.part.cas.point.lieu.monde.cependant.néanmoins.pourtant.toutefois.quand.lorsque.puisque.parce.afin.puis.lors.notamment.surtout.seulement.vraiment.enfin.ensuite.ailleurs.là.ici.voici.voilà.dont.lequel.laquelle.lesquels.lesquelles`.split(`.`)),r=new Set(`public.private.protected.static.void.class.interface.abstract.final.const.let.var.function.return.if.else.for.while.do.switch.case.break.continue.try.catch.throw.throws.finally.new.this.self.super.import.export.from.package.module.require.include.using.namespace.struct.enum.trait.impl.fn.def.func.fun.val.mut.async.await.yield.lambda.extends.implements.override.virtual.sealed.data.object.companion.where.when.match.guard.defer.go.chan.select.type.alias.as.is.in.of.with.true.false.null.nil.none.undefined.println.printf.fmt.log.print.main.args.argv.init.setup.teardown.describe.test.expect.assert.before.after.not.and.or.delete.typeof.instanceof.readonly.keyof.infer.never.unknown.declare.satisfies.get.set.add.remove.update.create.find.fetch.load.save.put.post.patch.list.map.filter.reduce.sort.merge.parse.format.convert.transform.validate.check.handle.process.execute.start.stop.reset.clear.close.open.read.write.send.receive.emit.trigger.dispatch.subscribe.unsubscribe.listen.notify.register.unregister.bind.apply.call.invoke.callback.handler.listener.middleware.interceptor.resolver.provider.consumer.producer.builder.factory.adapter.wrapper.proxy.decorator.observer.visitor.strategy.command.controller.service.repository.dao.dto.entity.model.schema.config.context.state.store.action.reducer.selector.hook.ref.effect.memo.component.module.plugin.extension.util.utils.helper.helpers.common.shared.base.default.index.app.core.lib.src.test.spec.mock.stub.fixture.impl.internal.api.sdk.client.server.request.response.status.code.error.exception.message.result.data.value.key.name.label.title.description.item.element.node.child.parent.root.container.wrapper.layout.view.page.screen.panel.header.footer.sidebar.navbar.body.content.section.row.col.column.grid.flex.block.inline.span.div.input.output.param.params.arg.option.options.props.attr.attrs.field.fields.property.properties.method.methods.string.number.boolean.integer.float.double.long.short.byte.char.array.object.map.set.list.vector.queue.stack.hash.table.tree.graph.pair.tuple.optional.nullable.void.unit.any.bool.bytes.none.int.str.bool.all.each.every.some.many.single.multi.first.last.next.prev.previous.current.old.temp.tmp.new.top.bottom.left.right.center.middle.start.end.begin.min.max.count.total.sum.avg.size.length.width.height.depth.flag.num.idx.id.uid.uuid.num.str.val.obj.arr.fn.cb.ctx.req.res.err.msg.src.dst.evt.doc.db.io.fs.os.env.sys.http.https.url.uri.path.port.host.tcp.udp.ssl.tls.html.css.json.xml.yml.yaml.csv.sql.regex.utf.ascii.rgb.rgba.hex.px.em.rem.vh.vw.auto.inherit.initial.application.file.local.source.messages.logging.alerting.programmed.offset.offsets.zone.zoned.decimal.big.integer.constructor.mapper.captor.publisher.verify.subscriber.org.edr.ack.ref.ssr.ssg.csr.isr.mockito.junit.vitest.jest.mocha.rspec.pytest.cypress.playwright.captor.spy.given.then.verify.times.never.invocation.argumentcaptor.inorder.donothing.doreturn.ippon.springframework.jakarta.javax.todo.fixme.hack.note.deprecated.experimental.eslint.prettier.typescript.javascript.java.kotlin.python.golang.rust.csharp.swift.ruby.spring.boot.javax.jakarta.hibernate.lombok.gradle.maven.webpack.vite.react.angular.vue.svelte.nuxt.express.fastapi.flask.django.rails.fiber.gin.actix.tokio.asyncio.junit.jest.mocha.pytest.rspec.docker.kubernetes.aws.gcp.azure.terraform.ansible.nginx.apache.linux.nextjs.remix.astro.sveltekit.gatsby.nuxtjs.qwik.solid.vercel.netlify.cloudflare.supabase.firebase.mongodb.postgres.prisma.drizzle.typeorm.sequelize.mongoose.redis.neon.trpc.graphql.grpc.rest.openapi.swagger.zod.yup.valibot.tailwind.shadcn.radix.headless.chakra.mantine.antd.mui.tanstack.tanstackquery.zustand.jotai.recoil.redux.mobx.storybook.cypress.playwright.vitest.turbopack.turborepo.getserversideprops.getstaticprops.getstaticpaths.generatestaticparams.generatemetadata.serveraction.revalidate.notfound.redirect.permanentredirect.unstablecache.unstablenostore.cookies.headers.userouter.usepathname.usesearchparams.useparams.useformstate.useformstatus.useoptimistic.useserveraction.classname.onclick.onchange.onsubmit.onfocus.onblur.onkeydown.onkeyup.onmousedown.onmouseup.defaultvalue.htmlfor.tabindex.strokewidth.viewbox.fillopacity.strokeopacity.pathdata.children.fragment.portal.suspense.errorboundary.strictmode.createelement.createcontext.createref.forwardref.usestate.useeffect.useref.usecontext.usememo.usecallback.usereducer.useid.usetransition.usedeferredvalue.useimperativehandle.mutex.lock.thread.goroutine.coroutine.channel.buffer.stream.pipe.observable.promise.future.completable.deferred.disposable.lifecycle.scope.annotation.attribute.metadata.reflection.generic.template.macro.preprocessor.compiler.runtime.debug.release.production.development.staging.build.deploy.lint.coverage.report.the.and.for.are.but.not.you.all.this.that.with.have.from.they.will.been.can.has.was.its.our.their.more.also.when.what.about.which.would.into.than.then.each.just.over.after.such.here.some.were.very.only`.split(`.`));function i(e){return n.has(e)||r.has(e)||e.length<3||/^\d+$/.test(e)||/^[^a-z]/.test(e)}function a(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/[_\-./]+/g,` `).toLowerCase().trim().split(/\s+/).filter(e=>e.length>=3)}function o(e){return e.toLowerCase().split(/[^a-zàâäéèêëïîôùûü]+/).filter(e=>e.length>=3)}let s=[{value:`adoc`,cat:`prose`},{value:`asciidoc`,cat:`prose`},{value:`asm`,cat:`code`},{value:`astro`,cat:`code`},{value:`avsc`,cat:`config`},{value:`bash`,cat:`code`},{value:`bat`,cat:`code`},{value:`bicep`,cat:`config`},{value:`c`,cat:`code`},{value:`cc`,cat:`code`},{value:`cfg`,cat:`config`},{value:`cjs`,cat:`code`},{value:`clj`,cat:`code`},{value:`cljs`,cat:`code`},{value:`cmake`,cat:`code`},{value:`cmd`,cat:`code`},{value:`conf`,cat:`config`},{value:`cpp`,cat:`code`},{value:`cql`,cat:`code`},{value:`cs`,cat:`code`},{value:`cshtml`,cat:`code`},{value:`css`,cat:`config`},{value:`cxx`,cat:`code`},{value:`dart`,cat:`code`},{value:`env`,cat:`config`},{value:`erb`,cat:`code`},{value:`erl`,cat:`code`},{value:`ex`,cat:`code`},{value:`exs`,cat:`code`},{value:`fish`,cat:`code`},{value:`fs`,cat:`code`},{value:`fsx`,cat:`code`},{value:`go`,cat:`code`},{value:`gql`,cat:`code`},{value:`gradle`,cat:`code`},{value:`graphql`,cat:`code`},{value:`groovy`,cat:`code`},{value:`h`,cat:`code`},{value:`hcl`,cat:`config`},{value:`hpp`,cat:`code`},{value:`hs`,cat:`code`},{value:`html`,cat:`config`},{value:`ini`,cat:`config`},{value:`java`,cat:`code`},{value:`jl`,cat:`code`},{value:`js`,cat:`code`},{value:`json`,cat:`config`},{value:`jsx`,cat:`code`,jsx:!0},{value:`kt`,cat:`code`},{value:`less`,cat:`config`},{value:`lua`,cat:`code`},{value:`m`,cat:`code`},{value:`md`,cat:`prose`,def:!0},{value:`mdx`,cat:`prose`},{value:`mjs`,cat:`code`},{value:`mk`,cat:`code`},{value:`ml`,cat:`code`},{value:`mli`,cat:`code`},{value:`mm`,cat:`code`},{value:`nim`,cat:`code`},{value:`php`,cat:`code`},{value:`pl`,cat:`code`},{value:`prisma`,cat:`code`},{value:`properties`,cat:`config`},{value:`proto`,cat:`code`},{value:`ps1`,cat:`code`},{value:`py`,cat:`code`},{value:`r`,cat:`code`},{value:`razor`,cat:`code`},{value:`rb`,cat:`code`},{value:`rs`,cat:`code`},{value:`rst`,cat:`prose`},{value:`s`,cat:`code`},{value:`scala`,cat:`code`},{value:`scss`,cat:`config`},{value:`sh`,cat:`code`},{value:`sol`,cat:`code`},{value:`sql`,cat:`code`},{value:`styl`,cat:`config`},{value:`svelte`,cat:`code`},{value:`swift`,cat:`code`},{value:`tex`,cat:`prose`},{value:`tf`,cat:`config`},{value:`tfvars`,cat:`config`},{value:`thrift`,cat:`code`},{value:`toml`,cat:`config`},{value:`ts`,cat:`code`},{value:`tsx`,cat:`code`,jsx:!0},{value:`txt`,cat:`prose`},{value:`v`,cat:`code`},{value:`vb`,cat:`code`},{value:`vue`,cat:`code`},{value:`xml`,cat:`config`},{value:`yaml`,cat:`config`},{value:`yml`,cat:`config`},{value:`zig`,cat:`code`},{value:`zsh`,cat:`code`}],c=new Set(s.filter(e=>e.cat===`prose`).map(e=>e.value)),l=new Set(s.filter(e=>e.cat===`code`).map(e=>e.value)),u=new Set(s.filter(e=>e.cat===`config`).map(e=>e.value)),d=new Set(s.filter(e=>e.jsx).map(e=>e.value));function f(e,t){let n=[];if(c.has(t)){let t=e.replace(/^\s*(import|export\s+\{[^}]*\}|export\s+\*|package|require|#include|from\s+['"][^'"]+['"]\s*(import)?)\b.*/gm,``).replace(/```[\s\S]*?```/g,` `).replace(/`[^`\n]+`/g,` `).replace(/!\[[^\]]*\]\([^)]*\)/g,` `).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/https?:\/\/\S+/g,` `).replace(/[#*_~>`|!\[\](){}=+\-]/g,` `);n.push(...o(t))}else l.has(t)?(d.has(t)&&(e=e.replace(/<\/?[A-Z][A-Za-z0-9.]*[^>]*>/g,` `),e=e.replace(/<\/?(div|span|main|section|article|aside|nav|header|footer|form|input|button|select|option|textarea|table|thead|tbody|tr|td|th|ul|ol|li|a|img|p|h[1-6]|label|figure|figcaption|picture|video|audio|canvas|svg|path|circle|rect|g|defs|use|link|meta|head|html|body|script|style|br|hr|strong|em|code|pre|blockquote|small|sub|sup)\b[^>]*>/gi,` `),e=e.replace(/\b(className|onClick|onChange|onSubmit|onFocus|onBlur|onKeyDown|onKeyUp|onMouseDown|onMouseUp|htmlFor|tabIndex|strokeWidth|viewBox|fillOpacity|strokeOpacity|defaultValue|placeholder|disabled|checked|readOnly|required|multiple|autoFocus|autoComplete|type|href|src|alt|width|height|style|key|ref)\s*=/g,` =`)),e=e.replace(/^\s*(import\s+[\w.*{},\s'"@/-]+;?|from\s+['"][^'"]+['"]\s*;?|package\s+[\w.]+;?|namespace\s+[\w.]+;?|using\s+[\w.]+;?|require\s*\(?\s*['"][^'"]+['"]\s*\)?;?)\s*$/gm,``),e.replace(/(?:\/\/|#(?!.*[{}[\]<>])| -- )\s*(.+)$/gm,(e,t)=>(n.push(...o(t)),e)),e.replace(/\/\*[\s\S]*?\*\//g,e=>(n.push(...o(e)),e)),e.replace(/"""[\s\S]*?"""|'''[\s\S]*?'''/g,e=>(n.push(...o(e)),e)),e.replace(/["'`]([A-Za-zÀ-ÿ][A-Za-zÀ-ÿ\s,.'éàèùâêîôûç]{3,})["'`]/g,(e,t)=>(n.push(...o(t)),e)),e.replace(/\b([A-Za-z][A-Za-z0-9_]{2,})\b/g,(e,t)=>(n.push(...a(t)),e))):u.has(t)&&(e.replace(/:\s*["']([^"']{3,})["']/g,(e,t)=>(n.push(...o(t)),e)),e.replace(/\b([A-Za-z][A-Za-z0-9_]{2,})\b/g,(e,t)=>(n.push(...a(t)),e)));return n.filter(e=>!i(e))}let p=P(``),m=P(``),h=P(1),g=P(``),_=P(!0),v=P(!1),y=P(I(s.map(e=>({value:e.value,label:`.`+e.value,checked:!!e.def}))));function b(){return V(y).filter(e=>e.checked).map(e=>e.value)}let x=N(()=>V(y).every(e=>e.checked)),S=P(null),C=P(null),w=P(0),T=P(null),E=P(I([])),D=P(I([])),ee=P(!1),te=P(``),O=P(0),ne=P(I([]));function re(){localStorage.setItem(`wc-exts`,JSON.stringify(b()))}function k(){let e=V(x);F(y,V(y).map(t=>({...t,checked:!e})),!0),re()}function ie(){re()}function ae(){return new Set((V(m)||``).split(/[\n,]/).map(e=>e.trim()).filter(Boolean))}function oe(e){let t=ae();t.has(e)||(t.add(e),F(m,[...t].join(`, `),!0),localStorage.setItem(`wc-exclude`,V(m)),V(de)&&ve(V(pe)),ce())}function se(){localStorage.setItem(`wc-exclude`,V(m)),V(de)&&ve(V(pe)),ce()}function ce(){V(ee)&&V(te)&&Ne(V(te))}function le(){V(S)&&Me()}function ue(){let e=localStorage.getItem(`wc-root`);e&&(F(p,e,!0),F(Se,e,!0));let t=localStorage.getItem(`wc-exclude`);t&&F(m,t,!0);let n=localStorage.getItem(`wc-exts`);if(n)try{let e=JSON.parse(n);F(y,V(y).map(t=>({...t,checked:e.includes(t.value)})),!0)}catch{}}let de=P(!1),fe=P(null),pe=P(``),me=P(``),he=P(null),ge=P(``);function _e(){F(de,!V(de)),V(de)&&ve(V(pe)||V(p)||`/`)}async function ve(e){F(he,null),F(ge,`Loading…`);try{let t=await fetch(`/api/browse?all=1&path=`+encodeURIComponent(e)).then(e=>e.json());F(pe,t.current,!0),F(fe,t.parent,!0),F(me,t.current,!0);let n=V(p).trim(),r=(e,t)=>n&&e.startsWith(n+`/`)?e.slice(n.length+1):t,i=ae(),a=(t.dirs||[]).filter(e=>!i.has(r(e.path,e.name))).map(e=>({kind:`dir`,name:e.name,path:e.path,entry:r(e.path,e.name)})),o=b(),s=(t.files||[]).filter(e=>o.some(t=>e.name.endsWith(`.`+t))).filter(e=>!i.has(r(e.path,e.name))).map(e=>({kind:`file`,name:e.name,entry:r(e.path,e.name)})),c=[...a,...s];F(he,c,!0),F(ge,c.length?``:`Empty directory`,!0)}catch{F(he,[],!0),F(ge,`Cannot read directory`)}}function ye(){V(fe)&&ve(V(fe))}let be=P(!1),xe=P(null),Se=P(``),Ce=P(``),A=P(null),we=P(``);function Te(){F(be,!V(be)),V(be)&&Ee(V(Se)||V(p)||`/`)}async function Ee(e){F(A,null),F(we,`Loading…`);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(Se,t.current,!0),F(xe,t.parent,!0),F(Ce,t.current,!0),F(A,(t.dirs||[]).map(e=>({name:e.name,path:e.path})),!0),F(we,V(A).length?``:`No sub-folders`,!0)}catch{F(A,[],!0),F(we,`Cannot read directory`)}}function De(){V(xe)&&Ee(V(xe))}function Oe(){F(p,V(Se),!0),localStorage.setItem(`wc-root`,V(Se)),F(be,!1),F(m,``),localStorage.removeItem(`wc-exclude`),F(pe,V(Se),!0)}let ke=P(null),Ae=P(null),je=P(!1);function Me(){if(!V(S)||!V(C))return;let e=Math.max(1,V(h)||1),t=[...V(S).entries()].sort((e,t)=>t[1]-e[1]),n=t.filter(([t])=>(V(C).get(t)||new Set).size>=e).slice(0,150);if(!n.length){let n=t.length;F(g,n?`${n} domain word(s) found but none appear in ${e}+ file(s). Lower the "Min files" threshold to 1.`:`No domain words extracted. Try adding more file extensions or a broader folder.`,!0),F(_,!0),F(je,!1),F(v,!1);return}let r=[...V(S).keys()].filter(t=>(V(C).get(t)||new Set).size>=e).length;F(T,{scanned:V(w),unique:r,shown:n.length},!0);let i=n.slice(0,50),a=i[0][1];F(D,i.map(([e,t])=>({word:e,freq:t,pct:Math.round(t/a*100)})),!0),F(v,!0),F(_,!1);let o=document.documentElement.classList.contains(`dark`),s=o?[`#60a5fa`,`#34d399`,`#f9a8d4`,`#a78bfa`,`#fbbf24`,`#6ee7b7`,`#93c5fd`,`#fb923c`,`#4ade80`,`#f472b6`]:[`#1d4ed8`,`#047857`,`#7c3aed`,`#b45309`,`#be123c`,`#0369a1`,`#4338ca`,`#c2410c`,`#15803d`,`#9333ea`];requestAnimationFrame(()=>{if(!V(ke)||!V(Ae))return;let e=V(ke),t=V(Ae);e.width=Math.max(400,t.offsetWidth),e.height=Math.max(300,t.offsetHeight),e.style.width=e.width+`px`,e.style.height=e.height+`px`,F(je,!0);let n=Math.sqrt(e.width*e.height/(800*500)),r=Math.min(220,Math.round(72*n)),c=i.map(([e,t])=>[e,Math.max(12,Math.round(r*t/a))]);window.WordCloud?.(e,{list:c,gridSize:Math.round(4*e.width/1024),fontFamily:`ui-sans-serif, system-ui, sans-serif`,color:()=>s[Math.floor(Math.random()*s.length)],backgroundColor:o?`#030712`:`#ffffff`,rotateRatio:.2,minSize:6,shrinkToFit:!0,click:e=>Ne(e[0])})})}function Ne(e){if(!V(C)||!V(S))return;let t=[...V(C).get(e)||[]].sort(),n=V(S).get(e)||0;F(te,e,!0),F(O,n,!0),F(ne,t,!0),F(ee,!0)}function Pe(){F(ee,!1)}async function Fe(){let e=V(p).trim();if(!e){F(g,`Please select a root folder first.`),F(_,!0);return}let t=b();if(!t.length){F(g,`Please select at least one extension.`),F(_,!0);return}F(be,!1),F(v,!1),F(ee,!1),F(g,`Reading files…`),F(_,!0),F(je,!1);try{let n=V(m).trim(),r=n?n.split(/[\n,]/).map(e=>e.trim()).filter(Boolean):[];localStorage.setItem(`wc-exclude`,n);let i=new URLSearchParams({path:e});t.forEach(e=>i.append(`ext`,e)),r.forEach(e=>i.append(`exclude`,e));let a=await fetch(`/api/wordcloud?`+i);if(!a.ok){F(g,`Error: `+((await a.json()).error||a.statusText));return}let{files:o,fileTexts:s}=await a.json();F(g,`Analyzing ${o} file(s)…`);let c=new Map,l=new Map,u=new Set;F(w,o,!0);for(let{path:e,text:t}of s){let n=(e.split(`.`).pop()||``).toLowerCase();n&&u.add(n);let r=f(t,n),i=new Set;for(let t of r)c.set(t,(c.get(t)||0)+1),i.has(t)||(i.add(t),l.has(t)||l.set(t,new Set),l.get(t).add(e))}F(S,c,!0),F(C,l,!0),F(E,[...u].sort().map(e=>`.`+e),!0),Me()}catch(e){F(g,`Error: `+e.message)}}let Ie=!1;kn(()=>{t.open&&!Ie?(Ie=!0,F(g,`Choose a root folder and click Launch.`),F(_,!0),F(je,!1),F(v,!1),F(ee,!1),F(S,null),F(C,null),F(T,null),F(D,[],!0),F(be,!1),F(de,!1),F(h,1),ue(),V(p)||fetch(`/api/config`).then(e=>e.json()).then(e=>{e.docsFolder&&(F(p,e.docsFolder,!0),F(Se,e.docsFolder,!0))}).catch(()=>{})):t.open||(Ie=!1)});var Le=Wr(),Re=R(Le),ze=e=>{var n=iw(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=L(c),u=L(l),d=L(u,!0);j(u);var f=z(u,2);Di(f);var b=z(f,2),S=z(L(b)),C=L(S,!0);j(S),j(b);var w=z(b,2),re=L(w,!0);j(w),j(l);var ae=z(l,2),ce=L(ae),ue=L(ce,!0);j(ce);var pe=z(ce,2);yn(pe);var Se=z(pe,2),Me=z(L(Se)),Ie=L(Me,!0);j(Me),j(Se),j(ae);var Le=z(ae,2),Re=e=>{var t=GC(),n=L(t),r=L(n),i=z(r,2),a=L(i,!0);j(i),j(n);var o=z(n,2),s=L(o),c=e=>{var t=VC(),n=L(t,!0);j(t),B(()=>G(n,V(ge))),W(e,t)},l=e=>{var t=HC(),n=L(t,!0);j(t),B(()=>{gi(t,1,`px-3 py-3 text-xs ${V(ge)===`Cannot read directory`?`text-red-400`:`text-gray-400`} text-center`),G(n,V(ge))}),W(e,t)},u=e=>{var t=Wr();q(R(t),17,()=>V(he),Xr,(e,t)=>{var n=Wr(),r=R(n),i=e=>{var n=UC(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(n),B(()=>G(a,V(t).name)),H(`click`,r,()=>ve(V(t).path)),H(`click`,o,()=>oe(V(t).entry)),W(e,n)},a=e=>{var n=WC(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(n),B(()=>G(a,V(t).name)),H(`click`,o,()=>oe(V(t).entry)),W(e,n)};K(r,e=>{V(t).kind===`dir`?e(i):e(a,-1)}),W(e,n)}),W(e,t)};K(s,e=>{V(he)===null?e(c):V(he).length===0?e(l,1):e(u,-1)}),j(o),j(t),B(()=>{r.disabled=!V(fe),G(a,V(me))}),H(`click`,r,ye),W(e,t)};K(Le,e=>{V(de)&&e(Re)});var ze=z(Le,2),Be=L(ze),Ve=L(Be,!0);j(Be);var He=z(Be,2),Ue=L(He);Di(Ue);var We=z(Ue);j(He),q(z(He,2),17,()=>V(y),e=>e.value,(e,t,n)=>{var r=KC(),i=L(r);Di(i);var a=z(i);j(r),B(()=>G(a,` ${V(t).label??``}`)),H(`change`,i,ie),Ii(i,()=>V(t).checked,e=>V(t).checked=e),W(e,r)}),j(ze);var Ge=z(ze,2),Ke=e=>{var t=GC(),n=L(t),r=L(n),i=z(r,2),a=L(i,!0);j(i),j(n);var o=z(n,2),s=L(o),c=e=>{var t=VC(),n=L(t,!0);j(t),B(()=>G(n,V(we))),W(e,t)},l=e=>{var t=YC(),n=R(t),r=e=>{var t=HC(),n=L(t,!0);j(t),B(()=>{gi(t,1,`px-3 py-3 text-xs ${V(we)===`Cannot read directory`?`text-red-400`:`text-gray-400`} text-center`),G(n,V(we))}),W(e,t)},i=e=>{var t=Wr();q(R(t),17,()=>V(A),Xr,(e,t)=>{var n=qC(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(n),B(()=>G(a,V(t).name)),H(`click`,r,()=>Ee(V(t).path)),H(`click`,o,()=>oe(V(t).name)),W(e,n)}),W(e,t)};K(n,e=>{V(A).length===0?e(r):e(i,-1)});var a=z(n,2),o=e=>{var t=JC(),n=z(L(t)),r=L(n,!0);j(n),j(t),B(()=>G(r,V(Ce))),H(`click`,t,Oe),W(e,t)};K(a,e=>{V(we)!==`Cannot read directory`&&e(o)}),W(e,t)};K(s,e=>{V(A)===null?e(c):e(l,-1)}),j(o),j(t),B(()=>{r.disabled=!V(xe),G(a,V(Ce))}),H(`click`,r,De),W(e,t)};K(Ge,e=>{V(be)&&e(Ke)}),j(c);var qe=z(c,2),Je=L(qe),Ye=e=>{var t=$C(),n=L(t),r=L(n),i=e=>{var t=ZC(),n=R(t),r=L(n);j(n);var i=z(n,2),a=L(i);j(i);var o=z(i,2),s=L(o);j(o);var c=z(o,2),l=e=>{var t=XC(),n=L(t);j(t),B((e,r)=>{J(t,`title`,e),G(n,`${V(E).length??``} extension${V(E).length>1?`s`:``} found (${r??``})`)},[()=>V(E).join(`, `),()=>V(E).join(`, `)]),W(e,t)};K(c,e=>{V(E).length&&e(l)}),B(()=>{G(r,`${V(T).scanned??``} file(s) scanned`),G(a,`${V(T).unique??``} unique domain words`),G(s,`${V(T).shown??``} shown`)}),W(e,t)};K(r,e=>{V(T)&&e(i)}),j(n);var a=z(n,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2);Di(c);var l=z(c,2),u=L(l,!0);j(l),j(a);var d=z(a,2),f=L(d,!0);j(d);var p=z(d,2);q(p,21,()=>V(D),Xr,(e,t,n)=>{var r=QC(),i=L(r);i.textContent=n+1;var a=z(i,2),o=L(a),s=L(o),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(o);var d=z(o,2),f=L(d);j(d),j(a),j(r),B(()=>{G(c,V(t).word),G(u,V(t).freq),vi(f,`width:${V(t).pct??``}%`)}),H(`click`,r,()=>Ne(V(t).word)),W(e,r)}),j(p),j(t),B((e,t,n,r,i,a)=>{J(o,`title`,e),G(s,t),J(c,`title`,n),J(l,`title`,r),G(u,i),G(f,a)},[()=>Y(`wc.min_files_hint`),()=>Y(`wc.min_files_label`),()=>Y(`wc.min_files_hint`),()=>Y(`wc.apply_hint`),()=>Y(`wc.apply_btn`),()=>Y(`wc.top_words`)]),Ni(c,()=>V(h),e=>F(h,e)),H(`click`,l,le),W(e,t)};K(Je,e=>{V(v)&&e(Ye)});var Xe=z(Je,2),Ze=L(Xe),Qe=e=>{var t=ew(),n=L(t,!0);j(t),B(()=>G(n,V(g))),W(e,t)};K(Ze,e=>{V(_)&&e(Qe)});var $e=z(Ze,2);let et;Vi($e,e=>F(ke,e),()=>V(ke)),j(Xe),Vi(Xe,e=>F(Ae,e),()=>V(Ae));var tt=z(Xe,2),nt=e=>{var t=rw(),n=L(t),r=L(n),i=L(r);j(r);var a=z(r,2);j(n);var o=z(n,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c),u=e=>{var t=Wr();q(R(t),17,()=>V(ne),Xr,(e,t)=>{var n=tw(),r=L(n),i=L(r,!0);j(r);var a=z(r,2);j(n),B(()=>G(i,V(t))),H(`click`,a,()=>oe(V(t))),W(e,n)}),W(e,t)},d=e=>{W(e,nw())};K(l,e=>{V(ne).length?e(u):e(d,-1)}),j(c),j(t),B(e=>{G(i,`${V(te)??``} ×${V(O)??``}`),G(s,e)},[()=>Y(`wc.found_in`)]),H(`click`,a,Pe),W(e,t)};K(tt,e=>{V(ee)&&e(nt)}),j(qe),j(n),B((e,t,n,r,i,o,c,l,u,f)=>{G(a,e),G(s,t),G(d,n),G(C,r),G(re,i),G(ue,o),J(pe,`placeholder`,c),G(Ie,l),G(Ve,u),ki(Ue,V(x)),G(We,` ${f??``}`),et=gi($e,1,``,null,et,{hidden:!V(je)})},[()=>Y(`wc.title`),()=>Y(`wc.close_btn`),()=>Y(`wc.search_root_label`),()=>Y(`wc.browse_btn`),()=>Y(`wc.launch_btn`),()=>Y(`wc.exclude_label`),()=>Y(`wc.exclude_placeholder`),()=>Y(`wc.browse_btn`),()=>Y(`wc.extensions_label`),()=>Y(`wc.all_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),Ni(f,()=>V(p),e=>F(p,e)),H(`click`,b,Te),H(`click`,w,Fe),H(`input`,pe,se),Ni(pe,()=>V(m),e=>F(m,e)),H(`click`,Se,_e),H(`change`,Ue,k),W(e,n)};K(Re,e=>{t.open&&e(ze)}),W(e,Le),Je()}Pr([`click`,`input`,`change`]);var ow=U(`<button title="Toggle dark mode" class="ghost-button" aria-label="Toggle dark mode"> </button>`),sw=U(`<button class="ghost-button"><i class="fa-solid fa-cloud"></i></button> <!>`,1),cw=U(`<div class="relative hidden sm:block"><input type="search" class="w-56 pl-8 pr-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"/> <span class="absolute left-2.5 top-2 text-gray-400 text-sm pointer-events-none">🔍</span></div>`),lw=U(`<p class="p-8 text-red-500"> </p>`),uw=U(`<div class="h-full flex items-center justify-center p-8"><div class="max-w-md text-center"><div class="text-5xl mb-4 select-none" aria-hidden="true">📚</div> <h2 class="text-xl font-semibold text-gray-700 dark:text-gray-300 mb-2"> </h2> <p class="text-sm text-gray-500 dark:text-gray-500"> </p> <p class="mt-4 text-xs text-gray-400 dark:text-gray-600 font-mono bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 inline-block"> </p> <p class="mt-2 text-xs text-gray-400"> </p></div></div>`),dw=U(`<div class="app-shell bg-gray-50 text-gray-900 dark:bg-gray-900 dark:text-gray-100"><!> <div class="flex overflow-hidden"><!> <main id="home-content-area" class="flex-1 overflow-y-auto"><!></main></div></div> <!> <!> <!> <!>`,1);function fw(e,t){qe(t,!0);let n=P(!1),r=P(!1),i=P(!1),a=P(!1),o=P(null),s=P(!1),c=P(``),l=P(!1),u=P(!1),d=P(`Living AI Documentation`),f=P(`YYYY_MM_DD_HH_mm_[Category]_title.md`),p=null;function m(){try{let e=localStorage.getItem(`ld-dark`);if(e!==null)return e===`true`}catch{}return window.matchMedia(`(prefers-color-scheme: dark)`).matches}function h(e){fo()&&(e=!1),F(l,e,!0),document.documentElement.classList.toggle(`dark`,e)}function g(){h(!V(l));try{localStorage.setItem(`ld-dark`,String(V(l)))}catch{}}kn(()=>{let e=document.getElementById(`hljs-dark`),t=document.getElementById(`hljs-light`);if(!e||!t)return;let n=X.codeBlockLightTheme&&!V(l);e.disabled=n,t.disabled=!n,document.body.classList.toggle(`ld-code-light`,n)});function _(e){let t=e.trim();if(p&&clearTimeout(p),!t){X.searchQuery=``,X.searchResults=null;return}X.searchQuery=t,X.searchResults=X.allDocs.filter(e=>e.title.toLowerCase().includes(t.toLowerCase())||e.category.toLowerCase().includes(t.toLowerCase())),p=window.setTimeout(async()=>{try{let e=await Bg(t);t===X.searchQuery&&(X.searchResults=e)}catch{}},350)}let v=P(I([]));function y(e){let t=V(v)[e];t&&(F(v,V(v).slice(0,e),!0),b(t.id,!1,`restore`))}async function b(e,t=!1,n=!1,r=null){if(n===!0&&X.currentDocId&&X.currentDocId!==e){let t=V(v).findIndex(t=>t.id===e);if(t!==-1)F(v,V(v).slice(0,t),!0);else{let e=X.allDocs.find(e=>e.id===X.currentDocId);F(v,[...V(v),{id:X.currentDocId,title:e?e.title:X.currentDocId}],!0)}}else n||F(v,[],!0);X.currentDocId=e;let i=X.allDocs.find(t=>t.id===e);if(i&&X.revealDoc(i),!t){let t=new URL(location.href);t.searchParams.set(`doc`,e),t.hash=r?`#${r}`:``,history.pushState({docId:e,anchor:r||null},``,t)}F(s,!0),F(c,``);try{let t=await Ig(e);t.id=e,F(o,t,!0),document.title=t.title,requestAnimationFrame(()=>{let e=document.getElementById(`home-content-area`);if(r){let t=document.getElementById(r);t&&e&&(e.scrollTop+=t.getBoundingClientRect().top-e.getBoundingClientRect().top-80)}else e&&(e.scrollTop=0)})}catch(e){F(c,Y(`doc.failed_to_load`)+(e instanceof Error?e.message:String(e)))}finally{F(s,!1)}}async function x(e){if(!V(o))return;let t=V(o).id,n=await fetch(`/api/documents/`+t,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:e})});if(!n.ok)throw Error(await n.text());let r=await Ig(t);r.id=t,F(o,r,!0);let i=e.match(/\]\(\s*\.?\/files\/[^)\s]+/g),a={...X.fileAttachmentCounts};i&&i.length?a[t]=i.length:delete a[t],X.fileAttachmentCounts=a}function S(e){let t=X.allDocs.find(t=>t.id===e);if(!t)return null;let n=(t.folder||[]).join(`/`),r=e=>(e.folder||[]).join(`/`)===n,i=X.hideCategories?X.allDocs.filter(r).slice().sort((e,t)=>(e.filename||``).localeCompare(t.filename||``)):X.allDocs.filter(e=>r(e)&&e.category===t.category),a=i.findIndex(t=>t.id===e);if(a===-1)return null;let o=i[a+1]??i[a-1];return o?o.id:null}async function C(){if(!V(o))return;let e=V(o).id;if(!(await fetch(`/api/documents/`+encodeURIComponent(e),{method:`DELETE`})).ok)return;let t=S(e);X.allDocs=X.allDocs.filter(t=>t.id!==e),Array.isArray(X.searchResults)&&(X.searchResults=X.searchResults.filter(t=>t.id!==e));let n={...X.annotationCounts};delete n[e],X.annotationCounts=n;let r={...X.fileAttachmentCounts};delete r[e],X.fileAttachmentCounts=r,t?await b(t):(X.currentDocId=null,F(o,null),history.pushState({},``,location.pathname))}async function w(){let[e,t]=await Promise.all([Pg(),Ng()]);if(X.allDocs=e,X.docsFolder=typeof t.docsFolder==`string`?t.docsFolder:``,t.docsFolder)try{X.allFolderPaths=await Fg(t.docsFolder)}catch{X.allFolderPaths=[]}let[n,r,i]=await Promise.all([Lg(),Rg(),zg()]);X.annotationCounts=n,X.fileAttachmentCounts=r,X.docStatuses=i}Gi(async()=>{F(u,fo(),!0),h(m());let e=await Ng();await ha(e.language||`en`),e.title&&(document.title=e.title,F(d,e.title,!0)),e.filenamePattern&&F(f,e.filenamePattern+`.md`),X.exclusiveFolderExpansion=!!e.exclusiveFolderExpansion,X.exclusiveCategoryExpansion=!!e.exclusiveCategoryExpansion,X.codeBlockMaxHeight=typeof e.codeBlockMaxHeight==`number`?e.codeBlockMaxHeight:400,X.imageRoundedCorners=!!e.imageRoundedCorners,X.imageCentered=!!e.imageCentered,X.imageBorder=!!e.imageBorder,X.codeBlockLightTheme=!!e.codeBlockLightTheme,X.sidebarSort=[`recent`,`oldest`,`alphabetical`].includes(e.sidebarSort)?e.sidebarSort:`recent`,X.codeBlockMaxHeight>0&&document.documentElement.style.setProperty(`--ld-code-max-h`,X.codeBlockMaxHeight+`px`),X.expandedCategories.size===0&&(X.expandedCategories=new Set([`DOCUMENTATION`,`General`])),await w();let t=new URLSearchParams(location.search).get(`doc`);if(t)b(t,!0,!1,location.hash?location.hash.slice(1):null);else{let t=Array.isArray(e.favorites)?e.favorites:[],n=t.length?t[0]?.id:void 0,r=(n?X.allDocs.find(e=>e.id===n):void 0)??X.allDocs.find(e=>e.category===`DOCUMENTATION`)??X.allDocs.find(e=>e.category===`General`)??X.allDocs[0];r&&b(r.id,!0)}let n=e=>{let t=e.state?.docId||new URLSearchParams(location.search).get(`doc`),n=e.state?.anchor||(location.hash.length>1?location.hash.slice(1):null);t&&b(t,!0,!1,n)};window.addEventListener(`popstate`,n);let r=()=>{w()};return window.addEventListener(`ld:documents-changed`,r),()=>{window.removeEventListener(`popstate`,n),window.removeEventListener(`ld:documents-changed`,r)}});var T=dw(),E=R(T),D=L(E);so(D,{get title(){return V(d)},subtitle:``,actions:e=>{var t=sw(),n=R(t),r=z(n,2),i=e=>{var t=ow(),n=L(t,!0);j(t),B(()=>G(n,V(l)?`☀`:`☾`)),H(`click`,t,g),W(e,t)};K(r,e=>{V(u)||e(i)}),B((e,t)=>{J(n,`title`,e),J(n,`aria-label`,t)},[()=>Y(`nav.word_cloud`),()=>Y(`nav.word_cloud`)]),H(`click`,n,()=>F(a,!0)),W(e,t)},children:(e,t)=>{var n=cw(),r=L(n);Di(r),Ie(2),j(n),B(e=>{J(r,`placeholder`,e),Oi(r,X.searchQuery)},[()=>Y(`nav.search_placeholder`)]),H(`input`,r,e=>_(e.target.value)),W(e,n)},$$slots:{actions:!0,default:!0}});var ee=z(D,2),te=L(ee);h_(te,{onopen:e=>b(e),onsearch:_,onexport:()=>F(i,!0),onnewfolder:()=>F(n,!0),onnewdoc:()=>F(r,!0)});var O=z(te,2),ne=L(O),re=e=>{var t=Wr(),n=R(t),r=e=>{var t=lw(),n=L(t,!0);j(t),B(()=>G(n,V(c))),W(e,t)},i=e=>{hC(e,{get doc(){return V(o)},get navHistory(){return V(v)},ongoback:y,onopen:(e,t)=>b(e,!1,!0,t),onsave:x,ondelete:C})};K(n,e=>{V(c)?e(r):e(i,-1)}),W(e,t)},k=e=>{var t=uw(),n=L(t),r=z(L(n),2),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var s=z(a,2),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(n),j(t),B((e,t,n)=>{G(i,e),G(o,t),G(c,V(f)),G(u,n)},[()=>Y(`welcome.title`),()=>Y(`welcome.hint`),()=>Y(`welcome.pattern_hint`)]),W(e,t)};K(ne,e=>{V(o)?e(re):e(k,-1)}),j(O),j(ee),j(E);var ie=z(E,2);CC(ie,{get open(){return V(n)},onclose:()=>F(n,!1),onsuccess:w});var ae=z(ie,2);MC(ae,{get open(){return V(r)},onclose:()=>F(r,!1),onsuccess:async e=>{await w(),b(e)}});var oe=z(ae,2);BC(oe,{get open(){return V(i)},onclose:()=>F(i,!1)}),aw(z(oe,2),{get open(){return V(a)},onclose:()=>F(a,!1)}),W(e,T),Je()}Pr([`click`,`input`]);var pw=`modulepreload`,mw=function(e){return`/`+e},hw={},gw=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,new URL(`../../../src/node/plugins/importAnalysisBuild.ts`,import.meta.url)).href}r=o(t.map(t=>{if(t=mw(t,n),t=s(t),t in hw)return;hw[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:pw,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},_w=U(`<div class="flex flex-col h-screen overflow-hidden bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100"><header class="flex items-center gap-1 px-2 h-12 shrink-0 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-sm z-10"><button class="tool-btn !w-auto px-2 text-xs font-medium text-gray-500 dark:text-gray-400"> </button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnSidebar" class="tool-btn">☰</button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnCopyDiagramId" class="tool-btn"><svg width="15" height="15" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="5" width="8" height="9" rx="1.5"></rect><path d="M3 11V3a1 1 0 0 1 1-1h7"></path></svg></button> <button id="toolSelect" class="tool-btn tool-active"><svg width="11" height="13" viewBox="0 0 11 13" fill="currentColor" stroke="none"><path d="M1 1 L1 12 L4 9 L6.5 13 L8 12.2 L5.5 8.2 L10 8.2 Z"></path></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="toolBox" class="tool-btn"><svg width="15" height="10" viewBox="0 0 15 10" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1" y="1" width="13" height="8" rx="1"></rect></svg></button> <button id="toolEllipse" class="tool-btn"><svg width="16" height="10" viewBox="0 0 16 10" fill="none" stroke="currentColor" stroke-width="1.5"><ellipse cx="8" cy="5" rx="7" ry="4"></ellipse></svg></button> <button id="toolDatabase" class="tool-btn"><svg width="12" height="16" viewBox="0 0 12 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><ellipse cx="6" cy="3" rx="5" ry="2"></ellipse><path d="M1 3v10c0 1.1 2.2 2 5 2s5-.9 5-2V3"></path><path d="M11 7.5c0 1.1-2.2 2-5 2s-5-.9-5-2"></path></svg></button> <button id="toolCircle" class="tool-btn"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="6.5" cy="6.5" r="5.5"></circle></svg></button> <button id="toolActor" class="tool-btn"><svg width="12" height="17" viewBox="0 0 12 17" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="6" cy="3" r="2.2"></circle><line x1="6" y1="5.2" x2="6" y2="10"></line><line x1="1.5" y1="7.5" x2="10.5" y2="7.5"></line><line x1="6" y1="10" x2="2.5" y2="15"></line><line x1="6" y1="10" x2="9.5" y2="15"></line></svg></button> <button id="toolPostIt" class="tool-btn"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.4"><path d="M1 1 H9 L12 4 V12 H1 Z"></path><path d="M9 1 V4 H12" stroke-opacity="0.5"></path></svg></button> <button id="toolTextFree" class="tool-btn" style="font-size:11px; font-weight:600;">T</button> <button id="toolImage" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="1" width="12" height="12" rx="1.5"></rect><circle cx="4.5" cy="4.5" r="1.2"></circle><path d="M1 9.5 L4 6.5 L6.5 9 L9 7 L13 10.5"></path></svg></button> <a href="/shape-editor" class="tool-btn">✦</a> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="toolArrow" class="tool-btn">→</button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDelete" class="tool-btn"><svg width="11" height="11" viewBox="0 0 11 11" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="1" y1="1" x2="10" y2="10"></line><line x1="10" y1="1" x2="1" y2="10"></line></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDiagramDefaults" class="tool-btn"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"></path><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.474l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"></path></svg></button> <button id="btnAlign" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4"><line x1="0.5" y1="7.5" x2="13.5" y2="7.5"></line><line x1="3.5" y1="0.5" x2="3.5" y2="13.5" stroke-dasharray="1.5 1.5"></line><line x1="10.5" y1="0.5" x2="10.5" y2="13.5" stroke-dasharray="1.5 1.5"></line></svg></button> <button id="btnGrid" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.2"><line x1="5" y1="1" x2="5" y2="13"></line><line x1="9" y1="1" x2="9" y2="13"></line><line x1="1" y1="5" x2="13" y2="5"></line><line x1="1" y1="9" x2="13" y2="9"></line><rect x="1" y="1" width="12" height="12" rx="1"></rect></svg></button> <button id="btnEdgeStraight" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><line x1="2" y1="12" x2="12" y2="2"></line><polyline points="8,2 12,2 12,6"></polyline></svg></button> <button id="btnEvidenceMode" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M4 1.5 H8.5 L11 4 V12.5 H4 Z"></path><path d="M8.5 1.5 V4 H11"></path><path d="M1.5 5.5 H6.5"></path><path d="M1.5 8 H6.5"></path><path d="M1.5 10.5 H5"></path></svg></button> <button id="btnResizeMode" class="tool-btn active-tool"><svg id="icon-resize-corner" width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="1" width="12" height="12" stroke-dasharray="2.5 2"></rect><line x1="4" y1="4" x2="10" y2="10"></line><polyline points="7,10 10,10 10,7"></polyline></svg> <svg id="icon-resize-center" width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="hidden"><rect x="1" y="1" width="12" height="12" stroke-dasharray="2.5 2"></rect><line x1="4" y1="4" x2="10" y2="10"></line><polyline points="4,6.5 4,4 6.5,4"></polyline><polyline points="10,7.5 10,10 7.5,10"></polyline><line x1="10" y1="4" x2="4" y2="10"></line><polyline points="7.5,4 10,4 10,6.5"></polyline><polyline points="4,7.5 4,10 6.5,10"></polyline></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <input id="diagramTitle" type="text" class="flex-1 min-w-0 px-2 py-1 text-sm bg-transparent border-0 focus:outline-none focus:ring-1 focus:ring-blue-500 rounded text-gray-700 dark:text-gray-300 placeholder:text-gray-400"/> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnZoomOut" class="tool-btn">−</button> <span id="zoomLevel" class="text-xs text-gray-500 dark:text-gray-400 w-10 text-center tabular-nums select-none">100%</span> <button id="btnZoomIn" class="tool-btn">+</button> <button id="btnZoomReset" class="tool-btn">⊡</button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDark" class="tool-btn"><span id="darkIcon">☽</span></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDebug" class="hidden tool-btn text-xs font-mono">dbg</button> <div id="sepDebug" class="hidden w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnExportDrawio" class="tool-btn"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnSave" disabled="" class="px-3 py-1.5 text-xs font-semibold rounded-lg bg-blue-600 hover:bg-blue-700 text-white disabled:opacity-40 disabled:cursor-not-allowed shrink-0 transition-colors"><span> </span></button></header> <div class="flex flex-1 overflow-hidden"><div id="sidebar" class="w-56 shrink-0 border-r border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 flex flex-col overflow-hidden" style="transition: width 0.2s ease"><div class="flex items-center justify-between px-3 py-2 border-b border-gray-200 dark:border-gray-700 shrink-0"><span class="text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider"> </span> <button id="btnNewDiagram" class="text-xs font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors"> </button></div> <div id="diagramList" class="flex-1 overflow-y-auto py-1"></div></div> <div role="separator" aria-orientation="vertical"></div> <div class="relative flex-1 overflow-hidden bg-gray-50 dark:bg-gray-950"><div id="vis-canvas" class="w-full h-full"></div> <div id="customShapeBar" class="hidden"><div id="customShapeBarBody"></div></div> <div id="debugLayer"></div> <div id="evidenceLayer" class="hidden"></div> <div id="stampOverlay" style="position:absolute;inset:0;display:none;z-index:11;cursor:crosshair;"></div> <div id="selectionOverlay"><div id="rh-tl" class="resize-handle" style="top: -5px; left: -5px; cursor: nw-resize"></div> <div id="rh-tr" class="resize-handle" style="top: -5px; right: -5px; cursor: ne-resize"></div> <div id="rh-bl" class="resize-handle" style="bottom: -5px; left: -5px; cursor: sw-resize"></div> <div id="rh-br" class="resize-handle" style="bottom: -5px; right: -5px; cursor: se-resize"></div> <div id="rh-rotate">↻</div> <div id="rh-label-rotate" style="left: 0; top: -28px;"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><g transform="rotate(25,5,5)"><line x1="2.5" y1="3" x2="7.5" y2="3"></line><line x1="5" y1="3" x2="5" y2="8"></line></g></svg></div></div> <aside id="evidencePanel" class="hidden absolute top-0 right-0 bottom-0 w-80 max-w-[85vw] z-30 bg-gray-50 dark:bg-gray-900 border-l border-gray-200 dark:border-gray-700 shadow-xl flex flex-col"><div class="flex items-center justify-between gap-2 px-4 py-3 border-b border-gray-200 dark:border-gray-700"><h2 id="evidencePanelTitle" class="text-sm font-semibold text-gray-800 dark:text-gray-100"> </h2> <button id="btnEvidenceClose" class="tool-btn !w-7 !h-7">×</button></div> <div id="evidencePanelBody" class="flex-1 overflow-y-auto p-3 space-y-3"></div></aside> <div id="nodePanel" class="float-panel hidden"><button id="btnNodeLock" class="tool-btn !w-6 !h-6 text-sm">🔒</button> <div class="panel-sep"></div> <div id="nodePanelControls" class="contents"><button id="nodeColorSwatch" style="width:1.5rem;height:1.5rem;border-radius:0.25rem;border:2px solid #a8a29e;background:#f5f5f4;cursor:pointer;flex-shrink:0;"></button> <div class="panel-sep"></div> <input id="nodeBgOpacity" type="range" min="0" max="100" step="5" value="100" class="w-16 h-1 accent-orange-500 cursor-pointer"/> <div class="panel-sep"></div> <button id="btnNodeLabelEdit" class="tool-btn !w-6 !h-6">✎</button> <button id="btnNodeLink" class="tool-btn !w-6 !h-6"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7.5a3.5 3.5 0 0 0 5 0l1.5-1.5a3.5 3.5 0 0 0-5-5L5 2.5"></path><path d="M8 5.5a3.5 3.5 0 0 0-5 0L1.5 7a3.5 3.5 0 0 0 5 5L8 10.5"></path></svg></button> <div class="panel-sep"></div> <button id="btnNodeFontDecrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa−</button> <span id="nodeFontSizeValue" class="inline-flex items-center justify-center min-w-[2.25rem] h-6 px-1 text-[11px] font-mono text-gray-700 dark:text-gray-200 border border-gray-300 dark:border-gray-600 rounded bg-white/80 dark:bg-gray-800/80">13</span> <button id="btnNodeFontIncrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa+</button> <div class="panel-sep"></div> <button id="btnAlignLeft" class="tool-btn !w-6 !h-6"><svg width="12" height="10" viewBox="0 0 12 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><line x1="1" y1="2" x2="11" y2="2"></line><line x1="1" y1="5" x2="7" y2="5"></line><line x1="1" y1="8" x2="9" y2="8"></line></svg></button> <button id="btnAlignCenter" class="tool-btn !w-6 !h-6"><svg width="12" height="10" viewBox="0 0 12 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><line x1="1" y1="2" x2="11" y2="2"></line><line x1="2.5" y1="5" x2="9.5" y2="5"></line><line x1="1.5" y1="8" x2="10.5" y2="8"></line></svg></button> <button id="btnAlignRight" class="tool-btn !w-6 !h-6"><svg width="12" height="10" viewBox="0 0 12 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><line x1="1" y1="2" x2="11" y2="2"></line><line x1="5" y1="5" x2="11" y2="5"></line><line x1="3" y1="8" x2="11" y2="8"></line></svg></button> <div class="panel-sep"></div> <button id="btnValignTop" class="tool-btn !w-6 !h-6"><svg width="10" height="12" viewBox="0 0 10 12" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="1" y1="1.5" x2="9" y2="1.5" stroke-width="2"></line><line x1="1" y1="5" x2="8" y2="5" stroke-width="1.3"></line><line x1="1" y1="8.5" x2="6" y2="8.5" stroke-width="1.3"></line></svg></button> <button id="btnValignMiddle" class="tool-btn !w-6 !h-6"><svg width="10" height="12" viewBox="0 0 10 12" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="1" y1="2.5" x2="8" y2="2.5" stroke-width="1.3"></line><line x1="1" y1="6" x2="9" y2="6" stroke-width="2"></line><line x1="1" y1="9.5" x2="6" y2="9.5" stroke-width="1.3"></line></svg></button> <button id="btnValignBottom" class="tool-btn !w-6 !h-6"><svg width="10" height="12" viewBox="0 0 10 12" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="1" y1="3.5" x2="8" y2="3.5" stroke-width="1.3"></line><line x1="1" y1="7" x2="6" y2="7" stroke-width="1.3"></line><line x1="1" y1="10.5" x2="9" y2="10.5" stroke-width="2"></line></svg></button> <div class="panel-sep"></div> <div id="customShapeLabelPlacementControls" class="hidden"><button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="above">T↑</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="below">T↓</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="left">←T</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="right">T→</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="center">T□</button> <div class="panel-sep"></div></div> <button id="btnZOrderBack" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="5" width="8" height="8" rx="1"></rect><rect x="5" y="1" width="8" height="8" rx="1" stroke-opacity="0.35"></rect></svg></button> <button id="btnZOrderFront" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="5" width="8" height="8" rx="1" stroke-opacity="0.35"></rect><rect x="5" y="1" width="8" height="8" rx="1"></rect></svg></button> <div class="panel-sep"></div> <button id="btnStampColor" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M7 2 C7 2 3 6.5 3 9 a4 4 0 0 0 8 0 C11 6.5 7 2 7 2 Z" fill="currentColor" fill-opacity="0.25"></path></svg></button> <button id="btnStampFontSize" class="tool-btn !w-7 !h-6 font-mono text-xs font-bold">Aa</button> <button id="btnStampSize" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="6" height="6" rx="0.8" fill="currentColor" fill-opacity="0.25"></rect><path d="M10 2 L12 2 L12 4"></path><path d="M12 2 L9 5"></path><path d="M10 12 L12 12 L12 10"></path><path d="M12 12 L9 9"></path></svg></button> <div class="panel-sep"></div> <button id="btnRotateCCW" class="tool-btn !w-7 !h-6" style="font-size:15px; line-height:1;">↺</button> <button id="btnRotateCW" class="tool-btn !w-7 !h-6" style="font-size:15px; line-height:1;">↻</button> <div class="panel-sep"></div> <button id="btnCopyPng" class="tool-btn !h-6 px-1.5 font-mono text-xs font-semibold flex items-center gap-0.5"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="7" x2="5" y2="1"></line><polyline points="2,4 5,1 8,4"></polyline><line x1="1" y1="9" x2="9" y2="9"></line></svg> PNG</button> <div class="panel-sep"></div> <button id="btnGroup" class="tool-btn !w-8 !h-7"><svg width="22" height="14" viewBox="0 0 22 14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"><rect x="0.7" y="1" width="20.6" height="12" rx="2" stroke-dasharray="2.5,1.5"></rect><rect x="4" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect><rect x="15" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect></svg></button> <button id="btnUngroup" class="tool-btn !w-8 !h-7"><svg width="26" height="14" viewBox="0 0 26 14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"><rect x="0.7" y="1" width="9" height="12" rx="2" stroke-dasharray="2.5,1.5"></rect><rect x="3" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect><rect x="16.3" y="1" width="9" height="12" rx="2" stroke-dasharray="2.5,1.5"></rect><rect x="19" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect></svg></button> <div class="panel-sep"></div> <button id="btnSaveShapeDefault" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"></path><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.474l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"></path></svg></button></div></div> <div id="linkPanel" class="float-panel hidden" style="min-width:260px; flex-direction:column; align-items:stretch; gap:0.5rem; padding:0.75rem;"><div class="text-xs font-semibold text-gray-500 dark:text-gray-400 mb-1"> </div> <label class="flex items-center gap-2 text-xs cursor-pointer"><input type="radio" name="linkType" id="linkTypeUrl" value="url" class="accent-orange-500"/> <span> </span></label> <div id="linkUrlRow"><input id="linkUrlInput" type="url" class="w-full text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-orange-400"/></div> <label class="flex items-center gap-2 text-xs cursor-pointer"><input type="radio" name="linkType" id="linkTypeDiagram" value="diagram" class="accent-orange-500"/> <span> </span></label> <div id="linkDiagramRow" class="hidden"><select id="linkDiagramSelect" class="w-full text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-orange-400"></select></div> <label class="flex items-center gap-2 text-xs cursor-pointer"><input type="radio" name="linkType" id="linkTypeNew" value="new" class="accent-orange-500"/> <span> </span></label> <div id="linkNewRow" class="hidden"><input id="linkNewName" type="text" class="w-full text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-orange-400"/></div> <div class="flex gap-1 mt-1"><button id="btnLinkSave" class="flex-1 text-xs bg-orange-500 hover:bg-orange-600 text-white rounded px-2 py-1"> </button> <button id="btnLinkRemove" class="text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-600"> </button> <button id="btnLinkCancel" class="text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 hover:bg-gray-100 dark:hover:bg-gray-700">✕</button></div></div> <div id="edgePanel" class="float-panel hidden"><button id="btnEdgeLock" class="tool-btn !w-6 !h-6 text-sm">🔒</button> <div class="panel-sep"></div> <div id="edgePanelControls" class="contents"><button id="edgeBtnNone" class="tool-btn !w-7 !h-6 font-mono text-xs">—</button> <button id="edgeBtnFrom" class="tool-btn !w-7 !h-6 text-xs">←</button> <button id="edgeBtnTo" class="tool-btn !w-7 !h-6 text-xs">→</button> <button id="edgeBtnBoth" class="tool-btn !w-8 !h-6 text-xs">←→</button> <div class="panel-sep"></div> <button id="edgeBtnSolid" class="tool-btn !w-8 !h-6"><svg width="22" height="4" viewBox="0 0 22 4"><line x1="1" y1="2" x2="21" y2="2" stroke="currentColor" stroke-width="2" stroke-linecap="round"></line></svg></button> <button id="edgeBtnDashed" class="tool-btn !w-8 !h-6"><svg width="22" height="4" viewBox="0 0 22 4"><line x1="1" y1="2" x2="21" y2="2" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="4,3"></line></svg></button> <div class="panel-sep"></div> <button id="btnEdgeFontDecrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa−</button> <span id="edgeFontSizeValue" class="inline-flex items-center justify-center min-w-[2.25rem] h-6 px-1 text-[11px] font-mono text-gray-700 dark:text-gray-200 border border-gray-300 dark:border-gray-600 rounded bg-white/80 dark:bg-gray-800/80">11</span> <button id="btnEdgeFontIncrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa+</button> <div class="panel-sep"></div> <button id="btnEdgeLabelEdit" class="tool-btn !w-6 !h-6">✎</button> <button id="btnEdgeLabelWidthReset" class="tool-btn !w-6 !h-6 text-xs">↔</button> <div class="panel-sep"></div> <button id="btnEdgeLabelRotateCCW" class="tool-btn !w-7 !h-6 text-sm">↺</button> <button id="btnEdgeLabelRotateCW" class="tool-btn !w-7 !h-6 text-sm">↻</button> <div class="panel-sep"></div> <button id="btnEdgeLabelOffsetLeft" class="tool-btn !w-6 !h-6 text-sm">←</button> <button id="btnEdgeLabelOffsetRight" class="tool-btn !w-6 !h-6 text-sm">→</button> <button id="btnEdgeLabelOffsetUp" class="tool-btn !w-6 !h-6 text-sm">↑</button> <button id="btnEdgeLabelOffsetDown" class="tool-btn !w-6 !h-6 text-sm">↓</button> <button id="btnEdgeLabelOffsetReset" class="tool-btn !w-6 !h-6 text-xs">⊙</button> <div class="panel-sep"></div> <button id="btnEdgeWidthDecrease" class="tool-btn !w-7 !h-6" style="font-size:10px">W−</button> <button id="btnEdgeWidthIncrease" class="tool-btn !w-7 !h-6" style="font-size:10px">W+</button> <div class="panel-sep"></div> <button id="edgeColorSwatch" style="width:1.5rem;height:1.5rem;border-radius:0.25rem;border:2px solid #a8a29e;background:#a8a29e;cursor:pointer;flex-shrink:0;"></button> <div class="panel-sep"></div> <button id="btnEdgeClearPorts" class="tool-btn !w-8 !h-6 text-xs">⊗</button> <div class="panel-sep"></div> <button id="btnSaveEdgeDefault" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"></path><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.474l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"></path></svg></button></div></div> <textarea id="labelInput" class="hidden" rows="1"></textarea> <div id="emptyState" class="absolute inset-0 flex flex-col items-center justify-center text-gray-400 dark:text-gray-600 pointer-events-none select-none"><svg width="52" height="44" viewBox="0 0 52 44" fill="none" stroke="currentColor" stroke-width="1.5" class="mb-3 opacity-50"><rect x="2" y="4" width="18" height="12" rx="2"></rect><rect x="32" y="28" width="18" height="12" rx="2"></rect><line x1="20" y1="10" x2="32" y2="34" stroke-dasharray="4,3"></line><rect x="17" y="16" width="18" height="12" rx="2"></rect><line x1="26" y1="16" x2="26" y2="10" stroke-dasharray="4,3"></line></svg> <p class="text-sm"> </p></div></div></div> <div id="toastContainer"></div> <div id="imageNameModal" style="display:none;position:fixed;inset:0;z-index:1000;background:rgba(0,0,0,0.5);" class="flex items-center justify-center"><div class="bg-white dark:bg-gray-800 rounded-xl shadow-2xl p-6 w-80 flex flex-col gap-3"><p class="text-sm font-semibold text-gray-700 dark:text-gray-200"> </p> <p class="text-xs text-gray-400 dark:text-gray-500">Lettres, chiffres, <code class="bg-gray-100 dark:bg-gray-700 px-0.5 rounded">_</code> et <code class="bg-gray-100 dark:bg-gray-700 px-0.5 rounded">-</code> uniquement.
278
+ </html>`,f=window.open(``,`_blank`);if(!f){alert(Y(`error.pdf_popup`));return}f.document.write(d),f.document.close(),t.onclose()}catch(e){alert(Y(`error.pdf_export`)+(e instanceof Error?e.message:String(e)))}finally{F(d,!1)}}let y=`px-4 py-2 text-sm border-b-2 border-blue-500 text-blue-600 dark:text-blue-400 font-semibold transition-colors`,b=`px-4 py-2 text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors`;var x=Wr(),S=R(x),C=e=>{var r=VC(),f=L(r),p=L(f),h=z(L(p),2),x=L(h,!0);j(h),j(p);var S=z(p,2),C=L(S),w=L(C,!0);j(C);var T=z(C,2),E=L(T,!0);j(T);var D=z(T,2),ee=L(D,!0);j(D),j(S);var te=z(S,2),O=e=>{var t=RC(),n=L(t),r=L(n),c=e=>{var t=FC(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},l=e=>{var t=IC(),n=L(t);j(t),B(e=>G(n,`${e??``}failed to load folders`),[()=>Y(`common.error_prefix`)]),W(e,t)},u=e=>{var t=Wr();q(R(t),16,()=>V(o),e=>e,(e,t)=>{var n=LC(),r=L(n);Di(r);var i,a=z(r,2),o=L(a,!0);j(a),j(n),B(()=>{i!==(i=t)&&(r.value=(r.__value=t)??``),G(o,t)}),Ii(r,()=>V(s)[t],e=>V(s)[t]=e),W(e,n)}),W(e,t)};K(r,e=>{V(i)?e(c):V(a)?e(l,1):e(u,-1)}),j(n),j(t),W(e,t)};K(te,e=>{V(n)===`html`&&e(O)});var ne=z(te,2),re=e=>{var n=zC(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var l=z(o,2),u=L(l,!0);j(l),j(a),j(n),B((e,t,n)=>{G(i,e),G(s,t),l.disabled=V(c),G(u,n)},[()=>Y(`modal.export.markdown_hint`),()=>Y(`common.cancel`),()=>V(c)?`⏳`:Y(`modal.export.markdown_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),H(`click`,l,g),W(e,n)};K(ne,e=>{V(n)===`markdown`&&e(re)});var k=z(ne,2),ie=e=>{var n=BC(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),d=L(c,!0);j(c);var f=z(c,2),p=L(f,!0);j(f),j(a),j(n),B((e,t,n,r)=>{G(i,e),G(s,t),c.disabled=V(l),G(d,n),f.disabled=V(u),G(p,r)},[()=>Y(`modal.export_html.hint`),()=>Y(`common.cancel`),()=>V(l)?`⏳`:Y(`modal.export_html.notion_btn`),()=>V(u)?`⏳`:Y(`modal.export_html.confluence_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),H(`click`,c,()=>_(`notion`)),H(`click`,f,()=>_(`confluence`)),W(e,n)};K(k,e=>{V(n)===`html`&&e(ie)});var ae=z(k,2),oe=e=>{var n=zC(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(a),j(n),B((e,t,n)=>{G(i,e),G(s,t),c.disabled=V(d),G(l,n)},[()=>Y(`modal.export.pdf_hint`),()=>Y(`common.cancel`),()=>V(d)?`⏳`:Y(`modal.export.pdf_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),H(`click`,c,v),W(e,n)};K(ae,e=>{V(n)===`pdf`&&e(oe)}),j(f),j(r),B((e,t,r,i)=>{G(x,e),gi(C,1,ui(V(n)===`markdown`?y:b)),G(w,t),gi(T,1,ui(V(n)===`html`?y:b)),G(E,r),gi(D,1,ui(V(n)===`pdf`?y:b)),G(ee,i)},[()=>Y(`modal.export.title`),()=>Y(`modal.export.tab_markdown`),()=>Y(`modal.export.tab_html`),()=>Y(`modal.export.tab_pdf`)]),H(`click`,r,e=>{e.target===e.currentTarget&&t.onclose()}),H(`click`,C,()=>m(`markdown`)),H(`click`,T,()=>m(`html`)),H(`click`,D,()=>m(`pdf`)),W(e,r)};K(S,e=>{t.open&&e(C)}),W(e,x),Je()}Pr([`click`]);var UC=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),WC=U(`<p> </p>`),GC=U(`<div class="group flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><button class="flex-1 flex items-center gap-2 px-3 py-2 text-sm text-left"><span class="text-gray-400 shrink-0">&#128193;</span> <span class="text-gray-700 dark:text-gray-300 truncate"> </span></button> <button title="Add to exclusions" class="shrink-0 text-red-400 hover:text-red-600 px-3 py-2 text-sm font-bold transition-colors">⊖</button></div>`),KC=U(`<div class="group flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><span class="flex-1 flex items-center gap-2 px-3 py-2 text-sm text-gray-500 dark:text-gray-400"><span class="shrink-0 opacity-40">&#128196;</span> <span class="truncate font-mono"> </span></span> <button title="Add to exclusions" class="shrink-0 text-red-400 hover:text-red-600 px-3 py-2 text-sm font-bold transition-colors">⊖</button></div>`),qC=U(`<div class="border-t border-gray-200 dark:border-gray-700"><div class="flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"><button class="text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-30 disabled:pointer-events-none shrink-0">&#8593; Up</button> <span class="font-mono text-xs text-gray-400 dark:text-gray-500 truncate flex-1 text-right"> </span></div> <div class="divide-y divide-gray-100 dark:divide-gray-800 max-h-52 overflow-y-auto"><!></div></div>`),JC=U(`<label class="flex items-center gap-1.5 text-xs text-gray-700 dark:text-gray-300 cursor-pointer"><input type="checkbox"/> </label>`),YC=U(`<div class="group flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><button class="flex-1 flex items-center gap-2 px-3 py-2 text-sm text-left"><span class="text-gray-400 shrink-0">&#128193;</span> <span class="text-gray-700 dark:text-gray-300 truncate"> </span></button> <button title="Exclude this folder" class="shrink-0 opacity-0 group-hover:opacity-100 text-red-400 hover:text-red-600 px-3 py-2 text-sm transition-opacity">⊖</button></div>`),XC=U(`<button class="w-full px-3 py-2 text-xs text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-950/30 text-left font-medium border-t border-gray-100 dark:border-gray-800">&#10003; Select: <span class="font-mono"> </span></button>`),ZC=U(`<!> <!>`,1),QC=U(`<div> </div>`),$C=U(`<div> </div> <div> </div> <div> </div> <!>`,1),ew=U(`<div role="button" tabindex="0" class="flex items-center gap-2 px-3 py-1 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors"><span class="text-gray-400 dark:text-gray-600 w-5 text-right shrink-0 tabular-nums text-xs"></span> <div class="flex-1 min-w-0"><div class="flex items-center justify-between gap-1"><span class="text-gray-800 dark:text-gray-200 font-medium truncate text-xs"> </span> <span class="text-gray-400 dark:text-gray-600 tabular-nums shrink-0 text-xs"> </span></div> <div class="h-1 bg-gray-100 dark:bg-gray-800 rounded-full mt-0.5"><div class="h-1 bg-blue-400 dark:bg-blue-600 rounded-full"></div></div></div></div>`),tw=U(`<div class="w-56 shrink-0 border-r border-gray-200 dark:border-gray-800 flex flex-col bg-white dark:bg-gray-900 overflow-hidden"><div class="px-3 py-2 text-xs text-gray-500 dark:text-gray-400 space-y-0.5 border-b border-gray-100 dark:border-gray-800"><!></div> <div class="px-3 py-2 border-b border-gray-100 dark:border-gray-800 flex items-center gap-2"><span class="text-xs text-gray-500 dark:text-gray-400 shrink-0 cursor-help"> </span> <input type="number" min="1" max="20" class="w-12 px-1.5 py-0.5 text-xs rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-800 dark:text-gray-200 focus:outline-none"/> <button class="text-xs text-blue-600 dark:text-blue-400 hover:underline"> </button></div> <p class="px-3 pt-2 pb-1 text-xs font-semibold text-gray-400 dark:text-gray-600 uppercase tracking-wider"> </p> <div class="flex-1 overflow-y-auto"></div></div>`),nw=U(`<p class="absolute inset-0 flex items-center justify-center text-gray-400 dark:text-gray-500 text-sm animate-pulse"> </p>`),rw=U(`<div class="flex items-center gap-1 group py-0.5"><span class="text-gray-600 dark:text-gray-400 break-all font-mono flex-1 text-xs"> </span> <button title="Exclude this file" class="shrink-0 opacity-0 group-hover:opacity-100 text-red-400 hover:text-red-600 text-xs leading-none px-1 transition-opacity">⊖</button></div>`),iw=U(`<div class="text-gray-400 text-center py-2">—</div>`),aw=U(`<div class="w-80 shrink-0 border-l border-gray-200 dark:border-gray-800 flex flex-col bg-white dark:bg-gray-900 overflow-hidden"><div class="px-3 py-2 border-b border-gray-100 dark:border-gray-800 flex items-center justify-between"><span class="font-bold text-sm text-gray-900 dark:text-gray-100"> </span> <button class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 text-xs leading-none">✕</button></div> <p class="px-3 pt-2 pb-1 text-xs font-semibold text-gray-400 dark:text-gray-600 uppercase tracking-wider"> </p> <div class="flex-1 overflow-y-auto px-3 py-1 space-y-1 text-xs"><!></div></div>`),ow=U(`<div class="fixed inset-0 z-50 flex flex-col bg-white dark:bg-gray-950"><div class="flex items-center justify-between px-6 h-14 border-b border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shrink-0"><h2 class="font-semibold text-base"> </h2> <button class="text-sm px-3 py-1.5 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"> </button></div> <div class="border-b border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shrink-0"><div class="flex items-center gap-3 px-6 py-3"><label class="text-xs font-medium text-gray-500 dark:text-gray-400 shrink-0"> </label> <input type="text" readonly="" spellcheck="false" class="flex-1 px-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono cursor-default focus:outline-none"/> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0">&#128193; <span> </span></button> <button class="text-sm px-4 py-1.5 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors shrink-0"> </button></div> <div class="flex items-start gap-3 px-6 pb-2"><label class="text-xs font-medium text-gray-500 dark:text-gray-400 shrink-0 pt-1.5"> </label> <textarea rows="3" spellcheck="false" class="flex-1 px-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono focus:outline-none focus:ring-1 focus:ring-blue-400 resize-y"></textarea> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0">&#128193; <span> </span></button></div> <!> <div class="flex items-center gap-x-4 gap-y-2 px-6 pb-3 flex-wrap"><span class="text-xs font-medium text-gray-500 dark:text-gray-400 shrink-0"> </span> <label class="flex items-center gap-1.5 text-xs font-medium text-blue-600 dark:text-blue-400 cursor-pointer shrink-0"><input type="checkbox"/> </label> <!></div> <!></div> <div class="flex-1 overflow-hidden flex"><!> <div class="flex-1 relative overflow-hidden"><!> <canvas style="position: absolute; inset: 0"></canvas></div> <!></div></div>`);function sw(e,t){qe(t,!0);let n=new Set(`the.a.an.and.or.but.not.nor.so.yet.both.either.neither.is.are.was.were.be.been.being.have.has.had.do.does.did.will.would.shall.should.may.might.can.could.must.need.dare.ought.used.to.of.in.for.on.with.at.by.from.up.about.into.through.during.before.after.above.below.between.out.off.over.under.again.further.then.once.here.there.when.where.why.how.all.each.few.more.most.other.some.such.no.only.own.same.than.too.very.just.also.still.already.always.never.often.sometimes.usually.this.that.these.those.its.your.our.their.his.her.him.she.you.they.we.me.my.it.who.which.what.whose.whom.if.though.although.because.since.while.unless.until.whether.as.like.via.per.i.am.he.us.see.now.new.old.got.let.put.say.said.says.get.use.make.made.take.come.came.go.went.know.think.look.want.give.seem.back.down.even.much.well.good.work.tell.keep.hold.turn.move.play.live.help.run.start.off.way.too.few.show.hear.etc.eg.ie.one.two.three.four.five.six.seven.eight.nine.ten.le.la.les.un.une.des.du.de.d.l.au.aux.ce.ci.cet.cette.ces.mon.ma.mes.ton.ta.tes.son.sa.ses.notre.nos.votre.vos.leur.leurs.je.tu.il.elle.on.nous.vous.ils.elles.me.te.se.lui.y.en.qui.que.quoi.dont.où.et.ou.mais.donc.or.ni.car.si.ne.pas.plus.moins.très.bien.mal.peu.beaucoup.trop.assez.aussi.comme.pour.par.avec.sans.dans.sur.sous.entre.vers.chez.contre.avant.après.pendant.depuis.selon.malgré.sauf.est.sont.était.être.avoir.fait.faire.dit.dire.peut.pouvoir.doit.devoir.veut.vouloir.sait.savoir.va.aller.vient.venir.tout.tous.toute.toutes.autre.autres.même.chaque.quel.quelle.quels.quelles.aucun.aucune.certain.certaine.plusieurs.quelque.quelques.tel.telle.tels.telles.cela.ceci.ça.celui.celle.ceux.celles.ici.voici.voilà.alors.ainsi.encore.déjà.jamais.toujours.souvent.parfois.rien.personne.chose.fois.jour.temps.part.cas.point.lieu.monde.cependant.néanmoins.pourtant.toutefois.quand.lorsque.puisque.parce.afin.puis.lors.notamment.surtout.seulement.vraiment.enfin.ensuite.ailleurs.là.ici.voici.voilà.dont.lequel.laquelle.lesquels.lesquelles`.split(`.`)),r=new Set(`public.private.protected.static.void.class.interface.abstract.final.const.let.var.function.return.if.else.for.while.do.switch.case.break.continue.try.catch.throw.throws.finally.new.this.self.super.import.export.from.package.module.require.include.using.namespace.struct.enum.trait.impl.fn.def.func.fun.val.mut.async.await.yield.lambda.extends.implements.override.virtual.sealed.data.object.companion.where.when.match.guard.defer.go.chan.select.type.alias.as.is.in.of.with.true.false.null.nil.none.undefined.println.printf.fmt.log.print.main.args.argv.init.setup.teardown.describe.test.expect.assert.before.after.not.and.or.delete.typeof.instanceof.readonly.keyof.infer.never.unknown.declare.satisfies.get.set.add.remove.update.create.find.fetch.load.save.put.post.patch.list.map.filter.reduce.sort.merge.parse.format.convert.transform.validate.check.handle.process.execute.start.stop.reset.clear.close.open.read.write.send.receive.emit.trigger.dispatch.subscribe.unsubscribe.listen.notify.register.unregister.bind.apply.call.invoke.callback.handler.listener.middleware.interceptor.resolver.provider.consumer.producer.builder.factory.adapter.wrapper.proxy.decorator.observer.visitor.strategy.command.controller.service.repository.dao.dto.entity.model.schema.config.context.state.store.action.reducer.selector.hook.ref.effect.memo.component.module.plugin.extension.util.utils.helper.helpers.common.shared.base.default.index.app.core.lib.src.test.spec.mock.stub.fixture.impl.internal.api.sdk.client.server.request.response.status.code.error.exception.message.result.data.value.key.name.label.title.description.item.element.node.child.parent.root.container.wrapper.layout.view.page.screen.panel.header.footer.sidebar.navbar.body.content.section.row.col.column.grid.flex.block.inline.span.div.input.output.param.params.arg.option.options.props.attr.attrs.field.fields.property.properties.method.methods.string.number.boolean.integer.float.double.long.short.byte.char.array.object.map.set.list.vector.queue.stack.hash.table.tree.graph.pair.tuple.optional.nullable.void.unit.any.bool.bytes.none.int.str.bool.all.each.every.some.many.single.multi.first.last.next.prev.previous.current.old.temp.tmp.new.top.bottom.left.right.center.middle.start.end.begin.min.max.count.total.sum.avg.size.length.width.height.depth.flag.num.idx.id.uid.uuid.num.str.val.obj.arr.fn.cb.ctx.req.res.err.msg.src.dst.evt.doc.db.io.fs.os.env.sys.http.https.url.uri.path.port.host.tcp.udp.ssl.tls.html.css.json.xml.yml.yaml.csv.sql.regex.utf.ascii.rgb.rgba.hex.px.em.rem.vh.vw.auto.inherit.initial.application.file.local.source.messages.logging.alerting.programmed.offset.offsets.zone.zoned.decimal.big.integer.constructor.mapper.captor.publisher.verify.subscriber.org.edr.ack.ref.ssr.ssg.csr.isr.mockito.junit.vitest.jest.mocha.rspec.pytest.cypress.playwright.captor.spy.given.then.verify.times.never.invocation.argumentcaptor.inorder.donothing.doreturn.ippon.springframework.jakarta.javax.todo.fixme.hack.note.deprecated.experimental.eslint.prettier.typescript.javascript.java.kotlin.python.golang.rust.csharp.swift.ruby.spring.boot.javax.jakarta.hibernate.lombok.gradle.maven.webpack.vite.react.angular.vue.svelte.nuxt.express.fastapi.flask.django.rails.fiber.gin.actix.tokio.asyncio.junit.jest.mocha.pytest.rspec.docker.kubernetes.aws.gcp.azure.terraform.ansible.nginx.apache.linux.nextjs.remix.astro.sveltekit.gatsby.nuxtjs.qwik.solid.vercel.netlify.cloudflare.supabase.firebase.mongodb.postgres.prisma.drizzle.typeorm.sequelize.mongoose.redis.neon.trpc.graphql.grpc.rest.openapi.swagger.zod.yup.valibot.tailwind.shadcn.radix.headless.chakra.mantine.antd.mui.tanstack.tanstackquery.zustand.jotai.recoil.redux.mobx.storybook.cypress.playwright.vitest.turbopack.turborepo.getserversideprops.getstaticprops.getstaticpaths.generatestaticparams.generatemetadata.serveraction.revalidate.notfound.redirect.permanentredirect.unstablecache.unstablenostore.cookies.headers.userouter.usepathname.usesearchparams.useparams.useformstate.useformstatus.useoptimistic.useserveraction.classname.onclick.onchange.onsubmit.onfocus.onblur.onkeydown.onkeyup.onmousedown.onmouseup.defaultvalue.htmlfor.tabindex.strokewidth.viewbox.fillopacity.strokeopacity.pathdata.children.fragment.portal.suspense.errorboundary.strictmode.createelement.createcontext.createref.forwardref.usestate.useeffect.useref.usecontext.usememo.usecallback.usereducer.useid.usetransition.usedeferredvalue.useimperativehandle.mutex.lock.thread.goroutine.coroutine.channel.buffer.stream.pipe.observable.promise.future.completable.deferred.disposable.lifecycle.scope.annotation.attribute.metadata.reflection.generic.template.macro.preprocessor.compiler.runtime.debug.release.production.development.staging.build.deploy.lint.coverage.report.the.and.for.are.but.not.you.all.this.that.with.have.from.they.will.been.can.has.was.its.our.their.more.also.when.what.about.which.would.into.than.then.each.just.over.after.such.here.some.were.very.only`.split(`.`));function i(e){return n.has(e)||r.has(e)||e.length<3||/^\d+$/.test(e)||/^[^a-z]/.test(e)}function a(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/[_\-./]+/g,` `).toLowerCase().trim().split(/\s+/).filter(e=>e.length>=3)}function o(e){return e.toLowerCase().split(/[^a-zàâäéèêëïîôùûü]+/).filter(e=>e.length>=3)}let s=[{value:`adoc`,cat:`prose`},{value:`asciidoc`,cat:`prose`},{value:`asm`,cat:`code`},{value:`astro`,cat:`code`},{value:`avsc`,cat:`config`},{value:`bash`,cat:`code`},{value:`bat`,cat:`code`},{value:`bicep`,cat:`config`},{value:`c`,cat:`code`},{value:`cc`,cat:`code`},{value:`cfg`,cat:`config`},{value:`cjs`,cat:`code`},{value:`clj`,cat:`code`},{value:`cljs`,cat:`code`},{value:`cmake`,cat:`code`},{value:`cmd`,cat:`code`},{value:`conf`,cat:`config`},{value:`cpp`,cat:`code`},{value:`cql`,cat:`code`},{value:`cs`,cat:`code`},{value:`cshtml`,cat:`code`},{value:`css`,cat:`config`},{value:`cxx`,cat:`code`},{value:`dart`,cat:`code`},{value:`env`,cat:`config`},{value:`erb`,cat:`code`},{value:`erl`,cat:`code`},{value:`ex`,cat:`code`},{value:`exs`,cat:`code`},{value:`fish`,cat:`code`},{value:`fs`,cat:`code`},{value:`fsx`,cat:`code`},{value:`go`,cat:`code`},{value:`gql`,cat:`code`},{value:`gradle`,cat:`code`},{value:`graphql`,cat:`code`},{value:`groovy`,cat:`code`},{value:`h`,cat:`code`},{value:`hcl`,cat:`config`},{value:`hpp`,cat:`code`},{value:`hs`,cat:`code`},{value:`html`,cat:`config`},{value:`ini`,cat:`config`},{value:`java`,cat:`code`},{value:`jl`,cat:`code`},{value:`js`,cat:`code`},{value:`json`,cat:`config`},{value:`jsx`,cat:`code`,jsx:!0},{value:`kt`,cat:`code`},{value:`less`,cat:`config`},{value:`lua`,cat:`code`},{value:`m`,cat:`code`},{value:`md`,cat:`prose`,def:!0},{value:`mdx`,cat:`prose`},{value:`mjs`,cat:`code`},{value:`mk`,cat:`code`},{value:`ml`,cat:`code`},{value:`mli`,cat:`code`},{value:`mm`,cat:`code`},{value:`nim`,cat:`code`},{value:`php`,cat:`code`},{value:`pl`,cat:`code`},{value:`prisma`,cat:`code`},{value:`properties`,cat:`config`},{value:`proto`,cat:`code`},{value:`ps1`,cat:`code`},{value:`py`,cat:`code`},{value:`r`,cat:`code`},{value:`razor`,cat:`code`},{value:`rb`,cat:`code`},{value:`rs`,cat:`code`},{value:`rst`,cat:`prose`},{value:`s`,cat:`code`},{value:`scala`,cat:`code`},{value:`scss`,cat:`config`},{value:`sh`,cat:`code`},{value:`sol`,cat:`code`},{value:`sql`,cat:`code`},{value:`styl`,cat:`config`},{value:`svelte`,cat:`code`},{value:`swift`,cat:`code`},{value:`tex`,cat:`prose`},{value:`tf`,cat:`config`},{value:`tfvars`,cat:`config`},{value:`thrift`,cat:`code`},{value:`toml`,cat:`config`},{value:`ts`,cat:`code`},{value:`tsx`,cat:`code`,jsx:!0},{value:`txt`,cat:`prose`},{value:`v`,cat:`code`},{value:`vb`,cat:`code`},{value:`vue`,cat:`code`},{value:`xml`,cat:`config`},{value:`yaml`,cat:`config`},{value:`yml`,cat:`config`},{value:`zig`,cat:`code`},{value:`zsh`,cat:`code`}],c=new Set(s.filter(e=>e.cat===`prose`).map(e=>e.value)),l=new Set(s.filter(e=>e.cat===`code`).map(e=>e.value)),u=new Set(s.filter(e=>e.cat===`config`).map(e=>e.value)),d=new Set(s.filter(e=>e.jsx).map(e=>e.value));function f(e,t){let n=[];if(c.has(t)){let t=e.replace(/^\s*(import|export\s+\{[^}]*\}|export\s+\*|package|require|#include|from\s+['"][^'"]+['"]\s*(import)?)\b.*/gm,``).replace(/```[\s\S]*?```/g,` `).replace(/`[^`\n]+`/g,` `).replace(/!\[[^\]]*\]\([^)]*\)/g,` `).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/https?:\/\/\S+/g,` `).replace(/[#*_~>`|!\[\](){}=+\-]/g,` `);n.push(...o(t))}else l.has(t)?(d.has(t)&&(e=e.replace(/<\/?[A-Z][A-Za-z0-9.]*[^>]*>/g,` `),e=e.replace(/<\/?(div|span|main|section|article|aside|nav|header|footer|form|input|button|select|option|textarea|table|thead|tbody|tr|td|th|ul|ol|li|a|img|p|h[1-6]|label|figure|figcaption|picture|video|audio|canvas|svg|path|circle|rect|g|defs|use|link|meta|head|html|body|script|style|br|hr|strong|em|code|pre|blockquote|small|sub|sup)\b[^>]*>/gi,` `),e=e.replace(/\b(className|onClick|onChange|onSubmit|onFocus|onBlur|onKeyDown|onKeyUp|onMouseDown|onMouseUp|htmlFor|tabIndex|strokeWidth|viewBox|fillOpacity|strokeOpacity|defaultValue|placeholder|disabled|checked|readOnly|required|multiple|autoFocus|autoComplete|type|href|src|alt|width|height|style|key|ref)\s*=/g,` =`)),e=e.replace(/^\s*(import\s+[\w.*{},\s'"@/-]+;?|from\s+['"][^'"]+['"]\s*;?|package\s+[\w.]+;?|namespace\s+[\w.]+;?|using\s+[\w.]+;?|require\s*\(?\s*['"][^'"]+['"]\s*\)?;?)\s*$/gm,``),e.replace(/(?:\/\/|#(?!.*[{}[\]<>])| -- )\s*(.+)$/gm,(e,t)=>(n.push(...o(t)),e)),e.replace(/\/\*[\s\S]*?\*\//g,e=>(n.push(...o(e)),e)),e.replace(/"""[\s\S]*?"""|'''[\s\S]*?'''/g,e=>(n.push(...o(e)),e)),e.replace(/["'`]([A-Za-zÀ-ÿ][A-Za-zÀ-ÿ\s,.'éàèùâêîôûç]{3,})["'`]/g,(e,t)=>(n.push(...o(t)),e)),e.replace(/\b([A-Za-z][A-Za-z0-9_]{2,})\b/g,(e,t)=>(n.push(...a(t)),e))):u.has(t)&&(e.replace(/:\s*["']([^"']{3,})["']/g,(e,t)=>(n.push(...o(t)),e)),e.replace(/\b([A-Za-z][A-Za-z0-9_]{2,})\b/g,(e,t)=>(n.push(...a(t)),e)));return n.filter(e=>!i(e))}let p=P(``),m=P(``),h=P(1),g=P(``),_=P(!0),v=P(!1),y=P(I(s.map(e=>({value:e.value,label:`.`+e.value,checked:!!e.def}))));function b(){return V(y).filter(e=>e.checked).map(e=>e.value)}let x=N(()=>V(y).every(e=>e.checked)),S=P(null),C=P(null),w=P(0),T=P(null),E=P(I([])),D=P(I([])),ee=P(!1),te=P(``),O=P(0),ne=P(I([]));function re(){localStorage.setItem(`wc-exts`,JSON.stringify(b()))}function k(){let e=V(x);F(y,V(y).map(t=>({...t,checked:!e})),!0),re()}function ie(){re()}function ae(){return new Set((V(m)||``).split(/[\n,]/).map(e=>e.trim()).filter(Boolean))}function oe(e){let t=ae();t.has(e)||(t.add(e),F(m,[...t].join(`, `),!0),localStorage.setItem(`wc-exclude`,V(m)),V(de)&&ve(V(pe)),ce())}function se(){localStorage.setItem(`wc-exclude`,V(m)),V(de)&&ve(V(pe)),ce()}function ce(){V(ee)&&V(te)&&Ne(V(te))}function le(){V(S)&&Me()}function ue(){let e=localStorage.getItem(`wc-root`);e&&(F(p,e,!0),F(Se,e,!0));let t=localStorage.getItem(`wc-exclude`);t&&F(m,t,!0);let n=localStorage.getItem(`wc-exts`);if(n)try{let e=JSON.parse(n);F(y,V(y).map(t=>({...t,checked:e.includes(t.value)})),!0)}catch{}}let de=P(!1),fe=P(null),pe=P(``),me=P(``),he=P(null),ge=P(``);function _e(){F(de,!V(de)),V(de)&&ve(V(pe)||V(p)||`/`)}async function ve(e){F(he,null),F(ge,`Loading…`);try{let t=await fetch(`/api/browse?all=1&path=`+encodeURIComponent(e)).then(e=>e.json());F(pe,t.current,!0),F(fe,t.parent,!0),F(me,t.current,!0);let n=V(p).trim(),r=(e,t)=>n&&e.startsWith(n+`/`)?e.slice(n.length+1):t,i=ae(),a=(t.dirs||[]).filter(e=>!i.has(r(e.path,e.name))).map(e=>({kind:`dir`,name:e.name,path:e.path,entry:r(e.path,e.name)})),o=b(),s=(t.files||[]).filter(e=>o.some(t=>e.name.endsWith(`.`+t))).filter(e=>!i.has(r(e.path,e.name))).map(e=>({kind:`file`,name:e.name,entry:r(e.path,e.name)})),c=[...a,...s];F(he,c,!0),F(ge,c.length?``:`Empty directory`,!0)}catch{F(he,[],!0),F(ge,`Cannot read directory`)}}function ye(){V(fe)&&ve(V(fe))}let be=P(!1),xe=P(null),Se=P(``),Ce=P(``),A=P(null),we=P(``);function Te(){F(be,!V(be)),V(be)&&Ee(V(Se)||V(p)||`/`)}async function Ee(e){F(A,null),F(we,`Loading…`);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(Se,t.current,!0),F(xe,t.parent,!0),F(Ce,t.current,!0),F(A,(t.dirs||[]).map(e=>({name:e.name,path:e.path})),!0),F(we,V(A).length?``:`No sub-folders`,!0)}catch{F(A,[],!0),F(we,`Cannot read directory`)}}function De(){V(xe)&&Ee(V(xe))}function Oe(){F(p,V(Se),!0),localStorage.setItem(`wc-root`,V(Se)),F(be,!1),F(m,``),localStorage.removeItem(`wc-exclude`),F(pe,V(Se),!0)}let ke=P(null),Ae=P(null),je=P(!1);function Me(){if(!V(S)||!V(C))return;let e=Math.max(1,V(h)||1),t=[...V(S).entries()].sort((e,t)=>t[1]-e[1]),n=t.filter(([t])=>(V(C).get(t)||new Set).size>=e).slice(0,150);if(!n.length){let n=t.length;F(g,n?`${n} domain word(s) found but none appear in ${e}+ file(s). Lower the "Min files" threshold to 1.`:`No domain words extracted. Try adding more file extensions or a broader folder.`,!0),F(_,!0),F(je,!1),F(v,!1);return}let r=[...V(S).keys()].filter(t=>(V(C).get(t)||new Set).size>=e).length;F(T,{scanned:V(w),unique:r,shown:n.length},!0);let i=n.slice(0,50),a=i[0][1];F(D,i.map(([e,t])=>({word:e,freq:t,pct:Math.round(t/a*100)})),!0),F(v,!0),F(_,!1);let o=document.documentElement.classList.contains(`dark`),s=o?[`#60a5fa`,`#34d399`,`#f9a8d4`,`#a78bfa`,`#fbbf24`,`#6ee7b7`,`#93c5fd`,`#fb923c`,`#4ade80`,`#f472b6`]:[`#1d4ed8`,`#047857`,`#7c3aed`,`#b45309`,`#be123c`,`#0369a1`,`#4338ca`,`#c2410c`,`#15803d`,`#9333ea`];requestAnimationFrame(()=>{if(!V(ke)||!V(Ae))return;let e=V(ke),t=V(Ae);e.width=Math.max(400,t.offsetWidth),e.height=Math.max(300,t.offsetHeight),e.style.width=e.width+`px`,e.style.height=e.height+`px`,F(je,!0);let n=Math.sqrt(e.width*e.height/(800*500)),r=Math.min(220,Math.round(72*n)),c=i.map(([e,t])=>[e,Math.max(12,Math.round(r*t/a))]);window.WordCloud?.(e,{list:c,gridSize:Math.round(4*e.width/1024),fontFamily:`ui-sans-serif, system-ui, sans-serif`,color:()=>s[Math.floor(Math.random()*s.length)],backgroundColor:o?`#030712`:`#ffffff`,rotateRatio:.2,minSize:6,shrinkToFit:!0,click:e=>Ne(e[0])})})}function Ne(e){if(!V(C)||!V(S))return;let t=[...V(C).get(e)||[]].sort(),n=V(S).get(e)||0;F(te,e,!0),F(O,n,!0),F(ne,t,!0),F(ee,!0)}function Pe(){F(ee,!1)}async function Fe(){let e=V(p).trim();if(!e){F(g,`Please select a root folder first.`),F(_,!0);return}let t=b();if(!t.length){F(g,`Please select at least one extension.`),F(_,!0);return}F(be,!1),F(v,!1),F(ee,!1),F(g,`Reading files…`),F(_,!0),F(je,!1);try{let n=V(m).trim(),r=n?n.split(/[\n,]/).map(e=>e.trim()).filter(Boolean):[];localStorage.setItem(`wc-exclude`,n);let i=new URLSearchParams({path:e});t.forEach(e=>i.append(`ext`,e)),r.forEach(e=>i.append(`exclude`,e));let a=await fetch(`/api/wordcloud?`+i);if(!a.ok){F(g,`Error: `+((await a.json()).error||a.statusText));return}let{files:o,fileTexts:s}=await a.json();F(g,`Analyzing ${o} file(s)…`);let c=new Map,l=new Map,u=new Set;F(w,o,!0);for(let{path:e,text:t}of s){let n=(e.split(`.`).pop()||``).toLowerCase();n&&u.add(n);let r=f(t,n),i=new Set;for(let t of r)c.set(t,(c.get(t)||0)+1),i.has(t)||(i.add(t),l.has(t)||l.set(t,new Set),l.get(t).add(e))}F(S,c,!0),F(C,l,!0),F(E,[...u].sort().map(e=>`.`+e),!0),Me()}catch(e){F(g,`Error: `+e.message)}}let Ie=!1;kn(()=>{t.open&&!Ie?(Ie=!0,F(g,`Choose a root folder and click Launch.`),F(_,!0),F(je,!1),F(v,!1),F(ee,!1),F(S,null),F(C,null),F(T,null),F(D,[],!0),F(be,!1),F(de,!1),F(h,1),ue(),V(p)||fetch(`/api/config`).then(e=>e.json()).then(e=>{e.docsFolder&&(F(p,e.docsFolder,!0),F(Se,e.docsFolder,!0))}).catch(()=>{})):t.open||(Ie=!1)});var Le=Wr(),Re=R(Le),ze=e=>{var n=ow(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=L(c),u=L(l),d=L(u,!0);j(u);var f=z(u,2);Di(f);var b=z(f,2),S=z(L(b)),C=L(S,!0);j(S),j(b);var w=z(b,2),re=L(w,!0);j(w),j(l);var ae=z(l,2),ce=L(ae),ue=L(ce,!0);j(ce);var pe=z(ce,2);yn(pe);var Se=z(pe,2),Me=z(L(Se)),Ie=L(Me,!0);j(Me),j(Se),j(ae);var Le=z(ae,2),Re=e=>{var t=qC(),n=L(t),r=L(n),i=z(r,2),a=L(i,!0);j(i),j(n);var o=z(n,2),s=L(o),c=e=>{var t=UC(),n=L(t,!0);j(t),B(()=>G(n,V(ge))),W(e,t)},l=e=>{var t=WC(),n=L(t,!0);j(t),B(()=>{gi(t,1,`px-3 py-3 text-xs ${V(ge)===`Cannot read directory`?`text-red-400`:`text-gray-400`} text-center`),G(n,V(ge))}),W(e,t)},u=e=>{var t=Wr();q(R(t),17,()=>V(he),Xr,(e,t)=>{var n=Wr(),r=R(n),i=e=>{var n=GC(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(n),B(()=>G(a,V(t).name)),H(`click`,r,()=>ve(V(t).path)),H(`click`,o,()=>oe(V(t).entry)),W(e,n)},a=e=>{var n=KC(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(n),B(()=>G(a,V(t).name)),H(`click`,o,()=>oe(V(t).entry)),W(e,n)};K(r,e=>{V(t).kind===`dir`?e(i):e(a,-1)}),W(e,n)}),W(e,t)};K(s,e=>{V(he)===null?e(c):V(he).length===0?e(l,1):e(u,-1)}),j(o),j(t),B(()=>{r.disabled=!V(fe),G(a,V(me))}),H(`click`,r,ye),W(e,t)};K(Le,e=>{V(de)&&e(Re)});var ze=z(Le,2),Be=L(ze),Ve=L(Be,!0);j(Be);var He=z(Be,2),Ue=L(He);Di(Ue);var We=z(Ue);j(He),q(z(He,2),17,()=>V(y),e=>e.value,(e,t,n)=>{var r=JC(),i=L(r);Di(i);var a=z(i);j(r),B(()=>G(a,` ${V(t).label??``}`)),H(`change`,i,ie),Ii(i,()=>V(t).checked,e=>V(t).checked=e),W(e,r)}),j(ze);var Ge=z(ze,2),Ke=e=>{var t=qC(),n=L(t),r=L(n),i=z(r,2),a=L(i,!0);j(i),j(n);var o=z(n,2),s=L(o),c=e=>{var t=UC(),n=L(t,!0);j(t),B(()=>G(n,V(we))),W(e,t)},l=e=>{var t=ZC(),n=R(t),r=e=>{var t=WC(),n=L(t,!0);j(t),B(()=>{gi(t,1,`px-3 py-3 text-xs ${V(we)===`Cannot read directory`?`text-red-400`:`text-gray-400`} text-center`),G(n,V(we))}),W(e,t)},i=e=>{var t=Wr();q(R(t),17,()=>V(A),Xr,(e,t)=>{var n=YC(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(n),B(()=>G(a,V(t).name)),H(`click`,r,()=>Ee(V(t).path)),H(`click`,o,()=>oe(V(t).name)),W(e,n)}),W(e,t)};K(n,e=>{V(A).length===0?e(r):e(i,-1)});var a=z(n,2),o=e=>{var t=XC(),n=z(L(t)),r=L(n,!0);j(n),j(t),B(()=>G(r,V(Ce))),H(`click`,t,Oe),W(e,t)};K(a,e=>{V(we)!==`Cannot read directory`&&e(o)}),W(e,t)};K(s,e=>{V(A)===null?e(c):e(l,-1)}),j(o),j(t),B(()=>{r.disabled=!V(xe),G(a,V(Ce))}),H(`click`,r,De),W(e,t)};K(Ge,e=>{V(be)&&e(Ke)}),j(c);var qe=z(c,2),Je=L(qe),Ye=e=>{var t=tw(),n=L(t),r=L(n),i=e=>{var t=$C(),n=R(t),r=L(n);j(n);var i=z(n,2),a=L(i);j(i);var o=z(i,2),s=L(o);j(o);var c=z(o,2),l=e=>{var t=QC(),n=L(t);j(t),B((e,r)=>{J(t,`title`,e),G(n,`${V(E).length??``} extension${V(E).length>1?`s`:``} found (${r??``})`)},[()=>V(E).join(`, `),()=>V(E).join(`, `)]),W(e,t)};K(c,e=>{V(E).length&&e(l)}),B(()=>{G(r,`${V(T).scanned??``} file(s) scanned`),G(a,`${V(T).unique??``} unique domain words`),G(s,`${V(T).shown??``} shown`)}),W(e,t)};K(r,e=>{V(T)&&e(i)}),j(n);var a=z(n,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2);Di(c);var l=z(c,2),u=L(l,!0);j(l),j(a);var d=z(a,2),f=L(d,!0);j(d);var p=z(d,2);q(p,21,()=>V(D),Xr,(e,t,n)=>{var r=ew(),i=L(r);i.textContent=n+1;var a=z(i,2),o=L(a),s=L(o),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(o);var d=z(o,2),f=L(d);j(d),j(a),j(r),B(()=>{G(c,V(t).word),G(u,V(t).freq),vi(f,`width:${V(t).pct??``}%`)}),H(`click`,r,()=>Ne(V(t).word)),W(e,r)}),j(p),j(t),B((e,t,n,r,i,a)=>{J(o,`title`,e),G(s,t),J(c,`title`,n),J(l,`title`,r),G(u,i),G(f,a)},[()=>Y(`wc.min_files_hint`),()=>Y(`wc.min_files_label`),()=>Y(`wc.min_files_hint`),()=>Y(`wc.apply_hint`),()=>Y(`wc.apply_btn`),()=>Y(`wc.top_words`)]),Ni(c,()=>V(h),e=>F(h,e)),H(`click`,l,le),W(e,t)};K(Je,e=>{V(v)&&e(Ye)});var Xe=z(Je,2),Ze=L(Xe),Qe=e=>{var t=nw(),n=L(t,!0);j(t),B(()=>G(n,V(g))),W(e,t)};K(Ze,e=>{V(_)&&e(Qe)});var $e=z(Ze,2);let et;Vi($e,e=>F(ke,e),()=>V(ke)),j(Xe),Vi(Xe,e=>F(Ae,e),()=>V(Ae));var tt=z(Xe,2),nt=e=>{var t=aw(),n=L(t),r=L(n),i=L(r);j(r);var a=z(r,2);j(n);var o=z(n,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c),u=e=>{var t=Wr();q(R(t),17,()=>V(ne),Xr,(e,t)=>{var n=rw(),r=L(n),i=L(r,!0);j(r);var a=z(r,2);j(n),B(()=>G(i,V(t))),H(`click`,a,()=>oe(V(t))),W(e,n)}),W(e,t)},d=e=>{W(e,iw())};K(l,e=>{V(ne).length?e(u):e(d,-1)}),j(c),j(t),B(e=>{G(i,`${V(te)??``} ×${V(O)??``}`),G(s,e)},[()=>Y(`wc.found_in`)]),H(`click`,a,Pe),W(e,t)};K(tt,e=>{V(ee)&&e(nt)}),j(qe),j(n),B((e,t,n,r,i,o,c,l,u,f)=>{G(a,e),G(s,t),G(d,n),G(C,r),G(re,i),G(ue,o),J(pe,`placeholder`,c),G(Ie,l),G(Ve,u),ki(Ue,V(x)),G(We,` ${f??``}`),et=gi($e,1,``,null,et,{hidden:!V(je)})},[()=>Y(`wc.title`),()=>Y(`wc.close_btn`),()=>Y(`wc.search_root_label`),()=>Y(`wc.browse_btn`),()=>Y(`wc.launch_btn`),()=>Y(`wc.exclude_label`),()=>Y(`wc.exclude_placeholder`),()=>Y(`wc.browse_btn`),()=>Y(`wc.extensions_label`),()=>Y(`wc.all_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),Ni(f,()=>V(p),e=>F(p,e)),H(`click`,b,Te),H(`click`,w,Fe),H(`input`,pe,se),Ni(pe,()=>V(m),e=>F(m,e)),H(`click`,Se,_e),H(`change`,Ue,k),W(e,n)};K(Re,e=>{t.open&&e(ze)}),W(e,Le),Je()}Pr([`click`,`input`,`change`]);var cw=U(`<button title="Toggle dark mode" class="ghost-button" aria-label="Toggle dark mode"> </button>`),lw=U(`<button class="ghost-button"><i class="fa-solid fa-cloud"></i></button> <!>`,1),uw=U(`<div class="relative hidden sm:block"><input type="search" class="w-56 pl-8 pr-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"/> <span class="absolute left-2.5 top-2 text-gray-400 text-sm pointer-events-none">🔍</span></div>`),dw=U(`<p class="p-8 text-red-500"> </p>`),fw=U(`<div class="h-full flex items-center justify-center p-8"><div class="max-w-md text-center"><div class="text-5xl mb-4 select-none" aria-hidden="true">📚</div> <h2 class="text-xl font-semibold text-gray-700 dark:text-gray-300 mb-2"> </h2> <p class="text-sm text-gray-500 dark:text-gray-500"> </p> <p class="mt-4 text-xs text-gray-400 dark:text-gray-600 font-mono bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 inline-block"> </p> <p class="mt-2 text-xs text-gray-400"> </p></div></div>`),pw=U(`<div class="app-shell bg-gray-50 text-gray-900 dark:bg-gray-900 dark:text-gray-100"><!> <div class="flex overflow-hidden"><!> <main id="home-content-area" class="flex-1 overflow-y-auto"><!></main></div></div> <!> <!> <!> <!>`,1);function mw(e,t){qe(t,!0);let n=P(!1),r=P(!1),i=P(!1),a=P(!1),o=P(null),s=P(!1),c=P(``),l=P(!1),u=P(!1),d=P(`Living AI Documentation`),f=P(`YYYY_MM_DD_HH_mm_[Category]_title.md`),p=null;function m(){try{let e=localStorage.getItem(`ld-dark`);if(e!==null)return e===`true`}catch{}return window.matchMedia(`(prefers-color-scheme: dark)`).matches}function h(e){fo()&&(e=!1),F(l,e,!0),document.documentElement.classList.toggle(`dark`,e)}function g(){h(!V(l));try{localStorage.setItem(`ld-dark`,String(V(l)))}catch{}}kn(()=>{let e=document.getElementById(`hljs-dark`),t=document.getElementById(`hljs-light`);if(!e||!t)return;let n=X.codeBlockLightTheme&&!V(l);e.disabled=n,t.disabled=!n,document.body.classList.toggle(`ld-code-light`,n)});function _(e){let t=e.trim();if(p&&clearTimeout(p),!t){X.searchQuery=``,X.searchResults=null;return}X.searchQuery=t,X.searchResults=X.allDocs.filter(e=>e.title.toLowerCase().includes(t.toLowerCase())||e.category.toLowerCase().includes(t.toLowerCase())),p=window.setTimeout(async()=>{try{let e=await Hg(t);t===X.searchQuery&&(X.searchResults=e)}catch{}},350)}let v=P(I([]));function y(e){let t=V(v)[e];t&&(F(v,V(v).slice(0,e),!0),b(t.id,!1,`restore`))}async function b(e,t=!1,n=!1,r=null){if(n===!0&&X.currentDocId&&X.currentDocId!==e){let t=V(v).findIndex(t=>t.id===e);if(t!==-1)F(v,V(v).slice(0,t),!0);else{let e=X.allDocs.find(e=>e.id===X.currentDocId);F(v,[...V(v),{id:X.currentDocId,title:e?e.title:X.currentDocId}],!0)}}else n||F(v,[],!0);X.currentDocId=e;let i=X.allDocs.find(t=>t.id===e);if(i&&X.revealDoc(i),!t){let t=new URL(location.href);t.searchParams.set(`doc`,e),t.hash=r?`#${r}`:``,history.pushState({docId:e,anchor:r||null},``,t)}F(s,!0),F(c,``);try{let t=await Rg(e);t.id=e,F(o,t,!0),document.title=t.title,requestAnimationFrame(()=>{let e=document.getElementById(`home-content-area`);if(r){let t=document.getElementById(r);t&&e&&(e.scrollTop+=t.getBoundingClientRect().top-e.getBoundingClientRect().top-80)}else e&&(e.scrollTop=0)})}catch(e){F(c,Y(`doc.failed_to_load`)+(e instanceof Error?e.message:String(e)))}finally{F(s,!1)}}async function x(e){if(!V(o))return;let t=V(o).id,n=await fetch(`/api/documents/`+t,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:e})});if(!n.ok)throw Error(await n.text());let r=await Rg(t);r.id=t,F(o,r,!0);let i=e.match(/\]\(\s*\.?\/files\/[^)\s]+/g),a={...X.fileAttachmentCounts};i&&i.length?a[t]=i.length:delete a[t],X.fileAttachmentCounts=a}function S(e){let t=X.allDocs.find(t=>t.id===e);if(!t)return null;let n=(t.folder||[]).join(`/`),r=e=>(e.folder||[]).join(`/`)===n,i=X.hideCategories?X.allDocs.filter(r).slice().sort((e,t)=>(e.filename||``).localeCompare(t.filename||``)):X.allDocs.filter(e=>r(e)&&e.category===t.category),a=i.findIndex(t=>t.id===e);if(a===-1)return null;let o=i[a+1]??i[a-1];return o?o.id:null}async function C(){if(!V(o))return;let e=V(o).id;if(!(await fetch(`/api/documents/`+encodeURIComponent(e),{method:`DELETE`})).ok)return;let t=S(e);X.allDocs=X.allDocs.filter(t=>t.id!==e),Array.isArray(X.searchResults)&&(X.searchResults=X.searchResults.filter(t=>t.id!==e));let n={...X.annotationCounts};delete n[e],X.annotationCounts=n;let r={...X.fileAttachmentCounts};delete r[e],X.fileAttachmentCounts=r,t?await b(t):(X.currentDocId=null,F(o,null),history.pushState({},``,location.pathname))}async function w(){let[e,t]=await Promise.all([Ig(),Fg()]);if(X.allDocs=e,X.docsFolder=typeof t.docsFolder==`string`?t.docsFolder:``,t.docsFolder)try{X.allFolderPaths=await Lg(t.docsFolder)}catch{X.allFolderPaths=[]}let[n,r,i]=await Promise.all([zg(),Bg(),Vg()]);X.annotationCounts=n,X.fileAttachmentCounts=r,X.docStatuses=i}Gi(async()=>{F(u,fo(),!0),h(m());let e=await Fg();await ha(e.language||`en`),e.title&&(document.title=e.title,F(d,e.title,!0)),e.filenamePattern&&F(f,e.filenamePattern+`.md`),X.exclusiveFolderExpansion=!!e.exclusiveFolderExpansion,X.exclusiveCategoryExpansion=!!e.exclusiveCategoryExpansion,X.codeBlockMaxHeight=typeof e.codeBlockMaxHeight==`number`?e.codeBlockMaxHeight:400,X.imageRoundedCorners=!!e.imageRoundedCorners,X.imageCentered=!!e.imageCentered,X.imageBorder=!!e.imageBorder,X.codeBlockLightTheme=!!e.codeBlockLightTheme,X.sidebarSort=[`recent`,`oldest`,`alphabetical`].includes(e.sidebarSort)?e.sidebarSort:`recent`,X.codeBlockMaxHeight>0&&document.documentElement.style.setProperty(`--ld-code-max-h`,X.codeBlockMaxHeight+`px`),X.expandedCategories.size===0&&(X.expandedCategories=new Set([`DOCUMENTATION`,`General`])),await w();let t=new URLSearchParams(location.search).get(`doc`);if(t)b(t,!0,!1,location.hash?location.hash.slice(1):null);else{let t=Array.isArray(e.favorites)?e.favorites:[],n=t.length?t[0]?.id:void 0,r=(n?X.allDocs.find(e=>e.id===n):void 0)??X.allDocs.find(e=>e.category===`DOCUMENTATION`)??X.allDocs.find(e=>e.category===`General`)??X.allDocs[0];r&&b(r.id,!0)}let n=e=>{let t=e.state?.docId||new URLSearchParams(location.search).get(`doc`),n=e.state?.anchor||(location.hash.length>1?location.hash.slice(1):null);t&&b(t,!0,!1,n)};window.addEventListener(`popstate`,n);let r=()=>{w()};return window.addEventListener(`ld:documents-changed`,r),()=>{window.removeEventListener(`popstate`,n),window.removeEventListener(`ld:documents-changed`,r)}});var T=pw(),E=R(T),D=L(E);so(D,{get title(){return V(d)},subtitle:``,actions:e=>{var t=lw(),n=R(t),r=z(n,2),i=e=>{var t=cw(),n=L(t,!0);j(t),B(()=>G(n,V(l)?`☀`:`☾`)),H(`click`,t,g),W(e,t)};K(r,e=>{V(u)||e(i)}),B((e,t)=>{J(n,`title`,e),J(n,`aria-label`,t)},[()=>Y(`nav.word_cloud`),()=>Y(`nav.word_cloud`)]),H(`click`,n,()=>F(a,!0)),W(e,t)},children:(e,t)=>{var n=uw(),r=L(n);Di(r),Ie(2),j(n),B(e=>{J(r,`placeholder`,e),Oi(r,X.searchQuery)},[()=>Y(`nav.search_placeholder`)]),H(`input`,r,e=>_(e.target.value)),W(e,n)},$$slots:{actions:!0,default:!0}});var ee=z(D,2),te=L(ee);__(te,{onopen:e=>b(e),onsearch:_,onexport:()=>F(i,!0),onnewfolder:()=>F(n,!0),onnewdoc:()=>F(r,!0)});var O=z(te,2),ne=L(O),re=e=>{var t=Wr(),n=R(t),r=e=>{var t=dw(),n=L(t,!0);j(t),B(()=>G(n,V(c))),W(e,t)},i=e=>{_C(e,{get doc(){return V(o)},get navHistory(){return V(v)},ongoback:y,onopen:(e,t)=>b(e,!1,!0,t),onsave:x,ondelete:C})};K(n,e=>{V(c)?e(r):e(i,-1)}),W(e,t)},k=e=>{var t=fw(),n=L(t),r=z(L(n),2),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var s=z(a,2),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(n),j(t),B((e,t,n)=>{G(i,e),G(o,t),G(c,V(f)),G(u,n)},[()=>Y(`welcome.title`),()=>Y(`welcome.hint`),()=>Y(`welcome.pattern_hint`)]),W(e,t)};K(ne,e=>{V(o)?e(re):e(k,-1)}),j(O),j(ee),j(E);var ie=z(E,2);TC(ie,{get open(){return V(n)},onclose:()=>F(n,!1),onsuccess:w});var ae=z(ie,2);PC(ae,{get open(){return V(r)},onclose:()=>F(r,!1),onsuccess:async e=>{await w(),b(e)}});var oe=z(ae,2);HC(oe,{get open(){return V(i)},onclose:()=>F(i,!1)}),sw(z(oe,2),{get open(){return V(a)},onclose:()=>F(a,!1)}),W(e,T),Je()}Pr([`click`,`input`]);var hw=`modulepreload`,gw=function(e){return`/`+e},_w={},vw=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,new URL(`../../../src/node/plugins/importAnalysisBuild.ts`,import.meta.url)).href}r=o(t.map(t=>{if(t=gw(t,n),t=s(t),t in _w)return;_w[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:hw,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},yw=U(`<div class="flex flex-col h-screen overflow-hidden bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100"><header class="flex items-center gap-1 px-2 h-12 shrink-0 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-sm z-10"><button class="tool-btn !w-auto px-2 text-xs font-medium text-gray-500 dark:text-gray-400"> </button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnSidebar" class="tool-btn">☰</button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnCopyDiagramId" class="tool-btn"><svg width="15" height="15" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="5" width="8" height="9" rx="1.5"></rect><path d="M3 11V3a1 1 0 0 1 1-1h7"></path></svg></button> <button id="toolSelect" class="tool-btn tool-active"><svg width="11" height="13" viewBox="0 0 11 13" fill="currentColor" stroke="none"><path d="M1 1 L1 12 L4 9 L6.5 13 L8 12.2 L5.5 8.2 L10 8.2 Z"></path></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="toolBox" class="tool-btn"><svg width="15" height="10" viewBox="0 0 15 10" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1" y="1" width="13" height="8" rx="1"></rect></svg></button> <button id="toolEllipse" class="tool-btn"><svg width="16" height="10" viewBox="0 0 16 10" fill="none" stroke="currentColor" stroke-width="1.5"><ellipse cx="8" cy="5" rx="7" ry="4"></ellipse></svg></button> <button id="toolDatabase" class="tool-btn"><svg width="12" height="16" viewBox="0 0 12 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><ellipse cx="6" cy="3" rx="5" ry="2"></ellipse><path d="M1 3v10c0 1.1 2.2 2 5 2s5-.9 5-2V3"></path><path d="M11 7.5c0 1.1-2.2 2-5 2s-5-.9-5-2"></path></svg></button> <button id="toolCircle" class="tool-btn"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="6.5" cy="6.5" r="5.5"></circle></svg></button> <button id="toolActor" class="tool-btn"><svg width="12" height="17" viewBox="0 0 12 17" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="6" cy="3" r="2.2"></circle><line x1="6" y1="5.2" x2="6" y2="10"></line><line x1="1.5" y1="7.5" x2="10.5" y2="7.5"></line><line x1="6" y1="10" x2="2.5" y2="15"></line><line x1="6" y1="10" x2="9.5" y2="15"></line></svg></button> <button id="toolPostIt" class="tool-btn"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.4"><path d="M1 1 H9 L12 4 V12 H1 Z"></path><path d="M9 1 V4 H12" stroke-opacity="0.5"></path></svg></button> <button id="toolTextFree" class="tool-btn" style="font-size:11px; font-weight:600;">T</button> <button id="toolImage" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="1" width="12" height="12" rx="1.5"></rect><circle cx="4.5" cy="4.5" r="1.2"></circle><path d="M1 9.5 L4 6.5 L6.5 9 L9 7 L13 10.5"></path></svg></button> <a href="/shape-editor" class="tool-btn">✦</a> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="toolArrow" class="tool-btn">→</button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDelete" class="tool-btn"><svg width="11" height="11" viewBox="0 0 11 11" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="1" y1="1" x2="10" y2="10"></line><line x1="10" y1="1" x2="1" y2="10"></line></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDiagramDefaults" class="tool-btn"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"></path><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.474l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"></path></svg></button> <button id="btnAlign" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4"><line x1="0.5" y1="7.5" x2="13.5" y2="7.5"></line><line x1="3.5" y1="0.5" x2="3.5" y2="13.5" stroke-dasharray="1.5 1.5"></line><line x1="10.5" y1="0.5" x2="10.5" y2="13.5" stroke-dasharray="1.5 1.5"></line></svg></button> <button id="btnGrid" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.2"><line x1="5" y1="1" x2="5" y2="13"></line><line x1="9" y1="1" x2="9" y2="13"></line><line x1="1" y1="5" x2="13" y2="5"></line><line x1="1" y1="9" x2="13" y2="9"></line><rect x="1" y="1" width="12" height="12" rx="1"></rect></svg></button> <button id="btnEdgeStraight" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><line x1="2" y1="12" x2="12" y2="2"></line><polyline points="8,2 12,2 12,6"></polyline></svg></button> <button id="btnEvidenceMode" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M4 1.5 H8.5 L11 4 V12.5 H4 Z"></path><path d="M8.5 1.5 V4 H11"></path><path d="M1.5 5.5 H6.5"></path><path d="M1.5 8 H6.5"></path><path d="M1.5 10.5 H5"></path></svg></button> <button id="btnResizeMode" class="tool-btn active-tool"><svg id="icon-resize-corner" width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="1" width="12" height="12" stroke-dasharray="2.5 2"></rect><line x1="4" y1="4" x2="10" y2="10"></line><polyline points="7,10 10,10 10,7"></polyline></svg> <svg id="icon-resize-center" width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="hidden"><rect x="1" y="1" width="12" height="12" stroke-dasharray="2.5 2"></rect><line x1="4" y1="4" x2="10" y2="10"></line><polyline points="4,6.5 4,4 6.5,4"></polyline><polyline points="10,7.5 10,10 7.5,10"></polyline><line x1="10" y1="4" x2="4" y2="10"></line><polyline points="7.5,4 10,4 10,6.5"></polyline><polyline points="4,7.5 4,10 6.5,10"></polyline></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <input id="diagramTitle" type="text" class="flex-1 min-w-0 px-2 py-1 text-sm bg-transparent border-0 focus:outline-none focus:ring-1 focus:ring-blue-500 rounded text-gray-700 dark:text-gray-300 placeholder:text-gray-400"/> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnZoomOut" class="tool-btn">−</button> <span id="zoomLevel" class="text-xs text-gray-500 dark:text-gray-400 w-10 text-center tabular-nums select-none">100%</span> <button id="btnZoomIn" class="tool-btn">+</button> <button id="btnZoomReset" class="tool-btn">⊡</button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDark" class="tool-btn"><span id="darkIcon">☽</span></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDebug" class="hidden tool-btn text-xs font-mono">dbg</button> <div id="sepDebug" class="hidden w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnExportDrawio" class="tool-btn"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnSave" disabled="" class="px-3 py-1.5 text-xs font-semibold rounded-lg bg-blue-600 hover:bg-blue-700 text-white disabled:opacity-40 disabled:cursor-not-allowed shrink-0 transition-colors"><span> </span></button></header> <div class="flex flex-1 overflow-hidden"><div id="sidebar" class="w-56 shrink-0 border-r border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 flex flex-col overflow-hidden" style="transition: width 0.2s ease"><div class="flex items-center justify-between px-3 py-2 border-b border-gray-200 dark:border-gray-700 shrink-0"><span class="text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider"> </span> <button id="btnNewDiagram" class="text-xs font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors"> </button></div> <div id="diagramList" class="flex-1 overflow-y-auto py-1"></div></div> <div role="separator" aria-orientation="vertical"></div> <div class="relative flex-1 overflow-hidden bg-gray-50 dark:bg-gray-950"><div id="vis-canvas" class="w-full h-full"></div> <div id="customShapeBar" class="hidden"><div id="customShapeBarBody"></div></div> <div id="debugLayer"></div> <div id="evidenceLayer" class="hidden"></div> <div id="stampOverlay" style="position:absolute;inset:0;display:none;z-index:11;cursor:crosshair;"></div> <div id="selectionOverlay"><div id="rh-tl" class="resize-handle" style="top: -5px; left: -5px; cursor: nw-resize"></div> <div id="rh-tr" class="resize-handle" style="top: -5px; right: -5px; cursor: ne-resize"></div> <div id="rh-bl" class="resize-handle" style="bottom: -5px; left: -5px; cursor: sw-resize"></div> <div id="rh-br" class="resize-handle" style="bottom: -5px; right: -5px; cursor: se-resize"></div> <div id="rh-rotate">↻</div> <div id="rh-label-rotate" style="left: 0; top: -28px;"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><g transform="rotate(25,5,5)"><line x1="2.5" y1="3" x2="7.5" y2="3"></line><line x1="5" y1="3" x2="5" y2="8"></line></g></svg></div></div> <aside id="evidencePanel" class="hidden absolute top-0 right-0 bottom-0 w-80 max-w-[85vw] z-30 bg-gray-50 dark:bg-gray-900 border-l border-gray-200 dark:border-gray-700 shadow-xl flex flex-col"><div class="flex items-center justify-between gap-2 px-4 py-3 border-b border-gray-200 dark:border-gray-700"><h2 id="evidencePanelTitle" class="text-sm font-semibold text-gray-800 dark:text-gray-100"> </h2> <button id="btnEvidenceClose" class="tool-btn !w-7 !h-7">×</button></div> <div id="evidencePanelBody" class="flex-1 overflow-y-auto p-3 space-y-3"></div></aside> <div id="nodePanel" class="float-panel hidden"><button id="btnNodeLock" class="tool-btn !w-6 !h-6 text-sm">🔒</button> <div class="panel-sep"></div> <div id="nodePanelControls" class="contents"><button id="nodeColorSwatch" style="width:1.5rem;height:1.5rem;border-radius:0.25rem;border:2px solid #a8a29e;background:#f5f5f4;cursor:pointer;flex-shrink:0;"></button> <div class="panel-sep"></div> <input id="nodeBgOpacity" type="range" min="0" max="100" step="5" value="100" class="w-16 h-1 accent-orange-500 cursor-pointer"/> <div class="panel-sep"></div> <button id="btnNodeLabelEdit" class="tool-btn !w-6 !h-6">✎</button> <button id="btnNodeLink" class="tool-btn !w-6 !h-6"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7.5a3.5 3.5 0 0 0 5 0l1.5-1.5a3.5 3.5 0 0 0-5-5L5 2.5"></path><path d="M8 5.5a3.5 3.5 0 0 0-5 0L1.5 7a3.5 3.5 0 0 0 5 5L8 10.5"></path></svg></button> <div class="panel-sep"></div> <button id="btnNodeFontDecrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa−</button> <span id="nodeFontSizeValue" class="inline-flex items-center justify-center min-w-[2.25rem] h-6 px-1 text-[11px] font-mono text-gray-700 dark:text-gray-200 border border-gray-300 dark:border-gray-600 rounded bg-white/80 dark:bg-gray-800/80">13</span> <button id="btnNodeFontIncrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa+</button> <div class="panel-sep"></div> <button id="btnAlignLeft" class="tool-btn !w-6 !h-6"><svg width="12" height="10" viewBox="0 0 12 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><line x1="1" y1="2" x2="11" y2="2"></line><line x1="1" y1="5" x2="7" y2="5"></line><line x1="1" y1="8" x2="9" y2="8"></line></svg></button> <button id="btnAlignCenter" class="tool-btn !w-6 !h-6"><svg width="12" height="10" viewBox="0 0 12 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><line x1="1" y1="2" x2="11" y2="2"></line><line x1="2.5" y1="5" x2="9.5" y2="5"></line><line x1="1.5" y1="8" x2="10.5" y2="8"></line></svg></button> <button id="btnAlignRight" class="tool-btn !w-6 !h-6"><svg width="12" height="10" viewBox="0 0 12 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><line x1="1" y1="2" x2="11" y2="2"></line><line x1="5" y1="5" x2="11" y2="5"></line><line x1="3" y1="8" x2="11" y2="8"></line></svg></button> <div class="panel-sep"></div> <button id="btnValignTop" class="tool-btn !w-6 !h-6"><svg width="10" height="12" viewBox="0 0 10 12" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="1" y1="1.5" x2="9" y2="1.5" stroke-width="2"></line><line x1="1" y1="5" x2="8" y2="5" stroke-width="1.3"></line><line x1="1" y1="8.5" x2="6" y2="8.5" stroke-width="1.3"></line></svg></button> <button id="btnValignMiddle" class="tool-btn !w-6 !h-6"><svg width="10" height="12" viewBox="0 0 10 12" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="1" y1="2.5" x2="8" y2="2.5" stroke-width="1.3"></line><line x1="1" y1="6" x2="9" y2="6" stroke-width="2"></line><line x1="1" y1="9.5" x2="6" y2="9.5" stroke-width="1.3"></line></svg></button> <button id="btnValignBottom" class="tool-btn !w-6 !h-6"><svg width="10" height="12" viewBox="0 0 10 12" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="1" y1="3.5" x2="8" y2="3.5" stroke-width="1.3"></line><line x1="1" y1="7" x2="6" y2="7" stroke-width="1.3"></line><line x1="1" y1="10.5" x2="9" y2="10.5" stroke-width="2"></line></svg></button> <div class="panel-sep"></div> <div id="customShapeLabelPlacementControls" class="hidden"><button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="above">T↑</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="below">T↓</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="left">←T</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="right">T→</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="center">T□</button> <div class="panel-sep"></div></div> <button id="btnZOrderBack" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="5" width="8" height="8" rx="1"></rect><rect x="5" y="1" width="8" height="8" rx="1" stroke-opacity="0.35"></rect></svg></button> <button id="btnZOrderFront" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="5" width="8" height="8" rx="1" stroke-opacity="0.35"></rect><rect x="5" y="1" width="8" height="8" rx="1"></rect></svg></button> <div class="panel-sep"></div> <button id="btnStampColor" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M7 2 C7 2 3 6.5 3 9 a4 4 0 0 0 8 0 C11 6.5 7 2 7 2 Z" fill="currentColor" fill-opacity="0.25"></path></svg></button> <button id="btnStampFontSize" class="tool-btn !w-7 !h-6 font-mono text-xs font-bold">Aa</button> <button id="btnStampSize" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="6" height="6" rx="0.8" fill="currentColor" fill-opacity="0.25"></rect><path d="M10 2 L12 2 L12 4"></path><path d="M12 2 L9 5"></path><path d="M10 12 L12 12 L12 10"></path><path d="M12 12 L9 9"></path></svg></button> <div class="panel-sep"></div> <button id="btnRotateCCW" class="tool-btn !w-7 !h-6" style="font-size:15px; line-height:1;">↺</button> <button id="btnRotateCW" class="tool-btn !w-7 !h-6" style="font-size:15px; line-height:1;">↻</button> <div class="panel-sep"></div> <button id="btnCopyPng" class="tool-btn !h-6 px-1.5 font-mono text-xs font-semibold flex items-center gap-0.5"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="7" x2="5" y2="1"></line><polyline points="2,4 5,1 8,4"></polyline><line x1="1" y1="9" x2="9" y2="9"></line></svg> PNG</button> <div class="panel-sep"></div> <button id="btnGroup" class="tool-btn !w-8 !h-7"><svg width="22" height="14" viewBox="0 0 22 14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"><rect x="0.7" y="1" width="20.6" height="12" rx="2" stroke-dasharray="2.5,1.5"></rect><rect x="4" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect><rect x="15" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect></svg></button> <button id="btnUngroup" class="tool-btn !w-8 !h-7"><svg width="26" height="14" viewBox="0 0 26 14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"><rect x="0.7" y="1" width="9" height="12" rx="2" stroke-dasharray="2.5,1.5"></rect><rect x="3" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect><rect x="16.3" y="1" width="9" height="12" rx="2" stroke-dasharray="2.5,1.5"></rect><rect x="19" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect></svg></button> <div class="panel-sep"></div> <button id="btnSaveShapeDefault" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"></path><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.474l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"></path></svg></button></div></div> <div id="linkPanel" class="float-panel hidden" style="min-width:260px; flex-direction:column; align-items:stretch; gap:0.5rem; padding:0.75rem;"><div class="text-xs font-semibold text-gray-500 dark:text-gray-400 mb-1"> </div> <label class="flex items-center gap-2 text-xs cursor-pointer"><input type="radio" name="linkType" id="linkTypeUrl" value="url" class="accent-orange-500"/> <span> </span></label> <div id="linkUrlRow"><input id="linkUrlInput" type="url" class="w-full text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-orange-400"/></div> <label class="flex items-center gap-2 text-xs cursor-pointer"><input type="radio" name="linkType" id="linkTypeDiagram" value="diagram" class="accent-orange-500"/> <span> </span></label> <div id="linkDiagramRow" class="hidden"><select id="linkDiagramSelect" class="w-full text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-orange-400"></select></div> <label class="flex items-center gap-2 text-xs cursor-pointer"><input type="radio" name="linkType" id="linkTypeNew" value="new" class="accent-orange-500"/> <span> </span></label> <div id="linkNewRow" class="hidden"><input id="linkNewName" type="text" class="w-full text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-orange-400"/></div> <div class="flex gap-1 mt-1"><button id="btnLinkSave" class="flex-1 text-xs bg-orange-500 hover:bg-orange-600 text-white rounded px-2 py-1"> </button> <button id="btnLinkRemove" class="text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-600"> </button> <button id="btnLinkCancel" class="text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 hover:bg-gray-100 dark:hover:bg-gray-700">✕</button></div></div> <div id="edgePanel" class="float-panel hidden"><button id="btnEdgeLock" class="tool-btn !w-6 !h-6 text-sm">🔒</button> <div class="panel-sep"></div> <div id="edgePanelControls" class="contents"><button id="edgeBtnNone" class="tool-btn !w-7 !h-6 font-mono text-xs">—</button> <button id="edgeBtnFrom" class="tool-btn !w-7 !h-6 text-xs">←</button> <button id="edgeBtnTo" class="tool-btn !w-7 !h-6 text-xs">→</button> <button id="edgeBtnBoth" class="tool-btn !w-8 !h-6 text-xs">←→</button> <div class="panel-sep"></div> <button id="edgeBtnSolid" class="tool-btn !w-8 !h-6"><svg width="22" height="4" viewBox="0 0 22 4"><line x1="1" y1="2" x2="21" y2="2" stroke="currentColor" stroke-width="2" stroke-linecap="round"></line></svg></button> <button id="edgeBtnDashed" class="tool-btn !w-8 !h-6"><svg width="22" height="4" viewBox="0 0 22 4"><line x1="1" y1="2" x2="21" y2="2" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="4,3"></line></svg></button> <div class="panel-sep"></div> <button id="btnEdgeFontDecrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa−</button> <span id="edgeFontSizeValue" class="inline-flex items-center justify-center min-w-[2.25rem] h-6 px-1 text-[11px] font-mono text-gray-700 dark:text-gray-200 border border-gray-300 dark:border-gray-600 rounded bg-white/80 dark:bg-gray-800/80">11</span> <button id="btnEdgeFontIncrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa+</button> <div class="panel-sep"></div> <button id="btnEdgeLabelEdit" class="tool-btn !w-6 !h-6">✎</button> <button id="btnEdgeLabelWidthReset" class="tool-btn !w-6 !h-6 text-xs">↔</button> <div class="panel-sep"></div> <button id="btnEdgeLabelRotateCCW" class="tool-btn !w-7 !h-6 text-sm">↺</button> <button id="btnEdgeLabelRotateCW" class="tool-btn !w-7 !h-6 text-sm">↻</button> <div class="panel-sep"></div> <button id="btnEdgeLabelOffsetLeft" class="tool-btn !w-6 !h-6 text-sm">←</button> <button id="btnEdgeLabelOffsetRight" class="tool-btn !w-6 !h-6 text-sm">→</button> <button id="btnEdgeLabelOffsetUp" class="tool-btn !w-6 !h-6 text-sm">↑</button> <button id="btnEdgeLabelOffsetDown" class="tool-btn !w-6 !h-6 text-sm">↓</button> <button id="btnEdgeLabelOffsetReset" class="tool-btn !w-6 !h-6 text-xs">⊙</button> <div class="panel-sep"></div> <button id="btnEdgeWidthDecrease" class="tool-btn !w-7 !h-6" style="font-size:10px">W−</button> <button id="btnEdgeWidthIncrease" class="tool-btn !w-7 !h-6" style="font-size:10px">W+</button> <div class="panel-sep"></div> <button id="edgeColorSwatch" style="width:1.5rem;height:1.5rem;border-radius:0.25rem;border:2px solid #a8a29e;background:#a8a29e;cursor:pointer;flex-shrink:0;"></button> <div class="panel-sep"></div> <button id="btnEdgeClearPorts" class="tool-btn !w-8 !h-6 text-xs">⊗</button> <div class="panel-sep"></div> <button id="btnSaveEdgeDefault" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"></path><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.474l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"></path></svg></button></div></div> <textarea id="labelInput" class="hidden" rows="1"></textarea> <div id="emptyState" class="absolute inset-0 flex flex-col items-center justify-center text-gray-400 dark:text-gray-600 pointer-events-none select-none"><svg width="52" height="44" viewBox="0 0 52 44" fill="none" stroke="currentColor" stroke-width="1.5" class="mb-3 opacity-50"><rect x="2" y="4" width="18" height="12" rx="2"></rect><rect x="32" y="28" width="18" height="12" rx="2"></rect><line x1="20" y1="10" x2="32" y2="34" stroke-dasharray="4,3"></line><rect x="17" y="16" width="18" height="12" rx="2"></rect><line x1="26" y1="16" x2="26" y2="10" stroke-dasharray="4,3"></line></svg> <p class="text-sm"> </p></div></div></div> <div id="toastContainer"></div> <div id="imageNameModal" style="display:none;position:fixed;inset:0;z-index:1000;background:rgba(0,0,0,0.5);" class="flex items-center justify-center"><div class="bg-white dark:bg-gray-800 rounded-xl shadow-2xl p-6 w-80 flex flex-col gap-3"><p class="text-sm font-semibold text-gray-700 dark:text-gray-200"> </p> <p class="text-xs text-gray-400 dark:text-gray-500">Lettres, chiffres, <code class="bg-gray-100 dark:bg-gray-700 px-0.5 rounded">_</code> et <code class="bg-gray-100 dark:bg-gray-700 px-0.5 rounded">-</code> uniquement.
279
279
  Laisser vide pour un nom automatique.</p> <div class="flex items-center gap-1"><input id="imageNameInput" type="text" autocomplete="off" spellcheck="false" class="flex-1 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700
280
280
  text-gray-900 dark:text-gray-100 text-sm px-2 py-1 outline-none focus:ring-2 focus:ring-blue-400"/> <span class="text-xs text-gray-400 dark:text-gray-500 whitespace-nowrap">.png</span></div> <p id="imageNameError" class="text-xs text-red-500 hidden"> </p> <div class="flex gap-2 justify-end"><button id="imageNameCancel" class="px-3 py-1 text-xs rounded border border-gray-300 dark:border-gray-600
281
- text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"> </button> <button id="imageNameConfirm" class="px-3 py-1 text-xs rounded bg-blue-500 text-white hover:bg-blue-600"> </button></div></div></div></div>`);function vw(e,t){qe(t,!0),Gi(()=>{let e;return(async()=>{let t=`en`;try{t=(await fetch(`/api/config`).then(e=>e.json())).language||`en`}catch{}await ha(t);let{initDiagram:r}=await gw(async()=>{let{initDiagram:e}=await import(`./main-CCEEXcuJ.js`);return{initDiagram:e}},[]);e=r();let i=document.getElementById(`sidebar`),a=parseInt(localStorage.getItem(n)||``,10);i&&Number.isFinite(a)&&(i.style.width=a+`px`)})(),()=>e?.()});let n=`ld-diagram-sidebar-w`,r=P(!1);function i(e){e.preventDefault();let t=document.getElementById(`sidebar`);if(!t)return;let i=e.clientX,a=t.getBoundingClientRect().width;F(r,!0),t.style.transition=`none`,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let n=Math.max(160,Math.min(480,a+e.clientX-i));t.style.width=n+`px`},s=()=>{document.removeEventListener(`mousemove`,o),document.removeEventListener(`mouseup`,s),document.body.style.cursor=``,document.body.style.userSelect=``,F(r,!1),t.style.transition=``;try{localStorage.setItem(n,String(parseInt(t.style.width,10)))}catch{}};document.addEventListener(`mousemove`,o),document.addEventListener(`mouseup`,s)}var a=_w(),o=L(a),s=L(o),c=L(s,!0);j(s);var l=z(s,4),u=z(l,4),d=z(u,2),f=z(d,4),p=z(f,2),m=z(p,2),h=z(m,2),g=z(h,2),_=z(g,2),v=z(_,2),y=z(v,2),b=z(y,2),x=z(b,4),S=z(x,4),C=z(S,4),w=z(C,2),T=z(w,2),E=z(T,2),D=z(E,2),ee=z(D,2),te=z(ee,4),O=z(te,4),ne=z(O,4),re=z(ne,2),k=z(re,8),ie=z(k,4),ae=z(ie,4),oe=L(ae),se=L(oe,!0);j(oe),j(ae),j(o);var ce=z(o,2),le=L(ce),ue=L(le),de=L(ue),fe=L(de,!0);j(de);var pe=z(de,2),me=L(pe,!0);j(pe),j(ue),Ie(2),j(le);var he=z(le,2),ge=z(he,2),_e=z(L(ge),10),ve=z(L(_e),8),ye=z(ve,2);j(_e);var be=z(_e,2),xe=L(be),Se=L(xe),Ce=L(Se,!0);j(Se);var A=z(Se,2);j(xe),Ie(2),j(be);var we=z(be,2),Te=L(we),Ee=z(Te,4),De=L(Ee),Oe=z(De,4),ke=z(Oe,4),Ae=z(ke,2),je=z(Ae,4),Me=z(je,2),Ne=z(Me,2),Pe=z(Ne,4),Fe=z(Pe,2),Le=z(Fe,2),Re=z(Le,4),ze=z(Re,2),Be=z(ze,2),Ve=z(Be,4),He=L(Ve),Ue=z(He,2),We=z(Ue,2),Ge=z(We,2),Ke=z(Ge,2);Ie(2),j(Ve);var Ye=z(Ve,2),Xe=z(Ye,2),Ze=z(Xe,4),Qe=z(Ze,2),$e=z(Qe,2),et=z($e,4),tt=z(et,2),nt=z(tt,4),rt=z(nt,4),it=z(rt,2),at=z(it,4);j(Ee),j(we);var ot=z(we,2),st=L(ot),ct=L(st,!0);j(st);var lt=z(st,2),ut=z(L(lt),2),dt=L(ut,!0);j(ut),j(lt);var ft=z(lt,2),M=L(ft);j(ft);var pt=z(ft,2),mt=z(L(pt),2),ht=L(mt,!0);j(mt),j(pt);var gt=z(pt,4),_t=z(L(gt),2),vt=L(_t,!0);j(_t),j(gt);var yt=z(gt,2),N=L(yt);j(yt);var bt=z(yt,2),xt=L(bt),St=L(xt,!0);j(xt);var Ct=z(xt,2),wt=L(Ct,!0);j(Ct),Ie(2),j(bt),j(ot);var Tt=z(ot,2),Et=L(Tt),Dt=z(Et,4),Ot=L(Dt),kt=z(Ot,2),At=z(kt,2),jt=z(At,2),Mt=z(jt,4),Nt=z(Mt,2),Pt=z(Nt,4),Ft=z(Pt,2),It=z(Ft,2),Lt=z(It,4),Rt=z(Lt,2),zt=z(Rt,4),Bt=z(zt,2),Vt=z(Bt,4),Ht=z(Vt,2),Ut=z(Ht,2),Wt=z(Ut,2),Gt=z(Wt,2),Kt=z(Gt,4),qt=z(Kt,2),Jt=z(qt,4),Yt=z(Jt,4),Xt=z(Yt,4);j(Dt),j(Tt);var Zt=z(Tt,2),Qt=z(Zt,2),$t=z(L(Qt),2),en=L($t,!0);j($t),j(Qt),j(ge),j(ce);var tn=z(ce,4),nn=L(tn),I=L(nn),rn=L(I,!0);j(I);var an=z(I,4),on=L(an);Ie(2),j(an);var sn=z(an,2),cn=L(sn,!0);j(sn);var ln=z(sn,2),un=L(ln),dn=L(un,!0);j(un);var fn=z(un,2),pn=L(fn,!0);j(fn),j(ln),j(nn),j(tn),j(a),B((e,t,n,i,a,o,s,ae,oe,ce,le,ue,de,pe,ge,_e,be,xe,Se,we,Ee,j,Ie,Ve,qe,Je,ot,st,lt,ut,ft,pt,mt,gt,_t,yt,bt,xt,Ct,Tt,Dt,P,Qt,F,$t,tn,nn,I,an,sn,ln,un,fn,L,R,z,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,B,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar)=>{G(c,e),J(l,`title`,t),J(u,`title`,n),J(d,`title`,i),J(f,`title`,a),J(p,`title`,o),J(m,`title`,s),J(h,`title`,ae),J(g,`title`,oe),J(_,`title`,ce),J(v,`title`,le),J(y,`title`,ue),J(b,`title`,de),J(x,`title`,pe),J(S,`title`,ge),J(C,`title`,_e),J(w,`title`,be),J(T,`title`,xe),J(E,`title`,Se),J(D,`title`,we),J(ee,`title`,Ee),J(te,`placeholder`,j),J(O,`title`,Ie),J(ne,`title`,Ve),J(re,`title`,qe),J(k,`title`,Je),J(ie,`title`,ot),G(se,st),G(fe,lt),G(me,ut),gi(he,1,`w-1 shrink-0 cursor-col-resize select-none transition-colors ${V(r)?`bg-blue-500/60`:`bg-transparent hover:bg-blue-500/40`}`),J(ve,`title`,ft),J(ye,`title`,pt),G(Ce,mt),J(A,`title`,gt),J(Te,`title`,_t),J(De,`title`,yt),J(Oe,`title`,bt),J(ke,`title`,xt),J(Ae,`title`,Ct),J(je,`title`,Tt),J(Me,`title`,Dt),J(Ne,`title`,P),J(Pe,`title`,Qt),J(Fe,`title`,F),J(Le,`title`,$t),J(Re,`title`,tn),J(ze,`title`,nn),J(Be,`title`,I),J(He,`title`,an),J(Ue,`title`,sn),J(We,`title`,ln),J(Ge,`title`,un),J(Ke,`title`,fn),J(Ye,`title`,L),J(Xe,`title`,R),J(Ze,`title`,z),J(Qe,`title`,mn),J($e,`title`,hn),J(et,`title`,gn),J(tt,`title`,_n),J(nt,`title`,vn),J(rt,`title`,yn),J(it,`title`,bn),J(at,`title`,xn),G(ct,Sn),G(dt,Cn),J(M,`placeholder`,wn),G(ht,Tn),G(vt,En),J(N,`placeholder`,Dn),G(St,On),G(wt,kn),J(Et,`title`,An),J(Ot,`title`,jn),J(kt,`title`,Mn),J(At,`title`,Nn),J(jt,`title`,Pn),J(Mt,`title`,Fn),J(Nt,`title`,B),J(Pt,`title`,In),J(Ft,`title`,Ln),J(It,`title`,Rn),J(Lt,`title`,zn),J(Rt,`title`,Bn),J(zt,`title`,Vn),J(Bt,`title`,Hn),J(Vt,`title`,Un),J(Ht,`title`,Wn),J(Ut,`title`,Gn),J(Wt,`title`,Kn),J(Gt,`title`,qn),J(Kt,`title`,Jn),J(qt,`title`,Yn),J(Jt,`title`,Xn),J(Yt,`title`,Zn),J(Xt,`title`,Qn),J(Zt,`placeholder`,$n),G(en,er),G(rn,tr),J(on,`placeholder`,nr),G(cn,rr),G(dn,ir),G(pn,ar)},[()=>Y(`diagram.back_btn`),()=>Y(`diagram.diagrams_list_title`),()=>Y(`diagram.toolbar.copy_mcp_id`),()=>Y(`diagram.toolbar.select`),()=>Y(`diagram.toolbar.box`),()=>Y(`diagram.toolbar.ellipse`),()=>Y(`diagram.toolbar.database`),()=>Y(`diagram.toolbar.circle`),()=>Y(`diagram.toolbar.actor`),()=>Y(`diagram.toolbar.postit`),()=>Y(`diagram.toolbar.text_free`),()=>Y(`diagram.toolbar.image`),()=>Y(`diagram.toolbar.shape_editor`),()=>Y(`diagram.toolbar.arrow`),()=>Y(`diagram.toolbar.delete`),()=>Y(`diagram.toolbar.defaults`),()=>Y(`diagram.toolbar.align_guides`),()=>Y(`diagram.toolbar.grid`),()=>Y(`diagram.toolbar.edge_style`),()=>Y(`diagram.toolbar.evidence_mode`),()=>Y(`diagram.toolbar.resize_corner`),()=>Y(`diagram.toolbar.title_placeholder`),()=>Y(`diagram.toolbar.zoom_out`),()=>Y(`diagram.toolbar.zoom_in`),()=>Y(`diagram.toolbar.fit`),()=>Y(`diagram.toolbar.debug`),()=>Y(`diagram.toolbar.export_drawio`),()=>Y(`diagram.toolbar.save`),()=>Y(`diagram.sidebar.title`),()=>Y(`diagram.sidebar.new_btn`),()=>Y(`diagram.selection.rotate_shape`),()=>Y(`diagram.selection.rotate_text`),()=>Y(`diagram.evidence.panel_title`),()=>Y(`diagram.evidence.close`),()=>Y(`diagram.node_panel.lock`),()=>Y(`diagram.node_panel.color`),()=>Y(`diagram.node_panel.bg_opacity`),()=>Y(`diagram.node_panel.edit_label`),()=>Y(`diagram.node_panel.edit_link`),()=>Y(`diagram.node_panel.font_decrease`),()=>Y(`diagram.node_panel.font_size_value`),()=>Y(`diagram.node_panel.font_increase`),()=>Y(`diagram.node_panel.align_left`),()=>Y(`diagram.node_panel.align_center`),()=>Y(`diagram.node_panel.align_right`),()=>Y(`diagram.node_panel.align_top`),()=>Y(`diagram.node_panel.align_middle`),()=>Y(`diagram.node_panel.align_bottom`),()=>Y(`diagram.node_panel.custom_label_above`),()=>Y(`diagram.node_panel.custom_label_below`),()=>Y(`diagram.node_panel.custom_label_left`),()=>Y(`diagram.node_panel.custom_label_right`),()=>Y(`diagram.node_panel.custom_label_center`),()=>Y(`diagram.node_panel.send_back`),()=>Y(`diagram.node_panel.bring_front`),()=>Y(`diagram.node_panel.stamp_color`),()=>Y(`diagram.node_panel.stamp_font`),()=>Y(`diagram.node_panel.stamp_size`),()=>Y(`diagram.node_panel.rotate_ccw`),()=>Y(`diagram.node_panel.rotate_cw`),()=>Y(`diagram.node_panel.copy_png`),()=>Y(`diagram.node_panel.group`),()=>Y(`diagram.node_panel.ungroup`),()=>Y(`diagram.node_panel.save_as_default`),()=>Y(`diagram.link_panel.title`),()=>Y(`diagram.link_panel.external`),()=>Y(`diagram.link_panel.url_placeholder`),()=>Y(`diagram.link_panel.existing_diagram`),()=>Y(`diagram.link_panel.new_diagram`),()=>Y(`diagram.link_panel.diagram_name_placeholder`),()=>Y(`diagram.link_panel.save_btn`),()=>Y(`diagram.link_panel.remove_btn`),()=>Y(`diagram.edge_panel.lock`),()=>Y(`diagram.edge_panel.no_arrow`),()=>Y(`diagram.edge_panel.arrow_from`),()=>Y(`diagram.edge_panel.arrow_to`),()=>Y(`diagram.edge_panel.arrow_both`),()=>Y(`diagram.edge_panel.solid`),()=>Y(`diagram.edge_panel.dashed`),()=>Y(`diagram.edge_panel.font_decrease`),()=>Y(`diagram.edge_panel.font_size_value`),()=>Y(`diagram.edge_panel.font_increase`),()=>Y(`diagram.edge_panel.edit_label`),()=>Y(`diagram.edge_panel.reset_label_width`),()=>Y(`diagram.edge_panel.rotate_label_ccw`),()=>Y(`diagram.edge_panel.rotate_label_cw`),()=>Y(`diagram.edge_panel.offset_label_left`),()=>Y(`diagram.edge_panel.offset_label_right`),()=>Y(`diagram.edge_panel.offset_label_up`),()=>Y(`diagram.edge_panel.offset_label_down`),()=>Y(`diagram.edge_panel.offset_label_reset`),()=>Y(`diagram.edge_panel.width_decrease`),()=>Y(`diagram.edge_panel.width_increase`),()=>Y(`diagram.edge_panel.color`),()=>Y(`diagram.edge_panel.clear_ports`),()=>Y(`diagram.edge_panel.save_as_default`),()=>Y(`diagram.label_input.placeholder`),()=>Y(`diagram.empty_state`),()=>Y(`diagram.image_modal.title`),()=>Y(`diagram.image_modal.placeholder`),()=>Y(`diagram.image_modal.error_chars`),()=>Y(`diagram.image_modal.cancel_btn`),()=>Y(`diagram.image_modal.paste_btn`)]),H(`click`,s,()=>history.back()),H(`mousedown`,he,i),W(e,a),Je()}Pr([`click`,`mousedown`]);var yw=U(`<span class="legend-item svelte-1bqlvrg"><span class="legend-dot svelte-1bqlvrg"></span> </span>`),bw=U(`<p class="graph-msg svelte-1bqlvrg"> </p>`),xw=U(`<p class="graph-msg graph-error svelte-1bqlvrg"> </p>`),Sw=U(`<div class="graph-page svelte-1bqlvrg"><!> <div class="graph-toolbar svelte-1bqlvrg"><span class="graph-counts svelte-1bqlvrg"> </span> <div class="graph-legend svelte-1bqlvrg"></div></div> <div class="graph-canvas-wrap svelte-1bqlvrg"><!> <div class="graph-canvas svelte-1bqlvrg"></div></div></div>`);function Cw(e,t){qe(t,!0);let n={ADR:`#3b82f6`,Worklog:`#22c55e`,Rule:`#f97316`,"Technical Doc":`#a855f7`,Document:`#64748b`,Concept:`#14b8a6`},r,i=P(!0),a=P(``),o=P(I({nodes:0,edges:0})),s=P(I([]));function c(e){return n[e]??`#94a3b8`}Gi(()=>{let e;return(async()=>{let t=`en`;try{t=(await fetch(`/api/config`).then(e=>e.json())).language||`en`}catch{}await ha(t);try{let t=await fetch(`/api/graph`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();F(o,{nodes:n.nodes.length,edges:n.edges.length},!0),F(s,[...new Set(n.nodes.map(e=>e.type))].sort().map(e=>({type:e,color:c(e)})),!0);let i=window.vis;if(!i)throw Error(Y(`graph.renderer_error`));let a=new i.DataSet(n.nodes.map(e=>({id:e.id,label:e.title,title:e.folder?`${e.folder} · ${e.type}`:e.type,color:{background:c(e.type),border:`rgba(100,116,139,0.9)`},shape:`dot`,size:12}))),l=new i.DataSet(n.edges.map((e,t)=>({id:t,from:e.from,to:e.to}))),u=getComputedStyle(document.body).color||`#334155`;e=new i.Network(r,{nodes:a,edges:l},{nodes:{font:{color:u,size:13,face:`inherit`},borderWidth:1.5},edges:{arrows:{to:{enabled:!0,scaleFactor:.5}},color:{color:`rgba(148,163,184,0.55)`,highlight:`#3b82f6`},smooth:{enabled:!0,type:`continuous`,roundness:.4},width:1},physics:{solver:`forceAtlas2Based`,forceAtlas2Based:{gravitationalConstant:-45,springLength:120,avoidOverlap:.6},stabilization:{iterations:250}},interaction:{hover:!0,tooltipDelay:150,navigationButtons:!1}}),e.on(`click`,e=>{e.nodes&&e.nodes.length>0&&(window.location.href=`/?doc=`+encodeURIComponent(e.nodes[0]))})}catch(e){F(a,e.message,!0)}finally{F(i,!1)}})(),()=>e?.destroy?.()});var l=Sw(),u=L(l);{let e=N(()=>Y(`graph.title`)||`Concept graph`);so(u,{get title(){return V(e)},subtitle:``})}var d=z(u,2),f=L(d),p=L(f);j(f);var m=z(f,2);q(m,21,()=>V(s),e=>e.type,(e,t)=>{var n=yw(),r=L(n),i=z(r,1,!0);j(n),B(()=>{vi(r,`background:${V(t).color??``}`),G(i,V(t).type)}),W(e,n)}),j(m),j(d);var h=z(d,2),g=L(h),_=e=>{var t=bw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`graph.loading`)||`Loading graph…`]),W(e,t)},v=e=>{var t=xw(),n=L(t,!0);j(t),B(()=>G(n,V(a))),W(e,t)},y=e=>{var t=bw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`graph.empty`)||`No concepts to graph yet.`]),W(e,t)};K(g,e=>{V(i)?e(_):V(a)?e(v,1):V(o).nodes===0&&e(y,2)}),Vi(z(g,2),e=>r=e,()=>r),j(h),j(l),B(()=>G(p,`${V(o).nodes??``} · ${V(o).edges??``}`)),W(e,l),Je()}We();var ww={network:null,nodes:null,edges:null,diagrams:[],currentDiagramId:null,currentTool:`select`,pendingShape:`box`,selectedNodeIds:[],selectedEdgeIds:[],alignGuides:!0,gridEnabled:!0,debugMode:!1,isDirty:!1,sidebarOpen:!0,editingNodeId:null,editingEdgeId:null,resizeDrag:null,rotateDrag:null,labelRotateDrag:null,activeStamp:null,stampTargetIds:[],clipboard:null,canonicalOrder:[],edgesStraight:!1,resizeSymmetric:!1,nodeColorOverrides:{},customShapeLibraries:[],customShapeDefs:new Map,edgeLabelCanvasPos:{},edgeLabelBBox:{},freeArrowFirstPoint:null,exportingPng:!1,evidenceMode:!1};function Tw(){ww.isDirty=!0,document.getElementById(`btnSave`).disabled=!1}var Ew=`custom-shape`,Dw=`custom-shape:`,Ow=[{id:`N`,x:.5,y:0},{id:`NE`,x:1,y:0},{id:`E`,x:1,y:.5},{id:`SE`,x:1,y:1},{id:`S`,x:.5,y:1},{id:`SW`,x:0,y:1},{id:`W`,x:0,y:.5},{id:`NW`,x:0,y:0}];function kw(e){return typeof e==`string`&&e.startsWith(`custom-shape:`)}function Aw(e){return kw(e)?e.slice(13):null}function jw(e){return e&&ww.customShapeDefs&&ww.customShapeDefs.get(e)||null}function Mw(e){let t=jw(e);return[t&&t.width||65,t&&t.height||65]}function Nw(e){let t=jw(e);return t&&Array.isArray(t.anchors)&&t.anchors.length?t.anchors:Ow}function Pw(e){let t=jw(e);return t&&[`center`,`below`,`above`,`right`,`left`].includes(t.labelPlacement)?t.labelPlacement:`below`}async function Fw(){try{let e=await fetch(`/api/shape-libraries`);if(!e.ok)throw Error(`shape libraries unavailable`);let t=await e.json(),n=Array.isArray(t.libraries)?t.libraries:[];ww.customShapeLibraries=n,ww.customShapeDefs=new Map,n.forEach(e=>{(e.shapes||[]).forEach(e=>ww.customShapeDefs.set(e.id,e))})}catch{ww.customShapeLibraries=[],ww.customShapeDefs=new Map}}function Iw(){let e=document.getElementById(`customShapeBar`),t=document.getElementById(`customShapeBarBody`);if(!e||!t)return;t.innerHTML=``;let n=(ww.customShapeLibraries||[]).flatMap(e=>(e.shapes||[]).filter(e=>e.showInDiagram!==!1).map(t=>({...t,libraryName:e.name})));e.classList.toggle(`hidden`,n.length===0),n.forEach(e=>{let n=document.createElement(`button`);n.type=`button`,n.className=`custom-shape-btn`,n.title=`${e.libraryName||``}${e.libraryName?` · `:``}${e.name}`,n.dataset.customShapeId=e.id;let r=document.createElement(`img`);r.src=e.imageSrc,r.alt=``,r.draggable=!1,n.appendChild(r),n.addEventListener(`click`,()=>{window.dispatchEvent(new CustomEvent(`diagram:setTool`,{detail:{tool:`addNode`,shape:`${Dw}${e.id}`}}))}),t.appendChild(n)})}function Lw(){let e={saveState:document.getElementById(`saveState`),librarySelect:document.getElementById(`librarySelect`),libraryName:document.getElementById(`libraryName`),shapeList:document.getElementById(`shapeList`),previewStage:document.getElementById(`previewStage`),previewImage:document.getElementById(`previewImage`),shapeName:document.getElementById(`shapeName`),imageFile:document.getElementById(`imageFile`),shapeWidth:document.getElementById(`shapeWidth`),shapeHeight:document.getElementById(`shapeHeight`),labelPlacement:document.getElementById(`labelPlacement`),shapeShowInDiagram:document.getElementById(`shapeShowInDiagram`),anchorList:document.getElementById(`anchorList`),anchorCount:document.getElementById(`anchorCount`)},t={libraries:[]},n=null,r=null,i=null,a=null,o=e=>`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,s=()=>t.libraries.find(e=>e.id===n)||null,c=()=>s()?.shapes.find(e=>e.id===r)||null,l=e=>Math.max(0,Math.min(1,e)),u=e=>[`below`,`above`,`right`,`left`,`center`].includes(e)?e:`below`,d=e=>String(e??``).replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e]);function f(t){e.saveState.textContent=t,t&&setTimeout(()=>{e.saveState.textContent===t&&(e.saveState.textContent=``)},1800)}async function p(){t=await(await fetch(`/api/shape-libraries`)).json(),Array.isArray(t.libraries)||(t.libraries=[]),t.libraries.length||t.libraries.push({id:o(`lib`),name:`My shapes`,shapes:[]}),n=t.libraries[0].id,r=t.libraries[0].shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g()}async function m(){t=await(await fetch(`/api/shape-libraries`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).json(),f(`Saved`)}function h(){return{id:o(`shape`),name:`New shape`,imageSrc:``,width:65,height:65,labelPlacement:`below`,showInDiagram:!0,anchors:structuredClone(Ow)}}function g(){_(),v(),y()}function _(){e.librarySelect.innerHTML=``,t.libraries.forEach(t=>{let r=document.createElement(`option`);r.value=t.id,r.textContent=t.name,r.selected=t.id===n,e.librarySelect.appendChild(r)}),e.libraryName.value=s()?.name||``}function v(){let t=s();e.shapeList.innerHTML=``,(t?.shapes||[]).forEach(t=>{let n=document.createElement(`button`);n.type=`button`,n.className=`shape-item w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left hover:bg-gray-100 ${t.id===r?`active`:``}`;let a=document.createElement(`img`);a.src=t.imageSrc,a.alt=``,a.className=`w-6 h-6 object-contain shrink-0`;let o=document.createElement(`span`);o.className=`truncate`,o.textContent=t.name,n.append(a,o),n.addEventListener(`click`,()=>{r=t.id,i=structuredClone(t),g()}),e.shapeList.appendChild(n)}),t?.shapes?.length||(e.shapeList.innerHTML=`<p class="text-xs text-gray-400 px-2 py-2">No shape yet.</p>`)}function y(){i||=h(),e.previewStage.style.aspectRatio=`${Math.max(16,Number(i.width)||65)} / ${Math.max(16,Number(i.height)||65)}`,e.previewImage.src=i.imageSrc||``,e.previewImage.style.display=i.imageSrc?`block`:`none`,e.shapeName.value=i.name||``,e.shapeWidth.value=i.width||65,e.shapeHeight.value=i.height||65,e.labelPlacement.value=u(i.labelPlacement),e.shapeShowInDiagram.checked=i.showInDiagram!==!1,b()}function b(){e.previewStage.querySelectorAll(`.anchor-dot`).forEach(e=>e.remove()),e.anchorList.innerHTML=``;let t=i.anchors||[];e.anchorCount.textContent=`${t.length} anchor${t.length>1?`s`:``}`,t.forEach((t,n)=>{let r=document.createElement(`button`);r.type=`button`,r.className=`anchor-dot`,r.style.left=`${t.x*100}%`,r.style.top=`${t.y*100}%`,r.dataset.anchorId=t.id,r.innerHTML=`<span>${t.id}</span>`,r.addEventListener(`pointerdown`,e=>{e.preventDefault(),a=t.id,r.setPointerCapture(e.pointerId)}),e.previewStage.appendChild(r);let o=document.createElement(`div`);o.className=`grid grid-cols-[4.5rem_1fr_1fr_2rem] gap-2 items-center`,o.innerHTML=`
281
+ text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"> </button> <button id="imageNameConfirm" class="px-3 py-1 text-xs rounded bg-blue-500 text-white hover:bg-blue-600"> </button></div></div></div></div>`);function bw(e,t){qe(t,!0),Gi(()=>{let e;return(async()=>{let t=`en`;try{t=(await fetch(`/api/config`).then(e=>e.json())).language||`en`}catch{}await ha(t);let{initDiagram:r}=await vw(async()=>{let{initDiagram:e}=await import(`./main-d0ob0eiu.js`);return{initDiagram:e}},[]);e=r();let i=document.getElementById(`sidebar`),a=parseInt(localStorage.getItem(n)||``,10);i&&Number.isFinite(a)&&(i.style.width=a+`px`)})(),()=>e?.()});let n=`ld-diagram-sidebar-w`,r=P(!1);function i(e){e.preventDefault();let t=document.getElementById(`sidebar`);if(!t)return;let i=e.clientX,a=t.getBoundingClientRect().width;F(r,!0),t.style.transition=`none`,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let n=Math.max(160,Math.min(480,a+e.clientX-i));t.style.width=n+`px`},s=()=>{document.removeEventListener(`mousemove`,o),document.removeEventListener(`mouseup`,s),document.body.style.cursor=``,document.body.style.userSelect=``,F(r,!1),t.style.transition=``;try{localStorage.setItem(n,String(parseInt(t.style.width,10)))}catch{}};document.addEventListener(`mousemove`,o),document.addEventListener(`mouseup`,s)}var a=yw(),o=L(a),s=L(o),c=L(s,!0);j(s);var l=z(s,4),u=z(l,4),d=z(u,2),f=z(d,4),p=z(f,2),m=z(p,2),h=z(m,2),g=z(h,2),_=z(g,2),v=z(_,2),y=z(v,2),b=z(y,2),x=z(b,4),S=z(x,4),C=z(S,4),w=z(C,2),T=z(w,2),E=z(T,2),D=z(E,2),ee=z(D,2),te=z(ee,4),O=z(te,4),ne=z(O,4),re=z(ne,2),k=z(re,8),ie=z(k,4),ae=z(ie,4),oe=L(ae),se=L(oe,!0);j(oe),j(ae),j(o);var ce=z(o,2),le=L(ce),ue=L(le),de=L(ue),fe=L(de,!0);j(de);var pe=z(de,2),me=L(pe,!0);j(pe),j(ue),Ie(2),j(le);var he=z(le,2),ge=z(he,2),_e=z(L(ge),10),ve=z(L(_e),8),ye=z(ve,2);j(_e);var be=z(_e,2),xe=L(be),Se=L(xe),Ce=L(Se,!0);j(Se);var A=z(Se,2);j(xe),Ie(2),j(be);var we=z(be,2),Te=L(we),Ee=z(Te,4),De=L(Ee),Oe=z(De,4),ke=z(Oe,4),Ae=z(ke,2),je=z(Ae,4),Me=z(je,2),Ne=z(Me,2),Pe=z(Ne,4),Fe=z(Pe,2),Le=z(Fe,2),Re=z(Le,4),ze=z(Re,2),Be=z(ze,2),Ve=z(Be,4),He=L(Ve),Ue=z(He,2),We=z(Ue,2),Ge=z(We,2),Ke=z(Ge,2);Ie(2),j(Ve);var Ye=z(Ve,2),Xe=z(Ye,2),Ze=z(Xe,4),Qe=z(Ze,2),$e=z(Qe,2),et=z($e,4),tt=z(et,2),nt=z(tt,4),rt=z(nt,4),it=z(rt,2),at=z(it,4);j(Ee),j(we);var ot=z(we,2),st=L(ot),ct=L(st,!0);j(st);var lt=z(st,2),ut=z(L(lt),2),dt=L(ut,!0);j(ut),j(lt);var ft=z(lt,2),M=L(ft);j(ft);var pt=z(ft,2),mt=z(L(pt),2),ht=L(mt,!0);j(mt),j(pt);var gt=z(pt,4),_t=z(L(gt),2),vt=L(_t,!0);j(_t),j(gt);var yt=z(gt,2),N=L(yt);j(yt);var bt=z(yt,2),xt=L(bt),St=L(xt,!0);j(xt);var Ct=z(xt,2),wt=L(Ct,!0);j(Ct),Ie(2),j(bt),j(ot);var Tt=z(ot,2),Et=L(Tt),Dt=z(Et,4),Ot=L(Dt),kt=z(Ot,2),At=z(kt,2),jt=z(At,2),Mt=z(jt,4),Nt=z(Mt,2),Pt=z(Nt,4),Ft=z(Pt,2),It=z(Ft,2),Lt=z(It,4),Rt=z(Lt,2),zt=z(Rt,4),Bt=z(zt,2),Vt=z(Bt,4),Ht=z(Vt,2),Ut=z(Ht,2),Wt=z(Ut,2),Gt=z(Wt,2),Kt=z(Gt,4),qt=z(Kt,2),Jt=z(qt,4),Yt=z(Jt,4),Xt=z(Yt,4);j(Dt),j(Tt);var Zt=z(Tt,2),Qt=z(Zt,2),$t=z(L(Qt),2),en=L($t,!0);j($t),j(Qt),j(ge),j(ce);var tn=z(ce,4),nn=L(tn),I=L(nn),rn=L(I,!0);j(I);var an=z(I,4),on=L(an);Ie(2),j(an);var sn=z(an,2),cn=L(sn,!0);j(sn);var ln=z(sn,2),un=L(ln),dn=L(un,!0);j(un);var fn=z(un,2),pn=L(fn,!0);j(fn),j(ln),j(nn),j(tn),j(a),B((e,t,n,i,a,o,s,ae,oe,ce,le,ue,de,pe,ge,_e,be,xe,Se,we,Ee,j,Ie,Ve,qe,Je,ot,st,lt,ut,ft,pt,mt,gt,_t,yt,bt,xt,Ct,Tt,Dt,P,Qt,F,$t,tn,nn,I,an,sn,ln,un,fn,L,R,z,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,B,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar)=>{G(c,e),J(l,`title`,t),J(u,`title`,n),J(d,`title`,i),J(f,`title`,a),J(p,`title`,o),J(m,`title`,s),J(h,`title`,ae),J(g,`title`,oe),J(_,`title`,ce),J(v,`title`,le),J(y,`title`,ue),J(b,`title`,de),J(x,`title`,pe),J(S,`title`,ge),J(C,`title`,_e),J(w,`title`,be),J(T,`title`,xe),J(E,`title`,Se),J(D,`title`,we),J(ee,`title`,Ee),J(te,`placeholder`,j),J(O,`title`,Ie),J(ne,`title`,Ve),J(re,`title`,qe),J(k,`title`,Je),J(ie,`title`,ot),G(se,st),G(fe,lt),G(me,ut),gi(he,1,`w-1 shrink-0 cursor-col-resize select-none transition-colors ${V(r)?`bg-blue-500/60`:`bg-transparent hover:bg-blue-500/40`}`),J(ve,`title`,ft),J(ye,`title`,pt),G(Ce,mt),J(A,`title`,gt),J(Te,`title`,_t),J(De,`title`,yt),J(Oe,`title`,bt),J(ke,`title`,xt),J(Ae,`title`,Ct),J(je,`title`,Tt),J(Me,`title`,Dt),J(Ne,`title`,P),J(Pe,`title`,Qt),J(Fe,`title`,F),J(Le,`title`,$t),J(Re,`title`,tn),J(ze,`title`,nn),J(Be,`title`,I),J(He,`title`,an),J(Ue,`title`,sn),J(We,`title`,ln),J(Ge,`title`,un),J(Ke,`title`,fn),J(Ye,`title`,L),J(Xe,`title`,R),J(Ze,`title`,z),J(Qe,`title`,mn),J($e,`title`,hn),J(et,`title`,gn),J(tt,`title`,_n),J(nt,`title`,vn),J(rt,`title`,yn),J(it,`title`,bn),J(at,`title`,xn),G(ct,Sn),G(dt,Cn),J(M,`placeholder`,wn),G(ht,Tn),G(vt,En),J(N,`placeholder`,Dn),G(St,On),G(wt,kn),J(Et,`title`,An),J(Ot,`title`,jn),J(kt,`title`,Mn),J(At,`title`,Nn),J(jt,`title`,Pn),J(Mt,`title`,Fn),J(Nt,`title`,B),J(Pt,`title`,In),J(Ft,`title`,Ln),J(It,`title`,Rn),J(Lt,`title`,zn),J(Rt,`title`,Bn),J(zt,`title`,Vn),J(Bt,`title`,Hn),J(Vt,`title`,Un),J(Ht,`title`,Wn),J(Ut,`title`,Gn),J(Wt,`title`,Kn),J(Gt,`title`,qn),J(Kt,`title`,Jn),J(qt,`title`,Yn),J(Jt,`title`,Xn),J(Yt,`title`,Zn),J(Xt,`title`,Qn),J(Zt,`placeholder`,$n),G(en,er),G(rn,tr),J(on,`placeholder`,nr),G(cn,rr),G(dn,ir),G(pn,ar)},[()=>Y(`diagram.back_btn`),()=>Y(`diagram.diagrams_list_title`),()=>Y(`diagram.toolbar.copy_mcp_id`),()=>Y(`diagram.toolbar.select`),()=>Y(`diagram.toolbar.box`),()=>Y(`diagram.toolbar.ellipse`),()=>Y(`diagram.toolbar.database`),()=>Y(`diagram.toolbar.circle`),()=>Y(`diagram.toolbar.actor`),()=>Y(`diagram.toolbar.postit`),()=>Y(`diagram.toolbar.text_free`),()=>Y(`diagram.toolbar.image`),()=>Y(`diagram.toolbar.shape_editor`),()=>Y(`diagram.toolbar.arrow`),()=>Y(`diagram.toolbar.delete`),()=>Y(`diagram.toolbar.defaults`),()=>Y(`diagram.toolbar.align_guides`),()=>Y(`diagram.toolbar.grid`),()=>Y(`diagram.toolbar.edge_style`),()=>Y(`diagram.toolbar.evidence_mode`),()=>Y(`diagram.toolbar.resize_corner`),()=>Y(`diagram.toolbar.title_placeholder`),()=>Y(`diagram.toolbar.zoom_out`),()=>Y(`diagram.toolbar.zoom_in`),()=>Y(`diagram.toolbar.fit`),()=>Y(`diagram.toolbar.debug`),()=>Y(`diagram.toolbar.export_drawio`),()=>Y(`diagram.toolbar.save`),()=>Y(`diagram.sidebar.title`),()=>Y(`diagram.sidebar.new_btn`),()=>Y(`diagram.selection.rotate_shape`),()=>Y(`diagram.selection.rotate_text`),()=>Y(`diagram.evidence.panel_title`),()=>Y(`diagram.evidence.close`),()=>Y(`diagram.node_panel.lock`),()=>Y(`diagram.node_panel.color`),()=>Y(`diagram.node_panel.bg_opacity`),()=>Y(`diagram.node_panel.edit_label`),()=>Y(`diagram.node_panel.edit_link`),()=>Y(`diagram.node_panel.font_decrease`),()=>Y(`diagram.node_panel.font_size_value`),()=>Y(`diagram.node_panel.font_increase`),()=>Y(`diagram.node_panel.align_left`),()=>Y(`diagram.node_panel.align_center`),()=>Y(`diagram.node_panel.align_right`),()=>Y(`diagram.node_panel.align_top`),()=>Y(`diagram.node_panel.align_middle`),()=>Y(`diagram.node_panel.align_bottom`),()=>Y(`diagram.node_panel.custom_label_above`),()=>Y(`diagram.node_panel.custom_label_below`),()=>Y(`diagram.node_panel.custom_label_left`),()=>Y(`diagram.node_panel.custom_label_right`),()=>Y(`diagram.node_panel.custom_label_center`),()=>Y(`diagram.node_panel.send_back`),()=>Y(`diagram.node_panel.bring_front`),()=>Y(`diagram.node_panel.stamp_color`),()=>Y(`diagram.node_panel.stamp_font`),()=>Y(`diagram.node_panel.stamp_size`),()=>Y(`diagram.node_panel.rotate_ccw`),()=>Y(`diagram.node_panel.rotate_cw`),()=>Y(`diagram.node_panel.copy_png`),()=>Y(`diagram.node_panel.group`),()=>Y(`diagram.node_panel.ungroup`),()=>Y(`diagram.node_panel.save_as_default`),()=>Y(`diagram.link_panel.title`),()=>Y(`diagram.link_panel.external`),()=>Y(`diagram.link_panel.url_placeholder`),()=>Y(`diagram.link_panel.existing_diagram`),()=>Y(`diagram.link_panel.new_diagram`),()=>Y(`diagram.link_panel.diagram_name_placeholder`),()=>Y(`diagram.link_panel.save_btn`),()=>Y(`diagram.link_panel.remove_btn`),()=>Y(`diagram.edge_panel.lock`),()=>Y(`diagram.edge_panel.no_arrow`),()=>Y(`diagram.edge_panel.arrow_from`),()=>Y(`diagram.edge_panel.arrow_to`),()=>Y(`diagram.edge_panel.arrow_both`),()=>Y(`diagram.edge_panel.solid`),()=>Y(`diagram.edge_panel.dashed`),()=>Y(`diagram.edge_panel.font_decrease`),()=>Y(`diagram.edge_panel.font_size_value`),()=>Y(`diagram.edge_panel.font_increase`),()=>Y(`diagram.edge_panel.edit_label`),()=>Y(`diagram.edge_panel.reset_label_width`),()=>Y(`diagram.edge_panel.rotate_label_ccw`),()=>Y(`diagram.edge_panel.rotate_label_cw`),()=>Y(`diagram.edge_panel.offset_label_left`),()=>Y(`diagram.edge_panel.offset_label_right`),()=>Y(`diagram.edge_panel.offset_label_up`),()=>Y(`diagram.edge_panel.offset_label_down`),()=>Y(`diagram.edge_panel.offset_label_reset`),()=>Y(`diagram.edge_panel.width_decrease`),()=>Y(`diagram.edge_panel.width_increase`),()=>Y(`diagram.edge_panel.color`),()=>Y(`diagram.edge_panel.clear_ports`),()=>Y(`diagram.edge_panel.save_as_default`),()=>Y(`diagram.label_input.placeholder`),()=>Y(`diagram.empty_state`),()=>Y(`diagram.image_modal.title`),()=>Y(`diagram.image_modal.placeholder`),()=>Y(`diagram.image_modal.error_chars`),()=>Y(`diagram.image_modal.cancel_btn`),()=>Y(`diagram.image_modal.paste_btn`)]),H(`click`,s,()=>history.back()),H(`mousedown`,he,i),W(e,a),Je()}Pr([`click`,`mousedown`]);var xw=U(`<span class="legend-item svelte-1bqlvrg"><span class="legend-dot svelte-1bqlvrg"></span> </span>`),Sw=U(`<p class="graph-msg svelte-1bqlvrg"> </p>`),Cw=U(`<p class="graph-msg graph-error svelte-1bqlvrg"> </p>`),ww=U(`<div class="graph-page svelte-1bqlvrg"><!> <div class="graph-toolbar svelte-1bqlvrg"><span class="graph-counts svelte-1bqlvrg"> </span> <div class="graph-legend svelte-1bqlvrg"></div></div> <div class="graph-canvas-wrap svelte-1bqlvrg"><!> <div class="graph-canvas svelte-1bqlvrg"></div></div></div>`);function Tw(e,t){qe(t,!0);let n={ADR:`#3b82f6`,Worklog:`#22c55e`,Rule:`#f97316`,"Technical Doc":`#a855f7`,Document:`#64748b`,Concept:`#14b8a6`},r,i=P(!0),a=P(``),o=P(I({nodes:0,edges:0})),s=P(I([]));function c(e){return n[e]??`#94a3b8`}Gi(()=>{let e;return(async()=>{let t=`en`;try{t=(await fetch(`/api/config`).then(e=>e.json())).language||`en`}catch{}await ha(t);try{let t=await fetch(`/api/graph`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();F(o,{nodes:n.nodes.length,edges:n.edges.length},!0),F(s,[...new Set(n.nodes.map(e=>e.type))].sort().map(e=>({type:e,color:c(e)})),!0);let i=window.vis;if(!i)throw Error(Y(`graph.renderer_error`));let a=new i.DataSet(n.nodes.map(e=>({id:e.id,label:e.title,title:e.folder?`${e.folder} · ${e.type}`:e.type,color:{background:c(e.type),border:`rgba(100,116,139,0.9)`},shape:`dot`,size:12}))),l=new i.DataSet(n.edges.map((e,t)=>({id:t,from:e.from,to:e.to}))),u=getComputedStyle(document.body).color||`#334155`;e=new i.Network(r,{nodes:a,edges:l},{nodes:{font:{color:u,size:13,face:`inherit`},borderWidth:1.5},edges:{arrows:{to:{enabled:!0,scaleFactor:.5}},color:{color:`rgba(148,163,184,0.55)`,highlight:`#3b82f6`},smooth:{enabled:!0,type:`continuous`,roundness:.4},width:1},physics:{solver:`forceAtlas2Based`,forceAtlas2Based:{gravitationalConstant:-45,springLength:120,avoidOverlap:.6},stabilization:{iterations:250}},interaction:{hover:!0,tooltipDelay:150,navigationButtons:!1}}),e.on(`click`,e=>{e.nodes&&e.nodes.length>0&&(window.location.href=`/?doc=`+encodeURIComponent(e.nodes[0]))})}catch(e){F(a,e.message,!0)}finally{F(i,!1)}})(),()=>e?.destroy?.()});var l=ww(),u=L(l);{let e=N(()=>Y(`graph.title`)||`Concept graph`);so(u,{get title(){return V(e)},subtitle:``})}var d=z(u,2),f=L(d),p=L(f);j(f);var m=z(f,2);q(m,21,()=>V(s),e=>e.type,(e,t)=>{var n=xw(),r=L(n),i=z(r,1,!0);j(n),B(()=>{vi(r,`background:${V(t).color??``}`),G(i,V(t).type)}),W(e,n)}),j(m),j(d);var h=z(d,2),g=L(h),_=e=>{var t=Sw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`graph.loading`)||`Loading graph…`]),W(e,t)},v=e=>{var t=Cw(),n=L(t,!0);j(t),B(()=>G(n,V(a))),W(e,t)},y=e=>{var t=Sw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`graph.empty`)||`No concepts to graph yet.`]),W(e,t)};K(g,e=>{V(i)?e(_):V(a)?e(v,1):V(o).nodes===0&&e(y,2)}),Vi(z(g,2),e=>r=e,()=>r),j(h),j(l),B(()=>G(p,`${V(o).nodes??``} · ${V(o).edges??``}`)),W(e,l),Je()}We();var Ew={network:null,nodes:null,edges:null,diagrams:[],currentDiagramId:null,currentTool:`select`,pendingShape:`box`,selectedNodeIds:[],selectedEdgeIds:[],alignGuides:!0,gridEnabled:!0,debugMode:!1,isDirty:!1,sidebarOpen:!0,editingNodeId:null,editingEdgeId:null,resizeDrag:null,rotateDrag:null,labelRotateDrag:null,activeStamp:null,stampTargetIds:[],clipboard:null,canonicalOrder:[],edgesStraight:!1,resizeSymmetric:!1,nodeColorOverrides:{},customShapeLibraries:[],customShapeDefs:new Map,edgeLabelCanvasPos:{},edgeLabelBBox:{},freeArrowFirstPoint:null,exportingPng:!1,evidenceMode:!1};function Dw(){Ew.isDirty=!0,document.getElementById(`btnSave`).disabled=!1}var Ow=`custom-shape`,kw=`custom-shape:`,Aw=[{id:`N`,x:.5,y:0},{id:`NE`,x:1,y:0},{id:`E`,x:1,y:.5},{id:`SE`,x:1,y:1},{id:`S`,x:.5,y:1},{id:`SW`,x:0,y:1},{id:`W`,x:0,y:.5},{id:`NW`,x:0,y:0}];function jw(e){return typeof e==`string`&&e.startsWith(`custom-shape:`)}function Mw(e){return jw(e)?e.slice(13):null}function Nw(e){return e&&Ew.customShapeDefs&&Ew.customShapeDefs.get(e)||null}function Pw(e){let t=Nw(e);return[t&&t.width||65,t&&t.height||65]}function Fw(e){let t=Nw(e);return t&&Array.isArray(t.anchors)&&t.anchors.length?t.anchors:Aw}function Iw(e){let t=Nw(e);return t&&[`center`,`below`,`above`,`right`,`left`].includes(t.labelPlacement)?t.labelPlacement:`below`}async function Lw(){try{let e=await fetch(`/api/shape-libraries`);if(!e.ok)throw Error(`shape libraries unavailable`);let t=await e.json(),n=Array.isArray(t.libraries)?t.libraries:[];Ew.customShapeLibraries=n,Ew.customShapeDefs=new Map,n.forEach(e=>{(e.shapes||[]).forEach(e=>Ew.customShapeDefs.set(e.id,e))})}catch{Ew.customShapeLibraries=[],Ew.customShapeDefs=new Map}}function Rw(){let e=document.getElementById(`customShapeBar`),t=document.getElementById(`customShapeBarBody`);if(!e||!t)return;t.innerHTML=``;let n=(Ew.customShapeLibraries||[]).flatMap(e=>(e.shapes||[]).filter(e=>e.showInDiagram!==!1).map(t=>({...t,libraryName:e.name})));e.classList.toggle(`hidden`,n.length===0),n.forEach(e=>{let n=document.createElement(`button`);n.type=`button`,n.className=`custom-shape-btn`,n.title=`${e.libraryName||``}${e.libraryName?` · `:``}${e.name}`,n.dataset.customShapeId=e.id;let r=document.createElement(`img`);r.src=e.imageSrc,r.alt=``,r.draggable=!1,n.appendChild(r),n.addEventListener(`click`,()=>{window.dispatchEvent(new CustomEvent(`diagram:setTool`,{detail:{tool:`addNode`,shape:`${kw}${e.id}`}}))}),t.appendChild(n)})}function zw(){let e={saveState:document.getElementById(`saveState`),librarySelect:document.getElementById(`librarySelect`),libraryName:document.getElementById(`libraryName`),shapeList:document.getElementById(`shapeList`),previewStage:document.getElementById(`previewStage`),previewImage:document.getElementById(`previewImage`),shapeName:document.getElementById(`shapeName`),imageFile:document.getElementById(`imageFile`),shapeWidth:document.getElementById(`shapeWidth`),shapeHeight:document.getElementById(`shapeHeight`),labelPlacement:document.getElementById(`labelPlacement`),shapeShowInDiagram:document.getElementById(`shapeShowInDiagram`),anchorList:document.getElementById(`anchorList`),anchorCount:document.getElementById(`anchorCount`)},t={libraries:[]},n=null,r=null,i=null,a=null,o=e=>`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,s=()=>t.libraries.find(e=>e.id===n)||null,c=()=>s()?.shapes.find(e=>e.id===r)||null,l=e=>Math.max(0,Math.min(1,e)),u=e=>[`below`,`above`,`right`,`left`,`center`].includes(e)?e:`below`,d=e=>String(e??``).replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e]);function f(t){e.saveState.textContent=t,t&&setTimeout(()=>{e.saveState.textContent===t&&(e.saveState.textContent=``)},1800)}async function p(){t=await(await fetch(`/api/shape-libraries`)).json(),Array.isArray(t.libraries)||(t.libraries=[]),t.libraries.length||t.libraries.push({id:o(`lib`),name:`My shapes`,shapes:[]}),n=t.libraries[0].id,r=t.libraries[0].shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g()}async function m(){t=await(await fetch(`/api/shape-libraries`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).json(),f(`Saved`)}function h(){return{id:o(`shape`),name:`New shape`,imageSrc:``,width:65,height:65,labelPlacement:`below`,showInDiagram:!0,anchors:structuredClone(Aw)}}function g(){_(),v(),y()}function _(){e.librarySelect.innerHTML=``,t.libraries.forEach(t=>{let r=document.createElement(`option`);r.value=t.id,r.textContent=t.name,r.selected=t.id===n,e.librarySelect.appendChild(r)}),e.libraryName.value=s()?.name||``}function v(){let t=s();e.shapeList.innerHTML=``,(t?.shapes||[]).forEach(t=>{let n=document.createElement(`button`);n.type=`button`,n.className=`shape-item w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left hover:bg-gray-100 ${t.id===r?`active`:``}`;let a=document.createElement(`img`);a.src=t.imageSrc,a.alt=``,a.className=`w-6 h-6 object-contain shrink-0`;let o=document.createElement(`span`);o.className=`truncate`,o.textContent=t.name,n.append(a,o),n.addEventListener(`click`,()=>{r=t.id,i=structuredClone(t),g()}),e.shapeList.appendChild(n)}),t?.shapes?.length||(e.shapeList.innerHTML=`<p class="text-xs text-gray-400 px-2 py-2">No shape yet.</p>`)}function y(){i||=h(),e.previewStage.style.aspectRatio=`${Math.max(16,Number(i.width)||65)} / ${Math.max(16,Number(i.height)||65)}`,e.previewImage.src=i.imageSrc||``,e.previewImage.style.display=i.imageSrc?`block`:`none`,e.shapeName.value=i.name||``,e.shapeWidth.value=i.width||65,e.shapeHeight.value=i.height||65,e.labelPlacement.value=u(i.labelPlacement),e.shapeShowInDiagram.checked=i.showInDiagram!==!1,b()}function b(){e.previewStage.querySelectorAll(`.anchor-dot`).forEach(e=>e.remove()),e.anchorList.innerHTML=``;let t=i.anchors||[];e.anchorCount.textContent=`${t.length} anchor${t.length>1?`s`:``}`,t.forEach((t,n)=>{let r=document.createElement(`button`);r.type=`button`,r.className=`anchor-dot`,r.style.left=`${t.x*100}%`,r.style.top=`${t.y*100}%`,r.dataset.anchorId=t.id,r.innerHTML=`<span>${t.id}</span>`,r.addEventListener(`pointerdown`,e=>{e.preventDefault(),a=t.id,r.setPointerCapture(e.pointerId)}),e.previewStage.appendChild(r);let o=document.createElement(`div`);o.className=`grid grid-cols-[4.5rem_1fr_1fr_2rem] gap-2 items-center`,o.innerHTML=`
282
282
  <input class="field !h-7 text-xs" value="${d(t.id)}">
283
283
  <input class="field !h-7 text-xs" type="number" min="0" max="100" step="1" value="${Math.round(t.x*100)}">
284
284
  <input class="field !h-7 text-xs" type="number" min="0" max="100" step="1" value="${Math.round(t.y*100)}">
285
285
  <button class="btn btn-danger !h-7 !px-0">×</button>
286
- `;let[s,c,u]=o.querySelectorAll(`input`);s.addEventListener(`input`,()=>{t.id=s.value.trim()||`p${n+1}`,b()}),c.addEventListener(`input`,()=>{t.x=l(Number(c.value)/100),b()}),u.addEventListener(`input`,()=>{t.y=l(Number(u.value)/100),b()}),o.querySelector(`button`).addEventListener(`click`,()=>{i.anchors=i.anchors.filter(e=>e!==t),b()}),e.anchorList.appendChild(o)})}function x(t,n){let r=e.previewStage.getBoundingClientRect();t.x=l((n.clientX-r.left)/r.width),t.y=l((n.clientY-r.top)/r.height)}let S=[],C=(e,t,n,r)=>{e.addEventListener(t,n,r),S.push(()=>e.removeEventListener(t,n,r))};return C(e.previewStage,`pointermove`,e=>{if(!a||!i)return;let t=i.anchors.find(e=>e.id===a);t&&(x(t,e),b())}),C(window,`pointerup`,()=>{a=null}),C(e.previewStage,`click`,e=>{if(e.target.closest(`.anchor-dot`)||a||!i)return;let t={id:`p${(i.anchors||[]).length+1}`,x:.5,y:.5};x(t,e),i.anchors=[...i.anchors||[],t],b()}),C(document.getElementById(`btnAddLibrary`),`click`,async()=>{let e={id:o(`lib`),name:`New library`,shapes:[]};t.libraries.push(e),n=e.id,r=null,i=h(),g(),await m()}),C(e.librarySelect,`change`,()=>{n=e.librarySelect.value,r=s()?.shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g()}),C(e.libraryName,`change`,async()=>{let t=s();t&&(t.name=e.libraryName.value.trim()||t.name,_(),await m())}),C(document.getElementById(`btnNewShape`),`click`,()=>{r=null,i=h(),g()}),C(document.getElementById(`btnDeleteShape`),`click`,async()=>{let e=s();!e||!r||(e.shapes=e.shapes.filter(e=>e.id!==r),r=e.shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g(),await m())}),C(document.getElementById(`btnDefaultAnchors`),`click`,()=>{i.anchors=structuredClone(Ow),b()}),C(document.getElementById(`btnClearAnchors`),`click`,()=>{i.anchors=[],b()}),C(document.getElementById(`btnSaveShape`),`click`,async()=>{let t=s();if(!t||!i||!i.imageSrc)return;i.name=e.shapeName.value.trim()||`Untitled shape`,i.width=Math.max(16,Math.min(1200,Math.round(Number(e.shapeWidth.value)||65))),i.height=Math.max(16,Math.min(1200,Math.round(Number(e.shapeHeight.value)||65))),i.labelPlacement=u(e.labelPlacement.value),i.showInDiagram=e.shapeShowInDiagram.checked;let n=t.shapes.findIndex(e=>e.id===i.id);n>=0?t.shapes[n]=structuredClone(i):t.shapes.push(structuredClone(i)),r=i.id,g(),await m()}),[`shapeName`,`shapeWidth`,`shapeHeight`,`labelPlacement`,`shapeShowInDiagram`].forEach(t=>{C(document.getElementById(t),`input`,()=>{i.name=e.shapeName.value,i.width=Number(e.shapeWidth.value)||65,i.height=Number(e.shapeHeight.value)||65,i.labelPlacement=u(e.labelPlacement.value),i.showInDiagram=e.shapeShowInDiagram.checked})}),C(e.imageFile,`change`,async()=>{let t=e.imageFile.files&&e.imageFile.files[0];if(!t||!i)return;let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=n,r.readAsDataURL(t)}),r=(t.name.split(`.`).pop()||`png`).toLowerCase().replace(/[^a-z0-9]/g,``)||`png`,a=t.name.replace(/\.[^.]+$/,``).slice(0,60),o=await(await fetch(`/api/images/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:n,ext:r,name:a})})).json();i.imageSrc=`/images/${o.filename}`,(!e.shapeName.value||e.shapeName.value===`New shape`)&&(i.name=a||i.name),y()}),p(),()=>{S.forEach(e=>e()),S.length=0}}var Rw=U(`<div class="ld-shape-editor h-screen overflow-hidden bg-gray-50 text-gray-900"><header class="h-12 border-b border-gray-200 bg-white flex items-center gap-2 px-3"><button class="btn">← Back</button> <h1 class="text-sm font-semibold">Shape editor</h1> <span id="saveState" class="ml-auto text-xs text-gray-500"></span></header> <main class="h-[calc(100vh-3rem)] grid grid-cols-[17rem_1fr] overflow-hidden"><aside class="border-r border-gray-200 bg-white flex flex-col min-h-0"><div class="p-3 border-b border-gray-200 space-y-2"><label class="block text-xs font-semibold text-gray-500">Library</label> <div class="flex gap-2"><select id="librarySelect" class="field flex-1"></select> <button id="btnAddLibrary" class="btn">+</button></div> <input id="libraryName" class="field w-full" placeholder="Library name"/></div> <div class="p-3 border-b border-gray-200 flex gap-2"><button id="btnNewShape" class="btn btn-primary flex-1">New shape</button> <button id="btnDeleteShape" class="btn btn-danger">Delete</button></div> <div id="shapeList" class="flex-1 overflow-y-auto p-2 space-y-1"></div></aside> <section class="min-w-0 min-h-0 overflow-y-auto p-5"><div class="grid grid-cols-[minmax(20rem,34rem)_minmax(20rem,1fr)] gap-5 items-start"><div class="space-y-3"><div id="previewStage"><img id="previewImage" alt=""/></div> <p class="text-xs text-gray-500">Click on the image to add an anchor. Drag anchors to refine their
287
- position.</p></div> <div class="space-y-4"><div class="grid grid-cols-2 gap-3"><label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Shape name</span> <input id="shapeName" class="field w-full" placeholder="Shape name"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Image / SVG</span> <input id="imageFile" type="file" accept="image/*,.svg" class="block w-full text-sm"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Width</span> <input id="shapeWidth" type="number" min="16" max="1200" class="field w-full"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Height</span> <input id="shapeHeight" type="number" min="16" max="1200" class="field w-full"/></label> <label class="space-y-1 col-span-2"><span class="block text-xs font-semibold text-gray-500">Text placement</span> <select id="labelPlacement" class="field w-full"><option> </option><option> </option><option> </option><option> </option><option> </option></select></label> <label class="col-span-2 flex items-start gap-2 rounded-md border border-gray-200 bg-white px-2 py-2 text-sm"><input id="shapeShowInDiagram" type="checkbox" class="mt-0.5 h-4 w-4 rounded border-gray-300 text-blue-600"/> <span class="space-y-0.5"><span class="block font-semibold text-gray-700"> </span> <span class="block text-xs text-gray-500"> </span></span></label></div> <div class="flex flex-wrap gap-2"><button id="btnDefaultAnchors" class="btn">Use 8 default anchors</button> <button id="btnClearAnchors" class="btn">Clear anchors</button> <button id="btnSaveShape" class="btn btn-primary">Save shape</button></div> <div><div class="flex items-center justify-between mb-2"><h2 class="text-xs font-semibold uppercase tracking-wide text-gray-500">Anchors</h2> <span id="anchorCount" class="text-xs text-gray-500"></span></div> <div id="anchorList" class="space-y-1"></div></div></div></div></section></main></div>`);function zw(e,t){qe(t,!1),Gi(async()=>{try{await ha((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{await ha(`en`)}return Lw()}),Hi();var n=Rw(),r=L(n),i=L(r);Ie(4),j(r);var a=z(r,2),o=z(L(a),2),s=L(o),c=z(L(s),2),l=L(c),u=z(L(l),8),d=z(L(u),2),f=L(d),p=L(f,!0);j(f),f.value=f.__value=`below`;var m=z(f),h=L(m,!0);j(m),m.value=m.__value=`above`;var g=z(m),_=L(g,!0);j(g),g.value=g.__value=`right`;var v=z(g),y=L(v,!0);j(v),v.value=v.__value=`left`;var b=z(v),x=L(b,!0);j(b),b.value=b.__value=`center`,j(d),j(u);var S=z(u,2),C=z(L(S),2),w=L(C),T=L(w,!0);j(w);var E=z(w,2),D=L(E,!0);j(E),j(C),j(S),j(l),Ie(4),j(c),j(s),j(o),j(a),j(n),B((e,t,n,r,i,a,o)=>{G(p,e),G(h,t),G(_,n),G(y,r),G(x,i),G(T,a),G(D,o)},[()=>Y(`shape_editor.label_placement.below`),()=>Y(`shape_editor.label_placement.above`),()=>Y(`shape_editor.label_placement.right`),()=>Y(`shape_editor.label_placement.left`),()=>Y(`shape_editor.label_placement.center`),()=>Y(`shape_editor.show_in_diagram_label`),()=>Y(`shape_editor.show_in_diagram_hint`)]),H(`click`,i,()=>history.back()),W(e,n),Je()}Pr([`click`]);var Bw=I({tasks:[],notes:[],links:[]}),Vw=!1,Hw=null;async function Uw(){try{let e=await fetch(`/api/survival-kit`);if(e.ok){let t=await e.json();Bw.tasks=Array.isArray(t.tasks)?t.tasks:[],Bw.notes=Array.isArray(t.notes)?t.notes:[],Bw.links=Array.isArray(t.links)?t.links:[]}}catch{}finally{Vw=!0}}async function Ww(){try{await fetch(`/api/survival-kit`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({tasks:Bw.tasks,notes:Bw.notes,links:Bw.links})})}catch{}}function Gw(){Vw&&(Hw&&clearTimeout(Hw),Hw=setTimeout(()=>{Hw=null,Ww()},400))}var Kw=U(`<button type="button"> </button>`),qw=U(`<p class="sk-empty svelte-lo2xyl"> </p>`),Jw=U(`<div><button type="button" aria-label="toggle"></button> <span class="sk-task-text svelte-lo2xyl"> </span> <span class="sk-task-tag svelte-lo2xyl"> </span> <button type="button" class="sk-task-del svelte-lo2xyl">✕</button></div>`),Yw=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-add-bar svelte-lo2xyl"><input type="text" class="svelte-lo2xyl"/> <select class="svelte-lo2xyl"><option> </option><option> </option><option> </option></select> <button type="button" class="sk-add-btn svelte-lo2xyl">+</button></div> <div class="sk-filters svelte-lo2xyl"></div> <div class="sk-tasks svelte-lo2xyl"><!></div>`,1);function Xw(e,t){qe(t,!0);let n=P(``),r=P(`normal`),i=P(`all`),a=[{key:`all`,label:()=>Y(`survival.tasks_filter_all`)},{key:`todo`,label:()=>Y(`survival.tasks_filter_todo`)},{key:`done`,label:()=>Y(`survival.tasks_filter_done`)},{key:`urgent`,label:()=>Y(`survival.tasks_filter_urgent`)},{key:`normal`,label:()=>Y(`survival.tasks_filter_normal`)},{key:`later`,label:()=>Y(`survival.tasks_filter_later`)}];function o(e){return Y(`survival.tasks_priority_${e}`)}let s=N(()=>Bw.tasks.filter(e=>V(i)===`todo`?!e.done:V(i)===`done`?e.done:V(i)===`urgent`||V(i)===`normal`||V(i)===`later`?e.priority===V(i):!0));function c(){let e=V(n).trim();e&&(Bw.tasks.unshift({id:Date.now(),text:e,priority:V(r),done:!1}),F(n,``),Gw())}function l(e){let t=Bw.tasks.find(t=>t.id===e);t&&(t.done=!t.done),Gw()}function u(e){Bw.tasks=Bw.tasks.filter(t=>t.id!==e),Gw()}var d=Yw(),f=R(d),p=L(f),m=L(p,!0);Ie(),j(p);var h=z(p,2),g=L(h,!0);j(h),j(f);var _=z(f,2),v=L(_);Di(v);var y=z(v,2),b=L(y),x=L(b,!0);j(b),b.value=b.__value=`normal`;var S=z(b),C=L(S,!0);j(S),S.value=S.__value=`urgent`;var w=z(S),T=L(w,!0);j(w),w.value=w.__value=`later`,j(y);var E=z(y,2);j(_);var D=z(_,2);q(D,21,()=>a,Xr,(e,t)=>{var n=Kw();let r;var a=L(n,!0);j(n),B(e=>{r=gi(n,1,`svelte-lo2xyl`,null,r,{active:V(i)===V(t).key}),G(a,e)},[()=>V(t).label()]),H(`click`,n,()=>F(i,V(t).key,!0)),W(e,n)}),j(D);var ee=z(D,2),te=L(ee),O=e=>{var t=qw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.tasks_empty`)]),W(e,t)},ne=e=>{var t=Wr();q(R(t),17,()=>V(s),e=>e.id,(e,t)=>{var n=Jw();let r;var i=L(n);let a;var s=z(i,2),c=L(s,!0);j(s);var d=z(s,2),f=L(d,!0);j(d);var p=z(d,2);j(n),B((e,o)=>{r=gi(n,1,`sk-task sk-task--${V(t).priority??``}`,`svelte-lo2xyl`,r,{done:V(t).done}),a=gi(i,1,`sk-check svelte-lo2xyl`,null,a,{checked:V(t).done}),G(c,V(t).text),G(f,e),J(p,`title`,o)},[()=>o(V(t).priority),()=>Y(`survival.tasks_delete_title`)]),H(`click`,i,()=>l(V(t).id)),H(`click`,p,()=>u(V(t).id)),W(e,n)}),W(e,t)};K(te,e=>{V(s).length===0?e(O):e(ne,-1)}),j(ee),B((e,t,n,r,i,a)=>{G(m,e),G(g,t),J(v,`placeholder`,n),G(x,r),G(C,i),G(T,a)},[()=>Y(`survival.tasks_title`),()=>Y(`survival.tasks_subtitle`),()=>Y(`survival.tasks_input_placeholder`),()=>Y(`survival.tasks_priority_normal`),()=>Y(`survival.tasks_priority_urgent`),()=>Y(`survival.tasks_priority_later`)]),H(`keydown`,v,e=>e.key===`Enter`&&c()),Ni(v,()=>V(n),e=>F(n,e)),xi(y,()=>V(r),e=>F(r,e)),H(`click`,E,c),W(e,d),Je()}Pr([`keydown`,`click`]);var Zw=[`t-green`,`t-violet`,`t-amber`,`t-sky`,`t-rose`,`t-teal`],Qw=U(`<div class="sk-modal-backdrop svelte-1rcj86" role="presentation"><div class="sk-modal svelte-1rcj86" role="dialog" aria-modal="true"><h3 class="sk-modal-title svelte-1rcj86"> </h3> <div class="sk-modal-body svelte-1rcj86"><!></div> <div class="sk-modal-actions svelte-1rcj86"><button type="button" class="sk-btn svelte-1rcj86"> </button> <button type="button"> </button></div></div></div>`);function $w(e,t){qe(t,!0);let n=Wi(t,`open`,3,!1),r=Wi(t,`title`,3,``),i=Wi(t,`confirmLabel`,19,()=>Y(`common.save`)),a=Wi(t,`danger`,3,!1);function o(e){e.target===e.currentTarget&&t.onClose()}function s(e){e.key===`Escape`&&t.onClose()}var c=Wr(),l=R(c),u=e=>{var n=Qw(),c=L(n),l=L(c),u=L(l,!0);j(l);var d=z(l,2);oi(L(d),()=>t.children),j(d);var f=z(d,2),p=L(f),m=L(p,!0);j(p);var h=z(p,2);let g;var _=L(h,!0);j(h),j(f),j(c),j(n),B(e=>{G(u,r()),G(m,e),g=gi(h,1,`sk-btn sk-btn--primary svelte-1rcj86`,null,g,{"sk-btn--danger":a()}),G(_,i())},[()=>Y(`common.cancel`)]),H(`click`,n,o),H(`keydown`,n,s),H(`click`,p,function(...e){t.onClose?.apply(this,e)}),H(`click`,h,function(...e){t.onConfirm?.apply(this,e)}),W(e,n)};K(l,e=>{n()&&e(u)}),W(e,c),Je()}Pr([`click`,`keydown`]);var eT=U(`<p class="sk-empty svelte-hpbata"> </p>`),tT=U(`<strong> </strong>`),nT=U(`<p> </p>`),rT=U(`<div class="sk-pre-wrap svelte-hpbata"><pre> </pre> <button type="button" class="sk-copy svelte-hpbata"> </button></div>`),iT=U(`<li> </li>`),aT=U(`<ul></ul>`),oT=U(`<th> </th>`),sT=U(`<td> </td>`),cT=U(`<tr></tr>`),lT=U(`<div class="sk-table-wrap svelte-hpbata"><table><thead><tr></tr></thead><tbody></tbody></table></div>`),uT=U(`<div class="sk-bloc svelte-hpbata"><div class="sk-bloc-content svelte-hpbata"><!></div> <div class="sk-bloc-actions svelte-hpbata"><button type="button" class="sk-mini svelte-hpbata">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-hpbata">✕</button></div></div>`),dT=U(`<div><div class="sk-note-head svelte-hpbata"><h3 class="svelte-hpbata"> </h3> <div class="sk-note-actions svelte-hpbata"><button type="button" class="sk-mini svelte-hpbata">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-hpbata">✕</button></div> <button type="button" class="sk-toggle svelte-hpbata" aria-label="toggle"><svg viewBox="0 0 10 6" width="10" height="6"><path d="M1 1 L5 5 L9 1" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div> <div class="sk-note-body svelte-hpbata"><!> <div class="sk-note-foot svelte-hpbata"><button type="button" class="sk-add-bloc svelte-hpbata"> </button></div></div></div>`),fT=U(`<option> </option>`),pT=U(`<label for="sk-note-titre"> </label> <input id="sk-note-titre" type="text"/> <label for="sk-note-color"> </label> <select id="sk-note-color"></select>`,1),mT=U(`<input id="sk-bloc-content" type="text"/>`),hT=U(`<textarea id="sk-bloc-content" rows="6"></textarea>`),gT=U(`<label for="sk-bloc-type"> </label> <select id="sk-bloc-type"><option> </option><option> </option><option> </option><option> </option><option> </option></select> <label for="sk-bloc-content"> </label> <!>`,1),_T=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-toolbar svelte-hpbata"><button type="button" class="sk-tool svelte-hpbata"> </button> <button type="button" class="sk-tool svelte-hpbata"> </button> <button type="button" class="sk-tool sk-tool--add svelte-hpbata"> </button></div> <div><!> <!></div> <!> <!>`,1);function vT(e,t){qe(t,!0);let n=P(!1),r=P(I({})),i=P(null),a=P(!1),o=P(-1),s=P(``),c=P(`t-green`),l=P(!1),u=P(-1),d=P(-1),f=P(`p`),p=P(``),m={"t-green":`survival.color_green`,"t-violet":`survival.color_violet`,"t-amber":`survival.color_amber`,"t-sky":`survival.color_sky`,"t-rose":`survival.color_rose`,"t-teal":`survival.color_teal`},h=N(()=>Bw.notes.length>0&&Bw.notes.every(e=>V(r)[e.id]));function g(e){V(r)[e]=!V(r)[e]}function _(){if(V(h))F(r,{},!0);else{let e={};Bw.notes.forEach(t=>e[t.id]=!0),F(r,e,!0)}}function v(){F(o,-1),F(s,``),F(c,`t-green`),F(a,!0)}function y(e){F(o,e,!0),F(s,Bw.notes[e].titre,!0),F(c,Bw.notes[e].theme,!0),F(a,!0)}function b(){let e=V(s).trim();if(e){if(V(o)===-1){let t=Date.now();Bw.notes.push({id:t,theme:V(c),titre:e,blocs:[]}),V(r)[t]=!0}else Bw.notes[V(o)].titre=e,Bw.notes[V(o)].theme=V(c);Gw(),F(a,!1)}}async function x(e){await t.confirmDelete(Y(`survival.confirm_del_note_title`),Y(`survival.confirm_del_note_msg`))&&(Bw.notes.splice(e,1),Gw())}function S(e){return e.type===`ul`?e.items.join(`
286
+ `;let[s,c,u]=o.querySelectorAll(`input`);s.addEventListener(`input`,()=>{t.id=s.value.trim()||`p${n+1}`,b()}),c.addEventListener(`input`,()=>{t.x=l(Number(c.value)/100),b()}),u.addEventListener(`input`,()=>{t.y=l(Number(u.value)/100),b()}),o.querySelector(`button`).addEventListener(`click`,()=>{i.anchors=i.anchors.filter(e=>e!==t),b()}),e.anchorList.appendChild(o)})}function x(t,n){let r=e.previewStage.getBoundingClientRect();t.x=l((n.clientX-r.left)/r.width),t.y=l((n.clientY-r.top)/r.height)}let S=[],C=(e,t,n,r)=>{e.addEventListener(t,n,r),S.push(()=>e.removeEventListener(t,n,r))};return C(e.previewStage,`pointermove`,e=>{if(!a||!i)return;let t=i.anchors.find(e=>e.id===a);t&&(x(t,e),b())}),C(window,`pointerup`,()=>{a=null}),C(e.previewStage,`click`,e=>{if(e.target.closest(`.anchor-dot`)||a||!i)return;let t={id:`p${(i.anchors||[]).length+1}`,x:.5,y:.5};x(t,e),i.anchors=[...i.anchors||[],t],b()}),C(document.getElementById(`btnAddLibrary`),`click`,async()=>{let e={id:o(`lib`),name:`New library`,shapes:[]};t.libraries.push(e),n=e.id,r=null,i=h(),g(),await m()}),C(e.librarySelect,`change`,()=>{n=e.librarySelect.value,r=s()?.shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g()}),C(e.libraryName,`change`,async()=>{let t=s();t&&(t.name=e.libraryName.value.trim()||t.name,_(),await m())}),C(document.getElementById(`btnNewShape`),`click`,()=>{r=null,i=h(),g()}),C(document.getElementById(`btnDeleteShape`),`click`,async()=>{let e=s();!e||!r||(e.shapes=e.shapes.filter(e=>e.id!==r),r=e.shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g(),await m())}),C(document.getElementById(`btnDefaultAnchors`),`click`,()=>{i.anchors=structuredClone(Aw),b()}),C(document.getElementById(`btnClearAnchors`),`click`,()=>{i.anchors=[],b()}),C(document.getElementById(`btnSaveShape`),`click`,async()=>{let t=s();if(!t||!i||!i.imageSrc)return;i.name=e.shapeName.value.trim()||`Untitled shape`,i.width=Math.max(16,Math.min(1200,Math.round(Number(e.shapeWidth.value)||65))),i.height=Math.max(16,Math.min(1200,Math.round(Number(e.shapeHeight.value)||65))),i.labelPlacement=u(e.labelPlacement.value),i.showInDiagram=e.shapeShowInDiagram.checked;let n=t.shapes.findIndex(e=>e.id===i.id);n>=0?t.shapes[n]=structuredClone(i):t.shapes.push(structuredClone(i)),r=i.id,g(),await m()}),[`shapeName`,`shapeWidth`,`shapeHeight`,`labelPlacement`,`shapeShowInDiagram`].forEach(t=>{C(document.getElementById(t),`input`,()=>{i.name=e.shapeName.value,i.width=Number(e.shapeWidth.value)||65,i.height=Number(e.shapeHeight.value)||65,i.labelPlacement=u(e.labelPlacement.value),i.showInDiagram=e.shapeShowInDiagram.checked})}),C(e.imageFile,`change`,async()=>{let t=e.imageFile.files&&e.imageFile.files[0];if(!t||!i)return;let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=n,r.readAsDataURL(t)}),r=(t.name.split(`.`).pop()||`png`).toLowerCase().replace(/[^a-z0-9]/g,``)||`png`,a=t.name.replace(/\.[^.]+$/,``).slice(0,60),o=await(await fetch(`/api/images/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:n,ext:r,name:a})})).json();i.imageSrc=`/images/${o.filename}`,(!e.shapeName.value||e.shapeName.value===`New shape`)&&(i.name=a||i.name),y()}),p(),()=>{S.forEach(e=>e()),S.length=0}}var Bw=U(`<div class="ld-shape-editor h-screen overflow-hidden bg-gray-50 text-gray-900"><header class="h-12 border-b border-gray-200 bg-white flex items-center gap-2 px-3"><button class="btn">← Back</button> <h1 class="text-sm font-semibold">Shape editor</h1> <span id="saveState" class="ml-auto text-xs text-gray-500"></span></header> <main class="h-[calc(100vh-3rem)] grid grid-cols-[17rem_1fr] overflow-hidden"><aside class="border-r border-gray-200 bg-white flex flex-col min-h-0"><div class="p-3 border-b border-gray-200 space-y-2"><label class="block text-xs font-semibold text-gray-500">Library</label> <div class="flex gap-2"><select id="librarySelect" class="field flex-1"></select> <button id="btnAddLibrary" class="btn">+</button></div> <input id="libraryName" class="field w-full" placeholder="Library name"/></div> <div class="p-3 border-b border-gray-200 flex gap-2"><button id="btnNewShape" class="btn btn-primary flex-1">New shape</button> <button id="btnDeleteShape" class="btn btn-danger">Delete</button></div> <div id="shapeList" class="flex-1 overflow-y-auto p-2 space-y-1"></div></aside> <section class="min-w-0 min-h-0 overflow-y-auto p-5"><div class="grid grid-cols-[minmax(20rem,34rem)_minmax(20rem,1fr)] gap-5 items-start"><div class="space-y-3"><div id="previewStage"><img id="previewImage" alt=""/></div> <p class="text-xs text-gray-500">Click on the image to add an anchor. Drag anchors to refine their
287
+ position.</p></div> <div class="space-y-4"><div class="grid grid-cols-2 gap-3"><label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Shape name</span> <input id="shapeName" class="field w-full" placeholder="Shape name"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Image / SVG</span> <input id="imageFile" type="file" accept="image/*,.svg" class="block w-full text-sm"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Width</span> <input id="shapeWidth" type="number" min="16" max="1200" class="field w-full"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Height</span> <input id="shapeHeight" type="number" min="16" max="1200" class="field w-full"/></label> <label class="space-y-1 col-span-2"><span class="block text-xs font-semibold text-gray-500">Text placement</span> <select id="labelPlacement" class="field w-full"><option> </option><option> </option><option> </option><option> </option><option> </option></select></label> <label class="col-span-2 flex items-start gap-2 rounded-md border border-gray-200 bg-white px-2 py-2 text-sm"><input id="shapeShowInDiagram" type="checkbox" class="mt-0.5 h-4 w-4 rounded border-gray-300 text-blue-600"/> <span class="space-y-0.5"><span class="block font-semibold text-gray-700"> </span> <span class="block text-xs text-gray-500"> </span></span></label></div> <div class="flex flex-wrap gap-2"><button id="btnDefaultAnchors" class="btn">Use 8 default anchors</button> <button id="btnClearAnchors" class="btn">Clear anchors</button> <button id="btnSaveShape" class="btn btn-primary">Save shape</button></div> <div><div class="flex items-center justify-between mb-2"><h2 class="text-xs font-semibold uppercase tracking-wide text-gray-500">Anchors</h2> <span id="anchorCount" class="text-xs text-gray-500"></span></div> <div id="anchorList" class="space-y-1"></div></div></div></div></section></main></div>`);function Vw(e,t){qe(t,!1),Gi(async()=>{try{await ha((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{await ha(`en`)}return zw()}),Hi();var n=Bw(),r=L(n),i=L(r);Ie(4),j(r);var a=z(r,2),o=z(L(a),2),s=L(o),c=z(L(s),2),l=L(c),u=z(L(l),8),d=z(L(u),2),f=L(d),p=L(f,!0);j(f),f.value=f.__value=`below`;var m=z(f),h=L(m,!0);j(m),m.value=m.__value=`above`;var g=z(m),_=L(g,!0);j(g),g.value=g.__value=`right`;var v=z(g),y=L(v,!0);j(v),v.value=v.__value=`left`;var b=z(v),x=L(b,!0);j(b),b.value=b.__value=`center`,j(d),j(u);var S=z(u,2),C=z(L(S),2),w=L(C),T=L(w,!0);j(w);var E=z(w,2),D=L(E,!0);j(E),j(C),j(S),j(l),Ie(4),j(c),j(s),j(o),j(a),j(n),B((e,t,n,r,i,a,o)=>{G(p,e),G(h,t),G(_,n),G(y,r),G(x,i),G(T,a),G(D,o)},[()=>Y(`shape_editor.label_placement.below`),()=>Y(`shape_editor.label_placement.above`),()=>Y(`shape_editor.label_placement.right`),()=>Y(`shape_editor.label_placement.left`),()=>Y(`shape_editor.label_placement.center`),()=>Y(`shape_editor.show_in_diagram_label`),()=>Y(`shape_editor.show_in_diagram_hint`)]),H(`click`,i,()=>history.back()),W(e,n),Je()}Pr([`click`]);var Hw=I({tasks:[],notes:[],links:[]}),Uw=!1,Ww=null;async function Gw(){try{let e=await fetch(`/api/survival-kit`);if(e.ok){let t=await e.json();Hw.tasks=Array.isArray(t.tasks)?t.tasks:[],Hw.notes=Array.isArray(t.notes)?t.notes:[],Hw.links=Array.isArray(t.links)?t.links:[]}}catch{}finally{Uw=!0}}async function Kw(){try{await fetch(`/api/survival-kit`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({tasks:Hw.tasks,notes:Hw.notes,links:Hw.links})})}catch{}}function qw(){Uw&&(Ww&&clearTimeout(Ww),Ww=setTimeout(()=>{Ww=null,Kw()},400))}var Jw=U(`<button type="button"> </button>`),Yw=U(`<p class="sk-empty svelte-lo2xyl"> </p>`),Xw=U(`<div><button type="button" aria-label="toggle"></button> <span class="sk-task-text svelte-lo2xyl"> </span> <span class="sk-task-tag svelte-lo2xyl"> </span> <button type="button" class="sk-task-del svelte-lo2xyl">✕</button></div>`),Zw=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-add-bar svelte-lo2xyl"><input type="text" class="svelte-lo2xyl"/> <select class="svelte-lo2xyl"><option> </option><option> </option><option> </option></select> <button type="button" class="sk-add-btn svelte-lo2xyl">+</button></div> <div class="sk-filters svelte-lo2xyl"></div> <div class="sk-tasks svelte-lo2xyl"><!></div>`,1);function Qw(e,t){qe(t,!0);let n=P(``),r=P(`normal`),i=P(`all`),a=[{key:`all`,label:()=>Y(`survival.tasks_filter_all`)},{key:`todo`,label:()=>Y(`survival.tasks_filter_todo`)},{key:`done`,label:()=>Y(`survival.tasks_filter_done`)},{key:`urgent`,label:()=>Y(`survival.tasks_filter_urgent`)},{key:`normal`,label:()=>Y(`survival.tasks_filter_normal`)},{key:`later`,label:()=>Y(`survival.tasks_filter_later`)}];function o(e){return Y(`survival.tasks_priority_${e}`)}let s=N(()=>Hw.tasks.filter(e=>V(i)===`todo`?!e.done:V(i)===`done`?e.done:V(i)===`urgent`||V(i)===`normal`||V(i)===`later`?e.priority===V(i):!0));function c(){let e=V(n).trim();e&&(Hw.tasks.unshift({id:Date.now(),text:e,priority:V(r),done:!1}),F(n,``),qw())}function l(e){let t=Hw.tasks.find(t=>t.id===e);t&&(t.done=!t.done),qw()}function u(e){Hw.tasks=Hw.tasks.filter(t=>t.id!==e),qw()}var d=Zw(),f=R(d),p=L(f),m=L(p,!0);Ie(),j(p);var h=z(p,2),g=L(h,!0);j(h),j(f);var _=z(f,2),v=L(_);Di(v);var y=z(v,2),b=L(y),x=L(b,!0);j(b),b.value=b.__value=`normal`;var S=z(b),C=L(S,!0);j(S),S.value=S.__value=`urgent`;var w=z(S),T=L(w,!0);j(w),w.value=w.__value=`later`,j(y);var E=z(y,2);j(_);var D=z(_,2);q(D,21,()=>a,Xr,(e,t)=>{var n=Jw();let r;var a=L(n,!0);j(n),B(e=>{r=gi(n,1,`svelte-lo2xyl`,null,r,{active:V(i)===V(t).key}),G(a,e)},[()=>V(t).label()]),H(`click`,n,()=>F(i,V(t).key,!0)),W(e,n)}),j(D);var ee=z(D,2),te=L(ee),O=e=>{var t=Yw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.tasks_empty`)]),W(e,t)},ne=e=>{var t=Wr();q(R(t),17,()=>V(s),e=>e.id,(e,t)=>{var n=Xw();let r;var i=L(n);let a;var s=z(i,2),c=L(s,!0);j(s);var d=z(s,2),f=L(d,!0);j(d);var p=z(d,2);j(n),B((e,o)=>{r=gi(n,1,`sk-task sk-task--${V(t).priority??``}`,`svelte-lo2xyl`,r,{done:V(t).done}),a=gi(i,1,`sk-check svelte-lo2xyl`,null,a,{checked:V(t).done}),G(c,V(t).text),G(f,e),J(p,`title`,o)},[()=>o(V(t).priority),()=>Y(`survival.tasks_delete_title`)]),H(`click`,i,()=>l(V(t).id)),H(`click`,p,()=>u(V(t).id)),W(e,n)}),W(e,t)};K(te,e=>{V(s).length===0?e(O):e(ne,-1)}),j(ee),B((e,t,n,r,i,a)=>{G(m,e),G(g,t),J(v,`placeholder`,n),G(x,r),G(C,i),G(T,a)},[()=>Y(`survival.tasks_title`),()=>Y(`survival.tasks_subtitle`),()=>Y(`survival.tasks_input_placeholder`),()=>Y(`survival.tasks_priority_normal`),()=>Y(`survival.tasks_priority_urgent`),()=>Y(`survival.tasks_priority_later`)]),H(`keydown`,v,e=>e.key===`Enter`&&c()),Ni(v,()=>V(n),e=>F(n,e)),xi(y,()=>V(r),e=>F(r,e)),H(`click`,E,c),W(e,d),Je()}Pr([`keydown`,`click`]);var $w=[`t-green`,`t-violet`,`t-amber`,`t-sky`,`t-rose`,`t-teal`],eT=U(`<div class="sk-modal-backdrop svelte-1rcj86" role="presentation"><div class="sk-modal svelte-1rcj86" role="dialog" aria-modal="true"><h3 class="sk-modal-title svelte-1rcj86"> </h3> <div class="sk-modal-body svelte-1rcj86"><!></div> <div class="sk-modal-actions svelte-1rcj86"><button type="button" class="sk-btn svelte-1rcj86"> </button> <button type="button"> </button></div></div></div>`);function tT(e,t){qe(t,!0);let n=Wi(t,`open`,3,!1),r=Wi(t,`title`,3,``),i=Wi(t,`confirmLabel`,19,()=>Y(`common.save`)),a=Wi(t,`danger`,3,!1);function o(e){e.target===e.currentTarget&&t.onClose()}function s(e){e.key===`Escape`&&t.onClose()}var c=Wr(),l=R(c),u=e=>{var n=eT(),c=L(n),l=L(c),u=L(l,!0);j(l);var d=z(l,2);oi(L(d),()=>t.children),j(d);var f=z(d,2),p=L(f),m=L(p,!0);j(p);var h=z(p,2);let g;var _=L(h,!0);j(h),j(f),j(c),j(n),B(e=>{G(u,r()),G(m,e),g=gi(h,1,`sk-btn sk-btn--primary svelte-1rcj86`,null,g,{"sk-btn--danger":a()}),G(_,i())},[()=>Y(`common.cancel`)]),H(`click`,n,o),H(`keydown`,n,s),H(`click`,p,function(...e){t.onClose?.apply(this,e)}),H(`click`,h,function(...e){t.onConfirm?.apply(this,e)}),W(e,n)};K(l,e=>{n()&&e(u)}),W(e,c),Je()}Pr([`click`,`keydown`]);var nT=U(`<p class="sk-empty svelte-hpbata"> </p>`),rT=U(`<strong> </strong>`),iT=U(`<p> </p>`),aT=U(`<div class="sk-pre-wrap svelte-hpbata"><pre> </pre> <button type="button" class="sk-copy svelte-hpbata"> </button></div>`),oT=U(`<li> </li>`),sT=U(`<ul></ul>`),cT=U(`<th> </th>`),lT=U(`<td> </td>`),uT=U(`<tr></tr>`),dT=U(`<div class="sk-table-wrap svelte-hpbata"><table><thead><tr></tr></thead><tbody></tbody></table></div>`),fT=U(`<div class="sk-bloc svelte-hpbata"><div class="sk-bloc-content svelte-hpbata"><!></div> <div class="sk-bloc-actions svelte-hpbata"><button type="button" class="sk-mini svelte-hpbata">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-hpbata">✕</button></div></div>`),pT=U(`<div><div class="sk-note-head svelte-hpbata"><h3 class="svelte-hpbata"> </h3> <div class="sk-note-actions svelte-hpbata"><button type="button" class="sk-mini svelte-hpbata">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-hpbata">✕</button></div> <button type="button" class="sk-toggle svelte-hpbata" aria-label="toggle"><svg viewBox="0 0 10 6" width="10" height="6"><path d="M1 1 L5 5 L9 1" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div> <div class="sk-note-body svelte-hpbata"><!> <div class="sk-note-foot svelte-hpbata"><button type="button" class="sk-add-bloc svelte-hpbata"> </button></div></div></div>`),mT=U(`<option> </option>`),hT=U(`<label for="sk-note-titre"> </label> <input id="sk-note-titre" type="text"/> <label for="sk-note-color"> </label> <select id="sk-note-color"></select>`,1),gT=U(`<input id="sk-bloc-content" type="text"/>`),_T=U(`<textarea id="sk-bloc-content" rows="6"></textarea>`),vT=U(`<label for="sk-bloc-type"> </label> <select id="sk-bloc-type"><option> </option><option> </option><option> </option><option> </option><option> </option></select> <label for="sk-bloc-content"> </label> <!>`,1),yT=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-toolbar svelte-hpbata"><button type="button" class="sk-tool svelte-hpbata"> </button> <button type="button" class="sk-tool svelte-hpbata"> </button> <button type="button" class="sk-tool sk-tool--add svelte-hpbata"> </button></div> <div><!> <!></div> <!> <!>`,1);function bT(e,t){qe(t,!0);let n=P(!1),r=P(I({})),i=P(null),a=P(!1),o=P(-1),s=P(``),c=P(`t-green`),l=P(!1),u=P(-1),d=P(-1),f=P(`p`),p=P(``),m={"t-green":`survival.color_green`,"t-violet":`survival.color_violet`,"t-amber":`survival.color_amber`,"t-sky":`survival.color_sky`,"t-rose":`survival.color_rose`,"t-teal":`survival.color_teal`},h=N(()=>Hw.notes.length>0&&Hw.notes.every(e=>V(r)[e.id]));function g(e){V(r)[e]=!V(r)[e]}function _(){if(V(h))F(r,{},!0);else{let e={};Hw.notes.forEach(t=>e[t.id]=!0),F(r,e,!0)}}function v(){F(o,-1),F(s,``),F(c,`t-green`),F(a,!0)}function y(e){F(o,e,!0),F(s,Hw.notes[e].titre,!0),F(c,Hw.notes[e].theme,!0),F(a,!0)}function b(){let e=V(s).trim();if(e){if(V(o)===-1){let t=Date.now();Hw.notes.push({id:t,theme:V(c),titre:e,blocs:[]}),V(r)[t]=!0}else Hw.notes[V(o)].titre=e,Hw.notes[V(o)].theme=V(c);qw(),F(a,!1)}}async function x(e){await t.confirmDelete(Y(`survival.confirm_del_note_title`),Y(`survival.confirm_del_note_msg`))&&(Hw.notes.splice(e,1),qw())}function S(e){return e.type===`ul`?e.items.join(`
288
288
  `):e.type===`table`?[e.headers.join(` | `),...e.rows.map(e=>e.join(` | `))].join(`
289
- `):e.content}function C(e){F(u,e,!0),F(d,-1),F(f,`p`),F(p,``),F(l,!0)}function w(e,t){F(u,e,!0),F(d,t,!0);let n=Bw.notes[e].blocs[t];F(f,n.type,!0),F(p,S(n),!0),F(l,!0)}function T(){let e=V(p);if(!e.trim())return null;if(V(f)===`ul`){let t=e.split(`
289
+ `):e.content}function C(e){F(u,e,!0),F(d,-1),F(f,`p`),F(p,``),F(l,!0)}function w(e,t){F(u,e,!0),F(d,t,!0);let n=Hw.notes[e].blocs[t];F(f,n.type,!0),F(p,S(n),!0),F(l,!0)}function T(){let e=V(p);if(!e.trim())return null;if(V(f)===`ul`){let t=e.split(`
290
290
  `).map(e=>e.trim()).filter(Boolean);return t.length?{type:`ul`,items:t}:null}if(V(f)===`table`){let t=e.split(`
291
- `).map(e=>e.trim()).filter(Boolean);return t.length?{type:`table`,headers:t[0].split(`|`).map(e=>e.trim()),rows:t.slice(1).map(e=>e.split(`|`).map(e=>e.trim()))}:null}return{type:V(f),content:e}}function E(){let e=T();e&&(V(d)===-1?Bw.notes[V(u)].blocs.push(e):Bw.notes[V(u)].blocs[V(d)]=e,Gw(),F(l,!1))}async function D(e,n){await t.confirmDelete(Y(`survival.confirm_del_bloc_title`),Y(`survival.irreversible`))&&(Bw.notes[e].blocs.splice(n,1),Gw())}async function ee(e,t){try{await navigator.clipboard.writeText(e),F(i,t,!0),setTimeout(()=>F(i,V(i)===t?null:V(i),!0),1500)}catch{}}let te=N(()=>V(f)===`ul`?Y(`survival.modal_bloc_placeholder_ul`):V(f)===`pre`?Y(`survival.modal_bloc_placeholder_pre`):V(f)===`table`?Y(`survival.modal_bloc_placeholder_table`):V(f)===`b`?Y(`survival.modal_bloc_placeholder_b`):Y(`survival.modal_bloc_placeholder_p`));var O=_T(),ne=R(O),re=L(ne),k=L(re,!0);Ie(),j(re);var ie=z(re,2),ae=L(ie,!0);j(ie),j(ne);var oe=z(ne,2),se=L(oe),ce=L(se,!0);j(se);var le=z(se,2),ue=L(le,!0);j(le);var de=z(le,2),fe=L(de,!0);j(de),j(oe);var pe=z(oe,2);let me;var he=L(pe),ge=e=>{var t=eT(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.notes_empty`)]),W(e,t)};K(he,e=>{Bw.notes.length===0&&e(ge)}),q(z(he,2),19,()=>Bw.notes,e=>e.id,(e,t,n)=>{let a=N(()=>!V(r)[V(t).id]);var o=dT();let s;var c=L(o),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d),p=z(f,2);j(d);var m=z(d,2);j(c);var h=z(c,2),_=L(h);q(_,17,()=>V(t).blocs,Xr,(e,r,a)=>{var o=uT(),s=L(o),c=L(s),l=e=>{var t=tT(),n=L(t,!0);j(t),B(()=>G(n,V(r).content)),W(e,t)},u=e=>{var t=nT(),n=L(t,!0);j(t),B(()=>G(n,V(r).content)),W(e,t)},d=e=>{let n=N(()=>`${V(t).id}-${a}`);var o=rT(),s=L(o),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(o),B(e=>{G(c,V(r).content),G(u,e)},[()=>V(i)===V(n)?Y(`survival.notes_btn_copied`):Y(`survival.notes_btn_copy`)]),H(`click`,l,()=>ee(V(r).content,V(n))),W(e,o)},f=e=>{var t=aT();q(t,21,()=>V(r).items,Xr,(e,t)=>{var n=iT(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(t),W(e,t)},p=e=>{var t=lT(),n=L(t),i=L(n),a=L(i);q(a,21,()=>V(r).headers,Xr,(e,t)=>{var n=oT(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(a),j(i);var o=z(i);q(o,21,()=>V(r).rows,Xr,(e,t)=>{var n=cT();q(n,21,()=>V(t),Xr,(e,t)=>{var n=sT(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(n),W(e,n)}),j(o),j(n),j(t),W(e,t)};K(c,e=>{V(r).type===`b`?e(l):V(r).type===`p`?e(u,1):V(r).type===`pre`?e(d,2):V(r).type===`ul`?e(f,3):V(r).type===`table`&&e(p,4)}),j(s);var m=z(s,2),h=L(m),g=z(h,2);j(m),j(o),H(`click`,h,()=>w(V(n),a)),H(`click`,g,()=>D(V(n),a)),W(e,o)});var v=z(_,2),b=L(v),S=L(b,!0);j(b),j(v),j(h),j(o),B(e=>{s=gi(o,1,`sk-note ${V(t).theme??``}`,`svelte-hpbata`,s,{collapsed:V(a)}),G(u,V(t).titre),G(S,e)},[()=>Y(`survival.notes_btn_add_bloc`)]),H(`click`,f,()=>y(V(n))),H(`click`,p,()=>x(V(n))),H(`click`,m,()=>g(V(t).id)),H(`click`,b,()=>C(V(n))),W(e,o)}),j(pe);var _e=z(pe,2);{let e=N(()=>V(o)===-1?Y(`survival.modal_note_title`):Y(`survival.modal_edit_note_title`)),t=N(()=>V(o)===-1?Y(`common.create`):Y(`common.save`));$w(_e,{get open(){return V(a)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:b,onClose:()=>F(a,!1),children:(e,t)=>{var n=pT(),r=R(n),i=L(r,!0);j(r);var a=z(r,2);Di(a);var o=z(a,2),l=L(o,!0);j(o);var u=z(o,2);q(u,21,()=>Zw,Xr,(e,t)=>{var n=fT(),r=L(n,!0);j(n);var i={};B(e=>{G(r,e),i!==(i=V(t))&&(n.value=(n.__value=V(t))??``)},[()=>Y(m[V(t)])]),W(e,n)}),j(u),B((e,t,n)=>{G(i,e),J(a,`placeholder`,t),G(l,n)},[()=>Y(`survival.modal_note_label_title`),()=>Y(`survival.modal_note_placeholder`),()=>Y(`survival.modal_label_color`)]),H(`keydown`,a,e=>e.key===`Enter`&&b()),Ni(a,()=>V(s),e=>F(s,e)),xi(u,()=>V(c),e=>F(c,e)),W(e,n)},$$slots:{default:!0}})}var ve=z(_e,2);{let e=N(()=>V(d)===-1?Y(`survival.modal_bloc_new`):Y(`survival.modal_bloc_edit`)),t=N(()=>Y(`common.save`));$w(ve,{get open(){return V(l)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:E,onClose:()=>F(l,!1),children:(e,t)=>{var n=gT(),r=R(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o),o.value=o.__value=`b`;var c=z(o),l=L(c,!0);j(c),c.value=c.__value=`p`;var u=z(c),d=L(u,!0);j(u),u.value=u.__value=`pre`;var m=z(u),h=L(m,!0);j(m),m.value=m.__value=`ul`;var g=z(m),_=L(g,!0);j(g),g.value=g.__value=`table`,j(a);var v=z(a,2),y=L(v,!0);j(v);var b=z(v,2),x=e=>{var t=mT();Di(t),B(()=>J(t,`placeholder`,V(te))),H(`keydown`,t,e=>e.key===`Enter`&&E()),Ni(t,()=>V(p),e=>F(p,e)),W(e,t)},S=e=>{var t=hT();yn(t),B(()=>J(t,`placeholder`,V(te))),Ni(t,()=>V(p),e=>F(p,e)),W(e,t)};K(b,e=>{V(f)===`b`?e(x):e(S,-1)}),B((e,t,n,r,a,o,c)=>{G(i,e),G(s,t),G(l,n),G(d,r),G(h,a),G(_,o),G(y,c)},[()=>Y(`survival.modal_bloc_label_type`),()=>Y(`survival.modal_bloc_type_b`),()=>Y(`survival.modal_bloc_type_p`),()=>Y(`survival.modal_bloc_type_pre`),()=>Y(`survival.modal_bloc_type_ul`),()=>Y(`survival.modal_bloc_type_table`),()=>Y(`survival.modal_bloc_label_content`)]),xi(a,()=>V(f),e=>F(f,e)),W(e,n)},$$slots:{default:!0}})}B((e,t,r,i,a)=>{G(k,e),G(ae,t),G(ce,r),G(ue,i),G(fe,a),me=gi(pe,1,`sk-notes svelte-hpbata`,null,me,{"edit-mode":V(n)})},[()=>Y(`survival.notes_title`),()=>Y(`survival.notes_subtitle`),()=>V(n)?Y(`survival.btn_read_mode`):Y(`survival.btn_edit_mode`),()=>V(h)?Y(`survival.btn_collapse_all`):Y(`survival.btn_expand_all`),()=>Y(`survival.notes_btn_add`)]),H(`click`,se,()=>F(n,!V(n))),H(`click`,le,_),H(`click`,de,v),W(e,O),Je()}Pr([`click`,`keydown`]);var yT=U(`<p class="sk-empty svelte-1j811iq"> </p>`),bT=U(`<span class="sk-link-desc svelte-1j811iq"> </span>`),xT=U(`<a target="_blank" rel="noopener" class="sk-link svelte-1j811iq"><span class="sk-link-text svelte-1j811iq"><span class="sk-link-name svelte-1j811iq"> </span><!></span> <span class="sk-arrow svelte-1j811iq">↗</span> <span class="sk-link-actions svelte-1j811iq"><button type="button" class="sk-mini svelte-1j811iq">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-1j811iq">✕</button></span></a>`),ST=U(`<section><div class="sk-cat-head svelte-1j811iq"><h3 class="svelte-1j811iq"> </h3> <div class="sk-cat-actions svelte-1j811iq"><button type="button" class="sk-mini svelte-1j811iq">+</button> <button type="button" class="sk-mini sk-mini--del svelte-1j811iq">✕</button></div> <button type="button" class="sk-toggle svelte-1j811iq" aria-label="toggle"><svg viewBox="0 0 10 6" width="10" height="6"><path d="M1 1 L5 5 L9 1" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div> <div class="sk-links svelte-1j811iq"></div></section>`),CT=U(`<option> </option>`),wT=U(`<label for="sk-cat-name"> </label> <input id="sk-cat-name" type="text"/> <label for="sk-cat-color"> </label> <select id="sk-cat-color"></select>`,1),TT=U(`<label for="sk-link-nom"> </label> <input id="sk-link-nom" type="text"/> <label for="sk-link-desc"> </label> <input id="sk-link-desc" type="text"/> <label for="sk-link-url"> </label> <input id="sk-link-url" type="text" placeholder="https://…"/>`,1),ET=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-toolbar svelte-1j811iq"><button type="button" class="sk-tool svelte-1j811iq"> </button> <button type="button" class="sk-tool svelte-1j811iq"> </button> <button type="button" class="sk-tool sk-tool--add svelte-1j811iq"> </button></div> <div><!> <!></div> <!> <!>`,1);function DT(e,t){qe(t,!0);let n=P(!1),r=P(I({})),i=P(!1),a=P(``),o=P(`t-green`),s=P(!1),c=P(-1),l=P(-1),u=P(``),d=P(``),f=P(``),p={"t-green":`survival.color_green`,"t-violet":`survival.color_violet`,"t-amber":`survival.color_amber`,"t-sky":`survival.color_sky`,"t-rose":`survival.color_rose`,"t-teal":`survival.color_teal`},m=N(()=>Bw.links.length>0&&Bw.links.every(e=>V(r)[e.titre]));function h(e){V(r)[e]=!V(r)[e]}function g(){if(V(m))F(r,{},!0);else{let e={};Bw.links.forEach(t=>e[t.titre]=!0),F(r,e,!0)}}function _(){F(a,``),F(o,`t-green`),F(i,!0)}function v(){let e=V(a).trim();e&&(Bw.links.push({theme:V(o),titre:e,liens:[]}),Gw(),F(i,!1))}async function y(e){Bw.links[e],await t.confirmDelete(Y(`survival.confirm_del_cat_title`),Y(`survival.confirm_del_cat_msg`))&&(Bw.links.splice(e,1),Gw())}function b(e){F(c,e,!0),F(l,-1),F(u,``),F(d,``),F(f,``),F(s,!0)}function x(e,t,n){e.preventDefault();let r=Bw.links[t].liens[n];F(c,t,!0),F(l,n,!0),F(u,r.nom,!0),F(d,r.desc,!0),F(f,r.url,!0),F(s,!0)}function S(){let e=V(u).trim(),t=V(f).trim();if(!e||!t)return;let n={nom:e,desc:V(d).trim(),url:t};V(l)===-1?Bw.links[V(c)].liens.push(n):Bw.links[V(c)].liens[V(l)]=n,Gw(),F(s,!1)}async function C(e,n,r){e.preventDefault(),await t.confirmDelete(Y(`survival.confirm_del_link_title`),Y(`survival.irreversible`))&&(Bw.links[n].liens.splice(r,1),Gw())}var w=ET(),T=R(w),E=L(T),D=L(E,!0);Ie(),j(E);var ee=z(E,2),te=L(ee,!0);j(ee),j(T);var O=z(T,2),ne=L(O),re=L(ne,!0);j(ne);var k=z(ne,2),ie=L(k,!0);j(k);var ae=z(k,2),oe=L(ae,!0);j(ae),j(O);var se=z(O,2);let ce;var le=L(se),ue=e=>{var t=yT(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.links_empty`)]),W(e,t)};K(le,e=>{Bw.links.length===0&&e(ue)}),q(z(le,2),19,()=>Bw.links,(e,t)=>e.titre+t,(e,t,n)=>{let i=N(()=>!V(r)[V(t).titre]);var a=ST();let o;var s=L(a),c=L(s),l=L(c,!0);j(c);var u=z(c,2),d=L(u),f=z(d,2);j(u);var p=z(u,2);j(s);var m=z(s,2);q(m,21,()=>V(t).liens,Xr,(e,t,r)=>{var i=xT(),a=L(i),o=L(a),s=L(o,!0);j(o);var c=z(o),l=e=>{var n=bT(),r=L(n);j(n),B(()=>G(r,`— ${V(t).desc??``}`)),W(e,n)};K(c,e=>{V(t).desc&&e(l)}),j(a);var u=z(a,4),d=L(u),f=z(d,2);j(u),j(i),B((e,n)=>{J(i,`href`,V(t).url),G(s,V(t).nom),J(d,`title`,e),J(f,`title`,n)},[()=>Y(`survival.links_edit_link_title`),()=>Y(`survival.links_del_link_title`)]),H(`click`,d,e=>x(e,V(n),r)),H(`click`,f,e=>C(e,V(n),r)),W(e,i)}),j(m),j(a),B((e,n)=>{o=gi(a,1,`sk-cat ${V(t).theme??``}`,`svelte-1j811iq`,o,{collapsed:V(i)}),G(l,V(t).titre),J(d,`title`,e),J(f,`title`,n)},[()=>Y(`survival.links_add_link_title`),()=>Y(`survival.links_del_cat_title`)]),H(`click`,d,()=>b(V(n))),H(`click`,f,()=>y(V(n))),H(`click`,p,()=>h(V(t).titre)),W(e,a)}),j(se);var de=z(se,2);{let e=N(()=>Y(`survival.modal_cat_title`)),t=N(()=>Y(`common.add`));$w(de,{get open(){return V(i)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:v,onClose:()=>F(i,!1),children:(e,t)=>{var n=wT(),r=R(n),i=L(r,!0);j(r);var s=z(r,2);Di(s);var c=z(s,2),l=L(c,!0);j(c);var u=z(c,2);q(u,21,()=>Zw,Xr,(e,t)=>{var n=CT(),r=L(n,!0);j(n);var i={};B(e=>{G(r,e),i!==(i=V(t))&&(n.value=(n.__value=V(t))??``)},[()=>Y(p[V(t)])]),W(e,n)}),j(u),B((e,t,n)=>{G(i,e),J(s,`placeholder`,t),G(l,n)},[()=>Y(`survival.modal_cat_label_name`),()=>Y(`survival.modal_cat_placeholder_name`),()=>Y(`survival.modal_label_color`)]),H(`keydown`,s,e=>e.key===`Enter`&&v()),Ni(s,()=>V(a),e=>F(a,e)),xi(u,()=>V(o),e=>F(o,e)),W(e,n)},$$slots:{default:!0}})}var fe=z(de,2);{let e=N(()=>V(l)===-1?Y(`survival.modal_link_title`):Y(`survival.modal_edit_link_title`)),t=N(()=>V(l)===-1?Y(`common.add`):Y(`common.save`));$w(fe,{get open(){return V(s)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:S,onClose:()=>F(s,!1),children:(e,t)=>{var n=TT(),r=R(n),i=L(r,!0);j(r);var a=z(r,2);Di(a);var o=z(a,2),s=L(o,!0);j(o);var c=z(o,2);Di(c);var l=z(c,2),p=L(l,!0);j(l);var m=z(l,2);Di(m),B((e,t,n,r,o)=>{G(i,e),J(a,`placeholder`,t),G(s,n),J(c,`placeholder`,r),G(p,o)},[()=>Y(`survival.modal_link_label_name`),()=>Y(`survival.modal_link_placeholder_name`),()=>Y(`survival.modal_link_label_desc`),()=>Y(`survival.modal_link_placeholder_desc`),()=>Y(`survival.modal_link_label_url`)]),Ni(a,()=>V(u),e=>F(u,e)),Ni(c,()=>V(d),e=>F(d,e)),H(`keydown`,m,e=>e.key===`Enter`&&S()),Ni(m,()=>V(f),e=>F(f,e)),W(e,n)},$$slots:{default:!0}})}B((e,t,r,i,a)=>{G(D,e),G(te,t),G(re,r),G(ie,i),G(oe,a),ce=gi(se,1,`sk-cats svelte-1j811iq`,null,ce,{"edit-mode":V(n)})},[()=>Y(`survival.links_title`),()=>Y(`survival.links_subtitle`),()=>V(n)?Y(`survival.btn_read_mode`):Y(`survival.btn_edit_mode`),()=>V(m)?Y(`survival.btn_collapse_all`):Y(`survival.btn_expand_all`),()=>Y(`survival.links_btn_add_cat`)]),H(`click`,ne,()=>F(n,!V(n))),H(`click`,k,g),H(`click`,ae,_),W(e,w),Je()}Pr([`click`,`keydown`]);var OT=U(`<button class="ghost-button"><i class="fa-solid fa-cloud"></i></button> <button title="Toggle dark mode" class="ghost-button" aria-label="Toggle dark mode"> </button>`,1),kT=U(`<p class="sk-loading svelte-ha6eja"> </p>`),AT=U(`<div class="sk-grid svelte-ha6eja"><section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section> <section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section> <section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section></div>`),jT=U(`<!> <div class="app-shell sk-root svelte-ha6eja"><div class="sk-menu-trigger svelte-ha6eja" role="presentation"></div> <div><!></div> <!></div> <!>`,1);function MT(e,t){qe(t,!0);let n=P(null),r=P(!1),i=P(!1),a=P(!1),o=P(!1);function s(e){F(o,e<=(V(o)?84:10))}kn(()=>{let e=e=>s(e.clientY);return window.addEventListener(`mousemove`,e),()=>window.removeEventListener(`mousemove`,e)});async function c(e,t){return V(n).show({title:e,message:t,confirmLabel:Y(`survival.irreversible_delete`),cancelLabel:Y(`common.cancel`),danger:!0})}function l(e){F(i,e,!0),document.documentElement.classList.toggle(`dark`,e)}function u(){let e=!1;try{let t=localStorage.getItem(`ld-dark`);e=t===null?window.matchMedia(`(prefers-color-scheme: dark)`).matches:t===`true`}catch{}l(e)}function d(){l(!V(i));try{localStorage.setItem(`ld-dark`,String(V(i)))}catch{}}Gi(async()=>{u();try{await ha((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}await Uw(),F(r,!0)});var f=jT(),p=R(f);Vi(ad(p,{}),e=>F(n,e,!0),()=>V(n));var m=z(p,2),h=L(m),g=z(h,2);let _;var v=L(g);{let e=e=>{var t=OT(),n=R(t),r=z(n,2),o=L(r,!0);j(r),B((e,t)=>{J(n,`title`,e),J(n,`aria-label`,t),G(o,V(i)?`☀`:`☾`)},[()=>Y(`nav.word_cloud`),()=>Y(`nav.word_cloud`)]),H(`click`,n,()=>F(a,!0)),H(`click`,r,d),W(e,t)},t=N(()=>Y(`survival.title`)),n=N(()=>Y(`survival.subtitle`));so(v,{get title(){return V(t)},get subtitle(){return V(n)},actions:e,$$slots:{actions:!0}})}j(g);var y=z(g,2),b=e=>{var t=kT(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},x=e=>{var t=AT(),n=L(t),r=L(n);Xw(L(r),{}),j(r),j(n);var i=z(n,2),a=L(i);vT(L(a),{confirmDelete:c}),j(a),j(i);var o=z(i,2),s=L(o);DT(L(s),{confirmDelete:c}),j(s),j(o),j(t),W(e,t)};K(y,e=>{V(r)?e(x,-1):e(b)}),j(m),aw(z(m,2),{get open(){return V(a)},onclose:()=>F(a,!1)}),B(()=>_=gi(g,1,`sk-menu-drawer svelte-ha6eja`,null,_,{revealed:V(o)})),Nr(`mouseenter`,h,()=>F(o,!0)),W(e,f),Je()}Pr([`click`]);var NT=`git-integration-config`,PT=`git-integration-status`,FT=`git-integration-save`,IT=`/admin#git-integration`,LT=120*1e3,RT=!1,zT=!1;function BT(e){let t=Date.parse(e);return Number.isFinite(t)&&Date.now()-t<LT}function VT(e){let t=e.toLowerCase();return t.includes(`cannot lock ref 'head'`)&&t.includes(`but expected`)?`un autre commit a modifié HEAD pendant l'autocommit. Réessayez l'enregistrement.`:e}async function HT(){if(!RT){RT=!0;try{let e=await fetch(`/api/git/status`,{cache:`no-store`});if(!e.ok)return;let t=await e.json();if(t.mode===`unconfigured`){Fa(`Veuillez configurer l'intégration Git dans la page Admin.`,`error`,600*1e3,{id:NT,href:IT,linkLabel:`Admin`}),Ea(PT),Ea(FT);return}if(Ea(NT),t.mode===`disabled`){Ea(PT),Ea(FT);return}if(!t.ok){Fa(`Intégration Git : ${t.message}`,`error`,600*1e3,{id:PT,href:IT,linkLabel:`Admin`});return}if(t.dirtyOutsideDocsCount>0){let e=t.docsFolder?.trim()||`docsFolder`;Fa(`Git : ${t.dirtyOutsideDocsCount} changement(s) hors ${e} seront ignorés par Living Documentation.`,`error`,600*1e3,PT)}else Ea(PT);let n=t.lastSave;n&&BT(n.timestamp)&&(n.error||n.warning)?Fa(`Git : ${VT(n.error||n.warning||``)}`,`error`,600*1e3,{id:FT,href:IT,linkLabel:`Admin`}):Ea(FT)}catch{}finally{RT=!1}}}function UT(){if(zT)return;zT=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await e(t,n),i=typeof t==`string`?t:t instanceof URL?t.toString():t.url;return(n?.method||(t instanceof Request?t.method:`GET`)).toUpperCase()!==`GET`&&!i.includes(`/api/git/`)&&(i.startsWith(`/api/`)||i.startsWith(`/mcp`)||i.startsWith(window.location.origin))&&window.setTimeout(()=>void HT(),80),r}}var WT=U(`<p style="padding:2rem"> </p>`);function GT(e,t){qe(t,!0);function n(e){return e.length>1?e.replace(/\/+$/,``):e}let r=new Set([`/`,`/admin`,`/workspace`,`/blueprint`,`/diagram`,`/shape-editor`,`/context`,`/files`,`/survival-kit`]),i=P(I(n(window.location.pathname)));function a(e){let t=new URL(e,window.location.href),r=n(t.pathname),a=`${r}${t.search}${t.hash}`;if(a===`${window.location.pathname}${window.location.search}${window.location.hash}`){Na();return}history.pushState(null,``,a),F(i,r,!0),Na(),HT(),window.dispatchEvent(new PopStateEvent(`popstate`))}function o(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;if(!(t instanceof HTMLAnchorElement)||t.target||t.hasAttribute(`download`))return;let i=new URL(t.href,window.location.href);if(i.origin!==window.location.origin)return;let o=n(i.pathname);r.has(o)&&(e.preventDefault(),a(`${o}${i.search}${i.hash}`))}Gi(()=>(Na(),UT(),HT(),document.addEventListener(`click`,o,!0),()=>{document.removeEventListener(`click`,o,!0)})),window.addEventListener(`popstate`,()=>{F(i,n(window.location.pathname),!0),Na(),HT()}),kn(()=>{V(i)===`/blueprint`?document.documentElement.setAttribute(`data-blueprint`,``):document.documentElement.removeAttribute(`data-blueprint`)});function s(e){a(e)}var c=Wr(),l=R(c),u=e=>{Ao(e,{navigate:s})},d=e=>{pf(e,{})},f=e=>{Bh(e,{})},p=e=>{Qh(e,{})},m=e=>{Mg(e,{navigate:s})},h=e=>{vw(e,{})},g=e=>{Cw(e,{})},_=e=>{zw(e,{})},v=e=>{MT(e,{})},y=e=>{fw(e,{})},b=e=>{var t=WT(),n=L(t);j(t),B(()=>G(n,`Route "${V(i)??``}" — not yet migrated.`)),W(e,t)};K(l,e=>{V(i)===`/admin`?e(u):V(i)===`/blueprint`?e(d,1):V(i)===`/workspace`?e(f,2):V(i)===`/files`?e(p,3):V(i)===`/context`?e(m,4):V(i)===`/diagram`?e(h,5):V(i)===`/graph`?e(g,6):V(i)===`/shape-editor`?e(_,7):V(i)===`/survival-kit`?e(v,8):V(i)===`/`?e(y,9):e(b,-1)}),W(e,c),Je()}var KT=new Set,qT=!1;function JT(e){KT.add(e)}function YT(){if(qT)return;qT=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await e(t,n);try{let e=typeof t==`string`?t:t instanceof URL?t.toString():t.url;(n?.method||(t instanceof Request?t.method:`GET`)).toUpperCase()===`GET`&&/\/api\/config(?:\?|$)/.test(e)&&r.clone().json().then(e=>{for(let t of KT)try{t(e)}catch{}}).catch(()=>{})}catch{}return r}}po(),JT(e=>mo(e)),JT(e=>$a.syncFromConfig(e)),YT(),Na(),ha(ma()).finally(()=>{Gr(GT,{target:document.getElementById(`app`)})});export{jw as a,Fw as c,ww as d,ha as f,Mw as i,Iw as l,Aw as n,Pw as o,Y as p,Nw as r,kw as s,Ew as t,Tw as u};
291
+ `).map(e=>e.trim()).filter(Boolean);return t.length?{type:`table`,headers:t[0].split(`|`).map(e=>e.trim()),rows:t.slice(1).map(e=>e.split(`|`).map(e=>e.trim()))}:null}return{type:V(f),content:e}}function E(){let e=T();e&&(V(d)===-1?Hw.notes[V(u)].blocs.push(e):Hw.notes[V(u)].blocs[V(d)]=e,qw(),F(l,!1))}async function D(e,n){await t.confirmDelete(Y(`survival.confirm_del_bloc_title`),Y(`survival.irreversible`))&&(Hw.notes[e].blocs.splice(n,1),qw())}async function ee(e,t){try{await navigator.clipboard.writeText(e),F(i,t,!0),setTimeout(()=>F(i,V(i)===t?null:V(i),!0),1500)}catch{}}let te=N(()=>V(f)===`ul`?Y(`survival.modal_bloc_placeholder_ul`):V(f)===`pre`?Y(`survival.modal_bloc_placeholder_pre`):V(f)===`table`?Y(`survival.modal_bloc_placeholder_table`):V(f)===`b`?Y(`survival.modal_bloc_placeholder_b`):Y(`survival.modal_bloc_placeholder_p`));var O=yT(),ne=R(O),re=L(ne),k=L(re,!0);Ie(),j(re);var ie=z(re,2),ae=L(ie,!0);j(ie),j(ne);var oe=z(ne,2),se=L(oe),ce=L(se,!0);j(se);var le=z(se,2),ue=L(le,!0);j(le);var de=z(le,2),fe=L(de,!0);j(de),j(oe);var pe=z(oe,2);let me;var he=L(pe),ge=e=>{var t=nT(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.notes_empty`)]),W(e,t)};K(he,e=>{Hw.notes.length===0&&e(ge)}),q(z(he,2),19,()=>Hw.notes,e=>e.id,(e,t,n)=>{let a=N(()=>!V(r)[V(t).id]);var o=pT();let s;var c=L(o),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d),p=z(f,2);j(d);var m=z(d,2);j(c);var h=z(c,2),_=L(h);q(_,17,()=>V(t).blocs,Xr,(e,r,a)=>{var o=fT(),s=L(o),c=L(s),l=e=>{var t=rT(),n=L(t,!0);j(t),B(()=>G(n,V(r).content)),W(e,t)},u=e=>{var t=iT(),n=L(t,!0);j(t),B(()=>G(n,V(r).content)),W(e,t)},d=e=>{let n=N(()=>`${V(t).id}-${a}`);var o=aT(),s=L(o),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(o),B(e=>{G(c,V(r).content),G(u,e)},[()=>V(i)===V(n)?Y(`survival.notes_btn_copied`):Y(`survival.notes_btn_copy`)]),H(`click`,l,()=>ee(V(r).content,V(n))),W(e,o)},f=e=>{var t=sT();q(t,21,()=>V(r).items,Xr,(e,t)=>{var n=oT(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(t),W(e,t)},p=e=>{var t=dT(),n=L(t),i=L(n),a=L(i);q(a,21,()=>V(r).headers,Xr,(e,t)=>{var n=cT(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(a),j(i);var o=z(i);q(o,21,()=>V(r).rows,Xr,(e,t)=>{var n=uT();q(n,21,()=>V(t),Xr,(e,t)=>{var n=lT(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(n),W(e,n)}),j(o),j(n),j(t),W(e,t)};K(c,e=>{V(r).type===`b`?e(l):V(r).type===`p`?e(u,1):V(r).type===`pre`?e(d,2):V(r).type===`ul`?e(f,3):V(r).type===`table`&&e(p,4)}),j(s);var m=z(s,2),h=L(m),g=z(h,2);j(m),j(o),H(`click`,h,()=>w(V(n),a)),H(`click`,g,()=>D(V(n),a)),W(e,o)});var v=z(_,2),b=L(v),S=L(b,!0);j(b),j(v),j(h),j(o),B(e=>{s=gi(o,1,`sk-note ${V(t).theme??``}`,`svelte-hpbata`,s,{collapsed:V(a)}),G(u,V(t).titre),G(S,e)},[()=>Y(`survival.notes_btn_add_bloc`)]),H(`click`,f,()=>y(V(n))),H(`click`,p,()=>x(V(n))),H(`click`,m,()=>g(V(t).id)),H(`click`,b,()=>C(V(n))),W(e,o)}),j(pe);var _e=z(pe,2);{let e=N(()=>V(o)===-1?Y(`survival.modal_note_title`):Y(`survival.modal_edit_note_title`)),t=N(()=>V(o)===-1?Y(`common.create`):Y(`common.save`));tT(_e,{get open(){return V(a)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:b,onClose:()=>F(a,!1),children:(e,t)=>{var n=hT(),r=R(n),i=L(r,!0);j(r);var a=z(r,2);Di(a);var o=z(a,2),l=L(o,!0);j(o);var u=z(o,2);q(u,21,()=>$w,Xr,(e,t)=>{var n=mT(),r=L(n,!0);j(n);var i={};B(e=>{G(r,e),i!==(i=V(t))&&(n.value=(n.__value=V(t))??``)},[()=>Y(m[V(t)])]),W(e,n)}),j(u),B((e,t,n)=>{G(i,e),J(a,`placeholder`,t),G(l,n)},[()=>Y(`survival.modal_note_label_title`),()=>Y(`survival.modal_note_placeholder`),()=>Y(`survival.modal_label_color`)]),H(`keydown`,a,e=>e.key===`Enter`&&b()),Ni(a,()=>V(s),e=>F(s,e)),xi(u,()=>V(c),e=>F(c,e)),W(e,n)},$$slots:{default:!0}})}var ve=z(_e,2);{let e=N(()=>V(d)===-1?Y(`survival.modal_bloc_new`):Y(`survival.modal_bloc_edit`)),t=N(()=>Y(`common.save`));tT(ve,{get open(){return V(l)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:E,onClose:()=>F(l,!1),children:(e,t)=>{var n=vT(),r=R(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o),o.value=o.__value=`b`;var c=z(o),l=L(c,!0);j(c),c.value=c.__value=`p`;var u=z(c),d=L(u,!0);j(u),u.value=u.__value=`pre`;var m=z(u),h=L(m,!0);j(m),m.value=m.__value=`ul`;var g=z(m),_=L(g,!0);j(g),g.value=g.__value=`table`,j(a);var v=z(a,2),y=L(v,!0);j(v);var b=z(v,2),x=e=>{var t=gT();Di(t),B(()=>J(t,`placeholder`,V(te))),H(`keydown`,t,e=>e.key===`Enter`&&E()),Ni(t,()=>V(p),e=>F(p,e)),W(e,t)},S=e=>{var t=_T();yn(t),B(()=>J(t,`placeholder`,V(te))),Ni(t,()=>V(p),e=>F(p,e)),W(e,t)};K(b,e=>{V(f)===`b`?e(x):e(S,-1)}),B((e,t,n,r,a,o,c)=>{G(i,e),G(s,t),G(l,n),G(d,r),G(h,a),G(_,o),G(y,c)},[()=>Y(`survival.modal_bloc_label_type`),()=>Y(`survival.modal_bloc_type_b`),()=>Y(`survival.modal_bloc_type_p`),()=>Y(`survival.modal_bloc_type_pre`),()=>Y(`survival.modal_bloc_type_ul`),()=>Y(`survival.modal_bloc_type_table`),()=>Y(`survival.modal_bloc_label_content`)]),xi(a,()=>V(f),e=>F(f,e)),W(e,n)},$$slots:{default:!0}})}B((e,t,r,i,a)=>{G(k,e),G(ae,t),G(ce,r),G(ue,i),G(fe,a),me=gi(pe,1,`sk-notes svelte-hpbata`,null,me,{"edit-mode":V(n)})},[()=>Y(`survival.notes_title`),()=>Y(`survival.notes_subtitle`),()=>V(n)?Y(`survival.btn_read_mode`):Y(`survival.btn_edit_mode`),()=>V(h)?Y(`survival.btn_collapse_all`):Y(`survival.btn_expand_all`),()=>Y(`survival.notes_btn_add`)]),H(`click`,se,()=>F(n,!V(n))),H(`click`,le,_),H(`click`,de,v),W(e,O),Je()}Pr([`click`,`keydown`]);var xT=U(`<p class="sk-empty svelte-1j811iq"> </p>`),ST=U(`<span class="sk-link-desc svelte-1j811iq"> </span>`),CT=U(`<a target="_blank" rel="noopener" class="sk-link svelte-1j811iq"><span class="sk-link-text svelte-1j811iq"><span class="sk-link-name svelte-1j811iq"> </span><!></span> <span class="sk-arrow svelte-1j811iq">↗</span> <span class="sk-link-actions svelte-1j811iq"><button type="button" class="sk-mini svelte-1j811iq">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-1j811iq">✕</button></span></a>`),wT=U(`<section><div class="sk-cat-head svelte-1j811iq"><h3 class="svelte-1j811iq"> </h3> <div class="sk-cat-actions svelte-1j811iq"><button type="button" class="sk-mini svelte-1j811iq">+</button> <button type="button" class="sk-mini sk-mini--del svelte-1j811iq">✕</button></div> <button type="button" class="sk-toggle svelte-1j811iq" aria-label="toggle"><svg viewBox="0 0 10 6" width="10" height="6"><path d="M1 1 L5 5 L9 1" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div> <div class="sk-links svelte-1j811iq"></div></section>`),TT=U(`<option> </option>`),ET=U(`<label for="sk-cat-name"> </label> <input id="sk-cat-name" type="text"/> <label for="sk-cat-color"> </label> <select id="sk-cat-color"></select>`,1),DT=U(`<label for="sk-link-nom"> </label> <input id="sk-link-nom" type="text"/> <label for="sk-link-desc"> </label> <input id="sk-link-desc" type="text"/> <label for="sk-link-url"> </label> <input id="sk-link-url" type="text" placeholder="https://…"/>`,1),OT=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-toolbar svelte-1j811iq"><button type="button" class="sk-tool svelte-1j811iq"> </button> <button type="button" class="sk-tool svelte-1j811iq"> </button> <button type="button" class="sk-tool sk-tool--add svelte-1j811iq"> </button></div> <div><!> <!></div> <!> <!>`,1);function kT(e,t){qe(t,!0);let n=P(!1),r=P(I({})),i=P(!1),a=P(``),o=P(`t-green`),s=P(!1),c=P(-1),l=P(-1),u=P(``),d=P(``),f=P(``),p={"t-green":`survival.color_green`,"t-violet":`survival.color_violet`,"t-amber":`survival.color_amber`,"t-sky":`survival.color_sky`,"t-rose":`survival.color_rose`,"t-teal":`survival.color_teal`},m=N(()=>Hw.links.length>0&&Hw.links.every(e=>V(r)[e.titre]));function h(e){V(r)[e]=!V(r)[e]}function g(){if(V(m))F(r,{},!0);else{let e={};Hw.links.forEach(t=>e[t.titre]=!0),F(r,e,!0)}}function _(){F(a,``),F(o,`t-green`),F(i,!0)}function v(){let e=V(a).trim();e&&(Hw.links.push({theme:V(o),titre:e,liens:[]}),qw(),F(i,!1))}async function y(e){Hw.links[e],await t.confirmDelete(Y(`survival.confirm_del_cat_title`),Y(`survival.confirm_del_cat_msg`))&&(Hw.links.splice(e,1),qw())}function b(e){F(c,e,!0),F(l,-1),F(u,``),F(d,``),F(f,``),F(s,!0)}function x(e,t,n){e.preventDefault();let r=Hw.links[t].liens[n];F(c,t,!0),F(l,n,!0),F(u,r.nom,!0),F(d,r.desc,!0),F(f,r.url,!0),F(s,!0)}function S(){let e=V(u).trim(),t=V(f).trim();if(!e||!t)return;let n={nom:e,desc:V(d).trim(),url:t};V(l)===-1?Hw.links[V(c)].liens.push(n):Hw.links[V(c)].liens[V(l)]=n,qw(),F(s,!1)}async function C(e,n,r){e.preventDefault(),await t.confirmDelete(Y(`survival.confirm_del_link_title`),Y(`survival.irreversible`))&&(Hw.links[n].liens.splice(r,1),qw())}var w=OT(),T=R(w),E=L(T),D=L(E,!0);Ie(),j(E);var ee=z(E,2),te=L(ee,!0);j(ee),j(T);var O=z(T,2),ne=L(O),re=L(ne,!0);j(ne);var k=z(ne,2),ie=L(k,!0);j(k);var ae=z(k,2),oe=L(ae,!0);j(ae),j(O);var se=z(O,2);let ce;var le=L(se),ue=e=>{var t=xT(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.links_empty`)]),W(e,t)};K(le,e=>{Hw.links.length===0&&e(ue)}),q(z(le,2),19,()=>Hw.links,(e,t)=>e.titre+t,(e,t,n)=>{let i=N(()=>!V(r)[V(t).titre]);var a=wT();let o;var s=L(a),c=L(s),l=L(c,!0);j(c);var u=z(c,2),d=L(u),f=z(d,2);j(u);var p=z(u,2);j(s);var m=z(s,2);q(m,21,()=>V(t).liens,Xr,(e,t,r)=>{var i=CT(),a=L(i),o=L(a),s=L(o,!0);j(o);var c=z(o),l=e=>{var n=ST(),r=L(n);j(n),B(()=>G(r,`— ${V(t).desc??``}`)),W(e,n)};K(c,e=>{V(t).desc&&e(l)}),j(a);var u=z(a,4),d=L(u),f=z(d,2);j(u),j(i),B((e,n)=>{J(i,`href`,V(t).url),G(s,V(t).nom),J(d,`title`,e),J(f,`title`,n)},[()=>Y(`survival.links_edit_link_title`),()=>Y(`survival.links_del_link_title`)]),H(`click`,d,e=>x(e,V(n),r)),H(`click`,f,e=>C(e,V(n),r)),W(e,i)}),j(m),j(a),B((e,n)=>{o=gi(a,1,`sk-cat ${V(t).theme??``}`,`svelte-1j811iq`,o,{collapsed:V(i)}),G(l,V(t).titre),J(d,`title`,e),J(f,`title`,n)},[()=>Y(`survival.links_add_link_title`),()=>Y(`survival.links_del_cat_title`)]),H(`click`,d,()=>b(V(n))),H(`click`,f,()=>y(V(n))),H(`click`,p,()=>h(V(t).titre)),W(e,a)}),j(se);var de=z(se,2);{let e=N(()=>Y(`survival.modal_cat_title`)),t=N(()=>Y(`common.add`));tT(de,{get open(){return V(i)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:v,onClose:()=>F(i,!1),children:(e,t)=>{var n=ET(),r=R(n),i=L(r,!0);j(r);var s=z(r,2);Di(s);var c=z(s,2),l=L(c,!0);j(c);var u=z(c,2);q(u,21,()=>$w,Xr,(e,t)=>{var n=TT(),r=L(n,!0);j(n);var i={};B(e=>{G(r,e),i!==(i=V(t))&&(n.value=(n.__value=V(t))??``)},[()=>Y(p[V(t)])]),W(e,n)}),j(u),B((e,t,n)=>{G(i,e),J(s,`placeholder`,t),G(l,n)},[()=>Y(`survival.modal_cat_label_name`),()=>Y(`survival.modal_cat_placeholder_name`),()=>Y(`survival.modal_label_color`)]),H(`keydown`,s,e=>e.key===`Enter`&&v()),Ni(s,()=>V(a),e=>F(a,e)),xi(u,()=>V(o),e=>F(o,e)),W(e,n)},$$slots:{default:!0}})}var fe=z(de,2);{let e=N(()=>V(l)===-1?Y(`survival.modal_link_title`):Y(`survival.modal_edit_link_title`)),t=N(()=>V(l)===-1?Y(`common.add`):Y(`common.save`));tT(fe,{get open(){return V(s)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:S,onClose:()=>F(s,!1),children:(e,t)=>{var n=DT(),r=R(n),i=L(r,!0);j(r);var a=z(r,2);Di(a);var o=z(a,2),s=L(o,!0);j(o);var c=z(o,2);Di(c);var l=z(c,2),p=L(l,!0);j(l);var m=z(l,2);Di(m),B((e,t,n,r,o)=>{G(i,e),J(a,`placeholder`,t),G(s,n),J(c,`placeholder`,r),G(p,o)},[()=>Y(`survival.modal_link_label_name`),()=>Y(`survival.modal_link_placeholder_name`),()=>Y(`survival.modal_link_label_desc`),()=>Y(`survival.modal_link_placeholder_desc`),()=>Y(`survival.modal_link_label_url`)]),Ni(a,()=>V(u),e=>F(u,e)),Ni(c,()=>V(d),e=>F(d,e)),H(`keydown`,m,e=>e.key===`Enter`&&S()),Ni(m,()=>V(f),e=>F(f,e)),W(e,n)},$$slots:{default:!0}})}B((e,t,r,i,a)=>{G(D,e),G(te,t),G(re,r),G(ie,i),G(oe,a),ce=gi(se,1,`sk-cats svelte-1j811iq`,null,ce,{"edit-mode":V(n)})},[()=>Y(`survival.links_title`),()=>Y(`survival.links_subtitle`),()=>V(n)?Y(`survival.btn_read_mode`):Y(`survival.btn_edit_mode`),()=>V(m)?Y(`survival.btn_collapse_all`):Y(`survival.btn_expand_all`),()=>Y(`survival.links_btn_add_cat`)]),H(`click`,ne,()=>F(n,!V(n))),H(`click`,k,g),H(`click`,ae,_),W(e,w),Je()}Pr([`click`,`keydown`]);var AT=U(`<button class="ghost-button"><i class="fa-solid fa-cloud"></i></button> <button title="Toggle dark mode" class="ghost-button" aria-label="Toggle dark mode"> </button>`,1),jT=U(`<p class="sk-loading svelte-ha6eja"> </p>`),MT=U(`<div class="sk-grid svelte-ha6eja"><section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section> <section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section> <section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section></div>`),NT=U(`<!> <div class="app-shell sk-root svelte-ha6eja"><div class="sk-menu-trigger svelte-ha6eja" role="presentation"></div> <div><!></div> <!></div> <!>`,1);function PT(e,t){qe(t,!0);let n=P(null),r=P(!1),i=P(!1),a=P(!1),o=P(!1);function s(e){F(o,e<=(V(o)?84:10))}kn(()=>{let e=e=>s(e.clientY);return window.addEventListener(`mousemove`,e),()=>window.removeEventListener(`mousemove`,e)});async function c(e,t){return V(n).show({title:e,message:t,confirmLabel:Y(`survival.irreversible_delete`),cancelLabel:Y(`common.cancel`),danger:!0})}function l(e){F(i,e,!0),document.documentElement.classList.toggle(`dark`,e)}function u(){let e=!1;try{let t=localStorage.getItem(`ld-dark`);e=t===null?window.matchMedia(`(prefers-color-scheme: dark)`).matches:t===`true`}catch{}l(e)}function d(){l(!V(i));try{localStorage.setItem(`ld-dark`,String(V(i)))}catch{}}Gi(async()=>{u();try{await ha((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}await Gw(),F(r,!0)});var f=NT(),p=R(f);Vi(ad(p,{}),e=>F(n,e,!0),()=>V(n));var m=z(p,2),h=L(m),g=z(h,2);let _;var v=L(g);{let e=e=>{var t=AT(),n=R(t),r=z(n,2),o=L(r,!0);j(r),B((e,t)=>{J(n,`title`,e),J(n,`aria-label`,t),G(o,V(i)?`☀`:`☾`)},[()=>Y(`nav.word_cloud`),()=>Y(`nav.word_cloud`)]),H(`click`,n,()=>F(a,!0)),H(`click`,r,d),W(e,t)},t=N(()=>Y(`survival.title`)),n=N(()=>Y(`survival.subtitle`));so(v,{get title(){return V(t)},get subtitle(){return V(n)},actions:e,$$slots:{actions:!0}})}j(g);var y=z(g,2),b=e=>{var t=jT(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},x=e=>{var t=MT(),n=L(t),r=L(n);Qw(L(r),{}),j(r),j(n);var i=z(n,2),a=L(i);bT(L(a),{confirmDelete:c}),j(a),j(i);var o=z(i,2),s=L(o);kT(L(s),{confirmDelete:c}),j(s),j(o),j(t),W(e,t)};K(y,e=>{V(r)?e(x,-1):e(b)}),j(m),sw(z(m,2),{get open(){return V(a)},onclose:()=>F(a,!1)}),B(()=>_=gi(g,1,`sk-menu-drawer svelte-ha6eja`,null,_,{revealed:V(o)})),Nr(`mouseenter`,h,()=>F(o,!0)),W(e,f),Je()}Pr([`click`]);var FT=`git-integration-config`,IT=`git-integration-status`,LT=`git-integration-save`,RT=`/admin#git-integration`,zT=120*1e3,BT=!1,VT=!1;function HT(e){let t=Date.parse(e);return Number.isFinite(t)&&Date.now()-t<zT}function UT(e){let t=e.toLowerCase();return t.includes(`cannot lock ref 'head'`)&&t.includes(`but expected`)?`un autre commit a modifié HEAD pendant l'autocommit. Réessayez l'enregistrement.`:e}async function WT(){if(!BT){BT=!0;try{let e=await fetch(`/api/git/status`,{cache:`no-store`});if(!e.ok)return;let t=await e.json();if(t.mode===`unconfigured`){Fa(`Veuillez configurer l'intégration Git dans la page Admin.`,`error`,600*1e3,{id:FT,href:RT,linkLabel:`Admin`}),Ea(IT),Ea(LT);return}if(Ea(FT),t.mode===`disabled`){Ea(IT),Ea(LT);return}if(!t.ok){Fa(`Intégration Git : ${t.message}`,`error`,600*1e3,{id:IT,href:RT,linkLabel:`Admin`});return}if(t.dirtyOutsideDocsCount>0){let e=t.docsFolder?.trim()||`docsFolder`;Fa(`Git : ${t.dirtyOutsideDocsCount} changement(s) hors ${e} seront ignorés par Living Documentation.`,`error`,600*1e3,IT)}else Ea(IT);let n=t.lastSave;n&&HT(n.timestamp)&&(n.error||n.warning)?Fa(`Git : ${UT(n.error||n.warning||``)}`,`error`,600*1e3,{id:LT,href:RT,linkLabel:`Admin`}):Ea(LT)}catch{}finally{BT=!1}}}function GT(){if(VT)return;VT=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await e(t,n),i=typeof t==`string`?t:t instanceof URL?t.toString():t.url;return(n?.method||(t instanceof Request?t.method:`GET`)).toUpperCase()!==`GET`&&!i.includes(`/api/git/`)&&(i.startsWith(`/api/`)||i.startsWith(`/mcp`)||i.startsWith(window.location.origin))&&window.setTimeout(()=>void WT(),80),r}}var KT=U(`<p style="padding:2rem"> </p>`);function qT(e,t){qe(t,!0);function n(e){return e.length>1?e.replace(/\/+$/,``):e}let r=new Set([`/`,`/admin`,`/workspace`,`/blueprint`,`/diagram`,`/shape-editor`,`/context`,`/files`,`/survival-kit`]),i=P(I(n(window.location.pathname)));function a(e){let t=new URL(e,window.location.href),r=n(t.pathname),a=`${r}${t.search}${t.hash}`;if(a===`${window.location.pathname}${window.location.search}${window.location.hash}`){Na();return}history.pushState(null,``,a),F(i,r,!0),Na(),WT(),window.dispatchEvent(new PopStateEvent(`popstate`))}function o(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;if(!(t instanceof HTMLAnchorElement)||t.target||t.hasAttribute(`download`))return;let i=new URL(t.href,window.location.href);if(i.origin!==window.location.origin)return;let o=n(i.pathname);r.has(o)&&(e.preventDefault(),a(`${o}${i.search}${i.hash}`))}Gi(()=>(Na(),GT(),WT(),document.addEventListener(`click`,o,!0),()=>{document.removeEventListener(`click`,o,!0)})),window.addEventListener(`popstate`,()=>{F(i,n(window.location.pathname),!0),Na(),WT()}),kn(()=>{V(i)===`/blueprint`?document.documentElement.setAttribute(`data-blueprint`,``):document.documentElement.removeAttribute(`data-blueprint`)});function s(e){a(e)}var c=Wr(),l=R(c),u=e=>{Ao(e,{navigate:s})},d=e=>{hf(e,{})},f=e=>{Hh(e,{})},p=e=>{eg(e,{})},m=e=>{Pg(e,{navigate:s})},h=e=>{bw(e,{})},g=e=>{Tw(e,{})},_=e=>{Vw(e,{})},v=e=>{PT(e,{})},y=e=>{mw(e,{})},b=e=>{var t=KT(),n=L(t);j(t),B(()=>G(n,`Route "${V(i)??``}" — not yet migrated.`)),W(e,t)};K(l,e=>{V(i)===`/admin`?e(u):V(i)===`/blueprint`?e(d,1):V(i)===`/workspace`?e(f,2):V(i)===`/files`?e(p,3):V(i)===`/context`?e(m,4):V(i)===`/diagram`?e(h,5):V(i)===`/graph`?e(g,6):V(i)===`/shape-editor`?e(_,7):V(i)===`/survival-kit`?e(v,8):V(i)===`/`?e(y,9):e(b,-1)}),W(e,c),Je()}var JT=new Set,YT=!1;function XT(e){JT.add(e)}function ZT(){if(YT)return;YT=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await e(t,n);try{let e=typeof t==`string`?t:t instanceof URL?t.toString():t.url;(n?.method||(t instanceof Request?t.method:`GET`)).toUpperCase()===`GET`&&/\/api\/config(?:\?|$)/.test(e)&&r.clone().json().then(e=>{for(let t of JT)try{t(e)}catch{}}).catch(()=>{})}catch{}return r}}po(),XT(e=>mo(e)),XT(e=>$a.syncFromConfig(e)),ZT(),Na(),ha(ma()).finally(()=>{Gr(qT,{target:document.getElementById(`app`)})});export{Nw as a,Lw as c,Ew as d,ha as f,Pw as i,Rw as l,Mw as n,Iw as o,Y as p,Fw as r,jw as s,Ow as t,Dw as u};