@inkeep/open-knowledge 0.9.2-beta.8 → 0.10.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/LICENSE +674 -0
  2. package/dist/assets/skills/discovery/SKILL.md +1 -1
  3. package/dist/assets/skills/project/SKILL.md +1 -1
  4. package/dist/cli.mjs +14 -13
  5. package/dist/constants-DJXMedPd.mjs +2 -0
  6. package/dist/{dist-sld-_d9T.mjs → dist-CILctbXr.mjs} +73 -70
  7. package/dist/{dist-Bj_IaFF5.mjs → dist-jwEG_6T7.mjs} +1 -1
  8. package/dist/{gh-detect-BveVRAue.mjs → gh-detect-DCIXLWuz.mjs} +2 -2
  9. package/dist/index.mjs +1 -1
  10. package/dist/{init-BjjtQpJ4.mjs → init-CsAeoxGW.mjs} +6 -6
  11. package/dist/init-jyYK5JFI.mjs +1 -0
  12. package/dist/{loader-BSyhsuGY.mjs → loader-DthGvoM_.mjs} +2 -2
  13. package/dist/loader-Hhqjtdao.mjs +1 -0
  14. package/dist/{preview-C6kOnHJr.mjs → preview-BGlZsxSQ.mjs} +2 -2
  15. package/dist/preview-CiM6px2S.mjs +1 -0
  16. package/dist/public/assets/{ActivityModeContent-ryZpdhrg.js → ActivityModeContent-CZ3f6pXo.js} +1 -1
  17. package/dist/public/assets/{DocumentContext-B0qDv4j7.js → DocumentContext-lPnCPfnx.js} +2 -2
  18. package/dist/public/assets/{GraphPanel-DUQL1b5J.js → GraphPanel-OqhIPCR-.js} +1 -1
  19. package/dist/public/assets/{SettingsDialogBody-D3PLgmQr.js → SettingsDialogBody-lpcuh5h-.js} +1 -1
  20. package/dist/public/assets/{SourceEditor-DOh6wSxy.js → SourceEditor-CA6VzD8t.js} +1 -1
  21. package/dist/public/assets/{config-validation-events-S5hCYFuT.js → config-validation-events-CVUdGMqF.js} +1 -1
  22. package/dist/public/assets/{index-C1LyLfKJ.js → index-D0Rrcm7t.js} +5 -5
  23. package/dist/public/assets/{keyboard-shortcuts-xl_TcQeg.js → keyboard-shortcuts-AT0jBk2u.js} +1 -1
  24. package/dist/public/assets/{prop-types-DgfF561f.js → prop-types-N7Ts5qWw.js} +110 -110
  25. package/dist/public/assets/{target-navigation-intent-D3XZeIgO.js → target-navigation-intent-DQhKf-lZ.js} +1 -1
  26. package/dist/public/assets/{typing-burst-detector-D53pUunD.js → typing-burst-detector-Bnt3kvRi.js} +1 -1
  27. package/dist/public/index.html +7 -7
  28. package/dist/{repair-launch-json-CBHiWTWu.mjs → repair-launch-json-NFu_e3_F.mjs} +2 -2
  29. package/dist/{repair-mcp-configs-s94bDnZZ.mjs → repair-mcp-configs-Zi_XxyGY.mjs} +2 -2
  30. package/dist/{repair-skills-BP58ginR.mjs → repair-skills-8cPy8M95.mjs} +2 -2
  31. package/dist/repair-skills-CTGGxNTm.mjs +1 -0
  32. package/dist/{server-lock-BpjJj3OD-2pOoEhSP.mjs → server-lock-BpjJj3OD-DBIqFE7p.mjs} +3 -3
  33. package/dist/server-lock-CyhBidkz-DbELIlyl.mjs +1 -0
  34. package/dist/{src-B1QW6YWQ.mjs → src-Djxmxob_.mjs} +2 -2
  35. package/dist/start-BXQ2VEmg.mjs +1 -0
  36. package/dist/{start-7bpluiOA.mjs → start-OWDBeL4F.mjs} +2 -2
  37. package/dist/{write-project-skill-ppRYJ9T2.mjs → write-project-skill-Da4v8WUu.mjs} +2 -2
  38. package/package.json +4 -2
  39. package/dist/constants-Dz5iTLUD.mjs +0 -2
  40. package/dist/init-CxAAKK9q.mjs +0 -1
  41. package/dist/loader-D6ZQW0bM.mjs +0 -1
  42. package/dist/preview-DRATXrPN.mjs +0 -1
  43. package/dist/repair-skills-B9lFVB-G.mjs +0 -1
  44. package/dist/server-lock-CyhBidkz-Blwoi-6-.mjs +0 -1
  45. package/dist/start-BjSIXm8g.mjs +0 -1
@@ -386,7 +386,7 @@ $2`).split(`
386
386
  });
387
387
  <\/script>
388
388
  </div>`}];function PG(e){return["```html preview",e.html,"```"].join(`
389
- `)}const FG=[{name:`--chart-1`,light:`oklch(0.62 0.19 259)`,dark:`oklch(0.72 0.14 259)`},{name:`--chart-2`,light:`oklch(0.58 0.14 145)`,dark:`oklch(0.73 0.13 145)`},{name:`--chart-3`,light:`oklch(0.62 0.15 70)`,dark:`oklch(0.77 0.14 70)`},{name:`--chart-4`,light:`oklch(0.55 0.18 290)`,dark:`oklch(0.72 0.16 290)`},{name:`--chart-5`,light:`oklch(0.58 0.21 25)`,dark:`oklch(0.72 0.2 25)`},{name:`--primary`,light:`oklch(0.6321 0.1983 259.59)`,dark:`#69a3ff`},{name:`--primary-foreground`,light:`oklch(0.985 0 0)`,dark:`oklch(0.205 0 0)`},{name:`--foreground`,light:`oklch(0.145 0 0)`,dark:`oklch(0.985 0 0)`},{name:`--background`,light:`oklch(1 0 0)`,dark:`oklch(0.145 0 0)`},{name:`--card`,light:`oklch(1 0 0)`,dark:`oklch(0.205 0 0)`},{name:`--card-foreground`,light:`oklch(0.145 0 0)`,dark:`oklch(0.985 0 0)`},{name:`--muted-foreground`,light:`oklch(0.556 0 0)`,dark:`oklch(0.708 0 0)`},{name:`--border`,light:`oklch(0.922 0 0)`,dark:`oklch(1 0 0 / 10%)`},{name:`--destructive`,light:`oklch(0.577 0.245 27.325)`,dark:`oklch(0.704 0.191 22.216)`},{name:`--radius`,light:`0.625rem`,dark:`0.625rem`}],IG=`localhost`,LG=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],RG=[`video/mp4`,`video/webm`,`video/ogg`],zG=[`audio/mpeg`,`audio/wav`,`audio/ogg`],BG=[`application/pdf`],VG=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`]),HG=new Set([`mp4`,`webm`,`mov`,`m4v`,`mkv`]),UG=new Set([`pdf`]),WG=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]),GG=new Set(`pdf.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),KG=new Set(`exe.bat.cmd.ps1.com.msi.vbs.js.jse.wsf.wsh.hta.sh.command.csh.ksh.bash.zsh.fish.desktop.action.workflow.html.htm.svg.xml.mhtml.svgz.dmg.pkg.mpkg.scpt.applescript.terminal.prefpane.webloc.inetloc.fileloc.jar.appimage.deb.rpm.msix.appx.ipa.apk.pif.scr.lnk.url`.split(`.`)),qG=new Set(`png.jpg.jpeg.gif.webp.avif.svg.apng.heic.heif.tiff.bmp.ico.pdf.mp4.webm.mov.m4v.mkv.avi.flv.wmv.mpeg.mpg.mp3.wav.ogg.m4a.flac.aac.opus.zip.woff.woff2.ttf.otf.eot.docx.xlsx.pptx.csv.txt.rtf.json.toml.lock`.split(`.`)),JG=new Set(`png.jpg.jpeg.gif.webp.avif.apng.heic.heif.tiff.bmp.ico.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.json.toml.lock`.split(`.`)),YG=`same-dir`,XG=new Set(`png.jpg.jpeg.gif.webp.avif.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),ZG=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`],QG=[`mp4`,`webm`,`mov`,`m4v`],$G=[`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`],eK=[`pdf`],tK=[`json`,`toml`,`lock`];function nK(e,t,n){for(let r of t)if(!n.has(r))throw Error(`${e}: ${r} is not present in canonical upload constants`)}nK(`SIDEBAR_IMAGE_ASSET_EXTENSIONS`,ZG,VG),nK(`SIDEBAR_VIDEO_ASSET_EXTENSIONS`,QG,HG),nK(`SIDEBAR_AUDIO_ASSET_EXTENSIONS`,$G,WG),nK(`SIDEBAR_PDF_ASSET_EXTENSIONS`,eK,UG),nK(`FILE_ATTACHMENT_EXTENSIONS`,[...GG],XG);const rK=new Set(ZG),iK=new Set(QG),aK=new Set($G),oK=new Set(eK),sK=new Set(tK);nK(`SIDEBAR_RENDERABLE_ASSET_EXTENSIONS`,[...new Set([...ZG,...QG,...$G,...eK,...tK])],JG);function cK(e){let t=e.toLowerCase().replace(/^\./,``);return rK.has(t)?`image`:iK.has(t)?`video`:aK.has(t)?`audio`:oK.has(t)?`pdf`:sK.has(t)?`text`:null}const lK=Ex.extend({priority:60,addAttributes(){return{...this.parent?.(),fenceDelimiter:{default:"`"},fenceLength:{default:3},meta:{default:null},sourceStyle:{default:`fenced`}}}}),uK=zx.extend({name:`emphasis`,priority:60,addAttributes(){return{...this.parent?.(),sourceDelimiter:{default:`*`}}},addInputRules(){return[rx({find:Px,type:this.type,getAttributes:{sourceDelimiter:`*`}}),rx({find:Ix,type:this.type,getAttributes:{sourceDelimiter:`_`}})]}}),dK=Nx.extend({name:`strong`,priority:60,addAttributes(){return{...this.parent?.(),sourceDelimiter:{default:`**`}}},addInputRules(){return[rx({find:Ox,type:this.type,getAttributes:{sourceDelimiter:`**`}}),rx({find:Ax,type:this.type,getAttributes:{sourceDelimiter:`__`}})]}}),fK=Ib.create({name:`escapeMark`,priority:10,excludes:``,inclusive:!1,parseHTML(){return[{tag:`span[data-escape-mark]`}]},renderHTML(){return[`span`,{"data-escape-mark":``},0]}}),pK=Vx.extend({priority:60,addAttributes(){return{...this.parent?.(),hardBreakStyle:{default:`backslash`}}}}),mK=Ux.extend({priority:60,addAttributes(){return{...this.parent?.(),headingStyle:{default:`atx`},sourceTrailingHashes:{default:null},sourceUnderlineLength:{default:null},sourceContiguousNext:{default:!1}}}}),hK=bx.create({name:`htmlBlock`,group:`block`,atom:!0,priority:60,addAttributes(){return{content:{default:``}}},parseHTML(){return[{tag:`div[data-html-block]`}]},renderHTML({node:e}){return[`div`,{"data-html-block":``,class:`html-block`},e.attrs.content]}});function gK(e){if(typeof e!=`string`||!e.startsWith(`/`))return e;let t=globalThis.window?.okDesktop?.config?.apiOrigin;return typeof t==`string`&&t?t+e:e}const _K=Gx.extend({priority:60,addAttributes(){return{...this.parent?.(),sourceUrl:{default:null,rendered:!1}}},renderHTML({HTMLAttributes:e}){let t=Dy(this.options.HTMLAttributes,e);return typeof t.src==`string`&&(t.src=gK(t.src)),[`img`,t]}}),vK=bx.create({name:`jsxComponent`,group:`block`,atom:!1,content:`block*`,isolating:!0,selectable:!0,defining:!0,priority:60,addAttributes(){return{componentName:{default:``},kind:{default:`element`},attributes:{default:[]},sourceRaw:{default:``},sourceDirty:{default:!1},props:{default:{}}}},parseHTML(){return[{tag:`div[data-jsx-component]`,getAttrs:e=>typeof e==`string`?!1:{componentName:e.getAttribute(`data-component-name`)||``,sourceRaw:e.getAttribute(`data-source-raw`)||``}}]},renderHTML({HTMLAttributes:e}){return[`div`,{"data-jsx-component":``,"data-component-name":e.componentName,"data-source-raw":e.sourceRaw},0]},addCommands(){return{insertJsxComponent:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{sourceRaw:e}})}}}),yK=bx.create({name:`jsxInline`,group:`inline`,inline:!0,atom:!1,content:`text*`,isolating:!1,selectable:!0,priority:60,addAttributes(){return{}},parseHTML(){return[{tag:`span[data-jsx-inline]`}]},renderHTML(){return[`span`,{"data-jsx-inline":``},0]}}),bK=[`https`,`http`,`mailto`,`tel`,`ftp`,`sms`],xK=bK.map(e=>`${e}:`).join(`|`);RegExp(`^(?:${xK}|\\/|#|\\?|\\.\\/|\\.\\.\\/)`,`i`);function SK(e){let t=e.trim();if(t===``)return!0;let n=t.indexOf(`:`);if(n===-1)return!0;let r=t.indexOf(`/`),i=t.indexOf(`?`),a=t.indexOf(`#`);return n>Math.min(r===-1?1/0:r,i===-1?1/0:i,a===-1?1/0:a)}const CK=new Set(bK.map(e=>`${e}:`));function wK(e){try{let t=new URL(e,`https://placeholder.invalid`);return CK.has(t.protocol.toLowerCase())}catch{return!1}}const TK=rS.extend({priority:60,addOptions(){return{openOnClick:!1,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer`},isAllowedUri:wK,validate:wK,shouldAutoLink:()=>!0}},addAttributes(){return{...this.parent?.(),linkStyle:{default:`inline`,rendered:!1},refLabel:{default:null,rendered:!1},sourceForm:{default:null,rendered:!1},target:{default:null,rendered:!1},anchor:{default:null,rendered:!1},alias:{default:null,rendered:!1},sourceUrlForm:{default:null,rendered:!1},sourceTitleMarker:{default:null,rendered:!1}}}}),EK=bx.create({name:`linkRefDef`,group:`block`,atom:!0,priority:60,addAttributes(){return{label:{default:``},href:{default:``},title:{default:null},sourceLayout:{default:null},sourceTitleMarker:{default:null}}},parseHTML(){return[{tag:`div[data-link-ref-def]`}]},renderHTML({node:e}){let{label:t,href:n,title:r}=e.attrs,i=r?`[${t}]: ${n} "${r}"`:`[${t}]: ${n}`;return[`div`,{"data-link-ref-def":``,class:`link-ref-def`},i]}});function DK(e){return e.type.name===`list`&&!e.attrs.ordered}function OK(e){return e.type.name===`list`&&!!e.attrs.ordered}function kK(e){let t=!1;return e.forEach(e=>{e.type.name===`listItem`&&e.attrs.checked!==null&&(t=!0)}),t}function AK(e,t,n,r,i,a,o){let s=_y(e=>e.type.name===`list`)(e.selection);if(s&&i(s.node)){let{$from:n,$to:i}=e.selection;return n.blockRange(i)?mp(r)(e,t):!1}if(s){if(!t)return!0;let{tr:n}=e;return n.setNodeMarkup(s.pos,void 0,{...s.node.attrs,...a}),o!==void 0&&s.node.forEach((e,t)=>{if(e.type.name===`listItem`){let r=s.pos+1+t;n.setNodeMarkup(r,void 0,{...e.attrs,...o})}}),t(n),!0}return dp(n,a)(e,void 0)?t?dp(n,a)(e,n=>{if(o){let t=n.mapping.map(e.selection.$from.pos),r=n.doc.resolve(t);for(let e=r.depth;e>0;e--){let t=r.node(e);if(t.type.name===`listItem`){n.setNodeMarkup(r.before(e),void 0,{...t.attrs,...o});break}}}t(n)}):!0:!1}const jK=bx.create({name:`list`,group:`block list`,content:`listItem+`,priority:60,addAttributes(){return{ordered:{default:!1},start:{default:1},spread:{default:!1},bulletMarker:{default:null},listMarkerDelimiter:{default:null}}},parseHTML(){return[{tag:`ul`,getAttrs:()=>({ordered:!1})},{tag:`ol`,getAttrs:e=>({ordered:!0,start:e.getAttribute(`start`)?Number(e.getAttribute(`start`)):1})}]},renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs.ordered?`ol`:`ul`,r={};return e.attrs.ordered&&e.attrs.start!==1&&(r.start=e.attrs.start),[n,Dy(t,r),0]},addCommands(){return{toggleBulletList:()=>({state:e,dispatch:t})=>{let n=e.schema.nodes.list,r=e.schema.nodes.listItem;return!n||!r?!1:AK(e,t,n,r,e=>DK(e)&&!kK(e),{ordered:!1},{checked:null})},toggleOrderedList:()=>({state:e,dispatch:t})=>{let n=e.schema.nodes.list,r=e.schema.nodes.listItem;return!n||!r?!1:AK(e,t,n,r,e=>OK(e),{ordered:!0},{checked:null})},toggleTaskList:()=>({state:e,dispatch:t})=>{let n=e.schema.nodes.list,r=e.schema.nodes.listItem;return!n||!r?!1:AK(e,t,n,r,e=>DK(e)&&kK(e),{ordered:!1},{checked:!1})}}},addInputRules(){return[ox({find:/^\s*([-+*])(?!\s*\[[ xX]\])\s$/,type:this.type,getAttributes:e=>({ordered:!1,bulletMarker:e[1]})}),ox({find:/^\s*(\d+)([.)])\s$/,type:this.type,getAttributes:e=>({ordered:!0,start:Number(e[1]),listMarkerDelimiter:e[2]})}),new Ob({find:/^\s*[-*+]\s\[([ xX])\]\s$/,handler:({state:e,range:t,match:n})=>{let r=e.schema.nodes.list;if(!r)return null;let i=n[1]!==` `,a=e.tr.delete(t.from,t.to),o=a.doc.resolve(t.from).blockRange();if(!o)return null;let s=Ed(o,r,{ordered:!1});if(!s)return null;a.wrap(o,s);let c=a.doc.resolve(a.mapping.map(t.from));for(let e=c.depth;e>0;e--){let t=c.node(e);if(t.type.name===`listItem`){a.setNodeMarkup(c.before(e),void 0,{...t.attrs,checked:i});break}}}})]},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList(),"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList(),"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),MK=bx.create({name:`listItem`,content:`paragraph block*`,defining:!0,addAttributes(){return{checked:{default:null},spread:{default:!1}}},parseHTML(){return[{tag:`li`,getAttrs:e=>{let t=e.querySelector(`input[type="checkbox"]`);return{checked:t?t.checked:null}}}]},renderHTML({node:e,HTMLAttributes:t}){return e.attrs.checked===null?[`li`,Dy(t),0]:[`li`,Dy(t,{"data-type":`taskItem`,"data-checked":e.attrs.checked?`true`:`false`}),[`label`,{contenteditable:`false`},[`input`,{type:`checkbox`,...e.attrs.checked?{checked:`checked`}:{}}]],[`div`,0]]},addNodeView(){return({node:e,getPos:t,editor:n,HTMLAttributes:r})=>{let i=document.createElement(`li`);Object.entries(Dy(r,e.attrs.checked===null?{}:{"data-type":`taskItem`,"data-checked":String(!!e.attrs.checked)})).forEach(([e,t])=>{t!=null&&i.setAttribute(e,String(t))});let a=null,o=null,s=document.createElement(`div`);return e.attrs.checked!==null&&(a=document.createElement(`label`),a.contentEditable=`false`,o=document.createElement(`input`),o.type=`checkbox`,o.checked=!!e.attrs.checked,n.isEditable||(o.disabled=!0),o.addEventListener(`change`,()=>{let r=t();r===void 0||typeof r!=`number`||n.view.dispatch(n.view.state.tr.setNodeMarkup(r,void 0,{...e.attrs,checked:o?.checked??!1}))}),a.appendChild(o),i.appendChild(a)),i.appendChild(s),{dom:i,contentDOM:s,update(t){return t.type!==e.type||t.attrs.checked!==null!=(e.attrs.checked!==null)?!1:(o&&t.attrs.checked!==null&&(o.checked=!!t.attrs.checked,i.setAttribute(`data-checked`,String(!!t.attrs.checked))),e=t,!0)}}}},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>{let{$from:e}=this.editor.state.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.name===`listItem`)return this.editor.commands.sinkListItem(this.name);return!1},"Shift-Tab":()=>{let{$from:e}=this.editor.state.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.name===`listItem`)return this.editor.commands.liftListItem(this.name);return!1}}}}),NK=jK,PK=MK,FK=bx.create({name:`mathInline`,group:`inline`,inline:!0,atom:!0,selectable:!0,priority:60,addAttributes(){return{formula:{default:``},id:{default:null},language:{default:`latex`}}},parseHTML(){return[{tag:`span[data-math-inline]`,getAttrs:e=>typeof e==`string`?!1:{formula:e.getAttribute(`data-formula`)||``,id:e.getAttribute(`id`)||null,language:e.getAttribute(`data-language`)||`latex`}}]},renderHTML({HTMLAttributes:e}){return[`span`,{"data-math-inline":``,"data-formula":e.formula,"data-language":e.language,...e.id?{id:e.id}:{}}]},addCommands(){return{insertMathInline:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{formula:e}})}}}),IK=bx.create({name:`rawMdxFallback`,group:`block`,atom:!1,content:`text*`,isolating:!0,selectable:!0,defining:!0,priority:60,addAttributes(){return{reason:{default:``},originalSpan:{default:{start:0,end:0}}}},parseHTML(){let e=e=>typeof e==`string`?!1:{reason:e.getAttribute(`data-reason`)||``};return[{tag:`div[data-raw-mdx-fallback]`,getAttrs:e},{tag:`pre[data-raw-mdx-fallback]`,getAttrs:e}]},renderHTML({HTMLAttributes:e}){return[`div`,{"data-raw-mdx-fallback":``,"data-raw-badge":`raw`,"data-reason":e.reason,contenteditable:`false`,class:`raw-mdx-fallback`},0]},addNodeView(){return({HTMLAttributes:e})=>{let t=document.createElement(`div`);t.setAttribute(`data-raw-mdx-fallback`,``),t.setAttribute(`data-raw-badge`,`raw`),t.setAttribute(`contenteditable`,`false`),t.classList.add(`raw-mdx-fallback`),e.reason&&t.setAttribute(`data-reason`,e.reason);let n=document.createElement(`pre`);return n.classList.add(`raw-mdx-fallback-content`),n.setAttribute(`contenteditable`,`false`),t.appendChild(n),{dom:t,contentDOM:n,ignoreMutation:()=>!0}}}}),LK=mw.extend({priority:60,addAttributes(){return{...this.parent?.(),sourceMarkerSpacings:{default:null}}}}),RK=vw.extend({excludes:``,addAttributes(){return{...this.parent?.(),sourceFenceChar:{default:"`"},sourceFenceLength:{default:1}}}}),zK=bx.create({name:`commentBlock`,group:`block`,content:`block+`,defining:!0,priority:60,addAttributes(){return{sourceForm:{default:`percent`,parseHTML:e=>e.getAttribute(`data-source-form`)===`html`?`html`:`percent`,renderHTML:e=>e.sourceForm===`html`?{"data-source-form":`html`}:{}},sourceLayout:{default:`block`,parseHTML:e=>e.getAttribute(`data-source-layout`)===`inline`?`inline`:`block`,renderHTML:e=>e.sourceLayout===`inline`?{"data-source-layout":`inline`}:{}}}},parseHTML(){return[{tag:`aside[data-comment-block]`},{tag:`aside.comment-block`}]},renderHTML({HTMLAttributes:e}){return[`aside`,{"data-comment-block":``,"data-clipboard-omit":`true`,class:`comment-block`,style:`display: none;`,...e},0]},addCommands(){return{setCommentBlock:()=>({commands:e})=>e.wrapIn(this.name),toggleCommentBlock:()=>({commands:e})=>e.toggleWrap(this.name),unsetCommentBlock:()=>({commands:e})=>e.lift(this.name)}}}),BK=Ib.create({name:`comment`,priority:10,excludes:``,inclusive:!1,addAttributes(){return{sourceForm:{default:`percent`,parseHTML:e=>e.getAttribute(`data-source-form`)===`html`?`html`:`percent`,renderHTML:e=>e.sourceForm===`html`?{"data-source-form":`html`}:{}}}},parseHTML(){return[{tag:`span[data-comment-mark]`}]},renderHTML({HTMLAttributes:e}){return[`span`,{"data-comment-mark":``,"data-clipboard-omit":`true`,class:`comment-mark`,style:`display: none;`,...e},0]},addCommands(){return{setComment:()=>({commands:e})=>e.setMark(this.name),toggleComment:()=>({commands:e})=>e.toggleMark(this.name),unsetComment:()=>({commands:e})=>e.unsetMark(this.name)}}}),VK=bx.create({name:`footnoteDefinition`,group:`block`,content:`block+`,defining:!0,priority:60,addAttributes(){return{identifier:{default:``},label:{default:null}}},parseHTML(){let e=e=>{if(typeof e==`string`)return!1;let t=e.getAttribute(`data-footnote-id`)||``;return{identifier:t,label:t||null}};return[{tag:`aside[data-footnote-def]`,getAttrs:e},{tag:`aside.footnote-def`,getAttrs:e}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.identifier??``);return[`aside`,{...t,"data-footnote-def":``,"data-footnote-id":n,id:`fn-${n}`,class:`footnote-def`},[`div`,{class:`footnote-body`},0],[`a`,{href:`#fnref-${n}`,class:`footnote-backref`,contentEditable:`false`,"aria-label":`Back to reference`},`↩`]]},addCommands(){return{insertFootnoteDefinition:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{identifier:e,label:e},content:[{type:`paragraph`}]})}}}),HK=bx.create({name:`footnoteReference`,group:`inline`,inline:!0,atom:!0,selectable:!0,draggable:!1,priority:60,addAttributes(){return{identifier:{default:``},label:{default:null}}},parseHTML(){return[{tag:`sup[data-footnote-ref]`,getAttrs:e=>{if(typeof e==`string`)return!1;let t=e.getAttribute(`data-footnote-id`)||``;return{identifier:t,label:t||null}}}]},renderHTML({node:e}){let t=String(e.attrs.identifier??``);return[`sup`,{id:`fnref-${t}`,"data-footnote-ref":``,"data-footnote-id":t,class:`footnote-ref`},[`a`,{href:`#fn-${t}`,class:`footnote-ref-link`},`[${t}]`]]},addCommands(){return{insertFootnoteReference:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{identifier:e,label:e}})}}}),UK=bx.create({name:`imageReference`,group:`inline`,inline:!0,atom:!0,priority:60,addAttributes(){return{alt:{default:``},label:{default:``},identifier:{default:``},referenceType:{default:`shortcut`}}},parseHTML(){return[{tag:`img[data-image-reference]`}]},renderHTML({node:e}){let{alt:t,label:n,referenceType:r}=e.attrs,i=t||n;return[`img`,{"data-image-reference":``,"data-reference-type":r,"data-label":n,alt:i}]}}),WK=Ib.create({name:`sourceLiteral`,priority:10,excludes:``,inclusive:!1,addAttributes(){return{sourceRaw:{default:``}}},parseHTML(){return[{tag:`span[data-source-literal]`}]},renderHTML({HTMLAttributes:e}){return[`span`,{"data-source-literal":``,...e},0]}});function GK(e,t){if(typeof e!=`string`||typeof t!=`string`||/[\x00-\x1F\x7F]/.test(e))return!1;let n=e.replaceAll(`\xA0`,` `),r=t.replaceAll(`\xA0`,` `);return n===r?!0:KK(n)===r}function KK(e){return e.replace(/\\([!-/:-@[-`{-~])/g,`$1`)}const qK=dw.extend({priority:60,addAttributes(){return{...this.parent?.(),sourceDashCounts:{default:null}}}}),JK=XC.extend({priority:60,addAttributes(){return{...this.parent?.(),sourcePadding:{default:null}}}}),YK=ZC.extend({priority:60,addAttributes(){return{...this.parent?.(),sourcePadding:{default:null}}}}),XK=bx.create({name:`tag`,group:`inline`,inline:!0,atom:!0,selectable:!0,priority:60,addAttributes(){return{value:{default:``}}},parseHTML(){return[{tag:`a[data-tag]`,getAttrs:e=>typeof e==`string`?!1:{value:e.getAttribute(`data-tag`)||``}}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.value??``);return[`a`,{...t,"data-tag":n,href:`#tag/${n}`,class:`tag`},`#${n}`]},addCommands(){return{insertTag:e=>({chain:t})=>t().insertContent({type:`tag`,attrs:{value:e}}).run()}}}),ZK=/^(?:---|—-|___\s|\*\*\*\s)$/;function QK(e){let t=String(e[0]??``).replace(/\s+$/,``);return t===`—-`?`---`:t}const $K=xw.extend({name:`thematicBreak`,priority:60,addAttributes(){return{...this.parent?.(),sourceRaw:{default:`---`}}},addInputRules(){return[ix({find:ZK,type:this.type,getAttributes:e=>({sourceRaw:QK(e)})})]}});function eq(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function tq(e){return e.alias?e.alias:e.anchor?`${e.target}#${e.anchor}`:e.target}const nq=bx.create({name:`wikiLink`,group:`inline`,inline:!0,atom:!0,priority:60,addAttributes(){return{target:{default:``},alias:{default:null},anchor:{default:null},resolved:{default:!1}}},parseHTML(){return[{tag:`span[data-wiki-link]`,getAttrs:e=>typeof e==`string`?!1:{target:e.getAttribute(`data-target`)||``,alias:eq(e.getAttribute(`data-alias`)),anchor:eq(e.getAttribute(`data-anchor`)),resolved:e.getAttribute(`data-resolved`)===`true`}},{tag:`a.wiki-link[data-target]`,priority:100,getAttrs:e=>{if(typeof e==`string`)return!1;let t=e.getAttribute(`data-target`)??``;return t?{target:t,alias:eq(e.getAttribute(`data-alias`)),anchor:eq(e.getAttribute(`data-anchor`)),resolved:!1}:!1}}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.target??``),r=eq(e.attrs.alias),i=eq(e.attrs.anchor),a=e.attrs.resolved===!0;return[`span`,{...t,"data-wiki-link":``,"data-target":n,"data-alias":r??``,"data-anchor":i??``,"data-resolved":a?`true`:`false`},tq({target:n,alias:r,anchor:i})]}});function rq(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0||n===t.length-1?``:t.slice(n+1).toLowerCase()}function iq(e){return e.alias?e.alias:e.anchor?`${e.target}#${e.anchor}`:e.target}const aq=[vK,IK,yK,FK,nq,bx.create({name:`wikiLinkEmbed`,group:`inline`,inline:!0,atom:!0,priority:60,addAttributes(){return{target:{default:``},alias:{default:null},anchor:{default:null},resolvedSrc:{default:null,rendered:!1,parseHTML:()=>null}}},parseHTML(){let e=e=>typeof e==`string`||!e.hasAttribute(`data-wiki-embed`)?!1:{target:e.getAttribute(`data-target`)||``,alias:eq(e.getAttribute(`data-alias`)),anchor:eq(e.getAttribute(`data-anchor`))};return[{tag:`img[data-wiki-embed]`,getAttrs:e,priority:100},{tag:`a[data-wiki-embed]`,getAttrs:e,priority:100}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.target??``),r=eq(e.attrs.alias),i=eq(e.attrs.anchor),a=eq(e.attrs.resolvedSrc),o=rq(n);if(VG.has(o))return[`img`,{...t,"data-wiki-embed":``,"data-target":n,"data-alias":r??``,"data-anchor":i??``,src:a??n,alt:r??n}];let s=a??n;return[`a`,{...t,"data-wiki-embed":``,"data-target":n,"data-alias":r??``,"data-anchor":i??``,href:i?`${s}#${i}`:s,target:`_blank`,rel:`noopener noreferrer`},iq({target:n,alias:r,anchor:i})]}}),XK,NK,PK,uK,dK,RK,lK,LK,mK,$K,TK,hK,EK,pK,fK,WK,YT.configure({undoRedo:!1,bulletList:!1,orderedList:!1,listItem:!1,italic:!1,bold:!1,code:!1,codeBlock:!1,heading:!1,horizontalRule:!1,hardBreak:!1,link:!1,blockquote:!1,dropcursor:{color:`color-mix(in oklch, var(--primary) 50%, transparent)`,width:2}}),qK.configure({resizable:!0}),QC,YK,JK,_K.configure({inline:!0}),UK,oS,BK,zK,HK,VK],oq=/^[a-zA-Z][\w/-]*$/;function sq(e){return e.startsWith(`#`)?e.slice(1):e}function cq(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function lq(e){if(!e||e.trim()===``)return[];let{map:t}=RW(e);if(!t)return[];let n=cq(t.tags),r=[];for(let e of n){let t=sq(e);oq.test(t)?r.push(t):console.warn(`[frontmatter-tags] dropping invalid tag entry: ${JSON.stringify(e)}`)}return r}function uq(e){if(e.length===0)return{ok:!1,reason:`docName must not be empty`};if(e.trim().length===0)return{ok:!1,reason:`docName must not be blank (whitespace only)`};if(e!==e.trim())return{ok:!1,reason:`docName must not have leading or trailing whitespace`};for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return{ok:!1,reason:`docName must not contain control characters`}}if(e.includes(`..`)||e.startsWith(`/`)||e.includes(`\\`))return{ok:!1,reason:`docName must not contain "..", a leading "/", or a backslash`};for(let t of e.split(`/`)){if(t.length===0)return{ok:!1,reason:`docName must not contain empty path segments (no leading, trailing, or doubled "/")`};if(t.startsWith(`.`))return{ok:!1,reason:`docName path segments must not start with "." (hidden files are not addressable)`}}return{ok:!0}}function dq(e,t){let n=uq(e);n.ok||t.addIssue({code:`custom`,message:n.reason})}const fq=k().superRefine(dq).optional(),pq=k().min(1).superRefine(dq),mq={agentId:k().optional(),agentName:k().optional(),colorSeed:k().optional(),clientName:k().optional(),clientVersion:k().optional(),label:k().optional()},hq=k().optional(),gq=/^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,_q=Qs(`kind`,[M({kind:P(`doc`),docPath:k().min(1)}).loose(),M({kind:P(`folder`),folderPath:k()}).loose()]),vq=N([`no-remote`,`detached-head`,`branch-not-on-origin`,`non-github-remote`,`invalid-path`]),yq=Qs(`ok`,[M({ok:P(!0),shareUrl:k().min(1),sharedUrl:k().min(1),branch:k().min(1)}).loose(),M({ok:P(!1),error:vq,branch:k().min(1).optional()}).loose()]),bq=N([`user`,`org`]),xq=M({login:k().min(1),kind:bq,avatarUrl:k().optional()}).loose(),Sq=N([`auth-required`,`network`]),Cq=Qs(`ok`,[M({ok:P(!0),owners:j(xq)}).loose(),M({ok:P(!1),error:Sq}).loose()]),wq=Qs(`ok`,[M({ok:P(!0),available:Ls()}).loose(),M({ok:P(!1),error:Sq}).loose()]),Tq=N([`public`,`private`]),Eq=M({owner:k().min(1),name:k().min(1),visibility:Tq,description:k().optional()}).loose(),Dq=N([`name-conflict`,`saml-sso`,`auth-required`,`push-failed`,`init-failed`,`network`,`no-project`]),Oq=Qs(`ok`,[M({ok:P(!0),ownerLogin:k().min(1),repoName:k().min(1),cloneUrl:k().min(1),defaultBranch:k().min(1)}).loose(),M({ok:P(!1),error:Dq}).loose()]);function kq(e){return!(typeof e!=`string`||e.length===0||e.startsWith(`-`)||/[\x00-\x1F\x7F]/.test(e)||/\s/.test(e)||e.includes(`:`)||e.split(`/`).includes(`..`))}const Aq=e=>e.refine(kq,`invalid branch name`);function jq(e){if(e==null)return!1;let t=e instanceof Error?e.message:String(e);return/couldn'?t find remote ref|Remote branch .+ not found/i.test(t)}const Mq={shareTargetExists:Ls(),dirtyConflicts:M({conflicts:Ls(),files:j(k().min(1))}).loose(),branchIsLocal:Ls()},Nq=Qs(`detached`,[M({detached:P(!1),currentBranch:k().min(1).nullable(),currentHeadSha:zs(),...Mq}).loose(),M({detached:P(!0),currentBranch:zs(),currentHeadSha:k().min(1),...Mq}).loose()]),Pq=M({branch:Aq(k().min(1)),principalId:k().optional()}).loose(),Fq=N([`dirty-conflict`,`branch-not-found`,`fetch-failed`,`checkout-failed`,`branch-in-other-worktree`]),Iq=Qs(`ok`,[M({ok:P(!0)}).loose(),M({ok:P(!1),reason:Fq,files:j(k().min(1)).optional(),otherWorktreePath:k().min(1).optional()}).loose()]),Lq=M({serverInstanceId:k().min(1),currentBranch:k().min(1).optional(),currentDiskAckSVs:nc(k().min(1),k().min(1)).optional()}).loose(),Rq=M({id:k().min(1),display_name:k().min(1),display_email:k(),source:N([`git-config`,`synthesized`]),created_at:k().min(1)}).loose(),zq=M({collabUrl:k().nullable(),previewUrl:k().nullable(),port:A(),paneTarget:k().nullable()}).loose(),Bq=N(`urn:ok:error:malformed-upload.urn:ok:error:collision-exhaustion.urn:ok:error:storage-full.urn:ok:error:storage-readonly.urn:ok:error:storage-error.urn:ok:error:no-file-received.urn:ok:error:path-escape.urn:ok:error:method-not-allowed.urn:ok:error:invalid-request.urn:ok:error:payload-too-large.urn:ok:error:request-timeout.urn:ok:error:internal-server-error.urn:ok:error:loopback-required.urn:ok:error:invalid-origin.urn:ok:error:url-not-allowed.urn:ok:error:dir-outside-home.urn:ok:error:concurrent-operation.urn:ok:error:clone-failed.urn:ok:error:clone-timeout.urn:ok:error:server-start-failed.urn:ok:error:reserved-doc-name.urn:ok:error:target-not-found.urn:ok:error:stale-target.urn:ok:error:frontmatter-edit-not-supported.urn:ok:error:invalid-frontmatter-patch.urn:ok:error:frontmatter-malformed.urn:ok:error:no-active-session.urn:ok:error:too-many-agent-sessions.urn:ok:error:doc-not-found.urn:ok:error:doc-already-exists.urn:ok:error:doc-not-open.urn:ok:error:rollback-not-configured.urn:ok:error:doc-not-available.urn:ok:error:backlink-index-not-configured.urn:ok:error:file-rescan-not-configured.urn:ok:error:shadow-not-configured.urn:ok:error:host-not-allowed.urn:ok:error:principal-not-available.urn:ok:error:not-found.urn:ok:error:auth-failed.urn:ok:error:no-project-dir.urn:ok:error:server-open-failed.urn:ok:error:doc-in-conflict.urn:ok:error:no-conflict-tracked.urn:ok:error:sync-not-active.urn:ok:error:project-repo-not-configured.urn:ok:error:seed-prerequisite-missing.urn:ok:error:seed-invalid-root.urn:ok:error:tag-index-not-configured.urn:ok:error:template-not-found.urn:ok:error:unsupported-asset-type.urn:ok:error:asset-not-found.urn:ok:error:collab-server-not-running.urn:ok:error:gateway-timeout.urn:ok:error:cursor-not-installed.urn:ok:error:cursor-spawn-timeout.urn:ok:error:cursor-spawn-failed.urn:ok:error:handoff-target-not-installed.urn:ok:error:handoff-spawn-timeout.urn:ok:error:handoff-spawn-failed`.split(`.`));function Vq(e){throw Error(`Unexpected ProblemType variant: ${JSON.stringify(e)}`)}const Hq=M({type:Bq,title:k().min(1),status:A().int().min(400).max(599),instance:k().regex(gq,`instance must be urn:uuid:<uuid>`).optional(),detail:k().optional()}).loose(),Uq=M({parentDocName:k().min(1),agentId:k().min(1).optional(),agentName:k().min(1).optional()}).loose(),Wq=M({src:k().min(1),path:k().min(1).optional(),deduped:Ls().optional()}).loose(),Gq=M({url:k().min(1),dir:k().min(1),branch:k().min(1).refine(kq,`invalid branch name`).optional()}).loose(),Kq=M({type:P(`error`),problem:Hq}).loose();function qq(e,t){let n=Array.isArray(e.attrs.attributes)?e.attrs.attributes.filter(e=>typeof e==`object`&&!!e&&`type`in e):[],r=e.attrs.props??{},i=new Map,a=new Set;if(t)for(let e of t)e.omitOnDefault===!0&&`defaultValue`in e&&e.defaultValue!==void 0&&i.set(e.name,e.defaultValue),e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&a.add(e.name);for(let[e,t]of Object.entries(r)){let r=n.findIndex(t=>t.type===`mdxJsxAttribute`&&t.name===e);if(i.has(e)&&Object.is(i.get(e),t)){r>=0&&n.splice(r,1);continue}if(a.has(e)&&t===``){r>=0&&n.splice(r,1);continue}let o=Jq(e,t);r>=0?n[r]=o:n.push(o)}return n}function Jq(e,t){if(t===!0)return{type:`mdxJsxAttribute`,name:e,value:null};if(t===!1)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:`false`}};if(t==null)return{type:`mdxJsxAttribute`,name:e,value:null};if(typeof t==`string`)return{type:`mdxJsxAttribute`,name:e,value:t};if(typeof t==`number`)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:JSON.stringify(t)}};if(typeof t==`object`){let n;try{n=JSON.stringify(t)}catch{n=String(t)}return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:n}}}return{type:`mdxJsxAttribute`,name:e,value:String(t)}}function Yq(e,t,n,r){return{type:`mdxJsxFlowElement`,name:e,attributes:qq(t,r),children:n.all(t),data:{}}}const Xq=/^[A-Za-z0-9]{20,}$/,Zq=/^(?:\d+s?|(?:\d+h)?(?:\d+m)?(?:\d+s)?)$/;function Qq(e){let t=e.toLowerCase();return t===`loom.com`||t===`www.loom.com`}function $q(e){let t=e.pathname.match(/^\/(?:share|embed)\/([A-Za-z0-9]+)\/?$/);if(!t)return null;let n=t[1]??``;return Xq.test(n)?n:null}function eJ(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!Qq(t.hostname))return null;let n=$q(t);if(!n)return null;let r=t.searchParams.get(`t`);return{id:n,startRaw:r&&r.length>0&&Zq.test(r)?r:null}}function tJ(e){return eJ(e)!==null}function nJ(e){let t=e.toLowerCase();return t===`vimeo.com`||t===`www.vimeo.com`||t===`player.vimeo.com`}function rJ(e){if(typeof e!=`string`||e.length===0)return!1;let t;try{t=new URL(e)}catch{return!1}return t.protocol!==`http:`&&t.protocol!==`https:`?!1:nJ(t.hostname)}const iJ=/^[A-Za-z0-9_-]{11}$/;function aJ(e){let t=e.toLowerCase();return t===`youtube.com`||t===`www.youtube.com`||t===`m.youtube.com`||t===`music.youtube.com`||t===`youtu.be`||t===`youtube-nocookie.com`||t===`www.youtube-nocookie.com`}function oJ(e){if(e.length===0)return null;if(/^[0-9]+$/.test(e)){let t=Number.parseInt(e,10);return t>0?t:null}let t=e.match(/^(?:([0-9]+)h)?(?:([0-9]+)m)?(?:([0-9]+)s?)?$/);if(!t)return null;let n=t[1]?Number.parseInt(t[1],10):0,r=t[2]?Number.parseInt(t[2],10):0,i=t[3]?Number.parseInt(t[3],10):0,a=n*3600+r*60+i;return a>0?a:null}function sJ(e){if(e.hostname.toLowerCase()===`youtu.be`){let t=e.pathname.replace(/^\//,``).split(`/`)[0]??``;return iJ.test(t)?t:null}if(e.pathname===`/watch`){let t=e.searchParams.get(`v`)??``;return iJ.test(t)?t:null}let t=e.pathname.match(/^\/(?:embed|shorts|v)\/([A-Za-z0-9_-]{11})\/?$/);return t?t[1]??null:null}function cJ(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!aJ(t.hostname))return null;let n=sJ(t);if(!n)return null;let r=t.searchParams.get(`t`)??t.searchParams.get(`start`)??``;return{id:n,startSeconds:r.length>0?oJ(r):null,noCookie:t.hostname.toLowerCase().endsWith(`youtube-nocookie.com`)}}const lJ=[{name:`type`,type:`enum`,enumValues:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`],defaultValue:`note`,required:!1,description:`Callout variant`},{name:`title`,type:`string`,required:!1,description:`Optional heading shown above the body`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Lightbulb`)",iconPicker:!0},{name:`color`,type:`string`,required:!1,advanced:!0,description:"Optional accent color override (hex — e.g. `#F05032`)",colorPicker:!0},{name:`collapsible`,type:`boolean`,required:!1,defaultValue:!1,advanced:!0,description:"Render as a foldable `<details>` (Obsidian `[!TYPE]+/-`)"},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,description:`When collapsible, start in the open state`,hideWhen:e=>e.collapsible!==!0},{name:`children`,type:`reactnode`,required:!0,description:`Callout content`}],uJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Image source URL`,accept:LG,autoFocus:!0},{name:`alt`,type:`string`,required:!0,description:`Alt text`},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Image width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Image height`},{name:`srcset`,type:`string`,required:!1,advanced:!0,description:`Responsive image candidate set (e.g. "x.png 1x, y.png 2x")`},{name:`sizes`,type:`string`,required:!1,advanced:!0,description:`Responsive image sizes hint paired with srcset`},{name:`loading`,type:`enum`,enumValues:[`eager`,`lazy`],defaultValue:`lazy`,required:!1,advanced:!0,omitOnDefault:!0,description:`Native img loading strategy (defaults to lazy)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`decoding`,type:`enum`,enumValues:[`sync`,`async`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Hint for how the browser should decode the image`},{name:`fetchpriority`,type:`enum`,enumValues:[`high`,`low`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Resource fetch priority hint`},{name:`crossorigin`,type:`enum`,enumValues:[`anonymous`,`use-credentials`],required:!1,advanced:!0,description:`CORS mode for the image fetch`},{name:`referrerpolicy`,type:`string`,required:!1,advanced:!0,description:`Referrer policy for the image fetch (HTML referrerpolicy values)`},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`}],dJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Embedded page URL (must start with http:// or https://)`,autoFocus:!0},{name:`title`,type:`string`,required:!1,description:`Iframe title (accessible label for screen readers)`},{name:`width`,type:`string`,required:!1,advanced:!0,description:`Embed width as a CSS length (e.g. "100%", "640px")`,cssLengthInput:!0},{name:`height`,type:`string`,required:!1,advanced:!0,description:`Embed height as a CSS length (e.g. "26rem", "480px")`,cssLengthInput:!0},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`}],fJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Video source URL`,accept:RG,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 video controls (defaults to true)`,hideWhen:e=>typeof e.src==`string`&&(rJ(e.src)||tJ(e.src))},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`poster`,type:`string`,required:!1,advanced:!0,description:`Poster image URL shown before playback`,accept:LG,hideWhen:e=>typeof e.src==`string`&&(rJ(e.src)||tJ(e.src))},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Video width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Video height`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`,hideWhen:e=>typeof e.src==`string`&&tJ(e.src)},{name:`playsinline`,type:`boolean`,required:!1,advanced:!0,description:`Play inline on iOS rather than entering fullscreen`,hideWhen:e=>typeof e.src==`string`&&(rJ(e.src)||tJ(e.src))},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the video to preload`,hideWhen:e=>typeof e.src==`string`&&(cJ(e.src)!==null||rJ(e.src)||tJ(e.src))},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`}],pJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Audio source URL`,accept:zG,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 audio controls (defaults to true)`},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the audio to preload`}],mJ=[{name:`title`,type:`string`,required:!0,description:`Accordion heading shown inside the <summary>`},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!1,description:`When true, the accordion renders expanded on initial load`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Rocket`)",iconPicker:!0},{name:`description`,type:`string`,required:!1,advanced:!0,description:`Optional subtitle rendered below the title inside <summary>`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#advanced-options`)"},{name:`name`,type:`string`,required:!1,advanced:!0,description:`HTML5 <details name=> group — siblings with the same name are mutually exclusive`}],hJ=[lJ[0],lJ[1],lJ[4],lJ[5],lJ[6]],gJ=[uJ[0],uJ[1],uJ[7]],_J=[mJ[0],mJ[1],mJ[4],mJ[5]],vJ=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Alt text (Obsidian alias syntax: `![[file.png|alt text]]`)"}],yJ=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[clip.mp4|title]]`)"}],bJ=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[song.mp3|title]]`)"}],xJ=[{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#install-tabs`)"}],SJ=[{name:`label`,type:`string`,required:!0,autoFocus:!0,defaultValue:`Tab`,description:`Tab strip label — shown in the clickable pill at the top`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#tab-npm`)"}],CJ=[{name:`formula`,type:`string`,required:!0,autoFocus:!0,language:`latex`,description:`LaTeX math source (rendered with KaTeX in the browser)`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#eq-pythagoras`)"},{name:`language`,type:`string`,required:!1,advanced:!0,description:"Forward-compat hint for the math source language (default `latex`). Reserved for future MathJax / Typst / AsciiMath substrates."}],wJ=[CJ[0]],TJ=[CJ[0]],EJ=[{name:`chart`,type:`string`,required:!0,hidden:!0,description:`Mermaid chart source (graph / flowchart / sequenceDiagram / class / state / etc.)`}],DJ=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Display name override (Obsidian alias syntax: `![[file.zip|label]]`)"}],OJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`File URL`,accept:[`*/*`],autoFocus:!0}],kJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`PDF source URL`,accept:BG,autoFocus:!0},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Accessible label for the embedded PDF viewer`},{name:`anchor`,type:`string`,required:!1,advanced:!0,description:"PDF viewer parameters as a single URL-fragment string (e.g. `page=3&height=600`)"}],AJ=[{name:`src`,type:`string`,required:!0,description:"Path of the source doc, extension-less (e.g. `api-spec`).",autoFocus:!0},{name:`anchor`,type:`string`,required:!0,description:"Id of the `<MirrorSource>` block within the source doc."}],jJ=[{name:`id`,type:`string`,required:!0,description:"Stable id agents and authors use to reference this block from `<Mirror>` elsewhere.",autoFocus:!0},{name:`children`,type:`reactnode`,required:!0,description:`Block content this MirrorSource owns — paragraphs, callouts, code, nested JSX, anything.`}];function MJ(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function NJ(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function PJ(e){let t=e.attrs.props,n=t?.target??``,r=typeof t?.alias==`string`&&t.alias.length>0?t.alias:null,i=typeof t?.anchor==`string`&&t.anchor.length>0?t.anchor:null,a=r??(i?`${n}#${i}`:n);return{type:`wikiLinkEmbed`,value:a,data:{target:n,anchor:i,alias:r},children:[{type:`text`,value:a}]}}const FJ=[{name:`Callout`,surface:`canonical`,hasChildren:!0,props:lJ,icon:`MessageSquareWarning`,category:`content`,displayName:`Callout`,description:`Alert / admonition with 15 type variants — 5 GFM (note, tip, important, warning, caution) plus 10 Obsidian-parity (abstract, info, todo, success, question, failure, danger, bug, example, quote)`,searchTerms:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`,`alert`,`admonition`,`callout`],serialize:(e,t)=>Yq(`Callout`,e,t,lJ)},{name:`img`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:uJ,icon:`Image`,category:`media`,displayName:`Image`,description:`Image with click-to-zoom and HTML-native attributes`,searchTerms:[`image`,`zoom`,`picture`,`photo`],placeholder:{label:`Add an image`},serialize:(e,t)=>Yq(`img`,e,t,uJ)},{name:`video`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:fJ,icon:`SquarePlay`,category:`media`,displayName:`Video`,description:`HTML5 video player with native controls`,searchTerms:[`video`,`media`,`player`,`mp4`,`webm`,`movie`],placeholder:{label:`Add a video`},serialize:(e,t)=>Yq(`video`,e,t,fJ)},{name:`audio`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:pJ,icon:`Volume2`,category:`media`,displayName:`Audio`,description:`HTML5 audio player with native controls`,searchTerms:[`audio`,`sound`,`music`,`mp3`,`podcast`,`player`],placeholder:{label:`Add audio`},serialize:(e,t)=>Yq(`audio`,e,t,pJ)},{name:`Pdf`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:kJ,icon:`FileText`,category:`media`,displayName:`PDF`,description:"Embedded PDF viewer (`#page=N` to open at page N, `#height=N` for viewer height)",searchTerms:[`pdf`,`document`,`embed`,`pdfjs`],placeholder:{label:`Add a PDF`},serialize:(e,t)=>Yq(`Pdf`,e,t,kJ)},{name:`File`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:OJ,icon:`Paperclip`,category:`media`,displayName:`File`,description:`Downloadable file attachment — inline row with name + size + download link`,searchTerms:[`file`,`attachment`,`download`,`document`,`zip`,`docx`,`doc`],placeholder:{label:`Add a file`},serialize:(e,t)=>Yq(`File`,e,t,OJ)},{name:`Embed`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:dJ,icon:`AppWindow`,category:`media`,displayName:`Embed`,description:`Inline web embed (iframe) — drop a URL, get a resizable preview pane`,searchTerms:[`embed`,`iframe`,`website`,`page`,`inline`,`frame`,`preview`],placeholder:{label:`Embed a URL`},serialize:(e,t)=>Yq(`Embed`,e,t,dJ)},{name:`Accordion`,surface:`canonical`,hasChildren:!0,props:mJ,icon:`ChevronRight`,category:`content`,displayName:`Accordion`,description:"Standalone expand/collapse via native HTML5 <details>/<summary>. Group siblings with the `name` prop for exclusive-accordion UX.",searchTerms:[`toggle`,`accordion`,`expandable`,`details`,`disclosure`,`collapse`,`fold`],exampleBody:`Body content revealed when the accordion is expanded.`,serialize:(e,t)=>Yq(`Accordion`,e,t,mJ)},{name:`Tabs`,surface:`canonical`,hasChildren:!0,emptyChildName:`Tab`,props:xJ,icon:`LayoutPanelTop`,category:`content`,displayName:`Tabs`,description:"Horizontal tab strip + active panel below. Each `<Tab>` child is one panel; clickable pills at the top switch the active one. Active selection is ephemeral (resets on reload).",searchTerms:[`tabs`,`tabbed`,`panels`,`tabgroup`,`switcher`],exampleBody:`<Tab label="One">Body of the first tab panel.</Tab>
389
+ `)}const FG=[{name:`--chart-1`,light:`oklch(0.62 0.19 259)`,dark:`oklch(0.72 0.14 259)`},{name:`--chart-2`,light:`oklch(0.58 0.14 145)`,dark:`oklch(0.73 0.13 145)`},{name:`--chart-3`,light:`oklch(0.62 0.15 70)`,dark:`oklch(0.77 0.14 70)`},{name:`--chart-4`,light:`oklch(0.55 0.18 290)`,dark:`oklch(0.72 0.16 290)`},{name:`--chart-5`,light:`oklch(0.58 0.21 25)`,dark:`oklch(0.72 0.2 25)`},{name:`--primary`,light:`oklch(0.6321 0.1983 259.59)`,dark:`#69a3ff`},{name:`--primary-foreground`,light:`oklch(0.985 0 0)`,dark:`oklch(0.205 0 0)`},{name:`--foreground`,light:`oklch(0.145 0 0)`,dark:`oklch(0.985 0 0)`},{name:`--background`,light:`oklch(1 0 0)`,dark:`oklch(0.145 0 0)`},{name:`--card`,light:`oklch(1 0 0)`,dark:`oklch(0.205 0 0)`},{name:`--card-foreground`,light:`oklch(0.145 0 0)`,dark:`oklch(0.985 0 0)`},{name:`--muted-foreground`,light:`oklch(0.556 0 0)`,dark:`oklch(0.708 0 0)`},{name:`--border`,light:`oklch(0.922 0 0)`,dark:`oklch(1 0 0 / 10%)`},{name:`--destructive`,light:`oklch(0.577 0.245 27.325)`,dark:`oklch(0.704 0.191 22.216)`},{name:`--radius`,light:`0.625rem`,dark:`0.625rem`}],IG=`localhost`,LG=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],RG=[`video/mp4`,`video/webm`,`video/ogg`],zG=[`audio/mpeg`,`audio/wav`,`audio/ogg`],BG=[`application/pdf`],VG=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`]),HG=new Set([`mp4`,`webm`,`mov`,`m4v`,`mkv`]),UG=new Set([`pdf`]),WG=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]),GG=new Set(`pdf.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),KG=new Set(`exe.bat.cmd.ps1.com.msi.vbs.js.jse.wsf.wsh.hta.sh.command.csh.ksh.bash.zsh.fish.desktop.action.workflow.html.htm.svg.xml.mhtml.svgz.dmg.pkg.mpkg.scpt.applescript.terminal.prefpane.webloc.inetloc.fileloc.jar.appimage.deb.rpm.msix.appx.ipa.apk.pif.scr.lnk.url`.split(`.`)),qG=new Set(`png.jpg.jpeg.gif.webp.avif.svg.apng.heic.heif.tiff.bmp.ico.pdf.mp4.webm.mov.m4v.mkv.avi.flv.wmv.mpeg.mpg.mp3.wav.ogg.m4a.flac.aac.opus.zip.woff.woff2.ttf.otf.eot.docx.xlsx.pptx.csv.txt.rtf.json.toml.lock`.split(`.`)),JG=new Set(`png.jpg.jpeg.gif.webp.avif.apng.heic.heif.tiff.bmp.ico.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.json.toml.lock`.split(`.`)),YG=`same-dir`,XG=new Set(`png.jpg.jpeg.gif.webp.avif.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),ZG=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`],QG=[`mp4`,`webm`,`mov`,`m4v`],$G=[`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`],eK=[`pdf`],tK=[`json`,`toml`,`lock`];function nK(e,t,n){for(let r of t)if(!n.has(r))throw Error(`${e}: ${r} is not present in canonical upload constants`)}nK(`SIDEBAR_IMAGE_ASSET_EXTENSIONS`,ZG,VG),nK(`SIDEBAR_VIDEO_ASSET_EXTENSIONS`,QG,HG),nK(`SIDEBAR_AUDIO_ASSET_EXTENSIONS`,$G,WG),nK(`SIDEBAR_PDF_ASSET_EXTENSIONS`,eK,UG),nK(`FILE_ATTACHMENT_EXTENSIONS`,[...GG],XG);const rK=new Set(ZG),iK=new Set(QG),aK=new Set($G),oK=new Set(eK),sK=new Set(tK);nK(`SIDEBAR_RENDERABLE_ASSET_EXTENSIONS`,[...new Set([...ZG,...QG,...$G,...eK,...tK])],JG);function cK(e){let t=e.toLowerCase().replace(/^\./,``);return rK.has(t)?`image`:iK.has(t)?`video`:aK.has(t)?`audio`:oK.has(t)?`pdf`:sK.has(t)?`text`:null}const lK=Ex.extend({priority:60,addAttributes(){return{...this.parent?.(),fenceDelimiter:{default:"`"},fenceLength:{default:3},meta:{default:null},sourceStyle:{default:`fenced`}}}}),uK=zx.extend({name:`emphasis`,priority:60,addAttributes(){return{...this.parent?.(),sourceDelimiter:{default:`*`}}},addInputRules(){return[rx({find:Px,type:this.type,getAttributes:{sourceDelimiter:`*`}}),rx({find:Ix,type:this.type,getAttributes:{sourceDelimiter:`_`}})]}}),dK=Nx.extend({name:`strong`,priority:60,addAttributes(){return{...this.parent?.(),sourceDelimiter:{default:`**`}}},addInputRules(){return[rx({find:Ox,type:this.type,getAttributes:{sourceDelimiter:`**`}}),rx({find:Ax,type:this.type,getAttributes:{sourceDelimiter:`__`}})]}}),fK=Ib.create({name:`escapeMark`,priority:10,excludes:``,inclusive:!1,parseHTML(){return[{tag:`span[data-escape-mark]`}]},renderHTML(){return[`span`,{"data-escape-mark":``},0]}}),pK=Vx.extend({priority:60,addAttributes(){return{...this.parent?.(),hardBreakStyle:{default:`backslash`}}}}),mK=Ux.extend({priority:60,addAttributes(){return{...this.parent?.(),headingStyle:{default:`atx`},sourceTrailingHashes:{default:null},sourceUnderlineLength:{default:null},sourceContiguousNext:{default:!1}}}}),hK=bx.create({name:`htmlBlock`,group:`block`,atom:!0,priority:60,addAttributes(){return{content:{default:``}}},parseHTML(){return[{tag:`div[data-html-block]`}]},renderHTML({node:e}){return[`div`,{"data-html-block":``,class:`html-block`},e.attrs.content]}});function gK(e){if(typeof e!=`string`||!e.startsWith(`/`))return e;let t=globalThis.window?.okDesktop?.config?.apiOrigin;return typeof t==`string`&&t?t+e:e}const _K=Gx.extend({priority:60,addAttributes(){return{...this.parent?.(),sourceUrl:{default:null,rendered:!1}}},renderHTML({HTMLAttributes:e}){let t=Dy(this.options.HTMLAttributes,e);return typeof t.src==`string`&&(t.src=gK(t.src)),[`img`,t]}}),vK=bx.create({name:`jsxComponent`,group:`block`,atom:!1,content:`block*`,isolating:!0,selectable:!0,defining:!0,priority:60,addAttributes(){return{componentName:{default:``},kind:{default:`element`},attributes:{default:[]},sourceRaw:{default:``},sourceDirty:{default:!1},props:{default:{}}}},parseHTML(){return[{tag:`div[data-jsx-component]`,getAttrs:e=>typeof e==`string`?!1:{componentName:e.getAttribute(`data-component-name`)||``,sourceRaw:e.getAttribute(`data-source-raw`)||``}}]},renderHTML({HTMLAttributes:e}){return[`div`,{"data-jsx-component":``,"data-component-name":e.componentName,"data-source-raw":e.sourceRaw},0]},addCommands(){return{insertJsxComponent:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{sourceRaw:e}})}}}),yK=bx.create({name:`jsxInline`,group:`inline`,inline:!0,atom:!1,content:`text*`,isolating:!1,selectable:!0,priority:60,addAttributes(){return{}},parseHTML(){return[{tag:`span[data-jsx-inline]`}]},renderHTML(){return[`span`,{"data-jsx-inline":``},0]}}),bK=[`https`,`http`,`mailto`,`tel`,`ftp`,`sms`],xK=bK.map(e=>`${e}:`).join(`|`);RegExp(`^(?:${xK}|\\/|#|\\?|\\.\\/|\\.\\.\\/)`,`i`);function SK(e){let t=e.trim();if(t===``)return!0;let n=t.indexOf(`:`);if(n===-1)return!0;let r=t.indexOf(`/`),i=t.indexOf(`?`),a=t.indexOf(`#`);return n>Math.min(r===-1?1/0:r,i===-1?1/0:i,a===-1?1/0:a)}const CK=new Set(bK.map(e=>`${e}:`));function wK(e){try{let t=new URL(e,`https://placeholder.invalid`);return CK.has(t.protocol.toLowerCase())}catch{return!1}}const TK=rS.extend({priority:60,addOptions(){return{openOnClick:!1,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer`},isAllowedUri:wK,validate:wK,shouldAutoLink:()=>!0}},addAttributes(){return{...this.parent?.(),linkStyle:{default:`inline`,rendered:!1},refLabel:{default:null,rendered:!1},sourceForm:{default:null,rendered:!1},target:{default:null,rendered:!1},anchor:{default:null,rendered:!1},alias:{default:null,rendered:!1},sourceUrlForm:{default:null,rendered:!1},sourceTitleMarker:{default:null,rendered:!1}}}}),EK=bx.create({name:`linkRefDef`,group:`block`,atom:!0,priority:60,addAttributes(){return{label:{default:``},href:{default:``},title:{default:null},sourceLayout:{default:null},sourceTitleMarker:{default:null}}},parseHTML(){return[{tag:`div[data-link-ref-def]`}]},renderHTML({node:e}){let{label:t,href:n,title:r}=e.attrs,i=r?`[${t}]: ${n} "${r}"`:`[${t}]: ${n}`;return[`div`,{"data-link-ref-def":``,class:`link-ref-def`},i]}});function DK(e){return e.type.name===`list`&&!e.attrs.ordered}function OK(e){return e.type.name===`list`&&!!e.attrs.ordered}function kK(e){let t=!1;return e.forEach(e=>{e.type.name===`listItem`&&e.attrs.checked!==null&&(t=!0)}),t}function AK(e,t,n,r,i,a,o){let s=_y(e=>e.type.name===`list`)(e.selection);if(s&&i(s.node)){let{$from:n,$to:i}=e.selection;return n.blockRange(i)?mp(r)(e,t):!1}if(s){if(!t)return!0;let{tr:n}=e;return n.setNodeMarkup(s.pos,void 0,{...s.node.attrs,...a}),o!==void 0&&s.node.forEach((e,t)=>{if(e.type.name===`listItem`){let r=s.pos+1+t;n.setNodeMarkup(r,void 0,{...e.attrs,...o})}}),t(n),!0}return dp(n,a)(e,void 0)?t?dp(n,a)(e,n=>{if(o){let t=n.mapping.map(e.selection.$from.pos),r=n.doc.resolve(t);for(let e=r.depth;e>0;e--){let t=r.node(e);if(t.type.name===`listItem`){n.setNodeMarkup(r.before(e),void 0,{...t.attrs,...o});break}}}t(n)}):!0:!1}const jK=bx.create({name:`list`,group:`block list`,content:`listItem+`,priority:60,addAttributes(){return{ordered:{default:!1},start:{default:1},spread:{default:!1},bulletMarker:{default:null},listMarkerDelimiter:{default:null}}},parseHTML(){return[{tag:`ul`,getAttrs:()=>({ordered:!1})},{tag:`ol`,getAttrs:e=>({ordered:!0,start:e.getAttribute(`start`)?Number(e.getAttribute(`start`)):1})}]},renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs.ordered?`ol`:`ul`,r={};return e.attrs.ordered&&e.attrs.start!==1&&(r.start=e.attrs.start),[n,Dy(t,r),0]},addCommands(){return{toggleBulletList:()=>({state:e,dispatch:t})=>{let n=e.schema.nodes.list,r=e.schema.nodes.listItem;return!n||!r?!1:AK(e,t,n,r,e=>DK(e)&&!kK(e),{ordered:!1},{checked:null})},toggleOrderedList:()=>({state:e,dispatch:t})=>{let n=e.schema.nodes.list,r=e.schema.nodes.listItem;return!n||!r?!1:AK(e,t,n,r,e=>OK(e),{ordered:!0},{checked:null})},toggleTaskList:()=>({state:e,dispatch:t})=>{let n=e.schema.nodes.list,r=e.schema.nodes.listItem;return!n||!r?!1:AK(e,t,n,r,e=>DK(e)&&kK(e),{ordered:!1},{checked:!1})}}},addInputRules(){return[ox({find:/^\s*([-+*])(?!\s*\[[ xX]\])\s$/,type:this.type,getAttributes:e=>({ordered:!1,bulletMarker:e[1]})}),ox({find:/^\s*(\d+)([.)])\s$/,type:this.type,getAttributes:e=>({ordered:!0,start:Number(e[1]),listMarkerDelimiter:e[2]})}),new Ob({find:/^\s*[-*+]\s\[([ xX])\]\s$/,handler:({state:e,range:t,match:n})=>{let r=e.schema.nodes.list;if(!r)return null;let i=n[1]!==` `,a=e.tr.delete(t.from,t.to),o=a.doc.resolve(t.from).blockRange();if(!o)return null;let s=Ed(o,r,{ordered:!1});if(!s)return null;a.wrap(o,s);let c=a.doc.resolve(a.mapping.map(t.from));for(let e=c.depth;e>0;e--){let t=c.node(e);if(t.type.name===`listItem`){a.setNodeMarkup(c.before(e),void 0,{...t.attrs,checked:i});break}}}})]},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList(),"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList(),"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),MK=bx.create({name:`listItem`,content:`paragraph block*`,defining:!0,addAttributes(){return{checked:{default:null},spread:{default:!1}}},parseHTML(){return[{tag:`li`,getAttrs:e=>{let t=e.querySelector(`input[type="checkbox"]`);return{checked:t?t.checked:null}}}]},renderHTML({node:e,HTMLAttributes:t}){return e.attrs.checked===null?[`li`,Dy(t),0]:[`li`,Dy(t,{"data-type":`taskItem`,"data-checked":e.attrs.checked?`true`:`false`}),[`label`,{contenteditable:`false`},[`input`,{type:`checkbox`,...e.attrs.checked?{checked:`checked`}:{}}]],[`div`,0]]},addNodeView(){return({node:e,getPos:t,editor:n,HTMLAttributes:r})=>{let i=document.createElement(`li`);Object.entries(Dy(r,e.attrs.checked===null?{}:{"data-type":`taskItem`,"data-checked":String(!!e.attrs.checked)})).forEach(([e,t])=>{t!=null&&i.setAttribute(e,String(t))});let a=null,o=null,s=document.createElement(`div`);return e.attrs.checked!==null&&(a=document.createElement(`label`),a.contentEditable=`false`,o=document.createElement(`input`),o.type=`checkbox`,o.checked=!!e.attrs.checked,n.isEditable||(o.disabled=!0),o.addEventListener(`change`,()=>{let r=t();r===void 0||typeof r!=`number`||n.view.dispatch(n.view.state.tr.setNodeMarkup(r,void 0,{...e.attrs,checked:o?.checked??!1}))}),a.appendChild(o),i.appendChild(a)),i.appendChild(s),{dom:i,contentDOM:s,update(t){return t.type!==e.type||t.attrs.checked!==null!=(e.attrs.checked!==null)?!1:(o&&t.attrs.checked!==null&&(o.checked=!!t.attrs.checked,i.setAttribute(`data-checked`,String(!!t.attrs.checked))),e=t,!0)}}}},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>{let{$from:e}=this.editor.state.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.name===`listItem`)return this.editor.commands.sinkListItem(this.name);return!1},"Shift-Tab":()=>{let{$from:e}=this.editor.state.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.name===`listItem`)return this.editor.commands.liftListItem(this.name);return!1}}}}),NK=jK,PK=MK,FK=bx.create({name:`mathInline`,group:`inline`,inline:!0,atom:!0,selectable:!0,priority:60,addAttributes(){return{formula:{default:``},id:{default:null},language:{default:`latex`}}},parseHTML(){return[{tag:`span[data-math-inline]`,getAttrs:e=>typeof e==`string`?!1:{formula:e.getAttribute(`data-formula`)||``,id:e.getAttribute(`id`)||null,language:e.getAttribute(`data-language`)||`latex`}}]},renderHTML({HTMLAttributes:e}){return[`span`,{"data-math-inline":``,"data-formula":e.formula,"data-language":e.language,...e.id?{id:e.id}:{}}]},addCommands(){return{insertMathInline:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{formula:e}})}}}),IK=bx.create({name:`rawMdxFallback`,group:`block`,atom:!1,content:`text*`,isolating:!0,selectable:!0,defining:!0,priority:60,addAttributes(){return{reason:{default:``},originalSpan:{default:{start:0,end:0}}}},parseHTML(){let e=e=>typeof e==`string`?!1:{reason:e.getAttribute(`data-reason`)||``};return[{tag:`div[data-raw-mdx-fallback]`,getAttrs:e},{tag:`pre[data-raw-mdx-fallback]`,getAttrs:e}]},renderHTML({HTMLAttributes:e}){return[`div`,{"data-raw-mdx-fallback":``,"data-raw-badge":`raw`,"data-reason":e.reason,contenteditable:`false`,class:`raw-mdx-fallback`},0]},addNodeView(){return({HTMLAttributes:e})=>{let t=document.createElement(`div`);t.setAttribute(`data-raw-mdx-fallback`,``),t.setAttribute(`data-raw-badge`,`raw`),t.setAttribute(`contenteditable`,`false`),t.classList.add(`raw-mdx-fallback`),e.reason&&t.setAttribute(`data-reason`,e.reason);let n=document.createElement(`pre`);return n.classList.add(`raw-mdx-fallback-content`),n.setAttribute(`contenteditable`,`false`),t.appendChild(n),{dom:t,contentDOM:n,ignoreMutation:()=>!0}}}}),LK=mw.extend({priority:60,addAttributes(){return{...this.parent?.(),sourceMarkerSpacings:{default:null}}}}),RK=vw.extend({excludes:``,addAttributes(){return{...this.parent?.(),sourceFenceChar:{default:"`"},sourceFenceLength:{default:1}}}}),zK=bx.create({name:`commentBlock`,group:`block`,content:`block+`,defining:!0,priority:60,addAttributes(){return{sourceForm:{default:`percent`,parseHTML:e=>e.getAttribute(`data-source-form`)===`html`?`html`:`percent`,renderHTML:e=>e.sourceForm===`html`?{"data-source-form":`html`}:{}},sourceLayout:{default:`block`,parseHTML:e=>e.getAttribute(`data-source-layout`)===`inline`?`inline`:`block`,renderHTML:e=>e.sourceLayout===`inline`?{"data-source-layout":`inline`}:{}}}},parseHTML(){return[{tag:`aside[data-comment-block]`},{tag:`aside.comment-block`}]},renderHTML({HTMLAttributes:e}){return[`aside`,{"data-comment-block":``,"data-clipboard-omit":`true`,class:`comment-block`,style:`display: none;`,...e},0]},addCommands(){return{setCommentBlock:()=>({commands:e})=>e.wrapIn(this.name),toggleCommentBlock:()=>({commands:e})=>e.toggleWrap(this.name),unsetCommentBlock:()=>({commands:e})=>e.lift(this.name)}}}),BK=Ib.create({name:`comment`,priority:10,excludes:``,inclusive:!1,addAttributes(){return{sourceForm:{default:`percent`,parseHTML:e=>e.getAttribute(`data-source-form`)===`html`?`html`:`percent`,renderHTML:e=>e.sourceForm===`html`?{"data-source-form":`html`}:{}}}},parseHTML(){return[{tag:`span[data-comment-mark]`}]},renderHTML({HTMLAttributes:e}){return[`span`,{"data-comment-mark":``,"data-clipboard-omit":`true`,class:`comment-mark`,style:`display: none;`,...e},0]},addCommands(){return{setComment:()=>({commands:e})=>e.setMark(this.name),toggleComment:()=>({commands:e})=>e.toggleMark(this.name),unsetComment:()=>({commands:e})=>e.unsetMark(this.name)}}}),VK=bx.create({name:`footnoteDefinition`,group:`block`,content:`block+`,defining:!0,priority:60,addAttributes(){return{identifier:{default:``},label:{default:null}}},parseHTML(){let e=e=>{if(typeof e==`string`)return!1;let t=e.getAttribute(`data-footnote-id`)||``;return{identifier:t,label:t||null}};return[{tag:`aside[data-footnote-def]`,getAttrs:e},{tag:`aside.footnote-def`,getAttrs:e}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.identifier??``);return[`aside`,{...t,"data-footnote-def":``,"data-footnote-id":n,id:`fn-${n}`,class:`footnote-def`},[`div`,{class:`footnote-body`},0],[`a`,{href:`#fnref-${n}`,class:`footnote-backref`,contentEditable:`false`,"aria-label":`Back to reference`},`↩`]]},addCommands(){return{insertFootnoteDefinition:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{identifier:e,label:e},content:[{type:`paragraph`}]})}}}),HK=bx.create({name:`footnoteReference`,group:`inline`,inline:!0,atom:!0,selectable:!0,draggable:!1,priority:60,addAttributes(){return{identifier:{default:``},label:{default:null}}},parseHTML(){return[{tag:`sup[data-footnote-ref]`,getAttrs:e=>{if(typeof e==`string`)return!1;let t=e.getAttribute(`data-footnote-id`)||``;return{identifier:t,label:t||null}}}]},renderHTML({node:e}){let t=String(e.attrs.identifier??``);return[`sup`,{id:`fnref-${t}`,"data-footnote-ref":``,"data-footnote-id":t,class:`footnote-ref`},[`a`,{href:`#fn-${t}`,class:`footnote-ref-link`},`[${t}]`]]},addCommands(){return{insertFootnoteReference:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{identifier:e,label:e}})}}}),UK=bx.create({name:`imageReference`,group:`inline`,inline:!0,atom:!0,priority:60,addAttributes(){return{alt:{default:``},label:{default:``},identifier:{default:``},referenceType:{default:`shortcut`}}},parseHTML(){return[{tag:`img[data-image-reference]`}]},renderHTML({node:e}){let{alt:t,label:n,referenceType:r}=e.attrs,i=t||n;return[`img`,{"data-image-reference":``,"data-reference-type":r,"data-label":n,alt:i}]}}),WK=Ib.create({name:`sourceLiteral`,priority:10,excludes:``,inclusive:!1,addAttributes(){return{sourceRaw:{default:``}}},parseHTML(){return[{tag:`span[data-source-literal]`}]},renderHTML({HTMLAttributes:e}){return[`span`,{"data-source-literal":``,...e},0]}});function GK(e,t){if(typeof e!=`string`||typeof t!=`string`||/[\x00-\x1F\x7F]/.test(e))return!1;let n=e.replaceAll(`\xA0`,` `),r=t.replaceAll(`\xA0`,` `);return n===r?!0:KK(n)===r}function KK(e){return e.replace(/\\([!-/:-@[-`{-~])/g,`$1`)}const qK=dw.extend({priority:60,addAttributes(){return{...this.parent?.(),sourceDashCounts:{default:null}}}}),JK=XC.extend({priority:60,addAttributes(){return{...this.parent?.(),sourcePadding:{default:null}}}}),YK=ZC.extend({priority:60,addAttributes(){return{...this.parent?.(),sourcePadding:{default:null}}}}),XK=bx.create({name:`tag`,group:`inline`,inline:!0,atom:!0,selectable:!0,priority:60,addAttributes(){return{value:{default:``}}},parseHTML(){return[{tag:`a[data-tag]`,getAttrs:e=>typeof e==`string`?!1:{value:e.getAttribute(`data-tag`)||``}}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.value??``);return[`a`,{...t,"data-tag":n,href:`#tag/${n}`,class:`tag`},`#${n}`]},addCommands(){return{insertTag:e=>({chain:t})=>t().insertContent({type:`tag`,attrs:{value:e}}).run()}}}),ZK=/^(?:---|—-|___\s|\*\*\*\s)$/;function QK(e){let t=String(e[0]??``).replace(/\s+$/,``);return t===`—-`?`---`:t}const $K=xw.extend({name:`thematicBreak`,priority:60,addAttributes(){return{...this.parent?.(),sourceRaw:{default:`---`}}},addInputRules(){return[ix({find:ZK,type:this.type,getAttributes:e=>({sourceRaw:QK(e)})})]}});function eq(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function tq(e){return e.alias?e.alias:e.anchor?`${e.target}#${e.anchor}`:e.target}const nq=bx.create({name:`wikiLink`,group:`inline`,inline:!0,atom:!0,priority:60,addAttributes(){return{target:{default:``},alias:{default:null},anchor:{default:null},resolved:{default:!1}}},parseHTML(){return[{tag:`span[data-wiki-link]`,getAttrs:e=>typeof e==`string`?!1:{target:e.getAttribute(`data-target`)||``,alias:eq(e.getAttribute(`data-alias`)),anchor:eq(e.getAttribute(`data-anchor`)),resolved:e.getAttribute(`data-resolved`)===`true`}},{tag:`a.wiki-link[data-target]`,priority:100,getAttrs:e=>{if(typeof e==`string`)return!1;let t=e.getAttribute(`data-target`)??``;return t?{target:t,alias:eq(e.getAttribute(`data-alias`)),anchor:eq(e.getAttribute(`data-anchor`)),resolved:!1}:!1}}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.target??``),r=eq(e.attrs.alias),i=eq(e.attrs.anchor),a=e.attrs.resolved===!0;return[`span`,{...t,"data-wiki-link":``,"data-target":n,"data-alias":r??``,"data-anchor":i??``,"data-resolved":a?`true`:`false`},tq({target:n,alias:r,anchor:i})]}});function rq(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0||n===t.length-1?``:t.slice(n+1).toLowerCase()}function iq(e){return e.alias?e.alias:e.anchor?`${e.target}#${e.anchor}`:e.target}const aq=[vK,IK,yK,FK,nq,bx.create({name:`wikiLinkEmbed`,group:`inline`,inline:!0,atom:!0,priority:60,addAttributes(){return{target:{default:``},alias:{default:null},anchor:{default:null},resolvedSrc:{default:null,rendered:!1,parseHTML:()=>null}}},parseHTML(){let e=e=>typeof e==`string`||!e.hasAttribute(`data-wiki-embed`)?!1:{target:e.getAttribute(`data-target`)||``,alias:eq(e.getAttribute(`data-alias`)),anchor:eq(e.getAttribute(`data-anchor`))};return[{tag:`img[data-wiki-embed]`,getAttrs:e,priority:100},{tag:`a[data-wiki-embed]`,getAttrs:e,priority:100}]},renderHTML({node:e,HTMLAttributes:t}){let n=String(e.attrs.target??``),r=eq(e.attrs.alias),i=eq(e.attrs.anchor),a=eq(e.attrs.resolvedSrc),o=rq(n);if(VG.has(o))return[`img`,{...t,"data-wiki-embed":``,"data-target":n,"data-alias":r??``,"data-anchor":i??``,src:a??n,alt:r??n}];let s=a??n;return[`a`,{...t,"data-wiki-embed":``,"data-target":n,"data-alias":r??``,"data-anchor":i??``,href:i?`${s}#${i}`:s,target:`_blank`,rel:`noopener noreferrer`},iq({target:n,alias:r,anchor:i})]}}),XK,NK,PK,uK,dK,RK,lK,LK,mK,$K,TK,hK,EK,pK,fK,WK,YT.configure({undoRedo:!1,bulletList:!1,orderedList:!1,listItem:!1,italic:!1,bold:!1,code:!1,codeBlock:!1,heading:!1,horizontalRule:!1,hardBreak:!1,link:!1,blockquote:!1,dropcursor:{color:`color-mix(in oklch, var(--primary) 50%, transparent)`,width:2}}),qK.configure({resizable:!0}),QC,YK,JK,_K.configure({inline:!0}),UK,oS,BK,zK,HK,VK],oq=/^[a-zA-Z][\w/-]*$/;function sq(e){return e.startsWith(`#`)?e.slice(1):e}function cq(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function lq(e){if(!e||e.trim()===``)return[];let{map:t}=RW(e);if(!t)return[];let n=cq(t.tags),r=[];for(let e of n){let t=sq(e);oq.test(t)?r.push(t):console.warn(`[frontmatter-tags] dropping invalid tag entry: ${JSON.stringify(e)}`)}return r}function uq(e){if(e.length===0)return{ok:!1,reason:`docName must not be empty`};if(e.trim().length===0)return{ok:!1,reason:`docName must not be blank (whitespace only)`};if(e!==e.trim())return{ok:!1,reason:`docName must not have leading or trailing whitespace`};for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return{ok:!1,reason:`docName must not contain control characters`}}if(e.includes(`..`)||e.startsWith(`/`)||e.includes(`\\`))return{ok:!1,reason:`docName must not contain "..", a leading "/", or a backslash`};for(let t of e.split(`/`)){if(t.length===0)return{ok:!1,reason:`docName must not contain empty path segments (no leading, trailing, or doubled "/")`};if(t.startsWith(`.`))return{ok:!1,reason:`docName path segments must not start with "." (hidden files are not addressable)`}}return{ok:!0}}function dq(e,t){let n=uq(e);n.ok||t.addIssue({code:`custom`,message:n.reason})}const fq=k().superRefine(dq).optional(),pq=k().min(1).superRefine(dq),mq={agentId:k().optional(),agentName:k().optional(),colorSeed:k().optional(),clientName:k().optional(),clientVersion:k().optional(),label:k().optional()},hq=k().optional(),gq=/^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,_q=Qs(`kind`,[M({kind:P(`doc`),docPath:k().min(1)}).loose(),M({kind:P(`folder`),folderPath:k()}).loose()]),vq=N([`no-remote`,`detached-head`,`branch-not-on-origin`,`non-github-remote`,`invalid-path`]),yq=Qs(`ok`,[M({ok:P(!0),shareUrl:k().min(1),sharedUrl:k().min(1),branch:k().min(1)}).loose(),M({ok:P(!1),error:vq,branch:k().min(1).optional()}).loose()]),bq=N([`user`,`org`]),xq=M({login:k().min(1),kind:bq,avatarUrl:k().optional()}).loose(),Sq=N([`auth-required`,`network`]),Cq=Qs(`ok`,[M({ok:P(!0),owners:j(xq)}).loose(),M({ok:P(!1),error:Sq}).loose()]),wq=Qs(`ok`,[M({ok:P(!0),available:Ls()}).loose(),M({ok:P(!1),error:Sq}).loose()]),Tq=N([`public`,`private`]),Eq=M({owner:k().min(1),name:k().min(1),visibility:Tq,description:k().optional()}).loose(),Dq=N([`name-conflict`,`saml-sso`,`auth-required`,`push-failed`,`init-failed`,`network`,`no-project`]),Oq=Qs(`ok`,[M({ok:P(!0),ownerLogin:k().min(1),repoName:k().min(1),cloneUrl:k().min(1),defaultBranch:k().min(1)}).loose(),M({ok:P(!1),error:Dq}).loose()]);function kq(e){return!(typeof e!=`string`||e.length===0||e.startsWith(`-`)||/[\x00-\x1F\x7F]/.test(e)||/\s/.test(e)||e.includes(`:`)||e.split(`/`).includes(`..`))}const Aq=e=>e.refine(kq,`invalid branch name`);function jq(e){if(e==null)return!1;let t=e instanceof Error?e.message:String(e);return/couldn'?t find remote ref|Remote branch .+ not found/i.test(t)}const Mq={shareTargetExists:Ls(),dirtyConflicts:M({conflicts:Ls(),files:j(k().min(1))}).loose(),branchIsLocal:Ls()},Nq=Qs(`detached`,[M({detached:P(!1),currentBranch:k().min(1).nullable(),currentHeadSha:zs(),...Mq}).loose(),M({detached:P(!0),currentBranch:zs(),currentHeadSha:k().min(1),...Mq}).loose()]),Pq=M({branch:Aq(k().min(1)),principalId:k().optional()}).loose(),Fq=N([`dirty-conflict`,`branch-not-found`,`fetch-failed`,`checkout-failed`,`branch-in-other-worktree`]),Iq=Qs(`ok`,[M({ok:P(!0)}).loose(),M({ok:P(!1),reason:Fq,files:j(k().min(1)).optional(),otherWorktreePath:k().min(1).optional()}).loose()]),Lq=M({serverInstanceId:k().min(1),currentBranch:k().min(1).optional(),currentDiskAckSVs:nc(k().min(1),k().min(1)).optional()}).loose(),Rq=M({id:k().min(1),display_name:k().min(1),display_email:k(),source:N([`git-config`,`synthesized`]),created_at:k().min(1)}).loose(),zq=M({collabUrl:k().nullable(),previewUrl:k().nullable(),port:A(),paneTarget:k().nullable()}).loose(),Bq=N(`urn:ok:error:malformed-upload.urn:ok:error:collision-exhaustion.urn:ok:error:storage-full.urn:ok:error:storage-readonly.urn:ok:error:storage-error.urn:ok:error:no-file-received.urn:ok:error:path-escape.urn:ok:error:method-not-allowed.urn:ok:error:invalid-request.urn:ok:error:payload-too-large.urn:ok:error:request-timeout.urn:ok:error:internal-server-error.urn:ok:error:loopback-required.urn:ok:error:invalid-origin.urn:ok:error:url-not-allowed.urn:ok:error:dir-outside-home.urn:ok:error:concurrent-operation.urn:ok:error:clone-failed.urn:ok:error:clone-timeout.urn:ok:error:server-start-failed.urn:ok:error:reserved-doc-name.urn:ok:error:target-not-found.urn:ok:error:stale-target.urn:ok:error:frontmatter-edit-not-supported.urn:ok:error:invalid-frontmatter-patch.urn:ok:error:frontmatter-malformed.urn:ok:error:no-active-session.urn:ok:error:too-many-agent-sessions.urn:ok:error:disk-divergence.urn:ok:error:doc-not-found.urn:ok:error:doc-already-exists.urn:ok:error:doc-not-open.urn:ok:error:rollback-not-configured.urn:ok:error:doc-not-available.urn:ok:error:backlink-index-not-configured.urn:ok:error:file-rescan-not-configured.urn:ok:error:shadow-not-configured.urn:ok:error:host-not-allowed.urn:ok:error:principal-not-available.urn:ok:error:not-found.urn:ok:error:auth-failed.urn:ok:error:no-project-dir.urn:ok:error:server-open-failed.urn:ok:error:doc-in-conflict.urn:ok:error:no-conflict-tracked.urn:ok:error:sync-not-active.urn:ok:error:project-repo-not-configured.urn:ok:error:seed-prerequisite-missing.urn:ok:error:seed-invalid-root.urn:ok:error:tag-index-not-configured.urn:ok:error:template-not-found.urn:ok:error:unsupported-asset-type.urn:ok:error:asset-not-found.urn:ok:error:collab-server-not-running.urn:ok:error:gateway-timeout.urn:ok:error:cursor-not-installed.urn:ok:error:cursor-spawn-timeout.urn:ok:error:cursor-spawn-failed.urn:ok:error:handoff-target-not-installed.urn:ok:error:handoff-spawn-timeout.urn:ok:error:handoff-spawn-failed`.split(`.`));function Vq(e){throw Error(`Unexpected ProblemType variant: ${JSON.stringify(e)}`)}const Hq=M({type:Bq,title:k().min(1),status:A().int().min(400).max(599),instance:k().regex(gq,`instance must be urn:uuid:<uuid>`).optional(),detail:k().optional()}).loose(),Uq=M({parentDocName:k().min(1),agentId:k().min(1).optional(),agentName:k().min(1).optional()}).loose(),Wq=M({src:k().min(1),path:k().min(1).optional(),deduped:Ls().optional()}).loose(),Gq=M({url:k().min(1),dir:k().min(1),branch:k().min(1).refine(kq,`invalid branch name`).optional()}).loose(),Kq=M({type:P(`error`),problem:Hq}).loose();function qq(e,t){let n=Array.isArray(e.attrs.attributes)?e.attrs.attributes.filter(e=>typeof e==`object`&&!!e&&`type`in e):[],r=e.attrs.props??{},i=new Map,a=new Set;if(t)for(let e of t)e.omitOnDefault===!0&&`defaultValue`in e&&e.defaultValue!==void 0&&i.set(e.name,e.defaultValue),e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&a.add(e.name);for(let[e,t]of Object.entries(r)){let r=n.findIndex(t=>t.type===`mdxJsxAttribute`&&t.name===e);if(i.has(e)&&Object.is(i.get(e),t)){r>=0&&n.splice(r,1);continue}if(a.has(e)&&t===``){r>=0&&n.splice(r,1);continue}let o=Jq(e,t);r>=0?n[r]=o:n.push(o)}return n}function Jq(e,t){if(t===!0)return{type:`mdxJsxAttribute`,name:e,value:null};if(t===!1)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:`false`}};if(t==null)return{type:`mdxJsxAttribute`,name:e,value:null};if(typeof t==`string`)return{type:`mdxJsxAttribute`,name:e,value:t};if(typeof t==`number`)return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:JSON.stringify(t)}};if(typeof t==`object`){let n;try{n=JSON.stringify(t)}catch{n=String(t)}return{type:`mdxJsxAttribute`,name:e,value:{type:`mdxJsxAttributeValueExpression`,value:n}}}return{type:`mdxJsxAttribute`,name:e,value:String(t)}}function Yq(e,t,n,r){return{type:`mdxJsxFlowElement`,name:e,attributes:qq(t,r),children:n.all(t),data:{}}}const Xq=/^[A-Za-z0-9]{20,}$/,Zq=/^(?:\d+s?|(?:\d+h)?(?:\d+m)?(?:\d+s)?)$/;function Qq(e){let t=e.toLowerCase();return t===`loom.com`||t===`www.loom.com`}function $q(e){let t=e.pathname.match(/^\/(?:share|embed)\/([A-Za-z0-9]+)\/?$/);if(!t)return null;let n=t[1]??``;return Xq.test(n)?n:null}function eJ(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!Qq(t.hostname))return null;let n=$q(t);if(!n)return null;let r=t.searchParams.get(`t`);return{id:n,startRaw:r&&r.length>0&&Zq.test(r)?r:null}}function tJ(e){return eJ(e)!==null}function nJ(e){let t=e.toLowerCase();return t===`vimeo.com`||t===`www.vimeo.com`||t===`player.vimeo.com`}function rJ(e){if(typeof e!=`string`||e.length===0)return!1;let t;try{t=new URL(e)}catch{return!1}return t.protocol!==`http:`&&t.protocol!==`https:`?!1:nJ(t.hostname)}const iJ=/^[A-Za-z0-9_-]{11}$/;function aJ(e){let t=e.toLowerCase();return t===`youtube.com`||t===`www.youtube.com`||t===`m.youtube.com`||t===`music.youtube.com`||t===`youtu.be`||t===`youtube-nocookie.com`||t===`www.youtube-nocookie.com`}function oJ(e){if(e.length===0)return null;if(/^[0-9]+$/.test(e)){let t=Number.parseInt(e,10);return t>0?t:null}let t=e.match(/^(?:([0-9]+)h)?(?:([0-9]+)m)?(?:([0-9]+)s?)?$/);if(!t)return null;let n=t[1]?Number.parseInt(t[1],10):0,r=t[2]?Number.parseInt(t[2],10):0,i=t[3]?Number.parseInt(t[3],10):0,a=n*3600+r*60+i;return a>0?a:null}function sJ(e){if(e.hostname.toLowerCase()===`youtu.be`){let t=e.pathname.replace(/^\//,``).split(`/`)[0]??``;return iJ.test(t)?t:null}if(e.pathname===`/watch`){let t=e.searchParams.get(`v`)??``;return iJ.test(t)?t:null}let t=e.pathname.match(/^\/(?:embed|shorts|v)\/([A-Za-z0-9_-]{11})\/?$/);return t?t[1]??null:null}function cJ(e){if(typeof e!=`string`||e.length===0)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`||!aJ(t.hostname))return null;let n=sJ(t);if(!n)return null;let r=t.searchParams.get(`t`)??t.searchParams.get(`start`)??``;return{id:n,startSeconds:r.length>0?oJ(r):null,noCookie:t.hostname.toLowerCase().endsWith(`youtube-nocookie.com`)}}const lJ=[{name:`type`,type:`enum`,enumValues:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`],defaultValue:`note`,required:!1,description:`Callout variant`},{name:`title`,type:`string`,required:!1,description:`Optional heading shown above the body`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Lightbulb`)",iconPicker:!0},{name:`color`,type:`string`,required:!1,advanced:!0,description:"Optional accent color override (hex — e.g. `#F05032`)",colorPicker:!0},{name:`collapsible`,type:`boolean`,required:!1,defaultValue:!1,advanced:!0,description:"Render as a foldable `<details>` (Obsidian `[!TYPE]+/-`)"},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,description:`When collapsible, start in the open state`,hideWhen:e=>e.collapsible!==!0},{name:`children`,type:`reactnode`,required:!0,description:`Callout content`}],uJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Image source URL`,accept:LG,autoFocus:!0},{name:`alt`,type:`string`,required:!0,description:`Alt text`},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Image width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Image height`},{name:`srcset`,type:`string`,required:!1,advanced:!0,description:`Responsive image candidate set (e.g. "x.png 1x, y.png 2x")`},{name:`sizes`,type:`string`,required:!1,advanced:!0,description:`Responsive image sizes hint paired with srcset`},{name:`loading`,type:`enum`,enumValues:[`eager`,`lazy`],defaultValue:`lazy`,required:!1,advanced:!0,omitOnDefault:!0,description:`Native img loading strategy (defaults to lazy)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`decoding`,type:`enum`,enumValues:[`sync`,`async`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Hint for how the browser should decode the image`},{name:`fetchpriority`,type:`enum`,enumValues:[`high`,`low`,`auto`],defaultValue:`auto`,required:!1,advanced:!0,omitOnDefault:!0,description:`Resource fetch priority hint`},{name:`crossorigin`,type:`enum`,enumValues:[`anonymous`,`use-credentials`],required:!1,advanced:!0,description:`CORS mode for the image fetch`},{name:`referrerpolicy`,type:`string`,required:!1,advanced:!0,description:`Referrer policy for the image fetch (HTML referrerpolicy values)`},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`}],dJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Embedded page URL (must start with http:// or https://)`,autoFocus:!0},{name:`title`,type:`string`,required:!1,description:`Iframe title (accessible label for screen readers)`},{name:`width`,type:`string`,required:!1,advanced:!0,description:`Embed width as a CSS length (e.g. "100%", "640px")`,cssLengthInput:!0},{name:`height`,type:`string`,required:!1,advanced:!0,description:`Embed height as a CSS length (e.g. "26rem", "480px")`,cssLengthInput:!0},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`}],fJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Video source URL`,accept:RG,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 video controls (defaults to true)`,hideWhen:e=>typeof e.src==`string`&&(rJ(e.src)||tJ(e.src))},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`poster`,type:`string`,required:!1,advanced:!0,description:`Poster image URL shown before playback`,accept:LG,hideWhen:e=>typeof e.src==`string`&&(rJ(e.src)||tJ(e.src))},{name:`width`,type:`number`,required:!1,advanced:!0,description:`Video width`},{name:`height`,type:`number`,required:!1,advanced:!0,description:`Video height`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`,hideWhen:e=>typeof e.src==`string`&&tJ(e.src)},{name:`playsinline`,type:`boolean`,required:!1,advanced:!0,description:`Play inline on iOS rather than entering fullscreen`,hideWhen:e=>typeof e.src==`string`&&(rJ(e.src)||tJ(e.src))},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the video to preload`,hideWhen:e=>typeof e.src==`string`&&(cJ(e.src)!==null||rJ(e.src)||tJ(e.src))},{name:`align`,type:`enum`,enumValues:[`center`,`left`,`right`],defaultValue:`center`,required:!1,omitOnDefault:!0,description:`Alignment within the column`}],pJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`Audio source URL`,accept:zG,autoFocus:!0},{name:`controls`,type:`boolean`,required:!1,defaultValue:!0,advanced:!0,omitOnDefault:!0,description:`Show native HTML5 audio controls (defaults to true)`},{name:`autoplay`,type:`boolean`,required:!1,advanced:!0,description:`Begin playback as soon as possible (usually requires muted)`},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Native HTML title attribute (tooltip)`},{name:`muted`,type:`boolean`,required:!1,advanced:!0,description:`Mute audio on load`},{name:`loop`,type:`boolean`,required:!1,advanced:!0,description:`Restart from the beginning when playback ends`},{name:`preload`,type:`enum`,enumValues:[`none`,`metadata`,`auto`],required:!1,advanced:!0,description:`Hint for how much of the audio to preload`}],mJ=[{name:`title`,type:`string`,required:!0,description:`Accordion heading shown inside the <summary>`},{name:`defaultOpen`,type:`boolean`,required:!1,defaultValue:!1,description:`When true, the accordion renders expanded on initial load`},{name:`icon`,type:`string`,required:!1,advanced:!0,description:"Custom lucide icon override (e.g. `lucide:Rocket`)",iconPicker:!0},{name:`description`,type:`string`,required:!1,advanced:!0,description:`Optional subtitle rendered below the title inside <summary>`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#advanced-options`)"},{name:`name`,type:`string`,required:!1,advanced:!0,description:`HTML5 <details name=> group — siblings with the same name are mutually exclusive`}],hJ=[lJ[0],lJ[1],lJ[4],lJ[5],lJ[6]],gJ=[uJ[0],uJ[1],uJ[7]],_J=[mJ[0],mJ[1],mJ[4],mJ[5]],vJ=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Alt text (Obsidian alias syntax: `![[file.png|alt text]]`)"}],yJ=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[clip.mp4|title]]`)"}],bJ=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Title text (Obsidian alias syntax: `![[song.mp3|title]]`)"}],xJ=[{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#install-tabs`)"}],SJ=[{name:`label`,type:`string`,required:!0,autoFocus:!0,defaultValue:`Tab`,description:`Tab strip label — shown in the clickable pill at the top`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#tab-npm`)"}],CJ=[{name:`formula`,type:`string`,required:!0,autoFocus:!0,language:`latex`,description:`LaTeX math source (rendered with KaTeX in the browser)`},{name:`id`,type:`string`,required:!1,advanced:!0,description:"HTML id attribute for deep-linking (e.g. `#eq-pythagoras`)"},{name:`language`,type:`string`,required:!1,advanced:!0,description:"Forward-compat hint for the math source language (default `latex`). Reserved for future MathJax / Typst / AsciiMath substrates."}],wJ=[CJ[0]],TJ=[CJ[0]],EJ=[{name:`chart`,type:`string`,required:!0,hidden:!0,description:`Mermaid chart source (graph / flowchart / sequenceDiagram / class / state / etc.)`}],DJ=[{name:`alias`,type:`string`,required:!1,defaultValue:``,description:"Display name override (Obsidian alias syntax: `![[file.zip|label]]`)"}],OJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`File URL`,accept:[`*/*`],autoFocus:!0}],kJ=[{name:`src`,type:`string`,required:!0,defaultValue:``,description:`PDF source URL`,accept:BG,autoFocus:!0},{name:`title`,type:`string`,required:!1,advanced:!0,description:`Accessible label for the embedded PDF viewer`},{name:`anchor`,type:`string`,required:!1,advanced:!0,description:"PDF viewer parameters as a single URL-fragment string (e.g. `page=3&height=600`)"}],AJ=[{name:`src`,type:`string`,required:!0,description:"Path of the source doc, extension-less (e.g. `api-spec`).",autoFocus:!0},{name:`anchor`,type:`string`,required:!0,description:"Id of the `<MirrorSource>` block within the source doc."}],jJ=[{name:`id`,type:`string`,required:!0,description:"Stable id agents and authors use to reference this block from `<Mirror>` elsewhere.",autoFocus:!0},{name:`children`,type:`reactnode`,required:!0,description:`Block content this MirrorSource owns — paragraphs, callouts, code, nested JSX, anything.`}];function MJ(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function NJ(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function PJ(e){let t=e.attrs.props,n=t?.target??``,r=typeof t?.alias==`string`&&t.alias.length>0?t.alias:null,i=typeof t?.anchor==`string`&&t.anchor.length>0?t.anchor:null,a=r??(i?`${n}#${i}`:n);return{type:`wikiLinkEmbed`,value:a,data:{target:n,anchor:i,alias:r},children:[{type:`text`,value:a}]}}const FJ=[{name:`Callout`,surface:`canonical`,hasChildren:!0,props:lJ,icon:`MessageSquareWarning`,category:`content`,displayName:`Callout`,description:`Alert / admonition with 15 type variants — 5 GFM (note, tip, important, warning, caution) plus 10 Obsidian-parity (abstract, info, todo, success, question, failure, danger, bug, example, quote)`,searchTerms:[`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`,`alert`,`admonition`,`callout`],serialize:(e,t)=>Yq(`Callout`,e,t,lJ)},{name:`img`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:uJ,icon:`Image`,category:`media`,displayName:`Image`,description:`Image with click-to-zoom and HTML-native attributes`,searchTerms:[`image`,`zoom`,`picture`,`photo`],placeholder:{label:`Add an image`},serialize:(e,t)=>Yq(`img`,e,t,uJ)},{name:`video`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:fJ,icon:`SquarePlay`,category:`media`,displayName:`Video`,description:`HTML5 video player with native controls`,searchTerms:[`video`,`media`,`player`,`mp4`,`webm`,`movie`],placeholder:{label:`Add a video`},serialize:(e,t)=>Yq(`video`,e,t,fJ)},{name:`audio`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:pJ,icon:`Volume2`,category:`media`,displayName:`Audio`,description:`HTML5 audio player with native controls`,searchTerms:[`audio`,`sound`,`music`,`mp3`,`podcast`,`player`],placeholder:{label:`Add audio`},serialize:(e,t)=>Yq(`audio`,e,t,pJ)},{name:`Pdf`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:kJ,icon:`FileText`,category:`media`,displayName:`PDF`,description:"Embedded PDF viewer (`#page=N` to open at page N, `#height=N` for viewer height)",searchTerms:[`pdf`,`document`,`embed`,`pdfjs`],placeholder:{label:`Add a PDF`},serialize:(e,t)=>Yq(`Pdf`,e,t,kJ)},{name:`File`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:OJ,icon:`Paperclip`,category:`media`,displayName:`File`,description:`Downloadable file attachment — inline row with name + size + download link`,searchTerms:[`file`,`attachment`,`download`,`document`,`zip`,`docx`,`doc`],placeholder:{label:`Add a file`},serialize:(e,t)=>Yq(`File`,e,t,OJ)},{name:`Embed`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:dJ,icon:`AppWindow`,category:`media`,displayName:`Embed`,description:`Inline web embed (iframe) — drop a URL, get a resizable preview pane`,searchTerms:[`embed`,`iframe`,`website`,`page`,`inline`,`frame`,`preview`],placeholder:{label:`Embed a URL`},serialize:(e,t)=>Yq(`Embed`,e,t,dJ)},{name:`Accordion`,surface:`canonical`,hasChildren:!0,props:mJ,icon:`ChevronRight`,category:`content`,displayName:`Accordion`,description:"Standalone expand/collapse via native HTML5 <details>/<summary>. Group siblings with the `name` prop for exclusive-accordion UX.",searchTerms:[`toggle`,`accordion`,`expandable`,`details`,`disclosure`,`collapse`,`fold`],exampleBody:`Body content revealed when the accordion is expanded.`,serialize:(e,t)=>Yq(`Accordion`,e,t,mJ)},{name:`Tabs`,surface:`canonical`,hasChildren:!0,emptyChildName:`Tab`,props:xJ,icon:`LayoutPanelTop`,category:`content`,displayName:`Tabs`,description:"Horizontal tab strip + active panel below. Each `<Tab>` child is one panel; clickable pills at the top switch the active one. Active selection is ephemeral (resets on reload).",searchTerms:[`tabs`,`tabbed`,`panels`,`tabgroup`,`switcher`],exampleBody:`<Tab label="One">Body of the first tab panel.</Tab>
390
390
  <Tab label="Two">Body of the second tab panel.</Tab>`,serialize:(e,t)=>Yq(`Tabs`,e,t,xJ)},{name:`Tab`,surface:`canonical`,hasChildren:!0,props:SJ,icon:`PanelTop`,category:`content`,displayName:`Tab`,description:"A single tab panel inside a `<Tabs>` container — carries the strip label and the block-content body.",searchTerms:[`tab`,`panel`],exampleBody:"Panel content — must be nested inside a `<Tabs>` parent.",serialize:(e,t)=>Yq(`Tab`,e,t,SJ)},{name:`Math`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:CJ,icon:`Sigma`,category:`content`,displayName:`Math`,description:`Block math equation rendered with KaTeX from a LaTeX source string`,searchTerms:[`math`,`latex`,`equation`,`formula`,`katex`,`tex`],serialize:(e,t)=>Yq(`Math`,e,t,CJ)},{name:`MermaidFence`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:EJ,icon:`Workflow`,category:`content`,displayName:`Mermaid`,description:"Diagram rendered from Mermaid source (flowchart, sequence, class, state, ER, gantt, pie). Authored exclusively as ` ```mermaid ` fenced code.",searchTerms:[`mermaid`,`diagram`,`flowchart`,`graph`,`sequence`,`sequencediagram`,`class`,`state`,`er`,`erdiagram`,`gantt`,`pie`,`chart`],serialize:e=>({type:`code`,lang:`mermaid`,meta:null,value:e.attrs.props?.chart??``})},{name:`Mirror`,surface:`canonical`,hasChildren:!1,isSelfClosing:!0,props:AJ,icon:`CopyPlus`,category:`content`,displayName:`Mirror`,description:"Render a read-only copy of a `<MirrorSource>` block from another doc. Use to keep the same content in sync across multiple docs without copy-paste — edits land at the source, every Mirror reflects the change.",searchTerms:[`mirror`,`sync`,`synced`,`transclude`,`embed`,`reference`,`shared block`],serialize:(e,t)=>Yq(`Mirror`,e,t,AJ)},{name:`MirrorSource`,surface:`canonical`,hasChildren:!0,props:jJ,icon:`GitBranch`,category:`content`,displayName:`Mirror Source`,description:'Mark a block as the source of truth for content that appears in multiple docs. Wrap any block content; `<Mirror src="…" anchor="<id>">` references render this verbatim read-only at every call-site. Edit here, propagate everywhere.',searchTerms:[`mirror source`,`sync source`,`source block`,`master block`,`shared`],exampleBody:"Authoritative content lives inside this block — edits here propagate to every `<Mirror>` that references this id.",serialize:(e,t)=>Yq(`MirrorSource`,e,t,jJ)},{name:`GFMCallout`,surface:`compat`,hasChildren:!0,props:hJ,icon:`MessageSquareWarning`,category:`content`,displayName:`GFM Callout`,description:"GFM blockquote alert (`> [!NOTE]`) — read-only compat. Preserves `> [!NOTE]` syntax on round-trip; insert a fresh Callout block for the full prop surface.",rendersAs:`Callout`,translateProps:e=>e,serialize:(e,t)=>{let n=e.attrs.props,r=new Set([`note`,`tip`,`important`,`warning`,`caution`,`abstract`,`info`,`todo`,`success`,`question`,`failure`,`danger`,`bug`,`example`,`quote`]),i=n?.type??`note`;return{type:`blockquote`,children:[{type:`html`,value:`[!${(r.has(i.toLowerCase())?i:`note`).toUpperCase()}]${n?.collapsible?n.defaultOpen===!1?`-`:`+`:``}${n?.title?` ${n.title}`:``}`},...t.all(e).filter(e=>{if(e.type!==`paragraph`)return!0;let t=e;return Array.isArray(t.children)&&t.children.length>0})]}}},{name:`CommonMarkImage`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:gJ,icon:`Image`,category:`media`,displayName:`CommonMark Image`,description:'CommonMark image (`![alt](src "title")`) — read-only compat. Preserves `![alt](src)` syntax on round-trip; insert a fresh Image block for the full HTML-native attribute surface (srcset, sizes, decoding, etc.).',rendersAs:`img`,translateProps:e=>e,serialize:e=>{let t=e.attrs.props;return{type:`paragraph`,children:[{type:`image`,url:t?.sourceUrl??t?.src??``,alt:t?.alt??``,title:t?.title??null}]}}},{name:`WikiEmbedImage`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:vJ,icon:`ZoomIn`,category:`media`,displayName:`Wiki Embed Image`,description:"Obsidian-style `![[file.png]]` wiki-embed — read-only compat. Edit the alt-text via the alias slot; the embed target / anchor stay on the prop bag and round-trip byte-identical.",rendersAs:`img`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.target==`string`?e.target:``;return{src:e.src,alt:t??n}},serialize:PJ},{name:`WikiEmbedVideo`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:yJ,icon:`Film`,category:`media`,displayName:`Wiki Embed Video`,description:"Obsidian-style `![[clip.mp4]]` wiki-embed — read-only compat. Edit the title via the alias slot; the embed target / anchor stay on the prop bag and round-trip byte-identical.",rendersAs:`video`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.target==`string`?e.target:``;return{src:e.src,title:t??n}},serialize:PJ},{name:`WikiEmbedAudio`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:bJ,icon:`Volume2`,category:`media`,displayName:`Wiki Embed Audio`,description:"Obsidian-style `![[song.mp3]]` wiki-embed — read-only compat. Edit the title via the alias slot; the embed target / anchor stay on the prop bag and round-trip byte-identical.",rendersAs:`audio`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.target==`string`?e.target:``;return{src:e.src,title:t??n}},serialize:PJ},{name:`WikiEmbedFile`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:DJ,icon:`Paperclip`,category:`media`,displayName:`Wiki Embed File`,description:"Obsidian-style `![[file.zip]]` wiki-embed — read-only compat for arbitrary downloadable attachments. Renders through the `File` canonical (inline row with file-up icon + bold name + optional dim size). Edit the display name via the alias slot.",rendersAs:`File`,translateProps:e=>{let t=typeof e.alias==`string`&&e.alias.length>0?e.alias:null,n=typeof e.size==`string`&&e.size.length>0?e.size:null;return{src:e.src,name:t??void 0,size:n??void 0}},serialize:PJ},{name:`HtmlDetailsAccordion`,surface:`compat`,hasChildren:!0,props:_J,icon:`ChevronRight`,category:`content`,displayName:`HTML5 Details`,description:"HTML5 `<details><summary>` collapsible — read-only compat. Preserves `<details>` syntax on round-trip; insert a fresh Accordion block for icon / description / group-name props.",rendersAs:`Accordion`,translateProps:e=>e,serialize:(e,t)=>{let n=e.attrs.props,r=n?.defaultOpen?` open`:``,i=n?.name?` name="${MJ(n.name)}"`:``,a=n?.id?` id="${MJ(n.id)}"`:``,o=n?.title?.trim(),s=o?`<summary>${NJ(o)}</summary>`:``;return{type:`mdxJsxFlowElement`,name:`HtmlDetailsAccordion`,attributes:[],children:t.all(e),data:{htmlBoundary:{opener:`<details${r}${i}${a}>\n${s}`,closer:`</details>`}}}}},{name:`DollarMath`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:wJ,icon:`Sigma`,category:`content`,displayName:`Dollar Math`,description:"Block math via `$$…$$` syntax — read-only compat. Preserves `$$…$$` form on round-trip; insert a fresh Math block for the full prop surface (id, language).",rendersAs:`Math`,translateProps:e=>e,serialize:e=>({type:`math`,value:e.attrs.props?.formula??``})},{name:`MathFence`,surface:`compat`,hasChildren:!1,isSelfClosing:!0,props:TJ,icon:`Sigma`,category:`content`,displayName:`Math Fence`,description:"Block math via ` ```math ` fenced code syntax — read-only compat. Preserves the fence form on round-trip; insert a fresh Math block for the full prop surface (id, language).",rendersAs:`Math`,translateProps:e=>e,serialize:e=>({type:`code`,lang:`math`,meta:null,value:e.attrs.props?.formula??``})}],IJ={name:`*`,surface:`canonical`,hasChildren:!0,props:[],description:`Unregistered component — children editable as markdown`,serialize:(e,t)=>Yq(e.attrs.componentName||`*`,e,t)};function LJ(){let e=new Map;e.set(`*`,IJ);for(let t of FJ)e.set(t.name,t);return{get(t){return e.get(t)},getOrWildcard(t){return e.get(t)??e.get(`*`)},set(t,n){e.set(t,n)},has(t){return e.has(t)},entries(){return e.entries()}}}function RJ(){let e=globalThis;return e.__okYpsCounters||={block:0,inline:0},e.__okYpsCounters}const zJ={parseFallback:{blockLevel:0,wholeDoc:0},jsxRenderFailure:{},jsxAutoConvertFailed:{},jsxAutoConvertSucceeded:{},jsxPropDropped:{},jsxMoveFailed:{},jsxStuckCopyFailed:{},jsxStuckDeleteFailed:{},jsxPopoverCloseRestoreFailed:{},jsxKeyboardDeleteFailed:{},blockGripClickSelectFailed:{},jsxArrowNodeSelectFailed:{}};function BJ(){zJ.parseFallback.blockLevel++}function VJ(){zJ.parseFallback.wholeDoc++}function HJ(){let e=RJ();return{parseFallback:{...zJ.parseFallback},ypsMismatch:{block:e.block,inline:e.inline},jsxRenderFailure:{...zJ.jsxRenderFailure},jsxAutoConvertFailed:{...zJ.jsxAutoConvertFailed},jsxAutoConvertSucceeded:{...zJ.jsxAutoConvertSucceeded},jsxPropDropped:{...zJ.jsxPropDropped},jsxMoveFailed:{...zJ.jsxMoveFailed},jsxStuckCopyFailed:{...zJ.jsxStuckCopyFailed},jsxStuckDeleteFailed:{...zJ.jsxStuckDeleteFailed},jsxPopoverCloseRestoreFailed:{...zJ.jsxPopoverCloseRestoreFailed},jsxKeyboardDeleteFailed:{...zJ.jsxKeyboardDeleteFailed},blockGripClickSelectFailed:{...zJ.blockGripClickSelectFailed},jsxArrowNodeSelectFailed:{...zJ.jsxArrowNodeSelectFailed}}}const UJ=/^(`{3,}|~{3,})/gm;function WJ(e){let t=[],n=null;for(let r of e.matchAll(UJ)){let e=r[1],i=r.index;n?e[0]===n.marker[0]&&e.length>=n.marker.length&&(t.push([n.offset,i+r[0].length]),n=null):n={marker:e,offset:i}}return n&&t.push([n.offset,e.length]),t}function GJ(e,t){return t.some(([t,n])=>e>=t&&e<n)}const KJ=/^[ \t]{0,3}\[([^\]]+)\]:\s*(\S+)(\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*$/gm;function qJ(e){let t=WJ(e),n=[];for(let r of e.matchAll(KJ))GJ(r.index,t)||n.push(r[0].trimEnd());return n.length>0?`${n.join(`
391
391
  `)}\n\n`:``}function JJ(e,t){let n={startMs:typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),calls:0};return ZJ(e,t.parse,0,n)}function YJ(e){return e.calls>=1e3?!0:(typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now())-e.startMs>=500}function XJ(e){return e instanceof Error?{name:e.name,message:e.message.slice(0,500),stack:e.stack?.split(`
392
392
  `).slice(0,4).join(`
@@ -424,5 +424,5 @@ $2`).split(`
424
424
  `;return l.join(f)},table(e,t,n,r){let i=n.enter(`table`),a=[],o=[],s=e.children??[];for(let e of s){let t=e.children??[],i=[],s=[];for(let e of t){let t=n.enter(`tableCell`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,{...r,before:` `,after:` `});a(),t(),i.push(o);let c=e.data?.sourcePadding;s.push(c&&typeof c.left==`number`&&typeof c.right==`number`?{left:c.left,right:c.right}:null)}a.push(i),o.push(s)}i();let c=e.align??[],l=e.data?.sourceDashCounts,u=a[0]?.length??0,d=a.slice(1).reduce((e,t)=>Math.max(e,t.length),0),f=Math.max(u,d,c.length),p=[];for(let e=0;e<f;e++){let t=c[e],n=``,r=``;t===`center`?(n=`:`,r=`:`):t===`left`?n=`:`:t===`right`&&(r=`:`);let i=l?.[e],a=typeof i==`number`&&i>=1?i:1;p.push(n+`-`.repeat(a)+r)}let m=(e,t)=>{let n=[];for(let r=0;r<f;r++){let i=e[r]??``,a=t[r]??{left:1,right:1};n.push(` `.repeat(a.left)+i+` `.repeat(a.right))}return`|${n.join(`|`)}|`},h=Array.from({length:f},()=>null);if(a.length===0)return m(p,h);let g=[];g.push(m(a[0],o[0]??[])),g.push(m(p,h));for(let e=1;e<a.length;e++)g.push(m(a[e],o[e]??[]));return g.join(`
425
425
  `)},mdxJsxFlowElement(e,t,n,r){let i=e,a=i.data?.sourceRaw;if(typeof a==`string`)return a;let o=i.data?.htmlBoundary;if(o&&typeof o.opener==`string`&&typeof o.closer==`string`){let e=n.containerFlow({type:`root`,children:i.children??[]},r);return`${o.opener}\n\n${e}\n\n${o.closer}`}let s=i.name??``,c=jZ(i.attributes??[]);if(!i.children||i.children.length===0)return s?c?`<${s} ${c} />`:`<${s} />`:``;let l=c?`<${s} ${c}>`:`<${s}>`,u=`</${s}>`;return`${l}\n\n${n.containerFlow({type:`root`,children:i.children},r)}\n\n${u}`},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),o+=i.move(`==`),a(),o},comment(e,t,n,r){let i=e.data?.sourceForm,a=i===`html`?`<!-- `:`%%`,o=i===`html`?` -->`:`%%`,s=n.createTracker(r),c=n.enter(`comment`),l=s.move(a);return l+=n.containerPhrasing(e,{before:l,after:o,...s.current()}),l+=s.move(o),c(),l},commentBlock(e,t,n,r){let i=n.createTracker(r),a=n.enter(`commentBlock`),o=e.children??[],s=e.data?.sourceForm,c=e.data?.sourceLayout,l=o.length===1&&o[0]?.type===`paragraph`;if(s===`html`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`<!-- `,after:` -->`,...i.current()});return a(),`<!-- ${t} -->`}if(c===`inline`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`%% `,after:` %%`,...i.current()});return a(),`%% ${t} %%`}let u=n.containerFlow(e,i.current());return a(),`%%\n\n${u}\n\n%%`},mdxJsxTextElement(e){let t=e.data?.sourceRaw;if(typeof t==`string`)return t;let n=e.name??``,r=jZ(e.attributes??[]);return r?`<${n} ${r} />`:`<${n}/>`},rawMdxFallback(e){return e.value??``},blockquote(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.containerFlow(e,a.current());i();let s=e.data?.sourceMarkerSpacings,c=0;return n.indentLines(o,(e,t,n)=>n?`>`:s?.[c++]===`none`?`>${e}`:`> ${e}`)}};function jZ(e){let t=[];for(let n of e){if(n.type===`mdxJsxExpressionAttribute`){t.push(`{${n.value}}`);continue}let e=n.name;if(n.value===null||n.value===void 0){t.push(e);continue}if(typeof n.value==`string`){if(n.value.includes(`"`)){let r=n.value.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`);t.push(`${e}={"${r}"}`)}else t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function MZ(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function NZ(e){if(!e)return``;let t=0,n=!0;for(let r of e)r===`(`?t++:r===`)`&&(t--,t<0&&(n=!1));return t!==0&&(n=!1),n?e:e.replace(/[\\()]/g,`\\$&`)}function PZ(e){return e.replace(/(?<!\\)&(?=[A-Za-z][A-Za-z0-9]*;|#[0-9]+;|#[xX][0-9A-Fa-f]+;)/g,`\\&`)}function FZ(e,t,n){let r=e.unsafe;e.unsafe=r.filter(e=>!(e.character===`&`&&e.after===`[#A-Za-z]`||e.character===`<`||e.character===`[`||e.character===`(`||e.character==="`"));let i;try{i=e.safe(t,n)}finally{e.unsafe=r}return PZ(i)}function IZ(e){if(!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KiB`,`MiB`,`GiB`,`TiB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(1).replace(/\.0$/,``)} ${t[r]}`}var LZ=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};constructor(e){this.schema=Ly(e.extensions),this.handlers=qZ(this.schema,this.parseCtx);let{nodeHandlers:t,markHandlers:n}=JZ(this.schema);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=xZ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=SZ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers,toMarkdownHandlers:AZ})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return CZ(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?wZ(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?JJ(e,{parse:e=>this.parse(e,t)}):{type:`doc`,content:[{type:`paragraph`,content:[]}]}}serialize(e){let t;try{t=this.schema.nodeFromJSON(e)}catch(t){let n=`MarkdownManager.serialize() failed: schema rejected JSONContent (type=${e.type}, childCount=${e.content?.length??0})`;throw Error(n,{cause:t})}return TZ(t,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}};const RZ=LJ();function zZ(e,t){let n=new Map;for(let e of t)n.set(e.name,e);let r={};for(let t of e){if(t.type===`mdxJsxExpressionAttribute`)continue;let e=t.name,i=n.get(e);if(t.value===null||t.value===void 0){r[e]=!0;continue}if(typeof t.value==`string`){if(i?.type===`number`){let n=Number(t.value);r[e]=Number.isNaN(n)?t.value:n}else i?.type===`boolean`?r[e]=t.value===`true`:r[e]=t.value;continue}let a=t.value.value;try{r[e]=JSON.parse(a)}catch{r[e]=a}}return r}function BZ(e){let t=!1;return e.descendants(e=>t||e.type.name===`jsxInline`?!1:e.type.name===`jsxComponent`&&e.attrs.sourceDirty?(t=!0,!1):!0),t}function VZ(e){return e.attrs.sourceDirty||BZ(e)}function HZ(e){if(e.type!==`paragraph`)return!1;let t=e.children??[];return t.length===0?!0:t.every(e=>e.type===`text`&&e.value===``)}function UZ(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),Object.keys(n).length===0?e:{...e,data:n}}function WZ(e,t){if(e.length===0)return UZ({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return UZ({type:`inlineCode`,value:e.map(e=>e.value).join(``)},t);if(e.length===1&&`children`in e[0]){let n=e[0];return{...n,children:[WZ(n.children,t)]}}return UZ({type:`inlineCode`,value:GZ(e)},t)}function GZ(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=GZ(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const KZ=VG;function qZ(e,t){let n=e.nodes,r=e.marks,i={};n.paragraph&&(i.paragraph=(e,t,r)=>{let i=r.all(e).flat(),a=i.some(e=>e?.isBlock&&!e?.isInline),o=i.some(e=>e?.isInline||e?.isText||e?.isTextblock);if(a&&!o)return i.length===1?i[0]:i;if(a&&o){let e=i.filter(e=>!e?.isBlock||e?.isInline),t=i.filter(e=>e?.isBlock&&!e?.isInline),r=[],a=n.paragraph.createAndFill(null,e.length>0?e:null);return a&&r.push(a),r.push(...t),r.length===1?r[0]:r}return n.paragraph.createAndFill(null,i.length>0?i:null)}),n.blockquote&&(i.blockquote=JL(n.blockquote,e=>({sourceMarkerSpacings:e.data?.sourceMarkerSpacings??null}))),n.tableCell&&(i.tableCell=(e=>(t,r,i)=>{let a=i.all(t).flat();if(a.length>0&&n.paragraph){let t=n.paragraph.create(null,a);return e.createAndFill(null,[t])}return e.createAndFill(null,null)})(n.tableCell)),n.tableRow&&(i.tableRow=JL(n.tableRow)),n.table&&n.tableRow&&n.tableCell&&(i.table=(e,t,r)=>{let i=e.align??[],a=e.children??[],o=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type!==`tableRow`)continue;let s=t.children??[],c=[];for(let t=0;t<s.length;t++){let a=s[t];if(a.type!==`tableCell`)continue;let o=r.all(a).flat(),l=o.length>0&&n.paragraph?[n.paragraph.create(null,o)]:null,u=i[t]??null,d=e===0&&n.tableHeader?n.tableHeader:n.tableCell,f=a.data?.sourcePadding??null,p=d.createAndFill({align:u,sourcePadding:f},l);p&&c.push(p)}let l=n.tableRow.createAndFill(null,c.length>0?c:null);l&&o.push(l)}let s=e.data?.sourceDashCounts??null;return n.table.createAndFill({sourceDashCounts:s},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=kZ(r,t.current.sourcePath);return n.image.createAndFill({src:i,alt:e.alt??null,title:e.title??null,sourceUrl:i===r?null:r})},n.imageReference?i.imageReference=e=>n.imageReference.createAndFill({alt:e.alt??``,label:e.label??e.identifier??``,identifier:e.identifier??``,referenceType:e.referenceType??`shortcut`}):i.imageReference=e=>n.image.createAndFill({src:``,alt:e.alt??null,title:null})),r.escapeMark&&(i.text=t=>{let n=t.value??``,i=typeof t.data?.sourceRaw==`string`?t.data.sourceRaw:null;if(!n&&!i)return null;if(i){let t=n.replaceAll(`\xA0`,` `);return r.sourceLiteral?e.text(t,[r.sourceLiteral.create({sourceRaw:i})]):e.text(t)}let a=t.data?.escapedChars,o=t.data?.entityRefSpans;if(!a?.length&&!o?.length)return e.text(n.replaceAll(`\xA0`,` `));let s=[...(a??[]).map(e=>({kind:`escape`,offset:e.offset,length:1})),...(o??[]).map(e=>({kind:`entity`,offset:e.offset,length:e.length,raw:e.raw}))];s.sort((e,t)=>e.offset-t.offset);let c=[],l=0;for(let t of s){if(t.offset>l){let r=n.slice(l,t.offset).replaceAll(`\xA0`,` `);r&&c.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length).replaceAll(`\xA0`,` `);i&&(t.kind===`escape`?c.push(e.text(i,[r.escapeMark.create()])):r.sourceLiteral?c.push(e.text(i,[r.sourceLiteral.create({sourceRaw:t.raw})])):c.push(e.text(i))),l=t.offset+t.length}}if(l<n.length){let t=n.slice(l).replaceAll(`\xA0`,` `);t&&c.push(e.text(t))}return c.length===1?c[0]:c}),r.code&&(i.inlineCode=t=>e.text(t.value,[r.code.create({sourceFenceChar:t.data?.sourceFenceChar??"`",sourceFenceLength:typeof t.data?.sourceFenceLength==`number`?t.data.sourceFenceLength:1})]));let a=r.strike??r.delete;if(a&&(i.delete=YL(a)),r.highlight&&(i.mark=YL(r.highlight)),r.comment&&(i.comment=YL(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=JL(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=YL(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=YL(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=JL(n.heading,e=>({level:e.depth,headingStyle:e.data?.sourceStyle??`atx`,sourceTrailingHashes:e.data?.sourceTrailingHashes??null,sourceUnderlineLength:e.data?.sourceUnderlineLength??null,sourceContiguousNext:e.data?.sourceContiguousNext??!1}))),n.codeBlock&&(i.code=t=>{let r=t.value?[e.text(t.value)]:[];return n.codeBlock.createAndFill({language:t.lang??null,meta:t.meta??null,fenceDelimiter:t.data?.sourceFenceChar??"`",fenceLength:t.data?.sourceFenceLength??3,sourceStyle:t.data?.sourceStyle??`fenced`},r)}),n.thematicBreak&&(i.thematicBreak=e=>n.thematicBreak.createAndFill({sourceRaw:e.data?.sourceRaw??`---`})),n.hardBreak&&(i.break=e=>n.hardBreak.createAndFill({hardBreakStyle:e.data?.sourceStyle??`spaces`})),n.list&&(i.list=JL(n.list,e=>({ordered:!!e.ordered,start:e.start??1,spread:!!e.spread,bulletMarker:e.data?.bulletMarker??null,listMarkerDelimiter:e.data?.listMarkerDelimiter??null}))),n.listItem&&(i.listItem=JL(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread}))),r.link){let t=r.sourceLiteral;i.link=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[](${n.url??``})`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.url??``,title:n.title??null,linkStyle:n.data?.sourceStyle??`inline`,refLabel:null,sourceUrlForm:n.data?.sourceUrlForm??null,sourceTitleMarker:n.data?.sourceTitleMarker??null});return o.map(e=>e.mark(s.addToSet(e.marks)))},i.linkReference=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[${n.label??``}][${n.identifier??``}]`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:``,title:null,linkStyle:n.referenceType??`shortcut`,refLabel:n.label??n.identifier??null});return o.map(e=>e.mark(s.addToSet(e.marks)))}}n.htmlBlock&&(i.html=e=>n.htmlBlock.createAndFill({content:e.value??``}));let o=n.linkDefinition??n.linkRefDef;if(o){let e=!!o.spec.attrs?.url,t=!!o.spec.attrs?.href,n=!!o.spec.attrs?.identifier,r=!!o.spec.attrs?.sourceLayout,a=!!o.spec.attrs?.sourceTitleMarker;i.definition=i=>{let s={title:i.title??null};return n&&(s.identifier=i.identifier??``),s.label=i.label??i.identifier??``,e?s.url=i.url??``:t&&(s.href=i.url??``),r&&(s.sourceLayout=i.data?.sourceLayout??null),a&&(s.sourceTitleMarker=i.data?.sourceTitleMarker??null),o.createAndFill(s)}}if(n.jsxComponent){let r=e=>{if(e&&typeof e==`object`&&`sourceRaw`in e){let t=e.sourceRaw;if(typeof t==`string`)return t}};i.mdxJsxFlowElement=(e,i,a)=>{let o=e.name??``,s=RZ.getOrWildcard(o),c=zZ(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=kZ(e,t.current.sourcePath);n!==e&&(c.src=n,c.sourceUrl=e)}let l=a.all(e).flat();return n.jsxComponent.createAndFill({componentName:o,kind:`element`,attributes:e.attributes,sourceRaw:r(e.data)??``,sourceDirty:!1,props:c},l.length?l:void 0)};let a=(e,t)=>{let n=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return n&&typeof n.value==`string`?n.value:null};i.mdxJsxTextElement=t=>{if(t.name===`InlineMath`&&n.mathInline){let e=a(t,`formula`)??``,r=a(t,`id`);return n.mathInline.create({formula:e,id:r??null})}if(t.name===`Tag`&&n.tag){let e=a(t,`value`)??``;return n.tag.create({value:e})}if(n.jsxInline){let i=r(t.data)??``;return n.jsxInline.createAndFill({},i?[e.text(i)]:null)}return n.jsxComponent.createAndFill({sourceRaw:r(t.data)??``})},i.mdxFlowExpression=e=>{let t=r(e.data)??`{${e.value??``}}`;return n.jsxComponent.createAndFill({kind:`expression`,sourceRaw:t,sourceDirty:!1})},i.mdxTextExpression=t=>{let n=r(t.data)??`{${t.value??``}}`;return e.text(n)}}return n.wikiLink&&(i.wikiLink=e=>n.wikiLink.createAndFill({target:e.data?.target??``,alias:e.data?.alias??null,anchor:e.data?.anchor??null})),n.tag&&(i.tag=e=>n.tag.createAndFill({value:e.value})),n.wikiLinkEmbed&&(i.wikiLinkEmbed=(i,a)=>{let o=i.data?.target??``,s=i.data?.alias??null,c=i.data?.anchor??null,l=rq(o),{resolveEmbed:u,sourcePath:d}=t.current,f=u&&d?u(o,d)??null:null,p=f?`/${f}`:o,m=a?.type===`paragraph`&&Array.isArray(a.children)&&a.children.length===1;if(m&&KZ.has(l)&&n.jsxComponent&&RZ.has(`WikiEmbedImage`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedImage`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,alt:s??o,target:o,anchor:c,alias:s}});if(m&&HG.has(l)&&n.jsxComponent&&RZ.has(`WikiEmbedVideo`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedVideo`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&WG.has(l)&&n.jsxComponent&&RZ.has(`WikiEmbedAudio`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedAudio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&GG.has(l)&&n.jsxComponent&&RZ.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&d?e(o,d)??null:null,i=r===null?null:IZ(r);return n.jsxComponent.createAndFill({componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,target:o,anchor:c,alias:s,size:i}})}let h=s||(c?`${o}#${c}`:o);if(XG.has(l)&&r.link){let t=r.link.create({href:p,title:null,linkStyle:`inline`,refLabel:null,sourceForm:`wikiembed`,target:o,anchor:c,alias:s});return e.text(h,[t])}if(r.link){let t=r.link.create({href:o,title:null,linkStyle:`inline`,refLabel:null});return e.text(h,[t])}throw Error("[wikiLinkEmbed handler] schema lacks `link` mark — cannot dispatch without violating the STOP rule against emitting PM wikiLinkEmbed server-side")}),n.mathInline&&(i.inlineMath=e=>n.mathInline.create({formula:e.value??``})),i.math||=t=>{let r=t.value==null?`«unknown:${t.type}»`:t.value;return n.rawMdxFallback?(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled block mdast: ${t.type}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled block mdast: ${t.type}`},r?[e.text(r)]:null)):null},i.inlineMath||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled inline mdast: ${t.type}`})),t.value==null?e.text(`«unknown:${t.type}»`):e.text(t.value)),n.footnoteReference?i.footnoteReference=e=>n.footnoteReference.create({identifier:e.identifier,label:e.label??e.identifier}):i.footnoteReference||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteReference`,reason:`FootnoteReference extension missing — recovering [^id] source`})),e.text(`[^${t.label??t.identifier}]`)),n.footnoteDefinition?i.footnoteDefinition=JL(n.footnoteDefinition,e=>{let t=e;return{identifier:t.identifier,label:t.label??t.identifier}}):i.footnoteDefinition||=t=>{console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteDefinition`,reason:`FootnoteDefinition extension missing — recovering [^id]: marker`}));let r=`[^${t.label??t.identifier}]: `;return n.paragraph?n.paragraph.create(null,e.text(r)):null},i.rawMdxFallbackMdast=t=>{if(!n.rawMdxFallback)return null;let r=t.position?{start:t.position.start?.offset??0,end:t.position.end?.offset??0}:{start:0,end:0};return console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.originalType,reason:`Unhandled mdast: ${t.originalType}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled mdast: ${t.originalType}`,originalSpan:r},t.value?[e.text(t.value)]:null)},i}function JZ(e){let t={},n={},r=e.nodes,i=e.marks;r.paragraph&&(t.paragraph=eR(`paragraph`)),r.blockquote&&(t.blockquote=eR(`blockquote`,e=>{let t=e.attrs.sourceMarkerSpacings,n={};return Array.isArray(t)&&t.length>0&&(n.sourceMarkerSpacings=t),Object.keys(n).length>0?{data:n}:{}})),r.heading&&(t.heading=eR(`heading`,e=>({depth:e.attrs.level,data:{sourceStyle:e.attrs.headingStyle,sourceTrailingHashes:e.attrs.sourceTrailingHashes??void 0,sourceUnderlineLength:e.attrs.sourceUnderlineLength??void 0,sourceContiguousNext:e.attrs.sourceContiguousNext===!0?!0:void 0}}))),r.codeBlock&&(t.codeBlock=e=>{let t=e.attrs.sourceStyle===`indented`?`indented`:`fenced`;return{type:`code`,lang:t===`indented`?null:e.attrs.language??null,meta:t===`indented`?null:e.attrs.meta??null,value:e.textContent??``,data:{sourceFenceChar:e.attrs.fenceDelimiter,sourceFenceLength:e.attrs.fenceLength,sourceStyle:t}}}),r.thematicBreak&&(t.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),r.hardBreak&&(t.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle}})),r.list&&(t.list=eR(`list`,e=>({ordered:e.attrs.ordered??!1,start:e.attrs.ordered?e.attrs.start??1:null,spread:e.attrs.spread??!1,data:{bulletMarker:e.attrs.bulletMarker,listMarkerDelimiter:e.attrs.listMarkerDelimiter}}))),r.listItem&&(t.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&HZ(r[0])?r.slice(1):r;return{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,children:i}}),r.table&&(t.table=(e,t,n)=>{let r=n.all(e),i=[],a=e.firstChild;a&&a.forEach(e=>{let t=e.attrs.align;i.push(t===`left`||t===`right`||t===`center`?t:null)});let o=r.filter(e=>e.type===`tableRow`),s=e.attrs.sourceDashCounts,c=Array.isArray(s)&&s.length>0?{sourceDashCounts:s}:void 0,l={type:`table`,align:i,children:o};return c&&(l.data=c),l}),r.tableRow&&(t.tableRow=eR(`tableRow`));let a=e=>{let t=e.attrs.sourcePadding,n={};return typeof t==`object`&&t&&typeof t.left==`number`&&typeof t.right==`number`&&(n.sourcePadding=t),Object.keys(n).length>0?{data:n}:{}};if(r.tableCell&&(t.tableCell=eR(`tableCell`,a)),r.tableHeader&&(t.tableHeader=eR(`tableCell`,a)),r.image&&(t.image=e=>({type:`image`,url:e.attrs.sourceUrl??e.attrs.src,alt:e.attrs.alt,title:e.attrs.title})),r.imageReference&&(t.imageReference=e=>{let t=e.attrs.label??``,n=e.attrs.identifier??t;return{type:`imageReference`,alt:e.attrs.alt??``,identifier:n,label:t||n,referenceType:e.attrs.referenceType??`shortcut`}}),r.htmlBlock&&(t.htmlBlock=e=>({type:`html`,value:e.attrs.content})),r.linkDefinition??r.linkRefDef){let e=r.linkDefinition?`linkDefinition`:`linkRefDef`;t[e]=e=>{let t={},n=e.attrs.sourceLayout;(n===`multiline`||n===`inline`)&&(t.sourceLayout=n);let r=e.attrs.sourceTitleMarker;(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r);let i={type:`definition`,identifier:e.attrs.identifier??e.attrs.label??``,label:e.attrs.label??e.attrs.identifier??``,url:e.attrs.url??e.attrs.href??``,title:e.attrs.title};return Object.keys(t).length>0&&(i.data=t),i}}if(r.jsxComponent&&(t.jsxComponent=(e,t,n)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let r=e.attrs.componentName||null,i=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[];return!VZ(e)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:r,attributes:i,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:RZ.getOrWildcard(r??`*`).serialize(e,{all:e=>n.all(e),registry:RZ,serializeChildren:()=>{throw Error(`SerializeContext.serializeChildren is not available in the PM→mdast handler. Compat descriptors that need markdown-byte body rendering must emit a marker mdast node and let the to-markdown handler render the body via state.containerFlow.`)}})}),r.rawMdxFallback&&(t.rawMdxFallback=e=>{let t=e.textContent??``,n=typeof e.attrs.reason==`string`?e.attrs.reason:``,r=e.attrs.originalSpan;return{type:`rawMdxFallback`,value:t,data:{reason:n,originalSpan:r&&typeof r==`object`&&`start`in r&&`end`in r?{start:Number(r.start)||0,end:Number(r.end)||0}:{start:0,end:0}}}}),r.jsxInline&&(t.jsxInline=e=>{let t=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:null,attributes:[],children:[],data:{sourceRaw:String(t)}}}),r.mathInline&&(t.mathInline=e=>{let t=e.attrs.formula??``,n=e.attrs.id;return typeof n==`string`&&n.length>0?{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]}:{type:`inlineMath`,value:t}}),r.wikiLink&&(t.wikiLink=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLink`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}),r.tag&&(t.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),r.wikiLinkEmbed&&(t.wikiLinkEmbed=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLinkEmbed`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}),i.emphasis&&(n.emphasis=tR(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),i.strong&&(n.strong=tR(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),i.code&&(n.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return WZ(n,{sourceFenceChar:r,sourceFenceLength:i})}),i.strike??i.delete){let e=i.strike?`strike`:`delete`;n[e]=tR(`delete`)}return i.highlight&&(n.highlight=tR(`mark`)),i.comment&&(n.comment=tR(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),r.commentBlock&&(t.commentBlock=eR(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),r.footnoteReference&&(t.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),r.footnoteDefinition&&(t.footnoteDefinition=eR(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),i.link&&(n.link=(e,t,n)=>{if(e.attrs.sourceForm===`wikiembed`){let t=typeof e.attrs.target==`string`&&e.attrs.target.length>0?e.attrs.target:e.attrs.href??``,n=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,r=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?e.attrs.alias:null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLinkEmbed`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}let r=e.attrs.linkStyle;if(r===`autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`autolink`}};if(r===`gfm-autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`gfm-autolink`}};if(r===`inline`||!r){let t={};e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);let r=e.attrs.sourceTitleMarker;return(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r),{type:`link`,url:e.attrs.href??``,title:e.attrs.title??null,children:n,...Object.keys(t).length>0?{data:t}:{}}}return{type:`linkReference`,identifier:(e.attrs.refLabel??``).toLowerCase(),label:e.attrs.refLabel,referenceType:r,children:n}}),i.escapeMark&&(n.escapeMark=(e,t,n)=>{for(let e of n)if(e.type===`text`&&e.value){let t=e;t.data=t.data??{},t.data.escapedChars=t.data.escapedChars??[];for(let e=0;e<t.value.length;e++)t.data.escapedChars.push({offset:e,char:t.value[e]})}return n.length===1?n[0]:n}),i.sourceLiteral&&(n.sourceLiteral=(e,t,n)=>{let r=typeof e.attrs.sourceRaw==`string`?e.attrs.sourceRaw:``;if(n.length===1&&n[0]?.type===`text`){let e=n[0],t=r||e.value;return GK(t,e.value)&&(e.data=e.data??{},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:t,markHandlers:n}}const YZ=/\p{M}+/gu,XZ=/[^\p{L}\p{N}]+/gu,ZZ=/^-+|-+$/g;function QZ(e){return e.trim().normalize(`NFKD`).replace(YZ,``).toLowerCase().replace(XZ,`-`).replace(ZZ,``)}function $Z(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function eQ(e,t){let n=QZ(e);return n?$Z(n,t):``}const tQ=WB(),nQ=cB(),rQ=lB();function iQ(){return FJ.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function aQ(){return iQ().filter(e=>oQ(e)!==`fence`)}function oQ(e){return e.name===`MermaidFence`?`fence`:e.hasChildren?`jsx-block`:`jsx-void`}function sQ(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:oQ(e)}}function cQ(e){if(e.hidden!==!0&&e.type!==`reactnode`){if(`defaultValue`in e&&e.defaultValue!==void 0)return e.defaultValue;if(e.type===`enum`)return e.enumValues[0];if(e.type===`string`)return``;if(e.type===`number`)return 0;if(e.type===`boolean`)return!1}}function lQ(e,t){return!(e.omitOnDefault===!0&&`defaultValue`in e&&Object.is(e.defaultValue,t)||e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&t===``)}function uQ(e){let t=[];for(let n of e.props){let e=cQ(n);e!==void 0&&lQ(n,e)&&t.push(Jq(n.name,e))}return t}function dQ(e){return gz(e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`Body content here.`,{extensions:[tQ],mdastExtensions:[nQ]}).children}function fQ(e){let t=oQ(e),n;if(t===`fence`)n={type:`code`,lang:`mermaid`,meta:null,value:e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`graph LR
426
426
  A --> B`};else{let r=uQ(e),i=t===`jsx-block`?dQ(e):[];n={type:`mdxJsxFlowElement`,name:e.name,attributes:r,children:i}}return uP({type:`root`,children:[n]},{extensions:[rQ]}).trimEnd()}function pQ(e){let t=[];for(let n of e.props){if(n.hidden===!0)continue;let e={name:n.name,type:n.type,required:n.required};n.description!==void 0&&(e.description=n.description),n.advanced===!0&&(e.advanced=!0),n.omitOnDefault===!0&&(e.omitOnDefault=!0),n.type===`enum`&&(e.values=n.enumValues,n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue)),n.type===`string`&&(n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.language!==void 0&&(e.language=n.language),n.accept!==void 0&&(e.accept=n.accept)),n.type===`boolean`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.type===`number`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),t.push(e)}return t}function mQ(e){return{...sQ(e),example:fQ(e),params:pQ(e)}}function hQ(){return[``,"**Custom canonical components.** OK `.md` / `.mdx` supports the JSX components below — use whichever is semantically useful in any part of the doc. For full source syntax + parameter schemas, call `get_components({ ids })` with the ids you want to use. Fenced code blocks render naturally and don't need a fetch — including ` ```mermaid ` for diagrams and ` ```html preview ` for interactive HTML/JS/CSS pages (the fence info-string `preview` token renders the block as a live iframe; works for `html` / `htm` / `xml`; optional `h=` / `w=` tokens set size, e.g. ` ```html preview h=400px `). Use ` ```html preview ` whenever you want anything interactive or JS-powered (charts, demos, calculators, animations) — just author the standalone HTML page in the fence. Call `get_authoring_palette` for the markdown-native component forms (write `> [!NOTE]`, not `<Callout>`), copy-ready themed `html preview` starters, and the theme tokens (`var(--chart-1)`, `var(--foreground)`, …) an embed should reference so it tracks the reader's light/dark theme. Arbitrary `<TagName>` JSX falls through as raw MDX when no canonical fits.",``,...aQ().map(sQ).map(e=>`- \`${e.id}\` (${e.kind}) — ${e.description}`)].join(`
427
- `)}const gQ=M({docName:fq,summary:hq,content:k().optional(),...mq}).loose(),_Q=M({docName:fq,summary:hq,markdown:k(),position:N([`append`,`prepend`,`replace`]).optional(),extension:N([`.md`,`.mdx`]).optional(),...mq}).loose(),vQ=M({docName:fq,summary:hq,find:k().min(1),replace:k(),offset:A().int().nonnegative().optional(),...mq}).loose(),yQ=M({docName:fq,connectionId:k().min(1),scope:N([`last`,`session`,`file`]).optional(),...mq}).loose(),bQ=M({value:k(),truncatedFrom:A().int().nonnegative().optional(),hint:k().optional()}).loose(),xQ=Qs(`kind`,[M({kind:P(`inline`),content:k()}),M({kind:P(`truncated`),byteLength:A().int().nonnegative(),hint:k()})]),SQ=M({kind:P(`content-divergence`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),divergenceType:k().optional(),currentState:xQ.optional(),hint:k().optional()}).loose(),CQ=M({type:P(`orphan`),parentCandidates:j(k()),message:k()}).loose(),wQ=M({timestamp:k().min(1),summary:bQ.optional()}).loose(),TQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:j(CQ).optional(),summary:bQ.optional(),warning:SQ.optional()}).loose(),EQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:bQ.optional(),warning:SQ.optional()}).loose(),DQ=M({docName:k().min(1),scope:N([`last`,`session`]),undone:Ls()}).loose(),OQ=M({docName:fq,patch:nc(k(),Xs([Mc,zs()])),types:nc(k(),N(jc)).optional(),summary:hq,...mq}).loose(),kQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:j(k()),summary:bQ.optional()}).loose(),AQ=M({entries:j(M({level:N([`info`,`warn`,`error`]),message:k().max(8192),event:k().optional(),fields:nc(k(),Us()).optional(),ts:A().optional(),sourceId:k().optional(),lineNumber:A().optional()}).loose()).max(100)}).loose(),jQ=M({accepted:A().int().min(0)}).loose(),MQ=M({status:k().min(1),reason:k()}).loose(),NQ=M({docName:k().min(1),content:k(),lifecycle:MQ.nullable()}).loose(),PQ=M({documents:j(M({kind:N([`document`,`asset`,`folder`]).default(`document`),docName:k().min(1).optional(),docExt:k().min(1).default(`.md`),size:A().int().nonnegative(),modified:k().min(1),isSymlink:Ls().default(!1),canonicalDocName:k().nullable().default(null),targetPath:k().nullable().default(null),path:k().min(1).optional(),assetExt:k().min(1).optional(),mediaKind:N([`image`,`video`,`audio`,`pdf`,`text`]).nullable().optional(),referencedBy:j(k().min(1)).optional(),hasChildren:Ls().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName)`})),truncated:Ls().optional()}).loose(),FQ=M({source:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),IQ=M({docName:k().min(1),backlinks:j(FQ)}).loose(),LQ=M({counts:nc(k().min(1),A().int().nonnegative())}).loose(),RQ=Qs(`kind`,[M({kind:P(`doc`),docName:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),M({kind:P(`external`),url:k().min(1),title:k(),snippet:k().nullable()}).loose()]),zQ=M({docName:k().min(1),forwardLinks:j(RQ)}).loose(),BQ=Qs(`kind`,[M({id:k().min(1),kind:P(`doc`),docName:k().min(1),anchor:k().nullable(),label:k(),cluster:k().nullable(),category:k().nullable(),tags:j(k()).nullable()}).loose(),M({id:k().min(1),kind:P(`external`),url:k().min(1),label:k()}).loose()]),VQ=M({source:k().min(1),target:k().min(1)}).loose(),HQ=M({nodes:j(BQ),links:j(VQ)}).loose(),UQ=M({ts:A().int().min(0),url:k(),method:k(),ua:k().optional(),origin:k().optional(),referer:k().optional(),host:k().optional(),remote:k().optional(),secChUa:k().optional(),secChUaMobile:k().optional(),secChUaPlatform:k().optional(),secFetchSite:k().optional(),secFetchDest:k().optional(),secFetchMode:k().optional(),secFetchUser:k().optional()}).loose(),WQ=M({app:Xs([P(`cursor`),P(`codex`),P(`claude`),zs()]),signals_fired:j(k())}).loose(),GQ=M({entries:j(UQ),count:A().int().min(0),detection:WQ}).loose(),KQ=M({writers:j(M({id:k().min(1),name:k().optional(),email:k().optional()}).loose()).optional(),...mq}).loose(),qQ=M({checkpointRef:k().min(1)}).loose(),JQ=M({v:A().int().optional(),id:k().min(1),name:k().min(1),colorSeed:k().optional(),docs:j(k()),summaries:j(k()).optional()}).loose(),YQ=M({entries:j(M({sha:k().min(1),timestamp:k().min(1),author:k(),authorEmail:k(),type:N([`checkpoint`,`wip`,`upstream`,`park`]),message:k(),contributors:j(JQ),checkpoint:Us().nullable()}).loose()),total:A().int().nonnegative().optional(),truncated:Ls().optional()}).loose(),XQ=M({sha:k().regex(/^[0-9a-f]{40}$/i),content:k(),timestamp:k(),author:k()}).loose(),ZQ=M({lines:j(M({type:N([`added`,`removed`,`unchanged`]),text:k()}).loose()),additions:A().int().nonnegative(),deletions:A().int().nonnegative()}).loose(),QQ=M({contentDir:k().min(1),pathSeparator:N([`/`,`\\`]),symlinkResolved:Ls()}).loose(),$Q=j(Qs(`source`,[M({docName:k().min(1),timestamp:k().min(1),size:A().int().nonnegative(),source:P(`flat`)}).loose(),M({docName:k().min(1),timestamp:k().min(1),source:P(`timeline`),sha:k().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),e$=M({orphans:j(M({docName:k().min(1),title:k()}).loose())}).loose(),t$=M({hubs:j(M({docName:k().min(1),title:k(),count:A().int().nonnegative()}).loose())}).loose(),n$=M({source:k().min(1),title:k(),snippet:k().nullable()}).loose(),r$=M({deadLinks:j(M({target:k().min(1),sources:j(n$)}).loose())}).loose(),i$=M({target:M({docName:k().min(1),title:k(),aliases:j(k())}).loose(),mentions:j(M({source:k().min(1),excerpt:k(),offset:A().int().nonnegative()}).loose()),truncated:Ls()}).loose(),a$=M({dir:k().min(1),port:A().int().min(1).max(65535).optional()}).loose(),o$=M({port:A().int().positive()}).loose(),s$=M({projectPath:k().min(1)}).loose(),c$=N([`not-a-git-worktree`,`init-failed`]),l$=Qs(`ok`,[M({ok:P(!0),projectPath:k().min(1)}).loose(),M({ok:P(!1),reason:c$,message:k().min(1)}).loose()]),u$=M({host:k().min(1).optional()}).loose(),d$=M({pat:k().min(1),host:k().min(1).optional()}).loose(),f$=M({name:k().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:k().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),p$=M({identity:M({name:k().min(1),email:k().min(1)}).loose().nullable()}).loose(),m$=M({authenticated:Ls()}).loose(),h$=M({type:P(`complete`).optional(),login:k().min(1).optional()}).loose(),g$=M({}).loose(),_$=M({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),v$=M({docName:k().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:j(_$)}).loose(),y$=M({displayName:k().min(1),color:k().min(1),icon:k().optional(),connectionId:k().min(1)}).loose(),b$=M({sessionAlive:Ls(),agent:y$.nullable(),files:j(v$)}).loose(),x$=M({diff:k(),generatedAt:A().int().min(0)}).loose(),S$=M({}).loose(),C$=M({}).loose(),w$=M({}).loose(),T$=M({}).loose(),E$=M({}).loose(),D$=M({displayName:k().min(1),icon:k(),color:k().min(1),currentDoc:k().nullable(),mode:N([`idle`,`writing`]),ts:A().int().min(0)}).loose(),O$=M({presence:nc(k().min(1),D$)}).loose(),k$=nc(k().min(1),Ls()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});M({path:k().min(1,`path must be non-empty`)}).loose();const A$=M({}).loose(),j$=M({fromDocName:k().min(1),toDocName:k().min(1)}).loose(),M$=M({fromPath:k().min(1),toPath:k().min(1)}).loose(),N$=M({}).loose(),P$=M({path:k().min(1),...mq,summary:hq}).loose(),F$=M({docName:k().min(1)}).loose(),I$=M({path:k().min(1),...mq,summary:hq}).loose(),L$=M({path:k().min(1)}).loose(),R$=M({kind:N([`file`,`folder`]),path:k().min(1),...mq,summary:hq}).loose(),z$=M({kind:N([`file`,`folder`]),path:k().min(1),duplicatedDocNames:j(k().min(1))}).loose(),B$=M({pages:j(M({docName:k().min(1),title:k(),docExt:k().min(1),size:A().int().nonnegative(),modified:k().min(1),icon:k().min(1).max(2048).optional()}).loose())}).loose(),V$=M({level:A().int().min(1).max(6),text:k(),slug:k()}).loose(),H$=M({docName:k().min(1),headings:j(V$)}).loose();M({docName:pq,newDocName:pq,summary:hq,...mq}).loose();const U$=M({docName:k().min(1),rewrites:A().int().nonnegative()}).loose();M({renamed:j(j$),rewrittenDocs:j(U$),summary:bQ.optional()}).loose();const W$=M({kind:N([`file`,`folder`,`asset`]),fromPath:k().min(1),toPath:k().min(1),...mq,summary:hq}).loose(),G$=M({renamed:j(j$),renamedAssets:j(M$),rewrittenDocs:j(U$).optional(),summary:bQ.optional()}).loose(),K$=M({kind:N([`file`,`folder`,`asset`]),path:k().min(1),...mq}).loose(),q$=M({deletedDocNames:j(k().min(1))}).loose(),J$=M({kind:N([`file`,`folder`,`asset`]),path:k().min(1),...mq,summary:hq}).loose(),Y$=M({deletedDocNames:j(k().min(1))}).loose(),X$=M({docName:k().min(1),commitSha:k().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:hq,...mq}).loose(),Z$=M({restoredFrom:k().min(1),timestamp:k().min(1),summary:bQ.optional(),warning:SQ.optional()}).loose(),Q$=N([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),$$=M({label:k().min(1),webUrl:_s().nullable()}).loose(),e1=Qs(`checkStatus`,[M({checkStatus:P(`allowed`)}).loose(),M({checkStatus:P(`denied`),deniedReason:N([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),M({checkStatus:P(`unknown`),unknownError:N([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),t1=M({state:Q$,lastSyncUtc:k().nullable(),lastFetchUtc:k().nullable(),lastPushedSha:k().nullable(),ahead:A().int().min(0),behind:A().int().min(0),consecutiveFailures:A().int().min(0),conflictCount:A().int().min(0),hasRemote:Ls(),syncEnabled:Ls(),identityUnresolved:Ls(),remote:$$.nullable().optional(),error:k().optional(),errorCode:N([`auth-403`,`auth-401`,`auth-scope-mismatch`,`semantic-protected-branch`]).optional(),pausedReason:k().optional(),pushPermission:e1.optional()}).loose(),n1=M({op:N([`sync`,`push`,`pull`]).optional()}).loose(),r1=M({op:N([`sync`,`push`,`pull`])}).loose(),i1=M({file:k().min(1),detectedAt:k().min(1),oursSha:k().optional(),theirsSha:k().optional(),baseSha:k().optional()}).loose(),a1=M({conflicts:j(i1)}).loose(),o1=M({file:k().min(1),strategy:N([`mine`,`theirs`,`content`,`delete`]),content:k().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),s1=M({}).loose(),c1=M({file:k().min(1),base:k(),ours:k(),theirs:k(),kind:N([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:k().nullable()}).loose(),l1=M({}).loose(),u1=M({plan:Ec(e=>e!==void 0,{message:`plan is required`})}).loose(),d1=M({plan:Ec(e=>e!==void 0,{message:`plan is required`})}).loose(),f1=M({result:Ec(e=>e!==void 0,{message:`result is required`})}).loose(),p1=M({path:k().min(1),summary:k().min(1)}).loose(),m1=M({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),h1=M({packs:j(M({id:k().min(1),name:k().min(1),description:k().min(1),defaultSubfolder:k().optional(),folders:j(p1),entryCounts:m1}).loose())}).loose(),g1=M({noOpen:Ls().optional(),out:k().min(1).optional()}).loose(),_1=M({reason:N([`unsupported-platform`,`spawn-error`]),message:k()}).loose(),v1=Qs(`status`,[M({status:P(`installed`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k()}).loose(),M({status:P(`built`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k(),handoffError:_1.optional()}).loose(),M({status:P(`failed`),buildError:k()}).loose(),M({status:P(`skip-current`),skillVersion:k(),recordedAt:k().optional()}).loose()]),y1=M({tags:j(M({name:k().min(1),count:A().int().nonnegative(),isLeaf:Ls()}).loose())}).loose(),b1=M({docName:k().min(1),title:k(),matchingTags:j(k().min(1)),snippet:k().nullable()}).loose(),x1=M({name:k().min(1),docs:j(b1)}).loose(),S1=M({folder:Us(),frontmatter_local:nc(k(),Us()).nullable()}).loose(),C1=M({path:k(),frontmatter:nc(k(),Us()).optional()}).loose(),w1=M({applied:Us()}).loose(),T1=nc(k(),Us()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),E1=M({template:M({name:k().min(1),folder:k(),scope:N([`local`,`inherited`]),path:k().min(1),frontmatter:T1,body:k()}).strict()}).strict(),D1=M({templates:j(M({name:k().min(1),title:k().optional(),description:k().optional(),path:k().min(1),source_folder:k()}).strict()),truncated:Ls()}).strict(),O1=M({folder:k(),name:k(),body:k().optional(),frontmatter:T1.optional()}).strict(),k1=M({path:k().min(1),created:Ls(),warnings:j(k())}).strict(),A1=M({existed:Ls(),path:k().min(1)}).strict(),j1=M({query:k().optional(),intent:N([`autocomplete`,`full_text`,`omnibar`]).optional(),scopes:j(N([`page`,`folder`,`content`])).optional(),scope:k().optional(),limit:A().int().nonnegative().optional()}).loose(),M1=M({kind:N([`page`,`folder`,`content`]),path:k().min(1),title:k(),score:A(),signals:nc(k(),Us()),snippet:k().optional()}).loose(),N1=M({query:k(),intent:N([`autocomplete`,`full_text`,`omnibar`]),results:j(M1),elapsedMs:A().nonnegative()}).loose(),P1=M({version:k().min(1),recordedAt:k().min(1)}).loose(),F1=M({currentVersion:k().min(1),targets:nc(k(),P1.nullable())}).loose(),I1=`server-info`,L1=`branch-switched`,R1=`disk-ack`,z1=`config-validation-rejected`,B1=`config-ignore-nested-error`,V1=N([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),H1=M({v:P(1),ch:P(I1),seq:A(),serverInstanceId:k().min(1),currentBranch:k().min(1).optional()}).loose(),U1=M({v:P(1),ch:P(L1),seq:A(),branch:k().min(1)}).loose(),W1=M({v:P(1),ch:V1,seq:A()}).loose(),G1=M({v:P(1),ch:P(R1),seq:A(),docName:k().min(1),sv:k().min(1)}).loose(),K1=M({v:P(1),ch:P(z1),seq:A(),docName:k().min(1),error:ll}).loose(),q1=M({v:P(1),ch:P(B1),seq:A(),path:k().min(1),error:k().min(1)}).loose(),J1={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},Y1=new WeakMap;function X1(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function Z1(e){return e.trim().toLowerCase()}function Q1(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function $1(e){return e.split(`/`).filter(Boolean).join(` `)}function e0(e){let t=Q1(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0;return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:$1(e.path),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function t0(e){let t=PU({schema:J1});return e.length>0&&GU(t,e),t}function n0(e){let t={documents:e};return Y1.set(t,t0(e)),t}function r0(e){let t=Y1.get(e);if(t)return t;let n=t0(e.documents);return Y1.set(e,n),n}function i0(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`]:[`page`,`folder`]}function a0(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function o0(e,t){let n=Z1(t);if(!n)return 0;let r=Z1(e.title),i=Z1(e.name),a=Z1(e.path),o=a.split(`/`);return r===n||i===n?700:a===n?650:r.startsWith(n)||i.startsWith(n)?600:o.some(e=>e.startsWith(n))?550:r.includes(n)||i.includes(n)?500:a.includes(n)?450:-1}function s0(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function c0(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function l0(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function u0(e,t){return Z1(t).length<4?0:e===`full_text`?1:0}function d0(e,t,n={}){let r=n.intent??`omnibar`,i=X1(n.limit),a=new Set(n.scopes??i0(r)),o=e.documents.filter(e=>a0(e,a)),s=Z1(t);if(!s)return o.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,i).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let c=xW(r0(e),{term:s,properties:c0(r),boost:l0(r),tolerance:u0(r,s),limit:Math.max(i*4,40)}),l=new Map(c.hits.filter(e=>a0(e.document,a)).map(e=>[e.document.id,e.score])),u=s0(o),d=new Map;for(let e of o)o0(e,s)>=0&&d.set(e.id,e);for(let e of c.hits)a0(e.document,a)&&d.set(e.document.id,e.document);return[...d.values()].map(e=>{let t=Math.max(0,o0(e,s)),n=l.get(e.id)??0,r=u.get(e.id)??0;return{document:e,score:t+n*20+r,signals:{lexical:t,fullText:n,recency:r}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score).slice(0,i)}function f0(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),p0(n)}function p0(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const m0=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),h0=globalThis;h0[m0]===void 0&&(h0[m0]=Fi());const g0=h0[m0],_0=[`.ok`,`skill-state.yml`],v0=[`claude-cowork`,`cli-hosts`],y0=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],b0=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,x0=Js({version:k().regex(b0,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(g0,{description:`Recorded skill version for this target.`}),recordedAt:Vo().register(g0,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:N(y0).register(g0,{description:`Install-source surface that recorded this entry.`}).optional()}),S0=Js({schema:P(1).register(g0,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Js({"claude-cowork":x0.optional(),"cli-hosts":x0.optional()}).register(g0,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function C0(){return{schema:1,targets:{}}}function w0(){let e=!1,t=``,n=0;return r=>{let i=T0(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function T0(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const E0=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],D0={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function O0(e,t=E0){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const k0={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function A0(e){return e?k0[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const j0={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function M0(e){let t=e?.trim();return t?j0[A0(t)]??t:`Agent`}function N0(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const P0=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function F0(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function I0(e){let t=e.trim();return P0.test(t)||t.startsWith(`//`)}function L0(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(I0(n))return{kind:`external`,url:n};let r=N0(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=F0(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function R0(e,t){let n=e.trim();if(!n)return null;if(I0(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=F0(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function z0(e,t){let n=e.trim();if(!n||P0.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function B0(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function V0(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function H0(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function U0(e){return e.split(`/`).filter(e=>e!==``)}function W0(e,t){let n=H0(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function G0(e,t){let n=H0(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:U0(r).length}function K0(e,t){let n=U0(e),r=U0(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function q0(){let e=new Map;function t(t){let n=B0(t);if(n===``)return;let r=V0(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=B0(t),r=V0(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=H0(B0(n)),o=[],s=[];for(let e of i)W0(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=G0(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=G0(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=K0(a,H0(t));for(let r=1;r<e.length;r++){let i=e[r],o=K0(a,H0(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function J0(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function Y0(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function X0(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function Z0(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function Q0(){try{let e=l(c(b(import.meta.url)),`..`,`package.json`),t=JSON.parse(m(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const $0=Q0(),e2=1;var t2=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function n2(e,t){return l(e,`${t}.lock`)}const r2=new Map;function i2(e){r2.set(e,(r2.get(e)??0)+1)}function a2(e){let t=r2.get(e);return t===void 0||t<=1?(r2.delete(e),!0):(r2.set(e,t-1),!1)}function o2(e,t){try{let n=JSON.parse(m(e,`utf-8`));return n&&typeof n==`object`&&Z0(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function s2(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;f(n,{recursive:!0});let a=n2(n,t),o={pid:process.pid,hostname:y(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??$0},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!d(a))try{let e=p(a,`wx`,384);try{_(e,s)}finally{u(e)}return i2(a),c2({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=o2(a,i);if(e){let r=e.hostname===y();if(r&&e.pid===process.pid)return g(a,s,{encoding:`utf-8`,mode:384}),i2(a),c2({lockName:t,lockDir:n,lockPath:a});if(r&&X0(e.pid))throw new t2(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{h(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function c2(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>f2({lockName:t,lockDir:n}),updatePort:e=>l2({lockName:t,lockDir:n,port:e})}}function l2(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=n2(n,t);if(!d(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(m(a,`utf-8`));if(!e||typeof e!=`object`||!Z0(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&!(typeof o.hostname==`string`&&o.hostname!==y())){o.port=r;try{g(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function u2(e){let{lockName:t,lockDir:n}=e,r=n2(n,t);if(!d(r))return null;let i;try{let e=JSON.parse(m(r,`utf-8`));if(!e||typeof e!=`object`||!Z0(e.pid))return null;i=e}catch{return null}if(i.hostname!==y())return null;if(!X0(i.pid)){try{h(r)}catch{}return null}return i}function d2(e){let{lockName:t,lockDir:n}=e,r=n2(n,t);if(!d(r))return{status:`absent`};let i;try{i=JSON.parse(m(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!Z0(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(o.hostname!==y())return{status:`stale`,lock:o};if(!X0(o.pid)){try{h(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}function f2(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=n2(n,t);if(a2(i)&&d(i))try{let e=JSON.parse(m(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==y())return;h(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var p2=class extends t2{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function m2(e,t){try{return s2({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof t2&&e.lockName===`server`?new p2(e.existing,e.lockPath):e}}function h2(e,t){l2({lockName:`server`,lockDir:e,port:t})}function g2(e){return u2({lockName:`server`,lockDir:e})}function _2(e){f2({lockName:`server`,lockDir:e})}export{bG as $,Vo as $i,E1 as $n,N0 as $r,LZ as $t,zq as A,Kc as Ai,Lq as An,f0 as Ar,zQ as At,G1 as B,Qs as Bi,Kq as Bn,jq as Br,HQ as Bt,EQ as C,Sl as Ci,qQ as Cn,n0 as Cr,EG as Ct,TQ as D,_l as Di,f1 as Dn,BW as Dr,S1 as Dt,_Q as E,ul as Ei,d1 as En,fG as Er,N$ as Et,nG as F,zs as Fi,Eq as Fn,aQ as Fr,t$ as Ft,R1 as G,M as Gi,o1 as Gn,dG as Gr,h$ as Gt,L1 as H,P as Hi,l1 as Hn,kq as Hr,u$ as Ht,U1 as I,Vs as Ii,Oq as In,eQ as Ir,JG as It,hG as J,nc as Ji,n1 as Jn,PG as Jr,Gq as Jt,I1 as K,cc as Ki,s1 as Kn,RW as Kr,f$ as Kt,q1 as L,j as Li,F1 as Ln,HJ as Lr,g1 as Lt,IQ as M,Ns as Mi,yq as Mn,lq as Mr,kQ as Mt,Nq as N,sc as Ni,wq as Nn,YW as Nr,YQ as Nt,gQ as O,nl as Oi,h1 as On,M0 as Or,C1 as Ot,ZW as P,N as Pi,Cq as Pn,IZ as Pr,XQ as Pt,xG as Q,_s as Qi,A1 as Qn,z0 as Qr,o$ as Qt,K1 as R,Ls as Ri,S0 as Rn,tq as Rr,v1 as Rt,vQ as S,tl as Si,KQ as Sn,RX as Sr,z$ as St,DQ as T,Fc as Ti,N1 as Tn,pG as Tr,GQ as Tt,B1 as U,Js as Ui,c1 as Un,cK as Ur,p$ as Ut,H1 as V,ec as Vi,i$ as Vn,AG as Vr,g$ as Vt,z1 as W,A as Wi,a1 as Wn,$W as Wr,d$ as Wt,SG as X,Xs as Xi,x1 as Xn,UW as Xr,l$ as Xt,CG as Y,k as Yi,r1 as Yn,mQ as Yr,s$ as Yt,yG as Z,Us as Zi,y1 as Zn,hQ as Zr,a$ as Zt,D0 as _,Mc as _i,_0 as _n,R0 as _r,q$ as _t,s2 as a,vr as aa,QZ as ai,NG as an,S$ as ar,SQ as at,b$ as b,yl as bi,MG as bn,q0 as br,NQ as bt,Z0 as c,fn as ca,Ly as ci,H$ as cn,DG as cr,P$ as ct,d2 as d,Lt as da,Cl as di,Hq as dn,QQ as dr,OG as dt,zo as ea,d0 as ei,O$ as en,O1 as er,Pq as et,g2 as f,Tt as fa,Wc as fi,W$ as fn,AW as fr,IG as ft,h2 as g,ft as ga,jc as gi,Z$ as gn,L0 as gr,K$ as gt,l2 as h,pt as ha,Vc as hi,X$ as hn,Vq as hr,r$ as ht,p2 as i,ai as ia,XW as ii,e$ as in,w$ as ir,i1 as it,LQ as j,qc as ji,_q as jn,J0 as jr,OQ as jt,wQ as k,$c as ki,u1 as kn,C0 as kr,w1 as kt,n2 as l,mn as la,Df as li,B$ as ln,Wq as lr,F$ as lt,_2 as m,D as ma,Hc as mi,$Q as mn,JW as mr,wG as mt,$0 as n,Ua as na,PW as ni,T$ as nn,D1 as nr,AQ as nt,m2 as o,cn as oa,IW as oi,FG as on,J$ as or,I$ as ot,f2 as p,O as pa,Uc as pi,G$ as pn,kW as pr,jG as pt,vG as q,kc as qi,t1 as qn,FW as qr,m$ as qt,e2 as r,Wa as ra,Y0 as ri,kG as rn,C$ as rr,jQ as rt,X0 as s,un as sa,uq as si,mG as sn,Y$ as sr,L$ as st,t2 as t,da as ta,aq as ti,E$ as tn,k1 as tr,Iq as tt,u2 as u,on as ua,F as ui,Rq as un,Uq as ur,YG as ut,TG as v,Tl as vi,v0 as vn,gG as vr,ZQ as vt,yQ as w,pl as wi,j1 as wn,e0 as wr,KG as wt,x$ as x,Jc as xi,_G as xn,w0 as xr,R$ as xt,qG as y,wl as yi,b0 as yn,O0 as yr,PQ as yt,W1 as z,Ec as zi,A$ as zn,A0 as zr,k$ as zt};
428
- //# sourceMappingURL=server-lock-BpjJj3OD-2pOoEhSP.mjs.map
427
+ `)}const gQ=M({docName:fq,summary:hq,content:k().optional(),...mq}).loose(),_Q=M({docName:fq,summary:hq,markdown:k(),position:N([`append`,`prepend`,`replace`]).optional(),extension:N([`.md`,`.mdx`]).optional(),...mq}).loose(),vQ=M({docName:fq,summary:hq,find:k().min(1),replace:k(),offset:A().int().nonnegative().optional(),...mq}).loose(),yQ=M({docName:fq,connectionId:k().min(1),scope:N([`last`,`session`,`file`]).optional(),...mq}).loose(),bQ=M({value:k(),truncatedFrom:A().int().nonnegative().optional(),hint:k().optional()}).loose(),xQ=Qs(`kind`,[M({kind:P(`inline`),content:k()}),M({kind:P(`truncated`),byteLength:A().int().nonnegative(),hint:k()})]),SQ=M({kind:P(`content-divergence`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),divergenceType:k().optional(),currentState:xQ.optional(),hint:k().optional()}).loose(),CQ=M({type:P(`orphan`),parentCandidates:j(k()),message:k()}).loose(),wQ=Qs(`kind`,[SQ,M({kind:P(`disk-edit-reconciled`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),hint:k().optional()}).loose()]),TQ=M({timestamp:k().min(1),summary:bQ.optional(),warning:wQ.optional()}).loose(),EQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:j(CQ).optional(),summary:bQ.optional(),warning:wQ.optional()}).loose(),DQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:bQ.optional(),warning:wQ.optional()}).loose(),OQ=M({docName:k().min(1),scope:N([`last`,`session`]),undone:Ls()}).loose(),kQ=M({docName:fq,patch:nc(k(),Xs([Mc,zs()])),types:nc(k(),N(jc)).optional(),summary:hq,...mq}).loose(),AQ=M({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:j(k()),summary:bQ.optional(),warning:wQ.optional()}).loose(),jQ=M({entries:j(M({level:N([`info`,`warn`,`error`]),message:k().max(8192),event:k().optional(),fields:nc(k(),Us()).optional(),ts:A().optional(),sourceId:k().optional(),lineNumber:A().optional()}).loose()).max(100)}).loose(),MQ=M({accepted:A().int().min(0)}).loose(),NQ=M({status:k().min(1),reason:k()}).loose(),PQ=M({docName:k().min(1),content:k(),lifecycle:NQ.nullable()}).loose(),FQ=M({documents:j(M({kind:N([`document`,`asset`,`folder`]).default(`document`),docName:k().min(1).optional(),docExt:k().min(1).default(`.md`),size:A().int().nonnegative(),modified:k().min(1),isSymlink:Ls().default(!1),canonicalDocName:k().nullable().default(null),targetPath:k().nullable().default(null),path:k().min(1).optional(),assetExt:k().min(1).optional(),mediaKind:N([`image`,`video`,`audio`,`pdf`,`text`]).nullable().optional(),referencedBy:j(k().min(1)).optional(),hasChildren:Ls().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName)`})),truncated:Ls().optional()}).loose(),IQ=M({source:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),LQ=M({docName:k().min(1),backlinks:j(IQ)}).loose(),RQ=M({counts:nc(k().min(1),A().int().nonnegative())}).loose(),zQ=Qs(`kind`,[M({kind:P(`doc`),docName:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),M({kind:P(`external`),url:k().min(1),title:k(),snippet:k().nullable()}).loose()]),BQ=M({docName:k().min(1),forwardLinks:j(zQ)}).loose(),VQ=Qs(`kind`,[M({id:k().min(1),kind:P(`doc`),docName:k().min(1),anchor:k().nullable(),label:k(),cluster:k().nullable(),category:k().nullable(),tags:j(k()).nullable()}).loose(),M({id:k().min(1),kind:P(`external`),url:k().min(1),label:k()}).loose()]),HQ=M({source:k().min(1),target:k().min(1)}).loose(),UQ=M({nodes:j(VQ),links:j(HQ)}).loose(),WQ=M({ts:A().int().min(0),url:k(),method:k(),ua:k().optional(),origin:k().optional(),referer:k().optional(),host:k().optional(),remote:k().optional(),secChUa:k().optional(),secChUaMobile:k().optional(),secChUaPlatform:k().optional(),secFetchSite:k().optional(),secFetchDest:k().optional(),secFetchMode:k().optional(),secFetchUser:k().optional()}).loose(),GQ=M({app:Xs([P(`cursor`),P(`codex`),P(`claude`),zs()]),signals_fired:j(k())}).loose(),KQ=M({entries:j(WQ),count:A().int().min(0),detection:GQ}).loose(),qQ=M({writers:j(M({id:k().min(1),name:k().optional(),email:k().optional()}).loose()).optional(),...mq}).loose(),JQ=M({checkpointRef:k().min(1)}).loose(),YQ=M({v:A().int().optional(),id:k().min(1),name:k().min(1),colorSeed:k().optional(),docs:j(k()),summaries:j(k()).optional()}).loose(),XQ=M({entries:j(M({sha:k().min(1),timestamp:k().min(1),author:k(),authorEmail:k(),type:N([`checkpoint`,`wip`,`upstream`,`park`]),message:k(),contributors:j(YQ),checkpoint:Us().nullable()}).loose()),total:A().int().nonnegative().optional(),truncated:Ls().optional()}).loose(),ZQ=M({sha:k().regex(/^[0-9a-f]{40}$/i),content:k(),timestamp:k(),author:k()}).loose(),QQ=M({lines:j(M({type:N([`added`,`removed`,`unchanged`]),text:k()}).loose()),additions:A().int().nonnegative(),deletions:A().int().nonnegative()}).loose(),$Q=M({contentDir:k().min(1),pathSeparator:N([`/`,`\\`]),symlinkResolved:Ls()}).loose(),e$=j(Qs(`source`,[M({docName:k().min(1),timestamp:k().min(1),size:A().int().nonnegative(),source:P(`flat`)}).loose(),M({docName:k().min(1),timestamp:k().min(1),source:P(`timeline`),sha:k().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),t$=M({orphans:j(M({docName:k().min(1),title:k()}).loose())}).loose(),n$=M({hubs:j(M({docName:k().min(1),title:k(),count:A().int().nonnegative()}).loose())}).loose(),r$=M({source:k().min(1),title:k(),snippet:k().nullable()}).loose(),i$=M({deadLinks:j(M({target:k().min(1),sources:j(r$)}).loose())}).loose(),a$=M({target:M({docName:k().min(1),title:k(),aliases:j(k())}).loose(),mentions:j(M({source:k().min(1),excerpt:k(),offset:A().int().nonnegative()}).loose()),truncated:Ls()}).loose(),o$=M({dir:k().min(1),port:A().int().min(1).max(65535).optional()}).loose(),s$=M({port:A().int().positive()}).loose(),c$=M({projectPath:k().min(1)}).loose(),l$=N([`not-a-git-worktree`,`init-failed`]),u$=Qs(`ok`,[M({ok:P(!0),projectPath:k().min(1)}).loose(),M({ok:P(!1),reason:l$,message:k().min(1)}).loose()]),d$=M({host:k().min(1).optional()}).loose(),f$=M({pat:k().min(1),host:k().min(1).optional()}).loose(),p$=M({name:k().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:k().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),m$=M({identity:M({name:k().min(1),email:k().min(1)}).loose().nullable()}).loose(),h$=M({authenticated:Ls()}).loose(),g$=M({type:P(`complete`).optional(),login:k().min(1).optional()}).loose(),_$=M({}).loose(),v$=M({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),y$=M({docName:k().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:j(v$)}).loose(),b$=M({displayName:k().min(1),color:k().min(1),icon:k().optional(),connectionId:k().min(1)}).loose(),x$=M({sessionAlive:Ls(),agent:b$.nullable(),files:j(y$)}).loose(),S$=M({diff:k(),generatedAt:A().int().min(0)}).loose(),C$=M({}).loose(),w$=M({}).loose(),T$=M({}).loose(),E$=M({}).loose(),D$=M({}).loose(),O$=M({displayName:k().min(1),icon:k(),color:k().min(1),currentDoc:k().nullable(),mode:N([`idle`,`writing`]),ts:A().int().min(0)}).loose(),k$=M({presence:nc(k().min(1),O$)}).loose(),A$=nc(k().min(1),Ls()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});M({path:k().min(1,`path must be non-empty`)}).loose();const j$=M({}).loose(),M$=M({fromDocName:k().min(1),toDocName:k().min(1)}).loose(),N$=M({fromPath:k().min(1),toPath:k().min(1)}).loose(),P$=M({}).loose(),F$=M({path:k().min(1),...mq,summary:hq}).loose(),I$=M({docName:k().min(1)}).loose(),L$=M({path:k().min(1),...mq,summary:hq}).loose(),R$=M({path:k().min(1)}).loose(),z$=M({kind:N([`file`,`folder`]),path:k().min(1),...mq,summary:hq}).loose(),B$=M({kind:N([`file`,`folder`]),path:k().min(1),duplicatedDocNames:j(k().min(1))}).loose(),V$=M({pages:j(M({docName:k().min(1),title:k(),docExt:k().min(1),size:A().int().nonnegative(),modified:k().min(1),icon:k().min(1).max(2048).optional()}).loose())}).loose(),H$=M({level:A().int().min(1).max(6),text:k(),slug:k()}).loose(),U$=M({docName:k().min(1),headings:j(H$)}).loose();M({docName:pq,newDocName:pq,summary:hq,...mq}).loose();const W$=M({docName:k().min(1),rewrites:A().int().nonnegative()}).loose();M({renamed:j(M$),rewrittenDocs:j(W$),summary:bQ.optional()}).loose();const G$=M({kind:N([`file`,`folder`,`asset`]),fromPath:k().min(1),toPath:k().min(1),...mq,summary:hq}).loose(),K$=M({renamed:j(M$),renamedAssets:j(N$),rewrittenDocs:j(W$).optional(),summary:bQ.optional()}).loose(),q$=M({kind:N([`file`,`folder`,`asset`]),path:k().min(1),...mq}).loose(),J$=M({deletedDocNames:j(k().min(1))}).loose(),Y$=M({kind:N([`file`,`folder`,`asset`]),path:k().min(1),...mq,summary:hq}).loose(),X$=M({deletedDocNames:j(k().min(1))}).loose(),Z$=M({docName:k().min(1),commitSha:k().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:hq,...mq}).loose(),Q$=M({restoredFrom:k().min(1),timestamp:k().min(1),summary:bQ.optional(),warning:SQ.optional()}).loose(),$$=N([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),e1=M({label:k().min(1),webUrl:_s().nullable()}).loose(),t1=Qs(`checkStatus`,[M({checkStatus:P(`allowed`)}).loose(),M({checkStatus:P(`denied`),deniedReason:N([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),M({checkStatus:P(`unknown`),unknownError:N([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),n1=M({state:$$,lastSyncUtc:k().nullable(),lastFetchUtc:k().nullable(),lastPushedSha:k().nullable(),ahead:A().int().min(0),behind:A().int().min(0),consecutiveFailures:A().int().min(0),conflictCount:A().int().min(0),hasRemote:Ls(),syncEnabled:Ls(),identityUnresolved:Ls(),remote:e1.nullable().optional(),error:k().optional(),errorCode:N([`auth-403`,`auth-401`,`auth-scope-mismatch`,`semantic-protected-branch`]).optional(),pausedReason:k().optional(),pushPermission:t1.optional()}).loose(),r1=M({op:N([`sync`,`push`,`pull`]).optional()}).loose(),i1=M({op:N([`sync`,`push`,`pull`])}).loose(),a1=M({file:k().min(1),detectedAt:k().min(1),oursSha:k().optional(),theirsSha:k().optional(),baseSha:k().optional()}).loose(),o1=M({conflicts:j(a1)}).loose(),s1=M({file:k().min(1),strategy:N([`mine`,`theirs`,`content`,`delete`]),content:k().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),c1=M({}).loose(),l1=M({file:k().min(1),base:k(),ours:k(),theirs:k(),kind:N([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:k().nullable()}).loose(),u1=M({}).loose(),d1=M({plan:Ec(e=>e!==void 0,{message:`plan is required`})}).loose(),f1=M({plan:Ec(e=>e!==void 0,{message:`plan is required`})}).loose(),p1=M({result:Ec(e=>e!==void 0,{message:`result is required`})}).loose(),m1=M({path:k().min(1),summary:k().min(1)}).loose(),h1=M({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),g1=M({packs:j(M({id:k().min(1),name:k().min(1),description:k().min(1),defaultSubfolder:k().optional(),folders:j(m1),entryCounts:h1}).loose())}).loose(),_1=M({noOpen:Ls().optional(),out:k().min(1).optional()}).loose(),v1=M({reason:N([`unsupported-platform`,`spawn-error`]),message:k()}).loose(),y1=Qs(`status`,[M({status:P(`installed`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k()}).loose(),M({status:P(`built`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k(),handoffError:v1.optional()}).loose(),M({status:P(`failed`),buildError:k()}).loose(),M({status:P(`skip-current`),skillVersion:k(),recordedAt:k().optional()}).loose()]),b1=M({tags:j(M({name:k().min(1),count:A().int().nonnegative(),isLeaf:Ls()}).loose())}).loose(),x1=M({docName:k().min(1),title:k(),matchingTags:j(k().min(1)),snippet:k().nullable()}).loose(),S1=M({name:k().min(1),docs:j(x1)}).loose(),C1=M({folder:Us(),frontmatter_local:nc(k(),Us()).nullable()}).loose(),w1=M({path:k(),frontmatter:nc(k(),Us()).optional()}).loose(),T1=M({applied:Us()}).loose(),E1=nc(k(),Us()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),D1=M({template:M({name:k().min(1),folder:k(),scope:N([`local`,`inherited`]),path:k().min(1),frontmatter:E1,body:k()}).strict()}).strict(),O1=M({templates:j(M({name:k().min(1),title:k().optional(),description:k().optional(),path:k().min(1),source_folder:k()}).strict()),truncated:Ls()}).strict(),k1=M({folder:k(),name:k(),body:k().optional(),frontmatter:E1.optional()}).strict(),A1=M({path:k().min(1),created:Ls(),warnings:j(k())}).strict(),j1=M({existed:Ls(),path:k().min(1)}).strict(),M1=M({query:k().optional(),intent:N([`autocomplete`,`full_text`,`omnibar`]).optional(),scopes:j(N([`page`,`folder`,`content`])).optional(),scope:k().optional(),limit:A().int().nonnegative().optional()}).loose(),N1=M({kind:N([`page`,`folder`,`content`]),path:k().min(1),title:k(),score:A(),signals:nc(k(),Us()),snippet:k().optional()}).loose(),P1=M({query:k(),intent:N([`autocomplete`,`full_text`,`omnibar`]),results:j(N1),elapsedMs:A().nonnegative()}).loose(),F1=M({version:k().min(1),recordedAt:k().min(1)}).loose(),I1=M({currentVersion:k().min(1),targets:nc(k(),F1.nullable())}).loose(),L1=`server-info`,R1=`branch-switched`,z1=`disk-ack`,B1=`config-validation-rejected`,V1=`config-ignore-nested-error`,H1=N([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),U1=M({v:P(1),ch:P(L1),seq:A(),serverInstanceId:k().min(1),currentBranch:k().min(1).optional()}).loose(),W1=M({v:P(1),ch:P(R1),seq:A(),branch:k().min(1)}).loose(),G1=M({v:P(1),ch:H1,seq:A()}).loose(),K1=M({v:P(1),ch:P(z1),seq:A(),docName:k().min(1),sv:k().min(1)}).loose(),q1=M({v:P(1),ch:P(B1),seq:A(),docName:k().min(1),error:ll}).loose(),J1=M({v:P(1),ch:P(V1),seq:A(),path:k().min(1),error:k().min(1)}).loose(),Y1={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},X1=new WeakMap;function Z1(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function Q1(e){return e.trim().toLowerCase()}function $1(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function e0(e){return e.split(`/`).filter(Boolean).join(` `)}function t0(e){let t=$1(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0;return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:e0(e.path),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function n0(e){let t=PU({schema:Y1});return e.length>0&&GU(t,e),t}function r0(e){let t={documents:e};return X1.set(t,n0(e)),t}function i0(e){let t=X1.get(e);if(t)return t;let n=n0(e.documents);return X1.set(e,n),n}function a0(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`]:[`page`,`folder`]}function o0(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function s0(e,t){let n=Q1(t);if(!n)return 0;let r=Q1(e.title),i=Q1(e.name),a=Q1(e.path),o=a.split(`/`);return r===n||i===n?700:a===n?650:r.startsWith(n)||i.startsWith(n)?600:o.some(e=>e.startsWith(n))?550:r.includes(n)||i.includes(n)?500:a.includes(n)?450:-1}function c0(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function l0(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function u0(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function d0(e,t){return Q1(t).length<4?0:e===`full_text`?1:0}function f0(e,t,n={}){let r=n.intent??`omnibar`,i=Z1(n.limit),a=new Set(n.scopes??a0(r)),o=e.documents.filter(e=>o0(e,a)),s=Q1(t);if(!s)return o.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,i).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let c=xW(i0(e),{term:s,properties:l0(r),boost:u0(r),tolerance:d0(r,s),limit:Math.max(i*4,40)}),l=new Map(c.hits.filter(e=>o0(e.document,a)).map(e=>[e.document.id,e.score])),u=c0(o),d=new Map;for(let e of o)s0(e,s)>=0&&d.set(e.id,e);for(let e of c.hits)o0(e.document,a)&&d.set(e.document.id,e.document);return[...d.values()].map(e=>{let t=Math.max(0,s0(e,s)),n=l.get(e.id)??0,r=u.get(e.id)??0;return{document:e,score:t+n*20+r,signals:{lexical:t,fullText:n,recency:r}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score).slice(0,i)}function p0(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),m0(n)}function m0(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const h0=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),g0=globalThis;g0[h0]===void 0&&(g0[h0]=Fi());const _0=g0[h0],v0=[`.ok`,`skill-state.yml`],y0=[`claude-cowork`,`cli-hosts`],b0=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],x0=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,S0=Js({version:k().regex(x0,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(_0,{description:`Recorded skill version for this target.`}),recordedAt:Vo().register(_0,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:N(b0).register(_0,{description:`Install-source surface that recorded this entry.`}).optional()}),C0=Js({schema:P(1).register(_0,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Js({"claude-cowork":S0.optional(),"cli-hosts":S0.optional()}).register(_0,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function w0(){return{schema:1,targets:{}}}function T0(){let e=!1,t=``,n=0;return r=>{let i=E0(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function E0(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const D0=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],O0={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function k0(e,t=D0){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const A0={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function j0(e){return e?A0[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const M0={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function N0(e){let t=e?.trim();return t?M0[j0(t)]??t:`Agent`}function P0(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const F0=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function I0(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function L0(e){let t=e.trim();return F0.test(t)||t.startsWith(`//`)}function R0(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(L0(n))return{kind:`external`,url:n};let r=P0(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=I0(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function z0(e,t){let n=e.trim();if(!n)return null;if(L0(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=I0(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function B0(e,t){let n=e.trim();if(!n||F0.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function V0(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function H0(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function U0(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function W0(e){return e.split(`/`).filter(e=>e!==``)}function G0(e,t){let n=U0(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function K0(e,t){let n=U0(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:W0(r).length}function q0(e,t){let n=W0(e),r=W0(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function J0(){let e=new Map;function t(t){let n=V0(t);if(n===``)return;let r=H0(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=V0(t),r=H0(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=U0(V0(n)),o=[],s=[];for(let e of i)G0(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=K0(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=K0(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=q0(a,U0(t));for(let r=1;r<e.length;r++){let i=e[r],o=q0(a,U0(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function Y0(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function X0(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function Z0(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function Q0(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function $0(){try{let e=l(c(b(import.meta.url)),`..`,`package.json`),t=JSON.parse(m(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const e2=$0(),t2=1;var n2=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function r2(e,t){return l(e,`${t}.lock`)}const i2=new Map;function a2(e){i2.set(e,(i2.get(e)??0)+1)}function o2(e){let t=i2.get(e);return t===void 0||t<=1?(i2.delete(e),!0):(i2.set(e,t-1),!1)}function s2(e,t){try{let n=JSON.parse(m(e,`utf-8`));return n&&typeof n==`object`&&Q0(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function c2(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;f(n,{recursive:!0});let a=r2(n,t),o={pid:process.pid,hostname:y(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??e2},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!d(a))try{let e=p(a,`wx`,384);try{_(e,s)}finally{u(e)}return a2(a),l2({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=s2(a,i);if(e){let r=e.hostname===y();if(r&&e.pid===process.pid)return g(a,s,{encoding:`utf-8`,mode:384}),a2(a),l2({lockName:t,lockDir:n,lockPath:a});if(r&&Z0(e.pid))throw new n2(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{h(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function l2(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>p2({lockName:t,lockDir:n}),updatePort:e=>u2({lockName:t,lockDir:n,port:e})}}function u2(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=r2(n,t);if(!d(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(m(a,`utf-8`));if(!e||typeof e!=`object`||!Q0(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&!(typeof o.hostname==`string`&&o.hostname!==y())){o.port=r;try{g(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function d2(e){let{lockName:t,lockDir:n}=e,r=r2(n,t);if(!d(r))return null;let i;try{let e=JSON.parse(m(r,`utf-8`));if(!e||typeof e!=`object`||!Q0(e.pid))return null;i=e}catch{return null}if(i.hostname!==y())return null;if(!Z0(i.pid)){try{h(r)}catch{}return null}return i}function f2(e){let{lockName:t,lockDir:n}=e,r=r2(n,t);if(!d(r))return{status:`absent`};let i;try{i=JSON.parse(m(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!Q0(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(o.hostname!==y())return{status:`stale`,lock:o};if(!Z0(o.pid)){try{h(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}function p2(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=r2(n,t);if(o2(i)&&d(i))try{let e=JSON.parse(m(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==y())return;h(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var m2=class extends n2{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function h2(e,t){try{return c2({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof n2&&e.lockName===`server`?new m2(e.existing,e.lockPath):e}}function g2(e,t){u2({lockName:`server`,lockDir:e,port:t})}function _2(e){return d2({lockName:`server`,lockDir:e})}function v2(e){p2({lockName:`server`,lockDir:e})}export{bG as $,Vo as $i,k1 as $n,P0 as $r,k$ as $t,zq as A,Kc as Ai,_q as An,p0 as Ar,kQ as At,K1 as B,Qs as Bi,a$ as Bn,jq as Br,_$ as Bt,DQ as C,Sl as Ci,M1 as Cn,r0 as Cr,KG as Ct,EQ as D,_l as Di,g1 as Dn,BW as Dr,w1 as Dt,_Q as E,ul as Ei,p1 as En,fG as Er,C1 as Et,nG as F,zs as Fi,Oq as Fn,aQ as Fr,JG as Ft,z1 as G,M as Gi,c1 as Gn,dG as Gr,p$ as Gt,R1 as H,P as Hi,l1 as Hn,kq as Hr,m$ as Ht,W1 as I,Vs as Ii,I1 as In,eQ as Ir,_1 as It,hG as J,nc as Ji,i1 as Jn,PG as Jr,c$ as Jt,L1 as K,cc as Ki,n1 as Kn,RW as Kr,h$ as Kt,J1 as L,j as Li,C0 as Ln,HJ as Lr,y1 as Lt,LQ as M,Ns as Mi,wq as Mn,lq as Mr,XQ as Mt,Nq as N,sc as Ni,Cq as Nn,YW as Nr,ZQ as Nt,gQ as O,nl as Oi,d1 as On,N0 as Or,T1 as Ot,ZW as P,N as Pi,Eq as Pn,IZ as Pr,n$ as Pt,xG as Q,_s as Qi,D1 as Qn,B0 as Qr,LZ as Qt,q1 as R,Ls as Ri,j$ as Rn,tq as Rr,A$ as Rt,vQ as S,tl as Si,JQ as Sn,RX as Sr,EG as St,OQ as T,Fc as Ti,f1 as Tn,pG as Tr,P$ as Tt,V1 as U,Js as Ui,o1 as Un,cK as Ur,f$ as Ut,U1 as V,ec as Vi,u1 as Vn,AG as Vr,d$ as Vt,B1 as W,A as Wi,s1 as Wn,$W as Wr,g$ as Wt,SG as X,Xs as Xi,b1 as Xn,UW as Xr,o$ as Xt,CG as Y,k as Yi,S1 as Yn,mQ as Yr,u$ as Yt,yG as Z,Us as Zi,j1 as Zn,hQ as Zr,s$ as Zt,O0 as _,Mc as _i,y0 as _n,z0 as _r,QQ as _t,c2 as a,vr as aa,QZ as ai,FG as an,Y$ as ar,L$ as at,x$ as b,yl as bi,_G as bn,J0 as br,z$ as bt,Q0 as c,fn as ca,Ly as ci,V$ as cn,Wq as cr,I$ as ct,f2 as d,Lt as da,Cl as di,G$ as dn,wQ as dr,IG as dt,zo as ea,f0 as ei,D$ as en,A1 as er,Pq as et,_2 as f,Tt as fa,Wc as fi,K$ as fn,AW as fr,jG as ft,g2 as g,ft as ga,jc as gi,v0 as gn,R0 as gr,J$ as gt,u2 as h,pt as ha,Vc as hi,Q$ as hn,Vq as hr,q$ as ht,m2 as i,ai as ia,XW as ii,NG as in,C$ as ir,a1 as it,RQ as j,qc as ji,yq as jn,Y0 as jr,AQ as jt,TQ as k,$c as ki,Lq as kn,w0 as kr,BQ as kt,r2 as l,mn as la,Df as li,Rq as ln,Uq as lr,YG as lt,v2 as m,D as ma,Hc as mi,Z$ as mn,JW as mr,i$ as mt,e2 as n,Ua as na,PW as ni,kG as nn,w$ as nr,jQ as nt,h2 as o,cn as oa,IW as oi,mG as on,X$ as or,R$ as ot,p2 as p,O as pa,Uc as pi,e$ as pn,kW as pr,wG as pt,vG as q,kc as qi,r1 as qn,FW as qr,Gq as qt,t2 as r,Wa as ra,X0 as ri,t$ as rn,T$ as rr,MQ as rt,Z0 as s,un as sa,uq as si,U$ as sn,DG as sr,F$ as st,n2 as t,da as ta,aq as ti,E$ as tn,O1 as tr,Iq as tt,d2 as u,on as ua,F as ui,Hq as un,$Q as ur,OG as ut,TG as v,Tl as vi,x0 as vn,gG as vr,FQ as vt,yQ as w,pl as wi,P1 as wn,t0 as wr,KQ as wt,S$ as x,Jc as xi,qQ as xn,T0 as xr,B$ as xt,qG as y,wl as yi,MG as yn,k0 as yr,PQ as yt,G1 as z,Ec as zi,Kq as zn,j0 as zr,UQ as zt};
428
+ //# sourceMappingURL=server-lock-BpjJj3OD-DBIqFE7p.mjs.map
@@ -0,0 +1 @@
1
+ import{g as e}from"./server-lock-BpjJj3OD-DBIqFE7p.mjs";export{e as updateServerLockPort};
@@ -1,7 +1,7 @@
1
- import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-2pOoEhSP.mjs";import"./gh-detect-BveVRAue.mjs";import{g as a,h as o,k as s}from"./init-BjjtQpJ4.mjs";import{Sr as c}from"./dist-sld-_d9T.mjs";import"./loader-BSyhsuGY.mjs";import{c as l}from"./colors-BtKMHmBX.mjs";import"./preview-C6kOnHJr.mjs";import{n as u}from"./write-project-skill-ppRYJ9T2.mjs";import{spawnSync as d}from"node:child_process";import{basename as f,dirname as p,isAbsolute as m,join as h,relative as ee,resolve as g}from"node:path";import{existsSync as _,lstatSync as te,readFileSync as v,readdirSync as y,statSync as b}from"node:fs";import{hostname as x}from"node:os";import{readFile as S,realpath as C}from"node:fs/promises";function w(e,t,a={}){let o=r(e,t);if(!_(o))return{status:`missing`,lockPath:o};let s;try{s=JSON.parse(v(o,`utf-8`))}catch{return{status:`corrupt`,lockPath:o}}if(!s||typeof s!=`object`||!n(s.pid))return{status:`corrupt`,lockPath:o};let c=s;if(!(a.isAlive??i)(c.pid))return{status:`dead-pid`,lockPath:o,lock:c};let l=a.host??x();return c.hostname===l?{status:`alive`,lockPath:o,lock:c}:{status:`foreign-host`,lockPath:o,lock:c}}function T(e){return e.replace(/:\d+$/,``)}function E(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function D(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}function O(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`);if(n.length<5||n[0]!==``||n[3]!==`tree`)return null;let r=n.slice(5);r.length===1&&r[0]===``&&r.pop();let i,a,o,s;try{i=decodeURIComponent(n[1]),a=decodeURIComponent(n[2]),o=decodeURIComponent(n[4]),s=r.map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.some(e=>e.length===0)?null:{owner:i,repo:a,branch:o,path:s.join(`/`)}}function k(e){let t=D(e);if(t)return{kind:`doc`,...t};let n=O(e);return n?{kind:`folder`,...n}:null}const A=2e3,j=2e3,ne=[/cli\.mjs/,/(^|[\s/])(open-knowledge|ok)\s+(start|mcp|ui)(\s|$)/,/Open Knowledge(?:\.app| Helper)/,/(^|[\s/])bun([\s/]).*?(run dev|packages\/app|vite|hocuspocus)/,/(^|[\s/])node([\s/]).*?(packages\/(cli|app)|vite|hocuspocus)/,/(^|\s)--ok-lock-dir-b64=/,/(^|\s)--ok-project-path=/];function M(e){return ne.some(t=>t.test(e))}function re(e){let t=e.trim().split(/\s+/).find(e=>e.startsWith(`--ok-lock-dir-b64=`));if(t==null)return null;let n=t.slice(18);if(!n)return null;try{let e=Buffer.from(n,`base64url`).toString(`utf8`);return m(e)?e:null}catch{return null}}function ie(e){let t=e.indexOf(`--ok-project-path=`);if(t===-1)return null;let n=t+18,r=e.slice(n),i=r.search(/\s--/),a=(i===-1?r:r.slice(0,i)).trim();return a&&m(a)?a:null}function ae(e){let t=[];for(let n of e.split(`
1
+ import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-DBIqFE7p.mjs";import"./gh-detect-DCIXLWuz.mjs";import{g as a,h as o,k as s}from"./init-CsAeoxGW.mjs";import{Sr as c}from"./dist-CILctbXr.mjs";import"./loader-DthGvoM_.mjs";import{c as l}from"./colors-BtKMHmBX.mjs";import"./preview-BGlZsxSQ.mjs";import{n as u}from"./write-project-skill-Da4v8WUu.mjs";import{spawnSync as d}from"node:child_process";import{basename as f,dirname as p,isAbsolute as m,join as h,relative as ee,resolve as g}from"node:path";import{existsSync as _,lstatSync as te,readFileSync as v,readdirSync as y,statSync as b}from"node:fs";import{hostname as x}from"node:os";import{readFile as S,realpath as C}from"node:fs/promises";function w(e,t,a={}){let o=r(e,t);if(!_(o))return{status:`missing`,lockPath:o};let s;try{s=JSON.parse(v(o,`utf-8`))}catch{return{status:`corrupt`,lockPath:o}}if(!s||typeof s!=`object`||!n(s.pid))return{status:`corrupt`,lockPath:o};let c=s;if(!(a.isAlive??i)(c.pid))return{status:`dead-pid`,lockPath:o,lock:c};let l=a.host??x();return c.hostname===l?{status:`alive`,lockPath:o,lock:c}:{status:`foreign-host`,lockPath:o,lock:c}}function T(e){return e.replace(/:\d+$/,``)}function E(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function D(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}function O(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`);if(n.length<5||n[0]!==``||n[3]!==`tree`)return null;let r=n.slice(5);r.length===1&&r[0]===``&&r.pop();let i,a,o,s;try{i=decodeURIComponent(n[1]),a=decodeURIComponent(n[2]),o=decodeURIComponent(n[4]),s=r.map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.some(e=>e.length===0)?null:{owner:i,repo:a,branch:o,path:s.join(`/`)}}function k(e){let t=D(e);if(t)return{kind:`doc`,...t};let n=O(e);return n?{kind:`folder`,...n}:null}const A=2e3,j=2e3,ne=[/cli\.mjs/,/(^|[\s/])(open-knowledge|ok)\s+(start|mcp|ui)(\s|$)/,/Open Knowledge(?:\.app| Helper)/,/(^|[\s/])bun([\s/]).*?(run dev|packages\/app|vite|hocuspocus)/,/(^|[\s/])node([\s/]).*?(packages\/(cli|app)|vite|hocuspocus)/,/(^|\s)--ok-lock-dir-b64=/,/(^|\s)--ok-project-path=/];function M(e){return ne.some(t=>t.test(e))}function re(e){let t=e.trim().split(/\s+/).find(e=>e.startsWith(`--ok-lock-dir-b64=`));if(t==null)return null;let n=t.slice(18);if(!n)return null;try{let e=Buffer.from(n,`base64url`).toString(`utf8`);return m(e)?e:null}catch{return null}}function ie(e){let t=e.indexOf(`--ok-project-path=`);if(t===-1)return null;let n=t+18,r=e.slice(n),i=r.search(/\s--/),a=(i===-1?r:r.slice(0,i)).trim();return a&&m(a)?a:null}function ae(e){let t=[];for(let n of e.split(`
2
2
  `)){let e=n.trim();if(!e)continue;let r=e.indexOf(` `);if(r===-1)continue;let i=e.slice(0,r),a=e.slice(r+1),o=Number.parseInt(i,10);!Number.isNaN(o)&&M(a)&&t.push({pid:o,command:a})}return t}function oe(e){let t=[],n=e.split(`
3
3
  `);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.indexOf(` `);if(i===-1)continue;let a=r.slice(0,i),o=r.slice(i+1).trim(),s=Number.parseInt(a,10);!Number.isNaN(s)&&M(o)&&t.push({pid:s,command:o})}return t}async function se(){let e=d(`pgrep`,[`-a`,`-f`,`cli\\.mjs|open-knowledge|Open Knowledge(\\.app| Helper)|--ok-lock-dir-b64=|--ok-project-path=|(^|[ /])ok[ ]+(start|mcp|ui)([ ]|$)|packages/(cli|app)|hocuspocus|vite`],{encoding:`utf-8`,timeout:A});if(!(e.error!=null&&e.error.code===`ENOENT`)){let t=e.stdout??``,n=ae(t);if(n.length>0||t.trim()===``)return n}let t=d(`ps`,[`-axo`,`pid,command`],{encoding:`utf-8`,timeout:A});return t.error!=null||!t.stdout?[]:oe(t.stdout)}function ce(e){let t=e.trim().split(/\s+/).filter(Boolean);for(let e of t){if(e.startsWith(`@`))continue;let t=f(e);if(t===`open-knowledge`||t===`ok`||e.endsWith(`/packages/cli/src/cli.ts`)||e.endsWith(`/packages/cli/dist/cli.mjs`)||t===`cli.mjs`||t===`cli.ts`)return e}return null}function N(e){let t=d(`ps`,[`-p`,String(e),`-o`,`command=`],{encoding:`utf-8`,timeout:A});return t.error!=null||!t.stdout?null:t.stdout.trim()||null}function P(e){let t=d(`ps`,[`-p`,String(e),`-o`,`%cpu=,%mem=`],{encoding:`utf-8`,timeout:A});if(t.error!=null||!t.stdout)return null;let[n,r]=t.stdout.trim().split(/\s+/),i=Number.parseFloat(n??``),a=Number.parseFloat(r??``);return Number.isNaN(i)||Number.isNaN(a)?null:{cpuPercent:i,memPercent:a}}async function F(e){let t=d(`lsof`,[`-p`,String(e),`-a`,`-d`,`cwd`,`-Fn`],{encoding:`utf-8`,timeout:A});if(t.error!=null)return null;let n=t.stdout??``;for(let e of n.split(`
4
4
  `))if(e.startsWith(`n`)&&e.length>1)return e.slice(1);return null}function I(e){let t=[],n=e.split(`
5
5
  `);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.split(/\s+/);if(i.length<2)continue;let a=Number.parseInt(i[1]??``,10);Number.isNaN(a)||t.push(a)}return[...new Set(t)]}function L(e){return _(h(e,`server.lock`))||_(h(e,`ui.lock`))}function R(e,t){for(let n of[h(t,`.ok`,`local`),h(t,`.ok`)])_(n)&&L(n)&&e.add(n)}function z(e,t){let n=0,r=(t,i)=>{if(n>=j||(n++,R(e,t),i>=3))return;let a;try{a=y(t)}catch{return}for(let e of a){if(n>=j)return;if(e===`node_modules`||e===`.git`||e===`Library`||e.startsWith(`.`)&&e!==`.ok`)continue;let a=h(t,e),o=!1;try{o=te(a).isDirectory()}catch{continue}o&&r(a,i+1)}};r(t,0)}async function B(){let e=new Set,t=await se(),n=t.map(e=>F(e.pid)),r=await Promise.all(n);for(let n of t){let t=re(n.command);t!=null&&_(t)&&e.add(t);let r=ie(n.command);r!=null&&R(e,r)}for(let t of r)t!=null&&R(e,t);let i=d(`lsof`,[`-iTCP`,`-sTCP:LISTEN`,`-nP`],{encoding:`utf-8`,timeout:A});if(i.error==null&&i.stdout){let n=I(i.stdout),r=new Set(t.map(e=>e.pid)),a=n.filter(e=>!r.has(e)).map(e=>F(e)),o=await Promise.all(a);for(let t of o)t!=null&&R(e,t)}(e.size===0||r.some(e=>e===`/`))&&z(e,process.cwd());let a=new Map;for(let t of e)try{let e=await C(t);a.set(e,e)}catch{a.set(t,t)}return[...a.values()]}var V=e(l(),1);function H(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function U(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function W(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:ce(r),command:r,isDesktop:H(r)}}function G(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function K(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&G(e)?`ui-orphan`:`stale`}const le=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function ue(e){switch(e){case`running`:return V.default.green(e);case`desktop`:return V.default.blue(e);case`foreign`:return V.default.cyan(e);case`ui-orphan`:return V.default.magenta(e);case`stale`:return V.default.yellow(e)}}function q(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function de(e){return`${q(e.server.usage)} | ${q(e.ui?.usage??null)}`}function fe(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function pe(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=K(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,fe(e),de(e),t,String(n),U(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=ue(K(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=V.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
6
6
  `)}async function J(e={}){let t=e.discover??B,n=e.inspect??w,r=e.log??(e=>console.log(e)),i=e.resolveCommand??N,a=e.resolveUsage??P,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=W(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:K(e)}));r(JSON.stringify(e,null,2));return}r(pe(e.all?s:s.filter(e=>le.has(K(e)))))}function me(){return new t(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await J({all:t.all===!0||e===`all`,json:t.json===!0})})}function he(e,t,n={}){let r=n.isAlive??i,a=[];for(let[n,i]of[[`server`,e],[`ui`,t]])(i.status===`alive`||i.status===`foreign-host`&&r(i.lock.pid))&&a.push({name:n,pid:i.lock.pid,port:i.lock.port});return{targets:a}}function Y(e){let t=e.inspect??(t=>w(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=he(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function X(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Z(e,t=i){let n=await B(),r=null;for(let i of n){let n=w(i,`server`),a=w(i,`ui`);if(X(n,t)&&n.lock.port===e||X(a,t)&&a.lock.port===e)return i;r===null&&(X(n,t)&&n.lock.pid===e||X(a,t)&&a.lock.pid===e)&&(r=i)}return r}function Q(e){let t=Y({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function ge(e){return new t(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=Y({lockDir:c(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await J({});return}if(n===`all`){let e=await B();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=w(n,`server`),r=w(n,`ui`);!X(e,i)&&!X(r,i)||(Q(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await Z(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Q(t);return}Q(c(n))})}async function _e(e,t){let n,r;try{n=await C(g(e)),r=await C(g(p(e)))}catch{return{kind:`not-git`}}if(!$(n,r))return{kind:`symlink-escape`};let i=h(n,`.git`),a;try{a=b(i)}catch{return{kind:`not-git`}}let o;if(a.isDirectory()){let e;try{e=await C(i)}catch{return{kind:`not-git`}}if(!$(e,n))return{kind:`symlink-escape`};o=e}else if(a.isFile()){let e;try{e=await S(i,`utf-8`)}catch{return{kind:`not-git`}}let t=/^gitdir:\s*(.+)$/m.exec(e.trim());if(!t)return{kind:`not-git`};let r=t[1].trim(),a=m(r)?r:g(n,r);try{o=await C(a)}catch{return{kind:`not-git`}}}else return{kind:`not-git`};let s=h(await ve(o),`config`),c;try{c=await S(s,`utf-8`)}catch{return{kind:`not-git`}}let l=be(c);if(l===null)return{kind:`no-origin`};let u=E(l);if(u===null||u.hostname!==`github.com`)return{kind:`non-github`};let d=u.owner.toLowerCase()===t.owner.toLowerCase(),f=u.name.toLowerCase()===t.repo.toLowerCase();return!d||!f?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://github.com/${u.owner}/${u.name}.git`}}async function ve(e){let t;try{t=(await S(h(e,`commondir`),`utf-8`)).trim()}catch{return e}if(t.length===0)return e;let n=m(t)?t:g(e,t);try{return await C(n)}catch{return n}}function $(e,t){if(e===t)return!0;let n=ee(t,e);return n.length>0&&!n.startsWith(`..`)&&!m(n)}function ye(e){let t=e.indexOf(`#`),n=e.indexOf(`;`),r=-1;return t>=0&&n>=0?r=Math.min(t,n):t>=0?r=t:n>=0&&(r=n),(r===-1?e:e.slice(0,r)).trim()}function be(e){let t=!1;for(let n of e.split(/\r?\n/)){let e=ye(n);if(e.length===0)continue;if(e.startsWith(`[`)){t=/^\[\s*remote\s+["']origin["']\s*\]$/.test(e);continue}if(!t)continue;let r=/^url\s*=\s*(.+)$/.exec(e);if(r)return xe(r[1])}return null}function xe(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}const Se=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=a(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let n=u(e,t);return{integration:`project-skill`,editorId:e.id,action:n.action,...n.path?{path:n.path}:{},...n.error?{error:n.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function Ce(e,t,n={},r=Se){let i=[];for(let a of t){let t=s[a];for(let a of r)i.push(a.write(t,e,n))}return i}function we(e,t,n={}){return{integrations:Ce(e,t,n),claudeLaunchJson:t.includes(`claude`)?o(e,n):void 0}}export{me as a,P as c,O as d,E as f,ge as i,D as l,_e as n,B as o,w as p,Y as r,N as s,we as t,k as u};
7
- //# sourceMappingURL=src-B1QW6YWQ.mjs.map
7
+ //# sourceMappingURL=src-Djxmxob_.mjs.map
@@ -0,0 +1 @@
1
+ import{h as e}from"./start-OWDBeL4F.mjs";export{e as startCommand};