@inkeep/open-knowledge 0.0.0-dev-20260430215257 → 0.0.0-dev-20260430220014
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.
- package/dist/cli.mjs +225 -223
- package/dist/constants-BJgA-R9A.mjs +2 -0
- package/dist/{dist-CSvz1VhR.mjs → dist-7GgIDlwG.mjs} +24 -24
- package/dist/{dist-U4KUxqv5.mjs → dist-BnZHVzE4.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{init-CoBzPU71.mjs → init-4hOSMFgg.mjs} +3 -3
- package/dist/init-74HGAC-m.mjs +1 -0
- package/dist/init-D0BylGY2.mjs +1 -0
- package/dist/{init-Do3bEm3B.mjs → init-DTaM2KXE.mjs} +2 -2
- package/dist/loader-CcIQcrAC.mjs +1 -0
- package/dist/{loader-BegmfMFA.mjs → loader-xw-iBLcB.mjs} +2 -2
- package/dist/paths-CTQx5S3f.mjs +2 -0
- package/dist/paths-EnLHpVly.mjs +1 -0
- package/dist/preview-CfADaMr4.mjs +1 -0
- package/dist/{preview-BREahqzv.mjs → preview-mARzyxNL.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-CUpTfvqt.js → ActivityModeContent-DWssAqaG.js} +1 -1
- package/dist/public/assets/{DocumentContext-CS3dbEFb.js → DocumentContext-GbmGcVzS.js} +1 -1
- package/dist/public/assets/{SettingsPane-C5lIVObs.js → SettingsPane-HKf0Vtow.js} +1 -1
- package/dist/public/assets/{SourceEditor-PEgx-NCm.js → SourceEditor-D5eu9Dbl.js} +1 -1
- package/dist/public/assets/{clipboard-CvirH7Hp.js → clipboard-D2LwhWD3.js} +1 -1
- package/dist/public/assets/{config-validation-events-Irg9X5oj.js → config-validation-events-5erczoJ8.js} +1 -1
- package/dist/public/assets/index-MyoVlmF1.js +1840 -0
- package/dist/public/index.html +4 -4
- package/dist/src-4CHmk5b7.mjs +1 -0
- package/dist/{start-C3TQYA3J.mjs → start-B6JuLc0Q.mjs} +2 -2
- package/dist/start-BneKCKPF.mjs +1 -0
- package/package.json +1 -1
- package/dist/constants-CKleSPG-.mjs +0 -2
- package/dist/init-BN0U8twb.mjs +0 -1
- package/dist/init-CZrCa_vj.mjs +0 -1
- package/dist/loader-QaZ7INwj.mjs +0 -1
- package/dist/paths-opiKEaCC.mjs +0 -2
- package/dist/paths-rUSBGS5c.mjs +0 -1
- package/dist/preview-D3e-de44.mjs +0 -1
- package/dist/public/assets/index-C947BPi_.js +0 -1840
- package/dist/src-Cwx2WBLv.mjs +0 -1
- package/dist/start-B00zNiq_.mjs +0 -1
|
@@ -31,4 +31,4 @@ console.log(greeting);`})})}},{name:`table`,label:`Table`,icon:dr,category:`inse
|
|
|
31
31
|
\${}
|
|
32
32
|
}`,{label:`interface`,detail:`definition`,type:`keyword`}),An("type ${name} = ${type}",{label:`type`,detail:`definition`,type:`keyword`}),An(`enum \${name} {
|
|
33
33
|
\${}
|
|
34
|
-
}`,{label:`enum`,detail:`definition`,type:`keyword`})]),pA=new en,mA=new Set([`Script`,`Block`,`FunctionExpression`,`FunctionDeclaration`,`ArrowFunction`,`MethodDeclaration`,`ForStatement`]);function hA(e){return(t,n)=>{let r=t.node.getChild(`VariableDefinition`);return r&&n(r,e),!0}}var gA=[`FunctionDeclaration`],_A={FunctionDeclaration:hA(`function`),ClassDeclaration:hA(`class`),ClassExpression:()=>!0,EnumDeclaration:hA(`constant`),TypeAliasDeclaration:hA(`type`),NamespaceDeclaration:hA(`namespace`),VariableDefinition(e,t){e.matchContext(gA)||t(e,`variable`)},TypeDefinition(e,t){t(e,`type`)},__proto__:null};function vA(e,t){let n=pA.get(t);if(n)return n;let r=[],i=!0;function a(t,n){let i=e.sliceString(t.from,t.to);r.push({label:i,type:n})}return t.cursor(On.IncludeAnonymous).iterate(t=>{if(i)i=!1;else if(t.name){let e=_A[t.name];if(e&&e(t,a)||mA.has(t.name))return!1}else if(t.to-t.from>8192){for(let n of vA(e,t.node))r.push(n);return!1}}),pA.set(t,r),r}var yA=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,bA=[`TemplateString`,`String`,`RegExp`,`LineComment`,`BlockComment`,`VariableDefinition`,`TypeDefinition`,`Label`,`PropertyDefinition`,`PropertyName`,`PrivatePropertyDefinition`,`PrivatePropertyName`,`JSXText`,`JSXAttributeValue`,`JSXOpenTag`,`JSXCloseTag`,`JSXSelfClosingTag`,`.`,`?.`];function xA(e){let t=Yt(e.state).resolveInner(e.pos,-1);if(bA.indexOf(t.name)>-1)return null;let n=t.name==`VariableName`||t.to-t.from<20&&yA.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let n=t;n;n=n.parent)mA.has(n.name)&&(r=r.concat(vA(e.state.doc,n)));return{options:r,from:n?t.from:e.pos,validFor:yA}}var SA=xn.define({name:`javascript`,parser:uA.configure({props:[Tn.add({IfStatement:wn({except:/^\s*({|else\b)/}),TryStatement:wn({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:un,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:yn({closing:`}`}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":wn({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),Dn.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":on,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name==`JSXSelfClosingTag`)return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){let t=e.firstChild?.nextSibling,n=e.lastChild;return!t||t.type.isError?null:{from:t.to,to:n.type.isError?e.to:n.from}}})]}),languageData:{closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]},commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:`$`}}),CA={test:e=>/^JSX/.test(e.name),facet:ln({commentTokens:{block:{open:`{/*`,close:`*/}`}}})},wA=SA.configure({dialect:`ts`},`typescript`),TA=SA.configure({dialect:`jsx`,props:[fn.add(e=>e.isTop?[CA]:void 0)]}),EA=SA.configure({dialect:`jsx ts`,props:[fn.add(e=>e.isTop?[CA]:void 0)]},`typescript`),DA=e=>({label:e,type:`keyword`}),OA=`break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield`.split(` `).map(DA),kA=OA.concat([`declare`,`implements`,`private`,`protected`,`public`].map(DA));function AA(e={}){let t=e.jsx?e.typescript?EA:TA:e.typescript?wA:SA,n=e.typescript?fA.concat(kA):dA.concat(OA);return new vn(t,[SA.data.of({autocomplete:jn(bA,kn(n))}),SA.data.of({autocomplete:xA}),e.jsx?PA:[]])}function jA(e){for(;;){if(e.name==`JSXOpenTag`||e.name==`JSXSelfClosingTag`||e.name==`JSXFragmentTag`)return e;if(e.name==`JSXEscape`||!e.parent)return null;e=e.parent}}function MA(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name==`JSXIdentifier`||r.name==`JSXBuiltin`||r.name==`JSXNamespacedName`||r.name==`JSXMemberExpression`)return e.sliceString(r.from,Math.min(r.to,n));return``}var NA=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),PA=rn.inputHandler.of((e,t,n,r,i)=>{if((NA?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!SA.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let{head:t}=e,n=Yt(o).resolveInner(t-1,-1),i;if(n.name==`JSXStartTag`&&(n=n.parent),!(o.doc.sliceString(t-1,t)!=r||n.name==`JSXAttributeValue`&&n.to>t)){if(r==`>`&&n.name==`JSXFragmentTag`)return{range:e,changes:{from:t,insert:`</>`}};if(r==`/`&&n.name==`JSXStartCloseTag`){let e=n.parent,r=e.parent;if(r&&e.from==t-2&&((i=MA(o.doc,r.firstChild,t))||r.firstChild?.name==`JSXFragmentTag`)){let e=`${i}>`;return{range:$t.cursor(t+e.length,-1),changes:{from:t,insert:e}}}}else if(r==`>`){let r=jA(n);if(r&&r.name==`JSXOpenTag`&&!/^\/?>|^<\//.test(o.doc.sliceString(t,t+2))&&(i=MA(o.doc,r,t)))return{range:e,changes:{from:t,insert:`</${i}>`}}}}return{range:e}});return s.changes.empty?!1:(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),FA=[`_blank`,`_self`,`_top`,`_parent`],IA=[`ascii`,`utf-8`,`utf-16`,`latin1`,`latin1`],LA=[`get`,`post`,`put`,`delete`],RA=[`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`],zA=[`true`,`false`],$={},BA={a:{attrs:{href:null,ping:null,type:null,media:null,target:FA,hreflang:null}},abbr:$,address:$,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:[`default`,`rect`,`circle`,`poly`]}},article:$,aside:$,audio:{attrs:{src:null,mediagroup:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`none`,`metadata`,`auto`],autoplay:[`autoplay`],loop:[`loop`],controls:[`controls`]}},b:$,base:{attrs:{href:null,target:FA}},bdi:$,bdo:$,blockquote:{attrs:{cite:null}},body:$,br:$,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:[`autofocus`],disabled:[`autofocus`],formenctype:RA,formmethod:LA,formnovalidate:[`novalidate`],formtarget:FA,type:[`submit`,`reset`,`button`]}},canvas:{attrs:{width:null,height:null}},caption:$,center:$,cite:$,code:$,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:[`command`,`checkbox`,`radio`],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:[`disabled`],checked:[`checked`]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:[`disabled`],multiple:[`multiple`]}},datalist:{attrs:{data:null}},dd:$,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:[`open`]}},dfn:$,div:$,dl:$,dt:$,em:$,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:[`disabled`],form:null,name:null}},figcaption:$,figure:$,footer:$,form:{attrs:{action:null,name:null,"accept-charset":IA,autocomplete:[`on`,`off`],enctype:RA,method:LA,novalidate:[`novalidate`],target:FA}},h1:$,h2:$,h3:$,h4:$,h5:$,h6:$,head:{children:[`title`,`base`,`link`,`style`,`meta`,`script`,`noscript`,`command`]},header:$,hgroup:$,hr:$,html:{attrs:{manifest:null}},i:$,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:[`allow-top-navigation`,`allow-same-origin`,`allow-forms`,`allow-scripts`],seamless:[`seamless`]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:[`audio/*`,`video/*`,`image/*`],autocomplete:[`on`,`off`],autofocus:[`autofocus`],checked:[`checked`],disabled:[`disabled`],formenctype:RA,formmethod:LA,formnovalidate:[`novalidate`],formtarget:FA,multiple:[`multiple`],readonly:[`readonly`],required:[`required`],type:[`hidden`,`text`,`search`,`tel`,`url`,`email`,`password`,`datetime`,`date`,`month`,`week`,`time`,`datetime-local`,`number`,`range`,`color`,`checkbox`,`radio`,`file`,`submit`,`image`,`reset`,`button`]}},ins:{attrs:{cite:null,datetime:null}},kbd:$,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:[`autofocus`],disabled:[`disabled`],keytype:[`RSA`]}},label:{attrs:{for:null,form:null}},legend:$,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:[`all`,`16x16`,`16x16 32x32`,`16x16 32x32 64x64`]}},map:{attrs:{name:null}},mark:$,menu:{attrs:{label:null,type:[`list`,`context`,`toolbar`]}},meta:{attrs:{content:null,charset:IA,name:[`viewport`,`application-name`,`author`,`description`,`generator`,`keywords`],"http-equiv":[`content-language`,`content-type`,`default-style`,`refresh`]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:$,noscript:$,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:[`typemustmatch`]}},ol:{attrs:{reversed:[`reversed`],start:null,type:[`1`,`a`,`A`,`i`,`I`]},children:[`li`,`script`,`template`,`ul`,`ol`]},optgroup:{attrs:{disabled:[`disabled`],label:null}},option:{attrs:{disabled:[`disabled`],label:null,selected:[`selected`],value:null}},output:{attrs:{for:null,form:null,name:null}},p:$,param:{attrs:{name:null,value:null}},pre:$,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:$,rt:$,ruby:$,samp:$,script:{attrs:{type:[`text/javascript`],src:null,async:[`async`],defer:[`defer`],charset:IA}},section:$,select:{attrs:{form:null,name:null,size:null,autofocus:[`autofocus`],disabled:[`disabled`],multiple:[`multiple`]}},slot:{attrs:{name:null}},small:$,source:{attrs:{src:null,type:null,media:null}},span:$,strong:$,style:{attrs:{type:[`text/css`],media:null,scoped:null}},sub:$,summary:$,sup:$,table:$,tbody:$,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:$,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:[`autofocus`],disabled:[`disabled`],readonly:[`readonly`],required:[`required`],wrap:[`soft`,`hard`]}},tfoot:$,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:[`row`,`col`,`rowgroup`,`colgroup`]}},thead:$,time:{attrs:{datetime:null}},title:$,tr:$,track:{attrs:{src:null,label:null,default:null,kind:[`subtitles`,`captions`,`descriptions`,`chapters`,`metadata`],srclang:null}},ul:{children:[`li`,`script`,`template`,`ul`,`ol`]},var:$,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`auto`,`metadata`,`none`],autoplay:[`autoplay`],mediagroup:[`movie`],muted:[`muted`],controls:[`controls`]}},wbr:$},VA={accesskey:null,class:null,contenteditable:zA,contextmenu:null,dir:[`ltr`,`rtl`,`auto`],draggable:[`true`,`false`,`auto`],dropzone:[`copy`,`move`,`link`,`string:`,`file:`],hidden:[`hidden`],id:null,inert:[`inert`],itemid:null,itemprop:null,itemref:null,itemscope:[`itemscope`],itemtype:null,lang:[`ar`,`bn`,`de`,`en-GB`,`en-US`,`es`,`fr`,`hi`,`id`,`ja`,`pa`,`pt`,`ru`,`tr`,`zh`],spellcheck:zA,autocorrect:zA,autocapitalize:zA,style:null,tabindex:null,title:null,translate:[`yes`,`no`],rel:[`stylesheet`,`alternate`,`author`,`bookmark`,`help`,`license`,`next`,`nofollow`,`noreferrer`,`prefetch`,`prev`,`search`,`tag`],role:`alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer`.split(` `),"aria-activedescendant":null,"aria-atomic":zA,"aria-autocomplete":[`inline`,`list`,`both`,`none`],"aria-busy":zA,"aria-checked":[`true`,`false`,`mixed`,`undefined`],"aria-controls":null,"aria-describedby":null,"aria-disabled":zA,"aria-dropeffect":null,"aria-expanded":[`true`,`false`,`undefined`],"aria-flowto":null,"aria-grabbed":[`true`,`false`,`undefined`],"aria-haspopup":zA,"aria-hidden":zA,"aria-invalid":[`true`,`false`,`grammar`,`spelling`],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":[`off`,`polite`,`assertive`],"aria-multiline":zA,"aria-multiselectable":zA,"aria-owns":null,"aria-posinset":null,"aria-pressed":[`true`,`false`,`mixed`,`undefined`],"aria-readonly":zA,"aria-relevant":null,"aria-required":zA,"aria-selected":[`true`,`false`,`undefined`],"aria-setsize":null,"aria-sort":[`ascending`,`descending`,`none`,`other`],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},HA=`beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload`.split(` `).map(e=>`on`+e);for(let e of HA)VA[e]=null;var UA=class{constructor(e,t){this.tags={...BA,...e},this.globalAttrs={...VA,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};UA.default=new UA;function WA(e,t,n=e.length){if(!t)return``;let r=t.firstChild,i=r&&r.getChild(`TagName`);return i?e.sliceString(i.from,Math.min(i.to,n)):``}function GA(e,t=!1){for(;e;e=e.parent)if(e.name==`Element`)if(t)t=!1;else return e;return null}function KA(e,t,n){return n.tags[WA(e,GA(t))]?.children||n.allTags}function qA(e,t){let n=[];for(let r=GA(t);r&&!r.type.isTop;r=GA(r.parent)){let i=WA(e,r);if(i&&r.lastChild.name==`CloseTag`)break;i&&n.indexOf(i)<0&&(t.name==`EndTag`||t.from>=r.firstChild.to)&&n.push(i)}return n}var JA=/^[:\-\.\w\u00b7-\uffff]*$/;function YA(e,t,n,r,i){let a=/\s*>/.test(e.sliceDoc(i,i+5))?``:`>`,o=GA(n,n.name==`StartTag`||n.name==`TagName`);return{from:r,to:i,options:KA(e.doc,o,t).map(e=>({label:e,type:`type`})).concat(qA(e.doc,n).map((e,t)=>({label:`/`+e,apply:`/`+e+a,type:`type`,boost:99-t}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function XA(e,t,n,r){let i=/\s*>/.test(e.sliceDoc(r,r+5))?``:`>`;return{from:n,to:r,options:qA(e.doc,t).map((e,t)=>({label:e,apply:e+i,type:`type`,boost:99-t})),validFor:JA}}function ZA(e,t,n,r){let i=[],a=0;for(let r of KA(e.doc,n,t))i.push({label:`<`+r,type:`type`});for(let t of qA(e.doc,n))i.push({label:`</`+t+`>`,type:`type`,boost:99-a++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function QA(e,t,n,r,i){let a=GA(n),o=a?t.tags[WA(e.doc,a)]:null,s=o&&o.attrs?Object.keys(o.attrs):[];return{from:r,to:i,options:(o&&o.globalAttrs===!1?s:s.length?s.concat(t.globalAttrNames):t.globalAttrNames).map(e=>({label:e,type:`property`})),validFor:JA}}function $A(e,t,n,r,i){let a=n.parent?.getChild(`AttributeName`),o=[],s;if(a){let c=e.sliceDoc(a.from,a.to),l=t.globalAttrs[c];if(!l){let r=GA(n),i=r?t.tags[WA(e.doc,r)]:null;l=i?.attrs&&i.attrs[c]}if(l){let t=e.sliceDoc(r,i).toLowerCase(),n=`"`,a=`"`;/^['"]/.test(t)?(s=t[0]==`"`?/^[^"]*$/:/^[^']*$/,n=``,a=e.sliceDoc(i,i+1)==t[0]?``:t[0],t=t.slice(1),r++):s=/^[^\s<>='"]*$/;for(let e of l)o.push({label:e,apply:n+e+a,type:`constant`})}}return{from:r,to:i,options:o,validFor:s}}function ej(e,t){let{state:n,pos:r}=t,i=Yt(n).resolveInner(r,-1),a=i.resolve(r);for(let e=r,t;a==i&&(t=i.childBefore(e));){let n=t.lastChild;if(!n||!n.type.isError||n.from<n.to)break;a=i=t,e=n.from}return i.name==`TagName`?i.parent&&/CloseTag$/.test(i.parent.name)?XA(n,i,i.from,r):YA(n,e,i,i.from,r):i.name==`StartTag`||i.name==`IncompleteTag`?YA(n,e,i,r,r):i.name==`StartCloseTag`||i.name==`IncompleteCloseTag`?XA(n,i,r,r):i.name==`OpenTag`||i.name==`SelfClosingTag`||i.name==`AttributeName`?QA(n,e,i,i.name==`AttributeName`?i.from:r,r):i.name==`Is`||i.name==`AttributeValue`||i.name==`UnquotedAttributeValue`?$A(n,e,i,i.name==`Is`?r:i.from,r):t.explicit&&(a.name==`Element`||a.name==`Text`||a.name==`Document`)?ZA(n,e,i,r):null}function tj(e){return ej(UA.default,e)}function nj(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new UA(t,n):UA.default;return e=>ej(r,e)}var rj=SA.parser.configure({top:`SingleExpression`}),ij=[{tag:`script`,attrs:e=>e.type==`text/typescript`||e.lang==`ts`,parser:wA.parser},{tag:`script`,attrs:e=>e.type==`text/babel`||e.type==`text/jsx`,parser:TA.parser},{tag:`script`,attrs:e=>e.type==`text/typescript-jsx`,parser:EA.parser},{tag:`script`,attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:rj},{tag:`script`,attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:SA.parser},{tag:`style`,attrs(e){return(!e.lang||e.lang==`css`)&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:Dk.parser}],aj=[{name:`style`,parser:Dk.parser.configure({top:`Styles`})}].concat(HA.map(e=>({name:e,parser:SA.parser}))),oj=xn.define({name:`html`,parser:EO.configure({props:[Tn.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let n=e.node;;){let e=n.lastChild;if(!e||e.name!=`Element`||e.to!=n.to)break;t=n=e}return t&&!((n=t.lastChild)&&(n.name==`CloseTag`||n.name==`SelfClosingTag`))?e.lineIndent(t.from)+e.unit:null}}),Dn.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!=`OpenTag`?null:{from:t.to,to:n.name==`CloseTag`?n.from:e.to}}}),gn.add({"OpenTag CloseTag":e=>e.getChild(`TagName`)})]}),languageData:{commentTokens:{block:{open:`<!--`,close:`-->`}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:`-_`}}),sj=oj.configure({wrap:AO(ij,aj)});function cj(e={}){let t=``,n;return e.matchClosingTags===!1&&(t=`noMatch`),e.selfClosingTags===!0&&(t=(t?t+` `:``)+`selfClosing`),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=AO((e.nestedLanguages||[]).concat(ij),(e.nestedAttributes||[]).concat(aj))),new vn(n?oj.configure({wrap:n,dialect:t}):t?sj.configure({dialect:t}):sj,[sj.data.of({autocomplete:nj(e)}),e.autoCloseTags===!1?[]:uj,AA().support,Ok().support])}var lj=new Set(`area base br col command embed frame hr img input keygen link meta param source track wbr menuitem`.split(` `)),uj=rn.inputHandler.of((e,t,n,r,i)=>{if(e.composing||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!sj.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let t=o.doc.sliceString(e.from-1,e.to)==r,{head:n}=e,i=Yt(o).resolveInner(n,-1),a;if(t&&r==`>`&&i.name==`EndTag`){let t=i.parent;if(t.parent?.lastChild?.name!=`CloseTag`&&(a=WA(o.doc,t.parent,n))&&!lj.has(a))return{range:e,changes:{from:n,to:n+ +(o.doc.sliceString(n,n+1)===`>`),insert:`</${a}>`}}}else if(t&&r==`/`&&i.name==`IncompleteCloseTag`){let e=i.parent;if(i.from==n-2&&e.lastChild?.name!=`CloseTag`&&(a=WA(o.doc,e,n))&&!lj.has(a)){let e=n+ +(o.doc.sliceString(n,n+1)===`>`),t=`${a}>`;return{range:$t.cursor(n+t.length,-1),changes:{from:n,to:e,insert:t}}}}return{range:e}});return s.changes.empty?!1:(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),dj=ln({commentTokens:{block:{open:`<!--`,close:`-->`}}}),fj=new Bt,pj=XE.configure({props:[Dn.add(e=>!e.is(`Block`)||e.is(`Document`)||mj(e)!=null||hj(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),fj.add(mj),Tn.add({Document:()=>null}),mn.add({Document:dj})]});function mj(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function hj(e){return e.name==`OrderedList`||e.name==`BulletList`}function gj(e,t){let n=e;for(;;){let e=n.nextSibling,r;if(!e||(r=mj(e.type))!=null&&r<=t)break;n=e}return n.to}var _j=cn.of((e,t,n)=>{for(let r=Yt(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let e=r.type.prop(fj);if(e==null)continue;let t=gj(r,e);if(t>n)return{from:n,to:t}}return null});function vj(e){return new dn(dj,e,[],`markdown`)}var yj=vj(pj),bj=vj(pj.configure([gD,yD,vD,bD,{props:[Dn.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));function xj(e,t){return n=>{if(n&&e){let t=null;if(n=/\S*/.exec(n)[0],t=typeof e==`function`?e(n):sn.matchLanguageName(e,n,!0),t instanceof sn)return t.support?t.support.language.parser:Sn.getSkippingParser(t.load());if(t)return t.parser}return t?t.parser:null}}var Sj=class{constructor(e,t,n,r,i,a,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=i,this.type=a,this.item=o}blank(e,t=!0){let n=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(e!=null){for(;n.length<e;)n+=` `;return n}else{for(let e=this.to-this.from-n.length-this.spaceAfter.length;e>0;e--)n+=` `;return n+(t?this.spaceAfter:``)}}marker(e,t){let n=this.node.name==`OrderedList`?String(+wj(this.item,e)[2]+t):``;return this.spaceBefore+n+this.type+this.spaceAfter}};function Cj(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if(t.name==`FencedCode`)return r;(t.name==`ListItem`||t.name==`Blockquote`)&&n.push(t)}for(let e=n.length-1;e>=0;e--){let i=n[e],a,o=t.lineAt(i.from),s=i.from-o.from;if(i.name==`Blockquote`&&(a=/^ *>( ?)/.exec(o.text.slice(s))))r.push(new Sj(i,s,s+a[0].length,``,a[1],`>`,null));else if(i.name==`ListItem`&&i.parent.name==`OrderedList`&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(s)))){let e=a[3],t=a[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new Sj(i.parent,s,s+t,a[1],e,a[2],i))}else if(i.name==`ListItem`&&i.parent.name==`BulletList`&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))){let e=a[4],t=a[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=a[2];a[3]&&(n+=a[3].replace(/[xX]/,` `)),r.push(new Sj(i.parent,s,s+t,a[1],e,n,i))}}return r}function wj(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function Tj(e,t,n,r=0){for(let i=-1,a=e;;){if(a.name==`ListItem`){let e=wj(a,t),o=+e[2];if(i>=0){if(o!=i+1)return;n.push({from:a.from+e[1].length,to:a.from+e[0].length,insert:String(i+2+r)})}i=o}let e=a.nextSibling;if(!e)break;a=e}}function Ej(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(Ht)!=` `)return e;let r=Vt(e,4,n),i=``;for(let e=r;e>0;)e>=4?(i+=` `,e-=4):(i+=` `,e--);return i+e.slice(n)}var Dj=((e={})=>({state:t,dispatch:n})=>{let r=Yt(t),{doc:i}=t,a=null,o=t.changeByRange(n=>{if(!n.empty||!bj.isActiveAt(t,n.from,-1)&&!bj.isActiveAt(t,n.from,1))return a={range:n};let o=n.from,s=i.lineAt(o),c=Cj(r.resolveInner(o,-1),i);for(;c.length&&c[c.length-1].from>o-s.from;)c.pop();if(!c.length)return a={range:n};let l=c[c.length-1];if(l.to-l.spaceAfter.length>o-s.from)return a={range:n};let u=o>=l.to-l.spaceAfter.length&&!/\S/.test(s.text.slice(l.to));if(l.item&&u){let n=l.node.firstChild,r=l.node.getChild(`ListItem`,`ListItem`);if(n.to>=o||r&&r.to<o||s.from>0&&!/[^\s>]/.test(i.lineAt(s.from-1).text)||e.nonTightLists===!1){let e=c.length>1?c[c.length-2]:null,t,n=``;e&&e.item?(t=s.from+e.from,n=e.marker(i,1)):t=s.from+(e?e.to:0);let r=[{from:t,to:o,insert:n}];return l.node.name==`OrderedList`&&Tj(l.item,i,r,-2),e&&e.node.name==`OrderedList`&&Tj(e.item,i,r),{range:$t.cursor(t+n.length),changes:r}}else{let e=Aj(c,t,s);return{range:$t.cursor(o+e.length+1),changes:{from:s.from,insert:e+t.lineBreak}}}}if(l.node.name==`Blockquote`&&u&&s.from){let e=i.lineAt(s.from-1),r=/>\s*$/.exec(e.text);if(r&&r.index==l.from){let i=t.changes([{from:e.from+r.index,to:e.to},{from:s.from+l.from,to:s.to}]);return{range:n.map(i),changes:i}}}let d=[];l.node.name==`OrderedList`&&Tj(l.item,i,d);let f=l.item&&l.item.from<s.from,p=``;if(!f||/^[\s\d.)\-+*>]*/.exec(s.text)[0].length>=l.to)for(let e=0,t=c.length-1;e<=t;e++)p+=e==t&&!f?c[e].marker(i,1):c[e].blank(e<t?Vt(s.text,4,c[e+1].from)-p.length:null);let m=o;for(;m>s.from&&/\s/.test(s.text.charAt(m-s.from-1));)m--;return p=Ej(p,t),kj(l.node,t.doc)&&(p=Aj(c,t,s)+t.lineBreak+p),d.push({from:m,to:o,insert:t.lineBreak+p}),{range:$t.cursor(m+p.length+1),changes:d}});return a?!1:(n(t.update(o,{scrollIntoView:!0,userEvent:`input`})),!0)})();function Oj(e){return e.name==`QuoteMark`||e.name==`ListMark`}function kj(e,t){if(e.name!=`OrderedList`&&e.name!=`BulletList`)return!1;let n=e.firstChild,r=e.getChild(`ListItem`,`ListItem`);if(!r)return!1;let i=t.lineAt(n.to),a=t.lineAt(r.from),o=/^[\s>]*$/.test(i.text);return i.number+ +!o<a.number}function Aj(e,t,n){let r=``;for(let t=0,i=e.length-2;t<=i;t++)r+=e[t].blank(t<i?Vt(n.text,4,e[t+1].from)-r.length:null,t<i);return Ej(r,t)}function jj(e,t){let n=e.resolveInner(t,-1),r=t;Oj(n)&&(r=n.from,n=n.parent);for(let e;e=n.childBefore(r);)if(Oj(e))r=e.from;else if(e.name==`OrderedList`||e.name==`BulletList`)n=e.lastChild,r=n.to;else break;return n}var Mj=[{key:`Enter`,run:Dj},{key:`Backspace`,run:({state:e,dispatch:t})=>{let n=Yt(e),r=null,i=e.changeByRange(t=>{let i=t.from,{doc:a}=e;if(t.empty&&bj.isActiveAt(e,t.from)){let t=a.lineAt(i),r=Cj(jj(n,i),a);if(r.length){let n=r[r.length-1],a=n.to-n.spaceAfter.length+ +!!n.spaceAfter;if(i-t.from>a&&!/\S/.test(t.text.slice(a,i-t.from)))return{range:$t.cursor(t.from+a),changes:{from:t.from+a,to:i}};if(i-t.from==a&&(!n.item||t.from<=n.item.from||!/\S/.test(t.text.slice(0,n.to)))){let r=t.from+n.from;if(n.item&&n.node.from<n.item.from&&/\S/.test(t.text.slice(n.from,n.to))){let i=n.blank(Vt(t.text,4,n.to)-Vt(t.text,4,n.from));return r==t.from&&(i=Ej(i,e)),{range:$t.cursor(r+i.length),changes:{from:r,to:t.from+n.to,insert:i}}}if(r<i)return{range:$t.cursor(r),changes:{from:r,to:i}}}}}return r={range:t}});return r?!1:(t(e.update(i,{scrollIntoView:!0,userEvent:`delete`})),!0)}}],Nj=cj({matchClosingTags:!1});function Pj(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:i}=yj,completeHTMLTags:a=!0,pasteURLAsLink:o=!0,htmlTagLanguage:s=Nj}=e;if(!(i instanceof SE))throw RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=e.extensions?[e.extensions]:[],l=[s.support,_j],u;o&&l.push(zj),n instanceof vn?(l.push(n.support),u=n.language):n&&(u=n);let d=t||u?xj(t,u):void 0;c.push(QE({codeParser:d,htmlParser:s.language.parser})),r&&l.push(hn.high(_n.of(Mj)));let f=vj(i.configure(c));return a&&l.push(f.data.of({autocomplete:Fj})),new vn(f,l)}function Fj(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let i=Yt(t).resolveInner(n,-1);for(;i&&!i.type.isTop;){if(i.name==`CodeBlock`||i.name==`FencedCode`||i.name==`ProcessingInstructionBlock`||i.name==`CommentBlock`||i.name==`Link`||i.name==`Image`)return null;i=i.parent}return{from:n-r[0].length,to:n,options:Lj(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}var Ij=null;function Lj(){if(Ij)return Ij;let e=tj(new Mn(Ut.create({extensions:Nj}),0,!0));return Ij=e?e.options:[]}var Rj=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,zj=rn.domEventHandlers({paste:(e,t)=>{let{main:n}=t.state.selection;if(n.empty)return!1;let r=e.clipboardData?.getData(`text/plain`);if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r=`https://`+r),!bj.isActiveAt(t.state,n.from,1)))return!1;let i=Yt(t.state),a=!1;return i.iterate({from:n.from,to:n.to,enter:e=>{(e.from>n.from||Rj.test(e.name))&&(a=!0)},leave:e=>{e.to<n.to&&(a=!0)}}),a?!1:(t.dispatch({changes:[{from:n.from,insert:`[`},{from:n.to,insert:`](${r})`}],userEvent:`input.paste`,scrollIntoView:!0}),!0)}});function Bj(){return Bj=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Bj.apply(null,arguments)}var Vj=e=>{var{theme:t,settings:n={},styles:r=[]}=e,i={".cm-gutters":{}},a={};n.background&&(a.backgroundColor=n.background),n.backgroundImage&&(a.backgroundImage=n.backgroundImage),n.foreground&&(a.color=n.foreground),n.fontSize&&(a.fontSize=n.fontSize),(n.background||n.foreground)&&(i[`&`]=a),n.fontFamily&&(i[`&.cm-editor .cm-scroller`]={fontFamily:n.fontFamily}),n.gutterBackground&&(i[`.cm-gutters`].backgroundColor=n.gutterBackground),n.gutterForeground&&(i[`.cm-gutters`].color=n.gutterForeground),n.gutterBorder&&(i[`.cm-gutters`].borderRightColor=n.gutterBorder),n.caret&&(i[`.cm-content`]={caretColor:n.caret},i[`.cm-cursor, .cm-dropCursor`]={borderLeftColor:n.caret});var o={};return n.gutterActiveForeground&&(o.color=n.gutterActiveForeground),n.lineHighlight&&(i[`.cm-activeLine`]={backgroundColor:n.lineHighlight},o.backgroundColor=n.lineHighlight),i[`.cm-activeLineGutter`]=o,n.selection&&(i[`&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection`]={background:n.selection+` !important`}),n.selectionMatch&&(i[`& .cm-selectionMatch`]={backgroundColor:n.selectionMatch}),[rn.theme(i,{dark:t===`dark`}),Jt(Cn.define(r))]},Hj={background:`#2E3235`,foreground:`#DDDDDD`,caret:`#DDDDDD`,selection:`#202325`,selectionMatch:`#202325`,gutterBackground:`#292d30`,gutterForeground:`#808080`,gutterBorder:`1px solid #ffffff10`,lineHighlight:`#B9D2FF30`},Uj=[{tag:W.keyword,color:`#fda331`},{tag:[W.name,W.deleted,W.character,W.propertyName,W.macroName],color:`#b5bd68`},{tag:[W.variableName],color:`#6fb3d2`},{tag:[W.function(W.variableName)],color:`#fda331`},{tag:[W.labelName],color:`#fc6d24`},{tag:[W.color,W.constant(W.name),W.standard(W.name)],color:`#fda331`},{tag:[W.definition(W.name),W.separator],color:`#cc99cc`},{tag:[W.brace],color:`#cc99cc`},{tag:[W.annotation],color:`#fc6d24`},{tag:[W.number,W.changed,W.annotation,W.modifier,W.self,W.namespace],color:`#fda331`},{tag:[W.typeName,W.className],color:`#6fb3d2`},{tag:[W.operator,W.operatorKeyword],color:`#cc99cc`},{tag:[W.tagName],color:`#fda331`},{tag:[W.squareBracket],color:`#cc99cc`},{tag:[W.angleBracket],color:`#cc99cc`},{tag:[W.attributeName],color:`#6fb3d2`},{tag:[W.regexp],color:`#fda331`},{tag:[W.quote],color:`#DDDDDD`},{tag:[W.string],color:`#b5bd68`},{tag:W.link,color:`#6987AF`,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[W.url,W.escape,W.special(W.string)],color:`#8abeb7`},{tag:[W.meta],color:`#A54543`},{tag:[W.comment],color:`#808080`,fontStyle:`italic`},{tag:W.monospace,color:`#DDDDDD`},{tag:W.strong,fontWeight:`bold`,color:`#fda331`},{tag:W.emphasis,fontStyle:`italic`,color:`#6fb3d2`},{tag:W.strikethrough,textDecoration:`line-through`},{tag:W.heading,fontWeight:`bold`,color:`#DDDDDD`},{tag:W.special(W.heading1),fontWeight:`bold`,color:`#DDDDDD`},{tag:W.heading1,fontWeight:`bold`,color:`#DDDDDD`},{tag:[W.heading2,W.heading3,W.heading4],fontWeight:`bold`,color:`#DDDDDD`},{tag:[W.heading5,W.heading6],color:`#DDDDDD`},{tag:[W.atom,W.bool,W.special(W.variableName)],color:`#8abeb7`},{tag:[W.processingInstruction,W.inserted],color:`#8abeb7`},{tag:[W.contentSeparator],color:`#6fb3d2`},{tag:W.invalid,color:`#B9D2FF`,borderBottom:`1px dotted #fc6d24`}],Wj=e=>{var{theme:t=`dark`,settings:n={},styles:r=[]}=e||{};return Vj({theme:t,settings:Bj({},Hj,n),styles:[...Uj,...r]})};Wj();var Gj={background:`#ffffff`,foreground:`#2e3440`,caret:`#3b4252`,selection:`#eceff4`,selectionMatch:`#e5e9f0`,gutterBackground:`#eceff4`,gutterForeground:`#2e3440`,gutterBorder:`none`,lineHighlight:`#02255f11`},Kj=[{tag:W.keyword,color:`#5e81ac`},{tag:[W.name,W.deleted,W.character,W.propertyName,W.macroName],color:`#d08770`},{tag:[W.variableName],color:`#d08770`},{tag:[W.function(W.variableName)],color:`#5e81ac`},{tag:[W.labelName],color:`#81a1c1`},{tag:[W.color,W.constant(W.name),W.standard(W.name)],color:`#5e81ac`},{tag:[W.definition(W.name),W.separator],color:`#a3be8c`},{tag:[W.brace],color:`#8fbcbb`},{tag:[W.annotation],color:`#d30102`},{tag:[W.number,W.changed,W.annotation,W.modifier,W.self,W.namespace],color:`#88c0d0`},{tag:[W.typeName,W.className],color:`#ebcb8b`},{tag:[W.operator,W.operatorKeyword],color:`#a3be8c`},{tag:[W.tagName],color:`#b48ead`},{tag:[W.squareBracket],color:`#bf616a`},{tag:[W.angleBracket],color:`#d08770`},{tag:[W.attributeName],color:`#ebcb8b`},{tag:[W.regexp],color:`#5e81ac`},{tag:[W.quote],color:`#3b4252`},{tag:[W.string],color:`#d08770`},{tag:W.link,color:`#8fbcbb`,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[W.url,W.escape,W.special(W.string)],color:`#d08770`},{tag:[W.meta],color:`#88c0d0`},{tag:[W.comment],color:`#434c5e`,fontStyle:`italic`},{tag:W.strong,fontWeight:`bold`,color:`#5e81ac`},{tag:W.emphasis,fontStyle:`italic`,color:`#5e81ac`},{tag:W.strikethrough,textDecoration:`line-through`},{tag:W.heading,fontWeight:`bold`,color:`#5e81ac`},{tag:W.special(W.heading1),fontWeight:`bold`,color:`#5e81ac`},{tag:W.heading1,fontWeight:`bold`,color:`#5e81ac`},{tag:[W.heading2,W.heading3,W.heading4],fontWeight:`bold`,color:`#5e81ac`},{tag:[W.heading5,W.heading6],color:`#5e81ac`},{tag:[W.atom,W.bool,W.special(W.variableName)],color:`#d08770`},{tag:[W.processingInstruction,W.inserted],color:`#8fbcbb`},{tag:[W.contentSeparator],color:`#ebcb8b`},{tag:W.invalid,color:`#434c5e`,borderBottom:`1px dotted #d30102`}],qj=e=>{var{theme:t=`light`,settings:n={},styles:r=[]}=e||{};return Vj({theme:t,settings:Bj({},Gj,n),styles:[...Kj,...r]})};qj();var Jj=[sn.of({name:`javascript`,alias:[`js`,`jsx`],extensions:[`js`,`mjs`,`cjs`,`jsx`],load:async()=>AA({jsx:!0})}),sn.of({name:`typescript`,alias:[`ts`,`tsx`],extensions:[`ts`,`mts`,`cts`,`tsx`],load:async()=>AA({typescript:!0,jsx:!0})}),sn.of({name:`json`,alias:[`jsonc`],extensions:[`json`,`jsonc`],load:()=>n(()=>import(`./dist-C3u7R0q7.js`).then(e=>e.json()),__vite__mapDeps([0,1,2,3,4]),import.meta.url)}),sn.of({name:`yaml`,alias:[`yml`],extensions:[`yaml`,`yml`],load:()=>n(()=>import(`./dist-Dtie9-Ui.js`).then(e=>e.yaml()),__vite__mapDeps([5,1,2,3,4]),import.meta.url)}),sn.of({name:`css`,alias:[`scss`,`less`],extensions:[`css`,`scss`,`less`],load:async()=>Ok()}),sn.of({name:`html`,alias:[`htm`],extensions:[`html`,`htm`],load:async()=>cj()}),sn.of({name:`python`,alias:[`py`],extensions:[`py`,`pyw`],load:()=>n(()=>import(`./dist-C82hC0q7.js`).then(e=>e.python()),__vite__mapDeps([6,7,1,2,3,4]),import.meta.url)}),sn.of({name:`rust`,alias:[`rs`],extensions:[`rs`],load:()=>n(()=>import(`./dist-mXs-_OvZ.js`).then(e=>e.rust()),__vite__mapDeps([8,1,2,3,4]),import.meta.url)}),sn.of({name:`markdown`,alias:[`md`,`mdx`],extensions:[`md`,`mdx`,`markdown`],load:async()=>Pj()}),sn.of({name:`bash`,alias:[`sh`,`shell`,`zsh`],extensions:[`sh`,`bash`,`zsh`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:t},{shell:r}]=await Promise.all([n(()=>import(`./dist-dkPJvrfr.js`).then(e=>e.m),__vite__mapDeps([1,2,3]),import.meta.url),n(()=>import(`./shell-BXlbE6k8.js`),[],import.meta.url)]);return new t(e.define(r))}}),sn.of({name:`go`,alias:[`golang`],extensions:[`go`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:t},{go:r}]=await Promise.all([n(()=>import(`./dist-dkPJvrfr.js`).then(e=>e.m),__vite__mapDeps([1,2,3]),import.meta.url),n(()=>import(`./go-DoDnGodl.js`),[],import.meta.url)]);return new t(e.define(r))}})],Yj=Xt.define(),Xj=Xt.define(),Zj=bn.line({class:`agent-flash`}),Qj=Qt.define({create(){return bn.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Yj)){let{from:r,to:i}=n.value,a=[];for(let e=r;e<=i;){let n=t.state.doc.lineAt(e);a.push(Zj.range(n.from)),e=n.to+1}e=e.update({add:a,sort:!0})}else n.is(Xj)&&(e=bn.none);return e},provide:e=>rn.decorations.from(e)});function $j(e){let t=e.getMap(`agent-flash`);return[Qj,an.define(e=>{let n=0,r=Date.now(),i=null,a=null,o=!1;function s(){let t=e.state.doc.length;t!==0&&(o||(e.dispatch({effects:Yj.of({from:0,to:t})}),a&&clearTimeout(a),a=setTimeout(()=>{a=null,!o&&e.dispatch({effects:Xj.of(null)})},De)))}let c=e=>{if(Ie(t),!Me(t,r))return;r=Date.now();let a=Date.now();if(a-n<500){if(!i){let e=500-(a-n);i=setTimeout(()=>{i=null,n=Date.now(),s()},e)}return}n=a,s()};t.observe(c);let l=()=>{document.visibilityState===`visible`?Me(t,r)&&(r=Date.now(),n=Date.now(),s()):r=Date.now()};return document.addEventListener(`visibilitychange`,l),{update(e){},destroy(){o=!0,t.unobserve(c),document.removeEventListener(`visibilitychange`,l),i&&=(clearTimeout(i),null),a&&=(clearTimeout(a),null)}}})]}var eM=/\[([^\]\n]*)\]\((<[^>\n]+>|[^)\s\n]+)(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?\)/g,tM=bn.mark({class:`cm-md-internal-link`});function nM(e,t){return t>0&&e[t-1]===`!`}function rM(e){let t=e[2]??``;return t.startsWith(`<`)&&t.endsWith(`>`)?t.slice(1,-1):t}function iM(e){let t=new pn;for(let{from:n,to:r}of e.visibleRanges){let i=e.state.doc.sliceString(n,r);eM.lastIndex=0;let a=eM.exec(i);for(;a!==null;){let e=nM(i,a.index)?null:PS(rM(a));e&&e.kind!==`external`&&t.add(n+a.index,n+a.index+a[0].length,tM),a=eM.exec(i)}}return t.finish()}var aM=an.fromClass(class{decorations;constructor(e){this.decorations=iM(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=iM(e.view))}},{decorations:e=>e.decorations}),oM=rn.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);eM.lastIndex=0;let i=eM.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=nM(r.text,i.index)?null:PS(rM(i));if(t&&t.kind!==`external`)return e.preventDefault(),t.kind===`doc`&&zS(e)?(RS(t),!0):(VS(t),!0)}i=eM.exec(r.text)}return!1}}),sM=rn.theme({".cm-md-internal-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-md-internal-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function cM(){return[aM,oM,sM]}var lM=5e3,uM=null,dM=0,fM=null,pM=new Map;async function mM(){let e=Date.now();return uM&&e-dM<lM?uM:(uM=await qC(),dM=e,fM=bM(uM),uM)}async function hM(e){let t=Date.now(),n=pM.get(e);if(n!==void 0&&t-n.time<lM)return n.headings;try{let n=await JC(e);return pM.set(e,{headings:n,time:t}),n}catch(n){return console.warn(`[wiki-link-source] /api/page-headings fetch failed:`,n),pM.set(e,{headings:[],time:t}),[]}}var gM=/\[\[[^\]]*?\]\]/g,_M=bn.mark({class:`cm-wiki-link`}),vM=bn.mark({class:`cm-wiki-link cm-wiki-link-broken`});function yM(e){let t=new Set;for(let n of e)t.add(n.docName.toLowerCase()),n.title&&t.add(n.title.toLowerCase());return t}function bM(e){let t=yM(e);for(let n of e){let e=n.docName.split(`/`);e.pop();let r=``;for(let n of e)r=r?`${r}/${n}`:n,t.add(r.toLowerCase())}return t}function xM(e){return e.split(/[#|]/)[0].trim().toLowerCase()}function SM(e){let t=new pn,n=uM?fM:null;for(let{from:r,to:i}of e.visibleRanges){let a=e.state.doc.sliceString(r,i);gM.lastIndex=0;let o=gM.exec(a);for(;o!==null;){let e=_M;if(n){let t=xM(o[0].slice(2,-2));t&&!n.has(t)&&(e=vM)}t.add(r+o.index,r+o.index+o[0].length,e),o=gM.exec(a)}}return t.finish()}var CM=an.fromClass(class{decorations;cacheWarmAtBuild;constructor(e){this.cacheWarmAtBuild=uM!==null,this.decorations=SM(e),this.cacheWarmAtBuild||this.warmCache(e)}update(e){let t=uM!==null;(e.docChanged||e.viewportChanged||!this.cacheWarmAtBuild&&t)&&(this.cacheWarmAtBuild=t,this.decorations=SM(e.view))}warmCache(e){mM().then(()=>{try{e.dispatch({})}catch{}}).catch(e=>{console.warn(`[wiki-link-source] warmCache fetch failed:`,e)})}},{decorations:e=>e.decorations}),wM=/\[\[([^[\]|#]+?)(?:#([^\]|]+?))?(?:\|([^\]]+?))?\]\]/g,TM=rn.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);wM.lastIndex=0;let i=wM.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=i[1]?.trim(),n=i[2]?.trim()||null;if(t){let r=c(t,n);if(!r)return!1;e.preventDefault(),r.kind===`external`?window.open(r.url,`_blank`,`noopener,noreferrer`):zS(e)?RS(r):window.location.hash=r.anchor?`#/${r.docName}?anchor=${encodeURIComponent(r.anchor)}`:`#/${r.docName}`}return!0}i=wM.exec(r.text)}return!1}});async function EM(e){let t=e.state.doc.sliceString(0,e.pos).match(/\[\[([^\]]*)$/);if(!t)return null;let n=t[1],r=e.pos-n.length,i=n.indexOf(`#`);if(i>0){let e=n.slice(0,i),t=n.slice(i+1),a=r+i+1,o=await hM(e);if(!o.length)return null;let s=HC(o,t);return s.length?{from:a,filter:!1,options:s.map(e=>({label:e.text,detail:`H${e.level}`,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.slug+a},selection:{anchor:r+e.slug.length+a.length}})}}))}:null}return{from:r,filter:!1,options:VC(await mM().catch(e=>(console.warn(`[wiki-link-source] Failed to fetch pages:`,e),[])),n).map(e=>({label:e.title,detail:e.title===e.docName?void 0:e.docName,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.docName+a},selection:{anchor:r+e.docName.length+a.length}})}}))}}var DM=rn.theme({".cm-wiki-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-wiki-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function OM(){return[CM,TM,DM,bj.data.of({autocomplete:EM})]}var kM=Wj({settings:{background:`transparent`,gutterBackground:`transparent`}}),AM=qj({settings:{background:`transparent`,gutterBackground:`transparent`}});function jM(e){let{themeCompartment:t,resolvedTheme:n,ydoc:r}=e,i=n===`dark`?kM:AM;return[Pj({base:bj,extensions:[gD],codeLanguages:Jj}),OM(),cM(),...r?[$j(r)]:[],_n.of([]),t.of(i),rn.lineWrapping,...e.extraKeymaps?[e.extraKeymaps]:[]]}function MM(e,t,n){let{state:r}=e,i=r.selection.main;if(!i.empty)return!1;if(t===`line`){let e=r.doc.lineAt(i.head);return n<0?e.from===0:e.to===r.doc.length}return n<0?i.head===0:i.head===r.doc.length}function NM(e){let{pmSel:t,nodePos:n,nodeSize:r,cmDocLen:i,cmSel:a,cmHasFocus:o}=e;if(t instanceof pe&&t.from===n)return o?{kind:`noop`}:{kind:`focus`};let s=n+1,c=n+r-1;if(t.from>=s&&t.to<=c){let e=Math.max(0,Math.min(t.anchor-s,i)),n=Math.max(0,Math.min(t.head-s,i));return a.anchor===e&&a.head===n&&o?{kind:`noop`}:{kind:`selection`,anchor:e,head:n}}return{kind:`noop`}}function PM(e,t){let n=pT().parseWithFallback(e),r;try{r=t.nodeFromJSON(n)}catch(e){return console.warn(JSON.stringify({event:`raw-mdx-upgrade-failure`,reason:e instanceof Error?e.message:String(e)})),null}if(r.childCount===0)return null;let i=[];for(let e=0;e<r.childCount;e++){let t=r.child(e);if(t.type.name===`rawMdxFallback`)return null;i.push(t)}return i}function FM(e,t){if(e===t)return null;let n=0,r=e.length,i=t.length;for(;n<r&&e.charCodeAt(n)===t.charCodeAt(n);)n++;for(;r>n&&i>n&&e.charCodeAt(r-1)===t.charCodeAt(i-1);)r--,i--;return{from:n,to:r,text:t.slice(n,i)}}function IM(e){let t=(0,q.c)(41),{node:n,editor:r,getPos:i}=e,a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(!1),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=new En,t[0]=c):c=t[0];let l=(0,G.useRef)(c),{resolvedTheme:u}=w(),d=n.attrs.reason||`Parse failed`,f;t[1]===d?f=t[2]:(f=HT(d),t[1]=d,t[2]=f);let p=f,m=UT[p],h;t[3]!==r||t[4]!==i?(h=e=>{let t=typeof i==`function`?i():void 0;if(t===void 0)return;let n=BT(r);if(!n)return;let a=n.state.doc.nodeAt(t);if(!a||a.type.name!==`rawMdxFallback`)return;let o=t+1,c=t+a.nodeSize-1;s.current=!0;try{let t=n.state.tr;if(e.length===0)t.delete(o,c);else{let r=n.state.schema.text(e);t.replaceWith(o,c,r)}n.dispatch(t)}catch(e){let t=e;throw s.current=!1,t}s.current=!1},t[3]=r,t[4]=i,t[5]=h):h=t[5];let g=h,_;t[6]!==r||t[7]!==g||t[8]!==i||t[9]!==n.textContent||t[10]!==u?(_=()=>{let e=a.current;if(!e)return;let t=l.current,c=_n.of([{key:`Mod-z`,run:()=>(r.commands.undo(),!0)},{key:`Mod-y`,run:()=>(r.commands.redo(),!0)},{key:`Mod-Shift-z`,run:()=>(r.commands.redo(),!0)}]),d=e=>{let t=typeof i==`function`?i():void 0;if(typeof t!=`number`)return!1;let n=BT(r);if(!n)return!1;let a=n.state.doc.nodeAt(t);if(!a||a.type.name!==`rawMdxFallback`)return!1;let o=e<0?t:t+a.nodeSize,s=ge.near(n.state.doc.resolve(o),e);return n.dispatch(n.state.tr.setSelection(s).scrollIntoView()),n.focus(),!0},f=_n.of([{key:`ArrowUp`,run:e=>MM(e,`line`,-1)?d(-1):!1},{key:`ArrowLeft`,run:e=>MM(e,`char`,-1)?d(-1):!1},{key:`ArrowDown`,run:e=>MM(e,`line`,1)?d(1):!1},{key:`ArrowRight`,run:e=>MM(e,`char`,1)?d(1):!1}]),p=jM({themeCompartment:t,resolvedTheme:u,ydoc:VT(r)??void 0,extraKeymaps:c});p.push(f),p.push(rn.updateListener.of(e=>{if(e.docChanged&&!s.current&&g(e.state.doc.toString()),e.focusChanged&&e.view.hasFocus&&!s.current){let e=typeof i==`function`?i():void 0;if(typeof e!=`number`)return;let t=BT(r);if(!t)return;let n=t.state.selection;if(n instanceof pe&&n.from===e)return;let a=t.state.doc.nodeAt(e);if(!a||a.type.name!==`rawMdxFallback`)return;s.current=!0;try{t.dispatch(t.state.tr.setSelection(pe.create(t.state.doc,e)))}catch(e){let t=e;throw s.current=!1,t}s.current=!1}if(e.focusChanged&&!e.view.hasFocus&&!s.current){let t=typeof i==`function`?i():void 0;if(typeof t!=`number`)return;let n=BT(r);if(!n)return;let a=n.state.doc.nodeAt(t);if(!a||a.type.name!==`rawMdxFallback`)return;let o=PM(e.view.state.doc.toString(),n.state.schema);if(!o)return;s.current=!0;try{n.dispatch(n.state.tr.replaceWith(t,t+a.nodeSize,o))}catch(e){let t=e;throw s.current=!1,t}s.current=!1}}));let m=new rn({doc:n.textContent,extensions:p,parent:e});o.current=m;let h=RM,_=m.contentDOM;_.addEventListener(`keydown`,h),_.addEventListener(`paste`,h),_.addEventListener(`drop`,h),_.addEventListener(`cut`,h);let v=()=>{_.removeEventListener(`keydown`,h),_.removeEventListener(`paste`,h),_.removeEventListener(`drop`,h),_.removeEventListener(`cut`,h)};return()=>{v(),m.destroy(),o.current=null}},t[6]=r,t[7]=g,t[8]=i,t[9]=n.textContent,t[10]=u,t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[12]=v):v=t[12],(0,G.useEffect)(_,v);let y,b;t[13]===u?(y=t[14],b=t[15]):(y=()=>{let e=o.current;if(!e)return;let t=u===`dark`?kM:AM;e.dispatch({effects:l.current.reconfigure(t)})},b=[u],t[13]=u,t[14]=y,t[15]=b),(0,G.useEffect)(y,b);let x,S;t[16]!==r||t[17]!==i?(x=()=>{let e=()=>{let e=typeof i==`function`?i():void 0;if(typeof e!=`number`)return;let t=o.current;if(!t||s.current)return;let n=BT(r);if(!n)return;let a=n.state.doc.nodeAt(e);if(!a)return;let c=NM({pmSel:n.state.selection,nodePos:e,nodeSize:a.nodeSize,cmDocLen:t.state.doc.length,cmSel:{anchor:t.state.selection.main.anchor,head:t.state.selection.main.head},cmHasFocus:t.hasFocus});if(c.kind!==`noop`){s.current=!0;try{c.kind===`selection`&&t.dispatch({selection:{anchor:c.anchor,head:c.head}}),t.hasFocus||t.focus()}catch(e){let t=e;throw s.current=!1,t}s.current=!1}};return r.on(`selectionUpdate`,e),()=>{r.off(`selectionUpdate`,e)}},S=[r,i],t[16]=r,t[17]=i,t[18]=x,t[19]=S):(x=t[18],S=t[19]),(0,G.useEffect)(x,S);let C=n.textContent,T,E;t[20]===C?(T=t[21],E=t[22]):(T=()=>{let e=o.current;if(!e||s.current)return;let t=FM(e.state.doc.toString(),C);if(t){s.current=!0;try{e.dispatch({changes:{from:t.from,to:t.to,insert:t.text}})}catch(e){let t=e;throw s.current=!1,t}s.current=!1}},E=[C],t[20]=C,t[21]=T,t[22]=E),(0,G.useEffect)(T,E);let D;t[23]!==r||t[24]!==i?(D=()=>{let e=typeof i==`function`?i():void 0;typeof e==`number`&&r.chain().focus().setNodeSelection(e).deleteSelection().run()},t[23]=r,t[24]=i,t[25]=D):D=t[25];let O=D,k=`raw-mdx-fallback-wrapper relative my-2 py-2 rounded border border-dashed ${m.wrapperClass}`,A=`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider ${m.badgeClass}`,j;t[26]!==d||t[27]!==m.label||t[28]!==A?(j=(0,K.jsx)(`span`,{className:A,title:d,children:m.label}),t[26]=d,t[27]=m.label,t[28]=A,t[29]=j):j=t[29];let M;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,K.jsx)(fr,{size:12}),t[30]=M):M=t[30];let N;t[31]===O?N=t[32]:(N=(0,K.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":`Delete block`,onClick:O,children:M}),t[31]=O,t[32]=N);let P;t[33]!==j||t[34]!==N?(P=(0,K.jsxs)(`div`,{className:`absolute top-1 right-1 z-10 flex items-center gap-1.5`,contentEditable:!1,onMouseDown:LM,children:[j,N]}),t[33]=j,t[34]=N,t[35]=P):P=t[35];let F;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,K.jsx)(`div`,{ref:a,className:`raw-mdx-fallback-cm`}),t[36]=F):F=t[36];let I;return t[37]!==p||t[38]!==k||t[39]!==P?(I=(0,K.jsxs)(Wa,{className:k,contentEditable:!1,"data-drag-handle":``,draggable:`true`,"data-severity":p,children:[P,F]}),t[37]=p,t[38]=k,t[39]=P,t[40]=I):I=t[40],I}function LM(e){return e.stopPropagation()}function RM(){}function zM(e,t){if(!e.selection.empty)return null;let n=t===`up`||t===`left`?-1:1,r=e.selection.$head,i=n>0?r.after():r.before();if(typeof i!=`number`)return null;let a=ge.near(e.doc.resolve(i),n);return a.$head?.parent.type.name===`rawMdxFallback`?a:null}function BM(e,t){let{state:n,view:r}=e;if(!r.endOfTextblock(t))return!1;let i=zM(n,t);return i?(r.dispatch(n.tr.setSelection(i)),!0):!1}var VM=L.extend({addKeyboardShortcuts(){return{ArrowLeft:({editor:e})=>BM(e,`left`),ArrowRight:({editor:e})=>BM(e,`right`),ArrowUp:({editor:e})=>BM(e,`up`),ArrowDown:({editor:e})=>BM(e,`down`)}},addNodeView(){return Qa(IM,{stopEvent:()=>!0,ignoreMutation:()=>!0})}});function HM(e){let t=(0,q.c)(47),{items:n,selectedIndex:r,categoryLabels:i,onSelect:a,onHoverIndex:o}=e,s=(0,G.useRef)(null),c=(0,G.useId)(),l=r>=0&&r<n.length?`${c}-option-${r}`:void 0,u=WM,d,f;if(t[0]===r?(d=t[1],f=t[2]):(d=()=>{let e=s.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(r);t&&t.scrollIntoView({block:`nearest`})},f=[r],t[0]=r,t[1]=d,t[2]=f),(0,G.useEffect)(d,f),n.length===0){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(`div`,{ref:s,role:`status`,"aria-live":`polite`,className:`w-56 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:{maxHeight:`var(--suggestion-menu-max-height, 40vh)`},onMouseDown:u,children:`No results`}),t[3]=e):e=t[3],e}let p,m,h,g,_,v,y,b,x,S,C,w,T;if(t[4]!==l||t[5]!==i||t[6]!==n||t[7]!==c||t[8]!==o||t[9]!==a||t[10]!==r){let e=[],d=0,f=new Map;for(let t of n){f.set(t,d++);let n=e.find(e=>e.key===t.category);n?n.items.push(t):e.push({key:t.category,items:[t]})}m=r>=0&&r<n.length?n[r]:null;let E;t[24]===n?E=t[25]:(E=n.some(UM),t[24]=n,t[25]=E),p=E,v=`flex items-start gap-2`,y=s,b=`listbox`,x=`Slash commands`,S=l,C=-1,w=u,T=`w-56 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,t[26]===Symbol.for(`react.memo_cache_sentinel`)?(h={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[26]=h):h=t[26];let D=m?`${m.label}${m.preview?`. ${m.preview.description}`:``}`:``;t[27]===D?g=t[28]:(g=(0,K.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:D}),t[27]=D,t[28]=g),_=e.map(e=>(0,K.jsxs)(`div`,{role:`group`,"aria-labelledby":`${c}-group-${e.key}`,children:[(0,K.jsx)(`div`,{id:`${c}-group-${e.key}`,className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground`,children:i[e.key]??e.key}),e.items.map(e=>{let t=f.get(e)??0,n=t===r,i=e.icon;return(0,K.jsxs)(`button`,{id:`${c}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseEnter:()=>o?.(t),onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,K.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`div`,{className:`flex flex-col min-w-0`,children:(0,K.jsx)(`span`,{className:`truncate`,children:e.label})})]},e.name)})]},e.key)),t[4]=l,t[5]=i,t[6]=n,t[7]=c,t[8]=o,t[9]=a,t[10]=r,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S,t[21]=C,t[22]=w,t[23]=T}else p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20],C=t[21],w=t[22],T=t[23];let E;t[29]!==h||t[30]!==g||t[31]!==_||t[32]!==y||t[33]!==b||t[34]!==x||t[35]!==S||t[36]!==C||t[37]!==w||t[38]!==T?(E=(0,K.jsxs)(`div`,{ref:y,role:b,"aria-label":x,"aria-activedescendant":S,tabIndex:C,onMouseDown:w,className:T,style:h,children:[g,_]}),t[29]=h,t[30]=g,t[31]=_,t[32]=y,t[33]=b,t[34]=x,t[35]=S,t[36]=C,t[37]=w,t[38]=T,t[39]=E):E=t[39];let D;t[40]!==p||t[41]!==m?(D=p?(0,K.jsx)(`aside`,{"aria-hidden":`true`,onMouseDown:u,className:`w-64 rounded-lg border bg-popover p-2 shadow-md ${m?.preview?``:`invisible`}`,children:m?.preview?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`mb-2 flex aspect-5/3 items-center justify-center overflow-hidden rounded-md bg-muted/40 p-3 *:max-h-full *:max-w-full [&_img]:size-full [&_img]:rounded-md [&_img]:object-contain`,children:m.preview.render()}),(0,K.jsx)(`p`,{className:`px-1 pb-1 text-xs text-muted-foreground`,children:m.preview.description})]}):null}):null,t[40]=p,t[41]=m,t[42]=D):D=t[42];let O;return t[43]!==v||t[44]!==E||t[45]!==D?(O=(0,K.jsxs)(`div`,{className:v,children:[E,D]}),t[43]=v,t[44]=E,t[45]=D,t[46]=O):O=t[46],O}function UM(e){return e.preview}function WM(e){return e.preventDefault()}var GM=new Ke(`slashCommand`),KM=U.create({name:`slashCommand`,addOptions(){return{itemsSources:[()=>Sx],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[AC({editor:this.editor,pluginKey:GM,char:`/`,startOfLine:!1,items:({query:t})=>{let n=e.options.itemsSources.flatMap(e=>{try{return e()}catch(e){return console.error(`[slash-command] item source threw an error`,e),[]}}),r=Object.keys(e.options.categoryLabels),i=e=>{let t=r.indexOf(e);return t===-1?1/0:t};return Cx(n.map((e,t)=>({item:e,i:t})).sort((e,t)=>{let n=i(e.item.category)-i(t.item.category);return n===0?e.i-t.i:n}).map(e=>e.item),t)},command:({editor:e,range:t,props:n})=>{try{e.chain().focus().deleteRange(t).run()}catch(e){console.error(`[slash-command] deleteRange failed for "${n.name}"`,e);return}try{n.command(e)}catch(e){console.error(`[slash-command] command "${n.name}" threw an error`,e)}},render:()=>{let t=null,n=null,r=0,i={popup:null,stopAutoUpdate:null},a=null,o=e=>{e!==r&&(r=e,s())},s=()=>{!t||!n||t.updateProps({items:n.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:n.command,onHoverIndex:o})};return{onStart(s){n=s,r=0;let c=IC(()=>n,`slash-command`);i.popup=c.popup,a=c.doPosition,t=new Xa(HM,{props:{items:s.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:s.command,onHoverIndex:o},editor:s.editor}),c.popup.appendChild(t.element),i.stopAutoUpdate=c.startAutoUpdate(),c.reveal()},onUpdate(e){n=e,r=Math.min(r,Math.max(0,e.items.length-1)),s(),a?.()},onKeyDown({event:e}){if(!n||n.items.length===0)return!1;let t=n.items;if(e.key===`ArrowDown`)return r=(r+1)%t.length,s(),!0;if(e.key===`ArrowUp`)return r=(r-1+t.length)%t.length,s(),!0;if(e.key===`Enter`||e.key===`Tab`){let e=t[r];return e&&n.command(e),!0}return e.key,!1},onExit(){LC(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}}),qM=new Ke(`sourceDirty`),JM=U.create({name:`sourceDirtyObserver`,addProseMirrorPlugins(){return[new ke({key:qM,appendTransaction(e,t,n){if(!e.some(e=>!e.getMeta(Ox))||!e.some(e=>e.docChanged))return null;let r=new je;for(let t of e)r.appendMapping(t.mapping);let i=r.invert(),a=[];if(n.doc.descendants((e,n)=>{if(e.type.name!==`jsxComponent`||e.attrs.sourceDirty)return;let r=i.map(n),o=t.doc.nodeAt(r),s=!o||o.type.name!==`jsxComponent`,c=typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0;if(s&&c)return;if(!o){(e.content.size>0||Object.keys(e.attrs.props??{}).length>0)&&a.push({pos:n});return}if(o.type.name!==`jsxComponent`){a.push({pos:n});return}let l=!YM(o.attrs.props,e.attrs.props),u=!o.content.eq(e.content);(l||u)&&a.push({pos:n})}),a.length===0)return null;let o=n.tr;for(let{pos:e}of a)o.setNodeAttribute(e,`sourceDirty`,!0);return o}})]}});function YM(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!=`object`)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!YM(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!YM(e[r],t[r]))return!1;return!0}function XM(e){let t=(0,q.c)(112),{open:n,target:r,alias:i,anchor:a,pages:o,onOpenChange:s,onSave:c}=e,[l,u]=(0,G.useState)(r),[d,f]=(0,G.useState)(i??``),[p,m]=(0,G.useState)(a??``),h=(0,G.useId)(),g=(0,G.useId)(),_=(0,G.useId)(),v=(0,G.useId)(),y;t[0]!==l||t[1]!==o?(y=Zy(l,o),t[0]=l,t[1]=o,t[2]=y):y=t[2];let b=XC(l,y&&n),x,S;t[3]!==i||t[4]!==a||t[5]!==n||t[6]!==r?(x=()=>{n&&(u(r),f(i??``),m(a??``))},S=[n,r,i,a],t[3]=i,t[4]=a,t[5]=n,t[6]=r,t[7]=x,t[8]=S):(x=t[7],S=t[8]),(0,G.useEffect)(x,S);let C;t[9]!==d||t[10]!==p||t[11]!==l||t[12]!==s||t[13]!==c?(C=function(){let e=l.trim();e&&(c(e,d.trim()||null,p.trim()||null),s(!1))},t[9]=d,t[10]=p,t[11]=l,t[12]=s,t[13]=c,t[14]=C):C=t[14];let w=C,T;t[15]===w?T=t[16]:(T=function(e){e.key===`Enter`&&w()},t[15]=w,t[16]=T);let E=T,D,O,k,A,j,M,N,P,F,I,L,R,z,ee,B,V;if(t[17]!==g||t[18]!==p||t[19]!==l||t[20]!==E||t[21]!==v||t[22]!==b||t[23]!==s||t[24]!==n||t[25]!==h){let e=new Map,r=b?.map(t=>{let n=e.get(t.slug)??0;e.set(t.slug,n+1);let r=n===0?t.slug:`${t.slug}-${n}`;return{...t,reactKey:r}}),i=!!r?.length;k=At,L=n,R=s,O=Nt,t[42]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,K.jsx)(Et,{className:`fixed inset-0 z-50 bg-black/40 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`}),t[42]=I):I=t[42],D=It,j=`dialog-content`,M=``,N=`fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-lg border border-border bg-background p-6 shadow-xl data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,K.jsx)(Ot,{className:`mb-1 text-base font-semibold`,children:`Edit wiki link`}),F=(0,K.jsx)(Tt,{className:`mb-4 text-sm text-muted-foreground`,children:`Modify the link target, anchor, and display label.`}),t[43]=P,t[44]=F):(P=t[43],F=t[44]),V=`mb-4 space-y-6`;let a;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,K.jsx)(`span`,{className:`text-red-500`,children:`*`}),t[45]=a):a=t[45];let o;t[46]===h?o=t[47]:(o=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:h,children:[`Page `,a]}),t[46]=h,t[47]=o);let c;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>u(e.target.value),t[48]=c):c=t[48];let d;t[49]!==l||t[50]!==E||t[51]!==h?(d=(0,K.jsx)(XS,{id:h,value:l,onChange:c,placeholder:`page-name`,autoFocus:!0,"aria-required":`true`,onKeyDown:E}),t[49]=l,t[50]=E,t[51]=h,t[52]=d):d=t[52],t[53]!==o||t[54]!==d?(A=(0,K.jsxs)(`div`,{children:[o,d]}),t[53]=o,t[54]=d,t[55]=A):A=t[55];let f;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional heading anchor)`}),t[56]=f):f=t[56],t[57]===g?z=t[58]:(z=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:g,children:[`Section`,` `,f]}),t[57]=g,t[58]=z);let _;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>m(e.target.value),t[59]=_):_=t[59],t[60]!==g||t[61]!==p||t[62]!==E?(ee=(0,K.jsx)(XS,{id:g,value:p,onChange:_,placeholder:`heading-slug`,onKeyDown:E}),t[60]=g,t[61]=p,t[62]=E,t[63]=ee):ee=t[63],B=i&&(0,K.jsx)(`div`,{role:`listbox`,id:v,"aria-label":`Heading anchors`,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:r.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":p===e.slug,className:ft(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,p===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>m(p===e.slug?``:e.slug),children:[(0,K.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,K.jsx)(`span`,{className:`truncate`,children:e.text})]},e.reactKey))}),t[17]=g,t[18]=p,t[19]=l,t[20]=E,t[21]=v,t[22]=b,t[23]=s,t[24]=n,t[25]=h,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=j,t[31]=M,t[32]=N,t[33]=P,t[34]=F,t[35]=I,t[36]=L,t[37]=R,t[38]=z,t[39]=ee,t[40]=B,t[41]=V}else D=t[26],O=t[27],k=t[28],A=t[29],j=t[30],M=t[31],N=t[32],P=t[33],F=t[34],I=t[35],L=t[36],R=t[37],z=t[38],ee=t[39],B=t[40],V=t[41];let H;t[64]!==z||t[65]!==ee||t[66]!==B?(H=(0,K.jsxs)(`div`,{children:[z,ee,B]}),t[64]=z,t[65]=ee,t[66]=B,t[67]=H):H=t[67];let te;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional display text)`}),t[68]=te):te=t[68];let ne;t[69]===_?ne=t[70]:(ne=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:_,children:[`Label`,` `,te]}),t[69]=_,t[70]=ne);let re;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>f(e.target.value),t[71]=re):re=t[71];let U;t[72]!==_||t[73]!==d||t[74]!==E?(U=(0,K.jsx)(XS,{id:_,value:d,onChange:re,placeholder:`Custom display text`,onKeyDown:E}),t[72]=_,t[73]=d,t[74]=E,t[75]=U):U=t[75];let ie;t[76]!==ne||t[77]!==U?(ie=(0,K.jsxs)(`div`,{children:[ne,U]}),t[76]=ne,t[77]=U,t[78]=ie):ie=t[78];let ae;t[79]!==A||t[80]!==H||t[81]!==ie||t[82]!==V?(ae=(0,K.jsxs)(`div`,{className:V,children:[A,H,ie]}),t[79]=A,t[80]=H,t[81]=ie,t[82]=V,t[83]=ae):ae=t[83];let oe;t[84]===s?oe=t[85]:(oe=(0,K.jsx)(_t,{variant:`outline`,onClick:()=>s(!1),children:`Cancel`}),t[84]=s,t[85]=oe);let se;t[86]===l?se=t[87]:(se=l.trim(),t[86]=l,t[87]=se);let ce=!se,le;t[88]!==w||t[89]!==ce?(le=(0,K.jsx)(_t,{onClick:w,disabled:ce,children:`Save`}),t[88]=w,t[89]=ce,t[90]=le):le=t[90];let ue;t[91]!==oe||t[92]!==le?(ue=(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[oe,le]}),t[91]=oe,t[92]=le,t[93]=ue):ue=t[93];let de;t[94]!==D||t[95]!==j||t[96]!==M||t[97]!==N||t[98]!==P||t[99]!==F||t[100]!==ae||t[101]!==ue?(de=(0,K.jsxs)(D,{"data-slot":j,"data-ok-layer-spawned":M,className:N,children:[P,F,ae,ue]}),t[94]=D,t[95]=j,t[96]=M,t[97]=N,t[98]=P,t[99]=F,t[100]=ae,t[101]=ue,t[102]=de):de=t[102];let fe;t[103]!==O||t[104]!==I||t[105]!==de?(fe=(0,K.jsxs)(O,{children:[I,de]}),t[103]=O,t[104]=I,t[105]=de,t[106]=fe):fe=t[106];let pe;return t[107]!==k||t[108]!==L||t[109]!==R||t[110]!==fe?(pe=(0,K.jsx)(k,{open:L,onOpenChange:R,children:fe}),t[107]=k,t[108]=L,t[109]=R,t[110]=fe,t[111]=pe):pe=t[111],pe}function ZM(e){let t=(0,q.c)(128),{editor:n,getPos:r,onClose:i}=e,a=r(),o=a==null?null:n.state.doc.nodeAt(a),s=String(o?.attrs.target??``),l=d(o?.attrs.alias),u=d(o?.attrs.anchor),f=Re({target:s,alias:l,anchor:u}),{folderPaths:p,pages:m,pagesBySlug:h,loading:g}=Se(),_=c(s,u),v=_?.kind===`external`?_:null,y=JS(s,{pages:m,folderPaths:p,pagesBySlug:h,fallbackTargets:Xy(s)}),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(null),w=YS(y);if(!o)return null;let T;t[0]!==n.state||t[1]!==n.view||t[2]!==r?(T=function(e,t,i){let a=r();a!=null&&n.view.dispatch(n.state.tr.setNodeMarkup(a,void 0,{...n.state.doc.nodeAt(a)?.attrs,target:e,alias:t,anchor:i}))},t[0]=n.state,t[1]=n.view,t[2]=r,t[3]=T):T=t[3];let E=T,D;t[4]!==n.state||t[5]!==n.view||t[6]!==r||t[7]!==i?(D=function(){let e=r();if(e==null)return;let t=n.state.doc.nodeAt(e);t&&(n.view.dispatch(n.state.tr.delete(e,e+t.nodeSize)),i())},t[4]=n.state,t[5]=n.view,t[6]=r,t[7]=i,t[8]=D):D=t[8];let O=D,k;t[9]!==u||t[10]!==v||t[11]!==y||t[12]!==C?(k=function(e){if(v){MS(v.url)?window.open(v.url,`_blank`,`noopener,noreferrer`):console.warn(`[safe-nav] blocked non-safe scheme:`,v.url);return}if(y.kind===`create`){C(`missing`);return}let t=y.hashDocName;if(e.newTab){RS({docName:t,anchor:u});return}if(u){let e=window.location.hash.match(/^#\/([^?#/]+)/);if((e?decodeURIComponent(e[1]):null)===t){let e=document.getElementById(u);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})}window.location.hash=`#/${t}?anchor=${encodeURIComponent(u)}`;return}window.location.hash=`#/${t}`},t[9]=u,t[10]=v,t[11]=y,t[12]=C,t[13]=k):k=t[13];let A=k,j;t[14]!==l||t[15]!==S||t[16]!==n.state||t[17]!==n.view||t[18]!==r||t[19]!==f||t[20]!==s?(j=function(e){if(S===`missing`&&e!==s){let t=r();if(t==null)return;n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...n.state.doc.nodeAt(t)?.attrs,target:e,alias:l??f}))}},t[14]=l,t[15]=S,t[16]=n.state,t[17]=n.view,t[18]=r,t[19]=f,t[20]=s,t[21]=j):j=t[21];let M=j,N=!v&&!g&&y.kind===`navigate`&&y.displayState===`resolved`,P=!v&&!g&&y.kind===`navigate`&&y.displayState===`folder`,F=!v&&!g&&y.kind===`create`,I,L,R,z,ee,B,V,H,te,ne;if(t[22]!==n.state||t[23]!==n.view||t[24]!==v||t[25]!==r||t[26]!==P||t[27]!==N||t[28]!==F||t[29]!==g||t[30]!==i){if(g){let e;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(rr,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[41]=e):e=t[41],L={icon:e,text:`Loading…`,className:`text-muted-foreground`}}else if(v){let e;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Wn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[42]=e):e=t[42],L={icon:e,text:`External wiki link`,className:`text-foreground`}}else if(P){let e;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(qn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[43]=e):e=t[43],L={icon:e,text:`Folder (no index)`,className:`text-foreground`}}else if(F){let e;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Hn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[44]=e):e=t[44],L={icon:e,text:`Page not found`,className:`text-red-700 dark:text-red-300`}}else if(N){let e;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Kn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[45]=e):e=t[45],L={icon:e,text:`Wiki link`,className:`text-foreground`}}else{let e;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Hn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[46]=e):e=t[46],L={icon:e,text:`Unrecognized wiki link`,className:`text-muted-foreground`}}let e;t[47]!==n.state||t[48]!==n.view||t[49]!==r?(e=()=>{let e=r();if(typeof e!=`number`)return new DOMRect;let t=n.state.doc.nodeAt(e);if(!t)return new DOMRect;try{return Be(n.view,e,e+t.nodeSize)}catch{return new DOMRect}},t[47]=n.state,t[48]=n.view,t[49]=r,t[50]=e):e=t[50];let a;t[51]!==n.view.dom||t[52]!==e?(a={getBoundingClientRect:e,contextElement:n.view.dom},t[51]=n.view.dom,t[52]=e,t[53]=a):a=t[53];let o=a;I=KS,ne=`wiki-link`,R=`Wiki link options`,z=i,ee=o,H=`mb-2 flex items-start gap-2 pr-8`,te=(0,K.jsx)(`div`,{className:ft(`mt-0.5 flex shrink-0`,L.className),children:L.icon}),V=`flex-1 min-w-0`,B=ft(`text-sm font-medium`,L.className),t[22]=n.state,t[23]=n.view,t[24]=v,t[25]=r,t[26]=P,t[27]=N,t[28]=F,t[29]=g,t[30]=i,t[31]=I,t[32]=L,t[33]=R,t[34]=z,t[35]=ee,t[36]=B,t[37]=V,t[38]=H,t[39]=te,t[40]=ne}else I=t[31],L=t[32],R=t[33],z=t[34],ee=t[35],B=t[36],V=t[37],H=t[38],te=t[39],ne=t[40];let re;t[54]!==L.text||t[55]!==B?(re=(0,K.jsx)(`div`,{className:B,children:L.text}),t[54]=L.text,t[55]=B,t[56]=re):re=t[56];let U=v?v.url:`${s}${u?`#${u}`:``}`,ie=v?v.url:`${s}${u?`#${u}`:``}`,ae;t[57]!==U||t[58]!==ie?(ae=(0,K.jsx)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,title:U,children:ie}),t[57]=U,t[58]=ie,t[59]=ae):ae=t[59];let oe;t[60]!==re||t[61]!==ae||t[62]!==V?(oe=(0,K.jsxs)(`div`,{className:V,children:[re,ae]}),t[60]=re,t[61]=ae,t[62]=V,t[63]=oe):oe=t[63];let se;t[64]!==oe||t[65]!==H||t[66]!==te?(se=(0,K.jsxs)(`div`,{className:H,children:[te,oe]}),t[64]=oe,t[65]=H,t[66]=te,t[67]=se):se=t[67];let ce;t[68]!==v||t[69]!==A||t[70]!==F||t[71]!==i?(ce=F?null:(0,K.jsx)(_t,{size:`sm`,variant:`default`,onClick:()=>{A({}),i()},children:v?`Open in new tab`:`Open`}),t[68]=v,t[69]=A,t[70]=F,t[71]=i,t[72]=ce):ce=t[72];let le;t[73]!==F||t[74]!==C?(le=F?(0,K.jsx)(_t,{size:`sm`,variant:`default`,onClick:()=>C(`missing`),children:`Create page`}):null,t[73]=F,t[74]=C,t[75]=le):le=t[75];let ue;t[76]!==w||t[77]!==P||t[78]!==C?(ue=P&&w?(0,K.jsxs)(_t,{size:`sm`,variant:`outline`,onClick:()=>C(`folder-index`),children:[(0,K.jsx)(Gn,{className:`size-3.5`,"aria-hidden":`true`}),`Create index`]}):null,t[76]=w,t[77]=P,t[78]=C,t[79]=ue):ue=t[79];let de;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,K.jsx)(`div`,{className:`flex-1`}),t[80]=de):de=t[80];let fe;t[81]===x?fe=t[82]:(fe=()=>x(!0),t[81]=x,t[82]=fe);let pe;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,K.jsx)(sr,{className:`size-3.5`,"aria-hidden":`true`}),t[83]=pe):pe=t[83];let me;t[84]===fe?me=t[85]:(me=(0,K.jsxs)(_t,{size:`sm`,variant:`outline`,onClick:fe,children:[pe,`Edit`]}),t[84]=fe,t[85]=me);let he;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,K.jsx)(fr,{className:`size-3.5`,"aria-hidden":`true`}),t[86]=he):he=t[86];let ge;t[87]===O?ge=t[88]:(ge=(0,K.jsxs)(_t,{size:`sm`,variant:`destructive`,onClick:O,children:[he,`Remove`]}),t[87]=O,t[88]=ge);let _e;t[89]!==ce||t[90]!==le||t[91]!==ue||t[92]!==me||t[93]!==ge?(_e=(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[ce,le,ue,de,me,ge]}),t[89]=ce,t[90]=le,t[91]=ue,t[92]=me,t[93]=ge,t[94]=_e):_e=t[94];let ve;t[95]!==I||t[96]!==R||t[97]!==z||t[98]!==ee||t[99]!==se||t[100]!==_e||t[101]!==ne?(ve=(0,K.jsxs)(I,{kind:ne,ariaLabel:R,onDeactivate:z,triggerReference:ee,children:[se,_e]}),t[95]=I,t[96]=R,t[97]=z,t[98]=ee,t[99]=se,t[100]=_e,t[101]=ne,t[102]=ve):ve=t[102];let ye=S!==null,be;t[103]===C?be=t[104]:(be=e=>{e||C(null)},t[103]=C,t[104]=be);let xe=S===`folder-index`&&w?w.initialDir:y.kind===`create`?y.initialDir:``,Ce=S===`folder-index`&&w?w.suggestedName:y.kind===`create`?y.suggestedName:void 0,we;t[105]!==S||t[106]!==w||t[107]!==s?(we=S===`folder-index`&&w?(0,K.jsxs)(K.Fragment,{children:[`Create an index note for`,` `,(0,K.jsxs)(`span`,{className:`font-medium text-foreground`,children:[w.initialDir,`/`]})]}):(0,K.jsxs)(K.Fragment,{children:[`Create a page for `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:s})]}),t[105]=S,t[106]=w,t[107]=s,t[108]=we):we=t[108];let Te;t[109]!==M||t[110]!==ye||t[111]!==be||t[112]!==xe||t[113]!==Ce||t[114]!==we?(Te=(0,K.jsx)(iC,{open:ye,onOpenChange:be,kind:`file`,initialDir:xe,suggestedName:Ce,description:we,onCreated:M}),t[109]=M,t[110]=ye,t[111]=be,t[112]=xe,t[113]=Ce,t[114]=we,t[115]=Te):Te=t[115];let Ee;t[116]!==l||t[117]!==u||t[118]!==b||t[119]!==E||t[120]!==m||t[121]!==x||t[122]!==s?(Ee=(0,K.jsx)(XM,{open:b,target:s,alias:l,anchor:u,pages:m,onOpenChange:x,onSave:E}),t[116]=l,t[117]=u,t[118]=b,t[119]=E,t[120]=m,t[121]=x,t[122]=s,t[123]=Ee):Ee=t[123];let De;return t[124]!==ve||t[125]!==Te||t[126]!==Ee?(De=(0,K.jsxs)(K.Fragment,{children:[ve,Te,Ee]}),t[124]=ve,t[125]=Te,t[126]=Ee,t[127]=De):De=t[127],De}var QM=0;function $M(){return`wiki-link-${++QM}`}function eN(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`span`);n.setAttribute(`data-wiki-link`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Wiki link: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-chip`),n.style.touchAction=`manipulation`;let r=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,i=t.createTextNode(r);return n.appendChild(i),{dom:n}}var tN=H.extend({priority:200,addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=$M(),{dom:i}=eN({nodeId:r,target:String(t.attrs.target??``),alias:t.attrs.alias==null?null:String(t.attrs.alias),anchor:t.attrs.anchor==null?null:String(t.attrs.anchor)}),a=t,o=()=>{let e=n();return typeof e==`number`?e:void 0},s=hC(e);return s.register({type:`wikiLink`,nodeId:r,getPos:o,controls:{propPanel:t=>(0,G.createElement)(ZM,{editor:e,getPos:o,onClose:t.deactivate})},handlePrimary:({newTab:e})=>{if(!e)return!1;let t=a.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=c(n,typeof t.anchor==`string`?t.anchor:null);return r?r.kind===`doc`?(RS({docName:r.docName,anchor:r.anchor}),!0):MS(r.url)?(IS(r.url),!0):!1:!1}}),{dom:i,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLink`)return!1;a=e;let t=String(e.attrs.target??``),n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor);return i.setAttribute(`data-target`,t),i.setAttribute(`data-alias`,n??``),i.setAttribute(`data-anchor`,r??``),i.setAttribute(`aria-label`,`Wiki link: ${t}${r?`#${r}`:``}`),i.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{s.deregister(r)}}}},addKeyboardShortcuts(){return{Backspace:()=>{if(RC.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(RC.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[YC(this.editor)]}}),nN=0;function rN(){return`wiki-link-embed-${++nN}`}function iN(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`a`);n.setAttribute(`data-wiki-embed`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`href`,e.href),n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Embed: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-embed-chip`),n.style.touchAction=`manipulation`;let r=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,i=t.createTextNode(r);return n.appendChild(i),{dom:n}}function aN(e){let t=(e.doc??(typeof document<`u`?document:{createElement:null})).createElement(`img`);return t.setAttribute(`data-wiki-embed`,``),t.setAttribute(`data-node-id`,e.nodeId),t.setAttribute(`data-target`,e.target),t.setAttribute(`data-alias`,e.alias??``),t.setAttribute(`src`,e.src),t.setAttribute(`alt`,e.alias??e.target),{dom:t}}function oN(e){let t=me(e);return t!==null&&j.has(t)}var sN=re.extend({addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=rN(),i=t,a=String(t.attrs.target??``),o=t.attrs.alias==null?null:String(t.attrs.alias),s=t.attrs.anchor==null?null:String(t.attrs.anchor),c=t.attrs.resolvedSrc==null?null:String(t.attrs.resolvedSrc);if(oN(a)){let{dom:e}=aN({nodeId:r,target:a,alias:o,src:c??a});return{dom:e,ignoreMutation:()=>!0,update:t=>{if(t.type.name!==`wikiLinkEmbed`)return!1;i=t;let n=String(t.attrs.target??``),r=t.attrs.alias==null?null:String(t.attrs.alias),a=t.attrs.resolvedSrc==null?null:String(t.attrs.resolvedSrc);if(!oN(n))return!1;let o=a??n;return e.setAttribute(`data-target`,n),e.setAttribute(`data-alias`,r??``),e.setAttribute(`src`,o),e.setAttribute(`alt`,r??n),!0}}}let{dom:l}=iN({nodeId:r,target:a,alias:o,anchor:s,href:c??a});l.addEventListener(`click`,e=>{e.preventDefault()});let u=()=>{let e=n();return typeof e==`number`?e:void 0},d=hC(e);return d.register({type:`wikiLinkEmbed`,nodeId:r,getPos:u,controls:{},handlePrimary:({newTab:e})=>{let t=i.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=(typeof t.resolvedSrc==`string`&&t.resolvedSrc.length>0?t.resolvedSrc:null)??n,a=me(n);if(a===null)return!1;let o=Ee(r,``)??n;return AS({url:r,projectRelPath:o,ext:a,title:o.split(`/`).pop()??r,forceOsDelegation:e}),!0}}),{dom:l,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let t=String(e.attrs.target??``);if(oN(t))return!1;let n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor),a=(e.attrs.resolvedSrc==null?null:String(e.attrs.resolvedSrc))??t;return l.setAttribute(`data-target`,t),l.setAttribute(`data-alias`,n??``),l.setAttribute(`data-anchor`,r??``),l.setAttribute(`href`,a),l.setAttribute(`aria-label`,`Embed: ${t}${r?`#${r}`:``}`),l.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{d.deregister(r)}}}}}),cN=[...N.map(e=>e.name===`jsxComponent`?zT:e.name===`rawMdxFallback`?VM:e.name===`wikiLink`?tN:e.name===`wikiLinkEmbed`?sN:e.name===`link`?uw:e),KM.configure({itemsSources:[()=>Sx,()=>lx()],categoryLabels:{content:`Components`,layout:`Layout`,media:`Media`,data:`Data`}}),Vy.configure({onDrop(e,t,n){for(let r of t)bx(r,e,n)},onPaste(e,t,n){for(let n of t)bx(n,e,e.state.selection.from)}}),DS,ES,Dx,JM,Hy,Nx,iT];function lN(e){return e===rt}var uN=3e4,dN=class extends Error{docName;elapsedMs;constructor(e,t){super(`Sync timed out for "${e}" after ${t}ms`),this.name=`SyncTimeoutError`,this.docName=e,this.elapsedMs=t}},fN=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},pN=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},mN=class extends Error{docName;cause;constructor(e,t){let n=t instanceof Error?t.message:String(t??`unknown`);super(`Bridge setup failed for "${e}": ${n}`),this.name=`BridgeSetupError`,this.docName=e,this.cause=t}},hN=class extends Error{docName;missingCapability;constructor(e,t){super(`Server is missing capability "${t}" required to open "${e}".`),this.name=`ServerCapabilityMismatchError`,this.docName=e,this.missingCapability=t}},gN=new Map,_N=!1;function vN(){for(let e of gN.values())if(!e.settled)return!0;return!1}function yN(){typeof document>`u`||document.visibilityState===`visible`&&bN(Date.now())}function bN(e){let t=[];for(let[n,r]of gN){if(r.settled)continue;let i=e-r.createdAt;if(i<3e4)continue;r.settled=!0;let a=new dN(n,i);wN(r),r.reject(a),t.push({docName:n,elapsedMs:i})}if(t.length>0){let e=t.map(e=>`${e.docName} (${e.elapsedMs}ms)`).join(`, `);console.warn(`[syncPromise] reaped ${t.length} timed-out ${t.length===1?`entry`:`entries`} on visibility restore (tab-sleep recovered): ${e}`)}return vN()||SN(),t.length}function xN(){_N||typeof document>`u`||(document.addEventListener(`visibilitychange`,yN),_N=!0)}function SN(){_N&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,yN),_N=!1))}var CN=new Map;function wN(e){e.detached||(e.detached=!0,e.timeoutHandle!==null&&clearTimeout(e.timeoutHandle),e.provider.off(`synced`,e.onSynced),e.provider.off(`close`,e.onClose))}function TN(e,t){let n=gN.get(e);if(n)return n.promise;let r=CN.get(e);if(r!==void 0){CN.delete(e);let n=r===`timeout`?new dN(e,0):new fN(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),J(`ok/sync/create`,{docName:e,warm:!1,armed:r}),J(`ok/sync/reject`,{docName:e,reason:`armed-${r}`});let i=DN(n);return gN.set(e,ON(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`),J(`ok/sync/create`,{docName:e,warm:!0}),J(`ok/sync/resolve`,{docName:e,elapsedMs:0,warm:!0});let n=Promise.resolve();return gN.set(e,EN(n,t)),n}let i=Date.now(),a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=()=>{let t=gN.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt;console.log(`[syncPromise] ${e} resolved in ${n}ms`),J(`ok/sync/resolve`,{docName:e,elapsedMs:n,warm:!1}),wN(t),vN()||SN(),t.resolve()},l=t=>{let n=gN.get(e);if(!n||n.settled)return;n.settled=!0;let r=new fN(e);console.warn(`[syncPromise] ${e} rejected: ${r.message}`),J(`ok/sync/reject`,{docName:e,reason:`pre-sync-disconnect`}),wN(n),vN()||SN(),n.reject(r)},u=setTimeout(()=>{let t=gN.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new dN(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`),J(`ok/sync/reject`,{docName:e,reason:`timeout`,elapsedMs:n}),wN(t),vN()||SN(),t.reject(r)},uN),d={promise:s,resolve:a,reject:o,createdAt:i,timeoutHandle:u,provider:t,onSynced:c,onClose:l,settled:!1,detached:!1};return gN.set(e,d),t.on(`synced`,c),t.on(`close`,l),xN(),J(`ok/sync/create`,{docName:e,warm:!1}),s}function EN(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,detached:!0}}function DN(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function ON(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,detached:!0}}function kN(e){let t=gN.get(e);t&&(t.settled=!0,wN(t),gN.delete(e),vN()||SN())}function AN(e,t){let n=gN.get(e);return!n||n.settled?!1:(n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),wN(n),vN()||SN(),n.reject(t),!0)}var jN=Object.freeze({kind:`tab-replay`}),MN=Object.freeze({kind:`idle`}),NN=ae(cN),PN=4e3,FN=1e4,IN=class extends Error{constructor(e,t){super(`client persistence clearData timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`ClientPersistenceClearTimeoutError`}},LN=`ok-last-observed-branch`,RN=5e3,zN=1*1024*1024;function BN(e,t,n=null){let r={};if(e!==null&&(r.principalId=e.principalId,r.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(r.expectedServerInstanceId=t),n!==null&&n.length>0&&(r.expectedBranch=n),Object.keys(r).length!==0)return JSON.stringify(r)}var VN=class{_entries=new Map;get entries(){return this._entries}lruOrder=[];activeDocName=null;maxSize;wsUrl;recycleDebounceMs;clearDataTimeoutMs;onChange=null;tabIdentity=null;serverRestartRecoveryState=MN;cachedServerInstanceId=null;pendingServerInstanceKnown=null;recoveryMismatchStaleClaim;bufferedUpdates=new Map;persistenceFactory;storage;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n?.recycleDebounceMs??PN,this.clearDataTimeoutMs=n?.clearDataTimeoutMs??FN,this.persistenceFactory=n?.persistenceFactory??Fy,n?.storage===void 0?this.storage=globalThis.localStorage===void 0?null:globalThis.localStorage:this.storage=n.storage}setTabIdentity(e){this.tabIdentity=e}setExpectedServerInstanceId(e){if(this.cachedServerInstanceId=e,!(e===null||e.length===0)){if(this.pendingServerInstanceKnown!==null){let t=this.pendingServerInstanceKnown;this.pendingServerInstanceKnown=null,t.resolve(e)}this.attachDeferredPersistence(e)}}whenServerInstanceKnown(){if(this.cachedServerInstanceId!==null&&this.cachedServerInstanceId.length>0)return Promise.resolve(this.cachedServerInstanceId);if(this.pendingServerInstanceKnown!==null)return this.pendingServerInstanceKnown.promise;let e,t=new Promise(t=>{e=t});return this.pendingServerInstanceKnown={promise:t,resolve:e},t}buildPersistence(e,t,n){return this.persistenceFactory({branch:this.getOrInitObservedBranch()??`_unknown_`,serverInstanceId:e,docName:t,doc:n})}attachDeferredPersistence(e){for(let t of this._entries.values())if(t.kind===`active`&&t.persistence===null)try{t.persistence=this.buildPersistence(e,t.docName,t.provider.document)}catch(e){let n=e instanceof Error?e.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(t.docName),errorName:n,errorMessage:e instanceof Error?e.message:String(e)})}}getServerRestartRecoveryState(){return this.serverRestartRecoveryState}observeDiskAck(e,t){let n=this.entries.get(e);!n||n.kind!==`active`||(n.lastDiskAckedSV=Ry(n.lastDiskAckedSV,t))}observeDiskAckBatch(e){for(let[t,n]of Object.entries(e))this.observeDiskAck(t,n)}lastObservedBranch=null;lastObservedBranchInitialized=!1;getOrInitObservedBranch(){if(this.lastObservedBranchInitialized)return this.lastObservedBranch;this.lastObservedBranchInitialized=!0;try{let e=this.storage?.getItem(LN)??null;e!==null&&e.length>0&&(this.lastObservedBranch=e)}catch{}return this.lastObservedBranch}persistObservedBranch(e){this.lastObservedBranch=e,this.lastObservedBranchInitialized=!0;try{e===null||e.length===0?this.storage?.removeItem(LN):this.storage?.setItem(LN,e)}catch{}}withClearDataTimeout(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(new IN(e,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);t.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e)})})}recoveryTelemetryBase(e,t){let n={docName:e,branch:this.getOrInitObservedBranch()??`_unknown_`},r=t===void 0?this.recoveryMismatchStaleClaim:t;return r!==void 0&&r.length>0&&(n.serverInstanceId=r),n}emitStructuredClientRecoveryEvent(e){console.warn(JSON.stringify(e))}clearRecoveryMismatchStaleClaimIfTerminal(){let e=this.serverRestartRecoveryState.kind;(e===`idle`||e===`failed`)&&(this.recoveryMismatchStaleClaim=void 0)}beginServerRestartRecovery(e,t){this.serverRestartRecoveryState={kind:`recovering`,phase:`clearing-local-cache`,docNames:e,failedDocNames:[],startedAt:t};for(let t of e)kN(t);this.notify()}enterServerRestartReconnect(e,t,n,r){if(e.length===0){this.serverRestartRecoveryState=t.length===0?MN:{kind:`failed`,reason:r,docNames:t,failedDocNames:t,startedAt:n},this.clearRecoveryMismatchStaleClaimIfTerminal(),this.notify();return}this.serverRestartRecoveryState={kind:`recovering`,phase:`reconnecting`,docNames:e,failedDocNames:t,startedAt:n,...t.length>0?{clearFailureReason:r}:{}},this.notify()}markServerRestartRecoverySynced(e){let t=this.serverRestartRecoveryState;if(t.kind!==`recovering`||t.phase!==`reconnecting`||!t.docNames.includes(e))return;let n=t.docNames.filter(t=>t!==e);if(n.length>0){this.serverRestartRecoveryState={...t,docNames:n};return}if(t.failedDocNames.length>0){this.serverRestartRecoveryState={kind:`failed`,reason:t.clearFailureReason??`clear-data-failed`,docNames:t.failedDocNames,failedDocNames:t.failedDocNames,startedAt:t.startedAt},this.clearRecoveryMismatchStaleClaimIfTerminal();return}this.serverRestartRecoveryState=MN,this.clearRecoveryMismatchStaleClaimIfTerminal()}setObservedBranch(e){this.persistObservedBranch(e)}compareAndUpdateObservedBranch(e){let t=this.getOrInitObservedBranch();return this.persistObservedBranch(e),t!==null&&t!==e}onBranchMismatch=null;branchMismatchInFlight=null;setOnBranchMismatch(e){if(e===null){this.onBranchMismatch=null;return}this.onBranchMismatch=()=>{if(this.branchMismatchInFlight!==null)return;let t=Promise.resolve().then(e).finally(()=>{this.branchMismatchInFlight===t&&(this.branchMismatchInFlight=null)});this.branchMismatchInFlight=t}}setOnChange(e){this.onChange=e}notify(){this.onChange?.()}evictListeners=new Set;onEvict(e){return this.evictListeners.add(e),()=>{this.evictListeners.delete(e)}}fireEvict(e){for(let t of this.evictListeners)try{t(e)}catch(t){console.warn(`[ProviderPool] evict listener threw for ${e}:`,t)}}touch(e){let t=this.lruOrder.indexOf(e);t!==-1&&this.lruOrder.splice(t,1),this.lruOrder.push(e)}open(e){if(lN(e))return null;let t=this.entries.get(e);if(t)return t.lastAccessedAt=Date.now(),this.touch(e),this.notify(),t;this.entries.size>=this.maxSize&&this.evictLru();let n=this.cachedServerInstanceId,r=BN(this.tabIdentity,n,this.getOrInitObservedBranch()),i=new uy({url:zy(this.wsUrl),name:e,forceSyncInterval:RN,...r===void 0?{}:{token:r}}),a=this.cachedServerInstanceId,o={kind:`active`,provider:i,persistence:a!==null&&a.length>0?this.buildPersistence(a,e,i.document):null,lastServerSyncedSV:null,lastDiskAckedSV:null,observerCleanup:null,syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),hasSynced:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1};if(i.on(`status`,({status:t})=>{o.kind!==`active`||this.entries.get(e)!==o||t===`disconnected`&&(o.syncState=`disconnected`,this.notify())}),i.on(`synced`,()=>{if(!(o.kind!==`active`||this.entries.get(e)!==o)&&(o.syncState=`synced`,o.hasSynced=!0,o.lastServerSyncedSV=Iy(i.document),o.pendingRecycleTimer&&=(clearTimeout(o.pendingRecycleTimer),null),this.markServerRestartRecoverySynced(e),this.notify(),!o.observerCleanup))try{let t=i.document,n=new y({extensions:cN});o.observerCleanup=lT({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:n,schema:NN,onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),o.bridgeSetupFailed=!0,AN(e,new mN(e,t))}}),i.on(`disconnect`,()=>{o.kind!==`active`||this.entries.get(e)!==o||(o.syncState=`disconnected`,this.notify(),o.hasSynced&&i.unsyncedChanges===0&&!o.pendingRecycleTimer&&(o.pendingRecycleTimer=setTimeout(()=>{o.kind===`active`&&(o.pendingRecycleTimer=null,this.entries.get(e)===o&&this.recycleDisconnectedEntry(e))},this.recycleDebounceMs)))}),i.on(`authenticationFailed`,({reason:e})=>{if(![`server-instance-mismatch`,`branch-mismatch`].includes(e)){console.warn(JSON.stringify({event:`ok-auth-failed-unknown-reason`,reason:e}));return}let t=e;if(t===`server-instance-mismatch`){if(n===null||this.cachedServerInstanceId!==n)return;let e=n;this.cachedServerInstanceId=null,this.handleServerInstanceMismatch(e);return}if(t===`branch-mismatch`){this.onBranchMismatch?.();return}}),this.bufferedUpdates.get(e)!==void 0){let t=this.recoveryMismatchStaleClaim,n=()=>{if(i.off(`synced`,n),o.kind!==`active`||this.entries.get(e)!==o)return;let r=this.bufferedUpdates.get(e);if(r!==void 0){this.bufferedUpdates.delete(e);try{ad(i.document,r,jN)}catch(n){let i=n instanceof Error?n.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-failed`,...this.recoveryTelemetryBase(e,t),replayByteLength:r.byteLength,errorName:i,errorMessage:n instanceof Error?n.message:String(n)})}}};i.on(`synced`,n)}return this._entries.set(e,o),this.touch(e),this.notify(),o}handleServerInstanceMismatch(e){this.recoveryMismatchStaleClaim=e.length>0?e:void 0;let t=Array.from(this.entries.entries()),n=Date.now(),r=this.activeDocName,i=r!==null&&t.some(([e,t])=>e===r&&t.kind===`active`)?[r]:[],a=r??t.find(([,e])=>e.kind===`active`)?.[0]??``;a.length>0&&this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-epoch-mismatch`,...this.recoveryTelemetryBase(a)}),this.beginServerRestartRecovery(i,n);for(let[e,n]of t)n.kind===`active`&&!i.includes(e)&&kN(e);for(let[e,n]of t){if(n.kind!==`active`)continue;let t=n.lastDiskAckedSV??n.lastServerSyncedSV;if(t===null){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-skipped-no-baseline`,...this.recoveryTelemetryBase(e),reason:`no-disk-ack-or-server-sync-vector`});continue}let r=Ly(n.provider.document,t);if(r.byteLength>zN){J(`ok/pool/buffer-overflow`,{docName:e,bytes:r.byteLength});continue}r.byteLength>0&&this.bufferedUpdates.set(e,r)}let o=[];for(let[e,n]of t)n.kind===`active`&&n.persistence!==null&&o.push({docName:e,promise:this.withClearDataTimeout(e,n.persistence.clearData())});Promise.allSettled(o.map(e=>e.promise)).then(e=>{let t=[],i=[],a=!1;e.forEach((e,n)=>{let r=o[n];if(!r)return;let s=r.docName;if(e.status===`rejected`){t.push(s);let n=e.reason instanceof IN;if(n&&(a=!0),n)this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`timeout`});else{let t=e.reason instanceof Error?e.reason.name:`unknown`;this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`rejected`,errorName:t,errorMessage:e.reason instanceof Error?e.reason.message:String(e.reason)})}}else i.push(s)});let s=i.filter(e=>e===r);if(t.length>0){let e=a?`clear-data-timeout`:`clear-data-failed`;console.warn(JSON.stringify({event:`ok-mismatch-recycle-partial-clears-failed`,failedDocs:t,clearedDocs:i})),this.enterServerRestartReconnect(s,t,n,e);for(let e of i)this.recycleDisconnectedEntry(e);return}this.enterServerRestartReconnect(s,[],n,`clear-data-failed`),this.recycleAllEntries()})}recycleAllEntries(){let e=Array.from(this.entries.keys());for(let t of e)this.recycleDisconnectedEntry(t)}prewarm(e){if(lN(e))return null;let t=this.entries.get(e);if(t)return t;let n=this.open(e);if(!n)return null;let r=this.lruOrder.indexOf(e);return r!==-1&&(this.lruOrder.splice(r,1),this.lruOrder.unshift(e)),n}close(e){let t=this.entries.get(e);t&&(this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),this.bufferedUpdates.delete(e),this.activeDocName===e&&(this.activeDocName=null),this.notify())}clearBufferedUpdates(){this.bufferedUpdates.clear()}__test_seedBufferedUpdate(e,t){this.bufferedUpdates.set(e,t)}__test_bufferedUpdatesSize(){return this.bufferedUpdates.size}__test_hasBufferedUpdate(e){return this.bufferedUpdates.has(e)}__test_getBufferedUpdate(e){return this.bufferedUpdates.get(e)}setActive(e){let t=this.entries.get(e);if(!t)throw Error(`[ProviderPool] Cannot setActive — "${e}" is not open`);t.lastAccessedAt=Date.now(),this.touch(e),this.activeDocName=e,this.notify()}clearActive(){this.activeDocName!==null&&(this.activeDocName=null,this.notify())}getActive(){return this.activeDocName?this.entries.get(this.activeDocName)??null:null}getActiveDocName(){return this.activeDocName}has(e){return this.entries.has(e)}recycle(e){this.recycleDisconnectedEntry(e)}dispose(){for(let e of this._entries.values())this.destroyEntry(e);this._entries.clear(),this.lruOrder=[],this.activeDocName=null,this.onChange=null,this.bufferedUpdates.clear(),this.onBranchMismatch=null,this.branchMismatchInFlight=null,this.evictListeners.clear(),this.serverRestartRecoveryState=MN,this.cachedServerInstanceId=null,this.pendingServerInstanceKnown=null,this.tabIdentity=null,this.recoveryMismatchStaleClaim=void 0}evictLru(){for(let e of this.lruOrder)if(e!==this.activeDocName){J(`ok/pool/evict-lru`,{docName:e}),this.close(e);return}}destroyEntry(e){if(e.kind===`tearing-down`)return;let t=e.observerCleanup,n=e.persistence,r=e.pendingRecycleTimer,i=e.docName,a=e;a.kind=`tearing-down`,a.persistence=null,a.observerCleanup=null,a.pendingRecycleTimer=null,r&&clearTimeout(r),kN(i),this.fireEvict(i),t?.(),n!==null&&n.destroy().catch(e=>{console.warn(`[ProviderPool] persistence destroy failed for ${i}:`,e)});try{a.provider.destroy()}catch(e){console.warn(`[ProviderPool] Provider destroy failed for ${i}:`,e)}}recycleDisconnectedEntry(e){let t=this.entries.get(e);if(!t||t.kind!==`active`)return;let n=this.activeDocName===e;if(J(`ok/pool/recycle-disconnected`,{docName:e,wasActive:n}),this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),n){this.open(e)&&this.setActive(e);return}this.notify()}},HN=crypto.randomUUID(),UN=!1;function WN(e){UN||(UN=!0,console.warn(`[principal-fetch] failed to resolve principal — falling back to random identity.`,e))}var GN=(0,G.createContext)(null),KN=null;function qN(e){return KN||(KN=new VN(10,e),Dg(KN)),KN}var JN={activeDocName:null,activeProvider:null,syncState:`connecting`,serverRestartRecovery:{kind:`idle`},poolEntries:[]};function YN(e){let t=e.getActive(),n=[];for(let t of e.entries.values())n.push({docName:t.docName,provider:t.provider,lastAccessedAt:t.lastAccessedAt});return n.sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt),{activeDocName:e.getActiveDocName(),activeProvider:t?.provider??null,syncState:t?.syncState??`connecting`,serverRestartRecovery:e.getServerRestartRecoveryState(),poolEntries:n}}function XN(e){let t=(0,q.c)(59),{children:n}=e,[r,i]=(0,G.useState)(JN),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(`doc`),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(0),{collabUrl:_,terminal:v,lastError:y,retry:b}=eg(),x,S;t[0]===_?(x=t[1],S=t[2]):(x=()=>{if(_===null)return;let e=qN(_);return i(YN(e)),e.setOnBranchMismatch(()=>Rh(e)),e.setOnChange(()=>i(YN(e))),fetch(`/api/principal`).then($N).then(t=>{let n=k.safeParse(t);n.success?(e.setTabIdentity({principalId:n.data.id,tabSessionId:HN}),c(n.data)):WN(n.error)}).catch(QN),Rh(e),()=>{e.setOnChange(null)}},S=[_],t[0]=_,t[1]=x,t[2]=S),(0,G.useEffect)(x,S);let C;t[3]===_?C=t[4]:(C=e=>{if(J(`ok/nav/open-document`,{docName:e,transition:!1}),_===null)return;let t=qN(_);t.open(e)&&(t.setActive(e),o({kind:`doc`,target:e,docName:e}))},t[3]=_,t[4]=C);let w=C,T;t[5]===w?T=t[6]:(T=e=>{J(`ok/nav/open-document`,{docName:e,transition:!1}),w(e)},t[5]=w,t[6]=T);let E=T,D;t[7]===_?D=t[8]:(D=e=>{if(_===null)return;let t=qN(_),n=he(e);n?(t.open(n),t.setActive(n)):t.clearActive(),o(e)},t[7]=_,t[8]=D);let O=D,A;t[9]===O?A=t[10]:(A=e=>{J(`ok/nav/open-target`,{docName:he(e),kind:e.kind,transition:!1}),O(e)},t[9]=O,t[10]=A);let j=A,M,N,P,F;t[11]===_?(M=t[12],N=t[13],P=t[14],F=t[15]):(N=()=>{if(_===null){o(null);return}qN(_).clearActive(),o(null)},P=e=>{_!==null&&(qN(_).close(e),o(t=>t&&(he(t)===e?null:t)))},F=e=>{_!==null&&qN(_).recycle(e)},M=e=>{_!==null&&qN(_).prewarm(e)},t[11]=_,t[12]=M,t[13]=N,t[14]=P,t[15]=F);let I,L,R,z,ee;t[16]===_?(I=t[17],L=t[18],R=t[19],z=t[20],ee=t[21]):(I=e=>{_!==null&&qN(_).setExpectedServerInstanceId(e)},L=async e=>{if(_===null)return;let t=qN(_);t.setObservedBranch(e),await Fh(t,e)},R=async e=>{if(_===null)return;let t=qN(_);t.compareAndUpdateObservedBranch(e)&&await Fh(t,e)},z=(e,t)=>{_!==null&&qN(_).observeDiskAck(e,t)},ee=async()=>{_!==null&&await Rh(qN(_))},t[16]=_,t[17]=I,t[18]=L,t[19]=R,t[20]=z,t[21]=ee);let B;t[22]!==p||t[23]!==d?(B=e=>{if(d===`agent`&&p===e){f(`doc`);return}m(e),f(`agent`),g(ZN)},t[22]=p,t[23]=d,t[24]=B):B=t[24];let V;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{f(`doc`),m(null)},t[25]=V):V=t[25];let H;t[26]!==a||t[27]!==y||t[28]!==v||t[29]!==_||t[30]!==p||t[31]!==h||t[32]!==d||t[33]!==w||t[34]!==E||t[35]!==O||t[36]!==j||t[37]!==s||t[38]!==b||t[39]!==r.activeDocName||t[40]!==r.activeProvider||t[41]!==r.poolEntries||t[42]!==r.serverRestartRecovery||t[43]!==r.syncState||t[44]!==l||t[45]!==M||t[46]!==I||t[47]!==L||t[48]!==R||t[49]!==z||t[50]!==ee||t[51]!==B||t[52]!==N||t[53]!==P||t[54]!==F?(H={principal:s,activeTarget:a,activeDocName:r.activeDocName,activeProvider:r.activeProvider,syncState:r.syncState,serverRestartRecovery:r.serverRestartRecovery,poolEntries:r.poolEntries,openDocument:w,openDocumentTransition:E,openTarget:O,openTargetTransition:j,clearTarget:N,closeDocument:P,recycleDocument:F,prewarm:M,systemProvider:l,setSystemProvider:u,updateServerInstanceId:I,onBranchSwitched:L,observeBranch:R,observeDiskAck:z,refreshServerInfo:ee,collabUrl:_,collabTerminal:v,collabLastError:y,retryCollab:b,docPanelMode:d,docPanelAgentId:p,docPanelExpandSignal:h,openActivityPanel:B,closeActivityPanel:V},t[26]=a,t[27]=y,t[28]=v,t[29]=_,t[30]=p,t[31]=h,t[32]=d,t[33]=w,t[34]=E,t[35]=O,t[36]=j,t[37]=s,t[38]=b,t[39]=r.activeDocName,t[40]=r.activeProvider,t[41]=r.poolEntries,t[42]=r.serverRestartRecovery,t[43]=r.syncState,t[44]=l,t[45]=M,t[46]=I,t[47]=L,t[48]=R,t[49]=z,t[50]=ee,t[51]=B,t[52]=N,t[53]=P,t[54]=F,t[55]=H):H=t[55];let te=H,ne;return t[56]!==n||t[57]!==te?(ne=(0,K.jsx)(GN,{value:te,children:n}),t[56]=n,t[57]=te,t[58]=ne):ne=t[58],ne}function ZN(e){return e+1}function QN(e){WN(e)}function $N(e){return e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))}function eP(){let e=(0,G.use)(GN);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function tP(){let e=(0,q.c)(3),{openDocumentTransition:t,openTargetTransition:n}=eP(),r;return e[0]!==t||e[1]!==n?(r={openDocumentTransition:t,openTargetTransition:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}export{Nd as $,pC as A,Hn as At,Wy as B,Aw as C,Qn as Ct,gw as D,qn as Dt,_w as E,Jn as Et,JS as F,mg as G,gg as H,Bx as I,Ih as J,Tg as K,kx as L,nC as M,Bn as Mt,XS as N,Rn as Nt,pw as O,Kn as Ot,YS as P,Ln as Pt,cf as Q,fx as R,Kw as S,er as St,hw as T,Yn as Tt,pg as U,uy as V,_g as W,Cm as X,kh as Y,Uu as Z,Wj as _,cr as _t,pN as a,tu as at,cT as b,nr as bt,dN as c,xo as ct,lN as d,Ra as dt,Md as et,cN as f,ki as ft,qj as g,fr as gt,AM as h,Mr as ht,mN as i,eu as it,iC as j,Vn as jt,hC as k,Gn as kt,kN as l,Fa as lt,kM as m,Ei as mt,eP as n,Ad as nt,fN as o,Nc as ot,jM as p,J as pt,Kh as q,tP as r,Td as rt,hN as s,So as st,XN as t,Ed as tt,TN as u,Ba as ut,Pj as v,sr as vt,ww as w,Xn as wt,sT as x,tr as xt,BT as y,rr as yt,Yb as z};
|
|
34
|
+
}`,{label:`enum`,detail:`definition`,type:`keyword`})]),pA=new en,mA=new Set([`Script`,`Block`,`FunctionExpression`,`FunctionDeclaration`,`ArrowFunction`,`MethodDeclaration`,`ForStatement`]);function hA(e){return(t,n)=>{let r=t.node.getChild(`VariableDefinition`);return r&&n(r,e),!0}}var gA=[`FunctionDeclaration`],_A={FunctionDeclaration:hA(`function`),ClassDeclaration:hA(`class`),ClassExpression:()=>!0,EnumDeclaration:hA(`constant`),TypeAliasDeclaration:hA(`type`),NamespaceDeclaration:hA(`namespace`),VariableDefinition(e,t){e.matchContext(gA)||t(e,`variable`)},TypeDefinition(e,t){t(e,`type`)},__proto__:null};function vA(e,t){let n=pA.get(t);if(n)return n;let r=[],i=!0;function a(t,n){let i=e.sliceString(t.from,t.to);r.push({label:i,type:n})}return t.cursor(On.IncludeAnonymous).iterate(t=>{if(i)i=!1;else if(t.name){let e=_A[t.name];if(e&&e(t,a)||mA.has(t.name))return!1}else if(t.to-t.from>8192){for(let n of vA(e,t.node))r.push(n);return!1}}),pA.set(t,r),r}var yA=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,bA=[`TemplateString`,`String`,`RegExp`,`LineComment`,`BlockComment`,`VariableDefinition`,`TypeDefinition`,`Label`,`PropertyDefinition`,`PropertyName`,`PrivatePropertyDefinition`,`PrivatePropertyName`,`JSXText`,`JSXAttributeValue`,`JSXOpenTag`,`JSXCloseTag`,`JSXSelfClosingTag`,`.`,`?.`];function xA(e){let t=Yt(e.state).resolveInner(e.pos,-1);if(bA.indexOf(t.name)>-1)return null;let n=t.name==`VariableName`||t.to-t.from<20&&yA.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let n=t;n;n=n.parent)mA.has(n.name)&&(r=r.concat(vA(e.state.doc,n)));return{options:r,from:n?t.from:e.pos,validFor:yA}}var SA=xn.define({name:`javascript`,parser:uA.configure({props:[Tn.add({IfStatement:wn({except:/^\s*({|else\b)/}),TryStatement:wn({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:un,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:yn({closing:`}`}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":wn({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),Dn.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":on,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name==`JSXSelfClosingTag`)return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){let t=e.firstChild?.nextSibling,n=e.lastChild;return!t||t.type.isError?null:{from:t.to,to:n.type.isError?e.to:n.from}}})]}),languageData:{closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]},commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:`$`}}),CA={test:e=>/^JSX/.test(e.name),facet:ln({commentTokens:{block:{open:`{/*`,close:`*/}`}}})},wA=SA.configure({dialect:`ts`},`typescript`),TA=SA.configure({dialect:`jsx`,props:[fn.add(e=>e.isTop?[CA]:void 0)]}),EA=SA.configure({dialect:`jsx ts`,props:[fn.add(e=>e.isTop?[CA]:void 0)]},`typescript`),DA=e=>({label:e,type:`keyword`}),OA=`break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield`.split(` `).map(DA),kA=OA.concat([`declare`,`implements`,`private`,`protected`,`public`].map(DA));function AA(e={}){let t=e.jsx?e.typescript?EA:TA:e.typescript?wA:SA,n=e.typescript?fA.concat(kA):dA.concat(OA);return new vn(t,[SA.data.of({autocomplete:jn(bA,kn(n))}),SA.data.of({autocomplete:xA}),e.jsx?PA:[]])}function jA(e){for(;;){if(e.name==`JSXOpenTag`||e.name==`JSXSelfClosingTag`||e.name==`JSXFragmentTag`)return e;if(e.name==`JSXEscape`||!e.parent)return null;e=e.parent}}function MA(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name==`JSXIdentifier`||r.name==`JSXBuiltin`||r.name==`JSXNamespacedName`||r.name==`JSXMemberExpression`)return e.sliceString(r.from,Math.min(r.to,n));return``}var NA=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),PA=rn.inputHandler.of((e,t,n,r,i)=>{if((NA?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!SA.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let{head:t}=e,n=Yt(o).resolveInner(t-1,-1),i;if(n.name==`JSXStartTag`&&(n=n.parent),!(o.doc.sliceString(t-1,t)!=r||n.name==`JSXAttributeValue`&&n.to>t)){if(r==`>`&&n.name==`JSXFragmentTag`)return{range:e,changes:{from:t,insert:`</>`}};if(r==`/`&&n.name==`JSXStartCloseTag`){let e=n.parent,r=e.parent;if(r&&e.from==t-2&&((i=MA(o.doc,r.firstChild,t))||r.firstChild?.name==`JSXFragmentTag`)){let e=`${i}>`;return{range:$t.cursor(t+e.length,-1),changes:{from:t,insert:e}}}}else if(r==`>`){let r=jA(n);if(r&&r.name==`JSXOpenTag`&&!/^\/?>|^<\//.test(o.doc.sliceString(t,t+2))&&(i=MA(o.doc,r,t)))return{range:e,changes:{from:t,insert:`</${i}>`}}}}return{range:e}});return s.changes.empty?!1:(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),FA=[`_blank`,`_self`,`_top`,`_parent`],IA=[`ascii`,`utf-8`,`utf-16`,`latin1`,`latin1`],LA=[`get`,`post`,`put`,`delete`],RA=[`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`],zA=[`true`,`false`],$={},BA={a:{attrs:{href:null,ping:null,type:null,media:null,target:FA,hreflang:null}},abbr:$,address:$,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:[`default`,`rect`,`circle`,`poly`]}},article:$,aside:$,audio:{attrs:{src:null,mediagroup:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`none`,`metadata`,`auto`],autoplay:[`autoplay`],loop:[`loop`],controls:[`controls`]}},b:$,base:{attrs:{href:null,target:FA}},bdi:$,bdo:$,blockquote:{attrs:{cite:null}},body:$,br:$,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:[`autofocus`],disabled:[`autofocus`],formenctype:RA,formmethod:LA,formnovalidate:[`novalidate`],formtarget:FA,type:[`submit`,`reset`,`button`]}},canvas:{attrs:{width:null,height:null}},caption:$,center:$,cite:$,code:$,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:[`command`,`checkbox`,`radio`],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:[`disabled`],checked:[`checked`]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:[`disabled`],multiple:[`multiple`]}},datalist:{attrs:{data:null}},dd:$,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:[`open`]}},dfn:$,div:$,dl:$,dt:$,em:$,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:[`disabled`],form:null,name:null}},figcaption:$,figure:$,footer:$,form:{attrs:{action:null,name:null,"accept-charset":IA,autocomplete:[`on`,`off`],enctype:RA,method:LA,novalidate:[`novalidate`],target:FA}},h1:$,h2:$,h3:$,h4:$,h5:$,h6:$,head:{children:[`title`,`base`,`link`,`style`,`meta`,`script`,`noscript`,`command`]},header:$,hgroup:$,hr:$,html:{attrs:{manifest:null}},i:$,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:[`allow-top-navigation`,`allow-same-origin`,`allow-forms`,`allow-scripts`],seamless:[`seamless`]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:[`audio/*`,`video/*`,`image/*`],autocomplete:[`on`,`off`],autofocus:[`autofocus`],checked:[`checked`],disabled:[`disabled`],formenctype:RA,formmethod:LA,formnovalidate:[`novalidate`],formtarget:FA,multiple:[`multiple`],readonly:[`readonly`],required:[`required`],type:[`hidden`,`text`,`search`,`tel`,`url`,`email`,`password`,`datetime`,`date`,`month`,`week`,`time`,`datetime-local`,`number`,`range`,`color`,`checkbox`,`radio`,`file`,`submit`,`image`,`reset`,`button`]}},ins:{attrs:{cite:null,datetime:null}},kbd:$,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:[`autofocus`],disabled:[`disabled`],keytype:[`RSA`]}},label:{attrs:{for:null,form:null}},legend:$,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:[`all`,`16x16`,`16x16 32x32`,`16x16 32x32 64x64`]}},map:{attrs:{name:null}},mark:$,menu:{attrs:{label:null,type:[`list`,`context`,`toolbar`]}},meta:{attrs:{content:null,charset:IA,name:[`viewport`,`application-name`,`author`,`description`,`generator`,`keywords`],"http-equiv":[`content-language`,`content-type`,`default-style`,`refresh`]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:$,noscript:$,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:[`typemustmatch`]}},ol:{attrs:{reversed:[`reversed`],start:null,type:[`1`,`a`,`A`,`i`,`I`]},children:[`li`,`script`,`template`,`ul`,`ol`]},optgroup:{attrs:{disabled:[`disabled`],label:null}},option:{attrs:{disabled:[`disabled`],label:null,selected:[`selected`],value:null}},output:{attrs:{for:null,form:null,name:null}},p:$,param:{attrs:{name:null,value:null}},pre:$,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:$,rt:$,ruby:$,samp:$,script:{attrs:{type:[`text/javascript`],src:null,async:[`async`],defer:[`defer`],charset:IA}},section:$,select:{attrs:{form:null,name:null,size:null,autofocus:[`autofocus`],disabled:[`disabled`],multiple:[`multiple`]}},slot:{attrs:{name:null}},small:$,source:{attrs:{src:null,type:null,media:null}},span:$,strong:$,style:{attrs:{type:[`text/css`],media:null,scoped:null}},sub:$,summary:$,sup:$,table:$,tbody:$,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:$,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:[`autofocus`],disabled:[`disabled`],readonly:[`readonly`],required:[`required`],wrap:[`soft`,`hard`]}},tfoot:$,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:[`row`,`col`,`rowgroup`,`colgroup`]}},thead:$,time:{attrs:{datetime:null}},title:$,tr:$,track:{attrs:{src:null,label:null,default:null,kind:[`subtitles`,`captions`,`descriptions`,`chapters`,`metadata`],srclang:null}},ul:{children:[`li`,`script`,`template`,`ul`,`ol`]},var:$,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`auto`,`metadata`,`none`],autoplay:[`autoplay`],mediagroup:[`movie`],muted:[`muted`],controls:[`controls`]}},wbr:$},VA={accesskey:null,class:null,contenteditable:zA,contextmenu:null,dir:[`ltr`,`rtl`,`auto`],draggable:[`true`,`false`,`auto`],dropzone:[`copy`,`move`,`link`,`string:`,`file:`],hidden:[`hidden`],id:null,inert:[`inert`],itemid:null,itemprop:null,itemref:null,itemscope:[`itemscope`],itemtype:null,lang:[`ar`,`bn`,`de`,`en-GB`,`en-US`,`es`,`fr`,`hi`,`id`,`ja`,`pa`,`pt`,`ru`,`tr`,`zh`],spellcheck:zA,autocorrect:zA,autocapitalize:zA,style:null,tabindex:null,title:null,translate:[`yes`,`no`],rel:[`stylesheet`,`alternate`,`author`,`bookmark`,`help`,`license`,`next`,`nofollow`,`noreferrer`,`prefetch`,`prev`,`search`,`tag`],role:`alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer`.split(` `),"aria-activedescendant":null,"aria-atomic":zA,"aria-autocomplete":[`inline`,`list`,`both`,`none`],"aria-busy":zA,"aria-checked":[`true`,`false`,`mixed`,`undefined`],"aria-controls":null,"aria-describedby":null,"aria-disabled":zA,"aria-dropeffect":null,"aria-expanded":[`true`,`false`,`undefined`],"aria-flowto":null,"aria-grabbed":[`true`,`false`,`undefined`],"aria-haspopup":zA,"aria-hidden":zA,"aria-invalid":[`true`,`false`,`grammar`,`spelling`],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":[`off`,`polite`,`assertive`],"aria-multiline":zA,"aria-multiselectable":zA,"aria-owns":null,"aria-posinset":null,"aria-pressed":[`true`,`false`,`mixed`,`undefined`],"aria-readonly":zA,"aria-relevant":null,"aria-required":zA,"aria-selected":[`true`,`false`,`undefined`],"aria-setsize":null,"aria-sort":[`ascending`,`descending`,`none`,`other`],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},HA=`beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload`.split(` `).map(e=>`on`+e);for(let e of HA)VA[e]=null;var UA=class{constructor(e,t){this.tags={...BA,...e},this.globalAttrs={...VA,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};UA.default=new UA;function WA(e,t,n=e.length){if(!t)return``;let r=t.firstChild,i=r&&r.getChild(`TagName`);return i?e.sliceString(i.from,Math.min(i.to,n)):``}function GA(e,t=!1){for(;e;e=e.parent)if(e.name==`Element`)if(t)t=!1;else return e;return null}function KA(e,t,n){return n.tags[WA(e,GA(t))]?.children||n.allTags}function qA(e,t){let n=[];for(let r=GA(t);r&&!r.type.isTop;r=GA(r.parent)){let i=WA(e,r);if(i&&r.lastChild.name==`CloseTag`)break;i&&n.indexOf(i)<0&&(t.name==`EndTag`||t.from>=r.firstChild.to)&&n.push(i)}return n}var JA=/^[:\-\.\w\u00b7-\uffff]*$/;function YA(e,t,n,r,i){let a=/\s*>/.test(e.sliceDoc(i,i+5))?``:`>`,o=GA(n,n.name==`StartTag`||n.name==`TagName`);return{from:r,to:i,options:KA(e.doc,o,t).map(e=>({label:e,type:`type`})).concat(qA(e.doc,n).map((e,t)=>({label:`/`+e,apply:`/`+e+a,type:`type`,boost:99-t}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function XA(e,t,n,r){let i=/\s*>/.test(e.sliceDoc(r,r+5))?``:`>`;return{from:n,to:r,options:qA(e.doc,t).map((e,t)=>({label:e,apply:e+i,type:`type`,boost:99-t})),validFor:JA}}function ZA(e,t,n,r){let i=[],a=0;for(let r of KA(e.doc,n,t))i.push({label:`<`+r,type:`type`});for(let t of qA(e.doc,n))i.push({label:`</`+t+`>`,type:`type`,boost:99-a++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function QA(e,t,n,r,i){let a=GA(n),o=a?t.tags[WA(e.doc,a)]:null,s=o&&o.attrs?Object.keys(o.attrs):[];return{from:r,to:i,options:(o&&o.globalAttrs===!1?s:s.length?s.concat(t.globalAttrNames):t.globalAttrNames).map(e=>({label:e,type:`property`})),validFor:JA}}function $A(e,t,n,r,i){let a=n.parent?.getChild(`AttributeName`),o=[],s;if(a){let c=e.sliceDoc(a.from,a.to),l=t.globalAttrs[c];if(!l){let r=GA(n),i=r?t.tags[WA(e.doc,r)]:null;l=i?.attrs&&i.attrs[c]}if(l){let t=e.sliceDoc(r,i).toLowerCase(),n=`"`,a=`"`;/^['"]/.test(t)?(s=t[0]==`"`?/^[^"]*$/:/^[^']*$/,n=``,a=e.sliceDoc(i,i+1)==t[0]?``:t[0],t=t.slice(1),r++):s=/^[^\s<>='"]*$/;for(let e of l)o.push({label:e,apply:n+e+a,type:`constant`})}}return{from:r,to:i,options:o,validFor:s}}function ej(e,t){let{state:n,pos:r}=t,i=Yt(n).resolveInner(r,-1),a=i.resolve(r);for(let e=r,t;a==i&&(t=i.childBefore(e));){let n=t.lastChild;if(!n||!n.type.isError||n.from<n.to)break;a=i=t,e=n.from}return i.name==`TagName`?i.parent&&/CloseTag$/.test(i.parent.name)?XA(n,i,i.from,r):YA(n,e,i,i.from,r):i.name==`StartTag`||i.name==`IncompleteTag`?YA(n,e,i,r,r):i.name==`StartCloseTag`||i.name==`IncompleteCloseTag`?XA(n,i,r,r):i.name==`OpenTag`||i.name==`SelfClosingTag`||i.name==`AttributeName`?QA(n,e,i,i.name==`AttributeName`?i.from:r,r):i.name==`Is`||i.name==`AttributeValue`||i.name==`UnquotedAttributeValue`?$A(n,e,i,i.name==`Is`?r:i.from,r):t.explicit&&(a.name==`Element`||a.name==`Text`||a.name==`Document`)?ZA(n,e,i,r):null}function tj(e){return ej(UA.default,e)}function nj(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new UA(t,n):UA.default;return e=>ej(r,e)}var rj=SA.parser.configure({top:`SingleExpression`}),ij=[{tag:`script`,attrs:e=>e.type==`text/typescript`||e.lang==`ts`,parser:wA.parser},{tag:`script`,attrs:e=>e.type==`text/babel`||e.type==`text/jsx`,parser:TA.parser},{tag:`script`,attrs:e=>e.type==`text/typescript-jsx`,parser:EA.parser},{tag:`script`,attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:rj},{tag:`script`,attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:SA.parser},{tag:`style`,attrs(e){return(!e.lang||e.lang==`css`)&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:Dk.parser}],aj=[{name:`style`,parser:Dk.parser.configure({top:`Styles`})}].concat(HA.map(e=>({name:e,parser:SA.parser}))),oj=xn.define({name:`html`,parser:EO.configure({props:[Tn.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let n=e.node;;){let e=n.lastChild;if(!e||e.name!=`Element`||e.to!=n.to)break;t=n=e}return t&&!((n=t.lastChild)&&(n.name==`CloseTag`||n.name==`SelfClosingTag`))?e.lineIndent(t.from)+e.unit:null}}),Dn.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!=`OpenTag`?null:{from:t.to,to:n.name==`CloseTag`?n.from:e.to}}}),gn.add({"OpenTag CloseTag":e=>e.getChild(`TagName`)})]}),languageData:{commentTokens:{block:{open:`<!--`,close:`-->`}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:`-_`}}),sj=oj.configure({wrap:AO(ij,aj)});function cj(e={}){let t=``,n;return e.matchClosingTags===!1&&(t=`noMatch`),e.selfClosingTags===!0&&(t=(t?t+` `:``)+`selfClosing`),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=AO((e.nestedLanguages||[]).concat(ij),(e.nestedAttributes||[]).concat(aj))),new vn(n?oj.configure({wrap:n,dialect:t}):t?sj.configure({dialect:t}):sj,[sj.data.of({autocomplete:nj(e)}),e.autoCloseTags===!1?[]:uj,AA().support,Ok().support])}var lj=new Set(`area base br col command embed frame hr img input keygen link meta param source track wbr menuitem`.split(` `)),uj=rn.inputHandler.of((e,t,n,r,i)=>{if(e.composing||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!sj.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let t=o.doc.sliceString(e.from-1,e.to)==r,{head:n}=e,i=Yt(o).resolveInner(n,-1),a;if(t&&r==`>`&&i.name==`EndTag`){let t=i.parent;if(t.parent?.lastChild?.name!=`CloseTag`&&(a=WA(o.doc,t.parent,n))&&!lj.has(a))return{range:e,changes:{from:n,to:n+ +(o.doc.sliceString(n,n+1)===`>`),insert:`</${a}>`}}}else if(t&&r==`/`&&i.name==`IncompleteCloseTag`){let e=i.parent;if(i.from==n-2&&e.lastChild?.name!=`CloseTag`&&(a=WA(o.doc,e,n))&&!lj.has(a)){let e=n+ +(o.doc.sliceString(n,n+1)===`>`),t=`${a}>`;return{range:$t.cursor(n+t.length,-1),changes:{from:n,to:e,insert:t}}}}return{range:e}});return s.changes.empty?!1:(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),dj=ln({commentTokens:{block:{open:`<!--`,close:`-->`}}}),fj=new Bt,pj=XE.configure({props:[Dn.add(e=>!e.is(`Block`)||e.is(`Document`)||mj(e)!=null||hj(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),fj.add(mj),Tn.add({Document:()=>null}),mn.add({Document:dj})]});function mj(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function hj(e){return e.name==`OrderedList`||e.name==`BulletList`}function gj(e,t){let n=e;for(;;){let e=n.nextSibling,r;if(!e||(r=mj(e.type))!=null&&r<=t)break;n=e}return n.to}var _j=cn.of((e,t,n)=>{for(let r=Yt(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let e=r.type.prop(fj);if(e==null)continue;let t=gj(r,e);if(t>n)return{from:n,to:t}}return null});function vj(e){return new dn(dj,e,[],`markdown`)}var yj=vj(pj),bj=vj(pj.configure([gD,yD,vD,bD,{props:[Dn.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));function xj(e,t){return n=>{if(n&&e){let t=null;if(n=/\S*/.exec(n)[0],t=typeof e==`function`?e(n):sn.matchLanguageName(e,n,!0),t instanceof sn)return t.support?t.support.language.parser:Sn.getSkippingParser(t.load());if(t)return t.parser}return t?t.parser:null}}var Sj=class{constructor(e,t,n,r,i,a,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=i,this.type=a,this.item=o}blank(e,t=!0){let n=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(e!=null){for(;n.length<e;)n+=` `;return n}else{for(let e=this.to-this.from-n.length-this.spaceAfter.length;e>0;e--)n+=` `;return n+(t?this.spaceAfter:``)}}marker(e,t){let n=this.node.name==`OrderedList`?String(+wj(this.item,e)[2]+t):``;return this.spaceBefore+n+this.type+this.spaceAfter}};function Cj(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if(t.name==`FencedCode`)return r;(t.name==`ListItem`||t.name==`Blockquote`)&&n.push(t)}for(let e=n.length-1;e>=0;e--){let i=n[e],a,o=t.lineAt(i.from),s=i.from-o.from;if(i.name==`Blockquote`&&(a=/^ *>( ?)/.exec(o.text.slice(s))))r.push(new Sj(i,s,s+a[0].length,``,a[1],`>`,null));else if(i.name==`ListItem`&&i.parent.name==`OrderedList`&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(s)))){let e=a[3],t=a[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new Sj(i.parent,s,s+t,a[1],e,a[2],i))}else if(i.name==`ListItem`&&i.parent.name==`BulletList`&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))){let e=a[4],t=a[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=a[2];a[3]&&(n+=a[3].replace(/[xX]/,` `)),r.push(new Sj(i.parent,s,s+t,a[1],e,n,i))}}return r}function wj(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function Tj(e,t,n,r=0){for(let i=-1,a=e;;){if(a.name==`ListItem`){let e=wj(a,t),o=+e[2];if(i>=0){if(o!=i+1)return;n.push({from:a.from+e[1].length,to:a.from+e[0].length,insert:String(i+2+r)})}i=o}let e=a.nextSibling;if(!e)break;a=e}}function Ej(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(Ht)!=` `)return e;let r=Vt(e,4,n),i=``;for(let e=r;e>0;)e>=4?(i+=` `,e-=4):(i+=` `,e--);return i+e.slice(n)}var Dj=((e={})=>({state:t,dispatch:n})=>{let r=Yt(t),{doc:i}=t,a=null,o=t.changeByRange(n=>{if(!n.empty||!bj.isActiveAt(t,n.from,-1)&&!bj.isActiveAt(t,n.from,1))return a={range:n};let o=n.from,s=i.lineAt(o),c=Cj(r.resolveInner(o,-1),i);for(;c.length&&c[c.length-1].from>o-s.from;)c.pop();if(!c.length)return a={range:n};let l=c[c.length-1];if(l.to-l.spaceAfter.length>o-s.from)return a={range:n};let u=o>=l.to-l.spaceAfter.length&&!/\S/.test(s.text.slice(l.to));if(l.item&&u){let n=l.node.firstChild,r=l.node.getChild(`ListItem`,`ListItem`);if(n.to>=o||r&&r.to<o||s.from>0&&!/[^\s>]/.test(i.lineAt(s.from-1).text)||e.nonTightLists===!1){let e=c.length>1?c[c.length-2]:null,t,n=``;e&&e.item?(t=s.from+e.from,n=e.marker(i,1)):t=s.from+(e?e.to:0);let r=[{from:t,to:o,insert:n}];return l.node.name==`OrderedList`&&Tj(l.item,i,r,-2),e&&e.node.name==`OrderedList`&&Tj(e.item,i,r),{range:$t.cursor(t+n.length),changes:r}}else{let e=Aj(c,t,s);return{range:$t.cursor(o+e.length+1),changes:{from:s.from,insert:e+t.lineBreak}}}}if(l.node.name==`Blockquote`&&u&&s.from){let e=i.lineAt(s.from-1),r=/>\s*$/.exec(e.text);if(r&&r.index==l.from){let i=t.changes([{from:e.from+r.index,to:e.to},{from:s.from+l.from,to:s.to}]);return{range:n.map(i),changes:i}}}let d=[];l.node.name==`OrderedList`&&Tj(l.item,i,d);let f=l.item&&l.item.from<s.from,p=``;if(!f||/^[\s\d.)\-+*>]*/.exec(s.text)[0].length>=l.to)for(let e=0,t=c.length-1;e<=t;e++)p+=e==t&&!f?c[e].marker(i,1):c[e].blank(e<t?Vt(s.text,4,c[e+1].from)-p.length:null);let m=o;for(;m>s.from&&/\s/.test(s.text.charAt(m-s.from-1));)m--;return p=Ej(p,t),kj(l.node,t.doc)&&(p=Aj(c,t,s)+t.lineBreak+p),d.push({from:m,to:o,insert:t.lineBreak+p}),{range:$t.cursor(m+p.length+1),changes:d}});return a?!1:(n(t.update(o,{scrollIntoView:!0,userEvent:`input`})),!0)})();function Oj(e){return e.name==`QuoteMark`||e.name==`ListMark`}function kj(e,t){if(e.name!=`OrderedList`&&e.name!=`BulletList`)return!1;let n=e.firstChild,r=e.getChild(`ListItem`,`ListItem`);if(!r)return!1;let i=t.lineAt(n.to),a=t.lineAt(r.from),o=/^[\s>]*$/.test(i.text);return i.number+ +!o<a.number}function Aj(e,t,n){let r=``;for(let t=0,i=e.length-2;t<=i;t++)r+=e[t].blank(t<i?Vt(n.text,4,e[t+1].from)-r.length:null,t<i);return Ej(r,t)}function jj(e,t){let n=e.resolveInner(t,-1),r=t;Oj(n)&&(r=n.from,n=n.parent);for(let e;e=n.childBefore(r);)if(Oj(e))r=e.from;else if(e.name==`OrderedList`||e.name==`BulletList`)n=e.lastChild,r=n.to;else break;return n}var Mj=[{key:`Enter`,run:Dj},{key:`Backspace`,run:({state:e,dispatch:t})=>{let n=Yt(e),r=null,i=e.changeByRange(t=>{let i=t.from,{doc:a}=e;if(t.empty&&bj.isActiveAt(e,t.from)){let t=a.lineAt(i),r=Cj(jj(n,i),a);if(r.length){let n=r[r.length-1],a=n.to-n.spaceAfter.length+ +!!n.spaceAfter;if(i-t.from>a&&!/\S/.test(t.text.slice(a,i-t.from)))return{range:$t.cursor(t.from+a),changes:{from:t.from+a,to:i}};if(i-t.from==a&&(!n.item||t.from<=n.item.from||!/\S/.test(t.text.slice(0,n.to)))){let r=t.from+n.from;if(n.item&&n.node.from<n.item.from&&/\S/.test(t.text.slice(n.from,n.to))){let i=n.blank(Vt(t.text,4,n.to)-Vt(t.text,4,n.from));return r==t.from&&(i=Ej(i,e)),{range:$t.cursor(r+i.length),changes:{from:r,to:t.from+n.to,insert:i}}}if(r<i)return{range:$t.cursor(r),changes:{from:r,to:i}}}}}return r={range:t}});return r?!1:(t(e.update(i,{scrollIntoView:!0,userEvent:`delete`})),!0)}}],Nj=cj({matchClosingTags:!1});function Pj(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:i}=yj,completeHTMLTags:a=!0,pasteURLAsLink:o=!0,htmlTagLanguage:s=Nj}=e;if(!(i instanceof SE))throw RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=e.extensions?[e.extensions]:[],l=[s.support,_j],u;o&&l.push(zj),n instanceof vn?(l.push(n.support),u=n.language):n&&(u=n);let d=t||u?xj(t,u):void 0;c.push(QE({codeParser:d,htmlParser:s.language.parser})),r&&l.push(hn.high(_n.of(Mj)));let f=vj(i.configure(c));return a&&l.push(f.data.of({autocomplete:Fj})),new vn(f,l)}function Fj(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let i=Yt(t).resolveInner(n,-1);for(;i&&!i.type.isTop;){if(i.name==`CodeBlock`||i.name==`FencedCode`||i.name==`ProcessingInstructionBlock`||i.name==`CommentBlock`||i.name==`Link`||i.name==`Image`)return null;i=i.parent}return{from:n-r[0].length,to:n,options:Lj(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}var Ij=null;function Lj(){if(Ij)return Ij;let e=tj(new Mn(Ut.create({extensions:Nj}),0,!0));return Ij=e?e.options:[]}var Rj=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,zj=rn.domEventHandlers({paste:(e,t)=>{let{main:n}=t.state.selection;if(n.empty)return!1;let r=e.clipboardData?.getData(`text/plain`);if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r=`https://`+r),!bj.isActiveAt(t.state,n.from,1)))return!1;let i=Yt(t.state),a=!1;return i.iterate({from:n.from,to:n.to,enter:e=>{(e.from>n.from||Rj.test(e.name))&&(a=!0)},leave:e=>{e.to<n.to&&(a=!0)}}),a?!1:(t.dispatch({changes:[{from:n.from,insert:`[`},{from:n.to,insert:`](${r})`}],userEvent:`input.paste`,scrollIntoView:!0}),!0)}});function Bj(){return Bj=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Bj.apply(null,arguments)}var Vj=e=>{var{theme:t,settings:n={},styles:r=[]}=e,i={".cm-gutters":{}},a={};n.background&&(a.backgroundColor=n.background),n.backgroundImage&&(a.backgroundImage=n.backgroundImage),n.foreground&&(a.color=n.foreground),n.fontSize&&(a.fontSize=n.fontSize),(n.background||n.foreground)&&(i[`&`]=a),n.fontFamily&&(i[`&.cm-editor .cm-scroller`]={fontFamily:n.fontFamily}),n.gutterBackground&&(i[`.cm-gutters`].backgroundColor=n.gutterBackground),n.gutterForeground&&(i[`.cm-gutters`].color=n.gutterForeground),n.gutterBorder&&(i[`.cm-gutters`].borderRightColor=n.gutterBorder),n.caret&&(i[`.cm-content`]={caretColor:n.caret},i[`.cm-cursor, .cm-dropCursor`]={borderLeftColor:n.caret});var o={};return n.gutterActiveForeground&&(o.color=n.gutterActiveForeground),n.lineHighlight&&(i[`.cm-activeLine`]={backgroundColor:n.lineHighlight},o.backgroundColor=n.lineHighlight),i[`.cm-activeLineGutter`]=o,n.selection&&(i[`&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection`]={background:n.selection+` !important`}),n.selectionMatch&&(i[`& .cm-selectionMatch`]={backgroundColor:n.selectionMatch}),[rn.theme(i,{dark:t===`dark`}),Jt(Cn.define(r))]},Hj={background:`#2E3235`,foreground:`#DDDDDD`,caret:`#DDDDDD`,selection:`#202325`,selectionMatch:`#202325`,gutterBackground:`#292d30`,gutterForeground:`#808080`,gutterBorder:`1px solid #ffffff10`,lineHighlight:`#B9D2FF30`},Uj=[{tag:W.keyword,color:`#fda331`},{tag:[W.name,W.deleted,W.character,W.propertyName,W.macroName],color:`#b5bd68`},{tag:[W.variableName],color:`#6fb3d2`},{tag:[W.function(W.variableName)],color:`#fda331`},{tag:[W.labelName],color:`#fc6d24`},{tag:[W.color,W.constant(W.name),W.standard(W.name)],color:`#fda331`},{tag:[W.definition(W.name),W.separator],color:`#cc99cc`},{tag:[W.brace],color:`#cc99cc`},{tag:[W.annotation],color:`#fc6d24`},{tag:[W.number,W.changed,W.annotation,W.modifier,W.self,W.namespace],color:`#fda331`},{tag:[W.typeName,W.className],color:`#6fb3d2`},{tag:[W.operator,W.operatorKeyword],color:`#cc99cc`},{tag:[W.tagName],color:`#fda331`},{tag:[W.squareBracket],color:`#cc99cc`},{tag:[W.angleBracket],color:`#cc99cc`},{tag:[W.attributeName],color:`#6fb3d2`},{tag:[W.regexp],color:`#fda331`},{tag:[W.quote],color:`#DDDDDD`},{tag:[W.string],color:`#b5bd68`},{tag:W.link,color:`#6987AF`,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[W.url,W.escape,W.special(W.string)],color:`#8abeb7`},{tag:[W.meta],color:`#A54543`},{tag:[W.comment],color:`#808080`,fontStyle:`italic`},{tag:W.monospace,color:`#DDDDDD`},{tag:W.strong,fontWeight:`bold`,color:`#fda331`},{tag:W.emphasis,fontStyle:`italic`,color:`#6fb3d2`},{tag:W.strikethrough,textDecoration:`line-through`},{tag:W.heading,fontWeight:`bold`,color:`#DDDDDD`},{tag:W.special(W.heading1),fontWeight:`bold`,color:`#DDDDDD`},{tag:W.heading1,fontWeight:`bold`,color:`#DDDDDD`},{tag:[W.heading2,W.heading3,W.heading4],fontWeight:`bold`,color:`#DDDDDD`},{tag:[W.heading5,W.heading6],color:`#DDDDDD`},{tag:[W.atom,W.bool,W.special(W.variableName)],color:`#8abeb7`},{tag:[W.processingInstruction,W.inserted],color:`#8abeb7`},{tag:[W.contentSeparator],color:`#6fb3d2`},{tag:W.invalid,color:`#B9D2FF`,borderBottom:`1px dotted #fc6d24`}],Wj=e=>{var{theme:t=`dark`,settings:n={},styles:r=[]}=e||{};return Vj({theme:t,settings:Bj({},Hj,n),styles:[...Uj,...r]})};Wj();var Gj={background:`#ffffff`,foreground:`#2e3440`,caret:`#3b4252`,selection:`#eceff4`,selectionMatch:`#e5e9f0`,gutterBackground:`#eceff4`,gutterForeground:`#2e3440`,gutterBorder:`none`,lineHighlight:`#02255f11`},Kj=[{tag:W.keyword,color:`#5e81ac`},{tag:[W.name,W.deleted,W.character,W.propertyName,W.macroName],color:`#d08770`},{tag:[W.variableName],color:`#d08770`},{tag:[W.function(W.variableName)],color:`#5e81ac`},{tag:[W.labelName],color:`#81a1c1`},{tag:[W.color,W.constant(W.name),W.standard(W.name)],color:`#5e81ac`},{tag:[W.definition(W.name),W.separator],color:`#a3be8c`},{tag:[W.brace],color:`#8fbcbb`},{tag:[W.annotation],color:`#d30102`},{tag:[W.number,W.changed,W.annotation,W.modifier,W.self,W.namespace],color:`#88c0d0`},{tag:[W.typeName,W.className],color:`#ebcb8b`},{tag:[W.operator,W.operatorKeyword],color:`#a3be8c`},{tag:[W.tagName],color:`#b48ead`},{tag:[W.squareBracket],color:`#bf616a`},{tag:[W.angleBracket],color:`#d08770`},{tag:[W.attributeName],color:`#ebcb8b`},{tag:[W.regexp],color:`#5e81ac`},{tag:[W.quote],color:`#3b4252`},{tag:[W.string],color:`#d08770`},{tag:W.link,color:`#8fbcbb`,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[W.url,W.escape,W.special(W.string)],color:`#d08770`},{tag:[W.meta],color:`#88c0d0`},{tag:[W.comment],color:`#434c5e`,fontStyle:`italic`},{tag:W.strong,fontWeight:`bold`,color:`#5e81ac`},{tag:W.emphasis,fontStyle:`italic`,color:`#5e81ac`},{tag:W.strikethrough,textDecoration:`line-through`},{tag:W.heading,fontWeight:`bold`,color:`#5e81ac`},{tag:W.special(W.heading1),fontWeight:`bold`,color:`#5e81ac`},{tag:W.heading1,fontWeight:`bold`,color:`#5e81ac`},{tag:[W.heading2,W.heading3,W.heading4],fontWeight:`bold`,color:`#5e81ac`},{tag:[W.heading5,W.heading6],color:`#5e81ac`},{tag:[W.atom,W.bool,W.special(W.variableName)],color:`#d08770`},{tag:[W.processingInstruction,W.inserted],color:`#8fbcbb`},{tag:[W.contentSeparator],color:`#ebcb8b`},{tag:W.invalid,color:`#434c5e`,borderBottom:`1px dotted #d30102`}],qj=e=>{var{theme:t=`light`,settings:n={},styles:r=[]}=e||{};return Vj({theme:t,settings:Bj({},Gj,n),styles:[...Kj,...r]})};qj();var Jj=[sn.of({name:`javascript`,alias:[`js`,`jsx`],extensions:[`js`,`mjs`,`cjs`,`jsx`],load:async()=>AA({jsx:!0})}),sn.of({name:`typescript`,alias:[`ts`,`tsx`],extensions:[`ts`,`mts`,`cts`,`tsx`],load:async()=>AA({typescript:!0,jsx:!0})}),sn.of({name:`json`,alias:[`jsonc`],extensions:[`json`,`jsonc`],load:()=>n(()=>import(`./dist-C3u7R0q7.js`).then(e=>e.json()),__vite__mapDeps([0,1,2,3,4]),import.meta.url)}),sn.of({name:`yaml`,alias:[`yml`],extensions:[`yaml`,`yml`],load:()=>n(()=>import(`./dist-Dtie9-Ui.js`).then(e=>e.yaml()),__vite__mapDeps([5,1,2,3,4]),import.meta.url)}),sn.of({name:`css`,alias:[`scss`,`less`],extensions:[`css`,`scss`,`less`],load:async()=>Ok()}),sn.of({name:`html`,alias:[`htm`],extensions:[`html`,`htm`],load:async()=>cj()}),sn.of({name:`python`,alias:[`py`],extensions:[`py`,`pyw`],load:()=>n(()=>import(`./dist-C82hC0q7.js`).then(e=>e.python()),__vite__mapDeps([6,7,1,2,3,4]),import.meta.url)}),sn.of({name:`rust`,alias:[`rs`],extensions:[`rs`],load:()=>n(()=>import(`./dist-mXs-_OvZ.js`).then(e=>e.rust()),__vite__mapDeps([8,1,2,3,4]),import.meta.url)}),sn.of({name:`markdown`,alias:[`md`,`mdx`],extensions:[`md`,`mdx`,`markdown`],load:async()=>Pj()}),sn.of({name:`bash`,alias:[`sh`,`shell`,`zsh`],extensions:[`sh`,`bash`,`zsh`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:t},{shell:r}]=await Promise.all([n(()=>import(`./dist-dkPJvrfr.js`).then(e=>e.m),__vite__mapDeps([1,2,3]),import.meta.url),n(()=>import(`./shell-BXlbE6k8.js`),[],import.meta.url)]);return new t(e.define(r))}}),sn.of({name:`go`,alias:[`golang`],extensions:[`go`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:t},{go:r}]=await Promise.all([n(()=>import(`./dist-dkPJvrfr.js`).then(e=>e.m),__vite__mapDeps([1,2,3]),import.meta.url),n(()=>import(`./go-DoDnGodl.js`),[],import.meta.url)]);return new t(e.define(r))}})],Yj=Xt.define(),Xj=Xt.define(),Zj=bn.line({class:`agent-flash`}),Qj=Qt.define({create(){return bn.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Yj)){let{from:r,to:i}=n.value,a=[];for(let e=r;e<=i;){let n=t.state.doc.lineAt(e);a.push(Zj.range(n.from)),e=n.to+1}e=e.update({add:a,sort:!0})}else n.is(Xj)&&(e=bn.none);return e},provide:e=>rn.decorations.from(e)});function $j(e){let t=e.getMap(`agent-flash`);return[Qj,an.define(e=>{let n=0,r=Date.now(),i=null,a=null,o=!1;function s(){let t=e.state.doc.length;t!==0&&(o||(e.dispatch({effects:Yj.of({from:0,to:t})}),a&&clearTimeout(a),a=setTimeout(()=>{a=null,!o&&e.dispatch({effects:Xj.of(null)})},De)))}let c=e=>{if(Ie(t),!Me(t,r))return;r=Date.now();let a=Date.now();if(a-n<500){if(!i){let e=500-(a-n);i=setTimeout(()=>{i=null,n=Date.now(),s()},e)}return}n=a,s()};t.observe(c);let l=()=>{document.visibilityState===`visible`?Me(t,r)&&(r=Date.now(),n=Date.now(),s()):r=Date.now()};return document.addEventListener(`visibilitychange`,l),{update(e){},destroy(){o=!0,t.unobserve(c),document.removeEventListener(`visibilitychange`,l),i&&=(clearTimeout(i),null),a&&=(clearTimeout(a),null)}}})]}var eM=/\[([^\]\n]*)\]\((<[^>\n]+>|[^)\s\n]+)(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?\)/g,tM=bn.mark({class:`cm-md-internal-link`});function nM(e,t){return t>0&&e[t-1]===`!`}function rM(e){let t=e[2]??``;return t.startsWith(`<`)&&t.endsWith(`>`)?t.slice(1,-1):t}function iM(e){let t=new pn;for(let{from:n,to:r}of e.visibleRanges){let i=e.state.doc.sliceString(n,r);eM.lastIndex=0;let a=eM.exec(i);for(;a!==null;){let e=nM(i,a.index)?null:PS(rM(a));e&&e.kind!==`external`&&t.add(n+a.index,n+a.index+a[0].length,tM),a=eM.exec(i)}}return t.finish()}var aM=an.fromClass(class{decorations;constructor(e){this.decorations=iM(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=iM(e.view))}},{decorations:e=>e.decorations}),oM=rn.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);eM.lastIndex=0;let i=eM.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=nM(r.text,i.index)?null:PS(rM(i));if(t&&t.kind!==`external`)return e.preventDefault(),t.kind===`doc`&&zS(e)?(RS(t),!0):(VS(t),!0)}i=eM.exec(r.text)}return!1}}),sM=rn.theme({".cm-md-internal-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-md-internal-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function cM(){return[aM,oM,sM]}var lM=5e3,uM=null,dM=0,fM=null,pM=new Map;async function mM(){let e=Date.now();return uM&&e-dM<lM?uM:(uM=await qC(),dM=e,fM=bM(uM),uM)}async function hM(e){let t=Date.now(),n=pM.get(e);if(n!==void 0&&t-n.time<lM)return n.headings;try{let n=await JC(e);return pM.set(e,{headings:n,time:t}),n}catch(n){return console.warn(`[wiki-link-source] /api/page-headings fetch failed:`,n),pM.set(e,{headings:[],time:t}),[]}}var gM=/\[\[[^\]]*?\]\]/g,_M=bn.mark({class:`cm-wiki-link`}),vM=bn.mark({class:`cm-wiki-link cm-wiki-link-broken`});function yM(e){let t=new Set;for(let n of e)t.add(n.docName.toLowerCase()),n.title&&t.add(n.title.toLowerCase());return t}function bM(e){let t=yM(e);for(let n of e){let e=n.docName.split(`/`);e.pop();let r=``;for(let n of e)r=r?`${r}/${n}`:n,t.add(r.toLowerCase())}return t}function xM(e){return e.split(/[#|]/)[0].trim().toLowerCase()}function SM(e){let t=new pn,n=uM?fM:null;for(let{from:r,to:i}of e.visibleRanges){let a=e.state.doc.sliceString(r,i);gM.lastIndex=0;let o=gM.exec(a);for(;o!==null;){let e=_M;if(n){let t=xM(o[0].slice(2,-2));t&&!n.has(t)&&(e=vM)}t.add(r+o.index,r+o.index+o[0].length,e),o=gM.exec(a)}}return t.finish()}var CM=an.fromClass(class{decorations;cacheWarmAtBuild;constructor(e){this.cacheWarmAtBuild=uM!==null,this.decorations=SM(e),this.cacheWarmAtBuild||this.warmCache(e)}update(e){let t=uM!==null;(e.docChanged||e.viewportChanged||!this.cacheWarmAtBuild&&t)&&(this.cacheWarmAtBuild=t,this.decorations=SM(e.view))}warmCache(e){mM().then(()=>{try{e.dispatch({})}catch{}}).catch(e=>{console.warn(`[wiki-link-source] warmCache fetch failed:`,e)})}},{decorations:e=>e.decorations}),wM=/\[\[([^[\]|#]+?)(?:#([^\]|]+?))?(?:\|([^\]]+?))?\]\]/g,TM=rn.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);wM.lastIndex=0;let i=wM.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=i[1]?.trim(),n=i[2]?.trim()||null;if(t){let r=c(t,n);if(!r)return!1;e.preventDefault(),r.kind===`external`?window.open(r.url,`_blank`,`noopener,noreferrer`):zS(e)?RS(r):window.location.hash=r.anchor?`#/${r.docName}?anchor=${encodeURIComponent(r.anchor)}`:`#/${r.docName}`}return!0}i=wM.exec(r.text)}return!1}});async function EM(e){let t=e.state.doc.sliceString(0,e.pos).match(/\[\[([^\]]*)$/);if(!t)return null;let n=t[1],r=e.pos-n.length,i=n.indexOf(`#`);if(i>0){let e=n.slice(0,i),t=n.slice(i+1),a=r+i+1,o=await hM(e);if(!o.length)return null;let s=HC(o,t);return s.length?{from:a,filter:!1,options:s.map(e=>({label:e.text,detail:`H${e.level}`,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.slug+a},selection:{anchor:r+e.slug.length+a.length}})}}))}:null}return{from:r,filter:!1,options:VC(await mM().catch(e=>(console.warn(`[wiki-link-source] Failed to fetch pages:`,e),[])),n).map(e=>({label:e.title,detail:e.title===e.docName?void 0:e.docName,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.docName+a},selection:{anchor:r+e.docName.length+a.length}})}}))}}var DM=rn.theme({".cm-wiki-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-wiki-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function OM(){return[CM,TM,DM,bj.data.of({autocomplete:EM})]}var kM=Wj({settings:{background:`transparent`,gutterBackground:`transparent`}}),AM=qj({settings:{background:`transparent`,gutterBackground:`transparent`}});function jM(e){let{themeCompartment:t,resolvedTheme:n,ydoc:r}=e,i=n===`dark`?kM:AM;return[Pj({base:bj,extensions:[gD],codeLanguages:Jj}),OM(),cM(),...r?[$j(r)]:[],_n.of([]),t.of(i),rn.lineWrapping,...e.extraKeymaps?[e.extraKeymaps]:[]]}function MM(e,t,n){let{state:r}=e,i=r.selection.main;if(!i.empty)return!1;if(t===`line`){let e=r.doc.lineAt(i.head);return n<0?e.from===0:e.to===r.doc.length}return n<0?i.head===0:i.head===r.doc.length}function NM(e){let{pmSel:t,nodePos:n,nodeSize:r,cmDocLen:i,cmSel:a,cmHasFocus:o}=e;if(t instanceof pe&&t.from===n)return o?{kind:`noop`}:{kind:`focus`};let s=n+1,c=n+r-1;if(t.from>=s&&t.to<=c){let e=Math.max(0,Math.min(t.anchor-s,i)),n=Math.max(0,Math.min(t.head-s,i));return a.anchor===e&&a.head===n&&o?{kind:`noop`}:{kind:`selection`,anchor:e,head:n}}return{kind:`noop`}}function PM(e,t){let n=pT().parseWithFallback(e),r;try{r=t.nodeFromJSON(n)}catch(e){return console.warn(JSON.stringify({event:`raw-mdx-upgrade-failure`,reason:e instanceof Error?e.message:String(e)})),null}if(r.childCount===0)return null;let i=[];for(let e=0;e<r.childCount;e++){let t=r.child(e);if(t.type.name===`rawMdxFallback`)return null;i.push(t)}return i}function FM(e,t){if(e===t)return null;let n=0,r=e.length,i=t.length;for(;n<r&&e.charCodeAt(n)===t.charCodeAt(n);)n++;for(;r>n&&i>n&&e.charCodeAt(r-1)===t.charCodeAt(i-1);)r--,i--;return{from:n,to:r,text:t.slice(n,i)}}function IM(e){let t=(0,q.c)(41),{node:n,editor:r,getPos:i}=e,a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(!1),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=new En,t[0]=c):c=t[0];let l=(0,G.useRef)(c),{resolvedTheme:u}=w(),d=n.attrs.reason||`Parse failed`,f;t[1]===d?f=t[2]:(f=HT(d),t[1]=d,t[2]=f);let p=f,m=UT[p],h;t[3]!==r||t[4]!==i?(h=e=>{let t=typeof i==`function`?i():void 0;if(t===void 0)return;let n=BT(r);if(!n)return;let a=n.state.doc.nodeAt(t);if(!a||a.type.name!==`rawMdxFallback`)return;let o=t+1,c=t+a.nodeSize-1;s.current=!0;try{let t=n.state.tr;if(e.length===0)t.delete(o,c);else{let r=n.state.schema.text(e);t.replaceWith(o,c,r)}n.dispatch(t)}catch(e){let t=e;throw s.current=!1,t}s.current=!1},t[3]=r,t[4]=i,t[5]=h):h=t[5];let g=h,_;t[6]!==r||t[7]!==g||t[8]!==i||t[9]!==n.textContent||t[10]!==u?(_=()=>{let e=a.current;if(!e)return;let t=l.current,c=_n.of([{key:`Mod-z`,run:()=>(r.commands.undo(),!0)},{key:`Mod-y`,run:()=>(r.commands.redo(),!0)},{key:`Mod-Shift-z`,run:()=>(r.commands.redo(),!0)}]),d=e=>{let t=typeof i==`function`?i():void 0;if(typeof t!=`number`)return!1;let n=BT(r);if(!n)return!1;let a=n.state.doc.nodeAt(t);if(!a||a.type.name!==`rawMdxFallback`)return!1;let o=e<0?t:t+a.nodeSize,s=ge.near(n.state.doc.resolve(o),e);return n.dispatch(n.state.tr.setSelection(s).scrollIntoView()),n.focus(),!0},f=_n.of([{key:`ArrowUp`,run:e=>MM(e,`line`,-1)?d(-1):!1},{key:`ArrowLeft`,run:e=>MM(e,`char`,-1)?d(-1):!1},{key:`ArrowDown`,run:e=>MM(e,`line`,1)?d(1):!1},{key:`ArrowRight`,run:e=>MM(e,`char`,1)?d(1):!1}]),p=jM({themeCompartment:t,resolvedTheme:u,ydoc:VT(r)??void 0,extraKeymaps:c});p.push(f),p.push(rn.updateListener.of(e=>{if(e.docChanged&&!s.current&&g(e.state.doc.toString()),e.focusChanged&&e.view.hasFocus&&!s.current){let e=typeof i==`function`?i():void 0;if(typeof e!=`number`)return;let t=BT(r);if(!t)return;let n=t.state.selection;if(n instanceof pe&&n.from===e)return;let a=t.state.doc.nodeAt(e);if(!a||a.type.name!==`rawMdxFallback`)return;s.current=!0;try{t.dispatch(t.state.tr.setSelection(pe.create(t.state.doc,e)))}catch(e){let t=e;throw s.current=!1,t}s.current=!1}if(e.focusChanged&&!e.view.hasFocus&&!s.current){let t=typeof i==`function`?i():void 0;if(typeof t!=`number`)return;let n=BT(r);if(!n)return;let a=n.state.doc.nodeAt(t);if(!a||a.type.name!==`rawMdxFallback`)return;let o=PM(e.view.state.doc.toString(),n.state.schema);if(!o)return;s.current=!0;try{n.dispatch(n.state.tr.replaceWith(t,t+a.nodeSize,o))}catch(e){let t=e;throw s.current=!1,t}s.current=!1}}));let m=new rn({doc:n.textContent,extensions:p,parent:e});o.current=m;let h=RM,_=m.contentDOM;_.addEventListener(`keydown`,h),_.addEventListener(`paste`,h),_.addEventListener(`drop`,h),_.addEventListener(`cut`,h);let v=()=>{_.removeEventListener(`keydown`,h),_.removeEventListener(`paste`,h),_.removeEventListener(`drop`,h),_.removeEventListener(`cut`,h)};return()=>{v(),m.destroy(),o.current=null}},t[6]=r,t[7]=g,t[8]=i,t[9]=n.textContent,t[10]=u,t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[12]=v):v=t[12],(0,G.useEffect)(_,v);let y,b;t[13]===u?(y=t[14],b=t[15]):(y=()=>{let e=o.current;if(!e)return;let t=u===`dark`?kM:AM;e.dispatch({effects:l.current.reconfigure(t)})},b=[u],t[13]=u,t[14]=y,t[15]=b),(0,G.useEffect)(y,b);let x,S;t[16]!==r||t[17]!==i?(x=()=>{let e=()=>{let e=typeof i==`function`?i():void 0;if(typeof e!=`number`)return;let t=o.current;if(!t||s.current)return;let n=BT(r);if(!n)return;let a=n.state.doc.nodeAt(e);if(!a)return;let c=NM({pmSel:n.state.selection,nodePos:e,nodeSize:a.nodeSize,cmDocLen:t.state.doc.length,cmSel:{anchor:t.state.selection.main.anchor,head:t.state.selection.main.head},cmHasFocus:t.hasFocus});if(c.kind!==`noop`){s.current=!0;try{c.kind===`selection`&&t.dispatch({selection:{anchor:c.anchor,head:c.head}}),t.hasFocus||t.focus()}catch(e){let t=e;throw s.current=!1,t}s.current=!1}};return r.on(`selectionUpdate`,e),()=>{r.off(`selectionUpdate`,e)}},S=[r,i],t[16]=r,t[17]=i,t[18]=x,t[19]=S):(x=t[18],S=t[19]),(0,G.useEffect)(x,S);let C=n.textContent,T,E;t[20]===C?(T=t[21],E=t[22]):(T=()=>{let e=o.current;if(!e||s.current)return;let t=FM(e.state.doc.toString(),C);if(t){s.current=!0;try{e.dispatch({changes:{from:t.from,to:t.to,insert:t.text}})}catch(e){let t=e;throw s.current=!1,t}s.current=!1}},E=[C],t[20]=C,t[21]=T,t[22]=E),(0,G.useEffect)(T,E);let D;t[23]!==r||t[24]!==i?(D=()=>{let e=typeof i==`function`?i():void 0;typeof e==`number`&&r.chain().focus().setNodeSelection(e).deleteSelection().run()},t[23]=r,t[24]=i,t[25]=D):D=t[25];let O=D,k=`raw-mdx-fallback-wrapper relative my-2 py-2 rounded border border-dashed ${m.wrapperClass}`,A=`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider ${m.badgeClass}`,j;t[26]!==d||t[27]!==m.label||t[28]!==A?(j=(0,K.jsx)(`span`,{className:A,title:d,children:m.label}),t[26]=d,t[27]=m.label,t[28]=A,t[29]=j):j=t[29];let M;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,K.jsx)(fr,{size:12}),t[30]=M):M=t[30];let N;t[31]===O?N=t[32]:(N=(0,K.jsx)(`button`,{type:`button`,className:`jsx-chrome-btn jsx-chrome-btn--delete`,"aria-label":`Delete block`,onClick:O,children:M}),t[31]=O,t[32]=N);let P;t[33]!==j||t[34]!==N?(P=(0,K.jsxs)(`div`,{className:`absolute top-1 right-1 z-10 flex items-center gap-1.5`,contentEditable:!1,onMouseDown:LM,children:[j,N]}),t[33]=j,t[34]=N,t[35]=P):P=t[35];let F;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,K.jsx)(`div`,{ref:a,className:`raw-mdx-fallback-cm`}),t[36]=F):F=t[36];let I;return t[37]!==p||t[38]!==k||t[39]!==P?(I=(0,K.jsxs)(Wa,{className:k,contentEditable:!1,"data-drag-handle":``,draggable:`true`,"data-severity":p,children:[P,F]}),t[37]=p,t[38]=k,t[39]=P,t[40]=I):I=t[40],I}function LM(e){return e.stopPropagation()}function RM(){}function zM(e,t){if(!e.selection.empty)return null;let n=t===`up`||t===`left`?-1:1,r=e.selection.$head,i=n>0?r.after():r.before();if(typeof i!=`number`)return null;let a=ge.near(e.doc.resolve(i),n);return a.$head?.parent.type.name===`rawMdxFallback`?a:null}function BM(e,t){let{state:n,view:r}=e;if(!r.endOfTextblock(t))return!1;let i=zM(n,t);return i?(r.dispatch(n.tr.setSelection(i)),!0):!1}var VM=L.extend({addKeyboardShortcuts(){return{ArrowLeft:({editor:e})=>BM(e,`left`),ArrowRight:({editor:e})=>BM(e,`right`),ArrowUp:({editor:e})=>BM(e,`up`),ArrowDown:({editor:e})=>BM(e,`down`)}},addNodeView(){return Qa(IM,{stopEvent:()=>!0,ignoreMutation:()=>!0})}});function HM(e){let t=(0,q.c)(47),{items:n,selectedIndex:r,categoryLabels:i,onSelect:a,onHoverIndex:o}=e,s=(0,G.useRef)(null),c=(0,G.useId)(),l=r>=0&&r<n.length?`${c}-option-${r}`:void 0,u=WM,d,f;if(t[0]===r?(d=t[1],f=t[2]):(d=()=>{let e=s.current;if(!e)return;let t=e.querySelectorAll(`[role="option"]`).item(r);t&&t.scrollIntoView({block:`nearest`})},f=[r],t[0]=r,t[1]=d,t[2]=f),(0,G.useEffect)(d,f),n.length===0){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(`div`,{ref:s,role:`status`,"aria-live":`polite`,className:`w-56 rounded-lg border bg-popover p-2 shadow-md text-sm text-muted-foreground`,style:{maxHeight:`var(--suggestion-menu-max-height, 40vh)`},onMouseDown:u,children:`No results`}),t[3]=e):e=t[3],e}let p,m,h,g,_,v,y,b,x,S,C,w,T;if(t[4]!==l||t[5]!==i||t[6]!==n||t[7]!==c||t[8]!==o||t[9]!==a||t[10]!==r){let e=[],d=0,f=new Map;for(let t of n){f.set(t,d++);let n=e.find(e=>e.key===t.category);n?n.items.push(t):e.push({key:t.category,items:[t]})}m=r>=0&&r<n.length?n[r]:null;let E;t[24]===n?E=t[25]:(E=n.some(UM),t[24]=n,t[25]=E),p=E,v=`flex items-start gap-2`,y=s,b=`listbox`,x=`Slash commands`,S=l,C=-1,w=u,T=`w-56 overflow-y-auto subtle-scrollbar rounded-lg border bg-popover p-1 shadow-md`,t[26]===Symbol.for(`react.memo_cache_sentinel`)?(h={maxHeight:`var(--suggestion-menu-max-height, 40vh)`},t[26]=h):h=t[26];let D=m?`${m.label}${m.preview?`. ${m.preview.description}`:``}`:``;t[27]===D?g=t[28]:(g=(0,K.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:D}),t[27]=D,t[28]=g),_=e.map(e=>(0,K.jsxs)(`div`,{role:`group`,"aria-labelledby":`${c}-group-${e.key}`,children:[(0,K.jsx)(`div`,{id:`${c}-group-${e.key}`,className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground`,children:i[e.key]??e.key}),e.items.map(e=>{let t=f.get(e)??0,n=t===r,i=e.icon;return(0,K.jsxs)(`button`,{id:`${c}-option-${t}`,type:`button`,role:`option`,"aria-selected":n,"data-selected":n,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-left ${n?`bg-accent text-accent-foreground`:``}`,onMouseEnter:()=>o?.(t),onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,K.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`div`,{className:`flex flex-col min-w-0`,children:(0,K.jsx)(`span`,{className:`truncate`,children:e.label})})]},e.name)})]},e.key)),t[4]=l,t[5]=i,t[6]=n,t[7]=c,t[8]=o,t[9]=a,t[10]=r,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S,t[21]=C,t[22]=w,t[23]=T}else p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20],C=t[21],w=t[22],T=t[23];let E;t[29]!==h||t[30]!==g||t[31]!==_||t[32]!==y||t[33]!==b||t[34]!==x||t[35]!==S||t[36]!==C||t[37]!==w||t[38]!==T?(E=(0,K.jsxs)(`div`,{ref:y,role:b,"aria-label":x,"aria-activedescendant":S,tabIndex:C,onMouseDown:w,className:T,style:h,children:[g,_]}),t[29]=h,t[30]=g,t[31]=_,t[32]=y,t[33]=b,t[34]=x,t[35]=S,t[36]=C,t[37]=w,t[38]=T,t[39]=E):E=t[39];let D;t[40]!==p||t[41]!==m?(D=p?(0,K.jsx)(`aside`,{"aria-hidden":`true`,onMouseDown:u,className:`w-64 rounded-lg border bg-popover p-2 shadow-md ${m?.preview?``:`invisible`}`,children:m?.preview?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`mb-2 flex aspect-5/3 items-center justify-center overflow-hidden rounded-md bg-muted/40 p-3 *:max-h-full *:max-w-full [&_img]:size-full [&_img]:rounded-md [&_img]:object-contain`,children:m.preview.render()}),(0,K.jsx)(`p`,{className:`px-1 pb-1 text-xs text-muted-foreground`,children:m.preview.description})]}):null}):null,t[40]=p,t[41]=m,t[42]=D):D=t[42];let O;return t[43]!==v||t[44]!==E||t[45]!==D?(O=(0,K.jsxs)(`div`,{className:v,children:[E,D]}),t[43]=v,t[44]=E,t[45]=D,t[46]=O):O=t[46],O}function UM(e){return e.preview}function WM(e){return e.preventDefault()}var GM=new Ke(`slashCommand`),KM=U.create({name:`slashCommand`,addOptions(){return{itemsSources:[()=>Sx],categoryLabels:{basic:`Basic blocks`,insert:`Insert`}}},addProseMirrorPlugins(){let e=this;return[AC({editor:this.editor,pluginKey:GM,char:`/`,startOfLine:!1,items:({query:t})=>{let n=e.options.itemsSources.flatMap(e=>{try{return e()}catch(e){return console.error(`[slash-command] item source threw an error`,e),[]}}),r=Object.keys(e.options.categoryLabels),i=e=>{let t=r.indexOf(e);return t===-1?1/0:t};return Cx(n.map((e,t)=>({item:e,i:t})).sort((e,t)=>{let n=i(e.item.category)-i(t.item.category);return n===0?e.i-t.i:n}).map(e=>e.item),t)},command:({editor:e,range:t,props:n})=>{try{e.chain().focus().deleteRange(t).run()}catch(e){console.error(`[slash-command] deleteRange failed for "${n.name}"`,e);return}try{n.command(e)}catch(e){console.error(`[slash-command] command "${n.name}" threw an error`,e)}},render:()=>{let t=null,n=null,r=0,i={popup:null,stopAutoUpdate:null},a=null,o=e=>{e!==r&&(r=e,s())},s=()=>{!t||!n||t.updateProps({items:n.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:n.command,onHoverIndex:o})};return{onStart(s){n=s,r=0;let c=IC(()=>n,`slash-command`);i.popup=c.popup,a=c.doPosition,t=new Xa(HM,{props:{items:s.items,selectedIndex:r,categoryLabels:e.options.categoryLabels,onSelect:s.command,onHoverIndex:o},editor:s.editor}),c.popup.appendChild(t.element),i.stopAutoUpdate=c.startAutoUpdate(),c.reveal()},onUpdate(e){n=e,r=Math.min(r,Math.max(0,e.items.length-1)),s(),a?.()},onKeyDown({event:e}){if(!n||n.items.length===0)return!1;let t=n.items;if(e.key===`ArrowDown`)return r=(r+1)%t.length,s(),!0;if(e.key===`ArrowUp`)return r=(r-1+t.length)%t.length,s(),!0;if(e.key===`Enter`||e.key===`Tab`){let e=t[r];return e&&n.command(e),!0}return e.key,!1},onExit(){LC(i),a=null,t?.destroy(),t=null,n=null,r=0}}}})]}}),qM=new Ke(`sourceDirty`),JM=U.create({name:`sourceDirtyObserver`,addProseMirrorPlugins(){return[new ke({key:qM,appendTransaction(e,t,n){if(!e.some(e=>!e.getMeta(Ox))||!e.some(e=>e.docChanged))return null;let r=new je;for(let t of e)r.appendMapping(t.mapping);let i=r.invert(),a=[];if(n.doc.descendants((e,n)=>{if(e.type.name!==`jsxComponent`||e.attrs.sourceDirty)return;let r=i.map(n),o=t.doc.nodeAt(r),s=!o||o.type.name!==`jsxComponent`,c=typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0;if(s&&c)return;if(!o){(e.content.size>0||Object.keys(e.attrs.props??{}).length>0)&&a.push({pos:n});return}if(o.type.name!==`jsxComponent`){a.push({pos:n});return}let l=!YM(o.attrs.props,e.attrs.props),u=!o.content.eq(e.content);(l||u)&&a.push({pos:n})}),a.length===0)return null;let o=n.tr;for(let{pos:e}of a)o.setNodeAttribute(e,`sourceDirty`,!0);return o}})]}});function YM(e,t){if(Object.is(e,t))return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!=`object`)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!YM(e[n],t[n]))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!YM(e[r],t[r]))return!1;return!0}function XM(e){let t=(0,q.c)(112),{open:n,target:r,alias:i,anchor:a,pages:o,onOpenChange:s,onSave:c}=e,[l,u]=(0,G.useState)(r),[d,f]=(0,G.useState)(i??``),[p,m]=(0,G.useState)(a??``),h=(0,G.useId)(),g=(0,G.useId)(),_=(0,G.useId)(),v=(0,G.useId)(),y;t[0]!==l||t[1]!==o?(y=Zy(l,o),t[0]=l,t[1]=o,t[2]=y):y=t[2];let b=XC(l,y&&n),x,S;t[3]!==i||t[4]!==a||t[5]!==n||t[6]!==r?(x=()=>{n&&(u(r),f(i??``),m(a??``))},S=[n,r,i,a],t[3]=i,t[4]=a,t[5]=n,t[6]=r,t[7]=x,t[8]=S):(x=t[7],S=t[8]),(0,G.useEffect)(x,S);let C;t[9]!==d||t[10]!==p||t[11]!==l||t[12]!==s||t[13]!==c?(C=function(){let e=l.trim();e&&(c(e,d.trim()||null,p.trim()||null),s(!1))},t[9]=d,t[10]=p,t[11]=l,t[12]=s,t[13]=c,t[14]=C):C=t[14];let w=C,T;t[15]===w?T=t[16]:(T=function(e){e.key===`Enter`&&w()},t[15]=w,t[16]=T);let E=T,D,O,k,A,j,M,N,P,F,I,L,R,z,ee,B,V;if(t[17]!==g||t[18]!==p||t[19]!==l||t[20]!==E||t[21]!==v||t[22]!==b||t[23]!==s||t[24]!==n||t[25]!==h){let e=new Map,r=b?.map(t=>{let n=e.get(t.slug)??0;e.set(t.slug,n+1);let r=n===0?t.slug:`${t.slug}-${n}`;return{...t,reactKey:r}}),i=!!r?.length;k=At,L=n,R=s,O=Nt,t[42]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,K.jsx)(Et,{className:`fixed inset-0 z-50 bg-black/40 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`}),t[42]=I):I=t[42],D=It,j=`dialog-content`,M=``,N=`fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-lg border border-border bg-background p-6 shadow-xl data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,K.jsx)(Ot,{className:`mb-1 text-base font-semibold`,children:`Edit wiki link`}),F=(0,K.jsx)(Tt,{className:`mb-4 text-sm text-muted-foreground`,children:`Modify the link target, anchor, and display label.`}),t[43]=P,t[44]=F):(P=t[43],F=t[44]),V=`mb-4 space-y-6`;let a;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,K.jsx)(`span`,{className:`text-red-500`,children:`*`}),t[45]=a):a=t[45];let o;t[46]===h?o=t[47]:(o=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:h,children:[`Page `,a]}),t[46]=h,t[47]=o);let c;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>u(e.target.value),t[48]=c):c=t[48];let d;t[49]!==l||t[50]!==E||t[51]!==h?(d=(0,K.jsx)(XS,{id:h,value:l,onChange:c,placeholder:`page-name`,autoFocus:!0,"aria-required":`true`,onKeyDown:E}),t[49]=l,t[50]=E,t[51]=h,t[52]=d):d=t[52],t[53]!==o||t[54]!==d?(A=(0,K.jsxs)(`div`,{children:[o,d]}),t[53]=o,t[54]=d,t[55]=A):A=t[55];let f;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional heading anchor)`}),t[56]=f):f=t[56],t[57]===g?z=t[58]:(z=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:g,children:[`Section`,` `,f]}),t[57]=g,t[58]=z);let _;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>m(e.target.value),t[59]=_):_=t[59],t[60]!==g||t[61]!==p||t[62]!==E?(ee=(0,K.jsx)(XS,{id:g,value:p,onChange:_,placeholder:`heading-slug`,onKeyDown:E}),t[60]=g,t[61]=p,t[62]=E,t[63]=ee):ee=t[63],B=i&&(0,K.jsx)(`div`,{role:`listbox`,id:v,"aria-label":`Heading anchors`,className:`mt-1.5 max-h-36 overflow-y-auto subtle-scrollbar rounded-md border border-border bg-muted/30`,children:r.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":p===e.slug,className:ft(`flex w-full items-center gap-2 px-2 py-1 text-left text-sm hover:bg-accent hover:text-accent-foreground`,p===e.slug&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${(e.level-1)*12+8}px`},onClick:()=>m(p===e.slug?``:e.slug),children:[(0,K.jsxs)(`span`,{className:`w-7 shrink-0 font-mono text-[10px] text-muted-foreground`,children:[`H`,e.level]}),(0,K.jsx)(`span`,{className:`truncate`,children:e.text})]},e.reactKey))}),t[17]=g,t[18]=p,t[19]=l,t[20]=E,t[21]=v,t[22]=b,t[23]=s,t[24]=n,t[25]=h,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=j,t[31]=M,t[32]=N,t[33]=P,t[34]=F,t[35]=I,t[36]=L,t[37]=R,t[38]=z,t[39]=ee,t[40]=B,t[41]=V}else D=t[26],O=t[27],k=t[28],A=t[29],j=t[30],M=t[31],N=t[32],P=t[33],F=t[34],I=t[35],L=t[36],R=t[37],z=t[38],ee=t[39],B=t[40],V=t[41];let H;t[64]!==z||t[65]!==ee||t[66]!==B?(H=(0,K.jsxs)(`div`,{children:[z,ee,B]}),t[64]=z,t[65]=ee,t[66]=B,t[67]=H):H=t[67];let te;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,K.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional display text)`}),t[68]=te):te=t[68];let ne;t[69]===_?ne=t[70]:(ne=(0,K.jsxs)(`label`,{className:`mb-1.5 block text-sm font-medium`,htmlFor:_,children:[`Label`,` `,te]}),t[69]=_,t[70]=ne);let re;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>f(e.target.value),t[71]=re):re=t[71];let U;t[72]!==_||t[73]!==d||t[74]!==E?(U=(0,K.jsx)(XS,{id:_,value:d,onChange:re,placeholder:`Custom display text`,onKeyDown:E}),t[72]=_,t[73]=d,t[74]=E,t[75]=U):U=t[75];let ie;t[76]!==ne||t[77]!==U?(ie=(0,K.jsxs)(`div`,{children:[ne,U]}),t[76]=ne,t[77]=U,t[78]=ie):ie=t[78];let ae;t[79]!==A||t[80]!==H||t[81]!==ie||t[82]!==V?(ae=(0,K.jsxs)(`div`,{className:V,children:[A,H,ie]}),t[79]=A,t[80]=H,t[81]=ie,t[82]=V,t[83]=ae):ae=t[83];let oe;t[84]===s?oe=t[85]:(oe=(0,K.jsx)(_t,{variant:`outline`,onClick:()=>s(!1),children:`Cancel`}),t[84]=s,t[85]=oe);let se;t[86]===l?se=t[87]:(se=l.trim(),t[86]=l,t[87]=se);let ce=!se,le;t[88]!==w||t[89]!==ce?(le=(0,K.jsx)(_t,{onClick:w,disabled:ce,children:`Save`}),t[88]=w,t[89]=ce,t[90]=le):le=t[90];let ue;t[91]!==oe||t[92]!==le?(ue=(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[oe,le]}),t[91]=oe,t[92]=le,t[93]=ue):ue=t[93];let de;t[94]!==D||t[95]!==j||t[96]!==M||t[97]!==N||t[98]!==P||t[99]!==F||t[100]!==ae||t[101]!==ue?(de=(0,K.jsxs)(D,{"data-slot":j,"data-ok-layer-spawned":M,className:N,children:[P,F,ae,ue]}),t[94]=D,t[95]=j,t[96]=M,t[97]=N,t[98]=P,t[99]=F,t[100]=ae,t[101]=ue,t[102]=de):de=t[102];let fe;t[103]!==O||t[104]!==I||t[105]!==de?(fe=(0,K.jsxs)(O,{children:[I,de]}),t[103]=O,t[104]=I,t[105]=de,t[106]=fe):fe=t[106];let pe;return t[107]!==k||t[108]!==L||t[109]!==R||t[110]!==fe?(pe=(0,K.jsx)(k,{open:L,onOpenChange:R,children:fe}),t[107]=k,t[108]=L,t[109]=R,t[110]=fe,t[111]=pe):pe=t[111],pe}function ZM(e){let t=(0,q.c)(128),{editor:n,getPos:r,onClose:i}=e,a=r(),o=a==null?null:n.state.doc.nodeAt(a),s=String(o?.attrs.target??``),l=d(o?.attrs.alias),u=d(o?.attrs.anchor),f=Re({target:s,alias:l,anchor:u}),{folderPaths:p,pages:m,pagesBySlug:h,loading:g}=Se(),_=c(s,u),v=_?.kind===`external`?_:null,y=JS(s,{pages:m,folderPaths:p,pagesBySlug:h,fallbackTargets:Xy(s)}),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(null),w=YS(y);if(!o)return null;let T;t[0]!==n.state||t[1]!==n.view||t[2]!==r?(T=function(e,t,i){let a=r();a!=null&&n.view.dispatch(n.state.tr.setNodeMarkup(a,void 0,{...n.state.doc.nodeAt(a)?.attrs,target:e,alias:t,anchor:i}))},t[0]=n.state,t[1]=n.view,t[2]=r,t[3]=T):T=t[3];let E=T,D;t[4]!==n.state||t[5]!==n.view||t[6]!==r||t[7]!==i?(D=function(){let e=r();if(e==null)return;let t=n.state.doc.nodeAt(e);t&&(n.view.dispatch(n.state.tr.delete(e,e+t.nodeSize)),i())},t[4]=n.state,t[5]=n.view,t[6]=r,t[7]=i,t[8]=D):D=t[8];let O=D,k;t[9]!==u||t[10]!==v||t[11]!==y||t[12]!==C?(k=function(e){if(v){MS(v.url)?window.open(v.url,`_blank`,`noopener,noreferrer`):console.warn(`[safe-nav] blocked non-safe scheme:`,v.url);return}if(y.kind===`create`){C(`missing`);return}let t=y.hashDocName;if(e.newTab){RS({docName:t,anchor:u});return}if(u){let e=window.location.hash.match(/^#\/([^?#/]+)/);if((e?decodeURIComponent(e[1]):null)===t){let e=document.getElementById(u);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})}window.location.hash=`#/${t}?anchor=${encodeURIComponent(u)}`;return}window.location.hash=`#/${t}`},t[9]=u,t[10]=v,t[11]=y,t[12]=C,t[13]=k):k=t[13];let A=k,j;t[14]!==l||t[15]!==S||t[16]!==n.state||t[17]!==n.view||t[18]!==r||t[19]!==f||t[20]!==s?(j=function(e){if(S===`missing`&&e!==s){let t=r();if(t==null)return;n.view.dispatch(n.state.tr.setNodeMarkup(t,void 0,{...n.state.doc.nodeAt(t)?.attrs,target:e,alias:l??f}))}},t[14]=l,t[15]=S,t[16]=n.state,t[17]=n.view,t[18]=r,t[19]=f,t[20]=s,t[21]=j):j=t[21];let M=j,N=!v&&!g&&y.kind===`navigate`&&y.displayState===`resolved`,P=!v&&!g&&y.kind===`navigate`&&y.displayState===`folder`,F=!v&&!g&&y.kind===`create`,I,L,R,z,ee,B,V,H,te,ne;if(t[22]!==n.state||t[23]!==n.view||t[24]!==v||t[25]!==r||t[26]!==P||t[27]!==N||t[28]!==F||t[29]!==g||t[30]!==i){if(g){let e;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(rr,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`}),t[41]=e):e=t[41],L={icon:e,text:`Loading…`,className:`text-muted-foreground`}}else if(v){let e;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Wn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[42]=e):e=t[42],L={icon:e,text:`External wiki link`,className:`text-foreground`}}else if(P){let e;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(qn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[43]=e):e=t[43],L={icon:e,text:`Folder (no index)`,className:`text-foreground`}}else if(F){let e;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Hn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[44]=e):e=t[44],L={icon:e,text:`Page not found`,className:`text-red-700 dark:text-red-300`}}else if(N){let e;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Kn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[45]=e):e=t[45],L={icon:e,text:`Wiki link`,className:`text-foreground`}}else{let e;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,K.jsx)(Hn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t[46]=e):e=t[46],L={icon:e,text:`Unrecognized wiki link`,className:`text-muted-foreground`}}let e;t[47]!==n.state||t[48]!==n.view||t[49]!==r?(e=()=>{let e=r();if(typeof e!=`number`)return new DOMRect;let t=n.state.doc.nodeAt(e);if(!t)return new DOMRect;try{return Be(n.view,e,e+t.nodeSize)}catch{return new DOMRect}},t[47]=n.state,t[48]=n.view,t[49]=r,t[50]=e):e=t[50];let a;t[51]!==n.view.dom||t[52]!==e?(a={getBoundingClientRect:e,contextElement:n.view.dom},t[51]=n.view.dom,t[52]=e,t[53]=a):a=t[53];let o=a;I=KS,ne=`wiki-link`,R=`Wiki link options`,z=i,ee=o,H=`mb-2 flex items-start gap-2 pr-8`,te=(0,K.jsx)(`div`,{className:ft(`mt-0.5 flex shrink-0`,L.className),children:L.icon}),V=`flex-1 min-w-0`,B=ft(`text-sm font-medium`,L.className),t[22]=n.state,t[23]=n.view,t[24]=v,t[25]=r,t[26]=P,t[27]=N,t[28]=F,t[29]=g,t[30]=i,t[31]=I,t[32]=L,t[33]=R,t[34]=z,t[35]=ee,t[36]=B,t[37]=V,t[38]=H,t[39]=te,t[40]=ne}else I=t[31],L=t[32],R=t[33],z=t[34],ee=t[35],B=t[36],V=t[37],H=t[38],te=t[39],ne=t[40];let re;t[54]!==L.text||t[55]!==B?(re=(0,K.jsx)(`div`,{className:B,children:L.text}),t[54]=L.text,t[55]=B,t[56]=re):re=t[56];let U=v?v.url:`${s}${u?`#${u}`:``}`,ie=v?v.url:`${s}${u?`#${u}`:``}`,ae;t[57]!==U||t[58]!==ie?(ae=(0,K.jsx)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,title:U,children:ie}),t[57]=U,t[58]=ie,t[59]=ae):ae=t[59];let oe;t[60]!==re||t[61]!==ae||t[62]!==V?(oe=(0,K.jsxs)(`div`,{className:V,children:[re,ae]}),t[60]=re,t[61]=ae,t[62]=V,t[63]=oe):oe=t[63];let se;t[64]!==oe||t[65]!==H||t[66]!==te?(se=(0,K.jsxs)(`div`,{className:H,children:[te,oe]}),t[64]=oe,t[65]=H,t[66]=te,t[67]=se):se=t[67];let ce;t[68]!==v||t[69]!==A||t[70]!==F||t[71]!==i?(ce=F?null:(0,K.jsx)(_t,{size:`sm`,variant:`default`,onClick:()=>{A({}),i()},children:v?`Open in new tab`:`Open`}),t[68]=v,t[69]=A,t[70]=F,t[71]=i,t[72]=ce):ce=t[72];let le;t[73]!==F||t[74]!==C?(le=F?(0,K.jsx)(_t,{size:`sm`,variant:`default`,onClick:()=>C(`missing`),children:`Create page`}):null,t[73]=F,t[74]=C,t[75]=le):le=t[75];let ue;t[76]!==w||t[77]!==P||t[78]!==C?(ue=P&&w?(0,K.jsxs)(_t,{size:`sm`,variant:`outline`,onClick:()=>C(`folder-index`),children:[(0,K.jsx)(Gn,{className:`size-3.5`,"aria-hidden":`true`}),`Create index`]}):null,t[76]=w,t[77]=P,t[78]=C,t[79]=ue):ue=t[79];let de;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,K.jsx)(`div`,{className:`flex-1`}),t[80]=de):de=t[80];let fe;t[81]===x?fe=t[82]:(fe=()=>x(!0),t[81]=x,t[82]=fe);let pe;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,K.jsx)(sr,{className:`size-3.5`,"aria-hidden":`true`}),t[83]=pe):pe=t[83];let me;t[84]===fe?me=t[85]:(me=(0,K.jsxs)(_t,{size:`sm`,variant:`outline`,onClick:fe,children:[pe,`Edit`]}),t[84]=fe,t[85]=me);let he;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,K.jsx)(fr,{className:`size-3.5`,"aria-hidden":`true`}),t[86]=he):he=t[86];let ge;t[87]===O?ge=t[88]:(ge=(0,K.jsxs)(_t,{size:`sm`,variant:`destructive`,onClick:O,children:[he,`Remove`]}),t[87]=O,t[88]=ge);let _e;t[89]!==ce||t[90]!==le||t[91]!==ue||t[92]!==me||t[93]!==ge?(_e=(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[ce,le,ue,de,me,ge]}),t[89]=ce,t[90]=le,t[91]=ue,t[92]=me,t[93]=ge,t[94]=_e):_e=t[94];let ve;t[95]!==I||t[96]!==R||t[97]!==z||t[98]!==ee||t[99]!==se||t[100]!==_e||t[101]!==ne?(ve=(0,K.jsxs)(I,{kind:ne,ariaLabel:R,onDeactivate:z,triggerReference:ee,children:[se,_e]}),t[95]=I,t[96]=R,t[97]=z,t[98]=ee,t[99]=se,t[100]=_e,t[101]=ne,t[102]=ve):ve=t[102];let ye=S!==null,be;t[103]===C?be=t[104]:(be=e=>{e||C(null)},t[103]=C,t[104]=be);let xe=S===`folder-index`&&w?w.initialDir:y.kind===`create`?y.initialDir:``,Ce=S===`folder-index`&&w?w.suggestedName:y.kind===`create`?y.suggestedName:void 0,we;t[105]!==S||t[106]!==w||t[107]!==s?(we=S===`folder-index`&&w?(0,K.jsxs)(K.Fragment,{children:[`Create an index note for`,` `,(0,K.jsxs)(`span`,{className:`font-medium text-foreground`,children:[w.initialDir,`/`]})]}):(0,K.jsxs)(K.Fragment,{children:[`Create a page for `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:s})]}),t[105]=S,t[106]=w,t[107]=s,t[108]=we):we=t[108];let Te;t[109]!==M||t[110]!==ye||t[111]!==be||t[112]!==xe||t[113]!==Ce||t[114]!==we?(Te=(0,K.jsx)(iC,{open:ye,onOpenChange:be,kind:`file`,initialDir:xe,suggestedName:Ce,description:we,onCreated:M}),t[109]=M,t[110]=ye,t[111]=be,t[112]=xe,t[113]=Ce,t[114]=we,t[115]=Te):Te=t[115];let Ee;t[116]!==l||t[117]!==u||t[118]!==b||t[119]!==E||t[120]!==m||t[121]!==x||t[122]!==s?(Ee=(0,K.jsx)(XM,{open:b,target:s,alias:l,anchor:u,pages:m,onOpenChange:x,onSave:E}),t[116]=l,t[117]=u,t[118]=b,t[119]=E,t[120]=m,t[121]=x,t[122]=s,t[123]=Ee):Ee=t[123];let De;return t[124]!==ve||t[125]!==Te||t[126]!==Ee?(De=(0,K.jsxs)(K.Fragment,{children:[ve,Te,Ee]}),t[124]=ve,t[125]=Te,t[126]=Ee,t[127]=De):De=t[127],De}var QM=0;function $M(){return`wiki-link-${++QM}`}function eN(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`span`);n.setAttribute(`data-wiki-link`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Wiki link: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-chip`),n.style.touchAction=`manipulation`;let r=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,i=t.createTextNode(r);return n.appendChild(i),{dom:n}}var tN=H.extend({priority:200,addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=$M(),{dom:i}=eN({nodeId:r,target:String(t.attrs.target??``),alias:t.attrs.alias==null?null:String(t.attrs.alias),anchor:t.attrs.anchor==null?null:String(t.attrs.anchor)}),a=t,o=()=>{let e=n();return typeof e==`number`?e:void 0},s=hC(e);return s.register({type:`wikiLink`,nodeId:r,getPos:o,controls:{propPanel:t=>(0,G.createElement)(ZM,{editor:e,getPos:o,onClose:t.deactivate})},handlePrimary:({newTab:e})=>{if(!e)return!1;let t=a.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=c(n,typeof t.anchor==`string`?t.anchor:null);return r?r.kind===`doc`?(RS({docName:r.docName,anchor:r.anchor}),!0):MS(r.url)?(IS(r.url),!0):!1:!1}}),{dom:i,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLink`)return!1;a=e;let t=String(e.attrs.target??``),n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor);return i.setAttribute(`data-target`,t),i.setAttribute(`data-alias`,n??``),i.setAttribute(`data-anchor`,r??``),i.setAttribute(`aria-label`,`Wiki link: ${t}${r?`#${r}`:``}`),i.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{s.deregister(r)}}}},addKeyboardShortcuts(){return{Backspace:()=>{if(RC.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeBefore;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from-t.nodeSize,e.from)),!0}return!1},Delete:()=>{if(RC.getState(this.editor.state)?.active)return!1;let{selection:e}=this.editor.state;if(!e.empty)return!1;let t=e.$from.nodeAfter;if(t?.type.name===`wikiLink`){let{state:n,view:r}=this.editor;return r.dispatch(n.tr.delete(e.from,e.from+t.nodeSize)),!0}return!1}}},addProseMirrorPlugins(){return[YC(this.editor)]}}),nN=0;function rN(){return`wiki-link-embed-${++nN}`}function iN(e){let t=e.doc??(typeof document<`u`?document:{createElement:null,createTextNode:null}),n=t.createElement(`a`);n.setAttribute(`data-wiki-embed`,``),n.setAttribute(`data-node-id`,e.nodeId),n.setAttribute(`data-target`,e.target),n.setAttribute(`data-alias`,e.alias??``),n.setAttribute(`data-anchor`,e.anchor??``),n.setAttribute(`href`,e.href),n.setAttribute(`target`,`_blank`),n.setAttribute(`rel`,`noopener noreferrer`),n.setAttribute(`contenteditable`,`false`),n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`),n.setAttribute(`aria-label`,`Embed: ${e.target}${e.anchor?`#${e.anchor}`:``}`),n.classList.add(`wiki-link-embed-chip`),n.style.touchAction=`manipulation`;let r=e.alias??`${e.target}${e.anchor?`#${e.anchor}`:``}`,i=t.createTextNode(r);return n.appendChild(i),{dom:n}}function aN(e){let t=(e.doc??(typeof document<`u`?document:{createElement:null})).createElement(`img`);return t.setAttribute(`data-wiki-embed`,``),t.setAttribute(`data-node-id`,e.nodeId),t.setAttribute(`data-target`,e.target),t.setAttribute(`data-alias`,e.alias??``),t.setAttribute(`src`,e.src),t.setAttribute(`alt`,e.alias??e.target),{dom:t}}function oN(e){let t=me(e);return t!==null&&j.has(t)}var sN=re.extend({addNodeView(){return({editor:e,node:t,getPos:n})=>{let r=rN(),i=t,a=String(t.attrs.target??``),o=t.attrs.alias==null?null:String(t.attrs.alias),s=t.attrs.anchor==null?null:String(t.attrs.anchor),c=t.attrs.resolvedSrc==null?null:String(t.attrs.resolvedSrc);if(oN(a)){let{dom:e}=aN({nodeId:r,target:a,alias:o,src:c??a});return{dom:e,ignoreMutation:()=>!0,update:t=>{if(t.type.name!==`wikiLinkEmbed`)return!1;i=t;let n=String(t.attrs.target??``),r=t.attrs.alias==null?null:String(t.attrs.alias),a=t.attrs.resolvedSrc==null?null:String(t.attrs.resolvedSrc);if(!oN(n))return!1;let o=a??n;return e.setAttribute(`data-target`,n),e.setAttribute(`data-alias`,r??``),e.setAttribute(`src`,o),e.setAttribute(`alt`,r??n),!0}}}let{dom:l}=iN({nodeId:r,target:a,alias:o,anchor:s,href:c??a});l.addEventListener(`click`,e=>{e.preventDefault()});let u=()=>{let e=n();return typeof e==`number`?e:void 0},d=hC(e);return d.register({type:`wikiLinkEmbed`,nodeId:r,getPos:u,controls:{},handlePrimary:({newTab:e})=>{let t=i.attrs,n=typeof t.target==`string`?t.target:``;if(!n)return!1;let r=(typeof t.resolvedSrc==`string`&&t.resolvedSrc.length>0?t.resolvedSrc:null)??n,a=me(n);if(a===null)return!1;let o=Ee(r,``)??n;return AS({url:r,projectRelPath:o,ext:a,title:o.split(`/`).pop()??r,forceOsDelegation:e}),!0}}),{dom:l,ignoreMutation:()=>!0,update:e=>{if(e.type.name!==`wikiLinkEmbed`)return!1;i=e;let t=String(e.attrs.target??``);if(oN(t))return!1;let n=e.attrs.alias==null?null:String(e.attrs.alias),r=e.attrs.anchor==null?null:String(e.attrs.anchor),a=(e.attrs.resolvedSrc==null?null:String(e.attrs.resolvedSrc))??t;return l.setAttribute(`data-target`,t),l.setAttribute(`data-alias`,n??``),l.setAttribute(`data-anchor`,r??``),l.setAttribute(`href`,a),l.setAttribute(`aria-label`,`Embed: ${t}${r?`#${r}`:``}`),l.textContent=n??`${t}${r?`#${r}`:``}`,!0},destroy:()=>{d.deregister(r)}}}}}),cN=[...N.map(e=>e.name===`jsxComponent`?zT:e.name===`rawMdxFallback`?VM:e.name===`wikiLink`?tN:e.name===`wikiLinkEmbed`?sN:e.name===`link`?uw:e),KM.configure({itemsSources:[()=>Sx,()=>lx()],categoryLabels:{content:`Components`,layout:`Layout`,media:`Media`,data:`Data`}}),Vy.configure({onDrop(e,t,n){for(let r of t)bx(r,e,n)},onPaste(e,t,n){for(let n of t)bx(n,e,e.state.selection.from)}}),DS,ES,Dx,JM,Hy,Nx,iT];function lN(e){return e===rt}var uN=3e4,dN=class extends Error{docName;elapsedMs;constructor(e,t){super(`Sync timed out for "${e}" after ${t}ms`),this.name=`SyncTimeoutError`,this.docName=e,this.elapsedMs=t}},fN=class extends Error{docName;constructor(e){super(`Provider disconnected before sync for "${e}"`),this.name=`PreSyncDisconnectError`,this.docName=e}},pN=class extends Error{docName;constructor(e){super(`Document not found: "${e}"`),this.name=`DocumentNotFoundError`,this.docName=e}},mN=class extends Error{docName;cause;constructor(e,t){let n=t instanceof Error?t.message:String(t??`unknown`);super(`Bridge setup failed for "${e}": ${n}`),this.name=`BridgeSetupError`,this.docName=e,this.cause=t}},hN=class extends Error{docName;missingCapability;constructor(e,t){super(`Server is missing capability "${t}" required to open "${e}".`),this.name=`ServerCapabilityMismatchError`,this.docName=e,this.missingCapability=t}},gN=new Map,_N=!1;function vN(){for(let e of gN.values())if(!e.settled)return!0;return!1}function yN(){typeof document>`u`||document.visibilityState===`visible`&&bN(Date.now())}function bN(e){let t=[];for(let[n,r]of gN){if(r.settled)continue;let i=e-r.createdAt;if(i<3e4)continue;r.settled=!0;let a=new dN(n,i);wN(r),r.reject(a),t.push({docName:n,elapsedMs:i})}if(t.length>0){let e=t.map(e=>`${e.docName} (${e.elapsedMs}ms)`).join(`, `);console.warn(`[syncPromise] reaped ${t.length} timed-out ${t.length===1?`entry`:`entries`} on visibility restore (tab-sleep recovered): ${e}`)}return vN()||SN(),t.length}function xN(){_N||typeof document>`u`||(document.addEventListener(`visibilitychange`,yN),_N=!0)}function SN(){_N&&(typeof document>`u`||(document.removeEventListener(`visibilitychange`,yN),_N=!1))}var CN=new Map;function wN(e){e.detached||(e.detached=!0,e.timeoutHandle!==null&&clearTimeout(e.timeoutHandle),e.provider.off(`synced`,e.onSynced),e.provider.off(`close`,e.onClose))}function TN(e,t){let n=gN.get(e);if(n)return n.promise;let r=CN.get(e);if(r!==void 0){CN.delete(e);let n=r===`timeout`?new dN(e,0):new fN(e);console.warn(`[syncPromise] ${e} rejected on creation (test hook, armed ${r}): ${n.message}`),J(`ok/sync/create`,{docName:e,warm:!1,armed:r}),J(`ok/sync/reject`,{docName:e,reason:`armed-${r}`});let i=DN(n);return gN.set(e,ON(i,t)),i}if(t.synced){console.log(`[syncPromise] ${e} resolved synchronously (warm provider)`),J(`ok/sync/create`,{docName:e,warm:!0}),J(`ok/sync/resolve`,{docName:e,elapsedMs:0,warm:!0});let n=Promise.resolve();return gN.set(e,EN(n,t)),n}let i=Date.now(),a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=()=>{let t=gN.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt;console.log(`[syncPromise] ${e} resolved in ${n}ms`),J(`ok/sync/resolve`,{docName:e,elapsedMs:n,warm:!1}),wN(t),vN()||SN(),t.resolve()},l=t=>{let n=gN.get(e);if(!n||n.settled)return;n.settled=!0;let r=new fN(e);console.warn(`[syncPromise] ${e} rejected: ${r.message}`),J(`ok/sync/reject`,{docName:e,reason:`pre-sync-disconnect`}),wN(n),vN()||SN(),n.reject(r)},u=setTimeout(()=>{let t=gN.get(e);if(!t||t.settled)return;t.settled=!0;let n=Date.now()-t.createdAt,r=new dN(e,n);console.warn(`[syncPromise] ${e} rejected: ${r.message}`),J(`ok/sync/reject`,{docName:e,reason:`timeout`,elapsedMs:n}),wN(t),vN()||SN(),t.reject(r)},uN),d={promise:s,resolve:a,reject:o,createdAt:i,timeoutHandle:u,provider:t,onSynced:c,onClose:l,settled:!1,detached:!1};return gN.set(e,d),t.on(`synced`,c),t.on(`close`,l),xN(),J(`ok/sync/create`,{docName:e,warm:!1}),s}function EN(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,detached:!0}}function DN(e){let t=Promise.reject(e);t.catch(()=>{});let n=t;return n.status=`rejected`,n.reason=e,n}function ON(e,t){return{promise:e,resolve:()=>{},reject:()=>{},createdAt:Date.now(),timeoutHandle:null,provider:t,onSynced:()=>{},onClose:()=>{},settled:!0,detached:!0}}function kN(e){let t=gN.get(e);t&&(t.settled=!0,wN(t),gN.delete(e),vN()||SN())}function AN(e,t){let n=gN.get(e);return!n||n.settled?!1:(n.settled=!0,console.warn(`[syncPromise] ${e} rejected: ${t.message}`),wN(n),vN()||SN(),n.reject(t),!0)}var jN=Object.freeze({kind:`tab-replay`}),MN=Object.freeze({kind:`idle`}),NN=ae(cN),PN=4e3,FN=1e4,IN=class extends Error{constructor(e,t){super(`client persistence clearData timed out for ${e} after ${t}ms`),this.docName=e,this.timeoutMs=t,this.name=`ClientPersistenceClearTimeoutError`}},LN=`ok-last-observed-branch`,RN=5e3,zN=1*1024*1024;function BN(e,t,n=null){let r={};if(e!==null&&(r.principalId=e.principalId,r.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(r.expectedServerInstanceId=t),n!==null&&n.length>0&&(r.expectedBranch=n),Object.keys(r).length!==0)return JSON.stringify(r)}var VN=class{_entries=new Map;get entries(){return this._entries}lruOrder=[];activeDocName=null;maxSize;wsUrl;recycleDebounceMs;clearDataTimeoutMs;onChange=null;tabIdentity=null;serverRestartRecoveryState=MN;cachedServerInstanceId=null;pendingServerInstanceKnown=null;recoveryMismatchStaleClaim;bufferedUpdates=new Map;persistenceFactory;storage;constructor(e,t,n){this.maxSize=e,this.wsUrl=t,this.recycleDebounceMs=n?.recycleDebounceMs??PN,this.clearDataTimeoutMs=n?.clearDataTimeoutMs??FN,this.persistenceFactory=n?.persistenceFactory??Fy,n?.storage===void 0?this.storage=globalThis.localStorage===void 0?null:globalThis.localStorage:this.storage=n.storage}setTabIdentity(e){this.tabIdentity=e}setExpectedServerInstanceId(e){if(this.cachedServerInstanceId=e,!(e===null||e.length===0)){if(this.pendingServerInstanceKnown!==null){let t=this.pendingServerInstanceKnown;this.pendingServerInstanceKnown=null,t.resolve(e)}this.attachDeferredPersistence(e)}}whenServerInstanceKnown(){if(this.cachedServerInstanceId!==null&&this.cachedServerInstanceId.length>0)return Promise.resolve(this.cachedServerInstanceId);if(this.pendingServerInstanceKnown!==null)return this.pendingServerInstanceKnown.promise;let e,t=new Promise(t=>{e=t});return this.pendingServerInstanceKnown={promise:t,resolve:e},t}buildPersistence(e,t,n){return this.persistenceFactory({branch:this.getOrInitObservedBranch()??`_unknown_`,serverInstanceId:e,docName:t,doc:n})}attachDeferredPersistence(e){for(let t of this._entries.values())if(t.kind===`active`&&t.persistence===null)try{t.persistence=this.buildPersistence(e,t.docName,t.provider.document)}catch(e){let n=e instanceof Error?e.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-client-persistence-attach-failed`,...this.recoveryTelemetryBase(t.docName),errorName:n,errorMessage:e instanceof Error?e.message:String(e)})}}getServerRestartRecoveryState(){return this.serverRestartRecoveryState}observeDiskAck(e,t){let n=this.entries.get(e);!n||n.kind!==`active`||(n.lastDiskAckedSV=Ry(n.lastDiskAckedSV,t))}observeDiskAckBatch(e){for(let[t,n]of Object.entries(e))this.observeDiskAck(t,n)}lastObservedBranch=null;lastObservedBranchInitialized=!1;getOrInitObservedBranch(){if(this.lastObservedBranchInitialized)return this.lastObservedBranch;this.lastObservedBranchInitialized=!0;try{let e=this.storage?.getItem(LN)??null;e!==null&&e.length>0&&(this.lastObservedBranch=e)}catch{}return this.lastObservedBranch}persistObservedBranch(e){this.lastObservedBranch=e,this.lastObservedBranchInitialized=!0;try{e===null||e.length===0?this.storage?.removeItem(LN):this.storage?.setItem(LN,e)}catch{}}withClearDataTimeout(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(new IN(e,this.clearDataTimeoutMs))},this.clearDataTimeoutMs);t.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e)})})}recoveryTelemetryBase(e,t){let n={docName:e,branch:this.getOrInitObservedBranch()??`_unknown_`},r=t===void 0?this.recoveryMismatchStaleClaim:t;return r!==void 0&&r.length>0&&(n.serverInstanceId=r),n}emitStructuredClientRecoveryEvent(e){console.warn(JSON.stringify(e))}clearRecoveryMismatchStaleClaimIfTerminal(){let e=this.serverRestartRecoveryState.kind;(e===`idle`||e===`failed`)&&(this.recoveryMismatchStaleClaim=void 0)}beginServerRestartRecovery(e,t){this.serverRestartRecoveryState={kind:`recovering`,phase:`clearing-local-cache`,docNames:e,failedDocNames:[],startedAt:t};for(let t of e)kN(t);this.notify()}enterServerRestartReconnect(e,t,n,r){if(e.length===0){this.serverRestartRecoveryState=t.length===0?MN:{kind:`failed`,reason:r,docNames:t,failedDocNames:t,startedAt:n},this.clearRecoveryMismatchStaleClaimIfTerminal(),this.notify();return}this.serverRestartRecoveryState={kind:`recovering`,phase:`reconnecting`,docNames:e,failedDocNames:t,startedAt:n,...t.length>0?{clearFailureReason:r}:{}},this.notify()}markServerRestartRecoverySynced(e){let t=this.serverRestartRecoveryState;if(t.kind!==`recovering`||t.phase!==`reconnecting`||!t.docNames.includes(e))return;let n=t.docNames.filter(t=>t!==e);if(n.length>0){this.serverRestartRecoveryState={...t,docNames:n};return}if(t.failedDocNames.length>0){this.serverRestartRecoveryState={kind:`failed`,reason:t.clearFailureReason??`clear-data-failed`,docNames:t.failedDocNames,failedDocNames:t.failedDocNames,startedAt:t.startedAt},this.clearRecoveryMismatchStaleClaimIfTerminal();return}this.serverRestartRecoveryState=MN,this.clearRecoveryMismatchStaleClaimIfTerminal()}setObservedBranch(e){this.persistObservedBranch(e)}compareAndUpdateObservedBranch(e){let t=this.getOrInitObservedBranch();return this.persistObservedBranch(e),t!==null&&t!==e}onBranchMismatch=null;branchMismatchInFlight=null;setOnBranchMismatch(e){if(e===null){this.onBranchMismatch=null;return}this.onBranchMismatch=()=>{if(this.branchMismatchInFlight!==null)return;let t=Promise.resolve().then(e).finally(()=>{this.branchMismatchInFlight===t&&(this.branchMismatchInFlight=null)});this.branchMismatchInFlight=t}}setOnChange(e){this.onChange=e}notify(){this.onChange?.()}evictListeners=new Set;onEvict(e){return this.evictListeners.add(e),()=>{this.evictListeners.delete(e)}}fireEvict(e){for(let t of this.evictListeners)try{t(e)}catch(t){console.warn(`[ProviderPool] evict listener threw for ${e}:`,t)}}touch(e){let t=this.lruOrder.indexOf(e);t!==-1&&this.lruOrder.splice(t,1),this.lruOrder.push(e)}open(e){if(lN(e))return null;let t=this.entries.get(e);if(t)return t.lastAccessedAt=Date.now(),this.touch(e),this.notify(),t;this.entries.size>=this.maxSize&&this.evictLru();let n=this.cachedServerInstanceId,r=BN(this.tabIdentity,n,this.getOrInitObservedBranch()),i=new uy({url:zy(this.wsUrl),name:e,forceSyncInterval:RN,...r===void 0?{}:{token:r}}),a=this.cachedServerInstanceId,o={kind:`active`,provider:i,persistence:a!==null&&a.length>0?this.buildPersistence(a,e,i.document):null,lastServerSyncedSV:null,lastDiskAckedSV:null,observerCleanup:null,syncState:`connecting`,docName:e,lastAccessedAt:Date.now(),hasSynced:!1,pendingRecycleTimer:null,bridgeSetupFailed:!1};if(i.on(`status`,({status:t})=>{o.kind!==`active`||this.entries.get(e)!==o||t===`disconnected`&&(o.syncState=`disconnected`,this.notify())}),i.on(`synced`,()=>{if(!(o.kind!==`active`||this.entries.get(e)!==o)&&(o.syncState=`synced`,o.hasSynced=!0,o.lastServerSyncedSV=Iy(i.document),o.pendingRecycleTimer&&=(clearTimeout(o.pendingRecycleTimer),null),this.markServerRestartRecoverySynced(e),this.notify(),!o.observerCleanup))try{let t=i.document,n=new y({extensions:cN});o.observerCleanup=lT({doc:t,xmlFragment:t.getXmlFragment(`default`),ytext:t.getText(`source`),mdManager:n,schema:NN,onSyncError:(t,n)=>{console.warn(`[Sync] ${t} failed for ${e}:`,n.message)}})}catch(t){console.error(`[ProviderPool] setupObservers init failed for ${e}:`,t),o.bridgeSetupFailed=!0,AN(e,new mN(e,t))}}),i.on(`disconnect`,()=>{o.kind!==`active`||this.entries.get(e)!==o||(o.syncState=`disconnected`,this.notify(),o.hasSynced&&i.unsyncedChanges===0&&!o.pendingRecycleTimer&&(o.pendingRecycleTimer=setTimeout(()=>{o.kind===`active`&&(o.pendingRecycleTimer=null,this.entries.get(e)===o&&this.recycleDisconnectedEntry(e))},this.recycleDebounceMs)))}),i.on(`authenticationFailed`,({reason:e})=>{if(![`server-instance-mismatch`,`branch-mismatch`].includes(e)){console.warn(JSON.stringify({event:`ok-auth-failed-unknown-reason`,reason:e}));return}let t=e;if(t===`server-instance-mismatch`){if(n===null||this.cachedServerInstanceId!==n)return;let e=n;this.cachedServerInstanceId=null,this.handleServerInstanceMismatch(e);return}if(t===`branch-mismatch`){this.onBranchMismatch?.();return}}),this.bufferedUpdates.get(e)!==void 0){let t=this.recoveryMismatchStaleClaim,n=()=>{if(i.off(`synced`,n),o.kind!==`active`||this.entries.get(e)!==o)return;let r=this.bufferedUpdates.get(e);if(r!==void 0){this.bufferedUpdates.delete(e);try{ad(i.document,r,jN)}catch(n){let i=n instanceof Error?n.name:`non-error-throw`;this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-failed`,...this.recoveryTelemetryBase(e,t),replayByteLength:r.byteLength,errorName:i,errorMessage:n instanceof Error?n.message:String(n)})}}};i.on(`synced`,n)}return this._entries.set(e,o),this.touch(e),this.notify(),o}handleServerInstanceMismatch(e){this.recoveryMismatchStaleClaim=e.length>0?e:void 0;let t=Array.from(this.entries.entries()),n=Date.now(),r=this.activeDocName,i=r!==null&&t.some(([e,t])=>e===r&&t.kind===`active`)?[r]:[],a=r??t.find(([,e])=>e.kind===`active`)?.[0]??``;a.length>0&&this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-epoch-mismatch`,...this.recoveryTelemetryBase(a)}),this.beginServerRestartRecovery(i,n);for(let[e,n]of t)n.kind===`active`&&!i.includes(e)&&kN(e);for(let[e,n]of t){if(n.kind!==`active`)continue;let t=n.lastDiskAckedSV??n.lastServerSyncedSV;if(t===null){this.emitStructuredClientRecoveryEvent({event:`ok-buffer-replay-skipped-no-baseline`,...this.recoveryTelemetryBase(e),reason:`no-disk-ack-or-server-sync-vector`});continue}let r=Ly(n.provider.document,t);if(r.byteLength>zN){J(`ok/pool/buffer-overflow`,{docName:e,bytes:r.byteLength});continue}r.byteLength>0&&this.bufferedUpdates.set(e,r)}let o=[];for(let[e,n]of t)n.kind===`active`&&n.persistence!==null&&o.push({docName:e,promise:this.withClearDataTimeout(e,n.persistence.clearData())});Promise.allSettled(o.map(e=>e.promise)).then(e=>{let t=[],i=[],a=!1;e.forEach((e,n)=>{let r=o[n];if(!r)return;let s=r.docName;if(e.status===`rejected`){t.push(s);let n=e.reason instanceof IN;if(n&&(a=!0),n)this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`timeout`});else{let t=e.reason instanceof Error?e.reason.name:`unknown`;this.emitStructuredClientRecoveryEvent({event:`ok-client-cache-clear-failed`,...this.recoveryTelemetryBase(s),failureKind:`rejected`,errorName:t,errorMessage:e.reason instanceof Error?e.reason.message:String(e.reason)})}}else i.push(s)});let s=i.filter(e=>e===r);if(t.length>0){let e=a?`clear-data-timeout`:`clear-data-failed`;console.warn(JSON.stringify({event:`ok-mismatch-recycle-partial-clears-failed`,failedDocs:t,clearedDocs:i})),this.enterServerRestartReconnect(s,t,n,e);for(let e of i)this.recycleDisconnectedEntry(e);return}this.enterServerRestartReconnect(s,[],n,`clear-data-failed`),this.recycleAllEntries()})}recycleAllEntries(){let e=Array.from(this.entries.keys());for(let t of e)this.recycleDisconnectedEntry(t)}prewarm(e){if(lN(e))return null;let t=this.entries.get(e);if(t)return t;let n=this.open(e);if(!n)return null;let r=this.lruOrder.indexOf(e);return r!==-1&&(this.lruOrder.splice(r,1),this.lruOrder.unshift(e)),n}close(e){let t=this.entries.get(e);t&&(this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),this.bufferedUpdates.delete(e),this.activeDocName===e&&(this.activeDocName=null),this.notify())}async closeAndClearPersistence(e){let t=this.entries.get(e);if(t?.kind===`active`&&t.persistence!==null){try{await t.persistence.clearData()}catch(t){console.warn(`[ProviderPool] clearData on rename failed for ${e}:`,t)}this.close(e);return}t&&this.close(e);let n=this.getOrInitObservedBranch(),r=this.cachedServerInstanceId;if(n===null||r===null)return;let i=`ok-ydoc:${n}:${r}:${e}`;try{await new Promise((e,t)=>{let n=indexedDB.deleteDatabase(i);n.onsuccess=()=>e(),n.onerror=()=>t(n.error),n.onblocked=()=>{console.warn(`[ProviderPool] IDB delete blocked for ${i}`),t(Error(`idb-clear-blocked: ${i}`))}})}catch(e){console.warn(`[ProviderPool] IDB delete on rename failed for ${i}:`,e)}}clearBufferedUpdates(){this.bufferedUpdates.clear()}__test_seedBufferedUpdate(e,t){this.bufferedUpdates.set(e,t)}__test_bufferedUpdatesSize(){return this.bufferedUpdates.size}__test_hasBufferedUpdate(e){return this.bufferedUpdates.has(e)}__test_getBufferedUpdate(e){return this.bufferedUpdates.get(e)}setActive(e){let t=this.entries.get(e);if(!t)throw Error(`[ProviderPool] Cannot setActive — "${e}" is not open`);t.lastAccessedAt=Date.now(),this.touch(e),this.activeDocName=e,this.notify()}clearActive(){this.activeDocName!==null&&(this.activeDocName=null,this.notify())}getActive(){return this.activeDocName?this.entries.get(this.activeDocName)??null:null}getActiveDocName(){return this.activeDocName}has(e){return this.entries.has(e)}recycle(e){this.recycleDisconnectedEntry(e)}dispose(){for(let e of this._entries.values())this.destroyEntry(e);this._entries.clear(),this.lruOrder=[],this.activeDocName=null,this.onChange=null,this.bufferedUpdates.clear(),this.onBranchMismatch=null,this.branchMismatchInFlight=null,this.evictListeners.clear(),this.serverRestartRecoveryState=MN,this.cachedServerInstanceId=null,this.pendingServerInstanceKnown=null,this.tabIdentity=null,this.recoveryMismatchStaleClaim=void 0}evictLru(){for(let e of this.lruOrder)if(e!==this.activeDocName){J(`ok/pool/evict-lru`,{docName:e}),this.close(e);return}}destroyEntry(e){if(e.kind===`tearing-down`)return;let t=e.observerCleanup,n=e.persistence,r=e.pendingRecycleTimer,i=e.docName,a=e;a.kind=`tearing-down`,a.persistence=null,a.observerCleanup=null,a.pendingRecycleTimer=null,r&&clearTimeout(r),kN(i),this.fireEvict(i),t?.(),n!==null&&n.destroy().catch(e=>{console.warn(`[ProviderPool] persistence destroy failed for ${i}:`,e)});try{a.provider.destroy()}catch(e){console.warn(`[ProviderPool] Provider destroy failed for ${i}:`,e)}}recycleDisconnectedEntry(e){let t=this.entries.get(e);if(!t||t.kind!==`active`)return;let n=this.activeDocName===e;if(J(`ok/pool/recycle-disconnected`,{docName:e,wasActive:n}),this.destroyEntry(t),this._entries.delete(e),this.lruOrder=this.lruOrder.filter(t=>t!==e),n){this.open(e)&&this.setActive(e);return}this.notify()}},HN=crypto.randomUUID(),UN=!1;function WN(e){UN||(UN=!0,console.warn(`[principal-fetch] failed to resolve principal — falling back to random identity.`,e))}var GN=(0,G.createContext)(null),KN=null;function qN(e){return KN||(KN=new VN(10,e),Dg(KN)),KN}var JN={activeDocName:null,activeProvider:null,syncState:`connecting`,serverRestartRecovery:{kind:`idle`},poolEntries:[]};function YN(e){let t=e.getActive(),n=[];for(let t of e.entries.values())n.push({docName:t.docName,provider:t.provider,lastAccessedAt:t.lastAccessedAt});return n.sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt),{activeDocName:e.getActiveDocName(),activeProvider:t?.provider??null,syncState:t?.syncState??`connecting`,serverRestartRecovery:e.getServerRestartRecoveryState(),poolEntries:n}}function XN(e){let t=(0,q.c)(61),{children:n}=e,[r,i]=(0,G.useState)(JN),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(`doc`),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(0),{collabUrl:_,terminal:v,lastError:y,retry:b}=eg(),x,S;t[0]===_?(x=t[1],S=t[2]):(x=()=>{if(_===null)return;let e=qN(_);return i(YN(e)),e.setOnBranchMismatch(()=>Rh(e)),e.setOnChange(()=>i(YN(e))),fetch(`/api/principal`).then($N).then(t=>{let n=k.safeParse(t);n.success?(e.setTabIdentity({principalId:n.data.id,tabSessionId:HN}),c(n.data)):WN(n.error)}).catch(QN),Rh(e),()=>{e.setOnChange(null)}},S=[_],t[0]=_,t[1]=x,t[2]=S),(0,G.useEffect)(x,S);let C;t[3]===_?C=t[4]:(C=e=>{if(J(`ok/nav/open-document`,{docName:e,transition:!1}),_===null)return;let t=qN(_);t.open(e)&&(t.setActive(e),o({kind:`doc`,target:e,docName:e}))},t[3]=_,t[4]=C);let w=C,T;t[5]===w?T=t[6]:(T=e=>{J(`ok/nav/open-document`,{docName:e,transition:!1}),w(e)},t[5]=w,t[6]=T);let E=T,D;t[7]===_?D=t[8]:(D=e=>{if(_===null)return;let t=qN(_),n=he(e);n?(t.open(n),t.setActive(n)):t.clearActive(),o(e)},t[7]=_,t[8]=D);let O=D,A;t[9]===O?A=t[10]:(A=e=>{J(`ok/nav/open-target`,{docName:he(e),kind:e.kind,transition:!1}),O(e)},t[9]=O,t[10]=A);let j=A,M,N,P,F,I;t[11]===_?(M=t[12],N=t[13],P=t[14],F=t[15],I=t[16]):(P=()=>{if(_===null){o(null);return}qN(_).clearActive(),o(null)},F=e=>{_!==null&&(qN(_).close(e),o(t=>t&&(he(t)===e?null:t)))},I=async e=>{_!==null&&(await qN(_).closeAndClearPersistence(e),o(t=>t&&(he(t)===e?null:t)))},M=e=>{_!==null&&qN(_).recycle(e)},N=e=>{_!==null&&qN(_).prewarm(e)},t[11]=_,t[12]=M,t[13]=N,t[14]=P,t[15]=F,t[16]=I);let L,R,z,ee,B;t[17]===_?(L=t[18],R=t[19],z=t[20],ee=t[21],B=t[22]):(L=e=>{_!==null&&qN(_).setExpectedServerInstanceId(e)},R=async e=>{if(_===null)return;let t=qN(_);t.setObservedBranch(e),await Fh(t,e)},z=async e=>{if(_===null)return;let t=qN(_);t.compareAndUpdateObservedBranch(e)&&await Fh(t,e)},ee=(e,t)=>{_!==null&&qN(_).observeDiskAck(e,t)},B=async()=>{_!==null&&await Rh(qN(_))},t[17]=_,t[18]=L,t[19]=R,t[20]=z,t[21]=ee,t[22]=B);let V;t[23]!==p||t[24]!==d?(V=e=>{if(d===`agent`&&p===e){f(`doc`);return}m(e),f(`agent`),g(ZN)},t[23]=p,t[24]=d,t[25]=V):V=t[25];let H;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{f(`doc`),m(null)},t[26]=H):H=t[26];let te;t[27]!==a||t[28]!==y||t[29]!==v||t[30]!==_||t[31]!==p||t[32]!==h||t[33]!==d||t[34]!==w||t[35]!==E||t[36]!==O||t[37]!==j||t[38]!==s||t[39]!==b||t[40]!==r.activeDocName||t[41]!==r.activeProvider||t[42]!==r.poolEntries||t[43]!==r.serverRestartRecovery||t[44]!==r.syncState||t[45]!==l||t[46]!==M||t[47]!==N||t[48]!==L||t[49]!==R||t[50]!==z||t[51]!==ee||t[52]!==B||t[53]!==V||t[54]!==P||t[55]!==F||t[56]!==I?(te={principal:s,activeTarget:a,activeDocName:r.activeDocName,activeProvider:r.activeProvider,syncState:r.syncState,serverRestartRecovery:r.serverRestartRecovery,poolEntries:r.poolEntries,openDocument:w,openDocumentTransition:E,openTarget:O,openTargetTransition:j,clearTarget:P,closeDocument:F,closeAndClearForRename:I,recycleDocument:M,prewarm:N,systemProvider:l,setSystemProvider:u,updateServerInstanceId:L,onBranchSwitched:R,observeBranch:z,observeDiskAck:ee,refreshServerInfo:B,collabUrl:_,collabTerminal:v,collabLastError:y,retryCollab:b,docPanelMode:d,docPanelAgentId:p,docPanelExpandSignal:h,openActivityPanel:V,closeActivityPanel:H},t[27]=a,t[28]=y,t[29]=v,t[30]=_,t[31]=p,t[32]=h,t[33]=d,t[34]=w,t[35]=E,t[36]=O,t[37]=j,t[38]=s,t[39]=b,t[40]=r.activeDocName,t[41]=r.activeProvider,t[42]=r.poolEntries,t[43]=r.serverRestartRecovery,t[44]=r.syncState,t[45]=l,t[46]=M,t[47]=N,t[48]=L,t[49]=R,t[50]=z,t[51]=ee,t[52]=B,t[53]=V,t[54]=P,t[55]=F,t[56]=I,t[57]=te):te=t[57];let ne=te,re;return t[58]!==n||t[59]!==ne?(re=(0,K.jsx)(GN,{value:ne,children:n}),t[58]=n,t[59]=ne,t[60]=re):re=t[60],re}function ZN(e){return e+1}function QN(e){WN(e)}function $N(e){return e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))}function eP(){let e=(0,G.use)(GN);if(!e)throw Error(`useDocumentContext must be used within <DocumentProvider />`);return e}function tP(){let e=(0,q.c)(3),{openDocumentTransition:t,openTargetTransition:n}=eP(),r;return e[0]!==t||e[1]!==n?(r={openDocumentTransition:t,openTargetTransition:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}export{Nd as $,pC as A,Hn as At,Wy as B,Aw as C,Qn as Ct,gw as D,qn as Dt,_w as E,Jn as Et,JS as F,mg as G,gg as H,Bx as I,Ih as J,Tg as K,kx as L,nC as M,Bn as Mt,XS as N,Rn as Nt,pw as O,Kn as Ot,YS as P,Ln as Pt,cf as Q,fx as R,Kw as S,er as St,hw as T,Yn as Tt,pg as U,uy as V,_g as W,Cm as X,kh as Y,Uu as Z,Wj as _,cr as _t,pN as a,tu as at,cT as b,nr as bt,dN as c,xo as ct,lN as d,Ra as dt,Md as et,cN as f,ki as ft,qj as g,fr as gt,AM as h,Mr as ht,mN as i,eu as it,iC as j,Vn as jt,hC as k,Gn as kt,kN as l,Fa as lt,kM as m,Ei as mt,eP as n,Ad as nt,fN as o,Nc as ot,jM as p,J as pt,Kh as q,tP as r,Td as rt,hN as s,So as st,XN as t,Ed as tt,TN as u,Ba as ut,Pj as v,sr as vt,ww as w,Xn as wt,sT as x,tr as xt,BT as y,rr as yt,Yb as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./chunk-DECur_0Z.js";import{n as t,r as n,t as r}from"./compiler-runtime-Y11fyRVL.js";import{Et as i,G as a,Mt as o,Rt as s,T as c,gt as l,n as u,t as d,w as f,zt as p}from"./toggle-group-DUoJt_Lj.js";import{t as m,x as h}from"./button-CXhPNzpp.js";import{N as g,V as _,Z as v,n as y,w as b}from"./DocumentContext-CS3dbEFb.js";import{i as x,n as S,r as C,s as w}from"./config-validation-events-Irg9X5oj.js";import{S as T,x as E}from"./dialog-CJazZw1E.js";import{i as D,n as O,t as k}from"./tooltip-CSwVg9kb.js";var A=h(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),j=e(t(),1),M=r();function N(e,t){if(e.length===0)throw Error(`buildPatch: path must be non-empty`);let[n,...r]=e;return r.length===0?{[String(n)]:t}:{[String(n)]:N(r,t)}}function P(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[String(e)]}return n}function F(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=t?._zod?.def;if(e?.type===`default`){let t=e.defaultValue;return typeof t==`function`?t():t}let n=t?._zod?.def?.innerType;if(n===void 0)return;t=n}}function I(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=t?._zod?.def;if(!e)return;if(e.type===`default`||e.type===`optional`||e.type===`nullable`){t=e.innerType;continue}return e.type}}function ee(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=t?._zod?.def;if(!e)return;if(e.type===`enum`)return e.entries?Object.values(e.entries):void 0;if(e.innerType!==void 0){t=e.innerType;continue}return}}var L=n(),R=[{id:`content`,title:`Content`,description:`Where Open Knowledge looks for documents.`,fields:[{path:[`content`,`dir`],label:`Content directory`,description:`Project-relative path containing your markdown files.`},{path:[`content`,`include`],label:`Include patterns`,description:`Glob patterns selecting which files are content. One per line.`},{path:[`content`,`exclude`],label:`Exclude patterns`,description:`Glob patterns to skip. One per line.`}]},{id:`server`,title:`Server`,description:`Local server bind and behavior.`,fields:[{path:[`server`,`host`],label:`Host`,description:`Bind interface (e.g. localhost, 0.0.0.0).`},{path:[`server`,`openOnAgentEdit`],label:`Open preview on agent edit`,description:`When enabled, an agent write opens the preview tab if not already open.`}]},{id:`github`,title:`GitHub`,description:`OAuth app identity for sign-in. Tokens are stored in your OS keychain, not here.`,fields:[{path:[`github`,`oauthAppClientId`],label:`OAuth App client ID`,description:`Public client ID for the GitHub OAuth app. Defaults to the published Open Knowledge app.`}]},{id:`preview`,title:`Preview`,description:`Where the preview tab points when no local UI is running.`,fields:[{path:[`preview`,`baseUrl`],label:`Preview base URL`,description:`URL of your team’s deployed wiki (project-only).`}]},{id:`mcp`,title:`MCP`,description:`Model Context Protocol agent integration tuning.`,fields:[{path:[`mcp`,`autoStart`],label:`Auto-start server`,description:"When enabled, `ok mcp` spawns `ok start` automatically."},{path:[`mcp`,`tools`,`read_document`,`historyDepth`],label:`read_document history depth`,description:`How many history entries the agent’s read_document tool returns.`},{path:[`mcp`,`tools`,`search`,`maxResults`],label:`search max results`,description:`Cap on results returned by the agent’s search tool.`}]},{id:`appearance`,title:`Appearance`,description:`UI preferences. Editor toggles continue to write localStorage as a cache.`,fields:[{path:[`appearance`,`theme`],label:`Theme`,description:`Light, dark, or follow the OS.`,control:`enum-toggle`},{path:[`appearance`,`editorModeDefault`],label:`Default editor mode`,description:`Which mode new docs open in by default.`,control:`enum-toggle`}]}];function z(e,t){let n=(0,M.c)(4),[r,i]=(0,j.useState)(null),o,s;return n[0]!==e||n[1]!==t?(o=()=>{if(e===null)return;let n=t===`project`?f:c,r=new v,o=new _({url:e,name:n,document:r}),s=a(o,t),l=!0,u=()=>{l&&i(e=>e?.provider===o?{...e,synced:!0,config:s.current()}:e)};o.on(`synced`,u);let d=s.subscribe(e=>{l&&i(t=>t?.provider===o?t&&{...t,config:e}:t)});return i({provider:o,binding:s,config:s.current(),synced:!1}),()=>{l=!1,d(),o.off(`synced`,u),s.dispose(),o.destroy(),r.destroy(),i(e=>e?.provider===o?null:e)}},s=[e,t],n[0]=e,n[1]=t,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,j.useEffect)(o,s),r}function B(e){let t=(0,M.c)(28),{scope:n,onClose:r,onScopeChange:i}=e,{collabUrl:a}=y(),o=z(a,n),[s,c]=(0,j.useState)(null),f=(0,j.useRef)(null),p,h;t[0]===n?(p=t[1],h=t[2]):(p=()=>{let e=S(e=>{if(!(n===`project`&&e.docName===`__config__/project`||n===`user`&&e.docName===`__user__/config.yml`))return;E.error(l(e.error),{duration:8e3});let t=V(e.error);t&&(c(t),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>c(null),600))});return()=>{e(),f.current&&clearTimeout(f.current)}},h=[n],t[0]=n,t[1]=p,t[2]=h),(0,j.useEffect)(p,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,L.jsx)(`h1`,{className:`text-sm font-semibold`,children:`Settings`}),t[3]=g):g=t[3];let _;t[4]===i?_=t[5]:(_=e=>{(e===`project`||e===`user`)&&i(e)},t[4]=i,t[5]=_);let v,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,L.jsx)(u,{value:`project`,className:`text-xs`,children:`This project`}),b=(0,L.jsx)(u,{value:`user`,className:`text-xs`,children:`User`}),t[6]=v,t[7]=b):(v=t[6],b=t[7]);let x;t[8]!==n||t[9]!==_?(x=(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[g,(0,L.jsxs)(d,{type:`single`,value:n,onValueChange:_,"aria-label":`Settings scope`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg`,children:[v,b]})]}),t[8]=n,t[9]=_,t[10]=x):x=t[10];let C;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,L.jsx)(T,{className:`size-4`}),t[11]=C):C=t[11];let w;t[12]===r?w=t[13]:(w=(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(m,{variant:`ghost`,size:`icon`,onClick:r,"aria-label":`Close settings`,className:`text-muted-foreground`,children:C})}),t[12]=r,t[13]=w);let A;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,L.jsx)(O,{children:`Close`}),t[14]=A):A=t[14];let N;t[15]===w?N=t[16]:(N=(0,L.jsxs)(k,{children:[w,A]}),t[15]=w,t[16]=N);let P;t[17]!==N||t[18]!==x?(P=(0,L.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center justify-between border-b px-4`,children:[x,N]}),t[17]=N,t[18]=x,t[19]=P):P=t[19];let F;t[20]!==o||t[21]!==s||t[22]!==n?(F=(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:o===null||!o.synced?(0,L.jsx)(H,{}):(0,L.jsx)(W,{scope:n,binding:o.binding,config:o.config,flashedPath:s})}),t[20]=o,t[21]=s,t[22]=n,t[23]=F):F=t[23];let I;return t[24]!==n||t[25]!==P||t[26]!==F?(I=(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-testid":`settings-pane`,"data-scope":n,children:[P,F]}),t[24]=n,t[25]=P,t[26]=F,t[27]=I):I=t[27],I}function V(e){if(!i(e)||e.code!==`SCHEMA_INVALID`)return null;let t=e.issues[0];return!t||t.path.length===0?null:t.path.map(String).join(`.`)}function H(){let e=(0,M.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsx)(`div`,{className:`space-y-6 p-6`,children:Array.from({length:3}).map(U)}),e[0]=t):t=e[0],t}function U(e,t){return(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(x,{className:`h-5 w-32`}),(0,L.jsx)(x,{className:`h-4 w-64`}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(x,{className:`h-9 w-full`}),(0,L.jsx)(x,{className:`h-9 w-full`})]})]},t)}function W(e){let t=(0,M.c)(8),{scope:n,binding:r,config:i,flashedPath:a}=e,o;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(o=R.map(e=>{let t=e.fields.filter(e=>G(e.path,n));return t.length===0?null:(0,L.jsx)(K,{section:e,children:t.map(e=>(0,L.jsx)(q,{field:e,scope:n,binding:r,config:i,isFlashed:a===e.path.join(`.`)},e.path.join(`.`)))},e.id)}),t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(se,{}),t[5]=s):s=t[5];let c;return t[6]===o?c=t[7]:(c=(0,L.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-8 p-6`,children:[o,s]}),t[6]=o,t[7]=c),c}function G(e,t){let n=o(s,e);if(!n)return!0;let r=p(n);return r?!(r.scope===`project`&&t!==`project`||r.scope===`user`&&t!==`user`):!0}function K(e){let t=(0,M.c)(14),{section:n,children:r}=e,i=`settings-${n.id}-title`,a=`settings-${n.id}-title`,o;t[0]!==n.title||t[1]!==a?(o=(0,L.jsx)(`h2`,{id:a,className:`text-base font-semibold`,children:n.title}),t[0]=n.title,t[1]=a,t[2]=o):o=t[2];let s;t[3]===n.description?s=t[4]:(s=(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[3]=n.description,t[4]=s);let c;t[5]!==o||t[6]!==s?(c=(0,L.jsxs)(`div`,{className:`space-y-1`,children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;t[8]===r?l=t[9]:(l=(0,L.jsx)(`div`,{className:`space-y-4`,children:r}),t[8]=r,t[9]=l);let u;return t[10]!==i||t[11]!==c||t[12]!==l?(u=(0,L.jsxs)(`section`,{"aria-labelledby":i,className:`space-y-3`,children:[c,l]}),t[10]=i,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function q(e){let t=(0,M.c)(55),{field:n,scope:r,binding:i,config:a,isFlashed:c}=e,l,u,d,f,h,g;if(t[0]!==a||t[1]!==n.path){let e=o(s,n.path);g=e?I(e):void 0,u=e?F(e):void 0,l=P(a,n.path),f=e?p(e):void 0,d=e?ee(e):void 0,h=u===void 0?l!=null:!$(l,u),t[0]=a,t[1]=n.path,t[2]=l,t[3]=u,t[4]=d,t[5]=f,t[6]=h,t[7]=g}else l=t[2],u=t[3],d=t[4],f=t[5],h=t[6],g=t[7];let _=h,v;t[8]===n.path?v=t[9]:(v=n.path.join(`-`),t[8]=n.path,t[9]=v);let y=v,b=`${y}-error`,[x,S]=(0,j.useState)(null),C;t[10]!==i||t[11]!==n.path?(C=e=>{let t=N(n.path,e),r=i.patch(t);return r.ok?(S(null),!0):(S(oe(r.error)),!1)},t[10]=i,t[11]=n.path,t[12]=C):C=t[12];let w=C,T;t[13]!==w||t[14]!==u?(T=()=>{w(u===void 0?null:u)},t[13]=w,t[14]=u,t[15]=T):T=t[15];let E=T,R;t[16]===_?R=t[17]:(R=_?(0,L.jsx)(`span`,{"data-modified":`true`,"aria-hidden":`true`,className:`absolute -left-3 top-1 h-5 w-0.5 rounded-full bg-primary`}):null,t[16]=_,t[17]=R);let z=R,B=`relative space-y-1 ${c?`animate-settings-flash`:``}`,V;t[18]===n.path?V=t[19]:(V=n.path.join(`.`),t[18]=n.path,t[19]=V);let H;t[20]!==n.label||t[21]!==y?(H=(0,L.jsx)(`label`,{htmlFor:y,className:`text-sm font-medium`,children:n.label}),t[20]=n.label,t[21]=y,t[22]=H):H=t[22];let U;t[23]!==l||t[24]!==u||t[25]!==n.label||t[26]!==E?(U=u!==void 0||l!==void 0?(0,L.jsxs)(k,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(m,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-muted-foreground opacity-60 hover:opacity-100`,onClick:E,"aria-label":`Reset ${n.label} to default`,children:(0,L.jsx)(A,{className:`size-3.5`})})}),(0,L.jsx)(O,{children:`Reset to default`})]}):null,t[23]=l,t[24]=u,t[25]=n.label,t[26]=E,t[27]=U):U=t[27];let W;t[28]!==H||t[29]!==U?(W=(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[H,U]}),t[28]=H,t[29]=U,t[30]=W):W=t[30];let G;t[31]===n.description?G=t[32]:(G=n.description?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.description}):null,t[31]=n.description,t[32]=G);let K=x?b:void 0,q=f?.scope===`project`&&r!==`project`?`This field can only be set per-project. Switch to the 'This project' tab to edit it.`:f?.scope===`user`&&r!==`user`?`This field can only be set globally. Switch to the 'User' tab to edit it.`:null,J;t[33]!==w||t[34]!==l||t[35]!==d||t[36]!==n||t[37]!==y||t[38]!==K||t[39]!==q||t[40]!==g?(J=(0,L.jsx)(te,{field:n,fieldId:y,errorId:K,typeTag:g,currentValue:l,enumOptions:d,onCommit:w,readonlyReason:q}),t[33]=w,t[34]=l,t[35]=d,t[36]=n,t[37]=y,t[38]=K,t[39]=q,t[40]=g,t[41]=J):J=t[41];let Y;t[42]!==x||t[43]!==b||t[44]!==n.path?(Y=x?(0,L.jsx)(`p`,{id:b,role:`alert`,className:`text-xs text-destructive`,"data-field-error":n.path.join(`.`),children:x}):null,t[42]=x,t[43]=b,t[44]=n.path,t[45]=Y):Y=t[45];let X;return t[46]!==z||t[47]!==r||t[48]!==G||t[49]!==J||t[50]!==Y||t[51]!==V||t[52]!==W||t[53]!==B?(X=(0,L.jsxs)(`div`,{className:B,"data-field":V,"data-scope":r,children:[z,W,G,J,Y]}),t[46]=z,t[47]=r,t[48]=G,t[49]=J,t[50]=Y,t[51]=V,t[52]=W,t[53]=B,t[54]=X):X=t[54],X}function te(e){let t=(0,M.c)(32),{field:n,fieldId:r,errorId:i,typeTag:a,currentValue:o,enumOptions:s,onCommit:c,readonlyReason:l}=e;if(l){let e;return t[0]!==r||t[1]!==l?(e=(0,L.jsx)(`div`,{id:r,role:`note`,className:`rounded border border-dashed border-muted px-3 py-2 text-xs text-muted-foreground`,children:l}),t[0]=r,t[1]=l,t[2]=e):e=t[2],e}if(a===`boolean`){let e=!!o,n;return t[3]!==i||t[4]!==r||t[5]!==c||t[6]!==e?(n=(0,L.jsx)(X,{fieldId:r,errorId:i,value:e,onCommit:c}),t[3]=i,t[4]=r,t[5]=c,t[6]=e,t[7]=n):n=t[7],n}if(a===`enum`&&s&&s.length>0&&(n.control===`enum-toggle`||s.length<=4)){let e=typeof o==`string`?o:``,a;return t[8]!==s||t[9]!==i||t[10]!==n.label||t[11]!==r||t[12]!==c||t[13]!==e?(a=(0,L.jsx)(ne,{fieldId:r,errorId:i,ariaLabel:n.label,options:s,value:e,onCommit:c}),t[8]=s,t[9]=i,t[10]=n.label,t[11]=r,t[12]=c,t[13]=e,t[14]=a):a=t[14],a}if(a===`number`||a===`int`){let e=typeof o==`number`?o:0,n;return t[15]!==i||t[16]!==r||t[17]!==c||t[18]!==e?(n=(0,L.jsx)(Y,{fieldId:r,errorId:i,value:e,onCommit:c}),t[15]=i,t[16]=r,t[17]=c,t[18]=e,t[19]=n):n=t[19],n}if(a===`array`){let e;t[20]===o?e=t[21]:(e=Array.isArray(o)?o:[],t[20]=o,t[21]=e);let n;return t[22]!==i||t[23]!==r||t[24]!==c||t[25]!==e?(n=(0,L.jsx)(re,{fieldId:r,errorId:i,value:e,onCommit:c}),t[22]=i,t[23]=r,t[24]=c,t[25]=e,t[26]=n):n=t[26],n}let u=typeof o==`string`?o:``,d;return t[27]!==i||t[28]!==r||t[29]!==c||t[30]!==u?(d=(0,L.jsx)(J,{fieldId:r,errorId:i,value:u,onCommit:c}),t[27]=i,t[28]=r,t[29]=c,t[30]=u,t[31]=d):d=t[31],d}function J(e){let t=(0,M.c)(22),{fieldId:n,errorId:r,value:i,onCommit:a}=e,[o,s]=(0,j.useState)(i),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(i),d,f;t[0]!==o||t[1]!==i?(d=()=>{o===u.current&&(s(i),u.current=i)},f=[i,o],t[0]=o,t[1]=i,t[2]=d,t[3]=f):(d=t[2],f=t[3]),(0,j.useEffect)(d,f);let p;t[4]!==a||t[5]!==o?(p=()=>{o!==u.current&&a(o)&&(u.current=o,Q(l))},t[4]=a,t[5]=o,t[6]=p):p=t[6];let m=p,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>s(e.target.value),t[7]=h):h=t[7];let _;t[8]===m?_=t[9]:(_=e=>{e.key===`Enter`&&(e.preventDefault(),m())},t[8]=m,t[9]=_);let v=r?!0:void 0,y;t[10]!==m||t[11]!==r||t[12]!==n||t[13]!==o||t[14]!==_||t[15]!==v?(y=(0,L.jsx)(g,{id:n,value:o,onChange:h,onBlur:m,onKeyDown:_,"aria-describedby":r,"aria-invalid":v,className:`h-8 text-sm`}),t[10]=m,t[11]=r,t[12]=n,t[13]=o,t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===c?b=t[18]:(b=(0,L.jsx)(Z,{visible:c}),t[17]=c,t[18]=b);let x;return t[19]!==y||t[20]!==b?(x=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,b]}),t[19]=y,t[20]=b,t[21]=x):x=t[21],x}function Y(e){let t=(0,M.c)(22),{fieldId:n,errorId:r,value:i,onCommit:a}=e,[o,s]=(0,j.useState)(String(i)),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(String(i)),d,f;t[0]!==o||t[1]!==i?(d=()=>{o===u.current&&(s(String(i)),u.current=String(i))},f=[i,o],t[0]=o,t[1]=i,t[2]=d,t[3]=f):(d=t[2],f=t[3]),(0,j.useEffect)(d,f);let p;t[4]!==a||t[5]!==o?(p=()=>{if(o===u.current)return;let e=Number(o);if(!Number.isFinite(e)){a(o);return}a(e)&&(u.current=o,Q(l))},t[4]=a,t[5]=o,t[6]=p):p=t[6];let m=p,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>s(e.target.value),t[7]=h):h=t[7];let _;t[8]===m?_=t[9]:(_=e=>{e.key===`Enter`&&(e.preventDefault(),m())},t[8]=m,t[9]=_);let v=r?!0:void 0,y;t[10]!==m||t[11]!==r||t[12]!==n||t[13]!==o||t[14]!==_||t[15]!==v?(y=(0,L.jsx)(g,{id:n,type:`number`,value:o,onChange:h,onBlur:m,onKeyDown:_,"aria-describedby":r,"aria-invalid":v,className:`h-8 w-28 text-sm`}),t[10]=m,t[11]=r,t[12]=n,t[13]=o,t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===c?b=t[18]:(b=(0,L.jsx)(Z,{visible:c}),t[17]=c,t[18]=b);let x;return t[19]!==y||t[20]!==b?(x=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,b]}),t[19]=y,t[20]=b,t[21]=x):x=t[21],x}function X(e){let t=(0,M.c)(12),{fieldId:n,errorId:r,value:i,onCommit:a}=e,[o,s]=(0,j.useState)(!1),c;t[0]===a?c=t[1]:(c=e=>{a(e)&&Q(s)},t[0]=a,t[1]=c);let l;t[2]!==r||t[3]!==n||t[4]!==c||t[5]!==i?(l=(0,L.jsx)(b,{id:n,checked:i,"aria-describedby":r,onCheckedChange:c}),t[2]=r,t[3]=n,t[4]=c,t[5]=i,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=(0,L.jsx)(Z,{visible:o}),t[7]=o,t[8]=u);let d;return t[9]!==l||t[10]!==u?(d=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11],d}function ne(e){let t=(0,M.c)(18),{fieldId:n,errorId:r,ariaLabel:i,options:a,value:o,onCommit:s}=e,[c,l]=(0,j.useState)(!1),f;t[0]===s?f=t[1]:(f=e=>{e&&s(e)&&Q(l)},t[0]=s,t[1]=f);let p;if(t[2]!==n||t[3]!==a){let e;t[5]===n?e=t[6]:(e=(e,t)=>(0,L.jsx)(u,{value:e,id:t===0?n:void 0,className:`text-xs capitalize`,children:e},e),t[5]=n,t[6]=e),p=a.map(e),t[2]=n,t[3]=a,t[4]=p}else p=t[4];let m;t[7]!==i||t[8]!==f||t[9]!==p||t[10]!==o?(m=(0,L.jsx)(d,{type:`single`,value:o,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg`,"aria-label":i,onValueChange:f,children:p}),t[7]=i,t[8]=f,t[9]=p,t[10]=o,t[11]=m):m=t[11];let h;t[12]===c?h=t[13]:(h=(0,L.jsx)(Z,{visible:c}),t[12]=c,t[13]=h);let g;return t[14]!==r||t[15]!==m||t[16]!==h?(g=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,"aria-describedby":r,children:[m,h]}),t[14]=r,t[15]=m,t[16]=h,t[17]=g):g=t[17],g}function re(e){let t=(0,M.c)(24),{fieldId:n,errorId:r,value:i,onCommit:a}=e,o;t[0]===i?o=t[1]:(o=i.join(`
|
|
1
|
+
import{r as e}from"./chunk-DECur_0Z.js";import{n as t,r as n,t as r}from"./compiler-runtime-Y11fyRVL.js";import{Et as i,G as a,Mt as o,Rt as s,T as c,gt as l,n as u,t as d,w as f,zt as p}from"./toggle-group-DUoJt_Lj.js";import{t as m,x as h}from"./button-CXhPNzpp.js";import{N as g,V as _,Z as v,n as y,w as b}from"./DocumentContext-GbmGcVzS.js";import{i as x,n as S,r as C,s as w}from"./config-validation-events-5erczoJ8.js";import{S as T,x as E}from"./dialog-CJazZw1E.js";import{i as D,n as O,t as k}from"./tooltip-CSwVg9kb.js";var A=h(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),j=e(t(),1),M=r();function N(e,t){if(e.length===0)throw Error(`buildPatch: path must be non-empty`);let[n,...r]=e;return r.length===0?{[String(n)]:t}:{[String(n)]:N(r,t)}}function P(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[String(e)]}return n}function F(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=t?._zod?.def;if(e?.type===`default`){let t=e.defaultValue;return typeof t==`function`?t():t}let n=t?._zod?.def?.innerType;if(n===void 0)return;t=n}}function I(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=t?._zod?.def;if(!e)return;if(e.type===`default`||e.type===`optional`||e.type===`nullable`){t=e.innerType;continue}return e.type}}function ee(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=t?._zod?.def;if(!e)return;if(e.type===`enum`)return e.entries?Object.values(e.entries):void 0;if(e.innerType!==void 0){t=e.innerType;continue}return}}var L=n(),R=[{id:`content`,title:`Content`,description:`Where Open Knowledge looks for documents.`,fields:[{path:[`content`,`dir`],label:`Content directory`,description:`Project-relative path containing your markdown files.`},{path:[`content`,`include`],label:`Include patterns`,description:`Glob patterns selecting which files are content. One per line.`},{path:[`content`,`exclude`],label:`Exclude patterns`,description:`Glob patterns to skip. One per line.`}]},{id:`server`,title:`Server`,description:`Local server bind and behavior.`,fields:[{path:[`server`,`host`],label:`Host`,description:`Bind interface (e.g. localhost, 0.0.0.0).`},{path:[`server`,`openOnAgentEdit`],label:`Open preview on agent edit`,description:`When enabled, an agent write opens the preview tab if not already open.`}]},{id:`github`,title:`GitHub`,description:`OAuth app identity for sign-in. Tokens are stored in your OS keychain, not here.`,fields:[{path:[`github`,`oauthAppClientId`],label:`OAuth App client ID`,description:`Public client ID for the GitHub OAuth app. Defaults to the published Open Knowledge app.`}]},{id:`preview`,title:`Preview`,description:`Where the preview tab points when no local UI is running.`,fields:[{path:[`preview`,`baseUrl`],label:`Preview base URL`,description:`URL of your team’s deployed wiki (project-only).`}]},{id:`mcp`,title:`MCP`,description:`Model Context Protocol agent integration tuning.`,fields:[{path:[`mcp`,`autoStart`],label:`Auto-start server`,description:"When enabled, `ok mcp` spawns `ok start` automatically."},{path:[`mcp`,`tools`,`read_document`,`historyDepth`],label:`read_document history depth`,description:`How many history entries the agent’s read_document tool returns.`},{path:[`mcp`,`tools`,`search`,`maxResults`],label:`search max results`,description:`Cap on results returned by the agent’s search tool.`}]},{id:`appearance`,title:`Appearance`,description:`UI preferences. Editor toggles continue to write localStorage as a cache.`,fields:[{path:[`appearance`,`theme`],label:`Theme`,description:`Light, dark, or follow the OS.`,control:`enum-toggle`},{path:[`appearance`,`editorModeDefault`],label:`Default editor mode`,description:`Which mode new docs open in by default.`,control:`enum-toggle`}]}];function z(e,t){let n=(0,M.c)(4),[r,i]=(0,j.useState)(null),o,s;return n[0]!==e||n[1]!==t?(o=()=>{if(e===null)return;let n=t===`project`?f:c,r=new v,o=new _({url:e,name:n,document:r}),s=a(o,t),l=!0,u=()=>{l&&i(e=>e?.provider===o?{...e,synced:!0,config:s.current()}:e)};o.on(`synced`,u);let d=s.subscribe(e=>{l&&i(t=>t?.provider===o?t&&{...t,config:e}:t)});return i({provider:o,binding:s,config:s.current(),synced:!1}),()=>{l=!1,d(),o.off(`synced`,u),s.dispose(),o.destroy(),r.destroy(),i(e=>e?.provider===o?null:e)}},s=[e,t],n[0]=e,n[1]=t,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,j.useEffect)(o,s),r}function B(e){let t=(0,M.c)(28),{scope:n,onClose:r,onScopeChange:i}=e,{collabUrl:a}=y(),o=z(a,n),[s,c]=(0,j.useState)(null),f=(0,j.useRef)(null),p,h;t[0]===n?(p=t[1],h=t[2]):(p=()=>{let e=S(e=>{if(!(n===`project`&&e.docName===`__config__/project`||n===`user`&&e.docName===`__user__/config.yml`))return;E.error(l(e.error),{duration:8e3});let t=V(e.error);t&&(c(t),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>c(null),600))});return()=>{e(),f.current&&clearTimeout(f.current)}},h=[n],t[0]=n,t[1]=p,t[2]=h),(0,j.useEffect)(p,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,L.jsx)(`h1`,{className:`text-sm font-semibold`,children:`Settings`}),t[3]=g):g=t[3];let _;t[4]===i?_=t[5]:(_=e=>{(e===`project`||e===`user`)&&i(e)},t[4]=i,t[5]=_);let v,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,L.jsx)(u,{value:`project`,className:`text-xs`,children:`This project`}),b=(0,L.jsx)(u,{value:`user`,className:`text-xs`,children:`User`}),t[6]=v,t[7]=b):(v=t[6],b=t[7]);let x;t[8]!==n||t[9]!==_?(x=(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[g,(0,L.jsxs)(d,{type:`single`,value:n,onValueChange:_,"aria-label":`Settings scope`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg`,children:[v,b]})]}),t[8]=n,t[9]=_,t[10]=x):x=t[10];let C;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,L.jsx)(T,{className:`size-4`}),t[11]=C):C=t[11];let w;t[12]===r?w=t[13]:(w=(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(m,{variant:`ghost`,size:`icon`,onClick:r,"aria-label":`Close settings`,className:`text-muted-foreground`,children:C})}),t[12]=r,t[13]=w);let A;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,L.jsx)(O,{children:`Close`}),t[14]=A):A=t[14];let N;t[15]===w?N=t[16]:(N=(0,L.jsxs)(k,{children:[w,A]}),t[15]=w,t[16]=N);let P;t[17]!==N||t[18]!==x?(P=(0,L.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center justify-between border-b px-4`,children:[x,N]}),t[17]=N,t[18]=x,t[19]=P):P=t[19];let F;t[20]!==o||t[21]!==s||t[22]!==n?(F=(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:o===null||!o.synced?(0,L.jsx)(H,{}):(0,L.jsx)(W,{scope:n,binding:o.binding,config:o.config,flashedPath:s})}),t[20]=o,t[21]=s,t[22]=n,t[23]=F):F=t[23];let I;return t[24]!==n||t[25]!==P||t[26]!==F?(I=(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-testid":`settings-pane`,"data-scope":n,children:[P,F]}),t[24]=n,t[25]=P,t[26]=F,t[27]=I):I=t[27],I}function V(e){if(!i(e)||e.code!==`SCHEMA_INVALID`)return null;let t=e.issues[0];return!t||t.path.length===0?null:t.path.map(String).join(`.`)}function H(){let e=(0,M.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsx)(`div`,{className:`space-y-6 p-6`,children:Array.from({length:3}).map(U)}),e[0]=t):t=e[0],t}function U(e,t){return(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(x,{className:`h-5 w-32`}),(0,L.jsx)(x,{className:`h-4 w-64`}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(x,{className:`h-9 w-full`}),(0,L.jsx)(x,{className:`h-9 w-full`})]})]},t)}function W(e){let t=(0,M.c)(8),{scope:n,binding:r,config:i,flashedPath:a}=e,o;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(o=R.map(e=>{let t=e.fields.filter(e=>G(e.path,n));return t.length===0?null:(0,L.jsx)(K,{section:e,children:t.map(e=>(0,L.jsx)(q,{field:e,scope:n,binding:r,config:i,isFlashed:a===e.path.join(`.`)},e.path.join(`.`)))},e.id)}),t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,L.jsx)(se,{}),t[5]=s):s=t[5];let c;return t[6]===o?c=t[7]:(c=(0,L.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-8 p-6`,children:[o,s]}),t[6]=o,t[7]=c),c}function G(e,t){let n=o(s,e);if(!n)return!0;let r=p(n);return r?!(r.scope===`project`&&t!==`project`||r.scope===`user`&&t!==`user`):!0}function K(e){let t=(0,M.c)(14),{section:n,children:r}=e,i=`settings-${n.id}-title`,a=`settings-${n.id}-title`,o;t[0]!==n.title||t[1]!==a?(o=(0,L.jsx)(`h2`,{id:a,className:`text-base font-semibold`,children:n.title}),t[0]=n.title,t[1]=a,t[2]=o):o=t[2];let s;t[3]===n.description?s=t[4]:(s=(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[3]=n.description,t[4]=s);let c;t[5]!==o||t[6]!==s?(c=(0,L.jsxs)(`div`,{className:`space-y-1`,children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;t[8]===r?l=t[9]:(l=(0,L.jsx)(`div`,{className:`space-y-4`,children:r}),t[8]=r,t[9]=l);let u;return t[10]!==i||t[11]!==c||t[12]!==l?(u=(0,L.jsxs)(`section`,{"aria-labelledby":i,className:`space-y-3`,children:[c,l]}),t[10]=i,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function q(e){let t=(0,M.c)(55),{field:n,scope:r,binding:i,config:a,isFlashed:c}=e,l,u,d,f,h,g;if(t[0]!==a||t[1]!==n.path){let e=o(s,n.path);g=e?I(e):void 0,u=e?F(e):void 0,l=P(a,n.path),f=e?p(e):void 0,d=e?ee(e):void 0,h=u===void 0?l!=null:!$(l,u),t[0]=a,t[1]=n.path,t[2]=l,t[3]=u,t[4]=d,t[5]=f,t[6]=h,t[7]=g}else l=t[2],u=t[3],d=t[4],f=t[5],h=t[6],g=t[7];let _=h,v;t[8]===n.path?v=t[9]:(v=n.path.join(`-`),t[8]=n.path,t[9]=v);let y=v,b=`${y}-error`,[x,S]=(0,j.useState)(null),C;t[10]!==i||t[11]!==n.path?(C=e=>{let t=N(n.path,e),r=i.patch(t);return r.ok?(S(null),!0):(S(oe(r.error)),!1)},t[10]=i,t[11]=n.path,t[12]=C):C=t[12];let w=C,T;t[13]!==w||t[14]!==u?(T=()=>{w(u===void 0?null:u)},t[13]=w,t[14]=u,t[15]=T):T=t[15];let E=T,R;t[16]===_?R=t[17]:(R=_?(0,L.jsx)(`span`,{"data-modified":`true`,"aria-hidden":`true`,className:`absolute -left-3 top-1 h-5 w-0.5 rounded-full bg-primary`}):null,t[16]=_,t[17]=R);let z=R,B=`relative space-y-1 ${c?`animate-settings-flash`:``}`,V;t[18]===n.path?V=t[19]:(V=n.path.join(`.`),t[18]=n.path,t[19]=V);let H;t[20]!==n.label||t[21]!==y?(H=(0,L.jsx)(`label`,{htmlFor:y,className:`text-sm font-medium`,children:n.label}),t[20]=n.label,t[21]=y,t[22]=H):H=t[22];let U;t[23]!==l||t[24]!==u||t[25]!==n.label||t[26]!==E?(U=u!==void 0||l!==void 0?(0,L.jsxs)(k,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(m,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-muted-foreground opacity-60 hover:opacity-100`,onClick:E,"aria-label":`Reset ${n.label} to default`,children:(0,L.jsx)(A,{className:`size-3.5`})})}),(0,L.jsx)(O,{children:`Reset to default`})]}):null,t[23]=l,t[24]=u,t[25]=n.label,t[26]=E,t[27]=U):U=t[27];let W;t[28]!==H||t[29]!==U?(W=(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[H,U]}),t[28]=H,t[29]=U,t[30]=W):W=t[30];let G;t[31]===n.description?G=t[32]:(G=n.description?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.description}):null,t[31]=n.description,t[32]=G);let K=x?b:void 0,q=f?.scope===`project`&&r!==`project`?`This field can only be set per-project. Switch to the 'This project' tab to edit it.`:f?.scope===`user`&&r!==`user`?`This field can only be set globally. Switch to the 'User' tab to edit it.`:null,J;t[33]!==w||t[34]!==l||t[35]!==d||t[36]!==n||t[37]!==y||t[38]!==K||t[39]!==q||t[40]!==g?(J=(0,L.jsx)(te,{field:n,fieldId:y,errorId:K,typeTag:g,currentValue:l,enumOptions:d,onCommit:w,readonlyReason:q}),t[33]=w,t[34]=l,t[35]=d,t[36]=n,t[37]=y,t[38]=K,t[39]=q,t[40]=g,t[41]=J):J=t[41];let Y;t[42]!==x||t[43]!==b||t[44]!==n.path?(Y=x?(0,L.jsx)(`p`,{id:b,role:`alert`,className:`text-xs text-destructive`,"data-field-error":n.path.join(`.`),children:x}):null,t[42]=x,t[43]=b,t[44]=n.path,t[45]=Y):Y=t[45];let X;return t[46]!==z||t[47]!==r||t[48]!==G||t[49]!==J||t[50]!==Y||t[51]!==V||t[52]!==W||t[53]!==B?(X=(0,L.jsxs)(`div`,{className:B,"data-field":V,"data-scope":r,children:[z,W,G,J,Y]}),t[46]=z,t[47]=r,t[48]=G,t[49]=J,t[50]=Y,t[51]=V,t[52]=W,t[53]=B,t[54]=X):X=t[54],X}function te(e){let t=(0,M.c)(32),{field:n,fieldId:r,errorId:i,typeTag:a,currentValue:o,enumOptions:s,onCommit:c,readonlyReason:l}=e;if(l){let e;return t[0]!==r||t[1]!==l?(e=(0,L.jsx)(`div`,{id:r,role:`note`,className:`rounded border border-dashed border-muted px-3 py-2 text-xs text-muted-foreground`,children:l}),t[0]=r,t[1]=l,t[2]=e):e=t[2],e}if(a===`boolean`){let e=!!o,n;return t[3]!==i||t[4]!==r||t[5]!==c||t[6]!==e?(n=(0,L.jsx)(X,{fieldId:r,errorId:i,value:e,onCommit:c}),t[3]=i,t[4]=r,t[5]=c,t[6]=e,t[7]=n):n=t[7],n}if(a===`enum`&&s&&s.length>0&&(n.control===`enum-toggle`||s.length<=4)){let e=typeof o==`string`?o:``,a;return t[8]!==s||t[9]!==i||t[10]!==n.label||t[11]!==r||t[12]!==c||t[13]!==e?(a=(0,L.jsx)(ne,{fieldId:r,errorId:i,ariaLabel:n.label,options:s,value:e,onCommit:c}),t[8]=s,t[9]=i,t[10]=n.label,t[11]=r,t[12]=c,t[13]=e,t[14]=a):a=t[14],a}if(a===`number`||a===`int`){let e=typeof o==`number`?o:0,n;return t[15]!==i||t[16]!==r||t[17]!==c||t[18]!==e?(n=(0,L.jsx)(Y,{fieldId:r,errorId:i,value:e,onCommit:c}),t[15]=i,t[16]=r,t[17]=c,t[18]=e,t[19]=n):n=t[19],n}if(a===`array`){let e;t[20]===o?e=t[21]:(e=Array.isArray(o)?o:[],t[20]=o,t[21]=e);let n;return t[22]!==i||t[23]!==r||t[24]!==c||t[25]!==e?(n=(0,L.jsx)(re,{fieldId:r,errorId:i,value:e,onCommit:c}),t[22]=i,t[23]=r,t[24]=c,t[25]=e,t[26]=n):n=t[26],n}let u=typeof o==`string`?o:``,d;return t[27]!==i||t[28]!==r||t[29]!==c||t[30]!==u?(d=(0,L.jsx)(J,{fieldId:r,errorId:i,value:u,onCommit:c}),t[27]=i,t[28]=r,t[29]=c,t[30]=u,t[31]=d):d=t[31],d}function J(e){let t=(0,M.c)(22),{fieldId:n,errorId:r,value:i,onCommit:a}=e,[o,s]=(0,j.useState)(i),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(i),d,f;t[0]!==o||t[1]!==i?(d=()=>{o===u.current&&(s(i),u.current=i)},f=[i,o],t[0]=o,t[1]=i,t[2]=d,t[3]=f):(d=t[2],f=t[3]),(0,j.useEffect)(d,f);let p;t[4]!==a||t[5]!==o?(p=()=>{o!==u.current&&a(o)&&(u.current=o,Q(l))},t[4]=a,t[5]=o,t[6]=p):p=t[6];let m=p,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>s(e.target.value),t[7]=h):h=t[7];let _;t[8]===m?_=t[9]:(_=e=>{e.key===`Enter`&&(e.preventDefault(),m())},t[8]=m,t[9]=_);let v=r?!0:void 0,y;t[10]!==m||t[11]!==r||t[12]!==n||t[13]!==o||t[14]!==_||t[15]!==v?(y=(0,L.jsx)(g,{id:n,value:o,onChange:h,onBlur:m,onKeyDown:_,"aria-describedby":r,"aria-invalid":v,className:`h-8 text-sm`}),t[10]=m,t[11]=r,t[12]=n,t[13]=o,t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===c?b=t[18]:(b=(0,L.jsx)(Z,{visible:c}),t[17]=c,t[18]=b);let x;return t[19]!==y||t[20]!==b?(x=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,b]}),t[19]=y,t[20]=b,t[21]=x):x=t[21],x}function Y(e){let t=(0,M.c)(22),{fieldId:n,errorId:r,value:i,onCommit:a}=e,[o,s]=(0,j.useState)(String(i)),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(String(i)),d,f;t[0]!==o||t[1]!==i?(d=()=>{o===u.current&&(s(String(i)),u.current=String(i))},f=[i,o],t[0]=o,t[1]=i,t[2]=d,t[3]=f):(d=t[2],f=t[3]),(0,j.useEffect)(d,f);let p;t[4]!==a||t[5]!==o?(p=()=>{if(o===u.current)return;let e=Number(o);if(!Number.isFinite(e)){a(o);return}a(e)&&(u.current=o,Q(l))},t[4]=a,t[5]=o,t[6]=p):p=t[6];let m=p,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>s(e.target.value),t[7]=h):h=t[7];let _;t[8]===m?_=t[9]:(_=e=>{e.key===`Enter`&&(e.preventDefault(),m())},t[8]=m,t[9]=_);let v=r?!0:void 0,y;t[10]!==m||t[11]!==r||t[12]!==n||t[13]!==o||t[14]!==_||t[15]!==v?(y=(0,L.jsx)(g,{id:n,type:`number`,value:o,onChange:h,onBlur:m,onKeyDown:_,"aria-describedby":r,"aria-invalid":v,className:`h-8 w-28 text-sm`}),t[10]=m,t[11]=r,t[12]=n,t[13]=o,t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===c?b=t[18]:(b=(0,L.jsx)(Z,{visible:c}),t[17]=c,t[18]=b);let x;return t[19]!==y||t[20]!==b?(x=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,b]}),t[19]=y,t[20]=b,t[21]=x):x=t[21],x}function X(e){let t=(0,M.c)(12),{fieldId:n,errorId:r,value:i,onCommit:a}=e,[o,s]=(0,j.useState)(!1),c;t[0]===a?c=t[1]:(c=e=>{a(e)&&Q(s)},t[0]=a,t[1]=c);let l;t[2]!==r||t[3]!==n||t[4]!==c||t[5]!==i?(l=(0,L.jsx)(b,{id:n,checked:i,"aria-describedby":r,onCheckedChange:c}),t[2]=r,t[3]=n,t[4]=c,t[5]=i,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=(0,L.jsx)(Z,{visible:o}),t[7]=o,t[8]=u);let d;return t[9]!==l||t[10]!==u?(d=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11],d}function ne(e){let t=(0,M.c)(18),{fieldId:n,errorId:r,ariaLabel:i,options:a,value:o,onCommit:s}=e,[c,l]=(0,j.useState)(!1),f;t[0]===s?f=t[1]:(f=e=>{e&&s(e)&&Q(l)},t[0]=s,t[1]=f);let p;if(t[2]!==n||t[3]!==a){let e;t[5]===n?e=t[6]:(e=(e,t)=>(0,L.jsx)(u,{value:e,id:t===0?n:void 0,className:`text-xs capitalize`,children:e},e),t[5]=n,t[6]=e),p=a.map(e),t[2]=n,t[3]=a,t[4]=p}else p=t[4];let m;t[7]!==i||t[8]!==f||t[9]!==p||t[10]!==o?(m=(0,L.jsx)(d,{type:`single`,value:o,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg`,"aria-label":i,onValueChange:f,children:p}),t[7]=i,t[8]=f,t[9]=p,t[10]=o,t[11]=m):m=t[11];let h;t[12]===c?h=t[13]:(h=(0,L.jsx)(Z,{visible:c}),t[12]=c,t[13]=h);let g;return t[14]!==r||t[15]!==m||t[16]!==h?(g=(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,"aria-describedby":r,children:[m,h]}),t[14]=r,t[15]=m,t[16]=h,t[17]=g):g=t[17],g}function re(e){let t=(0,M.c)(24),{fieldId:n,errorId:r,value:i,onCommit:a}=e,o;t[0]===i?o=t[1]:(o=i.join(`
|
|
2
2
|
`),t[0]=i,t[1]=o);let s=o,[c,l]=(0,j.useState)(s),[u,d]=(0,j.useState)(!1),f=(0,j.useRef)(s),p,m;t[2]!==c||t[3]!==i?(p=()=>{let e=i.join(`
|
|
3
3
|
`);c===f.current&&(l(e),f.current=e)},m=[i,c],t[2]=c,t[3]=i,t[4]=p,t[5]=m):(p=t[4],m=t[5]),(0,j.useEffect)(p,m);let h;t[6]!==a||t[7]!==c?(h=()=>{c!==f.current&&a(c.split(`
|
|
4
4
|
`).map(ae).filter(ie))&&(f.current=c,Q(d))},t[6]=a,t[7]=c,t[8]=h):h=t[8];let g=h,_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>l(e.target.value),t[9]=_):_=t[9];let v;t[10]===c?v=t[11]:(v=c.split(`
|