@inkeep/open-knowledge 0.49.1 → 0.50.0-beta.1

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 (293) hide show
  1. package/dist/{acp-harness-probe-C8FhVWZi.mjs → acp-harness-probe-DwJF1QrM.mjs} +2 -2
  2. package/dist/cli.mjs +62 -62
  3. package/dist/constants-C9EGLQ-u.mjs +2 -0
  4. package/dist/{git-handle-r3d7s3VF.mjs → git-handle-B9WUn7B2.mjs} +2 -2
  5. package/dist/git-handle-BfyNyc1q.mjs +1 -0
  6. package/dist/index.d.mts +36 -5
  7. package/dist/index.mjs +192 -192
  8. package/dist/{init-VslWN3Iz.mjs → init-8_iXriiz.mjs} +3 -3
  9. package/dist/init-D5SAyEIp.mjs +1 -0
  10. package/dist/{launch-json-removal-9-8M5r9e.mjs → launch-json-removal-CXPn5A7N.mjs} +2 -2
  11. package/dist/{loader-f3tIWlWk.mjs → loader-CJqV3lQK.mjs} +2 -2
  12. package/dist/loader-CU-Nz3ee.mjs +1 -0
  13. package/dist/md-manager-DGG55-uN.mjs +2 -0
  14. package/dist/{open-browser-BgReR_t5.mjs → open-browser-Bu1KY-5f.mjs} +2 -2
  15. package/dist/parse-worker.mjs +1 -1
  16. package/dist/{preview-CdESX2Ja.mjs → preview-CXrbuj-R.mjs} +2 -2
  17. package/dist/preview-CjwSh-52.mjs +1 -0
  18. package/dist/public/assets/ActivityModeContent-HRSmxB9_.js +1 -0
  19. package/dist/public/assets/{AgentDiffPane-T499-ugv.js → AgentDiffPane-BGYo5UN6.js} +1 -1
  20. package/dist/public/assets/{AgentThreadClientBinder-BlMGv16y.js → AgentThreadClientBinder-0uU00Tq4.js} +1 -1
  21. package/dist/public/assets/{AppMenubar-dik_dmjC.js → AppMenubar-Dk1BEmD9.js} +1 -1
  22. package/dist/public/assets/{BugReportHistory-DymFE_6x.js → BugReportHistory-CRlvJE2K.js} +1 -1
  23. package/dist/public/assets/{BugReportHistoryDialog-D28ahq-6.js → BugReportHistoryDialog-DIqnZXkT.js} +1 -1
  24. package/dist/public/assets/ChangedOutsideBadge-CG45zoCT.js +1 -0
  25. package/dist/public/assets/{CodeMirrorPropInput-3TWUbzXY.js → CodeMirrorPropInput-B__Dqs8P.js} +3 -3
  26. package/dist/public/assets/{ConfigSharingInfoTooltip-Bwt_R43K.js → ConfigSharingInfoTooltip-BNI3Q3Qo.js} +1 -1
  27. package/dist/public/assets/ConsentDialogBody-BlayjFQq.js +2 -0
  28. package/dist/public/assets/{CopyButton-DysciFW5.js → CopyButton-Q-6hSzy6.js} +1 -1
  29. package/dist/public/assets/{DiffView-DY54R06f.js → DiffView-BnNY_4OT.js} +1 -1
  30. package/dist/public/assets/DocumentContext-Dxzqsjf0.js +38 -0
  31. package/dist/public/assets/EditorModeToggle-OACqdrIA.js +1 -0
  32. package/dist/public/assets/EnableSyncConfirmDialog-DBMws9uC.js +1 -0
  33. package/dist/public/assets/FeedbackForm-YQbdmBFL.js +1 -0
  34. package/dist/public/assets/GraphPanel-BlBOG-me.js +44 -0
  35. package/dist/public/assets/ImportSkillDialog-CgeVAxXn.js +1 -0
  36. package/dist/public/assets/{LintConfigEditor-3f4-NF1O.js → LintConfigEditor-v0oqzBfd.js} +1 -1
  37. package/dist/public/assets/ManagedArtifactProperties-BfO4jYnj.js +2 -0
  38. package/dist/public/assets/ManagedArtifactProperties-Dmjq1ugS.js +1 -0
  39. package/dist/public/assets/McpConsentDialogBody-DcaMMYmf.js +1 -0
  40. package/dist/public/assets/{Mermaid-Cr48L9fH.js → Mermaid-cUFqNhzC.js} +1 -1
  41. package/dist/public/assets/{MermaidDocEditor-C30-UfMg.js → MermaidDocEditor-YEj8k0Fj.js} +1 -1
  42. package/dist/public/assets/{RegisteredAgentIcon-Cdt1gfjt.js → RegisteredAgentIcon-CCgDsAUc.js} +1 -1
  43. package/dist/public/assets/{ReportBugDialogBody-BUGec7jk.js → ReportBugDialogBody-f7fl9dVO.js} +1 -1
  44. package/dist/public/assets/SchemaConfigEditor-C_BBar0x.js +1 -0
  45. package/dist/public/assets/SessionsHost-DPObQsYR.js +2 -0
  46. package/dist/public/assets/SettingsDialogBody-C53PpDiP.js +12 -0
  47. package/dist/public/assets/ShareBranchSwitchDialog-DMbjNni-.js +1 -0
  48. package/dist/public/assets/ShareReceiveDialog-DMLSpBoi.js +1 -0
  49. package/dist/public/assets/{ShareReceiveMissDialog-B03ClkaE.js → ShareReceiveMissDialog-TTjnDvC9.js} +1 -1
  50. package/dist/public/assets/{SkillEditBanner-C7z-32HN.js → SkillEditBanner-Dmsi4hSW.js} +1 -1
  51. package/dist/public/assets/{SkillOriginInline-DgWSnmXH.js → SkillOriginInline-BoGssBkU.js} +1 -1
  52. package/dist/public/assets/{SkillToolbarControls-PvRY_LHn.js → SkillToolbarControls-C8yypIJ3.js} +1 -1
  53. package/dist/public/assets/SlidesToolbarControls-CWIkYgNX.js +1 -0
  54. package/dist/public/assets/SourceEditor-D3dXest3.js +1 -0
  55. package/dist/public/assets/{TerminalPanel-Bl3bWVA_.js → TerminalPanel-D_OODFVz.js} +3 -3
  56. package/dist/public/assets/{TerminalWindowApp-CFxcrkfe.js → TerminalWindowApp-Dwoah4yb.js} +1 -1
  57. package/dist/public/assets/{TextDocEditor-CHDC5byq.js → TextDocEditor-DzdzVGmP.js} +1 -1
  58. package/dist/public/assets/ThreadView-DJxvdzfd.js +10 -0
  59. package/dist/public/assets/TimelineDiffPane-D5U46urB.js +2 -0
  60. package/dist/public/assets/{agent-diff-store-B7oQn7l7.js → agent-diff-store-DmpkFUx3.js} +1 -1
  61. package/dist/public/assets/arrow-up-right-CXYxHO7Z.js +1 -0
  62. package/dist/public/assets/auth-state-cache-Dm1J9vyz.js +11 -0
  63. package/dist/public/assets/{braces-Ytg60O62.js → braces-54VO1tdr.js} +1 -1
  64. package/dist/public/assets/{calendar-GynmFVw0.js → calendar-BhCmsdcp.js} +1 -1
  65. package/dist/public/assets/{case-sensitive-DvBZDISP.js → case-sensitive-BpYLDHFG.js} +1 -1
  66. package/dist/public/assets/check-DA6LolTH.js +1 -0
  67. package/dist/public/assets/{checkbox-V0IoPAe3.js → checkbox-gpfWb1pY.js} +1 -1
  68. package/dist/public/assets/{chevron-down-DrpHBSgH.js → chevron-down-Ccgt58N5.js} +1 -1
  69. package/dist/public/assets/chevron-left-DY9flfyc.js +1 -0
  70. package/dist/public/assets/chevron-right-2RK4DD3b.js +1 -0
  71. package/dist/public/assets/{chevron-up-CsH_dTwv.js → chevron-up-DXAtCwKR.js} +1 -1
  72. package/dist/public/assets/client-version-BbTOZkhQ.js +1 -0
  73. package/dist/public/assets/{cm-theme-BJSRL90r.js → cm-theme-DPWSzbOc.js} +1 -1
  74. package/dist/public/assets/comment-chips-CNh6cTT4.js +5 -0
  75. package/dist/public/assets/config-provider-CZ_6SNHv.js +5 -0
  76. package/dist/public/assets/{dialog-eak3pI7G.js → dialog-O4u6_xiQ.js} +1 -1
  77. package/dist/public/assets/{dist-DndwauQ3.js → dist-BpOfJRMm.js} +1 -1
  78. package/dist/public/assets/{dist-hwUYIgzz.js → dist-C1TyNsxp.js} +1 -1
  79. package/dist/public/assets/{dist-BCM06z1D.js → dist-CDMQmWZl.js} +1 -1
  80. package/dist/public/assets/{dist-BDJLSjo2.js → dist-CI5_cNui.js} +1 -1
  81. package/dist/public/assets/{dist-CkHhDuKZ.js → dist-CJuiZAB0.js} +1 -1
  82. package/dist/public/assets/{dist-DvtYFuZI.js → dist-CNm9tACe.js} +1 -1
  83. package/dist/public/assets/{dist-DJ3iQH0N.js → dist-CebtYbHb.js} +1 -1
  84. package/dist/public/assets/{dist--4AcVRue.js → dist-CpwfhxFl.js} +1 -1
  85. package/dist/public/assets/{dist-DNV7r8rH.js → dist-DU2smIGg.js} +1 -1
  86. package/dist/public/assets/{dist-PVtTd_Sj2.js → dist-TVrIGknK2.js} +111 -111
  87. package/dist/public/assets/{dist-Wj2cwRLU.js → dist-hrQOAqN1.js} +1 -1
  88. package/dist/public/assets/{dist-yYRRvtMr.js → dist-wfUjMP-v.js} +1 -1
  89. package/dist/public/assets/{dist-ClczuKkQ.js → dist-y6w4IT08.js} +1 -1
  90. package/dist/public/assets/doc-paths-BKAhPn1c.js +1 -0
  91. package/dist/public/assets/{documents-events-COSAPFkC.js → documents-events-B6nWdFan.js} +1 -1
  92. package/dist/public/assets/{download-Bq4sKAdj.js → download-BuEN0lZf.js} +1 -1
  93. package/dist/public/assets/{dropdown-menu-BhMtMvZp.js → dropdown-menu-CP1RnfZI.js} +1 -1
  94. package/dist/public/assets/{eye-DYUvwA0Z.js → eye-CYj_zi2W.js} +1 -1
  95. package/dist/public/assets/{field-DN11CYjs.js → field-BADrt9_J.js} +1 -1
  96. package/dist/public/assets/{file-tree-adapter-B9dmiTPy.js → file-tree-adapter-Dhf8gmFi.js} +1 -1
  97. package/dist/public/assets/{file-tree-utils-CvsKsHRh.js → file-tree-utils-Cx1c51Ql.js} +1 -1
  98. package/dist/public/assets/{folder-Cnftw7jd.js → folder-CWVPrRtx.js} +1 -1
  99. package/dist/public/assets/folder-config-api-CKhPo3Lt.js +1 -0
  100. package/dist/public/assets/{folder-open-DoQalFip.js → folder-open-BXfoqsrp.js} +1 -1
  101. package/dist/public/assets/{follow-file-BymUhAtT.js → follow-file-BRGwJuKy.js} +1 -1
  102. package/dist/public/assets/{git-branch-BWBPTGqT.js → git-branch-CMN6cdzm.js} +1 -1
  103. package/dist/public/assets/globals-CIRDbOmQ.css +1 -0
  104. package/dist/public/assets/{hash-BZXl_HqD.js → hash-BS4ux6bl.js} +1 -1
  105. package/dist/public/assets/history-CiIvI4I4.js +1 -0
  106. package/dist/public/assets/i18n-iRTrMKQI.js +1 -0
  107. package/dist/public/assets/index-Dask65mE.js +2097 -0
  108. package/dist/public/assets/{info-Jj1j2YxC.js → info-160SNOuG.js} +1 -1
  109. package/dist/public/assets/{input-group-H-ZoGiXT.js → input-group-CPKSxoq5.js} +1 -1
  110. package/dist/public/assets/{lint-config-client-DkwFMG_T.js → lint-config-client-KRlZx1_T.js} +1 -1
  111. package/dist/public/assets/{list-plus-IYEFhKGU.js → list-plus-BPvSuFZX.js} +1 -1
  112. package/dist/public/assets/loader-circle-BbuX0POi.js +1 -0
  113. package/dist/public/assets/{local-menu-action-bus-DLozq_c4.js → local-menu-action-bus-BDB0W02w.js} +1 -1
  114. package/dist/public/assets/markdownlint-rule-browser-BAnqBevm.js +1 -0
  115. package/dist/public/assets/{mcp-consent-store-B_Tog3LX.js → mcp-consent-store-yqsuAEir.js} +1 -1
  116. package/dist/public/assets/messages-52Q73NDn.js +1 -0
  117. package/dist/public/assets/messages-B-LUKCxb.js +1 -0
  118. package/dist/public/assets/messages-Bjt29O_q.js +1 -0
  119. package/dist/public/assets/messages-BzwBNPDu.js +1 -0
  120. package/dist/public/assets/messages-CGjveR2E.js +1 -0
  121. package/dist/public/assets/messages-CkanzrCR.js +1 -0
  122. package/dist/public/assets/messages-Cy75Ipbk.js +1 -0
  123. package/dist/public/assets/messages-D2UntltU.js +1 -0
  124. package/dist/public/assets/messages-D8H0FnV4.js +1 -0
  125. package/dist/public/assets/messages-Dl7JEKLk.js +1 -0
  126. package/dist/public/assets/messages-s-nrsPLp.js +1 -0
  127. package/dist/public/assets/minus-Ba4o_31L.js +1 -0
  128. package/dist/public/assets/{miss-dialog-store--ihxgGwV.js → miss-dialog-store-CdaZpyLg.js} +1 -1
  129. package/dist/public/assets/{navigation-targets-DKe7BSku.js → navigation-targets-BhdJAW-R.js} +1 -1
  130. package/dist/public/assets/open-managed-artifact-tab-CgUiYJiR.js +1 -0
  131. package/dist/public/assets/{panel-right-open-BhUOm1Eq.js → panel-right-open-_nL1w4h-.js} +1 -1
  132. package/dist/public/assets/{paperclip-9gdTBktj.js → paperclip-DV67TMJS.js} +1 -1
  133. package/dist/public/assets/pending-receive-nav-store-Crda7hlg.js +1 -0
  134. package/dist/public/assets/{project-paths-fLhDAPyF.js → project-paths-BWmSfpDI.js} +1 -1
  135. package/dist/public/assets/prop-types-CvU-2DkU.js +1 -0
  136. package/dist/public/assets/{receive-store-BvkW9HUo.js → receive-store--Bc0z-E4.js} +1 -1
  137. package/dist/public/assets/{refresh-cw-REpEMEB2.js → refresh-cw-Bjv-Fpq5.js} +1 -1
  138. package/dist/public/assets/{schema-fields-view-intent-DZFjFt0c.js → schema-fields-view-intent-BMlW8LRz.js} +1 -1
  139. package/dist/public/assets/{select-CRztynyQ.js → select-BaOsrrG7.js} +1 -1
  140. package/dist/public/assets/{selection-context-CSP8zK1H.js → selection-context-CsRnyGFj.js} +1 -1
  141. package/dist/public/assets/{separator-k0mwGcaM.js → separator-BXBsYPiB.js} +1 -1
  142. package/dist/public/assets/skill-actions-B7Cmxryy.js +2 -0
  143. package/dist/public/assets/{skill-scope-Dr7iwSW3.js → skill-scope-CwmLPgmT.js} +1 -1
  144. package/dist/public/assets/{skills-api-qDbnaMmu.js → skills-api-DDfyPLwg.js} +1 -1
  145. package/dist/public/assets/{square-pen-D3oI-YUs.js → square-pen-CW0s3lqC.js} +1 -1
  146. package/dist/public/assets/{src-VcUCSe0b.js → src-DfI4uz3u.js} +1 -1
  147. package/dist/public/assets/{tag-pill-input-pBac7WXR.js → tag-pill-input-DnM-Fz1E.js} +1 -1
  148. package/dist/public/assets/{target-navigation-intent-DAyeqt__.js → target-navigation-intent-D8zAsaUV.js} +1 -1
  149. package/dist/public/assets/{telemetry-impl-C9jF13xo.js → telemetry-impl-DFcgjFFc.js} +1 -1
  150. package/dist/public/assets/{telemetry-startup-1DamiHqT.js → telemetry-startup-0F_AW_hr.js} +1 -1
  151. package/dist/public/assets/terminal-BNdVsbND.js +1 -0
  152. package/dist/public/assets/terminal-cli-display-Djf7X5gE.js +1 -0
  153. package/dist/public/assets/terminal-launch-events-B76nHQ-9.js +1 -0
  154. package/dist/public/assets/terminal-telemetry-CynEAJPS.js +1 -0
  155. package/dist/public/assets/{text-viewer-languages-BTzKrM_y.js → text-viewer-languages-BBrkAtBf.js} +2 -2
  156. package/dist/public/assets/thread-client-CER-baRK.js +1 -0
  157. package/dist/public/assets/{trash-2-BSr7FcE8.js → trash-2-rgduGgZB.js} +1 -1
  158. package/dist/public/assets/{triangle-alert-DNTyNeem.js → triangle-alert-CnW4IElJ.js} +1 -1
  159. package/dist/public/assets/{typing-burst-detector-BOmjXV-P.js → typing-burst-detector-DzIKrNKg.js} +4 -4
  160. package/dist/public/assets/{undo-2-u9f9OoCF.js → undo-2-BmxrL5XS.js} +1 -1
  161. package/dist/public/assets/{uninstall-36twrq5C.js → uninstall-DT91VYMe.js} +1 -1
  162. package/dist/public/assets/{use-activity-panel-BwANCYjg.js → use-activity-panel-CbIsW8Oq.js} +1 -1
  163. package/dist/public/assets/use-apply-config-color-theme-Cd_bVm8F.js +1 -0
  164. package/dist/public/assets/{use-collab-url-TKpnPAW8.js → use-collab-url-DESxkkaS.js} +1 -1
  165. package/dist/public/assets/use-live-xterm-theme-D9HFWiME.js +1 -0
  166. package/dist/public/assets/use-open-skill-DyTRfvTr.js +1 -0
  167. package/dist/public/assets/use-settings-route-BXWhuQbZ.js +1 -0
  168. package/dist/public/assets/{use-skill-directory-D9S5f8By.js → use-skill-directory-BaP9hj7C.js} +1 -1
  169. package/dist/public/assets/use-skill-origin-DBXnPKZS.js +1 -0
  170. package/dist/public/assets/{use-skills-D5kEHDif.js → use-skills-CVci-eTA.js} +1 -1
  171. package/dist/public/assets/use-terminal-enabled-DDthawVX.js +1 -0
  172. package/dist/public/assets/{use-timeline-entry-diff-CB_cI1yy.js → use-timeline-entry-diff-BC2rFPLm.js} +2 -2
  173. package/dist/public/assets/{use-workspace--QTATo27.js → use-workspace-CAcWHNxj.js} +1 -1
  174. package/dist/public/assets/{wrench-BPXVnAE5.js → wrench-DtGaC8XY.js} +1 -1
  175. package/dist/public/assets/x-D8xzRaMT.js +1 -0
  176. package/dist/public/index.html +122 -122
  177. package/dist/public/uninstall.html +14 -14
  178. package/dist/{repair-launch-json-DwJ_yLw4.mjs → repair-launch-json-V-un1HwF.mjs} +2 -2
  179. package/dist/{repair-mcp-configs-Q1hO02co.mjs → repair-mcp-configs-CgS2qBwI.mjs} +2 -2
  180. package/dist/repair-skills-KPpoS1oT.mjs +1 -0
  181. package/dist/{repair-skills-DADI6iaT.mjs → repair-skills-cQdbD3lz.mjs} +2 -2
  182. package/dist/server-lock-CMPaDe7b.mjs +1 -0
  183. package/dist/server-lock-CVlhIOaP.mjs +2 -0
  184. package/dist/{skill-teardown-onVYT1VF.mjs → skill-teardown-BVQqx1VE.mjs} +2 -2
  185. package/dist/src-C1NIOm2S.mjs +1 -0
  186. package/dist/{src-TKCctdpc.mjs → src-Cb3i1kcm.mjs} +5 -5
  187. package/dist/src-Dn98dNdR.mjs +1 -0
  188. package/dist/src-Mfncsy21.mjs +20 -0
  189. package/dist/src-q9JjDIHN.mjs +2032 -0
  190. package/dist/{start-DRG6a2sz.mjs → start-BSLZXd-A.mjs} +3 -3
  191. package/dist/start-CJ3wdpkC.mjs +1 -0
  192. package/dist/{write-project-skill-DOogyZge.mjs → write-project-skill-DPVCl9Kv.mjs} +2 -2
  193. package/package.json +5 -5
  194. package/dist/constants-BkYBCRUx.mjs +0 -2
  195. package/dist/git-handle-DBSzQutT.mjs +0 -1
  196. package/dist/init-BlCMJ0yB.mjs +0 -1
  197. package/dist/loader-Birwg2h1.mjs +0 -1
  198. package/dist/md-manager-BbSzMHHE.mjs +0 -2
  199. package/dist/preview-gKyXf1a0.mjs +0 -1
  200. package/dist/public/assets/ActivityModeContent-C08FYohG.js +0 -1
  201. package/dist/public/assets/ChangedOutsideBadge-GeQfL_b-.js +0 -1
  202. package/dist/public/assets/ConsentDialogBody-Clb82Qbo.js +0 -2
  203. package/dist/public/assets/DocumentContext-C-Lo65-_.js +0 -38
  204. package/dist/public/assets/EditorModeToggle-BjgmECAn.js +0 -1
  205. package/dist/public/assets/EnableSyncConfirmDialog-B1Eo_sVE.js +0 -1
  206. package/dist/public/assets/FeedbackForm-C_A-lpjC.js +0 -1
  207. package/dist/public/assets/GraphPanel-CxJeFUDp.js +0 -44
  208. package/dist/public/assets/ImportSkillDialog-ChsGV6eb.js +0 -1
  209. package/dist/public/assets/ManagedArtifactProperties-B1ZA0ofn.js +0 -2
  210. package/dist/public/assets/ManagedArtifactProperties-B_ecuboX.js +0 -1
  211. package/dist/public/assets/McpConsentDialogBody-CG5af4os.js +0 -1
  212. package/dist/public/assets/SchemaConfigEditor-DPK5XbMd.js +0 -1
  213. package/dist/public/assets/SessionsHost-BRUQMi7f.js +0 -2
  214. package/dist/public/assets/SettingsDialogBody-COTbFRqi.js +0 -12
  215. package/dist/public/assets/ShareBranchSwitchDialog-C0mAHHVQ.js +0 -1
  216. package/dist/public/assets/ShareReceiveDialog-Coi9tYAP.js +0 -1
  217. package/dist/public/assets/SlidesToolbarControls-8TzXHMwI.js +0 -1
  218. package/dist/public/assets/SourceEditor-Duqpede9.js +0 -1
  219. package/dist/public/assets/ThreadView-CAGruMiN.js +0 -10
  220. package/dist/public/assets/TimelineDiffPane-DnaRcvCk.js +0 -2
  221. package/dist/public/assets/agent-visibility-CHYjRInm.js +0 -1
  222. package/dist/public/assets/arrow-up-right-0IN5lFEX.js +0 -1
  223. package/dist/public/assets/auth-state-cache-BUYyIMUZ.js +0 -11
  224. package/dist/public/assets/check-BLuQ2zvV.js +0 -1
  225. package/dist/public/assets/chevron-left-BUr-yKA4.js +0 -1
  226. package/dist/public/assets/chevron-right-BU8AeJST.js +0 -1
  227. package/dist/public/assets/client-version-DfXcf1Qf.js +0 -1
  228. package/dist/public/assets/comment-chips-BhvfCPCk.js +0 -5
  229. package/dist/public/assets/config-context-DNY4at5d.js +0 -1
  230. package/dist/public/assets/config-provider-B7dMDFNr.js +0 -5
  231. package/dist/public/assets/doc-paths-CH8QyanF.js +0 -1
  232. package/dist/public/assets/folder-config-api-IGZhtkRo.js +0 -1
  233. package/dist/public/assets/globals-D9Q1kf3c.css +0 -1
  234. package/dist/public/assets/history-BNEST2Cx.js +0 -1
  235. package/dist/public/assets/i18n-CIRn0AvV.js +0 -1
  236. package/dist/public/assets/index-B-snLDY1.js +0 -2097
  237. package/dist/public/assets/loader-circle-Coob8S41.js +0 -1
  238. package/dist/public/assets/markdownlint-rule-browser-DY5CRVFm.js +0 -1
  239. package/dist/public/assets/messages-6Fd7I7zn.js +0 -1
  240. package/dist/public/assets/messages-BJIB1I1L.js +0 -1
  241. package/dist/public/assets/messages-BOXmrfhw.js +0 -1
  242. package/dist/public/assets/messages-BeOM8jWl.js +0 -1
  243. package/dist/public/assets/messages-CCWKIebo.js +0 -1
  244. package/dist/public/assets/messages-CQFityfC.js +0 -1
  245. package/dist/public/assets/messages-CzRXVtjz.js +0 -1
  246. package/dist/public/assets/messages-DYiuNk7y.js +0 -1
  247. package/dist/public/assets/messages-Db5U-G1d.js +0 -1
  248. package/dist/public/assets/messages-DohtKbKM.js +0 -1
  249. package/dist/public/assets/messages-WWFblTuV.js +0 -1
  250. package/dist/public/assets/minus-DPAjfzCa.js +0 -1
  251. package/dist/public/assets/open-managed-artifact-tab-DGO7syz6.js +0 -1
  252. package/dist/public/assets/pending-receive-nav-store-SZ8w-xKW.js +0 -1
  253. package/dist/public/assets/prop-types-DoONHMUn.js +0 -1
  254. package/dist/public/assets/skill-actions-98H3SnCL.js +0 -2
  255. package/dist/public/assets/terminal-launch-events-CIULxHeu.js +0 -1
  256. package/dist/public/assets/terminal-mGTI25Qq.js +0 -1
  257. package/dist/public/assets/terminal-telemetry-CqkILJJU.js +0 -1
  258. package/dist/public/assets/thread-client-DSDduEdo.js +0 -1
  259. package/dist/public/assets/use-live-xterm-theme-B8OPZLR3.js +0 -1
  260. package/dist/public/assets/use-open-skill-DCSEJ3jJ.js +0 -1
  261. package/dist/public/assets/use-settings-route-CKMxexs3.js +0 -1
  262. package/dist/public/assets/use-skill-origin-8_nwflm6.js +0 -1
  263. package/dist/public/assets/use-terminal-enabled-Ctosnrg_.js +0 -1
  264. package/dist/public/assets/x-COTyTduF.js +0 -1
  265. package/dist/repair-skills-DKwDAoHc.mjs +0 -1
  266. package/dist/server-lock-U8YDpJpq.mjs +0 -1
  267. package/dist/server-lock-aXnDVUI8.mjs +0 -2
  268. package/dist/src-BgeIHNkQ.mjs +0 -1
  269. package/dist/src-DNPRz0-U.mjs +0 -20
  270. package/dist/src-Dt5dAyFQ.mjs +0 -2032
  271. package/dist/src-cRpQSbXB.mjs +0 -1
  272. package/dist/start-CWIlNpAT.mjs +0 -1
  273. /package/dist/public/assets/{asset-dispatch-Dst62kKY.js → asset-dispatch-_dEhJuVP.js} +0 -0
  274. /package/dist/public/assets/{auth-prompt-store-B92v76dM.js → auth-prompt-store-CeaWNesV.js} +0 -0
  275. /package/dist/public/assets/{badge-B89o8Vy9.js → badge-CY_v_nGy.js} +0 -0
  276. /package/dist/public/assets/{copilot-qpaFt06v.js → copilot-D0J83lOh.js} +0 -0
  277. /package/dist/public/assets/{createLucideIcon-BbftclCc.js → createLucideIcon-BcLKHslE.js} +0 -0
  278. /package/dist/public/assets/{cursor-Df-vt--2.js → cursor-B6-YoFzF.js} +0 -0
  279. /package/dist/public/assets/{desktop-bridge-types-BjBBs_pU.js → desktop-bridge-types-rBjHIYSI.js} +0 -0
  280. /package/dist/public/assets/{dist-BlH6jxEE.js → dist-BTu6o3T-.js} +0 -0
  281. /package/dist/public/assets/{dist-CEwo98ia.js → dist-Bkx5dDHT2.js} +0 -0
  282. /package/dist/public/assets/{dist-C7IFraT6.js → dist-DoS8xGN6.js} +0 -0
  283. /package/dist/public/assets/{documents-fetch-BTUkzxjd.js → documents-fetch-B8A9IAH3.js} +0 -0
  284. /package/dist/public/assets/{external-link-BkNoUOYg.js → external-link-Bw5EK5AQ.js} +0 -0
  285. /package/dist/public/assets/{file-tree-rename-validation-CEz8MVWM.js → file-tree-rename-validation-Dt6fQYnB.js} +0 -0
  286. /package/dist/public/assets/{globals-C-kRTFCu.js → globals-C9aYStL7.js} +0 -0
  287. /package/dist/public/assets/{input-BKUcczSW.js → input-_CzMpvY9.js} +0 -0
  288. /package/dist/public/assets/{overlay-layers-BqWhClsR.js → overlay-layers-C1Y78Wu8.js} +0 -0
  289. /package/dist/public/assets/{panel-CbGx_cRv.js → panel-DVJ8gssn.js} +0 -0
  290. /package/dist/public/assets/{parse-api-error-Cyn4P6OR.js → parse-api-error-Mgtc4OJu.js} +0 -0
  291. /package/dist/public/assets/{startup-marks-BzFN1cqP.js → startup-marks-BPO-vrjH.js} +0 -0
  292. /package/dist/public/assets/{stex-CyLY7DTo.js → stex-Cj2UNqUe.js} +0 -0
  293. /package/dist/public/assets/{workspace-paths-EgbOaHls.js → workspace-paths-D7hYulMY.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{R as e}from"./src-TKCctdpc.mjs";import{ar as t,br as n,dr as r,gr as i,lr as a,mr as o,or as s,ur as c,xr as l}from"./src-Dt5dAyFQ.mjs";import{o as u,s as d,t as f,v as p}from"./write-project-skill-DOogyZge.mjs";import{n as m,s as h,t as g}from"./colors-BsmVIwfM.mjs";import{n as _,r as v,t as y}from"./skill-teardown-onVYT1VF.mjs";import{dirname as b,join as x,relative as S,resolve as C}from"node:path";import{existsSync as w,mkdirSync as T,readFileSync as E,readdirSync as D,rmSync as O,statSync as k,writeFileSync as A}from"node:fs";import{homedir as j}from"node:os";import{createInterface as M}from"node:readline/promises";const N={existsSync:e=>w(e),isDirectory:e=>{try{return k(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>D(e),readFileSync:e=>E(e),writeFileSync:(e,t)=>{A(e,t)},mkdirSync:(e,t)=>{T(e,t)},rmSync:(e,t)=>{O(e,t)}},P={resolveProjectBundledSkillDir:()=>i(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>i(e,{checkDesktop:!1}),readBundledVersion:()=>s(),readRecordedVersion:e=>a(e,`cli-hosts`),writeRecordedVersion:(e,t)=>r(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>o(e),readBundleDecision:(e,n)=>t(e,n),writeBundleDecision:(e,t,n)=>c(e,t,n),removeBundleFromDisk:(e,t)=>v(e,t)};function F(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function I(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(b(t),{recursive:!0}),L(e,t,n)}function L(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=x(e,r),a=x(t,r);n.isDirectory(i)?L(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function R(e,t,n,r,i,a){let o=[],s=x(e,`.agents`,`skills`,t),c=!1;if(r.existsSync(s))o.push({kind:`central`,path:s,outcome:`skipped-present`});else try{I(n,s,r),c=!0,o.push({kind:`central`,path:s,outcome:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let c of d){let l=x(e,c.hostDir),u=x(l,`skills`,t);if(u===s){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(l)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-host-absent`});continue}if(r.existsSync(u)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-present`});continue}try{I(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,error:t})}}return{entries:o,centralWritten:c}}function z(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function B(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of d){let o=x(e,t.hostDir,`skills`,`open-knowledge`),s=x(o,`SKILL.md`);if(n.existsSync(s)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`present`});continue}let c=u[t.editorId]?.projectConfigPath?.(e);if(!z(c,n)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{f(o,e),I(i,o,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`created`}),r({event:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function V(t,r,i,a){let o=e=>{r.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),c;try{c=await r.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return a({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await r.readRecordedVersion(t)}catch(e){a({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),u=null}let d=[],f=null;for(let e of l)try{d.push({id:e,sourceDir:r.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return a({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let o of d){let s=n[o.id],c=i.existsSync(x(t,`.agents`,`skills`,s)),l=await r.readBundleDecision(t,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{r.removeBundleFromDisk(t,o.id),a({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:o.id})}catch(e){a({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await r.writeBundleDecision(t,s,!0)}catch(e){a({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}p.push(o)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>i.existsSync(x(t,`.agents`,`skills`,n[e.id])));if(u!==null&&u===c&&m)return a({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:c}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===l.length,_=[];for(let{id:e,sourceDir:r}of p){let o=R(t,n[e],r,i,a,c);h.push(...o.entries),_.push({id:e,centralWritten:o.centralWritten})}let v=h.some(e=>e.kind===`central`&&e.outcome===`failed`);if(g&&!v){let e=null;try{await r.writeRecordedVersion(t,c),a({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:c})}catch(t){e=t instanceof Error?t.message:String(t),a({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:c,error:e})}for(let{id:t,centralWritten:n}of _)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?n?`installed`:`skip-current`:`failed`,version:c,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{let e=h.some(e=>e.kind===`host`&&e.outcome===`failed`);o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:c,reason:g?e?`all-writes-failed`:`central-write-failed`:`bundle-unresolved`})}return{outcome:`done`,version:c,entries:h}}async function H(e){let t=e.logger??F,n=e.fs??N,r=e.home??j(),i={...P,...e.deps};if(e.reclaimDisableEnv===`1`)return t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`};let a=B(e.projectDir,i,n,t),o=await V(r,i,n,t),s=_(r),c=[],l=!1,u=!1;if(s.skillDirs.length>0||s.emptyDirs.length>0)if(e.confirmLegacyCleanup&&await e.confirmLegacyCleanup(s)){try{c=y(r,s)}catch(e){u=!0,t({event:`legacy-fanout-cleanup-refused`,scope:`user`,error:e instanceof Error?e.message:String(e)})}for(let e of c)t({event:`legacy-fanout-path-removed`,scope:`user`,path:e})}else l=!0,t({event:`legacy-fanout-cleanup-declined`,scope:`user`});return{status:`done`,project:a,user:o,legacySwept:c,legacyCleanupDeclined:l,legacyCleanupFailed:u}}function U(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function W(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`present`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} present, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-present`).length,i=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,a=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} present, ${i} skipped, ${a} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return e.legacySwept.length>0?t.push(` Cleanup: removed ${e.legacySwept.length} path(s) from a pre-0.42 install.`):e.legacyCleanupFailed?t.push(` Cleanup: failed — see logs; pre-0.42 directories left in place.`):e.legacyCleanupDeclined&&t.push(` Cleanup: declined — pre-0.42 directories left in place.`),t.join(`
1
+ import{R as e}from"./src-Cb3i1kcm.mjs";import{ar as t,br as n,dr as r,gr as i,lr as a,mr as o,or as s,ur as c,xr as l}from"./src-q9JjDIHN.mjs";import{o as u,s as d,t as f,v as p}from"./write-project-skill-DPVCl9Kv.mjs";import{n as m,s as h,t as g}from"./colors-BsmVIwfM.mjs";import{n as _,r as v,t as y}from"./skill-teardown-BVQqx1VE.mjs";import{dirname as b,join as x,relative as S,resolve as C}from"node:path";import{existsSync as w,mkdirSync as T,readFileSync as E,readdirSync as D,rmSync as O,statSync as k,writeFileSync as A}from"node:fs";import{homedir as j}from"node:os";import{createInterface as M}from"node:readline/promises";const N={existsSync:e=>w(e),isDirectory:e=>{try{return k(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>D(e),readFileSync:e=>E(e),writeFileSync:(e,t)=>{A(e,t)},mkdirSync:(e,t)=>{T(e,t)},rmSync:(e,t)=>{O(e,t)}},P={resolveProjectBundledSkillDir:()=>i(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>i(e,{checkDesktop:!1}),readBundledVersion:()=>s(),readRecordedVersion:e=>a(e,`cli-hosts`),writeRecordedVersion:(e,t)=>r(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>o(e),readBundleDecision:(e,n)=>t(e,n),writeBundleDecision:(e,t,n)=>c(e,t,n),removeBundleFromDisk:(e,t)=>v(e,t)};function F(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function I(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(b(t),{recursive:!0}),L(e,t,n)}function L(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=x(e,r),a=x(t,r);n.isDirectory(i)?L(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function R(e,t,n,r,i,a){let o=[],s=x(e,`.agents`,`skills`,t),c=!1;if(r.existsSync(s))o.push({kind:`central`,path:s,outcome:`skipped-present`});else try{I(n,s,r),c=!0,o.push({kind:`central`,path:s,outcome:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let c of d){let l=x(e,c.hostDir),u=x(l,`skills`,t);if(u===s){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(l)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-host-absent`});continue}if(r.existsSync(u)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-present`});continue}try{I(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:!1,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,error:t})}}return{entries:o,centralWritten:c}}function z(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function B(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of d){let o=x(e,t.hostDir,`skills`,`open-knowledge`),s=x(o,`SKILL.md`);if(n.existsSync(s)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`present`});continue}let c=u[t.editorId]?.projectConfigPath?.(e);if(!z(c,n)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{f(o,e),I(i,o,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`created`}),r({event:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function V(t,r,i,a){let o=e=>{r.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),c;try{c=await r.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return a({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await r.readRecordedVersion(t)}catch(e){a({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),u=null}let d=[],f=null;for(let e of l)try{d.push({id:e,sourceDir:r.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return a({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let o of d){let s=n[o.id],c=i.existsSync(x(t,`.agents`,`skills`,s)),l=await r.readBundleDecision(t,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{r.removeBundleFromDisk(t,o.id),a({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:o.id})}catch(e){a({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await r.writeBundleDecision(t,s,!0)}catch(e){a({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}p.push(o)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>i.existsSync(x(t,`.agents`,`skills`,n[e.id])));if(u!==null&&u===c&&m)return a({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:c}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===l.length,_=[];for(let{id:e,sourceDir:r}of p){let o=R(t,n[e],r,i,a,c);h.push(...o.entries),_.push({id:e,centralWritten:o.centralWritten})}let v=h.some(e=>e.kind===`central`&&e.outcome===`failed`);if(g&&!v){let e=null;try{await r.writeRecordedVersion(t,c),a({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:c})}catch(t){e=t instanceof Error?t.message:String(t),a({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:c,error:e})}for(let{id:t,centralWritten:n}of _)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?n?`installed`:`skip-current`:`failed`,version:c,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{let e=h.some(e=>e.kind===`host`&&e.outcome===`failed`);o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:c,reason:g?e?`all-writes-failed`:`central-write-failed`:`bundle-unresolved`})}return{outcome:`done`,version:c,entries:h}}async function H(e){let t=e.logger??F,n=e.fs??N,r=e.home??j(),i={...P,...e.deps};if(e.reclaimDisableEnv===`1`)return t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`};let a=B(e.projectDir,i,n,t),o=await V(r,i,n,t),s=_(r),c=[],l=!1,u=!1;if(s.skillDirs.length>0||s.emptyDirs.length>0)if(e.confirmLegacyCleanup&&await e.confirmLegacyCleanup(s)){try{c=y(r,s)}catch(e){u=!0,t({event:`legacy-fanout-cleanup-refused`,scope:`user`,error:e instanceof Error?e.message:String(e)})}for(let e of c)t({event:`legacy-fanout-path-removed`,scope:`user`,path:e})}else l=!0,t({event:`legacy-fanout-cleanup-declined`,scope:`user`});return{status:`done`,project:a,user:o,legacySwept:c,legacyCleanupDeclined:l,legacyCleanupFailed:u}}function U(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function W(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`present`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} present, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-present`).length,i=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,a=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} present, ${i} skipped, ${a} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return e.legacySwept.length>0?t.push(` Cleanup: removed ${e.legacySwept.length} path(s) from a pre-0.42 install.`):e.legacyCleanupFailed?t.push(` Cleanup: failed — see logs; pre-0.42 directories left in place.`):e.legacyCleanupDeclined&&t.push(` Cleanup: declined — pre-0.42 directories left in place.`),t.join(`
2
2
  `)}function G(){return new p(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").option(`-y, --yes`,`Skip the confirmation prompt for removing directories left by a pre-0.42 install.`).action(async e=>{let t=await H({projectDir:C(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null,confirmLegacyCleanup:t=>K(t,{yes:e.yes===!0})});process.stdout.write(`${W(t)}\n`),process.exitCode=U(t)})}async function K(e,t){let n=j(),r=e=>`~/${S(n,e)}`,i=t.input??process.stdin,a=[``,g(`A previous version of OpenKnowledge installed its skill into agent tools you may never have used.`),m(`(Versions before 0.42 wrote to every host a third-party installer knew about — see issue #820.)`)];if(e.skillDirs.length>0&&a.push(``,`${g(`Remove OpenKnowledge skills:`)} ${e.skillDirs.length}`,...e.skillDirs.map(e=>` ${r(e)}`)),e.emptyDirs.length>0){let t=e.skillDirs.length>0?`Then remove these, which hold nothing else once the above are gone:`:`Remove these empty directories, left behind by that install:`;a.push(``,`${g(t)} ${e.emptyDirs.length}`,...e.emptyDirs.map(e=>` ${r(e)}`))}if(a.push(``,m(`Nothing outside these paths is touched. A directory that still holds anything is kept.`)),process.stdout.write(`${a.join(`
3
3
  `)}\n`),t.yes)return!0;if(!i.isTTY)return process.stdout.write(`${h("Not a terminal — skipping cleanup. Re-run with `ok repair-skills --yes` to remove these.")}\n`),!1;let o=M({input:i,output:process.stdout});try{let e=(await o.question(`\n${g(`Remove them?`)} ${m(`[y/N] `)}`)).trim().toLowerCase();return e===`y`||e===`yes`}finally{o.close()}}export{G as n,H as t};
4
- //# sourceMappingURL=repair-skills-DADI6iaT.mjs.map
4
+ //# sourceMappingURL=repair-skills-cQdbD3lz.mjs.map
@@ -0,0 +1 @@
1
+ import{a as e,o as t,r as n}from"./server-lock-CVlhIOaP.mjs";export{n as markServerLockDraining,e as releaseServerLock,t as updateServerLockPort};
@@ -0,0 +1,2 @@
1
+ import"./src-Cb3i1kcm.mjs";import{r as e}from"./logger-DFxEUjvj.mjs";import{dirname as t,join as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d,writeSync as f}from"node:fs";import{homedir as p,hostname as m}from"node:os";import{randomUUID as h}from"node:crypto";function g(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function _(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function v(e){return new URL(e.url??``,`http://localhost`).searchParams}function y(e){let t=e?.code;return typeof t==`string`?t:void 0}const b=/^[A-Za-z0-9-]{8,64}$/;let x=null;function S(e){return n(e??p(),`.ok`,`machine-id`)}function C(n){if(n===void 0&&x!==null)return x;let r=S(n),i=null;try{let e=l(r,`utf-8`).trim();b.test(e)&&(i=e)}catch{}if(i===null){i=h();try{s(t(r),{recursive:!0}),d(r,`${i}\n`,{encoding:`utf-8`,mode:384})}catch(t){e(`machine-id`).warn({path:r,err:t},`Failed to persist ${r} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${t instanceof Error?t.message:String(t)}`)}}return n===void 0&&(x=i),i}function w(){try{let e=r(t(i(import.meta.url)),`..`,`package.json`),n=JSON.parse(l(e,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}const T=w(),E=1,D=e(`process-lock`);var O=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running at ${e.url??`port ${e.port}`} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function k(e,t){return r(e,`${t}.lock`)}const A=new Map;function j(e){A.set(e,(A.get(e)??0)+1)}function M(e){let t=A.get(e);return t===void 0||t<=1?(A.delete(e),!0):(A.set(e,t-1),!1)}function N(e){return typeof e.machineId==`string`?e.machineId===C():e.hostname===m()}const P=new Set;let F=!1;function I(e){P.add(e),!F&&(F=!0,process.on(`exit`,()=>{for(let e of P)try{let t=JSON.parse(l(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==C()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==m())continue;u(e)}catch{}}))}function L(e,t){try{let n=JSON.parse(l(e,`utf-8`));return n&&typeof n==`object`&&_(n.pid)?n:(D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null}}function R(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;s(n,{recursive:!0});let l=k(n,t),p={pid:process.pid,hostname:m(),port:r.port,...r.url!==void 0&&{url:r.url},startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:C(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??T},h=JSON.stringify(p,null,2);for(let e=0;e<3;e++){if(!o(l))try{let e=c(l,`wx`,384);try{f(e,h)}finally{a(e)}return j(l),I(l),z({lockName:t,lockDir:n,lockPath:l})}catch(e){if(y(e)!==`EEXIST`)throw e}let e=L(l,i);if(e){if(N(e)&&e.pid===process.pid)return d(l,h,{encoding:`utf-8`,mode:384}),j(l),I(l),z({lockName:t,lockDir:n,lockPath:l});if(g(e.pid))throw new O(e,l,t);D.warn({pid:e.pid,host:e.hostname},`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{u(l)}catch{}}throw Error(`${i} Failed to acquire ${l} after 3 attempts (concurrent acquire contention).`)}function z(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>q({lockName:t,lockDir:n}),updatePort:(e,r)=>H({lockName:t,lockDir:n,port:e,url:r})}}function B(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function V(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=B(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}function H(e){let{lockName:t,lockDir:n,port:r,url:i}=e,a=`[${t}-lock]`,s=k(n,t);if(!o(s)){D.warn({lockPath:s},`${a} Lock file missing at ${s} during port update — skipping`);return}let c;try{let e=JSON.parse(l(s,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:s},`${a} Corrupt lock at ${s} during port update — skipping`);return}c=e}catch{D.warn({lockPath:s},`${a} Unreadable lock at ${s} during port update — skipping`);return}if(c.pid===process.pid&&N(c)){c.port=r,i===void 0?delete c.url:c.url=i;try{d(s,JSON.stringify(c,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:s,err:e},`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function U(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k(n,t);if((A.get(i)??0)>1)return;let a;try{let e=JSON.parse(l(i,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:i},`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){y(e)!==`ENOENT`&&D.warn({lockPath:i,err:e},`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N(a)&&a.draining!==!0){a.draining=!0;try{d(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:i,err:e},`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function W(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return null;let i;try{let e=JSON.parse(l(r,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid))return null;i=e}catch{return null}if(!N(i))return null;if(!g(i.pid)){try{u(r)}catch{}return null}return i}function G(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return{status:`absent`};let i;try{i=JSON.parse(l(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!_(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let s={pid:a.pid,hostname:a.hostname,port:a.port,url:typeof a.url==`string`?a.url:void 0,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,capabilities:Array.isArray(a.capabilities)&&a.capabilities.every(e=>typeof e==`string`)?a.capabilities:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N(s))return{status:`stale`,lock:s};if(!g(s.pid)){try{u(r)}catch{}return{status:`stale`,lock:s}}return s.protocolVersion===void 0||s.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:s}}async function K(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>W({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function q(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){U({lockName:t,lockDir:n});return}if(o(a))try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N(e))return;u(a),P.delete(a)}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var J=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function Y(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new J(e.existing,e.lockPath):e}}function X(e,t,n){H({lockName:`server`,lockDir:e,port:t,url:n})}function Z(e){return W({lockName:`server`,lockDir:e})}function Q(e,t){q({lockName:`server`,lockDir:e,...t})}function $(e){U({lockName:`server`,lockDir:e})}function ee(e,t){return K({lockName:`server`,lockDir:e,...t})}export{_ as C,g as S,T as _,Q as a,y as b,O as c,k as d,U as f,H as g,q as h,Z as i,R as l,G as m,Y as n,X as o,W as p,$ as r,ee as s,J as t,V as u,E as v,v as x,C as y};
2
+ //# sourceMappingURL=server-lock-CVlhIOaP.mjs.map
@@ -1,2 +1,2 @@
1
- import{br as e,xr as t}from"./src-Dt5dAyFQ.mjs";import{s as n}from"./write-project-skill-DOogyZge.mjs";import{dirname as r,isAbsolute as i,join as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,lstatSync as u,readdirSync as d,rmSync as f,rmdirSync as p}from"node:fs";const m=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],h=[...t.map(t=>e[t]),`open-knowledge`];function g(e){if(!i(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=s(e);if(t===c||r(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function _(e,t){let n=o(e,t);if(n.startsWith(`..`)||i(n))return!1;let r=e;for(let e of n.split(c)){r=a(r,e);try{if(!u(r).isDirectory())return!1}catch{return!1}}return!0}function v(e,t){try{return d(e).every(n=>t.has(a(e,n)))}catch{return!1}}function y(e){let t=g(e),n=[],i=[],o=new Set;for(let e of m){let s=a(t,e.hostDir,`skills`);if(!_(t,s))continue;let u=h.map(e=>a(s,e)).filter(e=>l(e));n.push(...u);for(let e of u)o.add(e);let d=a(t,e.pruneRoot),f=s;for(;v(f,o)&&(i.push(f),o.add(f),f!==d);){let e=r(f);if(e===f||e===t||!e.startsWith(t+c))break;f=e}}return{skillDirs:n,emptyDirs:i}}function b(e){try{if(!u(e).isDirectory())return!1;let t=d(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function x(e){let t=new Set,n=new Set;for(let i of m){let o=a(e,i.hostDir,`skills`);for(let e of h)t.add(a(o,e));let s=a(e,i.pruneRoot),l=o;for(;n.add(l),l!==s;){let t=r(l);if(t===l||t===e||!t.startsWith(e+c))break;l=t}}return{skillDirs:t,emptyDirs:n}}function S(e,t){let n=g(e),r=x(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(_(n,e)&&b(e))try{f(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(_(n,e))try{p(e),a.push(e)}catch{}return a}function C(r){let i=g(r),o=[];for(let r of t){let t=e[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let e of n)o.push({path:a(i,e.hostDir,`skills`,t),bundleId:r,scope:`host`,hostDir:e.hostDir})}return o}function w(e,t){let n=[];for(let r of C(e))if(r.bundleId===t)try{f(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}`)}export{C as i,y as n,w as r,S as t};
2
- //# sourceMappingURL=skill-teardown-onVYT1VF.mjs.map
1
+ import{br as e,xr as t}from"./src-q9JjDIHN.mjs";import{s as n}from"./write-project-skill-DPVCl9Kv.mjs";import{dirname as r,isAbsolute as i,join as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,lstatSync as u,readdirSync as d,rmSync as f,rmdirSync as p}from"node:fs";const m=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],h=[...t.map(t=>e[t]),`open-knowledge`];function g(e){if(!i(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=s(e);if(t===c||r(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function _(e,t){let n=o(e,t);if(n.startsWith(`..`)||i(n))return!1;let r=e;for(let e of n.split(c)){r=a(r,e);try{if(!u(r).isDirectory())return!1}catch{return!1}}return!0}function v(e,t){try{return d(e).every(n=>t.has(a(e,n)))}catch{return!1}}function y(e){let t=g(e),n=[],i=[],o=new Set;for(let e of m){let s=a(t,e.hostDir,`skills`);if(!_(t,s))continue;let u=h.map(e=>a(s,e)).filter(e=>l(e));n.push(...u);for(let e of u)o.add(e);let d=a(t,e.pruneRoot),f=s;for(;v(f,o)&&(i.push(f),o.add(f),f!==d);){let e=r(f);if(e===f||e===t||!e.startsWith(t+c))break;f=e}}return{skillDirs:n,emptyDirs:i}}function b(e){try{if(!u(e).isDirectory())return!1;let t=d(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function x(e){let t=new Set,n=new Set;for(let i of m){let o=a(e,i.hostDir,`skills`);for(let e of h)t.add(a(o,e));let s=a(e,i.pruneRoot),l=o;for(;n.add(l),l!==s;){let t=r(l);if(t===l||t===e||!t.startsWith(e+c))break;l=t}}return{skillDirs:t,emptyDirs:n}}function S(e,t){let n=g(e),r=x(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(_(n,e)&&b(e))try{f(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(_(n,e))try{p(e),a.push(e)}catch{}return a}function C(r){let i=g(r),o=[];for(let r of t){let t=e[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let e of n)o.push({path:a(i,e.hostDir,`skills`,t),bundleId:r,scope:`host`,hostDir:e.hostDir})}return o}function w(e,t){let n=[];for(let r of C(e))if(r.bundleId===t)try{f(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}`)}export{C as i,y as n,w as r,S as t};
2
+ //# sourceMappingURL=skill-teardown-BVQqx1VE.mjs.map
@@ -0,0 +1 @@
1
+ import"./src-Cb3i1kcm.mjs";import"./write-project-skill-DPVCl9Kv.mjs";import"./src-Mfncsy21.mjs";import"./acp-harness-probe-DwJF1QrM.mjs";import"./init-8_iXriiz.mjs";import{n as e}from"./loader-CJqV3lQK.mjs";import"./skill-teardown-BVQqx1VE.mjs";import"./preview-CXrbuj-R.mjs";import"./mcp-migrate-event-B1gJf6bG.mjs";export{e as loadConfig};
@@ -341,8 +341,8 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
341
341
  `,PLUGIN_SECURE_PROXY_MISSING_CHAT_MODEL:`Could not find a chat model defined in the secure proxy plugin configuration.
342
342
  Please provide a chat model before proceeding with creating an answer session.
343
343
  Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#plugin-secure-proxy
344
- `,ANSWER_SESSION_LAST_MESSAGE_IS_NOT_ASSISTANT:`The last message in the session is not an assistant message. Cannot regenerate non-assistant messages.`,PLUGIN_COMPONENT_CONFLICT:`The component "%s" is already defined. The plugin "%s" is trying to redefine it.`};function N4(e,...t){let n=Error(u4(M4[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function P4(e){return{raw:Number(e),formatted:m4(e)}}function F4(e){if(e.id){if(typeof e.id!=`string`)throw N4(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return g4()}function I4(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(t!==void 0&&!(r===`geopoint`&&typeof t==`object`&&typeof t.lon==`number`&&typeof t.lat==`number`)&&!(r===`enum`&&(typeof t==`string`||typeof t==`number`))){if(r===`enum[]`&&Array.isArray(t)){let e=t.length;for(let r=0;r<e;r++)if(typeof t[r]!=`string`&&typeof t[r]!=`number`)return n+`.`+r;continue}if(B4(r)){let e=U4(r);if(!Array.isArray(t)||t.length!==e)throw N4(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(V4(r)){if(!Array.isArray(t))return n;let e=H4(r),i=t.length;for(let r=0;r<i;r++)if(typeof t[r]!==e)return n+`.`+r;continue}if(typeof r==`object`){if(!t||typeof t!=`object`)return n;let e=I4(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}const L4={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},R4={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function z4(e){return e===`geopoint`}function B4(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function V4(e){return typeof e==`string`&&L4[e]}function H4(e){return R4[e]}function U4(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw N4(`INVALID_VECTOR_VALUE`,e);case t<=0:throw N4(`INVALID_VECTOR_SIZE`,e);default:return t}}function W4(){return{idToInternalId:new Map,internalIdToId:[],save:G4,load:K4}}function G4(e){return{internalIdToId:e.internalIdToId}}function K4(e,t){let{internalIdToId:n}=t;e.internalDocumentIDStore.idToInternalId.clear(),e.internalDocumentIDStore.internalIdToId=[];let r=n.length;for(let t=0;t<r;t++){let r=n[t];e.internalDocumentIDStore.idToInternalId.set(r,t+1),e.internalDocumentIDStore.internalIdToId.push(r)}}function q4(e,t){if(typeof t==`string`){let n=e.idToInternalId.get(t);if(n)return n;let r=e.idToInternalId.size+1;return e.idToInternalId.set(t,r),e.internalIdToId.push(t),r}return t>e.internalIdToId.length?q4(e,t.toString()):t}function J4(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function Y4(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function X4(e,t){let n=q4(e.sharedInternalDocumentStore,t);return e.docs[n]}function Z4(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=q4(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function Q4(e){return e.docs}function $4(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function e3(e,t){let n=q4(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function t3(e){return e.count}function n3(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function r3(e){return{docs:e.docs,count:e.count}}function i3(){return{create:Y4,get:X4,getMultiple:Z4,getAll:Q4,store:$4,remove:e3,count:t3,load:n3,save:r3}}const a3=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function o3(e,t){let n=[],r=e.plugins?.length;if(!r)return n;for(let i=0;i<r;i++)try{let r=e.plugins[i];typeof r[t]==`function`&&n.push(r[t])}catch(e){throw console.error(`Caught error in getAllPluginsByHook:`,e),N4(`PLUGIN_CRASHED`)}return n}const s3=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],c3=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function l3(e,t,n,r){if(e.some(T4))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function u3(e,t,n){if(e.some(T4))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function d3(e,t,n,r,i){if(e.some(T4))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function f3(e,t,n,r){if(e.some(T4))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function p3(e,t){if(e.some(T4))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var m3=class e{k;v;l=null;r=null;h=1;constructor(e,t){this.k=e,this.v=new Set(t)}updateHeight(){this.h=Math.max(e.getHeight(this.l),e.getHeight(this.r))+1}static getHeight(e){return e?e.h:0}getBalanceFactor(){return e.getHeight(this.l)-e.getHeight(this.r)}rotateLeft(){let e=this.r;return this.r=e.l,e.l=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){let e=this.l;return this.l=e.r,e.r=this,this.updateHeight(),e.updateHeight(),e}toJSON(){return{k:this.k,v:Array.from(this.v),l:this.l?this.l.toJSON():null,r:this.r?this.r.toJSON():null,h:this.h}}static fromJSON(t){let n=new e(t.k,t.v);return n.l=t.l?e.fromJSON(t.l):null,n.r=t.r?e.fromJSON(t.r):null,n.h=t.h,n}},h3=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new m3(e,t))}insert(e,t,n=1e3){this.root=this.insertNode(this.root,e,t,n)}insertMultiple(e,t,n=1e3){for(let r of t)this.insert(e,r,n)}rebalance(){this.root&&=this.rebalanceNode(this.root)}toJSON(){return{root:this.root?this.root.toJSON():null,insertCount:this.insertCount}}static fromJSON(t){let n=new e;return n.root=t.root?m3.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new m3(t,[n]);let i=[],a=e,o=null;for(;a!==null;)if(i.push({parent:o,node:a}),t<a.k)if(a.l===null){a.l=new m3(t,[n]),i.push({parent:a,node:a.l});break}else o=a,a=a.l;else if(t>a.k)if(a.r===null){a.r=new m3(t,[n]),i.push({parent:a,node:a.r});break}else o=a,a=a.r;else return a.v.add(n),e;let s=!1;this.insertCount++%r===0&&(s=!0);for(let t=i.length-1;t>=0;t--){let{parent:n,node:r}=i[t];if(r.updateHeight(),s){let t=this.rebalanceNode(r);n?n.l===r?n.l=t:n.r===r&&(n.r=t):e=t}}return e}rebalanceNode(e){let t=e.getBalanceFactor();if(t>1){if(e.l&&e.l.getBalanceFactor()>=0)return e.rotateRight();if(e.l)return e.l=e.l.rotateLeft(),e.rotateRight()}if(t<-1){if(e.r&&e.r.getBalanceFactor()<=0)return e.rotateLeft();if(e.r)return e.r=e.r.rotateRight(),e.rotateLeft()}return e}find(e){let t=this.findNodeByKey(e);return t?t.v:null}contains(e){return this.find(e)!==null}getSize(){let e=0,t=[],n=this.root;for(;n||t.length>0;){for(;n;)t.push(n),n=n.l;n=t.pop(),e++,n=n.r}return e}isBalanced(){if(!this.root)return!0;let e=[this.root];for(;e.length>0;){let t=e.pop(),n=t.getBalanceFactor();if(Math.abs(n)>1)return!1;t.l&&e.push(t.l),t.r&&e.push(t.r)}return!0}remove(e){this.root=this.removeNode(this.root,e)}removeDocument(e,t){let n=this.findNodeByKey(e);n&&(n.v.size===1?this.root=this.removeNode(this.root,e):n.v=new Set([...n.v.values()].filter(e=>e!==t)))}findNodeByKey(e){let t=this.root;for(;t;)if(e<t.k)t=t.l;else if(e>t.k)t=t.r;else return t;return null}removeNode(e,t){if(e===null)return null;let n=[],r=e;for(;r!==null&&r.k!==t;)n.push(r),r=t<r.k?r.l:r.r;if(r===null)return e;if(r.l===null||r.r===null){let t=r.l?r.l:r.r;if(n.length===0)e=t;else{let e=n[n.length-1];e.l===r?e.l=t:e.r=t}}else{let e=r,t=r.r;for(;t.l!==null;)e=t,t=t.l;r.k=t.k,r.v=t.v,e.l===t?e.l=t.r:e.r=t.r,r=e}n.push(r);for(let t=n.length-1;t>=0;t--){let r=n[t];r.updateHeight();let i=this.rebalanceNode(r);if(t>0){let e=n[t-1];e.l===r?e.l=i:e.r===r&&(e.r=i)}else e=i}return e}rangeSearch(e,t){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),i.k>=e&&i.k<=t)for(let e of i.v)n.add(e);if(i.k>t)break;i=i.r}return n}greaterThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.r;if(i=r.pop(),t&&i.k>=e||!t&&i.k>e)for(let e of i.v)n.add(e);else if(i.k<=e)break;i=i.l}return n}lessThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),t&&i.k<=e||!t&&i.k<e)for(let e of i.v)n.add(e);else if(i.k>e)break;i=i.r}return n}},g3=class e{numberToDocumentId;constructor(){this.numberToDocumentId=new Map}insert(e,t){this.numberToDocumentId.has(e)?this.numberToDocumentId.get(e).add(t):this.numberToDocumentId.set(e,new Set([t]))}find(e){let t=this.numberToDocumentId.get(e);return t?Array.from(t):null}remove(e){this.numberToDocumentId.delete(e)}removeDocument(e,t){let n=this.numberToDocumentId.get(t);n&&(n.delete(e),n.size===0&&this.numberToDocumentId.delete(t))}contains(e){return this.numberToDocumentId.has(e)}getSize(){let e=0;for(let t of this.numberToDocumentId.values())e+=t.size;return e}filter(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`eq`:{let t=e[n],r=this.numberToDocumentId.get(t);return r?Array.from(r):[]}case`in`:{let t=e[n],r=new Set;for(let e of t){let t=this.numberToDocumentId.get(e);if(t)for(let e of t)r.add(e)}return Array.from(r)}case`nin`:{let t=new Set(e[n]),r=new Set;for(let[e,n]of this.numberToDocumentId.entries())if(!t.has(e))for(let e of n)r.add(e);return Array.from(r)}default:throw Error(`Invalid operation`)}}filterArr(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`containsAll`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e].filter(e=>t.has(e))));return Array.from(r)}case`containsAny`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e,...t]));return Array.from(r)}default:throw Error(`Invalid operation`)}}static fromJSON(t){if(!t.numberToDocumentId)throw Error(`Invalid Flat Tree JSON`);let n=new e;for(let[e,r]of t.numberToDocumentId)n.numberToDocumentId.set(e,new Set(r));return n}toJSON(){return{numberToDocumentId:Array.from(this.numberToDocumentId.entries()).map(([e,t])=>[e,Array.from(t)])}}};function _3(e,t,n){if(n<0)return-1;if(e===t)return 0;let r=e.length,i=t.length;if(r===0)return i<=n?i:-1;if(i===0)return r<=n?r:-1;let a=Math.abs(r-i);if(e.startsWith(t))return a<=n?a:-1;if(t.startsWith(e))return 0;if(a>n)return-1;let o=[];for(let e=0;e<=r;e++){o[e]=[e];for(let t=1;t<=i;t++)o[e][t]=e===0?t:0}for(let a=1;a<=r;a++){let r=1/0;for(let n=1;n<=i;n++)e[a-1]===t[n-1]?o[a][n]=o[a-1][n-1]:o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+1),r=Math.min(r,o[a][n]);if(r>n)return-1}return o[r][i]<=n?o[r][i]:-1}function v3(e,t,n){let r=_3(e,t,n);return{distance:r,isBounded:r>=0}}var y3=class e{k;s;c=new Map;d=new Set;e;w=``;constructor(e,t,n){this.k=e,this.s=t,this.e=n}updateParent(e){this.w=e.w+this.s}addDocument(e){this.d.add(e)}removeDocument(e){return this.d.delete(e)}findAllWords(e,t,n,r){let i=[this];for(;i.length>0;){let a=i.pop();if(a.e){let{w:i,d:o}=a;if(n&&i!==t)continue;if(_4(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&v3(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if(_4(e,i)!=null&&o.size>0){let t=e[i];for(let e of o)t.includes(e)||t.push(e)}}a.c.size>0&&i.push(...a.c.values())}return e}insert(t,n){let r=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=r.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c){if(r=s,i+=l,i===a){s.e||=!0,s.addDocument(n);return}continue}let u=o.slice(0,l),d=o.slice(l),f=t.slice(i+l),p=new e(u[0],u,!1);if(r.c.set(u[0],p),p.updateParent(r),s.s=d,s.k=d[0],p.c.set(d[0],s),s.updateParent(p),f){let t=new e(f[0],f,!0);t.addDocument(n),p.c.set(f[0],t),t.updateParent(p)}else p.e=!0,p.addDocument(n);return}else{let a=new e(o,t.slice(i),!0);a.addDocument(n),r.c.set(o,a),a.updateParent(r);return}}r.e||=!0,r.addDocument(n)}_findLevenshtein(e,t,n,r,i){let a=[{node:this,index:t,tolerance:n}];for(;a.length>0;){let{node:t,index:n,tolerance:o}=a.pop();if(t.w.startsWith(e)){t.findAllWords(i,e,!1,0);continue}if(o<0)continue;if(t.e){let{w:n,d:a}=t;if(n&&(v3(e,n,r).isBounded&&(i[n]=[]),_4(i,n)!==void 0&&a.size>0)){let e=new Set(i[n]);for(let t of a)e.add(t);i[n]=Array.from(e)}}if(n>=e.length)continue;let s=e[n];if(t.c.has(s)){let e=t.c.get(s);a.push({node:e,index:n+1,tolerance:o})}a.push({node:t,index:n+1,tolerance:o-1});for(let[e,r]of t.c)a.push({node:r,index:n,tolerance:o-1}),e!==s&&a.push({node:r,index:n+1,tolerance:o-1})}}find(e){let{term:t,exact:n,tolerance:r}=e;if(r&&!n){let e={};return this._findLevenshtein(t,0,r,r,e),e}else{let e=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=e.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c)e=s,i+=l;else if(i+l===a)if(l===a-i){if(n)return{};{let e={};return s.findAllWords(e,t,n,r),e}}else return{};else return{}}else return{}}let o={};return e.findAllWords(o,t,n,r),o}}contains(e){let t=this,n=0,r=e.length;for(;n<r;){let i=e[n],a=t.c.get(i);if(a){let i=a.s,o=i.length,s=0;for(;s<o&&n+s<r&&i[s]===e[n+s];)s++;if(s<o)return!1;n+=o,t=a}else return!1}return!0}removeWord(e){if(!e)return!1;let t=this,n=e.length,r=[];for(let i=0;i<n;i++){let n=e[i];if(t.c.has(n)){let e=t.c.get(n);r.push({parent:t,character:n}),i+=e.s.length-1,t=e}else return!1}for(t.d.clear(),t.e=!1;r.length>0&&t.c.size===0&&!t.e&&t.d.size===0;){let{parent:e,character:n}=r.pop();e.c.delete(n),t=e}return!0}removeDocumentByWord(e,t,n=!0){if(!e)return!0;let r=this,i=e.length;for(let a=0;a<i;a++){let i=e[a];if(r.c.has(i)){let o=r.c.get(i);a+=o.s.length-1,r=o,n&&r.w!==e||r.removeDocument(t)}else return!1}return!0}static getCommonPrefix(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return e.slice(0,r)}toJSON(){return{w:this.w,s:this.s,e:this.e,k:this.k,d:Array.from(this.d),c:Array.from(this.c?.entries())?.map(([e,t])=>[e,t.toJSON()])}}static fromJSON(t){let n=new e(t.k,t.s,t.e);return n.w=t.w,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([t,n])=>[t,e.fromJSON(n)])||[]),n}},b3=class e extends y3{constructor(){super(``,``,!1)}static fromJSON(t){let n=new e;return n.w=t.w,n.s=t.s,n.e=t.e,n.k=t.k,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([e,t])=>[e,y3.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},x3=class e{point;docIDs;left;right;parent;constructor(e,t){this.point=e,this.docIDs=new Set(t),this.left=null,this.right=null,this.parent=null}toJSON(){return{point:this.point,docIDs:Array.from(this.docIDs),left:this.left?this.left.toJSON():null,right:this.right?this.right.toJSON():null}}static fromJSON(t,n=null){let r=new e(t.point,t.docIDs);return r.parent=n,t.left&&(r.left=e.fromJSON(t.left,r)),t.right&&(r.right=e.fromJSON(t.right,r)),r}},S3=class e{root;nodeMap;constructor(){this.root=null,this.nodeMap=new Map}getPointKey(e){return`${e.lon},${e.lat}`}insert(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);if(r){t.forEach(e=>r.docIDs.add(e));return}let i=new x3(e,t);if(this.nodeMap.set(n,i),this.root==null){this.root=i;return}let a=this.root,o=0;for(;;){if(o%2==0)if(e.lon<a.point.lon){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}else if(e.lat<a.point.lat){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}o++}}contains(e){let t=this.getPointKey(e);return this.nodeMap.has(t)}getDocIDsByCoordinates(e){let t=this.getPointKey(e),n=this.nodeMap.get(t);return n?Array.from(n.docIDs):null}removeDocByID(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);r&&(r.docIDs.delete(t),r.docIDs.size===0&&(this.nodeMap.delete(n),this.deleteNode(r)))}deleteNode(e){let t=e.parent,n=e.left?e.left:e.right;n&&(n.parent=t),t?t.left===e?t.left=n:t.right===e&&(t.right=n):(this.root=n,this.root&&(this.root.parent=null))}searchByRadius(t,n,r=!0,i=`asc`,a=!1){let o=a?e.vincentyDistance:e.haversineDistance,s=[{node:this.root,depth:0}],c=[];for(;s.length>0;){let{node:e,depth:i}=s.pop();if(e==null)continue;let a=o(t,e.point);(r?a<=n:a>n)&&c.push({point:e.point,docIDs:Array.from(e.docIDs)}),e.left!=null&&s.push({node:e.left,depth:i+1}),e.right!=null&&s.push({node:e.right,depth:i+1})}return i&&c.sort((e,n)=>{let r=o(t,e.point),a=o(t,n.point);return i.toLowerCase()===`asc`?r-a:a-r}),c}searchByPolygon(t,n=!0,r=null,i=!1){let a=[{node:this.root,depth:0}],o=[];for(;a.length>0;){let{node:r,depth:i}=a.pop();if(r==null)continue;r.left!=null&&a.push({node:r.left,depth:i+1}),r.right!=null&&a.push({node:r.right,depth:i+1});let s=e.isPointInPolygon(t,r.point);(s&&n||!s&&!n)&&o.push({point:r.point,docIDs:Array.from(r.docIDs)})}let s=e.calculatePolygonCentroid(t);if(r){let t=i?e.vincentyDistance:e.haversineDistance;o.sort((e,n)=>{let i=t(s,e.point),a=t(s,n.point);return r.toLowerCase()===`asc`?i-a:a-i})}return o}toJSON(){return{root:this.root?this.root.toJSON():null}}static fromJSON(t){let n=new e;return t.root&&(n.root=x3.fromJSON(t.root),n.buildNodeMap(n.root)),n}buildNodeMap(e){if(e==null)return;let t=this.getPointKey(e.point);this.nodeMap.set(t,e),e.left&&this.buildNodeMap(e.left),e.right&&this.buildNodeMap(e.right)}static calculatePolygonCentroid(e){let t=0,n=0,r=0,i=e.length;for(let a=0,o=i-1;a<i;o=a++){let i=e[a].lon,s=e[a].lat,c=e[o].lon,l=e[o].lat,u=i*l-c*s;t+=u,n+=(i+c)*u,r+=(s+l)*u}t/=2;let a=6*t;return n/=a,r/=a,{lon:n,lat:r}}static isPointInPolygon(e,t){let n=!1,r=t.lon,i=t.lat,a=e.length;for(let t=0,o=a-1;t<a;o=t++){let a=e[t].lon,s=e[t].lat,c=e[o].lon,l=e[o].lat;s>i!=l>i&&r<(c-a)*(i-s)/(l-s)+a&&(n=!n)}return n}static haversineDistance(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=(t.lat-e.lat)*n,o=(t.lon-e.lon)*n,s=Math.sin(a/2)*Math.sin(a/2)+Math.cos(r)*Math.cos(i)*Math.sin(o/2)*Math.sin(o/2);return 6371e3*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}static vincentyDistance(e,t){let n=6378137,r=1/298.257223563,i=(1-r)*n,a=Math.PI/180,o=e.lat*a,s=t.lat*a,c=(t.lon-e.lon)*a,l=Math.atan((1-r)*Math.tan(o)),u=Math.atan((1-r)*Math.tan(s)),d=Math.sin(l),f=Math.cos(l),p=Math.sin(u),m=Math.cos(u),h=c,g,_=1e3,v,y,b,x,S,C;do{let e=Math.sin(h),t=Math.cos(h);if(v=Math.sqrt(m*e*(m*e)+(f*p-d*m*t)*(f*p-d*m*t)),v===0)return 0;y=d*p+f*m*t,b=Math.atan2(v,y),x=f*m*e/v,S=1-x*x,C=y-2*d*p/S,isNaN(C)&&(C=0);let n=r/16*S*(4+r*(4-3*S));g=h,h=c+(1-n)*r*x*(b+n*v*(C+n*y*(-1+2*C*C)))}while(Math.abs(h-g)>1e-12&&--_>0);if(_===0)return NaN;let w=S*(n*n-i*i)/(i*i),T=1+w/16384*(4096+w*(-768+w*(320-175*w))),E=w/1024*(256+w*(-128+w*(74-47*w))),D=E*v*(C+E/4*(y*(-1+2*C*C)-E/6*C*(-3+4*v*v)*(-3+4*C*C)));return i*T*(b-D)}},C3=class e{true;false;constructor(){this.true=new Set,this.false=new Set}insert(e,t){t?this.true.add(e):this.false.add(e)}delete(e,t){t?this.true.delete(e):this.false.delete(e)}getSize(){return this.true.size+this.false.size}toJSON(){return{true:Array.from(this.true),false:Array.from(this.false)}}static fromJSON(t){let n=new e;return n.true=new Set(t.true),n.false=new Set(t.false),n}};function w3(e,t,n,r,i,{k:a,b:o,d:s}){return Math.log(1+(n-t+.5)/(t+.5))*(s+e*(a+1))/(e+a*(1-o+o*r/i))}var T3=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=E3(t,this.size);this.vectors.set(e,[n,t])}remove(e){this.vectors.delete(e)}find(e,t,n){return e instanceof Float32Array||(e=new Float32Array(e)),D3(e,n,this.vectors,this.size,t)}toJSON(){let e=[];for(let[t,[n,r]]of this.vectors)e.push([t,[n,Array.from(r)]]);return{size:this.size,vectors:e}}static fromJSON(t){let n=t,r=new e(n.size);for(let[e,[t,i]]of n.vectors)r.vectors.set(e,[t,new Float32Array(i)]);return r}};function E3(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function D3(e,t,n,r,i){let a=E3(e,r),o=[],s=t||n.keys();for(let t of s){let s=n.get(t);if(!s)continue;let c=s[0],l=s[1],u=0;for(let t=0;t<r;t++)u+=e[t]*l[t];let d=u/(a*c);d>=i&&o.push([t,d])}return o}function O3(e,t,n,r,i){let a=q4(e.sharedInternalDocumentStore,n);e.avgFieldLength[t]=((e.avgFieldLength[t]??0)*(i-1)+r.length)/i,e.fieldLengths[t][a]=r.length,e.frequencies[t][a]={}}function k3(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=q4(e.sharedInternalDocumentStore,n),s=a/r.length;e.frequencies[t][o][i]=s,i in e.tokenOccurrences[t]||(e.tokenOccurrences[t][i]=0),e.tokenOccurrences[t][i]=(e.tokenOccurrences[t][i]??0)+1}function A3(e,t,n,r){let i=q4(e.sharedInternalDocumentStore,n);r>1?e.avgFieldLength[t]=(e.avgFieldLength[t]*r-e.fieldLengths[t][i])/(r-1):e.avgFieldLength[t]=void 0,e.fieldLengths[t][i]=void 0,e.frequencies[t][i]=void 0}function j3(e,t,n){e.tokenOccurrences[t][n]--}function M3(e,t,n,r,i=``){r||={sharedInternalDocumentStore:t,indexes:{},vectorIndexes:{},searchableProperties:[],searchablePropertiesWithTypes:{},frequencies:{},tokenOccurrences:{},avgFieldLength:{},fieldLengths:{}};for(let[a,o]of Object.entries(n)){let n=`${i}${i?`.`:``}${a}`;if(typeof o==`object`&&!Array.isArray(o)){M3(e,t,o,r,n);continue}if(B4(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new T3(U4(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new C3,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new h3(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new b3,isArray:e},r.avgFieldLength[n]=0,r.frequencies[n]={},r.tokenOccurrences[n]={},r.fieldLengths[n]={};break;case`enum`:case`enum[]`:r.indexes[n]={type:`Flat`,node:new g3,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new S3,isArray:e};break;default:throw N4(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function N3(e,t,n,r,i,a,o,s){return c=>{let{type:l,node:u}=t.indexes[n];switch(l){case`Bool`:u[c?`true`:`false`].add(r);break;case`AVL`:{let e=s?.avlRebalanceThreshold??1;u.insert(c,r,e);break}case`Radix`:{let s=a.tokenize(c,i,n,!1);e.insertDocumentScoreParameters(t,n,r,s,o);for(let i of s)e.insertTokenScoreParameters(t,n,r,s,i),u.insert(i,r);break}case`Flat`:u.insert(c,r);break;case`BKD`:u.insert(c,[r]);break}}}function P3(e,t,n,r,i,a,o,s,c,l,u){if(B4(o))return F3(t,n,a,r,i);let d=N3(e,t,n,i,s,c,l,u);if(!V4(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function F3(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function I3(e,t,n,r,i,a,o,s,c,l){if(B4(o))return t.vectorIndexes[n].node.remove(i),!0;let{type:u,node:d}=t.indexes[n];switch(u){case`AVL`:return d.removeDocument(a,i),!0;case`Bool`:return d[a?`true`:`false`].delete(i),!0;case`Radix`:{let o=c.tokenize(a,s,n);e.removeDocumentScoreParameters(t,n,r,l);for(let r of o)e.removeTokenScoreParameters(t,n,r),d.removeDocumentByWord(r,i);return!0}case`Flat`:return d.removeDocument(i,a),!0;case`BKD`:return d.removeDocByID(a,i),!1}}function L3(e,t,n,r,i,a,o,s,c,l){if(!V4(o))return I3(e,t,n,r,i,a,o,s,c,l);let u=H4(o),d=a,f=d.length;for(let a=0;a<f;a++)I3(e,t,n,r,i,d[a],u,s,c,l);return!0}function R3(e,t,n,r,i,a,o,s,c,l){let u=Array.from(r),d=e.avgFieldLength[t],f=e.fieldLengths[t],p=e.tokenOccurrences[t],m=e.frequencies[t],h=typeof p[n]==`number`?p[n]??0:0,g=u.length;for(let e=0;e<g;e++){let r=u[e];if(c&&!c.has(r))continue;l.has(r)||l.set(r,new Map);let p=l.get(r);p.set(t,(p.get(t)||0)+1);let g=w3(m?.[r]?.[n]??0,h,i,f[r],d,a);o.has(r)?o.set(r,o.get(r)+g*s):o.set(r,g*s)}}function z3(e,t,n,r,i,a,o,s,c,l,u,d=0){let f=n.tokenize(t,r),p=f.length||1,m=new Map,h=new Map,g=new Map;for(let n of i){if(!(n in e.indexes))continue;let r=e.indexes[n],{type:i}=r;if(i!==`Radix`)throw N4(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw N4(`INVALID_BOOST_VALUE`,d);f.length===0&&!t&&f.push(``);let p=f.length;for(let t=0;t<p;t++){let i=f[t],s=r.node.find({term:i,exact:a,tolerance:o}),p=Object.keys(s);p.length>0&&h.set(i,!0);let _=p.length;for(let t=0;t<_;t++){let r=p[t],i=s[r];R3(e,n,r,i,l,c,g,d,u,m)}}}let _=Array.from(g.entries()).map(([e,t])=>[e,t]).sort((e,t)=>t[1]-e[1]);if(_.length===0)return[];if(d===1)return _;if(d===0){if(p===1)return _;for(let e of f)if(!h.get(e))return[];return _.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1})}let v=_.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1});if(v.length>0){let e=_.filter(([e])=>!v.some(([t])=>t===e)),t=Math.ceil(e.length*d);return[...v,...e.slice(0,t)]}return _}function B3(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:D4(...i.map(n=>B3(e,t,n,r)))}if(`or`in n&&n.or&&Array.isArray(n.or)){let i=n.or;return i.length===0?new Set:i.map(n=>B3(e,t,n,r)).reduce((e,t)=>k4(e,t),new Set)}if(`not`in n&&n.not){let i=n.not,a=new Set,o=e.sharedInternalDocumentStore;for(let e=1;e<=o.internalIdToId.length;e++)a.add(e);return A4(a,B3(e,t,i,r))}let i=Object.keys(n),a=i.reduce((e,t)=>({[t]:new Set,...e}),{});for(let o of i){let i=n[o];if(e.indexes[o]===void 0)throw N4(`UNKNOWN_FILTER_PROPERTY`,o);let{node:s,type:c,isArray:l}=e.indexes[o];if(c===`Bool`){let e=s,t=i?e.true:e.false;a[o]=k4(a[o],t);continue}if(c===`BKD`){let e;if(`radius`in i)e=`radius`;else if(`polygon`in i)e=`polygon`;else throw Error(`Invalid operation ${i}`);if(e===`radius`){let{value:t,coordinates:n,unit:r=`m`,inside:c=!0,highPrecision:l=!1}=i[e],u=C4(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=K3(a[o],d)}else{let{coordinates:t,inside:n=!0,highPrecision:r=!1}=i[e],c=s.searchByPolygon(t,n,void 0,r);a[o]=K3(a[o],c)}continue}if(c===`Radix`&&(typeof i==`string`||Array.isArray(i))){for(let e of[i].flat()){let n=t.tokenize(e,r,o);for(let e of n){let t=s.find({term:e,exact:!0});a[o]=X3(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw N4(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=k4(a[o],e);continue}if(c===`AVL`){let e=u[0],t=i[e],n;switch(e){case`gt`:n=s.greaterThan(t,!1);break;case`gte`:n=s.greaterThan(t,!0);break;case`lt`:n=s.lessThan(t,!1);break;case`lte`:n=s.lessThan(t,!0);break;case`eq`:n=s.find(t)??new Set;break;case`between`:{let[e,r]=t;n=s.rangeSearch(e,r);break}default:throw N4(`INVALID_FILTER_OPERATION`,e)}a[o]=k4(a[o],n)}}return D4(...Object.values(a))}function V3(e){return e.searchableProperties}function H3(e){return e.searchablePropertiesWithTypes}function U3(e,t){let{indexes:n,vectorIndexes:r,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}=t,u={},d={};for(let e of Object.keys(n)){let{node:t,type:r,isArray:i}=n[e];switch(r){case`Radix`:u[e]={type:`Radix`,node:b3.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:g3.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:h3.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:S3.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:C3.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:T3.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function W3(e){let{indexes:t,vectorIndexes:n,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}=e,l={};for(let e of Object.keys(n))l[e]=n[e].node.toJSON();let u={};for(let e of Object.keys(t)){let{type:n,node:r,isArray:i}=t[e];n===`Flat`||n===`Radix`||n===`AVL`||n===`BKD`||n===`Bool`?u[e]={type:n,node:r.toJSON(),isArray:i}:(u[e]=t[e],u[e].node=u[e].node.toJSON())}return{indexes:u,vectorIndexes:l,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}}function G3(){return{create:M3,insert:P3,remove:L3,insertDocumentScoreParameters:O3,insertTokenScoreParameters:k3,removeDocumentScoreParameters:A3,removeTokenScoreParameters:j3,calculateResultScores:R3,search:z3,searchByWhereClause:B3,getSearchableProperties:V3,getSearchablePropertiesWithTypes:H3,load:U3,save:W3}}function K3(e,t){e||=new Set;let n=t.length;for(let r=0;r<n;r++){let n=t[r].docIDs,i=n.length;for(let t=0;t<i;t++)e.add(n[t])}return e}function q3(e,t,n=!1){let r=n?S3.vincentyDistance:S3.haversineDistance,i=[],a=[];for(let{point:n}of e)a.push(r(t,n));let o=Math.max(...a),s=0;for(let{docIDs:t}of e){let e=o-a[s]+1;for(let n of t)i.push([n,e]);s++}return i.sort((e,t)=>t[1]-e[1]),i}function J3(e,t){let n=Object.keys(e);if(n.length!==1)return{isGeoOnly:!1};let r=n[0],i=e[r];if(t.indexes[r]===void 0)return{isGeoOnly:!1};let{type:a}=t.indexes[r];return a===`BKD`&&i&&(`radius`in i||`polygon`in i)?{isGeoOnly:!0,geoProperty:r,geoOperation:i}:{isGeoOnly:!1}}function Y3(e,t){let n=e,r=J3(t,n);if(!r.isGeoOnly||!r.geoProperty||!r.geoOperation)return null;let{node:i}=n.indexes[r.geoProperty],a=r.geoOperation,o=i,s;if(`radius`in a){let{value:e,coordinates:t,unit:n=`m`,inside:r=!0,highPrecision:i=!1}=a.radius,c=t,l=C4(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),q3(s,c,i)}else if(`polygon`in a){let{coordinates:e,inside:t=!0,highPrecision:n=!1}=a.polygon;s=o.searchByPolygon(e,t,`asc`,n);let r=S3.calculatePolygonCentroid(e);return q3(s,r,n)}return null}function X3(e,t){e||=new Set;let n=Object.keys(t),r=n.length;for(let i=0;i<r;i++){let r=t[n[i]],a=r.length;for(let t=0;t<a;t++)e.add(r[t])}return e}function Z3(e,t,n,r,i){let a={language:e.tokenizer.language,sharedInternalDocumentStore:t,enabled:!0,isSorted:!0,sortableProperties:[],sortablePropertiesWithTypes:{},sorts:{}};for(let[o,s]of Object.entries(n)){let n=`${i}${i?`.`:``}${o}`;if(!r.includes(n)){if(typeof s==`object`&&!Array.isArray(s)){let i=Z3(e,t,s,r,n);l4(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!B4(s))switch(s){case`boolean`:case`number`:case`string`:a.sortableProperties.push(n),a.sortablePropertiesWithTypes[n]=s,a.sorts[n]={docs:new Map,orderedDocsToRemove:new Map,orderedDocs:[],type:s};break;case`geopoint`:case`enum`:continue;case`enum[]`:case`boolean[]`:case`number[]`:case`string[]`:continue;default:throw N4(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function Q3(e,t,n,r){return r?.enabled===!1?{disabled:!0}:Z3(e,t,n,(r||{}).unsortableProperties||[],``)}function $3(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=q4(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&o6(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function e6(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)i6(e,n);e.isSorted=!0}function t6(e,t,n){return t[1].localeCompare(n[1],n4(e))}function n6(e,t){return e[1]-t[1]}function r6(e,t){return t[1]?-1:1}function i6(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=t6.bind(null,e.language);break;case`number`:r=n6.bind(null);break;case`boolean`:r=r6.bind(null);break}n.orderedDocs.sort(r);let i=n.orderedDocs.length;for(let e=0;e<i;e++){let t=n.orderedDocs[e][0];n.docs.set(t,e)}}function a6(e){let t=Object.keys(e.sorts);for(let n of t)o6(e,n)}function o6(e,t){let n=e.sorts[t];n.orderedDocsToRemove.size&&(n.orderedDocs=n.orderedDocs.filter(e=>!n.orderedDocsToRemove.has(e[0])),n.orderedDocsToRemove.clear())}function s6(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=q4(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function c6(e,t,n){if(!e.enabled)throw N4(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw N4(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return o6(e,r),e6(e),t.sort((t,n)=>{let r=a.docs.get(q4(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(q4(e.sharedInternalDocumentStore,n[0])),s=r!==void 0,c=o!==void 0;return!s&&!c?0:s?c?i?o-r:r-o:-1:1}),t}function l6(e){return e.enabled?e.sortableProperties:[]}function u6(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function d6(e,t){let n=t;if(!n.enabled)return{enabled:!1};let r=Object.keys(n.sorts).reduce((e,t)=>{let{docs:r,orderedDocs:i,type:a}=n.sorts[t];return e[t]={docs:new Map(Object.entries(r).map(([e,t])=>[+e,t])),orderedDocsToRemove:new Map,orderedDocs:i,type:a},e},{});return{sharedInternalDocumentStore:e,language:n.language,sortableProperties:n.sortableProperties,sortablePropertiesWithTypes:n.sortablePropertiesWithTypes,sorts:r,enabled:!0,isSorted:n.isSorted}}function f6(e){if(!e.enabled)return{enabled:!1};a6(e),e6(e);let t=Object.keys(e.sorts).reduce((t,n)=>{let{docs:r,orderedDocs:i,type:a}=e.sorts[n];return t[n]={docs:Object.fromEntries(r.entries()),orderedDocs:i,type:a},t},{});return{language:e.language,sortableProperties:e.sortableProperties,sortablePropertiesWithTypes:e.sortablePropertiesWithTypes,sorts:t,enabled:e.enabled,isSorted:e.isSorted}}function p6(){return{create:Q3,insert:$3,remove:s6,save:f6,load:d6,sortBy:c6,getSortableProperties:l6,getSortablePropertiesWithTypes:u6}}const m6=[65,65,65,65,65,65,65,67,69,69,69,69,73,73,73,73,69,78,79,79,79,79,79,null,79,85,85,85,85,89,80,115,97,97,97,97,97,97,97,99,101,101,101,101,105,105,105,105,101,110,111,111,111,111,111,null,111,117,117,117,117,121,112,121,65,97,65,97,65,97,67,99,67,99,67,99,67,99,68,100,68,100,69,101,69,101,69,101,69,101,69,101,71,103,71,103,71,103,71,103,72,104,72,104,73,105,73,105,73,105,73,105,73,105,73,105,74,106,75,107,107,76,108,76,108,76,108,76,108,76,108,78,110,78,110,78,110,110,78,110,79,111,79,111,79,111,79,111,82,114,82,114,82,114,83,115,83,115,83,115,83,115,84,116,84,116,84,116,85,117,85,117,85,117,85,117,85,117,85,117,87,119,89,121,89,90,122,90,122,90,122,115];function h6(e){return e<192||e>383?e:m6[e-192]||e}function g6(e){let t=[];for(let n=0;n<e.length;n++)t[n]=h6(e.charCodeAt(n));return String.fromCharCode(...t)}const _6={ational:`ate`,tional:`tion`,enci:`ence`,anci:`ance`,izer:`ize`,bli:`ble`,alli:`al`,entli:`ent`,eli:`e`,ousli:`ous`,ization:`ize`,ation:`ate`,ator:`ate`,alism:`al`,iveness:`ive`,fulness:`ful`,ousness:`ous`,aliti:`al`,iviti:`ive`,biliti:`ble`,logi:`log`},v6={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},y6=`[aeiouy]`,b6=`[^aeiou][^aeiouy]*`;y6+``;const x6=`^(`+b6+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`;``+b6;const S6=`^(`+b6+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,C6=`^(`+b6+`)?[aeiouy]`;function w6(e){let t,n,r,i,a,o;if(e.length<3)return e;let s=e.substring(0,1);if(s==`y`&&(e=s.toUpperCase()+e.substring(1)),r=/^(.+?)(ss|i)es$/,i=/^(.+?)([^s])s$/,r.test(e)?e=e.replace(r,`$1$2`):i.test(e)&&(e=e.replace(i,`$1$2`)),r=/^(.+?)eed$/,i=/^(.+?)(ed|ing)$/,r.test(e)){let t=r.exec(e);r=new RegExp(x6),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(C6),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+b6+y6+`[^aeiouwxy]$`),i.test(e)?e+=`e`:a.test(e)?(r=/.$/,e=e.replace(r,``)):o.test(e)&&(e+=`e`)));if(r=/^(.+?)y$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(C6),t&&r.test(t)&&(e=t+`i`)),r=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(x6),t&&r.test(t)&&(e=t+_6[n])}if(r=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(x6),t&&r.test(t)&&(e=t+v6[n])}if(r=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,i=/^(.+?)(s|t)(ion)$/,r.test(e))t=r.exec(e)?.[1],r=new RegExp(S6),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(S6),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(S6),i=RegExp(`^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`),a=RegExp(`^`+b6+y6+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(S6),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function T6(e,t,n=!0){let r=`${this.language}:${e}:${t}`;return n&&this.normalizationCache.has(r)?this.normalizationCache.get(r):this.stopWords?.includes(t)?(n&&this.normalizationCache.set(r,``),``):(this.stemmer&&!this.stemmerSkipProperties.has(e)&&(t=this.stemmer(t)),t=g6(t),n&&this.normalizationCache.set(r,t),t)}function E6(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function D6(e,t,n,r=!0){if(t&&t!==this.language)throw N4(`LANGUAGE_NOT_SUPPORTED`,t);if(typeof e!=`string`)return[e];let i=this.normalizeToken.bind(this,n??``),a;if(n&&this.tokenizeSkipProperties.has(n))a=[i(e,r)];else{let t=e4[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=E6(a);return this.allowDuplicates?o:Array.from(new Set(o))}function O6(e={}){if(!e.language)e.language=`english`;else if(!t4.includes(e.language))throw N4(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw N4(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=w6;else throw N4(`MISSING_STEMMER`,e.language);let n;if(e.stopWords!==!1){if(n=[],Array.isArray(e.stopWords))n=e.stopWords;else if(typeof e.stopWords==`function`)n=e.stopWords(n);else if(e.stopWords)throw N4(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw N4(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw N4(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:D6,language:e.language,stemmer:t,stemmerSkipProperties:new Set(e.stemmerSkipProperties?[e.stemmerSkipProperties].flat():[]),tokenizeSkipProperties:new Set(e.tokenizeSkipProperties?[e.tokenizeSkipProperties].flat():[]),stopWords:n,allowDuplicates:!!e.allowDuplicates,normalizeToken:T6,normalizationCache:new Map};return r.tokenize=D6.bind(r),r.normalizeToken=T6,r}function k6(e){return{sharedInternalDocumentStore:e,rules:new Map}}function A6(e,t){if(e.rules.has(t.id))throw Error(`PINNING_RULE_ALREADY_EXISTS: A pinning rule with id "${t.id}" already exists. Use updateRule to modify it.`);e.rules.set(t.id,t)}function j6(e,t){if(!e.rules.has(t.id))throw Error(`PINNING_RULE_NOT_FOUND: Cannot update pinning rule with id "${t.id}" because it does not exist. Use addRule to create it.`);e.rules.set(t.id,t)}function M6(e,t){return e.rules.delete(t)}function N6(e,t){return e.rules.get(t)}function P6(e){return Array.from(e.rules.values())}function F6(e,t){let n=e.toLowerCase().trim(),r=t.pattern.toLowerCase().trim();switch(t.anchoring){case`is`:return n===r;case`starts_with`:return n.startsWith(r);case`contains`:return n.includes(r);default:return!1}}function I6(e,t){return e?t.conditions.every(t=>F6(e,t)):!1}function L6(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())I6(t,r)&&n.push(r);return n}function R6(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function z6(e){return{rules:Array.from(e.rules.entries())}}function B6(){return{create:k6,addRule:A6,updateRule:j6,removeRule:M6,getRule:N6,getAllRules:P6,getMatchingRules:L6,load:R6,save:z6}}function V6(e){let t={formatElapsedTime:P4,getDocumentIndexId:F4,getDocumentProperties:b4,validateSchema:I4};for(let n of c3){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw N4(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!s3.includes(t)&&!c3.includes(t))throw N4(`UNSUPPORTED_COMPONENT`,t)}function H6({schema:e,sort:t,language:n,components:r,id:i,plugins:a}){r||={};for(let t of a??[]){if(!(`getComponents`in t)||typeof t.getComponents!=`function`)continue;let n=t.getComponents(e),i=Object.keys(n);for(let e of i)if(r[e])throw N4(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=g4();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:O6(o):O6({language:n??`english`}),r.tokenizer&&n)throw N4(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=W4();s||=G3(),l||=p6(),c||=i3(),u||=B6(),V6(r);let{getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,formatElapsedTime:h}=r,g={data:{},caches:{},schema:e,tokenizer:o,index:s,sorter:l,documentsStore:c,pinning:u,internalDocumentIDStore:d,getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,beforeInsert:[],afterInsert:[],beforeRemove:[],afterRemove:[],beforeUpdate:[],afterUpdate:[],beforeUpsert:[],afterUpsert:[],beforeSearch:[],afterSearch:[],beforeInsertMultiple:[],afterInsertMultiple:[],beforeRemoveMultiple:[],afterRemoveMultiple:[],beforeUpdateMultiple:[],afterUpdateMultiple:[],beforeUpsertMultiple:[],afterUpsertMultiple:[],afterCreate:[],formatElapsedTime:h,id:i,plugins:a,version:U6()};g.data={index:g.index.create(g,d,e),docs:g.documentsStore.create(g,d),sorting:g.sorter.create(g,d,e,t),pinning:g.pinning.create(d)};for(let e of a3)g[e]=(g[e]??[]).concat(o3(g,e));let _=g.afterCreate;return _&&p3(_,g),g}function U6(){return`{{VERSION}}`}function W6(e){return e.documentsStore.count(e.data.docs)}function G6(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw N4(`SCHEMA_VALIDATION_FAILURE`,a);return T4(e.beforeInsert)||T4(e.afterInsert)||T4(e.index.beforeInsert)||T4(e.index.insert)||T4(e.index.afterInsert)?J6(e,t,n,r,i):Y6(e,t,n,r,i)}const K6=new Set([`enum`,`enum[]`]),q6=new Set([`string`,`number`]);async function J6(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw N4(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=q4(e.internalDocumentIDStore,s);if(r||await l3(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw N4(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];X6(n,r,e,t)}return await Z6(e,s,u,f,l,n,t,i),r||await l3(e.afterInsert,e,s,t),s}function Y6(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw N4(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=q4(e.internalDocumentIDStore,s);if(r||l3(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw N4(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];X6(n,r,e,t)}return Q6(e,s,u,f,l,n,t,i),r||l3(e.afterInsert,e,s,t),s}function X6(e,t,n,r){if(!(z4(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(B4(t)&&Array.isArray(r))&&!(V4(t)&&Array.isArray(r))&&!(K6.has(t)&&q6.has(e))&&e!==t)throw N4(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function Z6(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o];await e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i);let l=e.internalDocumentIDStore.idToInternalId.get(t);await e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),await e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function Q6(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o],l=q4(e.internalDocumentIDStore,t);e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i),e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function $6(e,t,n,r,i,a){return T4(e.afterInsertMultiple)||T4(e.beforeInsertMultiple)||T4(e.index.beforeInsert)||T4(e.index.insert)||T4(e.index.afterInsert)?e8(e,t,n,r,i,a):t8(e,t,n,r,i,a)}async function e8(e,t,n=1e3,r,i,a=0){let o=[],s=async a=>{let s=Math.min(a+n,t.length),c=t.slice(a,s);for(let t of c){let n=await G6(e,t,r,i,{avlRebalanceThreshold:c.length});o.push(n)}return s};return await(async()=>{let e=0;for(;e<t.length;){let t=Date.now();if(e=await s(e),a>0){let e=a-(Date.now()-t);e>0&&j4(e)}}})(),i||await u3(e.afterInsertMultiple,e,t),o}function t8(e,t,n=1e3,r,i,a=0){let o=[],s=0;function c(){let a=t.slice(s*n,(s+1)*n);if(a.length===0)return!1;for(let t of a){let n=G6(e,t,r,i,{avlRebalanceThreshold:a.length});o.push(n)}return s++,!0}function l(){let e=Date.now();for(;c();)if(a>0){let t=Date.now()-e;if(t>=a){let e=a-t%a;e>0&&j4(e)}}}return l(),i||u3(e.afterInsertMultiple,e,t),o}function n8(e,t,n,r){return T4(e.index.beforeRemove)||T4(e.index.remove)||T4(e.index.afterRemove)?r8(e,t,n,r):i8(e,t,n,r)}async function r8(e,t,n,r){let i=!0,{index:a,docs:o}=e.data,s=e.documentsStore.get(o,t);if(!s)return!1;let c=q4(e.internalDocumentIDStore,t),l=J4(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||await l3(e.beforeRemove,e,l);let d=e.index.getSearchableProperties(a),f=e.index.getSearchablePropertiesWithTypes(a),p=e.getDocumentProperties(s,d);for(let r of d){let a=p[r];if(a===void 0)continue;let o=f[r];await e.index.beforeRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u),await e.index.remove(e.index,e.data.index,r,t,c,a,o,n,e.tokenizer,u)||(i=!1),await e.index.afterRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u)}let m=await e.sorter.getSortableProperties(e.data.sorting),h=await e.getDocumentProperties(s,m);for(let n of m)h[n]!==void 0&&e.sorter.remove(e.data.sorting,n,t);return r||await l3(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function i8(e,t,n,r){let i=!0,{index:a,docs:o}=e.data,s=e.documentsStore.get(o,t);if(!s)return!1;let c=q4(e.internalDocumentIDStore,t),l=J4(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||l3(e.beforeRemove,e,l);let d=e.index.getSearchableProperties(a),f=e.index.getSearchablePropertiesWithTypes(a),p=e.getDocumentProperties(s,d);for(let r of d){let a=p[r];if(a===void 0)continue;let o=f[r];e.index.beforeRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u),e.index.remove(e.index,e.data.index,r,t,c,a,o,n,e.tokenizer,u)||(i=!1),e.index.afterRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u)}let m=e.sorter.getSortableProperties(e.data.sorting),h=e.getDocumentProperties(s,m);for(let n of m)h[n]!==void 0&&e.sorter.remove(e.data.sorting,n,t);return r||l3(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function a8(e,t,n,r,i){return T4(e.index.beforeRemove)||T4(e.index.remove)||T4(e.index.afterRemove)||T4(e.beforeRemoveMultiple)||T4(e.afterRemoveMultiple)?o8(e,t,n,r,i):s8(e,t,n,r,i)}async function o8(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>J4(e.internalDocumentIDStore,q4(e.internalDocumentIDStore,t)));return i||await u3(e.beforeRemoveMultiple,e,o),await new Promise((o,s)=>{let c=0;async function l(){let u=t.slice(c*n,++c*n);if(!u.length)return o();for(let t of u)try{await n8(e,t,r,i)&&a++}catch(e){s(e)}setTimeout(l,0)}setTimeout(l,0)}),i||await u3(e.afterRemoveMultiple,e,o),a}function s8(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>J4(e.internalDocumentIDStore,q4(e.internalDocumentIDStore,t)));i||u3(e.beforeRemoveMultiple,e,o);let s=0;function c(){let o=t.slice(s*n,++s*n);if(o.length){for(let t of o)n8(e,t,r,i)&&a++;setTimeout(c,0)}}return c(),i||u3(e.afterRemoveMultiple,e,o),a}function c8(e,t){return e[1]-t[1]}function l8(e,t){return t[1]-e[1]}function u8(e=`desc`){return e.toLowerCase()===`asc`?c8:l8}function d8(e,t,n){let r={},i=t.map(([e])=>e),a=e.documentsStore.getMultiple(e.data.docs,i),o=Object.keys(n),s=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e of o){let t;if(s[e]===`number`){let{ranges:r}=n[e],i=r.length,a=Array.from({length:i});for(let e=0;e<i;e++){let t=r[e];a[e]=[`${t.from}-${t.to}`,0]}t=Object.fromEntries(a)}r[e]={count:0,values:t??{}}}let c=a.length;for(let e=0;e<c;e++){let t=a[e];for(let e of o){let i=e.includes(`.`)?x4(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;f8(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=f8(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:p8(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=p8(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw N4(`FACET_NOT_SUPPORTED`,a)}}}for(let e of o){let t=r[e];if(t.count=Object.keys(t.values).length,s[e]===`string`){let r=n[e],i=u8(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function f8(e,t,n){return r=>{for(let i of e){let e=`${i.from}-${i.to}`;n?.has(e)||r>=i.from&&r<=i.to&&(t[e]===void 0?t[e]=1:(t[e]++,n?.add(e)))}}}function p8(e,t,n){let r=t===`boolean`?`false`:``;return t=>{let i=t?.toString()??r;n?.has(i)||(e[i]=(e[i]??0)+1,n?.add(i))}}const m8={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},h8=[`string`,`number`,`boolean`];function g8(e,t,n){let r=n.properties,i=r.length,a=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e=0;e<i;e++){let t=r[e];if(a[t]===void 0)throw N4(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!h8.includes(a[t]))throw N4(`INVALID_GROUP_BY_PROPERTY`,t,h8.join(`, `),a[t])}let o=t.map(([t])=>J4(e.internalDocumentIDStore,t)),s=e.documentsStore.getMultiple(e.data.docs,o),c=s.length,l=n.maxResult||2**53-1,u=[],d={};for(let e=0;e<i;e++){let t=r[e],n={property:t,perValue:{}},i=new Set;for(let e=0;e<c;e++){let r=s[e],a=x4(r,t);if(a===void 0)continue;let o=typeof a==`boolean`?``+a:a,c=n.perValue[o]??{indexes:[],count:0};c.count>=l||(c.indexes.push(e),c.count++,n.perValue[o]=c,i.add(a))}u.push(Array.from(i)),d[t]=n}let f=_8(u),p=f.length,m=[];for(let e=0;e<p;e++){let t=f[e],n=t.length,i={values:[],indexes:[]},a=[];for(let e=0;e<n;e++){let n=t[e],o=r[e];a.push(d[o].perValue[typeof n==`boolean`?``+n:n].indexes),i.values.push(n)}i.indexes=y4(a).sort((e,t)=>e-t),i.indexes.length!==0&&m.push(i)}let h=m.length,g=Array.from({length:h});for(let e=0;e<h;e++){let r=m[e],i=n.reduce||m8,a=r.indexes.map(e=>({id:o[e],score:t[e][1],document:s[e]})),c=i.reducer.bind(null,r.values),l=i.getInitialValue(r.indexes.length),u=a.reduce(c,l);g[e]={values:r.values,result:u}}return g}function _8(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=_8(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];l4(n,t),i.push(n)}return i}function v8(e,t,n,r){let i=L6(t,r);if(i.length===0)return n;let a=i.flatMap(e=>e.consequence.promote);a.sort((e,t)=>e.position-t.position);let o=new Set,s=new Map,c=new Set;for(let t of a){let n=q4(e.internalDocumentIDStore,t.doc_id);if(n!==void 0){if(s.has(n)){let e=s.get(n);t.position<e&&s.set(n,t.position);continue}c.has(t.position)||(o.add(n),s.set(n,t.position),c.add(t.position))}}if(s.size===0)return n;let l=n.filter(([e])=>!o.has(e)),u=[];for(let[t,r]of s.entries())n.find(([e])=>e===t)?u.push([t,1e6-r]):e.documentsStore.get(e.data.docs,t)&&u.push([t,0]);u.sort((e,t)=>(s.get(e[0])??1/0)-(s.get(t[0])??1/0));let d=[],f=new Map;for(let e of u){let t=s.get(e[0]);f.set(t,e)}let p=0,m=0;for(;m<l.length+u.length;)if(f.has(m))d.push(f.get(m)),m++;else if(p<l.length)d.push(l[p]),p++,m++;else break;for(let[e,t]of f.entries())e>=d.length&&d.push(t);return d}function y8(e,t,n){let{term:r,properties:i}=t,a=e.data.index,o=e.caches.propertiesToSearch;if(!o){let t=e.index.getSearchablePropertiesWithTypes(a);o=e.index.getSearchableProperties(a),o=o.filter(e=>t[e].startsWith(`string`)),e.caches.propertiesToSearch=o}if(i&&i!==`*`){for(let e of i)if(!o.includes(e))throw N4(`UNKNOWN_INDEX`,e,o.join(`, `));o=o.filter(e=>i.includes(e))}let s=Object.keys(t.where??{}).length>0,c;s&&(c=e.index.searchByWhereClause(a,e.tokenizer,t.where,n));let l,u=t.threshold!==void 0&&t.threshold!==null?t.threshold:1;if(r||i){let i=W6(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},w8(t.relevance),i,c,u),t.exact&&r){let t=r.trim().split(/\s+/);l=l.filter(([n])=>{let r=e.documentsStore.get(e.data.docs,n);if(!r)return!1;for(let e of o){let n=x8(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${b8(e)}\\b`).test(n)))return!0}return!1})}}else l=s?Y3(a,t.where)||(c?Array.from(c):[]).map(e=>[+e,0]):Object.keys(e.documentsStore.getAll(e.data.docs)).map(e=>[+e,0]);return l}function b8(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function x8(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return r}function S8(e,t,n){let r=h4();function i(){let i=Object.keys(e.data.index.vectorIndexes),a=t.facets&&Object.keys(t.facets).length>0,{limit:o=10,offset:s=0,distinctOn:c,includeVectors:l=!1}=t,u=t.preflight===!0,d=y8(e,t,n);if(t.sortBy)if(typeof t.sortBy==`function`){let n=d.map(([e])=>e),r=e.documentsStore.getMultiple(e.data.docs,n).map((e,t)=>[d[t][0],d[t][1],e]);r.sort(t.sortBy),d=r.map(([e,t])=>[e,t])}else d=e.sorter.sortBy(e.data.sorting,d,t.sortBy).map(([t,n])=>[q4(e.internalDocumentIDStore,t),n]);else d=d.sort(v4);d=v8(e,e.data.pinning,d,t.term);let f;u||(f=c?I8(e,d,s,o,c):L8(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||w4(p,i)),a&&(p.facets=d8(e,d,t.facets)),t.groupBy&&(p.groups=g8(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(h4()-r),p}async function a(){e.beforeSearch&&await f3(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await d3(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}const C8={k:1.2,b:.75,d:.5};function w8(e){let t=e??{};return t.k=t.k??C8.k,t.b=t.b??C8.b,t.d=t.d??C8.d,t}function T8(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw N4(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw N4(`UNKNOWN_VECTOR_PROPERTY`,r.property);let a=i.node.size;if(r?.value.length!==a)throw r?.property===void 0||r?.value.length===void 0?N4(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):N4(`INVALID_INPUT_VECTOR`,r.property,a,r.value.length);let o=e.data.index,s;return Object.keys(t.where??{}).length>0&&(s=e.index.searchByWhereClause(o,e.tokenizer,t.where,n)),i.node.find(r.value,t.similarity??.8,s)}function E8(e,t,n=`english`){let r=h4();function i(){let i=T8(e,t,n).sort(v4);i=v8(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=d8(e,i,t.facets));let o=t.vector.property,s=t.includeVectors??!1,c=t.limit??10,l=t.offset??0,u=Array.from({length:c});for(let t=0;t<c;t++){let n=i[t+l];if(!n)break;let r=e.data.docs.docs[n[0]];r&&(s||(r[o]=null),u[t]={id:J4(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=g8(e,i,t.groupBy));let f=h4()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:m4(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await f3(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await d3(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function D8(e,t,n){let r=A8(y8(e,t,n)),i=T8(e,t,n),a=t.hybridWeights;return N8(r,i,t.term??``,a)}function O8(e,t,n){let r=h4();function i(){let i=D8(e,t,n);i=v8(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=d8(e,i,t.facets));let o;t.groupBy&&(o=g8(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=L8(e,i,s,c).filter(Boolean),u=h4(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:m4(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||w4(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await f3(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await d3(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function k8(e){return e[1]}function A8(e){let t=Math.max.apply(Math,e.map(k8));return e.map(([e,n])=>[e,n/t])}function j8(e,t){return e/t}function M8(e,t){return(n,r)=>n*e+r*t}function N8(e,t,n,r){let i=Math.max.apply(Math,e.map(k8)),a=Math.max.apply(Math,t.map(k8)),{text:o,vector:s}=r&&r.text&&r.vector?r:P8(n),c=new Map,l=e.length,u=M8(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(j8(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=j8(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function P8(e){return{text:.5,vector:.5}}function F8(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return S8(e,t,n);if(r===`vector`)return E8(e,t);if(r===`hybrid`)return O8(e,t);throw N4(`INVALID_SEARCH_MODE`,r)}function I8(e,t,n,r,i){let a=e.data.docs,o=new Map,s=[],c=new Set,l=t.length,u=0;for(let d=0;d<l;d++){let l=t[d];if(l===void 0)continue;let[f,p]=l;if(c.has(f))continue;let m=e.documentsStore.get(a,f),h=x4(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:J4(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function L8(e,t,n,r){let i=e.data.docs,a=Array.from({length:r}),o=new Set;for(let s=n;s<r+n;s++){let n=t[s];if(n===void 0)break;let[r,c]=n;if(!o.has(r)){let t=e.documentsStore.get(i,r);a[s]={id:J4(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}const R8={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},z8=new WeakMap;function B8(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function V8(e){return e.trim().toLowerCase()}const H8=/\.(?:md|mdx)$/;function U8(e,t){if(t!==`page`)return e;let n=e.replace(H8,``);return n.length>0?n:e}function W8(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function G8(e){let t=W8(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function K8(e){let t=H6({schema:R8});return e.length>0&&$6(t,e),t}function q8(e){let t={documents:e};return z8.set(t,K8(e)),t}function J8(e){let t=z8.get(e);if(t)return t;let n=K8(e.documents);return z8.set(e,n),n}const Y8=new WeakSet;function X8(e,t){return e===t||e.kind===t.kind&&e.path===t.path&&e.title===t.title&&e.name===t.name&&e.pathSegments===t.pathSegments&&e.modifiedTs===t.modifiedTs&&e.content===t.content}function Z8(e,t){let n=e=>({corpus:q8(t),inserted:0,updated:0,removed:0,rebuilt:!0,rebuildReason:e}),r=z8.get(e);if(!r)return n(`no-index`);if(Y8.has(e))return n(`stale-base`);let i=new Map(t.map(e=>[e.id,e]));if(i.size!==t.length)return n(`duplicate-id`);let a=[],o=[],s=0;for(let t of e.documents){let e=i.get(t.id);e?X8(t,e)||(a.push(t.id),o.push(e),s+=1):a.push(t.id)}let c=new Set(e.documents.map(e=>e.id));for(let e of t)c.has(e.id)||o.push(e);if(a.length+o.length>t.length)return n(`bulk-change`);Y8.add(e);try{if(a.length>0&&a8(r,a),o.length>0&&$6(r,o),W6(r)!==t.length)throw Error(`Search index count ${W6(r)} diverged from document count ${t.length} after incremental update`)}catch{return n(`mutation-failed`)}let l={documents:t};return z8.set(l,r),{corpus:l,inserted:o.length-s,updated:s,removed:a.length-s,rebuilt:!1}}function Q8(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function $8(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function e5(e,t){let n=V8(t);if(!n)return 0;let r=U8(n,e.kind),i=V8(e.title),a=V8(e.name),o=V8(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function t5(e,t){let n=e5(e,t);return n<=0?n:eb(e.path)?n*.5:n}function n5(e){return e===`file`?-60:0}function r5(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function i5(e,t,n,r){return e+t*20+n+n5(r)}function a5(e,t,n,r,i,a){return e===`relevance`?i5(t,n,r,i):r5(t,n,r,i,a)}function o5(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function s5(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function c5(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function l5(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function u5(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function d5(e,t){return V8(t).length<4?0:+(e===`full_text`)}function f5(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function p5(e){let t=[],n=[],r=[];for(let i of e){let e=f5(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function m5(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=p5(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function h5(e,t,n={}){let r=n.intent??`omnibar`,i=o5(r,n.ranking),a=B8(n.limit),o=new Set(n.scopes??Q8(r)),s=e.documents.filter(e=>$8(e,o)),c=V8(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=F8(J8(e),{term:c,properties:l5(r),boost:u5(r),tolerance:d5(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>$8(e.document,o)).map(e=>[e.document.id,e.score])),d=c5(s),f=new Map;for(let e of s)t5(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)$8(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=s5(f.values(),u);return m5([...f.values()].map(t=>{let n=Math.max(0,t5(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:a5(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return m5(_5({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function g5(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function _5(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=s5(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,t5(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?a5(o,t,n,s,e.kind,m):i5(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=g5(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=g5(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=+(e.lexical>0),r=+(t.lexical>0);if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}const v5=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),y5=globalThis;y5[v5]===void 0&&(y5[v5]=s());const b5=y5[v5],x5=[`.ok`,`skill-state.yml`],S5=[`claude-cowork`,`cli-hosts`],C5=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],w5=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,T5=y({version:k().regex(w5,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(b5,{description:`Recorded skill version for this target.`}),recordedAt:o().register(b5,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:O(C5).register(b5,{description:`Install-source surface that recorded this entry.`}).optional()}),E5=y({enabled:g().register(b5,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:o().register(b5,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),D5=y({schema:v(1).register(b5,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:y({"claude-cowork":T5.optional(),"cli-hosts":T5.optional()}).register(b5,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:h(k(),E5).register(b5,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional(),installsReported:x(k()).register(b5,{description:"Skill installs already reported to skills.sh from this machine, as `<owner/repo>#<skill>`. Append-only; presence suppresses a re-report."}).optional()});function O5(e,t){return e??t.installedOnDisk}function k5(){return{schema:1,targets:{}}}const A5=16*1024*1024,j5=64*1024*1024,M5=y({name:k(),description:k(),files:y({skillMd:k(),scripts:x(k()),references:x(k())})}),N5=y({pluginProvider:k().optional(),plugin:k().optional(),marketplace:k().optional(),version:k().optional(),gitCommitSha:k().optional(),scope:k().optional(),projectPath:k().optional()}),P5=y({commands:g(),hooks:g(),mcp:g()}),F5=y({...M5.shape,sourceHarness:k(),sourceHarnesses:x(k()),home:k(),provenance:N5,inert:P5,outsideProject:g().optional()}),I5=y({schema:v(1),name:k(),version:k(),description:k().optional(),author:y({name:k()}).optional(),skills:x(k()),hostCompatibility:x(k()).optional(),capabilities:y({scripts:k(),network:k(),inert:x(k())}).optional(),provenance:y({source:k(),ref:k(),contentHash:k()}).optional()}),L5=C({skills:x(F5),packs:x(I5)}).loose(),R5=C({results:x(C({id:k().min(1),name:k().min(1),source:k().min(1),description:k(),installs:E().int().nonnegative().nullable(),publisher:k().nullable()}).loose()),backend:O([`skills.sh`,`github-fallback`]),degraded:g()}).loose(),z5=C({title:k(),description:k(),image:k().nullable(),skillsUrl:k().nullable(),sourceKind:O([`github`,`site`]),sourceUrl:k()}).loose(),B5=C({skills:x(C({name:k(),description:k().nullable()}).loose())}).loose(),V5=C({kind:O([`local`,`import`,`none`]),scope:O(ot).optional(),name:k().optional(),dir:k().optional(),source:k().optional(),ref:k().optional(),via:O([`source`,`publisher`]).optional()}).loose(),H5=C({relPath:k(),content:k().nullable()}).loose(),U5=C({provider:k(),plugin:k(),version:k().optional(),marketplace:k().optional(),repositoryUrl:k().optional()}).loose(),W5=C({provider:k(),plugin:k(),version:k().optional(),description:k().optional(),repositoryUrl:k().optional(),bundledSkills:x(k()),capabilities:C({commands:g(),hooks:g(),mcp:g(),agents:g()}),setupSupported:g()}).loose(),G5=C({name:k(),description:k().nullable(),skillMd:k(),files:x(H5),plugin:U5.optional(),pluginBundle:W5.optional()}).loose(),K5=new Set([`project`,`local`]);function q5(e){return e!==void 0&&K5.has(e)?`project`:`global`}function J5(e,t){let n=e=>e.replace(/\/+$/,``);return n(e)===n(t)}function Y5(e,t){if(q5(e.scope)===`global`)return!0;let n=e.projectPath;return n===void 0||t===void 0?!0:J5(n,t)}function X5(e,t,n){if(n===void 0||q5(e.scope)!==`project`)return!1;let r=t.replace(/\/+$/,``),i=n.replace(/\/+$/,``);return r!==i&&!r.startsWith(`${i}/`)}const Z5=/^([\w.-]+)\/([\w.-]+)$/,Q5=/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function $5(e){let t=Z5.exec(e);if(t){let[,e,n]=t;if(e&&n)return{kind:`github`,owner:e,repo:n}}return Q5.test(e)?{kind:`site`,hostname:e}:null}function e7(e,t){let n=$5(e),r=t.trim();if(!n||!r)return null;let i=encodeURIComponent(r);if(n.kind===`github`){let e=encodeURIComponent(n.owner),t=encodeURIComponent(n.repo);return{sourceKind:`github`,skillsUrl:`https://www.skills.sh/${e}/${t}/${i}`,sourceUrl:`https://github.com/${e}/${t}`}}return{sourceKind:`site`,skillsUrl:`https://www.skills.sh/site/${encodeURIComponent(n.hostname)}/${i}`,sourceUrl:`https://${n.hostname}`}}function t7(e){return e.includes(`/`)?e.split(`/`)[0]??null:null}function n7(e){let t=e.split(`/`).pop();return t&&t.length>0?t:e}const r7=`template`;function i7(e){if(e.trim()===``)return{};let t;try{t=(0,Ye.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function a7(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function o7(e){let{frontmatter:t,body:n}=Sm(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:wm(t),markdown:n}}function s7(e){let t=e.split(`
345
- `);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=i7(n.join(`
346
- `))[r7];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
347
- `).replace(/\n+$/,``)}}function c7(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=Sm(t);if(n===``)return{identity:{},starterContent:t};let i=wm(n),a=s7(i);if(a)return{identity:a.identity,starterContent:a7(a.docFrontmatterText,r)};let{frontmatter:o}=Sm(r);if(o!==``)return{identity:i7(i),starterContent:r};let s=i7(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:a7(i,r)}}function l7(e,t){let{docFrontmatterText:n,markdown:r}=o7(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Ye.stringify)({[r7]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function u7(e){return c7(e).starterContent}function d7(){let e=!1,t=``,n=0;return r=>{let i=f7(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function f7(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const p7=/^(#{1,6})\s+(.+)$/;function m7(e,t){let n=(e.endsWith(`\r`)?e.slice(0,-1):e).match(p7);if(!n)return null;let r=n[2].trim(),i=GY(r,t);return i?{level:n[1].length,text:r,slug:i}:null}const h7=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],g7={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function _7(e,t=h7){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const v7={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`,"claude-acp":`claude`,"codex-acp":`openai`,"github-copilot-cli":`github`};function y7(e){return e?v7[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const b7={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function x7(e){let t=e?.trim();return t?b7[y7(t)]??t:`Agent`}function S7(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const C7=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function w7(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function T7(e){let t=e.trim();return C7.test(t)||t.startsWith(`//`)}function E7(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(T7(n))return{kind:`external`,url:n};let r=n.indexOf(`#`),i=r<0?n:n.slice(0,r),a=ht(i,t);if(a)return{kind:`doc`,docName:a,anchor:r<0?null:n.slice(r+1)};let o=mt(i,t);if(o)return{kind:`doc`,docName:o,anchor:r<0?null:n.slice(r+1)};let s=S7(n,t);if(s)return{kind:`doc`,docName:s.docName,anchor:s.anchor};let c=w7(n);return c&&c!==`md`&&c!==`mdx`?{kind:`asset`,url:n,ext:c}:null}function D7(e,t){let n=e.trim();if(!n)return null;if(T7(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=w7(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function O7(e,t){let n=e.trim();if(!n||C7.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function k7(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function A7(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function j7(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function M7(e){return e.split(`/`).filter(e=>e!==``)}function N7(e,t){let n=j7(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function P7(e,t){let n=j7(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:M7(r).length}function F7(e,t){let n=M7(e),r=M7(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function I7(){let e=new Map;function t(t){let n=k7(t);if(n===``)return;let r=A7(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=k7(t),r=A7(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=j7(k7(n)),o=[],s=[];for(let e of i)N7(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=P7(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=P7(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=F7(a,j7(t));for(let r=1;r<e.length;r++){let i=e[r],o=F7(a,j7(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function L7(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function R7(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}export{F2 as $,lb as $a,sX as $i,d$ as $n,Tt as $o,zZ as $r,v$ as $t,R5 as A,PW as Aa,ZX as Ai,o1 as An,Jt as Ao,AQ as Ar,a0 as At,G8 as B,Kb as Ba,LX as Bi,g1 as Bn,zt as Bo,sQ as Br,A1 as Bt,Y5 as C,tY as Ca,uZ as Ci,F$ as Cn,cn as Co,vQ as Cr,Ue as Cs,b0 as Ct,G5 as D,XW as Da,QX as Di,D$ as Dn,on as Do,CQ as Dr,he as Ds,l0 as Dt,B5 as E,LW as Ea,tZ as Ei,E$ as En,$t as Eo,yQ as Er,ve as Es,_0 as Et,w5 as F,dH as Fa,vX as Fi,n1 as Fn,Ut as Fo,cQ as Fr,U1 as Ft,Z2 as G,Gb as Ga,OX as Gi,t$ as Gn,At as Go,ZZ as Gr,w1 as Gt,Z8 as H,Ub as Ha,jX as Hi,T$ as Hn,Ot as Ho,eQ as Hr,k1 as Ht,D5 as I,KR as Ia,MX as Ii,i1 as In,Wt as Io,oQ as Ir,N1 as It,H2 as J,jb as Ja,fX as Ji,f$ as Jn,Mt as Jo,FZ as Jr,b1 as Jt,Q2 as K,Wb as Ka,RX as Ki,m$ as Kn,jt as Ko,WZ as Kr,C1 as Kt,k5 as L,FP as La,yX as Li,a1 as Ln,Bt as Lo,iQ as Lr,R1 as Lt,j5 as M,zU as Ma,BX as Mi,A$ as Mn,Gt as Mo,OQ as Mr,t0 as Mt,x5 as N,wH as Na,VX as Ni,j$ as Nn,Kt as No,YZ as Nr,n0 as Nt,V5 as O,HW as Oa,eZ as Oi,O$ as On,Xt as Oo,wQ as Or,ge as Os,f0 as Ot,S5 as P,fH as Pa,EX as Pi,_$ as Pn,Ht as Po,XZ as Pr,W1 as Pt,z2 as Q,ub as Qa,cX as Qi,u$ as Qn,Et as Qo,UZ as Qr,Q$ as Qt,O5 as R,EN as Ra,NX as Ri,e1 as Rn,Vt as Ro,nQ as Rr,D1 as Rt,q5 as S,nY as Sa,rZ as Si,N$ as Sn,F as So,_Q as Sr,qe as Ss,O0 as St,z5 as T,RW as Ta,KX as Ti,P$ as Tn,Yt as To,xQ as Tr,P as Ts,v0 as Tt,q2 as U,Rb as Ua,gX as Ui,x$ as Un,kt as Uo,QZ as Ur,E1 as Ut,h5 as V,zb as Va,_X as Vi,_1 as Vn,Lt as Vo,lQ as Vr,O1 as Vt,X2 as W,qb as Wa,AX as Wi,r$ as Wn,It as Wo,$Z as Wr,x1 as Wt,V2 as X,Pb as Xa,ZY as Xi,h$ as Xn,Nt as Xo,LZ as Xr,a$ as Xt,R2 as Y,Mb as Ya,hX as Yi,p$ as Yn,Pt as Yo,IZ as Yr,i$ as Yt,B2 as Z,sb as Za,oX as Zi,g$ as Zn,Dt as Zo,HZ as Zr,o$ as Zt,c7 as _,vY as _a,gZ as _i,y1 as _n,Cm as _o,gQ as _r,_t as _s,F0 as _t,D7 as a,IY as aa,OZ as ai,R$ as an,Ib as ao,GQ as ar,et as as,A2 as at,e7 as b,_Y as ba,cZ as bi,$$ as bn,pf as bo,TQ as br,bt as bs,C0 as bt,g7 as c,bY as ca,wZ as ci,q$ as cn,kb as co,WQ as cr,at as cs,_2 as ct,y7 as d,MY as da,bZ as di,U$ as dn,Xy as do,VQ as dr,ct as ds,g2 as dt,UY as ea,RZ as ei,c1 as en,hb as eo,l$ as er,Qe as es,P2 as et,m7 as f,sY as fa,xZ as fi,W$ as fn,Jy as fo,HQ as fr,st as fs,p2 as ft,u7 as g,fY as ga,SZ as gi,h1 as gn,Ry as go,hQ as gr,St as gs,W0 as gt,l7 as h,iY as ha,vZ as hi,C$ as hn,Hy as ho,zQ as hr,yt as hs,H0 as ht,E7 as i,FY as ia,AZ as ii,L$ as in,Fb as io,QQ as ir,tt as is,M2 as it,A5 as j,bW as ja,XX as ji,s1 as jn,qt as jo,DQ as jr,c0 as jt,L5 as k,NW as ka,$X as ki,k$ as kn,sn as ko,kQ as kr,me as ks,i0 as kt,_7 as l,SY as la,TZ as li,K$ as ln,bb as lo,UQ as lr,ot as ls,C2 as lt,r7 as m,pY as ma,_Z as mi,r1 as mn,Gy as mo,RQ as mr,lt as ms,X0 as mt,R7 as n,RY as na,MZ as ni,d1 as nn,_b as no,e$ as nr,nt as ns,L2 as nt,O7 as o,CY as oa,DZ as oi,z$ as on,Ob as oo,KQ as or,dt as os,k2 as ot,d7 as p,cY as pa,CZ as pi,G$ as pn,qy as po,LQ as pr,wt as ps,K0 as pt,K2 as q,Hb as qa,zX as qi,c$ as qn,Ft as qo,GZ as qr,S1 as qt,I7 as r,LY as ra,PZ as ri,M$ as rn,yb as ro,XQ as rr,$e as rs,I2 as rt,S7 as s,EY as sa,jZ as si,B$ as sn,Sb as so,YQ as sr,it as ss,w2 as st,L7 as t,zY as ta,VZ as ti,f1 as tn,mb as to,b$ as tr,rt as ts,N2 as tt,x7 as u,jY as ua,EZ as ui,H$ as un,eb as uo,BQ as ur,Ze as us,h2 as ut,t7 as v,yY as va,sZ as vi,Z$ as vn,Sm as vo,pQ as vr,ft as vs,I0 as vt,X5 as w,IW as wa,pZ as wi,I$ as wn,en as wo,fQ as wr,Je as ws,y0 as wt,n7 as x,hY as xa,iZ as xi,X$ as xn,ea as xo,EQ as xr,Xe as xs,A0 as xt,$5 as y,oY as ya,oZ as yi,m1 as yn,wm as yo,mQ as yr,ht as ys,N0 as yt,q8 as z,Bb as za,PX as zi,t1 as zn,Rt as zo,tQ as zr,j1 as zt};
348
- //# sourceMappingURL=src-TKCctdpc.mjs.map
344
+ `,ANSWER_SESSION_LAST_MESSAGE_IS_NOT_ASSISTANT:`The last message in the session is not an assistant message. Cannot regenerate non-assistant messages.`,PLUGIN_COMPONENT_CONFLICT:`The component "%s" is already defined. The plugin "%s" is trying to redefine it.`};function N4(e,...t){let n=Error(u4(M4[e]??`Unsupported Orama Error code: ${e}`,...t));return n.code=e,`captureStackTrace`in Error.prototype&&Error.captureStackTrace(n),n}function P4(e){return{raw:Number(e),formatted:m4(e)}}function F4(e){if(e.id){if(typeof e.id!=`string`)throw N4(`DOCUMENT_ID_MUST_BE_STRING`,typeof e.id);return e.id}return g4()}function I4(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];if(t!==void 0&&!(r===`geopoint`&&typeof t==`object`&&typeof t.lon==`number`&&typeof t.lat==`number`)&&!(r===`enum`&&(typeof t==`string`||typeof t==`number`))){if(r===`enum[]`&&Array.isArray(t)){let e=t.length;for(let r=0;r<e;r++)if(typeof t[r]!=`string`&&typeof t[r]!=`number`)return n+`.`+r;continue}if(B4(r)){let e=U4(r);if(!Array.isArray(t)||t.length!==e)throw N4(`INVALID_INPUT_VECTOR`,n,e,t.length);continue}if(V4(r)){if(!Array.isArray(t))return n;let e=H4(r),i=t.length;for(let r=0;r<i;r++)if(typeof t[r]!==e)return n+`.`+r;continue}if(typeof r==`object`){if(!t||typeof t!=`object`)return n;let e=I4(t,r);if(e)return n+`.`+e;continue}if(typeof t!==r)return n}}}const L4={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},R4={"string[]":`string`,"number[]":`number`,"boolean[]":`boolean`,"enum[]":`enum`};function z4(e){return e===`geopoint`}function B4(e){return typeof e==`string`&&/^vector\[\d+\]$/.test(e)}function V4(e){return typeof e==`string`&&L4[e]}function H4(e){return R4[e]}function U4(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw N4(`INVALID_VECTOR_VALUE`,e);case t<=0:throw N4(`INVALID_VECTOR_SIZE`,e);default:return t}}function W4(){return{idToInternalId:new Map,internalIdToId:[],save:G4,load:K4}}function G4(e){return{internalIdToId:e.internalIdToId}}function K4(e,t){let{internalIdToId:n}=t;e.internalDocumentIDStore.idToInternalId.clear(),e.internalDocumentIDStore.internalIdToId=[];let r=n.length;for(let t=0;t<r;t++){let r=n[t];e.internalDocumentIDStore.idToInternalId.set(r,t+1),e.internalDocumentIDStore.internalIdToId.push(r)}}function q4(e,t){if(typeof t==`string`){let n=e.idToInternalId.get(t);if(n)return n;let r=e.idToInternalId.size+1;return e.idToInternalId.set(t,r),e.internalIdToId.push(t),r}return t>e.internalIdToId.length?q4(e,t.toString()):t}function J4(e,t){if(e.internalIdToId.length<t)throw Error(`Invalid internalId ${t}`);return e.internalIdToId[t-1]}function Y4(e,t){return{sharedInternalDocumentStore:t,docs:{},count:0}}function X4(e,t){let n=q4(e.sharedInternalDocumentStore,t);return e.docs[n]}function Z4(e,t){let n=t.length,r=Array.from({length:n});for(let i=0;i<n;i++){let n=q4(e.sharedInternalDocumentStore,t[i]);r[i]=e.docs[n]}return r}function Q4(e){return e.docs}function $4(e,t,n,r){return e.docs[n]===void 0?(e.docs[n]=r,e.count++,!0):!1}function e3(e,t){let n=q4(e.sharedInternalDocumentStore,t);return e.docs[n]===void 0?!1:(delete e.docs[n],e.count--,!0)}function t3(e){return e.count}function n3(e,t){let n=t;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:e}}function r3(e){return{docs:e.docs,count:e.count}}function i3(){return{create:Y4,get:X4,getMultiple:Z4,getAll:Q4,store:$4,remove:e3,count:t3,load:n3,save:r3}}const a3=[`beforeInsert`,`afterInsert`,`beforeRemove`,`afterRemove`,`beforeUpdate`,`afterUpdate`,`beforeUpsert`,`afterUpsert`,`beforeSearch`,`afterSearch`,`beforeInsertMultiple`,`afterInsertMultiple`,`beforeRemoveMultiple`,`afterRemoveMultiple`,`beforeUpdateMultiple`,`afterUpdateMultiple`,`beforeUpsertMultiple`,`afterUpsertMultiple`,`beforeLoad`,`afterLoad`,`afterCreate`];function o3(e,t){let n=[],r=e.plugins?.length;if(!r)return n;for(let i=0;i<r;i++)try{let r=e.plugins[i];typeof r[t]==`function`&&n.push(r[t])}catch(e){throw console.error(`Caught error in getAllPluginsByHook:`,e),N4(`PLUGIN_CRASHED`)}return n}const s3=[`tokenizer`,`index`,`documentsStore`,`sorter`,`pinning`],c3=[`validateSchema`,`getDocumentIndexId`,`getDocumentProperties`,`formatElapsedTime`];function l3(e,t,n,r){if(e.some(T4))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function u3(e,t,n){if(e.some(T4))return(async()=>{for(let r of e)await r(t,n)})();for(let r of e)r(t,n)}function d3(e,t,n,r,i){if(e.some(T4))return(async()=>{for(let a of e)await a(t,n,r,i)})();for(let a of e)a(t,n,r,i)}function f3(e,t,n,r){if(e.some(T4))return(async()=>{for(let i of e)await i(t,n,r)})();for(let i of e)i(t,n,r)}function p3(e,t){if(e.some(T4))return(async()=>{for(let n of e)await n(t)})();for(let n of e)n(t)}var m3=class e{k;v;l=null;r=null;h=1;constructor(e,t){this.k=e,this.v=new Set(t)}updateHeight(){this.h=Math.max(e.getHeight(this.l),e.getHeight(this.r))+1}static getHeight(e){return e?e.h:0}getBalanceFactor(){return e.getHeight(this.l)-e.getHeight(this.r)}rotateLeft(){let e=this.r;return this.r=e.l,e.l=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){let e=this.l;return this.l=e.r,e.r=this,this.updateHeight(),e.updateHeight(),e}toJSON(){return{k:this.k,v:Array.from(this.v),l:this.l?this.l.toJSON():null,r:this.r?this.r.toJSON():null,h:this.h}}static fromJSON(t){let n=new e(t.k,t.v);return n.l=t.l?e.fromJSON(t.l):null,n.r=t.r?e.fromJSON(t.r):null,n.h=t.h,n}},h3=class e{root=null;insertCount=0;constructor(e,t){e!==void 0&&t!==void 0&&(this.root=new m3(e,t))}insert(e,t,n=1e3){this.root=this.insertNode(this.root,e,t,n)}insertMultiple(e,t,n=1e3){for(let r of t)this.insert(e,r,n)}rebalance(){this.root&&=this.rebalanceNode(this.root)}toJSON(){return{root:this.root?this.root.toJSON():null,insertCount:this.insertCount}}static fromJSON(t){let n=new e;return n.root=t.root?m3.fromJSON(t.root):null,n.insertCount=t.insertCount||0,n}insertNode(e,t,n,r){if(e===null)return new m3(t,[n]);let i=[],a=e,o=null;for(;a!==null;)if(i.push({parent:o,node:a}),t<a.k)if(a.l===null){a.l=new m3(t,[n]),i.push({parent:a,node:a.l});break}else o=a,a=a.l;else if(t>a.k)if(a.r===null){a.r=new m3(t,[n]),i.push({parent:a,node:a.r});break}else o=a,a=a.r;else return a.v.add(n),e;let s=!1;this.insertCount++%r===0&&(s=!0);for(let t=i.length-1;t>=0;t--){let{parent:n,node:r}=i[t];if(r.updateHeight(),s){let t=this.rebalanceNode(r);n?n.l===r?n.l=t:n.r===r&&(n.r=t):e=t}}return e}rebalanceNode(e){let t=e.getBalanceFactor();if(t>1){if(e.l&&e.l.getBalanceFactor()>=0)return e.rotateRight();if(e.l)return e.l=e.l.rotateLeft(),e.rotateRight()}if(t<-1){if(e.r&&e.r.getBalanceFactor()<=0)return e.rotateLeft();if(e.r)return e.r=e.r.rotateRight(),e.rotateLeft()}return e}find(e){let t=this.findNodeByKey(e);return t?t.v:null}contains(e){return this.find(e)!==null}getSize(){let e=0,t=[],n=this.root;for(;n||t.length>0;){for(;n;)t.push(n),n=n.l;n=t.pop(),e++,n=n.r}return e}isBalanced(){if(!this.root)return!0;let e=[this.root];for(;e.length>0;){let t=e.pop(),n=t.getBalanceFactor();if(Math.abs(n)>1)return!1;t.l&&e.push(t.l),t.r&&e.push(t.r)}return!0}remove(e){this.root=this.removeNode(this.root,e)}removeDocument(e,t){let n=this.findNodeByKey(e);n&&(n.v.size===1?this.root=this.removeNode(this.root,e):n.v=new Set([...n.v.values()].filter(e=>e!==t)))}findNodeByKey(e){let t=this.root;for(;t;)if(e<t.k)t=t.l;else if(e>t.k)t=t.r;else return t;return null}removeNode(e,t){if(e===null)return null;let n=[],r=e;for(;r!==null&&r.k!==t;)n.push(r),r=t<r.k?r.l:r.r;if(r===null)return e;if(r.l===null||r.r===null){let t=r.l?r.l:r.r;if(n.length===0)e=t;else{let e=n[n.length-1];e.l===r?e.l=t:e.r=t}}else{let e=r,t=r.r;for(;t.l!==null;)e=t,t=t.l;r.k=t.k,r.v=t.v,e.l===t?e.l=t.r:e.r=t.r,r=e}n.push(r);for(let t=n.length-1;t>=0;t--){let r=n[t];r.updateHeight();let i=this.rebalanceNode(r);if(t>0){let e=n[t-1];e.l===r?e.l=i:e.r===r&&(e.r=i)}else e=i}return e}rangeSearch(e,t){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),i.k>=e&&i.k<=t)for(let e of i.v)n.add(e);if(i.k>t)break;i=i.r}return n}greaterThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.r;if(i=r.pop(),t&&i.k>=e||!t&&i.k>e)for(let e of i.v)n.add(e);else if(i.k<=e)break;i=i.l}return n}lessThan(e,t=!1){let n=new Set,r=[],i=this.root;for(;i||r.length>0;){for(;i;)r.push(i),i=i.l;if(i=r.pop(),t&&i.k<=e||!t&&i.k<e)for(let e of i.v)n.add(e);else if(i.k>e)break;i=i.r}return n}},g3=class e{numberToDocumentId;constructor(){this.numberToDocumentId=new Map}insert(e,t){this.numberToDocumentId.has(e)?this.numberToDocumentId.get(e).add(t):this.numberToDocumentId.set(e,new Set([t]))}find(e){let t=this.numberToDocumentId.get(e);return t?Array.from(t):null}remove(e){this.numberToDocumentId.delete(e)}removeDocument(e,t){let n=this.numberToDocumentId.get(t);n&&(n.delete(e),n.size===0&&this.numberToDocumentId.delete(t))}contains(e){return this.numberToDocumentId.has(e)}getSize(){let e=0;for(let t of this.numberToDocumentId.values())e+=t.size;return e}filter(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`eq`:{let t=e[n],r=this.numberToDocumentId.get(t);return r?Array.from(r):[]}case`in`:{let t=e[n],r=new Set;for(let e of t){let t=this.numberToDocumentId.get(e);if(t)for(let e of t)r.add(e)}return Array.from(r)}case`nin`:{let t=new Set(e[n]),r=new Set;for(let[e,n]of this.numberToDocumentId.entries())if(!t.has(e))for(let e of n)r.add(e);return Array.from(r)}default:throw Error(`Invalid operation`)}}filterArr(e){let t=Object.keys(e);if(t.length!==1)throw Error(`Invalid operation`);let n=t[0];switch(n){case`containsAll`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e].filter(e=>t.has(e))));return Array.from(r)}case`containsAny`:{let t=e[n].map(e=>this.numberToDocumentId.get(e)??new Set);if(t.length===0)return[];let r=t.reduce((e,t)=>new Set([...e,...t]));return Array.from(r)}default:throw Error(`Invalid operation`)}}static fromJSON(t){if(!t.numberToDocumentId)throw Error(`Invalid Flat Tree JSON`);let n=new e;for(let[e,r]of t.numberToDocumentId)n.numberToDocumentId.set(e,new Set(r));return n}toJSON(){return{numberToDocumentId:Array.from(this.numberToDocumentId.entries()).map(([e,t])=>[e,Array.from(t)])}}};function _3(e,t,n){if(n<0)return-1;if(e===t)return 0;let r=e.length,i=t.length;if(r===0)return i<=n?i:-1;if(i===0)return r<=n?r:-1;let a=Math.abs(r-i);if(e.startsWith(t))return a<=n?a:-1;if(t.startsWith(e))return 0;if(a>n)return-1;let o=[];for(let e=0;e<=r;e++){o[e]=[e];for(let t=1;t<=i;t++)o[e][t]=e===0?t:0}for(let a=1;a<=r;a++){let r=1/0;for(let n=1;n<=i;n++)e[a-1]===t[n-1]?o[a][n]=o[a-1][n-1]:o[a][n]=Math.min(o[a-1][n]+1,o[a][n-1]+1,o[a-1][n-1]+1),r=Math.min(r,o[a][n]);if(r>n)return-1}return o[r][i]<=n?o[r][i]:-1}function v3(e,t,n){let r=_3(e,t,n);return{distance:r,isBounded:r>=0}}var y3=class e{k;s;c=new Map;d=new Set;e;w=``;constructor(e,t,n){this.k=e,this.s=t,this.e=n}updateParent(e){this.w=e.w+this.s}addDocument(e){this.d.add(e)}removeDocument(e){return this.d.delete(e)}findAllWords(e,t,n,r){let i=[this];for(;i.length>0;){let a=i.pop();if(a.e){let{w:i,d:o}=a;if(n&&i!==t)continue;if(_4(e,i)!==null)if(r)if(Math.abs(t.length-i.length)<=r&&v3(t,i,r).isBounded)e[i]=[];else continue;else e[i]=[];if(_4(e,i)!=null&&o.size>0){let t=e[i];for(let e of o)t.includes(e)||t.push(e)}}a.c.size>0&&i.push(...a.c.values())}return e}insert(t,n){let r=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=r.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c){if(r=s,i+=l,i===a){s.e||=!0,s.addDocument(n);return}continue}let u=o.slice(0,l),d=o.slice(l),f=t.slice(i+l),p=new e(u[0],u,!1);if(r.c.set(u[0],p),p.updateParent(r),s.s=d,s.k=d[0],p.c.set(d[0],s),s.updateParent(p),f){let t=new e(f[0],f,!0);t.addDocument(n),p.c.set(f[0],t),t.updateParent(p)}else p.e=!0,p.addDocument(n);return}else{let a=new e(o,t.slice(i),!0);a.addDocument(n),r.c.set(o,a),a.updateParent(r);return}}r.e||=!0,r.addDocument(n)}_findLevenshtein(e,t,n,r,i){let a=[{node:this,index:t,tolerance:n}];for(;a.length>0;){let{node:t,index:n,tolerance:o}=a.pop();if(t.w.startsWith(e)){t.findAllWords(i,e,!1,0);continue}if(o<0)continue;if(t.e){let{w:n,d:a}=t;if(n&&(v3(e,n,r).isBounded&&(i[n]=[]),_4(i,n)!==void 0&&a.size>0)){let e=new Set(i[n]);for(let t of a)e.add(t);i[n]=Array.from(e)}}if(n>=e.length)continue;let s=e[n];if(t.c.has(s)){let e=t.c.get(s);a.push({node:e,index:n+1,tolerance:o})}a.push({node:t,index:n+1,tolerance:o-1});for(let[e,r]of t.c)a.push({node:r,index:n,tolerance:o-1}),e!==s&&a.push({node:r,index:n+1,tolerance:o-1})}}find(e){let{term:t,exact:n,tolerance:r}=e;if(r&&!n){let e={};return this._findLevenshtein(t,0,r,r,e),e}else{let e=this,i=0,a=t.length;for(;i<a;){let o=t[i],s=e.c.get(o);if(s){let o=s.s,c=o.length,l=0;for(;l<c&&i+l<a&&o[l]===t[i+l];)l++;if(l===c)e=s,i+=l;else if(i+l===a)if(l===a-i){if(n)return{};{let e={};return s.findAllWords(e,t,n,r),e}}else return{};else return{}}else return{}}let o={};return e.findAllWords(o,t,n,r),o}}contains(e){let t=this,n=0,r=e.length;for(;n<r;){let i=e[n],a=t.c.get(i);if(a){let i=a.s,o=i.length,s=0;for(;s<o&&n+s<r&&i[s]===e[n+s];)s++;if(s<o)return!1;n+=o,t=a}else return!1}return!0}removeWord(e){if(!e)return!1;let t=this,n=e.length,r=[];for(let i=0;i<n;i++){let n=e[i];if(t.c.has(n)){let e=t.c.get(n);r.push({parent:t,character:n}),i+=e.s.length-1,t=e}else return!1}for(t.d.clear(),t.e=!1;r.length>0&&t.c.size===0&&!t.e&&t.d.size===0;){let{parent:e,character:n}=r.pop();e.c.delete(n),t=e}return!0}removeDocumentByWord(e,t,n=!0){if(!e)return!0;let r=this,i=e.length;for(let a=0;a<i;a++){let i=e[a];if(r.c.has(i)){let o=r.c.get(i);a+=o.s.length-1,r=o,n&&r.w!==e||r.removeDocument(t)}else return!1}return!0}static getCommonPrefix(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return e.slice(0,r)}toJSON(){return{w:this.w,s:this.s,e:this.e,k:this.k,d:Array.from(this.d),c:Array.from(this.c?.entries())?.map(([e,t])=>[e,t.toJSON()])}}static fromJSON(t){let n=new e(t.k,t.s,t.e);return n.w=t.w,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([t,n])=>[t,e.fromJSON(n)])||[]),n}},b3=class e extends y3{constructor(){super(``,``,!1)}static fromJSON(t){let n=new e;return n.w=t.w,n.s=t.s,n.e=t.e,n.k=t.k,n.d=new Set(t.d),n.c=new Map(t?.c?.map(([e,t])=>[e,y3.fromJSON(t)])||[]),n}toJSON(){return super.toJSON()}},x3=class e{point;docIDs;left;right;parent;constructor(e,t){this.point=e,this.docIDs=new Set(t),this.left=null,this.right=null,this.parent=null}toJSON(){return{point:this.point,docIDs:Array.from(this.docIDs),left:this.left?this.left.toJSON():null,right:this.right?this.right.toJSON():null}}static fromJSON(t,n=null){let r=new e(t.point,t.docIDs);return r.parent=n,t.left&&(r.left=e.fromJSON(t.left,r)),t.right&&(r.right=e.fromJSON(t.right,r)),r}},S3=class e{root;nodeMap;constructor(){this.root=null,this.nodeMap=new Map}getPointKey(e){return`${e.lon},${e.lat}`}insert(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);if(r){t.forEach(e=>r.docIDs.add(e));return}let i=new x3(e,t);if(this.nodeMap.set(n,i),this.root==null){this.root=i;return}let a=this.root,o=0;for(;;){if(o%2==0)if(e.lon<a.point.lon){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}else if(e.lat<a.point.lat){if(a.left==null){a.left=i,i.parent=a;return}a=a.left}else{if(a.right==null){a.right=i,i.parent=a;return}a=a.right}o++}}contains(e){let t=this.getPointKey(e);return this.nodeMap.has(t)}getDocIDsByCoordinates(e){let t=this.getPointKey(e),n=this.nodeMap.get(t);return n?Array.from(n.docIDs):null}removeDocByID(e,t){let n=this.getPointKey(e),r=this.nodeMap.get(n);r&&(r.docIDs.delete(t),r.docIDs.size===0&&(this.nodeMap.delete(n),this.deleteNode(r)))}deleteNode(e){let t=e.parent,n=e.left?e.left:e.right;n&&(n.parent=t),t?t.left===e?t.left=n:t.right===e&&(t.right=n):(this.root=n,this.root&&(this.root.parent=null))}searchByRadius(t,n,r=!0,i=`asc`,a=!1){let o=a?e.vincentyDistance:e.haversineDistance,s=[{node:this.root,depth:0}],c=[];for(;s.length>0;){let{node:e,depth:i}=s.pop();if(e==null)continue;let a=o(t,e.point);(r?a<=n:a>n)&&c.push({point:e.point,docIDs:Array.from(e.docIDs)}),e.left!=null&&s.push({node:e.left,depth:i+1}),e.right!=null&&s.push({node:e.right,depth:i+1})}return i&&c.sort((e,n)=>{let r=o(t,e.point),a=o(t,n.point);return i.toLowerCase()===`asc`?r-a:a-r}),c}searchByPolygon(t,n=!0,r=null,i=!1){let a=[{node:this.root,depth:0}],o=[];for(;a.length>0;){let{node:r,depth:i}=a.pop();if(r==null)continue;r.left!=null&&a.push({node:r.left,depth:i+1}),r.right!=null&&a.push({node:r.right,depth:i+1});let s=e.isPointInPolygon(t,r.point);(s&&n||!s&&!n)&&o.push({point:r.point,docIDs:Array.from(r.docIDs)})}let s=e.calculatePolygonCentroid(t);if(r){let t=i?e.vincentyDistance:e.haversineDistance;o.sort((e,n)=>{let i=t(s,e.point),a=t(s,n.point);return r.toLowerCase()===`asc`?i-a:a-i})}return o}toJSON(){return{root:this.root?this.root.toJSON():null}}static fromJSON(t){let n=new e;return t.root&&(n.root=x3.fromJSON(t.root),n.buildNodeMap(n.root)),n}buildNodeMap(e){if(e==null)return;let t=this.getPointKey(e.point);this.nodeMap.set(t,e),e.left&&this.buildNodeMap(e.left),e.right&&this.buildNodeMap(e.right)}static calculatePolygonCentroid(e){let t=0,n=0,r=0,i=e.length;for(let a=0,o=i-1;a<i;o=a++){let i=e[a].lon,s=e[a].lat,c=e[o].lon,l=e[o].lat,u=i*l-c*s;t+=u,n+=(i+c)*u,r+=(s+l)*u}t/=2;let a=6*t;return n/=a,r/=a,{lon:n,lat:r}}static isPointInPolygon(e,t){let n=!1,r=t.lon,i=t.lat,a=e.length;for(let t=0,o=a-1;t<a;o=t++){let a=e[t].lon,s=e[t].lat,c=e[o].lon,l=e[o].lat;s>i!=l>i&&r<(c-a)*(i-s)/(l-s)+a&&(n=!n)}return n}static haversineDistance(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=(t.lat-e.lat)*n,o=(t.lon-e.lon)*n,s=Math.sin(a/2)*Math.sin(a/2)+Math.cos(r)*Math.cos(i)*Math.sin(o/2)*Math.sin(o/2);return 6371e3*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}static vincentyDistance(e,t){let n=6378137,r=1/298.257223563,i=(1-r)*n,a=Math.PI/180,o=e.lat*a,s=t.lat*a,c=(t.lon-e.lon)*a,l=Math.atan((1-r)*Math.tan(o)),u=Math.atan((1-r)*Math.tan(s)),d=Math.sin(l),f=Math.cos(l),p=Math.sin(u),m=Math.cos(u),h=c,g,_=1e3,v,y,b,x,S,C;do{let e=Math.sin(h),t=Math.cos(h);if(v=Math.sqrt(m*e*(m*e)+(f*p-d*m*t)*(f*p-d*m*t)),v===0)return 0;y=d*p+f*m*t,b=Math.atan2(v,y),x=f*m*e/v,S=1-x*x,C=y-2*d*p/S,isNaN(C)&&(C=0);let n=r/16*S*(4+r*(4-3*S));g=h,h=c+(1-n)*r*x*(b+n*v*(C+n*y*(-1+2*C*C)))}while(Math.abs(h-g)>1e-12&&--_>0);if(_===0)return NaN;let w=S*(n*n-i*i)/(i*i),T=1+w/16384*(4096+w*(-768+w*(320-175*w))),E=w/1024*(256+w*(-128+w*(74-47*w))),D=E*v*(C+E/4*(y*(-1+2*C*C)-E/6*C*(-3+4*v*v)*(-3+4*C*C)));return i*T*(b-D)}},C3=class e{true;false;constructor(){this.true=new Set,this.false=new Set}insert(e,t){t?this.true.add(e):this.false.add(e)}delete(e,t){t?this.true.delete(e):this.false.delete(e)}getSize(){return this.true.size+this.false.size}toJSON(){return{true:Array.from(this.true),false:Array.from(this.false)}}static fromJSON(t){let n=new e;return n.true=new Set(t.true),n.false=new Set(t.false),n}};function w3(e,t,n,r,i,{k:a,b:o,d:s}){return Math.log(1+(n-t+.5)/(t+.5))*(s+e*(a+1))/(e+a*(1-o+o*r/i))}var T3=class e{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let n=E3(t,this.size);this.vectors.set(e,[n,t])}remove(e){this.vectors.delete(e)}find(e,t,n){return e instanceof Float32Array||(e=new Float32Array(e)),D3(e,n,this.vectors,this.size,t)}toJSON(){let e=[];for(let[t,[n,r]]of this.vectors)e.push([t,[n,Array.from(r)]]);return{size:this.size,vectors:e}}static fromJSON(t){let n=t,r=new e(n.size);for(let[e,[t,i]]of n.vectors)r.vectors.set(e,[t,new Float32Array(i)]);return r}};function E3(e,t){let n=0;for(let r=0;r<t;r++)n+=e[r]*e[r];return Math.sqrt(n)}function D3(e,t,n,r,i){let a=E3(e,r),o=[],s=t||n.keys();for(let t of s){let s=n.get(t);if(!s)continue;let c=s[0],l=s[1],u=0;for(let t=0;t<r;t++)u+=e[t]*l[t];let d=u/(a*c);d>=i&&o.push([t,d])}return o}function O3(e,t,n,r,i){let a=q4(e.sharedInternalDocumentStore,n);e.avgFieldLength[t]=((e.avgFieldLength[t]??0)*(i-1)+r.length)/i,e.fieldLengths[t][a]=r.length,e.frequencies[t][a]={}}function k3(e,t,n,r,i){let a=0;for(let e of r)e===i&&a++;let o=q4(e.sharedInternalDocumentStore,n),s=a/r.length;e.frequencies[t][o][i]=s,i in e.tokenOccurrences[t]||(e.tokenOccurrences[t][i]=0),e.tokenOccurrences[t][i]=(e.tokenOccurrences[t][i]??0)+1}function A3(e,t,n,r){let i=q4(e.sharedInternalDocumentStore,n);r>1?e.avgFieldLength[t]=(e.avgFieldLength[t]*r-e.fieldLengths[t][i])/(r-1):e.avgFieldLength[t]=void 0,e.fieldLengths[t][i]=void 0,e.frequencies[t][i]=void 0}function j3(e,t,n){e.tokenOccurrences[t][n]--}function M3(e,t,n,r,i=``){r||={sharedInternalDocumentStore:t,indexes:{},vectorIndexes:{},searchableProperties:[],searchablePropertiesWithTypes:{},frequencies:{},tokenOccurrences:{},avgFieldLength:{},fieldLengths:{}};for(let[a,o]of Object.entries(n)){let n=`${i}${i?`.`:``}${a}`;if(typeof o==`object`&&!Array.isArray(o)){M3(e,t,o,r,n);continue}if(B4(o))r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o,r.vectorIndexes[n]={type:`Vector`,node:new T3(U4(o)),isArray:!1};else{let e=/\[/.test(o);switch(o){case`boolean`:case`boolean[]`:r.indexes[n]={type:`Bool`,node:new C3,isArray:e};break;case`number`:case`number[]`:r.indexes[n]={type:`AVL`,node:new h3(0,[]),isArray:e};break;case`string`:case`string[]`:r.indexes[n]={type:`Radix`,node:new b3,isArray:e},r.avgFieldLength[n]=0,r.frequencies[n]={},r.tokenOccurrences[n]={},r.fieldLengths[n]={};break;case`enum`:case`enum[]`:r.indexes[n]={type:`Flat`,node:new g3,isArray:e};break;case`geopoint`:r.indexes[n]={type:`BKD`,node:new S3,isArray:e};break;default:throw N4(`INVALID_SCHEMA_TYPE`,Array.isArray(o)?`array`:o,n)}r.searchableProperties.push(n),r.searchablePropertiesWithTypes[n]=o}}return r}function N3(e,t,n,r,i,a,o,s){return c=>{let{type:l,node:u}=t.indexes[n];switch(l){case`Bool`:u[c?`true`:`false`].add(r);break;case`AVL`:{let e=s?.avlRebalanceThreshold??1;u.insert(c,r,e);break}case`Radix`:{let s=a.tokenize(c,i,n,!1);e.insertDocumentScoreParameters(t,n,r,s,o);for(let i of s)e.insertTokenScoreParameters(t,n,r,s,i),u.insert(i,r);break}case`Flat`:u.insert(c,r);break;case`BKD`:u.insert(c,[r]);break}}}function P3(e,t,n,r,i,a,o,s,c,l,u){if(B4(o))return F3(t,n,a,r,i);let d=N3(e,t,n,i,s,c,l,u);if(!V4(o))return d(a);let f=a,p=f.length;for(let e=0;e<p;e++)d(f[e])}function F3(e,t,n,r,i){e.vectorIndexes[t].node.add(i,n)}function I3(e,t,n,r,i,a,o,s,c,l){if(B4(o))return t.vectorIndexes[n].node.remove(i),!0;let{type:u,node:d}=t.indexes[n];switch(u){case`AVL`:return d.removeDocument(a,i),!0;case`Bool`:return d[a?`true`:`false`].delete(i),!0;case`Radix`:{let o=c.tokenize(a,s,n);e.removeDocumentScoreParameters(t,n,r,l);for(let r of o)e.removeTokenScoreParameters(t,n,r),d.removeDocumentByWord(r,i);return!0}case`Flat`:return d.removeDocument(i,a),!0;case`BKD`:return d.removeDocByID(a,i),!1}}function L3(e,t,n,r,i,a,o,s,c,l){if(!V4(o))return I3(e,t,n,r,i,a,o,s,c,l);let u=H4(o),d=a,f=d.length;for(let a=0;a<f;a++)I3(e,t,n,r,i,d[a],u,s,c,l);return!0}function R3(e,t,n,r,i,a,o,s,c,l){let u=Array.from(r),d=e.avgFieldLength[t],f=e.fieldLengths[t],p=e.tokenOccurrences[t],m=e.frequencies[t],h=typeof p[n]==`number`?p[n]??0:0,g=u.length;for(let e=0;e<g;e++){let r=u[e];if(c&&!c.has(r))continue;l.has(r)||l.set(r,new Map);let p=l.get(r);p.set(t,(p.get(t)||0)+1);let g=w3(m?.[r]?.[n]??0,h,i,f[r],d,a);o.has(r)?o.set(r,o.get(r)+g*s):o.set(r,g*s)}}function z3(e,t,n,r,i,a,o,s,c,l,u,d=0){let f=n.tokenize(t,r),p=f.length||1,m=new Map,h=new Map,g=new Map;for(let n of i){if(!(n in e.indexes))continue;let r=e.indexes[n],{type:i}=r;if(i!==`Radix`)throw N4(`WRONG_SEARCH_PROPERTY_TYPE`,n);let d=s[n]??1;if(d<=0)throw N4(`INVALID_BOOST_VALUE`,d);f.length===0&&!t&&f.push(``);let p=f.length;for(let t=0;t<p;t++){let i=f[t],s=r.node.find({term:i,exact:a,tolerance:o}),p=Object.keys(s);p.length>0&&h.set(i,!0);let _=p.length;for(let t=0;t<_;t++){let r=p[t],i=s[r];R3(e,n,r,i,l,c,g,d,u,m)}}}let _=Array.from(g.entries()).map(([e,t])=>[e,t]).sort((e,t)=>t[1]-e[1]);if(_.length===0)return[];if(d===1)return _;if(d===0){if(p===1)return _;for(let e of f)if(!h.get(e))return[];return _.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1})}let v=_.filter(([e])=>{let t=m.get(e);return t?Array.from(t.values()).some(e=>e===p):!1});if(v.length>0){let e=_.filter(([e])=>!v.some(([t])=>t===e)),t=Math.ceil(e.length*d);return[...v,...e.slice(0,t)]}return _}function B3(e,t,n,r){if(`and`in n&&n.and&&Array.isArray(n.and)){let i=n.and;return i.length===0?new Set:D4(...i.map(n=>B3(e,t,n,r)))}if(`or`in n&&n.or&&Array.isArray(n.or)){let i=n.or;return i.length===0?new Set:i.map(n=>B3(e,t,n,r)).reduce((e,t)=>k4(e,t),new Set)}if(`not`in n&&n.not){let i=n.not,a=new Set,o=e.sharedInternalDocumentStore;for(let e=1;e<=o.internalIdToId.length;e++)a.add(e);return A4(a,B3(e,t,i,r))}let i=Object.keys(n),a=i.reduce((e,t)=>({[t]:new Set,...e}),{});for(let o of i){let i=n[o];if(e.indexes[o]===void 0)throw N4(`UNKNOWN_FILTER_PROPERTY`,o);let{node:s,type:c,isArray:l}=e.indexes[o];if(c===`Bool`){let e=s,t=i?e.true:e.false;a[o]=k4(a[o],t);continue}if(c===`BKD`){let e;if(`radius`in i)e=`radius`;else if(`polygon`in i)e=`polygon`;else throw Error(`Invalid operation ${i}`);if(e===`radius`){let{value:t,coordinates:n,unit:r=`m`,inside:c=!0,highPrecision:l=!1}=i[e],u=C4(t,r),d=s.searchByRadius(n,u,c,void 0,l);a[o]=K3(a[o],d)}else{let{coordinates:t,inside:n=!0,highPrecision:r=!1}=i[e],c=s.searchByPolygon(t,n,void 0,r);a[o]=K3(a[o],c)}continue}if(c===`Radix`&&(typeof i==`string`||Array.isArray(i))){for(let e of[i].flat()){let n=t.tokenize(e,r,o);for(let e of n){let t=s.find({term:e,exact:!0});a[o]=X3(a[o],t)}}continue}let u=Object.keys(i);if(u.length>1)throw N4(`INVALID_FILTER_OPERATION`,u.length);if(c===`Flat`){let e=new Set(l?s.filterArr(i):s.filter(i));a[o]=k4(a[o],e);continue}if(c===`AVL`){let e=u[0],t=i[e],n;switch(e){case`gt`:n=s.greaterThan(t,!1);break;case`gte`:n=s.greaterThan(t,!0);break;case`lt`:n=s.lessThan(t,!1);break;case`lte`:n=s.lessThan(t,!0);break;case`eq`:n=s.find(t)??new Set;break;case`between`:{let[e,r]=t;n=s.rangeSearch(e,r);break}default:throw N4(`INVALID_FILTER_OPERATION`,e)}a[o]=k4(a[o],n)}}return D4(...Object.values(a))}function V3(e){return e.searchableProperties}function H3(e){return e.searchablePropertiesWithTypes}function U3(e,t){let{indexes:n,vectorIndexes:r,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}=t,u={},d={};for(let e of Object.keys(n)){let{node:t,type:r,isArray:i}=n[e];switch(r){case`Radix`:u[e]={type:`Radix`,node:b3.fromJSON(t),isArray:i};break;case`Flat`:u[e]={type:`Flat`,node:g3.fromJSON(t),isArray:i};break;case`AVL`:u[e]={type:`AVL`,node:h3.fromJSON(t),isArray:i};break;case`BKD`:u[e]={type:`BKD`,node:S3.fromJSON(t),isArray:i};break;case`Bool`:u[e]={type:`Bool`,node:C3.fromJSON(t),isArray:i};break;default:u[e]=n[e]}}for(let e of Object.keys(r))d[e]={type:`Vector`,isArray:!1,node:T3.fromJSON(r[e])};return{sharedInternalDocumentStore:e,indexes:u,vectorIndexes:d,searchableProperties:i,searchablePropertiesWithTypes:a,frequencies:o,tokenOccurrences:s,avgFieldLength:c,fieldLengths:l}}function W3(e){let{indexes:t,vectorIndexes:n,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}=e,l={};for(let e of Object.keys(n))l[e]=n[e].node.toJSON();let u={};for(let e of Object.keys(t)){let{type:n,node:r,isArray:i}=t[e];n===`Flat`||n===`Radix`||n===`AVL`||n===`BKD`||n===`Bool`?u[e]={type:n,node:r.toJSON(),isArray:i}:(u[e]=t[e],u[e].node=u[e].node.toJSON())}return{indexes:u,vectorIndexes:l,searchableProperties:r,searchablePropertiesWithTypes:i,frequencies:a,tokenOccurrences:o,avgFieldLength:s,fieldLengths:c}}function G3(){return{create:M3,insert:P3,remove:L3,insertDocumentScoreParameters:O3,insertTokenScoreParameters:k3,removeDocumentScoreParameters:A3,removeTokenScoreParameters:j3,calculateResultScores:R3,search:z3,searchByWhereClause:B3,getSearchableProperties:V3,getSearchablePropertiesWithTypes:H3,load:U3,save:W3}}function K3(e,t){e||=new Set;let n=t.length;for(let r=0;r<n;r++){let n=t[r].docIDs,i=n.length;for(let t=0;t<i;t++)e.add(n[t])}return e}function q3(e,t,n=!1){let r=n?S3.vincentyDistance:S3.haversineDistance,i=[],a=[];for(let{point:n}of e)a.push(r(t,n));let o=Math.max(...a),s=0;for(let{docIDs:t}of e){let e=o-a[s]+1;for(let n of t)i.push([n,e]);s++}return i.sort((e,t)=>t[1]-e[1]),i}function J3(e,t){let n=Object.keys(e);if(n.length!==1)return{isGeoOnly:!1};let r=n[0],i=e[r];if(t.indexes[r]===void 0)return{isGeoOnly:!1};let{type:a}=t.indexes[r];return a===`BKD`&&i&&(`radius`in i||`polygon`in i)?{isGeoOnly:!0,geoProperty:r,geoOperation:i}:{isGeoOnly:!1}}function Y3(e,t){let n=e,r=J3(t,n);if(!r.isGeoOnly||!r.geoProperty||!r.geoOperation)return null;let{node:i}=n.indexes[r.geoProperty],a=r.geoOperation,o=i,s;if(`radius`in a){let{value:e,coordinates:t,unit:n=`m`,inside:r=!0,highPrecision:i=!1}=a.radius,c=t,l=C4(e,n);return s=o.searchByRadius(c,l,r,`asc`,i),q3(s,c,i)}else if(`polygon`in a){let{coordinates:e,inside:t=!0,highPrecision:n=!1}=a.polygon;s=o.searchByPolygon(e,t,`asc`,n);let r=S3.calculatePolygonCentroid(e);return q3(s,r,n)}return null}function X3(e,t){e||=new Set;let n=Object.keys(t),r=n.length;for(let i=0;i<r;i++){let r=t[n[i]],a=r.length;for(let t=0;t<a;t++)e.add(r[t])}return e}function Z3(e,t,n,r,i){let a={language:e.tokenizer.language,sharedInternalDocumentStore:t,enabled:!0,isSorted:!0,sortableProperties:[],sortablePropertiesWithTypes:{},sorts:{}};for(let[o,s]of Object.entries(n)){let n=`${i}${i?`.`:``}${o}`;if(!r.includes(n)){if(typeof s==`object`&&!Array.isArray(s)){let i=Z3(e,t,s,r,n);l4(a.sortableProperties,i.sortableProperties),a.sorts={...a.sorts,...i.sorts},a.sortablePropertiesWithTypes={...a.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!B4(s))switch(s){case`boolean`:case`number`:case`string`:a.sortableProperties.push(n),a.sortablePropertiesWithTypes[n]=s,a.sorts[n]={docs:new Map,orderedDocsToRemove:new Map,orderedDocs:[],type:s};break;case`geopoint`:case`enum`:continue;case`enum[]`:case`boolean[]`:case`number[]`:case`string[]`:continue;default:throw N4(`INVALID_SORT_SCHEMA_TYPE`,Array.isArray(s)?`array`:s,n)}}}return a}function Q3(e,t,n,r){return r?.enabled===!1?{disabled:!0}:Z3(e,t,n,(r||{}).unsortableProperties||[],``)}function $3(e,t,n,r){if(!e.enabled)return;e.isSorted=!1;let i=q4(e.sharedInternalDocumentStore,n),a=e.sorts[t];a.orderedDocsToRemove.has(i)&&o6(e,t),a.docs.set(i,a.orderedDocs.length),a.orderedDocs.push([i,r])}function e6(e){if(e.isSorted||!e.enabled)return;let t=Object.keys(e.sorts);for(let n of t)i6(e,n);e.isSorted=!0}function t6(e,t,n){return t[1].localeCompare(n[1],n4(e))}function n6(e,t){return e[1]-t[1]}function r6(e,t){return t[1]?-1:1}function i6(e,t){let n=e.sorts[t],r;switch(n.type){case`string`:r=t6.bind(null,e.language);break;case`number`:r=n6.bind(null);break;case`boolean`:r=r6.bind(null);break}n.orderedDocs.sort(r);let i=n.orderedDocs.length;for(let e=0;e<i;e++){let t=n.orderedDocs[e][0];n.docs.set(t,e)}}function a6(e){let t=Object.keys(e.sorts);for(let n of t)o6(e,n)}function o6(e,t){let n=e.sorts[t];n.orderedDocsToRemove.size&&(n.orderedDocs=n.orderedDocs.filter(e=>!n.orderedDocsToRemove.has(e[0])),n.orderedDocsToRemove.clear())}function s6(e,t,n){if(!e.enabled)return;let r=e.sorts[t],i=q4(e.sharedInternalDocumentStore,n);r.docs.get(i)&&(r.docs.delete(i),r.orderedDocsToRemove.set(i,!0))}function c6(e,t,n){if(!e.enabled)throw N4(`SORT_DISABLED`);let r=n.property,i=n.order===`DESC`,a=e.sorts[r];if(!a)throw N4(`UNABLE_TO_SORT_ON_UNKNOWN_FIELD`,r,e.sortableProperties.join(`, `));return o6(e,r),e6(e),t.sort((t,n)=>{let r=a.docs.get(q4(e.sharedInternalDocumentStore,t[0])),o=a.docs.get(q4(e.sharedInternalDocumentStore,n[0])),s=r!==void 0,c=o!==void 0;return!s&&!c?0:s?c?i?o-r:r-o:-1:1}),t}function l6(e){return e.enabled?e.sortableProperties:[]}function u6(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function d6(e,t){let n=t;if(!n.enabled)return{enabled:!1};let r=Object.keys(n.sorts).reduce((e,t)=>{let{docs:r,orderedDocs:i,type:a}=n.sorts[t];return e[t]={docs:new Map(Object.entries(r).map(([e,t])=>[+e,t])),orderedDocsToRemove:new Map,orderedDocs:i,type:a},e},{});return{sharedInternalDocumentStore:e,language:n.language,sortableProperties:n.sortableProperties,sortablePropertiesWithTypes:n.sortablePropertiesWithTypes,sorts:r,enabled:!0,isSorted:n.isSorted}}function f6(e){if(!e.enabled)return{enabled:!1};a6(e),e6(e);let t=Object.keys(e.sorts).reduce((t,n)=>{let{docs:r,orderedDocs:i,type:a}=e.sorts[n];return t[n]={docs:Object.fromEntries(r.entries()),orderedDocs:i,type:a},t},{});return{language:e.language,sortableProperties:e.sortableProperties,sortablePropertiesWithTypes:e.sortablePropertiesWithTypes,sorts:t,enabled:e.enabled,isSorted:e.isSorted}}function p6(){return{create:Q3,insert:$3,remove:s6,save:f6,load:d6,sortBy:c6,getSortableProperties:l6,getSortablePropertiesWithTypes:u6}}const m6=[65,65,65,65,65,65,65,67,69,69,69,69,73,73,73,73,69,78,79,79,79,79,79,null,79,85,85,85,85,89,80,115,97,97,97,97,97,97,97,99,101,101,101,101,105,105,105,105,101,110,111,111,111,111,111,null,111,117,117,117,117,121,112,121,65,97,65,97,65,97,67,99,67,99,67,99,67,99,68,100,68,100,69,101,69,101,69,101,69,101,69,101,71,103,71,103,71,103,71,103,72,104,72,104,73,105,73,105,73,105,73,105,73,105,73,105,74,106,75,107,107,76,108,76,108,76,108,76,108,76,108,78,110,78,110,78,110,110,78,110,79,111,79,111,79,111,79,111,82,114,82,114,82,114,83,115,83,115,83,115,83,115,84,116,84,116,84,116,85,117,85,117,85,117,85,117,85,117,85,117,87,119,89,121,89,90,122,90,122,90,122,115];function h6(e){return e<192||e>383?e:m6[e-192]||e}function g6(e){let t=[];for(let n=0;n<e.length;n++)t[n]=h6(e.charCodeAt(n));return String.fromCharCode(...t)}const _6={ational:`ate`,tional:`tion`,enci:`ence`,anci:`ance`,izer:`ize`,bli:`ble`,alli:`al`,entli:`ent`,eli:`e`,ousli:`ous`,ization:`ize`,ation:`ate`,ator:`ate`,alism:`al`,iveness:`ive`,fulness:`ful`,ousness:`ous`,aliti:`al`,iviti:`ive`,biliti:`ble`,logi:`log`},v6={icate:`ic`,ative:``,alize:`al`,iciti:`ic`,ical:`ic`,ful:``,ness:``},y6=`[aeiouy]`,b6=`[^aeiou][^aeiouy]*`;y6+``;const x6=`^(`+b6+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*`;``+b6;const S6=`^(`+b6+`)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*`,C6=`^(`+b6+`)?[aeiouy]`;function w6(e){let t,n,r,i,a,o;if(e.length<3)return e;let s=e.substring(0,1);if(s==`y`&&(e=s.toUpperCase()+e.substring(1)),r=/^(.+?)(ss|i)es$/,i=/^(.+?)([^s])s$/,r.test(e)?e=e.replace(r,`$1$2`):i.test(e)&&(e=e.replace(i,`$1$2`)),r=/^(.+?)eed$/,i=/^(.+?)(ed|ing)$/,r.test(e)){let t=r.exec(e);r=new RegExp(x6),r.test(t[1])&&(r=/.$/,e=e.replace(r,``))}else i.test(e)&&(t=i.exec(e)[1],i=new RegExp(C6),i.test(t)&&(e=t,i=/(at|bl|iz)$/,a=RegExp(`([^aeiouylsz])\\1$`),o=RegExp(`^`+b6+y6+`[^aeiouwxy]$`),i.test(e)?e+=`e`:a.test(e)?(r=/.$/,e=e.replace(r,``)):o.test(e)&&(e+=`e`)));if(r=/^(.+?)y$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(C6),t&&r.test(t)&&(e=t+`i`)),r=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(x6),t&&r.test(t)&&(e=t+_6[n])}if(r=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,r.test(e)){let i=r.exec(e);t=i?.[1],n=i?.[2],r=new RegExp(x6),t&&r.test(t)&&(e=t+v6[n])}if(r=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,i=/^(.+?)(s|t)(ion)$/,r.test(e))t=r.exec(e)?.[1],r=new RegExp(S6),t&&r.test(t)&&(e=t);else if(i.test(e)){let n=i.exec(e);t=n?.[1]??``+n?.[2]??``,i=new RegExp(S6),i.test(t)&&(e=t)}return r=/^(.+?)e$/,r.test(e)&&(t=r.exec(e)?.[1],r=new RegExp(S6),i=RegExp(`^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$`),a=RegExp(`^`+b6+y6+`[^aeiouwxy]$`),t&&(r.test(t)||i.test(t)&&!a.test(t))&&(e=t)),r=/ll$/,i=new RegExp(S6),r.test(e)&&i.test(e)&&(r=/.$/,e=e.replace(r,``)),s==`y`&&(e=s.toLowerCase()+e.substring(1)),e}function T6(e,t,n=!0){let r=`${this.language}:${e}:${t}`;return n&&this.normalizationCache.has(r)?this.normalizationCache.get(r):this.stopWords?.includes(t)?(n&&this.normalizationCache.set(r,``),``):(this.stemmer&&!this.stemmerSkipProperties.has(e)&&(t=this.stemmer(t)),t=g6(t),n&&this.normalizationCache.set(r,t),t)}function E6(e){for(;e[e.length-1]===``;)e.pop();for(;e[0]===``;)e.shift();return e}function D6(e,t,n,r=!0){if(t&&t!==this.language)throw N4(`LANGUAGE_NOT_SUPPORTED`,t);if(typeof e!=`string`)return[e];let i=this.normalizeToken.bind(this,n??``),a;if(n&&this.tokenizeSkipProperties.has(n))a=[i(e,r)];else{let t=e4[this.language];a=e.toLowerCase().split(t).map(e=>i(e,r)).filter(Boolean)}let o=E6(a);return this.allowDuplicates?o:Array.from(new Set(o))}function O6(e={}){if(!e.language)e.language=`english`;else if(!t4.includes(e.language))throw N4(`LANGUAGE_NOT_SUPPORTED`,e.language);let t;if(e.stemming||e.stemmer&&!(`stemming`in e))if(e.stemmer){if(typeof e.stemmer!=`function`)throw N4(`INVALID_STEMMER_FUNCTION_TYPE`);t=e.stemmer}else if(e.language===`english`)t=w6;else throw N4(`MISSING_STEMMER`,e.language);let n;if(e.stopWords!==!1){if(n=[],Array.isArray(e.stopWords))n=e.stopWords;else if(typeof e.stopWords==`function`)n=e.stopWords(n);else if(e.stopWords)throw N4(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);if(!Array.isArray(n))throw N4(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`);for(let e of n)if(typeof e!=`string`)throw N4(`CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY`)}let r={tokenize:D6,language:e.language,stemmer:t,stemmerSkipProperties:new Set(e.stemmerSkipProperties?[e.stemmerSkipProperties].flat():[]),tokenizeSkipProperties:new Set(e.tokenizeSkipProperties?[e.tokenizeSkipProperties].flat():[]),stopWords:n,allowDuplicates:!!e.allowDuplicates,normalizeToken:T6,normalizationCache:new Map};return r.tokenize=D6.bind(r),r.normalizeToken=T6,r}function k6(e){return{sharedInternalDocumentStore:e,rules:new Map}}function A6(e,t){if(e.rules.has(t.id))throw Error(`PINNING_RULE_ALREADY_EXISTS: A pinning rule with id "${t.id}" already exists. Use updateRule to modify it.`);e.rules.set(t.id,t)}function j6(e,t){if(!e.rules.has(t.id))throw Error(`PINNING_RULE_NOT_FOUND: Cannot update pinning rule with id "${t.id}" because it does not exist. Use addRule to create it.`);e.rules.set(t.id,t)}function M6(e,t){return e.rules.delete(t)}function N6(e,t){return e.rules.get(t)}function P6(e){return Array.from(e.rules.values())}function F6(e,t){let n=e.toLowerCase().trim(),r=t.pattern.toLowerCase().trim();switch(t.anchoring){case`is`:return n===r;case`starts_with`:return n.startsWith(r);case`contains`:return n.includes(r);default:return!1}}function I6(e,t){return e?t.conditions.every(t=>F6(e,t)):!1}function L6(e,t){if(!t)return[];let n=[];for(let r of e.rules.values())I6(t,r)&&n.push(r);return n}function R6(e,t){return{sharedInternalDocumentStore:e,rules:new Map(t?.rules??[])}}function z6(e){return{rules:Array.from(e.rules.entries())}}function B6(){return{create:k6,addRule:A6,updateRule:j6,removeRule:M6,getRule:N6,getAllRules:P6,getMatchingRules:L6,load:R6,save:z6}}function V6(e){let t={formatElapsedTime:P4,getDocumentIndexId:F4,getDocumentProperties:b4,validateSchema:I4};for(let n of c3){let r=n;if(e[r]){if(typeof e[r]!=`function`)throw N4(`COMPONENT_MUST_BE_FUNCTION`,r)}else e[r]=t[r]}for(let t of Object.keys(e))if(!s3.includes(t)&&!c3.includes(t))throw N4(`UNSUPPORTED_COMPONENT`,t)}function H6({schema:e,sort:t,language:n,components:r,id:i,plugins:a}){r||={};for(let t of a??[]){if(!(`getComponents`in t)||typeof t.getComponents!=`function`)continue;let n=t.getComponents(e),i=Object.keys(n);for(let e of i)if(r[e])throw N4(`PLUGIN_COMPONENT_CONFLICT`,e,t.name);r={...r,...n}}i||=g4();let o=r.tokenizer,s=r.index,c=r.documentsStore,l=r.sorter,u=r.pinning;if(o=o?o.tokenize?o:O6(o):O6({language:n??`english`}),r.tokenizer&&n)throw N4(`NO_LANGUAGE_WITH_CUSTOM_TOKENIZER`);let d=W4();s||=G3(),l||=p6(),c||=i3(),u||=B6(),V6(r);let{getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,formatElapsedTime:h}=r,g={data:{},caches:{},schema:e,tokenizer:o,index:s,sorter:l,documentsStore:c,pinning:u,internalDocumentIDStore:d,getDocumentProperties:f,getDocumentIndexId:p,validateSchema:m,beforeInsert:[],afterInsert:[],beforeRemove:[],afterRemove:[],beforeUpdate:[],afterUpdate:[],beforeUpsert:[],afterUpsert:[],beforeSearch:[],afterSearch:[],beforeInsertMultiple:[],afterInsertMultiple:[],beforeRemoveMultiple:[],afterRemoveMultiple:[],beforeUpdateMultiple:[],afterUpdateMultiple:[],beforeUpsertMultiple:[],afterUpsertMultiple:[],afterCreate:[],formatElapsedTime:h,id:i,plugins:a,version:U6()};g.data={index:g.index.create(g,d,e),docs:g.documentsStore.create(g,d),sorting:g.sorter.create(g,d,e,t),pinning:g.pinning.create(d)};for(let e of a3)g[e]=(g[e]??[]).concat(o3(g,e));let _=g.afterCreate;return _&&p3(_,g),g}function U6(){return`{{VERSION}}`}function W6(e){return e.documentsStore.count(e.data.docs)}function G6(e,t,n,r,i){let a=e.validateSchema(t,e.schema);if(a)throw N4(`SCHEMA_VALIDATION_FAILURE`,a);return T4(e.beforeInsert)||T4(e.afterInsert)||T4(e.index.beforeInsert)||T4(e.index.insert)||T4(e.index.afterInsert)?J6(e,t,n,r,i):Y6(e,t,n,r,i)}const K6=new Set([`enum`,`enum[]`]),q6=new Set([`string`,`number`]);async function J6(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw N4(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=q4(e.internalDocumentIDStore,s);if(r||await l3(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw N4(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];X6(n,r,e,t)}return await Z6(e,s,u,f,l,n,t,i),r||await l3(e.afterInsert,e,s,t),s}function Y6(e,t,n,r,i){let{index:a,docs:o}=e.data,s=e.getDocumentIndexId(t);if(typeof s!=`string`)throw N4(`DOCUMENT_ID_MUST_BE_STRING`,typeof s);let c=q4(e.internalDocumentIDStore,s);if(r||l3(e.beforeInsert,e,s,t),!e.documentsStore.store(o,s,c,t))throw N4(`DOCUMENT_ALREADY_EXISTS`,s);let l=e.documentsStore.count(o),u=e.index.getSearchableProperties(a),d=e.index.getSearchablePropertiesWithTypes(a),f=e.getDocumentProperties(t,u);for(let[e,t]of Object.entries(f)){if(t===void 0)continue;let n=typeof t,r=d[e];X6(n,r,e,t)}return Q6(e,s,u,f,l,n,t,i),r||l3(e.afterInsert,e,s,t),s}function X6(e,t,n,r){if(!(z4(t)&&typeof r==`object`&&typeof r.lon==`number`&&typeof r.lat==`number`)&&!(B4(t)&&Array.isArray(r))&&!(V4(t)&&Array.isArray(r))&&!(K6.has(t)&&q6.has(e))&&e!==t)throw N4(`INVALID_DOCUMENT_PROPERTY`,n,t,e)}async function Z6(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o];await e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i);let l=e.internalDocumentIDStore.idToInternalId.get(t);await e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),await e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function Q6(e,t,n,r,i,a,o,s){for(let o of n){let n=r[o];if(n===void 0)continue;let c=e.index.getSearchablePropertiesWithTypes(e.data.index)[o],l=q4(e.internalDocumentIDStore,t);e.index.beforeInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i),e.index.insert(e.index,e.data.index,o,t,l,n,c,a,e.tokenizer,i,s),e.index.afterInsert?.(e.data.index,o,t,n,c,a,e.tokenizer,i)}let c=e.sorter.getSortableProperties(e.data.sorting),l=e.getDocumentProperties(o,c);for(let n of c){let r=l[n];if(r===void 0)continue;let i=e.sorter.getSortablePropertiesWithTypes(e.data.sorting)[n];e.sorter.insert(e.data.sorting,n,t,r,i,a)}}function $6(e,t,n,r,i,a){return T4(e.afterInsertMultiple)||T4(e.beforeInsertMultiple)||T4(e.index.beforeInsert)||T4(e.index.insert)||T4(e.index.afterInsert)?e8(e,t,n,r,i,a):t8(e,t,n,r,i,a)}async function e8(e,t,n=1e3,r,i,a=0){let o=[],s=async a=>{let s=Math.min(a+n,t.length),c=t.slice(a,s);for(let t of c){let n=await G6(e,t,r,i,{avlRebalanceThreshold:c.length});o.push(n)}return s};return await(async()=>{let e=0;for(;e<t.length;){let t=Date.now();if(e=await s(e),a>0){let e=a-(Date.now()-t);e>0&&j4(e)}}})(),i||await u3(e.afterInsertMultiple,e,t),o}function t8(e,t,n=1e3,r,i,a=0){let o=[],s=0;function c(){let a=t.slice(s*n,(s+1)*n);if(a.length===0)return!1;for(let t of a){let n=G6(e,t,r,i,{avlRebalanceThreshold:a.length});o.push(n)}return s++,!0}function l(){let e=Date.now();for(;c();)if(a>0){let t=Date.now()-e;if(t>=a){let e=a-t%a;e>0&&j4(e)}}}return l(),i||u3(e.afterInsertMultiple,e,t),o}function n8(e,t,n,r){return T4(e.index.beforeRemove)||T4(e.index.remove)||T4(e.index.afterRemove)?r8(e,t,n,r):i8(e,t,n,r)}async function r8(e,t,n,r){let i=!0,{index:a,docs:o}=e.data,s=e.documentsStore.get(o,t);if(!s)return!1;let c=q4(e.internalDocumentIDStore,t),l=J4(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||await l3(e.beforeRemove,e,l);let d=e.index.getSearchableProperties(a),f=e.index.getSearchablePropertiesWithTypes(a),p=e.getDocumentProperties(s,d);for(let r of d){let a=p[r];if(a===void 0)continue;let o=f[r];await e.index.beforeRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u),await e.index.remove(e.index,e.data.index,r,t,c,a,o,n,e.tokenizer,u)||(i=!1),await e.index.afterRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u)}let m=await e.sorter.getSortableProperties(e.data.sorting),h=await e.getDocumentProperties(s,m);for(let n of m)h[n]!==void 0&&e.sorter.remove(e.data.sorting,n,t);return r||await l3(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function i8(e,t,n,r){let i=!0,{index:a,docs:o}=e.data,s=e.documentsStore.get(o,t);if(!s)return!1;let c=q4(e.internalDocumentIDStore,t),l=J4(e.internalDocumentIDStore,c),u=e.documentsStore.count(o);r||l3(e.beforeRemove,e,l);let d=e.index.getSearchableProperties(a),f=e.index.getSearchablePropertiesWithTypes(a),p=e.getDocumentProperties(s,d);for(let r of d){let a=p[r];if(a===void 0)continue;let o=f[r];e.index.beforeRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u),e.index.remove(e.index,e.data.index,r,t,c,a,o,n,e.tokenizer,u)||(i=!1),e.index.afterRemove?.(e.data.index,r,l,a,o,n,e.tokenizer,u)}let m=e.sorter.getSortableProperties(e.data.sorting),h=e.getDocumentProperties(s,m);for(let n of m)h[n]!==void 0&&e.sorter.remove(e.data.sorting,n,t);return r||l3(e.afterRemove,e,l),e.documentsStore.remove(e.data.docs,t,c),i}function a8(e,t,n,r,i){return T4(e.index.beforeRemove)||T4(e.index.remove)||T4(e.index.afterRemove)||T4(e.beforeRemoveMultiple)||T4(e.afterRemoveMultiple)?o8(e,t,n,r,i):s8(e,t,n,r,i)}async function o8(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>J4(e.internalDocumentIDStore,q4(e.internalDocumentIDStore,t)));return i||await u3(e.beforeRemoveMultiple,e,o),await new Promise((o,s)=>{let c=0;async function l(){let u=t.slice(c*n,++c*n);if(!u.length)return o();for(let t of u)try{await n8(e,t,r,i)&&a++}catch(e){s(e)}setTimeout(l,0)}setTimeout(l,0)}),i||await u3(e.afterRemoveMultiple,e,o),a}function s8(e,t,n,r,i){let a=0;n||=1e3;let o=i?[]:t.map(t=>J4(e.internalDocumentIDStore,q4(e.internalDocumentIDStore,t)));i||u3(e.beforeRemoveMultiple,e,o);let s=0;function c(){let o=t.slice(s*n,++s*n);if(o.length){for(let t of o)n8(e,t,r,i)&&a++;setTimeout(c,0)}}return c(),i||u3(e.afterRemoveMultiple,e,o),a}function c8(e,t){return e[1]-t[1]}function l8(e,t){return t[1]-e[1]}function u8(e=`desc`){return e.toLowerCase()===`asc`?c8:l8}function d8(e,t,n){let r={},i=t.map(([e])=>e),a=e.documentsStore.getMultiple(e.data.docs,i),o=Object.keys(n),s=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e of o){let t;if(s[e]===`number`){let{ranges:r}=n[e],i=r.length,a=Array.from({length:i});for(let e=0;e<i;e++){let t=r[e];a[e]=[`${t.from}-${t.to}`,0]}t=Object.fromEntries(a)}r[e]={count:0,values:t??{}}}let c=a.length;for(let e=0;e<c;e++){let t=a[e];for(let e of o){let i=e.includes(`.`)?x4(t,e):t[e],a=s[e],o=r[e].values;switch(a){case`number`:{let t=n[e].ranges;f8(t,o)(i);break}case`number[]`:{let t=new Set,r=n[e].ranges,a=f8(r,o,t);for(let e of i)a(e);break}case`boolean`:case`enum`:case`string`:p8(o,a)(i);break;case`boolean[]`:case`enum[]`:case`string[]`:{let e=p8(o,a===`boolean[]`?`boolean`:`string`,new Set);for(let t of i)e(t);break}default:throw N4(`FACET_NOT_SUPPORTED`,a)}}}for(let e of o){let t=r[e];if(t.count=Object.keys(t.values).length,s[e]===`string`){let r=n[e],i=u8(r.sort);t.values=Object.fromEntries(Object.entries(t.values).sort(i).slice(r.offset??0,r.limit??10))}}return r}function f8(e,t,n){return r=>{for(let i of e){let e=`${i.from}-${i.to}`;n?.has(e)||r>=i.from&&r<=i.to&&(t[e]===void 0?t[e]=1:(t[e]++,n?.add(e)))}}}function p8(e,t,n){let r=t===`boolean`?`false`:``;return t=>{let i=t?.toString()??r;n?.has(i)||(e[i]=(e[i]??0)+1,n?.add(i))}}const m8={reducer:(e,t,n,r)=>(t[r]=n,t),getInitialValue:e=>Array.from({length:e})},h8=[`string`,`number`,`boolean`];function g8(e,t,n){let r=n.properties,i=r.length,a=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e=0;e<i;e++){let t=r[e];if(a[t]===void 0)throw N4(`UNKNOWN_GROUP_BY_PROPERTY`,t);if(!h8.includes(a[t]))throw N4(`INVALID_GROUP_BY_PROPERTY`,t,h8.join(`, `),a[t])}let o=t.map(([t])=>J4(e.internalDocumentIDStore,t)),s=e.documentsStore.getMultiple(e.data.docs,o),c=s.length,l=n.maxResult||2**53-1,u=[],d={};for(let e=0;e<i;e++){let t=r[e],n={property:t,perValue:{}},i=new Set;for(let e=0;e<c;e++){let r=s[e],a=x4(r,t);if(a===void 0)continue;let o=typeof a==`boolean`?``+a:a,c=n.perValue[o]??{indexes:[],count:0};c.count>=l||(c.indexes.push(e),c.count++,n.perValue[o]=c,i.add(a))}u.push(Array.from(i)),d[t]=n}let f=_8(u),p=f.length,m=[];for(let e=0;e<p;e++){let t=f[e],n=t.length,i={values:[],indexes:[]},a=[];for(let e=0;e<n;e++){let n=t[e],o=r[e];a.push(d[o].perValue[typeof n==`boolean`?``+n:n].indexes),i.values.push(n)}i.indexes=y4(a).sort((e,t)=>e-t),i.indexes.length!==0&&m.push(i)}let h=m.length,g=Array.from({length:h});for(let e=0;e<h;e++){let r=m[e],i=n.reduce||m8,a=r.indexes.map(e=>({id:o[e],score:t[e][1],document:s[e]})),c=i.reducer.bind(null,r.values),l=i.getInitialValue(r.indexes.length),u=a.reduce(c,l);g[e]={values:r.values,result:u}}return g}function _8(e,t=0){if(t+1===e.length)return e[t].map(e=>[e]);let n=e[t],r=_8(e,t+1),i=[];for(let e of n)for(let t of r){let n=[e];l4(n,t),i.push(n)}return i}function v8(e,t,n,r){let i=L6(t,r);if(i.length===0)return n;let a=i.flatMap(e=>e.consequence.promote);a.sort((e,t)=>e.position-t.position);let o=new Set,s=new Map,c=new Set;for(let t of a){let n=q4(e.internalDocumentIDStore,t.doc_id);if(n!==void 0){if(s.has(n)){let e=s.get(n);t.position<e&&s.set(n,t.position);continue}c.has(t.position)||(o.add(n),s.set(n,t.position),c.add(t.position))}}if(s.size===0)return n;let l=n.filter(([e])=>!o.has(e)),u=[];for(let[t,r]of s.entries())n.find(([e])=>e===t)?u.push([t,1e6-r]):e.documentsStore.get(e.data.docs,t)&&u.push([t,0]);u.sort((e,t)=>(s.get(e[0])??1/0)-(s.get(t[0])??1/0));let d=[],f=new Map;for(let e of u){let t=s.get(e[0]);f.set(t,e)}let p=0,m=0;for(;m<l.length+u.length;)if(f.has(m))d.push(f.get(m)),m++;else if(p<l.length)d.push(l[p]),p++,m++;else break;for(let[e,t]of f.entries())e>=d.length&&d.push(t);return d}function y8(e,t,n){let{term:r,properties:i}=t,a=e.data.index,o=e.caches.propertiesToSearch;if(!o){let t=e.index.getSearchablePropertiesWithTypes(a);o=e.index.getSearchableProperties(a),o=o.filter(e=>t[e].startsWith(`string`)),e.caches.propertiesToSearch=o}if(i&&i!==`*`){for(let e of i)if(!o.includes(e))throw N4(`UNKNOWN_INDEX`,e,o.join(`, `));o=o.filter(e=>i.includes(e))}let s=Object.keys(t.where??{}).length>0,c;s&&(c=e.index.searchByWhereClause(a,e.tokenizer,t.where,n));let l,u=t.threshold!==void 0&&t.threshold!==null?t.threshold:1;if(r||i){let i=W6(e);if(l=e.index.search(a,r||``,e.tokenizer,n,o,t.exact||!1,t.tolerance||0,t.boost||{},w8(t.relevance),i,c,u),t.exact&&r){let t=r.trim().split(/\s+/);l=l.filter(([n])=>{let r=e.documentsStore.get(e.data.docs,n);if(!r)return!1;for(let e of o){let n=x8(r,e);if(typeof n==`string`&&t.every(e=>RegExp(`\\b${b8(e)}\\b`).test(n)))return!0}return!1})}}else l=s?Y3(a,t.where)||(c?Array.from(c):[]).map(e=>[+e,0]):Object.keys(e.documentsStore.getAll(e.data.docs)).map(e=>[+e,0]);return l}function b8(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function x8(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r&&typeof r==`object`&&e in r)r=r[e];else return;return r}function S8(e,t,n){let r=h4();function i(){let i=Object.keys(e.data.index.vectorIndexes),a=t.facets&&Object.keys(t.facets).length>0,{limit:o=10,offset:s=0,distinctOn:c,includeVectors:l=!1}=t,u=t.preflight===!0,d=y8(e,t,n);if(t.sortBy)if(typeof t.sortBy==`function`){let n=d.map(([e])=>e),r=e.documentsStore.getMultiple(e.data.docs,n).map((e,t)=>[d[t][0],d[t][1],e]);r.sort(t.sortBy),d=r.map(([e,t])=>[e,t])}else d=e.sorter.sortBy(e.data.sorting,d,t.sortBy).map(([t,n])=>[q4(e.internalDocumentIDStore,t),n]);else d=d.sort(v4);d=v8(e,e.data.pinning,d,t.term);let f;u||(f=c?I8(e,d,s,o,c):L8(e,d,s,o));let p={elapsed:{formatted:``,raw:0},hits:[],count:d.length};return f!==void 0&&(p.hits=f.filter(Boolean),l||w4(p,i)),a&&(p.facets=d8(e,d,t.facets)),t.groupBy&&(p.groups=g8(e,d,t.groupBy)),p.elapsed=e.formatElapsedTime(h4()-r),p}async function a(){e.beforeSearch&&await f3(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await d3(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}const C8={k:1.2,b:.75,d:.5};function w8(e){let t=e??{};return t.k=t.k??C8.k,t.b=t.b??C8.b,t.d=t.d??C8.d,t}function T8(e,t,n){let r=t.vector;if(r&&(!(`value`in r)||!(`property`in r)))throw N4(`INVALID_VECTOR_INPUT`,Object.keys(r).join(`, `));let i=e.data.index.vectorIndexes[r.property];if(!i)throw N4(`UNKNOWN_VECTOR_PROPERTY`,r.property);let a=i.node.size;if(r?.value.length!==a)throw r?.property===void 0||r?.value.length===void 0?N4(`INVALID_INPUT_VECTOR`,`undefined`,a,`undefined`):N4(`INVALID_INPUT_VECTOR`,r.property,a,r.value.length);let o=e.data.index,s;return Object.keys(t.where??{}).length>0&&(s=e.index.searchByWhereClause(o,e.tokenizer,t.where,n)),i.node.find(r.value,t.similarity??.8,s)}function E8(e,t,n=`english`){let r=h4();function i(){let i=T8(e,t,n).sort(v4);i=v8(e,e.data.pinning,i,void 0);let a=[];t.facets&&Object.keys(t.facets).length>0&&(a=d8(e,i,t.facets));let o=t.vector.property,s=t.includeVectors??!1,c=t.limit??10,l=t.offset??0,u=Array.from({length:c});for(let t=0;t<c;t++){let n=i[t+l];if(!n)break;let r=e.data.docs.docs[n[0]];r&&(s||(r[o]=null),u[t]={id:J4(e.internalDocumentIDStore,n[0]),score:n[1],document:r})}let d=[];t.groupBy&&(d=g8(e,i,t.groupBy));let f=h4()-r;return{count:i.length,hits:u.filter(Boolean),elapsed:{raw:Number(f),formatted:m4(f)},...a?{facets:a}:{},...d?{groups:d}:{}}}async function a(){e.beforeSearch&&await f3(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await d3(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function D8(e,t,n){let r=A8(y8(e,t,n)),i=T8(e,t,n),a=t.hybridWeights;return N8(r,i,t.term??``,a)}function O8(e,t,n){let r=h4();function i(){let i=D8(e,t,n);i=v8(e,e.data.pinning,i,t.term);let a;t.facets&&Object.keys(t.facets).length>0&&(a=d8(e,i,t.facets));let o;t.groupBy&&(o=g8(e,i,t.groupBy));let s=t.offset??0,c=t.limit??10,l=L8(e,i,s,c).filter(Boolean),u=h4(),d={count:i.length,elapsed:{raw:Number(u-r),formatted:m4(u-r)},hits:l,...a?{facets:a}:{},...o?{groups:o}:{}};return(t.includeVectors??!1)||w4(d,Object.keys(e.data.index.vectorIndexes)),d}async function a(){e.beforeSearch&&await f3(e.beforeSearch,e,t,n);let r=i();return e.afterSearch&&await d3(e.afterSearch,e,t,n,r),r}return e.beforeSearch?.length||e.afterSearch?.length?a():i()}function k8(e){return e[1]}function A8(e){let t=Math.max.apply(Math,e.map(k8));return e.map(([e,n])=>[e,n/t])}function j8(e,t){return e/t}function M8(e,t){return(n,r)=>n*e+r*t}function N8(e,t,n,r){let i=Math.max.apply(Math,e.map(k8)),a=Math.max.apply(Math,t.map(k8)),{text:o,vector:s}=r&&r.text&&r.vector?r:P8(n),c=new Map,l=e.length,u=M8(o,s);for(let t=0;t<l;t++){let[n,r]=e[t],a=u(j8(r,i),0);c.set(n,a)}let d=t.length;for(let e=0;e<d;e++){let[n,r]=t[e],i=j8(r,a),o=c.get(n)??0;c.set(n,o+u(0,i))}return[...c].sort((e,t)=>t[1]-e[1])}function P8(e){return{text:.5,vector:.5}}function F8(e,t,n){let r=t.mode??`fulltext`;if(r===`fulltext`)return S8(e,t,n);if(r===`vector`)return E8(e,t);if(r===`hybrid`)return O8(e,t);throw N4(`INVALID_SEARCH_MODE`,r)}function I8(e,t,n,r,i){let a=e.data.docs,o=new Map,s=[],c=new Set,l=t.length,u=0;for(let d=0;d<l;d++){let l=t[d];if(l===void 0)continue;let[f,p]=l;if(c.has(f))continue;let m=e.documentsStore.get(a,f),h=x4(m,i);if(!(h===void 0||o.has(h))&&(o.set(h,!0),u++,!(u<=n)&&(s.push({id:J4(e.internalDocumentIDStore,f),score:p,document:m}),c.add(f),u>=n+r)))break}return s}function L8(e,t,n,r){let i=e.data.docs,a=Array.from({length:r}),o=new Set;for(let s=n;s<r+n;s++){let n=t[s];if(n===void 0)break;let[r,c]=n;if(!o.has(r)){let t=e.documentsStore.get(i,r);a[s]={id:J4(e.internalDocumentIDStore,r),score:c,document:t},o.add(r)}}return a}const R8={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},z8=new WeakMap;function B8(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function V8(e){return e.trim().toLowerCase()}const H8=/\.(?:md|mdx)$/;function U8(e,t){if(t!==`page`)return e;let n=e.replace(H8,``);return n.length>0?n:e}function W8(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function G8(e){let t=W8(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}const K8=/[^\P{L}a-zàèéìòóù]|[^\P{Nd}0-9]|\p{Nl}/iu,q8=(()=>{let e=globalThis.Intl.Segmenter;return e?new e(`en`,{granularity:`word`}):null})();function J8(){let e=O6({language:`english`}),t=e.tokenize.bind(e);return e.tokenize=(e,n,r,i)=>{let a=t(e,n,r,i);if(!q8||typeof e!=`string`||!K8.test(e))return a;let o=new Set(a);for(let{segment:t,isWordLike:n}of q8.segment(e)){if(!n||!K8.test(t))continue;let e=t.toLowerCase();o.has(e)||(o.add(e),a.push(e))}return a},e}function Y8(e){let t=H6({schema:R8,components:{tokenizer:J8()}});return e.length>0&&$6(t,e),t}function X8(e){let t={documents:e};return z8.set(t,Y8(e)),t}function Z8(e){let t=z8.get(e);if(t)return t;let n=Y8(e.documents);return z8.set(e,n),n}const Q8=new WeakSet;function $8(e,t){return e===t||e.kind===t.kind&&e.path===t.path&&e.title===t.title&&e.name===t.name&&e.pathSegments===t.pathSegments&&e.modifiedTs===t.modifiedTs&&e.content===t.content}function e5(e,t){let n=e=>({corpus:X8(t),inserted:0,updated:0,removed:0,rebuilt:!0,rebuildReason:e}),r=z8.get(e);if(!r)return n(`no-index`);if(Q8.has(e))return n(`stale-base`);let i=new Map(t.map(e=>[e.id,e]));if(i.size!==t.length)return n(`duplicate-id`);let a=[],o=[],s=0;for(let t of e.documents){let e=i.get(t.id);e?$8(t,e)||(a.push(t.id),o.push(e),s+=1):a.push(t.id)}let c=new Set(e.documents.map(e=>e.id));for(let e of t)c.has(e.id)||o.push(e);if(a.length+o.length>t.length)return n(`bulk-change`);Q8.add(e);try{if(a.length>0&&a8(r,a),o.length>0&&$6(r,o),W6(r)!==t.length)throw Error(`Search index count ${W6(r)} diverged from document count ${t.length} after incremental update`)}catch{return n(`mutation-failed`)}let l={documents:t};return z8.set(l,r),{corpus:l,inserted:o.length-s,updated:s,removed:a.length-s,rebuilt:!1}}function t5(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function n5(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function r5(e,t){let n=V8(t);if(!n)return 0;let r=U8(n,e.kind),i=V8(e.title),a=V8(e.name),o=V8(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function i5(e,t){let n=r5(e,t);return n<=0?n:eb(e.path)?n*.5:n}function a5(e){return e===`file`?-60:0}function o5(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function s5(e,t,n,r){return e+t*20+n+a5(r)}function c5(e,t,n,r,i,a){return e===`relevance`?s5(t,n,r,i):o5(t,n,r,i,a)}function l5(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function u5(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function d5(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function f5(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function p5(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}const m5=/[฀-๿ក-៿ -〿぀-ゟ゠-ヿ㐀-䶿一-鿿\uf900-﫿＀-￯\u1100-\u11ff\u3130-\u318f\ua960-\ua97f\uac00-\ud7ff]/;function h5(e,t){let n=V8(t);return n.length<4||m5.test(n)?0:+(e===`full_text`)}function g5(e){let{lexical:t,fullText:n}=e.signals;return t>=500?`lexical`:t===450&&n<=0?`pathOnly`:`body`}function _5(e){let t=[],n=[],r=[];for(let i of e){let e=g5(i);e===`lexical`?t.length<100&&t.push(i):e===`body`?n.length<6&&n.push(i):r.length<4&&r.push(i)}return[...t,...n,...r]}function v5(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=_5(e),i=[],a=0,o=0;for(let e of r){if(e.document.kind===`folder`){if(a>=3)continue;a+=1}else if(e.document.kind===`file`){if(o>=3)continue;o+=1}if(i.push(e),i.length>=n)break}return i}function y5(e,t,n={}){let r=n.intent??`omnibar`,i=l5(r,n.ranking),a=B8(n.limit),o=new Set(n.scopes??t5(r)),s=e.documents.filter(e=>n5(e,o)),c=V8(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=F8(Z8(e),{term:c,properties:f5(r),boost:p5(r),tolerance:h5(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>n5(e.document,o)).map(e=>[e.document.id,e.score])),d=d5(s),f=new Map;for(let e of s)i5(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)n5(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=u5(f.values(),u);return v5([...f.values()].map(t=>{let n=Math.max(0,i5(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:c5(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return v5(x5({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function b5(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function x5(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=u5(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,i5(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?c5(o,t,n,s,e.kind,m):s5(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=b5(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=b5(h.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.sort((e,t)=>{let n=+(e.lexical>0),r=+(t.lexical>0);if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=v(e.document.id),a=v(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n}))}const S5=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),C5=globalThis;C5[S5]===void 0&&(C5[S5]=s());const w5=C5[S5],T5=[`.ok`,`skill-state.yml`],E5=[`claude-cowork`,`cli-hosts`],D5=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],O5=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,k5=y({version:k().regex(O5,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(w5,{description:`Recorded skill version for this target.`}),recordedAt:o().register(w5,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:O(D5).register(w5,{description:`Install-source surface that recorded this entry.`}).optional()}),A5=y({enabled:g().register(w5,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:o().register(w5,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})}),j5=y({schema:v(1).register(w5,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:y({"claude-cowork":k5.optional(),"cli-hosts":k5.optional()}).register(w5,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:h(k(),A5).register(w5,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional(),installsReported:x(k()).register(w5,{description:"Skill installs already reported to skills.sh from this machine, as `<owner/repo>#<skill>`. Append-only; presence suppresses a re-report."}).optional()});function M5(e,t){return e??t.installedOnDisk}function N5(){return{schema:1,targets:{}}}const P5=16*1024*1024,F5=64*1024*1024,I5=y({name:k(),description:k(),files:y({skillMd:k(),scripts:x(k()),references:x(k())})}),L5=y({pluginProvider:k().optional(),plugin:k().optional(),marketplace:k().optional(),version:k().optional(),gitCommitSha:k().optional(),scope:k().optional(),projectPath:k().optional()}),R5=y({commands:g(),hooks:g(),mcp:g()}),z5=y({...I5.shape,sourceHarness:k(),sourceHarnesses:x(k()),home:k(),provenance:L5,inert:R5,outsideProject:g().optional()}),B5=y({schema:v(1),name:k(),version:k(),description:k().optional(),author:y({name:k()}).optional(),skills:x(k()),hostCompatibility:x(k()).optional(),capabilities:y({scripts:k(),network:k(),inert:x(k())}).optional(),provenance:y({source:k(),ref:k(),contentHash:k()}).optional()}),V5=C({skills:x(z5),packs:x(B5)}).loose(),H5=C({results:x(C({id:k().min(1),name:k().min(1),source:k().min(1),description:k(),installs:E().int().nonnegative().nullable(),publisher:k().nullable()}).loose()),backend:O([`skills.sh`,`github-fallback`]),degraded:g()}).loose(),U5=C({title:k(),description:k(),image:k().nullable(),skillsUrl:k().nullable(),sourceKind:O([`github`,`site`]),sourceUrl:k()}).loose(),W5=C({skills:x(C({name:k(),description:k().nullable()}).loose())}).loose(),G5=C({kind:O([`local`,`import`,`none`]),scope:O(ot).optional(),name:k().optional(),dir:k().optional(),source:k().optional(),ref:k().optional(),via:O([`source`,`publisher`]).optional()}).loose(),K5=C({relPath:k(),content:k().nullable()}).loose(),q5=C({provider:k(),plugin:k(),version:k().optional(),marketplace:k().optional(),repositoryUrl:k().optional()}).loose(),J5=C({provider:k(),plugin:k(),version:k().optional(),description:k().optional(),repositoryUrl:k().optional(),bundledSkills:x(k()),capabilities:C({commands:g(),hooks:g(),mcp:g(),agents:g()}),setupSupported:g()}).loose(),Y5=C({name:k(),description:k().nullable(),skillMd:k(),files:x(K5),plugin:q5.optional(),pluginBundle:J5.optional()}).loose(),X5=new Set([`project`,`local`]);function Z5(e){return e!==void 0&&X5.has(e)?`project`:`global`}function Q5(e,t){let n=e=>e.replace(/\/+$/,``);return n(e)===n(t)}function $5(e,t){if(Z5(e.scope)===`global`)return!0;let n=e.projectPath;return n===void 0||t===void 0?!0:Q5(n,t)}function e7(e,t,n){if(n===void 0||Z5(e.scope)!==`project`)return!1;let r=t.replace(/\/+$/,``),i=n.replace(/\/+$/,``);return r!==i&&!r.startsWith(`${i}/`)}const t7=/^([\w.-]+)\/([\w.-]+)$/,n7=/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function r7(e){let t=t7.exec(e);if(t){let[,e,n]=t;if(e&&n)return{kind:`github`,owner:e,repo:n}}return n7.test(e)?{kind:`site`,hostname:e}:null}function i7(e,t){let n=r7(e),r=t.trim();if(!n||!r)return null;let i=encodeURIComponent(r);if(n.kind===`github`){let e=encodeURIComponent(n.owner),t=encodeURIComponent(n.repo);return{sourceKind:`github`,skillsUrl:`https://www.skills.sh/${e}/${t}/${i}`,sourceUrl:`https://github.com/${e}/${t}`}}return{sourceKind:`site`,skillsUrl:`https://www.skills.sh/site/${encodeURIComponent(n.hostname)}/${i}`,sourceUrl:`https://${n.hostname}`}}function a7(e){return e.includes(`/`)?e.split(`/`)[0]??null:null}function o7(e){let t=e.split(`/`).pop();return t&&t.length>0?t:e}const s7=`template`;function c7(e){if(e.trim()===``)return{};let t;try{t=(0,Ye.parse)(e)}catch{return{}}return typeof t!=`object`||!t||Array.isArray(t)?{}:t}function l7(e,t){return e.trim()===``?t:`---\n${e}\n---\n${t}`}function u7(e){let{frontmatter:t,body:n}=Sm(e);return t===``?{docFrontmatterText:``,markdown:e}:{docFrontmatterText:wm(t),markdown:n}}function d7(e){let t=e.split(`
345
+ `);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=c7(n.join(`
346
+ `))[s7];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
347
+ `).replace(/\n+$/,``)}}function f7(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=Sm(t);if(n===``)return{identity:{},starterContent:t};let i=wm(n),a=d7(i);if(a)return{identity:a.identity,starterContent:l7(a.docFrontmatterText,r)};let{frontmatter:o}=Sm(r);if(o!==``)return{identity:c7(i),starterContent:r};let s=c7(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:l7(i,r)}}function p7(e,t){let{docFrontmatterText:n,markdown:r}=u7(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,Ye.stringify)({[s7]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function m7(e){return f7(e).starterContent}function h7(){let e=!1,t=``,n=0;return r=>{let i=g7(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function g7(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const _7=/^(#{1,6})\s+(.+)$/;function v7(e,t){let n=(e.endsWith(`\r`)?e.slice(0,-1):e).match(_7);if(!n)return null;let r=n[2].trim(),i=GY(r,t);return i?{level:n[1].length,text:r,slug:i}:null}const y7=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],b7={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function x7(e,t=y7){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const S7={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`,"claude-acp":`claude`,"codex-acp":`openai`,"github-copilot-cli":`github`};function C7(e){return e?S7[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const w7={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function T7(e){let t=e?.trim();return t?w7[C7(t)]??t:`Agent`}function E7(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const D7=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function O7(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function k7(e){let t=e.trim();return D7.test(t)||t.startsWith(`//`)}function A7(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(k7(n))return{kind:`external`,url:n};let r=n.indexOf(`#`),i=r<0?n:n.slice(0,r),a=ht(i,t);if(a)return{kind:`doc`,docName:a,anchor:r<0?null:n.slice(r+1)};let o=mt(i,t);if(o)return{kind:`doc`,docName:o,anchor:r<0?null:n.slice(r+1)};let s=E7(n,t);if(s)return{kind:`doc`,docName:s.docName,anchor:s.anchor};let c=O7(n);return c&&c!==`md`&&c!==`mdx`?{kind:`asset`,url:n,ext:c}:null}function j7(e,t){let n=e.trim();if(!n)return null;if(k7(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=O7(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function M7(e,t){let n=e.trim();if(!n||D7.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function N7(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function P7(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function F7(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function I7(e){return e.split(`/`).filter(e=>e!==``)}function L7(e,t){let n=F7(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function R7(e,t){let n=F7(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:I7(r).length}function z7(e,t){let n=I7(e),r=I7(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function B7(){let e=new Map;function t(t){let n=N7(t);if(n===``)return;let r=P7(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=N7(t),r=P7(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=F7(N7(n)),o=[],s=[];for(let e of i)L7(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=R7(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=R7(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=z7(a,F7(t));for(let r=1;r<e.length;r++){let i=e[r],o=z7(a,F7(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function V7(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function H7(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}export{F2 as $,lb as $a,sX as $i,d$ as $n,Tt as $o,zZ as $r,v$ as $t,H5 as A,PW as Aa,ZX as Ai,o1 as An,Jt as Ao,AQ as Ar,a0 as At,G8 as B,Kb as Ba,LX as Bi,g1 as Bn,zt as Bo,sQ as Br,A1 as Bt,$5 as C,tY as Ca,uZ as Ci,F$ as Cn,cn as Co,vQ as Cr,Ue as Cs,b0 as Ct,Y5 as D,XW as Da,QX as Di,D$ as Dn,on as Do,CQ as Dr,he as Ds,l0 as Dt,W5 as E,LW as Ea,tZ as Ei,E$ as En,$t as Eo,yQ as Er,ve as Es,_0 as Et,O5 as F,dH as Fa,vX as Fi,n1 as Fn,Ut as Fo,cQ as Fr,U1 as Ft,Z2 as G,Gb as Ga,OX as Gi,t$ as Gn,At as Go,ZZ as Gr,w1 as Gt,e5 as H,Ub as Ha,jX as Hi,T$ as Hn,Ot as Ho,eQ as Hr,k1 as Ht,j5 as I,KR as Ia,MX as Ii,i1 as In,Wt as Io,oQ as Ir,N1 as It,H2 as J,jb as Ja,fX as Ji,f$ as Jn,Mt as Jo,FZ as Jr,b1 as Jt,Q2 as K,Wb as Ka,RX as Ki,m$ as Kn,jt as Ko,WZ as Kr,C1 as Kt,N5 as L,FP as La,yX as Li,a1 as Ln,Bt as Lo,iQ as Lr,R1 as Lt,F5 as M,zU as Ma,BX as Mi,A$ as Mn,Gt as Mo,OQ as Mr,t0 as Mt,T5 as N,wH as Na,VX as Ni,j$ as Nn,Kt as No,YZ as Nr,n0 as Nt,G5 as O,HW as Oa,eZ as Oi,O$ as On,Xt as Oo,wQ as Or,ge as Os,f0 as Ot,E5 as P,fH as Pa,EX as Pi,_$ as Pn,Ht as Po,XZ as Pr,W1 as Pt,z2 as Q,ub as Qa,cX as Qi,u$ as Qn,Et as Qo,UZ as Qr,Q$ as Qt,M5 as R,EN as Ra,NX as Ri,e1 as Rn,Vt as Ro,nQ as Rr,D1 as Rt,Z5 as S,nY as Sa,rZ as Si,N$ as Sn,F as So,_Q as Sr,qe as Ss,O0 as St,U5 as T,RW as Ta,KX as Ti,P$ as Tn,Yt as To,xQ as Tr,P as Ts,v0 as Tt,q2 as U,Rb as Ua,gX as Ui,x$ as Un,kt as Uo,QZ as Ur,E1 as Ut,y5 as V,zb as Va,_X as Vi,_1 as Vn,Lt as Vo,lQ as Vr,O1 as Vt,X2 as W,qb as Wa,AX as Wi,r$ as Wn,It as Wo,$Z as Wr,x1 as Wt,V2 as X,Pb as Xa,ZY as Xi,h$ as Xn,Nt as Xo,LZ as Xr,a$ as Xt,R2 as Y,Mb as Ya,hX as Yi,p$ as Yn,Pt as Yo,IZ as Yr,i$ as Yt,B2 as Z,sb as Za,oX as Zi,g$ as Zn,Dt as Zo,HZ as Zr,o$ as Zt,f7 as _,vY as _a,gZ as _i,y1 as _n,Cm as _o,gQ as _r,_t as _s,F0 as _t,j7 as a,IY as aa,OZ as ai,R$ as an,Ib as ao,GQ as ar,et as as,A2 as at,i7 as b,_Y as ba,cZ as bi,$$ as bn,pf as bo,TQ as br,bt as bs,C0 as bt,b7 as c,bY as ca,wZ as ci,q$ as cn,kb as co,WQ as cr,at as cs,_2 as ct,C7 as d,MY as da,bZ as di,U$ as dn,Xy as do,VQ as dr,ct as ds,g2 as dt,UY as ea,RZ as ei,c1 as en,hb as eo,l$ as er,Qe as es,P2 as et,v7 as f,sY as fa,xZ as fi,W$ as fn,Jy as fo,HQ as fr,st as fs,p2 as ft,m7 as g,fY as ga,SZ as gi,h1 as gn,Ry as go,hQ as gr,St as gs,W0 as gt,p7 as h,iY as ha,vZ as hi,C$ as hn,Hy as ho,zQ as hr,yt as hs,H0 as ht,A7 as i,FY as ia,AZ as ii,L$ as in,Fb as io,QQ as ir,tt as is,M2 as it,P5 as j,bW as ja,XX as ji,s1 as jn,qt as jo,DQ as jr,c0 as jt,V5 as k,NW as ka,$X as ki,k$ as kn,sn as ko,kQ as kr,me as ks,i0 as kt,x7 as l,SY as la,TZ as li,K$ as ln,bb as lo,UQ as lr,ot as ls,C2 as lt,s7 as m,pY as ma,_Z as mi,r1 as mn,Gy as mo,RQ as mr,lt as ms,X0 as mt,H7 as n,RY as na,MZ as ni,d1 as nn,_b as no,e$ as nr,nt as ns,L2 as nt,M7 as o,CY as oa,DZ as oi,z$ as on,Ob as oo,KQ as or,dt as os,k2 as ot,h7 as p,cY as pa,CZ as pi,G$ as pn,qy as po,LQ as pr,wt as ps,K0 as pt,K2 as q,Hb as qa,zX as qi,c$ as qn,Ft as qo,GZ as qr,S1 as qt,B7 as r,LY as ra,PZ as ri,M$ as rn,yb as ro,XQ as rr,$e as rs,I2 as rt,E7 as s,EY as sa,jZ as si,B$ as sn,Sb as so,YQ as sr,it as ss,w2 as st,V7 as t,zY as ta,VZ as ti,f1 as tn,mb as to,b$ as tr,rt as ts,N2 as tt,T7 as u,jY as ua,EZ as ui,H$ as un,eb as uo,BQ as ur,Ze as us,h2 as ut,a7 as v,yY as va,sZ as vi,Z$ as vn,Sm as vo,pQ as vr,ft as vs,I0 as vt,e7 as w,IW as wa,pZ as wi,I$ as wn,en as wo,fQ as wr,Je as ws,y0 as wt,o7 as x,hY as xa,iZ as xi,X$ as xn,ea as xo,EQ as xr,Xe as xs,A0 as xt,r7 as y,oY as ya,oZ as yi,m1 as yn,wm as yo,mQ as yr,ht as ys,N0 as yt,X8 as z,Bb as za,PX as zi,t1 as zn,Rt as zo,tQ as zr,j1 as zt};
348
+ //# sourceMappingURL=src-Cb3i1kcm.mjs.map
@@ -0,0 +1 @@
1
+ import{Lo as e,P as t,Po as n,Qo as r,R as i,Ro as a,d as o,es as s,ks as c,l,us as u}from"./src-Cb3i1kcm.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Br as w,Bt as T,C as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Ft as W,G,Gi as K,Gn as q,Gr as J,Gt as Y,H as X,Hi as Z,Hn as Q,Hr as $,Ht as ee,I as te,Ii as ne,In as re,It as ie,J as ae,Ji as oe,Jn as se,Jr as ce,Jt as le,K as ue,Ki as de,Kn as fe,Kr as pe,Kt as me,L as he,Li as ge,Ln as _e,Lt as ve,M as ye,Mi as be,Mn as xe,Mr as Se,Mt as Ce,N as we,Ni as Te,Nn as Ee,Nt as De,O as Oe,Oi as ke,On as Ae,Or as je,Ot as Me,P as Ne,Pi as Pe,Pn as Fe,Pt as Ie,Q as Le,Qi as Re,Qn as ze,Qr as Be,Qt as Ve,R as He,Ri as Ue,Rn as We,Rr as Ge,Rt as Ke,S as qe,Si as Je,Sn as Ye,Sr as Xe,St as Ze,T as Qe,Ti as $e,Tn as et,Tr as tt,Tt as nt,U as rt,Ui as it,Un as at,Ur as ot,Ut as st,V as ct,Vi as lt,Vn as ut,Vr as dt,Vt as ft,W as pt,Wi as mt,Wn as ht,Wr as gt,Wt as _t,X as vt,Xi as yt,Xn as bt,Xr as xt,Xt as St,Y as Ct,Yi as wt,Yn as Tt,Yr as Et,Yt as Dt,Z as Ot,Zi as kt,Zn as At,Zr as jt,Zt as Mt,_ as Nt,_a as Pt,_i as Ft,_n as It,_r as Lt,_t as Rt,a as zt,aa as Bt,ai as Vt,an as Ht,ar as Ut,at as Wt,b as Gt,ba as Kt,bi as qt,bn as Jt,br as Yt,bt as Xt,c as Zt,ca as Qt,ci as $t,cn as en,cr as tn,d as nn,da as rn,di as an,dn as on,dr as sn,ea as cn,ei as ln,en as un,er as dn,et as fn,f as pn,fa as mn,fi as hn,fn as gn,fr as _n,g as vn,ga as yn,gi as bn,gn as xn,gr as Sn,gt as Cn,h as wn,ha as Tn,hi as En,hn as Dn,hr as On,ht as kn,i as An,ia as jn,ii as Mn,in as Nn,ir as Pn,it as Fn,j as In,ji as Ln,jn as Rn,jr as zn,jt as Bn,k as Vn,ki as Hn,kn as Un,kr as Wn,kt as Gn,l as Kn,la as qn,li as Jn,ln as Yn,lr as Xn,m as Zn,ma as Qn,mi as $n,mn as er,mr as tr,mt as nr,n as rr,na as ir,ni as ar,nn as or,nr as sr,nt as cr,o as lr,oa as ur,oi as dr,on as fr,or as pr,ot as mr,p as hr,pa as gr,pi as _r,pn as vr,pr as yr,q as br,qi as xr,qn as Sr,qr as Cr,qt as wr,r as Tr,ra as Er,ri as Dr,rn as Or,rr as kr,rt as Ar,s as jr,sa as Mr,si as Nr,sn as Pr,sr as Fr,st as Ir,t as Lr,ta as Rr,ti as zr,tn as Br,tr as Vr,tt as Hr,u as Ur,ua as Wr,ui as Gr,un as Kr,ur as qr,v as Jr,va as Yr,vn as Xr,vr as Zr,vt as Qr,w as $r,wi as ei,wn as ti,wr as ni,wt as ri,x as ii,xi as ai,xn as oi,xr as si,xt as ci,y as li,ya as ui,yi as di,yn as fi,yr as pi,yt as mi,z as hi,zi as gi,zn as _i,zr as vi,zt as yi}from"./src-q9JjDIHN.mjs";import{C as bi,E as xi,T as Si,_ as Ci,b as wi,c as Ti,d as Ei,g as Di,i as Oi,l as ki,m as Ai,n as ji,p as Mi,s as Ni,t as Pi,u as Fi,v as Ii,w as Li,x as Ri,y as zi}from"./fs-traced-DVpoNaQJ.mjs";import{a as Bi,d as Vi,f as Hi,i as Ui,l as Wi,n as Gi,r as Ki,t as qi,u as Ji}from"./logger-DFxEUjvj.mjs";import{C as Yi,S as Xi,_ as Zi,a as Qi,c as $i,d as ea,g as ta,h as na,i as ra,l as ia,m as aa,n as oa,o as sa,p as ca,r as la,s as ua,t as da,u as fa,v as pa,y as ma}from"./server-lock-CVlhIOaP.mjs";export{rn as AGENT_ID_MAX_LEN,mn as AGENT_ID_RE,M as AGENT_WRITE_ORIGIN,Yr as AcpPermissionStore,Tn as AcpRegistry,Je as AcpThreadManager,qt as AgentFocusBroadcaster,di as AgentPresenceBroadcaster,ke as AgentSessionCapacityError,Hn as AgentSessionManager,kn as AutoStartDisabledError,Zr as BUNDLE_IDS,pi as BUNDLE_SCOPE,Yt as BUNDLE_SKILL_NAME,Sr as BacklinkIndex,gi as CC1Broadcaster,s as CC1_CONTRACT_VERSION,Kr as CONFIG_FILENAME,ut as CONFLICT_MARKER_RE,w as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Nt as ConfigSchema,K as DEFAULT_CHECKPOINT_RETENTION,Vt as DEFAULT_EMBEDDINGS_DIMENSIONS,W as DEFAULT_PACK_ID,ct as DocumentDurabilityState,dr as EMBEDDINGS_API_KEY_ENV,yn as FEATURED_AGENT_IDS,de as FILE_SYSTEM_WRITER,q as FILE_WATCHER_ORIGIN,m as FileEmbeddingsBackend,Mt as GIT_PREFLIGHT_FAIL_SPAN_NAME,xr as GIT_UPSTREAM_WRITER,ui as GitDirAccessError,h as GitNotAvailableError,un as GitTooOldError,Cn as HOCUSPOCUS_AUTH_REJECTION_REASONS,Rt as HocuspocusAuthRejection,Qr as HocuspocusAuthTokenSchema,pe as INSTALLED_AGENTS_SCHEMES,r as LINEAGE_EPOCH_KEY,He as LIVE_DERIVED_INDEX_DEBOUNCE_MS,ie as LOG_MD_TEMPLATE,nt as MANAGED_RENAME_ORIGIN,D as MAX_ACP_THREADS,_ as MAX_AGENT_SESSIONS,$e as MCP_CONNECTION_ID_HEADER,n as MCP_SERVER_NAME,Ln as MIN_EVICTABLE_IDLE_MS,Br as MIN_GIT_VERSION,X as MISSING_OK_CONFIG_MESSAGE,Kt as MalformedGitPointerError,fn as McpLogger,rt as MissingOkConfigError,Te as OBSERVER_SYNC_ORIGIN,on as OK_OKIGNORE_TEMPLATE,e as ORPHAN_MODES,c as PROTOCOL_VERSION,qi as PinoLogger,$i as ProcessLockCollisionError,Kn as ProjectGitInitError,B as ROLLBACK_ORIGIN,gn as ROOT_GITIGNORE_TEMPLATE,Zi as RUNTIME_VERSION,fi as RemoteConfigError,oe as SERVICE_WRITER,yr as SKILL_INSTALL_EVENTS_FILE_REL,t as SKILL_STATE_TARGETS,ve as STARTER_FOLDERS,Ke as STARTER_FOLDER_FRONTMATTER_FILENAME,yi as STARTER_PACKS,T as STARTER_PACK_IDS,ft as STARTER_TEMPLATES,Qe as STATE_MANIFEST_FILENAME,pa as STATE_SCHEMA_VERSION,u as SYSTEM_DOC_NAME,wr as SeedPrerequisiteError,le as SeedRootDirError,da as ServerLockCollisionError,Lr as SingleFileNotAFileError,rr as SingleFileNotFoundError,Tr as SingleFileNotMarkdownError,I as StateManifestError,fe as TagIndex,si as USER_GLOBAL_BUNDLE_IDS,Tt as UiLockCollisionError,F as __getShowAllWalkStatsForTesting,Me as __resetShowAllWalkStatsForTesting,ia as acquireProcessLock,oa as acquireServerLock,bt as acquireUiLock,be as applyAgentMarkdownWrite,_i as applyExternalChange,Ie as applySeed,j as assertCompatibleStateManifest,or as assertGitAvailable,N as assertNeverDiskEvent,ai as attachAcpThreadSocket,nr as attachIdleShutdown,Jr as bootServer,dn as buildAndOpenSkill,vr as buildConfigYmlContent,Ct as buildExecResult,ei as buildOkMcpStdioCommand,On as buildSkillZip,ee as buildStarterFolderFrontmatterYaml,wt as buildWipTree,Xe as bundleSkillMdPath,ln as canonicalProjectKey,Ae as classifyEvents,Pi as classifyFsPath,zr as clearAllEmbeddingsKeys,$t as clearContributors,st as coercePackId,l as colorFromSeed,yt as commitUpstreamImport,kt as commitWip,Re as commitWipFromTree,Or as compareSemver,tt as composeEffectiveLinterConfig,z as composeFrontmatterSchemasConfig,Q as containsConflictMarkers,Un as contentHash,Jn as contributorCount,Ne as countShadowObjects,V as countStaleAgentWipRefs,te as countWipRefs,Gn as createApiExtension,ri as createAssetServeMiddleware,G as createCollaborationHost,Ge as createContentFilter,vi as createContentFilterAsync,ar as createEmbeddingsSecretStore,An as createEphemeralProjectDir,C as createExternalChangeHandler,pn as createFileLogger,hi as createLiveDerivedIndexExtension,br as createMcpHttpHandler,Cr as createOsProbe,we as createPersistenceExtension,E as createServer,In as createServerObserverExtension,ne as createStreamingErrorWriter,Gi as createTestLogger,Dr as describeStoredEmbeddingsKey,vn as detectClaudeDesktopPresence,Nn as detectGit,Oe as detectProjectShape,Vr as detectUserSkillHosts,Ar as discoverLockDirs,Wn as discoverMarkdownlintConfig,Ve as emitPreflightFailureSpan,vt as encodeDocName,Ot as encodeFolderRoute,Le as encodeSkillRoute,Ur as ensureProjectGit,er as ensureProjectSkillGitignore,ge as errorResponse,v as evictStaleTrackerEntries,b as extractHeadings,Fn as extractOkBinaryPath,se as extractWikiLinksFromMarkdown,Ht as fallbackPaths,nn as findEnclosingGitRoot,et as findEnclosingProjectRoot,y as findNativeMarkdownlintFile,hr as flushFileLogger,mi as formatAuthRejectionWire,Gr as formatContributors,an as formatContributorsFrom,Ce as formatPackRationale,f as gcCheckpointRefs,Hr as getCurrentMcpLogger,En as getLocalDir,Zn as getLogFilePath,Ki as getLogger,wn as getLogsDir,ma as getMachineId,zi as getMeter,ur as getMetrics,wi as getTracer,Mr as handleCollabSocketError,dt as handleSpawnCursor,Jt as hasForwardingHeaders,he as hasGcLogLatch,o as iconFromClientName,Qt as incrementCollabSocketFilteredError,qn as incrementServerObserverFire,Dn as initContent,cn as initShadowRepo,Ri as initTelemetry,Gt as initToleranceTelemetryWriter,Ir as installPrettyZodErrors,Ui as installTestLoggers,sr as installUserSkill,Xr as isAllowedApiOrigin,O as isAllowedWorkspaceHostHeader,S as isConfigDoc,Xt as isHocuspocusAuthRejectionReason,_t as isKnownPackId,lt as isLinkIndexExcludedDoc,ti as isLoopbackAddress,Z as isManagedArtifactDoc,a as isOrphanMode,Pe as isPairedWriteOrigin,$ as isPathWithinDir,Xi as isProcessAlive,R as isProjectRoot,oi as isRemoteAdmitted,it as isReservedForUserTree,Rn as isSelfWrite,mt as isSystemDoc,ii as isToleranceTelemetryEnabled,Yi as isValidLockPid,xe as lastKnownHash,Rr as listRescueCheckpoints,Y as listStarterPacks,Pt as loadCustomAgents,ye as loadPrincipal,fa as lockBaseUrl,ea as lockFilePath,Bi as loggerFactory,Wi as logsCurrentPath,Ji as logsPreviousPath,Mn as makeLazyEmbeddingsKeyStore,la as markServerLockDraining,pt as mountMcpAndApi,ji as normalizeFsPath,k as originGitHubHost,xn as packageVersionMajorMinor,ci as parseAuthRejectionWire,fr as parseGitVersion,Ze as parseHocuspocusAuthToken,ue as parseKeepaliveConnectionId,Ee as pathToDocName,De as planSeed,zt as prepareSingleFileOpen,Wt as processCommand,mr as processUsage,Pn as readAllTargets,Ut as readBundleDecision,zn as readOwnNativeRules,ca as readProcessLock,aa as readProcessLockDetailed,x as readProjectHeadState,Be as readProjectLocalSemanticConfig,ra as readServerLock,pr as readServerPackageVersion,Fr as readSkillInstallStateSnapshot,Vn as readStateManifest,tn as readTargetRecordedAt,Xn as readTargetVersion,At as readUiLock,at as reconcile,hn as recordContributor,tr as recordSkillInstallEvent,ae as registerAllTools,Fe as registerWrite,na as releaseProcessLock,Qi as releaseServerLock,ze as releaseUiLock,U as removeLastKnownHash,kr as reportSkillInstall,Wr as resetMetrics,i as resolveBundleEnabled,Sn as resolveBundledSkillDir,bn as resolveContentDir,ot as resolveCursorBinaryDefault,gt as resolveCursorSpawnInvocation,P as resolveEffectiveLinterConfig,Nr as resolveEmbeddingsCredential,Ft as resolveLockDir,je as resolveNativeConfigForDoc,Se as resolveNativeMarkdownlintConfig,me as resolvePack,jr as resolvePackageVersion,Ye as resolveRemoteAccess,_n as resolveSkillInstallReportSettings,d as resolveUiInfo,_r as restoreContributors,li as restoreLifecycleFromConflictsJson,xt as rewriteMarkdownLinksForDocumentRename,jt as rewriteWikiLinksForDocumentRename,Pr as runAuthReposSubprocess,en as runAuthStatusSubprocess,Dt as runCloneSubprocess,Yn as runDeviceFlowSubprocess,cr as runWithMcpLogger,Et as safeContentPath,Bn as safeSubdir,ir as safetyCheckpoint,L as sanitizeClientName,Er as saveInMemoryCheckpoint,jn as saveVersion,A as seedBasenameIndex,lr as serializeError,bi as setActiveSpanAttributes,H as setupServerObservers,Bt as shadowGit,Li as shutdownTelemetry,Vi as spansCurrentPath,Hi as spansPreviousPath,J as spawnDetached,ht as splitMarkdownBlocks,re as startWatcher,Ue as streamingProblemEvent,$n as swapContributors,qe as teardownToleranceTelemetryWriter,gr as toBroadcasterKey,Oi as tracedAppendFileSync,Ni as tracedLinkSync,Ti as tracedMkdir,ki as tracedMkdirSync,Fi as tracedRename,Ei as tracedRenameSync,Mi as tracedRmSync,Ai as tracedRmdirSync,Di as tracedUnlinkSync,Ci as tracedWriteFile,Ii as tracedWriteFileSync,$r as trustSystemCertificates,Zt as untrackTrackedProjectSkillProjection,_e as updateLastKnownHash,ta as updateProcessLockPort,sa as updateServerLockPort,p as updateUiLockPort,Qn as validateAgentId,St as validateCloneInputs,Lt as validateSkillZip,ua as waitForServerLockDrain,ce as withHiddenWindowsConsole,Si as withSpan,xi as withSpanSync,qr as writeBundleDecision,ni as writeMarkdownlintRule,It as writeRootGitignoreForNewRepo,g as writeStateManifest,sn as writeTargetVersion,We as writeTracker};