vibelet 1.2.239 → 1.2.240

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 (128) hide show
  1. package/README.md +26 -6
  2. package/dist/cloudflared/LICENSE +202 -0
  3. package/dist/cloudflared/manifest.json +96 -0
  4. package/dist/index.cjs +1 -1
  5. package/dist/inventory-scan-worker.cjs +1 -1
  6. package/dist/runtime-version.cjs +1 -1
  7. package/dist/vibelet.mjs +67 -9
  8. package/dist/web/assets/App-NMmWfGoY.js +2 -0
  9. package/dist/web/assets/BrowserControlPanel-0BJ0UEIg.js +1 -0
  10. package/dist/web/assets/ChatPane-DG_WUdJo.css +1 -0
  11. package/dist/web/assets/ChatPane-DeCnLcyQ.js +2 -0
  12. package/dist/web/assets/{ChipGroup-CW7pSZ1H.js → ChipGroup-B4vUfB2t.js} +1 -1
  13. package/dist/web/assets/{ComposerMenus-wrk6Gio2.js → ComposerMenus-DzcPREkw.js} +1 -1
  14. package/dist/web/assets/{DiffDrawer-BA2Hbb9d.js → DiffDrawer-BznOAVqb.js} +1 -1
  15. package/dist/web/assets/{FilesControlPanel-BazHfGx5.js → FilesControlPanel-Czt8c-TF.js} +1 -1
  16. package/dist/web/assets/{GlobalPendingDialog-CzVR6KXb.js → GlobalPendingDialog-DexSMOb1.js} +1 -1
  17. package/dist/web/assets/{ImageViewer-TeTrYqhq.js → ImageViewer-BQZAWRHv.js} +1 -1
  18. package/dist/web/assets/{LanguageSettingsPanel-BU_E69VO.js → LanguageSettingsPanel-CcKwfMci.js} +1 -1
  19. package/dist/web/assets/{MarkdownModePanel-Cf1zF1CS.js → MarkdownModePanel-Djl7nwaJ.js} +1 -1
  20. package/dist/web/assets/{MessageImage-Beca9pI9.js → MessageImage-BNOsxgJR.js} +1 -1
  21. package/dist/web/assets/NewSessionDialog-EXTRdgtg.js +1 -0
  22. package/dist/web/assets/NewSessionDialog-eX_6NPbk.css +1 -0
  23. package/dist/web/assets/{NotificationSettingsPanel-DbDEqalL.js → NotificationSettingsPanel-Clp5I7Xt.js} +1 -1
  24. package/dist/web/assets/{PanelFind-C_SuWRdx.js → PanelFind-DtJNet9b.js} +1 -1
  25. package/dist/web/assets/RemoteLifeOSBlock-B5kU_35n.js +2 -0
  26. package/dist/web/assets/{RemoteWorkspaceSettings-C2-LkNIY.js → RemoteWorkspaceSettings-DiV8YdWM.js} +1 -1
  27. package/dist/web/assets/{SessionTerminalPanel-0eTDyrbE.js → SessionTerminalPanel-CfChktgw.js} +2 -2
  28. package/dist/web/assets/{SpeechInputSettingsPanel-CPbNY2rE.js → SpeechInputSettingsPanel-BT-RXrZI.js} +1 -1
  29. package/dist/web/assets/{ThemeSettingsPanel-18vq_pMT.js → ThemeSettingsPanel-BMeMeln2.js} +1 -1
  30. package/dist/web/assets/{__vite-browser-external-2447137e-DiZsMwIM.js → __vite-browser-external-2447137e-DZMxqW1v.js} +1 -1
  31. package/dist/web/assets/{abnfDiagram-VRR7QNED-D16YT2oa.js → abnfDiagram-VRR7QNED-DK2hMaza.js} +1 -1
  32. package/dist/web/assets/{arc-CD8cZzH1.js → arc-CzrEQYq_.js} +1 -1
  33. package/dist/web/assets/{architectureDiagram-ZJ3FMSHR-BoHVV-Bf.js → architectureDiagram-ZJ3FMSHR-DZxghfRl.js} +1 -1
  34. package/dist/web/assets/{arrow-left-BWX9F1j7.js → arrow-left-CaVb4nSl.js} +1 -1
  35. package/dist/web/assets/{arrow-right-DL315HuR.js → arrow-right-BzeEEQgJ.js} +1 -1
  36. package/dist/web/assets/{blockDiagram-677ZJIJ3-dankl6OT.js → blockDiagram-677ZJIJ3-BkA7tw-T.js} +1 -1
  37. package/dist/web/assets/{c4Diagram-LMCZKHZV-CnEfLirT.js → c4Diagram-LMCZKHZV-B7XTpVaD.js} +1 -1
  38. package/dist/web/assets/channel-KKpxBoQi.js +1 -0
  39. package/dist/web/assets/chevron-up-d3Fwun7t.js +1 -0
  40. package/dist/web/assets/{chunk-2Q5K7J3B-Cf6eEkXb.js → chunk-2Q5K7J3B-Bss5s9E2.js} +1 -1
  41. package/dist/web/assets/{chunk-32BRIVSS-B-mFVfY1.js → chunk-32BRIVSS-CA1C0nXS.js} +1 -1
  42. package/dist/web/assets/{chunk-5VM5RSS4-vZpebBcz.js → chunk-5VM5RSS4-BH6U7p_f.js} +1 -1
  43. package/dist/web/assets/{chunk-EX3LRPZG-qX5Ystpv.js → chunk-EX3LRPZG-CcqWCMjI.js} +1 -1
  44. package/dist/web/assets/{chunk-JWPE2WC7-CikZm0lV.js → chunk-JWPE2WC7-B-4yNTb8.js} +1 -1
  45. package/dist/web/assets/{chunk-MOJQB5TN-BLeio_v0.js → chunk-MOJQB5TN-Bwvx3fwJ.js} +1 -1
  46. package/dist/web/assets/{chunk-RYQCIY6F-BYZjdg_s.js → chunk-RYQCIY6F-Bb4gbrTX.js} +1 -1
  47. package/dist/web/assets/{chunk-V7JOEXUC-5QaQnF3b.js → chunk-V7JOEXUC-DKK57hpe.js} +1 -1
  48. package/dist/web/assets/{chunk-VR4S4FIN-ztEf7jtF.js → chunk-VR4S4FIN--Lw_tXW6.js} +1 -1
  49. package/dist/web/assets/{chunk-XXDRQBXY-BKO3NrVs.js → chunk-XXDRQBXY-BmnjnFO6.js} +1 -1
  50. package/dist/web/assets/classDiagram-OUVF2IWQ-CHHZpVy2.js +1 -0
  51. package/dist/web/assets/classDiagram-v2-EOCWNBFH-CHHZpVy2.js +1 -0
  52. package/dist/web/assets/{collectMessageImages-D1Qfi5Ue.js → collectMessageImages-C3-JxSH9.js} +1 -1
  53. package/dist/web/assets/{cose-bilkent-JH36ORCC-BjuHC-9r.js → cose-bilkent-JH36ORCC-BxPt-mvK.js} +1 -1
  54. package/dist/web/assets/{cynefin-VYW2F7L2-C9WA3Klp.js → cynefin-VYW2F7L2-XMhkQxq7.js} +1 -1
  55. package/dist/web/assets/{cynefinDiagram-TSTJHNR4-BrkQLEng.js → cynefinDiagram-TSTJHNR4-Dxsg5z0o.js} +1 -1
  56. package/dist/web/assets/{dagre-VKFMJZFB-COXHxqP3.js → dagre-VKFMJZFB-BTkUFd1o.js} +1 -1
  57. package/dist/web/assets/{diagram-FQU43EPY-BFIgdo4s.js → diagram-FQU43EPY-C1CbNvfX.js} +1 -1
  58. package/dist/web/assets/{diagram-G47NLZAW-D1fQm8BL.js → diagram-G47NLZAW-BlP_2bxX.js} +1 -1
  59. package/dist/web/assets/{diagram-NH7WQ7WH-BD0xfVRd.js → diagram-NH7WQ7WH-QGwfazGi.js} +1 -1
  60. package/dist/web/assets/{diagram-OA4YK3LP-CaiohUvX.js → diagram-OA4YK3LP-DMuz6rJC.js} +1 -1
  61. package/dist/web/assets/{diagram-WEI45ONY-CcH3TCt-.js → diagram-WEI45ONY-B2xDOQNA.js} +1 -1
  62. package/dist/web/assets/{ebnfDiagram-CCIWWBDH-qLIcGxWI.js → ebnfDiagram-CCIWWBDH-CerWiTMA.js} +1 -1
  63. package/dist/web/assets/{erDiagram-Q63AITRT-CoL7qrIU.js → erDiagram-Q63AITRT-B-ssV3I1.js} +1 -1
  64. package/dist/web/assets/{file-editor-FileCodeEditor-fPld0d8r.js → file-editor-FileCodeEditor-DHRDHCQw.js} +1 -1
  65. package/dist/web/assets/{file-editor-ObsidianCodeEditor-DfjD9J5s.js → file-editor-ObsidianCodeEditor-DTwaAF2M.js} +1 -1
  66. package/dist/web/assets/file-editor-ObsidianFileEditor-HVqh_MR8.js +2 -0
  67. package/dist/web/assets/{flowDiagram-23GEKE2U-upXJb-cK.js → flowDiagram-23GEKE2U-CK4bbOLH.js} +1 -1
  68. package/dist/web/assets/{folder-plus-DrReR7Th.js → folder-plus-ROMRV3aa.js} +1 -1
  69. package/dist/web/assets/{ganttDiagram-NO4QXBWP-Boq7ZfbG.js → ganttDiagram-NO4QXBWP-BeljgJy_.js} +1 -1
  70. package/dist/web/assets/{gitGraphDiagram-IHSO6WYX-C3UD7kxM.js → gitGraphDiagram-IHSO6WYX-Cxm3yG2c.js} +1 -1
  71. package/dist/web/assets/highlighted-body-TPN3WLV5-BQu24dd9.js +1 -0
  72. package/dist/web/assets/{imageViewerCopy-BMcwovIT.js → imageViewerCopy-DZnSk47F.js} +1 -1
  73. package/dist/web/assets/{index-OdgHTLbm.js → index-D0cZ64pO.js} +1 -1
  74. package/dist/web/assets/{index-CJZRHYmg.js → index-D0cm1aa-.js} +1 -1
  75. package/dist/web/assets/{index-CArel_iz.js → index-DUrY8OKv.js} +2 -2
  76. package/dist/web/assets/{index-IHEjoxaX.js → index-ucaYl4gM.js} +1 -1
  77. package/dist/web/assets/infoDiagram-FWYZ7A6U-D1XxPfE7.js +1 -0
  78. package/dist/web/assets/{ishikawaDiagram-FXEZZL3T-C5c9muOA.js → ishikawaDiagram-FXEZZL3T-no1azdW5.js} +1 -1
  79. package/dist/web/assets/{journeyDiagram-5HDEW3XC-D6YhCPzt.js → journeyDiagram-5HDEW3XC-D69pbBkz.js} +1 -1
  80. package/dist/web/assets/{kanban-definition-HUTT4EX6-DDtSDQB3.js → kanban-definition-HUTT4EX6-DF9jBMQX.js} +1 -1
  81. package/dist/web/assets/{key-round-Bu4tTOs1.js → key-round-Cz5tcv0j.js} +1 -1
  82. package/dist/web/assets/{linear-Cn0QcXcT.js → linear-BvELtO_n.js} +1 -1
  83. package/dist/web/assets/{mermaid-O7DHMXV3-Da6OUdgR.js → mermaid-O7DHMXV3-DQT4ZA59.js} +2 -2
  84. package/dist/web/assets/{mermaid.core-B71KCuEy.js → mermaid.core-Cqy39_Ub.js} +2 -2
  85. package/dist/web/assets/{mic-BJRlwfse.js → mic-CfwPV1bx.js} +1 -1
  86. package/dist/web/assets/{mindmap-definition-LN4V7U3C-CzqgcnU8.js → mindmap-definition-LN4V7U3C-rUKSYXvP.js} +1 -1
  87. package/dist/web/assets/{pegDiagram-2B236MQR-BBBLeyAR.js → pegDiagram-2B236MQR-C_nLcufF.js} +1 -1
  88. package/dist/web/assets/{pieDiagram-ENE6RG2P-wDmBek2O.js → pieDiagram-ENE6RG2P-lKOgx3ur.js} +1 -1
  89. package/dist/web/assets/{quadrantDiagram-ABIIQ3AL-CiHFwAYe.js → quadrantDiagram-ABIIQ3AL-CmD-Y89j.js} +1 -1
  90. package/dist/web/assets/{railroadDiagram-RFXS5EU6-Bzato2yp.js → railroadDiagram-RFXS5EU6-BtUqJU9X.js} +1 -1
  91. package/dist/web/assets/{requirementDiagram-TGXJPOKE-D_9LFmYp.js → requirementDiagram-TGXJPOKE-BTuqBSlC.js} +1 -1
  92. package/dist/web/assets/{sankeyDiagram-HTMAVEWB-D108ZeA-.js → sankeyDiagram-HTMAVEWB-BIe_zpdG.js} +1 -1
  93. package/dist/web/assets/{sequenceDiagram-DBY2YBRQ-BpS0Gg69.js → sequenceDiagram-DBY2YBRQ-D4KPMbym.js} +1 -1
  94. package/dist/web/assets/{shield-check-CGxGNyPR.js → shield-check-BIUOkwl_.js} +1 -1
  95. package/dist/web/assets/{sizeCapture-X5ZJPWSS-BSEM5OEf.js → sizeCapture-X5ZJPWSS-CzD-vufl.js} +1 -1
  96. package/dist/web/assets/{stateDiagram-2N3HPSRC-Do4VQPVi.js → stateDiagram-2N3HPSRC-C1i-TljJ.js} +1 -1
  97. package/dist/web/assets/stateDiagram-v2-6OUMAXLB-km2c4PyD.js +1 -0
  98. package/dist/web/assets/{swimlanes-5IMT3BWC-r788e2DT.js → swimlanes-5IMT3BWC-CNe1pOBr.js} +2 -2
  99. package/dist/web/assets/swimlanesDiagram-G3AALYLV-Da0hYc5p.js +1 -0
  100. package/dist/web/assets/{timeline-definition-FHXFAJF6-YulkUzoz.js → timeline-definition-FHXFAJF6-CMs8BbV7.js} +1 -1
  101. package/dist/web/assets/{ComposerModelSettings-CHnw14co.css → useComposerCompletion-B0xUeljY.css} +1 -1
  102. package/dist/web/assets/useComposerCompletion-Brvpj9zV.js +1 -0
  103. package/dist/web/assets/{useMessageImage-DAqXbRED.js → useMessageImage-CNR1wZjv.js} +1 -1
  104. package/dist/web/assets/{vennDiagram-L72KCM5P-BQEO8zby.js → vennDiagram-L72KCM5P-aQDmSxcV.js} +1 -1
  105. package/dist/web/assets/{wardleyDiagram-EHGQE667-CR0Nflio.js → wardleyDiagram-EHGQE667-B77JdKDN.js} +1 -1
  106. package/dist/web/assets/{xychartDiagram-FW5EYKEG-DSDhUpzz.js → xychartDiagram-FW5EYKEG-RXhJfM4g.js} +1 -1
  107. package/dist/web/assets/{zap-CxrOlc87.js → zap-CIk2VoXi.js} +1 -1
  108. package/dist/web/index.html +1 -1
  109. package/dist/web/obsidian-editor-assets.json +1 -1
  110. package/package.json +16 -2
  111. package/scripts/install-cloudflared.mjs +58 -0
  112. package/dist/web/assets/App-DKhLAmub.js +0 -2
  113. package/dist/web/assets/BrowserControlPanel-CauziPMg.js +0 -1
  114. package/dist/web/assets/ChatPane-CEoPrwLT.css +0 -1
  115. package/dist/web/assets/ChatPane-Dsv1Sp_0.js +0 -2
  116. package/dist/web/assets/ComposerModelSettings-D3QMPRfS.js +0 -1
  117. package/dist/web/assets/NewSessionDialog-5JSvL7EJ.css +0 -1
  118. package/dist/web/assets/NewSessionDialog-CPC0n7i2.js +0 -1
  119. package/dist/web/assets/RemoteLifeOSBlock-aE9tb99H.js +0 -2
  120. package/dist/web/assets/channel-eAy6Uhzj.js +0 -1
  121. package/dist/web/assets/chevron-up-bHY6-UxU.js +0 -1
  122. package/dist/web/assets/classDiagram-OUVF2IWQ-DH_JRr8n.js +0 -1
  123. package/dist/web/assets/classDiagram-v2-EOCWNBFH-DH_JRr8n.js +0 -1
  124. package/dist/web/assets/file-editor-ObsidianFileEditor-jdTZNnN9.js +0 -2
  125. package/dist/web/assets/highlighted-body-TPN3WLV5-iUQ394Gx.js +0 -1
  126. package/dist/web/assets/infoDiagram-FWYZ7A6U-D9e8ooN4.js +0 -1
  127. package/dist/web/assets/stateDiagram-v2-6OUMAXLB-DEy9N7yk.js +0 -1
  128. package/dist/web/assets/swimlanesDiagram-G3AALYLV-BbEmmRWA.js +0 -1
@@ -0,0 +1 @@
1
+ import{c as r,s as e}from"./flowDiagram-23GEKE2U-CK4bbOLH.js";import{_ as t}from"./mermaid.core-Cqy39_Ub.js";import"./RemoteLifeOSBlock-B5kU_35n.js";import"./chunk-5VM5RSS4-BH6U7p_f.js";import"./chunk-XXDRQBXY-BmnjnFO6.js";import"./chunk-VR4S4FIN--Lw_tXW6.js";import"./chunk-32BRIVSS-CA1C0nXS.js";import"./purify.es-BNLkGfTg.js";import"./channel-KKpxBoQi.js";import"./index-DUrY8OKv.js";import"./marked.esm-BBjA1da9.js";import"./index-D0cZ64pO.js";import"./index-D0cm1aa-.js";import"./file-editor-index-C6CU7Fik.js";import"./App-NMmWfGoY.js";import"./chevron-up-d3Fwun7t.js";import"./__vite-browser-external-2447137e-DZMxqW1v.js";var o=r({defaultLayout:"swimlane",styles:t(r=>`${e(r)}\n .swimlane.cluster rect {\n stroke: ${r.clusterBorder} !important;\n }\n [data-look="neo"].cluster rect {\n filter: none;\n }\n`,"getStyles")});export{o as diagram};
@@ -1 +1 @@
1
- import{_ as t,z as e,a9 as n,aa as i,ab as r,c as a,l as s,F as o,a1 as c,ac as l,d as h,u as d,ad as p,q as u}from"./mermaid.core-B71KCuEy.js";import{d as g}from"./arc-CD8cZzH1.js";import"./index-CArel_iz.js";import"./RemoteLifeOSBlock-aE9tb99H.js";import"./index-OdgHTLbm.js";import"./index-CJZRHYmg.js";import"./file-editor-index-C6CU7Fik.js";import"./App-DKhLAmub.js";import"./chevron-up-bHY6-UxU.js";import"./__vite-browser-external-2447137e-DiZsMwIM.js";import"./purify.es-BNLkGfTg.js";import"./marked.esm-BBjA1da9.js";var y=function(){var e=t(function(t,e,n,i){for(n=n||{},i=t.length;i--;n[t[i]]=e);return n},"o"),n=[6,11,13,14,15,17,19,20,23,24],i=[1,12],r=[1,13],a=[1,14],s=[1,15],o=[1,16],c=[1,19],l=[1,20],h={trace:t(function(){},"trace"),yy:{},symbols_:{error:2,start:3,timeline_header:4,document:5,EOF:6,timeline:7,timeline_lr:8,timeline_td:9,line:10,SPACE:11,statement:12,NEWLINE:13,title:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,period_statement:21,event_statement:22,period:23,event:24,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",7:"timeline",8:"timeline_lr",9:"timeline_td",11:"SPACE",13:"NEWLINE",14:"title",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",23:"period",24:"event"},productions_:[0,[3,3],[4,1],[4,1],[4,1],[5,0],[5,2],[10,2],[10,1],[10,1],[10,1],[12,1],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[21,1],[22,1]],performAction:t(function(t,e,n,i,r,a,s){var o=a.length-1;switch(r){case 1:return a[o-1];case 3:i.setDirection("LR");break;case 4:i.setDirection("TD");break;case 5:case 9:case 10:this.$=[];break;case 6:a[o-1].push(a[o]),this.$=a[o-1];break;case 7:case 8:this.$=a[o];break;case 11:i.getCommonDb().setDiagramTitle(a[o].substr(6)),this.$=a[o].substr(6);break;case 12:this.$=a[o].trim(),i.getCommonDb().setAccTitle(this.$);break;case 13:case 14:this.$=a[o].trim(),i.getCommonDb().setAccDescription(this.$);break;case 15:i.addSection(a[o].substr(8)),this.$=a[o].substr(8);break;case 18:i.addTask(a[o],0,""),this.$=a[o];break;case 19:i.addEvent(a[o].substr(2)),this.$=a[o]}},"anonymous"),table:[{3:1,4:2,7:[1,3],8:[1,4],9:[1,5]},{1:[3]},e(n,[2,5],{5:6}),e(n,[2,2]),e(n,[2,3]),e(n,[2,4]),{6:[1,7],10:8,11:[1,9],12:10,13:[1,11],14:i,15:r,17:a,19:s,20:o,21:17,22:18,23:c,24:l},e(n,[2,10],{1:[2,1]}),e(n,[2,6]),{12:21,14:i,15:r,17:a,19:s,20:o,21:17,22:18,23:c,24:l},e(n,[2,8]),e(n,[2,9]),e(n,[2,11]),{16:[1,22]},{18:[1,23]},e(n,[2,14]),e(n,[2,15]),e(n,[2,16]),e(n,[2,17]),e(n,[2,18]),e(n,[2,19]),e(n,[2,7]),e(n,[2,12]),e(n,[2,13])],defaultActions:{},parseError:t(function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t)},"parseError"),parse:t(function(e){var n=this,i=[0],r=[],a=[null],s=[],o=this.table,c="",l=0,h=0,d=s.slice.call(arguments,1),p=Object.create(this.lexer),u={yy:{}};for(var g in this.yy)Object.prototype.hasOwnProperty.call(this.yy,g)&&(u.yy[g]=this.yy[g]);p.setInput(e,u.yy),u.yy.lexer=p,u.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var y=p.yylloc;s.push(y);var f=p.options&&p.options.ranges;function m(){var t;return"number"!=typeof(t=r.pop()||p.lex()||1)&&(t instanceof Array&&(t=(r=t).pop()),t=n.symbols_[t]||t),t}"function"==typeof u.yy.parseError?this.parseError=u.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,t(function(t){i.length=i.length-2*t,a.length=a.length-t,s.length=s.length-t},"popStack"),t(m,"lex");for(var x,b,k,w,_,$,v,S,E={};;){if(b=i[i.length-1],this.defaultActions[b]?k=this.defaultActions[b]:(null==x&&(x=m()),k=o[b]&&o[b][x]),void 0===k||!k.length||!k[0]){var T;for(_ in S=[],o[b])this.terminals_[_]&&_>2&&S.push("'"+this.terminals_[_]+"'");T=p.showPosition?"Parse error on line "+(l+1)+":\n"+p.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[x]||x)+"'":"Parse error on line "+(l+1)+": Unexpected "+(1==x?"end of input":"'"+(this.terminals_[x]||x)+"'"),this.parseError(T,{text:p.match,token:this.terminals_[x]||x,line:p.yylineno,loc:y,expected:S})}if(k[0]instanceof Array&&k.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+x);switch(k[0]){case 1:i.push(x),a.push(p.yytext),s.push(p.yylloc),i.push(k[1]),x=null,h=p.yyleng,c=p.yytext,l=p.yylineno,y=p.yylloc;break;case 2:if($=this.productions_[k[1]][1],E.$=a[a.length-$],E._$={first_line:s[s.length-($||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-($||1)].first_column,last_column:s[s.length-1].last_column},f&&(E._$.range=[s[s.length-($||1)].range[0],s[s.length-1].range[1]]),void 0!==(w=this.performAction.apply(E,[c,h,l,u.yy,k[1],a,s].concat(d))))return w;$&&(i=i.slice(0,-1*$*2),a=a.slice(0,-1*$),s=s.slice(0,-1*$)),i.push(this.productions_[k[1]][0]),a.push(E.$),s.push(E._$),v=o[i[i.length-2]][i[i.length-1]],i.push(v);break;case 3:return!0}}return!0},"parse")},d=function(){return{EOF:1,parseError:t(function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},"parseError"),setInput:t(function(t,e){return this.yy=e||this.yy||{},this._input=t,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:t(function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.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),t},"input"),unput:t(function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var i=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 r=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===i.length?this.yylloc.first_column:0)+i[i.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},"unput"),more:t(function(){return this._more=!0,this},"more"),reject:t(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):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).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:t(function(t){this.unput(this.match.slice(t))},"less"),pastInput:t(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:t(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:t(function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},"showPosition"),test_match:t(function(t,e){var n,i,r;if(this.options.backtrack_lexer&&(r={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(r.yylloc.range=this.yylloc.range.slice(0))),(i=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in r)this[a]=r[a];return!1}return!1},"test_match"),next:t(function(){if(this.done)return this.EOF;var t,e,n,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var r=this._currentRules(),a=0;a<r.length;a++)if((n=this._input.match(this.rules[r[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,i=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,r[a])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,r[i]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:t(function(){return this.next()||this.lex()},"lex"),begin:t(function(t){this.conditionStack.push(t)},"begin"),popState:t(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:t(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:t(function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},"topState"),pushState:t(function(t){this.begin(t)},"pushState"),stateStackSize:t(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:t(function(t,e,n,i){switch(n){case 0:case 1:case 3:case 4:break;case 2:return 13;case 5:return 8;case 6:return 9;case 7:return 7;case 8:return 14;case 9:return this.begin("acc_title"),15;case 10:return this.popState(),"acc_title_value";case 11:return this.begin("acc_descr"),17;case 12:return this.popState(),"acc_descr_value";case 13:this.begin("acc_descr_multiline");break;case 14:this.popState();break;case 15:return"acc_descr_multiline_value";case 16:return 20;case 17:return 24;case 18:return 23;case 19:return 6;case 20:return"INVALID"}},"anonymous"),rules:[/^(?:%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:timeline[ \t]+LR\b)/i,/^(?:timeline[ \t]+TD\b)/i,/^(?:timeline\b)/i,/^(?:title\s[^\n]+)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:section\s[^:\n]+)/i,/^(?::\s(?:[^:\n]|:(?!\s))+)/i,/^(?:[^#:\n]+)/i,/^(?:$)/i,/^(?:.)/i],conditions:{acc_descr_multiline:{rules:[14,15],inclusive:!1},acc_descr:{rules:[12],inclusive:!1},acc_title:{rules:[10],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,11,13,16,17,18,19,20],inclusive:!0}}}}();function p(){this.yy={}}return h.lexer=d,t(p,"Parser"),p.prototype=h,h.Parser=p,new p}();y.parser=y;var f=y,m={};d(m,{addEvent:()=>C,addSection:()=>I,addTask:()=>L,addTaskOrg:()=>N,clear:()=>S,default:()=>j,getCommonDb:()=>v,getDirection:()=>T,getSections:()=>M,getTasks:()=>H,setDirection:()=>E});var x="",b=0,k="LR",w=[],_=[],$=[],v=t(()=>p,"getCommonDb"),S=t(function(){w.length=0,_.length=0,x="",$.length=0,k="LR",u()},"clear"),E=t(function(t){k=t},"setDirection"),T=t(function(){return k},"getDirection"),I=t(function(t){x=t,w.push(t)},"addSection"),M=t(function(){return w},"getSections"),H=t(function(){let t=D(),e=0;for(;!t&&e<100;)t=D(),e++;return _.push(...$),_},"getTasks"),L=t(function(t,e,n){const i={id:b++,section:x,type:x,task:t,score:e||0,events:n?[n]:[]};$.push(i)},"addTask"),C=t(function(t){$.find(t=>t.id===b-1).events.push(t)},"addEvent"),N=t(function(t){const e={section:x,type:x,description:t,task:t,classes:[]};_.push(e)},"addTaskOrg"),D=t(function(){const e=t(function(t){return $[t].processed},"compileTask");let n=!0;for(const[t,i]of $.entries())e(t),n=n&&i.processed;return n},"compileTasks"),j={clear:S,getCommonDb:v,getDirection:T,setDirection:E,addSection:I,getSections:M,getTasks:H,addTask:L,addTaskOrg:N,addEvent:C},O=0,A=t(function(t,e){const n=t.append("rect");return n.attr("x",e.x),n.attr("y",e.y),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("width",e.width),n.attr("height",e.height),n.attr("rx",e.rx),n.attr("ry",e.ry),void 0!==e.class&&n.attr("class",e.class),n},"drawRect"),R=t(function(e,n){const i=e.append("circle").attr("cx",n.cx).attr("cy",n.cy).attr("class","face").attr("r",15).attr("stroke-width",2).attr("overflow","visible"),r=e.append("g");function a(t){const e=g().startAngle(Math.PI/2).endAngle(Math.PI/2*3).innerRadius(7.5).outerRadius(15/2.2);t.append("path").attr("class","mouth").attr("d",e).attr("transform","translate("+n.cx+","+(n.cy+2)+")")}function s(t){const e=g().startAngle(3*Math.PI/2).endAngle(Math.PI/2*5).innerRadius(7.5).outerRadius(15/2.2);t.append("path").attr("class","mouth").attr("d",e).attr("transform","translate("+n.cx+","+(n.cy+7)+")")}function o(t){t.append("line").attr("class","mouth").attr("stroke",2).attr("x1",n.cx-5).attr("y1",n.cy+7).attr("x2",n.cx+5).attr("y2",n.cy+7).attr("class","mouth").attr("stroke-width","1px").attr("stroke","#666")}return r.append("circle").attr("cx",n.cx-5).attr("cy",n.cy-5).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),r.append("circle").attr("cx",n.cx+5).attr("cy",n.cy-5).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),t(a,"smile"),t(s,"sad"),t(o,"ambivalent"),n.score>3?a(r):n.score<3?s(r):o(r),i},"drawFace"),B=t(function(t,e){const n=t.append("circle");return n.attr("cx",e.cx),n.attr("cy",e.cy),n.attr("class","actor-"+e.pos),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("r",e.r),void 0!==n.class&&n.attr("class",n.class),void 0!==e.title&&n.append("title").text(e.title),n},"drawCircle"),P=t(function(t,e){const n=e.text.replace(/<br\s*\/?>/gi," "),i=t.append("text");i.attr("x",e.x),i.attr("y",e.y),i.attr("class","legend"),i.style("text-anchor",e.anchor),void 0!==e.class&&i.attr("class",e.class);const r=i.append("tspan");return r.attr("x",e.x+2*e.textMargin),r.text(n),i},"drawText"),W=t(function(e,n){function i(t,e,n,i,r){return t+","+e+" "+(t+n)+","+e+" "+(t+n)+","+(e+i-r)+" "+(t+n-1.2*r)+","+(e+i)+" "+t+","+(e+i)}t(i,"genPoints");const r=e.append("polygon");r.attr("points",i(n.x,n.y,50,20,7)),r.attr("class","labelBox"),n.y=n.y+n.labelMargin,n.x=n.x+.5*n.labelMargin,P(e,n)},"drawLabel"),F=t(function(t,e,n){const i=t.append("g"),r=U();r.x=e.x,r.y=e.y,r.fill=e.fill,r.width=n.width,r.height=n.height,r.class="journey-section section-type-"+e.num,r.rx=3,r.ry=3,A(i,r),Z(n)(e.text,i,r.x,r.y,r.width,r.height,{class:"journey-section section-type-"+e.num},n,e.colour)},"drawSection"),z=-1,V=t(function(t,e,n,i){const r=e.x+n.width/2,a=t.append("g");z++,a.append("line").attr("id",i+"-task"+z).attr("x1",r).attr("y1",e.y).attr("x2",r).attr("y2",450).attr("class","task-line").attr("stroke-width","1px").attr("stroke-dasharray","4 2").attr("stroke","#666"),R(a,{cx:r,cy:300+30*(5-e.score),score:e.score});const s=U();s.x=e.x,s.y=e.y,s.fill=e.fill,s.width=n.width,s.height=n.height,s.class="task task-type-"+e.num,s.rx=3,s.ry=3,A(a,s),Z(n)(e.task,a,s.x,s.y,s.width,s.height,{class:"task"},n,e.colour)},"drawTask"),G=t(function(t,e){A(t,{x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,class:"rect"}).lower()},"drawBackgroundRect"),q=t(function(){return{x:0,y:0,fill:void 0,"text-anchor":"start",width:100,height:100,textMargin:0,rx:0,ry:0}},"getTextObj"),U=t(function(){return{x:0,y:0,width:100,anchor:"start",height:100,rx:0,ry:0}},"getNoteRect"),Z=function(){function e(t,e,n,i,a,s,o,c){r(e.append("text").attr("x",n+a/2).attr("y",i+s/2+5).style("font-color",c).style("text-anchor","middle").text(t),o)}function n(t,e,n,i,a,s,o,c,l){const{taskFontSize:h,taskFontFamily:d}=c,p=t.split(/<br\s*\/?>/gi);for(let u=0;u<p.length;u++){const t=u*h-h*(p.length-1)/2,c=e.append("text").attr("x",n+a/2).attr("y",i).attr("fill",l).style("text-anchor","middle").style("font-size",h).style("font-family",d);c.append("tspan").attr("x",n+a/2).attr("dy",t).text(p[u]),c.attr("y",i+s/2).attr("dominant-baseline","central").attr("alignment-baseline","central"),r(c,o)}}function i(t,e,i,a,s,o,c,l){const h=e.append("switch"),d=h.append("foreignObject").attr("x",i).attr("y",a).attr("width",s).attr("height",o).attr("position","fixed").append("xhtml:div").style("display","table").style("height","100%").style("width","100%");d.append("div").attr("class","label").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(t),n(t,h,i,a,s,o,c,l),r(d,c)}function r(t,e){for(const n in e)n in e&&t.attr(n,e[n])}return t(e,"byText"),t(n,"byTspan"),t(i,"byFo"),t(r,"_setTextAttrs"),function(t){return"fo"===t.textPlacement?i:"old"===t.textPlacement?e:n}}(),Y=t(function(t,e){O=0,z=-1,t.append("defs").append("marker").attr("id",e+"-arrowhead").attr("refX",5).attr("refY",2).attr("markerWidth",6).attr("markerHeight",4).attr("orient","auto").append("path").attr("d","M 0,0 V 4 L6,2 Z")},"initGraphics");function K(t,e){t.each(function(){var t,n=h(this),i=n.text().split(/(\s+|<br>)/).reverse(),r=[],a=n.attr("y"),s=parseFloat(n.attr("dy")),o=n.text(null).append("tspan").attr("x",0).attr("y",a).attr("dy",s+"em");for(let c=0;c<i.length;c++)t=i[i.length-1-c],r.push(t),o.text(r.join(" ").trim()),(o.node().getComputedTextLength()>e||"<br>"===t)&&(r.pop(),o.text(r.join(" ").trim()),r="<br>"===t?[""]:[t],o=n.append("tspan").attr("x",0).attr("y",a).attr("dy","1.1em").text(t))})}t(K,"wrap");var Q=t(function(t,e,n,i,r,a=!1){const{theme:s,look:o}=i,c=s?.includes("redux"),l=n%(i?.themeVariables?.THEME_COLOR_LIMIT??12)-1,d=t.append("g");e.section=l,d.attr("class",(e.class?e.class+" ":"")+"timeline-node section-"+l);const p=d.append("g"),u=d.append("g"),g=u.append("text").text(e.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(K,e.width).node().getBBox(),y=i.fontSize?.replace?i.fontSize.replace("px",""):i.fontSize;if(e.height=g.height+1.1*y*.5+e.padding,e.height=Math.max(e.height,e.maxHeight),e.width=e.width+2*e.padding,u.attr("transform","translate("+e.width/2+", "+e.padding/2+")"),c&&u.attr("transform",`translate(${e.width/2}, ${a?e.padding/2+3:e.padding})`),J(p,e,l,r,i),"neo"===o&&(d.attr("data-look","neo"),c)){const e=s.includes("dark"),n=t.node()?.ownerSVGElement??t.node(),i=h(n),r=i.attr("id")??"",a=r?`${r}-drop-shadow`:"drop-shadow";if(i.select(`#${a}`).empty()){const t=i.select("defs");(t.empty()?i.append("defs"):t).append("filter").attr("id",a).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity",e?"0.2":"0.06").attr("flood-color",e?"#FFFFFF":"#000000")}}return e},"drawNode"),X=t(function(t,e,n){const i=t.append("g"),r=i.append("text").text(e.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(K,e.width).node().getBBox(),a=n.fontSize?.replace?n.fontSize.replace("px",""):n.fontSize;return i.remove(),r.height+1.1*a*.5+e.padding},"getVirtualNodeHeight"),J=t(function(t,e,n,i,r){const{theme:a}=r,s=a?.includes("redux")?0:5,o=s>0?`M0 ${e.height-5} v${10-e.height} q0,-${s},${s},-${s} h${e.width-10} q${s},0,${s},${s} v${e.height-5} H0 Z`:`M0 ${e.height-5} v${-(e.height-5)} h${e.width} v${e.height} H0 Z`;t.append("path").attr("id",i+"-node-"+O++).attr("class","node-bkg node-"+e.type).attr("d",o),a?.includes("redux")||t.append("line").attr("class","node-line-"+n).attr("x1",0).attr("y1",e.height).attr("x2",e.width).attr("y2",e.height)},"defaultBkg"),tt={drawRect:A,drawCircle:B,drawSection:F,drawText:P,drawLabel:W,drawTask:V,drawBackgroundRect:G,getTextObj:q,getNoteRect:U,initGraphics:Y,drawNode:Q,getVirtualNodeHeight:X},et=t(function(t,e,n,i){const r=a(),{look:o,theme:c,themeVariables:d}=r,{useGradient:p,gradientStart:u,gradientStop:g}=d,y=r.timeline?.leftMargin??50;s.debug("timeline",i.db);const f=r.securityLevel;let m;"sandbox"===f&&(m=h("#i"+e));const x=h("sandbox"===f?m.nodes()[0].contentDocument.body:"body").select("#"+e);x.append("g");const b=i.db.getTasks(),k=i.db.getCommonDb().getDiagramTitle();s.debug("task",b),tt.initGraphics(x,e);const w=i.db.getSections();s.debug("sections",w);let _=0,$=0,v=0,S=0,E=50+y,T=50;S=50;let I=0,M=!0;w.forEach(function(t){const e={number:I,descr:t,section:I,width:150,padding:20,maxHeight:_},n=tt.getVirtualNodeHeight(x,e,r);s.debug("sectionHeight before draw",n),_=Math.max(_,n+20)});let H=0,L=0;s.debug("tasks.length",b.length);for(const[a,l]of b.entries()){const t={number:a,descr:l,section:l.section,width:150,padding:20,maxHeight:$},e=tt.getVirtualNodeHeight(x,t,r);s.debug("taskHeight before draw",e),$=Math.max($,e+20),H=Math.max(H,l.events.length);let n=0;for(const i of l.events){const t={descr:i,section:l.section,number:l.section,width:150,padding:20,maxHeight:50};n+=tt.getVirtualNodeHeight(x,t,r)}l.events.length>0&&(n+=10*(l.events.length-1)),L=Math.max(L,n)}s.debug("maxSectionHeight before draw",_),s.debug("maxTaskHeight before draw",$),w&&w.length>0?w.forEach(t=>{const n=b.filter(e=>e.section===t),i={number:I,descr:t,section:I,width:200*Math.max(n.length,1)-50,padding:20,maxHeight:_};s.debug("sectionNode",i);const a=x.append("g"),o=tt.drawNode(a,i,I,r,e);s.debug("sectionNode output",o),a.attr("transform",`translate(${E}, 50)`),T+=_+50,n.length>0&&nt(x,n,I,E,T,$,r,H,L,_,!1,e),E+=200*Math.max(n.length,1),T=50,I++}):(M=!1,nt(x,b,I,E,T,$,r,H,L,_,!0,e));const C=x.node().getBBox();if(s.debug("bounds",C),k&&x.append("text").text(k).attr("x","neo"===o?2*C.x+y:C.width/2-y).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),v=M?_+$+150:$+100,x.append("g").attr("class","lineWrapper").append("line").attr("x1",y).attr("y1",v).attr("x2",C.width+3*y).attr("y2",v).attr("stroke-width",4).attr("stroke","black").attr("marker-end",`url(#${e}-arrowhead)`),"neo"===o&&p&&"neutral"!==c){const t=x.select("defs"),e=(t.empty()?x.append("defs"):t).append("linearGradient").attr("id",x.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");e.append("stop").attr("offset","0%").attr("stop-color",u).attr("stop-opacity",1),e.append("stop").attr("offset","100%").attr("stop-color",g).attr("stop-opacity",1)}l(void 0,x,r.timeline?.padding??50,r.timeline?.useMaxWidth??!1)},"draw"),nt=t(function(t,e,n,i,r,a,o,c,l,h,d,p){for(const u of e){const e={descr:u.task,section:n,number:n,width:150,padding:20,maxHeight:a};s.debug("taskNode",e);const c=t.append("g").attr("class","taskWrapper"),h=tt.drawNode(c,e,n,o,p).height;if(s.debug("taskHeight after draw",h),c.attr("transform",`translate(${i}, ${r})`),a=Math.max(a,h),u.events){const e=t.append("g").attr("class","lineWrapper");let s=a;r+=100,s+=it(t,u.events,n,i,r,o,p),r-=100,e.append("line").attr("x1",i+95).attr("y1",r+a).attr("x2",i+95).attr("y2",r+a+100+l+100).attr("stroke-width",2).attr("stroke","black").attr("marker-end",`url(#${p}-arrowhead)`).attr("stroke-dasharray","5,5")}i+=200,d&&!o.timeline?.disableMulticolor&&n++}r-=10},"drawTasks"),it=t(function(t,e,n,i,r,a,o){let c=0;const l=r;r+=100;for(const h of e){const e={descr:h,section:n,number:n,width:150,padding:20,maxHeight:50};s.debug("eventNode",e);const l=t.append("g").attr("class","eventWrapper"),d=tt.drawNode(l,e,n,a,o,!0).height;c+=d,l.attr("transform",`translate(${i}, ${r})`),r=r+10+d}return r=l,c},"drawEvents"),rt={setConf:t(()=>{},"setConf"),draw:et},at=t(function(t,e,n,i){const r=a(),h=r.timeline?.leftMargin??50;s.debug("timeline",i.db);const d=o(e);d.append("g");const p=i.db.getTasks(),u=i.db.getCommonDb().getDiagramTitle();s.debug("task",p),tt.initGraphics(d);const g=i.db.getSections();s.debug("sections",g);let y=0,f=0;const m=50+h;let x=50;const b=x,k=m+230;let w=0;const _=g&&g.length>0,$=_?k:m+230,v=Math.max(50,580);g.forEach(function(t){const e={number:w,descr:t,section:w,width:v,padding:5,maxHeight:y},n=tt.getVirtualNodeHeight(d,e,r);s.debug("sectionHeight before draw",n),y=Math.max(y,n)});let S=0;s.debug("tasks.length",p.length);for(const[a,o]of p.entries()){const t={number:a,descr:o,section:o.section,width:200,padding:5,maxHeight:f},e=tt.getVirtualNodeHeight(d,t,r);s.debug("taskHeight before draw",e),f=Math.max(f,e);let n=0;for(const i of o.events){const t={descr:i,section:o.section,number:o.section,width:300,padding:5,maxHeight:50};n+=tt.getVirtualNodeHeight(d,t,r)}o.events.length>0&&(n+=10*(o.events.length-1)),S=Math.max(S,n)+0}s.debug("maxSectionHeight before draw",y),s.debug("maxTaskHeight before draw",f);const E=Math.max(f,S)+30;_?g.forEach(t=>{const e=p.filter(e=>e.section===t),n={number:w,descr:t,section:w,width:v,padding:5,maxHeight:y};s.debug("sectionNode",n);const i=d.append("g"),a=tt.drawNode(i,n,w,r);s.debug("sectionNode output",a);const o=$-230;i.attr("transform",`translate(${o}, ${x})`);const c=x+a.height+20;e.length>0&&st(d,e,w,$,c,f,r,E,!1);const l=e.length,h=a.height+20+E*Math.max(l,1)-(l>0?60:0);x+=h,w++}):st(d,p,w,$,x,f,r,E,!0);let T=d.node()?.getBBox();if(!T)throw new Error("bbox not found");if(s.debug("bounds",T),u){if(d.append("text").text(u).attr("x",T.width/2-h).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),T=d.node()?.getBBox(),!T)throw new Error("bbox not found");s.debug("bounds after title",T)}const[I]=c(r.fontSize),M=2*(I??16),H=.5*(I??16)+20,L=d.append("g").attr("class","lineWrapper");L.append("line").attr("x1",$).attr("y1",b-M).attr("x2",$).attr("y2",T.y+T.height+H).attr("stroke-width",4).attr("stroke","black").attr("marker-end","url(#arrowhead)"),L.lower(),l(void 0,d,r.timeline?.padding??50,r.timeline?.useMaxWidth??!1)},"draw"),st=t(function(t,e,n,i,r,a,o,c,l){for(const h of e){const e={descr:h.task,section:n,number:n,width:200,padding:5,maxHeight:a};s.debug("taskNode",e);const d=t.append("g").attr("class","taskWrapper"),p=tt.drawNode(d,e,n,o),u=p.height;s.debug("taskHeight after draw",u);const g=i-20-p.width;if(d.attr("transform",`translate(${g}, ${r})`),a=Math.max(a,u),h.events&&h.events.length>0){const e=r,a=i+50;ot(t,h.events,n,i,a,e,o)}r+=c,l&&!o.timeline?.disableMulticolor&&n++}},"drawTasks"),ot=t(function(t,e,n,i,r,a,o){let c=a;for(const l of e){const e={descr:l,section:n,number:n,width:300,padding:5,maxHeight:0};s.debug("eventNode",e);const a=t.append("g").attr("class","eventWrapper"),h=tt.drawNode(a,e,n,o).height;a.attr("transform",`translate(${r}, ${c})`);const d=c+h/2;t.append("g").attr("class","lineWrapper").append("line").attr("x1",i).attr("y1",d).attr("x2",r).attr("y2",d).attr("stroke-width",2).attr("stroke","black").attr("marker-end","url(#arrowhead)").attr("stroke-dasharray","5,5"),c=c+h+10}return c-a},"drawEvents"),ct={setConf:t(()=>{},"setConf"),draw:at},lt=t(t=>{const{theme:n}=e(),i=n?.includes("dark"),r=n?.includes("color"),a=t.svgId?.replace(/^#/,"")??"",s=a?`url(#${a}-drop-shadow)`:t.dropShadow??"none";let o="";for(let e=0;e<t.THEME_COLOR_LIMIT;e++){const n=""+(17-3*e),a=r?t.borderColorArray[e]:t.mainBkg,c=r?t.borderColorArray[e]:t.nodeBorder;o+=`\n .section-${e-1} rect,\n .section-${e-1} path,\n .section-${e-1} circle {\n fill: ${i&&r?t.mainBkg:a};\n stroke: ${c};\n stroke-width: ${t.strokeWidth};\n filter: ${s};\n }\n\n .section-${e-1} text {\n fill: ${t.nodeBorder};\n font-weight: ${t.fontWeight}\n }\n\n .node-icon-${e-1} {\n font-size: 40px;\n color: ${t["cScaleLabel"+e]};\n }\n\n .section-edge-${e-1} {\n stroke: ${t["cScale"+e]};\n }\n\n .edge-depth-${e-1} {\n stroke-width: ${n};\n }\n\n .section-${e-1} line {\n stroke: ${t["cScaleInv"+e]};\n stroke-width: 3;\n }\n\n .lineWrapper line {\n stroke: ${t.nodeBorder};\n stroke-width:${t.strokeWidth}\n }\n\n .disabled,\n .disabled circle,\n .disabled text {\n fill: ${t.tertiaryColor??"lightgray"};\n }\n\n .disabled text {\n fill: ${t.clusterBorder??"#efefef"};\n }\n `}return o},"genReduxSections"),ht=t(t=>{let e="";for(let a=0;a<t.THEME_COLOR_LIMIT;a++)t["lineColor"+a]=t["lineColor"+a]||t["cScaleInv"+a],n(t["lineColor"+a])?t["lineColor"+a]=i(t["lineColor"+a],20):t["lineColor"+a]=r(t["lineColor"+a],20);for(let n=0;n<t.THEME_COLOR_LIMIT;n++){const i=""+(17-3*n);e+=`\n .section-${n-1} rect, .section-${n-1} path, .section-${n-1} circle, .section-${n-1} path {\n fill: ${t["cScale"+n]};\n }\n .section-${n-1} text {\n fill: ${t["cScaleLabel"+n]};\n }\n .node-icon-${n-1} {\n font-size: 40px;\n color: ${t["cScaleLabel"+n]};\n }\n .section-edge-${n-1}{\n stroke: ${t["cScale"+n]};\n }\n .edge-depth-${n-1}{\n stroke-width: ${i};\n }\n .section-${n-1} line {\n stroke: ${t["cScaleInv"+n]} ;\n stroke-width: 3;\n }\n\n .lineWrapper line{\n stroke: ${t["cScaleLabel"+n]} ;\n }\n\n .disabled, .disabled circle, .disabled text {\n fill: ${t.tertiaryColor??"lightgray"};\n }\n .disabled text {\n fill: ${t.clusterBorder??"#efefef"};\n }\n `}return e},"genSections"),dt=t(t=>{const{theme:n}=e(),i=n?.includes("redux"),r="neutral"===n,a=t.svgId?.replace(/^#/,"")??"";let s="";if(t.useGradient&&a&&t.THEME_COLOR_LIMIT&&!r)for(let e=0;e<t.THEME_COLOR_LIMIT;e++)s+=`\n .section-${e-1}[data-look="neo"] rect,\n .section-${e-1}[data-look="neo"] path,\n .section-${e-1}[data-look="neo"] circle {\n fill: ${t.mainBkg};\n stroke: url(#${a}-gradient);\n stroke-width: 2;\n }\n .section-${e-1}[data-look="neo"] line {\n stroke: url(#${a}-gradient);\n stroke-width: 2;\n }`;return`\n .edge {\n stroke-width: 3;\n }\n ${i?lt(t):ht(t)}\n ${s}\n .section-root rect, .section-root path, .section-root circle {\n fill: ${t.git0};\n }\n .section-root text {\n fill: ${t.gitBranchLabel0};\n }\n .icon-container {\n height:100%;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .edge {\n fill: none;\n }\n .eventWrapper {\n filter: brightness(120%);\n }\n`},"getStyles"),pt={db:m,renderer:{setConf:t(()=>{},"setConf"),draw:t((t,e,n,i)=>"TD"===(i?.db?.getDirection?.()??"LR")?ct.draw(t,e,n,i):rt.draw(t,e,n,i),"draw")},parser:f,styles:dt};export{pt as diagram};
1
+ import{_ as t,z as e,a9 as n,aa as i,ab as r,c as a,l as s,F as o,a1 as c,ac as l,d as h,u as d,ad as p,q as u}from"./mermaid.core-Cqy39_Ub.js";import{d as g}from"./arc-CzrEQYq_.js";import"./index-DUrY8OKv.js";import"./RemoteLifeOSBlock-B5kU_35n.js";import"./index-D0cZ64pO.js";import"./index-D0cm1aa-.js";import"./file-editor-index-C6CU7Fik.js";import"./App-NMmWfGoY.js";import"./chevron-up-d3Fwun7t.js";import"./__vite-browser-external-2447137e-DZMxqW1v.js";import"./purify.es-BNLkGfTg.js";import"./marked.esm-BBjA1da9.js";var y=function(){var e=t(function(t,e,n,i){for(n=n||{},i=t.length;i--;n[t[i]]=e);return n},"o"),n=[6,11,13,14,15,17,19,20,23,24],i=[1,12],r=[1,13],a=[1,14],s=[1,15],o=[1,16],c=[1,19],l=[1,20],h={trace:t(function(){},"trace"),yy:{},symbols_:{error:2,start:3,timeline_header:4,document:5,EOF:6,timeline:7,timeline_lr:8,timeline_td:9,line:10,SPACE:11,statement:12,NEWLINE:13,title:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,period_statement:21,event_statement:22,period:23,event:24,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",7:"timeline",8:"timeline_lr",9:"timeline_td",11:"SPACE",13:"NEWLINE",14:"title",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",23:"period",24:"event"},productions_:[0,[3,3],[4,1],[4,1],[4,1],[5,0],[5,2],[10,2],[10,1],[10,1],[10,1],[12,1],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[21,1],[22,1]],performAction:t(function(t,e,n,i,r,a,s){var o=a.length-1;switch(r){case 1:return a[o-1];case 3:i.setDirection("LR");break;case 4:i.setDirection("TD");break;case 5:case 9:case 10:this.$=[];break;case 6:a[o-1].push(a[o]),this.$=a[o-1];break;case 7:case 8:this.$=a[o];break;case 11:i.getCommonDb().setDiagramTitle(a[o].substr(6)),this.$=a[o].substr(6);break;case 12:this.$=a[o].trim(),i.getCommonDb().setAccTitle(this.$);break;case 13:case 14:this.$=a[o].trim(),i.getCommonDb().setAccDescription(this.$);break;case 15:i.addSection(a[o].substr(8)),this.$=a[o].substr(8);break;case 18:i.addTask(a[o],0,""),this.$=a[o];break;case 19:i.addEvent(a[o].substr(2)),this.$=a[o]}},"anonymous"),table:[{3:1,4:2,7:[1,3],8:[1,4],9:[1,5]},{1:[3]},e(n,[2,5],{5:6}),e(n,[2,2]),e(n,[2,3]),e(n,[2,4]),{6:[1,7],10:8,11:[1,9],12:10,13:[1,11],14:i,15:r,17:a,19:s,20:o,21:17,22:18,23:c,24:l},e(n,[2,10],{1:[2,1]}),e(n,[2,6]),{12:21,14:i,15:r,17:a,19:s,20:o,21:17,22:18,23:c,24:l},e(n,[2,8]),e(n,[2,9]),e(n,[2,11]),{16:[1,22]},{18:[1,23]},e(n,[2,14]),e(n,[2,15]),e(n,[2,16]),e(n,[2,17]),e(n,[2,18]),e(n,[2,19]),e(n,[2,7]),e(n,[2,12]),e(n,[2,13])],defaultActions:{},parseError:t(function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t)},"parseError"),parse:t(function(e){var n=this,i=[0],r=[],a=[null],s=[],o=this.table,c="",l=0,h=0,d=s.slice.call(arguments,1),p=Object.create(this.lexer),u={yy:{}};for(var g in this.yy)Object.prototype.hasOwnProperty.call(this.yy,g)&&(u.yy[g]=this.yy[g]);p.setInput(e,u.yy),u.yy.lexer=p,u.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var y=p.yylloc;s.push(y);var f=p.options&&p.options.ranges;function m(){var t;return"number"!=typeof(t=r.pop()||p.lex()||1)&&(t instanceof Array&&(t=(r=t).pop()),t=n.symbols_[t]||t),t}"function"==typeof u.yy.parseError?this.parseError=u.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,t(function(t){i.length=i.length-2*t,a.length=a.length-t,s.length=s.length-t},"popStack"),t(m,"lex");for(var x,b,k,w,_,$,v,S,E={};;){if(b=i[i.length-1],this.defaultActions[b]?k=this.defaultActions[b]:(null==x&&(x=m()),k=o[b]&&o[b][x]),void 0===k||!k.length||!k[0]){var T;for(_ in S=[],o[b])this.terminals_[_]&&_>2&&S.push("'"+this.terminals_[_]+"'");T=p.showPosition?"Parse error on line "+(l+1)+":\n"+p.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[x]||x)+"'":"Parse error on line "+(l+1)+": Unexpected "+(1==x?"end of input":"'"+(this.terminals_[x]||x)+"'"),this.parseError(T,{text:p.match,token:this.terminals_[x]||x,line:p.yylineno,loc:y,expected:S})}if(k[0]instanceof Array&&k.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+x);switch(k[0]){case 1:i.push(x),a.push(p.yytext),s.push(p.yylloc),i.push(k[1]),x=null,h=p.yyleng,c=p.yytext,l=p.yylineno,y=p.yylloc;break;case 2:if($=this.productions_[k[1]][1],E.$=a[a.length-$],E._$={first_line:s[s.length-($||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-($||1)].first_column,last_column:s[s.length-1].last_column},f&&(E._$.range=[s[s.length-($||1)].range[0],s[s.length-1].range[1]]),void 0!==(w=this.performAction.apply(E,[c,h,l,u.yy,k[1],a,s].concat(d))))return w;$&&(i=i.slice(0,-1*$*2),a=a.slice(0,-1*$),s=s.slice(0,-1*$)),i.push(this.productions_[k[1]][0]),a.push(E.$),s.push(E._$),v=o[i[i.length-2]][i[i.length-1]],i.push(v);break;case 3:return!0}}return!0},"parse")},d=function(){return{EOF:1,parseError:t(function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},"parseError"),setInput:t(function(t,e){return this.yy=e||this.yy||{},this._input=t,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:t(function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.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),t},"input"),unput:t(function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var i=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 r=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===i.length?this.yylloc.first_column:0)+i[i.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},"unput"),more:t(function(){return this._more=!0,this},"more"),reject:t(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):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).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:t(function(t){this.unput(this.match.slice(t))},"less"),pastInput:t(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:t(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:t(function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},"showPosition"),test_match:t(function(t,e){var n,i,r;if(this.options.backtrack_lexer&&(r={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(r.yylloc.range=this.yylloc.range.slice(0))),(i=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in r)this[a]=r[a];return!1}return!1},"test_match"),next:t(function(){if(this.done)return this.EOF;var t,e,n,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var r=this._currentRules(),a=0;a<r.length;a++)if((n=this._input.match(this.rules[r[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,i=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,r[a])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,r[i]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:t(function(){return this.next()||this.lex()},"lex"),begin:t(function(t){this.conditionStack.push(t)},"begin"),popState:t(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:t(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:t(function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},"topState"),pushState:t(function(t){this.begin(t)},"pushState"),stateStackSize:t(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:t(function(t,e,n,i){switch(n){case 0:case 1:case 3:case 4:break;case 2:return 13;case 5:return 8;case 6:return 9;case 7:return 7;case 8:return 14;case 9:return this.begin("acc_title"),15;case 10:return this.popState(),"acc_title_value";case 11:return this.begin("acc_descr"),17;case 12:return this.popState(),"acc_descr_value";case 13:this.begin("acc_descr_multiline");break;case 14:this.popState();break;case 15:return"acc_descr_multiline_value";case 16:return 20;case 17:return 24;case 18:return 23;case 19:return 6;case 20:return"INVALID"}},"anonymous"),rules:[/^(?:%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:timeline[ \t]+LR\b)/i,/^(?:timeline[ \t]+TD\b)/i,/^(?:timeline\b)/i,/^(?:title\s[^\n]+)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:section\s[^:\n]+)/i,/^(?::\s(?:[^:\n]|:(?!\s))+)/i,/^(?:[^#:\n]+)/i,/^(?:$)/i,/^(?:.)/i],conditions:{acc_descr_multiline:{rules:[14,15],inclusive:!1},acc_descr:{rules:[12],inclusive:!1},acc_title:{rules:[10],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,11,13,16,17,18,19,20],inclusive:!0}}}}();function p(){this.yy={}}return h.lexer=d,t(p,"Parser"),p.prototype=h,h.Parser=p,new p}();y.parser=y;var f=y,m={};d(m,{addEvent:()=>C,addSection:()=>I,addTask:()=>L,addTaskOrg:()=>N,clear:()=>S,default:()=>j,getCommonDb:()=>v,getDirection:()=>T,getSections:()=>M,getTasks:()=>H,setDirection:()=>E});var x="",b=0,k="LR",w=[],_=[],$=[],v=t(()=>p,"getCommonDb"),S=t(function(){w.length=0,_.length=0,x="",$.length=0,k="LR",u()},"clear"),E=t(function(t){k=t},"setDirection"),T=t(function(){return k},"getDirection"),I=t(function(t){x=t,w.push(t)},"addSection"),M=t(function(){return w},"getSections"),H=t(function(){let t=D(),e=0;for(;!t&&e<100;)t=D(),e++;return _.push(...$),_},"getTasks"),L=t(function(t,e,n){const i={id:b++,section:x,type:x,task:t,score:e||0,events:n?[n]:[]};$.push(i)},"addTask"),C=t(function(t){$.find(t=>t.id===b-1).events.push(t)},"addEvent"),N=t(function(t){const e={section:x,type:x,description:t,task:t,classes:[]};_.push(e)},"addTaskOrg"),D=t(function(){const e=t(function(t){return $[t].processed},"compileTask");let n=!0;for(const[t,i]of $.entries())e(t),n=n&&i.processed;return n},"compileTasks"),j={clear:S,getCommonDb:v,getDirection:T,setDirection:E,addSection:I,getSections:M,getTasks:H,addTask:L,addTaskOrg:N,addEvent:C},O=0,A=t(function(t,e){const n=t.append("rect");return n.attr("x",e.x),n.attr("y",e.y),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("width",e.width),n.attr("height",e.height),n.attr("rx",e.rx),n.attr("ry",e.ry),void 0!==e.class&&n.attr("class",e.class),n},"drawRect"),R=t(function(e,n){const i=e.append("circle").attr("cx",n.cx).attr("cy",n.cy).attr("class","face").attr("r",15).attr("stroke-width",2).attr("overflow","visible"),r=e.append("g");function a(t){const e=g().startAngle(Math.PI/2).endAngle(Math.PI/2*3).innerRadius(7.5).outerRadius(15/2.2);t.append("path").attr("class","mouth").attr("d",e).attr("transform","translate("+n.cx+","+(n.cy+2)+")")}function s(t){const e=g().startAngle(3*Math.PI/2).endAngle(Math.PI/2*5).innerRadius(7.5).outerRadius(15/2.2);t.append("path").attr("class","mouth").attr("d",e).attr("transform","translate("+n.cx+","+(n.cy+7)+")")}function o(t){t.append("line").attr("class","mouth").attr("stroke",2).attr("x1",n.cx-5).attr("y1",n.cy+7).attr("x2",n.cx+5).attr("y2",n.cy+7).attr("class","mouth").attr("stroke-width","1px").attr("stroke","#666")}return r.append("circle").attr("cx",n.cx-5).attr("cy",n.cy-5).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),r.append("circle").attr("cx",n.cx+5).attr("cy",n.cy-5).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),t(a,"smile"),t(s,"sad"),t(o,"ambivalent"),n.score>3?a(r):n.score<3?s(r):o(r),i},"drawFace"),B=t(function(t,e){const n=t.append("circle");return n.attr("cx",e.cx),n.attr("cy",e.cy),n.attr("class","actor-"+e.pos),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("r",e.r),void 0!==n.class&&n.attr("class",n.class),void 0!==e.title&&n.append("title").text(e.title),n},"drawCircle"),P=t(function(t,e){const n=e.text.replace(/<br\s*\/?>/gi," "),i=t.append("text");i.attr("x",e.x),i.attr("y",e.y),i.attr("class","legend"),i.style("text-anchor",e.anchor),void 0!==e.class&&i.attr("class",e.class);const r=i.append("tspan");return r.attr("x",e.x+2*e.textMargin),r.text(n),i},"drawText"),W=t(function(e,n){function i(t,e,n,i,r){return t+","+e+" "+(t+n)+","+e+" "+(t+n)+","+(e+i-r)+" "+(t+n-1.2*r)+","+(e+i)+" "+t+","+(e+i)}t(i,"genPoints");const r=e.append("polygon");r.attr("points",i(n.x,n.y,50,20,7)),r.attr("class","labelBox"),n.y=n.y+n.labelMargin,n.x=n.x+.5*n.labelMargin,P(e,n)},"drawLabel"),F=t(function(t,e,n){const i=t.append("g"),r=U();r.x=e.x,r.y=e.y,r.fill=e.fill,r.width=n.width,r.height=n.height,r.class="journey-section section-type-"+e.num,r.rx=3,r.ry=3,A(i,r),Z(n)(e.text,i,r.x,r.y,r.width,r.height,{class:"journey-section section-type-"+e.num},n,e.colour)},"drawSection"),z=-1,V=t(function(t,e,n,i){const r=e.x+n.width/2,a=t.append("g");z++,a.append("line").attr("id",i+"-task"+z).attr("x1",r).attr("y1",e.y).attr("x2",r).attr("y2",450).attr("class","task-line").attr("stroke-width","1px").attr("stroke-dasharray","4 2").attr("stroke","#666"),R(a,{cx:r,cy:300+30*(5-e.score),score:e.score});const s=U();s.x=e.x,s.y=e.y,s.fill=e.fill,s.width=n.width,s.height=n.height,s.class="task task-type-"+e.num,s.rx=3,s.ry=3,A(a,s),Z(n)(e.task,a,s.x,s.y,s.width,s.height,{class:"task"},n,e.colour)},"drawTask"),G=t(function(t,e){A(t,{x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,class:"rect"}).lower()},"drawBackgroundRect"),q=t(function(){return{x:0,y:0,fill:void 0,"text-anchor":"start",width:100,height:100,textMargin:0,rx:0,ry:0}},"getTextObj"),U=t(function(){return{x:0,y:0,width:100,anchor:"start",height:100,rx:0,ry:0}},"getNoteRect"),Z=function(){function e(t,e,n,i,a,s,o,c){r(e.append("text").attr("x",n+a/2).attr("y",i+s/2+5).style("font-color",c).style("text-anchor","middle").text(t),o)}function n(t,e,n,i,a,s,o,c,l){const{taskFontSize:h,taskFontFamily:d}=c,p=t.split(/<br\s*\/?>/gi);for(let u=0;u<p.length;u++){const t=u*h-h*(p.length-1)/2,c=e.append("text").attr("x",n+a/2).attr("y",i).attr("fill",l).style("text-anchor","middle").style("font-size",h).style("font-family",d);c.append("tspan").attr("x",n+a/2).attr("dy",t).text(p[u]),c.attr("y",i+s/2).attr("dominant-baseline","central").attr("alignment-baseline","central"),r(c,o)}}function i(t,e,i,a,s,o,c,l){const h=e.append("switch"),d=h.append("foreignObject").attr("x",i).attr("y",a).attr("width",s).attr("height",o).attr("position","fixed").append("xhtml:div").style("display","table").style("height","100%").style("width","100%");d.append("div").attr("class","label").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(t),n(t,h,i,a,s,o,c,l),r(d,c)}function r(t,e){for(const n in e)n in e&&t.attr(n,e[n])}return t(e,"byText"),t(n,"byTspan"),t(i,"byFo"),t(r,"_setTextAttrs"),function(t){return"fo"===t.textPlacement?i:"old"===t.textPlacement?e:n}}(),Y=t(function(t,e){O=0,z=-1,t.append("defs").append("marker").attr("id",e+"-arrowhead").attr("refX",5).attr("refY",2).attr("markerWidth",6).attr("markerHeight",4).attr("orient","auto").append("path").attr("d","M 0,0 V 4 L6,2 Z")},"initGraphics");function K(t,e){t.each(function(){var t,n=h(this),i=n.text().split(/(\s+|<br>)/).reverse(),r=[],a=n.attr("y"),s=parseFloat(n.attr("dy")),o=n.text(null).append("tspan").attr("x",0).attr("y",a).attr("dy",s+"em");for(let c=0;c<i.length;c++)t=i[i.length-1-c],r.push(t),o.text(r.join(" ").trim()),(o.node().getComputedTextLength()>e||"<br>"===t)&&(r.pop(),o.text(r.join(" ").trim()),r="<br>"===t?[""]:[t],o=n.append("tspan").attr("x",0).attr("y",a).attr("dy","1.1em").text(t))})}t(K,"wrap");var Q=t(function(t,e,n,i,r,a=!1){const{theme:s,look:o}=i,c=s?.includes("redux"),l=n%(i?.themeVariables?.THEME_COLOR_LIMIT??12)-1,d=t.append("g");e.section=l,d.attr("class",(e.class?e.class+" ":"")+"timeline-node section-"+l);const p=d.append("g"),u=d.append("g"),g=u.append("text").text(e.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(K,e.width).node().getBBox(),y=i.fontSize?.replace?i.fontSize.replace("px",""):i.fontSize;if(e.height=g.height+1.1*y*.5+e.padding,e.height=Math.max(e.height,e.maxHeight),e.width=e.width+2*e.padding,u.attr("transform","translate("+e.width/2+", "+e.padding/2+")"),c&&u.attr("transform",`translate(${e.width/2}, ${a?e.padding/2+3:e.padding})`),J(p,e,l,r,i),"neo"===o&&(d.attr("data-look","neo"),c)){const e=s.includes("dark"),n=t.node()?.ownerSVGElement??t.node(),i=h(n),r=i.attr("id")??"",a=r?`${r}-drop-shadow`:"drop-shadow";if(i.select(`#${a}`).empty()){const t=i.select("defs");(t.empty()?i.append("defs"):t).append("filter").attr("id",a).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity",e?"0.2":"0.06").attr("flood-color",e?"#FFFFFF":"#000000")}}return e},"drawNode"),X=t(function(t,e,n){const i=t.append("g"),r=i.append("text").text(e.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(K,e.width).node().getBBox(),a=n.fontSize?.replace?n.fontSize.replace("px",""):n.fontSize;return i.remove(),r.height+1.1*a*.5+e.padding},"getVirtualNodeHeight"),J=t(function(t,e,n,i,r){const{theme:a}=r,s=a?.includes("redux")?0:5,o=s>0?`M0 ${e.height-5} v${10-e.height} q0,-${s},${s},-${s} h${e.width-10} q${s},0,${s},${s} v${e.height-5} H0 Z`:`M0 ${e.height-5} v${-(e.height-5)} h${e.width} v${e.height} H0 Z`;t.append("path").attr("id",i+"-node-"+O++).attr("class","node-bkg node-"+e.type).attr("d",o),a?.includes("redux")||t.append("line").attr("class","node-line-"+n).attr("x1",0).attr("y1",e.height).attr("x2",e.width).attr("y2",e.height)},"defaultBkg"),tt={drawRect:A,drawCircle:B,drawSection:F,drawText:P,drawLabel:W,drawTask:V,drawBackgroundRect:G,getTextObj:q,getNoteRect:U,initGraphics:Y,drawNode:Q,getVirtualNodeHeight:X},et=t(function(t,e,n,i){const r=a(),{look:o,theme:c,themeVariables:d}=r,{useGradient:p,gradientStart:u,gradientStop:g}=d,y=r.timeline?.leftMargin??50;s.debug("timeline",i.db);const f=r.securityLevel;let m;"sandbox"===f&&(m=h("#i"+e));const x=h("sandbox"===f?m.nodes()[0].contentDocument.body:"body").select("#"+e);x.append("g");const b=i.db.getTasks(),k=i.db.getCommonDb().getDiagramTitle();s.debug("task",b),tt.initGraphics(x,e);const w=i.db.getSections();s.debug("sections",w);let _=0,$=0,v=0,S=0,E=50+y,T=50;S=50;let I=0,M=!0;w.forEach(function(t){const e={number:I,descr:t,section:I,width:150,padding:20,maxHeight:_},n=tt.getVirtualNodeHeight(x,e,r);s.debug("sectionHeight before draw",n),_=Math.max(_,n+20)});let H=0,L=0;s.debug("tasks.length",b.length);for(const[a,l]of b.entries()){const t={number:a,descr:l,section:l.section,width:150,padding:20,maxHeight:$},e=tt.getVirtualNodeHeight(x,t,r);s.debug("taskHeight before draw",e),$=Math.max($,e+20),H=Math.max(H,l.events.length);let n=0;for(const i of l.events){const t={descr:i,section:l.section,number:l.section,width:150,padding:20,maxHeight:50};n+=tt.getVirtualNodeHeight(x,t,r)}l.events.length>0&&(n+=10*(l.events.length-1)),L=Math.max(L,n)}s.debug("maxSectionHeight before draw",_),s.debug("maxTaskHeight before draw",$),w&&w.length>0?w.forEach(t=>{const n=b.filter(e=>e.section===t),i={number:I,descr:t,section:I,width:200*Math.max(n.length,1)-50,padding:20,maxHeight:_};s.debug("sectionNode",i);const a=x.append("g"),o=tt.drawNode(a,i,I,r,e);s.debug("sectionNode output",o),a.attr("transform",`translate(${E}, 50)`),T+=_+50,n.length>0&&nt(x,n,I,E,T,$,r,H,L,_,!1,e),E+=200*Math.max(n.length,1),T=50,I++}):(M=!1,nt(x,b,I,E,T,$,r,H,L,_,!0,e));const C=x.node().getBBox();if(s.debug("bounds",C),k&&x.append("text").text(k).attr("x","neo"===o?2*C.x+y:C.width/2-y).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),v=M?_+$+150:$+100,x.append("g").attr("class","lineWrapper").append("line").attr("x1",y).attr("y1",v).attr("x2",C.width+3*y).attr("y2",v).attr("stroke-width",4).attr("stroke","black").attr("marker-end",`url(#${e}-arrowhead)`),"neo"===o&&p&&"neutral"!==c){const t=x.select("defs"),e=(t.empty()?x.append("defs"):t).append("linearGradient").attr("id",x.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");e.append("stop").attr("offset","0%").attr("stop-color",u).attr("stop-opacity",1),e.append("stop").attr("offset","100%").attr("stop-color",g).attr("stop-opacity",1)}l(void 0,x,r.timeline?.padding??50,r.timeline?.useMaxWidth??!1)},"draw"),nt=t(function(t,e,n,i,r,a,o,c,l,h,d,p){for(const u of e){const e={descr:u.task,section:n,number:n,width:150,padding:20,maxHeight:a};s.debug("taskNode",e);const c=t.append("g").attr("class","taskWrapper"),h=tt.drawNode(c,e,n,o,p).height;if(s.debug("taskHeight after draw",h),c.attr("transform",`translate(${i}, ${r})`),a=Math.max(a,h),u.events){const e=t.append("g").attr("class","lineWrapper");let s=a;r+=100,s+=it(t,u.events,n,i,r,o,p),r-=100,e.append("line").attr("x1",i+95).attr("y1",r+a).attr("x2",i+95).attr("y2",r+a+100+l+100).attr("stroke-width",2).attr("stroke","black").attr("marker-end",`url(#${p}-arrowhead)`).attr("stroke-dasharray","5,5")}i+=200,d&&!o.timeline?.disableMulticolor&&n++}r-=10},"drawTasks"),it=t(function(t,e,n,i,r,a,o){let c=0;const l=r;r+=100;for(const h of e){const e={descr:h,section:n,number:n,width:150,padding:20,maxHeight:50};s.debug("eventNode",e);const l=t.append("g").attr("class","eventWrapper"),d=tt.drawNode(l,e,n,a,o,!0).height;c+=d,l.attr("transform",`translate(${i}, ${r})`),r=r+10+d}return r=l,c},"drawEvents"),rt={setConf:t(()=>{},"setConf"),draw:et},at=t(function(t,e,n,i){const r=a(),h=r.timeline?.leftMargin??50;s.debug("timeline",i.db);const d=o(e);d.append("g");const p=i.db.getTasks(),u=i.db.getCommonDb().getDiagramTitle();s.debug("task",p),tt.initGraphics(d);const g=i.db.getSections();s.debug("sections",g);let y=0,f=0;const m=50+h;let x=50;const b=x,k=m+230;let w=0;const _=g&&g.length>0,$=_?k:m+230,v=Math.max(50,580);g.forEach(function(t){const e={number:w,descr:t,section:w,width:v,padding:5,maxHeight:y},n=tt.getVirtualNodeHeight(d,e,r);s.debug("sectionHeight before draw",n),y=Math.max(y,n)});let S=0;s.debug("tasks.length",p.length);for(const[a,o]of p.entries()){const t={number:a,descr:o,section:o.section,width:200,padding:5,maxHeight:f},e=tt.getVirtualNodeHeight(d,t,r);s.debug("taskHeight before draw",e),f=Math.max(f,e);let n=0;for(const i of o.events){const t={descr:i,section:o.section,number:o.section,width:300,padding:5,maxHeight:50};n+=tt.getVirtualNodeHeight(d,t,r)}o.events.length>0&&(n+=10*(o.events.length-1)),S=Math.max(S,n)+0}s.debug("maxSectionHeight before draw",y),s.debug("maxTaskHeight before draw",f);const E=Math.max(f,S)+30;_?g.forEach(t=>{const e=p.filter(e=>e.section===t),n={number:w,descr:t,section:w,width:v,padding:5,maxHeight:y};s.debug("sectionNode",n);const i=d.append("g"),a=tt.drawNode(i,n,w,r);s.debug("sectionNode output",a);const o=$-230;i.attr("transform",`translate(${o}, ${x})`);const c=x+a.height+20;e.length>0&&st(d,e,w,$,c,f,r,E,!1);const l=e.length,h=a.height+20+E*Math.max(l,1)-(l>0?60:0);x+=h,w++}):st(d,p,w,$,x,f,r,E,!0);let T=d.node()?.getBBox();if(!T)throw new Error("bbox not found");if(s.debug("bounds",T),u){if(d.append("text").text(u).attr("x",T.width/2-h).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),T=d.node()?.getBBox(),!T)throw new Error("bbox not found");s.debug("bounds after title",T)}const[I]=c(r.fontSize),M=2*(I??16),H=.5*(I??16)+20,L=d.append("g").attr("class","lineWrapper");L.append("line").attr("x1",$).attr("y1",b-M).attr("x2",$).attr("y2",T.y+T.height+H).attr("stroke-width",4).attr("stroke","black").attr("marker-end","url(#arrowhead)"),L.lower(),l(void 0,d,r.timeline?.padding??50,r.timeline?.useMaxWidth??!1)},"draw"),st=t(function(t,e,n,i,r,a,o,c,l){for(const h of e){const e={descr:h.task,section:n,number:n,width:200,padding:5,maxHeight:a};s.debug("taskNode",e);const d=t.append("g").attr("class","taskWrapper"),p=tt.drawNode(d,e,n,o),u=p.height;s.debug("taskHeight after draw",u);const g=i-20-p.width;if(d.attr("transform",`translate(${g}, ${r})`),a=Math.max(a,u),h.events&&h.events.length>0){const e=r,a=i+50;ot(t,h.events,n,i,a,e,o)}r+=c,l&&!o.timeline?.disableMulticolor&&n++}},"drawTasks"),ot=t(function(t,e,n,i,r,a,o){let c=a;for(const l of e){const e={descr:l,section:n,number:n,width:300,padding:5,maxHeight:0};s.debug("eventNode",e);const a=t.append("g").attr("class","eventWrapper"),h=tt.drawNode(a,e,n,o).height;a.attr("transform",`translate(${r}, ${c})`);const d=c+h/2;t.append("g").attr("class","lineWrapper").append("line").attr("x1",i).attr("y1",d).attr("x2",r).attr("y2",d).attr("stroke-width",2).attr("stroke","black").attr("marker-end","url(#arrowhead)").attr("stroke-dasharray","5,5"),c=c+h+10}return c-a},"drawEvents"),ct={setConf:t(()=>{},"setConf"),draw:at},lt=t(t=>{const{theme:n}=e(),i=n?.includes("dark"),r=n?.includes("color"),a=t.svgId?.replace(/^#/,"")??"",s=a?`url(#${a}-drop-shadow)`:t.dropShadow??"none";let o="";for(let e=0;e<t.THEME_COLOR_LIMIT;e++){const n=""+(17-3*e),a=r?t.borderColorArray[e]:t.mainBkg,c=r?t.borderColorArray[e]:t.nodeBorder;o+=`\n .section-${e-1} rect,\n .section-${e-1} path,\n .section-${e-1} circle {\n fill: ${i&&r?t.mainBkg:a};\n stroke: ${c};\n stroke-width: ${t.strokeWidth};\n filter: ${s};\n }\n\n .section-${e-1} text {\n fill: ${t.nodeBorder};\n font-weight: ${t.fontWeight}\n }\n\n .node-icon-${e-1} {\n font-size: 40px;\n color: ${t["cScaleLabel"+e]};\n }\n\n .section-edge-${e-1} {\n stroke: ${t["cScale"+e]};\n }\n\n .edge-depth-${e-1} {\n stroke-width: ${n};\n }\n\n .section-${e-1} line {\n stroke: ${t["cScaleInv"+e]};\n stroke-width: 3;\n }\n\n .lineWrapper line {\n stroke: ${t.nodeBorder};\n stroke-width:${t.strokeWidth}\n }\n\n .disabled,\n .disabled circle,\n .disabled text {\n fill: ${t.tertiaryColor??"lightgray"};\n }\n\n .disabled text {\n fill: ${t.clusterBorder??"#efefef"};\n }\n `}return o},"genReduxSections"),ht=t(t=>{let e="";for(let a=0;a<t.THEME_COLOR_LIMIT;a++)t["lineColor"+a]=t["lineColor"+a]||t["cScaleInv"+a],n(t["lineColor"+a])?t["lineColor"+a]=i(t["lineColor"+a],20):t["lineColor"+a]=r(t["lineColor"+a],20);for(let n=0;n<t.THEME_COLOR_LIMIT;n++){const i=""+(17-3*n);e+=`\n .section-${n-1} rect, .section-${n-1} path, .section-${n-1} circle, .section-${n-1} path {\n fill: ${t["cScale"+n]};\n }\n .section-${n-1} text {\n fill: ${t["cScaleLabel"+n]};\n }\n .node-icon-${n-1} {\n font-size: 40px;\n color: ${t["cScaleLabel"+n]};\n }\n .section-edge-${n-1}{\n stroke: ${t["cScale"+n]};\n }\n .edge-depth-${n-1}{\n stroke-width: ${i};\n }\n .section-${n-1} line {\n stroke: ${t["cScaleInv"+n]} ;\n stroke-width: 3;\n }\n\n .lineWrapper line{\n stroke: ${t["cScaleLabel"+n]} ;\n }\n\n .disabled, .disabled circle, .disabled text {\n fill: ${t.tertiaryColor??"lightgray"};\n }\n .disabled text {\n fill: ${t.clusterBorder??"#efefef"};\n }\n `}return e},"genSections"),dt=t(t=>{const{theme:n}=e(),i=n?.includes("redux"),r="neutral"===n,a=t.svgId?.replace(/^#/,"")??"";let s="";if(t.useGradient&&a&&t.THEME_COLOR_LIMIT&&!r)for(let e=0;e<t.THEME_COLOR_LIMIT;e++)s+=`\n .section-${e-1}[data-look="neo"] rect,\n .section-${e-1}[data-look="neo"] path,\n .section-${e-1}[data-look="neo"] circle {\n fill: ${t.mainBkg};\n stroke: url(#${a}-gradient);\n stroke-width: 2;\n }\n .section-${e-1}[data-look="neo"] line {\n stroke: url(#${a}-gradient);\n stroke-width: 2;\n }`;return`\n .edge {\n stroke-width: 3;\n }\n ${i?lt(t):ht(t)}\n ${s}\n .section-root rect, .section-root path, .section-root circle {\n fill: ${t.git0};\n }\n .section-root text {\n fill: ${t.gitBranchLabel0};\n }\n .icon-container {\n height:100%;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .edge {\n fill: none;\n }\n .eventWrapper {\n filter: brightness(120%);\n }\n`},"getStyles"),pt={db:m,renderer:{setConf:t(()=>{},"setConf"),draw:t((t,e,n,i)=>"TD"===(i?.db?.getDirection?.()??"LR")?ct.draw(t,e,n,i):rt.draw(t,e,n,i),"draw")},parser:f,styles:dt};export{pt as diagram};
@@ -1 +1 @@
1
- .composer .composer-attachments{flex-direction:column;align-items:stretch;gap:8px;width:100%;display:flex}.composer-attachment-images{flex-wrap:wrap;justify-content:flex-start;gap:10px;display:flex}.composer-attachment-card{width:96px;height:76px;position:relative}.composer-image-card .message-image-preview{width:100%;height:100%;margin:0}.composer-image-card .message-image-preview img{object-fit:contain;width:100%;height:100%}.composer-image-card .message-image-placeholder{overflow-wrap:anywhere;min-width:0;max-width:100%;padding:8px;font-size:11px}.composer-image-remove{border:1px solid var(--border-strong);background:var(--card);width:22px;height:22px;color:var(--text);cursor:pointer;border-radius:50%;place-items:center;padding:0;display:grid;position:absolute;top:4px;right:4px}.composer-image-remove:hover{background:var(--card-alt)}.composer-image-remove svg{width:14px;height:14px}.composer-attachment-card button:focus-visible{outline:2px solid var(--accent-foreground);outline-offset:2px}.composer-file-preview{border:1px solid var(--border);background:var(--card-alt);width:100%;height:100%;color:var(--text-secondary);cursor:pointer;border-radius:8px;flex-direction:column;justify-content:center;align-items:center;gap:3px;padding:8px;display:flex}.composer-file-preview>svg{flex-shrink:0;width:20px;height:20px}.composer-file-preview>span{text-overflow:ellipsis;white-space:nowrap;width:100%;font-size:11px;line-height:1.2;overflow:hidden}.composer-file-preview>small{font-size:10px;line-height:1.2}.submit-button-group{flex-shrink:0;align-items:center;gap:4px;display:inline-flex}.submit-button-group .submit-shortcut-toggle{width:32px;height:32px;color:var(--text-muted);cursor:pointer;background:0 0;border:0;border-radius:7px;justify-content:center;align-items:center;gap:1px;padding:4px;display:inline-flex;position:relative}.submit-shortcut-toggle>svg{width:15px;height:15px}.submit-button-group .submit-shortcut-toggle:hover,.submit-button-group .submit-shortcut-toggle:focus-visible{background:color-mix(in srgb, var(--text) 8%, transparent);color:var(--text)}.submit-shortcut-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.submit-shortcut-tooltip{z-index:20;border:1px solid var(--border);background:var(--bg);width:max-content;max-width:min(340px,75vw);color:var(--text);text-align:left;pointer-events:none;visibility:hidden;border-radius:8px;padding:8px 10px;font-size:12px;line-height:1.5;position:absolute;bottom:calc(100% + 8px);right:0}.submit-shortcut-toggle:hover .submit-shortcut-tooltip,.submit-shortcut-toggle:focus-visible .submit-shortcut-tooltip{visibility:visible}.submit-button-group>.submit-action-button{background:var(--text);width:30px;min-width:30px;height:30px;min-height:30px;color:var(--bg);box-shadow:none;border:0;border-radius:50%;flex:none;justify-content:center;align-items:center;padding:7px;display:inline-flex}.submit-button-group>.submit-action-button:hover:not(:disabled){background:color-mix(in srgb, var(--text) 85%, var(--bg))}.submit-button-group>.submit-action-button:disabled{background:var(--sidebar-selection);color:var(--text-muted);opacity:.6}.submit-button-group>.submit-action-button>svg{width:16px;height:16px}.submit-button-group .submit-shortcut-toggle[aria-pressed=true]{background:color-mix(in srgb, var(--text) 8%, transparent);color:var(--text)}.composer .composer-toolbar{flex-wrap:nowrap}.composer-scroll-controls{align-items:center;gap:var(--space-2);overscroll-behavior-x:contain;scrollbar-width:thin;flex:auto;min-width:0;padding-block:3px;display:flex;overflow-x:auto}.composer-scroll-controls .composer-leading-controls,.composer-scroll-controls .composer-control-strip{flex-wrap:nowrap;flex:none;order:0}.composer-scroll-controls .composer-menu{flex-shrink:0}.composer .composer-toolbar>.submit-button-group{flex-shrink:0;order:0}.composer-option-popover.portal{z-index:1100;margin:0;position:fixed;bottom:auto;right:auto;overflow-y:auto}.composer .quick-replies-toggle.selected{background:color-mix(in srgb, var(--accent-action) 7%, transparent);color:var(--accent-action);box-shadow:none}.composer .quick-replies-toggle:hover:not(:disabled){background:color-mix(in srgb, var(--accent-action) 11%, transparent)}.composer-model-trigger>button{max-width:100%}.composer-model-trigger>button>span{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.composer-fast-indicator{color:var(--warning,#b45309);white-space:nowrap;align-items:center;gap:4px;font-size:12px;display:inline-flex}.composer-fast-indicator svg{width:16px;height:16px}.composer-settings-popover{z-index:1100;border:1px solid var(--border);background:var(--panel,var(--bg));width:min(340px,100vw - 32px);color:var(--text);border-radius:16px;padding:12px;position:fixed;overflow-y:auto;box-shadow:0 12px 40px #0002}.composer-model-settings{flex-direction:column;gap:12px;font-size:13px;display:flex}.composer-model-settings .composer-option-button{justify-content:space-between;width:100%}.composer-model-settings .composer-option-popover{width:100%;min-width:0;max-height:180px;box-shadow:none;margin-top:6px;position:relative;inset:auto;overflow-y:auto}.composer-effort-options{flex-wrap:wrap;gap:6px;display:flex}.composer-effort-options button{border:1px solid var(--border);color:var(--text);background:0 0;border-radius:8px;padding:7px 10px}.composer-effort-options button[aria-pressed=true]{background:var(--control-fill);border-color:var(--accent-action)}.composer-fast-switch{border:0;border-top:1px solid var(--border);color:var(--text);text-align:left;background:0 0;align-items:center;gap:10px;padding:12px 0 0;display:flex}.composer-fast-switch>svg{width:18px;height:18px}.composer-fast-switch>span:nth-child(2){flex:1;gap:4px;display:grid}.composer-fast-switch small{color:var(--muted)}.composer-switch-track{background:var(--border);border-radius:20px;width:32px;height:20px;padding:3px}.composer-switch-track>span{background:var(--text);border-radius:50%;width:14px;height:14px;transition:transform .12s;display:block}.composer-fast-switch[aria-checked=true] .composer-switch-track{background:var(--control-fill);outline:1px solid var(--accent-action)}.composer-fast-switch[aria-checked=true] .composer-switch-track>span{background:var(--accent-action);transform:translate(12px)}.composer-settings-popover button:focus-visible{outline:2px solid var(--accent-action);outline-offset:2px}
1
+ .composer .composer-attachments{flex-direction:column;align-items:stretch;gap:8px;width:100%;display:flex}.composer-attachment-images{flex-wrap:wrap;justify-content:flex-start;gap:10px;display:flex}.composer-attachment-card{width:96px;height:76px;position:relative}.composer-image-card .message-image-preview{width:100%;height:100%;margin:0}.composer-image-card .message-image-preview img{object-fit:contain;width:100%;height:100%}.composer-image-card .message-image-placeholder{overflow-wrap:anywhere;min-width:0;max-width:100%;padding:8px;font-size:11px}.composer-image-remove{border:1px solid var(--border-strong);background:var(--card);width:22px;height:22px;color:var(--text);cursor:pointer;border-radius:50%;place-items:center;padding:0;display:grid;position:absolute;top:4px;right:4px}.composer-image-remove:hover{background:var(--card-alt)}.composer-image-remove svg{width:14px;height:14px}.composer-attachment-card button:focus-visible{outline:2px solid var(--accent-foreground);outline-offset:2px}.composer-file-preview{border:1px solid var(--border);background:var(--card-alt);width:100%;height:100%;color:var(--text-secondary);cursor:pointer;border-radius:8px;flex-direction:column;justify-content:center;align-items:center;gap:3px;padding:8px;display:flex}.composer-file-preview>svg{flex-shrink:0;width:20px;height:20px}.composer-file-preview>span{text-overflow:ellipsis;white-space:nowrap;width:100%;font-size:11px;line-height:1.2;overflow:hidden}.composer-file-preview>small{font-size:10px;line-height:1.2}.submit-button-group{flex-shrink:0;align-items:center;gap:4px;display:inline-flex}.submit-button-group .submit-shortcut-toggle{width:32px;height:32px;color:var(--text-muted);cursor:pointer;background:0 0;border:0;border-radius:7px;justify-content:center;align-items:center;gap:1px;padding:4px;display:inline-flex;position:relative}.submit-shortcut-toggle>svg{width:15px;height:15px}.submit-button-group .submit-shortcut-toggle:hover,.submit-button-group .submit-shortcut-toggle:focus-visible{background:color-mix(in srgb, var(--text) 8%, transparent);color:var(--text)}.submit-shortcut-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.submit-shortcut-tooltip{z-index:20;border:1px solid var(--border);background:var(--bg);width:max-content;max-width:min(340px,75vw);color:var(--text);text-align:left;pointer-events:none;visibility:hidden;border-radius:8px;padding:8px 10px;font-size:12px;line-height:1.5;position:absolute;bottom:calc(100% + 8px);right:0}.submit-shortcut-toggle:hover .submit-shortcut-tooltip,.submit-shortcut-toggle:focus-visible .submit-shortcut-tooltip{visibility:visible}.submit-button-group>.submit-action-button{background:var(--text);width:30px;min-width:30px;height:30px;min-height:30px;color:var(--bg);box-shadow:none;border:0;border-radius:50%;flex:none;justify-content:center;align-items:center;padding:7px;display:inline-flex}.submit-button-group>.submit-action-button:hover:not(:disabled){background:color-mix(in srgb, var(--text) 85%, var(--bg))}.submit-button-group>.submit-action-button:disabled{background:var(--sidebar-selection);color:var(--text-muted);opacity:.6}.submit-button-group>.submit-action-button>svg{width:16px;height:16px}.submit-button-group .submit-shortcut-toggle[aria-pressed=true]{background:color-mix(in srgb, var(--text) 8%, transparent);color:var(--text)}.composer .composer-toolbar{flex-wrap:nowrap}.composer-scroll-controls{align-items:center;gap:var(--space-2);overscroll-behavior-x:contain;scrollbar-width:thin;flex:auto;min-width:0;padding-block:3px;display:flex;overflow-x:auto}.composer-scroll-controls .composer-leading-controls,.composer-scroll-controls .composer-control-strip{flex-wrap:nowrap;flex:none;order:0}.composer-scroll-controls .composer-menu{flex-shrink:0}.composer .composer-toolbar>.submit-button-group{flex-shrink:0;order:0}.composer-option-popover.portal{z-index:1100;margin:0;position:fixed;bottom:auto;right:auto;overflow-y:auto}.composer .quick-replies-toggle.selected{background:color-mix(in srgb, var(--accent-action) 7%, transparent);color:var(--accent-action);box-shadow:none}.composer .quick-replies-toggle:hover:not(:disabled){background:color-mix(in srgb, var(--accent-action) 11%, transparent)}.composer-model-trigger>button{max-width:100%}.composer-model-trigger>button>span{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.composer-fast-indicator{color:var(--warning,#b45309);white-space:nowrap;align-items:center;gap:4px;font-size:12px;display:inline-flex}.composer-fast-indicator svg{width:16px;height:16px}.composer-settings-popover{z-index:1100;border:1px solid var(--border);background:var(--panel,var(--bg));width:min(340px,100vw - 32px);color:var(--text);border-radius:16px;padding:12px;position:fixed;overflow-y:auto;box-shadow:0 12px 40px #0002}.composer-model-settings{flex-direction:column;gap:12px;font-size:13px;display:flex}.composer-model-settings .composer-option-button{justify-content:space-between;width:100%}.composer-model-settings .composer-option-popover{width:100%;min-width:0;max-height:180px;box-shadow:none;margin-top:6px;position:relative;inset:auto;overflow-y:auto}.composer-effort-options{flex-wrap:wrap;gap:6px;display:flex}.composer-effort-options button{border:1px solid var(--border);color:var(--text);background:0 0;border-radius:8px;padding:7px 10px}.composer-effort-options button[aria-pressed=true]{background:var(--control-fill);border-color:var(--accent-action)}.composer-fast-switch{border:0;border-top:1px solid var(--border);color:var(--text);text-align:left;background:0 0;align-items:center;gap:10px;padding:12px 0 0;display:flex}.composer-fast-switch>svg{width:18px;height:18px}.composer-fast-switch>span:nth-child(2){flex:1;gap:4px;display:grid}.composer-fast-switch small{color:var(--muted)}.composer-switch-track{background:var(--border);border-radius:20px;width:32px;height:20px;padding:3px}.composer-switch-track>span{background:var(--text);border-radius:50%;width:14px;height:14px;transition:transform .12s;display:block}.composer-fast-switch[aria-checked=true] .composer-switch-track{background:var(--control-fill);outline:1px solid var(--accent-action)}.composer-fast-switch[aria-checked=true] .composer-switch-track>span{background:var(--accent-action);transform:translate(12px)}.composer-settings-popover button:focus-visible{outline:2px solid var(--accent-action);outline-offset:2px}.composer:has(.desktop-composer-toolbar){border-radius:20px}.composer .desktop-composer-toolbar{flex-wrap:nowrap;align-items:center;gap:8px;display:flex}.desktop-composer-toolbar>*{flex-shrink:0}.desktop-composer-toolbar .composer-toolbar-spacer{flex:8px}.desktop-composer-toolbar .composer-model-trigger{flex:0 auto;min-width:0}.composer-tools-trigger>button{padding:8px}.composer-permission.full-access .composer-option-button{color:var(--warning,#b45309)}.composer-tools-list{gap:4px;display:grid}.composer-tools-list button{color:var(--text);text-align:left;background:0 0;border:0;border-radius:8px;align-items:center;gap:10px;padding:10px;display:flex}.composer-tools-list button:hover:not(:disabled){background:var(--control-hover)}.composer-tools-list button:disabled{color:var(--muted);cursor:not-allowed}.composer-tools-list svg{width:18px;height:18px}.composer-tools-list kbd{color:var(--muted);margin-left:auto}
@@ -0,0 +1 @@
1
+ import{c as e,r as t,j as a,u as n,f as o}from"./index-DUrY8OKv.js";import{N as s,M as l,f as r,U as i,X as c,D as d,P as u,W as p,b as m,S as h,Y as f,_ as b,$ as v}from"./App-NMmWfGoY.js";import{i as g}from"./useMessageImage-CNR1wZjv.js";import{M as x}from"./MessageImage-BNOsxgJR.js";import{S as y}from"./shield-check-BIUOkwl_.js";import{Z as k,C as j}from"./zap-CIk2VoXi.js";import{u as M,C as w,a as C,S as $}from"./ComposerMenus-DzcPREkw.js";const N=e("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),S=e("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]),E=e("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),D=e("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),A=e("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);function I(e,a,n,o,s,l,r){const i=JSON.stringify([a,n,o,s]),[c,d]=t.useState(null);if(t.useEffect(()=>{if("codex"!==a||!e)return;let t,s=!1,l=0,r=0,c=!1,u=!1;const p=()=>{s||u||c||void 0!==t||r>=5||(t=setTimeout(b,1e3*2**Math.max(0,r-1)))},m=t=>{u=Boolean(t?.defaultModel),d({client:e,key:i,state:t,loading:!u&&r<5})};d({client:e,key:i,state:null,loading:!0});const h=e.onMessage(e=>{s||"session.model"!==e.type||e.sessionId!==o||(l++,clearTimeout(t),t=void 0,m(e),p())}),f=e.onClose(()=>{s=!0,clearTimeout(t),d({client:e,key:i,state:null,loading:!1})});async function b(){if(t=void 0,s||!e)return;c=!0,r++;const a=l;try{const t=await e.request({action:"model.status",id:e.makeId("model-status"),...o?{sessionId:o}:{cwd:n}},{timeoutMs:15e3});s||l!==a||m(t)}catch{s||l!==a||m(null)}finally{c=!1,p()}}return t=setTimeout(b,200),()=>{s=!0,clearTimeout(t),h(),f()}},[e,a,n,o,s,i]),"codex"!==a)return l;const u=c&&c.client===e&&c.key===i?c:null,p={value:"",label:`CLI · ${u?.state?.defaultModel||(!e||u&&!u.loading?r.unknown:r.remoteModelChecking)}`,desc:"config"===u?.state?.defaultSource?r.remoteModelConfig:"recommended"===u?.state?.defaultSource?r.remoteModelRecommended:r.unknown};return l.some(e=>""===e.value)?l.map(e=>""===e.value?{...e,...p}:e):[p,...l]}function K(e,t,a=s()){return!t.altKey&&(t.metaKey||t.ctrlKey?l(t,a):"enter"===e?!t.shiftKey:"shiftEnter"===e&&t.shiftKey)}function R({attachments:e,uploadBusy:t,onRemove:n,onOpen:o,t:s}){if(!e.length&&!t)return null;const l=e.filter(e=>e.type.startsWith("image/")||g(e.path)||g(e.name)),d=()=>l.map(e=>({src:e.path,alt:e.name||r(e.path)}));return a.jsxs("div",{className:"attachment-row composer-attachments",children:[e.length>0&&a.jsx("div",{className:"composer-attachment-images",children:e.map(e=>{const t=e.name||r(e.path),u=l.includes(e);return a.jsxs("div",{className:"composer-attachment-card "+(u?"composer-image-card":"composer-file-card"),children:[u?a.jsx(x,{src:e.path,alt:t,onOpen:o,gallery:d}):a.jsxs("button",{className:"composer-file-preview",type:"button",title:`${t} · ${i(e.size)}`,"aria-label":`${s.preview}: ${t}`,onClick:()=>o(e.path),children:[a.jsx(D,{"aria-hidden":"true"}),a.jsx("span",{children:t}),a.jsx("small",{children:i(e.size)})]}),a.jsx("button",{className:"composer-image-remove",type:"button",title:`${s.removeAttachment}: ${t}`,"aria-label":`${s.removeAttachment}: ${t}`,onClick:()=>n(e.path),children:a.jsx(c,{"aria-hidden":"true"})})]},e.path)})}),t&&a.jsxs("span",{className:"attachment-empty",role:"status",children:[a.jsx("span",{className:"loading-spinner small","aria-hidden":"true"}),s.uploading]})]})}function L({shortcut:e,onChange:t,action:n,t:o}){const s="New session"!==o.newSession,l="傳送快捷鍵"===o.sendShortcut,r="enter"===e?"Enter":"shiftEnter"===e?"Shift+Enter":d("mod+enter"),i="enter"===e?"shiftEnter":"enter",c="enter"===i?"Enter":"Shift+Enter",u="create"===n?s?"建立":"create":s?o.send:"send",p="create"===n&&s&&!l?"创建":u,m="enter"===e?"Shift+Enter":"Enter",h=s?`${r} ${p};${m} ${l?"換行":"换行"}。${l?"點擊切換為":"点击切换为"} ${c} ${p}`:`${r} to ${u}; ${m} for a newline. Click to switch to ${c} to ${u}`;return a.jsxs("button",{type:"button",className:"submit-shortcut-toggle","data-shortcut":e,"aria-label":h,"aria-pressed":"enter"!==e,onMouseDown:e=>e.preventDefault(),onClick:()=>t(i),children:[a.jsx(E,{"aria-hidden":"true"}),a.jsx("span",{className:"submit-shortcut-tooltip","aria-hidden":"true",children:h})]})}function F({leading:e,controls:t,submit:n}){return a.jsxs("div",{className:"composer-toolbar",children:[a.jsxs("div",{className:"composer-scroll-controls",children:[a.jsx("div",{className:"composer-leading-controls",children:e}),a.jsx("div",{className:"composer-control-strip",children:t})]}),n]})}function O({label:e,disabled:t,onClick:n}){return a.jsx("button",{type:"button",className:"icon-button",title:e,"aria-label":e,disabled:t,onClick:n,children:a.jsx(u,{"aria-hidden":"true"})})}function P({children:e,...t}){return a.jsx("button",{...t,className:"send-button submit-action-button",children:e})}function z({value:e,textareaRef:n,onValueChange:o,onKeyDown:s,autoFocus:l,disabled:r,...i}){const c=t.useRef(!1),d=t.useRef(!1);t.useEffect(()=>{if(!l||r||d.current)return;let e=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>{const e=n.current;if(!e)return;d.current=!0;const t=document.activeElement;t&&t!==document.body&&t!==e||(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length),d.current=!0)})});return()=>cancelAnimationFrame(e)},[l,r,n]);const u=t.useMemo(()=>function(e){let t=0;for(let a=0;a<e.length;a++){const n=e.charCodeAt(a);if(t=n>32&&n<127?t+1:0,t>=4096)return"off"}return"soft"}(e),[e]);return t.useLayoutEffect(()=>{const t=n.current;t&&!c.current&&t.value!==e&&(t.value=e)},[e,n]),a.jsx("textarea",{...i,ref:n,disabled:r,wrap:c.current?n.current?.wrap:u,onCompositionStart:()=>{c.current=!0},onCompositionEnd:e=>{c.current=!1,o(e.currentTarget.value)},onChange:e=>o(e.currentTarget.value),onKeyDown:e=>{c.current||e.nativeEvent.isComposing||229===e.nativeEvent.keyCode||s?.(e)}})}function q(e,t){const a=e.map(e=>({value:e.value,label:e.label,description:e.desc,icon:j}));return a.some(e=>""===e.value)||a.unshift({value:"",label:t.defaultOption,description:t.useDaemonDefaultModel,icon:j}),a}function T(e){return[{value:"normal",label:e.approvalNormal,description:e.approvalNormalDescription,icon:y},{value:"plan",label:e.approvalPlan,description:e.approvalPlanDescription,icon:p},{value:"acceptEdits",label:e.approvalEdits,description:e.approvalEditsDescription,icon:N},{value:"autoApprove",label:e.approvalAuto,description:e.approvalAutoDescription,icon:k}]}function H(e){return[{value:"",label:e.effort,description:e.useDaemonDefault,icon:S},{value:"minimal",label:e.effortMinimal,icon:S},{value:"low",label:e.effortLow,icon:S},{value:"medium",label:e.effortMedium,icon:S},{value:"high",label:e.effortHigh,icon:S},{value:"xhigh",label:e.effortXHigh,icon:S},{value:"max",label:e.effortMax,icon:S},{value:"ultra",label:e.effortUltra,icon:S}]}function U({label:e,triggerContent:s,className:l="",align:r="right",children:i}){const[c,d]=t.useState(!1),u=t.useRef(null),p=t.useId(),m=()=>{d(!1),u.current?.focus()},h=n(m,void 0,c),f=M(c,u,h,r);return t.useEffect(()=>{if(!c)return;const e=e=>{e.target instanceof Node&&!h.current?.contains(e.target)&&!u.current?.contains(e.target)&&d(!1)},t=e=>{e.target instanceof Node&&!h.current?.contains(e.target)&&!u.current?.contains(e.target)&&d(!1)};return document.addEventListener("pointerdown",e),document.addEventListener("focusin",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("focusin",t)}},[c]),a.jsxs("div",{className:`composer-menu ${l}`,onKeyDown:e=>{"Escape"!==e.key||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),m())},children:[a.jsx("button",{ref:u,type:"button",className:"composer-option-button",title:e,"aria-label":e,"aria-haspopup":"dialog","aria-expanded":c,"aria-controls":c?p:void 0,onClick:()=>d(!c),children:s}),c&&o.createPortal(a.jsx("div",{ref:h,id:p,role:"dialog","aria-label":e,className:"composer-settings-popover",style:f,children:i(m)}),document.body)]})}function B(e){const{t}=e;return a.jsxs(a.Fragment,{children:[e.fastMode&&a.jsxs("span",{className:"composer-fast-indicator",role:"status","aria-label":t.fastMode,title:t.fastMode,children:[a.jsx(k,{"aria-hidden":"true"}),a.jsx("span",{children:t.fast})]}),a.jsx(U,{label:`${t.model} / ${t.effort}`,className:"composer-model-trigger",triggerContent:a.jsxs(a.Fragment,{children:[a.jsxs("span",{children:[e.modelLabel," · ",e.effort?e.effortLabel:t.defaultOption]}),a.jsx(m,{"aria-hidden":"true"})]}),children:()=>a.jsxs("div",{className:"composer-model-settings",children:[a.jsx("strong",{children:t.model}),a.jsx(w,{icon:j,label:e.modelLabel,menuLabel:t.model,tooltipHoverDelay:1500,options:e.modelOptions,value:e.model,onSelect:e.onModelChange,wide:!0}),a.jsx("strong",{children:t.effort}),a.jsx("div",{className:"composer-effort-options",role:"group","aria-label":t.effort,children:e.effortOptions.map(n=>a.jsx("button",{type:"button",disabled:n.disabled,"aria-pressed":e.effort===n.value,title:n.description??n.label,onClick:()=>e.onEffortChange(n.value),children:n.value?n.label:t.defaultOption},n.value))}),a.jsxs("button",{type:"button",role:"switch","aria-checked":e.fastMode,"aria-label":t.fastMode,className:"composer-fast-switch",onClick:()=>e.onFastModeChange(!e.fastMode),children:[a.jsx(S,{"aria-hidden":"true"}),a.jsxs("span",{children:[a.jsx("strong",{children:t.fastMode}),a.jsx("small",{children:t.preferFasterResponses})]}),a.jsx("span",{className:"composer-switch-track","aria-hidden":"true",children:a.jsx("span",{})})]})]})})]})}function Q(e){const{t}=e;return a.jsxs("div",{className:"composer-toolbar desktop-composer-toolbar",children:[a.jsx(W,{...e}),a.jsx("div",{className:"composer-permission "+("autoApprove"===e.approvalMode?"full-access":""),children:a.jsx(w,{portal:!0,icon:y,label:e.approvalLabel,menuLabel:t.approvalMode,options:e.approvalOptions,value:e.approvalMode,onSelect:e.onApprovalModeChange,wide:!0,blendBackground:!0})}),a.jsx("div",{className:"composer-toolbar-spacer"}),a.jsx(B,{...e}),e.voice,e.submit]})}function W(e){const{t}=e,n=[{label:t.uploadFiles,icon:D,action:e.onUpload,disabled:e.toolsDisabled},{label:t.skills,icon:k,action:e.onSkills,shortcut:"$",disabled:e.toolsDisabled},{label:t.commands,icon:h,action:e.onCommands,shortcut:"/",disabled:e.toolsDisabled},...e.quickRepliesAvailable?[{label:e.quickRepliesOpen?t.hideQuickReplies:t.showQuickReplies,icon:A,action:e.onQuickReplies,disabled:!1}]:[]];return a.jsx(U,{align:"left",label:`${t.uploadFiles} / ${t.skills} / ${t.commands}`,className:"composer-tools-trigger",triggerContent:a.jsx(u,{"aria-hidden":"true"}),children:e=>a.jsx("div",{className:"composer-tools-list",children:n.map(({label:t,icon:n,action:o,shortcut:s,disabled:l})=>a.jsxs("button",{type:"button",disabled:l,onClick:()=>{e(),o?.()},children:[a.jsx(n,{"aria-hidden":"true"}),a.jsx("span",{children:t}),s&&a.jsx("kbd",{children:s})]},t))})})}function Z({draft:e,onChange:n,textareaRef:o,agent:s,skills:l,onRefreshSkills:r,t:i}){const[c,d]=t.useState(null),[u,p]=t.useState(""),[m,h]=t.useState(null),g=c?.draft===e?c.start:e.length,x=c?.draft===e&&c.start!==c.end?null:function(e,t){const a=/([$/])([A-Za-z0-9._:-]*)$/.exec(e.slice(0,t));return a?{symbol:a[1],keyword:a[2],start:a.index,end:t}:null}(e,g),y=x?`${e}:${g}`:"",k=!!x&&u!==y,j=k&&"/"===x.symbol,M=k&&"$"===x.symbol,w=f(b(s),x?.keyword??"",8),N=v(l,x?.keyword??"",8),S=(e,t)=>{n(e),d({draft:e,start:t,end:t}),requestAnimationFrame(()=>{const e=o.current;e&&(e.focus(),e.setSelectionRange(t,t))})},E=()=>{p(y),m&&e===m.after&&S(m.before,g-1),h(null),o.current?.focus()},D=t=>{if("$"===t&&r(),k&&x?.symbol===t)return E();if(p(""),x?.symbol===t)return o.current?.focus();const a=e.slice(0,g)+t+e.slice(g);h({before:e,after:a}),S(a,g+1)},A=t=>{if(!x)return;const a=`${x.symbol}${t} `,n=e.slice(0,x.start)+a+e.slice(x.end);h(null),S(n,x.start+a.length)},I=function({context:e,count:a,onSelect:n,onClose:o}){const s=t.useId(),[l,r]=t.useState({context:"",index:0}),i=l.context===e?Math.min(l.index,Math.max(0,a-1)):0,c=t=>r({context:e,index:t});return{listId:s,selectedIndex:i,selectIndex:c,handleKeyDown:t=>!(!e||t.nativeEvent.isComposing||229===t.nativeEvent.keyCode||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||("Escape"===t.key?(t.preventDefault(),t.stopPropagation(),o(),0):!a||("ArrowDown"===t.key||"ArrowUp"===t.key?(t.preventDefault(),t.stopPropagation(),c((i+("ArrowDown"===t.key?1:-1)+a)%a),0):"Enter"!==t.key&&"Tab"!==t.key||(t.preventDefault(),t.stopPropagation(),n(i),0))))}}({context:k?`${y}:${s}`:"",count:j?w.length:M?N.length:0,onSelect:e=>A(j?w[e].name:N[e].name),onClose:E}),K={listId:I.listId,selectedIndex:I.selectedIndex,onHighlight:I.selectIndex,onClose:E,t:i};return{showCommandSuggestions:j,showSkillSuggestions:M,handleOpenCommands:()=>D("/"),handleOpenSkills:()=>D("$"),handleKeyDown:I.handleKeyDown,textareaProps:{onSelect:()=>{const e=o.current;e&&d({draft:e.value,start:e.selectionStart,end:e.selectionEnd})},"aria-controls":k?I.listId:void 0,"aria-activedescendant":k&&(j?w.length:N.length)?`${I.listId}-${I.selectedIndex}`:void 0,"aria-autocomplete":"list"},popovers:a.jsxs(a.Fragment,{children:[a.jsx(C,{...K,visible:j,commands:w,onSelect:e=>A(e.name)}),a.jsx($,{...K,visible:M,skills:N,onSelect:e=>A(e.name)})]})}}export{z as C,Q as D,S as G,D as P,L as S,R as a,F as b,W as c,T as d,H as e,q as f,B as g,I as h,P as i,O as j,A as k,K as s,Z as u};
@@ -1 +1 @@
1
- import{c as t,r as e}from"./index-CArel_iz.js";import{j as n,k as r}from"./App-DKhLAmub.js";const s=t("image-off",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]),i=new RegExp("((?:~/|/|\\.{1,2}/|[A-Za-z0-9._-]+/)[^\\n`<>\"')\\]},。!?;:、]*?\\.(?:png|jpg|jpeg|gif|webp|svg|heic|heif)(?::\\d+(?::\\d+)?|#[^\\s`<>\"')\\]},。!?;:、]+)?)","gi"),a=[".png",".jpg",".jpeg",".gif",".webp",".svg",".heic",".heif"],l="\\s`<>\"')\\]},。!?;:、",o="`<>\"')\\]},。!?;:、\\n\\r\\t",c=new RegExp(`(^|[\\s([{>])((?:~\\/|\\/|\\.{1,2}\\/)[^${l}]+|[A-Za-z0-9._-]+(?:\\/[A-Za-z0-9._-]+)+(?:\\.[A-Za-z0-9._-]+)?\\/?)`,"g"),u=new RegExp(`(^|[\\s([{>])((?=[^${o}]*\\/)[^${o}]+?\\.[A-Za-z0-9._-]+(?::\\d+(?::\\d+)?|#[^${l}]+)?)(?=$|[${l}])`,"g");function h(t){let e=t;for(;/[.,!?;:,。!?;:、]+$/.test(e);)e=e.slice(0,-1);return e}function f(t,e){return!!t&&!/^[a-z]+:\/\//i.test(t)&&!t.startsWith("streamdown:")&&(!("~"!==t&&!t.startsWith("~/"))||!!(t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))||!(!/^[A-Za-z]:[\\/]/.test(t)&&!t.startsWith("\\\\"))||!(!t.includes("/")&&!t.includes("\\"))||Boolean(e?.allowBareFilename)&&/^[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+$/.test(t))}function d(t){let e=h(t.trim());if(!e)return"";const n=e.indexOf("#");if(n>0){const t=e.slice(0,n);f(t,{allowBareFilename:!0})&&(e=t)}const r=e.match(/^(.*?)(:\d+(?::\d+)?)$/);if(r){const t=r[1]??"";f(t,{allowBareFilename:!0})&&(e=t)}return h(e)}function p(t,e){return t.start<e.end&&e.start<t.end}function m(t){if(t.startsWith("/")||t.startsWith("~/")||t.startsWith("./")||t.startsWith("../"))return!0;const e=t.indexOf("/");if(e<=0)return!1;const n=t.slice(0,e).trim();return!!/^\d+\s+\S/.test(n)||!/\s/.test(n)&&/[^\p{ASCII}]/u.test(n)}function g(t){if(m(t.rawCandidate))return t;const e=t.rawCandidate.indexOf("/");if(e<=0)return t;const n=t.rawCandidate.slice(0,e);for(let r=n.indexOf(" ");r>=0;r=n.indexOf(" ",r+1)){const e=r+1,n=t.rawCandidate.slice(e);if(m(n))return{start:t.start+e,end:t.end,rawCandidate:n}}return t}function w(t,e){return f(d(t),e)}function y(t){const e=d(t).toLowerCase();return w(e,{allowBareFilename:!0})&&a.some(t=>e.endsWith(t))}const x=/^[a-z][a-z0-9+.-]*:/i,b=/^[a-z]:[\\/]/i,v=/\.(?:md|markdown)$/i,$=/[/\\]$/,_=t=>v.test(t)||$.test(t),z="https://vibelet.local",C="/__vibelet_markdown__",k=`${z}${C}`;function R(t){const e=t?.trim()??"";if(!e||e.startsWith("#")||e.startsWith("//"))return null;const n=function(t){let e;try{e=new URL(t)}catch{return null}if(e.origin!==z)return null;if(e.pathname!==C)return null;const n=e.searchParams.get("path");return n&&_(n)?n:null}(e);if(n)return n;if(x.test(e)&&!b.test(e))return null;const r=e.split(/[?#]/,1)[0]??"";return _(r)?function(t){try{return decodeURIComponent(t)}catch{return t}}(r):null}function A(t){const e=t.split("\n");let n=null;return e.map(t=>{const e=t.match(/^ {0,3}(`{3,}|~{3,})/);if(e){const r=e[1][0];return n===r?n=null:n||(n=r),t}return n?t:function(t){let e="",n=0;for(;n<t.length;){if("`"===t[n]){const r=W(t,n);e+=t.slice(n,r),n=r;continue}if("["===t[n]&&"!"!==t[n-1]){const r=E(t,n);if(r){e+=r.text,n=r.end;continue}}e+=t[n],n+=1}return e}(t)}).join("\n")}function W(t,e){let n=0;for(;"`"===t[e+n];)n+=1;const r="`".repeat(n),s=t.indexOf(r,e+n);return s<0?t.length:s+n}function E(t,e){const n=function(t,e){let n=!1;for(let r=e+1;r<t.length;r+=1){const e=t[r];if(n)n=!1;else if("\\"!==e){if("]"===e)return r}else n=!0}return-1}(t,e);if(n<0||"("!==t[n+1])return null;const r=n+2,s=function(t,e){let n=!1;for(let r=e;r<t.length;r+=1){const e=t[r];if(n)n=!1;else if("\\"!==e){if(")"===e)return r}else n=!0}return-1}(t,r);if(s<0)return null;const i=function(t){const e=t.match(/^\s*/)?.[0]??"",n=t.match(/\s*$/)?.[0]??"",r=t.slice(e.length,t.length-n.length);if(r.startsWith("<")){const t=r.indexOf(">");if(t<0)return null;const s=U(r.slice(1,t));return s?`${e}<${s}>${r.slice(t+1)}${n}`:null}const s=r.match(/^(\S+)([\s\S]*)$/);if(!s)return null;const i=U(s[1]);return i?`${e}${i}${s[2]}${n}`:null}(t.slice(r,s));return i?{text:`${t.slice(e,r)}${i})`,end:s+1}:null}function U(t){const e=R(t);return e?`${k}?path=${encodeURIComponent(e)}`:null}const j="https://vibelet.local/__vibelet_file__";function B(t){if(!t)return null;const e=R(t);if(e)return e;let n=t.trim();if(n.startsWith(j))try{const t=new URL(n);if("https://vibelet.local"!==t.origin||"/__vibelet_file__"!==t.pathname)return null;n=t.searchParams.get("path")??""}catch{return null}else if(/^file:\/\//i.test(n))try{const t=new URL(n);if(t.hostname&&"localhost"!==t.hostname)return null;n=t.pathname}catch{return null}else if(/^(?:[a-z][a-z\d+.-]*:|\/\/|#)/i.test(n)&&!/^[a-z]:[\\/]/i.test(n))return null;try{n=decodeURIComponent(n.split("?")[0])}catch{}return n=d(n),w(n,{allowBareFilename:!0})?n:null}const L=t=>`${j}?path=${encodeURIComponent(t)}`;function O(t){return t.value??t.children?.map(O).join("")??""}function I(){return t=>{const e=t=>{if("link"===t.type||"image"===t.type){const e=B(t.url);return void(e&&(t.url=L(e),y(e)&&(t.alt=t.alt||O(t)||e.split(/[\\/]/).at(-1),t.type="image",delete t.children)))}t.children&&!["code","inlineCode","html"].includes(t.type)&&(t.children=t.children.flatMap(t=>"text"===t.type?function(t){const e=[],n=new RegExp(`(?:file://(?:localhost)?(?=/))?${i.source}`,i.flags);let r=0;const s=t=>{for(const n of function(t){if(!t)return[];const e=[];let n=0;for(const r of function(t){const e=[];for(const n of t.matchAll(c)){const t=n[1]??"",r=n[2]??"",s=(n.index??0)+t.length;e.push({start:s,end:s+r.length,rawCandidate:r})}for(const n of t.matchAll(u)){const t=n[1]??"",r=n[2]??"",s=(n.index??0)+t.length,i=g({start:s,end:s+r.length,rawCandidate:r}),a=e.filter(t=>p(t,i));if(0!==a.length){if(m(i.rawCandidate)){for(const t of a){const n=e.indexOf(t);n>=0&&e.splice(n,1)}e.push(i)}}else e.push(i)}return e.sort((t,e)=>t.start-e.start||t.end-e.end)}(t)){r.start>n&&e.push({type:"text",value:t.slice(n,r.start)});const s=h(r.rawCandidate),i=d(s),a=r.rawCandidate.slice(s.length);w(s)&&!y(s)?(e.push({type:"path",value:s,target:i||s}),a&&e.push({type:"text",value:a})):e.push({type:"text",value:r.rawCandidate}),n=r.end}return n<t.length&&e.push({type:"text",value:t.slice(n)}),e.length>0?e:[{type:"text",value:t}]}(t))e.push("path"===n.type?{type:"link",url:L(n.target??n.value),children:[{type:"text",value:n.value}]}:{type:"text",value:n.value})};for(const i of t.matchAll(n)){const n=B(i[0]);n&&y(n)&&(s(t.slice(r,i.index)),e.push({type:"image",url:L(n),alt:n.split(/[\\/]/).at(-1)}),r=i.index+i[0].length)}return s(t.slice(r)),e}(t.value??""):(e(t),[t])))};e(t)}}const S=20971520,Z=new class{constructor(t=128,e=67108864,n=3e4){this.maxEntries=t,this.maxBytes=e,this.ttl=n}scope="";bytes=0;entries=new Map;get(t,e,n){this.scope!==t&&(this.entries.clear(),this.bytes=0,this.scope=t);for(const[i,a]of this.entries)a.expires<=Date.now()&&this.remove(i,a);const r=this.entries.get(e);if(r)return this.entries.delete(e),this.entries.set(e,r),r.promise;const s={promise:Promise.resolve(new Blob),bytes:0,expires:1/0};return s.promise=Promise.resolve().then(n).then(t=>(this.entries.get(e)===s&&(s.bytes=t.size,s.expires=Date.now()+this.ttl,this.bytes+=t.size,this.trim()),t),t=>{throw this.remove(e,s),t}),this.entries.set(e,s),this.trim(),s.promise}remove(t,e){this.entries.get(t)===e&&(this.entries.delete(t),this.bytes-=e.bytes)}trim(){for(;this.entries.size>this.maxEntries||this.bytes>this.maxBytes;){const t=this.entries.entries().next().value;if(!t)return;this.remove(...t)}}};function T(t,e){return Z.get(e,t,()=>async function(t,e){for(let r=0;;r++){const s=new AbortController;let i;const a=()=>{clearTimeout(i),i=setTimeout(()=>s.abort(new DOMException("Image request timed out","TimeoutError")),3e4)};a();try{const n=await fetch(t,{headers:{authorization:`Bearer ${e}`},signal:s.signal});if(0===r&&[502,503,504].includes(n.status)){await(n.body?.cancel());continue}const i=n.headers.get("content-type")??"";if(!n.ok||Number(n.headers.get("content-length"))>S||!i.startsWith("image/"))throw await(n.body?.cancel()),new Error("Image unavailable");const l=n.body?.getReader();if(!l)throw new Error("Image unavailable");const o=[];let c=0;try{for(;;){a();const{value:t,done:e}=await l.read();if(e)break;if(c+=t.byteLength,c>S)throw await l.cancel(),new Error("Unsupported image");o.push(t)}}finally{l.releaseLock()}return new Blob(o,{type:i})}catch(n){if(0===r&&(n instanceof TypeError||s.signal.aborted))continue;throw n}finally{clearTimeout(i)}}}(t,e))}function M(t,s,i=1600){const a=B(t),l=n(),[o,c]=e.useState(null),[u,h]=e.useState(null);return e.useEffect(()=>{if(!a)return;const e=new AbortController;let n;return c(null),h(null),(async()=>{try{if(!l)throw new Error("No pairing");const o=new URL(r(a,s));null!==i&&o.searchParams.set("w",String(i));const u=await T(o.toString(),l.pairToken);if(e.signal.aborted)return;n=URL.createObjectURL(u),c({src:t,url:n})}catch{e.signal.aborted||h(t)}})(),()=>{e.abort(),n&&URL.revokeObjectURL(n)}},[t,a,s,i,l?.pairToken,l?.webSocketUrl]),{url:a?o?.src===t?o.url:void 0:t,error:u===t,fail:()=>h(t)}}export{s as I,I as a,B as b,y as i,T as l,A as r,M as u};
1
+ import{c as t,r as e}from"./index-DUrY8OKv.js";import{j as n,k as r}from"./App-NMmWfGoY.js";const s=t("image-off",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]),i=new RegExp("((?:~/|/|\\.{1,2}/|[A-Za-z0-9._-]+/)[^\\n`<>\"')\\]},。!?;:、]*?\\.(?:png|jpg|jpeg|gif|webp|svg|heic|heif)(?::\\d+(?::\\d+)?|#[^\\s`<>\"')\\]},。!?;:、]+)?)","gi"),a=[".png",".jpg",".jpeg",".gif",".webp",".svg",".heic",".heif"],l="\\s`<>\"')\\]},。!?;:、",o="`<>\"')\\]},。!?;:、\\n\\r\\t",c=new RegExp(`(^|[\\s([{>])((?:~\\/|\\/|\\.{1,2}\\/)[^${l}]+|[A-Za-z0-9._-]+(?:\\/[A-Za-z0-9._-]+)+(?:\\.[A-Za-z0-9._-]+)?\\/?)`,"g"),u=new RegExp(`(^|[\\s([{>])((?=[^${o}]*\\/)[^${o}]+?\\.[A-Za-z0-9._-]+(?::\\d+(?::\\d+)?|#[^${l}]+)?)(?=$|[${l}])`,"g");function h(t){let e=t;for(;/[.,!?;:,。!?;:、]+$/.test(e);)e=e.slice(0,-1);return e}function f(t,e){return!!t&&!/^[a-z]+:\/\//i.test(t)&&!t.startsWith("streamdown:")&&(!("~"!==t&&!t.startsWith("~/"))||!!(t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))||!(!/^[A-Za-z]:[\\/]/.test(t)&&!t.startsWith("\\\\"))||!(!t.includes("/")&&!t.includes("\\"))||Boolean(e?.allowBareFilename)&&/^[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+$/.test(t))}function d(t){let e=h(t.trim());if(!e)return"";const n=e.indexOf("#");if(n>0){const t=e.slice(0,n);f(t,{allowBareFilename:!0})&&(e=t)}const r=e.match(/^(.*?)(:\d+(?::\d+)?)$/);if(r){const t=r[1]??"";f(t,{allowBareFilename:!0})&&(e=t)}return h(e)}function p(t,e){return t.start<e.end&&e.start<t.end}function m(t){if(t.startsWith("/")||t.startsWith("~/")||t.startsWith("./")||t.startsWith("../"))return!0;const e=t.indexOf("/");if(e<=0)return!1;const n=t.slice(0,e).trim();return!!/^\d+\s+\S/.test(n)||!/\s/.test(n)&&/[^\p{ASCII}]/u.test(n)}function g(t){if(m(t.rawCandidate))return t;const e=t.rawCandidate.indexOf("/");if(e<=0)return t;const n=t.rawCandidate.slice(0,e);for(let r=n.indexOf(" ");r>=0;r=n.indexOf(" ",r+1)){const e=r+1,n=t.rawCandidate.slice(e);if(m(n))return{start:t.start+e,end:t.end,rawCandidate:n}}return t}function w(t,e){return f(d(t),e)}function y(t){const e=d(t).toLowerCase();return w(e,{allowBareFilename:!0})&&a.some(t=>e.endsWith(t))}const x=/^[a-z][a-z0-9+.-]*:/i,b=/^[a-z]:[\\/]/i,v=/\.(?:md|markdown)$/i,$=/[/\\]$/,_=t=>v.test(t)||$.test(t),z="https://vibelet.local",C="/__vibelet_markdown__",k=`${z}${C}`;function R(t){const e=t?.trim()??"";if(!e||e.startsWith("#")||e.startsWith("//"))return null;const n=function(t){let e;try{e=new URL(t)}catch{return null}if(e.origin!==z)return null;if(e.pathname!==C)return null;const n=e.searchParams.get("path");return n&&_(n)?n:null}(e);if(n)return n;if(x.test(e)&&!b.test(e))return null;const r=e.split(/[?#]/,1)[0]??"";return _(r)?function(t){try{return decodeURIComponent(t)}catch{return t}}(r):null}function A(t){const e=t.split("\n");let n=null;return e.map(t=>{const e=t.match(/^ {0,3}(`{3,}|~{3,})/);if(e){const r=e[1][0];return n===r?n=null:n||(n=r),t}return n?t:function(t){let e="",n=0;for(;n<t.length;){if("`"===t[n]){const r=W(t,n);e+=t.slice(n,r),n=r;continue}if("["===t[n]&&"!"!==t[n-1]){const r=E(t,n);if(r){e+=r.text,n=r.end;continue}}e+=t[n],n+=1}return e}(t)}).join("\n")}function W(t,e){let n=0;for(;"`"===t[e+n];)n+=1;const r="`".repeat(n),s=t.indexOf(r,e+n);return s<0?t.length:s+n}function E(t,e){const n=function(t,e){let n=!1;for(let r=e+1;r<t.length;r+=1){const e=t[r];if(n)n=!1;else if("\\"!==e){if("]"===e)return r}else n=!0}return-1}(t,e);if(n<0||"("!==t[n+1])return null;const r=n+2,s=function(t,e){let n=!1;for(let r=e;r<t.length;r+=1){const e=t[r];if(n)n=!1;else if("\\"!==e){if(")"===e)return r}else n=!0}return-1}(t,r);if(s<0)return null;const i=function(t){const e=t.match(/^\s*/)?.[0]??"",n=t.match(/\s*$/)?.[0]??"",r=t.slice(e.length,t.length-n.length);if(r.startsWith("<")){const t=r.indexOf(">");if(t<0)return null;const s=U(r.slice(1,t));return s?`${e}<${s}>${r.slice(t+1)}${n}`:null}const s=r.match(/^(\S+)([\s\S]*)$/);if(!s)return null;const i=U(s[1]);return i?`${e}${i}${s[2]}${n}`:null}(t.slice(r,s));return i?{text:`${t.slice(e,r)}${i})`,end:s+1}:null}function U(t){const e=R(t);return e?`${k}?path=${encodeURIComponent(e)}`:null}const j="https://vibelet.local/__vibelet_file__";function B(t){if(!t)return null;const e=R(t);if(e)return e;let n=t.trim();if(n.startsWith(j))try{const t=new URL(n);if("https://vibelet.local"!==t.origin||"/__vibelet_file__"!==t.pathname)return null;n=t.searchParams.get("path")??""}catch{return null}else if(/^file:\/\//i.test(n))try{const t=new URL(n);if(t.hostname&&"localhost"!==t.hostname)return null;n=t.pathname}catch{return null}else if(/^(?:[a-z][a-z\d+.-]*:|\/\/|#)/i.test(n)&&!/^[a-z]:[\\/]/i.test(n))return null;try{n=decodeURIComponent(n.split("?")[0])}catch{}return n=d(n),w(n,{allowBareFilename:!0})?n:null}const L=t=>`${j}?path=${encodeURIComponent(t)}`;function O(t){return t.value??t.children?.map(O).join("")??""}function I(){return t=>{const e=t=>{if("link"===t.type||"image"===t.type){const e=B(t.url);return void(e&&(t.url=L(e),y(e)&&(t.alt=t.alt||O(t)||e.split(/[\\/]/).at(-1),t.type="image",delete t.children)))}t.children&&!["code","inlineCode","html"].includes(t.type)&&(t.children=t.children.flatMap(t=>"text"===t.type?function(t){const e=[],n=new RegExp(`(?:file://(?:localhost)?(?=/))?${i.source}`,i.flags);let r=0;const s=t=>{for(const n of function(t){if(!t)return[];const e=[];let n=0;for(const r of function(t){const e=[];for(const n of t.matchAll(c)){const t=n[1]??"",r=n[2]??"",s=(n.index??0)+t.length;e.push({start:s,end:s+r.length,rawCandidate:r})}for(const n of t.matchAll(u)){const t=n[1]??"",r=n[2]??"",s=(n.index??0)+t.length,i=g({start:s,end:s+r.length,rawCandidate:r}),a=e.filter(t=>p(t,i));if(0!==a.length){if(m(i.rawCandidate)){for(const t of a){const n=e.indexOf(t);n>=0&&e.splice(n,1)}e.push(i)}}else e.push(i)}return e.sort((t,e)=>t.start-e.start||t.end-e.end)}(t)){r.start>n&&e.push({type:"text",value:t.slice(n,r.start)});const s=h(r.rawCandidate),i=d(s),a=r.rawCandidate.slice(s.length);w(s)&&!y(s)?(e.push({type:"path",value:s,target:i||s}),a&&e.push({type:"text",value:a})):e.push({type:"text",value:r.rawCandidate}),n=r.end}return n<t.length&&e.push({type:"text",value:t.slice(n)}),e.length>0?e:[{type:"text",value:t}]}(t))e.push("path"===n.type?{type:"link",url:L(n.target??n.value),children:[{type:"text",value:n.value}]}:{type:"text",value:n.value})};for(const i of t.matchAll(n)){const n=B(i[0]);n&&y(n)&&(s(t.slice(r,i.index)),e.push({type:"image",url:L(n),alt:n.split(/[\\/]/).at(-1)}),r=i.index+i[0].length)}return s(t.slice(r)),e}(t.value??""):(e(t),[t])))};e(t)}}const S=20971520,Z=new class{constructor(t=128,e=67108864,n=3e4){this.maxEntries=t,this.maxBytes=e,this.ttl=n}scope="";bytes=0;entries=new Map;get(t,e,n){this.scope!==t&&(this.entries.clear(),this.bytes=0,this.scope=t);for(const[i,a]of this.entries)a.expires<=Date.now()&&this.remove(i,a);const r=this.entries.get(e);if(r)return this.entries.delete(e),this.entries.set(e,r),r.promise;const s={promise:Promise.resolve(new Blob),bytes:0,expires:1/0};return s.promise=Promise.resolve().then(n).then(t=>(this.entries.get(e)===s&&(s.bytes=t.size,s.expires=Date.now()+this.ttl,this.bytes+=t.size,this.trim()),t),t=>{throw this.remove(e,s),t}),this.entries.set(e,s),this.trim(),s.promise}remove(t,e){this.entries.get(t)===e&&(this.entries.delete(t),this.bytes-=e.bytes)}trim(){for(;this.entries.size>this.maxEntries||this.bytes>this.maxBytes;){const t=this.entries.entries().next().value;if(!t)return;this.remove(...t)}}};function T(t,e){return Z.get(e,t,()=>async function(t,e){for(let r=0;;r++){const s=new AbortController;let i;const a=()=>{clearTimeout(i),i=setTimeout(()=>s.abort(new DOMException("Image request timed out","TimeoutError")),3e4)};a();try{const n=await fetch(t,{headers:{authorization:`Bearer ${e}`},signal:s.signal});if(0===r&&[502,503,504].includes(n.status)){await(n.body?.cancel());continue}const i=n.headers.get("content-type")??"";if(!n.ok||Number(n.headers.get("content-length"))>S||!i.startsWith("image/"))throw await(n.body?.cancel()),new Error("Image unavailable");const l=n.body?.getReader();if(!l)throw new Error("Image unavailable");const o=[];let c=0;try{for(;;){a();const{value:t,done:e}=await l.read();if(e)break;if(c+=t.byteLength,c>S)throw await l.cancel(),new Error("Unsupported image");o.push(t)}}finally{l.releaseLock()}return new Blob(o,{type:i})}catch(n){if(0===r&&(n instanceof TypeError||s.signal.aborted))continue;throw n}finally{clearTimeout(i)}}}(t,e))}function M(t,s,i=1600){const a=B(t),l=n(),[o,c]=e.useState(null),[u,h]=e.useState(null);return e.useEffect(()=>{if(!a)return;const e=new AbortController;let n;return c(null),h(null),(async()=>{try{if(!l)throw new Error("No pairing");const o=new URL(r(a,s));null!==i&&o.searchParams.set("w",String(i));const u=await T(o.toString(),l.pairToken);if(e.signal.aborted)return;n=URL.createObjectURL(u),c({src:t,url:n})}catch{e.signal.aborted||h(t)}})(),()=>{e.abort(),n&&URL.revokeObjectURL(n)}},[t,a,s,i,l?.pairToken,l?.webSocketUrl]),{url:a?o?.src===t?o.url:void 0:t,error:u===t,fail:()=>h(t)}}export{s as I,I as a,B as b,y as i,T as l,A as r,M as u};
@@ -1 +1 @@
1
- import{b3 as t,_ as e,s as n,g as s,p as i,o as r,a as o,b as a,z as l,F as c,d as h,ak as u,a9 as f,aa as d,ab as y,e as g,q as p,B as x,D as m}from"./mermaid.core-B71KCuEy.js";import"./RemoteLifeOSBlock-aE9tb99H.js";import"./index-CArel_iz.js";import"./purify.es-BNLkGfTg.js";import"./marked.esm-BBjA1da9.js";import"./index-OdgHTLbm.js";import"./index-CJZRHYmg.js";import"./file-editor-index-C6CU7Fik.js";import"./App-DKhLAmub.js";import"./chevron-up-bHY6-UxU.js";import"./__vite-browser-external-2447137e-DiZsMwIM.js";const b=(e,n)=>t(e,"a",-n);function v(t,e){const n=function(t){const e=[];for(let n=0;n<t.length;++n)for(let s=n+1;s<t.length;++s){const i=w(t[n],t[s]);for(const t of i)t.parentIndex=[n,s],e.push(t)}return e}(t),s=n.filter(e=>function(t,e){return e.every(e=>M(t,e)<e.radius+1e-10)}(e,t));let i=0,r=0;const o=[];if(s.length>1){const e=_(s);for(let t=0;t<s.length;++t){const n=s[t];n.angle=Math.atan2(n.x-e.x,n.y-e.y)}s.sort((t,e)=>e.angle-t.angle);let n=s[s.length-1];for(let a=0;a<s.length;++a){const e=s[a];r+=(n.x+e.x)*(e.y-n.y);const l={x:(e.x+n.x)/2,y:(e.y+n.y)/2};let c=null;for(let s=0;s<e.parentIndex.length;++s)if(n.parentIndex.includes(e.parentIndex[s])){const i=t[e.parentIndex[s]],r=Math.atan2(e.x-i.x,e.y-i.y),o=Math.atan2(n.x-i.x,n.y-i.y);let a=o-r;a<0&&(a+=2*Math.PI);const h=o-a/2;let u=M(l,{x:i.x+i.radius*Math.sin(h),y:i.y+i.radius*Math.cos(h)});u>2*i.radius&&(u=2*i.radius),(null==c||c.width>u)&&(c={circle:i,width:u,p1:e,p2:n,large:u>i.radius,sweep:!0})}null!=c&&(o.push(c),i+=I(c.circle.radius,c.width),n=e)}}else{let e=t[0];for(let s=1;s<t.length;++s)t[s].radius<e.radius&&(e=t[s]);let n=!1;for(let s=0;s<t.length;++s)if(M(t[s],e)>Math.abs(e.radius-t[s].radius)){n=!0;break}n?i=r=0:(i=e.radius*e.radius*Math.PI,o.push({circle:e,p1:{x:e.x,y:e.y+e.radius},p2:{x:e.x-1e-10,y:e.y+e.radius},width:2*e.radius,large:!0,sweep:!0}))}return r/=2,e&&(e.area=i+r,e.arcArea=i,e.polygonArea=r,e.arcs=o,e.innerPoints=s,e.intersectionPoints=n),i+r}function I(t,e){return t*t*Math.acos(1-e/t)-(t-e)*Math.sqrt(e*(2*t-e))}function M(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function k(t,e,n){if(n>=t+e)return 0;if(n<=Math.abs(t-e))return Math.PI*Math.min(t,e)*Math.min(t,e);const s=e-(n*n-t*t+e*e)/(2*n);return I(t,t-(n*n-e*e+t*t)/(2*n))+I(e,s)}function w(t,e){const n=M(t,e),s=t.radius,i=e.radius;if(n>=s+i||n<=Math.abs(s-i))return[];const r=(s*s-i*i+n*n)/(2*n),o=Math.sqrt(s*s-r*r),a=t.x+r*(e.x-t.x)/n,l=t.y+r*(e.y-t.y)/n,c=-(e.y-t.y)*(o/n),h=-(e.x-t.x)*(o/n);return[{x:a+c,y:l-h},{x:a-c,y:l+h}]}function _(t){const e={x:0,y:0};for(const n of t)e.x+=n.x,e.y+=n.y;return e.x/=t.length,e.y/=t.length,e}function S(t){const e=new Array(t);for(let n=0;n<t;++n)e[n]=0;return e}function E(t,e){return S(t).map(()=>S(e))}function T(t,e){let n=0;for(let s=0;s<t.length;++s)n+=t[s]*e[s];return n}function z(t){return Math.sqrt(T(t,t))}function A(t,e,n){for(let s=0;s<e.length;++s)t[s]=e[s]*n}function R(t,e,n,s,i){for(let r=0;r<t.length;++r)t[r]=e*n[r]+s*i[r]}function N(t,e,n){const s=(n=n||{}).maxIterations||200*e.length,i=n.nonZeroDelta||1.05,r=n.zeroDelta||.001,o=n.minErrorDelta||1e-6,a=n.minErrorDelta||1e-5,l=void 0!==n.rho?n.rho:1,c=void 0!==n.chi?n.chi:2,h=void 0!==n.psi?n.psi:-.5,u=void 0!==n.sigma?n.sigma:.5;let f;const d=e.length,y=new Array(d+1);y[0]=e,y[0].fx=t(e),y[0].id=0;for(let I=0;I<d;++I){const n=e.slice();n[I]=n[I]?n[I]*i:r,y[I+1]=n,y[I+1].fx=t(n),y[I+1].id=I+1}function g(t){for(let e=0;e<t.length;e++)y[d][e]=t[e];y[d].fx=t.fx}const p=(t,e)=>t.fx-e.fx,x=e.slice(),m=e.slice(),b=e.slice(),v=e.slice();for(let I=0;I<s;++I){if(y.sort(p),n.history){const t=y.map(t=>{const e=t.slice();return e.fx=t.fx,e.id=t.id,e});t.sort((t,e)=>t.id-e.id),n.history.push({x:y[0].slice(),fx:y[0].fx,simplex:t})}f=0;for(let t=0;t<d;++t)f=Math.max(f,Math.abs(y[0][t]-y[1][t]));if(Math.abs(y[0].fx-y[d].fx)<o&&f<a)break;for(let t=0;t<d;++t){x[t]=0;for(let e=0;e<d;++e)x[t]+=y[e][t];x[t]/=d}const e=y[d];if(R(m,1+l,x,-l,e),m.fx=t(m),m.fx<y[0].fx)R(v,1+c,x,-c,e),v.fx=t(v),v.fx<m.fx?g(v):g(m);else if(m.fx>=y[d-1].fx){let n=!1;if(m.fx>e.fx?(R(b,1+h,x,-h,e),b.fx=t(b),b.fx<e.fx?g(b):n=!0):(R(b,1-h*l,x,h*l,e),b.fx=t(b),b.fx<m.fx?g(b):n=!0),n){if(u>=1)break;for(let e=1;e<y.length;++e)R(y[e],1-u,y[0],u,y[e]),y[e].fx=t(y[e])}}else g(m)}return y.sort(p),{fx:y[0].fx,x:y[0]}}function D(t,e,n,s,i,r,o){const a=n.fx,l=T(n.fxprime,e);let c=a,h=a,u=l,f=0;function d(h,f,d){for(let y=0;y<16;++y)if(i=(h+f)/2,R(s.x,1,n.x,i,e),c=s.fx=t(s.x,s.fxprime),u=T(s.fxprime,e),c>a+r*i*l||c>=d)f=i;else{if(Math.abs(u)<=-o*l)return i;u*(f-h)>=0&&(f=h),h=i,d=c}return 0}i=i||1,r=r||1e-6,o=o||.1;for(let y=0;y<10;++y){if(R(s.x,1,n.x,i,e),c=s.fx=t(s.x,s.fxprime),u=T(s.fxprime,e),c>a+r*i*l||y&&c>=h)return d(f,i,h);if(Math.abs(u)<=-o*l)return i;if(u>=0)return d(i,f,c);h=c,f=i,i*=2}return i}function O(t,e,n){let s={x:e.slice(),fx:0,fxprime:e.slice()},i={x:e.slice(),fx:0,fxprime:e.slice()};const r=e.slice();let o,a,l,c=1;l=(n=n||{}).maxIterations||20*e.length,s.fx=t(s.x,s.fxprime),o=s.fxprime.slice(),A(o,s.fxprime,-1);for(let h=0;h<l;++h){if(c=D(t,o,s,i,c),n.history&&n.history.push({x:s.x.slice(),fx:s.fx,fxprime:s.fxprime.slice(),alpha:c}),c){R(r,1,i.fxprime,-1,s.fxprime);const t=T(s.fxprime,s.fxprime);R(o,Math.max(0,T(r,i.fxprime)/t),o,-1,i.fxprime),a=s,s=i,i=a}else A(o,s.fxprime,-1);if(z(s.fxprime)<=1e-5)break}return n.history&&n.history.push({x:s.x.slice(),fx:s.fx,fxprime:s.fxprime.slice(),alpha:c}),s}function j(t,e={}){e.maxIterations=e.maxIterations||500;const n=e.initialLayout||$,s=e.lossFunction||P,i=function(t,e={}){const n=e.distinct,s=t.map(t=>Object.assign({},t));function i(t){return t.join(";")}if(n){const t=new Map;for(const e of s)for(let n=0;n<e.sets.length;n++){const s=String(e.sets[n]);t.set(s,e.size+(t.get(s)||0));for(let i=n+1;i<e.sets.length;i++){const n=String(e.sets[i]),r=`${s};${n}`,o=`${n};${s}`;t.set(r,e.size+(t.get(r)||0)),t.set(o,e.size+(t.get(o)||0))}}for(const e of s)e.sets.length<3&&(e.size=t.get(i(e.sets)))}const r=[],o=new Set;for(const a of s)if(1===a.sets.length)r.push(a.sets[0]);else if(2===a.sets.length){const t=a.sets[0],e=a.sets[1];o.add(i(a.sets)),o.add(i([e,t]))}r.sort((t,e)=>t===e?0:t<e?-1:1);for(let a=0;a<r.length;++a){const t=r[a];for(let e=a+1;e<r.length;++e){const n=r[e];o.has(i([t,n]))||s.push({sets:[t,n],size:0})}}return s}(t,e),r=n(i,e),o=Object.keys(r),a=[];for(const c of o)a.push(r[c].x),a.push(r[c].y);const l=N(t=>{const e={};for(let n=0;n<o.length;++n){const s=o[n];e[s]={x:t[2*n],y:t[2*n+1],radius:r[s].radius}}return s(e,i)},a,e).x;for(let c=0;c<o.length;++c){const t=o[c];r[t].x=l[2*c],r[t].y=l[2*c+1]}return r}const F=1e-10;function C(t,e,n){return Math.min(t,e)*Math.min(t,e)*Math.PI<=n+F?Math.abs(t-e):function(t,e,n,s){const i=(s=s||{}).maxIterations||100,r=s.tolerance||1e-10,o=t(e),a=t(n);let l=n-e;if(o*a>0)throw"Initial bisect points must have opposite signs";if(0===o)return e;if(0===a)return n;for(let c=0;c<i;++c){l/=2;const n=e+l,s=t(n);if(s*o>=0&&(e=n),Math.abs(l)<r||0===s)return n}return e+l}(s=>k(t,e,s)-n,0,t+e)}function $(t,e={}){let n=function(t,e){const n=e&&e.lossFunction?e.lossFunction:P,s={},i={};for(const u of t)if(1===u.sets.length){const t=u.sets[0];s[t]={x:1e10,y:1e10,rowid:s.length,size:u.size,radius:Math.sqrt(u.size/Math.PI)},i[t]=[]}t=t.filter(t=>2===t.sets.length);for(const u of t){let t=null!=u.weight?u.weight:1;const e=u.sets[0],n=u.sets[1];u.size+F>=Math.min(s[e].size,s[n].size)&&(t=0),i[e].push({set:n,size:u.size,weight:t}),i[n].push({set:e,size:u.size,weight:t})}const r=[];function o(t,e){return e.size-t.size}Object.keys(i).forEach(t=>{let e=0;for(let n=0;n<i[t].length;++n)e+=i[t][n].size*i[t][n].weight;r.push({set:t,size:e})}),r.sort(o);const a={};function l(t){return t.set in a}function c(t,e){s[e].x=t.x,s[e].y=t.y,a[e]=!0}c({x:0,y:0},r[0].set);for(let u=1;u<r.length;++u){const e=r[u].set,a=i[e].filter(l),f=s[e];if(a.sort(o),0===a.length)throw"ERROR: missing pairwise overlap information";const d=[];for(var h=0;h<a.length;++h){const t=s[a[h].set],e=C(f.radius,t.radius,a[h].size);d.push({x:t.x+e,y:t.y}),d.push({x:t.x-e,y:t.y}),d.push({y:t.y+e,x:t.x}),d.push({y:t.y-e,x:t.x});for(let n=h+1;n<a.length;++n){const i=s[a[n].set],r=C(f.radius,i.radius,a[n].size),o=w({x:t.x,y:t.y,radius:e},{x:i.x,y:i.y,radius:r});d.push(...o)}}let y=1e50,g=d[0];for(const i of d){s[e].x=i.x,s[e].y=i.y;const r=n(s,t);r<y&&(y=r,g=i)}c(g,e)}return s}(t,e);const s=e.lossFunction||P;if(t.length>=8){const i=function(t,e={}){const n=e.restarts||10,s=[],i={};for(const f of t)1===f.sets.length&&(i[f.sets[0]]=s.length,s.push(f));let{distances:r,constraints:o}=function(t,e,n){const s=E(e.length,e.length),i=E(e.length,e.length);return t.filter(t=>2===t.sets.length).forEach(t=>{const r=n[t.sets[0]],o=n[t.sets[1]],a=C(Math.sqrt(e[r].size/Math.PI),Math.sqrt(e[o].size/Math.PI),t.size);s[r][o]=s[o][r]=a;let l=0;t.size+1e-10>=Math.min(e[r].size,e[o].size)?l=1:t.size<=1e-10&&(l=-1),i[r][o]=i[o][r]=l}),{distances:s,constraints:i}}(t,s,i);const a=z(r.map(z))/r.length;r=r.map(t=>t.map(t=>t/a));const l=(t,e)=>function(t,e,n,s){for(let r=0;r<e.length;++r)e[r]=0;let i=0;for(let r=0;r<n.length;++r){const o=t[2*r],a=t[2*r+1];for(let l=r+1;l<n.length;++l){const c=t[2*l],h=t[2*l+1],u=n[r][l],f=s[r][l],d=(c-o)*(c-o)+(h-a)*(h-a),y=Math.sqrt(d),g=d-u*u;f>0&&y<=u||f<0&&y>=u||(i+=2*g*g,e[2*r]+=4*g*(o-c),e[2*r+1]+=4*g*(a-h),e[2*l]+=4*g*(c-o),e[2*l+1]+=4*g*(h-a))}}return i}(t,e,r,o);let c=null;for(let f=0;f<n;++f){const t=O(l,S(2*r.length).map(Math.random),e);(!c||t.fx<c.fx)&&(c=t)}const h=c.x,u={};for(let f=0;f<s.length;++f){const t=s[f];u[t.sets[0]]={x:h[2*f]*a,y:h[2*f+1]*a,radius:Math.sqrt(t.size/Math.PI)}}if(e.history)for(const f of e.history)A(f.x,a);return u}(t,e);s(i,t)+1e-8<s(n,t)&&(n=i)}return n}function P(t,e){let n=0;for(const s of e){if(1===s.sets.length)continue;let e;if(2===s.sets.length){const n=t[s.sets[0]],i=t[s.sets[1]];e=k(n.radius,i.radius,M(n,i))}else e=v(s.sets.map(e=>t[e]));n+=(null!=s.weight?s.weight:1)*(e-s.size)*(e-s.size)}return n}function L(t,e){let n=0;for(const s of e){if(1===s.sets.length)continue;let e;if(2===s.sets.length){const n=t[s.sets[0]],i=t[s.sets[1]];e=k(n.radius,i.radius,M(n,i))}else e=v(s.sets.map(e=>t[e]));const i=null!=s.weight?s.weight:1,r=Math.log((e+1)/(s.size+1));n+=i*r*r}return n}function q(t,e,n){if(null==n?t.sort((t,e)=>e.radius-t.radius):t.sort(n),t.length>0){const e=t[0].x,n=t[0].y;for(const s of t)s.x-=e,s.y-=n}if(2===t.length&&M(t[0],t[1])<Math.abs(t[1].radius-t[0].radius)&&(t[1].x=t[0].x+t[0].radius-t[1].radius-1e-10,t[1].y=t[0].y),t.length>1){const n=Math.atan2(t[1].x,t[1].y)-e,s=Math.cos(n),i=Math.sin(n);for(const e of t){const t=e.x,n=e.y;e.x=s*t-i*n,e.y=i*t+s*n}}if(t.length>2){let n=Math.atan2(t[2].x,t[2].y)-e;for(;n<0;)n+=2*Math.PI;for(;n>2*Math.PI;)n-=2*Math.PI;if(n>Math.PI){const e=t[1].y/(1e-10+t[1].x);for(const n of t){var s=(n.x+e*n.y)/(1+e*e);n.x=2*s-n.x,n.y=2*s*e-n.y}}}}function B(t){const e=e=>({max:t.reduce((t,n)=>Math.max(t,n[e]+n.radius),Number.NEGATIVE_INFINITY),min:t.reduce((t,n)=>Math.min(t,n[e]-n.radius),Number.POSITIVE_INFINITY)});return{xRange:e("x"),yRange:e("y")}}function U(t,e,n){null==e&&(e=Math.PI/2);let s=V(t).map(t=>Object.assign({},t));const i=function(t){function e(t){return t.parent!==t&&(t.parent=e(t.parent)),t.parent}function n(t,n){const s=e(t),i=e(n);s.parent=i}t.forEach(t=>{t.parent=t});for(let i=0;i<t.length;++i)for(let e=i+1;e<t.length;++e){const s=t[i].radius+t[e].radius;M(t[i],t[e])+1e-10<s&&n(t[e],t[i])}const s=new Map;for(let i=0;i<t.length;++i){const n=e(t[i]).parent.setid;s.has(n)||s.set(n,[]),s.get(n).push(t[i])}return t.forEach(t=>{delete t.parent}),Array.from(s.values())}(s);for(const c of i){q(c,e,n);const t=B(c);c.size=(t.xRange.max-t.xRange.min)*(t.yRange.max-t.yRange.min),c.bounds=t}i.sort((t,e)=>e.size-t.size),s=i[0];let r=s.bounds;const o=(r.xRange.max-r.xRange.min)/50;function a(t,e,n){if(!t)return;const i=t.bounds;let a,l;if(e)a=r.xRange.max-i.xRange.min+o;else{a=r.xRange.max-i.xRange.max;const t=(i.xRange.max-i.xRange.min)/2-(r.xRange.max-r.xRange.min)/2;t<0&&(a+=t)}if(n)l=r.yRange.max-i.yRange.min+o;else{l=r.yRange.max-i.yRange.max;const t=(i.yRange.max-i.yRange.min)/2-(r.yRange.max-r.yRange.min)/2;t<0&&(l+=t)}for(const r of t)r.x+=a,r.y+=l,s.push(r)}let l=1;for(;l<i.length;)a(i[l],!0,!1),a(i[l+1],!1,!0),a(i[l+2],!0,!0),l+=3,r=B(s);return W(s)}function G(t,e,n,s,i){const r=V(t);e-=2*s,n-=2*s;const{xRange:o,yRange:a}=B(r);if(o.max===o.min||a.max===a.min)return console.log("not scaling solution: zero size detected"),t;let l,c;if(i){const t=2*Math.sqrt(i/Math.PI);l=e/t,c=n/t}else l=e/(o.max-o.min),c=n/(a.max-a.min);const h=Math.min(c,l),u=(e-(o.max-o.min)*h)/2,f=(n-(a.max-a.min)*h)/2;return W(r.map(t=>({radius:h*t.radius,x:s+u+(t.x-o.min)*h,y:s+f+(t.y-a.min)*h,setid:t.setid})))}function W(t){const e={};for(const n of t)e[n.setid]=n;return e}function V(t){return Object.keys(t).map(e=>Object.assign(t[e],{setid:e}))}function X(t,e){return function(n){const s=this,i=t[n.sets[0]].radius||50,r=e(n)||"",o=r.split(/\s+/).reverse(),a=(r.length+o.length)/3;let l=o.pop(),c=[l],h=0;s.textContent=null;const u=[];function f(t){const e=s.ownerDocument.createElementNS(s.namespaceURI,"tspan");return e.textContent=t,u.push(e),s.append(e),e}let d=f(l);for(;l=o.pop(),l;){c.push(l);const t=c.join(" ");d.textContent=t,t.length>a&&d.getComputedTextLength()>i&&(c.pop(),d.textContent=c.join(" "),c=[l],d=f(l),h++)}const y=.35-1.1*h/2,g=s.getAttribute("x"),p=s.getAttribute("y");u.forEach((t,e)=>{t.setAttribute("x",g),t.setAttribute("y",p),t.setAttribute("dy",`${y+1.1*e}em`)})}}function K(t,e,n){let s=e[0].radius-M(e[0],t);for(let i=1;i<e.length;++i){const n=e[i].radius-M(e[i],t);n<=s&&(s=n)}for(let i=0;i<n.length;++i){const e=M(n[i],t)-n[i].radius;e<=s&&(s=e)}return s}function Y(t,e,n){const s=[];for(const h of t)s.push({x:h.x,y:h.y}),s.push({x:h.x+h.radius/2,y:h.y}),s.push({x:h.x-h.radius/2,y:h.y}),s.push({x:h.x,y:h.y+h.radius/2}),s.push({x:h.x,y:h.y-h.radius/2});let i=s[0],r=K(s[0],t,e);for(let h=1;h<s.length;++h){const n=K(s[h],t,e);n>=r&&(i=s[h],r=n)}const o=N(n=>-1*K({x:n[0],y:n[1]},t,e),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,a={x:n?0:o[0],y:o[1]};let l=!0;for(const h of t)if(M(a,h)>h.radius){l=!1;break}for(const h of e)if(M(a,h)<h.radius){l=!1;break}if(l)return a;if(1==t.length)return{x:t[0].x,y:t[0].y};const c={};return v(t,c),0===c.arcs.length?{x:0,y:-1e3,disjoint:!0}:1==c.arcs.length?{x:c.arcs[0].circle.x,y:c.arcs[0].circle.y}:e.length?Y(t,[]):_(c.arcs.map(t=>t.p1))}function Z(t,e,n){const s={},i=function(t){const e={},n=Object.keys(t);for(const s of n)e[s]=[];for(let s=0;s<n.length;s++){const i=n[s],r=t[i];for(let o=s+1;o<n.length;++o){const s=n[o],a=t[s],l=M(r,a);l+a.radius<=r.radius+1e-10?e[s].push(i):l+r.radius<=a.radius+1e-10&&e[i].push(s)}}return e}(t);for(let r=0;r<e.length;++r){const o=e[r].sets,a={},l={};for(let t=0;t<o.length;++t){a[o[t]]=!0;const e=i[o[t]];for(let t=0;t<e.length;++t)l[e[t]]=!0}const c=[],h=[];for(let e in t)e in a?c.push(t[e]):e in l||h.push(t[e]);const u=Y(c,h,n);s[o]=u,u.disjoint&&e[r].size>0&&console.log("WARNING: area "+o+" not represented on screen")}return s}function H(t){if(0===t.length)return[];const e={};return v(t,e),e.arcs}function Q(t,e){if(0===t.length)return"M 0 0";const n=Math.pow(10,e||0),s=null!=e?t=>Math.round(t*n)/n:t=>t;if(1==t.length){const e=t[0].circle;return function(t,e,n){const s=[];return s.push("\nM",t,e),s.push("\nm",-n,0),s.push("\na",n,n,0,1,0,2*n,0),s.push("\na",n,n,0,1,0,2*-n,0),s.join(" ")}(s(e.x),s(e.y),s(e.radius))}const i=["\nM",s(t[0].p2.x),s(t[0].p2.y)];for(const r of t){const t=s(r.circle.radius);i.push("\nA",t,t,0,r.large?1:0,r.sweep?1:0,s(r.p1.x),s(r.p1.y))}return i.join(" ")}function J(t,e){return Q(H(t),e)}var tt=function(){var t=e(function(t,e,n,s){for(n=n||{},s=t.length;s--;n[t[s]]=e);return n},"o"),n=[5,8],s=[7,8,11,12,17,19,22,24],i=[1,17],r=[1,18],o=[7,8,11,12,14,15,16,17,19,20,21,22,24,27],a=[1,31],l=[1,39],c=[7,8,11,12,17,19,22,24,27],h=[1,57],u=[1,56],f=[1,58],d=[1,59],y=[1,60],g=[7,8,11,12,16,17,19,20,22,24,27,31,32,33],p={trace:e(function(){},"trace"),yy:{},symbols_:{error:2,start:3,optNewlines:4,VENN:5,document:6,EOF:7,NEWLINE:8,line:9,statement:10,TITLE:11,SET:12,identifier:13,BRACKET_LABEL:14,COLON:15,NUMERIC:16,UNION:17,identifierList:18,TEXT:19,IDENTIFIER:20,STRING:21,INDENT_TEXT:22,indentedTextTail:23,STYLE:24,stylesOpt:25,styleField:26,COMMA:27,styleValue:28,valueTokens:29,valueToken:30,HEXCOLOR:31,RGBCOLOR:32,RGBACOLOR:33,$accept:0,$end:1},terminals_:{2:"error",5:"VENN",7:"EOF",8:"NEWLINE",11:"TITLE",12:"SET",14:"BRACKET_LABEL",15:"COLON",16:"NUMERIC",17:"UNION",19:"TEXT",20:"IDENTIFIER",21:"STRING",22:"INDENT_TEXT",24:"STYLE",27:"COMMA",31:"HEXCOLOR",32:"RGBCOLOR",33:"RGBACOLOR"},productions_:[0,[3,4],[4,0],[4,2],[6,0],[6,2],[9,1],[9,1],[10,1],[10,2],[10,3],[10,4],[10,5],[10,2],[10,3],[10,4],[10,5],[10,3],[10,3],[10,3],[10,4],[10,4],[10,2],[10,3],[23,1],[23,1],[23,1],[23,2],[23,2],[25,1],[25,3],[26,3],[28,1],[28,1],[29,1],[29,2],[30,1],[30,1],[30,1],[30,1],[30,1],[18,1],[18,3],[13,1],[13,1]],performAction:e(function(t,e,n,s,i,r,o){var a=r.length-1;switch(i){case 1:return r[a-1];case 2:case 3:case 4:case 6:this.$=[];break;case 5:case 35:r[a-1].push(r[a]),this.$=r[a-1];break;case 7:case 22:case 32:case 36:case 37:case 38:case 39:case 40:case 43:case 44:this.$=r[a];break;case 8:s.setDiagramTitle(r[a].substr(6)),this.$=r[a].substr(6);break;case 9:s.addSubsetData([r[a]],void 0,void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 10:s.addSubsetData([r[a-1]],r[a],void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 11:s.addSubsetData([r[a-2]],void 0,parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 12:s.addSubsetData([r[a-3]],r[a-2],parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 13:if(r[a].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a]),s.addSubsetData(r[a],void 0,void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 14:if(r[a-1].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-1]),s.addSubsetData(r[a-1],r[a],void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 15:if(r[a-2].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-2]),s.addSubsetData(r[a-2],void 0,parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 16:if(r[a-3].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-3]),s.addSubsetData(r[a-3],r[a-2],parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 17:case 18:case 19:s.addTextData(r[a-1],r[a],void 0);break;case 20:case 21:s.addTextData(r[a-2],r[a-1],r[a]);break;case 23:s.addStyleData(r[a-1],r[a]);break;case 24:case 25:case 26:if(!(l=s.getCurrentSets()))throw new Error("text requires set");s.addTextData(l,r[a],void 0);break;case 27:case 28:var l;if(!(l=s.getCurrentSets()))throw new Error("text requires set");s.addTextData(l,r[a-1],r[a]);break;case 29:case 41:case 34:this.$=[r[a]];break;case 30:case 42:this.$=[...r[a-2],r[a]];break;case 31:this.$=[r[a-2],r[a]];break;case 33:this.$=r[a].join(" ")}},"anonymous"),table:[t(n,[2,2],{3:1,4:2}),{1:[3]},{5:[1,3],8:[1,4]},t(s,[2,4],{6:5}),t(n,[2,3]),{7:[1,6],8:[1,8],9:7,10:9,11:[1,10],12:[1,11],17:[1,12],19:[1,13],22:[1,14],24:[1,15]},{1:[2,1]},t(s,[2,5]),t(s,[2,6]),t(s,[2,7]),t(s,[2,8]),{13:16,20:i,21:r},{13:20,18:19,20:i,21:r},{13:20,18:21,20:i,21:r},{16:[1,25],20:[1,23],21:[1,24],23:22},{13:20,18:26,20:i,21:r},t(s,[2,9],{14:[1,27],15:[1,28]}),t(o,[2,43]),t(o,[2,44]),t(s,[2,13],{14:[1,29],15:[1,30],27:a}),t(o,[2,41]),{16:[1,34],20:[1,32],21:[1,33],27:a},t(s,[2,22]),t(s,[2,24],{14:[1,35]}),t(s,[2,25],{14:[1,36]}),t(s,[2,26]),{20:l,25:37,26:38,27:a},t(s,[2,10],{15:[1,40]}),{16:[1,41]},t(s,[2,14],{15:[1,42]}),{16:[1,43]},{13:44,20:i,21:r},t(s,[2,17],{14:[1,45]}),t(s,[2,18],{14:[1,46]}),t(s,[2,19]),t(s,[2,27]),t(s,[2,28]),t(s,[2,23],{27:[1,47]}),t(c,[2,29]),{15:[1,48]},{16:[1,49]},t(s,[2,11]),{16:[1,50]},t(s,[2,15]),t(o,[2,42]),t(s,[2,20]),t(s,[2,21]),{20:l,26:51},{16:h,20:u,21:[1,53],28:52,29:54,30:55,31:f,32:d,33:y},t(s,[2,12]),t(s,[2,16]),t(c,[2,30]),t(c,[2,31]),t(c,[2,32]),t(c,[2,33],{30:61,16:h,20:u,31:f,32:d,33:y}),t(g,[2,34]),t(g,[2,36]),t(g,[2,37]),t(g,[2,38]),t(g,[2,39]),t(g,[2,40]),t(g,[2,35])],defaultActions:{6:[2,1]},parseError:e(function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t)},"parseError"),parse:e(function(t){var n=this,s=[0],i=[],r=[null],o=[],a=this.table,l="",c=0,h=0,u=o.slice.call(arguments,1),f=Object.create(this.lexer),d={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(d.yy[y]=this.yy[y]);f.setInput(t,d.yy),d.yy.lexer=f,d.yy.parser=this,void 0===f.yylloc&&(f.yylloc={});var g=f.yylloc;o.push(g);var p=f.options&&f.options.ranges;function x(){var t;return"number"!=typeof(t=i.pop()||f.lex()||1)&&(t instanceof Array&&(t=(i=t).pop()),t=n.symbols_[t]||t),t}"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,e(function(t){s.length=s.length-2*t,r.length=r.length-t,o.length=o.length-t},"popStack"),e(x,"lex");for(var m,b,v,I,M,k,w,_,S={};;){if(b=s[s.length-1],this.defaultActions[b]?v=this.defaultActions[b]:(null==m&&(m=x()),v=a[b]&&a[b][m]),void 0===v||!v.length||!v[0]){var E;for(M in _=[],a[b])this.terminals_[M]&&M>2&&_.push("'"+this.terminals_[M]+"'");E=f.showPosition?"Parse error on line "+(c+1)+":\n"+f.showPosition()+"\nExpecting "+_.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(c+1)+": Unexpected "+(1==m?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(E,{text:f.match,token:this.terminals_[m]||m,line:f.yylineno,loc:g,expected:_})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+m);switch(v[0]){case 1:s.push(m),r.push(f.yytext),o.push(f.yylloc),s.push(v[1]),m=null,h=f.yyleng,l=f.yytext,c=f.yylineno,g=f.yylloc;break;case 2:if(k=this.productions_[v[1]][1],S.$=r[r.length-k],S._$={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},p&&(S._$.range=[o[o.length-(k||1)].range[0],o[o.length-1].range[1]]),void 0!==(I=this.performAction.apply(S,[l,h,c,d.yy,v[1],r,o].concat(u))))return I;k&&(s=s.slice(0,-1*k*2),r=r.slice(0,-1*k),o=o.slice(0,-1*k)),s.push(this.productions_[v[1]][0]),r.push(S.$),o.push(S._$),w=a[s[s.length-2]][s[s.length-1]],s.push(w);break;case 3:return!0}}return!0},"parse")},x=function(){return{EOF:1,parseError:e(function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},"parseError"),setInput:e(function(t,e){return this.yy=e||this.yy||{},this._input=t,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 t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.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),t},"input"),unput:e(function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var s=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===s.length?this.yylloc.first_column:0)+s[s.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},"unput"),more:e(function(){return this._more=!0,this},"more"),reject:e(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):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).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:e(function(t){this.unput(this.match.slice(t))},"less"),pastInput:e(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:e(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:e(function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},"showPosition"),test_match:e(function(t,e){var n,s,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var r in i)this[r]=i[r];return!1}return!1},"test_match"),next:e(function(){if(this.done)return this.EOF;var t,e,n,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),r=0;r<i.length;r++)if((n=this._input.match(this.rules[i[r]]))&&(!e||n[0].length>e[0].length)){if(e=n,s=r,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[r])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[s]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:e(function(){return this.next()||this.lex()},"lex"),begin:e(function(t){this.conditionStack.push(t)},"begin"),popState:e(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:e(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:e(function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},"topState"),pushState:e(function(t){this.begin(t)},"pushState"),stateStackSize:e(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:e(function(t,e,n,s){switch(n){case 0:case 1:case 2:case 4:case 7:case 8:break;case 3:if(t.getIndentMode&&t.getIndentMode())return t.consumeIndentText=!0,this.begin("INITIAL"),22;break;case 5:t.setIndentMode&&t.setIndentMode(!1),this.begin("INITIAL"),this.unput(e.yytext);break;case 6:return this.begin("bol"),8;case 9:return 7;case 10:return 11;case 11:return 5;case 12:return 12;case 13:return 17;case 14:if(!t.consumeIndentText)return 19;t.consumeIndentText=!1;break;case 15:return 24;case 16:return e.yytext=e.yytext.slice(2,-2),14;case 17:return e.yytext=e.yytext.slice(1,-1).trim(),14;case 18:return 16;case 19:return 31;case 20:return 33;case 21:return 32;case 22:return 20;case 23:return 21;case 24:return 27;case 25:return 15}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[ \t]+(?=[\n\r]))/i,/^(?:[ \t]+(?=text\b))/i,/^(?:[ \t]+)/i,/^(?:[^ \t\n\r])/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[ \t]+)/i,/^(?:$)/i,/^(?:title\s[^#\n;]+)/i,/^(?:venn-beta\b)/i,/^(?:set\b)/i,/^(?:union\b)/i,/^(?:text\b)/i,/^(?:style\b)/i,/^(?:\["[^\"]*"\])/i,/^(?:\[[^\]\"]+\])/i,/^(?:[+-]?(\d+(\.\d+)?|\.\d+))/i,/^(?:#[0-9a-fA-F]{3,8})/i,/^(?:rgba\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:rgb\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,/^(?:"[^\"]*")/i,/^(?:,)/i,/^(?::)/i],conditions:{bol:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0},INITIAL:{rules:[0,1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0}}}}();function m(){this.yy={}}return p.lexer=x,e(m,"Parser"),m.prototype=p,p.Parser=m,new m}();tt.parser=tt;var et,nt=tt,st=[],it=[],rt=[],ot=new Set,at=!1,lt=e((t,e,n)=>{const s=gt(t).sort(),i=n??10/Math.pow(t.length,2);et=s,1===s.length&&ot.add(s[0]),st.push({sets:s,size:i,label:e?ht(e):void 0})},"addSubsetData"),ct=e(()=>st,"getSubsetData"),ht=e(t=>{const e=t.trim();return e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e},"normalizeText"),ut=e(t=>t?ht(t):t,"normalizeStyleValue"),ft=e((t,e,n)=>{const s=ht(e);it.push({sets:gt(t).sort(),id:s,label:n?ht(n):void 0})},"addTextData"),dt=e((t,e)=>{const n=gt(t).sort(),s={};for(const[i,r]of e)s[i]=ut(r)??r;rt.push({targets:n,styles:s})},"addStyleData"),yt=e(()=>rt,"getStyleData"),gt=e(t=>t.map(t=>ht(t)),"normalizeIdentifierList"),pt=e(t=>{const e=gt(t).filter(t=>!ot.has(t));if(e.length>0)throw new Error(`unknown set identifier: ${e.join(", ")}`)},"validateUnionIdentifiers"),xt=e(()=>it,"getTextData"),mt=e(()=>et,"getCurrentSets"),bt=e(()=>at,"getIndentMode"),vt=e(t=>{at=t},"setIndentMode"),It=m.venn;function Mt(){return x(It,l().venn)}e(Mt,"getConfig");var kt={getConfig:Mt,clear:e(()=>{p(),st.length=0,it.length=0,rt.length=0,ot.clear(),et=void 0,at=!1},"customClear"),setAccTitle:a,getAccTitle:o,setDiagramTitle:r,getDiagramTitle:i,getAccDescription:s,setAccDescription:n,addSubsetData:lt,getSubsetData:ct,addTextData:ft,addStyleData:dt,validateUnionIdentifiers:pt,getTextData:xt,getStyleData:yt,getCurrentSets:mt,getIndentMode:bt,setIndentMode:vt},wt=e(t=>`\n .venn-title {\n font-size: 32px;\n fill: ${t.vennTitleTextColor};\n font-family: ${t.fontFamily};\n }\n\n .venn-circle text {\n font-size: 48px;\n font-family: ${t.fontFamily};\n }\n\n .venn-intersection text {\n font-size: 48px;\n fill: ${t.vennSetTextColor};\n font-family: ${t.fontFamily};\n }\n\n .venn-text-node {\n font-family: ${t.fontFamily};\n color: ${t.vennSetTextColor};\n }\n`,"getStyles");function _t(t){const e=new Map;for(const n of t){const t=n.targets.join("|"),s=e.get(t);s?Object.assign(s,n.styles):e.set(t,{...n.styles})}return e}e(_t,"buildStyleByKey");var St=e((t,e,n,s)=>{const i=s.db,r=i.getConfig?.(),{themeVariables:o,look:a,handDrawnSeed:p}=l(),x="handDrawn"===a,m=[o.venn1,o.venn2,o.venn3,o.venn4,o.venn5,o.venn6,o.venn7,o.venn8].filter(Boolean),v=i.getDiagramTitle?.(),I=i.getSubsetData(),M=i.getTextData(),k=_t(i.getStyleData()),w=zt(I),_=r?.width??800,S=r?.height??450,E=_/1600,T=v?48*E:0,z=o.primaryTextColor??o.textColor,A=c(e);A.attr("viewBox",`0 0 ${_} ${S}`),v&&A.append("text").text(v).attr("class","venn-title").attr("font-size",32*E+"px").attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x","50%").attr("y",32*E).style("fill",o.vennTitleTextColor||o.titleColor);const R=h(document.createElement("div")),N=function(t={}){let e=!1,n=600,s=350,i=15,r=1e3,o=Math.PI/2,a=!0,l=null,c=!0,h=!0,u=null,f=null,d=!1,y=null,g=!(!t||!t.symmetricalTextCentre)&&t.symmetricalTextCentre,p={},x=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=0,b=function(t){if(t in p)return p[t];var e=p[t]=x[m];return m+=1,m>=x.length&&(m=0),e},v=j,I=P;function M(p){let x=p.datum();const m=new Set;x.forEach(t=>{0==t.size&&1==t.sets.length&&m.add(t.sets[0])}),x=x.filter(t=>!t.sets.some(t=>m.has(t)));let M={},k={};if(x.length>0){let t=v(x,{lossFunction:I,distinct:d});a&&(t=U(t,o,f)),M=G(t,n,s,i,l),k=Z(M,x,g)}const w={};function _(t){return t.sets in w?w[t.sets]:1==t.sets.length?""+t.sets[0]:void 0}x.forEach(t=>{t.label&&(w[t.sets]=t.label)}),p.selectAll("svg").data([M]).enter().append("svg");const S=p.select("svg");e?S.attr("viewBox",`0 0 ${n} ${s}`):S.attr("width",n).attr("height",s);const E={};let T=!1;function z(t){return e=>J(t.sets.map(t=>{let i=E[t],r=M[t];return i||(i={x:n/2,y:s/2,radius:1}),r||(r={x:n/2,y:s/2,radius:1}),{x:i.x*(1-e)+r.x*e,y:i.y*(1-e)+r.y*e,radius:i.radius*(1-e)+r.radius*e}}),y)}S.selectAll(".venn-area path").each(function(t){const e=this.getAttribute("d");1==t.sets.length&&e&&!d&&(T=!0,E[t.sets[0]]=function(t){const e=t.split(" ");return{x:Number.parseFloat(e[1]),y:Number.parseFloat(e[2]),radius:-Number.parseFloat(e[4])}}(e))});const A=S.selectAll(".venn-area").data(x,t=>t.sets),R=A.enter().append("g").attr("class",t=>`venn-area venn-${1==t.sets.length?"circle":"intersection"}${t.colour||t.color?" venn-coloured":""}`).attr("data-venn-sets",t=>t.sets.join("_")),N=R.append("path"),D=R.append("text").attr("class","label").text(t=>_(t)).attr("text-anchor","middle").attr("dy",".35em").attr("x",n/2).attr("y",s/2);function O(t){return"function"==typeof t.transition?t.transition("venn").duration(r):t}h&&(N.style("fill-opacity","0").filter(t=>1==t.sets.length).style("fill",t=>t.colour?t.colour:t.color?t.color:b(t.sets)).style("fill-opacity",".25"),D.style("fill",e=>e.colour||e.color?"#FFF":t.textFill?t.textFill:1==e.sets.length?b(e.sets):"#444"));let j=p;T&&"function"==typeof j.transition?(j=O(p),j.selectAll("path").attrTween("d",z)):j.selectAll("path").attr("d",t=>J(t.sets.map(t=>M[t])),y);const F=j.selectAll("text").filter(t=>t.sets in k).text(t=>_(t)).attr("x",t=>Math.floor(k[t.sets].x)).attr("y",t=>Math.floor(k[t.sets].y));c&&(T?"on"in F?F.on("end",X(M,_)):F.each("end",X(M,_)):F.each(X(M,_)));const C=O(A.exit()).remove();"function"==typeof A.transition&&C.selectAll("path").attrTween("d",z);const $=C.selectAll("text").attr("x",n/2).attr("y",s/2);return null!==u&&(D.style("font-size","0px"),F.style("font-size",u),$.style("font-size","0px")),{circles:M,textCentres:k,nodes:A,enter:R,update:j,exit:C}}return M.wrap=function(t){return arguments.length?(c=t,M):c},M.useViewBox=function(){return e=!0,M},M.width=function(t){return arguments.length?(n=t,M):n},M.height=function(t){return arguments.length?(s=t,M):s},M.padding=function(t){return arguments.length?(i=t,M):i},M.distinct=function(t){return arguments.length?(d=t,M):d},M.colours=function(t){return arguments.length?(b=t,M):b},M.colors=function(t){return arguments.length?(b=t,M):b},M.fontSize=function(t){return arguments.length?(u=t,M):u},M.round=function(t){return arguments.length?(y=t,M):y},M.duration=function(t){return arguments.length?(r=t,M):r},M.layoutFunction=function(t){return arguments.length?(v=t,M):v},M.normalize=function(t){return arguments.length?(a=t,M):a},M.scaleToFit=function(t){return arguments.length?(l=t,M):l},M.styled=function(t){return arguments.length?(h=t,M):h},M.orientation=function(t){return arguments.length?(o=t,M):o},M.orientationOrder=function(t){return arguments.length?(f=t,M):f},M.lossFunction=function(t){return arguments.length?(I="default"===t?P:"logRatio"===t?L:t,M):I},M}().width(_).height(S-T);R.datum(w).call(N);const D=x?u.svg(R.select("svg").node()):void 0,O=function(t,e={}){const{lossFunction:n,layoutFunction:s=j,normalize:i=!0,orientation:r=Math.PI/2,orientationOrder:o,width:a=600,height:l=350,padding:c=15,scaleToFit:h=!1,symmetricalTextCentre:u=!1,distinct:f,round:d=2}=e;let y=s(t,{lossFunction:"default"!==n&&n?"logRatio"===n?L:n:P,distinct:f});i&&(y=U(y,r,o));const g=G(y,a,l,c,h),p=Z(g,t,u),x=new Map(Object.keys(g).map(t=>[t,{set:t,x:g[t].x,y:g[t].y,radius:g[t].radius}])),m=t.map(t=>{const e=t.sets.map(t=>x.get(t)),n=H(e);return{circles:e,arcs:n,path:Q(n,d),area:t,has:new Set(t.sets)}});function b(t){let e="";for(const n of m)n.has.size>t.length&&t.every(t=>n.has.has(t))&&(e+=" "+n.path);return e}return m.map(({circles:t,arcs:e,path:n,area:s})=>({data:s,text:p[s.sets],circles:t,arcs:e,path:n,distinctPath:n+b(s.sets)}))}(w,{width:_,height:S-T,padding:r?.padding??15}),F=new Map;for(const l of O){const t=Et([...l.data.sets].sort());F.set(t,l)}M.length>0&&Tt(r,F,R,M,E,k);const C=f(o.background||"#f4f4f4");R.selectAll(".venn-circle").each(function(t,e){const n=h(this),s=Et([...t.sets].sort()),i=k.get(s),r=i?.fill||m[e%m.length]||o.primaryColor;n.classed("venn-set-"+e%8,!0);const a=i?.["fill-opacity"]??.1,l=i?.stroke||r,c=i?.["stroke-width"]||""+5*E;if(x&&D){const t=F.get(s);if(t&&t.circles.length>0){const s=t.circles[0],i=D.circle(s.x,s.y,2*s.radius,{roughness:.7,seed:p,fill:b(r,.7),fillStyle:"hachure",fillWeight:2,hachureGap:8,hachureAngle:60*e-41,stroke:l,strokeWidth:parseFloat(String(c))});n.select("path").remove(),n.node()?.insertBefore(i,n.select("text").node())}}else n.select("path").style("fill",r).style("fill-opacity",a).style("stroke",l).style("stroke-width",c).style("stroke-opacity",.95);const u=i?.color||(C?d(r,30):y(r,30));n.select("text").style("font-size",48*E+"px").style("fill",u)}),x&&D?R.selectAll(".venn-intersection").each(function(t){const e=h(this),n=Et([...t.sets].sort()),s=k.get(n),i=s?.fill;if(i){const t=e.select("path"),n=t.attr("d");if(n){const e=D.path(n,{roughness:.7,seed:p,fill:b(i,.3),fillStyle:"cross-hatch",fillWeight:2,hachureGap:6,hachureAngle:60,stroke:"none"}),s=t.node();s?.parentNode?.insertBefore(e,s),t.remove()}}else e.select("path").style("fill-opacity",0);e.select("text").style("font-size",48*E+"px").style("fill",s?.color??o.vennSetTextColor??z)}):(R.selectAll(".venn-intersection text").style("font-size",48*E+"px").style("fill",t=>{const e=Et([...t.sets].sort());return k.get(e)?.color??o.vennSetTextColor??z}),R.selectAll(".venn-intersection path").style("fill-opacity",t=>{const e=Et([...t.sets].sort());return k.get(e)?.fill?1:0}).style("fill",t=>{const e=Et([...t.sets].sort());return k.get(e)?.fill??"transparent"}));const $=A.append("g").attr("transform",`translate(0, ${T})`),q=R.select("svg").node();if(q&&"childNodes"in q)for(const l of[...q.childNodes])$.node()?.appendChild(l);g(A,S,_,r?.useMaxWidth??!0)},"draw");function Et(t){return t.join("|")}function Tt(t,e,n,s,i,r){const o=t?.useDebugLayout??!1,a=n.select("svg").append("g").attr("class","venn-text-nodes"),l=new Map;for(const c of s){const t=Et(c.sets),e=l.get(t);e?e.push(c):l.set(t,[c])}for(const[c,h]of l.entries()){const t=e.get(c);if(!t?.text)continue;const n=t.text.x,s=t.text.y,l=Math.min(...t.circles.map(t=>t.radius)),u=Math.min(...t.circles.map(t=>t.radius-Math.hypot(n-t.x,s-t.y)));let f=Number.isFinite(u)?Math.max(0,u):0;0===f&&Number.isFinite(l)&&(f=.6*l);const d=a.append("g").attr("class","venn-text-area").attr("font-size",40*i+"px");o&&d.append("circle").attr("class","venn-text-debug-circle").attr("cx",n).attr("cy",s).attr("r",f).attr("fill","none").attr("stroke","purple").attr("stroke-width",1.5*i).attr("stroke-dasharray",`${6*i} ${4*i}`);const y=Math.max(80*i,2*f*.95),g=Math.max(60*i,2*f*.95),p=(t.data.label&&t.data.label.length>0?Math.min(32*i,.25*f):0)+(h.length<=2?30*i:0),x=n-y/2,m=s-g/2+p,b=Math.max(1,Math.ceil(Math.sqrt(h.length))),v=y/b,I=g/Math.max(1,Math.ceil(h.length/b));for(const[e,a]of h.entries()){const t=e%b,n=Math.floor(e/b),s=x+v*(t+.5),l=m+I*(n+.5);o&&d.append("rect").attr("class","venn-text-debug-cell").attr("x",x+v*t).attr("y",m+I*n).attr("width",v).attr("height",I).attr("fill","none").attr("stroke","teal").attr("stroke-width",1*i).attr("stroke-dasharray",`${4*i} ${3*i}`);const c=.9*v,h=.9*I,u=d.append("foreignObject").attr("class","venn-text-node-fo").attr("width",c).attr("height",h).attr("x",s-c/2).attr("y",l-h/2).attr("overflow","visible"),f=r.get(a.id)?.color,y=u.append("xhtml:span").attr("class","venn-text-node").style("display","flex").style("width","100%").style("height","100%").style("white-space","normal").style("align-items","center").style("justify-content","center").style("text-align","center").style("overflow-wrap","normal").style("word-break","normal").text(a.label??a.id);f&&y.style("color",f)}}}function zt(t){const e=new Set(t.map(t=>[...t.sets].sort().join("|"))),n=new Map(t.filter(t=>1===t.sets.length&&void 0!==t.size).map(t=>[t.sets[0],t.size])),s=[];for(const i of t){if(i.sets.length<3)continue;const t=[...i.sets].sort();for(let i=0;i<t.length-1;i++)for(let r=i+1;r<t.length;r++){const o=[t[i],t[r]],a=o.join("|");if(!e.has(a)){e.add(a);const t=n.get(o[0]),i=n.get(o[1]),r=void 0!==t&&void 0!==i?Math.min(t,i)/4:2.5;s.push({sets:o,size:r,label:""})}}}return s.length>0?[...t,...s]:t}e(Et,"stableSetsKey"),e(Tt,"renderTextNodes"),e(zt,"ensurePairwiseSubsets");var At={parser:nt,db:kt,renderer:{draw:St},styles:wt};export{At as diagram};
1
+ import{b3 as t,_ as e,s as n,g as s,p as i,o as r,a as o,b as a,z as l,F as c,d as h,ak as u,a9 as f,aa as d,ab as y,e as g,q as p,B as x,D as m}from"./mermaid.core-Cqy39_Ub.js";import"./RemoteLifeOSBlock-B5kU_35n.js";import"./index-DUrY8OKv.js";import"./purify.es-BNLkGfTg.js";import"./marked.esm-BBjA1da9.js";import"./index-D0cZ64pO.js";import"./index-D0cm1aa-.js";import"./file-editor-index-C6CU7Fik.js";import"./App-NMmWfGoY.js";import"./chevron-up-d3Fwun7t.js";import"./__vite-browser-external-2447137e-DZMxqW1v.js";const b=(e,n)=>t(e,"a",-n);function v(t,e){const n=function(t){const e=[];for(let n=0;n<t.length;++n)for(let s=n+1;s<t.length;++s){const i=w(t[n],t[s]);for(const t of i)t.parentIndex=[n,s],e.push(t)}return e}(t),s=n.filter(e=>function(t,e){return e.every(e=>M(t,e)<e.radius+1e-10)}(e,t));let i=0,r=0;const o=[];if(s.length>1){const e=_(s);for(let t=0;t<s.length;++t){const n=s[t];n.angle=Math.atan2(n.x-e.x,n.y-e.y)}s.sort((t,e)=>e.angle-t.angle);let n=s[s.length-1];for(let a=0;a<s.length;++a){const e=s[a];r+=(n.x+e.x)*(e.y-n.y);const l={x:(e.x+n.x)/2,y:(e.y+n.y)/2};let c=null;for(let s=0;s<e.parentIndex.length;++s)if(n.parentIndex.includes(e.parentIndex[s])){const i=t[e.parentIndex[s]],r=Math.atan2(e.x-i.x,e.y-i.y),o=Math.atan2(n.x-i.x,n.y-i.y);let a=o-r;a<0&&(a+=2*Math.PI);const h=o-a/2;let u=M(l,{x:i.x+i.radius*Math.sin(h),y:i.y+i.radius*Math.cos(h)});u>2*i.radius&&(u=2*i.radius),(null==c||c.width>u)&&(c={circle:i,width:u,p1:e,p2:n,large:u>i.radius,sweep:!0})}null!=c&&(o.push(c),i+=I(c.circle.radius,c.width),n=e)}}else{let e=t[0];for(let s=1;s<t.length;++s)t[s].radius<e.radius&&(e=t[s]);let n=!1;for(let s=0;s<t.length;++s)if(M(t[s],e)>Math.abs(e.radius-t[s].radius)){n=!0;break}n?i=r=0:(i=e.radius*e.radius*Math.PI,o.push({circle:e,p1:{x:e.x,y:e.y+e.radius},p2:{x:e.x-1e-10,y:e.y+e.radius},width:2*e.radius,large:!0,sweep:!0}))}return r/=2,e&&(e.area=i+r,e.arcArea=i,e.polygonArea=r,e.arcs=o,e.innerPoints=s,e.intersectionPoints=n),i+r}function I(t,e){return t*t*Math.acos(1-e/t)-(t-e)*Math.sqrt(e*(2*t-e))}function M(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function k(t,e,n){if(n>=t+e)return 0;if(n<=Math.abs(t-e))return Math.PI*Math.min(t,e)*Math.min(t,e);const s=e-(n*n-t*t+e*e)/(2*n);return I(t,t-(n*n-e*e+t*t)/(2*n))+I(e,s)}function w(t,e){const n=M(t,e),s=t.radius,i=e.radius;if(n>=s+i||n<=Math.abs(s-i))return[];const r=(s*s-i*i+n*n)/(2*n),o=Math.sqrt(s*s-r*r),a=t.x+r*(e.x-t.x)/n,l=t.y+r*(e.y-t.y)/n,c=-(e.y-t.y)*(o/n),h=-(e.x-t.x)*(o/n);return[{x:a+c,y:l-h},{x:a-c,y:l+h}]}function _(t){const e={x:0,y:0};for(const n of t)e.x+=n.x,e.y+=n.y;return e.x/=t.length,e.y/=t.length,e}function S(t){const e=new Array(t);for(let n=0;n<t;++n)e[n]=0;return e}function E(t,e){return S(t).map(()=>S(e))}function T(t,e){let n=0;for(let s=0;s<t.length;++s)n+=t[s]*e[s];return n}function z(t){return Math.sqrt(T(t,t))}function A(t,e,n){for(let s=0;s<e.length;++s)t[s]=e[s]*n}function R(t,e,n,s,i){for(let r=0;r<t.length;++r)t[r]=e*n[r]+s*i[r]}function N(t,e,n){const s=(n=n||{}).maxIterations||200*e.length,i=n.nonZeroDelta||1.05,r=n.zeroDelta||.001,o=n.minErrorDelta||1e-6,a=n.minErrorDelta||1e-5,l=void 0!==n.rho?n.rho:1,c=void 0!==n.chi?n.chi:2,h=void 0!==n.psi?n.psi:-.5,u=void 0!==n.sigma?n.sigma:.5;let f;const d=e.length,y=new Array(d+1);y[0]=e,y[0].fx=t(e),y[0].id=0;for(let I=0;I<d;++I){const n=e.slice();n[I]=n[I]?n[I]*i:r,y[I+1]=n,y[I+1].fx=t(n),y[I+1].id=I+1}function g(t){for(let e=0;e<t.length;e++)y[d][e]=t[e];y[d].fx=t.fx}const p=(t,e)=>t.fx-e.fx,x=e.slice(),m=e.slice(),b=e.slice(),v=e.slice();for(let I=0;I<s;++I){if(y.sort(p),n.history){const t=y.map(t=>{const e=t.slice();return e.fx=t.fx,e.id=t.id,e});t.sort((t,e)=>t.id-e.id),n.history.push({x:y[0].slice(),fx:y[0].fx,simplex:t})}f=0;for(let t=0;t<d;++t)f=Math.max(f,Math.abs(y[0][t]-y[1][t]));if(Math.abs(y[0].fx-y[d].fx)<o&&f<a)break;for(let t=0;t<d;++t){x[t]=0;for(let e=0;e<d;++e)x[t]+=y[e][t];x[t]/=d}const e=y[d];if(R(m,1+l,x,-l,e),m.fx=t(m),m.fx<y[0].fx)R(v,1+c,x,-c,e),v.fx=t(v),v.fx<m.fx?g(v):g(m);else if(m.fx>=y[d-1].fx){let n=!1;if(m.fx>e.fx?(R(b,1+h,x,-h,e),b.fx=t(b),b.fx<e.fx?g(b):n=!0):(R(b,1-h*l,x,h*l,e),b.fx=t(b),b.fx<m.fx?g(b):n=!0),n){if(u>=1)break;for(let e=1;e<y.length;++e)R(y[e],1-u,y[0],u,y[e]),y[e].fx=t(y[e])}}else g(m)}return y.sort(p),{fx:y[0].fx,x:y[0]}}function D(t,e,n,s,i,r,o){const a=n.fx,l=T(n.fxprime,e);let c=a,h=a,u=l,f=0;function d(h,f,d){for(let y=0;y<16;++y)if(i=(h+f)/2,R(s.x,1,n.x,i,e),c=s.fx=t(s.x,s.fxprime),u=T(s.fxprime,e),c>a+r*i*l||c>=d)f=i;else{if(Math.abs(u)<=-o*l)return i;u*(f-h)>=0&&(f=h),h=i,d=c}return 0}i=i||1,r=r||1e-6,o=o||.1;for(let y=0;y<10;++y){if(R(s.x,1,n.x,i,e),c=s.fx=t(s.x,s.fxprime),u=T(s.fxprime,e),c>a+r*i*l||y&&c>=h)return d(f,i,h);if(Math.abs(u)<=-o*l)return i;if(u>=0)return d(i,f,c);h=c,f=i,i*=2}return i}function O(t,e,n){let s={x:e.slice(),fx:0,fxprime:e.slice()},i={x:e.slice(),fx:0,fxprime:e.slice()};const r=e.slice();let o,a,l,c=1;l=(n=n||{}).maxIterations||20*e.length,s.fx=t(s.x,s.fxprime),o=s.fxprime.slice(),A(o,s.fxprime,-1);for(let h=0;h<l;++h){if(c=D(t,o,s,i,c),n.history&&n.history.push({x:s.x.slice(),fx:s.fx,fxprime:s.fxprime.slice(),alpha:c}),c){R(r,1,i.fxprime,-1,s.fxprime);const t=T(s.fxprime,s.fxprime);R(o,Math.max(0,T(r,i.fxprime)/t),o,-1,i.fxprime),a=s,s=i,i=a}else A(o,s.fxprime,-1);if(z(s.fxprime)<=1e-5)break}return n.history&&n.history.push({x:s.x.slice(),fx:s.fx,fxprime:s.fxprime.slice(),alpha:c}),s}function j(t,e={}){e.maxIterations=e.maxIterations||500;const n=e.initialLayout||$,s=e.lossFunction||P,i=function(t,e={}){const n=e.distinct,s=t.map(t=>Object.assign({},t));function i(t){return t.join(";")}if(n){const t=new Map;for(const e of s)for(let n=0;n<e.sets.length;n++){const s=String(e.sets[n]);t.set(s,e.size+(t.get(s)||0));for(let i=n+1;i<e.sets.length;i++){const n=String(e.sets[i]),r=`${s};${n}`,o=`${n};${s}`;t.set(r,e.size+(t.get(r)||0)),t.set(o,e.size+(t.get(o)||0))}}for(const e of s)e.sets.length<3&&(e.size=t.get(i(e.sets)))}const r=[],o=new Set;for(const a of s)if(1===a.sets.length)r.push(a.sets[0]);else if(2===a.sets.length){const t=a.sets[0],e=a.sets[1];o.add(i(a.sets)),o.add(i([e,t]))}r.sort((t,e)=>t===e?0:t<e?-1:1);for(let a=0;a<r.length;++a){const t=r[a];for(let e=a+1;e<r.length;++e){const n=r[e];o.has(i([t,n]))||s.push({sets:[t,n],size:0})}}return s}(t,e),r=n(i,e),o=Object.keys(r),a=[];for(const c of o)a.push(r[c].x),a.push(r[c].y);const l=N(t=>{const e={};for(let n=0;n<o.length;++n){const s=o[n];e[s]={x:t[2*n],y:t[2*n+1],radius:r[s].radius}}return s(e,i)},a,e).x;for(let c=0;c<o.length;++c){const t=o[c];r[t].x=l[2*c],r[t].y=l[2*c+1]}return r}const F=1e-10;function C(t,e,n){return Math.min(t,e)*Math.min(t,e)*Math.PI<=n+F?Math.abs(t-e):function(t,e,n,s){const i=(s=s||{}).maxIterations||100,r=s.tolerance||1e-10,o=t(e),a=t(n);let l=n-e;if(o*a>0)throw"Initial bisect points must have opposite signs";if(0===o)return e;if(0===a)return n;for(let c=0;c<i;++c){l/=2;const n=e+l,s=t(n);if(s*o>=0&&(e=n),Math.abs(l)<r||0===s)return n}return e+l}(s=>k(t,e,s)-n,0,t+e)}function $(t,e={}){let n=function(t,e){const n=e&&e.lossFunction?e.lossFunction:P,s={},i={};for(const u of t)if(1===u.sets.length){const t=u.sets[0];s[t]={x:1e10,y:1e10,rowid:s.length,size:u.size,radius:Math.sqrt(u.size/Math.PI)},i[t]=[]}t=t.filter(t=>2===t.sets.length);for(const u of t){let t=null!=u.weight?u.weight:1;const e=u.sets[0],n=u.sets[1];u.size+F>=Math.min(s[e].size,s[n].size)&&(t=0),i[e].push({set:n,size:u.size,weight:t}),i[n].push({set:e,size:u.size,weight:t})}const r=[];function o(t,e){return e.size-t.size}Object.keys(i).forEach(t=>{let e=0;for(let n=0;n<i[t].length;++n)e+=i[t][n].size*i[t][n].weight;r.push({set:t,size:e})}),r.sort(o);const a={};function l(t){return t.set in a}function c(t,e){s[e].x=t.x,s[e].y=t.y,a[e]=!0}c({x:0,y:0},r[0].set);for(let u=1;u<r.length;++u){const e=r[u].set,a=i[e].filter(l),f=s[e];if(a.sort(o),0===a.length)throw"ERROR: missing pairwise overlap information";const d=[];for(var h=0;h<a.length;++h){const t=s[a[h].set],e=C(f.radius,t.radius,a[h].size);d.push({x:t.x+e,y:t.y}),d.push({x:t.x-e,y:t.y}),d.push({y:t.y+e,x:t.x}),d.push({y:t.y-e,x:t.x});for(let n=h+1;n<a.length;++n){const i=s[a[n].set],r=C(f.radius,i.radius,a[n].size),o=w({x:t.x,y:t.y,radius:e},{x:i.x,y:i.y,radius:r});d.push(...o)}}let y=1e50,g=d[0];for(const i of d){s[e].x=i.x,s[e].y=i.y;const r=n(s,t);r<y&&(y=r,g=i)}c(g,e)}return s}(t,e);const s=e.lossFunction||P;if(t.length>=8){const i=function(t,e={}){const n=e.restarts||10,s=[],i={};for(const f of t)1===f.sets.length&&(i[f.sets[0]]=s.length,s.push(f));let{distances:r,constraints:o}=function(t,e,n){const s=E(e.length,e.length),i=E(e.length,e.length);return t.filter(t=>2===t.sets.length).forEach(t=>{const r=n[t.sets[0]],o=n[t.sets[1]],a=C(Math.sqrt(e[r].size/Math.PI),Math.sqrt(e[o].size/Math.PI),t.size);s[r][o]=s[o][r]=a;let l=0;t.size+1e-10>=Math.min(e[r].size,e[o].size)?l=1:t.size<=1e-10&&(l=-1),i[r][o]=i[o][r]=l}),{distances:s,constraints:i}}(t,s,i);const a=z(r.map(z))/r.length;r=r.map(t=>t.map(t=>t/a));const l=(t,e)=>function(t,e,n,s){for(let r=0;r<e.length;++r)e[r]=0;let i=0;for(let r=0;r<n.length;++r){const o=t[2*r],a=t[2*r+1];for(let l=r+1;l<n.length;++l){const c=t[2*l],h=t[2*l+1],u=n[r][l],f=s[r][l],d=(c-o)*(c-o)+(h-a)*(h-a),y=Math.sqrt(d),g=d-u*u;f>0&&y<=u||f<0&&y>=u||(i+=2*g*g,e[2*r]+=4*g*(o-c),e[2*r+1]+=4*g*(a-h),e[2*l]+=4*g*(c-o),e[2*l+1]+=4*g*(h-a))}}return i}(t,e,r,o);let c=null;for(let f=0;f<n;++f){const t=O(l,S(2*r.length).map(Math.random),e);(!c||t.fx<c.fx)&&(c=t)}const h=c.x,u={};for(let f=0;f<s.length;++f){const t=s[f];u[t.sets[0]]={x:h[2*f]*a,y:h[2*f+1]*a,radius:Math.sqrt(t.size/Math.PI)}}if(e.history)for(const f of e.history)A(f.x,a);return u}(t,e);s(i,t)+1e-8<s(n,t)&&(n=i)}return n}function P(t,e){let n=0;for(const s of e){if(1===s.sets.length)continue;let e;if(2===s.sets.length){const n=t[s.sets[0]],i=t[s.sets[1]];e=k(n.radius,i.radius,M(n,i))}else e=v(s.sets.map(e=>t[e]));n+=(null!=s.weight?s.weight:1)*(e-s.size)*(e-s.size)}return n}function L(t,e){let n=0;for(const s of e){if(1===s.sets.length)continue;let e;if(2===s.sets.length){const n=t[s.sets[0]],i=t[s.sets[1]];e=k(n.radius,i.radius,M(n,i))}else e=v(s.sets.map(e=>t[e]));const i=null!=s.weight?s.weight:1,r=Math.log((e+1)/(s.size+1));n+=i*r*r}return n}function q(t,e,n){if(null==n?t.sort((t,e)=>e.radius-t.radius):t.sort(n),t.length>0){const e=t[0].x,n=t[0].y;for(const s of t)s.x-=e,s.y-=n}if(2===t.length&&M(t[0],t[1])<Math.abs(t[1].radius-t[0].radius)&&(t[1].x=t[0].x+t[0].radius-t[1].radius-1e-10,t[1].y=t[0].y),t.length>1){const n=Math.atan2(t[1].x,t[1].y)-e,s=Math.cos(n),i=Math.sin(n);for(const e of t){const t=e.x,n=e.y;e.x=s*t-i*n,e.y=i*t+s*n}}if(t.length>2){let n=Math.atan2(t[2].x,t[2].y)-e;for(;n<0;)n+=2*Math.PI;for(;n>2*Math.PI;)n-=2*Math.PI;if(n>Math.PI){const e=t[1].y/(1e-10+t[1].x);for(const n of t){var s=(n.x+e*n.y)/(1+e*e);n.x=2*s-n.x,n.y=2*s*e-n.y}}}}function B(t){const e=e=>({max:t.reduce((t,n)=>Math.max(t,n[e]+n.radius),Number.NEGATIVE_INFINITY),min:t.reduce((t,n)=>Math.min(t,n[e]-n.radius),Number.POSITIVE_INFINITY)});return{xRange:e("x"),yRange:e("y")}}function U(t,e,n){null==e&&(e=Math.PI/2);let s=V(t).map(t=>Object.assign({},t));const i=function(t){function e(t){return t.parent!==t&&(t.parent=e(t.parent)),t.parent}function n(t,n){const s=e(t),i=e(n);s.parent=i}t.forEach(t=>{t.parent=t});for(let i=0;i<t.length;++i)for(let e=i+1;e<t.length;++e){const s=t[i].radius+t[e].radius;M(t[i],t[e])+1e-10<s&&n(t[e],t[i])}const s=new Map;for(let i=0;i<t.length;++i){const n=e(t[i]).parent.setid;s.has(n)||s.set(n,[]),s.get(n).push(t[i])}return t.forEach(t=>{delete t.parent}),Array.from(s.values())}(s);for(const c of i){q(c,e,n);const t=B(c);c.size=(t.xRange.max-t.xRange.min)*(t.yRange.max-t.yRange.min),c.bounds=t}i.sort((t,e)=>e.size-t.size),s=i[0];let r=s.bounds;const o=(r.xRange.max-r.xRange.min)/50;function a(t,e,n){if(!t)return;const i=t.bounds;let a,l;if(e)a=r.xRange.max-i.xRange.min+o;else{a=r.xRange.max-i.xRange.max;const t=(i.xRange.max-i.xRange.min)/2-(r.xRange.max-r.xRange.min)/2;t<0&&(a+=t)}if(n)l=r.yRange.max-i.yRange.min+o;else{l=r.yRange.max-i.yRange.max;const t=(i.yRange.max-i.yRange.min)/2-(r.yRange.max-r.yRange.min)/2;t<0&&(l+=t)}for(const r of t)r.x+=a,r.y+=l,s.push(r)}let l=1;for(;l<i.length;)a(i[l],!0,!1),a(i[l+1],!1,!0),a(i[l+2],!0,!0),l+=3,r=B(s);return W(s)}function G(t,e,n,s,i){const r=V(t);e-=2*s,n-=2*s;const{xRange:o,yRange:a}=B(r);if(o.max===o.min||a.max===a.min)return console.log("not scaling solution: zero size detected"),t;let l,c;if(i){const t=2*Math.sqrt(i/Math.PI);l=e/t,c=n/t}else l=e/(o.max-o.min),c=n/(a.max-a.min);const h=Math.min(c,l),u=(e-(o.max-o.min)*h)/2,f=(n-(a.max-a.min)*h)/2;return W(r.map(t=>({radius:h*t.radius,x:s+u+(t.x-o.min)*h,y:s+f+(t.y-a.min)*h,setid:t.setid})))}function W(t){const e={};for(const n of t)e[n.setid]=n;return e}function V(t){return Object.keys(t).map(e=>Object.assign(t[e],{setid:e}))}function X(t,e){return function(n){const s=this,i=t[n.sets[0]].radius||50,r=e(n)||"",o=r.split(/\s+/).reverse(),a=(r.length+o.length)/3;let l=o.pop(),c=[l],h=0;s.textContent=null;const u=[];function f(t){const e=s.ownerDocument.createElementNS(s.namespaceURI,"tspan");return e.textContent=t,u.push(e),s.append(e),e}let d=f(l);for(;l=o.pop(),l;){c.push(l);const t=c.join(" ");d.textContent=t,t.length>a&&d.getComputedTextLength()>i&&(c.pop(),d.textContent=c.join(" "),c=[l],d=f(l),h++)}const y=.35-1.1*h/2,g=s.getAttribute("x"),p=s.getAttribute("y");u.forEach((t,e)=>{t.setAttribute("x",g),t.setAttribute("y",p),t.setAttribute("dy",`${y+1.1*e}em`)})}}function K(t,e,n){let s=e[0].radius-M(e[0],t);for(let i=1;i<e.length;++i){const n=e[i].radius-M(e[i],t);n<=s&&(s=n)}for(let i=0;i<n.length;++i){const e=M(n[i],t)-n[i].radius;e<=s&&(s=e)}return s}function Y(t,e,n){const s=[];for(const h of t)s.push({x:h.x,y:h.y}),s.push({x:h.x+h.radius/2,y:h.y}),s.push({x:h.x-h.radius/2,y:h.y}),s.push({x:h.x,y:h.y+h.radius/2}),s.push({x:h.x,y:h.y-h.radius/2});let i=s[0],r=K(s[0],t,e);for(let h=1;h<s.length;++h){const n=K(s[h],t,e);n>=r&&(i=s[h],r=n)}const o=N(n=>-1*K({x:n[0],y:n[1]},t,e),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,a={x:n?0:o[0],y:o[1]};let l=!0;for(const h of t)if(M(a,h)>h.radius){l=!1;break}for(const h of e)if(M(a,h)<h.radius){l=!1;break}if(l)return a;if(1==t.length)return{x:t[0].x,y:t[0].y};const c={};return v(t,c),0===c.arcs.length?{x:0,y:-1e3,disjoint:!0}:1==c.arcs.length?{x:c.arcs[0].circle.x,y:c.arcs[0].circle.y}:e.length?Y(t,[]):_(c.arcs.map(t=>t.p1))}function Z(t,e,n){const s={},i=function(t){const e={},n=Object.keys(t);for(const s of n)e[s]=[];for(let s=0;s<n.length;s++){const i=n[s],r=t[i];for(let o=s+1;o<n.length;++o){const s=n[o],a=t[s],l=M(r,a);l+a.radius<=r.radius+1e-10?e[s].push(i):l+r.radius<=a.radius+1e-10&&e[i].push(s)}}return e}(t);for(let r=0;r<e.length;++r){const o=e[r].sets,a={},l={};for(let t=0;t<o.length;++t){a[o[t]]=!0;const e=i[o[t]];for(let t=0;t<e.length;++t)l[e[t]]=!0}const c=[],h=[];for(let e in t)e in a?c.push(t[e]):e in l||h.push(t[e]);const u=Y(c,h,n);s[o]=u,u.disjoint&&e[r].size>0&&console.log("WARNING: area "+o+" not represented on screen")}return s}function H(t){if(0===t.length)return[];const e={};return v(t,e),e.arcs}function Q(t,e){if(0===t.length)return"M 0 0";const n=Math.pow(10,e||0),s=null!=e?t=>Math.round(t*n)/n:t=>t;if(1==t.length){const e=t[0].circle;return function(t,e,n){const s=[];return s.push("\nM",t,e),s.push("\nm",-n,0),s.push("\na",n,n,0,1,0,2*n,0),s.push("\na",n,n,0,1,0,2*-n,0),s.join(" ")}(s(e.x),s(e.y),s(e.radius))}const i=["\nM",s(t[0].p2.x),s(t[0].p2.y)];for(const r of t){const t=s(r.circle.radius);i.push("\nA",t,t,0,r.large?1:0,r.sweep?1:0,s(r.p1.x),s(r.p1.y))}return i.join(" ")}function J(t,e){return Q(H(t),e)}var tt=function(){var t=e(function(t,e,n,s){for(n=n||{},s=t.length;s--;n[t[s]]=e);return n},"o"),n=[5,8],s=[7,8,11,12,17,19,22,24],i=[1,17],r=[1,18],o=[7,8,11,12,14,15,16,17,19,20,21,22,24,27],a=[1,31],l=[1,39],c=[7,8,11,12,17,19,22,24,27],h=[1,57],u=[1,56],f=[1,58],d=[1,59],y=[1,60],g=[7,8,11,12,16,17,19,20,22,24,27,31,32,33],p={trace:e(function(){},"trace"),yy:{},symbols_:{error:2,start:3,optNewlines:4,VENN:5,document:6,EOF:7,NEWLINE:8,line:9,statement:10,TITLE:11,SET:12,identifier:13,BRACKET_LABEL:14,COLON:15,NUMERIC:16,UNION:17,identifierList:18,TEXT:19,IDENTIFIER:20,STRING:21,INDENT_TEXT:22,indentedTextTail:23,STYLE:24,stylesOpt:25,styleField:26,COMMA:27,styleValue:28,valueTokens:29,valueToken:30,HEXCOLOR:31,RGBCOLOR:32,RGBACOLOR:33,$accept:0,$end:1},terminals_:{2:"error",5:"VENN",7:"EOF",8:"NEWLINE",11:"TITLE",12:"SET",14:"BRACKET_LABEL",15:"COLON",16:"NUMERIC",17:"UNION",19:"TEXT",20:"IDENTIFIER",21:"STRING",22:"INDENT_TEXT",24:"STYLE",27:"COMMA",31:"HEXCOLOR",32:"RGBCOLOR",33:"RGBACOLOR"},productions_:[0,[3,4],[4,0],[4,2],[6,0],[6,2],[9,1],[9,1],[10,1],[10,2],[10,3],[10,4],[10,5],[10,2],[10,3],[10,4],[10,5],[10,3],[10,3],[10,3],[10,4],[10,4],[10,2],[10,3],[23,1],[23,1],[23,1],[23,2],[23,2],[25,1],[25,3],[26,3],[28,1],[28,1],[29,1],[29,2],[30,1],[30,1],[30,1],[30,1],[30,1],[18,1],[18,3],[13,1],[13,1]],performAction:e(function(t,e,n,s,i,r,o){var a=r.length-1;switch(i){case 1:return r[a-1];case 2:case 3:case 4:case 6:this.$=[];break;case 5:case 35:r[a-1].push(r[a]),this.$=r[a-1];break;case 7:case 22:case 32:case 36:case 37:case 38:case 39:case 40:case 43:case 44:this.$=r[a];break;case 8:s.setDiagramTitle(r[a].substr(6)),this.$=r[a].substr(6);break;case 9:s.addSubsetData([r[a]],void 0,void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 10:s.addSubsetData([r[a-1]],r[a],void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 11:s.addSubsetData([r[a-2]],void 0,parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 12:s.addSubsetData([r[a-3]],r[a-2],parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 13:if(r[a].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a]),s.addSubsetData(r[a],void 0,void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 14:if(r[a-1].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-1]),s.addSubsetData(r[a-1],r[a],void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 15:if(r[a-2].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-2]),s.addSubsetData(r[a-2],void 0,parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 16:if(r[a-3].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-3]),s.addSubsetData(r[a-3],r[a-2],parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 17:case 18:case 19:s.addTextData(r[a-1],r[a],void 0);break;case 20:case 21:s.addTextData(r[a-2],r[a-1],r[a]);break;case 23:s.addStyleData(r[a-1],r[a]);break;case 24:case 25:case 26:if(!(l=s.getCurrentSets()))throw new Error("text requires set");s.addTextData(l,r[a],void 0);break;case 27:case 28:var l;if(!(l=s.getCurrentSets()))throw new Error("text requires set");s.addTextData(l,r[a-1],r[a]);break;case 29:case 41:case 34:this.$=[r[a]];break;case 30:case 42:this.$=[...r[a-2],r[a]];break;case 31:this.$=[r[a-2],r[a]];break;case 33:this.$=r[a].join(" ")}},"anonymous"),table:[t(n,[2,2],{3:1,4:2}),{1:[3]},{5:[1,3],8:[1,4]},t(s,[2,4],{6:5}),t(n,[2,3]),{7:[1,6],8:[1,8],9:7,10:9,11:[1,10],12:[1,11],17:[1,12],19:[1,13],22:[1,14],24:[1,15]},{1:[2,1]},t(s,[2,5]),t(s,[2,6]),t(s,[2,7]),t(s,[2,8]),{13:16,20:i,21:r},{13:20,18:19,20:i,21:r},{13:20,18:21,20:i,21:r},{16:[1,25],20:[1,23],21:[1,24],23:22},{13:20,18:26,20:i,21:r},t(s,[2,9],{14:[1,27],15:[1,28]}),t(o,[2,43]),t(o,[2,44]),t(s,[2,13],{14:[1,29],15:[1,30],27:a}),t(o,[2,41]),{16:[1,34],20:[1,32],21:[1,33],27:a},t(s,[2,22]),t(s,[2,24],{14:[1,35]}),t(s,[2,25],{14:[1,36]}),t(s,[2,26]),{20:l,25:37,26:38,27:a},t(s,[2,10],{15:[1,40]}),{16:[1,41]},t(s,[2,14],{15:[1,42]}),{16:[1,43]},{13:44,20:i,21:r},t(s,[2,17],{14:[1,45]}),t(s,[2,18],{14:[1,46]}),t(s,[2,19]),t(s,[2,27]),t(s,[2,28]),t(s,[2,23],{27:[1,47]}),t(c,[2,29]),{15:[1,48]},{16:[1,49]},t(s,[2,11]),{16:[1,50]},t(s,[2,15]),t(o,[2,42]),t(s,[2,20]),t(s,[2,21]),{20:l,26:51},{16:h,20:u,21:[1,53],28:52,29:54,30:55,31:f,32:d,33:y},t(s,[2,12]),t(s,[2,16]),t(c,[2,30]),t(c,[2,31]),t(c,[2,32]),t(c,[2,33],{30:61,16:h,20:u,31:f,32:d,33:y}),t(g,[2,34]),t(g,[2,36]),t(g,[2,37]),t(g,[2,38]),t(g,[2,39]),t(g,[2,40]),t(g,[2,35])],defaultActions:{6:[2,1]},parseError:e(function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t)},"parseError"),parse:e(function(t){var n=this,s=[0],i=[],r=[null],o=[],a=this.table,l="",c=0,h=0,u=o.slice.call(arguments,1),f=Object.create(this.lexer),d={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(d.yy[y]=this.yy[y]);f.setInput(t,d.yy),d.yy.lexer=f,d.yy.parser=this,void 0===f.yylloc&&(f.yylloc={});var g=f.yylloc;o.push(g);var p=f.options&&f.options.ranges;function x(){var t;return"number"!=typeof(t=i.pop()||f.lex()||1)&&(t instanceof Array&&(t=(i=t).pop()),t=n.symbols_[t]||t),t}"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,e(function(t){s.length=s.length-2*t,r.length=r.length-t,o.length=o.length-t},"popStack"),e(x,"lex");for(var m,b,v,I,M,k,w,_,S={};;){if(b=s[s.length-1],this.defaultActions[b]?v=this.defaultActions[b]:(null==m&&(m=x()),v=a[b]&&a[b][m]),void 0===v||!v.length||!v[0]){var E;for(M in _=[],a[b])this.terminals_[M]&&M>2&&_.push("'"+this.terminals_[M]+"'");E=f.showPosition?"Parse error on line "+(c+1)+":\n"+f.showPosition()+"\nExpecting "+_.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(c+1)+": Unexpected "+(1==m?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(E,{text:f.match,token:this.terminals_[m]||m,line:f.yylineno,loc:g,expected:_})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+m);switch(v[0]){case 1:s.push(m),r.push(f.yytext),o.push(f.yylloc),s.push(v[1]),m=null,h=f.yyleng,l=f.yytext,c=f.yylineno,g=f.yylloc;break;case 2:if(k=this.productions_[v[1]][1],S.$=r[r.length-k],S._$={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},p&&(S._$.range=[o[o.length-(k||1)].range[0],o[o.length-1].range[1]]),void 0!==(I=this.performAction.apply(S,[l,h,c,d.yy,v[1],r,o].concat(u))))return I;k&&(s=s.slice(0,-1*k*2),r=r.slice(0,-1*k),o=o.slice(0,-1*k)),s.push(this.productions_[v[1]][0]),r.push(S.$),o.push(S._$),w=a[s[s.length-2]][s[s.length-1]],s.push(w);break;case 3:return!0}}return!0},"parse")},x=function(){return{EOF:1,parseError:e(function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},"parseError"),setInput:e(function(t,e){return this.yy=e||this.yy||{},this._input=t,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 t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.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),t},"input"),unput:e(function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var s=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===s.length?this.yylloc.first_column:0)+s[s.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},"unput"),more:e(function(){return this._more=!0,this},"more"),reject:e(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):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).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:e(function(t){this.unput(this.match.slice(t))},"less"),pastInput:e(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:e(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:e(function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},"showPosition"),test_match:e(function(t,e){var n,s,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var r in i)this[r]=i[r];return!1}return!1},"test_match"),next:e(function(){if(this.done)return this.EOF;var t,e,n,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),r=0;r<i.length;r++)if((n=this._input.match(this.rules[i[r]]))&&(!e||n[0].length>e[0].length)){if(e=n,s=r,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[r])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[s]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:e(function(){return this.next()||this.lex()},"lex"),begin:e(function(t){this.conditionStack.push(t)},"begin"),popState:e(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:e(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:e(function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},"topState"),pushState:e(function(t){this.begin(t)},"pushState"),stateStackSize:e(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:e(function(t,e,n,s){switch(n){case 0:case 1:case 2:case 4:case 7:case 8:break;case 3:if(t.getIndentMode&&t.getIndentMode())return t.consumeIndentText=!0,this.begin("INITIAL"),22;break;case 5:t.setIndentMode&&t.setIndentMode(!1),this.begin("INITIAL"),this.unput(e.yytext);break;case 6:return this.begin("bol"),8;case 9:return 7;case 10:return 11;case 11:return 5;case 12:return 12;case 13:return 17;case 14:if(!t.consumeIndentText)return 19;t.consumeIndentText=!1;break;case 15:return 24;case 16:return e.yytext=e.yytext.slice(2,-2),14;case 17:return e.yytext=e.yytext.slice(1,-1).trim(),14;case 18:return 16;case 19:return 31;case 20:return 33;case 21:return 32;case 22:return 20;case 23:return 21;case 24:return 27;case 25:return 15}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[ \t]+(?=[\n\r]))/i,/^(?:[ \t]+(?=text\b))/i,/^(?:[ \t]+)/i,/^(?:[^ \t\n\r])/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[ \t]+)/i,/^(?:$)/i,/^(?:title\s[^#\n;]+)/i,/^(?:venn-beta\b)/i,/^(?:set\b)/i,/^(?:union\b)/i,/^(?:text\b)/i,/^(?:style\b)/i,/^(?:\["[^\"]*"\])/i,/^(?:\[[^\]\"]+\])/i,/^(?:[+-]?(\d+(\.\d+)?|\.\d+))/i,/^(?:#[0-9a-fA-F]{3,8})/i,/^(?:rgba\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:rgb\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,/^(?:"[^\"]*")/i,/^(?:,)/i,/^(?::)/i],conditions:{bol:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0},INITIAL:{rules:[0,1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0}}}}();function m(){this.yy={}}return p.lexer=x,e(m,"Parser"),m.prototype=p,p.Parser=m,new m}();tt.parser=tt;var et,nt=tt,st=[],it=[],rt=[],ot=new Set,at=!1,lt=e((t,e,n)=>{const s=gt(t).sort(),i=n??10/Math.pow(t.length,2);et=s,1===s.length&&ot.add(s[0]),st.push({sets:s,size:i,label:e?ht(e):void 0})},"addSubsetData"),ct=e(()=>st,"getSubsetData"),ht=e(t=>{const e=t.trim();return e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e},"normalizeText"),ut=e(t=>t?ht(t):t,"normalizeStyleValue"),ft=e((t,e,n)=>{const s=ht(e);it.push({sets:gt(t).sort(),id:s,label:n?ht(n):void 0})},"addTextData"),dt=e((t,e)=>{const n=gt(t).sort(),s={};for(const[i,r]of e)s[i]=ut(r)??r;rt.push({targets:n,styles:s})},"addStyleData"),yt=e(()=>rt,"getStyleData"),gt=e(t=>t.map(t=>ht(t)),"normalizeIdentifierList"),pt=e(t=>{const e=gt(t).filter(t=>!ot.has(t));if(e.length>0)throw new Error(`unknown set identifier: ${e.join(", ")}`)},"validateUnionIdentifiers"),xt=e(()=>it,"getTextData"),mt=e(()=>et,"getCurrentSets"),bt=e(()=>at,"getIndentMode"),vt=e(t=>{at=t},"setIndentMode"),It=m.venn;function Mt(){return x(It,l().venn)}e(Mt,"getConfig");var kt={getConfig:Mt,clear:e(()=>{p(),st.length=0,it.length=0,rt.length=0,ot.clear(),et=void 0,at=!1},"customClear"),setAccTitle:a,getAccTitle:o,setDiagramTitle:r,getDiagramTitle:i,getAccDescription:s,setAccDescription:n,addSubsetData:lt,getSubsetData:ct,addTextData:ft,addStyleData:dt,validateUnionIdentifiers:pt,getTextData:xt,getStyleData:yt,getCurrentSets:mt,getIndentMode:bt,setIndentMode:vt},wt=e(t=>`\n .venn-title {\n font-size: 32px;\n fill: ${t.vennTitleTextColor};\n font-family: ${t.fontFamily};\n }\n\n .venn-circle text {\n font-size: 48px;\n font-family: ${t.fontFamily};\n }\n\n .venn-intersection text {\n font-size: 48px;\n fill: ${t.vennSetTextColor};\n font-family: ${t.fontFamily};\n }\n\n .venn-text-node {\n font-family: ${t.fontFamily};\n color: ${t.vennSetTextColor};\n }\n`,"getStyles");function _t(t){const e=new Map;for(const n of t){const t=n.targets.join("|"),s=e.get(t);s?Object.assign(s,n.styles):e.set(t,{...n.styles})}return e}e(_t,"buildStyleByKey");var St=e((t,e,n,s)=>{const i=s.db,r=i.getConfig?.(),{themeVariables:o,look:a,handDrawnSeed:p}=l(),x="handDrawn"===a,m=[o.venn1,o.venn2,o.venn3,o.venn4,o.venn5,o.venn6,o.venn7,o.venn8].filter(Boolean),v=i.getDiagramTitle?.(),I=i.getSubsetData(),M=i.getTextData(),k=_t(i.getStyleData()),w=zt(I),_=r?.width??800,S=r?.height??450,E=_/1600,T=v?48*E:0,z=o.primaryTextColor??o.textColor,A=c(e);A.attr("viewBox",`0 0 ${_} ${S}`),v&&A.append("text").text(v).attr("class","venn-title").attr("font-size",32*E+"px").attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x","50%").attr("y",32*E).style("fill",o.vennTitleTextColor||o.titleColor);const R=h(document.createElement("div")),N=function(t={}){let e=!1,n=600,s=350,i=15,r=1e3,o=Math.PI/2,a=!0,l=null,c=!0,h=!0,u=null,f=null,d=!1,y=null,g=!(!t||!t.symmetricalTextCentre)&&t.symmetricalTextCentre,p={},x=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=0,b=function(t){if(t in p)return p[t];var e=p[t]=x[m];return m+=1,m>=x.length&&(m=0),e},v=j,I=P;function M(p){let x=p.datum();const m=new Set;x.forEach(t=>{0==t.size&&1==t.sets.length&&m.add(t.sets[0])}),x=x.filter(t=>!t.sets.some(t=>m.has(t)));let M={},k={};if(x.length>0){let t=v(x,{lossFunction:I,distinct:d});a&&(t=U(t,o,f)),M=G(t,n,s,i,l),k=Z(M,x,g)}const w={};function _(t){return t.sets in w?w[t.sets]:1==t.sets.length?""+t.sets[0]:void 0}x.forEach(t=>{t.label&&(w[t.sets]=t.label)}),p.selectAll("svg").data([M]).enter().append("svg");const S=p.select("svg");e?S.attr("viewBox",`0 0 ${n} ${s}`):S.attr("width",n).attr("height",s);const E={};let T=!1;function z(t){return e=>J(t.sets.map(t=>{let i=E[t],r=M[t];return i||(i={x:n/2,y:s/2,radius:1}),r||(r={x:n/2,y:s/2,radius:1}),{x:i.x*(1-e)+r.x*e,y:i.y*(1-e)+r.y*e,radius:i.radius*(1-e)+r.radius*e}}),y)}S.selectAll(".venn-area path").each(function(t){const e=this.getAttribute("d");1==t.sets.length&&e&&!d&&(T=!0,E[t.sets[0]]=function(t){const e=t.split(" ");return{x:Number.parseFloat(e[1]),y:Number.parseFloat(e[2]),radius:-Number.parseFloat(e[4])}}(e))});const A=S.selectAll(".venn-area").data(x,t=>t.sets),R=A.enter().append("g").attr("class",t=>`venn-area venn-${1==t.sets.length?"circle":"intersection"}${t.colour||t.color?" venn-coloured":""}`).attr("data-venn-sets",t=>t.sets.join("_")),N=R.append("path"),D=R.append("text").attr("class","label").text(t=>_(t)).attr("text-anchor","middle").attr("dy",".35em").attr("x",n/2).attr("y",s/2);function O(t){return"function"==typeof t.transition?t.transition("venn").duration(r):t}h&&(N.style("fill-opacity","0").filter(t=>1==t.sets.length).style("fill",t=>t.colour?t.colour:t.color?t.color:b(t.sets)).style("fill-opacity",".25"),D.style("fill",e=>e.colour||e.color?"#FFF":t.textFill?t.textFill:1==e.sets.length?b(e.sets):"#444"));let j=p;T&&"function"==typeof j.transition?(j=O(p),j.selectAll("path").attrTween("d",z)):j.selectAll("path").attr("d",t=>J(t.sets.map(t=>M[t])),y);const F=j.selectAll("text").filter(t=>t.sets in k).text(t=>_(t)).attr("x",t=>Math.floor(k[t.sets].x)).attr("y",t=>Math.floor(k[t.sets].y));c&&(T?"on"in F?F.on("end",X(M,_)):F.each("end",X(M,_)):F.each(X(M,_)));const C=O(A.exit()).remove();"function"==typeof A.transition&&C.selectAll("path").attrTween("d",z);const $=C.selectAll("text").attr("x",n/2).attr("y",s/2);return null!==u&&(D.style("font-size","0px"),F.style("font-size",u),$.style("font-size","0px")),{circles:M,textCentres:k,nodes:A,enter:R,update:j,exit:C}}return M.wrap=function(t){return arguments.length?(c=t,M):c},M.useViewBox=function(){return e=!0,M},M.width=function(t){return arguments.length?(n=t,M):n},M.height=function(t){return arguments.length?(s=t,M):s},M.padding=function(t){return arguments.length?(i=t,M):i},M.distinct=function(t){return arguments.length?(d=t,M):d},M.colours=function(t){return arguments.length?(b=t,M):b},M.colors=function(t){return arguments.length?(b=t,M):b},M.fontSize=function(t){return arguments.length?(u=t,M):u},M.round=function(t){return arguments.length?(y=t,M):y},M.duration=function(t){return arguments.length?(r=t,M):r},M.layoutFunction=function(t){return arguments.length?(v=t,M):v},M.normalize=function(t){return arguments.length?(a=t,M):a},M.scaleToFit=function(t){return arguments.length?(l=t,M):l},M.styled=function(t){return arguments.length?(h=t,M):h},M.orientation=function(t){return arguments.length?(o=t,M):o},M.orientationOrder=function(t){return arguments.length?(f=t,M):f},M.lossFunction=function(t){return arguments.length?(I="default"===t?P:"logRatio"===t?L:t,M):I},M}().width(_).height(S-T);R.datum(w).call(N);const D=x?u.svg(R.select("svg").node()):void 0,O=function(t,e={}){const{lossFunction:n,layoutFunction:s=j,normalize:i=!0,orientation:r=Math.PI/2,orientationOrder:o,width:a=600,height:l=350,padding:c=15,scaleToFit:h=!1,symmetricalTextCentre:u=!1,distinct:f,round:d=2}=e;let y=s(t,{lossFunction:"default"!==n&&n?"logRatio"===n?L:n:P,distinct:f});i&&(y=U(y,r,o));const g=G(y,a,l,c,h),p=Z(g,t,u),x=new Map(Object.keys(g).map(t=>[t,{set:t,x:g[t].x,y:g[t].y,radius:g[t].radius}])),m=t.map(t=>{const e=t.sets.map(t=>x.get(t)),n=H(e);return{circles:e,arcs:n,path:Q(n,d),area:t,has:new Set(t.sets)}});function b(t){let e="";for(const n of m)n.has.size>t.length&&t.every(t=>n.has.has(t))&&(e+=" "+n.path);return e}return m.map(({circles:t,arcs:e,path:n,area:s})=>({data:s,text:p[s.sets],circles:t,arcs:e,path:n,distinctPath:n+b(s.sets)}))}(w,{width:_,height:S-T,padding:r?.padding??15}),F=new Map;for(const l of O){const t=Et([...l.data.sets].sort());F.set(t,l)}M.length>0&&Tt(r,F,R,M,E,k);const C=f(o.background||"#f4f4f4");R.selectAll(".venn-circle").each(function(t,e){const n=h(this),s=Et([...t.sets].sort()),i=k.get(s),r=i?.fill||m[e%m.length]||o.primaryColor;n.classed("venn-set-"+e%8,!0);const a=i?.["fill-opacity"]??.1,l=i?.stroke||r,c=i?.["stroke-width"]||""+5*E;if(x&&D){const t=F.get(s);if(t&&t.circles.length>0){const s=t.circles[0],i=D.circle(s.x,s.y,2*s.radius,{roughness:.7,seed:p,fill:b(r,.7),fillStyle:"hachure",fillWeight:2,hachureGap:8,hachureAngle:60*e-41,stroke:l,strokeWidth:parseFloat(String(c))});n.select("path").remove(),n.node()?.insertBefore(i,n.select("text").node())}}else n.select("path").style("fill",r).style("fill-opacity",a).style("stroke",l).style("stroke-width",c).style("stroke-opacity",.95);const u=i?.color||(C?d(r,30):y(r,30));n.select("text").style("font-size",48*E+"px").style("fill",u)}),x&&D?R.selectAll(".venn-intersection").each(function(t){const e=h(this),n=Et([...t.sets].sort()),s=k.get(n),i=s?.fill;if(i){const t=e.select("path"),n=t.attr("d");if(n){const e=D.path(n,{roughness:.7,seed:p,fill:b(i,.3),fillStyle:"cross-hatch",fillWeight:2,hachureGap:6,hachureAngle:60,stroke:"none"}),s=t.node();s?.parentNode?.insertBefore(e,s),t.remove()}}else e.select("path").style("fill-opacity",0);e.select("text").style("font-size",48*E+"px").style("fill",s?.color??o.vennSetTextColor??z)}):(R.selectAll(".venn-intersection text").style("font-size",48*E+"px").style("fill",t=>{const e=Et([...t.sets].sort());return k.get(e)?.color??o.vennSetTextColor??z}),R.selectAll(".venn-intersection path").style("fill-opacity",t=>{const e=Et([...t.sets].sort());return k.get(e)?.fill?1:0}).style("fill",t=>{const e=Et([...t.sets].sort());return k.get(e)?.fill??"transparent"}));const $=A.append("g").attr("transform",`translate(0, ${T})`),q=R.select("svg").node();if(q&&"childNodes"in q)for(const l of[...q.childNodes])$.node()?.appendChild(l);g(A,S,_,r?.useMaxWidth??!0)},"draw");function Et(t){return t.join("|")}function Tt(t,e,n,s,i,r){const o=t?.useDebugLayout??!1,a=n.select("svg").append("g").attr("class","venn-text-nodes"),l=new Map;for(const c of s){const t=Et(c.sets),e=l.get(t);e?e.push(c):l.set(t,[c])}for(const[c,h]of l.entries()){const t=e.get(c);if(!t?.text)continue;const n=t.text.x,s=t.text.y,l=Math.min(...t.circles.map(t=>t.radius)),u=Math.min(...t.circles.map(t=>t.radius-Math.hypot(n-t.x,s-t.y)));let f=Number.isFinite(u)?Math.max(0,u):0;0===f&&Number.isFinite(l)&&(f=.6*l);const d=a.append("g").attr("class","venn-text-area").attr("font-size",40*i+"px");o&&d.append("circle").attr("class","venn-text-debug-circle").attr("cx",n).attr("cy",s).attr("r",f).attr("fill","none").attr("stroke","purple").attr("stroke-width",1.5*i).attr("stroke-dasharray",`${6*i} ${4*i}`);const y=Math.max(80*i,2*f*.95),g=Math.max(60*i,2*f*.95),p=(t.data.label&&t.data.label.length>0?Math.min(32*i,.25*f):0)+(h.length<=2?30*i:0),x=n-y/2,m=s-g/2+p,b=Math.max(1,Math.ceil(Math.sqrt(h.length))),v=y/b,I=g/Math.max(1,Math.ceil(h.length/b));for(const[e,a]of h.entries()){const t=e%b,n=Math.floor(e/b),s=x+v*(t+.5),l=m+I*(n+.5);o&&d.append("rect").attr("class","venn-text-debug-cell").attr("x",x+v*t).attr("y",m+I*n).attr("width",v).attr("height",I).attr("fill","none").attr("stroke","teal").attr("stroke-width",1*i).attr("stroke-dasharray",`${4*i} ${3*i}`);const c=.9*v,h=.9*I,u=d.append("foreignObject").attr("class","venn-text-node-fo").attr("width",c).attr("height",h).attr("x",s-c/2).attr("y",l-h/2).attr("overflow","visible"),f=r.get(a.id)?.color,y=u.append("xhtml:span").attr("class","venn-text-node").style("display","flex").style("width","100%").style("height","100%").style("white-space","normal").style("align-items","center").style("justify-content","center").style("text-align","center").style("overflow-wrap","normal").style("word-break","normal").text(a.label??a.id);f&&y.style("color",f)}}}function zt(t){const e=new Set(t.map(t=>[...t.sets].sort().join("|"))),n=new Map(t.filter(t=>1===t.sets.length&&void 0!==t.size).map(t=>[t.sets[0],t.size])),s=[];for(const i of t){if(i.sets.length<3)continue;const t=[...i.sets].sort();for(let i=0;i<t.length-1;i++)for(let r=i+1;r<t.length;r++){const o=[t[i],t[r]],a=o.join("|");if(!e.has(a)){e.add(a);const t=n.get(o[0]),i=n.get(o[1]),r=void 0!==t&&void 0!==i?Math.min(t,i)/4:2.5;s.push({sets:o,size:r,label:""})}}}return s.length>0?[...t,...s]:t}e(Et,"stableSetsKey"),e(Tt,"renderTextNodes"),e(zt,"ensurePairwiseSubsets");var At={parser:nt,db:kt,renderer:{draw:St},styles:wt};export{At as diagram};