@inkeep/open-knowledge 0.30.0-beta.3 → 0.30.0-beta.5

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 (83) hide show
  1. package/dist/assets/skills/discovery/SKILL.md +1 -1
  2. package/dist/assets/skills/project/SKILL.md +1 -1
  3. package/dist/cli.mjs +54 -54
  4. package/dist/config-schema.json +24 -0
  5. package/dist/config.project-local.schema.json +24 -0
  6. package/dist/constants-CvXLVbm6.mjs +2 -0
  7. package/dist/{dist-DAVo_TRx.mjs → dist-Cz2oOaYb.mjs} +17 -15
  8. package/dist/dist-DArAF-Z8.mjs +1 -0
  9. package/dist/{gh-detect-BxDh8M_E.mjs → gh-detect-OjM7QxYB.mjs} +2 -2
  10. package/dist/index.mjs +1 -1
  11. package/dist/init-BRSDpXwQ.mjs +1 -0
  12. package/dist/{init-Cj3rYYNW.mjs → init-iHmXas-2.mjs} +5 -5
  13. package/dist/{launch-json-removal-Bsd2If9V.mjs → launch-json-removal-yifel8HM.mjs} +2 -2
  14. package/dist/loader-b4IAzAz6.mjs +1 -0
  15. package/dist/{loader-DBQRSW23.mjs → loader-hl0o6W6h.mjs} +3 -3
  16. package/dist/{open-browser-6ztGUs93.mjs → open-browser-BE9TwPRU.mjs} +2 -2
  17. package/dist/{preview-4_TQ2eLW.mjs → preview-CPvGhej6.mjs} +2 -2
  18. package/dist/preview-DTCU2jNI.mjs +1 -0
  19. package/dist/public/assets/{ActivityModeContent-gJPRToqC.js → ActivityModeContent-D2vlnwuv.js} +1 -1
  20. package/dist/public/assets/CodeMirrorPropInput-DIQ7Kf5H.js +3 -0
  21. package/dist/public/assets/DocumentContext-D3J8u-yJ.js +35 -0
  22. package/dist/public/assets/{EnableSyncConfirmDialog-Ds9VzFz7.js → EnableSyncConfirmDialog-BARabdkd.js} +1 -1
  23. package/dist/public/assets/{GraphPanel-DticGDW4.js → GraphPanel-fXnpaAgY.js} +1 -1
  24. package/dist/public/assets/{ManagedArtifactProperties-BG7ax3pN.js → ManagedArtifactProperties-BLeL9TCx.js} +1 -1
  25. package/dist/public/assets/{McpConsentDialogBody-jKfEiUIH.js → McpConsentDialogBody-x2AhHc7a.js} +1 -1
  26. package/dist/public/assets/{MermaidDocEditor-B_WSq6De.js → MermaidDocEditor-sSBTLHZ8.js} +1 -1
  27. package/dist/public/assets/{PropertyPanel-JSTiSMvX.js → PropertyPanel-DGyVDpJX.js} +1 -1
  28. package/dist/public/assets/{SettingsDialogBody-C4mvHDJH.js → SettingsDialogBody-UFh0-nb1.js} +2 -2
  29. package/dist/public/assets/{ShareBranchSwitchDialog-2z9NWmqe.js → ShareBranchSwitchDialog-CHkvSij0.js} +1 -1
  30. package/dist/public/assets/{ShareReceiveDialog-CGSDsgBh.js → ShareReceiveDialog-DJb80ZUd.js} +1 -1
  31. package/dist/public/assets/{ShareReceiveMissDialog-D7zjXalK.js → ShareReceiveMissDialog-CtSEaJGF.js} +1 -1
  32. package/dist/public/assets/{SkillEditorActions-CxGse8tc.js → SkillEditorActions-Dd3W2TJ2.js} +1 -1
  33. package/dist/public/assets/SourceEditor-DpFI9KX7.js +1 -0
  34. package/dist/public/assets/{TerminalPanel-B3CcTB8S.js → TerminalPanel-D1ztFh-8.js} +1 -1
  35. package/dist/public/assets/{agent-presence-DJQje6SV.js → agent-presence-DYvXM7da.js} +1 -1
  36. package/dist/public/assets/{auth-state-cache-DyKWS3xm.js → auth-state-cache-DCGhumiU.js} +1 -1
  37. package/dist/public/assets/{config-provider-D0CfBIwU.js → config-provider-Bkj9YufI.js} +1 -1
  38. package/dist/public/assets/{dist-DoFKRM_F.js → dist-B27DnPFz.js} +2 -2
  39. package/dist/public/assets/{dist-CJc7OX7s.js → dist-W-hKJCWn.js} +12 -6
  40. package/dist/public/assets/{doc-hash-B7rSgZqz.js → doc-hash-CCfJH4d9.js} +1 -1
  41. package/dist/public/assets/{documents-events-Bit0pJeY.js → documents-events-C2yqFJPg.js} +1 -1
  42. package/dist/public/assets/file-tree-adapter-8cV2wqcm.js +1 -0
  43. package/dist/public/assets/index-BJaSDWbA.js +2003 -0
  44. package/dist/public/assets/{keyboard-shortcuts-CvYXgqK4.js → keyboard-shortcuts-BrZDq1VP.js} +1 -1
  45. package/dist/public/assets/navigation-targets-D5Vr3b-e.js +1 -0
  46. package/dist/public/assets/{open-managed-artifact-tab-Da7L5wL4.js → open-managed-artifact-tab-7RGWt7Lr.js} +1 -1
  47. package/dist/public/assets/{pending-receive-nav-store-CAm5nHeI.js → pending-receive-nav-store-DRc7Xpt6.js} +1 -1
  48. package/dist/public/assets/{prop-types-BwJNmxtq.js → prop-types-Zdll0W8u.js} +1 -1
  49. package/dist/public/assets/{receive-store-C72xSCDE.js → receive-store-Brkf98BO.js} +1 -1
  50. package/dist/public/assets/{selection-context-JPA-xW1g.js → selection-context-DArc3SI0.js} +1 -1
  51. package/dist/public/assets/{skill-actions-CMd77Yt2.js → skill-actions-BfvtIGj9.js} +1 -1
  52. package/dist/public/assets/{skills-api-UoasHTUi.js → skills-api-DQp0sBix.js} +1 -1
  53. package/dist/public/assets/{src-CXdmKAqZ.js → src-BGo7Caak.js} +1 -1
  54. package/dist/public/assets/{target-navigation-intent-C_Y-i35d.js → target-navigation-intent-BH9odHdJ.js} +1 -1
  55. package/dist/public/assets/{typing-burst-detector-DLup_S3P.js → typing-burst-detector-DiAheTFV.js} +2 -2
  56. package/dist/public/assets/{workspace-paths-CYa5l8eZ.js → workspace-paths-DDVHpOi-.js} +1 -1
  57. package/dist/public/index.html +25 -25
  58. package/dist/{repair-launch-json-CtA3dzno.mjs → repair-launch-json-Ci58ZFOB.mjs} +2 -2
  59. package/dist/{repair-mcp-configs-DP4ZjS6O.mjs → repair-mcp-configs-BZ3WjjMF.mjs} +2 -2
  60. package/dist/{repair-skills-zutt1is6.mjs → repair-skills-DEr0n_7M.mjs} +2 -2
  61. package/dist/repair-skills-Do4RqKu3.mjs +1 -0
  62. package/dist/schemas/v0/config.project-local.schema.json +24 -0
  63. package/dist/server-lock-GuuouVft-BiYh08SN.mjs +1 -0
  64. package/dist/{server-lock-iLcBw_q0-RDMfTH6b.mjs → server-lock-iLcBw_q0-7VqZoW4r.mjs} +25 -18
  65. package/dist/{src-Z7vZvOn3.mjs → src-DhuiHwcZ.mjs} +3 -3
  66. package/dist/{start-B1VS-wwf.mjs → start-CmL4qv8P.mjs} +2 -2
  67. package/dist/start-D06sB6Pa.mjs +1 -0
  68. package/dist/{write-project-skill-BzVHToYO.mjs → write-project-skill-DNrA5OdY.mjs} +2 -2
  69. package/package.json +1 -1
  70. package/dist/constants-CgHcIqh6.mjs +0 -2
  71. package/dist/dist-DJ0wJimx.mjs +0 -1
  72. package/dist/init-CNK7GfhY.mjs +0 -1
  73. package/dist/loader-BkadQueQ.mjs +0 -1
  74. package/dist/preview-4uaPC3tK.mjs +0 -1
  75. package/dist/public/assets/CodeMirrorPropInput-A-b7Ox39.js +0 -3
  76. package/dist/public/assets/DocumentContext-Cf3xyIUc.js +0 -35
  77. package/dist/public/assets/SourceEditor-B4hGDoTR.js +0 -1
  78. package/dist/public/assets/file-tree-adapter--v55j77z.js +0 -1
  79. package/dist/public/assets/index--kgVY3Zd.js +0 -2003
  80. package/dist/public/assets/navigation-targets-D-taKoGj.js +0 -1
  81. package/dist/repair-skills-B0TdudPZ.mjs +0 -1
  82. package/dist/server-lock-GuuouVft-CCnjEa8y.mjs +0 -1
  83. package/dist/start-DGO0EIO_.mjs +0 -1
@@ -151,7 +151,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
151
151
 
152
152
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Nt,s=!vt.jitless,c=s&&Pt.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?oi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function li(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Yt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Qt(e,r,yt())))}),t)}const ui=O(`$ZodUnion`,(e,t)=>{br.init(e,t),Dt(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),Dt(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Dt(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Dt(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>wt(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>li(t,i,e,a)):li(s,i,e,a)}}),di=O(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ui.init(e,t);let n=e._zod.parse;Dt(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=St(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Nt(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),fi=O(`$ZodIntersection`,(e,t)=>{br.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>mi(e,t,n)):mi(e,i,a)}});function pi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ft(e)&&Ft(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=pi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function mi(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Yt(e))return e;let o=pi(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const hi=O(`$ZodRecord`,(e,t)=>{br.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Ft(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Xt(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Xt(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Xn.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Qt(e,r,yt())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Xt(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Xt(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),gi=O(`$ZodEnum`,(e,t)=>{br.init(e,t);let n=bt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Lt.has(typeof e)).map(e=>typeof e==`string`?Rt(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),_i=O(`$ZodLiteral`,(e,t)=>{if(br.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Rt(e):e?Rt(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),vi=O(`$ZodTransform`,(e,t)=>{br.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new _t(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new gt;return n.value=i,n}});function yi(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const bi=O(`$ZodOptional`,(e,t)=>{br.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,Dt(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Dt(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${wt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>yi(t,e.value)):yi(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),xi=O(`$ZodExactOptional`,(e,t)=>{bi.init(e,t),Dt(e._zod,`values`,()=>t.innerType._zod.values),Dt(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Si=O(`$ZodNullable`,(e,t)=>{br.init(e,t),Dt(e._zod,`optin`,()=>t.innerType._zod.optin),Dt(e._zod,`optout`,()=>t.innerType._zod.optout),Dt(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${wt(e.source)}|null)$`):void 0}),Dt(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ci=O(`$ZodDefault`,(e,t)=>{br.init(e,t),e._zod.optin=`optional`,Dt(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>wi(e,t)):wi(r,t)}});function wi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Ti=O(`$ZodPrefault`,(e,t)=>{br.init(e,t),e._zod.optin=`optional`,Dt(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ei=O(`$ZodNonOptional`,(e,t)=>{br.init(e,t),Dt(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Di(t,e)):Di(i,e)}});function Di(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Oi=O(`$ZodCatch`,(e,t)=>{br.init(e,t),Dt(e._zod,`optin`,()=>t.innerType._zod.optin),Dt(e._zod,`optout`,()=>t.innerType._zod.optout),Dt(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Qt(e,n,yt()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Qt(e,n,yt()))},input:e.value}),e.issues=[]),e)}}),ki=O(`$ZodPipe`,(e,t)=>{br.init(e,t),Dt(e._zod,`values`,()=>t.in._zod.values),Dt(e._zod,`optin`,()=>t.in._zod.optin),Dt(e._zod,`optout`,()=>t.out._zod.optout),Dt(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ai(e,t.in,n)):Ai(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ai(e,t.out,n)):Ai(r,t.out,n)}});function Ai(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ji=O(`$ZodReadonly`,(e,t)=>{br.init(e,t),Dt(e._zod,`propValues`,()=>t.innerType._zod.propValues),Dt(e._zod,`values`,()=>t.innerType._zod.values),Dt(e._zod,`optin`,()=>t.innerType?._zod?.optin),Dt(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Mi):Mi(r)}});function Mi(e){return e.value=Object.freeze(e.value),e}const Ni=O(`$ZodLazy`,(e,t)=>{br.init(e,t),Dt(e._zod,`innerType`,()=>t.getter()),Dt(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),Dt(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),Dt(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),Dt(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Pi=O(`$ZodCustom`,(e,t)=>{tr.init(e,t),br.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Fi(t,n,r,e));Fi(i,n,r,e)}});function Fi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(en(e))}}var Ii,Li=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ri(){return new Li}(Ii=globalThis).__zod_globalRegistry??(Ii.__zod_globalRegistry=Ri());const zi=globalThis.__zod_globalRegistry;function Bi(e,t){return new e({type:`string`,...k(t)})}function Vi(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...k(t)})}function Hi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...k(t)})}function Ui(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...k(t)})}function Wi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...k(t)})}function Gi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...k(t)})}function Ki(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...k(t)})}function qi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...k(t)})}function Ji(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...k(t)})}function Yi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...k(t)})}function Xi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...k(t)})}function Zi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...k(t)})}function Qi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...k(t)})}function $i(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...k(t)})}function ea(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...k(t)})}function ta(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...k(t)})}function na(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...k(t)})}function ra(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...k(t)})}function ia(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...k(t)})}function aa(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...k(t)})}function oa(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...k(t)})}function sa(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...k(t)})}function ca(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...k(t)})}function la(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...k(t)})}function ua(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...k(t)})}function da(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...k(t)})}function fa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...k(t)})}function pa(e,t){return new e({type:`number`,checks:[],...k(t)})}function ma(e,t){return new e({type:`number`,coerce:!0,checks:[],...k(t)})}function ha(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...k(t)})}function ga(e,t){return new e({type:`boolean`,...k(t)})}function _a(e,t){return new e({type:`null`,...k(t)})}function va(e){return new e({type:`any`})}function ya(e){return new e({type:`unknown`})}function ba(e,t){return new e({type:`never`,...k(t)})}function xa(e,t){return new rr({check:`less_than`,...k(t),value:e,inclusive:!1})}function Sa(e,t){return new rr({check:`less_than`,...k(t),value:e,inclusive:!0})}function Ca(e,t){return new ir({check:`greater_than`,...k(t),value:e,inclusive:!1})}function wa(e,t){return new ir({check:`greater_than`,...k(t),value:e,inclusive:!0})}function Ta(e,t){return new ar({check:`multiple_of`,...k(t),value:e})}function Ea(e,t){return new sr({check:`max_length`,...k(t),maximum:e})}function Da(e,t){return new cr({check:`min_length`,...k(t),minimum:e})}function Oa(e,t){return new lr({check:`length_equals`,...k(t),length:e})}function ka(e,t){return new dr({check:`string_format`,format:`regex`,...k(t),pattern:e})}function Aa(e){return new fr({check:`string_format`,format:`lowercase`,...k(e)})}function ja(e){return new pr({check:`string_format`,format:`uppercase`,...k(e)})}function Ma(e,t){return new mr({check:`string_format`,format:`includes`,...k(t),includes:e})}function Na(e,t){return new hr({check:`string_format`,format:`starts_with`,...k(t),prefix:e})}function Pa(e,t){return new gr({check:`string_format`,format:`ends_with`,...k(t),suffix:e})}function Fa(e){return new _r({check:`overwrite`,tx:e})}function Ia(e){return Fa(t=>t.normalize(e))}function La(){return Fa(e=>e.trim())}function Ra(){return Fa(e=>e.toLowerCase())}function za(){return Fa(e=>e.toUpperCase())}function Ba(){return Fa(e=>jt(e))}function Va(e,t,n){return new e({type:`array`,element:t,...k(n)})}function Ha(e,t,n){let r=k(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Ua(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...k(n)})}function Wa(e){let t=Ga(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(en(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(en(r))}},e(n.value,n)));return t}function Ga(e,t){let n=new tr({check:`custom`,...k(t)});return n._zod.check=e,n}function Ka(e){let t=new tr({check:`describe`});return t._zod.onattach=[t=>{let n=zi.get(t)??{};zi.add(t,{...n,description:e})}],t._zod.check=()=>{},t}function qa(e){let t=new tr({check:`meta`});return t._zod.onattach=[t=>{let n=zi.get(t)??{};zi.add(t,{...n,...e})}],t._zod.check=()=>{},t}function Ja(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??zi,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Ya(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Ya(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Qa(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Xa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
153
153
 
154
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Za(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:eo(t,`input`,e.processors),output:eo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Qa(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Qa(r.element,n);if(r.type===`set`)return Qa(r.valueType,n);if(r.type===`lazy`)return Qa(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Qa(r.innerType,n);if(r.type===`intersection`)return Qa(r.left,n)||Qa(r.right,n);if(r.type===`record`||r.type===`map`)return Qa(r.keyType,n)||Qa(r.valueType,n);if(r.type===`pipe`)return Qa(r.in,n)||Qa(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Qa(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Qa(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Qa(e,n))return!0;return!!(r.rest&&Qa(r.rest,n))}return!1}const $a=(e,t={})=>n=>{let r=Ja({...n,processors:t});return Ya(e,r),Xa(r,e),Za(r,e)},eo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ja({...i??{},target:a,io:t,processors:n});return Ya(e,o),Xa(o,e),Za(o,e)},to={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},no=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=to[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},ro=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},io=(e,t,n,r)=>{n.type=`boolean`},ao=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},oo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},so=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},co=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},lo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},uo=(e,t,n,r)=>{n.not={}},fo=(e,t,n,r)=>{},po=(e,t,n,r)=>{},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{let i=e._zod.def,a=bt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},go=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},_o=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},vo=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},yo=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},bo=(e,t,n,r)=>{n.type=`boolean`},xo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},So=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Co=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},wo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},To=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Eo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Ya(a.element,t,{...r,path:[...r.path,`items`]})},Do=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Ya(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Ya(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Oo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ya(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ko=(e,t,n,r)=>{let i=e._zod.def,a=Ya(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ya(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Ao=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Ya(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Ya(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},jo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Ya(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Ya(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Ya(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Mo=(e,t,n,r)=>{let i=e._zod.def,a=Ya(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},No=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Po=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Fo=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Io=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Lo=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;Ya(a,t,r);let o=t.seen.get(e);o.ref=a},Ro=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},zo=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Bo=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Vo=(e,t,n,r)=>{let i=e._zod.innerType;Ya(i,t,r);let a=t.seen.get(e);a.ref=i},Ho={string:no,number:ro,boolean:io,bigint:ao,symbol:oo,null:so,undefined:co,void:lo,never:uo,any:fo,unknown:po,date:mo,enum:ho,literal:go,nan:_o,template_literal:vo,file:yo,success:bo,custom:xo,function:So,transform:Co,map:wo,set:To,array:Eo,object:Do,union:Oo,intersection:ko,tuple:Ao,record:jo,nullable:Mo,nonoptional:No,default:Po,prefault:Fo,catch:Io,pipe:Lo,readonly:Ro,promise:zo,optional:Bo,lazy:Vo};function Uo(e,t){if(`_idmap`in e){let n=e,r=Ja({...t,processors:Ho}),i={};for(let e of n._idmap.entries()){let[t,n]=e;Ya(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;Xa(r,n),a[t]=Za(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Ja({...t,processors:Ho});return Ya(e,n),Xa(n,e),Za(n,e)}const Wo=O(`ZodISODateTime`,(e,t)=>{Pr.init(e,t),gs.init(e,t)});function Go(e){return la(Wo,e)}const Ko=O(`ZodISODate`,(e,t)=>{Fr.init(e,t),gs.init(e,t)});function qo(e){return ua(Ko,e)}const Jo=O(`ZodISOTime`,(e,t)=>{Ir.init(e,t),gs.init(e,t)});function Yo(e){return da(Jo,e)}const Xo=O(`ZodISODuration`,(e,t)=>{Lr.init(e,t),gs.init(e,t)});function Zo(e){return fa(Xo,e)}const Qo=(e,t)=>{nn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>on(e,t)},flatten:{value:t=>an(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,xt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,xt,2)}},isEmpty:{get(){return e.issues.length===0}}})};O(`ZodError`,Qo);const $o=O(`ZodError`,Qo,{Parent:Error}),es=ln($o),ts=dn($o),ns=pn($o),rs=hn($o),is=_n($o),as=vn($o),ss=yn($o),cs=bn($o),ls=xn($o),us=Sn($o),ds=Cn($o),fs=wn($o),ps=O(`ZodType`,(e,t)=>(br.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:eo(e,`input`),output:eo(e,`output`)}}),e.toJSONSchema=$a(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(kt(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>zt(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>es(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ns(e,t,n),e.parseAsync=async(t,n)=>ts(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>rs(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>is(e,t,n),e.decode=(t,n)=>as(e,t,n),e.encodeAsync=async(t,n)=>ss(e,t,n),e.decodeAsync=async(t,n)=>cs(e,t,n),e.safeEncode=(t,n)=>ls(e,t,n),e.safeDecode=(t,n)=>us(e,t,n),e.safeEncodeAsync=async(t,n)=>ds(e,t,n),e.safeDecodeAsync=async(t,n)=>fs(e,t,n),e.refine=(t,n)=>e.check(Mc(t,n)),e.superRefine=t=>e.check(Nc(t)),e.overwrite=t=>e.check(Fa(t)),e.optional=()=>dc(e),e.exactOptional=()=>pc(e),e.nullable=()=>hc(e),e.nullish=()=>dc(hc(e)),e.nonoptional=t=>xc(e,t),e.array=()=>N(e),e.or=t=>$s([e,t]),e.and=t=>rc(e,t),e.transform=t=>Tc(e,lc(t)),e.default=t=>_c(e,t),e.prefault=t=>yc(e,t),e.catch=t=>Cc(e,t),e.pipe=t=>Tc(e,t),e.readonly=()=>Dc(e),e.describe=t=>{let n=e.clone();return zi.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return zi.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return zi.get(e);let n=e.clone();return zi.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),ms=O(`_ZodString`,(e,t)=>{xr.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>no(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ka(...t)),e.includes=(...t)=>e.check(Ma(...t)),e.startsWith=(...t)=>e.check(Na(...t)),e.endsWith=(...t)=>e.check(Pa(...t)),e.min=(...t)=>e.check(Da(...t)),e.max=(...t)=>e.check(Ea(...t)),e.length=(...t)=>e.check(Oa(...t)),e.nonempty=(...t)=>e.check(Da(1,...t)),e.lowercase=t=>e.check(Aa(t)),e.uppercase=t=>e.check(ja(t)),e.trim=()=>e.check(La()),e.normalize=(...t)=>e.check(Ia(...t)),e.toLowerCase=()=>e.check(Ra()),e.toUpperCase=()=>e.check(za()),e.slugify=()=>e.check(Ba())}),hs=O(`ZodString`,(e,t)=>{xr.init(e,t),ms.init(e,t),e.email=t=>e.check(Vi(_s,t)),e.url=t=>e.check(qi(bs,t)),e.jwt=t=>e.check(ca(Is,t)),e.emoji=t=>e.check(Ji(Ss,t)),e.guid=t=>e.check(Hi(vs,t)),e.uuid=t=>e.check(Ui(ys,t)),e.uuidv4=t=>e.check(Wi(ys,t)),e.uuidv6=t=>e.check(Gi(ys,t)),e.uuidv7=t=>e.check(Ki(ys,t)),e.nanoid=t=>e.check(Yi(Cs,t)),e.guid=t=>e.check(Hi(vs,t)),e.cuid=t=>e.check(Xi(ws,t)),e.cuid2=t=>e.check(Zi(Ts,t)),e.ulid=t=>e.check(Qi(Es,t)),e.base64=t=>e.check(aa(Ns,t)),e.base64url=t=>e.check(oa(Ps,t)),e.xid=t=>e.check($i(Ds,t)),e.ksuid=t=>e.check(ea(Os,t)),e.ipv4=t=>e.check(ta(ks,t)),e.ipv6=t=>e.check(na(As,t)),e.cidrv4=t=>e.check(ra(js,t)),e.cidrv6=t=>e.check(ia(Ms,t)),e.e164=t=>e.check(sa(Fs,t)),e.datetime=t=>e.check(Go(t)),e.date=t=>e.check(qo(t)),e.time=t=>e.check(Yo(t)),e.duration=t=>e.check(Zo(t))});function A(e){return Bi(hs,e)}const gs=O(`ZodStringFormat`,(e,t)=>{Sr.init(e,t),ms.init(e,t)}),_s=O(`ZodEmail`,(e,t)=>{Tr.init(e,t),gs.init(e,t)}),vs=O(`ZodGUID`,(e,t)=>{Cr.init(e,t),gs.init(e,t)}),ys=O(`ZodUUID`,(e,t)=>{wr.init(e,t),gs.init(e,t)}),bs=O(`ZodURL`,(e,t)=>{Er.init(e,t),gs.init(e,t)});function xs(e){return qi(bs,e)}const Ss=O(`ZodEmoji`,(e,t)=>{Dr.init(e,t),gs.init(e,t)}),Cs=O(`ZodNanoID`,(e,t)=>{Or.init(e,t),gs.init(e,t)}),ws=O(`ZodCUID`,(e,t)=>{kr.init(e,t),gs.init(e,t)}),Ts=O(`ZodCUID2`,(e,t)=>{Ar.init(e,t),gs.init(e,t)}),Es=O(`ZodULID`,(e,t)=>{jr.init(e,t),gs.init(e,t)}),Ds=O(`ZodXID`,(e,t)=>{Mr.init(e,t),gs.init(e,t)}),Os=O(`ZodKSUID`,(e,t)=>{Nr.init(e,t),gs.init(e,t)}),ks=O(`ZodIPv4`,(e,t)=>{Rr.init(e,t),gs.init(e,t)}),As=O(`ZodIPv6`,(e,t)=>{zr.init(e,t),gs.init(e,t)}),js=O(`ZodCIDRv4`,(e,t)=>{Br.init(e,t),gs.init(e,t)}),Ms=O(`ZodCIDRv6`,(e,t)=>{Vr.init(e,t),gs.init(e,t)}),Ns=O(`ZodBase64`,(e,t)=>{Ur.init(e,t),gs.init(e,t)}),Ps=O(`ZodBase64URL`,(e,t)=>{Gr.init(e,t),gs.init(e,t)}),Fs=O(`ZodE164`,(e,t)=>{Kr.init(e,t),gs.init(e,t)}),Is=O(`ZodJWT`,(e,t)=>{Jr.init(e,t),gs.init(e,t)}),Ls=O(`ZodNumber`,(e,t)=>{Yr.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ro(e,t,n,r),e.gt=(t,n)=>e.check(Ca(t,n)),e.gte=(t,n)=>e.check(wa(t,n)),e.min=(t,n)=>e.check(wa(t,n)),e.lt=(t,n)=>e.check(xa(t,n)),e.lte=(t,n)=>e.check(Sa(t,n)),e.max=(t,n)=>e.check(Sa(t,n)),e.int=t=>e.check(zs(t)),e.safe=t=>e.check(zs(t)),e.positive=t=>e.check(Ca(0,t)),e.nonnegative=t=>e.check(wa(0,t)),e.negative=t=>e.check(xa(0,t)),e.nonpositive=t=>e.check(Sa(0,t)),e.multipleOf=(t,n)=>e.check(Ta(t,n)),e.step=(t,n)=>e.check(Ta(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function j(e){return pa(Ls,e)}const Rs=O(`ZodNumberFormat`,(e,t)=>{Xr.init(e,t),Ls.init(e,t)});function zs(e){return ha(Rs,e)}const Bs=O(`ZodBoolean`,(e,t)=>{Zr.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>io(e,t,n,r)});function M(e){return ga(Bs,e)}const Vs=O(`ZodNull`,(e,t)=>{Qr.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r)});function Hs(e){return _a(Vs,e)}const Us=O(`ZodAny`,(e,t)=>{$r.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ws(){return va(Us)}const Gs=O(`ZodUnknown`,(e,t)=>{ei.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ks(){return ya(Gs)}const qs=O(`ZodNever`,(e,t)=>{ti.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r)});function Js(e){return ba(qs,e)}const Ys=O(`ZodArray`,(e,t)=>{ri.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Da(t,n)),e.nonempty=t=>e.check(Da(1,t)),e.max=(t,n)=>e.check(Ea(t,n)),e.length=(t,n)=>e.check(Oa(t,n)),e.unwrap=()=>e.element});function N(e,t){return Va(Ys,e,t)}const Xs=O(`ZodObject`,(e,t)=>{ci.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r),Dt(e,`shape`,()=>t.shape),e.keyof=()=>F(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ks()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ks()}),e.strict=()=>e.clone({...e._zod.def,catchall:Js()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Wt(e,t),e.safeExtend=t=>Gt(e,t),e.merge=t=>Kt(e,t),e.pick=t=>Ht(e,t),e.omit=t=>Ut(e,t),e.partial=(...t)=>qt(uc,e,t[0]),e.required=(...t)=>Jt(bc,e,t[0])});function P(e,t){return new Xs({type:`object`,shape:e??{},...k(t)})}function Zs(e,t){return new Xs({type:`object`,shape:e,catchall:Ks(),...k(t)})}const Qs=O(`ZodUnion`,(e,t)=>{ui.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.options=t.options});function $s(e,t){return new Qs({type:`union`,options:e,...k(t)})}const ec=O(`ZodDiscriminatedUnion`,(e,t)=>{Qs.init(e,t),di.init(e,t)});function tc(e,t,n){return new ec({type:`union`,options:t,discriminator:e,...k(n)})}const nc=O(`ZodIntersection`,(e,t)=>{fi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r)});function rc(e,t){return new nc({type:`intersection`,left:e,right:t})}const ic=O(`ZodRecord`,(e,t)=>{hi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ac(e,t,n){return new ic({type:`record`,keyType:e,valueType:t,...k(n)})}const oc=O(`ZodEnum`,(e,t)=>{gi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new oc({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new oc({...t,checks:[],...k(r),entries:i})}});function F(e,t){return new oc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...k(t)})}const sc=O(`ZodLiteral`,(e,t)=>{_i.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function I(e,t){return new sc({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}const cc=O(`ZodTransform`,(e,t)=>{vi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new _t(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(en(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(en(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function lc(e){return new cc({type:`transform`,transform:e})}const uc=O(`ZodOptional`,(e,t)=>{bi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new uc({type:`optional`,innerType:e})}const fc=O(`ZodExactOptional`,(e,t)=>{xi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pc(e){return new fc({type:`optional`,innerType:e})}const mc=O(`ZodNullable`,(e,t)=>{Si.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hc(e){return new mc({type:`nullable`,innerType:e})}const gc=O(`ZodDefault`,(e,t)=>{Ci.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _c(e,t){return new gc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():It(t)}})}const vc=O(`ZodPrefault`,(e,t)=>{Ti.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yc(e,t){return new vc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():It(t)}})}const bc=O(`ZodNonOptional`,(e,t)=>{Ei.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xc(e,t){return new bc({type:`nonoptional`,innerType:e,...k(t)})}const Sc=O(`ZodCatch`,(e,t)=>{Oi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Cc(e,t){return new Sc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const wc=O(`ZodPipe`,(e,t)=>{ki.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.in=t.in,e.out=t.out});function Tc(e,t){return new wc({type:`pipe`,in:e,out:t})}const Ec=O(`ZodReadonly`,(e,t)=>{ji.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Dc(e){return new Ec({type:`readonly`,innerType:e})}const Oc=O(`ZodLazy`,(e,t)=>{Ni.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function kc(e){return new Oc({type:`lazy`,getter:e})}const Ac=O(`ZodCustom`,(e,t)=>{Pi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r)});function jc(e,t){return Ha(Ac,e??(()=>!0),t)}function Mc(e,t={}){return Ua(Ac,e,t)}function Nc(e){return Wa(e)}function Pc(e,t){return Tc(lc(e),t)}var Fc=mt();a();const Ic=new Set(Object.keys({sh:`bash`,zsh:`bash`,bash:`bash`,c:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,"c++":`cpp`,h:`c`,hh:`cpp`,hpp:`cpp`,cs:`csharp`,css:`css`,less:`less`,scss:`scss`,sass:`scss`,diff:`diff`,patch:`diff`,go:`go`,gql:`graphql`,graphql:`graphql`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`ini`,java:`java`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,kt:`kotlin`,kts:`kotlin`,lua:`lua`,makefile:`makefile`,md:`markdown`,mdx:`markdown`,m:`objectivec`,mm:`objectivec`,pl:`perl`,pm:`perl`,php:`php`,phtml:`php`,py:`python`,pyi:`python`,pyx:`python`,r:`r`,rb:`ruby`,rs:`rust`,sql:`sql`,swift:`swift`,ts:`typescript`,tsx:`typescript`,xml:`xml`,yaml:`yaml`,yml:`yaml`})),Lc=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],Rc=[`video/mp4`,`video/webm`,`video/ogg`],zc=[`audio/mpeg`,`audio/wav`,`audio/ogg`],Bc=[`application/pdf`],Vc=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`]),Hc=new Set([`mp4`,`webm`,`mov`,`m4v`,`mkv`]),Uc=new Set([`pdf`]),Wc=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]),Gc=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(`.`)),Kc=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(`.`)),qc=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.7z.tar.gz.rar.woff.woff2.ttf.otf.eot.docx.xlsx.pptx.doc.xls.ppt.odt.ods.odp.pages.numbers.key.epub.mobi.csv.tsv.txt.rtf.json.yaml.yml.xml.toml.lock.gpx.html.htm`.split(`.`)),Jc=new Set([`html`,`htm`]),Yc=`sandbox allow-scripts; connect-src 'none'`,Xc=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(`.`)),Zc=`same-dir`,Qc=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(`.`)),$c=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`],el=[`mp4`,`webm`,`mov`,`m4v`],tl=[`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`],nl=[`pdf`],rl=[`json`,`toml`,`lock`];function il(e,t,n){for(let r of t)if(!n.has(r))throw Error(`${e}: ${r} is not present in canonical upload constants`)}il(`SIDEBAR_IMAGE_ASSET_EXTENSIONS`,$c,Vc),il(`SIDEBAR_VIDEO_ASSET_EXTENSIONS`,el,Hc),il(`SIDEBAR_AUDIO_ASSET_EXTENSIONS`,tl,Wc),il(`SIDEBAR_PDF_ASSET_EXTENSIONS`,nl,Uc),il(`FILE_ATTACHMENT_EXTENSIONS`,[...Gc],Qc),il(`WIKI_EMBED_EXTENSIONS`,[...Qc],qc);const al=new Set($c),ol=new Set(el),sl=new Set(tl),cl=new Set(nl),ll=new Set(rl);il(`SIDEBAR_RENDERABLE_ASSET_EXTENSIONS`,[...new Set([...$c,...el,...tl,...nl,...rl])],Xc);const ul=new Set([`base`,`canvas`]),dl=new Set([`mmd`,`mermaid`]);function fl(e){let t=e.lastIndexOf(`.`);return t<0?!1:dl.has(e.slice(t+1).toLowerCase())}const pl=new Set([...qc,...ul,...dl]);function ml(e){let t=e.toLowerCase().replace(/^\./,``);return al.has(t)?`image`:ol.has(t)?`video`:sl.has(t)?`audio`:cl.has(t)?`pdf`:ll.has(t)||ul.has(t)?`text`:dl.has(t)?`mermaid`:Ic.has(t)?`text`:null}const hl=Symbol.for(`@inkeep/open-knowledge/field-registry`),gl=globalThis;gl[hl]===void 0&&(gl[hl]=Ri());const _l=gl[hl];function vl(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=yl(t)?_l.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function yl(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}const bl=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),xl=52428800,Sl=26214400,Cl=`https://api.openai.com/v1`,wl=`text-embedding-3-small`;function Tl(e){let t=e.trim();return t===``?`./`:t}function El(e){let t=Tl(e);return t.includes(`\0`)||t.includes(`\\`)?!1:t===`/`?!0:!(t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.split(`/`).some(e=>e===`..`))}const Dl=Zs({content:Zs({dir:A().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Folder OpenKnowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore.`}).default(`.`),attachmentFolderPath:A().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Where pasted and dropped assets are stored, relative to the content root. './' colocates beside the current document (default); '/' targets the content root; './subdir' targets a subfolder under the current document folder; 'folder' targets a fixed folder under the content root. Whitespace-only values are treated as './'.`}).refine(El,{message:`Invalid attachment folder path: must not contain '..' segments, NUL bytes, backslashes, or OS absolute paths (use '/' for the content root).`}).default(`./`)}).default({dir:`.`,attachmentFolderPath:`./`}),appearance:Zs({theme:F([`light`,`dark`,`system`]).register(_l,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),preview:Zs({autoOpen:M().register(_l,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:Zs({showHiddenFiles:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1)}).optional()}).default({preview:{autoOpen:!0}}),editor:Zs({wordWrap:M().register(_l,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0}),agents:Zs({autoApproveOkTools:M().register(_l,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools (and `ok open` on Claude) for agents launched from the built-in terminal. Destructive tools (delete/move/share/install) still prompt. Per-machine personal preference (user scope)."}).default(!0)}).default({autoApproveOkTools:!0}),autoSync:Zs({enabled:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Whether this machine auto-pulls and auto-pushes git commits for this project. null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared.`}).nullable().default(null),default:M().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Committed project default for a machine's autoSync.enabled on first open: true = auto-sync on, false = off, null = ask (show the onboarding prompt). Shared via git. A per-machine autoSync.enabled choice overrides it.`}).nullable().default(null)}).default({enabled:null,default:null}),terminal:Zs({enabled:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null)}).default({enabled:null}),telemetry:Zs({localSink:Zs({enabled:M().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:Zs({maxBytes:j().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(xl)}).default({maxBytes:xl}),logs:Zs({maxBytes:j().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(Sl)}).default({maxBytes:Sl}),attributeDenylist:N(A()).register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...bl])}).default({enabled:!0,spans:{maxBytes:xl},logs:{maxBytes:Sl},attributeDenylist:[...bl]})}).default({localSink:{enabled:!0,spans:{maxBytes:xl},logs:{maxBytes:Sl},attributeDenylist:[...bl]}}),search:Zs({semantic:Zs({enabled:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:A().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override for Azure / self-hosted / other providers. The API key is NOT stored here — set it with `ok embeddings set-key` (OS keyring)."}).default(Cl),model:A().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(wl),dimensions:j().int().positive().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit to use the model's native size (1536 for text-embedding-3-small). Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality. Changing it re-embeds the corpus.`}).optional(),similarityFloor:j().min(0).max(1).register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Optional hard cutoff: drop any "by meaning" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap.`}).optional()}).default({enabled:!1,baseUrl:Cl,model:wl})}).default({semantic:{enabled:!1,baseUrl:Cl,model:wl}})}),Ol=`open-knowledge-config`;async function kl(e,t,n){let r=o.getTracer(Ol),a=t?{attributes:t}:{};return r.startActiveSpan(e,a,async e=>{try{return await n(e)}catch(t){throw e.recordException(t),e.setStatus({code:i.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function Al(e,t,n){let r=o.getTracer(Ol),a=t?{attributes:t}:{};return r.startActiveSpan(e,a,e=>{try{return n(e)}catch(t){throw e.recordException(t),e.setStatus({code:i.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function jl(e,t){let n=o.getActiveSpan();n&&n.addEvent(e,t)}function Ml(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function Nl(e,t){let n=e;for(let e of t){n=Ml(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function Pl(e,t){let n=Nl(e,t);if(n!==void 0)return vl(n)}function Fl(e,t){return e===`either`?!0:e===t}function Il(e,t){let n=null;function r(e,i){if(n!==null||e===void 0)return;if(typeof e==`object`&&e&&!Array.isArray(e)){for(let[t,a]of Object.entries(e))if(r(a,[...i,t]),n!==null)return;return}let a=Pl(Dl,i);a?.scope!==void 0&&(Fl(a.scope,t)||(n={code:`SCOPE_VIOLATION`,path:i,expectedScope:a.scope,actualScope:t}))}for(let[t,i]of Object.entries(e))if(r(i,[t]),n!==null)break;return n}function Ll(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&((0,Fc.isCollection)(e.getIn(r,!0))||e.deleteIn(r))}}function Rl(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){Ll(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}Ll(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function zl(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}const Bl=P({file:A(),line:j().int().min(1),column:j().int().min(1),snippet:A().optional()}),Vl=P({path:N($s([A(),j()])),message:A(),issueCode:A(),params:ac(A(),Ks()).optional(),source:Bl.optional()}),Hl=F([`user`,`project`,`project-local`,`either`]),Ul=F([`user`,`project`,`project-local`]),Wl=tc(`code`,[P({code:I(`YAML_PARSE`),detail:A()}),P({code:I(`SCHEMA_INVALID`),issues:N(Vl)}),P({code:I(`SCOPE_VIOLATION`),path:N(A()),expectedScope:Hl,actualScope:Ul}),P({code:I(`NOT_AGENT_SETTABLE`),path:N(A())}),P({code:I(`MIXED_SCOPE`),paths:N(P({path:N(A()),scope:Ul}))}),P({code:I(`REMOVED_KEY`),path:N(A()),redirect:A(),source:Bl.optional()}),P({code:I(`WRITE_ERROR`),detail:A()}),P({code:I(`OKIGNORE_INVALID`),detail:A(),lineNumber:j().int().min(1).optional()}),P({code:I(`UNKNOWN`),message:A().optional()})]),Gl=new Set(Wl.options.map(e=>e.shape.code.value)),Kl=$s([Wl,Zs({code:A(),message:A().optional()})]);function ql(e){return Gl.has(e.code)}function Jl(e){switch(e){case`user`:return`~/.ok/global.yml`;case`project`:return`.ok/config.yml`;case`project-local`:return`.ok/local/config.yml`;case`either`:return`.ok/config.yml or ~/.ok/global.yml`}}function Yl(e){switch(e){case`user`:return`personal to you, across all projects`;case`project`:return`shared with your team via git`;case`project-local`:return`this machine only, not shared`;case`either`:return`user or project`}}function Xl(e){if(!ql(e))return e.message??`Unknown error (${e.code}).`;switch(e.code){case`YAML_PARSE`:return`Failed to parse YAML: ${e.detail}`;case`SCHEMA_INVALID`:{if(e.issues.length===0)return`Invalid configuration.`;let t=new Map;for(let n of e.issues){let e=n.source?.file??`<no source>`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=[];for(let[e,r]of t){e===`<no source>`?n.push(`Invalid configuration:`):n.push(`Invalid configuration at ${e}:`);for(let t of r){let r=t.path.length===0?`<root>`:t.path.join(`.`);if(t.source){if(n.push(` ${e}:${t.source.line}:${t.source.column}`),n.push(` ${r}: ${t.message}`),t.source.snippet&&t.source.snippet.length>0)for(let e of t.source.snippet.split(`
154
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Za(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:eo(t,`input`,e.processors),output:eo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Qa(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Qa(r.element,n);if(r.type===`set`)return Qa(r.valueType,n);if(r.type===`lazy`)return Qa(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Qa(r.innerType,n);if(r.type===`intersection`)return Qa(r.left,n)||Qa(r.right,n);if(r.type===`record`||r.type===`map`)return Qa(r.keyType,n)||Qa(r.valueType,n);if(r.type===`pipe`)return Qa(r.in,n)||Qa(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Qa(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Qa(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Qa(e,n))return!0;return!!(r.rest&&Qa(r.rest,n))}return!1}const $a=(e,t={})=>n=>{let r=Ja({...n,processors:t});return Ya(e,r),Xa(r,e),Za(r,e)},eo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ja({...i??{},target:a,io:t,processors:n});return Ya(e,o),Xa(o,e),Za(o,e)},to={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},no=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=to[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},ro=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},io=(e,t,n,r)=>{n.type=`boolean`},ao=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},oo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},so=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},co=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},lo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},uo=(e,t,n,r)=>{n.not={}},fo=(e,t,n,r)=>{},po=(e,t,n,r)=>{},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{let i=e._zod.def,a=bt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},go=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},_o=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},vo=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},yo=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},bo=(e,t,n,r)=>{n.type=`boolean`},xo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},So=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Co=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},wo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},To=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Eo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Ya(a.element,t,{...r,path:[...r.path,`items`]})},Do=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Ya(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Ya(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Oo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ya(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ko=(e,t,n,r)=>{let i=e._zod.def,a=Ya(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ya(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Ao=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Ya(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Ya(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},jo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Ya(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Ya(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Ya(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Mo=(e,t,n,r)=>{let i=e._zod.def,a=Ya(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},No=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Po=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Fo=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Io=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Lo=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;Ya(a,t,r);let o=t.seen.get(e);o.ref=a},Ro=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},zo=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Bo=(e,t,n,r)=>{let i=e._zod.def;Ya(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Vo=(e,t,n,r)=>{let i=e._zod.innerType;Ya(i,t,r);let a=t.seen.get(e);a.ref=i},Ho={string:no,number:ro,boolean:io,bigint:ao,symbol:oo,null:so,undefined:co,void:lo,never:uo,any:fo,unknown:po,date:mo,enum:ho,literal:go,nan:_o,template_literal:vo,file:yo,success:bo,custom:xo,function:So,transform:Co,map:wo,set:To,array:Eo,object:Do,union:Oo,intersection:ko,tuple:Ao,record:jo,nullable:Mo,nonoptional:No,default:Po,prefault:Fo,catch:Io,pipe:Lo,readonly:Ro,promise:zo,optional:Bo,lazy:Vo};function Uo(e,t){if(`_idmap`in e){let n=e,r=Ja({...t,processors:Ho}),i={};for(let e of n._idmap.entries()){let[t,n]=e;Ya(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;Xa(r,n),a[t]=Za(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Ja({...t,processors:Ho});return Ya(e,n),Xa(n,e),Za(n,e)}const Wo=O(`ZodISODateTime`,(e,t)=>{Pr.init(e,t),gs.init(e,t)});function Go(e){return la(Wo,e)}const Ko=O(`ZodISODate`,(e,t)=>{Fr.init(e,t),gs.init(e,t)});function qo(e){return ua(Ko,e)}const Jo=O(`ZodISOTime`,(e,t)=>{Ir.init(e,t),gs.init(e,t)});function Yo(e){return da(Jo,e)}const Xo=O(`ZodISODuration`,(e,t)=>{Lr.init(e,t),gs.init(e,t)});function Zo(e){return fa(Xo,e)}const Qo=(e,t)=>{nn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>on(e,t)},flatten:{value:t=>an(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,xt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,xt,2)}},isEmpty:{get(){return e.issues.length===0}}})};O(`ZodError`,Qo);const $o=O(`ZodError`,Qo,{Parent:Error}),es=ln($o),ts=dn($o),ns=pn($o),rs=hn($o),is=_n($o),as=vn($o),ss=yn($o),cs=bn($o),ls=xn($o),us=Sn($o),ds=Cn($o),fs=wn($o),ps=O(`ZodType`,(e,t)=>(br.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:eo(e,`input`),output:eo(e,`output`)}}),e.toJSONSchema=$a(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(kt(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>zt(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>es(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ns(e,t,n),e.parseAsync=async(t,n)=>ts(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>rs(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>is(e,t,n),e.decode=(t,n)=>as(e,t,n),e.encodeAsync=async(t,n)=>ss(e,t,n),e.decodeAsync=async(t,n)=>cs(e,t,n),e.safeEncode=(t,n)=>ls(e,t,n),e.safeDecode=(t,n)=>us(e,t,n),e.safeEncodeAsync=async(t,n)=>ds(e,t,n),e.safeDecodeAsync=async(t,n)=>fs(e,t,n),e.refine=(t,n)=>e.check(Mc(t,n)),e.superRefine=t=>e.check(Nc(t)),e.overwrite=t=>e.check(Fa(t)),e.optional=()=>dc(e),e.exactOptional=()=>pc(e),e.nullable=()=>hc(e),e.nullish=()=>dc(hc(e)),e.nonoptional=t=>xc(e,t),e.array=()=>N(e),e.or=t=>$s([e,t]),e.and=t=>rc(e,t),e.transform=t=>Tc(e,lc(t)),e.default=t=>_c(e,t),e.prefault=t=>yc(e,t),e.catch=t=>Cc(e,t),e.pipe=t=>Tc(e,t),e.readonly=()=>Dc(e),e.describe=t=>{let n=e.clone();return zi.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return zi.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return zi.get(e);let n=e.clone();return zi.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),ms=O(`_ZodString`,(e,t)=>{xr.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>no(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ka(...t)),e.includes=(...t)=>e.check(Ma(...t)),e.startsWith=(...t)=>e.check(Na(...t)),e.endsWith=(...t)=>e.check(Pa(...t)),e.min=(...t)=>e.check(Da(...t)),e.max=(...t)=>e.check(Ea(...t)),e.length=(...t)=>e.check(Oa(...t)),e.nonempty=(...t)=>e.check(Da(1,...t)),e.lowercase=t=>e.check(Aa(t)),e.uppercase=t=>e.check(ja(t)),e.trim=()=>e.check(La()),e.normalize=(...t)=>e.check(Ia(...t)),e.toLowerCase=()=>e.check(Ra()),e.toUpperCase=()=>e.check(za()),e.slugify=()=>e.check(Ba())}),hs=O(`ZodString`,(e,t)=>{xr.init(e,t),ms.init(e,t),e.email=t=>e.check(Vi(_s,t)),e.url=t=>e.check(qi(bs,t)),e.jwt=t=>e.check(ca(Is,t)),e.emoji=t=>e.check(Ji(Ss,t)),e.guid=t=>e.check(Hi(vs,t)),e.uuid=t=>e.check(Ui(ys,t)),e.uuidv4=t=>e.check(Wi(ys,t)),e.uuidv6=t=>e.check(Gi(ys,t)),e.uuidv7=t=>e.check(Ki(ys,t)),e.nanoid=t=>e.check(Yi(Cs,t)),e.guid=t=>e.check(Hi(vs,t)),e.cuid=t=>e.check(Xi(ws,t)),e.cuid2=t=>e.check(Zi(Ts,t)),e.ulid=t=>e.check(Qi(Es,t)),e.base64=t=>e.check(aa(Ns,t)),e.base64url=t=>e.check(oa(Ps,t)),e.xid=t=>e.check($i(Ds,t)),e.ksuid=t=>e.check(ea(Os,t)),e.ipv4=t=>e.check(ta(ks,t)),e.ipv6=t=>e.check(na(As,t)),e.cidrv4=t=>e.check(ra(js,t)),e.cidrv6=t=>e.check(ia(Ms,t)),e.e164=t=>e.check(sa(Fs,t)),e.datetime=t=>e.check(Go(t)),e.date=t=>e.check(qo(t)),e.time=t=>e.check(Yo(t)),e.duration=t=>e.check(Zo(t))});function A(e){return Bi(hs,e)}const gs=O(`ZodStringFormat`,(e,t)=>{Sr.init(e,t),ms.init(e,t)}),_s=O(`ZodEmail`,(e,t)=>{Tr.init(e,t),gs.init(e,t)}),vs=O(`ZodGUID`,(e,t)=>{Cr.init(e,t),gs.init(e,t)}),ys=O(`ZodUUID`,(e,t)=>{wr.init(e,t),gs.init(e,t)}),bs=O(`ZodURL`,(e,t)=>{Er.init(e,t),gs.init(e,t)});function xs(e){return qi(bs,e)}const Ss=O(`ZodEmoji`,(e,t)=>{Dr.init(e,t),gs.init(e,t)}),Cs=O(`ZodNanoID`,(e,t)=>{Or.init(e,t),gs.init(e,t)}),ws=O(`ZodCUID`,(e,t)=>{kr.init(e,t),gs.init(e,t)}),Ts=O(`ZodCUID2`,(e,t)=>{Ar.init(e,t),gs.init(e,t)}),Es=O(`ZodULID`,(e,t)=>{jr.init(e,t),gs.init(e,t)}),Ds=O(`ZodXID`,(e,t)=>{Mr.init(e,t),gs.init(e,t)}),Os=O(`ZodKSUID`,(e,t)=>{Nr.init(e,t),gs.init(e,t)}),ks=O(`ZodIPv4`,(e,t)=>{Rr.init(e,t),gs.init(e,t)}),As=O(`ZodIPv6`,(e,t)=>{zr.init(e,t),gs.init(e,t)}),js=O(`ZodCIDRv4`,(e,t)=>{Br.init(e,t),gs.init(e,t)}),Ms=O(`ZodCIDRv6`,(e,t)=>{Vr.init(e,t),gs.init(e,t)}),Ns=O(`ZodBase64`,(e,t)=>{Ur.init(e,t),gs.init(e,t)}),Ps=O(`ZodBase64URL`,(e,t)=>{Gr.init(e,t),gs.init(e,t)}),Fs=O(`ZodE164`,(e,t)=>{Kr.init(e,t),gs.init(e,t)}),Is=O(`ZodJWT`,(e,t)=>{Jr.init(e,t),gs.init(e,t)}),Ls=O(`ZodNumber`,(e,t)=>{Yr.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ro(e,t,n,r),e.gt=(t,n)=>e.check(Ca(t,n)),e.gte=(t,n)=>e.check(wa(t,n)),e.min=(t,n)=>e.check(wa(t,n)),e.lt=(t,n)=>e.check(xa(t,n)),e.lte=(t,n)=>e.check(Sa(t,n)),e.max=(t,n)=>e.check(Sa(t,n)),e.int=t=>e.check(zs(t)),e.safe=t=>e.check(zs(t)),e.positive=t=>e.check(Ca(0,t)),e.nonnegative=t=>e.check(wa(0,t)),e.negative=t=>e.check(xa(0,t)),e.nonpositive=t=>e.check(Sa(0,t)),e.multipleOf=(t,n)=>e.check(Ta(t,n)),e.step=(t,n)=>e.check(Ta(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function j(e){return pa(Ls,e)}const Rs=O(`ZodNumberFormat`,(e,t)=>{Xr.init(e,t),Ls.init(e,t)});function zs(e){return ha(Rs,e)}const Bs=O(`ZodBoolean`,(e,t)=>{Zr.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>io(e,t,n,r)});function M(e){return ga(Bs,e)}const Vs=O(`ZodNull`,(e,t)=>{Qr.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r)});function Hs(e){return _a(Vs,e)}const Us=O(`ZodAny`,(e,t)=>{$r.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ws(){return va(Us)}const Gs=O(`ZodUnknown`,(e,t)=>{ei.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ks(){return ya(Gs)}const qs=O(`ZodNever`,(e,t)=>{ti.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r)});function Js(e){return ba(qs,e)}const Ys=O(`ZodArray`,(e,t)=>{ri.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Da(t,n)),e.nonempty=t=>e.check(Da(1,t)),e.max=(t,n)=>e.check(Ea(t,n)),e.length=(t,n)=>e.check(Oa(t,n)),e.unwrap=()=>e.element});function N(e,t){return Va(Ys,e,t)}const Xs=O(`ZodObject`,(e,t)=>{ci.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r),Dt(e,`shape`,()=>t.shape),e.keyof=()=>F(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ks()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ks()}),e.strict=()=>e.clone({...e._zod.def,catchall:Js()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Wt(e,t),e.safeExtend=t=>Gt(e,t),e.merge=t=>Kt(e,t),e.pick=t=>Ht(e,t),e.omit=t=>Ut(e,t),e.partial=(...t)=>qt(uc,e,t[0]),e.required=(...t)=>Jt(bc,e,t[0])});function P(e,t){return new Xs({type:`object`,shape:e??{},...k(t)})}function Zs(e,t){return new Xs({type:`object`,shape:e,catchall:Ks(),...k(t)})}const Qs=O(`ZodUnion`,(e,t)=>{ui.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.options=t.options});function $s(e,t){return new Qs({type:`union`,options:e,...k(t)})}const ec=O(`ZodDiscriminatedUnion`,(e,t)=>{Qs.init(e,t),di.init(e,t)});function tc(e,t,n){return new ec({type:`union`,options:t,discriminator:e,...k(n)})}const nc=O(`ZodIntersection`,(e,t)=>{fi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r)});function rc(e,t){return new nc({type:`intersection`,left:e,right:t})}const ic=O(`ZodRecord`,(e,t)=>{hi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ac(e,t,n){return new ic({type:`record`,keyType:e,valueType:t,...k(n)})}const oc=O(`ZodEnum`,(e,t)=>{gi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new oc({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new oc({...t,checks:[],...k(r),entries:i})}});function F(e,t){return new oc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...k(t)})}const sc=O(`ZodLiteral`,(e,t)=>{_i.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function I(e,t){return new sc({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}const cc=O(`ZodTransform`,(e,t)=>{vi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new _t(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(en(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(en(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function lc(e){return new cc({type:`transform`,transform:e})}const uc=O(`ZodOptional`,(e,t)=>{bi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new uc({type:`optional`,innerType:e})}const fc=O(`ZodExactOptional`,(e,t)=>{xi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pc(e){return new fc({type:`optional`,innerType:e})}const mc=O(`ZodNullable`,(e,t)=>{Si.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hc(e){return new mc({type:`nullable`,innerType:e})}const gc=O(`ZodDefault`,(e,t)=>{Ci.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _c(e,t){return new gc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():It(t)}})}const vc=O(`ZodPrefault`,(e,t)=>{Ti.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yc(e,t){return new vc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():It(t)}})}const bc=O(`ZodNonOptional`,(e,t)=>{Ei.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xc(e,t){return new bc({type:`nonoptional`,innerType:e,...k(t)})}const Sc=O(`ZodCatch`,(e,t)=>{Oi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Cc(e,t){return new Sc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const wc=O(`ZodPipe`,(e,t)=>{ki.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.in=t.in,e.out=t.out});function Tc(e,t){return new wc({type:`pipe`,in:e,out:t})}const Ec=O(`ZodReadonly`,(e,t)=>{ji.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Dc(e){return new Ec({type:`readonly`,innerType:e})}const Oc=O(`ZodLazy`,(e,t)=>{Ni.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function kc(e){return new Oc({type:`lazy`,getter:e})}const Ac=O(`ZodCustom`,(e,t)=>{Pi.init(e,t),ps.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r)});function jc(e,t){return Ha(Ac,e??(()=>!0),t)}function Mc(e,t={}){return Ua(Ac,e,t)}function Nc(e){return Wa(e)}function Pc(e,t){return Tc(lc(e),t)}var Fc=mt();a();const Ic=new Set(Object.keys({sh:`bash`,zsh:`bash`,bash:`bash`,c:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,"c++":`cpp`,h:`c`,hh:`cpp`,hpp:`cpp`,cs:`csharp`,css:`css`,less:`less`,scss:`scss`,sass:`scss`,diff:`diff`,patch:`diff`,go:`go`,gql:`graphql`,graphql:`graphql`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`ini`,java:`java`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,kt:`kotlin`,kts:`kotlin`,lua:`lua`,makefile:`makefile`,md:`markdown`,mdx:`markdown`,m:`objectivec`,mm:`objectivec`,pl:`perl`,pm:`perl`,php:`php`,phtml:`php`,py:`python`,pyi:`python`,pyx:`python`,r:`r`,rb:`ruby`,rs:`rust`,sql:`sql`,swift:`swift`,ts:`typescript`,tsx:`typescript`,xml:`xml`,yaml:`yaml`,yml:`yaml`})),Lc=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],Rc=[`video/mp4`,`video/webm`,`video/ogg`],zc=[`audio/mpeg`,`audio/wav`,`audio/ogg`],Bc=[`application/pdf`],Vc=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`]),Hc=new Set([`mp4`,`webm`,`mov`,`m4v`,`mkv`]),Uc=new Set([`pdf`]),Wc=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]),Gc=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(`.`)),Kc=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(`.`)),qc=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.7z.tar.gz.rar.woff.woff2.ttf.otf.eot.docx.xlsx.pptx.doc.xls.ppt.odt.ods.odp.pages.numbers.key.epub.mobi.csv.tsv.txt.rtf.json.yaml.yml.xml.toml.lock.gpx.html.htm`.split(`.`)),Jc=new Set([`html`,`htm`]),Yc=`sandbox allow-scripts; connect-src 'none'`,Xc=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(`.`)),Zc=`same-dir`,Qc=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(`.`)),$c=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`],el=[`mp4`,`webm`,`mov`,`m4v`],tl=[`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`],nl=[`pdf`],rl=[`json`,`toml`,`lock`];function il(e,t,n){for(let r of t)if(!n.has(r))throw Error(`${e}: ${r} is not present in canonical upload constants`)}il(`SIDEBAR_IMAGE_ASSET_EXTENSIONS`,$c,Vc),il(`SIDEBAR_VIDEO_ASSET_EXTENSIONS`,el,Hc),il(`SIDEBAR_AUDIO_ASSET_EXTENSIONS`,tl,Wc),il(`SIDEBAR_PDF_ASSET_EXTENSIONS`,nl,Uc),il(`FILE_ATTACHMENT_EXTENSIONS`,[...Gc],Qc),il(`WIKI_EMBED_EXTENSIONS`,[...Qc],qc);const al=new Set($c),ol=new Set(el),sl=new Set(tl),cl=new Set(nl),ll=new Set(rl);il(`SIDEBAR_RENDERABLE_ASSET_EXTENSIONS`,[...new Set([...$c,...el,...tl,...nl,...rl])],Xc);const ul=new Set([`base`,`canvas`]),dl=new Set([`mmd`,`mermaid`]);function fl(e){let t=e.lastIndexOf(`.`);return t<0?!1:dl.has(e.slice(t+1).toLowerCase())}const pl=new Set([...qc,...ul,...dl]);function ml(e){let t=e.toLowerCase().replace(/^\./,``);return al.has(t)?`image`:ol.has(t)?`video`:sl.has(t)?`audio`:cl.has(t)?`pdf`:ll.has(t)||ul.has(t)?`text`:dl.has(t)?`mermaid`:Ic.has(t)?`text`:null}const hl=Symbol.for(`@inkeep/open-knowledge/field-registry`),gl=globalThis;gl[hl]===void 0&&(gl[hl]=Ri());const _l=gl[hl];function vl(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=yl(t)?_l.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function yl(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}const bl=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),xl=52428800,Sl=26214400,Cl=`https://api.openai.com/v1`,wl=`text-embedding-3-small`;function Tl(e){let t=e.trim();return t===``?`./`:t}function El(e){let t=Tl(e);return t.includes(`\0`)||t.includes(`\\`)?!1:t===`/`?!0:!(t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.split(`/`).some(e=>e===`..`))}const Dl=Zs({content:Zs({dir:A().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Folder OpenKnowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore.`}).default(`.`),attachmentFolderPath:A().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Where pasted and dropped assets are stored, relative to the content root. './' colocates beside the current document (default); '/' targets the content root; './subdir' targets a subfolder under the current document folder; 'folder' targets a fixed folder under the content root. Whitespace-only values are treated as './'.`}).refine(El,{message:`Invalid attachment folder path: must not contain '..' segments, NUL bytes, backslashes, or OS absolute paths (use '/' for the content root).`}).default(`./`)}).default({dir:`.`,attachmentFolderPath:`./`}),appearance:Zs({theme:F([`light`,`dark`,`system`]).register(_l,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),preview:Zs({autoOpen:M().register(_l,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:Zs({showHiddenFiles:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showOnlyMarkdownFiles:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show only markdown documents (.md/.mdx) and folders in the file tree, hiding other file types from view. View-only: hidden files stay on disk and remain reachable via links and search. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillsSection:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show the Skills section in the sidebar. Skill documents remain reachable via links and search while the section is hidden. Per-machine (project-local) — not shared with collaborators.`}).default(!0),showOkFolders:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show .ok folders (skills, templates, and other OpenKnowledge-managed state) in the file tree as read-only entries. .ok/worktrees and .ok/local never appear. Per-machine (project-local) — not shared with collaborators.`}).default(!1)}).optional()}).default({preview:{autoOpen:!0}}),editor:Zs({wordWrap:M().register(_l,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0}),agents:Zs({autoApproveOkTools:M().register(_l,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools (and `ok open` on Claude) for agents launched from the built-in terminal. Destructive tools (delete/move/share/install) still prompt. Per-machine personal preference (user scope)."}).default(!0)}).default({autoApproveOkTools:!0}),autoSync:Zs({enabled:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Whether this machine auto-pulls and auto-pushes git commits for this project. null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared.`}).nullable().default(null),default:M().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Committed project default for a machine's autoSync.enabled on first open: true = auto-sync on, false = off, null = ask (show the onboarding prompt). Shared via git. A per-machine autoSync.enabled choice overrides it.`}).nullable().default(null)}).default({enabled:null,default:null}),terminal:Zs({enabled:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null)}).default({enabled:null}),telemetry:Zs({localSink:Zs({enabled:M().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:Zs({maxBytes:j().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(xl)}).default({maxBytes:xl}),logs:Zs({maxBytes:j().register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(Sl)}).default({maxBytes:Sl}),attributeDenylist:N(A()).register(_l,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...bl])}).default({enabled:!0,spans:{maxBytes:xl},logs:{maxBytes:Sl},attributeDenylist:[...bl]})}).default({localSink:{enabled:!0,spans:{maxBytes:xl},logs:{maxBytes:Sl},attributeDenylist:[...bl]}}),search:Zs({semantic:Zs({enabled:M().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:A().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override for Azure / self-hosted / other providers. The API key is NOT stored here — set it with `ok embeddings set-key` (OS keyring)."}).default(Cl),model:A().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(wl),dimensions:j().int().positive().register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit to use the model's native size (1536 for text-embedding-3-small). Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality. Changing it re-embeds the corpus.`}).optional(),similarityFloor:j().min(0).max(1).register(_l,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Optional hard cutoff: drop any "by meaning" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap.`}).optional()}).default({enabled:!1,baseUrl:Cl,model:wl})}).default({semantic:{enabled:!1,baseUrl:Cl,model:wl}})}),Ol=`open-knowledge-config`;async function kl(e,t,n){let r=o.getTracer(Ol),a=t?{attributes:t}:{};return r.startActiveSpan(e,a,async e=>{try{return await n(e)}catch(t){throw e.recordException(t),e.setStatus({code:i.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function Al(e,t,n){let r=o.getTracer(Ol),a=t?{attributes:t}:{};return r.startActiveSpan(e,a,e=>{try{return n(e)}catch(t){throw e.recordException(t),e.setStatus({code:i.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function jl(e,t){let n=o.getActiveSpan();n&&n.addEvent(e,t)}function Ml(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function Nl(e,t){let n=e;for(let e of t){n=Ml(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function Pl(e,t){let n=Nl(e,t);if(n!==void 0)return vl(n)}function Fl(e,t){return e===`either`?!0:e===t}function Il(e,t){let n=null;function r(e,i){if(n!==null||e===void 0)return;if(typeof e==`object`&&e&&!Array.isArray(e)){for(let[t,a]of Object.entries(e))if(r(a,[...i,t]),n!==null)return;return}let a=Pl(Dl,i);a?.scope!==void 0&&(Fl(a.scope,t)||(n={code:`SCOPE_VIOLATION`,path:i,expectedScope:a.scope,actualScope:t}))}for(let[t,i]of Object.entries(e))if(r(i,[t]),n!==null)break;return n}function Ll(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&((0,Fc.isCollection)(e.getIn(r,!0))||e.deleteIn(r))}}function Rl(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){Ll(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}Ll(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function zl(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}const Bl=P({file:A(),line:j().int().min(1),column:j().int().min(1),snippet:A().optional()}),Vl=P({path:N($s([A(),j()])),message:A(),issueCode:A(),params:ac(A(),Ks()).optional(),source:Bl.optional()}),Hl=F([`user`,`project`,`project-local`,`either`]),Ul=F([`user`,`project`,`project-local`]),Wl=tc(`code`,[P({code:I(`YAML_PARSE`),detail:A()}),P({code:I(`SCHEMA_INVALID`),issues:N(Vl)}),P({code:I(`SCOPE_VIOLATION`),path:N(A()),expectedScope:Hl,actualScope:Ul}),P({code:I(`NOT_AGENT_SETTABLE`),path:N(A())}),P({code:I(`MIXED_SCOPE`),paths:N(P({path:N(A()),scope:Ul}))}),P({code:I(`REMOVED_KEY`),path:N(A()),redirect:A(),source:Bl.optional()}),P({code:I(`WRITE_ERROR`),detail:A()}),P({code:I(`OKIGNORE_INVALID`),detail:A(),lineNumber:j().int().min(1).optional()}),P({code:I(`UNKNOWN`),message:A().optional()})]),Gl=new Set(Wl.options.map(e=>e.shape.code.value)),Kl=$s([Wl,Zs({code:A(),message:A().optional()})]);function ql(e){return Gl.has(e.code)}function Jl(e){switch(e){case`user`:return`~/.ok/global.yml`;case`project`:return`.ok/config.yml`;case`project-local`:return`.ok/local/config.yml`;case`either`:return`.ok/config.yml or ~/.ok/global.yml`}}function Yl(e){switch(e){case`user`:return`personal to you, across all projects`;case`project`:return`shared with your team via git`;case`project-local`:return`this machine only, not shared`;case`either`:return`user or project`}}function Xl(e){if(!ql(e))return e.message??`Unknown error (${e.code}).`;switch(e.code){case`YAML_PARSE`:return`Failed to parse YAML: ${e.detail}`;case`SCHEMA_INVALID`:{if(e.issues.length===0)return`Invalid configuration.`;let t=new Map;for(let n of e.issues){let e=n.source?.file??`<no source>`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=[];for(let[e,r]of t){e===`<no source>`?n.push(`Invalid configuration:`):n.push(`Invalid configuration at ${e}:`);for(let t of r){let r=t.path.length===0?`<root>`:t.path.join(`.`);if(t.source){if(n.push(` ${e}:${t.source.line}:${t.source.column}`),n.push(` ${r}: ${t.message}`),t.source.snippet&&t.source.snippet.length>0)for(let e of t.source.snippet.split(`
155
155
  `))n.push(` ${e}`)}else n.push(` ${r}: ${t.message}`)}}return n.join(`
156
156
  `)}case`SCOPE_VIOLATION`:return[`Setting ${e.path.join(`.`)} belongs in your ${e.expectedScope} config`,`(${Jl(e.expectedScope)} — ${Yl(e.expectedScope)}),`,`but it was set in the ${e.actualScope} config (${Jl(e.actualScope)}).`,`Move it to ${Jl(e.expectedScope)}.`].join(` `);case`NOT_AGENT_SETTABLE`:return[`Setting ${e.path.join(`.`)} is human-only and can't be changed by an agent.`,`Change it in the Settings pane, or edit the config.yml by hand.`].join(` `);case`MIXED_SCOPE`:return[`This change touches settings that live in different config files. Apply them one file at a time:`,e.paths.map(({path:e,scope:t})=>` ${e.join(`.`)} → ${Jl(t)} (${t})`).join(`
157
157
  `)].join(`
@@ -159,7 +159,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
159
159
  `))n.push(` ${t}`);return n.join(`
160
160
  `)}case`WRITE_ERROR`:return`Failed to write config file: ${e.detail}`;case`OKIGNORE_INVALID`:return e.lineNumber===void 0?`.okignore: ${e.detail}`:`.okignore line ${e.lineNumber}: ${e.detail}`;case`UNKNOWN`:return e.message??`Unknown error.`}}function Zl(e,t){if(t.length===0)return e.contents??null;let n=e.getIn(t,!0);if((0,Fc.isNode)(n))return n;for(let n=t.length-1;n>=0;n--){let r=e.getIn(t.slice(0,n),!0);if((0,Fc.isNode)(r))return r}return e.contents??null}function Ql(e,t){let n=1,r=1,i=Math.min(t,e.length);for(let t=0;t<i;t++)e.charCodeAt(t)===10?(n++,r=1):r++;return{line:n,column:r}}function $l(e,t,n,r,i){let a=e.split(`
161
161
  `),o=r-1;if(o<0||o>=a.length)return``;let s=a[o]??``,c=t-(i-1)+s.length,l=Math.max(1,Math.min(n,c)-t),u=[],d=String(o+2).length;for(let e=Math.max(0,o-1);e<=Math.min(a.length-1,o+1);e++){let t=e===o,n=t?`>`:` `,r=String(e+1).padStart(d,` `);if(u.push(`${n} ${r} | ${a[e]??``}`),t){let e=` `.repeat(2+d+3+i-1);u.push(`${e}${`^`.repeat(l)}`)}}return u.join(`
162
- `)}function eu(e){let t=Zl(e.doc,e.path);if(!t)return;let n=t.range;if(!n)return;let[r,,i=r]=n,{line:a,column:o}=Ql(e.source,r),s=(0,Fc.isCollection)(t)?$l(e.source,r,r+1,a,o):$l(e.source,r,i,a,o);return{file:e.file,line:a,column:o,snippet:s.length>0?s:void 0}}const tu="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.",nu=[{path:[`content`,`include`],redirect:[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,tu].join(` `)},{path:[`content`,`exclude`],redirect:[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,tu].join(` `)},{path:[`folders`],redirect:[`folders is no longer a top-level config field.`,"A folder's own frontmatter (open-shape, like a doc's) lives in nested `<folder>/.ok/frontmatter.yml`; new-doc starting properties come from templates in `<folder>/.ok/templates/`.","Edit via the folder overview in the editor sidebar, or `edit({ folder: { path, frontmatter } })` via the MCP.",tu].join(` `)},{path:[`appearance`,`editorModeDefault`],redirect:[`appearance.editorModeDefault was removed and is never read — new docs always open in WYSIWYG; toggle mode via the editor mode button.`,tu].join(` `)},{path:[`upload`,`maxBytes`],redirect:[`streaming uploads have no user-facing cap; the value is hardcoded in @inkeep/open-knowledge-core.`,tu].join(` `)},{path:[`github`,`oauthAppClientId`],redirect:[`Use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID environment variable instead.`,tu].join(` `)},{path:[`server`,`host`],redirect:[`Use the --host CLI flag or the HOST environment variable instead.`,tu].join(` `)},{path:[`server`,`openOnAgentEdit`],redirect:[`This behavior was removed; the value is hardcoded.`,tu].join(` `)},{path:[`mcp`,`autoStart`],redirect:[`To disable MCP auto-start, set OK_MCP_AUTOSTART=0.`,tu].join(` `)},{path:[`mcp`,`tools`,`read_document`,`historyDepth`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,tu].join(` `)},{path:[`mcp`,`tools`,`grep`,`maxResults`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,tu].join(` `)},{path:[`mcp`,`tools`,`search`,`maxResults`],redirect:[`The search result cap is hardcoded in @inkeep/open-knowledge-core; this config key was removed.`,tu].join(` `)},{path:[`preview`,`baseUrl`],redirect:["preview URLs now resolve only to the running UI process — start one with `ok ui`.",tu].join(` `)},{path:[`preview`,`scriptSrc`],redirect:[`preview.scriptSrc has been removed.`,`The code-block preview iframe now runs a fixed open network policy (it is no longer configurable).`,tu].join(` `)},{path:[`appearance`,`sidebar`,`showAllFiles`],redirect:[`appearance.sidebar.showAllFiles has been removed.`,`The sidebar now always lists every file on disk; dot-prefixed entries are still gated by appearance.sidebar.showHiddenFiles. There is no longer a way to scope the tree to indexed/linked content.`,tu].join(` `)}];function ru(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function iu(e,t){let n=e;for(let e=0;e<t.length-1;e++){if(!ru(n))return!1;n=n[t[e]]}return ru(n)?t[t.length-1]in n:!1}function au(e){let{value:t,file:n,source:r,doc:i}=e;if(!ru(t))return[];let a=[];for(let e of nu){if(!iu(t,e.path))continue;let o;i!=null&&r!=null&&n!=null&&(o=eu({file:n,source:r,doc:i,path:e.path})),a.push({code:`REMOVED_KEY`,path:e.path,redirect:e.redirect,...o===void 0?{}:{source:o}})}return a}const ou=`v0`,su=`.ok/config.yml`,cu=`local`;function lu(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function uu(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?fu(e.position):`start`in e||`end`in e?fu(e):`line`in e||`column`in e?du(e):``}function du(e){return pu(e&&e.line)+`:`+pu(e&&e.column)}function fu(e){return du(e&&e.start)+`-`+du(e&&e.end)}function pu(e){return e&&typeof e==`number`?e:1}var mu=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=uu(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};mu.prototype.file=``,mu.prototype.name=``,mu.prototype.reason=``,mu.prototype.message=``,mu.prototype.stack=``,mu.prototype.column=void 0,mu.prototype.line=void 0,mu.prototype.ancestors=void 0,mu.prototype.cause=void 0,mu.prototype.fatal=void 0,mu.prototype.place=void 0,mu.prototype.ruleId=void 0,mu.prototype.source=void 0;function hu(e){this.content=e}hu.prototype={constructor:hu,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new hu(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new hu(n)},addToStart:function(e,t){return new hu([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new hu(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new hu(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=hu.from(e),e.size?new hu(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=hu.from(e),e.size?new hu(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=hu.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},hu.from=function(e){if(e instanceof hu)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new hu(t)};function gu(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=gu(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function _u(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=_u(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var L=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return gu(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return _u(this,e,t,n)}findIndex(e){if(e==0)return yu(0,e);if(e==this.size)return yu(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?yu(t+1,i):yu(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};L.empty=new L([],0);const vu={index:0,offset:0};function yu(e,t){return vu.index=e,vu.offset=t,vu}function bu(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!bu(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!bu(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var xu=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&bu(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};xu.none=[];var Su=class extends Error{},R=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=wu(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Cu(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(L.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};R.empty=new R(L.empty,0,0);function Cu(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Cu(a.content,t-i-1,n-i-1)))}function wu(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=wu(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function Tu(e,t,n){if(n.openStart>e.depth)throw new Su(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Su(`Inconsistent open depths`);return Eu(e,t,n,0)}function Eu(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=Eu(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return ju(a,Nu(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return ju(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Pu(n,e);return ju(a,Mu(e,i,o,t,r))}}function Du(e,t){if(!t.type.compatibleContent(e.type))throw new Su(`Cannot join `+t.type.name+` onto `+e.type.name)}function Ou(e,t,n){let r=e.node(n);return Du(r,t.node(n)),r}function ku(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Au(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(ku(e.nodeAfter,r),a++));for(let e=a;e<o;e++)ku(i.child(e),r);t&&t.depth==n&&t.textOffset&&ku(t.nodeBefore,r)}function ju(e,t){return e.type.checkContent(t),e.copy(t)}function Mu(e,t,n,r,i){let a=e.depth>i&&Ou(e,t,i+1),o=r.depth>i&&Ou(n,r,i+1),s=[];return Au(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Du(a,o),ku(ju(a,Mu(e,t,n,r,i+1)),s)):(a&&ku(ju(a,Nu(e,t,i+1)),s),Au(t,n,i,s),o&&ku(ju(o,Nu(n,r,i+1)),s)),Au(r,null,i,s),new L(s)}function Nu(e,t,n){let r=[];return Au(null,e,n,r),e.depth>n&&ku(ju(Ou(e,t,n+1),Nu(e,t,n+1)),r),Au(t,null,n,r),new L(r)}function Pu(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(L.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Fu=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return xu.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new zu(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Ru.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Ru.set(t,r=new Iu);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Lu,i}},Iu=class{constructor(){this.elts=[],this.i=0}};const Lu=12,Ru=new WeakMap;var zu=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}};const Bu=Object.create(null);var Vu=class e{constructor(e,t,n,r=xu.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||L.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&bu(this.attrs,t||e.defaultAttrs||Bu)&&xu.sameSet(this.marks,n||xu.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return R.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new R(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Tu(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Fu.resolveCached(this,e)}resolveNoCache(e){return Fu.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Uu(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=L.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=xu.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!xu.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=L.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Vu.prototype.text=void 0;var Hu=class e extends Vu{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Uu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Uu(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Wu=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Gu(t,n);if(r.next==null)return e.empty;let i=Ku(r);r.next&&r.err(`Unexpected trailing text`);let a=nd($u(i));return rd(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return L.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
162
+ `)}function eu(e){let t=Zl(e.doc,e.path);if(!t)return;let n=t.range;if(!n)return;let[r,,i=r]=n,{line:a,column:o}=Ql(e.source,r),s=(0,Fc.isCollection)(t)?$l(e.source,r,r+1,a,o):$l(e.source,r,i,a,o);return{file:e.file,line:a,column:o,snippet:s.length>0?s:void 0}}const tu="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.",nu=[{path:[`content`,`include`],redirect:[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,tu].join(` `)},{path:[`content`,`exclude`],redirect:[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,tu].join(` `)},{path:[`folders`],redirect:[`folders is no longer a top-level config field.`,"A folder's own frontmatter (open-shape, like a doc's) lives in nested `<folder>/.ok/frontmatter.yml`; new-doc starting properties come from templates in `<folder>/.ok/templates/`.","Edit via the folder overview in the editor sidebar, or `edit({ folder: { path, frontmatter } })` via the MCP.",tu].join(` `)},{path:[`appearance`,`editorModeDefault`],redirect:[`appearance.editorModeDefault was removed and is never read — new docs always open in WYSIWYG; toggle mode via the editor mode button.`,tu].join(` `)},{path:[`upload`,`maxBytes`],redirect:[`streaming uploads have no user-facing cap; the value is hardcoded in @inkeep/open-knowledge-core.`,tu].join(` `)},{path:[`github`,`oauthAppClientId`],redirect:[`Use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID environment variable instead.`,tu].join(` `)},{path:[`server`,`host`],redirect:[`Use the --host CLI flag or the HOST environment variable instead.`,tu].join(` `)},{path:[`server`,`openOnAgentEdit`],redirect:[`This behavior was removed; the value is hardcoded.`,tu].join(` `)},{path:[`mcp`,`autoStart`],redirect:[`To disable MCP auto-start, set OK_MCP_AUTOSTART=0.`,tu].join(` `)},{path:[`mcp`,`tools`,`read_document`,`historyDepth`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,tu].join(` `)},{path:[`mcp`,`tools`,`grep`,`maxResults`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,tu].join(` `)},{path:[`mcp`,`tools`,`search`,`maxResults`],redirect:[`The search result cap is hardcoded in @inkeep/open-knowledge-core; this config key was removed.`,tu].join(` `)},{path:[`preview`,`baseUrl`],redirect:["preview URLs now resolve only to the running UI process — start one with `ok ui`.",tu].join(` `)},{path:[`preview`,`scriptSrc`],redirect:[`preview.scriptSrc has been removed.`,`The code-block preview iframe now runs a fixed open network policy (it is no longer configurable).`,tu].join(` `)},{path:[`appearance`,`sidebar`,`showAllFiles`],redirect:[`appearance.sidebar.showAllFiles has been removed.`,`The sidebar lists every file on disk by default; dot-prefixed entries are gated by appearance.sidebar.showHiddenFiles, and appearance.sidebar.showOnlyMarkdownFiles scopes the tree down to markdown documents as a per-machine view preference.`,tu].join(` `)}];function ru(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function iu(e,t){let n=e;for(let e=0;e<t.length-1;e++){if(!ru(n))return!1;n=n[t[e]]}return ru(n)?t[t.length-1]in n:!1}function au(e){let{value:t,file:n,source:r,doc:i}=e;if(!ru(t))return[];let a=[];for(let e of nu){if(!iu(t,e.path))continue;let o;i!=null&&r!=null&&n!=null&&(o=eu({file:n,source:r,doc:i,path:e.path})),a.push({code:`REMOVED_KEY`,path:e.path,redirect:e.redirect,...o===void 0?{}:{source:o}})}return a}const ou=`v0`,su=`.ok/config.yml`,cu=`local`;function lu(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function uu(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?fu(e.position):`start`in e||`end`in e?fu(e):`line`in e||`column`in e?du(e):``}function du(e){return pu(e&&e.line)+`:`+pu(e&&e.column)}function fu(e){return du(e&&e.start)+`-`+du(e&&e.end)}function pu(e){return e&&typeof e==`number`?e:1}var mu=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=uu(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};mu.prototype.file=``,mu.prototype.name=``,mu.prototype.reason=``,mu.prototype.message=``,mu.prototype.stack=``,mu.prototype.column=void 0,mu.prototype.line=void 0,mu.prototype.ancestors=void 0,mu.prototype.cause=void 0,mu.prototype.fatal=void 0,mu.prototype.place=void 0,mu.prototype.ruleId=void 0,mu.prototype.source=void 0;function hu(e){this.content=e}hu.prototype={constructor:hu,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new hu(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new hu(n)},addToStart:function(e,t){return new hu([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new hu(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new hu(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=hu.from(e),e.size?new hu(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=hu.from(e),e.size?new hu(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=hu.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},hu.from=function(e){if(e instanceof hu)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new hu(t)};function gu(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=gu(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function _u(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=_u(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var L=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return gu(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return _u(this,e,t,n)}findIndex(e){if(e==0)return yu(0,e);if(e==this.size)return yu(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?yu(t+1,i):yu(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};L.empty=new L([],0);const vu={index:0,offset:0};function yu(e,t){return vu.index=e,vu.offset=t,vu}function bu(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!bu(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!bu(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var xu=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&bu(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};xu.none=[];var Su=class extends Error{},R=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=wu(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Cu(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(L.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};R.empty=new R(L.empty,0,0);function Cu(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Cu(a.content,t-i-1,n-i-1)))}function wu(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=wu(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function Tu(e,t,n){if(n.openStart>e.depth)throw new Su(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Su(`Inconsistent open depths`);return Eu(e,t,n,0)}function Eu(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=Eu(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return ju(a,Nu(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return ju(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Pu(n,e);return ju(a,Mu(e,i,o,t,r))}}function Du(e,t){if(!t.type.compatibleContent(e.type))throw new Su(`Cannot join `+t.type.name+` onto `+e.type.name)}function Ou(e,t,n){let r=e.node(n);return Du(r,t.node(n)),r}function ku(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Au(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(ku(e.nodeAfter,r),a++));for(let e=a;e<o;e++)ku(i.child(e),r);t&&t.depth==n&&t.textOffset&&ku(t.nodeBefore,r)}function ju(e,t){return e.type.checkContent(t),e.copy(t)}function Mu(e,t,n,r,i){let a=e.depth>i&&Ou(e,t,i+1),o=r.depth>i&&Ou(n,r,i+1),s=[];return Au(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Du(a,o),ku(ju(a,Mu(e,t,n,r,i+1)),s)):(a&&ku(ju(a,Nu(e,t,i+1)),s),Au(t,n,i,s),o&&ku(ju(o,Nu(n,r,i+1)),s)),Au(r,null,i,s),new L(s)}function Nu(e,t,n){let r=[];return Au(null,e,n,r),e.depth>n&&ku(ju(Ou(e,t,n+1),Nu(e,t,n+1)),r),Au(t,null,n,r),new L(r)}function Pu(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(L.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Fu=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return xu.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new zu(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Ru.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Ru.set(t,r=new Iu);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Lu,i}},Iu=class{constructor(){this.elts=[],this.i=0}};const Lu=12,Ru=new WeakMap;var zu=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}};const Bu=Object.create(null);var Vu=class e{constructor(e,t,n,r=xu.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||L.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&bu(this.attrs,t||e.defaultAttrs||Bu)&&xu.sameSet(this.marks,n||xu.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return R.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new R(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Tu(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Fu.resolveCached(this,e)}resolveNoCache(e){return Fu.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Uu(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=L.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=xu.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!xu.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=L.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Vu.prototype.text=void 0;var Hu=class e extends Vu{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Uu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Uu(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Wu=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Gu(t,n);if(r.next==null)return e.empty;let i=Ku(r);r.next&&r.err(`Unexpected trailing text`);let a=nd($u(i));return rd(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return L.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
163
163
  `)}};Wu.empty=new Wu(!0);var Gu=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Ku(e){let t=[];do t.push(qu(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function qu(e){let t=[];do t.push(Ju(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Ju(e){let t=Qu(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Xu(e,t);else break;return t}function Yu(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Xu(e,t){let n=Yu(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Yu(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Zu(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Qu(e){if(e.eat(`(`)){let t=Ku(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Zu(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function $u(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function ed(e,t){return t-e}function td(e,t){let n=[];return r(t),n.sort(ed);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function nd(e){let t=Object.create(null);return n(td(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);td(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Wu(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(ed);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function rd(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function id(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function ad(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function od(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function sd(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new ud(e,r,t[r]);return n}var cd=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=sd(e,n.attrs),this.defaultAttrs=id(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Wu.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ad(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Vu(this,this.computeAttrs(e),L.from(t),xu.setFrom(n))}createChecked(e=null,t,n){return t=L.from(t),this.checkContent(t),new Vu(this,this.computeAttrs(e),t,xu.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=L.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(L.empty,!0);return i?new Vu(this,e,t.append(i),xu.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){od(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:xu.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function ld(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var ud=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?ld(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},dd=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=sd(e,r.attrs),this.excluded=null;let i=id(this.attrs);this.instance=i?new xu(this,i):null}create(e=null){return!e&&this.instance?this.instance:new xu(this,ad(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){od(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},fd=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=hu.from(e.nodes),t.marks=hu.from(e.marks||{}),this.nodes=cd.compile(this.spec.nodes,this),this.marks=dd.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Wu.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?pd(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:pd(this,n.split(` `))}this.nodeFromJSON=e=>Vu.fromJSON(this,e),this.markFromJSON=e=>xu.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof cd))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new Hu(n,n.defaultAttrs,e,xu.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function pd(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function md(e){return e.tag!=null}function hd(e){return e.style!=null}var gd=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(md(e))this.tags.push(e);else if(hd(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Sd(this,t,!1);return n.addAll(e,xu.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Sd(this,t,!0);return n.addAll(e,xu.none,t.from,t.to),R.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(wd(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Td(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Td(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}};const _d={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},vd={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},yd={ol:!0,ul:!0};function bd(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?1:0)|(t===`full`?2:0)}var xd=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=xu.none,this.match=i||(a&4?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(L.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&1)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=L.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(L.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!_d.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Sd=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=bd(null,t.preserveWhitespace,0)|(n?4:0);i=r?new xd(r.type,r.attrs,xu.none,!0,t.topMatch||r.type.contentMatch,a):n?new xd(null,null,xu.none,!0,null,a):new xd(e.schema.topNodeType,null,xu.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&2?`full`:this.localPreserveWS||(r.options&1)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
164
164
  `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;yd.hasOwnProperty(a)&&this.parser.normalizeLists&&Cd(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:vd.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(_d.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
165
165
  `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=xu.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Ed(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=bd(e,i,a.options);a.options&4&&a.content.length==0&&(o|=4);let s=xu.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):Ed(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new xd(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=1);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Cd(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&yd.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function wd(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Td(e){let t={};for(let n in e)t[n]=e[n];return t}function Ed(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var Dd=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=kd(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=Nd(kd(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Nd(kd(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return Nd(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=Od(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return Od(e.marks)}};function Od(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function kd(e){return e.document||window.document}const Ad=new WeakMap;function jd(e){let t=Ad.get(e);return t===void 0&&Ad.set(e,t=Md(e)),t}function Md(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function Nd(e,t,n,r){if(typeof t==`string`)return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=jd(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=Nd(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}const Pd=65535,Fd=2**16;function Id(e,t){return e+t*Fd}function Ld(e){return e&Pd}function Rd(e){return(e-(e&Pd))/Fd}var zd=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&8)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&4)>0}},Bd=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Ld(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+Rd(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Id(o/3,e-s),f=e==s?2:e==u?1:4;return(t<0?e!=s:e!=u)&&(f|=8),new zd(a,f,d)}r+=l-c}return n?e+r:new zd(e+r,0,null)}touches(e,t){let n=0,r=Ld(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};Bd.empty=new Bd([]);var Vd=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new zd(e,r,null)}};const Hd=Object.create(null);var Ud=class{getMap(){return Bd.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Hd[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Hd)throw RangeError(`Duplicate use of step JSON ID `+e);return Hd[e]=t,t.prototype.jsonID=e,t}},Wd=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Su)return e.fail(t.message);throw t}}};function Gd(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Gd(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return L.fromArray(r)}var Kd=class e extends Ud{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new R(Gd(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return Wd.fromReplace(e,this.from,this.to,i)}invert(){return new qd(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Ud.jsonID(`addMark`,Kd);var qd=class e extends Ud{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new R(Gd(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Wd.fromReplace(e,this.from,this.to,n)}invert(){return new Kd(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Ud.jsonID(`removeMark`,qd);var Jd=class e extends Ud{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Wd.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Wd.fromReplace(e,this.pos,this.pos+1,new R(L.from(n),0,t.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Yd(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Ud.jsonID(`addNodeMark`,Jd);var Yd=class e extends Ud{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Wd.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Wd.fromReplace(e,this.pos,this.pos+1,new R(L.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Jd(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Ud.jsonID(`removeNodeMark`,Yd);var Xd=class e extends Ud{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Qd(e,this.from,this.to)?Wd.fail(`Structure replace would overwrite content`):Wd.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Bd([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?R.empty:new R(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?R.empty:new R(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,R.fromJSON(t,n.slice),!!n.structure)}};Xd.MAP_BIAS=1,Ud.jsonID(`replace`,Xd);var Zd=class e extends Ud{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Qd(e,this.from,this.gapFrom)||Qd(e,this.gapTo,this.to)))return Wd.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Wd.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?Wd.fromReplace(e,this.from,this.to,n):Wd.fail(`Content does not fit in gap`)}getMap(){return new Bd([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,R.fromJSON(t,n.slice),n.insert,!!n.structure)}};Ud.jsonID(`replaceAround`,Zd);function Qd(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function $d(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new qd(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Kd(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function ef(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof dd){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new qd(t.from,t.to,t.style)))}function tf(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Xd(s,l,R.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new qd(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new R(L.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Xd(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(L.empty,!0);e.replace(s,s,new R(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function nf(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function rf(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!nf(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function af(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=L.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=L.from(r.node(e).copy(u)),d++):c--;let f=L.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=L.from(i.node(e).copy(f)),p++):l++;e.step(new Zd(c,l,o,s,new R(u.append(f),d,p),u.size-d,!0))}function of(e,t,n=null,r=e){let i=cf(e,t),a=i&&lf(r,t);return a?i.map(sf).concat({type:t,attrs:n}).concat(a.map(sf)):null}function sf(e){return{type:e,attrs:null}}function cf(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function lf(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function uf(e,t,n){let r=L.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=L.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Zd(i,a,i,a,new R(r,0,0),n.length,!0))}function df(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&mf(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&pf(e,t,n,a),tf(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Zd(c,l,c+1,l-1,new R(L.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&ff(e,t,n,a),!1}})}function ff(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function pf(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
@@ -411,43 +411,50 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
411
411
  `):f},inlineCode(e,t,n){let r=e.value??``,i=e.data?.sourceFenceChar===`~`?`~`:"`",a=typeof e.data?.sourceFenceLength==`number`&&e.data.sourceFenceLength>0?e.data.sourceFenceLength:1,o=i==="`"?"`":`~`,s=a;for(;RegExp(`(^|[^${o}])${o.repeat(s)}([^${o}]|$)`).test(r);)s+=1;let c=i.repeat(s);/[^ \r\n]/.test(r)&&(e.data?.sourcePadded===!0||/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||r.startsWith(i)||r.endsWith(i))&&(r=` ${r} `);let l=`${c}${r}${c}`;return n.stack.includes(`tableCell`)?l.replace(/\|/g,`\\$&`):l},inlineMath:JQ,delete:YQ,heading(e,t,n,r){let i=e.data?.sourceStyle??`atx`,a=e.depth;if(i===`setext`&&(a===1||a===2)){let t=n.containerPhrasing(e,{...r,before:`
412
412
  `,after:`
413
413
  `}),i=e.data?.sourceUnderlineLength,o=typeof i==`number`&&i>=1?i:Math.max(t.length,3);return`${t}\n${(a===1?`=`:`-`).repeat(o)}`}let o=e.data?.sourceLeadingIndent,s=typeof o==`number`&&o>=1&&o<=3?` `.repeat(o):``,c=e.data?.sourceInteriorSpacing,l=typeof c==`number`&&c>=2?` `.repeat(c):` `,u=`#`.repeat(a),d=n.enter(`okAtxHeading`),f=n.containerPhrasing(e,{...r,before:`${u} `,after:`
414
- `});d();let p=e.data?.sourceTrailingHashes;if(typeof p==`number`&&p>0){let e=`#`.repeat(p);return f?`${s}${u}${l}${f} ${e}`:`${s}${u} ${e}`}return f?`${s}${u}${l}${f}`:`${s}${u}`},list(e,t,n,r){let i=n.options.bullet||`-`,a=!!e.ordered,o=n.bulletCurrent,s=n.bulletLastUsed;if(!a){let t=e.data?.bulletMarker;(t===`-`||t===`*`||t===`+`)&&(n.bulletCurrent=t)}let c=e.children||[],l=[],u=a?e.data?.listMarkerDelimiter??`.`:null,d=e.start??1;for(let t=0;t<c.length;t++){let o=c[t],s=o.data?.sourceOrdinal,f=typeof s==`number`&&s>=0?s:d+t,p=a?`${f}${u}`:e.data?.bulletMarker??i,m=o.data?.sourceMarkerSpacing,h=typeof m==`number`&&m>=2&&m<=4?m:1,g=` `.repeat(h),_=p;o.checked===!0?_+=`${g}[${o.data?.sourceCheckboxChar===`X`?`X`:`x`}]`:o.checked===!1&&(_+=`${g}[ ]`);let v=o.data?.sourceContinuationIndent,y=p.length+h,b=typeof v==`number`&&v>=y&&v<=y+3?v:y,x=` `.repeat(b),S=o.checked===null||o.checked===void 0?g:` `,C=n.containerFlow(o,r).split(`
414
+ `});d();let p=e.data?.sourceTrailingHashes;if(typeof p==`number`&&p>0){let e=`#`.repeat(p);return f?`${s}${u}${l}${f} ${e}`:`${s}${u} ${e}`}return f?`${s}${u}${l}${f}`:`${s}${u}`},list(e,t,n,r){let i=n.options.bullet||`-`,a=!!e.ordered,o=n.bulletCurrent,s=n.bulletLastUsed;if(!a){let t=e.data?.bulletMarker;(t===`-`||t===`*`||t===`+`)&&(n.bulletCurrent=t)}let c=e.children||[],l=[],u=a?e.data?.listMarkerDelimiter??`.`:null,d=e.start??1;for(let t=0;t<c.length;t++){let o=c[t],s=o.data?.sourceOrdinal,f=typeof s==`number`&&s>=0?s:d+t,p=a?`${f}${u}`:e.data?.bulletMarker??i,m=o.data?.sourceMarkerSpacing,h=typeof m==`number`&&m>=2&&m<=4?m:1,g=` `.repeat(h),_=p;o.checked===!0?_+=`${g}[${o.data?.sourceCheckboxChar===`X`?`X`:`x`}]`:o.checked===!1&&(_+=`${g}[ ]`);let v=o.data?.sourceContinuationIndent,y=p.length+h,b=typeof v==`number`&&v>=y&&v<=y+3?v:y,x=` `.repeat(b),S=o.checked===null||o.checked===void 0?g:` `,C=o.children??[],w=C[0]?.type===`list`,T;if(w){let e=o.checked!==null&&o.checked!==void 0,t=n.containerFlow({...o,children:[C[0]]},r),i=C.slice(1),a=i.length?n.containerFlow({...o,children:i},r):``,s=t.split(`
415
+ `).map((t,n)=>n===0?e?`${x}${t}`:`${_}${S}${t}`:t&&`${x}${t}`).join(`
416
+ `),c=[];if(e?c.push(_,``,s):c.push(s),a){let e=a.split(`
417
+ `).map(e=>e&&`${x}${e}`).join(`
418
+ `);c.push(``,e)}T=c.join(`
419
+ `)}else T=n.containerFlow(o,r).split(`
415
420
  `).map((e,t)=>t===0?`${_}${S}${e}`:e&&`${x}${e}`).join(`
416
- `);l.push(C)}n.bulletCurrent=o,n.bulletLastUsed=s;let f=e.spread?`
421
+ `);l.push(T)}n.bulletCurrent=o,n.bulletLastUsed=s;let f=e.spread?`
417
422
 
418
423
  `:`
419
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);if(f===0)return console.warn(JSON.stringify({event:`table-serialize-dropped-empty`,rows:s.length})),``;let 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))}let r=v&&!v.leading?``:`|`,i=v&&!v.trailing?``:`|`;return`${r}${n.join(`|`)}${i}`},h=e.data?.sourceAlignmentPadding,g=Array.from({length:f},(e,t)=>{let n=h?.[t];return n&&typeof n.left==`number`&&typeof n.right==`number`?n:null}),_=e.data?.sourceOuterPipes,v=_&&f>=2&&a.every(e=>{let t=(e[0]??``).trim(),n=(e[f-1]??``).trim();return(_.leading||t.length>0)&&(_.trailing||n.length>0&&!n.endsWith(`\\`))})?_:null;if(a.length===0)return m(p,g);let y=[];y.push(m(a[0],o[0]??[])),y.push(m(p,g));for(let e=1;e<a.length;e++)y.push(m(a[e],o[e]??[]));return y.join(`
420
- `)},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=QQ(i.attributes??[]);return!i.children||i.children.length===0?s?c?`<${s} ${c} />`:`<${s} />`:``:XQ({...i,attributes:(i.attributes??[]).map(e$)},t,n,r)},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=u$(n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),r,`==`),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=QQ(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)=>{if(n)return`>`;let r=s?.[c++];return r===`none`||r===0?`>${e}`:typeof r==`number`&&r>=2&&!e.startsWith(` `)?`>${` `.repeat(r)}${e}`:`> ${e}`})}};function QQ(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`){n.value.includes(`"`)?t.push(`${e}={${$Q(n.value)}}`):t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function $Q(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function e$(e){return e.type===`mdxJsxAttribute`&&typeof e.value==`string`&&e.value.includes(`"`)?{type:`mdxJsxAttribute`,name:e.name,value:{type:`mdxJsxAttributeValueExpression`,value:$Q(e.value)}}:e}function t$(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function n$(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 r$(e){return e.replace(/(?<!\\)&(?=(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z][A-Za-z0-9]*);)/g,(e,t)=>i$(t)?e:`\\${e}`)}function i$(e){if(e.charCodeAt(0)!==35)return!1;let t=e[1]===`x`||e[1]===`X`?Number.parseInt(e.slice(2),16):Number.parseInt(e.slice(1),10);return t===9||t===10||t===11||t===12||t===13||t===32}function a$(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==="`"||(e.character===`*`||e.character===`_`||e.character===`~`)&&e.inConstruct===`phrasing`||e.character===`=`&&e.atBreak===!0||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`));let i;try{i=e.safe(t,n)}finally{e.unsafe=r}return r$(l$(i,n))}function o$(e){if(Number.isNaN(e))return`ws`;let t=HN(e);return t===1?`ws`:t===2?`punct`:`other`}function s$(e,t,n){let r=o$(t),i=o$(n),a=i!==`ws`&&(i===`other`||r!==`other`),o=r!==`ws`&&(r===`other`||i!==`other`);return e===`_`?a&&(!o||r===`punct`)||o&&(!a||i===`punct`):a||o}function c$(e,t,n){let r=t;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;if(r<e.length)return e[r]===`
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=QQ(i.attributes??[]);return!i.children||i.children.length===0?s?c?`<${s} ${c} />`:`<${s} />`:``:XQ({...i,attributes:(i.attributes??[]).map(e$)},t,n,r)},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=u$(n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),r,`==`),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=QQ(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)=>{if(n)return`>`;let r=s?.[c++];return r===`none`||r===0?`>${e}`:typeof r==`number`&&r>=2&&!e.startsWith(` `)?`>${` `.repeat(r)}${e}`:`> ${e}`})}};function QQ(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`){n.value.includes(`"`)?t.push(`${e}={${$Q(n.value)}}`):t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function $Q(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function e$(e){return e.type===`mdxJsxAttribute`&&typeof e.value==`string`&&e.value.includes(`"`)?{type:`mdxJsxAttribute`,name:e.name,value:{type:`mdxJsxAttributeValueExpression`,value:$Q(e.value)}}:e}function t$(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function n$(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 r$(e){return e.replace(/(?<!\\)&(?=(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z][A-Za-z0-9]*);)/g,(e,t)=>i$(t)?e:`\\${e}`)}function i$(e){if(e.charCodeAt(0)!==35)return!1;let t=e[1]===`x`||e[1]===`X`?Number.parseInt(e.slice(2),16):Number.parseInt(e.slice(1),10);return t===9||t===10||t===11||t===12||t===13||t===32}function a$(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===`!`&&e.after===`\\[`&&e.inConstruct===`phrasing`||e.character===`@`&&e.before===`[+\\-.\\w]`||e.character===`{`&&Array.isArray(e.inConstruct)&&e.inConstruct.includes(`phrasing`)||e.character==="`"||(e.character===`*`||e.character===`_`||e.character===`~`)&&e.inConstruct===`phrasing`||e.character===`=`&&e.atBreak===!0||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`)),e.unsafe=e.unsafe.map(e=>{if(e.character!==`)`||e.atBreak!==!0||e.before!==`\\d+`||e.after!==void 0)return e;let t={...e,after:`(?:[ \r
426
+ ]|$)`};return delete t._compiled,t});let i;try{i=e.safe(t,n)}finally{e.unsafe=r}return r$(l$(i,n))}function o$(e){if(Number.isNaN(e))return`ws`;let t=HN(e);return t===1?`ws`:t===2?`punct`:`other`}function s$(e,t,n){let r=o$(t),i=o$(n),a=i!==`ws`&&(i===`other`||r!==`other`),o=r!==`ws`&&(r===`other`||i!==`other`);return e===`_`?a&&(!o||r===`punct`)||o&&(!a||i===`punct`):a||o}function c$(e,t,n){let r=t;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;if(r<e.length)return e[r]===`
421
427
  `||e[r]===`\r`;let i=n.after.charCodeAt(0);return Number.isNaN(i)||i===10||i===13}function l$(e,t){let n=``,r=0;for(;r<e.length;){let i=e.charAt(r);if(i===`\\`){n+=e.slice(r,r+2),r+=2;continue}if(i===`*`||i===`_`||i===`~`||i===`=`){let a=r+1;for(;a<e.length&&e.charAt(a)===i;)a++;let o=r===0?t.before.charCodeAt(t.before.length-1):e.charCodeAt(r-1);if(i===`=`)n+=(Number.isNaN(o)||o===10||o===13)&&c$(e,a,t)?`\\${e.slice(r,a)}`:e.slice(r,a);else{let s=a<e.length?e.charCodeAt(a):t.after.charCodeAt(0);n+=s$(i,o,s)?`\\${i}`.repeat(a-r):e.slice(r,a)}r=a;continue}n+=i,r+=1}return n}function u$(e,t,n){let r=n.startsWith(`_`)?`_`:`*`,i=t.before??``,a=t.after??``,o=e,s=o.charCodeAt(0);d$(i.charCodeAt(i.length-1),s,r)&&(o=f$(s)+o.slice(1));let c=o.charCodeAt(o.length-1);return d$(a.charCodeAt(0),c,r)&&(o=o.slice(0,-1)+f$(c)),o}function d$(e,t,n){return!(HN(t)!==1||n===`_`&&HN(e)===void 0)}function f$(e){return`&#x${e.toString(16).toUpperCase()};`}function p$(e,t,n,r){let i=e.value??``,a=e.data?.sourceDelimiter,o=typeof a==`string`&&/^\$+$/.test(a)?a.length:2;for(o===1&&!h$(i,r)&&(o=2);RegExp(`(^|[^$])${`\\$`.repeat(o)}([^$]|$)`).test(i);)o++;let s=`$`.repeat(o);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` ${i} `);let c=-1;for(;++c<n.unsafe.length;){let e=n.unsafe[c];if(!e.atBreak)continue;let t=n.compilePattern(e),r;for(;(r=t.exec(i))!==null;){let e=r.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=`${i.slice(0,e)} ${i.slice(r.index+1)}`}}return s+i+s}function m$(e,t,n,r){let i=e.data?.sourceDelimiter===`~`?`~`:`~~`,a=n.createTracker(r),o=n.enter(`strikethrough`),s=a.move(i);return s+=u$(n.containerPhrasing(e,{...a.current(),before:s,after:`~`}),r,i),s+=a.move(i),o(),s}function h$(e,t){return!(e.length===0||!/^\S/.test(e)||!/\S$/.test(e)||/[$\r\n]/.test(e)||e.endsWith(`\\`)||/\\[!-/:-@[-`{-~]/.test(e)||/^\d/.test(t.after)||t.before.endsWith(`\\`))}function g$(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 _$=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};freshnessHolder={checker:void 0};constructor(e){this.schema=gb(e.extensions),this.handlers=D$(this.schema,this.parseCtx),this.freshnessHolder.checker=e.deriveStructuralFreshness?RJ({parse:e=>this.parseWithFallback(e)}):void 0;let{nodeHandlers:t,markHandlers:n}=O$(this.schema,this.freshnessHolder);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=PQ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=FQ({toMarkdownHandlers:ZQ})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return VQ(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?HQ(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?HY(e,{parse:e=>this.parse(e,t)}):{type:`doc`,content:[{type:`paragraph`,content:[]}]}}serialize(e,t){let n;try{n=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})}let r=this.freshnessHolder.checker;t?.skipFreshnessDerive&&(this.freshnessHolder.checker=void 0);try{return UQ(n,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}finally{this.freshnessHolder.checker=r}}};const v$=AY();function y$(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 b$(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 x$(e,t){return e.attrs.sourceDirty||b$(e)?!0:t?t.isDiverged(e.toJSON()):!1}function S$(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 C$(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),t.sourcePadded===!0&&(n.sourcePadded=!0),Object.keys(n).length===0?e:{...e,data:n}}function w$(e,t){if(e.length===0)return C$({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return C$({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:[w$(n.children,t)]}}return C$({type:`inlineCode`,value:T$(e)},t)}function T$(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=T$(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const E$=Vc;function D$(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=jR(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=jR(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,c=e.data?.sourceOuterPipes??null,l=e.data?.sourceAlignmentPadding??null;return n.table.createAndFill({sourceDashCounts:s,sourceOuterPipes:c,sourceAlignmentPadding:l},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=qQ(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=[];for(let e of s){let t=c[c.length-1];e.kind===`entity`&&t?.kind===`entity`&&t.offset+t.length===e.offset&&YK(t.raw)!==null&&KK(e.raw)?c[c.length-1]={kind:`entity`,offset:t.offset,length:t.length+e.length,raw:t.raw+e.raw}:c.push(e)}let l=[],u=0;for(let t of c){if(t.offset>u){let r=n.slice(u,t.offset).replaceAll(`\xA0`,` `);r&&l.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length).replaceAll(`\xA0`,` `);if(i)if(t.kind===`escape`)l.push(e.text(i,[r.escapeMark.create()]));else if(r.sourceLiteral){let n=YK(t.raw);l.push(e.text(n??i,[r.sourceLiteral.create({sourceRaw:t.raw})]))}else l.push(e.text(i));u=t.offset+t.length}}if(u<n.length){let t=n.slice(u).replaceAll(`\xA0`,` `);t&&l.push(e.text(t))}return l.length===1?l[0]:l}),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,sourcePadded:t.data?.sourcePadded===!0})]));let a=r.strike??r.delete;if(a&&(i.delete=MR(a,e=>({sourceDelimiter:e.data?.sourceDelimiter===`~`?`~`:`~~`}))),r.highlight&&(i.mark=MR(r.highlight)),r.comment&&(i.comment=MR(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=jR(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=MR(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=MR(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=jR(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,sourceLeadingIndent:e.data?.sourceLeadingIndent??null,sourceInteriorSpacing:e.data?.sourceInteriorSpacing??null}))),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`,sourceClosingFenceLength:t.data?.sourceClosingFenceLength??null,sourceFenceIndent:t.data?.sourceFenceIndent??null,sourceInfoPadding:t.data?.sourceInfoPadding??null,sourceIndents:t.data?.sourceIndents??null},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`,sourceRaw:e.data?.sourceRaw??null})),n.list&&(i.list=jR(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=jR(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread,sourceMarkerSpacing:e.data?.sourceMarkerSpacing??null,sourceOrdinal:e.data?.sourceOrdinal??null,sourceCheckboxChar:e.data?.sourceCheckboxChar??null,sourceContinuationIndent:e.data?.sourceContinuationIndent??null}))),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=v$.getOrWildcard(o),c=y$(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=qQ(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,sourceTarget:e.data?.sourceTarget??null,sourceAnchor:e.data?.sourceAnchor??null,sourceAlias:e.data?.sourceAlias??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=uq(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&&E$.has(l)&&n.jsxComponent&&v$.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&&Hc.has(l)&&n.jsxComponent&&v$.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&&Wc.has(l)&&n.jsxComponent&&v$.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&&Gc.has(l)&&n.jsxComponent&&v$.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&d?e(o,d)??null:null,i=r===null?null:g$(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(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])}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??``,sourceDelimiter:e.data?.sourceDelimiter??null})),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=jR(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}`,unresolvedPosition:t.unresolvedPosition??!1})),n.rawMdxFallback.createAndFill({reason:`Unhandled mdast: ${t.originalType}`,originalSpan:r},t.value?[e.text(t.value)]:null)},i}function O$(e,t){let n={},r={},i=e.nodes,a=e.marks;i.paragraph&&(n.paragraph=LR(`paragraph`)),i.blockquote&&(n.blockquote=LR(`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}:{}})),i.heading&&(n.heading=LR(`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,sourceLeadingIndent:e.attrs.sourceLeadingIndent??void 0,sourceInteriorSpacing:e.attrs.sourceInteriorSpacing??void 0}}))),i.codeBlock&&(n.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,sourceClosingFenceLength:e.attrs.sourceClosingFenceLength??void 0,sourceFenceIndent:e.attrs.sourceFenceIndent??void 0,sourceInfoPadding:e.attrs.sourceInfoPadding??void 0,sourceIndents:e.attrs.sourceIndents??void 0}}}),i.thematicBreak&&(n.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),i.hardBreak&&(n.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle,...typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0?{sourceRaw:e.attrs.sourceRaw}:{}}})),i.list&&(n.list=LR(`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}}))),i.listItem&&(n.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&S$(r[0])?r.slice(1):r,a={};return typeof e.attrs.sourceMarkerSpacing==`number`&&(a.sourceMarkerSpacing=e.attrs.sourceMarkerSpacing),typeof e.attrs.sourceOrdinal==`number`&&(a.sourceOrdinal=e.attrs.sourceOrdinal),e.attrs.sourceCheckboxChar===`X`&&(a.sourceCheckboxChar=`X`),typeof e.attrs.sourceContinuationIndent==`number`&&(a.sourceContinuationIndent=e.attrs.sourceContinuationIndent),{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,...Object.keys(a).length>0?{data:a}:{},children:i}}),i.table&&(n.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&&(c.sourceDashCounts=s);let l=e.attrs.sourceOuterPipes;typeof l==`object`&&l&&typeof l.leading==`boolean`&&typeof l.trailing==`boolean`&&(c.sourceOuterPipes=l);let u=e.attrs.sourceAlignmentPadding;Array.isArray(u)&&u.length>0&&(c.sourceAlignmentPadding=u);let d=Object.keys(c).length>0?c:void 0,f={type:`table`,align:i,children:o};return d&&(f.data=d),f}),i.tableRow&&(n.tableRow=LR(`tableRow`));let o=(e,t)=>{let n={type:`tableCell`,children:uJ(t)},r=e.attrs.sourcePadding;return typeof r==`object`&&r&&typeof r.left==`number`&&typeof r.right==`number`&&(n.data={sourcePadding:r}),n};if(i.tableCell&&(n.tableCell=(e,t,n)=>o(e,n.all(e))),i.tableHeader&&(n.tableHeader=(e,t,n)=>o(e,n.all(e))),i.image&&(n.image=e=>({type:`image`,url:e.attrs.sourceUrl??e.attrs.src,alt:e.attrs.alt,title:e.attrs.title})),i.imageReference&&(n.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`}}),i.htmlBlock&&(n.htmlBlock=e=>({type:`html`,value:e.attrs.content})),i.linkDefinition??i.linkRefDef){let e=i.linkDefinition?`linkDefinition`:`linkRefDef`;n[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(i.jsxComponent&&(n.jsxComponent=(e,n,r)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let i=e.attrs.componentName||null,a=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[];return!x$(e,t.checker)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:i,attributes:a,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:v$.getOrWildcard(i??`*`).serialize(e,{all:e=>r.all(e),registry:v$,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.`)}})}),i.rawMdxFallback&&(n.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}}}}),i.jsxInline&&(n.jsxInline=e=>{let t=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:null,attributes:[],children:[],data:{sourceRaw:String(t)}}}),i.mathInline&&(n.mathInline=e=>{let t=e.attrs.formula??``,n=e.attrs.id;if(typeof n==`string`&&n.length>0)return{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]};let r=e.attrs.sourceDelimiter;return{type:`inlineMath`,value:t,...typeof r==`string`&&r.length>0?{data:{sourceDelimiter:r}}:{}}}),i.wikiLink&&(n.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,sourceTarget:typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,sourceAnchor:typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,sourceAlias:typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null},children:[{type:`text`,value:i}]}}),i.tag&&(n.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),i.wikiLinkEmbed&&(n.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}]}}),a.emphasis&&(r.emphasis=RR(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.strong&&(r.strong=RR(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.code&&(r.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return w$(n,{sourceFenceChar:r,sourceFenceLength:i,sourcePadded:e.attrs.sourcePadded===!0?!0:void 0})}),a.strike??a.delete){let e=a.strike?`strike`:`delete`;r[e]=RR(`delete`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter===`~`?`~`:`~~`}}))}return a.highlight&&(r.highlight=RR(`mark`)),a.comment&&(r.comment=RR(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),i.commentBlock&&(n.commentBlock=LR(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),i.footnoteReference&&(n.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),i.footnoteDefinition&&(n.footnoteDefinition=LR(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),a.link&&(r.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??``,r=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,i=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?e.attrs.alias:null,a=i||(r?`${t}#${r}`:t),o=n.map(e=>`value`in e&&typeof e.value==`string`?e.value:``).join(``);return o!==a&&o.trim().length>0&&!o.includes(`]]`)&&(i=o,a=o),{type:`wikiLinkEmbed`,value:a,data:{target:t,anchor:r,alias:i},children:[{type:`text`,value:a}]}}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}}),a.escapeMark&&(r.escapeMark=(e,t,n)=>{for(let e of n)if(e.type===`text`&&e.value){let t=e;t.data??={},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}),a.sourceLiteral&&(r.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 ZK(t,e.value)&&(e.data??={},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:n,markHandlers:r}}const k$=/\p{M}+/gu,A$=/[^\p{L}\p{N}]+/gu,j$=/^-+|-+$/g;function M$(e){return e.trim().normalize(`NFKD`).replace(k$,``).toLowerCase().replace(A$,`-`).replace(j$,``)}function N$(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function P$(e,t){let n=M$(e);return n?N$(n,t):``}const F$=new Set([`img`,`video`,`audio`,`mark`]);new Map(OY.flatMap(e=>e.surface===`compat`&&F$.has(e.rendersAs)?[[e.name,e]]:[])),WF(`<>`);const I$=DV(),L$=GB(),R$=KB();function z$(){return OY.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function B$(){return z$().filter(e=>V$(e)!==`fence`)}function V$(e){return e.name===`MermaidFence`?`fence`:e.hasChildren?`jsx-block`:`jsx-void`}function H$(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:V$(e)}}function U$(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 W$(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 G$(e){let t=[];for(let n of e.props){let e=U$(n);e!==void 0&&W$(n,e)&&t.push(VJ(n.name,e))}return t}function K$(e){return $z(e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`Body content here.`,{extensions:[I$],mdastExtensions:[L$]}).children}function q$(e){let t=V$(e),n;if(t===`fence`)n={type:`code`,lang:`mermaid`,meta:null,value:e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`graph LR
422
428
  A --> B`};else{let r=G$(e),i=t===`jsx-block`?K$(e):[];n={type:`mdxJsxFlowElement`,name:e.name,attributes:r,children:i}}return GP({type:`root`,children:[n]},{extensions:[R$]}).trimEnd()}function J$(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 Y$(e){return{...H$(e),example:q$(e),params:J$(e)}}function X$(){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 `palette({ components: [ids] })` with the ids you want to use. Fenced code blocks render naturally and don't need a fetch — including ` ```mermaid ` for diagrams (mermaid label text has sharp edges — `palette({ components: [\"Mermaid\"] })` lists them; parse failures come back as `warnings` entries on write/edit) 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 `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.",``,...B$().map(H$).map(e=>`- \`${e.id}\` (${e.kind}) — ${e.description}`)].join(`
423
429
  `)}const Z$=[`text`,`number`,`boolean`,`date`,`list`,`object`];F(Z$);const Q$=$s([A(),j(),M()]),$$=kc(()=>$s([Q$.transform(e=>String(e)),ac(A(),e1),N($$)])),e1=kc(()=>$s([A(),j(),M(),N($$),ac(A(),e1)]));function t1(e){if(Array.isArray(e)){let t=[];for(let n of e)n!==null&&t.push(t1(n));return t}if(typeof e==`object`&&e){let t={};for(let[n,r]of Object.entries(e))t[n]=r===null?``:t1(r);return t}return e}const n1=Pc(t1,ac(A(),e1));ac(A(),$s([e1,Hs()]));function r1(e){return!!(e===null||typeof e==`string`&&e===``||Array.isArray(e)&&e.length===0)}const i1=P({docName:yq,summary:xq,content:A().optional(),...bq}).loose(),a1=P({docName:yq,summary:xq,markdown:A(),position:F([`append`,`prepend`,`replace`]).optional(),extension:F(BG).optional(),...bq}).loose(),o1=P({docName:yq,summary:xq,find:A().min(1),replace:A(),offset:j().int().nonnegative().optional(),...bq}).loose(),s1=P({docName:yq,connectionId:A().min(1),scope:F([`last`,`session`,`file`]).optional(),...bq}).loose(),c1=P({value:A(),truncatedFrom:j().int().nonnegative().optional(),hint:A().optional()}).loose(),l1=tc(`kind`,[P({kind:I(`inline`),content:A()}),P({kind:I(`truncated`),byteLength:j().int().nonnegative(),hint:A()})]),u1=P({kind:I(`content-divergence`),intendedBytes:j().int().nonnegative(),actualBytes:j().int().nonnegative(),byteDelta:j().int(),divergenceType:A().optional(),currentState:l1.optional(),hint:A().optional()}).loose(),d1=P({type:I(`orphan`),parentCandidates:N(A()),message:A()}).loose(),f1=P({kind:I(`disk-edit-reconciled`),intendedBytes:j().int().nonnegative(),actualBytes:j().int().nonnegative(),byteDelta:j().int(),mergeOutcome:A().optional(),hint:A().optional()}).loose(),p1=tc(`kind`,[u1,f1]),m1=tc(`kind`,[u1,f1,P({kind:I(`mermaid-parse-error`),fenceIndex:j().int().positive(),fenceFirstLine:A(),message:A(),line:j().int().positive().optional()}).loose()]),h1=N(m1).min(1),g1=P({href:A(),resolvedTo:A().nullable(),reason:F([`no-such-doc`,`no-such-file`,`unresolvable`])}).loose(),_1=N(g1),v1=P({timestamp:A().min(1),summary:c1.optional(),warning:p1.optional(),warnings:h1.optional()}).loose(),y1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),hints:N(d1).optional(),summary:c1.optional(),warning:p1.optional(),warnings:h1.optional(),brokenLinks:_1}).loose(),b1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),summary:c1.optional(),warning:p1.optional(),warnings:h1.optional(),brokenLinks:_1}).loose(),x1=P({docName:A().min(1),scope:F([`last`,`session`]),undone:M()}).loose(),S1=P({docName:yq,patch:ac(A(),$s([e1,Hs()])),types:ac(A(),F(Z$)).optional(),summary:xq,...bq}).loose(),C1=P({timestamp:A().min(1),subscriberCount:j().int().nonnegative(),systemSubscriberCount:j().int().nonnegative(),appliedKeys:N(A()),summary:c1.optional(),warning:p1.optional(),warnings:h1.optional(),brokenLinks:_1}).loose(),w1=P({entries:N(P({level:F([`info`,`warn`,`error`]),message:A().max(8192),event:A().optional(),fields:ac(A(),Ks()).optional(),ts:j().optional(),sourceId:A().optional(),lineNumber:j().optional()}).loose()).max(100)}).loose(),T1=P({accepted:j().int().min(0)}).loose(),E1=P({status:A().min(1),reason:A()}).loose(),D1=P({docName:A().min(1),content:A(),lifecycle:E1.nullable()}).loose(),O1=P({documents:N(P({kind:F([`document`,`asset`,`folder`,`file`]).default(`document`),docName:A().min(1).optional(),docExt:A().min(1).default(`.md`),size:j().int().nonnegative(),modified:A().min(1),isSymlink:M().default(!1),canonicalDocName:A().nullable().default(null),targetPath:A().nullable().default(null),path:A().min(1).optional(),assetExt:A().min(1).optional(),mediaKind:F([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`]).nullable().optional(),referencedBy:N(A().min(1)).optional(),hasChildren:M().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.kind===`file`?e.path!==void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder/file kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName; file → path, no mediaKind/referencedBy/hasChildren)`})),truncated:M().optional()}).loose(),k1=P({source:A().min(1),anchor:A().nullable(),title:A(),snippet:A().nullable()}).loose(),A1=P({docName:A().min(1),backlinks:N(k1)}).loose(),j1=P({counts:ac(A().min(1),j().int().nonnegative())}).loose(),M1=tc(`kind`,[P({kind:I(`doc`),docName:A().min(1),anchor:A().nullable(),title:A(),snippet:A().nullable()}).loose(),P({kind:I(`external`),url:A().min(1),title:A(),snippet:A().nullable()}).loose()]),N1=P({docName:A().min(1),forwardLinks:N(M1)}).loose(),P1=tc(`kind`,[P({id:A().min(1),kind:I(`doc`),docName:A().min(1),anchor:A().nullable(),label:A(),cluster:A().nullable(),category:A().nullable(),tags:N(A()).nullable()}).loose(),P({id:A().min(1),kind:I(`external`),url:A().min(1),label:A()}).loose()]),F1=P({source:A().min(1),target:A().min(1)}).loose(),I1=P({nodes:N(P1),links:N(F1)}).loose(),L1=P({ts:j().int().min(0),url:A(),method:A(),ua:A().optional(),origin:A().optional(),referer:A().optional(),host:A().optional(),remote:A().optional(),secChUa:A().optional(),secChUaMobile:A().optional(),secChUaPlatform:A().optional(),secFetchSite:A().optional(),secFetchDest:A().optional(),secFetchMode:A().optional(),secFetchUser:A().optional()}).loose(),R1=P({app:$s([I(`cursor`),I(`codex`),I(`claude`),Hs()]),signals_fired:N(A())}).loose(),z1=P({entries:N(L1),count:j().int().min(0),detection:R1}).loose(),B1=P({writers:N(P({id:A().min(1),name:A().optional(),email:A().optional()}).loose()).optional(),summary:xq,...bq}).loose(),V1=P({checkpointRef:A().min(1)}).loose(),H1=P({v:j().int().optional(),id:A().min(1),name:A().min(1),colorSeed:A().optional(),docs:N(A()),summaries:N(A()).optional()}).loose(),U1=P({entries:N(P({sha:A().min(1),timestamp:A().min(1),author:A(),authorEmail:A(),type:F([`checkpoint`,`wip`,`upstream`,`park`]),message:A(),contributors:N(H1),checkpoint:Ks().nullable()}).loose()),total:j().int().nonnegative().optional(),truncated:M().optional(),hasMore:M().optional()}).loose(),W1=P({sha:A().regex(/^[0-9a-f]{40}$/i),content:A(),timestamp:A(),author:A()}).loose(),G1=P({contentDir:A().min(1),pathSeparator:F([`/`,`\\`]),symlinkResolved:M()}).loose(),K1=N(tc(`source`,[P({docName:A().min(1),timestamp:A().min(1),size:j().int().nonnegative(),source:I(`flat`)}).loose(),P({docName:A().min(1),timestamp:A().min(1),source:I(`timeline`),sha:A().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),q1=P({orphans:N(P({docName:A().min(1),title:A()}).loose())}).loose(),J1=P({hubs:N(P({docName:A().min(1),title:A(),count:j().int().nonnegative()}).loose())}).loose(),Y1=P({source:A().min(1),title:A(),snippet:A().nullable()}).loose(),X1=P({deadLinks:N(P({target:A().min(1),sources:N(Y1)}).loose())}).loose(),Z1=P({target:P({docName:A().min(1),title:A(),aliases:N(A())}).loose(),mentions:N(P({source:A().min(1),excerpt:A(),offset:j().int().nonnegative()}).loose()),truncated:M()}).loose(),Q1=P({projectPath:A().min(1)}).loose(),$1=F([`not-a-git-worktree`,`init-failed`]),e0=tc(`ok`,[P({ok:I(!0),projectPath:A().min(1)}).loose(),P({ok:I(!1),reason:$1,message:A().min(1)}).loose()]),t0=P({host:A().min(1).optional()}).loose(),n0=P({key:A().min(1)}).loose(),r0=P({keyPresent:M()}).loose(),i0=P({name:A().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:A().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),a0=P({authenticated:M()}).loose(),o0=P({}).loose(),s0=P({stackIndex:j().int().min(0),ts:j().int().min(0),additions:j().int().min(0),deletions:j().int().min(0)}).loose(),c0=P({docName:A().min(1),additionsTotal:j().int().min(0),deletionsTotal:j().int().min(0),lastTs:j().int().min(0),bursts:N(s0)}).loose(),l0=P({displayName:A().min(1),color:A().min(1),icon:A().optional(),connectionId:A().min(1)}).loose(),u0=P({sessionAlive:M(),agent:l0.nullable(),files:N(c0)}).loose(),d0=P({diff:A(),generatedAt:j().int().min(0)}).loose(),f0=P({}).loose(),p0=P({}).loose(),m0=P({}).loose(),h0=P({}).loose(),g0=P({}).loose(),_0=P({}).loose(),v0=P({displayName:A().min(1),icon:A(),color:A().min(1),currentDoc:A().nullable(),mode:F([`idle`,`writing`]),ts:j().int().min(0)}).loose(),y0=P({presence:ac(A().min(1),v0)}).loose(),b0=ac(A().min(1),M()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});P({path:A().min(1,`path must be non-empty`)}).loose();const x0=P({}).loose(),S0=P({fromDocName:A().min(1),toDocName:A().min(1)}).loose(),C0=P({fromPath:A().min(1),toPath:A().min(1)}).loose(),w0=P({}).loose(),T0=P({path:A().min(1),...bq,summary:xq}).loose(),E0=P({docName:A().min(1)}).loose(),D0=P({path:A().min(1),...bq,summary:xq}).loose(),O0=P({path:A().min(1)}).loose(),k0=P({kind:F([`file`,`folder`]),path:A().min(1),...bq,summary:xq}).loose(),A0=P({kind:F([`file`,`folder`]),path:A().min(1),duplicatedDocNames:N(A().min(1))}).loose(),j0=P({pages:N(P({docName:A().min(1),title:A(),docExt:A().min(1),size:j().int().nonnegative(),modified:A().min(1),icon:A().min(1).max(2048).optional()}).loose())}).loose(),M0=P({level:j().int().min(1).max(6),text:A(),slug:A()}).loose(),N0=P({docName:A().min(1),headings:N(M0)}).loose(),P0=P({docName:A().min(1),rewrites:j().int().nonnegative()}).loose(),F0=P({kind:F([`file`,`folder`,`asset`]),fromPath:A().min(1),toPath:A().min(1),...bq,summary:xq}).loose(),I0=P({renamed:N(S0),renamedAssets:N(C0),rewrittenDocs:N(P0).optional(),summary:c1.optional()}).loose(),L0=P({kind:F([`file`,`folder`,`asset`]),path:A().min(1),...bq}).loose(),R0=P({deletedDocNames:N(A().min(1))}).loose(),z0=P({kind:F([`file`,`folder`,`asset`]),path:A().min(1),...bq,summary:xq}).loose(),B0=P({deletedDocNames:N(A().min(1))}).loose(),V0=P({docName:A().min(1),commitSha:A().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:xq,...bq}).loose(),H0=P({restoredFrom:A().min(1),timestamp:A().min(1),summary:c1.optional(),warning:u1.optional(),warnings:h1.optional()}).loose(),U0=F([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),W0=P({label:A().min(1),webUrl:xs().nullable()}).loose(),G0=tc(`checkStatus`,[P({checkStatus:I(`allowed`)}).loose(),P({checkStatus:I(`denied`),deniedReason:F([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),P({checkStatus:I(`unknown`),unknownError:F([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),K0=F([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),q0=P({state:U0,lastSyncUtc:A().nullable(),lastFetchUtc:A().nullable(),lastPushedSha:A().nullable(),ahead:j().int().min(0),behind:j().int().min(0),consecutiveFailures:j().int().min(0),conflictCount:j().int().min(0),hasRemote:M(),syncEnabled:M(),identityUnresolved:M(),remote:W0.nullable().optional(),pushError:A().optional(),pushErrorCode:K0.optional(),pullError:A().optional(),pullErrorCode:K0.optional(),pausedReason:A().optional(),pushPermission:G0.optional()}).loose(),J0=P({op:F([`sync`,`push`,`pull`]).optional()}).loose(),Y0=P({op:F([`sync`,`push`,`pull`])}).loose(),X0=P({conflicts:N(P({file:A().min(1),detectedAt:A().min(1),oursSha:A().optional(),theirsSha:A().optional(),baseSha:A().optional()}).loose())}).loose(),Z0=P({file:A().min(1),strategy:F([`mine`,`theirs`,`content`,`delete`]),content:A().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`]}),Q0=P({}).loose(),$0=P({file:A().min(1),base:A(),ours:A(),theirs:A(),kind:F([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:A().nullable()}).loose(),e2=P({plan:jc(e=>e!==void 0,{message:`plan is required`})}).loose(),t2=P({plan:jc(e=>e!==void 0,{message:`plan is required`})}).loose(),n2=P({result:jc(e=>e!==void 0,{message:`result is required`})}).loose(),r2=P({path:A().min(1),summary:A().min(1)}).loose(),i2=P({files:j().int().nonnegative(),folders:j().int().nonnegative()}).loose(),a2=P({packs:N(P({id:A().min(1),name:A().min(1),description:A().min(1),defaultSubfolder:A().optional(),folders:N(r2),entryCounts:i2}).loose())}).loose(),o2=P({noOpen:M().optional(),out:A().min(1).optional()}).loose(),s2=P({reason:F([`unsupported-platform`,`spawn-error`]),message:A()}).loose(),c2=tc(`status`,[P({status:I(`installed`),outputPath:A(),size:j().int().nonnegative(),sha256:A(),skillVersion:A()}).loose(),P({status:I(`built`),outputPath:A(),size:j().int().nonnegative(),sha256:A(),skillVersion:A(),handoffError:s2.optional()}).loose(),P({status:I(`failed`),buildError:A()}).loose(),P({status:I(`skip-current`),skillVersion:A(),recordedAt:A().optional()}).loose()]),l2=[`.ok`,`skill-targets.json`],u2=F(KG),d2=Zs({schema:I(1),targets:N(u2).default([])});function f2(e){let t;try{t=JSON.parse(e)}catch{return null}let n=d2.safeParse(t);return n.success?n.data:null}const p2=P({tags:N(P({name:A().min(1),count:j().int().nonnegative(),isLeaf:M()}).loose())}).loose(),m2=P({docName:A().min(1),title:A(),matchingTags:N(A().min(1)),snippet:A().nullable()}).loose(),h2=P({name:A().min(1),docs:N(m2)}).loose(),g2=P({folder:Ks(),frontmatter_local:ac(A(),Ks()).nullable()}).loose(),_2=P({path:A(),frontmatter:ac(A(),Ks()).optional()}).loose(),v2=P({applied:Ks()}).loose(),y2=ac(A(),Ks()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),b2=P({template:P({name:A().min(1),folder:A(),scope:F([`local`,`inherited`]),path:A().min(1),frontmatter:y2,body:A()}).strict()}).strict(),x2=P({templates:N(P({name:A().min(1),title:A().optional(),description:A().optional(),path:A().min(1),source_folder:A()}).strict()),truncated:M()}).strict(),S2=P({folder:A(),name:A(),body:A().optional(),frontmatter:y2.optional(),...bq,summary:xq}).strict(),C2=P({path:A().min(1),created:M(),warnings:N(A())}).strict(),w2=P({existed:M(),path:A().min(1)}).strict(),T2=P({fromFolder:A(),fromName:A(),toFolder:A(),toName:A(),body:A().optional(),frontmatter:y2.optional(),...bq,summary:xq}).strict(),E2=P({from:A().min(1),to:A().min(1),committed:M()}).strict(),D2=F(TG),O2=/^[a-z0-9-]+$/,k2=/<\/?[A-Za-z][^>]*>/;function A2(e){return k2.test(e)}const j2=/^[A-Za-z0-9_-]+$/,M2=P({name:A(),description:A()}).strict(),N2=P({skill:P({name:A().min(1),scope:D2,path:A().min(1),frontmatter:M2,body:A(),files:N(P({path:A().min(1),text:A().nullable()})).optional()}).strict()}).strict(),P2=P({skills:N(P({name:A().min(1),description:A().optional(),scope:D2,path:A().min(1),absolutePath:A().min(1).optional(),installed:M(),hosts:N(A()),installedVersion:A().optional(),bundledVersion:A().optional(),updateAvailable:M().optional()}).strict()),truncated:M()}).strict(),F2=P({scope:D2.default(`project`),name:A(),body:A().optional(),frontmatter:M2,...bq,summary:xq}).strict(),I2=P({path:A().min(1),created:M(),warnings:N(A())}).strict(),L2=P({scope:D2.default(`project`),name:A(),...bq,summary:xq}).strict(),R2=P({name:A().min(1),version:A().min(1),previousVersion:A().optional(),checkpointRef:A().optional()}).strict(),z2=P({existed:M(),path:A().min(1)}).strict(),B2=P({scope:D2.default(`project`),fromName:A(),toName:A(),body:A().optional(),frontmatter:M2.optional(),...bq,summary:xq}).strict(),V2=P({from:A().min(1),to:A().min(1),committed:M()}).strict(),H2=F([`reference`,`script`]),U2=P({scope:D2.default(`project`),name:A(),path:A().min(1),content:A(),...bq,summary:xq}).strict(),W2=P({path:A().min(1),created:M(),kind:H2,content:M()}).strict(),G2=P({path:A().min(1),kind:H2,text:A()}).strict(),K2=P({path:A().min(1),existed:M(),kind:H2}).strict(),q2=P({scope:D2.default(`project`),name:A(),targets:N(u2).optional().meta({description:`Explicit editor ids to install into; omit to use project-configured editors.`}),...bq,summary:xq}).strict(),J2=P({name:A().min(1),hosts:N(A()),scripts:M(),warnings:N(A()),warningCodes:N(F([`no-targets`,`scripts-present`]))}).strict(),Y2=P({scope:D2.default(`project`),name:A()}).strict(),X2=P({name:A().min(1),uninstalled:M()}).strict(),Z2=P({targets:N(u2),configured:M()}).strict(),Q2=P({targets:N(u2)}).strict(),$2=P({targets:N(u2),reprojected:N(P({name:A(),hosts:N(A())}).strict()),bundleHosts:N(A()),removedFrom:N(A())}).strict(),e4=P({scope:D2.default(`project`),name:A(),version:A().regex(/^[0-9a-f]{40}$/i),...bq,summary:xq}).strict(),t4=P({name:A().min(1),version:A(),restoredFiles:N(A()),warnings:N(A())}).strict(),n4=P({query:A().optional(),intent:F([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:F([`navigation`,`relevance`]).optional(),scopes:N(F([`page`,`folder`,`content`,`file`])).optional(),scope:A().optional(),limit:j().int().nonnegative().optional(),semantic:M().optional(),source:F([`omnibar`,`mcp`,`http`]).optional()}).loose(),r4=P({kind:F([`page`,`folder`,`content`,`file`]),path:A().min(1),title:A(),score:j(),signals:ac(A(),Ks()),snippet:A().optional()}).loose(),i4=P({capable:M(),applied:M(),coverage:P({embedded:j().int().nonnegative(),total:j().int().nonnegative()})}).loose(),a4=P({enabled:M(),keyPresent:M(),keySource:F([`file`,`env`]).nullable(),keyHint:A().nullable(),ready:M(),capable:M(),embedded:j().int().nonnegative(),total:j().int().nonnegative()}).loose(),o4=P({query:A(),intent:F([`autocomplete`,`full_text`,`omnibar`]),results:N(r4),elapsedMs:j().nonnegative(),semantic:i4.optional(),truncated:M().optional(),ready:M().optional()}).loose(),s4=P({version:A().min(1),recordedAt:A().min(1)}).loose(),c4=P({currentVersion:A().min(1),targets:ac(A(),s4.nullable())}).loose(),l4=`server-info`,u4=`branch-switched`,d4=`disk-ack`,f4=`config-validation-rejected`,p4=`config-ignore-nested-error`,m4=F([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),h4=P({v:I(1),ch:I(l4),seq:j(),serverInstanceId:A().min(1),currentBranch:A().min(1).optional()}).loose(),g4=P({v:I(1),ch:I(u4),seq:j(),branch:A().min(1)}).loose(),_4=P({v:I(1),ch:m4,seq:j()}).loose(),v4=P({v:I(1),ch:I(d4),seq:j(),docName:A().min(1),sv:A().min(1)}).loose(),y4=P({v:I(1),ch:I(f4),seq:j(),docName:A().min(1),error:Kl}).loose(),b4=P({v:I(1),ch:I(p4),seq:j(),path:A().min(1),error:A().min(1)}).loose(),x4=new fG.default;function S4(e,t){if(e===t)return[{value:e}];let{chars1:n,chars2:r,lineArray:i}=x4.diff_linesToChars_(e,t),a=x4.diff_main(n,r,!1);x4.diff_charsToLines_(a,i),x4.diff_cleanupSemantic(a);let o=[];for(let[e,t]of a)e===fG.default.DIFF_DELETE?o.push({value:t,removed:!0}):e===fG.default.DIFF_INSERT?o.push({value:t,added:!0}):o.push({value:t});return o}const C4=new fG.default;C4.Diff_Timeout=.25;const w4=256*1024;function T4(e,t,n){if(t===n)return;let r=S4(t,n),i=0;for(let n=0;n<r.length;n++){let a=r[n],o=r[n+1];if(a.removed&&o?.added){if(t.substring(i,i+o.value.length)===o.value){i+=o.value.length,n++;continue}e.delete(i,a.value.length),e.insert(i,o.value),i+=o.value.length,n++}else a.removed?e.delete(i,a.value.length):(a.added&&e.insert(i,a.value),i+=a.value.length)}}function E4(e,t,n){if(t===n)return;if(t.length>w4||n.length>w4){D4(e,t,n);return}let r=C4.diff_main(t,n);C4.diff_cleanupSemantic(r);let i=0;for(let[t,n]of r)t===0?i+=n.length:t===-1?e.delete(i,n.length):t===1&&(e.insert(i,n),i+=n.length)}function D4(e,t,n){let r=0,i=Math.min(t.length,n.length);for(;r<i&&t.charCodeAt(r)===n.charCodeAt(r);)r++;let a=0;for(;a<i-r&&t.charCodeAt(t.length-1-a)===n.charCodeAt(n.length-1-a);)a++;let o=t.length-r-a,s=n.slice(r,n.length-a);o>0&&e.delete(r,o),s.length>0&&e.insert(r,s)}const O4=P({path:N($s([A(),j()])),message:A(),issueCode:A()});tc(`code`,[P({code:I(`SCHEMA_INVALID`),issues:N(O4)}),P({code:I(`WRITE_ERROR`),detail:A()})]);const k4={defaultKeyType:`PLAIN`,defaultStringType:`PLAIN`,lineWidth:0};function A4(e){if(e.trim()===``)return{doc:new Fc.Document({}),map:{}};let t;try{t=(0,Fc.parseDocument)(e)}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new Fc.Document({}),map:null,parseError:`parse threw: ${t}`}}if(t.errors.length>0)return{doc:t,map:null,parseError:t.errors[0]?.message??`yaml parse errors`};let n;try{n=t.toJS()}catch(e){let n=e instanceof Error?e.message:String(e);return{doc:t,map:null,parseError:`toJS threw: ${n}`}}if(typeof n!=`object`||!n||Array.isArray(n))return{doc:t,map:null,parseError:`top-level value is not a mapping`};let r=n1.safeParse(n);if(!r.success){let e=r.error.issues[0],n=e&&Array.isArray(e.path)?e.path.join(`.`):``,i=e?.message??`unknown`;return{doc:t,map:null,parseError:n?`value at "${n}" failed schema: ${i}`:`schema validation failed: ${i}`}}return{doc:t,map:r.data}}function j4(e){return Object.keys(e).length===0?``:new Fc.Document(e).toString(k4)}function M4(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N4(e,t,n){if(Array.isArray(n)){let r=e.createNode(n),i=(0,Fc.isSeq)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}if(M4(n)){let r=e.createNode(n),i=(0,Fc.isMap)(t)?t.flow:void 0;return i!==void 0&&(r.flow=i),r}return n}function P4(e){return e===``?``:`---\n${e.endsWith(`
424
430
  `)?e.slice(0,-1):e}\n---\n`}function F4(e){let t=e.match(uK);return t?{fenced:t[0],body:e.slice(t[0].length)}:{fenced:``,body:e}}function I4(e){if(e.trim()===``)return{doc:new Fc.Document({}),map:{}};let t;try{t=(0,Fc.parseDocument)(e,{uniqueKeys:!1})}catch(e){let t=e instanceof Error?e.message:String(e);return{doc:new Fc.Document({}),map:null,parseError:`parse threw: ${t}`}}if(t.errors.length>0)return{doc:t,map:null,parseError:t.errors[0]?.message??`yaml parse errors`};let n;try{n=t.toJS()}catch(e){let n=e instanceof Error?e.message:String(e);return{doc:t,map:null,parseError:`toJS threw: ${n}`}}if(typeof n!=`object`||!n||Array.isArray(n))return{doc:t,map:null,parseError:`top-level value is not a mapping`};let r=n1.safeParse(n);if(!r.success){let e=r.error.issues[0],n=e&&Array.isArray(e.path)?e.path.join(`.`):``,i=e?.message??`unknown`;return{doc:t,map:null,parseError:n?`value at "${n}" failed schema: ${i}`:`schema validation failed: ${i}`}}return{doc:t,map:r.data}}function L4(e){return e===``?{doc:new Fc.Document({}),map:{}}:I4(pK(e))}function R4(e){let{fenced:t}=F4(e),{map:n}=L4(t);return n??{}}function z4(e){if(e.contents==null||!(`items`in e.contents)){let t=e.createNode({});return e.contents=t,t}return e.contents}function B4(e){let t=e.contents;return!t||!(`items`in t)||(t.items?.length??0)===0?``:P4(e.toString(k4))}function V4(e){let t=new TextEncoder().encode(e).byteLength;return t>65536?{kind:`region_too_large`,bytes:t,limit:65536}:null}function H4(e){let t=B4(e),n=V4(t);return n?{ok:!1,error:n}:{ok:!0,nextFenced:t}}function U4(e,t){if(Object.hasOwn(t,`frontmatter`))return{ok:!1,error:{kind:`reserved_key`,key:`frontmatter`}};let{doc:n,map:r}=L4(e);if(r===null)return{ok:!1,error:{kind:`parse_failed`,reason:`fm region unparseable`}};try{z4(n);for(let[e,r]of Object.entries(t)){if(r===null){n.delete(e);continue}let t=e1.safeParse(r);if(!t.success)return{ok:!1,error:{kind:`invalid_value`,key:e,reason:t.error.issues[0]?.message??`invalid value`}};n.set(e,N4(n,n.get(e,!0),t.data))}return H4(n)}catch(e){return{ok:!1,error:{kind:`parse_failed`,reason:`yaml@2 threw: ${e instanceof Error?e.message:String(e)}`}}}}Object.freeze({source:`local`,skipStoreHooks:!1,context:Object.freeze({origin:`form-write`})});function W4(e,t){let n=t?.verbose===!0,r=t?.nowMs===void 0?new Date().toISOString():new Date(t.nowMs).toISOString(),i={event:`bridge-invariant-violation`,site:e.site,"doc.name":e.docName??null,"tolerance-class-attempted":`untracked`,"normalize-equal-modulo-tolerance":!1,ytextLen:e.ytextSnapshot.length,fragmentLen:e.fragmentMdSnapshot.length,ytextHash:lu(e.ytextSnapshot),fragmentHash:lu(e.fragmentMdSnapshot),redacted:!n,timestamp:r};return n?{...i,diff:e.unifiedDiff}:i}var G4=class extends Error{violation;constructor(e){let t=typeof e.origin==`string`?e.origin:e.origin?.context?.origin??`unknown-object`,n=e.docName?` doc='${e.docName}'`:``;super(`Bridge invariant violated [site='${e.site}'${n}, origin='${t}'].\n Y.Text (${e.ytextSnapshot.length} chars): ${e.ytextSnapshot.slice(0,200)}...\n Fragment (${e.fragmentMdSnapshot.length} chars): ${e.fragmentMdSnapshot.slice(0,200)}...\n Diff:\n${e.unifiedDiff}`),this.name=`BridgeInvariantViolationError`,this.violation=e}};const K4=/^(?:\r?\n)+/;function q4(e){let{frontmatter:t,body:n}=dK(e),r=n.match(K4);if(!r)return{boundary:``,text:e};let i=n.slice(r[0].length);return t===``&&uK.test(i)?{boundary:``,text:e}:{boundary:r[0],text:t+i}}function J4(e,t){if(t===``)return e;let{frontmatter:n,body:r}=dK(e);return n+t+r}function Y4(e){let t=q4(e).text;return dK(t).frontmatter===``?t:J4(t,`
425
- `)}const X4=new fG.default;X4.Match_Threshold=.5;function Z4(e,t,n){let r=Q4(e,t,n);return r3(e,t,n,r),r}function Q4(e,t,n){if(e===t)return n;if(e===n||t===n)return t;let r=MV(t.split(`
431
+ `)}function X4(e,t=16){let n=e.trim();return n.length<t?!1:!(n.startsWith(`<`)||n.startsWith("```")||n.startsWith(`|`))}function Z4(e,t=16){let n=new Map;for(let r of e.split(`
432
+ `)){if(!X4(r,t))continue;let e=r.trim();n.set(e,(n.get(e)??0)+1)}return n}function Q4(e,t,n=16){let r=Z4(t,n),i=[];for(let[t,a]of Z4(e,n))a>=2&&a>(r.get(t)??0)&&i.push(t);return i}const $4=new fG.default;$4.Match_Threshold=.5;function e3(e,t,n){let r=t3(e,t,n);return o3(e,t,n,r),r}function t3(e,t,n){if(e===t)return n;if(e===n||t===n)return t;let r=MV(t.split(`
426
433
  `),e.split(`
427
434
  `),n.split(`
428
435
  `)),i=[];for(let e=0;e<r.length;e++){let t=r[e];if(`ok`in t&&t.ok)i.push(t.ok.join(`
429
436
  `));else if(`conflict`in t&&t.conflict){let e=t.conflict.o.join(`
430
437
  `),n=t.conflict.a.join(`
431
438
  `),r=t.conflict.b.join(`
432
- `);i.push(i3(e,n,r))}}return i.join(`
433
- `)}function $4(e){return e.map(e=>({len:e.length,digest:lu(e)}))}var e3=class extends Error{info;constructor(e){let t=e.lostSubstrings.map(e=>JSON.stringify(e.length>80?`${e.slice(0,77)}...`:e)).join(`, `);super(`Bridge merge content loss (which=${e.which}, side=${e.side}): ${t}`),this.name=`BridgeMergeContentLossError`,this.info=e}toLog(e){let t=e?.verbose===!0;return{event:`bridge-merge-content-loss`,which:this.info.which,side:this.info.side,baselineLen:this.info.baseline.length,userTextLen:this.info.userText.length,agentTextLen:this.info.agentText.length,resultLen:this.info.result.length,lostSubstrings:t?this.info.lostSubstrings:$4(this.info.lostSubstrings),redacted:!t}}};function t3(e,t){if(e===t)return[];let n=X4.diff_main(e,t);X4.diff_cleanupSemantic(n);let r=[];for(let[e,t]of n)if(e===1)for(let e of t.split(`
434
- `)){let t=e.trim();t.length!==0&&r.push(t)}return r}function n3(e,t){let n=0;for(let r of t){let t=e.indexOf(r,n);if(t<0){if(e.indexOf(r)<0)continue;return r}n=t+r.length}return null}function r3(e,t,n,r){let i=t3(e,t),a=t3(e,n),o=i.filter(e=>!r.includes(e));if(o.length>0)throw new e3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:o,which:`substring`,side:`user`});let s=a.filter(e=>!r.includes(e));if(s.length>0)throw new e3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:s,which:`substring`,side:`agent`});let c=n3(r,i);if(c!==null)throw new e3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[c],which:`order`,side:`user`});let l=n3(r,a);if(l!==null)throw new e3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[l],which:`order`,side:`agent`})}function i3(e,t,n){if(t===``)return n;if(n===``)return t;let r=X4.patch_make(e,t),[i,a]=X4.patch_apply(r,n);return a.some(e=>!e)&&console.warn(JSON.stringify({event:`bridge-merge-patch-drop`,applied:a.filter(Boolean).length,total:a.length,regionSize:n.length})),i}const a3=/\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g,o3=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/,s3=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/,c3=/^\d+([.)])(?=\s)/,l3=/\*\*\s*(`[^`]+`)\s*\*\*/g,u3=/^(`{3,}|~{3,})/;function d3(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r].trimEnd(),a=u3.exec(i);if(a){let e=a[1][0];if(n===null){n=e;continue}if(n===e){n=null;continue}}if(n!==null||r===0||!o3.test(i))continue;let o=e[r-1].trimEnd();if(!(!o.startsWith(`|`)||o3.test(o))){t.add(r-1),t.add(r);for(let n=r+1;n<e.length&&e[n].trimEnd().startsWith(`|`);n++)t.add(n)}}return t}function f3(e){return e.slice(0,-1).trimEnd()}const p3=/^(?:#{1,6}[ \t]|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/;function m3(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r]??``,a=/^(`{3,}|~{3,})/.exec(i.trimStart());if(a?.[1]){let e=a[1][0];if(n===null){n=e;continue}if(n===e){n=null;continue}}n!==null&&t.add(r)}return t}const h3=/^<\/?[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,g3=/^<[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,_3=/^<\/[A-Z][A-Za-z0-9.]*\s*>$/,v3=/<\/?[A-Z]/;function y3(e){let t=!1;for(let n=0;n<e.length;n++)if(v3.test(e[n]??``)){t=!0;break}if(!t)return e;let n=m3(e),r=[],i=[],a=0;for(let t=0;t<e.length;t++){let o=e[t]??``,s=o.trim();if(n.has(t)){r.push(!1),i.push(a);continue}let c=a>=1||!/^[ \t]/.test(o);r.push(c&&h3.test(s));let l=c&&_3.test(s),u=c&&!l&&g3.test(s)&&!s.endsWith(`/>`);l?(a=Math.max(0,a-1),i.push(a)):(i.push(a),u&&(a+=1))}let o=Array(e.length);for(let t=0,n=-1;t<e.length;t++)o[t]=n,(e[t]??``).trim()!==``&&(n=t);let s=Array(e.length);for(let t=e.length-1,n=e.length;t>=0;t--)s[t]=n,(e[t]??``).trim()!==``&&(n=t);let c=new Set;for(let t=0;t<e.length;t++){if((e[t]??``).trim()!==``||n.has(t)||(i[t]??0)<1)continue;let a=o[t]??-1,l=s[t]??e.length;(a>=0&&r[a]===!0||l<e.length&&r[l]===!0)&&c.add(t)}let l=[];for(let t=0;t<e.length;t++){if(c.has(t))continue;let n=e[t]??``;l.push(r[t]===!0&&(i[t]??0)>=1?n.replace(/^[ \t]+/,``):n)}return l}function b3(e){let t=y3(e.replace(/^/,``).replace(/\r/g,``).replace(a3,`$1`).replace(l3,`$1`).replace(/^\n+/,``).replace(/^[*-]{3,}(?=\n|$)/,`---`).replace(/(\n)([#>+-]|\d+[.)]|`{3,}|~{3,})/g,`
439
+ `);i.push(s3(e,n,r))}}return i.join(`
440
+ `)}function n3(e){return e.map(e=>({len:e.length,digest:lu(e)}))}var r3=class extends Error{info;constructor(e){let t=e.lostSubstrings.map(e=>JSON.stringify(e.length>80?`${e.slice(0,77)}...`:e)).join(`, `);super(`Bridge merge content loss (which=${e.which}, side=${e.side}): ${t}`),this.name=`BridgeMergeContentLossError`,this.info=e}toLog(e){let t=e?.verbose===!0;return{event:`bridge-merge-content-loss`,which:this.info.which,side:this.info.side,baselineLen:this.info.baseline.length,userTextLen:this.info.userText.length,agentTextLen:this.info.agentText.length,resultLen:this.info.result.length,lostSubstrings:t?this.info.lostSubstrings:n3(this.info.lostSubstrings),redacted:!t}}};function i3(e,t){if(e===t)return[];let n=$4.diff_main(e,t);$4.diff_cleanupSemantic(n);let r=[];for(let[e,t]of n)if(e===1)for(let e of t.split(`
441
+ `)){let t=e.trim();t.length!==0&&r.push(t)}return r}function a3(e,t){let n=0;for(let r of t){let t=e.indexOf(r,n);if(t<0){if(e.indexOf(r)<0)continue;return r}n=t+r.length}return null}function o3(e,t,n,r){let i=i3(e,t),a=i3(e,n),o=i.filter(e=>!r.includes(e));if(o.length>0)throw new r3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:o,which:`substring`,side:`user`});let s=a.filter(e=>!r.includes(e));if(s.length>0)throw new r3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:s,which:`substring`,side:`agent`});let c=a3(r,i);if(c!==null)throw new r3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[c],which:`order`,side:`user`});let l=a3(r,a);if(l!==null)throw new r3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[l],which:`order`,side:`agent`});let u=Z4(e),d=Z4(t),f=Z4(n);for(let[i,a]of Z4(r))if(!(a<2)&&a>Math.max(u.get(i)??0,d.get(i)??0,f.get(i)??0))throw new r3({baseline:e,userText:t,agentText:n,result:r,lostSubstrings:[i],which:`growth`,side:`user`})}function s3(e,t,n){if(t===``)return n;if(n===``)return t;let r=$4.patch_make(e,t),[i,a]=$4.patch_apply(r,n);return a.some(e=>!e)&&console.warn(JSON.stringify({event:`bridge-merge-patch-drop`,applied:a.filter(Boolean).length,total:a.length,regionSize:n.length})),i}const c3=/\\([!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])/g,l3=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/,u3=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/,d3=/^\d+([.)])(?=\s)/,f3=/\*\*\s*(`[^`]+`)\s*\*\*/g,p3=/^(`{3,}|~{3,})/;function m3(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r].trimEnd(),a=p3.exec(i);if(a){let e=a[1][0];if(n===null){n=e;continue}if(n===e){n=null;continue}}if(n!==null||r===0||!l3.test(i))continue;let o=e[r-1].trimEnd();if(!(!o.startsWith(`|`)||l3.test(o))){t.add(r-1),t.add(r);for(let n=r+1;n<e.length&&e[n].trimEnd().startsWith(`|`);n++)t.add(n)}}return t}function h3(e){return e.slice(0,-1).trimEnd()}const g3=/^(?:#{1,6}[ \t]|>|(?:[-+*]|\d{1,9}[.)])[ \t]|`{3,}|~{3,}|=+[ \t]*$|-+[ \t]*$|(?:\*[ \t]*){3,}$|(?:_[ \t]*){3,}$)/;function _3(e){let t=new Set,n=null;for(let r=0;r<e.length;r++){let i=e[r]??``,a=/^(`{3,}|~{3,})/.exec(i.trimStart());if(a?.[1]){let e=a[1][0];if(n===null){n=e;continue}if(n===e){n=null;continue}}n!==null&&t.add(r)}return t}const v3=/^<\/?[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,y3=/^<[A-Z][A-Za-z0-9.]*(?:\s[^>]*)?>$/,b3=/^<\/[A-Z][A-Za-z0-9.]*\s*>$/,x3=/<\/?[A-Z]/;function S3(e){let t=!1;for(let n=0;n<e.length;n++)if(x3.test(e[n]??``)){t=!0;break}if(!t)return e;let n=_3(e),r=[],i=[],a=0;for(let t=0;t<e.length;t++){let o=e[t]??``,s=o.trim();if(n.has(t)){r.push(!1),i.push(a);continue}let c=a>=1||!/^[ \t]/.test(o);r.push(c&&v3.test(s));let l=c&&b3.test(s),u=c&&!l&&y3.test(s)&&!s.endsWith(`/>`);l?(a=Math.max(0,a-1),i.push(a)):(i.push(a),u&&(a+=1))}let o=Array(e.length);for(let t=0,n=-1;t<e.length;t++)o[t]=n,(e[t]??``).trim()!==``&&(n=t);let s=Array(e.length);for(let t=e.length-1,n=e.length;t>=0;t--)s[t]=n,(e[t]??``).trim()!==``&&(n=t);let c=new Set;for(let t=0;t<e.length;t++){if((e[t]??``).trim()!==``||n.has(t)||(i[t]??0)<1)continue;let a=o[t]??-1,l=s[t]??e.length;(a>=0&&r[a]===!0||l<e.length&&r[l]===!0)&&c.add(t)}let l=[];for(let t=0;t<e.length;t++){if(c.has(t))continue;let n=e[t]??``;l.push(r[t]===!0&&(i[t]??0)>=1?n.replace(/^[ \t]+/,``):n)}return l}function C3(e){let t=S3(e.replace(/^/,``).replace(/\r/g,``).replace(c3,`$1`).replace(f3,`$1`).replace(/^\n+/,``).replace(/^[*-]{3,}(?=\n|$)/,`---`).replace(/(\n)([#>+-]|\d+[.)]|`{3,}|~{3,})/g,`
435
442
 
436
443
  $2`).replace(/^([#>+-].*|\d+[.)].*|`{3,}.*|~{3,}.*)\n([^\n])/gm,`$1
437
444
 
438
445
  $2`).split(`
439
- `)),n=d3(t),r=m3(t);return t.map((e,i)=>{let a=e.trimEnd();if(i>0&&!r.has(i)&&/^[ \t]+\S/.test(a)&&(t[i-1]??``).trim()!==``&&!s3.test(a)&&!p3.test(a.trimStart())){let e=(t[i-1]??``).trimStart();if(!p3.test(e)&&!e.startsWith(`|`))return a.replace(/^[ \t]+/,``)}if(o3.test(a)){let e=a.replace(/\s+/g,``);return n.has(i)&&e.length>1&&e.startsWith(`|`)&&e.endsWith(`|`)?f3(e):e}let o=s3.test(a)?a.replace(/^[ \t]+/,``):a;return n.has(i)&&o.length>1&&o.startsWith(`|`)&&o.endsWith(`|`)&&(o=f3(o)),o.replace(c3,`1$1`)}).join(`
446
+ `)),n=m3(t),r=_3(t);return t.map((e,i)=>{let a=e.trimEnd();if(i>0&&!r.has(i)&&/^[ \t]+\S/.test(a)&&(t[i-1]??``).trim()!==``&&!u3.test(a)&&!g3.test(a.trimStart())){let e=(t[i-1]??``).trimStart();if(!g3.test(e)&&!e.startsWith(`|`))return a.replace(/^[ \t]+/,``)}if(l3.test(a)){let e=a.replace(/\s+/g,``);return n.has(i)&&e.length>1&&e.startsWith(`|`)&&e.endsWith(`|`)?h3(e):e}let o=u3.test(a)?a.replace(/^[ \t]+/,``):a;return n.has(i)&&o.length>1&&o.startsWith(`|`)&&o.endsWith(`|`)&&(o=h3(o)),o.replace(d3,`1$1`)}).join(`
440
447
  `).replace(/\n{3,}/g,`
441
448
 
442
- `).replace(/\n+$/,``)}function x3(e,t){let n=[];(e.charCodeAt(0)===65279||t.charCodeAt(0)===65279)&&n.push(`bom`),(e.includes(`\r`)||t.includes(`\r`))&&n.push(`crlf`),(/\\[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/.test(e)||/\\[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/.test(t))&&n.push(`commonmark-escape`),(/\*\*\s*`[^`]+`\s*\*\*/.test(e)||/\*\*\s*`[^`]+`\s*\*\*/.test(t))&&n.push(`emphasis-around-code`);let r=e.replace(/^/,``),i=t.replace(/^/,``);r.startsWith(`
449
+ `).replace(/\n+$/,``)}function w3(e,t){let n=[];(e.charCodeAt(0)===65279||t.charCodeAt(0)===65279)&&n.push(`bom`),(e.includes(`\r`)||t.includes(`\r`))&&n.push(`crlf`),(/\\[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/.test(e)||/\\[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/.test(t))&&n.push(`commonmark-escape`),(/\*\*\s*`[^`]+`\s*\*\*/.test(e)||/\*\*\s*`[^`]+`\s*\*\*/.test(t))&&n.push(`emphasis-around-code`);let r=e.replace(/^/,``),i=t.replace(/^/,``);r.startsWith(`
443
450
  `)!==i.startsWith(`
444
451
  `)&&n.push(`leading-newline`);let a=r.replace(/^\n+/,``),o=i.replace(/^\n+/,``),s=/^\*{3,}(?=\n|$)/.test(a),c=/^-{3,}(?=\n|$)/.test(a),l=/^\*{3,}(?=\n|$)/.test(o),u=/^-{3,}(?=\n|$)/.test(o);(s&&u||c&&l)&&n.push(`doc-start-thematic`);let d=/\n\n([#>+-]|\d+[.)]|`{3,}|~{3,})/,f=/^([#>+-].*|\d+[.)].*|`{3,}.*|~{3,}.*)\n\n[^\n]/m,p=d.test(r),m=d.test(i),h=f.test(r),g=f.test(i);(p!==m||h!==g)&&n.push(`block-separator-collapse`);let _=r.replace(/\r/g,``),v=i.replace(/\r/g,``),y=/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/m;(y.test(_)||y.test(v))&&n.push(`table-align-row-spacing`);let b=e=>y.test(e)&&/^\|[^\n]*[^|\s][ \t]*$/m.test(e);b(_)!==b(v)&&n.push(`row-no-trailing-pipe`);let x=/^[ \t]+([-+*]|\d+[.)]|[a-zA-Z][.)])\s/m;(x.test(_)||x.test(v))&&n.push(`list-indent-canonical`);let S=/[^\n]\n[ \t]+(?![-+*>#]|\d+[.)])\S/;(S.test(_)||S.test(v))&&n.push(`paragraph-continuation-indent`);let C=_.split(`
445
452
  `),w=v.split(`
446
- `),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&h3.test(n),a=n===``&&r!==``&&h3.test(r);if(i||a)return!0}return!1};(T(C)||T(w))&&n.push(`jsx-container-boundary-blank`);let E=e=>e.replace(/^[ \t]+/,``).replace(c3,`1$1`),ee=Math.min(C.length,w.length);for(let e=0;e<ee;e++){let t=C[e]??``,r=w[e]??``;if(t!==r&&E(t)===E(r)&&/^[ \t]*\d+[.)]\s/.test(t)){n.push(`ordered-list-marker-number`);break}}return(/[ \t]\n/.test(_)||/[ \t]\n/.test(v))&&n.push(`trailing-whitespace`),(/[ \t]$/.test(_)||/[ \t]$/.test(v))&&(n.includes(`trailing-whitespace`)||n.push(`trailing-whitespace`)),(/\n{3,}/.test(_)||/\n{3,}/.test(v))&&n.push(`blank-line-collapse`),_.endsWith(`
453
+ `),T=e=>{for(let t=0;t<e.length-1;t++){let n=(e[t]??``).trim(),r=(e[t+1]??``).trim(),i=n!==``&&r===``&&v3.test(n),a=n===``&&r!==``&&v3.test(r);if(i||a)return!0}return!1};(T(C)||T(w))&&n.push(`jsx-container-boundary-blank`);let E=e=>e.replace(/^[ \t]+/,``).replace(d3,`1$1`),ee=Math.min(C.length,w.length);for(let e=0;e<ee;e++){let t=C[e]??``,r=w[e]??``;if(t!==r&&E(t)===E(r)&&/^[ \t]*\d+[.)]\s/.test(t)){n.push(`ordered-list-marker-number`);break}}return(/[ \t]\n/.test(_)||/[ \t]\n/.test(v))&&n.push(`trailing-whitespace`),(/[ \t]$/.test(_)||/[ \t]$/.test(v))&&(n.includes(`trailing-whitespace`)||n.push(`trailing-whitespace`)),(/\n{3,}/.test(_)||/\n{3,}/.test(v))&&n.push(`blank-line-collapse`),_.endsWith(`
447
454
  `)!==v.endsWith(`
448
- `)&&n.push(`trailing-newline`),n}const S3=`parse-equivalence`;function C3(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}function w3(e){return e.replace(/[ \t]+$/gm,``)}const T3=/^([ \t]*)\d+([.)])(?=[ \t])/;function E3(e){return e.split(`
449
- `).map(e=>e.replace(T3,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const D3=new Set;function O3(e,t,n){let r=dK(e),i=dK(t);if(r.frontmatter!==i.frontmatter)return!1;if(r.body===i.body)return!0;let a;try{a=n(r.body)}catch(e){let t=e instanceof Error?e.message:String(e);return D3.size<8&&!D3.has(t)&&(D3.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return C3(w3(a))===C3(w3(i.body))?dJ(E3(r.body),E3(a)):!1}const k3={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},A3={"emphasis-around-code":`pm-model-caused`,bom:`parser-caused`,crlf:`parser-caused`,"commonmark-escape":`parser-caused`,"leading-newline":`parser-caused`,"paragraph-continuation-indent":`parser-caused`,"doc-start-thematic":`parser-caused`,"block-separator-collapse":`serializer-caused`,"table-align-row-spacing":`serializer-caused`,"row-no-trailing-pipe":`serializer-caused`,"ordered-list-marker-number":`serializer-caused`,"list-indent-canonical":`serializer-caused`,"jsx-container-boundary-blank":`serializer-caused`,"trailing-whitespace":`serializer-caused`,"blank-line-collapse":`serializer-caused`,"trailing-newline":`serializer-caused`,"parse-equivalence":`parser-caused`};function j3(e){return A3[e]}function M3(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return e.length===t.length?-1:n}let N3=null;function P3(e){N3=e}function F3(e,t,n,r){if(!N3||e.length===0)return;let i=M3(t,n),a=new Date().toISOString();for(let t of e)N3({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:j3(t)})}const I3=1e4,L3=`last-spawn-error.log`,R3=/^[a-zA-Z0-9][\w/-]*$/;function z3(e){return e.startsWith(`#`)?e.slice(1):e}function B3(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function V3(e){if(!e||e.trim()===``)return[];let{map:t}=A4(e);if(!t)return[];let n=B3(t.tags),r=[];for(let e of n){let t=z3(e);R3.test(t)&&r.push(t)}return r}const H3=[`.ok`,`local`,`installed-skills.json`],U3=F(TG),W3=Zs({hosts:N(A()),scope:U3,scripts:M(),installedAt:Go()}),G3=Zs({schema:I(1),skills:ac(A(),W3).default({})});function K3(){return{schema:1,skills:{}}}function q3(e){let t;try{t=JSON.parse(e)}catch{return null}let n=G3.safeParse(t);return n.success?n.data:null}const J3={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},Y3=new WeakMap;function X3(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function Z3(e){return e.trim().toLowerCase()}const Q3=/\.(?:md|mdx)$/;function $3(e,t){if(t!==`page`)return e;let n=e.replace(Q3,``);return n.length>0?n:e}function e6(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function t6(e){let t=e6(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function n6(e){let t=SW({schema:J3});return e.length>0&&NW(t,e),t}function r6(e){let t={documents:e};return Y3.set(t,n6(e)),t}function i6(e){let t=Y3.get(e);if(t)return t;let n=n6(e.documents);return Y3.set(e,n),n}function a6(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function o6(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function s6(e,t){let n=Z3(t);if(!n)return 0;let r=$3(n,e.kind),i=Z3(e.title),a=Z3(e.name),o=Z3(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function c6(e,t){let n=s6(e,t);return n<=0?n:_q(e.path)?n*.5:n}function l6(e){return e===`file`?-60:0}function u6(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function d6(e,t,n,r){return e+t*20+n+l6(r)}function f6(e,t,n,r,i,a){return e===`relevance`?d6(t,n,r,i):u6(t,n,r,i,a)}function p6(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function m6(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function h6(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 g6(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function _6(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 v6(e,t){return Z3(t).length<4?0:e===`full_text`?1:0}function y6(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function b6(e){let t=[],n=[],r=[];for(let i of e){let e=y6(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function x6(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=b6(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function S6(e,t,n={}){let r=n.intent??`omnibar`,i=p6(r,n.ranking),a=X3(n.limit),o=new Set(n.scopes??a6(r)),s=e.documents.filter(e=>o6(e,o)),c=Z3(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=lG(i6(e),{term:c,properties:g6(r),boost:_6(r),tolerance:v6(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>o6(e.document,o)).map(e=>[e.document.id,e.score])),d=h6(s),f=new Map;for(let e of s)c6(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)o6(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=m6(f.values(),u);return x6([...f.values()].map(t=>{let n=Math.max(0,c6(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:f6(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return x6(w6({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function C6(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function w6(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=m6(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,c6(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?f6(o,t,n,s,e.kind,m):d6(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=C6(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=C6(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}function T6(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),E6(n)}function E6(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 D6=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),O6=globalThis;O6[D6]===void 0&&(O6[D6]=Ri());const k6=O6[D6],A6=[`.ok`,`skill-state.yml`],j6=[`claude-cowork`,`cli-hosts`],M6=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],N6=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,P6=Zs({version:A().regex(N6,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(k6,{description:`Recorded skill version for this target.`}),recordedAt:Go().register(k6,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:F(M6).register(k6,{description:`Install-source surface that recorded this entry.`}).optional()}),F6=Zs({enabled:M().register(k6,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:Go().register(k6,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),I6=Zs({schema:I(1).register(k6,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Zs({"claude-cowork":P6.optional(),"cli-hosts":P6.optional()}).register(k6,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:ac(A(),F6).register(k6,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function L6(e,t){return e??t.installedOnDisk}function R6(){return{schema:1,targets:{}}}const z6=`template`;function B6(e){if(e.trim()===``)return{};let t;try{t=(0,Fc.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function V6(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function H6(e){let{frontmatter:t,body:n}=dK(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:pK(t),markdown:n}}function U6(e){let t=e.split(`
450
- `);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=B6(n.join(`
451
- `))[z6];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
452
- `).replace(/\n+$/,``)}}function W6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=dK(t);if(n===``)return{identity:{},starterContent:t};let i=pK(n),a=U6(i);if(a)return{identity:a.identity,starterContent:V6(a.docFrontmatterText,r)};let{frontmatter:o}=dK(r);if(o!==``)return{identity:B6(i),starterContent:r};let s=B6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:V6(i,r)}}function G6(e,t){let{docFrontmatterText:n,markdown:r}=H6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Fc.stringify)({[z6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function K6(e){return W6(e).starterContent}function q6(){let e=!1,t=``,n=0;return r=>{let i=J6(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 J6(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 Y6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],X6={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function Z6(e,t=Y6){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const Q6={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function $6(e){return e?Q6[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const e8={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function t8(e){let t=e?.trim();return t?e8[$6(t)]??t:`Agent`}function n8(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 r8=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function i8(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function a8(e){let t=e.trim();return r8.test(t)||t.startsWith(`//`)}function o8(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(a8(n))return{kind:`external`,url:n};let r=n8(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=i8(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function s8(e,t){let n=e.trim();if(!n)return null;if(a8(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=i8(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function c8(e,t){let n=e.trim();if(!n||r8.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 l8(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function u8(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function d8(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function f8(e){return e.split(`/`).filter(e=>e!==``)}function p8(e,t){let n=d8(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function m8(e,t){let n=d8(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:f8(r).length}function h8(e,t){let n=f8(e),r=f8(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function g8(){let e=new Map;function t(t){let n=l8(t);if(n===``)return;let r=u8(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=l8(t),r=u8(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=d8(l8(n)),o=[],s=[];for(let e of i)p8(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=m8(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=m8(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=h8(a,d8(t));for(let r=1;r<e.length;r++){let i=e[r],o=h8(a,d8(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 _8(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 v8(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 y8(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function b8(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}const x8=/^[A-Za-z0-9-]{8,64}$/;let S8=null;function C8(e){return l(e??m(),`.ok`,`machine-id`)}function w8(e){if(e===void 0&&S8!==null)return S8;let t=C8(e),n=null;try{let e=b(t,`utf-8`).trim();x8.test(e)&&(n=e)}catch{}if(n===null){n=w();try{v(c(t),{recursive:!0}),S(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){console.warn(`[machine-id] Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(S8=n),n}function T8(){try{let e=u(c(f(import.meta.url)),`..`,`package.json`),t=JSON.parse(b(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const E8=T8(),D8=1;var O8=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${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 k8(e,t){return u(e,`${t}.lock`)}const A8=new Map;function j8(e){A8.set(e,(A8.get(e)??0)+1)}function M8(e){let t=A8.get(e);return t===void 0||t<=1?(A8.delete(e),!0):(A8.set(e,t-1),!1)}function N8(e){return typeof e.machineId==`string`?e.machineId===w8():e.hostname===h()}const P8=new Set;let F8=!1;function I8(e){P8.add(e),!F8&&(F8=!0,process.on(`exit`,()=>{for(let e of P8)try{let t=JSON.parse(b(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==w8()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==h())continue;x(e)}catch{}}))}function L8(e,t){try{let n=JSON.parse(b(e,`utf-8`));return n&&typeof n==`object`&&b8(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 R8(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;v(n,{recursive:!0});let a=k8(n,t),o={pid:process.pid,hostname:h(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:w8(),...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??E8},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!_(a))try{let e=y(a,`wx`,384);try{C(e,s)}finally{g(e)}return j8(a),I8(a),z8({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=L8(a,i);if(e){if(N8(e)&&e.pid===process.pid)return S(a,s,{encoding:`utf-8`,mode:384}),j8(a),I8(a),z8({lockName:t,lockDir:n,lockPath:a});if(y8(e.pid))throw new O8(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{x(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function z8(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>G8({lockName:t,lockDir:n}),updatePort:e=>B8({lockName:t,lockDir:n,port:e})}}function B8(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=k8(n,t);if(!_(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||!b8(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&&N8(o)){o.port=r;try{S(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 V8(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k8(n,t);if((A8.get(i)??0)>1)return;let a;try{let e=JSON.parse(b(i,`utf-8`));if(!e||typeof e!=`object`||!b8(e.pid)){console.warn(`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){e.code!==`ENOENT`&&console.warn(`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N8(a)&&a.draining!==!0){a.draining=!0;try{S(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function H8(e){let{lockName:t,lockDir:n}=e,r=k8(n,t);if(!_(r))return null;let i;try{let e=JSON.parse(b(r,`utf-8`));if(!e||typeof e!=`object`||!b8(e.pid))return null;i=e}catch{return null}if(!N8(i))return null;if(!y8(i.pid)){try{x(r)}catch{}return null}return i}function U8(e){let{lockName:t,lockDir:n}=e,r=k8(n,t);if(!_(r))return{status:`absent`};let i;try{i=JSON.parse(b(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(!b8(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,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N8(o))return{status:`stale`,lock:o};if(!y8(o.pid)){try{x(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}}async function W8(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>H8({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function G8(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k8(n,t);if(M8(a)){if(r){V8({lockName:t,lockDir:n});return}if(_(a))try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N8(e))return;x(a),P8.delete(a)}catch(e){console.warn(`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var K8=class extends O8{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function q8(e,t){try{return R8({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O8&&e.lockName===`server`?new K8(e.existing,e.lockPath):e}}function J8(e,t){B8({lockName:`server`,lockDir:e,port:t})}function Y8(e){return H8({lockName:`server`,lockDir:e})}function X8(e,t){G8({lockName:`server`,lockDir:e,...t})}function Z8(e){V8({lockName:`server`,lockDir:e})}function Q8(e,t){return W8({lockName:`server`,lockDir:e,...t})}export{mG as $,fl as $a,f2 as $i,z2 as $n,YG as $r,n0 as $t,a1 as A,lu as Aa,g$ as Ai,N6 as An,Uo as Ao,X0 as Ar,_2 as At,g1 as B,Kc as Ba,Gq as Bi,n2 as Bn,cn as Bo,w2 as Br,H3 as Bt,m1 as C,M$ as Ca,t8 as Ci,K1 as Cn,Pc as Co,L2 as Cr,A0 as Ct,b1 as D,gb as Da,T6 as Di,O2 as Dn,Ks as Do,lJ as Dr,z1 as Dt,o1 as E,P4 as Ea,R6 as Ei,DG as En,$s as Eo,x0 as Er,GG as Et,j1 as F,Cl as Fa,$6 as Fi,B1 as Fn,br as Fo,Y0 as Fr,e1 as Ft,v4 as G,nu as Ga,zG as Gi,Cq as Gn,ht as Go,C2 as Gr,VG as Gt,b4 as H,pl as Ha,QG as Hi,e2 as Hn,Dt as Ho,T2 as Hr,c2 as Ht,A1 as I,wl as Ia,K6 as Ii,V1 as In,un as Io,z6 as Ir,qG as It,p4 as J,jl as Ja,A4 as Ji,Aq as Jn,p0 as Jr,t0 as Jt,h4 as K,Yc as Ka,Z4 as Ki,Eq as Kn,mt as Ko,x2 as Kr,I1 as Kt,qq as L,Sl as La,Rq as Li,n4 as Ln,fn as Lo,j2 as Lr,U1 as Lt,i1 as M,ou as Ma,P$ as Mi,L3 as Mn,Ka as Mo,Q0 as Mr,N1 as Mt,v1 as N,Dl as Na,IY as Ni,BG as Nn,qa as No,q0 as Nr,S1 as Nt,s1 as O,op as Oa,_8 as Oi,A6 as On,xs as Oo,Z1 as Or,w0 as Ot,nJ as P,Zc as Pa,cq as Pi,gG as Pn,si as Po,J0 as Pr,C1 as Pt,_G as Q,ql as Qa,MG as Qi,Qq as Qn,B0 as Qr,r0 as Qt,G4 as R,xl as Ra,r1 as Ri,o4 as Rn,mn as Ro,h2 as Rr,W1 as Rt,UG as S,W4 as Sa,F4 as Si,I0 as Sn,dc as So,X2 as Sr,k0 as St,d0 as T,hq as Ta,K3 as Ti,H0 as Tn,A as To,P2 as Tr,JG as Tt,y4 as U,cu as Ua,O3 as Ui,a4 as Un,k as Uo,E2 as Ur,b0 as Ut,g4 as V,Xc as Va,EG as Vi,a2 as Vn,zt as Vo,b2 as Vr,o2 as Vt,_4 as W,su as Wa,Iq as Wi,eJ as Wn,O as Wo,S2 as Wr,G3 as Wt,d4 as X,au as Xa,q3 as Xi,Fq as Xn,f0 as Xr,a0 as Xt,f4 as Y,Rl as Ya,PG as Yi,Nq as Yn,m0 as Yr,i0 as Yt,l4 as Z,Xl as Za,LG as Zi,Zq as Zn,z0 as Zr,cJ as Zt,X8 as _,mq as _a,WZ as _i,N0 as _n,rc as _o,Z2 as _r,X1 as _t,R8 as a,OG as aa,U4 as ai,$G as an,Il as ao,q2 as ar,Jq as at,Q8 as b,dK as ba,k3 as bi,aJ as bn,j as bo,d2 as br,O1 as bt,y8 as c,X$ as ca,o8 as ci,_0 as cn,Ls as co,B2 as cr,T1 as ct,V8 as d,n8 as da,Z6 as di,q1 as dn,Hs as do,I2 as dr,T0 as dt,W6 as ea,sJ as ei,Q1 as en,El as eo,K2 as er,SG as et,Z8 as f,AG as fa,kJ as fi,S3 as fn,Ws as fo,e4 as fr,E0 as ft,G8 as g,fq as ga,q6 as gi,pG as gn,tc as go,u2 as gr,HG as gt,Y8 as h,P3 as ha,g8 as hi,KG as hn,jc as ho,I6 as hr,I3 as ht,K8 as i,Y4 as ia,T4 as ii,TG as in,zl as io,N2 as ir,yG as it,y1 as j,qc as ja,B$ as ji,l2 as jn,ma as jo,Z0 as jr,v2 as jt,x1 as k,L as ka,V3 as ki,j6 as kn,Go as ko,$0 as kr,g2 as kt,b8 as l,c8 as la,s8 as li,g0 as ln,uc as lo,V2 as lr,D0 as lt,U8 as m,j4 as ma,A2 as mi,nK as mn,M as mo,D2 as mr,rK as mt,E8 as n,tK as na,G1 as ni,CG as nn,ml as no,U2 as nr,vG as nt,q8 as o,R4 as oa,iJ as oi,_$ as on,kl as oo,c4 as or,Xq as ot,H8 as p,S6 as pa,G6 as pi,eK as pn,N as po,t4 as pr,XG as pt,u4 as q,Jc as qa,b3 as qi,jq as qn,h0 as qr,o0 as qt,D8 as r,Y$ as ra,E4 as ri,wG as rn,Tl as ro,W2 as rr,bG as rt,w8 as s,J4 as sa,Wq as si,y0 as sn,Al as so,J2 as sr,w1 as st,O8 as t,fK as ta,oJ as ti,e0 as tn,eu as to,G2 as tr,xG as tt,k8 as u,L6 as ua,hG as ui,ZG as un,F as uo,F2 as ur,O0 as ut,B8 as v,FG as va,r6 as vi,j0 as vn,I as vo,Q2 as vr,L0 as vt,u0 as w,pK as wa,F3 as wi,V0 as wn,ac as wo,R2 as wr,WG as wt,X6 as x,v8 as xa,x3 as xi,F0 as xn,P as xo,Y2 as xr,D1 as xt,J8 as y,q4 as ya,t6 as yi,tJ as yn,Zs as yo,$2 as yr,R0 as yt,e3 as z,bl as za,_q as zi,t2 as zn,gn as zo,p2 as zr,J1 as zt};
453
- //# sourceMappingURL=server-lock-iLcBw_q0-RDMfTH6b.mjs.map
455
+ `)&&n.push(`trailing-newline`),n}const T3=`parse-equivalence`;function E3(e){return e.replace(/^\n+/,``).replace(/\n+$/,``)}function D3(e){return e.replace(/[ \t]+$/gm,``)}const O3=/^([ \t]*)\d+([.)])(?=[ \t])/;function k3(e){return e.split(`
456
+ `).map(e=>e.replace(O3,(e,t,n)=>`${t}1${n}`)).join(``).replace(/\s+/g,``)}const A3=new Set;function j3(e,t,n){let r=dK(e),i=dK(t);if(r.frontmatter!==i.frontmatter)return!1;if(r.body===i.body)return!0;let a;try{a=n(r.body)}catch(e){let t=e instanceof Error?e.message:String(e);return A3.size<8&&!A3.has(t)&&(A3.add(t),console.warn(`[parse-equivalence] canonicalizeBody threw; treating as not equivalent:`,t)),!1}return E3(D3(a))===E3(D3(i.body))?dJ(k3(r.body),k3(a)):!1}const M3={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e),now:()=>Date.now()},N3={"emphasis-around-code":`pm-model-caused`,bom:`parser-caused`,crlf:`parser-caused`,"commonmark-escape":`parser-caused`,"leading-newline":`parser-caused`,"paragraph-continuation-indent":`parser-caused`,"doc-start-thematic":`parser-caused`,"block-separator-collapse":`serializer-caused`,"table-align-row-spacing":`serializer-caused`,"row-no-trailing-pipe":`serializer-caused`,"ordered-list-marker-number":`serializer-caused`,"list-indent-canonical":`serializer-caused`,"jsx-container-boundary-blank":`serializer-caused`,"trailing-whitespace":`serializer-caused`,"blank-line-collapse":`serializer-caused`,"trailing-newline":`serializer-caused`,"parse-equivalence":`parser-caused`};function P3(e){return N3[e]}function F3(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return e.length===t.length?-1:n}let I3=null;function L3(e){I3=e}function R3(e,t,n,r){if(!I3||e.length===0)return;let i=F3(t,n),a=new Date().toISOString();for(let t of e)I3({timestamp:a,className:t,documentName:r,codeUnitPosition:i,severity:P3(t)})}const z3=1e4,B3=`last-spawn-error.log`,V3=/^[a-zA-Z0-9][\w/-]*$/;function H3(e){return e.startsWith(`#`)?e.slice(1):e}function U3(e){return typeof e==`string`?[e]:Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function W3(e){if(!e||e.trim()===``)return[];let{map:t}=A4(e);if(!t)return[];let n=U3(t.tags),r=[];for(let e of n){let t=H3(e);V3.test(t)&&r.push(t)}return r}const G3=[`.ok`,`local`,`installed-skills.json`],K3=F(TG),q3=Zs({hosts:N(A()),scope:K3,scripts:M(),installedAt:Go()}),J3=Zs({schema:I(1),skills:ac(A(),q3).default({})});function Y3(){return{schema:1,skills:{}}}function X3(e){let t;try{t=JSON.parse(e)}catch{return null}let n=J3.safeParse(t);return n.success?n.data:null}const Z3={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},Q3=new WeakMap;function $3(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function e6(e){return e.trim().toLowerCase()}const t6=/\.(?:md|mdx)$/;function n6(e,t){if(t!==`page`)return e;let n=e.replace(t6,``);return n.length>0?n:e}function r6(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function i6(e){let t=r6(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function a6(e){let t=SW({schema:Z3});return e.length>0&&NW(t,e),t}function o6(e){let t={documents:e};return Q3.set(t,a6(e)),t}function s6(e){let t=Q3.get(e);if(t)return t;let n=a6(e.documents);return Q3.set(e,n),n}function c6(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function l6(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function u6(e,t){let n=e6(t);if(!n)return 0;let r=n6(n,e.kind),i=e6(e.title),a=e6(e.name),o=e6(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function d6(e,t){let n=u6(e,t);return n<=0?n:_q(e.path)?n*.5:n}function f6(e){return e===`file`?-60:0}function p6(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function m6(e,t,n,r){return e+t*20+n+f6(r)}function h6(e,t,n,r,i,a){return e===`relevance`?m6(t,n,r,i):p6(t,n,r,i,a)}function g6(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function _6(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function v6(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 y6(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function b6(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 x6(e,t){return e6(t).length<4?0:e===`full_text`?1:0}function S6(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function C6(e){let t=[],n=[],r=[];for(let i of e){let e=S6(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function w6(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=C6(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function T6(e,t,n={}){let r=n.intent??`omnibar`,i=g6(r,n.ranking),a=$3(n.limit),o=new Set(n.scopes??c6(r)),s=e.documents.filter(e=>l6(e,o)),c=e6(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=lG(s6(e),{term:c,properties:y6(r),boost:b6(r),tolerance:x6(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>l6(e.document,o)).map(e=>[e.document.id,e.score])),d=v6(s),f=new Map;for(let e of s)d6(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)l6(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=_6(f.values(),u);return w6([...f.values()].map(t=>{let n=Math.max(0,d6(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:h6(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return w6(D6({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function E6(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function D6(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=_6(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,d6(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?h6(o,t,n,s,e.kind,m):m6(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=E6(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=E6(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}function O6(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),k6(n)}function k6(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 A6=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),j6=globalThis;j6[A6]===void 0&&(j6[A6]=Ri());const M6=j6[A6],N6=[`.ok`,`skill-state.yml`],P6=[`claude-cowork`,`cli-hosts`],F6=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],I6=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,L6=Zs({version:A().regex(I6,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(M6,{description:`Recorded skill version for this target.`}),recordedAt:Go().register(M6,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:F(F6).register(M6,{description:`Install-source surface that recorded this entry.`}).optional()}),R6=Zs({enabled:M().register(M6,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:Go().register(M6,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),z6=Zs({schema:I(1).register(M6,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Zs({"claude-cowork":L6.optional(),"cli-hosts":L6.optional()}).register(M6,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:ac(A(),R6).register(M6,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional()});function B6(e,t){return e??t.installedOnDisk}function V6(){return{schema:1,targets:{}}}const H6=`template`;function U6(e){if(e.trim()===``)return{};let t;try{t=(0,Fc.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function W6(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function G6(e){let{frontmatter:t,body:n}=dK(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:pK(t),markdown:n}}function K6(e){let t=e.split(`
457
+ `);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=U6(n.join(`
458
+ `))[H6];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
459
+ `).replace(/\n+$/,``)}}function q6(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=dK(t);if(n===``)return{identity:{},starterContent:t};let i=pK(n),a=K6(i);if(a)return{identity:a.identity,starterContent:W6(a.docFrontmatterText,r)};let{frontmatter:o}=dK(r);if(o!==``)return{identity:U6(i),starterContent:r};let s=U6(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:W6(i,r)}}function J6(e,t){let{docFrontmatterText:n,markdown:r}=G6(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Fc.stringify)({[H6]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function Y6(e){return q6(e).starterContent}function X6(){let e=!1,t=``,n=0;return r=>{let i=Z6(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 Z6(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 Q6=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],$6={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function e8(e,t=Q6){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const t8={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function n8(e){return e?t8[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const r8={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function i8(e){let t=e?.trim();return t?r8[n8(t)]??t:`Agent`}function a8(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 o8=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function s8(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function c8(e){let t=e.trim();return o8.test(t)||t.startsWith(`//`)}function l8(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(c8(n))return{kind:`external`,url:n};let r=a8(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=s8(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function u8(e,t){let n=e.trim();if(!n)return null;if(c8(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=s8(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function d8(e,t){let n=e.trim();if(!n||o8.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 f8(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function p8(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function m8(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function h8(e){return e.split(`/`).filter(e=>e!==``)}function g8(e,t){let n=m8(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function _8(e,t){let n=m8(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:h8(r).length}function v8(e,t){let n=h8(e),r=h8(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function y8(){let e=new Map;function t(t){let n=f8(t);if(n===``)return;let r=p8(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=f8(t),r=p8(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=m8(f8(n)),o=[],s=[];for(let e of i)g8(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=_8(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=_8(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=v8(a,m8(t));for(let r=1;r<e.length;r++){let i=e[r],o=v8(a,m8(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 b8(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 x8(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 S8(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function C8(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}const w8=/^[A-Za-z0-9-]{8,64}$/;let T8=null;function E8(e){return l(e??m(),`.ok`,`machine-id`)}function D8(e){if(e===void 0&&T8!==null)return T8;let t=E8(e),n=null;try{let e=b(t,`utf-8`).trim();w8.test(e)&&(n=e)}catch{}if(n===null){n=w();try{v(c(t),{recursive:!0}),S(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){console.warn(`[machine-id] Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(T8=n),n}function O8(){try{let e=u(c(f(import.meta.url)),`..`,`package.json`),t=JSON.parse(b(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const k8=O8(),A8=1;var j8=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${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 M8(e,t){return u(e,`${t}.lock`)}const N8=new Map;function P8(e){N8.set(e,(N8.get(e)??0)+1)}function F8(e){let t=N8.get(e);return t===void 0||t<=1?(N8.delete(e),!0):(N8.set(e,t-1),!1)}function I8(e){return typeof e.machineId==`string`?e.machineId===D8():e.hostname===h()}const L8=new Set;let R8=!1;function z8(e){L8.add(e),!R8&&(R8=!0,process.on(`exit`,()=>{for(let e of L8)try{let t=JSON.parse(b(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==D8()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==h())continue;x(e)}catch{}}))}function B8(e,t){try{let n=JSON.parse(b(e,`utf-8`));return n&&typeof n==`object`&&C8(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 V8(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;v(n,{recursive:!0});let a=M8(n,t),o={pid:process.pid,hostname:h(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:D8(),...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??k8},s=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!_(a))try{let e=y(a,`wx`,384);try{C(e,s)}finally{g(e)}return P8(a),z8(a),H8({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=B8(a,i);if(e){if(I8(e)&&e.pid===process.pid)return S(a,s,{encoding:`utf-8`,mode:384}),P8(a),z8(a),H8({lockName:t,lockDir:n,lockPath:a});if(S8(e.pid))throw new j8(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{x(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function H8(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>J8({lockName:t,lockDir:n}),updatePort:e=>U8({lockName:t,lockDir:n,port:e})}}function U8(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=M8(n,t);if(!_(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||!C8(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&&I8(o)){o.port=r;try{S(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 W8(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=M8(n,t);if((N8.get(i)??0)>1)return;let a;try{let e=JSON.parse(b(i,`utf-8`));if(!e||typeof e!=`object`||!C8(e.pid)){console.warn(`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){e.code!==`ENOENT`&&console.warn(`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&I8(a)&&a.draining!==!0){a.draining=!0;try{S(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function G8(e){let{lockName:t,lockDir:n}=e,r=M8(n,t);if(!_(r))return null;let i;try{let e=JSON.parse(b(r,`utf-8`));if(!e||typeof e!=`object`||!C8(e.pid))return null;i=e}catch{return null}if(!I8(i))return null;if(!S8(i.pid)){try{x(r)}catch{}return null}return i}function K8(e){let{lockName:t,lockDir:n}=e,r=M8(n,t);if(!_(r))return{status:`absent`};let i;try{i=JSON.parse(b(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(!C8(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,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!I8(o))return{status:`stale`,lock:o};if(!S8(o.pid)){try{x(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}}async function q8(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>G8({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function J8(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=M8(n,t);if(F8(a)){if(r){W8({lockName:t,lockDir:n});return}if(_(a))try{let e=JSON.parse(b(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!I8(e))return;x(a),L8.delete(a)}catch(e){console.warn(`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var Y8=class extends j8{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function X8(e,t){try{return V8({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof j8&&e.lockName===`server`?new Y8(e.existing,e.lockPath):e}}function Z8(e,t){U8({lockName:`server`,lockDir:e,port:t})}function Q8(e){return G8({lockName:`server`,lockDir:e})}function $8(e,t){J8({lockName:`server`,lockDir:e,...t})}function e5(e){W8({lockName:`server`,lockDir:e})}function t5(e,t){return q8({lockName:`server`,lockDir:e,...t})}export{mG as $,ql as $a,MG as $i,z2 as $n,YG as $r,n0 as $t,a1 as A,L as Aa,g$ as Ai,I6 as An,Go as Ao,X0 as Ar,_2 as At,g1 as B,bl as Ba,Gq as Bi,n2 as Bn,gn as Bo,w2 as Br,G3 as Bt,m1 as C,W4 as Ca,i8 as Ci,K1 as Cn,dc as Co,L2 as Cr,A0 as Ct,b1 as D,P4 as Da,O6 as Di,O2 as Dn,$s as Do,lJ as Dr,z1 as Dt,o1 as E,hq as Ea,V6 as Ei,DG as En,A as Eo,x0 as Er,GG as Et,j1 as F,Zc as Fa,n8 as Fi,B1 as Fn,si as Fo,Y0 as Fr,e1 as Ft,v4 as G,su as Ga,zG as Gi,Cq as Gn,O as Go,C2 as Gr,VG as Gt,b4 as H,Xc as Ha,QG as Hi,e2 as Hn,zt as Ho,T2 as Hr,c2 as Ht,A1 as I,Cl as Ia,Y6 as Ii,V1 as In,br as Io,H6 as Ir,qG as It,p4 as J,Jc as Ja,Q4 as Ji,Aq as Jn,p0 as Jr,t0 as Jt,h4 as K,nu as Ka,e3 as Ki,Eq as Kn,ht as Ko,x2 as Kr,I1 as Kt,qq as L,wl as La,Rq as Li,n4 as Ln,un as Lo,j2 as Lr,U1 as Lt,i1 as M,qc as Ma,P$ as Mi,B3 as Mn,ma as Mo,Q0 as Mr,N1 as Mt,v1 as N,ou as Na,IY as Ni,BG as Nn,Ka as No,q0 as Nr,S1 as Nt,s1 as O,gb as Oa,b8 as Oi,N6 as On,Ks as Oo,Z1 as Or,w0 as Ot,nJ as P,Dl as Pa,cq as Pi,gG as Pn,qa as Po,J0 as Pr,C1 as Pt,_G as Q,Xl as Qa,LG as Qi,Qq as Qn,B0 as Qr,r0 as Qt,G4 as R,Sl as Ra,r1 as Ri,o4 as Rn,fn as Ro,h2 as Rr,W1 as Rt,UG as S,x8 as Sa,F4 as Si,I0 as Sn,P as So,X2 as Sr,k0 as St,d0 as T,pK as Ta,Y3 as Ti,H0 as Tn,ac as To,P2 as Tr,JG as Tt,y4 as U,pl as Ua,j3 as Ui,a4 as Un,Dt as Uo,E2 as Ur,b0 as Ut,g4 as V,Kc as Va,EG as Vi,a2 as Vn,cn as Vo,b2 as Vr,o2 as Vt,_4 as W,cu as Wa,Iq as Wi,eJ as Wn,k as Wo,S2 as Wr,J3 as Wt,d4 as X,Rl as Xa,PG as Xi,Fq as Xn,f0 as Xr,a0 as Xt,f4 as Y,jl as Ya,A4 as Yi,Nq as Yn,m0 as Yr,i0 as Yt,l4 as Z,au as Za,X3 as Zi,Zq as Zn,z0 as Zr,cJ as Zt,$8 as _,fq as _a,WZ as _i,N0 as _n,tc as _o,Z2 as _r,X1 as _t,V8 as a,Y4 as aa,U4 as ai,$G as an,zl as ao,q2 as ar,Jq as at,t5 as b,q4 as ba,M3 as bi,aJ as bn,Zs as bo,d2 as br,O1 as bt,S8 as c,J4 as ca,l8 as ci,_0 as cn,Al as co,B2 as cr,T1 as ct,W8 as d,B6 as da,e8 as di,q1 as dn,F as do,I2 as dr,T0 as dt,f2 as ea,sJ as ei,Q1 as en,fl as eo,K2 as er,SG as et,e5 as f,a8 as fa,kJ as fi,T3 as fn,Hs as fo,e4 as fr,E0 as ft,J8 as g,L3 as ga,X6 as gi,pG as gn,jc as go,u2 as gr,HG as gt,Q8 as h,j4 as ha,y8 as hi,KG as hn,M as ho,z6 as hr,z3 as ht,Y8 as i,Y$ as ia,T4 as ii,TG as in,Tl as io,N2 as ir,yG as it,y1 as j,lu as ja,B$ as ji,l2 as jn,Uo as jo,Z0 as jr,v2 as jt,x1 as k,op as ka,W3 as ki,P6 as kn,xs as ko,$0 as kr,g2 as kt,C8 as l,X$ as la,u8 as li,g0 as ln,Ls as lo,V2 as lr,D0 as lt,K8 as m,T6 as ma,A2 as mi,nK as mn,N as mo,D2 as mr,rK as mt,k8 as n,fK as na,G1 as ni,CG as nn,eu as no,U2 as nr,vG as nt,X8 as o,OG as oa,iJ as oi,_$ as on,Il as oo,c4 as or,Xq as ot,G8 as p,AG as pa,J6 as pi,eK as pn,Ws as po,t4 as pr,XG as pt,u4 as q,Yc as qa,C3 as qi,jq as qn,mt as qo,h0 as qr,o0 as qt,A8 as r,tK as ra,E4 as ri,wG as rn,ml as ro,W2 as rr,bG as rt,D8 as s,R4 as sa,Wq as si,y0 as sn,kl as so,J2 as sr,w1 as st,j8 as t,q6 as ta,oJ as ti,e0 as tn,El as to,G2 as tr,xG as tt,M8 as u,d8 as ua,hG as ui,ZG as un,uc as uo,F2 as ur,O0 as ut,U8 as v,mq as va,o6 as vi,j0 as vn,rc as vo,Q2 as vr,L0 as vt,u0 as w,M$ as wa,R3 as wi,V0 as wn,Pc as wo,R2 as wr,WG as wt,$6 as x,dK as xa,w3 as xi,F0 as xn,j as xo,Y2 as xr,D1 as xt,Z8 as y,FG as ya,i6 as yi,tJ as yn,I as yo,$2 as yr,R0 as yt,r3 as z,xl as za,_q as zi,t2 as zn,mn as zo,p2 as zr,J1 as zt};
460
+ //# sourceMappingURL=server-lock-iLcBw_q0-7VqZoW4r.mjs.map