@inkeep/open-knowledge 0.5.0-beta.2 → 0.5.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/THIRD_PARTY_NOTICES.md +10 -0
  2. package/dist/assets/skills/open-knowledge/SKILL.md +1 -1
  3. package/dist/cli.mjs +40 -40
  4. package/dist/constants-BX3j-Yin.mjs +2 -0
  5. package/dist/{dist-DLi5l7jc.mjs → dist-B-QGEbwX.mjs} +1 -1
  6. package/dist/{dist-DD3jbGts.mjs → dist-Buq7uUK7.mjs} +20 -20
  7. package/dist/{dist-CKbBtGcV.mjs → dist-C2XvqbzG.mjs} +5 -5
  8. package/dist/index.mjs +1 -1
  9. package/dist/init-C4vpeHcE.mjs +1 -0
  10. package/dist/{init-BVF99f4p.mjs → init-waQJnje3.mjs} +3 -3
  11. package/dist/{loader-BuVjsSVh.mjs → loader-PJR8tk3Q.mjs} +2 -2
  12. package/dist/loader-V2wyK36w.mjs +1 -0
  13. package/dist/{preview-CgtprTPm.mjs → preview-BbtR5Qqj.mjs} +2 -2
  14. package/dist/preview-DR_OP2am.mjs +1 -0
  15. package/dist/public/assets/ActivityModeContent-baqsrxsY.js +2 -0
  16. package/dist/public/assets/ConsentDialogBody-zb1TKG9i.js +2 -0
  17. package/dist/public/assets/DocumentContext-D4lHVgL4.js +52 -0
  18. package/dist/public/assets/{GraphPanel-C3gvPdoq.js → GraphPanel-Bqt87S0c.js} +2 -2
  19. package/dist/public/assets/McpConsentDialogBody-C8ewMYVI.js +1 -0
  20. package/dist/public/assets/SettingsDialog-D6nNBqeV.js +11 -0
  21. package/dist/public/assets/{SourceEditor-Xxy5TvNJ.js → SourceEditor-CJiFlEvK.js} +2 -2
  22. package/dist/public/assets/{_baseFor-CVV1DSgL.js → _baseFor-Dewzr4ka.js} +1 -1
  23. package/dist/public/assets/{arc-DoxD41WW.js → arc-DA-_Qgty.js} +1 -1
  24. package/dist/public/assets/architecture-YZFGNWBL-ii1DMScC.js +1 -0
  25. package/dist/public/assets/{architectureDiagram-Q4EWVU46-Du5oNRD5.js → architectureDiagram-Q4EWVU46-Wd0Ua0Z1.js} +1 -1
  26. package/dist/public/assets/{blockDiagram-DXYQGD6D-CuxUJ8VP.js → blockDiagram-DXYQGD6D-B_z4vCOg.js} +1 -1
  27. package/dist/public/assets/{c4Diagram-AHTNJAMY-D58kKzW4.js → c4Diagram-AHTNJAMY-CXNX0C7S.js} +1 -1
  28. package/dist/public/assets/channel-BsgewBDI.js +1 -0
  29. package/dist/public/assets/{chunk-2KRD3SAO-uai9wz3V.js → chunk-2KRD3SAO-QHu6lS2z.js} +1 -1
  30. package/dist/public/assets/{chunk-336JU56O-CtkQ28bg.js → chunk-336JU56O-D77Rj_75.js} +2 -2
  31. package/dist/public/assets/chunk-426QAEUC-b3iWz8H-.js +1 -0
  32. package/dist/public/assets/{chunk-4BX2VUAB-BTctgoF3.js → chunk-4BX2VUAB-CDjfF5mJ.js} +1 -1
  33. package/dist/public/assets/{chunk-4TB4RGXK-Cnl-K_AI.js → chunk-4TB4RGXK-DgzpC1RW.js} +1 -1
  34. package/dist/public/assets/chunk-55IACEB6-DLoy8CmX.js +1 -0
  35. package/dist/public/assets/{chunk-5FUZZQ4R-DF0EG1O8.js → chunk-5FUZZQ4R-pDx0Wde8.js} +1 -1
  36. package/dist/public/assets/{chunk-5PVQY5BW-BpceE2BZ.js → chunk-5PVQY5BW-kcWn_d-_.js} +1 -1
  37. package/dist/public/assets/{chunk-67CJDMHE-DiSIolj4.js → chunk-67CJDMHE-DlS8iVRi.js} +1 -1
  38. package/dist/public/assets/{chunk-7N4EOEYR-Yp7Nf16N.js → chunk-7N4EOEYR-BhSQn_oU.js} +1 -1
  39. package/dist/public/assets/{chunk-AA7GKIK3--s2NNuet.js → chunk-AA7GKIK3-C1CcYx5B.js} +1 -1
  40. package/dist/public/assets/{chunk-BSJP7CBP-BrRqu__W.js → chunk-BSJP7CBP-B5xN369R.js} +1 -1
  41. package/dist/public/assets/{chunk-CIAEETIT-BUzaopy6.js → chunk-CIAEETIT-ecxKAxUb.js} +1 -1
  42. package/dist/public/assets/{chunk-EDXVE4YY-Bo83e0iq.js → chunk-EDXVE4YY-Bm2-fU6x.js} +1 -1
  43. package/dist/public/assets/{chunk-ENJZ2VHE-CY9yto8o.js → chunk-ENJZ2VHE-1bYQNnwE.js} +1 -1
  44. package/dist/public/assets/{chunk-FMBD7UC4-DEzvlUl3.js → chunk-FMBD7UC4-Da7gMLWx.js} +1 -1
  45. package/dist/public/assets/{chunk-FOC6F5B3-BtjWNx10.js → chunk-FOC6F5B3-CHF5QCPz.js} +1 -1
  46. package/dist/public/assets/{chunk-ICPOFSXX-BC5Xd13f.js → chunk-ICPOFSXX-rmT7ehAO.js} +1 -1
  47. package/dist/public/assets/{chunk-K5T4RW27-CfU2wPmV.js → chunk-K5T4RW27-CHoEPFOL.js} +1 -1
  48. package/dist/public/assets/{chunk-KGLVRYIC-BV1pDifD.js → chunk-KGLVRYIC-DRtjGHKV.js} +1 -1
  49. package/dist/public/assets/{chunk-LIHQZDEY-C40dIbib.js → chunk-LIHQZDEY-GDhBbkMd.js} +1 -1
  50. package/dist/public/assets/{chunk-ORNJ4GCN-8cFqvOFf.js → chunk-ORNJ4GCN-C9FrQ4Hp.js} +1 -1
  51. package/dist/public/assets/{chunk-OYMX7WX6-D0C6jdl8.js → chunk-OYMX7WX6-CAW2HwTq.js} +1 -1
  52. package/dist/public/assets/chunk-QZHKN3VN-XrJADtWP.js +1 -0
  53. package/dist/public/assets/{chunk-U2HBQHQK-DenE4TdD.js → chunk-U2HBQHQK-Cg7rxXd1.js} +1 -1
  54. package/dist/public/assets/{chunk-X2U36JSP-DSyuGkzP.js → chunk-X2U36JSP-Z4V8etFJ.js} +1 -1
  55. package/dist/public/assets/{chunk-XPW4576I-CLO5Bb_q.js → chunk-XPW4576I-Ci37cmyJ.js} +1 -1
  56. package/dist/public/assets/{chunk-YZCP3GAM-D8kUvWu6.js → chunk-YZCP3GAM-BlAQKShJ.js} +1 -1
  57. package/dist/public/assets/{chunk-ZZ45TVLE-DHB0SHUz.js → chunk-ZZ45TVLE-CKHp-exc.js} +1 -1
  58. package/dist/public/assets/classDiagram-6PBFFD2Q-Bt8hJVX9.js +1 -0
  59. package/dist/public/assets/classDiagram-v2-HSJHXN6E-BTPIteVB.js +1 -0
  60. package/dist/public/assets/clone-B_tH2FKO.js +1 -0
  61. package/dist/public/assets/config-validation-events-CuJstsYS.js +10 -0
  62. package/dist/public/assets/{cose-bilkent-S5V4N54A-6FB6GAoi.js → cose-bilkent-S5V4N54A-CzOLOBap.js} +1 -1
  63. package/dist/public/assets/{dagre-D2_448Gx.js → dagre-CbTJGa51.js} +1 -1
  64. package/dist/public/assets/{dagre-KV5264BT-Bn9RtFC-.js → dagre-KV5264BT-CzrIWBHi.js} +1 -1
  65. package/dist/public/assets/{diagram-5BDNPKRD-XCR9sVhK.js → diagram-5BDNPKRD-DDHvw5SM.js} +1 -1
  66. package/dist/public/assets/{diagram-G4DWMVQ6-Bz0ngc_7.js → diagram-G4DWMVQ6-DiQx8aIN.js} +1 -1
  67. package/dist/public/assets/{diagram-MMDJMWI5-o_IQFxK_.js → diagram-MMDJMWI5-CJELLr4J.js} +1 -1
  68. package/dist/public/assets/{diagram-TYMM5635-D2QJXyfV.js → diagram-TYMM5635-BHwicR15.js} +1 -1
  69. package/dist/public/assets/dialog-CY2eQd6O.js +45 -0
  70. package/dist/public/assets/{dist-BYGzJeLM.js → dist-B3L7cm0M.js} +1 -1
  71. package/dist/public/assets/{dist-CXGJFbY5.js → dist-BMooy-F_.js} +1 -1
  72. package/dist/public/assets/{dist-DsbVHLNy.js → dist-BiYnsAMa.js} +1 -1
  73. package/dist/public/assets/{dist-Cq1LYbUj.js → dist-CATLRngz.js} +1 -1
  74. package/dist/public/assets/{dist-BrsSsfiw.js → dist-Cp-iTcML.js} +1 -1
  75. package/dist/public/assets/{dist-CyaBbyDQ.js → dist-Dwop2AD8.js} +1 -1
  76. package/dist/public/assets/doc-hash-D-COaeDG.js +422 -0
  77. package/dist/public/assets/{erDiagram-SMLLAGMA-C1Mr5jbs.js → erDiagram-SMLLAGMA-DdltplqB.js} +1 -1
  78. package/dist/public/assets/{flatten-DFiFicpD.js → flatten-BdgTwKTr.js} +1 -1
  79. package/dist/public/assets/{flowDiagram-DWJPFMVM--ukgnTYS.js → flowDiagram-DWJPFMVM-CQHlOxjR.js} +1 -1
  80. package/dist/public/assets/{ganttDiagram-T4ZO3ILL-CVeIdgCM.js → ganttDiagram-T4ZO3ILL-CNDOT9hb.js} +1 -1
  81. package/dist/public/assets/gitGraph-7Q5UKJZL-CIz9LX1B.js +1 -0
  82. package/dist/public/assets/{gitGraphDiagram-UUTBAWPF-BSivDyLh.js → gitGraphDiagram-UUTBAWPF-BgXxQBs9.js} +1 -1
  83. package/dist/public/assets/{graphlib-DvRtwu4N.js → graphlib-CrrIJ98S.js} +1 -1
  84. package/dist/public/assets/index-BHqEYdAv.css +1 -0
  85. package/dist/public/assets/index-Bzh2wENQ.js +1853 -0
  86. package/dist/public/assets/info-OMHHGYJF-CIFsXa-y.js +1 -0
  87. package/dist/public/assets/{infoDiagram-42DDH7IO-DtO1Tc8U.js → infoDiagram-42DDH7IO-BNSprTvD.js} +1 -1
  88. package/dist/public/assets/{isEmpty-gGVpRSDa.js → isEmpty-XlV2b3kS.js} +1 -1
  89. package/dist/public/assets/isSymbol-CiN6ou2H.js +1 -0
  90. package/dist/public/assets/{ishikawaDiagram-UXIWVN3A-BY3noyNF.js → ishikawaDiagram-UXIWVN3A-COSeJVOI.js} +1 -1
  91. package/dist/public/assets/{journeyDiagram-VCZTEJTY-DdFdkR8_.js → journeyDiagram-VCZTEJTY-sGfNXUrs.js} +1 -1
  92. package/dist/public/assets/{kanban-definition-6JOO6SKY-WoLnXp48.js → kanban-definition-6JOO6SKY-DknMinG3.js} +1 -1
  93. package/dist/public/assets/{line-C59Ezo8Z.js → line-BI6r6-S8.js} +1 -1
  94. package/dist/public/assets/{linear-faBQNtcz.js → linear-1aKBO-v1.js} +1 -1
  95. package/dist/public/assets/{mermaid-parser.core-CFsvu03i.js → mermaid-parser.core-BrufKICx.js} +2 -2
  96. package/dist/public/assets/{mermaid.core-CWYso-V4.js → mermaid.core-hgzeX18g.js} +3 -3
  97. package/dist/public/assets/{mindmap-definition-QFDTVHPH-BG3Kwhhs.js → mindmap-definition-QFDTVHPH-X4KQZFdB.js} +1 -1
  98. package/dist/public/assets/{now-D_m-3Vjm.js → now--RAZR_wd.js} +1 -1
  99. package/dist/public/assets/{ordinal-BLFwWMHf.js → ordinal-C6wHcby9.js} +1 -1
  100. package/dist/public/assets/packet-4T2RLAQJ-BaGTVTK6.js +1 -0
  101. package/dist/public/assets/pie-ZZUOXDRM-BlBm3k_7.js +1 -0
  102. package/dist/public/assets/{pieDiagram-DEJITSTG-B1wtn7py.js → pieDiagram-DEJITSTG-5kceM3o3.js} +1 -1
  103. package/dist/public/assets/{quadrantDiagram-34T5L4WZ-yboV7Kxh.js → quadrantDiagram-34T5L4WZ-CQehowKY.js} +1 -1
  104. package/dist/public/assets/radar-PYXPWWZC-DcDFZeKR.js +1 -0
  105. package/dist/public/assets/{reduce-DmI60TfL.js → reduce-C4NH7ua9.js} +1 -1
  106. package/dist/public/assets/{requirementDiagram-MS252O5E-BpVLqxNT.js → requirementDiagram-MS252O5E-DySfGFfG.js} +1 -1
  107. package/dist/public/assets/{sankeyDiagram-XADWPNL6-CH1ZYL1H.js → sankeyDiagram-XADWPNL6-CMU0uGgr.js} +1 -1
  108. package/dist/public/assets/{sequenceDiagram-FGHM5R23-CwQvwa3m.js → sequenceDiagram-FGHM5R23-BlnukeK1.js} +1 -1
  109. package/dist/public/assets/{src-DOAilbaA.js → src-BXk72DrU.js} +1 -1
  110. package/dist/public/assets/{stateDiagram-FHFEXIEX-DL3pXt3n.js → stateDiagram-FHFEXIEX-B7C4fJw1.js} +1 -1
  111. package/dist/public/assets/stateDiagram-v2-QKLJ7IA2-BjMTOSSV.js +1 -0
  112. package/dist/public/assets/{target-navigation-intent-Bsa-5sN4.js → target-navigation-intent-BebfMyQT.js} +1 -1
  113. package/dist/public/assets/{telemetry-impl-H--5W_Jc.js → telemetry-impl-C6x9yckj.js} +2 -2
  114. package/dist/public/assets/{timeline-definition-GMOUNBTQ-CDbb3c--.js → timeline-definition-GMOUNBTQ-DAcQtRlS.js} +1 -1
  115. package/dist/public/assets/{toggle-group-fH3GS2vu.js → toggle-group-B6Y5d2LH.js} +1 -1
  116. package/dist/public/assets/{tooltip-BuwIhPCp.js → tooltip-Cn5mq_qc.js} +1 -1
  117. package/dist/public/assets/treeView-SZITEDCU-DT6-aoa9.js +1 -0
  118. package/dist/public/assets/treemap-W4RFUUIX-JWBoWOdi.js +1 -0
  119. package/dist/public/assets/{typing-burst-detector-isOlON7R.js → typing-burst-detector-BizuT3zF.js} +2 -2
  120. package/dist/public/assets/{vennDiagram-DHZGUBPP-BaHOUqGA.js → vennDiagram-DHZGUBPP-D5QpqXSc.js} +1 -1
  121. package/dist/public/assets/wardley-RL74JXVD-GxyzoOqN.js +1 -0
  122. package/dist/public/assets/{wardleyDiagram-NUSXRM2D-5ysokC2z.js → wardleyDiagram-NUSXRM2D-CV74dN2L.js} +1 -1
  123. package/dist/public/assets/{xychartDiagram-5P7HB3ND-CFQqcNjf.js → xychartDiagram-5P7HB3ND-VYAkLjyv.js} +1 -1
  124. package/dist/public/index.html +19 -20
  125. package/dist/{src-ClUycJ-8.mjs → src-C2dzaqiT.mjs} +2 -2
  126. package/dist/{start-9GiauZpx.mjs → start-BPgTRJoS.mjs} +2 -2
  127. package/dist/start-DI5JWpBI.mjs +1 -0
  128. package/package.json +1 -1
  129. package/dist/constants-DaHLULeB.mjs +0 -2
  130. package/dist/init-C5EZlTRi.mjs +0 -1
  131. package/dist/loader-hhLpWo02.mjs +0 -1
  132. package/dist/preview-B3SUZJxp.mjs +0 -1
  133. package/dist/public/assets/ActivityModeContent-BPpQcXSp.js +0 -2
  134. package/dist/public/assets/ConsentDialogBody-CPwBJJLE.js +0 -2
  135. package/dist/public/assets/DocumentContext-DOBntg5q.js +0 -37
  136. package/dist/public/assets/McpConsentDialogBody-0w9-K4mU.js +0 -1
  137. package/dist/public/assets/SettingsDialog-DJeu0WRa.js +0 -11
  138. package/dist/public/assets/architecture-YZFGNWBL-C7rs88Cj.js +0 -1
  139. package/dist/public/assets/channel-kvPH_LHg.js +0 -1
  140. package/dist/public/assets/chunk-426QAEUC-jRhC4EYv.js +0 -1
  141. package/dist/public/assets/chunk-55IACEB6-dtXOOCuI.js +0 -1
  142. package/dist/public/assets/chunk-QZHKN3VN-Bz4XrtbS.js +0 -1
  143. package/dist/public/assets/classDiagram-6PBFFD2Q-MrFnlVPS.js +0 -1
  144. package/dist/public/assets/classDiagram-v2-HSJHXN6E-DFkKo4Ct.js +0 -1
  145. package/dist/public/assets/clone-jj9sSaF-.js +0 -1
  146. package/dist/public/assets/config-validation-events-BpvRjXIZ.js +0 -10
  147. package/dist/public/assets/dialog-BFN-ujuF.js +0 -1
  148. package/dist/public/assets/dist-OTL8-1C2.js +0 -45
  149. package/dist/public/assets/doc-hash-DefAyZGx.js +0 -422
  150. package/dist/public/assets/gitGraph-7Q5UKJZL-Bmgp5n-M.js +0 -1
  151. package/dist/public/assets/index-Cfu0nrKh.js +0 -1853
  152. package/dist/public/assets/index-Cl4ZMMDO.css +0 -1
  153. package/dist/public/assets/info-OMHHGYJF-DCMX4pS_.js +0 -1
  154. package/dist/public/assets/isSymbol-D0ur5y-p.js +0 -1
  155. package/dist/public/assets/packet-4T2RLAQJ-DveBhlQF.js +0 -1
  156. package/dist/public/assets/pie-ZZUOXDRM-yiLyabeZ.js +0 -1
  157. package/dist/public/assets/radar-PYXPWWZC-D8GV_2fZ.js +0 -1
  158. package/dist/public/assets/stateDiagram-v2-QKLJ7IA2-6f8E13YF.js +0 -1
  159. package/dist/public/assets/treeView-SZITEDCU-A2Cj-I1J.js +0 -1
  160. package/dist/public/assets/treemap-W4RFUUIX-uOn6xcZK.js +0 -1
  161. package/dist/public/assets/wardley-RL74JXVD-DrTPuxUO.js +0 -1
  162. package/dist/start-BOjZrRX3.mjs +0 -1
  163. /package/dist/public/assets/{ActivityPanelDiffView-DeDaG2lq.js → ActivityPanelDiffView-EaCFURAu.js} +0 -0
  164. /package/dist/public/assets/{__vite-browser-external-sCjVW6Bj.js → __vite-browser-external-mvD4HPu0.js} +0 -0
  165. /package/dist/public/assets/{array-COEOjKUv.js → array-o2rfyIz3.js} +0 -0
  166. /package/dist/public/assets/{colors-D6LRuSY-.js → colors-BbIH8S-B.js} +0 -0
  167. /package/dist/public/assets/{cytoscape.esm-4jw_vW_Q.js → cytoscape.esm-xzkCxEpv.js} +0 -0
  168. /package/dist/public/assets/{defaultLocale-CoF2cqkH.js → defaultLocale-D3xTVDt1.js} +0 -0
  169. /package/dist/public/assets/{dist-Du-s1q8P.js → dist-D2RGH7XO.js} +0 -0
  170. /package/dist/public/assets/{dist-Bog19bCH.js → dist-TlK-S7KL.js} +0 -0
  171. /package/dist/public/assets/{go-wMvjCq97.js → go-e6pdpn6U.js} +0 -0
  172. /package/dist/public/assets/{init-8GNx5phc.js → init-gbiKrEzm.js} +0 -0
  173. /package/dist/public/assets/{input-BOmkuBId.js → input-hZk8Tm0e.js} +0 -0
  174. /package/dist/public/assets/{isObjectLike-DFnkciUU.js → isObjectLike-BNNgtFA6.js} +0 -0
  175. /package/dist/public/assets/{min-BiwsSkbB.js → min-VayDM1tY.js} +0 -0
  176. /package/dist/public/assets/{path-C-grg3CZ.js → path-DFpIsaqN.js} +0 -0
  177. /package/dist/public/assets/{pdf-CtJiipL_.js → pdf-w2KBoLit.js} +0 -0
  178. /package/dist/public/assets/{pdf.worker-BZq-wJdz.js → pdf.worker-BpRoOtgY.js} +0 -0
  179. /package/dist/public/assets/{project-paths-Cs3srSjk.js → project-paths-hiY0fNWB.js} +0 -0
  180. /package/dist/public/assets/{rough.esm-DDK-gphn.js → rough.esm-BgPNbngg.js} +0 -0
  181. /package/dist/public/assets/{shell-DdhS5_h8.js → shell-BkCD5kyH.js} +0 -0
  182. /package/dist/public/assets/{src-L3wpjxBL.js → src-BYmEUJ3I.js} +0 -0
  183. /package/dist/public/assets/{stex-CzCFWeB9.js → stex-J8UMaf7u.js} +0 -0
  184. /package/dist/public/assets/{textarea-CaFqgjns.js → textarea-gXd-JXvQ.js} +0 -0
@@ -1,2 +1,2 @@
1
- import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{$ as i,D as a,E as o,Kt as s,O as c,n as l}from"./DocumentContext-DOBntg5q.js";import{a as u,c as d,i as f,n as ee,o as te,r as ne,s as re,t as ie,u as ae}from"./panel-8fydlQgn.js";import{At as p,Dt as m,s as oe}from"./doc-hash-DefAyZGx.js";import{r as se}from"./button-C1nwPVFQ.js";import{$ as h,At as g,Bt as _,Dt as v,E as y,Et as b,Ft as x,Ht as S,J as C,Mt as w,N as T,Ot as E,Pt as D,Q as O,Rt as k,Ut as A,X as j,_ as ce,_t as M,ct as N,dt as P,et as F,f as I,gt as L,ht as R,l as le,lt as ue,mt as de,nt as fe,ot as pe,rt as me,st as he,tt as ge,ut as _e,wt as z,y as ve,yt as B,zt as ye}from"./dist-Du-s1q8P.js";import{i as be,n as xe,o as Se,r as Ce}from"./dist-BrsSsfiw.js";var we=e(t(),1),Te=r(),Ee=new Map;function De(e,t){Ee.set(e,t)}function Oe(e){let t=Ee.get(e)??null;return Ee.delete(e),t}function ke(e){Ee.delete(e)}var Ae=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,V=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(Ae(e)):Ae,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return k(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=A(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ye(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(V.prototype[Symbol.iterator]=function(){return this});var je={from:-1,to:-1,match:/.*/.exec(``)},Me=`gm`+(/x/.unicode==null?``:`u`),Ne=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=je,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Ie(e,t,n,r,i);this.re=new RegExp(t,Me+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=Re(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Re(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Pe=new WeakMap,Fe=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Pe.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Pe.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Pe.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Ie=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=je,this.matchPos=Re(e,r),this.re=new RegExp(t,Me+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Fe.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=Re(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Fe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Ne.prototype[Symbol.iterator]=Ie.prototype[Symbol.iterator]=function(){return this});function Le(e){try{return new RegExp(e,Me),!0}catch{return!1}}function Re(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var ze=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=L(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),ee=b.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,j.scrollIntoView(ee.from,{y:`center`})],selection:ee})}),!0},Be={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Ve=E.define({combine(e){return _(e,Be,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function He(e){let t=[Je,qe];return e&&t.push(Ve.of(e)),t}var Ue=C.mark({class:`cm-selectionMatch`}),We=C.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Ge(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=z.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=z.Word)}function Ke(e,t,n,r){return e(t.sliceDoc(n,n+1))==z.Word&&e(t.sliceDoc(r-1,r))==z.Word}var qe=O.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Ve),{state:n}=e,r=n.selection;if(r.ranges.length>1)return C.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return C.none;let e=n.wordAt(i.head);if(!e)return C.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return C.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Ge(o,n,i.from,i.to)&&Ke(o,n,i.from,i.to)))return C.none}else if(a=n.sliceDoc(i.from,i.to),!a)return C.none}let s=[];for(let r of e.visibleRanges){let e=new V(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Ge(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(We.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Ue.range(r,a)),s.length>t.maxMatches))return C.none}}return C.set(s)}},{decorations:e=>e.decorations}),Je=j.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Ye=({state:e,dispatch:t})=>{let{selection:n}=e,r=b.create(n.ranges.map(t=>e.wordAt(t.head)||b.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Xe(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new V(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new V(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Ze=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Ye({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Xe(e,r);return i?(t(e.update({selection:e.selection.addRange(b.range(i.from,i.to),!1),effects:j.scrollIntoView(i.to)})),!0):!1},H=E.define({combine(e){return _(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Et(e),scrollToMatch:e=>j.scrollIntoView(e)})}}),Qe=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Le(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
- `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new st(this):new nt(this)}getCursor(e,t=0,n){let r=e.doc?e:v.create({doc:e});return n??=r.doc.length,this.regexp?W(this,r,t,n):U(this,r,t,n)}},$e=class{constructor(e){this.spec=e}};function et(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function U(e,t,n,r){let i;return e.wholeWord&&(i=tt(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=et(e.test,t,i)),new V(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function tt(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(it(i,n-a))!=z.Word||t(at(i,n-a))!=z.Word)&&(t(at(i,r-a))!=z.Word||t(it(i,r-a))!=z.Word))}var nt=class extends $e{constructor(e){super(e)}nextMatch(e,t,n){let r=U(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=U(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=U(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=U(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=U(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function rt(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function W(e,t,n,r){let i;return e.wholeWord&&(i=ot(t.charCategorizer(t.selection.main.head))),e.test&&(i=rt(e.test,t,i)),new Ne(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function it(e,t){return e.slice(S(e,t,!1),t)}function at(e,t){return e.slice(t,S(e,t))}function ot(e){return(t,n,r)=>!r[0].length||(e(it(r.input,r.index))!=z.Word||e(at(r.input,r.index))!=z.Word)&&(e(at(r.input,r.index+r[0].length))!=z.Word||e(it(r.input,r.index+r[0].length))!=z.Word)}var st=class extends $e{nextMatch(e,t,n){let r=W(this.spec,e,n,e.doc.length).next();return r.done&&(r=W(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=W(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=W(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=W(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},G=D.define(),ct=D.define(),K=x.define({create(e){return new lt(bt(e).create(),null)},update(e,t){for(let n of t.effects)n.is(G)?e=new lt(n.value.create(),e.panel):n.is(ct)&&(e=new lt(e.query,n.value?yt:null));return e},provide:e=>M.from(e,e=>e.panel)}),lt=class{constructor(e,t){this.query=e,this.panel=t}},ut=C.mark({class:`cm-searchMatch`}),dt=C.mark({class:`cm-searchMatch cm-searchMatch-selected`}),ft=O.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(K))}update(e){let t=e.state.field(K);(t!=e.startState.field(K)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return C.none;let{view:n}=this,r=new w;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?dt:ut)})}return r.finish()}},{decorations:e=>e.decorations});function q(e){return t=>{let n=t.state.field(K,!1);return n&&n.query.spec.valid?e(t,n):Ct(t)}}var pt=q((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=b.single(r.from,r.to),a=e.state.facet(H);return e.dispatch({selection:i,effects:[kt(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),St(e),!0}),mt=q((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=b.single(i.from,i.to),o=e.state.facet(H);return e.dispatch({selection:a,effects:[kt(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),St(e),!0}),ht=q((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:b.create(n.map(e=>b.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),gt=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new V(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(b.range(t.value.from,t.value.to))}return t(e.update({selection:b.create(a,o),userEvent:`select.search.matches`})),!0},_t=q((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(j.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=b.single(o.from,o.to).map(d),u.push(kt(e,o)),u.push(n.facet(H).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),vt=q((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:j.announce.of(r),userEvent:`input.replace.all`}),!0});function yt(e){return e.state.facet(H).createPanel(e)}function bt(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(H);return new Qe({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function xt(e){let t=me(e,yt);return t&&t.dom.querySelector(`[main-field]`)}function St(e){let t=xt(e);t&&t==e.root.activeElement&&t.select()}var Ct=e=>{let t=e.state.field(K,!1);if(t&&t.panel){let n=xt(e);if(n&&n!=e.root.activeElement){let r=bt(e.state,t.query.spec);r.valid&&e.dispatch({effects:G.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[ct.of(!0),t?G.of(bt(e.state,t.query.spec)):D.appendConfig.of(jt)]});return!0},wt=e=>{let t=e.state.field(K,!1);if(!t||!t.panel)return!1;let n=me(e,yt);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:ct.of(!1)}),!0},Tt=[{key:`Mod-f`,run:Ct,scope:`editor search-panel`},{key:`F3`,run:pt,shift:mt,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:pt,shift:mt,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:wt,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:gt},{key:`Mod-Alt-g`,run:ze},{key:`Mod-d`,run:Ze,preventDefault:!0}],Et=class{constructor(e){this.view=e;let t=this.query=e.state.field(K).query.spec;this.commit=this.commit.bind(this),this.searchField=B(`input`,{value:t.search,placeholder:J(e,`Find`),"aria-label":J(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=B(`input`,{value:t.replace,placeholder:J(e,`Replace`),"aria-label":J(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=B(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=B(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=B(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return B(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=B(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>pt(e),[J(e,`next`)]),n(`prev`,()=>mt(e),[J(e,`previous`)]),n(`select`,()=>ht(e),[J(e,`all`)]),B(`label`,null,[this.caseField,J(e,`match case`)]),B(`label`,null,[this.reField,J(e,`regexp`)]),B(`label`,null,[this.wordField,J(e,`by word`)]),...e.state.readOnly?[]:[B(`br`),this.replaceField,n(`replace`,()=>_t(e),[J(e,`replace`)]),n(`replaceAll`,()=>vt(e),[J(e,`replace all`)])],B(`button`,{name:`close`,onclick:()=>wt(e),"aria-label":J(e,`close`),type:`button`},[`×`])])}commit(){let e=new Qe({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:G.of(e)}))}keydown(e){R(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?mt:pt)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),_t(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(G)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(H).top}};function J(e,t){return e.state.phrase(t)}var Dt=30,Ot=/[\s\.,:;?!]/;function kt(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-Dt),o=Math.min(i,n+Dt),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Dt;e++)if(!Ot.test(s[e+1])&&Ot.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Dt;e--)if(!Ot.test(s[e-1])&&Ot.test(s[e])){s=s.slice(0,e);break}}return j.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var At=j.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),jt=[K,g.low(ft),At],Mt=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},Y=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Q).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new w,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=en(s);if(i)o.add(n,n,C.widget({widget:new qt(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,C.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,X(f))}};function X(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new Mt(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Mt(r.from,n,r.diagnostic)}),r}function Nt(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Q).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(Ft))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Pt(e,t){return e.field(Z,!1)?t:t.concat(D.appendConfig.of(tn))}var Ft=D.define(),It=D.define(),Lt=D.define(),Z=x.define({create(){return new Y(C.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=X(n,e.selected.diagnostic,i)||X(n,null,i)}!n.size&&i&&t.state.facet(Q).autoPanel&&(i=null),e=new Y(n,i,r)}for(let n of t.effects)if(n.is(Ft)){let r=t.state.facet(Q).autoPanel?n.value.length?Yt.open:null:e.panel;e=Y.init(n.value,r,t.state)}else n.is(It)?e=new Y(e.diagnostics,n.value?Yt.open:null,e.selected):n.is(Lt)&&(e=new Y(e.diagnostics,e.panel,n.value));return e},provide:e=>[M.from(e,e=>e.panel),j.decorations.from(e,e=>e.diagnostics)]}),Rt=C.mark({class:`cm-lintRange cm-lintRange-active`});function zt(e,t,n){let{diagnostics:r}=e.state.field(Z),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Q).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:Bt(e,i)}}}:null}function Bt(e,t){return B(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Kt(e,t,!1)))}var Vt=e=>{let t=e.state.field(Z,!1);(!t||!t.panel)&&e.dispatch({effects:Pt(e.state,[It.of(!0)])});let n=me(e,Yt.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},Ht=e=>{let t=e.state.field(Z,!1);return!t||!t.panel?!1:(e.dispatch({effects:It.of(!1)}),!0)},Ut=[{key:`Mod-Shift-m`,run:Vt,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Z,!1);if(!t)return!1;let n=e.state.selection.main,r=X(t.diagnostics,null,n.to+1);return!r&&(r=X(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Q=E.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),..._(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Wt,tooltipFilter:Wt,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Wt(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Gt(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Kt(e,t,n){let r=n?Gt(t.actions):[];return B(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},B(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=X(e.state.field(Z).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),B(`u`,s.slice(c,c+1)),s.slice(c+1)];return B(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&B(`div`,{class:`cm-diagnosticSource`},t.source))}var qt=class extends h{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return B(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Jt=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Kt(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Yt=class e{constructor(e){this.view=e,this.items=[],this.list=B(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Ht(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=Gt(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=X(this.view.state.field(Z).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=B(`div`,{class:`cm-panel-lint`},this.list,B(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>Ht(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Z).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Z),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new Jt(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Jt(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=X(this.view.state.field(Z).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Lt.of(t)})}static open(t){return new e(t)}};function Xt(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Zt(e){return Xt(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Qt=j.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Zt(`#d11`)},".cm-lintRange-warning":{backgroundImage:Zt(`orange`)},".cm-lintRange-info":{backgroundImage:Zt(`#999`)},".cm-lintRange-hint":{backgroundImage:Zt(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function $t(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function en(e){let t=`hint`,n=1;for(let r of e){let e=$t(r.severity);e>n&&(n=e,t=r.severity)}return t}var tn=[Z,j.decorations.compute([Z],e=>{let{selected:t,panel:n}=e.field(Z);return!t||!n||t.from==t.to?C.none:C.set([Rt.range(t.from,t.to)])}),ue(zt,{hideOn:Nt}),Qt],nn=[P(),he(),N(),a(),ce(),ge(),fe(),v.allowMultipleSelections.of(!0),y(),T(I,{fallback:!0}),le(),Ce(),xe(),de(),F(),pe(),He(),_e.of([...be,...o,...Tt,...c,...ve,...Se,...Ut])];N(),a(),ge(),T(I,{fallback:!0}),_e.of([...o,...c]);function rn(e,t){let n=(0,Te.c)(4),r=t===void 0?!1:t,[i,a]=(0,we.useState)(void 0),o=(0,we.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,we.useEffect)(s,c),i}var $=n(),an=300;async function on(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new i(`Page headings response was not JSON`,{cause:e,status:t.status})}if(!t.ok){let e=p.safeParse(n);throw e.success?Error(e.data.title):new i(`Page headings error response did not match RFC 9457`,{status:t.status})}let r=m.safeParse(n);if(!r.success)throw new i(`Page headings response did not match success schema`,{status:t.status});return r.data.headings??[]}var sn=32,cn=12,ln=6,un=`open-knowledge:outline-nav`;function dn(e){let t=(0,Te.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(s,{name:`outline-panel`,children:(0,$.jsx)(fn,{...e})}),t[0]=e,t[1]=n),n}function fn(e){let t=(0,Te.c)(49),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{pages:o,loading:s}=oe(),c=ae(),{activeProvider:p,activeDocName:m}=l(),h,g;t[0]===n?(h=t[1],g=t[2]):(h=[`page-headings`,n],g=()=>on(n),t[0]=n,t[1]=h,t[2]=g);let _;t[3]!==n||t[4]!==s||t[5]!==o?(_=!s&&o.has(n),t[3]=n,t[4]=s,t[5]=o,t[6]=_):_=t[6];let v;t[7]!==h||t[8]!==g||t[9]!==_?(v={queryKey:h,queryFn:g,enabled:_,staleTime:1/0},t[7]=h,t[8]=g,t[9]=_,t[10]=v):v=t[10];let{data:y,isLoading:b,error:x}=d(v),S;t[11]===y?S=t[12]:(S=y===void 0?[]:y,t[11]=y,t[12]=S);let C=S,w,T;t[13]!==m||t[14]!==p||t[15]!==n||t[16]!==c?(w=()=>{if(!p||m!==n)return;let e=p.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,c.invalidateQueries({queryKey:[`page-headings`,n]})},an)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},T=[p,m,n,c],t[13]=m,t[14]=p,t[15]=n,t[16]=c,t[17]=w,t[18]=T):(w=t[17],T=t[18]),(0,we.useEffect)(w,T);let E;t[19]===C?E=t[20]:(E=C.map(pn),t[19]=C,t[20]=E);let D=rn(E,r),O;t[21]!==D||t[22]!==C?(O=D?C.findIndex(e=>e.slug===D):-1,t[21]=D,t[22]=C,t[23]=O):O=t[23];let k=O,A;t[24]!==n||t[25]!==r?(A=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&De(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(un,{detail:i}))},t[24]=n,t[25]=r,t[26]=A):A=t[26];let j=A,ce=((k>=0?C[k].level:1)-1)*cn+(cn-ln)/2,M=k*sn+(sn-ln)/2,N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(re,{children:`Outline`}),t[27]=N):N=t[27];let P;t[28]!==C.length||t[29]!==b?(P=!b&&(0,$.jsx)(ne,{children:C.length}),t[28]=C.length,t[29]=b,t[30]=P):P=t[30];let F;t[31]===P?F=t[32]:(F=(0,$.jsxs)(te,{children:[N,P]}),t[31]=P,t[32]=F);let I;t[33]!==k||t[34]!==D||t[35]!==x||t[36]!==j||t[37]!==C||t[38]!==b||t[39]!==ce||t[40]!==M?(I=x?(0,$.jsx)(u,{className:`px-2`,children:x instanceof Error?x.message:`Failed to load headings`}):C.length===0&&!b?(0,$.jsx)(f,{className:`px-2`,children:`No headings yet.`}):(0,$.jsxs)(`nav`,{"aria-label":`Document outline`,className:`relative`,children:[k>=0&&(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:ln,height:ln,transform:`translate(${ce}px, ${M}px)`}}),C.map((e,t)=>{let n=e.slug===D;return(0,$.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>j(t,e.slug),className:se(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*cn+20}px`},title:e.text,children:e.text},t)})]}),t[33]=k,t[34]=D,t[35]=x,t[36]=j,t[37]=C,t[38]=b,t[39]=ce,t[40]=M,t[41]=I):I=t[41];let L;t[42]!==b||t[43]!==I?(L=(0,$.jsx)(ee,{className:`px-3 py-2`,"aria-busy":b,children:I}),t[42]=b,t[43]=I,t[44]=L):L=t[44];let R;return t[45]!==a||t[46]!==F||t[47]!==L?(R=(0,$.jsxs)(ie,{className:a,children:[F,L]}),t[45]=a,t[46]=F,t[47]=L,t[48]=R):R=t[48],R}function pn(e){return e.slug}export{Oe as a,ke as i,dn as n,De as o,nn as r,un as t};
1
+ import{o as e}from"./chunk-CFjPhJqf.js";import{n as t,r as n,t as r}from"./compiler-runtime-CVnuRdak.js";import{$ as i,$t as a,D as o,E as s,O as c,n as l}from"./DocumentContext-D4lHVgL4.js";import{a as u,c as d,i as f,n as ee,o as te,r as ne,s as re,t as ie,u as ae}from"./panel-8fydlQgn.js";import{Ot as p,jt as m,s as oe}from"./doc-hash-D-COaeDG.js";import{r as se}from"./button-C1nwPVFQ.js";import{$ as h,At as g,Bt as _,Dt as v,E as y,Et as b,Ft as x,Ht as S,J as C,Mt as w,N as T,Ot as E,Pt as D,Q as O,Rt as k,Ut as A,X as j,_ as ce,_t as M,ct as N,dt as P,et as F,f as I,gt as L,ht as R,l as le,lt as ue,mt as de,nt as fe,ot as pe,rt as me,st as he,tt as ge,ut as _e,wt as z,y as ve,yt as B,zt as ye}from"./dist-D2RGH7XO.js";import{i as be,n as xe,o as Se,r as Ce}from"./dist-Cp-iTcML.js";var we=e(t(),1),Te=r(),Ee=new Map;function De(e,t){Ee.set(e,t)}function Oe(e){let t=Ee.get(e)??null;return Ee.delete(e),t}function ke(e){Ee.delete(e)}var Ae=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,V=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(Ae(e)):Ae,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return k(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=A(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ye(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(V.prototype[Symbol.iterator]=function(){return this});var je={from:-1,to:-1,match:/.*/.exec(``)},Me=`gm`+(/x/.unicode==null?``:`u`),Ne=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=je,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Ie(e,t,n,r,i);this.re=new RegExp(t,Me+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=Re(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Re(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Pe=new WeakMap,Fe=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Pe.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Pe.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Pe.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Ie=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=je,this.matchPos=Re(e,r),this.re=new RegExp(t,Me+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Fe.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=Re(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Fe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Ne.prototype[Symbol.iterator]=Ie.prototype[Symbol.iterator]=function(){return this});function Le(e){try{return new RegExp(e,Me),!0}catch{return!1}}function Re(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var ze=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=L(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),ee=b.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,j.scrollIntoView(ee.from,{y:`center`})],selection:ee})}),!0},Be={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Ve=E.define({combine(e){return _(e,Be,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function He(e){let t=[Je,qe];return e&&t.push(Ve.of(e)),t}var Ue=C.mark({class:`cm-selectionMatch`}),We=C.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Ge(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=z.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=z.Word)}function Ke(e,t,n,r){return e(t.sliceDoc(n,n+1))==z.Word&&e(t.sliceDoc(r-1,r))==z.Word}var qe=O.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Ve),{state:n}=e,r=n.selection;if(r.ranges.length>1)return C.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return C.none;let e=n.wordAt(i.head);if(!e)return C.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return C.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Ge(o,n,i.from,i.to)&&Ke(o,n,i.from,i.to)))return C.none}else if(a=n.sliceDoc(i.from,i.to),!a)return C.none}let s=[];for(let r of e.visibleRanges){let e=new V(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Ge(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(We.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Ue.range(r,a)),s.length>t.maxMatches))return C.none}}return C.set(s)}},{decorations:e=>e.decorations}),Je=j.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Ye=({state:e,dispatch:t})=>{let{selection:n}=e,r=b.create(n.ranges.map(t=>e.wordAt(t.head)||b.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Xe(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new V(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new V(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Ze=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Ye({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Xe(e,r);return i?(t(e.update({selection:e.selection.addRange(b.range(i.from,i.to),!1),effects:j.scrollIntoView(i.to)})),!0):!1},H=E.define({combine(e){return _(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Et(e),scrollToMatch:e=>j.scrollIntoView(e)})}}),Qe=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Le(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
+ `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new st(this):new nt(this)}getCursor(e,t=0,n){let r=e.doc?e:v.create({doc:e});return n??=r.doc.length,this.regexp?W(this,r,t,n):U(this,r,t,n)}},$e=class{constructor(e){this.spec=e}};function et(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function U(e,t,n,r){let i;return e.wholeWord&&(i=tt(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=et(e.test,t,i)),new V(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function tt(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(it(i,n-a))!=z.Word||t(at(i,n-a))!=z.Word)&&(t(at(i,r-a))!=z.Word||t(it(i,r-a))!=z.Word))}var nt=class extends $e{constructor(e){super(e)}nextMatch(e,t,n){let r=U(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=U(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=U(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=U(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=U(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function rt(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function W(e,t,n,r){let i;return e.wholeWord&&(i=ot(t.charCategorizer(t.selection.main.head))),e.test&&(i=rt(e.test,t,i)),new Ne(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function it(e,t){return e.slice(S(e,t,!1),t)}function at(e,t){return e.slice(t,S(e,t))}function ot(e){return(t,n,r)=>!r[0].length||(e(it(r.input,r.index))!=z.Word||e(at(r.input,r.index))!=z.Word)&&(e(at(r.input,r.index+r[0].length))!=z.Word||e(it(r.input,r.index+r[0].length))!=z.Word)}var st=class extends $e{nextMatch(e,t,n){let r=W(this.spec,e,n,e.doc.length).next();return r.done&&(r=W(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=W(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=W(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=W(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},G=D.define(),ct=D.define(),K=x.define({create(e){return new lt(bt(e).create(),null)},update(e,t){for(let n of t.effects)n.is(G)?e=new lt(n.value.create(),e.panel):n.is(ct)&&(e=new lt(e.query,n.value?yt:null));return e},provide:e=>M.from(e,e=>e.panel)}),lt=class{constructor(e,t){this.query=e,this.panel=t}},ut=C.mark({class:`cm-searchMatch`}),dt=C.mark({class:`cm-searchMatch cm-searchMatch-selected`}),ft=O.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(K))}update(e){let t=e.state.field(K);(t!=e.startState.field(K)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return C.none;let{view:n}=this,r=new w;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?dt:ut)})}return r.finish()}},{decorations:e=>e.decorations});function q(e){return t=>{let n=t.state.field(K,!1);return n&&n.query.spec.valid?e(t,n):Ct(t)}}var pt=q((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=b.single(r.from,r.to),a=e.state.facet(H);return e.dispatch({selection:i,effects:[kt(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),St(e),!0}),mt=q((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=b.single(i.from,i.to),o=e.state.facet(H);return e.dispatch({selection:a,effects:[kt(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),St(e),!0}),ht=q((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:b.create(n.map(e=>b.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),gt=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new V(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(b.range(t.value.from,t.value.to))}return t(e.update({selection:b.create(a,o),userEvent:`select.search.matches`})),!0},_t=q((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(j.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=b.single(o.from,o.to).map(d),u.push(kt(e,o)),u.push(n.facet(H).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),vt=q((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:j.announce.of(r),userEvent:`input.replace.all`}),!0});function yt(e){return e.state.facet(H).createPanel(e)}function bt(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(H);return new Qe({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function xt(e){let t=me(e,yt);return t&&t.dom.querySelector(`[main-field]`)}function St(e){let t=xt(e);t&&t==e.root.activeElement&&t.select()}var Ct=e=>{let t=e.state.field(K,!1);if(t&&t.panel){let n=xt(e);if(n&&n!=e.root.activeElement){let r=bt(e.state,t.query.spec);r.valid&&e.dispatch({effects:G.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[ct.of(!0),t?G.of(bt(e.state,t.query.spec)):D.appendConfig.of(jt)]});return!0},wt=e=>{let t=e.state.field(K,!1);if(!t||!t.panel)return!1;let n=me(e,yt);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:ct.of(!1)}),!0},Tt=[{key:`Mod-f`,run:Ct,scope:`editor search-panel`},{key:`F3`,run:pt,shift:mt,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:pt,shift:mt,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:wt,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:gt},{key:`Mod-Alt-g`,run:ze},{key:`Mod-d`,run:Ze,preventDefault:!0}],Et=class{constructor(e){this.view=e;let t=this.query=e.state.field(K).query.spec;this.commit=this.commit.bind(this),this.searchField=B(`input`,{value:t.search,placeholder:J(e,`Find`),"aria-label":J(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=B(`input`,{value:t.replace,placeholder:J(e,`Replace`),"aria-label":J(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=B(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=B(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=B(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return B(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=B(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>pt(e),[J(e,`next`)]),n(`prev`,()=>mt(e),[J(e,`previous`)]),n(`select`,()=>ht(e),[J(e,`all`)]),B(`label`,null,[this.caseField,J(e,`match case`)]),B(`label`,null,[this.reField,J(e,`regexp`)]),B(`label`,null,[this.wordField,J(e,`by word`)]),...e.state.readOnly?[]:[B(`br`),this.replaceField,n(`replace`,()=>_t(e),[J(e,`replace`)]),n(`replaceAll`,()=>vt(e),[J(e,`replace all`)])],B(`button`,{name:`close`,onclick:()=>wt(e),"aria-label":J(e,`close`),type:`button`},[`×`])])}commit(){let e=new Qe({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:G.of(e)}))}keydown(e){R(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?mt:pt)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),_t(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(G)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(H).top}};function J(e,t){return e.state.phrase(t)}var Dt=30,Ot=/[\s\.,:;?!]/;function kt(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-Dt),o=Math.min(i,n+Dt),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Dt;e++)if(!Ot.test(s[e+1])&&Ot.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Dt;e--)if(!Ot.test(s[e-1])&&Ot.test(s[e])){s=s.slice(0,e);break}}return j.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var At=j.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),jt=[K,g.low(ft),At],Mt=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},Y=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Q).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new w,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=en(s);if(i)o.add(n,n,C.widget({widget:new qt(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,C.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,X(f))}};function X(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new Mt(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Mt(r.from,n,r.diagnostic)}),r}function Nt(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Q).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(Ft))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Pt(e,t){return e.field(Z,!1)?t:t.concat(D.appendConfig.of(tn))}var Ft=D.define(),It=D.define(),Lt=D.define(),Z=x.define({create(){return new Y(C.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=X(n,e.selected.diagnostic,i)||X(n,null,i)}!n.size&&i&&t.state.facet(Q).autoPanel&&(i=null),e=new Y(n,i,r)}for(let n of t.effects)if(n.is(Ft)){let r=t.state.facet(Q).autoPanel?n.value.length?Yt.open:null:e.panel;e=Y.init(n.value,r,t.state)}else n.is(It)?e=new Y(e.diagnostics,n.value?Yt.open:null,e.selected):n.is(Lt)&&(e=new Y(e.diagnostics,e.panel,n.value));return e},provide:e=>[M.from(e,e=>e.panel),j.decorations.from(e,e=>e.diagnostics)]}),Rt=C.mark({class:`cm-lintRange cm-lintRange-active`});function zt(e,t,n){let{diagnostics:r}=e.state.field(Z),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Q).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:Bt(e,i)}}}:null}function Bt(e,t){return B(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Kt(e,t,!1)))}var Vt=e=>{let t=e.state.field(Z,!1);(!t||!t.panel)&&e.dispatch({effects:Pt(e.state,[It.of(!0)])});let n=me(e,Yt.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},Ht=e=>{let t=e.state.field(Z,!1);return!t||!t.panel?!1:(e.dispatch({effects:It.of(!1)}),!0)},Ut=[{key:`Mod-Shift-m`,run:Vt,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Z,!1);if(!t)return!1;let n=e.state.selection.main,r=X(t.diagnostics,null,n.to+1);return!r&&(r=X(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Q=E.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),..._(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Wt,tooltipFilter:Wt,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Wt(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Gt(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Kt(e,t,n){let r=n?Gt(t.actions):[];return B(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},B(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=X(e.state.field(Z).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),B(`u`,s.slice(c,c+1)),s.slice(c+1)];return B(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&B(`div`,{class:`cm-diagnosticSource`},t.source))}var qt=class extends h{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return B(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Jt=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Kt(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Yt=class e{constructor(e){this.view=e,this.items=[],this.list=B(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Ht(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=Gt(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=X(this.view.state.field(Z).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=B(`div`,{class:`cm-panel-lint`},this.list,B(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>Ht(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Z).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Z),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new Jt(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Jt(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=X(this.view.state.field(Z).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Lt.of(t)})}static open(t){return new e(t)}};function Xt(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Zt(e){return Xt(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Qt=j.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Zt(`#d11`)},".cm-lintRange-warning":{backgroundImage:Zt(`orange`)},".cm-lintRange-info":{backgroundImage:Zt(`#999`)},".cm-lintRange-hint":{backgroundImage:Zt(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function $t(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function en(e){let t=`hint`,n=1;for(let r of e){let e=$t(r.severity);e>n&&(n=e,t=r.severity)}return t}var tn=[Z,j.decorations.compute([Z],e=>{let{selected:t,panel:n}=e.field(Z);return!t||!n||t.from==t.to?C.none:C.set([Rt.range(t.from,t.to)])}),ue(zt,{hideOn:Nt}),Qt],nn=[P(),he(),N(),o(),ce(),ge(),fe(),v.allowMultipleSelections.of(!0),y(),T(I,{fallback:!0}),le(),Ce(),xe(),de(),F(),pe(),He(),_e.of([...be,...s,...Tt,...c,...ve,...Se,...Ut])];N(),o(),ge(),T(I,{fallback:!0}),_e.of([...s,...c]);function rn(e,t){let n=(0,Te.c)(4),r=t===void 0?!1:t,[i,a]=(0,we.useState)(void 0),o=(0,we.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,we.useEffect)(s,c),i}var $=n(),an=300;async function on(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`),n;try{n=await t.json()}catch(e){throw new i(`Page headings response was not JSON`,{cause:e,status:t.status})}if(!t.ok){let e=m.safeParse(n);throw e.success?Error(e.data.title):new i(`Page headings error response did not match RFC 9457`,{status:t.status})}let r=p.safeParse(n);if(!r.success)throw new i(`Page headings response did not match success schema`,{status:t.status});return r.data.headings??[]}var sn=32,cn=12,ln=6,un=`open-knowledge:outline-nav`;function dn(e){let t=(0,Te.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(a,{name:`outline-panel`,children:(0,$.jsx)(fn,{...e})}),t[0]=e,t[1]=n),n}function fn(e){let t=(0,Te.c)(49),{docName:n,isSourceMode:r,className:i}=e,a=i===void 0?``:i,{pages:o,loading:s}=oe(),c=ae(),{activeProvider:p,activeDocName:m}=l(),h,g;t[0]===n?(h=t[1],g=t[2]):(h=[`page-headings`,n],g=()=>on(n),t[0]=n,t[1]=h,t[2]=g);let _;t[3]!==n||t[4]!==s||t[5]!==o?(_=!s&&o.has(n),t[3]=n,t[4]=s,t[5]=o,t[6]=_):_=t[6];let v;t[7]!==h||t[8]!==g||t[9]!==_?(v={queryKey:h,queryFn:g,enabled:_,staleTime:1/0},t[7]=h,t[8]=g,t[9]=_,t[10]=v):v=t[10];let{data:y,isLoading:b,error:x}=d(v),S;t[11]===y?S=t[12]:(S=y===void 0?[]:y,t[11]=y,t[12]=S);let C=S,w,T;t[13]!==m||t[14]!==p||t[15]!==n||t[16]!==c?(w=()=>{if(!p||m!==n)return;let e=p.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,c.invalidateQueries({queryKey:[`page-headings`,n]})},an)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},T=[p,m,n,c],t[13]=m,t[14]=p,t[15]=n,t[16]=c,t[17]=w,t[18]=T):(w=t[17],T=t[18]),(0,we.useEffect)(w,T);let E;t[19]===C?E=t[20]:(E=C.map(pn),t[19]=C,t[20]=E);let D=rn(E,r),O;t[21]!==D||t[22]!==C?(O=D?C.findIndex(e=>e.slug===D):-1,t[21]=D,t[22]=C,t[23]=O):O=t[23];let k=O,A;t[24]!==n||t[25]!==r?(A=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&De(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(un,{detail:i}))},t[24]=n,t[25]=r,t[26]=A):A=t[26];let j=A,ce=((k>=0?C[k].level:1)-1)*cn+(cn-ln)/2,M=k*sn+(sn-ln)/2,N;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(re,{children:`Outline`}),t[27]=N):N=t[27];let P;t[28]!==C.length||t[29]!==b?(P=!b&&(0,$.jsx)(ne,{children:C.length}),t[28]=C.length,t[29]=b,t[30]=P):P=t[30];let F;t[31]===P?F=t[32]:(F=(0,$.jsxs)(te,{children:[N,P]}),t[31]=P,t[32]=F);let I;t[33]!==k||t[34]!==D||t[35]!==x||t[36]!==j||t[37]!==C||t[38]!==b||t[39]!==ce||t[40]!==M?(I=x?(0,$.jsx)(u,{className:`px-2`,children:x instanceof Error?x.message:`Failed to load headings`}):C.length===0&&!b?(0,$.jsx)(f,{className:`px-2`,children:`No headings yet.`}):(0,$.jsxs)(`nav`,{"aria-label":`Document outline`,className:`relative`,children:[k>=0&&(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 rounded-full bg-primary motion-safe:[transition:transform_0.25s_var(--ease-out-strong)]`,style:{width:ln,height:ln,transform:`translate(${ce}px, ${M}px)`}}),C.map((e,t)=>{let n=e.slug===D;return(0,$.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>j(t,e.slug),className:se(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*cn+20}px`},title:e.text,children:e.text},t)})]}),t[33]=k,t[34]=D,t[35]=x,t[36]=j,t[37]=C,t[38]=b,t[39]=ce,t[40]=M,t[41]=I):I=t[41];let L;t[42]!==b||t[43]!==I?(L=(0,$.jsx)(ee,{className:`px-3 py-2`,"aria-busy":b,children:I}),t[42]=b,t[43]=I,t[44]=L):L=t[44];let R;return t[45]!==a||t[46]!==F||t[47]!==L?(R=(0,$.jsxs)(ie,{className:a,children:[F,L]}),t[45]=a,t[46]=F,t[47]=L,t[48]=R):R=t[48],R}function pn(e){return e.slug}export{Oe as a,ke as i,dn as n,De as o,nn as r,un as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./src-DOAilbaA.js";import{$ as t,B as n,C as r,Q as i,V as a,W as o,_ as s,a as c,c as l,d as u,et as d,tt as f,v as p,y as m}from"./chunk-ICPOFSXX-BC5Xd13f.js";import{C as h}from"./src-L3wpjxBL.js";import{r as g}from"./chunk-5PVQY5BW-BpceE2BZ.js";import{t as _}from"./chunk-426QAEUC-jRhC4EYv.js";import{t as v}from"./rough.esm-DDK-gphn.js";var y=(e,t)=>d(e,`a`,-t),b=1e-10;function x(e,t){let n=C(e),r=n.filter(t=>S(t,e)),i=0,a=0,o=[];if(r.length>1){let t=O(r);for(let e=0;e<r.length;++e){let n=r[e];n.angle=Math.atan2(n.x-t.x,n.y-t.y)}r.sort((e,t)=>t.angle-e.angle);let n=r[r.length-1];for(let t=0;t<r.length;++t){let s=r[t];a+=(n.x+s.x)*(s.y-n.y);let c={x:(s.x+n.x)/2,y:(s.y+n.y)/2},l=null;for(let t=0;t<s.parentIndex.length;++t)if(n.parentIndex.includes(s.parentIndex[t])){let r=e[s.parentIndex[t]],i=Math.atan2(s.x-r.x,s.y-r.y),a=Math.atan2(n.x-r.x,n.y-r.y),o=a-i;o<0&&(o+=2*Math.PI);let u=a-o/2,d=T(c,{x:r.x+r.radius*Math.sin(u),y:r.y+r.radius*Math.cos(u)});d>r.radius*2&&(d=r.radius*2),(l==null||l.width>d)&&(l={circle:r,width:d,p1:s,p2:n,large:d>r.radius,sweep:!0})}l!=null&&(o.push(l),i+=w(l.circle.radius,l.width),n=s)}}else{let t=e[0];for(let n=1;n<e.length;++n)e[n].radius<t.radius&&(t=e[n]);let n=!1;for(let r=0;r<e.length;++r)if(T(e[r],t)>Math.abs(t.radius-e[r].radius)){n=!0;break}n?i=a=0:(i=t.radius*t.radius*Math.PI,o.push({circle:t,p1:{x:t.x,y:t.y+t.radius},p2:{x:t.x-b,y:t.y+t.radius},width:t.radius*2,large:!0,sweep:!0}))}return a/=2,t&&(t.area=i+a,t.arcArea=i,t.polygonArea=a,t.arcs=o,t.innerPoints=r,t.intersectionPoints=n),i+a}function S(e,t){return t.every(t=>T(e,t)<t.radius+b)}function C(e){let t=[];for(let n=0;n<e.length;++n)for(let r=n+1;r<e.length;++r){let i=D(e[n],e[r]);for(let e of i)e.parentIndex=[n,r],t.push(e)}return t}function w(e,t){return e*e*Math.acos(1-t/e)-(e-t)*Math.sqrt(t*(2*e-t))}function T(e,t){return Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))}function E(e,t,n){if(n>=e+t)return 0;if(n<=Math.abs(e-t))return Math.PI*Math.min(e,t)*Math.min(e,t);let r=e-(n*n-t*t+e*e)/(2*n),i=t-(n*n-e*e+t*t)/(2*n);return w(e,r)+w(t,i)}function D(e,t){let n=T(e,t),r=e.radius,i=t.radius;if(n>=r+i||n<=Math.abs(r-i))return[];let a=(r*r-i*i+n*n)/(2*n),o=Math.sqrt(r*r-a*a),s=e.x+a*(t.x-e.x)/n,c=e.y+a*(t.y-e.y)/n,l=-(t.y-e.y)*(o/n),u=-(t.x-e.x)*(o/n);return[{x:s+l,y:c-u},{x:s-l,y:c+u}]}function O(e){let t={x:0,y:0};for(let n of e)t.x+=n.x,t.y+=n.y;return t.x/=e.length,t.y/=e.length,t}function k(e,t,n,r){r||={};let i=r.maxIterations||100,a=r.tolerance||1e-10,o=e(t),s=e(n),c=n-t;if(o*s>0)throw`Initial bisect points must have opposite signs`;if(o===0)return t;if(s===0)return n;for(let n=0;n<i;++n){c/=2;let n=t+c,r=e(n);if(r*o>=0&&(t=n),Math.abs(c)<a||r===0)return n}return t+c}function A(e){let t=Array(e);for(let n=0;n<e;++n)t[n]=0;return t}function j(e,t){return A(e).map(()=>A(t))}function M(e,t){let n=0;for(let r=0;r<e.length;++r)n+=e[r]*t[r];return n}function N(e){return Math.sqrt(M(e,e))}function P(e,t,n){for(let r=0;r<t.length;++r)e[r]=t[r]*n}function F(e,t,n,r,i){for(let a=0;a<e.length;++a)e[a]=t*n[a]+r*i[a]}function I(e,t,n){n||={};let r=n.maxIterations||t.length*200,i=n.nonZeroDelta||1.05,a=n.zeroDelta||.001,o=n.minErrorDelta||1e-6,s=n.minErrorDelta||1e-5,c=n.rho===void 0?1:n.rho,l=n.chi===void 0?2:n.chi,u=n.psi===void 0?-.5:n.psi,d=n.sigma===void 0?.5:n.sigma,f,p=t.length,m=Array(p+1);m[0]=t,m[0].fx=e(t),m[0].id=0;for(let n=0;n<p;++n){let r=t.slice();r[n]=r[n]?r[n]*i:a,m[n+1]=r,m[n+1].fx=e(r),m[n+1].id=n+1}function h(e){for(let t=0;t<e.length;t++)m[p][t]=e[t];m[p].fx=e.fx}let g=(e,t)=>e.fx-t.fx,_=t.slice(),v=t.slice(),y=t.slice(),b=t.slice();for(let t=0;t<r;++t){if(m.sort(g),n.history){let e=m.map(e=>{let t=e.slice();return t.fx=e.fx,t.id=e.id,t});e.sort((e,t)=>e.id-t.id),n.history.push({x:m[0].slice(),fx:m[0].fx,simplex:e})}f=0;for(let e=0;e<p;++e)f=Math.max(f,Math.abs(m[0][e]-m[1][e]));if(Math.abs(m[0].fx-m[p].fx)<o&&f<s)break;for(let e=0;e<p;++e){_[e]=0;for(let t=0;t<p;++t)_[e]+=m[t][e];_[e]/=p}let t=m[p];if(F(v,1+c,_,-c,t),v.fx=e(v),v.fx<m[0].fx)F(b,1+l,_,-l,t),b.fx=e(b),b.fx<v.fx?h(b):h(v);else if(v.fx>=m[p-1].fx){let n=!1;if(v.fx>t.fx?(F(y,1+u,_,-u,t),y.fx=e(y),y.fx<t.fx?h(y):n=!0):(F(y,1-u*c,_,u*c,t),y.fx=e(y),y.fx<v.fx?h(y):n=!0),n){if(d>=1)break;for(let t=1;t<m.length;++t)F(m[t],1-d,m[0],d,m[t]),m[t].fx=e(m[t])}}else h(v)}return m.sort(g),{fx:m[0].fx,x:m[0]}}function L(e,t,n,r,i,a,o){let s=n.fx,c=M(n.fxprime,t),l=s,u=s,d=c,f=0;i||=1,a||=1e-6,o||=.1;function p(u,f,p){for(let m=0;m<16;++m)if(i=(u+f)/2,F(r.x,1,n.x,i,t),l=r.fx=e(r.x,r.fxprime),d=M(r.fxprime,t),l>s+a*i*c||l>=p)f=i;else{if(Math.abs(d)<=-o*c)return i;d*(f-u)>=0&&(f=u),u=i,p=l}return 0}for(let m=0;m<10;++m){if(F(r.x,1,n.x,i,t),l=r.fx=e(r.x,r.fxprime),d=M(r.fxprime,t),l>s+a*i*c||m&&l>=u)return p(f,i,u);if(Math.abs(d)<=-o*c)return i;if(d>=0)return p(i,f,l);u=l,f=i,i*=2}return i}function ee(e,t,n){let r={x:t.slice(),fx:0,fxprime:t.slice()},i={x:t.slice(),fx:0,fxprime:t.slice()},a=t.slice(),o,s,c=1,l;n||={},l=n.maxIterations||t.length*20,r.fx=e(r.x,r.fxprime),o=r.fxprime.slice(),P(o,r.fxprime,-1);for(let t=0;t<l;++t){if(c=L(e,o,r,i,c),n.history&&n.history.push({x:r.x.slice(),fx:r.fx,fxprime:r.fxprime.slice(),alpha:c}),!c)P(o,r.fxprime,-1);else{F(a,1,i.fxprime,-1,r.fxprime);let e=M(r.fxprime,r.fxprime),t=Math.max(0,M(a,i.fxprime)/e);F(o,t,o,-1,i.fxprime),s=r,r=i,i=s}if(N(r.fxprime)<=1e-5)break}return n.history&&n.history.push({x:r.x.slice(),fx:r.fx,fxprime:r.fxprime.slice(),alpha:c}),r}function te(e,t={}){t.maxIterations=t.maxIterations||500;let n=t.initialLayout||oe,r=t.lossFunction||z,i=re(e,t),a=n(i,t),o=Object.keys(a),s=[];for(let e of o)s.push(a[e].x),s.push(a[e].y);let c=I(e=>{let t={};for(let n=0;n<o.length;++n){let r=o[n];t[r]={x:e[2*n],y:e[2*n+1],radius:a[r].radius}}return r(t,i)},s,t).x;for(let e=0;e<o.length;++e){let t=o[e];a[t].x=c[2*e],a[t].y=c[2*e+1]}return a}var ne=1e-10;function R(e,t,n){return Math.min(e,t)*Math.min(e,t)*Math.PI<=n+ne?Math.abs(e-t):k(r=>E(e,t,r)-n,0,e+t)}function re(e,t={}){let n=t.distinct,r=e.map(e=>Object.assign({},e));function i(e){return e.join(`;`)}if(n){let e=new Map;for(let t of r)for(let n=0;n<t.sets.length;n++){let r=String(t.sets[n]);e.set(r,t.size+(e.get(r)||0));for(let i=n+1;i<t.sets.length;i++){let n=String(t.sets[i]),a=`${r};${n}`,o=`${n};${r}`;e.set(a,t.size+(e.get(a)||0)),e.set(o,t.size+(e.get(o)||0))}}for(let t of r)t.sets.length<3&&(t.size=e.get(i(t.sets)))}let a=[],o=new Set;for(let e of r)if(e.sets.length===1)a.push(e.sets[0]);else if(e.sets.length===2){let t=e.sets[0],n=e.sets[1];o.add(i(e.sets)),o.add(i([n,t]))}a.sort((e,t)=>e===t?0:e<t?-1:1);for(let e=0;e<a.length;++e){let t=a[e];for(let n=e+1;n<a.length;++n){let e=a[n];o.has(i([t,e]))||r.push({sets:[t,e],size:0})}}return r}function ie(e,t,n){let r=j(t.length,t.length),i=j(t.length,t.length);return e.filter(e=>e.sets.length===2).forEach(e=>{let a=n[e.sets[0]],o=n[e.sets[1]],s=R(Math.sqrt(t[a].size/Math.PI),Math.sqrt(t[o].size/Math.PI),e.size);r[a][o]=r[o][a]=s;let c=0;e.size+1e-10>=Math.min(t[a].size,t[o].size)?c=1:e.size<=1e-10&&(c=-1),i[a][o]=i[o][a]=c}),{distances:r,constraints:i}}function ae(e,t,n,r){for(let e=0;e<t.length;++e)t[e]=0;let i=0;for(let a=0;a<n.length;++a){let o=e[2*a],s=e[2*a+1];for(let c=a+1;c<n.length;++c){let l=e[2*c],u=e[2*c+1],d=n[a][c],f=r[a][c],p=(l-o)*(l-o)+(u-s)*(u-s),m=Math.sqrt(p),h=p-d*d;f>0&&m<=d||f<0&&m>=d||(i+=2*h*h,t[2*a]+=4*h*(o-l),t[2*a+1]+=4*h*(s-u),t[2*c]+=4*h*(l-o),t[2*c+1]+=4*h*(u-s))}}return i}function oe(e,t={}){let n=ce(e,t),r=t.lossFunction||z;if(e.length>=8){let i=se(e,t),a=r(i,e),o=r(n,e);a+1e-8<o&&(n=i)}return n}function se(e,t={}){let n=t.restarts||10,r=[],i={};for(let t of e)t.sets.length===1&&(i[t.sets[0]]=r.length,r.push(t));let{distances:a,constraints:o}=ie(e,r,i),s=N(a.map(N))/a.length;a=a.map(e=>e.map(e=>e/s));let c=(e,t)=>ae(e,t,a,o),l=null;for(let e=0;e<n;++e){let e=ee(c,A(a.length*2).map(Math.random),t);(!l||e.fx<l.fx)&&(l=e)}let u=l.x,d={};for(let e=0;e<r.length;++e){let t=r[e];d[t.sets[0]]={x:u[2*e]*s,y:u[2*e+1]*s,radius:Math.sqrt(t.size/Math.PI)}}if(t.history)for(let e of t.history)P(e.x,s);return d}function ce(e,t){let n=t&&t.lossFunction?t.lossFunction:z,r={},i={};for(let t of e)if(t.sets.length===1){let e=t.sets[0];r[e]={x:1e10,y:1e10,rowid:r.length,size:t.size,radius:Math.sqrt(t.size/Math.PI)},i[e]=[]}e=e.filter(e=>e.sets.length===2);for(let t of e){let e=t.weight==null?1:t.weight,n=t.sets[0],a=t.sets[1];t.size+ne>=Math.min(r[n].size,r[a].size)&&(e=0),i[n].push({set:a,size:t.size,weight:e}),i[a].push({set:n,size:t.size,weight:e})}let a=[];Object.keys(i).forEach(e=>{let t=0;for(let n=0;n<i[e].length;++n)t+=i[e][n].size*i[e][n].weight;a.push({set:e,size:t})});function o(e,t){return t.size-e.size}a.sort(o);let s={};function c(e){return e.set in s}function l(e,t){r[t].x=e.x,r[t].y=e.y,s[t]=!0}l({x:0,y:0},a[0].set);for(let t=1;t<a.length;++t){let s=a[t].set,d=i[s].filter(c),f=r[s];if(d.sort(o),d.length===0)throw`ERROR: missing pairwise overlap information`;let p=[];for(var u=0;u<d.length;++u){let e=r[d[u].set],t=R(f.radius,e.radius,d[u].size);p.push({x:e.x+t,y:e.y}),p.push({x:e.x-t,y:e.y}),p.push({y:e.y+t,x:e.x}),p.push({y:e.y-t,x:e.x});for(let n=u+1;n<d.length;++n){let i=r[d[n].set],a=R(f.radius,i.radius,d[n].size),o=D({x:e.x,y:e.y,radius:t},{x:i.x,y:i.y,radius:a});p.push(...o)}}let m=1e50,h=p[0];for(let t of p){r[s].x=t.x,r[s].y=t.y;let i=n(r,e);i<m&&(m=i,h=t)}l(h,s)}return r}function z(e,t){let n=0;for(let r of t){if(r.sets.length===1)continue;let t;if(r.sets.length===2){let n=e[r.sets[0]],i=e[r.sets[1]];t=E(n.radius,i.radius,T(n,i))}else t=x(r.sets.map(t=>e[t]));let i=r.weight==null?1:r.weight;n+=i*(t-r.size)*(t-r.size)}return n}function le(e,t){let n=0;for(let r of t){if(r.sets.length===1)continue;let t;if(r.sets.length===2){let n=e[r.sets[0]],i=e[r.sets[1]];t=E(n.radius,i.radius,T(n,i))}else t=x(r.sets.map(t=>e[t]));let i=r.weight==null?1:r.weight,a=Math.log((t+1)/(r.size+1));n+=i*a*a}return n}function ue(e,t,n){if(n==null?e.sort((e,t)=>t.radius-e.radius):e.sort(n),e.length>0){let t=e[0].x,n=e[0].y;for(let r of e)r.x-=t,r.y-=n}if(e.length===2&&T(e[0],e[1])<Math.abs(e[1].radius-e[0].radius)&&(e[1].x=e[0].x+e[0].radius-e[1].radius-1e-10,e[1].y=e[0].y),e.length>1){let n=Math.atan2(e[1].x,e[1].y)-t,r=Math.cos(n),i=Math.sin(n);for(let t of e){let e=t.x,n=t.y;t.x=r*e-i*n,t.y=i*e+r*n}}if(e.length>2){let n=Math.atan2(e[2].x,e[2].y)-t;for(;n<0;)n+=2*Math.PI;for(;n>2*Math.PI;)n-=2*Math.PI;if(n>Math.PI){let t=e[1].y/(1e-10+e[1].x);for(let n of e){var r=(n.x+t*n.y)/(1+t*t);n.x=2*r-n.x,n.y=2*r*t-n.y}}}}function de(e){e.forEach(e=>{e.parent=e});function t(e){return e.parent!==e&&(e.parent=t(e.parent)),e.parent}function n(e,n){let r=t(e);r.parent=t(n)}for(let t=0;t<e.length;++t)for(let r=t+1;r<e.length;++r){let i=e[t].radius+e[r].radius;T(e[t],e[r])+1e-10<i&&n(e[r],e[t])}let r=new Map;for(let n=0;n<e.length;++n){let i=t(e[n]).parent.setid;r.has(i)||r.set(i,[]),r.get(i).push(e[n])}return e.forEach(e=>{delete e.parent}),Array.from(r.values())}function B(e){let t=t=>({max:e.reduce((e,n)=>Math.max(e,n[t]+n.radius),-1/0),min:e.reduce((e,n)=>Math.min(e,n[t]-n.radius),1/0)});return{xRange:t(`x`),yRange:t(`y`)}}function fe(e,t,n){t??=Math.PI/2;let r=he(e).map(e=>Object.assign({},e)),i=de(r);for(let e of i){ue(e,t,n);let r=B(e);e.size=(r.xRange.max-r.xRange.min)*(r.yRange.max-r.yRange.min),e.bounds=r}i.sort((e,t)=>t.size-e.size),r=i[0];let a=r.bounds,o=(a.xRange.max-a.xRange.min)/50;function s(e,t,n){if(!e)return;let i=e.bounds,s,c;if(t)s=a.xRange.max-i.xRange.min+o;else{s=a.xRange.max-i.xRange.max;let e=(i.xRange.max-i.xRange.min)/2-(a.xRange.max-a.xRange.min)/2;e<0&&(s+=e)}if(n)c=a.yRange.max-i.yRange.min+o;else{c=a.yRange.max-i.yRange.max;let e=(i.yRange.max-i.yRange.min)/2-(a.yRange.max-a.yRange.min)/2;e<0&&(c+=e)}for(let t of e)t.x+=s,t.y+=c,r.push(t)}let c=1;for(;c<i.length;)s(i[c],!0,!1),s(i[c+1],!1,!0),s(i[c+2],!0,!0),c+=3,a=B(r);return me(r)}function pe(e,t,n,r,i){let a=he(e);t-=2*r,n-=2*r;let{xRange:o,yRange:s}=B(a);if(o.max===o.min||s.max===s.min)return console.log(`not scaling solution: zero size detected`),e;let c,l;if(i){let e=Math.sqrt(i/Math.PI)*2;c=t/e,l=n/e}else c=t/(o.max-o.min),l=n/(s.max-s.min);let u=Math.min(l,c),d=(t-(o.max-o.min)*u)/2,f=(n-(s.max-s.min)*u)/2;return me(a.map(e=>({radius:u*e.radius,x:r+d+(e.x-o.min)*u,y:r+f+(e.y-s.min)*u,setid:e.setid})))}function me(e){let t={};for(let n of e)t[n.setid]=n;return t}function he(e){return Object.keys(e).map(t=>Object.assign(e[t],{setid:t}))}function ge(e={}){let t=!1,n=600,r=350,i=15,a=1e3,o=Math.PI/2,s=!0,c=null,l=!0,u=!0,d=null,f=null,p=!1,m=null,h=e&&e.symmetricalTextCentre?e.symmetricalTextCentre:!1,g={},_=e&&e.colourScheme?e.colourScheme:e&&e.colorScheme?e.colorScheme:[`#1f77b4`,`#ff7f0e`,`#2ca02c`,`#d62728`,`#9467bd`,`#8c564b`,`#e377c2`,`#7f7f7f`,`#bcbd22`,`#17becf`],v=0,y=function(e){if(e in g)return g[e];var t=g[e]=_[v];return v+=1,v>=_.length&&(v=0),t},b=te,x=z;function S(g){let _=g.datum(),v=new Set;_.forEach(e=>{e.size==0&&e.sets.length==1&&v.add(e.sets[0])}),_=_.filter(e=>!e.sets.some(e=>v.has(e)));let S={},C={};if(_.length>0){let e=b(_,{lossFunction:x,distinct:p});s&&(e=fe(e,o,f)),S=pe(e,n,r,i,c),C=ye(S,_,h)}let w={};_.forEach(e=>{e.label&&(w[e.sets]=e.label)});function T(e){if(e.sets in w)return w[e.sets];if(e.sets.length==1)return``+e.sets[0]}g.selectAll(`svg`).data([S]).enter().append(`svg`);let E=g.select(`svg`);t?E.attr(`viewBox`,`0 0 ${n} ${r}`):E.attr(`width`,n).attr(`height`,r);let D={},O=!1;E.selectAll(`.venn-area path`).each(function(e){let t=this.getAttribute(`d`);e.sets.length==1&&t&&!p&&(O=!0,D[e.sets[0]]=xe(t))});function k(e){return t=>we(e.sets.map(e=>{let i=D[e],a=S[e];return i||={x:n/2,y:r/2,radius:1},a||={x:n/2,y:r/2,radius:1},{x:i.x*(1-t)+a.x*t,y:i.y*(1-t)+a.y*t,radius:i.radius*(1-t)+a.radius*t}}),m)}let A=E.selectAll(`.venn-area`).data(_,e=>e.sets),j=A.enter().append(`g`).attr(`class`,e=>`venn-area venn-${e.sets.length==1?`circle`:`intersection`}${e.colour||e.color?` venn-coloured`:``}`).attr(`data-venn-sets`,e=>e.sets.join(`_`)),M=j.append(`path`),N=j.append(`text`).attr(`class`,`label`).text(e=>T(e)).attr(`text-anchor`,`middle`).attr(`dy`,`.35em`).attr(`x`,n/2).attr(`y`,r/2);u&&(M.style(`fill-opacity`,`0`).filter(e=>e.sets.length==1).style(`fill`,e=>e.colour?e.colour:e.color?e.color:y(e.sets)).style(`fill-opacity`,`.25`),N.style(`fill`,t=>t.colour||t.color?`#FFF`:e.textFill?e.textFill:t.sets.length==1?y(t.sets):`#444`));function P(e){return typeof e.transition==`function`?e.transition(`venn`).duration(a):e}let F=g;O&&typeof F.transition==`function`?(F=P(g),F.selectAll(`path`).attrTween(`d`,k)):F.selectAll(`path`).attr(`d`,e=>we(e.sets.map(e=>S[e])),m);let I=F.selectAll(`text`).filter(e=>e.sets in C).text(e=>T(e)).attr(`x`,e=>Math.floor(C[e.sets].x)).attr(`y`,e=>Math.floor(C[e.sets].y));l&&(O?`on`in I?I.on(`end`,V(S,T)):I.each(`end`,V(S,T)):I.each(V(S,T)));let L=P(A.exit()).remove();typeof A.transition==`function`&&L.selectAll(`path`).attrTween(`d`,k);let ee=L.selectAll(`text`).attr(`x`,n/2).attr(`y`,r/2);return d!==null&&(N.style(`font-size`,`0px`),I.style(`font-size`,d),ee.style(`font-size`,`0px`)),{circles:S,textCentres:C,nodes:A,enter:j,update:F,exit:L}}return S.wrap=function(e){return arguments.length?(l=e,S):l},S.useViewBox=function(){return t=!0,S},S.width=function(e){return arguments.length?(n=e,S):n},S.height=function(e){return arguments.length?(r=e,S):r},S.padding=function(e){return arguments.length?(i=e,S):i},S.distinct=function(e){return arguments.length?(p=e,S):p},S.colours=function(e){return arguments.length?(y=e,S):y},S.colors=function(e){return arguments.length?(y=e,S):y},S.fontSize=function(e){return arguments.length?(d=e,S):d},S.round=function(e){return arguments.length?(m=e,S):m},S.duration=function(e){return arguments.length?(a=e,S):a},S.layoutFunction=function(e){return arguments.length?(b=e,S):b},S.normalize=function(e){return arguments.length?(s=e,S):s},S.scaleToFit=function(e){return arguments.length?(c=e,S):c},S.styled=function(e){return arguments.length?(u=e,S):u},S.orientation=function(e){return arguments.length?(o=e,S):o},S.orientationOrder=function(e){return arguments.length?(f=e,S):f},S.lossFunction=function(e){return arguments.length?(x=e===`default`?z:e===`logRatio`?le:e,S):x},S}function V(e,t){return function(n){let r=this,i=e[n.sets[0]].radius||50,a=t(n)||``,o=a.split(/\s+/).reverse(),s=(a.length+o.length)/3,c=o.pop(),l=[c],u=0,d=1.1;r.textContent=null;let f=[];function p(e){let t=r.ownerDocument.createElementNS(r.namespaceURI,`tspan`);return t.textContent=e,f.push(t),r.append(t),t}let m=p(c);for(;c=o.pop(),c;){l.push(c);let e=l.join(` `);m.textContent=e,e.length>s&&m.getComputedTextLength()>i&&(l.pop(),m.textContent=l.join(` `),l=[c],m=p(c),u++)}let h=.35-u*d/2,g=r.getAttribute(`x`),_=r.getAttribute(`y`);f.forEach((e,t)=>{e.setAttribute(`x`,g),e.setAttribute(`y`,_),e.setAttribute(`dy`,`${h+t*d}em`)})}}function H(e,t,n){let r=t[0].radius-T(t[0],e);for(let n=1;n<t.length;++n){let i=t[n].radius-T(t[n],e);i<=r&&(r=i)}for(let t=0;t<n.length;++t){let i=T(n[t],e)-n[t].radius;i<=r&&(r=i)}return r}function _e(e,t,n){let r=[];for(let t of e)r.push({x:t.x,y:t.y}),r.push({x:t.x+t.radius/2,y:t.y}),r.push({x:t.x-t.radius/2,y:t.y}),r.push({x:t.x,y:t.y+t.radius/2}),r.push({x:t.x,y:t.y-t.radius/2});let i=r[0],a=H(r[0],e,t);for(let n=1;n<r.length;++n){let o=H(r[n],e,t);o>=a&&(i=r[n],a=o)}let o=I(n=>-1*H({x:n[0],y:n[1]},e,t),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,s={x:n?0:o[0],y:o[1]},c=!0;for(let t of e)if(T(s,t)>t.radius){c=!1;break}for(let e of t)if(T(s,e)<e.radius){c=!1;break}if(c)return s;if(e.length==1)return{x:e[0].x,y:e[0].y};let l={};return x(e,l),l.arcs.length===0?{x:0,y:-1e3,disjoint:!0}:l.arcs.length==1?{x:l.arcs[0].circle.x,y:l.arcs[0].circle.y}:t.length?_e(e,[]):O(l.arcs.map(e=>e.p1))}function ve(e){let t={},n=Object.keys(e);for(let e of n)t[e]=[];for(let r=0;r<n.length;r++){let i=n[r],a=e[i];for(let o=r+1;o<n.length;++o){let r=n[o],s=e[r],c=T(a,s);c+s.radius<=a.radius+1e-10?t[r].push(i):c+a.radius<=s.radius+1e-10&&t[i].push(r)}}return t}function ye(e,t,n){let r={},i=ve(e);for(let a=0;a<t.length;++a){let o=t[a].sets,s={},c={};for(let e=0;e<o.length;++e){s[o[e]]=!0;let t=i[o[e]];for(let e=0;e<t.length;++e)c[t[e]]=!0}let l=[],u=[];for(let t in e)t in s?l.push(e[t]):t in c||u.push(e[t]);let d=_e(l,u,n);r[o]=d,d.disjoint&&t[a].size>0&&console.log(`WARNING: area `+o+` not represented on screen`)}return r}function be(e,t,n){let r=[];return r.push(`
1
+ import{n as e}from"./src-BXk72DrU.js";import{$ as t,B as n,C as r,Q as i,V as a,W as o,_ as s,a as c,c as l,d as u,et as d,tt as f,v as p,y as m}from"./chunk-ICPOFSXX-rmT7ehAO.js";import{C as h}from"./src-BYmEUJ3I.js";import{r as g}from"./chunk-5PVQY5BW-kcWn_d-_.js";import{t as _}from"./chunk-426QAEUC-b3iWz8H-.js";import{t as v}from"./rough.esm-BgPNbngg.js";var y=(e,t)=>d(e,`a`,-t),b=1e-10;function x(e,t){let n=C(e),r=n.filter(t=>S(t,e)),i=0,a=0,o=[];if(r.length>1){let t=O(r);for(let e=0;e<r.length;++e){let n=r[e];n.angle=Math.atan2(n.x-t.x,n.y-t.y)}r.sort((e,t)=>t.angle-e.angle);let n=r[r.length-1];for(let t=0;t<r.length;++t){let s=r[t];a+=(n.x+s.x)*(s.y-n.y);let c={x:(s.x+n.x)/2,y:(s.y+n.y)/2},l=null;for(let t=0;t<s.parentIndex.length;++t)if(n.parentIndex.includes(s.parentIndex[t])){let r=e[s.parentIndex[t]],i=Math.atan2(s.x-r.x,s.y-r.y),a=Math.atan2(n.x-r.x,n.y-r.y),o=a-i;o<0&&(o+=2*Math.PI);let u=a-o/2,d=T(c,{x:r.x+r.radius*Math.sin(u),y:r.y+r.radius*Math.cos(u)});d>r.radius*2&&(d=r.radius*2),(l==null||l.width>d)&&(l={circle:r,width:d,p1:s,p2:n,large:d>r.radius,sweep:!0})}l!=null&&(o.push(l),i+=w(l.circle.radius,l.width),n=s)}}else{let t=e[0];for(let n=1;n<e.length;++n)e[n].radius<t.radius&&(t=e[n]);let n=!1;for(let r=0;r<e.length;++r)if(T(e[r],t)>Math.abs(t.radius-e[r].radius)){n=!0;break}n?i=a=0:(i=t.radius*t.radius*Math.PI,o.push({circle:t,p1:{x:t.x,y:t.y+t.radius},p2:{x:t.x-b,y:t.y+t.radius},width:t.radius*2,large:!0,sweep:!0}))}return a/=2,t&&(t.area=i+a,t.arcArea=i,t.polygonArea=a,t.arcs=o,t.innerPoints=r,t.intersectionPoints=n),i+a}function S(e,t){return t.every(t=>T(e,t)<t.radius+b)}function C(e){let t=[];for(let n=0;n<e.length;++n)for(let r=n+1;r<e.length;++r){let i=D(e[n],e[r]);for(let e of i)e.parentIndex=[n,r],t.push(e)}return t}function w(e,t){return e*e*Math.acos(1-t/e)-(e-t)*Math.sqrt(t*(2*e-t))}function T(e,t){return Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))}function E(e,t,n){if(n>=e+t)return 0;if(n<=Math.abs(e-t))return Math.PI*Math.min(e,t)*Math.min(e,t);let r=e-(n*n-t*t+e*e)/(2*n),i=t-(n*n-e*e+t*t)/(2*n);return w(e,r)+w(t,i)}function D(e,t){let n=T(e,t),r=e.radius,i=t.radius;if(n>=r+i||n<=Math.abs(r-i))return[];let a=(r*r-i*i+n*n)/(2*n),o=Math.sqrt(r*r-a*a),s=e.x+a*(t.x-e.x)/n,c=e.y+a*(t.y-e.y)/n,l=-(t.y-e.y)*(o/n),u=-(t.x-e.x)*(o/n);return[{x:s+l,y:c-u},{x:s-l,y:c+u}]}function O(e){let t={x:0,y:0};for(let n of e)t.x+=n.x,t.y+=n.y;return t.x/=e.length,t.y/=e.length,t}function k(e,t,n,r){r||={};let i=r.maxIterations||100,a=r.tolerance||1e-10,o=e(t),s=e(n),c=n-t;if(o*s>0)throw`Initial bisect points must have opposite signs`;if(o===0)return t;if(s===0)return n;for(let n=0;n<i;++n){c/=2;let n=t+c,r=e(n);if(r*o>=0&&(t=n),Math.abs(c)<a||r===0)return n}return t+c}function A(e){let t=Array(e);for(let n=0;n<e;++n)t[n]=0;return t}function j(e,t){return A(e).map(()=>A(t))}function M(e,t){let n=0;for(let r=0;r<e.length;++r)n+=e[r]*t[r];return n}function N(e){return Math.sqrt(M(e,e))}function P(e,t,n){for(let r=0;r<t.length;++r)e[r]=t[r]*n}function F(e,t,n,r,i){for(let a=0;a<e.length;++a)e[a]=t*n[a]+r*i[a]}function I(e,t,n){n||={};let r=n.maxIterations||t.length*200,i=n.nonZeroDelta||1.05,a=n.zeroDelta||.001,o=n.minErrorDelta||1e-6,s=n.minErrorDelta||1e-5,c=n.rho===void 0?1:n.rho,l=n.chi===void 0?2:n.chi,u=n.psi===void 0?-.5:n.psi,d=n.sigma===void 0?.5:n.sigma,f,p=t.length,m=Array(p+1);m[0]=t,m[0].fx=e(t),m[0].id=0;for(let n=0;n<p;++n){let r=t.slice();r[n]=r[n]?r[n]*i:a,m[n+1]=r,m[n+1].fx=e(r),m[n+1].id=n+1}function h(e){for(let t=0;t<e.length;t++)m[p][t]=e[t];m[p].fx=e.fx}let g=(e,t)=>e.fx-t.fx,_=t.slice(),v=t.slice(),y=t.slice(),b=t.slice();for(let t=0;t<r;++t){if(m.sort(g),n.history){let e=m.map(e=>{let t=e.slice();return t.fx=e.fx,t.id=e.id,t});e.sort((e,t)=>e.id-t.id),n.history.push({x:m[0].slice(),fx:m[0].fx,simplex:e})}f=0;for(let e=0;e<p;++e)f=Math.max(f,Math.abs(m[0][e]-m[1][e]));if(Math.abs(m[0].fx-m[p].fx)<o&&f<s)break;for(let e=0;e<p;++e){_[e]=0;for(let t=0;t<p;++t)_[e]+=m[t][e];_[e]/=p}let t=m[p];if(F(v,1+c,_,-c,t),v.fx=e(v),v.fx<m[0].fx)F(b,1+l,_,-l,t),b.fx=e(b),b.fx<v.fx?h(b):h(v);else if(v.fx>=m[p-1].fx){let n=!1;if(v.fx>t.fx?(F(y,1+u,_,-u,t),y.fx=e(y),y.fx<t.fx?h(y):n=!0):(F(y,1-u*c,_,u*c,t),y.fx=e(y),y.fx<v.fx?h(y):n=!0),n){if(d>=1)break;for(let t=1;t<m.length;++t)F(m[t],1-d,m[0],d,m[t]),m[t].fx=e(m[t])}}else h(v)}return m.sort(g),{fx:m[0].fx,x:m[0]}}function L(e,t,n,r,i,a,o){let s=n.fx,c=M(n.fxprime,t),l=s,u=s,d=c,f=0;i||=1,a||=1e-6,o||=.1;function p(u,f,p){for(let m=0;m<16;++m)if(i=(u+f)/2,F(r.x,1,n.x,i,t),l=r.fx=e(r.x,r.fxprime),d=M(r.fxprime,t),l>s+a*i*c||l>=p)f=i;else{if(Math.abs(d)<=-o*c)return i;d*(f-u)>=0&&(f=u),u=i,p=l}return 0}for(let m=0;m<10;++m){if(F(r.x,1,n.x,i,t),l=r.fx=e(r.x,r.fxprime),d=M(r.fxprime,t),l>s+a*i*c||m&&l>=u)return p(f,i,u);if(Math.abs(d)<=-o*c)return i;if(d>=0)return p(i,f,l);u=l,f=i,i*=2}return i}function ee(e,t,n){let r={x:t.slice(),fx:0,fxprime:t.slice()},i={x:t.slice(),fx:0,fxprime:t.slice()},a=t.slice(),o,s,c=1,l;n||={},l=n.maxIterations||t.length*20,r.fx=e(r.x,r.fxprime),o=r.fxprime.slice(),P(o,r.fxprime,-1);for(let t=0;t<l;++t){if(c=L(e,o,r,i,c),n.history&&n.history.push({x:r.x.slice(),fx:r.fx,fxprime:r.fxprime.slice(),alpha:c}),!c)P(o,r.fxprime,-1);else{F(a,1,i.fxprime,-1,r.fxprime);let e=M(r.fxprime,r.fxprime),t=Math.max(0,M(a,i.fxprime)/e);F(o,t,o,-1,i.fxprime),s=r,r=i,i=s}if(N(r.fxprime)<=1e-5)break}return n.history&&n.history.push({x:r.x.slice(),fx:r.fx,fxprime:r.fxprime.slice(),alpha:c}),r}function te(e,t={}){t.maxIterations=t.maxIterations||500;let n=t.initialLayout||oe,r=t.lossFunction||z,i=re(e,t),a=n(i,t),o=Object.keys(a),s=[];for(let e of o)s.push(a[e].x),s.push(a[e].y);let c=I(e=>{let t={};for(let n=0;n<o.length;++n){let r=o[n];t[r]={x:e[2*n],y:e[2*n+1],radius:a[r].radius}}return r(t,i)},s,t).x;for(let e=0;e<o.length;++e){let t=o[e];a[t].x=c[2*e],a[t].y=c[2*e+1]}return a}var ne=1e-10;function R(e,t,n){return Math.min(e,t)*Math.min(e,t)*Math.PI<=n+ne?Math.abs(e-t):k(r=>E(e,t,r)-n,0,e+t)}function re(e,t={}){let n=t.distinct,r=e.map(e=>Object.assign({},e));function i(e){return e.join(`;`)}if(n){let e=new Map;for(let t of r)for(let n=0;n<t.sets.length;n++){let r=String(t.sets[n]);e.set(r,t.size+(e.get(r)||0));for(let i=n+1;i<t.sets.length;i++){let n=String(t.sets[i]),a=`${r};${n}`,o=`${n};${r}`;e.set(a,t.size+(e.get(a)||0)),e.set(o,t.size+(e.get(o)||0))}}for(let t of r)t.sets.length<3&&(t.size=e.get(i(t.sets)))}let a=[],o=new Set;for(let e of r)if(e.sets.length===1)a.push(e.sets[0]);else if(e.sets.length===2){let t=e.sets[0],n=e.sets[1];o.add(i(e.sets)),o.add(i([n,t]))}a.sort((e,t)=>e===t?0:e<t?-1:1);for(let e=0;e<a.length;++e){let t=a[e];for(let n=e+1;n<a.length;++n){let e=a[n];o.has(i([t,e]))||r.push({sets:[t,e],size:0})}}return r}function ie(e,t,n){let r=j(t.length,t.length),i=j(t.length,t.length);return e.filter(e=>e.sets.length===2).forEach(e=>{let a=n[e.sets[0]],o=n[e.sets[1]],s=R(Math.sqrt(t[a].size/Math.PI),Math.sqrt(t[o].size/Math.PI),e.size);r[a][o]=r[o][a]=s;let c=0;e.size+1e-10>=Math.min(t[a].size,t[o].size)?c=1:e.size<=1e-10&&(c=-1),i[a][o]=i[o][a]=c}),{distances:r,constraints:i}}function ae(e,t,n,r){for(let e=0;e<t.length;++e)t[e]=0;let i=0;for(let a=0;a<n.length;++a){let o=e[2*a],s=e[2*a+1];for(let c=a+1;c<n.length;++c){let l=e[2*c],u=e[2*c+1],d=n[a][c],f=r[a][c],p=(l-o)*(l-o)+(u-s)*(u-s),m=Math.sqrt(p),h=p-d*d;f>0&&m<=d||f<0&&m>=d||(i+=2*h*h,t[2*a]+=4*h*(o-l),t[2*a+1]+=4*h*(s-u),t[2*c]+=4*h*(l-o),t[2*c+1]+=4*h*(u-s))}}return i}function oe(e,t={}){let n=ce(e,t),r=t.lossFunction||z;if(e.length>=8){let i=se(e,t),a=r(i,e),o=r(n,e);a+1e-8<o&&(n=i)}return n}function se(e,t={}){let n=t.restarts||10,r=[],i={};for(let t of e)t.sets.length===1&&(i[t.sets[0]]=r.length,r.push(t));let{distances:a,constraints:o}=ie(e,r,i),s=N(a.map(N))/a.length;a=a.map(e=>e.map(e=>e/s));let c=(e,t)=>ae(e,t,a,o),l=null;for(let e=0;e<n;++e){let e=ee(c,A(a.length*2).map(Math.random),t);(!l||e.fx<l.fx)&&(l=e)}let u=l.x,d={};for(let e=0;e<r.length;++e){let t=r[e];d[t.sets[0]]={x:u[2*e]*s,y:u[2*e+1]*s,radius:Math.sqrt(t.size/Math.PI)}}if(t.history)for(let e of t.history)P(e.x,s);return d}function ce(e,t){let n=t&&t.lossFunction?t.lossFunction:z,r={},i={};for(let t of e)if(t.sets.length===1){let e=t.sets[0];r[e]={x:1e10,y:1e10,rowid:r.length,size:t.size,radius:Math.sqrt(t.size/Math.PI)},i[e]=[]}e=e.filter(e=>e.sets.length===2);for(let t of e){let e=t.weight==null?1:t.weight,n=t.sets[0],a=t.sets[1];t.size+ne>=Math.min(r[n].size,r[a].size)&&(e=0),i[n].push({set:a,size:t.size,weight:e}),i[a].push({set:n,size:t.size,weight:e})}let a=[];Object.keys(i).forEach(e=>{let t=0;for(let n=0;n<i[e].length;++n)t+=i[e][n].size*i[e][n].weight;a.push({set:e,size:t})});function o(e,t){return t.size-e.size}a.sort(o);let s={};function c(e){return e.set in s}function l(e,t){r[t].x=e.x,r[t].y=e.y,s[t]=!0}l({x:0,y:0},a[0].set);for(let t=1;t<a.length;++t){let s=a[t].set,d=i[s].filter(c),f=r[s];if(d.sort(o),d.length===0)throw`ERROR: missing pairwise overlap information`;let p=[];for(var u=0;u<d.length;++u){let e=r[d[u].set],t=R(f.radius,e.radius,d[u].size);p.push({x:e.x+t,y:e.y}),p.push({x:e.x-t,y:e.y}),p.push({y:e.y+t,x:e.x}),p.push({y:e.y-t,x:e.x});for(let n=u+1;n<d.length;++n){let i=r[d[n].set],a=R(f.radius,i.radius,d[n].size),o=D({x:e.x,y:e.y,radius:t},{x:i.x,y:i.y,radius:a});p.push(...o)}}let m=1e50,h=p[0];for(let t of p){r[s].x=t.x,r[s].y=t.y;let i=n(r,e);i<m&&(m=i,h=t)}l(h,s)}return r}function z(e,t){let n=0;for(let r of t){if(r.sets.length===1)continue;let t;if(r.sets.length===2){let n=e[r.sets[0]],i=e[r.sets[1]];t=E(n.radius,i.radius,T(n,i))}else t=x(r.sets.map(t=>e[t]));let i=r.weight==null?1:r.weight;n+=i*(t-r.size)*(t-r.size)}return n}function le(e,t){let n=0;for(let r of t){if(r.sets.length===1)continue;let t;if(r.sets.length===2){let n=e[r.sets[0]],i=e[r.sets[1]];t=E(n.radius,i.radius,T(n,i))}else t=x(r.sets.map(t=>e[t]));let i=r.weight==null?1:r.weight,a=Math.log((t+1)/(r.size+1));n+=i*a*a}return n}function ue(e,t,n){if(n==null?e.sort((e,t)=>t.radius-e.radius):e.sort(n),e.length>0){let t=e[0].x,n=e[0].y;for(let r of e)r.x-=t,r.y-=n}if(e.length===2&&T(e[0],e[1])<Math.abs(e[1].radius-e[0].radius)&&(e[1].x=e[0].x+e[0].radius-e[1].radius-1e-10,e[1].y=e[0].y),e.length>1){let n=Math.atan2(e[1].x,e[1].y)-t,r=Math.cos(n),i=Math.sin(n);for(let t of e){let e=t.x,n=t.y;t.x=r*e-i*n,t.y=i*e+r*n}}if(e.length>2){let n=Math.atan2(e[2].x,e[2].y)-t;for(;n<0;)n+=2*Math.PI;for(;n>2*Math.PI;)n-=2*Math.PI;if(n>Math.PI){let t=e[1].y/(1e-10+e[1].x);for(let n of e){var r=(n.x+t*n.y)/(1+t*t);n.x=2*r-n.x,n.y=2*r*t-n.y}}}}function de(e){e.forEach(e=>{e.parent=e});function t(e){return e.parent!==e&&(e.parent=t(e.parent)),e.parent}function n(e,n){let r=t(e);r.parent=t(n)}for(let t=0;t<e.length;++t)for(let r=t+1;r<e.length;++r){let i=e[t].radius+e[r].radius;T(e[t],e[r])+1e-10<i&&n(e[r],e[t])}let r=new Map;for(let n=0;n<e.length;++n){let i=t(e[n]).parent.setid;r.has(i)||r.set(i,[]),r.get(i).push(e[n])}return e.forEach(e=>{delete e.parent}),Array.from(r.values())}function B(e){let t=t=>({max:e.reduce((e,n)=>Math.max(e,n[t]+n.radius),-1/0),min:e.reduce((e,n)=>Math.min(e,n[t]-n.radius),1/0)});return{xRange:t(`x`),yRange:t(`y`)}}function fe(e,t,n){t??=Math.PI/2;let r=he(e).map(e=>Object.assign({},e)),i=de(r);for(let e of i){ue(e,t,n);let r=B(e);e.size=(r.xRange.max-r.xRange.min)*(r.yRange.max-r.yRange.min),e.bounds=r}i.sort((e,t)=>t.size-e.size),r=i[0];let a=r.bounds,o=(a.xRange.max-a.xRange.min)/50;function s(e,t,n){if(!e)return;let i=e.bounds,s,c;if(t)s=a.xRange.max-i.xRange.min+o;else{s=a.xRange.max-i.xRange.max;let e=(i.xRange.max-i.xRange.min)/2-(a.xRange.max-a.xRange.min)/2;e<0&&(s+=e)}if(n)c=a.yRange.max-i.yRange.min+o;else{c=a.yRange.max-i.yRange.max;let e=(i.yRange.max-i.yRange.min)/2-(a.yRange.max-a.yRange.min)/2;e<0&&(c+=e)}for(let t of e)t.x+=s,t.y+=c,r.push(t)}let c=1;for(;c<i.length;)s(i[c],!0,!1),s(i[c+1],!1,!0),s(i[c+2],!0,!0),c+=3,a=B(r);return me(r)}function pe(e,t,n,r,i){let a=he(e);t-=2*r,n-=2*r;let{xRange:o,yRange:s}=B(a);if(o.max===o.min||s.max===s.min)return console.log(`not scaling solution: zero size detected`),e;let c,l;if(i){let e=Math.sqrt(i/Math.PI)*2;c=t/e,l=n/e}else c=t/(o.max-o.min),l=n/(s.max-s.min);let u=Math.min(l,c),d=(t-(o.max-o.min)*u)/2,f=(n-(s.max-s.min)*u)/2;return me(a.map(e=>({radius:u*e.radius,x:r+d+(e.x-o.min)*u,y:r+f+(e.y-s.min)*u,setid:e.setid})))}function me(e){let t={};for(let n of e)t[n.setid]=n;return t}function he(e){return Object.keys(e).map(t=>Object.assign(e[t],{setid:t}))}function ge(e={}){let t=!1,n=600,r=350,i=15,a=1e3,o=Math.PI/2,s=!0,c=null,l=!0,u=!0,d=null,f=null,p=!1,m=null,h=e&&e.symmetricalTextCentre?e.symmetricalTextCentre:!1,g={},_=e&&e.colourScheme?e.colourScheme:e&&e.colorScheme?e.colorScheme:[`#1f77b4`,`#ff7f0e`,`#2ca02c`,`#d62728`,`#9467bd`,`#8c564b`,`#e377c2`,`#7f7f7f`,`#bcbd22`,`#17becf`],v=0,y=function(e){if(e in g)return g[e];var t=g[e]=_[v];return v+=1,v>=_.length&&(v=0),t},b=te,x=z;function S(g){let _=g.datum(),v=new Set;_.forEach(e=>{e.size==0&&e.sets.length==1&&v.add(e.sets[0])}),_=_.filter(e=>!e.sets.some(e=>v.has(e)));let S={},C={};if(_.length>0){let e=b(_,{lossFunction:x,distinct:p});s&&(e=fe(e,o,f)),S=pe(e,n,r,i,c),C=ye(S,_,h)}let w={};_.forEach(e=>{e.label&&(w[e.sets]=e.label)});function T(e){if(e.sets in w)return w[e.sets];if(e.sets.length==1)return``+e.sets[0]}g.selectAll(`svg`).data([S]).enter().append(`svg`);let E=g.select(`svg`);t?E.attr(`viewBox`,`0 0 ${n} ${r}`):E.attr(`width`,n).attr(`height`,r);let D={},O=!1;E.selectAll(`.venn-area path`).each(function(e){let t=this.getAttribute(`d`);e.sets.length==1&&t&&!p&&(O=!0,D[e.sets[0]]=xe(t))});function k(e){return t=>we(e.sets.map(e=>{let i=D[e],a=S[e];return i||={x:n/2,y:r/2,radius:1},a||={x:n/2,y:r/2,radius:1},{x:i.x*(1-t)+a.x*t,y:i.y*(1-t)+a.y*t,radius:i.radius*(1-t)+a.radius*t}}),m)}let A=E.selectAll(`.venn-area`).data(_,e=>e.sets),j=A.enter().append(`g`).attr(`class`,e=>`venn-area venn-${e.sets.length==1?`circle`:`intersection`}${e.colour||e.color?` venn-coloured`:``}`).attr(`data-venn-sets`,e=>e.sets.join(`_`)),M=j.append(`path`),N=j.append(`text`).attr(`class`,`label`).text(e=>T(e)).attr(`text-anchor`,`middle`).attr(`dy`,`.35em`).attr(`x`,n/2).attr(`y`,r/2);u&&(M.style(`fill-opacity`,`0`).filter(e=>e.sets.length==1).style(`fill`,e=>e.colour?e.colour:e.color?e.color:y(e.sets)).style(`fill-opacity`,`.25`),N.style(`fill`,t=>t.colour||t.color?`#FFF`:e.textFill?e.textFill:t.sets.length==1?y(t.sets):`#444`));function P(e){return typeof e.transition==`function`?e.transition(`venn`).duration(a):e}let F=g;O&&typeof F.transition==`function`?(F=P(g),F.selectAll(`path`).attrTween(`d`,k)):F.selectAll(`path`).attr(`d`,e=>we(e.sets.map(e=>S[e])),m);let I=F.selectAll(`text`).filter(e=>e.sets in C).text(e=>T(e)).attr(`x`,e=>Math.floor(C[e.sets].x)).attr(`y`,e=>Math.floor(C[e.sets].y));l&&(O?`on`in I?I.on(`end`,V(S,T)):I.each(`end`,V(S,T)):I.each(V(S,T)));let L=P(A.exit()).remove();typeof A.transition==`function`&&L.selectAll(`path`).attrTween(`d`,k);let ee=L.selectAll(`text`).attr(`x`,n/2).attr(`y`,r/2);return d!==null&&(N.style(`font-size`,`0px`),I.style(`font-size`,d),ee.style(`font-size`,`0px`)),{circles:S,textCentres:C,nodes:A,enter:j,update:F,exit:L}}return S.wrap=function(e){return arguments.length?(l=e,S):l},S.useViewBox=function(){return t=!0,S},S.width=function(e){return arguments.length?(n=e,S):n},S.height=function(e){return arguments.length?(r=e,S):r},S.padding=function(e){return arguments.length?(i=e,S):i},S.distinct=function(e){return arguments.length?(p=e,S):p},S.colours=function(e){return arguments.length?(y=e,S):y},S.colors=function(e){return arguments.length?(y=e,S):y},S.fontSize=function(e){return arguments.length?(d=e,S):d},S.round=function(e){return arguments.length?(m=e,S):m},S.duration=function(e){return arguments.length?(a=e,S):a},S.layoutFunction=function(e){return arguments.length?(b=e,S):b},S.normalize=function(e){return arguments.length?(s=e,S):s},S.scaleToFit=function(e){return arguments.length?(c=e,S):c},S.styled=function(e){return arguments.length?(u=e,S):u},S.orientation=function(e){return arguments.length?(o=e,S):o},S.orientationOrder=function(e){return arguments.length?(f=e,S):f},S.lossFunction=function(e){return arguments.length?(x=e===`default`?z:e===`logRatio`?le:e,S):x},S}function V(e,t){return function(n){let r=this,i=e[n.sets[0]].radius||50,a=t(n)||``,o=a.split(/\s+/).reverse(),s=(a.length+o.length)/3,c=o.pop(),l=[c],u=0,d=1.1;r.textContent=null;let f=[];function p(e){let t=r.ownerDocument.createElementNS(r.namespaceURI,`tspan`);return t.textContent=e,f.push(t),r.append(t),t}let m=p(c);for(;c=o.pop(),c;){l.push(c);let e=l.join(` `);m.textContent=e,e.length>s&&m.getComputedTextLength()>i&&(l.pop(),m.textContent=l.join(` `),l=[c],m=p(c),u++)}let h=.35-u*d/2,g=r.getAttribute(`x`),_=r.getAttribute(`y`);f.forEach((e,t)=>{e.setAttribute(`x`,g),e.setAttribute(`y`,_),e.setAttribute(`dy`,`${h+t*d}em`)})}}function H(e,t,n){let r=t[0].radius-T(t[0],e);for(let n=1;n<t.length;++n){let i=t[n].radius-T(t[n],e);i<=r&&(r=i)}for(let t=0;t<n.length;++t){let i=T(n[t],e)-n[t].radius;i<=r&&(r=i)}return r}function _e(e,t,n){let r=[];for(let t of e)r.push({x:t.x,y:t.y}),r.push({x:t.x+t.radius/2,y:t.y}),r.push({x:t.x-t.radius/2,y:t.y}),r.push({x:t.x,y:t.y+t.radius/2}),r.push({x:t.x,y:t.y-t.radius/2});let i=r[0],a=H(r[0],e,t);for(let n=1;n<r.length;++n){let o=H(r[n],e,t);o>=a&&(i=r[n],a=o)}let o=I(n=>-1*H({x:n[0],y:n[1]},e,t),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,s={x:n?0:o[0],y:o[1]},c=!0;for(let t of e)if(T(s,t)>t.radius){c=!1;break}for(let e of t)if(T(s,e)<e.radius){c=!1;break}if(c)return s;if(e.length==1)return{x:e[0].x,y:e[0].y};let l={};return x(e,l),l.arcs.length===0?{x:0,y:-1e3,disjoint:!0}:l.arcs.length==1?{x:l.arcs[0].circle.x,y:l.arcs[0].circle.y}:t.length?_e(e,[]):O(l.arcs.map(e=>e.p1))}function ve(e){let t={},n=Object.keys(e);for(let e of n)t[e]=[];for(let r=0;r<n.length;r++){let i=n[r],a=e[i];for(let o=r+1;o<n.length;++o){let r=n[o],s=e[r],c=T(a,s);c+s.radius<=a.radius+1e-10?t[r].push(i):c+a.radius<=s.radius+1e-10&&t[i].push(r)}}return t}function ye(e,t,n){let r={},i=ve(e);for(let a=0;a<t.length;++a){let o=t[a].sets,s={},c={};for(let e=0;e<o.length;++e){s[o[e]]=!0;let t=i[o[e]];for(let e=0;e<t.length;++e)c[t[e]]=!0}let l=[],u=[];for(let t in e)t in s?l.push(e[t]):t in c||u.push(e[t]);let d=_e(l,u,n);r[o]=d,d.disjoint&&t[a].size>0&&console.log(`WARNING: area `+o+` not represented on screen`)}return r}function be(e,t,n){let r=[];return r.push(`
2
2
  M`,e,t),r.push(`
3
3
  m`,-n,0),r.push(`
4
4
  a`,n,n,0,1,0,n*2,0),r.push(`
@@ -0,0 +1 @@
1
+ import"./chunk-K5T4RW27-CHoEPFOL.js";import{n as e}from"./chunk-CIAEETIT-ecxKAxUb.js";export{e as createWardleyServices};
@@ -1,4 +1,4 @@
1
- import{n as e,r as t}from"./src-DOAilbaA.js";import{B as n,C as r,L as i,V as a,W as o,_ as s,a as c,b as l,c as u,v as d}from"./chunk-ICPOFSXX-BC5Xd13f.js";import{t as f}from"./chunk-426QAEUC-jRhC4EYv.js";import{t as p}from"./chunk-4BX2VUAB-BTctgoF3.js";import{t as m}from"./mermaid-parser.core-CFsvu03i.js";var h=e((e,t)=>{let n=e<=1?e*100:e;if(n<0||n>100)throw Error(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`);return n},`toPercent`),g=e((e,t,n)=>({x:h(t,`${n} evolution`),y:h(e,`${n} visibility`)}),`toCoordinates`),_=e(e=>{if(e){if(e===`+<>`)return`bidirectional`;if(e===`+<`)return`backward`;if(e===`+>`)return`forward`}},`getFlowFromPort`),v=e(e=>{if(!e?.startsWith(`+`))return{};let t=/^\+'([^']*)'/.exec(e)?.[1];return e.includes(`<>`)?{flow:`bidirectional`,label:t}:e.includes(`<`)?{flow:`backward`,label:t}:e.includes(`>`)?{flow:`forward`,label:t}:{label:t}},`extractFlowFromArrow`),y=e((e,t)=>{if(p(e,t),e.size&&t.setSize(e.size.width,e.size.height),e.evolution){let n=e.evolution.stages.map(e=>e.secondName?`${e.name.trim()} / ${e.secondName.trim()}`:e.name.trim()),r=e.evolution.stages.filter(e=>e.boundary!==void 0).map(e=>e.boundary);t.updateAxes({stages:n,stageBoundaries:r})}if(e.anchors.forEach(e=>{let n=g(e.visibility,e.evolution,`Anchor "${e.name}"`);t.addNode(e.name,e.name,n.x,n.y,`anchor`)}),e.components.forEach(e=>{let n=g(e.visibility,e.evolution,`Component "${e.name}"`),r=e.label?(e.label.negX?-1:1)*e.label.offsetX:void 0,i=e.label?(e.label.negY?-1:1)*e.label.offsetY:void 0,a=e.decorator?.strategy;t.addNode(e.name,e.name,n.x,n.y,`component`,r,i,e.inertia,a)}),e.notes.forEach(e=>{let n=g(e.visibility,e.evolution,`Note "${e.text}"`);t.addNote(e.text,n.x,n.y)}),e.pipelines.forEach(e=>{let n=t.getNode(e.parent);if(!n||typeof n.y!=`number`)throw Error(`Pipeline "${e.parent}" must reference an existing component with coordinates.`);let r=n.y;t.startPipeline(e.parent),e.components.forEach(n=>{let i=`${e.parent}_${n.name}`,a=n.label?(n.label.negX?-1:1)*n.label.offsetX:void 0,o=n.label?(n.label.negY?-1:1)*n.label.offsetY:void 0,s=h(n.evolution,`Pipeline component "${n.name}" evolution`);t.addNode(i,n.name,s,r,`pipeline-component`,a,o),t.addPipelineComponent(e.parent,i)})}),e.links.forEach(e=>{let n=!!e.arrow&&(e.arrow.includes(`-.->`)||e.arrow.includes(`.-.`)),r=_(e.fromPort)??_(e.toPort),{flow:i,label:a}=v(e.arrow);!r&&i&&(r=i);let o=e.linkLabel,s=a??o;t.addLink(e.from,e.to,n,s,r)}),e.evolves.forEach(e=>{let n=t.getNode(e.component);if(n?.y!==void 0){let r=h(e.target,`Evolve target for "${e.component}"`);t.addTrend(e.component,r,n.y)}}),e.annotations.length>0){let n=e.annotations[0],r=g(n.x,n.y,`Annotations box`);t.setAnnotationsBox(r.x,r.y)}e.annotation.forEach(e=>{let n=g(e.x,e.y,`Annotation ${e.number}`);t.addAnnotation(e.number,[{x:n.x,y:n.y}],e.text)}),e.accelerators.forEach(e=>{let n=g(e.x,e.y,`Accelerator "${e.name}"`);t.addAccelerator(e.name,n.x,n.y)}),e.deaccelerators.forEach(e=>{let n=g(e.x,e.y,`Deaccelerator "${e.name}"`);t.addDeaccelerator(e.name,n.x,n.y)})},`populateDb`),b={parser:{yy:void 0},parse:e(async e=>{let n=await m(`wardley`,e);t.debug(n);let r=b.parser?.yy;if(!r||typeof r.addNode!=`function`)throw Error(`parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.`);y(n,r)},`parse`)},x=new class{constructor(){this.nodes=new Map,this.links=[],this.trends=new Map,this.pipelines=new Map,this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.axes={}}static{e(this,`WardleyBuilder`)}addNode(e){let t=this.nodes.get(e.id)??{id:e.id,label:e.label},n={...t,...e,className:e.className??t.className,labelOffsetX:e.labelOffsetX??t.labelOffsetX,labelOffsetY:e.labelOffsetY??t.labelOffsetY};this.nodes.set(e.id,n)}addLink(e){this.links.push(e)}addTrend(e){this.trends.set(e.nodeId,e)}startPipeline(e){this.pipelines.set(e,{nodeId:e,componentIds:[]});let t=this.nodes.get(e);t&&(t.isPipelineParent=!0)}addPipelineComponent(e,t){let n=this.pipelines.get(e);n&&n.componentIds.push(t);let r=this.nodes.get(t);r&&(r.inPipeline=!0)}addAnnotation(e){this.annotations.push(e)}addNote(e){this.notes.push(e)}addAccelerator(e){this.accelerators.push(e)}addDeaccelerator(e){this.deaccelerators.push(e)}setAnnotationsBox(e,t){this.annotationsBox={x:e,y:t}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,t){this.size={width:e,height:t}}getNode(e){return this.nodes.get(e)}build(){let e=[];for(let t of this.nodes.values()){if(typeof t.x!=`number`||typeof t.y!=`number`)throw Error(`Node "${t.label}" is missing coordinates`);e.push(t)}return{nodes:e,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}clear(){this.nodes.clear(),this.links=[],this.trends.clear(),this.pipelines.clear(),this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.annotationsBox=void 0,this.axes={},this.size=void 0}};function S(e){let t=l();return i(e.trim(),t)}e(S,`textSanitizer`);function C(){return l()[`wardley-beta`]}e(C,`getConfig`);function w(e,t,n,r,i,a,o,s,c){x.addNode({id:e,label:S(t),x:n,y:r,className:i,labelOffsetX:a,labelOffsetY:o,inertia:s,sourceStrategy:c})}e(w,`addNode`);function T(e,t,n=!1,r,i){x.addLink({source:e,target:t,dashed:n,label:r,flow:i})}e(T,`addLink`);function E(e,t,n){x.addTrend({nodeId:e,targetX:t,targetY:n})}e(E,`addTrend`);function D(e,t,n){x.addAnnotation({number:e,coordinates:t,text:n?S(n):void 0})}e(D,`addAnnotation`);function O(e,t,n){x.addNote({text:S(e),x:t,y:n})}e(O,`addNote`);function k(e,t,n){x.addAccelerator({name:S(e),x:t,y:n})}e(k,`addAccelerator`);function A(e,t,n){x.addDeaccelerator({name:S(e),x:t,y:n})}e(A,`addDeaccelerator`);function j(e,t){x.setAnnotationsBox(e,t)}e(j,`setAnnotationsBox`);function M(e,t){x.setSize(e,t)}e(M,`setSize`);function N(e){x.startPipeline(e)}e(N,`startPipeline`);function P(e,t){x.addPipelineComponent(e,t)}e(P,`addPipelineComponent`);function F(e){let t={};e.xLabel&&(t.xLabel=S(e.xLabel)),e.yLabel&&(t.yLabel=S(e.yLabel)),e.stages&&(t.stages=e.stages.map(e=>S(e))),e.stageBoundaries&&(t.stageBoundaries=e.stageBoundaries),x.setAxes(t)}e(F,`updateAxes`);function I(e){return x.getNode(e)}e(I,`getNode`);function L(){return x.build()}e(L,`getWardleyData`);function R(){x.clear(),c()}e(R,`clear`);var z={getConfig:C,addNode:w,addLink:T,addTrend:E,addAnnotation:D,addNote:O,addAccelerator:k,addDeaccelerator:A,setAnnotationsBox:j,setSize:M,startPipeline:N,addPipelineComponent:P,updateAxes:F,getNode:I,getWardleyData:L,clear:R,setAccTitle:a,getAccTitle:d,setDiagramTitle:o,getDiagramTitle:r,getAccDescription:s,setAccDescription:n},B=[`Genesis`,`Custom Built`,`Product`,`Commodity`],V=e(()=>{let{themeVariables:e}=l();return{backgroundColor:e.wardley?.backgroundColor??e.background??`#fff`,axisColor:e.wardley?.axisColor??`#000`,axisTextColor:e.wardley?.axisTextColor??e.primaryTextColor??`#222`,gridColor:e.wardley?.gridColor??`rgba(100, 100, 100, 0.2)`,componentFill:e.wardley?.componentFill??`#fff`,componentStroke:e.wardley?.componentStroke??`#000`,componentLabelColor:e.wardley?.componentLabelColor??e.primaryTextColor??`#222`,linkStroke:e.wardley?.linkStroke??`#000`,evolutionStroke:e.wardley?.evolutionStroke??`#dc3545`,annotationStroke:e.wardley?.annotationStroke??`#000`,annotationTextColor:e.wardley?.annotationTextColor??e.primaryTextColor??`#222`,annotationFill:e.wardley?.annotationFill??e.background??`#fff`}},`getTheme`),H=e(()=>{let e=l()[`wardley-beta`];return{width:e?.width??900,height:e?.height??600,padding:e?.padding??48,nodeRadius:e?.nodeRadius??6,nodeLabelOffset:e?.nodeLabelOffset??8,axisFontSize:e?.axisFontSize??12,labelFontSize:e?.labelFontSize??10,showGrid:e?.showGrid??!1,useMaxWidth:e?.useMaxWidth??!0}},`getConfigValues`),U={parser:b,db:z,renderer:{draw:e((n,r,i,a)=>{t.debug(`Rendering Wardley map
1
+ import{n as e,r as t}from"./src-BXk72DrU.js";import{B as n,C as r,L as i,V as a,W as o,_ as s,a as c,b as l,c as u,v as d}from"./chunk-ICPOFSXX-rmT7ehAO.js";import{t as f}from"./chunk-426QAEUC-b3iWz8H-.js";import{t as p}from"./chunk-4BX2VUAB-CDjfF5mJ.js";import{t as m}from"./mermaid-parser.core-BrufKICx.js";var h=e((e,t)=>{let n=e<=1?e*100:e;if(n<0||n>100)throw Error(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`);return n},`toPercent`),g=e((e,t,n)=>({x:h(t,`${n} evolution`),y:h(e,`${n} visibility`)}),`toCoordinates`),_=e(e=>{if(e){if(e===`+<>`)return`bidirectional`;if(e===`+<`)return`backward`;if(e===`+>`)return`forward`}},`getFlowFromPort`),v=e(e=>{if(!e?.startsWith(`+`))return{};let t=/^\+'([^']*)'/.exec(e)?.[1];return e.includes(`<>`)?{flow:`bidirectional`,label:t}:e.includes(`<`)?{flow:`backward`,label:t}:e.includes(`>`)?{flow:`forward`,label:t}:{label:t}},`extractFlowFromArrow`),y=e((e,t)=>{if(p(e,t),e.size&&t.setSize(e.size.width,e.size.height),e.evolution){let n=e.evolution.stages.map(e=>e.secondName?`${e.name.trim()} / ${e.secondName.trim()}`:e.name.trim()),r=e.evolution.stages.filter(e=>e.boundary!==void 0).map(e=>e.boundary);t.updateAxes({stages:n,stageBoundaries:r})}if(e.anchors.forEach(e=>{let n=g(e.visibility,e.evolution,`Anchor "${e.name}"`);t.addNode(e.name,e.name,n.x,n.y,`anchor`)}),e.components.forEach(e=>{let n=g(e.visibility,e.evolution,`Component "${e.name}"`),r=e.label?(e.label.negX?-1:1)*e.label.offsetX:void 0,i=e.label?(e.label.negY?-1:1)*e.label.offsetY:void 0,a=e.decorator?.strategy;t.addNode(e.name,e.name,n.x,n.y,`component`,r,i,e.inertia,a)}),e.notes.forEach(e=>{let n=g(e.visibility,e.evolution,`Note "${e.text}"`);t.addNote(e.text,n.x,n.y)}),e.pipelines.forEach(e=>{let n=t.getNode(e.parent);if(!n||typeof n.y!=`number`)throw Error(`Pipeline "${e.parent}" must reference an existing component with coordinates.`);let r=n.y;t.startPipeline(e.parent),e.components.forEach(n=>{let i=`${e.parent}_${n.name}`,a=n.label?(n.label.negX?-1:1)*n.label.offsetX:void 0,o=n.label?(n.label.negY?-1:1)*n.label.offsetY:void 0,s=h(n.evolution,`Pipeline component "${n.name}" evolution`);t.addNode(i,n.name,s,r,`pipeline-component`,a,o),t.addPipelineComponent(e.parent,i)})}),e.links.forEach(e=>{let n=!!e.arrow&&(e.arrow.includes(`-.->`)||e.arrow.includes(`.-.`)),r=_(e.fromPort)??_(e.toPort),{flow:i,label:a}=v(e.arrow);!r&&i&&(r=i);let o=e.linkLabel,s=a??o;t.addLink(e.from,e.to,n,s,r)}),e.evolves.forEach(e=>{let n=t.getNode(e.component);if(n?.y!==void 0){let r=h(e.target,`Evolve target for "${e.component}"`);t.addTrend(e.component,r,n.y)}}),e.annotations.length>0){let n=e.annotations[0],r=g(n.x,n.y,`Annotations box`);t.setAnnotationsBox(r.x,r.y)}e.annotation.forEach(e=>{let n=g(e.x,e.y,`Annotation ${e.number}`);t.addAnnotation(e.number,[{x:n.x,y:n.y}],e.text)}),e.accelerators.forEach(e=>{let n=g(e.x,e.y,`Accelerator "${e.name}"`);t.addAccelerator(e.name,n.x,n.y)}),e.deaccelerators.forEach(e=>{let n=g(e.x,e.y,`Deaccelerator "${e.name}"`);t.addDeaccelerator(e.name,n.x,n.y)})},`populateDb`),b={parser:{yy:void 0},parse:e(async e=>{let n=await m(`wardley`,e);t.debug(n);let r=b.parser?.yy;if(!r||typeof r.addNode!=`function`)throw Error(`parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.`);y(n,r)},`parse`)},x=new class{constructor(){this.nodes=new Map,this.links=[],this.trends=new Map,this.pipelines=new Map,this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.axes={}}static{e(this,`WardleyBuilder`)}addNode(e){let t=this.nodes.get(e.id)??{id:e.id,label:e.label},n={...t,...e,className:e.className??t.className,labelOffsetX:e.labelOffsetX??t.labelOffsetX,labelOffsetY:e.labelOffsetY??t.labelOffsetY};this.nodes.set(e.id,n)}addLink(e){this.links.push(e)}addTrend(e){this.trends.set(e.nodeId,e)}startPipeline(e){this.pipelines.set(e,{nodeId:e,componentIds:[]});let t=this.nodes.get(e);t&&(t.isPipelineParent=!0)}addPipelineComponent(e,t){let n=this.pipelines.get(e);n&&n.componentIds.push(t);let r=this.nodes.get(t);r&&(r.inPipeline=!0)}addAnnotation(e){this.annotations.push(e)}addNote(e){this.notes.push(e)}addAccelerator(e){this.accelerators.push(e)}addDeaccelerator(e){this.deaccelerators.push(e)}setAnnotationsBox(e,t){this.annotationsBox={x:e,y:t}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,t){this.size={width:e,height:t}}getNode(e){return this.nodes.get(e)}build(){let e=[];for(let t of this.nodes.values()){if(typeof t.x!=`number`||typeof t.y!=`number`)throw Error(`Node "${t.label}" is missing coordinates`);e.push(t)}return{nodes:e,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}clear(){this.nodes.clear(),this.links=[],this.trends.clear(),this.pipelines.clear(),this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.annotationsBox=void 0,this.axes={},this.size=void 0}};function S(e){let t=l();return i(e.trim(),t)}e(S,`textSanitizer`);function C(){return l()[`wardley-beta`]}e(C,`getConfig`);function w(e,t,n,r,i,a,o,s,c){x.addNode({id:e,label:S(t),x:n,y:r,className:i,labelOffsetX:a,labelOffsetY:o,inertia:s,sourceStrategy:c})}e(w,`addNode`);function T(e,t,n=!1,r,i){x.addLink({source:e,target:t,dashed:n,label:r,flow:i})}e(T,`addLink`);function E(e,t,n){x.addTrend({nodeId:e,targetX:t,targetY:n})}e(E,`addTrend`);function D(e,t,n){x.addAnnotation({number:e,coordinates:t,text:n?S(n):void 0})}e(D,`addAnnotation`);function O(e,t,n){x.addNote({text:S(e),x:t,y:n})}e(O,`addNote`);function k(e,t,n){x.addAccelerator({name:S(e),x:t,y:n})}e(k,`addAccelerator`);function A(e,t,n){x.addDeaccelerator({name:S(e),x:t,y:n})}e(A,`addDeaccelerator`);function j(e,t){x.setAnnotationsBox(e,t)}e(j,`setAnnotationsBox`);function M(e,t){x.setSize(e,t)}e(M,`setSize`);function N(e){x.startPipeline(e)}e(N,`startPipeline`);function P(e,t){x.addPipelineComponent(e,t)}e(P,`addPipelineComponent`);function F(e){let t={};e.xLabel&&(t.xLabel=S(e.xLabel)),e.yLabel&&(t.yLabel=S(e.yLabel)),e.stages&&(t.stages=e.stages.map(e=>S(e))),e.stageBoundaries&&(t.stageBoundaries=e.stageBoundaries),x.setAxes(t)}e(F,`updateAxes`);function I(e){return x.getNode(e)}e(I,`getNode`);function L(){return x.build()}e(L,`getWardleyData`);function R(){x.clear(),c()}e(R,`clear`);var z={getConfig:C,addNode:w,addLink:T,addTrend:E,addAnnotation:D,addNote:O,addAccelerator:k,addDeaccelerator:A,setAnnotationsBox:j,setSize:M,startPipeline:N,addPipelineComponent:P,updateAxes:F,getNode:I,getWardleyData:L,clear:R,setAccTitle:a,getAccTitle:d,setDiagramTitle:o,getDiagramTitle:r,getAccDescription:s,setAccDescription:n},B=[`Genesis`,`Custom Built`,`Product`,`Commodity`],V=e(()=>{let{themeVariables:e}=l();return{backgroundColor:e.wardley?.backgroundColor??e.background??`#fff`,axisColor:e.wardley?.axisColor??`#000`,axisTextColor:e.wardley?.axisTextColor??e.primaryTextColor??`#222`,gridColor:e.wardley?.gridColor??`rgba(100, 100, 100, 0.2)`,componentFill:e.wardley?.componentFill??`#fff`,componentStroke:e.wardley?.componentStroke??`#000`,componentLabelColor:e.wardley?.componentLabelColor??e.primaryTextColor??`#222`,linkStroke:e.wardley?.linkStroke??`#000`,evolutionStroke:e.wardley?.evolutionStroke??`#dc3545`,annotationStroke:e.wardley?.annotationStroke??`#000`,annotationTextColor:e.wardley?.annotationTextColor??e.primaryTextColor??`#222`,annotationFill:e.wardley?.annotationFill??e.background??`#fff`}},`getTheme`),H=e(()=>{let e=l()[`wardley-beta`];return{width:e?.width??900,height:e?.height??600,padding:e?.padding??48,nodeRadius:e?.nodeRadius??6,nodeLabelOffset:e?.nodeLabelOffset??8,axisFontSize:e?.axisFontSize??12,labelFontSize:e?.labelFontSize??10,showGrid:e?.showGrid??!1,useMaxWidth:e?.useMaxWidth??!0}},`getConfigValues`),U={parser:b,db:z,renderer:{draw:e((n,r,i,a)=>{t.debug(`Rendering Wardley map
2
2
  `+n);let o=H(),s=V(),c=o.nodeRadius*1.6,l=a.db,d=l.getWardleyData(),p=l.getDiagramTitle(),m=d.size?.width??o.width,h=d.size?.height??o.height,g=f(r);g.selectAll(`*`).remove(),u(g,h,m,o.useMaxWidth),g.attr(`viewBox`,`0 0 ${m} ${h}`);let _=g.append(`g`).attr(`class`,`wardley-map`),v=g.append(`defs`);v.append(`marker`).attr(`id`,`arrow-${r}`).attr(`viewBox`,`0 0 10 10`).attr(`refX`,9).attr(`refY`,5).attr(`markerWidth`,6).attr(`markerHeight`,6).attr(`orient`,`auto-start-reverse`).append(`path`).attr(`d`,`M 0 0 L 10 5 L 0 10 z`).attr(`fill`,s.evolutionStroke).attr(`stroke`,`none`),v.append(`marker`).attr(`id`,`link-arrow-end-${r}`).attr(`viewBox`,`0 0 10 10`).attr(`refX`,9).attr(`refY`,5).attr(`markerWidth`,5).attr(`markerHeight`,5).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 0 0 L 10 5 L 0 10 z`).attr(`fill`,s.linkStroke).attr(`stroke`,`none`),v.append(`marker`).attr(`id`,`link-arrow-start-${r}`).attr(`viewBox`,`0 0 10 10`).attr(`refX`,1).attr(`refY`,5).attr(`markerWidth`,5).attr(`markerHeight`,5).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 10 0 L 0 5 L 10 10 z`).attr(`fill`,s.linkStroke).attr(`stroke`,`none`),_.append(`rect`).attr(`class`,`wardley-background`).attr(`width`,m).attr(`height`,h).attr(`fill`,s.backgroundColor);let y=m-o.padding*2,b=h-o.padding*2;p&&_.append(`text`).attr(`class`,`wardley-title`).attr(`x`,m/2).attr(`y`,o.padding/2).attr(`fill`,s.axisTextColor).attr(`font-size`,o.axisFontSize*1.05).attr(`font-weight`,`bold`).attr(`text-anchor`,`middle`).attr(`dominant-baseline`,`middle`).text(p);let x=e(e=>o.padding+e/100*y,`projectX`),S=e(e=>h-o.padding-e/100*b,`projectY`),C=_.append(`g`).attr(`class`,`wardley-axes`);C.append(`line`).attr(`x1`,o.padding).attr(`x2`,m-o.padding).attr(`y1`,h-o.padding).attr(`y2`,h-o.padding).attr(`stroke`,s.axisColor).attr(`stroke-width`,1),C.append(`line`).attr(`x1`,o.padding).attr(`x2`,o.padding).attr(`y1`,o.padding).attr(`y2`,h-o.padding).attr(`stroke`,s.axisColor).attr(`stroke-width`,1);let w=d.axes.xLabel??`Evolution`,T=d.axes.yLabel??`Visibility`;C.append(`text`).attr(`class`,`wardley-axis-label wardley-axis-label-x`).attr(`x`,o.padding+y/2).attr(`y`,h-o.padding/4).attr(`fill`,s.axisTextColor).attr(`font-size`,o.axisFontSize).attr(`font-weight`,`bold`).attr(`text-anchor`,`middle`).text(w),C.append(`text`).attr(`class`,`wardley-axis-label wardley-axis-label-y`).attr(`x`,o.padding/3).attr(`y`,o.padding+b/2).attr(`fill`,s.axisTextColor).attr(`font-size`,o.axisFontSize).attr(`font-weight`,`bold`).attr(`text-anchor`,`middle`).attr(`transform`,`rotate(-90 ${o.padding/3} ${o.padding+b/2})`).text(T);let E=d.axes.stages&&d.axes.stages.length>0?d.axes.stages:B;if(E.length>0){let e=_.append(`g`).attr(`class`,`wardley-stages`),t=d.axes.stageBoundaries,n=[];if(t&&t.length===E.length){let e=0;t.forEach(t=>{n.push({start:e,end:t}),e=t})}else{let e=1/E.length;E.forEach((t,r)=>{n.push({start:r*e,end:(r+1)*e})})}E.forEach((t,r)=>{let i=n[r],a=o.padding+i.start*y,c=(a+(o.padding+i.end*y))/2;r>0&&e.append(`line`).attr(`x1`,a).attr(`x2`,a).attr(`y1`,o.padding).attr(`y2`,h-o.padding).attr(`stroke`,`#000`).attr(`stroke-width`,1).attr(`stroke-dasharray`,`5 5`).attr(`opacity`,.8),e.append(`text`).attr(`class`,`wardley-stage-label`).attr(`x`,c).attr(`y`,h-o.padding/1.5).attr(`fill`,s.axisTextColor).attr(`font-size`,o.axisFontSize-2).attr(`text-anchor`,`middle`).text(t)})}if(o.showGrid){let e=_.append(`g`).attr(`class`,`wardley-grid`);for(let t=1;t<4;t++){let n=t/4,r=o.padding+y*n;e.append(`line`).attr(`x1`,r).attr(`x2`,r).attr(`y1`,o.padding).attr(`y2`,h-o.padding).attr(`stroke`,s.gridColor).attr(`stroke-dasharray`,`2 6`),e.append(`line`).attr(`x1`,o.padding).attr(`x2`,m-o.padding).attr(`y1`,h-o.padding-b*n).attr(`y2`,h-o.padding-b*n).attr(`stroke`,s.gridColor).attr(`stroke-dasharray`,`2 6`)}}let D=new Map;if(d.nodes.forEach(e=>{D.set(e.id,{x:x(e.x),y:S(e.y),node:e})}),d.pipelines.length>0){let e=_.append(`g`).attr(`class`,`wardley-pipelines`),t=_.append(`g`).attr(`class`,`wardley-pipeline-links`);d.pipelines.forEach(n=>{if(n.componentIds.length===0)return;let r=n.componentIds.map(e=>({id:e,pos:D.get(e),node:d.nodes.find(t=>t.id===e)})).filter(e=>e.pos&&e.node).sort((e,t)=>e.node.x-t.node.x);for(let e=0;e<r.length-1;e++){let n=r[e],i=r[e+1];t.append(`line`).attr(`class`,`wardley-pipeline-evolution-link`).attr(`x1`,n.pos.x).attr(`y1`,n.pos.y).attr(`x2`,i.pos.x).attr(`y2`,i.pos.y).attr(`stroke`,s.linkStroke).attr(`stroke-width`,1).attr(`stroke-dasharray`,`4 4`)}let i=1/0,a=-1/0,l=0;if(n.componentIds.forEach(e=>{let t=D.get(e);t&&(i=Math.min(i,t.x),a=Math.max(a,t.x),l=t.y)}),i!==1/0&&a!==-1/0){let t=o.nodeRadius*4,r=l-t/2,u=D.get(n.nodeId);u&&(u.x=(i+a)/2,u.y=r-c/6),e.append(`rect`).attr(`class`,`wardley-pipeline-box`).attr(`x`,i-15).attr(`y`,r).attr(`width`,a-i+30).attr(`height`,t).attr(`fill`,`none`).attr(`stroke`,s.axisColor).attr(`stroke-width`,1.5).attr(`rx`,4).attr(`ry`,4)}})}let O=_.append(`g`).attr(`class`,`wardley-links`),k=new Map;d.pipelines.forEach(e=>{k.set(e.nodeId,new Set(e.componentIds))});let A=d.links.filter(e=>!(!D.has(e.source)||!D.has(e.target)||k.get(e.target)?.has(e.source)));O.selectAll(`line`).data(A).enter().append(`line`).attr(`class`,e=>`wardley-link${e.dashed?` wardley-link--dashed`:``}`).attr(`x1`,e=>{let t=D.get(e.source),n=D.get(e.target),r=d.nodes.find(t=>t.id===e.source).isPipelineParent?c/Math.sqrt(2):o.nodeRadius,i=n.x-t.x,a=n.y-t.y,s=Math.sqrt(i*i+a*a);return t.x+i/s*r}).attr(`y1`,e=>{let t=D.get(e.source),n=D.get(e.target),r=d.nodes.find(t=>t.id===e.source).isPipelineParent?c/Math.sqrt(2):o.nodeRadius,i=n.x-t.x,a=n.y-t.y,s=Math.sqrt(i*i+a*a);return t.y+a/s*r}).attr(`x2`,e=>{let t=D.get(e.source),n=D.get(e.target),r=d.nodes.find(t=>t.id===e.target).isPipelineParent?c/Math.sqrt(2):o.nodeRadius,i=t.x-n.x,a=t.y-n.y,s=Math.sqrt(i*i+a*a);return n.x+i/s*r}).attr(`y2`,e=>{let t=D.get(e.source),n=D.get(e.target),r=d.nodes.find(t=>t.id===e.target).isPipelineParent?c/Math.sqrt(2):o.nodeRadius,i=t.x-n.x,a=t.y-n.y,s=Math.sqrt(i*i+a*a);return n.y+a/s*r}).attr(`stroke`,s.linkStroke).attr(`stroke-width`,1).attr(`stroke-dasharray`,e=>e.dashed?`6 6`:null).attr(`marker-end`,e=>e.flow===`forward`||e.flow===`bidirectional`?`url(#link-arrow-end-${r})`:null).attr(`marker-start`,e=>e.flow===`backward`||e.flow===`bidirectional`?`url(#link-arrow-start-${r})`:null),O.selectAll(`text`).data(A.filter(e=>e.label)).enter().append(`text`).attr(`class`,`wardley-link-label`).attr(`x`,e=>{let t=D.get(e.source),n=D.get(e.target),r=(t.x+n.x)/2,i=n.y-t.y,a=n.x-t.x;return r+i/Math.sqrt(a*a+i*i)*8}).attr(`y`,e=>{let t=D.get(e.source),n=D.get(e.target),r=(t.y+n.y)/2,i=n.x-t.x,a=n.y-t.y,o=Math.sqrt(i*i+a*a);return r+-i/o*8}).attr(`fill`,s.axisTextColor).attr(`font-size`,o.labelFontSize).attr(`text-anchor`,`middle`).attr(`dominant-baseline`,`middle`).attr(`transform`,e=>{let t=D.get(e.source),n=D.get(e.target),r=(t.x+n.x)/2,i=(t.y+n.y)/2,a=n.x-t.x,o=n.y-t.y,s=Math.sqrt(a*a+o*o),c=o/s,l=-a/s,u=r+c*8,d=i+l*8,f=Math.atan2(o,a)*180/Math.PI;return(f>90||f<-90)&&(f+=180),`rotate(${f} ${u} ${d})`}).text(e=>e.label);let j=_.append(`g`).attr(`class`,`wardley-trends`),M=d.trends.map(e=>{let t=D.get(e.nodeId);if(!t)return null;let n=x(e.targetX),r=S(e.targetY),i=n-t.x,a=r-t.y,s=Math.sqrt(i*i+a*a),c=o.nodeRadius+2;return{origin:t,targetX:n,targetY:r,adjustedX2:s>c?n-i/s*c:n,adjustedY2:s>c?r-a/s*c:r}}).filter(e=>e!==null);j.selectAll(`line`).data(M).enter().append(`line`).attr(`class`,`wardley-trend`).attr(`x1`,e=>e.origin.x).attr(`y1`,e=>e.origin.y).attr(`x2`,e=>e.adjustedX2).attr(`y2`,e=>e.adjustedY2).attr(`stroke`,s.evolutionStroke).attr(`stroke-width`,1).attr(`stroke-dasharray`,`4 4`).attr(`marker-end`,`url(#arrow-${r})`);let N=_.append(`g`).attr(`class`,`wardley-nodes`).selectAll(`g`).data(d.nodes).enter().append(`g`).attr(`class`,e=>[`wardley-node`,e.className?`wardley-node--${e.className}`:``].filter(Boolean).join(` `));N.filter(e=>e.sourceStrategy===`outsource`).append(`circle`).attr(`class`,`wardley-outsource-overlay`).attr(`cx`,e=>D.get(e.id).x).attr(`cy`,e=>D.get(e.id).y).attr(`r`,o.nodeRadius*2).attr(`fill`,`#666`).attr(`stroke`,s.componentStroke).attr(`stroke-width`,1),N.filter(e=>e.sourceStrategy===`buy`).append(`circle`).attr(`class`,`wardley-buy-overlay`).attr(`cx`,e=>D.get(e.id).x).attr(`cy`,e=>D.get(e.id).y).attr(`r`,o.nodeRadius*2).attr(`fill`,`#ccc`).attr(`stroke`,s.componentStroke).attr(`stroke-width`,1),N.filter(e=>e.sourceStrategy===`build`).append(`circle`).attr(`class`,`wardley-build-overlay`).attr(`cx`,e=>D.get(e.id).x).attr(`cy`,e=>D.get(e.id).y).attr(`r`,o.nodeRadius*2).attr(`fill`,`#eee`).attr(`stroke`,`#000`).attr(`stroke-width`,1);let P=N.filter(e=>e.sourceStrategy===`market`);P.append(`circle`).attr(`class`,`wardley-market-overlay`).attr(`cx`,e=>D.get(e.id).x).attr(`cy`,e=>D.get(e.id).y).attr(`r`,o.nodeRadius*2).attr(`fill`,`white`).attr(`stroke`,s.componentStroke).attr(`stroke-width`,1),N.filter(e=>!e.isPipelineParent&&e.sourceStrategy!==`market`&&e.className!==`anchor`).append(`circle`).attr(`cx`,e=>D.get(e.id).x).attr(`cy`,e=>D.get(e.id).y).attr(`r`,o.nodeRadius).attr(`fill`,s.componentFill).attr(`stroke`,s.componentStroke).attr(`stroke-width`,1);let F=o.nodeRadius*.7,I=o.nodeRadius*1.2;if(P.append(`line`).attr(`class`,`wardley-market-line`).attr(`x1`,e=>D.get(e.id).x).attr(`y1`,e=>D.get(e.id).y-I).attr(`x2`,e=>D.get(e.id).x-I*Math.cos(Math.PI/6)).attr(`y2`,e=>D.get(e.id).y+I*Math.sin(Math.PI/6)).attr(`stroke`,s.componentStroke).attr(`stroke-width`,1),P.append(`line`).attr(`class`,`wardley-market-line`).attr(`x1`,e=>D.get(e.id).x-I*Math.cos(Math.PI/6)).attr(`y1`,e=>D.get(e.id).y+I*Math.sin(Math.PI/6)).attr(`x2`,e=>D.get(e.id).x+I*Math.cos(Math.PI/6)).attr(`y2`,e=>D.get(e.id).y+I*Math.sin(Math.PI/6)).attr(`stroke`,s.componentStroke).attr(`stroke-width`,1),P.append(`line`).attr(`class`,`wardley-market-line`).attr(`x1`,e=>D.get(e.id).x+I*Math.cos(Math.PI/6)).attr(`y1`,e=>D.get(e.id).y+I*Math.sin(Math.PI/6)).attr(`x2`,e=>D.get(e.id).x).attr(`y2`,e=>D.get(e.id).y-I).attr(`stroke`,s.componentStroke).attr(`stroke-width`,1),P.append(`circle`).attr(`class`,`wardley-market-dot`).attr(`cx`,e=>D.get(e.id).x).attr(`cy`,e=>D.get(e.id).y-I).attr(`r`,F).attr(`fill`,`white`).attr(`stroke`,s.componentStroke).attr(`stroke-width`,2),P.append(`circle`).attr(`class`,`wardley-market-dot`).attr(`cx`,e=>D.get(e.id).x-I*Math.cos(Math.PI/6)).attr(`cy`,e=>D.get(e.id).y+I*Math.sin(Math.PI/6)).attr(`r`,F).attr(`fill`,`white`).attr(`stroke`,s.componentStroke).attr(`stroke-width`,2),P.append(`circle`).attr(`class`,`wardley-market-dot`).attr(`cx`,e=>D.get(e.id).x+I*Math.cos(Math.PI/6)).attr(`cy`,e=>D.get(e.id).y+I*Math.sin(Math.PI/6)).attr(`r`,F).attr(`fill`,`white`).attr(`stroke`,s.componentStroke).attr(`stroke-width`,2),N.filter(e=>e.isPipelineParent===!0).append(`rect`).attr(`x`,e=>D.get(e.id).x-c/2).attr(`y`,e=>D.get(e.id).y-c/2).attr(`width`,c).attr(`height`,c).attr(`fill`,s.componentFill).attr(`stroke`,s.componentStroke).attr(`stroke-width`,1),N.filter(e=>e.inertia===!0).append(`line`).attr(`class`,`wardley-inertia`).attr(`x1`,e=>{let t=D.get(e.id),n=e.isPipelineParent?c/2+15:o.nodeRadius+15;return e.sourceStrategy&&(n+=o.nodeRadius+10),t.x+n}).attr(`y1`,e=>{let t=D.get(e.id),n=e.isPipelineParent?c:o.nodeRadius*2;return t.y-n/2}).attr(`x2`,e=>{let t=D.get(e.id),n=e.isPipelineParent?c/2+15:o.nodeRadius+15;return e.sourceStrategy&&(n+=o.nodeRadius+10),t.x+n}).attr(`y2`,e=>{let t=D.get(e.id),n=e.isPipelineParent?c:o.nodeRadius*2;return t.y+n/2}).attr(`stroke`,s.componentStroke).attr(`stroke-width`,6),N.append(`text`).attr(`x`,e=>{let t=D.get(e.id);if(e.className===`anchor`)return e.labelOffsetX===void 0?t.x:t.x+e.labelOffsetX;let n=o.nodeLabelOffset;e.sourceStrategy&&e.labelOffsetX===void 0&&(n+=10);let r=e.labelOffsetX??n;return t.x+r}).attr(`y`,e=>{let t=D.get(e.id);if(e.className===`anchor`)return e.labelOffsetY===void 0?t.y-3:t.y+e.labelOffsetY;let n=-o.nodeLabelOffset;e.sourceStrategy&&e.labelOffsetY===void 0&&(n-=10);let r=e.labelOffsetY??n;return t.y+r}).attr(`class`,`wardley-node-label`).attr(`fill`,e=>e.className===`evolved`?s.evolutionStroke:e.className===`anchor`?`#000`:s.componentLabelColor).attr(`font-size`,o.labelFontSize).attr(`font-weight`,e=>e.className===`anchor`?`bold`:`normal`).attr(`text-anchor`,e=>e.className===`anchor`?`middle`:`start`).attr(`dominant-baseline`,e=>e.className===`anchor`?`middle`:`auto`).text(e=>e.label),d.annotations.length>0){let e=_.append(`g`).attr(`class`,`wardley-annotations`);if(d.annotations.forEach(t=>{let n=t.coordinates.map(e=>({x:x(e.x),y:S(e.y)}));if(n.length>1)for(let t=0;t<n.length-1;t++)e.append(`line`).attr(`class`,`wardley-annotation-line`).attr(`x1`,n[t].x).attr(`y1`,n[t].y).attr(`x2`,n[t+1].x).attr(`y2`,n[t+1].y).attr(`stroke`,s.axisColor).attr(`stroke-width`,1.5).attr(`stroke-dasharray`,`4 4`);n.forEach(n=>{let r=e.append(`g`).attr(`class`,`wardley-annotation`);r.append(`circle`).attr(`cx`,n.x).attr(`cy`,n.y).attr(`r`,10).attr(`fill`,`white`).attr(`stroke`,s.axisColor).attr(`stroke-width`,1.5),r.append(`text`).attr(`x`,n.x).attr(`y`,n.y).attr(`text-anchor`,`middle`).attr(`dominant-baseline`,`central`).attr(`font-size`,10).attr(`fill`,s.axisTextColor).attr(`font-weight`,`bold`).text(t.number)})}),d.annotationsBox){let t=x(d.annotationsBox.x),n=S(d.annotationsBox.y),r=e.append(`g`).attr(`class`,`wardley-annotations-box`),i=[...d.annotations].filter(e=>e.text).sort((e,t)=>e.number-t.number),a=[];if(i.forEach((e,i)=>{let o=r.append(`text`).attr(`x`,t+10).attr(`y`,n+10+(i+1)*16).attr(`font-size`,11).attr(`fill`,s.axisTextColor).attr(`text-anchor`,`start`).attr(`dominant-baseline`,`middle`).text(`${e.number}. ${e.text}`);a.push(o)}),a.length>0){let e=0,c=0;a.forEach(t=>{let n=t.node(),r=n.getComputedTextLength();e=Math.max(e,r);let i=n.getBBox();c=Math.max(c,i.height)});let l=e+20+105,u=i.length*16+20+c/2,d=o.padding,f=m-o.padding-l,p=o.padding,g=h-o.padding-u;t=Math.max(d,Math.min(t,f)),n=Math.max(p,Math.min(n,g)),a.forEach((e,r)=>{e.attr(`x`,t+10).attr(`y`,n+10+(r+1)*16)}),r.insert(`rect`,`text`).attr(`x`,t).attr(`y`,n).attr(`width`,l).attr(`height`,u).attr(`fill`,`white`).attr(`stroke`,s.axisColor).attr(`stroke-width`,1.5).attr(`rx`,4).attr(`ry`,4)}}}if(d.notes.length>0){let e=_.append(`g`).attr(`class`,`wardley-notes`);d.notes.forEach(t=>{let n=x(t.x),r=S(t.y);e.append(`text`).attr(`x`,n).attr(`y`,r).attr(`text-anchor`,`start`).attr(`font-size`,11).attr(`fill`,s.axisTextColor).attr(`font-weight`,`bold`).text(t.text)})}if(d.accelerators.length>0){let e=_.append(`g`).attr(`class`,`wardley-accelerators`);d.accelerators.forEach(t=>{let n=x(t.x),r=S(t.y),i=`
3
3
  M ${n} ${r-30/2}
4
4
  L ${n+60-20} ${r-30/2}
@@ -1,4 +1,4 @@
1
- import{n as e,r as t}from"./src-DOAilbaA.js";import{B as n,C as r,E as i,L as a,V as o,W as s,_ as c,a as l,c as u,d,v as f,y as p}from"./chunk-ICPOFSXX-BC5Xd13f.js";import{t as m}from"./linear-faBQNtcz.js";import{t as h}from"./ordinal-BLFwWMHf.js";import{t as g}from"./init-8GNx5phc.js";import{r as _}from"./chunk-5PVQY5BW-BpceE2BZ.js";import{t as v}from"./line-C59Ezo8Z.js";import{t as y}from"./chunk-426QAEUC-jRhC4EYv.js";import{t as b}from"./chunk-U2HBQHQK-DenE4TdD.js";function x(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function S(){var e=h().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=x(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return S(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},g.apply(d(),arguments)}var C=(function(){var t=e(function(e,t,n,r){for(n||={},r=e.length;r--;n[e[r]]=t);return n},`o`),n=[1,10,12,14,16,18,19,21,23],r=[2,6],i=[1,3],a=[1,5],o=[1,6],s=[1,7],c=[1,5,10,12,14,16,18,19,21,23,34,35,36],l=[1,25],u=[1,26],d=[1,28],f=[1,29],p=[1,30],m=[1,31],h=[1,32],g=[1,33],_=[1,34],v=[1,35],y=[1,36],b=[1,37],x=[1,43],S=[1,42],C=[1,47],w=[1,50],T=[1,10,12,14,16,18,19,21,23,34,35,36],E=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36],D=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36,41,42,43,44,45,46,47,48,49,50],O=[1,64],k={trace:e(function(){},`trace`),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,commaSeparatedNumbers:25,SQUARE_BRACES_END:26,NUMBER_WITH_DECIMAL:27,COMMA:28,xAxisData:29,bandData:30,ARROW_DELIMITER:31,commaSeparatedTexts:32,yAxisData:33,NEWLINE:34,SEMI:35,EOF:36,alphaNum:37,STR:38,MD_STR:39,alphaNumToken:40,AMP:41,NUM:42,ALPHA:43,PLUS:44,EQUALS:45,MULT:46,DOT:47,BRKT:48,MINUS:49,UNDERSCORE:50,$accept:0,$end:1},terminals_:{2:`error`,5:`XYCHART`,8:`CHART_ORIENTATION`,10:`title`,12:`X_AXIS`,14:`Y_AXIS`,16:`LINE`,18:`BAR`,19:`acc_title`,20:`acc_title_value`,21:`acc_descr`,22:`acc_descr_value`,23:`acc_descr_multiline_value`,24:`SQUARE_BRACES_START`,26:`SQUARE_BRACES_END`,27:`NUMBER_WITH_DECIMAL`,28:`COMMA`,31:`ARROW_DELIMITER`,34:`NEWLINE`,35:`SEMI`,36:`EOF`,38:`STR`,39:`MD_STR`,41:`AMP`,42:`NUM`,43:`ALPHA`,44:`PLUS`,45:`EQUALS`,46:`MULT`,47:`DOT`,48:`BRKT`,49:`MINUS`,50:`UNDERSCORE`},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[13,1],[13,2],[13,1],[29,1],[29,3],[30,3],[32,3],[32,1],[15,1],[15,2],[15,1],[33,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[37,1],[37,2],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1]],performAction:e(function(e,t,n,r,i,a,o){var s=a.length-1;switch(i){case 5:r.setOrientation(a[s]);break;case 9:r.setDiagramTitle(a[s].text.trim());break;case 12:r.setLineData({text:``,type:`text`},a[s]);break;case 13:r.setLineData(a[s-1],a[s]);break;case 14:r.setBarData({text:``,type:`text`},a[s]);break;case 15:r.setBarData(a[s-1],a[s]);break;case 16:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 17:case 18:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 19:this.$=a[s-1];break;case 20:this.$=[Number(a[s-2]),...a[s]];break;case 21:this.$=[Number(a[s])];break;case 22:r.setXAxisTitle(a[s]);break;case 23:r.setXAxisTitle(a[s-1]);break;case 24:r.setXAxisTitle({type:`text`,text:``});break;case 25:r.setXAxisBand(a[s]);break;case 26:r.setXAxisRangeData(Number(a[s-2]),Number(a[s]));break;case 27:this.$=a[s-1];break;case 28:this.$=[a[s-2],...a[s]];break;case 29:this.$=[a[s]];break;case 30:r.setYAxisTitle(a[s]);break;case 31:r.setYAxisTitle(a[s-1]);break;case 32:r.setYAxisTitle({type:`text`,text:``});break;case 33:r.setYAxisRangeData(Number(a[s-2]),Number(a[s]));break;case 37:this.$={text:a[s],type:`text`};break;case 38:this.$={text:a[s],type:`text`};break;case 39:this.$={text:a[s],type:`markdown`};break;case 40:this.$=a[s];break;case 41:this.$=a[s-1]+``+a[s];break}},`anonymous`),table:[t(n,r,{3:1,4:2,7:4,5:i,34:a,35:o,36:s}),{1:[3]},t(n,r,{4:2,7:4,3:8,5:i,34:a,35:o,36:s}),t(n,r,{4:2,7:4,6:9,3:10,5:i,8:[1,11],34:a,35:o,36:s}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},t(c,[2,34]),t(c,[2,35]),t(c,[2,36]),{1:[2,1]},t(n,r,{4:2,7:4,3:21,5:i,34:a,35:o,36:s}),{1:[2,3]},t(c,[2,5]),t(n,[2,7],{4:22,34:a,35:o,36:s}),{11:23,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},{11:39,13:38,24:x,27:S,29:40,30:41,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},{11:45,15:44,27:C,33:46,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},{11:49,17:48,24:w,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},{11:52,17:51,24:w,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},{20:[1,53]},{22:[1,54]},t(T,[2,18]),{1:[2,2]},t(T,[2,8]),t(T,[2,9]),t(E,[2,37],{40:55,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b}),t(E,[2,38]),t(E,[2,39]),t(D,[2,40]),t(D,[2,42]),t(D,[2,43]),t(D,[2,44]),t(D,[2,45]),t(D,[2,46]),t(D,[2,47]),t(D,[2,48]),t(D,[2,49]),t(D,[2,50]),t(D,[2,51]),t(T,[2,10]),t(T,[2,22],{30:41,29:56,24:x,27:S}),t(T,[2,24]),t(T,[2,25]),{31:[1,57]},{11:59,32:58,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},t(T,[2,11]),t(T,[2,30],{33:60,27:C}),t(T,[2,32]),{31:[1,61]},t(T,[2,12]),{17:62,24:w},{25:63,27:O},t(T,[2,14]),{17:65,24:w},t(T,[2,16]),t(T,[2,17]),t(D,[2,41]),t(T,[2,23]),{27:[1,66]},{26:[1,67]},{26:[2,29],28:[1,68]},t(T,[2,31]),{27:[1,69]},t(T,[2,13]),{26:[1,70]},{26:[2,21],28:[1,71]},t(T,[2,15]),t(T,[2,26]),t(T,[2,27]),{11:59,32:72,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},t(T,[2,33]),t(T,[2,19]),{25:73,27:O},{26:[2,28]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],72:[2,28],73:[2,20]},parseError:e(function(e,t){if(t.recoverable)this.trace(e);else{var n=Error(e);throw n.hash=t,n}},`parseError`),parse:e(function(t){var n=this,r=[0],i=[],a=[null],o=[],s=this.table,c=``,l=0,u=0,d=0,f=2,p=1,m=o.slice.call(arguments,1),h=Object.create(this.lexer),g={yy:{}};for(var _ in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_)&&(g.yy[_]=this.yy[_]);h.setInput(t,g.yy),g.yy.lexer=h,g.yy.parser=this,h.yylloc===void 0&&(h.yylloc={});var v=h.yylloc;o.push(v);var y=h.options&&h.options.ranges;typeof g.yy.parseError==`function`?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function b(e){r.length-=2*e,a.length-=e,o.length-=e}e(b,`popStack`);function x(){var e=i.pop()||h.lex()||p;return typeof e!=`number`&&(e instanceof Array&&(i=e,e=i.pop()),e=n.symbols_[e]||e),e}e(x,`lex`);for(var S,C,w,T,E,D={},O,k,A,j;;){if(w=r[r.length-1],this.defaultActions[w]?T=this.defaultActions[w]:(S??=x(),T=s[w]&&s[w][S]),T===void 0||!T.length||!T[0]){var M=``;for(O in j=[],s[w])this.terminals_[O]&&O>f&&j.push(`'`+this.terminals_[O]+`'`);M=h.showPosition?`Parse error on line `+(l+1)+`:
1
+ import{n as e,r as t}from"./src-BXk72DrU.js";import{B as n,C as r,E as i,L as a,V as o,W as s,_ as c,a as l,c as u,d,v as f,y as p}from"./chunk-ICPOFSXX-rmT7ehAO.js";import{t as m}from"./linear-1aKBO-v1.js";import{t as h}from"./ordinal-C6wHcby9.js";import{t as g}from"./init-gbiKrEzm.js";import{r as _}from"./chunk-5PVQY5BW-kcWn_d-_.js";import{t as v}from"./line-BI6r6-S8.js";import{t as y}from"./chunk-426QAEUC-b3iWz8H-.js";import{t as b}from"./chunk-U2HBQHQK-Cg7rxXd1.js";function x(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function S(){var e=h().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=x(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return S(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},g.apply(d(),arguments)}var C=(function(){var t=e(function(e,t,n,r){for(n||={},r=e.length;r--;n[e[r]]=t);return n},`o`),n=[1,10,12,14,16,18,19,21,23],r=[2,6],i=[1,3],a=[1,5],o=[1,6],s=[1,7],c=[1,5,10,12,14,16,18,19,21,23,34,35,36],l=[1,25],u=[1,26],d=[1,28],f=[1,29],p=[1,30],m=[1,31],h=[1,32],g=[1,33],_=[1,34],v=[1,35],y=[1,36],b=[1,37],x=[1,43],S=[1,42],C=[1,47],w=[1,50],T=[1,10,12,14,16,18,19,21,23,34,35,36],E=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36],D=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36,41,42,43,44,45,46,47,48,49,50],O=[1,64],k={trace:e(function(){},`trace`),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,commaSeparatedNumbers:25,SQUARE_BRACES_END:26,NUMBER_WITH_DECIMAL:27,COMMA:28,xAxisData:29,bandData:30,ARROW_DELIMITER:31,commaSeparatedTexts:32,yAxisData:33,NEWLINE:34,SEMI:35,EOF:36,alphaNum:37,STR:38,MD_STR:39,alphaNumToken:40,AMP:41,NUM:42,ALPHA:43,PLUS:44,EQUALS:45,MULT:46,DOT:47,BRKT:48,MINUS:49,UNDERSCORE:50,$accept:0,$end:1},terminals_:{2:`error`,5:`XYCHART`,8:`CHART_ORIENTATION`,10:`title`,12:`X_AXIS`,14:`Y_AXIS`,16:`LINE`,18:`BAR`,19:`acc_title`,20:`acc_title_value`,21:`acc_descr`,22:`acc_descr_value`,23:`acc_descr_multiline_value`,24:`SQUARE_BRACES_START`,26:`SQUARE_BRACES_END`,27:`NUMBER_WITH_DECIMAL`,28:`COMMA`,31:`ARROW_DELIMITER`,34:`NEWLINE`,35:`SEMI`,36:`EOF`,38:`STR`,39:`MD_STR`,41:`AMP`,42:`NUM`,43:`ALPHA`,44:`PLUS`,45:`EQUALS`,46:`MULT`,47:`DOT`,48:`BRKT`,49:`MINUS`,50:`UNDERSCORE`},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[13,1],[13,2],[13,1],[29,1],[29,3],[30,3],[32,3],[32,1],[15,1],[15,2],[15,1],[33,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[37,1],[37,2],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1]],performAction:e(function(e,t,n,r,i,a,o){var s=a.length-1;switch(i){case 5:r.setOrientation(a[s]);break;case 9:r.setDiagramTitle(a[s].text.trim());break;case 12:r.setLineData({text:``,type:`text`},a[s]);break;case 13:r.setLineData(a[s-1],a[s]);break;case 14:r.setBarData({text:``,type:`text`},a[s]);break;case 15:r.setBarData(a[s-1],a[s]);break;case 16:this.$=a[s].trim(),r.setAccTitle(this.$);break;case 17:case 18:this.$=a[s].trim(),r.setAccDescription(this.$);break;case 19:this.$=a[s-1];break;case 20:this.$=[Number(a[s-2]),...a[s]];break;case 21:this.$=[Number(a[s])];break;case 22:r.setXAxisTitle(a[s]);break;case 23:r.setXAxisTitle(a[s-1]);break;case 24:r.setXAxisTitle({type:`text`,text:``});break;case 25:r.setXAxisBand(a[s]);break;case 26:r.setXAxisRangeData(Number(a[s-2]),Number(a[s]));break;case 27:this.$=a[s-1];break;case 28:this.$=[a[s-2],...a[s]];break;case 29:this.$=[a[s]];break;case 30:r.setYAxisTitle(a[s]);break;case 31:r.setYAxisTitle(a[s-1]);break;case 32:r.setYAxisTitle({type:`text`,text:``});break;case 33:r.setYAxisRangeData(Number(a[s-2]),Number(a[s]));break;case 37:this.$={text:a[s],type:`text`};break;case 38:this.$={text:a[s],type:`text`};break;case 39:this.$={text:a[s],type:`markdown`};break;case 40:this.$=a[s];break;case 41:this.$=a[s-1]+``+a[s];break}},`anonymous`),table:[t(n,r,{3:1,4:2,7:4,5:i,34:a,35:o,36:s}),{1:[3]},t(n,r,{4:2,7:4,3:8,5:i,34:a,35:o,36:s}),t(n,r,{4:2,7:4,6:9,3:10,5:i,8:[1,11],34:a,35:o,36:s}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},t(c,[2,34]),t(c,[2,35]),t(c,[2,36]),{1:[2,1]},t(n,r,{4:2,7:4,3:21,5:i,34:a,35:o,36:s}),{1:[2,3]},t(c,[2,5]),t(n,[2,7],{4:22,34:a,35:o,36:s}),{11:23,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},{11:39,13:38,24:x,27:S,29:40,30:41,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},{11:45,15:44,27:C,33:46,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},{11:49,17:48,24:w,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},{11:52,17:51,24:w,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},{20:[1,53]},{22:[1,54]},t(T,[2,18]),{1:[2,2]},t(T,[2,8]),t(T,[2,9]),t(E,[2,37],{40:55,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b}),t(E,[2,38]),t(E,[2,39]),t(D,[2,40]),t(D,[2,42]),t(D,[2,43]),t(D,[2,44]),t(D,[2,45]),t(D,[2,46]),t(D,[2,47]),t(D,[2,48]),t(D,[2,49]),t(D,[2,50]),t(D,[2,51]),t(T,[2,10]),t(T,[2,22],{30:41,29:56,24:x,27:S}),t(T,[2,24]),t(T,[2,25]),{31:[1,57]},{11:59,32:58,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},t(T,[2,11]),t(T,[2,30],{33:60,27:C}),t(T,[2,32]),{31:[1,61]},t(T,[2,12]),{17:62,24:w},{25:63,27:O},t(T,[2,14]),{17:65,24:w},t(T,[2,16]),t(T,[2,17]),t(D,[2,41]),t(T,[2,23]),{27:[1,66]},{26:[1,67]},{26:[2,29],28:[1,68]},t(T,[2,31]),{27:[1,69]},t(T,[2,13]),{26:[1,70]},{26:[2,21],28:[1,71]},t(T,[2,15]),t(T,[2,26]),t(T,[2,27]),{11:59,32:72,37:24,38:l,39:u,40:27,41:d,42:f,43:p,44:m,45:h,46:g,47:_,48:v,49:y,50:b},t(T,[2,33]),t(T,[2,19]),{25:73,27:O},{26:[2,28]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],72:[2,28],73:[2,20]},parseError:e(function(e,t){if(t.recoverable)this.trace(e);else{var n=Error(e);throw n.hash=t,n}},`parseError`),parse:e(function(t){var n=this,r=[0],i=[],a=[null],o=[],s=this.table,c=``,l=0,u=0,d=0,f=2,p=1,m=o.slice.call(arguments,1),h=Object.create(this.lexer),g={yy:{}};for(var _ in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_)&&(g.yy[_]=this.yy[_]);h.setInput(t,g.yy),g.yy.lexer=h,g.yy.parser=this,h.yylloc===void 0&&(h.yylloc={});var v=h.yylloc;o.push(v);var y=h.options&&h.options.ranges;typeof g.yy.parseError==`function`?this.parseError=g.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function b(e){r.length-=2*e,a.length-=e,o.length-=e}e(b,`popStack`);function x(){var e=i.pop()||h.lex()||p;return typeof e!=`number`&&(e instanceof Array&&(i=e,e=i.pop()),e=n.symbols_[e]||e),e}e(x,`lex`);for(var S,C,w,T,E,D={},O,k,A,j;;){if(w=r[r.length-1],this.defaultActions[w]?T=this.defaultActions[w]:(S??=x(),T=s[w]&&s[w][S]),T===void 0||!T.length||!T[0]){var M=``;for(O in j=[],s[w])this.terminals_[O]&&O>f&&j.push(`'`+this.terminals_[O]+`'`);M=h.showPosition?`Parse error on line `+(l+1)+`:
2
2
  `+h.showPosition()+`
3
3
  Expecting `+j.join(`, `)+`, got '`+(this.terminals_[S]||S)+`'`:`Parse error on line `+(l+1)+`: Unexpected `+(S==p?`end of input`:`'`+(this.terminals_[S]||S)+`'`),this.parseError(M,{text:h.match,token:this.terminals_[S]||S,line:h.yylineno,loc:v,expected:j})}if(T[0]instanceof Array&&T.length>1)throw Error(`Parse Error: multiple actions possible at state: `+w+`, token: `+S);switch(T[0]){case 1:r.push(S),a.push(h.yytext),o.push(h.yylloc),r.push(T[1]),S=null,C?(S=C,C=null):(u=h.yyleng,c=h.yytext,l=h.yylineno,v=h.yylloc,d>0&&d--);break;case 2:if(k=this.productions_[T[1]][1],D.$=a[a.length-k],D._$={first_line:o[o.length-(k||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(k||1)].first_column,last_column:o[o.length-1].last_column},y&&(D._$.range=[o[o.length-(k||1)].range[0],o[o.length-1].range[1]]),E=this.performAction.apply(D,[c,u,l,g.yy,T[1],a,o].concat(m)),E!==void 0)return E;k&&(r=r.slice(0,-1*k*2),a=a.slice(0,-1*k),o=o.slice(0,-1*k)),r.push(this.productions_[T[1]][0]),a.push(D.$),o.push(D._$),A=s[r[r.length-2]][r[r.length-1]],r.push(A);break;case 3:return!0}}return!0},`parse`)};k.lexer=(function(){return{EOF:1,parseError:e(function(e,t){if(this.yy.parser)this.yy.parser.parseError(e,t);else throw Error(e)},`parseError`),setInput:e(function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match=``,this.conditionStack=[`INITIAL`],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},`setInput`),input:e(function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},`input`),unput:e(function(e){var t=e.length,n=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},`unput`),more:e(function(){return this._more=!0,this},`more`),reject:e(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError(`Lexical error on line `+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:``,token:null,line:this.yylineno});return this},`reject`),less:e(function(e){this.unput(this.match.slice(e))},`less`),pastInput:e(function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?`...`:``)+e.substr(-20).replace(/\n/g,``)},`pastInput`),upcomingInput:e(function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?`...`:``)).replace(/\n/g,``)},`upcomingInput`),showPosition:e(function(){var e=this.pastInput(),t=Array(e.length+1).join(`-`);return e+this.upcomingInput()+`
@@ -48,39 +48,38 @@
48
48
  -->
49
49
  <script>(() => { let t = 'system'; try { const r = localStorage.getItem('ok-theme-v1'); if (r === 'light' || r === 'dark' || r === 'system') t = r; } catch {} let dark = t === 'dark'; if (t === 'system') { try { dark = window.matchMedia('(prefers-color-scheme: dark)').matches; } catch {} } if (dark) document.documentElement.classList.add('dark'); if (window.okDesktop) document.documentElement.classList.add('electron-mode'); })();</script>
50
50
  <style>html { background-color: #fafafa } html.dark { background-color: #171717 }</style>
51
- <script type="module" crossorigin src="./assets/index-Cfu0nrKh.js"></script>
51
+ <script type="module" crossorigin src="./assets/index-Bzh2wENQ.js"></script>
52
52
  <link rel="modulepreload" crossorigin href="./assets/chunk-CFjPhJqf.js">
53
53
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-2ej06EnG.js">
54
54
  <link rel="modulepreload" crossorigin href="./assets/w3c-keyname-B5t0fahT.js">
55
- <link rel="modulepreload" crossorigin href="./assets/dist-Du-s1q8P.js">
56
- <link rel="modulepreload" crossorigin href="./assets/dist-BrsSsfiw.js">
57
- <link rel="modulepreload" crossorigin href="./assets/dist-BYGzJeLM.js">
58
- <link rel="modulepreload" crossorigin href="./assets/dist-DsbVHLNy.js">
59
- <link rel="modulepreload" crossorigin href="./assets/dist-Cq1LYbUj.js">
60
- <link rel="modulepreload" crossorigin href="./assets/stex-CzCFWeB9.js">
55
+ <link rel="modulepreload" crossorigin href="./assets/dist-D2RGH7XO.js">
56
+ <link rel="modulepreload" crossorigin href="./assets/dist-Cp-iTcML.js">
57
+ <link rel="modulepreload" crossorigin href="./assets/dist-B3L7cm0M.js">
58
+ <link rel="modulepreload" crossorigin href="./assets/dist-BiYnsAMa.js">
59
+ <link rel="modulepreload" crossorigin href="./assets/dist-CATLRngz.js">
60
+ <link rel="modulepreload" crossorigin href="./assets/stex-J8UMaf7u.js">
61
61
  <link rel="modulepreload" crossorigin href="./assets/trace-api-CiCjX4Sz.js">
62
62
  <link rel="modulepreload" crossorigin href="./assets/compiler-runtime-CVnuRdak.js">
63
63
  <link rel="modulepreload" crossorigin href="./assets/button-C1nwPVFQ.js">
64
64
  <link rel="modulepreload" crossorigin href="./assets/dist-Cg-Qaqw_.js">
65
- <link rel="modulepreload" crossorigin href="./assets/doc-hash-DefAyZGx.js">
65
+ <link rel="modulepreload" crossorigin href="./assets/doc-hash-D-COaeDG.js">
66
66
  <link rel="modulepreload" crossorigin href="./assets/propagation-api-3kmMXRwS.js">
67
- <link rel="modulepreload" crossorigin href="./assets/dist-OTL8-1C2.js">
67
+ <link rel="modulepreload" crossorigin href="./assets/dialog-CY2eQd6O.js">
68
68
  <link rel="modulepreload" crossorigin href="./assets/dist-Bej94Urx.js">
69
- <link rel="modulepreload" crossorigin href="./assets/input-BOmkuBId.js">
70
- <link rel="modulepreload" crossorigin href="./assets/DocumentContext-DOBntg5q.js">
69
+ <link rel="modulepreload" crossorigin href="./assets/input-hZk8Tm0e.js">
70
+ <link rel="modulepreload" crossorigin href="./assets/DocumentContext-D4lHVgL4.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/panel-8fydlQgn.js">
72
- <link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-isOlON7R.js">
72
+ <link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-BizuT3zF.js">
73
73
  <link rel="modulepreload" crossorigin href="./assets/label-Dv_9VZWz.js">
74
- <link rel="modulepreload" crossorigin href="./assets/toggle-group-fH3GS2vu.js">
75
- <link rel="modulepreload" crossorigin href="./assets/dialog-BFN-ujuF.js">
76
- <link rel="modulepreload" crossorigin href="./assets/textarea-CaFqgjns.js">
77
- <link rel="modulepreload" crossorigin href="./assets/config-validation-events-BpvRjXIZ.js">
74
+ <link rel="modulepreload" crossorigin href="./assets/toggle-group-B6Y5d2LH.js">
75
+ <link rel="modulepreload" crossorigin href="./assets/textarea-gXd-JXvQ.js">
76
+ <link rel="modulepreload" crossorigin href="./assets/config-validation-events-CuJstsYS.js">
78
77
  <link rel="modulepreload" crossorigin href="./assets/mcp-consent-store-DZ1pCmhN.js">
79
- <link rel="modulepreload" crossorigin href="./assets/tooltip-BuwIhPCp.js">
78
+ <link rel="modulepreload" crossorigin href="./assets/tooltip-Cn5mq_qc.js">
80
79
  <link rel="modulepreload" crossorigin href="./assets/agent-presence-BrTlNKmt.js">
81
- <link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-Bsa-5sN4.js">
82
- <link rel="modulepreload" crossorigin href="./assets/project-paths-Cs3srSjk.js">
83
- <link rel="stylesheet" crossorigin href="./assets/index-Cl4ZMMDO.css">
80
+ <link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-BebfMyQT.js">
81
+ <link rel="modulepreload" crossorigin href="./assets/project-paths-hiY0fNWB.js">
82
+ <link rel="stylesheet" crossorigin href="./assets/index-BHqEYdAv.css">
84
83
  </head>
85
84
 
86
85
  <body class="antialiased">
@@ -1,2 +1,2 @@
1
- import{c as e,f as t,s as n}from"./init-BVF99f4p.mjs";import"./loader-BuVjsSVh.mjs";import"./preview-CgtprTPm.mjs";function r(r,i,a={}){let o=[];for(let n of i){let i=t[n],s=i.projectConfigPath?.(r);if(!s){o.push({editorId:n,outcome:`skipped-no-project-surface`});continue}let c;try{c=e(i,r,a,void 0,s)}catch(e){o.push({editorId:n,outcome:`failed`,error:e instanceof Error?e.message:String(e)});continue}if(c.action===`written`||c.action===`overwritten`){o.push({editorId:n,outcome:c.action});continue}if(c.action===`failed`){o.push({editorId:n,outcome:`failed`,error:c.error});continue}o.push({editorId:n,outcome:`failed`,error:`unexpected project-scope action: ${c.action}`})}return{editorOutcomes:o,claudeLaunchJson:i.includes(`claude`)?n(r,a):void 0}}export{r as t};
2
- //# sourceMappingURL=src-ClUycJ-8.mjs.map
1
+ import{c as e,f as t,s as n}from"./init-waQJnje3.mjs";import"./loader-PJR8tk3Q.mjs";import"./preview-BbtR5Qqj.mjs";function r(r,i,a={}){let o=[];for(let n of i){let i=t[n],s=i.projectConfigPath?.(r);if(!s){o.push({editorId:n,outcome:`skipped-no-project-surface`});continue}let c;try{c=e(i,r,a,void 0,s)}catch(e){o.push({editorId:n,outcome:`failed`,error:e instanceof Error?e.message:String(e)});continue}if(c.action===`written`||c.action===`overwritten`){o.push({editorId:n,outcome:c.action});continue}if(c.action===`failed`){o.push({editorId:n,outcome:`failed`,error:c.error});continue}o.push({editorId:n,outcome:`failed`,error:`unexpected project-scope action: ${c.action}`})}return{editorOutcomes:o,claudeLaunchJson:i.includes(`claude`)?n(r,a):void 0}}export{r as t};
2
+ //# sourceMappingURL=src-C2dzaqiT.mjs.map
@@ -1,3 +1,3 @@
1
- import{n as e,t}from"./esm-CEs3LWY3.mjs";import"./dist-DD3jbGts.mjs";import{n}from"./constants-DaHLULeB.mjs";import{spawn as r}from"node:child_process";import{join as i}from"node:path";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,statSync as l}from"node:fs";import{homedir as u}from"node:os";import{setTimeout as d}from"node:timers/promises";const f=`Open Knowledge.app`,p=`/Applications/${f}`;function m(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return l(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function h(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(g(e,p))return p;let t=i(e.homeDir??u(),`Applications`,f);return g(e,t)?t:null}function g(e,t){try{let n=i(t,`Contents`,`MacOS`,`Open Knowledge`),r=e.statSync(n);return r&&typeof r.isFile==`function`?r.isFile():!1}catch{return!1}}function _(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`)return{available:!1,reason:`darwin-only`};let t;try{t=h(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:e.isTTY!==!0||e.env.SSH_CONNECTION||e.env.SSH_TTY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function v(e){(e.log??(e=>console.error(e)))("Launching Open Knowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),e.spawn(`open`,[`-b`,`com.inkeep.open-knowledge`],{detached:!0,stdio:`ignore`}).unref()}function y(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found at ${p}. Install via DMG, or omit --mode for browser mode.`;case`darwin-only`:return`Desktop app is macOS-only on this release. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect desktop bundle at ${p} (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available at ${p} but launch dispatch did not fire (caller bug).`}}function b(){let e=process.execPath,t=process.argv[1];return t?{command:e,prefixArgs:[t]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx @inkeep/open-knowledge\`. This re-introduces the version-drift surface that re-exec was fixing. Observed argv: ${JSON.stringify(process.argv)}`),{command:`npx`,prefixArgs:[`@inkeep/open-knowledge`]})}function x(e,t){return e.host??t.HOST??`localhost`}var S=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function C(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function w(e){o(e.lockDir)||s(e.lockDir,{recursive:!0});let t=c(i(e.lockDir,`last-spawn-error.log`),`w`),n=e.spawn??r,{PORT:l,...u}=process.env,d=b();try{let r=n(d.command,[...d.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:u});return r.unref(),r}finally{try{a(t)}catch{}}}async function T(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}function E(e){let t=e.sigtermGraceMs??1e4,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>d(e));return async()=>{try{let i=e.readUiLock();if(i&&e.isAlive(i.pid))try{e.killPid(i.pid,`SIGTERM`),e.log?.info({pid:i.pid,port:i.port},`idle-shutdown: SIGTERM UI sibling`);let a=Date.now()+t;for(;Date.now()<a&&e.isAlive(i.pid);)await r(n);if(e.isAlive(i.pid))try{e.killPid(i.pid,`SIGKILL`),e.log?.warn({pid:i.pid,graceMs:t},`idle-shutdown: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: SIGKILL failed`)}}catch(t){e.log?.warn({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t instanceof Error?t.message:String(t)},`idle-shutdown: UI lookup failed; proceeding with destroy`)}await e.destroy()}}async function D(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.skipUiAutoSpawn??!1,o=e.idleThresholdMs??18e5,{existsSync:s,mkdirSync:c}=await import(`node:fs`),{resolve:l}=await import(`node:path`),{bootServer:u,getLogger:f,isProcessAlive:p,readUiLock:m,resolveContentDir:h}=await import(`./dist-DLi5l7jc.mjs`),g=e.log??f(`start`),_=l(n,`.ok`);if(!i&&!s(_))throw new S(n);let v=h(t,n);s(v)||(c(v,{recursive:!0}),g.info({contentDir:v},`Created content directory`));let y=null,b=await u({config:t,contentDir:v,projectDir:n,contentRoot:t.content.dir,port:e.port,host:r,quiet:!1,localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:!0,idleShutdownMs:o,skipAutoInit:!0,spawnUiSiblingFn:async({lockDir:t})=>{if(y=C({uiLock:m(t),isAlive:p}),y.action===`spawn`&&!a)try{w({lockDir:t,cwd:n,spawn:e.spawn}),g.info({reason:y.reason},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else y.action===`skip`&&g.info({port:y.port,pid:y.pid},`UI already running at port ${y.port}`)},idleShutdownHandler:e=>E({readUiLock:()=>m(b.lockDir),isAlive:p,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:g}),log:g});y||={action:`skip`,reason:`alive`,pid:0,port:0};let x=y,D=null;if(x.action===`skip`)D=x.port>0?x.port:null;else if(!a){let t=e.uiBindTimeoutMs??3e3;D=await T({readUiLock:()=>m(b.lockDir),now:Date.now,sleep:e=>d(e),timeoutMs:t,pollIntervalMs:50}),D===null&&g.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:b.httpServer,destroy:b.destroy,lockDir:b.lockDir,contentDir:v,port:b.port,ready:b.ready,degraded:b.degraded,uiSpawnDecision:y,resolvedUiPort:D}}function O(t){if(t===`browser`||t===`app`)return t;throw new e(`--mode must be 'browser' or 'app'`)}async function k(e,t){let{renderBanner:r}=await import(`./banner-8cQrR88n.mjs`),{dim:i,error:a,warning:o}=await import(`./colors-BCE2jNgl.mjs`),s=process.cwd(),c=e,l=x(t,process.env),u=t.port===void 0?void 0:Number(t.port),d=process.env.PORT?Number(process.env.PORT):void 0,f=u??d,p;try{p=await D({config:c,cwd:s,host:l,port:f})}catch(e){e instanceof S&&(console.error(a(e.message)),process.exit(1));let t=A(e,s,await import(`./dist-DLi5l7jc.mjs`));t!==null&&(console.error(a(t)),process.exit(1)),console.error(`${a(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let m=!1,h=async e=>{if(!m){m=!0,console.log(i(`\nShutting down (${e})`));try{await p.destroy()}catch(e){console.error(`${a(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)}};process.once(`SIGINT`,()=>{h(`SIGINT`)}),process.once(`SIGTERM`,()=>{h(`SIGTERM`)});let g=`http://${l}:${p.port}`,_=l===`0.0.0.0`||l===`::`?`http://0.0.0.0:${p.port}`:void 0,v=p.resolvedUiPort,y=v!==null&&v>0?`http://${l}:${v}`:g;console.log(r({name:`open-knowledge`,version:n,localUrl:y,apiUrl:y===g?void 0:g,networkUrl:_}));let b={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};p.ready.then(async()=>{if(p.degraded.length>0){console.log();for(let e of p.degraded){let t=b[e]??`${e} (check server logs for details)`;console.warn(` ${o(`⚠`)} ${o(e)}: ${i(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-BOeCxs2W.mjs`);e(y)}}).catch(e=>{console.error(` ${a(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function A(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=i(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`Open Knowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function j(e){return new t(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,O).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
1
+ import{n as e,t}from"./esm-CEs3LWY3.mjs";import"./dist-Buq7uUK7.mjs";import{n}from"./constants-BX3j-Yin.mjs";import{spawn as r}from"node:child_process";import{join as i}from"node:path";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,statSync as l}from"node:fs";import{homedir as u}from"node:os";import{setTimeout as d}from"node:timers/promises";const f=`Open Knowledge.app`,p=`/Applications/${f}`;function m(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return l(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function h(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}if(g(e,p))return p;let t=i(e.homeDir??u(),`Applications`,f);return g(e,t)?t:null}function g(e,t){try{let n=i(t,`Contents`,`MacOS`,`Open Knowledge`),r=e.statSync(n);return r&&typeof r.isFile==`function`?r.isFile():!1}catch{return!1}}function _(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`)return{available:!1,reason:`darwin-only`};let t;try{t=h(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:e.isTTY!==!0||e.env.SSH_CONNECTION||e.env.SSH_TTY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function v(e){(e.log??(e=>console.error(e)))("Launching Open Knowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)"),e.spawn(`open`,[`-b`,`com.inkeep.open-knowledge`],{detached:!0,stdio:`ignore`}).unref()}function y(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found at ${p}. Install via DMG, or omit --mode for browser mode.`;case`darwin-only`:return`Desktop app is macOS-only on this release. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect desktop bundle at ${p} (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available at ${p} but launch dispatch did not fire (caller bug).`}}function b(){let e=process.execPath,t=process.argv[1];return t?{command:e,prefixArgs:[t]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx @inkeep/open-knowledge\`. This re-introduces the version-drift surface that re-exec was fixing. Observed argv: ${JSON.stringify(process.argv)}`),{command:`npx`,prefixArgs:[`@inkeep/open-knowledge`]})}function x(e,t){return e.host??t.HOST??`localhost`}var S=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}};function C(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function w(e){o(e.lockDir)||s(e.lockDir,{recursive:!0});let t=c(i(e.lockDir,`last-spawn-error.log`),`w`),n=e.spawn??r,{PORT:l,...u}=process.env,d=b();try{let r=n(d.command,[...d.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:u});return r.unref(),r}finally{try{a(t)}catch{}}}async function T(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}function E(e){let t=e.sigtermGraceMs??1e4,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>d(e));return async()=>{try{let i=e.readUiLock();if(i&&e.isAlive(i.pid))try{e.killPid(i.pid,`SIGTERM`),e.log?.info({pid:i.pid,port:i.port},`idle-shutdown: SIGTERM UI sibling`);let a=Date.now()+t;for(;Date.now()<a&&e.isAlive(i.pid);)await r(n);if(e.isAlive(i.pid))try{e.killPid(i.pid,`SIGKILL`),e.log?.warn({pid:i.pid,graceMs:t},`idle-shutdown: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: SIGKILL failed`)}}catch(t){e.log?.warn({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t instanceof Error?t.message:String(t)},`idle-shutdown: UI lookup failed; proceeding with destroy`)}await e.destroy()}}async function D(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.skipUiAutoSpawn??!1,o=e.idleThresholdMs??18e5,{existsSync:s,mkdirSync:c}=await import(`node:fs`),{resolve:l}=await import(`node:path`),{bootServer:u,getLogger:f,isProcessAlive:p,readUiLock:m,resolveContentDir:h}=await import(`./dist-B-QGEbwX.mjs`),g=e.log??f(`start`),_=l(n,`.ok`);if(!i&&!s(_))throw new S(n);let v=h(t,n);s(v)||(c(v,{recursive:!0}),g.info({contentDir:v},`Created content directory`));let y=null,b=await u({config:t,contentDir:v,projectDir:n,contentRoot:t.content.dir,port:e.port,host:r,quiet:!1,localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:!0,idleShutdownMs:o,skipAutoInit:!0,spawnUiSiblingFn:async({lockDir:t})=>{if(y=C({uiLock:m(t),isAlive:p}),y.action===`spawn`&&!a)try{w({lockDir:t,cwd:n,spawn:e.spawn}),g.info({reason:y.reason},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else y.action===`skip`&&g.info({port:y.port,pid:y.pid},`UI already running at port ${y.port}`)},idleShutdownHandler:e=>E({readUiLock:()=>m(b.lockDir),isAlive:p,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:g}),log:g});y||={action:`skip`,reason:`alive`,pid:0,port:0};let x=y,D=null;if(x.action===`skip`)D=x.port>0?x.port:null;else if(!a){let t=e.uiBindTimeoutMs??3e3;D=await T({readUiLock:()=>m(b.lockDir),now:Date.now,sleep:e=>d(e),timeoutMs:t,pollIntervalMs:50}),D===null&&g.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:b.httpServer,destroy:b.destroy,lockDir:b.lockDir,contentDir:v,port:b.port,ready:b.ready,degraded:b.degraded,uiSpawnDecision:y,resolvedUiPort:D}}function O(t){if(t===`browser`||t===`app`)return t;throw new e(`--mode must be 'browser' or 'app'`)}async function k(e,t){let{renderBanner:r}=await import(`./banner-8cQrR88n.mjs`),{dim:i,error:a,warning:o}=await import(`./colors-BCE2jNgl.mjs`),s=process.cwd(),c=e,l=x(t,process.env),u=t.port===void 0?void 0:Number(t.port),d=process.env.PORT?Number(process.env.PORT):void 0,f=u??d,p;try{p=await D({config:c,cwd:s,host:l,port:f})}catch(e){e instanceof S&&(console.error(a(e.message)),process.exit(1));let t=A(e,s,await import(`./dist-B-QGEbwX.mjs`));t!==null&&(console.error(a(t)),process.exit(1)),console.error(`${a(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let m=!1,h=async e=>{if(!m){m=!0,console.log(i(`\nShutting down (${e})`));try{await p.destroy()}catch(e){console.error(`${a(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)}};process.once(`SIGINT`,()=>{h(`SIGINT`)}),process.once(`SIGTERM`,()=>{h(`SIGTERM`)});let g=`http://${l}:${p.port}`,_=l===`0.0.0.0`||l===`::`?`http://0.0.0.0:${p.port}`:void 0,v=p.resolvedUiPort,y=v!==null&&v>0?`http://${l}:${v}`:g;console.log(r({name:`open-knowledge`,version:n,localUrl:y,apiUrl:y===g?void 0:g,networkUrl:_}));let b={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};p.ready.then(async()=>{if(p.degraded.length>0){console.log();for(let e of p.degraded){let t=b[e]??`${e} (check server logs for details)`;console.warn(` ${o(`⚠`)} ${o(e)}: ${i(t)}`)}console.log()}if(t.open){let{openBrowser:e}=await import(`./open-browser-BOeCxs2W.mjs`);e(y)}}).catch(e=>{console.error(` ${a(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}function A(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=i(t,`.ok`),r=n.readServerLock(e);return r?r.kind===`interactive`?`Open Knowledge desktop is currently running on this project. Quit it or use --cwd to point elsewhere.`:r.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`.":"Open Knowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function j(e){return new t(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,O).action(async t=>{let n=e();if(t.mode===`app`){t.open&&(process.stderr.write(`error: option '--mode=app' cannot be combined with '--open' (--open opens a browser tab against the local server, which app mode does not boot)
2
2
  `),process.exit(2));let e=[];if(t.port!==void 0&&e.push(`--port`),t.host!==void 0&&e.push(`--host`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=_(m());if(n.available){v({spawn:r});return}console.error(y(n.reason)),process.exit(1)}await k(n,t)})}export{C as a,w as c,b as d,m as f,E as i,j as l,v as m,T as n,x as o,_ as p,D as r,k as s,S as t,A as u};
3
- //# sourceMappingURL=start-9GiauZpx.mjs.map
3
+ //# sourceMappingURL=start-BPgTRJoS.mjs.map
@@ -0,0 +1 @@
1
+ import{l as e}from"./start-BPgTRJoS.mjs";export{e as startCommand};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/open-knowledge",
3
- "version": "0.5.0-beta.2",
3
+ "version": "0.5.0-beta.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,2 +0,0 @@
1
- import"./dist-DD3jbGts.mjs";var e=`0.5.0-beta.2`;const t=`config.yml`,n=e;export{n,t};
2
- //# sourceMappingURL=constants-DaHLULeB.mjs.map
@@ -1 +0,0 @@
1
- import{o as e}from"./init-BVF99f4p.mjs";export{e as runInit};
@@ -1 +0,0 @@
1
- import{n as e}from"./loader-BuVjsSVh.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./preview-CgtprTPm.mjs";export{t as formatPreviewBlock,e as previewContent};