@inkeep/open-knowledge 0.63.1 → 0.63.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/dist/{acp-harness-probe-XMxFGBoY.mjs → acp-harness-probe-Bl2YIsum.mjs} +2 -2
  2. package/dist/cli.mjs +6 -6
  3. package/dist/constants-DOaUGsN8.mjs +2 -0
  4. package/dist/{git-handle-DBSBLTQr.mjs → git-handle-4kfkNWhe.mjs} +2 -2
  5. package/dist/git-handle-BdfJ9JDW.mjs +1 -0
  6. package/dist/index.mjs +60 -56
  7. package/dist/init-BLXlbDea.mjs +1 -0
  8. package/dist/{init-w448Zb1P.mjs → init-BnIbaMPo.mjs} +3 -3
  9. package/dist/{launch-json-removal-BGxa7kOw.mjs → launch-json-removal-BKL0-y8-.mjs} +2 -2
  10. package/dist/loader-EbJXHwng.mjs +1 -0
  11. package/dist/{loader-DWWsI9JR.mjs → loader-Xwx5vjNX.mjs} +2 -2
  12. package/dist/md-manager-DS8TUqd4.mjs +2 -0
  13. package/dist/{open-browser-ycZBGuNV.mjs → open-browser-c1C7j5cZ.mjs} +2 -2
  14. package/dist/parse-worker.mjs +1 -1
  15. package/dist/{preview-Cd_2hNw6.mjs → preview-CzPN3mXn.mjs} +2 -2
  16. package/dist/preview-HBOVip3T.mjs +1 -0
  17. package/dist/public/assets/{ActivityModeContent-BJkv-wtf.js → ActivityModeContent-BRHWUTU_.js} +1 -1
  18. package/dist/public/assets/{AddPropertiesButton-DZrj-WbN.js → AddPropertiesButton-B5S_biuo.js} +1 -1
  19. package/dist/public/assets/{AgentDiffPane-DdTUH5Iy.js → AgentDiffPane-CKMN7uO2.js} +1 -1
  20. package/dist/public/assets/{AgentThreadClientBinder-B7GHdT50.js → AgentThreadClientBinder-BeOI_eLL.js} +1 -1
  21. package/dist/public/assets/{BugReportHistory-CDjs-UvS.js → BugReportHistory-DX6L-_sJ.js} +1 -1
  22. package/dist/public/assets/{BugReportHistoryDialog-gMqpgd_4.js → BugReportHistoryDialog-DsssFBQs.js} +1 -1
  23. package/dist/public/assets/{CodeMirrorPropInput-BQbWlwTu.js → CodeMirrorPropInput-CiDPQMoe.js} +1 -1
  24. package/dist/public/assets/{DocumentContext-DQusF2ho.js → DocumentContext-BNVmouLp.js} +1 -1
  25. package/dist/public/assets/{EditorModeToggle-BdGWhpIY.js → EditorModeToggle-ChXuaX-g.js} +1 -1
  26. package/dist/public/assets/{EnableSyncConfirmDialog-BI3oSfND.js → EnableSyncConfirmDialog-BZxFQH1e.js} +1 -1
  27. package/dist/public/assets/{ExcalidrawDocEditor-DJV8Vr7i.js → ExcalidrawDocEditor-kSXgInTo.js} +1 -1
  28. package/dist/public/assets/FeedbackForm-i76yrsBl.js +1 -0
  29. package/dist/public/assets/{GraphPanel-fAs0m1k4.js → GraphPanel-XzZ9os01.js} +1 -1
  30. package/dist/public/assets/{ImportSkillDialog-BhUc9wrT.js → ImportSkillDialog-AMZB8Sq-.js} +1 -1
  31. package/dist/public/assets/{LintConfigEditor-BbQC5XBO.js → LintConfigEditor-CR1JM7qC.js} +1 -1
  32. package/dist/public/assets/ManagedArtifactProperties-BXWl4sj9.js +1 -0
  33. package/dist/public/assets/ManagedArtifactProperties-DvxRb75E.js +1 -0
  34. package/dist/public/assets/{MermaidDocEditor-CLd3gDFx.js → MermaidDocEditor-DNtN6gpQ.js} +1 -1
  35. package/dist/public/assets/{PropertyDisplayRow-BqNNqtQq.js → PropertyDisplayRow-D8YTuo2g.js} +1 -1
  36. package/dist/public/assets/{ReportBugDialogBody-7G3gDx90.js → ReportBugDialogBody-eEi1p8SY.js} +1 -1
  37. package/dist/public/assets/{SchemaConfigEditor-DJdskJ7F.js → SchemaConfigEditor-BdDBPlf8.js} +1 -1
  38. package/dist/public/assets/{SessionsHost-C0KNjtqL.js → SessionsHost-BWF5LkCB.js} +2 -2
  39. package/dist/public/assets/{SettingsDialogBody-eG4WwStf.js → SettingsDialogBody-D-xJh1Wz.js} +1 -1
  40. package/dist/public/assets/{ShareBranchSwitchDialog-BVSorWIl.js → ShareBranchSwitchDialog-CrAn8BfM.js} +1 -1
  41. package/dist/public/assets/{ShareReceiveDialog-MMs7AIMS.js → ShareReceiveDialog-BHw7vyVN.js} +1 -1
  42. package/dist/public/assets/{ShareReceiveMissDialog-Brs6R8I6.js → ShareReceiveMissDialog-BLiZVpAL.js} +1 -1
  43. package/dist/public/assets/{SkillCostValue-_Y5l2XwJ.js → SkillCostValue-BLO1pLvK.js} +1 -1
  44. package/dist/public/assets/{SkillEditBanner-D7_vEL-Q.js → SkillEditBanner-gs8OWdnP.js} +1 -1
  45. package/dist/public/assets/{SkillInstallMenu-CK7w8oqi.js → SkillInstallMenu-B8VpVw2e.js} +1 -1
  46. package/dist/public/assets/{SkillOriginInline-CPhIPMvZ.js → SkillOriginInline-B2Xgoqtt.js} +1 -1
  47. package/dist/public/assets/{SkillToolbarControls-mIxMbZvN.js → SkillToolbarControls-DV1Fs4Pg.js} +1 -1
  48. package/dist/public/assets/{SlidesToolbarControls-BMDuGCKO.js → SlidesToolbarControls-CTcysZq-.js} +1 -1
  49. package/dist/public/assets/{SourceEditor-D61sV5zD.js → SourceEditor-n5FZTUOu.js} +1 -1
  50. package/dist/public/assets/{TerminalPanel-CyBB22vO.js → TerminalPanel-B6ZtyhwL.js} +1 -1
  51. package/dist/public/assets/{TerminalWindowApp-8SJJG0FH.js → TerminalWindowApp-CZJAw22h.js} +1 -1
  52. package/dist/public/assets/{TextDocEditor-YEyv9FD3.js → TextDocEditor-DkJOYSVf.js} +1 -1
  53. package/dist/public/assets/{ThreadView-DusalK06.js → ThreadView-BRzUHw-R.js} +1 -1
  54. package/dist/public/assets/{TimelineDiffPane-CuowvgxZ.js → TimelineDiffPane-DCCqK3H8.js} +1 -1
  55. package/dist/public/assets/{agent-diff-store-B3q363Zs.js → agent-diff-store-DI5tXhTu.js} +1 -1
  56. package/dist/public/assets/{auth-state-cache-Cy2yuigh.js → auth-state-cache-CG_XUeO-.js} +1 -1
  57. package/dist/public/assets/{bug-report-send-manager-BVeLqplu.js → bug-report-send-manager-zDc5vC2X.js} +1 -1
  58. package/dist/public/assets/{client-version-D29tmSfy.js → client-version-lhd-bvFR.js} +1 -1
  59. package/dist/public/assets/{comment-chips-B11UWYP_.js → comment-chips-ChSYInGh.js} +1 -1
  60. package/dist/public/assets/{config-provider-Cn54Nsso.js → config-provider-CQmpYETo.js} +3 -3
  61. package/dist/public/assets/{dist-D3fPY7nj2.js → dist-GmWRTOzP2.js} +1 -1
  62. package/dist/public/assets/{doc-paths-82OyHgqG.js → doc-paths-UE_zeyLH.js} +1 -1
  63. package/dist/public/assets/{documents-events-DuT0NGpP.js → documents-events-BgxcR4IL.js} +1 -1
  64. package/dist/public/assets/{file-tree-adapter-QHHr7v_y.js → file-tree-adapter-K79-tTPB.js} +1 -1
  65. package/dist/public/assets/{file-tree-utils-dEjn4DTA.js → file-tree-utils-tuCOKGBG.js} +1 -1
  66. package/dist/public/assets/{folder-config-api-CCs-JTL1.js → folder-config-api-CU0x8rpW.js} +1 -1
  67. package/dist/public/assets/i18n-CW15xoEi.js +1 -0
  68. package/dist/public/assets/{index-D1NhpG7M.js → index-C3NZCyxs.js} +23 -23
  69. package/dist/public/assets/{lint-config-client-sUKnaDfE.js → lint-config-client-CHv46z_2.js} +1 -1
  70. package/dist/public/assets/{markdownlint-rule-browser-DoSn8IJz.js → markdownlint-rule-browser-BnjfZkl5.js} +1 -1
  71. package/dist/public/assets/{messages-BjsESsFx.js → messages-B4vyk0Oe.js} +1 -1
  72. package/dist/public/assets/{messages-CgRQxqOr.js → messages-Bry-igYF.js} +1 -1
  73. package/dist/public/assets/{messages-B8yzAqdX.js → messages-C-vHgGCq.js} +1 -1
  74. package/dist/public/assets/{messages-DKj1XaXP.js → messages-CyOd2E4x.js} +1 -1
  75. package/dist/public/assets/{messages-rvWZA8Dv.js → messages-Czl8K-VD.js} +1 -1
  76. package/dist/public/assets/{messages-su76b0h7.js → messages-D6n-Lvbi.js} +1 -1
  77. package/dist/public/assets/{messages-B_leGMuj.js → messages-DFdt_O5T.js} +1 -1
  78. package/dist/public/assets/{messages-ClYIPasG.js → messages-DXYzwWT9.js} +1 -1
  79. package/dist/public/assets/{messages-rsgDLMpR.js → messages-DYELQ0Z6.js} +1 -1
  80. package/dist/public/assets/{messages-WY-HJ7CG.js → messages-DcU5DDUm.js} +1 -1
  81. package/dist/public/assets/{messages-DoiuiDAc.js → messages-DmlpLtXS.js} +1 -1
  82. package/dist/public/assets/{messages-XTC09BUs.js → messages-HxBLjyRy.js} +1 -1
  83. package/dist/public/assets/{page-list-cache-SxA5m5if.js → page-list-cache-C3X4L8GH.js} +1 -1
  84. package/dist/public/assets/{pending-receive-nav-store-DY4RHmGg.js → pending-receive-nav-store-DVgOZI59.js} +1 -1
  85. package/dist/public/assets/{progress-Bsmo7TE1.js → progress-dpq4llLB.js} +1 -1
  86. package/dist/public/assets/{prop-types-CPMCR1bB.js → prop-types-DtbA0trN.js} +1 -1
  87. package/dist/public/assets/{receive-store-DXkS-6fp.js → receive-store-CN9wympB.js} +1 -1
  88. package/dist/public/assets/{selection-context-Bjtq9RIN.js → selection-context-CrjxZBGv.js} +1 -1
  89. package/dist/public/assets/{skill-scope-CSgNqFEM.js → skill-scope-Dbjtreno.js} +1 -1
  90. package/dist/public/assets/skills-api-CjF1HVT0.js +1 -0
  91. package/dist/public/assets/{src-M-32C9_n.js → src-BlvJjNme.js} +1 -1
  92. package/dist/public/assets/{tag-pill-input-vXWkMHt_.js → tag-pill-input-DiSoMc1e.js} +1 -1
  93. package/dist/public/assets/{target-navigation-intent-B6pF65mo.js → target-navigation-intent-Bti3wCKM.js} +1 -1
  94. package/dist/public/assets/{terminal-cli-display-D8ya3OyM.js → terminal-cli-display-BSCPXe42.js} +1 -1
  95. package/dist/public/assets/{terminal-launch-events-CEw1ZoL3.js → terminal-launch-events-CBiJUoBx.js} +1 -1
  96. package/dist/public/assets/{terminal-telemetry-BkPbxfR9.js → terminal-telemetry-Bq5le7-n.js} +1 -1
  97. package/dist/public/assets/{typing-burst-detector-B2N-OjvB.js → typing-burst-detector-mAlBPt1_.js} +1 -1
  98. package/dist/public/assets/{uninstall-D6ZjikLo.js → uninstall-2B6SvOJQ.js} +1 -1
  99. package/dist/public/assets/{use-activity-panel-DDPT7XZw.js → use-activity-panel-DKoNNsPq.js} +1 -1
  100. package/dist/public/assets/{use-apply-config-color-theme-Chbv5kIz.js → use-apply-config-color-theme-DaKv9alx.js} +1 -1
  101. package/dist/public/assets/{use-collab-url-CLES09HL.js → use-collab-url-bAnITYA-.js} +1 -1
  102. package/dist/public/assets/{use-live-xterm-theme-BeGlZWUx.js → use-live-xterm-theme-DkxNKSl2.js} +1 -1
  103. package/dist/public/assets/use-open-skill-BPCb-4s8.js +1 -0
  104. package/dist/public/assets/{use-settings-route-1RDLdzh1.js → use-settings-route-wdvSSekr.js} +1 -1
  105. package/dist/public/assets/{use-skill-origin-BPSEVtzI.js → use-skill-origin-D-1lraVF.js} +1 -1
  106. package/dist/public/assets/use-skills-D-q84Vic.js +1 -0
  107. package/dist/public/assets/{use-terminal-enabled-FDOP0Dht.js → use-terminal-enabled-CiKWUCqJ.js} +1 -1
  108. package/dist/public/assets/{use-timeline-entry-diff-Bj-dtOq4.js → use-timeline-entry-diff-CpLnYL7S.js} +1 -1
  109. package/dist/public/assets/{use-workspace-BuKQ4WE6.js → use-workspace-ClElU10Z.js} +1 -1
  110. package/dist/public/index.html +46 -46
  111. package/dist/public/uninstall.html +4 -4
  112. package/dist/{repair-launch-json-DKNYsvM3.mjs → repair-launch-json-YHV6PmvL.mjs} +2 -2
  113. package/dist/{repair-mcp-configs-CkxrN_Wr.mjs → repair-mcp-configs-B4DSiyA0.mjs} +2 -2
  114. package/dist/repair-skills-BI9OFTxB.mjs +1 -0
  115. package/dist/{repair-skills-Dye90u_k.mjs → repair-skills-CPlU1WM5.mjs} +2 -2
  116. package/dist/{resolve-project-root-Bc1ADd86.mjs → resolve-project-root-C70nb-25.mjs} +2 -2
  117. package/dist/{server-lock-DmHwX0B4.mjs → server-lock-BGqc8NMa.mjs} +2 -2
  118. package/dist/server-lock-DuwfbnK9.mjs +1 -0
  119. package/dist/{skill-teardown-D6lPMY6n.mjs → skill-teardown-BfYSeXPm.mjs} +2 -2
  120. package/dist/{src-BOzh5nAU.mjs → src-Bh7r8AFJ.mjs} +2 -2
  121. package/dist/src-Ya2LM3Xe.mjs +1 -0
  122. package/dist/{src-CzJVDa-w.mjs → src-aLTXEBdL.mjs} +1 -1
  123. package/dist/{src-B3B2YRvO.mjs → src-fMI-H4kX.mjs} +2 -2
  124. package/dist/src-vY_ilATE.mjs +2038 -0
  125. package/dist/start-CEJear8P.mjs +1 -0
  126. package/dist/{start-CaFctwyb.mjs → start-wwlR3B7J.mjs} +3 -3
  127. package/package.json +4 -4
  128. package/dist/constants-YeJcPjI1.mjs +0 -2
  129. package/dist/git-handle-Bp1KC5ON.mjs +0 -1
  130. package/dist/init-CWbX0ELh.mjs +0 -1
  131. package/dist/loader-CNMujsT-.mjs +0 -1
  132. package/dist/md-manager-YCnEcytX.mjs +0 -2
  133. package/dist/preview-DVXKfAP5.mjs +0 -1
  134. package/dist/public/assets/FeedbackForm-CzfpNEYX.js +0 -1
  135. package/dist/public/assets/ManagedArtifactProperties-DeJMraIa.js +0 -1
  136. package/dist/public/assets/ManagedArtifactProperties-ToX26_H8.js +0 -1
  137. package/dist/public/assets/i18n-CrTwsN89.js +0 -1
  138. package/dist/public/assets/skills-api-Bk-f3oIn.js +0 -1
  139. package/dist/public/assets/use-open-skill-BfEbXDC8.js +0 -1
  140. package/dist/public/assets/use-skills-X0D5g-_u.js +0 -1
  141. package/dist/repair-skills-DnJVC8BQ.mjs +0 -1
  142. package/dist/server-lock-0Z4DgFB6.mjs +0 -1
  143. package/dist/src-AM93pMhZ.mjs +0 -1
  144. package/dist/src-BqTdx7nf.mjs +0 -2030
  145. package/dist/start-CIWCAkyi.mjs +0 -1
package/dist/index.mjs CHANGED
@@ -411,7 +411,7 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content:
411
411
  `);return i.messages.map(e=>Rq(e,o))}function Bq(e){let t=!1;return JE(e,[`link`,`linkReference`],()=>(t=!0,!1)),t}const Vq=Fq(`index-shape`,`**/index`,(e,t)=>{let n=!1;for(let r of e.children){if(r.type===`heading`){n=!0;continue}r.type===`list`&&!n&&t.message(`This index list is not under a section heading, so an Open Knowledge Format consumer reading the file as navigation has no name to file its entries under — an index is one or more heading-led sections of bulleted links.`,r)}JE(e,`listItem`,e=>{e.children.some(e=>e.type===`list`)||Bq(e)||t.message(`This index entry has no link, so an Open Knowledge Format consumer reading the file as navigation has nowhere to follow it. Every entry in the format's own reference bundles is a link followed by a short description.`,e)})}),Hq=/^\s*(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])(?!\d)/;function Uq(e,t,n){let r=new Date(Date.UTC(e,t-1,n));return r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n}const Wq=/^\s*\d{4}[-/.]\d{1,2}[-/.]\d{1,2}/;function Gq(e){let t=e.trim();return t.length>60?`${t.slice(0,59)}…`:t}const Kq=Fq(`log-shape`,`**/log`,(e,t)=>{let n;JE(e,`heading`,e=>{if(e.depth!==2)return;let r=YE(e),i=Hq.exec(r);if(!i){t.message(Wq.test(r)?`Log date heading "${Gq(r)}" is not in ISO 8601 YYYY-MM-DD form, the one form an Open Knowledge Format log requires of its date headings.`:`Log entry heading "${Gq(r)}" is not a date, so it falls outside the dated-entry format an Open Knowledge Format consumer reads a log as — nothing under it reaches the change-history timeline.`,e);return}let a=`${i[1]}-${i[2]}-${i[3]}`;if(!Uq(Number(i[1]),Number(i[2]),Number(i[3]))){t.message(`Log date heading "${a}" is not a real calendar date, so it is not ISO 8601 — the one form an Open Knowledge Format log requires of its date headings.`,e);return}n!==void 0&&a>n&&t.message(`Log date heading "${a}" is newer than the entry above it — an Open Knowledge Format log is a flat list of date-grouped entries, newest first.`,e),n=a})}),qq=/\[\[[^[\]\n]+\]\]/g;function Jq(e){let t=`Wiki-link ${e} won't resolve for an external Open Knowledge Format consumer — it renders as literal text and its graph edge is lost.`;return e.includes(`|`)?`${t} The alias "|" also splits a GFM table cell.`:t}const Yq=Pq(`no-wiki-links`,(e,t)=>{let n=typeof t.value==`string`?t.value:String(t.value);JE(e,`text`,e=>{let r=e.position?.start,i=e.position?.end,a=r?.offset,o=a===void 0||i?.offset===void 0?e.value:n.slice(a,i.offset),s=0,c=r?.line??0,l=r?.column??0,u=e=>{for(;s<e;s+=1)o[s]===`
412
412
  `?(c+=1,l=1):l+=1;return{line:c,column:l}};for(let e of o.matchAll(qq)){let{index:i}=e;if((a===void 0?o[i-1]:n[a+i-1])===`!`)continue;let s=r&&a!==void 0?{start:u(i),end:u(i+e[0].length)}:void 0;t.message(Jq(e[0]),s)}})}),Xq=[`index`,`log`];function Zq(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);if(n<=0)return t;let r=t.slice(n).toLowerCase();return Nl.includes(r)?t.slice(0,n):t}const Qq=Pq(`reserved-casing`,(e,t)=>{let n=t.data.okfDocName;if(n===void 0)return;let r=Zq(n),i=r.toLowerCase();Xq.includes(i)&&r!==i&&t.message(`This file is named "${r}", but the Open Knowledge Format only recognizes "${i}". On a case-sensitive filesystem a consumer reads it as an ordinary concept document rather than the reserved file it is meant to be.`)}),$q=[{id:`no-wiki-links`,rule:Yq},{id:`log-shape`,rule:Kq},{id:`index-shape`,rule:Vq},{id:`reserved-casing`,rule:Qq}],eJ=$q.map(e=>e.rule);function tJ(e){return e===void 0?eJ:$q.filter(t=>_q(e,t.id)).map(e=>e.rule)}const nJ=uo([L(),H(pre),V(F(),R())]),rJ={id:`markdownlint`,sliceSchema:B({enabled:L(),rules:V(F(),nJ)}),defaultSlice:{enabled:!1,rules:WB},async lint(e,t){return dq(e,GB(t.rules))},fix(e,t){return uq(e,GB(t.rules))}},iJ=B({appliesTo:uo([F(),z(F())]).optional(),file:F(),enabled:L().optional(),key:F().optional(),schema:V(F(),R()).optional()}),aJ=[rJ,{id:`frontmatter`,sliceSchema:B({enabled:L(),schemas:z(iJ)}),defaultSlice:{enabled:!1,schemas:[]},async lint(e,t,n){return gU(e,eU(t.schemas,n.docName))},frontmatter:{schemasForDoc:(e,t)=>eU(e.schemas,t),narrowSliceToFrontmatter:e=>e,advertisedMappings:e=>e.schemas}},{id:`okf`,sliceSchema:B({enabled:L(),rules:V(F(),L()).optional(),generate:B({index:L().optional()}).optional()}),defaultSlice:{enabled:!1},async lint(e,t,n){return[...zq(e,tJ(t.rules),n.docName),...jq(e,t.rules,n.docName)]},frontmatter:{schemasForDoc:(e,t)=>kq(e.rules,t),narrowSliceToFrontmatter:e=>({...e,rules:{...e.rules,...Oq}}),advertisedMappings:e=>Aq(e.rules)}}];Object.fromEntries(aJ.map(e=>[e.id,e.defaultSlice]));const oJ=[`text`,`number`,`boolean`,`date`,`list`,`object`];H(oJ);const sJ=uo([F(),I(),L()]),cJ=Co(()=>uo([sJ.transform(e=>String(e)),V(F(),lJ),z(cJ)])),lJ=Co(()=>uo([F(),I(),L(),z(cJ),V(F(),lJ)]));function uJ(e){if(Array.isArray(e)){let t=[];for(let n of e)n!==null&&t.push(uJ(n));return t}if(typeof e==`object`&&e){let t={};for(let[n,r]of Object.entries(e))t[n]=r===null?``:uJ(r);return t}return e}Eo(uJ,V(F(),lJ)),V(F(),uo([lJ,oo()])),B({docName:nw,summary:iw,content:F().optional(),...rw}).loose(),B({docName:nw,summary:iw,markdown:F(),position:H([`append`,`prepend`,`replace`]).optional(),extension:H(Nl).optional(),...rw}).loose(),B({docName:nw,summary:iw,find:F().min(1),replace:F(),offset:I().int().nonnegative().optional(),...rw}).loose(),B({docName:nw,connectionId:F().min(1),scope:H([`last`,`session`,`file`,`count`]).optional(),count:I().int().positive().optional(),...rw}).loose().refine(e=>e.scope!==`count`||e.count!==void 0,{message:`count is required when scope is 'count'`,path:[`count`]});const dJ=B({value:F(),truncatedFrom:I().int().nonnegative().optional(),hint:F().optional()}).loose(),fJ=fo(`kind`,[B({kind:U(`inline`),content:F()}),B({kind:U(`truncated`),byteLength:I().int().nonnegative(),hint:F()})]),pJ=B({kind:U(`content-divergence`),intendedBytes:I().int().nonnegative(),actualBytes:I().int().nonnegative(),byteDelta:I().int(),divergenceType:F().optional(),currentState:fJ.optional(),hint:F().optional()}).loose(),mJ=B({type:U(`orphan`),parentCandidates:z(F()),message:F()}).loose(),hJ=B({kind:U(`disk-edit-reconciled`),intendedBytes:I().int().nonnegative(),actualBytes:I().int().nonnegative(),byteDelta:I().int(),mergeOutcome:F().optional(),hint:F().optional()}).loose(),gJ=fo(`kind`,[pJ,hJ]),_J=B({kind:U(`mermaid-parse-error`),fenceIndex:I().int().positive(),fenceFirstLine:F(),message:F(),line:I().int().positive().optional()}).loose(),vJ=B({href:F(),targetKind:F(),role:F(),sourceForm:F(),resolvedTarget:F().nullable(),reason:F(),resolutionMethod:F(),fallbackTarget:F().nullable().optional(),definition:B({line:I().int().nonnegative(),label:F()}).loose().optional()}).loose(),yJ=fo(`kind`,[pJ,hJ,_J,B({kind:U(`lint-violation`),source:F(),code:F(),message:F(),severity:H([`error`,`warning`,`info`,`hint`]),line:I().int().positive(),column:I().int().positive(),linkTarget:F().optional(),localTarget:vJ.optional()}).loose()]),bJ=z(yJ).min(1),xJ=B({href:F(),resolvedTo:F().nullable(),reason:H([`no-such-doc`,`no-such-file`,`unresolvable`]),localTarget:vJ.optional()}).loose(),SJ=z(xJ);B({timestamp:F().min(1),summary:dJ.optional(),warning:gJ.optional(),warnings:bJ.optional()}).loose(),B({timestamp:F().min(1),subscriberCount:I().int().nonnegative(),systemSubscriberCount:I().int().nonnegative(),hints:z(mJ).optional(),summary:dJ.optional(),warning:gJ.optional(),warnings:bJ.optional(),brokenLinks:SJ}).loose(),B({timestamp:F().min(1),subscriberCount:I().int().nonnegative(),systemSubscriberCount:I().int().nonnegative(),summary:dJ.optional(),warning:gJ.optional(),warnings:bJ.optional(),brokenLinks:SJ}).loose(),B({docName:F().min(1),scope:H([`last`,`session`,`count`]),undone:L()}).loose(),B({docs:z(B({docName:pse,markdown:F(),position:H([`append`,`prepend`,`replace`]).optional(),extension:H(Nl).optional(),summary:iw}).loose()).min(1).max(100),...rw}).loose();const CJ=B({type:dw,title:F(),detail:F().optional()}).loose(),wJ=fo(`status`,[B({status:U(`written`),docName:F().min(1),summary:dJ.optional(),warnings:bJ.optional(),brokenLinks:SJ}).loose(),B({status:U(`error`),docName:F().min(1),error:CJ}).loose()]);B({timestamp:F().min(1),results:z(wJ),written:I().int().nonnegative(),failed:I().int().nonnegative()}).loose(),B({docName:nw,patch:V(F(),uo([lJ,oo()])),types:V(F(),H(oJ)).optional(),summary:iw,...rw}).loose(),B({timestamp:F().min(1),subscriberCount:I().int().nonnegative(),systemSubscriberCount:I().int().nonnegative(),appliedKeys:z(F()),summary:dJ.optional(),warning:gJ.optional(),warnings:bJ.optional(),brokenLinks:SJ}).loose();const TJ=Object.fromEntries(aJ.map(e=>[e.id,e.sliceSchema]));B({effective:B({enabled:L(),plugins:B(TJ)}),configFile:F().nullable().optional(),configProblems:z(F()).optional()});const EJ=uo([L(),V(F(),R())]);B({ruleId:F().min(1).max(64).regex(/^[A-Za-z][A-Za-z0-9_-]*$/),value:uo([EJ,oo()])}),B({file:F().min(1).max(512),delete:U(!0).optional(),field:F().min(1).max(256).optional(),parentPath:z(uo([F().min(1).max(256),B({items:U(!0)}).strict()])).max(8).optional(),removeField:U(!0).optional(),renameTo:F().min(1).max(256).optional(),constraint:B({type:H([`string`,`number`,`boolean`,`array`,`object`]).nullable().optional(),enum:z(uo([F(),I(),L()])).nullable().optional(),itemsEnum:z(uo([F(),I(),L()])).nullable().optional(),itemsType:H([`string`,`number`,`boolean`,`object`]).nullable().optional(),pattern:F().nullable().optional(),format:F().nullable().optional(),description:F().max(2048).nullable().optional(),required:L().optional()}).optional()}).refine(e=>e.delete===void 0||e.field===void 0&&e.constraint===void 0&&e.removeField===void 0&&e.renameTo===void 0,{message:`delete cannot be combined with a field edit`}).refine(e=>[e.constraint,e.removeField,e.renameTo].filter(e=>e!==void 0).length<=1,{message:`constraint, removeField, and renameTo are mutually exclusive`}).refine(e=>e.removeField===void 0&&e.renameTo===void 0||e.field!==void 0,{message:`removeField and renameTo require field`}).refine(e=>e.parentPath===void 0||e.field!==void 0,{message:`parentPath requires field`}).refine(e=>e.field===void 0?e.constraint===void 0:e.constraint!==void 0||e.removeField!==void 0||e.renameTo!==void 0,{message:`field requires constraint, removeField, or renameTo`}),B({schemas:z(F()),truncated:L()}).strict();const DJ=B({line:I(),character:I()}),OJ=B({start:DJ,end:DJ}),kJ=B({range:OJ,severity:H([`error`,`warning`,`info`,`hint`]),source:F(),code:F(),message:F(),fixes:z(B({range:OJ,newText:F()})).optional(),frontmatterScope:H(dre).optional(),frontmatterProperty:F().optional()});B({files:z(B({file:F(),diagnostics:z(kJ),warnings:z(F()).optional()})),fileCount:I(),errorCount:I(),warningCount:I(),warnings:z(F())});const AJ=kJ.extend({linkTarget:F().optional(),localTarget:vJ.optional()});B({files:z(B({file:F(),diagnostics:z(AJ)})),fileCount:I(),errorCount:I(),warningCount:I(),warnings:z(F())});const jJ=B({errorCount:I().int().nonnegative(),warningCount:I().int().nonnegative()});B({files:z(B({file:F(),lint:jJ,links:jJ})),fileCount:I().int().nonnegative(),errorCount:I().int().nonnegative(),warningCount:I().int().nonnegative(),warnings:z(F())}),B({docName:nw,summary:iw,...rw}).loose(),B({file:F(),fixedCount:I(),diagnostics:z(kJ),errorCount:I(),warningCount:I(),warning:F().optional()});const MJ=[{id:`MD001`,alias:`heading-increment`,aliases:[`heading-increment`],name:`Heading levels should only increment by one level at a time`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md001.md`,tags:[`headings`],options:[{key:`front_matter_title`,type:`string`,description:`RegExp for matching title in front matter`,default:`^\\s*title\\s*[:=]`}]},{id:`MD003`,alias:`heading-style`,aliases:[`heading-style`],name:`Heading style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md003.md`,tags:[`headings`],options:[{key:`style`,type:`enum`,description:`Heading style`,enum:[`consistent`,`atx`,`atx_closed`,`setext`,`setext_with_atx`,`setext_with_atx_closed`],default:`consistent`}]},{id:`MD004`,alias:`ul-style`,aliases:[`ul-style`],name:`Unordered list style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md004.md`,tags:[`bullet`,`ul`],options:[{key:`style`,type:`enum`,description:`List style`,enum:[`consistent`,`asterisk`,`plus`,`dash`,`sublist`],default:`consistent`}]},{id:`MD005`,alias:`list-indent`,aliases:[`list-indent`],name:`Inconsistent indentation for list items at the same level`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md005.md`,tags:[`bullet`,`ul`,`indentation`],options:[]},{id:`MD007`,alias:`ul-indent`,aliases:[`ul-indent`],name:`Unordered list indentation`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md007.md`,tags:[`bullet`,`ul`,`indentation`],options:[{key:`indent`,type:`integer`,description:`Spaces for indent`,default:2,minimum:1},{key:`start_indented`,type:`boolean`,description:`Whether to indent the first level of the list`,default:!1},{key:`start_indent`,type:`integer`,description:`Spaces for first level indent (when start_indented is set)`,default:2,minimum:1}]},{id:`MD009`,alias:`no-trailing-spaces`,aliases:[`no-trailing-spaces`],name:`Trailing spaces`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md009.md`,tags:[`whitespace`],options:[{key:`br_spaces`,type:`integer`,description:`Spaces for line break`,default:2,minimum:0},{key:`code_blocks`,type:`boolean`,description:`Include code blocks`,default:!1},{key:`list_item_empty_lines`,type:`boolean`,description:`Allow spaces for empty lines in list items`,default:!1},{key:`strict`,type:`boolean`,description:`Include unnecessary breaks`,default:!1}]},{id:`MD010`,alias:`no-hard-tabs`,aliases:[`no-hard-tabs`],name:`Hard tabs`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md010.md`,tags:[`whitespace`,`hard_tab`],options:[{key:`code_blocks`,type:`boolean`,description:`Include code blocks`,default:!0},{key:`ignore_code_languages`,type:`string-array`,description:`Fenced code languages to ignore`,default:[]},{key:`spaces_per_tab`,type:`integer`,description:`Number of spaces for each hard tab`,default:1,minimum:0}]},{id:`MD011`,alias:`no-reversed-links`,aliases:[`no-reversed-links`],name:`Reversed link syntax`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md011.md`,tags:[`links`],options:[]},{id:`MD012`,alias:`no-multiple-blanks`,aliases:[`no-multiple-blanks`],name:`Multiple consecutive blank lines`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md012.md`,tags:[`whitespace`,`blank_lines`],options:[{key:`maximum`,type:`integer`,description:`Consecutive blank lines`,default:1,minimum:1}]},{id:`MD013`,alias:`line-length`,aliases:[`line-length`],name:`Line length`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md013.md`,tags:[`line_length`],options:[{key:`line_length`,type:`integer`,description:`Number of characters`,default:80,minimum:1},{key:`heading_line_length`,type:`integer`,description:`Number of characters for headings`,default:80,minimum:1},{key:`code_block_line_length`,type:`integer`,description:`Number of characters for code blocks`,default:80,minimum:1},{key:`code_blocks`,type:`boolean`,description:`Include code blocks`,default:!0},{key:`tables`,type:`boolean`,description:`Include tables`,default:!0},{key:`headings`,type:`boolean`,description:`Include headings`,default:!0},{key:`strict`,type:`boolean`,description:`Strict length checking`,default:!1},{key:`stern`,type:`boolean`,description:`Stern length checking`,default:!1}]},{id:`MD014`,alias:`commands-show-output`,aliases:[`commands-show-output`],name:`Dollar signs used before commands without showing output`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md014.md`,tags:[`code`],options:[]},{id:`MD018`,alias:`no-missing-space-atx`,aliases:[`no-missing-space-atx`],name:`No space after hash on atx style heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md018.md`,tags:[`headings`,`atx`,`spaces`],options:[]},{id:`MD019`,alias:`no-multiple-space-atx`,aliases:[`no-multiple-space-atx`],name:`Multiple spaces after hash on atx style heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md019.md`,tags:[`headings`,`atx`,`spaces`],options:[]},{id:`MD020`,alias:`no-missing-space-closed-atx`,aliases:[`no-missing-space-closed-atx`],name:`No space inside hashes on closed atx style heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md020.md`,tags:[`headings`,`spaces`,`atx_closed`],options:[]},{id:`MD021`,alias:`no-multiple-space-closed-atx`,aliases:[`no-multiple-space-closed-atx`],name:`Multiple spaces inside hashes on closed atx style heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md021.md`,tags:[`headings`,`spaces`,`atx_closed`],options:[]},{id:`MD022`,alias:`blanks-around-headings`,aliases:[`blanks-around-headings`],name:`Headings should be surrounded by blank lines`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md022.md`,tags:[`headings`,`blank_lines`],options:[{key:`include_front_matter`,type:`boolean`,description:`Include front matter content`,default:!1},{key:`lines_above`,type:`unsupported`,description:`Blank lines above heading`,default:1},{key:`lines_below`,type:`unsupported`,description:`Blank lines below heading`,default:1}]},{id:`MD023`,alias:`heading-start-left`,aliases:[`heading-start-left`],name:`Headings must start at the beginning of the line`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md023.md`,tags:[`headings`,`spaces`],options:[]},{id:`MD024`,alias:`no-duplicate-heading`,aliases:[`no-duplicate-heading`],name:`Multiple headings with the same content`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md024.md`,tags:[`headings`],options:[{key:`siblings_only`,type:`boolean`,description:`Only check sibling headings`,default:!1}]},{id:`MD025`,alias:`single-title`,aliases:[`single-title`,`single-h1`],name:`Multiple top-level headings in the same document`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md025.md`,tags:[`headings`],options:[{key:`front_matter_title`,type:`string`,description:`RegExp for matching title in front matter`,default:`^\\s*title\\s*[:=]`},{key:`level`,type:`integer`,description:`Heading level`,default:1,minimum:1,maximum:6}]},{id:`MD026`,alias:`no-trailing-punctuation`,aliases:[`no-trailing-punctuation`],name:`Trailing punctuation in heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md026.md`,tags:[`headings`],options:[{key:`punctuation`,type:`string`,description:`Punctuation characters`,default:`.,;:!。,;:!`}]},{id:`MD027`,alias:`no-multiple-space-blockquote`,aliases:[`no-multiple-space-blockquote`],name:`Multiple spaces after blockquote symbol`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md027.md`,tags:[`indentation`,`whitespace`,`blockquote`],options:[{key:`list_items`,type:`boolean`,description:`Include list items`,default:!0}]},{id:`MD028`,alias:`no-blanks-blockquote`,aliases:[`no-blanks-blockquote`],name:`Blank line inside blockquote`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md028.md`,tags:[`whitespace`,`blockquote`],options:[]},{id:`MD029`,alias:`ol-prefix`,aliases:[`ol-prefix`],name:`Ordered list item prefix`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md029.md`,tags:[`ol`],options:[{key:`style`,type:`enum`,description:`List style`,enum:[`one`,`ordered`,`one_or_ordered`,`zero`],default:`one_or_ordered`}]},{id:`MD030`,alias:`list-marker-space`,aliases:[`list-marker-space`],name:`Spaces after list markers`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md030.md`,tags:[`ul`,`whitespace`,`ol`],options:[{key:`ul_single`,type:`integer`,description:`Spaces for single-line unordered list items`,default:1,minimum:1},{key:`ol_single`,type:`integer`,description:`Spaces for single-line ordered list items`,default:1,minimum:1},{key:`ul_multi`,type:`integer`,description:`Spaces for multi-line unordered list items`,default:1,minimum:1},{key:`ol_multi`,type:`integer`,description:`Spaces for multi-line ordered list items`,default:1,minimum:1}]},{id:`MD031`,alias:`blanks-around-fences`,aliases:[`blanks-around-fences`],name:`Fenced code blocks should be surrounded by blank lines`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md031.md`,tags:[`blank_lines`,`code`],options:[{key:`list_items`,type:`boolean`,description:`Include list items`,default:!0}]},{id:`MD032`,alias:`blanks-around-lists`,aliases:[`blanks-around-lists`],name:`Lists should be surrounded by blank lines`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md032.md`,tags:[`bullet`,`ul`,`blank_lines`,`ol`],options:[]},{id:`MD033`,alias:`no-inline-html`,aliases:[`no-inline-html`],name:`Inline HTML`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md033.md`,tags:[`html`],options:[{key:`allowed_elements`,type:`string-array`,description:`Allowed elements`,default:[]},{key:`table_allowed_elements`,type:`string-array`,description:`Allowed elements in tables`,default:[]}]},{id:`MD034`,alias:`no-bare-urls`,aliases:[`no-bare-urls`],name:`Bare URL used`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md034.md`,tags:[`links`,`url`],options:[]},{id:`MD035`,alias:`hr-style`,aliases:[`hr-style`],name:`Horizontal rule style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md035.md`,tags:[`hr`],options:[{key:`style`,type:`string`,description:`Horizontal rule style`,default:`consistent`}]},{id:`MD036`,alias:`no-emphasis-as-heading`,aliases:[`no-emphasis-as-heading`],name:`Emphasis used instead of a heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md036.md`,tags:[`headings`,`emphasis`],options:[{key:`punctuation`,type:`string`,description:`Punctuation characters`,default:`.,;:!?。,;:!?`}]},{id:`MD037`,alias:`no-space-in-emphasis`,aliases:[`no-space-in-emphasis`],name:`Spaces inside emphasis markers`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md037.md`,tags:[`whitespace`,`emphasis`],options:[]},{id:`MD038`,alias:`no-space-in-code`,aliases:[`no-space-in-code`],name:`Spaces inside code span elements`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md038.md`,tags:[`whitespace`,`code`],options:[]},{id:`MD039`,alias:`no-space-in-links`,aliases:[`no-space-in-links`],name:`Spaces inside link text`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md039.md`,tags:[`whitespace`,`links`],options:[]},{id:`MD040`,alias:`fenced-code-language`,aliases:[`fenced-code-language`],name:`Fenced code blocks should have a language specified`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md040.md`,tags:[`code`,`language`],options:[{key:`allowed_languages`,type:`string-array`,description:`List of languages`,default:[]},{key:`language_only`,type:`boolean`,description:`Require language only`,default:!1}]},{id:`MD041`,alias:`first-line-heading`,aliases:[`first-line-heading`,`first-line-h1`],name:`First line in a file should be a top-level heading`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md041.md`,tags:[`headings`],options:[{key:`allow_preamble`,type:`boolean`,description:`Allow content before first heading`,default:!1},{key:`front_matter_title`,type:`string`,description:`RegExp for matching title in front matter`,default:`^\\s*title\\s*[:=]`},{key:`level`,type:`integer`,description:`Heading level`,default:1,minimum:1,maximum:6}]},{id:`MD042`,alias:`no-empty-links`,aliases:[`no-empty-links`],name:`No empty links`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md042.md`,tags:[`links`],options:[]},{id:`MD043`,alias:`required-headings`,aliases:[`required-headings`],name:`Required heading structure`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md043.md`,tags:[`headings`],options:[{key:`headings`,type:`string-array`,description:`List of headings`,default:[]},{key:`match_case`,type:`boolean`,description:`Match case of headings`,default:!1}]},{id:`MD044`,alias:`proper-names`,aliases:[`proper-names`],name:`Proper names should have the correct capitalization`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md044.md`,tags:[`spelling`],options:[{key:`names`,type:`string-array`,description:`List of proper names`,default:[]},{key:`code_blocks`,type:`boolean`,description:`Include code blocks`,default:!0},{key:`html_elements`,type:`boolean`,description:`Include HTML elements`,default:!0}]},{id:`MD045`,alias:`no-alt-text`,aliases:[`no-alt-text`],name:`Images should have alternate text (alt text)`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md045.md`,tags:[`accessibility`,`images`],options:[]},{id:`MD046`,alias:`code-block-style`,aliases:[`code-block-style`],name:`Code block style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md046.md`,tags:[`code`],options:[{key:`style`,type:`enum`,description:`Block style`,enum:[`consistent`,`fenced`,`indented`],default:`consistent`}]},{id:`MD047`,alias:`single-trailing-newline`,aliases:[`single-trailing-newline`],name:`Files should end with a single newline character`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md047.md`,tags:[`blank_lines`],options:[]},{id:`MD048`,alias:`code-fence-style`,aliases:[`code-fence-style`],name:`Code fence style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md048.md`,tags:[`code`],options:[{key:`style`,type:`enum`,description:`Code fence style`,enum:[`consistent`,`backtick`,`tilde`],default:`consistent`}]},{id:`MD049`,alias:`emphasis-style`,aliases:[`emphasis-style`],name:`Emphasis style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md049.md`,tags:[`emphasis`],options:[{key:`style`,type:`enum`,description:`Emphasis style`,enum:[`consistent`,`asterisk`,`underscore`],default:`consistent`}]},{id:`MD050`,alias:`strong-style`,aliases:[`strong-style`],name:`Strong style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md050.md`,tags:[`emphasis`],options:[{key:`style`,type:`enum`,description:`Strong style`,enum:[`consistent`,`asterisk`,`underscore`],default:`consistent`}]},{id:`MD051`,alias:`link-fragments`,aliases:[`link-fragments`],name:`Link fragments should be valid`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md051.md`,tags:[`links`],options:[{key:`ignore_case`,type:`boolean`,description:`Ignore case of fragments`,default:!1},{key:`ignored_pattern`,type:`string`,description:`Pattern for ignoring additional fragments`,default:``}]},{id:`MD052`,alias:`reference-links-images`,aliases:[`reference-links-images`],name:`Reference links and images should use a label that is defined`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md052.md`,tags:[`links`,`images`],options:[{key:`ignored_labels`,type:`string-array`,description:`Ignored link labels`,default:[`x`]},{key:`shortcut_syntax`,type:`boolean`,description:`Include shortcut syntax`,default:!1}]},{id:`MD053`,alias:`link-image-reference-definitions`,aliases:[`link-image-reference-definitions`],name:`Link and image reference definitions should be needed`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md053.md`,tags:[`links`,`images`],options:[{key:`ignored_definitions`,type:`string-array`,description:`Ignored definitions`,default:[`//`]}]},{id:`MD054`,alias:`link-image-style`,aliases:[`link-image-style`],name:`Link and image style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md054.md`,tags:[`links`,`images`],options:[{key:`autolink`,type:`boolean`,description:`Allow autolinks`,default:!0},{key:`inline`,type:`boolean`,description:`Allow inline links and images`,default:!0},{key:`full`,type:`boolean`,description:`Allow full reference links and images`,default:!0},{key:`collapsed`,type:`boolean`,description:`Allow collapsed reference links and images`,default:!0},{key:`shortcut`,type:`boolean`,description:`Allow shortcut reference links and images`,default:!0},{key:`url_inline`,type:`boolean`,description:`Allow URLs as inline links`,default:!0}]},{id:`MD055`,alias:`table-pipe-style`,aliases:[`table-pipe-style`],name:`Table pipe style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md055.md`,tags:[`table`],options:[{key:`style`,type:`enum`,description:`Table pipe style`,enum:[`consistent`,`leading_only`,`trailing_only`,`leading_and_trailing`,`no_leading_or_trailing`],default:`consistent`}]},{id:`MD056`,alias:`table-column-count`,aliases:[`table-column-count`],name:`Table column count`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md056.md`,tags:[`table`],options:[]},{id:`MD058`,alias:`blanks-around-tables`,aliases:[`blanks-around-tables`],name:`Tables should be surrounded by blank lines`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md058.md`,tags:[`table`],options:[]},{id:`MD059`,alias:`descriptive-link-text`,aliases:[`descriptive-link-text`],name:`Link text should be descriptive`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md059.md`,tags:[`links`,`accessibility`],options:[{key:`prohibited_texts`,type:`string-array`,description:`Prohibited link texts`,default:[`click here`,`here`,`link`,`more`]}]},{id:`MD060`,alias:`table-column-style`,aliases:[`table-column-style`],name:`Table column style`,docUrl:`https://github.com/DavidAnson/markdownlint/blob/v0.41.1/doc/md060.md`,tags:[`table`],options:[{key:`style`,type:`enum`,description:`Table column style`,enum:[`any`,`aligned`,`compact`,`tight`],default:`any`},{key:`aligned_delimiter`,type:`boolean`,description:`Aligned delimiter columns`,default:!1}]}];(()=>{let e=new Map;for(let t of MJ){e.set(t.id.toUpperCase(),t.id);for(let n of t.aliases)e.set(n.toUpperCase(),t.id)}return e})();const NJ=new Set([`img`,`video`,`audio`,`mark`,`u`,`ins`]);new Map(MM.flatMap(e=>e.surface===`compat`&&NJ.has(e.rendersAs)?[[e.name,e]]:[])),Hfe(`<>`),QR(),gR(),_R();function PJ(){return MM.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function FJ(){return PJ().filter(e=>{let t=IJ(e);return t!==`fence`&&t!==`html`})}function IJ(e){return e.name===`MermaidFence`?`fence`:e.name===`HtmlAlignBlock`?`html`:e.hasChildren?`jsx-block`:`jsx-void`}function LJ(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:IJ(e)}}function RJ(){return[``,"**Custom canonical components.** OK `.md` / `.mdx` supports the JSX components below. For source syntax + parameter schemas, call `palette({ components: [ids] })`. Arbitrary `<TagName>` JSX falls through as raw MDX when no canonical fits.",``,...FJ().map(LJ).map(e=>`- \`${e.id}\` (${e.kind}) — ${e.description}`)].join(`
413
413
  `)}function zJ(){return[RJ(),``,"Fenced code blocks render naturally and don't need a fetch — including ` ```mermaid ` for diagrams (mermaid label text has sharp edges — `palette({ components: [\"Mermaid\"] })` lists them; parse failures come back as `warnings` entries on write/edit) and ` ```html preview ` for interactive HTML/JS/CSS pages (the fence info-string `preview` token renders the block as a live iframe; works for `html` / `htm` / `xml`; optional `h=` / `w=` tokens set size, e.g. ` ```html preview h=400px `). Use ` ```html preview ` whenever you want anything interactive or JS-powered (charts, demos, calculators, animations) — just author the standalone HTML page in the fence. Call `palette` for the markdown-native component forms (write `> [!NOTE]`, not `<Callout>`), copy-ready themed `html preview` starters, and the theme tokens (`var(--chart-1)`, `var(--foreground)`, …) an embed should reference so it tracks the reader's light/dark theme."].join(`
414
- `)}B({entries:z(B({level:H([`info`,`warn`,`error`]),message:F().max(8192),event:F().optional(),fields:V(F(),R()).optional(),ts:I().optional(),sourceId:F().optional(),lineNumber:I().optional()}).loose()).max(100),droppedSinceLastFlush:I().int().min(0).optional()}).loose(),B({accepted:I().int().min(0)}).loose();const BJ=B({exact:F().min(1),prefix:F(),suffix:F(),start:I().int().nonnegative(),end:I().int().nonnegative()}),VJ=z(uo([F(),I().int().nonnegative()])),HJ=fo(`kind`,[B({kind:U(`body`)}),B({kind:U(`property`),key:F().min(1),path:VJ.default([])})]).default({kind:`body`}),UJ=H([`anchored`,`orphaned`,`resolved`]),WJ=B({threadId:F().min(1),docName:F().min(1),target:HJ,anchor:BJ.nullable(),state:UJ,queued:L(),latestComment:F(),createdBy:F().min(1),createdAt:I(),updatedAt:I().optional()}),GJ=B({docName:F(),instruction:F(),property:F().nullable(),passage:B({exact:F(),prefix:F(),suffix:F()}).nullable(),anchorLost:L(),passageRepeats:L()}).loose(),KJ=B({threadId:F(),ok:U(!0)}),qJ=B({threadId:F(),ok:U(!1),error:U(`not-found`)});B({threads:z(WJ)}).loose(),B({meta:WJ,orphaned:L()}).loose(),B({threadId:F()}).loose(),B({meta:WJ,payload:GJ}).loose(),B({results:z(uo([KJ.extend({meta:WJ,payload:GJ}),qJ]))}).loose(),B({results:z(uo([KJ.extend({meta:WJ}),qJ]))}).loose();const JJ=B({status:F().min(1),reason:F()}).loose();B({docName:F().min(1),content:F(),lifecycle:JJ.nullable()}).loose(),B({documents:z(B({kind:H([`document`,`asset`,`folder`,`file`]).default(`document`),docName:F().min(1).optional(),docExt:F().min(1).default(`.md`),size:I().int().nonnegative(),modified:F().min(1),isSymlink:L().default(!1),canonicalDocName:F().nullable().default(null),targetPath:F().nullable().default(null),path:F().min(1).optional(),assetExt:F().min(1).optional(),mediaKind:H([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`,`excalidraw`]).nullable().optional(),referencedBy:z(F().min(1)).optional(),hasChildren:L().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.kind===`file`?e.path!==void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder/file kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName; file → path, no mediaKind/referencedBy/hasChildren)`})),truncated:L().optional()}).loose();const YJ=B({source:F().min(1),anchor:F().nullable(),title:F(),snippet:F().nullable()}).loose();B({docName:F().min(1),backlinks:z(YJ)}).loose(),B({counts:V(F().min(1),I().int().nonnegative())}).loose(),B({counts:V(F().min(1),I().int().nonnegative())}).loose();const XJ=fo(`kind`,[B({kind:U(`doc`),docName:F().min(1),anchor:F().nullable(),title:F(),snippet:F().nullable()}).loose(),B({kind:U(`external`),url:F().min(1),title:F(),snippet:F().nullable()}).loose()]),ZJ=B({role:F().min(1),sourceForm:F().min(1),targetKind:F().min(1),href:F(),resolvedTarget:F().nullable(),status:F().min(1),reason:F().nullable(),resolutionMethod:F().min(1),fallbackTarget:F().nullable().default(null),range:B({start:I().int().nonnegative(),end:I().int().nonnegative()}),line:I().int().nonnegative(),column:I().int().nonnegative(),definition:B({label:F(),line:I().int().nonnegative()}).nullable().default(null)}).loose();B({docName:F().min(1),forwardLinks:z(XJ),localTargets:z(ZJ).optional()}).loose();const QJ=fo(`kind`,[B({id:F().min(1),kind:U(`doc`),docName:F().min(1),anchor:F().nullable(),label:F(),cluster:F().nullable(),category:F().nullable(),tags:z(F()).nullable(),managed:L().optional()}).loose(),B({id:F().min(1),kind:U(`external`),url:F().min(1),label:F()}).loose()]),$J=B({source:F().min(1),target:F().min(1)}).loose();B({nodes:z(QJ),links:z($J)}).loose();const eY=B({ts:I().int().min(0),url:F(),method:F(),ua:F().optional(),origin:F().optional(),referer:F().optional(),host:F().optional(),remote:F().optional(),secChUa:F().optional(),secChUaMobile:F().optional(),secChUaPlatform:F().optional(),secFetchSite:F().optional(),secFetchDest:F().optional(),secFetchMode:F().optional(),secFetchUser:F().optional()}).loose(),tY=B({app:uo([U(`cursor`),U(`codex`),U(`claude`),oo()]),signals_fired:z(F())}).loose();B({entries:z(eY),count:I().int().min(0),detection:tY}).loose(),B({writers:z(B({id:F().min(1),name:F().optional(),email:F().optional()}).loose()).optional(),summary:iw,...rw}).loose(),B({checkpointRef:F().min(1)}).loose();const nY=B({v:I().int().optional(),id:F().min(1),name:F().min(1),colorSeed:F().optional(),docs:z(F()),summaries:z(F()).optional()}).loose();B({entries:z(B({sha:F().min(1),timestamp:F().min(1),author:F(),authorEmail:F(),type:H([`checkpoint`,`wip`,`upstream`,`park`]),message:F(),contributors:z(nY),checkpoint:R().nullable(),parentSha:F().nullable().optional()}).loose()),total:I().int().nonnegative().optional(),truncated:L().optional(),hasMore:L().optional()}).loose(),B({sha:F().regex(/^[0-9a-f]{40}$/i),content:F(),timestamp:F(),author:F()}).loose(),B({contentDir:F().min(1),pathSeparator:H([`/`,`\\`]),symlinkResolved:L()}).loose(),z(fo(`source`,[B({docName:F().min(1),timestamp:F().min(1),size:I().int().nonnegative(),source:U(`flat`)}).loose(),B({docName:F().min(1),timestamp:F().min(1),source:U(`timeline`),sha:F().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."});const rY=B({domain:F().min(1),title:F().optional(),description:F().optional(),siteName:F().optional(),faviconDataUri:F().optional()}).loose();B({url:F()}).loose(),fo(`ok`,[B({ok:U(!0),metadata:rY}).loose(),B({ok:U(!1),reason:F()}).loose()]),B({orphans:z(B({docName:F().min(1),title:F()}).loose())}).loose(),B({hubs:z(B({docName:F().min(1),title:F(),count:I().int().nonnegative()}).loose())}).loose();const iY=B({source:F().min(1),title:F(),snippet:F().nullable()}).loose();B({deadLinks:z(B({target:F().min(1),sources:z(iY)}).loose())}).loose(),B({target:B({docName:F().min(1),title:F(),aliases:z(F())}).loose(),mentions:z(B({source:F().min(1),excerpt:F(),offset:I().int().nonnegative()}).loose()),truncated:L()}).loose(),B({projectPath:F().min(1)}).loose();const aY=H([`not-a-git-worktree`,`init-failed`]);fo(`ok`,[B({ok:U(!0),projectPath:F().min(1)}).loose(),B({ok:U(!1),reason:aY,message:F().min(1)}).loose()]),B({host:F().min(1).optional()}).loose(),B({host:F().min(1).optional(),token:F().min(1)}).loose(),B({host:F(),login:F()}).loose(),B({key:F().min(1)}).loose(),B({keyPresent:L()}).loose();const oY=H([`no_key`,`invalid_endpoint`,`rate_limit`,`timeout`,`http_error`,`network`,`dims_mismatch`,`malformed_response`]);fo(`ok`,[B({ok:U(!0),endpoint:F().min(1),model:F().min(1),dimensions:I().int().positive()}).loose(),B({ok:U(!1),endpoint:F().min(1),model:F().min(1),reason:oY,status:I().int().optional()}).loose()]),B({name:F().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:F().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),B({authenticated:L()}).loose(),B({channel:H([`login`,`gh-login`]).default(`login`)}).loose(),B({}).loose();const sY=B({changes:z(fo(`kind`,[B({key:F(),kind:U(`added`),after:lJ}).loose(),B({key:F(),kind:U(`removed`),before:lJ}).loose(),B({key:F(),kind:U(`changed`),before:lJ,after:lJ}).loose()])),unparseable:B({before:F(),after:F()}).loose().nullable()}).loose(),cY=B({stackIndex:I().int().min(0),ts:I().int().min(0),additions:I().int().min(0),deletions:I().int().min(0)}).loose(),lY=B({docName:F().min(1),additionsTotal:I().int().min(0),deletionsTotal:I().int().min(0),lastTs:I().int().min(0),bursts:z(cY)}).loose(),uY=B({displayName:F().min(1),color:F().min(1),icon:F().optional(),connectionId:F().min(1)}).loose();B({sessionAlive:L(),agent:uY.nullable(),files:z(lY)}).loose(),B({diff:F(),before:F(),after:F(),properties:sY,generatedAt:I().int().min(0)}).loose(),B({}).loose(),B({}).loose(),B({}).loose(),B({}).loose(),B({}).loose(),B({}).loose();const dY=B({displayName:F().min(1),icon:F(),color:F().min(1),currentDoc:F().nullable(),mode:H([`idle`,`writing`]),ts:I().int().min(0)}).loose();B({presence:V(F().min(1),dY)}).loose();const fY=B({sessionId:F().min(1),agentType:F().min(1),ts:I().int().min(0),insertedChars:I().int().min(0),deletedChars:I().int().min(0)}).loose();B({effects:z(B({"doc.name":F().min(1),entries:z(fY)}).loose())}).loose(),B({decisions:z(B({ts:I().int().min(0),decision:F().min(1),kind:F().min(1),"doc.name":F().min(1),pathRole:F().min(1)}).loose())}).loose(),V(F().min(1),L()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`}),B({path:F().min(1,`path must be non-empty`)}).loose(),B({}).loose();const pY=B({fromDocName:F().min(1),toDocName:F().min(1)}).loose(),mY=B({fromPath:F().min(1),toPath:F().min(1)}).loose();B({}).loose(),B({path:F().min(1),...rw,summary:iw}).loose(),B({docName:F().min(1)}).loose(),B({path:F().min(1),...rw,summary:iw}).loose(),B({path:F().min(1)}).loose(),B({kind:H([`file`,`folder`]),path:F().min(1),...rw,summary:iw}).loose(),B({kind:H([`file`,`folder`]),path:F().min(1),duplicatedDocNames:z(F().min(1))}).loose(),B({pages:z(B({docName:F().min(1),title:F(),docExt:F().min(1),size:I().int().nonnegative(),modified:F().min(1),icon:F().min(1).max(2048).optional()}).loose())}).loose();const hY=B({level:I().int().min(1).max(6),text:F(),slug:F()}).loose();B({docName:F().min(1),headings:z(hY)}).loose();const gY=B({docName:F().min(1),rewrites:I().int().nonnegative()}).loose();B({kind:H([`file`,`folder`,`asset`]),fromPath:F().min(1),toPath:F().min(1),...rw,summary:iw}).loose(),B({renamed:z(pY),renamedAssets:z(mY),rewrittenDocs:z(gY).optional(),summary:dJ.optional()}).loose(),B({kind:H([`file`,`folder`,`asset`]),path:F().min(1),...rw}).loose(),B({deletedDocNames:z(F().min(1))}).loose(),B({kind:H([`file`,`folder`,`asset`]),path:F().min(1),...rw,summary:iw}).loose(),B({deletedDocNames:z(F().min(1))}).loose(),B({docName:F().min(1),commitSha:F().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:iw,...rw}).loose(),B({restoredFrom:F().min(1),timestamp:F().min(1),summary:dJ.optional(),warning:pJ.optional(),warnings:bJ.optional()}).loose();const _Y=/^#[0-9a-fA-F]{6}$/,vY=B(Object.fromEntries(is.map(e=>[e,F().regex(_Y,`must be a #rrggbb hex color`)]))),yY=F().min(1).refine(gre,{message:`must contain a non-whitespace character`}),bY=B({name:yY,author:yY.optional(),variant:H([`dark`,`light`]),palette:vY}).loose();B({name:F().min(1),scheme:bY,stem:F().min(1).optional(),extension:H([`.yaml`,`.yml`]).optional()}).loose(),B({id:F().min(1),filename:F().min(1)}).loose(),B({id:F().min(1),scheme:bY}).loose(),B({id:F().min(1),filename:F().min(1)}).loose(),fo(`existed`,[B({existed:U(!1)}).loose(),B({existed:U(!0),filename:F().min(1),scheme:bY}).loose()]),B({themes:z(fo(`ok`,[B({ok:U(!0),id:F().min(1),filename:F().min(1),scheme:bY}),B({ok:U(!1),filename:F().min(1),id:F().min(1).optional(),code:F().min(1),conflictingFilenames:z(F().min(1)).min(2).optional()})])),truncated:L()}).loose();const xY=H([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),SY=B({label:F().min(1),webUrl:ro().nullable()}).loose(),CY=fo(`checkStatus`,[B({checkStatus:U(`allowed`)}).loose(),B({checkStatus:U(`denied`),deniedReason:H([`no-collaborator`,`private-no-access`,`repo-not-found`,`not-authenticated`]),resolvedLogin:F().optional(),declaredLogin:F().optional(),declaredSource:F().optional()}).loose(),B({checkStatus:U(`unknown`),unknownError:H([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`,`ssh-unverified`]).optional()}).loose()]),wY=H([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`auth-not-found-as-identity`,`semantic-protected-branch`]),TY=H(Xne),EY=H([`succeeded`,`up-to-date`,`conflict`,`refused`,`error`]);B({state:xY,lastSyncUtc:F().nullable(),lastFetchUtc:F().nullable(),lastPushedSha:F().nullable(),ahead:I().int().min(0),behind:I().int().min(0),consecutiveFailures:I().int().min(0),conflictCount:I().int().min(0),hasRemote:L(),syncEnabled:L(),identityUnresolved:L(),remote:SY.nullable().optional(),pushError:F().optional(),pushErrorCode:wY.optional(),pullError:F().optional(),pullErrorCode:wY.optional(),pausedReason:F().optional(),pushPermission:CY.optional(),syncMode:TY.optional(),lastPullUtc:F().nullable().optional(),lastPullOutcome:EY.nullable().optional()}).loose(),B({op:H([`sync`,`push`,`pull`]).optional()}).loose(),B({op:H([`sync`,`push`,`pull`])}).loose(),B({conflicts:z(B({file:F().min(1),detectedAt:F().min(1),oursSha:F().optional(),theirsSha:F().optional(),baseSha:F().optional()}).loose())}).loose(),B({file:F().min(1),strategy:H([`mine`,`theirs`,`content`,`delete`]),content:F().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),B({}).loose(),B({file:F().min(1),base:F(),ours:F(),theirs:F(),kind:H([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:F().nullable()}).loose(),B({plan:To(e=>e!==void 0,{message:`plan is required`})}).loose(),B({plan:To(e=>e!==void 0,{message:`plan is required`})}).loose(),B({result:To(e=>e!==void 0,{message:`result is required`})}).loose(),B({packId:F().min(1)}).strict(),B({installedHosts:z(F()),skills:z(B({name:F().min(1),created:L()}).strict())}).strict();const DY=B({path:F().min(1),summary:F().min(1)}).loose(),OY=B({files:I().int().nonnegative(),folders:I().int().nonnegative()}).loose();B({packs:z(B({id:F().min(1),name:F().min(1),description:F().min(1),defaultSubfolder:F().optional(),folders:z(DY),entryCounts:OY}).loose())}).loose(),B({noOpen:L().optional(),out:F().min(1).optional()}).loose();const kY=B({reason:H([`unsupported-platform`,`spawn-error`]),message:F()}).loose();fo(`status`,[B({status:U(`installed`),outputPath:F(),size:I().int().nonnegative(),sha256:F(),skillVersion:F()}).loose(),B({status:U(`built`),outputPath:F(),size:I().int().nonnegative(),sha256:F(),skillVersion:F(),handoffError:kY.optional()}).loose(),B({status:U(`failed`),buildError:F()}).loose(),B({status:U(`skip-current`),skillVersion:F(),recordedAt:F().optional()}).loose()]);const AY=H(Rl),jY=H(zl),MY=B({alwaysOn:I().int().nonnegative(),onTrigger:I().int().nonnegative(),onDemand:I().int().nonnegative()}).strict();B({tags:z(B({name:F().min(1),count:I().int().nonnegative(),isLeaf:L()}).loose())}).loose();const NY=B({docName:F().min(1),title:F(),matchingTags:z(F().min(1)),snippet:F().nullable()}).loose();B({name:F().min(1),docs:z(NY)}).loose(),B({folder:R(),frontmatter_local:V(F(),R()).nullable()}).loose(),B({path:F(),frontmatter:V(F(),R()).optional()}).loose(),B({applied:R()}).loose();const PY=V(F(),R()).meta({description:`Free-form frontmatter map embedded in template payloads.`});B({template:B({name:F().min(1),folder:F(),scope:H([`local`,`inherited`]),path:F().min(1),frontmatter:PY,body:F()}).strict()}).strict(),B({templates:z(B({name:F().min(1),title:F().optional(),description:F().optional(),path:F().min(1),source_folder:F()}).strict()),truncated:L()}).strict(),B({folder:F(),name:F(),body:F().optional(),frontmatter:PY.optional(),...rw,summary:iw}).strict(),B({path:F().min(1),created:L(),warnings:z(F())}).strict(),B({sourcePath:F().min(1),targetFolder:F(),name:F().optional(),title:F().optional(),deleteSource:L().optional(),...rw,summary:iw}).strict(),B({path:F().min(1),created:L(),warnings:z(F())}).strict(),B({existed:L(),path:F().min(1)}).strict(),B({fromFolder:F(),fromName:F(),toFolder:F(),toName:F(),body:F().optional(),frontmatter:PY.optional(),...rw,summary:iw}).strict(),B({from:F().min(1),to:F().min(1),committed:L()}).strict();const FY=H(Al),IY=/^[a-z0-9-]+$/,LY=B({name:F(),description:F(),metadata:B({pack:F()}).strict().optional()}).strict();B({skill:B({name:F().min(1),scope:FY,path:F().min(1),frontmatter:LY,body:F(),files:z(B({path:F().min(1),text:F().nullable()})).optional(),managed:L().optional()}).strict()}).strict();const RY=B({source:F().min(1),publisher:F().optional(),skill:F().optional(),marketplaceUrl:F().optional(),importedAt:F().min(1),autoUpdate:L().optional()}).strict(),zY=B({name:F().min(1),description:F().optional(),scope:FY,path:F().min(1),canonicalPath:F().min(1).optional(),absolutePath:F().min(1).optional(),installed:L(),hosts:z(F()),hostQualifier:F().optional().meta({description:"Set on a GLOBAL entry that shares its name with a distinct-content bundle in another host dir AND is not the by-name default: the host id whose root holds THIS bundle. Doc-name builders append it (`__skill__/global/<name>@<host>`) so each same-named bundle keeps its own tab and its own write-back path; the default bundle keeps the stable unqualified name."}),driftPaths:z(F()).optional().meta({description:`Recorded locations whose on-disk form (copy vs symlink) no longer matches what OK last wrote there — evidence another tool rewrote the path.`}),hostAliases:V(F(),F()).optional().meta({description:`Host skills roots that are symlink ALIASES of another location (host id → base-relative target root). An aliased folder is a derived view — no menu row, never a write target; the host's icon rides the target root's row.`}),conflictHosts:z(F()).optional().meta({description:`Hosts whose dir holds a DIFFERENT same-name skill (fork/conflict) — occupied, not this skill.`}),symlinkedHosts:z(F()).optional(),installableEditors:z(F()).optional(),linkMode:L().optional(),customPlacements:z(B({path:F(),mode:H([`copy`,`link`])}).strict()).optional(),plugin:B({name:F().min(1),marketplace:F().min(1),provider:F().min(1),url:F().optional()}).strict().optional(),managed:L().optional(),origin:RY.optional(),pack:F().optional(),modified:L().optional(),revertable:L().optional(),ignored:L().optional(),size:MY.optional()}).strict();B({name:F().min(1),scope:FY,apply:L().optional()}).strict(),B({line:F().min(1),gitignorePath:F().min(1),applied:L(),alreadyTracked:L().optional()}).strict(),B({skills:z(zY),truncated:L()}).strict(),B({scope:FY.default(`project`),name:F().meta({description:`Managed skill name to create or update.`}),body:F().optional(),frontmatter:LY,...rw,summary:iw}).strict(),B({path:F().min(1),created:L(),warnings:z(F())}).strict(),B({scope:FY.default(`project`),name:F(),dryRun:L().optional(),setAutoUpdate:L().optional(),...rw,summary:iw}).strict(),B({name:F().min(1),updated:L(),source:F().min(1),localBody:F().optional(),upstreamBody:F().optional(),gitTracked:L().optional(),warnings:z(F())}).strict(),B({scope:FY.default(`project`),name:F(),...rw,summary:iw}).strict(),B({name:F().min(1),baselineRef:F().min(1),restoredFiles:z(F()),warnings:z(F())}).strict(),B({existed:L(),path:F().min(1)}).strict(),B({scope:FY.default(`project`),fromName:F(),toName:F(),body:F().optional(),frontmatter:LY.optional(),...rw,summary:iw}).strict(),B({from:F().min(1),to:F().min(1),committed:L()}).strict(),B({name:F(),fromScope:FY,toScope:FY,...rw,summary:iw}).strict(),B({scope:FY,path:F().optional()}).strict(),B({scope:FY,name:F(),toName:F(),...rw,summary:iw}).strict(),B({name:F().min(1)}).strict(),B({name:F(),home:F().min(1)}).strict(),B({docName:F().min(1)}).strict();const BY=H([`reference`,`script`,`file`]);B({scope:FY.default(`project`),name:F(),path:F().min(1),content:F(),...rw,summary:iw}).strict(),B({path:F().min(1),created:L(),kind:BY,content:L()}).strict(),B({scope:FY.default(`project`),name:F(),from:F().min(1),to:F().min(1),...rw,summary:iw}).strict(),B({from:F().min(1),to:F().min(1),fromDocName:F().optional(),toDocName:F().optional()}).strict(),B({path:F().min(1),kind:BY,text:F()}).strict(),B({path:F().min(1),existed:L(),kind:BY}).strict();const VY=uo([jY,U(`agents`)]),HY=F().min(1).refine(e=>!e.startsWith(`/`)&&!e.startsWith(`~`)&&!/^[A-Za-z]:/.test(e),{error:`a custom root is base-relative (e.g. ".tim/skills"), not absolute or ~-prefixed`}).refine(e=>e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),{error:`a custom root may not contain "..", "." or empty path segments`}).refine(e=>e.includes(`/`),{error:`a custom root is a path (e.g. ".tim/skills") — bare editor names are host ids`}),UY=uo([VY,HY]);B({scope:FY.default(`project`),name:F(),targets:z(VY).optional().meta({description:'SET-EXACT install targets (editor ids, plus "agents" for the .agents hub — in-place skills only): the COMPLETE resulting host set. Omit to use project-configured editors; pass [] to uninstall everywhere. Stateless callers should prefer `add`/`remove`.'}),add:z(UY).optional().meta({description:`Locations to ADD the skill to (everything else untouched). Editor ids fan out a managed copy/symlink; a custom root path (".tim/skills") places the bundle there.`}),remove:z(UY).optional().meta({description:"Locations to REMOVE the skill from (lossless only — a hand-edited fork is refused, never deleted). The source cannot be removed; move it first with `source`."}),mode:H([`copy`,`link`]).optional().meta({description:`"link": one real folder (the source); every other location becomes a symlink to it. "copy": independent real folders, refreshed from the source until hand-edited (a hand-edit forks that copy). Converts existing locations losslessly. Omit to follow the form the skill already uses.`}),source:UY.optional().meta({description:`Move the skill's REAL folder to this location (the old source becomes a symlink to it — never a removal). Sticky across rescans.`}),linkMode:L().optional(),setSource:F().min(1).optional(),place:B({dir:F().min(1).meta({description:`Project-relative directory the bundle dir is created under (e.g. ".windsurf/skills").`}),mode:H([`copy`,`link`])}).strict().optional(),convert:B({target:UY.meta({description:`The installed location to convert — an editor id, "agents", or a recorded custom placement path.`}),mode:H([`copy`,`link`]).meta({description:`"link": replace this location with a symlink to the source. "copy": replace it with an independent real folder.`})}).strict().optional(),unplace:B({path:F().min(1).meta({description:`The recorded placement bundle path (e.g. ".windsurf/skills/my-skill").`})}).strict().optional(),...rw,summary:iw,fork:B({editor:F().min(1),action:H([`align`,`make-source`,`rename`]),toName:F().optional()}).strict().optional()}).strict().refine(e=>!(e.targets!==void 0&&(e.add!==void 0||e.remove!==void 0)),{error:"`targets` is set-exact; `add`/`remove` are additive — use one style per call"}).refine(e=>e.fork===void 0||e.targets===void 0&&e.add===void 0&&e.remove===void 0&&e.source===void 0&&e.setSource===void 0,{error:"`fork` is its own operation — run it in a separate call"}).refine(e=>e.fork?.action!==`rename`||e.fork.toName!==void 0,{error:"`fork.rename` requires `toName`"}).refine(e=>!(e.source!==void 0&&(e.add!==void 0||e.remove!==void 0)),{error:"a `source` move is its own operation — run it in a separate call from `add`/`remove`"}).refine(e=>[e.targets!==void 0||e.add!==void 0||e.remove!==void 0,e.place!==void 0,e.unplace!==void 0,e.convert!==void 0,e.source!==void 0||e.setSource!==void 0,e.fork!==void 0].filter(Boolean).length<=1,{error:"one operation per call — membership (`targets`/`add`/`remove`), `place`, `unplace`, `convert`, `source`, and `fork` are mutually exclusive"}),B({name:F().min(1).meta({description:`Managed skill name installed or uninstalled.`}),hosts:z(F()).meta({description:`Editor ids the skill is projected into after the operation; [] is expected after uninstall.`}),scripts:L().meta({description:`True when the skill ships executable scripts, projected but never run.`}),warnings:z(F()).meta({description:`Non-fatal install/uninstall warnings from target projection.`}),warningCodes:z(H([`no-targets`,`scripts-present`,`name-conflict`,`no-description`,`skill-fork-name-unpatched`,`place-path-invalid`,`place-fork-refused`])).meta({description:"Machine-readable warning codes aligned with `warnings`."}),placedAt:F().optional(),sourceMovedTo:F().optional()}).strict(),B({scope:FY.default(`project`),name:F().meta({description:`Managed skill name to uninstall without deleting source.`})}).strict(),B({name:F().min(1).meta({description:`Managed skill name requested for uninstall.`}),uninstalled:L().meta({description:`True when an install marker existed and was removed; false for an idempotent no-op.`})}).strict(),B({targets:z(AY),configured:L(),folders:z(B({scope:FY,host:F(),root:F(),state:H([`own`,`linked`,`linked-parent`,`absent`]),target:F().optional(),drift:U(!0).optional(),expected:F().optional()}).strict()).optional()}).strict();const WY=B({action:U(`link`),scope:FY,root:F().min(1).meta({description:`The folder to link (e.g. ".codex/skills").`}),target:F().min(1).meta({description:`The root it merges into (e.g. ".agents/skills"). Required.`})}),GY=B({action:U(`unlink`),scope:FY,root:F().min(1).meta({description:`The linked folder to materialize back.`}),exclude:z(F().min(1)).optional().meta({description:`Skill names to LEAVE OUT when materializing — the folder keeps every other skill it currently sees (as per-skill links) and stops auto-following the target root.`})}).strict(),KY=B({action:U(`add-root`),scope:FY,root:HY.meta({description:`New custom skills root to declare (base-relative, e.g. ".team/skills").`})}).strict(),qY=fo(`action`,[WY.extend({preview:L().optional().meta({description:`Return the merge plan only (moves, drops, removes, conflicts, strays) — nothing is written.`})}).strict(),GY,KY]);fo(`action`,[WY.strict(),GY,KY]),B({folderAction:qY}).strict();const JY=B({moves:z(F()),drops:z(F()),removes:z(F()),replaces:z(F()),conflicts:z(F()),strays:z(F())}).strict();B({targets:z(AY),reprojected:z(B({name:F(),hosts:z(F())}).strict()),bundleHosts:z(F()),removedFrom:z(F()),folder:B({moved:z(F()),dropped:z(F()),linked:z(F())}).strict().optional(),preview:JY.optional()}).strict(),B({scope:FY.default(`project`),name:F(),version:F().regex(/^[0-9a-f]{40}$/i),...rw,summary:iw}).strict(),B({name:F().min(1),version:F(),restoredFiles:z(F()),warnings:z(F())}).strict(),B({query:F().optional(),intent:H([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:H([`navigation`,`relevance`]).optional(),scopes:z(H([`page`,`folder`,`content`,`file`])).optional(),scope:F().optional(),limit:I().int().nonnegative().optional(),semantic:L().optional(),source:H([`omnibar`,`mcp`,`http`]).optional()}).loose();const YY=B({kind:H([`page`,`folder`,`content`,`file`]),path:F().min(1),title:F(),score:I(),signals:V(F(),R()),snippet:F().optional()}).loose(),XY=B({capable:L(),applied:L(),coverage:B({embedded:I().int().nonnegative(),total:I().int().nonnegative()})}).loose();B({enabled:L(),keyPresent:L(),keyNotRequired:L(),keySource:H([`project`,`file`,`env`]).nullable(),keyHint:F().nullable(),ready:L(),capable:L(),embedded:I().int().nonnegative(),total:I().int().nonnegative()}).loose(),B({query:F(),intent:H([`autocomplete`,`full_text`,`omnibar`]),results:z(YY),elapsedMs:I().nonnegative(),semantic:XY.optional(),truncated:L().optional(),ready:L().optional()}).loose();const ZY=B({version:F().min(1),recordedAt:F().min(1)}).loose();B({currentVersion:F().min(1),targets:V(F(),ZY.nullable())}).loose(),B({scope:FY.default(`project`),source:F().min(1).meta({description:`External skill source: full skills.sh skill-page URL (https://www.skills.sh/<owner>/<repo>/<skill>, or https://www.skills.sh/site/<hostname>/<skill> for a website catalog), GitHub owner/repo[/subpath], git URL, or local/file path.`}),skill:F().min(1).optional().meta({description:`Specific skill name to import from a multi-skill source.`}),install:L().optional().meta({description:`Pass false to import WITHOUT the default-editor auto-projection (the caller installs explicitly afterwards). Default true.`}),marketplace:L().optional().meta({description:"The source came from a skills.sh listing the user chose (the Explore tab), so the install is reported to skills.sh and counts toward that listing. Off by default: a hand-typed repo must not be announced to skills.sh. Honors the `telemetry.skillInstallReports.enabled` setting and DO_NOT_TRACK."}),...rw,summary:iw}).strict(),B({scope:FY.default(`project`),source:F().min(1).meta({description:`External skill source: full skills.sh skill-page URL, GitHub owner/repo[/subpath], git URL, or local/file path.`}),skills:z(F().min(1)).min(1).max(100).meta({description:`Skill names to import from the source.`}),install:L().optional().meta({description:`Pass false to import WITHOUT the default-editor auto-projection. Default true.`}),marketplace:L().optional().meta({description:"The source came from a skills.sh listing the user chose (a marketplace plugin bundle), so the import is reported to skills.sh as one batched install event and counts toward that listing. Off by default: a hand-typed repo must not be announced to skills.sh. Honors the `telemetry.skillInstallReports.enabled` setting and DO_NOT_TRACK."}),...rw,summary:iw}).strict(),B({results:z(B({requested:F(),status:H([`imported`,`already-imported`,`not-found`,`failed`]),name:F().optional(),collisionRenamedFrom:F().optional(),warnings:z(F()),error:F().optional()}).loose()),imported:I(),alreadyImported:I(),failed:I()}).loose(),B({scope:FY.default(`project`),names:z(F().min(1)).min(1).max(100).meta({description:`Managed skill names to refresh from their recorded upstreams.`}),...rw,summary:iw}).strict(),B({results:z(B({requested:F(),status:H([`updated`,`up-to-date`,`not-found`,`failed`]),source:F().optional(),warnings:z(F()),error:F().optional()}).loose()),updated:I(),upToDate:I(),failed:I()}).loose();const QY=B({source:F(),ref:F().optional(),contentHash:F(),publisher:F().optional()}).loose();B({name:F().min(1).meta({description:`Managed skill name created or matched.`}),path:F().min(1).meta({description:`Store-relative path to the imported skill source.`}),created:L().meta({description:`True when this request created new source files.`}),alreadyImported:L().meta({description:`True when identical content was already present and no files changed.`}),collisionRenamedFrom:F().optional().meta({description:`Original source name when collision handling renamed the import.`}),provenance:QY,warnings:z(F()).meta({description:`Non-fatal import warnings, such as skipped unsupported files.`})}).loose();const $Y=H([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`,`comments`,`lint-config`,`local-targets`]);B({v:U(1),ch:U(`server-info`),seq:I(),serverInstanceId:F().min(1),currentBranch:F().min(1).optional()}).loose(),B({v:U(1),ch:U(`branch-switched`),seq:I(),branch:F().min(1)}).loose(),B({v:U(1),ch:$Y,seq:I()}).loose(),B({v:U(1),ch:U(`disk-ack`),seq:I(),docName:F().min(1),sv:F().min(1)}).loose(),B({v:U(1),ch:U(`config-validation-rejected`),seq:I(),docName:F().min(1),error:fl}).loose(),B({v:U(1),ch:U(`config-ignore-nested-error`),seq:I(),path:F().min(1),error:F().min(1)}).loose();var eX=e(i(((e,t)=>{var n=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},r=-1,i=1,a=0;n.Diff=function(e,t){return[e,t]},n.prototype.diff_main=function(e,t,r,i){i===void 0&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+this.Diff_Timeout*1e3);var o=i;if(e==null||t==null)throw Error(`Null input. (diff_main)`);if(e==t)return e?[new n.Diff(a,e)]:[];r===void 0&&(r=!0);var s=r,c=this.diff_commonPrefix(e,t),l=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=this.diff_commonSuffix(e,t);var u=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var d=this.diff_compute_(e,t,s,o);return l&&d.unshift(new n.Diff(a,l)),u&&d.push(new n.Diff(a,u)),this.diff_cleanupMerge(d),d},n.prototype.diff_compute_=function(e,t,o,s){var c;if(!e)return[new n.Diff(i,t)];if(!t)return[new n.Diff(r,e)];var l=e.length>t.length?e:t,u=e.length>t.length?t:e,d=l.indexOf(u);if(d!=-1)return c=[new n.Diff(i,l.substring(0,d)),new n.Diff(a,u),new n.Diff(i,l.substring(d+u.length))],e.length>t.length&&(c[0][0]=c[2][0]=r),c;if(u.length==1)return[new n.Diff(r,e),new n.Diff(i,t)];var f=this.diff_halfMatch_(e,t);if(f){var p=f[0],m=f[1],h=f[2],g=f[3],_=f[4],v=this.diff_main(p,h,o,s),y=this.diff_main(m,g,o,s);return v.concat([new n.Diff(a,_)],y)}return o&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,s):this.diff_bisect_(e,t,s)},n.prototype.diff_lineMode_=function(e,t,o){var s=this.diff_linesToChars_(e,t);e=s.chars1,t=s.chars2;var c=s.lineArray,l=this.diff_main(e,t,!1,o);this.diff_charsToLines_(l,c),this.diff_cleanupSemantic(l),l.push(new n.Diff(a,``));for(var u=0,d=0,f=0,p=``,m=``;u<l.length;){switch(l[u][0]){case i:f++,m+=l[u][1];break;case r:d++,p+=l[u][1];break;case a:if(d>=1&&f>=1){l.splice(u-d-f,d+f),u=u-d-f;for(var h=this.diff_main(p,m,!1,o),g=h.length-1;g>=0;g--)l.splice(u,0,h[g]);u+=h.length}f=0,d=0,p=``,m=``;break}u++}return l.pop(),l},n.prototype.diff_bisect_=function(e,t,a){for(var o=e.length,s=t.length,c=Math.ceil((o+s)/2),l=c,u=2*c,d=Array(u),f=Array(u),p=0;p<u;p++)d[p]=-1,f[p]=-1;d[l+1]=0,f[l+1]=0;for(var m=o-s,h=m%2!=0,g=0,_=0,v=0,y=0,b=0;b<c&&!(new Date().getTime()>a);b++){for(var x=-b+g;x<=b-_;x+=2){for(var S=l+x,C=x==-b||x!=b&&d[S-1]<d[S+1]?d[S+1]:d[S-1]+1,w=C-x;C<o&&w<s&&e.charAt(C)==t.charAt(w);)C++,w++;if(d[S]=C,C>o)_+=2;else if(w>s)g+=2;else if(h){var T=l+m-x;if(T>=0&&T<u&&f[T]!=-1){var E=o-f[T];if(C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}for(var D=-b+v;D<=b-y;D+=2){for(var T=l+D,E=D==-b||D!=b&&f[T-1]<f[T+1]?f[T+1]:f[T-1]+1,O=E-D;E<o&&O<s&&e.charAt(o-E-1)==t.charAt(s-O-1);)E++,O++;if(f[T]=E,E>o)y+=2;else if(O>s)v+=2;else if(!h){var S=l+m-D;if(S>=0&&S<u&&d[S]!=-1){var C=d[S],w=l+C-S;if(E=o-E,C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}}return[new n.Diff(r,e),new n.Diff(i,t)]},n.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,o,!1,i),u=this.diff_main(s,c,!1,i);return l.concat(u)},n.prototype.diff_linesToChars_=function(e,t){var n=[],r={};n[0]=``;function i(e){for(var t=``,i=0,o=-1,s=n.length;o<e.length-1;){o=e.indexOf(`
414
+ `)}B({entries:z(B({level:H([`info`,`warn`,`error`]),message:F().max(8192),event:F().optional(),fields:V(F(),R()).optional(),ts:I().optional(),sourceId:F().optional(),lineNumber:I().optional()}).loose()).max(100),droppedSinceLastFlush:I().int().min(0).optional()}).loose(),B({accepted:I().int().min(0)}).loose();const BJ=B({exact:F().min(1),prefix:F(),suffix:F(),start:I().int().nonnegative(),end:I().int().nonnegative()}),VJ=z(uo([F(),I().int().nonnegative()])),HJ=fo(`kind`,[B({kind:U(`body`)}),B({kind:U(`property`),key:F().min(1),path:VJ.default([])})]).default({kind:`body`}),UJ=H([`anchored`,`orphaned`,`resolved`]),WJ=B({threadId:F().min(1),docName:F().min(1),target:HJ,anchor:BJ.nullable(),state:UJ,queued:L(),latestComment:F(),createdBy:F().min(1),createdAt:I(),updatedAt:I().optional()}),GJ=B({docName:F(),instruction:F(),property:F().nullable(),passage:B({exact:F(),prefix:F(),suffix:F()}).nullable(),anchorLost:L(),passageRepeats:L()}).loose(),KJ=B({threadId:F(),ok:U(!0)}),qJ=B({threadId:F(),ok:U(!1),error:U(`not-found`)});B({threads:z(WJ)}).loose(),B({meta:WJ,orphaned:L()}).loose(),B({threadId:F()}).loose(),B({meta:WJ,payload:GJ}).loose(),B({results:z(uo([KJ.extend({meta:WJ,payload:GJ}),qJ]))}).loose(),B({results:z(uo([KJ.extend({meta:WJ}),qJ]))}).loose();const JJ=B({status:F().min(1),reason:F()}).loose();B({docName:F().min(1),content:F(),lifecycle:JJ.nullable()}).loose(),B({documents:z(B({kind:H([`document`,`asset`,`folder`,`file`]).default(`document`),docName:F().min(1).optional(),docExt:F().min(1).default(`.md`),size:I().int().nonnegative(),modified:F().min(1),isSymlink:L().default(!1),canonicalDocName:F().nullable().default(null),targetPath:F().nullable().default(null),path:F().min(1).optional(),assetExt:F().min(1).optional(),mediaKind:H([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`,`excalidraw`]).nullable().optional(),referencedBy:z(F().min(1)).optional(),hasChildren:L().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.kind===`file`?e.path!==void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder/file kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName; file → path, no mediaKind/referencedBy/hasChildren)`})),truncated:L().optional()}).loose();const YJ=B({source:F().min(1),anchor:F().nullable(),title:F(),snippet:F().nullable()}).loose();B({docName:F().min(1),backlinks:z(YJ)}).loose(),B({counts:V(F().min(1),I().int().nonnegative())}).loose(),B({counts:V(F().min(1),I().int().nonnegative())}).loose();const XJ=fo(`kind`,[B({kind:U(`doc`),docName:F().min(1),anchor:F().nullable(),title:F(),snippet:F().nullable()}).loose(),B({kind:U(`external`),url:F().min(1),title:F(),snippet:F().nullable()}).loose()]),ZJ=B({role:F().min(1),sourceForm:F().min(1),targetKind:F().min(1),href:F(),resolvedTarget:F().nullable(),status:F().min(1),reason:F().nullable(),resolutionMethod:F().min(1),fallbackTarget:F().nullable().default(null),range:B({start:I().int().nonnegative(),end:I().int().nonnegative()}),line:I().int().nonnegative(),column:I().int().nonnegative(),definition:B({label:F(),line:I().int().nonnegative()}).nullable().default(null)}).loose();B({docName:F().min(1),forwardLinks:z(XJ),localTargets:z(ZJ).optional()}).loose();const QJ=fo(`kind`,[B({id:F().min(1),kind:U(`doc`),docName:F().min(1),anchor:F().nullable(),label:F(),cluster:F().nullable(),category:F().nullable(),tags:z(F()).nullable(),managed:L().optional()}).loose(),B({id:F().min(1),kind:U(`external`),url:F().min(1),label:F()}).loose()]),$J=B({source:F().min(1),target:F().min(1)}).loose();B({nodes:z(QJ),links:z($J)}).loose();const eY=B({ts:I().int().min(0),url:F(),method:F(),ua:F().optional(),origin:F().optional(),referer:F().optional(),host:F().optional(),remote:F().optional(),secChUa:F().optional(),secChUaMobile:F().optional(),secChUaPlatform:F().optional(),secFetchSite:F().optional(),secFetchDest:F().optional(),secFetchMode:F().optional(),secFetchUser:F().optional()}).loose(),tY=B({app:uo([U(`cursor`),U(`codex`),U(`claude`),oo()]),signals_fired:z(F())}).loose();B({entries:z(eY),count:I().int().min(0),detection:tY}).loose(),B({writers:z(B({id:F().min(1),name:F().optional(),email:F().optional()}).loose()).optional(),summary:iw,...rw}).loose(),B({checkpointRef:F().min(1)}).loose();const nY=B({v:I().int().optional(),id:F().min(1),name:F().min(1),colorSeed:F().optional(),docs:z(F()),summaries:z(F()).optional()}).loose();B({entries:z(B({sha:F().min(1),timestamp:F().min(1),author:F(),authorEmail:F(),type:H([`checkpoint`,`wip`,`upstream`,`park`]),message:F(),contributors:z(nY),checkpoint:R().nullable(),parentSha:F().nullable().optional()}).loose()),total:I().int().nonnegative().optional(),truncated:L().optional(),hasMore:L().optional()}).loose(),B({sha:F().regex(/^[0-9a-f]{40}$/i),content:F(),timestamp:F(),author:F()}).loose(),B({contentDir:F().min(1),pathSeparator:H([`/`,`\\`]),symlinkResolved:L()}).loose(),z(fo(`source`,[B({docName:F().min(1),timestamp:F().min(1),size:I().int().nonnegative(),source:U(`flat`)}).loose(),B({docName:F().min(1),timestamp:F().min(1),source:U(`timeline`),sha:F().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."});const rY=B({domain:F().min(1),title:F().optional(),description:F().optional(),siteName:F().optional(),faviconDataUri:F().optional()}).loose();B({url:F()}).loose(),fo(`ok`,[B({ok:U(!0),metadata:rY}).loose(),B({ok:U(!1),reason:F()}).loose()]),B({orphans:z(B({docName:F().min(1),title:F()}).loose())}).loose(),B({hubs:z(B({docName:F().min(1),title:F(),count:I().int().nonnegative()}).loose())}).loose();const iY=B({source:F().min(1),title:F(),snippet:F().nullable()}).loose();B({deadLinks:z(B({target:F().min(1),sources:z(iY)}).loose())}).loose(),B({target:B({docName:F().min(1),title:F(),aliases:z(F())}).loose(),mentions:z(B({source:F().min(1),excerpt:F(),offset:I().int().nonnegative()}).loose()),truncated:L()}).loose(),B({projectPath:F().min(1)}).loose();const aY=H([`not-a-git-worktree`,`init-failed`]);fo(`ok`,[B({ok:U(!0),projectPath:F().min(1)}).loose(),B({ok:U(!1),reason:aY,message:F().min(1)}).loose()]),B({host:F().min(1).optional()}).loose(),B({host:F().min(1).optional(),token:F().min(1)}).loose(),B({host:F(),login:F()}).loose(),B({key:F().min(1)}).loose(),B({keyPresent:L()}).loose();const oY=H([`no_key`,`invalid_endpoint`,`rate_limit`,`timeout`,`http_error`,`network`,`dims_mismatch`,`malformed_response`]);fo(`ok`,[B({ok:U(!0),endpoint:F().min(1),model:F().min(1),dimensions:I().int().positive()}).loose(),B({ok:U(!1),endpoint:F().min(1),model:F().min(1),reason:oY,status:I().int().optional()}).loose()]),B({name:F().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:F().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),B({authenticated:L()}).loose(),B({channel:H([`login`,`gh-login`]).default(`login`)}).loose(),B({}).loose();const sY=B({changes:z(fo(`kind`,[B({key:F(),kind:U(`added`),after:lJ}).loose(),B({key:F(),kind:U(`removed`),before:lJ}).loose(),B({key:F(),kind:U(`changed`),before:lJ,after:lJ}).loose()])),unparseable:B({before:F(),after:F()}).loose().nullable()}).loose(),cY=B({stackIndex:I().int().min(0),ts:I().int().min(0),additions:I().int().min(0),deletions:I().int().min(0)}).loose(),lY=B({docName:F().min(1),additionsTotal:I().int().min(0),deletionsTotal:I().int().min(0),lastTs:I().int().min(0),bursts:z(cY)}).loose(),uY=B({displayName:F().min(1),color:F().min(1),icon:F().optional(),connectionId:F().min(1)}).loose();B({sessionAlive:L(),agent:uY.nullable(),files:z(lY)}).loose(),B({diff:F(),before:F(),after:F(),properties:sY,generatedAt:I().int().min(0)}).loose(),B({}).loose(),B({}).loose(),B({}).loose(),B({}).loose(),B({}).loose(),B({}).loose();const dY=B({displayName:F().min(1),icon:F(),color:F().min(1),currentDoc:F().nullable(),mode:H([`idle`,`writing`]),ts:I().int().min(0)}).loose();B({presence:V(F().min(1),dY)}).loose();const fY=B({sessionId:F().min(1),agentType:F().min(1),ts:I().int().min(0),insertedChars:I().int().min(0),deletedChars:I().int().min(0)}).loose();B({effects:z(B({"doc.name":F().min(1),entries:z(fY)}).loose())}).loose(),B({decisions:z(B({ts:I().int().min(0),decision:F().min(1),kind:F().min(1),"doc.name":F().min(1),pathRole:F().min(1)}).loose())}).loose(),V(F().min(1),L()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`}),B({path:F().min(1,`path must be non-empty`)}).loose(),B({}).loose();const pY=B({fromDocName:F().min(1),toDocName:F().min(1)}).loose(),mY=B({fromPath:F().min(1),toPath:F().min(1)}).loose();B({}).loose(),B({path:F().min(1),...rw,summary:iw}).loose(),B({docName:F().min(1)}).loose(),B({path:F().min(1),...rw,summary:iw}).loose(),B({path:F().min(1)}).loose(),B({kind:H([`file`,`folder`]),path:F().min(1),...rw,summary:iw}).loose(),B({kind:H([`file`,`folder`]),path:F().min(1),duplicatedDocNames:z(F().min(1))}).loose(),B({pages:z(B({docName:F().min(1),title:F(),docExt:F().min(1),size:I().int().nonnegative(),modified:F().min(1),icon:F().min(1).max(2048).optional()}).loose())}).loose();const hY=B({level:I().int().min(1).max(6),text:F(),slug:F()}).loose();B({docName:F().min(1),headings:z(hY)}).loose();const gY=B({docName:F().min(1),rewrites:I().int().nonnegative()}).loose();B({kind:H([`file`,`folder`,`asset`]),fromPath:F().min(1),toPath:F().min(1),...rw,summary:iw}).loose(),B({renamed:z(pY),renamedAssets:z(mY),rewrittenDocs:z(gY).optional(),summary:dJ.optional()}).loose(),B({kind:H([`file`,`folder`,`asset`]),path:F().min(1),...rw}).loose(),B({deletedDocNames:z(F().min(1))}).loose(),B({kind:H([`file`,`folder`,`asset`]),path:F().min(1),...rw,summary:iw}).loose(),B({deletedDocNames:z(F().min(1))}).loose(),B({docName:F().min(1),commitSha:F().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:iw,...rw}).loose(),B({restoredFrom:F().min(1),timestamp:F().min(1),summary:dJ.optional(),warning:pJ.optional(),warnings:bJ.optional()}).loose();const _Y=/^#[0-9a-fA-F]{6}$/,vY=B(Object.fromEntries(is.map(e=>[e,F().regex(_Y,`must be a #rrggbb hex color`)]))),yY=F().min(1).refine(gre,{message:`must contain a non-whitespace character`}),bY=B({name:yY,author:yY.optional(),variant:H([`dark`,`light`]),palette:vY}).loose();B({name:F().min(1),scheme:bY,stem:F().min(1).optional(),extension:H([`.yaml`,`.yml`]).optional()}).loose(),B({id:F().min(1),filename:F().min(1)}).loose(),B({id:F().min(1),scheme:bY}).loose(),B({id:F().min(1),filename:F().min(1)}).loose(),fo(`existed`,[B({existed:U(!1)}).loose(),B({existed:U(!0),filename:F().min(1),scheme:bY}).loose()]),B({themes:z(fo(`ok`,[B({ok:U(!0),id:F().min(1),filename:F().min(1),scheme:bY}),B({ok:U(!1),filename:F().min(1),id:F().min(1).optional(),code:F().min(1),conflictingFilenames:z(F().min(1)).min(2).optional()})])),truncated:L()}).loose();const xY=H([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),SY=B({label:F().min(1),webUrl:ro().nullable()}).loose(),CY=fo(`checkStatus`,[B({checkStatus:U(`allowed`)}).loose(),B({checkStatus:U(`denied`),deniedReason:H([`no-collaborator`,`private-no-access`,`repo-not-found`,`not-authenticated`]),resolvedLogin:F().optional(),declaredLogin:F().optional(),declaredSource:F().optional()}).loose(),B({checkStatus:U(`unknown`),unknownError:H([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`,`ssh-unverified`]).optional()}).loose()]),wY=H([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`auth-not-found-as-identity`,`semantic-protected-branch`]),TY=H(Xne),EY=H([`succeeded`,`up-to-date`,`conflict`,`refused`,`error`]);B({state:xY,lastSyncUtc:F().nullable(),lastFetchUtc:F().nullable(),lastPushedSha:F().nullable(),ahead:I().int().min(0),behind:I().int().min(0),consecutiveFailures:I().int().min(0),conflictCount:I().int().min(0),hasRemote:L(),syncEnabled:L(),identityUnresolved:L(),remote:SY.nullable().optional(),pushError:F().optional(),pushErrorCode:wY.optional(),pullError:F().optional(),pullErrorCode:wY.optional(),pausedReason:F().optional(),pushPermission:CY.optional(),syncMode:TY.optional(),lastPullUtc:F().nullable().optional(),lastPullOutcome:EY.nullable().optional()}).loose(),B({op:H([`sync`,`push`,`pull`]).optional()}).loose(),B({op:H([`sync`,`push`,`pull`])}).loose(),B({conflicts:z(B({file:F().min(1),detectedAt:F().min(1),oursSha:F().optional(),theirsSha:F().optional(),baseSha:F().optional()}).loose())}).loose(),B({file:F().min(1),strategy:H([`mine`,`theirs`,`content`,`delete`]),content:F().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),B({}).loose(),B({file:F().min(1),base:F(),ours:F(),theirs:F(),kind:H([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:F().nullable()}).loose(),B({plan:To(e=>e!==void 0,{message:`plan is required`})}).loose(),B({plan:To(e=>e!==void 0,{message:`plan is required`})}).loose(),B({result:To(e=>e!==void 0,{message:`result is required`})}).loose(),B({packId:F().min(1)}).strict(),B({installedHosts:z(F()),skills:z(B({name:F().min(1),created:L()}).strict())}).strict();const DY=B({path:F().min(1),summary:F().min(1)}).loose(),OY=B({files:I().int().nonnegative(),folders:I().int().nonnegative()}).loose();B({packs:z(B({id:F().min(1),name:F().min(1),description:F().min(1),defaultSubfolder:F().optional(),folders:z(DY),entryCounts:OY}).loose())}).loose(),B({noOpen:L().optional(),out:F().min(1).optional()}).loose();const kY=B({reason:H([`unsupported-platform`,`spawn-error`]),message:F()}).loose();fo(`status`,[B({status:U(`installed`),outputPath:F(),size:I().int().nonnegative(),sha256:F(),skillVersion:F()}).loose(),B({status:U(`built`),outputPath:F(),size:I().int().nonnegative(),sha256:F(),skillVersion:F(),handoffError:kY.optional()}).loose(),B({status:U(`failed`),buildError:F()}).loose(),B({status:U(`skip-current`),skillVersion:F(),recordedAt:F().optional()}).loose()]);const AY=H(Rl),jY=H(zl),MY=B({alwaysOn:I().int().nonnegative(),onTrigger:I().int().nonnegative(),onDemand:I().int().nonnegative()}).strict();B({tags:z(B({name:F().min(1),count:I().int().nonnegative(),isLeaf:L()}).loose())}).loose();const NY=B({docName:F().min(1),title:F(),matchingTags:z(F().min(1)),snippet:F().nullable()}).loose();B({name:F().min(1),docs:z(NY)}).loose(),B({folder:R(),frontmatter_local:V(F(),R()).nullable()}).loose(),B({path:F(),frontmatter:V(F(),R()).optional()}).loose(),B({applied:R()}).loose();const PY=V(F(),R()).meta({description:`Free-form frontmatter map embedded in template payloads.`});B({template:B({name:F().min(1),folder:F(),scope:H([`local`,`inherited`]),path:F().min(1),frontmatter:PY,body:F()}).strict()}).strict(),B({templates:z(B({name:F().min(1),title:F().optional(),description:F().optional(),path:F().min(1),source_folder:F()}).strict()),truncated:L()}).strict(),B({folder:F(),name:F(),body:F().optional(),frontmatter:PY.optional(),...rw,summary:iw}).strict(),B({path:F().min(1),created:L(),warnings:z(F())}).strict(),B({sourcePath:F().min(1),targetFolder:F(),name:F().optional(),title:F().optional(),deleteSource:L().optional(),...rw,summary:iw}).strict(),B({path:F().min(1),created:L(),warnings:z(F())}).strict(),B({existed:L(),path:F().min(1)}).strict(),B({fromFolder:F(),fromName:F(),toFolder:F(),toName:F(),body:F().optional(),frontmatter:PY.optional(),...rw,summary:iw}).strict(),B({from:F().min(1),to:F().min(1),committed:L()}).strict();const FY=H(Al),IY=/^[a-z0-9-]+$/,LY=B({name:F(),description:F(),metadata:B({pack:F()}).strict().optional()}).strict();B({skill:B({name:F().min(1),scope:FY,path:F().min(1),frontmatter:LY,body:F(),files:z(B({path:F().min(1),text:F().nullable()})).optional(),managed:L().optional()}).strict()}).strict();const RY=B({source:F().min(1),publisher:F().optional(),skill:F().optional(),marketplaceUrl:F().optional(),importedAt:F().min(1),autoUpdate:L().optional()}).strict(),zY=B({name:F().min(1),description:F().optional(),scope:FY,path:F().min(1),canonicalPath:F().min(1).optional(),filePaths:z(F()).optional(),absolutePath:F().min(1).optional(),installed:L(),hosts:z(F()),hostQualifier:F().optional().meta({description:"Set on a GLOBAL entry that shares its name with a distinct-content bundle in another host dir AND is not the by-name default: the host id whose root holds THIS bundle. Doc-name builders append it (`__skill__/global/<name>@<host>`) so each same-named bundle keeps its own tab and its own write-back path; the default bundle keeps the stable unqualified name."}),driftPaths:z(F()).optional().meta({description:`Recorded locations whose on-disk form (copy vs symlink) no longer matches what OK last wrote there — evidence another tool rewrote the path.`}),hostAliases:V(F(),F()).optional().meta({description:`Host skills roots that are symlink ALIASES of another location (host id → base-relative target root). An aliased folder is a derived view — no menu row, never a write target; the host's icon rides the target root's row.`}),conflictHosts:z(F()).optional().meta({description:`Hosts whose dir holds a DIFFERENT same-name skill (fork/conflict) — occupied, not this skill.`}),symlinkedHosts:z(F()).optional(),installableEditors:z(F()).optional(),linkMode:L().optional(),customPlacements:z(B({path:F(),mode:H([`copy`,`link`])}).strict()).optional(),plugin:B({name:F().min(1),marketplace:F().min(1),provider:F().min(1),url:F().optional()}).strict().optional(),managed:L().optional(),origin:RY.optional(),pack:F().optional(),modified:L().optional(),revertable:L().optional(),ignored:L().optional(),size:MY.optional()}).strict();B({name:F().min(1),scope:FY,apply:L().optional()}).strict(),B({line:F().min(1),gitignorePath:F().min(1),applied:L(),alreadyTracked:L().optional()}).strict(),B({skills:z(zY),truncated:L()}).strict(),B({scope:FY.default(`project`),name:F().meta({description:`Managed skill name to create or update.`}),body:F().optional(),frontmatter:LY,...rw,summary:iw}).strict(),B({path:F().min(1),created:L(),warnings:z(F())}).strict(),B({scope:FY.default(`project`),name:F(),dryRun:L().optional(),setAutoUpdate:L().optional(),...rw,summary:iw}).strict(),B({name:F().min(1),updated:L(),source:F().min(1),localBody:F().optional(),upstreamBody:F().optional(),gitTracked:L().optional(),warnings:z(F())}).strict(),B({scope:FY.default(`project`),name:F(),...rw,summary:iw}).strict(),B({name:F().min(1),baselineRef:F().min(1),restoredFiles:z(F()),warnings:z(F())}).strict(),B({existed:L(),path:F().min(1)}).strict(),B({scope:FY.default(`project`),fromName:F(),toName:F(),body:F().optional(),frontmatter:LY.optional(),...rw,summary:iw}).strict(),B({from:F().min(1),to:F().min(1),committed:L()}).strict(),B({name:F(),fromScope:FY,toScope:FY,...rw,summary:iw}).strict(),B({scope:FY,path:F().optional()}).strict(),B({scope:FY,name:F(),toName:F(),...rw,summary:iw}).strict(),B({name:F().min(1)}).strict(),B({name:F(),home:F().min(1)}).strict(),B({docName:F().min(1)}).strict();const BY=H([`reference`,`script`,`file`]);B({scope:FY.default(`project`),name:F(),path:F().min(1),content:F(),...rw,summary:iw}).strict(),B({path:F().min(1),created:L(),kind:BY,content:L()}).strict(),B({scope:FY.default(`project`),name:F(),from:F().min(1),to:F().min(1),...rw,summary:iw}).strict(),B({from:F().min(1),to:F().min(1),fromDocName:F().optional(),toDocName:F().optional()}).strict(),B({path:F().min(1),kind:BY,text:F()}).strict(),B({path:F().min(1),existed:L(),kind:BY}).strict();const VY=uo([jY,U(`agents`)]),HY=F().min(1).refine(e=>!e.startsWith(`/`)&&!e.startsWith(`~`)&&!/^[A-Za-z]:/.test(e),{error:`a custom root is base-relative (e.g. ".tim/skills"), not absolute or ~-prefixed`}).refine(e=>e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),{error:`a custom root may not contain "..", "." or empty path segments`}).refine(e=>e.includes(`/`),{error:`a custom root is a path (e.g. ".tim/skills") — bare editor names are host ids`}),UY=uo([VY,HY]);B({scope:FY.default(`project`),name:F(),targets:z(VY).optional().meta({description:'SET-EXACT install targets (editor ids, plus "agents" for the .agents hub — in-place skills only): the COMPLETE resulting host set. Omit to use project-configured editors; pass [] to uninstall everywhere. Stateless callers should prefer `add`/`remove`.'}),add:z(UY).optional().meta({description:`Locations to ADD the skill to (everything else untouched). Editor ids fan out a managed copy/symlink; a custom root path (".tim/skills") places the bundle there.`}),remove:z(UY).optional().meta({description:"Locations to REMOVE the skill from (lossless only — a hand-edited fork is refused, never deleted). The source cannot be removed; move it first with `source`."}),mode:H([`copy`,`link`]).optional().meta({description:`"link": one real folder (the source); every other location becomes a symlink to it. "copy": independent real folders, refreshed from the source until hand-edited (a hand-edit forks that copy). Converts existing locations losslessly. Omit to follow the form the skill already uses.`}),source:UY.optional().meta({description:`Move the skill's REAL folder to this location (the old source becomes a symlink to it — never a removal). Sticky across rescans.`}),linkMode:L().optional(),setSource:F().min(1).optional(),place:B({dir:F().min(1).meta({description:`Project-relative directory the bundle dir is created under (e.g. ".windsurf/skills").`}),mode:H([`copy`,`link`])}).strict().optional(),convert:B({target:UY.meta({description:`The installed location to convert — an editor id, "agents", or a recorded custom placement path.`}),mode:H([`copy`,`link`]).meta({description:`"link": replace this location with a symlink to the source. "copy": replace it with an independent real folder.`})}).strict().optional(),unplace:B({path:F().min(1).meta({description:`The recorded placement bundle path (e.g. ".windsurf/skills/my-skill").`})}).strict().optional(),...rw,summary:iw,fork:B({editor:F().min(1),action:H([`align`,`make-source`,`rename`]),toName:F().optional()}).strict().optional()}).strict().refine(e=>!(e.targets!==void 0&&(e.add!==void 0||e.remove!==void 0)),{error:"`targets` is set-exact; `add`/`remove` are additive — use one style per call"}).refine(e=>e.fork===void 0||e.targets===void 0&&e.add===void 0&&e.remove===void 0&&e.source===void 0&&e.setSource===void 0,{error:"`fork` is its own operation — run it in a separate call"}).refine(e=>e.fork?.action!==`rename`||e.fork.toName!==void 0,{error:"`fork.rename` requires `toName`"}).refine(e=>!(e.source!==void 0&&(e.add!==void 0||e.remove!==void 0)),{error:"a `source` move is its own operation — run it in a separate call from `add`/`remove`"}).refine(e=>[e.targets!==void 0||e.add!==void 0||e.remove!==void 0,e.place!==void 0,e.unplace!==void 0,e.convert!==void 0,e.source!==void 0||e.setSource!==void 0,e.fork!==void 0].filter(Boolean).length<=1,{error:"one operation per call — membership (`targets`/`add`/`remove`), `place`, `unplace`, `convert`, `source`, and `fork` are mutually exclusive"}),B({name:F().min(1).meta({description:`Managed skill name installed or uninstalled.`}),hosts:z(F()).meta({description:`Editor ids the skill is projected into after the operation; [] is expected after uninstall.`}),scripts:L().meta({description:`True when the skill ships executable scripts, projected but never run.`}),warnings:z(F()).meta({description:`Non-fatal install/uninstall warnings from target projection.`}),warningCodes:z(H([`no-targets`,`scripts-present`,`name-conflict`,`no-description`,`skill-fork-name-unpatched`,`place-path-invalid`,`place-fork-refused`])).meta({description:"Machine-readable warning codes aligned with `warnings`."}),placedAt:F().optional(),sourceMovedTo:F().optional()}).strict(),B({scope:FY.default(`project`),name:F().meta({description:`Managed skill name to uninstall without deleting source.`})}).strict(),B({name:F().min(1).meta({description:`Managed skill name requested for uninstall.`}),uninstalled:L().meta({description:`True when an install marker existed and was removed; false for an idempotent no-op.`})}).strict(),B({targets:z(AY),configured:L(),folders:z(B({scope:FY,host:F(),root:F(),state:H([`own`,`linked`,`linked-parent`,`absent`]),target:F().optional(),drift:U(!0).optional(),expected:F().optional()}).strict()).optional()}).strict();const WY=B({action:U(`link`),scope:FY,root:F().min(1).meta({description:`The folder to link (e.g. ".codex/skills").`}),target:F().min(1).meta({description:`The root it merges into (e.g. ".agents/skills"). Required.`})}),GY=B({action:U(`unlink`),scope:FY,root:F().min(1).meta({description:`The linked folder to materialize back.`}),exclude:z(F().min(1)).optional().meta({description:`Skill names to LEAVE OUT when materializing — the folder keeps every other skill it currently sees (as per-skill links) and stops auto-following the target root.`})}).strict(),KY=B({action:U(`add-root`),scope:FY,root:HY.meta({description:`New custom skills root to declare (base-relative, e.g. ".team/skills").`})}).strict(),qY=fo(`action`,[WY.extend({preview:L().optional().meta({description:`Return the merge plan only (moves, drops, removes, conflicts, strays) — nothing is written.`})}).strict(),GY,KY]);fo(`action`,[WY.strict(),GY,KY]),B({folderAction:qY}).strict();const JY=B({moves:z(F()),drops:z(F()),removes:z(F()),replaces:z(F()),conflicts:z(F()),strays:z(F())}).strict();B({targets:z(AY),reprojected:z(B({name:F(),hosts:z(F())}).strict()),bundleHosts:z(F()),removedFrom:z(F()),folder:B({moved:z(F()),dropped:z(F()),linked:z(F())}).strict().optional(),preview:JY.optional()}).strict(),B({scope:FY.default(`project`),name:F(),version:F().regex(/^[0-9a-f]{40}$/i),...rw,summary:iw}).strict(),B({name:F().min(1),version:F(),restoredFiles:z(F()),warnings:z(F())}).strict(),B({query:F().optional(),intent:H([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:H([`navigation`,`relevance`]).optional(),scopes:z(H([`page`,`folder`,`content`,`file`])).optional(),scope:F().optional(),limit:I().int().nonnegative().optional(),semantic:L().optional(),source:H([`omnibar`,`mcp`,`http`]).optional()}).loose();const YY=B({kind:H([`page`,`folder`,`content`,`file`]),path:F().min(1),title:F(),score:I(),signals:V(F(),R()),snippet:F().optional()}).loose(),XY=B({capable:L(),applied:L(),coverage:B({embedded:I().int().nonnegative(),total:I().int().nonnegative()})}).loose();B({enabled:L(),keyPresent:L(),keyNotRequired:L(),keySource:H([`project`,`file`,`env`]).nullable(),keyHint:F().nullable(),ready:L(),capable:L(),embedded:I().int().nonnegative(),total:I().int().nonnegative()}).loose(),B({query:F(),intent:H([`autocomplete`,`full_text`,`omnibar`]),results:z(YY),elapsedMs:I().nonnegative(),semantic:XY.optional(),truncated:L().optional(),ready:L().optional()}).loose();const ZY=B({version:F().min(1),recordedAt:F().min(1)}).loose();B({currentVersion:F().min(1),targets:V(F(),ZY.nullable())}).loose(),B({scope:FY.default(`project`),source:F().min(1).meta({description:`External skill source: full skills.sh skill-page URL (https://www.skills.sh/<owner>/<repo>/<skill>, or https://www.skills.sh/site/<hostname>/<skill> for a website catalog), GitHub owner/repo[/subpath], git URL, or local/file path.`}),skill:F().min(1).optional().meta({description:`Specific skill name to import from a multi-skill source.`}),install:L().optional().meta({description:`Pass false to import WITHOUT the default-editor auto-projection (the caller installs explicitly afterwards). Default true.`}),marketplace:L().optional().meta({description:"The source came from a skills.sh listing the user chose (the Explore tab), so the install is reported to skills.sh and counts toward that listing. Off by default: a hand-typed repo must not be announced to skills.sh. Honors the `telemetry.skillInstallReports.enabled` setting and DO_NOT_TRACK."}),...rw,summary:iw}).strict(),B({scope:FY.default(`project`),source:F().min(1).meta({description:`External skill source: full skills.sh skill-page URL, GitHub owner/repo[/subpath], git URL, or local/file path.`}),skills:z(F().min(1)).min(1).max(100).meta({description:`Skill names to import from the source.`}),install:L().optional().meta({description:`Pass false to import WITHOUT the default-editor auto-projection. Default true.`}),marketplace:L().optional().meta({description:"The source came from a skills.sh listing the user chose (a marketplace plugin bundle), so the import is reported to skills.sh as one batched install event and counts toward that listing. Off by default: a hand-typed repo must not be announced to skills.sh. Honors the `telemetry.skillInstallReports.enabled` setting and DO_NOT_TRACK."}),...rw,summary:iw}).strict(),B({results:z(B({requested:F(),status:H([`imported`,`already-imported`,`not-found`,`failed`]),name:F().optional(),collisionRenamedFrom:F().optional(),warnings:z(F()),error:F().optional()}).loose()),imported:I(),alreadyImported:I(),failed:I()}).loose(),B({scope:FY.default(`project`),names:z(F().min(1)).min(1).max(100).meta({description:`Managed skill names to refresh from their recorded upstreams.`}),...rw,summary:iw}).strict(),B({results:z(B({requested:F(),status:H([`updated`,`up-to-date`,`not-found`,`failed`]),source:F().optional(),warnings:z(F()),error:F().optional()}).loose()),updated:I(),upToDate:I(),failed:I()}).loose();const QY=B({source:F(),ref:F().optional(),contentHash:F(),publisher:F().optional()}).loose();B({name:F().min(1).meta({description:`Managed skill name created or matched.`}),path:F().min(1).meta({description:`Store-relative path to the imported skill source.`}),created:L().meta({description:`True when this request created new source files.`}),alreadyImported:L().meta({description:`True when identical content was already present and no files changed.`}),collisionRenamedFrom:F().optional().meta({description:`Original source name when collision handling renamed the import.`}),provenance:QY,warnings:z(F()).meta({description:`Non-fatal import warnings, such as skipped unsupported files.`})}).loose();const $Y=H([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`,`comments`,`lint-config`,`local-targets`]);B({v:U(1),ch:U(`server-info`),seq:I(),serverInstanceId:F().min(1),currentBranch:F().min(1).optional()}).loose(),B({v:U(1),ch:U(`branch-switched`),seq:I(),branch:F().min(1)}).loose(),B({v:U(1),ch:$Y,seq:I()}).loose(),B({v:U(1),ch:U(`disk-ack`),seq:I(),docName:F().min(1),sv:F().min(1)}).loose(),B({v:U(1),ch:U(`config-validation-rejected`),seq:I(),docName:F().min(1),error:fl}).loose(),B({v:U(1),ch:U(`config-ignore-nested-error`),seq:I(),path:F().min(1),error:F().min(1)}).loose();var eX=e(i(((e,t)=>{var n=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},r=-1,i=1,a=0;n.Diff=function(e,t){return[e,t]},n.prototype.diff_main=function(e,t,r,i){i===void 0&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+this.Diff_Timeout*1e3);var o=i;if(e==null||t==null)throw Error(`Null input. (diff_main)`);if(e==t)return e?[new n.Diff(a,e)]:[];r===void 0&&(r=!0);var s=r,c=this.diff_commonPrefix(e,t),l=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=this.diff_commonSuffix(e,t);var u=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var d=this.diff_compute_(e,t,s,o);return l&&d.unshift(new n.Diff(a,l)),u&&d.push(new n.Diff(a,u)),this.diff_cleanupMerge(d),d},n.prototype.diff_compute_=function(e,t,o,s){var c;if(!e)return[new n.Diff(i,t)];if(!t)return[new n.Diff(r,e)];var l=e.length>t.length?e:t,u=e.length>t.length?t:e,d=l.indexOf(u);if(d!=-1)return c=[new n.Diff(i,l.substring(0,d)),new n.Diff(a,u),new n.Diff(i,l.substring(d+u.length))],e.length>t.length&&(c[0][0]=c[2][0]=r),c;if(u.length==1)return[new n.Diff(r,e),new n.Diff(i,t)];var f=this.diff_halfMatch_(e,t);if(f){var p=f[0],m=f[1],h=f[2],g=f[3],_=f[4],v=this.diff_main(p,h,o,s),y=this.diff_main(m,g,o,s);return v.concat([new n.Diff(a,_)],y)}return o&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,s):this.diff_bisect_(e,t,s)},n.prototype.diff_lineMode_=function(e,t,o){var s=this.diff_linesToChars_(e,t);e=s.chars1,t=s.chars2;var c=s.lineArray,l=this.diff_main(e,t,!1,o);this.diff_charsToLines_(l,c),this.diff_cleanupSemantic(l),l.push(new n.Diff(a,``));for(var u=0,d=0,f=0,p=``,m=``;u<l.length;){switch(l[u][0]){case i:f++,m+=l[u][1];break;case r:d++,p+=l[u][1];break;case a:if(d>=1&&f>=1){l.splice(u-d-f,d+f),u=u-d-f;for(var h=this.diff_main(p,m,!1,o),g=h.length-1;g>=0;g--)l.splice(u,0,h[g]);u+=h.length}f=0,d=0,p=``,m=``;break}u++}return l.pop(),l},n.prototype.diff_bisect_=function(e,t,a){for(var o=e.length,s=t.length,c=Math.ceil((o+s)/2),l=c,u=2*c,d=Array(u),f=Array(u),p=0;p<u;p++)d[p]=-1,f[p]=-1;d[l+1]=0,f[l+1]=0;for(var m=o-s,h=m%2!=0,g=0,_=0,v=0,y=0,b=0;b<c&&!(new Date().getTime()>a);b++){for(var x=-b+g;x<=b-_;x+=2){for(var S=l+x,C=x==-b||x!=b&&d[S-1]<d[S+1]?d[S+1]:d[S-1]+1,w=C-x;C<o&&w<s&&e.charAt(C)==t.charAt(w);)C++,w++;if(d[S]=C,C>o)_+=2;else if(w>s)g+=2;else if(h){var T=l+m-x;if(T>=0&&T<u&&f[T]!=-1){var E=o-f[T];if(C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}for(var D=-b+v;D<=b-y;D+=2){for(var T=l+D,E=D==-b||D!=b&&f[T-1]<f[T+1]?f[T+1]:f[T-1]+1,O=E-D;E<o&&O<s&&e.charAt(o-E-1)==t.charAt(s-O-1);)E++,O++;if(f[T]=E,E>o)y+=2;else if(O>s)v+=2;else if(!h){var S=l+m-D;if(S>=0&&S<u&&d[S]!=-1){var C=d[S],w=l+C-S;if(E=o-E,C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}}return[new n.Diff(r,e),new n.Diff(i,t)]},n.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,o,!1,i),u=this.diff_main(s,c,!1,i);return l.concat(u)},n.prototype.diff_linesToChars_=function(e,t){var n=[],r={};n[0]=``;function i(e){for(var t=``,i=0,o=-1,s=n.length;o<e.length-1;){o=e.indexOf(`
415
415
  `,i),o==-1&&(o=e.length-1);var c=e.substring(i,o+1);(r.hasOwnProperty?r.hasOwnProperty(c):r[c]!==void 0)?t+=String.fromCharCode(r[c]):(s==a&&(c=e.substring(i),o=e.length),t+=String.fromCharCode(s),r[c]=s,n[s++]=c),i=o+1}return t}var a=4e4,o=i(e);return a=65535,{chars1:o,chars2:i(t),lineArray:n}},n.prototype.diff_charsToLines_=function(e,t){for(var n=0;n<e.length;n++){for(var r=e[n][1],i=[],a=0;a<r.length;a++)i[a]=t[r.charCodeAt(a)];e[n][1]=i.join(``)}},n.prototype.diff_commonPrefix=function(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return i},n.prototype.diff_commonSuffix=function(e,t){if(!e||!t||e.charAt(e.length-1)!=t.charAt(t.length-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return i},n.prototype.diff_commonOverlap_=function(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,(c==0||e.substring(i-o)==t.substring(0,o))&&(a=o,o++)}},n.prototype.diff_halfMatch_=function(e,t){if(this.Diff_Timeout<=0)return null;var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;var i=this;function a(e,t,n){for(var r=e.substring(n,n+Math.floor(e.length/4)),a=-1,o=``,s,c,l,u;(a=t.indexOf(r,a+1))!=-1;){var d=i.diff_commonPrefix(e.substring(n),t.substring(a)),f=i.diff_commonSuffix(e.substring(0,n),t.substring(0,a));o.length<f+d&&(o=t.substring(a-f,a)+t.substring(a,a+d),s=e.substring(0,n-f),c=e.substring(n+d),l=t.substring(0,a-f),u=t.substring(a+d))}return o.length*2>=e.length?[s,c,l,u,o]:null}var o=a(n,r,Math.ceil(n.length/4)),s=a(n,r,Math.ceil(n.length/2)),c;if(!o&&!s)return null;c=s?o&&o[4].length>s[4].length?o:s:o;var l,u,d,f;e.length>t.length?(l=c[0],u=c[1],d=c[2],f=c[3]):(d=c[0],f=c[1],l=c[2],u=c[3]);var p=c[4];return[l,u,d,f,p]},n.prototype.diff_cleanupSemantic=function(e){for(var t=!1,o=[],s=0,c=null,l=0,u=0,d=0,f=0,p=0;l<e.length;)e[l][0]==a?(o[s++]=l,u=f,d=p,f=0,p=0,c=e[l][1]):(e[l][0]==i?f+=e[l][1].length:p+=e[l][1].length,c&&c.length<=Math.max(u,d)&&c.length<=Math.max(f,p)&&(e.splice(o[s-1],0,new n.Diff(r,c)),e[o[s-1]+1][0]=i,s--,s--,l=s>0?o[s-1]:-1,u=0,d=0,f=0,p=0,c=null,t=!0)),l++;for(t&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),l=1;l<e.length;){if(e[l-1][0]==r&&e[l][0]==i){var m=e[l-1][1],h=e[l][1],g=this.diff_commonOverlap_(m,h),_=this.diff_commonOverlap_(h,m);g>=_?(g>=m.length/2||g>=h.length/2)&&(e.splice(l,0,new n.Diff(a,h.substring(0,g))),e[l-1][1]=m.substring(0,m.length-g),e[l+1][1]=h.substring(g),l++):(_>=m.length/2||_>=h.length/2)&&(e.splice(l,0,new n.Diff(a,m.substring(0,_))),e[l-1][0]=i,e[l-1][1]=h.substring(0,h.length-_),e[l+1][0]=r,e[l+1][1]=m.substring(_),l++),l++}l++}},n.prototype.diff_cleanupSemanticLossless=function(e){function t(e,t){if(!e||!t)return 6;var r=e.charAt(e.length-1),i=t.charAt(0),a=r.match(n.nonAlphaNumericRegex_),o=i.match(n.nonAlphaNumericRegex_),s=a&&r.match(n.whitespaceRegex_),c=o&&i.match(n.whitespaceRegex_),l=s&&r.match(n.linebreakRegex_),u=c&&i.match(n.linebreakRegex_),d=l&&e.match(n.blanklineEndRegex_),f=u&&t.match(n.blanklineStartRegex_);return d||f?5:l||u?4:a&&!s&&c?3:s||c?2:a||o?1:0}for(var r=1;r<e.length-1;){if(e[r-1][0]==a&&e[r+1][0]==a){var i=e[r-1][1],o=e[r][1],s=e[r+1][1],c=this.diff_commonSuffix(i,o);if(c){var l=o.substring(o.length-c);i=i.substring(0,i.length-c),o=l+o.substring(0,o.length-c),s=l+s}for(var u=i,d=o,f=s,p=t(i,o)+t(o,s);o.charAt(0)===s.charAt(0);){i+=o.charAt(0),o=o.substring(1)+s.charAt(0),s=s.substring(1);var m=t(i,o)+t(o,s);m>=p&&(p=m,u=i,d=o,f=s)}e[r-1][1]!=u&&(u?e[r-1][1]=u:(e.splice(r-1,1),r--),e[r][1]=d,f?e[r+1][1]=f:(e.splice(r+1,1),r--))}r++}},n.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,n.whitespaceRegex_=/\s/,n.linebreakRegex_=/[\r\n]/,n.blanklineEndRegex_=/\n\r?\n$/,n.blanklineStartRegex_=/^\r?\n\r?\n/,n.prototype.diff_cleanupEfficiency=function(e){for(var t=!1,o=[],s=0,c=null,l=0,u=!1,d=!1,f=!1,p=!1;l<e.length;)e[l][0]==a?(e[l][1].length<this.Diff_EditCost&&(f||p)?(o[s++]=l,u=f,d=p,c=e[l][1]):(s=0,c=null),f=p=!1):(e[l][0]==r?p=!0:f=!0,c&&(u&&d&&f&&p||c.length<this.Diff_EditCost/2&&u+d+f+p==3)&&(e.splice(o[s-1],0,new n.Diff(r,c)),e[o[s-1]+1][0]=i,s--,c=null,u&&d?(f=p=!0,s=0):(s--,l=s>0?o[s-1]:-1,f=p=!1),t=!0)),l++;t&&this.diff_cleanupMerge(e)},n.prototype.diff_cleanupMerge=function(e){e.push(new n.Diff(a,``));for(var t=0,o=0,s=0,c=``,l=``,u;t<e.length;)switch(e[t][0]){case i:s++,l+=e[t][1],t++;break;case r:o++,c+=e[t][1],t++;break;case a:o+s>1?(o!==0&&s!==0&&(u=this.diff_commonPrefix(l,c),u!==0&&(t-o-s>0&&e[t-o-s-1][0]==a?e[t-o-s-1][1]+=l.substring(0,u):(e.splice(0,0,new n.Diff(a,l.substring(0,u))),t++),l=l.substring(u),c=c.substring(u)),u=this.diff_commonSuffix(l,c),u!==0&&(e[t][1]=l.substring(l.length-u)+e[t][1],l=l.substring(0,l.length-u),c=c.substring(0,c.length-u))),t-=o+s,e.splice(t,o+s),c.length&&(e.splice(t,0,new n.Diff(r,c)),t++),l.length&&(e.splice(t,0,new n.Diff(i,l)),t++),t++):t!==0&&e[t-1][0]==a?(e[t-1][1]+=e[t][1],e.splice(t,1)):t++,s=0,o=0,c=``,l=``;break}e[e.length-1][1]===``&&e.pop();var d=!1;for(t=1;t<e.length-1;)e[t-1][0]==a&&e[t+1][0]==a&&(e[t][1].substring(e[t][1].length-e[t-1][1].length)==e[t-1][1]?(e[t][1]=e[t-1][1]+e[t][1].substring(0,e[t][1].length-e[t-1][1].length),e[t+1][1]=e[t-1][1]+e[t+1][1],e.splice(t-1,1),d=!0):e[t][1].substring(0,e[t+1][1].length)==e[t+1][1]&&(e[t-1][1]+=e[t+1][1],e[t][1]=e[t][1].substring(e[t+1][1].length)+e[t+1][1],e.splice(t+1,1),d=!0)),t++;d&&this.diff_cleanupMerge(e)},n.prototype.diff_xIndex=function(e,t){var n=0,a=0,o=0,s=0,c;for(c=0;c<e.length&&(e[c][0]!==i&&(n+=e[c][1].length),e[c][0]!==r&&(a+=e[c][1].length),!(n>t));c++)o=n,s=a;return e.length!=c&&e[c][0]===r?s:s+(t-o)},n.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,o=/</g,s=/>/g,c=/\n/g,l=0;l<e.length;l++){var u=e[l][0],d=e[l][1].replace(n,`&amp;`).replace(o,`&lt;`).replace(s,`&gt;`).replace(c,`&para;<br>`);switch(u){case i:t[l]=`<ins style="background:#e6ffe6;">`+d+`</ins>`;break;case r:t[l]=`<del style="background:#ffe6e6;">`+d+`</del>`;break;case a:t[l]=`<span>`+d+`</span>`;break}}return t.join(``)},n.prototype.diff_text1=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==i&&(t[n]=e[n][1]);return t.join(``)},n.prototype.diff_text2=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==r&&(t[n]=e[n][1]);return t.join(``)},n.prototype.diff_levenshtein=function(e){for(var t=0,n=0,o=0,s=0;s<e.length;s++){var c=e[s][0],l=e[s][1];switch(c){case i:n+=l.length;break;case r:o+=l.length;break;case a:t+=Math.max(n,o),n=0,o=0;break}}return t+=Math.max(n,o),t},n.prototype.diff_toDelta=function(e){for(var t=[],n=0;n<e.length;n++)switch(e[n][0]){case i:t[n]=`+`+encodeURI(e[n][1]);break;case r:t[n]=`-`+e[n][1].length;break;case a:t[n]=`=`+e[n][1].length;break}return t.join(` `).replace(/%20/g,` `)},n.prototype.diff_fromDelta=function(e,t){for(var o=[],s=0,c=0,l=t.split(/\t/g),u=0;u<l.length;u++){var d=l[u].substring(1);switch(l[u].charAt(0)){case`+`:try{o[s++]=new n.Diff(i,decodeURI(d))}catch{throw Error(`Illegal escape in diff_fromDelta: `+d)}break;case`-`:case`=`:var f=parseInt(d,10);if(isNaN(f)||f<0)throw Error(`Invalid number in diff_fromDelta: `+d);var p=e.substring(c,c+=f);l[u].charAt(0)==`=`?o[s++]=new n.Diff(a,p):o[s++]=new n.Diff(r,p);break;default:if(l[u])throw Error(`Invalid diff operation in diff_fromDelta: `+l[u])}}if(c!=e.length)throw Error(`Delta length (`+c+`) does not equal source text length (`+e.length+`).`);return o},n.prototype.match_main=function(e,t,n){if(e==null||t==null||n==null)throw Error(`Null input. (match_main)`);return n=Math.max(0,Math.min(n,e.length)),e==t?0:e.length?e.substring(n,n+t.length)==t?n:this.match_bitap_(e,t,n):-1},n.prototype.match_bitap_=function(e,t,n){if(t.length>this.Match_MaxBits)throw Error(`Pattern too long for this browser.`);var r=this.match_alphabet_(t),i=this;function a(e,r){var a=e/t.length,o=Math.abs(n-r);return i.Match_Distance?a+o/i.Match_Distance:o?1:a}var o=this.Match_Threshold,s=e.indexOf(t,n);s!=-1&&(o=Math.min(a(0,s),o),s=e.lastIndexOf(t,n+t.length),s!=-1&&(o=Math.min(a(0,s),o)));var c=1<<t.length-1;s=-1;for(var l,u,d=t.length+e.length,f,p=0;p<t.length;p++){for(l=0,u=d;l<u;)a(p,n+u)<=o?l=u:d=u,u=Math.floor((d-l)/2+l);d=u;var m=Math.max(1,n-u+1),h=Math.min(n+u,e.length)+t.length,g=Array(h+2);g[h+1]=(1<<p)-1;for(var _=h;_>=m;_--){var v=r[e.charAt(_-1)];if(p===0?g[_]=(g[_+1]<<1|1)&v:g[_]=(g[_+1]<<1|1)&v|(f[_+1]|f[_])<<1|1|f[_+1],g[_]&c){var y=a(p,_-1);if(y<=o)if(o=y,s=_-1,s>n)m=Math.max(1,2*n-s);else break}}if(a(p+1,n)>o)break;f=g}return s},n.prototype.match_alphabet_=function(e){for(var t={},n=0;n<e.length;n++)t[e.charAt(n)]=0;for(var n=0;n<e.length;n++)t[e.charAt(n)]|=1<<e.length-n-1;return t},n.prototype.patch_addContext_=function(e,t){if(t.length!=0){if(e.start2===null)throw Error(`patch not initialized`);for(var r=t.substring(e.start2,e.start2+e.length1),i=0;t.indexOf(r)!=t.lastIndexOf(r)&&r.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)i+=this.Patch_Margin,r=t.substring(e.start2-i,e.start2+e.length1+i);i+=this.Patch_Margin;var o=t.substring(e.start2-i,e.start2);o&&e.diffs.unshift(new n.Diff(a,o));var s=t.substring(e.start2+e.length1,e.start2+e.length1+i);s&&e.diffs.push(new n.Diff(a,s)),e.start1-=o.length,e.start2-=o.length,e.length1+=o.length+s.length,e.length2+=o.length+s.length}},n.prototype.patch_make=function(e,t,o){var s,c;if(typeof e==`string`&&typeof t==`string`&&o===void 0)s=e,c=this.diff_main(s,t,!0),c.length>2&&(this.diff_cleanupSemantic(c),this.diff_cleanupEfficiency(c));else if(e&&typeof e==`object`&&t===void 0&&o===void 0)c=e,s=this.diff_text1(c);else if(typeof e==`string`&&t&&typeof t==`object`&&o===void 0)s=e,c=t;else if(typeof e==`string`&&typeof t==`string`&&o&&typeof o==`object`)s=e,c=o;else throw Error(`Unknown call format to patch_make.`);if(c.length===0)return[];for(var l=[],u=new n.patch_obj,d=0,f=0,p=0,m=s,h=s,g=0;g<c.length;g++){var _=c[g][0],v=c[g][1];switch(!d&&_!==a&&(u.start1=f,u.start2=p),_){case i:u.diffs[d++]=c[g],u.length2+=v.length,h=h.substring(0,p)+v+h.substring(p);break;case r:u.length1+=v.length,u.diffs[d++]=c[g],h=h.substring(0,p)+h.substring(p+v.length);break;case a:v.length<=2*this.Patch_Margin&&d&&c.length!=g+1?(u.diffs[d++]=c[g],u.length1+=v.length,u.length2+=v.length):v.length>=2*this.Patch_Margin&&d&&(this.patch_addContext_(u,m),l.push(u),u=new n.patch_obj,d=0,m=h,f=p);break}_!==i&&(f+=v.length),_!==r&&(p+=v.length)}return d&&(this.patch_addContext_(u,m),l.push(u)),l},n.prototype.patch_deepCopy=function(e){for(var t=[],r=0;r<e.length;r++){var i=e[r],a=new n.patch_obj;a.diffs=[];for(var o=0;o<i.diffs.length;o++)a.diffs[o]=new n.Diff(i.diffs[o][0],i.diffs[o][1]);a.start1=i.start1,a.start2=i.start2,a.length1=i.length1,a.length2=i.length2,t[r]=a}return t},n.prototype.patch_apply=function(e,t){if(e.length==0)return[t,[]];e=this.patch_deepCopy(e);var n=this.patch_addPadding(e);t=n+t+n,this.patch_splitMax(e);for(var o=0,s=[],c=0;c<e.length;c++){var l=e[c].start2+o,u=this.diff_text1(e[c].diffs),d,f=-1;if(u.length>this.Match_MaxBits?(d=this.match_main(t,u.substring(0,this.Match_MaxBits),l),d!=-1&&(f=this.match_main(t,u.substring(u.length-this.Match_MaxBits),l+u.length-this.Match_MaxBits),(f==-1||d>=f)&&(d=-1))):d=this.match_main(t,u,l),d==-1)s[c]=!1,o-=e[c].length2-e[c].length1;else{s[c]=!0,o=d-l;var p=f==-1?t.substring(d,d+u.length):t.substring(d,f+this.Match_MaxBits);if(u==p)t=t.substring(0,d)+this.diff_text2(e[c].diffs)+t.substring(d+u.length);else{var m=this.diff_main(u,p,!1);if(u.length>this.Match_MaxBits&&this.diff_levenshtein(m)/u.length>this.Patch_DeleteThreshold)s[c]=!1;else{this.diff_cleanupSemanticLossless(m);for(var h=0,g,_=0;_<e[c].diffs.length;_++){var v=e[c].diffs[_];v[0]!==a&&(g=this.diff_xIndex(m,h)),v[0]===i?t=t.substring(0,d+g)+v[1]+t.substring(d+g):v[0]===r&&(t=t.substring(0,d+g)+t.substring(d+this.diff_xIndex(m,h+v[1].length))),v[0]!==r&&(h+=v[1].length)}}}}}return t=t.substring(n.length,t.length-n.length),[t,s]},n.prototype.patch_addPadding=function(e){for(var t=this.Patch_Margin,r=``,i=1;i<=t;i++)r+=String.fromCharCode(i);for(var i=0;i<e.length;i++)e[i].start1+=t,e[i].start2+=t;var o=e[0],s=o.diffs;if(s.length==0||s[0][0]!=a)s.unshift(new n.Diff(a,r)),o.start1-=t,o.start2-=t,o.length1+=t,o.length2+=t;else if(t>s[0][1].length){var c=t-s[0][1].length;s[0][1]=r.substring(s[0][1].length)+s[0][1],o.start1-=c,o.start2-=c,o.length1+=c,o.length2+=c}if(o=e[e.length-1],s=o.diffs,s.length==0||s[s.length-1][0]!=a)s.push(new n.Diff(a,r)),o.length1+=t,o.length2+=t;else if(t>s[s.length-1][1].length){var c=t-s[s.length-1][1].length;s[s.length-1][1]+=r.substring(0,c),o.length1+=c,o.length2+=c}return r},n.prototype.patch_splitMax=function(e){for(var t=this.Match_MaxBits,o=0;o<e.length;o++)if(!(e[o].length1<=t)){var s=e[o];e.splice(o--,1);for(var c=s.start1,l=s.start2,u=``;s.diffs.length!==0;){var d=new n.patch_obj,f=!0;for(d.start1=c-u.length,d.start2=l-u.length,u!==``&&(d.length1=d.length2=u.length,d.diffs.push(new n.Diff(a,u)));s.diffs.length!==0&&d.length1<t-this.Patch_Margin;){var p=s.diffs[0][0],m=s.diffs[0][1];p===i?(d.length2+=m.length,l+=m.length,d.diffs.push(s.diffs.shift()),f=!1):p===r&&d.diffs.length==1&&d.diffs[0][0]==a&&m.length>2*t?(d.length1+=m.length,c+=m.length,f=!1,d.diffs.push(new n.Diff(p,m)),s.diffs.shift()):(m=m.substring(0,t-d.length1-this.Patch_Margin),d.length1+=m.length,c+=m.length,p===a?(d.length2+=m.length,l+=m.length):f=!1,d.diffs.push(new n.Diff(p,m)),m==s.diffs[0][1]?s.diffs.shift():s.diffs[0][1]=s.diffs[0][1].substring(m.length))}u=this.diff_text2(d.diffs),u=u.substring(u.length-this.Patch_Margin);var h=this.diff_text1(s.diffs).substring(0,this.Patch_Margin);h!==``&&(d.length1+=h.length,d.length2+=h.length,d.diffs.length!==0&&d.diffs[d.diffs.length-1][0]===a?d.diffs[d.diffs.length-1][1]+=h:d.diffs.push(new n.Diff(a,h))),f||e.splice(++o,0,d)}}},n.prototype.patch_toText=function(e){for(var t=[],n=0;n<e.length;n++)t[n]=e[n];return t.join(``)},n.prototype.patch_fromText=function(e){var t=[];if(!e)return t;for(var o=e.split(`
416
416
  `),s=0,c=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;s<o.length;){var l=o[s].match(c);if(!l)throw Error(`Invalid patch string: `+o[s]);var u=new n.patch_obj;for(t.push(u),u.start1=parseInt(l[1],10),l[2]===``?(u.start1--,u.length1=1):l[2]==`0`?u.length1=0:(u.start1--,u.length1=parseInt(l[2],10)),u.start2=parseInt(l[3],10),l[4]===``?(u.start2--,u.length2=1):l[4]==`0`?u.length2=0:(u.start2--,u.length2=parseInt(l[4],10)),s++;s<o.length;){var d=o[s].charAt(0);try{var f=decodeURI(o[s].substring(1))}catch{throw Error(`Illegal escape in patch_fromText: `+f)}if(d==`-`)u.diffs.push(new n.Diff(r,f));else if(d==`+`)u.diffs.push(new n.Diff(i,f));else if(d==` `)u.diffs.push(new n.Diff(a,f));else if(d==`@`)break;else if(d!==``)throw Error(`Invalid patch mode "`+d+`" in: `+f);s++}}return t},n.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0},n.patch_obj.prototype.toString=function(){for(var e=this.length1===0?this.start1+`,0`:this.length1==1?this.start1+1:this.start1+1+`,`+this.length1,t=this.length2===0?this.start2+`,0`:this.length2==1?this.start2+1:this.start2+1+`,`+this.length2,n=[`@@ -`+e+` +`+t+` @@
417
417
  `],o,s=0;s<this.diffs.length;s++){switch(this.diffs[s][0]){case i:o=`+`;break;case r:o=`-`;break;case a:o=` `;break}n[s+1]=o+encodeURI(this.diffs[s][1])+`
@@ -431,29 +431,33 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
431
431
  `){return e.split(n).reduce((e,n)=>{let r=t?n.trim():n;return r&&e.push(r),e},[])}function x1(e,t){return b1(e,!0).map(e=>t(e))}function S1(e){return(0,J$.exists)(e,J$.FOLDER)}function C1(e,t){return Array.isArray(e)?e.includes(t)||e.push(t):e.add(t),t}function hge(e,t){return Array.isArray(e)&&!e.includes(t)&&e.push(t),e}function w1(e,t){if(Array.isArray(e)){let n=e.indexOf(t);n>=0&&e.splice(n,1)}else e.delete(t);return t}function T1(e){return Array.isArray(e)?e:[e]}function E1(e){return e.replace(/[\s-]+(.)/g,(e,t)=>t.toUpperCase())}function D1(e){return T1(e).map(e=>e instanceof String?e:String(e))}function O1(e,t=0){if(e==null)return t;let n=parseInt(e,10);return Number.isNaN(n)?t:n}function k1(e,t){let n=[];for(let r=0,i=e.length;r<i;r++)n.push(t,e[r]);return n}function A1(e){return(Array.isArray(e)?Buffer.concat(e):e).toString(`utf-8`)}function gge(e,t){let n={};return t.forEach(t=>{e[t]!==void 0&&(n[t]=e[t])}),n}function _ge(e=0){return new Promise(t=>setTimeout(t,e))}function j1(e){if(e!==!1)return e}var M1,N1,P1,F1=a1({"src/lib/utils/util.ts"(){G1(),M1=`\0`,N1=()=>{},P1=Object.prototype.toString.call.bind(Object.prototype.toString)}});function I1(e,t,n){return t(e)?e:arguments.length>2?n:void 0}function L1(e,t){let n=Z$(e)?`string`:typeof e;return/number|string|boolean/.test(n)&&(!t||!t.includes(n))}function R1(e){return!!e&&P1(e)===`[object Object]`}function z1(e){return typeof e==`function`}var B1,V1,H1,U1,W1,G1=a1({"src/lib/utils/argument-filters.ts"(){F1(),B1=e=>Array.isArray(e),V1=e=>typeof e==`number`,H1=e=>typeof e==`string`||Z$(e),U1=e=>H1(e)||Array.isArray(e)&&e.every(H1),W1=e=>e==null||`number|boolean|function`.includes(typeof e)?!1:typeof e.length==`number`}}),K1,vge=a1({"src/lib/utils/exit-codes.ts"(){K1=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e[e.ERROR=1]=`ERROR`,e[e.NOT_FOUND=-2]=`NOT_FOUND`,e[e.UNCLEAN=128]=`UNCLEAN`,e))(K1||{})}}),q1,yge=a1({"src/lib/utils/git-output-streams.ts"(){q1=class e{constructor(e,t){this.stdOut=e,this.stdErr=t}asStrings(){return new e(this.stdOut.toString(`utf8`),this.stdErr.toString(`utf8`))}}}});function bge(){throw Error(`LineParser:useMatches not implemented`)}var J1,Y1,xge=a1({"src/lib/utils/line-parser.ts"(){J1=class{constructor(e,t){this.matches=[],this.useMatches=bge,this.parse=(e,t)=>(this.resetMatches(),this._regExp.every((t,n)=>this.addMatch(t,n,e(n)))?this.useMatches(t,this.prepareMatches())!==!1:!1),this._regExp=Array.isArray(e)?e:[e],t&&(this.useMatches=t)}resetMatches(){this.matches.length=0}prepareMatches(){return this.matches}addMatch(e,t,n){let r=n&&e.exec(n);return r&&this.pushMatch(t,r),!!r}pushMatch(e,t){this.matches.push(...t.slice(1))}},Y1=class extends J1{addMatch(e,t,n){return/^remote:\s/.test(String(n))&&super.addMatch(e,t,n)}pushMatch(e,t){(e>0||t.length>1)&&super.pushMatch(e,t)}}}});function Sge(...e){let t=process.cwd(),n=Object.assign({baseDir:t,...X1},...e.filter(e=>typeof e==`object`&&e));return n.baseDir=n.baseDir||t,n.trimmed=n.trimmed===!0,n}var X1,Cge=a1({"src/lib/utils/simple-git-options.ts"(){X1={binary:`git`,maxConcurrentProcesses:5,config:[],trimmed:!1}}});function Z1(e,t=[]){return R1(e)?Object.keys(e).reduce((t,n)=>{let r=e[n];if(Z$(r))t.push(r);else if(L1(r,[`boolean`]))t.push(n+`=`+r);else if(Array.isArray(r))for(let e of r)L1(e,[`string`,`number`])||t.push(n+`=`+e);else t.push(n);return t},t):t}function Q1(e,t=0,n=!1){let r=[];for(let n=0,i=t<0?e.length:t;n<i;n++)`string|number`.includes(typeof e[n])&&r.push(String(e[n]));return Z1($1(e),r),n||r.push(...wge(e)),r}function wge(e){return D1(I1(v1(e,+(typeof v1(e)==`function`)),B1,[]))}function $1(e){return I1(v1(e,+!!z1(v1(e))),R1)}function e0(e,t=!0){let n=m1(v1(e));return t||h1(n)?n:void 0}var Tge=a1({"src/lib/utils/task-options.ts"(){G1(),F1()}});function t0(e,t){return e(t.stdOut,t.stdErr)}function n0(e,t,n,r=!0){return T1(n).forEach(n=>{for(let i=b1(n,r),a=0,o=i.length;a<o;a++){let n=(e=0)=>{if(!(a+e>=o))return i[a+e]};t.some(({parse:t})=>t(n,e))}}),e}var Ege=a1({"src/lib/utils/task-parser.ts"(){F1()}}),r0={};o1(r0,{ExitCodes:()=>K1,GitOutputStreams:()=>q1,LineParser:()=>J1,NOOP:()=>N1,NULL:()=>M1,RemoteLineParser:()=>Y1,append:()=>C1,appendTaskOptions:()=>Z1,asArray:()=>T1,asCamelCase:()=>E1,asFunction:()=>m1,asNumber:()=>O1,asStringArray:()=>D1,bufferToString:()=>A1,callTaskParser:()=>t0,createInstanceConfig:()=>Sge,delay:()=>_ge,filterArray:()=>B1,filterFunction:()=>z1,filterHasLength:()=>W1,filterNumber:()=>V1,filterPlainObject:()=>R1,filterPrimitives:()=>L1,filterString:()=>H1,filterStringOrStringArray:()=>U1,filterType:()=>I1,first:()=>_1,folderExists:()=>S1,forEachLineWithContent:()=>x1,getTrailingOptions:()=>Q1,including:()=>hge,isUserFunction:()=>h1,last:()=>v1,objectToString:()=>P1,orVoid:()=>j1,parseStringResponse:()=>n0,pick:()=>gge,prefixedArray:()=>k1,remove:()=>w1,splitOn:()=>g1,toLinesWithContent:()=>b1,trailingFunctionArgument:()=>e0,trailingOptionsArgument:()=>$1});var i0=a1({"src/lib/utils/index.ts"(){G1(),vge(),yge(),xge(),Cge(),Tge(),Ege(),F1()}}),a0={};o1(a0,{CheckRepoActions:()=>c0,checkIsBareRepoTask:()=>s0,checkIsRepoRootTask:()=>o0,checkIsRepoTask:()=>Dge});function Dge(e){switch(e){case`bare`:return s0();case`root`:return o0()}return{commands:[`rev-parse`,`--is-inside-work-tree`],format:`utf-8`,onError:l0,parser:u0}}function o0(){return{commands:[`rev-parse`,`--git-dir`],format:`utf-8`,onError:l0,parser(e){return/^\.(git)?$/.test(e.trim())}}}function s0(){return{commands:[`rev-parse`,`--is-bare-repository`],format:`utf-8`,onError:l0,parser:u0}}function Oge(e){return/(Not a git repository|Kein Git-Repository)/i.test(String(e))}var c0,l0,u0,d0=a1({"src/lib/tasks/check-is-repo.ts"(){i0(),c0=(e=>(e.BARE=`bare`,e.IN_TREE=`tree`,e.IS_REPO_ROOT=`root`,e))(c0||{}),l0=({exitCode:e},t,n,r)=>{if(e===128&&Oge(t))return n(Buffer.from(`false`));r(t)},u0=e=>e.trim()===`true`}});function kge(e,t){let n=new f0(e),r=e?m0:p0;return b1(t).forEach(e=>{let t=e.replace(r,``);n.paths.push(t),(h0.test(t)?n.folders:n.files).push(t)}),n}var f0,p0,m0,h0,Age=a1({"src/lib/responses/CleanSummary.ts"(){i0(),f0=class{constructor(e){this.dryRun=e,this.paths=[],this.files=[],this.folders=[]}},p0=/^[a-z]+\s*/i,m0=/^[a-z]+\s+[a-z]+\s*/i,h0=/\/$/}}),g0={};o1(g0,{EMPTY_COMMANDS:()=>C0,adhocExecTask:()=>_0,configurationErrorTask:()=>v0,isBufferTask:()=>x0,isEmptyTask:()=>S0,straightThroughBufferTask:()=>b0,straightThroughStringTask:()=>y0});function _0(e){return{commands:C0,format:`empty`,parser:e}}function v0(e){return{commands:C0,format:`empty`,parser(){throw typeof e==`string`?new f1(e):e}}}function y0(e,t=!1){return{commands:e,format:`utf-8`,parser(e){return t?String(e).trim():e}}}function b0(e){return{commands:e,format:`buffer`,parser(e){return e}}}function x0(e){return e.format===`buffer`}function S0(e){return e.format===`empty`||!e.commands.length}var C0,w0=a1({"src/lib/tasks/task.ts"(){p1(),C0=[]}}),T0={};o1(T0,{CONFIG_ERROR_INTERACTIVE_MODE:()=>D0,CONFIG_ERROR_MODE_REQUIRED:()=>O0,CONFIG_ERROR_UNKNOWN_OPTION:()=>k0,CleanOptions:()=>A0,cleanTask:()=>E0,cleanWithOptionsTask:()=>jge,isCleanOptionsArray:()=>Mge});function jge(e,t){let{cleanMode:n,options:r,valid:i}=Nge(e);return n?i.options?(r.push(...t),r.some(Ige)?v0(D0):E0(n,r)):v0(k0+JSON.stringify(e)):v0(O0)}function E0(e,t){return{commands:[`clean`,`-${e}`,...t],format:`utf-8`,parser(t){return kge(e===`n`,t)}}}function Mge(e){return Array.isArray(e)&&e.every(e=>j0.has(e))}function Nge(e){let t,n=[],r={cleanMode:!1,options:!0};return e.replace(/[^a-z]i/g,``).split(``).forEach(e=>{Pge(e)?(t=e,r.cleanMode=!0):r.options=r.options&&Fge(n[n.length]=`-${e}`)}),{cleanMode:t,options:n,valid:r}}function Pge(e){return e===`f`||e===`n`}function Fge(e){return/^-[a-z]$/i.test(e)&&j0.has(e.charAt(1))}function Ige(e){return/^-[^\-]/.test(e)?e.indexOf(`i`)>0:e===`--interactive`}var D0,O0,k0,A0,j0,M0=a1({"src/lib/tasks/clean.ts"(){Age(),i0(),w0(),D0=`Git clean interactive mode is not supported`,O0=`Git clean mode parameter ("n" or "f") is required`,k0=`Git clean unknown option found in: `,A0=(e=>(e.DRY_RUN=`n`,e.FORCE=`f`,e.IGNORED_INCLUDED=`x`,e.IGNORED_ONLY=`X`,e.EXCLUDING=`e`,e.QUIET=`q`,e.RECURSIVE=`d`,e))(A0||{}),j0=new Set([`i`,...D1(Object.values(A0))])}});function Lge(e){let t=new P0;for(let n of N0(e))t.addValue(n.file,String(n.key),n.value);return t}function Rge(e,t){let n=null,r=[],i=new Map;for(let a of N0(e,t))a.key===t&&(r.push(n=a.value),i.has(a.file)||i.set(a.file,[]),i.get(a.file).push(n));return{key:t,paths:Array.from(i.keys()),scopes:i,value:n,values:r}}function zge(e){return e.replace(/^(file):/,``)}function*N0(e,t=null){let n=e.split(`\0`);for(let e=0,r=n.length-1;e<r;){let r=zge(n[e++]),i=n[e++],a=t;if(i.includes(`
432
432
  `)){let e=g1(i,`
433
433
  `);a=e[0],i=e[1]}yield{file:r,key:a,value:i}}}var P0,Bge=a1({"src/lib/responses/ConfigList.ts"(){i0(),P0=class{constructor(){this.files=[],this.values=Object.create(null)}get all(){return this._all||=this.files.reduce((e,t)=>Object.assign(e,this.values[t]),{}),this._all}addFile(e){if(!(e in this.values)){let t=v1(this.files);this.values[e]=t?Object.create(this.values[t]):{},this.files.push(e)}return this.values[e]}addValue(e,t,n){let r=this.addFile(e);Object.hasOwn(r,t)?Array.isArray(r[t])?r[t].push(n):r[t]=[r[t],n]:r[t]=n,this._all=void 0}}}});function F0(e,t){return typeof e==`string`&&Object.hasOwn(I0,e)?e:t}function Vge(e,t,n,r){let i=[`config`,`--${r}`];return n&&i.push(`--add`),i.push(e,t),{commands:i,format:`utf-8`,parser(e){return e}}}function Hge(e,t){let n=[`config`,`--null`,`--show-origin`,`--get-all`,e];return t&&n.splice(1,0,`--${t}`),{commands:n,format:`utf-8`,parser(t){return Rge(t,e)}}}function Uge(e){let t=[`config`,`--list`,`--show-origin`,`--null`];return e&&t.push(`--${e}`),{commands:t,format:`utf-8`,parser(e){return Lge(e)}}}function Wge(){return{addConfig(e,t,...n){return this._runTask(Vge(e,t,n[0]===!0,F0(n[1],`local`)),e0(arguments))},getConfig(e,t){return this._runTask(Hge(e,F0(t,void 0)),e0(arguments))},listConfig(...e){return this._runTask(Uge(F0(e[0],void 0)),e0(arguments))}}}var I0,L0=a1({"src/lib/tasks/config.ts"(){Bge(),i0(),I0=(e=>(e.system=`system`,e.global=`global`,e.local=`local`,e.worktree=`worktree`,e))(I0||{})}});function Gge(e){return z0.has(e)}var R0,z0,B0=a1({"src/lib/tasks/diff-name-status.ts"(){R0=(e=>(e.ADDED=`A`,e.COPIED=`C`,e.DELETED=`D`,e.MODIFIED=`M`,e.RENAMED=`R`,e.CHANGED=`T`,e.UNMERGED=`U`,e.UNKNOWN=`X`,e.BROKEN=`B`,e))(R0||{}),z0=new Set(Object.values(R0))}});function Kge(...e){return new W0().param(...e)}function qge(e){let t=new Set,n={};return x1(e,e=>{let[r,i,a]=e.split(M1);t.add(r),(n[r]=n[r]||[]).push({line:O1(i),path:r,preview:a})}),{paths:t,results:n}}function Jge(){return{grep(e){let t=e0(arguments),n=Q1(arguments);for(let e of V0)if(n.includes(e))return this._runTask(v0(`git.grep: use of "${e}" is not supported.`),t);typeof e==`string`&&(e=Kge().param(e));let r=[`grep`,`--null`,`-n`,`--full-name`,...n,...e];return this._runTask({commands:r,format:`utf-8`,parser(e){return qge(e)}},t)}}}var V0,H0,U0,W0,G0=a1({"src/lib/tasks/grep.ts"(){i0(),w0(),V0=[`-h`],H0=Symbol(`grepQuery`),W0=class{constructor(){this[U0]=[]}*[(U0=H0,Symbol.iterator)](){for(let e of this[H0])yield e}and(...e){return e.length&&this[H0].push(`--and`,`(`,...k1(e,`-e`),`)`),this}param(...e){return this[H0].push(...k1(e,`-e`)),this}}}}),K0={};o1(K0,{ResetMode:()=>J0,getResetMode:()=>Xge,resetTask:()=>Yge});function Yge(e,t){let n=[`reset`];return q0(e)&&n.push(`--${e}`),n.push(...t),y0(n)}function Xge(e){if(q0(e))return e;switch(typeof e){case`string`:case`undefined`:return`soft`}}function q0(e){return typeof e==`string`&&Y0.includes(e)}var J0,Y0,X0=a1({"src/lib/tasks/reset.ts"(){i0(),w0(),J0=(e=>(e.MIXED=`mixed`,e.SOFT=`soft`,e.HARD=`hard`,e.MERGE=`merge`,e.KEEP=`keep`,e))(J0||{}),Y0=D1(Object.values(J0))}});function Zge(){return(0,Q$.default)(`simple-git`)}function Z0(e,t,n){return!t||!String(t).replace(/\s*/,``)?n?(t,...r)=>{e(t,...r),n(t,...r)}:e:(r,...i)=>{e(`%s ${r}`,t,...i),n&&n(r,...i)}}function Qge(e,t,{namespace:n}){if(typeof e==`string`)return e;let r=t&&t.namespace||``;return r.startsWith(n)?r.substr(n.length+1):r||n}function Q0(e,t,n,r=Zge()){let i=e&&`[${e}]`||``,a=[],o=typeof t==`string`?r.extend(t):t,s=Qge(I1(t,H1),o,r);return l(n);function c(t,n){return C1(a,Q0(e,s.replace(/^[^:]+/,t),n,r))}function l(t){let n=t&&`[${t}]`||``,a=o&&Z0(o,n)||N1,s=Z0(r,`${i} ${n}`,a);return Object.assign(o?a:s,{label:e,sibling:c,info:s,step:l})}}var $0=a1({"src/lib/git-logger.ts"(){i0(),Q$.default.formatters.L=e=>String(W1(e)?e.length:`-`),Q$.default.formatters.B=e=>Buffer.isBuffer(e)?e.toString(`utf8`):P1(e)}}),e2,$ge=a1({"src/lib/runners/tasks-pending-queue.ts"(){l1(),$0(),e2=class e{constructor(e=`GitExecutor`){this.logLabel=e,this._queue=new Map}withProgress(e){return this._queue.get(e)}createProgress(t){let n=e.getName(t.commands[0]);return{task:t,logger:Q0(this.logLabel,n),name:n}}push(e){let t=this.createProgress(e);return t.logger(`Adding task to the queue, commands = %o`,e.commands),this._queue.set(e,t),t}fatal(e){for(let[t,{logger:n}]of Array.from(this._queue.entries()))t===e.task?(n.info(`Failed %o`,e),n(`Fatal exception, any as-yet un-started tasks run through this executor will not be attempted`)):n.info(`A fatal exception occurred in a previous task, the queue has been purged: %o`,e.message),this.complete(t);if(this._queue.size!==0)throw Error(`Queue size should be zero after fatal: ${this._queue.size}`)}complete(e){this.withProgress(e)&&this._queue.delete(e)}attempt(e){let t=this.withProgress(e);if(!t)throw new c1(void 0,`TasksPendingQueue: attempt called for an unknown task`);return t.logger(`Starting task`),t}static getName(t=`empty`){return`task:${t}:${++e.counter}`}static{this.counter=0}}}});function t2(e,t){return{method:_1(e.commands)||``,commands:t}}function e_e(e,t){return n=>{t(`[ERROR] child process exception %o`,n),e.push(Buffer.from(String(n.stack),`ascii`))}}function n2(e,t,n,r){return i=>{n(`%s received %L bytes`,t,i),r(`%B`,i),e.push(i)}}var r2,t_e=a1({"src/lib/runners/git-executor-chain.ts"(){l1(),w0(),i0(),$ge(),r2=class{constructor(e,t,n){this._executor=e,this._scheduler=t,this._plugins=n,this._chain=Promise.resolve(),this._queue=new e2}get cwd(){return this._cwd||this._executor.cwd}set cwd(e){this._cwd=e}get env(){return this._executor.env}get outputHandler(){return this._executor.outputHandler}chain(){return this}push(e){return this._queue.push(e),this._chain=this._chain.then(()=>this.attemptTask(e))}async attemptTask(e){let t=await this._scheduler.next(),n=()=>this._queue.complete(e);try{let{logger:t}=this._queue.attempt(e);return await(S0(e)?this.attemptEmptyTask(e,t):this.attemptRemoteTask(e,t))}catch(t){throw this.onFatalException(e,t)}finally{n(),t()}}onFatalException(e,t){let n=t instanceof c1?Object.assign(t,{task:e}):new c1(e,t&&String(t));return this._chain=Promise.resolve(),this._queue.fatal(n),n}async attemptRemoteTask(e,t){let n=this._plugins.exec(`spawn.binary`,``,t2(e,e.commands)),r=this._plugins.exec(`spawn.args`,[...e.commands],{...t2(e,e.commands),env:{...this.env}}),i=await this.gitResponse(e,n,r,this.outputHandler,t.step(`SPAWN`)),a=await this.handleTaskData(e,r,i,t.step(`HANDLE`));return t(`passing response to task's parser as a %s`,e.format),x0(e)?t0(e.parser,a):t0(e.parser,a.asStrings())}async attemptEmptyTask(e,t){return t(`empty task bypassing child process to call to task's parser`),e.parser(this)}handleTaskData(e,t,n,r){let{exitCode:i,rejection:a,stdOut:o,stdErr:s}=n;return new Promise((c,l)=>{r(`Preparing to handle process response exitCode=%d stdOut=`,i);let{error:u}=this._plugins.exec(`task.error`,{error:a},{...t2(e,t),...n});if(u&&e.onError)return r.info(`exitCode=%s handling with custom error handler`),e.onError(n,u,e=>{r.info(`custom error handler treated as success`),r(`custom error returned a %s`,P1(e)),c(new q1(Array.isArray(e)?Buffer.concat(e):e,Buffer.concat(s)))},l);if(u)return r.info(`handling as error: exitCode=%s stdErr=%s rejection=%o`,i,s.length,a),l(u);r.info(`retrieving task output complete`),c(new q1(Buffer.concat(o),Buffer.concat(s)))})}async gitResponse(e,t,n,r,i){let a=i.sibling(`output`),o=this._plugins.exec(`spawn.options`,{cwd:this.cwd,env:this.env,windowsHide:!0},t2(e,e.commands));return new Promise(s=>{let c=[],l=[];i.info(`%s %o`,t,n),i(`%O`,o);let u=this._beforeSpawn(e,n);if(u)return s({stdOut:c,stdErr:l,exitCode:9901,rejection:u});this._plugins.exec(`spawn.before`,void 0,{...t2(e,n),kill(e){u=e||u}});let d=Pe(t,n,o);d.stdout.on(`data`,n2(c,`stdOut`,i,a.step(`stdOut`))),d.stderr.on(`data`,n2(l,`stdErr`,i,a.step(`stdErr`))),d.on(`error`,e_e(l,i)),r&&(i(`Passing child process stdOut/stdErr to custom outputHandler`),r(t,d.stdout,d.stderr,[...n])),this._plugins.exec(`spawn.after`,void 0,{...t2(e,n),spawned:d,close(e,t){s({stdOut:c,stdErr:l,exitCode:e,rejection:u||t})},kill(e){d.killed||(u=e,d.kill(`SIGINT`))}})})}_beforeSpawn(e,t){let n;return this._plugins.exec(`spawn.before`,void 0,{...t2(e,t),kill(e){n=e||n}}),n}}}}),i2={};o1(i2,{GitExecutor:()=>a2});var a2,n_e=a1({"src/lib/runners/git-executor.ts"(){t_e(),a2=class{constructor(e,t,n){this.cwd=e,this._scheduler=t,this._plugins=n,this._chain=new r2(this,this._scheduler,this._plugins)}chain(){return new r2(this,this._scheduler,this._plugins)}push(e){return this._chain.push(e)}}}});function r_e(e,t,n=N1){t.then(e=>{n(null,e)},t=>{t?.task===e&&n(t instanceof u1?i_e(t):t,void 0)})}function i_e(e){let t=e=>{console.warn(`simple-git deprecation notice: accessing GitResponseError.${e} should be GitResponseError.git.${e}, this will no longer be available in version 3`),t=N1};return Object.create(e,Object.getOwnPropertyNames(e.git).reduce(n,{}));function n(n,r){return r in e||(n[r]={enumerable:!1,configurable:!1,get(){return t(r),e.git[r]}}),n}}var a_e=a1({"src/lib/task-callback.ts"(){d1(),i0()}});function o2(e,t){return _0(n=>{if(!S1(e))throw Error(`Git.cwd: cannot change to non-directory "${e}"`);return(t||n).cwd=e})}var o_e=a1({"src/lib/tasks/change-working-directory.ts"(){i0(),w0()}});function s2(e){let t=[`checkout`,...e];return t[1]===`-b`&&t.includes(`-B`)&&(t[1]=w1(t,`-B`)),y0(t)}function s_e(){return{checkout(){return this._runTask(s2(Q1(arguments,1)),e0(arguments))},checkoutBranch(e,t){return this._runTask(s2([`-b`,e,t,...Q1(arguments)]),e0(arguments))},checkoutLocalBranch(e){return this._runTask(s2([`-b`,e,...Q1(arguments)]),e0(arguments))}}}var c_e=a1({"src/lib/tasks/checkout.ts"(){i0(),w0()}});function l_e(){return{count:0,garbage:0,inPack:0,packs:0,prunePackable:0,size:0,sizeGarbage:0,sizePack:0}}function u_e(){return{countObjects(){return this._runTask({commands:[`count-objects`,`--verbose`],format:`utf-8`,parser(e){return n0(l_e(),[c2],e)}})}}}var c2,d_e=a1({"src/lib/tasks/count-objects.ts"(){i0(),c2=new J1(/([a-z-]+): (\d+)$/,(e,[t,n])=>{let r=E1(t);Object.hasOwn(e,r)&&(e[r]=O1(n))})}});function f_e(e){return n0({author:null,branch:``,commit:``,root:!1,summary:{changes:0,insertions:0,deletions:0}},l2,e)}var l2,p_e=a1({"src/lib/parsers/parse-commit.ts"(){i0(),l2=[new J1(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/,(e,[t,n,r])=>{e.branch=t,e.commit=r,e.root=!!n}),new J1(/\s*Author:\s(.+)/i,(e,[t])=>{let n=t.split(`<`),r=n.pop();!r||!r.includes(`@`)||(e.author={email:r.substr(0,r.length-1),name:n.join(`<`).trim()})}),new J1(/(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g,(e,[t,n,r])=>{e.summary.changes=parseInt(t,10)||0,e.summary.insertions=parseInt(n,10)||0,e.summary.deletions=parseInt(r,10)||0}),new J1(/^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/,(e,[t,n,r])=>{e.summary.changes=parseInt(t,10)||0;let i=parseInt(n,10)||0;r===`-`?e.summary.deletions=i:r===`+`&&(e.summary.insertions=i)})]}});function m_e(e,t,n){return{commands:[`-c`,`core.abbrev=40`,`commit`,...k1(e,`-m`),...t,...n],format:`utf-8`,parser:f_e}}function h_e(){return{commit(t,...n){let r=e0(arguments),i=e(t)||m_e(T1(t),T1(I1(n[0],U1,[])),[...D1(I1(n[1],B1,[])),...Q1(arguments,0,!0)]);return this._runTask(i,r)}};function e(e){return!U1(e)&&v0(`git.commit: requires the commit message to be supplied as a string/string[]`)}}var g_e=a1({"src/lib/tasks/commit.ts"(){p_e(),i0(),w0()}});function __e(){return{firstCommit(){return this._runTask(y0([`rev-list`,`--max-parents=0`,`HEAD`],!0),e0(arguments))}}}var v_e=a1({"src/lib/tasks/first-commit.ts"(){i0(),w0()}});function y_e(e,t){let n=[`hash-object`,e];return t&&n.push(`-w`),y0(n,!0)}var b_e=a1({"src/lib/tasks/hash-object.ts"(){w0()}});function x_e(e,t,n){let r=String(n).trim(),i;if(i=d2.exec(r))return new u2(e,t,!1,i[1]);if(i=f2.exec(r))return new u2(e,t,!0,i[1]);let a=``,o=r.split(` `);for(;o.length;)if(o.shift()===`in`){a=o.join(` `);break}return new u2(e,t,/^re/i.test(r),a)}var u2,d2,f2,S_e=a1({"src/lib/responses/InitSummary.ts"(){u2=class{constructor(e,t,n,r){this.bare=e,this.path=t,this.existing=n,this.gitDir=r}},d2=/^Init.+ repository in (.+)$/,f2=/^Rein.+ in (.+)$/}});function C_e(e){return e.includes(p2)}function w_e(e=!1,t,n){let r=[`init`,...n];return e&&!C_e(r)&&r.splice(1,0,p2),{commands:r,format:`utf-8`,parser(e){return x_e(r.includes(`--bare`),t,e)}}}var p2,T_e=a1({"src/lib/tasks/init.ts"(){S_e(),p2=`--bare`}});function m2(e){for(let t=0;t<e.length;t++){let n=h2.exec(e[t]);if(n)return`--${n[1]}`}return``}function E_e(e){return h2.test(e)}var h2,g2=a1({"src/lib/args/log-format.ts"(){h2=/^--(stat|numstat|name-only|name-status)(=|$)/}}),_2,D_e=a1({"src/lib/responses/DiffSummary.ts"(){_2=class{constructor(){this.changed=0,this.deletions=0,this.insertions=0,this.files=[]}}}});function v2(e=``){let t=C2[e];return e=>n0(new _2,t,e,!1)}var y2,b2,x2,S2,C2,w2=a1({"src/lib/parsers/parse-diff-summary.ts"(){g2(),D_e(),B0(),i0(),y2=[new J1(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,(e,[t,n,r=``])=>{e.files.push({file:t.trim(),changes:O1(n),insertions:r.replace(/[^+]/g,``).length,deletions:r.replace(/[^-]/g,``).length,binary:!1})}),new J1(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/,(e,[t,n,r])=>{e.files.push({file:t.trim(),before:O1(n),after:O1(r),binary:!0})}),new J1(/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/,(e,[t,n])=>{let r=/(\d+) i/.exec(n),i=/(\d+) d/.exec(n);e.changed=O1(t),e.insertions=O1(r?.[1]),e.deletions=O1(i?.[1])})],b2=[new J1(/(\d+)\t(\d+)\t(.+)$/,(e,[t,n,r])=>{let i=O1(t),a=O1(n);e.changed++,e.insertions+=i,e.deletions+=a,e.files.push({file:r,changes:i+a,insertions:i,deletions:a,binary:!1})}),new J1(/-\t-\t(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,after:0,before:0,binary:!0})})],x2=[new J1(/(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,changes:0,insertions:0,deletions:0,binary:!1})})],S2=[new J1(/([ACDMRTUXB])([0-9]{0,3})\t(.[^\t]*)(\t(.[^\t]*))?$/,(e,[t,n,r,i,a])=>{e.changed++,e.files.push({file:a??r,changes:0,insertions:0,deletions:0,binary:!1,status:j1(Gge(t)&&t),from:j1(!!a&&r!==a&&r),similarity:O1(n)})})],C2={"":y2,"--stat":y2,"--numstat":b2,"--name-status":S2,"--name-only":x2}}});function O_e(e,t){return t.reduce((t,n,r)=>(t[n]=e[r]||``,t),Object.create({diff:null}))}function T2(e=O2,t=k2,n=``){let r=v2(n);return function(n){let i=b1(n.trim(),!1,E2).map(function(n){let i=n.split(D2),a=O_e(i[0].split(e),t);return i.length>1&&i[1].trim()&&(a.diff=r(i[1])),a});return{all:i,latest:i.length&&i[0]||null,total:i.length}}}var E2,D2,O2,k2,A2=a1({"src/lib/parsers/parse-list-log-summary.ts"(){i0(),w2(),g2(),E2=`òòòòòò `,D2=` òò`,O2=` ò `,k2=[`hash`,`date`,`message`,`refs`,`author_name`,`author_email`]}}),j2={};o1(j2,{diffSummaryTask:()=>k_e,validateLogFormatConfig:()=>M2});function k_e(e){let t=m2(e),n=[`diff`];return t===``&&(t=`--stat`,n.push(`--stat=4096`)),n.push(...e),M2(n)||{commands:n,format:`utf-8`,parser:v2(t)}}function M2(e){let t=e.filter(E_e);if(t.length>1)return v0(`Summary flags are mutually exclusive - pick one of ${t.join(`,`)}`);if(t.length&&e.includes(`-z`))return v0(`Summary flag ${t} parsing is not compatible with null termination option '-z'`)}var N2=a1({"src/lib/tasks/diff.ts"(){g2(),w2(),w0()}});function A_e(e,t){let n=[],r=[];return Object.keys(e).forEach(t=>{n.push(t),r.push(String(e[t]))}),[n,r.join(t)]}function j_e(e){return Object.keys(e).reduce((t,n)=>(n in F2||(t[n]=e[n]),t),{})}function P2(e={},t=[]){let n=I1(e.splitter,H1,O2),[r,i]=A_e(R1(e.format)?e.format:{hash:`%H`,date:e.strictDate===!1?`%ai`:`%aI`,message:`%s`,refs:`%D`,body:e.multiLine?`%B`:`%b`,author_name:e.mailMap===!1?`%an`:`%aN`,author_email:e.mailMap===!1?`%ae`:`%aE`},n),a=[],o=[`--pretty=format:${E2}${i}${D2}`,...t],s=e.n||e[`max-count`]||e.maxCount;if(s&&o.push(`--max-count=${s}`),e.from||e.to){let t=e.symmetric===!1?`..`:`...`;a.push(`${e.from||``}${t}${e.to||``}`)}return H1(e.file)&&o.push(`--follow`,X$(e.file)),Z1(j_e(e),o),{fields:r,splitter:n,commands:[...o,...a]}}function M_e(e,t,n){let r=T2(e,t,m2(n));return{commands:[`log`,...n],format:`utf-8`,parser:r}}function N_e(){return{log(...n){let r=e0(arguments),i=P2($1(arguments),D1(I1(arguments[0],B1,[]))),a=t(...n)||M2(i.commands)||e(i);return this._runTask(a,r)}};function e(e){return M_e(e.splitter,e.fields,e.commands)}function t(e,t){return H1(e)&&H1(t)&&v0(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`)}}var F2,I2=a1({"src/lib/tasks/log.ts"(){g2(),A2(),i0(),w0(),N2(),F2=(e=>(e[e[`--pretty`]=0]=`--pretty`,e[e[`max-count`]=1]=`max-count`,e[e.maxCount=2]=`maxCount`,e[e.n=3]=`n`,e[e.file=4]=`file`,e[e.format=5]=`format`,e[e.from=6]=`from`,e[e.to=7]=`to`,e[e.splitter=8]=`splitter`,e[e.symmetric=9]=`symmetric`,e[e.mailMap=10]=`mailMap`,e[e.multiLine=11]=`multiLine`,e[e.strictDate=12]=`strictDate`,e))(F2||{})}}),L2,R2,P_e=a1({"src/lib/responses/MergeSummary.ts"(){L2=class{constructor(e,t=null,n){this.reason=e,this.file=t,this.meta=n}toString(){return`${this.file}:${this.reason}`}},R2=class{constructor(){this.conflicts=[],this.merges=[],this.result=`success`}get failed(){return this.conflicts.length>0}get reason(){return this.result}toString(){return this.conflicts.length?`CONFLICTS: ${this.conflicts.join(`, `)}`:`OK`}}}}),z2,B2,F_e=a1({"src/lib/responses/PullSummary.ts"(){z2=class{constructor(){this.remoteMessages={all:[]},this.created=[],this.deleted=[],this.files=[],this.deletions={},this.insertions={},this.summary={changes:0,deletions:0,insertions:0}}},B2=class{constructor(){this.remote=``,this.hash={local:``,remote:``},this.branch={local:``,remote:``},this.message=``}toString(){return this.message}}}});function V2(e){return e.objects=e.objects||{compressing:0,counting:0,enumerating:0,packReused:0,reused:{count:0,delta:0},total:{count:0,delta:0}}}function H2(e){let t=/^\s*(\d+)/.exec(e),n=/delta (\d+)/i.exec(e);return{count:O1(t&&t[1]||`0`),delta:O1(n&&n[1]||`0`)}}var U2,I_e=a1({"src/lib/parsers/parse-remote-objects.ts"(){i0(),U2=[new Y1(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=V2(e.remoteMessages);Object.assign(i,{[r]:O1(n)})}),new Y1(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=V2(e.remoteMessages);Object.assign(i,{[r]:O1(n)})}),new Y1(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,(e,[t,n,r])=>{let i=V2(e.remoteMessages);i.total=H2(t),i.reused=H2(n),i.packReused=O1(r)})]}});function W2(e,t){return n0({remoteMessages:new K2},G2,t)}var G2,K2,q2=a1({"src/lib/parsers/parse-remote-messages.ts"(){i0(),I_e(),G2=[new Y1(/^remote:\s*(.+)$/,(e,[t])=>(e.remoteMessages.all.push(t.trim()),!1)),...U2,new Y1([/create a (?:pull|merge) request/i,/\s(https?:\/\/\S+)$/],(e,[t])=>{e.remoteMessages.pullRequestUrl=t}),new Y1([/found (\d+) vulnerabilities.+\(([^)]+)\)/i,/\s(https?:\/\/\S+)$/],(e,[t,n,r])=>{e.remoteMessages.vulnerabilities={count:O1(t),summary:n,url:r}})],K2=class{constructor(){this.all=[]}}}});function L_e(e,t){let n=n0(new B2,Q2,[e,t]);return n.message&&n}var J2,Y2,X2,Z2,Q2,$2,e4,t4=a1({"src/lib/parsers/parse-pull.ts"(){F_e(),i0(),q2(),J2=/^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/,Y2=/(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/,X2=/^(create|delete) mode \d+ (.+)/,Z2=[new J1(J2,(e,[t,n,r])=>{e.files.push(t),n&&(e.insertions[t]=n.length),r&&(e.deletions[t]=r.length)}),new J1(Y2,(e,[t,,n,,r])=>n!==void 0||r!==void 0?(e.summary.changes=+t||0,e.summary.insertions=+n||0,e.summary.deletions=+r||0,!0):!1),new J1(X2,(e,[t,n])=>{C1(e.files,n),C1(t===`create`?e.created:e.deleted,n)})],Q2=[new J1(/^from\s(.+)$/i,(e,[t])=>void(e.remote=t)),new J1(/^fatal:\s(.+)$/,(e,[t])=>void(e.message=t)),new J1(/([a-z0-9]+)\.\.([a-z0-9]+)\s+(\S+)\s+->\s+(\S+)$/,(e,[t,n,r,i])=>{e.branch.local=r,e.hash.local=t,e.branch.remote=i,e.hash.remote=n})],$2=(e,t)=>n0(new z2,Z2,[e,t]),e4=(e,t)=>Object.assign(new z2,$2(e,t),W2(e,t))}}),n4,r4,i4,R_e=a1({"src/lib/parsers/parse-merge.ts"(){P_e(),i0(),t4(),n4=[new J1(/^Auto-merging\s+(.+)$/,(e,[t])=>{e.merges.push(t)}),new J1(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/,(e,[t,n])=>{e.conflicts.push(new L2(t,n))}),new J1(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,(e,[t,n,r])=>{e.conflicts.push(new L2(t,n,{deleteRef:r}))}),new J1(/^CONFLICT\s+\((.+)\):/,(e,[t])=>{e.conflicts.push(new L2(t,null))}),new J1(/^Automatic merge failed;\s+(.+)$/,(e,[t])=>{e.result=t})],r4=(e,t)=>Object.assign(i4(e,t),e4(e,t)),i4=e=>n0(new R2,n4,e)}});function a4(e){return e.length?{commands:[`merge`,...e],format:`utf-8`,parser(e,t){let n=r4(e,t);if(n.failed)throw new u1(n);return n}}:v0(`Git.merge requires at least one option`)}var z_e=a1({"src/lib/tasks/merge.ts"(){d1(),R_e(),w0()}});function B_e(e,t,n){let r=n.includes(`deleted`),i=n.includes(`tag`)||/^refs\/tags/.test(e),a=!n.includes(`new`);return{deleted:r,tag:i,branch:!i,new:!a,alreadyUpdated:a,local:e,remote:t}}var o4,s4,c4,V_e=a1({"src/lib/parsers/parse-push.ts"(){i0(),q2(),o4=[new J1(/^Pushing to (.+)$/,(e,[t])=>{e.repo=t}),new J1(/^updating local tracking ref '(.+)'/,(e,[t])=>{e.ref={...e.ref||{},local:t}}),new J1(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/,(e,[t,n,r])=>{e.pushed.push(B_e(t,n,r))}),new J1(/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,(e,[t,n,r])=>{e.branch={...e.branch||{},local:t,remote:n,remoteName:r}}),new J1(/^([^:]+):(\S+)\s+([a-z0-9]+)\.\.([a-z0-9]+)$/,(e,[t,n,r,i])=>{e.update={head:{local:t,remote:n},hash:{from:r,to:i}}})],s4=(e,t)=>{let n=c4(e,t),r=W2(e,t);return{...n,...r}},c4=(e,t)=>n0({pushed:[]},o4,[e,t])}}),l4={};o1(l4,{pushTagsTask:()=>H_e,pushTask:()=>u4});function H_e(e={},t){return C1(t,`--tags`),u4(e,t)}function u4(e={},t){let n=[`push`,...t];return e.branch&&n.splice(1,0,e.branch),e.remote&&n.splice(1,0,e.remote),w1(n,`-v`),C1(n,`--verbose`),C1(n,`--porcelain`),{commands:n,format:`utf-8`,parser:s4}}var d4=a1({"src/lib/tasks/push.ts"(){V_e(),i0()}});function U_e(){return{showBuffer(){let e=[`show`,...Q1(arguments,1)];return e.includes(`--binary`)||e.splice(1,0,`--binary`),this._runTask(b0(e),e0(arguments))},show(){let e=[`show`,...Q1(arguments,1)];return this._runTask(y0(e),e0(arguments))}}}var W_e=a1({"src/lib/tasks/show.ts"(){i0(),w0()}}),f4,p4,G_e=a1({"src/lib/responses/FileStatusSummary.ts"(){f4=/^(.+)\0(.+)$/,p4=class{constructor(e,t,n){if(this.path=e,this.index=t,this.working_dir=n,t===`R`||n===`R`){let t=f4.exec(e)||[null,e,e];this.from=t[2]||``,this.path=t[1]||``}}}}});function m4(e){let[t,n]=e.split(M1);return{from:n||t,to:t}}function h4(e,t,n){return[`${e}${t}`,n]}function g4(e,...t){return t.map(t=>h4(e,t,(e,t)=>e.conflicted.push(t)))}function K_e(e,t){let n=t.trim();switch(` `){case n.charAt(2):return r(n.charAt(0),n.charAt(1),n.slice(3));case n.charAt(1):return r(` `,n.charAt(0),n.slice(2));default:return}function r(t,n,r){let i=`${t}${n}`,a=v4.get(i);a&&a(e,r),i!==`##`&&i!==`!!`&&e.files.push(new p4(r,t,n))}}var _4,v4,y4,q_e=a1({"src/lib/responses/StatusSummary.ts"(){i0(),G_e(),_4=class{constructor(){this.not_added=[],this.conflicted=[],this.created=[],this.deleted=[],this.ignored=void 0,this.modified=[],this.renamed=[],this.files=[],this.staged=[],this.ahead=0,this.behind=0,this.current=null,this.tracking=null,this.detached=!1,this.isClean=()=>!this.files.length}},v4=new Map([h4(` `,`A`,(e,t)=>e.created.push(t)),h4(` `,`D`,(e,t)=>e.deleted.push(t)),h4(` `,`M`,(e,t)=>e.modified.push(t)),h4(`A`,` `,(e,t)=>{e.created.push(t),e.staged.push(t)}),h4(`A`,`M`,(e,t)=>{e.created.push(t),e.staged.push(t),e.modified.push(t)}),h4(`D`,` `,(e,t)=>{e.deleted.push(t),e.staged.push(t)}),h4(`M`,` `,(e,t)=>{e.modified.push(t),e.staged.push(t)}),h4(`M`,`M`,(e,t)=>{e.modified.push(t),e.staged.push(t)}),h4(`R`,` `,(e,t)=>{e.renamed.push(m4(t))}),h4(`R`,`M`,(e,t)=>{let n=m4(t);e.renamed.push(n),e.modified.push(n.to)}),h4(`!`,`!`,(e,t)=>{(e.ignored=e.ignored||[]).push(t)}),h4(`?`,`?`,(e,t)=>e.not_added.push(t)),...g4(`A`,`A`,`U`),...g4(`D`,`D`,`U`),...g4(`U`,`A`,`D`,`U`),[`##`,(e,t)=>{let n=/ahead (\d+)/,r=/behind (\d+)/,i=/^(.+?(?=(?:\.{3}|\s|$)))/,a=/\.{3}(\S*)/,o=/\son\s(\S+?)(?=\.{3}|$)/,s=n.exec(t);e.ahead=s&&+s[1]||0,s=r.exec(t),e.behind=s&&+s[1]||0,s=i.exec(t),e.current=I1(s?.[1],H1,null),s=a.exec(t),e.tracking=I1(s?.[1],H1,null),s=o.exec(t),s&&(e.current=I1(s?.[1],H1,e.current)),e.detached=/\(no branch\)/.test(t)}]]),y4=function(e){let t=e.split(M1),n=new _4;for(let e=0,r=t.length;e<r;){let r=t[e++].trim();r&&(r.charAt(0)===`R`&&(r+=M1+(t[e++]||``)),K_e(n,r))}return n}}});function J_e(e){return{format:`utf-8`,commands:[`status`,`--porcelain`,`-b`,`-u`,`--null`,...e.filter(e=>!b4.includes(e))],parser(e){return y4(e)}}}var b4,Y_e=a1({"src/lib/tasks/status.ts"(){q_e(),b4=[`--null`,`-z`]}});function x4(e=0,t=0,n=0,r=``,i=!0){return Object.defineProperty({major:e,minor:t,patch:n,agent:r,installed:i},`toString`,{value(){return`${this.major}.${this.minor}.${this.patch}`},configurable:!1,enumerable:!1})}function X_e(){return x4(0,0,0,``,!1)}function Z_e(){return{version(){return this._runTask({commands:[`--version`],format:`utf-8`,parser:Q_e,onError(e,t,n,r){if(e.exitCode===-2)return n(Buffer.from(S4));r(t)}})}}}function Q_e(e){return e===S4?X_e():n0(x4(0,0,0,e),C4,e)}var S4,C4,$_e=a1({"src/lib/tasks/version.ts"(){i0(),S4=`installed=false`,C4=[new J1(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,(e,[t,n,r,i=``])=>{Object.assign(e,x4(O1(t),O1(n),O1(r),i))}),new J1(/version (\d+)\.(\d+)\.(\D+)(.+)?$/,(e,[t,n,r,i=``])=>{Object.assign(e,x4(O1(t),O1(n),r,i))})]}});function w4(e,t,n,...r){return H1(n)?t(n,I1(r[0],H1),Q1(arguments)):v0(`git.${e}() requires a string 'repoPath'`)}function eve(){return{clone(e,...t){return this._runTask(w4(`clone`,T4,I1(e,H1),...t),e0(arguments))},mirror(e,...t){return this._runTask(w4(`mirror`,E4,I1(e,H1),...t),e0(arguments))}}}var T4,E4,tve=a1({"src/lib/tasks/clone.ts"(){w0(),i0(),T4=(e,t,n)=>{let r=[`clone`,...n];return H1(e)&&r.push(X$(e)),H1(t)&&r.push(X$(t)),y0(r)},E4=(e,t,n)=>(C1(n,`--mirror`),T4(e,t,n))}}),D4={};o1(D4,{SimpleGitApi:()=>O4});var O4,nve=a1({"src/lib/simple-git-api.ts"(){a_e(),o_e(),c_e(),d_e(),g_e(),L0(),v_e(),G0(),b_e(),T_e(),I2(),z_e(),d4(),W_e(),Y_e(),w0(),$_e(),i0(),tve(),O4=class{constructor(e){this._executor=e}_runTask(e,t){let n=this._executor.chain(),r=n.push(e);return t&&r_e(e,r,t),Object.create(this,{then:{value:r.then.bind(r)},catch:{value:r.catch.bind(r)},_executor:{value:n}})}add(e){return this._runTask(y0([`add`,...T1(e)]),e0(arguments))}cwd(e){let t=e0(arguments);return typeof e==`string`?this._runTask(o2(e,this._executor),t):typeof e?.path==`string`?this._runTask(o2(e.path,e.root&&this._executor||void 0),t):this._runTask(v0(`Git.cwd: workingDirectory must be supplied as a string`),t)}hashObject(e,t){return this._runTask(y_e(e,t===!0),e0(arguments))}init(e){return this._runTask(w_e(e===!0,this._executor.cwd,Q1(arguments)),e0(arguments))}merge(){return this._runTask(a4(Q1(arguments)),e0(arguments))}mergeFromTo(e,t){return H1(e)&&H1(t)?this._runTask(a4([e,t,...Q1(arguments)]),e0(arguments,!1)):this._runTask(v0(`Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`))}outputHandler(e){return this._executor.outputHandler=e,this}push(){let e=u4({remote:I1(arguments[0],H1),branch:I1(arguments[1],H1)},Q1(arguments));return this._runTask(e,e0(arguments))}stash(){return this._runTask(y0([`stash`,...Q1(arguments)]),e0(arguments))}status(){return this._runTask(J_e(Q1(arguments)),e0(arguments))}},Object.assign(O4.prototype,s_e(),eve(),h_e(),Wge(),u_e(),__e(),Jge(),N_e(),U_e(),Z_e())}}),k4={};o1(k4,{Scheduler:()=>j4});var A4,j4,rve=a1({"src/lib/runners/scheduler.ts"(){i0(),$0(),A4=(()=>{let e=0;return()=>{e++;let{promise:t,done:n}=(0,$$.createDeferred)();return{promise:t,done:n,id:e}}})(),j4=class{constructor(e=2){this.concurrency=e,this.logger=Q0(``,`scheduler`),this.pending=[],this.running=[],this.logger(`Constructed, concurrency=%s`,e)}schedule(){if(!this.pending.length||this.running.length>=this.concurrency){this.logger(`Schedule attempt ignored, pending=%s running=%s concurrency=%s`,this.pending.length,this.running.length,this.concurrency);return}let e=C1(this.running,this.pending.shift());this.logger(`Attempting id=%s`,e.id),e.done(()=>{this.logger(`Completing id=`,e.id),w1(this.running,e),this.schedule()})}next(){let{promise:e,id:t}=C1(this.pending,A4());return this.logger(`Scheduling id=%s`,t),this.schedule(),e}}}}),M4={};o1(M4,{applyPatchTask:()=>ive});function ive(e,t){return y0([`apply`,...t,...e])}var ave=a1({"src/lib/tasks/apply-patch.ts"(){w0()}});function ove(e,t){return{branch:e,hash:t,success:!0}}function sve(e){return{branch:e,hash:null,success:!1}}var N4,cve=a1({"src/lib/responses/BranchDeleteSummary.ts"(){N4=class{constructor(){this.all=[],this.branches={},this.errors=[]}get success(){return!this.errors.length}}}});function P4(e,t){return t===1&&I4.test(e)}var F4,I4,L4,R4,lve=a1({"src/lib/parsers/parse-branch-delete.ts"(){cve(),i0(),F4=/(\S+)\s+\(\S+\s([^)]+)\)/,I4=/^error[^']+'([^']+)'/m,L4=[new J1(F4,(e,[t,n])=>{let r=ove(t,n);e.all.push(r),e.branches[t]=r}),new J1(I4,(e,[t])=>{let n=sve(t);e.errors.push(n),e.all.push(n),e.branches[t]=n})],R4=(e,t)=>n0(new N4,L4,[e,t])}}),z4,uve=a1({"src/lib/responses/BranchSummary.ts"(){z4=class{constructor(){this.all=[],this.branches={},this.current=``,this.detached=!1}push(e,t,n,r,i){e===`*`&&(this.detached=t,this.current=n),this.all.push(n),this.branches[n]={current:e===`*`,linkedWorkTree:e===`+`,name:n,commit:r,label:i}}}}});function B4(e){return e?e.charAt(0):``}function V4(e,t=!1){return n0(new z4,t?[U4]:H4,e)}var H4,U4,dve=a1({"src/lib/parsers/parse-branch.ts"(){uve(),i0(),H4=[new J1(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,(e,[t,n,r,i])=>{e.push(B4(t),!0,n,r,i)}),new J1(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,(e,[t,n,r,i])=>{e.push(B4(t),!1,n,r,i)})],U4=new J1(/^(\S+)$/s,(e,[t])=>{e.push(`*`,!1,t,``,``)})}}),W4={};o1(W4,{branchLocalTask:()=>pve,branchTask:()=>fve,containsDeleteBranchCommand:()=>G4,deleteBranchTask:()=>hve,deleteBranchesTask:()=>mve});function G4(e){let t=[`-d`,`-D`,`--delete`];return e.some(e=>t.includes(e))}function fve(e){let t=G4(e),n=e.includes(`--show-current`),r=[`branch`,...e];return r.length===1&&r.push(`-a`),r.includes(`-v`)||r.splice(1,0,`-v`),{format:`utf-8`,commands:r,parser(e,r){return t?R4(e,r).all[0]:V4(e,n)}}}function pve(){return{format:`utf-8`,commands:[`branch`,`-v`],parser(e){return V4(e)}}}function mve(e,t=!1){return{format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,...e],parser(e,t){return R4(e,t)},onError({exitCode:e,stdOut:t},n,r,i){if(!P4(String(n),e))return i(n);r(t)}}}function hve(e,t=!1){let n={format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,e],parser(t,n){return R4(t,n).branches[e]},onError({exitCode:e,stdErr:t,stdOut:r},i,a,o){if(!P4(String(i),e))return o(i);throw new u1(n.parser(A1(r),A1(t)),String(i))}};return n}var gve=a1({"src/lib/tasks/branch.ts"(){d1(),lve(),dve(),i0()}});function _ve(e){let t=e.trim().replace(/^["']|["']$/g,``);return t&&he(t)}var K4,vve=a1({"src/lib/responses/CheckIgnore.ts"(){K4=e=>e.split(/\n/g).map(_ve).filter(Boolean)}}),q4={};o1(q4,{checkIgnoreTask:()=>yve});function yve(e){return{commands:[`check-ignore`,...e],format:`utf-8`,parser:K4}}var bve=a1({"src/lib/tasks/check-ignore.ts"(){vve()}});function xve(e,t){return n0({raw:e,remote:null,branches:[],tags:[],updated:[],deleted:[]},J4,[e,t])}var J4,Sve=a1({"src/lib/parsers/parse-fetch.ts"(){i0(),J4=[new J1(/From (.+)$/,(e,[t])=>{e.remote=t}),new J1(/\* \[new branch]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.branches.push({name:t,tracking:n})}),new J1(/\* \[new tag]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.tags.push({name:t,tracking:n})}),new J1(/- \[deleted]\s+\S+\s*-> (.+)$/,(e,[t])=>{e.deleted.push({tracking:t})}),new J1(/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/,(e,[t,n,r,i])=>{e.updated.push({name:r,tracking:i,to:n,from:t})})]}}),Y4={};o1(Y4,{fetchTask:()=>wve});function Cve(e){return/^--upload-pack(=|$)/.test(e)}function wve(e,t,n){let r=[`fetch`,...n];return e&&t&&r.push(e,t),r.find(Cve)?v0(`git.fetch: potential exploit argument blocked.`):{commands:r,format:`utf-8`,parser:xve}}var Tve=a1({"src/lib/tasks/fetch.ts"(){Sve(),w0()}});function Eve(e){return n0({moves:[]},X4,e)}var X4,Dve=a1({"src/lib/parsers/parse-move.ts"(){i0(),X4=[new J1(/^Renaming (.+) to (.+)$/,(e,[t,n])=>{e.moves.push({from:t,to:n})})]}}),Z4={};o1(Z4,{moveTask:()=>Ove});function Ove(e,t){return{commands:[`mv`,`-v`,...T1(e),t],format:`utf-8`,parser:Eve}}var kve=a1({"src/lib/tasks/move.ts"(){Dve(),i0()}}),Q4={};o1(Q4,{pullTask:()=>Ave});function Ave(e,t,n){let r=[`pull`,...n];return e&&t&&r.splice(1,0,e,t),{commands:r,format:`utf-8`,parser(e,t){return e4(e,t)},onError(e,t,n,r){let i=L_e(A1(e.stdOut),A1(e.stdErr));if(i)return r(new u1(i));r(t)}}}var jve=a1({"src/lib/tasks/pull.ts"(){d1(),t4(),i0()}});function Mve(e){let t={};return $4(e,([e])=>t[e]={name:e}),Object.values(t)}function Nve(e){let t={};return $4(e,([e,n,r])=>{Object.hasOwn(t,e)||(t[e]={name:e,refs:{fetch:``,push:``}}),r&&n&&(t[e].refs[r.replace(/[^a-z]/g,``)]=n)}),Object.values(t)}function $4(e,t){x1(e,e=>t(e.split(/\s+/)))}var Pve=a1({"src/lib/responses/GetRemoteSummary.ts"(){i0()}}),e3={};o1(e3,{addRemoteTask:()=>Fve,getRemotesTask:()=>Ive,listRemotesTask:()=>Lve,remoteTask:()=>Rve,removeRemoteTask:()=>zve});function Fve(e,t,n){return y0([`remote`,`add`,...n,e,t])}function Ive(e){let t=[`remote`];return e&&t.push(`-v`),{commands:t,format:`utf-8`,parser:e?Nve:Mve}}function Lve(e){let t=[...e];return t[0]!==`ls-remote`&&t.unshift(`ls-remote`),y0(t)}function Rve(e){let t=[...e];return t[0]!==`remote`&&t.unshift(`remote`),y0(t)}function zve(e){return y0([`remote`,`remove`,e])}var Bve=a1({"src/lib/tasks/remote.ts"(){Pve(),w0()}}),t3={};o1(t3,{stashListTask:()=>Vve});function Vve(e={},t){let n=P2(e),r=[`stash`,`list`,...n.commands,...t],i=T2(n.splitter,n.fields,m2(r));return M2(r)||{commands:r,format:`utf-8`,parser:i}}var Hve=a1({"src/lib/tasks/stash-list.ts"(){g2(),A2(),N2(),I2()}}),n3={};o1(n3,{addSubModuleTask:()=>Uve,initSubModuleTask:()=>Wve,subModuleTask:()=>r3,updateSubModuleTask:()=>Gve});function Uve(e,t){return r3([`add`,e,t])}function Wve(e){return r3([`init`,...e])}function r3(e){let t=[...e];return t[0]!==`submodule`&&t.unshift(`submodule`),y0(t)}function Gve(e){return r3([`update`,...e])}var Kve=a1({"src/lib/tasks/sub-module.ts"(){w0()}});function qve(e,t){let n=Number.isNaN(e);return n===Number.isNaN(t)?n?i3(e,t):0:n?1:-1}function i3(e,t){return e===t?0:e>t?1:-1}function Jve(e){return e.trim()}function a3(e){return typeof e==`string`&&parseInt(e.replace(/^\D+/g,``),10)||0}var o3,s3,Yve=a1({"src/lib/responses/TagList.ts"(){o3=class{constructor(e,t){this.all=e,this.latest=t}},s3=function(e,t=!1){let n=e.split(`
434
- `).map(Jve).filter(Boolean);t||n.sort(function(e,t){let n=e.split(`.`),r=t.split(`.`);if(n.length===1||r.length===1)return qve(a3(n[0]),a3(r[0]));for(let e=0,t=Math.max(n.length,r.length);e<t;e++){let t=i3(a3(n[e]),a3(r[e]));if(t)return t}return 0});let r=t?n[0]:[...n].reverse().find(e=>e.indexOf(`.`)>=0);return new o3(n,r)}}}),c3={};o1(c3,{addAnnotatedTagTask:()=>Qve,addTagTask:()=>Zve,tagListTask:()=>Xve});function Xve(e=[]){let t=e.some(e=>/^--sort=/.test(e));return{format:`utf-8`,commands:[`tag`,`-l`,...e],parser(e){return s3(e,t)}}}function Zve(e){return{format:`utf-8`,commands:[`tag`,e],parser(){return{name:e}}}}function Qve(e,t){return{format:`utf-8`,commands:[`tag`,`-a`,`-m`,t,e],parser(){return{name:e}}}}var $ve=a1({"src/lib/tasks/tag.ts"(){Yve()}}),eye=pge({"src/git.js"(e,t){var{GitExecutor:n}=(n_e(),s1(i2)),{SimpleGitApi:r}=(nve(),s1(D4)),{Scheduler:i}=(rve(),s1(k4)),{adhocExecTask:a,configurationErrorTask:o}=(w0(),s1(g0)),{asArray:s,filterArray:c,filterPrimitives:l,filterString:u,filterStringOrStringArray:d,filterType:f,getTrailingOptions:p,trailingFunctionArgument:m,trailingOptionsArgument:h}=(i0(),s1(r0)),{applyPatchTask:g}=(ave(),s1(M4)),{branchTask:_,branchLocalTask:v,deleteBranchesTask:y,deleteBranchTask:b}=(gve(),s1(W4)),{checkIgnoreTask:x}=(bve(),s1(q4)),{checkIsRepoTask:S}=(d0(),s1(a0)),{cleanWithOptionsTask:C,isCleanOptionsArray:w}=(M0(),s1(T0)),{diffSummaryTask:T}=(N2(),s1(j2)),{fetchTask:E}=(Tve(),s1(Y4)),{moveTask:D}=(kve(),s1(Z4)),{pullTask:O}=(jve(),s1(Q4)),{pushTagsTask:ee}=(d4(),s1(l4)),{addRemoteTask:te,getRemotesTask:ne,listRemotesTask:re,remoteTask:ie,removeRemoteTask:ae}=(Bve(),s1(e3)),{getResetMode:oe,resetTask:se}=(X0(),s1(K0)),{stashListTask:k}=(Hve(),s1(t3)),{addSubModuleTask:ce,initSubModuleTask:le,subModuleTask:ue,updateSubModuleTask:A}=(Kve(),s1(n3)),{addAnnotatedTagTask:j,addTagTask:de,tagListTask:fe}=($ve(),s1(c3)),{straightThroughBufferTask:pe,straightThroughStringTask:me}=(w0(),s1(g0));function M(e,t){this._plugins=t,this._executor=new n(e.baseDir,new i(e.maxConcurrentProcesses),t),this._trimmed=e.trimmed}(M.prototype=Object.create(r.prototype)).constructor=M,M.prototype.customBinary=function(e){return this._plugins.reconfigure(`binary`,e),this},M.prototype.env=function(e,t){return arguments.length===1&&typeof e==`object`?this._executor.env=e:(this._executor.env=this._executor.env||{})[e]=t,this},M.prototype.stashList=function(e){return this._runTask(k(h(arguments)||{},c(e)&&e||[]),m(arguments))},M.prototype.mv=function(e,t){return this._runTask(D(e,t),m(arguments))},M.prototype.checkoutLatestTag=function(e){var t=this;return this.pull(function(){t.tags(function(n,r){t.checkout(r.latest,e)})})},M.prototype.pull=function(e,t,n,r){return this._runTask(O(f(e,u),f(t,u),p(arguments)),m(arguments))},M.prototype.fetch=function(e,t){return this._runTask(E(f(e,u),f(t,u),p(arguments)),m(arguments))},M.prototype.silent=function(e){return this._runTask(a(()=>console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this method will be removed.")))},M.prototype.tags=function(e,t){return this._runTask(fe(p(arguments)),m(arguments))},M.prototype.rebase=function(){return this._runTask(me([`rebase`,...p(arguments)]),m(arguments))},M.prototype.reset=function(e){return this._runTask(se(oe(e),p(arguments)),m(arguments))},M.prototype.revert=function(e){let t=m(arguments);return typeof e==`string`?this._runTask(me([`revert`,...p(arguments,0,!0),e]),t):this._runTask(o(`Commit must be a string`),t)},M.prototype.addTag=function(e){let t=typeof e==`string`?de(e):o(`Git.addTag requires a tag name`);return this._runTask(t,m(arguments))},M.prototype.addAnnotatedTag=function(e,t){return this._runTask(j(e,t),m(arguments))},M.prototype.deleteLocalBranch=function(e,t,n){return this._runTask(b(e,typeof t==`boolean`?t:!1),m(arguments))},M.prototype.deleteLocalBranches=function(e,t,n){return this._runTask(y(e,typeof t==`boolean`?t:!1),m(arguments))},M.prototype.branch=function(e,t){return this._runTask(_(p(arguments)),m(arguments))},M.prototype.branchLocal=function(e){return this._runTask(v(),m(arguments))},M.prototype.raw=function(e){let t=!Array.isArray(e),n=[].slice.call(t?arguments:e,0);for(let e=0;e<n.length&&t;e++)if(!l(n[e])){n.splice(e,n.length-e);break}n.push(...p(arguments,0,!0));var r=m(arguments);return n.length?this._runTask(me(n,this._trimmed),r):this._runTask(o(`Raw: must supply one or more command to execute`),r)},M.prototype.submoduleAdd=function(e,t,n){return this._runTask(ce(e,t),m(arguments))},M.prototype.submoduleUpdate=function(e,t){return this._runTask(A(p(arguments,!0)),m(arguments))},M.prototype.submoduleInit=function(e,t){return this._runTask(le(p(arguments,!0)),m(arguments))},M.prototype.subModule=function(e,t){return this._runTask(ue(p(arguments)),m(arguments))},M.prototype.listRemote=function(){return this._runTask(re(p(arguments)),m(arguments))},M.prototype.addRemote=function(e,t,n){return this._runTask(te(e,t,p(arguments)),m(arguments))},M.prototype.removeRemote=function(e,t){return this._runTask(ae(e),m(arguments))},M.prototype.getRemotes=function(e,t){return this._runTask(ne(e===!0),m(arguments))},M.prototype.remote=function(e,t){return this._runTask(ie(p(arguments)),m(arguments))},M.prototype.tag=function(e,t){let n=p(arguments);return n[0]!==`tag`&&n.unshift(`tag`),this._runTask(me(n),m(arguments))},M.prototype.updateServerInfo=function(e){return this._runTask(me([`update-server-info`]),m(arguments))},M.prototype.pushTags=function(e,t){let n=ee({remote:f(e,u)},p(arguments));return this._runTask(n,m(arguments))},M.prototype.rm=function(e){return this._runTask(me([`rm`,`-f`,...s(e)]),m(arguments))},M.prototype.rmKeepLocal=function(e){return this._runTask(me([`rm`,`--cached`,...s(e)]),m(arguments))},M.prototype.catFile=function(e,t){return this._catFile(`utf-8`,arguments)},M.prototype.binaryCatFile=function(){return this._catFile(`buffer`,arguments)},M.prototype._catFile=function(e,t){var n=m(t),r=[`cat-file`],i=t[0];if(typeof i==`string`)return this._runTask(o(`Git.catFile: options must be supplied as an array of strings`),n);Array.isArray(i)&&r.push.apply(r,i);let a=e===`buffer`?pe(r):me(r);return this._runTask(a,n)},M.prototype.diff=function(e,t){let n=u(e)?o(`git.diff: supplying options as a single string is no longer supported, switch to an array of strings`):me([`diff`,...p(arguments)]);return this._runTask(n,m(arguments))},M.prototype.diffSummary=function(){return this._runTask(T(p(arguments,1)),m(arguments))},M.prototype.applyPatch=function(e){let t=d(e)?g(s(e),p([].slice.call(arguments,1))):o(`git.applyPatch requires one or more string patches as the first argument`);return this._runTask(t,m(arguments))},M.prototype.revparse=function(){let e=[`rev-parse`,...p(arguments,!0)];return this._runTask(me(e,!0),m(arguments))},M.prototype.clean=function(e,t,n){let r=w(e),i=r&&e.join(``)||f(e,u)||``,a=p([].slice.call(arguments,+!!r));return this._runTask(C(i,a),m(arguments))},M.prototype.exec=function(e){return this._runTask({commands:[],format:`utf-8`,parser(){typeof e==`function`&&e()}})},M.prototype.clearQueue=function(){return this._runTask(a(()=>console.warn(`simple-git deprecation notice: clearQueue() is deprecated and will be removed, switch to using the abortPlugin instead.`)))},M.prototype.checkIgnore=function(e,t){return this._runTask(x(s(f(e,d,[]))),m(arguments))},M.prototype.checkIsRepo=function(e,t){return this._runTask(S(f(e,u)),m(arguments))},t.exports=M}});l1(),l1(),l1(),d1(),p1(),d0(),M0(),L0(),B0(),G0(),X0(),i0(),i0(),(0,$$.deferred)().promise,i0(),l1(),i0(),i0(),i0(),i0(),eye(),d1(),W$(`checkpoint-chain`);function l3(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function tye(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}W$(`shadow-lock`),W$(`shadow-op-gate`),W$(`shadow-repo`),(()=>{let e=process.env.OK_GIT_TIMEOUT_MS;if(!e)return 3e4;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:3e4})(),(()=>{let e=process.env.OK_SHADOW_MAINTENANCE_GC_TIMEOUT_MS;if(!e)return 6e5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:6e5})(),(()=>{let e=process.env.OK_SHADOW_STAGE_TIMEOUT_MS;if(!e)return 3e5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:3e5})(),wX.fileSystem,wX.gitUpstream,wX.service,wX.generator,W$(`bridge-loss-detector`),W$(`checkpoint`);function u3(e){let t=me(e).toLowerCase();return Nl.includes(t)}function nye(e){let t=e.toLowerCase();for(let n of Nl)if(t.endsWith(n))return e.slice(0,-n.length);return e}function rye(e){return e===`__system__`}const iye=new Set(kl);function aye(e){return iye.has(e)}function oye(e){return jl(e)}function sye(e){return rye(e)||aye(e)||oye(e)}W$(`parse-pool`),Math.max(1,Math.min(4,ie()-1)),G$(()=>{}),W$(`bridge-watchdog`),G$(()=>{}),W$(`server-observers`),W$(`server-observers`),W$(`agent-sessions`);function d3(e){return{...e,windowsHide:!0}}function cye(){try{let e=ve(pe(Se(import.meta.url)),`..`,`package.json`),t=JSON.parse(S(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}cye(),RegExp(`^(?:${`do you mind.i would like you to.i'd like you to.i want you to.i need you to.i would like to.i'd like to.i want to.i need to.we need to.we want to.we should.go ahead and.take a look at.have a look at.look into.look at.help me with.help me to.help me.can you.could you.would you.will you.can we.could we.should we.let's.lets.try to.please.kindly.hello.alright.actually.anyway.also.okay.hey.hi.yo.ok.so.pls.plz.just.maybe`.split(`.`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})\\b(?:[\\s,:;!.\\-–—]+|$)`,`i`),Fe(s);const lye=co({source:F(),pluginProvider:F().optional(),skill:F().optional(),ref:F().optional(),contentHash:F(),files:z(F()).optional(),localHash:F().optional(),baselineRef:F().optional(),publisher:F().optional(),importedAt:Ma(),autoUpdate:L().optional()});co({schema:U(1),skills:V(F(),lye).default({})}),new Set(Object.values(Xl)),new Set([...new Set([`.git`,`node_modules`]),`scripts`,`references`]);const f3=[`agents`,`claude`,`cursor`,`codex`,`opencode`,`pi`,`copilot`];var uye=i(((e,t)=>{t.exports=n;function n(){this.pending=0,this.max=1/0,this.listeners=[],this.waiting=[],this.error=null}n.prototype.go=function(e){this.pending<this.max?i(this,e):this.waiting.push(e)},n.prototype.wait=function(e){this.pending===0?e(this.error):this.listeners.push(e)},n.prototype.hold=function(){return r(this)};function r(e){e.pending+=1;var t=!1;return n;function n(n){if(t)throw Error(`callback called twice`);if(t=!0,e.error=e.error||n,--e.pending,e.waiting.length>0&&e.pending<e.max)i(e,e.waiting.shift());else if(e.pending===0){var a=e.listeners;e.listeners=[],a.forEach(r)}}function r(t){t(e.error)}}function i(e,t){t(r(e))}})),dye=i((e=>{var n=t(`fs`),r=t(`util`),i=t(`stream`),a=i.Readable,o=i.PassThrough,s=uye(),c=t(`events`).EventEmitter;e.BufferSlicer=d,e.FdSlicer=l,r.inherits(l,c);function l(e){c.call(this),this.fd=e,this.pend=new s,this.pend.max=1,this.refCount=0}l.prototype.read=function(e,t,r,i,a){var o=this;o.pend.go(function(s){n.read(o.fd,e,t,r,i,function(e,t,n){s(),a(e,t,n)})})},l.prototype.createReadStream=function(e){return new u(this,e)},l.prototype.ref=function(){this.refCount+=1},l.prototype.unref=function(){var e=this;if(--e.refCount,e.refCount<0)throw Error(`invalid unref`);if(e.refCount>0)return;n.close(e.fd,t);function t(t){t?e.emit(`error`,t):e.emit(`close`)}},r.inherits(u,a);function u(e,t){t||={},a.call(this,t),this.context=e,this.context.ref(),this.start=t.start||0,this.endOffset=t.end,this.pos=this.start}u.prototype._read=function(e){var t=this,r=Math.min(t._readableState.highWaterMark,e);if(t.endOffset!=null&&(r=Math.min(r,t.endOffset-t.pos)),r<=0){t.push(null),this._cleanup();return}t.context.pend.go(function(e){var i=Buffer.allocUnsafe(r);n.read(t.context.fd,i,0,r,t.pos,function(n,r){n?t.destroy(n):r===0?(t.push(null),t._cleanup()):(t.pos+=r,t.push(i.slice(0,r))),e()})})},u.prototype._destroy=function(e,t){this._cleanup(),t(e)},u.prototype._cleanup=function(){this.context!=null&&(this.context.unref(),this.context=null)},r.inherits(d,c);function d(e){c.call(this),this.refCount=0,this.buffer=e}d.prototype.read=function(e,t,n,r,i){if(!(0<=t&&t<=e.length))throw RangeError(`offset outside buffer: 0 <= `+t+` <= `+e.length);if(r<0)throw RangeError(`position is negative: `+r);if(t+n>e.length&&(n=e.length-t),r+n>this.buffer.length&&(n=this.buffer.length-r),n<=0){setImmediate(function(){i(null,0)});return}this.buffer.copy(e,t,r,r+n),setImmediate(function(){i(null,n)})},d.prototype.createReadStream=function(e){e||={};var t=new o(e);t.start=e.start||0,t.endOffset=e.end,t.pos=t.endOffset||this.buffer.length;for(var n=this.buffer.slice(t.start,t.pos),r=65536,i=0;;){var a=i+r;if(a>=n.length){i<n.length&&t.write(n.slice(i,n.length));break}t.write(n.slice(i,a)),i=a}return t.end(),t},d.prototype.ref=function(){this.refCount+=1},d.prototype.unref=function(){if(--this.refCount,this.refCount<0)throw Error(`invalid unref`)}})),fye=i(((e,t)=>{let n=new Int32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function r(e){let t=-1;for(let r of e)t=n[(t^r)&255]^t>>>8;return(t^-1)>>>0}t.exports=r}));i((e=>{t(`fs`);var n=t(`zlib`);dye();var r=t(`util`),i=t(`events`).EventEmitter,a=t(`stream`).Transform,o=t(`stream`).PassThrough,s=t(`stream`).Writable;let c=typeof n.crc32==`function`?n.crc32:fye();r.inherits(l,i);function l(e,t,n,r,a,o,s,c,l,u){var f=this;i.call(f),f.reader=e,f.reader.on(`error`,function(e){d(f,e)}),f.reader.once(`close`,function(){f.emit(`close`)}),f.readEntryCursor=t,f.fileSize=n,f.entryCount=r,f.comment=a,f.entriesRead=0,f.autoClose=!!o,f.lazyEntries=!!s,f.decodeStrings=!!c,f.validateEntrySizes=!!l,f.strictFileNames=!!u,f.isOpen=!0,f.emittedError=!1,f.hasEachEntryBeenCalled=!1,f.lazyEntries||f._readEntry()}l.prototype.close=function(){this.isOpen&&(this.isOpen=!1,this.reader.unref())};function u(e,t){e.autoClose&&e.close(),d(e,t)}function d(e,t){e.emittedError||(e.emittedError=!0,e.emit(`error`,t))}l.prototype.readEntry=function(){if(!this.lazyEntries)throw Error(`readEntry() called without lazyEntries:true`);this._readEntry()},l.prototype._readEntry=function(){var e=this;if(e.entryCount===e.entriesRead){setImmediate(function(){e.autoClose&&e.close(),!e.emittedError&&e.emit(`end`)});return}if(!e.emittedError){var t=T(46);v(e.reader,t,0,t.length,e.readEntryCursor,function(n){if(n)return u(e,n);if(!e.emittedError){var r=new f,i=t.readUInt32LE(0);if(i!==33639248)return u(e,Error(`invalid central directory file header signature: 0x`+i.toString(16)));if(r.versionMadeBy=t.readUInt16LE(4),r.versionNeededToExtract=t.readUInt16LE(6),r.generalPurposeBitFlag=t.readUInt16LE(8),r.compressionMethod=t.readUInt16LE(10),r.lastModFileTime=t.readUInt16LE(12),r.lastModFileDate=t.readUInt16LE(14),r.crc32=t.readUInt32LE(16),r.compressedSize=t.readUInt32LE(20),r.uncompressedSize=t.readUInt32LE(24),r.fileNameLength=t.readUInt16LE(28),r.extraFieldLength=t.readUInt16LE(30),r.fileCommentLength=t.readUInt16LE(32),r.internalFileAttributes=t.readUInt16LE(36),r.externalFileAttributes=t.readUInt32LE(38),r.relativeOffsetOfLocalHeader=t.readUInt32LE(42),r.generalPurposeBitFlag&64)return u(e,Error(`strong encryption is not supported`));e.readEntryCursor+=46,t=T(r.fileNameLength+r.extraFieldLength+r.fileCommentLength),v(e.reader,t,0,t.length,e.readEntryCursor,function(n){if(n)return u(e,n);if(!e.emittedError){r.fileNameRaw=t.subarray(0,r.fileNameLength);var i=r.fileNameLength+r.extraFieldLength;r.extraFieldRaw=t.subarray(r.fileNameLength,i),r.fileCommentRaw=t.subarray(i,i+r.fileCommentLength);try{r.extraFields=_(r.extraFieldRaw)}catch(t){return u(e,t)}if(e.decodeStrings){var a=(r.generalPurposeBitFlag&2048)!=0;r.fileComment=C(r.fileCommentRaw,a),r.fileName=h(r.generalPurposeBitFlag,r.fileNameRaw,r.extraFields,e.strictFileNames);var o=g(r.fileName);if(o!=null)return u(e,Error(o))}else r.fileComment=r.fileCommentRaw,r.fileName=r.fileNameRaw;r.comment=r.fileComment,e.readEntryCursor+=t.length,e.entriesRead+=1;for(var s=0;s<r.extraFields.length;s++){var c=r.extraFields[s];if(c.id===1){var l=c.data,d=0;if(r.uncompressedSize===4294967295){if(d+8>l.length)return u(e,Error(`zip64 extended information extra field does not include uncompressed size`));r.uncompressedSize=w(l,d),d+=8}if(r.compressedSize===4294967295){if(d+8>l.length)return u(e,Error(`zip64 extended information extra field does not include compressed size`));r.compressedSize=w(l,d),d+=8}if(r.relativeOffsetOfLocalHeader===4294967295){if(d+8>l.length)return u(e,Error(`zip64 extended information extra field does not include relative header offset`));r.relativeOffsetOfLocalHeader=w(l,d),d+=8}break}}if(e.validateEntrySizes&&r.compressionMethod===0){var f=r.uncompressedSize;if(r.isEncrypted()&&(f+=12),r.compressedSize!==f){var p=`compressed/uncompressed size mismatch for stored file: `+r.compressedSize+` != `+r.uncompressedSize;return u(e,Error(p))}}e.emit(`entry`,r),e.lazyEntries||e._readEntry()}})}})}},l.prototype.eachEntry=function(){let e=this;if(!e.lazyEntries)throw Error(`eachEntry() requires lazyEntries: true`);if(e.hasEachEntryBeenCalled)throw Error(`eachEntry() must only be called once per ZipFile`);e.hasEachEntryBeenCalled=!0;let t=null;e.on(`entry`,r),e.on(`end`,i),e.on(`error`,a);function n(){e.removeListener(`entry`,r),e.removeListener(`end`,i),e.removeListener(`error`,a),e.autoClose&&e.close()}function r(e){let{resolve:n}=t;t=null,n({value:e})}function i(){let{resolve:e}=t;t=null,n(),e({done:!0})}function a(e){let{reject:r}=t;t=null,n(),r(e)}return{[Symbol.asyncIterator](){return this},next(){let n=new Promise((e,n)=>{if(t!=null)throw Error(`next() called before previous Promise was resolved.`);t={resolve:e,reject:n}});return e.readEntry(),n},return(e){return n(),Promise.resolve({done:!0,value:e})},throw(e){return n(),Promise.reject(e)}}},l.prototype.openReadStream=function(e,t,n){var r=this,i=0,a=e.compressedSize;if(n??(n=t,t=null),t==null)t={};else{if(t.decodeFileData===!1){if(t.decrypt!=null)throw Error(`cannot use options.decrypt when options.decodeFileData === false`);if(t.decompress!=null)throw Error(`cannot use options.decompress when options.decodeFileData === false`)}else{if(t.decrypt!=null){if(!e.isEncrypted())throw Error(`options.decrypt can only be specified for encrypted entries. See also option decodeFileData.`);if(t.decrypt!==!1)throw Error(`invalid options.decrypt value: `+t.decrypt);if(e.isCompressed()&&t.decompress!==!1)throw Error(`entry is encrypted and compressed, and options.decompress !== false. See also option decodeFileData.`)}if(t.decompress!=null){if(!e.isCompressed())throw Error(`options.decompress can only be specified for compressed entries. See also option decodeFileData.`);if(!(t.decompress===!1||t.decompress===!0))throw Error(`invalid options.decompress value: `+t.decompress);s=t.decompress}}if(t.start!=null){if(i=t.start,i<0)throw Error(`options.start < 0`);if(i>e.compressedSize)throw Error(`options.start > entry.compressedSize`)}if(t.end!=null){if(a=t.end,a<0)throw Error(`options.end < 0`);if(a>e.compressedSize)throw Error(`options.end > entry.compressedSize`);if(a<i)throw Error(`options.end < options.start`)}}var o=t.decodeFileData===!1||(e.compressionMethod===0||e.compressionMethod===8&&t.decompress===!1)&&(!e.isEncrypted()||t.decrypt===!1);if((t.start!=null||t.end!=null)&&!o)throw Error(`start/end range require options.decodeFileData === false for non-trivial encoded entries.`);if(!r.isOpen)return n(Error(`closed`));if(e.isEncrypted()&&!o&&t.decrypt!==!1)return n(Error(`entry is encrypted, and options.decodeFileData !== false`));var s;if(o)s=!1;else if(e.compressionMethod===8)s=t.decodeFileData!==!0;else return n(Error(`unsupported compression method: `+e.compressionMethod));r.readLocalFileHeader(e,{minimal:!0},function(t,o){if(t)return n(t);r.openReadStreamLowLevel(o.fileDataStart,e.compressedSize,i,a,s,e.uncompressedSize,n)})},l.prototype.openReadStreamLowLevel=function(e,t,r,i,a,o,s){var c=this;e+t;var l=c.reader.createReadStream({start:e+r,end:e+i}),u=l;if(a){var d=!1,f=n.createInflateRaw();l.on(`error`,function(e){setImmediate(function(){d||f.emit(`error`,e)})}),l.pipe(f),c.validateEntrySizes?(u=new y(o),f.on(`error`,function(e){setImmediate(function(){d||u.emit(`error`,e)})}),f.pipe(u)):u=f,E(u,function(){d=!0,f!==u&&f.unpipe(u),l.unpipe(f),l.destroy()})}s(null,u)},l.prototype.readLocalFileHeader=function(e,t,n){var r=this;n??(n=t,t=null),t??={},r.reader.ref();var i=T(30);v(r.reader,i,0,i.length,e.relativeOffsetOfLocalHeader,function(a){try{if(a)return n(a);var o=i.readUInt32LE(0);if(o!==67324752)return n(Error(`invalid local file header signature: 0x`+o.toString(16)));var s=i.readUInt16LE(26),c=i.readUInt16LE(28),l=e.relativeOffsetOfLocalHeader+30+s+c;if(l+e.compressedSize>r.fileSize)return n(Error(`file data overflows file bounds: `+l+` + `+e.compressedSize+` > `+r.fileSize));if(t.minimal)return n(null,{fileDataStart:l});var u=new p;u.fileDataStart=l,u.versionNeededToExtract=i.readUInt16LE(4),u.generalPurposeBitFlag=i.readUInt16LE(6),u.compressionMethod=i.readUInt16LE(8),u.lastModFileTime=i.readUInt16LE(10),u.lastModFileDate=i.readUInt16LE(12),u.crc32=i.readUInt32LE(14),u.compressedSize=i.readUInt32LE(18),u.uncompressedSize=i.readUInt32LE(22),u.fileNameLength=s,u.extraFieldLength=c,i=T(s+c),r.reader.ref(),v(r.reader,i,0,i.length,e.relativeOffsetOfLocalHeader+30,function(e){try{return e?n(e):(u.fileName=i.subarray(0,s),u.extraField=i.subarray(s),n(null,u))}finally{r.reader.unref()}})}finally{r.reader.unref()}})},l.prototype.openReadStreamPromise=function(e,t){return new Promise((n,r)=>{this.openReadStream(e,t,function(e,t){if(e)return r(e);n(t)})})},l.prototype.openReadStreamLowLevelPromise=function(e,t,n,r,i,a){return new Promise((o,s)=>{this.openReadStream(e,t,n,r,i,a,function(e,t){if(e)return s(e);o(t)})})},l.prototype.readLocalFileHeaderPromise=function(e,t){return new Promise((n,r)=>{this.readLocalFileHeader(e,t,function(e,t){if(e)return r(e);n(t)})})};function f(){}f.prototype.getLastModDate=function(e){if(e??={},!e.forceDosFormat)for(var t=0;t<this.extraFields.length;t++){var n=this.extraFields[t];if(n.id===21589){var r=n.data;if(r.length<5||!(r[0]&1))continue;var i=r.readInt32LE(1);return new Date(i*1e3)}else if(n.id===10){var r=n.data;if(r.length!==32||r.readUInt16LE(4)!==1||r.readUInt16LE(6)!==24)continue;var a=(r.readUInt32LE(8)+4294967296*r.readInt32LE(12))/1e4-0xa9730b66800;return new Date(a)}}return m(this.lastModFileDate,this.lastModFileTime,e.timezone)},f.prototype.canDecodeFileData=function(){return!this.isEncrypted()&&(this.compressionMethod===0||this.compressionMethod===8)},f.prototype.isEncrypted=function(){return(this.generalPurposeBitFlag&1)!=0},f.prototype.isCompressed=function(){return this.compressionMethod===8};function p(){}function m(e,t,n){var r=e&31,i=(e>>5&15)-1,a=(e>>9&127)+1980,o=0,s=(t&31)*2,c=t>>5&63,l=t>>11&31;if(n==null||n===`local`)return new Date(a,i,r,l,c,s,o);if(n===`UTC`)return new Date(Date.UTC(a,i,r,l,c,s,o));throw Error(`unrecognized options.timezone: `+options.timezone)}function h(e,t,n,r){for(var i=null,a=0;a<n.length;a++){var o=n[a];if(o.id===28789){if(o.data.length<6||o.data.readUInt8(0)!==1)continue;var s=o.data.readUInt32LE(1);if(c(t)!==s)continue;i=C(o.data.subarray(5),!0);break}}return i??=C(t,(e&2048)!=0),r||(i=i.replace(/\\/g,`/`)),i}function g(e){return e.indexOf(`\\`)===-1?/^[a-zA-Z]:/.test(e)||/^\//.test(e)?`absolute path: `+e:e.split(`/`).indexOf(`..`)===-1?null:`invalid relative path: `+e:`invalid characters in fileName: `+e}function _(e){for(var t=[],n=0;n<e.length-3;){var r=e.readUInt16LE(n+0),i=e.readUInt16LE(n+2),a=n+4,o=a+i;if(o>e.length)throw Error(`extra field length exceeds extra field buffer size`);var s=e.subarray(a,o);t.push({id:r,data:s}),n=o}return t}function v(e,t,n,r,i,a){if(r===0)return setImmediate(function(){a(null,T(0))});e.read(t,n,r,i,function(e,t){if(e)return a(e);if(t<r)return a(Error(`unexpected EOF`));a()})}r.inherits(y,a);function y(e){a.call(this),this.actualByteCount=0,this.expectedByteCount=e}y.prototype._transform=function(e,t,n){if(this.actualByteCount+=e.length,this.actualByteCount>this.expectedByteCount){var r=`too many bytes in the stream. expected `+this.expectedByteCount+`. got at least `+this.actualByteCount;return n(Error(r))}n(null,e)},y.prototype._flush=function(e){if(this.actualByteCount<this.expectedByteCount){var t=`not enough bytes in the stream. expected `+this.expectedByteCount+`. got only `+this.actualByteCount;return e(Error(t))}e()},r.inherits(b,i);function b(){i.call(this),this.refCount=0}b.prototype.ref=function(){this.refCount+=1},b.prototype.unref=function(){var e=this;if(--e.refCount,e.refCount>0)return;if(e.refCount<0)throw Error(`invalid unref`);e.close(t);function t(t){if(t)return e.emit(`error`,t);e.emit(`close`)}},b.prototype.createReadStream=function(e){e??={};var t=e.start,n=e.end;if(t===n){var r=new o;return setImmediate(function(){r.end()}),r}var i=this._readStreamForRange(t,n),a=!1,s=new x(this);i.on(`error`,function(e){setImmediate(function(){a||s.emit(`error`,e)})}),E(s,function(){i.unpipe(s),s.unref(),i.destroy()});var c=new y(n-t);return s.on(`error`,function(e){setImmediate(function(){a||c.emit(`error`,e)})}),E(c,function(){a=!0,s.unpipe(c),s.destroy()}),i.pipe(s).pipe(c)},b.prototype._readStreamForRange=function(e,t){throw Error(`not implemented`)},b.prototype.read=function(e,t,n,r,i){var a=this.createReadStream({start:r,end:r+n}),o=new s,c=0;o._write=function(n,r,i){n.copy(e,t+c,0,n.length),c+=n.length,i()},o.on(`finish`,i),a.on(`error`,function(e){i(e)}),a.pipe(o)},b.prototype.close=function(e){setImmediate(e)},r.inherits(x,o);function x(e){o.call(this),this.context=e,this.context.ref(),this.unreffedYet=!1}x.prototype._flush=function(e){this.unref(),e()},x.prototype.unref=function(e){this.unreffedYet||(this.unreffedYet=!0,this.context.unref())};var S=`\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\xA0`;function C(e,t){if(t)return e.toString(`utf8`);for(var n=``,r=0;r<e.length;r++)n+=S[e[r]];return n}function w(e,t){var n=e.readUInt32LE(t);return e.readUInt32LE(t+4)*4294967296+n}var T=typeof Buffer.allocUnsafe==`function`?function(e){return Buffer.allocUnsafe(e)}:function(e){return new Buffer(e)};function E(e,t){typeof e.destroy==`function`?e._destroy=function(e,n){t(),n?.(e)}:e.destroy=t}}))(),Object.freeze({source:`local`,skipStoreHooks:!0,context:Object.freeze({origin:`effect-capture`,paired:!1})});var pye=e(a(),1);const p3={discovery:`open-knowledge-discovery`,project:`open-knowledge`,"write-skill":`open-knowledge-write-skill`};new Set(Object.values(p3));const mye=Object.keys(p3),hye={discovery:`user`,project:`project`,"write-skill":`user`},m3=mye.filter(e=>hye[e]===`user`);new Set(m3.map(e=>p3[e]));const h3=`OpenKnowledge.app/Contents/Resources/cli/dist/assets/skills`;function gye(e,t={}){let n=t.platform??process.platform,r=t.checkDesktop??!1,i=t.home??oe(),a=[],o=process.env.NODE_ENV===`test`;r&&n===`darwin`&&(o||a.push(N(`/Applications`,h3,e)),(!o||t.home!==void 0)&&a.push(N(i,`Applications`,h3,e))),a.push(Se(new URL(`../dist/assets/skills/${e}`,import.meta.url))),a.push(Se(new URL(`../assets/skills/${e}`,import.meta.url))),a.push(Se(new URL(`./assets/skills/${e}`,import.meta.url)));for(let e of a)if(g(e))return e;throw Error(`Bundled skill asset directory not found for bundle '${e}'. Tried: ${a.join(`, `)}. This usually means the CLI build did not copy packages/server/assets into dist/assets. Run \`cd packages/cli && bun run build\` before publishing.`)}const g3={start:I().int().nonnegative().optional(),end:I().int().nonnegative().optional(),quote:F().min(1).optional(),prefix:F().max(1e3).optional(),suffix:F().max(1e3).optional()};B({docName:F().min(1),...g3,propertyKey:F().min(1).optional(),propertyPath:z(uo([F(),I().int().nonnegative()])).optional(),body:F(),queue:L().optional(),summary:F().optional()});const _3=rne();fo(`action`,[B({action:U(`edit`),id:_3,body:F(),summary:F().optional()}),B({action:U(`resolve`),id:_3,summary:F().optional()}),B({action:U(`reopen`),id:_3,summary:F().optional()}),B({action:U(`replace`),id:_3,...g3,summary:F().optional()}),B({action:U(`queue`),id:_3,summary:F().optional()}),B({action:U(`unqueue`),id:_3,summary:F().optional()}),B({action:U(`dispatch-prepare`),id:_3,summary:F().optional()}),B({action:U(`dispatch-complete`),id:_3,summary:F().optional()}),B({action:U(`dispatch-prepare-batch`),ids:z(_3).min(1).max(200),summary:F().optional()}),B({action:U(`dispatch-complete-batch`),ids:z(_3).min(1).max(200),summary:F().optional()})]);const v3="Absolute host path inside the target OpenKnowledge project. Required when the MCP server is registered globally (e.g. `npx @inkeep/open-knowledge mcp` once at the host level, routing per call), unless the MCP client advertises exactly one root via the `roots` capability — that single root is then used as the implicit `cwd`. Optional when the server is anchored to a single project (the per-project HTTP MCP server defaults to its configured project root).";F().max(200).optional().describe(`Optional one-line user-outcome description (≤80 chars). Appears as a bullet in the timeline.`),F().length(40).regex(/^[0-9a-f]+$/i).describe("A 40-character commit SHA identifying a saved version. Produced by `checkpoint`, listed by `history` as `entries[].version`, and consumed here — the same `version` field name across all three."),F().nullable().describe("Route-only preview URL (`/#/<doc>`, no host:port), or null when no UI is running."),F().optional().describe(`How the previewUrl was resolved (e.g. the UI lock).`),F().optional().describe(`Route of the prior/removed path, for closing a stale preview tab.`);const _ye=B({value:F(),truncatedFrom:I().optional(),hint:F().optional()}).describe(`Normalized change-note summary, when one was recorded.`),vye=z(V(F(),R()));V(F(),R()).optional().describe("Preview-attach hint (`{ action, previewUrl?, message? }`) when relevant."),z(xJ).describe('Outbound internal links in the just-written doc that do not resolve. Always present — `[]` means every link resolves. Each: `{ href (as written), resolvedTo (the docName or content-root file path it pointed at, or null), reason: "no-such-doc" | "no-such-file" | "unresolvable" }`. Report-only — the write landed regardless; fix in a follow-up edit.'),_ye.optional(),z(yJ).min(1).optional().describe("Advisory entries discriminated by `kind`. Write-integrity kinds — `content-divergence` (converged Y.Text didn't byte-match what you composed) and `disk-edit-reconciled` (an out-of-band disk edit was folded in before your write) — mean re-read the doc. The renderability kind `mermaid-parse-error` means the write landed but that fence will not render — fix it and re-edit."),z(B({name:F(),description:F().optional()})).min(1).optional().describe("Templates the parent folder offers, present only when a create passed no `template`. A nudge — the write already landed; pass `template` next time to match the folder's shape.");const yye=F().optional().describe("Auto-duplicated body text. `textPlusStructured` mirrors the visible body here as a Claude / Claude Desktop client-quirk workaround (those clients hide `content[]` when `structuredContent` is present). Internal — programmatic consumers should prefer the `content[0].text` channel.");function y3(e){return{text:yye,...e}}new class{capacity;store;writeIndex=0;filled=!1;constructor(e){if(!Number.isInteger(e)||e<=0)throw RangeError(`RingBuffer capacity must be a positive integer, got ${e}`);this.capacity=e,this.store=Array(e)}push(e){this.store[this.writeIndex]=e,this.writeIndex=(this.writeIndex+1)%this.capacity,this.writeIndex===0&&(this.filled=!0)}read(){let e=[],t=this.filled?this.capacity:this.writeIndex;for(let n=1;n<=t;n++){let t=(this.writeIndex-n+this.capacity)%this.capacity,r=this.store[t];r!==void 0&&e.push(r)}return e}get size(){return this.filled?this.capacity:this.writeIndex}}(256),Wl.cursor,Wl.codex,Wl[`claude-desktop`],W$(`embeddings`),W$(`embeddings`);function bye(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return`${t.protocol}//${t.host.toLowerCase()}${n}`}catch{return e.trim().replace(/\/+$/,``)}}bye(ys),W$(`embeddings`),W$(`embeddings`);const xye=String.raw`\[\[([^\n#[\]|]+)(?:#([^\n[\]|]+))?(?:\|([^\n[\]]+))?\]\]`,Sye=String.raw`\((<[^>\n]+>|[^)\s\n]+)((?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?)\)`,b3=String.raw`([^\]\n]*)`,x3=String.raw`([^\]\n]*(?:\][^[\]\n]*)?)`,S3=e=>RegExp(`(!?)${xye}`,e),C3=(e,t)=>RegExp(`(!?)\\[${e}\\]${Sye}`,t);S3(`y`),S3(`g`),C3(b3,`y`),C3(x3,`y`),C3(b3,`g`),C3(x3,`g`);const Cye=String.raw`(!?)\[([^\]\n]*)\](?:\[([^\]\n]*)\])?`;new RegExp(Cye,`y`);function w3(e){return e.replace(/\\/g,`/`)}B({target:H(Object.keys({"claude-cowork":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},"claude-code":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},codex:{type:`app-bundle`,appName:`Codex`,urlScheme:`codex:`,probeScheme:`codex`,quitFirst:!0},cursor:{type:`cli-binary`,binaryName:`cursor`,urlScheme:`cursor:`}})),url:F().min(1).max(4096),workspacePath:F().optional()}),B({}).loose(),W$(`installed-skills-marker`);var T3=e(i(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.*\/|^\.+$/,l=`node-ignore`;typeof Symbol<`u`&&(l=Symbol.for(`node-ignore`));let u=l,d=(e,t,n)=>Object.defineProperty(e,t,{value:n}),f=/([0-z])-([0-z])/g,p=()=>!1,m=e=>e.replace(f,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),h=e=>{let{length:t}=e;return e.slice(0,t-t%2)},g=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${h(r)}${i}`:i===`]`&&r.length%2==0?`[${m(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(e,t)=>`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`]],_=Object.create(null),v=(e,t)=>{let n=_[e];return n||(n=g.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),_[e]=n),t?new RegExp(n,`i`):new RegExp(n)},y=e=>typeof e==`string`,b=e=>e&&y(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,x=e=>e.split(s);var S=class{constructor(e,t,n,r){this.origin=e,this.pattern=t,this.negative=n,this.regex=r}};let C=(e,t)=>{let n=e,r=!1;e.indexOf(`!`)===0&&(r=!0,e=e.substr(1)),e=e.replace(a,`!`).replace(o,`#`);let i=v(e,t);return new S(n,e,r,i)},w=(e,t)=>{throw new t(e)},T=(e,t,n)=>y(e)?e?T.isNotRelative(e)?n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),E=e=>c.test(e);T.isNotRelative=E,T.convert=e=>e;var D=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){d(this,u,!0),this._rules=[],this._ignoreCase=t,this._allowRelativePaths=n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[u]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(b(e)){let t=C(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(y(e)?x(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,t){let n=!1,r=!1;return this._rules.forEach(i=>{let{negative:a}=i;r===a&&n!==r||a&&!n&&!r&&!t||i.regex.test(e)&&(n=!a,r=a)}),{ignored:n,unignored:r}}_test(e,t,n,r){let i=e&&T.convert(e);return T(i,e,this._allowRelativePaths?p:w),this._t(i,t,n,r)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`),r.pop(),!r.length)return t[e]=this._testOne(e,n);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._testOne(e,n)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let O=e=>new D(e);if(O.isPathValid=e=>T(e&&T.convert(e),e,p),O.default=O,t.exports=O,typeof process<`u`&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform===`win32`)){T.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;T.isNotRelative=t=>e.test(t)||E(t)}}))(),1);const E3=W$(`content-filter`);Fe(s);const D3=[`.claude`,`.cursor`,`.codex`,`.agents`,`.opencode`,`.pi`],O3=new Set([`node_modules`,`.venv`,`venv`,`env`,`__pycache__`,`vendor`,`dist`,`build`,`out`,`output`,`.next`,`.nuxt`,`.svelte-kit`,`.astro`,`.turbo`,`.cache`,`.parcel-cache`,`coverage`,`.git`,`.ok`,`.open-knowledge`,`.openknowledge`,...D3,`Library`,`Applications`,`.Trash`]),wye=new Set([`.git`,`node_modules`,`.ok`,`.open-knowledge`,`.openknowledge`,...D3]),k3=new Set([`worktrees`,`local`]);function A3(e){let t=Ss(e);if(!Cs(t))throw Error(`Invalid attachment folder path`);if(t===`./`)return{kind:`sibling`};if(t===`/`||t===`.`)return{kind:`content-root`};let n=t.startsWith(`./`),r=(n?t.slice(2):t).split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`);return r===``?n?{kind:`sibling`}:{kind:`content-root`}:{kind:n?`doc-relative`:`fixed`,path:r}}function Tye(e){throw Error(`[AttachmentFolderShape] unhandled variant: ${JSON.stringify(e)}`)}function Eye(e,t,n){let r=me(e).slice(1).toLowerCase();if(!ts.has(r)||t.kind===`sibling`)return!1;let i=e.lastIndexOf(`/`),a=i===-1?``:e.slice(0,i);if(t.kind===`content-root`)return a===``;if(t.kind===`fixed`)return a===t.path||a.startsWith(`${t.path}/`);if(t.kind===`doc-relative`){let e=a===``?[]:a.split(`/`),r=t.path.split(`/`);for(let t=0;t<=e.length-r.length;t++)if(r.every((n,r)=>e[t+r]===n)&&n(e.slice(0,t).join(`/`)))return!0;return!1}return Tye(t)}function j3(e,t){let n=e.split(`/`);for(let e=0;e<n.length;e++){let r=n[e],i=r.toLowerCase()===`.ok`?`.ok`:r;if(wye.has(i)&&!(t&&i===`.ok`&&!k3.has((n[e+1]??``).toLowerCase())))return!0}return!1}function M3(e){return e.startsWith(`${Ml}/`)}function Dye(e){return e===`.ok`||e===`.ok/skills`||e.startsWith(`.ok/skills/`)}const N3=new Set([`.ok`,...D3]),Oye=new Set([...O3].filter(e=>!N3.has(e))),kye=[`.git`,`node_modules`,`.ok/local`,`.ok/worktrees`].flatMap(e=>[e,`${e}/**`,`**/${e}`,`**/${e}/**`]);function Aye(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`);return t.includes(`..`)?!1:t.some(e=>Oye.has(e))?!0:t.some((e,n)=>e.toLowerCase()===`.ok`&&k3.has((t[n+1]??``).toLowerCase()))}const jye=[`.gitignore`,`.ok`,`.ok/config.yml`,`.ok/.gitignore`,`.ok/schemas/frontmatter.json`,`.ok/templates/example.md`,`.ok/skills/example/SKILL.md`,`docs/.ok`,`docs/.ok/frontmatter.yml`,`docs/.ok/templates/example.md`,...D3.flatMap(e=>[e,`${e}/skills/example/SKILL.md`])];function Mye(e){let t=e.trim();if(!t||t.startsWith(`!`)||t.startsWith(`#`))return!1;let n=t.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`);if(n.includes(`..`))return!0;if(Aye(t))return!1;if(n.some(e=>N3.has(e)))return!0;try{let e=(0,T3.default)().add(t);return jye.some(t=>e.ignores(t))}catch{return!0}}function Nye(e){let t=e.filter(e=>e.length>0&&!e.startsWith(`!`)&&!e.startsWith(`#`)&&!Mye(e));return[...new Set([...t,...kye])]}function P3(e,t){for(let n=0;n<t;n++)if(O3.has(e[n])||e[n].toLowerCase()===`.ok`)return!0;return!1}function F3(e){let t=e.split(`/`),n=t.length;return n<3||t[n-3]!==`.ok`||t[n-2]!==`templates`||me(t[n-1])!==`.md`?!1:!P3(t,n-3)}function I3(e){let t=e.split(`/`),n=t.length;return t[n-1]===`.ok`?!P3(t,n-1):n>=2&&t[n-1]===`templates`&&t[n-2]===`.ok`?!P3(t,n-2):!1}function Pye(e){let t=e.split(`/`),n=t.length;return t[0]===`.ok`&&(n===2&&(t[1]===`config.yml`||t[1]===`.gitignore`)||n===3&&t[1]===`schemas`&&t[2].toLowerCase().endsWith(`.json`))||F3(e)?!0:n>=2&&t[n-1]===`frontmatter.yml`&&t[n-2]===`.ok`?!P3(t,n-2):!1}function Fye(e){return e===`.ok`||e===`.ok/schemas`?!0:I3(e)}function Iye(e,t){for(let n of t)if(e===n||e.startsWith(`${n}/`))return!0;return!1}function L3(e,t){if(t.size===0)return!1;for(let n of t)if(e.startsWith(`${n}/`))return!0;return!1}function Lye(e,t){if(t.size===0)return!1;for(let n of t)if(n===e||n.startsWith(`${e}/`)||e.startsWith(`${n}/`))return!0;return!1}const Rye=new Set([`.ds_store`,`.localized`,`thumbs.db`,`desktop.ini`,`.directory`]);function R3(e){return Rye.has(e.slice(e.lastIndexOf(`/`)+1).toLowerCase())}const zye=new Set([`.ssh`,`.aws`,`.gnupg`,`.kube`,`.docker`]);function z3(e){for(let t of e.split(`/`))if(zye.has(t.toLowerCase()))return!0;return!1}const Bye=new Set([`credentials`,`.netrc`,`.npmrc`,`.pgpass`,`.git-credentials`]),Vye=[`.pem`,`.key`,`.p12`,`.pfx`,`.keystore`,`.jks`,`.ppk`];function B3(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();if(t===`.env`||t.startsWith(`.env.`)||Bye.has(t)||t.startsWith(`id_rsa`)||t.startsWith(`id_ed25519`)||t.startsWith(`id_ecdsa`)||t.startsWith(`id_dsa`))return!0;for(let e of Vye)if(t.endsWith(e))return!0;return!1}function Hye(e,t){return t===e||t.startsWith(`${e}/`)}const V3=[`.gitignore`,`.okignore`];function Uye(e,t){let n=Wye(e);if(n===null)return[];let r=[];H3(N(n,`info`,`exclude`),t,r,`info/exclude`);let i=Gye(e);return i&&H3(i,t,r,`global excludesfile`),r}function Wye(e){let t=u(`git`,[`rev-parse`,`--git-common-dir`],d3({cwd:e,encoding:`utf-8`,timeout:5e3}));return t.status!==0||!t.stdout?null:ve(e,t.stdout.trim())}function Gye(e){let t=u(`git`,[`config`,`--get`,`--type=path`,`core.excludesfile`],d3({cwd:e,encoding:`utf-8`,timeout:5e3}));if(t.status===0&&t.stdout){let e=t.stdout.trim();if(e)return e}return Kye()}function Kye(){let e=process.env.XDG_CONFIG_HOME?.trim();return N(e&&e.length>0?e:N(oe(),`.config`),`git`,`ignore`)}function H3(e,t,n,r){if(g(e))try{let r=S(e,`utf-8`);t.value+=r.length,n.push(...W3(r))}catch(t){E3.warn({path:e,err:t},`Failed to read ${r} at ${e}`)}}function qye(e){let{projectDir:t,contentDir:n,onAfterRebuild:r,singleDocRelPath:i}=e,a=e.inPlaceSkillDirs??new Set,o=A3(e.attachmentFolderPath??`./`),s=e.skillRootPaths??new Set,c=w3(_e(t,n)),l=c.startsWith(`..`),u,d,f,p,m=0,h=0,_=0;function v(){let e=(0,T3.default)(),r=(0,T3.default)();e.add(`.git`);let i=[],a=0,o=0;for(let n of V3){let o=N(t,n);if(g(o))try{let t=S(o,`utf-8`);a+=t.length;let s=W3(t);i.push(...s),e.add(s),n===`.okignore`&&r.add(s)}catch(e){E3.warn({path:o,err:e},`Failed to read ${n} at ${o}`)}}if(c&&!l)for(let t of V3){let i=N(n,t);if(g(i))try{let n=S(i,`utf-8`);a+=n.length,o++;let s=W3(n).map(e=>G3(e,c));e.add(s),t===`.okignore`&&r.add(s)}catch(e){E3.warn({path:i,err:e},`Failed to read ${t} at ${i}`)}}let s={value:a};o+=K3(n,t,e,r,s),a=s.value;let v=Uye(t,s);a=s.value,v.length>0&&(i.push(...v),e.add(v));let y=Nye(i);return u=e,d=r,f=i,p=y,m=i.length,h=o,_=a,{patternCount:m,nestedFileCount:h,bytes:_}}v();let y=new Map;function b(e,t){if(l&&t?.pathBase!==`project`)return!1;let n=t?.pathBase===`project`||!c?e:`${c}/${e}`;return n.startsWith(`..`)?!1:u.ignores(n)}function x(e,t){return t.pathBase===`project`||!c?e:`${c}/${e}`}function C(e){if(l)return!1;let t=c?`${c}/${e}`:e;return d.ignores(t)}let w=()=>{i===void 0&&U3(n,``,b,y)};w();function T(e){return sye(nye(e))}function E(e){for(let t of e.split(`/`))if(O3.has(t))return!0;return l?!1:b(e)}let D=null,O=null;return{isExcluded(e,t){if(T(e)||B3(e)||z3(e)||!t?.bypassFilters&&Iye(e,s)&&!L3(e,a))return!0;if(!t?.bypassFilters&&(M3(e)||L3(e,a)&&!b(e))){if(i!==void 0)return e!==i;if(u3(e))return!1;let t=me(e).slice(1).toLowerCase();return!ts.has(t)}if(!t?.bypassFilters&&F3(e)||!t?.bypassFilters&&t?.syncScope!==void 0&&Pye(x(e,t.syncScope))&&!b(e,t.syncScope))return i===void 0?!1:e!==i;if(j3(e,t?.showOk)||R3(e))return!0;if(i!==void 0)return e!==i;if(t?.bypassFilters)return t.respectOkignore===!0&&C(e);if(E(e))return!0;if(u3(e)||Eye(e,o,e=>(y.get(e)??0)>0))return!1;let n=me(e).slice(1).toLowerCase();if(ts.has(n)){let t=pe(e),n=t===`.`?``:t;if((y.get(n)??0)>0)return!1}return!0},isDirExcluded(e,t){if(z3(e))return!0;if(!t?.bypassFilters&&(Dye(e)||I3(e)||t?.syncScope!==void 0&&Fye(x(e,t.syncScope))||Lye(e,a)))return!1;if(j3(e,t?.showOk))return!0;if(i!==void 0)return!Hye(e,i);if(t?.bypassFilters)return t.respectOkignore===!0&&(C(e)||C(`${e}/`));for(let t of e.split(`/`))if(O3.has(t))return!0;return l?!1:b(e,t?.syncScope)||b(`${e}/`,t?.syncScope)},isPathIgnored(e,t){return T(e)||B3(e)||z3(e)?!0:M3(e)||L3(e,a)&&!b(e)||F3(e)?!1:j3(e)||R3(e)?!0:t?.bypassFilters?!1:E(e)},getWatcherIgnoreGlobs(){return p},incrementMdDir(e){let t=e===`.`?``:e;y.set(t,(y.get(t)??0)+1)},decrementMdDir(e){let t=e===`.`?``:e,n=y.get(t)??0;n<=1?y.delete(t):y.set(t,n-1)},rebuildDirCount(){let e=new Map(y);y.clear();try{w()}catch(t){for(let[t,n]of e)y.set(t,n);E3.warn({err:t instanceof Error?t:Error(String(t))},`content-filter rebuildDirCount walk failed — retaining previous counts`)}},setAttachmentFolderPath(e){o=A3(e)},refreshInPlaceSkillDirs(){if(e.rescanInPlaceSkillDirs)try{a=e.rescanInPlaceSkillDirs()}catch(e){E3.warn({err:e},`in-place skill re-scan failed — keeping previous allow-list`)}},async rebuildIgnorePatterns(){let t=e=>(D=e().finally(()=>{D=null}),D),n=async()=>{if(e.rescanInPlaceSkillDirs)try{a=e.rescanInPlaceSkillDirs()}catch(e){E3.warn({err:e},`in-place skill re-scan failed — keeping previous allow-list`)}let t=u,n=d,i=f,o=p,s=m,c=h,l=_,g=Date.now();return rge(`config.ignore.rebuild`,{attributes:{}},async e=>{try{let t=v();y.clear(),w();let n=Date.now()-g;if(e.setAttributes({"ok.ignore.pattern_count":t.patternCount,"ok.ignore.nested_file_count":t.nestedFileCount,"ok.ignore.bytes":t.bytes}),E3.info({patternCount:t.patternCount,nestedFileCount:t.nestedFileCount,bytes:t.bytes,durationMs:n},`content-filter rebuild succeeded`),r)try{r()}catch(e){E3.warn({err:e instanceof Error?e:Error(String(e))},`content-filter onAfterRebuild callback threw — derived views may be stale`)}return{ok:!0,patternCount:t.patternCount,nestedFileCount:t.nestedFileCount,bytes:t.bytes,durationMs:n}}catch(e){u=t,d=n,f=i,p=o,m=s,h=c,_=l,y.clear();try{w()}catch(e){E3.warn({err:e instanceof Error?e:Error(String(e))},`content-filter rollback dirCount re-walk failed — sibling-asset counts may be stale until next rebuild`)}let r=e instanceof Error?e.message:String(e);return E3.warn({err:e instanceof Error?e:Error(r)},`content-filter rebuild failed — rolled back to previous state`),{ok:!1,error:{message:r}}}})};return D===null?t(n):(O===null&&(O=D.catch(()=>null).then(()=>(O=null,t(n)))),O)}}}function U3(e,t,n,r){let i;try{i=C(e,{withFileTypes:!0})}catch(t){E3.warn({dir:e,err:t},`Failed to read directory for dir-count: ${e}`);return}for(let a of i){let i=t?`${t}/${a.name}`:a.name;if(a.isDirectory()){if(O3.has(a.name)||n(i)||n(`${i}/`))continue;U3(N(e,a.name),i,n,r)}else a.isFile()&&u3(a.name)&&!n(i)&&r.set(t,(r.get(t)??0)+1)}}function W3(e){return e.split(`
434
+ `).map(Jve).filter(Boolean);t||n.sort(function(e,t){let n=e.split(`.`),r=t.split(`.`);if(n.length===1||r.length===1)return qve(a3(n[0]),a3(r[0]));for(let e=0,t=Math.max(n.length,r.length);e<t;e++){let t=i3(a3(n[e]),a3(r[e]));if(t)return t}return 0});let r=t?n[0]:[...n].reverse().find(e=>e.indexOf(`.`)>=0);return new o3(n,r)}}}),c3={};o1(c3,{addAnnotatedTagTask:()=>Qve,addTagTask:()=>Zve,tagListTask:()=>Xve});function Xve(e=[]){let t=e.some(e=>/^--sort=/.test(e));return{format:`utf-8`,commands:[`tag`,`-l`,...e],parser(e){return s3(e,t)}}}function Zve(e){return{format:`utf-8`,commands:[`tag`,e],parser(){return{name:e}}}}function Qve(e,t){return{format:`utf-8`,commands:[`tag`,`-a`,`-m`,t,e],parser(){return{name:e}}}}var $ve=a1({"src/lib/tasks/tag.ts"(){Yve()}}),eye=pge({"src/git.js"(e,t){var{GitExecutor:n}=(n_e(),s1(i2)),{SimpleGitApi:r}=(nve(),s1(D4)),{Scheduler:i}=(rve(),s1(k4)),{adhocExecTask:a,configurationErrorTask:o}=(w0(),s1(g0)),{asArray:s,filterArray:c,filterPrimitives:l,filterString:u,filterStringOrStringArray:d,filterType:f,getTrailingOptions:p,trailingFunctionArgument:m,trailingOptionsArgument:h}=(i0(),s1(r0)),{applyPatchTask:g}=(ave(),s1(M4)),{branchTask:_,branchLocalTask:v,deleteBranchesTask:y,deleteBranchTask:b}=(gve(),s1(W4)),{checkIgnoreTask:x}=(bve(),s1(q4)),{checkIsRepoTask:S}=(d0(),s1(a0)),{cleanWithOptionsTask:C,isCleanOptionsArray:w}=(M0(),s1(T0)),{diffSummaryTask:T}=(N2(),s1(j2)),{fetchTask:E}=(Tve(),s1(Y4)),{moveTask:D}=(kve(),s1(Z4)),{pullTask:O}=(jve(),s1(Q4)),{pushTagsTask:ee}=(d4(),s1(l4)),{addRemoteTask:te,getRemotesTask:ne,listRemotesTask:re,remoteTask:ie,removeRemoteTask:ae}=(Bve(),s1(e3)),{getResetMode:oe,resetTask:se}=(X0(),s1(K0)),{stashListTask:k}=(Hve(),s1(t3)),{addSubModuleTask:ce,initSubModuleTask:le,subModuleTask:ue,updateSubModuleTask:A}=(Kve(),s1(n3)),{addAnnotatedTagTask:j,addTagTask:de,tagListTask:fe}=($ve(),s1(c3)),{straightThroughBufferTask:pe,straightThroughStringTask:me}=(w0(),s1(g0));function M(e,t){this._plugins=t,this._executor=new n(e.baseDir,new i(e.maxConcurrentProcesses),t),this._trimmed=e.trimmed}(M.prototype=Object.create(r.prototype)).constructor=M,M.prototype.customBinary=function(e){return this._plugins.reconfigure(`binary`,e),this},M.prototype.env=function(e,t){return arguments.length===1&&typeof e==`object`?this._executor.env=e:(this._executor.env=this._executor.env||{})[e]=t,this},M.prototype.stashList=function(e){return this._runTask(k(h(arguments)||{},c(e)&&e||[]),m(arguments))},M.prototype.mv=function(e,t){return this._runTask(D(e,t),m(arguments))},M.prototype.checkoutLatestTag=function(e){var t=this;return this.pull(function(){t.tags(function(n,r){t.checkout(r.latest,e)})})},M.prototype.pull=function(e,t,n,r){return this._runTask(O(f(e,u),f(t,u),p(arguments)),m(arguments))},M.prototype.fetch=function(e,t){return this._runTask(E(f(e,u),f(t,u),p(arguments)),m(arguments))},M.prototype.silent=function(e){return this._runTask(a(()=>console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this method will be removed.")))},M.prototype.tags=function(e,t){return this._runTask(fe(p(arguments)),m(arguments))},M.prototype.rebase=function(){return this._runTask(me([`rebase`,...p(arguments)]),m(arguments))},M.prototype.reset=function(e){return this._runTask(se(oe(e),p(arguments)),m(arguments))},M.prototype.revert=function(e){let t=m(arguments);return typeof e==`string`?this._runTask(me([`revert`,...p(arguments,0,!0),e]),t):this._runTask(o(`Commit must be a string`),t)},M.prototype.addTag=function(e){let t=typeof e==`string`?de(e):o(`Git.addTag requires a tag name`);return this._runTask(t,m(arguments))},M.prototype.addAnnotatedTag=function(e,t){return this._runTask(j(e,t),m(arguments))},M.prototype.deleteLocalBranch=function(e,t,n){return this._runTask(b(e,typeof t==`boolean`?t:!1),m(arguments))},M.prototype.deleteLocalBranches=function(e,t,n){return this._runTask(y(e,typeof t==`boolean`?t:!1),m(arguments))},M.prototype.branch=function(e,t){return this._runTask(_(p(arguments)),m(arguments))},M.prototype.branchLocal=function(e){return this._runTask(v(),m(arguments))},M.prototype.raw=function(e){let t=!Array.isArray(e),n=[].slice.call(t?arguments:e,0);for(let e=0;e<n.length&&t;e++)if(!l(n[e])){n.splice(e,n.length-e);break}n.push(...p(arguments,0,!0));var r=m(arguments);return n.length?this._runTask(me(n,this._trimmed),r):this._runTask(o(`Raw: must supply one or more command to execute`),r)},M.prototype.submoduleAdd=function(e,t,n){return this._runTask(ce(e,t),m(arguments))},M.prototype.submoduleUpdate=function(e,t){return this._runTask(A(p(arguments,!0)),m(arguments))},M.prototype.submoduleInit=function(e,t){return this._runTask(le(p(arguments,!0)),m(arguments))},M.prototype.subModule=function(e,t){return this._runTask(ue(p(arguments)),m(arguments))},M.prototype.listRemote=function(){return this._runTask(re(p(arguments)),m(arguments))},M.prototype.addRemote=function(e,t,n){return this._runTask(te(e,t,p(arguments)),m(arguments))},M.prototype.removeRemote=function(e,t){return this._runTask(ae(e),m(arguments))},M.prototype.getRemotes=function(e,t){return this._runTask(ne(e===!0),m(arguments))},M.prototype.remote=function(e,t){return this._runTask(ie(p(arguments)),m(arguments))},M.prototype.tag=function(e,t){let n=p(arguments);return n[0]!==`tag`&&n.unshift(`tag`),this._runTask(me(n),m(arguments))},M.prototype.updateServerInfo=function(e){return this._runTask(me([`update-server-info`]),m(arguments))},M.prototype.pushTags=function(e,t){let n=ee({remote:f(e,u)},p(arguments));return this._runTask(n,m(arguments))},M.prototype.rm=function(e){return this._runTask(me([`rm`,`-f`,...s(e)]),m(arguments))},M.prototype.rmKeepLocal=function(e){return this._runTask(me([`rm`,`--cached`,...s(e)]),m(arguments))},M.prototype.catFile=function(e,t){return this._catFile(`utf-8`,arguments)},M.prototype.binaryCatFile=function(){return this._catFile(`buffer`,arguments)},M.prototype._catFile=function(e,t){var n=m(t),r=[`cat-file`],i=t[0];if(typeof i==`string`)return this._runTask(o(`Git.catFile: options must be supplied as an array of strings`),n);Array.isArray(i)&&r.push.apply(r,i);let a=e===`buffer`?pe(r):me(r);return this._runTask(a,n)},M.prototype.diff=function(e,t){let n=u(e)?o(`git.diff: supplying options as a single string is no longer supported, switch to an array of strings`):me([`diff`,...p(arguments)]);return this._runTask(n,m(arguments))},M.prototype.diffSummary=function(){return this._runTask(T(p(arguments,1)),m(arguments))},M.prototype.applyPatch=function(e){let t=d(e)?g(s(e),p([].slice.call(arguments,1))):o(`git.applyPatch requires one or more string patches as the first argument`);return this._runTask(t,m(arguments))},M.prototype.revparse=function(){let e=[`rev-parse`,...p(arguments,!0)];return this._runTask(me(e,!0),m(arguments))},M.prototype.clean=function(e,t,n){let r=w(e),i=r&&e.join(``)||f(e,u)||``,a=p([].slice.call(arguments,+!!r));return this._runTask(C(i,a),m(arguments))},M.prototype.exec=function(e){return this._runTask({commands:[],format:`utf-8`,parser(){typeof e==`function`&&e()}})},M.prototype.clearQueue=function(){return this._runTask(a(()=>console.warn(`simple-git deprecation notice: clearQueue() is deprecated and will be removed, switch to using the abortPlugin instead.`)))},M.prototype.checkIgnore=function(e,t){return this._runTask(x(s(f(e,d,[]))),m(arguments))},M.prototype.checkIsRepo=function(e,t){return this._runTask(S(f(e,u)),m(arguments))},t.exports=M}});l1(),l1(),l1(),d1(),p1(),d0(),M0(),L0(),B0(),G0(),X0(),i0(),i0(),(0,$$.deferred)().promise,i0(),l1(),i0(),i0(),i0(),i0(),eye(),d1(),W$(`checkpoint-chain`);function l3(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function tye(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}W$(`shadow-lock`),W$(`shadow-op-gate`),W$(`shadow-repo`),(()=>{let e=process.env.OK_GIT_TIMEOUT_MS;if(!e)return 3e4;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:3e4})(),(()=>{let e=process.env.OK_SHADOW_MAINTENANCE_GC_TIMEOUT_MS;if(!e)return 6e5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:6e5})(),(()=>{let e=process.env.OK_SHADOW_STAGE_TIMEOUT_MS;if(!e)return 3e5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:3e5})(),wX.fileSystem,wX.gitUpstream,wX.service,wX.generator,W$(`bridge-loss-detector`),W$(`checkpoint`);function u3(e){let t=me(e).toLowerCase();return Nl.includes(t)}function nye(e){let t=e.toLowerCase();for(let n of Nl)if(t.endsWith(n))return e.slice(0,-n.length);return e}function rye(e){return e===`__system__`}const iye=new Set(kl);function aye(e){return iye.has(e)}function oye(e){return jl(e)}function sye(e){return rye(e)||aye(e)||oye(e)}W$(`parse-pool`),Math.max(1,Math.min(4,ie()-1)),G$(()=>{}),W$(`bridge-watchdog`),G$(()=>{}),W$(`server-observers`),W$(`server-observers`),W$(`agent-sessions`);function d3(e){return{...e,windowsHide:!0}}function cye(){try{let e=ve(pe(Se(import.meta.url)),`..`,`package.json`),t=JSON.parse(S(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}cye(),RegExp(`^(?:${`do you mind.i would like you to.i'd like you to.i want you to.i need you to.i would like to.i'd like to.i want to.i need to.we need to.we want to.we should.go ahead and.take a look at.have a look at.look into.look at.help me with.help me to.help me.can you.could you.would you.will you.can we.could we.should we.let's.lets.try to.please.kindly.hello.alright.actually.anyway.also.okay.hey.hi.yo.ok.so.pls.plz.just.maybe`.split(`.`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})\\b(?:[\\s,:;!.\\-–—]+|$)`,`i`),Fe(s);const lye=co({source:F(),pluginProvider:F().optional(),skill:F().optional(),ref:F().optional(),contentHash:F(),files:z(F()).optional(),localHash:F().optional(),baselineRef:F().optional(),publisher:F().optional(),importedAt:Ma(),autoUpdate:L().optional()});co({schema:U(1),skills:V(F(),lye).default({})}),new Set(Object.values(Xl)),new Set([...new Set([`.git`,`node_modules`]),`scripts`,`references`]);const f3=[`agents`,`claude`,`cursor`,`codex`,`opencode`,`pi`,`copilot`];var uye=i(((e,t)=>{t.exports=n;function n(){this.pending=0,this.max=1/0,this.listeners=[],this.waiting=[],this.error=null}n.prototype.go=function(e){this.pending<this.max?i(this,e):this.waiting.push(e)},n.prototype.wait=function(e){this.pending===0?e(this.error):this.listeners.push(e)},n.prototype.hold=function(){return r(this)};function r(e){e.pending+=1;var t=!1;return n;function n(n){if(t)throw Error(`callback called twice`);if(t=!0,e.error=e.error||n,--e.pending,e.waiting.length>0&&e.pending<e.max)i(e,e.waiting.shift());else if(e.pending===0){var a=e.listeners;e.listeners=[],a.forEach(r)}}function r(t){t(e.error)}}function i(e,t){t(r(e))}})),dye=i((e=>{var n=t(`fs`),r=t(`util`),i=t(`stream`),a=i.Readable,o=i.PassThrough,s=uye(),c=t(`events`).EventEmitter;e.BufferSlicer=d,e.FdSlicer=l,r.inherits(l,c);function l(e){c.call(this),this.fd=e,this.pend=new s,this.pend.max=1,this.refCount=0}l.prototype.read=function(e,t,r,i,a){var o=this;o.pend.go(function(s){n.read(o.fd,e,t,r,i,function(e,t,n){s(),a(e,t,n)})})},l.prototype.createReadStream=function(e){return new u(this,e)},l.prototype.ref=function(){this.refCount+=1},l.prototype.unref=function(){var e=this;if(--e.refCount,e.refCount<0)throw Error(`invalid unref`);if(e.refCount>0)return;n.close(e.fd,t);function t(t){t?e.emit(`error`,t):e.emit(`close`)}},r.inherits(u,a);function u(e,t){t||={},a.call(this,t),this.context=e,this.context.ref(),this.start=t.start||0,this.endOffset=t.end,this.pos=this.start}u.prototype._read=function(e){var t=this,r=Math.min(t._readableState.highWaterMark,e);if(t.endOffset!=null&&(r=Math.min(r,t.endOffset-t.pos)),r<=0){t.push(null),this._cleanup();return}t.context.pend.go(function(e){var i=Buffer.allocUnsafe(r);n.read(t.context.fd,i,0,r,t.pos,function(n,r){n?t.destroy(n):r===0?(t.push(null),t._cleanup()):(t.pos+=r,t.push(i.slice(0,r))),e()})})},u.prototype._destroy=function(e,t){this._cleanup(),t(e)},u.prototype._cleanup=function(){this.context!=null&&(this.context.unref(),this.context=null)},r.inherits(d,c);function d(e){c.call(this),this.refCount=0,this.buffer=e}d.prototype.read=function(e,t,n,r,i){if(!(0<=t&&t<=e.length))throw RangeError(`offset outside buffer: 0 <= `+t+` <= `+e.length);if(r<0)throw RangeError(`position is negative: `+r);if(t+n>e.length&&(n=e.length-t),r+n>this.buffer.length&&(n=this.buffer.length-r),n<=0){setImmediate(function(){i(null,0)});return}this.buffer.copy(e,t,r,r+n),setImmediate(function(){i(null,n)})},d.prototype.createReadStream=function(e){e||={};var t=new o(e);t.start=e.start||0,t.endOffset=e.end,t.pos=t.endOffset||this.buffer.length;for(var n=this.buffer.slice(t.start,t.pos),r=65536,i=0;;){var a=i+r;if(a>=n.length){i<n.length&&t.write(n.slice(i,n.length));break}t.write(n.slice(i,a)),i=a}return t.end(),t},d.prototype.ref=function(){this.refCount+=1},d.prototype.unref=function(){if(--this.refCount,this.refCount<0)throw Error(`invalid unref`)}})),fye=i(((e,t)=>{let n=new Int32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function r(e){let t=-1;for(let r of e)t=n[(t^r)&255]^t>>>8;return(t^-1)>>>0}t.exports=r}));i((e=>{t(`fs`);var n=t(`zlib`);dye();var r=t(`util`),i=t(`events`).EventEmitter,a=t(`stream`).Transform,o=t(`stream`).PassThrough,s=t(`stream`).Writable;let c=typeof n.crc32==`function`?n.crc32:fye();r.inherits(l,i);function l(e,t,n,r,a,o,s,c,l,u){var f=this;i.call(f),f.reader=e,f.reader.on(`error`,function(e){d(f,e)}),f.reader.once(`close`,function(){f.emit(`close`)}),f.readEntryCursor=t,f.fileSize=n,f.entryCount=r,f.comment=a,f.entriesRead=0,f.autoClose=!!o,f.lazyEntries=!!s,f.decodeStrings=!!c,f.validateEntrySizes=!!l,f.strictFileNames=!!u,f.isOpen=!0,f.emittedError=!1,f.hasEachEntryBeenCalled=!1,f.lazyEntries||f._readEntry()}l.prototype.close=function(){this.isOpen&&(this.isOpen=!1,this.reader.unref())};function u(e,t){e.autoClose&&e.close(),d(e,t)}function d(e,t){e.emittedError||(e.emittedError=!0,e.emit(`error`,t))}l.prototype.readEntry=function(){if(!this.lazyEntries)throw Error(`readEntry() called without lazyEntries:true`);this._readEntry()},l.prototype._readEntry=function(){var e=this;if(e.entryCount===e.entriesRead){setImmediate(function(){e.autoClose&&e.close(),!e.emittedError&&e.emit(`end`)});return}if(!e.emittedError){var t=T(46);v(e.reader,t,0,t.length,e.readEntryCursor,function(n){if(n)return u(e,n);if(!e.emittedError){var r=new f,i=t.readUInt32LE(0);if(i!==33639248)return u(e,Error(`invalid central directory file header signature: 0x`+i.toString(16)));if(r.versionMadeBy=t.readUInt16LE(4),r.versionNeededToExtract=t.readUInt16LE(6),r.generalPurposeBitFlag=t.readUInt16LE(8),r.compressionMethod=t.readUInt16LE(10),r.lastModFileTime=t.readUInt16LE(12),r.lastModFileDate=t.readUInt16LE(14),r.crc32=t.readUInt32LE(16),r.compressedSize=t.readUInt32LE(20),r.uncompressedSize=t.readUInt32LE(24),r.fileNameLength=t.readUInt16LE(28),r.extraFieldLength=t.readUInt16LE(30),r.fileCommentLength=t.readUInt16LE(32),r.internalFileAttributes=t.readUInt16LE(36),r.externalFileAttributes=t.readUInt32LE(38),r.relativeOffsetOfLocalHeader=t.readUInt32LE(42),r.generalPurposeBitFlag&64)return u(e,Error(`strong encryption is not supported`));e.readEntryCursor+=46,t=T(r.fileNameLength+r.extraFieldLength+r.fileCommentLength),v(e.reader,t,0,t.length,e.readEntryCursor,function(n){if(n)return u(e,n);if(!e.emittedError){r.fileNameRaw=t.subarray(0,r.fileNameLength);var i=r.fileNameLength+r.extraFieldLength;r.extraFieldRaw=t.subarray(r.fileNameLength,i),r.fileCommentRaw=t.subarray(i,i+r.fileCommentLength);try{r.extraFields=_(r.extraFieldRaw)}catch(t){return u(e,t)}if(e.decodeStrings){var a=(r.generalPurposeBitFlag&2048)!=0;r.fileComment=C(r.fileCommentRaw,a),r.fileName=h(r.generalPurposeBitFlag,r.fileNameRaw,r.extraFields,e.strictFileNames);var o=g(r.fileName);if(o!=null)return u(e,Error(o))}else r.fileComment=r.fileCommentRaw,r.fileName=r.fileNameRaw;r.comment=r.fileComment,e.readEntryCursor+=t.length,e.entriesRead+=1;for(var s=0;s<r.extraFields.length;s++){var c=r.extraFields[s];if(c.id===1){var l=c.data,d=0;if(r.uncompressedSize===4294967295){if(d+8>l.length)return u(e,Error(`zip64 extended information extra field does not include uncompressed size`));r.uncompressedSize=w(l,d),d+=8}if(r.compressedSize===4294967295){if(d+8>l.length)return u(e,Error(`zip64 extended information extra field does not include compressed size`));r.compressedSize=w(l,d),d+=8}if(r.relativeOffsetOfLocalHeader===4294967295){if(d+8>l.length)return u(e,Error(`zip64 extended information extra field does not include relative header offset`));r.relativeOffsetOfLocalHeader=w(l,d),d+=8}break}}if(e.validateEntrySizes&&r.compressionMethod===0){var f=r.uncompressedSize;if(r.isEncrypted()&&(f+=12),r.compressedSize!==f){var p=`compressed/uncompressed size mismatch for stored file: `+r.compressedSize+` != `+r.uncompressedSize;return u(e,Error(p))}}e.emit(`entry`,r),e.lazyEntries||e._readEntry()}})}})}},l.prototype.eachEntry=function(){let e=this;if(!e.lazyEntries)throw Error(`eachEntry() requires lazyEntries: true`);if(e.hasEachEntryBeenCalled)throw Error(`eachEntry() must only be called once per ZipFile`);e.hasEachEntryBeenCalled=!0;let t=null;e.on(`entry`,r),e.on(`end`,i),e.on(`error`,a);function n(){e.removeListener(`entry`,r),e.removeListener(`end`,i),e.removeListener(`error`,a),e.autoClose&&e.close()}function r(e){let{resolve:n}=t;t=null,n({value:e})}function i(){let{resolve:e}=t;t=null,n(),e({done:!0})}function a(e){let{reject:r}=t;t=null,n(),r(e)}return{[Symbol.asyncIterator](){return this},next(){let n=new Promise((e,n)=>{if(t!=null)throw Error(`next() called before previous Promise was resolved.`);t={resolve:e,reject:n}});return e.readEntry(),n},return(e){return n(),Promise.resolve({done:!0,value:e})},throw(e){return n(),Promise.reject(e)}}},l.prototype.openReadStream=function(e,t,n){var r=this,i=0,a=e.compressedSize;if(n??(n=t,t=null),t==null)t={};else{if(t.decodeFileData===!1){if(t.decrypt!=null)throw Error(`cannot use options.decrypt when options.decodeFileData === false`);if(t.decompress!=null)throw Error(`cannot use options.decompress when options.decodeFileData === false`)}else{if(t.decrypt!=null){if(!e.isEncrypted())throw Error(`options.decrypt can only be specified for encrypted entries. See also option decodeFileData.`);if(t.decrypt!==!1)throw Error(`invalid options.decrypt value: `+t.decrypt);if(e.isCompressed()&&t.decompress!==!1)throw Error(`entry is encrypted and compressed, and options.decompress !== false. See also option decodeFileData.`)}if(t.decompress!=null){if(!e.isCompressed())throw Error(`options.decompress can only be specified for compressed entries. See also option decodeFileData.`);if(!(t.decompress===!1||t.decompress===!0))throw Error(`invalid options.decompress value: `+t.decompress);s=t.decompress}}if(t.start!=null){if(i=t.start,i<0)throw Error(`options.start < 0`);if(i>e.compressedSize)throw Error(`options.start > entry.compressedSize`)}if(t.end!=null){if(a=t.end,a<0)throw Error(`options.end < 0`);if(a>e.compressedSize)throw Error(`options.end > entry.compressedSize`);if(a<i)throw Error(`options.end < options.start`)}}var o=t.decodeFileData===!1||(e.compressionMethod===0||e.compressionMethod===8&&t.decompress===!1)&&(!e.isEncrypted()||t.decrypt===!1);if((t.start!=null||t.end!=null)&&!o)throw Error(`start/end range require options.decodeFileData === false for non-trivial encoded entries.`);if(!r.isOpen)return n(Error(`closed`));if(e.isEncrypted()&&!o&&t.decrypt!==!1)return n(Error(`entry is encrypted, and options.decodeFileData !== false`));var s;if(o)s=!1;else if(e.compressionMethod===8)s=t.decodeFileData!==!0;else return n(Error(`unsupported compression method: `+e.compressionMethod));r.readLocalFileHeader(e,{minimal:!0},function(t,o){if(t)return n(t);r.openReadStreamLowLevel(o.fileDataStart,e.compressedSize,i,a,s,e.uncompressedSize,n)})},l.prototype.openReadStreamLowLevel=function(e,t,r,i,a,o,s){var c=this;e+t;var l=c.reader.createReadStream({start:e+r,end:e+i}),u=l;if(a){var d=!1,f=n.createInflateRaw();l.on(`error`,function(e){setImmediate(function(){d||f.emit(`error`,e)})}),l.pipe(f),c.validateEntrySizes?(u=new y(o),f.on(`error`,function(e){setImmediate(function(){d||u.emit(`error`,e)})}),f.pipe(u)):u=f,E(u,function(){d=!0,f!==u&&f.unpipe(u),l.unpipe(f),l.destroy()})}s(null,u)},l.prototype.readLocalFileHeader=function(e,t,n){var r=this;n??(n=t,t=null),t??={},r.reader.ref();var i=T(30);v(r.reader,i,0,i.length,e.relativeOffsetOfLocalHeader,function(a){try{if(a)return n(a);var o=i.readUInt32LE(0);if(o!==67324752)return n(Error(`invalid local file header signature: 0x`+o.toString(16)));var s=i.readUInt16LE(26),c=i.readUInt16LE(28),l=e.relativeOffsetOfLocalHeader+30+s+c;if(l+e.compressedSize>r.fileSize)return n(Error(`file data overflows file bounds: `+l+` + `+e.compressedSize+` > `+r.fileSize));if(t.minimal)return n(null,{fileDataStart:l});var u=new p;u.fileDataStart=l,u.versionNeededToExtract=i.readUInt16LE(4),u.generalPurposeBitFlag=i.readUInt16LE(6),u.compressionMethod=i.readUInt16LE(8),u.lastModFileTime=i.readUInt16LE(10),u.lastModFileDate=i.readUInt16LE(12),u.crc32=i.readUInt32LE(14),u.compressedSize=i.readUInt32LE(18),u.uncompressedSize=i.readUInt32LE(22),u.fileNameLength=s,u.extraFieldLength=c,i=T(s+c),r.reader.ref(),v(r.reader,i,0,i.length,e.relativeOffsetOfLocalHeader+30,function(e){try{return e?n(e):(u.fileName=i.subarray(0,s),u.extraField=i.subarray(s),n(null,u))}finally{r.reader.unref()}})}finally{r.reader.unref()}})},l.prototype.openReadStreamPromise=function(e,t){return new Promise((n,r)=>{this.openReadStream(e,t,function(e,t){if(e)return r(e);n(t)})})},l.prototype.openReadStreamLowLevelPromise=function(e,t,n,r,i,a){return new Promise((o,s)=>{this.openReadStream(e,t,n,r,i,a,function(e,t){if(e)return s(e);o(t)})})},l.prototype.readLocalFileHeaderPromise=function(e,t){return new Promise((n,r)=>{this.readLocalFileHeader(e,t,function(e,t){if(e)return r(e);n(t)})})};function f(){}f.prototype.getLastModDate=function(e){if(e??={},!e.forceDosFormat)for(var t=0;t<this.extraFields.length;t++){var n=this.extraFields[t];if(n.id===21589){var r=n.data;if(r.length<5||!(r[0]&1))continue;var i=r.readInt32LE(1);return new Date(i*1e3)}else if(n.id===10){var r=n.data;if(r.length!==32||r.readUInt16LE(4)!==1||r.readUInt16LE(6)!==24)continue;var a=(r.readUInt32LE(8)+4294967296*r.readInt32LE(12))/1e4-0xa9730b66800;return new Date(a)}}return m(this.lastModFileDate,this.lastModFileTime,e.timezone)},f.prototype.canDecodeFileData=function(){return!this.isEncrypted()&&(this.compressionMethod===0||this.compressionMethod===8)},f.prototype.isEncrypted=function(){return(this.generalPurposeBitFlag&1)!=0},f.prototype.isCompressed=function(){return this.compressionMethod===8};function p(){}function m(e,t,n){var r=e&31,i=(e>>5&15)-1,a=(e>>9&127)+1980,o=0,s=(t&31)*2,c=t>>5&63,l=t>>11&31;if(n==null||n===`local`)return new Date(a,i,r,l,c,s,o);if(n===`UTC`)return new Date(Date.UTC(a,i,r,l,c,s,o));throw Error(`unrecognized options.timezone: `+options.timezone)}function h(e,t,n,r){for(var i=null,a=0;a<n.length;a++){var o=n[a];if(o.id===28789){if(o.data.length<6||o.data.readUInt8(0)!==1)continue;var s=o.data.readUInt32LE(1);if(c(t)!==s)continue;i=C(o.data.subarray(5),!0);break}}return i??=C(t,(e&2048)!=0),r||(i=i.replace(/\\/g,`/`)),i}function g(e){return e.indexOf(`\\`)===-1?/^[a-zA-Z]:/.test(e)||/^\//.test(e)?`absolute path: `+e:e.split(`/`).indexOf(`..`)===-1?null:`invalid relative path: `+e:`invalid characters in fileName: `+e}function _(e){for(var t=[],n=0;n<e.length-3;){var r=e.readUInt16LE(n+0),i=e.readUInt16LE(n+2),a=n+4,o=a+i;if(o>e.length)throw Error(`extra field length exceeds extra field buffer size`);var s=e.subarray(a,o);t.push({id:r,data:s}),n=o}return t}function v(e,t,n,r,i,a){if(r===0)return setImmediate(function(){a(null,T(0))});e.read(t,n,r,i,function(e,t){if(e)return a(e);if(t<r)return a(Error(`unexpected EOF`));a()})}r.inherits(y,a);function y(e){a.call(this),this.actualByteCount=0,this.expectedByteCount=e}y.prototype._transform=function(e,t,n){if(this.actualByteCount+=e.length,this.actualByteCount>this.expectedByteCount){var r=`too many bytes in the stream. expected `+this.expectedByteCount+`. got at least `+this.actualByteCount;return n(Error(r))}n(null,e)},y.prototype._flush=function(e){if(this.actualByteCount<this.expectedByteCount){var t=`not enough bytes in the stream. expected `+this.expectedByteCount+`. got only `+this.actualByteCount;return e(Error(t))}e()},r.inherits(b,i);function b(){i.call(this),this.refCount=0}b.prototype.ref=function(){this.refCount+=1},b.prototype.unref=function(){var e=this;if(--e.refCount,e.refCount>0)return;if(e.refCount<0)throw Error(`invalid unref`);e.close(t);function t(t){if(t)return e.emit(`error`,t);e.emit(`close`)}},b.prototype.createReadStream=function(e){e??={};var t=e.start,n=e.end;if(t===n){var r=new o;return setImmediate(function(){r.end()}),r}var i=this._readStreamForRange(t,n),a=!1,s=new x(this);i.on(`error`,function(e){setImmediate(function(){a||s.emit(`error`,e)})}),E(s,function(){i.unpipe(s),s.unref(),i.destroy()});var c=new y(n-t);return s.on(`error`,function(e){setImmediate(function(){a||c.emit(`error`,e)})}),E(c,function(){a=!0,s.unpipe(c),s.destroy()}),i.pipe(s).pipe(c)},b.prototype._readStreamForRange=function(e,t){throw Error(`not implemented`)},b.prototype.read=function(e,t,n,r,i){var a=this.createReadStream({start:r,end:r+n}),o=new s,c=0;o._write=function(n,r,i){n.copy(e,t+c,0,n.length),c+=n.length,i()},o.on(`finish`,i),a.on(`error`,function(e){i(e)}),a.pipe(o)},b.prototype.close=function(e){setImmediate(e)},r.inherits(x,o);function x(e){o.call(this),this.context=e,this.context.ref(),this.unreffedYet=!1}x.prototype._flush=function(e){this.unref(),e()},x.prototype.unref=function(e){this.unreffedYet||(this.unreffedYet=!0,this.context.unref())};var S=`\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\xA0`;function C(e,t){if(t)return e.toString(`utf8`);for(var n=``,r=0;r<e.length;r++)n+=S[e[r]];return n}function w(e,t){var n=e.readUInt32LE(t);return e.readUInt32LE(t+4)*4294967296+n}var T=typeof Buffer.allocUnsafe==`function`?function(e){return Buffer.allocUnsafe(e)}:function(e){return new Buffer(e)};function E(e,t){typeof e.destroy==`function`?e._destroy=function(e,n){t(),n?.(e)}:e.destroy=t}}))(),Object.freeze({source:`local`,skipStoreHooks:!0,context:Object.freeze({origin:`effect-capture`,paired:!1})});var pye=e(a(),1);const p3={discovery:`open-knowledge-discovery`,project:`open-knowledge`,"write-skill":`open-knowledge-write-skill`};new Set(Object.values(p3));const mye=Object.keys(p3),hye={discovery:`user`,project:`project`,"write-skill":`user`},m3=mye.filter(e=>hye[e]===`user`);new Set(m3.map(e=>p3[e]));const h3=`OpenKnowledge.app/Contents/Resources/cli/dist/assets/skills`;function gye(e,t={}){let n=t.platform??process.platform,r=t.checkDesktop??!1,i=t.home??oe(),a=[],o=process.env.NODE_ENV===`test`;r&&n===`darwin`&&(o||a.push(N(`/Applications`,h3,e)),(!o||t.home!==void 0)&&a.push(N(i,`Applications`,h3,e))),a.push(Se(new URL(`../dist/assets/skills/${e}`,import.meta.url))),a.push(Se(new URL(`../assets/skills/${e}`,import.meta.url))),a.push(Se(new URL(`./assets/skills/${e}`,import.meta.url)));for(let e of a)if(g(e))return e;throw Error(`Bundled skill asset directory not found for bundle '${e}'. Tried: ${a.join(`, `)}. This usually means the CLI build did not copy packages/server/assets into dist/assets. Run \`cd packages/cli && bun run build\` before publishing.`)}const g3={start:I().int().nonnegative().optional(),end:I().int().nonnegative().optional(),quote:F().min(1).optional(),prefix:F().max(1e3).optional(),suffix:F().max(1e3).optional()};B({docName:F().min(1),...g3,propertyKey:F().min(1).optional(),propertyPath:z(uo([F(),I().int().nonnegative()])).optional(),body:F(),queue:L().optional(),summary:F().optional()});const _3=rne();fo(`action`,[B({action:U(`edit`),id:_3,body:F(),summary:F().optional()}),B({action:U(`resolve`),id:_3,summary:F().optional()}),B({action:U(`reopen`),id:_3,summary:F().optional()}),B({action:U(`replace`),id:_3,...g3,summary:F().optional()}),B({action:U(`queue`),id:_3,summary:F().optional()}),B({action:U(`unqueue`),id:_3,summary:F().optional()}),B({action:U(`dispatch-prepare`),id:_3,summary:F().optional()}),B({action:U(`dispatch-complete`),id:_3,summary:F().optional()}),B({action:U(`dispatch-prepare-batch`),ids:z(_3).min(1).max(200),summary:F().optional()}),B({action:U(`dispatch-complete-batch`),ids:z(_3).min(1).max(200),summary:F().optional()})]);const v3="Absolute host path inside the target OpenKnowledge project. Required when the MCP server is registered globally (e.g. `npx @inkeep/open-knowledge mcp` once at the host level, routing per call), unless the MCP client advertises exactly one root via the `roots` capability — that single root is then used as the implicit `cwd`. Optional when the server is anchored to a single project (the per-project HTTP MCP server defaults to its configured project root).";F().max(200).optional().describe(`Optional one-line user-outcome description (≤80 chars). Appears as a bullet in the timeline.`),F().length(40).regex(/^[0-9a-f]+$/i).describe("A 40-character commit SHA identifying a saved version. Produced by `checkpoint`, listed by `history` as `entries[].version`, and consumed here — the same `version` field name across all three."),F().nullable().describe("Route-only preview URL (`/#/<doc>`, no host:port), or null when no UI is running."),F().optional().describe(`How the previewUrl was resolved (e.g. the UI lock).`),F().optional().describe(`Route of the prior/removed path, for closing a stale preview tab.`);const _ye=B({value:F(),truncatedFrom:I().optional(),hint:F().optional()}).describe(`Normalized change-note summary, when one was recorded.`),vye=z(V(F(),R()));V(F(),R()).optional().describe("Preview-attach hint (`{ action, previewUrl?, message? }`) when relevant."),z(xJ).describe('Outbound internal links in the just-written doc that do not resolve. Always present — `[]` means every link resolves. Each: `{ href (as written), resolvedTo (the docName or content-root file path it pointed at, or null), reason: "no-such-doc" | "no-such-file" | "unresolvable" }`. Report-only — the write landed regardless; fix in a follow-up edit.'),_ye.optional(),z(yJ).min(1).optional().describe("Advisory entries discriminated by `kind`. Write-integrity kinds — `content-divergence` (converged Y.Text didn't byte-match what you composed) and `disk-edit-reconciled` (an out-of-band disk edit was folded in before your write) — mean re-read the doc. The renderability kind `mermaid-parse-error` means the write landed but that fence will not render — fix it and re-edit."),z(B({name:F(),description:F().optional()})).min(1).optional().describe("Templates the parent folder offers, present only when a create passed no `template`. A nudge — the write already landed; pass `template` next time to match the folder's shape.");const yye=F().optional().describe("Auto-duplicated body text. `textPlusStructured` mirrors the visible body here as a Claude / Claude Desktop client-quirk workaround (those clients hide `content[]` when `structuredContent` is present). Internal — programmatic consumers should prefer the `content[0].text` channel.");function y3(e){return{text:yye,...e}}new class{capacity;store;writeIndex=0;filled=!1;constructor(e){if(!Number.isInteger(e)||e<=0)throw RangeError(`RingBuffer capacity must be a positive integer, got ${e}`);this.capacity=e,this.store=Array(e)}push(e){this.store[this.writeIndex]=e,this.writeIndex=(this.writeIndex+1)%this.capacity,this.writeIndex===0&&(this.filled=!0)}read(){let e=[],t=this.filled?this.capacity:this.writeIndex;for(let n=1;n<=t;n++){let t=(this.writeIndex-n+this.capacity)%this.capacity,r=this.store[t];r!==void 0&&e.push(r)}return e}get size(){return this.filled?this.capacity:this.writeIndex}}(256),Wl.cursor,Wl.codex,Wl[`claude-desktop`],W$(`embeddings`),W$(`embeddings`);function bye(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return`${t.protocol}//${t.host.toLowerCase()}${n}`}catch{return e.trim().replace(/\/+$/,``)}}bye(ys),W$(`embeddings`),W$(`embeddings`);const xye=String.raw`\[\[([^\n#[\]|]+)(?:#([^\n[\]|]+))?(?:\|([^\n[\]]+))?\]\]`,Sye=String.raw`\((<[^>\n]+>|[^)\s\n]+)((?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?)\)`,b3=String.raw`([^\]\n]*)`,x3=String.raw`([^\]\n]*(?:\][^[\]\n]*)?)`,S3=e=>RegExp(`(!?)${xye}`,e),C3=(e,t)=>RegExp(`(!?)\\[${e}\\]${Sye}`,t);S3(`y`),S3(`g`),C3(b3,`y`),C3(x3,`y`),C3(b3,`g`),C3(x3,`g`);const Cye=String.raw`(!?)\[([^\]\n]*)\](?:\[([^\]\n]*)\])?`;new RegExp(Cye,`y`);function w3(e){return e.replace(/\\/g,`/`)}B({target:H(Object.keys({"claude-cowork":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},"claude-code":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},codex:{type:`app-bundle`,appName:`Codex`,urlScheme:`codex:`,probeScheme:`codex`,quitFirst:!0},cursor:{type:`cli-binary`,binaryName:`cursor`,urlScheme:`cursor:`}})),url:F().min(1).max(4096),workspacePath:F().optional()}),B({}).loose(),W$(`installed-skills-marker`);var T3=e(i(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.*\/|^\.+$/,l=`node-ignore`;typeof Symbol<`u`&&(l=Symbol.for(`node-ignore`));let u=l,d=(e,t,n)=>Object.defineProperty(e,t,{value:n}),f=/([0-z])-([0-z])/g,p=()=>!1,m=e=>e.replace(f,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),h=e=>{let{length:t}=e;return e.slice(0,t-t%2)},g=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${h(r)}${i}`:i===`]`&&r.length%2==0?`[${m(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(e,t)=>`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`]],_=Object.create(null),v=(e,t)=>{let n=_[e];return n||(n=g.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),_[e]=n),t?new RegExp(n,`i`):new RegExp(n)},y=e=>typeof e==`string`,b=e=>e&&y(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,x=e=>e.split(s);var S=class{constructor(e,t,n,r){this.origin=e,this.pattern=t,this.negative=n,this.regex=r}};let C=(e,t)=>{let n=e,r=!1;e.indexOf(`!`)===0&&(r=!0,e=e.substr(1)),e=e.replace(a,`!`).replace(o,`#`);let i=v(e,t);return new S(n,e,r,i)},w=(e,t)=>{throw new t(e)},T=(e,t,n)=>y(e)?e?T.isNotRelative(e)?n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),E=e=>c.test(e);T.isNotRelative=E,T.convert=e=>e;var D=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){d(this,u,!0),this._rules=[],this._ignoreCase=t,this._allowRelativePaths=n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[u]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(b(e)){let t=C(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(y(e)?x(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,t){let n=!1,r=!1;return this._rules.forEach(i=>{let{negative:a}=i;r===a&&n!==r||a&&!n&&!r&&!t||i.regex.test(e)&&(n=!a,r=a)}),{ignored:n,unignored:r}}_test(e,t,n,r){let i=e&&T.convert(e);return T(i,e,this._allowRelativePaths?p:w),this._t(i,t,n,r)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`),r.pop(),!r.length)return t[e]=this._testOne(e,n);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._testOne(e,n)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let O=e=>new D(e);if(O.isPathValid=e=>T(e&&T.convert(e),e,p),O.default=O,t.exports=O,typeof process<`u`&&(process.env&&process.env.IGNORE_TEST_WIN32||process.platform===`win32`)){T.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;T.isNotRelative=t=>e.test(t)||E(t)}}))(),1);const E3=W$(`content-filter`);Fe(s);const D3=[`.claude`,`.cursor`,`.codex`,`.agents`,`.opencode`,`.pi`],O3=new Set([`node_modules`,`.venv`,`venv`,`env`,`__pycache__`,`vendor`,`dist`,`build`,`out`,`output`,`.next`,`.nuxt`,`.svelte-kit`,`.astro`,`.turbo`,`.cache`,`.parcel-cache`,`coverage`,`.git`,`.ok`,`.open-knowledge`,`.openknowledge`,...D3,`Library`,`Applications`,`.Trash`]),wye=new Set([`.git`,`node_modules`,`.ok`,`.open-knowledge`,`.openknowledge`,...D3]),k3=new Set([`worktrees`,`local`]);function A3(e){let t=Ss(e);if(!Cs(t))throw Error(`Invalid attachment folder path`);if(t===`./`)return{kind:`sibling`};if(t===`/`||t===`.`)return{kind:`content-root`};let n=t.startsWith(`./`),r=(n?t.slice(2):t).split(`/`).filter(e=>e!==``&&e!==`.`).join(`/`);return r===``?n?{kind:`sibling`}:{kind:`content-root`}:{kind:n?`doc-relative`:`fixed`,path:r}}function Tye(e){throw Error(`[AttachmentFolderShape] unhandled variant: ${JSON.stringify(e)}`)}function Eye(e,t,n){let r=me(e).slice(1).toLowerCase();if(!ts.has(r)||t.kind===`sibling`)return!1;let i=e.lastIndexOf(`/`),a=i===-1?``:e.slice(0,i);if(t.kind===`content-root`)return a===``;if(t.kind===`fixed`)return a===t.path||a.startsWith(`${t.path}/`);if(t.kind===`doc-relative`){let e=a===``?[]:a.split(`/`),r=t.path.split(`/`);for(let t=0;t<=e.length-r.length;t++)if(r.every((n,r)=>e[t+r]===n)&&n(e.slice(0,t).join(`/`)))return!0;return!1}return Tye(t)}function j3(e,t){let n=e.split(`/`);for(let e=0;e<n.length;e++){let r=n[e],i=r.toLowerCase()===`.ok`?`.ok`:r;if(wye.has(i)&&!(t&&i===`.ok`&&!k3.has((n[e+1]??``).toLowerCase())))return!0}return!1}function M3(e){return e.startsWith(`${Ml}/`)}function Dye(e){return e===`.ok`||e===`.ok/skills`||e.startsWith(`.ok/skills/`)}const N3=new Set([`.ok`,...D3]),Oye=new Set([...O3].filter(e=>!N3.has(e))),kye=[`.git`,`node_modules`,`.ok/local`,`.ok/worktrees`].flatMap(e=>[e,`${e}/**`,`**/${e}`,`**/${e}/**`]);function Aye(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`);return t.includes(`..`)?!1:t.some(e=>Oye.has(e))?!0:t.some((e,n)=>e.toLowerCase()===`.ok`&&k3.has((t[n+1]??``).toLowerCase()))}const jye=[`.gitignore`,`.ok`,`.ok/config.yml`,`.ok/.gitignore`,`.ok/schemas/frontmatter.json`,`.ok/templates/example.md`,`.ok/skills/example/SKILL.md`,`docs/.ok`,`docs/.ok/frontmatter.yml`,`docs/.ok/templates/example.md`,...D3.flatMap(e=>[e,`${e}/skills/example/SKILL.md`])];function Mye(e){let t=e.trim();if(!t||t.startsWith(`!`)||t.startsWith(`#`))return!1;let n=t.replace(/^\/+/,``).replace(/\/+$/,``).split(`/`);if(n.includes(`..`))return!0;if(Aye(t))return!1;if(n.some(e=>N3.has(e)))return!0;try{let e=(0,T3.default)().add(t);return jye.some(t=>e.ignores(t))}catch{return!0}}function Nye(e){let t=e.filter(e=>e.length>0&&!e.startsWith(`!`)&&!e.startsWith(`#`)&&!Mye(e));return[...new Set([...t,...kye])]}function P3(e,t){for(let n=0;n<t;n++)if(O3.has(e[n])||e[n].toLowerCase()===`.ok`)return!0;return!1}function F3(e){let t=e.split(`/`),n=t.length;return n<3||t[n-3]!==`.ok`||t[n-2]!==`templates`||me(t[n-1])!==`.md`?!1:!P3(t,n-3)}function I3(e){let t=e.split(`/`),n=t.length;return t[n-1]===`.ok`?!P3(t,n-1):n>=2&&t[n-1]===`templates`&&t[n-2]===`.ok`?!P3(t,n-2):!1}function Pye(e){let t=e.split(`/`),n=t.length;return t[0]===`.ok`&&(n===2&&(t[1]===`config.yml`||t[1]===`.gitignore`)||n===3&&t[1]===`schemas`&&t[2].toLowerCase().endsWith(`.json`))||F3(e)?!0:n>=2&&t[n-1]===`frontmatter.yml`&&t[n-2]===`.ok`?!P3(t,n-2):!1}function Fye(e){return e===`.ok`||e===`.ok/schemas`?!0:I3(e)}function Iye(e,t){for(let n of t)if(e===n||e.startsWith(`${n}/`))return!0;return!1}function L3(e,t){if(t.size===0)return!1;for(let n of t)if(e.startsWith(`${n}/`))return!0;return!1}function Lye(e,t){if(t.size===0)return!1;for(let n of t)if(n===e||n.startsWith(`${e}/`)||e.startsWith(`${n}/`))return!0;return!1}const Rye=new Set([`.ds_store`,`.localized`,`thumbs.db`,`desktop.ini`,`.directory`]);function R3(e){return Rye.has(e.slice(e.lastIndexOf(`/`)+1).toLowerCase())}const zye=new Set([`.ssh`,`.aws`,`.gnupg`,`.kube`,`.docker`]);function z3(e){for(let t of e.split(`/`))if(zye.has(t.toLowerCase()))return!0;return!1}const Bye=new Set([`credentials`,`.netrc`,`.npmrc`,`.pgpass`,`.git-credentials`]),Vye=[`.pem`,`.key`,`.p12`,`.pfx`,`.keystore`,`.jks`,`.ppk`];function B3(e){let t=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();if(t===`.env`||t.startsWith(`.env.`)||Bye.has(t)||t.startsWith(`id_rsa`)||t.startsWith(`id_ed25519`)||t.startsWith(`id_ecdsa`)||t.startsWith(`id_dsa`))return!0;for(let e of Vye)if(t.endsWith(e))return!0;return!1}function Hye(e,t){return t===e||t.startsWith(`${e}/`)}const V3=[`.gitignore`,`.okignore`];function Uye(e,t){let n=Wye(e);if(n===null)return[];let r=[];H3(N(n,`info`,`exclude`),t,r,`info/exclude`);let i=Gye(e);return i&&H3(i,t,r,`global excludesfile`),r}function Wye(e){let t=u(`git`,[`rev-parse`,`--git-common-dir`],d3({cwd:e,encoding:`utf-8`,timeout:5e3}));return t.status!==0||!t.stdout?null:ve(e,t.stdout.trim())}function Gye(e){let t=u(`git`,[`config`,`--get`,`--type=path`,`core.excludesfile`],d3({cwd:e,encoding:`utf-8`,timeout:5e3}));if(t.status===0&&t.stdout){let e=t.stdout.trim();if(e)return e}return Kye()}function Kye(){let e=process.env.XDG_CONFIG_HOME?.trim();return N(e&&e.length>0?e:N(oe(),`.config`),`git`,`ignore`)}function H3(e,t,n,r){if(g(e))try{let r=S(e,`utf-8`);t.value+=r.length,n.push(...W3(r))}catch(t){E3.warn({path:e,err:t},`Failed to read ${r} at ${e}`)}}function qye(e){let{projectDir:t,contentDir:n,onAfterRebuild:r,singleDocRelPath:i}=e,a=e.inPlaceSkillDirs??new Set,o=A3(e.attachmentFolderPath??`./`),s=e.skillRootPaths??new Set,c=w3(_e(t,n)),l=c.startsWith(`..`),u,d,f,p,m=0,h=0,_=0;function v(){let e=(0,T3.default)(),r=(0,T3.default)();e.add(`.git`);let i=[],a=0,o=0;for(let n of V3){let o=N(t,n);if(g(o))try{let t=S(o,`utf-8`);a+=t.length;let s=W3(t);i.push(...s),e.add(s),n===`.okignore`&&r.add(s)}catch(e){E3.warn({path:o,err:e},`Failed to read ${n} at ${o}`)}}if(c&&!l)for(let t of V3){let i=N(n,t);if(g(i))try{let n=S(i,`utf-8`);a+=n.length,o++;let s=W3(n).map(e=>G3(e,c));e.add(s),t===`.okignore`&&r.add(s)}catch(e){E3.warn({path:i,err:e},`Failed to read ${t} at ${i}`)}}let s={value:a};o+=K3(n,t,e,r,s),a=s.value;let v=Uye(t,s);a=s.value,v.length>0&&(i.push(...v),e.add(v));let y=Nye(i);return u=e,d=r,f=i,p=y,m=i.length,h=o,_=a,{patternCount:m,nestedFileCount:h,bytes:_}}v();let y=new Map;function b(e,t){if(l&&t?.pathBase!==`project`)return!1;let n=t?.pathBase===`project`||!c?e:`${c}/${e}`;return n.startsWith(`..`)?!1:u.ignores(n)}function x(e,t){return t.pathBase===`project`||!c?e:`${c}/${e}`}function C(e){if(l)return!1;let t=c?`${c}/${e}`:e;return d.ignores(t)}let w=()=>{i===void 0&&U3(n,``,b,y)};w();function T(e){return sye(nye(e))}function E(e){for(let t of e.split(`/`))if(O3.has(t))return!0;return l?!1:b(e)}let D=null,O=null;return{isExcluded(e,t){if(T(e)||B3(e)||z3(e)||!t?.bypassFilters&&Iye(e,s)&&!L3(e,a))return!0;if(!t?.bypassFilters&&(M3(e)||L3(e,a)&&!b(e))){if(i!==void 0)return e!==i;if(u3(e))return!1;let t=me(e).slice(1).toLowerCase();return!ts.has(t)}if(!t?.bypassFilters&&F3(e)||!t?.bypassFilters&&t?.syncScope!==void 0&&Pye(x(e,t.syncScope))&&!b(e,t.syncScope))return i===void 0?!1:e!==i;if(j3(e,t?.showOk)||R3(e))return!0;if(i!==void 0)return e!==i;if(t?.bypassFilters)return t.respectOkignore===!0&&C(e);if(E(e))return!0;if(u3(e)||Eye(e,o,e=>(y.get(e)??0)>0))return!1;let n=me(e).slice(1).toLowerCase();if(ts.has(n)){let t=pe(e),n=t===`.`?``:t;if((y.get(n)??0)>0)return!1}return!0},isDirExcluded(e,t){if(z3(e))return!0;if(!t?.bypassFilters&&(Dye(e)||I3(e)||t?.syncScope!==void 0&&Fye(x(e,t.syncScope))||Lye(e,a)))return!1;if(j3(e,t?.showOk))return!0;if(i!==void 0)return!Hye(e,i);if(t?.bypassFilters)return t.respectOkignore===!0&&(C(e)||C(`${e}/`));for(let t of e.split(`/`))if(O3.has(t))return!0;return l?!1:b(e,t?.syncScope)||b(`${e}/`,t?.syncScope)},isPathIgnored(e,t){return T(e)||B3(e)||z3(e)?!0:M3(e)||L3(e,a)&&!b(e)||F3(e)?!1:j3(e)||R3(e)?!0:t?.bypassFilters?!1:E(e)},getWatcherIgnoreGlobs(){return p},incrementMdDir(e){let t=e===`.`?``:e;y.set(t,(y.get(t)??0)+1)},decrementMdDir(e){let t=e===`.`?``:e,n=y.get(t)??0;n<=1?y.delete(t):y.set(t,n-1)},rebuildDirCount(){let e=new Map(y);y.clear();try{w()}catch(t){for(let[t,n]of e)y.set(t,n);E3.warn({err:t instanceof Error?t:Error(String(t))},`content-filter rebuildDirCount walk failed — retaining previous counts`)}},setAttachmentFolderPath(e){o=A3(e)},refreshInPlaceSkillDirs(){if(e.rescanInPlaceSkillDirs)try{a=e.rescanInPlaceSkillDirs()}catch(e){E3.warn({err:e},`in-place skill re-scan failed — keeping previous allow-list`)}},inPlaceSkillDirsFingerprint(){return[...a].sort().join(`
435
+ `)},peekFreshInPlaceSkillDirsFingerprint(){if(!e.rescanInPlaceSkillDirs)return[...a].sort().join(`
436
+ `);try{return[...e.rescanInPlaceSkillDirs()].sort().join(`
437
+ `)}catch{return[...a].sort().join(`
438
+ `)}},async rebuildIgnorePatterns(){let t=e=>(D=e().finally(()=>{D=null}),D),o=async()=>{if(e.rescanInPlaceSkillDirs)try{a=e.rescanInPlaceSkillDirs()}catch(e){E3.warn({err:e},`in-place skill re-scan failed — keeping previous allow-list`)}let t=u,o=d,s=f,c=p,l=m,g=h,x=_,S=Date.now();return rge(`config.ignore.rebuild`,{attributes:{}},async e=>{try{let t=v();y.clear(),i===void 0&&await Jye(n,b,y);let a=Date.now()-S;if(e.setAttributes({"ok.ignore.pattern_count":t.patternCount,"ok.ignore.nested_file_count":t.nestedFileCount,"ok.ignore.bytes":t.bytes}),E3.info({patternCount:t.patternCount,nestedFileCount:t.nestedFileCount,bytes:t.bytes,durationMs:a},`content-filter rebuild succeeded`),r)try{r()}catch(e){E3.warn({err:e instanceof Error?e:Error(String(e))},`content-filter onAfterRebuild callback threw — derived views may be stale`)}return{ok:!0,patternCount:t.patternCount,nestedFileCount:t.nestedFileCount,bytes:t.bytes,durationMs:a}}catch(e){u=t,d=o,f=s,p=c,m=l,h=g,_=x,y.clear();try{w()}catch(e){E3.warn({err:e instanceof Error?e:Error(String(e))},`content-filter rollback dirCount re-walk failed — sibling-asset counts may be stale until next rebuild`)}let n=e instanceof Error?e.message:String(e);return E3.warn({err:e instanceof Error?e:Error(n)},`content-filter rebuild failed — rolled back to previous state`),{ok:!1,error:{message:n}}}})};return D===null?t(o):(O===null&&(O=D.catch(()=>null).then(()=>(O=null,t(o)))),O)}}}async function Jye(e,t,n){let r=[{dir:e,relPath:``}],i=0;for(;r.length>0;){let{dir:e,relPath:a}=r.pop();i+=1,i>=50&&(i=0,await new Promise(e=>setImmediate(e)));let o;try{o=C(e,{withFileTypes:!0})}catch(t){E3.warn({dir:e,err:t},`Failed to read directory for dir-count: ${e}`);continue}for(let i of o){let o=a?`${a}/${i.name}`:i.name;if(i.isDirectory()){if(O3.has(i.name)||t(o)||t(`${o}/`))continue;r.push({dir:N(e,i.name),relPath:o})}else i.isFile()&&u3(i.name)&&!t(o)&&n.set(a,(n.get(a)??0)+1)}}}function U3(e,t,n,r){let i;try{i=C(e,{withFileTypes:!0})}catch(t){E3.warn({dir:e,err:t},`Failed to read directory for dir-count: ${e}`);return}for(let a of i){let i=t?`${t}/${a.name}`:a.name;if(a.isDirectory()){if(O3.has(a.name)||n(i)||n(`${i}/`))continue;U3(N(e,a.name),i,n,r)}else a.isFile()&&u3(a.name)&&!n(i)&&r.set(t,(r.get(t)??0)+1)}}function W3(e){return e.split(`
435
439
  `).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`))}function G3(e,t){let n=e.startsWith(`!`),r=n?e.slice(1):e,i=r.startsWith(`/`)?r.slice(1):r,a=i.endsWith(`/`)?i.slice(0,-1):i,o=r.startsWith(`/`)||a.includes(`/`)?`${t}/${i}`:`${t}/**/${i}`;return n?`!${o}`:o}function K3(e,t,n,r,i){let a;try{a=C(e,{withFileTypes:!0})}catch(t){return E3.warn({dir:e,err:t},`Failed to read directory ${e}`),0}let o=0;for(let s of a){if(!s.isDirectory()||O3.has(s.name))continue;let a=N(e,s.name),c=w3(_e(t,a));if(!c.startsWith(`..`)&&!(n.ignores(c)||n.ignores(`${c}/`))){for(let e of V3){let t=N(a,e);if(g(t))try{let a=S(t,`utf-8`);i.value+=a.length;let s=W3(a).map(e=>G3(e,c));n.add(s),e===`.okignore`&&r.add(s),o++}catch(n){E3.warn({path:t,err:n},`Failed to read nested ${e} at ${t}`)}}o+=K3(a,t,n,r,i)}}return o}function q3(e,t=!1){let n=e.length,r=0,i=``,a=0,o=16,s=0,c=0,l=0,u=0,d=0;function f(t,n){let i=0,a=0;for(;i<t||!n;){let t=e.charCodeAt(r);if(t>=48&&t<=57)a=a*16+t-48;else if(t>=65&&t<=70)a=a*16+t-65+10;else if(t>=97&&t<=102)a=a*16+t-97+10;else break;r++,i++}return i<t&&(a=-1),a}function p(e){r=e,i=``,a=0,o=16,d=0}function m(){let t=r;if(e.charCodeAt(r)===48)r++;else for(r++;r<e.length&&X3(e.charCodeAt(r));)r++;if(r<e.length&&e.charCodeAt(r)===46)if(r++,r<e.length&&X3(e.charCodeAt(r)))for(r++;r<e.length&&X3(e.charCodeAt(r));)r++;else return d=3,e.substring(t,r);let n=r;if(r<e.length&&(e.charCodeAt(r)===69||e.charCodeAt(r)===101))if(r++,(r<e.length&&e.charCodeAt(r)===43||e.charCodeAt(r)===45)&&r++,r<e.length&&X3(e.charCodeAt(r))){for(r++;r<e.length&&X3(e.charCodeAt(r));)r++;n=r}else d=3;return e.substring(t,n)}function h(){let t=``,i=r;for(;;){if(r>=n){t+=e.substring(i,r),d=2;break}let a=e.charCodeAt(r);if(a===34){t+=e.substring(i,r),r++;break}if(a===92){if(t+=e.substring(i,r),r++,r>=n){d=2;break}switch(e.charCodeAt(r++)){case 34:t+=`"`;break;case 92:t+=`\\`;break;case 47:t+=`/`;break;case 98:t+=`\b`;break;case 102:t+=`\f`;break;case 110:t+=`
436
440
  `;break;case 114:t+=`\r`;break;case 116:t+=` `;break;case 117:let e=f(4,!0);e>=0?t+=String.fromCharCode(e):d=4;break;default:d=5}i=r;continue}if(a>=0&&a<=31)if(Y3(a)){t+=e.substring(i,r),d=2;break}else d=6;r++}return t}function g(){if(i=``,d=0,a=r,c=s,u=l,r>=n)return a=n,o=17;let t=e.charCodeAt(r);if(J3(t)){do r++,i+=String.fromCharCode(t),t=e.charCodeAt(r);while(J3(t));return o=15}if(Y3(t))return r++,i+=String.fromCharCode(t),t===13&&e.charCodeAt(r)===10&&(r++,i+=`
437
- `),s++,l=r,o=14;switch(t){case 123:return r++,o=1;case 125:return r++,o=2;case 91:return r++,o=3;case 93:return r++,o=4;case 58:return r++,o=6;case 44:return r++,o=5;case 34:return r++,i=h(),o=10;case 47:let c=r-1;if(e.charCodeAt(r+1)===47){for(r+=2;r<n&&!Y3(e.charCodeAt(r));)r++;return i=e.substring(c,r),o=12}if(e.charCodeAt(r+1)===42){r+=2;let t=n-1,a=!1;for(;r<t;){let t=e.charCodeAt(r);if(t===42&&e.charCodeAt(r+1)===47){r+=2,a=!0;break}r++,Y3(t)&&(t===13&&e.charCodeAt(r)===10&&r++,s++,l=r)}return a||(r++,d=1),i=e.substring(c,r),o=13}return i+=String.fromCharCode(t),r++,o=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!X3(e.charCodeAt(r)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=m(),o=11;default:for(;r<n&&_(t);)r++,t=e.charCodeAt(r);if(a!==r){switch(i=e.substring(a,r),i){case`true`:return o=8;case`false`:return o=9;case`null`:return o=7}return o=16}return i+=String.fromCharCode(t),r++,o=16}}function _(e){if(J3(e)||Y3(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function v(){let e;do e=g();while(e>=12&&e<=15);return e}return{setPosition:p,getPosition:()=>r,scan:t?v:g,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>a,getTokenLength:()=>r-a,getTokenStartLine:()=>c,getTokenStartCharacter:()=>a-u,getTokenError:()=>d}}function J3(e){return e===32||e===9}function Y3(e){return e===10||e===13}function X3(e){return e>=48&&e<=57}var Jye;(function(e){e[e.lineFeed=10]=`lineFeed`,e[e.carriageReturn=13]=`carriageReturn`,e[e.space=32]=`space`,e[e._0=48]=`_0`,e[e._1=49]=`_1`,e[e._2=50]=`_2`,e[e._3=51]=`_3`,e[e._4=52]=`_4`,e[e._5=53]=`_5`,e[e._6=54]=`_6`,e[e._7=55]=`_7`,e[e._8=56]=`_8`,e[e._9=57]=`_9`,e[e.a=97]=`a`,e[e.b=98]=`b`,e[e.c=99]=`c`,e[e.d=100]=`d`,e[e.e=101]=`e`,e[e.f=102]=`f`,e[e.g=103]=`g`,e[e.h=104]=`h`,e[e.i=105]=`i`,e[e.j=106]=`j`,e[e.k=107]=`k`,e[e.l=108]=`l`,e[e.m=109]=`m`,e[e.n=110]=`n`,e[e.o=111]=`o`,e[e.p=112]=`p`,e[e.q=113]=`q`,e[e.r=114]=`r`,e[e.s=115]=`s`,e[e.t=116]=`t`,e[e.u=117]=`u`,e[e.v=118]=`v`,e[e.w=119]=`w`,e[e.x=120]=`x`,e[e.y=121]=`y`,e[e.z=122]=`z`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.asterisk=42]=`asterisk`,e[e.backslash=92]=`backslash`,e[e.closeBrace=125]=`closeBrace`,e[e.closeBracket=93]=`closeBracket`,e[e.colon=58]=`colon`,e[e.comma=44]=`comma`,e[e.dot=46]=`dot`,e[e.doubleQuote=34]=`doubleQuote`,e[e.minus=45]=`minus`,e[e.openBrace=123]=`openBrace`,e[e.openBracket=91]=`openBracket`,e[e.plus=43]=`plus`,e[e.slash=47]=`slash`,e[e.formFeed=12]=`formFeed`,e[e.tab=9]=`tab`})(Jye||={});const Z3=Array(20).fill(0).map((e,t)=>` `.repeat(t)),Q3={" ":{"\n":Array(200).fill(0).map((e,t)=>`
441
+ `),s++,l=r,o=14;switch(t){case 123:return r++,o=1;case 125:return r++,o=2;case 91:return r++,o=3;case 93:return r++,o=4;case 58:return r++,o=6;case 44:return r++,o=5;case 34:return r++,i=h(),o=10;case 47:let c=r-1;if(e.charCodeAt(r+1)===47){for(r+=2;r<n&&!Y3(e.charCodeAt(r));)r++;return i=e.substring(c,r),o=12}if(e.charCodeAt(r+1)===42){r+=2;let t=n-1,a=!1;for(;r<t;){let t=e.charCodeAt(r);if(t===42&&e.charCodeAt(r+1)===47){r+=2,a=!0;break}r++,Y3(t)&&(t===13&&e.charCodeAt(r)===10&&r++,s++,l=r)}return a||(r++,d=1),i=e.substring(c,r),o=13}return i+=String.fromCharCode(t),r++,o=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!X3(e.charCodeAt(r)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=m(),o=11;default:for(;r<n&&_(t);)r++,t=e.charCodeAt(r);if(a!==r){switch(i=e.substring(a,r),i){case`true`:return o=8;case`false`:return o=9;case`null`:return o=7}return o=16}return i+=String.fromCharCode(t),r++,o=16}}function _(e){if(J3(e)||Y3(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function v(){let e;do e=g();while(e>=12&&e<=15);return e}return{setPosition:p,getPosition:()=>r,scan:t?v:g,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>a,getTokenLength:()=>r-a,getTokenStartLine:()=>c,getTokenStartCharacter:()=>a-u,getTokenError:()=>d}}function J3(e){return e===32||e===9}function Y3(e){return e===10||e===13}function X3(e){return e>=48&&e<=57}var Yye;(function(e){e[e.lineFeed=10]=`lineFeed`,e[e.carriageReturn=13]=`carriageReturn`,e[e.space=32]=`space`,e[e._0=48]=`_0`,e[e._1=49]=`_1`,e[e._2=50]=`_2`,e[e._3=51]=`_3`,e[e._4=52]=`_4`,e[e._5=53]=`_5`,e[e._6=54]=`_6`,e[e._7=55]=`_7`,e[e._8=56]=`_8`,e[e._9=57]=`_9`,e[e.a=97]=`a`,e[e.b=98]=`b`,e[e.c=99]=`c`,e[e.d=100]=`d`,e[e.e=101]=`e`,e[e.f=102]=`f`,e[e.g=103]=`g`,e[e.h=104]=`h`,e[e.i=105]=`i`,e[e.j=106]=`j`,e[e.k=107]=`k`,e[e.l=108]=`l`,e[e.m=109]=`m`,e[e.n=110]=`n`,e[e.o=111]=`o`,e[e.p=112]=`p`,e[e.q=113]=`q`,e[e.r=114]=`r`,e[e.s=115]=`s`,e[e.t=116]=`t`,e[e.u=117]=`u`,e[e.v=118]=`v`,e[e.w=119]=`w`,e[e.x=120]=`x`,e[e.y=121]=`y`,e[e.z=122]=`z`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.asterisk=42]=`asterisk`,e[e.backslash=92]=`backslash`,e[e.closeBrace=125]=`closeBrace`,e[e.closeBracket=93]=`closeBracket`,e[e.colon=58]=`colon`,e[e.comma=44]=`comma`,e[e.dot=46]=`dot`,e[e.doubleQuote=34]=`doubleQuote`,e[e.minus=45]=`minus`,e[e.openBrace=123]=`openBrace`,e[e.openBracket=91]=`openBracket`,e[e.plus=43]=`plus`,e[e.slash=47]=`slash`,e[e.formFeed=12]=`formFeed`,e[e.tab=9]=`tab`})(Yye||={});const Z3=Array(20).fill(0).map((e,t)=>` `.repeat(t)),Q3={" ":{"\n":Array(200).fill(0).map((e,t)=>`
438
442
  `+` `.repeat(t)),"\r":Array(200).fill(0).map((e,t)=>`\r`+` `.repeat(t)),"\r\n":Array(200).fill(0).map((e,t)=>`\r
439
443
  `+` `.repeat(t))}," ":{"\n":Array(200).fill(0).map((e,t)=>`
440
444
  `+` `.repeat(t)),"\r":Array(200).fill(0).map((e,t)=>`\r`+` `.repeat(t)),"\r\n":Array(200).fill(0).map((e,t)=>`\r
441
- `+` `.repeat(t))}},Yye=[`
445
+ `+` `.repeat(t))}},Xye=[`
442
446
  `,`\r`,`\r
443
- `];function Xye(e,t,n){let r,i,a,o,s;if(t){for(o=t.offset,s=o+t.length,a=o;a>0&&!e6(e,a-1);)a--;let c=s;for(;c<e.length&&!e6(e,c);)c++;i=e.substring(a,c),r=Zye(i,n)}else i=e,r=0,a=0,o=0,s=e.length;let c=Qye(n,e),l=Yye.includes(c),u=0,d=0,f;f=n.insertSpaces?Z3[n.tabSize||4]??$3(Z3[1],n.tabSize||4):` `;let p=f===` `?` `:` `,m=q3(i,!1),h=!1;function g(){if(u>1)return $3(c,u)+$3(f,r+d);let e=f.length*(r+d);return!l||e>Q3[p][c].length?c+$3(f,r+d):e<=0?c:Q3[p][c][e]}function _(){let e=m.scan();for(u=0;e===15||e===14;)e===14&&n.keepLines?u+=1:e===14&&(u=1),e=m.scan();return h=e===16||m.getTokenError()!==0,e}let v=[];function y(n,r,i){!h&&(!t||r<s&&i>o)&&e.substring(r,i)!==n&&v.push({offset:r,length:i-r,content:n})}let b=_();if(n.keepLines&&u>0&&y($3(c,u),0,0),b!==17){let e=m.getTokenOffset()+a;y(f.length*r<20&&n.insertSpaces?Z3[f.length*r]:$3(f,r),a,e)}for(;b!==17;){let e=m.getTokenOffset()+m.getTokenLength()+a,t=_(),r=``,i=!1;for(;u===0&&(t===12||t===13);){let n=m.getTokenOffset()+a;y(Z3[1],e,n),e=m.getTokenOffset()+m.getTokenLength()+a,i=t===12,r=i?g():``,t=_()}if(t===2)b!==1&&d--,n.keepLines&&u>0||!n.keepLines&&b!==1?r=g():n.keepLines&&(r=Z3[1]);else if(t===4)b!==3&&d--,n.keepLines&&u>0||!n.keepLines&&b!==3?r=g():n.keepLines&&(r=Z3[1]);else{switch(b){case 3:case 1:d++,r=n.keepLines&&u>0||!n.keepLines?g():Z3[1];break;case 5:r=n.keepLines&&u>0||!n.keepLines?g():Z3[1];break;case 12:r=g();break;case 13:u>0?r=g():i||(r=Z3[1]);break;case 6:n.keepLines&&u>0?r=g():i||(r=Z3[1]);break;case 10:n.keepLines&&u>0?r=g():t===6&&!i&&(r=``);break;case 7:case 8:case 9:case 11:case 2:case 4:n.keepLines&&u>0?r=g():(t===12||t===13)&&!i?r=Z3[1]:t!==5&&t!==17&&(h=!0);break;case 16:h=!0;break}u>0&&(t===12||t===13)&&(r=g())}t===17&&(r=n.keepLines&&u>0?g():n.insertFinalNewline?c:``);let o=m.getTokenOffset()+a;y(r,e,o),b=t}return v}function $3(e,t){let n=``;for(let r=0;r<t;r++)n+=e;return n}function Zye(e,t){let n=0,r=0,i=t.tabSize||4;for(;n<e.length;){let t=e.charAt(n);if(t===Z3[1])r++;else if(t===` `)r+=i;else break;n++}return Math.floor(r/i)}function Qye(e,t){for(let e=0;e<t.length;e++){let n=t.charAt(e);if(n===`\r`)return e+1<t.length&&t.charAt(e+1)===`
447
+ `];function Zye(e,t,n){let r,i,a,o,s;if(t){for(o=t.offset,s=o+t.length,a=o;a>0&&!e6(e,a-1);)a--;let c=s;for(;c<e.length&&!e6(e,c);)c++;i=e.substring(a,c),r=Qye(i,n)}else i=e,r=0,a=0,o=0,s=e.length;let c=$ye(n,e),l=Xye.includes(c),u=0,d=0,f;f=n.insertSpaces?Z3[n.tabSize||4]??$3(Z3[1],n.tabSize||4):` `;let p=f===` `?` `:` `,m=q3(i,!1),h=!1;function g(){if(u>1)return $3(c,u)+$3(f,r+d);let e=f.length*(r+d);return!l||e>Q3[p][c].length?c+$3(f,r+d):e<=0?c:Q3[p][c][e]}function _(){let e=m.scan();for(u=0;e===15||e===14;)e===14&&n.keepLines?u+=1:e===14&&(u=1),e=m.scan();return h=e===16||m.getTokenError()!==0,e}let v=[];function y(n,r,i){!h&&(!t||r<s&&i>o)&&e.substring(r,i)!==n&&v.push({offset:r,length:i-r,content:n})}let b=_();if(n.keepLines&&u>0&&y($3(c,u),0,0),b!==17){let e=m.getTokenOffset()+a;y(f.length*r<20&&n.insertSpaces?Z3[f.length*r]:$3(f,r),a,e)}for(;b!==17;){let e=m.getTokenOffset()+m.getTokenLength()+a,t=_(),r=``,i=!1;for(;u===0&&(t===12||t===13);){let n=m.getTokenOffset()+a;y(Z3[1],e,n),e=m.getTokenOffset()+m.getTokenLength()+a,i=t===12,r=i?g():``,t=_()}if(t===2)b!==1&&d--,n.keepLines&&u>0||!n.keepLines&&b!==1?r=g():n.keepLines&&(r=Z3[1]);else if(t===4)b!==3&&d--,n.keepLines&&u>0||!n.keepLines&&b!==3?r=g():n.keepLines&&(r=Z3[1]);else{switch(b){case 3:case 1:d++,r=n.keepLines&&u>0||!n.keepLines?g():Z3[1];break;case 5:r=n.keepLines&&u>0||!n.keepLines?g():Z3[1];break;case 12:r=g();break;case 13:u>0?r=g():i||(r=Z3[1]);break;case 6:n.keepLines&&u>0?r=g():i||(r=Z3[1]);break;case 10:n.keepLines&&u>0?r=g():t===6&&!i&&(r=``);break;case 7:case 8:case 9:case 11:case 2:case 4:n.keepLines&&u>0?r=g():(t===12||t===13)&&!i?r=Z3[1]:t!==5&&t!==17&&(h=!0);break;case 16:h=!0;break}u>0&&(t===12||t===13)&&(r=g())}t===17&&(r=n.keepLines&&u>0?g():n.insertFinalNewline?c:``);let o=m.getTokenOffset()+a;y(r,e,o),b=t}return v}function $3(e,t){let n=``;for(let r=0;r<t;r++)n+=e;return n}function Qye(e,t){let n=0,r=0,i=t.tabSize||4;for(;n<e.length;){let t=e.charAt(n);if(t===Z3[1])r++;else if(t===` `)r+=i;else break;n++}return Math.floor(r/i)}function $ye(e,t){for(let e=0;e<t.length;e++){let n=t.charAt(e);if(n===`\r`)return e+1<t.length&&t.charAt(e+1)===`
444
448
  `?`\r
445
449
  `:`\r`;if(n===`
446
450
  `)return`
447
451
  `}return e&&e.eol||`
448
452
  `}function e6(e,t){return`\r
449
- `.indexOf(e.charAt(t))!==-1}var t6;(function(e){e.DEFAULT={allowTrailingComma:!1}})(t6||={});function $ye(e,t=[],n=t6.DEFAULT){let r=null,i=[],a=[];function o(e){Array.isArray(i)?i.push(e):r!==null&&(i[r]=e)}return a6(e,{onObjectBegin:()=>{let e={};o(e),a.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=a.pop()},onArrayBegin:()=>{let e=[];o(e),a.push(i),i=e,r=null},onArrayEnd:()=>{i=a.pop()},onLiteralValue:o,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n),i[0]}function n6(e,t=[],n=t6.DEFAULT){let r={type:`array`,offset:-1,length:-1,children:[],parent:void 0};function i(e){r.type===`property`&&(r.length=e-r.offset,r=r.parent)}function a(e){return r.children.push(e),e}a6(e,{onObjectBegin:e=>{r=a({type:`object`,offset:e,length:-1,parent:r,children:[]})},onObjectProperty:(e,t,n)=>{r=a({type:`property`,offset:t,length:-1,parent:r,children:[]}),r.children.push({type:`string`,value:e,offset:t,length:n,parent:r})},onObjectEnd:(e,t)=>{i(e+t),r.length=e+t-r.offset,r=r.parent,i(e+t)},onArrayBegin:(e,t)=>{r=a({type:`array`,offset:e,length:-1,parent:r,children:[]})},onArrayEnd:(e,t)=>{r.length=e+t-r.offset,r=r.parent,i(e+t)},onLiteralValue:(e,t,n)=>{a({type:ebe(e),offset:t,length:n,parent:r,value:e}),i(t+n)},onSeparator:(e,t,n)=>{r.type===`property`&&(e===`:`?r.colonOffset=t:e===`,`&&i(t))},onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n);let o=r.children[0];return o&&delete o.parent,o}function r6(e,t){if(!e)return;let n=e;for(let e of t)if(typeof e==`string`){if(n.type!==`object`||!Array.isArray(n.children))return;let t=!1;for(let r of n.children)if(Array.isArray(r.children)&&r.children[0].value===e&&r.children.length===2){n=r.children[1],t=!0;break}if(!t)return}else{let t=e;if(n.type!==`array`||t<0||!Array.isArray(n.children)||t>=n.children.length)return;n=n.children[t]}return n}function i6(e){switch(e.type){case`array`:return e.children.map(i6);case`object`:let t=Object.create(null);for(let n of e.children){let e=n.children[1];e&&(t[n.children[0].value]=i6(e))}return t;case`null`:case`string`:case`number`:case`boolean`:return e.value;default:return}}function a6(e,t,n=t6.DEFAULT){let r=q3(e,!1),i=[],a=0;function o(e){return e?()=>a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function s(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function c(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function l(e){return e?()=>{a>0?a++:e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(a=1)}:()=>!0}function u(e){return e?()=>{a>0&&a--,a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}let d=l(t.onObjectBegin),f=c(t.onObjectProperty),p=u(t.onObjectEnd),m=l(t.onArrayBegin),h=u(t.onArrayEnd),g=c(t.onLiteralValue),_=s(t.onSeparator),v=o(t.onComment),y=s(t.onError),b=n&&n.disallowComments,x=n&&n.allowTrailingComma;function S(){for(;;){let e=r.scan();switch(r.getTokenError()){case 4:C(14);break;case 5:C(15);break;case 3:C(13);break;case 1:b||C(11);break;case 2:C(12);break;case 6:C(16);break}switch(e){case 12:case 13:b?C(10):v();break;case 16:C(1);break;case 15:case 14:break;default:return e}}}function C(e,t=[],n=[]){if(y(e),t.length+n.length>0){let e=r.getToken();for(;e!==17;){if(t.indexOf(e)!==-1){S();break}else if(n.indexOf(e)!==-1)break;e=S()}}}function w(e){let t=r.getTokenValue();return e?g(t):(f(t),i.push(t)),S(),!0}function T(){switch(r.getToken()){case 11:let e=r.getTokenValue(),t=Number(e);isNaN(t)&&(C(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return S(),!0}function E(){return r.getToken()===10?(w(!1),r.getToken()===6?(_(`:`),S(),ee()||C(4,[],[2,5])):C(5,[],[2,5]),i.pop(),!0):(C(3,[],[2,5]),!1)}function D(){d(),S();let e=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(e||C(4,[],[]),_(`,`),S(),r.getToken()===2&&x)break}else e&&C(6,[],[]);E()||C(4,[],[2,5]),e=!0}return p(),r.getToken()===2?S():C(7,[2],[]),!0}function O(){m(),S();let e=!0,t=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(t||C(4,[],[]),_(`,`),S(),r.getToken()===4&&x)break}else t&&C(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,ee()||C(4,[],[4,5]),t=!0}return h(),e||i.pop(),r.getToken()===4?S():C(8,[4],[]),!0}function ee(){switch(r.getToken()){case 3:return O();case 1:return D();case 10:return w(!0);default:return T()}}return S(),r.getToken()===17?n.allowEmptyContent?!0:(C(4,[],[]),!1):ee()?(r.getToken()!==17&&C(9,[],[]),!0):(C(4,[],[]),!1)}function ebe(e){switch(typeof e){case`boolean`:return`boolean`;case`number`:return`number`;case`string`:return`string`;case`object`:return e?Array.isArray(e)?`array`:`object`:`null`;default:return`null`}}function tbe(e,t,n,r){let i=t.slice(),a=n6(e,[]),o,s;for(;i.length>0&&(s=i.pop(),o=r6(a,i),o===void 0&&n!==void 0);)n=typeof s==`string`?{[s]:n}:[n];if(!o){if(n===void 0)throw Error(`Can not delete in empty document`);return o6(e,{offset:a?a.offset:0,length:a?a.length:0,content:JSON.stringify(n)},r)}else if(o.type===`object`&&typeof s==`string`&&Array.isArray(o.children)){let t=r6(o,[s]);if(t!==void 0)if(n===void 0){if(!t.parent)throw Error(`Malformed AST`);let n=o.children.indexOf(t.parent),i,a=t.parent.offset+t.parent.length;if(n>0){let e=o.children[n-1];i=e.offset+e.length}else i=o.offset+1,o.children.length>1&&(a=o.children[1].offset);return o6(e,{offset:i,length:a-i,content:``},r)}else return o6(e,{offset:t.offset,length:t.length,content:JSON.stringify(n)},r);else{if(n===void 0)return[];let t=`${JSON.stringify(s)}: ${JSON.stringify(n)}`,i=r.getInsertionIndex?r.getInsertionIndex(o.children.map(e=>e.children[0].value)):o.children.length,a;if(i>0){let e=o.children[i-1];a={offset:e.offset+e.length,length:0,content:`,`+t}}else a=o.children.length===0?{offset:o.offset+1,length:0,content:t}:{offset:o.offset+1,length:0,content:t+`,`};return o6(e,a,r)}}else if(o.type===`array`&&typeof s==`number`&&Array.isArray(o.children)){let t=s;if(t===-1){let t=`${JSON.stringify(n)}`,i;if(o.children.length===0)i={offset:o.offset+1,length:0,content:t};else{let e=o.children[o.children.length-1];i={offset:e.offset+e.length,length:0,content:`,`+t}}return o6(e,i,r)}else if(n===void 0&&o.children.length>=0){let t=s,n=o.children[t],i;if(o.children.length===1)i={offset:o.offset+1,length:o.length-2,content:``};else if(o.children.length-1===t){let e=o.children[t-1],n=e.offset+e.length;i={offset:n,length:o.offset+o.length-2-n,content:``}}else i={offset:n.offset,length:o.children[t+1].offset-n.offset,content:``};return o6(e,i,r)}else if(n!==void 0){let t,i=`${JSON.stringify(n)}`;if(!r.isArrayInsertion&&o.children.length>s){let e=o.children[s];t={offset:e.offset,length:e.length,content:i}}else if(o.children.length===0||s===0)t={offset:o.offset+1,length:0,content:o.children.length===0?i:i+`,`};else{let e=s>o.children.length?o.children.length:s,n=o.children[e-1];t={offset:n.offset+n.length,length:0,content:`,`+i}}return o6(e,t,r)}else throw Error(`Can not ${n===void 0?`remove`:r.isArrayInsertion?`insert`:`modify`} Array index ${t} as length is not sufficient`)}else throw Error(`Can not add ${typeof s==`number`?`property`:`index`} to parent of type ${o.type}`)}function o6(e,t,n){if(!n.formattingOptions)return[t];let r=s6(e,t),i=t.offset,a=t.offset+t.content.length;if(t.length===0||t.content.length===0){for(;i>0&&!e6(r,i-1);)i--;for(;a<r.length&&!e6(r,a);)a++}let o=Xye(r,{offset:i,length:a-i},{...n.formattingOptions,keepLines:!1});for(let e=o.length-1;e>=0;e--){let t=o[e];r=s6(r,t),i=Math.min(i,t.offset),a=Math.max(a,t.offset+t.length),a+=t.content.length-t.length}let s=e.length-(r.length-a)-i;return[{offset:i,length:s,content:r.substring(i,a)}]}function s6(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var nbe;(function(e){e[e.None=0]=`None`,e[e.UnexpectedEndOfComment=1]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=2]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=3]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=4]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=5]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=6]=`InvalidCharacter`})(nbe||={});var rbe;(function(e){e[e.OpenBraceToken=1]=`OpenBraceToken`,e[e.CloseBraceToken=2]=`CloseBraceToken`,e[e.OpenBracketToken=3]=`OpenBracketToken`,e[e.CloseBracketToken=4]=`CloseBracketToken`,e[e.CommaToken=5]=`CommaToken`,e[e.ColonToken=6]=`ColonToken`,e[e.NullKeyword=7]=`NullKeyword`,e[e.TrueKeyword=8]=`TrueKeyword`,e[e.FalseKeyword=9]=`FalseKeyword`,e[e.StringLiteral=10]=`StringLiteral`,e[e.NumericLiteral=11]=`NumericLiteral`,e[e.LineCommentTrivia=12]=`LineCommentTrivia`,e[e.BlockCommentTrivia=13]=`BlockCommentTrivia`,e[e.LineBreakTrivia=14]=`LineBreakTrivia`,e[e.Trivia=15]=`Trivia`,e[e.Unknown=16]=`Unknown`,e[e.EOF=17]=`EOF`})(rbe||={});const ibe=$ye,abe=n6,c6=i6;var obe;(function(e){e[e.InvalidSymbol=1]=`InvalidSymbol`,e[e.InvalidNumberFormat=2]=`InvalidNumberFormat`,e[e.PropertyNameExpected=3]=`PropertyNameExpected`,e[e.ValueExpected=4]=`ValueExpected`,e[e.ColonExpected=5]=`ColonExpected`,e[e.CommaExpected=6]=`CommaExpected`,e[e.CloseBraceExpected=7]=`CloseBraceExpected`,e[e.CloseBracketExpected=8]=`CloseBracketExpected`,e[e.EndOfFileExpected=9]=`EndOfFileExpected`,e[e.InvalidCommentToken=10]=`InvalidCommentToken`,e[e.UnexpectedEndOfComment=11]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=12]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=13]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=14]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=15]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=16]=`InvalidCharacter`})(obe||={});function l6(e,t,n,r){return tbe(e,t,n,r)}function u6(e,t){let n=t.slice(0).sort((e,t)=>{let n=e.offset-t.offset;return n===0?e.length-t.length:n}),r=e.length;for(let t=n.length-1;t>=0;t--){let i=n[t];if(i.offset+i.length<=r)e=s6(e,i);else throw Error(`Overlapping edit`);r=i.offset}return e}W$(`mermaid-validator`),W$(`saved-themes`);const sbe=/^[A-Za-z0-9-]{8,64}$/;let d6=null;function cbe(e){return N(e??oe(),`.ok`,`machine-id`)}function lbe(e){if(e===void 0&&d6!==null)return d6;let t=cbe(e),n=null;try{let e=S(t,`utf-8`).trim();sbe.test(e)&&(n=e)}catch{}if(n===null){n=je();try{v(pe(t),{recursive:!0}),te(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){W$(`machine-id`).warn({path:t,err:e},`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&&(d6=n),n}W$(`process-lock`);function ube(e,t){return ve(e,`${t}.lock`)}new class{_tail=Promise.resolve();enqueue(e){let t=this._tail.then(()=>e());return this._tail=t.catch(()=>void 0),t}},W$(`git-context`),Fe(x),[...Rl];function f6(e,t){return[...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({editor:e,root:t})),{editor:`agents`,root:t}]}f6(Il,Yl),[...f6(Ll,Yl)].sort((e,t)=>{let n=f3.indexOf(e.editor),r=f3.indexOf(t.editor);return(n===-1?f3.length:n)-(r===-1?f3.length:r)||e.editor.localeCompare(t.editor)}),W$(`upload-streaming`),W$(`backlinks`),W$(`tag-index`),W$(`derived-document-index`),W$(`file-watcher`);function dbe(e){try{return O(ve(e,`.ok/config.yml`)).isFile()}catch(e){let t=e?.code;if(t===`ENOENT`||t===`ENOTDIR`)return!1;throw e}}W$(`git-checkout`),G$(()=>{}),W$(`asset-references`);const fbe=global.Request;var p6=class extends fbe{constructor(e,t){if(typeof e==`object`&&x6 in e){let n=t!==void 0&&`body`in t&&t.body!=null;if(e[A6]&&!n)throw TypeError(`Cannot construct a Request with a Request object that has already been used.`);e=e[x6]()}t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}};const m6=e=>{let t=[],n=e.rawHeaders;for(let e=0,r=n.length;e<r;e+=2){let r=n[e];r.charCodeAt(0)!==58&&t.push([r,n[e+1]])}return new Headers(t)},pbe=Symbol(`wrapBodyStream`),mbe=new Set([`latin1`,`binary`,`hex`,`base64`,`base64url`]),hbe=e=>e===null||mbe.has(e),h6=Symbol(`bodyBufferedBeforeDisconnect`),g6=Symbol(`bodyBufferedLengthBeforeDisconnect`),_6=(e,t)=>Buffer.isBuffer(e)?e:Buffer.from(e,t??`utf8`),v6=e=>!(e instanceof Ie)&&!!e.complete&&!!e.readableAborted&&typeof e.read==`function`&&hbe(e.readableEncoding),y6=(e,t)=>{if(e.readableDidRead&&!t||!v6(e))return;let n=e;if(n[h6]!==void 0)return n[h6];let r,i=e.errored;if(i&&i.code!==`ECONNRESET`)r=i;else if(n[g6]!==void 0&&e.readableLength!==n[g6])r=N6();else{let n=t??[],i=e.read();i!==null&&n.push(_6(i,e.readableEncoding));let a=n.length===1?n[0]:Buffer.concat(n);r=a;let o=e.headers[`content-length`];if(typeof o==`string`&&/^\d+$/.test(o)){let e=Number(o);Number.isSafeInteger(e)&&a.length!==e&&(r=N6())}}return n[h6]=r,r},b6=(e,t)=>{if(t instanceof Error){e.error(t);return}t.length>0&&e.enqueue(t),e.close()},gbe=(e,t,n,r,i)=>{let a={method:e,headers:n,signal:i.signal};if(e===`TRACE`){a.method=`GET`;let e=new p6(t,a);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in r&&r.rawBody instanceof Buffer)a.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[pbe]){let e;a.body=new ReadableStream({async pull(t){try{if(!e){let e=y6(r);if(e!==void 0){b6(t,e);return}}e||=Oe.toWeb(r).getReader();let{done:n,value:i}=await e.read();n?t.close():t.enqueue(i)}catch(e){t.error(e)}}})}else{let e=y6(r);e===void 0?a.body=Oe.toWeb(r):a.body=new ReadableStream({start(t){b6(t,e)}})}return new p6(t,a)},x6=Symbol(`getRequestCache`),S6=Symbol(`requestCache`),C6=Symbol(`incomingKey`),w6=Symbol(`urlKey`),_be=Symbol(`methodKey`),T6=Symbol(`headersKey`),E6=Symbol(`abortControllerKey`),D6=Symbol(`getAbortController`),vbe=Symbol(`abortRequest`),O6=Symbol(`bodyBuffer`),k6=Symbol(`bodyReadPromise`),A6=Symbol(`bodyConsumedDirectly`),j6=Symbol(`bodyLockReader`),M6=Symbol(`abortReason`),N6=()=>TypeError(`Body is unusable`),P6=()=>Promise.reject(N6()),ybe=new TextDecoder,bbe=e=>{if(e[A6])return P6();e[A6]=!0},xbe=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),Sbe=e=>(e[T6]||=m6(e[C6])).get(`content-type`)||``,Cbe=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,wbe=e=>{if(!Cbe.test(e))return TypeError(`'${e}' is not a valid HTTP method.`);let t=e.toUpperCase();if(t===`CONNECT`||t===`TRACK`||t===`TRACE`&&e!==`TRACE`)return TypeError(`'${e}' HTTP method is unsupported.`)},F6=(e,t,n)=>{if(e[A6])return P6();let r=e.method;if(r===`GET`||r===`HEAD`)return e[x6]()[t]();let i=wbe(r);if(i)return Promise.reject(i);if(e[S6]&&r!==`TRACE`)return e[S6][t]();let a=bbe(e);if(a)return a;let o=Tbe(e);if(o){let t=Promise.resolve(n(o,e));return e[O6]=void 0,t}return Ebe(e).then(t=>{let r=n(t,e);return e[O6]=void 0,r})},Tbe=e=>{let t=e[C6];if(`rawBody`in t&&t.rawBody instanceof Buffer)return t.rawBody},I6=(e,t)=>{if(t.errored)return t.errored;let n=e[M6];return n===void 0?Error(`Client connection prematurely closed.`):n instanceof Error?n:Error(String(n))},Ebe=e=>{if(e[O6])return Promise.resolve(e[O6]);if(e[k6])return e[k6];let t=e[C6];if(t.readableDidRead)return P6();let n=y6(t);if(n!==void 0)return n instanceof Error?Promise.reject(n):(e[O6]=n,Promise.resolve(n));let r=new Promise((n,r)=>{let i=[],a=!1,o=e=>{a||(a=!0,f(),e())},s=a=>{let s=t.errored??a;return!v6(t)||s&&s.code!==`ECONNRESET`?!1:(o(()=>{let o=y6(t,i);o instanceof Error?r(o):o===void 0?r(a??I6(e,t)):(e[O6]=o,n(o))}),!0)},c=e=>{i.push(_6(e,t.readableEncoding))},l=()=>{o(()=>{let t=i.length===1?i[0]:Buffer.concat(i);e[O6]=t,n(t)})},u=e=>{s(e)||o(()=>{r(e)})},d=()=>{if(t.readableEnded){l();return}s()||o(()=>{r(I6(e,t))})},f=()=>{t.off(`data`,c),t.off(`end`,l),t.off(`error`,u),t.off(`close`,d),e[k6]=void 0};t.on(`data`,c),t.on(`end`,l),t.on(`error`,u),t.on(`close`,d),queueMicrotask(()=>{a||(t.readableEnded?l():t.errored?u(t.errored):t.destroyed&&d())})});return e[k6]=r,r},L6={get method(){return this[_be]},get url(){return this[w6]},get headers(){return this[T6]||=m6(this[C6])},[vbe](e){this[M6]===void 0&&(this[M6]=e);let t=this[E6];t&&!t.signal.aborted&&t.abort(e)},[D6](){return this[E6]||=new AbortController,this[M6]!==void 0&&!this[E6].signal.aborted&&this[E6].abort(this[M6]),this[E6]},[x6](){let e=this[D6]();if(this[S6])return this[S6];let t=this.method;if(this[A6]&&!(t===`GET`||t===`HEAD`)){this[O6]=void 0;let n={method:t===`TRACE`?`GET`:t,headers:this.headers,signal:e.signal};t!==`TRACE`&&(n.body=new ReadableStream({start(e){e.close()}}),n.duplex=`half`);let r=new p6(this[w6],n);return t===`TRACE`&&Object.defineProperty(r,`method`,{get(){return`TRACE`}}),this[S6]=r}return this[S6]=gbe(this.method,this[w6],this.headers,this[C6],e)},get body(){if(!this[A6])return this[x6]().body;let e=this[x6]();return!this[j6]&&e.body&&(this[j6]=e.body.getReader()),e.body},get bodyUsed(){return this[A6]?!0:this[S6]?this[S6].bodyUsed:!1}};Object.defineProperty(L6,`signal`,{get(){return this[D6]().signal}}),[`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`keepalive`].forEach(e=>{Object.defineProperty(L6,e,{get(){return this[x6]()[e]}})}),[`clone`,`formData`].forEach(e=>{Object.defineProperty(L6,e,{value:function(){if(this[A6]){if(e===`clone`)throw N6();return P6()}return this[x6]()[e]()}})}),Object.defineProperty(L6,`text`,{value:function(){return F6(this,`text`,e=>ybe.decode(e))}}),Object.defineProperty(L6,`arrayBuffer`,{value:function(){return F6(this,`arrayBuffer`,e=>xbe(e))}}),Object.defineProperty(L6,`blob`,{value:function(){return F6(this,`blob`,(e,t)=>{let n=Sbe(t);return new Response(e,n?{headers:{"content-type":n}}:void 0).blob()})}}),Object.defineProperty(L6,`json`,{value:function(){return this[A6]?P6():this.text().then(JSON.parse)}}),Object.defineProperty(L6,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){return`Request (lightweight) ${n({method:this.method,url:this.url,headers:this.headers,nativeRequest:this[S6]},{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(L6,p6.prototype);const R6=Symbol(`responseCache`),z6=Symbol(`getResponseCache`),B6=Symbol(`cache`),V6=global.Response;var H6=class e{#e;#t;[z6](){let e=this[B6],t=e&&e[2]instanceof Headers?e[2]:void 0;return delete this[B6],this[R6]||=new V6(this.#e,t?{status:this.#t?.status,statusText:this.#t?.statusText,headers:t}:this.#t)}constructor(t,n){let r;if(this.#e=t,n instanceof V6){let t=n[R6];if(t){this.#t=t,this[z6]();return}this.#t=n instanceof e?n.#t:n,r=new Headers(n.headers)}else this.#t=n;(t==null||typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(this[B6]=[n?.status||200,t??null,r||n?.headers])}get headers(){let e=this[B6];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||(e[1]===null?void 0:{"content-type":`text/plain; charset=UTF-8`}))),e[2]):this[z6]().headers}get status(){return this[B6]?.[0]??this[z6]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(H6.prototype,e,{get(){return this[z6]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(H6.prototype,e,{value:function(){return this[z6]()[e]()}})}),Object.defineProperty(H6.prototype,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){return`Response (lightweight) ${n({status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[R6]},{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(H6,V6),Object.setPrototypeOf(H6.prototype,V6.prototype);const Dbe=/^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/,Obe=e=>e instanceof URL?e.href:Dbe.test(e)?e:new URL(e).href,kbe=new Set([301,302,303,307,308]);Object.defineProperty(H6,`redirect`,{value:function(e,t=302){if(!kbe.has(t))throw RangeError(`Invalid status code`);return new H6(null,{status:t,headers:{location:Obe(e)}})},writable:!0,configurable:!0}),Object.defineProperty(H6,`json`,{value:function(e,t){let n=JSON.stringify(e);if(n===void 0)throw TypeError(`The data is not JSON serializable`);let r=t?.headers,i;return r?(i=new Headers(r),i.has(`content-type`)||i.set(`content-type`,`application/json`)):i={"content-type":`application/json`},new H6(n,{status:t?.status??200,statusText:t?.statusText,headers:i})},writable:!0,configurable:!0}),globalThis.CloseEvent,globalThis.ErrorEvent,new Response(null,{headers:{"x-hono-already-sent":`true`}}),W$(`suggest-links`);function U6(e){try{return T.native(e)}catch{return e}}`${Jl}`,`${Bl.join(`
450
- `)}`,i(((e,t)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:new RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,`toString`,{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}else if(t=e.match(r.twoOctet))return(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})();else if(t=e.match(r.threeOctet))return(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})();else return null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=this.toNormalizedString(),n=0,r=-1,i;for(;i=e.exec(t);)i[0].length>r&&(n=i.index,r=i[0].length);return r<0?t:`${t.substring(0,n)}::${t.substring(n+r)}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},p.IPv6.parse=function(e){let t=this.parser(e);if(t.parts===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,`toString`,{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch{throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`)}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(e)}))(),W$(`link-preview.guarded-fetch`),W$(`link-preview.cache`),W$(`local-op-security`),W$(`clone-flow`),Fe(s),W$(`managed-artifact-persistence`),W$(`managed-rename`);var W6=i(((e,t)=>{function n(e){if(e.length===0)return;let t=Object.create(null),n=0;for(;n<e.length;++n){let t=e.charCodeAt(n);if(u[t]!==1){if(t!==47||n===0)return;break}}if(n===e.length)return;let i=e.slice(0,n).toLowerCase(),a=++n;for(;n<e.length;++n)if(u[e.charCodeAt(n)]!==1){if(n===a||r(e,n,t)===void 0)return;break}if(n!==a)return{type:i,subtype:e.slice(a,n).toLowerCase(),params:t}}function r(e,t,n){for(;t<e.length;){for(;t<e.length;++t){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}if(t===e.length)break;if(e.charCodeAt(t++)!==59)return;for(;t<e.length;++t){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}if(t===e.length)return;let r,i=t;for(;t<e.length;++t){let n=e.charCodeAt(t);if(u[n]!==1){if(n!==61)return;break}}if(t===e.length||(r=e.slice(i,t),++t,t===e.length))return;let a=``,o;if(e.charCodeAt(t)===34){o=++t;let n=!1;for(;t<e.length;++t){let r=e.charCodeAt(t);if(r===92){n?(o=t,n=!1):(a+=e.slice(o,t),n=!0);continue}if(r===34){if(n){o=t,n=!1;continue}a+=e.slice(o,t);break}if(n&&=(o=t-1,!1),d[r]!==1)return}if(t===e.length)return;++t}else{for(o=t;t<e.length;++t)if(u[e.charCodeAt(t)]!==1){if(t===o)return;break}a=e.slice(o,t)}r=r.toLowerCase(),n[r]===void 0&&(n[r]=a)}return n}function i(e,t){if(e.length===0)return;let n=Object.create(null),r=0;for(;r<e.length;++r)if(u[e.charCodeAt(r)]!==1){if(a(e,r,n,t)===void 0)return;break}return{type:e.slice(0,r).toLowerCase(),params:n}}function a(e,t,n,r){for(;t<e.length;){for(;t<e.length;++t){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}if(t===e.length)break;if(e.charCodeAt(t++)!==59)return;for(;t<e.length;++t){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}if(t===e.length)return;let i,a=t;for(;t<e.length;++t){let n=e.charCodeAt(t);if(u[n]!==1){if(n===61)break;return}}if(t===e.length)return;let o=``,s,l;if(i=e.slice(a,t),i.charCodeAt(i.length-1)===42){let n=++t;for(;t<e.length;++t){let n=e.charCodeAt(t);if(f[n]!==1){if(n!==39)return;break}}if(t===e.length)return;for(l=e.slice(n,t),++t;t<e.length&&e.charCodeAt(t)!==39;++t);if(t===e.length||(++t,t===e.length))return;s=t;let r=0;for(;t<e.length;++t){let n=e.charCodeAt(t);if(p[n]!==1){if(n===37){let n,i;if(t+2<e.length&&(n=m[e.charCodeAt(t+1)])!==-1&&(i=m[e.charCodeAt(t+2)])!==-1){let a=(n<<4)+i;o+=e.slice(s,t),o+=String.fromCharCode(a),t+=2,s=t+1,a>=128?r=2:r===0&&(r=1);continue}return}break}}if(o+=e.slice(s,t),o=c(o,l,r),o===void 0)return}else{if(++t,t===e.length)return;if(e.charCodeAt(t)===34){s=++t;let n=!1;for(;t<e.length;++t){let r=e.charCodeAt(t);if(r===92){n?(s=t,n=!1):(o+=e.slice(s,t),n=!0);continue}if(r===34){if(n){s=t,n=!1;continue}o+=e.slice(s,t);break}if(n&&=(s=t-1,!1),d[r]!==1)return}if(t===e.length)return;++t}else{for(s=t;t<e.length;++t)if(u[e.charCodeAt(t)]!==1){if(t===s)return;break}o=e.slice(s,t)}if(o=r(o,2),o===void 0)return}i=i.toLowerCase(),n[i]===void 0&&(n[i]=o)}return n}function o(e){let t;for(;;)switch(e){case`utf-8`:case`utf8`:return s.utf8;case`latin1`:case`ascii`:case`us-ascii`:case`iso-8859-1`:case`iso8859-1`:case`iso88591`:case`iso_8859-1`:case`windows-1252`:case`iso_8859-1:1987`:case`cp1252`:case`x-cp1252`:return s.latin1;case`utf16le`:case`utf-16le`:case`ucs2`:case`ucs-2`:return s.utf16le;case`base64`:return s.base64;default:if(t===void 0){t=!0,e=e.toLowerCase();continue}return s.other.bind(e)}}let s={utf8:(e,t)=>{if(e.length===0)return``;if(typeof e==`string`){if(t<2)return e;e=Buffer.from(e,`latin1`)}return e.utf8Slice(0,e.length)},latin1:(e,t)=>e.length===0?``:typeof e==`string`?e:e.latin1Slice(0,e.length),utf16le:(e,t)=>e.length===0?``:(typeof e==`string`&&(e=Buffer.from(e,`latin1`)),e.ucs2Slice(0,e.length)),base64:(e,t)=>e.length===0?``:(typeof e==`string`&&(e=Buffer.from(e,`latin1`)),e.base64Slice(0,e.length)),other:(t,n)=>{if(t.length===0)return``;typeof t==`string`&&(t=Buffer.from(t,`latin1`));try{return new TextDecoder(e).decode(t)}catch{}}};function c(e,t,n){let r=o(t);if(r)return r(e,n)}function l(e){if(typeof e!=`string`)return``;for(let t=e.length-1;t>=0;--t)switch(e.charCodeAt(t)){case 47:case 92:return e=e.slice(t+1),e===`..`||e===`.`?``:e}return e===`..`||e===`.`?``:e}let u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d=[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],f=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],p=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],m=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];t.exports={basename:l,convertToUTF8:c,getDecoder:o,parseContentType:n,parseDisposition:i}})),Abe=i(((e,t)=>{function n(e,t,n,r,i){for(let a=0;a<i;++a)if(e[t+a]!==n[r+a])return!1;return!0}var r=class{constructor(e,t){if(typeof t!=`function`)throw Error(`Missing match callback`);if(typeof e==`string`)e=Buffer.from(e);else if(!Buffer.isBuffer(e))throw Error(`Expected Buffer for needle, got ${typeof e}`);let n=e.length;if(this.maxMatches=1/0,this.matches=0,this._cb=t,this._lookbehindSize=0,this._needle=e,this._bufPos=0,this._lookbehind=Buffer.allocUnsafe(n),this._occ=[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],n>1)for(let t=0;t<n-1;++t)this._occ[e[t]]=n-1-t}reset(){this.matches=0,this._lookbehindSize=0,this._bufPos=0}push(e,t){let n;Buffer.isBuffer(e)||(e=Buffer.from(e,`latin1`));let r=e.length;for(this._bufPos=t||0;n!==r&&this.matches<this.maxMatches;)n=i(this,e);return n}destroy(){let e=this._lookbehindSize;e&&this._cb(!1,this._lookbehind,0,e,!1),this.reset()}};function i(e,t){let r=t.length,i=e._needle,o=i.length,s=-e._lookbehindSize,c=o-1,l=i[c],u=r-o,d=e._occ,f=e._lookbehind;if(s<0){for(;s<0&&s<=u;){let n=s+c,r=n<0?f[e._lookbehindSize+n]:t[n];if(r===l&&a(e,t,s,c))return e._lookbehindSize=0,++e.matches,s>-e._lookbehindSize?e._cb(!0,f,0,e._lookbehindSize+s,!1):e._cb(!0,void 0,0,0,!0),e._bufPos=s+o;s+=d[r]}for(;s<0&&!a(e,t,s,r-s);)++s;if(s<0){let n=e._lookbehindSize+s;return n>0&&e._cb(!1,f,0,n,!1),e._lookbehindSize-=n,f.copy(f,0,n,e._lookbehindSize),f.set(t,e._lookbehindSize),e._lookbehindSize+=r,e._bufPos=r,r}e._cb(!1,f,0,e._lookbehindSize,!1),e._lookbehindSize=0}s+=e._bufPos;let p=i[0];for(;s<=u;){let r=t[s+c];if(r===l&&t[s]===p&&n(i,0,t,s,c))return++e.matches,s>0?e._cb(!0,t,e._bufPos,s,!0):e._cb(!0,void 0,0,0,!0),e._bufPos=s+o;s+=d[r]}for(;s<r;){if(t[s]!==p||!n(t,s,i,0,r-s)){++s;continue}t.copy(f,0,s,r),e._lookbehindSize=r-s;break}return s>0&&e._cb(!1,t,e._bufPos,s<r?s:r,!0),e._bufPos=r,r}function a(e,t,n,r){let i=e._lookbehind,a=e._lookbehindSize,o=e._needle;for(let e=0;e<r;++e,++n)if((n<0?i[a+n]:t[n])!==o[e])return!1;return!0}t.exports=r})),jbe=i(((e,n)=>{let{Readable:r,Writable:i}=t(`stream`),a=Abe(),{basename:o,convertToUTF8:s,getDecoder:c,parseContentType:l,parseDisposition:u}=W6(),d=Buffer.from(`\r
451
- `),f=Buffer.from(`\r`),p=Buffer.from(`-`);function m(){}let h=16*1024;var g=class{constructor(e){this.header=Object.create(null),this.pairCount=0,this.byteCount=0,this.state=0,this.name=``,this.value=``,this.crlf=0,this.cb=e}reset(){this.header=Object.create(null),this.pairCount=0,this.byteCount=0,this.state=0,this.name=``,this.value=``,this.crlf=0}push(e,t,n){let r=t;for(;t<n;)switch(this.state){case 0:{let i=!1;for(;t<n;++t){if(this.byteCount===h)return-1;++this.byteCount;let n=e[t];if(w[n]!==1){if(n!==58||(this.name+=e.latin1Slice(r,t),this.name.length===0))return-1;++t,i=!0,this.state=1;break}}if(!i){this.name+=e.latin1Slice(r,t);break}}case 1:{let i=!1;for(;t<n;++t){if(this.byteCount===h)return-1;++this.byteCount;let n=e[t];if(n!==32&&n!==9){r=t,i=!0,this.state=2;break}}if(!i)break}case 2:switch(this.crlf){case 0:for(;t<n;++t){if(this.byteCount===h)return-1;++this.byteCount;let n=e[t];if(T[n]!==1){if(n!==13)return-1;++this.crlf;break}}this.value+=e.latin1Slice(r,t++);break;case 1:if(this.byteCount===h||(++this.byteCount,e[t++]!==10))return-1;++this.crlf;break;case 2:{if(this.byteCount===h)return-1;++this.byteCount;let n=e[t];n===32||n===9?(r=t,this.crlf=0):(++this.pairCount<2e3&&(this.name=this.name.toLowerCase(),this.header[this.name]===void 0?this.header[this.name]=[this.value]:this.header[this.name].push(this.value)),n===13?(++this.crlf,++t):(r=t,this.crlf=0,this.state=0,this.name=``,this.value=``));break}case 3:{if(this.byteCount===h||(++this.byteCount,e[t++]!==10))return-1;let n=this.header;return this.reset(),this.cb(n),t}}break}return t}},_=class extends r{constructor(e,t){super(e),this.truncated=!1,this._readcb=null,this.once(`end`,()=>{if(this._read(),--t._fileEndsLeft===0&&t._finalcb){let e=t._finalcb;t._finalcb=null,process.nextTick(e)}})}_read(e){let t=this._readcb;t&&(this._readcb=null,t())}};let v={push:(e,t)=>{},destroy:()=>{}};function y(e,t){let n=e._writecb;e._writecb=null,t?e.destroy(t):n&&n()}function b(e,t){return e}var x=class extends i{constructor(e){let t={autoDestroy:!0,emitClose:!0,highWaterMark:typeof e.highWaterMark==`number`?e.highWaterMark:void 0};if(super(t),!e.conType.params||typeof e.conType.params.boundary!=`string`)throw Error(`Multipart: Boundary not found`);let n=e.conType.params.boundary,r=typeof e.defParamCharset==`string`&&e.defParamCharset?c(e.defParamCharset):b,i=e.defCharset||`utf8`,h=e.preservePath,y={autoDestroy:!0,emitClose:!0,highWaterMark:typeof e.fileHwm==`number`?e.fileHwm:void 0},x=e.limits,S=x&&typeof x.fieldSize==`number`?x.fieldSize:1*1024*1024,C=x&&typeof x.fileSize==`number`?x.fileSize:1/0,w=x&&typeof x.files==`number`?x.files:1/0,T=x&&typeof x.fields==`number`?x.fields:1/0,E=x&&typeof x.parts==`number`?x.parts:1/0,D=-1,O=0,ee=0,te=!1;this._fileEndsLeft=0,this._fileStream=void 0,this._complete=!1;let ne=0,re,ie=0,ae,oe,se,k,ce=!1,le=!1,ue=!1;this._hparser=null;let A=new g(e=>{this._hparser=null,te=!1,se=`text/plain`,ae=i,oe=`7bit`,k=void 0,ce=!1;let t;if(!e[`content-disposition`]){te=!0;return}let n=u(e[`content-disposition`][0],r);if(!n||n.type!==`form-data`){te=!0;return}if(n.params&&(n.params.name&&(k=n.params.name),n.params[`filename*`]?t=n.params[`filename*`]:n.params.filename&&(t=n.params.filename),t!==void 0&&!h&&(t=o(t))),e[`content-type`]){let t=l(e[`content-type`][0]);t&&(se=`${t.type}/${t.subtype}`,t.params&&typeof t.params.charset==`string`&&(ae=t.params.charset.toLowerCase()))}if(e[`content-transfer-encoding`]&&(oe=e[`content-transfer-encoding`][0].toLowerCase()),se===`application/octet-stream`||t!==void 0){if(ee===w){le||(le=!0,this.emit(`filesLimit`)),te=!0;return}if(++ee,this.listenerCount(`file`)===0){te=!0;return}ne=0,this._fileStream=new _(y,this),++this._fileEndsLeft,this.emit(`file`,k,this._fileStream,{filename:t,encoding:oe,mimeType:se})}else{if(O===T){ue||(ue=!0,this.emit(`fieldsLimit`)),te=!0;return}if(++O,this.listenerCount(`field`)===0){te=!0;return}re=[],ie=0}}),j=0,de=(e,t,n,r,i)=>{retrydata:for(;t;){if(this._hparser!==null){let e=this._hparser.push(t,n,r);if(e===-1){this._hparser=null,A.reset(),this.emit(`error`,Error(`Malformed part header`));break}n=e}if(n===r)break;if(j!==0){if(j===1){switch(t[n]){case 45:j=2,++n;break;case 13:j=3,++n;break;default:j=0}if(n===r)return}if(j===2){if(j=0,t[n]===45){this._complete=!0,this._bparser=v;return}let e=this._writecb;this._writecb=m,de(!1,p,0,1,!1),this._writecb=e}else if(j===3)if(j=0,t[n]===10){if(++n,D>=E||(this._hparser=A,n===r))break;continue retrydata}else{let e=this._writecb;this._writecb=m,de(!1,f,0,1,!1),this._writecb=e}}if(!te){if(this._fileStream){let e,a=Math.min(r-n,C-ne);i?e=t.slice(n,n+a):(e=Buffer.allocUnsafe(a),t.copy(e,0,n,n+a)),ne+=e.length,ne===C?(e.length>0&&this._fileStream.push(e),this._fileStream.emit(`limit`),this._fileStream.truncated=!0,te=!0):this._fileStream.push(e)||(this._writecb&&(this._fileStream._readcb=this._writecb),this._writecb=null)}else if(re!==void 0){let e,a=Math.min(r-n,S-ie);i?e=t.slice(n,n+a):(e=Buffer.allocUnsafe(a),t.copy(e,0,n,n+a)),ie+=a,re.push(e),ie===S&&(te=!0,ce=!0)}}break}if(e){if(j=1,this._fileStream)this._fileStream.push(null),this._fileStream=null;else if(re!==void 0){let e;switch(re.length){case 0:e=``;break;case 1:e=s(re[0],ae,0);break;default:e=s(Buffer.concat(re,ie),ae,0)}re=void 0,ie=0,this.emit(`field`,k,e,{nameTruncated:!1,valueTruncated:ce,encoding:oe,mimeType:se})}++D===E&&this.emit(`partsLimit`)}};this._bparser=new a(`\r\n--${n}`,de),this._writecb=null,this._finalcb=null,this.write(d)}static detect(e){return e.type===`multipart`&&e.subtype===`form-data`}_write(e,t,n){this._writecb=n,this._bparser.push(e,0),this._writecb&&y(this)}_destroy(e,t){this._hparser=null,this._bparser=v,e||=C(this);let n=this._fileStream;n&&(this._fileStream=null,n.destroy(e)),t(e)}_final(e){if(this._bparser.destroy(),!this._complete)return e(Error(`Unexpected end of form`));this._fileEndsLeft?this._finalcb=S.bind(null,this,e):S(this,e)}};function S(e,t,n){if(n)return t(n);n=C(e),t(n)}function C(e){if(e._hparser)return Error(`Malformed part header`);let t=e._fileStream;if(t&&(e._fileStream=null,t.destroy(Error(`Unexpected end of file`))),!e._complete)return Error(`Unexpected end of form`)}let w=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],T=[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];n.exports=x})),Mbe=i(((e,n)=>{let{Writable:r}=t(`stream`),{getDecoder:i}=W6();var a=class extends r{constructor(e){let t={autoDestroy:!0,emitClose:!0,highWaterMark:typeof e.highWaterMark==`number`?e.highWaterMark:void 0};super(t);let n=e.defCharset||`utf8`;e.conType.params&&typeof e.conType.params.charset==`string`&&(n=e.conType.params.charset),this.charset=n;let r=e.limits;this.fieldSizeLimit=r&&typeof r.fieldSize==`number`?r.fieldSize:1*1024*1024,this.fieldsLimit=r&&typeof r.fields==`number`?r.fields:1/0,this.fieldNameSizeLimit=r&&typeof r.fieldNameSize==`number`?r.fieldNameSize:100,this._inKey=!0,this._keyTrunc=!1,this._valTrunc=!1,this._bytesKey=0,this._bytesVal=0,this._fields=0,this._key=``,this._val=``,this._byte=-2,this._lastPos=0,this._encode=0,this._decoder=i(n)}static detect(e){return e.type===`application`&&e.subtype===`x-www-form-urlencoded`}_write(e,t,n){if(this._fields>=this.fieldsLimit)return n();let r=0,i=e.length;if(this._lastPos=0,this._byte!==-2){if(r=o(this,e,r,i),r===-1)return n(Error(`Malformed urlencoded form`));if(r>=i)return n();this._inKey?++this._bytesKey:++this._bytesVal}main:for(;r<i;)if(this._inKey){for(r=s(this,e,r,i);r<i;){switch(e[r]){case 61:this._lastPos<r&&(this._key+=e.latin1Slice(this._lastPos,r)),this._lastPos=++r,this._key=this._decoder(this._key,this._encode),this._encode=0,this._inKey=!1;continue main;case 38:if(this._lastPos<r&&(this._key+=e.latin1Slice(this._lastPos,r)),this._lastPos=++r,this._key=this._decoder(this._key,this._encode),this._encode=0,this._bytesKey>0&&this.emit(`field`,this._key,``,{nameTruncated:this._keyTrunc,valueTruncated:!1,encoding:this.charset,mimeType:`text/plain`}),this._key=``,this._val=``,this._keyTrunc=!1,this._valTrunc=!1,this._bytesKey=0,this._bytesVal=0,++this._fields>=this.fieldsLimit)return this.emit(`fieldsLimit`),n();continue;case 43:this._lastPos<r&&(this._key+=e.latin1Slice(this._lastPos,r)),this._key+=` `,this._lastPos=r+1;break;case 37:if(this._encode===0&&(this._encode=1),this._lastPos<r&&(this._key+=e.latin1Slice(this._lastPos,r)),this._lastPos=r+1,this._byte=-1,r=o(this,e,r+1,i),r===-1)return n(Error(`Malformed urlencoded form`));if(r>=i)return n();++this._bytesKey,r=s(this,e,r,i);continue}++r,++this._bytesKey,r=s(this,e,r,i)}this._lastPos<r&&(this._key+=e.latin1Slice(this._lastPos,r))}else{for(r=c(this,e,r,i);r<i;){switch(e[r]){case 38:if(this._lastPos<r&&(this._val+=e.latin1Slice(this._lastPos,r)),this._lastPos=++r,this._inKey=!0,this._val=this._decoder(this._val,this._encode),this._encode=0,(this._bytesKey>0||this._bytesVal>0)&&this.emit(`field`,this._key,this._val,{nameTruncated:this._keyTrunc,valueTruncated:this._valTrunc,encoding:this.charset,mimeType:`text/plain`}),this._key=``,this._val=``,this._keyTrunc=!1,this._valTrunc=!1,this._bytesKey=0,this._bytesVal=0,++this._fields>=this.fieldsLimit)return this.emit(`fieldsLimit`),n();continue main;case 43:this._lastPos<r&&(this._val+=e.latin1Slice(this._lastPos,r)),this._val+=` `,this._lastPos=r+1;break;case 37:if(this._encode===0&&(this._encode=1),this._lastPos<r&&(this._val+=e.latin1Slice(this._lastPos,r)),this._lastPos=r+1,this._byte=-1,r=o(this,e,r+1,i),r===-1)return n(Error(`Malformed urlencoded form`));if(r>=i)return n();++this._bytesVal,r=c(this,e,r,i);continue}++r,++this._bytesVal,r=c(this,e,r,i)}this._lastPos<r&&(this._val+=e.latin1Slice(this._lastPos,r))}n()}_final(e){if(this._byte!==-2)return e(Error(`Malformed urlencoded form`));(!this._inKey||this._bytesKey>0||this._bytesVal>0)&&(this._inKey?this._key=this._decoder(this._key,this._encode):this._val=this._decoder(this._val,this._encode),this.emit(`field`,this._key,this._val,{nameTruncated:this._keyTrunc,valueTruncated:this._valTrunc,encoding:this.charset,mimeType:`text/plain`})),e()}};function o(e,t,n,r){if(n>=r)return r;if(e._byte===-1){let i=l[t[n++]];if(i===-1)return-1;if(i>=8&&(e._encode=2),n<r){let r=l[t[n++]];if(r===-1)return-1;e._inKey?e._key+=String.fromCharCode((i<<4)+r):e._val+=String.fromCharCode((i<<4)+r),e._byte=-2,e._lastPos=n}else e._byte=i}else{let r=l[t[n++]];if(r===-1)return-1;e._inKey?e._key+=String.fromCharCode((e._byte<<4)+r):e._val+=String.fromCharCode((e._byte<<4)+r),e._byte=-2,e._lastPos=n}return n}function s(e,t,n,r){if(e._bytesKey>e.fieldNameSizeLimit){for(e._keyTrunc||e._lastPos<n&&(e._key+=t.latin1Slice(e._lastPos,n-1)),e._keyTrunc=!0;n<r;++n){let r=t[n];if(r===61||r===38)break;++e._bytesKey}e._lastPos=n}return n}function c(e,t,n,r){if(e._bytesVal>e.fieldSizeLimit){for(e._valTrunc||e._lastPos<n&&(e._val+=t.latin1Slice(e._lastPos,n-1)),e._valTrunc=!0;n<r&&t[n]!==38;++n)++e._bytesVal;e._lastPos=n}return n}let l=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];n.exports=a}));i(((e,t)=>{let{parseContentType:n}=W6();function r(e){let t=e.headers,r=n(t[`content-type`]);if(!r)throw Error(`Malformed content type`);for(let n of i){if(!n.detect(r))continue;let i={limits:e.limits,headers:t,conType:r,highWaterMark:void 0,fileHwm:void 0,defCharset:void 0,defParamCharset:void 0,preservePath:!1};return e.highWaterMark&&(i.highWaterMark=e.highWaterMark),e.fileHwm&&(i.fileHwm=e.fileHwm),i.defCharset=e.defCharset,i.defParamCharset=e.defParamCharset,i.preservePath=e.preservePath,new n(i)}throw Error(`Unsupported content type: ${t[`content-type`]}`)}let i=[jbe(),Mbe()].filter(function(e){return typeof e.detect==`function`});t.exports=e=>{if((typeof e!=`object`||!e)&&(e={}),typeof e.headers!=`object`||e.headers===null||typeof e.headers[`content-type`]!=`string`)throw Error(`Missing Content-Type`);return r(e)}}))(),W$(`rename-log`),p3.project,Object.fromEntries(Object.entries(Xl).map(([e,t])=>[t,e])),[`These are patterns to adapt to your domain, not a layout to copy verbatim.`,"To build a variant: create your own folders (via `write` or your editor) and reuse only the ideas that fit.","To adopt this pack as-is: re-run without `--dry-run`."].join(`
452
- `),Object.assign({"3g2":`video/3gpp2`,"3gp":`video/3gpp`,"3gpp":`video/3gpp`,"3mf":`model/3mf`,aac:`audio/aac`,ac:`application/pkix-attr-cert`,adp:`audio/adpcm`,adts:`audio/aac`,ai:`application/postscript`,aml:`application/automationml-aml+xml`,amlx:`application/automationml-amlx+zip`,amr:`audio/amr`,apng:`image/apng`,appcache:`text/cache-manifest`,appinstaller:`application/appinstaller`,appx:`application/appx`,appxbundle:`application/appxbundle`,asc:`application/pgp-keys`,atom:`application/atom+xml`,atomcat:`application/atomcat+xml`,atomdeleted:`application/atomdeleted+xml`,atomsvc:`application/atomsvc+xml`,au:`audio/basic`,avci:`image/avci`,avcs:`image/avcs`,avif:`image/avif`,aw:`application/applixware`,bdoc:`application/bdoc`,bin:`application/octet-stream`,bmp:`image/bmp`,bpk:`application/octet-stream`,btf:`image/prs.btif`,btif:`image/prs.btif`,buffer:`application/octet-stream`,ccxml:`application/ccxml+xml`,cdfx:`application/cdfx+xml`,cdmia:`application/cdmi-capability`,cdmic:`application/cdmi-container`,cdmid:`application/cdmi-domain`,cdmio:`application/cdmi-object`,cdmiq:`application/cdmi-queue`,cer:`application/pkix-cert`,cgm:`image/cgm`,cjs:`application/node`,class:`application/java-vm`,coffee:`text/coffeescript`,conf:`text/plain`,cpl:`application/cpl+xml`,cpt:`application/mac-compactpro`,crl:`application/pkix-crl`,css:`text/css`,csv:`text/csv`,cu:`application/cu-seeme`,cwl:`application/cwl`,cww:`application/prs.cww`,davmount:`application/davmount+xml`,dbk:`application/docbook+xml`,deb:`application/octet-stream`,def:`text/plain`,deploy:`application/octet-stream`,dib:`image/bmp`,"disposition-notification":`message/disposition-notification`,dist:`application/octet-stream`,distz:`application/octet-stream`,dll:`application/octet-stream`,dmg:`application/octet-stream`,dms:`application/octet-stream`,doc:`application/msword`,dot:`application/msword`,dpx:`image/dpx`,drle:`image/dicom-rle`,dsc:`text/prs.lines.tag`,dssc:`application/dssc+der`,dtd:`application/xml-dtd`,dump:`application/octet-stream`,dwd:`application/atsc-dwd+xml`,ear:`application/java-archive`,ecma:`application/ecmascript`,elc:`application/octet-stream`,emf:`image/emf`,eml:`message/rfc822`,emma:`application/emma+xml`,emotionml:`application/emotionml+xml`,eps:`application/postscript`,epub:`application/epub+zip`,exe:`application/octet-stream`,exi:`application/exi`,exp:`application/express`,exr:`image/aces`,ez:`application/andrew-inset`,fdf:`application/fdf`,fdt:`application/fdt+xml`,fits:`image/fits`,g3:`image/g3fax`,gbr:`application/rpki-ghostbusters`,geojson:`application/geo+json`,gif:`image/gif`,glb:`model/gltf-binary`,gltf:`model/gltf+json`,gml:`application/gml+xml`,gpx:`application/gpx+xml`,gram:`application/srgs`,grxml:`application/srgs+xml`,gxf:`application/gxf`,gz:`application/gzip`,h261:`video/h261`,h263:`video/h263`,h264:`video/h264`,heic:`image/heic`,heics:`image/heic-sequence`,heif:`image/heif`,heifs:`image/heif-sequence`,hej2:`image/hej2k`,held:`application/atsc-held+xml`,hjson:`application/hjson`,hlp:`application/winhlp`,hqx:`application/mac-binhex40`,hsj2:`image/hsj2`,htm:`text/html`,html:`text/html`,ics:`text/calendar`,ief:`image/ief`,ifb:`text/calendar`,iges:`model/iges`,igs:`model/iges`,img:`application/octet-stream`,in:`text/plain`,ini:`text/plain`,ink:`application/inkml+xml`,inkml:`application/inkml+xml`,ipfix:`application/ipfix`,iso:`application/octet-stream`,its:`application/its+xml`,jade:`text/jade`,jar:`application/java-archive`,jhc:`image/jphc`,jls:`image/jls`,jp2:`image/jp2`,jpe:`image/jpeg`,jpeg:`image/jpeg`,jpf:`image/jpx`,jpg:`image/jpeg`,jpg2:`image/jp2`,jpgm:`image/jpm`,jpgv:`video/jpeg`,jph:`image/jph`,jpm:`image/jpm`,jpx:`image/jpx`,js:`text/javascript`,json:`application/json`,json5:`application/json5`,jsonld:`application/ld+json`,jsonml:`application/jsonml+json`,jsx:`text/jsx`,jt:`model/jt`,jxl:`image/jxl`,jxr:`image/jxr`,jxra:`image/jxra`,jxrs:`image/jxrs`,jxs:`image/jxs`,jxsc:`image/jxsc`,jxsi:`image/jxsi`,jxss:`image/jxss`,kar:`audio/midi`,ktx:`image/ktx`,ktx2:`image/ktx2`,less:`text/less`,lgr:`application/lgr+xml`,list:`text/plain`,litcoffee:`text/coffeescript`,log:`text/plain`,lostxml:`application/lost+xml`,lrf:`application/octet-stream`,m1v:`video/mpeg`,m21:`application/mp21`,m2a:`audio/mpeg`,m2t:`video/mp2t`,m2ts:`video/mp2t`,m2v:`video/mpeg`,m3a:`audio/mpeg`,m4a:`audio/mp4`,m4p:`application/mp4`,m4s:`video/iso.segment`,ma:`application/mathematica`,mads:`application/mads+xml`,maei:`application/mmt-aei+xml`,man:`text/troff`,manifest:`text/cache-manifest`,map:`application/json`,mar:`application/octet-stream`,markdown:`text/markdown`,mathml:`application/mathml+xml`,mb:`application/mathematica`,mbox:`application/mbox`,md:`text/markdown`,mdx:`text/mdx`,me:`text/troff`,mesh:`model/mesh`,meta4:`application/metalink4+xml`,metalink:`application/metalink+xml`,mets:`application/mets+xml`,mft:`application/rpki-manifest`,mid:`audio/midi`,midi:`audio/midi`,mime:`message/rfc822`,mj2:`video/mj2`,mjp2:`video/mj2`,mjs:`text/javascript`,mml:`text/mathml`,mods:`application/mods+xml`,mov:`video/quicktime`,mp2:`audio/mpeg`,mp21:`application/mp21`,mp2a:`audio/mpeg`,mp3:`audio/mpeg`,mp4:`video/mp4`,mp4a:`audio/mp4`,mp4s:`application/mp4`,mp4v:`video/mp4`,mpd:`application/dash+xml`,mpe:`video/mpeg`,mpeg:`video/mpeg`,mpf:`application/media-policy-dataset+xml`,mpg:`video/mpeg`,mpg4:`video/mp4`,mpga:`audio/mpeg`,mpp:`application/dash-patch+xml`,mrc:`application/marc`,mrcx:`application/marcxml+xml`,ms:`text/troff`,mscml:`application/mediaservercontrol+xml`,msh:`model/mesh`,msi:`application/octet-stream`,msix:`application/msix`,msixbundle:`application/msixbundle`,msm:`application/octet-stream`,msp:`application/octet-stream`,mtl:`model/mtl`,mts:`video/mp2t`,musd:`application/mmt-usd+xml`,mxf:`application/mxf`,mxmf:`audio/mobile-xmf`,mxml:`application/xv+xml`,n3:`text/n3`,nb:`application/mathematica`,nq:`application/n-quads`,nt:`application/n-triples`,obj:`model/obj`,oda:`application/oda`,oga:`audio/ogg`,ogg:`audio/ogg`,ogv:`video/ogg`,ogx:`application/ogg`,omdoc:`application/omdoc+xml`,onepkg:`application/onenote`,onetmp:`application/onenote`,onetoc:`application/onenote`,onetoc2:`application/onenote`,opf:`application/oebps-package+xml`,opus:`audio/ogg`,otf:`font/otf`,owl:`application/rdf+xml`,oxps:`application/oxps`,p10:`application/pkcs10`,p7c:`application/pkcs7-mime`,p7m:`application/pkcs7-mime`,p7s:`application/pkcs7-signature`,p8:`application/pkcs8`,pdf:`application/pdf`,pfr:`application/font-tdpfr`,pgp:`application/pgp-encrypted`,pkg:`application/octet-stream`,pki:`application/pkixcmp`,pkipath:`application/pkix-pkipath`,pls:`application/pls+xml`,png:`image/png`,prc:`model/prc`,prf:`application/pics-rules`,provx:`application/provenance+xml`,ps:`application/postscript`,pskcxml:`application/pskc+xml`,pti:`image/prs.pti`,qt:`video/quicktime`,raml:`application/raml+yaml`,rapd:`application/route-apd+xml`,rdf:`application/rdf+xml`,relo:`application/p2p-overlay+xml`,rif:`application/reginfo+xml`,rl:`application/resource-lists+xml`,rld:`application/resource-lists-diff+xml`,rmi:`audio/midi`,rnc:`application/relax-ng-compact-syntax`,rng:`application/xml`,roa:`application/rpki-roa`,roff:`text/troff`,rq:`application/sparql-query`,rs:`application/rls-services+xml`,rsat:`application/atsc-rsat+xml`,rsd:`application/rsd+xml`,rsheet:`application/urc-ressheet+xml`,rss:`application/rss+xml`,rtf:`text/rtf`,rtx:`text/richtext`,rusd:`application/route-usd+xml`,s3m:`audio/s3m`,sbml:`application/sbml+xml`,scq:`application/scvp-cv-request`,scs:`application/scvp-cv-response`,sdp:`application/sdp`,senmlx:`application/senml+xml`,sensmlx:`application/sensml+xml`,ser:`application/java-serialized-object`,setpay:`application/set-payment-initiation`,setreg:`application/set-registration-initiation`,sgi:`image/sgi`,sgm:`text/sgml`,sgml:`text/sgml`,shex:`text/shex`,shf:`application/shf+xml`,shtml:`text/html`,sieve:`application/sieve`,sig:`application/pgp-signature`,sil:`audio/silk`,silo:`model/mesh`,siv:`application/sieve`,slim:`text/slim`,slm:`text/slim`,sls:`application/route-s-tsid+xml`,smi:`application/smil+xml`,smil:`application/smil+xml`,snd:`audio/basic`,so:`application/octet-stream`,spdx:`text/spdx`,spp:`application/scvp-vp-response`,spq:`application/scvp-vp-request`,spx:`audio/ogg`,sql:`application/sql`,sru:`application/sru+xml`,srx:`application/sparql-results+xml`,ssdl:`application/ssdl+xml`,ssml:`application/ssml+xml`,stk:`application/hyperstudio`,stl:`model/stl`,stpx:`model/step+xml`,stpxz:`model/step-xml+zip`,stpz:`model/step+zip`,styl:`text/stylus`,stylus:`text/stylus`,svg:`image/svg+xml`,svgz:`image/svg+xml`,swidtag:`application/swid+xml`,t:`text/troff`,t38:`image/t38`,td:`application/urc-targetdesc+xml`,tei:`application/tei+xml`,teicorpus:`application/tei+xml`,text:`text/plain`,tfi:`application/thraud+xml`,tfx:`image/tiff-fx`,tif:`image/tiff`,tiff:`image/tiff`,toml:`application/toml`,tr:`text/troff`,trig:`application/trig`,ts:`video/mp2t`,tsd:`application/timestamped-data`,tsv:`text/tab-separated-values`,ttc:`font/collection`,ttf:`font/ttf`,ttl:`text/turtle`,ttml:`application/ttml+xml`,txt:`text/plain`,u3d:`model/u3d`,u8dsn:`message/global-delivery-status`,u8hdr:`message/global-headers`,u8mdn:`message/global-disposition-notification`,u8msg:`message/global`,ubj:`application/ubjson`,uri:`text/uri-list`,uris:`text/uri-list`,urls:`text/uri-list`,vcard:`text/vcard`,vrml:`model/vrml`,vtt:`text/vtt`,vxml:`application/voicexml+xml`,war:`application/java-archive`,wasm:`application/wasm`,wav:`audio/wav`,weba:`audio/webm`,webm:`video/webm`,webmanifest:`application/manifest+json`,webp:`image/webp`,wgsl:`text/wgsl`,wgt:`application/widget`,wif:`application/watcherinfo+xml`,wmf:`image/wmf`,woff:`font/woff`,woff2:`font/woff2`,wrl:`model/vrml`,wsdl:`application/wsdl+xml`,wspolicy:`application/wspolicy+xml`,x3d:`model/x3d+xml`,x3db:`model/x3d+fastinfoset`,x3dbz:`model/x3d+binary`,x3dv:`model/x3d-vrml`,x3dvz:`model/x3d+vrml`,x3dz:`model/x3d+xml`,xaml:`application/xaml+xml`,xav:`application/xcap-att+xml`,xca:`application/xcap-caps+xml`,xcs:`application/calendar+xml`,xdf:`application/xcap-diff+xml`,xdssc:`application/dssc+xml`,xel:`application/xcap-el+xml`,xenc:`application/xenc+xml`,xer:`application/patch-ops-error+xml`,xfdf:`application/xfdf`,xht:`application/xhtml+xml`,xhtml:`application/xhtml+xml`,xhvml:`application/xv+xml`,xlf:`application/xliff+xml`,xm:`audio/xm`,xml:`text/xml`,xns:`application/xcap-ns+xml`,xop:`application/xop+xml`,xpl:`application/xproc+xml`,xsd:`application/xml`,xsf:`application/prs.xsf+xml`,xsl:`application/xml`,xslt:`application/xml`,xspf:`application/xspf+xml`,xvm:`application/xv+xml`,xvml:`application/xv+xml`,yaml:`text/yaml`,yang:`application/yang`,yin:`application/yin+xml`,yml:`text/yaml`,zip:`application/zip`},{m4v:`video/mp4`,mkv:`video/x-matroska`,flac:`audio/flac`,toml:`application/toml`,lock:`text/plain`,"7z":`application/x-7z-compressed`,tar:`application/x-tar`,rar:`application/vnd.rar`,xls:`application/vnd.ms-excel`,ppt:`application/vnd.ms-powerpoint`,odt:`application/vnd.oasis.opendocument.text`,ods:`application/vnd.oasis.opendocument.spreadsheet`,odp:`application/vnd.oasis.opendocument.presentation`,pages:`application/vnd.apple.pages`,numbers:`application/vnd.apple.numbers`,key:`application/vnd.apple.keynote`,mobi:`application/x-mobipocket-ebook`}),W$(`file-ops`),W$(`search`),W$(`skill-import`),W$(`skill-install`),W$(`history`),W$(`skills-leaderboard`),W$(`timeline`),W$(`api`),B({enabled:L(),active:L(),git:B({state:H([`not-applicable`,`ready`,`missing`,`conflict`,`unavailable`]),ownership:H([`open-knowledge`,`existing`]).optional()}),applied:L().optional(),reason:H([`git-conflict`,`git-unavailable`,`config-write`]).optional()}),B({enabled:L()}).strict(),B({principalId:F().optional(),tabSessionId:F().optional(),expectedServerInstanceId:F().optional(),expectedBranch:F().optional(),expectedDocLineageEpoch:F().optional(),clientProtocolVersion:I().optional(),clientRuntimeVersion:F().optional(),clientKind:F().optional()}).loose(),W$(`conflict-storage`);const G6=To(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),K6=uo([F(),I().int()]),q6=F();co({ttl:I().optional(),pollInterval:I().optional()});const Nbe=B({ttl:I().optional()}),Pbe=B({taskId:F()}),J6=co({progressToken:K6.optional(),"io.modelcontextprotocol/related-task":Pbe.optional()}),Y6=B({_meta:J6.optional()}),X6=Y6.extend({task:Nbe.optional()}),Z6=B({method:F(),params:Y6.loose().optional()}),Q6=B({_meta:J6.optional()}),$6=B({method:F(),params:Q6.loose().optional()}),e8=co({_meta:J6.optional()}),t8=uo([F(),I().int()]),Fbe=B({jsonrpc:U(`2.0`),id:t8,...Z6.shape}).strict(),Ibe=B({jsonrpc:U(`2.0`),...$6.shape}).strict(),n8=B({jsonrpc:U(`2.0`),id:t8,result:e8}).strict();var Lbe;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(Lbe||={});const r8=B({jsonrpc:U(`2.0`),id:t8.optional(),error:B({code:I().int(),message:F(),data:R().optional()})}).strict();uo([Fbe,Ibe,n8,r8]),uo([n8,r8]);const i8=e8.strict(),Rbe=Q6.extend({requestId:t8.optional(),reason:F().optional()}),a8=$6.extend({method:U(`notifications/cancelled`),params:Rbe}),o8=B({icons:z(B({src:F(),mimeType:F().optional(),sizes:z(F()).optional(),theme:H([`light`,`dark`]).optional()})).optional()}),s8=B({name:F(),title:F().optional()}),c8=s8.extend({...s8.shape,...o8.shape,version:F(),websiteUrl:F().optional(),description:F().optional()}),zbe=Eo(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,po(B({form:po(B({applyDefaults:L().optional()}),V(F(),R())).optional(),url:G6.optional()}),V(F(),R()).optional())),Bbe=co({list:G6.optional(),cancel:G6.optional(),requests:co({sampling:co({createMessage:G6.optional()}).optional(),elicitation:co({create:G6.optional()}).optional()}).optional()}),Vbe=co({list:G6.optional(),cancel:G6.optional(),requests:co({tools:co({call:G6.optional()}).optional()}).optional()}),Hbe=B({experimental:V(F(),G6).optional(),sampling:B({context:G6.optional(),tools:G6.optional()}).optional(),elicitation:zbe.optional(),roots:B({listChanged:L().optional()}).optional(),tasks:Bbe.optional(),extensions:V(F(),G6).optional()}),Ube=Y6.extend({protocolVersion:F(),capabilities:Hbe,clientInfo:c8}),Wbe=Z6.extend({method:U(`initialize`),params:Ube}),Gbe=B({experimental:V(F(),G6).optional(),logging:G6.optional(),completions:G6.optional(),prompts:B({listChanged:L().optional()}).optional(),resources:B({subscribe:L().optional(),listChanged:L().optional()}).optional(),tools:B({listChanged:L().optional()}).optional(),tasks:Vbe.optional(),extensions:V(F(),G6).optional()}),Kbe=e8.extend({protocolVersion:F(),capabilities:Gbe,serverInfo:c8,instructions:F().optional()}),qbe=$6.extend({method:U(`notifications/initialized`),params:Q6.optional()}),l8=Z6.extend({method:U(`ping`),params:Y6.optional()}),Jbe=B({progress:I(),total:vo(I()),message:vo(F())}),Ybe=B({...Q6.shape,...Jbe.shape,progressToken:K6}),u8=$6.extend({method:U(`notifications/progress`),params:Ybe}),Xbe=Y6.extend({cursor:q6.optional()}),d8=Z6.extend({params:Xbe.optional()}),f8=e8.extend({nextCursor:q6.optional()}),Zbe=H([`working`,`input_required`,`completed`,`failed`,`cancelled`]),p8=B({taskId:F(),status:Zbe,ttl:uo([I(),oo()]),createdAt:F(),lastUpdatedAt:F(),pollInterval:vo(I()),statusMessage:vo(F())}),m8=e8.extend({task:p8}),Qbe=Q6.merge(p8),h8=$6.extend({method:U(`notifications/tasks/status`),params:Qbe}),g8=Z6.extend({method:U(`tasks/get`),params:Y6.extend({taskId:F()})}),_8=e8.merge(p8),v8=Z6.extend({method:U(`tasks/result`),params:Y6.extend({taskId:F()})});e8.loose();const y8=d8.extend({method:U(`tasks/list`)}),b8=f8.extend({tasks:z(p8)}),x8=Z6.extend({method:U(`tasks/cancel`),params:Y6.extend({taskId:F()})});e8.merge(p8);const S8=B({uri:F(),mimeType:vo(F()),_meta:V(F(),R()).optional()}),C8=S8.extend({text:F()}),w8=F().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),T8=S8.extend({blob:w8}),E8=H([`user`,`assistant`]),D8=B({audience:z(E8).optional(),priority:I().min(0).max(1).optional(),lastModified:Ma({offset:!0}).optional()}),O8=B({...s8.shape,...o8.shape,uri:F(),description:vo(F()),mimeType:vo(F()),size:vo(I()),annotations:D8.optional(),_meta:vo(co({}))}),$be=B({...s8.shape,...o8.shape,uriTemplate:F(),description:vo(F()),mimeType:vo(F()),annotations:D8.optional(),_meta:vo(co({}))}),exe=d8.extend({method:U(`resources/list`)}),txe=f8.extend({resources:z(O8)}),nxe=d8.extend({method:U(`resources/templates/list`)}),rxe=f8.extend({resourceTemplates:z($be)}),k8=Y6.extend({uri:F()}),ixe=k8,axe=Z6.extend({method:U(`resources/read`),params:ixe}),oxe=e8.extend({contents:z(uo([C8,T8]))}),sxe=$6.extend({method:U(`notifications/resources/list_changed`),params:Q6.optional()}),cxe=k8,lxe=Z6.extend({method:U(`resources/subscribe`),params:cxe}),uxe=k8,dxe=Z6.extend({method:U(`resources/unsubscribe`),params:uxe}),fxe=Q6.extend({uri:F()}),pxe=$6.extend({method:U(`notifications/resources/updated`),params:fxe}),mxe=B({name:F(),description:vo(F()),required:vo(L())}),hxe=B({...s8.shape,...o8.shape,description:vo(F()),arguments:vo(z(mxe)),_meta:vo(co({}))}),gxe=d8.extend({method:U(`prompts/list`)}),_xe=f8.extend({prompts:z(hxe)}),vxe=Y6.extend({name:F(),arguments:V(F(),F()).optional()}),yxe=Z6.extend({method:U(`prompts/get`),params:vxe}),A8=B({type:U(`text`),text:F(),annotations:D8.optional(),_meta:V(F(),R()).optional()}),j8=B({type:U(`image`),data:w8,mimeType:F(),annotations:D8.optional(),_meta:V(F(),R()).optional()}),M8=B({type:U(`audio`),data:w8,mimeType:F(),annotations:D8.optional(),_meta:V(F(),R()).optional()}),bxe=B({type:U(`tool_use`),name:F(),id:F(),input:V(F(),R()),_meta:V(F(),R()).optional()}),xxe=B({type:U(`resource`),resource:uo([C8,T8]),annotations:D8.optional(),_meta:V(F(),R()).optional()}),N8=uo([A8,j8,M8,O8.extend({type:U(`resource_link`)}),xxe]),Sxe=B({role:E8,content:N8}),Cxe=e8.extend({description:F().optional(),messages:z(Sxe)}),wxe=$6.extend({method:U(`notifications/prompts/list_changed`),params:Q6.optional()}),Txe=B({title:F().optional(),readOnlyHint:L().optional(),destructiveHint:L().optional(),idempotentHint:L().optional(),openWorldHint:L().optional()}),Exe=B({taskSupport:H([`required`,`optional`,`forbidden`]).optional()}),P8=B({...s8.shape,...o8.shape,description:F().optional(),inputSchema:B({type:U(`object`),properties:V(F(),G6).optional(),required:z(F()).optional()}).catchall(R()),outputSchema:B({type:U(`object`),properties:V(F(),G6).optional(),required:z(F()).optional()}).catchall(R()).optional(),annotations:Txe.optional(),execution:Exe.optional(),_meta:V(F(),R()).optional()}),Dxe=d8.extend({method:U(`tools/list`)}),Oxe=f8.extend({tools:z(P8)}),F8=e8.extend({content:z(N8).default([]),structuredContent:V(F(),R()).optional(),isError:L().optional()});F8.or(e8.extend({toolResult:R()}));const kxe=X6.extend({name:F(),arguments:V(F(),R()).optional()}),Axe=Z6.extend({method:U(`tools/call`),params:kxe}),jxe=$6.extend({method:U(`notifications/tools/list_changed`),params:Q6.optional()});B({autoRefresh:L().default(!0),debounceMs:I().int().nonnegative().default(300)});const I8=H([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Mxe=Y6.extend({level:I8}),Nxe=Z6.extend({method:U(`logging/setLevel`),params:Mxe}),Pxe=Q6.extend({level:I8,logger:F().optional(),data:R()}),Fxe=$6.extend({method:U(`notifications/message`),params:Pxe}),Ixe=B({hints:z(B({name:F().optional()})).optional(),costPriority:I().min(0).max(1).optional(),speedPriority:I().min(0).max(1).optional(),intelligencePriority:I().min(0).max(1).optional()}),Lxe=B({mode:H([`auto`,`required`,`none`]).optional()}),Rxe=B({type:U(`tool_result`),toolUseId:F().describe(`The unique identifier for the corresponding tool call.`),content:z(N8).default([]),structuredContent:B({}).loose().optional(),isError:L().optional(),_meta:V(F(),R()).optional()}),zxe=fo(`type`,[A8,j8,M8]),L8=fo(`type`,[A8,j8,M8,bxe,Rxe]),Bxe=B({role:E8,content:uo([L8,z(L8)]),_meta:V(F(),R()).optional()}),Vxe=X6.extend({messages:z(Bxe),modelPreferences:Ixe.optional(),systemPrompt:F().optional(),includeContext:H([`none`,`thisServer`,`allServers`]).optional(),temperature:I().optional(),maxTokens:I().int(),stopSequences:z(F()).optional(),metadata:G6.optional(),tools:z(P8).optional(),toolChoice:Lxe.optional()}),Hxe=Z6.extend({method:U(`sampling/createMessage`),params:Vxe}),Uxe=e8.extend({model:F(),stopReason:vo(H([`endTurn`,`stopSequence`,`maxTokens`]).or(F())),role:E8,content:zxe}),Wxe=e8.extend({model:F(),stopReason:vo(H([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(F())),role:E8,content:uo([L8,z(L8)])}),Gxe=B({type:U(`boolean`),title:F().optional(),description:F().optional(),default:L().optional()}),Kxe=B({type:U(`string`),title:F().optional(),description:F().optional(),minLength:I().optional(),maxLength:I().optional(),format:H([`email`,`uri`,`date`,`date-time`]).optional(),default:F().optional()}),qxe=B({type:H([`number`,`integer`]),title:F().optional(),description:F().optional(),minimum:I().optional(),maximum:I().optional(),default:I().optional()}),Jxe=B({type:U(`string`),title:F().optional(),description:F().optional(),enum:z(F()),default:F().optional()}),Yxe=B({type:U(`string`),title:F().optional(),description:F().optional(),oneOf:z(B({const:F(),title:F()})),default:F().optional()}),Xxe=uo([uo([B({type:U(`string`),title:F().optional(),description:F().optional(),enum:z(F()),enumNames:z(F()).optional(),default:F().optional()}),uo([Jxe,Yxe]),uo([B({type:U(`array`),title:F().optional(),description:F().optional(),minItems:I().optional(),maxItems:I().optional(),items:B({type:U(`string`),enum:z(F())}),default:z(F()).optional()}),B({type:U(`array`),title:F().optional(),description:F().optional(),minItems:I().optional(),maxItems:I().optional(),items:B({anyOf:z(B({const:F(),title:F()}))}),default:z(F()).optional()})])]),Gxe,Kxe,qxe]),Zxe=uo([X6.extend({mode:U(`form`).optional(),message:F(),requestedSchema:B({type:U(`object`),properties:V(F(),Xxe),required:z(F()).optional()})}),X6.extend({mode:U(`url`),message:F(),elicitationId:F(),url:F().url()})]),Qxe=Z6.extend({method:U(`elicitation/create`),params:Zxe}),$xe=Q6.extend({elicitationId:F()}),eSe=$6.extend({method:U(`notifications/elicitation/complete`),params:$xe}),tSe=e8.extend({action:H([`accept`,`decline`,`cancel`]),content:Eo(e=>e===null?void 0:e,V(F(),uo([F(),I(),L(),z(F())])).optional())}),nSe=B({type:U(`ref/resource`),uri:F()}),rSe=B({type:U(`ref/prompt`),name:F()}),iSe=Y6.extend({ref:uo([rSe,nSe]),argument:B({name:F(),value:F()}),context:B({arguments:V(F(),F()).optional()}).optional()}),aSe=Z6.extend({method:U(`completion/complete`),params:iSe}),oSe=e8.extend({completion:co({values:z(F()).max(100),total:vo(I().int()),hasMore:vo(L())})}),sSe=B({uri:F().startsWith(`file://`),name:F().optional(),_meta:V(F(),R()).optional()}),cSe=Z6.extend({method:U(`roots/list`),params:Y6.optional()}),lSe=e8.extend({roots:z(sSe)}),uSe=$6.extend({method:U(`notifications/roots/list_changed`),params:Q6.optional()});uo([l8,Wbe,aSe,Nxe,yxe,gxe,exe,nxe,axe,lxe,dxe,Axe,Dxe,g8,v8,y8,x8]),uo([a8,u8,qbe,uSe,h8]),uo([i8,Uxe,Wxe,tSe,lSe,_8,b8,m8]),uo([l8,Hxe,Qxe,cSe,g8,v8,y8,x8]),uo([a8,u8,Fxe,pxe,sxe,jxe,wxe,h8,eSe]),uo([i8,Kbe,oSe,Cxe,_xe,txe,rxe,oxe,F8,Oxe,_8,b8,m8]);var dSe;(function(e){e.Completable=`McpCompletable`})(dSe||={});var fSe=global.Request,R8=class extends fSe{constructor(e,t){typeof e==`object`&&z8 in e&&(e=e[z8]()),t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}},pSe=e=>{let t=[],n=e.rawHeaders;for(let e=0;e<n.length;e+=2){let{[e]:r,[e+1]:i}=n;r.charCodeAt(0)!==58&&t.push([r,i])}return new Headers(t)},mSe=Symbol(`wrapBodyStream`),hSe=(e,t,n,r,i)=>{let a={method:e,headers:n,signal:i.signal};if(e===`TRACE`){a.method=`GET`;let e=new R8(t,a);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in r&&r.rawBody instanceof Buffer)a.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[mSe]){let e;a.body=new ReadableStream({async pull(t){try{e||=Ne.toWeb(r).getReader();let{done:n,value:i}=await e.read();n?t.close():t.enqueue(i)}catch(e){t.error(e)}}})}else a.body=Ne.toWeb(r);return new R8(t,a)},z8=Symbol(`getRequestCache`),B8=Symbol(`requestCache`),V8=Symbol(`incomingKey`),H8=Symbol(`urlKey`),gSe=Symbol(`headersKey`),U8=Symbol(`abortControllerKey`),W8={get method(){return this[V8].method||`GET`},get url(){return this[H8]},get headers(){return this[gSe]||=pSe(this[V8])},[Symbol(`getAbortController`)](){return this[z8](),this[U8]},[z8](){return this[U8]||=new AbortController,this[B8]||=hSe(this.method,this[H8],this.headers,this[V8],this[U8])}};[`body`,`bodyUsed`,`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`signal`,`keepalive`].forEach(e=>{Object.defineProperty(W8,e,{get(){return this[z8]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(W8,e,{value:function(){return this[z8]()[e]()}})}),Object.defineProperty(W8,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){return`Request (lightweight) ${n({method:this.method,url:this.url,headers:this.headers,nativeRequest:this[B8]},{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(W8,R8.prototype);var G8=Symbol(`responseCache`),K8=Symbol(`getResponseCache`),q8=Symbol(`cache`),J8=global.Response,Y8=class e{#e;#t;[K8](){return delete this[q8],this[G8]||=new J8(this.#e,this.#t)}constructor(t,n){let r;if(this.#e=t,n instanceof e){let e=n[G8];if(e){this.#t=e,this[K8]();return}else this.#t=n.#t,r=new Headers(n.#t.headers)}else this.#t=n;(typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(this[q8]=[n?.status||200,t,r||n?.headers])}get headers(){let e=this[q8];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":`text/plain; charset=UTF-8`})),e[2]):this[K8]().headers}get status(){return this[q8]?.[0]??this[K8]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(Y8.prototype,e,{get(){return this[K8]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(Y8.prototype,e,{value:function(){return this[K8]()[e]()}})}),Object.defineProperty(Y8.prototype,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){return`Response (lightweight) ${n({status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[G8]},{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(Y8,J8),Object.setPrototypeOf(Y8.prototype,J8.prototype),global.crypto===void 0&&(global.crypto=Me),new Le,G$(()=>{}),[`[Requires: Hocuspocus server] Unified validation audit: every content problem — markdown-lint violations AND broken internal links — in one read-only call, grouped by the file to fix.`,``,"- No args → audit every in-scope `.md`/`.mdx` doc; pass `path` to scope to a folder or a single file.","- To CHECK whether links resolve, use this tool: each broken link is reported under the SOURCE doc that contains it, at the offending line. (The `links` tool is the navigation/graph reader — backlinks, forward links, orphans, hubs — not the validation surface.)",``,"Each diagnostic carries a `source` naming the validator ('markdownlint' rule violations; 'links' broken internal links), a `code` (e.g. MD010, dead-link), `message`, a 0-based LSP `range` (for links: line exact, column approximate), and `severity` ('error' | 'warning' — broken links default to warnings; the project's `validation.links` setting can raise them to errors or hide them). Only files with at least one problem are listed, plus `fileCount`/`errorCount`/`warningCount` totals. Output (text and structured) is capped at 10 files × 10 diagnostics per file, with explicit '… and N more' indicators; the counts always reflect the full scan — re-run with `path` scoped to a folder or file to see what was omitted.",``,"Read-only: nothing is modified. Auto-fix fixable lint findings with `lint({ document, fix: true })`; broken links need content edits via `edit`/`write`."].join(`
453
+ `.indexOf(e.charAt(t))!==-1}var t6;(function(e){e.DEFAULT={allowTrailingComma:!1}})(t6||={});function ebe(e,t=[],n=t6.DEFAULT){let r=null,i=[],a=[];function o(e){Array.isArray(i)?i.push(e):r!==null&&(i[r]=e)}return a6(e,{onObjectBegin:()=>{let e={};o(e),a.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=a.pop()},onArrayBegin:()=>{let e=[];o(e),a.push(i),i=e,r=null},onArrayEnd:()=>{i=a.pop()},onLiteralValue:o,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n),i[0]}function n6(e,t=[],n=t6.DEFAULT){let r={type:`array`,offset:-1,length:-1,children:[],parent:void 0};function i(e){r.type===`property`&&(r.length=e-r.offset,r=r.parent)}function a(e){return r.children.push(e),e}a6(e,{onObjectBegin:e=>{r=a({type:`object`,offset:e,length:-1,parent:r,children:[]})},onObjectProperty:(e,t,n)=>{r=a({type:`property`,offset:t,length:-1,parent:r,children:[]}),r.children.push({type:`string`,value:e,offset:t,length:n,parent:r})},onObjectEnd:(e,t)=>{i(e+t),r.length=e+t-r.offset,r=r.parent,i(e+t)},onArrayBegin:(e,t)=>{r=a({type:`array`,offset:e,length:-1,parent:r,children:[]})},onArrayEnd:(e,t)=>{r.length=e+t-r.offset,r=r.parent,i(e+t)},onLiteralValue:(e,t,n)=>{a({type:tbe(e),offset:t,length:n,parent:r,value:e}),i(t+n)},onSeparator:(e,t,n)=>{r.type===`property`&&(e===`:`?r.colonOffset=t:e===`,`&&i(t))},onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n);let o=r.children[0];return o&&delete o.parent,o}function r6(e,t){if(!e)return;let n=e;for(let e of t)if(typeof e==`string`){if(n.type!==`object`||!Array.isArray(n.children))return;let t=!1;for(let r of n.children)if(Array.isArray(r.children)&&r.children[0].value===e&&r.children.length===2){n=r.children[1],t=!0;break}if(!t)return}else{let t=e;if(n.type!==`array`||t<0||!Array.isArray(n.children)||t>=n.children.length)return;n=n.children[t]}return n}function i6(e){switch(e.type){case`array`:return e.children.map(i6);case`object`:let t=Object.create(null);for(let n of e.children){let e=n.children[1];e&&(t[n.children[0].value]=i6(e))}return t;case`null`:case`string`:case`number`:case`boolean`:return e.value;default:return}}function a6(e,t,n=t6.DEFAULT){let r=q3(e,!1),i=[],a=0;function o(e){return e?()=>a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function s(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function c(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function l(e){return e?()=>{a>0?a++:e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(a=1)}:()=>!0}function u(e){return e?()=>{a>0&&a--,a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}let d=l(t.onObjectBegin),f=c(t.onObjectProperty),p=u(t.onObjectEnd),m=l(t.onArrayBegin),h=u(t.onArrayEnd),g=c(t.onLiteralValue),_=s(t.onSeparator),v=o(t.onComment),y=s(t.onError),b=n&&n.disallowComments,x=n&&n.allowTrailingComma;function S(){for(;;){let e=r.scan();switch(r.getTokenError()){case 4:C(14);break;case 5:C(15);break;case 3:C(13);break;case 1:b||C(11);break;case 2:C(12);break;case 6:C(16);break}switch(e){case 12:case 13:b?C(10):v();break;case 16:C(1);break;case 15:case 14:break;default:return e}}}function C(e,t=[],n=[]){if(y(e),t.length+n.length>0){let e=r.getToken();for(;e!==17;){if(t.indexOf(e)!==-1){S();break}else if(n.indexOf(e)!==-1)break;e=S()}}}function w(e){let t=r.getTokenValue();return e?g(t):(f(t),i.push(t)),S(),!0}function T(){switch(r.getToken()){case 11:let e=r.getTokenValue(),t=Number(e);isNaN(t)&&(C(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return S(),!0}function E(){return r.getToken()===10?(w(!1),r.getToken()===6?(_(`:`),S(),ee()||C(4,[],[2,5])):C(5,[],[2,5]),i.pop(),!0):(C(3,[],[2,5]),!1)}function D(){d(),S();let e=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(e||C(4,[],[]),_(`,`),S(),r.getToken()===2&&x)break}else e&&C(6,[],[]);E()||C(4,[],[2,5]),e=!0}return p(),r.getToken()===2?S():C(7,[2],[]),!0}function O(){m(),S();let e=!0,t=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(t||C(4,[],[]),_(`,`),S(),r.getToken()===4&&x)break}else t&&C(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,ee()||C(4,[],[4,5]),t=!0}return h(),e||i.pop(),r.getToken()===4?S():C(8,[4],[]),!0}function ee(){switch(r.getToken()){case 3:return O();case 1:return D();case 10:return w(!0);default:return T()}}return S(),r.getToken()===17?n.allowEmptyContent?!0:(C(4,[],[]),!1):ee()?(r.getToken()!==17&&C(9,[],[]),!0):(C(4,[],[]),!1)}function tbe(e){switch(typeof e){case`boolean`:return`boolean`;case`number`:return`number`;case`string`:return`string`;case`object`:return e?Array.isArray(e)?`array`:`object`:`null`;default:return`null`}}function nbe(e,t,n,r){let i=t.slice(),a=n6(e,[]),o,s;for(;i.length>0&&(s=i.pop(),o=r6(a,i),o===void 0&&n!==void 0);)n=typeof s==`string`?{[s]:n}:[n];if(!o){if(n===void 0)throw Error(`Can not delete in empty document`);return o6(e,{offset:a?a.offset:0,length:a?a.length:0,content:JSON.stringify(n)},r)}else if(o.type===`object`&&typeof s==`string`&&Array.isArray(o.children)){let t=r6(o,[s]);if(t!==void 0)if(n===void 0){if(!t.parent)throw Error(`Malformed AST`);let n=o.children.indexOf(t.parent),i,a=t.parent.offset+t.parent.length;if(n>0){let e=o.children[n-1];i=e.offset+e.length}else i=o.offset+1,o.children.length>1&&(a=o.children[1].offset);return o6(e,{offset:i,length:a-i,content:``},r)}else return o6(e,{offset:t.offset,length:t.length,content:JSON.stringify(n)},r);else{if(n===void 0)return[];let t=`${JSON.stringify(s)}: ${JSON.stringify(n)}`,i=r.getInsertionIndex?r.getInsertionIndex(o.children.map(e=>e.children[0].value)):o.children.length,a;if(i>0){let e=o.children[i-1];a={offset:e.offset+e.length,length:0,content:`,`+t}}else a=o.children.length===0?{offset:o.offset+1,length:0,content:t}:{offset:o.offset+1,length:0,content:t+`,`};return o6(e,a,r)}}else if(o.type===`array`&&typeof s==`number`&&Array.isArray(o.children)){let t=s;if(t===-1){let t=`${JSON.stringify(n)}`,i;if(o.children.length===0)i={offset:o.offset+1,length:0,content:t};else{let e=o.children[o.children.length-1];i={offset:e.offset+e.length,length:0,content:`,`+t}}return o6(e,i,r)}else if(n===void 0&&o.children.length>=0){let t=s,n=o.children[t],i;if(o.children.length===1)i={offset:o.offset+1,length:o.length-2,content:``};else if(o.children.length-1===t){let e=o.children[t-1],n=e.offset+e.length;i={offset:n,length:o.offset+o.length-2-n,content:``}}else i={offset:n.offset,length:o.children[t+1].offset-n.offset,content:``};return o6(e,i,r)}else if(n!==void 0){let t,i=`${JSON.stringify(n)}`;if(!r.isArrayInsertion&&o.children.length>s){let e=o.children[s];t={offset:e.offset,length:e.length,content:i}}else if(o.children.length===0||s===0)t={offset:o.offset+1,length:0,content:o.children.length===0?i:i+`,`};else{let e=s>o.children.length?o.children.length:s,n=o.children[e-1];t={offset:n.offset+n.length,length:0,content:`,`+i}}return o6(e,t,r)}else throw Error(`Can not ${n===void 0?`remove`:r.isArrayInsertion?`insert`:`modify`} Array index ${t} as length is not sufficient`)}else throw Error(`Can not add ${typeof s==`number`?`property`:`index`} to parent of type ${o.type}`)}function o6(e,t,n){if(!n.formattingOptions)return[t];let r=s6(e,t),i=t.offset,a=t.offset+t.content.length;if(t.length===0||t.content.length===0){for(;i>0&&!e6(r,i-1);)i--;for(;a<r.length&&!e6(r,a);)a++}let o=Zye(r,{offset:i,length:a-i},{...n.formattingOptions,keepLines:!1});for(let e=o.length-1;e>=0;e--){let t=o[e];r=s6(r,t),i=Math.min(i,t.offset),a=Math.max(a,t.offset+t.length),a+=t.content.length-t.length}let s=e.length-(r.length-a)-i;return[{offset:i,length:s,content:r.substring(i,a)}]}function s6(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var rbe;(function(e){e[e.None=0]=`None`,e[e.UnexpectedEndOfComment=1]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=2]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=3]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=4]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=5]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=6]=`InvalidCharacter`})(rbe||={});var ibe;(function(e){e[e.OpenBraceToken=1]=`OpenBraceToken`,e[e.CloseBraceToken=2]=`CloseBraceToken`,e[e.OpenBracketToken=3]=`OpenBracketToken`,e[e.CloseBracketToken=4]=`CloseBracketToken`,e[e.CommaToken=5]=`CommaToken`,e[e.ColonToken=6]=`ColonToken`,e[e.NullKeyword=7]=`NullKeyword`,e[e.TrueKeyword=8]=`TrueKeyword`,e[e.FalseKeyword=9]=`FalseKeyword`,e[e.StringLiteral=10]=`StringLiteral`,e[e.NumericLiteral=11]=`NumericLiteral`,e[e.LineCommentTrivia=12]=`LineCommentTrivia`,e[e.BlockCommentTrivia=13]=`BlockCommentTrivia`,e[e.LineBreakTrivia=14]=`LineBreakTrivia`,e[e.Trivia=15]=`Trivia`,e[e.Unknown=16]=`Unknown`,e[e.EOF=17]=`EOF`})(ibe||={});const abe=ebe,obe=n6,c6=i6;var sbe;(function(e){e[e.InvalidSymbol=1]=`InvalidSymbol`,e[e.InvalidNumberFormat=2]=`InvalidNumberFormat`,e[e.PropertyNameExpected=3]=`PropertyNameExpected`,e[e.ValueExpected=4]=`ValueExpected`,e[e.ColonExpected=5]=`ColonExpected`,e[e.CommaExpected=6]=`CommaExpected`,e[e.CloseBraceExpected=7]=`CloseBraceExpected`,e[e.CloseBracketExpected=8]=`CloseBracketExpected`,e[e.EndOfFileExpected=9]=`EndOfFileExpected`,e[e.InvalidCommentToken=10]=`InvalidCommentToken`,e[e.UnexpectedEndOfComment=11]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=12]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=13]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=14]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=15]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=16]=`InvalidCharacter`})(sbe||={});function l6(e,t,n,r){return nbe(e,t,n,r)}function u6(e,t){let n=t.slice(0).sort((e,t)=>{let n=e.offset-t.offset;return n===0?e.length-t.length:n}),r=e.length;for(let t=n.length-1;t>=0;t--){let i=n[t];if(i.offset+i.length<=r)e=s6(e,i);else throw Error(`Overlapping edit`);r=i.offset}return e}W$(`mermaid-validator`),W$(`saved-themes`);const cbe=/^[A-Za-z0-9-]{8,64}$/;let d6=null;function lbe(e){return N(e??oe(),`.ok`,`machine-id`)}function ube(e){if(e===void 0&&d6!==null)return d6;let t=lbe(e),n=null;try{let e=S(t,`utf-8`).trim();cbe.test(e)&&(n=e)}catch{}if(n===null){n=je();try{v(pe(t),{recursive:!0}),te(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){W$(`machine-id`).warn({path:t,err:e},`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&&(d6=n),n}W$(`process-lock`);function dbe(e,t){return ve(e,`${t}.lock`)}new class{_tail=Promise.resolve();enqueue(e){let t=this._tail.then(()=>e());return this._tail=t.catch(()=>void 0),t}},W$(`git-context`),Fe(x),[...Rl];function f6(e,t){return[...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({editor:e,root:t})),{editor:`agents`,root:t}]}f6(Il,Yl),[...f6(Ll,Yl)].sort((e,t)=>{let n=f3.indexOf(e.editor),r=f3.indexOf(t.editor);return(n===-1?f3.length:n)-(r===-1?f3.length:r)||e.editor.localeCompare(t.editor)}),W$(`upload-streaming`),W$(`backlinks`),W$(`tag-index`),W$(`derived-document-index`),W$(`file-watcher`);function fbe(e){try{return O(ve(e,`.ok/config.yml`)).isFile()}catch(e){let t=e?.code;if(t===`ENOENT`||t===`ENOTDIR`)return!1;throw e}}W$(`git-checkout`),G$(()=>{}),W$(`asset-references`);const pbe=global.Request;var p6=class extends pbe{constructor(e,t){if(typeof e==`object`&&x6 in e){let n=t!==void 0&&`body`in t&&t.body!=null;if(e[A6]&&!n)throw TypeError(`Cannot construct a Request with a Request object that has already been used.`);e=e[x6]()}t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}};const m6=e=>{let t=[],n=e.rawHeaders;for(let e=0,r=n.length;e<r;e+=2){let r=n[e];r.charCodeAt(0)!==58&&t.push([r,n[e+1]])}return new Headers(t)},mbe=Symbol(`wrapBodyStream`),hbe=new Set([`latin1`,`binary`,`hex`,`base64`,`base64url`]),gbe=e=>e===null||hbe.has(e),h6=Symbol(`bodyBufferedBeforeDisconnect`),g6=Symbol(`bodyBufferedLengthBeforeDisconnect`),_6=(e,t)=>Buffer.isBuffer(e)?e:Buffer.from(e,t??`utf8`),v6=e=>!(e instanceof Ie)&&!!e.complete&&!!e.readableAborted&&typeof e.read==`function`&&gbe(e.readableEncoding),y6=(e,t)=>{if(e.readableDidRead&&!t||!v6(e))return;let n=e;if(n[h6]!==void 0)return n[h6];let r,i=e.errored;if(i&&i.code!==`ECONNRESET`)r=i;else if(n[g6]!==void 0&&e.readableLength!==n[g6])r=N6();else{let n=t??[],i=e.read();i!==null&&n.push(_6(i,e.readableEncoding));let a=n.length===1?n[0]:Buffer.concat(n);r=a;let o=e.headers[`content-length`];if(typeof o==`string`&&/^\d+$/.test(o)){let e=Number(o);Number.isSafeInteger(e)&&a.length!==e&&(r=N6())}}return n[h6]=r,r},b6=(e,t)=>{if(t instanceof Error){e.error(t);return}t.length>0&&e.enqueue(t),e.close()},_be=(e,t,n,r,i)=>{let a={method:e,headers:n,signal:i.signal};if(e===`TRACE`){a.method=`GET`;let e=new p6(t,a);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in r&&r.rawBody instanceof Buffer)a.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[mbe]){let e;a.body=new ReadableStream({async pull(t){try{if(!e){let e=y6(r);if(e!==void 0){b6(t,e);return}}e||=Oe.toWeb(r).getReader();let{done:n,value:i}=await e.read();n?t.close():t.enqueue(i)}catch(e){t.error(e)}}})}else{let e=y6(r);e===void 0?a.body=Oe.toWeb(r):a.body=new ReadableStream({start(t){b6(t,e)}})}return new p6(t,a)},x6=Symbol(`getRequestCache`),S6=Symbol(`requestCache`),C6=Symbol(`incomingKey`),w6=Symbol(`urlKey`),vbe=Symbol(`methodKey`),T6=Symbol(`headersKey`),E6=Symbol(`abortControllerKey`),D6=Symbol(`getAbortController`),ybe=Symbol(`abortRequest`),O6=Symbol(`bodyBuffer`),k6=Symbol(`bodyReadPromise`),A6=Symbol(`bodyConsumedDirectly`),j6=Symbol(`bodyLockReader`),M6=Symbol(`abortReason`),N6=()=>TypeError(`Body is unusable`),P6=()=>Promise.reject(N6()),bbe=new TextDecoder,xbe=e=>{if(e[A6])return P6();e[A6]=!0},Sbe=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),Cbe=e=>(e[T6]||=m6(e[C6])).get(`content-type`)||``,wbe=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Tbe=e=>{if(!wbe.test(e))return TypeError(`'${e}' is not a valid HTTP method.`);let t=e.toUpperCase();if(t===`CONNECT`||t===`TRACK`||t===`TRACE`&&e!==`TRACE`)return TypeError(`'${e}' HTTP method is unsupported.`)},F6=(e,t,n)=>{if(e[A6])return P6();let r=e.method;if(r===`GET`||r===`HEAD`)return e[x6]()[t]();let i=Tbe(r);if(i)return Promise.reject(i);if(e[S6]&&r!==`TRACE`)return e[S6][t]();let a=xbe(e);if(a)return a;let o=Ebe(e);if(o){let t=Promise.resolve(n(o,e));return e[O6]=void 0,t}return Dbe(e).then(t=>{let r=n(t,e);return e[O6]=void 0,r})},Ebe=e=>{let t=e[C6];if(`rawBody`in t&&t.rawBody instanceof Buffer)return t.rawBody},I6=(e,t)=>{if(t.errored)return t.errored;let n=e[M6];return n===void 0?Error(`Client connection prematurely closed.`):n instanceof Error?n:Error(String(n))},Dbe=e=>{if(e[O6])return Promise.resolve(e[O6]);if(e[k6])return e[k6];let t=e[C6];if(t.readableDidRead)return P6();let n=y6(t);if(n!==void 0)return n instanceof Error?Promise.reject(n):(e[O6]=n,Promise.resolve(n));let r=new Promise((n,r)=>{let i=[],a=!1,o=e=>{a||(a=!0,f(),e())},s=a=>{let s=t.errored??a;return!v6(t)||s&&s.code!==`ECONNRESET`?!1:(o(()=>{let o=y6(t,i);o instanceof Error?r(o):o===void 0?r(a??I6(e,t)):(e[O6]=o,n(o))}),!0)},c=e=>{i.push(_6(e,t.readableEncoding))},l=()=>{o(()=>{let t=i.length===1?i[0]:Buffer.concat(i);e[O6]=t,n(t)})},u=e=>{s(e)||o(()=>{r(e)})},d=()=>{if(t.readableEnded){l();return}s()||o(()=>{r(I6(e,t))})},f=()=>{t.off(`data`,c),t.off(`end`,l),t.off(`error`,u),t.off(`close`,d),e[k6]=void 0};t.on(`data`,c),t.on(`end`,l),t.on(`error`,u),t.on(`close`,d),queueMicrotask(()=>{a||(t.readableEnded?l():t.errored?u(t.errored):t.destroyed&&d())})});return e[k6]=r,r},L6={get method(){return this[vbe]},get url(){return this[w6]},get headers(){return this[T6]||=m6(this[C6])},[ybe](e){this[M6]===void 0&&(this[M6]=e);let t=this[E6];t&&!t.signal.aborted&&t.abort(e)},[D6](){return this[E6]||=new AbortController,this[M6]!==void 0&&!this[E6].signal.aborted&&this[E6].abort(this[M6]),this[E6]},[x6](){let e=this[D6]();if(this[S6])return this[S6];let t=this.method;if(this[A6]&&!(t===`GET`||t===`HEAD`)){this[O6]=void 0;let n={method:t===`TRACE`?`GET`:t,headers:this.headers,signal:e.signal};t!==`TRACE`&&(n.body=new ReadableStream({start(e){e.close()}}),n.duplex=`half`);let r=new p6(this[w6],n);return t===`TRACE`&&Object.defineProperty(r,`method`,{get(){return`TRACE`}}),this[S6]=r}return this[S6]=_be(this.method,this[w6],this.headers,this[C6],e)},get body(){if(!this[A6])return this[x6]().body;let e=this[x6]();return!this[j6]&&e.body&&(this[j6]=e.body.getReader()),e.body},get bodyUsed(){return this[A6]?!0:this[S6]?this[S6].bodyUsed:!1}};Object.defineProperty(L6,`signal`,{get(){return this[D6]().signal}}),[`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`keepalive`].forEach(e=>{Object.defineProperty(L6,e,{get(){return this[x6]()[e]}})}),[`clone`,`formData`].forEach(e=>{Object.defineProperty(L6,e,{value:function(){if(this[A6]){if(e===`clone`)throw N6();return P6()}return this[x6]()[e]()}})}),Object.defineProperty(L6,`text`,{value:function(){return F6(this,`text`,e=>bbe.decode(e))}}),Object.defineProperty(L6,`arrayBuffer`,{value:function(){return F6(this,`arrayBuffer`,e=>Sbe(e))}}),Object.defineProperty(L6,`blob`,{value:function(){return F6(this,`blob`,(e,t)=>{let n=Cbe(t);return new Response(e,n?{headers:{"content-type":n}}:void 0).blob()})}}),Object.defineProperty(L6,`json`,{value:function(){return this[A6]?P6():this.text().then(JSON.parse)}}),Object.defineProperty(L6,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){return`Request (lightweight) ${n({method:this.method,url:this.url,headers:this.headers,nativeRequest:this[S6]},{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(L6,p6.prototype);const R6=Symbol(`responseCache`),z6=Symbol(`getResponseCache`),B6=Symbol(`cache`),V6=global.Response;var H6=class e{#e;#t;[z6](){let e=this[B6],t=e&&e[2]instanceof Headers?e[2]:void 0;return delete this[B6],this[R6]||=new V6(this.#e,t?{status:this.#t?.status,statusText:this.#t?.statusText,headers:t}:this.#t)}constructor(t,n){let r;if(this.#e=t,n instanceof V6){let t=n[R6];if(t){this.#t=t,this[z6]();return}this.#t=n instanceof e?n.#t:n,r=new Headers(n.headers)}else this.#t=n;(t==null||typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(this[B6]=[n?.status||200,t??null,r||n?.headers])}get headers(){let e=this[B6];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||(e[1]===null?void 0:{"content-type":`text/plain; charset=UTF-8`}))),e[2]):this[z6]().headers}get status(){return this[B6]?.[0]??this[z6]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(H6.prototype,e,{get(){return this[z6]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(H6.prototype,e,{value:function(){return this[z6]()[e]()}})}),Object.defineProperty(H6.prototype,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){return`Response (lightweight) ${n({status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[R6]},{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(H6,V6),Object.setPrototypeOf(H6.prototype,V6.prototype);const Obe=/^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/,kbe=e=>e instanceof URL?e.href:Obe.test(e)?e:new URL(e).href,Abe=new Set([301,302,303,307,308]);Object.defineProperty(H6,`redirect`,{value:function(e,t=302){if(!Abe.has(t))throw RangeError(`Invalid status code`);return new H6(null,{status:t,headers:{location:kbe(e)}})},writable:!0,configurable:!0}),Object.defineProperty(H6,`json`,{value:function(e,t){let n=JSON.stringify(e);if(n===void 0)throw TypeError(`The data is not JSON serializable`);let r=t?.headers,i;return r?(i=new Headers(r),i.has(`content-type`)||i.set(`content-type`,`application/json`)):i={"content-type":`application/json`},new H6(n,{status:t?.status??200,statusText:t?.statusText,headers:i})},writable:!0,configurable:!0}),globalThis.CloseEvent,globalThis.ErrorEvent,new Response(null,{headers:{"x-hono-already-sent":`true`}}),W$(`suggest-links`);function U6(e){try{return T.native(e)}catch{return e}}`${Jl}`,`${Bl.join(`
454
+ `)}`,i(((e,t)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:new RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch{throw Error(`ipaddr: the address does not have IPv4 CIDR format`)}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,`toString`,{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}else if(t=e.match(r.twoOctet))return(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})();else if(t=e.match(r.threeOctet))return(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})();else return null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=this.toNormalizedString(),n=0,r=-1,i;for(;i=e.exec(t);)i[0].length>r&&(n=i.index,r=i[0].length);return r<0?t:`${t.substring(0,n)}::${t.substring(n+r)}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},p.IPv6.parse=function(e){let t=this.parser(e);if(t.parts===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,`toString`,{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch{throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`)}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(e)}))(),W$(`link-preview.guarded-fetch`),W$(`link-preview.cache`),W$(`local-op-security`),W$(`clone-flow`),Fe(s),W$(`managed-artifact-persistence`),W$(`managed-rename`);var W6=i(((e,t)=>{function n(e){if(e.length===0)return;let t=Object.create(null),n=0;for(;n<e.length;++n){let t=e.charCodeAt(n);if(u[t]!==1){if(t!==47||n===0)return;break}}if(n===e.length)return;let i=e.slice(0,n).toLowerCase(),a=++n;for(;n<e.length;++n)if(u[e.charCodeAt(n)]!==1){if(n===a||r(e,n,t)===void 0)return;break}if(n!==a)return{type:i,subtype:e.slice(a,n).toLowerCase(),params:t}}function r(e,t,n){for(;t<e.length;){for(;t<e.length;++t){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}if(t===e.length)break;if(e.charCodeAt(t++)!==59)return;for(;t<e.length;++t){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}if(t===e.length)return;let r,i=t;for(;t<e.length;++t){let n=e.charCodeAt(t);if(u[n]!==1){if(n!==61)return;break}}if(t===e.length||(r=e.slice(i,t),++t,t===e.length))return;let a=``,o;if(e.charCodeAt(t)===34){o=++t;let n=!1;for(;t<e.length;++t){let r=e.charCodeAt(t);if(r===92){n?(o=t,n=!1):(a+=e.slice(o,t),n=!0);continue}if(r===34){if(n){o=t,n=!1;continue}a+=e.slice(o,t);break}if(n&&=(o=t-1,!1),d[r]!==1)return}if(t===e.length)return;++t}else{for(o=t;t<e.length;++t)if(u[e.charCodeAt(t)]!==1){if(t===o)return;break}a=e.slice(o,t)}r=r.toLowerCase(),n[r]===void 0&&(n[r]=a)}return n}function i(e,t){if(e.length===0)return;let n=Object.create(null),r=0;for(;r<e.length;++r)if(u[e.charCodeAt(r)]!==1){if(a(e,r,n,t)===void 0)return;break}return{type:e.slice(0,r).toLowerCase(),params:n}}function a(e,t,n,r){for(;t<e.length;){for(;t<e.length;++t){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}if(t===e.length)break;if(e.charCodeAt(t++)!==59)return;for(;t<e.length;++t){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}if(t===e.length)return;let i,a=t;for(;t<e.length;++t){let n=e.charCodeAt(t);if(u[n]!==1){if(n===61)break;return}}if(t===e.length)return;let o=``,s,l;if(i=e.slice(a,t),i.charCodeAt(i.length-1)===42){let n=++t;for(;t<e.length;++t){let n=e.charCodeAt(t);if(f[n]!==1){if(n!==39)return;break}}if(t===e.length)return;for(l=e.slice(n,t),++t;t<e.length&&e.charCodeAt(t)!==39;++t);if(t===e.length||(++t,t===e.length))return;s=t;let r=0;for(;t<e.length;++t){let n=e.charCodeAt(t);if(p[n]!==1){if(n===37){let n,i;if(t+2<e.length&&(n=m[e.charCodeAt(t+1)])!==-1&&(i=m[e.charCodeAt(t+2)])!==-1){let a=(n<<4)+i;o+=e.slice(s,t),o+=String.fromCharCode(a),t+=2,s=t+1,a>=128?r=2:r===0&&(r=1);continue}return}break}}if(o+=e.slice(s,t),o=c(o,l,r),o===void 0)return}else{if(++t,t===e.length)return;if(e.charCodeAt(t)===34){s=++t;let n=!1;for(;t<e.length;++t){let r=e.charCodeAt(t);if(r===92){n?(s=t,n=!1):(o+=e.slice(s,t),n=!0);continue}if(r===34){if(n){s=t,n=!1;continue}o+=e.slice(s,t);break}if(n&&=(s=t-1,!1),d[r]!==1)return}if(t===e.length)return;++t}else{for(s=t;t<e.length;++t)if(u[e.charCodeAt(t)]!==1){if(t===s)return;break}o=e.slice(s,t)}if(o=r(o,2),o===void 0)return}i=i.toLowerCase(),n[i]===void 0&&(n[i]=o)}return n}function o(e){let t;for(;;)switch(e){case`utf-8`:case`utf8`:return s.utf8;case`latin1`:case`ascii`:case`us-ascii`:case`iso-8859-1`:case`iso8859-1`:case`iso88591`:case`iso_8859-1`:case`windows-1252`:case`iso_8859-1:1987`:case`cp1252`:case`x-cp1252`:return s.latin1;case`utf16le`:case`utf-16le`:case`ucs2`:case`ucs-2`:return s.utf16le;case`base64`:return s.base64;default:if(t===void 0){t=!0,e=e.toLowerCase();continue}return s.other.bind(e)}}let s={utf8:(e,t)=>{if(e.length===0)return``;if(typeof e==`string`){if(t<2)return e;e=Buffer.from(e,`latin1`)}return e.utf8Slice(0,e.length)},latin1:(e,t)=>e.length===0?``:typeof e==`string`?e:e.latin1Slice(0,e.length),utf16le:(e,t)=>e.length===0?``:(typeof e==`string`&&(e=Buffer.from(e,`latin1`)),e.ucs2Slice(0,e.length)),base64:(e,t)=>e.length===0?``:(typeof e==`string`&&(e=Buffer.from(e,`latin1`)),e.base64Slice(0,e.length)),other:(t,n)=>{if(t.length===0)return``;typeof t==`string`&&(t=Buffer.from(t,`latin1`));try{return new TextDecoder(e).decode(t)}catch{}}};function c(e,t,n){let r=o(t);if(r)return r(e,n)}function l(e){if(typeof e!=`string`)return``;for(let t=e.length-1;t>=0;--t)switch(e.charCodeAt(t)){case 47:case 92:return e=e.slice(t+1),e===`..`||e===`.`?``:e}return e===`..`||e===`.`?``:e}let u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d=[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],f=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],p=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],m=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];t.exports={basename:l,convertToUTF8:c,getDecoder:o,parseContentType:n,parseDisposition:i}})),jbe=i(((e,t)=>{function n(e,t,n,r,i){for(let a=0;a<i;++a)if(e[t+a]!==n[r+a])return!1;return!0}var r=class{constructor(e,t){if(typeof t!=`function`)throw Error(`Missing match callback`);if(typeof e==`string`)e=Buffer.from(e);else if(!Buffer.isBuffer(e))throw Error(`Expected Buffer for needle, got ${typeof e}`);let n=e.length;if(this.maxMatches=1/0,this.matches=0,this._cb=t,this._lookbehindSize=0,this._needle=e,this._bufPos=0,this._lookbehind=Buffer.allocUnsafe(n),this._occ=[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],n>1)for(let t=0;t<n-1;++t)this._occ[e[t]]=n-1-t}reset(){this.matches=0,this._lookbehindSize=0,this._bufPos=0}push(e,t){let n;Buffer.isBuffer(e)||(e=Buffer.from(e,`latin1`));let r=e.length;for(this._bufPos=t||0;n!==r&&this.matches<this.maxMatches;)n=i(this,e);return n}destroy(){let e=this._lookbehindSize;e&&this._cb(!1,this._lookbehind,0,e,!1),this.reset()}};function i(e,t){let r=t.length,i=e._needle,o=i.length,s=-e._lookbehindSize,c=o-1,l=i[c],u=r-o,d=e._occ,f=e._lookbehind;if(s<0){for(;s<0&&s<=u;){let n=s+c,r=n<0?f[e._lookbehindSize+n]:t[n];if(r===l&&a(e,t,s,c))return e._lookbehindSize=0,++e.matches,s>-e._lookbehindSize?e._cb(!0,f,0,e._lookbehindSize+s,!1):e._cb(!0,void 0,0,0,!0),e._bufPos=s+o;s+=d[r]}for(;s<0&&!a(e,t,s,r-s);)++s;if(s<0){let n=e._lookbehindSize+s;return n>0&&e._cb(!1,f,0,n,!1),e._lookbehindSize-=n,f.copy(f,0,n,e._lookbehindSize),f.set(t,e._lookbehindSize),e._lookbehindSize+=r,e._bufPos=r,r}e._cb(!1,f,0,e._lookbehindSize,!1),e._lookbehindSize=0}s+=e._bufPos;let p=i[0];for(;s<=u;){let r=t[s+c];if(r===l&&t[s]===p&&n(i,0,t,s,c))return++e.matches,s>0?e._cb(!0,t,e._bufPos,s,!0):e._cb(!0,void 0,0,0,!0),e._bufPos=s+o;s+=d[r]}for(;s<r;){if(t[s]!==p||!n(t,s,i,0,r-s)){++s;continue}t.copy(f,0,s,r),e._lookbehindSize=r-s;break}return s>0&&e._cb(!1,t,e._bufPos,s<r?s:r,!0),e._bufPos=r,r}function a(e,t,n,r){let i=e._lookbehind,a=e._lookbehindSize,o=e._needle;for(let e=0;e<r;++e,++n)if((n<0?i[a+n]:t[n])!==o[e])return!1;return!0}t.exports=r})),Mbe=i(((e,n)=>{let{Readable:r,Writable:i}=t(`stream`),a=jbe(),{basename:o,convertToUTF8:s,getDecoder:c,parseContentType:l,parseDisposition:u}=W6(),d=Buffer.from(`\r
455
+ `),f=Buffer.from(`\r`),p=Buffer.from(`-`);function m(){}let h=16*1024;var g=class{constructor(e){this.header=Object.create(null),this.pairCount=0,this.byteCount=0,this.state=0,this.name=``,this.value=``,this.crlf=0,this.cb=e}reset(){this.header=Object.create(null),this.pairCount=0,this.byteCount=0,this.state=0,this.name=``,this.value=``,this.crlf=0}push(e,t,n){let r=t;for(;t<n;)switch(this.state){case 0:{let i=!1;for(;t<n;++t){if(this.byteCount===h)return-1;++this.byteCount;let n=e[t];if(w[n]!==1){if(n!==58||(this.name+=e.latin1Slice(r,t),this.name.length===0))return-1;++t,i=!0,this.state=1;break}}if(!i){this.name+=e.latin1Slice(r,t);break}}case 1:{let i=!1;for(;t<n;++t){if(this.byteCount===h)return-1;++this.byteCount;let n=e[t];if(n!==32&&n!==9){r=t,i=!0,this.state=2;break}}if(!i)break}case 2:switch(this.crlf){case 0:for(;t<n;++t){if(this.byteCount===h)return-1;++this.byteCount;let n=e[t];if(T[n]!==1){if(n!==13)return-1;++this.crlf;break}}this.value+=e.latin1Slice(r,t++);break;case 1:if(this.byteCount===h||(++this.byteCount,e[t++]!==10))return-1;++this.crlf;break;case 2:{if(this.byteCount===h)return-1;++this.byteCount;let n=e[t];n===32||n===9?(r=t,this.crlf=0):(++this.pairCount<2e3&&(this.name=this.name.toLowerCase(),this.header[this.name]===void 0?this.header[this.name]=[this.value]:this.header[this.name].push(this.value)),n===13?(++this.crlf,++t):(r=t,this.crlf=0,this.state=0,this.name=``,this.value=``));break}case 3:{if(this.byteCount===h||(++this.byteCount,e[t++]!==10))return-1;let n=this.header;return this.reset(),this.cb(n),t}}break}return t}},_=class extends r{constructor(e,t){super(e),this.truncated=!1,this._readcb=null,this.once(`end`,()=>{if(this._read(),--t._fileEndsLeft===0&&t._finalcb){let e=t._finalcb;t._finalcb=null,process.nextTick(e)}})}_read(e){let t=this._readcb;t&&(this._readcb=null,t())}};let v={push:(e,t)=>{},destroy:()=>{}};function y(e,t){let n=e._writecb;e._writecb=null,t?e.destroy(t):n&&n()}function b(e,t){return e}var x=class extends i{constructor(e){let t={autoDestroy:!0,emitClose:!0,highWaterMark:typeof e.highWaterMark==`number`?e.highWaterMark:void 0};if(super(t),!e.conType.params||typeof e.conType.params.boundary!=`string`)throw Error(`Multipart: Boundary not found`);let n=e.conType.params.boundary,r=typeof e.defParamCharset==`string`&&e.defParamCharset?c(e.defParamCharset):b,i=e.defCharset||`utf8`,h=e.preservePath,y={autoDestroy:!0,emitClose:!0,highWaterMark:typeof e.fileHwm==`number`?e.fileHwm:void 0},x=e.limits,S=x&&typeof x.fieldSize==`number`?x.fieldSize:1*1024*1024,C=x&&typeof x.fileSize==`number`?x.fileSize:1/0,w=x&&typeof x.files==`number`?x.files:1/0,T=x&&typeof x.fields==`number`?x.fields:1/0,E=x&&typeof x.parts==`number`?x.parts:1/0,D=-1,O=0,ee=0,te=!1;this._fileEndsLeft=0,this._fileStream=void 0,this._complete=!1;let ne=0,re,ie=0,ae,oe,se,k,ce=!1,le=!1,ue=!1;this._hparser=null;let A=new g(e=>{this._hparser=null,te=!1,se=`text/plain`,ae=i,oe=`7bit`,k=void 0,ce=!1;let t;if(!e[`content-disposition`]){te=!0;return}let n=u(e[`content-disposition`][0],r);if(!n||n.type!==`form-data`){te=!0;return}if(n.params&&(n.params.name&&(k=n.params.name),n.params[`filename*`]?t=n.params[`filename*`]:n.params.filename&&(t=n.params.filename),t!==void 0&&!h&&(t=o(t))),e[`content-type`]){let t=l(e[`content-type`][0]);t&&(se=`${t.type}/${t.subtype}`,t.params&&typeof t.params.charset==`string`&&(ae=t.params.charset.toLowerCase()))}if(e[`content-transfer-encoding`]&&(oe=e[`content-transfer-encoding`][0].toLowerCase()),se===`application/octet-stream`||t!==void 0){if(ee===w){le||(le=!0,this.emit(`filesLimit`)),te=!0;return}if(++ee,this.listenerCount(`file`)===0){te=!0;return}ne=0,this._fileStream=new _(y,this),++this._fileEndsLeft,this.emit(`file`,k,this._fileStream,{filename:t,encoding:oe,mimeType:se})}else{if(O===T){ue||(ue=!0,this.emit(`fieldsLimit`)),te=!0;return}if(++O,this.listenerCount(`field`)===0){te=!0;return}re=[],ie=0}}),j=0,de=(e,t,n,r,i)=>{retrydata:for(;t;){if(this._hparser!==null){let e=this._hparser.push(t,n,r);if(e===-1){this._hparser=null,A.reset(),this.emit(`error`,Error(`Malformed part header`));break}n=e}if(n===r)break;if(j!==0){if(j===1){switch(t[n]){case 45:j=2,++n;break;case 13:j=3,++n;break;default:j=0}if(n===r)return}if(j===2){if(j=0,t[n]===45){this._complete=!0,this._bparser=v;return}let e=this._writecb;this._writecb=m,de(!1,p,0,1,!1),this._writecb=e}else if(j===3)if(j=0,t[n]===10){if(++n,D>=E||(this._hparser=A,n===r))break;continue retrydata}else{let e=this._writecb;this._writecb=m,de(!1,f,0,1,!1),this._writecb=e}}if(!te){if(this._fileStream){let e,a=Math.min(r-n,C-ne);i?e=t.slice(n,n+a):(e=Buffer.allocUnsafe(a),t.copy(e,0,n,n+a)),ne+=e.length,ne===C?(e.length>0&&this._fileStream.push(e),this._fileStream.emit(`limit`),this._fileStream.truncated=!0,te=!0):this._fileStream.push(e)||(this._writecb&&(this._fileStream._readcb=this._writecb),this._writecb=null)}else if(re!==void 0){let e,a=Math.min(r-n,S-ie);i?e=t.slice(n,n+a):(e=Buffer.allocUnsafe(a),t.copy(e,0,n,n+a)),ie+=a,re.push(e),ie===S&&(te=!0,ce=!0)}}break}if(e){if(j=1,this._fileStream)this._fileStream.push(null),this._fileStream=null;else if(re!==void 0){let e;switch(re.length){case 0:e=``;break;case 1:e=s(re[0],ae,0);break;default:e=s(Buffer.concat(re,ie),ae,0)}re=void 0,ie=0,this.emit(`field`,k,e,{nameTruncated:!1,valueTruncated:ce,encoding:oe,mimeType:se})}++D===E&&this.emit(`partsLimit`)}};this._bparser=new a(`\r\n--${n}`,de),this._writecb=null,this._finalcb=null,this.write(d)}static detect(e){return e.type===`multipart`&&e.subtype===`form-data`}_write(e,t,n){this._writecb=n,this._bparser.push(e,0),this._writecb&&y(this)}_destroy(e,t){this._hparser=null,this._bparser=v,e||=C(this);let n=this._fileStream;n&&(this._fileStream=null,n.destroy(e)),t(e)}_final(e){if(this._bparser.destroy(),!this._complete)return e(Error(`Unexpected end of form`));this._fileEndsLeft?this._finalcb=S.bind(null,this,e):S(this,e)}};function S(e,t,n){if(n)return t(n);n=C(e),t(n)}function C(e){if(e._hparser)return Error(`Malformed part header`);let t=e._fileStream;if(t&&(e._fileStream=null,t.destroy(Error(`Unexpected end of file`))),!e._complete)return Error(`Unexpected end of form`)}let w=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],T=[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];n.exports=x})),Nbe=i(((e,n)=>{let{Writable:r}=t(`stream`),{getDecoder:i}=W6();var a=class extends r{constructor(e){let t={autoDestroy:!0,emitClose:!0,highWaterMark:typeof e.highWaterMark==`number`?e.highWaterMark:void 0};super(t);let n=e.defCharset||`utf8`;e.conType.params&&typeof e.conType.params.charset==`string`&&(n=e.conType.params.charset),this.charset=n;let r=e.limits;this.fieldSizeLimit=r&&typeof r.fieldSize==`number`?r.fieldSize:1*1024*1024,this.fieldsLimit=r&&typeof r.fields==`number`?r.fields:1/0,this.fieldNameSizeLimit=r&&typeof r.fieldNameSize==`number`?r.fieldNameSize:100,this._inKey=!0,this._keyTrunc=!1,this._valTrunc=!1,this._bytesKey=0,this._bytesVal=0,this._fields=0,this._key=``,this._val=``,this._byte=-2,this._lastPos=0,this._encode=0,this._decoder=i(n)}static detect(e){return e.type===`application`&&e.subtype===`x-www-form-urlencoded`}_write(e,t,n){if(this._fields>=this.fieldsLimit)return n();let r=0,i=e.length;if(this._lastPos=0,this._byte!==-2){if(r=o(this,e,r,i),r===-1)return n(Error(`Malformed urlencoded form`));if(r>=i)return n();this._inKey?++this._bytesKey:++this._bytesVal}main:for(;r<i;)if(this._inKey){for(r=s(this,e,r,i);r<i;){switch(e[r]){case 61:this._lastPos<r&&(this._key+=e.latin1Slice(this._lastPos,r)),this._lastPos=++r,this._key=this._decoder(this._key,this._encode),this._encode=0,this._inKey=!1;continue main;case 38:if(this._lastPos<r&&(this._key+=e.latin1Slice(this._lastPos,r)),this._lastPos=++r,this._key=this._decoder(this._key,this._encode),this._encode=0,this._bytesKey>0&&this.emit(`field`,this._key,``,{nameTruncated:this._keyTrunc,valueTruncated:!1,encoding:this.charset,mimeType:`text/plain`}),this._key=``,this._val=``,this._keyTrunc=!1,this._valTrunc=!1,this._bytesKey=0,this._bytesVal=0,++this._fields>=this.fieldsLimit)return this.emit(`fieldsLimit`),n();continue;case 43:this._lastPos<r&&(this._key+=e.latin1Slice(this._lastPos,r)),this._key+=` `,this._lastPos=r+1;break;case 37:if(this._encode===0&&(this._encode=1),this._lastPos<r&&(this._key+=e.latin1Slice(this._lastPos,r)),this._lastPos=r+1,this._byte=-1,r=o(this,e,r+1,i),r===-1)return n(Error(`Malformed urlencoded form`));if(r>=i)return n();++this._bytesKey,r=s(this,e,r,i);continue}++r,++this._bytesKey,r=s(this,e,r,i)}this._lastPos<r&&(this._key+=e.latin1Slice(this._lastPos,r))}else{for(r=c(this,e,r,i);r<i;){switch(e[r]){case 38:if(this._lastPos<r&&(this._val+=e.latin1Slice(this._lastPos,r)),this._lastPos=++r,this._inKey=!0,this._val=this._decoder(this._val,this._encode),this._encode=0,(this._bytesKey>0||this._bytesVal>0)&&this.emit(`field`,this._key,this._val,{nameTruncated:this._keyTrunc,valueTruncated:this._valTrunc,encoding:this.charset,mimeType:`text/plain`}),this._key=``,this._val=``,this._keyTrunc=!1,this._valTrunc=!1,this._bytesKey=0,this._bytesVal=0,++this._fields>=this.fieldsLimit)return this.emit(`fieldsLimit`),n();continue main;case 43:this._lastPos<r&&(this._val+=e.latin1Slice(this._lastPos,r)),this._val+=` `,this._lastPos=r+1;break;case 37:if(this._encode===0&&(this._encode=1),this._lastPos<r&&(this._val+=e.latin1Slice(this._lastPos,r)),this._lastPos=r+1,this._byte=-1,r=o(this,e,r+1,i),r===-1)return n(Error(`Malformed urlencoded form`));if(r>=i)return n();++this._bytesVal,r=c(this,e,r,i);continue}++r,++this._bytesVal,r=c(this,e,r,i)}this._lastPos<r&&(this._val+=e.latin1Slice(this._lastPos,r))}n()}_final(e){if(this._byte!==-2)return e(Error(`Malformed urlencoded form`));(!this._inKey||this._bytesKey>0||this._bytesVal>0)&&(this._inKey?this._key=this._decoder(this._key,this._encode):this._val=this._decoder(this._val,this._encode),this.emit(`field`,this._key,this._val,{nameTruncated:this._keyTrunc,valueTruncated:this._valTrunc,encoding:this.charset,mimeType:`text/plain`})),e()}};function o(e,t,n,r){if(n>=r)return r;if(e._byte===-1){let i=l[t[n++]];if(i===-1)return-1;if(i>=8&&(e._encode=2),n<r){let r=l[t[n++]];if(r===-1)return-1;e._inKey?e._key+=String.fromCharCode((i<<4)+r):e._val+=String.fromCharCode((i<<4)+r),e._byte=-2,e._lastPos=n}else e._byte=i}else{let r=l[t[n++]];if(r===-1)return-1;e._inKey?e._key+=String.fromCharCode((e._byte<<4)+r):e._val+=String.fromCharCode((e._byte<<4)+r),e._byte=-2,e._lastPos=n}return n}function s(e,t,n,r){if(e._bytesKey>e.fieldNameSizeLimit){for(e._keyTrunc||e._lastPos<n&&(e._key+=t.latin1Slice(e._lastPos,n-1)),e._keyTrunc=!0;n<r;++n){let r=t[n];if(r===61||r===38)break;++e._bytesKey}e._lastPos=n}return n}function c(e,t,n,r){if(e._bytesVal>e.fieldSizeLimit){for(e._valTrunc||e._lastPos<n&&(e._val+=t.latin1Slice(e._lastPos,n-1)),e._valTrunc=!0;n<r&&t[n]!==38;++n)++e._bytesVal;e._lastPos=n}return n}let l=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];n.exports=a}));i(((e,t)=>{let{parseContentType:n}=W6();function r(e){let t=e.headers,r=n(t[`content-type`]);if(!r)throw Error(`Malformed content type`);for(let n of i){if(!n.detect(r))continue;let i={limits:e.limits,headers:t,conType:r,highWaterMark:void 0,fileHwm:void 0,defCharset:void 0,defParamCharset:void 0,preservePath:!1};return e.highWaterMark&&(i.highWaterMark=e.highWaterMark),e.fileHwm&&(i.fileHwm=e.fileHwm),i.defCharset=e.defCharset,i.defParamCharset=e.defParamCharset,i.preservePath=e.preservePath,new n(i)}throw Error(`Unsupported content type: ${t[`content-type`]}`)}let i=[Mbe(),Nbe()].filter(function(e){return typeof e.detect==`function`});t.exports=e=>{if((typeof e!=`object`||!e)&&(e={}),typeof e.headers!=`object`||e.headers===null||typeof e.headers[`content-type`]!=`string`)throw Error(`Missing Content-Type`);return r(e)}}))(),W$(`rename-log`),p3.project,Object.fromEntries(Object.entries(Xl).map(([e,t])=>[t,e])),[`These are patterns to adapt to your domain, not a layout to copy verbatim.`,"To build a variant: create your own folders (via `write` or your editor) and reuse only the ideas that fit.","To adopt this pack as-is: re-run without `--dry-run`."].join(`
456
+ `),Object.assign({"3g2":`video/3gpp2`,"3gp":`video/3gpp`,"3gpp":`video/3gpp`,"3mf":`model/3mf`,aac:`audio/aac`,ac:`application/pkix-attr-cert`,adp:`audio/adpcm`,adts:`audio/aac`,ai:`application/postscript`,aml:`application/automationml-aml+xml`,amlx:`application/automationml-amlx+zip`,amr:`audio/amr`,apng:`image/apng`,appcache:`text/cache-manifest`,appinstaller:`application/appinstaller`,appx:`application/appx`,appxbundle:`application/appxbundle`,asc:`application/pgp-keys`,atom:`application/atom+xml`,atomcat:`application/atomcat+xml`,atomdeleted:`application/atomdeleted+xml`,atomsvc:`application/atomsvc+xml`,au:`audio/basic`,avci:`image/avci`,avcs:`image/avcs`,avif:`image/avif`,aw:`application/applixware`,bdoc:`application/bdoc`,bin:`application/octet-stream`,bmp:`image/bmp`,bpk:`application/octet-stream`,btf:`image/prs.btif`,btif:`image/prs.btif`,buffer:`application/octet-stream`,ccxml:`application/ccxml+xml`,cdfx:`application/cdfx+xml`,cdmia:`application/cdmi-capability`,cdmic:`application/cdmi-container`,cdmid:`application/cdmi-domain`,cdmio:`application/cdmi-object`,cdmiq:`application/cdmi-queue`,cer:`application/pkix-cert`,cgm:`image/cgm`,cjs:`application/node`,class:`application/java-vm`,coffee:`text/coffeescript`,conf:`text/plain`,cpl:`application/cpl+xml`,cpt:`application/mac-compactpro`,crl:`application/pkix-crl`,css:`text/css`,csv:`text/csv`,cu:`application/cu-seeme`,cwl:`application/cwl`,cww:`application/prs.cww`,davmount:`application/davmount+xml`,dbk:`application/docbook+xml`,deb:`application/octet-stream`,def:`text/plain`,deploy:`application/octet-stream`,dib:`image/bmp`,"disposition-notification":`message/disposition-notification`,dist:`application/octet-stream`,distz:`application/octet-stream`,dll:`application/octet-stream`,dmg:`application/octet-stream`,dms:`application/octet-stream`,doc:`application/msword`,dot:`application/msword`,dpx:`image/dpx`,drle:`image/dicom-rle`,dsc:`text/prs.lines.tag`,dssc:`application/dssc+der`,dtd:`application/xml-dtd`,dump:`application/octet-stream`,dwd:`application/atsc-dwd+xml`,ear:`application/java-archive`,ecma:`application/ecmascript`,elc:`application/octet-stream`,emf:`image/emf`,eml:`message/rfc822`,emma:`application/emma+xml`,emotionml:`application/emotionml+xml`,eps:`application/postscript`,epub:`application/epub+zip`,exe:`application/octet-stream`,exi:`application/exi`,exp:`application/express`,exr:`image/aces`,ez:`application/andrew-inset`,fdf:`application/fdf`,fdt:`application/fdt+xml`,fits:`image/fits`,g3:`image/g3fax`,gbr:`application/rpki-ghostbusters`,geojson:`application/geo+json`,gif:`image/gif`,glb:`model/gltf-binary`,gltf:`model/gltf+json`,gml:`application/gml+xml`,gpx:`application/gpx+xml`,gram:`application/srgs`,grxml:`application/srgs+xml`,gxf:`application/gxf`,gz:`application/gzip`,h261:`video/h261`,h263:`video/h263`,h264:`video/h264`,heic:`image/heic`,heics:`image/heic-sequence`,heif:`image/heif`,heifs:`image/heif-sequence`,hej2:`image/hej2k`,held:`application/atsc-held+xml`,hjson:`application/hjson`,hlp:`application/winhlp`,hqx:`application/mac-binhex40`,hsj2:`image/hsj2`,htm:`text/html`,html:`text/html`,ics:`text/calendar`,ief:`image/ief`,ifb:`text/calendar`,iges:`model/iges`,igs:`model/iges`,img:`application/octet-stream`,in:`text/plain`,ini:`text/plain`,ink:`application/inkml+xml`,inkml:`application/inkml+xml`,ipfix:`application/ipfix`,iso:`application/octet-stream`,its:`application/its+xml`,jade:`text/jade`,jar:`application/java-archive`,jhc:`image/jphc`,jls:`image/jls`,jp2:`image/jp2`,jpe:`image/jpeg`,jpeg:`image/jpeg`,jpf:`image/jpx`,jpg:`image/jpeg`,jpg2:`image/jp2`,jpgm:`image/jpm`,jpgv:`video/jpeg`,jph:`image/jph`,jpm:`image/jpm`,jpx:`image/jpx`,js:`text/javascript`,json:`application/json`,json5:`application/json5`,jsonld:`application/ld+json`,jsonml:`application/jsonml+json`,jsx:`text/jsx`,jt:`model/jt`,jxl:`image/jxl`,jxr:`image/jxr`,jxra:`image/jxra`,jxrs:`image/jxrs`,jxs:`image/jxs`,jxsc:`image/jxsc`,jxsi:`image/jxsi`,jxss:`image/jxss`,kar:`audio/midi`,ktx:`image/ktx`,ktx2:`image/ktx2`,less:`text/less`,lgr:`application/lgr+xml`,list:`text/plain`,litcoffee:`text/coffeescript`,log:`text/plain`,lostxml:`application/lost+xml`,lrf:`application/octet-stream`,m1v:`video/mpeg`,m21:`application/mp21`,m2a:`audio/mpeg`,m2t:`video/mp2t`,m2ts:`video/mp2t`,m2v:`video/mpeg`,m3a:`audio/mpeg`,m4a:`audio/mp4`,m4p:`application/mp4`,m4s:`video/iso.segment`,ma:`application/mathematica`,mads:`application/mads+xml`,maei:`application/mmt-aei+xml`,man:`text/troff`,manifest:`text/cache-manifest`,map:`application/json`,mar:`application/octet-stream`,markdown:`text/markdown`,mathml:`application/mathml+xml`,mb:`application/mathematica`,mbox:`application/mbox`,md:`text/markdown`,mdx:`text/mdx`,me:`text/troff`,mesh:`model/mesh`,meta4:`application/metalink4+xml`,metalink:`application/metalink+xml`,mets:`application/mets+xml`,mft:`application/rpki-manifest`,mid:`audio/midi`,midi:`audio/midi`,mime:`message/rfc822`,mj2:`video/mj2`,mjp2:`video/mj2`,mjs:`text/javascript`,mml:`text/mathml`,mods:`application/mods+xml`,mov:`video/quicktime`,mp2:`audio/mpeg`,mp21:`application/mp21`,mp2a:`audio/mpeg`,mp3:`audio/mpeg`,mp4:`video/mp4`,mp4a:`audio/mp4`,mp4s:`application/mp4`,mp4v:`video/mp4`,mpd:`application/dash+xml`,mpe:`video/mpeg`,mpeg:`video/mpeg`,mpf:`application/media-policy-dataset+xml`,mpg:`video/mpeg`,mpg4:`video/mp4`,mpga:`audio/mpeg`,mpp:`application/dash-patch+xml`,mrc:`application/marc`,mrcx:`application/marcxml+xml`,ms:`text/troff`,mscml:`application/mediaservercontrol+xml`,msh:`model/mesh`,msi:`application/octet-stream`,msix:`application/msix`,msixbundle:`application/msixbundle`,msm:`application/octet-stream`,msp:`application/octet-stream`,mtl:`model/mtl`,mts:`video/mp2t`,musd:`application/mmt-usd+xml`,mxf:`application/mxf`,mxmf:`audio/mobile-xmf`,mxml:`application/xv+xml`,n3:`text/n3`,nb:`application/mathematica`,nq:`application/n-quads`,nt:`application/n-triples`,obj:`model/obj`,oda:`application/oda`,oga:`audio/ogg`,ogg:`audio/ogg`,ogv:`video/ogg`,ogx:`application/ogg`,omdoc:`application/omdoc+xml`,onepkg:`application/onenote`,onetmp:`application/onenote`,onetoc:`application/onenote`,onetoc2:`application/onenote`,opf:`application/oebps-package+xml`,opus:`audio/ogg`,otf:`font/otf`,owl:`application/rdf+xml`,oxps:`application/oxps`,p10:`application/pkcs10`,p7c:`application/pkcs7-mime`,p7m:`application/pkcs7-mime`,p7s:`application/pkcs7-signature`,p8:`application/pkcs8`,pdf:`application/pdf`,pfr:`application/font-tdpfr`,pgp:`application/pgp-encrypted`,pkg:`application/octet-stream`,pki:`application/pkixcmp`,pkipath:`application/pkix-pkipath`,pls:`application/pls+xml`,png:`image/png`,prc:`model/prc`,prf:`application/pics-rules`,provx:`application/provenance+xml`,ps:`application/postscript`,pskcxml:`application/pskc+xml`,pti:`image/prs.pti`,qt:`video/quicktime`,raml:`application/raml+yaml`,rapd:`application/route-apd+xml`,rdf:`application/rdf+xml`,relo:`application/p2p-overlay+xml`,rif:`application/reginfo+xml`,rl:`application/resource-lists+xml`,rld:`application/resource-lists-diff+xml`,rmi:`audio/midi`,rnc:`application/relax-ng-compact-syntax`,rng:`application/xml`,roa:`application/rpki-roa`,roff:`text/troff`,rq:`application/sparql-query`,rs:`application/rls-services+xml`,rsat:`application/atsc-rsat+xml`,rsd:`application/rsd+xml`,rsheet:`application/urc-ressheet+xml`,rss:`application/rss+xml`,rtf:`text/rtf`,rtx:`text/richtext`,rusd:`application/route-usd+xml`,s3m:`audio/s3m`,sbml:`application/sbml+xml`,scq:`application/scvp-cv-request`,scs:`application/scvp-cv-response`,sdp:`application/sdp`,senmlx:`application/senml+xml`,sensmlx:`application/sensml+xml`,ser:`application/java-serialized-object`,setpay:`application/set-payment-initiation`,setreg:`application/set-registration-initiation`,sgi:`image/sgi`,sgm:`text/sgml`,sgml:`text/sgml`,shex:`text/shex`,shf:`application/shf+xml`,shtml:`text/html`,sieve:`application/sieve`,sig:`application/pgp-signature`,sil:`audio/silk`,silo:`model/mesh`,siv:`application/sieve`,slim:`text/slim`,slm:`text/slim`,sls:`application/route-s-tsid+xml`,smi:`application/smil+xml`,smil:`application/smil+xml`,snd:`audio/basic`,so:`application/octet-stream`,spdx:`text/spdx`,spp:`application/scvp-vp-response`,spq:`application/scvp-vp-request`,spx:`audio/ogg`,sql:`application/sql`,sru:`application/sru+xml`,srx:`application/sparql-results+xml`,ssdl:`application/ssdl+xml`,ssml:`application/ssml+xml`,stk:`application/hyperstudio`,stl:`model/stl`,stpx:`model/step+xml`,stpxz:`model/step-xml+zip`,stpz:`model/step+zip`,styl:`text/stylus`,stylus:`text/stylus`,svg:`image/svg+xml`,svgz:`image/svg+xml`,swidtag:`application/swid+xml`,t:`text/troff`,t38:`image/t38`,td:`application/urc-targetdesc+xml`,tei:`application/tei+xml`,teicorpus:`application/tei+xml`,text:`text/plain`,tfi:`application/thraud+xml`,tfx:`image/tiff-fx`,tif:`image/tiff`,tiff:`image/tiff`,toml:`application/toml`,tr:`text/troff`,trig:`application/trig`,ts:`video/mp2t`,tsd:`application/timestamped-data`,tsv:`text/tab-separated-values`,ttc:`font/collection`,ttf:`font/ttf`,ttl:`text/turtle`,ttml:`application/ttml+xml`,txt:`text/plain`,u3d:`model/u3d`,u8dsn:`message/global-delivery-status`,u8hdr:`message/global-headers`,u8mdn:`message/global-disposition-notification`,u8msg:`message/global`,ubj:`application/ubjson`,uri:`text/uri-list`,uris:`text/uri-list`,urls:`text/uri-list`,vcard:`text/vcard`,vrml:`model/vrml`,vtt:`text/vtt`,vxml:`application/voicexml+xml`,war:`application/java-archive`,wasm:`application/wasm`,wav:`audio/wav`,weba:`audio/webm`,webm:`video/webm`,webmanifest:`application/manifest+json`,webp:`image/webp`,wgsl:`text/wgsl`,wgt:`application/widget`,wif:`application/watcherinfo+xml`,wmf:`image/wmf`,woff:`font/woff`,woff2:`font/woff2`,wrl:`model/vrml`,wsdl:`application/wsdl+xml`,wspolicy:`application/wspolicy+xml`,x3d:`model/x3d+xml`,x3db:`model/x3d+fastinfoset`,x3dbz:`model/x3d+binary`,x3dv:`model/x3d-vrml`,x3dvz:`model/x3d+vrml`,x3dz:`model/x3d+xml`,xaml:`application/xaml+xml`,xav:`application/xcap-att+xml`,xca:`application/xcap-caps+xml`,xcs:`application/calendar+xml`,xdf:`application/xcap-diff+xml`,xdssc:`application/dssc+xml`,xel:`application/xcap-el+xml`,xenc:`application/xenc+xml`,xer:`application/patch-ops-error+xml`,xfdf:`application/xfdf`,xht:`application/xhtml+xml`,xhtml:`application/xhtml+xml`,xhvml:`application/xv+xml`,xlf:`application/xliff+xml`,xm:`audio/xm`,xml:`text/xml`,xns:`application/xcap-ns+xml`,xop:`application/xop+xml`,xpl:`application/xproc+xml`,xsd:`application/xml`,xsf:`application/prs.xsf+xml`,xsl:`application/xml`,xslt:`application/xml`,xspf:`application/xspf+xml`,xvm:`application/xv+xml`,xvml:`application/xv+xml`,yaml:`text/yaml`,yang:`application/yang`,yin:`application/yin+xml`,yml:`text/yaml`,zip:`application/zip`},{m4v:`video/mp4`,mkv:`video/x-matroska`,flac:`audio/flac`,toml:`application/toml`,lock:`text/plain`,"7z":`application/x-7z-compressed`,tar:`application/x-tar`,rar:`application/vnd.rar`,xls:`application/vnd.ms-excel`,ppt:`application/vnd.ms-powerpoint`,odt:`application/vnd.oasis.opendocument.text`,ods:`application/vnd.oasis.opendocument.spreadsheet`,odp:`application/vnd.oasis.opendocument.presentation`,pages:`application/vnd.apple.pages`,numbers:`application/vnd.apple.numbers`,key:`application/vnd.apple.keynote`,mobi:`application/x-mobipocket-ebook`}),W$(`file-ops`),W$(`search`),W$(`skill-import`),W$(`skill-install`),W$(`history`),W$(`skills-leaderboard`),W$(`timeline`),W$(`api`),B({enabled:L(),active:L(),git:B({state:H([`not-applicable`,`ready`,`missing`,`conflict`,`unavailable`]),ownership:H([`open-knowledge`,`existing`]).optional()}),applied:L().optional(),reason:H([`git-conflict`,`git-unavailable`,`config-write`]).optional()}),B({enabled:L()}).strict(),B({principalId:F().optional(),tabSessionId:F().optional(),expectedServerInstanceId:F().optional(),expectedBranch:F().optional(),expectedDocLineageEpoch:F().optional(),clientProtocolVersion:I().optional(),clientRuntimeVersion:F().optional(),clientKind:F().optional()}).loose(),W$(`conflict-storage`);const G6=To(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),K6=uo([F(),I().int()]),q6=F();co({ttl:I().optional(),pollInterval:I().optional()});const Pbe=B({ttl:I().optional()}),Fbe=B({taskId:F()}),J6=co({progressToken:K6.optional(),"io.modelcontextprotocol/related-task":Fbe.optional()}),Y6=B({_meta:J6.optional()}),X6=Y6.extend({task:Pbe.optional()}),Z6=B({method:F(),params:Y6.loose().optional()}),Q6=B({_meta:J6.optional()}),$6=B({method:F(),params:Q6.loose().optional()}),e8=co({_meta:J6.optional()}),t8=uo([F(),I().int()]),Ibe=B({jsonrpc:U(`2.0`),id:t8,...Z6.shape}).strict(),Lbe=B({jsonrpc:U(`2.0`),...$6.shape}).strict(),n8=B({jsonrpc:U(`2.0`),id:t8,result:e8}).strict();var Rbe;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(Rbe||={});const r8=B({jsonrpc:U(`2.0`),id:t8.optional(),error:B({code:I().int(),message:F(),data:R().optional()})}).strict();uo([Ibe,Lbe,n8,r8]),uo([n8,r8]);const i8=e8.strict(),zbe=Q6.extend({requestId:t8.optional(),reason:F().optional()}),a8=$6.extend({method:U(`notifications/cancelled`),params:zbe}),o8=B({icons:z(B({src:F(),mimeType:F().optional(),sizes:z(F()).optional(),theme:H([`light`,`dark`]).optional()})).optional()}),s8=B({name:F(),title:F().optional()}),c8=s8.extend({...s8.shape,...o8.shape,version:F(),websiteUrl:F().optional(),description:F().optional()}),Bbe=Eo(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,po(B({form:po(B({applyDefaults:L().optional()}),V(F(),R())).optional(),url:G6.optional()}),V(F(),R()).optional())),Vbe=co({list:G6.optional(),cancel:G6.optional(),requests:co({sampling:co({createMessage:G6.optional()}).optional(),elicitation:co({create:G6.optional()}).optional()}).optional()}),Hbe=co({list:G6.optional(),cancel:G6.optional(),requests:co({tools:co({call:G6.optional()}).optional()}).optional()}),Ube=B({experimental:V(F(),G6).optional(),sampling:B({context:G6.optional(),tools:G6.optional()}).optional(),elicitation:Bbe.optional(),roots:B({listChanged:L().optional()}).optional(),tasks:Vbe.optional(),extensions:V(F(),G6).optional()}),Wbe=Y6.extend({protocolVersion:F(),capabilities:Ube,clientInfo:c8}),Gbe=Z6.extend({method:U(`initialize`),params:Wbe}),Kbe=B({experimental:V(F(),G6).optional(),logging:G6.optional(),completions:G6.optional(),prompts:B({listChanged:L().optional()}).optional(),resources:B({subscribe:L().optional(),listChanged:L().optional()}).optional(),tools:B({listChanged:L().optional()}).optional(),tasks:Hbe.optional(),extensions:V(F(),G6).optional()}),qbe=e8.extend({protocolVersion:F(),capabilities:Kbe,serverInfo:c8,instructions:F().optional()}),Jbe=$6.extend({method:U(`notifications/initialized`),params:Q6.optional()}),l8=Z6.extend({method:U(`ping`),params:Y6.optional()}),Ybe=B({progress:I(),total:vo(I()),message:vo(F())}),Xbe=B({...Q6.shape,...Ybe.shape,progressToken:K6}),u8=$6.extend({method:U(`notifications/progress`),params:Xbe}),Zbe=Y6.extend({cursor:q6.optional()}),d8=Z6.extend({params:Zbe.optional()}),f8=e8.extend({nextCursor:q6.optional()}),Qbe=H([`working`,`input_required`,`completed`,`failed`,`cancelled`]),p8=B({taskId:F(),status:Qbe,ttl:uo([I(),oo()]),createdAt:F(),lastUpdatedAt:F(),pollInterval:vo(I()),statusMessage:vo(F())}),m8=e8.extend({task:p8}),$be=Q6.merge(p8),h8=$6.extend({method:U(`notifications/tasks/status`),params:$be}),g8=Z6.extend({method:U(`tasks/get`),params:Y6.extend({taskId:F()})}),_8=e8.merge(p8),v8=Z6.extend({method:U(`tasks/result`),params:Y6.extend({taskId:F()})});e8.loose();const y8=d8.extend({method:U(`tasks/list`)}),b8=f8.extend({tasks:z(p8)}),x8=Z6.extend({method:U(`tasks/cancel`),params:Y6.extend({taskId:F()})});e8.merge(p8);const S8=B({uri:F(),mimeType:vo(F()),_meta:V(F(),R()).optional()}),C8=S8.extend({text:F()}),w8=F().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),T8=S8.extend({blob:w8}),E8=H([`user`,`assistant`]),D8=B({audience:z(E8).optional(),priority:I().min(0).max(1).optional(),lastModified:Ma({offset:!0}).optional()}),O8=B({...s8.shape,...o8.shape,uri:F(),description:vo(F()),mimeType:vo(F()),size:vo(I()),annotations:D8.optional(),_meta:vo(co({}))}),exe=B({...s8.shape,...o8.shape,uriTemplate:F(),description:vo(F()),mimeType:vo(F()),annotations:D8.optional(),_meta:vo(co({}))}),txe=d8.extend({method:U(`resources/list`)}),nxe=f8.extend({resources:z(O8)}),rxe=d8.extend({method:U(`resources/templates/list`)}),ixe=f8.extend({resourceTemplates:z(exe)}),k8=Y6.extend({uri:F()}),axe=k8,oxe=Z6.extend({method:U(`resources/read`),params:axe}),sxe=e8.extend({contents:z(uo([C8,T8]))}),cxe=$6.extend({method:U(`notifications/resources/list_changed`),params:Q6.optional()}),lxe=k8,uxe=Z6.extend({method:U(`resources/subscribe`),params:lxe}),dxe=k8,fxe=Z6.extend({method:U(`resources/unsubscribe`),params:dxe}),pxe=Q6.extend({uri:F()}),mxe=$6.extend({method:U(`notifications/resources/updated`),params:pxe}),hxe=B({name:F(),description:vo(F()),required:vo(L())}),gxe=B({...s8.shape,...o8.shape,description:vo(F()),arguments:vo(z(hxe)),_meta:vo(co({}))}),_xe=d8.extend({method:U(`prompts/list`)}),vxe=f8.extend({prompts:z(gxe)}),yxe=Y6.extend({name:F(),arguments:V(F(),F()).optional()}),bxe=Z6.extend({method:U(`prompts/get`),params:yxe}),A8=B({type:U(`text`),text:F(),annotations:D8.optional(),_meta:V(F(),R()).optional()}),j8=B({type:U(`image`),data:w8,mimeType:F(),annotations:D8.optional(),_meta:V(F(),R()).optional()}),M8=B({type:U(`audio`),data:w8,mimeType:F(),annotations:D8.optional(),_meta:V(F(),R()).optional()}),xxe=B({type:U(`tool_use`),name:F(),id:F(),input:V(F(),R()),_meta:V(F(),R()).optional()}),Sxe=B({type:U(`resource`),resource:uo([C8,T8]),annotations:D8.optional(),_meta:V(F(),R()).optional()}),N8=uo([A8,j8,M8,O8.extend({type:U(`resource_link`)}),Sxe]),Cxe=B({role:E8,content:N8}),wxe=e8.extend({description:F().optional(),messages:z(Cxe)}),Txe=$6.extend({method:U(`notifications/prompts/list_changed`),params:Q6.optional()}),Exe=B({title:F().optional(),readOnlyHint:L().optional(),destructiveHint:L().optional(),idempotentHint:L().optional(),openWorldHint:L().optional()}),Dxe=B({taskSupport:H([`required`,`optional`,`forbidden`]).optional()}),P8=B({...s8.shape,...o8.shape,description:F().optional(),inputSchema:B({type:U(`object`),properties:V(F(),G6).optional(),required:z(F()).optional()}).catchall(R()),outputSchema:B({type:U(`object`),properties:V(F(),G6).optional(),required:z(F()).optional()}).catchall(R()).optional(),annotations:Exe.optional(),execution:Dxe.optional(),_meta:V(F(),R()).optional()}),Oxe=d8.extend({method:U(`tools/list`)}),kxe=f8.extend({tools:z(P8)}),F8=e8.extend({content:z(N8).default([]),structuredContent:V(F(),R()).optional(),isError:L().optional()});F8.or(e8.extend({toolResult:R()}));const Axe=X6.extend({name:F(),arguments:V(F(),R()).optional()}),jxe=Z6.extend({method:U(`tools/call`),params:Axe}),Mxe=$6.extend({method:U(`notifications/tools/list_changed`),params:Q6.optional()});B({autoRefresh:L().default(!0),debounceMs:I().int().nonnegative().default(300)});const I8=H([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Nxe=Y6.extend({level:I8}),Pxe=Z6.extend({method:U(`logging/setLevel`),params:Nxe}),Fxe=Q6.extend({level:I8,logger:F().optional(),data:R()}),Ixe=$6.extend({method:U(`notifications/message`),params:Fxe}),Lxe=B({hints:z(B({name:F().optional()})).optional(),costPriority:I().min(0).max(1).optional(),speedPriority:I().min(0).max(1).optional(),intelligencePriority:I().min(0).max(1).optional()}),Rxe=B({mode:H([`auto`,`required`,`none`]).optional()}),zxe=B({type:U(`tool_result`),toolUseId:F().describe(`The unique identifier for the corresponding tool call.`),content:z(N8).default([]),structuredContent:B({}).loose().optional(),isError:L().optional(),_meta:V(F(),R()).optional()}),Bxe=fo(`type`,[A8,j8,M8]),L8=fo(`type`,[A8,j8,M8,xxe,zxe]),Vxe=B({role:E8,content:uo([L8,z(L8)]),_meta:V(F(),R()).optional()}),Hxe=X6.extend({messages:z(Vxe),modelPreferences:Lxe.optional(),systemPrompt:F().optional(),includeContext:H([`none`,`thisServer`,`allServers`]).optional(),temperature:I().optional(),maxTokens:I().int(),stopSequences:z(F()).optional(),metadata:G6.optional(),tools:z(P8).optional(),toolChoice:Rxe.optional()}),Uxe=Z6.extend({method:U(`sampling/createMessage`),params:Hxe}),Wxe=e8.extend({model:F(),stopReason:vo(H([`endTurn`,`stopSequence`,`maxTokens`]).or(F())),role:E8,content:Bxe}),Gxe=e8.extend({model:F(),stopReason:vo(H([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(F())),role:E8,content:uo([L8,z(L8)])}),Kxe=B({type:U(`boolean`),title:F().optional(),description:F().optional(),default:L().optional()}),qxe=B({type:U(`string`),title:F().optional(),description:F().optional(),minLength:I().optional(),maxLength:I().optional(),format:H([`email`,`uri`,`date`,`date-time`]).optional(),default:F().optional()}),Jxe=B({type:H([`number`,`integer`]),title:F().optional(),description:F().optional(),minimum:I().optional(),maximum:I().optional(),default:I().optional()}),Yxe=B({type:U(`string`),title:F().optional(),description:F().optional(),enum:z(F()),default:F().optional()}),Xxe=B({type:U(`string`),title:F().optional(),description:F().optional(),oneOf:z(B({const:F(),title:F()})),default:F().optional()}),Zxe=uo([uo([B({type:U(`string`),title:F().optional(),description:F().optional(),enum:z(F()),enumNames:z(F()).optional(),default:F().optional()}),uo([Yxe,Xxe]),uo([B({type:U(`array`),title:F().optional(),description:F().optional(),minItems:I().optional(),maxItems:I().optional(),items:B({type:U(`string`),enum:z(F())}),default:z(F()).optional()}),B({type:U(`array`),title:F().optional(),description:F().optional(),minItems:I().optional(),maxItems:I().optional(),items:B({anyOf:z(B({const:F(),title:F()}))}),default:z(F()).optional()})])]),Kxe,qxe,Jxe]),Qxe=uo([X6.extend({mode:U(`form`).optional(),message:F(),requestedSchema:B({type:U(`object`),properties:V(F(),Zxe),required:z(F()).optional()})}),X6.extend({mode:U(`url`),message:F(),elicitationId:F(),url:F().url()})]),$xe=Z6.extend({method:U(`elicitation/create`),params:Qxe}),eSe=Q6.extend({elicitationId:F()}),tSe=$6.extend({method:U(`notifications/elicitation/complete`),params:eSe}),nSe=e8.extend({action:H([`accept`,`decline`,`cancel`]),content:Eo(e=>e===null?void 0:e,V(F(),uo([F(),I(),L(),z(F())])).optional())}),rSe=B({type:U(`ref/resource`),uri:F()}),iSe=B({type:U(`ref/prompt`),name:F()}),aSe=Y6.extend({ref:uo([iSe,rSe]),argument:B({name:F(),value:F()}),context:B({arguments:V(F(),F()).optional()}).optional()}),oSe=Z6.extend({method:U(`completion/complete`),params:aSe}),sSe=e8.extend({completion:co({values:z(F()).max(100),total:vo(I().int()),hasMore:vo(L())})}),cSe=B({uri:F().startsWith(`file://`),name:F().optional(),_meta:V(F(),R()).optional()}),lSe=Z6.extend({method:U(`roots/list`),params:Y6.optional()}),uSe=e8.extend({roots:z(cSe)}),dSe=$6.extend({method:U(`notifications/roots/list_changed`),params:Q6.optional()});uo([l8,Gbe,oSe,Pxe,bxe,_xe,txe,rxe,oxe,uxe,fxe,jxe,Oxe,g8,v8,y8,x8]),uo([a8,u8,Jbe,dSe,h8]),uo([i8,Wxe,Gxe,nSe,uSe,_8,b8,m8]),uo([l8,Uxe,$xe,lSe,g8,v8,y8,x8]),uo([a8,u8,Ixe,mxe,cxe,Mxe,Txe,h8,tSe]),uo([i8,qbe,sSe,wxe,vxe,nxe,ixe,sxe,F8,kxe,_8,b8,m8]);var fSe;(function(e){e.Completable=`McpCompletable`})(fSe||={});var pSe=global.Request,R8=class extends pSe{constructor(e,t){typeof e==`object`&&z8 in e&&(e=e[z8]()),t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}},mSe=e=>{let t=[],n=e.rawHeaders;for(let e=0;e<n.length;e+=2){let{[e]:r,[e+1]:i}=n;r.charCodeAt(0)!==58&&t.push([r,i])}return new Headers(t)},hSe=Symbol(`wrapBodyStream`),gSe=(e,t,n,r,i)=>{let a={method:e,headers:n,signal:i.signal};if(e===`TRACE`){a.method=`GET`;let e=new R8(t,a);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in r&&r.rawBody instanceof Buffer)a.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[hSe]){let e;a.body=new ReadableStream({async pull(t){try{e||=Ne.toWeb(r).getReader();let{done:n,value:i}=await e.read();n?t.close():t.enqueue(i)}catch(e){t.error(e)}}})}else a.body=Ne.toWeb(r);return new R8(t,a)},z8=Symbol(`getRequestCache`),B8=Symbol(`requestCache`),V8=Symbol(`incomingKey`),H8=Symbol(`urlKey`),_Se=Symbol(`headersKey`),U8=Symbol(`abortControllerKey`),W8={get method(){return this[V8].method||`GET`},get url(){return this[H8]},get headers(){return this[_Se]||=mSe(this[V8])},[Symbol(`getAbortController`)](){return this[z8](),this[U8]},[z8](){return this[U8]||=new AbortController,this[B8]||=gSe(this.method,this[H8],this.headers,this[V8],this[U8])}};[`body`,`bodyUsed`,`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`signal`,`keepalive`].forEach(e=>{Object.defineProperty(W8,e,{get(){return this[z8]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(W8,e,{value:function(){return this[z8]()[e]()}})}),Object.defineProperty(W8,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){return`Request (lightweight) ${n({method:this.method,url:this.url,headers:this.headers,nativeRequest:this[B8]},{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(W8,R8.prototype);var G8=Symbol(`responseCache`),K8=Symbol(`getResponseCache`),q8=Symbol(`cache`),J8=global.Response,Y8=class e{#e;#t;[K8](){return delete this[q8],this[G8]||=new J8(this.#e,this.#t)}constructor(t,n){let r;if(this.#e=t,n instanceof e){let e=n[G8];if(e){this.#t=e,this[K8]();return}else this.#t=n.#t,r=new Headers(n.#t.headers)}else this.#t=n;(typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(this[q8]=[n?.status||200,t,r||n?.headers])}get headers(){let e=this[q8];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":`text/plain; charset=UTF-8`})),e[2]):this[K8]().headers}get status(){return this[q8]?.[0]??this[K8]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(Y8.prototype,e,{get(){return this[K8]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(Y8.prototype,e,{value:function(){return this[K8]()[e]()}})}),Object.defineProperty(Y8.prototype,Symbol.for(`nodejs.util.inspect.custom`),{value:function(e,t,n){return`Response (lightweight) ${n({status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[G8]},{...t,depth:e==null?null:e-1})}`}}),Object.setPrototypeOf(Y8,J8),Object.setPrototypeOf(Y8.prototype,J8.prototype),global.crypto===void 0&&(global.crypto=Me),new Le,G$(()=>{}),[`[Requires: Hocuspocus server] Unified validation audit: every content problem — markdown-lint violations AND broken internal links — in one read-only call, grouped by the file to fix.`,``,"- No args → audit every in-scope `.md`/`.mdx` doc; pass `path` to scope to a folder or a single file.","- To CHECK whether links resolve, use this tool: each broken link is reported under the SOURCE doc that contains it, at the offending line. (The `links` tool is the navigation/graph reader — backlinks, forward links, orphans, hubs — not the validation surface.)",``,"Each diagnostic carries a `source` naming the validator ('markdownlint' rule violations; 'links' broken internal links), a `code` (e.g. MD010, dead-link), `message`, a 0-based LSP `range` (for links: line exact, column approximate), and `severity` ('error' | 'warning' — broken links default to warnings; the project's `validation.links` setting can raise them to errors or hide them). Only files with at least one problem are listed, plus `fileCount`/`errorCount`/`warningCount` totals. Output (text and structured) is capped at 10 files × 10 diagnostics per file, with explicit '… and N more' indicators; the counts always reflect the full scan — re-run with `path` scoped to a folder or file to see what was omitted.",``,"Read-only: nothing is modified. Auto-fix fixable lint findings with `lint({ document, fix: true })`; broken links need content edits via `edit`/`write`."].join(`
453
457
  `),[`[Requires: Hocuspocus server] Save a project-wide checkpoint of every document — a single restore point you can return to.`,``,`**Parameters:**`,'- `summary` — Optional one-line label for the checkpoint (≤80 chars). Defaults to "Checkpoint version". Appears as the checkpoint subject in `history`. Avoid secrets or PII — persisted to git history.',``,"Returns `{ version }` — the 40-char checkpoint SHA. Find checkpoints later via `history`; restore a single doc with `restore_version({ document, version })`."].join(`
454
458
  `),[`[Operates on disk; no running OK server required] Read the effective merged OpenKnowledge config (defaults → user → project).`,``,`Use this when you need to inspect the config mid-session — e.g., after a write that may have changed disk state, or to re-confirm the value of a field before reading it again.`,``,"Read returns the FULL merged config or a sub-tree when `key` is provided. There is no allowlist on reads — every field is readable.",``,"Note: the `server.*`, `mcp.*`, and `github.*` config sub-trees, plus `preview.baseUrl` and `preview.scriptSrc`, were removed; their values are now built-in constants in `@inkeep/open-knowledge-core` (or, for the preview iframe, a fixed open network policy). Reading those keys returns `exists: false`. (`appearance.preview.autoOpen` is still a live key.)",``,"This tool is a pure READ. Folder-level skill topology (link / unlink / add-root) moved to the `install` tool's `skillFolders` argument, so this one keeps its read-only annotation and stays auto-approvable.",``,`**Parameters:**`,'- `key` (optional) — Dotted config key. `"content"` returns the content sub-tree; `"appearance.theme"` returns just that leaf. Omit for full config.',"- `cwd` (optional) — Project root (see `cwd` description below)."].join(`
455
459
  `),F().optional().describe(`Dotted config key (e.g. "appearance.theme"). Omit to return the full merged config.`),F().optional().describe(v3),y3({value:R().describe(`Resolved config value at the requested path (or full config).`),exists:L().optional().describe('Whether the requested path resolved to a value. `false` distinguishes "path absent" from "path explicitly set to null". Always emitted — `true` on a full-config read.'),key:F().optional().describe(`Echo of the requested dotted key (absent when reading the full config).`)}),["[Requires: Hocuspocus server] Read GitHub-sync merge conflicts. Dispatches on `kind`:",``,'- `kind: "list"` — enumerate every doc currently tracked in a merge-conflict state. Returns `{ list: [{ file, detectedAt, ... }] }` (empty when none). The entry point to the resolve flow.','- `kind: "content"` — fetch the three merge stages for one `file`. Returns `{ content: { file, base, ours, theirs, shape, lifecycleStatus } }`. `ours` reflects the live Y.Text (what the human sees) when the doc is loaded server-side.',``,`**Parameters:**`,"- `kind` — `list` | `content`.",'- `file` — Required for `kind: "content"`. Relative path WITH the `.md`/`.mdx` extension (e.g. `notes/sso.md`) — git stages key on the exact path, so do NOT strip the extension.',``,"The `shape` field discriminates the conflict: `both-modified` (both sides edited), `delete-modify` (you deleted, they edited — `ours` empty), or `modify-delete` (you edited, they deleted — `theirs` empty). Use it to pick the `resolve_conflict` strategy."].join(`
456
- `);const _Se=[`lock`],vSe=uo([lJ,oo()]),ySe=uo([F(),I(),L(),z(R()),V(F(),R()),oo()]);V(F(),ySe).superRefine((e,t)=>{for(let[n,r]of Object.entries(e))vSe.safeParse(r).success||t.addIssue({code:`custom`,path:[n],message:`invalid frontmatter value — allowed: a scalar (string | number | boolean), a scalar array, a nested object, or an array of objects; a top-level key may be null to delete it, but nested null is not allowed`})}).describe(`Metadata as a key→value map. Values may be a scalar (string | number | boolean), a scalar array, a nested object, or an array of objects. Merge-patch: include a top-level key to set it, set a top-level key to null to delete it; keys you omit are unchanged. A nested object REPLACES the existing subtree at that key (send the full subtree you want). Example: { title: "Q3 Planning", tags: ["planning"], metadata: { version: "1.0", author: "Inkeep" } }.`),H([`append`,`prepend`,`replace`]).describe(`Where content lands. replace = overwrite the whole body (default for a new doc; required for an existing doc). append / prepend = add to the end / start.`),H(Nl).describe("File format for a NEW doc: `.md` (default) or `.mdx` (Markdown + JSX components). Honored only on create — an existing doc keeps its on-disk extension. Takes precedence over an extension typed into `path`."),H(Al).describe(`Level: "project" (default — a Project skill: lives in this KB wherever its folder is, shared with teammates via git) or "global" (a Global skill: lives under your user home, available in every project on this machine — not shared, not version-tracked). Pass the literal value "global" for a Global skill.`),["Delete one thing. Pass EXACTLY ONE of `document`, `folder`, `template`, `skill`, or `asset`.",``,"- `document` — Doc path(s) to delete (a single path or an array). Inbound links become redlinks. Irreversible. [Requires: Hocuspocus server]","- `folder` — Folder path to delete (recursive). [Requires: Hocuspocus server]",'- `template` — `{ path: "<folder>/<name>" }` — a template to delete (server-routed, attributed; auto-cleans empty `.ok/`). [Requires: Hocuspocus server]','- `skill` — `{ name }` deletes a whole SKILL; `{ name, files: ["references/x.md"] }` deletes specific bundle files (server-routed, attributed; auto-cleans empty `.ok/`). [Requires: Hocuspocus server]','- `asset` — `{ path: "<folder>/<file.ext>" }` — a binary asset to delete. [Requires: Hocuspocus server]',``,'Call `links({ kind: "backlinks", document })` BEFORE deleting a doc to see what links here.'].join(`
460
+ `);const vSe=[`lock`],ySe=uo([lJ,oo()]),bSe=uo([F(),I(),L(),z(R()),V(F(),R()),oo()]);V(F(),bSe).superRefine((e,t)=>{for(let[n,r]of Object.entries(e))ySe.safeParse(r).success||t.addIssue({code:`custom`,path:[n],message:`invalid frontmatter value — allowed: a scalar (string | number | boolean), a scalar array, a nested object, or an array of objects; a top-level key may be null to delete it, but nested null is not allowed`})}).describe(`Metadata as a key→value map. Values may be a scalar (string | number | boolean), a scalar array, a nested object, or an array of objects. Merge-patch: include a top-level key to set it, set a top-level key to null to delete it; keys you omit are unchanged. A nested object REPLACES the existing subtree at that key (send the full subtree you want). Example: { title: "Q3 Planning", tags: ["planning"], metadata: { version: "1.0", author: "Inkeep" } }.`),H([`append`,`prepend`,`replace`]).describe(`Where content lands. replace = overwrite the whole body (default for a new doc; required for an existing doc). append / prepend = add to the end / start.`),H(Nl).describe("File format for a NEW doc: `.md` (default) or `.mdx` (Markdown + JSX components). Honored only on create — an existing doc keeps its on-disk extension. Takes precedence over an extension typed into `path`."),H(Al).describe(`Level: "project" (default — a Project skill: lives in this KB wherever its folder is, shared with teammates via git) or "global" (a Global skill: lives under your user home, available in every project on this machine — not shared, not version-tracked). Pass the literal value "global" for a Global skill.`),["Delete one thing. Pass EXACTLY ONE of `document`, `folder`, `template`, `skill`, or `asset`.",``,"- `document` — Doc path(s) to delete (a single path or an array). Inbound links become redlinks. Irreversible. [Requires: Hocuspocus server]","- `folder` — Folder path to delete (recursive). [Requires: Hocuspocus server]",'- `template` — `{ path: "<folder>/<name>" }` — a template to delete (server-routed, attributed; auto-cleans empty `.ok/`). [Requires: Hocuspocus server]','- `skill` — `{ name }` deletes a whole SKILL; `{ name, files: ["references/x.md"] }` deletes specific bundle files (server-routed, attributed; auto-cleans empty `.ok/`). [Requires: Hocuspocus server]','- `asset` — `{ path: "<folder>/<file.ext>" }` — a binary asset to delete. [Requires: Hocuspocus server]',``,'Call `links({ kind: "backlinks", document })` BEFORE deleting a doc to see what links here.'].join(`
457
461
  `),`${["Edit one thing in place. Pass EXACTLY ONE of `document`, `folder`, `template`, or `skill`. Within each: a body edit (`find` + `replace`) OR a metadata patch — not both in one call.",``,"- `document` — Edit a doc [Requires: Hocuspocus server]. Body: `{ path, find, replace, occurrence? }` (occurrence = which match, 1 = first). Metadata: `{ path, frontmatter }` (merge-patch; `null` deletes a key). Body find/replace is body-only; frontmatter-intersecting finds are rejected.","- `folder` — Edit a folder (folders have no body): `{ path, frontmatter }` (merge-patch).",'- `template` — Edit a template: `{ path: "<folder>/<name>", ... }`; body `find`/`replace`/`occurrence?` or metadata `frontmatter`.',"- `skill` — Edit a SKILL: `{ name, ... }`; body `find`/`replace`/`occurrence?` OR a `description` change (a skill's only metadata leaf). Every recorded copy re-syncs from the source, so there is nothing to re-install.","- `summary` — Optional one-line user-outcome (≤80 chars) recorded in the timeline for any `document`, `folder`, `template`, or `skill` edit. Avoid secrets or PII — persisted to git history.",``,'Responses may include `structuredContent.document.warnings` — advisory entries discriminated by `kind`: `content-divergence` / `disk-edit-reconciled` (write-integrity — re-read the doc with `exec("cat <path>")`) and `mermaid-parse-error` (the edit landed but that fence will not render — fix it and re-edit).'].join(`
458
462
  `)}${RJ()}`;var X8;(function(e){e.EOF=`EOF`,e.NEWLINE=`NEWLINE`,e.SEMICOLON=`SEMICOLON`,e.AMP=`AMP`,e.PIPE=`PIPE`,e.PIPE_AMP=`PIPE_AMP`,e.AND_AND=`AND_AND`,e.OR_OR=`OR_OR`,e.BANG=`BANG`,e.LESS=`LESS`,e.GREAT=`GREAT`,e.DLESS=`DLESS`,e.DGREAT=`DGREAT`,e.LESSAND=`LESSAND`,e.GREATAND=`GREATAND`,e.LESSGREAT=`LESSGREAT`,e.DLESSDASH=`DLESSDASH`,e.CLOBBER=`CLOBBER`,e.TLESS=`TLESS`,e.AND_GREAT=`AND_GREAT`,e.AND_DGREAT=`AND_DGREAT`,e.LPAREN=`LPAREN`,e.RPAREN=`RPAREN`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.DSEMI=`DSEMI`,e.SEMI_AND=`SEMI_AND`,e.SEMI_SEMI_AND=`SEMI_SEMI_AND`,e.DBRACK_START=`DBRACK_START`,e.DBRACK_END=`DBRACK_END`,e.DPAREN_START=`DPAREN_START`,e.DPAREN_END=`DPAREN_END`,e.IF=`IF`,e.THEN=`THEN`,e.ELSE=`ELSE`,e.ELIF=`ELIF`,e.FI=`FI`,e.FOR=`FOR`,e.WHILE=`WHILE`,e.UNTIL=`UNTIL`,e.DO=`DO`,e.DONE=`DONE`,e.CASE=`CASE`,e.ESAC=`ESAC`,e.IN=`IN`,e.FUNCTION=`FUNCTION`,e.SELECT=`SELECT`,e.TIME=`TIME`,e.COPROC=`COPROC`,e.WORD=`WORD`,e.NAME=`NAME`,e.NUMBER=`NUMBER`,e.ASSIGNMENT_WORD=`ASSIGNMENT_WORD`,e.FD_VARIABLE=`FD_VARIABLE`,e.COMMENT=`COMMENT`,e.HEREDOC_CONTENT=`HEREDOC_CONTENT`})(X8||={}),new Map([[`if`,X8.IF],[`then`,X8.THEN],[`else`,X8.ELSE],[`elif`,X8.ELIF],[`fi`,X8.FI],[`for`,X8.FOR],[`while`,X8.WHILE],[`until`,X8.UNTIL],[`do`,X8.DO],[`done`,X8.DONE],[`case`,X8.CASE],[`esac`,X8.ESAC],[`in`,X8.IN],[`function`,X8.FUNCTION],[`select`,X8.SELECT],[`time`,X8.TIME],[`coproc`,X8.COPROC]]),X8.SEMI_SEMI_AND,X8.TLESS,X8.AND_DGREAT,X8.DBRACK_START,X8.DBRACK_END,X8.DPAREN_START,X8.DPAREN_END,X8.AND_AND,X8.OR_OR,X8.DSEMI,X8.SEMI_AND,X8.PIPE_AMP,X8.DGREAT,X8.LESSAND,X8.GREATAND,X8.LESSGREAT,X8.CLOBBER,X8.AND_GREAT,new Map([[`|`,X8.PIPE],[`&`,X8.AMP],[`;`,X8.SEMICOLON],[`(`,X8.LPAREN],[`)`,X8.RPAREN],[`<`,X8.LESS],[`>`,X8.GREAT]]),new Set([X8.LESS,X8.GREAT,X8.DLESS,X8.DGREAT,X8.LESSAND,X8.GREATAND,X8.LESSGREAT,X8.DLESSDASH,X8.CLOBBER,X8.TLESS,X8.AND_GREAT,X8.AND_DGREAT]),new Set([X8.LESS,X8.GREAT,X8.DLESS,X8.DGREAT,X8.LESSAND,X8.GREATAND,X8.LESSGREAT,X8.DLESSDASH,X8.CLOBBER,X8.TLESS]),new Set([X8.LESS,X8.GREAT,X8.DLESS,X8.DGREAT,X8.LESSAND,X8.GREATAND,X8.LESSGREAT,X8.DLESSDASH,X8.CLOBBER,X8.TLESS,X8.AND_GREAT,X8.AND_DGREAT]),new Set([X8.AMP,X8.PIPE,X8.PIPE_AMP,X8.SEMICOLON,X8.AND_AND,X8.OR_OR,X8.DSEMI,X8.SEMI_AND,X8.SEMI_SEMI_AND]);var Z8=[{name:`echo`,load:async()=>(await import(`./echo-O45JWWI2-gk6mEMAU.mjs`)).echoCommand},{name:`cat`,load:async()=>(await import(`./cat-RDUMLXKC-D1H4LA3Z.mjs`)).catCommand},{name:`printf`,load:async()=>(await import(`./printf-CX64KX2P-B_vWcqAL.mjs`)).printfCommand},{name:`ls`,load:async()=>(await import(`./ls-KSXFZCWH-GOWXktO9.mjs`)).lsCommand},{name:`mkdir`,load:async()=>(await import(`./mkdir-TDEMSB6C-BVcgITXm.mjs`)).mkdirCommand},{name:`rmdir`,load:async()=>(await import(`./rmdir-XTQXT7RK-DZfv6Zfz.mjs`)).rmdirCommand},{name:`touch`,load:async()=>(await import(`./touch-DX2IJOQ4-CRX6GYeb.mjs`)).touchCommand},{name:`rm`,load:async()=>(await import(`./rm-RTZG23RL-sCMTtbxP.mjs`)).rmCommand},{name:`cp`,load:async()=>(await import(`./cp-XOYR4ABJ-CpnwcT2f.mjs`)).cpCommand},{name:`mv`,load:async()=>(await import(`./mv-Z6MORUFL-El0zMsEA.mjs`)).mvCommand},{name:`ln`,load:async()=>(await import(`./ln-4TRFBYAT-DGrhTL40.mjs`)).lnCommand},{name:`chmod`,load:async()=>(await import(`./chmod-SYMGL4JA-lEGJICyB.mjs`)).chmodCommand},{name:`pwd`,load:async()=>(await import(`./pwd-D4OZ7N27-NYST_A3S.mjs`)).pwdCommand},{name:`readlink`,load:async()=>(await import(`./readlink-MI4GCHJF-Dl1Uxmrf.mjs`)).readlinkCommand},{name:`head`,load:async()=>(await import(`./head-HT2B6D2J-B5ybc-my.mjs`)).headCommand},{name:`tail`,load:async()=>(await import(`./tail-S5ULNTJU-Cfa1pDQZ.mjs`)).tailCommand},{name:`wc`,load:async()=>(await import(`./wc-TQB3VNOX-DqHFY4jy.mjs`)).wcCommand},{name:`stat`,load:async()=>(await import(`./stat-BT5A227F-CEZPXJ9_.mjs`)).statCommand},{name:`grep`,load:async()=>(await import(`./grep-2HUTXO5U-9G7xEEms.mjs`)).grepCommand},{name:`fgrep`,load:async()=>(await import(`./grep-2HUTXO5U-9G7xEEms.mjs`)).fgrepCommand},{name:`egrep`,load:async()=>(await import(`./grep-2HUTXO5U-9G7xEEms.mjs`)).egrepCommand},{name:`rg`,load:async()=>(await import(`./rg-XNF3R3II-vKB7djPZ.mjs`)).rgCommand},{name:`sed`,load:async()=>(await import(`./sed-JAPPVBEU-C7wh6RxT.mjs`)).sedCommand},{name:`awk`,load:async()=>(await import(`./awk2-BBAGSFUB-ClUuupKf.mjs`)).awkCommand2},{name:`sort`,load:async()=>(await import(`./sort-DCNRDA7U-vT57Mw8o.mjs`)).sortCommand},{name:`uniq`,load:async()=>(await import(`./uniq-SUNANL47-DBRSkw7j.mjs`)).uniqCommand},{name:`comm`,load:async()=>(await import(`./comm-5SLSESQG-0igXzBnl.mjs`)).commCommand},{name:`cut`,load:async()=>(await import(`./cut-OPC3VAGB-nJAw1cEp.mjs`)).cutCommand},{name:`paste`,load:async()=>(await import(`./paste-7N6AFSDS-BnqApCW_.mjs`)).pasteCommand},{name:`tr`,load:async()=>(await import(`./tr-2HXZRDSW-ByYmbFae.mjs`)).trCommand},{name:`rev`,load:async()=>(await import(`./rev-XOSYPP45-D6eJxPKd.mjs`)).rev},{name:`nl`,load:async()=>(await import(`./nl-U5YJDM32-Y_hGSMac.mjs`)).nl},{name:`fold`,load:async()=>(await import(`./fold-LDSORVYE-Dhx0k6vg.mjs`)).fold},{name:`expand`,load:async()=>(await import(`./expand-DTNXU4LQ-D2bEx87V.mjs`)).expand},{name:`unexpand`,load:async()=>(await import(`./unexpand-RGTMIGZM-BL5sZ5_Z.mjs`)).unexpand},{name:`strings`,load:async()=>(await import(`./strings-7PLOGTPD-CiVw0Uh4.mjs`)).strings},{name:`split`,load:async()=>(await import(`./split-SITCSYCZ-Ci_IfVPT.mjs`)).split},{name:`column`,load:async()=>(await import(`./column-WLPMMSTS-Do8HgL6q.mjs`)).column},{name:`join`,load:async()=>(await import(`./join-GG2LDHE5-7k4Syl20.mjs`)).join},{name:`tee`,load:async()=>(await import(`./tee-O7VXZDCO-D95l5L5Z.mjs`)).teeCommand},{name:`find`,load:async()=>(await import(`./find-DH2ALKQS-B6bMjuwo.mjs`)).findCommand},{name:`basename`,load:async()=>(await import(`./basename-AA2KJYZQ-CEdH80GO.mjs`)).basenameCommand},{name:`dirname`,load:async()=>(await import(`./dirname-LEMTZZFS-Dg3ijqjM.mjs`)).dirnameCommand},{name:`tree`,load:async()=>(await import(`./tree-LYXBS7DC-Dq6aWetx.mjs`)).treeCommand},{name:`du`,load:async()=>(await import(`./du-WO2ENHXQ-jqWYqk_n.mjs`)).duCommand},{name:`env`,load:async()=>(await import(`./env-5EPCWSXR-BU5zTNDV.mjs`)).envCommand},{name:`printenv`,load:async()=>(await import(`./env-5EPCWSXR-BU5zTNDV.mjs`)).printenvCommand},{name:`alias`,load:async()=>(await import(`./alias-JE7RI5QX-BLuOrjl2.mjs`)).aliasCommand},{name:`unalias`,load:async()=>(await import(`./alias-JE7RI5QX-BLuOrjl2.mjs`)).unaliasCommand},{name:`history`,load:async()=>(await import(`./history-J4QRNGRO-DesXbqi2.mjs`)).historyCommand},{name:`xargs`,load:async()=>(await import(`./xargs-I6EZUCYF-C_ZtmUCd.mjs`)).xargsCommand},{name:`true`,load:async()=>(await import(`./true-WHJNXCHG-XC4ZnbBw.mjs`)).trueCommand},{name:`false`,load:async()=>(await import(`./true-WHJNXCHG-XC4ZnbBw.mjs`)).falseCommand},{name:`clear`,load:async()=>(await import(`./clear-5CZ5X4YR-9EZyt4MH.mjs`)).clearCommand},{name:`bash`,load:async()=>(await import(`./bash-IJWYRKFO-BDtU-lTC.mjs`)).bashCommand},{name:`sh`,load:async()=>(await import(`./bash-IJWYRKFO-BDtU-lTC.mjs`)).shCommand},{name:`jq`,load:async()=>(await import(`./jq-LYZFFBZB-BZ4XP29I.mjs`)).jqCommand},{name:`base64`,load:async()=>(await import(`./base64-4YMZCVJ5-CtkujsXK.mjs`)).base64Command},{name:`diff`,load:async()=>(await import(`./diff-HJF2MPDN-EjmLU95d.mjs`)).diffCommand},{name:`date`,load:async()=>(await import(`./date-DD7FVA2V-W_sbdO4n.mjs`)).dateCommand},{name:`sleep`,load:async()=>(await import(`./sleep-VZFPZFWA-CBARUnrz.mjs`)).sleepCommand},{name:`timeout`,load:async()=>(await import(`./timeout-VRKMCG72-DFU5EkCe.mjs`)).timeoutCommand},{name:`time`,load:async()=>(await import(`./time-DEUO3QV2-DwnT4FOS.mjs`)).timeCommand},{name:`seq`,load:async()=>(await import(`./seq-RN5ZUASB-R5HjEVux.mjs`)).seqCommand},{name:`expr`,load:async()=>(await import(`./expr-YYCVMXE3-wI0boF3e.mjs`)).exprCommand},{name:`md5sum`,load:async()=>(await import(`./md5sum-INMIK4DX-BlgGpdCD.mjs`)).md5sumCommand},{name:`sha1sum`,load:async()=>(await import(`./sha1sum-VJPNLNU6-DfzpfxJ-.mjs`)).sha1sumCommand},{name:`sha256sum`,load:async()=>(await import(`./sha256sum-PI32XWXY-DrKtnAPK.mjs`)).sha256sumCommand},{name:`file`,load:async()=>(await import(`./file-IGDTDPLG-DkYMcmTl.mjs`)).fileCommand},{name:`html-to-markdown`,load:async()=>(await import(`./html-to-markdown-TFCECAGV-DLUGt6pW.mjs`)).htmlToMarkdownCommand},{name:`help`,load:async()=>(await import(`./help-VVWX7SA5-Bb8T3djf.mjs`)).helpCommand},{name:`which`,load:async()=>(await import(`./which-XZHEH76L-CbmRVw8E.mjs`)).whichCommand},{name:`tac`,load:async()=>(await import(`./tac-SJGXQ4T2-BL4Xd7y6.mjs`)).tac},{name:`hostname`,load:async()=>(await import(`./hostname-BK6HG2DE-DTiGP5th.mjs`)).hostname},{name:`whoami`,load:async()=>(await import(`./whoami-DGKU3D2X-BDJh39KM.mjs`)).whoami},{name:`od`,load:async()=>(await import(`./od-VJEF2UR5-CueTpZ68.mjs`)).od},{name:`gzip`,load:async()=>(await import(`./gzip-AQXSGOVS-BcGYw5wM.mjs`)).gzipCommand},{name:`gunzip`,load:async()=>(await import(`./gzip-AQXSGOVS-BcGYw5wM.mjs`)).gunzipCommand},{name:`zcat`,load:async()=>(await import(`./gzip-AQXSGOVS-BcGYw5wM.mjs`)).zcatCommand}];(typeof __BROWSER__>`u`||!__BROWSER__)&&(Z8.push({name:`tar`,load:async()=>(await import(`./tar-MZQD7NO4-HJsWmzu9.mjs`)).tarCommand}),Z8.push({name:`yq`,load:async()=>(await import(`./yq-OAKYHSXH-COzSqY4J.mjs`)).yqCommand}),Z8.push({name:`xan`,load:async()=>(await import(`./xan-UD7JYIL2-DQo9f-1a.mjs`)).xanCommand}),Z8.push({name:`sqlite3`,load:async()=>(await import(`./sqlite3-TE5AIOTF-BhXSdz7U.mjs`)).sqlite3Command}));var Q8=[];(typeof __BROWSER__>`u`||!__BROWSER__)&&(Q8.push({name:`python3`,load:async()=>(await import(`./python3-DNGS4G3E-DaBJervu.mjs`)).python3Command}),Q8.push({name:`python`,load:async()=>(await import(`./python3-DNGS4G3E-DaBJervu.mjs`)).pythonCommand}));var $8=[];(typeof __BROWSER__>`u`||!__BROWSER__)&&($8.push({name:`js-exec`,load:async()=>(await import(`./js-exec-VXN6TZ7U-Ds5SsewK.mjs`)).jsExecCommand}),$8.push({name:`node`,load:async()=>(await import(`./js-exec-VXN6TZ7U-Ds5SsewK.mjs`)).nodeStubCommand})),new TextEncoder,Object.freeze({stdout:``,stderr:``,exitCode:0}),[...new Map([[`:`,[`: [arguments]`,`Null command.
459
463
  No effect; the command does nothing.
@@ -802,10 +806,10 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
802
806
  job specification, and reports its termination status.
803
807
  Exit Status:
804
808
  Returns the status of the last ID; fails if ID is invalid or an invalid
805
- option is given.`]]]).keys()].sort(),new TextDecoder(`utf-8`,{fatal:!0});var bSe=i(((e,t)=>{var n=[`||`,`&&`,`;;`,`|&`,`<(`,`<<<`,`>>`,`>&`,`<&`,`&`,`;`,`(`,`)`,`|`,`<`,`>`],r=/[\n\r\u2028\u2029]/,i=/[\s#!"$&'():;<=>@\\^`|]/g;t.exports=function(e){return e.map(function(e){if(e===``)return`''`;if(e&&typeof e==`object`){if(`op`in e&&e.op===`glob`){if(typeof e.pattern!=`string`)throw TypeError("glob token requires a string `pattern`");if(r.test(e.pattern))throw TypeError("glob `pattern` must not contain line terminators");return e.pattern.replace(i,`\\$&`)}if(`op`in e&&typeof e.op==`string`){if(n.indexOf(e.op)<0)throw TypeError("invalid `op` value: "+JSON.stringify(e.op));return e.op.replace(/[\s\S]/g,`\\$&`)}if(`comment`in e&&typeof e.comment==`string`){if(r.test(e.comment))throw TypeError("`comment` must not contain line terminators");return`#`+e.comment}throw TypeError(`unrecognized object token shape`)}return/["\s\\]/.test(e)&&!/'/.test(e)?`'`+e.replace(/(['])/g,`\\$1`)+`'`:/["'\s]/.test(e)?`"`+e.replace(/(["\\$`!])/g,`\\$1`)+`"`:String(e).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}~])/g,`$1\\$2`)}).join(` `)}})),xSe=i(((e,t)=>{for(var n=`(?:`+[`\\|\\|`,`\\&\\&`,`;;`,`\\|\\&`,`\\<\\(`,`\\<\\<\\<`,`>>`,`>\\&`,`<\\&`,`[&;()|<>]`].join(`|`)+`)`,r=RegExp(`^`+n+`$`),i=`|&;()<> \\t`,a=`'([^']*?)'`,o=`"((\\\\"|[^"])*?)"`,s=/^#$/,c=`'`,l=`"`,u=`$`,d=``,f=4294967296,p=0;p<4;p++)d+=(f*Math.random()).toString(16);var m=RegExp(`^`+d);function h(e,t){for(var n=t.lastIndex,r=[],i;i=t.exec(e);)r[r.length]=i,t.lastIndex===i.index&&(t.lastIndex+=1);return t.lastIndex=n,r}function g(e,t,n){var r=typeof e==`function`?e(n):e[n];return r===void 0&&n!=``?r=``:r===void 0&&(r=`$`),typeof r==`object`?t+d+JSON.stringify(r)+d:t+r}function _(e,t,d){d||={};var f=d.escape||`\\`,p=d.splitUnquoted===!0?`
809
+ option is given.`]]]).keys()].sort(),new TextDecoder(`utf-8`,{fatal:!0});var xSe=i(((e,t)=>{var n=[`||`,`&&`,`;;`,`|&`,`<(`,`<<<`,`>>`,`>&`,`<&`,`&`,`;`,`(`,`)`,`|`,`<`,`>`],r=/[\n\r\u2028\u2029]/,i=/[\s#!"$&'():;<=>@\\^`|]/g;t.exports=function(e){return e.map(function(e){if(e===``)return`''`;if(e&&typeof e==`object`){if(`op`in e&&e.op===`glob`){if(typeof e.pattern!=`string`)throw TypeError("glob token requires a string `pattern`");if(r.test(e.pattern))throw TypeError("glob `pattern` must not contain line terminators");return e.pattern.replace(i,`\\$&`)}if(`op`in e&&typeof e.op==`string`){if(n.indexOf(e.op)<0)throw TypeError("invalid `op` value: "+JSON.stringify(e.op));return e.op.replace(/[\s\S]/g,`\\$&`)}if(`comment`in e&&typeof e.comment==`string`){if(r.test(e.comment))throw TypeError("`comment` must not contain line terminators");return`#`+e.comment}throw TypeError(`unrecognized object token shape`)}return/["\s\\]/.test(e)&&!/'/.test(e)?`'`+e.replace(/(['])/g,`\\$1`)+`'`:/["'\s]/.test(e)?`"`+e.replace(/(["\\$`!])/g,`\\$1`)+`"`:String(e).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}~])/g,`$1\\$2`)}).join(` `)}})),SSe=i(((e,t)=>{for(var n=`(?:`+[`\\|\\|`,`\\&\\&`,`;;`,`\\|\\&`,`\\<\\(`,`\\<\\<\\<`,`>>`,`>\\&`,`<\\&`,`[&;()|<>]`].join(`|`)+`)`,r=RegExp(`^`+n+`$`),i=`|&;()<> \\t`,a=`'([^']*?)'`,o=`"((\\\\"|[^"])*?)"`,s=/^#$/,c=`'`,l=`"`,u=`$`,d=``,f=4294967296,p=0;p<4;p++)d+=(f*Math.random()).toString(16);var m=RegExp(`^`+d);function h(e,t){for(var n=t.lastIndex,r=[],i;i=t.exec(e);)r[r.length]=i,t.lastIndex===i.index&&(t.lastIndex+=1);return t.lastIndex=n,r}function g(e,t,n){var r=typeof e==`function`?e(n):e[n];return r===void 0&&n!=``?r=``:r===void 0&&(r=`$`),typeof r==`object`?t+d+JSON.stringify(r)+d:t+r}function _(e,t,d){d||={};var f=d.escape||`\\`,p=d.splitUnquoted===!0?`
806
810
  `:typeof d.splitUnquoted==`string`?d.splitUnquoted:``,m=`(\\`+f+`['"`+i+`]|[^\\s'"`+i+`])+`,_=h(e,new RegExp([`(`+n+`)`,`(`+m+`|`+o+`|`+a+`)+`].join(`|`),`g`));if(_.length===0)return[];t||={};var v=!1;return _.map(function(n){var i=n[0];if(!i||v)return;if(r.test(i))return{op:i};var a=!1,o=!1,d=``,m=[],h=!1,_=null,y=!1,b;function x(){b+=1;var e,n,r=i.charAt(b);if(r===`{`){if(b+=1,i.charAt(b)===`}`)throw Error(`Bad substitution: `+i.slice(b-2,b+1));var a=1;for(e=b;a>0&&e<i.length;)i.charAt(e)===`{`&&i.charAt(e-1)===`$`?a+=1:i.charAt(e)===`}`&&--a,e+=1;if(a!==0)throw Error(`Bad substitution: `+i.slice(b));--e,n=i.slice(b,e),b=e}else if(/[*@#?$!_-]/.test(r))n=r,b+=1;else{var o=i.slice(b);e=o.match(/[^\w\d_]/),e?(n=o.slice(0,e.index),b+=e.index-1):(n=o,b=i.length)}return g(t,``,n)}function S(){if(_!==null){if(_===0)d!==``&&(m[m.length]=d,d=``);else{m[m.length]=d,d=``;for(var e=1;e<_;e+=1)m[m.length]=``}_=null}}for(b=0;b<i.length;b++){var C=i.charAt(b);if(p&&C!==u&&S(),y||=!a&&(C===`*`||C===`?`),o)d+=C,o=!1;else if(a)C===a?a=!1:a==c?d+=C:C===f?(b+=1,C=i.charAt(b),C===l||C===f||C===u?d+=C:d+=f+C):C===u?d+=x():d+=C;else if(C===l||C===c)a=C,h=!0;else if(r.test(C))return{op:i};else if(s.test(C)){v=!0;var w={comment:e.slice(n.index+b+1)};return d.length?[d,w]:[w]}else if(C===f)o=!0;else if(C===u){var T=x();if(!p)d+=T;else for(var E=0;E<T.length;E+=1){var D=T.charAt(E);p.indexOf(D)<0?(S(),d+=D):_===null?_=D===` `||D===` `||D===`
807
811
  `?0:1:D!==` `&&D!==` `&&D!==`
808
- `&&(_+=1)}}else d+=C}if(y)return{op:`glob`,pattern:d};if(p){if(_!==null&&_>0){m[m.length]=d,d=``;for(var O=1;O<_;O+=1)m[m.length]=``}return(d!==``||h&&m.length===0)&&(m[m.length]=d),m}return d}).reduce(function(e,t){return t===void 0||[].concat(t).forEach(function(t){e[e.length]=t}),e},[])}t.exports=function(e,t,n){var r=_(e,t,n);return typeof t==`function`?r.reduce(function(e,t){if(typeof t==`object`)return e[e.length]=t,e;var n=t.split(RegExp(`(`+d+`.*?`+d+`)`,`g`));return n.length===1?(e[e.length]=n[0],e):(n.filter(Boolean).forEach(function(t){e[e.length]=m.test(t)?JSON.parse(t.split(d)[1]):t}),e)},[]):r}}));i((e=>{e.quote=bSe(),e.parse=xSe()}))(),["**STOP — when the project has `.ok/`, do NOT use native `Read`/`Grep`/`Glob` on in-scope `.md`/`.mdx`; use `exec` (this tool).** Native tools skip the frontmatter, backlinks, unresolved comments, shadow-repo activity, and git history `exec` returns per wiki file. Reserve native tools for source code, non-markdown, and projects without `.ok/`. (Full rule + escape hatch: the `open-knowledge` skill.)",``,`Run a read-only bash-like command against the project content directory. Returns raw stdout plus enriched metadata for every wiki file referenced (frontmatter, backlink/forward-link counts, shadow-repo activity with agent/human attribution).`,``,"`⚠ N unresolved comment(s)` = open human review requests — factor in before editing, and report them.",``,"Allowlist: cat, ls, grep, find, head, tail, wc, sort, uniq, cut. One command or a pipe (|) per call — NOT a shell: `&&`, `;`, redirections, subshells, and writes are rejected. To do several things, make separate exec calls or pass multiple paths to one command (e.g. `ls -A a b c`, `cat a b c`).",``,"cwd: the command runs in the explicit absolute `cwd` you pass, or in the MCP client's only advertised root when there is exactly one. If the client has zero or multiple roots, pass `cwd` explicitly. Paths inside the command resolve relative to that cwd; traversal above it is rejected.",``,"Stdout provenance headers (GNU-style): `ls <dir>/` prepends `<dir>/:`, single-file `cat`/`head`/`tail` prepends `==> <path> <==`, so the subject of the command is visible in raw output. Multi-file `cat a b` emits no header — the `enrichedPaths` array still lists every file. `head`/`tail` used as pipe trimmers (no file arg) defer to the upstream producer.",``,`Examples:`,'- `exec({ command: "cat articles/auth.md" })` — file contents + full enrichment','- `exec({ command: "ls articles/" })` — listing + per-file enrichment (slim)','- `exec({ command: "grep -rn oauth articles/ | head -5" })` — pipe with enrichment on matched files','- `exec({ command: "ls", cwd: "/abs/path/to/other-repo" })` — run in a different project'].join(`
812
+ `&&(_+=1)}}else d+=C}if(y)return{op:`glob`,pattern:d};if(p){if(_!==null&&_>0){m[m.length]=d,d=``;for(var O=1;O<_;O+=1)m[m.length]=``}return(d!==``||h&&m.length===0)&&(m[m.length]=d),m}return d}).reduce(function(e,t){return t===void 0||[].concat(t).forEach(function(t){e[e.length]=t}),e},[])}t.exports=function(e,t,n){var r=_(e,t,n);return typeof t==`function`?r.reduce(function(e,t){if(typeof t==`object`)return e[e.length]=t,e;var n=t.split(RegExp(`(`+d+`.*?`+d+`)`,`g`));return n.length===1?(e[e.length]=n[0],e):(n.filter(Boolean).forEach(function(t){e[e.length]=m.test(t)?JSON.parse(t.split(d)[1]):t}),e)},[]):r}}));i((e=>{e.quote=xSe(),e.parse=SSe()}))(),["**STOP — when the project has `.ok/`, do NOT use native `Read`/`Grep`/`Glob` on in-scope `.md`/`.mdx`; use `exec` (this tool).** Native tools skip the frontmatter, backlinks, unresolved comments, shadow-repo activity, and git history `exec` returns per wiki file. Reserve native tools for source code, non-markdown, and projects without `.ok/`. (Full rule + escape hatch: the `open-knowledge` skill.)",``,`Run a read-only bash-like command against the project content directory. Returns raw stdout plus enriched metadata for every wiki file referenced (frontmatter, backlink/forward-link counts, shadow-repo activity with agent/human attribution).`,``,"`⚠ N unresolved comment(s)` = open human review requests — factor in before editing, and report them.",``,"Allowlist: cat, ls, grep, find, head, tail, wc, sort, uniq, cut. One command or a pipe (|) per call — NOT a shell: `&&`, `;`, redirections, subshells, and writes are rejected. To do several things, make separate exec calls or pass multiple paths to one command (e.g. `ls -A a b c`, `cat a b c`).",``,"cwd: the command runs in the explicit absolute `cwd` you pass, or in the MCP client's only advertised root when there is exactly one. If the client has zero or multiple roots, pass `cwd` explicitly. Paths inside the command resolve relative to that cwd; traversal above it is rejected.",``,"Stdout provenance headers (GNU-style): `ls <dir>/` prepends `<dir>/:`, single-file `cat`/`head`/`tail` prepends `==> <path> <==`, so the subject of the command is visible in raw output. Multi-file `cat a b` emits no header — the `enrichedPaths` array still lists every file. `head`/`tail` used as pipe trimmers (no file arg) defer to the upstream producer.",``,`Examples:`,'- `exec({ command: "cat articles/auth.md" })` — file contents + full enrichment','- `exec({ command: "ls articles/" })` — listing + per-file enrichment (slim)','- `exec({ command: "grep -rn oauth articles/ | head -5" })` — pipe with enrichment on matched files','- `exec({ command: "ls", cwd: "/abs/path/to/other-repo" })` — run in a different project'].join(`
809
813
  `),["Resolve the browser-reachable preview URL for an OpenKnowledge project (optionally for a specific doc). Opening a preview counts as demand: when no OK server is running for the project, this call auto-starts one (same `OK_MCP_AUTOSTART` gate and spawn timeout as the read/write tools) and waits briefly for the preview UI to bind — a cold first call can take a few seconds; calls against a running system answer immediately.",``,"Per-response `previewUrl` fields on read/write tools are ROUTE-ONLY (`/#/<doc>`, no host:port) — they identify which doc to preview, not a URL to open by itself. Call this tool to get the full, openable URL.",``,"This is THE way to open a doc OR a loose file in a browser, and the only way to force a browser when the OK Desktop app is installed (the `ok open` CLI prefers Desktop). Use it when YOUR host opens the URL itself: navigate your in-app / embedded browser to the returned `url`, or — only on a stdio host with no browser tool — `open` it in the system browser. Do not hunt for the URL via `ok ps`/`ok status` or by guessing a port — this tool returns it. Claude Code Desktop opens its in-app Browser pane with `preview_start({url})` then `navigate({url})` to move; a pure stdio CLI with no browser uses `ok open <doc>` to open in the OK Desktop app.",``,"If you are running INSIDE an OpenKnowledge surface — the desktop app’s built-in terminal or its in-app agent panel — the response leads with an `ok open …` steer and returns it as `okOpenCommand`. Run that instead: the user is already looking at the app, so a localhost URL in your reply is noise at best and a dead link at worst. Never paste `url` into your answer in that case.",``,"Returns `{ url: null, baseUrl: null, running: false, autoOpen }` + a recovery hint only when no UI could be reached (auto-start disabled via `OK_MCP_AUTOSTART=0`, no spawn authority in this registration, or the UI did not bind in time) — the hint names the right command for the actual state.",``,"To open a single markdown file that may live OUTSIDE any Open Knowledge project (a loose file, or a doc in a different git worktree), pass `file` with an absolute path: the tool finds the running session whose content directory contains it and returns that session’s URL, then navigate your in-app browser there. `document`/`folder` are for a doc in the current project; `file` is the out-of-project form.",``,`**Parameters:**`,"- `document` (optional) — Extension-less doc path in the current project (e.g. `specs/foo/SPEC`). Omit for the UI root URL.","- `folder` (optional) — Folder path in the current project (e.g. `specs/foo`); returns the `…/#/<folder>/` route. Mutually exclusive with `document`.","- `skill` (optional) — A skill to open in the editor: `{ name, scope? }` (scope `project` default). Returns the `…/#/__skill__/<scope>/<name>` route. Mutually exclusive with `document`/`folder`/`file`.","- `file` (optional) — Absolute path to a single markdown file, including one outside any project. Resolves to the running single-file / worktree session serving it. Mutually exclusive with `document`/`folder`/`skill`; `cwd` is ignored when set.","- `cwd` (optional) — Project root (see `cwd` description below)."].join(`
810
814
  `),F().optional().describe(`Extension-less doc path to resolve a preview URL for (e.g. "specs/foo/SPEC"). Omit to get the UI root URL.`),F().min(1).optional().describe('Folder path to resolve a folder-route preview URL for (e.g. "specs/foo"); returns the `…/#/<folder>/` route. Mutually exclusive with `document`.'),B({name:F().min(1).regex(IY,`Skill name must be lowercase letters, digits, and hyphens only.`).describe(`Skill name (the bundle-dir identity, wherever the skill lives).`),scope:H(Al).optional().describe("Skill scope; defaults to `project`.")}).optional().describe("Skill to resolve an editor preview URL for; returns the `…/#/__skill__/<scope>/<name>` route. Mutually exclusive with `document`/`folder`/`file`."),F().optional().describe("Absolute path to a single markdown file to open, including one OUTSIDE any Open Knowledge project. Resolves to the running single-file (or worktree) session whose content directory contains it and returns that session’s `url`. Mutually exclusive with `document` / `folder` / `skill`. When `file` is set, `cwd` is ignored."),F().optional().describe(v3),y3({url:F().nullable().describe("Browser-reachable URL — the UI base joined with the doc route when `document` is given, else the UI root. `null` when no UI is running."),baseUrl:F().nullable().describe("Browser-reachable origin of the running UI (e.g. `http://localhost:5173`). `null` when no UI is running."),running:L().describe(`Whether a UI is running for the project.`),autoOpen:L().describe("User-scoped preview-auto-open preference (`appearance.preview.autoOpen`). When `true`, the agent should route the preview using capability-based routing (in-app browser if available, system browser as fallback). When `false`, the user is managing their own preview view (OK Desktop window, a browser tab they opened, etc.) — the agent must NOT open or refresh any preview UI, and should surface this URL only on direct user ask. Resolved fresh on every call; defaults to `true`."),okOpenCommand:F().nullable().optional().describe("Machine-readable form of the hosted-agent steer: when the calling agent runs inside an OpenKnowledge surface (the desktop app’s built-in terminal, or its in-app agent panel) AND a doc/folder/skill target was given, the exact `ok open …` command to run to bring it up for the user. Run it INSTEAD of navigating `url`, and do not paste `url` into your reply — the user is already in the app it points at. `null`/absent in every other context (navigate `url` per your host instead).")}),B({version:F().describe("40-char commit SHA for this entry — pass to `restore_version({ document, version })`."),timestamp:F().describe(`ISO timestamp of the entry.`),author:F().describe(`Author display name.`),authorEmail:F().describe(`Author email.`),kind:H([`checkpoint`,`wip`,`upstream`]).describe(`Entry kind: checkpoint / wip / upstream.`),message:F().describe(`Commit subject (the checkpoint summary, when one was set).`),contributors:vye.describe(`Per-contributor records parsed from the commit (writer id, name, docs, summaries).`),checkpoint:R().nullable().describe(`Checkpoint metadata when this entry is a checkpoint, else null.`)}),[`[Requires: Hocuspocus server] List version history for a document, or the activity timeline for a folder.`,`Returns timeline entries from the shadow repo, sorted by timestamp descending.`,"Each entry carries a `version` (40-char commit SHA) you pass straight to `restore_version({ document, version })` — same field name on both sides.",``,"**Parameters (pass EXACTLY ONE of `document` / `folder` / `skill`):**","- `document` — Document name to query history for, typically without extension. A trailing `.md` or `.mdx` is stripped automatically.",'- `folder` — Folder path for the FOLDER timeline: attributed activity over the folder\'s `.ok/` artifacts (templates + frontmatter) — who created / edited / renamed / moved / deleted them, when. `""` = project root.',"- `skill` — Skill NAME to query version history for (the skill folder's attributed versions). PROJECT-scope skills only — global skills are unversioned. Pass an entry's `version` to `restore_version({ skill, version })`.","- `branch` (optional) — Branch name (default: current branch)","- `limit` (optional) — Maximum entries to return (default 50, max 200)","- `offset` (optional) — Number of entries to skip for pagination (default 0)",'- `kind` (optional) — Filter by entry type: "checkpoint", "upstream", or "wip"',"- `author` (optional) — Filter to entries by this author name or email","- `excludeAuthor` (optional) — Exclude entries by this author name or email"].join(`
811
815
  `),[`[Requires: Hocuspocus server] Import a skill into this project as versioned content.`,``,"Fetches an agentskills.io / skills.sh skill-dir from a `source` and writes it into the vendor-neutral `.agents/skills/<name>/` hub — where it gains history, search, attribution, and cross-harness projection (via `install`) for free. Provenance (source, commit, content hash, publisher) is recorded in `.ok/skills-lock.json`. Scripts are imported as content and are NEVER executed. `add` says where it goes — an import always places the skill somewhere, so `install` afterwards is only for changing WHERE it lives (add/remove/convert/source).",``,`**Parameters:**`,"- `source` — paste the full skills.sh skill-page URL (`https://www.skills.sh/<owner>/<repo>/<skill>`, or `https://www.skills.sh/site/<hostname>/<skill>` for a website catalog), or pass `owner/repo[/subpath]` (GitHub), a git URL, or a local / `file://` path.","- `skill` — Pick ONE skill when the source bundles several.","- `scope` — `project` (default, versioned + shared) or `global` (user-global, unversioned).",``,"On a name collision with an existing skill the import lands under `<name>-imported` (never overwrites). An identical re-import (same content hash) is a no-op."].join(`
@@ -817,20 +821,20 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
817
821
  `),z(F().min(1)).max(32).optional().describe("Canonical ids to expand to full JSX-form detail (max 32, case-sensitive). Returns `componentDetails` + `notFound`."),F().optional().describe(v3),y3({version:U(1).describe(`Schema version stamp — bump for breaking shape changes.`),components:z(B({id:F(),displayName:F(),description:F(),authoring:H([`markdown`,`jsx`]).describe("`markdown` — write the markdown-native form OK auto-promotes; `jsx` — write the JSX tag directly (no markdown-native form exists)."),example:F().describe(`Copy-ready source for the authoring form.`),guidance:F().describe(`One line on when / how to use this construct.`)})).describe(`Canonical authoring constructs, keyed by the form an agent should write.`),embedPatterns:z(B({id:F(),title:F(),description:F(),snippet:F().describe("A complete, theme-wired ```html preview fenced block.")})).describe("Copy-ready themed `html preview` starters."),tokens:z(B({name:F().describe("CSS custom-property name, e.g. `--chart-1`."),light:F(),dark:F()})).describe("Theme tokens injected into every preview iframe — reference with `var(--name)`."),componentDetails:z(V(F(),R())).optional().describe("Full JSX-form prop schema for the requested `components` ids (when provided)."),notFound:z(F()).optional().describe("Requested `components` ids that did not match any canonical.")}),[`[Requires: Hocuspocus server] Resolve a tracked merge conflict by writing the chosen content to disk and committing.`,``,`Strategy:`,"- `mine` — runs `git checkout --ours -- <file>` then `git add` (your committed ours stage, stage 2). Fails on delete-modify (DU) conflicts where stage 2 is missing — use `delete` instead.","- `theirs` — runs `git checkout --theirs -- <file>` then `git add` (their committed stage 3). Fails on modify-delete (UD) conflicts where stage 3 is missing — use `delete` instead.",'- `content` — writes the provided `content` argument (e.g. a per-hunk merged result, or the live Y.Text bytes the user sees in the DiffView). The provided string must be non-empty — use `delete` to remove the file entirely (an agent constructing a per-hunk merge that happens to land on `""` gets a 400 at the Zod boundary rather than a misleading 500).','- `delete` — runs `git rm <file>` then commits the deletion. Honors deletion intent for delete-modify (DU: "keep deletion") and modify-delete (UD: "accept their deletion") shapes. Inspect the `shape` field on `conflicts({ kind: "content" })` to pick the right strategy for the conflict shape.',``,'Returns 200 on success; 500 indicates commit failure (re-call `conflicts({ kind: "list" })` to confirm post-state — the resolve API is best-effort, non-atomic, and the file may have been resolved by another session).',``,`**DESTRUCTIVE:** this modifies the working tree and creates a git commit.`,``,`**Parameters:**`,"- `file` — Relative-to-projectDir path WITH .md extension (e.g. `notes/sso.md`).","- `strategy` — One of `mine` | `theirs` | `content` | `delete`.",'- `content` — Required (non-empty) when `strategy === "content"`; ignored otherwise.'].join(`
818
822
  `),y3({ok:L(),file:F()}),["[Requires: Hocuspocus server] Restore a DOCUMENT (CRDT, append-only) or a SKILL (fs-direct) to a historical version. Pass EXACTLY ONE of `document` or `skill`.",``,`**Parameters:**`,"- `document` — The document to restore (path, no extension; trailing `.md`/`.mdx` is stripped). Append-only via the CRDT layer; all connected editors see the change live.","- `skill` — The skill NAME to restore (PROJECT-scope skills only — global skills are unversioned). Rewrites the skill folder to the target version (fs-direct); every recorded copy re-syncs from it, so there is nothing to re-install.","- `version` — The 40-character commit SHA to restore to. Copy it from the `history` tool (same field name there).","- `summary` — Optional one-line summary (≤80 chars). Avoid secrets or PII — persisted to git history.",``,'A response may include `structuredContent.warnings` (kind `content-divergence`) when the restored `Y.Text` does not byte-match the target-version bytes. The restore still landed; re-read the doc with `exec("cat <document>")` to see what converged.'].join(`
819
823
  `),["[Requires: Hocuspocus server] Ranked retrieval across ALL non-ignored files (markdown by title/body, other file types by name/path, plus folders) — pair with `exec` `grep` for exhaustive content search. The cmd-K engine (title boost + body BM25 + recency).",``,"NAMES/paths are indexed for all files; BODY content for markdown only. Two-tier agent model: run this fast indexed `search` (all files by name/path + markdown content) IN PARALLEL with `exec` (`grep`) for exhaustive literal-string content search across every file — instant ranked hits plus full content coverage. Reach for `exec` grep when you need to match content inside code/config/data files.",``,"When semantic search is enabled for the workspace (an opt-in setting with an API key), an embeddings signal is additionally fused into `full_text` ranking, surfacing conceptually-related pages that share no keywords. This tool opts in by default; the `semantic` block in the response reports coverage. Note: with semantic enabled, the query and matching page content are sent to the configured embeddings provider (content egress). Set `semantic: false` to force pure-lexical ranking for a call.",``,"Returns scored `page`, `folder`, and name-only `file` hits, each with a `signals` breakdown (lexical / fullText / recency / vector); markdown `page` hits also carry a body snippet (`file` hits never do — name-only).",``,'Cold start: right after the server boots, the response may carry `ready: false` with an empty `results` while the index is still building. That empty set is NOT authoritative — wait ~2-3 seconds, then retry (agents have no built-in delay, so do not retry in immediate succession). If it is still `ready: false` after 2-3 retries (e.g. a very large workspace), fall back to `exec("grep ...")` rather than polling further. Once `ready` is true/omitted the results are complete.',``,`**Parameters:**`,"- `query` — Free-form; tokenized across title, name, path segments, and (with `full_text`) body.","- `intent` (optional) — `omnibar` searches title/path/folders only (fast); `full_text` includes body. Default `full_text`.","- `scopes` (optional) — Result scope: `page` | `folder` | `file` | `content`. Defaults derive from `intent`.","- `limit` (optional) — Max rows; default 20, max 100.","- `semantic` (optional) — Set `false` to force pure-lexical ranking even when semantic search is enabled. Omit to use semantic when available.",``,'If the server is down, the tool returns a recovery hint — use `exec("grep ...")` as the server-free fallback.'].join(`
820
- `),F().describe(`Search query — title, path, or body terms.`),H([`omnibar`,`full_text`]).optional().describe(`'omnibar' for title/path/folder only (fast); 'full_text' includes body content. Default 'full_text'.`),z(H([`page`,`folder`,`content`,`file`])).optional().describe(`Override the default scope set. Members: 'page', 'folder', 'file', 'content'. Defaults derive from intent.`),I().int().min(1).max(100).optional().describe(`Max rows; default 20, max 100.`),L().optional().describe(`Set false to force pure-lexical ranking for this call even when semantic search is enabled. Omit to use semantic when available.`),F().optional().describe(v3);const SSe=B({kind:H([`page`,`folder`,`file`]),path:F(),docName:F(),title:F().nullable(),score:I(),signals:B({lexical:I(),fullText:I(),recency:I(),vector:I().optional()}),snippet:F().optional(),previewUrl:F().nullable(),previewUrlSource:H(_Se).optional()}),CSe=B({capable:L(),applied:L(),coverage:B({embedded:I().int(),total:I().int()})});y3({cwd:F(),query:F(),intent:F(),resultCount:I().int(),results:z(SSe),elapsedMs:I().nullable(),semantic:CSe.optional(),ready:U(!1).optional()}),["[Requires: Hocuspocus server] Build a shareable GitHub-substrate URL (`https://openknowledge.ai/d/...`) pinned to the project's current branch + the focused target (a doc or a folder). Read-only against the working tree — no commits, no pushes, no `git fetch`.",``,`Use this when the user asks for a share link / shareable link / URL to send to a teammate. Recipients open the link to receive the doc (or folder subtree) into their own OpenKnowledge install.`,``,"**Publishing is a user act.** Agents do NOT publish projects to GitHub from this tool. When the project has no GitHub remote, this tool returns an error pointing the user at the Share wizard (or `gh repo create` + `git push`) — it does not run those steps itself.",``,`**Parameters:**`,'- `path` — Content-dir-relative target. For a doc, extension-less (trailing `.md`/`.mdx` is stripped; the on-disk file is probed automatically). For a folder, the directory path. The empty string `""` is the content-root sentinel (folder-only).',"- `kind` (optional) — `'doc'` or `'folder'`. Omit to auto-probe disk (`.mdx` → `.md` → directory, first hit wins). REQUIRED when `path` is empty (`\"\"`), since auto-probe cannot disambiguate the root.","- `cwd` (optional) — Project root (see `cwd` description below).",``,"**Preconditions:** project on a named branch (not detached HEAD); origin set to a GitHub remote (`github.com` or a GitHub Enterprise Server host); the branch already pushed to origin."].join(`
821
- `),y3({ok:L().describe(`Success discriminator.`),shareUrl:F().optional().describe(`Marketing share URL (success only).`),sharedUrl:F().optional().describe(`Unencoded GitHub blob/tree URL (success only).`),branch:F().optional().describe(`Branch the share URL pins to (success only).`),resolvedKind:H([`doc`,`folder`]).optional().describe(`Kind the target resolved to (success only).`),freshness:ow.optional().describe(`Whether the shared target matches origin (success only): current, stale (unpushed edits), absent (not on origin, a push fixes it), or empty (a folder holding nothing git can track, which no push fixes). Omitted when the probe could not run.`),error:H([...aw.options,`target-not-found`,`kind-mismatch`,`unknown`]).optional().describe(`Failure code (error path only).`),message:F().optional().describe(`Agent-actionable error message (error path only).`),previewUrl:F().nullable().optional().describe("Route-only preview URL (no host:port): `/#/<doc>` for a doc, `/#/<folder>/` for a folder, `/#/` for the content root. `null` when no UI is running."),previewUrlSource:F().optional().describe(`Internal: preview-URL provenance.`)});const e5="Which level the skill lives at. `project` = lives in this KB (wherever its folder is; shared via git); `global` = user-level under your home dir (available in every project on this machine, not shared).",wSe=B({id:F().describe("Location id — editor host id, `agents`, or a custom root path. Pass to `install`."),path:F().describe('Base-relative bundle dir (e.g. ".claude/skills/x"). INFORMATIONAL — for showing a user where a location lives. Skills are addressed by `name` + `scope`: pass `id` to `install`, and read bundle files with `skills({ name, file })`, never by handing this path to `exec` or a native file tool.'),role:H([`source`,`copy`,`symlink`]).describe(`source = the REAL folder (the skill itself); copy = independent folder, auto-refreshed from the source until hand-edited (then it forks); symlink = live link to the source.`),audience:z(F()).optional().describe(`Folders that RESOLVE INTO this location (folder-level symlinks) — their agents read what lands here.`),drift:L().optional().describe(`Something outside OK rewrote this path since OK last wrote it.`)});B({name:F().describe("Skill name (its identity; pass to `edit`/`move`/`delete`/`install`)."),scope:H([`project`,`global`]).describe(e5),description:F().optional().describe(`The skill's one-line description (when present).`),installed:L().describe('Always true for a managed skill — its source folder IS the skill, so it is never "not installed". Read `locations[]` for where it actually lives.'),hosts:z(F()).describe(`Flat location ids (locations[].id), SOURCE first — legacy projection.`),locations:z(wSe).describe("Everywhere the skill lives. Exactly one `source` (the skill's real folder); every other entry is a managed copy or symlink of it."),mode:H([`copy`,`link`]).describe("The form a NEW location would take, derived from the ones the skill already uses. Not a stored preference and not a claim about existing locations — read `locations[].role` for those."),conflicts:z(F()).optional().describe(`Host ids where a DIFFERENT skill with this name occupies the slot.`)});const TSe=B({path:F().describe(`Skill-relative path (e.g. "references/tiers.md").`),kind:H([`reference`,`script`]).describe("`script` for anything under scripts/; `reference` for every other bundle file.")});B({name:F().describe(`Skill name (its identity).`),scope:H([`project`,`global`]).describe(e5),description:F().describe(`The skill's one-line description (empty if none).`),body:F().describe(`The SKILL.md body (markdown, frontmatter stripped).`),files:z(TSe).describe("Bundle files beside SKILL.md (path + kind, no inline text). Read one via `file`.")}),B({path:F().describe(`Skill-relative path read.`),kind:H([`reference`,`script`]).describe("`reference` or `script`."),text:F().describe(`Full text of the bundle file.`)}),B({name:F().describe("Skill name to pass as `skill` to `import`."),source:F().describe("Import-ready repository coordinates or website hostname. Pass this exact value to `import`."),description:F().describe(`Marketplace description for deciding whether the skill matches the task.`),installs:I().int().nonnegative().nullable().describe(`skills.sh install count, if known.`),publisher:F().nullable().describe(`Publisher, website, or GitHub owner, if known.`)}),["[Requires: Hocuspocus server] Read-only discovery for SKILLS — the read half of the skill vocabulary (`write`/`edit`/`delete`/`move`/`install` are the mutate half).",``,"This is how you search the marketplace, list managed skills, and read managed skill content. Managed skills are addressed by `name` + `scope`, NOT by path — do NOT `ls`/`cat` `.ok/skills/` or pass raw `.ok/...` paths; `.ok/` is opaque internal state.",``,"Marketplace rows are external candidates; they are NOT managed content until you call `import({ source, skill: name })`, and they are NOT active in editors until `install` projects them.",``,"OpenKnowledge's own built-in `open-knowledge*` skills (e.g. the `open-knowledge` project skill) are runtime skills already loaded in your skill list — they are NOT here, and you never fetch them through this tool.",``,`**Four modes:**`,"- **Marketplace search** (pass `query`): search skills.sh and return import-ready rows (`name`, `source`, `description`, `publisher`, installs). Use when a user asks to find/browse/add an external skill. Then call `import({ source, skill: name })` on the chosen row.","- **List** (omit `name`): every skill across BOTH levels — Project (this KB) and Global (user-level). Returns name, scope, description, installed/hosts.","- **Read skill** (pass `name`): that skill's description + body + a `files` list (`{ path, kind }`, no inline text) of its bundle files (`references/**`, `scripts/**`, and any other file the skill ships). `scope` optional — omitted, it resolves by name (preferring Project when a name exists at both levels).","- **Read file** (pass `name` + `file`): one bundle file's text — the universal read path for references + scripts (no native `cat`)."].join(`
824
+ `),F().describe(`Search query — title, path, or body terms.`),H([`omnibar`,`full_text`]).optional().describe(`'omnibar' for title/path/folder only (fast); 'full_text' includes body content. Default 'full_text'.`),z(H([`page`,`folder`,`content`,`file`])).optional().describe(`Override the default scope set. Members: 'page', 'folder', 'file', 'content'. Defaults derive from intent.`),I().int().min(1).max(100).optional().describe(`Max rows; default 20, max 100.`),L().optional().describe(`Set false to force pure-lexical ranking for this call even when semantic search is enabled. Omit to use semantic when available.`),F().optional().describe(v3);const CSe=B({kind:H([`page`,`folder`,`file`]),path:F(),docName:F(),title:F().nullable(),score:I(),signals:B({lexical:I(),fullText:I(),recency:I(),vector:I().optional()}),snippet:F().optional(),previewUrl:F().nullable(),previewUrlSource:H(vSe).optional()}),wSe=B({capable:L(),applied:L(),coverage:B({embedded:I().int(),total:I().int()})});y3({cwd:F(),query:F(),intent:F(),resultCount:I().int(),results:z(CSe),elapsedMs:I().nullable(),semantic:wSe.optional(),ready:U(!1).optional()}),["[Requires: Hocuspocus server] Build a shareable GitHub-substrate URL (`https://openknowledge.ai/d/...`) pinned to the project's current branch + the focused target (a doc or a folder). Read-only against the working tree — no commits, no pushes, no `git fetch`.",``,`Use this when the user asks for a share link / shareable link / URL to send to a teammate. Recipients open the link to receive the doc (or folder subtree) into their own OpenKnowledge install.`,``,"**Publishing is a user act.** Agents do NOT publish projects to GitHub from this tool. When the project has no GitHub remote, this tool returns an error pointing the user at the Share wizard (or `gh repo create` + `git push`) — it does not run those steps itself.",``,`**Parameters:**`,'- `path` — Content-dir-relative target. For a doc, extension-less (trailing `.md`/`.mdx` is stripped; the on-disk file is probed automatically). For a folder, the directory path. The empty string `""` is the content-root sentinel (folder-only).',"- `kind` (optional) — `'doc'` or `'folder'`. Omit to auto-probe disk (`.mdx` → `.md` → directory, first hit wins). REQUIRED when `path` is empty (`\"\"`), since auto-probe cannot disambiguate the root.","- `cwd` (optional) — Project root (see `cwd` description below).",``,"**Preconditions:** project on a named branch (not detached HEAD); origin set to a GitHub remote (`github.com` or a GitHub Enterprise Server host); the branch already pushed to origin."].join(`
825
+ `),y3({ok:L().describe(`Success discriminator.`),shareUrl:F().optional().describe(`Marketing share URL (success only).`),sharedUrl:F().optional().describe(`Unencoded GitHub blob/tree URL (success only).`),branch:F().optional().describe(`Branch the share URL pins to (success only).`),resolvedKind:H([`doc`,`folder`]).optional().describe(`Kind the target resolved to (success only).`),freshness:ow.optional().describe(`Whether the shared target matches origin (success only): current, stale (unpushed edits), absent (not on origin, a push fixes it), or empty (a folder holding nothing git can track, which no push fixes). Omitted when the probe could not run.`),error:H([...aw.options,`target-not-found`,`kind-mismatch`,`unknown`]).optional().describe(`Failure code (error path only).`),message:F().optional().describe(`Agent-actionable error message (error path only).`),previewUrl:F().nullable().optional().describe("Route-only preview URL (no host:port): `/#/<doc>` for a doc, `/#/<folder>/` for a folder, `/#/` for the content root. `null` when no UI is running."),previewUrlSource:F().optional().describe(`Internal: preview-URL provenance.`)});const e5="Which level the skill lives at. `project` = lives in this KB (wherever its folder is; shared via git); `global` = user-level under your home dir (available in every project on this machine, not shared).",TSe=B({id:F().describe("Location id — editor host id, `agents`, or a custom root path. Pass to `install`."),path:F().describe('Base-relative bundle dir (e.g. ".claude/skills/x"). INFORMATIONAL — for showing a user where a location lives. Skills are addressed by `name` + `scope`: pass `id` to `install`, and read bundle files with `skills({ name, file })`, never by handing this path to `exec` or a native file tool.'),role:H([`source`,`copy`,`symlink`]).describe(`source = the REAL folder (the skill itself); copy = independent folder, auto-refreshed from the source until hand-edited (then it forks); symlink = live link to the source.`),audience:z(F()).optional().describe(`Folders that RESOLVE INTO this location (folder-level symlinks) — their agents read what lands here.`),drift:L().optional().describe(`Something outside OK rewrote this path since OK last wrote it.`)});B({name:F().describe("Skill name (its identity; pass to `edit`/`move`/`delete`/`install`)."),scope:H([`project`,`global`]).describe(e5),description:F().optional().describe(`The skill's one-line description (when present).`),installed:L().describe('Always true for a managed skill — its source folder IS the skill, so it is never "not installed". Read `locations[]` for where it actually lives.'),hosts:z(F()).describe(`Flat location ids (locations[].id), SOURCE first — legacy projection.`),locations:z(TSe).describe("Everywhere the skill lives. Exactly one `source` (the skill's real folder); every other entry is a managed copy or symlink of it."),mode:H([`copy`,`link`]).describe("The form a NEW location would take, derived from the ones the skill already uses. Not a stored preference and not a claim about existing locations — read `locations[].role` for those."),conflicts:z(F()).optional().describe(`Host ids where a DIFFERENT skill with this name occupies the slot.`)});const ESe=B({path:F().describe(`Skill-relative path (e.g. "references/tiers.md").`),kind:H([`reference`,`script`]).describe("`script` for anything under scripts/; `reference` for every other bundle file.")});B({name:F().describe(`Skill name (its identity).`),scope:H([`project`,`global`]).describe(e5),description:F().describe(`The skill's one-line description (empty if none).`),body:F().describe(`The SKILL.md body (markdown, frontmatter stripped).`),files:z(ESe).describe("Bundle files beside SKILL.md (path + kind, no inline text). Read one via `file`.")}),B({path:F().describe(`Skill-relative path read.`),kind:H([`reference`,`script`]).describe("`reference` or `script`."),text:F().describe(`Full text of the bundle file.`)}),B({name:F().describe("Skill name to pass as `skill` to `import`."),source:F().describe("Import-ready repository coordinates or website hostname. Pass this exact value to `import`."),description:F().describe(`Marketplace description for deciding whether the skill matches the task.`),installs:I().int().nonnegative().nullable().describe(`skills.sh install count, if known.`),publisher:F().nullable().describe(`Publisher, website, or GitHub owner, if known.`)}),["[Requires: Hocuspocus server] Read-only discovery for SKILLS — the read half of the skill vocabulary (`write`/`edit`/`delete`/`move`/`install` are the mutate half).",``,"This is how you search the marketplace, list managed skills, and read managed skill content. Managed skills are addressed by `name` + `scope`, NOT by path — do NOT `ls`/`cat` `.ok/skills/` or pass raw `.ok/...` paths; `.ok/` is opaque internal state.",``,"Marketplace rows are external candidates; they are NOT managed content until you call `import({ source, skill: name })`, and they are NOT active in editors until `install` projects them.",``,"OpenKnowledge's own built-in `open-knowledge*` skills (e.g. the `open-knowledge` project skill) are runtime skills already loaded in your skill list — they are NOT here, and you never fetch them through this tool.",``,`**Four modes:**`,"- **Marketplace search** (pass `query`): search skills.sh and return import-ready rows (`name`, `source`, `description`, `publisher`, installs). Use when a user asks to find/browse/add an external skill. Then call `import({ source, skill: name })` on the chosen row.","- **List** (omit `name`): every skill across BOTH levels — Project (this KB) and Global (user-level). Returns name, scope, description, installed/hosts.","- **Read skill** (pass `name`): that skill's description + body + a `files` list (`{ path, kind }`, no inline text) of its bundle files (`references/**`, `scripts/**`, and any other file the skill ships). `scope` optional — omitted, it resolves by name (preferring Project when a name exists at both levels).","- **Read file** (pass `name` + `file`): one bundle file's text — the universal read path for references + scripts (no native `cat`)."].join(`
822
826
  `),`${["Create or replace one thing. Pass EXACTLY ONE of `document`, `folder`, `template`, `skill`, or `asset` (or `documents` for a batch of docs).",``,'- `document` — Create or overwrite a doc via the CRDT layer [Requires: Hocuspocus server]. `{ path, content }`, or `{ path, template }` to instantiate from a folder template (mutually exclusive with `content`). Optional `frontmatter` (its own YAML) and `position` (`replace` default for a new doc; required for an existing one) — note supplying `frontmatter` alongside literal `content` forces `position: replace` (the only position that persists a YAML block), overriding an explicit `append`/`prepend`. Example: `{ document: { path: "meetings/standup", content: "# Standup\\n..." } }`.','- `folder` — Create a NEW folder (optionally with its own properties) [Requires: Hocuspocus server]. `{ path, frontmatter? }`. To change an EXISTING folder use `edit`. Example: `{ folder: { path: "ideas" } }`.','- `template` — Create a reusable starting shape for new docs in a folder. `{ path: "<folder>/<name>", content, frontmatter: { title, description?, tags? } }`.','- `skill` — Create or overwrite an agent SKILL: reusable agent guidance you author in OK and `install` into your editors. A NEW skill lands at the project\'s default skill home (e.g. `.agents/skills/<name>/`); an existing one is edited at its real folder. `{ name, description, body, scope? }`. `name` is the identity (lowercase-hyphen); `description` is the trigger (when to use it). Example: `{ skill: { name: "trip-log", description: "Use when logging a fishing trip.", body: "# Steps\\n..." } }`.','- `asset` — Upload a binary (image/file) via the media route [Requires: Hocuspocus server]. `{ path: "<folder>/<file.ext>", content(base64) | source(local path) }`.',"- `documents` — Batch: `[{ path, content?|template?, frontmatter?, position?, summary? }, ...]` written in order; the response reports each.","- `summary` — Optional one-line user-outcome (≤80 chars) for the timeline, for a single `document`/`folder`/`template`/`asset` write. For a `documents` batch, give each entry its own `summary` instead (a top-level `summary` is ignored on the batch path). Avoid secrets or PII — persisted to git history.",``,"Responses may include `structuredContent.document.warnings` (batch: per-entry under `documents[]`) — advisory entries discriminated by `kind`: `content-divergence` / `disk-edit-reconciled` (write-integrity — re-read the doc) and `mermaid-parse-error` (the write landed but that fence will not render — fix it and re-edit)."].join(`
823
- `)}${zJ()}`;var t5=i(((e,t)=>{let n=[`nodebuffer`,`arraybuffer`,`fragments`],r=typeof Blob<`u`;r&&n.push(`blob`),t.exports={BINARY_TYPES:n,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,hasBlob:r,kForOnEventAttribute:Symbol(`kIsForOnEventAttribute`),kListener:Symbol(`kListener`),kStatusCode:Symbol(`status-code`),kWebSocket:Symbol(`websocket`),NOOP:()=>{}}})),n5=i(((e,n)=>{let{EMPTY_BUFFER:r}=t5(),i=Buffer[Symbol.species];function a(e,t){if(e.length===0)return r;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),a=0;for(let t=0;t<e.length;t++){let r=e[t];n.set(r,a),a+=r.length}return a<t?new i(n.buffer,n.byteOffset,a):n}function o(e,t,n,r,i){for(let a=0;a<i;a++)n[r+a]=e[a]^t[a&3]}function s(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function c(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function l(e){if(l.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new i(e):ArrayBuffer.isView(e)?t=new i(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),l.readOnly=!1),t}if(n.exports={concat:a,mask:o,toArrayBuffer:c,toBuffer:l,unmask:s},!process.env.WS_NO_BUFFER_UTIL)try{let e=t(`bufferutil`);n.exports.mask=function(t,n,r,i,a){a<48?o(t,n,r,i,a):e.mask(t,n,r,i,a)},n.exports.unmask=function(t,n){t.length<32?s(t,n):e.unmask(t,n)}}catch{}})),ESe=i(((e,t)=>{let n=Symbol(`kDone`),r=Symbol(`kRun`);t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[n])}}}})),r5=i(((e,n)=>{let r=t(`zlib`),i=n5(),a=ESe(),{kStatusCode:o}=t5(),s=Buffer[Symbol.species],c=Buffer.from([0,0,255,255]),l=Symbol(`permessage-deflate`),u=Symbol(`total-length`),d=Symbol(`callback`),f=Symbol(`buffers`),p=Symbol(`error`),m;n.exports=class{constructor(e){this._options=e||{},this._threshold=this._options.threshold===void 0?1024:this._options.threshold,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,m||=new a(this._options.concurrencyLimit===void 0?10:this._options.concurrencyLimit)}static get extensionName(){return`permessage-deflate`}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits??(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&=(this._inflate.close(),null),this._deflate){let e=this._deflate[d];this._deflate.close(),this._deflate=null,e&&e(Error(`The deflate stream was closed while data was being processed`))}}acceptAsServer(e){let t=this._options,n=e.find(e=>!(t.serverNoContextTakeover===!1&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits==`number`&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==`number`&&!e.client_max_window_bits));if(!n)throw Error(`None of the extension offers can be accepted`);return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits==`number`&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits==`number`?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw Error(`Unexpected parameter "client_no_context_takeover"`);if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits==`number`&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==`number`&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error(`Unexpected or invalid parameter "client_max_window_bits"`);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(n=n[0],t===`client_max_window_bits`){if(n!==!0){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else if(t===`server_max_window_bits`){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(t===`client_no_context_takeover`||t===`server_no_context_takeover`){if(n!==!0)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=n})}),e}decompress(e,t,n){m.add(r=>{this._decompress(e,t,(e,t)=>{r(),n(e,t)})})}compress(e,t,n){m.add(r=>{this._compress(e,t,(e,t)=>{r(),n(e,t)})})}_decompress(e,t,n){let a=this._isServer?`client`:`server`;if(!this._inflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:r.Z_DEFAULT_WINDOWBITS;this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[l]=this,this._inflate[u]=0,this._inflate[f]=[],this._inflate.on(`error`,_),this._inflate.on(`data`,g)}this._inflate[d]=n,this._inflate.write(e),t&&this._inflate.write(c),this._inflate.flush(()=>{let e=this._inflate[p];if(e){this._inflate.close(),this._inflate=null,n(e);return}let r=i.concat(this._inflate[f],this._inflate[u]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[u]=0,this._inflate[f]=[],t&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),n(null,r)})}_compress(e,t,n){let a=this._isServer?`server`:`client`;if(!this._deflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:r.Z_DEFAULT_WINDOWBITS;this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[u]=0,this._deflate[f]=[],this._deflate.on(`data`,h)}this._deflate[d]=n,this._deflate.write(e),this._deflate.flush(r.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=i.concat(this._deflate[f],this._deflate[u]);t&&(e=new s(e.buffer,e.byteOffset,e.length-4)),this._deflate[d]=null,this._deflate[u]=0,this._deflate[f]=[],t&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),n(null,e)})}};function h(e){this[f].push(e),this[u]+=e.length}function g(e){if(this[u]+=e.length,this[l]._maxPayload<1||this[u]<=this[l]._maxPayload){this[f].push(e);return}this[p]=RangeError(`Max payload size exceeded`),this[p].code=`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`,this[p][o]=1009,this.removeListener(`data`,g),this.reset()}function _(e){if(this[l]._inflate=null,this[p]){this[d](this[p]);return}e[o]=1007,this[d](e)}})),i5=i(((e,n)=>{let{isUtf8:r}=t(`buffer`),{hasBlob:i}=t5(),a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function o(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function s(e){let t=e.length,n=0;for(;n<t;)if(!(e[n]&128))n++;else if((e[n]&224)==192){if(n+1===t||(e[n+1]&192)!=128||(e[n]&254)==192)return!1;n+=2}else if((e[n]&240)==224){if(n+2>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||e[n]===224&&(e[n+1]&224)==128||e[n]===237&&(e[n+1]&224)==160)return!1;n+=3}else if((e[n]&248)==240){if(n+3>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||(e[n+3]&192)!=128||e[n]===240&&(e[n+1]&240)==128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function c(e){return i&&typeof e==`object`&&typeof e.arrayBuffer==`function`&&typeof e.type==`string`&&typeof e.stream==`function`&&(e[Symbol.toStringTag]===`Blob`||e[Symbol.toStringTag]===`File`)}if(n.exports={isBlob:c,isValidStatusCode:o,isValidUTF8:s,tokenChars:a},r)n.exports.isValidUTF8=function(e){return e.length<24?s(e):r(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=t(`utf-8-validate`);n.exports.isValidUTF8=function(t){return t.length<32?s(t):e(t)}}catch{}})),a5=i(((e,n)=>{let{Writable:r}=t(`stream`),i=r5(),{BINARY_TYPES:a,EMPTY_BUFFER:o,kStatusCode:s,kWebSocket:c}=t5(),{concat:l,toArrayBuffer:u,unmask:d}=n5(),{isValidStatusCode:f,isValidUTF8:p}=i5(),m=Buffer[Symbol.species];n.exports=class extends r{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents===void 0?!0:e.allowSynchronousEvents,this._binaryType=e.binaryType||a[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[c]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(this._opcode===8&&this._state==0)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){n(this.createError(RangeError,`Too many buffered chunks`,!1,1008,`WS_ERR_TOO_MANY_BUFFERED_PARTS`));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new m(t.buffer,t.byteOffset+e,t.length-e),new m(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],r=t.length-e;e>=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=new m(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){e(this.createError(RangeError,`RSV2 and RSV3 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_2_3`));return}let n=(t[0]&64)==64;if(n&&!this._extensions[i.extensionName]){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._fin=(t[0]&128)==128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(!this._fragmented){e(this.createError(RangeError,`invalid opcode 0`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){e(this.createError(RangeError,`FIN must be set`,!0,1002,`WS_ERR_EXPECTED_FIN`));return}if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,`WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH`));return}}else{e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)==128,this._isServer){if(!this._masked){e(this.createError(RangeError,`MASK must be set`,!0,1002,`WS_ERR_EXPECTED_MASK`));return}}else if(this._masked){e(this.createError(RangeError,`MASK must be clear`,!0,1002,`WS_ERR_UNEXPECTED_MASK`));return}this._payloadLength===126?this._state=1:this._payloadLength===127?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),n=t.readUInt32BE(0);if(n>2**21-1){e(this.createError(RangeError,`Unsupported WebSocket frame: payload length > 2^53 - 1`,!1,1009,`WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH`));return}this._payloadLength=n*2**32+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=o;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&d(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=5,this.decompress(t,e);return}if(t.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){e(this.createError(RangeError,`Too many message fragments`,!1,1008,`WS_ERR_TOO_MANY_BUFFERED_PARTS`));return}this._messageLength=this._totalPayloadLength,this._fragments.push(t)}this.dataMessage(e)}decompress(e,t){this._extensions[i.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){t(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){t(this.createError(RangeError,`Too many message fragments`,!1,1008,`WS_ERR_TOO_MANY_BUFFERED_PARTS`));return}this._fragments.push(n)}this.dataMessage(t),this._state===0&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;r=this._binaryType===`nodebuffer`?l(n,t):this._binaryType===`arraybuffer`?u(l(n,t)):this._binaryType===`blob`?new Blob(n):n,this._allowSynchronousEvents?(this.emit(`message`,r,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!0),this._state=0,this.startLoop(e)}))}else{let r=l(n,t);if(!this._skipUTF8Validation&&!p(r)){e(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._state===5||this._allowSynchronousEvents?(this.emit(`message`,r,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit(`conclude`,1005,o),this.end();else{let n=e.readUInt16BE(0);if(!f(n)){t(this.createError(RangeError,`invalid status code ${n}`,!0,1002,`WS_ERR_INVALID_CLOSE_CODE`));return}let r=new m(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!p(r)){t(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._loop=!1,this.emit(`conclude`,n,r),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0,this.startLoop(t)}))}createError(e,t,n,r,i){this._loop=!1,this._errored=!0;let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=i,a[s]=r,a}}})),o5=i(((e,n)=>{let{Duplex:r}=t(`stream`),{randomFillSync:i}=t(`crypto`),{types:{isUint8Array:a}}=t(`util`),o=r5(),{EMPTY_BUFFER:s,kWebSocket:c,NOOP:l}=t5(),{isBlob:u,isValidStatusCode:d}=i5(),{mask:f,toBuffer:p}=n5(),m=Symbol(`kByteLength`),h=Buffer.alloc(4),g=8*1024,_,v=g;n.exports=class e{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=l,this[c]=void 0}static frame(e,t){let n,r=!1,a=2,o=!1;t.mask&&(n=t.maskBuffer||h,t.generateMask?t.generateMask(n):(v===g&&(_===void 0&&(_=Buffer.alloc(g)),i(_,0,g),v=0),n[0]=_[v++],n[1]=_[v++],n[2]=_[v++],n[3]=_[v++]),o=(n[0]|n[1]|n[2]|n[3])===0,a=6);let s;typeof e==`string`?(!t.mask||o)&&t[m]!==void 0?s=t[m]:(e=Buffer.from(e),s=e.length):(s=e.length,r=t.mask&&t.readOnly&&!o);let c=s;s>=65536?(a+=8,c=127):s>125&&(a+=2,c=126);let l=Buffer.allocUnsafe(r?s+a:a);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(s,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),!t.mask||(l[1]|=128,l[a-4]=n[0],l[a-3]=n[1],l[a-2]=n[2],l[a-1]=n[3],o)?[l,e]:r?(f(e,n,l,a,s),[l]):(f(e,n,e,0,s),[l,e])}close(t,n,r,i){let o;if(t===void 0)o=s;else if(typeof t!=`number`||!d(t))throw TypeError(`First argument must be a valid error code number`);else if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let e=Buffer.byteLength(n);if(e>123)throw RangeError(`The message must not be greater than 123 bytes`);if(o=Buffer.allocUnsafe(2+e),o.writeUInt16BE(t,0),typeof n==`string`)o.write(n,2);else if(a(n))o.set(n,2);else throw TypeError(`Second argument must be a string or a Uint8Array`)}let c={[m]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state===0?this.sendFrame(e.frame(o,c),i):this.enqueue([this.dispatch,o,!1,c,i])}ping(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):u(t)?(i=t.size,a=!1):(t=p(t),i=t.length,a=p.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[m]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};u(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}pong(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):u(t)?(i=t.size,a=!1):(t=p(t),i=t.length,a=p.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[m]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};u(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}send(e,t,n){let r=this._extensions[o.extensionName],i=t.binary?2:1,a=t.compress,s,c;typeof e==`string`?(s=Buffer.byteLength(e),c=!1):u(e)?(s=e.size,c=!1):(e=p(e),s=e.length,c=p.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?`server_no_context_takeover`:`client_no_context_takeover`]&&(a=s>=r._threshold),this._compress=a):(a=!1,i=0),t.fin&&(this._firstFragment=!0);let l={[m]:s,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:a};u(e)?this._state===0?this.getBlobData(e,this._compress,l,n):this.enqueue([this.getBlobData,e,this._compress,l,n]):this._state===0?this.dispatch(e,this._compress,l,n):this.enqueue([this.dispatch,e,this._compress,l,n])}getBlobData(t,n,r,i){this._bufferedBytes+=r[m],this._state=2,t.arrayBuffer().then(t=>{if(this._socket.destroyed){let e=Error(`The socket was closed while the blob was being read`);process.nextTick(y,this,e,i);return}this._bufferedBytes-=r[m];let a=p(t);n?this.dispatch(a,n,r,i):(this._state=0,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(e=>{process.nextTick(b,this,e,i)})}dispatch(t,n,r,i){if(!n){this.sendFrame(e.frame(t,r),i);return}let a=this._extensions[o.extensionName];this._bufferedBytes+=r[m],this._state=1,a.compress(t,r.fin,(t,n)=>{if(this._socket.destroyed){let e=Error(`The socket was closed while data was being compressed`);y(this,e,i);return}this._bufferedBytes-=r[m],this._state=0,r.readOnly=!1,this.sendFrame(e.frame(n,r),i),this.dequeue()})}dequeue(){for(;this._state===0&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][m],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][m],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};function y(e,t,n){typeof n==`function`&&n(t);for(let n=0;n<e._queue.length;n++){let r=e._queue[n],i=r[r.length-1];typeof i==`function`&&i(t)}}function b(e,t,n){y(e,t,n),e.onerror(t)}})),DSe=i(((e,t)=>{let{kForOnEventAttribute:n,kListener:r}=t5(),i=Symbol(`kCode`),a=Symbol(`kData`),o=Symbol(`kError`),s=Symbol(`kMessage`),c=Symbol(`kReason`),l=Symbol(`kTarget`),u=Symbol(`kType`),d=Symbol(`kWasClean`);var f=class{constructor(e){this[l]=null,this[u]=e}get target(){return this[l]}get type(){return this[u]}};Object.defineProperty(f.prototype,`target`,{enumerable:!0}),Object.defineProperty(f.prototype,`type`,{enumerable:!0});var p=class extends f{constructor(e,t={}){super(e),this[i]=t.code===void 0?0:t.code,this[c]=t.reason===void 0?``:t.reason,this[d]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[i]}get reason(){return this[c]}get wasClean(){return this[d]}};Object.defineProperty(p.prototype,`code`,{enumerable:!0}),Object.defineProperty(p.prototype,`reason`,{enumerable:!0}),Object.defineProperty(p.prototype,`wasClean`,{enumerable:!0});var m=class extends f{constructor(e,t={}){super(e),this[o]=t.error===void 0?null:t.error,this[s]=t.message===void 0?``:t.message}get error(){return this[o]}get message(){return this[s]}};Object.defineProperty(m.prototype,`error`,{enumerable:!0}),Object.defineProperty(m.prototype,`message`,{enumerable:!0});var h=class extends f{constructor(e,t={}){super(e),this[a]=t.data===void 0?null:t.data}get data(){return this[a]}};Object.defineProperty(h.prototype,`data`,{enumerable:!0}),t.exports={CloseEvent:p,ErrorEvent:m,Event:f,EventTarget:{addEventListener(e,t,i={}){for(let a of this.listeners(e))if(!i[n]&&a[r]===t&&!a[n])return;let a;if(e===`message`)a=function(e,n){let r=new h(`message`,{data:n?e:e.toString()});r[l]=this,g(t,this,r)};else if(e===`close`)a=function(e,n){let r=new p(`close`,{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[l]=this,g(t,this,r)};else if(e===`error`)a=function(e){let n=new m(`error`,{error:e,message:e.message});n[l]=this,g(t,this,n)};else if(e===`open`)a=function(){let e=new f(`open`);e[l]=this,g(t,this,e)};else return;a[n]=!!i[n],a[r]=t,i.once?this.once(e,a):this.on(e,a)},removeEventListener(e,t){for(let i of this.listeners(e))if(i[r]===t&&!i[n]){this.removeListener(e,i);break}}},MessageEvent:h};function g(e,t,n){typeof e==`object`&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}})),s5=i(((e,t)=>{let{tokenChars:n}=i5();function r(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function i(e){let t=Object.create(null),i=Object.create(null),a=!1,o=!1,s=!1,c,l,u=-1,d=-1,f=-1,p=0;for(;p<e.length;p++)if(d=e.charCodeAt(p),c===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(p!==0&&(d===32||d===9))f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);d===44?(r(t,n,i),i=Object.create(null)):c=n,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);else if(l===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(d===32||d===9)f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p),r(i,e.slice(u,f),!0),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),u=f=-1}else if(d===61&&u!==-1&&f===-1)l=e.slice(u,p),u=f=-1;else throw SyntaxError(`Unexpected character at index ${p}`);else if(o){if(n[d]!==1)throw SyntaxError(`Unexpected character at index ${p}`);u===-1?u=p:a||=!0,o=!1}else if(s)if(n[d]===1)u===-1&&(u=p);else if(d===34&&u!==-1)s=!1,f=p;else if(d===92)o=!0;else throw SyntaxError(`Unexpected character at index ${p}`);else if(d===34&&e.charCodeAt(p-1)===61)s=!0;else if(f===-1&&n[d]===1)u===-1&&(u=p);else if(u!==-1&&(d===32||d===9))f===-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);a&&=(n=n.replace(/\\/g,``),!1),r(i,l,n),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),l=void 0,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);if(u===-1||s||d===32||d===9)throw SyntaxError(`Unexpected end of input`);f===-1&&(f=p);let m=e.slice(u,f);return c===void 0?r(t,m,i):(l===void 0?r(i,m,!0):a?r(i,l,m.replace(/\\/g,``)):r(i,l,m),r(t,c,i)),t}function a(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>e===!0?t:`${t}=${e}`).join(`; `)})).join(`; `)).join(`, `)}).join(`, `)}t.exports={format:a,parse:i}})),c5=i(((e,n)=>{let r=t(`events`),i=t(`https`),a=t(`http`),o=t(`net`),s=t(`tls`),{randomBytes:c,createHash:l}=t(`crypto`),{Duplex:u,Readable:d}=t(`stream`),{URL:f}=t(`url`),p=r5(),m=a5(),h=o5(),{isBlob:g}=i5(),{BINARY_TYPES:_,CLOSE_TIMEOUT:v,EMPTY_BUFFER:y,GUID:b,kForOnEventAttribute:x,kListener:S,kStatusCode:C,kWebSocket:w,NOOP:T}=t5(),{EventTarget:{addEventListener:E,removeEventListener:D}}=DSe(),{format:O,parse:ee}=s5(),{toBuffer:te}=n5(),ne=Symbol(`kAborted`),re=[8,13],ie=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],ae=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;var oe=class e extends r{constructor(t,n,r){super(),this._binaryType=_[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=y,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol=``,this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t===null?(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0):(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n==`object`&&n?(r=n,n=[]):n=[n]),se(this,t,n,r))}get binaryType(){return this._binaryType}set binaryType(e){_.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,r){let i=new m({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),a=new h(t,this._extensions,r.generateMask);this._receiver=i,this._sender=a,this._socket=t,i[w]=this,a[w]=this,t[w]=this,i.on(`conclude`,j),i.on(`drain`,de),i.on(`error`,fe),i.on(`message`,me),i.on(`ping`,M),i.on(`pong`,N),a.onerror=ge,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on(`close`,ve),t.on(`data`,ye),t.on(`end`,be),t.on(`error`,xe),this._readyState=e.OPEN,this.emit(`open`)}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage);return}this._extensions[p.extensionName]&&this._extensions[p.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){ue(this,this._req,`WebSocket was closed before the connection was established`);return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),_e(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){A(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||y,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){A(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||y,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof n==`function`&&(r=n,n={}),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){A(this,t,r);return}let i={binary:typeof t!=`string`,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[p.extensionName]||(i.compress=!1),this._sender.send(t||y,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){ue(this,this._req,`WebSocket was closed before the connection was established`);return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(oe,`CONNECTING`,{enumerable:!0,value:ie.indexOf(`CONNECTING`)}),Object.defineProperty(oe.prototype,`CONNECTING`,{enumerable:!0,value:ie.indexOf(`CONNECTING`)}),Object.defineProperty(oe,`OPEN`,{enumerable:!0,value:ie.indexOf(`OPEN`)}),Object.defineProperty(oe.prototype,`OPEN`,{enumerable:!0,value:ie.indexOf(`OPEN`)}),Object.defineProperty(oe,`CLOSING`,{enumerable:!0,value:ie.indexOf(`CLOSING`)}),Object.defineProperty(oe.prototype,`CLOSING`,{enumerable:!0,value:ie.indexOf(`CLOSING`)}),Object.defineProperty(oe,`CLOSED`,{enumerable:!0,value:ie.indexOf(`CLOSED`)}),Object.defineProperty(oe.prototype,`CLOSED`,{enumerable:!0,value:ie.indexOf(`CLOSED`)}),[`binaryType`,`bufferedAmount`,`extensions`,`isPaused`,`protocol`,`readyState`,`url`].forEach(e=>{Object.defineProperty(oe.prototype,e,{enumerable:!0})}),[`open`,`error`,`close`,`message`].forEach(e=>{Object.defineProperty(oe.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[x])return t[S];return null},set(t){for(let t of this.listeners(e))if(t[x]){this.removeListener(e,t);break}typeof t==`function`&&this.addEventListener(e,t,{[x]:!0})}})}),oe.prototype.addEventListener=E,oe.prototype.removeEventListener=D,n.exports=oe;function se(e,t,n,r){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:v,protocolVersion:re[1],maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:`GET`,host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!re.includes(o.protocolVersion))throw RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${re.join(`, `)})`);let s;if(t instanceof f)s=t;else try{s=new f(t)}catch{throw SyntaxError(`Invalid URL: ${t}`)}s.protocol===`http:`?s.protocol=`ws:`:s.protocol===`https:`&&(s.protocol=`wss:`),e._url=s.href;let u=s.protocol===`wss:`,d=s.protocol===`ws+unix:`,m;if(s.protocol!==`ws:`&&!u&&!d?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:d&&!s.pathname?m=`The URL's pathname is empty`:s.hash&&(m=`The URL contains a fragment identifier`),m){let t=SyntaxError(m);if(e._redirects===0)throw t;k(e,t);return}let h=u?443:80,g=c(16).toString(`base64`),_=u?i.request:a.request,y=new Set,x;if(o.createConnection=o.createConnection||(u?le:ce),o.defaultPort=o.defaultPort||h,o.port=s.port||h,o.host=s.hostname.startsWith(`[`)?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":g,Connection:`Upgrade`,Upgrade:`websocket`},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(x=new p({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers[`Sec-WebSocket-Extensions`]=O({[p.extensionName]:x.offer()})),n.length){for(let e of n){if(typeof e!=`string`||!ae.test(e)||y.has(e))throw SyntaxError(`An invalid or duplicated subprotocol was specified`);y.add(e)}o.headers[`Sec-WebSocket-Protocol`]=n.join(`,`)}if(o.origin&&(o.protocolVersion<13?o.headers[`Sec-WebSocket-Origin`]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}:${s.password}`),d){let e=o.path.split(`:`);o.socketPath=e[0],o.path=e[1]}let S;if(o.followRedirects){if(e._redirects===0){e._originalIpc=d,e._originalSecure=u,e._originalHostOrSocketPath=d?o.socketPath:s.host;let t=r&&r.headers;if(r={...r,headers:{}},t)for(let[e,n]of Object.entries(t))r.headers[e.toLowerCase()]=n}else if(e.listenerCount(`redirect`)===0){let t=d?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:s.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!u)&&(delete o.headers.authorization,delete o.headers.cookie,t||delete o.headers.host,o.auth=void 0)}o.auth&&!r.headers.authorization&&(r.headers.authorization=`Basic `+Buffer.from(o.auth).toString(`base64`)),S=e._req=_(o),e._redirects&&e.emit(`redirect`,e.url,S)}else S=e._req=_(o);o.timeout&&S.on(`timeout`,()=>{ue(e,S,`Opening handshake has timed out`)}),S.on(`error`,t=>{S===null||S[ne]||(S=e._req=null,k(e,t))}),S.on(`response`,i=>{let a=i.headers.location,s=i.statusCode;if(a&&o.followRedirects&&s>=300&&s<400){if(++e._redirects>o.maxRedirects){ue(e,S,`Maximum redirects exceeded`);return}S.abort();let i;try{i=new f(a,t)}catch{k(e,SyntaxError(`Invalid URL: ${a}`));return}se(e,i,n,r)}else e.emit(`unexpected-response`,S,i)||ue(e,S,`Unexpected server response: ${i.statusCode}`)}),S.on(`upgrade`,(t,n,r)=>{if(e.emit(`upgrade`,t),e.readyState!==oe.CONNECTING)return;S=e._req=null;let i=t.headers.upgrade;if(i===void 0||i.toLowerCase()!==`websocket`){ue(e,n,`Invalid Upgrade header`);return}let a=l(`sha1`).update(g+b).digest(`base64`);if(t.headers[`sec-websocket-accept`]!==a){ue(e,n,`Invalid Sec-WebSocket-Accept header`);return}let s=t.headers[`sec-websocket-protocol`],c;if(s===void 0?y.size&&(c=`Server sent no subprotocol`):y.size?y.has(s)||(c=`Server sent an invalid subprotocol`):c=`Server sent a subprotocol but none was requested`,c){ue(e,n,c);return}s&&(e._protocol=s);let u=t.headers[`sec-websocket-extensions`];if(u!==void 0){if(!x){ue(e,n,`Server sent a Sec-WebSocket-Extensions header but no extension was requested`);return}let t;try{t=ee(u)}catch{ue(e,n,`Invalid Sec-WebSocket-Extensions header`);return}let r=Object.keys(t);if(r.length!==1||r[0]!==p.extensionName){ue(e,n,`Server indicated an extension that was not requested`);return}try{x.accept(t[p.extensionName])}catch{ue(e,n,`Invalid Sec-WebSocket-Extensions header`);return}e._extensions[p.extensionName]=x}e.setSocket(n,r,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,e):S.end()}function k(e,t){e._readyState=oe.CLOSING,e._errorEmitted=!0,e.emit(`error`,t),e.emitClose()}function ce(e){return e.path=e.socketPath,o.connect(e)}function le(e){return e.path=void 0,!e.servername&&e.servername!==``&&(e.servername=o.isIP(e.host)?``:e.host),s.connect(e)}function ue(e,t,n){e._readyState=oe.CLOSING;let r=Error(n);Error.captureStackTrace(r,ue),t.setHeader?(t[ne]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(k,e,r)):(t.destroy(r),t.once(`error`,e.emit.bind(e,`error`)),t.once(`close`,e.emitClose.bind(e)))}function A(e,t,n){if(t){let n=g(t)?t.size:te(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${ie[e.readyState]})`);process.nextTick(n,t)}}function j(e,t){let n=this[w];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[w]!==void 0&&(n._socket.removeListener(`data`,ye),process.nextTick(he,n._socket),e===1005?n.close():n.close(e,t))}function de(){let e=this[w];e.isPaused||e._socket.resume()}function fe(e){let t=this[w];t._socket[w]!==void 0&&(t._socket.removeListener(`data`,ye),process.nextTick(he,t._socket),t.close(e[C])),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e))}function pe(){this[w].emitClose()}function me(e,t){this[w].emit(`message`,e,t)}function M(e){let t=this[w];t._autoPong&&t.pong(e,!this._isServer,T),t.emit(`ping`,e)}function N(e){this[w].emit(`pong`,e)}function he(e){e.resume()}function ge(e){let t=this[w];t.readyState!==oe.CLOSED&&(t.readyState===oe.OPEN&&(t._readyState=oe.CLOSING,_e(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e)))}function _e(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function ve(){let e=this[w];if(this.removeListener(`close`,ve),this.removeListener(`data`,ye),this.removeListener(`end`,be),e._readyState=oe.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[w]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on(`error`,pe),e._receiver.on(`finish`,pe))}function ye(e){this[w]._receiver.write(e)||this.pause()}function be(){let e=this[w];e._readyState=oe.CLOSING,e._receiver.end(),this.end()}function xe(){let e=this[w];this.removeListener(`error`,xe),this.on(`error`,T),e&&(e._readyState=oe.CLOSING,this.destroy())}})),OSe=i(((e,n)=>{c5();let{Duplex:r}=t(`stream`);function i(e){e.emit(`close`)}function a(){!this.destroyed&&this._writableState.finished&&this.destroy()}function o(e){this.removeListener(`error`,o),this.destroy(),this.listenerCount(`error`)===0&&this.emit(`error`,e)}function s(e,t){let n=!0,s=new r({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on(`message`,function(t,n){let r=!n&&s._readableState.objectMode?t.toString():t;s.push(r)||e.pause()}),e.once(`error`,function(e){s.destroyed||(n=!1,s.destroy(e))}),e.once(`close`,function(){s.destroyed||s.push(null)}),s._destroy=function(t,r){if(e.readyState===e.CLOSED){r(t),process.nextTick(i,s);return}let a=!1;e.once(`error`,function(e){a=!0,r(e)}),e.once(`close`,function(){a||r(t),process.nextTick(i,s)}),n&&e.terminate()},s._final=function(t){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._final(t)});return}e._socket!==null&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once(`finish`,function(){t()}),e.close()))},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,n,r){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._write(t,n,r)});return}e.send(t,r)},s.on(`end`,a),s.on(`error`,o),s}n.exports=s})),l5=i(((e,t)=>{let{tokenChars:n}=i5();function r(e){let t=new Set,r=-1,i=-1,a=0;for(;a<e.length;a++){let o=e.charCodeAt(a);if(i===-1&&n[o]===1)r===-1&&(r=a);else if(a!==0&&(o===32||o===9))i===-1&&r!==-1&&(i=a);else if(o===44){if(r===-1)throw SyntaxError(`Unexpected character at index ${a}`);i===-1&&(i=a);let n=e.slice(r,i);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);t.add(n),r=i=-1}else throw SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||i!==-1)throw SyntaxError(`Unexpected end of input`);let o=e.slice(r,a);if(t.has(o))throw SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}t.exports={parse:r}})),kSe=i(((e,n)=>{let r=t(`events`),i=t(`http`),{Duplex:a}=t(`stream`),{createHash:o}=t(`crypto`),s=s5(),c=r5(),l=l5(),u=c5(),{CLOSE_TIMEOUT:d,GUID:f,kWebSocket:p}=t5(),m=/^[+/0-9A-Za-z]{22}==$/;n.exports=class extends r{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:d,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:u,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError(`One and only one of the "port", "server", or "noServer" options must be specified`);if(e.port==null?e.server&&(this._server=e.server):(this._server=i.createServer((e,t)=>{let n=i.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":`text/plain`}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)),this._server){let e=this.emit.bind(this,`connection`);this._removeListeners=h(this._server,{listening:this.emit.bind(this,`listening`),error:this.emit.bind(this,`error`),upgrade:(t,n,r)=>{this.handleUpgrade(t,n,r,e)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error(`The server is operating in "noServer" mode`);return this._server?this._server.address():null}close(e){if(this._state===2){e&&this.once(`close`,()=>{e(Error(`The server is not running`))}),process.nextTick(g,this);return}if(e&&this.once(`close`,e),this._state!==1)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(g,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{g(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf(`?`);if((t===-1?e.url:e.url.slice(0,t))!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,r){t.on(`error`,_);let i=e.headers[`sec-websocket-key`],a=e.headers.upgrade,o=+e.headers[`sec-websocket-version`];if(e.method!==`GET`){y(this,e,t,405,`Invalid HTTP method`);return}if(a===void 0||a.toLowerCase()!==`websocket`){y(this,e,t,400,`Invalid Upgrade header`);return}if(i===void 0||!m.test(i)){y(this,e,t,400,`Missing or invalid Sec-WebSocket-Key header`);return}if(o!==13&&o!==8){y(this,e,t,400,`Missing or invalid Sec-WebSocket-Version header`,{"Sec-WebSocket-Version":`13, 8`});return}if(!this.shouldHandle(e)){v(t,400);return}let u=e.headers[`sec-websocket-protocol`],d=new Set;if(u!==void 0)try{d=l.parse(u)}catch{y(this,e,t,400,`Invalid Sec-WebSocket-Protocol header`);return}let f=e.headers[`sec-websocket-extensions`],p={};if(this.options.perMessageDeflate&&f!==void 0){let n=new c({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let e=s.parse(f);e[c.extensionName]&&(n.accept(e[c.extensionName]),p[c.extensionName]=n)}catch{y(this,e,t,400,`Invalid or unacceptable Sec-WebSocket-Extensions header`);return}}if(this.options.verifyClient){let a={origin:e.headers[`${o===8?`sec-websocket-origin`:`origin`}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(a,(a,o,s,c)=>{if(!a)return v(t,o||401,s,c);this.completeUpgrade(p,i,d,e,t,n,r)});return}if(!this.options.verifyClient(a))return v(t,401)}this.completeUpgrade(p,i,d,e,t,n,r)}completeUpgrade(e,t,n,r,i,a,l){if(!i.readable||!i.writable)return i.destroy();if(i[p])throw Error(`server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration`);if(this._state>0)return v(i,503);let u=[`HTTP/1.1 101 Switching Protocols`,`Upgrade: websocket`,`Connection: Upgrade`,`Sec-WebSocket-Accept: ${o(`sha1`).update(t+f).digest(`base64`)}`],d=new this.options.WebSocket(null,void 0,this.options);if(n.size){let e=this.options.handleProtocols?this.options.handleProtocols(n,r):n.values().next().value;e&&(u.push(`Sec-WebSocket-Protocol: ${e}`),d._protocol=e)}if(e[c.extensionName]){let t=e[c.extensionName].params,n=s.format({[c.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${n}`),d._extensions=e}this.emit(`headers`,u,r),i.write(u.concat(`\r
827
+ `)}${zJ()}`;var t5=i(((e,t)=>{let n=[`nodebuffer`,`arraybuffer`,`fragments`],r=typeof Blob<`u`;r&&n.push(`blob`),t.exports={BINARY_TYPES:n,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,hasBlob:r,kForOnEventAttribute:Symbol(`kIsForOnEventAttribute`),kListener:Symbol(`kListener`),kStatusCode:Symbol(`status-code`),kWebSocket:Symbol(`websocket`),NOOP:()=>{}}})),n5=i(((e,n)=>{let{EMPTY_BUFFER:r}=t5(),i=Buffer[Symbol.species];function a(e,t){if(e.length===0)return r;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),a=0;for(let t=0;t<e.length;t++){let r=e[t];n.set(r,a),a+=r.length}return a<t?new i(n.buffer,n.byteOffset,a):n}function o(e,t,n,r,i){for(let a=0;a<i;a++)n[r+a]=e[a]^t[a&3]}function s(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function c(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function l(e){if(l.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new i(e):ArrayBuffer.isView(e)?t=new i(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),l.readOnly=!1),t}if(n.exports={concat:a,mask:o,toArrayBuffer:c,toBuffer:l,unmask:s},!process.env.WS_NO_BUFFER_UTIL)try{let e=t(`bufferutil`);n.exports.mask=function(t,n,r,i,a){a<48?o(t,n,r,i,a):e.mask(t,n,r,i,a)},n.exports.unmask=function(t,n){t.length<32?s(t,n):e.unmask(t,n)}}catch{}})),DSe=i(((e,t)=>{let n=Symbol(`kDone`),r=Symbol(`kRun`);t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[n])}}}})),r5=i(((e,n)=>{let r=t(`zlib`),i=n5(),a=DSe(),{kStatusCode:o}=t5(),s=Buffer[Symbol.species],c=Buffer.from([0,0,255,255]),l=Symbol(`permessage-deflate`),u=Symbol(`total-length`),d=Symbol(`callback`),f=Symbol(`buffers`),p=Symbol(`error`),m;n.exports=class{constructor(e){this._options=e||{},this._threshold=this._options.threshold===void 0?1024:this._options.threshold,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,m||=new a(this._options.concurrencyLimit===void 0?10:this._options.concurrencyLimit)}static get extensionName(){return`permessage-deflate`}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits??(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&=(this._inflate.close(),null),this._deflate){let e=this._deflate[d];this._deflate.close(),this._deflate=null,e&&e(Error(`The deflate stream was closed while data was being processed`))}}acceptAsServer(e){let t=this._options,n=e.find(e=>!(t.serverNoContextTakeover===!1&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits==`number`&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==`number`&&!e.client_max_window_bits));if(!n)throw Error(`None of the extension offers can be accepted`);return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits==`number`&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits==`number`?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw Error(`Unexpected parameter "client_no_context_takeover"`);if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits==`number`&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==`number`&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error(`Unexpected or invalid parameter "client_max_window_bits"`);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(n=n[0],t===`client_max_window_bits`){if(n!==!0){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else if(t===`server_max_window_bits`){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(t===`client_no_context_takeover`||t===`server_no_context_takeover`){if(n!==!0)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=n})}),e}decompress(e,t,n){m.add(r=>{this._decompress(e,t,(e,t)=>{r(),n(e,t)})})}compress(e,t,n){m.add(r=>{this._compress(e,t,(e,t)=>{r(),n(e,t)})})}_decompress(e,t,n){let a=this._isServer?`client`:`server`;if(!this._inflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:r.Z_DEFAULT_WINDOWBITS;this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[l]=this,this._inflate[u]=0,this._inflate[f]=[],this._inflate.on(`error`,_),this._inflate.on(`data`,g)}this._inflate[d]=n,this._inflate.write(e),t&&this._inflate.write(c),this._inflate.flush(()=>{let e=this._inflate[p];if(e){this._inflate.close(),this._inflate=null,n(e);return}let r=i.concat(this._inflate[f],this._inflate[u]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[u]=0,this._inflate[f]=[],t&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),n(null,r)})}_compress(e,t,n){let a=this._isServer?`server`:`client`;if(!this._deflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:r.Z_DEFAULT_WINDOWBITS;this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[u]=0,this._deflate[f]=[],this._deflate.on(`data`,h)}this._deflate[d]=n,this._deflate.write(e),this._deflate.flush(r.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=i.concat(this._deflate[f],this._deflate[u]);t&&(e=new s(e.buffer,e.byteOffset,e.length-4)),this._deflate[d]=null,this._deflate[u]=0,this._deflate[f]=[],t&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),n(null,e)})}};function h(e){this[f].push(e),this[u]+=e.length}function g(e){if(this[u]+=e.length,this[l]._maxPayload<1||this[u]<=this[l]._maxPayload){this[f].push(e);return}this[p]=RangeError(`Max payload size exceeded`),this[p].code=`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`,this[p][o]=1009,this.removeListener(`data`,g),this.reset()}function _(e){if(this[l]._inflate=null,this[p]){this[d](this[p]);return}e[o]=1007,this[d](e)}})),i5=i(((e,n)=>{let{isUtf8:r}=t(`buffer`),{hasBlob:i}=t5(),a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function o(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function s(e){let t=e.length,n=0;for(;n<t;)if(!(e[n]&128))n++;else if((e[n]&224)==192){if(n+1===t||(e[n+1]&192)!=128||(e[n]&254)==192)return!1;n+=2}else if((e[n]&240)==224){if(n+2>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||e[n]===224&&(e[n+1]&224)==128||e[n]===237&&(e[n+1]&224)==160)return!1;n+=3}else if((e[n]&248)==240){if(n+3>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||(e[n+3]&192)!=128||e[n]===240&&(e[n+1]&240)==128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function c(e){return i&&typeof e==`object`&&typeof e.arrayBuffer==`function`&&typeof e.type==`string`&&typeof e.stream==`function`&&(e[Symbol.toStringTag]===`Blob`||e[Symbol.toStringTag]===`File`)}if(n.exports={isBlob:c,isValidStatusCode:o,isValidUTF8:s,tokenChars:a},r)n.exports.isValidUTF8=function(e){return e.length<24?s(e):r(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=t(`utf-8-validate`);n.exports.isValidUTF8=function(t){return t.length<32?s(t):e(t)}}catch{}})),a5=i(((e,n)=>{let{Writable:r}=t(`stream`),i=r5(),{BINARY_TYPES:a,EMPTY_BUFFER:o,kStatusCode:s,kWebSocket:c}=t5(),{concat:l,toArrayBuffer:u,unmask:d}=n5(),{isValidStatusCode:f,isValidUTF8:p}=i5(),m=Buffer[Symbol.species];n.exports=class extends r{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents===void 0?!0:e.allowSynchronousEvents,this._binaryType=e.binaryType||a[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[c]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(this._opcode===8&&this._state==0)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){n(this.createError(RangeError,`Too many buffered chunks`,!1,1008,`WS_ERR_TOO_MANY_BUFFERED_PARTS`));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new m(t.buffer,t.byteOffset+e,t.length-e),new m(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],r=t.length-e;e>=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=new m(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){e(this.createError(RangeError,`RSV2 and RSV3 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_2_3`));return}let n=(t[0]&64)==64;if(n&&!this._extensions[i.extensionName]){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._fin=(t[0]&128)==128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(!this._fragmented){e(this.createError(RangeError,`invalid opcode 0`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){e(this.createError(RangeError,`FIN must be set`,!0,1002,`WS_ERR_EXPECTED_FIN`));return}if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,`WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH`));return}}else{e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)==128,this._isServer){if(!this._masked){e(this.createError(RangeError,`MASK must be set`,!0,1002,`WS_ERR_EXPECTED_MASK`));return}}else if(this._masked){e(this.createError(RangeError,`MASK must be clear`,!0,1002,`WS_ERR_UNEXPECTED_MASK`));return}this._payloadLength===126?this._state=1:this._payloadLength===127?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),n=t.readUInt32BE(0);if(n>2**21-1){e(this.createError(RangeError,`Unsupported WebSocket frame: payload length > 2^53 - 1`,!1,1009,`WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH`));return}this._payloadLength=n*2**32+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=o;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&d(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=5,this.decompress(t,e);return}if(t.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){e(this.createError(RangeError,`Too many message fragments`,!1,1008,`WS_ERR_TOO_MANY_BUFFERED_PARTS`));return}this._messageLength=this._totalPayloadLength,this._fragments.push(t)}this.dataMessage(e)}decompress(e,t){this._extensions[i.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){t(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){t(this.createError(RangeError,`Too many message fragments`,!1,1008,`WS_ERR_TOO_MANY_BUFFERED_PARTS`));return}this._fragments.push(n)}this.dataMessage(t),this._state===0&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;r=this._binaryType===`nodebuffer`?l(n,t):this._binaryType===`arraybuffer`?u(l(n,t)):this._binaryType===`blob`?new Blob(n):n,this._allowSynchronousEvents?(this.emit(`message`,r,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!0),this._state=0,this.startLoop(e)}))}else{let r=l(n,t);if(!this._skipUTF8Validation&&!p(r)){e(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._state===5||this._allowSynchronousEvents?(this.emit(`message`,r,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit(`conclude`,1005,o),this.end();else{let n=e.readUInt16BE(0);if(!f(n)){t(this.createError(RangeError,`invalid status code ${n}`,!0,1002,`WS_ERR_INVALID_CLOSE_CODE`));return}let r=new m(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!p(r)){t(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._loop=!1,this.emit(`conclude`,n,r),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0,this.startLoop(t)}))}createError(e,t,n,r,i){this._loop=!1,this._errored=!0;let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=i,a[s]=r,a}}})),o5=i(((e,n)=>{let{Duplex:r}=t(`stream`),{randomFillSync:i}=t(`crypto`),{types:{isUint8Array:a}}=t(`util`),o=r5(),{EMPTY_BUFFER:s,kWebSocket:c,NOOP:l}=t5(),{isBlob:u,isValidStatusCode:d}=i5(),{mask:f,toBuffer:p}=n5(),m=Symbol(`kByteLength`),h=Buffer.alloc(4),g=8*1024,_,v=g;n.exports=class e{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=l,this[c]=void 0}static frame(e,t){let n,r=!1,a=2,o=!1;t.mask&&(n=t.maskBuffer||h,t.generateMask?t.generateMask(n):(v===g&&(_===void 0&&(_=Buffer.alloc(g)),i(_,0,g),v=0),n[0]=_[v++],n[1]=_[v++],n[2]=_[v++],n[3]=_[v++]),o=(n[0]|n[1]|n[2]|n[3])===0,a=6);let s;typeof e==`string`?(!t.mask||o)&&t[m]!==void 0?s=t[m]:(e=Buffer.from(e),s=e.length):(s=e.length,r=t.mask&&t.readOnly&&!o);let c=s;s>=65536?(a+=8,c=127):s>125&&(a+=2,c=126);let l=Buffer.allocUnsafe(r?s+a:a);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(s,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),!t.mask||(l[1]|=128,l[a-4]=n[0],l[a-3]=n[1],l[a-2]=n[2],l[a-1]=n[3],o)?[l,e]:r?(f(e,n,l,a,s),[l]):(f(e,n,e,0,s),[l,e])}close(t,n,r,i){let o;if(t===void 0)o=s;else if(typeof t!=`number`||!d(t))throw TypeError(`First argument must be a valid error code number`);else if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let e=Buffer.byteLength(n);if(e>123)throw RangeError(`The message must not be greater than 123 bytes`);if(o=Buffer.allocUnsafe(2+e),o.writeUInt16BE(t,0),typeof n==`string`)o.write(n,2);else if(a(n))o.set(n,2);else throw TypeError(`Second argument must be a string or a Uint8Array`)}let c={[m]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state===0?this.sendFrame(e.frame(o,c),i):this.enqueue([this.dispatch,o,!1,c,i])}ping(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):u(t)?(i=t.size,a=!1):(t=p(t),i=t.length,a=p.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[m]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};u(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}pong(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):u(t)?(i=t.size,a=!1):(t=p(t),i=t.length,a=p.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[m]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};u(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}send(e,t,n){let r=this._extensions[o.extensionName],i=t.binary?2:1,a=t.compress,s,c;typeof e==`string`?(s=Buffer.byteLength(e),c=!1):u(e)?(s=e.size,c=!1):(e=p(e),s=e.length,c=p.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?`server_no_context_takeover`:`client_no_context_takeover`]&&(a=s>=r._threshold),this._compress=a):(a=!1,i=0),t.fin&&(this._firstFragment=!0);let l={[m]:s,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:a};u(e)?this._state===0?this.getBlobData(e,this._compress,l,n):this.enqueue([this.getBlobData,e,this._compress,l,n]):this._state===0?this.dispatch(e,this._compress,l,n):this.enqueue([this.dispatch,e,this._compress,l,n])}getBlobData(t,n,r,i){this._bufferedBytes+=r[m],this._state=2,t.arrayBuffer().then(t=>{if(this._socket.destroyed){let e=Error(`The socket was closed while the blob was being read`);process.nextTick(y,this,e,i);return}this._bufferedBytes-=r[m];let a=p(t);n?this.dispatch(a,n,r,i):(this._state=0,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(e=>{process.nextTick(b,this,e,i)})}dispatch(t,n,r,i){if(!n){this.sendFrame(e.frame(t,r),i);return}let a=this._extensions[o.extensionName];this._bufferedBytes+=r[m],this._state=1,a.compress(t,r.fin,(t,n)=>{if(this._socket.destroyed){let e=Error(`The socket was closed while data was being compressed`);y(this,e,i);return}this._bufferedBytes-=r[m],this._state=0,r.readOnly=!1,this.sendFrame(e.frame(n,r),i),this.dequeue()})}dequeue(){for(;this._state===0&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][m],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][m],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};function y(e,t,n){typeof n==`function`&&n(t);for(let n=0;n<e._queue.length;n++){let r=e._queue[n],i=r[r.length-1];typeof i==`function`&&i(t)}}function b(e,t,n){y(e,t,n),e.onerror(t)}})),OSe=i(((e,t)=>{let{kForOnEventAttribute:n,kListener:r}=t5(),i=Symbol(`kCode`),a=Symbol(`kData`),o=Symbol(`kError`),s=Symbol(`kMessage`),c=Symbol(`kReason`),l=Symbol(`kTarget`),u=Symbol(`kType`),d=Symbol(`kWasClean`);var f=class{constructor(e){this[l]=null,this[u]=e}get target(){return this[l]}get type(){return this[u]}};Object.defineProperty(f.prototype,`target`,{enumerable:!0}),Object.defineProperty(f.prototype,`type`,{enumerable:!0});var p=class extends f{constructor(e,t={}){super(e),this[i]=t.code===void 0?0:t.code,this[c]=t.reason===void 0?``:t.reason,this[d]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[i]}get reason(){return this[c]}get wasClean(){return this[d]}};Object.defineProperty(p.prototype,`code`,{enumerable:!0}),Object.defineProperty(p.prototype,`reason`,{enumerable:!0}),Object.defineProperty(p.prototype,`wasClean`,{enumerable:!0});var m=class extends f{constructor(e,t={}){super(e),this[o]=t.error===void 0?null:t.error,this[s]=t.message===void 0?``:t.message}get error(){return this[o]}get message(){return this[s]}};Object.defineProperty(m.prototype,`error`,{enumerable:!0}),Object.defineProperty(m.prototype,`message`,{enumerable:!0});var h=class extends f{constructor(e,t={}){super(e),this[a]=t.data===void 0?null:t.data}get data(){return this[a]}};Object.defineProperty(h.prototype,`data`,{enumerable:!0}),t.exports={CloseEvent:p,ErrorEvent:m,Event:f,EventTarget:{addEventListener(e,t,i={}){for(let a of this.listeners(e))if(!i[n]&&a[r]===t&&!a[n])return;let a;if(e===`message`)a=function(e,n){let r=new h(`message`,{data:n?e:e.toString()});r[l]=this,g(t,this,r)};else if(e===`close`)a=function(e,n){let r=new p(`close`,{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[l]=this,g(t,this,r)};else if(e===`error`)a=function(e){let n=new m(`error`,{error:e,message:e.message});n[l]=this,g(t,this,n)};else if(e===`open`)a=function(){let e=new f(`open`);e[l]=this,g(t,this,e)};else return;a[n]=!!i[n],a[r]=t,i.once?this.once(e,a):this.on(e,a)},removeEventListener(e,t){for(let i of this.listeners(e))if(i[r]===t&&!i[n]){this.removeListener(e,i);break}}},MessageEvent:h};function g(e,t,n){typeof e==`object`&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}})),s5=i(((e,t)=>{let{tokenChars:n}=i5();function r(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function i(e){let t=Object.create(null),i=Object.create(null),a=!1,o=!1,s=!1,c,l,u=-1,d=-1,f=-1,p=0;for(;p<e.length;p++)if(d=e.charCodeAt(p),c===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(p!==0&&(d===32||d===9))f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);d===44?(r(t,n,i),i=Object.create(null)):c=n,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);else if(l===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(d===32||d===9)f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p),r(i,e.slice(u,f),!0),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),u=f=-1}else if(d===61&&u!==-1&&f===-1)l=e.slice(u,p),u=f=-1;else throw SyntaxError(`Unexpected character at index ${p}`);else if(o){if(n[d]!==1)throw SyntaxError(`Unexpected character at index ${p}`);u===-1?u=p:a||=!0,o=!1}else if(s)if(n[d]===1)u===-1&&(u=p);else if(d===34&&u!==-1)s=!1,f=p;else if(d===92)o=!0;else throw SyntaxError(`Unexpected character at index ${p}`);else if(d===34&&e.charCodeAt(p-1)===61)s=!0;else if(f===-1&&n[d]===1)u===-1&&(u=p);else if(u!==-1&&(d===32||d===9))f===-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);a&&=(n=n.replace(/\\/g,``),!1),r(i,l,n),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),l=void 0,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);if(u===-1||s||d===32||d===9)throw SyntaxError(`Unexpected end of input`);f===-1&&(f=p);let m=e.slice(u,f);return c===void 0?r(t,m,i):(l===void 0?r(i,m,!0):a?r(i,l,m.replace(/\\/g,``)):r(i,l,m),r(t,c,i)),t}function a(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>e===!0?t:`${t}=${e}`).join(`; `)})).join(`; `)).join(`, `)}).join(`, `)}t.exports={format:a,parse:i}})),c5=i(((e,n)=>{let r=t(`events`),i=t(`https`),a=t(`http`),o=t(`net`),s=t(`tls`),{randomBytes:c,createHash:l}=t(`crypto`),{Duplex:u,Readable:d}=t(`stream`),{URL:f}=t(`url`),p=r5(),m=a5(),h=o5(),{isBlob:g}=i5(),{BINARY_TYPES:_,CLOSE_TIMEOUT:v,EMPTY_BUFFER:y,GUID:b,kForOnEventAttribute:x,kListener:S,kStatusCode:C,kWebSocket:w,NOOP:T}=t5(),{EventTarget:{addEventListener:E,removeEventListener:D}}=OSe(),{format:O,parse:ee}=s5(),{toBuffer:te}=n5(),ne=Symbol(`kAborted`),re=[8,13],ie=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],ae=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;var oe=class e extends r{constructor(t,n,r){super(),this._binaryType=_[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=y,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol=``,this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t===null?(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0):(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n==`object`&&n?(r=n,n=[]):n=[n]),se(this,t,n,r))}get binaryType(){return this._binaryType}set binaryType(e){_.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,r){let i=new m({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),a=new h(t,this._extensions,r.generateMask);this._receiver=i,this._sender=a,this._socket=t,i[w]=this,a[w]=this,t[w]=this,i.on(`conclude`,j),i.on(`drain`,de),i.on(`error`,fe),i.on(`message`,me),i.on(`ping`,M),i.on(`pong`,N),a.onerror=ge,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on(`close`,ve),t.on(`data`,ye),t.on(`end`,be),t.on(`error`,xe),this._readyState=e.OPEN,this.emit(`open`)}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage);return}this._extensions[p.extensionName]&&this._extensions[p.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){ue(this,this._req,`WebSocket was closed before the connection was established`);return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),_e(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){A(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||y,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){A(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||y,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof n==`function`&&(r=n,n={}),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){A(this,t,r);return}let i={binary:typeof t!=`string`,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[p.extensionName]||(i.compress=!1),this._sender.send(t||y,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){ue(this,this._req,`WebSocket was closed before the connection was established`);return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(oe,`CONNECTING`,{enumerable:!0,value:ie.indexOf(`CONNECTING`)}),Object.defineProperty(oe.prototype,`CONNECTING`,{enumerable:!0,value:ie.indexOf(`CONNECTING`)}),Object.defineProperty(oe,`OPEN`,{enumerable:!0,value:ie.indexOf(`OPEN`)}),Object.defineProperty(oe.prototype,`OPEN`,{enumerable:!0,value:ie.indexOf(`OPEN`)}),Object.defineProperty(oe,`CLOSING`,{enumerable:!0,value:ie.indexOf(`CLOSING`)}),Object.defineProperty(oe.prototype,`CLOSING`,{enumerable:!0,value:ie.indexOf(`CLOSING`)}),Object.defineProperty(oe,`CLOSED`,{enumerable:!0,value:ie.indexOf(`CLOSED`)}),Object.defineProperty(oe.prototype,`CLOSED`,{enumerable:!0,value:ie.indexOf(`CLOSED`)}),[`binaryType`,`bufferedAmount`,`extensions`,`isPaused`,`protocol`,`readyState`,`url`].forEach(e=>{Object.defineProperty(oe.prototype,e,{enumerable:!0})}),[`open`,`error`,`close`,`message`].forEach(e=>{Object.defineProperty(oe.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[x])return t[S];return null},set(t){for(let t of this.listeners(e))if(t[x]){this.removeListener(e,t);break}typeof t==`function`&&this.addEventListener(e,t,{[x]:!0})}})}),oe.prototype.addEventListener=E,oe.prototype.removeEventListener=D,n.exports=oe;function se(e,t,n,r){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:v,protocolVersion:re[1],maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:`GET`,host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!re.includes(o.protocolVersion))throw RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${re.join(`, `)})`);let s;if(t instanceof f)s=t;else try{s=new f(t)}catch{throw SyntaxError(`Invalid URL: ${t}`)}s.protocol===`http:`?s.protocol=`ws:`:s.protocol===`https:`&&(s.protocol=`wss:`),e._url=s.href;let u=s.protocol===`wss:`,d=s.protocol===`ws+unix:`,m;if(s.protocol!==`ws:`&&!u&&!d?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:d&&!s.pathname?m=`The URL's pathname is empty`:s.hash&&(m=`The URL contains a fragment identifier`),m){let t=SyntaxError(m);if(e._redirects===0)throw t;k(e,t);return}let h=u?443:80,g=c(16).toString(`base64`),_=u?i.request:a.request,y=new Set,x;if(o.createConnection=o.createConnection||(u?le:ce),o.defaultPort=o.defaultPort||h,o.port=s.port||h,o.host=s.hostname.startsWith(`[`)?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":g,Connection:`Upgrade`,Upgrade:`websocket`},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(x=new p({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers[`Sec-WebSocket-Extensions`]=O({[p.extensionName]:x.offer()})),n.length){for(let e of n){if(typeof e!=`string`||!ae.test(e)||y.has(e))throw SyntaxError(`An invalid or duplicated subprotocol was specified`);y.add(e)}o.headers[`Sec-WebSocket-Protocol`]=n.join(`,`)}if(o.origin&&(o.protocolVersion<13?o.headers[`Sec-WebSocket-Origin`]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}:${s.password}`),d){let e=o.path.split(`:`);o.socketPath=e[0],o.path=e[1]}let S;if(o.followRedirects){if(e._redirects===0){e._originalIpc=d,e._originalSecure=u,e._originalHostOrSocketPath=d?o.socketPath:s.host;let t=r&&r.headers;if(r={...r,headers:{}},t)for(let[e,n]of Object.entries(t))r.headers[e.toLowerCase()]=n}else if(e.listenerCount(`redirect`)===0){let t=d?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:s.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!u)&&(delete o.headers.authorization,delete o.headers.cookie,t||delete o.headers.host,o.auth=void 0)}o.auth&&!r.headers.authorization&&(r.headers.authorization=`Basic `+Buffer.from(o.auth).toString(`base64`)),S=e._req=_(o),e._redirects&&e.emit(`redirect`,e.url,S)}else S=e._req=_(o);o.timeout&&S.on(`timeout`,()=>{ue(e,S,`Opening handshake has timed out`)}),S.on(`error`,t=>{S===null||S[ne]||(S=e._req=null,k(e,t))}),S.on(`response`,i=>{let a=i.headers.location,s=i.statusCode;if(a&&o.followRedirects&&s>=300&&s<400){if(++e._redirects>o.maxRedirects){ue(e,S,`Maximum redirects exceeded`);return}S.abort();let i;try{i=new f(a,t)}catch{k(e,SyntaxError(`Invalid URL: ${a}`));return}se(e,i,n,r)}else e.emit(`unexpected-response`,S,i)||ue(e,S,`Unexpected server response: ${i.statusCode}`)}),S.on(`upgrade`,(t,n,r)=>{if(e.emit(`upgrade`,t),e.readyState!==oe.CONNECTING)return;S=e._req=null;let i=t.headers.upgrade;if(i===void 0||i.toLowerCase()!==`websocket`){ue(e,n,`Invalid Upgrade header`);return}let a=l(`sha1`).update(g+b).digest(`base64`);if(t.headers[`sec-websocket-accept`]!==a){ue(e,n,`Invalid Sec-WebSocket-Accept header`);return}let s=t.headers[`sec-websocket-protocol`],c;if(s===void 0?y.size&&(c=`Server sent no subprotocol`):y.size?y.has(s)||(c=`Server sent an invalid subprotocol`):c=`Server sent a subprotocol but none was requested`,c){ue(e,n,c);return}s&&(e._protocol=s);let u=t.headers[`sec-websocket-extensions`];if(u!==void 0){if(!x){ue(e,n,`Server sent a Sec-WebSocket-Extensions header but no extension was requested`);return}let t;try{t=ee(u)}catch{ue(e,n,`Invalid Sec-WebSocket-Extensions header`);return}let r=Object.keys(t);if(r.length!==1||r[0]!==p.extensionName){ue(e,n,`Server indicated an extension that was not requested`);return}try{x.accept(t[p.extensionName])}catch{ue(e,n,`Invalid Sec-WebSocket-Extensions header`);return}e._extensions[p.extensionName]=x}e.setSocket(n,r,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,e):S.end()}function k(e,t){e._readyState=oe.CLOSING,e._errorEmitted=!0,e.emit(`error`,t),e.emitClose()}function ce(e){return e.path=e.socketPath,o.connect(e)}function le(e){return e.path=void 0,!e.servername&&e.servername!==``&&(e.servername=o.isIP(e.host)?``:e.host),s.connect(e)}function ue(e,t,n){e._readyState=oe.CLOSING;let r=Error(n);Error.captureStackTrace(r,ue),t.setHeader?(t[ne]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(k,e,r)):(t.destroy(r),t.once(`error`,e.emit.bind(e,`error`)),t.once(`close`,e.emitClose.bind(e)))}function A(e,t,n){if(t){let n=g(t)?t.size:te(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${ie[e.readyState]})`);process.nextTick(n,t)}}function j(e,t){let n=this[w];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[w]!==void 0&&(n._socket.removeListener(`data`,ye),process.nextTick(he,n._socket),e===1005?n.close():n.close(e,t))}function de(){let e=this[w];e.isPaused||e._socket.resume()}function fe(e){let t=this[w];t._socket[w]!==void 0&&(t._socket.removeListener(`data`,ye),process.nextTick(he,t._socket),t.close(e[C])),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e))}function pe(){this[w].emitClose()}function me(e,t){this[w].emit(`message`,e,t)}function M(e){let t=this[w];t._autoPong&&t.pong(e,!this._isServer,T),t.emit(`ping`,e)}function N(e){this[w].emit(`pong`,e)}function he(e){e.resume()}function ge(e){let t=this[w];t.readyState!==oe.CLOSED&&(t.readyState===oe.OPEN&&(t._readyState=oe.CLOSING,_e(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e)))}function _e(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function ve(){let e=this[w];if(this.removeListener(`close`,ve),this.removeListener(`data`,ye),this.removeListener(`end`,be),e._readyState=oe.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[w]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on(`error`,pe),e._receiver.on(`finish`,pe))}function ye(e){this[w]._receiver.write(e)||this.pause()}function be(){let e=this[w];e._readyState=oe.CLOSING,e._receiver.end(),this.end()}function xe(){let e=this[w];this.removeListener(`error`,xe),this.on(`error`,T),e&&(e._readyState=oe.CLOSING,this.destroy())}})),kSe=i(((e,n)=>{c5();let{Duplex:r}=t(`stream`);function i(e){e.emit(`close`)}function a(){!this.destroyed&&this._writableState.finished&&this.destroy()}function o(e){this.removeListener(`error`,o),this.destroy(),this.listenerCount(`error`)===0&&this.emit(`error`,e)}function s(e,t){let n=!0,s=new r({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on(`message`,function(t,n){let r=!n&&s._readableState.objectMode?t.toString():t;s.push(r)||e.pause()}),e.once(`error`,function(e){s.destroyed||(n=!1,s.destroy(e))}),e.once(`close`,function(){s.destroyed||s.push(null)}),s._destroy=function(t,r){if(e.readyState===e.CLOSED){r(t),process.nextTick(i,s);return}let a=!1;e.once(`error`,function(e){a=!0,r(e)}),e.once(`close`,function(){a||r(t),process.nextTick(i,s)}),n&&e.terminate()},s._final=function(t){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._final(t)});return}e._socket!==null&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once(`finish`,function(){t()}),e.close()))},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,n,r){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._write(t,n,r)});return}e.send(t,r)},s.on(`end`,a),s.on(`error`,o),s}n.exports=s})),l5=i(((e,t)=>{let{tokenChars:n}=i5();function r(e){let t=new Set,r=-1,i=-1,a=0;for(;a<e.length;a++){let o=e.charCodeAt(a);if(i===-1&&n[o]===1)r===-1&&(r=a);else if(a!==0&&(o===32||o===9))i===-1&&r!==-1&&(i=a);else if(o===44){if(r===-1)throw SyntaxError(`Unexpected character at index ${a}`);i===-1&&(i=a);let n=e.slice(r,i);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);t.add(n),r=i=-1}else throw SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||i!==-1)throw SyntaxError(`Unexpected end of input`);let o=e.slice(r,a);if(t.has(o))throw SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}t.exports={parse:r}})),ASe=i(((e,n)=>{let r=t(`events`),i=t(`http`),{Duplex:a}=t(`stream`),{createHash:o}=t(`crypto`),s=s5(),c=r5(),l=l5(),u=c5(),{CLOSE_TIMEOUT:d,GUID:f,kWebSocket:p}=t5(),m=/^[+/0-9A-Za-z]{22}==$/;n.exports=class extends r{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:d,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:u,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError(`One and only one of the "port", "server", or "noServer" options must be specified`);if(e.port==null?e.server&&(this._server=e.server):(this._server=i.createServer((e,t)=>{let n=i.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":`text/plain`}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)),this._server){let e=this.emit.bind(this,`connection`);this._removeListeners=h(this._server,{listening:this.emit.bind(this,`listening`),error:this.emit.bind(this,`error`),upgrade:(t,n,r)=>{this.handleUpgrade(t,n,r,e)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error(`The server is operating in "noServer" mode`);return this._server?this._server.address():null}close(e){if(this._state===2){e&&this.once(`close`,()=>{e(Error(`The server is not running`))}),process.nextTick(g,this);return}if(e&&this.once(`close`,e),this._state!==1)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(g,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{g(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf(`?`);if((t===-1?e.url:e.url.slice(0,t))!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,r){t.on(`error`,_);let i=e.headers[`sec-websocket-key`],a=e.headers.upgrade,o=+e.headers[`sec-websocket-version`];if(e.method!==`GET`){y(this,e,t,405,`Invalid HTTP method`);return}if(a===void 0||a.toLowerCase()!==`websocket`){y(this,e,t,400,`Invalid Upgrade header`);return}if(i===void 0||!m.test(i)){y(this,e,t,400,`Missing or invalid Sec-WebSocket-Key header`);return}if(o!==13&&o!==8){y(this,e,t,400,`Missing or invalid Sec-WebSocket-Version header`,{"Sec-WebSocket-Version":`13, 8`});return}if(!this.shouldHandle(e)){v(t,400);return}let u=e.headers[`sec-websocket-protocol`],d=new Set;if(u!==void 0)try{d=l.parse(u)}catch{y(this,e,t,400,`Invalid Sec-WebSocket-Protocol header`);return}let f=e.headers[`sec-websocket-extensions`],p={};if(this.options.perMessageDeflate&&f!==void 0){let n=new c({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let e=s.parse(f);e[c.extensionName]&&(n.accept(e[c.extensionName]),p[c.extensionName]=n)}catch{y(this,e,t,400,`Invalid or unacceptable Sec-WebSocket-Extensions header`);return}}if(this.options.verifyClient){let a={origin:e.headers[`${o===8?`sec-websocket-origin`:`origin`}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(a,(a,o,s,c)=>{if(!a)return v(t,o||401,s,c);this.completeUpgrade(p,i,d,e,t,n,r)});return}if(!this.options.verifyClient(a))return v(t,401)}this.completeUpgrade(p,i,d,e,t,n,r)}completeUpgrade(e,t,n,r,i,a,l){if(!i.readable||!i.writable)return i.destroy();if(i[p])throw Error(`server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration`);if(this._state>0)return v(i,503);let u=[`HTTP/1.1 101 Switching Protocols`,`Upgrade: websocket`,`Connection: Upgrade`,`Sec-WebSocket-Accept: ${o(`sha1`).update(t+f).digest(`base64`)}`],d=new this.options.WebSocket(null,void 0,this.options);if(n.size){let e=this.options.handleProtocols?this.options.handleProtocols(n,r):n.values().next().value;e&&(u.push(`Sec-WebSocket-Protocol: ${e}`),d._protocol=e)}if(e[c.extensionName]){let t=e[c.extensionName].params,n=s.format({[c.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${n}`),d._extensions=e}this.emit(`headers`,u,r),i.write(u.concat(`\r
824
828
  `).join(`\r
825
829
  `)),i.removeListener(`error`,_),d.setSocket(i,a,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(d),d.on(`close`,()=>{this.clients.delete(d),this._shouldEmitClose&&!this.clients.size&&process.nextTick(g,this)})),l(d,r)}};function h(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let n of Object.keys(t))e.removeListener(n,t[n])}}function g(e){e._state=2,e.emit(`close`)}function _(){this.destroy()}function v(e,t,n,r){n||=i.STATUS_CODES[t],r={Connection:`close`,"Content-Type":`text/html`,"Content-Length":Buffer.byteLength(n),...r},e.once(`finish`,e.destroy),e.end(`HTTP/1.1 ${t} ${i.STATUS_CODES[t]}\r\n`+Object.keys(r).map(e=>`${e}: ${r[e]}`).join(`\r
826
830
  `)+`\r
827
831
  \r
828
- `+n)}function y(e,t,n,r,i,a){if(e.listenerCount(`wsClientError`)){let r=Error(i);Error.captureStackTrace(r,y),e.emit(`wsClientError`,r,n,t)}else v(n,r,i,a)}}));OSe(),s5(),r5(),a5(),o5(),l5(),c5(),kSe();let u5,d5,f5,p5,m5=!0;typeof process<`u`&&({FORCE_COLOR:u5,NODE_DISABLE_COLORS:d5,NO_COLOR:f5,TERM:p5}=process.env||{},m5=process.stdout&&process.stdout.isTTY);const h5={enabled:!d5&&f5==null&&p5!==`dumb`&&(u5!=null&&u5!==`0`||m5),reset:_5(0,0),bold:_5(1,22),dim:_5(2,22),italic:_5(3,23),underline:_5(4,24),inverse:_5(7,27),hidden:_5(8,28),strikethrough:_5(9,29),black:_5(30,39),red:_5(31,39),green:_5(32,39),yellow:_5(33,39),blue:_5(34,39),magenta:_5(35,39),cyan:_5(36,39),white:_5(37,39),gray:_5(90,39),grey:_5(90,39),bgBlack:_5(40,49),bgRed:_5(41,49),bgGreen:_5(42,49),bgYellow:_5(43,49),bgBlue:_5(44,49),bgMagenta:_5(45,49),bgCyan:_5(46,49),bgWhite:_5(47,49)};function g5(e,t){let n=0,r,i=``,a=``;for(;n<e.length;n++)r=e[n],i+=r.open,a+=r.close,~t.indexOf(r.close)&&(t=t.replace(r.rgx,r.close+r.open));return i+t+a}function ASe(e,t){let n={has:e,keys:t};return n.reset=h5.reset.bind(n),n.bold=h5.bold.bind(n),n.dim=h5.dim.bind(n),n.italic=h5.italic.bind(n),n.underline=h5.underline.bind(n),n.inverse=h5.inverse.bind(n),n.hidden=h5.hidden.bind(n),n.strikethrough=h5.strikethrough.bind(n),n.black=h5.black.bind(n),n.red=h5.red.bind(n),n.green=h5.green.bind(n),n.yellow=h5.yellow.bind(n),n.blue=h5.blue.bind(n),n.magenta=h5.magenta.bind(n),n.cyan=h5.cyan.bind(n),n.white=h5.white.bind(n),n.gray=h5.gray.bind(n),n.grey=h5.grey.bind(n),n.bgBlack=h5.bgBlack.bind(n),n.bgRed=h5.bgRed.bind(n),n.bgGreen=h5.bgGreen.bind(n),n.bgYellow=h5.bgYellow.bind(n),n.bgBlue=h5.bgBlue.bind(n),n.bgMagenta=h5.bgMagenta.bind(n),n.bgCyan=h5.bgCyan.bind(n),n.bgWhite=h5.bgWhite.bind(n),n}function _5(e,t){let n={open:`\x1b[${e}m`,close:`\x1b[${t}m`,rgx:RegExp(`\\x1b\\[${t}m`,`g`)};return function(t){return this!==void 0&&this.has!==void 0?(~this.has.indexOf(e)||(this.has.push(e),this.keys.push(n)),t===void 0?this:h5.enabled?g5(this.keys,t+``):t+``):t===void 0?ASe([e],[n]):h5.enabled?g5([n],t+``):t+``}}Number.isNaN,Number.isInteger,Number.isNaN,Number.parseInt,Array.from,Array.isArray;const jSe=String.fromCharCode;String.fromCodePoint,jSe(65535);const v5=typeof TextEncoder<`u`?new TextEncoder:null;let y5=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});y5&&y5.decode(new Uint8Array).length===1&&(y5=null);const b5=e=>Error(e);new Uint8Array(3e4).length/3,v5&&v5.encodeInto,b5(`Unexpected end of array`),b5(`Integer out of Range`),Date.now;var x5=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),S5=o(import.meta.url),C5=x5(((e,t)=>{let n=[`nodebuffer`,`arraybuffer`,`fragments`],r=typeof Blob<`u`;r&&n.push(`blob`),t.exports={BINARY_TYPES:n,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,hasBlob:r,kForOnEventAttribute:Symbol(`kIsForOnEventAttribute`),kListener:Symbol(`kListener`),kStatusCode:Symbol(`status-code`),kWebSocket:Symbol(`websocket`),NOOP:()=>{}}})),w5=x5(((e,t)=>{let{EMPTY_BUFFER:n}=C5(),r=Buffer[Symbol.species];function i(e,t){if(e.length===0)return n;if(e.length===1)return e[0];let i=Buffer.allocUnsafe(t),a=0;for(let t=0;t<e.length;t++){let n=e[t];i.set(n,a),a+=n.length}return a<t?new r(i.buffer,i.byteOffset,a):i}function a(e,t,n,r,i){for(let a=0;a<i;a++)n[r+a]=e[a]^t[a&3]}function o(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function s(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function c(e){if(c.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new r(e):ArrayBuffer.isView(e)?t=new r(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),c.readOnly=!1),t}if(t.exports={concat:i,mask:a,toArrayBuffer:s,toBuffer:c,unmask:o},!process.env.WS_NO_BUFFER_UTIL)try{let e=S5(`bufferutil`);t.exports.mask=function(t,n,r,i,o){o<48?a(t,n,r,i,o):e.mask(t,n,r,i,o)},t.exports.unmask=function(t,n){t.length<32?o(t,n):e.unmask(t,n)}}catch{}})),MSe=x5(((e,t)=>{let n=Symbol(`kDone`),r=Symbol(`kRun`);t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[n])}}}})),T5=x5(((e,t)=>{let n=S5(`zlib`),r=w5(),i=MSe(),{kStatusCode:a}=C5(),o=Buffer[Symbol.species],s=Buffer.from([0,0,255,255]),c=Symbol(`permessage-deflate`),l=Symbol(`total-length`),u=Symbol(`callback`),d=Symbol(`buffers`),f=Symbol(`error`),p;t.exports=class{constructor(e,t,n){this._maxPayload=n|0,this._options=e||{},this._threshold=this._options.threshold===void 0?1024:this._options.threshold,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,p||=new i(this._options.concurrencyLimit===void 0?10:this._options.concurrencyLimit)}static get extensionName(){return`permessage-deflate`}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits??(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&=(this._inflate.close(),null),this._deflate){let e=this._deflate[u];this._deflate.close(),this._deflate=null,e&&e(Error(`The deflate stream was closed while data was being processed`))}}acceptAsServer(e){let t=this._options,n=e.find(e=>!(t.serverNoContextTakeover===!1&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits==`number`&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==`number`&&!e.client_max_window_bits));if(!n)throw Error(`None of the extension offers can be accepted`);return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits==`number`&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits==`number`?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw Error(`Unexpected parameter "client_no_context_takeover"`);if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits==`number`&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==`number`&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error(`Unexpected or invalid parameter "client_max_window_bits"`);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(n=n[0],t===`client_max_window_bits`){if(n!==!0){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else if(t===`server_max_window_bits`){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(t===`client_no_context_takeover`||t===`server_no_context_takeover`){if(n!==!0)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=n})}),e}decompress(e,t,n){p.add(r=>{this._decompress(e,t,(e,t)=>{r(),n(e,t)})})}compress(e,t,n){p.add(r=>{this._compress(e,t,(e,t)=>{r(),n(e,t)})})}_decompress(e,t,i){let a=this._isServer?`client`:`server`;if(!this._inflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._inflate=n.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[l]=0,this._inflate[d]=[],this._inflate.on(`error`,g),this._inflate.on(`data`,h)}this._inflate[u]=i,this._inflate.write(e),t&&this._inflate.write(s),this._inflate.flush(()=>{let e=this._inflate[f];if(e){this._inflate.close(),this._inflate=null,i(e);return}let n=r.concat(this._inflate[d],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[d]=[],t&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),i(null,n)})}_compress(e,t,i){let a=this._isServer?`server`:`client`;if(!this._deflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._deflate=n.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[d]=[],this._deflate.on(`data`,m)}this._deflate[u]=i,this._deflate.write(e),this._deflate.flush(n.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=r.concat(this._deflate[d],this._deflate[l]);t&&(e=new o(e.buffer,e.byteOffset,e.length-4)),this._deflate[u]=null,this._deflate[l]=0,this._deflate[d]=[],t&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),i(null,e)})}};function m(e){this[d].push(e),this[l]+=e.length}function h(e){if(this[l]+=e.length,this[c]._maxPayload<1||this[l]<=this[c]._maxPayload){this[d].push(e);return}this[f]=RangeError(`Max payload size exceeded`),this[f].code=`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`,this[f][a]=1009,this.removeListener(`data`,h),this.reset()}function g(e){if(this[c]._inflate=null,this[f]){this[u](this[f]);return}e[a]=1007,this[u](e)}})),E5=x5(((e,t)=>{let{isUtf8:n}=S5(`buffer`),{hasBlob:r}=C5(),i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function a(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function o(e){let t=e.length,n=0;for(;n<t;)if(!(e[n]&128))n++;else if((e[n]&224)==192){if(n+1===t||(e[n+1]&192)!=128||(e[n]&254)==192)return!1;n+=2}else if((e[n]&240)==224){if(n+2>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||e[n]===224&&(e[n+1]&224)==128||e[n]===237&&(e[n+1]&224)==160)return!1;n+=3}else if((e[n]&248)==240){if(n+3>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||(e[n+3]&192)!=128||e[n]===240&&(e[n+1]&240)==128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function s(e){return r&&typeof e==`object`&&typeof e.arrayBuffer==`function`&&typeof e.type==`string`&&typeof e.stream==`function`&&(e[Symbol.toStringTag]===`Blob`||e[Symbol.toStringTag]===`File`)}if(t.exports={isBlob:s,isValidStatusCode:a,isValidUTF8:o,tokenChars:i},n)t.exports.isValidUTF8=function(e){return e.length<24?o(e):n(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=S5(`utf-8-validate`);t.exports.isValidUTF8=function(t){return t.length<32?o(t):e(t)}}catch{}})),D5=x5(((e,t)=>{let{Writable:n}=S5(`stream`),r=T5(),{BINARY_TYPES:i,EMPTY_BUFFER:a,kStatusCode:o,kWebSocket:s}=C5(),{concat:c,toArrayBuffer:l,unmask:u}=w5(),{isValidStatusCode:d,isValidUTF8:f}=E5(),p=Buffer[Symbol.species];t.exports=class extends n{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents===void 0?!0:e.allowSynchronousEvents,this._binaryType=e.binaryType||i[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[s]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(this._opcode===8&&this._state==0)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new p(t.buffer,t.byteOffset+e,t.length-e),new p(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],r=t.length-e;e>=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=new p(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){e(this.createError(RangeError,`RSV2 and RSV3 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_2_3`));return}let n=(t[0]&64)==64;if(n&&!this._extensions[r.extensionName]){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._fin=(t[0]&128)==128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(!this._fragmented){e(this.createError(RangeError,`invalid opcode 0`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){e(this.createError(RangeError,`FIN must be set`,!0,1002,`WS_ERR_EXPECTED_FIN`));return}if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,`WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH`));return}}else{e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)==128,this._isServer){if(!this._masked){e(this.createError(RangeError,`MASK must be set`,!0,1002,`WS_ERR_EXPECTED_MASK`));return}}else if(this._masked){e(this.createError(RangeError,`MASK must be clear`,!0,1002,`WS_ERR_UNEXPECTED_MASK`));return}this._payloadLength===126?this._state=1:this._payloadLength===127?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),n=t.readUInt32BE(0);if(n>2**21-1){e(this.createError(RangeError,`Unsupported WebSocket frame: payload length > 2^53 - 1`,!1,1009,`WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH`));return}this._payloadLength=n*2**32+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=a;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&u(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=5,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[r.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){t(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._fragments.push(n)}this.dataMessage(t),this._state===0&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;r=this._binaryType===`nodebuffer`?c(n,t):this._binaryType===`arraybuffer`?l(c(n,t)):this._binaryType===`blob`?new Blob(n):n,this._allowSynchronousEvents?(this.emit(`message`,r,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!0),this._state=0,this.startLoop(e)}))}else{let r=c(n,t);if(!this._skipUTF8Validation&&!f(r)){e(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._state===5||this._allowSynchronousEvents?(this.emit(`message`,r,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit(`conclude`,1005,a),this.end();else{let n=e.readUInt16BE(0);if(!d(n)){t(this.createError(RangeError,`invalid status code ${n}`,!0,1002,`WS_ERR_INVALID_CLOSE_CODE`));return}let r=new p(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!f(r)){t(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._loop=!1,this.emit(`conclude`,n,r),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0,this.startLoop(t)}))}createError(e,t,n,r,i){this._loop=!1,this._errored=!0;let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=i,a[o]=r,a}}})),O5=x5(((e,t)=>{let{Duplex:n}=S5(`stream`),{randomFillSync:r}=S5(`crypto`),i=T5(),{EMPTY_BUFFER:a,kWebSocket:o,NOOP:s}=C5(),{isBlob:c,isValidStatusCode:l}=E5(),{mask:u,toBuffer:d}=w5(),f=Symbol(`kByteLength`),p=Buffer.alloc(4),m=8*1024,h,g=m;t.exports=class e{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=s,this[o]=void 0}static frame(e,t){let n,i=!1,a=2,o=!1;t.mask&&(n=t.maskBuffer||p,t.generateMask?t.generateMask(n):(g===m&&(h===void 0&&(h=Buffer.alloc(m)),r(h,0,m),g=0),n[0]=h[g++],n[1]=h[g++],n[2]=h[g++],n[3]=h[g++]),o=(n[0]|n[1]|n[2]|n[3])===0,a=6);let s;typeof e==`string`?(!t.mask||o)&&t[f]!==void 0?s=t[f]:(e=Buffer.from(e),s=e.length):(s=e.length,i=t.mask&&t.readOnly&&!o);let c=s;s>=65536?(a+=8,c=127):s>125&&(a+=2,c=126);let l=Buffer.allocUnsafe(i?s+a:a);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(s,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),!t.mask||(l[1]|=128,l[a-4]=n[0],l[a-3]=n[1],l[a-2]=n[2],l[a-1]=n[3],o)?[l,e]:i?(u(e,n,l,a,s),[l]):(u(e,n,e,0,s),[l,e])}close(t,n,r,i){let o;if(t===void 0)o=a;else if(typeof t!=`number`||!l(t))throw TypeError(`First argument must be a valid error code number`);else if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let e=Buffer.byteLength(n);if(e>123)throw RangeError(`The message must not be greater than 123 bytes`);o=Buffer.allocUnsafe(2+e),o.writeUInt16BE(t,0),typeof n==`string`?o.write(n,2):o.set(n,2)}let s={[f]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state===0?this.sendFrame(e.frame(o,s),i):this.enqueue([this.dispatch,o,!1,s,i])}ping(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):c(t)?(i=t.size,a=!1):(t=d(t),i=t.length,a=d.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[f]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};c(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}pong(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):c(t)?(i=t.size,a=!1):(t=d(t),i=t.length,a=d.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[f]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};c(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}send(e,t,n){let r=this._extensions[i.extensionName],a=t.binary?2:1,o=t.compress,s,l;typeof e==`string`?(s=Buffer.byteLength(e),l=!1):c(e)?(s=e.size,l=!1):(e=d(e),s=e.length,l=d.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?`server_no_context_takeover`:`client_no_context_takeover`]&&(o=s>=r._threshold),this._compress=o):(o=!1,a=0),t.fin&&(this._firstFragment=!0);let u={[f]:s,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:l,rsv1:o};c(e)?this._state===0?this.getBlobData(e,this._compress,u,n):this.enqueue([this.getBlobData,e,this._compress,u,n]):this._state===0?this.dispatch(e,this._compress,u,n):this.enqueue([this.dispatch,e,this._compress,u,n])}getBlobData(t,n,r,i){this._bufferedBytes+=r[f],this._state=2,t.arrayBuffer().then(t=>{if(this._socket.destroyed){let e=Error(`The socket was closed while the blob was being read`);process.nextTick(_,this,e,i);return}this._bufferedBytes-=r[f];let a=d(t);n?this.dispatch(a,n,r,i):(this._state=0,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(e=>{process.nextTick(v,this,e,i)})}dispatch(t,n,r,a){if(!n){this.sendFrame(e.frame(t,r),a);return}let o=this._extensions[i.extensionName];this._bufferedBytes+=r[f],this._state=1,o.compress(t,r.fin,(t,n)=>{if(this._socket.destroyed){_(this,Error(`The socket was closed while data was being compressed`),a);return}this._bufferedBytes-=r[f],this._state=0,r.readOnly=!1,this.sendFrame(e.frame(n,r),a),this.dequeue()})}dequeue(){for(;this._state===0&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][f],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][f],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};function _(e,t,n){typeof n==`function`&&n(t);for(let n=0;n<e._queue.length;n++){let r=e._queue[n],i=r[r.length-1];typeof i==`function`&&i(t)}}function v(e,t,n){_(e,t,n),e.onerror(t)}})),NSe=x5(((e,t)=>{let{kForOnEventAttribute:n,kListener:r}=C5(),i=Symbol(`kCode`),a=Symbol(`kData`),o=Symbol(`kError`),s=Symbol(`kMessage`),c=Symbol(`kReason`),l=Symbol(`kTarget`),u=Symbol(`kType`),d=Symbol(`kWasClean`);var f=class{constructor(e){this[l]=null,this[u]=e}get target(){return this[l]}get type(){return this[u]}};Object.defineProperty(f.prototype,`target`,{enumerable:!0}),Object.defineProperty(f.prototype,`type`,{enumerable:!0});var p=class extends f{constructor(e,t={}){super(e),this[i]=t.code===void 0?0:t.code,this[c]=t.reason===void 0?``:t.reason,this[d]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[i]}get reason(){return this[c]}get wasClean(){return this[d]}};Object.defineProperty(p.prototype,`code`,{enumerable:!0}),Object.defineProperty(p.prototype,`reason`,{enumerable:!0}),Object.defineProperty(p.prototype,`wasClean`,{enumerable:!0});var m=class extends f{constructor(e,t={}){super(e),this[o]=t.error===void 0?null:t.error,this[s]=t.message===void 0?``:t.message}get error(){return this[o]}get message(){return this[s]}};Object.defineProperty(m.prototype,`error`,{enumerable:!0}),Object.defineProperty(m.prototype,`message`,{enumerable:!0});var h=class extends f{constructor(e,t={}){super(e),this[a]=t.data===void 0?null:t.data}get data(){return this[a]}};Object.defineProperty(h.prototype,`data`,{enumerable:!0}),t.exports={CloseEvent:p,ErrorEvent:m,Event:f,EventTarget:{addEventListener(e,t,i={}){for(let a of this.listeners(e))if(!i[n]&&a[r]===t&&!a[n])return;let a;if(e===`message`)a=function(e,n){let r=new h(`message`,{data:n?e:e.toString()});r[l]=this,g(t,this,r)};else if(e===`close`)a=function(e,n){let r=new p(`close`,{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[l]=this,g(t,this,r)};else if(e===`error`)a=function(e){let n=new m(`error`,{error:e,message:e.message});n[l]=this,g(t,this,n)};else if(e===`open`)a=function(){let e=new f(`open`);e[l]=this,g(t,this,e)};else return;a[n]=!!i[n],a[r]=t,i.once?this.once(e,a):this.on(e,a)},removeEventListener(e,t){for(let i of this.listeners(e))if(i[r]===t&&!i[n]){this.removeListener(e,i);break}}},MessageEvent:h};function g(e,t,n){typeof e==`object`&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}})),k5=x5(((e,t)=>{let{tokenChars:n}=E5();function r(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function i(e){let t=Object.create(null),i=Object.create(null),a=!1,o=!1,s=!1,c,l,u=-1,d=-1,f=-1,p=0;for(;p<e.length;p++)if(d=e.charCodeAt(p),c===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(p!==0&&(d===32||d===9))f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);d===44?(r(t,n,i),i=Object.create(null)):c=n,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);else if(l===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(d===32||d===9)f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p),r(i,e.slice(u,f),!0),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),u=f=-1}else if(d===61&&u!==-1&&f===-1)l=e.slice(u,p),u=f=-1;else throw SyntaxError(`Unexpected character at index ${p}`);else if(o){if(n[d]!==1)throw SyntaxError(`Unexpected character at index ${p}`);u===-1?u=p:a||=!0,o=!1}else if(s)if(n[d]===1)u===-1&&(u=p);else if(d===34&&u!==-1)s=!1,f=p;else if(d===92)o=!0;else throw SyntaxError(`Unexpected character at index ${p}`);else if(d===34&&e.charCodeAt(p-1)===61)s=!0;else if(f===-1&&n[d]===1)u===-1&&(u=p);else if(u!==-1&&(d===32||d===9))f===-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);a&&=(n=n.replace(/\\/g,``),!1),r(i,l,n),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),l=void 0,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);if(u===-1||s||d===32||d===9)throw SyntaxError(`Unexpected end of input`);f===-1&&(f=p);let m=e.slice(u,f);return c===void 0?r(t,m,i):(l===void 0?r(i,m,!0):a?r(i,l,m.replace(/\\/g,``)):r(i,l,m),r(t,c,i)),t}function a(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>e===!0?t:`${t}=${e}`).join(`; `)})).join(`; `)).join(`, `)}).join(`, `)}t.exports={format:a,parse:i}})),A5=x5(((e,t)=>{let n=S5(`events`),r=S5(`https`),i=S5(`http`),a=S5(`net`),o=S5(`tls`),{randomBytes:s,createHash:c}=S5(`crypto`),{Duplex:l,Readable:u}=S5(`stream`),{URL:d}=S5(`url`),f=T5(),p=D5(),m=O5(),{isBlob:h}=E5(),{BINARY_TYPES:g,CLOSE_TIMEOUT:_,EMPTY_BUFFER:v,GUID:y,kForOnEventAttribute:b,kListener:x,kStatusCode:S,kWebSocket:C,NOOP:w}=C5(),{EventTarget:{addEventListener:T,removeEventListener:E}}=NSe(),{format:D,parse:O}=k5(),{toBuffer:ee}=w5(),te=Symbol(`kAborted`),ne=[8,13],re=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],ie=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;var ae=class e extends n{constructor(t,n,r){super(),this._binaryType=g[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=v,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol=``,this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t===null?(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0):(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n==`object`&&n?(r=n,n=[]):n=[n]),oe(this,t,n,r))}get binaryType(){return this._binaryType}set binaryType(e){g.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,r){let i=new p({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),a=new m(t,this._extensions,r.generateMask);this._receiver=i,this._sender=a,this._socket=t,i[C]=this,a[C]=this,t[C]=this,i.on(`conclude`,A),i.on(`drain`,j),i.on(`error`,de),i.on(`message`,pe),i.on(`ping`,me),i.on(`pong`,M),a.onerror=he,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on(`close`,_e),t.on(`data`,ve),t.on(`end`,ye),t.on(`error`,be),this._readyState=e.OPEN,this.emit(`open`)}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage);return}this._extensions[f.extensionName]&&this._extensions[f.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){le(this,this._req,`WebSocket was closed before the connection was established`);return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ge(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ue(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||v,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ue(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||v,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof n==`function`&&(r=n,n={}),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ue(this,t,r);return}let i={binary:typeof t!=`string`,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[f.extensionName]||(i.compress=!1),this._sender.send(t||v,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){le(this,this._req,`WebSocket was closed before the connection was established`);return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(ae,`CONNECTING`,{enumerable:!0,value:re.indexOf(`CONNECTING`)}),Object.defineProperty(ae.prototype,`CONNECTING`,{enumerable:!0,value:re.indexOf(`CONNECTING`)}),Object.defineProperty(ae,`OPEN`,{enumerable:!0,value:re.indexOf(`OPEN`)}),Object.defineProperty(ae.prototype,`OPEN`,{enumerable:!0,value:re.indexOf(`OPEN`)}),Object.defineProperty(ae,`CLOSING`,{enumerable:!0,value:re.indexOf(`CLOSING`)}),Object.defineProperty(ae.prototype,`CLOSING`,{enumerable:!0,value:re.indexOf(`CLOSING`)}),Object.defineProperty(ae,`CLOSED`,{enumerable:!0,value:re.indexOf(`CLOSED`)}),Object.defineProperty(ae.prototype,`CLOSED`,{enumerable:!0,value:re.indexOf(`CLOSED`)}),[`binaryType`,`bufferedAmount`,`extensions`,`isPaused`,`protocol`,`readyState`,`url`].forEach(e=>{Object.defineProperty(ae.prototype,e,{enumerable:!0})}),[`open`,`error`,`close`,`message`].forEach(e=>{Object.defineProperty(ae.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[b])return t[x];return null},set(t){for(let t of this.listeners(e))if(t[b]){this.removeListener(e,t);break}typeof t==`function`&&this.addEventListener(e,t,{[b]:!0})}})}),ae.prototype.addEventListener=T,ae.prototype.removeEventListener=E,t.exports=ae;function oe(e,t,n,a){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:_,protocolVersion:ne[1],maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...a,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:`GET`,host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!ne.includes(o.protocolVersion))throw RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${ne.join(`, `)})`);let l;if(t instanceof d)l=t;else try{l=new d(t)}catch{throw SyntaxError(`Invalid URL: ${t}`)}l.protocol===`http:`?l.protocol=`ws:`:l.protocol===`https:`&&(l.protocol=`wss:`),e._url=l.href;let u=l.protocol===`wss:`,p=l.protocol===`ws+unix:`,m;if(l.protocol!==`ws:`&&!u&&!p?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:p&&!l.pathname?m=`The URL's pathname is empty`:l.hash&&(m=`The URL contains a fragment identifier`),m){let t=SyntaxError(m);if(e._redirects===0)throw t;se(e,t);return}let h=u?443:80,g=s(16).toString(`base64`),v=u?r.request:i.request,b=new Set,x;if(o.createConnection=o.createConnection||(u?ce:k),o.defaultPort=o.defaultPort||h,o.port=l.port||h,o.host=l.hostname.startsWith(`[`)?l.hostname.slice(1,-1):l.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":g,Connection:`Upgrade`,Upgrade:`websocket`},o.path=l.pathname+l.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(x=new f(o.perMessageDeflate===!0?{}:o.perMessageDeflate,!1,o.maxPayload),o.headers[`Sec-WebSocket-Extensions`]=D({[f.extensionName]:x.offer()})),n.length){for(let e of n){if(typeof e!=`string`||!ie.test(e)||b.has(e))throw SyntaxError(`An invalid or duplicated subprotocol was specified`);b.add(e)}o.headers[`Sec-WebSocket-Protocol`]=n.join(`,`)}if(o.origin&&(o.protocolVersion<13?o.headers[`Sec-WebSocket-Origin`]=o.origin:o.headers.Origin=o.origin),(l.username||l.password)&&(o.auth=`${l.username}:${l.password}`),p){let e=o.path.split(`:`);o.socketPath=e[0],o.path=e[1]}let S;if(o.followRedirects){if(e._redirects===0){e._originalIpc=p,e._originalSecure=u,e._originalHostOrSocketPath=p?o.socketPath:l.host;let t=a&&a.headers;if(a={...a,headers:{}},t)for(let[e,n]of Object.entries(t))a.headers[e.toLowerCase()]=n}else if(e.listenerCount(`redirect`)===0){let t=p?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:l.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!u)&&(delete o.headers.authorization,delete o.headers.cookie,t||delete o.headers.host,o.auth=void 0)}o.auth&&!a.headers.authorization&&(a.headers.authorization=`Basic `+Buffer.from(o.auth).toString(`base64`)),S=e._req=v(o),e._redirects&&e.emit(`redirect`,e.url,S)}else S=e._req=v(o);o.timeout&&S.on(`timeout`,()=>{le(e,S,`Opening handshake has timed out`)}),S.on(`error`,t=>{S===null||S[te]||(S=e._req=null,se(e,t))}),S.on(`response`,r=>{let i=r.headers.location,s=r.statusCode;if(i&&o.followRedirects&&s>=300&&s<400){if(++e._redirects>o.maxRedirects){le(e,S,`Maximum redirects exceeded`);return}S.abort();let r;try{r=new d(i,t)}catch{se(e,SyntaxError(`Invalid URL: ${i}`));return}oe(e,r,n,a)}else e.emit(`unexpected-response`,S,r)||le(e,S,`Unexpected server response: ${r.statusCode}`)}),S.on(`upgrade`,(t,n,r)=>{if(e.emit(`upgrade`,t),e.readyState!==ae.CONNECTING)return;S=e._req=null;let i=t.headers.upgrade;if(i===void 0||i.toLowerCase()!==`websocket`){le(e,n,`Invalid Upgrade header`);return}let a=c(`sha1`).update(g+y).digest(`base64`);if(t.headers[`sec-websocket-accept`]!==a){le(e,n,`Invalid Sec-WebSocket-Accept header`);return}let s=t.headers[`sec-websocket-protocol`],l;if(s===void 0?b.size&&(l=`Server sent no subprotocol`):b.size?b.has(s)||(l=`Server sent an invalid subprotocol`):l=`Server sent a subprotocol but none was requested`,l){le(e,n,l);return}s&&(e._protocol=s);let u=t.headers[`sec-websocket-extensions`];if(u!==void 0){if(!x){le(e,n,`Server sent a Sec-WebSocket-Extensions header but no extension was requested`);return}let t;try{t=O(u)}catch{le(e,n,`Invalid Sec-WebSocket-Extensions header`);return}let r=Object.keys(t);if(r.length!==1||r[0]!==f.extensionName){le(e,n,`Server indicated an extension that was not requested`);return}try{x.accept(t[f.extensionName])}catch{le(e,n,`Invalid Sec-WebSocket-Extensions header`);return}e._extensions[f.extensionName]=x}e.setSocket(n,r,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,e):S.end()}function se(e,t){e._readyState=ae.CLOSING,e._errorEmitted=!0,e.emit(`error`,t),e.emitClose()}function k(e){return e.path=e.socketPath,a.connect(e)}function ce(e){return e.path=void 0,!e.servername&&e.servername!==``&&(e.servername=a.isIP(e.host)?``:e.host),o.connect(e)}function le(e,t,n){e._readyState=ae.CLOSING;let r=Error(n);Error.captureStackTrace(r,le),t.setHeader?(t[te]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(se,e,r)):(t.destroy(r),t.once(`error`,e.emit.bind(e,`error`)),t.once(`close`,e.emitClose.bind(e)))}function ue(e,t,n){if(t){let n=h(t)?t.size:ee(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${re[e.readyState]})`);process.nextTick(n,t)}}function A(e,t){let n=this[C];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[C]!==void 0&&(n._socket.removeListener(`data`,ve),process.nextTick(N,n._socket),e===1005?n.close():n.close(e,t))}function j(){let e=this[C];e.isPaused||e._socket.resume()}function de(e){let t=this[C];t._socket[C]!==void 0&&(t._socket.removeListener(`data`,ve),process.nextTick(N,t._socket),t.close(e[S])),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e))}function fe(){this[C].emitClose()}function pe(e,t){this[C].emit(`message`,e,t)}function me(e){let t=this[C];t._autoPong&&t.pong(e,!this._isServer,w),t.emit(`ping`,e)}function M(e){this[C].emit(`pong`,e)}function N(e){e.resume()}function he(e){let t=this[C];t.readyState!==ae.CLOSED&&(t.readyState===ae.OPEN&&(t._readyState=ae.CLOSING,ge(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e)))}function ge(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function _e(){let e=this[C];if(this.removeListener(`close`,_e),this.removeListener(`data`,ve),this.removeListener(`end`,ye),e._readyState=ae.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[C]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on(`error`,fe),e._receiver.on(`finish`,fe))}function ve(e){this[C]._receiver.write(e)||this.pause()}function ye(){let e=this[C];e._readyState=ae.CLOSING,e._receiver.end(),this.end()}function be(){let e=this[C];this.removeListener(`error`,be),this.on(`error`,w),e&&(e._readyState=ae.CLOSING,this.destroy())}})),PSe=x5(((e,t)=>{A5();let{Duplex:n}=S5(`stream`);function r(e){e.emit(`close`)}function i(){!this.destroyed&&this._writableState.finished&&this.destroy()}function a(e){this.removeListener(`error`,a),this.destroy(),this.listenerCount(`error`)===0&&this.emit(`error`,e)}function o(e,t){let o=!0,s=new n({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on(`message`,function(t,n){let r=!n&&s._readableState.objectMode?t.toString():t;s.push(r)||e.pause()}),e.once(`error`,function(e){s.destroyed||(o=!1,s.destroy(e))}),e.once(`close`,function(){s.destroyed||s.push(null)}),s._destroy=function(t,n){if(e.readyState===e.CLOSED){n(t),process.nextTick(r,s);return}let i=!1;e.once(`error`,function(e){i=!0,n(e)}),e.once(`close`,function(){i||n(t),process.nextTick(r,s)}),o&&e.terminate()},s._final=function(t){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._final(t)});return}e._socket!==null&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once(`finish`,function(){t()}),e.close()))},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,n,r){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._write(t,n,r)});return}e.send(t,r)},s.on(`end`,i),s.on(`error`,a),s}t.exports=o})),FSe=x5(((e,t)=>{let{tokenChars:n}=E5();function r(e){let t=new Set,r=-1,i=-1,a=0;for(;a<e.length;a++){let o=e.charCodeAt(a);if(i===-1&&n[o]===1)r===-1&&(r=a);else if(a!==0&&(o===32||o===9))i===-1&&r!==-1&&(i=a);else if(o===44){if(r===-1)throw SyntaxError(`Unexpected character at index ${a}`);i===-1&&(i=a);let n=e.slice(r,i);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);t.add(n),r=i=-1}else throw SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||i!==-1)throw SyntaxError(`Unexpected end of input`);let o=e.slice(r,a);if(t.has(o))throw SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}t.exports={parse:r}})),ISe=x5(((e,t)=>{let n=S5(`events`),r=S5(`http`),{Duplex:i}=S5(`stream`),{createHash:a}=S5(`crypto`),o=k5(),s=T5(),c=FSe(),l=A5(),{CLOSE_TIMEOUT:u,GUID:d,kWebSocket:f}=C5(),p=/^[+/0-9A-Za-z]{22}==$/;t.exports=class extends n{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:u,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:l,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError(`One and only one of the "port", "server", or "noServer" options must be specified`);if(e.port==null?e.server&&(this._server=e.server):(this._server=r.createServer((e,t)=>{let n=r.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":`text/plain`}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)),this._server){let e=this.emit.bind(this,`connection`);this._removeListeners=m(this._server,{listening:this.emit.bind(this,`listening`),error:this.emit.bind(this,`error`),upgrade:(t,n,r)=>{this.handleUpgrade(t,n,r,e)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error(`The server is operating in "noServer" mode`);return this._server?this._server.address():null}close(e){if(this._state===2){e&&this.once(`close`,()=>{e(Error(`The server is not running`))}),process.nextTick(h,this);return}if(e&&this.once(`close`,e),this._state!==1)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(h,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{h(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf(`?`);if((t===-1?e.url:e.url.slice(0,t))!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,r){t.on(`error`,g);let i=e.headers[`sec-websocket-key`],a=e.headers.upgrade,l=+e.headers[`sec-websocket-version`];if(e.method!==`GET`){v(this,e,t,405,`Invalid HTTP method`);return}if(a===void 0||a.toLowerCase()!==`websocket`){v(this,e,t,400,`Invalid Upgrade header`);return}if(i===void 0||!p.test(i)){v(this,e,t,400,`Missing or invalid Sec-WebSocket-Key header`);return}if(l!==13&&l!==8){v(this,e,t,400,`Missing or invalid Sec-WebSocket-Version header`,{"Sec-WebSocket-Version":`13, 8`});return}if(!this.shouldHandle(e)){_(t,400);return}let u=e.headers[`sec-websocket-protocol`],d=new Set;if(u!==void 0)try{d=c.parse(u)}catch{v(this,e,t,400,`Invalid Sec-WebSocket-Protocol header`);return}let f=e.headers[`sec-websocket-extensions`],m={};if(this.options.perMessageDeflate&&f!==void 0){let n=new s(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let e=o.parse(f);e[s.extensionName]&&(n.accept(e[s.extensionName]),m[s.extensionName]=n)}catch{v(this,e,t,400,`Invalid or unacceptable Sec-WebSocket-Extensions header`);return}}if(this.options.verifyClient){let a={origin:e.headers[`${l===8?`sec-websocket-origin`:`origin`}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(a,(a,o,s,c)=>{if(!a)return _(t,o||401,s,c);this.completeUpgrade(m,i,d,e,t,n,r)});return}if(!this.options.verifyClient(a))return _(t,401)}this.completeUpgrade(m,i,d,e,t,n,r)}completeUpgrade(e,t,n,r,i,c,l){if(!i.readable||!i.writable)return i.destroy();if(i[f])throw Error(`server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration`);if(this._state>0)return _(i,503);let u=[`HTTP/1.1 101 Switching Protocols`,`Upgrade: websocket`,`Connection: Upgrade`,`Sec-WebSocket-Accept: ${a(`sha1`).update(t+d).digest(`base64`)}`],p=new this.options.WebSocket(null,void 0,this.options);if(n.size){let e=this.options.handleProtocols?this.options.handleProtocols(n,r):n.values().next().value;e&&(u.push(`Sec-WebSocket-Protocol: ${e}`),p._protocol=e)}if(e[s.extensionName]){let t=e[s.extensionName].params,n=o.format({[s.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${n}`),p._extensions=e}this.emit(`headers`,u,r),i.write(u.concat(`\r
832
+ `+n)}function y(e,t,n,r,i,a){if(e.listenerCount(`wsClientError`)){let r=Error(i);Error.captureStackTrace(r,y),e.emit(`wsClientError`,r,n,t)}else v(n,r,i,a)}}));kSe(),s5(),r5(),a5(),o5(),l5(),c5(),ASe();let u5,d5,f5,p5,m5=!0;typeof process<`u`&&({FORCE_COLOR:u5,NODE_DISABLE_COLORS:d5,NO_COLOR:f5,TERM:p5}=process.env||{},m5=process.stdout&&process.stdout.isTTY);const h5={enabled:!d5&&f5==null&&p5!==`dumb`&&(u5!=null&&u5!==`0`||m5),reset:_5(0,0),bold:_5(1,22),dim:_5(2,22),italic:_5(3,23),underline:_5(4,24),inverse:_5(7,27),hidden:_5(8,28),strikethrough:_5(9,29),black:_5(30,39),red:_5(31,39),green:_5(32,39),yellow:_5(33,39),blue:_5(34,39),magenta:_5(35,39),cyan:_5(36,39),white:_5(37,39),gray:_5(90,39),grey:_5(90,39),bgBlack:_5(40,49),bgRed:_5(41,49),bgGreen:_5(42,49),bgYellow:_5(43,49),bgBlue:_5(44,49),bgMagenta:_5(45,49),bgCyan:_5(46,49),bgWhite:_5(47,49)};function g5(e,t){let n=0,r,i=``,a=``;for(;n<e.length;n++)r=e[n],i+=r.open,a+=r.close,~t.indexOf(r.close)&&(t=t.replace(r.rgx,r.close+r.open));return i+t+a}function jSe(e,t){let n={has:e,keys:t};return n.reset=h5.reset.bind(n),n.bold=h5.bold.bind(n),n.dim=h5.dim.bind(n),n.italic=h5.italic.bind(n),n.underline=h5.underline.bind(n),n.inverse=h5.inverse.bind(n),n.hidden=h5.hidden.bind(n),n.strikethrough=h5.strikethrough.bind(n),n.black=h5.black.bind(n),n.red=h5.red.bind(n),n.green=h5.green.bind(n),n.yellow=h5.yellow.bind(n),n.blue=h5.blue.bind(n),n.magenta=h5.magenta.bind(n),n.cyan=h5.cyan.bind(n),n.white=h5.white.bind(n),n.gray=h5.gray.bind(n),n.grey=h5.grey.bind(n),n.bgBlack=h5.bgBlack.bind(n),n.bgRed=h5.bgRed.bind(n),n.bgGreen=h5.bgGreen.bind(n),n.bgYellow=h5.bgYellow.bind(n),n.bgBlue=h5.bgBlue.bind(n),n.bgMagenta=h5.bgMagenta.bind(n),n.bgCyan=h5.bgCyan.bind(n),n.bgWhite=h5.bgWhite.bind(n),n}function _5(e,t){let n={open:`\x1b[${e}m`,close:`\x1b[${t}m`,rgx:RegExp(`\\x1b\\[${t}m`,`g`)};return function(t){return this!==void 0&&this.has!==void 0?(~this.has.indexOf(e)||(this.has.push(e),this.keys.push(n)),t===void 0?this:h5.enabled?g5(this.keys,t+``):t+``):t===void 0?jSe([e],[n]):h5.enabled?g5([n],t+``):t+``}}Number.isNaN,Number.isInteger,Number.isNaN,Number.parseInt,Array.from,Array.isArray;const MSe=String.fromCharCode;String.fromCodePoint,MSe(65535);const v5=typeof TextEncoder<`u`?new TextEncoder:null;let y5=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});y5&&y5.decode(new Uint8Array).length===1&&(y5=null);const b5=e=>Error(e);new Uint8Array(3e4).length/3,v5&&v5.encodeInto,b5(`Unexpected end of array`),b5(`Integer out of Range`),Date.now;var x5=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),S5=o(import.meta.url),C5=x5(((e,t)=>{let n=[`nodebuffer`,`arraybuffer`,`fragments`],r=typeof Blob<`u`;r&&n.push(`blob`),t.exports={BINARY_TYPES:n,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,hasBlob:r,kForOnEventAttribute:Symbol(`kIsForOnEventAttribute`),kListener:Symbol(`kListener`),kStatusCode:Symbol(`status-code`),kWebSocket:Symbol(`websocket`),NOOP:()=>{}}})),w5=x5(((e,t)=>{let{EMPTY_BUFFER:n}=C5(),r=Buffer[Symbol.species];function i(e,t){if(e.length===0)return n;if(e.length===1)return e[0];let i=Buffer.allocUnsafe(t),a=0;for(let t=0;t<e.length;t++){let n=e[t];i.set(n,a),a+=n.length}return a<t?new r(i.buffer,i.byteOffset,a):i}function a(e,t,n,r,i){for(let a=0;a<i;a++)n[r+a]=e[a]^t[a&3]}function o(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function s(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function c(e){if(c.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new r(e):ArrayBuffer.isView(e)?t=new r(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),c.readOnly=!1),t}if(t.exports={concat:i,mask:a,toArrayBuffer:s,toBuffer:c,unmask:o},!process.env.WS_NO_BUFFER_UTIL)try{let e=S5(`bufferutil`);t.exports.mask=function(t,n,r,i,o){o<48?a(t,n,r,i,o):e.mask(t,n,r,i,o)},t.exports.unmask=function(t,n){t.length<32?o(t,n):e.unmask(t,n)}}catch{}})),NSe=x5(((e,t)=>{let n=Symbol(`kDone`),r=Symbol(`kRun`);t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[n])}}}})),T5=x5(((e,t)=>{let n=S5(`zlib`),r=w5(),i=NSe(),{kStatusCode:a}=C5(),o=Buffer[Symbol.species],s=Buffer.from([0,0,255,255]),c=Symbol(`permessage-deflate`),l=Symbol(`total-length`),u=Symbol(`callback`),d=Symbol(`buffers`),f=Symbol(`error`),p;t.exports=class{constructor(e,t,n){this._maxPayload=n|0,this._options=e||{},this._threshold=this._options.threshold===void 0?1024:this._options.threshold,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,p||=new i(this._options.concurrencyLimit===void 0?10:this._options.concurrencyLimit)}static get extensionName(){return`permessage-deflate`}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits??(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&=(this._inflate.close(),null),this._deflate){let e=this._deflate[u];this._deflate.close(),this._deflate=null,e&&e(Error(`The deflate stream was closed while data was being processed`))}}acceptAsServer(e){let t=this._options,n=e.find(e=>!(t.serverNoContextTakeover===!1&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits==`number`&&t.serverMaxWindowBits>e.server_max_window_bits)||typeof t.clientMaxWindowBits==`number`&&!e.client_max_window_bits));if(!n)throw Error(`None of the extension offers can be accepted`);return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits==`number`&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits==`number`?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw Error(`Unexpected parameter "client_no_context_takeover"`);if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits==`number`&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==`number`&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error(`Unexpected or invalid parameter "client_max_window_bits"`);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let n=e[t];if(n.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(n=n[0],t===`client_max_window_bits`){if(n!==!0){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else if(t===`server_max_window_bits`){let e=+n;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${n}`);n=e}else if(t===`client_no_context_takeover`||t===`server_no_context_takeover`){if(n!==!0)throw TypeError(`Invalid value for parameter "${t}": ${n}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=n})}),e}decompress(e,t,n){p.add(r=>{this._decompress(e,t,(e,t)=>{r(),n(e,t)})})}compress(e,t,n){p.add(r=>{this._compress(e,t,(e,t)=>{r(),n(e,t)})})}_decompress(e,t,i){let a=this._isServer?`client`:`server`;if(!this._inflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._inflate=n.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[l]=0,this._inflate[d]=[],this._inflate.on(`error`,g),this._inflate.on(`data`,h)}this._inflate[u]=i,this._inflate.write(e),t&&this._inflate.write(s),this._inflate.flush(()=>{let e=this._inflate[f];if(e){this._inflate.close(),this._inflate=null,i(e);return}let n=r.concat(this._inflate[d],this._inflate[l]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[l]=0,this._inflate[d]=[],t&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),i(null,n)})}_compress(e,t,i){let a=this._isServer?`server`:`client`;if(!this._deflate){let e=`${a}_max_window_bits`,t=typeof this.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._deflate=n.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[l]=0,this._deflate[d]=[],this._deflate.on(`data`,m)}this._deflate[u]=i,this._deflate.write(e),this._deflate.flush(n.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=r.concat(this._deflate[d],this._deflate[l]);t&&(e=new o(e.buffer,e.byteOffset,e.length-4)),this._deflate[u]=null,this._deflate[l]=0,this._deflate[d]=[],t&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),i(null,e)})}};function m(e){this[d].push(e),this[l]+=e.length}function h(e){if(this[l]+=e.length,this[c]._maxPayload<1||this[l]<=this[c]._maxPayload){this[d].push(e);return}this[f]=RangeError(`Max payload size exceeded`),this[f].code=`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`,this[f][a]=1009,this.removeListener(`data`,h),this.reset()}function g(e){if(this[c]._inflate=null,this[f]){this[u](this[f]);return}e[a]=1007,this[u](e)}})),E5=x5(((e,t)=>{let{isUtf8:n}=S5(`buffer`),{hasBlob:r}=C5(),i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function a(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function o(e){let t=e.length,n=0;for(;n<t;)if(!(e[n]&128))n++;else if((e[n]&224)==192){if(n+1===t||(e[n+1]&192)!=128||(e[n]&254)==192)return!1;n+=2}else if((e[n]&240)==224){if(n+2>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||e[n]===224&&(e[n+1]&224)==128||e[n]===237&&(e[n+1]&224)==160)return!1;n+=3}else if((e[n]&248)==240){if(n+3>=t||(e[n+1]&192)!=128||(e[n+2]&192)!=128||(e[n+3]&192)!=128||e[n]===240&&(e[n+1]&240)==128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function s(e){return r&&typeof e==`object`&&typeof e.arrayBuffer==`function`&&typeof e.type==`string`&&typeof e.stream==`function`&&(e[Symbol.toStringTag]===`Blob`||e[Symbol.toStringTag]===`File`)}if(t.exports={isBlob:s,isValidStatusCode:a,isValidUTF8:o,tokenChars:i},n)t.exports.isValidUTF8=function(e){return e.length<24?o(e):n(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=S5(`utf-8-validate`);t.exports.isValidUTF8=function(t){return t.length<32?o(t):e(t)}}catch{}})),D5=x5(((e,t)=>{let{Writable:n}=S5(`stream`),r=T5(),{BINARY_TYPES:i,EMPTY_BUFFER:a,kStatusCode:o,kWebSocket:s}=C5(),{concat:c,toArrayBuffer:l,unmask:u}=w5(),{isValidStatusCode:d,isValidUTF8:f}=E5(),p=Buffer[Symbol.species];t.exports=class extends n{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents===void 0?!0:e.allowSynchronousEvents,this._binaryType=e.binaryType||i[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[s]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,n){if(this._opcode===8&&this._state==0)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new p(t.buffer,t.byteOffset+e,t.length-e),new p(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],r=t.length-e;e>=n.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),r),this._buffers[0]=new p(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){e(this.createError(RangeError,`RSV2 and RSV3 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_2_3`));return}let n=(t[0]&64)==64;if(n&&!this._extensions[r.extensionName]){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._fin=(t[0]&128)==128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(!this._fragmented){e(this.createError(RangeError,`invalid opcode 0`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){e(this.createError(RangeError,`FIN must be set`,!0,1002,`WS_ERR_EXPECTED_FIN`));return}if(n){e(this.createError(RangeError,`RSV1 must be clear`,!0,1002,`WS_ERR_UNEXPECTED_RSV_1`));return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,`WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH`));return}}else{e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,`WS_ERR_INVALID_OPCODE`));return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)==128,this._isServer){if(!this._masked){e(this.createError(RangeError,`MASK must be set`,!0,1002,`WS_ERR_EXPECTED_MASK`));return}}else if(this._masked){e(this.createError(RangeError,`MASK must be clear`,!0,1002,`WS_ERR_UNEXPECTED_MASK`));return}this._payloadLength===126?this._state=1:this._payloadLength===127?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),n=t.readUInt32BE(0);if(n>2**21-1){e(this.createError(RangeError,`Unsupported WebSocket frame: payload length > 2^53 - 1`,!1,1009,`WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH`));return}this._payloadLength=n*2**32+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){e(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=a;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&u(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=5,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[r.extensionName].decompress(e,this._fin,(e,n)=>{if(e)return t(e);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){t(this.createError(RangeError,`Max payload size exceeded`,!1,1009,`WS_ERR_UNSUPPORTED_MESSAGE_LENGTH`));return}this._fragments.push(n)}this.dataMessage(t),this._state===0&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;r=this._binaryType===`nodebuffer`?c(n,t):this._binaryType===`arraybuffer`?l(c(n,t)):this._binaryType===`blob`?new Blob(n):n,this._allowSynchronousEvents?(this.emit(`message`,r,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!0),this._state=0,this.startLoop(e)}))}else{let r=c(n,t);if(!this._skipUTF8Validation&&!f(r)){e(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._state===5||this._allowSynchronousEvents?(this.emit(`message`,r,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit(`message`,r,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit(`conclude`,1005,a),this.end();else{let n=e.readUInt16BE(0);if(!d(n)){t(this.createError(RangeError,`invalid status code ${n}`,!0,1002,`WS_ERR_INVALID_CLOSE_CODE`));return}let r=new p(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!f(r)){t(this.createError(Error,`invalid UTF-8 sequence`,!0,1007,`WS_ERR_INVALID_UTF8`));return}this._loop=!1,this.emit(`conclude`,n,r),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(this._opcode===9?`ping`:`pong`,e),this._state=0,this.startLoop(t)}))}createError(e,t,n,r,i){this._loop=!1,this._errored=!0;let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=i,a[o]=r,a}}})),O5=x5(((e,t)=>{let{Duplex:n}=S5(`stream`),{randomFillSync:r}=S5(`crypto`),i=T5(),{EMPTY_BUFFER:a,kWebSocket:o,NOOP:s}=C5(),{isBlob:c,isValidStatusCode:l}=E5(),{mask:u,toBuffer:d}=w5(),f=Symbol(`kByteLength`),p=Buffer.alloc(4),m=8*1024,h,g=m;t.exports=class e{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=s,this[o]=void 0}static frame(e,t){let n,i=!1,a=2,o=!1;t.mask&&(n=t.maskBuffer||p,t.generateMask?t.generateMask(n):(g===m&&(h===void 0&&(h=Buffer.alloc(m)),r(h,0,m),g=0),n[0]=h[g++],n[1]=h[g++],n[2]=h[g++],n[3]=h[g++]),o=(n[0]|n[1]|n[2]|n[3])===0,a=6);let s;typeof e==`string`?(!t.mask||o)&&t[f]!==void 0?s=t[f]:(e=Buffer.from(e),s=e.length):(s=e.length,i=t.mask&&t.readOnly&&!o);let c=s;s>=65536?(a+=8,c=127):s>125&&(a+=2,c=126);let l=Buffer.allocUnsafe(i?s+a:a);return l[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(s,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),!t.mask||(l[1]|=128,l[a-4]=n[0],l[a-3]=n[1],l[a-2]=n[2],l[a-1]=n[3],o)?[l,e]:i?(u(e,n,l,a,s),[l]):(u(e,n,e,0,s),[l,e])}close(t,n,r,i){let o;if(t===void 0)o=a;else if(typeof t!=`number`||!l(t))throw TypeError(`First argument must be a valid error code number`);else if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let e=Buffer.byteLength(n);if(e>123)throw RangeError(`The message must not be greater than 123 bytes`);o=Buffer.allocUnsafe(2+e),o.writeUInt16BE(t,0),typeof n==`string`?o.write(n,2):o.set(n,2)}let s={[f]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state===0?this.sendFrame(e.frame(o,s),i):this.enqueue([this.dispatch,o,!1,s,i])}ping(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):c(t)?(i=t.size,a=!1):(t=d(t),i=t.length,a=d.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[f]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};c(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}pong(t,n,r){let i,a;if(typeof t==`string`?(i=Buffer.byteLength(t),a=!1):c(t)?(i=t.size,a=!1):(t=d(t),i=t.length,a=d.readOnly),i>125)throw RangeError(`The data size must not be greater than 125 bytes`);let o={[f]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};c(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}send(e,t,n){let r=this._extensions[i.extensionName],a=t.binary?2:1,o=t.compress,s,l;typeof e==`string`?(s=Buffer.byteLength(e),l=!1):c(e)?(s=e.size,l=!1):(e=d(e),s=e.length,l=d.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?`server_no_context_takeover`:`client_no_context_takeover`]&&(o=s>=r._threshold),this._compress=o):(o=!1,a=0),t.fin&&(this._firstFragment=!0);let u={[f]:s,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:l,rsv1:o};c(e)?this._state===0?this.getBlobData(e,this._compress,u,n):this.enqueue([this.getBlobData,e,this._compress,u,n]):this._state===0?this.dispatch(e,this._compress,u,n):this.enqueue([this.dispatch,e,this._compress,u,n])}getBlobData(t,n,r,i){this._bufferedBytes+=r[f],this._state=2,t.arrayBuffer().then(t=>{if(this._socket.destroyed){let e=Error(`The socket was closed while the blob was being read`);process.nextTick(_,this,e,i);return}this._bufferedBytes-=r[f];let a=d(t);n?this.dispatch(a,n,r,i):(this._state=0,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(e=>{process.nextTick(v,this,e,i)})}dispatch(t,n,r,a){if(!n){this.sendFrame(e.frame(t,r),a);return}let o=this._extensions[i.extensionName];this._bufferedBytes+=r[f],this._state=1,o.compress(t,r.fin,(t,n)=>{if(this._socket.destroyed){_(this,Error(`The socket was closed while data was being compressed`),a);return}this._bufferedBytes-=r[f],this._state=0,r.readOnly=!1,this.sendFrame(e.frame(n,r),a),this.dequeue()})}dequeue(){for(;this._state===0&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][f],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][f],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};function _(e,t,n){typeof n==`function`&&n(t);for(let n=0;n<e._queue.length;n++){let r=e._queue[n],i=r[r.length-1];typeof i==`function`&&i(t)}}function v(e,t,n){_(e,t,n),e.onerror(t)}})),PSe=x5(((e,t)=>{let{kForOnEventAttribute:n,kListener:r}=C5(),i=Symbol(`kCode`),a=Symbol(`kData`),o=Symbol(`kError`),s=Symbol(`kMessage`),c=Symbol(`kReason`),l=Symbol(`kTarget`),u=Symbol(`kType`),d=Symbol(`kWasClean`);var f=class{constructor(e){this[l]=null,this[u]=e}get target(){return this[l]}get type(){return this[u]}};Object.defineProperty(f.prototype,`target`,{enumerable:!0}),Object.defineProperty(f.prototype,`type`,{enumerable:!0});var p=class extends f{constructor(e,t={}){super(e),this[i]=t.code===void 0?0:t.code,this[c]=t.reason===void 0?``:t.reason,this[d]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[i]}get reason(){return this[c]}get wasClean(){return this[d]}};Object.defineProperty(p.prototype,`code`,{enumerable:!0}),Object.defineProperty(p.prototype,`reason`,{enumerable:!0}),Object.defineProperty(p.prototype,`wasClean`,{enumerable:!0});var m=class extends f{constructor(e,t={}){super(e),this[o]=t.error===void 0?null:t.error,this[s]=t.message===void 0?``:t.message}get error(){return this[o]}get message(){return this[s]}};Object.defineProperty(m.prototype,`error`,{enumerable:!0}),Object.defineProperty(m.prototype,`message`,{enumerable:!0});var h=class extends f{constructor(e,t={}){super(e),this[a]=t.data===void 0?null:t.data}get data(){return this[a]}};Object.defineProperty(h.prototype,`data`,{enumerable:!0}),t.exports={CloseEvent:p,ErrorEvent:m,Event:f,EventTarget:{addEventListener(e,t,i={}){for(let a of this.listeners(e))if(!i[n]&&a[r]===t&&!a[n])return;let a;if(e===`message`)a=function(e,n){let r=new h(`message`,{data:n?e:e.toString()});r[l]=this,g(t,this,r)};else if(e===`close`)a=function(e,n){let r=new p(`close`,{code:e,reason:n.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});r[l]=this,g(t,this,r)};else if(e===`error`)a=function(e){let n=new m(`error`,{error:e,message:e.message});n[l]=this,g(t,this,n)};else if(e===`open`)a=function(){let e=new f(`open`);e[l]=this,g(t,this,e)};else return;a[n]=!!i[n],a[r]=t,i.once?this.once(e,a):this.on(e,a)},removeEventListener(e,t){for(let i of this.listeners(e))if(i[r]===t&&!i[n]){this.removeListener(e,i);break}}},MessageEvent:h};function g(e,t,n){typeof e==`object`&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}})),k5=x5(((e,t)=>{let{tokenChars:n}=E5();function r(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function i(e){let t=Object.create(null),i=Object.create(null),a=!1,o=!1,s=!1,c,l,u=-1,d=-1,f=-1,p=0;for(;p<e.length;p++)if(d=e.charCodeAt(p),c===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(p!==0&&(d===32||d===9))f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);d===44?(r(t,n,i),i=Object.create(null)):c=n,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);else if(l===void 0)if(f===-1&&n[d]===1)u===-1&&(u=p);else if(d===32||d===9)f===-1&&u!==-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p),r(i,e.slice(u,f),!0),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),u=f=-1}else if(d===61&&u!==-1&&f===-1)l=e.slice(u,p),u=f=-1;else throw SyntaxError(`Unexpected character at index ${p}`);else if(o){if(n[d]!==1)throw SyntaxError(`Unexpected character at index ${p}`);u===-1?u=p:a||=!0,o=!1}else if(s)if(n[d]===1)u===-1&&(u=p);else if(d===34&&u!==-1)s=!1,f=p;else if(d===92)o=!0;else throw SyntaxError(`Unexpected character at index ${p}`);else if(d===34&&e.charCodeAt(p-1)===61)s=!0;else if(f===-1&&n[d]===1)u===-1&&(u=p);else if(u!==-1&&(d===32||d===9))f===-1&&(f=p);else if(d===59||d===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let n=e.slice(u,f);a&&=(n=n.replace(/\\/g,``),!1),r(i,l,n),d===44&&(r(t,c,i),i=Object.create(null),c=void 0),l=void 0,u=f=-1}else throw SyntaxError(`Unexpected character at index ${p}`);if(u===-1||s||d===32||d===9)throw SyntaxError(`Unexpected end of input`);f===-1&&(f=p);let m=e.slice(u,f);return c===void 0?r(t,m,i):(l===void 0?r(i,m,!0):a?r(i,l,m.replace(/\\/g,``)):r(i,l,m),r(t,c,i)),t}function a(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>[t].concat(Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(e=>e===!0?t:`${t}=${e}`).join(`; `)})).join(`; `)).join(`, `)}).join(`, `)}t.exports={format:a,parse:i}})),A5=x5(((e,t)=>{let n=S5(`events`),r=S5(`https`),i=S5(`http`),a=S5(`net`),o=S5(`tls`),{randomBytes:s,createHash:c}=S5(`crypto`),{Duplex:l,Readable:u}=S5(`stream`),{URL:d}=S5(`url`),f=T5(),p=D5(),m=O5(),{isBlob:h}=E5(),{BINARY_TYPES:g,CLOSE_TIMEOUT:_,EMPTY_BUFFER:v,GUID:y,kForOnEventAttribute:b,kListener:x,kStatusCode:S,kWebSocket:C,NOOP:w}=C5(),{EventTarget:{addEventListener:T,removeEventListener:E}}=PSe(),{format:D,parse:O}=k5(),{toBuffer:ee}=w5(),te=Symbol(`kAborted`),ne=[8,13],re=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],ie=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;var ae=class e extends n{constructor(t,n,r){super(),this._binaryType=g[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=v,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol=``,this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t===null?(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0):(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n==`object`&&n?(r=n,n=[]):n=[n]),oe(this,t,n,r))}get binaryType(){return this._binaryType}set binaryType(e){g.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,n,r){let i=new p({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),a=new m(t,this._extensions,r.generateMask);this._receiver=i,this._sender=a,this._socket=t,i[C]=this,a[C]=this,t[C]=this,i.on(`conclude`,A),i.on(`drain`,j),i.on(`error`,de),i.on(`message`,pe),i.on(`ping`,me),i.on(`pong`,M),a.onerror=he,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on(`close`,_e),t.on(`data`,ve),t.on(`end`,ye),t.on(`error`,be),this._readyState=e.OPEN,this.emit(`open`)}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage);return}this._extensions[f.extensionName]&&this._extensions[f.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){le(this,this._req,`WebSocket was closed before the connection was established`);return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ge(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ue(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||v,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof t==`function`?(r=t,t=n=void 0):typeof n==`function`&&(r=n,n=void 0),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ue(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||v,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw Error(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeof n==`function`&&(r=n,n={}),typeof t==`number`&&(t=t.toString()),this.readyState!==e.OPEN){ue(this,t,r);return}let i={binary:typeof t!=`string`,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[f.extensionName]||(i.compress=!1),this._sender.send(t||v,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){le(this,this._req,`WebSocket was closed before the connection was established`);return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(ae,`CONNECTING`,{enumerable:!0,value:re.indexOf(`CONNECTING`)}),Object.defineProperty(ae.prototype,`CONNECTING`,{enumerable:!0,value:re.indexOf(`CONNECTING`)}),Object.defineProperty(ae,`OPEN`,{enumerable:!0,value:re.indexOf(`OPEN`)}),Object.defineProperty(ae.prototype,`OPEN`,{enumerable:!0,value:re.indexOf(`OPEN`)}),Object.defineProperty(ae,`CLOSING`,{enumerable:!0,value:re.indexOf(`CLOSING`)}),Object.defineProperty(ae.prototype,`CLOSING`,{enumerable:!0,value:re.indexOf(`CLOSING`)}),Object.defineProperty(ae,`CLOSED`,{enumerable:!0,value:re.indexOf(`CLOSED`)}),Object.defineProperty(ae.prototype,`CLOSED`,{enumerable:!0,value:re.indexOf(`CLOSED`)}),[`binaryType`,`bufferedAmount`,`extensions`,`isPaused`,`protocol`,`readyState`,`url`].forEach(e=>{Object.defineProperty(ae.prototype,e,{enumerable:!0})}),[`open`,`error`,`close`,`message`].forEach(e=>{Object.defineProperty(ae.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[b])return t[x];return null},set(t){for(let t of this.listeners(e))if(t[b]){this.removeListener(e,t);break}typeof t==`function`&&this.addEventListener(e,t,{[b]:!0})}})}),ae.prototype.addEventListener=T,ae.prototype.removeEventListener=E,t.exports=ae;function oe(e,t,n,a){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:_,protocolVersion:ne[1],maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...a,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:`GET`,host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!ne.includes(o.protocolVersion))throw RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${ne.join(`, `)})`);let l;if(t instanceof d)l=t;else try{l=new d(t)}catch{throw SyntaxError(`Invalid URL: ${t}`)}l.protocol===`http:`?l.protocol=`ws:`:l.protocol===`https:`&&(l.protocol=`wss:`),e._url=l.href;let u=l.protocol===`wss:`,p=l.protocol===`ws+unix:`,m;if(l.protocol!==`ws:`&&!u&&!p?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:p&&!l.pathname?m=`The URL's pathname is empty`:l.hash&&(m=`The URL contains a fragment identifier`),m){let t=SyntaxError(m);if(e._redirects===0)throw t;se(e,t);return}let h=u?443:80,g=s(16).toString(`base64`),v=u?r.request:i.request,b=new Set,x;if(o.createConnection=o.createConnection||(u?ce:k),o.defaultPort=o.defaultPort||h,o.port=l.port||h,o.host=l.hostname.startsWith(`[`)?l.hostname.slice(1,-1):l.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":g,Connection:`Upgrade`,Upgrade:`websocket`},o.path=l.pathname+l.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(x=new f(o.perMessageDeflate===!0?{}:o.perMessageDeflate,!1,o.maxPayload),o.headers[`Sec-WebSocket-Extensions`]=D({[f.extensionName]:x.offer()})),n.length){for(let e of n){if(typeof e!=`string`||!ie.test(e)||b.has(e))throw SyntaxError(`An invalid or duplicated subprotocol was specified`);b.add(e)}o.headers[`Sec-WebSocket-Protocol`]=n.join(`,`)}if(o.origin&&(o.protocolVersion<13?o.headers[`Sec-WebSocket-Origin`]=o.origin:o.headers.Origin=o.origin),(l.username||l.password)&&(o.auth=`${l.username}:${l.password}`),p){let e=o.path.split(`:`);o.socketPath=e[0],o.path=e[1]}let S;if(o.followRedirects){if(e._redirects===0){e._originalIpc=p,e._originalSecure=u,e._originalHostOrSocketPath=p?o.socketPath:l.host;let t=a&&a.headers;if(a={...a,headers:{}},t)for(let[e,n]of Object.entries(t))a.headers[e.toLowerCase()]=n}else if(e.listenerCount(`redirect`)===0){let t=p?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:l.host===e._originalHostOrSocketPath;(!t||e._originalSecure&&!u)&&(delete o.headers.authorization,delete o.headers.cookie,t||delete o.headers.host,o.auth=void 0)}o.auth&&!a.headers.authorization&&(a.headers.authorization=`Basic `+Buffer.from(o.auth).toString(`base64`)),S=e._req=v(o),e._redirects&&e.emit(`redirect`,e.url,S)}else S=e._req=v(o);o.timeout&&S.on(`timeout`,()=>{le(e,S,`Opening handshake has timed out`)}),S.on(`error`,t=>{S===null||S[te]||(S=e._req=null,se(e,t))}),S.on(`response`,r=>{let i=r.headers.location,s=r.statusCode;if(i&&o.followRedirects&&s>=300&&s<400){if(++e._redirects>o.maxRedirects){le(e,S,`Maximum redirects exceeded`);return}S.abort();let r;try{r=new d(i,t)}catch{se(e,SyntaxError(`Invalid URL: ${i}`));return}oe(e,r,n,a)}else e.emit(`unexpected-response`,S,r)||le(e,S,`Unexpected server response: ${r.statusCode}`)}),S.on(`upgrade`,(t,n,r)=>{if(e.emit(`upgrade`,t),e.readyState!==ae.CONNECTING)return;S=e._req=null;let i=t.headers.upgrade;if(i===void 0||i.toLowerCase()!==`websocket`){le(e,n,`Invalid Upgrade header`);return}let a=c(`sha1`).update(g+y).digest(`base64`);if(t.headers[`sec-websocket-accept`]!==a){le(e,n,`Invalid Sec-WebSocket-Accept header`);return}let s=t.headers[`sec-websocket-protocol`],l;if(s===void 0?b.size&&(l=`Server sent no subprotocol`):b.size?b.has(s)||(l=`Server sent an invalid subprotocol`):l=`Server sent a subprotocol but none was requested`,l){le(e,n,l);return}s&&(e._protocol=s);let u=t.headers[`sec-websocket-extensions`];if(u!==void 0){if(!x){le(e,n,`Server sent a Sec-WebSocket-Extensions header but no extension was requested`);return}let t;try{t=O(u)}catch{le(e,n,`Invalid Sec-WebSocket-Extensions header`);return}let r=Object.keys(t);if(r.length!==1||r[0]!==f.extensionName){le(e,n,`Server indicated an extension that was not requested`);return}try{x.accept(t[f.extensionName])}catch{le(e,n,`Invalid Sec-WebSocket-Extensions header`);return}e._extensions[f.extensionName]=x}e.setSocket(n,r,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,e):S.end()}function se(e,t){e._readyState=ae.CLOSING,e._errorEmitted=!0,e.emit(`error`,t),e.emitClose()}function k(e){return e.path=e.socketPath,a.connect(e)}function ce(e){return e.path=void 0,!e.servername&&e.servername!==``&&(e.servername=a.isIP(e.host)?``:e.host),o.connect(e)}function le(e,t,n){e._readyState=ae.CLOSING;let r=Error(n);Error.captureStackTrace(r,le),t.setHeader?(t[te]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(se,e,r)):(t.destroy(r),t.once(`error`,e.emit.bind(e,`error`)),t.once(`close`,e.emitClose.bind(e)))}function ue(e,t,n){if(t){let n=h(t)?t.size:ee(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n}if(n){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${re[e.readyState]})`);process.nextTick(n,t)}}function A(e,t){let n=this[C];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[C]!==void 0&&(n._socket.removeListener(`data`,ve),process.nextTick(N,n._socket),e===1005?n.close():n.close(e,t))}function j(){let e=this[C];e.isPaused||e._socket.resume()}function de(e){let t=this[C];t._socket[C]!==void 0&&(t._socket.removeListener(`data`,ve),process.nextTick(N,t._socket),t.close(e[S])),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e))}function fe(){this[C].emitClose()}function pe(e,t){this[C].emit(`message`,e,t)}function me(e){let t=this[C];t._autoPong&&t.pong(e,!this._isServer,w),t.emit(`ping`,e)}function M(e){this[C].emit(`pong`,e)}function N(e){e.resume()}function he(e){let t=this[C];t.readyState!==ae.CLOSED&&(t.readyState===ae.OPEN&&(t._readyState=ae.CLOSING,ge(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit(`error`,e)))}function ge(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function _e(){let e=this[C];if(this.removeListener(`close`,_e),this.removeListener(`data`,ve),this.removeListener(`end`,ye),e._readyState=ae.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[C]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on(`error`,fe),e._receiver.on(`finish`,fe))}function ve(e){this[C]._receiver.write(e)||this.pause()}function ye(){let e=this[C];e._readyState=ae.CLOSING,e._receiver.end(),this.end()}function be(){let e=this[C];this.removeListener(`error`,be),this.on(`error`,w),e&&(e._readyState=ae.CLOSING,this.destroy())}})),FSe=x5(((e,t)=>{A5();let{Duplex:n}=S5(`stream`);function r(e){e.emit(`close`)}function i(){!this.destroyed&&this._writableState.finished&&this.destroy()}function a(e){this.removeListener(`error`,a),this.destroy(),this.listenerCount(`error`)===0&&this.emit(`error`,e)}function o(e,t){let o=!0,s=new n({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on(`message`,function(t,n){let r=!n&&s._readableState.objectMode?t.toString():t;s.push(r)||e.pause()}),e.once(`error`,function(e){s.destroyed||(o=!1,s.destroy(e))}),e.once(`close`,function(){s.destroyed||s.push(null)}),s._destroy=function(t,n){if(e.readyState===e.CLOSED){n(t),process.nextTick(r,s);return}let i=!1;e.once(`error`,function(e){i=!0,n(e)}),e.once(`close`,function(){i||n(t),process.nextTick(r,s)}),o&&e.terminate()},s._final=function(t){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._final(t)});return}e._socket!==null&&(e._socket._writableState.finished?(t(),s._readableState.endEmitted&&s.destroy()):(e._socket.once(`finish`,function(){t()}),e.close()))},s._read=function(){e.isPaused&&e.resume()},s._write=function(t,n,r){if(e.readyState===e.CONNECTING){e.once(`open`,function(){s._write(t,n,r)});return}e.send(t,r)},s.on(`end`,i),s.on(`error`,a),s}t.exports=o})),ISe=x5(((e,t)=>{let{tokenChars:n}=E5();function r(e){let t=new Set,r=-1,i=-1,a=0;for(;a<e.length;a++){let o=e.charCodeAt(a);if(i===-1&&n[o]===1)r===-1&&(r=a);else if(a!==0&&(o===32||o===9))i===-1&&r!==-1&&(i=a);else if(o===44){if(r===-1)throw SyntaxError(`Unexpected character at index ${a}`);i===-1&&(i=a);let n=e.slice(r,i);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);t.add(n),r=i=-1}else throw SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||i!==-1)throw SyntaxError(`Unexpected end of input`);let o=e.slice(r,a);if(t.has(o))throw SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}t.exports={parse:r}})),LSe=x5(((e,t)=>{let n=S5(`events`),r=S5(`http`),{Duplex:i}=S5(`stream`),{createHash:a}=S5(`crypto`),o=k5(),s=T5(),c=ISe(),l=A5(),{CLOSE_TIMEOUT:u,GUID:d,kWebSocket:f}=C5(),p=/^[+/0-9A-Za-z]{22}==$/;t.exports=class extends n{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:u,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:l,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError(`One and only one of the "port", "server", or "noServer" options must be specified`);if(e.port==null?e.server&&(this._server=e.server):(this._server=r.createServer((e,t)=>{let n=r.STATUS_CODES[426];t.writeHead(426,{"Content-Length":n.length,"Content-Type":`text/plain`}),t.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)),this._server){let e=this.emit.bind(this,`connection`);this._removeListeners=m(this._server,{listening:this.emit.bind(this,`listening`),error:this.emit.bind(this,`error`),upgrade:(t,n,r)=>{this.handleUpgrade(t,n,r,e)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error(`The server is operating in "noServer" mode`);return this._server?this._server.address():null}close(e){if(this._state===2){e&&this.once(`close`,()=>{e(Error(`The server is not running`))}),process.nextTick(h,this);return}if(e&&this.once(`close`,e),this._state!==1)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(h,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{h(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf(`?`);if((t===-1?e.url:e.url.slice(0,t))!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,r){t.on(`error`,g);let i=e.headers[`sec-websocket-key`],a=e.headers.upgrade,l=+e.headers[`sec-websocket-version`];if(e.method!==`GET`){v(this,e,t,405,`Invalid HTTP method`);return}if(a===void 0||a.toLowerCase()!==`websocket`){v(this,e,t,400,`Invalid Upgrade header`);return}if(i===void 0||!p.test(i)){v(this,e,t,400,`Missing or invalid Sec-WebSocket-Key header`);return}if(l!==13&&l!==8){v(this,e,t,400,`Missing or invalid Sec-WebSocket-Version header`,{"Sec-WebSocket-Version":`13, 8`});return}if(!this.shouldHandle(e)){_(t,400);return}let u=e.headers[`sec-websocket-protocol`],d=new Set;if(u!==void 0)try{d=c.parse(u)}catch{v(this,e,t,400,`Invalid Sec-WebSocket-Protocol header`);return}let f=e.headers[`sec-websocket-extensions`],m={};if(this.options.perMessageDeflate&&f!==void 0){let n=new s(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let e=o.parse(f);e[s.extensionName]&&(n.accept(e[s.extensionName]),m[s.extensionName]=n)}catch{v(this,e,t,400,`Invalid or unacceptable Sec-WebSocket-Extensions header`);return}}if(this.options.verifyClient){let a={origin:e.headers[`${l===8?`sec-websocket-origin`:`origin`}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(a,(a,o,s,c)=>{if(!a)return _(t,o||401,s,c);this.completeUpgrade(m,i,d,e,t,n,r)});return}if(!this.options.verifyClient(a))return _(t,401)}this.completeUpgrade(m,i,d,e,t,n,r)}completeUpgrade(e,t,n,r,i,c,l){if(!i.readable||!i.writable)return i.destroy();if(i[f])throw Error(`server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration`);if(this._state>0)return _(i,503);let u=[`HTTP/1.1 101 Switching Protocols`,`Upgrade: websocket`,`Connection: Upgrade`,`Sec-WebSocket-Accept: ${a(`sha1`).update(t+d).digest(`base64`)}`],p=new this.options.WebSocket(null,void 0,this.options);if(n.size){let e=this.options.handleProtocols?this.options.handleProtocols(n,r):n.values().next().value;e&&(u.push(`Sec-WebSocket-Protocol: ${e}`),p._protocol=e)}if(e[s.extensionName]){let t=e[s.extensionName].params,n=o.format({[s.extensionName]:[t]});u.push(`Sec-WebSocket-Extensions: ${n}`),p._extensions=e}this.emit(`headers`,u,r),i.write(u.concat(`\r
829
833
  `).join(`\r
830
834
  `)),i.removeListener(`error`,g),p.setSocket(i,c,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(p),p.on(`close`,()=>{this.clients.delete(p),this._shouldEmitClose&&!this.clients.size&&process.nextTick(h,this)})),l(p,r)}};function m(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let n of Object.keys(t))e.removeListener(n,t[n])}}function h(e){e._state=2,e.emit(`close`)}function g(){this.destroy()}function _(e,t,n,i){n||=r.STATUS_CODES[t],i={Connection:`close`,"Content-Type":`text/html`,"Content-Length":Buffer.byteLength(n),...i},e.once(`finish`,e.destroy),e.end(`HTTP/1.1 ${t} ${r.STATUS_CODES[t]}\r\n`+Object.keys(i).map(e=>`${e}: ${i[e]}`).join(`\r
831
835
  `)+`\r
832
836
  \r
833
- `+n)}function v(e,t,n,r,i,a){if(e.listenerCount(`wsClientError`)){let r=Error(i);Error.captureStackTrace(r,v),e.emit(`wsClientError`,r,n,t)}else _(n,r,i,a)}}));PSe(),D5(),O5(),A5(),ISe(),W$(`config-persistence`),W$(`generated-index-git-attributes`),W$(`head-watcher`),W$(`shadow-gc`),W$(`shadow-maintenance`),(()=>{let e=process.env.OK_SHADOW_MAINTENANCE_DEAD_CHAIN_THRESHOLD;if(!e)return 5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:5})(),(()=>{let e=process.env.OK_SHADOW_MAINTENANCE_CONSOLIDATION_SPACING_MS;if(!e)return 600*1e3;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:600*1e3})(),W$(`mermaid-persistence`),W$(`persistence`),W$(`persistence-staleness`),W$(`recovered-file-target`),W$(`removed-docs-journal`),W$(`server-observers`),W$(`github-permissions`),W$(`github-account`),W$(`sync-engine`),new Set([`.mcp.json`,`.cursor/mcp.json`,`.codex/config.toml`,`opencode.json`]),Fe(s),(()=>{let e=Object.freeze({origin:`park-snapshot`,paired:!0});return Object.freeze({source:`local`,skipStoreHooks:!1,context:e})})(),(()=>{let e=Object.freeze({origin:`generated-index`,paired:!0});return Object.freeze({source:`local`,skipStoreHooks:!1,context:e})})();let j5=null;G$(()=>{j5?.disable(),j5=null}),W$(`skill-migrate`);function M5(e){return[{host:`agents`,root:Yl},...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({host:e,root:t}))].sort((e,t)=>{let n=f3.indexOf(e.host),r=f3.indexOf(t.host);return(n===-1?f3.length:n)-(r===-1?f3.length:r)||e.host.localeCompare(t.host)})}M5(Il),M5(Ll),W$(`skill-reconcile`),[...Rl],Number(process.env.OK_DESTROY_STEP_TIMEOUT_MS);const LSe=ws;N(oe(),`.ok`,`logs`),Fe(s),W$(`project-git`),W$(`project-skill-git`),Bl.map(e=>e.replace(/\/$/,``));const N5=Pl,P5=Fl,RSe=Vl,F5=`node`,I5={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},L5=`# ok-mcp-v2
837
+ `+n)}function v(e,t,n,r,i,a){if(e.listenerCount(`wsClientError`)){let r=Error(i);Error.captureStackTrace(r,v),e.emit(`wsClientError`,r,n,t)}else _(n,r,i,a)}}));FSe(),D5(),O5(),A5(),LSe(),W$(`config-persistence`),W$(`generated-index-git-attributes`),W$(`head-watcher`),W$(`shadow-gc`),W$(`shadow-maintenance`),(()=>{let e=process.env.OK_SHADOW_MAINTENANCE_DEAD_CHAIN_THRESHOLD;if(!e)return 5;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:5})(),(()=>{let e=process.env.OK_SHADOW_MAINTENANCE_CONSOLIDATION_SPACING_MS;if(!e)return 600*1e3;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:600*1e3})(),W$(`mermaid-persistence`),W$(`persistence`),W$(`persistence-staleness`),W$(`recovered-file-target`),W$(`removed-docs-journal`),W$(`server-observers`),W$(`github-permissions`),W$(`github-account`),W$(`sync-engine`),new Set([`.mcp.json`,`.cursor/mcp.json`,`.codex/config.toml`,`opencode.json`]),Fe(s),(()=>{let e=Object.freeze({origin:`park-snapshot`,paired:!0});return Object.freeze({source:`local`,skipStoreHooks:!1,context:e})})(),(()=>{let e=Object.freeze({origin:`generated-index`,paired:!0});return Object.freeze({source:`local`,skipStoreHooks:!1,context:e})})();let j5=null;G$(()=>{j5?.disable(),j5=null}),W$(`skill-migrate`);function M5(e){return[{host:`agents`,root:Yl},...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({host:e,root:t}))].sort((e,t)=>{let n=f3.indexOf(e.host),r=f3.indexOf(t.host);return(n===-1?f3.length:n)-(r===-1?f3.length:r)||e.host.localeCompare(t.host)})}M5(Il),M5(Ll),W$(`skill-reconcile`),[...Rl],Number(process.env.OK_DESTROY_STEP_TIMEOUT_MS);const RSe=ws;N(oe(),`.ok`,`logs`),Fe(s),W$(`project-git`),W$(`project-skill-git`),Bl.map(e=>e.replace(/\/$/,``));const N5=Pl,P5=Fl,zSe=Vl,F5=`node`,I5={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},L5=`# ok-mcp-v2
834
838
  USER_BUNDLE="$HOME/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
835
839
  [ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
836
840
  BUNDLE="/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
@@ -866,7 +870,7 @@ foreach ($d in $dirs) {
866
870
  if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '@inkeep/open-knowledge@latest' mcp; exit $LASTEXITCODE }
867
871
  }
868
872
  [Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
869
- exit 127`,z5=`// ok-pi-bridge`,B5=`${z5}-v1`;function V5(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(B5)}return!1}function H5(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=ve(e);if(fe(t)===`cli.mjs`&&fe(pe(t))===`dist`)return t;let n=t.split(ye),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return N(i.length===0?ye:i.join(ye),`packages`,`cli`,`dist`,`cli.mjs`)}function U5(e={}){return e.mode===`dev`?{command:F5,args:[H5(),`mcp`],env:{...I5}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,R5]}:{command:`/bin/sh`,args:[`-l`,`-c`,L5]}}function zSe(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[F5,H5(),`mcp`],environment:{...I5}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,R5]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,L5]}}function W5(e){if(typeof e!=`object`||!e)return!1;let t=e;return G5(t,U5({mode:`published`,platformName:`darwin`}))||G5(t,U5({mode:`published`,platformName:`win32`}))}function G5(e,t){return Object.keys(e).length===Object.keys(t).length?BSe(e,t):!1}function BSe(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function K5(e,t){let n=e=>typeof e==`string`&&e.includes(`# ok-mcp`);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`?e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3]):!1}function VSe(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:K5(t.args,t.command)}function HSe(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&K5(r,n)}function q5(e){return e===`win32`?be:ge}function USe(e={}){let t=e.platformName??process.platform,n=e.home??oe();return q5(t).join(n,`.claude.json`)}function J5(e={}){let t=e.platformName??process.platform,n=e.home??oe(),r=e.env??process.env;if(t===`darwin`)return ge.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??be.join(n,`AppData`,`Roaming`);return be.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Y5(e={}){let t=e.platformName??process.platform,n=e.home??oe();return q5(t).join(n,`.cursor`,`mcp.json`)}function WSe(e={}){let t=e.platformName??process.platform,n=e.home??oe();return(e.env??process.env).CODEX_HOME??q5(t).join(n,`.codex`)}function X5(e={}){return q5(e.platformName??process.platform).join(WSe(e),`config.toml`)}function Z5(e={}){let t=e.platformName??process.platform,n=e.home??oe(),r=(e.env??process.env).COPILOT_HOME??q5(t).join(n,`.copilot`);return q5(t).join(r,`mcp-config.json`)}function GSe(e={}){let t=e.platformName??process.platform,n=e.home??oe(),r=e.env??process.env,i=q5(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function Q5(e={}){return q5(e.platformName??process.platform).join(GSe(e),`opencode.json`)}function KSe(e={}){let t=e.platformName??process.platform,n=e.home??oe();return q5(t).join(n,`.openclaw`,`openclaw.json`)}function qSe(e={}){let t=e.platformName??process.platform,n=e.home??oe();return q5(t).join(n,`.hermes`,`config.yaml`)}function $5(e={}){let t=e.platformName??process.platform,n=e.home??oe();return(e.env??process.env).PI_CODING_AGENT_DIR??q5(t).join(n,`.pi`,`agent`)}function JSe(e={}){let t=e.platformName??process.platform,n=e.home??oe();return q5(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function YSe(e,t){let n=q5(t),r=n.join(e,`.lmstudio`,`mcp.json`),i=n.join(e,`.cache`,`lm-studio`,`mcp.json`);return t===`darwin`?[i,r]:[r,i]}function e7(e={}){let t=e.platformName??process.platform,n=YSe(e.home??oe(),t);return n.find(e=>g(e))||n.find(e=>g(pe(e)))||n[0]}function XSe(e){let t=e.serverName(``);return e.format===`toml`?`[${e.topLevelKey}.${t}]`:[e.topLevelKey,e.serverMapSubKey,t].filter(Boolean).join(`.`)}function ZSe(e,t){let n;try{n=e.configPath(``,t)}catch{return null}return n.startsWith(`${t}/`)?`~${n.slice(t.length)}`:n}const t7={claude:{id:`claude`,label:P5.claude,configPath:(e,t)=>USe({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>N(t??oe(),`.claude`),projectConfigPath:e=>N(e,`.mcp.json`),projectSkillPath:e=>N(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:P5[`claude-desktop`],configPath:(e,t)=>J5({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>pe(J5({home:t}))},cursor:{id:`cursor`,label:P5.cursor,configPath:(e,t)=>Y5({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>pe(Y5({home:t})),projectConfigPath:e=>N(e,`.cursor`,`mcp.json`),projectSkillPath:e=>N(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:P5.codex,configPath:(e,t)=>X5({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>pe(X5({home:t})),projectConfigPath:e=>N(e,`.codex`,`config.toml`),projectSkillPath:e=>N(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:P5.copilot,configPath:(e,t)=>Z5({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>pe(Z5({home:t})),projectSkillPath:e=>N(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:P5.opencode,configPath:(e,t)=>Q5({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>ql,buildEntry:(e,t)=>zSe(t),scope:`global`,detectPath:(e,t)=>pe(Q5({home:t})),projectConfigPath:e=>N(e,`opencode.json`),projectSkillPath:e=>N(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:P5.openclaw,configPath:(e,t)=>KSe({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>N(t??oe(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:P5.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>$5({home:t}),projectConfigPath:e=>N(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>N(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:P5.antigravity,configPath:(e,t)=>JSe({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>N(t??oe(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:P5[`lm-studio`],configPath:(e,t)=>e7({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>pe(e7({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:P5.hermes,configPath:(e,t)=>qSe({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>N(t??oe(),`.hermes`),offerOnlyWhenDetected:!0}};function QSe(e){let t=e.filter(e=>!Object.hasOwn(t7,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${N5.join(`, `)}`);return e.map(e=>t7[e])}var n7=i((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),r7=i((e=>{let{InvalidArgumentError:t}=n7();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),i7=i((e=>{let{humanReadableArgName:t}=r7();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
873
+ exit 127`,z5=`// ok-pi-bridge`,B5=`${z5}-v1`;function V5(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v2`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(B5)}return!1}function H5(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=ve(e);if(fe(t)===`cli.mjs`&&fe(pe(t))===`dist`)return t;let n=t.split(ye),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return N(i.length===0?ye:i.join(ye),`packages`,`cli`,`dist`,`cli.mjs`)}function U5(e={}){return e.mode===`dev`?{command:F5,args:[H5(),`mcp`],env:{...I5}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,R5]}:{command:`/bin/sh`,args:[`-l`,`-c`,L5]}}function BSe(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[F5,H5(),`mcp`],environment:{...I5}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,R5]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,L5]}}function W5(e){if(typeof e!=`object`||!e)return!1;let t=e;return G5(t,U5({mode:`published`,platformName:`darwin`}))||G5(t,U5({mode:`published`,platformName:`win32`}))}function G5(e,t){return Object.keys(e).length===Object.keys(t).length?VSe(e,t):!1}function VSe(e,t){if(e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function K5(e,t){let n=e=>typeof e==`string`&&e.includes(`# ok-mcp`);return t===`/bin/sh`?e[0]===`-l`&&e[1]===`-c`&&n(e[2]):t===`powershell`?e[0]===`-NoProfile`&&e[1]===`-NonInteractive`&&e[2]===`-Command`&&n(e[3]):!1}function HSe(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.enabled===!1||typeof t.command!=`string`||!Array.isArray(t.args)?!1:K5(t.args,t.command)}function USe(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.type!==`local`||t.enabled===!1||!Array.isArray(t.command))return!1;let[n,...r]=t.command;return typeof n==`string`&&K5(r,n)}function q5(e){return e===`win32`?be:ge}function WSe(e={}){let t=e.platformName??process.platform,n=e.home??oe();return q5(t).join(n,`.claude.json`)}function J5(e={}){let t=e.platformName??process.platform,n=e.home??oe(),r=e.env??process.env;if(t===`darwin`)return ge.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??be.join(n,`AppData`,`Roaming`);return be.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function Y5(e={}){let t=e.platformName??process.platform,n=e.home??oe();return q5(t).join(n,`.cursor`,`mcp.json`)}function GSe(e={}){let t=e.platformName??process.platform,n=e.home??oe();return(e.env??process.env).CODEX_HOME??q5(t).join(n,`.codex`)}function X5(e={}){return q5(e.platformName??process.platform).join(GSe(e),`config.toml`)}function Z5(e={}){let t=e.platformName??process.platform,n=e.home??oe(),r=(e.env??process.env).COPILOT_HOME??q5(t).join(n,`.copilot`);return q5(t).join(r,`mcp-config.json`)}function KSe(e={}){let t=e.platformName??process.platform,n=e.home??oe(),r=e.env??process.env,i=q5(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function Q5(e={}){return q5(e.platformName??process.platform).join(KSe(e),`opencode.json`)}function qSe(e={}){let t=e.platformName??process.platform,n=e.home??oe();return q5(t).join(n,`.openclaw`,`openclaw.json`)}function JSe(e={}){let t=e.platformName??process.platform,n=e.home??oe();return q5(t).join(n,`.hermes`,`config.yaml`)}function $5(e={}){let t=e.platformName??process.platform,n=e.home??oe();return(e.env??process.env).PI_CODING_AGENT_DIR??q5(t).join(n,`.pi`,`agent`)}function YSe(e={}){let t=e.platformName??process.platform,n=e.home??oe();return q5(t).join(n,`.gemini`,`config`,`mcp_config.json`)}function XSe(e,t){let n=q5(t),r=n.join(e,`.lmstudio`,`mcp.json`),i=n.join(e,`.cache`,`lm-studio`,`mcp.json`);return t===`darwin`?[i,r]:[r,i]}function e7(e={}){let t=e.platformName??process.platform,n=XSe(e.home??oe(),t);return n.find(e=>g(e))||n.find(e=>g(pe(e)))||n[0]}function ZSe(e){let t=e.serverName(``);return e.format===`toml`?`[${e.topLevelKey}.${t}]`:[e.topLevelKey,e.serverMapSubKey,t].filter(Boolean).join(`.`)}function QSe(e,t){let n;try{n=e.configPath(``,t)}catch{return null}return n.startsWith(`${t}/`)?`~${n.slice(t.length)}`:n}const t7={claude:{id:`claude`,label:P5.claude,configPath:(e,t)=>WSe({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>N(t??oe(),`.claude`),projectConfigPath:e=>N(e,`.mcp.json`),projectSkillPath:e=>N(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:P5[`claude-desktop`],configPath:(e,t)=>J5({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>pe(J5({home:t}))},cursor:{id:`cursor`,label:P5.cursor,configPath:(e,t)=>Y5({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>pe(Y5({home:t})),projectConfigPath:e=>N(e,`.cursor`,`mcp.json`),projectSkillPath:e=>N(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:P5.codex,configPath:(e,t)=>X5({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>pe(X5({home:t})),projectConfigPath:e=>N(e,`.codex`,`config.toml`),projectSkillPath:e=>N(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},copilot:{id:`copilot`,label:P5.copilot,configPath:(e,t)=>Z5({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>pe(Z5({home:t})),projectSkillPath:e=>N(e,`.github`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:P5.opencode,configPath:(e,t)=>Q5({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>ql,buildEntry:(e,t)=>BSe(t),scope:`global`,detectPath:(e,t)=>pe(Q5({home:t})),projectConfigPath:e=>N(e,`opencode.json`),projectSkillPath:e=>N(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:P5.openclaw,configPath:(e,t)=>qSe({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>N(t??oe(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:P5.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>$5({home:t}),projectConfigPath:e=>N(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>N(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)},antigravity:{id:`antigravity`,label:P5.antigravity,configPath:(e,t)=>YSe({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>N(t??oe(),`.gemini`),offerOnlyWhenDetected:!0},"lm-studio":{id:`lm-studio`,label:P5[`lm-studio`],configPath:(e,t)=>e7({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>pe(e7({home:t})),offerOnlyWhenDetected:!0},hermes:{id:`hermes`,label:P5.hermes,configPath:(e,t)=>JSe({home:t}),format:`yaml`,topLevelKey:`mcp_servers`,serverName:()=>ql,buildEntry:(e,t)=>U5(t),scope:`global`,detectPath:(e,t)=>N(t??oe(),`.hermes`),offerOnlyWhenDetected:!0}};function $Se(e){let t=e.filter(e=>!Object.hasOwn(t7,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${N5.join(`, `)}`);return e.map(e=>t7[e])}var n7=i((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),r7=i((e=>{let{InvalidArgumentError:t}=n7();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),i7=i((e=>{let{humanReadableArgName:t}=r7();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
870
874
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
871
875
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
872
876
  `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),a7=i((e=>{let{InvalidArgumentError:t}=n7();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -875,7 +879,7 @@ exit 127`,z5=`// ok-pi-bridge`,B5=`${z5}-v1`;function V5(e){if(typeof e!=`object
875
879
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(t)?Error(`${n}
876
880
  - too many short flags`):i.test(t)?Error(`${n}
877
881
  - too many long flags`):Error(`${n}
878
- - unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}e.Option=n,e.DualOptions=r})),$Se=i((e=>{function t(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a=1;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function n(e,n){if(!n||n.length===0)return``;n=Array.from(new Set(n));let r=e.startsWith(`--`);r&&(e=e.slice(2),n=n.map(e=>e.slice(2)));let i=[],a=3;return n.forEach(n=>{if(n.length<=1)return;let r=t(e,n),o=Math.max(e.length,n.length);(o-r)/o>.4&&(r<a?(a=r,i=[n]):r===a&&i.push(n))}),i.sort((e,t)=>e.localeCompare(t)),r&&(i=i.map(e=>`--${e}`)),i.length>1?`\n(Did you mean one of ${i.join(`, `)}?)`:i.length===1?`\n(Did you mean ${i[0]}?)`:``}e.suggestSimilar=n})),eCe=i((e=>{let n=t(`node:events`).EventEmitter,r=t(`node:child_process`),i=t(`node:path`),a=t(`node:fs`),o=t(`node:process`),{Argument:s,humanReadableArgName:c}=r7(),{CommanderError:l}=n7(),{Help:u,stripColor:d}=i7(),{Option:f,DualOptions:p}=a7(),{suggestSimilar:m}=$Se();var h=class e extends n{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||``,this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description=``,this._summary=``,this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>o.stdout.write(e),writeErr:e=>o.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>o.stdout.isTTY?o.stdout.columns:void 0,getErrHelpWidth:()=>o.stderr.isTTY?o.stderr.columns:void 0,getOutHasColors:()=>_()??(o.stdout.isTTY&&o.stdout.hasColors?.()),getErrHasColors:()=>_()??(o.stderr.isTTY&&o.stderr.hasColors?.()),stripColor:e=>d(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let r=t,i=n;typeof r==`object`&&r&&(i=r,r=null),i||={};let[,a,o]=e.match(/([^ ]+) *(.*)/),s=this.createCommand(a);return r&&(s.description(r),s._executableHandler=!0),i.isDefault&&(this._defaultCommandName=s._name),s._hidden=!!(i.noHelp||i.hidden),s._executableFile=i.executableFile||null,o&&s.arguments(o),this._registerCommand(s),s.parent=this,s.copyInheritedSettings(this),r?this:s}createCommand(t){return new e(t)}createHelp(){return Object.assign(new u,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!=`string`&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
882
+ - unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}e.Option=n,e.DualOptions=r})),eCe=i((e=>{function t(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a=1;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function n(e,n){if(!n||n.length===0)return``;n=Array.from(new Set(n));let r=e.startsWith(`--`);r&&(e=e.slice(2),n=n.map(e=>e.slice(2)));let i=[],a=3;return n.forEach(n=>{if(n.length<=1)return;let r=t(e,n),o=Math.max(e.length,n.length);(o-r)/o>.4&&(r<a?(a=r,i=[n]):r===a&&i.push(n))}),i.sort((e,t)=>e.localeCompare(t)),r&&(i=i.map(e=>`--${e}`)),i.length>1?`\n(Did you mean one of ${i.join(`, `)}?)`:i.length===1?`\n(Did you mean ${i[0]}?)`:``}e.suggestSimilar=n})),tCe=i((e=>{let n=t(`node:events`).EventEmitter,r=t(`node:child_process`),i=t(`node:path`),a=t(`node:fs`),o=t(`node:process`),{Argument:s,humanReadableArgName:c}=r7(),{CommanderError:l}=n7(),{Help:u,stripColor:d}=i7(),{Option:f,DualOptions:p}=a7(),{suggestSimilar:m}=eCe();var h=class e extends n{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||``,this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description=``,this._summary=``,this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>o.stdout.write(e),writeErr:e=>o.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>o.stdout.isTTY?o.stdout.columns:void 0,getErrHelpWidth:()=>o.stderr.isTTY?o.stderr.columns:void 0,getOutHasColors:()=>_()??(o.stdout.isTTY&&o.stdout.hasColors?.()),getErrHasColors:()=>_()??(o.stderr.isTTY&&o.stderr.hasColors?.()),stripColor:e=>d(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let r=t,i=n;typeof r==`object`&&r&&(i=r,r=null),i||={};let[,a,o]=e.match(/([^ ]+) *(.*)/),s=this.createCommand(a);return r&&(s.description(r),s._executableHandler=!0),i.isDefault&&(this._defaultCommandName=s._name),s._hidden=!!(i.noHelp||i.hidden),s._executableFile=i.executableFile||null,o&&s.arguments(o),this._registerCommand(s),s.parent=this,s.copyInheritedSettings(this),r?this:s}createCommand(t){return new e(t)}createHelp(){return Object.assign(new u,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!=`string`&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
879
883
  - specify the name in Command constructor or using .name()`);return t||={},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new s(e,t)}argument(e,t,n,r){let i=this.createArgument(e,t);return typeof n==`function`?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e==`boolean`)return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let[,n,r]=(e??`help [command]`).match(/([^ ]+) *(.*)/),i=t??`display help for command`,a=this.createCommand(n);return a.helpOption(!1),r&&a.arguments(r),i&&a.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||t)&&this._initCommandGroup(a),this}addHelpCommand(e,t){return typeof e==`object`?(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this):(this.helpCommand(e,t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand(`help`))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=[`preSubcommand`,`preAction`,`postAction`];if(!n.includes(e))throw Error(`Unexpected value for event passed to hook : '${e}'.
880
884
  Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=e=>{if(e.code!==`commander.executeSubCommandAsync`)throw e},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new l(e,t,n)),o.exit(e)}action(e){let t=t=>{let n=this.registeredArguments.length,r=t.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new f(e,t)}_callParseArg(e,t,n,r){try{return e.parseArg(t,n)}catch(e){if(e.code===`commander.invalidArgument`){let t=`${r} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
881
885
  - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=e=>[e.name()].concat(e.aliases()),n=t(e).find(e=>this._findCommand(e));if(n){let r=t(this._findCommand(n)).join(`|`),i=t(e).join(`|`);throw Error(`cannot add command '${i}' as already have command '${r}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let t=e.long.replace(/^--no-/,`--`);this._findOption(t)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,`default`)}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,`default`);let r=(t,r,i)=>{t==null&&e.presetArg!==void 0&&(t=e.presetArg);let a=this.getOptionValue(n);t!==null&&e.parseArg?t=this._callParseArg(e,t,a,r):t!==null&&e.variadic&&(t=e._collectValue(t,a)),t??=e.negate?!1:e.isBoolean()||e.optional?!0:``,this.setOptionValueWithSource(n,t,i)};return this.on(`option:`+t,t=>{r(t,`error: option '${e.flags}' argument '${t}' is invalid.`,`cli`)}),e.envVar&&this.on(`optionEnv:`+t,t=>{r(t,`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`,`env`)}),this}_optionEx(e,t,n,r,i){if(typeof t==`object`&&t instanceof f)throw Error(`To add an Option object use addOption() instead of option() or requiredOption()`);let a=this.createOption(t,n);if(a.makeOptionMandatory(!!e.mandatory),typeof r==`function`)a.default(i).argParser(r);else if(r instanceof RegExp){let e=r;r=(t,n)=>{let r=e.exec(t);return r?r[0]:n},a.default(i).argParser(r)}else a.default(r);return this.addOption(a)}option(e,t,n,r){return this._optionEx({},e,t,n,r)}requiredOption(e,t,n,r){return this._optionEx({mandatory:!0},e,t,n,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw Error(`call .storeOptionsAsProperties() before adding options`);if(Object.keys(this._optionValues).length)throw Error(`call .storeOptionsAsProperties() before setting option values`);return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw Error(`first parameter to parse must be array or undefined`);if(t||={},e===void 0&&t.from===void 0){o.versions?.electron&&(t.from=`electron`);let e=o.execArgv??[];(e.includes(`-e`)||e.includes(`--eval`)||e.includes(`-p`)||e.includes(`--print`))&&(t.from=`eval`)}e===void 0&&(e=o.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case`node`:this._scriptPath=e[1],n=e.slice(2);break;case`electron`:o.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case`user`:n=e.slice(0);break;case`eval`:n=e.slice(1);break;default:throw Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||`program`,n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
@@ -884,7 +888,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
884
888
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
885
889
  - ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function c(e,t){let n=i.resolve(e,t);if(a.existsSync(n))return n;if(s.includes(i.extname(t)))return;let r=s.find(e=>a.existsSync(`${n}${e}`));if(r)return`${n}${r}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=i.resolve(i.dirname(e),d)}if(d){let t=c(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=i.basename(this._scriptPath,i.extname(this._scriptPath));n!==this._name&&(t=c(d,`${n}-${e._name}`))}u=t||u}n=s.includes(i.extname(u));let f;o.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.execPath,t,{stdio:`inherit`})):n?(t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.argv[0],t,{stdio:`inherit`})):f=r.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{o.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new l(e,`commander.executeSubCommandAsync`,`(close)`)):o.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)o.exit(1);else{let e=new l(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)===void 0?!1:this.getOptionValueSource(t)!==`default`});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
886
890
  `),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in o.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,o.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new p(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=m(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=m(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>c(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=i.basename(e,i.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(o.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
887
- Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=h,e.useColor=_}));const{program:tCe,createCommand:nCe,createArgument:rCe,createOption:iCe,CommanderError:aCe,InvalidArgumentError:oCe,InvalidOptionArgumentError:sCe,Command:cCe,Argument:lCe,Option:uCe,Help:dCe}=e(i((e=>{let{Argument:t}=r7(),{Command:n}=eCe(),{CommanderError:r,InvalidArgumentError:i}=n7(),{Help:a}=i7(),{Option:o}=a7();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default;
891
+ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=h,e.useColor=_}));const{program:nCe,createCommand:rCe,createArgument:iCe,createOption:aCe,CommanderError:oCe,InvalidArgumentError:sCe,InvalidOptionArgumentError:cCe,Command:lCe,Argument:uCe,Option:dCe,Help:fCe}=e(i((e=>{let{Argument:t}=r7(),{Command:n}=tCe(),{CommanderError:r,InvalidArgumentError:i}=n7(),{Help:a}=i7(),{Option:o}=a7();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default;
888
892
  /*!
889
893
  * Copyright (c) Squirrel Chat et al., All rights reserved.
890
894
  * SPDX-License-Identifier: BSD-3-Clause
@@ -912,7 +916,7 @@ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let
912
916
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
913
917
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
914
918
  */
915
- let fCe=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var pCe=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(fCe);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
919
+ let pCe=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var mCe=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(pCe);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
916
920
  /*!
917
921
  * Copyright (c) Squirrel Chat et al., All rights reserved.
918
922
  * SPDX-License-Identifier: BSD-3-Clause
@@ -940,9 +944,9 @@ let fCe=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+
940
944
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
941
945
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
942
946
  */
943
- function mCe(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function hCe(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
947
+ function hCe(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function gCe(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
944
948
  `,e===t&&(i+=` `.repeat(a+n+2),i+=`^
945
- `))}return i}var o7=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=mCe(t.toml,t.ptr),i=hCe(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
949
+ `))}return i}var o7=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=hCe(t.toml,t.ptr),i=gCe(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
946
950
  /*!
947
951
  * Copyright (c) Squirrel Chat et al., All rights reserved.
948
952
  * SPDX-License-Identifier: BSD-3-Clause
@@ -970,12 +974,12 @@ function mCe(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop(
970
974
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
971
975
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
972
976
  */
973
- let gCe=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,_Ce=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,vCe=/^[+-]?0[0-9_]/;function s7(e,t){let n=e[t++],r=n,i=n===`'`,a=n===e[t]&&n===e[t+1];a&&(e[t+=2]===`
977
+ let _Ce=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,vCe=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,yCe=/^[+-]?0[0-9_]/;function s7(e,t){let n=e[t++],r=n,i=n===`'`,a=n===e[t]&&n===e[t+1];a&&(e[t+=2]===`
974
978
  `?t++:e[t]===`\r`&&e[t+1]===`
975
979
  `&&(t+=2));let o=``,s=t,c=0;for(let l=t;l<e.length;l++)if(n=e[l],a&&(n===`
976
980
  `||n===`\r`&&e[l+1]===`
977
981
  `))c&&=3;else if(n<` `&&n!==` `||n===``)throw new o7(`control characters are not allowed in strings`,{toml:e,ptr:l});else if((!c||c===3)&&n===r&&(!a||e[l+1]===r&&e[l+2]===r))return a&&(e[l+3]===r&&l++,e[l+3]===r&&l++),[c?o:o+e.slice(s,l),l+(a?3:1)];else if(!c)!i&&n===`\\`&&(o+=e.slice(s,s=l),c=1);else if(c===1)if(n===`x`||n===`u`||n===`U`){let t=0,r=n===`x`?2:n===`u`?4:8;for(let n=0;n<r;n++,l++){let n=e.charCodeAt(l+1),r=n>=48&&n<=57?n-48:n>=65&&n<=70?n-65+10:n>=97&&n<=102?n-97+10:-1;if(r<0)throw new o7(`invalid non-hex character in unicode escape`,{toml:e,ptr:l+1});t=t<<4|r}if(t<0||t>1114111||t>=55296&&t<=57343)throw new o7(`invalid unicode escape`,{toml:e,ptr:l});o+=String.fromCodePoint(t),s=l+1,c=0}else if(n===` `||n===` `)c=2;else{if(n===`b`)o+=`\b`;else if(n===`t`)o+=` `;else if(n===`n`)o+=`
978
- `;else if(n===`f`)o+=`\f`;else if(n===`r`)o+=`\r`;else if(n===`e`)o+=`\x1B`;else if(n===`"`)o+=`"`;else if(n===`\\`)o+=`\\`;else throw new o7(`unrecognized escape sequence`,{toml:e,ptr:l});s=l+1,c=0}else if(n!==` `&&n!==` `){if(c===2)throw new o7(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:s});c=+(!i&&n===`\\`),s=l}throw new o7(`unfinished string`,{toml:e,ptr:t})}function yCe(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=gCe.test(e);if(i||_Ce.test(e)){if(vCe.test(e))throw new o7(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new o7(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new o7(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new pCe(e);if(!a.isValid())throw new o7(`invalid value`,{toml:t,ptr:n});return a}
982
+ `;else if(n===`f`)o+=`\f`;else if(n===`r`)o+=`\r`;else if(n===`e`)o+=`\x1B`;else if(n===`"`)o+=`"`;else if(n===`\\`)o+=`\\`;else throw new o7(`unrecognized escape sequence`,{toml:e,ptr:l});s=l+1,c=0}else if(n!==` `&&n!==` `){if(c===2)throw new o7(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:s});c=+(!i&&n===`\\`),s=l}throw new o7(`unfinished string`,{toml:e,ptr:t})}function bCe(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=_Ce.test(e);if(i||vCe.test(e)){if(yCe.test(e))throw new o7(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new o7(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new o7(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new mCe(e);if(!a.isValid())throw new o7(`invalid value`,{toml:t,ptr:n});return a}
979
983
  /*!
980
984
  * Copyright (c) Squirrel Chat et al., All rights reserved.
981
985
  * SPDX-License-Identifier: BSD-3-Clause
@@ -1008,7 +1012,7 @@ function c7(e,t=0,n=e.length){let r=e.indexOf(`
1008
1012
  `)return n;if(r===`\r`&&e[n+1]===`
1009
1013
  `)return n+1;if(r<` `&&r!==` `||r===``)throw new o7(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}function u7(e,t,n,r){let i;for(;;){for(;(i=e[t])===` `||i===` `||!n&&(i===`
1010
1014
  `||i===`\r`&&e[t+1]===`
1011
- `);)t++;if(r||i!==`#`)break;t=l7(e,t)}return t}function bCe(e,t,n,r,i=!1){if(!r)return t=c7(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=c7(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
1015
+ `);)t++;if(r||i!==`#`)break;t=l7(e,t)}return t}function xCe(e,t,n,r,i=!1){if(!r)return t=c7(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=c7(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
1012
1016
  `||t===`\r`&&e[a+1]===`
1013
1017
  `))return a}throw new o7(`cannot find end of structure`,{toml:e,ptr:t})}
1014
1018
  /*!
@@ -1038,8 +1042,8 @@ function c7(e,t=0,n=e.length){let r=e.indexOf(`
1038
1042
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1039
1043
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1040
1044
  */
1041
- function xCe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(l7(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function d7(e,t,n,r,i){if(r===0)throw new o7(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?wCe(e,t,r,i):CCe(e,t,r,i);if(n){if(s=u7(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new o7(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}if(a===`"`||a===`'`){let[r,i]=s7(e,t);if(n){if(i=u7(e,i),e[i]&&e[i]!==`,`&&e[i]!==n&&e[i]!==`
1042
- `&&e[i]!==`\r`)throw new o7(`unexpected character encountered`,{toml:e,ptr:i});e[i]===`,`&&i++}return[r,i]}let o=bCe(e,t,`,`,n),s=xCe(e,t,o-+(e[o-1]===`,`));if(!s[0])throw new o7(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=u7(e,t+s[1]),e[o]===`,`&&o++),[yCe(s[0],e,t,i),o]}
1045
+ function SCe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(l7(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function d7(e,t,n,r,i){if(r===0)throw new o7(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?TCe(e,t,r,i):wCe(e,t,r,i);if(n){if(s=u7(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new o7(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}if(a===`"`||a===`'`){let[r,i]=s7(e,t);if(n){if(i=u7(e,i),e[i]&&e[i]!==`,`&&e[i]!==n&&e[i]!==`
1046
+ `&&e[i]!==`\r`)throw new o7(`unexpected character encountered`,{toml:e,ptr:i});e[i]===`,`&&i++}return[r,i]}let o=xCe(e,t,`,`,n),s=SCe(e,t,o-+(e[o-1]===`,`));if(!s[0])throw new o7(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=u7(e,t+s[1]),e[o]===`,`&&o++),[bCe(s[0],e,t,i),o]}
1043
1047
  /*!
1044
1048
  * Copyright (c) Squirrel Chat et al., All rights reserved.
1045
1049
  * SPDX-License-Identifier: BSD-3-Clause
@@ -1067,8 +1071,8 @@ function xCe(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(l7(e,i),r=
1067
1071
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1068
1072
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1069
1073
  */
1070
- let SCe=/^[a-zA-Z0-9-_]+[ \t]*$/;function f7(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new o7(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `)if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new o7(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let[s,c]=s7(e,t);r=e.indexOf(`.`,c);let l=e.slice(c,r<0||r>a?a:r),u=c7(l);if(u>-1)throw new o7(`newlines are not allowed in keys`,{toml:e,ptr:t+r+u});if(l.trimStart())throw new o7(`found extra tokens after the string part`,{toml:e,ptr:c});if(a<c&&(a=e.indexOf(n,c),a<0))throw new o7(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(s)}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!SCe.test(n))throw new o7(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}while(r+1&&r<a);return[i,u7(e,a+1,!0,!0)]}function CCe(e,t,n,r){let i={},a=new Set,o;for(t++;(o=e[t++])!==`}`&&o;)if(o===`,`)throw new o7(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=l7(e,t);else if(o!==` `&&o!==` `&&o!==`
1071
- `&&o!==`\r`){let o,s=i,c=!1,[l,u]=f7(e,t-1);for(let n=0;n<l.length;n++){if(n&&(s=c?s[o]:s[o]={}),o=l[n],(c=Object.hasOwn(s,o))&&(typeof s[o]!=`object`||a.has(s[o])))throw new o7(`trying to redefine an already defined value`,{toml:e,ptr:t});!c&&o===`__proto__`&&Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new o7(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=d7(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new o7(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}function wCe(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new o7(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=l7(e,t);else if(a!==` `&&a!==` `&&a!==`
1074
+ let CCe=/^[a-zA-Z0-9-_]+[ \t]*$/;function f7(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new o7(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `)if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new o7(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let[s,c]=s7(e,t);r=e.indexOf(`.`,c);let l=e.slice(c,r<0||r>a?a:r),u=c7(l);if(u>-1)throw new o7(`newlines are not allowed in keys`,{toml:e,ptr:t+r+u});if(l.trimStart())throw new o7(`found extra tokens after the string part`,{toml:e,ptr:c});if(a<c&&(a=e.indexOf(n,c),a<0))throw new o7(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(s)}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!CCe.test(n))throw new o7(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}while(r+1&&r<a);return[i,u7(e,a+1,!0,!0)]}function wCe(e,t,n,r){let i={},a=new Set,o;for(t++;(o=e[t++])!==`}`&&o;)if(o===`,`)throw new o7(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=l7(e,t);else if(o!==` `&&o!==` `&&o!==`
1075
+ `&&o!==`\r`){let o,s=i,c=!1,[l,u]=f7(e,t-1);for(let n=0;n<l.length;n++){if(n&&(s=c?s[o]:s[o]={}),o=l[n],(c=Object.hasOwn(s,o))&&(typeof s[o]!=`object`||a.has(s[o])))throw new o7(`trying to redefine an already defined value`,{toml:e,ptr:t});!c&&o===`__proto__`&&Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new o7(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=d7(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new o7(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}function TCe(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new o7(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=l7(e,t);else if(a!==` `&&a!==` `&&a!==`
1072
1076
  `&&a!==`\r`){let a=d7(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new o7(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}
1073
1077
  /*!
1074
1078
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -1097,7 +1101,7 @@ let SCe=/^[a-zA-Z0-9-_]+[ \t]*$/;function f7(e,t,n=`=`){let r=t-1,i=[],a=e.index
1097
1101
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1098
1102
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1099
1103
  */
1100
- function p7(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function TCe(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=u7(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=f7(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new o7(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=p7(n[0],r,i,t?2:1);if(!c)throw new o7(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=f7(e,s),i=p7(r[0],a,o,0);if(!i)throw new o7(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=d7(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=u7(e,s,!0),e[s]&&e[s]!==`
1104
+ function p7(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function ECe(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=u7(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=f7(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new o7(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=p7(n[0],r,i,t?2:1);if(!c)throw new o7(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=f7(e,s),i=p7(r[0],a,o,0);if(!i)throw new o7(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=d7(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=u7(e,s,!0),e[s]&&e[s]!==`
1101
1105
  `&&e[s]!==`\r`)throw new o7(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=u7(e,s)}return r}
1102
1106
  /*!
1103
1107
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -1126,13 +1130,13 @@ function p7(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i
1126
1130
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1127
1131
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1128
1132
  */
1129
- let m7=/^[a-z0-9-_]+$/i;function h7(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function ECe(e){for(let t=0;t<e.length;t++)if(h7(e[t])!==`object`)return!1;return e.length!=0}function g7(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function _7(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:Number.isInteger(e)&&(r||!Number.isSafeInteger(e))?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return g7(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return DCe(e,n,r);if(t===`array`)return OCe(e,n,r)}function DCe(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=m7.test(o)?o:g7(o),i+=` = `,i+=_7(e[o],h7(e[o]),t-1,n)}return i+` }`}function OCe(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=_7(e[i],h7(e[i]),t-1,n)}return r+` ]`}function kCe(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
1130
- `}[[${t}]]\n`,i+=v7(0,e[a],t,n,r);return i}function v7(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=h7(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=m7.test(c)?c:g7(c);if(e===`array`&&ECe(t[c]))o+=(o&&`
1131
- `)+kCe(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
1133
+ let m7=/^[a-z0-9-_]+$/i;function h7(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function DCe(e){for(let t=0;t<e.length;t++)if(h7(e[t])!==`object`)return!1;return e.length!=0}function g7(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function _7(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:Number.isInteger(e)&&(r||!Number.isSafeInteger(e))?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return g7(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return OCe(e,n,r);if(t===`array`)return kCe(e,n,r)}function OCe(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=m7.test(o)?o:g7(o),i+=` = `,i+=_7(e[o],h7(e[o]),t-1,n)}return i+` }`}function kCe(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=_7(e[i],h7(e[i]),t-1,n)}return r+` ]`}function ACe(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
1134
+ `}[[${t}]]\n`,i+=v7(0,e[a],t,n,r);return i}function v7(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=h7(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=m7.test(c)?c:g7(c);if(e===`array`&&DCe(t[c]))o+=(o&&`
1135
+ `)+ACe(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
1132
1136
  `)+v7(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=_7(t[c],e,r,i),a+=`
1133
- `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function ACe(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(h7(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=v7(0,e,``,t,n);return r[r.length-1]===`
1137
+ `}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function jCe(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(h7(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=v7(0,e,``,t,n);return r[r.length-1]===`
1134
1138
  `?r:r+`
1135
- `}function jCe(e){let{projectDir:t,contentDir:n,sampleCap:r=5}=e,i=[],a=[];try{_(n)}catch(e){return{totalCount:0,sample:[],contentDir:n,warnings:[`cannot access content directory ${n}: ${e instanceof Error?e.message:String(e)}`]}}let o;try{o=qye({projectDir:t,contentDir:n})}catch(e){return{totalCount:0,sample:[],contentDir:n,warnings:[e instanceof Error?e.message:String(e)]}}function s(e){let t;try{t=C(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);i.push(`could not read directory ${_e(n,e)||`.`}: ${r}`);return}for(let r of t){let t=N(e,r.name);if(r.isSymbolicLink()){let e;try{e=T(t)}catch(e){let r=e.code;r===`ENOENT`||r===`ELOOP`?i.push(`broken or cyclic symlink: ${_e(n,t)}`):i.push(`cannot resolve symlink ${_e(n,t)}: ${r??`unknown error`}`);continue}let r;try{r=O(e)}catch{continue}if(r.isDirectory()){let e=_e(n,t);if(o.isDirExcluded(e))continue;s(t)}else if(r.isFile()){let e=_e(n,t);if(o.isExcluded(e))continue;a.push(e)}}else if(r.isDirectory()){let e=_e(n,t);if(o.isDirExcluded(e))continue;s(t)}else if(r.isFile()){let e=_e(n,t);if(o.isExcluded(e))continue;a.push(e)}}}return s(n),{totalCount:a.length,sample:a.slice(0,r),contentDir:n,warnings:i}}const MCe=`${z5}-dev`;function NCe(e){return e.startsWith(z5)}function y7(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command!==`ok-pi-managed-extension`||!Array.isArray(t.args))return!1;let n=t.args[0];return typeof n==`string`&&NCe(n)}function PCe(e){return{command:`ok-pi-managed-extension`,args:[e]}}function b7(e={}){let t=e.mode===`dev`?MCe:B5,n={unix:U5({...e,platformName:`darwin`}),win32:U5({...e,platformName:`win32`})};return`${t}
1139
+ `}function MCe(e){let{projectDir:t,contentDir:n,sampleCap:r=5}=e,i=[],a=[];try{_(n)}catch(e){return{totalCount:0,sample:[],contentDir:n,warnings:[`cannot access content directory ${n}: ${e instanceof Error?e.message:String(e)}`]}}let o;try{o=qye({projectDir:t,contentDir:n})}catch(e){return{totalCount:0,sample:[],contentDir:n,warnings:[e instanceof Error?e.message:String(e)]}}function s(e){let t;try{t=C(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);i.push(`could not read directory ${_e(n,e)||`.`}: ${r}`);return}for(let r of t){let t=N(e,r.name);if(r.isSymbolicLink()){let e;try{e=T(t)}catch(e){let r=e.code;r===`ENOENT`||r===`ELOOP`?i.push(`broken or cyclic symlink: ${_e(n,t)}`):i.push(`cannot resolve symlink ${_e(n,t)}: ${r??`unknown error`}`);continue}let r;try{r=O(e)}catch{continue}if(r.isDirectory()){let e=_e(n,t);if(o.isDirExcluded(e))continue;s(t)}else if(r.isFile()){let e=_e(n,t);if(o.isExcluded(e))continue;a.push(e)}}else if(r.isDirectory()){let e=_e(n,t);if(o.isDirExcluded(e))continue;s(t)}else if(r.isFile()){let e=_e(n,t);if(o.isExcluded(e))continue;a.push(e)}}}return s(n),{totalCount:a.length,sample:a.slice(0,r),contentDir:n,warnings:i}}const NCe=`${z5}-dev`;function PCe(e){return e.startsWith(z5)}function y7(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command!==`ok-pi-managed-extension`||!Array.isArray(t.args))return!1;let n=t.args[0];return typeof n==`string`&&PCe(n)}function FCe(e){return{command:`ok-pi-managed-extension`,args:[e]}}function b7(e={}){let t=e.mode===`dev`?NCe:B5,n={unix:U5({...e,platformName:`darwin`}),win32:U5({...e,platformName:`win32`})};return`${t}
1136
1140
  /**
1137
1141
  * Open Knowledge bridge for Pi — MANAGED FILE, written by \`ok init\`.
1138
1142
  * Hand edits are overwritten whenever OK re-syncs this project; remove it
@@ -1475,55 +1479,55 @@ export default function okBridge(pi: {
1475
1479
  }
1476
1480
  });
1477
1481
  }
1478
- `}function FCe(e,t){let n=_e(U6(t),U6(e));return n.length>0&&!n.startsWith(`..`)&&!M(n)}const ICe=e=>{try{let t=c(`git`,[`rev-parse`,`--show-toplevel`],d3({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function LCe(e,t={}){let n=t.homeDir??oe(),r=t.gitTopLevel??ICe,i=ve(e),a;try{a=T(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(dbe(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=pe(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&FCe(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function x7(e,t){let n;try{n=_(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);S7(e,t)}function RCe(e,t){S7(e,t)}function S7(e,t){let n;try{n=T(t)}catch{n=ve(t)}let r=pe(e);for(;r.length>1&&r!==ye;){let t;try{t=T(r)}catch(e){if(e.code===`ENOENT`){r=pe(r);continue}throw e}let i=_e(n,t);if(i===``||!i.startsWith(`..`)&&!M(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function C7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zCe(e,t,n){try{if(O(n).size>10485760)return!1}catch{return!1}let r;try{r=S(n,`utf-8`)}catch{return!1}let i=[],a=ibe(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!C7(a))return!1;let o=a[e.topLevelKey];if(!C7(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;return C7(s)?C7(s[e.serverName(t)]):!1}function BCe(e,t,n={}){if(!Ul.includes(e.id))return!0;try{return zCe(e,t,e.configPath(t,n.home))}catch{return!1}}function w7(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!BCe(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=gye(`project`,{checkDesktop:!0}),i=pe(r);x7(i,t);let a=g(r)?`overwritten`:`written`;return D(i,{recursive:!0,force:!0}),v(pe(i),{recursive:!0}),m(n,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function VCe(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=pe(n);return g(n)?(RCe(r,t),D(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function T7(e){let t=e&&typeof e==`object`&&`code`in e?e.code:void 0;return t===`MODULE_NOT_FOUND`||t===`ERR_MODULE_NOT_FOUND`}function E7(e,t){if(!process.env.OK_DEBUG_NATIVE)return;let n=t instanceof Error?t.message:String(t);process.stderr.write(`[ok] native-config ${e}: ${n}\n`)}const HCe=[`native`,`index.js`];function D7(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??o(t);try{return n(N(pe(Se(t)),...HCe))}catch(e){T7(e)||E7(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return T7(e)||E7(`workspace addon failed to load`,e),null}}function UCe(){let e=D7();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function WCe(e){let t=e,n=new Set;for(;;){let r;try{r=_(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=w(t)}catch(t){return E7(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=M(i)?i:N(pe(t),i)}}let O7;function GCe(){return O7===void 0&&(O7=UCe()),O7}function KCe(e,t=GCe){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){E7(`resolveSymlinkWritePath threw`,e)}return WCe(e)}function k7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qCe(){let e=D7();return e&&typeof e.parseTomlToJson==`function`?e:null}function JCe(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return E7(`addon loaded but probe failed`,e),!1}}function A7(e){if(!k7(e))throw Error(`TOML root is not a table`);return e}function YCe(e){return{backend:`native`,parseToObject(t){return A7(JSON.parse(e.parseTomlToJson(t)))},upsertEntry(t,n,r){let i=e.upsertMcpServer(t,n,JSON.stringify(r));return{text:i.text,existed:i.existed}},removeEntry(t,n){let r=e.removeMcpServer(t,n);return{text:r.text,existed:r.existed}}}}function XCe(){return{backend:`fallback`,parseToObject(e){return A7(TCe(e))}}}function ZCe(e=qCe){let t=e();return t&&JCe(t)?YCe(t):XCe()}let j7=null;function M7(){return j7===null&&(j7=ZCe()),j7}function QCe(){let e=M7();return e.backend===`native`?e:void 0}const N7=`.ok/`,P7=`**/.ok/*`,F7=`!**/${Ml}/`;function I7(e){let t=[`.ok/`,`.okignore`];for(let n of N5){let r=t7[n];r.projectConfigPath&&t.push(awe(r.projectConfigPath(e),e))}t.push(`.claude/launch.json`);let n=N(e,...aX);if(g(n))try{let e=lX(S(n,`utf-8`));if(e){for(let[n,r]of Object.entries(e.skills))if(n!==`open-knowledge`)for(let e of r.hosts){let r=Il[e];r&&t.push(`${r}/${n}/`)}}}catch{}return Array.from(new Set(t))}function $Ce(e,t){let n=L7(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:R7(n)};let r=z7(e);if(r.kind!==`ok`)return r.result;let i=g(r.path)?S(r.path,`utf-8`):``,a=H7(i),o=[],s=[];for(let e of t)V7(a,e)?s.push(e):o.push(e);if(o.length===0)return{kind:`updated`,appended:o,alreadyPresent:s,removed:[]};let c=i.length===0||i.endsWith(`
1482
+ `}function ICe(e,t){let n=_e(U6(t),U6(e));return n.length>0&&!n.startsWith(`..`)&&!M(n)}const LCe=e=>{try{let t=c(`git`,[`rev-parse`,`--show-toplevel`],d3({cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]})).trim();return t.length>0?t:null}catch{return null}};function RCe(e,t={}){let n=t.homeDir??oe(),r=t.gitTopLevel??LCe,i=ve(e),a;try{a=T(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(fbe(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=pe(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&ICe(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function x7(e,t){let n;try{n=_(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(n?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);S7(e,t)}function zCe(e,t){S7(e,t)}function S7(e,t){let n;try{n=T(t)}catch{n=ve(t)}let r=pe(e);for(;r.length>1&&r!==ye;){let t;try{t=T(r)}catch(e){if(e.code===`ENOENT`){r=pe(r);continue}throw e}let i=_e(n,t);if(i===``||!i.startsWith(`..`)&&!M(i))return;throw Error(`Refusing to write at ${e}: ancestor ${r} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function C7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function BCe(e,t,n){try{if(O(n).size>10485760)return!1}catch{return!1}let r;try{r=S(n,`utf-8`)}catch{return!1}let i=[],a=abe(r.charCodeAt(0)===65279?r.slice(1):r,i,{allowTrailingComma:!0,disallowComments:!1});if(i.length>0||!C7(a))return!1;let o=a[e.topLevelKey];if(!C7(o))return!1;let s=e.serverMapSubKey?o[e.serverMapSubKey]:o;return C7(s)?C7(s[e.serverName(t)]):!1}function VCe(e,t,n={}){if(!Ul.includes(e.id))return!0;try{return BCe(e,t,e.configPath(t,n.home))}catch{return!1}}function w7(e,t,n={}){let r=e.projectSkillPath?.(t);if(!r)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};if(!VCe(e,t,n))return{editorId:e.id,label:e.label,action:`skipped-prerequisite`,path:r};try{let n=gye(`project`,{checkDesktop:!0}),i=pe(r);x7(i,t);let a=g(r)?`overwritten`:`written`;return D(i,{recursive:!0,force:!0}),v(pe(i),{recursive:!0}),m(n,i,{recursive:!0}),{editorId:e.id,label:e.label,action:a,path:r}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}function HCe(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=pe(n);return g(n)?(zCe(r,t),D(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function T7(e){let t=e&&typeof e==`object`&&`code`in e?e.code:void 0;return t===`MODULE_NOT_FOUND`||t===`ERR_MODULE_NOT_FOUND`}function E7(e,t){if(!process.env.OK_DEBUG_NATIVE)return;let n=t instanceof Error?t.message:String(t);process.stderr.write(`[ok] native-config ${e}: ${n}\n`)}const UCe=[`native`,`index.js`];function D7(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??o(t);try{return n(N(pe(Se(t)),...UCe))}catch(e){T7(e)||E7(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return T7(e)||E7(`workspace addon failed to load`,e),null}}function WCe(){let e=D7();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function GCe(e){let t=e,n=new Set;for(;;){let r;try{r=_(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=w(t)}catch(t){return E7(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=M(i)?i:N(pe(t),i)}}let O7;function KCe(){return O7===void 0&&(O7=WCe()),O7}function qCe(e,t=KCe){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){E7(`resolveSymlinkWritePath threw`,e)}return GCe(e)}function k7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function JCe(){let e=D7();return e&&typeof e.parseTomlToJson==`function`?e:null}function YCe(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return E7(`addon loaded but probe failed`,e),!1}}function A7(e){if(!k7(e))throw Error(`TOML root is not a table`);return e}function XCe(e){return{backend:`native`,parseToObject(t){return A7(JSON.parse(e.parseTomlToJson(t)))},upsertEntry(t,n,r){let i=e.upsertMcpServer(t,n,JSON.stringify(r));return{text:i.text,existed:i.existed}},removeEntry(t,n){let r=e.removeMcpServer(t,n);return{text:r.text,existed:r.existed}}}}function ZCe(){return{backend:`fallback`,parseToObject(e){return A7(ECe(e))}}}function QCe(e=JCe){let t=e();return t&&YCe(t)?XCe(t):ZCe()}let j7=null;function M7(){return j7===null&&(j7=QCe()),j7}function $Ce(){let e=M7();return e.backend===`native`?e:void 0}const N7=`.ok/`,P7=`**/.ok/*`,F7=`!**/${Ml}/`;function I7(e){let t=[`.ok/`,`.okignore`];for(let n of N5){let r=t7[n];r.projectConfigPath&&t.push(owe(r.projectConfigPath(e),e))}t.push(`.claude/launch.json`);let n=N(e,...aX);if(g(n))try{let e=lX(S(n,`utf-8`));if(e){for(let[n,r]of Object.entries(e.skills))if(n!==`open-knowledge`)for(let e of r.hosts){let r=Il[e];r&&t.push(`${r}/${n}/`)}}}catch{}return Array.from(new Set(t))}function ewe(e,t){let n=L7(e,t).tracked;if(n.length>0)return{kind:`refused-tracked`,tracked:n,remediation:R7(n)};let r=z7(e);if(r.kind!==`ok`)return r.result;let i=g(r.path)?S(r.path,`utf-8`):``,a=H7(i),o=[],s=[];for(let e of t)V7(a,e)?s.push(e):o.push(e);if(o.length===0)return{kind:`updated`,appended:o,alreadyPresent:s,removed:[]};let c=i.length===0||i.endsWith(`
1479
1483
  `)?``:`
1480
1484
  `,l=`${o.join(`
1481
- `)}\n`;try{te(r.path,`${i}${c}${l}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:o,alreadyPresent:s,removed:[]}}function ewe(e,t){let n=z7(e);if(n.kind!==`ok`)return n.result;if(!g(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>B7(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(P7),i.add(F7);let a;try{a=S(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let o=a.split(`
1485
+ `)}\n`;try{te(r.path,`${i}${c}${l}`,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:o,alreadyPresent:s,removed:[]}}function twe(e,t){let n=z7(e);if(n.kind!==`ok`)return n.result;if(!g(n.path))return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let r=t.map(e=>B7(e)),i=new Set;for(let e of r)for(let t of e)i.add(t);i.add(P7),i.add(F7);let a;try{a=S(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let o=a.split(`
1482
1486
  `),s=new Set,c=[];for(let e of o){let t=e.trim();if(i.has(t)){s.add(t);continue}c.push(e)}let l=t.filter(e=>{for(let t of B7(e))if(s.has(t))return!0;return!1});if(s.size===0)return{kind:`updated`,appended:[],alreadyPresent:[],removed:[]};let u=c.join(`
1483
- `);if(u!==a)try{te(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function twe(e){let t=z7(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!g(t.path))return`shared`;let n;try{n=S(t.path,`utf-8`)}catch{return`shared`}let r=H7(n),i=I7(e);for(let e of i)if(V7(r,e))return`local-only`;return r.has(P7)?`local-only`:`shared`}function nwe(e){let t=z7(e);if(t.kind!==`ok`||!g(t.path))return[];let n;try{n=S(t.path,`utf-8`)}catch{return[]}let r=H7(n);return I7(e).filter(e=>V7(r,e))}function rwe(e){let t=z7(e);if(t.kind!==`ok`||!g(t.path))return!1;let n;try{n=S(t.path,`utf-8`)}catch{return!1}let r=H7(n);return r.has(P7)&&r.has(F7)}function iwe(e,t){let n=z7(e);if(n.kind!==`ok`)return n.result;let r=``;if(g(n.path))try{r=S(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let i=new Set([...B7(N7),P7,F7]),a=r.split(`
1487
+ `);if(u!==a)try{te(n.path,u,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:[],alreadyPresent:[],removed:l}}function nwe(e){let t=z7(e);if(t.kind!==`ok`)return t.result.reason===`no-git`||t.result.reason===`malformed-pointer`||t.result.reason===`inaccessible`?`no-git`:`shared`;if(!g(t.path))return`shared`;let n;try{n=S(t.path,`utf-8`)}catch{return`shared`}let r=H7(n),i=I7(e);for(let e of i)if(V7(r,e))return`local-only`;return r.has(P7)?`local-only`:`shared`}function rwe(e){let t=z7(e);if(t.kind!==`ok`||!g(t.path))return[];let n;try{n=S(t.path,`utf-8`)}catch{return[]}let r=H7(n);return I7(e).filter(e=>V7(r,e))}function iwe(e){let t=z7(e);if(t.kind!==`ok`||!g(t.path))return!1;let n;try{n=S(t.path,`utf-8`)}catch{return!1}let r=H7(n);return r.has(P7)&&r.has(F7)}function awe(e,t){let n=z7(e);if(n.kind!==`ok`)return n.result;let r=``;if(g(n.path))try{r=S(n.path,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}let i=new Set([...B7(N7),P7,F7]),a=r.split(`
1484
1488
  `).filter(e=>!i.has(e.trim())),o=t?[P7,F7]:[N7],s=a.join(`
1485
1489
  `),c=`${s}${s.length===0||s.endsWith(`
1486
1490
  `)?``:`
1487
1491
  `}${o.join(`
1488
1492
  `)}\n`;try{te(n.path,c,`utf-8`)}catch{return{kind:`no-exclude`,reason:`inaccessible`}}return{kind:`updated`,appended:o,alreadyPresent:[],removed:[]}}function L7(e,t){let n=[];for(let r of t)if(g(ve(e,r)))try{c(`git`,[`ls-files`,`--error-unmatch`,`--`,r],d3({cwd:e,stdio:[`ignore`,`ignore`,`ignore`]})),n.push(r)}catch{}return{tracked:n}}function R7(e){let t=[];t.push(`Cannot switch OpenKnowledge to local-only — these OK files are tracked upstream:`),t.push(``);for(let n of e)t.push(` ${n}`);t.push(``),t.push(`.git/info/exclude only hides files that git isn't already tracking. To proceed, untrack them first:`),t.push(``);for(let n of e){let e=n.replace(/\/$/,``),r=n.endsWith(`/`)?`-r `:``;t.push(` git rm --cached ${r}${e}`)}return t.push(``),t.push("Then re-run the command. Note: `git rm --cached` removes the files from the index — your teammates will see a deletion on their next pull. If you don't want that, leave sharing mode set to 'shared'."),t.join(`
1489
1493
  `)}function z7(e){let t=OX(e);switch(t.kind){case`repository`:{let e=t.repository.readCommonDir();if(e.kind===`unreadable`)return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}};let n=N(e.path,`info`);return g(n)?{kind:`ok`,path:N(n,`exclude`)}:{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-info-dir`}}}case`absent`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`no-git`}};case`malformed-pointer`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`malformed-pointer`}};case`inaccessible`:return{kind:`no-exclude`,result:{kind:`no-exclude`,reason:`inaccessible`}}}}function B7(e){let t=e.replace(/\/$/,``);return new Set([e,t,`/${e}`,`/${t}`])}function V7(e,t){for(let n of B7(t))if(e.has(n))return!0;return!1}function H7(e){let t=new Set;for(let n of e.split(`
1490
- `)){let e=n.trim();e.length!==0&&t.add(e)}return t}function awe(e,t){return owe(_e(t,e))}function owe(e){return ye===`/`?e:e.split(ye).join(`/`)}function swe(e){for(let t of e.split(`
1491
- `)){let e=t.trimStart();if(!(e.length===0||e.length===t.length))return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function U7(e){let t=(e.match(/\r\n/g)??[]).length;return t===0?!1:t>=(e.match(/\n/g)??[]).length-t}function W7(e){try{return O(e).mode&511}catch{return}}function cwe(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
1494
+ `)){let e=n.trim();e.length!==0&&t.add(e)}return t}function owe(e,t){return swe(_e(t,e))}function swe(e){return ye===`/`?e:e.split(ye).join(`/`)}function cwe(e){for(let t of e.split(`
1495
+ `)){let e=t.trimStart();if(!(e.length===0||e.length===t.length))return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function U7(e){let t=(e.match(/\r\n/g)??[]).length;return t===0?!1:t>=(e.match(/\n/g)??[]).length-t}function W7(e){try{return O(e).mode&511}catch{return}}function lwe(e,t){let n=e.charCodeAt(0)===65279,r=n?e.slice(1):e,i=r.includes(`\r
1492
1496
  `)?`\r
1493
1497
  `:`
1494
- `,a=l6(r,t,void 0,{formattingOptions:{...swe(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${u6(r,a)}`;return{text:o,changed:o!==e}}const lwe={allowTrailingComma:!0,disallowComments:!1};function uwe(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function G7(e){let t=[],n=abe(e,t,lwe);return t.some(t=>!uwe(t,e))||!n||n.type!==`object`?null:n}function K7(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&c6(e)===t&&(n+=1)}return n}function q7(e,t){KQ(e,`${JSON.stringify(t,null,2)}\n`)}function dwe(e,t){let n=ACe(t);KQ(e,n.endsWith(`
1495
- `)?n:`${n}\n`)}function fwe(e,t){let n=(0,on.stringify)(t);KQ(e,n.endsWith(`
1496
- `)?n:`${n}\n`)}const J7=10*1024*1024;function Y7(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>Y7(e,t[n]));if(k7(e)&&k7(t)){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>Object.hasOwn(t,n)&&Y7(e[n],t[n])):!1}return!1}const pwe=[`command`,`args`],mwe=[`type`,`command`];function X7(e){return e.type===`local`&&Array.isArray(e.command)?mwe:pwe}function hwe(e,t,n){return k7(e)&&n.every(n=>Y7(e[n],t[n]))}function gwe(e){for(let t of e.split(`
1497
- `)){let e=t.trimStart();if(!(e.length===0||e.length===t.length))return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function Z7(e,t,n){return t===void 0?[e,n]:[e,t,n]}function Q7(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function $7(e,t,n){let r=e[t];return n===void 0?r:k7(r)?r[n]:void 0}function _we(e,t,n,r,i){if(!g(e))return q7(e,Q7(t,i,n,r)),{kind:`written`};let a;try{a=S(e,`utf-8`)}catch(e){return E7(`json config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(a.trim()===``)return q7(e,Q7(t,i,n,r)),{kind:`written`};if(Buffer.byteLength(a,`utf-8`)>J7)return{kind:`declined`,reason:`oversize`};let o=G7(a);if(!o)return{kind:`declined`,reason:`unparseable`};if(K7(o,t)>1)return{kind:`declined`,reason:`duplicate-container`};let s=$7(c6(o),t,i),c=k7(s)?s[n]:void 0,l=c!==void 0,u=X7(r);if(l&&hwe(c,r,u))return{kind:`overwritten`};let d=a.charCodeAt(0)===65279,f=d?a.slice(1):a,p=f.includes(`\r
1498
+ `,a=l6(r,t,void 0,{formattingOptions:{...cwe(r),eol:i}});if(a.length===0)return{text:e,changed:!1};let o=`${n?``:``}${u6(r,a)}`;return{text:o,changed:o!==e}}const uwe={allowTrailingComma:!0,disallowComments:!1};function dwe(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function G7(e){let t=[],n=obe(e,t,uwe);return t.some(t=>!dwe(t,e))||!n||n.type!==`object`?null:n}function K7(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&c6(e)===t&&(n+=1)}return n}function q7(e,t){KQ(e,`${JSON.stringify(t,null,2)}\n`)}function fwe(e,t){let n=jCe(t);KQ(e,n.endsWith(`
1499
+ `)?n:`${n}\n`)}function pwe(e,t){let n=(0,on.stringify)(t);KQ(e,n.endsWith(`
1500
+ `)?n:`${n}\n`)}const J7=10*1024*1024;function Y7(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>Y7(e,t[n]));if(k7(e)&&k7(t)){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>Object.hasOwn(t,n)&&Y7(e[n],t[n])):!1}return!1}const mwe=[`command`,`args`],hwe=[`type`,`command`];function X7(e){return e.type===`local`&&Array.isArray(e.command)?hwe:mwe}function gwe(e,t,n){return k7(e)&&n.every(n=>Y7(e[n],t[n]))}function _we(e){for(let t of e.split(`
1501
+ `)){let e=t.trimStart();if(!(e.length===0||e.length===t.length))return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function Z7(e,t,n){return t===void 0?[e,n]:[e,t,n]}function Q7(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function $7(e,t,n){let r=e[t];return n===void 0?r:k7(r)?r[n]:void 0}function vwe(e,t,n,r,i){if(!g(e))return q7(e,Q7(t,i,n,r)),{kind:`written`};let a;try{a=S(e,`utf-8`)}catch(e){return E7(`json config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(a.trim()===``)return q7(e,Q7(t,i,n,r)),{kind:`written`};if(Buffer.byteLength(a,`utf-8`)>J7)return{kind:`declined`,reason:`oversize`};let o=G7(a);if(!o)return{kind:`declined`,reason:`unparseable`};if(K7(o,t)>1)return{kind:`declined`,reason:`duplicate-container`};let s=$7(c6(o),t,i),c=k7(s)?s[n]:void 0,l=c!==void 0,u=X7(r);if(l&&gwe(c,r,u))return{kind:`overwritten`};let d=a.charCodeAt(0)===65279,f=d?a.slice(1):a,p=f.includes(`\r
1498
1502
  `)?`\r
1499
1503
  `:`
1500
- `,m={...gwe(f),eol:p},h=Z7(t,i,n),_=f;if(l&&k7(c))for(let e of u){let t=l6(_,[...h,e],r[e],{formattingOptions:m});_=u6(_,t)}else{let e=l6(_,h,r,{formattingOptions:m});_=u6(_,e)}let v=`${d?``:``}${_}`;return v!==a&&KQ(e,v,{mode:W7(e)}),{kind:l?`overwritten`:`written`}}function vwe(e,t,n,r,i){let a=``;if(g(t))try{a=S(t,`utf-8`)}catch(e){return E7(`toml config read failed`,e),{kind:`declined`,reason:`unparseable`}}let o=a.trim()===``;if(e.backend===`fallback`)return o?(dwe(t,{[n]:{[r]:i}}),{kind:`written`}):{kind:`declined`,reason:`no-native-writer`};let s=a.charCodeAt(0)===65279,c=s?a.slice(1):a,l=U7(c),u=o||c.endsWith(`
1504
+ `,m={..._we(f),eol:p},h=Z7(t,i,n),_=f;if(l&&k7(c))for(let e of u){let t=l6(_,[...h,e],r[e],{formattingOptions:m});_=u6(_,t)}else{let e=l6(_,h,r,{formattingOptions:m});_=u6(_,e)}let v=`${d?``:``}${_}`;return v!==a&&KQ(e,v,{mode:W7(e)}),{kind:l?`overwritten`:`written`}}function ywe(e,t,n,r,i){let a=``;if(g(t))try{a=S(t,`utf-8`)}catch(e){return E7(`toml config read failed`,e),{kind:`declined`,reason:`unparseable`}}let o=a.trim()===``;if(e.backend===`fallback`)return o?(fwe(t,{[n]:{[r]:i}}),{kind:`written`}):{kind:`declined`,reason:`no-native-writer`};let s=a.charCodeAt(0)===65279,c=s?a.slice(1):a,l=U7(c),u=o||c.endsWith(`
1501
1505
  `),d;try{d=e.upsertEntry(c,r,i)}catch(e){return E7(`upsertEntry failed`,e),{kind:`declined`,reason:`unparseable`}}let f=d.text;u?f.endsWith(`
1502
1506
  `)||(f=`${f}\n`):f=f.replace(/\n+$/,``),l&&(f=f.replace(/\r\n/g,`
1503
1507
  `).replace(/\n/g,`\r
1504
- `));let p=`${s?``:``}${f}`;return p!==a&&KQ(t,p,{mode:W7(t)}),{kind:d.existed?`overwritten`:`written`}}function ywe(e,t,n,r){let i=``;if(g(e))try{i=S(e,`utf-8`)}catch(e){return E7(`yaml config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(i.trim()===``)return fwe(e,{[t]:{[n]:r}}),{kind:`written`};if(Buffer.byteLength(i,`utf-8`)>J7)return{kind:`declined`,reason:`oversize`};let a=i.charCodeAt(0)===65279,o=a?i.slice(1):i,s=(0,on.parseDocument)(o);if(s.errors.length>0)return{kind:`declined`,reason:`unparseable`};let c=[t,n],l=s.hasIn(c);s.hasIn([t])&&!(0,on.isCollection)(s.getIn([t],!0))&&s.deleteIn([t]);let u=s.getIn(c,!0);if(l&&(0,on.isCollection)(u))for(let e of X7(r))s.setIn([...c,e],s.createNode(r[e]));else s.setIn(c,s.createNode(r));let d=s.toString(),f=U7(o);o.endsWith(`
1508
+ `));let p=`${s?``:``}${f}`;return p!==a&&KQ(t,p,{mode:W7(t)}),{kind:d.existed?`overwritten`:`written`}}function bwe(e,t,n,r){let i=``;if(g(e))try{i=S(e,`utf-8`)}catch(e){return E7(`yaml config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(i.trim()===``)return pwe(e,{[t]:{[n]:r}}),{kind:`written`};if(Buffer.byteLength(i,`utf-8`)>J7)return{kind:`declined`,reason:`oversize`};let a=i.charCodeAt(0)===65279,o=a?i.slice(1):i,s=(0,on.parseDocument)(o);if(s.errors.length>0)return{kind:`declined`,reason:`unparseable`};let c=[t,n],l=s.hasIn(c);s.hasIn([t])&&!(0,on.isCollection)(s.getIn([t],!0))&&s.deleteIn([t]);let u=s.getIn(c,!0);if(l&&(0,on.isCollection)(u))for(let e of X7(r))s.setIn([...c,e],s.createNode(r[e]));else s.setIn(c,s.createNode(r));let d=s.toString(),f=U7(o);o.endsWith(`
1505
1509
  `)?d.endsWith(`
1506
1510
  `)||(d=`${d}\n`):d=d.replace(/\n+$/,``),f&&(d=d.replace(/\r\n/g,`
1507
1511
  `).replace(/\n/g,`\r
1508
- `));let p=`${a?``:``}${d}`;return p!==i&&KQ(e,p,{mode:W7(e)}),{kind:l?`overwritten`:`written`}}const bwe=`open-knowledge-ui`;function e9(e,t,n){try{return g(e.detectPath?.(t,n)??pe(e.configPath(t,n)))}catch{return!1}}function xwe(e,t,n){try{let r=ve(pe(e.configPath(t,n))),i=ve(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+ye)}catch{return!1}}function t9(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||xwe(e,t,r);if(!i&&s&&!e9(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{x7(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return Cwe(e,o,a,n,{isProjectScope:i!==void 0});let c;try{c=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{v(pe(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let l={action:`written`},u;try{JQ(`${o}.lock`,()=>{let t=KCe(o).writePath;if(v(pe(t),{recursive:!0}),e.format===`toml`){let n=vwe(M7(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}if(e.format===`yaml`){let n=ywe(t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=_we(t,e.topLevelKey,a,c,e.serverMapSubKey);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){u=e instanceof Error?e:Error(String(e))}return u?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:u.message,...i===void 0?{}:{configScope:`project`}}:l.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:l.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:l.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Swe={pi:b7};function Cwe(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Swe[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{v(pe(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{JQ(`${t}.lock`,()=>{let e=null;try{e=S(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}KQ(t,c,e===null?void 0:{mode:W7(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}async function wwe(e){let t=QSe(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0};return t.map(t=>t9(t,``,n,e.home))}function n9(e,t,n,r){let i=i9(e,t,n,r);return i.kind===`present`?i.entry:null}function r9(e,t,n,r){let i=$7(e,t,r);if(!k7(i))return{kind:`no-entry`};let a=i[n];return k7(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function i9(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!g(i))return{kind:`absent`};try{if(O(i).size>J7)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=S(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:PCe(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=M7().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return r9(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,on.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:r9(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=G7(a);return s?K7(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:r9(c6(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}function Twe(e,t){let n=[];for(let r of N5)e9(t7[r],e,t)&&n.push(r);return n}function Ewe(e){return e===`opencode`?HSe:VSe}function Dwe(e,t,n){let r=t7[e],i=Ewe(e),a=[],o=r.projectConfigPath?.(t);o!==void 0&&a.push({scope:`project`,configPath:o});try{a.push({scope:`user`,configPath:r.configPath(t,n)})}catch{}for(let o of a){let a=n9(r,t,n,o.configPath);if(a!==null&&i(a))return{editorId:e,scope:o.scope,configPath:o.configPath}}return null}function a9(){return N(oe(),`.ok`,`bug-reports`)}function Owe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=a9(),r=`${t}-bugreport`,i=N(n,`${r}.zip`);for(let e=2;g(i);e+=1)i=N(n,`${r}-${e}.zip`);return i}function o9(e,t){let n=N(e,`.ok`,`config.yml`);if(g(n))try{let e=S(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return g(N(e,`.ok`))?Ae(`sha256`).update(ve(e)).digest(`hex`).slice(0,12):null}function kwe(){let e={timestamp:new Date().toISOString(),platform:k(),osType:A(),osRelease:ce(),hostname:`[redacted]`,uptime:j(),freeMem:ae(),totalMem:ue(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=l(`sw_vers -productVersion 2>/dev/null`,d3({encoding:`utf8`})).trim()}catch{}try{let t=N(__dirname,`..`,`..`,`package.json`);g(t)&&(e.okVersion=JSON.parse(S(t,`utf8`)).version)}catch{}return e}const Awe=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function s9(e){let t=fe(e);return Awe.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function jwe(e,t){return u9(e,t).files}const Mwe=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function c9(e,t=`com.inkeep.open-knowledge`){let n=N(e,`${t}.ShipIt`);return g(n)?Mwe.map(e=>N(n,e)).filter(e=>g(e)):[]}function l9(e){if(!g(e))return[];try{let t=new Map;for(let n of C(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-10):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>N(e,t))}catch{return[]}}function u9(e,t){if(!g(t))return{files:[],excludedByProjectSlug:0};let n=C(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>N(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(s9),i=[],a=r.filter(t=>{try{return S(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!s9(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Nwe(e){let t=N(e,`.ok`,`local`);return g(t)?{files:[`server.lock`,`last-spawn-error.log`,iX].map(e=>N(t,e)).filter(e=>g(e))}:{files:[]}}function Pwe(e){let t=N(e,`.ok`,`local`,`logs`);return g(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>N(t,e)).filter(e=>g(e))}:{files:[]}}function d9(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=ko(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function f9(e){for(let t of e.files)try{d9({zipfile:e.zipfile,name:`${e.prefix}/${fe(t)}`,content:S(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Fwe(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??N(oe(),`.ok`,`logs`),o=t.projectDir?o9(t.projectDir,i):null;v(pe(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let s=kwe();s.desktop=t.desktop??null,s.language=t.language??null;let{files:c,excludedByProjectSlug:l}=u9(o,a),{files:u}=t.projectDir?Nwe(t.projectDir):{files:[]},{files:d}=t.projectDir?Pwe(t.projectDir):{files:[]},f=t.shipItLogFiles??[];i?.info({logFileCount:c.length,logFilesExcludedByProjectSlug:l,lockFileCount:u.length,localSinkFileCount:d.length,shipItLogFileCount:f.length},`files collected`);let p=[],m=[],{ZipFile:g}=await import(`./yazl-BlMyAOcT.mjs`).then(t=>e(t.t(),1)),_=new g;f9({zipfile:_,files:[...c,...f],prefix:`logs`,redact:n,bundleFiles:m,redactions:p,logger:i}),f9({zipfile:_,files:u,prefix:`lockdir`,redact:n,bundleFiles:m,redactions:p,logger:i}),f9({zipfile:_,files:d,prefix:`local-logs`,redact:n,bundleFiles:m,redactions:p,logger:i}),f9({zipfile:_,files:t.bugReportLedgerFiles??[],prefix:Do,redact:n,bundleFiles:m,redactions:p,logger:i});for(let e of t.extraFiles??[])try{let t=S(e.sourcePath),n=`extra/${e.zipName??fe(e.sourcePath)}`;_.addBuffer(t,n),m.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&d9({zipfile:_,name:`note.txt`,content:t.note,redact:n,bundleFiles:m,redactions:p});let y=JSON.stringify(s,null,2);_.addBuffer(Buffer.from(y,`utf8`),`sysinfo.json`),m.push(`sysinfo.json`);let b={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:m,redactions:p,sysinfo:s};_.addBuffer(Buffer.from(JSON.stringify(b,null,2),`utf8`),`MANIFEST.json`);let x=p.reduce((e,t)=>e+t.lineCount,0),C=new Set(f.map(e=>`logs/${fe(e)}`)),w=m.filter(e=>C.has(e)),T=new Set((t.bugReportLedgerFiles??[]).map(e=>`${Do}/${fe(e)}`)),E=m.filter(e=>T.has(e)),D=o?m.filter(e=>e.startsWith(`logs/`)&&!s9(e)&&!C.has(e)):[],O=[`# Bug Report Bundle`,``,`Generated: ${b.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${b.disciplineVersion}`,``,`## Contents`,``,...m.map(e=>`- ${e}`),``,`## Privacy`,``,...D.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...D.map(e=>`- ${e}`),``]:[],...w.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...w.map(e=>`- ${e}`),``]:[],...E.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...E.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${Jne.join(`, `)}`,x>0?`${x} line(s) were scrubbed across ${p.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
1512
+ `));let p=`${a?``:``}${d}`;return p!==i&&KQ(e,p,{mode:W7(e)}),{kind:l?`overwritten`:`written`}}const xwe=`open-knowledge-ui`;function e9(e,t,n){try{return g(e.detectPath?.(t,n)??pe(e.configPath(t,n)))}catch{return!1}}function Swe(e,t,n){try{let r=ve(pe(e.configPath(t,n))),i=ve(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+ye)}catch{return!1}}function t9(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||Swe(e,t,r);if(!i&&s&&!e9(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{x7(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return wwe(e,o,a,n,{isProjectScope:i!==void 0});let c;try{c=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{v(pe(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let l={action:`written`},u;try{JQ(`${o}.lock`,()=>{let t=qCe(o).writePath;if(v(pe(t),{recursive:!0}),e.format===`toml`){let n=ywe(M7(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}if(e.format===`yaml`){let n=bwe(t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=vwe(t,e.topLevelKey,a,c,e.serverMapSubKey);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){u=e instanceof Error?e:Error(String(e))}return u?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:u.message,...i===void 0?{}:{configScope:`project`}}:l.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:l.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:l.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Cwe={pi:b7};function wwe(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Cwe[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{v(pe(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{JQ(`${t}.lock`,()=>{let e=null;try{e=S(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}KQ(t,c,e===null?void 0:{mode:W7(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}async function Twe(e){let t=$Se(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0};return t.map(t=>t9(t,``,n,e.home))}function n9(e,t,n,r){let i=i9(e,t,n,r);return i.kind===`present`?i.entry:null}function r9(e,t,n,r){let i=$7(e,t,r);if(!k7(i))return{kind:`no-entry`};let a=i[n];return k7(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function i9(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!g(i))return{kind:`absent`};try{if(O(i).size>J7)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=S(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:FCe(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=M7().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return r9(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,on.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:r9(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=G7(a);return s?K7(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:r9(c6(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}function Ewe(e,t){let n=[];for(let r of N5)e9(t7[r],e,t)&&n.push(r);return n}function Dwe(e){return e===`opencode`?USe:HSe}function Owe(e,t,n){let r=t7[e],i=Dwe(e),a=[],o=r.projectConfigPath?.(t);o!==void 0&&a.push({scope:`project`,configPath:o});try{a.push({scope:`user`,configPath:r.configPath(t,n)})}catch{}for(let o of a){let a=n9(r,t,n,o.configPath);if(a!==null&&i(a))return{editorId:e,scope:o.scope,configPath:o.configPath}}return null}function a9(){return N(oe(),`.ok`,`bug-reports`)}function kwe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=a9(),r=`${t}-bugreport`,i=N(n,`${r}.zip`);for(let e=2;g(i);e+=1)i=N(n,`${r}-${e}.zip`);return i}function o9(e,t){let n=N(e,`.ok`,`config.yml`);if(g(n))try{let e=S(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return g(N(e,`.ok`))?Ae(`sha256`).update(ve(e)).digest(`hex`).slice(0,12):null}function Awe(){let e={timestamp:new Date().toISOString(),platform:k(),osType:A(),osRelease:ce(),hostname:`[redacted]`,uptime:j(),freeMem:ae(),totalMem:ue(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=l(`sw_vers -productVersion 2>/dev/null`,d3({encoding:`utf8`})).trim()}catch{}try{let t=N(__dirname,`..`,`..`,`package.json`);g(t)&&(e.okVersion=JSON.parse(S(t,`utf8`)).version)}catch{}return e}const jwe=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function s9(e){let t=fe(e);return jwe.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Mwe(e,t){return u9(e,t).files}const Nwe=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function c9(e,t=`com.inkeep.open-knowledge`){let n=N(e,`${t}.ShipIt`);return g(n)?Nwe.map(e=>N(n,e)).filter(e=>g(e)):[]}function l9(e){if(!g(e))return[];try{let t=new Map;for(let n of C(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-10):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>N(e,t))}catch{return[]}}function u9(e,t){if(!g(t))return{files:[],excludedByProjectSlug:0};let n=C(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>N(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(s9),i=[],a=r.filter(t=>{try{return S(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!s9(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Pwe(e){let t=N(e,`.ok`,`local`);return g(t)?{files:[`server.lock`,`last-spawn-error.log`,iX].map(e=>N(t,e)).filter(e=>g(e))}:{files:[]}}function Fwe(e){let t=N(e,`.ok`,`local`,`logs`);return g(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>N(t,e)).filter(e=>g(e))}:{files:[]}}function d9(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=ko(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function f9(e){for(let t of e.files)try{d9({zipfile:e.zipfile,name:`${e.prefix}/${fe(t)}`,content:S(t,`utf8`),redact:e.redact,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Iwe(t){let{redact:n,outputPath:r,logger:i}=t,a=t.userLogsDir??N(oe(),`.ok`,`logs`),o=t.projectDir?o9(t.projectDir,i):null;v(pe(r),{recursive:!0}),i?.info({projectSlug:o},`gathering diagnostic data`);let s=Awe();s.desktop=t.desktop??null,s.language=t.language??null;let{files:c,excludedByProjectSlug:l}=u9(o,a),{files:u}=t.projectDir?Pwe(t.projectDir):{files:[]},{files:d}=t.projectDir?Fwe(t.projectDir):{files:[]},f=t.shipItLogFiles??[];i?.info({logFileCount:c.length,logFilesExcludedByProjectSlug:l,lockFileCount:u.length,localSinkFileCount:d.length,shipItLogFileCount:f.length},`files collected`);let p=[],m=[],{ZipFile:g}=await import(`./yazl-BlMyAOcT.mjs`).then(t=>e(t.t(),1)),_=new g;f9({zipfile:_,files:[...c,...f],prefix:`logs`,redact:n,bundleFiles:m,redactions:p,logger:i}),f9({zipfile:_,files:u,prefix:`lockdir`,redact:n,bundleFiles:m,redactions:p,logger:i}),f9({zipfile:_,files:d,prefix:`local-logs`,redact:n,bundleFiles:m,redactions:p,logger:i}),f9({zipfile:_,files:t.bugReportLedgerFiles??[],prefix:Do,redact:n,bundleFiles:m,redactions:p,logger:i});for(let e of t.extraFiles??[])try{let t=S(e.sourcePath),n=`extra/${e.zipName??fe(e.sourcePath)}`;_.addBuffer(t,n),m.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&d9({zipfile:_,name:`note.txt`,content:t.note,redact:n,bundleFiles:m,redactions:p});let y=JSON.stringify(s,null,2);_.addBuffer(Buffer.from(y,`utf8`),`sysinfo.json`),m.push(`sysinfo.json`);let b={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:o,files:m,redactions:p,sysinfo:s};_.addBuffer(Buffer.from(JSON.stringify(b,null,2),`utf8`),`MANIFEST.json`);let x=p.reduce((e,t)=>e+t.lineCount,0),C=new Set(f.map(e=>`logs/${fe(e)}`)),w=m.filter(e=>C.has(e)),T=new Set((t.bugReportLedgerFiles??[]).map(e=>`${Do}/${fe(e)}`)),E=m.filter(e=>T.has(e)),D=o?m.filter(e=>e.startsWith(`logs/`)&&!s9(e)&&!C.has(e)):[],O=[`# Bug Report Bundle`,``,`Generated: ${b.generatedAt}`,`Project: ${o??`(unscoped)`}`,`Discipline version: ${b.disciplineVersion}`,``,`## Contents`,``,...m.map(e=>`- ${e}`),``,`## Privacy`,``,...D.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...D.map(e=>`- ${e}`),``]:[],...w.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...w.map(e=>`- ${e}`),``]:[],...E.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...E.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${Jne.join(`, `)}`,x>0?`${x} line(s) were scrubbed across ${p.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
1509
1513
  `);_.addBuffer(Buffer.from(O,`utf8`),`README.md`),_.end();let ee=h(r);return _.outputStream.pipe(ee),await new Promise((e,t)=>{ee.on(`close`,e),ee.on(`error`,t)}),i?.info({bundlePath:r,fileCount:m.length,redactionCount:x},`bundle written`),{zipPath:r,summary:{projectSlug:o,files:m,redactions:p,redactedLineCount:x,generatedAt:b.generatedAt}}}function p9(e,t){let n=ve(e),r=t===void 0?$5():$5({home:t,env:{}});return{cwd:n,bridgePath:t7.pi.projectConfigPath?.(n)??``,trustPath:N(r,`trust.json`)}}function m9(e,t,n){let r=i9(t7.pi,e,n,t);if(r.kind===`absent`)return{state:`absent`,text:null};if(r.kind!==`present`)return{state:`unreadable`,text:null};let i=r.entry,a=Array.isArray(i.args)&&typeof i.args[0]==`string`?i.args[0]:null;return V5(i)?{state:`own-current`,text:a}:y7(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function h9(e,t){let n;try{n=S(e,`utf-8`)}catch(e){let t=e.code;return t===`ENOENT`||t===`ENOTDIR`?{state:`untrusted`,entries:{},trailingNewline:!1}:{state:`unreadable`,entries:null,trailingNewline:!1}}if(n.trim()===``)return{state:`untrusted`,entries:{},trailingNewline:!1};let r;try{r=JSON.parse(n)}catch{return{state:`unreadable`,entries:null,trailingNewline:!1}}return k7(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
1510
- `)}:{state:`unreadable`,entries:null,trailingNewline:!1}}function Iwe(e,t){let n=p9(e,t),r=m9(n.cwd,n.bridgePath,t).state,i=h9(n.trustPath,n.cwd).state;return{...n,bridge:r,trust:i,bridgeLoadable:(r===`own-current`||r===`own-stale`)&&i===`trusted`,otherExtensions:g9(n.bridgePath).names}}function g9(e){let t=pe(e),n=fe(e);try{return{names:C(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort(),verified:!0}}catch(e){let t=e.code;return{names:[],verified:t===`ENOENT`||t===`ENOTDIR`}}}async function Lwe(e,t={mode:`published`},n){let r=p9(e,n),i=m9(r.cwd,r.bridgePath,n);if(i.state===`foreign`)return{...r,ok:!1,bridge:`refused-foreign`,trust:`skipped`};if(i.state===`unreadable`)return{...r,ok:!1,bridge:`refused-unreadable`,trust:`skipped`};let a;if(i.state===`absent`)a=`written`;else{let e;try{e=b7(t)}catch{e=void 0}a=e!==void 0&&i.text===e?`unchanged`:`refreshed`}if(a!==`unchanged`){let e=t9(t7.pi,r.cwd,t,n,r.bridgePath);if(e.action!==`written`&&e.action!==`overwritten`)return{...r,ok:!1,bridge:`failed`,trust:`skipped`,error:e.error??`bridge write ${e.action}`}}let o=await Rwe(r.trustPath,r.cwd);return{...r,ok:o.action===`already-trusted`||o.action===`added`,bridge:a,trust:o.action,...o.error===void 0?{}:{error:o.error}}}async function Rwe(e,t){try{v(pe(e),{recursive:!0})}catch(e){return{action:`failed`,error:e instanceof Error?e.message:String(e)}}let n={action:`added`};try{await dhe(`${e}.lock`,async()=>{let r=h9(e,t);if(r.state===`trusted`){n.action=`already-trusted`;return}if(r.entries===null){n.action=`refused-unreadable`;return}let i={...r.entries,[t]:!0},a=JSON.stringify(i,null,2)+(r.trailingNewline?`
1511
- `:``),o=W7(e);KQ(e,a,o===void 0?void 0:{mode:o}),n.action=`added`})}catch(e){return{action:`failed`,error:e instanceof Error?e.message:String(e)}}return n.action===`refused-unreadable`?{action:`refused-unreadable`,error:`trust store is not a readable JSON object`}:{action:n.action}}function zwe(e,t){let n=p9(e,t),r=g9(n.bridgePath);if(!r.verified)return{action:`kept-unverified`,error:`could not read the Pi extensions folder`};if(r.names.length>0)return{action:`kept-shared`};if(!g(n.trustPath))return{action:`not-present`};let i={action:`removed`};try{JQ(`${n.trustPath}.lock`,()=>{let e=h9(n.trustPath,n.cwd);if(e.entries===null){i.action=e.state===`unreadable`?`refused-unreadable`:`not-present`;return}if(!(n.cwd in e.entries)){i.action=`not-present`;return}let t={...e.entries};delete t[n.cwd];let r=JSON.stringify(t,null,2)+(e.trailingNewline?`
1512
- `:``),a=W7(n.trustPath);KQ(n.trustPath,r,a===void 0?void 0:{mode:a}),i.action=`removed`})}catch(e){return{action:`failed`,error:e instanceof Error?e.message:String(e)}}return i.action===`refused-unreadable`?{action:`refused-unreadable`,error:`trust store is not a readable JSON object`}:{action:i.action}}function Bwe(e){return V5(e)||W5(e)||y7(e)}const _9=10*1024*1024;function Vwe(e,t,n,r){let i=i9(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(!Bwe(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);if(e.format===`file`){D(a,{force:!0});let e=zwe(t,n);return{kind:`removed`,trust:e.action,...e.error===void 0?{}:{trustError:e.error}}}return e.format===`toml`?Wwe(a,o):e.format===`yaml`?Uwe(a,e.topLevelKey,o):Hwe(a,e.topLevelKey,e.serverMapSubKey,o)}function Hwe(e,t,n,r){let i;try{i=S(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>_9)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=cwe(i,Z7(t,n,r));return o?(KQ(e,a,{mode:W7(e)}),{kind:`removed`}):{kind:`not-present`}}function Uwe(e,t,n){let r;try{r=S(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>_9)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,on.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(),l=U7(a);a.trim()===``||a.endsWith(`
1514
+ `)}:{state:`unreadable`,entries:null,trailingNewline:!1}}function Lwe(e,t){let n=p9(e,t),r=m9(n.cwd,n.bridgePath,t).state,i=h9(n.trustPath,n.cwd).state;return{...n,bridge:r,trust:i,bridgeLoadable:(r===`own-current`||r===`own-stale`)&&i===`trusted`,otherExtensions:g9(n.bridgePath).names}}function g9(e){let t=pe(e),n=fe(e);try{return{names:C(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort(),verified:!0}}catch(e){let t=e.code;return{names:[],verified:t===`ENOENT`||t===`ENOTDIR`}}}async function Rwe(e,t={mode:`published`},n){let r=p9(e,n),i=m9(r.cwd,r.bridgePath,n);if(i.state===`foreign`)return{...r,ok:!1,bridge:`refused-foreign`,trust:`skipped`};if(i.state===`unreadable`)return{...r,ok:!1,bridge:`refused-unreadable`,trust:`skipped`};let a;if(i.state===`absent`)a=`written`;else{let e;try{e=b7(t)}catch{e=void 0}a=e!==void 0&&i.text===e?`unchanged`:`refreshed`}if(a!==`unchanged`){let e=t9(t7.pi,r.cwd,t,n,r.bridgePath);if(e.action!==`written`&&e.action!==`overwritten`)return{...r,ok:!1,bridge:`failed`,trust:`skipped`,error:e.error??`bridge write ${e.action}`}}let o=await zwe(r.trustPath,r.cwd);return{...r,ok:o.action===`already-trusted`||o.action===`added`,bridge:a,trust:o.action,...o.error===void 0?{}:{error:o.error}}}async function zwe(e,t){try{v(pe(e),{recursive:!0})}catch(e){return{action:`failed`,error:e instanceof Error?e.message:String(e)}}let n={action:`added`};try{await dhe(`${e}.lock`,async()=>{let r=h9(e,t);if(r.state===`trusted`){n.action=`already-trusted`;return}if(r.entries===null){n.action=`refused-unreadable`;return}let i={...r.entries,[t]:!0},a=JSON.stringify(i,null,2)+(r.trailingNewline?`
1515
+ `:``),o=W7(e);KQ(e,a,o===void 0?void 0:{mode:o}),n.action=`added`})}catch(e){return{action:`failed`,error:e instanceof Error?e.message:String(e)}}return n.action===`refused-unreadable`?{action:`refused-unreadable`,error:`trust store is not a readable JSON object`}:{action:n.action}}function Bwe(e,t){let n=p9(e,t),r=g9(n.bridgePath);if(!r.verified)return{action:`kept-unverified`,error:`could not read the Pi extensions folder`};if(r.names.length>0)return{action:`kept-shared`};if(!g(n.trustPath))return{action:`not-present`};let i={action:`removed`};try{JQ(`${n.trustPath}.lock`,()=>{let e=h9(n.trustPath,n.cwd);if(e.entries===null){i.action=e.state===`unreadable`?`refused-unreadable`:`not-present`;return}if(!(n.cwd in e.entries)){i.action=`not-present`;return}let t={...e.entries};delete t[n.cwd];let r=JSON.stringify(t,null,2)+(e.trailingNewline?`
1516
+ `:``),a=W7(n.trustPath);KQ(n.trustPath,r,a===void 0?void 0:{mode:a}),i.action=`removed`})}catch(e){return{action:`failed`,error:e instanceof Error?e.message:String(e)}}return i.action===`refused-unreadable`?{action:`refused-unreadable`,error:`trust store is not a readable JSON object`}:{action:i.action}}function Vwe(e){return V5(e)||W5(e)||y7(e)}const _9=10*1024*1024;function Hwe(e,t,n,r){let i=i9(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(!Vwe(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);if(e.format===`file`){D(a,{force:!0});let e=Bwe(t,n);return{kind:`removed`,trust:e.action,...e.error===void 0?{}:{trustError:e.error}}}return e.format===`toml`?Gwe(a,o):e.format===`yaml`?Wwe(a,e.topLevelKey,o):Uwe(a,e.topLevelKey,e.serverMapSubKey,o)}function Uwe(e,t,n,r){let i;try{i=S(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>_9)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=lwe(i,Z7(t,n,r));return o?(KQ(e,a,{mode:W7(e)}),{kind:`removed`}):{kind:`not-present`}}function Wwe(e,t,n){let r;try{r=S(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>_9)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,on.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(),l=U7(a);a.trim()===``||a.endsWith(`
1513
1517
  `)?c.endsWith(`
1514
1518
  `)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
1515
1519
  `).replace(/\n/g,`\r
1516
- `));let u=`${i?``:``}${c}`;return u!==r&&KQ(e,u,{mode:W7(e)}),{kind:`removed`}}function Wwe(e,t){let n=M7();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=S(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=U7(a),s=a.trim()===``||a.endsWith(`
1520
+ `));let u=`${i?``:``}${c}`;return u!==r&&KQ(e,u,{mode:W7(e)}),{kind:`removed`}}function Gwe(e,t){let n=M7();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=S(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=U7(a),s=a.trim()===``||a.endsWith(`
1517
1521
  `),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
1518
1522
  `)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
1519
1523
  `).replace(/\n/g,`\r
1520
- `));let u=`${i?``:``}${l}`;return u!==r&&KQ(e,u,{mode:W7(e)}),{kind:`removed`}}function Gwe(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}function Kwe(e){let{priorCommand:t,priorArgs:n}=v9(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function v9(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function y9(e,t){if(!g(e))return{status:`missing`,lockPath:e};let n;try{n=JSON.parse(S(e,`utf-8`))}catch{return{status:`corrupt`,lockPath:e}}if(!n||typeof n!=`object`||!tye(n.pid))return{status:`corrupt`,lockPath:e};let r=n;if(!(t.isAlive??l3)(r.pid))return{status:`dead-pid`,lockPath:e,lock:r};if(typeof r.machineId==`string`)return r.machineId===(t.machineId??lbe())?{status:`alive`,lockPath:e,lock:r}:{status:`foreign-host`,lockPath:e,lock:r};let i=t.host??se();return r.hostname===i?{status:`alive`,lockPath:e,lock:r}:{status:`foreign-host`,lockPath:e,lock:r}}function qwe(e,t,n={}){return y9(ube(e,t),n)}function Jwe(e,t={}){return y9(N(e,`ui.lock`),t)}function Ywe(e,t,n={}){let r=n.isAlive??l3,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function Xwe(e){let t=e.inspect??(t=>t===`ui`?Jwe(e.lockDir):qwe(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=Ywe(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 b9(e){if(!g(e))return{value:null,path:e,source:null,doc:null};let t;try{t=S(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,on.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return k7(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function Zwe(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=$c({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function Qwe(e){let t=e??process.cwd(),n=[],r=[],i=[],a=[],o=XQ(`user`,t),s=GQ({absPath:o});r.push(...s.diagnostics),!s.valid&&s.sidelinedTo!==void 0&&i.push({from:o,to:s.sidelinedTo}),s.valid&&s.source!==void 0&&n.push(o);let c=(e,t=!1)=>{let i=b9(e);if(i.diagnostic!==void 0&&r.push(i.diagnostic),i.value===null)return{};let o=Tl({value:i.value,file:i.path,source:i.source,doc:i.doc});r.push(...o),n.push(e);let s=o.length>0?Dl(i.value):i.value;return t&&a.push(...tl({value:s,file:i.path,source:i.source,doc:i.doc})),s},l=ve(t,`.ok`,`config.yml`),u=c(l,!0),d=c(XQ(`project-local`,t)),f=_l(s.value,u,d),p=LSe.safeParse(f);if(!p.success){let e=b9(l),t={code:`SCHEMA_INVALID`,issues:Zwe(p.error.issues,e)};throw Error(gl(t))}return{config:p.data,sources:n,diagnostics:r,sidelined:i,ignoredCommittedKeys:a}}function x9(e){return e.replace(/:\d+$/,``)}function S9(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:x9(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:x9(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:x9(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 C9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=Kl(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`).filter(e=>e.length>0);if(r.length<5||r[2]!==`blob`)return null;let i,a,o,s;try{i=decodeURIComponent(r[0]),a=decodeURIComponent(r[1]),o=decodeURIComponent(r[3]),s=r.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.length===0||s.some(e=>e.length===0)?null:{host:n,owner:i,repo:a,branch:o,path:s.join(`/`)}}function w9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=Kl(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`);if(r.length<5||r[0]!==``||r[3]!==`tree`)return null;let i=r.slice(5);i.length===1&&i[0]===``&&i.pop();let a,o,s,c;try{a=decodeURIComponent(r[1]),o=decodeURIComponent(r[2]),s=decodeURIComponent(r[4]),c=i.map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.some(e=>e.length===0)?null:{host:n,owner:a,repo:o,branch:s,path:c.join(`/`)}}function $we(e){let t=C9(e);if(t)return{kind:`doc`,...t};let n=w9(e);return n?{kind:`folder`,...n}:null}async function eTe(e,t){let n,r;try{n=await Te(ve(e)),r=await Te(ve(pe(e)))}catch{return{kind:`not-git`}}if(!T9(n,r))return{kind:`symlink-escape`};let i=N(n,`.git`),a;try{a=O(i)}catch{return{kind:`not-git`}}if(a.isDirectory()){let e;try{e=await Te(i)}catch{return{kind:`not-git`}}if(!T9(e,n))return{kind:`symlink-escape`}}else if(!a.isFile())return{kind:`not-git`};let o=DX(n);if(o.kind!==`repository`)return{kind:`not-git`};let s=o.repository.readRemoteUrl(`origin`);if(s.kind===`unreadable`)return{kind:`not-git`};if(s.kind===`absent`)return s.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let c=s.url,l=S9(c);if(l===null)return{kind:`non-github`};let u=Kl(l.hostname);if(u===null)return{kind:`non-github`};let d=u===t.host.toLowerCase(),f=l.owner.toLowerCase()===t.owner.toLowerCase(),p=l.name.toLowerCase()===t.repo.toLowerCase();return!d&&f&&p?{kind:`wrong-host`,actualHost:u}:!d||!f||!p?{kind:`wrong-repo`,actualOwner:l.owner,actualRepo:l.name}:{kind:`ok`,gitRemoteUrl:`https://${u}/${l.owner}/${l.name}.git`}}function T9(e,t){if(e===t)return!0;let n=_e(t,e);return n.length>0&&!n.startsWith(`..`)&&!M(n)}const tTe=`# >>> open-knowledge cli >>>`,nTe=`# <<< open-knowledge cli <<<`,rTe=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function iTe(e){return N(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}[...m3.map(e=>p3[e])];function aTe(e){if(!M(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=ve(e);if(t===ye||pe(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function E9(e){let t=aTe(e),n=[];for(let e of m3){let r=p3[e];n.push({path:N(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of Hl)n.push({path:N(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function oTe(e,t){let n=[];for(let r of E9(e))if(r.bundleId===t)try{D(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}const sTe=[{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=t9(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 r=w7(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function cTe(e,t,n={},r=sTe){let i=[];for(let a of t){let t=t7[a];for(let a of r)i.push(a.write(t,e,n))}return i}function lTe(e,t,n={}){return{integrations:cTe(e,t,n)}}function uTe(e){return GQ({absPath:XQ(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function D9({home:e=oe(),env:t=process.env}={}){let n=uTe(e),{override:r,preferenceList:i}=ghe(t),{locale:a,source:o}=Sse({override:r,storedPreference:n,supportedLocales:ns,preferenceList:i,autoDetectableLocales:lre});return{preference:n,locale:a,source:o,systemLanguages:i}}function O9(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function dTe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function k9(e,t){if(typeof e==`string`)return O9(e,t.contentDir);if(Array.isArray(e))return e.map(e=>k9(e,t));if(!dTe(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=k9(i,t);return n}function A9(e,t){let n=S(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
1524
+ `));let u=`${i?``:``}${l}`;return u!==r&&KQ(e,u,{mode:W7(e)}),{kind:`removed`}}function Kwe(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}function qwe(e){let{priorCommand:t,priorArgs:n}=v9(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function v9(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function y9(e,t){if(!g(e))return{status:`missing`,lockPath:e};let n;try{n=JSON.parse(S(e,`utf-8`))}catch{return{status:`corrupt`,lockPath:e}}if(!n||typeof n!=`object`||!tye(n.pid))return{status:`corrupt`,lockPath:e};let r=n;if(!(t.isAlive??l3)(r.pid))return{status:`dead-pid`,lockPath:e,lock:r};if(typeof r.machineId==`string`)return r.machineId===(t.machineId??ube())?{status:`alive`,lockPath:e,lock:r}:{status:`foreign-host`,lockPath:e,lock:r};let i=t.host??se();return r.hostname===i?{status:`alive`,lockPath:e,lock:r}:{status:`foreign-host`,lockPath:e,lock:r}}function Jwe(e,t,n={}){return y9(dbe(e,t),n)}function Ywe(e,t={}){return y9(N(e,`ui.lock`),t)}function Xwe(e,t,n={}){let r=n.isAlive??l3,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function Zwe(e){let t=e.inspect??(t=>t===`ui`?Ywe(e.lockDir):Jwe(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=Xwe(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 b9(e){if(!g(e))return{value:null,path:e,source:null,doc:null};let t;try{t=S(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,on.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return k7(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function Qwe(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=$c({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function $we(e){let t=e??process.cwd(),n=[],r=[],i=[],a=[],o=XQ(`user`,t),s=GQ({absPath:o});r.push(...s.diagnostics),!s.valid&&s.sidelinedTo!==void 0&&i.push({from:o,to:s.sidelinedTo}),s.valid&&s.source!==void 0&&n.push(o);let c=(e,t=!1)=>{let i=b9(e);if(i.diagnostic!==void 0&&r.push(i.diagnostic),i.value===null)return{};let o=Tl({value:i.value,file:i.path,source:i.source,doc:i.doc});r.push(...o),n.push(e);let s=o.length>0?Dl(i.value):i.value;return t&&a.push(...tl({value:s,file:i.path,source:i.source,doc:i.doc})),s},l=ve(t,`.ok`,`config.yml`),u=c(l,!0),d=c(XQ(`project-local`,t)),f=_l(s.value,u,d),p=RSe.safeParse(f);if(!p.success){let e=b9(l),t={code:`SCHEMA_INVALID`,issues:Qwe(p.error.issues,e)};throw Error(gl(t))}return{config:p.data,sources:n,diagnostics:r,sidelined:i,ignoredCommittedKeys:a}}function x9(e){return e.replace(/:\d+$/,``)}function S9(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:x9(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:x9(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:x9(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 C9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=Kl(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`).filter(e=>e.length>0);if(r.length<5||r[2]!==`blob`)return null;let i,a,o,s;try{i=decodeURIComponent(r[0]),a=decodeURIComponent(r[1]),o=decodeURIComponent(r[3]),s=r.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.length===0||s.some(e=>e.length===0)?null:{host:n,owner:i,repo:a,branch:o,path:s.join(`/`)}}function w9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=Kl(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`);if(r.length<5||r[0]!==``||r[3]!==`tree`)return null;let i=r.slice(5);i.length===1&&i[0]===``&&i.pop();let a,o,s,c;try{a=decodeURIComponent(r[1]),o=decodeURIComponent(r[2]),s=decodeURIComponent(r[4]),c=i.map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.some(e=>e.length===0)?null:{host:n,owner:a,repo:o,branch:s,path:c.join(`/`)}}function eTe(e){let t=C9(e);if(t)return{kind:`doc`,...t};let n=w9(e);return n?{kind:`folder`,...n}:null}async function tTe(e,t){let n,r;try{n=await Te(ve(e)),r=await Te(ve(pe(e)))}catch{return{kind:`not-git`}}if(!T9(n,r))return{kind:`symlink-escape`};let i=N(n,`.git`),a;try{a=O(i)}catch{return{kind:`not-git`}}if(a.isDirectory()){let e;try{e=await Te(i)}catch{return{kind:`not-git`}}if(!T9(e,n))return{kind:`symlink-escape`}}else if(!a.isFile())return{kind:`not-git`};let o=DX(n);if(o.kind!==`repository`)return{kind:`not-git`};let s=o.repository.readRemoteUrl(`origin`);if(s.kind===`unreadable`)return{kind:`not-git`};if(s.kind===`absent`)return s.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let c=s.url,l=S9(c);if(l===null)return{kind:`non-github`};let u=Kl(l.hostname);if(u===null)return{kind:`non-github`};let d=u===t.host.toLowerCase(),f=l.owner.toLowerCase()===t.owner.toLowerCase(),p=l.name.toLowerCase()===t.repo.toLowerCase();return!d&&f&&p?{kind:`wrong-host`,actualHost:u}:!d||!f||!p?{kind:`wrong-repo`,actualOwner:l.owner,actualRepo:l.name}:{kind:`ok`,gitRemoteUrl:`https://${u}/${l.owner}/${l.name}.git`}}function T9(e,t){if(e===t)return!0;let n=_e(t,e);return n.length>0&&!n.startsWith(`..`)&&!M(n)}const nTe=`# >>> open-knowledge cli >>>`,rTe=`# <<< open-knowledge cli <<<`,iTe=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function aTe(e){return N(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}[...m3.map(e=>p3[e])];function oTe(e){if(!M(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=ve(e);if(t===ye||pe(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function E9(e){let t=oTe(e),n=[];for(let e of m3){let r=p3[e];n.push({path:N(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of Hl)n.push({path:N(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function sTe(e,t){let n=[];for(let r of E9(e))if(r.bundleId===t)try{D(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}const cTe=[{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=t9(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 r=w7(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function lTe(e,t,n={},r=cTe){let i=[];for(let a of t){let t=t7[a];for(let a of r)i.push(a.write(t,e,n))}return i}function uTe(e,t,n={}){return{integrations:lTe(e,t,n)}}function dTe(e){return GQ({absPath:XQ(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function D9({home:e=oe(),env:t=process.env}={}){let n=dTe(e),{override:r,preferenceList:i}=ghe(t),{locale:a,source:o}=Sse({override:r,storedPreference:n,supportedLocales:ns,preferenceList:i,autoDetectableLocales:lre});return{preference:n,locale:a,source:o,systemLanguages:i}}function O9(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function fTe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function k9(e,t){if(typeof e==`string`)return O9(e,t.contentDir);if(Array.isArray(e))return e.map(e=>k9(e,t));if(!fTe(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=k9(i,t);return n}function A9(e,t){let n=S(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
1521
1525
  `),i=n.split(`
1522
1526
  `),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(!(e===i.length-1&&n===``)){if(n.length===0){a.push(``);continue}try{let e=k9(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}te(e,r?`${a.join(`
1523
1527
  `)}\n`:a.join(`
1524
1528
  `))}function j9(e,t){let n=S(e,`utf-8`);if(n.trim().length!==0)try{let r=k9(JSON.parse(n),t),i=n.endsWith(`
1525
1529
  `)?`
1526
- `:``;te(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=O9(n,t.contentDir);r!==n&&te(e,r)}}function M9(e,t){let n=S(e,`utf-8`),r=O9(n,t.contentDir);r!==n&&te(e,r)}function N9(e){try{return C(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>N(e,t.name))}catch{return[]}}const fTe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function P9(e){return/\.log\.\d+$/.test(e)}function pTe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||P9(e)}function mTe(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of N9(N(e.stagingDir,n)))pTe(r)?A9(r,t):r.endsWith(`.json`)?j9(r,t):M9(r,t);for(let n of N9(N(e.stagingDir,`state`))){let e=fe(n);n.endsWith(`.jsonl`)?A9(n,t):fTe.has(e)?j9(n,t):M9(n,t)}}const F9=[`.ok`,`local`,`telemetry`],I9=[`.ok`,`local`,`logs`],L9=[`.ok`,`local`,`loss-capture`],R9=`spans-current.jsonl`,z9=`spans-prev.jsonl`,B9=`server-current.jsonl`,V9=`server-prev.jsonl`,H9=`loss-current.jsonl`,U9=`loss-prev.jsonl`;function hTe(e){return N(e,...F9,R9)}function gTe(e){return N(e,...F9,z9)}function _Te(e){return N(e,...I9,B9)}function vTe(e){return N(e,...I9,V9)}function yTe(e){return N(e,...L9,H9)}function bTe(e){return N(e,...L9,U9)}const W9=1e3;async function xTe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}async function STe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}async function CTe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}function wTe(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
1527
- `)}\n`:null}catch{return null}}function TTe(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=u(`git`,[`-C`,t,`log`,`--oneline`,`-50`],d3({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ETe(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=u(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],d3({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function G9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function DTe(){return{nodeVersion:process.version,platform:k(),arch:re()}}function OTe(){return process.env.OTEL_SDK_DISABLED===`false`}function K9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q9(e){if(!g(e))return{};let t;try{t=(0,on.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!K9(t))return{};let n=t.telemetry;if(!K9(n))return{};let r=n.localSink;return K9(r)?r:{}}function J9(e){return typeof e==`boolean`?e:void 0}function kTe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y9(e){if(K9(e))return kTe(e.maxBytes)}function ATe(e){let t=q9(XQ(`project`,e)),n=q9(XQ(`project-local`,e));return{enabled:J9(n.enabled)??J9(t.enabled)??!0,spansMaxBytes:Y9(n.spans)??Y9(t.spans)??52428800,logsMaxBytes:Y9(n.logs)??Y9(t.logs)??26214400}}function jTe(e){return Ae(`sha256`).update(e).digest(`hex`)}function MTe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function NTe(e){let t=S(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X9(e,t){if(!g(e))return!1;try{return v(pe(t),{recursive:!0}),m(e,t),!0}catch{return!1}}function Z9(e){let t=[],n=e=>{let r=C(e,{withFileTypes:!0});for(let i of r){let r=N(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const PTe=new Set([`.jsonl`]);function Q9(e){let t=e.lastIndexOf(`.`);return t===-1?!1:PTe.has(e.slice(t))}const FTe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`]);function ITe(e){if(P9(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:FTe.has(e.slice(t))}function LTe(e){let t=[];for(let n of Z9(e)){let r=$9(e,n);if(!ITe(r))continue;let{redacted:i,patterns:a,lineCount:o}=ko(S(n,`utf-8`));a.length!==0&&(te(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return _e(e,t).split(ye).join(`/`)}async function RTe(e){let t=ve(e.contentDir),n=ve(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??xTe,a=r.fetchAgentEffects??STe,o=r.fetchWatcherRecent??CTe,s=r.readShadowHead??TTe,c=r.readCheckpointRefs??ETe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.63.1`),d=r.readDesktopEnv??G9,f=r.readLanguage??D9,p=r.readRuntime??DTe,h=r.isOtlpPushEnabled??OTe,_=y(N(le(),`ok-bundle-`));try{v(N(_,`telemetry`),{recursive:!0}),v(N(_,`logs`),{recursive:!0}),v(N(_,`state`),{recursive:!0}),X9(hTe(n),N(_,`telemetry`,R9)),X9(gTe(n),N(_,`telemetry`,z9)),X9(_Te(n),N(_,`logs`,B9)),X9(vTe(n),N(_,`logs`,V9));for(let t of e.userLogFiles??[])X9(t,N(_,`logs`,fe(t)));for(let t of e.userStateFiles??[])X9(t,N(_,Do,fe(t)));let y=N(n,`.ok`,`local`),b=N(y,`server.lock`),x=`not-running`,C=`no server.lock`,w=null;if(g(b)){X9(b,N(_,`state`,`server.lock`));try{let e=S(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?w=t.port:C=`lock present but no port`}catch{C=`lock present but unparseable`}}if(w!==null){let e=await i(w);e===null?C=`agent-presence endpoint at :${w} unreachable`:(te(N(_,`state`,`agent-presence.json`),e),x=`running`,C=``);let t=await a(w);t!==null&&te(N(_,`state`,`agent-effects.json`),t);let n=await o(w);if(n!==null){let e=wTe(n);e!==null&&te(N(_,`state`,`watcher-recent.jsonl`),e)}}let T=s(t);T!==null&&te(N(_,`state`,`shadow-head.txt`),T);let E=c(t);E!==null&&te(N(_,`state`,`checkpoint-refs.txt`),E),X9(yTe(n),N(_,`state`,H9)),X9(bTe(n),N(_,`state`,U9)),X9(N(y,`last-spawn-error.log`),N(_,`state`,`last-spawn-error.log`)),X9(N(y,rX),N(_,`state`,rX)),X9(N(y,iX),N(_,`state`,iX));let ee=p(),ne=d(),re=f(),ie={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:re}};te(N(_,`state`,`runtime.json`),`${JSON.stringify(ie,null,2)}\n`);let ae=x===`running`?`running
1528
- `:`not-running (${C})\n`;if(te(N(_,`state`,`server-status.txt`),ae),e.processDir&&g(e.processDir)){let t=N(_,`process`);v(t,{recursive:!0}),m(e.processDir,t,{recursive:!0})}let oe=e.redact===!0;oe&&mTe({stagingDir:_,contentDir:t}),e.note&&te(N(_,`note.txt`),e.note);let se=null;e.scrubSecrets===!0&&(se=LTe(_));for(let t of e.extraFiles??[])X9(t.sourcePath,N(_,`extra`,t.zipName??fe(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let k=ATe(n),ce=Z9(_),le=[],ue=0,A=0;for(let e of ce){let t=$9(_,e),n=O(e).size,r=Q9(t)?MTe(e):0;le.push({path:t,bytes:n,lines:r}),ue+=n,t.startsWith(`telemetry/`)&&Q9(t)&&(A+=NTe(e))}let j={applied:oe};se!==null&&(j.secretScrub=se);let de={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:re},contentDir:{pathSha256:jTe(t),absolutePath:oe?`<CONTENT_DIR>`:t},telemetry:{localSink:k,otlpPushEnabled:h()},redaction:j,serverStatus:x,files:le};te(N(_,`manifest.json`),`${JSON.stringify(de,null,2)}\n`);let pe=ce.some(e=>{try{return S(e,`utf-8`).includes(t)}catch{return!1}}),me={totalBytes:ue,fileCount:le.length,docNameCount:A,contentDirVisible:pe,redacted:oe},M=!1;return{stagingDir:_,manifest:de,summary:me,cleanup:()=>{M||(M=!0,D(_,{recursive:!0,force:!0}))}}}catch(e){throw D(_,{recursive:!0,force:!0}),e}}async function zTe(e){let{collected:t,outputPath:n}=e,r=pe(n);if(!g(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new pye.ZipFile,a=Z9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=h(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function BTe(e,t){let n=N(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,on.parse)(S(n,`utf-8`)),r=k7(t)?t.content:void 0,i=k7(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return ve(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return ve(e)}async function VTe(e,t,n,r){let i=o9(t,e.logger),a=await RTe({contentDir:BTe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...jwe(i,e.userLogsDir??N(oe(),`.ok`,`logs`)),...c9(e.cachesDir??N(oe(),`Library`,`Caches`))],userStateFiles:l9(e.bugReportsDir??a9()),deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{v(pe(e.outputPath),{recursive:!0}),await zTe({collected:a,outputPath:e.outputPath});let t=a.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:i,files:a.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:a.manifest.createdAt}}}finally{a.cleanup()}}async function HTe(e){let{projectDir:t}=e,n=e.readDesktopEnv??G9,r=e.readLanguage??D9;if(e.level===`full`&&t!==void 0)return VTe(e,t,n,r);let{zipPath:i,summary:a}=await Fwe({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:c9(e.cachesDir??N(oe(),`Library`,`Caches`)),bugReportLedgerFiles:l9(e.bugReportsDir??a9()),logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:i,summary:{level:e.level,systemWide:t===void 0,projectSlug:a.projectSlug,files:a.files,redactions:a.redactions,redactedLineCount:a.redactedLineCount,generatedAt:a.generatedAt}}}export{N5 as ALL_EDITOR_IDS,P5 as EDITOR_LABELS,t7 as EDITOR_TARGETS,RSe as HOSTS_WITH_USER_SKILL_DIR,bwe as LAUNCH_CONFIG_NAME,tTe as PATH_SHIM_BEGIN,rTe as PATH_SHIM_BLOCK_RE,nTe as PATH_SHIM_END,$Ce as addOkPathsToGitExclude,x7 as assertProjectPathSafe,U5 as buildManagedServerEntry,Gwe as buildMcpConfigDeclineEvent,Kwe as buildMcpConfigMigrateEvent,i9 as classifyExistingMcpEntry,HTe as collectReportBundle,un as createTokenStore,Owe as defaultBugReportZipPath,Be as detectGh,Ue as detectGhAccounts,Twe as detectInstalledEditors,ZSe as editorConfigPathDisplay,XSe as editorEntryLocator,Lwe as ensurePiBridge,R7 as formatTrackedRemediation,nwe as getExcludedOkPaths,QCe as getNativeTomlMcpEditor,I7 as getOkArtifactPaths,V5 as isEntryUpToDate,W5 as isOwnManagedEntry,Qwe as loadConfig,fee as makeLazyProbeTokenStore,a9 as okBugReportsDir,C9 as parseGitHubBlobUrl,$we as parseGitHubShareUrl,w9 as parseGitHubTreeUrl,S9 as parseGitUrl,iTe as pathInstallMarkerPath,jCe as previewContent,Dwe as probeOwnManagedEditorMcpEntry,Iwe as probePiBridgeState,L7 as probeTrackedOkPaths,n9 as readExistingMcpEntry,twe as readSharingMode,rwe as readSkillsShared,ko as redactContent,ewe as removeOkPathsFromGitExclude,Vwe as removeOwnMcpEntry,VCe as removeProjectSkill,oTe as removeUserGlobalSkillBundle,LCe as resolveProjectRoot,Xwe as runStop,iwe as setSkillsShared,v9 as truncatePriorEntry,E9 as userGlobalSkillBundleTargets,eTe as validateLocalFolderForShare,t9 as writeEditorMcpConfig,lTe as writeProjectAiIntegrations,w7 as writeProjectSkill,wwe as writeUserMcpConfigs};
1530
+ `:``;te(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=O9(n,t.contentDir);r!==n&&te(e,r)}}function M9(e,t){let n=S(e,`utf-8`),r=O9(n,t.contentDir);r!==n&&te(e,r)}function N9(e){try{return C(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>N(e,t.name))}catch{return[]}}const pTe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function P9(e){return/\.log\.\d+$/.test(e)}function mTe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||P9(e)}function hTe(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of N9(N(e.stagingDir,n)))mTe(r)?A9(r,t):r.endsWith(`.json`)?j9(r,t):M9(r,t);for(let n of N9(N(e.stagingDir,`state`))){let e=fe(n);n.endsWith(`.jsonl`)?A9(n,t):pTe.has(e)?j9(n,t):M9(n,t)}}const F9=[`.ok`,`local`,`telemetry`],I9=[`.ok`,`local`,`logs`],L9=[`.ok`,`local`,`loss-capture`],R9=`spans-current.jsonl`,z9=`spans-prev.jsonl`,B9=`server-current.jsonl`,V9=`server-prev.jsonl`,H9=`loss-current.jsonl`,U9=`loss-prev.jsonl`;function gTe(e){return N(e,...F9,R9)}function _Te(e){return N(e,...F9,z9)}function vTe(e){return N(e,...I9,B9)}function yTe(e){return N(e,...I9,V9)}function bTe(e){return N(e,...L9,H9)}function xTe(e){return N(e,...L9,U9)}const W9=1e3;async function STe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}async function CTe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}async function wTe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}function TTe(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
1531
+ `)}\n`:null}catch{return null}}function ETe(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=u(`git`,[`-C`,t,`log`,`--oneline`,`-50`],d3({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function DTe(e){let t=N(e,`.git`,`ok`);if(!g(t))return null;let n=u(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],d3({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function G9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function OTe(){return{nodeVersion:process.version,platform:k(),arch:re()}}function kTe(){return process.env.OTEL_SDK_DISABLED===`false`}function K9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q9(e){if(!g(e))return{};let t;try{t=(0,on.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!K9(t))return{};let n=t.telemetry;if(!K9(n))return{};let r=n.localSink;return K9(r)?r:{}}function J9(e){return typeof e==`boolean`?e:void 0}function ATe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y9(e){if(K9(e))return ATe(e.maxBytes)}function jTe(e){let t=q9(XQ(`project`,e)),n=q9(XQ(`project-local`,e));return{enabled:J9(n.enabled)??J9(t.enabled)??!0,spansMaxBytes:Y9(n.spans)??Y9(t.spans)??52428800,logsMaxBytes:Y9(n.logs)??Y9(t.logs)??26214400}}function MTe(e){return Ae(`sha256`).update(e).digest(`hex`)}function NTe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function PTe(e){let t=S(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function X9(e,t){if(!g(e))return!1;try{return v(pe(t),{recursive:!0}),m(e,t),!0}catch{return!1}}function Z9(e){let t=[],n=e=>{let r=C(e,{withFileTypes:!0});for(let i of r){let r=N(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const FTe=new Set([`.jsonl`]);function Q9(e){let t=e.lastIndexOf(`.`);return t===-1?!1:FTe.has(e.slice(t))}const ITe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`]);function LTe(e){if(P9(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:ITe.has(e.slice(t))}function RTe(e){let t=[];for(let n of Z9(e)){let r=$9(e,n);if(!LTe(r))continue;let{redacted:i,patterns:a,lineCount:o}=ko(S(n,`utf-8`));a.length!==0&&(te(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return _e(e,t).split(ye).join(`/`)}async function zTe(e){let t=ve(e.contentDir),n=ve(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??STe,a=r.fetchAgentEffects??CTe,o=r.fetchWatcherRecent??wTe,s=r.readShadowHead??ETe,c=r.readCheckpointRefs??DTe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.63.2`),d=r.readDesktopEnv??G9,f=r.readLanguage??D9,p=r.readRuntime??OTe,h=r.isOtlpPushEnabled??kTe,_=y(N(le(),`ok-bundle-`));try{v(N(_,`telemetry`),{recursive:!0}),v(N(_,`logs`),{recursive:!0}),v(N(_,`state`),{recursive:!0}),X9(gTe(n),N(_,`telemetry`,R9)),X9(_Te(n),N(_,`telemetry`,z9)),X9(vTe(n),N(_,`logs`,B9)),X9(yTe(n),N(_,`logs`,V9));for(let t of e.userLogFiles??[])X9(t,N(_,`logs`,fe(t)));for(let t of e.userStateFiles??[])X9(t,N(_,Do,fe(t)));let y=N(n,`.ok`,`local`),b=N(y,`server.lock`),x=`not-running`,C=`no server.lock`,w=null;if(g(b)){X9(b,N(_,`state`,`server.lock`));try{let e=S(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?w=t.port:C=`lock present but no port`}catch{C=`lock present but unparseable`}}if(w!==null){let e=await i(w);e===null?C=`agent-presence endpoint at :${w} unreachable`:(te(N(_,`state`,`agent-presence.json`),e),x=`running`,C=``);let t=await a(w);t!==null&&te(N(_,`state`,`agent-effects.json`),t);let n=await o(w);if(n!==null){let e=TTe(n);e!==null&&te(N(_,`state`,`watcher-recent.jsonl`),e)}}let T=s(t);T!==null&&te(N(_,`state`,`shadow-head.txt`),T);let E=c(t);E!==null&&te(N(_,`state`,`checkpoint-refs.txt`),E),X9(bTe(n),N(_,`state`,H9)),X9(xTe(n),N(_,`state`,U9)),X9(N(y,`last-spawn-error.log`),N(_,`state`,`last-spawn-error.log`)),X9(N(y,rX),N(_,`state`,rX)),X9(N(y,iX),N(_,`state`,iX));let ee=p(),ne=d(),re=f(),ie={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:re}};te(N(_,`state`,`runtime.json`),`${JSON.stringify(ie,null,2)}\n`);let ae=x===`running`?`running
1532
+ `:`not-running (${C})\n`;if(te(N(_,`state`,`server-status.txt`),ae),e.processDir&&g(e.processDir)){let t=N(_,`process`);v(t,{recursive:!0}),m(e.processDir,t,{recursive:!0})}let oe=e.redact===!0;oe&&hTe({stagingDir:_,contentDir:t}),e.note&&te(N(_,`note.txt`),e.note);let se=null;e.scrubSecrets===!0&&(se=RTe(_));for(let t of e.extraFiles??[])X9(t.sourcePath,N(_,`extra`,t.zipName??fe(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let k=jTe(n),ce=Z9(_),le=[],ue=0,A=0;for(let e of ce){let t=$9(_,e),n=O(e).size,r=Q9(t)?NTe(e):0;le.push({path:t,bytes:n,lines:r}),ue+=n,t.startsWith(`telemetry/`)&&Q9(t)&&(A+=PTe(e))}let j={applied:oe};se!==null&&(j.secretScrub=se);let de={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:re},contentDir:{pathSha256:MTe(t),absolutePath:oe?`<CONTENT_DIR>`:t},telemetry:{localSink:k,otlpPushEnabled:h()},redaction:j,serverStatus:x,files:le};te(N(_,`manifest.json`),`${JSON.stringify(de,null,2)}\n`);let pe=ce.some(e=>{try{return S(e,`utf-8`).includes(t)}catch{return!1}}),me={totalBytes:ue,fileCount:le.length,docNameCount:A,contentDirVisible:pe,redacted:oe},M=!1;return{stagingDir:_,manifest:de,summary:me,cleanup:()=>{M||(M=!0,D(_,{recursive:!0,force:!0}))}}}catch(e){throw D(_,{recursive:!0,force:!0}),e}}async function BTe(e){let{collected:t,outputPath:n}=e,r=pe(n);if(!g(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new pye.ZipFile,a=Z9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=h(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function VTe(e,t){let n=N(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,on.parse)(S(n,`utf-8`)),r=k7(t)?t.content:void 0,i=k7(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return ve(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return ve(e)}async function HTe(e,t,n,r){let i=o9(t,e.logger),a=await zTe({contentDir:VTe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...Mwe(i,e.userLogsDir??N(oe(),`.ok`,`logs`)),...c9(e.cachesDir??N(oe(),`Library`,`Caches`))],userStateFiles:l9(e.bugReportsDir??a9()),deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{v(pe(e.outputPath),{recursive:!0}),await BTe({collected:a,outputPath:e.outputPath});let t=a.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:i,files:a.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:a.manifest.createdAt}}}finally{a.cleanup()}}async function UTe(e){let{projectDir:t}=e,n=e.readDesktopEnv??G9,r=e.readLanguage??D9;if(e.level===`full`&&t!==void 0)return HTe(e,t,n,r);let{zipPath:i,summary:a}=await Iwe({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:c9(e.cachesDir??N(oe(),`Library`,`Caches`)),bugReportLedgerFiles:l9(e.bugReportsDir??a9()),logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:i,summary:{level:e.level,systemWide:t===void 0,projectSlug:a.projectSlug,files:a.files,redactions:a.redactions,redactedLineCount:a.redactedLineCount,generatedAt:a.generatedAt}}}export{N5 as ALL_EDITOR_IDS,P5 as EDITOR_LABELS,t7 as EDITOR_TARGETS,zSe as HOSTS_WITH_USER_SKILL_DIR,xwe as LAUNCH_CONFIG_NAME,nTe as PATH_SHIM_BEGIN,iTe as PATH_SHIM_BLOCK_RE,rTe as PATH_SHIM_END,ewe as addOkPathsToGitExclude,x7 as assertProjectPathSafe,U5 as buildManagedServerEntry,Kwe as buildMcpConfigDeclineEvent,qwe as buildMcpConfigMigrateEvent,i9 as classifyExistingMcpEntry,UTe as collectReportBundle,un as createTokenStore,kwe as defaultBugReportZipPath,Be as detectGh,Ue as detectGhAccounts,Ewe as detectInstalledEditors,QSe as editorConfigPathDisplay,ZSe as editorEntryLocator,Rwe as ensurePiBridge,R7 as formatTrackedRemediation,rwe as getExcludedOkPaths,$Ce as getNativeTomlMcpEditor,I7 as getOkArtifactPaths,V5 as isEntryUpToDate,W5 as isOwnManagedEntry,$we as loadConfig,fee as makeLazyProbeTokenStore,a9 as okBugReportsDir,C9 as parseGitHubBlobUrl,eTe as parseGitHubShareUrl,w9 as parseGitHubTreeUrl,S9 as parseGitUrl,aTe as pathInstallMarkerPath,MCe as previewContent,Owe as probeOwnManagedEditorMcpEntry,Lwe as probePiBridgeState,L7 as probeTrackedOkPaths,n9 as readExistingMcpEntry,nwe as readSharingMode,iwe as readSkillsShared,ko as redactContent,twe as removeOkPathsFromGitExclude,Hwe as removeOwnMcpEntry,HCe as removeProjectSkill,sTe as removeUserGlobalSkillBundle,RCe as resolveProjectRoot,Zwe as runStop,awe as setSkillsShared,v9 as truncatePriorEntry,E9 as userGlobalSkillBundleTargets,tTe as validateLocalFolderForShare,t9 as writeEditorMcpConfig,uTe as writeProjectAiIntegrations,w7 as writeProjectSkill,Twe as writeUserMcpConfigs};
1529
1533
  //# sourceMappingURL=index.mjs.map