@inkeep/open-knowledge 0.30.0-beta.2 → 0.30.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +11 -11
- package/dist/config-schema.json +24 -0
- package/dist/config.project-local.schema.json +24 -0
- package/dist/constants-UBjBavXu.mjs +2 -0
- package/dist/{dist-DJ0wJimx.mjs → dist-B5JbDwWb.mjs} +1 -1
- package/dist/{dist-DAVo_TRx.mjs → dist-DXIG2Jyg.mjs} +7 -7
- package/dist/{gh-detect-BxDh8M_E.mjs → gh-detect-BMbpd_Yj.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{init-E8FDYW-D.mjs → init-CkBE_apM.mjs} +3 -3
- package/dist/init-CoL8N4la.mjs +1 -0
- package/dist/{launch-json-removal-ByWYRF7W.mjs → launch-json-removal-YtOryh7V.mjs} +2 -2
- package/dist/{loader-Bi7zAoyk.mjs → loader-BOmEZv00.mjs} +2 -2
- package/dist/loader-eceKqMkc.mjs +1 -0
- package/dist/{open-browser-6ztGUs93.mjs → open-browser-gwoFcjXN.mjs} +2 -2
- package/dist/{preview-hq0cdoZw.mjs → preview-CJm1A1UQ.mjs} +2 -2
- package/dist/preview-DHkr2cX1.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-D1snXuNs.js → ActivityModeContent-C0_GSBuC.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-C3FZ7AWB.js → CodeMirrorPropInput-C2VECyjO.js} +2 -2
- package/dist/public/assets/{DocumentContext-CPgyt-fa.js → DocumentContext-f6XQqg_y.js} +7 -7
- package/dist/public/assets/{EnableSyncConfirmDialog-a1BAa003.js → EnableSyncConfirmDialog-BhwhYBFL.js} +1 -1
- package/dist/public/assets/{GraphPanel-Dqn1R3FA.js → GraphPanel-ByzLo6-b.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-D9gtQzwY.js → ManagedArtifactProperties-DAzdDsOt.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-B3eYpOil.js → McpConsentDialogBody-BwDo5LSJ.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-CZKy1wMI.js → MermaidDocEditor-BpnOw4CA.js} +1 -1
- package/dist/public/assets/{PropertyPanel-k3LSAy4u.js → PropertyPanel-B3wmhQBT.js} +1 -1
- package/dist/public/assets/SettingsDialogBody-DVvKGL9J.js +7 -0
- package/dist/public/assets/{ShareBranchSwitchDialog-OJA4wjqQ.js → ShareBranchSwitchDialog-i35Gg8js.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-7EizE4VA.js → ShareReceiveDialog-LrK6Us6O.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-D8Up16fz.js → ShareReceiveMissDialog-CEV0ExUm.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-B25PfvD1.js → SkillEditorActions-BoEoI6NN.js} +1 -1
- package/dist/public/assets/{SourceEditor-D_fZ07fz.js → SourceEditor-DuPpY_T6.js} +1 -1
- package/dist/public/assets/{TerminalPanel-Dw3H1oil.js → TerminalPanel-Di7sR9_K.js} +1 -1
- package/dist/public/assets/{agent-presence-c_qxeP7e.js → agent-presence-DOgDiPgh.js} +1 -1
- package/dist/public/assets/{auth-state-cache-D4z3eiMF.js → auth-state-cache-CZRVpVW6.js} +3 -3
- package/dist/public/assets/{config-provider-BONo47Qc.js → config-provider-BnOnKhga.js} +1 -1
- package/dist/public/assets/{dist-CJfVM-iJ.js → dist-D7PDymSy.js} +3 -3
- package/dist/public/assets/{dist-BDGd7UYM.js → dist-xdRBzARh.js} +1 -1
- package/dist/public/assets/{doc-hash-BLS3MEoj.js → doc-hash-i5oNLfum.js} +1 -1
- package/dist/public/assets/{documents-events-H4-z8Qjp.js → documents-events-D26lhbOZ.js} +1 -1
- package/dist/public/assets/file-tree-adapter-N1FVhfKw.js +1 -0
- package/dist/public/assets/index-KSKNKDpJ.js +2003 -0
- package/dist/public/assets/{keyboard-shortcuts-DnJWzgZ1.js → keyboard-shortcuts-Bgozgsx2.js} +1 -1
- package/dist/public/assets/navigation-targets-D_wZddL9.js +1 -0
- package/dist/public/assets/{open-managed-artifact-tab-NBmHUyDy.js → open-managed-artifact-tab-kOn8WHrp.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-D7JjzV1n.js → pending-receive-nav-store-CDyGvnwD.js} +1 -1
- package/dist/public/assets/{prop-types-Cl1SYZho.js → prop-types-BK5m4zFC.js} +1 -1
- package/dist/public/assets/{receive-store-DWC9dc5j.js → receive-store-Jc3PEGIh.js} +1 -1
- package/dist/public/assets/{selection-context-DALYXIVY.js → selection-context-72mLve4s.js} +1 -1
- package/dist/public/assets/{skill-actions-BV30AE89.js → skill-actions-CeU8Dbpm.js} +1 -1
- package/dist/public/assets/{skills-api-B0z9Mw2W.js → skills-api-k47WvkqQ.js} +1 -1
- package/dist/public/assets/{src-DZ97WDxX.js → src-B6vksAtW.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-CpKCAQDV.js → target-navigation-intent-DEwTup1R.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-ko_Nb-fG.js → typing-burst-detector-BC1YUpwK.js} +1 -1
- package/dist/public/assets/{workspace-paths-CMbeqczX.js → workspace-paths-D4weWrbA.js} +1 -1
- package/dist/public/index.html +25 -25
- package/dist/{repair-launch-json-BdfDMobg.mjs → repair-launch-json-DO2QDHDR.mjs} +2 -2
- package/dist/{repair-mcp-configs-DZMxi-7M.mjs → repair-mcp-configs-RYSmTXdj.mjs} +2 -2
- package/dist/{repair-skills-zutt1is6.mjs → repair-skills-BrAdfxB-.mjs} +2 -2
- package/dist/repair-skills-NtsjF26d.mjs +1 -0
- package/dist/schemas/v0/config.project-local.schema.json +24 -0
- package/dist/server-lock-GuuouVft-CXM0Fdz7.mjs +1 -0
- package/dist/{server-lock-iLcBw_q0-RDMfTH6b.mjs → server-lock-iLcBw_q0-DB1Ahu2b.mjs} +3 -3
- package/dist/{src-Bi9Si6vM.mjs → src-2ZRymDy2.mjs} +2 -2
- package/dist/{start-DqcZAaBv.mjs → start-CR2-ryWz.mjs} +2 -2
- package/dist/start-D2aYJnFK.mjs +1 -0
- package/dist/{write-project-skill-BzVHToYO.mjs → write-project-skill-XZCJ5TEZ.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-BGBZW_Qv.mjs +0 -2
- package/dist/init-B02GcqsQ.mjs +0 -1
- package/dist/loader-CT3CzsPt.mjs +0 -1
- package/dist/preview-DtuXRRGi.mjs +0 -1
- package/dist/public/assets/SettingsDialogBody-do88Fri6.js +0 -7
- package/dist/public/assets/file-tree-adapter-B8tTfm_Y.js +0 -1
- package/dist/public/assets/index-Ci4eWUi8.js +0 -2003
- package/dist/public/assets/navigation-targets-DM3L8UZy.js +0 -1
- package/dist/repair-skills-B0TdudPZ.mjs +0 -1
- package/dist/server-lock-GuuouVft-CCnjEa8y.mjs +0 -1
- package/dist/start-CDJKwObu.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(`
|
|
@@ -450,4 +450,4 @@ $2`).split(`
|
|
|
450
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
451
|
`))[z6];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
|
|
452
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-
|
|
453
|
+
//# sourceMappingURL=server-lock-iLcBw_q0-DB1Ahu2b.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as e}from"./chunk-C94x7I9S.mjs";import{Ko as t,c as n,l as r,s as i,u as a}from"./server-lock-iLcBw_q0-
|
|
1
|
+
import{s as e}from"./chunk-C94x7I9S.mjs";import{Ko as t,c as n,l as r,s as i,u as a}from"./server-lock-iLcBw_q0-DB1Ahu2b.mjs";import{Ar as o,Sn as s,ei as c,fa as l,kr as u,un as d,vn as f}from"./dist-DXIG2Jyg.mjs";import{t as p}from"./esm-CsQUg9js.mjs";import"./gh-detect-BMbpd_Yj.mjs";import{E as m,S as ee,T as h,_ as g,b as te,o as ne,v as re,w as _}from"./init-CkBE_apM.mjs";import{_ as ie,d as ae,i as oe,v}from"./write-project-skill-XZCJ5TEZ.mjs";import"./loader-BOmEZv00.mjs";import{c as y}from"./colors-8SzMRIVy.mjs";import"./preview-CJm1A1UQ.mjs";import{dirname as b,isAbsolute as x,join as S,relative as C,resolve as w}from"node:path";import{hostname as se}from"node:os";import{existsSync as T,lstatSync as ce,readFileSync as E,readlinkSync as le,rmSync as ue,statSync as de}from"node:fs";import{readFile as D,realpath as O}from"node:fs/promises";function k(e,t,o={}){let s=a(e,t);if(!T(s))return{status:`missing`,lockPath:s};let c;try{c=JSON.parse(E(s,`utf-8`))}catch{return{status:`corrupt`,lockPath:s}}if(!c||typeof c!=`object`||!r(c.pid))return{status:`corrupt`,lockPath:s};let l=c;if(!(o.isAlive??n)(l.pid))return{status:`dead-pid`,lockPath:s,lock:l};if(typeof l.machineId==`string`)return l.machineId===(o.machineId??i())?{status:`alive`,lockPath:s,lock:l}:{status:`foreign-host`,lockPath:s,lock:l};let u=o.host??se();return l.hostname===u?{status:`alive`,lockPath:s,lock:l}:{status:`foreign-host`,lockPath:s,lock:l}}function A(e){return e.replace(/:\d+$/,``)}function j(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:A(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:A(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:A(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.-]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function M(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}function N(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`);if(n.length<5||n[0]!==``||n[3]!==`tree`)return null;let r=n.slice(5);r.length===1&&r[0]===``&&r.pop();let i,a,o,s;try{i=decodeURIComponent(n[1]),a=decodeURIComponent(n[2]),o=decodeURIComponent(n[4]),s=r.map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.some(e=>e.length===0)?null:{owner:i,repo:a,branch:o,path:s.join(`/`)}}function P(e){let t=M(e);if(t)return{kind:`doc`,...t};let n=N(e);return n?{kind:`folder`,...n}:null}const F=`# >>> open-knowledge cli >>>`,I=`# <<< open-knowledge cli <<<`,L=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function R(e){return S(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const z={existsSync:e=>T(e),readFileSync:(e,t)=>E(e,t),lstatSync:e=>ce(e),readlinkSync:e=>le(e)};function B(e,t=z){let n=R(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function V(e){let t=e.replace(L,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function H(e,t,n=z){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}var fe=t();function pe(e){return ie(e)||v(e)||ee(e)}const U=10*1024*1024;function me(e,t,n,r){let i=ne(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!pe(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(ue(a,{force:!0}),{kind:`removed`}):e.format===`toml`?_e(a,o):e.format===`yaml`?ge(a,e.topLevelKey,o):he(a,e.topLevelKey,e.serverMapSubKey,o)}function he(e,t,n,r){let i;try{i=E(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>U)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=m(i,g(t,n,r));return o?(l(e,a,{mode:_(e)}),{kind:`removed`}):{kind:`not-present`}}function ge(e,t,n){let r;try{r=E(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>U)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,fe.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),u=h(a);a.trim()===``||a.endsWith(`
|
|
2
2
|
`)?c.endsWith(`
|
|
3
3
|
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),u&&(c=c.replace(/\r\n/g,`
|
|
4
4
|
`).replace(/\n/g,`\r
|
|
@@ -8,4 +8,4 @@ import{s as e}from"./chunk-C94x7I9S.mjs";import{Ko as t,c as n,l as r,s as i,u a
|
|
|
8
8
|
`).replace(/\n/g,`\r
|
|
9
9
|
`));let d=`${i?``:``}${u}`;return d!==r&&l(e,d,{mode:_(e)}),{kind:`removed`}}const ve=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`deinit`]);function ye(e,t,n=s){if(e!==void 0&&!ve.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let W=null;function be(e){W=e}function xe(){return W??process.cwd()}var G=e(y(),1);function Se(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Ce(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function we(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:f(r),command:r,isDesktop:Se(r)}}function Te(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function K(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&Te(e)?`ui-orphan`:`stale`}const Ee=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function De(e){switch(e){case`running`:return G.default.green(e);case`desktop`:return G.default.blue(e);case`foreign`:return G.default.cyan(e);case`ui-orphan`:return G.default.magenta(e);case`stale`:return G.default.yellow(e)}}function q(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Oe(e){return`${q(e.server.usage)} | ${q(e.ui?.usage??null)}`}function ke(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function Ae(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=K(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,ke(e),Oe(e),t,String(n),Ce(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=De(K(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=G.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
10
10
|
`)}async function J(e={}){let t=e.discover??d,n=e.inspect??k,r=e.log??(e=>console.log(e)),i=e.resolveCommand??u,a=e.resolveUsage??o,s=await t(),c=[];for(let e of s){let t=n(e,`server`),r=n(e,`ui`),o=we(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&c.push(o)}if(e.json){let e=c.map(e=>({...e,displayStatus:K(e)}));r(JSON.stringify(e,null,2));return}r(Ae(e.all?c:c.filter(e=>Ee.has(K(e)))))}function je(){return new p(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await J({all:t.all===!0||e===`all`,json:t.json===!0})})}function Me(e,t,r={}){let i=r.isAlive??n,a=[];for(let[n,r]of[[`server`,e],[`ui`,t]])(r.status===`alive`||r.status===`foreign-host`&&i(r.lock.pid))&&a.push({name:n,pid:r.lock.pid,port:r.lock.port});return{targets:a}}function Y(e){let t=e.inspect??(t=>k(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=Me(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function X(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Ne(e,t=n){let r=await d(),i=null;for(let n of r){let r=k(n,`server`),a=k(n,`ui`);if(X(r,t)&&r.lock.port===e||X(a,t)&&a.lock.port===e)return n;i===null&&(X(r,t)&&r.lock.pid===e||X(a,t)&&a.lock.pid===e)&&(i=n)}return i}function Z(e){let t=Y({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Pe(e){return new p(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let r=t.length===0?void 0:t.join(` `);if(r===void 0){e();let t=Y({lockDir:c(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await J({});return}if(r===`all`){let e=await d();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let r of e){let e=k(r,`server`),i=k(r,`ui`);!X(e,n)&&!X(i,n)||(Z(r),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(r)){let e=Number.parseInt(r,10),t=await Ne(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Z(t);return}Z(c(w(xe(),r)))})}function Fe(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}async function Q(e,t){let n,r;try{n=await O(w(e)),r=await O(w(b(e)))}catch{return{kind:`not-git`}}if(!$(n,r))return{kind:`symlink-escape`};let i=S(n,`.git`),a;try{a=de(i)}catch{return{kind:`not-git`}}let o;if(a.isDirectory()){let e;try{e=await O(i)}catch{return{kind:`not-git`}}if(!$(e,n))return{kind:`symlink-escape`};o=e}else if(a.isFile()){let e;try{e=await D(i,`utf-8`)}catch{return{kind:`not-git`}}let t=/^gitdir:\s*(.+)$/m.exec(e.trim());if(!t)return{kind:`not-git`};let r=t[1].trim(),a=x(r)?r:w(n,r);try{o=await O(a)}catch{return{kind:`not-git`}}}else return{kind:`not-git`};let s=S(await Ie(o),`config`),c;try{c=await D(s,`utf-8`)}catch{return{kind:`not-git`}}let l=Re(c);if(l===null)return{kind:`no-origin`};let u=j(l);if(u===null||u.hostname!==`github.com`)return{kind:`non-github`};let d=u.owner.toLowerCase()===t.owner.toLowerCase(),f=u.name.toLowerCase()===t.repo.toLowerCase();return!d||!f?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://github.com/${u.owner}/${u.name}.git`}}async function Ie(e){let t;try{t=(await D(S(e,`commondir`),`utf-8`)).trim()}catch{return e}if(t.length===0)return e;let n=x(t)?t:w(e,t);try{return await O(n)}catch{return n}}function $(e,t){if(e===t)return!0;let n=C(t,e);return n.length>0&&!n.startsWith(`..`)&&!x(n)}function Le(e){let t=e.indexOf(`#`),n=e.indexOf(`;`),r=-1;return t>=0&&n>=0?r=Math.min(t,n):t>=0?r=t:n>=0&&(r=n),(r===-1?e:e.slice(0,r)).trim()}function Re(e){let t=!1;for(let n of e.split(/\r?\n/)){let e=Le(n);if(e.length===0)continue;if(e.startsWith(`[`)){t=/^\[\s*remote\s+["']origin["']\s*\]$/.test(e);continue}if(!t)continue;let r=/^url\s*=\s*(.+)$/.exec(e);if(r)return ze(r[1])}return null}function ze(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}const Be=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=re(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let n=oe(e,t);return{integration:`project-skill`,editorId:e.id,action:n.action,...n.path?{path:n.path}:{},...n.error?{error:n.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function Ve(e,t,n={},r=Be){let i=[];for(let a of t){let t=ae[a];for(let a of r)i.push(a.write(t,e,n))}return i}function He(e,t,n={}){return{integrations:Ve(e,t,n)}}export{M as _,Pe as a,j as b,ye as c,L as d,I as f,V as g,B as h,Y as i,me as l,R as m,Q as n,je as o,H as p,Fe as r,be as s,He as t,F as u,P as v,k as x,N as y};
|
|
11
|
-
//# sourceMappingURL=src-
|
|
11
|
+
//# sourceMappingURL=src-2ZRymDy2.mjs.map
|