@pi-outpost/embed 0.61.0 → 0.62.0

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 (149) hide show
  1. package/README.md +4 -0
  2. package/dist/{abnfDiagram-S7VZAUFO-BdOzCXh1.js → abnfDiagram-S7VZAUFO-BvdbTr4n.js} +2 -2
  3. package/dist/{abnfDiagram-S7VZAUFO-zyFnpqZ0.cjs → abnfDiagram-S7VZAUFO-C14iOswH.cjs} +1 -1
  4. package/dist/{architectureDiagram-YGSQEFNW-DiYOcBqo.js → architectureDiagram-YGSQEFNW-CPW5HJ_P.js} +20 -20
  5. package/dist/{architectureDiagram-YGSQEFNW-gEzRb5xY.cjs → architectureDiagram-YGSQEFNW-CfDEcnft.cjs} +3 -3
  6. package/dist/{blockDiagram-APKKGZFW-CIX-8mpK.js → blockDiagram-APKKGZFW-C4ig73DE.js} +5 -5
  7. package/dist/{blockDiagram-APKKGZFW-KL3nQT0s.cjs → blockDiagram-APKKGZFW-DLTDUF2F.cjs} +1 -1
  8. package/dist/{c4Diagram-KJ2TOQU5-BS_M90FN.js → c4Diagram-KJ2TOQU5-BViiS4eZ.js} +4 -4
  9. package/dist/{c4Diagram-KJ2TOQU5-D-dCJWvI.cjs → c4Diagram-KJ2TOQU5-BZrZGJnq.cjs} +1 -1
  10. package/dist/chunk-6MUBBAK2-Do5Y2VaL.js +631 -0
  11. package/dist/chunk-6MUBBAK2-fxSdrddJ.cjs +2 -0
  12. package/dist/{chunk-AXFCVDMN-DrVQa3gP.js → chunk-AXFCVDMN-BTcT9L5T.js} +196 -196
  13. package/dist/{chunk-AXFCVDMN-B6dhmE32.cjs → chunk-AXFCVDMN-DSN0_Pz7.cjs} +7 -7
  14. package/dist/{chunk-DQASFODM-DAaU7yoa.js → chunk-DQASFODM-BjATojAo.js} +30 -30
  15. package/dist/chunk-DQASFODM-GtaZ5zZF.cjs +10 -0
  16. package/dist/{chunk-HFQBQIA3-lOxrhpos.cjs → chunk-HFQBQIA3-Bt4zc3D1.cjs} +1 -1
  17. package/dist/{chunk-HFQBQIA3-DqHSeXIz.js → chunk-HFQBQIA3-l7lNC9FO.js} +1 -1
  18. package/dist/{chunk-KQLB2F66-C7twW9LJ.js → chunk-KQLB2F66-P-DwEW1U.js} +5 -5
  19. package/dist/{chunk-KQLB2F66-Ec2IAtUR.cjs → chunk-KQLB2F66-xBZn8cMv.cjs} +1 -1
  20. package/dist/{chunk-KS47KZWR-OD3AMBe8.js → chunk-KS47KZWR-Ca0eP7K6.js} +1 -1
  21. package/dist/{chunk-KS47KZWR-C7Yv0kfF.cjs → chunk-KS47KZWR-DLYUwvq1.cjs} +1 -1
  22. package/dist/{chunk-LEVMRMFU-BFGXlIAt.cjs → chunk-LEVMRMFU-8QpYqPF4.cjs} +1 -1
  23. package/dist/{chunk-LEVMRMFU-NLMudZfn.js → chunk-LEVMRMFU-DXj_Ks_M.js} +2 -2
  24. package/dist/{chunk-M57EVK23-BSZ7OEGY.cjs → chunk-M57EVK23-Cvl56jvK.cjs} +1 -1
  25. package/dist/{chunk-M57EVK23-C8-Jp43x.js → chunk-M57EVK23-D_qW99As.js} +3 -3
  26. package/dist/{chunk-OY52VR5R-B7NRk2-S.js → chunk-OY52VR5R-DAhIWmSX.js} +1 -1
  27. package/dist/{chunk-OY52VR5R-CvyV3pJF.cjs → chunk-OY52VR5R-DoFojbud.cjs} +1 -1
  28. package/dist/{chunk-QB3YPZ4I-DaIXN7QF.cjs → chunk-QB3YPZ4I-CcobelQp.cjs} +1 -1
  29. package/dist/{chunk-QB3YPZ4I-DPQ26dC9.js → chunk-QB3YPZ4I-DZ4KU0AI.js} +5 -5
  30. package/dist/{chunk-STOXU5M4-0WKKmqbF.js → chunk-STOXU5M4-CcGFpnKt.js} +7 -7
  31. package/dist/{chunk-STOXU5M4-CmoaBap6.cjs → chunk-STOXU5M4-_pvE8f8d.cjs} +2 -2
  32. package/dist/{classDiagram-v2-L25IHNXF-CAts0vNW.js → classDiagram-v2-L25IHNXF-CoK-3RrH.js} +8 -8
  33. package/dist/{classDiagram-v2-L25IHNXF-CAbdJ2_W.cjs → classDiagram-v2-L25IHNXF-DUh5AzbW.cjs} +1 -1
  34. package/dist/{conversationExport-C-0oWDfL.cjs → conversationExport-DXxmgLoF.cjs} +1 -1
  35. package/dist/{conversationExport-BGLSsVDO.js → conversationExport-jRLUX0kH.js} +3 -3
  36. package/dist/{conversationHistory-CRkCClAn.js → conversationHistory-3pDBlkZZ.js} +11 -6
  37. package/dist/{conversationHistory-BgnXSxWk.cjs → conversationHistory-C6PqGsO9.cjs} +2 -2
  38. package/dist/{cynefinDiagram-L36ESFBY-CrsJmb7x.cjs → cynefinDiagram-L36ESFBY-BLUfdwhj.cjs} +1 -1
  39. package/dist/{cynefinDiagram-L36ESFBY-ByHpHKCc.js → cynefinDiagram-L36ESFBY-COLv504g.js} +7 -7
  40. package/dist/{dagre-SPEB5RXH-C01_UMxx.js → dagre-SPEB5RXH-CohPsDHQ.js} +7 -7
  41. package/dist/{dagre-SPEB5RXH-ExCiSqVu.cjs → dagre-SPEB5RXH-DF8bZfUb.cjs} +1 -1
  42. package/dist/{diagram-3B7GL73J-CRNoSH2i.cjs → diagram-3B7GL73J-CFwrYkyI.cjs} +1 -1
  43. package/dist/{diagram-3B7GL73J-D7i6eGGQ.js → diagram-3B7GL73J-w28Iaq_1.js} +8 -8
  44. package/dist/{diagram-DNEMPZML-CkhkOJo2.cjs → diagram-DNEMPZML-CezYrBHl.cjs} +1 -1
  45. package/dist/{diagram-DNEMPZML-Di5RqN_h.js → diagram-DNEMPZML-HpZqPF1t.js} +6 -6
  46. package/dist/{diagram-L3MUGCDN-BtQkAzOD.js → diagram-L3MUGCDN-Bg9oF9vU.js} +7 -7
  47. package/dist/{diagram-L3MUGCDN-B1vXsDB1.cjs → diagram-L3MUGCDN-FmKU8C82.cjs} +2 -2
  48. package/dist/{diagram-LA4NIPWU-DST6DvSP.cjs → diagram-LA4NIPWU-B4zPp12a.cjs} +2 -2
  49. package/dist/{diagram-LA4NIPWU-Badv-tyU.js → diagram-LA4NIPWU-D5S10Z1M.js} +16 -16
  50. package/dist/{diagram-MHCOC4E2-DmA9ezb9.js → diagram-MHCOC4E2-BMg2Maje.js} +5 -5
  51. package/dist/{diagram-MHCOC4E2-BafwTqOD.cjs → diagram-MHCOC4E2-DcF56W3-.cjs} +2 -2
  52. package/dist/{diagram-XPFHEONP-CZHt29x-.js → diagram-XPFHEONP-COT08Qlw.js} +9 -9
  53. package/dist/{diagram-XPFHEONP-DCm8Rjp8.cjs → diagram-XPFHEONP-GLEfHAAK.cjs} +5 -5
  54. package/dist/dist-BDWJ0PuE.js +1007 -0
  55. package/dist/dist-CeGGIzgU.cjs +1 -0
  56. package/dist/{docxExport-DM0_V94R.cjs → docxExport-D-T3fTj7.cjs} +1 -1
  57. package/dist/{docxExport-COweplKv.js → docxExport-diU6sv-G.js} +2 -2
  58. package/dist/{ebnfDiagram-UZSYDL2S-DVGQga8g.js → ebnfDiagram-UZSYDL2S-Cu5-1sQW.js} +2 -2
  59. package/dist/{ebnfDiagram-UZSYDL2S-fO0plY-B.cjs → ebnfDiagram-UZSYDL2S-ftYbml6-.cjs} +1 -1
  60. package/dist/{elk-XV6XMXQE-CioXUob9.cjs → elk-XV6XMXQE-32eNFZGY.cjs} +2 -2
  61. package/dist/{elk-XV6XMXQE-BkH0WNCd.js → elk-XV6XMXQE-BoimJY8z.js} +9 -8
  62. package/dist/{erDiagram-EYBAPDEH-CUgDxVam.cjs → erDiagram-EYBAPDEH-BCiRLs1y.cjs} +1 -1
  63. package/dist/{erDiagram-EYBAPDEH-Byy0RKKe.js → erDiagram-EYBAPDEH-BxyIjrYb.js} +7 -7
  64. package/dist/flowDiagram-MALGAFMO-BwqIeP0j.js +15 -0
  65. package/dist/flowDiagram-MALGAFMO-DkxE7jK-.cjs +1 -0
  66. package/dist/ganttDiagram-23REXITY-CSCN0suz.cjs +292 -0
  67. package/dist/{ganttDiagram-23REXITY-DAs5LGLL.js → ganttDiagram-23REXITY-uW1Fo-_u.js} +467 -489
  68. package/dist/{gitGraphDiagram-STJD7YCW-B3zcpUUP.cjs → gitGraphDiagram-STJD7YCW-DsKvmxrY.cjs} +3 -3
  69. package/dist/{gitGraphDiagram-STJD7YCW-BVa0DHTU.js → gitGraphDiagram-STJD7YCW-j7-SImA3.js} +57 -57
  70. package/dist/{infoDiagram-KBXO4MBG-DRQkxKbg.cjs → infoDiagram-KBXO4MBG-CYMQGNUj.cjs} +1 -1
  71. package/dist/{infoDiagram-KBXO4MBG-BW7IcSQr.js → infoDiagram-KBXO4MBG-DE6zWbEk.js} +1 -1
  72. package/dist/init-DP9k4ltr.js +151 -0
  73. package/dist/init-UgQs1rm8.cjs +1 -0
  74. package/dist/{ishikawaDiagram-M35NCXHK-DBokYlS8.cjs → ishikawaDiagram-M35NCXHK-DbHbBLzt.cjs} +1 -1
  75. package/dist/{ishikawaDiagram-M35NCXHK-BiLoyI1l.js → ishikawaDiagram-M35NCXHK-zvWEWMyM.js} +2 -2
  76. package/dist/{journeyDiagram-OPLOXDXO-DsyubZVY.js → journeyDiagram-OPLOXDXO-Ckjy-e7g.js} +2 -2
  77. package/dist/{journeyDiagram-OPLOXDXO-CgabMAC2.cjs → journeyDiagram-OPLOXDXO-Df3Isppt.cjs} +2 -2
  78. package/dist/{kanban-definition-BZKZHSQY-DU8sOWQd.js → kanban-definition-BZKZHSQY-BmePUr-s.js} +6 -6
  79. package/dist/{kanban-definition-BZKZHSQY-CLi3J9cI.cjs → kanban-definition-BZKZHSQY-C0592yvk.cjs} +1 -1
  80. package/dist/linear-DgbjLlQ3.cjs +1 -0
  81. package/dist/linear-uoBSwo4a.js +198 -0
  82. package/dist/{loadReferencedImage-D47xCpa7.cjs → loadReferencedImage-N3Qidv7i.cjs} +1 -1
  83. package/dist/{loadReferencedImage-VNYxXIzB.js → loadReferencedImage-u2es0OEX.js} +1 -1
  84. package/dist/{mermaid.core-DPCy8dJO.js → mermaid.core-BlYpILf7.js} +65 -65
  85. package/dist/{mermaid.core-BL4WDqAH.cjs → mermaid.core-uCBIzEBU.cjs} +7 -7
  86. package/dist/{mermaidToImage-CViP9wx2.js → mermaidToImage-CBa4nUvP.js} +1 -1
  87. package/dist/{mermaidToImage-B7I6iJ9s.cjs → mermaidToImage-Gx6dNGEn.cjs} +1 -1
  88. package/dist/{mindmap-definition-I2QAS2VK-GT8_r7or.cjs → mindmap-definition-I2QAS2VK-CRXX7-9C.cjs} +1 -1
  89. package/dist/{mindmap-definition-I2QAS2VK-C2KpoDqG.js → mindmap-definition-I2QAS2VK-DgJirDRS.js} +7 -7
  90. package/dist/ordinal-CeUiYJ7_.cjs +1 -0
  91. package/dist/ordinal-DFWF7eBM.js +28 -0
  92. package/dist/{pegDiagram-FD4XPPHP-D0OZoETj.cjs → pegDiagram-FD4XPPHP-DFmA0OWh.cjs} +1 -1
  93. package/dist/{pegDiagram-FD4XPPHP-CSA4sB83.js → pegDiagram-FD4XPPHP-DpYyVjjQ.js} +2 -2
  94. package/dist/pi-outpost-embed.cjs +3 -3
  95. package/dist/pi-outpost-embed.js +3 -3
  96. package/dist/pieDiagram-J4AKIIQI-Cz-UbIk9.cjs +39 -0
  97. package/dist/pieDiagram-J4AKIIQI-DuqHiYUq.js +155 -0
  98. package/dist/{quadrantDiagram-XTYBLID2-BjaZuA3m.js → quadrantDiagram-XTYBLID2-B94UoyXc.js} +1 -1
  99. package/dist/{quadrantDiagram-XTYBLID2-CfdtTmYm.cjs → quadrantDiagram-XTYBLID2-BCN9RHwV.cjs} +1 -1
  100. package/dist/{railroadDiagram-MRQ6NCDL-DDOA_8gY.cjs → railroadDiagram-MRQ6NCDL-BlrwhMUX.cjs} +1 -1
  101. package/dist/{railroadDiagram-MRQ6NCDL-DgAKQKiD.js → railroadDiagram-MRQ6NCDL-Br7PQgSm.js} +2 -2
  102. package/dist/{requirementDiagram-Y7LWUY3S-Bhlk2ueA.js → requirementDiagram-Y7LWUY3S-CT4WIq10.js} +7 -7
  103. package/dist/{requirementDiagram-Y7LWUY3S-nSr_pknl.cjs → requirementDiagram-Y7LWUY3S-CzR9zsNk.cjs} +1 -1
  104. package/dist/{sankeyDiagram-WGJFYUXA-x6J896b3.cjs → sankeyDiagram-WGJFYUXA-D8LLSvqn.cjs} +1 -1
  105. package/dist/{sankeyDiagram-WGJFYUXA-DUYWd4HF.js → sankeyDiagram-WGJFYUXA-DiEth1kw.js} +1 -1
  106. package/dist/{sequenceDiagram-5NDRBG5M-BFgcr8MT.cjs → sequenceDiagram-5NDRBG5M-BATWsrlf.cjs} +1 -1
  107. package/dist/{sequenceDiagram-5NDRBG5M-D1YS8Amk.js → sequenceDiagram-5NDRBG5M-DJ1ruzP_.js} +4 -4
  108. package/dist/{stateDiagram-v2-FJ4FJNEA-6j2vDdvl.js → stateDiagram-v2-FJ4FJNEA-CtEFZimW.js} +8 -8
  109. package/dist/{stateDiagram-v2-FJ4FJNEA-DOTmLAY2.cjs → stateDiagram-v2-FJ4FJNEA-DS0IS9Xt.cjs} +1 -1
  110. package/dist/{swimlanes-UMQ2AFYF-CNb1NF60.js → swimlanes-UMQ2AFYF-B9sFO11Y.js} +8 -8
  111. package/dist/{swimlanes-UMQ2AFYF-BQLQzNLz.cjs → swimlanes-UMQ2AFYF-CNdzpvk7.cjs} +1 -1
  112. package/dist/{swimlanesDiagram-OMPLPG4O-BOl138lS.js → swimlanesDiagram-OMPLPG4O-CEjeo6Pa.js} +9 -9
  113. package/dist/swimlanesDiagram-OMPLPG4O-F8fhW_eR.cjs +8 -0
  114. package/dist/{timeline-definition-SEUHKTQE-B_909Amn.js → timeline-definition-SEUHKTQE-BiPtPmVz.js} +3 -3
  115. package/dist/{timeline-definition-SEUHKTQE-Du5-RSsU.cjs → timeline-definition-SEUHKTQE-CHvbMdoq.cjs} +2 -2
  116. package/dist/{usecaseDiagram-AFA6YXN4-BUs_YsqB.cjs → usecaseDiagram-AFA6YXN4-B_KoFCdb.cjs} +1 -1
  117. package/dist/{usecaseDiagram-AFA6YXN4-CiVGRP5X.js → usecaseDiagram-AFA6YXN4-VzWSjfFU.js} +7 -7
  118. package/dist/{vennDiagram-NNMJR3RB-CKxaec4G.cjs → vennDiagram-NNMJR3RB-BRWZo29n.cjs} +1 -1
  119. package/dist/{vennDiagram-NNMJR3RB-l3A_FZxZ.js → vennDiagram-NNMJR3RB-D5u2Njla.js} +2 -2
  120. package/dist/{wardleyDiagram-S7YFUSEH-Ctqri3T4.cjs → wardleyDiagram-S7YFUSEH-CSq-zmI3.cjs} +2 -2
  121. package/dist/{wardleyDiagram-S7YFUSEH-BMQf5dl9.js → wardleyDiagram-S7YFUSEH-VNmN8A6j.js} +5 -5
  122. package/dist/{xychartDiagram-GGNKY7IX-CuFU4ynf.js → xychartDiagram-GGNKY7IX-D-eT4Gjt.js} +18 -25
  123. package/dist/{xychartDiagram-GGNKY7IX-BUma86Wh.cjs → xychartDiagram-GGNKY7IX-D4bccPOk.cjs} +3 -3
  124. package/package.json +1 -1
  125. package/dist/arc-37kcMiGl.js +0 -82
  126. package/dist/arc-C7P0rHQr.cjs +0 -1
  127. package/dist/array-CApNbSU9.js +0 -6
  128. package/dist/array-DZSRzHA_.cjs +0 -1
  129. package/dist/chunk-6MUBBAK2-BTabKnTR.cjs +0 -2
  130. package/dist/chunk-6MUBBAK2-DlUTxzYh.js +0 -1334
  131. package/dist/chunk-DQASFODM-BBkQ8gE7.cjs +0 -10
  132. package/dist/dist-BB5r6V4R.cjs +0 -1
  133. package/dist/dist-CZhfI1u7.js +0 -59
  134. package/dist/flowDiagram-MALGAFMO-D2e4rl0I.js +0 -15
  135. package/dist/flowDiagram-MALGAFMO-ZfeGO5tQ.cjs +0 -1
  136. package/dist/ganttDiagram-23REXITY-D82ogzPM.cjs +0 -292
  137. package/dist/init-BJdqMO10.cjs +0 -1
  138. package/dist/init-CuXVI8k2.js +0 -13
  139. package/dist/line-Bf0B129l.cjs +0 -1
  140. package/dist/line-DRq00lCg.js +0 -34
  141. package/dist/linear-Bh2vuvAF.cjs +0 -1
  142. package/dist/linear-CxE0kir0.js +0 -287
  143. package/dist/ordinal-Bm_chml2.cjs +0 -1
  144. package/dist/ordinal-D3SPD7Kk.js +0 -65
  145. package/dist/path-DIS6ck99.cjs +0 -1
  146. package/dist/path-PGqhG0Rz.js +0 -84
  147. package/dist/pieDiagram-J4AKIIQI-CNLlH6kK.js +0 -203
  148. package/dist/pieDiagram-J4AKIIQI-O870G6iX.cjs +0 -39
  149. package/dist/swimlanesDiagram-OMPLPG4O-BNDsO6gw.cjs +0 -8
@@ -2,10 +2,10 @@ const e=require("./rolldown-runtime-DbbDpzbe.cjs"),t=require("./lib-CRTt_FoR.cjs
2
2
  `),n=b(t);if(n===-1)return;let r=t[n],i=/^(\s*)(flowchart|graph)([ \t]+(TD|TB|BT|LR|RL)\b)?(.*)$/i.exec(r);if(i!==null){let[,e,r,,a,o]=i,s=a===void 0?`TB`:y(a),c=v(s),l=[...t];return l[n]=`${e}${r} ${c}${o}`,{direction:s,turned:l.join(`
3
3
  `)}}let a=/^(\s*)stateDiagram(-v2)?\s*$/i.exec(r);if(a!==null)return S(t,n,a[1])}function S(e,t,n){let r=0;for(let n=t+1;n<e.length;n+=1){let t=e[n],i=r===0?/^\s*direction\s+(TD|TB|BT|LR|RL)\s*$/i.exec(t):null;if(i!==null){let r=y(i[1]),a=[...e];return a[n]=t.replace(/(direction\s+)(TD|TB|BT|LR|RL)/i,`$1${v(r)}`),{direction:r,turned:a.join(`
4
4
  `)}}r+=(t.match(/\{/g)?.length??0)-(t.match(/\}/g)?.length??0),r<0&&(r=0)}let i=[...e];return i.splice(t+1,0,`${n} direction LR`),{direction:`TB`,turned:i.join(`
5
- `)}}var C=`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,w=`flex flex-wrap items-center gap-3 text-xs`,T=null;async function E(e){let t=await(T??=Promise.resolve().then(()=>require("./mermaid.core-BL4WDqAH.cjs")).then(e=>e.t));return t.default.initialize({startOnLoad:!1,theme:e,look:`classic`,securityLevel:`strict`,suppressErrorRendering:!0}),t}function ee(e){let t=/viewBox="\s*[\d.-]+[\s,]+[\d.-]+[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e),n=t?Number(t[1]):NaN;return Number.isFinite(n)&&n>0?n:void 0}function D(e,t){if(typeof e!=`object`||!e||!(`props`in e))return null;let n=e.props;if(t!==void 0&&!RegExp(`\\blanguage-${t}\\b`).test(n.className??``))return null;let r=n.children;return typeof r==`string`?r:Array.isArray(r)&&r.every(e=>typeof e==`string`)?r.join(``):null}function te(e){let t=D(e,`mermaid`);return t===null?null:t.trim()}function ne(e){let{children:t,...n}=e,r=te(t);if(r!==null)return(0,o.jsx)(re,{code:r});let i=D(t);return i===null?(0,o.jsx)(`pre`,{...n,children:t}):(0,o.jsxs)(`div`,{className:`code-block relative`,"data-testid":`code-block`,children:[(0,o.jsx)(`pre`,{...n,children:t}),(0,o.jsx)(u,{iconOnly:!0,text:i.replace(/\n$/,``),className:`absolute right-1.5 top-1.5 rounded border border-zinc-300 bg-white/80 px-1.5 py-0.5 text-xs text-zinc-500 hover:text-zinc-800 dark:border-zinc-700 dark:bg-zinc-900/80 dark:text-zinc-400 dark:hover:text-zinc-100`})]})}function re({code:e}){let n=(0,a.useId)().replace(/[^a-zA-Z0-9]/g,``),r=l()===`light`?`default`:`dark`,[i,s]=(0,a.useState)(null),[c,d]=(0,a.useState)(null),[p,g]=(0,a.useState)(!1),[v,y]=(0,a.useState)(!1),[b,S]=(0,a.useState)(!1),[T,D]=(0,a.useState)(null),te=(0,a.useRef)(!1),ne=(0,a.useRef)(0),re=(0,a.useRef)(0),ie=()=>`mermaid-${n}-${++re.current}`,ae=(0,a.useMemo)(()=>x(e),[e]),oe=ae===void 0?`landscape`:_(ae.direction),[se,ce]=(0,a.useState)(void 0),le=i?.svg??null,ue=i!==null&&i.orientation!==oe,de=(0,a.useRef)(null),O=(0,a.useRef)(e);O.current=e,(0,a.useEffect)(()=>(ne.current+=1,s(null),ce(void 0),y(!1),d(null),D(null),()=>{ne.current+=1}),[e]);async function fe(){if(!i||te.current)return;te.current=!0,S(!0),D(null);let e=ne.current;try{let{renderDiagram:t}=await Promise.resolve().then(()=>require("./mermaidToImage-B7I6iJ9s.cjs")).then(e=>e.r),r=await t(i.source,`mermaid-download-${n}`);if(e!==ne.current)return;let a=URL.createObjectURL(new Blob([r.svg],{type:`image/svg+xml;charset=utf-8`}));try{let e=document.createElement(`a`);e.href=a,e.download=`diagram.svg`,e.click()}finally{URL.revokeObjectURL(a)}}catch(t){e===ne.current&&D(t instanceof Error?t.message:String(t))}finally{te.current=!1,S(!1)}}return(0,a.useEffect)(()=>{let e=!1,n=setTimeout(()=>void t.h(async()=>{try{let t=(await E(r)).default,n=O.current,i=x(n),a=i===void 0?`landscape`:_(i.direction);if(se!==void 0&&i!==void 0){let r=se===a?n:i.turned,{svg:o}=await t.render(ie(),r);e||(s({svg:o,orientation:se,source:r}),d(null));return}let o=await t.render(ie(),n),c={svg:o.svg,orientation:a,source:n},l=ee(o.svg);if(i!==void 0&&l!==void 0&&l>710){let e=await t.render(ie(),i.turned),n=ee(e.svg);if(n!==void 0){let t=a===`landscape`?h(l,n):h(n,l);t!==a&&(c={svg:e.svg,orientation:t,source:i.turned})}}e||(s(c),d(null))}catch(t){e||(s(null),d(t instanceof Error?t.message:String(t)))}}),300);return()=>{e=!0,clearTimeout(n)}},[e,n,r,se]),le?(0,o.jsxs)(`div`,{ref:de,className:`my-2 flex flex-col gap-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,o.jsxs)(`div`,{className:`${w} order-3`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>g(!p),title:p?`Show diagram`:`Show code`,className:C,children:p?`⚏ diagram`:`⌗ code`}),!p&&ae!==void 0&&i!==null&&(0,o.jsx)(`button`,{type:`button`,"data-testid":`mermaid-orientation`,onClick:()=>ce(e=>m(e??i.orientation)),title:i.orientation===`portrait`?`Turn it across the page — it is drawn down`:`Turn it down the page — it is drawn across`,"aria-label":`Turn the diagram ${m(i.orientation)}`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,children:i.orientation===`portrait`?`↔ landscape`:`↕ portrait`}),!p&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>y(!0),"aria-label":`Show diagram at full size`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,children:`⤢ enlarge`}),(0,o.jsx)(`button`,{type:`button`,className:C,disabled:b,onClick:()=>void fe(),title:`Save as .svg — insert it as a picture in a document`,children:b?`preparing SVG…`:`⤓ download SVG`}),(0,o.jsx)(u,{text:e,className:C}),T&&(0,o.jsxs)(`span`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:[`Could not download SVG: `,T]})]}),p?(0,o.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,o.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:le}}),ue&&!p&&(0,o.jsxs)(`div`,{className:`mt-1 text-center text-xs text-zinc-400 dark:text-zinc-600`,"data-testid":`mermaid-turned`,children:[`drawn `,i?.orientation,` to fit — the source asks for `,oe]}),(0,o.jsx)(f,{label:`diagram`,testId:`mermaid-enlarged`,open:v,onClose:()=>y(!1),anchorRef:de,actions:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,className:C,disabled:b,onClick:()=>void fe(),children:b?`preparing SVG…`:`⤓ download SVG`}),T&&(0,o.jsxs)(`span`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:[`Could not download SVG: `,T]})]}),children:(0,o.jsx)(`div`,{style:{width:ee(le)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:le}})})]}):(0,o.jsxs)(`pre`,{className:`my-2 overflow-x-auto rounded-lg border border-zinc-200 bg-zinc-50 p-3 font-mono text-xs text-zinc-500 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:[e,c&&(0,o.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:c})]})}var ie=`urn:structured-exchange:1`,ae=[`graph`,`sequence`];function oe(e){return se(e)?[`graph`,`sequence`,`table`]:ae}function se(e){return e===`urn:structured-exchange:2`||e===`urn:structured-exchange:3`}function ce(e){if(Array.isArray(e))return{cells:e};let t=e.heading;return typeof t==`string`?{cells:[],role:e.role,heading:t}:{cells:e.cells,role:e.role}}var le={nodes:500,edges:2e3,participants:100,messages:1e3,columns:50,rows:5e3,removals:500,ref:200,localId:200,label:500,kind:100,kindsPerVocabulary:64,columnName:200,cell:1e3},ue=`urn:structured-exchange:2`,de={profile:200,attributesPerItem:50,removeAttributesPerItem:50,attributeName:200,attributeString:1e3,attributeListItems:50,revision:200,locationsPerItem:10,uri:2e3,position:1e6,artifactsPerItem:20,artifactsPerDocument:50,artifactRel:100,artifactMediaType:100,artifactLabel:500,artifactDigest:71,relations:2e3,heading:500,headingDepth:6,viewpoints:20,viewpointConcern:500},O=8e6,fe=`urn:structured-exchange:3`,pe=[ie,ue,fe];function me(e){return pe.find(t=>t===e)}var he=4e6,ge=Math.max(he,O);function _e(e){return se(e)?O:he}var ve=e=>new TextEncoder().encode(e).length;function ye(e){return e===`bytes`?ge:e===`relations`?de.relations:le[e]}function be(e,t){let n=ye(e),r=t?.[e];return r===void 0||r>=n?{limit:n,level:`ceiling`}:{limit:r,level:`deployment`}}function xe(e,t,n){let r=ve(e),i=be(`bytes`,t),a=n===void 0?1/0:_e(n),o=Math.min(i.limit,a),s=o===a&&a<i.limit?`ceiling`:i.level;if(!(r<=o))return{rule:`document-too-large`,path:``,message:`document is ${r} bytes, past the ${o}-byte ${s===`ceiling`?`contract ceiling`:`limit this deployment applies`}`,limit:o,observed:r,level:s}}var k={graph:[`nodes`,`edges`],sequence:[`participants`,`messages`],table:[`columns`,`rows`,`relations`]};function A(e,t){if(t===void 0)return[];let n=[];for(let r of k[e.kind]??[]){let i=e.data[r];if(!Array.isArray(i))continue;let{limit:a,level:o}=be(r,t);o===`deployment`&&i.length>a&&n.push({rule:`collection-past-deployment-limit`,path:`/data/${r}`,message:`${r} has ${i.length} entries, past the ${a} this deployment allows`,limit:a,observed:i.length,level:o})}return n}function Se(e,t){let n={};for(let t of k[e.kind]??[]){let r=e.data[t];Array.isArray(r)&&(n[t]=r.length)}return{kind:e.kind,bytes:ve(t),counts:n}}var Ce=6.6,we=5.4;function Te(e,t,n){let r=e.flatMap(e=>e.split(/\r?\n/)).reduce((e,t)=>Math.max(e,t.length),0);return Math.min(Math.max(r*Ce+22,t),n)}function Ee(e,t,n,r){let i=t.map(e=>Ae(e).length).reduce((e,t)=>Math.max(e,t),0);return Math.max(Te(e,n,r),Math.min(i*we+22,r))}function De(e,t,n=Ce){let r=Math.max(Math.floor((t-22)/n+1e-6),4),i=[],a=e.split(/\r?\n/);if(a.length>1)return a.flatMap(e=>De(e,t,n)).slice(0,3);let o=``;for(let t of e.split(/\s+/)){let e=o===``?t:`${o} ${t}`;if(e.length<=r)o=e;else for(o!==``&&i.push(o),o=t;o.length>r&&i.length<3;)i.push(o.slice(0,r)),o=o.slice(r)}if(o!==``&&i.push(o),i.length===0)return[``];if(i.length<=3)return i;let s=i.slice(0,3);return s[2]=`${s[2].slice(0,Math.max(r-1,1))}…`,s}function Oe(e,t){return e*15+t*15+14}function ke(e,t){return e.flatMap(e=>De(Ae(e),t,we))}function Ae(e){return`${e.field}: ${e.from===void 0?``:`${e.from} → `}${e.to}`}function je(e,t){return`${e}: ${Me(t)}`}function Me(e){return Array.isArray(e)?e.map(e=>Me(e)).join(`, `):e===null?`null`:typeof e==`object`&&typeof e.ref==`string`?`<${e.ref}>`:String(e)}function Ne(e){let t=e.range===void 0?``:` lines ${e.range.startLine}–${e.range.endLine}`,n=e.revision===void 0?``:` at ${e.revision}`;return`${e.uri}${t}${n}`}function Pe(e){let t=e.label===void 0?e.uri:`${e.label} (${e.uri})`,n=e.mediaType===void 0?``:`, ${e.mediaType}`;return`${e.rel}: ${t}${n} — ${e.sha256.slice(0,14)}…`}var Fe=864e5,Ie=/^(\d{4})-(\d{2})-(\d{2})$/;function Le(e){let t=Ie.exec(e);if(t===null)return;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=new Date(Date.UTC(n,r-1,i));if(a.setUTCFullYear(n,r-1,i),a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i)return Math.round(a.getTime()/Fe)}function Re(e){let t=new Date(e*Fe);return`${String(t.getUTCFullYear()).padStart(4,`0`)}-${String(t.getUTCMonth()+1).padStart(2,`0`)}-${String(t.getUTCDate()).padStart(2,`0`)}`}function ze(e=new Date){return Math.round(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())/Fe)}function Be(e){let t=Le(e.type===`activity`?e.start:e.date),n=Le(e.type===`activity`?e.end:e.date);return t===void 0||n===void 0?void 0:{start:t,end:n}}function Ve(e){let t=new Map;return e.rows.forEach((e,n)=>{e.type===`task`&&(t.has(e.id)||t.set(e.id,{id:e.id,type:`task`,row:n,days:He(e)}),e.items.forEach((e,r)=>{e.id===void 0||t.has(e.id)||t.set(e.id,{id:e.id,type:e.type,row:n,item:r,days:Be(e)})}))}),t}function He(e){let t;for(let n of e.items){let e=Be(n);e!==void 0&&(t=t===void 0?{...e}:{start:Math.min(t.start,e.start),end:Math.max(t.end,e.end)})}return t}function Ue(e){return e.type??`finish-to-start`}function We(e){return{from:e.startsWith(`finish`)?`end`:`start`,to:e.endsWith(`finish`)?`end`:`start`}}function Ge(e,t){let n=t.get(e.from)?.days,r=t.get(e.to)?.days;if(n===void 0||r===void 0)return;let i=We(Ue(e));return r[i.to]>=n[i.from]}function Ke(e){if(`date`in e){let t=Le(e.date)??0;return{start:t,end:t}}return{start:Le(e.start)??0,end:Le(e.end)??0}}function qe(e){if(e.previous===void 0)return;let t=Ke(e.type===`activity`?{start:e.start,end:e.end}:{date:e.date}),n=Ke(e.previous);return{start:t.start-n.start,end:t.end-n.end}}function Je(e){if(e===0)return``;let t=e>0?`+`:`−`,n=Math.abs(e);return n<14?`${t}${n}d`:n<70?`${t}${Math.round(n/7)}w`:`${t}${Math.round(n/30.44)}mo`}function Ye(e){let t=qe(e);return t===void 0?``:t.start===t.end?Je(t.start):t.start===0?`end${Je(t.end)}`:t.end===0?`start${Je(t.start)}`:`${Je(t.start)}, end${Je(t.end)}`}function Xe(e,t){if(e.role!==void 0||t?.role!==void 0)return!0;let n=qe(e);return n!==void 0&&(n.start!==0||n.end!==0)}function Ze(e){return e.role!==void 0||e.items.some(t=>Xe(t,e))}var Qe={week:12,month:4,quarter:.75};function $e(e,t){let n=e>=8?`week`:e>=1?`month`:`quarter`;if(t===void 0)return n;let r=[`week`,`month`,`quarter`];return r[Math.max(r.indexOf(n),r.indexOf(t))]}var et=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function tt(e){return e.width>=24?e.label:e.width>=9?e.label.charAt(0):``}function nt(e,t){return t===`month`?tt(e):e.width>=e.label.length*6+4?e.label:``}function rt(e){return((e+3)%7+7)%7}function it(e){let t=e-rt(e)+3,n=new Date(t*Fe).getUTCFullYear();return Math.floor((t-ct(n,0))/7)+1}function at(e){if(e.label!==void 0&&e.label!==``)return e.label;if(e.type===`milestone`&&e.kind!==void 0&&e.kind!==``)return e.kind}function ot(e){return e.length*Ce}function st(e,t){let n=new Date(e*Fe),r=n.getUTCFullYear(),i=n.getUTCMonth(),a=[];for(;;){i+=1,i===12&&(i=0,r+=1);let e=ct(r,i);if(e>t)return a;a.push({day:e,year:r,month:i})}}function ct(e,t){let n=new Date(0);return n.setUTCFullYear(e,t,1),Math.round(n.getTime()/Fe)}function lt(e,t){let n=e=>e===`bar`||e===`ghost`;return n(e)&&t===`star`||e===`star`&&n(t)}function ut(e,t){return e.x0<t.x1&&t.x0<e.x1}function dt(e,t){if(t<=0||e.width<=t)return;let n=e.items.filter(e=>e.change!==void 0);if(n.length>0){let e=Math.min(...n.flatMap(e=>e.ghost===void 0?[e.glyph.x]:[e.glyph.x,e.ghost.x]));return e<t*.9?void 0:Math.max(0,e-t/6)}if(`x`in e.today&&e.today.x>t*.8)return Math.max(0,e.today.x-t/3)}function ft(e,t,n={}){let r=Le(e.time.start)??0,i=Le(e.time.end)??r,a=n.pxPerDay??Qe[e.time.scale]??4,o=(i-r+1)*a,s=e=>(e-r)*a,c=st(r,i),l=new Date(r*Fe),u=[{day:r,year:l.getUTCFullYear(),month:l.getUTCMonth()},...c],d=u.map((e,t)=>{let n=t+1<u.length?u[t+1].day:i+1;return{label:et[e.month],x:s(e.day),width:(n-e.day)*a,year:e.year,month:e.month}}),f=[];u.forEach((e,t)=>{let n=d[t],r=f[f.length-1];r!==void 0&&r.label===String(e.year)?r.width+=n.width:f.push({label:String(e.year),x:n.x,width:n.width})});let p=$e(a,n.unit),m=(e,t)=>e.map((n,r)=>{let o=r+1<e.length?e[r+1]:i+1;return{label:t(n),x:s(n),width:(o-n)*a}}),h=f,g;if(p===`week`){let e=[];for(let t=r-rt(r)+7;t<=i;t+=7)e.push(t);g=m([r,...e],e=>`W${it(e)}`),h=d.map(e=>({label:`${e.label} ${e.year}`,x:e.x,width:e.width}))}else if(p===`quarter`){let e=u.filter((e,t)=>t===0||e.month%3==0);g=e.map((t,n)=>{let r=n+1<e.length?e[n+1].day:i+1;return{label:`Q${Math.floor(t.month/3)+1}`,x:s(t.day),width:(r-t.day)*a}})}else g=d;let _=g.slice(1).map(e=>e.x),v=[],y=[],b=0,x=e.comparedTo!==void 0,S=(e,t)=>{if(!x)return;if(e.role===`added`||t.role===`added`)return`(new)`;let n=Ye(e);return n===``?void 0:`(${n})`},C=(e,t,n)=>{let r=S(e,t);return r===void 0?n:n===void 0?r:`${n} ${r}`},w=(e,t)=>{if(x)return e.role===`removed`||t.role===`removed`?`removed`:e.role===`added`||t.role===`added`?`added`:Ye(e)===``?void 0:`moved`},T=(e,t)=>{let n=[],r=[],i=[],c=e.map(e=>({...e,days:Be(e.item)})).filter(e=>e.days!==void 0).sort((e,t)=>Number(e.item.type===`milestone`)-Number(t.item.type===`milestone`)||e.days.start-t.days.start||e.row-t.row||e.index-t.index);for(let{item:e,index:t,row:l,days:u,text:d,note:f,change:p}of c){let c=[],m;if(p===`moved`&&e.previous!==void 0){let t=Ke(e.previous);if(e.type===`activity`)m={x0:s(t.start),x1:s(t.end+1)};else{let e=s(t.start)+a/2;m={x0:e-7,x1:e+7,cx:e}}c.push({kind:`ghost`,x0:m.x0,x1:m.x1})}let h,g,_,v;if(e.type===`activity`){if(g=s(u.start),_=s(u.end+1),c.push({kind:`bar`,x0:g,x1:_}),d!==void 0){let e=ot(d);h=e+12<=_-g?{text:d,inside:!0,x:g+6,width:e}:pt(d,g,_,o),f!==void 0&&(h.note=f),c.push({kind:`label`,x0:h.x,x1:h.x+h.width})}}else v=s(u.start)+a/2,g=v-7,_=v+7,c.push({kind:`star`,x0:g,x1:_}),d!==void 0&&(h=pt(d,g,_,o),f!==void 0&&(h.note=f),c.push({kind:`label`,x0:h.x,x1:h.x+h.width}));let y=n.findIndex(e=>c.every(t=>e.every(e=>lt(t.kind,e.kind)||!ut(t,e))));y===-1&&(y=n.length,n.push([])),n[y].push(...c),r.push({row:l,item:t,type:e.type,lane:y,days:u,...e.kind?{kind:e.kind}:{},...p===void 0?{}:{change:p}}),i.push({label:h===void 0?void 0:{...h,...p===`removed`?{struck:!0}:{}},x0:g,x1:_,cx:v,ghost:m})}return r.forEach((e,n)=>{let r=i[n],a=t+4+e.lane*24+12,o=e.type===`activity`?{x:r.x0,y:a-6,width:r.x1-r.x0,height:12}:{x:r.x0,y:a-7,width:14,height:14},s=r.ghost;y.push({...e,glyph:o,...r.cx===void 0?{}:{center:{x:r.cx,y:a}},...r.label===void 0?{}:{label:{...r.label,y:a-8,height:16}},...s===void 0?{}:e.type===`activity`?{ghost:{x:s.x0,y:a-6,width:s.x1-s.x0,height:12}}:{ghost:{x:s.x0,y:a-7,width:14,height:14},ghostCenter:{x:s.cx,y:a}}})}),Math.max(1,n.length)},E=e=>e*24+8,ee=(e,t)=>{let n=T(e.items.map((n,r)=>({row:t,index:r,item:n,text:C(n,e,at(n)),note:S(n,e),change:w(n,e)})),b),r=E(n);v.push({type:`task`,row:t,y:b,height:r,lanes:n,label:e.label,id:e.id}),b+=r},D,te=()=>{if(D!==void 0){if(D.tasks.length===0){let e=D.label?26:10;v.push({type:`separator`,row:D.row,y:b,height:e,...D.label?{label:D.label}:{}}),b+=e}else{let e=T(D.tasks.flatMap(({task:e,row:t})=>e.items.map((n,r)=>({row:t,index:r,item:n,text:C(n,e,at(n)??(n.type===`activity`?e.label:void 0)),note:S(n,e),change:w(n,e)}))),b),t=E(e);v.push({type:`section`,row:D.row,y:b,height:t,lanes:e,...D.label?{label:D.label}:{},tasks:D.tasks.map(({task:e})=>e.id)}),b+=t}D=void 0}},ne=(()=>{let t=new Set;if(!(n.onlyChanged&&x))return;let r;return e.rows.forEach((e,n)=>{e.type===`separator`?r=n:Ze(e)&&(t.add(n),r!==void 0&&t.add(r))}),t})(),re=ne===void 0?0:e.rows.filter((e,t)=>e.type===`task`&&!ne.has(t)).length;e.rows.forEach((e,t)=>{if(ne===void 0||ne.has(t)){if(e.type===`separator`){if(n.compact){te(),D={row:t,...e.label?{label:e.label}:{},tasks:[]};return}let r=e.label?26:10;v.push({type:`separator`,row:t,y:b,height:r,...e.label?{label:e.label}:{}}),b+=r}else D===void 0?ee(e,t):D.tasks.push({task:e,row:t})}}),te();let ie=[];for(let t of e.rows)if(t.type===`task`)for(let e of t.items)e.kind&&!ie.includes(e.kind)&&ie.push(e.kind);for(let t of[...e.periods??[],...e.references??[]])t.kind&&!ie.includes(t.kind)&&ie.push(t.kind);let ae=[];(e.periods??[]).forEach((e,t)=>{let n=Math.max(Le(e.start)??r,r),o=Math.min(Le(e.end)??i,i);n>o||ae.push({index:t,x:s(n),width:(o-n+1)*a,start:e.start,end:e.end,...e.label?{label:e.label}:{},...e.kind?{kind:e.kind}:{}})});let oe=(e.references??[]).flatMap((e,t)=>{let n=Le(e.date);return n===void 0||n<r||n>i?[]:[{index:t,x:s(n)+a/2,label:e.label,date:e.date,...e.kind?{kind:e.kind}:{}}]}),se=[];if(t>=r&&t<=i){let e=s(t)+a/2;se.push({x0:e-26,x1:e+26})}let ce=[],le=[...ae.filter(e=>e.label).map(e=>({of:`period`,index:e.index,text:e.label,x:e.x+3,room:e.width-6})),...oe.map(e=>{let t=ot(e.label)*(10/11);return{of:`reference`,index:e.index,text:e.label,x:Math.min(Math.max(2,e.x-t/2),o-t-2),room:o-4}})].sort((e,t)=>e.x-t.x);for(let e of le){let t=ot(e.text)*(10/11);if(t>e.room)continue;let n={x0:e.x-2,x1:e.x+t+2};se.some(e=>n.x0<e.x1&&e.x0<n.x1)||(se.push(n),ce.push({of:e.of,index:e.index,text:e.text,x:e.x,width:t}))}return{width:o,height:b,start:r,end:i,years:f,months:d,monthLines:c.map(e=>s(e.day)),unit:p,upper:h,lower:g,unitLines:_,rows:v,items:y,dependencies:mt(e,v,y,s),today:t<r?{outside:`before`,day:t}:t>i?{outside:`after`,day:t}:{x:s(t)+a/2,day:t},kinds:ie,hiddenTasks:re,periods:ae,references:oe,headerLabels:ce}}function pt(e,t,n,r){let i=ot(e),a=n+4;if(a+i<=r)return{text:e,inside:!1,x:a,width:i};let o=t-4-i;return o>=0?{text:e,inside:!1,x:o,width:i}:{text:e,inside:!1,x:Math.max(0,r-i),width:i}}function mt(e,t,n,r){let i=Ve(e),a=new Map(n.map(e=>[`${e.row}:${e.item}`,e])),o=new Map(t.map(e=>[e.row,e])),s=(e,t)=>{let s=i.get(e);if(s?.days===void 0)return;if(s.item!==void 0){let e=a.get(`${s.row}:${s.item}`);if(e===void 0)return;let n=e.glyph.y+e.glyph.height/2;return e.center===void 0?{x:t===`start`?e.glyph.x:e.glyph.x+e.glyph.width,y:n}:{x:e.center.x+(t===`start`?-7:7),y:n}}let c=r(t===`start`?s.days.start:s.days.end+1),l=o.get(s.row);if(l!==void 0&&l.type===`task`)return{x:c,y:l.y+4+12};let u=n.filter(e=>e.row===s.row).sort((e,n)=>t===`start`?e.glyph.x-n.glyph.x:n.glyph.x+n.glyph.width-(e.glyph.x+e.glyph.width));if(u.length!==0)return{x:c,y:u[0].glyph.y+u[0].glyph.height/2}},c=[];return(e.dependencies??[]).forEach((e,t)=>{let n=Ue(e),r=We(n),a=s(e.from,r.from),o=s(e.to,r.to),l=Ge(e,i);if(a===void 0||o===void 0||l===void 0)return;let u={x:a.x+(r.from===`end`?8:-8),y:a.y},d={x:o.x+(r.to===`start`?-8:8),y:o.y};if(a.y===o.y&&r.from===`end`&&r.to===`start`&&o.x>=a.x-14){c.push({index:t,from:e.from,to:e.to,type:n,satisfied:l,points:[a,o]});return}let f=o.y>a.y?o.y-12:(o.y,a.y,o.y+12);c.push({index:t,from:e.from,to:e.to,type:n,satisfied:l,points:[a,u,{x:u.x,y:f},{x:d.x,y:f},d,o]})}),c}function ht(e){let t=e.rows.reduce((e,t)=>Math.max(e,(t.label??``).length),0);return Math.min(Math.max(t*Ce+24,120),280)}function gt(e,t){for(let n of e.rows){if(n.type!==`task`)continue;if(n.id===t)return`"${n.label}" (${t})`;let e=n.items.find(e=>e.id===t);if(e!==void 0){let n=at(e);return n===void 0?t:`"${n}" (${t})`}}return t}function _t(e,t,n){let r=n===!1?` — not satisfied by the dates`:``;return`${gt(e,t.to)} waits on ${gt(e,t.from)} (${Ue(t)})${r}`}function vt(e){let t=[];e.title!==void 0&&e.title!==``&&t.push(e.title),e.comparedTo!==void 0&&t.push(`Compared with ${e.comparedTo.label}${e.comparedTo.date===void 0?``:` (${e.comparedTo.date})`}`),t.push(`From ${e.time.start} to ${e.time.end}, by ${e.time.scale}`);for(let n of e.rows){if(t.push(``),n.type===`separator`){t.push(n.label?`— ${n.label} —`:`———`);continue}let e=n.role===void 0?``:n.role===`added`?` — new`:` — removed`;t.push(`${n.label} [${n.id}]${n.items.length===0?` — no items`:``}${e}`);for(let e of n.items){let n=e.type===`activity`?`${e.start} to ${e.end}`:e.date,r=e.label===void 0?``:`: ${e.label}`,i=e.kind===void 0?``:` [${e.kind}]`,a=e.id===void 0?``:` (${e.id})`,o=(()=>{if(e.role===`added`)return` — new`;if(e.role===`removed`)return` — removed`;let t=Ye(e);return t===``||e.previous===void 0?``:` — moved ${t}, was ${`date`in e.previous?e.previous.date:`${e.previous.start} to ${e.previous.end}`}`})();t.push(` ${e.type} ${n}${r}${i}${a}${o}`)}}let n=[...(e.periods??[]).map(e=>` period ${e.start} to ${e.end}${e.label?`: ${e.label}`:``}${e.kind?` [${e.kind}]`:``}`),...(e.references??[]).map(e=>` reference ${e.date}: ${e.label}${e.kind?` [${e.kind}]`:``}`)];n.length>0&&t.push(``,`Calendar`,...n);let r=e.dependencies??[];if(r.length>0){let n=Ve(e);t.push(``,`Dependencies`);for(let i of r)t.push(` ${_t(e,i,Ge(i,n))}`)}return t}function yt(e){let t=[],n=(e,n)=>{let r=Le(e);return r===void 0&&t.push({rule:`invalid-date`,path:n,message:`"${e}" is not a day of the calendar`}),r},r=n(e.time.start,`/data/time/start`),i=n(e.time.end,`/data/time/end`),a=r!==void 0&&i!==void 0&&r<=i?{start:r,end:i}:void 0;r!==void 0&&i!==void 0&&r>i&&t.push({rule:`inverted-range`,path:`/data/time`,message:`the timeline starts on ${e.time.start}, after it ends on ${e.time.end}`});let o=`${e.time.start} to ${e.time.end}`,s=new Map,c=(e,n)=>{if(e===void 0)return;let r=s.get(e);r===void 0?s.set(e,n):t.push({rule:`duplicate-identifier`,path:`${n}/id`,message:`identifier "${e}" is already declared at ${r}`})},l=e.comparedTo!==void 0;e.comparedTo?.date!==void 0&&n(e.comparedTo.date,`/data/comparedTo/date`);let u=e=>t.push({rule:`comparison-without-reference`,path:e,message:"previous dates and change roles describe a comparison; declare `comparedTo` naming the plan they compare with"}),d=new Set;return e.rows.forEach((e,r)=>{if(e.type!==`task`)return;let i=`/data/rows/${r}`;c(e.id,i),e.role!==void 0&&!l&&u(`${i}/role`),e.items.forEach((r,s)=>{let f=`${i}/items/${s}`;if(c(r.id,f),r.kind!==void 0&&d.add(r.kind),r.role!==void 0&&!l&&u(`${f}/role`),r.previous!==void 0){l||u(`${f}/previous`),(r.role!==void 0||e.role!==void 0)&&t.push({rule:`contradictory-change`,path:`${f}/previous`,message:`an item that is ${r.role??`in a task that is ${e.role}`} has no previous dates; it is new or dropped, not moved`});let i=r.previous,s=r.type===`activity`?{first:n(i.start,`${f}/previous/start`),last:n(i.end,`${f}/previous/end`)}:(()=>{let e=n(i.date,`${f}/previous/date`);return{first:e,last:e}})();s.first!==void 0&&s.last!==void 0&&(s.first>s.last?t.push({rule:`inverted-range`,path:`${f}/previous`,message:`the previous dates start on ${i.start}, after they end on ${i.end}`}):a!==void 0&&(s.first<a.start||s.last>a.end)&&t.push({rule:`item-outside-range`,path:`${f}/previous`,message:`the previous dates fall outside the timeline's range ${o}; the range covers both plans, so widen \`time\``}))}r.role!==void 0&&e.role!==void 0&&r.role!==e.role&&t.push({rule:`contradictory-change`,path:`${f}/role`,message:`an item ${r.role} in a task that is ${e.role}`});let p,m;if(r.type===`activity`){if(p=n(r.start,`${f}/start`),m=n(r.end,`${f}/end`),p!==void 0&&m!==void 0&&p>m){t.push({rule:`inverted-range`,path:f,message:`the activity starts on ${r.start}, after it ends on ${r.end}`});return}}else p=m=n(r.date,`${f}/date`);a!==void 0&&p!==void 0&&m!==void 0&&(p<a.start||m>a.end)&&t.push({rule:`item-outside-range`,path:f,message:r.type===`activity`?`the activity runs ${r.start} to ${r.end}, outside the timeline's range ${o}; widen \`time\` or move the activity`:`the milestone falls on ${r.date}, outside the timeline's range ${o}; widen \`time\` or move the milestone`})})}),(e.periods??[]).forEach((e,r)=>{let i=`/data/periods/${r}`;e.kind!==void 0&&d.add(e.kind);let s=n(e.start,`${i}/start`),c=n(e.end,`${i}/end`);s!==void 0&&c!==void 0&&(s>c?t.push({rule:`inverted-range`,path:i,message:`the period starts on ${e.start}, after it ends on ${e.end}`}):a!==void 0&&(c<a.start||s>a.end)&&t.push({rule:`period-outside-range`,path:i,message:`the period ${e.start} to ${e.end} lies wholly outside the timeline's range ${o}, so nothing of it could be drawn`}))}),(e.references??[]).forEach((e,r)=>{let i=`/data/references/${r}`;e.kind!==void 0&&d.add(e.kind);let s=n(e.date,`${i}/date`);s!==void 0&&a!==void 0&&(s<a.start||s>a.end)&&t.push({rule:`item-outside-range`,path:i,message:`the reference date ${e.date} is outside the timeline's range ${o}; widen \`time\` or move it`})}),d.size>le.kindsPerVocabulary&&t.push({rule:`too-many-kinds`,path:`/data/rows`,message:`${d.size} distinct item types, and no more than ${le.kindsPerVocabulary} can be told apart in a rendering`,observed:d.size,limit:le.kindsPerVocabulary}),t.push(...xt(e,Ve(e))),t.push(...bt(e)),t}function bt(e){let t=new Set;for(let n of e.rows)if(n.type===`task`){n.role===`removed`&&t.add(n.id);for(let e of n.items)e.id!==void 0&&(e.role===`removed`||n.role===`removed`)&&t.add(e.id)}let n=[];return(e.dependencies??[]).forEach((e,r)=>{for(let i of[`from`,`to`])t.has(e[i])&&n.push({rule:`dependency-on-removed`,path:`/data/dependencies/${r}/${i}`,message:`"${e[i]}" was dropped from the plan, so nothing can depend on it any more; remove the dependency`})}),n}function xt(e,t){let n=[],r=e.dependencies??[],i=[],a=new Map;r.forEach((r,o)=>{let s=`/data/dependencies/${o}`,c=!0;for(let i of[`from`,`to`]){let a=r[i],o=t.get(a);if(o===void 0)c=!1,n.push({rule:`unresolved-endpoint`,path:`${s}/${i}`,message:`"${a}" is not the identifier of any task or item this timeline declares`});else if(o.type===`task`&&o.days===void 0){c=!1;let t=e.rows[o.row];if(t.type===`task`&&t.items.length>0)continue;n.push({rule:`empty-task-endpoint`,path:`${s}/${i}`,message:`task "${a}" holds no item, so it has no start or finish for a dependency to link`})}}if(!c)return;let l=t.get(r.from),u=t.get(r.to),d=(e,t)=>e.type===`task`&&t.type!==`task`&&t.row===e.row;if(l.id===u.id||d(l,u)||d(u,l)){n.push({rule:`self-dependency`,path:s,message:l.id===u.id?`"${l.id}" cannot depend on itself`:`a task and one of its own items cannot depend on each other: the task's span is made of its items`});return}let f=JSON.stringify([r.from,r.to,Ue(r)]),p=a.get(f);p===void 0?(a.set(f,o),i.push({from:r.from,to:r.to,index:o})):n.push({rule:`duplicate-dependency`,path:s,message:`the same dependency is already declared at /data/dependencies/${p}`})});let o=St(i);return o!==void 0&&n.push({rule:`dependency-cycle`,path:`/data/dependencies/${o.index}`,message:`dependencies form a cycle, which no dates can honour: ${o.ids.join(` → `)}`}),n}function St(e){let t=new Map;for(let n of e){let e=t.get(n.from)??[];e.push({to:n.to,index:n.index}),t.set(n.from,e)}let n=new Map,r=[];for(let e of t.keys()){if(n.has(e))continue;let i=[{id:e,next:0}];for(n.set(e,`open`),r.push({id:e,index:-1});i.length>0;){let e=i[i.length-1],a=t.get(e.id)??[];if(e.next>=a.length){n.set(e.id,`done`),i.pop(),r.pop();continue}let o=a[e.next++],s=n.get(o.to);if(s===`open`){let e=r.findIndex(e=>e.id===o.to);return{ids:[...r.slice(e).map(e=>e.id),o.to],index:o.index}}s===void 0&&(n.set(o.to,`open`),i.push({id:o.to,next:0}),r.push({id:o.to,index:o.index}))}}}function Ct(e){let t=e.data;return e.kind===`graph`?Array.isArray(t.nodes)&&Array.isArray(t.edges):e.kind===`sequence`?Array.isArray(t.participants)&&Array.isArray(t.messages):e.kind===`timeline`?typeof t.time==`object`&&t.time!==null&&Array.isArray(t.rows):Array.isArray(t.columns)&&Array.isArray(t.rows)}function wt(e){return e.kind===`graph`?e.data.nodes:e.kind===`sequence`?e.data.participants:[]}function Tt(e){return e.kind===`graph`?e.data.edges:e.kind===`sequence`?e.data.messages:[]}function Et(e){return e.kind===`graph`||e.kind===`sequence`?e.data.containers??[]:[]}function Dt(e){return e.kind===`graph`?`/data/nodes`:`/data/participants`}function Ot(e){return e.kind===`graph`?`/data/edges`:`/data/messages`}function kt(e){if(e.kind===`timeline`)return[];let t=e.data,n=[];for(let e of[`nodes`,`edges`,`participants`,`messages`,`rows`,`relations`]){let r=t[e];Array.isArray(r)&&r.forEach((t,r)=>{if(typeof t!=`object`||!t||Array.isArray(t))return;let i=t;n.push({at:`/data/${e}/${r}`,ref:typeof i.ref==`string`?i.ref:void 0,set:i.set,expect:i.expect,locations:i.locations})})}return n}function At(e){if(e.kind!==`table`)return[];let t=e.data.rows,n=[];return t.forEach((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e;(r.ref!==void 0||r.set!==void 0)&&n.push({at:`/data/rows/${t}`,...typeof r.ref==`string`?{ref:r.ref}:{},...r.set===void 0?{}:{set:r.set}})}),n}function jt(e){if(e.kind!==`table`)return[];let t=e.data.rows,n=[];return t.forEach((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e.id;typeof r==`string`&&n.push({id:r,at:`/data/rows/${t}`})}),n}function Mt(e){if(e.kind!==`table`)return[];let t=e.data.relations;return Array.isArray(t)?t:[]}function Nt(e,t){return e===`timeline`?`a timeline is maintained by presenting the revised timeline again, not proposed as a change, ${t}`:`a ${e} is a projection and cannot be proposed, ${t}`}function Pt(e){let t=[];if(!Ct(e))return t.push({rule:`kind-data-mismatch`,path:`/data`,message:`data does not carry what kind "${e.kind}" declares`}),t;let n=oe(e.schema).includes(e.kind);e.target!==void 0&&!n&&t.push({rule:`kind-not-proposable`,path:`/target`,message:Nt(e.kind,`so it carries no target`)}),e.removals!==void 0&&(n?e.target===void 0&&t.push({rule:`removal-without-target`,path:`/removals`,message:`removals need a target: an artifact that does not exist yet has nothing to remove`}):t.push({rule:`kind-not-proposable`,path:`/removals`,message:Nt(e.kind,`so it declares no removals`)}));let r=wt(e),i=Dt(e),a=new Map;r.forEach((e,n)=>{let r=a.get(e.id);r===void 0?a.set(e.id,n):t.push({rule:`duplicate-identifier`,path:`${i}/${n}/id`,message:`identifier "${e.id}" is already declared at ${i}/${r}`})});let o=new Map;Et(e).forEach((e,n)=>{let r=o.get(e.id);r===void 0?o.set(e.id,n):t.push({rule:`duplicate-container-identifier`,path:`/data/containers/${n}/id`,message:`container "${e.id}" is already declared at /data/containers/${r}`})}),r.forEach((e,n)=>{for(let[r,a]of[[`container`,e.container],[`set/container`,e.set?.container]])a!==void 0&&!o.has(a)&&t.push({rule:`unresolved-container`,path:`${i}/${n}/${r}`,message:`"${a}" is not a container declared in /data/containers`})});let s=Ot(e);Tt(e).forEach((e,n)=>{for(let r of[`from`,`to`]){let o=e[r];a.has(o)||t.push({rule:`unresolved-endpoint`,path:`${s}/${n}/${r}`,message:`"${o}" is not an identifier declared in ${i}`})}});let c=new Map,l=(e,n,r)=>{if(n===void 0)return;let i=`${e}:${n}`,a=c.get(i);a===void 0?c.set(i,r):t.push({rule:`duplicate-reference`,path:r,message:`${e} "${n}" is already addressed at ${a}; a proposal states one intention per thing`})};r.forEach((e,t)=>l(`element`,e.ref,`${i}/${t}`)),Tt(e).forEach((e,t)=>l(`relationship`,e.ref,`${s}/${t}`)),At(e).forEach(e=>l(`row`,e.ref,e.at)),(e.removals??[]).forEach((e,t)=>l(e.type,e.ref,`/removals/${t}`));let u=[...r.map((e,t)=>({at:`${i}/${t}`,ref:e.ref,set:e.set})),...Tt(e).map((t,n)=>({at:`${Ot(e)}/${n}`,ref:t.ref,set:t.set})),...At(e)];for(let r of u)r.set!==void 0&&(r.ref===void 0?t.push({rule:`change-without-reference`,path:`${r.at}/set`,message:`a change names a reference to change; without one this is a new thing, and its fields are its values`}):n?e.target===void 0&&t.push({rule:`change-without-target`,path:`${r.at}/set`,message:`a change needs a target: naming what is being changed is what makes this a proposal rather than a new artifact`}):t.push({rule:`kind-not-proposable`,path:`${r.at}/set`,message:Nt(e.kind,`so nothing in it declares a change`)}));let d=e=>{let t=new Set;for(let n of e)n.kind!==void 0&&n.kind!==``&&t.add(n.kind);return t},f=[[e.kind===`sequence`?`participant`:`element`,i,d(r)],[e.kind===`sequence`?`message`:`relationship`,Ot(e),d(Tt(e))]];for(let[e,n,r]of f)r.size>le.kindsPerVocabulary&&t.push({rule:`too-many-kinds`,path:n,message:`${r.size} distinct ${e} types, and no more than ${le.kindsPerVocabulary} can be told apart in a rendering`,observed:r.size,limit:le.kindsPerVocabulary});let p=e.viewpoints;if(Array.isArray(p)){if(e.kind!==`graph`)t.push({rule:`viewpoints-without-graph`,path:`/viewpoints`,message:`only a graph declares viewpoints; a ${e.kind} has no element and relationship kinds for one to retain`});else{let n=new Set(r.map(e=>e.kind).filter(e=>!!e)),i=new Set(Tt(e).map(e=>e.kind).filter(e=>!!e)),a=new Map;p.forEach((e,r)=>{let o=`/viewpoints/${r}`,{id:s,elementKinds:c,relationshipKinds:l}=e,u=a.get(s);u===void 0?a.set(s,r):t.push({rule:`duplicate-viewpoint-identifier`,path:`${o}/id`,message:`viewpoint "${s}" is already declared at /viewpoints/${u}`}),c===void 0&&l===void 0&&t.push({rule:`empty-viewpoint`,path:o,message:`viewpoint "${s}" retains no kind, so it would show nothing it was not already showing; name elementKinds, relationshipKinds, or both`});let d=[[c,n,i,`elementKinds`,`element`,`relationship`],[l,i,n,`relationshipKinds`,`relationship`,`element`]];for(let[e,n,r,i,a,c]of d)e?.forEach((e,l)=>{n.has(e)||t.push({rule:`unresolved-viewpoint-kind`,path:`${o}/${i}/${l}`,message:`viewpoint "${s}" retains ${a} kind "${e}", and no ${a} of this document has it`+(r.has(e)?` (it is a ${c} kind here, which is a different vocabulary)`:``)})})})}}if(e.kind===`table`){let{columns:n,rows:r}=e.data;r.forEach((e,r)=>{let{cells:i,heading:a}=ce(e);a===void 0&&i.length!==n.length&&t.push({rule:`row-column-mismatch`,path:`/data/rows/${r}`,message:`row has ${i.length} values but ${n.length} columns are declared`,observed:i.length,limit:n.length})})}e.kind===`timeline`&&t.push(...yt(e.data));for(let n of kt(e)){n.expect!==void 0&&(e.target===void 0?t.push({rule:`expectation-without-target`,path:`${n.at}/expect`,message:`an expectation is checked by the authority a proposal targets; a document that targets nothing has nobody to check it`}):n.ref===void 0&&t.push({rule:`expectation-without-reference`,path:`${n.at}/expect`,message:`an expectation describes something that already exists, and this item carries no reference to one`}));let r=n.set?.removeAttributes;if(Array.isArray(r)){let e=n.set?.attributes??{},i=new Map;r.forEach((r,a)=>{if(typeof r!=`string`)return;let o=i.get(r);o===void 0?i.set(r,a):t.push({rule:`duplicate-attribute-removal`,path:`${n.at}/set/removeAttributes/${a}`,message:`"${r}" is already removed at ${n.at}/set/removeAttributes/${o}`}),Object.prototype.hasOwnProperty.call(e,r)&&t.push({rule:`attribute-set-and-removed`,path:`${n.at}/set/removeAttributes/${a}`,message:`"${r}" is both assigned and removed; a proposal states one intention per property`})})}Array.isArray(n.locations)&&n.locations.forEach((e,r)=>{if(typeof e!=`object`||!e)return;let i=e.range;i!==void 0&&(i.endLine<i.startLine||i.endLine===i.startLine&&i.endCharacter!==void 0&&i.startCharacter!==void 0&&i.endCharacter<i.startCharacter)&&t.push({rule:`location-range-reversed`,path:`${n.at}/locations/${r}/range`,message:`a range ends before it begins, so it selects nothing a reader could be taken to`})})}e.kind===`table`&&e.data.rows.forEach((e,n)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e;r.role!==void 0&&r.set!==void 0&&t.push({rule:`role-with-change`,path:`/data/rows/${n}/role`,message:`a row states what it observed or what it asks for, not both: a declared role beside a change is a report and an instruction at once`})});let m=new Map;for(let n of jt(e)){let e=m.get(n.id);e===void 0?m.set(n.id,n.at):t.push({rule:`duplicate-identifier`,path:`${n.at}/id`,message:`identifier "${n.id}" is already declared at ${e}`})}return Mt(e).forEach((e,n)=>{for(let r of[`from`,`to`]){let i=e[r];if(typeof i!=`object`||!i)continue;let a=i.id;typeof a==`string`&&(m.has(a)||t.push({rule:`unresolved-endpoint`,path:`/data/relations/${n}/${r}`,message:`"${a}" is not the identifier of any row this document declares`}))}}),t}function Ft(e,t){let n=t(e);if(n.length>0)return{valid:!1,issues:n};let r=e,i=Pt(r);return i.length>0?{valid:!1,issues:i}:{valid:!0,envelope:r,issues:[]}}function It(e,t,n){let r=xe(e,n);if(r!==void 0)return{valid:!1,issues:[r]};let i;try{i=JSON.parse(e)}catch{return{valid:!1,issues:[{rule:`not-json`,path:``,message:`document is not parseable JSON`}]}}let a=Ft(i,t);if(!a.valid)return a;let o=xe(e,n,a.envelope.schema);if(o!==void 0)return{valid:!1,issues:[o]};let s=A(a.envelope,n);return s.length>0?{valid:!1,issues:s}:{valid:!0,envelope:a.envelope,measurement:Se(a.envelope,e),issues:[]}}function Lt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e.schema;if(typeof t==`string`&&t.startsWith(`urn:structured-exchange:`))return t}function Rt(e,t,n){let r=xe(e,n);if(r!==void 0)return{status:`too-large`,issue:r};let i;try{i=JSON.parse(e)}catch{return{status:`not-a-document`,why:`unparseable`}}let a=Lt(i);if(a===void 0)return{status:`not-a-document`,why:`undeclared`};if(me(a)===void 0)return{status:`unsupported-version`,schema:a};let o=Ft(i,t);if(!o.valid)return{status:`invalid`,issues:o.issues};let s=xe(e,n,o.envelope.schema);return s===void 0?{status:`valid`,envelope:o.envelope}:{status:`too-large`,issue:s}}function zt(e){let t=e.replace(/\r\n/g,`
5
+ `)}}var C=`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,w=`flex flex-wrap items-center gap-3 text-xs`,T=null;async function E(e){let t=await(T??=Promise.resolve().then(()=>require("./mermaid.core-uCBIzEBU.cjs")).then(e=>e.t));return t.default.initialize({startOnLoad:!1,theme:e,look:`classic`,securityLevel:`strict`,suppressErrorRendering:!0}),t}function ee(e){let t=/viewBox="\s*[\d.-]+[\s,]+[\d.-]+[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e),n=t?Number(t[1]):NaN;return Number.isFinite(n)&&n>0?n:void 0}function D(e,t){if(typeof e!=`object`||!e||!(`props`in e))return null;let n=e.props;if(t!==void 0&&!RegExp(`\\blanguage-${t}\\b`).test(n.className??``))return null;let r=n.children;return typeof r==`string`?r:Array.isArray(r)&&r.every(e=>typeof e==`string`)?r.join(``):null}function te(e){let t=D(e,`mermaid`);return t===null?null:t.trim()}function ne(e){let{children:t,...n}=e,r=te(t);if(r!==null)return(0,o.jsx)(re,{code:r});let i=D(t);return i===null?(0,o.jsx)(`pre`,{...n,children:t}):(0,o.jsxs)(`div`,{className:`code-block relative`,"data-testid":`code-block`,children:[(0,o.jsx)(`pre`,{...n,children:t}),(0,o.jsx)(u,{iconOnly:!0,text:i.replace(/\n$/,``),className:`absolute right-1.5 top-1.5 rounded border border-zinc-300 bg-white/80 px-1.5 py-0.5 text-xs text-zinc-500 hover:text-zinc-800 dark:border-zinc-700 dark:bg-zinc-900/80 dark:text-zinc-400 dark:hover:text-zinc-100`})]})}function re({code:e}){let n=(0,a.useId)().replace(/[^a-zA-Z0-9]/g,``),r=l()===`light`?`default`:`dark`,[i,s]=(0,a.useState)(null),[c,d]=(0,a.useState)(null),[p,g]=(0,a.useState)(!1),[v,y]=(0,a.useState)(!1),[b,S]=(0,a.useState)(!1),[T,D]=(0,a.useState)(null),te=(0,a.useRef)(!1),ne=(0,a.useRef)(0),re=(0,a.useRef)(0),ie=()=>`mermaid-${n}-${++re.current}`,ae=(0,a.useMemo)(()=>x(e),[e]),oe=ae===void 0?`landscape`:_(ae.direction),[se,ce]=(0,a.useState)(void 0),le=i?.svg??null,ue=i!==null&&i.orientation!==oe,de=(0,a.useRef)(null),O=(0,a.useRef)(e);O.current=e,(0,a.useEffect)(()=>(ne.current+=1,s(null),ce(void 0),y(!1),d(null),D(null),()=>{ne.current+=1}),[e]);async function fe(){if(!i||te.current)return;te.current=!0,S(!0),D(null);let e=ne.current;try{let{renderDiagram:t}=await Promise.resolve().then(()=>require("./mermaidToImage-Gx6dNGEn.cjs")).then(e=>e.r),r=await t(i.source,`mermaid-download-${n}`);if(e!==ne.current)return;let a=URL.createObjectURL(new Blob([r.svg],{type:`image/svg+xml;charset=utf-8`}));try{let e=document.createElement(`a`);e.href=a,e.download=`diagram.svg`,e.click()}finally{URL.revokeObjectURL(a)}}catch(t){e===ne.current&&D(t instanceof Error?t.message:String(t))}finally{te.current=!1,S(!1)}}return(0,a.useEffect)(()=>{let e=!1,n=setTimeout(()=>void t.h(async()=>{try{let t=(await E(r)).default,n=O.current,i=x(n),a=i===void 0?`landscape`:_(i.direction);if(se!==void 0&&i!==void 0){let r=se===a?n:i.turned,{svg:o}=await t.render(ie(),r);e||(s({svg:o,orientation:se,source:r}),d(null));return}let o=await t.render(ie(),n),c={svg:o.svg,orientation:a,source:n},l=ee(o.svg);if(i!==void 0&&l!==void 0&&l>710){let e=await t.render(ie(),i.turned),n=ee(e.svg);if(n!==void 0){let t=a===`landscape`?h(l,n):h(n,l);t!==a&&(c={svg:e.svg,orientation:t,source:i.turned})}}e||(s(c),d(null))}catch(t){e||(s(null),d(t instanceof Error?t.message:String(t)))}}),300);return()=>{e=!0,clearTimeout(n)}},[e,n,r,se]),le?(0,o.jsxs)(`div`,{ref:de,className:`my-2 flex flex-col gap-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-900`,children:[(0,o.jsxs)(`div`,{className:`${w} order-3`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>g(!p),title:p?`Show diagram`:`Show code`,className:C,children:p?`⚏ diagram`:`⌗ code`}),!p&&ae!==void 0&&i!==null&&(0,o.jsx)(`button`,{type:`button`,"data-testid":`mermaid-orientation`,onClick:()=>ce(e=>m(e??i.orientation)),title:i.orientation===`portrait`?`Turn it across the page — it is drawn down`:`Turn it down the page — it is drawn across`,"aria-label":`Turn the diagram ${m(i.orientation)}`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,children:i.orientation===`portrait`?`↔ landscape`:`↕ portrait`}),!p&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>y(!0),"aria-label":`Show diagram at full size`,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50`,children:`⤢ enlarge`}),(0,o.jsx)(`button`,{type:`button`,className:C,disabled:b,onClick:()=>void fe(),title:`Save as .svg — insert it as a picture in a document`,children:b?`preparing SVG…`:`⤓ download SVG`}),(0,o.jsx)(u,{text:e,className:C}),T&&(0,o.jsxs)(`span`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:[`Could not download SVG: `,T]})]}),p?(0,o.jsx)(`pre`,{className:`overflow-x-auto font-mono text-xs text-zinc-500 dark:text-zinc-400`,children:e}):(0,o.jsx)(`div`,{className:`flex justify-center overflow-x-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:le}}),ue&&!p&&(0,o.jsxs)(`div`,{className:`mt-1 text-center text-xs text-zinc-400 dark:text-zinc-600`,"data-testid":`mermaid-turned`,children:[`drawn `,i?.orientation,` to fit — the source asks for `,oe]}),(0,o.jsx)(f,{label:`diagram`,testId:`mermaid-enlarged`,open:v,onClose:()=>y(!1),anchorRef:de,actions:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,className:C,disabled:b,onClick:()=>void fe(),children:b?`preparing SVG…`:`⤓ download SVG`}),T&&(0,o.jsxs)(`span`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:[`Could not download SVG: `,T]})]}),children:(0,o.jsx)(`div`,{style:{width:ee(le)},className:`[&_svg]:!h-auto [&_svg]:!max-w-none [&_svg]:!w-full`,dangerouslySetInnerHTML:{__html:le}})})]}):(0,o.jsxs)(`pre`,{className:`my-2 overflow-x-auto rounded-lg border border-zinc-200 bg-zinc-50 p-3 font-mono text-xs text-zinc-500 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:[e,c&&(0,o.jsx)(`div`,{className:`mt-2 text-red-600 dark:text-red-400`,children:c})]})}var ie=`urn:structured-exchange:1`,ae=[`graph`,`sequence`];function oe(e){return se(e)?[`graph`,`sequence`,`table`]:ae}function se(e){return e===`urn:structured-exchange:2`||e===`urn:structured-exchange:3`}function ce(e){if(Array.isArray(e))return{cells:e};let t=e.heading;return typeof t==`string`?{cells:[],role:e.role,heading:t}:{cells:e.cells,role:e.role}}var le={nodes:500,edges:2e3,participants:100,messages:1e3,columns:50,rows:5e3,removals:500,ref:200,localId:200,label:500,kind:100,kindsPerVocabulary:64,columnName:200,cell:1e3},ue=`urn:structured-exchange:2`,de={profile:200,attributesPerItem:50,removeAttributesPerItem:50,attributeName:200,attributeString:1e3,attributeListItems:50,revision:200,locationsPerItem:10,uri:2e3,position:1e6,artifactsPerItem:20,artifactsPerDocument:50,artifactRel:100,artifactMediaType:100,artifactLabel:500,artifactDigest:71,relations:2e3,heading:500,headingDepth:6,viewpoints:20,viewpointConcern:500},O=8e6,fe=`urn:structured-exchange:3`,pe=[ie,ue,fe];function me(e){return pe.find(t=>t===e)}var he=4e6,ge=Math.max(he,O);function _e(e){return se(e)?O:he}var ve=e=>new TextEncoder().encode(e).length;function ye(e){return e===`bytes`?ge:e===`relations`?de.relations:le[e]}function be(e,t){let n=ye(e),r=t?.[e];return r===void 0||r>=n?{limit:n,level:`ceiling`}:{limit:r,level:`deployment`}}function xe(e,t,n){let r=ve(e),i=be(`bytes`,t),a=n===void 0?1/0:_e(n),o=Math.min(i.limit,a),s=o===a&&a<i.limit?`ceiling`:i.level;if(!(r<=o))return{rule:`document-too-large`,path:``,message:`document is ${r} bytes, past the ${o}-byte ${s===`ceiling`?`contract ceiling`:`limit this deployment applies`}`,limit:o,observed:r,level:s}}var k={graph:[`nodes`,`edges`],sequence:[`participants`,`messages`],table:[`columns`,`rows`,`relations`]};function A(e,t){if(t===void 0)return[];let n=[];for(let r of k[e.kind]??[]){let i=e.data[r];if(!Array.isArray(i))continue;let{limit:a,level:o}=be(r,t);o===`deployment`&&i.length>a&&n.push({rule:`collection-past-deployment-limit`,path:`/data/${r}`,message:`${r} has ${i.length} entries, past the ${a} this deployment allows`,limit:a,observed:i.length,level:o})}return n}function Se(e,t){let n={};for(let t of k[e.kind]??[]){let r=e.data[t];Array.isArray(r)&&(n[t]=r.length)}return{kind:e.kind,bytes:ve(t),counts:n}}var Ce=6.6,we=5.4;function Te(e,t,n){let r=e.flatMap(e=>e.split(/\r?\n/)).reduce((e,t)=>Math.max(e,t.length),0);return Math.min(Math.max(r*Ce+22,t),n)}function Ee(e,t,n,r){let i=t.map(e=>Ae(e).length).reduce((e,t)=>Math.max(e,t),0);return Math.max(Te(e,n,r),Math.min(i*we+22,r))}function De(e,t,n=Ce){let r=Math.max(Math.floor((t-22)/n+1e-6),4),i=[],a=e.split(/\r?\n/);if(a.length>1)return a.flatMap(e=>De(e,t,n)).slice(0,3);let o=``;for(let t of e.split(/\s+/)){let e=o===``?t:`${o} ${t}`;if(e.length<=r)o=e;else for(o!==``&&i.push(o),o=t;o.length>r&&i.length<3;)i.push(o.slice(0,r)),o=o.slice(r)}if(o!==``&&i.push(o),i.length===0)return[``];if(i.length<=3)return i;let s=i.slice(0,3);return s[2]=`${s[2].slice(0,Math.max(r-1,1))}…`,s}function Oe(e,t){return e*15+t*15+14}function ke(e,t){return e.flatMap(e=>De(Ae(e),t,we))}function Ae(e){return`${e.field}: ${e.from===void 0?``:`${e.from} → `}${e.to}`}function je(e,t){return`${e}: ${Me(t)}`}function Me(e){return Array.isArray(e)?e.map(e=>Me(e)).join(`, `):e===null?`null`:typeof e==`object`&&typeof e.ref==`string`?`<${e.ref}>`:String(e)}function Ne(e){let t=e.range===void 0?``:` lines ${e.range.startLine}–${e.range.endLine}`,n=e.revision===void 0?``:` at ${e.revision}`;return`${e.uri}${t}${n}`}function Pe(e){let t=e.label===void 0?e.uri:`${e.label} (${e.uri})`,n=e.mediaType===void 0?``:`, ${e.mediaType}`;return`${e.rel}: ${t}${n} — ${e.sha256.slice(0,14)}…`}var Fe=864e5,Ie=/^(\d{4})-(\d{2})-(\d{2})$/;function Le(e){let t=Ie.exec(e);if(t===null)return;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=new Date(Date.UTC(n,r-1,i));if(a.setUTCFullYear(n,r-1,i),a.getUTCFullYear()===n&&a.getUTCMonth()===r-1&&a.getUTCDate()===i)return Math.round(a.getTime()/Fe)}function Re(e){let t=new Date(e*Fe);return`${String(t.getUTCFullYear()).padStart(4,`0`)}-${String(t.getUTCMonth()+1).padStart(2,`0`)}-${String(t.getUTCDate()).padStart(2,`0`)}`}function ze(e=new Date){return Math.round(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())/Fe)}function Be(e){let t=Le(e.type===`activity`?e.start:e.date),n=Le(e.type===`activity`?e.end:e.date);return t===void 0||n===void 0?void 0:{start:t,end:n}}function Ve(e){let t=new Map;return e.rows.forEach((e,n)=>{e.type===`task`&&(t.has(e.id)||t.set(e.id,{id:e.id,type:`task`,row:n,days:He(e)}),e.items.forEach((e,r)=>{e.id===void 0||t.has(e.id)||t.set(e.id,{id:e.id,type:e.type,row:n,item:r,days:Be(e)})}))}),t}function He(e){let t;for(let n of e.items){let e=Be(n);e!==void 0&&(t=t===void 0?{...e}:{start:Math.min(t.start,e.start),end:Math.max(t.end,e.end)})}return t}function Ue(e){return e.type??`finish-to-start`}function We(e){return{from:e.startsWith(`finish`)?`end`:`start`,to:e.endsWith(`finish`)?`end`:`start`}}function Ge(e,t){let n=t.get(e.from)?.days,r=t.get(e.to)?.days;if(n===void 0||r===void 0)return;let i=We(Ue(e));return r[i.to]>=n[i.from]}function Ke(e){if(`date`in e){let t=Le(e.date)??0;return{start:t,end:t}}return{start:Le(e.start)??0,end:Le(e.end)??0}}function qe(e){if(e.previous===void 0)return;let t=Ke(e.type===`activity`?{start:e.start,end:e.end}:{date:e.date}),n=Ke(e.previous);return{start:t.start-n.start,end:t.end-n.end}}function Je(e){if(e===0)return``;let t=e>0?`+`:`−`,n=Math.abs(e);return n<14?`${t}${n}d`:n<70?`${t}${Math.round(n/7)}w`:`${t}${Math.round(n/30.44)}mo`}function Ye(e){let t=qe(e);return t===void 0?``:t.start===t.end?Je(t.start):t.start===0?`end${Je(t.end)}`:t.end===0?`start${Je(t.start)}`:`${Je(t.start)}, end${Je(t.end)}`}function Xe(e,t){if(e.role!==void 0||t?.role!==void 0)return!0;let n=qe(e);return n!==void 0&&(n.start!==0||n.end!==0)}function Ze(e){return e.role!==void 0||e.items.some(t=>Xe(t,e))}var Qe={week:12,month:4,quarter:.75};function $e(e,t){let n=e>=8?`week`:e>=1?`month`:`quarter`;if(t===void 0)return n;let r=[`week`,`month`,`quarter`];return r[Math.max(r.indexOf(n),r.indexOf(t))]}var et=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function tt(e){return e.width>=24?e.label:e.width>=9?e.label.charAt(0):``}function nt(e,t){return t===`month`?tt(e):e.width>=e.label.length*6+4?e.label:``}function rt(e){return((e+3)%7+7)%7}function it(e){let t=e-rt(e)+3,n=new Date(t*Fe).getUTCFullYear();return Math.floor((t-ct(n,0))/7)+1}function at(e){if(e.label!==void 0&&e.label!==``)return e.label;if(e.type===`milestone`&&e.kind!==void 0&&e.kind!==``)return e.kind}function ot(e){return e.length*Ce}function st(e,t){let n=new Date(e*Fe),r=n.getUTCFullYear(),i=n.getUTCMonth(),a=[];for(;;){i+=1,i===12&&(i=0,r+=1);let e=ct(r,i);if(e>t)return a;a.push({day:e,year:r,month:i})}}function ct(e,t){let n=new Date(0);return n.setUTCFullYear(e,t,1),Math.round(n.getTime()/Fe)}function lt(e,t){let n=e=>e===`bar`||e===`ghost`;return n(e)&&t===`star`||e===`star`&&n(t)}function ut(e,t){return e.x0<t.x1&&t.x0<e.x1}function dt(e,t){if(t<=0||e.width<=t)return;let n=e.items.filter(e=>e.change!==void 0);if(n.length>0){let e=Math.min(...n.flatMap(e=>e.ghost===void 0?[e.glyph.x]:[e.glyph.x,e.ghost.x]));return e<t*.9?void 0:Math.max(0,e-t/6)}if(`x`in e.today&&e.today.x>t*.8)return Math.max(0,e.today.x-t/3)}function ft(e,t,n={}){let r=Le(e.time.start)??0,i=Le(e.time.end)??r,a=n.pxPerDay??Qe[e.time.scale]??4,o=(i-r+1)*a,s=e=>(e-r)*a,c=st(r,i),l=new Date(r*Fe),u=[{day:r,year:l.getUTCFullYear(),month:l.getUTCMonth()},...c],d=u.map((e,t)=>{let n=t+1<u.length?u[t+1].day:i+1;return{label:et[e.month],x:s(e.day),width:(n-e.day)*a,year:e.year,month:e.month}}),f=[];u.forEach((e,t)=>{let n=d[t],r=f[f.length-1];r!==void 0&&r.label===String(e.year)?r.width+=n.width:f.push({label:String(e.year),x:n.x,width:n.width})});let p=$e(a,n.unit),m=(e,t)=>e.map((n,r)=>{let o=r+1<e.length?e[r+1]:i+1;return{label:t(n),x:s(n),width:(o-n)*a}}),h=f,g;if(p===`week`){let e=[];for(let t=r-rt(r)+7;t<=i;t+=7)e.push(t);g=m([r,...e],e=>`W${it(e)}`),h=d.map(e=>({label:`${e.label} ${e.year}`,x:e.x,width:e.width}))}else if(p===`quarter`){let e=u.filter((e,t)=>t===0||e.month%3==0);g=e.map((t,n)=>{let r=n+1<e.length?e[n+1].day:i+1;return{label:`Q${Math.floor(t.month/3)+1}`,x:s(t.day),width:(r-t.day)*a}})}else g=d;let _=g.slice(1).map(e=>e.x),v=[],y=[],b=0,x=e.comparedTo!==void 0,S=(e,t)=>{if(!x)return;if(e.role===`added`||t.role===`added`)return`(new)`;let n=Ye(e);return n===``?void 0:`(${n})`},C=(e,t,n)=>{let r=S(e,t);return r===void 0?n:n===void 0?r:`${n} ${r}`},w=(e,t)=>{if(x)return e.role===`removed`||t.role===`removed`?`removed`:e.role===`added`||t.role===`added`?`added`:Ye(e)===``?void 0:`moved`},T=(e,t)=>{let n=[],r=[],i=[],c=e.map(e=>({...e,days:Be(e.item)})).filter(e=>e.days!==void 0).sort((e,t)=>Number(e.item.type===`milestone`)-Number(t.item.type===`milestone`)||e.days.start-t.days.start||e.row-t.row||e.index-t.index);for(let{item:e,index:t,row:l,days:u,text:d,note:f,change:p}of c){let c=[],m;if(p===`moved`&&e.previous!==void 0){let t=Ke(e.previous);if(e.type===`activity`)m={x0:s(t.start),x1:s(t.end+1)};else{let e=s(t.start)+a/2;m={x0:e-7,x1:e+7,cx:e}}c.push({kind:`ghost`,x0:m.x0,x1:m.x1})}let h,g,_,v;if(e.type===`activity`){if(g=s(u.start),_=s(u.end+1),c.push({kind:`bar`,x0:g,x1:_}),d!==void 0){let e=ot(d);h=e+12<=_-g?{text:d,inside:!0,x:g+6,width:e}:pt(d,g,_,o),f!==void 0&&(h.note=f),c.push({kind:`label`,x0:h.x,x1:h.x+h.width})}}else v=s(u.start)+a/2,g=v-7,_=v+7,c.push({kind:`star`,x0:g,x1:_}),d!==void 0&&(h=pt(d,g,_,o),f!==void 0&&(h.note=f),c.push({kind:`label`,x0:h.x,x1:h.x+h.width}));let y=n.findIndex(e=>c.every(t=>e.every(e=>lt(t.kind,e.kind)||!ut(t,e))));y===-1&&(y=n.length,n.push([])),n[y].push(...c),r.push({row:l,item:t,type:e.type,lane:y,days:u,...e.kind?{kind:e.kind}:{},...p===void 0?{}:{change:p}}),i.push({label:h===void 0?void 0:{...h,...p===`removed`?{struck:!0}:{}},x0:g,x1:_,cx:v,ghost:m})}return r.forEach((e,n)=>{let r=i[n],a=t+4+e.lane*24+12,o=e.type===`activity`?{x:r.x0,y:a-6,width:r.x1-r.x0,height:12}:{x:r.x0,y:a-7,width:14,height:14},s=r.ghost;y.push({...e,glyph:o,...r.cx===void 0?{}:{center:{x:r.cx,y:a}},...r.label===void 0?{}:{label:{...r.label,y:a-8,height:16}},...s===void 0?{}:e.type===`activity`?{ghost:{x:s.x0,y:a-6,width:s.x1-s.x0,height:12}}:{ghost:{x:s.x0,y:a-7,width:14,height:14},ghostCenter:{x:s.cx,y:a}}})}),Math.max(1,n.length)},E=e=>e*24+8,ee=(e,t)=>{let n=T(e.items.map((n,r)=>({row:t,index:r,item:n,text:C(n,e,at(n)),note:S(n,e),change:w(n,e)})),b),r=E(n);v.push({type:`task`,row:t,y:b,height:r,lanes:n,label:e.label,id:e.id}),b+=r},D,te=()=>{if(D!==void 0){if(D.tasks.length===0){let e=D.label?26:10;v.push({type:`separator`,row:D.row,y:b,height:e,...D.label?{label:D.label}:{}}),b+=e}else{let e=T(D.tasks.flatMap(({task:e,row:t})=>e.items.map((n,r)=>({row:t,index:r,item:n,text:C(n,e,at(n)??(n.type===`activity`?e.label:void 0)),note:S(n,e),change:w(n,e)}))),b),t=E(e);v.push({type:`section`,row:D.row,y:b,height:t,lanes:e,...D.label?{label:D.label}:{},tasks:D.tasks.map(({task:e})=>e.id)}),b+=t}D=void 0}},ne=(()=>{let t=new Set;if(!(n.onlyChanged&&x))return;let r;return e.rows.forEach((e,n)=>{e.type===`separator`?r=n:Ze(e)&&(t.add(n),r!==void 0&&t.add(r))}),t})(),re=ne===void 0?0:e.rows.filter((e,t)=>e.type===`task`&&!ne.has(t)).length;e.rows.forEach((e,t)=>{if(ne===void 0||ne.has(t)){if(e.type===`separator`){if(n.compact){te(),D={row:t,...e.label?{label:e.label}:{},tasks:[]};return}let r=e.label?26:10;v.push({type:`separator`,row:t,y:b,height:r,...e.label?{label:e.label}:{}}),b+=r}else D===void 0?ee(e,t):D.tasks.push({task:e,row:t})}}),te();let ie=[];for(let t of e.rows)if(t.type===`task`)for(let e of t.items)e.kind&&!ie.includes(e.kind)&&ie.push(e.kind);for(let t of[...e.periods??[],...e.references??[]])t.kind&&!ie.includes(t.kind)&&ie.push(t.kind);let ae=[];(e.periods??[]).forEach((e,t)=>{let n=Math.max(Le(e.start)??r,r),o=Math.min(Le(e.end)??i,i);n>o||ae.push({index:t,x:s(n),width:(o-n+1)*a,start:e.start,end:e.end,...e.label?{label:e.label}:{},...e.kind?{kind:e.kind}:{}})});let oe=(e.references??[]).flatMap((e,t)=>{let n=Le(e.date);return n===void 0||n<r||n>i?[]:[{index:t,x:s(n)+a/2,label:e.label,date:e.date,...e.kind?{kind:e.kind}:{}}]}),se=[];if(t>=r&&t<=i){let e=s(t)+a/2;se.push({x0:e-26,x1:e+26})}let ce=[],le=[...ae.filter(e=>e.label).map(e=>({of:`period`,index:e.index,text:e.label,x:e.x+3,room:e.width-6})),...oe.map(e=>{let t=ot(e.label)*(10/11);return{of:`reference`,index:e.index,text:e.label,x:Math.min(Math.max(2,e.x-t/2),o-t-2),room:o-4}})].sort((e,t)=>e.x-t.x);for(let e of le){let t=ot(e.text)*(10/11);if(t>e.room)continue;let n={x0:e.x-2,x1:e.x+t+2};se.some(e=>n.x0<e.x1&&e.x0<n.x1)||(se.push(n),ce.push({of:e.of,index:e.index,text:e.text,x:e.x,width:t}))}return{width:o,height:b,start:r,end:i,years:f,months:d,monthLines:c.map(e=>s(e.day)),unit:p,upper:h,lower:g,unitLines:_,rows:v,items:y,dependencies:mt(e,v,y,s),today:t<r?{outside:`before`,day:t}:t>i?{outside:`after`,day:t}:{x:s(t)+a/2,day:t},kinds:ie,hiddenTasks:re,periods:ae,references:oe,headerLabels:ce}}function pt(e,t,n,r){let i=ot(e),a=n+4;if(a+i<=r)return{text:e,inside:!1,x:a,width:i};let o=t-4-i;return o>=0?{text:e,inside:!1,x:o,width:i}:{text:e,inside:!1,x:Math.max(0,r-i),width:i}}function mt(e,t,n,r){let i=Ve(e),a=new Map(n.map(e=>[`${e.row}:${e.item}`,e])),o=new Map(t.map(e=>[e.row,e])),s=(e,t)=>{let s=i.get(e);if(s?.days===void 0)return;if(s.item!==void 0){let e=a.get(`${s.row}:${s.item}`);if(e===void 0)return;let n=e.glyph.y+e.glyph.height/2;return e.center===void 0?{x:t===`start`?e.glyph.x:e.glyph.x+e.glyph.width,y:n}:{x:e.center.x+(t===`start`?-7:7),y:n}}let c=r(t===`start`?s.days.start:s.days.end+1),l=o.get(s.row);if(l!==void 0&&l.type===`task`)return{x:c,y:l.y+4+12};let u=n.filter(e=>e.row===s.row).sort((e,n)=>t===`start`?e.glyph.x-n.glyph.x:n.glyph.x+n.glyph.width-(e.glyph.x+e.glyph.width));if(u.length!==0)return{x:c,y:u[0].glyph.y+u[0].glyph.height/2}},c=[];return(e.dependencies??[]).forEach((e,t)=>{let n=Ue(e),r=We(n),a=s(e.from,r.from),o=s(e.to,r.to),l=Ge(e,i);if(a===void 0||o===void 0||l===void 0)return;let u={x:a.x+(r.from===`end`?8:-8),y:a.y},d={x:o.x+(r.to===`start`?-8:8),y:o.y};if(a.y===o.y&&r.from===`end`&&r.to===`start`&&o.x>=a.x-14){c.push({index:t,from:e.from,to:e.to,type:n,satisfied:l,points:[a,o]});return}let f=o.y>a.y?o.y-12:(o.y,a.y,o.y+12);c.push({index:t,from:e.from,to:e.to,type:n,satisfied:l,points:[a,u,{x:u.x,y:f},{x:d.x,y:f},d,o]})}),c}function ht(e){let t=e.rows.reduce((e,t)=>Math.max(e,(t.label??``).length),0);return Math.min(Math.max(t*Ce+24,120),280)}function gt(e,t){for(let n of e.rows){if(n.type!==`task`)continue;if(n.id===t)return`"${n.label}" (${t})`;let e=n.items.find(e=>e.id===t);if(e!==void 0){let n=at(e);return n===void 0?t:`"${n}" (${t})`}}return t}function _t(e,t,n){let r=n===!1?` — not satisfied by the dates`:``;return`${gt(e,t.to)} waits on ${gt(e,t.from)} (${Ue(t)})${r}`}function vt(e){let t=[];e.title!==void 0&&e.title!==``&&t.push(e.title),e.comparedTo!==void 0&&t.push(`Compared with ${e.comparedTo.label}${e.comparedTo.date===void 0?``:` (${e.comparedTo.date})`}`),t.push(`From ${e.time.start} to ${e.time.end}, by ${e.time.scale}`);for(let n of e.rows){if(t.push(``),n.type===`separator`){t.push(n.label?`— ${n.label} —`:`———`);continue}let e=n.role===void 0?``:n.role===`added`?` — new`:` — removed`;t.push(`${n.label} [${n.id}]${n.items.length===0?` — no items`:``}${e}`);for(let e of n.items){let n=e.type===`activity`?`${e.start} to ${e.end}`:e.date,r=e.label===void 0?``:`: ${e.label}`,i=e.kind===void 0?``:` [${e.kind}]`,a=e.id===void 0?``:` (${e.id})`,o=(()=>{if(e.role===`added`)return` — new`;if(e.role===`removed`)return` — removed`;let t=Ye(e);return t===``||e.previous===void 0?``:` — moved ${t}, was ${`date`in e.previous?e.previous.date:`${e.previous.start} to ${e.previous.end}`}`})();t.push(` ${e.type} ${n}${r}${i}${a}${o}`)}}let n=[...(e.periods??[]).map(e=>` period ${e.start} to ${e.end}${e.label?`: ${e.label}`:``}${e.kind?` [${e.kind}]`:``}`),...(e.references??[]).map(e=>` reference ${e.date}: ${e.label}${e.kind?` [${e.kind}]`:``}`)];n.length>0&&t.push(``,`Calendar`,...n);let r=e.dependencies??[];if(r.length>0){let n=Ve(e);t.push(``,`Dependencies`);for(let i of r)t.push(` ${_t(e,i,Ge(i,n))}`)}return t}function yt(e){let t=[],n=(e,n)=>{let r=Le(e);return r===void 0&&t.push({rule:`invalid-date`,path:n,message:`"${e}" is not a day of the calendar`}),r},r=n(e.time.start,`/data/time/start`),i=n(e.time.end,`/data/time/end`),a=r!==void 0&&i!==void 0&&r<=i?{start:r,end:i}:void 0;r!==void 0&&i!==void 0&&r>i&&t.push({rule:`inverted-range`,path:`/data/time`,message:`the timeline starts on ${e.time.start}, after it ends on ${e.time.end}`});let o=`${e.time.start} to ${e.time.end}`,s=new Map,c=(e,n)=>{if(e===void 0)return;let r=s.get(e);r===void 0?s.set(e,n):t.push({rule:`duplicate-identifier`,path:`${n}/id`,message:`identifier "${e}" is already declared at ${r}`})},l=e.comparedTo!==void 0;e.comparedTo?.date!==void 0&&n(e.comparedTo.date,`/data/comparedTo/date`);let u=e=>t.push({rule:`comparison-without-reference`,path:e,message:"previous dates and change roles describe a comparison; declare `comparedTo` naming the plan they compare with"}),d=new Set;return e.rows.forEach((e,r)=>{if(e.type!==`task`)return;let i=`/data/rows/${r}`;c(e.id,i),e.role!==void 0&&!l&&u(`${i}/role`),e.items.forEach((r,s)=>{let f=`${i}/items/${s}`;if(c(r.id,f),r.kind!==void 0&&d.add(r.kind),r.role!==void 0&&!l&&u(`${f}/role`),r.previous!==void 0){l||u(`${f}/previous`),(r.role!==void 0||e.role!==void 0)&&t.push({rule:`contradictory-change`,path:`${f}/previous`,message:`an item that is ${r.role??`in a task that is ${e.role}`} has no previous dates; it is new or dropped, not moved`});let i=r.previous,s=r.type===`activity`?{first:n(i.start,`${f}/previous/start`),last:n(i.end,`${f}/previous/end`)}:(()=>{let e=n(i.date,`${f}/previous/date`);return{first:e,last:e}})();s.first!==void 0&&s.last!==void 0&&(s.first>s.last?t.push({rule:`inverted-range`,path:`${f}/previous`,message:`the previous dates start on ${i.start}, after they end on ${i.end}`}):a!==void 0&&(s.first<a.start||s.last>a.end)&&t.push({rule:`item-outside-range`,path:`${f}/previous`,message:`the previous dates fall outside the timeline's range ${o}; the range covers both plans, so widen \`time\``}))}r.role!==void 0&&e.role!==void 0&&r.role!==e.role&&t.push({rule:`contradictory-change`,path:`${f}/role`,message:`an item ${r.role} in a task that is ${e.role}`});let p,m;if(r.type===`activity`){if(p=n(r.start,`${f}/start`),m=n(r.end,`${f}/end`),p!==void 0&&m!==void 0&&p>m){t.push({rule:`inverted-range`,path:f,message:`the activity starts on ${r.start}, after it ends on ${r.end}`});return}}else p=m=n(r.date,`${f}/date`);a!==void 0&&p!==void 0&&m!==void 0&&(p<a.start||m>a.end)&&t.push({rule:`item-outside-range`,path:f,message:r.type===`activity`?`the activity runs ${r.start} to ${r.end}, outside the timeline's range ${o}; widen \`time\` or move the activity`:`the milestone falls on ${r.date}, outside the timeline's range ${o}; widen \`time\` or move the milestone`})})}),(e.periods??[]).forEach((e,r)=>{let i=`/data/periods/${r}`;e.kind!==void 0&&d.add(e.kind);let s=n(e.start,`${i}/start`),c=n(e.end,`${i}/end`);s!==void 0&&c!==void 0&&(s>c?t.push({rule:`inverted-range`,path:i,message:`the period starts on ${e.start}, after it ends on ${e.end}`}):a!==void 0&&(c<a.start||s>a.end)&&t.push({rule:`period-outside-range`,path:i,message:`the period ${e.start} to ${e.end} lies wholly outside the timeline's range ${o}, so nothing of it could be drawn`}))}),(e.references??[]).forEach((e,r)=>{let i=`/data/references/${r}`;e.kind!==void 0&&d.add(e.kind);let s=n(e.date,`${i}/date`);s!==void 0&&a!==void 0&&(s<a.start||s>a.end)&&t.push({rule:`item-outside-range`,path:i,message:`the reference date ${e.date} is outside the timeline's range ${o}; widen \`time\` or move it`})}),d.size>le.kindsPerVocabulary&&t.push({rule:`too-many-kinds`,path:`/data/rows`,message:`${d.size} distinct item types, and no more than ${le.kindsPerVocabulary} can be told apart in a rendering`,observed:d.size,limit:le.kindsPerVocabulary}),t.push(...xt(e,Ve(e))),t.push(...bt(e)),t}function bt(e){let t=new Set;for(let n of e.rows)if(n.type===`task`){n.role===`removed`&&t.add(n.id);for(let e of n.items)e.id!==void 0&&(e.role===`removed`||n.role===`removed`)&&t.add(e.id)}let n=[];return(e.dependencies??[]).forEach((e,r)=>{for(let i of[`from`,`to`])t.has(e[i])&&n.push({rule:`dependency-on-removed`,path:`/data/dependencies/${r}/${i}`,message:`"${e[i]}" was dropped from the plan, so nothing can depend on it any more; remove the dependency`})}),n}function xt(e,t){let n=[],r=e.dependencies??[],i=[],a=new Map;r.forEach((r,o)=>{let s=`/data/dependencies/${o}`,c=!0;for(let i of[`from`,`to`]){let a=r[i],o=t.get(a);if(o===void 0)c=!1,n.push({rule:`unresolved-endpoint`,path:`${s}/${i}`,message:`"${a}" is not the identifier of any task or item this timeline declares`});else if(o.type===`task`&&o.days===void 0){c=!1;let t=e.rows[o.row];if(t.type===`task`&&t.items.length>0)continue;n.push({rule:`empty-task-endpoint`,path:`${s}/${i}`,message:`task "${a}" holds no item, so it has no start or finish for a dependency to link`})}}if(!c)return;let l=t.get(r.from),u=t.get(r.to),d=(e,t)=>e.type===`task`&&t.type!==`task`&&t.row===e.row;if(l.id===u.id||d(l,u)||d(u,l)){n.push({rule:`self-dependency`,path:s,message:l.id===u.id?`"${l.id}" cannot depend on itself`:`a task and one of its own items cannot depend on each other: the task's span is made of its items`});return}let f=JSON.stringify([r.from,r.to,Ue(r)]),p=a.get(f);p===void 0?(a.set(f,o),i.push({from:r.from,to:r.to,index:o})):n.push({rule:`duplicate-dependency`,path:s,message:`the same dependency is already declared at /data/dependencies/${p}`})});let o=St(i);return o!==void 0&&n.push({rule:`dependency-cycle`,path:`/data/dependencies/${o.index}`,message:`dependencies form a cycle, which no dates can honour: ${o.ids.join(` → `)}`}),n}function St(e){let t=new Map;for(let n of e){let e=t.get(n.from)??[];e.push({to:n.to,index:n.index}),t.set(n.from,e)}let n=new Map,r=[];for(let e of t.keys()){if(n.has(e))continue;let i=[{id:e,next:0}];for(n.set(e,`open`),r.push({id:e,index:-1});i.length>0;){let e=i[i.length-1],a=t.get(e.id)??[];if(e.next>=a.length){n.set(e.id,`done`),i.pop(),r.pop();continue}let o=a[e.next++],s=n.get(o.to);if(s===`open`){let e=r.findIndex(e=>e.id===o.to);return{ids:[...r.slice(e).map(e=>e.id),o.to],index:o.index}}s===void 0&&(n.set(o.to,`open`),i.push({id:o.to,next:0}),r.push({id:o.to,index:o.index}))}}}function Ct(e){let t=e.data;return e.kind===`graph`?Array.isArray(t.nodes)&&Array.isArray(t.edges):e.kind===`sequence`?Array.isArray(t.participants)&&Array.isArray(t.messages):e.kind===`timeline`?typeof t.time==`object`&&t.time!==null&&Array.isArray(t.rows):Array.isArray(t.columns)&&Array.isArray(t.rows)}function wt(e){return e.kind===`graph`?e.data.nodes:e.kind===`sequence`?e.data.participants:[]}function Tt(e){return e.kind===`graph`?e.data.edges:e.kind===`sequence`?e.data.messages:[]}function Et(e){return e.kind===`graph`||e.kind===`sequence`?e.data.containers??[]:[]}function Dt(e){return e.kind===`graph`?`/data/nodes`:`/data/participants`}function Ot(e){return e.kind===`graph`?`/data/edges`:`/data/messages`}function kt(e){if(e.kind===`timeline`)return[];let t=e.data,n=[];for(let e of[`nodes`,`edges`,`participants`,`messages`,`rows`,`relations`]){let r=t[e];Array.isArray(r)&&r.forEach((t,r)=>{if(typeof t!=`object`||!t||Array.isArray(t))return;let i=t;n.push({at:`/data/${e}/${r}`,ref:typeof i.ref==`string`?i.ref:void 0,set:i.set,expect:i.expect,locations:i.locations})})}return n}function At(e){if(e.kind!==`table`)return[];let t=e.data.rows,n=[];return t.forEach((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e;(r.ref!==void 0||r.set!==void 0)&&n.push({at:`/data/rows/${t}`,...typeof r.ref==`string`?{ref:r.ref}:{},...r.set===void 0?{}:{set:r.set}})}),n}function jt(e){if(e.kind!==`table`)return[];let t=e.data.rows,n=[];return t.forEach((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e.id;typeof r==`string`&&n.push({id:r,at:`/data/rows/${t}`})}),n}function Mt(e){if(e.kind!==`table`)return[];let t=e.data.relations;return Array.isArray(t)?t:[]}function Nt(e,t){return e===`timeline`?`a timeline is maintained by presenting the revised timeline again, not proposed as a change, ${t}`:`a ${e} is a projection and cannot be proposed, ${t}`}function Pt(e){let t=[];if(!Ct(e))return t.push({rule:`kind-data-mismatch`,path:`/data`,message:`data does not carry what kind "${e.kind}" declares`}),t;let n=oe(e.schema).includes(e.kind);e.target!==void 0&&!n&&t.push({rule:`kind-not-proposable`,path:`/target`,message:Nt(e.kind,`so it carries no target`)}),e.removals!==void 0&&(n?e.target===void 0&&t.push({rule:`removal-without-target`,path:`/removals`,message:`removals need a target: an artifact that does not exist yet has nothing to remove`}):t.push({rule:`kind-not-proposable`,path:`/removals`,message:Nt(e.kind,`so it declares no removals`)}));let r=wt(e),i=Dt(e),a=new Map;r.forEach((e,n)=>{let r=a.get(e.id);r===void 0?a.set(e.id,n):t.push({rule:`duplicate-identifier`,path:`${i}/${n}/id`,message:`identifier "${e.id}" is already declared at ${i}/${r}`})});let o=new Map;Et(e).forEach((e,n)=>{let r=o.get(e.id);r===void 0?o.set(e.id,n):t.push({rule:`duplicate-container-identifier`,path:`/data/containers/${n}/id`,message:`container "${e.id}" is already declared at /data/containers/${r}`})}),r.forEach((e,n)=>{for(let[r,a]of[[`container`,e.container],[`set/container`,e.set?.container]])a!==void 0&&!o.has(a)&&t.push({rule:`unresolved-container`,path:`${i}/${n}/${r}`,message:`"${a}" is not a container declared in /data/containers`})});let s=Ot(e);Tt(e).forEach((e,n)=>{for(let r of[`from`,`to`]){let o=e[r];a.has(o)||t.push({rule:`unresolved-endpoint`,path:`${s}/${n}/${r}`,message:`"${o}" is not an identifier declared in ${i}`})}});let c=new Map,l=(e,n,r)=>{if(n===void 0)return;let i=`${e}:${n}`,a=c.get(i);a===void 0?c.set(i,r):t.push({rule:`duplicate-reference`,path:r,message:`${e} "${n}" is already addressed at ${a}; a proposal states one intention per thing`})};r.forEach((e,t)=>l(`element`,e.ref,`${i}/${t}`)),Tt(e).forEach((e,t)=>l(`relationship`,e.ref,`${s}/${t}`)),At(e).forEach(e=>l(`row`,e.ref,e.at)),(e.removals??[]).forEach((e,t)=>l(e.type,e.ref,`/removals/${t}`));let u=[...r.map((e,t)=>({at:`${i}/${t}`,ref:e.ref,set:e.set})),...Tt(e).map((t,n)=>({at:`${Ot(e)}/${n}`,ref:t.ref,set:t.set})),...At(e)];for(let r of u)r.set!==void 0&&(r.ref===void 0?t.push({rule:`change-without-reference`,path:`${r.at}/set`,message:`a change names a reference to change; without one this is a new thing, and its fields are its values`}):n?e.target===void 0&&t.push({rule:`change-without-target`,path:`${r.at}/set`,message:`a change needs a target: naming what is being changed is what makes this a proposal rather than a new artifact`}):t.push({rule:`kind-not-proposable`,path:`${r.at}/set`,message:Nt(e.kind,`so nothing in it declares a change`)}));let d=e=>{let t=new Set;for(let n of e)n.kind!==void 0&&n.kind!==``&&t.add(n.kind);return t},f=[[e.kind===`sequence`?`participant`:`element`,i,d(r)],[e.kind===`sequence`?`message`:`relationship`,Ot(e),d(Tt(e))]];for(let[e,n,r]of f)r.size>le.kindsPerVocabulary&&t.push({rule:`too-many-kinds`,path:n,message:`${r.size} distinct ${e} types, and no more than ${le.kindsPerVocabulary} can be told apart in a rendering`,observed:r.size,limit:le.kindsPerVocabulary});let p=e.viewpoints;if(Array.isArray(p)){if(e.kind!==`graph`)t.push({rule:`viewpoints-without-graph`,path:`/viewpoints`,message:`only a graph declares viewpoints; a ${e.kind} has no element and relationship kinds for one to retain`});else{let n=new Set(r.map(e=>e.kind).filter(e=>!!e)),i=new Set(Tt(e).map(e=>e.kind).filter(e=>!!e)),a=new Map;p.forEach((e,r)=>{let o=`/viewpoints/${r}`,{id:s,elementKinds:c,relationshipKinds:l}=e,u=a.get(s);u===void 0?a.set(s,r):t.push({rule:`duplicate-viewpoint-identifier`,path:`${o}/id`,message:`viewpoint "${s}" is already declared at /viewpoints/${u}`}),c===void 0&&l===void 0&&t.push({rule:`empty-viewpoint`,path:o,message:`viewpoint "${s}" retains no kind, so it would show nothing it was not already showing; name elementKinds, relationshipKinds, or both`});let d=[[c,n,i,`elementKinds`,`element`,`relationship`],[l,i,n,`relationshipKinds`,`relationship`,`element`]];for(let[e,n,r,i,a,c]of d)e?.forEach((e,l)=>{n.has(e)||t.push({rule:`unresolved-viewpoint-kind`,path:`${o}/${i}/${l}`,message:`viewpoint "${s}" retains ${a} kind "${e}", and no ${a} of this document has it`+(r.has(e)?` (it is a ${c} kind here, which is a different vocabulary)`:``)})})})}}if(e.kind===`table`){let{columns:n,rows:r}=e.data;r.forEach((e,r)=>{let{cells:i,heading:a}=ce(e);a===void 0&&i.length!==n.length&&t.push({rule:`row-column-mismatch`,path:`/data/rows/${r}`,message:`row has ${i.length} values but ${n.length} columns are declared`,observed:i.length,limit:n.length})})}e.kind===`timeline`&&t.push(...yt(e.data));for(let n of kt(e)){n.expect!==void 0&&(e.target===void 0?t.push({rule:`expectation-without-target`,path:`${n.at}/expect`,message:`an expectation is checked by the authority a proposal targets; a document that targets nothing has nobody to check it`}):n.ref===void 0&&t.push({rule:`expectation-without-reference`,path:`${n.at}/expect`,message:`an expectation describes something that already exists, and this item carries no reference to one`}));let r=n.set?.removeAttributes;if(Array.isArray(r)){let e=n.set?.attributes??{},i=new Map;r.forEach((r,a)=>{if(typeof r!=`string`)return;let o=i.get(r);o===void 0?i.set(r,a):t.push({rule:`duplicate-attribute-removal`,path:`${n.at}/set/removeAttributes/${a}`,message:`"${r}" is already removed at ${n.at}/set/removeAttributes/${o}`}),Object.prototype.hasOwnProperty.call(e,r)&&t.push({rule:`attribute-set-and-removed`,path:`${n.at}/set/removeAttributes/${a}`,message:`"${r}" is both assigned and removed; a proposal states one intention per property`})})}Array.isArray(n.locations)&&n.locations.forEach((e,r)=>{if(typeof e!=`object`||!e)return;let i=e.range;i!==void 0&&(i.endLine<i.startLine||i.endLine===i.startLine&&i.endCharacter!==void 0&&i.startCharacter!==void 0&&i.endCharacter<i.startCharacter)&&t.push({rule:`location-range-reversed`,path:`${n.at}/locations/${r}/range`,message:`a range ends before it begins, so it selects nothing a reader could be taken to`})})}e.kind===`table`&&e.data.rows.forEach((e,n)=>{if(typeof e!=`object`||!e||Array.isArray(e))return;let r=e;r.role!==void 0&&r.set!==void 0&&t.push({rule:`role-with-change`,path:`/data/rows/${n}/role`,message:`a row states what it observed or what it asks for, not both: a declared role beside a change is a report and an instruction at once`})});let m=new Map;for(let n of jt(e)){let e=m.get(n.id);e===void 0?m.set(n.id,n.at):t.push({rule:`duplicate-identifier`,path:`${n.at}/id`,message:`identifier "${n.id}" is already declared at ${e}`})}return Mt(e).forEach((e,n)=>{for(let r of[`from`,`to`]){let i=e[r];if(typeof i!=`object`||!i)continue;let a=i.id;typeof a==`string`&&(m.has(a)||t.push({rule:`unresolved-endpoint`,path:`/data/relations/${n}/${r}`,message:`"${a}" is not the identifier of any row this document declares`}))}}),t}function Ft(e,t){let n=t(e);if(n.length>0)return{valid:!1,issues:n};let r=e,i=Pt(r);return i.length>0?{valid:!1,issues:i}:{valid:!0,envelope:r,issues:[]}}function It(e,t,n){let r=xe(e,n);if(r!==void 0)return{valid:!1,issues:[r]};let i;try{i=JSON.parse(e)}catch{return{valid:!1,issues:[{rule:`not-json`,path:``,message:`document is not parseable JSON`}]}}let a=Ft(i,t);if(!a.valid)return a;let o=xe(e,n,a.envelope.schema);if(o!==void 0)return{valid:!1,issues:[o]};let s=A(a.envelope,n);return s.length>0?{valid:!1,issues:s}:{valid:!0,envelope:a.envelope,measurement:Se(a.envelope,e),issues:[]}}function Lt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e.schema;if(typeof t==`string`&&t.startsWith(`urn:structured-exchange:`))return t}function Rt(e,t,n){let r=xe(e,n);if(r!==void 0)return{status:`too-large`,issue:r};let i;try{i=JSON.parse(e)}catch{return{status:`not-a-document`,why:`unparseable`}}let a=Lt(i);if(a===void 0)return{status:`not-a-document`,why:`undeclared`};if(me(a)===void 0)return{status:`unsupported-version`,schema:a};let o=Ft(i,t);if(!o.valid)return{status:`invalid`,issues:o.issues};let s=xe(e,n,o.envelope.schema);return s===void 0?{status:`valid`,envelope:o.envelope}:{status:`too-large`,issue:s}}function zt(e){let t=e.replace(/\r\n/g,`
6
6
  `).replace(/\s+$/,``),n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return`sx-${(n>>>0).toString(16).padStart(8,`0`)}-${t.length.toString(36)}`}async function Bt(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.cssText=`position:fixed;top:0;left:0;opacity:0;pointer-events:none`,document.body.append(t);try{return t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}}function Vt(e,t,n){return e>=t&&e<=n}function Ht(e){return e===8205}function Ut(e){return Vt(e,55296,56319)}function Wt(e){return Vt(e,127462,127487)}function Gt(e){return Vt(e,65024,65039)}function Kt(e){return Vt(e,768,879)||Vt(e,6832,6911)||Vt(e,7616,7679)||Vt(e,65056,65071)}function qt(e){return e>65535?2:1}function Jt(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(Kt(n)||Gt(n))t+=qt(n);else break}return t}function Yt(e,t){let n=e.codePointAt(t),r=t+qt(n);for(r=Jt(e,r);r<e.length-1&&Ht(e.codePointAt(r));){let t=e.codePointAt(r+1);r+=1+qt(t),r=Jt(e,r)}return Wt(n)&&r<e.length&&Wt(e.codePointAt(r))&&(r+=qt(e.codePointAt(r))),r}function Xt(e){return Ut(e)||Kt(e)||Gt(e)||Ht(e)}function Zt(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=Yt(e,r),n++,n>=t)return!0;return!1}function Qt(e,t){let n=0,r=0;for(;r<e.length;)if(r=Yt(e,r),n++,n>t)return!1;return!0}function $t(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(Xt(e.charCodeAt(n)))return Zt(e,t);if(n++,n>=t)return!0}return!1}function en(e,t){let n=0;for(;n<e.length;){if(Xt(e.charCodeAt(n)))return Qt(e,t);if(n++,n>t)return!1}return!0}function tn(e){return Array.isArray(e)}function nn(e){return fn(typeof e,`bigint`)}function rn(e){return fn(typeof e,`boolean`)}function an(e){if(dn(e)||!on(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function on(e){return fn(typeof e,`function`)}function sn(e){return fn(e,null)}function cn(e){return fn(typeof e,`object`)&&!sn(e)}function ln(e){return fn(typeof e,`string`)}function un(e){return fn(typeof e,`symbol`)}function dn(e){return fn(e,void 0)}function fn(e,t){return e===t}function j(e,t){return en(e,t)}function M(e,t){return $t(e,t)}function pn(e){return e instanceof Boolean}function mn(e){return e instanceof Number}function hn(e){return e instanceof String}function gn(e){return globalThis.ArrayBuffer.isView(e)}function _n(e){return e instanceof globalThis.RegExp}function vn(e){return e instanceof globalThis.Date}var yn=[];function bn(e){yn=e.variables}var xn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>yn[0].test(e)||!1)&&e.schema===`urn:structured-exchange:1`&&(e.kind===`graph`||e.kind===`sequence`||e.kind===`table`)&&(e.target===void 0||!(`target`in e)||Sn(e.target))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>Cn(e))&&e.removals.length<=500)&&[typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`nodes`in e.data&&`edges`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>yn[2].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>Dn(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>kn(e))&&e.data.edges.length<=2e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>jn(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`participants`in e.data&&`messages`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>yn[8].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>Dn(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>Mn(e))&&e.data.messages.length<=1e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>jn(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`columns`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).length===2&&Array.isArray(e.data.columns)&&e.data.columns.every((e,t)=>typeof e==`string`&&j(e,200)&&M(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[Pn(e),typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>yn[11].test(e)||!1)&&Pn(e.cells)&&(e.role===void 0||!(`role`in e)||e.role===`added`||e.role===`changed`||e.role===`context`||e.role===`removed`)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.data.rows.length<=5e3].reduce((e,t,n)=>t===!0?++e:e,0)===1),Sn=(e=>typeof e==`string`&&j(e,200)&&M(e,1)),Cn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>yn[1].test(e)||!1)&&(e.type===`element`||e.type===`relationship`)&&Sn(e.ref)&&(e.label===void 0||!(`label`in e)||wn(e.label))&&(e.kind===void 0||!(`kind`in e)||Tn(e.kind))&&(e.from===void 0||!(`from`in e)||En(e.from))&&(e.to===void 0||!(`to`in e)||En(e.to))),wn=(e=>typeof e==`string`&&j(e,500)),Tn=(e=>typeof e==`string`&&j(e,100)&&M(e,1)),En=(e=>typeof e==`string`&&j(e,200)&&M(e,1)),Dn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>yn[3].test(e)||!1)&&En(e.id)&&(e.ref===void 0||!(`ref`in e)||Sn(e.ref))&&(e.label===void 0||!(`label`in e)||wn(e.label))&&(e.kind===void 0||!(`kind`in e)||Tn(e.kind))&&(e.set===void 0||!(`set`in e)||On(e.set))&&(e.container===void 0||!(`container`in e)||En(e.container))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),On=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>yn[4].test(e)||!1)&&(e.label===void 0||!(`label`in e)||wn(e.label))&&(e.kind===void 0||!(`kind`in e)||Tn(e.kind))&&(e.container===void 0||!(`container`in e)||En(e.container))&&Object.getOwnPropertyNames(e).length>=1),kn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>yn[5].test(e)||!1)&&En(e.from)&&En(e.to)&&(e.kind===void 0||!(`kind`in e)||Tn(e.kind))&&(e.ref===void 0||!(`ref`in e)||Sn(e.ref))&&(e.label===void 0||!(`label`in e)||wn(e.label))&&(e.set===void 0||!(`set`in e)||An(e.set))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),An=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>yn[6].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||Tn(e.kind))&&(e.label===void 0||!(`label`in e)||wn(e.label))&&Object.getOwnPropertyNames(e).length>=1),jn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>yn[7].test(e)||!1)&&En(e.id)&&wn(e.label)&&(e.kind===void 0||!(`kind`in e)||Tn(e.kind))),Mn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>yn[9].test(e)||!1)&&En(e.from)&&En(e.to)&&(e.ref===void 0||!(`ref`in e)||Sn(e.ref))&&(e.label===void 0||!(`label`in e)||wn(e.label))&&(e.set===void 0||!(`set`in e)||Nn(e.set))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),Nn=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>yn[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||wn(e.label))&&Object.getOwnPropertyNames(e).length>=1),Pn=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||j(e,1e3)))&&e.length<=50);function Fn(e){return xn(e)}bn({variables:[RegExp(`(^schema$|^kind$|^target$|^removals$|^data$)`,`u`),RegExp(`(^type$|^ref$|^label$|^kind$|^from$|^to$)`,`u`),RegExp(`(^nodes$|^edges$|^containers$)`,`u`),RegExp(`(^id$|^ref$|^label$|^kind$|^set$|^container$)`,`u`),RegExp(`(^label$|^kind$|^container$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^set$)`,`u`),RegExp(`(^kind$|^label$)`,`u`),RegExp(`(^id$|^label$|^kind$)`,`u`),RegExp(`(^participants$|^messages$|^containers$)`,`u`),RegExp(`(^from$|^to$|^ref$|^label$|^set$)`,`u`),RegExp(`(^label$)`,`u`),RegExp(`(^cells$|^role$)`,`u`)]});function In(){throw Error(`Unreachable`)}function Ln(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Reflect.ownKeys(n))e!==`constructor`&&typeof e!=`symbol`&&t.add(e);n=Object.getPrototypeOf(n)}return[...t]}function Rn(e){return typeof e==`number`}var zn;(function(e){e[e.Array=0]=`Array`,e[e.BigInt=1]=`BigInt`,e[e.Boolean=2]=`Boolean`,e[e.Date=3]=`Date`,e[e.Constructor=4]=`Constructor`,e[e.Function=5]=`Function`,e[e.Null=6]=`Null`,e[e.Number=7]=`Number`,e[e.Object=8]=`Object`,e[e.RegExp=9]=`RegExp`,e[e.String=10]=`String`,e[e.Symbol=11]=`Symbol`,e[e.TypeArray=12]=`TypeArray`,e[e.Undefined=13]=`Undefined`})(zn||={});var Bn=BigInt(`14695981039346656037`),[Vn,Hn]=[BigInt(`1099511628211`),BigInt(`18446744073709551616`)],Un=Array.from({length:256}).map((e,t)=>BigInt(t)),Wn=new Float64Array(1),Gn=new DataView(Wn.buffer),Kn=new Uint8Array(Wn.buffer);function qn(e){Bn^=Un[e],Bn=Bn*Vn%Hn}function Jn(e){qn(zn.Array);for(let t of e)lr(t)}function Yn(e){qn(zn.BigInt),Gn.setBigInt64(0,e);for(let e of Kn)qn(e)}function Xn(e){qn(zn.Boolean),qn(+!!e)}function Zn(e){qn(zn.Constructor),lr(e.toString())}function Qn(e){qn(zn.Date),lr(e.getTime())}function $n(e){qn(zn.Function),lr(e.toString())}function er(e){qn(zn.Null)}function tr(e){qn(zn.Number),Gn.setFloat64(0,e,!0);for(let e of Kn)qn(e)}function nr(e){qn(zn.Object);for(let t of Ln(e).sort())lr(t),lr(e[t])}function rr(e){qn(zn.RegExp),ar(e.toString())}var ir=new TextEncoder;function ar(e){qn(zn.String);for(let t of ir.encode(e))qn(t)}function or(e){qn(zn.Symbol),lr(e.toString())}function sr(e){qn(zn.TypeArray);let t=new Uint8Array(e.buffer);for(let e=0;e<t.length;e++)qn(t[e])}function cr(e){return qn(zn.Undefined)}function lr(e){return gn(e)?sr(e):vn(e)?Qn(e):_n(e)?rr(e):pn(e)?Xn(e.valueOf()):hn(e)?ar(e.valueOf()):mn(e)?tr(e.valueOf()):Rn(e)?tr(e):tn(e)?Jn(e):rn(e)?Xn(e):nn(e)?Yn(e):an(e)?Zn(e):sn(e)?er(e):cn(e)?nr(e):ln(e)?ar(e):un(e)?or(e):dn(e)?cr(e):on(e)?$n(e):In()}function ur(e){return Bn=BigInt(`14695981039346656037`),lr(e),Bn}function dr(e){return ur(e).toString(16).padStart(16,`0`)}var fr=[];function pr(e){fr=e.variables}var mr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[0].test(e)||!1)&&e.schema===`urn:structured-exchange:2`&&(e.kind===`graph`||e.kind===`sequence`||e.kind===`table`)&&(e.profile===void 0||!(`profile`in e)||typeof e.profile==`string`&&j(e.profile,200)&&M(e.profile,1))&&(e.target===void 0||!(`target`in e)||typeof e.target==`object`&&e.target!==null&&!Array.isArray(e.target)&&`ref`in e.target&&Object.getOwnPropertyNames(e.target).every((e,t)=>fr[1].test(e)||!1)&&hr(e.target.ref)&&(e.target.revision===void 0||!(`revision`in e.target)||gr(e.target.revision)))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>_r(e))&&e.removals.length<=500)&&(e.artifacts===void 0||!(`artifacts`in e)||Array.isArray(e.artifacts)&&e.artifacts.every((e,t)=>xr(e))&&e.artifacts.length<=50)&&(e.viewpoints===void 0||!(`viewpoints`in e)||Array.isArray(e.viewpoints)&&e.viewpoints.every((e,t)=>Sr(e))&&e.viewpoints.length<=20)&&[typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`nodes`in e.data&&`edges`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>fr[6].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>Cr(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>Fr(e))&&e.data.edges.length<=2e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>Lr(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`participants`in e.data&&`messages`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>fr[16].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>Cr(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>Rr(e))&&e.data.messages.length<=1e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>Lr(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`columns`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>fr[19].test(e)||!1)&&Array.isArray(e.data.columns)&&e.data.columns.every((e,t)=>typeof e==`string`&&j(e,200)&&M(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[Br(e),Vr(e),Wr(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.data.rows.length<=5e3&&(e.data.relations===void 0||!(`relations`in e.data)||Array.isArray(e.data.relations)&&e.data.relations.every((e,t)=>Gr(e))&&e.data.relations.length<=2e3)].reduce((e,t,n)=>t===!0?++e:e,0)===1),hr=(e=>typeof e==`string`&&j(e,200)&&M(e,1)),gr=(e=>typeof e==`string`&&j(e,200)&&M(e,1)),_r=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[2].test(e)||!1)&&(e.type===`element`||e.type===`relationship`||e.type===`row`)&&hr(e.ref)&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.kind===void 0||!(`kind`in e)||yr(e.kind))&&(e.from===void 0||!(`from`in e)||br(e.from))&&(e.to===void 0||!(`to`in e)||br(e.to))),vr=(e=>typeof e==`string`&&j(e,500)),yr=(e=>typeof e==`string`&&j(e,100)&&M(e,1)),br=(e=>typeof e==`string`&&j(e,200)&&M(e,1)),xr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`rel`in e&&`uri`in e&&`sha256`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[3].test(e)||!1)&&typeof e.rel==`string`&&j(e.rel,100)&&M(e.rel,1)&&typeof e.uri==`string`&&j(e.uri,2e3)&&M(e.uri,1)&&typeof e.sha256==`string`&&fr[4].test(e.sha256)&&(e.mediaType===void 0||!(`mediaType`in e)||typeof e.mediaType==`string`&&j(e.mediaType,100)&&M(e.mediaType,1))&&(e.label===void 0||!(`label`in e)||vr(e.label))),Sr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&`concern`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[5].test(e)||!1)&&br(e.id)&&typeof e.label==`string`&&j(e.label,500)&&M(e.label,1)&&typeof e.concern==`string`&&j(e.concern,500)&&M(e.concern,1)&&(e.elementKinds===void 0||!(`elementKinds`in e)||Array.isArray(e.elementKinds)&&e.elementKinds.every((e,t)=>yr(e))&&e.elementKinds.length<=64&&e.elementKinds.length>=1&&new Set(e.elementKinds.map(dr)).size===e.elementKinds.length)&&(e.relationshipKinds===void 0||!(`relationshipKinds`in e)||Array.isArray(e.relationshipKinds)&&e.relationshipKinds.every((e,t)=>yr(e))&&e.relationshipKinds.length<=64&&e.relationshipKinds.length>=1&&new Set(e.relationshipKinds.map(dr)).size===e.relationshipKinds.length)),Cr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[7].test(e)||!1)&&br(e.id)&&(e.ref===void 0||!(`ref`in e)||hr(e.ref))&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.kind===void 0||!(`kind`in e)||yr(e.kind))&&(e.set===void 0||!(`set`in e)||wr(e.set))&&(e.container===void 0||!(`container`in e)||br(e.container))&&(e.attributes===void 0||!(`attributes`in e)||Tr(e.attributes))&&(e.expect===void 0||!(`expect`in e)||Ar(e.expect))&&(e.locations===void 0||!(`locations`in e)||jr(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Pr(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),wr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>fr[8].test(e)||!1)&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.kind===void 0||!(`kind`in e)||yr(e.kind))&&(e.container===void 0||!(`container`in e)||br(e.container))&&(e.attributes===void 0||!(`attributes`in e)||Tr(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||kr(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Tr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((t,n)=>fr[9].test(t)||Er(e[t]))&&Object.getOwnPropertyNames(e).every((e,t)=>typeof e!=`string`||j(e,200)&&M(e,1))&&Object.getOwnPropertyNames(e).length<=50),Er=(e=>[Dr(e),Or(e),Array.isArray(e)&&e.every((e,t)=>[Dr(e),Or(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.length<=50].reduce((e,t,n)=>t===!0?++e:e,0)===1),Dr=(e=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||j(e,1e3))),Or=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`ref`in e&&Object.getOwnPropertyNames(e).length===1&&hr(e.ref)),kr=(e=>Array.isArray(e)&&e.every((e,t)=>br(e))&&e.length<=50),Ar=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>fr[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.kind===void 0||!(`kind`in e)||yr(e.kind))&&(e.container===void 0||!(`container`in e)||br(e.container))&&(e.revision===void 0||!(`revision`in e)||gr(e.revision))&&(e.attributes===void 0||!(`attributes`in e)||Tr(e.attributes))&&Object.getOwnPropertyNames(e).length>=1),jr=(e=>Array.isArray(e)&&e.every((e,t)=>Mr(e))&&e.length<=10),Mr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`uri`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[11].test(e)||!1)&&typeof e.uri==`string`&&j(e.uri,2e3)&&M(e.uri,1)&&(e.revision===void 0||!(`revision`in e)||gr(e.revision))&&(e.range===void 0||!(`range`in e)||typeof e.range==`object`&&e.range!==null&&!Array.isArray(e.range)&&`startLine`in e.range&&`endLine`in e.range&&Object.getOwnPropertyNames(e.range).every((e,t)=>fr[12].test(e)||!1)&&Nr(e.range.startLine)&&(e.range.startCharacter===void 0||!(`startCharacter`in e.range)||Nr(e.range.startCharacter))&&Nr(e.range.endLine)&&(e.range.endCharacter===void 0||!(`endCharacter`in e.range)||Nr(e.range.endCharacter)))),Nr=(e=>Number.isInteger(e)&&(!(Number.isFinite(e)||typeof e==`bigint`)||e<=1e6&&e>=0)),Pr=(e=>Array.isArray(e)&&e.every((e,t)=>xr(e))&&e.length<=20),Fr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[13].test(e)||!1)&&br(e.from)&&br(e.to)&&(e.kind===void 0||!(`kind`in e)||yr(e.kind))&&(e.ref===void 0||!(`ref`in e)||hr(e.ref))&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.set===void 0||!(`set`in e)||Ir(e.set))&&(e.attributes===void 0||!(`attributes`in e)||Tr(e.attributes))&&(e.expect===void 0||!(`expect`in e)||Ar(e.expect))&&(e.locations===void 0||!(`locations`in e)||jr(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Pr(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),Ir=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>fr[14].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||yr(e.kind))&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.attributes===void 0||!(`attributes`in e)||Tr(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||kr(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Lr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[15].test(e)||!1)&&br(e.id)&&vr(e.label)&&(e.kind===void 0||!(`kind`in e)||yr(e.kind))),Rr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[17].test(e)||!1)&&br(e.from)&&br(e.to)&&(e.ref===void 0||!(`ref`in e)||hr(e.ref))&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.set===void 0||!(`set`in e)||zr(e.set))&&(e.attributes===void 0||!(`attributes`in e)||Tr(e.attributes))&&(e.expect===void 0||!(`expect`in e)||Ar(e.expect))&&(e.locations===void 0||!(`locations`in e)||jr(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Pr(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),zr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>fr[18].test(e)||!1)&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.attributes===void 0||!(`attributes`in e)||Tr(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||kr(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Br=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||j(e,1e3)))&&e.length<=50),Vr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[20].test(e)||!1)&&Br(e.cells)&&(e.role===void 0||!(`role`in e)||Hr(e.role))&&(e.id===void 0||!(`id`in e)||br(e.id))&&(e.ref===void 0||!(`ref`in e)||hr(e.ref))&&(e.kind===void 0||!(`kind`in e)||yr(e.kind))&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.set===void 0||!(`set`in e)||Ur(e.set))&&(e.attributes===void 0||!(`attributes`in e)||Tr(e.attributes))&&(e.expect===void 0||!(`expect`in e)||Ar(e.expect))&&(e.locations===void 0||!(`locations`in e)||jr(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||Pr(e.artifacts))),Hr=(e=>e===`added`||e===`changed`||e===`context`||e===`removed`),Ur=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>fr[21].test(e)||!1)&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.kind===void 0||!(`kind`in e)||yr(e.kind))&&(e.cells===void 0||!(`cells`in e)||Br(e.cells))&&(e.attributes===void 0||!(`attributes`in e)||Tr(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||kr(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Wr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`heading`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[22].test(e)||!1)&&typeof e.heading==`string`&&j(e.heading,500)&&M(e.heading,1)&&(e.depth===void 0||!(`depth`in e)||Number.isInteger(e.depth)&&(!(Number.isFinite(e.depth)||typeof e.depth==`bigint`)||e.depth<=6&&e.depth>=1))&&(e.role===void 0||!(`role`in e)||Hr(e.role))&&(e.id===void 0||!(`id`in e)||br(e.id))&&(e.ref===void 0||!(`ref`in e)||hr(e.ref))),Gr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&`kind`in e&&Object.getOwnPropertyNames(e).every((e,t)=>fr[23].test(e)||!1)&&Kr(e.from)&&Kr(e.to)&&yr(e.kind)&&(e.ref===void 0||!(`ref`in e)||hr(e.ref))&&(e.label===void 0||!(`label`in e)||vr(e.label))&&(e.attributes===void 0||!(`attributes`in e)||Tr(e.attributes))),Kr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>fr[24].test(e)||!1)&&(e.id===void 0||!(`id`in e)||br(e.id))&&(e.ref===void 0||!(`ref`in e)||hr(e.ref))&&Object.getOwnPropertyNames(e).length>=1&&Object.getOwnPropertyNames(e).length<=1&&[!(typeof e==`object`&&e&&!Array.isArray(e))||`id`in e,!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e].reduce((e,t,n)=>t===!0?++e:e,0)===1);function qr(e){return mr(e)}pr({variables:[RegExp(`(^schema$|^kind$|^profile$|^target$|^removals$|^artifacts$|^viewpoints$|^data$)`,`u`),RegExp(`(^ref$|^revision$)`,`u`),RegExp(`(^type$|^ref$|^label$|^kind$|^from$|^to$)`,`u`),RegExp(`(^rel$|^uri$|^sha256$|^mediaType$|^label$)`,`u`),RegExp(`^sha256:[0-9a-f]{64}$`,`u`),RegExp(`(^id$|^label$|^concern$|^elementKinds$|^relationshipKinds$)`,`u`),RegExp(`(^nodes$|^edges$|^containers$)`,`u`),RegExp(`(^id$|^ref$|^label$|^kind$|^set$|^container$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^container$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(?!)`,`u`),RegExp(`(^label$|^kind$|^container$|^revision$|^attributes$)`,`u`),RegExp(`(^uri$|^revision$|^range$)`,`u`),RegExp(`(^startLine$|^startCharacter$|^endLine$|^endCharacter$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^kind$|^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^id$|^label$|^kind$)`,`u`),RegExp(`(^participants$|^messages$|^containers$)`,`u`),RegExp(`(^from$|^to$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^columns$|^rows$|^relations$)`,`u`),RegExp(`(^cells$|^role$|^id$|^ref$|^kind$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^cells$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^heading$|^depth$|^role$|^id$|^ref$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^attributes$)`,`u`),RegExp(`(^id$|^ref$)`,`u`)]});var N=[];function Jr(e){N=e.variables}var Yr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`schema`in e&&`kind`in e&&`data`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[0].test(e)||!1)&&e.schema===`urn:structured-exchange:3`&&(e.kind===`graph`||e.kind===`sequence`||e.kind===`table`||e.kind===`timeline`)&&(e.profile===void 0||!(`profile`in e)||typeof e.profile==`string`&&j(e.profile,200)&&M(e.profile,1))&&(e.target===void 0||!(`target`in e)||typeof e.target==`object`&&e.target!==null&&!Array.isArray(e.target)&&`ref`in e.target&&Object.getOwnPropertyNames(e.target).every((e,t)=>N[1].test(e)||!1)&&Xr(e.target.ref)&&(e.target.revision===void 0||!(`revision`in e.target)||Zr(e.target.revision)))&&(e.removals===void 0||!(`removals`in e)||Array.isArray(e.removals)&&e.removals.every((e,t)=>Qr(e))&&e.removals.length<=500)&&(e.artifacts===void 0||!(`artifacts`in e)||Array.isArray(e.artifacts)&&e.artifacts.every((e,t)=>ni(e))&&e.artifacts.length<=50)&&(e.viewpoints===void 0||!(`viewpoints`in e)||Array.isArray(e.viewpoints)&&e.viewpoints.every((e,t)=>ri(e))&&e.viewpoints.length<=20)&&[typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`nodes`in e.data&&`edges`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>N[6].test(e)||!1)&&Array.isArray(e.data.nodes)&&e.data.nodes.every((e,t)=>ii(e))&&e.data.nodes.length<=500&&e.data.nodes.length>=1&&Array.isArray(e.data.edges)&&e.data.edges.every((e,t)=>gi(e))&&e.data.edges.length<=2e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>vi(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`participants`in e.data&&`messages`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>N[16].test(e)||!1)&&Array.isArray(e.data.participants)&&e.data.participants.every((e,t)=>ii(e))&&e.data.participants.length<=100&&e.data.participants.length>=1&&Array.isArray(e.data.messages)&&e.data.messages.every((e,t)=>yi(e))&&e.data.messages.length<=1e3&&(e.data.containers===void 0||!(`containers`in e.data)||Array.isArray(e.data.containers)&&e.data.containers.every((e,t)=>vi(e))&&e.data.containers.length<=50),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`columns`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>N[19].test(e)||!1)&&Array.isArray(e.data.columns)&&e.data.columns.every((e,t)=>typeof e==`string`&&j(e,200)&&M(e,1))&&e.data.columns.length<=50&&e.data.columns.length>=1&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>[xi(e),Si(e),Ti(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.data.rows.length<=5e3&&(e.data.relations===void 0||!(`relations`in e.data)||Array.isArray(e.data.relations)&&e.data.relations.every((e,t)=>Ei(e))&&e.data.relations.length<=2e3),typeof e.data==`object`&&e.data!==null&&!Array.isArray(e.data)&&`time`in e.data&&`rows`in e.data&&Object.getOwnPropertyNames(e.data).every((e,t)=>N[25].test(e)||!1)&&(e.data.title===void 0||!(`title`in e.data)||$r(e.data.title))&&typeof e.data.time==`object`&&e.data.time!==null&&!Array.isArray(e.data.time)&&`start`in e.data.time&&`end`in e.data.time&&`scale`in e.data.time&&Object.getOwnPropertyNames(e.data.time).length===3&&Oi(e.data.time.start)&&Oi(e.data.time.end)&&(e.data.time.scale===`week`||e.data.time.scale===`month`||e.data.time.scale===`quarter`)&&Array.isArray(e.data.rows)&&e.data.rows.every((e,t)=>ki(e))&&e.data.rows.length<=500&&(e.data.dependencies===void 0||!(`dependencies`in e.data)||Array.isArray(e.data.dependencies)&&e.data.dependencies.every((e,t)=>Ii(e))&&e.data.dependencies.length<=2e3)&&(e.data.comparedTo===void 0||!(`comparedTo`in e.data)||typeof e.data.comparedTo==`object`&&e.data.comparedTo!==null&&!Array.isArray(e.data.comparedTo)&&`label`in e.data.comparedTo&&Object.getOwnPropertyNames(e.data.comparedTo).every((e,t)=>N[32].test(e)||!1)&&typeof e.data.comparedTo.label==`string`&&j(e.data.comparedTo.label,500)&&M(e.data.comparedTo.label,1)&&(e.data.comparedTo.date===void 0||!(`date`in e.data.comparedTo)||Oi(e.data.comparedTo.date)))&&(e.data.periods===void 0||!(`periods`in e.data)||Array.isArray(e.data.periods)&&e.data.periods.every((e,t)=>Li(e))&&e.data.periods.length<=100)&&(e.data.references===void 0||!(`references`in e.data)||Array.isArray(e.data.references)&&e.data.references.every((e,t)=>Ri(e))&&e.data.references.length<=50)].reduce((e,t,n)=>t===!0?++e:e,0)===1),Xr=(e=>typeof e==`string`&&j(e,200)&&M(e,1)),Zr=(e=>typeof e==`string`&&j(e,200)&&M(e,1)),Qr=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`ref`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[2].test(e)||!1)&&(e.type===`element`||e.type===`relationship`||e.type===`row`)&&Xr(e.ref)&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))&&(e.from===void 0||!(`from`in e)||ti(e.from))&&(e.to===void 0||!(`to`in e)||ti(e.to))),$r=(e=>typeof e==`string`&&j(e,500)),ei=(e=>typeof e==`string`&&j(e,100)&&M(e,1)),ti=(e=>typeof e==`string`&&j(e,200)&&M(e,1)),ni=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`rel`in e&&`uri`in e&&`sha256`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[3].test(e)||!1)&&typeof e.rel==`string`&&j(e.rel,100)&&M(e.rel,1)&&typeof e.uri==`string`&&j(e.uri,2e3)&&M(e.uri,1)&&typeof e.sha256==`string`&&N[4].test(e.sha256)&&(e.mediaType===void 0||!(`mediaType`in e)||typeof e.mediaType==`string`&&j(e.mediaType,100)&&M(e.mediaType,1))&&(e.label===void 0||!(`label`in e)||$r(e.label))),ri=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&`concern`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[5].test(e)||!1)&&ti(e.id)&&typeof e.label==`string`&&j(e.label,500)&&M(e.label,1)&&typeof e.concern==`string`&&j(e.concern,500)&&M(e.concern,1)&&(e.elementKinds===void 0||!(`elementKinds`in e)||Array.isArray(e.elementKinds)&&e.elementKinds.every((e,t)=>ei(e))&&e.elementKinds.length<=64&&e.elementKinds.length>=1&&new Set(e.elementKinds.map(dr)).size===e.elementKinds.length)&&(e.relationshipKinds===void 0||!(`relationshipKinds`in e)||Array.isArray(e.relationshipKinds)&&e.relationshipKinds.every((e,t)=>ei(e))&&e.relationshipKinds.length<=64&&e.relationshipKinds.length>=1&&new Set(e.relationshipKinds.map(dr)).size===e.relationshipKinds.length)),ii=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[7].test(e)||!1)&&ti(e.id)&&(e.ref===void 0||!(`ref`in e)||Xr(e.ref))&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))&&(e.set===void 0||!(`set`in e)||ai(e.set))&&(e.container===void 0||!(`container`in e)||ti(e.container))&&(e.attributes===void 0||!(`attributes`in e)||oi(e.attributes))&&(e.expect===void 0||!(`expect`in e)||di(e.expect))&&(e.locations===void 0||!(`locations`in e)||fi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||hi(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),ai=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>N[8].test(e)||!1)&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))&&(e.container===void 0||!(`container`in e)||ti(e.container))&&(e.attributes===void 0||!(`attributes`in e)||oi(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||ui(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),oi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((t,n)=>N[9].test(t)||si(e[t]))&&Object.getOwnPropertyNames(e).every((e,t)=>typeof e!=`string`||j(e,200)&&M(e,1))&&Object.getOwnPropertyNames(e).length<=50),si=(e=>[ci(e),li(e),Array.isArray(e)&&e.every((e,t)=>[ci(e),li(e)].reduce((e,t,n)=>t===!0?++e:e,0)===1)&&e.length<=50].reduce((e,t,n)=>t===!0?++e:e,0)===1),ci=(e=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||j(e,1e3))),li=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`ref`in e&&Object.getOwnPropertyNames(e).length===1&&Xr(e.ref)),ui=(e=>Array.isArray(e)&&e.every((e,t)=>ti(e))&&e.length<=50),di=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>N[10].test(e)||!1)&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))&&(e.container===void 0||!(`container`in e)||ti(e.container))&&(e.revision===void 0||!(`revision`in e)||Zr(e.revision))&&(e.attributes===void 0||!(`attributes`in e)||oi(e.attributes))&&Object.getOwnPropertyNames(e).length>=1),fi=(e=>Array.isArray(e)&&e.every((e,t)=>pi(e))&&e.length<=10),pi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`uri`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[11].test(e)||!1)&&typeof e.uri==`string`&&j(e.uri,2e3)&&M(e.uri,1)&&(e.revision===void 0||!(`revision`in e)||Zr(e.revision))&&(e.range===void 0||!(`range`in e)||typeof e.range==`object`&&e.range!==null&&!Array.isArray(e.range)&&`startLine`in e.range&&`endLine`in e.range&&Object.getOwnPropertyNames(e.range).every((e,t)=>N[12].test(e)||!1)&&mi(e.range.startLine)&&(e.range.startCharacter===void 0||!(`startCharacter`in e.range)||mi(e.range.startCharacter))&&mi(e.range.endLine)&&(e.range.endCharacter===void 0||!(`endCharacter`in e.range)||mi(e.range.endCharacter)))),mi=(e=>Number.isInteger(e)&&(!(Number.isFinite(e)||typeof e==`bigint`)||e<=1e6&&e>=0)),hi=(e=>Array.isArray(e)&&e.every((e,t)=>ni(e))&&e.length<=20),gi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[13].test(e)||!1)&&ti(e.from)&&ti(e.to)&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))&&(e.ref===void 0||!(`ref`in e)||Xr(e.ref))&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.set===void 0||!(`set`in e)||_i(e.set))&&(e.attributes===void 0||!(`attributes`in e)||oi(e.attributes))&&(e.expect===void 0||!(`expect`in e)||di(e.expect))&&(e.locations===void 0||!(`locations`in e)||fi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||hi(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`kind`in e)),_i=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>N[14].test(e)||!1)&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.attributes===void 0||!(`attributes`in e)||oi(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||ui(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),vi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`id`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[15].test(e)||!1)&&ti(e.id)&&$r(e.label)&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))),yi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[17].test(e)||!1)&&ti(e.from)&&ti(e.to)&&(e.ref===void 0||!(`ref`in e)||Xr(e.ref))&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.set===void 0||!(`set`in e)||bi(e.set))&&(e.attributes===void 0||!(`attributes`in e)||oi(e.attributes))&&(e.expect===void 0||!(`expect`in e)||di(e.expect))&&(e.locations===void 0||!(`locations`in e)||fi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||hi(e.artifacts))&&(typeof e!=`object`||!e||Array.isArray(e)||`ref`in e?!0:!(typeof e==`object`&&e&&!Array.isArray(e))||`label`in e)),bi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>N[18].test(e)||!1)&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.attributes===void 0||!(`attributes`in e)||oi(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||ui(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),xi=(e=>Array.isArray(e)&&e.every((e,t)=>(typeof e==`string`||Number.isFinite(e)||typeof e==`boolean`||e===null)&&(typeof e!=`string`||j(e,1e3)))&&e.length<=50),Si=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`cells`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[20].test(e)||!1)&&xi(e.cells)&&(e.role===void 0||!(`role`in e)||Ci(e.role))&&(e.id===void 0||!(`id`in e)||ti(e.id))&&(e.ref===void 0||!(`ref`in e)||Xr(e.ref))&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.set===void 0||!(`set`in e)||wi(e.set))&&(e.attributes===void 0||!(`attributes`in e)||oi(e.attributes))&&(e.expect===void 0||!(`expect`in e)||di(e.expect))&&(e.locations===void 0||!(`locations`in e)||fi(e.locations))&&(e.artifacts===void 0||!(`artifacts`in e)||hi(e.artifacts))),Ci=(e=>e===`added`||e===`changed`||e===`context`||e===`removed`),wi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>N[21].test(e)||!1)&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))&&(e.cells===void 0||!(`cells`in e)||xi(e.cells))&&(e.attributes===void 0||!(`attributes`in e)||oi(e.attributes))&&(e.removeAttributes===void 0||!(`removeAttributes`in e)||ui(e.removeAttributes))&&Object.getOwnPropertyNames(e).length>=1),Ti=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`heading`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[22].test(e)||!1)&&typeof e.heading==`string`&&j(e.heading,500)&&M(e.heading,1)&&(e.depth===void 0||!(`depth`in e)||Number.isInteger(e.depth)&&(!(Number.isFinite(e.depth)||typeof e.depth==`bigint`)||e.depth<=6&&e.depth>=1))&&(e.role===void 0||!(`role`in e)||Ci(e.role))&&(e.id===void 0||!(`id`in e)||ti(e.id))&&(e.ref===void 0||!(`ref`in e)||Xr(e.ref))),Ei=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&`kind`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[23].test(e)||!1)&&Di(e.from)&&Di(e.to)&&ei(e.kind)&&(e.ref===void 0||!(`ref`in e)||Xr(e.ref))&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.attributes===void 0||!(`attributes`in e)||oi(e.attributes))),Di=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getOwnPropertyNames(e).every((e,t)=>N[24].test(e)||!1)&&(e.id===void 0||!(`id`in e)||ti(e.id))&&(e.ref===void 0||!(`ref`in e)||Xr(e.ref))&&Object.getOwnPropertyNames(e).length>=1&&Object.getOwnPropertyNames(e).length<=1&&[!(typeof e==`object`&&e&&!Array.isArray(e))||`id`in e,!(typeof e==`object`&&e&&!Array.isArray(e))||`ref`in e].reduce((e,t,n)=>t===!0?++e:e,0)===1),Oi=(e=>typeof e==`string`&&N[26].test(e)),ki=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&(e.type===`task`||e.type===`separator`)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`task`?Ai(e):!0)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`separator`?Fi(e):!0)),Ai=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`id`in e&&`label`in e&&`items`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[27].test(e)||!1)&&e.type===`task`&&ti(e.id)&&$r(e.label)&&Array.isArray(e.items)&&e.items.every((e,t)=>ji(e))&&e.items.length<=100&&(e.role===void 0||!(`role`in e)||Ni(e.role))),ji=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&(e.type===`activity`||e.type===`milestone`)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`activity`?Mi(e):!0)&&(typeof e!=`object`||!e||Array.isArray(e)||e.type===void 0||!(`type`in e)||e.type===`milestone`?Pi(e):!0)),Mi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`start`in e&&`end`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[28].test(e)||!1)&&e.type===`activity`&&Oi(e.start)&&Oi(e.end)&&(e.id===void 0||!(`id`in e)||ti(e.id))&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))&&(e.previous===void 0||!(`previous`in e)||typeof e.previous==`object`&&e.previous!==null&&!Array.isArray(e.previous)&&`start`in e.previous&&`end`in e.previous&&Object.getOwnPropertyNames(e.previous).length===2&&Oi(e.previous.start)&&Oi(e.previous.end))&&(e.role===void 0||!(`role`in e)||Ni(e.role))),Ni=(e=>e===`added`||e===`removed`),Pi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&`date`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[29].test(e)||!1)&&e.type===`milestone`&&Oi(e.date)&&(e.id===void 0||!(`id`in e)||ti(e.id))&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))&&(e.previous===void 0||!(`previous`in e)||typeof e.previous==`object`&&e.previous!==null&&!Array.isArray(e.previous)&&`date`in e.previous&&Object.getOwnPropertyNames(e.previous).length===1&&Oi(e.previous.date))&&(e.role===void 0||!(`role`in e)||Ni(e.role))),Fi=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`type`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[30].test(e)||!1)&&e.type===`separator`&&(e.label===void 0||!(`label`in e)||$r(e.label))),Ii=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`from`in e&&`to`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[31].test(e)||!1)&&ti(e.from)&&ti(e.to)&&(e.type===void 0||!(`type`in e)||e.type===`finish-to-start`||e.type===`start-to-start`||e.type===`finish-to-finish`||e.type===`start-to-finish`)),Li=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`start`in e&&`end`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[33].test(e)||!1)&&Oi(e.start)&&Oi(e.end)&&(e.label===void 0||!(`label`in e)||$r(e.label))&&(e.kind===void 0||!(`kind`in e)||ei(e.kind))),Ri=(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&`date`in e&&`label`in e&&Object.getOwnPropertyNames(e).every((e,t)=>N[34].test(e)||!1)&&Oi(e.date)&&typeof e.label==`string`&&j(e.label,500)&&M(e.label,1)&&(e.kind===void 0||!(`kind`in e)||ei(e.kind)));function zi(e){return Yr(e)}Jr({variables:[RegExp(`(^schema$|^kind$|^profile$|^target$|^removals$|^artifacts$|^viewpoints$|^data$)`,`u`),RegExp(`(^ref$|^revision$)`,`u`),RegExp(`(^type$|^ref$|^label$|^kind$|^from$|^to$)`,`u`),RegExp(`(^rel$|^uri$|^sha256$|^mediaType$|^label$)`,`u`),RegExp(`^sha256:[0-9a-f]{64}$`,`u`),RegExp(`(^id$|^label$|^concern$|^elementKinds$|^relationshipKinds$)`,`u`),RegExp(`(^nodes$|^edges$|^containers$)`,`u`),RegExp(`(^id$|^ref$|^label$|^kind$|^set$|^container$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^container$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(?!)`,`u`),RegExp(`(^label$|^kind$|^container$|^revision$|^attributes$)`,`u`),RegExp(`(^uri$|^revision$|^range$)`,`u`),RegExp(`(^startLine$|^startCharacter$|^endLine$|^endCharacter$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^kind$|^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^id$|^label$|^kind$)`,`u`),RegExp(`(^participants$|^messages$|^containers$)`,`u`),RegExp(`(^from$|^to$|^ref$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^columns$|^rows$|^relations$)`,`u`),RegExp(`(^cells$|^role$|^id$|^ref$|^kind$|^label$|^set$|^attributes$|^expect$|^locations$|^artifacts$)`,`u`),RegExp(`(^label$|^kind$|^cells$|^attributes$|^removeAttributes$)`,`u`),RegExp(`(^heading$|^depth$|^role$|^id$|^ref$)`,`u`),RegExp(`(^from$|^to$|^kind$|^ref$|^label$|^attributes$)`,`u`),RegExp(`(^id$|^ref$)`,`u`),RegExp(`(^title$|^time$|^rows$|^dependencies$|^comparedTo$|^periods$|^references$)`,`u`),RegExp(`^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$`,`u`),RegExp(`(^type$|^id$|^label$|^items$|^role$)`,`u`),RegExp(`(^type$|^start$|^end$|^id$|^label$|^kind$|^previous$|^role$)`,`u`),RegExp(`(^type$|^date$|^id$|^label$|^kind$|^previous$|^role$)`,`u`),RegExp(`(^type$|^label$)`,`u`),RegExp(`(^from$|^to$|^type$)`,`u`),RegExp(`(^label$|^date$)`,`u`),RegExp(`(^start$|^end$|^label$|^kind$)`,`u`),RegExp(`(^date$|^label$|^kind$)`,`u`)]});var Bi={[ie]:Fn,[ue]:qr,[fe]:zi},Vi=e=>{let t=Lt(e),n=me(t);return n===void 0&&t!==void 0?[{rule:`unsupported-version`,path:`/schema`,message:`this build validates ${pe.join(` and `)}`}]:Bi[n??`urn:structured-exchange:1`](e)?[]:[{rule:`schema/invalid`,path:``,message:`does not conform to the published structured-exchange schema`}]},Hi=Object.defineProperty,Ui=(e,t,n)=>t in e?Hi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wi=(e,t)=>{for(var n in t)Hi(e,n,{get:t[n],enumerable:!0})},Gi=(e,t,n)=>Ui(e,typeof t==`symbol`?t:t+``,n),Ki={};Wi(Ki,{Graph:()=>ja,alg:()=>aa});var qi=Object.defineProperty,Ji=(e,t)=>{for(var n in t)qi(e,n,{get:t[n],enumerable:!0})},Yi=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=Qi(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=$i(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Xi(this._preds[a],i),Xi(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?ea(this._isDirected,e):Qi(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?ea(this._isDirected,e):Qi(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?ea(this._isDirected,e):Qi(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],Zi(this._preds[t],e),Zi(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function Xi(e,t){e[t]?e[t]++:e[t]=1}function Zi(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Qi(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function $i(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function ea(e,t){return Qi(e,t.v,t.w,t.name)}Ji({},{read:()=>ia,write:()=>ta});function ta(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:na(e),edges:ra(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function na(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function ra(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function ia(e){let t=new Yi(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var aa={};Ji(aa,{CycleException:()=>ba,bellmanFord:()=>sa,components:()=>la,dijkstra:()=>fa,dijkstraAll:()=>ma,findCycles:()=>ga,floydWarshall:()=>va,isAcyclic:()=>Sa,postorder:()=>Ea,preorder:()=>Da,prim:()=>Oa,shortestPaths:()=>ka,tarjan:()=>ha,topsort:()=>xa});var oa=()=>1;function sa(e,t,n,r){return ca(e,String(t),n||oa,r||function(t){return e.outEdges(t)??[]})}function ca(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function la(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var ua=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},da=()=>1;function fa(e,t,n,r){return pa(e,String(t),n||da,r||function(t){return e.outEdges(t)??[]})}function pa(e,t,n,r){let i={},a=new ua,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function ma(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=fa(e,i,t,n),r},{})}function ha(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function ga(e){return ha(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var _a=()=>1;function va(e,t,n){return ya(e,t||_a,n||function(t){return e.outEdges(t)??[]})}function ya(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var ba=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function xa(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new ba;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new ba;return r}function Sa(e){try{xa(e)}catch(e){if(e instanceof ba)return!1;throw e}return!0}function Ca(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=wa(e,t,n===`post`,o,a,r,i)}),i}function wa(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=wa(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function Ta(e,t,n){return Ca(e,t,n,function(e,t){return e.push(t),e},[])}function Ea(e,t){return Ta(e,t,`post`)}function Da(e,t){return Ta(e,t,`pre`)}function Oa(e,t){var n;let r=new Yi,i={},a=new ua,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function ka(e,t,n,r){return Aa(e,t,n,r??(t=>e.outEdges(t)??[]))}function Aa(e,t,n,r){if(n===void 0)return fa(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return sa(e,t,n,r)}return fa(e,t,n,r)}var ja=Yi;function Ma(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Ja(r);return n.dummy=t,e.setNode(i,n),i}function Na(e){let t=new ja().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function Pa(e){let t=new ja({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Fa(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function Ia(e){let t=Ya(Ua(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function La(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Ha(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Ra(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Ha(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function za(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Ma(e,`border`,i,t)}function Ba(e,t=Va){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Va=65535;function Ha(e,t){return t.length>Va?e(...Ba(t).map(t=>e(...t))):e(...t)}function Ua(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Ha(Math.max,t)}function Wa(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Ga(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function Ka(e,t){return t()}var qa=0;function Ja(e){return e+(``+ ++qa)}function Ya(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function Xa(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Za(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function Qa(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var $a=`\0`;function eo(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var to=`3.1.1`,no=class{constructor(){Gi(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return ro(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&ro(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,io)),n=n._prev;return`[`+e.join(`, `)+`]`}};function ro(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function io(e,t){if(e!==`_next`&&e!==`_prev`)return t}var ao=no,oo=()=>1;function so(e,t){if(e.nodeCount()<=1)return[];let n=uo(e,t||oo);return co(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function co(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)lo(e,t,n,o);for(;o=i.dequeue();)lo(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(lo(e,t,n,o,!0)||[]);break}}}return r}function lo(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,fo(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,fo(t,n,o)}),e.removeNode(r.v),o}function uo(e,t){let n=new ja,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=po(i+r+3).map(()=>new ao),o=r+1;return n.nodes().forEach(e=>{fo(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function fo(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function po(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function mo(e,t){(e.graph().acyclicer===`greedy`?so(e,n(e)):ho(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,Ja(`rev`))});function n(e){return t=>e.edge(t).weight}}function ho(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&_o(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function go(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function _o(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function vo(e){e.graph().dummyChains=[],e.edges().forEach(t=>yo(e,t))}function yo(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=Ma(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function bo(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function xo(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=Ha(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function So(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Co=wo;function wo(e){let t=new ja({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;To(t,e)<i&&(a=Eo(t,e),a);)o=t.hasNode(a.v)?So(e,a):-So(e,a),Do(t,e,o);return t}function To(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!So(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function Eo(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=So(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function Do(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Oo,postorder:ko}=aa,Ao=jo;jo.initLowLimValues=Fo,jo.initCutValues=Mo,jo.calcCutValue=Po,jo.leaveEdge=Lo,jo.enterEdge=Ro,jo.exchangeEdges=zo;function jo(e){e=Na(e),xo(e);let t=Co(e);Fo(t),Mo(t,e);let n,r;for(;n=Lo(t);)r=Ro(t,e,n),zo(t,e,n,r)}function Mo(e,t){let n=ko(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>No(e,t,n))}function No(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=Po(e,t,n)}function Po(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,Vo(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Fo(e,t){arguments.length<2&&(t=e.nodes()[0]),Io(e,{},1,t)}function Io(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=Io(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function Lo(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Ro(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===Ho(e,e.node(t.v),s)&&c!==Ho(e,e.node(t.w),s)).reduce((e,n)=>So(t,n)<So(t,e)?n:e)}function zo(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Fo(e),Mo(e,t),Bo(e,t)}function Bo(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Oo(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function Vo(e,t,n){return e.hasEdge(t,n)}function Ho(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Uo=Wo;function Wo(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:qo(e);break;case`tight-tree`:Ko(e);break;case`longest-path`:Go(e);break;case`none`:break;default:qo(e)}}var Go=xo;function Ko(e){xo(e),Co(e)}function qo(e){Ao(e)}var Jo=Yo;function Yo(e){let t=Zo(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Xo(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function Xo(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function Zo(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children($a).forEach(r),t}function Qo(e){let t=Ma(e,`root`,{},`_root`),n=es(e),r=Object.values(n),i=Ha(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=ts(e)+1;e.children($a).forEach(r=>{$o(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function $o(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=za(e,`_bt`),l=za(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{$o(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function es(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children($a).forEach(e=>n(e,1)),t}function ts(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function ns(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var rs=is;function is(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)as(e,`borderLeft`,`_bl`,n,i,t),as(e,`borderRight`,`_br`,n,i,t)}}e.children($a).forEach(t)}function as(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Ma(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function os(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&cs(e)}function ss(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&us(e),(t===`lr`||t===`rl`)&&(fs(e),cs(e))}function cs(e){e.nodes().forEach(t=>ls(e.node(t))),e.edges().forEach(t=>ls(e.edge(t)))}function ls(e){let t=e.width;e.width=e.height,e.height=t}function us(e){e.nodes().forEach(t=>ds(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ds),Object.hasOwn(r,`y`)&&ds(r)})}function ds(e){e.y=-e.y}function fs(e){e.nodes().forEach(t=>ps(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ps),Object.hasOwn(r,`x`)&&ps(r)})}function ps(e){let t=e.x;e.x=e.y,e.y=t}function ms(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Ya(Ha(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return eo(t,e.node(n),e.node(r))}return a}function hs(e,t){let n=0;for(let r=1;r<t.length;++r)n+=gs(e,t[r-1],t[r]);return n}function gs(e,t,n){let r=Qa(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function _s(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function vs(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),ys(Object.values(n).filter(e=>!e.indegree))}function ys(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&bs(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>Xa(e,[`vs`,`i`,`barycenter`,`weight`]))}function bs(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function xs(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=Wa(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(Cs(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=Ss(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=Ss(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function Ss(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Cs(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=eo(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function ws(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=_s(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=ws(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&Es(t,r)}});let h=vs(m,n);Ts(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]=h[n],h.splice(n,1),n--}else _=!0}let v=xs(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function Ts(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function Es(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function Ds(e,t,n,r){r||=e.nodes();let i=Os(e),a=new ja({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function Os(e){let t;for(;e.hasNode(t=Ja(`_root`)););return t}function ks(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function As(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,As);return}let r=Ua(e),i=js(e,Ya(1,r+1),`inEdges`),a=js(e,Ya(r-1,-1,-1),`outEdges`),o=ms(e,n);if(Ns(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){Ms(t%2?i:a,t%4>=2,l,n),o=Ia(e);let u=hs(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}Ns(e,c)}function js(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return Ds(e,t,n,r.get(t)||[])})}function Ms(e,t,n,r){let i=!0,a=new ja;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=ws(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),ks(e,a,s.vs)})}function Ns(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Ps(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=Is(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&Ls(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function Fs(e,t){let n={};function r(t,r,i,a,o){Ya(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&Ls(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function Is(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function Ls(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Rs(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function zs(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||Js(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>Js(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!Rs(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function Bs(e,t,n,r,i=!1){let a={},o=Vs(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function Vs(e,t,n,r){let i=new ja,a=e.graph(),o=Ks(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function Hs(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=qs(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function Us(e,t){let n=Object.values(t),r=Ha(Math.min,n),i=Ha(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-Ha(Math.min,c);a!==`l`&&(l=i-Ha(Math.max,c)),l&&(e[o]=Za(s,e=>e+l))})})}function Ws(e,t=void 0){let n=e.ul;return n?Za(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function Gs(e,t){let n=Ia(e),r=Object.assign(Ps(e,n),Fs(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=zs(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Bs(e,a,s.root,s.align,n===`r`);n===`r`&&(c=Za(c,e=>-e)),i[o+n]=c})}),Us(i,Hs(e,i)),Ws(i,e.graph().align)}function Ks(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function qs(e,t){return e.node(t).width}function Js(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function Ys(e,t){e=Pa(e),Xs(e),Object.entries(Gs(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Xs(e){let t=Ia(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var Zs=new WeakMap;function Qs(e,t={}){return ec(e,Ka,t),e}function $s(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function ec(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new ja({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=$s(e,t.v,r),i=$s(e,t.w,r);if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),ec(o,t,n);let l=dc(o);tc(l,t,n,null),nc(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),(!isFinite(u)||!isFinite(d)||!isFinite(f)||!isFinite(p))&&(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=dc(e),g=tc(h,t,n,Zs.get(e)??null);Zs.set(e,g),nc(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),delete n._dagreClusterSubgraph}})}function tc(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>fc(e)),t(` removeSelfEdges`,()=>xc(e)),t(` acyclic`,()=>mo(e,s)),t(` nestingGraph.run`,()=>Qo(e)),t(` rank`,()=>Uo(Pa(e))),t(` injectEdgeLabelProxies`,()=>pc(e)),t(` removeEmptyRanks`,()=>Ra(e)),t(` nestingGraph.cleanup`,()=>ns(e)),t(` normalizeRanks`,()=>La(e)),t(` assignRankMinMax`,()=>mc(e)),t(` removeEdgeLabelProxies`,()=>hc(e)),t(` normalize.run`,()=>vo(e)),t(` parentDummyChains`,()=>Jo(e)),t(` addBorderSegments`,()=>rs(e)),t(` order`,()=>As(e,n,c)),t(` insertSelfEdges`,()=>Sc(e)),t(` adjustCoordinateSystem`,()=>os(e)),t(` position`,()=>Ys(e,n.corePath)),t(` positionSelfEdges`,()=>Cc(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>bc(e)),t(` normalize.undo`,()=>bo(e)),t(` fixupEdgeLabelCoords`,()=>vc(e)),t(` undoCoordinateSystem`,()=>ss(e)),t(` translateGraph`,()=>gc(e)),t(` assignNodeIntersects`,()=>_c(e)),t(` reversePoints`,()=>yc(e)),t(` acyclic.undo`,()=>go(e)),{graph:e,rawNodes:l}}function nc(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var rc=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],ic={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},ac=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],oc=[`width`,`height`,`rank`],sc={width:0,height:0},cc=[`minlen`,`weight`,`width`,`height`,`labeloffset`],lc={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},uc=[`labelpos`];function dc(e){let t=new ja({multigraph:!0,compound:!0}),n=Tc(e.graph());return t.setGraph(Object.assign({},ic,wc(n,rc),Xa(n,ac))),e.nodes().forEach(n=>{let r=wc(Tc(e.node(n)),oc);Object.keys(sc).forEach(e=>{r[e]===void 0&&(r[e]=sc[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=Tc(e.edge(n));t.setEdge(n,Object.assign({},lc,wc(r,cc),Xa(r,uc)))}),t}function fc(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function pc(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Ma(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function mc(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function hc(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function gc(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function _c(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(Fa(r,a)),n.points.push(Fa(i,o))})}function vc(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function yc(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function bc(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function xc(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Sc(e){Ia(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{Ma(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),(!Array.isArray(t.label.points)||t.label.points.length!==7)&&(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function Cc(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function wc(e,t){return Za(Xa(e,t),Number)}function Tc(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function Ec(e){let t=Ia(e),n=new ja({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var Dc={graphlib:Ki,version:to,layout:Qs,debug:Ec,util:{time:Ga,notime:Ka}};function Oc(e,t){return t?e.ref===void 0?`added`:e.set===void 0?`context`:`changed`:`unchanged`}function kc(e,t){if(t&&e.heading===void 0)return e.ref===void 0?`added`:e.set===void 0?`context`:`changed`}function Ac(e,t){return t?e.ref===void 0?`added`:e.set===void 0?`context`:`changed`:`unchanged`}function jc(e){let t=e.set;if(t===void 0)return[];let n=e;return Object.entries(t).filter(([e])=>e!==`attributes`&&e!==`removeAttributes`).map(([e,t])=>{let r=n[e];return{field:e,...typeof r==`string`?{from:r}:{},to:String(t)}})}var Mc={added:`added`,changed:`changed`,context:`existing`,unchanged:``},Nc={added:`added`,changed:`changed`,context:`existing`,removed:`removed`},Pc=[`added`,`changed`,`context`,`removed`];function Fc(e){return e.rows.some(e=>ce(e).role!==void 0)}function Ic(e,t){if(t)return ce(e).role??`context`}function Lc(e){if(e.length===0)return;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t-Vc,y:n-Vc-Hc,width:r-t+Vc*2,height:i-n+Vc*2+Hc}}var Rc=64,zc=24,Bc=12,Vc=10,Hc=16,Uc=16,Wc=160,Gc=52;function Kc(e,t,n=`landscape`){let r=new Dc.graphlib.Graph({compound:!0,multigraph:!0});r.setGraph({rankdir:n===`portrait`?`TB`:`LR`,ranksep:Rc,nodesep:zc,marginx:Bc,marginy:Bc}),r.setDefaultEdgeLabel(()=>({}));for(let n of e.nodes)r.setNode(n.id,t(n));let i=e.containers??[],a=new Map;for(let t of e.nodes)t.container!==void 0&&i.some(e=>e.id===t.container)&&(r.setNode(t.container,{label:t.container}),r.setParent(t.id,t.container),a.set(t.container,[...a.get(t.container)??[],t.id]));e.edges.forEach((e,t)=>{e.from!==e.to&&r.hasNode(e.from)&&r.hasNode(e.to)&&r.setEdge(e.from,e.to,{},String(t))}),Dc.layout(r);let o=e.nodes.map(e=>{let n=r.node(e.id),{width:i,height:a}=t(e);return{id:e.id,x:(n?.x??Bc+i/2)-i/2,y:(n?.y??Bc+a/2)-a/2,width:i,height:a}}),s=[];e.edges.forEach((e,t)=>{if(e.from===e.to)return;let n=r.edge(e.from,e.to,String(t));n?.points!==void 0&&n.points.length>0&&s.push({index:t,points:n.points.map(e=>({x:e.x,y:e.y}))})});let c=[],l=o.reduce((e,t)=>Math.max(e,t.y+t.height),Bc)+Uc,u=new Map(o.map(e=>[e.id,e]));for(let e of i){let t=Lc((a.get(e.id)??[]).flatMap(e=>{let t=u.get(e);return t===void 0?[]:[t]}));t===void 0?(c.push({id:e.id,label:e.label,x:Bc,y:l,width:Wc,height:Gc}),l+=68):c.push({id:e.id,label:e.label,...t})}let d=[...o.map(e=>({x:e.x,y:e.y,width:e.width,height:e.height})),...c],f=Math.min(0,...d.map(e=>e.x))-Bc,p=Math.min(0,...d.map(e=>e.y))-Bc;if(f<0||p<0){for(let e of o)e.x-=f,e.y-=p;for(let e of c)e.x-=f,e.y-=p;for(let e of s)for(let t of e.points)t.x-=f,t.y-=p}let m=[...o.map(e=>({x:e.x,y:e.y,width:e.width,height:e.height})),...c].reduce((e,t)=>({width:Math.max(e.width,t.x+t.width),height:Math.max(e.height,t.y+t.height)}),{width:0,height:0});return{nodes:o,edges:s,containers:c,width:m.width+Bc,height:m.height+Bc}}var qc={attributes:[],expectations:[],assignments:[],removedAttributes:[],locations:[],artifacts:[]};function Jc(e){if(typeof e!=`object`||!e)return qc;let t=e,n=e=>typeof e==`object`&&e&&!Array.isArray(e)?Object.entries(e):[],r=t.set,i=r?.removeAttributes;return{attributes:n(t.attributes),expectations:n(t.expect?.attributes),assignments:n(r?.attributes),removedAttributes:Array.isArray(i)?i.filter(e=>typeof e==`string`):[],locations:Array.isArray(t.locations)?t.locations:[],artifacts:Array.isArray(t.artifacts)?t.artifacts:[]}}function Yc(e){let t=e.target;if(typeof t==`string`)return{ref:t};if(typeof t!=`object`||!t)return;let n=t;if(typeof n.ref==`string`)return{ref:n.ref,...typeof n.revision==`string`?{revision:n.revision}:{}}}function Xc(e,t){let n=(e.removals??[]).map(e=>({type:e.type,ref:e.ref})),r=e.profile,i=e.artifacts,a={...typeof r==`string`?{profile:r}:{},...(()=>{let t=Yc(e);return t===void 0?{}:{target:t}})(),artifacts:Array.isArray(i)?i:[]};if(e.kind===`table`){let r=e.data,i=Fc(r),o=r.rows.map(e=>{let n=Array.isArray(e)?{}:e,r=(Array.isArray(e)?void 0:e.role)??kc({ref:typeof n.ref==`string`?n.ref:void 0,set:n.set,heading:typeof n.heading==`string`?n.heading:void 0},t)??Ic(e,i),{cells:a,heading:o}=ce(e),s=Array.isArray(e)?{}:e;return{cells:a,...r===void 0?{}:{role:r},...o===void 0?{}:{heading:o},...typeof s.depth==`number`?{depth:s.depth}:{},...typeof s.id==`string`?{id:s.id}:{},...typeof s.ref==`string`?{ref:s.ref}:{},...typeof s.kind==`string`?{kind:s.kind}:{},changes:jc(s),...Jc(e)}}),s=new Map;for(let e of o){if(e.id===void 0)continue;let t=e.cells.find(e=>typeof e==`string`&&e!==``);s.set(e.id,(typeof t==`string`?t:void 0)??e.ref??e.id)}let c=r.relations,l=(Array.isArray(c)?c:[]).map(e=>{let t=e,n=e=>{let t=typeof e?.id==`string`?e.id:void 0,n=typeof e?.ref==`string`?e.ref:void 0;return{id:t,ref:n,label:(t===void 0?void 0:s.get(t))??n??t??``}},r=n(t.from),i=n(t.to);return{kind:t.kind??``,...typeof t.label==`string`?{label:t.label}:{},...r.id===void 0?{}:{fromRow:r.id},...i.id===void 0?{}:{toRow:i.id},...r.ref===void 0?{}:{fromRef:r.ref},...i.ref===void 0?{}:{toRef:i.ref},fromLabel:r.label,toLabel:i.label}});return{thingNoun:`column`,linkNoun:`row`,things:[],links:[],columns:r.columns,rows:o,containers:[],removals:n,traces:l,...a}}if(e.kind===`timeline`)return{thingNoun:`task`,linkNoun:`dependency`,things:[],links:[],containers:[],removals:n,traces:[],...a};let o=e.kind===`graph`,s=o?e.data.nodes:e.data.participants,c=o?e.data.edges:e.data.messages,l=new Map(s.map(e=>[e.id,Zc(e)]));return{thingNoun:o?`element`:`participant`,linkNoun:o?`relationship`:`message`,things:s.map(e=>({id:e.id,label:Zc(e),kind:e.kind,role:Oc(e,t),changes:jc(e),container:e.container,...Jc(e)})),links:c.map(e=>({from:e.from,to:e.to,fromLabel:l.get(e.from)??e.from,toLabel:l.get(e.to)??e.to,label:e.label,kind:`kind`in e?e.kind:void 0,role:Ac(e,t),changes:jc(e),isLoop:e.from===e.to,...Jc(e)})),containers:e.data.containers??[],removals:n,traces:[],...a}}function Zc(e){return e.label??e.ref??e.id}function Qc(e){if(e.kind===`graph`){let t=e.data,n=[`flowchart TD`],r=t.containers??[],i=new Set(r.map(e=>e.id)),a=e=>t.nodes.filter(t=>t.container===e);for(let e of r){n.push(` subgraph ${$c(e.id)}["${tl(e.label)}"]`);for(let t of a(e.id))n.push(` ${$c(t.id)}["${tl(Zc(t))}"]`);n.push(` end`)}for(let e of t.nodes)e.container!==void 0&&i.has(e.container)||n.push(` ${$c(e.id)}["${tl(Zc(e))}"]`);for(let e of t.edges){let t=e.label??e.kind,r=t===void 0?`-->`:`-- "${tl(t)}" -->`;n.push(` ${$c(e.from)} ${r} ${$c(e.to)}`)}return n.join(`
7
7
  `)}if(e.kind===`sequence`){let t=e.data,n=[`sequenceDiagram`],r=t.containers??[],i=new Set(r.map(e=>e.id)),a=(e,t)=>`${t}participant ${$c(e.id)} as "${tl(Zc(e))}"`;for(let e of r){n.push(` box ${tl(e.label)}`);for(let r of t.participants.filter(t=>t.container===e.id))n.push(a(r,` `));n.push(` end`)}for(let e of t.participants)e.container!==void 0&&i.has(e.container)||n.push(a(e,` `));for(let e of t.messages)n.push(` ${$c(e.from)}->>${$c(e.to)}: ${tl(e.label??``)}`);return n.join(`
8
- `)}}function $c(e){return`n${[...e].map(e=>e.charCodeAt(0).toString(36)).join(``)}`}var el={"#":`#35;`,'"':`#quot;`,";":`#59;`,"<":`#60;`,">":`#62;`};function tl(e){return e.replace(/[#";<>]/g,e=>el[e]).replace(/[\r\n\t\f\v\u0000-\u001f\u2028\u2029]+/g,` `)}function nl(e,t){return`${e}:${t}`}var rl=new Set;function il(e,t,n){return n===void 0||n===``?!1:e.has(nl(t,n))}function al(e){let t=e?.viewpoints;return Array.isArray(t)?t:[]}function ol(e,t){let n=new Set,r=(e,t,r)=>{if(t===void 0)return;let i=new Set(t);for(let t of e)t.kind!==void 0&&t.kind!==``&&!i.has(t.kind)&&n.add(nl(r,t.kind))};return r(e.nodes,t.elementKinds,`element`),r(e.edges,t.relationshipKinds,`relationship`),n}function sl(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var cl=40,ll=22;function ul(e){let t=e.containers??[],n;if(t.length===0)n=e.participants;else{let r=new Set(t.map(e=>e.id)),i=new Set;n=[];for(let t of e.participants){if(i.has(t.id))continue;let a=t.container;if(a===void 0||!r.has(a))n.push(t),i.add(t.id);else for(let t of e.participants)t.container!==a||i.has(t.id)||(n.push(t),i.add(t.id))}}let r=[];n.forEach((e,n)=>{let i=t.find(t=>t.id===e.container);if(i===void 0)return;let a=r.at(-1);a!==void 0&&a.container.id===i.id&&a.to===n-1?a.to=n:r.push({container:i,from:n,to:n})});let i=t.length>0?ll:0,a=new Map(n.map((e,t)=>[e.id,t])),o=Math.max(...e.participants.map(e=>Ee([Zc(e)],jc(e),110,240)),Te(e.messages.map(e=>e.label??``),110,240)*.8),s=o-14,c=e.participants.reduce((e,t)=>Math.max(e,Oe(De(Zc(t),s).length,ke(jc(t),s).length)),Oe(1,0))+8;return{columns:n,bands:r,bandHeight:i,lifelineX:o,boxW:s,headerHeight:c,messageGap:cl,width:Math.max(e.participants.length*o,240),height:i+c+(e.messages.length+1)*cl,xOf:e=>(a.get(e)??0)*o+o/2}}function dl(e,t){let n=[Zc(e)];t!==`unchanged`&&n.push(`(${Mc[t]})`),e.ref!==void 0&&n.push(`[${e.ref}]`);for(let t of jc(e))n.push(Ae(t));return n.join(` `)}function fl(e,t){let n=t.cx-e.cx,r=t.cy-e.cy;if(n===0&&r===0)return{x:e.cx,y:e.cy};let i=Math.min(n===0?1/0:e.w/2/Math.abs(n),r===0?1/0:e.h/2/Math.abs(r));return{x:e.cx+n*i,y:e.cy+r*i}}function pl(e,t){if(e.length<3)return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `);let n=[`M ${e[0].x} ${e[0].y}`];for(let r=1;r<e.length-1;r++){let i=e[r-1],a=e[r],o=e[r+1],s=Math.hypot(a.x-i.x,a.y-i.y),c=Math.hypot(o.x-a.x,o.y-a.y);if(s===0||c===0)continue;let l=((a.x-i.x)*(o.y-a.y)-(a.y-i.y)*(o.x-a.x))/(s*c);if(Math.abs(l)<.02)continue;let u=Math.min(t,s/2,c/2),d={x:a.x-(a.x-i.x)/s*u,y:a.y-(a.y-i.y)/s*u},f={x:a.x+(o.x-a.x)/c*u,y:a.y+(o.y-a.y)/c*u};n.push(`L ${d.x} ${d.y}`,`Q ${a.x} ${a.y} ${f.x} ${f.y}`)}let r=e[e.length-1];return n.push(`L ${r.x} ${r.y}`),n.join(` `)}function ml(e,t,n,r,i){if(e===t){let t=26+r*12,n=e.cx-e.w/4,i=e.cx+e.w/4,a=e.y;return{d:`M ${n} ${a} C ${n} ${a-t}, ${i} ${a-t}, ${i} ${a}`,labelAt:{x:e.cx,y:a-t*.75},span:t*2}}let a=fl(e,t),o=fl(t,e),s=Math.hypot(o.x-a.x,o.y-a.y),c=(n??[]).slice(1,-1),l=i===void 0?c:c.map((e,t)=>{let n=c.length===1?.5:t/(c.length-1);return{x:e.x+i.from.dx*(1-n)+i.to.dx*n,y:e.y+i.from.dy*(1-n)+i.to.dy*n}});if(l.length>0&&r===0){let e=l[Math.floor((l.length-1)/2)];return{d:pl([a,...l,o],12),labelAt:e,span:s}}let u=r===0?0:Math.ceil(r/2)*22*(r%2==1?1:-1),d=(a.x+o.x)/2,f=(a.y+o.y)/2;if(u===0)return{d:`M ${a.x} ${a.y} L ${o.x} ${o.y}`,labelAt:{x:d,y:f},span:s};let p=s===0?0:-(o.y-a.y)/s,m=s===0?0:(o.x-a.x)/s,h=d+p*u*2,g=f+m*u*2;return{d:`M ${a.x} ${a.y} Q ${h} ${g} ${o.x} ${o.y}`,labelAt:{x:d+p*u,y:f+m*u},span:s}}function hl(e){let t=(e.match(/-?\d+(?:\.\d+)?/g)??[]).map(Number);if(t.length<2)return;let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let e=0;e+1<t.length;e+=2)n=Math.min(n,t[e]),i=Math.max(i,t[e]),r=Math.min(r,t[e+1]),a=Math.max(a,t[e+1]);return{minX:n,minY:r,maxX:i,maxY:a}}function gl(e,t,n,r){let i=t=>{let n=e.participants.find(e=>e.id===t);return n===void 0?t:Zc(n)},a=t.label===void 0||t.label===``?``:`: ${t.label}`;return[`${n+1}.`,`${i(t.from)} → ${i(t.to)}${a}`,t.from===t.to?`(to itself)`:``,r===`unchanged`?``:`[${Mc[r]}]`,jc(t).map(Ae).join(`, `)].filter(e=>e!==``).join(` `)}function _l(e,t,n){let r=t=>{let n=e.nodes.find(e=>e.id===t);return n===void 0?t:Zc(n)},i=t.label??t.kind;return[`${r(t.from)} → ${r(t.to)}`,i===void 0?``:`(${i})`,n===`unchanged`?``:`[${Mc[n]}]`,jc(t).map(Ae).join(`, `)].filter(e=>e!==``).join(` `)}function vl(e){if(e===void 0||e===``)return;let t=It(e,Vi);return t.valid?{valid:!0,envelope:t.envelope,issues:[]}:t}function yl(e){let t=vl(e);return t?.valid===!0?t.envelope:void 0}function bl(e){return Rt(e,Vi)}var xl=`pi-outpost/structured-exchange-arrangement-1`,Sl=()=>({format:xl,views:{}}),Cl=()=>({elements:{},relationships:{}});function wl(e){return/\.json$/i.test(e)?e.replace(/\.json$/i,`.arrangement.json`):`${e}.arrangement.json`}var Tl=e=>e.replace(/[%>#[\]\s]/g,e=>`%${e.charCodeAt(0).toString(16).padStart(2,`0`).toUpperCase()}`);function El(e){return e.ref===void 0?`id:${Tl(e.id)}`:`ref:${Tl(e.ref)}`}function Dl(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Map;return e.edges.map(e=>{if(e.ref!==void 0)return`ref:${Tl(e.ref)}`;let r=t.get(e.from),i=t.get(e.to),a=`${r===void 0?`id:${Tl(e.from)}`:El(r)}>${i===void 0?`id:${Tl(e.to)}`:El(i)}[${Tl(e.kind??``)}]`,o=n.get(a)??0;return n.set(a,o+1),`${a}#${o}`})}var Ol=e=>typeof e==`object`&&!!e&&!Array.isArray(e),kl=e=>Ol(e)&&Number.isFinite(e.x)&&Number.isFinite(e.y);function Al(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,reason:`it is not parseable JSON`}}if(!Ol(t)||t.format!==`pi-outpost/structured-exchange-arrangement-1`)return{ok:!1,reason:`it does not declare "format": "${xl}"`};if(!Ol(t.views))return{ok:!1,reason:`it has no views`};let n={};for(let[e,r]of Object.entries(t.views)){if(!Ol(r))return{ok:!1,reason:`view "${e}" is not an object`};let t=Cl();if(r.orientation!==void 0){if(r.orientation!==`landscape`&&r.orientation!==`portrait`)return{ok:!1,reason:`view "${e}" has an unknown orientation`};t.orientation=r.orientation}if(!Ol(r.elements))return{ok:!1,reason:`view "${e}" has no elements`};if(!Ol(r.relationships))return{ok:!1,reason:`view "${e}" has no relationships`};for(let[n,i]of Object.entries(r.elements)){if(!kl(i))return{ok:!1,reason:`element "${n}" of view "${e}" has no x and y`};t.elements[n]={x:i.x,y:i.y}}for(let[n,i]of Object.entries(r.relationships)){if(!Ol(i))return{ok:!1,reason:`relationship "${n}" of view "${e}" is not an object`};let r={};for(let t of[`exit`,`entry`])if(i[t]!==void 0){if(!kl(i[t]))return{ok:!1,reason:`relationship "${n}" of view "${e}" has an unreadable ${t}`};r[t]={x:i[t].x,y:i[t].y}}if(i.waypoints!==void 0){if(!Array.isArray(i.waypoints)||!i.waypoints.every(kl))return{ok:!1,reason:`relationship "${n}" of view "${e}" has unreadable waypoints`};r.waypoints=i.waypoints.map(e=>({x:e.x,y:e.y}))}if(i.label!==void 0){let t=i.label;if(!Ol(t)||!Number.isFinite(t.along)||!kl(t.offset)||t.across!==void 0&&!Number.isFinite(t.across))return{ok:!1,reason:`relationship "${n}" of view "${e}" has an unreadable label`};r.label={along:t.along,...t.across===void 0?{}:{across:t.across},offset:{x:t.offset.x,y:t.offset.y}}}t.relationships[n]=r}n[e]=t}return{ok:!0,arrangement:{format:xl,views:n}}}var jl=e=>Math.round(e*1e4)/1e4,Ml=e=>Math.round(e/10)*10,Nl=e=>({x:Ml(e.x),y:Ml(e.y)});function Pl(e){let t={};return e.entry!==void 0&&(t.entry={x:jl(e.entry.x),y:jl(e.entry.y)}),e.exit!==void 0&&(t.exit={x:jl(e.exit.x),y:jl(e.exit.y)}),e.label!==void 0&&(t.label={...e.label.across===void 0||e.label.across===0?{}:{across:Math.round(e.label.across)},along:jl(e.label.along),offset:{x:Math.round(e.label.offset.x),y:Math.round(e.label.offset.y)}}),e.waypoints!==void 0&&e.waypoints.length>0&&(t.waypoints=e.waypoints.map(e=>({x:Math.round(e.x),y:Math.round(e.y)}))),t}var Fl=e=>Object.keys(e).sort().map(t=>[t,e[t]]);function Il(e){let t={};for(let[n,r]of Fl(e.views))t[n]={elements:Object.fromEntries(Fl(r.elements).map(([e,t])=>[e,Nl(t)])),...r.orientation===void 0?{}:{orientation:r.orientation},relationships:Object.fromEntries(Fl(r.relationships).map(([e,t])=>[e,Pl(t)]))};return`${JSON.stringify({format:xl,views:t},null,2).replace(/\{\n\s*"x": (-?[\d.]+),\n\s*"y": (-?[\d.]+)\n\s*\}/g,`{ "x": $1, "y": $2 }`)}\n`}var Ll={shape:`label`,perimeter:`rectanglePerimeter`},Rl={shape:`connector`,endArrow:`classic`,rounded:1},zl={ellipse:{shape:`ellipse`,perimeter:`ellipsePerimeter`},rhombus:{shape:`rhombus`,perimeter:`rhombusPerimeter`},triangle:{shape:`triangle`,perimeter:`trianglePerimeter`},line:{shape:`line`},image:{shape:`image`},roundImage:{shape:`image`,perimeter:`ellipsePerimeter`},rhombusImage:{shape:`image`,perimeter:`rhombusPerimeter`},arrow:{shape:`arrow`,edgeStyle:`none`},swimlane:{shape:`swimlane`}};function Bl(e,t){let n=e.startsWith(`;`)?{}:{...t?Rl:Ll};for(let t of e.split(`;`)){let e=t.indexOf(`=`);if(e>=0){let r=t.slice(0,e),i=t.slice(e+1);i===`none`?delete n[r]:n[r]=i.trim()!==``&&Number.isFinite(Number(i))?Number.parseFloat(i):i}else if(Object.hasOwn(zl,t))for(let[e,r]of Object.entries(zl[t]))r===`none`?delete n[e]:n[e]=r}return n}var Vl=(e,t,n)=>{let r=e[t],i=typeof r==`number`?r:Number.parseFloat(String(r??``));return Number.isFinite(i)?i:n},Hl=1,Ul=2,Wl=4,Gl=8,Kl=15,ql=6,Jl=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),Yl=e=>Math.round(e*10)/10,Xl=(e,t,n)=>t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height;function Zl(e){let{style:t}=e;if(Vl(t,`rotation`,0)%360!=0||t.direction!==void 0&&t.direction!==`east`||Vl(t,`flipH`,0)===1||Vl(t,`flipV`,0)===1)return!1;let n=String(t.shape??``);if(n.startsWith(`mxgraph.`)||n.startsWith(`stencil(`)||Vl(t,`roundedPerimeter`,0)===1&&Vl(t,`rounded`,0)===1||Vl(t,`labelPerimeter`,0)===1)return!1;let r=t.perimeter;return r===void 0||[`rectanglePerimeter`,`ellipsePerimeter`,`rhombusPerimeter`,`centerPerimeter`].includes(String(r))}function Ql(e,t,n,r,i,a,o,s){let c=(s-a)*(n-e)-(o-i)*(r-t),l=(o-i)*(t-a)-(s-a)*(e-i),u=(n-e)*(t-a)-(r-t)*(e-i),d=l/c,f=u/c;return d>=0&&d<=1&&f>=0&&f<=1?{x:e+d*(n-e),y:t+d*(r-t)}:null}function $l(e,t,n){let r=e.x+e.width/2,i=e.y+e.height/2,a=Math.atan2(t.y-i,t.x-r),o={x:0,y:0},s=Math.PI,c=s/2-a,l=Math.atan2(e.height,e.width);return a<-s+l||a>s-l?(o.x=e.x,o.y=i-e.width*Math.tan(a)/2):a<-l?(o.y=e.y,o.x=r-e.height*Math.tan(c)/2):a<l?(o.x=e.x+e.width,o.y=i+e.width*Math.tan(a)/2):(o.y=e.y+e.height,o.x=r+e.height*Math.tan(c)/2),n&&(t.x>=e.x&&t.x<=e.x+e.width?o.x=t.x:t.y>=e.y&&t.y<=e.y+e.height&&(o.y=t.y),t.x<e.x?o.x=e.x:t.x>e.x+e.width&&(o.x=e.x+e.width),t.y<e.y?o.y=e.y:t.y>e.y+e.height&&(o.y=e.y+e.height)),o}function eu(e,t,n){let{x:r,y:i}=e,a=e.width/2,o=e.height/2,s=r+a,c=i+o,l=t.x,u=t.y,d=Math.trunc(l-s),f=Math.trunc(u-c);if(d===0&&f!==0)return{x:s,y:c+o*f/Math.abs(f)};if(d===0&&f===0)return{x:l,y:u};if(n){if(u>=i&&u<=i+e.height){let e=u-c,t=Math.sqrt(a*a*(1-e*e/(o*o)))||0;return l<=r&&(t=-t),{x:s+t,y:u}}if(l>=r&&l<=r+e.width){let e=l-s,t=Math.sqrt(o*o*(1-e*e/(a*a)))||0;return u<=i&&(t=-t),{x:l,y:c+t}}}let p=a*o/Math.sqrt(o*o*d*d+a*a*f*f);return{x:s+p*d,y:c+p*f}}function tu(e,t,n){let{x:r,y:i}=e,a=e.width,o=e.height,s=r+a/2,c=i+o/2,l=t.x,u=t.y;if(s===l)return c>u?{x:s,y:i}:{x:s,y:i+o};if(c===u)return s>l?{x:r,y:c}:{x:r+a,y:c};let d=s,f=c;return n&&(l>=r&&l<=r+a?d=l:u>=i&&u<=i+o&&(f=u)),l<s?u<c?Ql(l,u,d,f,s,i,r,c):Ql(l,u,d,f,s,i+o,r,c):u<c?Ql(l,u,d,f,s,i,r+a,c):Ql(l,u,d,f,s,i+o,r+a,c)}function nu(e,t,n,r){let i=r+Vl(e.style,`perimeterSpacing`,0),a={x:e.box.x-i,y:e.box.y-i,width:e.box.width+2*i,height:e.box.height+2*i},o=e.style.perimeter,s=null;return o!==void 0&&(a.width>0||a.height>0)&&(o===`ellipsePerimeter`?s=eu(a,t,n):o===`rhombusPerimeter`?s=tu(a,t,n):o===`rectanglePerimeter`&&(s=$l(a,t,n))),s??Jl(e.box)}var ru=(e,t)=>({x:t.x+e.origin.x,y:t.y+e.origin.y});function iu(e){let t=(e&Hl)<<3;return t|=(e&Ul)<<1,t|=(e&Wl)>>1,t|=(e&Gl)>>3,t}function au(e,t,n){let r=e.style.portConstraint??t.style[n?`sourcePortConstraint`:`targetPortConstraint`];if(r===void 0)return Kl;let i=String(r),a=0;return i.includes(`north`)&&(a|=Ul),i.includes(`west`)&&(a|=Hl),i.includes(`south`)&&(a|=Wl),i.includes(`east`)&&(a|=Gl),a}var ou=10;function su(e,t){let n=e.style[t?`sourceJettySize`:`targetJettySize`]??e.style.jettySize??ou;if(n===`auto`){let n=e.style[t?`startArrow`:`endArrow`];if(n!==void 0&&n!==`none`){let n=Vl(e.style,t?`startSize`:`endSize`,ql);return Math.max(2,Math.ceil((n+ou)/ou))*ou}return 20}return typeof n==`number`?n:Number.parseFloat(String(n))}var cu=(e,t,n,r,i)=>{let a=e.absolutePoints.map(e=>e===null?null:{x:Yl(e.x),y:Yl(e.y)}),o=t?.box??null,s=n?.box??null,c=[],l=e=>c.push(e),u=i.length>0&&i[0]!=null?{x:i[0].x,y:i[0].y}:null,d=!0,f=null,p=e=>(e.x=Yl(e.x),e.y=Yl(e.y),(u===null||Math.abs(u.x-e.x)>=1||Math.abs(u.y-e.y)>=1)&&(i.push({x:e.x,y:e.y}),u=e),u),m=a[0]??null;m===null&&t!==null?m=Jl(t.box):m!==null&&(m={...m});let h=a.length-1,g;if(r!==null&&r.length>0){let i=r.map(t=>ru(e,t));if(i.length===0)return;m!==null&&i[0]!==void 0&&(Math.abs(i[0].x-m.x)<1&&(i[0].x=m.x),Math.abs(i[0].y-m.y)<1&&(i[0].y=m.y)),g=a[h],g!=null&&i[i.length-1]!==void 0&&(Math.abs(i[i.length-1].x-g.x)<1&&(i[i.length-1].x=g.x),Math.abs(i[i.length-1].y-g.y)<1&&(i[i.length-1].y=g.y)),f=i[0];let c=t,u=o,p=a[0],_=!1,v=!1,y=f;p!=null&&(c=null);for(let e=0;e<2;e++){let t=p!=null&&p.x===y.x,r=p!=null&&p.y===y.y,o=c!==null&&y.y>=u.y&&y.y<=u.y+u.height,l=c!==null&&y.x>=u.x&&y.x<=u.x+u.width;if(_=r||p==null&&o,v=t||p==null&&l,!(e===0&&(_&&v||t&&r))){if(p!=null&&!r&&!t&&(o||l)){d=!o;break}if(v||_){d=_,e===1&&(d=i.length%2==0?_:v);break}}c=n,u=s,p=a[h],p!=null&&(c=null),y=i[i.length-1],t&&r&&(i=i.slice(1))}d&&(a[0]!=null&&a[0].y!==f.y||a[0]==null&&t!==null&&(f.y<o.y||f.y>o.y+o.height))?l({x:m.x,y:f.y}):!d&&(a[0]!=null&&a[0].x!==f.x||a[0]==null&&t!==null&&(f.x<o.x||f.x>o.x+o.width))&&l({x:f.x,y:m.y}),d?m.y=f.y:m.x=f.x;for(let e of i)d=!d,f=e,d?m.y=f.y:m.x=f.x,l({...m})}else f=m,d=!0;if(m=a[h]??null,m===null&&n!==null&&(m=Jl(n.box)),m!==null&&f!==null&&(d&&(a[h]!=null&&a[h].y!==f.y||a[h]==null&&n!==null&&(f.y<s.y||f.y>s.y+s.height))?l({x:m.x,y:f.y}):!d&&(a[h]!=null&&a[h].x!==f.x||a[h]==null&&n!==null&&(f.x<s.x||f.x>s.x+s.width))&&l({x:f.x,y:m.y})),a[0]==null&&t!==null)for(;c.length>0&&Xl(o,c[0].x,c[0].y);)c.splice(0,1);if(a[h]==null&&n!==null)for(;c.length>0&&Xl(s,c[c.length-1].x,c[c.length-1].y);)c.splice(c.length-1,1);for(let e of c)p(e);let _=i[i.length-1];if(g!=null&&_!=null&&Math.abs(g.x-_.x)<=1&&Math.abs(g.y-_.y)<=1){i.splice(i.length-1,1);let e=i[i.length-1];e!=null&&(Math.abs(e.x-g.x)<1&&(e.x=g.x),Math.abs(e.y-g.y)<1&&(e.y=g.y))}},lu=[[-1,0],[0,-1],[1,0],[0,1],[-1,0],[0,-1],[1,0]],uu=[[[513,2308,2081,2562],[513,1090,514,2184,2114,2561],[513,1090,514,2564,2184,2562],[513,2308,2561,1090,514,2568,2308]],[[514,1057,513,2308,2081,2562],[514,2184,2114,2561],[514,2184,2562,1057,513,2564,2184],[514,1057,513,2568,2308,2561]],[[1090,514,1057,513,2308,2081,2562],[2114,2561],[1090,2562,1057,513,2564,2184],[1090,514,1057,513,2308,2561,2568]],[[2081,2562],[1057,513,1090,514,2184,2114,2561],[1057,513,1090,514,2184,2562,2564],[1057,2561,1090,514,2568,2308]]],du=1024,fu=2048,pu=480,mu=512,hu=(e,t,n,r,i)=>{let a=e.absolutePoints.map(e=>e===null?null:{x:Yl(e.x),y:Yl(e.y)}),o=t===null?null:{...t.box,x:Yl(t.box.x),y:Yl(t.box.y),width:Yl(t.box.width),height:Yl(t.box.height)},s=n===null?null:{...n.box,x:Yl(n.box.x),y:Yl(n.box.y),width:Yl(n.box.width),height:Yl(n.box.height)},c=a[0]??null,l=a[a.length-1]??null,u=o===null?c.x:o.x,d=o===null?c.y:o.y,f=o===null?1:o.width,p=o===null?1:o.height,m=s===null?l.x:s.x,h=s===null?l.y:s.y,g=s===null?1:s.width,_=s===null?1:s.height,v=su(e,!0),y=su(e,!1),b=y+v,x=!1;if(c!==null&&l!==null){let e=l.x-c.x,t=l.y-c.y;x=e*e+t*t<b*b}if(x||r!==null&&r.length>0){cu(e,t,n,r,i);return}let S=[Kl,Kl];if(t!==null&&(S[0]=au(t,e,!0)),n!==null&&(S[1]=au(n,e,!1)),f===0||p===0||g===0||_===0)return;let C=[0,0],w=[[u,d,f,p],[m,h,g,_]],T=[v,y],E=[[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];for(let e=0;e<2;e++)E[e][1]=w[e][0]-T[e],E[e][2]=w[e][1]-T[e],E[e][4]=w[e][0]+w[e][2]+T[e],E[e][8]=w[e][1]+w[e][3]+T[e];let ee=w[0][0]+w[0][2]/2,D=w[0][1]+w[0][3]/2,te=w[1][0]+w[1][2]/2,ne=w[1][1]+w[1][3]/2,re=ee-te,ie=D-ne,ae=0;re<0?ae=ie<0?2:1:ie<=0&&(ae=3,re===0&&(ae=2));let oe=t===null?null:c,se=[[.5,.5],[.5,.5]];t===null&&(se[0]=[0,0]),n===null&&(se[1]=[0,0]);for(let e=0;e<2;e++)oe!==null&&(se[e][0]=(oe.x-w[e][0])/w[e][2],Math.abs(oe.x-w[e][0])<=1?C[e]=Hl:Math.abs(oe.x-w[e][0]-w[e][2])<=1&&(C[e]=Gl),se[e][1]=(oe.y-w[e][1])/w[e][3],Math.abs(oe.y-w[e][1])<=1?C[e]=Ul:Math.abs(oe.y-w[e][1]-w[e][3])<=1&&(C[e]=Wl)),oe=n===null?null:l;let ce=w[0][1]-(w[1][1]+w[1][3]),le=w[0][0]-(w[1][0]+w[1][2]),ue=w[1][1]-(w[0][1]+w[0][3]),de=w[1][0]-(w[0][0]+w[0][2]),O=[];O[1]=Math.max(le-b,0),O[2]=Math.max(ce-b,0),O[4]=Math.max(ue-b,0),O[3]=Math.max(de-b,0);let fe=[],pe=[],me=[];pe[0]=le>=de?Hl:Gl,me[0]=ce>=ue?Ul:Wl,pe[1]=iu(pe[0]),me[1]=iu(me[0]);let he=le>=de?le:de,ge=ce>=ue?ce:ue,_e=[[0,0],[0,0]],ve=!1;for(let e=0;e<2;e++)C[e]===0&&((pe[e]&S[e])===0&&(pe[e]=iu(pe[e])),(me[e]&S[e])===0&&(me[e]=iu(me[e])),_e[e][0]=me[e],_e[e][1]=pe[e]);ge>0&&he>0&&((pe[0]&S[0])>0&&(me[1]&S[1])>0?(_e[0]=[pe[0],me[0]],_e[1]=[me[1],pe[1]],ve=!0):(me[0]&S[0])>0&&(pe[1]&S[1])>0&&(_e[0]=[me[0],pe[0]],_e[1]=[pe[1],me[1]],ve=!0)),ge>0&&!ve&&(_e[0]=[me[0],pe[0]],_e[1]=[me[1],pe[1]],ve=!0),he>0&&!ve&&(_e[0]=[pe[0],me[0]],_e[1]=[pe[1],me[1]]);for(let e=0;e<2;e++)C[e]===0&&((_e[e][0]&S[e])===0&&(_e[e][0]=_e[e][1]),fe[e]=_e[e][0]&S[e],fe[e]|=(_e[e][1]&S[e])<<8,fe[e]|=(_e[1-e][e]&S[e])<<16,fe[e]|=(_e[1-e][1-e]&S[e])<<24,fe[e]&15||(fe[e]=fe[e]<<8),fe[e]&3840||(fe[e]=fe[e]&15|fe[e]>>8),fe[e]&983040||(fe[e]=fe[e]&65535|(fe[e]&251658240)>>8),C[e]=fe[e]&15,(S[e]===Hl||S[e]===Ul||S[e]===Gl||S[e]===Wl)&&(C[e]=S[e]));let ye=C[0]===Gl?3:C[0],be=C[1]===Gl?3:C[1];ye-=ae,be-=ae,ye<1&&(ye+=4),be<1&&(be+=4);let xe=uu[ye-1][be-1],k=Array.from({length:12},()=>[0,0]);switch(k[0][0]=w[0][0],k[0][1]=w[0][1],C[0]){case Hl:k[0][0]-=v,k[0][1]+=se[0][1]*w[0][3];break;case Wl:k[0][0]+=se[0][0]*w[0][2],k[0][1]+=w[0][3]+v;break;case Gl:k[0][0]+=w[0][2]+v,k[0][1]+=se[0][1]*w[0][3];break;case Ul:k[0][0]+=se[0][0]*w[0][2],k[0][1]-=v}let A=0,Se=(C[0]&9)>0?0:1,Ce=Se,we=0;for(let e of xe){let t=e&15,n=t===Gl?3:t;n+=ae,n>4&&(n-=4);let r=lu[n-1];we=n%2>0?0:1,we!==Se&&(A++,k[A][0]=k[A-1][0],k[A][1]=k[A-1][1]);let i=(e&fu)>0,a=(e&du)>0,o=(e&pu)>>5;o<<=ae,o>15&&(o>>=4);let s=(e&mu)>0;if((a||i)&&o<9){let e=0,t=+!a;if(e=s&&we===0?w[t][0]+se[t][0]*w[t][2]:s?w[t][1]+se[t][1]*w[t][3]:E[t][o],we===0){let t=k[A][0],n=(e-t)*r[0];n>0&&(k[A][0]+=r[0]*n)}else{let t=k[A][1],n=(e-t)*r[1];n>0&&(k[A][1]+=r[1]*n)}}else s&&(k[A][0]+=r[0]*Math.abs(O[n]/2),k[A][1]+=r[1]*Math.abs(O[n]/2));A>0&&k[A][we]===k[A-1][we]?A--:Se=we}for(let e=0;e<=A&&(e!==A||(((C[1]&9)>0?0:1)===Ce?0:1)==(A+1)%2);e++)i.push({x:Yl(k[e][0]),y:Yl(k[e][1])});let Te=1;for(;Te<i.length;){let[e,t]=[i[Te-1],i[Te]];e==null||t==null||e.x!==t.x||e.y!==t.y?Te++:i.splice(Te,1)}},gu=(e,t,n)=>Xl(e,t,n),_u=(e,t,n,r,i)=>{let a=r!==null&&r.length>0?ru(e,r[0]):null,o=e.absolutePoints[0],s=e.absolutePoints[e.absolutePoints.length-1],c=o==null?t?.box??null:{x:o.x,y:o.y,width:0,height:0},l=s==null?n?.box??null:{x:s.x,y:s.y,width:0,height:0};if(c===null||l===null)return;let u=Math.max(c.x,l.x),d=Math.min(c.x+c.width,l.x+l.width),f=a===null?Math.round(d+(u-d)/2):a.x,p=c.y+c.height/2,m=l.y+l.height/2;if(a!==null&&(a.y>=c.y&&a.y<=c.y+c.height&&(p=a.y),a.y>=l.y&&a.y<=l.y+l.height&&(m=a.y)),!gu(l,f,p)&&!gu(c,f,p)&&i.push({x:f,y:p}),!gu(l,f,m)&&!gu(c,f,m)&&i.push({x:f,y:m}),i.length===1){if(a!==null)!gu(l,f,a.y)&&!gu(c,f,a.y)&&i.push({x:f,y:a.y});else{let e=Math.max(c.y,l.y),t=Math.min(c.y+c.height,l.y+l.height);i.push({x:f,y:e+(t-e)/2})}}a=null},vu=(e,t,n,r,i)=>{let a=r!==null&&r.length>0?ru(e,r[0]):null,o=e.absolutePoints[0],s=e.absolutePoints[e.absolutePoints.length-1],c=o==null?t?.box??null:{x:o.x,y:o.y,width:0,height:0},l=s==null?n?.box??null:{x:s.x,y:s.y,width:0,height:0};if(c===null||l===null)return;let u=Math.max(c.y,l.y),d=Math.min(c.y+c.height,l.y+l.height),f=c.x+c.width/2;a!==null&&a.x>=c.x&&a.x<=c.x+c.width&&(f=a.x);let p=a===null?Math.round(d+(u-d)/2):a.y;if(!gu(l,f,p)&&!gu(c,f,p)&&i.push({x:f,y:p}),f=a!==null&&a.x>=l.x&&a.x<=l.x+l.width?a.x:l.x+l.width/2,!gu(l,f,p)&&!gu(c,f,p)&&i.push({x:f,y:p}),i.length===1){if(a!==null)!gu(l,a.x,p)&&!gu(c,a.x,p)&&i.push({x:a.x,y:p});else{let e=Math.max(c.x,l.x),t=Math.min(c.x+c.width,l.x+l.width);i.push({x:e+(t-e)/2,y:p})}}},yu=(e,t,n,r,i)=>{let a=r!==null&&r.length>0?r[0]:null,o=!1,s=!1;if(t!==null&&n!==null){let r=t.box,i=n.box;if(a!==null){let t=Math.min(r.x,i.x),n=Math.max(r.x+r.width,i.x+i.width),c=Math.min(r.y,i.y),l=Math.max(r.y+r.height,i.y+i.height);a=ru(e,a),o=a.y<c||a.y>l,s=a.x<t||a.x>n}else o=Math.max(r.x,i.x)===Math.min(r.x+r.width,i.x+i.width),o||(s=Math.max(r.y,i.y)===Math.min(r.y+r.height,i.y+i.height))}!s&&(o||e.style.elbow===`vertical`)?vu(e,t,n,r,i):_u(e,t,n,r,i)},bu={orthogonalEdgeStyle:hu,segmentEdgeStyle:cu,elbowEdgeStyle:yu,sideToSideEdgeStyle:_u,topToBottomEdgeStyle:vu},xu=new Set([hu,cu,yu,_u,vu]),Su=new Set([yu,_u,vu]);function Cu(e){let t=new Map(e.cells.filter(e=>e.id!==void 0).map(e=>[e.id,e])),n=new Map,r=(e,i=new Set)=>{if(e.id!==void 0&&n.has(e.id))return n.get(e.id);let a={x:0,y:0},o=e.parent===void 0?void 0:t.get(e.parent);if(o!==void 0&&!i.has(o.id??``)){if(i.add(o.id??``),o.edge)a=null;else if(o.vertex){let e=r(o,i),t=o.geometry;a=e===null||t===void 0||t.relative?null:{x:e.x+t.x,y:e.y+t.y}}}return e.id!==void 0&&n.set(e.id,a),a},i=new Map;for(let t of e.cells){if(t.id===void 0)continue;let e=r(t);!t.vertex||t.geometry===void 0||t.geometry.relative||e===null||t.geometry.unreadable.length>0||i.set(t.id,{box:{x:e.x+t.geometry.x,y:e.y+t.geometry.y,width:t.geometry.width,height:t.geometry.height},style:Bl(t.style,!1)})}return{terminals:i,origins:n}}function wu(e,t){let n=e.geometry;if(n===void 0||e.id===void 0)return;let r=t.origins.get(e.id);if(r==null)return;let i=Bl(e.style,!0);if(i.sourcePort!==void 0||i.targetPort!==void 0||i.snapToPoint!==void 0||Vl(i,`fixedPointSpacing`,0)===1||i.orthogonal!==void 0)return;let a=e.source===void 0?null:t.terminals.get(e.source),o=e.target===void 0?null:t.terminals.get(e.target);if(a===void 0||o===void 0||a!==null&&!Zl(a)||o!==null&&!Zl(o)||a!==null&&a===o)return;let s=Vl(i,`noEdgeStyle`,0)===1?void 0:i.edgeStyle,c=s===void 0?null:bu[String(s)];if(c===void 0)return;let l={style:i,absolutePoints:[null,null],origin:r},u=(e,t)=>{let a=t?`exit`:`entry`;if(e!==null&&e.style.perimeter===`centerPerimeter`)return Jl(e.box);let o=i[`${a}X`],s=i[`${a}Y`];if(e!==null&&o!==void 0&&s!==void 0){let t=Number.parseFloat(String(o)),n=Number.parseFloat(String(s)),r=i[`${a}Perimeter`]===void 0||!!Number(i[`${a}Perimeter`]),c=Vl(i,`${a}Dx`,0),l=Vl(i,`${a}Dy`,0),u={x:e.box.x+t*e.box.width+c,y:e.box.y+n*e.box.height+l};return r&&(u=nu(e,u,!1,0)),u}if(e===null){let e=t?n.sourcePointAt:n.targetPointAt;return e===void 0?null:{x:e.x+r.x,y:e.y+r.y}}return null};if(l.absolutePoints=[u(a,!0),u(o,!1)],a===null&&l.absolutePoints[0]===null||o===null&&l.absolutePoints[1]===null)return;let d=n.points.length>0?n.points:null,f=[l.absolutePoints[0]];if(c!==null)c(l,a,o,d,f);else if(d!==null)for(let e of d)f.push(ru(l,e));f.push(l.absolutePoints[1]);let p=c!==null&&xu.has(c),m=(e,t,n)=>{let r=f.length,a=f[n?Math.min(1,r-1):Math.max(0,r-2)]??null;a===null&&t!==null&&(a=Jl(t.box));let o=Vl(i,`perimeterSpacing`,0)+Vl(i,n?`sourcePerimeterSpacing`:`targetPerimeterSpacing`,0);return a===null?Jl(e.box):nu(e,a,p,o)};if(f[f.length-1]===null&&o!==null&&(f[f.length-1]=m(o,a,!1)),f[0]===null&&a!==null&&(f[0]=m(a,o,!0)),c!==null&&(Su.has(c)||c===hu&&d===null)&&f.length>2){let e=(e,t)=>e!==null&&t!==null&&Math.abs(e.x-t.x)<.01&&Math.abs(e.y-t.y)<.01,t=!1;for(let n=1;n<f.length&&!t;n++)t=e(f[n-1],f[n]);if(t)for(let t=f.length-2;t>0&&f.length>2;t--)(e(f[t],f[t+1])||e(f[t],f[t-1]))&&f.splice(t,1)}if(f.some(e=>e===null)||f.length<2)return;let h=f,g=[],_=0;for(let e=1;e<h.length;e++){let t=Math.hypot(h[e-1].x-h[e].x,h[e-1].y-h[e].y);g.push(t),_+=t}return{points:h,segments:g,length:_}}function Tu(e,t,n={x:0,y:0}){let{points:r,segments:i}=e,a=t.x/2,o=Math.round((a+.5)*e.length),s=i[0]??0,c=0,l=1;for(;o>=Math.round(c+s)&&l<r.length-1;)c+=s,s=i[l++];let u=s===0?0:(o-c)/s,d=r[l-1],f=r[l],p=f.x-d.x,m=f.y-d.y,h=s===0?0:m/s,g=s===0?0:p/s;return{x:d.x+p*u+(h*t.y+n.x),y:d.y+m*u-(g*t.y-n.y)}}function Eu(e){let t=String(e.shape??``);return t===`ellipse`||t===`doubleEllipse`?`ellipse`:t===`rhombus`?`rhombus`:`box`}function Du(e,t,n,r,i){let a=n.width/2-i,o=n.height/2-i;if(a<=0||o<=0)return 0;let s=n.x+n.width/2,c=n.y+n.height/2,l=(e.x-s)/a,u=(e.y-c)/o,d=(t.x-e.x)/a,f=(t.y-e.y)/o,p=0,m=1;if(r===`ellipse`){let e=d*d+f*f;if(e===0)return 0;let t=2*(l*d+u*f),n=l*l+u*u-1,r=t*t-4*e*n;if(r<=0)return 0;let i=Math.sqrt(r);p=Math.max(0,(-t-i)/(2*e)),m=Math.min(1,(-t+i)/(2*e))}else{let e=r===`box`?[[1,0],[-1,0],[0,1],[0,-1]]:[[1,1],[1,-1],[-1,1],[-1,-1]];for(let[t,n]of e){let e=t*l+n*u-1,r=t*d+n*f;if(r===0){if(e>=0)return 0;continue}let i=-e/r;r<0?p=Math.max(p,i):m=Math.min(m,i)}}return m<=p?0:(m-p)*Math.hypot(t.x-e.x,t.y-e.y)}function Ou(e,t){let n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),r=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);return n>0&&r>0?n*r:0}function ku(e,t,n){let r=Math.max(1,t.length)*n*.45,i=n*1.18;return{x:e.x-r/2,y:e.y-i/2,width:r,height:i}}function Au(e,t,n,r={x:0,y:0}){let i=[e.label,...t.filter(t=>t.parent===e.id).map(e=>e.label)],a=t=>{let n=n=>{let r=RegExp(`(?:^|;)${t}${n}=([^;]*)`).exec(e.style)?.[1],i=r===void 0?NaN:Number.parseFloat(r);return Number.isFinite(i)?i:void 0},r=n(`X`),i=n(`Y`);return r===void 0||i===void 0?void 0:{x:r,y:i}};return{id:e.id,label:i.filter(e=>e!==``).join(` `),source:e.source,target:e.target,exit:a(`exit`),entry:a(`entry`),points:n,waypoints:(e.geometry?.points??[]).map(e=>({x:r.x+e.x,y:r.y+e.y}))}}var ju=[.25,.5,.75,.125,.375,.625,.875],Mu=.06;function Nu(e,t){let n=t.x+t.width/2-(e.x+e.width/2),r=t.y+t.height/2-(e.y+e.height/2);return Math.abs(n)>=Math.abs(r)?n>=0?`X=1;Y=0.5`:`X=0;Y=0.5`:r>=0?`X=0.5;Y=1`:`X=0.5;Y=0`}var Pu=(e,t)=>{let[n,r]=Nu(e,t).split(`;`).map(e=>Number(e.slice(2)));return{x:e.x+e.width*n,y:e.y+e.height*r}},Fu=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,Iu=e=>e.reduce((t,n,r)=>r===0?0:t+Math.hypot(n.x-e[r-1].x,n.y-e[r-1].y),0),Lu=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function Ru(e,t){let n=e.width>0?(t.x-e.x)/e.width:.5,r=e.height>0?(t.y-e.y)/e.height:.5,[i,,a]=[[`left`,Math.abs(n),r],[`right`,Math.abs(1-n),r],[`top`,Math.abs(r),n],[`bottom`,Math.abs(1-r),n]].reduce((e,t)=>t[1]<e[1]?t:e);return{side:i,along:a}}var zu=(e,t)=>{let n=String(t);return e===`left`?`X=0;Y=${n}`:e===`right`?`X=1;Y=${n}`:e===`top`?`X=${n};Y=0`:`X=${n};Y=1`};function Bu(e){let t=e=>e>0&&e<1;if(e.x===0&&t(e.y))return`left`;if(e.x===1&&t(e.y))return`right`;if(e.y===0&&t(e.x))return`top`;if(e.y===1&&t(e.x))return`bottom`}function Vu(e,t,n){return t===`right`?n.x+n.width<=e.x:t===`left`?n.x>=e.x+e.width:t===`bottom`?n.y+n.height<=e.y:n.y>=e.y+e.height}var Hu={left:`left side`,right:`right side`,top:`top`,bottom:`bottom`},Uu=(e,t)=>`${e}:${t}`;function Wu(e,t){let n=new Map;for(let r of e){if(r.points.length<2)continue;let e=(e,i,a)=>{if(e===void 0||!t.has(e))return;let o=n.get(e)??[];o.push({wire:r,shape:e,point:i,role:a}),n.set(e,o)};e(r.source,r.points[0],`exit`),e(r.target,r.points[r.points.length-1],`entry`)}return n}function Gu(e,t){let n=[];for(let r of e){if(r.points.length<2)continue;let e=r.source===void 0?void 0:t.get(r.source),i=r.target===void 0?void 0:t.get(r.target);if(e!==void 0&&i!==void 0)for(let[t,a,o,s]of[[`exit`,r.exit,e,i],[`entry`,r.entry,i,e]]){let e=a===void 0?void 0:Bu(a);e!==void 0&&Vu(o,e,s)&&n.push({wire:r,role:t,side:e})}}return n}function Ku(e,t,n){let r=new Map,i=Wu(e,t);for(let[e,a]of i){let i=t.get(e),o=new Map;for(let e of a){if(!n.has(Uu(e.wire.id,e.role)))continue;let r=e.role===`exit`?e.wire.target:e.wire.source,a=r===void 0?void 0:t.get(r);if(a===void 0)continue;let s=Ru(i,Pu(i,a)).side;o.set(s,[...o.get(s)??[],e])}for(let[e,t]of o){let o=a.filter(e=>!n.has(Uu(e.wire.id,e.role))).map(e=>Ru(i,e.point)).filter(t=>t.side===e).map(e=>e.along),s=t.length===1?[.5,...ju.filter(e=>e!==.5)]:t.length===2?[.25,.75,...ju.filter(e=>e!==.25&&e!==.75)]:ju,c=s.filter(e=>o.every(t=>Math.abs(t-e)>Mu));t.forEach((t,n)=>{let o=c[n];o===void 0?r.set(Uu(t.wire.id,t.role),Ju(i,a,r,e)??zu(e,s[n%s.length])):r.set(Uu(t.wire.id,t.role),zu(e,o))})}}return r}function qu(e,t,n,r,i){return t.flatMap(t=>{let a=Uu(t.wire.id,t.role),o=n.get(a);if(o!==void 0){let[t,n]=o.split(`;`).map(e=>Number(e.slice(2))),i=Ru(e,{x:e.x+e.width*t,y:e.y+e.height*n});return i.side===r?[i.along]:[]}if(i?.has(a))return[];let s=Ru(e,t.point);return s.side===r?[s.along]:[]})}function Ju(e,t,n,r){for(let i of[`right`,`bottom`,`left`,`top`].filter(e=>e!==r)){let r=qu(e,t,n,i),a=ju.find(e=>r.every(t=>Math.abs(t-e)>Mu));if(a!==void 0)return zu(i,a)}}function Yu(e,t,n){let r=Gu(e,t).filter(e=>!n.has(e.wire.id)),i=new Set([...[...n].flatMap(([e,t])=>t.map(t=>Uu(e,t))),...r.map(e=>Uu(e.wire.id,e.role))]);return{away:r,moving:i,placements:Ku(e,t,i)}}function Xu(e,t,n){let r=new Map;for(let[i,a]of Yu(e,t,n).placements){let e=i.slice(i.lastIndexOf(`:`)+1);r.set(i,a.split(`;`).map(t=>`${e}${t}`).join(`;`))}return r}var Zu=e=>`(${Math.round(e.x)}, ${Math.round(e.y)})`;function Qu(e,t){let n=(e,t)=>Math.abs(e.x-t.x)<=1&&Math.abs(e.y-t.y)<=1;for(let r=0;r+1<e.length;r++){let i=e[r],a=e[r+1],o=Math.hypot(a.x-i.x,a.y-i.y);if(o>=.5&&o<20){let e=Math.abs(a.x-i.x)<Math.abs(a.y-i.y),r=n=>t.find(t=>e?Math.abs(t.y-n.y)<=1:Math.abs(t.x-n.x)<=1),s=t.find(e=>n(e,a))??t.find(e=>n(e,i))??r(a)??r(i),c=`a ${Math.max(1,Math.round(o))}-unit segment`;if(s===void 0)return{where:i,why:c,vertical:e,waypoints:t,fix:``};let l=n(s,a)||(e?Math.abs(s.y-a.y)<=1:Math.abs(s.x-a.x)<=1)?i:a,u=e?{x:s.x,y:l.y}:{x:l.x,y:s.y};return{where:i,why:c,vertical:e,waypoint:s,waypoints:t.map(e=>e===s?u:e),fix:`move its waypoint at ${Zu(s)} to ${Zu(u)}`}}let s=e[r+2];if(s===void 0)continue;let c={x:a.x-i.x,y:a.y-i.y},l={x:s.x-a.x,y:s.y-a.y};if(Math.abs(c.x*l.y-c.y*l.x)<.5&&c.x*l.x+c.y*l.y<0){let e=t.find(e=>n(e,a)),r=`a segment that goes back over the one before it`;return e===void 0?{where:a,why:r,vertical:c.x===0,waypoints:t,fix:``}:{where:a,why:r,vertical:c.x===0,waypoint:e,waypoints:t.filter(t=>t!==e),fix:`remove its waypoint at ${Zu(e)}`}}}}function $u(e,t,n=e=>`"${e}"`,r=new Map,i){let a=[],{away:o,moving:s,placements:c}=Yu(e,t,r),l=(e,t)=>c.get(Uu(e,t)).split(`;`).map(e=>`${t}${e}`).join(`;`),u=new Map;for(let[r,i]of Wu(e,t)){let e=t.get(r),o=i.filter(e=>!s.has(Uu(e.wire.id,e.role))),l=[];for(let e of o){let t=l.find(t=>Math.abs(t[0].point.x-e.point.x)<=1&&Math.abs(t[0].point.y-e.point.y)<=1);t?t.push(e):l.push([e])}for(let s of l){if(new Set(s.map(e=>e.wire.id)).size<2)continue;let l=new Set(s.map(e=>Lu(e.wire.label)));if(l.size===1&&!l.has(``))continue;let{side:d,along:f}=Ru(e,s[0].point),p=[...o.map(t=>Ru(e,t.point)).filter(e=>e.side===d).map(e=>e.along),...i.flatMap(t=>{let n=c.get(Uu(t.wire.id,t.role));if(n===void 0)return[];let[r,i]=n.split(`;`).map(e=>Number(e.slice(2))),a=Ru(e,{x:e.x+e.width*r,y:e.y+e.height*i});return a.side===d?[a.along]:[]})];p.push(...u.get(`${r}:${d}`)??[]);let m=ju.filter(e=>p.every(t=>Math.abs(t-e)>Mu)&&Math.abs(f-e)>Mu),h=s.slice(1);u.set(`${r}:${d}`,[...u.get(`${r}:${d}`)??[],...m.slice(0,h.length)]);let g=s.map(e=>n(e.wire.id)),_=l.has(``)?`they are not labelled as the same data`:`they carry different data`,v=h.slice(0,m.length).map((e,t)=>`${zu(d,m[t]).split(`;`).map(t=>`${e.role}${t}`).join(`;`)} for ${n(e.wire.id)}`),y=t=>[...i.map(t=>Ru(e,t.point)).filter(e=>e.side===t).map(e=>e.along),...i.flatMap(n=>c.has(Uu(n.wire.id,n.role))?qu(e,[n],c,t):[]),...u.get(`${r}:${t}`)??[]],b=h.slice(m.length).map(i=>{let a=i.role===`exit`?i.wire.target:i.wire.source,o=a===void 0?void 0:t.get(a),s=o===void 0?void 0:Ru(e,Pu(e,o)).side,c=[...new Set([s,`right`,`bottom`,`left`,`top`])].filter(e=>e!==void 0&&e!==d);for(let e of c){let t=ju.find(t=>y(e).every(e=>Math.abs(e-t)>Mu));if(t!==void 0)return u.set(`${r}:${e}`,[...u.get(`${r}:${e}`)??[],t]),`${zu(e,t).split(`;`).map(e=>`${i.role}${e}`).join(`;`)} for ${n(i.wire.id)}, on its ${Hu[e]}`}return`${n(i.wire.id)}: no side of this shape has a free point left, so make the shape larger`}),x=v.length===0?`that ${Hu[d]} has no free point left, so move them to other sides: ${b.join(`, `)}`:`give each its own point on its ${Hu[d]}: ${v.join(`, `)}${b.length>0?`, and, since that side has no free point left, ${b.join(`, `)}`:``}`;a.push({rule:`shared-point`,wires:[...new Set(s.map(e=>e.wire.id))],shapes:[r],message:`connectors ${g.join(`, `)} meet shape ${n(r)} at the same point, and ${_}: ${x}. Only wires with the same label may share a point`})}}let d=new Set;for(let{wire:e,role:t,side:r}of o){d.add(e.id);let i=t===`exit`?e.source:e.target,o=t===`exit`?e.target:e.source;a.push({rule:`facing-away`,wires:[e.id],shapes:[i],message:`connector ${n(e.id)} ${t===`exit`?`leaves`:`enters`} shape ${n(i)} on its ${Hu[r]}, facing away from ${n(o)}: fix it on the side facing it (${l(e.id,t)}), or drop ${t}X/${t}Y to let draw.io choose`})}for(let i of e){if(i.points.length<2||d.has(i.id)||r.has(i.id))continue;let e=i.source===void 0?void 0:t.get(i.source),o=i.target===void 0?void 0:t.get(i.target);if(e===void 0||o===void 0||Fu(e,o))continue;let s=Pu(e,o),c=Pu(o,e),l=Math.hypot(c.x-s.x,c.y-s.y),u=Iu(i.points);if(u<=2*l||u-l<80)continue;let f=Nu(e,o).split(`;`).map(e=>`exit${e}`).join(`;`),p=Nu(o,e).split(`;`).map(e=>`entry${e}`).join(`;`);a.push({rule:`detour`,wires:[i.id],shapes:[i.source,i.target],message:`connector ${n(i.id)} runs ${Math.round(u)} units to join shapes ${n(i.source)} and ${n(i.target)}, whose facing sides are ${Math.round(l)} apart: fix its exit and entry on those sides (${f};${p}), or give it a waypoint on the short way (<Array as="points"><mxPoint x="…" y="…"/></Array> in its geometry)`})}for(let o of e){if(o.waypoints.length===0&&o.exit===void 0&&o.entry===void 0||d.has(o.id)||r.has(o.id))continue;let e=Qu(o.points,o.waypoints);if(e===void 0)continue;let s=(e,t)=>{if(i===void 0)return!0;let n=i(o,e,t);return n!==void 0&&Qu(n,e)===void 0},c;if(e.waypoint!==void 0&&s(e.waypoints)?c=e.fix:s([])&&(c=`remove its waypoints (the <Array as="points"> in its geometry) to let draw.io route it`),c===void 0){let n=o.source===void 0?void 0:t.get(o.source),r=o.target===void 0?void 0:t.get(o.target);if(n===void 0||r===void 0)continue;let i=o.points[0],a=o.points[o.points.length-1],l=(t,n)=>e.vertical?(n.y-t.y)/t.height:(n.x-t.x)/t.width,u=e=>Math.round(e*1e4)/1e4,d=o.entry===void 0?void 0:u(l(r,i)),f=o.exit===void 0?void 0:u(l(n,a)),p=e.vertical?`Y`:`X`;d!==void 0&&d>0&&d<1&&s(o.waypoints,{[`entry${p}`]:d})?c=`put its entry level with its exit: entry${p}=${d}`:f!==void 0&&f>0&&f<1&&s(o.waypoints,{[`exit${p}`]:f})?c=`put its exit level with its entry: exit${p}=${f}`:(o.exit!==void 0||o.entry!==void 0)&&s(o.waypoints,{...o.exit?{exitX:NaN}:{},...o.entry?{entryX:NaN}:{}})&&(c=`drop exitX/exitY and entryX/entryY to let draw.io choose where it leaves and enters`)}if(c===void 0){let r=t.get(o.source),i=t.get(o.target),a=Math.round(r.y+r.height/2-(i.y+i.height/2)),s=Math.round(r.x+r.width/2-(i.x+i.width/2)),l=e.vertical?{name:`y`,by:a}:{name:`x`,by:s};if(l.by===0)continue;c=`line up the shapes it joins, whose middles are ${Math.abs(l.by)} units apart: move ${n(o.target)} by ${l.by>0?`+`:``}${l.by} on ${l.name}`}a.push({rule:`needless-bend`,wires:[o.id],shapes:[],message:`connector ${n(o.id)} has a needless bend near ${Zu(e.where)}: ${e.why}. Fix it: ${c}`})}return a}var ed=class extends Error{constructor(e){super(e),this.name=`XmlError`}},td=new Map([[`amp`,`&`],[`lt`,`<`],[`gt`,`>`],[`quot`,`"`],[`apos`,`'`]]);function nd(e){return e.includes(`&`)?e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-zA-Z]+);/g,(e,t)=>{if(t.startsWith(`#x`)||t.startsWith(`#X`)){let n=Number.parseInt(t.slice(2),16);return Number.isFinite(n)&&n>0?rd(n,e):e}if(t.startsWith(`#`)){let n=Number.parseInt(t.slice(1),10);return Number.isFinite(n)&&n>0?rd(n,e):e}return td.get(t)??e}):e}function rd(e,t){try{return String.fromCodePoint(e)}catch{return t}}function id(e){let t=new Map,n=/([^\s=/>]+)\s*=\s*("([^"]*)"|'([^']*)')/g,r;for(;(r=n.exec(e))!==null;)t.set(r[1],nd(r[3]??r[4]??``));return t}function ad(e,t){let n=0,r=e.length;for(;n<r;){let r=e.indexOf(`<`,n);if(r===-1){i(e.slice(n));return}if(r>n&&i(e.slice(n,r))===!1)return;if(e.startsWith(`<!--`,r)){let t=e.indexOf(`-->`,r+4);if(t===-1)return;n=t+3;continue}if(e.startsWith(`<![CDATA[`,r)){let i=e.indexOf(`]]>`,r+9);if(i===-1)throw new ed(`unterminated CDATA section`);if(t({kind:`text`,text:e.slice(r+9,i)})===!1)return;n=i+3;continue}if(/^<!doctype/i.test(e.slice(r,r+9)))throw new ed(`this document declares a DOCTYPE, which is refused`);if(e.startsWith(`<?`,r)){let t=e.indexOf(`?>`,r+2);if(t===-1)throw new ed(`unterminated processing instruction`);n=t+2;continue}let a=od(e,r);if(a===-1)throw new ed(`unterminated tag`);let o=e.slice(r+1,a);if(n=a+1,o.startsWith(`/`)){if(t({kind:`close`,name:o.slice(1).trim()})===!1)return;continue}let s=o.endsWith(`/`),c=s?o.slice(0,-1):o,l=c.search(/[\s/]/),u=(l===-1?c:c.slice(0,l)).trim();if(u===``)throw new ed(`a tag has no name`);if(t({kind:`open`,name:u,attributes:l===-1?new Map:id(c.slice(l)),selfClosing:s})===!1)return}function i(e){if(e!==``)return t({kind:`text`,text:nd(e)})}}function od(e,t){let n=null;for(let r=t+1;r<e.length;r++){let t=e[r];if(n!==null)t===n&&(n=null);else if(t===`"`||t===`'`)n=t;else if(t===`>`)return r}return-1}var sd=class extends Error{constructor(e){super(e),this.name=`DrawioReadError`}},cd=[`x`,`y`,`width`,`height`];function ld(e){let t=e.replace(/[^\x20-\x7e]/g,`?`);return t.length>40?`${t.slice(0,39)}…`:t}function ud(e){let t=``,n=null;for(let r of e??``)r===`<`?n=``:r===`>`?(n!==null&&/^br\b/i.test(n)&&(t+=` `),n=null):n===null?t+=r:n+=r;return t.replace(/&nbsp;/g,` `).replace(/\s+/g,` `).trim()}function dd(e){let t={x:0,y:0,width:0,height:0,relative:e.get(`relative`)===`1`,unreadable:[],sourcePoint:!1,targetPoint:!1,points:[]};for(let n of cd){let r=e.get(n);if(r===void 0)continue;let i=Number(r);r.trim()===``||!Number.isFinite(i)?t.unreadable.push(`${n}="${r}"`):t[n]=i}return t}function fd(e,t){let n=[],r=[],i=null,a=null,o=null,s=!1;try{ad(e,e=>{if(e.kind===`text`)return;if(e.kind===`close`){let t=r.pop();if(t!==e.name)throw new sd(`</${ld(e.name)}> closes <${ld(t??`nothing`)}>`);e.name===`mxCell`?a=null:e.name===`mxGeometry`?o=null:(e.name===`object`||e.name===`UserObject`)&&(i=null);return}let{name:t,attributes:c,selfClosing:l}=e;if(r.length===0){if(t!==`mxGraphModel`)throw new sd(`its model is <${ld(t)}>, not <mxGraphModel>`);s=!0}if(t===`object`||t===`UserObject`)i=c;else if(t===`mxCell`){let e={id:(i??c).get(`id`)??c.get(`id`),parent:c.get(`parent`),vertex:c.get(`vertex`)===`1`,edge:c.get(`edge`)===`1`,source:c.get(`source`),target:c.get(`target`),label:ud(i?i.get(`label`)??i.get(`value`):c.get(`value`)),style:c.get(`style`)??``,geometry:void 0};n.push(e),a=l?null:e}else if(t===`mxGeometry`&&a!==null&&(c.get(`as`)??`geometry`)===`geometry`){let e=dd(c);a.geometry=e,o=l?null:e}else if(t===`mxPoint`&&o!==null){let e={x:Number(c.get(`x`)??0)||0,y:Number(c.get(`y`)??0)||0},t=o;c.get(`as`)===`sourcePoint`?(t.sourcePoint=!0,t.sourcePointAt=e):c.get(`as`)===`targetPoint`?(t.targetPoint=!0,t.targetPointAt=e):c.get(`as`)===`offset`?t.offset=e:r[r.length-1]===`Array`&&r[r.length-2]===`mxGeometry`&&t.points.push(e)}l||r.push(t)})}catch(e){throw e instanceof sd?e:e instanceof ed?new sd(`page "${t}" is not well-formed XML: ${e.message}`):e}if(!s)throw new sd(`page "${t}" holds no <mxGraphModel>`);if(r.length>0)throw new sd(`page "${t}" ends inside <${r[r.length-1]}>`);return n}function pd(e,t){let n=e.replace(/^/,``).trim(),r;try{ad(n,e=>{if(e.kind===`open`)return r=e.name,!1})}catch(e){throw e instanceof ed?new sd(`this is not well-formed XML: ${e.message}`):e}if(r===`mxGraphModel`)return[{name:`Page-1`,cells:fd(n,`Page-1`)}];if(r!==`mxfile`)throw new sd(r===void 0?`the file is empty`:`its root is <${ld(r)}>, not <mxfile> or <mxGraphModel>`);let i=[],a=/<diagram\b([^>]*?)(\/>|>([\s\S]*?)<\/diagram>)/g,o;for(;(o=a.exec(n))!==null;){let e=`Page-${i.length+1}`;ad(`<diagram${o[1]}/>`,t=>{if(t.kind===`open`){let n=t.attributes.get(`name`);n&&(e=n)}return!1});let n=(o[3]??``).trim();if(n===``)throw new sd(`page "${e}" is empty`);let r;try{if(n.startsWith(`<`))r=n;else if(t===void 0)throw new sd(`its compressed data cannot be read here`);else r=t(n)}catch(t){throw t instanceof sd?new sd(`page "${e}" cannot be read: ${t.message}`):t}i.push({name:e,cells:fd(r,e)})}if(i.length===0)throw new sd(`the <mxfile> holds no <diagram> page`);return i}function md(e){let t=e.label.length>40?`${e.label.slice(0,39)}…`:e.label;return t===``?`"${e.id}"`:`"${e.id}" (${t})`}function hd(e,t){let n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),r=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);return n>0&&r>0?n*r:0}function gd(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}var _d=.1;function vd(e){if(e.label===``)return!1;let t=e.style.split(`;`)[0];return![`line`,`image`,`group`,`text`,`edgeLabel`].includes(t)&&!/(^|;)(shape=(line|image)|image=)/.test(e.style)}var yd={shapes:0,ends:1,sharedPoints:2,detours:3,crossings:4,labels:5};function bd(e,t){let n=t.length,r=new Map,i=(n,i,a,o)=>{let s={severity:n,page:e.name,cells:i,message:a};t.push(s),o!==void 0&&r.set(s,o)},a=new Map;for(let t of e.cells)t.id===void 0||t.id===``?i(`error`,[],`a cell${t.label?` labelled "${t.label}"`:``} has no id`):a.has(t.id)?i(`error`,[t.id],`the id "${t.id}" is used by more than one cell`):a.set(t.id,t);let o=e.cells[0];for(let t of e.cells)t.id!==void 0&&(t.parent===void 0?t!==o&&i(`error`,[t.id],`cell ${md(t)} has no parent; every cell but the root belongs to a layer or a container`):a.has(t.parent)||i(`error`,[t.id],`cell ${md(t)} belongs to "${t.parent}", which does not exist`));let s=e=>e.geometry?.relative===!0||e.parent!==void 0&&a.get(e.parent)?.edge===!0;for(let t of e.cells)if(t.id!==void 0){if(t.edge){for(let[e,n,r]of[[`start`,t.source,t.geometry?.sourcePoint],[`end`,t.target,t.geometry?.targetPoint]])n!==void 0&&!a.has(n)?i(`error`,[t.id],`connector ${md(t)} has its ${e} on "${n}", which does not exist`):n===void 0&&r!==!0&&i(`error`,[t.id],`connector ${md(t)} is attached to nothing at its ${e}: give it a ${e===`start`?`source`:`target`}, or a ${e===`start`?`sourcePoint`:`targetPoint`}`);t.geometry===void 0&&i(`error`,[t.id],`connector ${md(t)} has no <mxGeometry relative="1" as="geometry">`)}if(t.vertex){let e=t.geometry;e===void 0?i(`error`,[t.id],`shape ${md(t)} has no <mxGeometry as="geometry">, so it has no size or place`):e.unreadable.length>0?i(`error`,[t.id],`shape ${md(t)} has geometry that is not numbers: ${e.unreadable.join(`, `)}`):e.width<0||e.height<0?i(`error`,[t.id],`shape ${md(t)} is ${e.width} × ${e.height}: a negative size cannot be drawn`):!s(t)&&e.width===0&&e.height===0&&i(`warning`,[t.id],`shape ${md(t)} is 0 × 0, so nothing of it shows`,yd.shapes)}}let c=e.cells.filter(e=>e.vertex&&e.id!==void 0&&e.geometry!==void 0&&e.geometry.unreadable.length===0&&!s(e)&&e.geometry.width>0&&e.geometry.height>0),l=new Set(c.filter(e=>c.some(t=>t.parent===e.id)).map(e=>e.id)),u=new Map;for(let e of c){let t=e.parent??``;u.set(t,[...u.get(t)??[],e])}for(let e of u.values()){let t=e.filter(vd);for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){let[r,a]=[t[e],t[n]],o=Math.min(r.geometry.width*r.geometry.height,a.geometry.width*a.geometry.height);hd(r.geometry,a.geometry)>_d*o&&!gd(r.geometry,a.geometry)&&!gd(a.geometry,r.geometry)&&i(`warning`,[r.id,a.id],`shapes ${md(r)} and ${md(a)} overlap`,yd.shapes)}}for(let e of c){let t=e.parent===void 0?void 0:a.get(e.parent);t!==void 0&&t.vertex&&l.has(t.id??``)&&t.geometry!==void 0&&(t.style.split(`;`)[0]===`group`||/(^|;)rotation=(?!0(;|$))/.test(t.style)||gd({...t.geometry,x:0,y:0},e.geometry)||i(`warning`,[e.id,t.id??``],`shape ${md(e)} lies partly outside its container ${md(t)}`,yd.shapes))}Cd(e,a,l,i);let d=t.splice(n),f=e=>e.severity===`error`?-1:r.get(e)??-1;t.push(...d.map((e,t)=>({issue:e,index:t})).sort((e,t)=>f(e.issue)-f(t.issue)||e.index-t.index).map(({issue:e})=>e))}var xd=2,Sd=.3;function Cd(e,t,n,r){let i=Cu(e),a=[...i.terminals.entries()].flatMap(([e,r])=>{let i=t.get(e);return i!==void 0&&vd(i)&&!n.has(e)&&r.box.width>0&&r.box.height>0?[{id:e,cell:i,box:r.box,outline:Eu(r.style)}]:[]}),o=e=>{let n=new Set;for(let r=e===void 0?void 0:t.get(e);r?.parent!==void 0&&!n.has(r.parent);r=t.get(r.parent))n.add(r.parent);return n},s=(e,t,n)=>e.some((r,i)=>i>0&&Du(e[i-1],r,t,n,xd)>0),c=[],l=[],u=new Map,d=new Map,f=[];for(let n of e.cells){if(!n.edge||n.id===void 0)continue;let p=wu(n,i);if(p===void 0)continue;c.push(Au({...n,id:n.id},e.cells,p.points,i.origins.get(n.id)??void 0)),u.set(n.id,p);let m=new Set([n.source,n.target].filter(e=>e!==void 0)),h=new Set([...o(n.source),...o(n.target),...o(n.id)]);for(let e of a)m.has(e.id)||h.has(e.id)||s(p.points,e.box,e.outline)&&r(`warning`,[n.id,e.id],`connector ${md(n)} runs through shape ${md(e.cell)}: move the shape off its path, give the connector a waypoint that goes around it (<Array as="points"><mxPoint x="…" y="…"/></Array> in its geometry), or fix its exit and entry on other sides (exitX/exitY, entryX/entryY)`,yd.crossings);let g=n.source===void 0?void 0:i.terminals.get(n.source),_=n.target===void 0?void 0:i.terminals.get(n.target);if(g!==void 0&&_!==void 0&&Ou(g.box,_.box)===0){let e=[[`source`,n.source,g,_,`exit`],[`target`,n.target,_,g,`entry`]].filter(([,e,n])=>t.get(e)!==void 0&&s(p.points,n.box,Eu(n.style)));if(e.length>0){let t=(n.geometry?.points.length??0)>0,r=e=>RegExp(`(?:^|;)${e}X=`).test(n.style)&&RegExp(`(?:^|;)${e}Y=`).test(n.style);d.set(n.id,e.map(([,,,,e])=>e).filter(e=>!t||r(e))),f.push({edge:{...n,id:n.id},own:e.map(([e,t,,,n])=>({role:e,id:t,prefix:n})),waypoints:t})}}let v=[];if(n.label!==``&&n.geometry!==void 0){let e=n.geometry.relative?{x:n.geometry.x,y:n.geometry.y}:{x:0,y:0};v.push({text:n.label,centre:Tu(p,e,n.geometry.offset),style:n.style,holder:n.id,along:e,...n.geometry.offset?{offset:n.geometry.offset}:{}})}for(let t of e.cells){if(t.parent!==n.id||t.label===``||t.geometry===void 0||!t.geometry.relative||t.id===void 0)continue;let e={x:t.geometry.x,y:t.geometry.y};v.push({text:t.label,centre:Tu(p,e,t.geometry.offset),style:t.style,holder:t.id,along:e,...t.geometry.offset?{offset:t.geometry.offset}:{}})}for(let e of v){let t=Number(/(?:^|;)fontSize=([\d.]+)/.exec(e.style)?.[1]??11)||11,i=ku(e.centre,e.text,t);l.push({wire:n.id,holder:e.holder,text:e.text,fontSize:t,along:e.along,...e.offset?{offset:e.offset}:{},box:i,around:h});for(let t of a)h.has(t.id)||Ou(i,t.box)>Sd*i.width*i.height&&r(`warning`,[n.id,t.id],`the label "${e.text.length>40?`${e.text.slice(0,39)}…`:e.text}" of connector ${md(n)} sits on shape ${md(t.cell)}: move the label along the connector (its mxGeometry x, from -1 at the source to 1 at the target) or beside it (y), or move the shape`,yd.labels)}}let p=e=>{let n=t.get(e);return n===void 0?`"${e}"`:md(n)},m=new Map([...i.terminals].map(([e,t])=>[e,t.box])),h=Xu(c,m,d);for(let{edge:e,own:n,waypoints:i}of f){let a=n.map(({role:e,id:n})=>`its ${e} ${md(t.get(n))}`).join(` and `),o=n.flatMap(({prefix:t})=>h.get(`${e.id}:${t}`)??[]).join(`;`),s=`remove its waypoints (the <Array as="points"> in its geometry) to let draw.io route it, or move the first and last of them off those shapes`,c=i&&o===``?`connector ${md(e)} runs through ${a}: its waypoints take it back across them. Fix it: ${s}`:i?`connector ${md(e)} runs through ${a}: its exit or entry is on a side facing away from the other end, and it has waypoints. Put them on the sides facing each other (${o}), and ${s}`:`connector ${md(e)} runs through ${a}: its exit or entry is on a side facing away from the other end. Put them on the sides facing each other (${o}), or drop exitX/exitY and entryX/entryY to let draw.io choose`;r(`warning`,[e.id,...n.map(({id:e})=>e)],c,yd.ends)}let g={"shared-point":yd.sharedPoints,"facing-away":yd.ends,detour:yd.detours,"needless-bend":yd.detours},_=(e,n,r={})=>{let a=t.get(e.id),o=i.origins.get(e.id);if(a?.geometry===void 0||o==null)return;let s=a.style;for(let[e,t]of Object.entries(r)){let n=Number.isNaN(t)?[e,e.replace(/X$/,`Y`)]:[e];for(let e of n)s=s.replace(RegExp(`(^|;)${e}=[^;]*`),`$1`);Number.isNaN(t)||(s=`${s}${s.endsWith(`;`)?``:`;`}${e}=${t};`)}return wu({...a,style:s,geometry:{...a.geometry,points:n.map(e=>({x:e.x-o.x,y:e.y-o.y}))}},i)?.points},v=new Set(d.keys());for(let e of $u(c,m,p,d,_)){r(`warning`,[...e.wires,...e.shapes],e.message,g[e.rule]);for(let t of e.wires)v.add(t)}Od(l,u,c,a,p,r,_,s,v)}var wd=[0,-.3,.3,-.6,.6,-.8,.8],Td=[-14,14,-28,28],Ed=[10,-10,20,-20,30,-30,40,-40],Dd=e=>e.length>40?`${e.slice(0,39)}…`:e;function Od(e,t,n,r,i,a,o,s,c){let l=(e,t)=>Ou(e,t)>Sd*Math.min(e.width*e.height,t.width*t.height),u=(e,t)=>t.points.reduce((n,r,i)=>i===0?0:n+Du(t.points[i-1],r,e,`box`,0),0),d=(n,i)=>e.every(e=>e===n||!l(i,e.box))&&r.every(e=>n.around.has(e.id)||Ou(i,e.box)<=Sd*i.width*i.height)&&[...t].every(([e,t])=>e===n.wire||u(i,t)<4),f=e=>{let n=t.get(e.wire);if(n===void 0)return;let r=[e.along.x,...wd.filter(t=>Math.abs(t-e.along.x)>.05).sort((t,n)=>Math.abs(t-e.along.x)-Math.abs(n-e.along.x))];for(let t of[e.along.y,...Td.map(t=>e.along.y+t)])for(let i of r)if((i!==e.along.x||t!==e.along.y)&&d(e,ku(Tu(n,{x:i,y:t},e.offset),e.text,e.fontSize)))return{x:i,y:t}},p=e=>{let t=f(e);if(t===void 0)return`move the shapes so the connectors part, or shorten the label`;let n=t.y===e.along.y?``:` y="${t.y}"`;return`move it ${n===``?`along`:`beside`} its connector: set x="${t.x}"${n} in the mxGeometry of ${i(e.holder)}`},m=new Set;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){let r=e[t],o=e[n];r.wire===o.wire||m.has(r)||m.has(o)||c.has(r.wire)||c.has(o.wire)||!l(r.box,o.box)||(m.add(o),a(`warning`,[o.wire,r.wire],`the label "${Dd(o.text)}" of connector ${i(o.wire)} lies on the label "${Dd(r.text)}" of connector ${i(r.wire)}: ${p(o)}`,yd.labels))}for(let n of e)if(!(m.has(n)||c.has(n.wire))){for(let[e,r]of t)if(!(e===n.wire||c.has(e)||u(n.box,r)<4)){m.add(n),a(`warning`,[n.wire,e],`the label "${Dd(n.text)}" of connector ${i(n.wire)} lies across connector ${i(e)}: ${p(n)}`,yd.labels);break}}let h=e=>e.replace(/\s+/g,` `).trim().toLowerCase(),g=(e,t)=>{let n=0,r,i;for(let a=1;a<e.length;a++)for(let o=1;o<t.length;o++){let[s,c,l,u]=[e[a-1],e[a],t[o-1],t[o]],d=Math.abs(s.x-c.x)<.5&&Math.abs(l.x-u.x)<.5&&Math.abs(s.x-l.x)<8,f=Math.abs(s.y-c.y)<.5&&Math.abs(l.y-u.y)<.5&&Math.abs(s.y-l.y)<8;if(!d&&!f)continue;let[p,m]=d?[Math.max(Math.min(s.y,c.y),Math.min(l.y,u.y)),Math.min(Math.max(s.y,c.y),Math.max(l.y,u.y))]:[Math.max(Math.min(s.x,c.x),Math.min(l.x,u.x)),Math.min(Math.max(s.x,c.x),Math.max(l.x,u.x))];m-p<=0||(n+=m-p,r===void 0&&(r=d?{x:s.x,y:p}:{x:p,y:s.y},i=d?{x:s.x,y:m}:{x:m,y:s.y}))}return{total:n,from:r,to:i}},_=new Set,v=new Map,y=e=>v.get(e.id)??e.points;for(let e=0;e<n.length;e++)for(let t=e+1;t<n.length;t++){let l=n[e],u=n[t];if(h(l.label)!==``&&h(l.label)===h(u.label)||_.has(u.id)||c.has(l.id)||c.has(u.id))continue;let d=g(l.points,u.points);if(d.total<12||d.from===void 0||d.to===void 0)continue;_.add(u.id);let f=Math.abs(d.from.x-d.to.x)<.5,p={x:(d.from.x+d.to.x)/2,y:(d.from.y+d.to.y)/2},m=(e,t)=>f?{x:e.x+t,y:e.y}:{x:e.x,y:e.y+t},b=e=>`(${Math.round(e.x)}, ${Math.round(e.y)})`,x=e=>{let t,i=S(e,(i,a)=>{let c=o(e,i,a);if(c===void 0||Qu(c,i)!==void 0||r.some(e=>s(c,e.box,e.outline)))return!1;let l=t=>h(t.label)!==``&&h(t.label)===h(e.label);return n.every(t=>t===e||l(t)||g(y(t),c).total<12)?(t=c,!0):!1});if(i!==void 0&&t!==void 0)return v.set(e.id,t),{wire:e,fix:i}},S=(e,t)=>{for(let n of Ed){for(let r of e.waypoints){let i=m(r,n);if(t(e.waypoints.map(e=>e===r?i:e)))return`move its waypoint at ${b(r)} to ${b(i)}`}if(e.waypoints.length>1){let r=e.waypoints.map(e=>m(e,n));if(t(r))return`move its waypoints to ${r.map(b).join(`, `)}`}if(e.waypoints.length===0){let r=e.points.slice(1,-1).map(e=>m(e,n));if(r.length>0&&t(r))return`add waypoints at ${r.map(b).join(`, `)}: <Array as="points">${r.map(e=>`<mxPoint x="${Math.round(e.x)}" y="${Math.round(e.y)}"/>`).join(``)}</Array> in its geometry`;let i=m(p,n);if(t([i]))return`add a waypoint at ${b(i)}: <Array as="points"><mxPoint x="${Math.round(i.x)}" y="${Math.round(i.y)}"/></Array> in its geometry`}}for(let n of[`exit`,`entry`]){let r=n===`exit`?e.exit:e.entry;if(r===void 0)continue;let i=r.x===0||r.x===1?{axis:`Y`,along:r.y,keep:`${n}X=${r.x}`}:{axis:`X`,along:r.x,keep:`${n}Y=${r.y}`};for(let r of[.25,.75,.125,.375,.625,.875,.5])if(!(Math.abs(r-i.along)<.06)&&t(e.waypoints,{[`${n}${i.axis}`]:r}))return`move its ${n} to ${n}${i.axis}=${r} (keeping ${i.keep})`}},C=x(u)??x(l),w=C?.fix,T=C?.wire??u,E=h(l.label)===``||h(u.label)===``?`they are not labelled as the same data`:`they carry different data`;a(`warning`,[u.id,l.id],`connectors ${i(l.id)} and ${i(u.id)} run along the same line for ${Math.round(d.total)} units from (${Math.round(d.from.x)}, ${Math.round(d.from.y)}), and ${E}: a reader cannot tell them apart. Fix ${i(T.id)}: ${w??`give it another exit or entry point (exitX/exitY, entryX/entryY), or move a shape so their routes part`}`,yd.crossings)}}function kd(e,t){return Ad(pd(e,t))}function Ad(e){let t=[];for(let n of e)bd(n,t);return{pages:e.map(e=>({name:e.name,shapes:e.cells.filter(e=>e.vertex).length,connectors:e.cells.filter(e=>e.edge).length})),issues:t}}var jd=`(?:(?!</mxCell>)[\\s\\S])*?`;function Md(e,t,n){let r=RegExp(`(^|;)${t}=[^;]*`);return r.test(e)?e.replace(r,`$1${t}=${n}`):`${e}${e.endsWith(`;`)||e===``?``:`;`}${t}=${n};`}function Nd(e){let t=new Map,n=(e,n)=>{let r=t.get(e)??{},i=new Set(Object.keys(r));for(let e of n.split(`;`)){let[t,n]=e.split(`=`);t&&n&&!i.has(t)&&(r[t]=n)}t.set(e,r)};for(let t of e){for(let e of t.matchAll(/((?:exit|entry)[XY]=[\d.]+;(?:exit|entry)[XY]=[\d.]+) for "([^"]+)"/g))n(e[2],e[1]);let e=/^connector "([^"]+)".*Fix it: put its (?:entry|exit) level with its (?:exit|entry): ((?:exit|entry)[XY]=[\d.]+)/.exec(t);e&&n(e[1],e[2]);let r=/^connector "([^"]+)".*fix its exit and entry on those sides \(((?:(?:exit|entry)[XY]=[\d.]+;?)+)\)/.exec(t);r&&n(r[1],r[2]);let i=/Fix "([^"]{1,200})"(?: \([^)]{0,80}\))?: move its (?:exit|entry) to ((?:exit|entry)[XY]=[\d.]+) \(keeping ((?:exit|entry)[XY]=[\d.]+)\)/.exec(t);i&&n(i[1],`${i[2]};${i[3]}`);let a=/^connector "([^"]+)".*Fix it: drop exitX\/exitY and entryX\/entryY to let draw\.io choose where/.exec(t);a&&n(a[1],`exitX=none;exitY=none;entryX=none;entryY=none`);let o=/^connector "([^"]+)".*?(?:sides facing each other|side facing it) \(((?:(?:exit|entry)[XY]=[\d.]+;?)+)\)/.exec(t);o&&n(o[1],o[2])}return t}function Pd(e){return e.flatMap(e=>{let t=/Fix "([^"]{1,200})"(?: \([^)]{0,80}\))?: (?:move its waypoints to|add waypoints at) ((?:\(-?\d+, -?\d+\)(?:, )?)+)/.exec(e);return t?[{wire:t[1],points:[...t[2].matchAll(/\((-?\d+), (-?\d+)\)/g)].map(e=>({x:Number(e[1]),y:Number(e[2])}))}]:[]})}function Fd(e,t){let n=e;for(let e of t){let t=e.wire.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=e.points.map(e=>`<mxPoint x="${e.x}" y="${e.y}"/>`).join(``),i=RegExp(`(<mxCell\\b[^>]*\\bid="${t}"[^>]*>\\s*<mxGeometry\\b[^>]*[^/]>${jd}<Array as="points">)[\\s\\S]*?(</Array>)`);n=i.test(n)?n.replace(i,(e,t,n)=>`${t}${r}${n}`):Bd(n,e.wire,r)}return n}function Id(e){return e.flatMap(e=>{let t=/Fix "([^"]{1,200})"(?: \([^)]{0,80}\))?: move its waypoint at/.exec(e)?.[1]??/^connector "([^"]+)"/.exec(e)?.[1];if(t===void 0)return[];let n=/(?:Fix it|Fix "[^"]{1,200}"(?: \([^)]{0,80}\))?): move its waypoint at \((-?\d+), (-?\d+)\) to \((-?\d+), (-?\d+)\)/.exec(e);if(n)return[{wire:t,from:{x:Number(n[1]),y:Number(n[2])},to:{x:Number(n[3]),y:Number(n[4])}}];let r=/Fix it: remove its waypoint at \((-?\d+), (-?\d+)\)/.exec(e);return r?[{wire:t,from:{x:Number(r[1]),y:Number(r[2])},to:null}]:[]})}function Ld(e,t){let n=e;for(let e of t){let t=e.wire.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n=n.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${t}"${jd}<Array as="points">)([\\s\\S]*?)(</Array>)`),(t,n,r,i)=>{let a=r.match(/<mxPoint\b[^>]*\/>/g)?.find(t=>{let n=Number(/\bx="([^"]*)"/.exec(t)?.[1]??0),r=Number(/\by="([^"]*)"/.exec(t)?.[1]??0);return Math.abs(n-e.from.x)<=1&&Math.abs(r-e.from.y)<=1});if(a===void 0)return`${n}${r}${i}`;let o=e.to===null?``:`<mxPoint x="${e.to.x}" y="${e.to.y}"/>`;return`${n}${r.replace(a,o)}${i}`})}return n}function Rd(e){return e.flatMap(e=>{let t=/set x="(-?[\d.]+)"(?: y="(-?[\d.]+)")? in the mxGeometry of "([^"]+)"/.exec(e);return t?[{cell:t[3],x:t[1],...t[2]===void 0?{}:{y:t[2]}}]:[]})}function zd(e,t){let n=e;for(let e of t){let t=e.cell.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n=n.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${t}"[^>]*>\\s*<mxGeometry\\b)([^>]*?)(/?>)`),(t,n,r,i)=>{let a=(e,t,n)=>RegExp(`\\b${t}="[^"]*"`).test(e)?e.replace(RegExp(`\\b${t}="[^"]*"`),`${t}="${n}"`):`${e} ${t}="${n}"`,o=a(r,`x`,e.x);return e.y!==void 0&&(o=a(o,`y`,e.y)),`${n}${o}${i}`})}return n}function Bd(e,t,n){let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return e.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${r}"[^>]*>\\s*<mxGeometry\\b[^>]*?)(/>|>)`),(e,t,r)=>r===`/>`?`${t}><Array as="points">${n}</Array></mxGeometry>`:`${t}><Array as="points">${n}</Array>`)}function Vd(e){return e.flatMap(e=>{let t=/Fix "([^"]{1,200})"(?: \([^)]{0,80}\))?: add a waypoint at \((-?\d+), (-?\d+)\)/.exec(e);return t?[{wire:t[1],at:{x:Number(t[2]),y:Number(t[3])}}]:[]})}function Hd(e,t){let n=e;for(let e of t){let t=e.wire.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=`<Array as="points"><mxPoint x="${e.at.x}" y="${e.at.y}"/></Array>`;n=n.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${t}"[^>]*>\\s*<mxGeometry\\b[^>]*?)(/>|>)`),(e,t,n)=>n===`/>`?`${t}>${r}</mxGeometry>`:`${t}>${r}`)}return n}function Ud(e){return e.flatMap(e=>{let t=/Fix it: line up the shapes it joins, whose middles are \d+ units apart: move "([^"]{1,200})"(?: \([^)]{0,80}\))? by ([+-]?\d+) on (x|y)/.exec(e);return t?[{shape:t[1],by:Number(t[2]),axis:t[3]}]:[]})}function Wd(e,t){let n=e;for(let e of t){let t=e.shape.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n=n.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${t}"[^>]*>\\s*<mxGeometry\\b[^>]*?\\b${e.axis}=")(-?[\\d.]+)`),(t,n,r)=>`${n}${Number(r)+e.by}`)}return n}function Gd(e){return new Set(e.flatMap(e=>{let t=/^connector "([^"]+)".*(?:Fix it: remove its waypoints|and remove its waypoints)/.exec(e);return t?[t[1]]:[]}))}function Kd(e,t){let n=e;for(let e of t){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n=n.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${t}"${jd})<Array as="points">[\\s\\S]*?</Array>`),`$1`)}return n}function qd(e,t){return e.replace(/<mxCell\b[^>]*>/g,e=>{let n=/\bid="([^"]*)"/.exec(e)?.[1],r=n===void 0?void 0:t.get(n);return r?e.replace(/\bstyle="([^"]*)"/,(e,t)=>{let n=t;for(let[e,t]of Object.entries(r))n=Md(n,e,t);return`style="${n}"`}):e})}var Jd=/at the same point|facing away|runs .* units to join|runs through its (source|target)|needless bend|lies on the label|lies across connector|run along the same line/;function Yd(e,t=12,n,r={}){let i=e,a=new Set,o=r.only??(()=>!0);for(let e=0;;e++){let s=kd(i).issues.map(e=>e.message),c=s.filter(e=>Jd.test(e));n?.(e,c);let l=new Map([...Nd(s)].filter(([e])=>o(e))),u=Id(s).filter(e=>o(e.wire)),d=new Set([...Gd(s)].filter(o)),f=r.moveShapes===!1?[]:Ud(s).filter(e=>o(e.shape)),p=Rd(s).filter(e=>o(e.cell)),m=Vd(s).filter(e=>o(e.wire)),h=Pd(s).filter(e=>o(e.wire));if(l.size===0&&d.size===0&&u.length===0&&f.length===0&&p.length===0&&m.length===0&&h.length===0)return{rounds:e,converged:c.length===0,looped:!1,left:c,xml:i};let g=Fd(Hd(zd(Wd(Ld(Kd(qd(i,l),d),u),f),p),m),h);if(g===i||a.has(g)||e>=t)return{rounds:e,converged:!1,looped:!0,left:c,xml:i};a.add(i),i=g}}var Xd=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/\n/g,`&#10;`),Zd=(e,t)=>t===void 0?``:` ${e}="${Xd(t)}"`;function Qd(e){let t=[`x`,`y`,`width`,`height`].map(t=>e[t]===0?``:` ${t}="${e[t]}"`).join(``),n=[e.points.length===0?``:`<Array as="points">${e.points.map(e=>`<mxPoint x="${e.x}" y="${e.y}"/>`).join(``)}</Array>`,e.offset===void 0?``:`<mxPoint x="${e.offset.x}" y="${e.offset.y}" as="offset"/>`].join(``),r=`<mxGeometry${t}${e.relative?` relative="1"`:``} as="geometry"`;return n===``?`${r}/>`:`${r}>${n}</mxGeometry>`}function $d(e){let t=`${e.vertex?` vertex="1"`:``}${e.edge?` edge="1"`:``}`,n=`<mxCell${Zd(`id`,e.id)}${Zd(`value`,e.label===``?void 0:e.label)}${Zd(`style`,e.style===``?void 0:e.style)}${t}${Zd(`parent`,e.parent)}${Zd(`source`,e.source)}${Zd(`target`,e.target)}`;return e.geometry===void 0?`${n}/>`:`${n}>${Qd(e.geometry)}</mxCell>`}function ef(e){return[`<mxfile host="pi-outpost">`,`<diagram${Zd(`name`,e.name)}>`,`<mxGraphModel><root>`,...e.cells.map($d),`</root></mxGraphModel>`,`</diagram>`,`</mxfile>`,``].join(`
8
+ `)}}function $c(e){return`n${[...e].map(e=>e.charCodeAt(0).toString(36)).join(``)}`}var el={"#":`#35;`,'"':`#quot;`,";":`#59;`,"<":`#60;`,">":`#62;`};function tl(e){return e.replace(/[#";<>]/g,e=>el[e]).replace(/[\r\n\t\f\v\u0000-\u001f\u2028\u2029]+/g,` `)}function nl(e,t){return`${e}:${t}`}var rl=new Set;function il(e,t,n){return n===void 0||n===``?!1:e.has(nl(t,n))}function al(e){let t=e?.viewpoints;return Array.isArray(t)?t:[]}function ol(e,t){let n=new Set,r=(e,t,r)=>{if(t===void 0)return;let i=new Set(t);for(let t of e)t.kind!==void 0&&t.kind!==``&&!i.has(t.kind)&&n.add(nl(r,t.kind))};return r(e.nodes,t.elementKinds,`element`),r(e.edges,t.relationshipKinds,`relationship`),n}function sl(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var cl=40,ll=22;function ul(e){let t=e.containers??[],n;if(t.length===0)n=e.participants;else{let r=new Set(t.map(e=>e.id)),i=new Set;n=[];for(let t of e.participants){if(i.has(t.id))continue;let a=t.container;if(a===void 0||!r.has(a))n.push(t),i.add(t.id);else for(let t of e.participants)t.container!==a||i.has(t.id)||(n.push(t),i.add(t.id))}}let r=[];n.forEach((e,n)=>{let i=t.find(t=>t.id===e.container);if(i===void 0)return;let a=r.at(-1);a!==void 0&&a.container.id===i.id&&a.to===n-1?a.to=n:r.push({container:i,from:n,to:n})});let i=t.length>0?ll:0,a=new Map(n.map((e,t)=>[e.id,t])),o=Math.max(...e.participants.map(e=>Ee([Zc(e)],jc(e),110,240)),Te(e.messages.map(e=>e.label??``),110,240)*.8),s=o-14,c=e.participants.reduce((e,t)=>Math.max(e,Oe(De(Zc(t),s).length,ke(jc(t),s).length)),Oe(1,0))+8;return{columns:n,bands:r,bandHeight:i,lifelineX:o,boxW:s,headerHeight:c,messageGap:cl,width:Math.max(e.participants.length*o,240),height:i+c+(e.messages.length+1)*cl,xOf:e=>(a.get(e)??0)*o+o/2}}function dl(e,t){let n=[Zc(e)];t!==`unchanged`&&n.push(`(${Mc[t]})`),e.ref!==void 0&&n.push(`[${e.ref}]`);for(let t of jc(e))n.push(Ae(t));return n.join(` `)}function fl(e,t){let n=t.cx-e.cx,r=t.cy-e.cy;if(n===0&&r===0)return{x:e.cx,y:e.cy};let i=Math.min(n===0?1/0:e.w/2/Math.abs(n),r===0?1/0:e.h/2/Math.abs(r));return{x:e.cx+n*i,y:e.cy+r*i}}function pl(e,t){if(e.length<3)return e.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `);let n=[`M ${e[0].x} ${e[0].y}`];for(let r=1;r<e.length-1;r++){let i=e[r-1],a=e[r],o=e[r+1],s=Math.hypot(a.x-i.x,a.y-i.y),c=Math.hypot(o.x-a.x,o.y-a.y);if(s===0||c===0)continue;let l=((a.x-i.x)*(o.y-a.y)-(a.y-i.y)*(o.x-a.x))/(s*c);if(Math.abs(l)<.02)continue;let u=Math.min(t,s/2,c/2),d={x:a.x-(a.x-i.x)/s*u,y:a.y-(a.y-i.y)/s*u},f={x:a.x+(o.x-a.x)/c*u,y:a.y+(o.y-a.y)/c*u};n.push(`L ${d.x} ${d.y}`,`Q ${a.x} ${a.y} ${f.x} ${f.y}`)}let r=e[e.length-1];return n.push(`L ${r.x} ${r.y}`),n.join(` `)}function ml(e,t,n,r,i){if(e===t){let t=26+r*12,n=e.cx-e.w/4,i=e.cx+e.w/4,a=e.y;return{d:`M ${n} ${a} C ${n} ${a-t}, ${i} ${a-t}, ${i} ${a}`,labelAt:{x:e.cx,y:a-t*.75},span:t*2}}let a=fl(e,t),o=fl(t,e),s=Math.hypot(o.x-a.x,o.y-a.y),c=(n??[]).slice(1,-1),l=i===void 0?c:c.map((e,t)=>{let n=c.length===1?.5:t/(c.length-1);return{x:e.x+i.from.dx*(1-n)+i.to.dx*n,y:e.y+i.from.dy*(1-n)+i.to.dy*n}});if(l.length>0&&r===0){let e=l[Math.floor((l.length-1)/2)];return{d:pl([a,...l,o],12),labelAt:e,span:s}}let u=r===0?0:Math.ceil(r/2)*22*(r%2==1?1:-1),d=(a.x+o.x)/2,f=(a.y+o.y)/2;if(u===0)return{d:`M ${a.x} ${a.y} L ${o.x} ${o.y}`,labelAt:{x:d,y:f},span:s};let p=s===0?0:-(o.y-a.y)/s,m=s===0?0:(o.x-a.x)/s,h=d+p*u*2,g=f+m*u*2;return{d:`M ${a.x} ${a.y} Q ${h} ${g} ${o.x} ${o.y}`,labelAt:{x:d+p*u,y:f+m*u},span:s}}function hl(e){let t=(e.match(/-?\d+(?:\.\d+)?/g)??[]).map(Number);if(t.length<2)return;let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let e=0;e+1<t.length;e+=2)n=Math.min(n,t[e]),i=Math.max(i,t[e]),r=Math.min(r,t[e+1]),a=Math.max(a,t[e+1]);return{minX:n,minY:r,maxX:i,maxY:a}}function gl(e,t,n,r){let i=t=>{let n=e.participants.find(e=>e.id===t);return n===void 0?t:Zc(n)},a=t.label===void 0||t.label===``?``:`: ${t.label}`;return[`${n+1}.`,`${i(t.from)} → ${i(t.to)}${a}`,t.from===t.to?`(to itself)`:``,r===`unchanged`?``:`[${Mc[r]}]`,jc(t).map(Ae).join(`, `)].filter(e=>e!==``).join(` `)}function _l(e,t,n){let r=t=>{let n=e.nodes.find(e=>e.id===t);return n===void 0?t:Zc(n)},i=t.label??t.kind;return[`${r(t.from)} → ${r(t.to)}`,i===void 0?``:`(${i})`,n===`unchanged`?``:`[${Mc[n]}]`,jc(t).map(Ae).join(`, `)].filter(e=>e!==``).join(` `)}function vl(e){if(e===void 0||e===``)return;let t=It(e,Vi);return t.valid?{valid:!0,envelope:t.envelope,issues:[]}:t}function yl(e){let t=vl(e);return t?.valid===!0?t.envelope:void 0}function bl(e){return Rt(e,Vi)}var xl=`pi-outpost/structured-exchange-arrangement-1`,Sl=()=>({format:xl,views:{}}),Cl=()=>({elements:{},relationships:{}});function wl(e){return/\.json$/i.test(e)?e.replace(/\.json$/i,`.arrangement.json`):`${e}.arrangement.json`}var Tl=e=>e.replace(/[%>#[\]\s]/g,e=>`%${e.charCodeAt(0).toString(16).padStart(2,`0`).toUpperCase()}`);function El(e){return e.ref===void 0?`id:${Tl(e.id)}`:`ref:${Tl(e.ref)}`}function Dl(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Map;return e.edges.map(e=>{if(e.ref!==void 0)return`ref:${Tl(e.ref)}`;let r=t.get(e.from),i=t.get(e.to),a=`${r===void 0?`id:${Tl(e.from)}`:El(r)}>${i===void 0?`id:${Tl(e.to)}`:El(i)}[${Tl(e.kind??``)}]`,o=n.get(a)??0;return n.set(a,o+1),`${a}#${o}`})}var Ol=e=>typeof e==`object`&&!!e&&!Array.isArray(e),kl=e=>Ol(e)&&Number.isFinite(e.x)&&Number.isFinite(e.y);function Al(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,reason:`it is not parseable JSON`}}if(!Ol(t)||t.format!==`pi-outpost/structured-exchange-arrangement-1`)return{ok:!1,reason:`it does not declare "format": "${xl}"`};if(!Ol(t.views))return{ok:!1,reason:`it has no views`};let n={};for(let[e,r]of Object.entries(t.views)){if(!Ol(r))return{ok:!1,reason:`view "${e}" is not an object`};let t=Cl();if(r.orientation!==void 0){if(r.orientation!==`landscape`&&r.orientation!==`portrait`)return{ok:!1,reason:`view "${e}" has an unknown orientation`};t.orientation=r.orientation}if(!Ol(r.elements))return{ok:!1,reason:`view "${e}" has no elements`};if(!Ol(r.relationships))return{ok:!1,reason:`view "${e}" has no relationships`};for(let[n,i]of Object.entries(r.elements)){if(!kl(i))return{ok:!1,reason:`element "${n}" of view "${e}" has no x and y`};t.elements[n]={x:i.x,y:i.y}}for(let[n,i]of Object.entries(r.relationships)){if(!Ol(i))return{ok:!1,reason:`relationship "${n}" of view "${e}" is not an object`};let r={};for(let t of[`exit`,`entry`])if(i[t]!==void 0){if(!kl(i[t]))return{ok:!1,reason:`relationship "${n}" of view "${e}" has an unreadable ${t}`};r[t]={x:i[t].x,y:i[t].y}}if(i.waypoints!==void 0){if(!Array.isArray(i.waypoints)||!i.waypoints.every(kl))return{ok:!1,reason:`relationship "${n}" of view "${e}" has unreadable waypoints`};r.waypoints=i.waypoints.map(e=>({x:e.x,y:e.y}))}if(i.label!==void 0){let t=i.label;if(!Ol(t)||!Number.isFinite(t.along)||!kl(t.offset)||t.across!==void 0&&!Number.isFinite(t.across))return{ok:!1,reason:`relationship "${n}" of view "${e}" has an unreadable label`};r.label={along:t.along,...t.across===void 0?{}:{across:t.across},offset:{x:t.offset.x,y:t.offset.y}}}t.relationships[n]=r}n[e]=t}return{ok:!0,arrangement:{format:xl,views:n}}}var jl=e=>Math.round(e*1e4)/1e4,Ml=e=>Math.round(e/10)*10,Nl=e=>({x:Ml(e.x),y:Ml(e.y)});function Pl(e){let t={};return e.entry!==void 0&&(t.entry={x:jl(e.entry.x),y:jl(e.entry.y)}),e.exit!==void 0&&(t.exit={x:jl(e.exit.x),y:jl(e.exit.y)}),e.label!==void 0&&(t.label={...e.label.across===void 0||e.label.across===0?{}:{across:Math.round(e.label.across)},along:jl(e.label.along),offset:{x:Math.round(e.label.offset.x),y:Math.round(e.label.offset.y)}}),e.waypoints!==void 0&&e.waypoints.length>0&&(t.waypoints=e.waypoints.map(e=>({x:Math.round(e.x),y:Math.round(e.y)}))),t}var Fl=e=>Object.keys(e).sort().map(t=>[t,e[t]]);function Il(e){let t={};for(let[n,r]of Fl(e.views))t[n]={elements:Object.fromEntries(Fl(r.elements).map(([e,t])=>[e,Nl(t)])),...r.orientation===void 0?{}:{orientation:r.orientation},relationships:Object.fromEntries(Fl(r.relationships).map(([e,t])=>[e,Pl(t)]))};return`${JSON.stringify({format:xl,views:t},null,2).replace(/\{\n\s*"x": (-?[\d.]+),\n\s*"y": (-?[\d.]+)\n\s*\}/g,`{ "x": $1, "y": $2 }`)}\n`}var Ll={shape:`label`,perimeter:`rectanglePerimeter`},Rl={shape:`connector`,endArrow:`classic`,rounded:1},zl={ellipse:{shape:`ellipse`,perimeter:`ellipsePerimeter`},rhombus:{shape:`rhombus`,perimeter:`rhombusPerimeter`},triangle:{shape:`triangle`,perimeter:`trianglePerimeter`},line:{shape:`line`},image:{shape:`image`},roundImage:{shape:`image`,perimeter:`ellipsePerimeter`},rhombusImage:{shape:`image`,perimeter:`rhombusPerimeter`},arrow:{shape:`arrow`,edgeStyle:`none`},swimlane:{shape:`swimlane`}};function Bl(e,t){let n=e.startsWith(`;`)?{}:{...t?Rl:Ll};for(let t of e.split(`;`)){let e=t.indexOf(`=`);if(e>=0){let r=t.slice(0,e),i=t.slice(e+1);i===`none`?delete n[r]:n[r]=i.trim()!==``&&Number.isFinite(Number(i))?Number.parseFloat(i):i}else if(Object.hasOwn(zl,t))for(let[e,r]of Object.entries(zl[t]))r===`none`?delete n[e]:n[e]=r}return n}var Vl=(e,t,n)=>{let r=e[t],i=typeof r==`number`?r:Number.parseFloat(String(r??``));return Number.isFinite(i)?i:n},Hl=1,Ul=2,Wl=4,Gl=8,Kl=15,ql=6,Jl=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),Yl=e=>Math.round(e*10)/10,Xl=(e,t,n)=>t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height;function Zl(e){let{style:t}=e;if(Vl(t,`rotation`,0)%360!=0||t.direction!==void 0&&t.direction!==`east`||Vl(t,`flipH`,0)===1||Vl(t,`flipV`,0)===1)return!1;let n=String(t.shape??``);if(n.startsWith(`mxgraph.`)||n.startsWith(`stencil(`)||Vl(t,`roundedPerimeter`,0)===1&&Vl(t,`rounded`,0)===1||Vl(t,`labelPerimeter`,0)===1)return!1;let r=t.perimeter;return r===void 0||[`rectanglePerimeter`,`ellipsePerimeter`,`rhombusPerimeter`,`centerPerimeter`].includes(String(r))}function Ql(e,t,n,r,i,a,o,s){let c=(s-a)*(n-e)-(o-i)*(r-t),l=(o-i)*(t-a)-(s-a)*(e-i),u=(n-e)*(t-a)-(r-t)*(e-i),d=l/c,f=u/c;return d>=0&&d<=1&&f>=0&&f<=1?{x:e+d*(n-e),y:t+d*(r-t)}:null}function $l(e,t,n){let r=e.x+e.width/2,i=e.y+e.height/2,a=Math.atan2(t.y-i,t.x-r),o={x:0,y:0},s=Math.PI,c=s/2-a,l=Math.atan2(e.height,e.width);return a<-s+l||a>s-l?(o.x=e.x,o.y=i-e.width*Math.tan(a)/2):a<-l?(o.y=e.y,o.x=r-e.height*Math.tan(c)/2):a<l?(o.x=e.x+e.width,o.y=i+e.width*Math.tan(a)/2):(o.y=e.y+e.height,o.x=r+e.height*Math.tan(c)/2),n&&(t.x>=e.x&&t.x<=e.x+e.width?o.x=t.x:t.y>=e.y&&t.y<=e.y+e.height&&(o.y=t.y),t.x<e.x?o.x=e.x:t.x>e.x+e.width&&(o.x=e.x+e.width),t.y<e.y?o.y=e.y:t.y>e.y+e.height&&(o.y=e.y+e.height)),o}function eu(e,t,n){let{x:r,y:i}=e,a=e.width/2,o=e.height/2,s=r+a,c=i+o,l=t.x,u=t.y,d=Math.trunc(l-s),f=Math.trunc(u-c);if(d===0&&f!==0)return{x:s,y:c+o*f/Math.abs(f)};if(d===0&&f===0)return{x:l,y:u};if(n){if(u>=i&&u<=i+e.height){let e=u-c,t=Math.sqrt(a*a*(1-e*e/(o*o)))||0;return l<=r&&(t=-t),{x:s+t,y:u}}if(l>=r&&l<=r+e.width){let e=l-s,t=Math.sqrt(o*o*(1-e*e/(a*a)))||0;return u<=i&&(t=-t),{x:l,y:c+t}}}let p=a*o/Math.sqrt(o*o*d*d+a*a*f*f);return{x:s+p*d,y:c+p*f}}function tu(e,t,n){let{x:r,y:i}=e,a=e.width,o=e.height,s=r+a/2,c=i+o/2,l=t.x,u=t.y;if(s===l)return c>u?{x:s,y:i}:{x:s,y:i+o};if(c===u)return s>l?{x:r,y:c}:{x:r+a,y:c};let d=s,f=c;return n&&(l>=r&&l<=r+a?d=l:u>=i&&u<=i+o&&(f=u)),l<s?u<c?Ql(l,u,d,f,s,i,r,c):Ql(l,u,d,f,s,i+o,r,c):u<c?Ql(l,u,d,f,s,i,r+a,c):Ql(l,u,d,f,s,i+o,r+a,c)}function nu(e,t,n,r){let i=r+Vl(e.style,`perimeterSpacing`,0),a={x:e.box.x-i,y:e.box.y-i,width:e.box.width+2*i,height:e.box.height+2*i},o=e.style.perimeter,s=null;return o!==void 0&&(a.width>0||a.height>0)&&(o===`ellipsePerimeter`?s=eu(a,t,n):o===`rhombusPerimeter`?s=tu(a,t,n):o===`rectanglePerimeter`&&(s=$l(a,t,n))),s??Jl(e.box)}var ru=(e,t)=>({x:t.x+e.origin.x,y:t.y+e.origin.y});function iu(e){let t=(e&Hl)<<3;return t|=(e&Ul)<<1,t|=(e&Wl)>>1,t|=(e&Gl)>>3,t}function au(e,t,n){let r=e.style.portConstraint??t.style[n?`sourcePortConstraint`:`targetPortConstraint`];if(r===void 0)return Kl;let i=String(r),a=0;return i.includes(`north`)&&(a|=Ul),i.includes(`west`)&&(a|=Hl),i.includes(`south`)&&(a|=Wl),i.includes(`east`)&&(a|=Gl),a}var ou=10;function su(e,t){let n=e.style[t?`sourceJettySize`:`targetJettySize`]??e.style.jettySize??ou;if(n===`auto`){let n=e.style[t?`startArrow`:`endArrow`];if(n!==void 0&&n!==`none`){let n=Vl(e.style,t?`startSize`:`endSize`,ql);return Math.max(2,Math.ceil((n+ou)/ou))*ou}return 20}return typeof n==`number`?n:Number.parseFloat(String(n))}var cu=(e,t,n,r,i)=>{let a=e.absolutePoints.map(e=>e===null?null:{x:Yl(e.x),y:Yl(e.y)}),o=t?.box??null,s=n?.box??null,c=[],l=e=>c.push(e),u=i.length>0&&i[0]!=null?{x:i[0].x,y:i[0].y}:null,d=!0,f=null,p=e=>(e.x=Yl(e.x),e.y=Yl(e.y),(u===null||Math.abs(u.x-e.x)>=1||Math.abs(u.y-e.y)>=1)&&(i.push({x:e.x,y:e.y}),u=e),u),m=a[0]??null;m===null&&t!==null?m=Jl(t.box):m!==null&&(m={...m});let h=a.length-1,g;if(r!==null&&r.length>0){let i=r.map(t=>ru(e,t));if(i.length===0)return;m!==null&&i[0]!==void 0&&(Math.abs(i[0].x-m.x)<1&&(i[0].x=m.x),Math.abs(i[0].y-m.y)<1&&(i[0].y=m.y)),g=a[h],g!=null&&i[i.length-1]!==void 0&&(Math.abs(i[i.length-1].x-g.x)<1&&(i[i.length-1].x=g.x),Math.abs(i[i.length-1].y-g.y)<1&&(i[i.length-1].y=g.y)),f=i[0];let c=t,u=o,p=a[0],_=!1,v=!1,y=f;p!=null&&(c=null);for(let e=0;e<2;e++){let t=p!=null&&p.x===y.x,r=p!=null&&p.y===y.y,o=c!==null&&y.y>=u.y&&y.y<=u.y+u.height,l=c!==null&&y.x>=u.x&&y.x<=u.x+u.width;if(_=r||p==null&&o,v=t||p==null&&l,!(e===0&&(_&&v||t&&r))){if(p!=null&&!r&&!t&&(o||l)){d=!o;break}if(v||_){d=_,e===1&&(d=i.length%2==0?_:v);break}}c=n,u=s,p=a[h],p!=null&&(c=null),y=i[i.length-1],t&&r&&(i=i.slice(1))}d&&(a[0]!=null&&a[0].y!==f.y||a[0]==null&&t!==null&&(f.y<o.y||f.y>o.y+o.height))?l({x:m.x,y:f.y}):!d&&(a[0]!=null&&a[0].x!==f.x||a[0]==null&&t!==null&&(f.x<o.x||f.x>o.x+o.width))&&l({x:f.x,y:m.y}),d?m.y=f.y:m.x=f.x;for(let e of i)d=!d,f=e,d?m.y=f.y:m.x=f.x,l({...m})}else f=m,d=!0;if(m=a[h]??null,m===null&&n!==null&&(m=Jl(n.box)),m!==null&&f!==null&&(d&&(a[h]!=null&&a[h].y!==f.y||a[h]==null&&n!==null&&(f.y<s.y||f.y>s.y+s.height))?l({x:m.x,y:f.y}):!d&&(a[h]!=null&&a[h].x!==f.x||a[h]==null&&n!==null&&(f.x<s.x||f.x>s.x+s.width))&&l({x:f.x,y:m.y})),a[0]==null&&t!==null)for(;c.length>0&&Xl(o,c[0].x,c[0].y);)c.splice(0,1);if(a[h]==null&&n!==null)for(;c.length>0&&Xl(s,c[c.length-1].x,c[c.length-1].y);)c.splice(c.length-1,1);for(let e of c)p(e);let _=i[i.length-1];if(g!=null&&_!=null&&Math.abs(g.x-_.x)<=1&&Math.abs(g.y-_.y)<=1){i.splice(i.length-1,1);let e=i[i.length-1];e!=null&&(Math.abs(e.x-g.x)<1&&(e.x=g.x),Math.abs(e.y-g.y)<1&&(e.y=g.y))}},lu=[[-1,0],[0,-1],[1,0],[0,1],[-1,0],[0,-1],[1,0]],uu=[[[513,2308,2081,2562],[513,1090,514,2184,2114,2561],[513,1090,514,2564,2184,2562],[513,2308,2561,1090,514,2568,2308]],[[514,1057,513,2308,2081,2562],[514,2184,2114,2561],[514,2184,2562,1057,513,2564,2184],[514,1057,513,2568,2308,2561]],[[1090,514,1057,513,2308,2081,2562],[2114,2561],[1090,2562,1057,513,2564,2184],[1090,514,1057,513,2308,2561,2568]],[[2081,2562],[1057,513,1090,514,2184,2114,2561],[1057,513,1090,514,2184,2562,2564],[1057,2561,1090,514,2568,2308]]],du=1024,fu=2048,pu=480,mu=512,hu=(e,t,n,r,i)=>{let a=e.absolutePoints.map(e=>e===null?null:{x:Yl(e.x),y:Yl(e.y)}),o=t===null?null:{...t.box,x:Yl(t.box.x),y:Yl(t.box.y),width:Yl(t.box.width),height:Yl(t.box.height)},s=n===null?null:{...n.box,x:Yl(n.box.x),y:Yl(n.box.y),width:Yl(n.box.width),height:Yl(n.box.height)},c=a[0]??null,l=a[a.length-1]??null,u=o===null?c.x:o.x,d=o===null?c.y:o.y,f=o===null?1:o.width,p=o===null?1:o.height,m=s===null?l.x:s.x,h=s===null?l.y:s.y,g=s===null?1:s.width,_=s===null?1:s.height,v=su(e,!0),y=su(e,!1),b=y+v,x=!1;if(c!==null&&l!==null){let e=l.x-c.x,t=l.y-c.y;x=e*e+t*t<b*b}if(x||r!==null&&r.length>0){cu(e,t,n,r,i);return}let S=[Kl,Kl];if(t!==null&&(S[0]=au(t,e,!0)),n!==null&&(S[1]=au(n,e,!1)),f===0||p===0||g===0||_===0)return;let C=[0,0],w=[[u,d,f,p],[m,h,g,_]],T=[v,y],E=[[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];for(let e=0;e<2;e++)E[e][1]=w[e][0]-T[e],E[e][2]=w[e][1]-T[e],E[e][4]=w[e][0]+w[e][2]+T[e],E[e][8]=w[e][1]+w[e][3]+T[e];let ee=w[0][0]+w[0][2]/2,D=w[0][1]+w[0][3]/2,te=w[1][0]+w[1][2]/2,ne=w[1][1]+w[1][3]/2,re=ee-te,ie=D-ne,ae=0;re<0?ae=ie<0?2:1:ie<=0&&(ae=3,re===0&&(ae=2));let oe=t===null?null:c,se=[[.5,.5],[.5,.5]];t===null&&(se[0]=[0,0]),n===null&&(se[1]=[0,0]);for(let e=0;e<2;e++)oe!==null&&(se[e][0]=(oe.x-w[e][0])/w[e][2],Math.abs(oe.x-w[e][0])<=1?C[e]=Hl:Math.abs(oe.x-w[e][0]-w[e][2])<=1&&(C[e]=Gl),se[e][1]=(oe.y-w[e][1])/w[e][3],Math.abs(oe.y-w[e][1])<=1?C[e]=Ul:Math.abs(oe.y-w[e][1]-w[e][3])<=1&&(C[e]=Wl)),oe=n===null?null:l;let ce=w[0][1]-(w[1][1]+w[1][3]),le=w[0][0]-(w[1][0]+w[1][2]),ue=w[1][1]-(w[0][1]+w[0][3]),de=w[1][0]-(w[0][0]+w[0][2]),O=[];O[1]=Math.max(le-b,0),O[2]=Math.max(ce-b,0),O[4]=Math.max(ue-b,0),O[3]=Math.max(de-b,0);let fe=[],pe=[],me=[];pe[0]=le>=de?Hl:Gl,me[0]=ce>=ue?Ul:Wl,pe[1]=iu(pe[0]),me[1]=iu(me[0]);let he=le>=de?le:de,ge=ce>=ue?ce:ue,_e=[[0,0],[0,0]],ve=!1;for(let e=0;e<2;e++)C[e]===0&&((pe[e]&S[e])===0&&(pe[e]=iu(pe[e])),(me[e]&S[e])===0&&(me[e]=iu(me[e])),_e[e][0]=me[e],_e[e][1]=pe[e]);ge>0&&he>0&&((pe[0]&S[0])>0&&(me[1]&S[1])>0?(_e[0]=[pe[0],me[0]],_e[1]=[me[1],pe[1]],ve=!0):(me[0]&S[0])>0&&(pe[1]&S[1])>0&&(_e[0]=[me[0],pe[0]],_e[1]=[pe[1],me[1]],ve=!0)),ge>0&&!ve&&(_e[0]=[me[0],pe[0]],_e[1]=[me[1],pe[1]],ve=!0),he>0&&!ve&&(_e[0]=[pe[0],me[0]],_e[1]=[pe[1],me[1]]);for(let e=0;e<2;e++)C[e]===0&&((_e[e][0]&S[e])===0&&(_e[e][0]=_e[e][1]),fe[e]=_e[e][0]&S[e],fe[e]|=(_e[e][1]&S[e])<<8,fe[e]|=(_e[1-e][e]&S[e])<<16,fe[e]|=(_e[1-e][1-e]&S[e])<<24,fe[e]&15||(fe[e]=fe[e]<<8),fe[e]&3840||(fe[e]=fe[e]&15|fe[e]>>8),fe[e]&983040||(fe[e]=fe[e]&65535|(fe[e]&251658240)>>8),C[e]=fe[e]&15,(S[e]===Hl||S[e]===Ul||S[e]===Gl||S[e]===Wl)&&(C[e]=S[e]));let ye=C[0]===Gl?3:C[0],be=C[1]===Gl?3:C[1];ye-=ae,be-=ae,ye<1&&(ye+=4),be<1&&(be+=4);let xe=uu[ye-1][be-1],k=Array.from({length:12},()=>[0,0]);switch(k[0][0]=w[0][0],k[0][1]=w[0][1],C[0]){case Hl:k[0][0]-=v,k[0][1]+=se[0][1]*w[0][3];break;case Wl:k[0][0]+=se[0][0]*w[0][2],k[0][1]+=w[0][3]+v;break;case Gl:k[0][0]+=w[0][2]+v,k[0][1]+=se[0][1]*w[0][3];break;case Ul:k[0][0]+=se[0][0]*w[0][2],k[0][1]-=v}let A=0,Se=(C[0]&9)>0?0:1,Ce=Se,we=0;for(let e of xe){let t=e&15,n=t===Gl?3:t;n+=ae,n>4&&(n-=4);let r=lu[n-1];we=n%2>0?0:1,we!==Se&&(A++,k[A][0]=k[A-1][0],k[A][1]=k[A-1][1]);let i=(e&fu)>0,a=(e&du)>0,o=(e&pu)>>5;o<<=ae,o>15&&(o>>=4);let s=(e&mu)>0;if((a||i)&&o<9){let e=0,t=+!a;if(e=s&&we===0?w[t][0]+se[t][0]*w[t][2]:s?w[t][1]+se[t][1]*w[t][3]:E[t][o],we===0){let t=k[A][0],n=(e-t)*r[0];n>0&&(k[A][0]+=r[0]*n)}else{let t=k[A][1],n=(e-t)*r[1];n>0&&(k[A][1]+=r[1]*n)}}else s&&(k[A][0]+=r[0]*Math.abs(O[n]/2),k[A][1]+=r[1]*Math.abs(O[n]/2));A>0&&k[A][we]===k[A-1][we]?A--:Se=we}for(let e=0;e<=A&&(e!==A||(((C[1]&9)>0?0:1)===Ce?0:1)==(A+1)%2);e++)i.push({x:Yl(k[e][0]),y:Yl(k[e][1])});let Te=1;for(;Te<i.length;){let[e,t]=[i[Te-1],i[Te]];e==null||t==null||e.x!==t.x||e.y!==t.y?Te++:i.splice(Te,1)}},gu=(e,t,n)=>Xl(e,t,n),_u=(e,t,n,r,i)=>{let a=r!==null&&r.length>0?ru(e,r[0]):null,o=e.absolutePoints[0],s=e.absolutePoints[e.absolutePoints.length-1],c=o==null?t?.box??null:{x:o.x,y:o.y,width:0,height:0},l=s==null?n?.box??null:{x:s.x,y:s.y,width:0,height:0};if(c===null||l===null)return;let u=Math.max(c.x,l.x),d=Math.min(c.x+c.width,l.x+l.width),f=a===null?Math.round(d+(u-d)/2):a.x,p=c.y+c.height/2,m=l.y+l.height/2;if(a!==null&&(a.y>=c.y&&a.y<=c.y+c.height&&(p=a.y),a.y>=l.y&&a.y<=l.y+l.height&&(m=a.y)),!gu(l,f,p)&&!gu(c,f,p)&&i.push({x:f,y:p}),!gu(l,f,m)&&!gu(c,f,m)&&i.push({x:f,y:m}),i.length===1){if(a!==null)!gu(l,f,a.y)&&!gu(c,f,a.y)&&i.push({x:f,y:a.y});else{let e=Math.max(c.y,l.y),t=Math.min(c.y+c.height,l.y+l.height);i.push({x:f,y:e+(t-e)/2})}}a=null},vu=(e,t,n,r,i)=>{let a=r!==null&&r.length>0?ru(e,r[0]):null,o=e.absolutePoints[0],s=e.absolutePoints[e.absolutePoints.length-1],c=o==null?t?.box??null:{x:o.x,y:o.y,width:0,height:0},l=s==null?n?.box??null:{x:s.x,y:s.y,width:0,height:0};if(c===null||l===null)return;let u=Math.max(c.y,l.y),d=Math.min(c.y+c.height,l.y+l.height),f=c.x+c.width/2;a!==null&&a.x>=c.x&&a.x<=c.x+c.width&&(f=a.x);let p=a===null?Math.round(d+(u-d)/2):a.y;if(!gu(l,f,p)&&!gu(c,f,p)&&i.push({x:f,y:p}),f=a!==null&&a.x>=l.x&&a.x<=l.x+l.width?a.x:l.x+l.width/2,!gu(l,f,p)&&!gu(c,f,p)&&i.push({x:f,y:p}),i.length===1){if(a!==null)!gu(l,a.x,p)&&!gu(c,a.x,p)&&i.push({x:a.x,y:p});else{let e=Math.max(c.x,l.x),t=Math.min(c.x+c.width,l.x+l.width);i.push({x:e+(t-e)/2,y:p})}}},yu=(e,t,n,r,i)=>{let a=r!==null&&r.length>0?r[0]:null,o=!1,s=!1;if(t!==null&&n!==null){let r=t.box,i=n.box;if(a!==null){let t=Math.min(r.x,i.x),n=Math.max(r.x+r.width,i.x+i.width),c=Math.min(r.y,i.y),l=Math.max(r.y+r.height,i.y+i.height);a=ru(e,a),o=a.y<c||a.y>l,s=a.x<t||a.x>n}else o=Math.max(r.x,i.x)===Math.min(r.x+r.width,i.x+i.width),o||(s=Math.max(r.y,i.y)===Math.min(r.y+r.height,i.y+i.height))}!s&&(o||e.style.elbow===`vertical`)?vu(e,t,n,r,i):_u(e,t,n,r,i)},bu={orthogonalEdgeStyle:hu,segmentEdgeStyle:cu,elbowEdgeStyle:yu,sideToSideEdgeStyle:_u,topToBottomEdgeStyle:vu},xu=new Set([hu,cu,yu,_u,vu]),Su=new Set([yu,_u,vu]);function Cu(e){let t=new Map(e.cells.filter(e=>e.id!==void 0).map(e=>[e.id,e])),n=new Map,r=(e,i=new Set)=>{if(e.id!==void 0&&n.has(e.id))return n.get(e.id);let a={x:0,y:0},o=e.parent===void 0?void 0:t.get(e.parent);if(o!==void 0&&!i.has(o.id??``)){if(i.add(o.id??``),o.edge)a=null;else if(o.vertex){let e=r(o,i),t=o.geometry;a=e===null||t===void 0||t.relative?null:{x:e.x+t.x,y:e.y+t.y}}}return e.id!==void 0&&n.set(e.id,a),a},i=new Map;for(let t of e.cells){if(t.id===void 0)continue;let e=r(t);!t.vertex||t.geometry===void 0||t.geometry.relative||e===null||t.geometry.unreadable.length>0||i.set(t.id,{box:{x:e.x+t.geometry.x,y:e.y+t.geometry.y,width:t.geometry.width,height:t.geometry.height},style:Bl(t.style,!1)})}return{terminals:i,origins:n}}function wu(e,t){let n=e.geometry;if(n===void 0||e.id===void 0)return;let r=t.origins.get(e.id);if(r==null)return;let i=Bl(e.style,!0);if(i.sourcePort!==void 0||i.targetPort!==void 0||i.snapToPoint!==void 0||Vl(i,`fixedPointSpacing`,0)===1||i.orthogonal!==void 0)return;let a=e.source===void 0?null:t.terminals.get(e.source),o=e.target===void 0?null:t.terminals.get(e.target);if(a===void 0||o===void 0||a!==null&&!Zl(a)||o!==null&&!Zl(o)||a!==null&&a===o)return;let s=Vl(i,`noEdgeStyle`,0)===1?void 0:i.edgeStyle,c=s===void 0?null:bu[String(s)];if(c===void 0)return;let l={style:i,absolutePoints:[null,null],origin:r},u=(e,t)=>{let a=t?`exit`:`entry`;if(e!==null&&e.style.perimeter===`centerPerimeter`)return Jl(e.box);let o=i[`${a}X`],s=i[`${a}Y`];if(e!==null&&o!==void 0&&s!==void 0){let t=Number.parseFloat(String(o)),n=Number.parseFloat(String(s)),r=i[`${a}Perimeter`]===void 0||!!Number(i[`${a}Perimeter`]),c=Vl(i,`${a}Dx`,0),l=Vl(i,`${a}Dy`,0),u=Vl(e.style,`perimeterSpacing`,0),d={x:e.box.x-u,y:e.box.y-u,width:e.box.width+2*u,height:e.box.height+2*u},f={x:d.x+t*d.width+c,y:d.y+n*d.height+l};return r&&(f=nu(e,f,!1,0)),f}if(e===null){let e=t?n.sourcePointAt:n.targetPointAt;return e===void 0?null:{x:e.x+r.x,y:e.y+r.y}}return null};if(l.absolutePoints=[u(a,!0),u(o,!1)],a===null&&l.absolutePoints[0]===null||o===null&&l.absolutePoints[1]===null)return;let d=n.points.length>0?n.points:null,f=[l.absolutePoints[0]];if(c!==null)c(l,a,o,d,f);else if(d!==null)for(let e of d)f.push(ru(l,e));f.push(l.absolutePoints[1]);let p=c!==null&&xu.has(c),m=(e,t,n)=>{let r=f.length,a=f[n?Math.min(1,r-1):Math.max(0,r-2)]??null;a===null&&t!==null&&(a=Jl(t.box));let o=Vl(i,`perimeterSpacing`,0)+Vl(i,n?`sourcePerimeterSpacing`:`targetPerimeterSpacing`,0);return a===null?Jl(e.box):nu(e,a,p,o)};if(f[f.length-1]===null&&o!==null&&(f[f.length-1]=m(o,a,!1)),f[0]===null&&a!==null&&(f[0]=m(a,o,!0)),c!==null&&(Su.has(c)||c===hu&&d===null)&&f.length>2){let e=(e,t)=>e!==null&&t!==null&&Math.abs(e.x-t.x)<.01&&Math.abs(e.y-t.y)<.01,t=!1;for(let n=1;n<f.length&&!t;n++)t=e(f[n-1],f[n]);if(t)for(let t=f.length-2;t>0&&f.length>2;t--)(e(f[t],f[t+1])||e(f[t],f[t-1]))&&f.splice(t,1)}if(f.some(e=>e===null)||f.length<2)return;let h=f,g=[],_=0;for(let e=1;e<h.length;e++){let t=Math.hypot(h[e-1].x-h[e].x,h[e-1].y-h[e].y);g.push(t),_+=t}return{points:h,segments:g,length:_}}function Tu(e,t,n={x:0,y:0}){let{points:r,segments:i}=e,a=t.x/2,o=Math.round((a+.5)*e.length),s=i[0]??0,c=0,l=1;for(;o>=Math.round(c+s)&&l<r.length-1;)c+=s,s=i[l++];let u=s===0?0:(o-c)/s,d=r[l-1],f=r[l],p=f.x-d.x,m=f.y-d.y,h=s===0?0:m/s,g=s===0?0:p/s;return{x:d.x+p*u+(h*t.y+n.x),y:d.y+m*u-(g*t.y-n.y)}}function Eu(e){let t=String(e.shape??``);return t===`ellipse`||t===`doubleEllipse`?`ellipse`:t===`rhombus`?`rhombus`:`box`}function Du(e,t,n,r,i){let a=n.width/2-i,o=n.height/2-i;if(a<=0||o<=0)return 0;let s=n.x+n.width/2,c=n.y+n.height/2,l=(e.x-s)/a,u=(e.y-c)/o,d=(t.x-e.x)/a,f=(t.y-e.y)/o,p=0,m=1;if(r===`ellipse`){let e=d*d+f*f;if(e===0)return 0;let t=2*(l*d+u*f),n=l*l+u*u-1,r=t*t-4*e*n;if(r<=0)return 0;let i=Math.sqrt(r);p=Math.max(0,(-t-i)/(2*e)),m=Math.min(1,(-t+i)/(2*e))}else{let e=r===`box`?[[1,0],[-1,0],[0,1],[0,-1]]:[[1,1],[1,-1],[-1,1],[-1,-1]];for(let[t,n]of e){let e=t*l+n*u-1,r=t*d+n*f;if(r===0){if(e>=0)return 0;continue}let i=-e/r;r<0?p=Math.max(p,i):m=Math.min(m,i)}}return m<=p?0:(m-p)*Math.hypot(t.x-e.x,t.y-e.y)}function Ou(e,t){let n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),r=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);return n>0&&r>0?n*r:0}function ku(e,t,n){let r=Math.max(1,t.length)*n*.45,i=n*1.18;return{x:e.x-r/2,y:e.y-i/2,width:r,height:i}}function Au(e,t,n,r={x:0,y:0}){let i=[e.label,...t.filter(t=>t.parent===e.id).map(e=>e.label)],a=t=>{let n=n=>{let r=RegExp(`(?:^|;)${t}${n}=([^;]*)`).exec(e.style)?.[1],i=r===void 0?NaN:Number.parseFloat(r);return Number.isFinite(i)?i:void 0},r=n(`X`),i=n(`Y`);return r===void 0||i===void 0?void 0:{x:r,y:i}};return{id:e.id,label:i.filter(e=>e!==``).join(` `),source:e.source,target:e.target,exit:a(`exit`),entry:a(`entry`),points:n,waypoints:(e.geometry?.points??[]).map(e=>({x:r.x+e.x,y:r.y+e.y}))}}var ju=[.25,.5,.75,.125,.375,.625,.875],Mu=.06;function Nu(e,t){let n=t.x+t.width/2-(e.x+e.width/2),r=t.y+t.height/2-(e.y+e.height/2);return Math.abs(n)>=Math.abs(r)?n>=0?`X=1;Y=0.5`:`X=0;Y=0.5`:r>=0?`X=0.5;Y=1`:`X=0.5;Y=0`}var Pu=(e,t)=>{let[n,r]=Nu(e,t).split(`;`).map(e=>Number(e.slice(2)));return{x:e.x+e.width*n,y:e.y+e.height*r}},Fu=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,Iu=e=>e.reduce((t,n,r)=>r===0?0:t+Math.hypot(n.x-e[r-1].x,n.y-e[r-1].y),0),Lu=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function Ru(e,t){let n=e.width>0?(t.x-e.x)/e.width:.5,r=e.height>0?(t.y-e.y)/e.height:.5,[i,,a]=[[`left`,Math.abs(n),r],[`right`,Math.abs(1-n),r],[`top`,Math.abs(r),n],[`bottom`,Math.abs(1-r),n]].reduce((e,t)=>t[1]<e[1]?t:e);return{side:i,along:a}}var zu=(e,t)=>{let n=String(t);return e===`left`?`X=0;Y=${n}`:e===`right`?`X=1;Y=${n}`:e===`top`?`X=${n};Y=0`:`X=${n};Y=1`};function Bu(e){let t=e=>e>0&&e<1;if(e.x===0&&t(e.y))return`left`;if(e.x===1&&t(e.y))return`right`;if(e.y===0&&t(e.x))return`top`;if(e.y===1&&t(e.x))return`bottom`}function Vu(e,t,n){return t===`right`?n.x+n.width<=e.x:t===`left`?n.x>=e.x+e.width:t===`bottom`?n.y+n.height<=e.y:n.y>=e.y+e.height}var Hu={left:`left side`,right:`right side`,top:`top`,bottom:`bottom`},Uu=(e,t)=>`${e}:${t}`;function Wu(e,t){let n=new Map;for(let r of e){if(r.points.length<2)continue;let e=(e,i,a)=>{if(e===void 0||!t.has(e))return;let o=n.get(e)??[];o.push({wire:r,shape:e,point:i,role:a}),n.set(e,o)};e(r.source,r.points[0],`exit`),e(r.target,r.points[r.points.length-1],`entry`)}return n}function Gu(e,t){let n=[];for(let r of e){if(r.points.length<2)continue;let e=r.source===void 0?void 0:t.get(r.source),i=r.target===void 0?void 0:t.get(r.target);if(e!==void 0&&i!==void 0)for(let[t,a,o,s]of[[`exit`,r.exit,e,i],[`entry`,r.entry,i,e]]){let e=a===void 0?void 0:Bu(a);e!==void 0&&Vu(o,e,s)&&n.push({wire:r,role:t,side:e})}}return n}function Ku(e,t,n){let r=new Map,i=Wu(e,t);for(let[e,a]of i){let i=t.get(e),o=new Map;for(let e of a){if(!n.has(Uu(e.wire.id,e.role)))continue;let r=e.role===`exit`?e.wire.target:e.wire.source,a=r===void 0?void 0:t.get(r);if(a===void 0)continue;let s=Ru(i,Pu(i,a)).side;o.set(s,[...o.get(s)??[],e])}for(let[e,t]of o){let o=a.filter(e=>!n.has(Uu(e.wire.id,e.role))).map(e=>Ru(i,e.point)).filter(t=>t.side===e).map(e=>e.along),s=t.length===1?[.5,...ju.filter(e=>e!==.5)]:t.length===2?[.25,.75,...ju.filter(e=>e!==.25&&e!==.75)]:ju,c=s.filter(e=>o.every(t=>Math.abs(t-e)>Mu));t.forEach((t,n)=>{let o=c[n];o===void 0?r.set(Uu(t.wire.id,t.role),Ju(i,a,r,e)??zu(e,s[n%s.length])):r.set(Uu(t.wire.id,t.role),zu(e,o))})}}return r}function qu(e,t,n,r,i){return t.flatMap(t=>{let a=Uu(t.wire.id,t.role),o=n.get(a);if(o!==void 0){let[t,n]=o.split(`;`).map(e=>Number(e.slice(2))),i=Ru(e,{x:e.x+e.width*t,y:e.y+e.height*n});return i.side===r?[i.along]:[]}if(i?.has(a))return[];let s=Ru(e,t.point);return s.side===r?[s.along]:[]})}function Ju(e,t,n,r){for(let i of[`right`,`bottom`,`left`,`top`].filter(e=>e!==r)){let r=qu(e,t,n,i),a=ju.find(e=>r.every(t=>Math.abs(t-e)>Mu));if(a!==void 0)return zu(i,a)}}function Yu(e,t,n){let r=Gu(e,t).filter(e=>!n.has(e.wire.id)),i=new Set([...[...n].flatMap(([e,t])=>t.map(t=>Uu(e,t))),...r.map(e=>Uu(e.wire.id,e.role))]);return{away:r,moving:i,placements:Ku(e,t,i)}}function Xu(e,t,n){let r=new Map;for(let[i,a]of Yu(e,t,n).placements){let e=i.slice(i.lastIndexOf(`:`)+1);r.set(i,a.split(`;`).map(t=>`${e}${t}`).join(`;`))}return r}var Zu=e=>`(${Math.round(e.x)}, ${Math.round(e.y)})`;function Qu(e,t){let n=(e,t)=>Math.abs(e.x-t.x)<=1&&Math.abs(e.y-t.y)<=1;for(let r=0;r+1<e.length;r++){let i=e[r],a=e[r+1],o=Math.hypot(a.x-i.x,a.y-i.y);if(o>=.5&&o<20){let e=Math.abs(a.x-i.x)<Math.abs(a.y-i.y),r=n=>t.find(t=>e?Math.abs(t.y-n.y)<=1:Math.abs(t.x-n.x)<=1),s=t.find(e=>n(e,a))??t.find(e=>n(e,i))??r(a)??r(i),c=`a ${Math.max(1,Math.round(o))}-unit segment`;if(s===void 0)return{where:i,why:c,vertical:e,waypoints:t,fix:``};let l=n(s,a)||(e?Math.abs(s.y-a.y)<=1:Math.abs(s.x-a.x)<=1)?i:a,u=e?{x:s.x,y:l.y}:{x:l.x,y:s.y};return{where:i,why:c,vertical:e,waypoint:s,waypoints:t.map(e=>e===s?u:e),fix:`move its waypoint at ${Zu(s)} to ${Zu(u)}`}}let s=e[r+2];if(s===void 0)continue;let c={x:a.x-i.x,y:a.y-i.y},l={x:s.x-a.x,y:s.y-a.y};if(Math.abs(c.x*l.y-c.y*l.x)<.5&&c.x*l.x+c.y*l.y<0){let e=t.find(e=>n(e,a)),r=`a segment that goes back over the one before it`;return e===void 0?{where:a,why:r,vertical:c.x===0,waypoints:t,fix:``}:{where:a,why:r,vertical:c.x===0,waypoint:e,waypoints:t.filter(t=>t!==e),fix:`remove its waypoint at ${Zu(e)}`}}}}function $u(e,t,n=e=>`"${e}"`,r=new Map,i){let a=[],{away:o,moving:s,placements:c}=Yu(e,t,r),l=(e,t)=>c.get(Uu(e,t)).split(`;`).map(e=>`${t}${e}`).join(`;`),u=new Map;for(let[r,i]of Wu(e,t)){let e=t.get(r),o=i.filter(e=>!s.has(Uu(e.wire.id,e.role))),l=[];for(let e of o){let t=l.find(t=>Math.abs(t[0].point.x-e.point.x)<=1&&Math.abs(t[0].point.y-e.point.y)<=1);t?t.push(e):l.push([e])}for(let s of l){if(new Set(s.map(e=>e.wire.id)).size<2)continue;let l=new Set(s.map(e=>Lu(e.wire.label)));if(l.size===1&&!l.has(``))continue;let{side:d,along:f}=Ru(e,s[0].point),p=[...o.map(t=>Ru(e,t.point)).filter(e=>e.side===d).map(e=>e.along),...i.flatMap(t=>{let n=c.get(Uu(t.wire.id,t.role));if(n===void 0)return[];let[r,i]=n.split(`;`).map(e=>Number(e.slice(2))),a=Ru(e,{x:e.x+e.width*r,y:e.y+e.height*i});return a.side===d?[a.along]:[]})];p.push(...u.get(`${r}:${d}`)??[]);let m=ju.filter(e=>p.every(t=>Math.abs(t-e)>Mu)&&Math.abs(f-e)>Mu),h=s.slice(1);u.set(`${r}:${d}`,[...u.get(`${r}:${d}`)??[],...m.slice(0,h.length)]);let g=s.map(e=>n(e.wire.id)),_=l.has(``)?`they are not labelled as the same data`:`they carry different data`,v=h.slice(0,m.length).map((e,t)=>`${zu(d,m[t]).split(`;`).map(t=>`${e.role}${t}`).join(`;`)} for ${n(e.wire.id)}`),y=t=>[...i.map(t=>Ru(e,t.point)).filter(e=>e.side===t).map(e=>e.along),...i.flatMap(n=>c.has(Uu(n.wire.id,n.role))?qu(e,[n],c,t):[]),...u.get(`${r}:${t}`)??[]],b=h.slice(m.length).map(i=>{let a=i.role===`exit`?i.wire.target:i.wire.source,o=a===void 0?void 0:t.get(a),s=o===void 0?void 0:Ru(e,Pu(e,o)).side,c=[...new Set([s,`right`,`bottom`,`left`,`top`])].filter(e=>e!==void 0&&e!==d);for(let e of c){let t=ju.find(t=>y(e).every(e=>Math.abs(e-t)>Mu));if(t!==void 0)return u.set(`${r}:${e}`,[...u.get(`${r}:${e}`)??[],t]),`${zu(e,t).split(`;`).map(e=>`${i.role}${e}`).join(`;`)} for ${n(i.wire.id)}, on its ${Hu[e]}`}return`${n(i.wire.id)}: no side of this shape has a free point left, so make the shape larger`}),x=v.length===0?`that ${Hu[d]} has no free point left, so move them to other sides: ${b.join(`, `)}`:`give each its own point on its ${Hu[d]}: ${v.join(`, `)}${b.length>0?`, and, since that side has no free point left, ${b.join(`, `)}`:``}`;a.push({rule:`shared-point`,wires:[...new Set(s.map(e=>e.wire.id))],shapes:[r],message:`connectors ${g.join(`, `)} meet shape ${n(r)} at the same point, and ${_}: ${x}. Only wires with the same label may share a point`})}}let d=new Set;for(let{wire:e,role:t,side:r}of o){d.add(e.id);let i=t===`exit`?e.source:e.target,o=t===`exit`?e.target:e.source;a.push({rule:`facing-away`,wires:[e.id],shapes:[i],message:`connector ${n(e.id)} ${t===`exit`?`leaves`:`enters`} shape ${n(i)} on its ${Hu[r]}, facing away from ${n(o)}: fix it on the side facing it (${l(e.id,t)}), or drop ${t}X/${t}Y to let draw.io choose`})}for(let i of e){if(i.points.length<2||d.has(i.id)||r.has(i.id))continue;let e=i.source===void 0?void 0:t.get(i.source),o=i.target===void 0?void 0:t.get(i.target);if(e===void 0||o===void 0||Fu(e,o))continue;let s=Pu(e,o),c=Pu(o,e),l=Math.hypot(c.x-s.x,c.y-s.y),u=Iu(i.points);if(u<=2*l||u-l<80)continue;let f=Nu(e,o).split(`;`).map(e=>`exit${e}`).join(`;`),p=Nu(o,e).split(`;`).map(e=>`entry${e}`).join(`;`);a.push({rule:`detour`,wires:[i.id],shapes:[i.source,i.target],message:`connector ${n(i.id)} runs ${Math.round(u)} units to join shapes ${n(i.source)} and ${n(i.target)}, whose facing sides are ${Math.round(l)} apart: fix its exit and entry on those sides (${f};${p}), or give it a waypoint on the short way (<Array as="points"><mxPoint x="…" y="…"/></Array> in its geometry)`})}for(let o of e){if(o.waypoints.length===0&&o.exit===void 0&&o.entry===void 0||d.has(o.id)||r.has(o.id))continue;let e=Qu(o.points,o.waypoints);if(e===void 0)continue;let s=(e,t)=>{if(i===void 0)return!0;let n=i(o,e,t);return n!==void 0&&Qu(n,e)===void 0},c;if(e.waypoint!==void 0&&s(e.waypoints)?c=e.fix:s([])&&(c=`remove its waypoints (the <Array as="points"> in its geometry) to let draw.io route it`),c===void 0){let n=o.source===void 0?void 0:t.get(o.source),r=o.target===void 0?void 0:t.get(o.target);if(n===void 0||r===void 0)continue;let i=o.points[0],a=o.points[o.points.length-1],l=(t,n)=>e.vertical?(n.y-t.y)/t.height:(n.x-t.x)/t.width,u=e=>Math.round(e*1e4)/1e4,d=o.entry===void 0?void 0:u(l(r,i)),f=o.exit===void 0?void 0:u(l(n,a)),p=e.vertical?`Y`:`X`;d!==void 0&&d>0&&d<1&&s(o.waypoints,{[`entry${p}`]:d})?c=`put its entry level with its exit: entry${p}=${d}`:f!==void 0&&f>0&&f<1&&s(o.waypoints,{[`exit${p}`]:f})?c=`put its exit level with its entry: exit${p}=${f}`:(o.exit!==void 0||o.entry!==void 0)&&s(o.waypoints,{...o.exit?{exitX:NaN}:{},...o.entry?{entryX:NaN}:{}})&&(c=`drop exitX/exitY and entryX/entryY to let draw.io choose where it leaves and enters`)}if(c===void 0){let r=t.get(o.source),i=t.get(o.target),a=Math.round(r.y+r.height/2-(i.y+i.height/2)),s=Math.round(r.x+r.width/2-(i.x+i.width/2)),l=e.vertical?{name:`y`,by:a}:{name:`x`,by:s};if(l.by===0)continue;c=`line up the shapes it joins, whose middles are ${Math.abs(l.by)} units apart: move ${n(o.target)} by ${l.by>0?`+`:``}${l.by} on ${l.name}`}a.push({rule:`needless-bend`,wires:[o.id],shapes:[],message:`connector ${n(o.id)} has a needless bend near ${Zu(e.where)}: ${e.why}. Fix it: ${c}`})}return a}var ed=class extends Error{constructor(e){super(e),this.name=`XmlError`}},td=new Map([[`amp`,`&`],[`lt`,`<`],[`gt`,`>`],[`quot`,`"`],[`apos`,`'`]]);function nd(e){return e.includes(`&`)?e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-zA-Z]+);/g,(e,t)=>{if(t.startsWith(`#x`)||t.startsWith(`#X`)){let n=Number.parseInt(t.slice(2),16);return Number.isFinite(n)&&n>0?rd(n,e):e}if(t.startsWith(`#`)){let n=Number.parseInt(t.slice(1),10);return Number.isFinite(n)&&n>0?rd(n,e):e}return td.get(t)??e}):e}function rd(e,t){try{return String.fromCodePoint(e)}catch{return t}}function id(e){let t=new Map,n=/([^\s=/>]+)\s*=\s*("([^"]*)"|'([^']*)')/g,r;for(;(r=n.exec(e))!==null;)t.set(r[1],nd(r[3]??r[4]??``));return t}function ad(e,t){let n=0,r=e.length;for(;n<r;){let r=e.indexOf(`<`,n);if(r===-1){i(e.slice(n));return}if(r>n&&i(e.slice(n,r))===!1)return;if(e.startsWith(`<!--`,r)){let t=e.indexOf(`-->`,r+4);if(t===-1)return;n=t+3;continue}if(e.startsWith(`<![CDATA[`,r)){let i=e.indexOf(`]]>`,r+9);if(i===-1)throw new ed(`unterminated CDATA section`);if(t({kind:`text`,text:e.slice(r+9,i)})===!1)return;n=i+3;continue}if(/^<!doctype/i.test(e.slice(r,r+9)))throw new ed(`this document declares a DOCTYPE, which is refused`);if(e.startsWith(`<?`,r)){let t=e.indexOf(`?>`,r+2);if(t===-1)throw new ed(`unterminated processing instruction`);n=t+2;continue}let a=od(e,r);if(a===-1)throw new ed(`unterminated tag`);let o=e.slice(r+1,a);if(n=a+1,o.startsWith(`/`)){if(t({kind:`close`,name:o.slice(1).trim()})===!1)return;continue}let s=o.endsWith(`/`),c=s?o.slice(0,-1):o,l=c.search(/[\s/]/),u=(l===-1?c:c.slice(0,l)).trim();if(u===``)throw new ed(`a tag has no name`);if(t({kind:`open`,name:u,attributes:l===-1?new Map:id(c.slice(l)),selfClosing:s})===!1)return}function i(e){if(e!==``)return t({kind:`text`,text:nd(e)})}}function od(e,t){let n=null;for(let r=t+1;r<e.length;r++){let t=e[r];if(n!==null)t===n&&(n=null);else if(t===`"`||t===`'`)n=t;else if(t===`>`)return r}return-1}var sd=class extends Error{constructor(e){super(e),this.name=`DrawioReadError`}},cd=[`x`,`y`,`width`,`height`];function ld(e){let t=e.replace(/[^\x20-\x7e]/g,`?`);return t.length>40?`${t.slice(0,39)}…`:t}function ud(e){let t=``,n=null;for(let r of e??``)r===`<`?n=``:r===`>`?(n!==null&&/^br\b/i.test(n)&&(t+=` `),n=null):n===null?t+=r:n+=r;return t.replace(/&nbsp;/g,` `).replace(/\s+/g,` `).trim()}function dd(e){let t={x:0,y:0,width:0,height:0,relative:e.get(`relative`)===`1`,unreadable:[],sourcePoint:!1,targetPoint:!1,points:[]};for(let n of cd){let r=e.get(n);if(r===void 0)continue;let i=Number(r);r.trim()===``||!Number.isFinite(i)?t.unreadable.push(`${n}="${r}"`):t[n]=i}return t}function fd(e,t){let n=[],r=[],i=null,a=null,o=null,s=!1;try{ad(e,e=>{if(e.kind===`text`)return;if(e.kind===`close`){let t=r.pop();if(t!==e.name)throw new sd(`</${ld(e.name)}> closes <${ld(t??`nothing`)}>`);e.name===`mxCell`?a=null:e.name===`mxGeometry`?o=null:(e.name===`object`||e.name===`UserObject`)&&(i=null);return}let{name:t,attributes:c,selfClosing:l}=e;if(r.length===0){if(t!==`mxGraphModel`)throw new sd(`its model is <${ld(t)}>, not <mxGraphModel>`);s=!0}if(t===`object`||t===`UserObject`)i=c;else if(t===`mxCell`){let e={id:(i??c).get(`id`)??c.get(`id`),parent:c.get(`parent`),vertex:c.get(`vertex`)===`1`,edge:c.get(`edge`)===`1`,source:c.get(`source`),target:c.get(`target`),label:ud(i?i.get(`label`)??i.get(`value`):c.get(`value`)),style:c.get(`style`)??``,geometry:void 0};n.push(e),a=l?null:e}else if(t===`mxGeometry`&&a!==null&&(c.get(`as`)??`geometry`)===`geometry`){let e=dd(c);a.geometry=e,o=l?null:e}else if(t===`mxPoint`&&o!==null){let e={x:Number(c.get(`x`)??0)||0,y:Number(c.get(`y`)??0)||0},t=o;c.get(`as`)===`sourcePoint`?(t.sourcePoint=!0,t.sourcePointAt=e):c.get(`as`)===`targetPoint`?(t.targetPoint=!0,t.targetPointAt=e):c.get(`as`)===`offset`?t.offset=e:r[r.length-1]===`Array`&&r[r.length-2]===`mxGeometry`&&t.points.push(e)}l||r.push(t)})}catch(e){throw e instanceof sd?e:e instanceof ed?new sd(`page "${t}" is not well-formed XML: ${e.message}`):e}if(!s)throw new sd(`page "${t}" holds no <mxGraphModel>`);if(r.length>0)throw new sd(`page "${t}" ends inside <${r[r.length-1]}>`);return n}function pd(e,t){let n=e.replace(/^/,``).trim(),r;try{ad(n,e=>{if(e.kind===`open`)return r=e.name,!1})}catch(e){throw e instanceof ed?new sd(`this is not well-formed XML: ${e.message}`):e}if(r===`mxGraphModel`)return[{name:`Page-1`,cells:fd(n,`Page-1`)}];if(r!==`mxfile`)throw new sd(r===void 0?`the file is empty`:`its root is <${ld(r)}>, not <mxfile> or <mxGraphModel>`);let i=[],a=/<diagram\b([^>]*?)(\/>|>([\s\S]*?)<\/diagram>)/g,o;for(;(o=a.exec(n))!==null;){let e=`Page-${i.length+1}`;ad(`<diagram${o[1]}/>`,t=>{if(t.kind===`open`){let n=t.attributes.get(`name`);n&&(e=n)}return!1});let n=(o[3]??``).trim();if(n===``)throw new sd(`page "${e}" is empty`);let r;try{if(n.startsWith(`<`))r=n;else if(t===void 0)throw new sd(`its compressed data cannot be read here`);else r=t(n)}catch(t){throw t instanceof sd?new sd(`page "${e}" cannot be read: ${t.message}`):t}i.push({name:e,cells:fd(r,e)})}if(i.length===0)throw new sd(`the <mxfile> holds no <diagram> page`);return i}function md(e){let t=e.label.length>40?`${e.label.slice(0,39)}…`:e.label;return t===``?`"${e.id}"`:`"${e.id}" (${t})`}function hd(e,t){let n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),r=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);return n>0&&r>0?n*r:0}function gd(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}var _d=.1;function vd(e){if(e.label===``)return!1;let t=e.style.split(`;`)[0];return![`line`,`image`,`group`,`text`,`edgeLabel`].includes(t)&&!/(^|;)(shape=(line|image)|image=)/.test(e.style)}var yd={shapes:0,ends:1,sharedPoints:2,detours:3,crossings:4,labels:5};function bd(e,t){let n=t.length,r=new Map,i=(n,i,a,o)=>{let s={severity:n,page:e.name,cells:i,message:a};t.push(s),o!==void 0&&r.set(s,o)},a=new Map;for(let t of e.cells)t.id===void 0||t.id===``?i(`error`,[],`a cell${t.label?` labelled "${t.label}"`:``} has no id`):a.has(t.id)?i(`error`,[t.id],`the id "${t.id}" is used by more than one cell`):a.set(t.id,t);let o=e.cells[0];for(let t of e.cells)t.id!==void 0&&(t.parent===void 0?t!==o&&i(`error`,[t.id],`cell ${md(t)} has no parent; every cell but the root belongs to a layer or a container`):a.has(t.parent)||i(`error`,[t.id],`cell ${md(t)} belongs to "${t.parent}", which does not exist`));let s=e=>e.geometry?.relative===!0||e.parent!==void 0&&a.get(e.parent)?.edge===!0;for(let t of e.cells)if(t.id!==void 0){if(t.edge){for(let[e,n,r]of[[`start`,t.source,t.geometry?.sourcePoint],[`end`,t.target,t.geometry?.targetPoint]])n!==void 0&&!a.has(n)?i(`error`,[t.id],`connector ${md(t)} has its ${e} on "${n}", which does not exist`):n===void 0&&r!==!0&&i(`error`,[t.id],`connector ${md(t)} is attached to nothing at its ${e}: give it a ${e===`start`?`source`:`target`}, or a ${e===`start`?`sourcePoint`:`targetPoint`}`);t.geometry===void 0&&i(`error`,[t.id],`connector ${md(t)} has no <mxGeometry relative="1" as="geometry">`)}if(t.vertex){let e=t.geometry;e===void 0?i(`error`,[t.id],`shape ${md(t)} has no <mxGeometry as="geometry">, so it has no size or place`):e.unreadable.length>0?i(`error`,[t.id],`shape ${md(t)} has geometry that is not numbers: ${e.unreadable.join(`, `)}`):e.width<0||e.height<0?i(`error`,[t.id],`shape ${md(t)} is ${e.width} × ${e.height}: a negative size cannot be drawn`):!s(t)&&e.width===0&&e.height===0&&i(`warning`,[t.id],`shape ${md(t)} is 0 × 0, so nothing of it shows`,yd.shapes)}}let c=e.cells.filter(e=>e.vertex&&e.id!==void 0&&e.geometry!==void 0&&e.geometry.unreadable.length===0&&!s(e)&&e.geometry.width>0&&e.geometry.height>0),l=new Set(c.filter(e=>c.some(t=>t.parent===e.id)).map(e=>e.id)),u=new Map;for(let e of c){let t=e.parent??``;u.set(t,[...u.get(t)??[],e])}for(let e of u.values()){let t=e.filter(vd);for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++){let[r,a]=[t[e],t[n]],o=Math.min(r.geometry.width*r.geometry.height,a.geometry.width*a.geometry.height);hd(r.geometry,a.geometry)>_d*o&&!gd(r.geometry,a.geometry)&&!gd(a.geometry,r.geometry)&&i(`warning`,[r.id,a.id],`shapes ${md(r)} and ${md(a)} overlap`,yd.shapes)}}for(let e of c){let t=e.parent===void 0?void 0:a.get(e.parent);t!==void 0&&t.vertex&&l.has(t.id??``)&&t.geometry!==void 0&&(t.style.split(`;`)[0]===`group`||/(^|;)rotation=(?!0(;|$))/.test(t.style)||gd({...t.geometry,x:0,y:0},e.geometry)||i(`warning`,[e.id,t.id??``],`shape ${md(e)} lies partly outside its container ${md(t)}`,yd.shapes))}Cd(e,a,l,i);let d=t.splice(n),f=e=>e.severity===`error`?-1:r.get(e)??-1;t.push(...d.map((e,t)=>({issue:e,index:t})).sort((e,t)=>f(e.issue)-f(t.issue)||e.index-t.index).map(({issue:e})=>e))}var xd=2,Sd=.3;function Cd(e,t,n,r){let i=Cu(e),a=[...i.terminals.entries()].flatMap(([e,r])=>{let i=t.get(e);return i!==void 0&&vd(i)&&!n.has(e)&&r.box.width>0&&r.box.height>0?[{id:e,cell:i,box:r.box,outline:Eu(r.style)}]:[]}),o=e=>{let n=new Set;for(let r=e===void 0?void 0:t.get(e);r?.parent!==void 0&&!n.has(r.parent);r=t.get(r.parent))n.add(r.parent);return n},s=(e,t,n)=>e.some((r,i)=>i>0&&Du(e[i-1],r,t,n,xd)>0),c=[],l=[],u=new Map,d=new Map,f=[];for(let n of e.cells){if(!n.edge||n.id===void 0)continue;let p=wu(n,i);if(p===void 0)continue;c.push(Au({...n,id:n.id},e.cells,p.points,i.origins.get(n.id)??void 0)),u.set(n.id,p);let m=new Set([n.source,n.target].filter(e=>e!==void 0)),h=new Set([...o(n.source),...o(n.target),...o(n.id)]);for(let e of a)m.has(e.id)||h.has(e.id)||s(p.points,e.box,e.outline)&&r(`warning`,[n.id,e.id],`connector ${md(n)} runs through shape ${md(e.cell)}: move the shape off its path, give the connector a waypoint that goes around it (<Array as="points"><mxPoint x="…" y="…"/></Array> in its geometry), or fix its exit and entry on other sides (exitX/exitY, entryX/entryY)`,yd.crossings);let g=n.source===void 0?void 0:i.terminals.get(n.source),_=n.target===void 0?void 0:i.terminals.get(n.target);if(g!==void 0&&_!==void 0&&Ou(g.box,_.box)===0){let e=[[`source`,n.source,g,_,`exit`],[`target`,n.target,_,g,`entry`]].filter(([,e,n])=>t.get(e)!==void 0&&s(p.points,n.box,Eu(n.style)));if(e.length>0){let t=(n.geometry?.points.length??0)>0,r=e=>RegExp(`(?:^|;)${e}X=`).test(n.style)&&RegExp(`(?:^|;)${e}Y=`).test(n.style);d.set(n.id,e.map(([,,,,e])=>e).filter(e=>!t||r(e))),f.push({edge:{...n,id:n.id},own:e.map(([e,t,,,n])=>({role:e,id:t,prefix:n})),waypoints:t})}}let v=[];if(n.label!==``&&n.geometry!==void 0){let e=n.geometry.relative?{x:n.geometry.x,y:n.geometry.y}:{x:0,y:0};v.push({text:n.label,centre:Tu(p,e,n.geometry.offset),style:n.style,holder:n.id,along:e,...n.geometry.offset?{offset:n.geometry.offset}:{}})}for(let t of e.cells){if(t.parent!==n.id||t.label===``||t.geometry===void 0||!t.geometry.relative||t.id===void 0)continue;let e={x:t.geometry.x,y:t.geometry.y};v.push({text:t.label,centre:Tu(p,e,t.geometry.offset),style:t.style,holder:t.id,along:e,...t.geometry.offset?{offset:t.geometry.offset}:{}})}for(let e of v){let t=Number(/(?:^|;)fontSize=([\d.]+)/.exec(e.style)?.[1]??11)||11,i=ku(e.centre,e.text,t);l.push({wire:n.id,holder:e.holder,text:e.text,fontSize:t,along:e.along,...e.offset?{offset:e.offset}:{},box:i,around:h});for(let t of a)h.has(t.id)||Ou(i,t.box)>Sd*i.width*i.height&&r(`warning`,[n.id,t.id],`the label "${e.text.length>40?`${e.text.slice(0,39)}…`:e.text}" of connector ${md(n)} sits on shape ${md(t.cell)}: move the label along the connector (its mxGeometry x, from -1 at the source to 1 at the target) or beside it (y), or move the shape`,yd.labels)}}let p=e=>{let n=t.get(e);return n===void 0?`"${e}"`:md(n)},m=new Map([...i.terminals].map(([e,t])=>[e,t.box])),h=Xu(c,m,d);for(let{edge:e,own:n,waypoints:i}of f){let a=n.map(({role:e,id:n})=>`its ${e} ${md(t.get(n))}`).join(` and `),o=n.flatMap(({prefix:t})=>h.get(`${e.id}:${t}`)??[]).join(`;`),s=`remove its waypoints (the <Array as="points"> in its geometry) to let draw.io route it, or move the first and last of them off those shapes`,c=i&&o===``?`connector ${md(e)} runs through ${a}: its waypoints take it back across them. Fix it: ${s}`:i?`connector ${md(e)} runs through ${a}: its exit or entry is on a side facing away from the other end, and it has waypoints. Put them on the sides facing each other (${o}), and ${s}`:`connector ${md(e)} runs through ${a}: its exit or entry is on a side facing away from the other end. Put them on the sides facing each other (${o}), or drop exitX/exitY and entryX/entryY to let draw.io choose`;r(`warning`,[e.id,...n.map(({id:e})=>e)],c,yd.ends)}let g={"shared-point":yd.sharedPoints,"facing-away":yd.ends,detour:yd.detours,"needless-bend":yd.detours},_=(e,n,r={})=>{let a=t.get(e.id),o=i.origins.get(e.id);if(a?.geometry===void 0||o==null)return;let s=a.style;for(let[e,t]of Object.entries(r)){let n=Number.isNaN(t)?[e,e.replace(/X$/,`Y`)]:[e];for(let e of n)s=s.replace(RegExp(`(^|;)${e}=[^;]*`),`$1`);Number.isNaN(t)||(s=`${s}${s.endsWith(`;`)?``:`;`}${e}=${t};`)}return wu({...a,style:s,geometry:{...a.geometry,points:n.map(e=>({x:e.x-o.x,y:e.y-o.y}))}},i)?.points},v=new Set(d.keys());for(let e of $u(c,m,p,d,_)){r(`warning`,[...e.wires,...e.shapes],e.message,g[e.rule]);for(let t of e.wires)v.add(t)}Od(l,u,c,a,p,r,_,s,v)}var wd=[0,-.3,.3,-.6,.6,-.8,.8],Td=[-14,14,-28,28],Ed=[10,-10,20,-20,30,-30,40,-40],Dd=e=>e.length>40?`${e.slice(0,39)}…`:e;function Od(e,t,n,r,i,a,o,s,c){let l=(e,t)=>Ou(e,t)>Sd*Math.min(e.width*e.height,t.width*t.height),u=(e,t)=>t.points.reduce((n,r,i)=>i===0?0:n+Du(t.points[i-1],r,e,`box`,0),0),d=(n,i)=>e.every(e=>e===n||!l(i,e.box))&&r.every(e=>n.around.has(e.id)||Ou(i,e.box)<=Sd*i.width*i.height)&&[...t].every(([e,t])=>e===n.wire||u(i,t)<4),f=e=>{let n=t.get(e.wire);if(n===void 0)return;let r=[e.along.x,...wd.filter(t=>Math.abs(t-e.along.x)>.05).sort((t,n)=>Math.abs(t-e.along.x)-Math.abs(n-e.along.x))];for(let t of[e.along.y,...Td.map(t=>e.along.y+t)])for(let i of r)if((i!==e.along.x||t!==e.along.y)&&d(e,ku(Tu(n,{x:i,y:t},e.offset),e.text,e.fontSize)))return{x:i,y:t}},p=e=>{let t=f(e);if(t===void 0)return`move the shapes so the connectors part, or shorten the label`;let n=t.y===e.along.y?``:` y="${t.y}"`;return`move it ${n===``?`along`:`beside`} its connector: set x="${t.x}"${n} in the mxGeometry of ${i(e.holder)}`},m=new Set;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){let r=e[t],o=e[n];r.wire===o.wire||m.has(r)||m.has(o)||c.has(r.wire)||c.has(o.wire)||!l(r.box,o.box)||(m.add(o),a(`warning`,[o.wire,r.wire],`the label "${Dd(o.text)}" of connector ${i(o.wire)} lies on the label "${Dd(r.text)}" of connector ${i(r.wire)}: ${p(o)}`,yd.labels))}for(let n of e)if(!(m.has(n)||c.has(n.wire))){for(let[e,r]of t)if(!(e===n.wire||c.has(e)||u(n.box,r)<4)){m.add(n),a(`warning`,[n.wire,e],`the label "${Dd(n.text)}" of connector ${i(n.wire)} lies across connector ${i(e)}: ${p(n)}`,yd.labels);break}}let h=e=>e.replace(/\s+/g,` `).trim().toLowerCase(),g=(e,t)=>{let n=0,r,i;for(let a=1;a<e.length;a++)for(let o=1;o<t.length;o++){let[s,c,l,u]=[e[a-1],e[a],t[o-1],t[o]],d=Math.abs(s.x-c.x)<.5&&Math.abs(l.x-u.x)<.5&&Math.abs(s.x-l.x)<8,f=Math.abs(s.y-c.y)<.5&&Math.abs(l.y-u.y)<.5&&Math.abs(s.y-l.y)<8;if(!d&&!f)continue;let[p,m]=d?[Math.max(Math.min(s.y,c.y),Math.min(l.y,u.y)),Math.min(Math.max(s.y,c.y),Math.max(l.y,u.y))]:[Math.max(Math.min(s.x,c.x),Math.min(l.x,u.x)),Math.min(Math.max(s.x,c.x),Math.max(l.x,u.x))];m-p<=0||(n+=m-p,r===void 0&&(r=d?{x:s.x,y:p}:{x:p,y:s.y},i=d?{x:s.x,y:m}:{x:m,y:s.y}))}return{total:n,from:r,to:i}},_=new Set,v=new Map,y=e=>v.get(e.id)??e.points;for(let e=0;e<n.length;e++)for(let t=e+1;t<n.length;t++){let l=n[e],u=n[t];if(h(l.label)!==``&&h(l.label)===h(u.label)||_.has(u.id)||c.has(l.id)||c.has(u.id))continue;let d=g(l.points,u.points);if(d.total<12||d.from===void 0||d.to===void 0)continue;_.add(u.id);let f=Math.abs(d.from.x-d.to.x)<.5,p={x:(d.from.x+d.to.x)/2,y:(d.from.y+d.to.y)/2},m=(e,t)=>f?{x:e.x+t,y:e.y}:{x:e.x,y:e.y+t},b=e=>`(${Math.round(e.x)}, ${Math.round(e.y)})`,x=e=>{let t,i=S(e,(i,a)=>{let c=o(e,i,a);if(c===void 0||Qu(c,i)!==void 0||r.some(e=>s(c,e.box,e.outline)))return!1;let l=t=>h(t.label)!==``&&h(t.label)===h(e.label);return n.every(t=>t===e||l(t)||g(y(t),c).total<12)?(t=c,!0):!1});if(i!==void 0&&t!==void 0)return v.set(e.id,t),{wire:e,fix:i}},S=(e,t)=>{for(let n of Ed){for(let r of e.waypoints){let i=m(r,n);if(t(e.waypoints.map(e=>e===r?i:e)))return`move its waypoint at ${b(r)} to ${b(i)}`}if(e.waypoints.length>1){let r=e.waypoints.map(e=>m(e,n));if(t(r))return`move its waypoints to ${r.map(b).join(`, `)}`}if(e.waypoints.length===0){let r=e.points.slice(1,-1).map(e=>m(e,n));if(r.length>0&&t(r))return`add waypoints at ${r.map(b).join(`, `)}: <Array as="points">${r.map(e=>`<mxPoint x="${Math.round(e.x)}" y="${Math.round(e.y)}"/>`).join(``)}</Array> in its geometry`;let i=m(p,n);if(t([i]))return`add a waypoint at ${b(i)}: <Array as="points"><mxPoint x="${Math.round(i.x)}" y="${Math.round(i.y)}"/></Array> in its geometry`}}for(let n of[`exit`,`entry`]){let r=n===`exit`?e.exit:e.entry;if(r===void 0)continue;let i=r.x===0||r.x===1?{axis:`Y`,along:r.y,keep:`${n}X=${r.x}`}:{axis:`X`,along:r.x,keep:`${n}Y=${r.y}`};for(let r of[.25,.75,.125,.375,.625,.875,.5])if(!(Math.abs(r-i.along)<.06)&&t(e.waypoints,{[`${n}${i.axis}`]:r}))return`move its ${n} to ${n}${i.axis}=${r} (keeping ${i.keep})`}},C=x(u)??x(l),w=C?.fix,T=C?.wire??u,E=h(l.label)===``||h(u.label)===``?`they are not labelled as the same data`:`they carry different data`;a(`warning`,[u.id,l.id],`connectors ${i(l.id)} and ${i(u.id)} run along the same line for ${Math.round(d.total)} units from (${Math.round(d.from.x)}, ${Math.round(d.from.y)}), and ${E}: a reader cannot tell them apart. Fix ${i(T.id)}: ${w??`give it another exit or entry point (exitX/exitY, entryX/entryY), or move a shape so their routes part`}`,yd.crossings)}}function kd(e,t){return Ad(pd(e,t))}function Ad(e){let t=[];for(let n of e)bd(n,t);return{pages:e.map(e=>({name:e.name,shapes:e.cells.filter(e=>e.vertex).length,connectors:e.cells.filter(e=>e.edge).length})),issues:t}}var jd=`(?:(?!</mxCell>)[\\s\\S])*?`;function Md(e,t,n){let r=RegExp(`(^|;)${t}=[^;]*`);return r.test(e)?e.replace(r,`$1${t}=${n}`):`${e}${e.endsWith(`;`)||e===``?``:`;`}${t}=${n};`}function Nd(e){let t=new Map,n=(e,n)=>{let r=t.get(e)??{},i=new Set(Object.keys(r));for(let e of n.split(`;`)){let[t,n]=e.split(`=`);t&&n&&!i.has(t)&&(r[t]=n)}t.set(e,r)};for(let t of e){for(let e of t.matchAll(/((?:exit|entry)[XY]=[\d.]+;(?:exit|entry)[XY]=[\d.]+) for "([^"]+)"/g))n(e[2],e[1]);let e=/^connector "([^"]+)".*Fix it: put its (?:entry|exit) level with its (?:exit|entry): ((?:exit|entry)[XY]=[\d.]+)/.exec(t);e&&n(e[1],e[2]);let r=/^connector "([^"]+)".*fix its exit and entry on those sides \(((?:(?:exit|entry)[XY]=[\d.]+;?)+)\)/.exec(t);r&&n(r[1],r[2]);let i=/Fix "([^"]{1,200})"(?: \([^)]{0,80}\))?: move its (?:exit|entry) to ((?:exit|entry)[XY]=[\d.]+) \(keeping ((?:exit|entry)[XY]=[\d.]+)\)/.exec(t);i&&n(i[1],`${i[2]};${i[3]}`);let a=/^connector "([^"]+)".*Fix it: drop exitX\/exitY and entryX\/entryY to let draw\.io choose where/.exec(t);a&&n(a[1],`exitX=none;exitY=none;entryX=none;entryY=none`);let o=/^connector "([^"]+)".*?(?:sides facing each other|side facing it) \(((?:(?:exit|entry)[XY]=[\d.]+;?)+)\)/.exec(t);o&&n(o[1],o[2])}return t}function Pd(e){return e.flatMap(e=>{let t=/Fix "([^"]{1,200})"(?: \([^)]{0,80}\))?: (?:move its waypoints to|add waypoints at) ((?:\(-?\d+, -?\d+\)(?:, )?)+)/.exec(e);return t?[{wire:t[1],points:[...t[2].matchAll(/\((-?\d+), (-?\d+)\)/g)].map(e=>({x:Number(e[1]),y:Number(e[2])}))}]:[]})}function Fd(e,t){let n=e;for(let e of t){let t=e.wire.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=e.points.map(e=>`<mxPoint x="${e.x}" y="${e.y}"/>`).join(``),i=RegExp(`(<mxCell\\b[^>]*\\bid="${t}"[^>]*>\\s*<mxGeometry\\b[^>]*[^/]>${jd}<Array as="points">)[\\s\\S]*?(</Array>)`);n=i.test(n)?n.replace(i,(e,t,n)=>`${t}${r}${n}`):Bd(n,e.wire,r)}return n}function Id(e){return e.flatMap(e=>{let t=/Fix "([^"]{1,200})"(?: \([^)]{0,80}\))?: move its waypoint at/.exec(e)?.[1]??/^connector "([^"]+)"/.exec(e)?.[1];if(t===void 0)return[];let n=/(?:Fix it|Fix "[^"]{1,200}"(?: \([^)]{0,80}\))?): move its waypoint at \((-?\d+), (-?\d+)\) to \((-?\d+), (-?\d+)\)/.exec(e);if(n)return[{wire:t,from:{x:Number(n[1]),y:Number(n[2])},to:{x:Number(n[3]),y:Number(n[4])}}];let r=/Fix it: remove its waypoint at \((-?\d+), (-?\d+)\)/.exec(e);return r?[{wire:t,from:{x:Number(r[1]),y:Number(r[2])},to:null}]:[]})}function Ld(e,t){let n=e;for(let e of t){let t=e.wire.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n=n.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${t}"${jd}<Array as="points">)([\\s\\S]*?)(</Array>)`),(t,n,r,i)=>{let a=r.match(/<mxPoint\b[^>]*\/>/g)?.find(t=>{let n=Number(/\bx="([^"]*)"/.exec(t)?.[1]??0),r=Number(/\by="([^"]*)"/.exec(t)?.[1]??0);return Math.abs(n-e.from.x)<=1&&Math.abs(r-e.from.y)<=1});if(a===void 0)return`${n}${r}${i}`;let o=e.to===null?``:`<mxPoint x="${e.to.x}" y="${e.to.y}"/>`;return`${n}${r.replace(a,o)}${i}`})}return n}function Rd(e){return e.flatMap(e=>{let t=/set x="(-?[\d.]+)"(?: y="(-?[\d.]+)")? in the mxGeometry of "([^"]+)"/.exec(e);return t?[{cell:t[3],x:t[1],...t[2]===void 0?{}:{y:t[2]}}]:[]})}function zd(e,t){let n=e;for(let e of t){let t=e.cell.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n=n.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${t}"[^>]*>\\s*<mxGeometry\\b)([^>]*?)(/?>)`),(t,n,r,i)=>{let a=(e,t,n)=>RegExp(`\\b${t}="[^"]*"`).test(e)?e.replace(RegExp(`\\b${t}="[^"]*"`),`${t}="${n}"`):`${e} ${t}="${n}"`,o=a(r,`x`,e.x);return e.y!==void 0&&(o=a(o,`y`,e.y)),`${n}${o}${i}`})}return n}function Bd(e,t,n){let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return e.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${r}"[^>]*>\\s*<mxGeometry\\b[^>]*?)(/>|>)`),(e,t,r)=>r===`/>`?`${t}><Array as="points">${n}</Array></mxGeometry>`:`${t}><Array as="points">${n}</Array>`)}function Vd(e){return e.flatMap(e=>{let t=/Fix "([^"]{1,200})"(?: \([^)]{0,80}\))?: add a waypoint at \((-?\d+), (-?\d+)\)/.exec(e);return t?[{wire:t[1],at:{x:Number(t[2]),y:Number(t[3])}}]:[]})}function Hd(e,t){let n=e;for(let e of t){let t=e.wire.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=`<Array as="points"><mxPoint x="${e.at.x}" y="${e.at.y}"/></Array>`;n=n.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${t}"[^>]*>\\s*<mxGeometry\\b[^>]*?)(/>|>)`),(e,t,n)=>n===`/>`?`${t}>${r}</mxGeometry>`:`${t}>${r}`)}return n}function Ud(e){return e.flatMap(e=>{let t=/Fix it: line up the shapes it joins, whose middles are \d+ units apart: move "([^"]{1,200})"(?: \([^)]{0,80}\))? by ([+-]?\d+) on (x|y)/.exec(e);return t?[{shape:t[1],by:Number(t[2]),axis:t[3]}]:[]})}function Wd(e,t){let n=e;for(let e of t){let t=e.shape.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n=n.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${t}"[^>]*>\\s*<mxGeometry\\b[^>]*?\\b${e.axis}=")(-?[\\d.]+)`),(t,n,r)=>`${n}${Number(r)+e.by}`)}return n}function Gd(e){return new Set(e.flatMap(e=>{let t=/^connector "([^"]+)".*(?:Fix it: remove its waypoints|and remove its waypoints)/.exec(e);return t?[t[1]]:[]}))}function Kd(e,t){let n=e;for(let e of t){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);n=n.replace(RegExp(`(<mxCell\\b[^>]*\\bid="${t}"${jd})<Array as="points">[\\s\\S]*?</Array>`),`$1`)}return n}function qd(e,t){return e.replace(/<mxCell\b[^>]*>/g,e=>{let n=/\bid="([^"]*)"/.exec(e)?.[1],r=n===void 0?void 0:t.get(n);return r?e.replace(/\bstyle="([^"]*)"/,(e,t)=>{let n=t;for(let[e,t]of Object.entries(r))n=Md(n,e,t);return`style="${n}"`}):e})}var Jd=/at the same point|facing away|runs .* units to join|runs through its (source|target)|needless bend|lies on the label|lies across connector|run along the same line/;function Yd(e,t=12,n,r={}){let i=e,a=new Set,o=r.only??(()=>!0);for(let e=0;;e++){let s=kd(i).issues.map(e=>e.message),c=s.filter(e=>Jd.test(e));n?.(e,c);let l=new Map([...Nd(s)].filter(([e])=>o(e))),u=Id(s).filter(e=>o(e.wire)),d=new Set([...Gd(s)].filter(o)),f=r.moveShapes===!1?[]:Ud(s).filter(e=>o(e.shape)),p=Rd(s).filter(e=>o(e.cell)),m=Vd(s).filter(e=>o(e.wire)),h=Pd(s).filter(e=>o(e.wire));if(l.size===0&&d.size===0&&u.length===0&&f.length===0&&p.length===0&&m.length===0&&h.length===0)return{rounds:e,converged:c.length===0,looped:!1,left:c,xml:i};let g=Fd(Hd(zd(Wd(Ld(Kd(qd(i,l),d),u),f),p),m),h);if(g===i||a.has(g)||e>=t)return{rounds:e,converged:!1,looped:!0,left:c,xml:i};a.add(i),i=g}}var Xd=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/\n/g,`&#10;`),Zd=(e,t)=>t===void 0?``:` ${e}="${Xd(t)}"`;function Qd(e){let t=[`x`,`y`,`width`,`height`].map(t=>e[t]===0?``:` ${t}="${e[t]}"`).join(``),n=[e.points.length===0?``:`<Array as="points">${e.points.map(e=>`<mxPoint x="${e.x}" y="${e.y}"/>`).join(``)}</Array>`,e.offset===void 0?``:`<mxPoint x="${e.offset.x}" y="${e.offset.y}" as="offset"/>`].join(``),r=`<mxGeometry${t}${e.relative?` relative="1"`:``} as="geometry"`;return n===``?`${r}/>`:`${r}>${n}</mxGeometry>`}function $d(e){let t=`${e.vertex?` vertex="1"`:``}${e.edge?` edge="1"`:``}`,n=`<mxCell${Zd(`id`,e.id)}${Zd(`value`,e.label===``?void 0:e.label)}${Zd(`style`,e.style===``?void 0:e.style)}${t}${Zd(`parent`,e.parent)}${Zd(`source`,e.source)}${Zd(`target`,e.target)}`;return e.geometry===void 0?`${n}/>`:`${n}>${Qd(e.geometry)}</mxCell>`}function ef(e){return[`<mxfile host="pi-outpost">`,`<diagram${Zd(`name`,e.name)}>`,`<mxGraphModel><root>`,...e.cells.map($d),`</root></mxGraphModel>`,`</diagram>`,`</mxfile>`,``].join(`
9
9
  `)}var tf=`n:`,nf=`r:`,rf=e=>`${tf}${e}`,af=e=>`${nf}${e}`,of=e=>({...e,relative:!1,unreadable:[],sourcePoint:!1,targetPoint:!1,points:[]});function sf(e){let t=(e,t)=>t===void 0?``:`${e}X=${t.x};${e}Y=${t.y};`;return`edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;endArrow=block;${t(`exit`,e?.exit)}${t(`entry`,e?.entry)}`}function cf(e,t,n=new Map){let r=[{id:`0`,parent:void 0,vertex:!1,edge:!1,source:void 0,target:void 0,label:``,style:``,geometry:void 0},{id:`1`,parent:`0`,vertex:!1,edge:!1,source:void 0,target:void 0,label:``,style:``,geometry:void 0}];for(let[t,i]of e)r.push({id:rf(t),parent:`1`,vertex:!0,edge:!1,source:void 0,target:void 0,label:n.get(t)??t,style:`rounded=0;whiteSpace=wrap;html=1;`,geometry:of(i)});for(let n of t){if(!e.has(n.from)||!e.has(n.to))continue;let t=n.ends,i={...of({x:t?.label?.along??0,y:t?.label?.across??0,width:0,height:0}),relative:!0,points:(t?.waypoints??[]).map(e=>({...e}))};t?.label!==void 0&&(t.label.offset.x!==0||t.label.offset.y!==0)&&(i.offset={...t.label.offset}),r.push({id:af(n.index),parent:`1`,vertex:!1,edge:!0,source:rf(n.from),target:rf(n.to),label:n.label,style:sf(t),geometry:i})}return{name:`Figure`,cells:r}}function lf(e){let t=Cu(e),n=new Map;for(let r of e.cells){if(!r.edge||r.id===void 0||!r.id.startsWith(nf)||r.source===r.target)continue;let e=wu(r,t);if(e===void 0)continue;let i=Tu(e,{x:r.geometry?.x??0,y:r.geometry?.y??0},r.geometry?.offset);n.set(Number(r.id.slice(2)),{points:e.points,labelAt:i,span:xf(e.points,i)})}return n}var uf=.5;function df(e){let t=[];for(let n of e){let e=t[t.length-1];t.push(e===void 0?{x:ff(n.x),y:ff(n.y)}:{x:Math.abs(n.x-e.x)<uf?e.x:ff(n.x),y:Math.abs(n.y-e.y)<uf?e.y:ff(n.y)})}return t.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `)}var ff=e=>Math.round(e*100)/100,pf=10;function mf(e,t){let n=new Map;for(let e of t){if(e.from===e.to)continue;let t=JSON.stringify([e.from,e.to].sort());n.set(t,[...n.get(t)??[],e])}let r=new Map;for(let t of n.values()){if(t.length<2)continue;let n=e.get(t[0].from),i=e.get(t[0].to);if(n===void 0||i===void 0)continue;let a=gf(n,i)?Math.min(n.height,i.height):Math.min(n.width,i.width),o=Math.max(1,Math.min(t.length,Math.floor(a/pf)-1)),s=t.length-o;t.forEach((t,n)=>{let i=e.get(t.from),a=e.get(t.to);if(i===void 0||a===void 0)return;if(n<o){let e=hf((n+1)/(o+1));r.set(t.index,{exit:_f(i,a,e),entry:_f(a,i,e)});return}let c=n-o,l=c%2==1,u=Math.floor(c/2)+1,d=hf(u/(Math.ceil(s/2)+1)),f=gf(i,a),p=f?{x:d,y:+!!l}:{x:+!!l,y:d},m=20*u,h=f?[i,a].map(e=>({x:Math.round(e.x+e.width*d),y:l?Math.max(i.y+i.height,a.y+a.height)+m:Math.min(i.y,a.y)-m})):[i,a].map(e=>({x:l?Math.max(i.x+i.width,a.x+a.width)+m:Math.min(i.x,a.x)-m,y:Math.round(e.y+e.height*d)}));r.set(t.index,{exit:p,entry:{...p},waypoints:h})})}return r}var hf=e=>Math.round(e*1e4)/1e4;function gf(e,t){return Math.abs(t.x+t.width/2-(e.x+e.width/2))>=Math.abs(t.y+t.height/2-(e.y+e.height/2))}function _f(e,t,n){let r=t.x+t.width/2-(e.x+e.width/2),i=t.y+t.height/2-(e.y+e.height/2);return Math.abs(r)>=Math.abs(i)?{x:+(r>=0),y:n}:{x:n,y:+(i>=0)}}function vf(e,t,n){for(let[r,i]of t)if(!n.includes(r)){for(let t=1;t<e.length;t++)if(Du(e[t-1],e[t],i,`box`,2)>0)return!0}return!1}function yf(e,t,n){let r=lf(cf(e,t)),i=new Map;for(let a of t){let t=r.get(a.index),o=n.get(a.index);if(t===void 0||o===void 0||o.length<3||!vf(t.points,e,[a.from,a.to]))continue;let s=o.slice(1,-1).map(e=>({x:Math.round(e.x),y:Math.round(e.y)}));i.set(a.index,s)}return i}function bf(e,t){if(t.size===0)return e;let n=new Set([...t].map(af)),[r]=pd(Yd(ef(e),12,void 0,{only:e=>n.has(e),moveShapes:!1}).xml);return r===void 0?e:{...r,name:e.name}}function xf(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n],a=Math.min(r.x,i.x)-1<=t.x&&t.x<=Math.max(r.x,i.x)+1,o=Math.min(r.y,i.y)-1<=t.y&&t.y<=Math.max(r.y,i.y)+1;if(a&&o)return Math.abs(r.y-i.y)<uf?Math.abs(i.x-r.x):Math.abs(i.y-r.y)>=28?1/0:0}return 0}function Sf(e,t,n){let r=t.y>=e.y+e.height,i=t.y+t.height<=e.y,a=t.x>=e.x+e.width,o=t.x+t.width<=e.x;return n?r?`bottom`:i?`top`:t.x+t.width/2>=e.x+e.width/2?`right`:`left`:a?`right`:o?`left`:t.y+t.height/2>=e.y+e.height/2?`bottom`:`top`}var Cf=(e,t)=>e===`top`?{x:t,y:0}:e===`bottom`?{x:t,y:1}:e===`left`?{x:0,y:t}:{x:1,y:t};function wf(e,t,n){let r=new Map,i=t.filter(e=>e.ends===void 0&&e.from!==e.to);for(let t of i){let i=e.get(t.from),a=e.get(t.to);if(i!==void 0&&a!==void 0)for(let[e,o,s,c]of[[`exit`,i,a,t.from],[`entry`,a,i,t.to]]){let i=Sf(o,s,n),a=`${c}\u0000${i}`;r.set(a,[...r.get(a)??[],{relationship:t,role:e,side:i,other:s}])}}let a=new Map,o=new Set;for(let e of r.values()){let t=e=>e.side===`top`||e.side===`bottom`?e.other.x+e.other.width/2:e.other.y+e.other.height/2,n=[...e].sort((e,n)=>t(e)-t(n)||e.relationship.index-n.relationship.index||(e.role===`exit`?-1:1));n.forEach((e,t)=>a.set(`${e.relationship.index}:${e.role}`,Cf(e.side,hf((t+1)/(n.length+1))))),n.length===1&&o.add(`${n[0].relationship.index}:${n[0].role}`)}let s=new Map;for(let t of i){let n=a.get(`${t.index}:exit`),r=a.get(`${t.index}:entry`);if(n===void 0||r===void 0)continue;let i=e.get(t.from),c=e.get(t.to);if(o.has(`${t.index}:exit`)&&o.has(`${t.index}:entry`)){let e=Tf(i,c,n,r);if(e!==void 0){s.set(t.index,e);continue}}s.set(t.index,{exit:n,entry:r})}return s}function Tf(e,t,n,r){let i=(n.y===0||n.y===1)&&(r.y===0||r.y===1)&&n.y!==r.y,a=(n.x===0||n.x===1)&&(r.x===0||r.x===1)&&n.x!==r.x;if(!i&&!a)return;let o=i?Math.max(e.x,t.x):Math.max(e.y,t.y),s=i?Math.min(e.x+e.width,t.x+t.width):Math.min(e.y+e.height,t.y+t.height);if(s-o<2)return;let c=Math.round((o+s)/2),l=e=>hf(i?(c-e.x)/e.width:(c-e.y)/e.height);return i?{exit:{x:l(e),y:n.y},entry:{x:l(t),y:r.y}}:{exit:{x:n.x,y:l(e)},entry:{x:r.x,y:l(t)}}}function Ef(e,t){let n=lf(e);return{...e,cells:e.cells.map(e=>{if(!e.edge||e.id===void 0||!e.id.startsWith(nf)||e.geometry===void 0)return e;let r=Number(e.id.slice(2)),i=n.get(r);if(!t.has(r)||i===void 0||i.points.length<3)return e;let a=i.points.slice(1).map((e,t)=>Math.hypot(e.x-i.points[t].x,e.y-i.points[t].y)),o=a.reduce((e,t)=>e+t,0);if(o===0)return e;let s=a.indexOf(Math.max(...a)),c=a.slice(0,s).reduce((e,t)=>e+t,0)+a[s]/2;return{...e,geometry:{...e.geometry,x:hf((c/o-.5)*2)}}})}}var Df=4;function Of(e,t){return t!==void 0&&e.nodes.some(e=>t.elements[El(e)]!==void 0)}var kf=(e,t,n)=>e.x<t.x+t.width+n&&t.x<e.x+e.width+n&&e.y<t.y+t.height+n&&t.y<e.y+e.height+n;function Af(e,t,n,r){let i=new Map(e.nodes.map(e=>[e.id,El(e)])),a=new Map,o=[];for(let r of e.nodes){let e=t.elements[i.get(r.id)];if(e===void 0)continue;let{width:s,height:c}=n(r);a.set(r.id,{id:r.id,x:e.x,y:e.y,width:s,height:c}),o.push(r.id)}let s=new Set(i.values()),c=Object.keys(t.elements).filter(e=>!s.has(e)).sort(),l=new Map;for(let t of e.edges)t.from!==t.to&&(l.set(t.from,[...l.get(t.from)??[],t.to]),l.set(t.to,[...l.get(t.to)??[],t.from]));let u=r===`landscape`,d=e=>[...a.values()].every(t=>!kf(e,t,24)),f=[],p=[],m=e.nodes.filter(e=>!a.has(e.id));for(;m.length>0;){let e=Math.max(0,m.findIndex(e=>(l.get(e.id)??[]).some(e=>a.has(e)))),t=m.splice(e,1)[0],{width:r,height:i}=n(t),s=(e,n)=>({id:t.id,...Nl({x:e,y:n}),width:r,height:i}),c=(l.get(t.id)??[]).map(e=>a.get(e)).filter(e=>e!==void 0)[0],h;if(c===void 0){let e=[...a.values()];h=e.length===0?s(24,24):u?s(Math.max(...e.map(e=>e.x+e.width))+64,Math.min(...e.map(e=>e.y))):s(Math.min(...e.map(e=>e.x)),Math.max(...e.map(e=>e.y+e.height))+64)}else{let e=u?{dx:c.width+64,dy:0}:{dx:0,dy:c.height+64},t=u?{dx:-(r+64),dy:0}:{dx:0,dy:-(i+64)},n=u?{dx:0,dy:c.height+24}:{dx:c.width+24,dy:0},l=u?i+24:r+24,f=[];for(let r=0;r<=Df;r++){for(let n of[e,t]){let e=r*l;for(let t of r===0?[0]:[1,-1])f.push(u?s(c.x+n.dx,c.y+t*e):s(c.x+t*e,c.y+n.dy))}for(let e of[1,-1]){let t=r+1;f.push(u?s(c.x,c.y+e*t*n.dy):s(c.x+e*t*n.dx,c.y))}}if(h=f.find(d),h===void 0){let t=s(c.x+e.dx,c.y+e.dy);h=t;let n=[...a.values()].filter(e=>u?e.x+e.width+24>t.x:e.y+e.height+24>t.y).sort((e,t)=>e.id.localeCompare(t.id)),l=Math.min(...n.map(e=>u?e.x:e.y)),d=Math.max(0,(u?t.x+r:t.y+i)+64-l);for(let e of n){if(d===0)break;o.includes(e.id)&&p.push({id:e.id,from:{x:e.x,y:e.y}}),u?e.x+=d:e.y+=d}}}a.set(t.id,h),f.push(t.id)}return{boxes:e.nodes.map(e=>a.get(e.id)),arranged:o,placed:f,shifted:p,gone:c}}function jf(e,t,n){let r={...n===void 0?{}:{orientation:n},elements:{},relationships:{}},i=new Map(t.cells.filter(e=>e.id!==void 0).map(e=>[e.id,e]));for(let t of e.nodes){let e=i.get(rf(t.id))?.geometry;e!==void 0&&(r.elements[El(t)]=Nl({x:e.x,y:e.y}))}return Dl(e).forEach((e,t)=>{let n=i.get(af(t));if(n===void 0||n.geometry===void 0)return;let a=Bl(n.style,!0),o=e=>{let t=Number(a[`${e}X`]),n=Number(a[`${e}Y`]);return a[`${e}X`]===void 0||a[`${e}Y`]===void 0||!Number.isFinite(t)||!Number.isFinite(n)?void 0:{x:t,y:n}},s={},c=o(`exit`),l=o(`entry`);c!==void 0&&(s.exit=c),l!==void 0&&(s.entry=l),n.geometry.points.length>0&&(s.waypoints=n.geometry.points.map(e=>({x:Math.round(e.x),y:Math.round(e.y)})));let u=n.geometry.offset??{x:0,y:0};(n.geometry.x!==0||n.geometry.y!==0||u.x!==0||u.y!==0)&&(s.label={along:n.geometry.x,...n.geometry.y===0?{}:{across:n.geometry.y},offset:{x:u.x,y:u.y}}),r.relationships[e]=s}),r}function Mf(e,t,n,r,i,a){let o=jf(e,t,a),s={orientation:a,elements:{...n?.elements,...o.elements},relationships:{...n?.relationships,...o.relationships}},c=e.nodes.find(e=>e.id===r);return c===void 0||(s.elements[El(c)]=Nl(i),Dl(e).forEach((t,n)=>{let i=e.edges[n];(i.from===r||i.to===r)&&delete s.relationships[t]})),s}var Nf=`#ffffff`,Pf=`#27272a`,Ff=`#71717a`,If={added:{fill:`#ecfdf5`,stroke:`#059669`,text:`#065f46`},changed:{fill:`#fffbeb`,stroke:`#d97706`,text:`#92400e`},context:{fill:`#fafafa`,stroke:`#d4d4d8`,text:`#71717a`},unchanged:{fill:`#ffffff`,stroke:`#a1a1aa`,text:Pf}},Lf={added:`#059669`,changed:`#d97706`,context:`#d4d4d8`,unchanged:`#a1a1aa`},Rf=[`added`,`changed`,`context`,`unchanged`],zf=[{fill:`#eff6ff`,stroke:`#2563eb`},{fill:`#f5f3ff`,stroke:`#7c3aed`},{fill:`#ecfeff`,stroke:`#0891b2`},{fill:`#fff1f2`,stroke:`#e11d48`},{fill:`#f7fee7`,stroke:`#65a30d`},{fill:`#fff7ed`,stroke:`#ea580c`},{fill:`#f0fdfa`,stroke:`#0d9488`},{fill:`#fdf4ff`,stroke:`#c026d3`},{fill:`#fefce8`,stroke:`#ca8a04`},{fill:`#f8fafc`,stroke:`#475569`},{fill:`#eef2ff`,stroke:`#4f46e5`},{fill:`#fef2f2`,stroke:`#b91c1c`},{fill:`#f0fdf4`,stroke:`#16a34a`},{fill:`#fdf2f8`,stroke:`#db2777`},{fill:`#f5f5f4`,stroke:`#78716c`},{fill:`#f0f9ff`,stroke:`#0369a1`}],Bf=[void 0,`7 3`,`2 3`,`9 3 2 3`],Vf=zf.length*Bf.length;function Hf(e,t=.88){let n=n=>{let r=Number.parseInt(e.slice(1+n*2,3+n*2),16);return Math.round(r+(255-r)*t).toString(16).padStart(2,`0`)};return`#${n(0)}${n(1)}${n(2)}`}function Uf(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t}zf.length;function Wf(e,t,n={}){let r=n.dashes===!1,i=Vf,a=new Map,o=new Set,s=e=>t!==void 0&&Object.hasOwn(t,e)?t[e].color:void 0,c=new Set;for(let t of e){let e=s(t);e!==void 0&&(a.set(t,{fill:Hf(e),stroke:e,declared:!0}),c.add(e.toLowerCase()))}for(let e=0;e<i;e++)c.has(zf[e%zf.length].stroke.toLowerCase())&&o.add(e);for(let t of e){if(a.has(t))continue;let e;if(r){e=-1;let n=Uf(t)%zf.length;for(let t=0;t<zf.length&&e===-1;t++){let r=(n+t)%zf.length;o.has(r)||(e=r)}for(let t=zf.length;t<Vf&&e===-1;t++){let r=zf.length+(n+t)%(Vf-zf.length);o.has(r)||(e=r)}e===-1&&(e=n)}else{e=Uf(t)%i;for(let t=0;t<i&&o.has(e);t++)e=(e+1)%i}o.add(e);let n=zf[e%zf.length],s=Math.floor(e/zf.length)%Bf.length;if(r)a.set(t,{...n,...s===0?{}:{hatch:s}});else{let e=Bf[s];a.set(t,{...n,...e===void 0?{}:{dash:e}})}}return a}function Gf(e,t){let n=new Map;for(let r of e){let e=t.get(r);if(e?.declared!==!0)continue;let i=e.stroke.toLowerCase();n.set(i,[...n.get(i)??[],r])}let r=new Map;for(let e of n.values())if(!(e.length<2))for(let t of e)r.set(t,e.filter(e=>e!==t));return r}function Kf(e){let t=[];for(let n of e)n.kind!==void 0&&n.kind!==``&&!t.includes(n.kind)&&t.push(n.kind);return t}var qf=`system-ui, Segoe UI, Arial, Helvetica, sans-serif`;function Jf(e){let t=If[e.role],n={fill:e.tint?.fill??t.fill,stroke:e.role===`unchanged`?e.tint?.stroke??t.stroke:t.stroke,text:t.text===`#71717a`?Ff:Pf},r=e.role===`added`||e.role===`changed`?2:1.2,i=e.role===`context`?.62:1,a=e.anchor??`start`,o=De(e.label,e.width),s=ke(e.changes,e.width),c=o.length+s.length,l=e.y+e.height/2-(c-1)*15/2+4,u=a===`middle`?e.x+e.width/2:e.x+8,d=[{shape:`rect`,x:e.x,y:e.y,width:e.width,height:e.height,rx:5,fill:n.fill,stroke:n.stroke,strokeWidth:r,...e.tint?.dash===void 0?{}:{strokeDasharray:e.tint.dash},opacity:i}];return o.forEach((e,t)=>{d.push({shape:`text`,x:u,y:l+t*15,text:e,fontSize:11,fill:n.text,fontFamily:qf,textAnchor:a,opacity:i})}),s.forEach((e,t)=>{d.push({shape:`text`,x:u,y:l+(o.length+t)*15,text:e,fontSize:9,fontWeight:600,fill:n.text,fontFamily:qf,textAnchor:a,opacity:i,testId:`field-changes`})}),d}function Yf(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function Xf(e){return Yf(e).replace(/"/g,`&quot;`)}function Zf(e){return e.filter(([,e])=>e!==void 0).map(([e,t])=>` ${e}="${Xf(String(t))}"`).join(``)}function Qf(e){let t=Object.entries(e.data??{}).map(([e,t])=>[`data-${e}`,t]);switch(e.shape){case`rect`:return`<rect${Zf([[`x`,e.x],[`y`,e.y],[`width`,e.width],[`height`,e.height],[`rx`,e.rx],[`fill`,e.fill],[`fill-opacity`,e.fillOpacity],[`stroke`,e.stroke],[`stroke-width`,e.strokeWidth],[`stroke-dasharray`,e.strokeDasharray],[`opacity`,e.opacity],...t])} />`;case`text`:{let n=`${Yf(e.text)}${e.note===void 0?``:` <tspan font-style="italic">${Yf(e.note)}</tspan>`}`,r=[[`x`,e.x],[`y`,e.y],[`font-size`,e.fontSize],[`font-family`,e.fontFamily],[`font-weight`,e.fontWeight],[`font-style`,e.fontStyle],[`text-anchor`,e.textAnchor]],i=`<text${Zf([...r,[`fill`,e.fill],...e.paintOrder===`stroke`?[]:[[`stroke`,e.stroke],[`stroke-width`,e.strokeWidth]],[`text-decoration`,e.textDecoration],[`opacity`,e.opacity],[`data-testid`,e.testId],...t])}>${n}</text>`;return e.paintOrder===`stroke`?`<text${Zf([...r,[`fill`,e.stroke],[`stroke`,e.stroke],[`stroke-width`,e.strokeWidth],[`opacity`,e.opacity],[`aria-hidden`,`true`]])}>${n}</text>${i}`:i}case`line`:return`<line${Zf([[`x1`,e.x1],[`y1`,e.y1],[`x2`,e.x2],[`y2`,e.y2],[`stroke`,e.stroke],[`stroke-width`,e.strokeWidth],[`stroke-dasharray`,e.strokeDasharray],[`opacity`,e.opacity],[`marker-end`,e.markerEnd===void 0?void 0:`url(#${e.markerEnd})`],...t])} />`;case`path`:return`<path${Zf([[`d`,e.d],[`stroke`,e.stroke],[`fill`,e.fill??`none`],[`stroke-width`,e.strokeWidth],[`stroke-dasharray`,e.strokeDasharray],[`stroke-linecap`,e.strokeLinecap],[`opacity`,e.opacity],[`marker-end`,e.markerEnd===void 0?void 0:`url(#${e.markerEnd})`],...t])} />`}}function $f(e){return`<marker id="${Xf(e.id)}" markerWidth="7" markerHeight="7" refX="9" refY="5" viewBox="0 0 10 10" markerUnits="userSpaceOnUse" orient="auto"><path d="M0,0 L10,5 L0,10 z" fill="${Xf(e.paint)}" /></marker>`}function ep(e){let t=e=>{let n=Object.entries(e.data??{}).map(([e,t])=>[`data-${e}`,t]),r=e.title===void 0?``:`<title>${Yf(e.title)}</title>`,i=[[`opacity`,e.opacity],[`data-testid`,e.testId]];return`<g${Zf([...n,...i])}>${r}`+e.primitives.map(Qf).join(``)+(e.groups??[]).map(t).join(``)+`</g>`},n=e.groups.map(t).join(``),r=e.markers.length===0?``:`<defs>${e.markers.map($f).join(``)}</defs>`;return`<svg xmlns="http://www.w3.org/2000/svg" role="img"`+Zf([[`aria-label`,e.ariaLabel],[`viewBox`,e.viewBox],[`width`,e.width],[`height`,e.height]])+`><rect${Zf([[`x`,e.viewBox.split(` `)[0]],[`y`,e.viewBox.split(` `)[1]],[`width`,e.width],[`height`,e.height],[`fill`,e.background]])} />`+r+n+`</svg>`}var tp=17,np=18,rp=92,ip=860;function ap(e){return Math.min(e,ip)}function op(e){return 21+(e.length+9)*5.6+np}function sp(e,t){let n=ap(t),r=1,i=0;for(let t of e.entries){let e=op(t.label);i>0&&rp+i+e>n-20&&(r+=1,i=0),i+=e}return r}function cp(e){let t=e.flatMap(e=>e.entries).reduce((e,t)=>Math.max(e,op(t.label)),0);return t===0?0:Math.min(rp+t+32,ip)}function lp(e,t){let n=e.filter(e=>e.entries.length>0);return n.length===0?0:n.reduce((e,n)=>e+sp(n,t),0)*tp+12}function up(e,t,n,r){let i=e.filter(e=>e.entries.length>0);if(i.length===0)return[];let a=ap(r),o=[],s=0;for(let e of i){let r=s,i=0,c=[];for(let r of e.entries){let o=op(r.label);i>0&&rp+i+o>a-20&&(s+=1,i=0);let l=t+rp+i,u=n+s*tp;i+=o;let d=e.sample===`line`?{shape:`line`,x1:l,y1:u+5,x2:l+16,y2:u+5,stroke:r.stroke,strokeWidth:1.6,...r.dashed===void 0?{}:{strokeDasharray:r.dashed}}:{shape:`rect`,x:l,y:u,width:16,height:10,rx:2,fill:r.fill,stroke:r.stroke,strokeWidth:1.2,...r.dashed===void 0?{}:{strokeDasharray:r.dashed}};c.push({id:`legend-${r.key??r.label}`,...r.projectColour===!0?{title:`${r.label} — project colour`}:{},data:{"legend-entry":r.key??r.label,...r.projectColour===!0?{"colour-source":`project`}:{},...r.toggles===!0&&r.key!==void 0?{toggles:`true`}:{},...r.faded===!0?{faded:`true`}:{},...r.hidden===!0?{hidden:`true`}:{}},opacity:r.hidden===!0?.45:r.faded===!0?.62:1,primitives:[d,{shape:`text`,x:l+21,y:u+9,text:r.hidden===!0?`${r.label} (hidden)`:r.label,fontSize:9,fill:Ff,fontFamily:qf}]})}o.push({id:`legend-title-${e.title}`,primitives:[{shape:`text`,x:t,y:n+r*tp+9,text:e.title,fontSize:9,fontWeight:600,fill:Ff,fontFamily:qf,testId:`legend-group`}]}),o.push(...c),s+=1}return[{id:`diagram-legend`,testId:`diagram-legend`,primitives:[],groups:o}]}var dp=12,fp=5.2;function pp(e,t){let n=Math.max(Math.floor((t-24)/fp),20),r=[],i=``;for(let t of e.split(/\s+/).filter(e=>e!==``))for(i===``?i=t:i.length+1+t.length<=n?i=`${i} ${t}`:(r.push(i),i=t);i.length>n;)r.push(i.slice(0,n)),i=i.slice(n);return i!==``&&r.push(i),r}function mp(e){let t=e.length;for(;t>0&&(e[t-1]===`.`||/\s/.test(e[t-1]));)--t;return e.slice(0,t)}function hp(e,t,n,r,i){let a=`${t.nodes.length} of ${e.nodes.length} elements and ${t.edges.length} of ${e.edges.length} relationships shown.`+(r?` Hidden types are still part of the proposal.`:``);if(i===void 0)return n.size===0?void 0:`Filtered view: ${a}`;let o=!sl(n,ol(e,i));return`Viewpoint: ${i.label} — ${mp(i.concern)}`+(o?` (adjusted).`:`.`)+(n.size===0?``:` ${a}`)}function gp(e,t){return`${e}-${t.replace(`#`,``)}`}function _p(e){let t=Ee([Zc(e)],jc(e),120,260);return{width:t,height:Oe(De(Zc(e),t).length,ke(jc(e),t).length)}}function vp(e,t){let n=e.nodes.filter(e=>!il(t,`element`,e.kind)),r=new Set(n.map(e=>e.id));return{nodes:n,edges:e.edges.filter(e=>!il(t,`relationship`,e.kind)&&r.has(e.from)&&r.has(e.to)),containers:e.containers}}function yp(e,t,n){return{label:n===void 0?e:`${e} (same colour as ${n.join(`, `)})`,fill:t.fill,stroke:t.stroke,...t.dash===void 0?{}:{dashed:t.dash},...t.declared===!0?{projectColour:!0}:{}}}function bp(e,t){if(t!==void 0)return{layout:Kc(e,_p,t),orientation:t};let n=Kc(e,_p,`landscape`);if(n.width<=710)return{layout:n,orientation:`landscape`};let r=Kc(e,_p,`portrait`);return h(n.width,r.width)===`portrait`?{layout:r,orientation:`portrait`}:{layout:n,orientation:`landscape`}}function xp(e,t=rl){return bp(vp(e,t),void 0).orientation}function Sp(e,t,n,r,i){let a=new Map,o=new Map;for(let e of t.nodes){let t=n(e.id);t!==void 0&&a.set(e.id,{x:t.x,y:t.y,width:t.w,height:t.h})}for(let t of e.nodes)o.set(t.id,Zc(t));let s=e.edges.map((e,t)=>({index:t,from:e.from,to:e.to,label:e.label??e.kind??``})),c=mf(a,s),l=Dl(e),u=new Map;l.forEach((e,t)=>{let n=r?.relationships[e];n!==void 0&&u.set(t,n)});let d=s.map(e=>({...e,ends:u.get(e.index)??c.get(e.index)})),f=wf(a,d,i===`portrait`),p=d.map(e=>({...e,ends:e.ends??f.get(e.index)})),m=new Map(t.edges.map(e=>[e.index,e.points])),h=yf(a,p.filter(e=>!u.has(e.index)),m),g=cf(a,p.map(e=>{let t=h.get(e.index);return t===void 0?e:{...e,ends:{...e.ends,waypoints:t}}}),o),_=new Set(s.filter(e=>!u.has(e.index)&&c.get(e.index)?.waypoints===void 0).map(e=>e.index)),v=bf(Ef(g,_),_);return{page:v,wires:lf(v)}}function Cp(e,t={}){let n=vp(e,t.hidden??rl),{layout:r,orientation:i,placement:a}=wp(n,t.orientation,t.arrangement),o=new Map(r.nodes.map(e=>[e.id,e]));return{shown:n,page:Sp(n,r,e=>{let t=o.get(e);return t===void 0?void 0:{x:t.x,y:t.y,cx:t.x+t.width/2,cy:t.y+t.height/2,w:t.width,h:t.height}},t.arrangement,i).page,orientation:i,...a===void 0?{}:{placement:a}}}function wp(e,t,n){let r=t??n?.orientation;if(n===void 0||!Of(e,n)){let t=bp(e,r),n=t.layout.nodes.map(e=>({...e,...Nl({x:e.x,y:e.y})}));return{...t,layout:{...t.layout,nodes:n}}}let i=r??`landscape`,a=Af(e,n,_p,i),o=a.boxes.map(e=>({...e})),s=new Map(o.map(e=>[e.id,e])),c=[],l=Math.max(0,...o.map(e=>e.y+e.height))+16;for(let t of e.containers??[]){let n=Lc(e.nodes.filter(e=>e.container===t.id).flatMap(e=>{let t=s.get(e.id);return t===void 0?[]:[t]}));n===void 0?(c.push({id:t.id,label:t.label,x:12,y:l,width:160,height:52}),l+=68):c.push({id:t.id,label:t.label,...n})}let u=Math.max(0,...o.map(e=>e.x+e.width),...c.map(e=>e.x+e.width)),d=Math.max(0,...o.map(e=>e.y+e.height),...c.map(e=>e.y+e.height));return{layout:{nodes:o,edges:[],containers:c,width:u+12,height:d+12},orientation:i,placement:a}}function Tp(e,t){let n=t.hidden??rl,r=t.nudges??new Map,i=t.isProposal,a=vp(e,n),{layout:o,orientation:s,placement:c}=wp(a,t.orientation,t.arrangement),l=new Map(o.nodes.map(e=>[e.id,e])),u=e=>{let t=l.get(e);if(t===void 0)return;let n=r.get(e),i=t.x+(n?.dx??0),a=t.y+(n?.dy??0);return{x:i,y:a,cx:i+t.width/2,cy:a+t.height/2,w:t.width,h:t.height}},d=o.containers.map(e=>{let t=Lc(a.nodes.filter(t=>t.container===e.id).flatMap(e=>{let t=u(e.id);return t===void 0?[]:[{x:t.x,y:t.y,width:t.w,height:t.h}]}));return t===void 0?e:{...e,...t}}),f=Wf(Kf(e.nodes),t.appearance?.kinds),p=Wf(Kf(e.edges),t.appearance?.relationshipKinds),m=Gf(Kf(e.nodes),f),h=Gf(Kf(e.edges),p),g=e=>t=>({...yp(t,(e===`element`?f:p).get(t),(e===`element`?m:h).get(t)),toggles:!0,key:nl(e,t),hidden:n.has(nl(e,t))}),_=[{title:`elements`,sample:`box`,entries:Kf(e.nodes).map(g(`element`))},{title:`relationships`,sample:`line`,entries:Kf(e.edges).map(g(`relationship`))}];if(i){let e=new Set([...a.nodes.map(e=>Oc(e,!0)),...a.edges.map(e=>Ac(e,!0))]);_.push({title:`changes`,sample:`box`,entries:Rf.filter(t=>t!==`unchanged`&&e.has(t)).map(e=>({label:Mc[e],fill:Nf,stroke:If[e].stroke,faded:e===`context`}))})}let v=new Map,y=new Map;for(let e of a.edges){let t=JSON.stringify([e.from,e.to]),n=y.get(t)??0;v.set(e,n),y.set(t,n+1)}let{wires:b}=Sp(a,o,u,t.arrangement,s),x=a.edges.map((e,t)=>{let n=u(e.from),r=u(e.to);if(n===void 0||r===void 0)return;let i=b.get(t);return i===void 0?ml(n,e.from===e.to?n:r,void 0,v.get(e)??0):{d:df(i.points),labelAt:i.labelAt,span:i.span}}),S=o.nodes.map(e=>u(e.id)),C=x.flatMap(e=>{let t=e===void 0?void 0:hl(e.d);return t===void 0?[]:[t]}),w=(r.size>0||c!==void 0)&&S.length>0,T=d.map(e=>({x:e.x,y:e.y,w:e.width,h:e.height})),E=e=>w?[]:[e],ee=Math.min(...E(0),...S.map(e=>e.x-12),...T.map(e=>e.x-12),...C.map(e=>e.minX-12)),D=Math.min(...E(0),...S.map(e=>e.y-12),...T.map(e=>e.y-14),...C.map(e=>e.minY-14)),te=Math.max(...E(o.width),...S.map(e=>e.x+e.w+12),...T.map(e=>e.x+e.w+12),...C.map(e=>e.maxX+12)),ne=Math.max(...E(o.height),...S.map(e=>e.y+e.h+12),...T.map(e=>e.y+e.h+12),...C.map(e=>e.maxY+12)),re=e=>{let t=Ac(e,i),n=e.kind===void 0?void 0:p.get(e.kind);return{role:t,stroke:n?.stroke??Lf.unchanged,dash:n?.dash,halo:t===`added`||t===`changed`?Lf[t]:void 0,width:t===`context`?1:t===`unchanged`?1.5:1.8,opacity:t===`context`?.6:1}},ie=[...new Set(a.edges.map(e=>re(e).stroke))],ae=ne+4,oe=Math.max(te-ee,cp(_)),se=hp(e,a,n,i,t.viewpoint),ce=t.viewpoint===void 0||se===void 0?0:pp(se,oe).length*dp+4,le=ne-D+lp(_,oe)+ce,ue=[];for(let e of d)ue.push({id:`container-${e.id}`,data:{container:e.id},primitives:[{shape:`rect`,x:e.x,y:e.y,width:e.width,height:e.height,rx:8,fill:`none`,stroke:Ff,strokeDasharray:`5 3`,opacity:.55},{shape:`text`,x:e.x+8,y:e.y+12,text:e.label,fontSize:10,fill:Ff}]});a.edges.forEach((t,n)=>{let r=u(t.from),i=u(t.to),a=x[n];if(r===void 0||i===void 0||a===void 0)return;let o=re(t),s=o.stroke,c=jc(t),l=t.label??t.kind,d=e=>e.length*5.2+8<=a.span,f=[];o.halo!==void 0&&f.push({shape:`path`,data:{edge:`role`},d:a.d,fill:`none`,stroke:o.halo,strokeWidth:o.width+4,strokeLinecap:`round`,opacity:.3}),f.push({shape:`path`,data:{edge:`line`},d:a.d,fill:`none`,stroke:s,strokeWidth:o.width,...o.dash===void 0?{}:{strokeDasharray:o.dash},opacity:o.opacity,markerEnd:gp(`se-arrow`,s)}),l!==void 0&&d(l)&&f.push({shape:`text`,x:a.labelAt.x,y:a.labelAt.y-5,text:l,textAnchor:`middle`,fontSize:9,fill:s,fontFamily:qf,stroke:Nf,strokeWidth:3,paintOrder:`stroke`});let p=c.map(Ae).join(`, `);c.length>0&&d(p)&&f.push({shape:`text`,x:a.labelAt.x,y:a.labelAt.y+10,text:p,textAnchor:`middle`,fontSize:9,fontWeight:600,fill:s,fontFamily:qf,stroke:Nf,strokeWidth:3,paintOrder:`stroke`,testId:`relationship-change`}),ue.push({id:`edge-${n}`,data:{"relationship-role":o.role,"relationship-shape":t.from===t.to?`loop`:`open`},title:_l(e,t,o.role),primitives:f})});for(let e of a.nodes){let t=u(e.id);if(t===void 0)continue;let n=Oc(e,i);ue.push({id:e.id,data:{"element-role":n,"element-id":e.id,draggable:`node`},title:dl(e,n),primitives:Jf({x:t.x,y:t.y,width:t.w,height:t.h,role:n,label:Zc(e),...e.kind===void 0?{}:{tint:f.get(e.kind)},changes:jc(e)})})}let de=t.viewpoint,O=se;if(O!==void 0&&de!==void 0){let e=pp(O,oe);ue.push({id:`filter-note`,testId:`diagram-filter-note`,data:{viewpoint:de.id},primitives:e.map((t,n)=>({shape:`text`,x:ee+12,y:ae+lp(_,oe)+dp*n+dp-4,text:n<e.length-1?`${t} `:t,fontSize:9,fontWeight:600,fill:`#92400e`,fontFamily:qf}))})}else O!==void 0&&ue.push({id:`filter-note`,primitives:[{shape:`text`,x:ee+12,y:ae+lp(_,oe)-4,text:O,fontSize:9,fontWeight:600,fill:`#92400e`,fontFamily:qf,testId:`diagram-filter-note`}]});return ue.push(...up(_,ee+12,ae,oe)),{width:oe,height:le,viewBox:`${ee} ${D} ${oe} ${le}`,ariaLabel:a.nodes.length===e.nodes.length&&a.edges.length===e.edges.length?`Graph of ${e.nodes.length} elements and ${e.edges.length} relationships`:`Graph of ${e.nodes.length} elements and ${e.edges.length} relationships, filtered to ${a.nodes.length} elements and ${a.edges.length} relationships`,background:Nf,markers:ie.map(e=>({id:gp(`se-arrow`,e),paint:e})),groups:ue,...O===void 0?{}:{narrowing:O},orientation:s}}function Ep(e,t){let n=t.isProposal,r=ul(e),{columns:i,bands:a,bandHeight:o,lifelineX:s,boxW:c,headerHeight:l,messageGap:u}=r,d=o,f=r.xOf,p=Wf(Kf(e.participants),t.appearance?.kinds),m=Gf(Kf(e.participants),p),h=[{title:`participants`,sample:`box`,entries:Kf(e.participants).map(e=>({...yp(e,p.get(e),m.get(e)),key:nl(`element`,e)}))}];if(n){let t=new Set([...e.participants.map(e=>Oc(e,!0)),...e.messages.map(e=>Ac(e,!0))]);h.push({title:`changes`,sample:`box`,entries:Rf.filter(e=>e!==`unchanged`&&t.has(e)).map(e=>({label:Mc[e],fill:Nf,stroke:If[e].stroke,faded:e===`context`}))})}let g=r.height+4,_=Math.max(r.width,cp(h)),v=r.height+lp(h,_),y=[];for(let e of a){let t=e.from*s+(s-c)/2,n=e.to*s+(s+c)/2;y.push({id:`band-${e.container.id}-${e.from}`,data:{container:e.container.id},primitives:[{shape:`rect`,x:t,y:2,width:n-t,height:d-6,rx:5,fill:`none`,stroke:Ff,strokeDasharray:`5 3`,opacity:.55},{shape:`text`,x:(t+n)/2,y:d-9,text:e.container.label,fontSize:10,textAnchor:`middle`,fill:Ff}]})}for(let e of i)y.push({id:`life-${e.id}`,primitives:[{shape:`line`,x1:f(e.id),y1:o+l,x2:f(e.id),y2:r.height-6,stroke:`#d4d4d8`,strokeDasharray:`3 3`,strokeWidth:1}]});for(let e of i){let t=Oc(e,n);y.push({id:e.id,data:{"element-role":t,"element-id":e.id},title:dl(e,t),primitives:Jf({x:f(e.id)-c/2,y:o+4,width:c,height:l-8,role:t,label:Zc(e),...e.kind===void 0?{}:{tint:p.get(e.kind)},changes:jc(e),anchor:`middle`})})}return e.messages.forEach((t,r)=>{let i=Ac(t,n),a=Lf[i],s=o+l+(r+1)*u,c=f(t.from),d=f(t.to),p=t.from===t.to,m=jc(t),h=p?c+26+6:(c+d)/2,g=p?`start`:`middle`,_=[];p?_.push({shape:`path`,d:`M ${c} ${s} h 26 v ${u/2} h -26`,fill:`none`,stroke:a,strokeWidth:1.4,markerEnd:gp(`se-msg`,a)}):_.push({shape:`line`,x1:c,y1:s,x2:d,y2:s,stroke:a,strokeWidth:1.4,markerEnd:gp(`se-msg`,a)}),t.label!==void 0&&_.push({shape:`text`,x:h,y:s-5,text:t.label,textAnchor:g,fontSize:10,fill:Pf,fontFamily:qf,stroke:Nf,strokeWidth:3,paintOrder:`stroke`}),m.length>0&&_.push({shape:`text`,x:h,y:s+11,text:m.map(Ae).join(`, `),textAnchor:g,fontSize:9,fontWeight:600,fill:a,fontFamily:qf,stroke:Nf,strokeWidth:3,paintOrder:`stroke`,testId:`relationship-change`}),_.push({shape:`text`,x:4,y:s+3,text:String(r+1),fontSize:9,fill:Ff,fontFamily:qf}),y.push({id:`message-${r}`,data:{"relationship-role":i,"message-index":String(r),"message-from":t.from,"message-to":t.to},title:gl(e,t,r,i),primitives:_})}),y.push(...up(h,12,g,_)),{width:_,height:v,viewBox:`0 0 ${_} ${v}`,ariaLabel:`Sequence of ${e.participants.length} participants and ${e.messages.length} messages`,background:Nf,markers:Rf.map(e=>({id:gp(`se-msg`,Lf[e]),paint:Lf[e]})),groups:y}}var Dp=/"n:([^"]*)"(?: \([^)]*\))?/g,Op=/"r:(\d+)"(?: \([^)]*\))?/g,kp=20;function Ap(e,t={}){let{shown:n,page:r,placement:i}=Cp(e,t),a=new Map(n.nodes.map(e=>[e.id,Zc(e)])),o=e=>`"${a.get(e)??e}"`,s=e=>{let t=n.edges[e];if(t===void 0)return`relationship ${e}`;let r=t.label??t.kind;return`"${a.get(t.from)??t.from} → ${a.get(t.to)??t.to}"${r===void 0?``:` (${r})`}`},c=e=>e.replace(Dp,(e,t)=>o(t)).replace(Op,(e,t)=>s(Number(t))).replace(/ in the mxGeometry of [^:.,]*/g,``).replace(/To change a connector with edit[^.]*\./g,``),l=[];for(let e of Ad([r]).issues){let t=e.cells.filter(e=>e.startsWith(`n:`)).map(e=>e.slice(2)),n=e.cells.filter(e=>e.startsWith(`r:`)).map(e=>Number(e.slice(2)));if(/runs through shape/.test(e.message)&&n.length===1&&t.length===1){let e=jp(r,n[0],t[0]);l.push({elements:t,relationships:n,message:`${s(n[0])} runs through ${o(t[0])}: ${e??`move the box off its path, or give the relationship waypoints that go around it`}`})}else Jd.test(e.message)&&l.push({elements:t,relationships:n,message:c(e.message).trim()})}let u=t.arrangement;if(u!==void 0){let t=new Set(Dl(e)),n=new Set(e.nodes.map(El));for(let e of Object.keys(u.elements).sort())n.has(e)||l.push({elements:[],relationships:[],message:`the arrangement places "${e}", which the document no longer holds: nothing is drawn for it, and it can be removed from the arrangement`});for(let e of Object.keys(u.relationships).sort())t.has(e)||l.push({elements:[],relationships:[],message:`the arrangement routes "${e}", which the document no longer holds: nothing is drawn for it, and it can be removed from the arrangement`})}for(let e of i?.shifted??[]){let t=i.boxes.find(t=>t.id===e.id);l.push({elements:[e.id],relationships:[],message:`${o(e.id)} was moved from (${e.from.x}, ${e.from.y}) to (${t.x}, ${t.y}) to make room for ${i.placed.map(o).join(`, `)}: check it still reads as you arranged it`})}return l}function jp(e,t,n){let r=new Map(e.cells.filter(e=>e.id!==void 0).map(e=>[e.id,e])),i=r.get(`r:${t}`),a=r.get(`n:${n}`)?.geometry;if(i?.geometry===void 0||a===void 0)return;let o=Cu(e),s=[i.source,i.target],c=e=>[...o.terminals].every(([t,n])=>s.includes(t)||e.every((t,r)=>r===0||Du(e[r-1],t,n.box,`box`,2)===0)),l=e=>wu({...i,geometry:{...i.geometry,points:e}},o)?.points,u=e=>e.reduce((t,n,r)=>r===0?0:t+Math.hypot(n.x-e[r-1].x,n.y-e[r-1].y),0);if(i.geometry.points.length>0){let e=l([]);if(e!==void 0&&c(e))return`remove its waypoints`}let d=l(i.geometry.points);if(d===void 0||d.length<2)return;let f=d[0],p=d[d.length-1],m=[[{x:f.x,y:a.y-kp},{x:p.x,y:a.y-kp}],[{x:f.x,y:a.y+a.height+kp},{x:p.x,y:a.y+a.height+kp}],[{x:a.x-kp,y:f.y},{x:a.x-kp,y:p.y}],[{x:a.x+a.width+kp,y:f.y},{x:a.x+a.width+kp,y:p.y}]].map(e=>e.map(e=>({x:Math.round(e.x),y:Math.round(e.y)}))).map(e=>({lane:e,route:l(e)})).filter(e=>e.route!==void 0&&c(e.route)).sort((e,t)=>u(e.route)-u(t.route))[0];return m===void 0?void 0:`give it waypoints at ${m.lane.map(e=>`(${e.x}, ${e.y})`).join(`, `)}`}var Mp=(0,a.createContext)({serverUrl:``});function Np(){return(0,a.useContext)(Mp)}var Pp=/^(exit|entry)(X|Y|Dx|Dy|Perimeter)$/;function Fp(e,t,n,r,i){let a=new Map(t.cells.filter(e=>e.id!==void 0).map(e=>[e.id,e])),o=new Map(n.cells.filter(e=>e.id!==void 0).map(e=>[e.id,e])),s=new Map(e.nodes.map(e=>[e.id,e])),c=t=>{if(t.id?.startsWith(`n:`)){let e=s.get(t.id.slice(2));return`"${e===void 0?t.label:Zc(e)}"`}let n=t.id?.startsWith(`r:`)?e.edges[Number(t.id.slice(2))]:void 0;if(n===void 0)return t.label===``?`a connector`:`"${t.label}"`;let r=s.get(n.from),i=s.get(n.to);return`"${r===void 0?n.from:Zc(r)} → ${i===void 0?n.to:Zc(i)}"`},l=[];for(let[e,t]of a){if(!t.vertex&&!t.edge)continue;let n=o.get(e);n===void 0?l.push(`${c(t)} was deleted: the document still holds it, so it is drawn again`):(n.label!==t.label&&l.push(`the text of ${c(t)} was changed to "${n.label}": the document's text is not changed from here`),t.edge&&(n.source!==t.source||n.target!==t.target)&&l.push(`${c(t)} was attached to other boxes: a relationship's ends are the document's, so it keeps them`),Ip(t.style,t.edge)!==Ip(n.style,n.edge)&&l.push(`the look of ${c(t)} was changed: colours and styles come from the document's kinds and the project`))}for(let[e,t]of o)a.has(e)||!t.vertex&&!t.edge||l.push(`${t.vertex?`a box`:`a connector`}${t.label===``?``:` "${t.label}"`} was added: the document is not changed from here`);let u=jf(e,{...n,cells:n.cells.filter(e=>e.id!==void 0&&a.has(e.id)&&a.get(e.id).source===e.source&&a.get(e.id).target===e.target)},i);return{view:{orientation:i,elements:{...r?.elements,...u.elements},relationships:{...r?.relationships,...u.relationships}},notKept:l}}function Ip(e,t){return Object.entries(Bl(e,t)).filter(([e])=>!Pp.test(e)).map(([e,t])=>`${e}=${t}`).sort().join(`;`)}var Lp={RENDER:`pi-outpost:drawio-render`,READY:`pi-outpost:drawio-ready`,RENDERED:`pi-outpost:drawio-rendered`,FAILED:`pi-outpost:drawio-failed`,EDIT:`pi-outpost:drawio-edit`,SAVE:`pi-outpost:drawio-save`,CLEAN:`pi-outpost:drawio-clean`,UNDO:`pi-outpost:drawio-undo`,REDO:`pi-outpost:drawio-redo`,EXPORT_SVG:`pi-outpost:drawio-export-svg`,WIRE_STYLE:`pi-outpost:drawio-wire-style`,REMOVE_BENDS:`pi-outpost:drawio-remove-bends`,CHANGED:`pi-outpost:drawio-changed`,SAVED:`pi-outpost:drawio-saved`,SVG:`pi-outpost:drawio-svg`,ESCAPE:`pi-outpost:drawio-escape`,FOCUS:`pi-outpost:drawio-focus`,PAGE_LOCKED:`pi-outpost:drawio-page-locked`};function Rp(e,t=window.location.href){return new URL(`${e}/vendor/drawio/viewer-static.min.js`,t).href}function zp(e){return JSON.stringify(e).replace(/</g,`\\u003c`)}function Bp(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function Vp(e){let t=[`default-src 'none'`,`script-src ${e} 'unsafe-inline' 'unsafe-eval'`,`style-src 'unsafe-inline'`,`img-src data: blob:`,`font-src data:`].join(`; `),n=e.slice(0,e.lastIndexOf(`/`)),r={DRAWIO_BASE_URL:n,DRAWIO_LIGHTBOX_URL:n,DRAWIO_VIEWER_URL:e,PROXY_URL:n,STENCIL_PATH:n,SHAPES_PATH:n,STYLE_PATH:n,GRAPH_IMAGE_PATH:n,DRAW_MATH_URL:n,mxImageBasePath:n,mxBasePath:n,mxLoadResources:!1,mxLoadStylesheets:!1};return`<!doctype html>
10
10
  <html><head><meta charset="utf-8">
11
11
  <meta http-equiv="Content-Security-Policy" content="${Bp(t)}">