@hardikg/mdview 0.9.1 → 0.11.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.
- package/CHANGELOG.md +82 -0
- package/README.md +53 -11
- package/bin/chunk-RBYD2HWV.mjs +196 -0
- package/bin/chunk-WWM6JNAS.mjs +209 -0
- package/bin/chunk-XFRQFZZ4.mjs +20 -0
- package/bin/mdview.mjs +521 -1289
- package/bin/regex-worker.mjs +52 -0
- package/bin/server-KALIU7HM.mjs +1854 -0
- package/bin/shiki-5SFVA32N.mjs +13 -0
- package/dist/client/assets/23I4SOAX-BN9xvzna.js +2 -0
- package/dist/client/assets/26H2HVXD-Cu1OTMxT.js +2 -0
- package/dist/client/assets/2IZ5MNOH-DMjMO3_9.js +1 -0
- package/dist/client/assets/2P3CZEXH-D-4BP7dg.js +2 -0
- package/dist/client/assets/3E5HRNYT-DUYblpdl.js +5 -0
- package/dist/client/assets/3JIRLDUO-C1CwW1Ha.js +1 -0
- package/dist/client/assets/5MJ3UKSG-DtT76qKq.js +2 -0
- package/dist/client/assets/5THPTBWS-Ce_hS451.js +1 -0
- package/dist/client/assets/7WLXJQOR-D6QVYUu9.js +1 -0
- package/dist/client/assets/A255FCTW-woaH7Mj_.js +1 -0
- package/dist/client/assets/AM43MQ64-CsWC_OQH.js +2 -0
- package/dist/client/assets/AOZTNTMC-BIehUQHD.js +5 -0
- package/dist/client/assets/AQNLM6KG-DIUuJgPm.js +4 -0
- package/dist/client/assets/BNU2RHQB-DeXpwU5k.js +2 -0
- package/dist/client/assets/C5HTQT3I-7U13x70S.js +4 -0
- package/dist/client/assets/CPKRWH5G-CRxaqyOs.js +12 -0
- package/dist/client/assets/CUVCMPQX-JTGMOfG2.js +1 -0
- package/dist/client/assets/D4V2MWCI-CytzCr6g.js +1 -0
- package/dist/client/assets/DHKBVIA3-CVnlqiEq.js +1 -0
- package/dist/client/assets/DKTLEL5E-DciMwFJ1.js +1 -0
- package/dist/client/assets/DUZNPW7S-D3pifVNb.js +2 -0
- package/dist/client/assets/E3FWOBN4-D5m5o2g0.js +4 -0
- package/dist/client/assets/E65FQMJL-Bg5F0Zo8.js +1 -0
- package/dist/client/assets/FTXIJQGB-CggtIYAM.js +1 -0
- package/dist/client/assets/G3MDBVQH-BZmnMkFw.js +1 -0
- package/dist/client/assets/G3OATVW2-VpVvT5i2.js +8 -0
- package/dist/client/assets/IV52FOAS-DgPxxRI4.js +5 -0
- package/dist/client/assets/JTJEEBDN-Bl0iUT_r.js +2 -0
- package/dist/client/assets/K7FUICZ3-DgoihkiR.js +2 -0
- package/dist/client/assets/LHH2HHRB-BXHTnBD0.js +2 -0
- package/dist/client/assets/MSPQPZZY-DQg7F6a8.js +4 -0
- package/dist/client/assets/OB6ZFVKF-UHmC8m-y.js +2 -0
- package/dist/client/assets/PLTZDMI2-C1ZAoc-e.js +1 -0
- package/dist/client/assets/R7EPXMMD-ChI1SqjJ.js +5 -0
- package/dist/client/assets/RVARI57O-CgA1WoRv.js +1 -0
- package/dist/client/assets/SPBWZ4VS-EqfCsJ5V.js +1 -0
- package/dist/client/assets/SR7OOV3Q-CFnFs0kL.js +4 -0
- package/dist/client/assets/STAXBNH4-D4c13Xlj.js +2 -0
- package/dist/client/assets/SXFARSFO-CkFSkgdi.js +1 -0
- package/dist/client/assets/TC77ISAL--WP0GBo0.js +2 -0
- package/dist/client/assets/TYIQQHVC-B67pCpxM.js +13 -0
- package/dist/client/assets/TZUXETIT-BFD9W5hl.js +2 -0
- package/dist/client/assets/U7N72BGE-Do3829la.js +6 -0
- package/dist/client/assets/UFPIB6EZ-DTs_MyQv.js +3 -0
- package/dist/client/assets/UO52YEYL-DN1qbGwF.js +3 -0
- package/dist/client/assets/VIK3ONSK-DC8mR2sZ.js +2 -0
- package/dist/client/assets/VVVO4ZVP-DAtGLbxR.js +2 -0
- package/dist/client/assets/WRGXZO53-D30IuREw.js +3 -0
- package/dist/client/assets/X5SG7MGC-CdjdoL_s.js +2 -0
- package/dist/client/assets/XLHPVVFU-BFP9ID9p.js +2 -0
- package/dist/client/assets/XXYPNCD5-DqCewu_S.js +5 -0
- package/dist/client/assets/Z6WRYFJC-BEt1KCoU.js +7 -0
- package/dist/client/assets/ZI2QNEGF-VzC4uHcW.js +8 -0
- package/dist/client/assets/index-B96jWJTi.css +1 -0
- package/dist/client/assets/index-DCU09WmS.js +2 -0
- package/dist/client/assets/katex-C0xaXAD4.js +257 -0
- package/dist/client/assets/katex.min-3X1qOa03.js +1 -0
- package/dist/client/assets/katex.min-DMey5pMQ.css +1 -0
- package/dist/client/assets/lazy-DaMZI1F7.js +45 -0
- package/dist/client/index.html +2 -2
- package/package.json +32 -26
- package/dist/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/client/assets/abnfDiagram-VCTEODGH-BJQEGN-7.js +0 -1
- package/dist/client/assets/arc-C6Oi4WlG.js +0 -1
- package/dist/client/assets/architectureDiagram-5GKGNRK7-CvFdvi3K.js +0 -36
- package/dist/client/assets/blockDiagram-NRAW4CY4-D8P8a3XW.js +0 -129
- package/dist/client/assets/c4Diagram-UCG6FXSJ-WcmmjfHX.js +0 -38
- package/dist/client/assets/channel-UA4WTF8Q.js +0 -1
- package/dist/client/assets/chunk-2Q5K7J3B-LeZsbe9d.js +0 -1
- package/dist/client/assets/chunk-5VM5RSS4-COq9euGx.js +0 -15
- package/dist/client/assets/chunk-F27PBJKO-BxcjnaqW.js +0 -1
- package/dist/client/assets/chunk-G27WJ6UU-CscpPXiS.js +0 -231
- package/dist/client/assets/chunk-JWPE2WC7-DD0M0JL-.js +0 -1
- package/dist/client/assets/chunk-LCL6LL3I-DXhJ59Qq.js +0 -206
- package/dist/client/assets/chunk-POPQ4Y6H-Bj3eKHA8.js +0 -1
- package/dist/client/assets/chunk-SVP7TREG-CDQ9vZv1.js +0 -88
- package/dist/client/assets/chunk-XXDRQBXY-91VBn0TQ.js +0 -1
- package/dist/client/assets/classDiagram-DTDB5LWJ-Ch3MnxRH.js +0 -1
- package/dist/client/assets/classDiagram-v2-JRS7N3AN-Ch3MnxRH.js +0 -1
- package/dist/client/assets/cose-bilkent-JH36ORCC-BaQN6N6K.js +0 -1
- package/dist/client/assets/cynefin-OW5HDTMX-DFpC3uqz.js +0 -178
- package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CSeSIxw6.js +0 -62
- package/dist/client/assets/cytoscape.esm-BjAbmLdb.js +0 -331
- package/dist/client/assets/dagre-3AP2YEHR-BBkMnw1s.js +0 -4
- package/dist/client/assets/defaultLocale-DX6XiGOO.js +0 -1
- package/dist/client/assets/diagram-S7CK7UJ4-BRdjuShi.js +0 -30
- package/dist/client/assets/diagram-UQ7AKVKN-D-RaNNET.js +0 -41
- package/dist/client/assets/diagram-VSXAHHWV-eL5_j9pa.js +0 -3
- package/dist/client/assets/diagram-VX7I27RA-nlUjCwlX.js +0 -24
- package/dist/client/assets/diagram-Z3DM3KII-DvhXGz8M.js +0 -24
- package/dist/client/assets/ebnfDiagram-PWID7BFC-LgynLQ4Z.js +0 -1
- package/dist/client/assets/erDiagram-SSCWMZ5O-Bc2j9FRV.js +0 -99
- package/dist/client/assets/flowDiagram-A5DVABFB-ClpDS0y_.js +0 -168
- package/dist/client/assets/ganttDiagram-EL5Y4UJY-_RmNHCQH.js +0 -292
- package/dist/client/assets/gitGraphDiagram-WWUBYQGX-F1UGJQ4d.js +0 -106
- package/dist/client/assets/index-BP_8buXC.css +0 -1
- package/dist/client/assets/index-DqIihcNP.js +0 -2
- package/dist/client/assets/infoDiagram-RXCK75RN-BR20W1yx.js +0 -2
- package/dist/client/assets/init-Gi6I4Gst.js +0 -1
- package/dist/client/assets/ishikawaDiagram-5VMMS53U-D6bgpoOj.js +0 -70
- package/dist/client/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
- package/dist/client/assets/jetbrains-mono-cyrillic-600-normal-8K4wrrwR.woff +0 -0
- package/dist/client/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
- package/dist/client/assets/jetbrains-mono-greek-600-normal-mc2nkWzM.woff +0 -0
- package/dist/client/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/dist/client/assets/jetbrains-mono-latin-600-normal-BfsvjouI.woff +0 -0
- package/dist/client/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
- package/dist/client/assets/jetbrains-mono-latin-ext-600-normal-DObL3zCW.woff +0 -0
- package/dist/client/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
- package/dist/client/assets/jetbrains-mono-vietnamese-600-normal-OWROknRo.woff +0 -0
- package/dist/client/assets/journeyDiagram-EYS64GPL-CBjB_0Bx.js +0 -139
- package/dist/client/assets/kanban-definition-3QL26DDD-Bz0HhYZd.js +0 -89
- package/dist/client/assets/katex-C5jXJg4s.js +0 -257
- package/dist/client/assets/katex.min-BYZTj3zW.css +0 -1
- package/dist/client/assets/katex.min-DXaO1tdm.js +0 -1
- package/dist/client/assets/layout-BmTy4KT7.js +0 -1
- package/dist/client/assets/linear-Cgk2Kw-d.js +0 -1
- package/dist/client/assets/mermaid.core-Dq2piIpp.js +0 -312
- package/dist/client/assets/mindmap-definition-FBJOCRG2-BSbZ3zKk.js +0 -96
- package/dist/client/assets/ordinal-Cboi1Yqb.js +0 -1
- package/dist/client/assets/pegDiagram-XKGWAZYB-BLsHBZ_O.js +0 -1
- package/dist/client/assets/pieDiagram-E7YTZNPT-BTtaojGC.js +0 -39
- package/dist/client/assets/quadrantDiagram-AXDQQJYC-W-VPz1gZ.js +0 -7
- package/dist/client/assets/railroadDiagram-O6MQD6OU-CstXUJhE.js +0 -1
- package/dist/client/assets/requirementDiagram-EFPCY7ZU-DPpI_Lvd.js +0 -84
- package/dist/client/assets/sankeyDiagram-P5KCCOFB-B3HiW1sY.js +0 -40
- package/dist/client/assets/sequenceDiagram-WJ2MYXX4-CfpZAY9b.js +0 -162
- package/dist/client/assets/sizeCapture-X5ZJPWSS-Dsdx6W_J.js +0 -1
- package/dist/client/assets/stateDiagram-HBIQ2CUA-DPm-o7Ee.js +0 -1
- package/dist/client/assets/stateDiagram-v2-4QOOHH4V-DDqXMzve.js +0 -1
- package/dist/client/assets/swimlanes-XN3QIQJK-BPdZeRls.js +0 -1
- package/dist/client/assets/swimlanesDiagram-VK2B7HYN-BHORPcrU.js +0 -8
- package/dist/client/assets/timeline-definition-24CTP7MA-1bs3iV0k.js +0 -120
- package/dist/client/assets/vennDiagram-4TSXK5OY-vYOlmqTL.js +0 -34
- package/dist/client/assets/wardleyDiagram-VM6X3IG4-DTPUMRNL.js +0 -78
- package/dist/client/assets/xychartDiagram-S5SC5T6Z-M5kqQyt7.js +0 -7
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{_ as e,a as t,b as n,d as r,i,o as a,r as o,s,u as c,x as l}from"./E3FWOBN4-D5m5o2g0.js";import{o as u,r as d}from"./DKTLEL5E-DciMwFJ1.js";import{s as f}from"./CUVCMPQX-JTGMOfG2.js";import{t as p}from"./E65FQMJL-Bg5F0Zo8.js";import{r as m}from"./DUZNPW7S-D3pifVNb.js";import{PeleError as h,g,h as _,n as v,s as y,u as b,y as x}from"./lazy-DaMZI1F7.js";var S=`aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen transparent currentcolor inherit initial unset revert accentcolor accentcolortext activetext buttonborder buttonface buttontext canvas canvastext field fieldtext graytext highlight highlighttext linktext mark marktext selecteditem selecteditemtext visitedtext activeborder activecaption appworkspace background buttonhighlight buttonshadow captiontext inactiveborder inactivecaption inactivecaptiontext infobackground infotext menu menutext scrollbar threeddarkshadow threedface threedhighlight threedlightshadow threedshadow window windowframe windowtext`,C,w=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i;function T(e){if(e.toLowerCase()===`none`)return 4;let t=w.exec(e);return t?t[1]===void 0?1:t[1]===`%`?2:3:0}function ee(e,t){let n=T(e);return n===1||n===2||t&&n===4}function E(e){let t=e.startsWith(`hsl`),n=e.indexOf(`(`),r=e.slice(0,n);if(r!==`rgb`&&r!==`rgba`&&r!==`hsl`&&r!==`hsla`||e.length>120||e.indexOf(`)`)!==e.length-1)return!1;let i=e.slice(n+1,-1).trim(),a,o,s=i.includes(`,`);if(s)a=i.split(`,`).map(e=>e.trim()),a.length===4&&(o=a.pop());else{let e=i.split(`/`);if(e.length>2)return!1;a=e[0].trim().split(/\s+/),e.length===2&&(o=e[1].trim())}if(a.length!==3||o!==void 0&&!ee(o,!s))return!1;let c=a.map(T);if(s)return t?(c[0]===1||c[0]===3)&&c[1]===2&&c[2]===2:(c[0]===1||c[0]===2)&&c[1]===c[0]&&c[2]===c[0];for(let e=0;e<3;e++){let n=c[e];if(!(n===1||n===4||(t&&e===0?n===3:n===2)))return!1}return!0}function te(e){return e.includes(`(`)?E(e):(C??=new Set(S.split(` `)),C.has(e.toLowerCase()))}var ne=/^:?wrap:/,D=/^:?nowrap:/,re=/^:?(?:no)?wrap:/,ie=/^(?:rgba?|hsla?)\s*\(/,O=/[\r\u2028\u2029]/,ae=/^\w*/;function k(e){throw new h(e,`semantic`,{type:`sequence`})}function A(e){let t=e.trim(),n=ne.test(t)?!0:!D.test(t)&&void 0;return{text:(n===void 0?t:t.replace(re,``)).trim(),wrap:n}}function oe(e){let t=ie.exec(e);if(t){let n=e.lastIndexOf(`)`);if(n>=t[0].length)return O.test(e.slice(t[0].length))?void 0:[e.slice(0,n+1),e.slice(n+1)]}if(O.test(e))return;let n=ae.exec(e)[0];return[n,e.slice(n.length)]}function se(e){return typeof e==`string`?[...e].map((e,t)=>[String(t),e]):typeof e==`object`&&e?Object.entries(e):[]}var j=class{type=`sequence`;actors=new Map;createdActors=new Map;destroyedActors=new Map;boxes=[];messages=[];notes=[];title;accTitle;accDescr;prevActor;currentBox;lastCreated;lastDestroyed;wrapEnabled;sequenceWrap;active=new Map;constructor(e={}){this.wrapEnabled=e.wrap,this.sequenceWrap=e.sequenceWrap??!1}autoWrap(){return this.wrapEnabled??this.sequenceWrap}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
2
|
+
`)}setDiagramTitle(e){this.title=e}parseMessage(e){return A(e)}parseBoxData(e){let t=oe(e),n=t?.[0]?t[0].trim():`transparent`,r=t?.[1]?t[1].trim():void 0;if(te(n)||(n=`transparent`,r=e.trim()),r===void 0)return{text:void 0,color:n,wrap:void 0};let{text:i,wrap:a}=A(r);return{text:i||void 0,color:n,wrap:a}}addBox(e){this.currentBox={name:e.text,wrap:e.wrap??this.autoWrap(),fill:e.color,actorKeys:[]},this.boxes.push(this.currentBox)}addActor(e,t,n,r,i){let a=this.currentBox,o;if(i!==void 0){let t;try{t=v(i.includes(`
|
|
3
|
+
`)?i+`
|
|
4
|
+
`:`{
|
|
5
|
+
`+i+`
|
|
6
|
+
}`)}catch(t){throw new h(`Config of participant "${e}" is not valid YAML. ${t.message}`,`syntax`,{type:`sequence`})}typeof t==`object`&&t&&!Array.isArray(t)&&(o=t)}let s=o&&Object.prototype.hasOwnProperty.call(o,`type`)?o.type:void 0,c=o&&Object.prototype.hasOwnProperty.call(o,`alias`)?o.alias:void 0;s!=null&&(r=String(s)),c&&(!n||n.text===t)&&(n={text:String(c),wrap:n?.wrap,type:r});let l=this.actors.get(e);if(!(l&&(this.currentBox&&l.box&&this.currentBox!==l.box&&k(`A same participant should only be defined in one Box: ${l.name} can't be in '${l.box.name}' and in '${this.currentBox.name}' at the same time.`),a=l.box?l.box:this.currentBox,l.box=a,t===l.name&&n==null))){if((n?.text==null||r==null)&&(n={text:t,type:r}),this.actors.set(e,{box:a,name:t,description:n.text,wrap:n.wrap??this.autoWrap(),prevActor:this.prevActor,links:new Map,properties:new Map,type:r??`participant`}),this.prevActor){let t=this.actors.get(this.prevActor);t&&(t.nextActor=e)}this.currentBox&&this.currentBox.actorKeys.push(e),this.prevActor=e}}addMessage(e,t,n,r){this.messages.push({id:String(this.messages.length),from:e,to:t,message:n.text,wrap:n.wrap??this.autoWrap(),answer:r})}addSignal(e,t,n,r,i=!1,a){if(r===18){let t=e?this.active.get(e)??0:0;t<1&&k(`Trying to inactivate an inactive participant (${e})`),this.active.set(e,t-1)}else r===17&&e&&this.active.set(e,(this.active.get(e)??0)+1);return this.messages.push({id:String(this.messages.length),from:e,to:t,message:n?.text??``,wrap:n?.wrap??this.autoWrap(),type:r,activate:i,centralConnection:a??0}),!0}addNote(e,t,n){let r=n.wrap??this.autoWrap(),i={actor:e,placement:t,message:n.text,wrap:r},a=typeof e==`string`?[e,e]:e;this.notes.push(i),this.messages.push({id:String(this.messages.length),from:a[0],to:a[1],message:n.text,wrap:r,type:2,placement:t})}addLinks(e,t){let n=this.actors.get(e);if(n)try{let e=JSON.parse(t.text);for(let[t,r]of se(e))n.links.set(t,r)}catch{return}}addALink(e,t){let n=this.actors.get(e);if(!n)return;let r=t.text.indexOf(`@`);n.links.set(t.text.slice(0,r-1).trim(),t.text.slice(r+1).trim())}addProperties(e,t){let n=this.actors.get(e);if(n)try{let e=JSON.parse(t.text);for(let[t,r]of se(e))n.properties.set(t,r)}catch{return}}addDetails(e,t){let n=this.actors.get(e);n&&(n.details=t.text)}apply(e){let t=[],n=[],r=e;for(;;){r!==void 0&&(Array.isArray(r)?(t.push(r),n.push(0)):typeof r!=`string`&&this.applyOne(r));let e=t.length-1;if(e<0)return;let i=t[e];n[e]<i.length?r=i[n[e]++]:(t.pop(),n.pop(),r=void 0)}}applyOne(e){let t=e.actor;switch(e.type){case`sequenceIndex`:this.messages.push({id:String(this.messages.length),from:void 0,to:void 0,message:{start:e.sequenceIndex,step:e.sequenceIndexStep,visible:e.sequenceVisible===!0},wrap:!1,type:e.signalType});break;case`addParticipant`:this.addActor(t,t,e.description,e.draw,e.config);break;case`createParticipant`:this.actors.has(t)&&k(`It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior`),this.lastCreated=t,this.addActor(t,t,e.description,e.draw,e.config),this.createdActors.set(t,this.messages.length);break;case`destroyParticipant`:this.lastDestroyed=t,this.destroyedActors.set(t,this.messages.length);break;case`activeStart`:case`activeEnd`:case`centralConnection`:case`centralConnectionReverse`:this.addSignal(t,void 0,void 0,e.signalType);break;case`addNote`:this.addNote(e.actor,e.placement,e.text);break;case`addLinks`:this.addLinks(t,e.text);break;case`addALink`:this.addALink(t,e.text);break;case`addProperties`:this.addProperties(t,e.text);break;case`addDetails`:this.addDetails(t,e.text);break;case`addMessage`:this.lastCreated?(e.to!==this.lastCreated&&k(`The created participant ${this.lastCreated} does not have an associated creating message after its declaration. Please check the sequence diagram.`),this.lastCreated=void 0):this.lastDestroyed&&=(e.to!==this.lastDestroyed&&e.from!==this.lastDestroyed&&k(`The destroyed participant ${this.lastDestroyed} does not have an associated destroying message after its declaration. Please check the sequence diagram.`),void 0),this.addSignal(e.from,e.to,e.msg,e.signalType,e.activate,e.centralConnection);break;case`boxStart`:this.addBox(e.boxData);break;case`boxEnd`:this.currentBox=void 0;break;case`loopStart`:this.addSignal(void 0,void 0,e.loopText,e.signalType);break;case`rectStart`:this.addSignal(void 0,void 0,e.color,e.signalType);break;case`optStart`:this.addSignal(void 0,void 0,e.optText,e.signalType);break;case`altStart`:case`else`:this.addSignal(void 0,void 0,e.altText,e.signalType);break;case`parStart`:case`and`:this.addSignal(void 0,void 0,e.parText,e.signalType);break;case`criticalStart`:this.addSignal(void 0,void 0,e.criticalText,e.signalType);break;case`option`:this.addSignal(void 0,void 0,e.optionText,e.signalType);break;case`breakStart`:this.addSignal(void 0,void 0,e.breakText,e.signalType);break;case`loopEnd`:case`rectEnd`:case`optEnd`:case`altEnd`:case`parEnd`:case`criticalEnd`:case`breakEnd`:this.addSignal(void 0,void 0,void 0,e.signalType)}}},M=`$end.INVALID.INVALID.NEWLINE.SD.create.box.restOfLine.end.autonumber.NUM.off.activate.deactivate.title.legacy_title.acc_title.acc_title_value.acc_descr.acc_descr_value.acc_descr_multiline_value.loop.rect.opt.alt.par.par_over.critical.break.option.and.else.participant.AS.participant_actor.destroy.note.over.links.link.properties.details.,.left_of.right_of.+.-.().ACTOR.CONFIG_START.CONFIG_CONTENT.CONFIG_END.TXT.SOLID_OPEN_ARROW.DOTTED_OPEN_ARROW.SOLID_ARROW.BIDIRECTIONAL_SOLID_ARROW.DOTTED_ARROW.BIDIRECTIONAL_DOTTED_ARROW.SOLID_CROSS.DOTTED_CROSS.SOLID_POINT.DOTTED_POINT.SOLID_ARROW_TOP.SOLID_ARROW_BOTTOM.STICK_ARROW_TOP.STICK_ARROW_BOTTOM.SOLID_ARROW_TOP_DOTTED.SOLID_ARROW_BOTTOM_DOTTED.STICK_ARROW_TOP_DOTTED.STICK_ARROW_BOTTOM_DOTTED.SOLID_ARROW_TOP_REVERSE.SOLID_ARROW_BOTTOM_REVERSE.STICK_ARROW_TOP_REVERSE.STICK_ARROW_BOTTOM_REVERSE.SOLID_ARROW_TOP_REVERSE_DOTTED.SOLID_ARROW_BOTTOM_REVERSE_DOTTED.STICK_ARROW_TOP_REVERSE_DOTTED.STICK_ARROW_BOTTOM_REVERSE_DOTTED`.split(`.`),ce=new Uint8Array(128);for(let e=0;e<128;e++){let t=String.fromCharCode(e),n=e===32||e>=9&&e<=13,r=0;`/\\+()<->:
|
|
7
|
+
,;`.includes(t)||(r|=1),`+<->:
|
|
8
|
+
,;`.includes(t)||(r|=2),`<>:
|
|
9
|
+
,;@`.includes(t)||(r|=8|(n?0:4)),`#
|
|
10
|
+
;`.includes(t)||(r|=16),!`/\\+()<>:
|
|
11
|
+
,;-`.includes(t)&&!n&&(r|=32),ce[e]=r}function N(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=-1,l=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},u=(e,t,a,o)=>{n.push(e),r.push(o),i.push(t),s=a},d=e=>{a.push(o),o=e},f=()=>{a.length>0&&(o=a.pop())},p=n=>(c<n&&(c=e.indexOf(`
|
|
12
|
+
`,n),c===-1&&(c=t)),c),m=(t,n)=>{let r=e.charCodeAt(t);return r<128?(ce[r]&n)!==0:n===4||n===32?!_(r):!0},h=(t,n)=>{for(let r=0;r<n.length;r++){let i=n.charCodeAt(r),a=e.charCodeAt(t+r);if(i>=97&&i<=122?(a|32)!==i:a!==i)return!1}return!0},v=t=>h(s,t)&&!g(e.charCodeAt(s+t.length)),y=n=>{for(;n<t&&_(e.charCodeAt(n));)n++;return n},b=()=>{let n=s;for(;n<t;){let t=e.charCodeAt(n);if(t===10||!_(t))break;n++}return n!==s&&(s=n,!0)},S=e=>{for(;e<t&&m(e,16);)e++;return e},C=(e,t,n)=>{l(e,s,s+t),d(n)},w=(e,t,n=-1)=>v(e)?(l(t,s,s+e.length),n>=0&&d(n),!0):!1,T=(n,r)=>{if(!h(s,n))return!1;let i=s+n.length,a=e.charCodeAt(i);if(a!==32&&a!==9)return!1;for(;a===32||a===9;)a=e.charCodeAt(++i);return i>=t||!m(i,32)?!1:(l(r,s,s+n.length),!0)},ee=t=>{let n=e.charCodeAt(t),r=e.charCodeAt(t+1);if(n===45){if(r===120||r===88||r===41||r===92||r===47||r===45)return!0;let n=e.charCodeAt(t+2);return r===124&&(n===92||n===47)}return n===47||n===92?(r===124||r===n)&&e.charCodeAt(t+2)===45:n===40&&r===41},E=()=>{let n=s+1;for(;n<t&&m(n,1);)n++;for(;n<t&&!ee(n);){let r=n;for(;e.charCodeAt(r)===45;)r++;if(r>=t||!m(r,2))break;for(r++;r<t&&m(r,2);)r++;n=r}u(48,s,n,e.slice(s,n).trim())},te=()=>{let t=s;for(;x(e.charCodeAt(t));)t++;let n=t>s;if(e.charCodeAt(t)===46&&x(e.charCodeAt(t+1))){let n=x(e.charCodeAt(t+2))?t+3:t+2,r=e.charCodeAt(n);if(r===32||r===10)return l(10,s,n),!0}let r=e.charCodeAt(t);return n&&(r===32||r===10)?(l(10,s,t),!0):!1},ne=()=>{let t=e.charCodeAt(s+1),n=e.charCodeAt(s+2);if(t===62)l(n===62?55:53,s,s+(n===62?3:2));else if(t===120||t===88)l(59,s,s+2);else if(t===41)l(61,s,s+2);else if(t===124&&n===92)l(63,s,s+3);else if(t===124&&n===47)l(64,s,s+3);else if(t===92&&n===92)l(65,s,s+3);else if(t===47&&n===47)l(66,s,s+3);else if(t===45){let t=e.charCodeAt(s+3);n===62?l(t===62?57:54,s,s+(t===62?4:3)):n===120||n===88?l(60,s,s+3):n===41?l(62,s,s+3):n===124&&t===92?l(67,s,s+4):n===124&&t===47?l(68,s,s+4):n===92&&t===92?l(69,s,s+4):n===47&&t===47?l(70,s,s+4):l(46,s,s+1)}else l(46,s,s+1)},D=t=>{let n=e.charCodeAt(s+1);if(n!==124&&n!==t||e.charCodeAt(s+2)!==45)return!1;let r=e.charCodeAt(s+3)===45,i=t===47,a;return a=n===124?r?i?75:76:i?71:72:r?i?77:78:i?73:74,l(a,s,s+(r?4:3)),!0},re=()=>{if(!h(s,`title`))return!1;let n=s+5,r=e.charCodeAt(n)===58;r&&n++;let i=n;for(;i<t&&e.charCodeAt(i)!==10&&_(e.charCodeAt(i));)i++;if(i===t||e.charCodeAt(i)===10)return s=i,!0;let a=e.charCodeAt(n);return!_(a)||a===13||!m(n+1,16)?!1:(l(r?15:14,s,S(n+1)),!0)},ie=()=>{let t=h(s,`accdescr`);if(!t&&!h(s,`acctitle`))return!1;let n=y(s+8),r=e.charCodeAt(n);return r===58?(l(t?18:16,s,y(n+1)),d(t?6:5),!0):t&&r===123?(s=y(n+1),d(7),!0):!1},O=e=>{switch(e|32){case 97:return w(`actor`,34,1)||w(`alt`,24,3)||w(`and`,30,3)||w(`activate`,12,1)||ie()||w(`autonumber`,9);case 98:return w(`box`,6,3)||w(`break`,28,3);case 99:return w(`create`,5)||w(`critical`,27,3);case 100:return w(`destroy`,35,1)||T(`details`,41)||w(`deactivate`,13,1);case 101:return w(`else`,31,3)||w(`end`,8);case 108:return w(`loop`,21,3)||w(`left of`,43)||T(`links`,38)||T(`link`,39);case 110:return w(`note`,36);case 111:return w(`opt`,23,3)||w(`option`,29,3)||w(`over`,37)||w(`off`,11);case 112:return w(`participant`,32,1)||w(`par`,25,3)||w(`par_over`,26,3)||T(`properties`,40);case 114:return w(`rect`,22,3)||w(`right of`,44);case 115:return w(`sequencediagram`,4);case 116:return re();default:return!1}},ae=()=>{let t=e.charCodeAt(s);if(t===10){let t=s+1;for(;e.charCodeAt(t)===10;)t++;l(3,s,t)}else if(_(t))s=y(s+1);else if(t===35||t===37&&e.charCodeAt(s+1)!==123)s=p(s);else if((!x(t)&&t!==46||!te())&&!(t<128&&(t|32)>=97&&(t|32)<=122&&O(t))){if(t===44)l(42,s,s+1);else if(t===59)l(3,s,s+1);else if(m(s,1))E();else if(t===45)ne();else if(t===60&&e.startsWith(`<<->>`,s))l(56,s,s+5);else if(t===60&&e.startsWith(`<<-->>`,s))l(58,s,s+6);else{if((t===47||t===92)&&D(t))return;t===58?l(52,s,S(s+1)):t===43?l(45,s,s+1):t===40&&e.charCodeAt(s+1)===41?l(47,s,s+2):l(2,s,s+1)}}},k=()=>{if(b())return!0;let n=e.charCodeAt(s);if(n===35)return s=p(s),!0;if(n===64&&e.charCodeAt(s+1)===123)return C(49,2,4),!0;let r=s;for(;r<t&&m(r,4);)r++;if(r>s){let t=y(r);if(e.charCodeAt(t)===64&&e.charCodeAt(t+1)===123)return l(48,s,r),!0;if(t>r&&h(t,`as`)&&_(e.charCodeAt(t+2)))return l(48,s,r),d(2),!0}let i=r;for(;i<t&&m(i,8);)i++;if(i>s){let n=e.charCodeAt(i),r=i;if(i<t&&n!==10&&n!==59)for(r--;r>s&&e.charCodeAt(r)!==35;)r--;if(r>s)return u(48,s,r,e.slice(s,r).trim()),f(),!0}if(e.charCodeAt(i)===60)return l(2,s,p(s)),f(),!0;if(n!==10){let t=p(s);return u(2,s,t,e.slice(s,t).trim()),f(),!0}return!1},A=()=>{switch(o){case 0:return ae(),!0;case 1:return k();case 2:return b()?!0:e.charCodeAt(s)===35?(s=p(s),!0):(f(),f(),v(`as`)?C(33,2,3):l(3,s,s),!0);case 3:return b()?!0:e.charCodeAt(s)===35?(s=p(s),!0):(l(7,s,S(s)),f(),!0);case 4:if(e.charCodeAt(s)!==125){let n=e.indexOf(`}`,s);return n===-1&&(n=t),l(50,s,n),!0}{let t=y(s+1),n=t>s+1&&h(t,`as`)&&_(e.charCodeAt(t+2));return l(51,s,s+1),f(),n?d(2):f(),!0}case 5:case 6:return l(o===5?17:19,s,p(s)),f(),!0;default:if(e.charCodeAt(s)===125)s++,f();else{let n=e.indexOf(`}`,s);n===-1&&(n=t),l(20,s,n)}return!0}};for(;s<t;)if(!A())return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i};return o===0||o===2?l(3,t,t):o===3?l(7,t,t):o===5?l(17,t,t):o===6?l(19,t,t):o===7&&l(20,t,t),n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var P=new Int8Array(79).fill(-1);P[53]=5,P[54]=6,P[55]=0,P[57]=1,P[56]=33,P[58]=34,P[59]=3,P[60]=4,P[61]=24,P[62]=25,P[63]=41,P[64]=42,P[65]=43,P[66]=44,P[67]=51,P[68]=52,P[69]=53,P[70]=54,P[71]=45,P[72]=46,P[73]=47,P[74]=48,P[75]=55,P[76]=56,P[77]=57,P[78]=58;var F=new Int8Array(79).fill(-1);F[21]=2,F[22]=3,F[23]=4,F[28]=5,F[24]=6,F[25]=7,F[26]=7,F[27]=8,F[6]=1;var I=`'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'`;function L(e,t){let{types:n,texts:r,starts:i}=N(e),a=0,o=t=>{let r=n[a];throw r===1?y(`sequence`,e,i[a],``,!0):y(`sequence`,e,i[a],`Expecting ${t}, got '${M[r]}'`)},s=e=>(n[a]!==e&&o(`'${M[e]}'`),r[a++]),c=()=>{let e=n[a];return e!==48&&e!==39&&o(`'ACTOR'`),{type:`addParticipant`,actor:r[a++]}},l=()=>t.parseMessage(s(52).trim().substring(1)),u=()=>{let e=n[a++];if(e===35){let e=c();return s(3),e.type=`destroyParticipant`,e}let r=c();if(n[a]===49&&n[a-1]===48){a++;let e=s(50);s(51),r.config=e.trim()}if(r.draw=e===32?`participant`:`actor`,n[a]===33){a++;let e=s(7);s(3),r.description=t.parseMessage(e)}else n[a]===3?a++:o(`'AS', 'NEWLINE'`);return r},d=e=>{let t=!1;n[a]===47&&(t=!0,a++);let r=P[n[a]];r<0&&o(I),a++;let i=n[a];i!==47&&(t||i!==45&&i!==46)||a++;let s=c(),u=l(),d={type:`addMessage`,from:e.actor,to:s.actor,signalType:r,msg:u},f=[e,s,d];if(t){let t=i===47;d.activate=t,d.centralConnection=t?61:60,t&&f.push({type:`centralConnection`,signalType:59,actor:s.actor}),f.push({type:`centralConnectionReverse`,signalType:60,actor:e.actor})}else i===45?(d.activate=!0,f.push({type:`activeStart`,signalType:17,actor:s.actor})):i===46?f.push({type:`activeEnd`,signalType:18,actor:e.actor}):i===47&&(d.activate=!0,d.centralConnection=59,f.push({type:`centralConnection`,signalType:59,actor:s.actor}));return f},f=e=>{a++;let t=c();return[t,{type:e,actor:t.actor,text:l()}]},p=()=>{a++;let e=n[a];if(e===37){a++;let e=c(),t=e,r=[e.actor,e.actor];if(n[a]===42){a++;let n=c();t=[e,n],r=[e.actor,n.actor]}return[t,{type:`addNote`,placement:2,actor:r,text:l()}]}e!==43&&e!==44&&o(`'over', 'left_of', 'right_of'`),a++;let t=c();return[t,{type:`addNote`,placement:e===43?0:1,actor:t.actor,text:l()}]},m=()=>{a++;let e={type:`sequenceIndex`,sequenceVisible:!0,signalType:26};return n[a]===10?(e.sequenceIndex=Number(r[a++]),e.sequenceIndexStep=n[a]===10?Number(r[a++]):1):n[a]===11&&(a++,e.sequenceVisible=!1),n[a]!==3&&o(`'NEWLINE', 'NUM', 'off'`),a++,e},h=(e,n,r,i)=>{let a=e.list,o=e.sections;if(o)for(let e=o.length-2;e>=0;e-=2){let s={type:n,signalType:i};s[r]=t.parseMessage(o[e+1]),a=o[e].concat([s,a])}return a},g=e=>{let n=e.text,r=e.list;switch(e.kind){case 1:r[0]={type:`boxStart`,boxData:t.parseBoxData(n)},r.push({type:`boxEnd`,boxText:n});break;case 2:r[0]={type:`loopStart`,loopText:t.parseMessage(n),signalType:10},r.push({type:`loopEnd`,loopText:n,signalType:11});break;case 3:r[0]={type:`rectStart`,color:t.parseMessage(n),signalType:22},r.push({type:`rectEnd`,color:t.parseMessage(n),signalType:23});break;case 4:r[0]={type:`optStart`,optText:t.parseMessage(n),signalType:15},r.push({type:`optEnd`,optText:t.parseMessage(n),signalType:16});break;case 5:r[0]={type:`breakStart`,breakText:t.parseMessage(n),signalType:30},r.push({type:`breakEnd`,optText:t.parseMessage(n),signalType:31});break;case 6:r=h(e,`else`,`altText`,13),r[0]={type:`altStart`,altText:t.parseMessage(n),signalType:12},r.push({type:`altEnd`,signalType:14});break;case 7:r=h(e,`and`,`parText`,20),r[0]={type:`parStart`,parText:t.parseMessage(n),signalType:e.startType},r.push({type:`parEnd`,signalType:21});break;default:r=h(e,`option`,`optionText`,28),r[0]={type:`criticalStart`,criticalText:t.parseMessage(n),signalType:27},r.push({type:`criticalEnd`,signalType:29})}return r};for(;n[a]===3;)a++;s(4);let _=[],v={kind:0,text:``,startType:0,list:[],sections:void 0};for(;;){let e=n[a],i=v.list;if(v.kind===1){if(e===32||e===34||e===35)i.push(u());else if(e===3)i.push([]),a++;else if(e===8){a++;let e=g(v);v=_.pop(),v.list.push(e)}else o(`'end', 'NEWLINE', 'participant', 'participant_actor', 'destroy'`)}else switch(e){case 3:case 2:i.push([]),a++;break;case 32:case 34:case 35:i.push(u());break;case 5:{a++;let e=n[a];e!==32&&e!==34&&e!==35&&o(`'participant', 'participant_actor', 'destroy'`);let t=u();t.type=`createParticipant`,i.push(t);break}case 48:i.push(d(c())),s(3);break;case 39:{let e=n[a+1];i.push(e===48||e===39?f(`addALink`):d(c())),s(3);break}case 38:i.push(f(`addLinks`)),s(3);break;case 40:i.push(f(`addProperties`)),s(3);break;case 41:i.push(f(`addDetails`)),s(3);break;case 36:i.push(p()),s(3);break;case 9:i.push(m());break;case 12:case 13:{a++;let t=c();s(3),i.push(e===12?{type:`activeStart`,signalType:17,actor:t.actor}:{type:`activeEnd`,signalType:18,actor:t.actor});break}case 14:case 15:{let n=r[a++].substring(e===14?6:7);t.setDiagramTitle(n),i.push(n);break}case 16:{a++;let e=s(17).trim();t.setAccTitle(e),i.push(e);break}case 18:{a++;let e=s(19).trim();t.setAccDescription(e),i.push(e);break}case 20:{let e=r[a++].trim();t.setAccDescription(e),i.push(e);break}case 21:case 22:case 23:case 28:case 24:case 25:case 26:case 27:case 6:{a++;let t=s(7);_.push(v),v={kind:F[e],text:t,startType:e===26?32:19,list:[[]],sections:void 0};break}case 31:case 30:case 29:{v.kind!==(e===31?6:e===30?7:8)&&o(`'end'`),a++;let t=s(7);(v.sections??=[]).push(i,t),v.list=[];break}case 8:{v.kind===0&&o(`'NEWLINE', 'EOF'`),a++;let e=g(v);v=_.pop(),v.list.push(e);break}case 0:v.kind!==0&&o(`'end'`),t.apply(i);return;default:o(`'NEWLINE', 'ACTOR', 'participant', 'note', 'end'`)}}}var R=16,le=10,z=34,ue=4,B=5,V=6,H=` fill="var(--_s)" stroke="var(--_b)"`,U=` fill="none" stroke="var(--_b)"`,de=new Set([`participant`,`actor`,`boundary`,`control`,`entity`,`database`,`collections`,`queue`]),W=new Set([`actor`,`boundary`,`control`,`entity`,`database`]);function fe(e){return de.has(e)?e:`participant`}function pe(e){return W.has(e)}function me(e,t,n,r,i=R){if(pe(e))return{w:Math.max(40,t.width+8),h:z+(t.height>0?ue+t.height:0)};let a=e===`collections`?B:e===`queue`?2*V:0;return{w:Math.max(n,t.width+2*i)+a,h:Math.max(r,t.height+2*le)+(e===`collections`?B:0)}}function G(e,t,n){let r=l(t),i=e=>l(n+e);switch(e){case`actor`:return`<circle cx="${r}" cy="${i(7)}" r="6"${H}/><path d="M${r},${i(13)}V${i(24)}M${l(t-10)},${i(17)}H${l(t+10)}M${l(t-8)},${i(34)}L${r},${i(24)}L${l(t+8)},${i(34)}"${U}/>`;case`boundary`:return`<path d="M${l(t-19)},${i(6)}V${i(28)}M${l(t-19)},${i(17)}H${l(t-8)}"${U}/><circle cx="${l(t+3)}" cy="${i(17)}" r="11"${H}/>`;case`control`:return`<circle cx="${r}" cy="${i(21)}" r="11"${H}/><path d="M${l(t+5)},${i(5)}L${l(t-1)},${i(10)}L${l(t+5)},${i(15)}"${U}/>`;case`entity`:return`<circle cx="${r}" cy="${i(15)}" r="11"${H}/><path d="M${l(t-11)},${i(30)}H${l(t+11)}"${U}/>`;default:{let e=l(t-14),n=l(t+14);return`<path d="M${e},${i(7)}V${i(27)}A14,5 0 0 0 ${n},${i(27)}V${i(7)}A14,5 0 0 0 ${e},${i(7)}Z"${H}/><path d="M${e},${i(7)}A14,5 0 0 0 ${n},${i(7)}"${U}/>`}}}function he(e,t,n,r,i,s){let{w:c,h:u}=r,d=` class="pele-label"`;if(pe(e))return G(e,t,n)+a(i,t,n+z+ue+i.height/2,d,s);let f=t-c/2;if(e===`collections`){let e=c-B,t=u-B;return`<rect x="${l(f+B)}" y="${l(n)}" width="${l(e)}" height="${l(t)}"${H}${o}/><rect x="${l(f)}" y="${l(n+B)}" width="${l(e)}" height="${l(t)}"${H}${o}/>`+a(i,f+e/2,n+B+t/2,d,s)}if(e===`queue`){let e=l(f+V),r=l(f+c-V),o=l(n+u),p=l(u/2);return`<path d="M${e},${l(n)}H${r}A${V},${p} 0 0 1 ${r},${o}H${e}A${V},${p} 0 0 1 ${e},${l(n)}Z"${H}/><path d="M${r},${l(n)}A${V},${p} 0 0 0 ${r},${o}"${U}/>`+a(i,t-V/2,n+u/2,d,s)}return`<rect x="${l(f)}" y="${l(n)}" width="${l(c)}" height="${l(u)}"${H}${o}/>`+a(i,t,n+u/2,d,s)}var ge=[];function K(e,t,n,r=1,i=!1){ge[e]={dotted:t,head:n,atStart:r!==1,atEnd:r!==0,bottom:i}}K(0,!1,1),K(1,!0,1),K(3,!1,2),K(4,!0,2),K(5,!1,0),K(6,!0,0),K(24,!1,3),K(25,!0,3),K(33,!1,1,2),K(34,!0,1,2);for(let e of[!1,!0]){let t=e?10:0;K(41+t,e,4),K(42+t,e,4,1,!0),K(43+t,e,5),K(44+t,e,5,1,!0),K(45+t,e,4,0),K(46+t,e,4,0,!0),K(47+t,e,5,0),K(48+t,e,5,0,!0)}var _e=new Map([[10,`loop`],[12,`alt`],[15,`opt`],[19,`par`],[32,`par`],[27,`critical`],[30,`break`],[22,`rect`]]),ve=12,ye=28,be=22,q=10,xe=4,Se=14,J=10,Ce=16,we=20,Te=10,Ee=20,De=240,Oe=16,Y=4,ke=` stroke-dasharray="4 4"`;function Ae(e){return e!==void 0&&ge[e]!==void 0}function je(e,t){let n=Array(e.length),r=Array(e.length),i=1,a=1,o=!1;for(let s=0;s<e.length;s++){let c=e[s];if(n[s]=NaN,r[s]=!1,c.type===26){let e=c.message;i=e.start||i,a=e.step||a,o=e.visible}else Ae(c.type)&&(n[s]=i,r[s]=o||t,i=Math.round((i+a)*100)/100)}return{index:n,shown:r,visible:o}}var Me={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function X(e,t,n){let r=e[t];return typeof r==`number`&&r>=0&&r<=2e3?r:n}function Ne(e,t,n,r,i){let a=l(e-n*8);return i?`<path class="pele-marker" d="M${l(e)},${l(t)}L${a},${l(t+r*5)}"/>`:`<path class="pele-marker" d="M${l(e)},${l(t)}L${a},${l(t+r*4.5)}V${l(t)}Z" fill="var(--_l)" stroke="none"/>`}function Pe(e,t,n,r,i){switch(e){case 1:return f(`arrow_point`,t,n,r,0,`var(--_l)`);case 2:return f(`arrow_cross`,t,n,r,0,`var(--_l)`);case 3:return`<path class="pele-marker" d="M${l(t-r*8)},${l(n-4.5)}L${l(t)},${l(n)}L${l(t-r*8)},${l(n+4.5)}" stroke-linejoin="round"/>`;case 4:return Ne(t,n,r,i,!1);case 5:return Ne(t,n,r,i,!0);default:return``}}function Fe(e){return e===1?7:e===2?4:0}function Z(e,t,n){return u(n,r=>Ie(e,t,n,r))}function Ie(u,f,h,g){let _=f.sequence??{},v=h.fontSize??16,y=Math.round(v*.875),x=Math.round(v*.75),S=h.measurer??b(h.fontFamily,h.fontFamilyMono),C=h.icons,w=h.padding??8,T=_.mirrorActors!==!1,ee=_.rightAngles===!0,E=Math.min(X(_,`actorMargin`,40),g?8:1/0),te=Math.min(X(_,`width`,64),g?48:1/0),ne=X(_,`height`,Math.round(v*1.5)+20),D=Math.min(X(_,`width`,160),g?Math.max(32,((h.maxWidth??320)-2*w)/Math.max(1,u.actors.size)-E-24):1/0),re=Math.max(4,14+X(_,`messageMargin`,35)-35),ie=Math.min(X(_,`noteMargin`,10),g?6:1/0),O=Math.min(X(_,`boxMargin`,10),g?6:1/0),ae=_.messageAlign===`left`?-1:+(_.messageAlign===`right`),k=g?6:ve,A=g?8:Ce,oe=g?12:we,se=g?6:Te,j=u.messages,M=j.length,ce=je(j,_.showSequenceNumbers===!0),N=(e,t,n,r=D,i=0)=>{let a=c(e,!1,S,t,g||n?r:1/0,i);return g?m(a,S,Math.max(120,r)):a},P;if(_.hideUnusedParticipants===!0){P=new Set;for(let e of j)P.add(e.from).add(e.to)}let F=new Int32Array(M+1);F[M]=-1;for(let e=M-1;e>=0;e--)F[e]=Ae(j[e].type)?e:F[e+1];let I=[],L=new Map;for(let[e,t]of u.actors){if(P&&!P.has(e))continue;let n=fe(t.type),r=N(t.description,v,t.wrap),i=u.createdActors.get(e),a=u.destroyedActors.get(e),o=i===void 0?-1:F[Math.min(i,M)];o>=0&&j[o].to!==e&&(o=-1);let s=a===void 0?-1:F[Math.min(a,M)];s>=0&&j[s].to!==e&&j[s].from!==e&&(s=-1),L.set(e,I.length),I.push({id:e,actor:t,kind:n,label:r,size:me(n,r,te,ne,g?8:void 0),x:0,createAt:o,destroyAt:s,top:0,lifeStart:0,lifeEnd:-1,activations:[]})}let R=I.length-1,le=new Map,z=(e,t,n)=>{if(e<0||t>R)return;let r=e*I.length+t;(le.get(r)??0)<n&&le.set(r,n)},ue=e=>ce.shown[e]?Math.max(Oe,S.width(String(ce.index[e]),x,0)+8):0,B=Array(M);for(let e=0;e<M;e++){let t=j[e],n=t.from===void 0?void 0:L.get(t.from),r=t.to===void 0?void 0:L.get(t.to);if(n!==void 0&&r!==void 0&&typeof t.message==`string`){if(t.type===2){let i=N(t.message,y,t.wrap),a=i.width+2*ie;t.placement===0?z(n-1,n,a+2*J+q):t.placement===1?z(n,n+1,a+2*J+q):n===r?(z(n-1,n,a/2+J),z(n,n+1,a/2+J)):z(Math.min(n,r),Math.max(n,r),a-2*A),B[e]={kind:2,a:n,b:r,label:i,x:0,w:a}}else if(Ae(t.type)){let i=N(t.message,y,t.wrap),a=ue(e);if(n===r)z(n,n+1,ye+8+i.width+16+q+a),B[e]={kind:1,a:n,b:r,label:i,x:0,w:0};else{let o=I[r].createAt===e?I[r].size.w/2:0,s=t.centralConnection?4*Y:0;z(Math.min(n,r),Math.max(n,r),(g?Math.min(i.width,Math.max(16,D-16)):i.width)+2*k+q+a+o+s),B[e]={kind:0,a:n,b:r,label:i,x:0,w:0}}}}}let V=[];for(let e=0;e<=R;e++){let t=I[e].actor.box,n=V[V.length-1];t&&n&&n.box===t&&n.last===e-1?n.last=e:t&&V.push({box:t,first:e,last:e,title:N(t.name,y,t.wrap),grow:0})}let H=Array(Math.max(R,0));for(let e=0;e<R;e++){let t=I[e],n=I[e+1],r=t.actor.box===n.actor.box?0:(t.actor.box?O:0)+(n.actor.box?O:0);H[e]=Math.max(t.size.w/2+n.size.w/2+E+r,le.get(e*I.length+e+1)??0)}let U=[];for(let[e,t]of le){let n=Math.floor(e/I.length),r=e%I.length;r-n>1&&U.push([n,r,t])}U.sort((e,t)=>e[1]-e[0]-(t[1]-t[0])||e[0]-t[0]);for(let[e,t,n]of U){let r=0;for(let n=e;n<t;n++)r+=H[n];if(r>=n)continue;let i=(n-r)/(t-e);for(let n=e;n<t;n++)H[n]+=i}let de=()=>{for(let e=1;e<=R;e++)I[e].x=I[e-1].x+H[e-1]};de();for(let e of V){let t=I[e.last].x+I[e.last].size.w/2-(I[e.first].x-I[e.first].size.w/2);e.grow=Math.max(0,(e.title.width-t)/2),e.grow!==0&&(e.first>0&&(H[e.first-1]+=e.grow),e.last<R&&(H[e.last]+=e.grow))}de();let W=1/0,G=-1/0,K=(e,t)=>{e<W&&(W=e),t>G&&(G=t)};for(let e of I)K(e.x-e.size.w/2,e.x+e.size.w/2);for(let e of V)K(I[e.first].x-I[e.first].size.w/2-O-e.grow,I[e.last].x+I[e.last].size.w/2+O+e.grow);let Ne=Array(M),Z=[],Ie=()=>R<0?[0,120]:[I[0].x-oe,I[R].x+oe];for(let e=0;e<M;e++){let t=j[e],n=t.type,r=n===void 0?void 0:_e.get(n),i=B[e];if(r!==void 0){let n={kind:r,x0:1/0,x1:-1/0,top:0,title:Me,tabW:0,fill:r===`rect`&&typeof t.message==`string`?t.message:``,dividers:[e],dividerY:[],dividerLabels:[]};Ne[e]=n,Z.push(n)}else if(n===13||n===20||n===28)Z[Z.length-1]?.dividers.push(e);else if(n===11||n===14||n===16||n===21||n===29||n===31||n===23){let t=Z.pop();if(!t)continue;if(Ne[e]=t,t.x0>t.x1&&([t.x0,t.x1]=Ie()),t.kind!==`rect`){t.tabW=S.width(t.kind,x,1)+14;for(let e=0;e<t.dividers.length;e++){let n=j[t.dividers[e]].message,r=e===0?t.tabW+8:0,i=t.x1-t.x0-16-r,a=n?N(`[${n}]`,y,!0,Math.max(i,g?Math.min(De,D):De)):Me;a.width>i&&(t.x1+=a.width-i),e===0?t.title=a:t.dividerLabels.push(a)}}K(t.x0,t.x1);let n=Z[Z.length-1];n&&(n.x0=Math.min(n.x0,t.x0-se),n.x1=Math.max(n.x1,t.x1+se))}else if(i){let n=I[i.a],r=I[i.b],a,o;if(i.kind===2){if(t.placement===0)i.x=n.x-J-i.w;else if(t.placement===1)i.x=n.x+J;else if(i.a===i.b)i.x=n.x-i.w/2;else{let e=Math.min(n.x,r.x)-A,a=Math.max(n.x,r.x)+A;(g||t.wrap)&&(i.label=N(t.message,y,!0,Math.max(D,a-e-2*ie))),i.w=Math.max(a-e,i.label.width+2*ie),i.x=(e+a-i.w)/2}a=i.x,o=i.x+i.w}else i.kind===1?(a=n.x,o=n.x+q+ye+8+i.label.width+ue(e)):(a=Math.min(n.x,r.x),o=Math.max(n.x,r.x),(g||t.wrap)&&(i.label=N(t.message,y,!0,Math.max(D,o-a-2*k-q))),r.createAt===e&&(r.x>n.x?o+=r.size.w/2:a-=r.size.w/2));K(a,o);let s=Z[Z.length-1];s&&(s.x0=Math.min(s.x0,a-oe),s.x1=Math.max(s.x1,o+oe))}}let Le=0;for(let e of V)Le=Math.max(Le,e.title.height);let Re=V.length>0?O+(Le>0?Le+4:0):0,ze=0;for(let e of I)e.createAt<0&&(ze=Math.max(ze,e.size.h));let Be=Re+ze;for(let e of I)e.top=Be-e.size.h,e.lifeStart=Be;let Ve=I.map(e=>e.x),He=(e,t)=>{let n=0,r=Ve.length;for(;n<r;){let t=n+r>>1;Ve[t]<=e?n=t+1:r=t}return n<Ve.length&&Ve[n]<t},Ue=(e,t,n,r)=>{if(e.width===0)return``;let i=t-e.width/2;return(He(i,i+e.width)?`<rect x="${l(i-3)}" y="${l(n-e.height/2+2)}" width="${l(e.width+6)}" height="${l(e.height-4)}" rx="3" fill="var(--_bg)" stroke="none"/>`:``)+a(e,t,n,r,C)},We=(e,t=0)=>e.activations.length+t>0?e.x-q/2:e.x,Ge=(e,t=0)=>{let n=e.activations.length+t;return n>0?e.x+q/2+(n-1)*xe:e.x},Ke=[],qe=[],Je=``,Ye=``,Xe=``,Ze=``,Qe=``,$e=``,et=(e,t)=>{let n=e.activations.pop(),r=Math.max(t,n+Se),a=e.x-q/2+e.activations.length*xe;return K(a,a+q),qe.push(`<rect class="pele-activation" data-id="${i(e.id)}" x="${l(a)}" y="${l(n)}" width="${q}" height="${l(r-n)}" rx="2"/>`),r},tt=(e,t)=>{let n=e.x,r=t+16;return e.lifeEnd=r,$e+=`<path class="pele-destroy" data-id="${i(e.id)}" d="M${l(n-6)},${l(r-6)}L${l(n+6)},${l(r+6)}M${l(n+6)},${l(r-6)}L${l(n-6)},${l(r+6)}"/>`,r+6},nt=(e,t,r)=>{let a=e.actor.properties.get(`class`);return`<g class="pele-node pele-actor pele-actor-${e.kind}${r?` pele-actor-footer`:``}${typeof a==`string`?n(a):``}" data-id="${i(e.id)}">`+he(e.kind,e.x,t,e.size,e.label,C)+`</g>`},rt=(e,n,r,i)=>`<g class="pele-sequence-number"><rect x="${l(n-i/2)}" y="${l(r-Oe/2)}" width="${l(i)}" height="${Oe}" rx="${Oe/2}" fill="var(--_l)" stroke="none"/><text x="${l(n)}" y="${l(r+x*.35)}" text-anchor="middle" font-size="${x}" fill="var(--_bg)" stroke="none">${t(String(ce.index[e]))}</text></g>`,Q=Be+6,it=[];for(let e=0;e<M;e++){let t=j[e],n=t.type,c=B[e],u=Ne[e];if(n===17){let e=t.from===void 0?void 0:L.get(t.from);e!==void 0&&I[e].activations.push(Q)}else if(n===18){let e=t.from===void 0?void 0:L.get(t.from);e!==void 0&&I[e].activations.length>0&&(Q=Math.max(Q,et(I[e],Q)))}else if(u&&u.dividers[0]===e)it.push(u),u.kind===`rect`?(u.top=Q+8,Q=u.top):(u.top=Q+12,Q=u.top+Math.max(Ee,u.title.height+2));else if(u){it.pop();let e=Q+12,t=l(u.x0),n=l(u.x1-u.x0);if(u.kind===`rect`){let i=u.fill?s([`fill:${u.fill}`]).shape:``;Ke.push(`<rect class="pele-rect" x="${t}" y="${l(u.top)}" width="${n}" height="${l(e-u.top)}"${r((i?``:` fill-opacity="0.5"`)+i)}/>`)}else{let r=`<rect x="${t}" y="${l(u.top)}" width="${n}" height="${l(e-u.top)}" fill="none"${o}/>`;for(let e=0;e<u.dividerY.length;e++){let n=u.dividerY[e],i=u.dividerLabels[e];r+=`<path d="M${t},${l(n)}H${l(u.x1)}"${ke}/>`+Ue(i,u.x0+8+i.width/2,n+2+i.height/2,` class="pele-frame-label" fill="var(--_m)" stroke="none"`)}r+=`<rect x="${t}" y="${l(u.top)}" width="${l(u.tabW)}" height="${Ee}" fill="var(--_s)"${o}/><text class="pele-frame-kind" x="${l(u.x0+u.tabW/2)}" y="${l(u.top+Ee/2+x*.35)}" text-anchor="middle" font-size="${x}" font-weight="var(--_hw)" fill="var(--_m)" stroke="none">${u.kind}</text>`+Ue(u.title,u.x0+u.tabW+8+u.title.width/2,u.top+Math.max(Ee,u.title.height)/2,` class="pele-frame-label" fill="var(--_m)" stroke="none"`),Je+=`<g class="pele-frame pele-frame-${u.kind}">${r}</g>`}Q=e}else if(n===13||n===20||n===28){let e=it[it.length-1];if(e){let t=e.dividerLabels[e.dividerY.length];e.dividerY.push(Q+12),Q+=12+(t.height>0?t.height:0)}}else if(c&&c.kind===2){let e=I[c.a],n=c.label.height+2*Math.max(4,ie-4),r=Q+10,s=c.x;t.placement===1?s+=Ge(e)-e.x:t.placement===0&&(s+=We(e)-e.x),K(s,s+c.w),Ze+=`<g class="pele-note" data-id="i${i(t.id)}"><rect x="${l(s)}" y="${l(r)}" width="${l(c.w)}" height="${l(n)}"${o}/>`+a(c.label,s+c.w/2,r+n/2,` class="pele-label" stroke="none" fill="var(--_fg)"`,C)+`</g>`,Q=r+n}else if(c){let r=ge[n],o=I[c.a],s=I[c.b],u=c.label,d=ue(e),f=0;for(let n=e+1;n<M;n++){let e=j[n].type;if(e===17)j[n].from===t.to&&f++;else if(e!==18&&e!==59&&e!==60)break}let p=r.bottom?1:-1,m=r.dotted?ke:``,h=t.centralConnection,g=h===59||h===61,_=h===60||h===61,v=(e,t)=>`<circle class="pele-central" cx="${l(e)}" cy="${l(t)}" r="${Y}" fill="var(--_l)" stroke="none"/>`,y=r.atStart&&!r.atEnd,b=Fe(r.head),x=``,S;if(c.kind===1){let n=Q+re+Math.max(0,(u.height-be)/2),s=n+be,c=_?o.x+Y:Ge(o),h=g?o.x+Y:Ge(o,f),w=Math.max(c,h)+ye+d/2;_&&(x+=v(o.x,n)),g&&(x+=v(o.x,s)),d>0&&(x+=rt(e,y?h:c,y?s:n,d),y?h+=d/2:c+=d/2);let T=(r.atStart?Pe(r.head,c,n,-1,p):``)+(r.atEnd?Pe(r.head,h,s,-1,-p):``),E=l(c+(r.atStart?b:0)),te=l(h+(r.atEnd?b:0));x=`<path d="${ee?`M${E},${l(n)}H${l(w)}V${l(s)}H${te}`:`M${E},${l(n)}H${l(w-6)}A6,6 0 0 1 ${l(w)},${l(n+6)}V${l(s-6)}A6,6 0 0 1 ${l(w-6)},${l(s)}H${te}`}"${m}/>`+T+x,K(o.x,w+8+u.width),u.width>0&&(Xe+=`<g class="pele-edge-label" data-id="i${i(t.id)}">${a(u,w+8+u.width/2,(n+s)/2,``,C)}</g>`),S=Math.max(s,(n+s)/2+u.height/2)}else{let n=s.x>o.x?1:-1,a=s.createAt===e;S=Q+re+Math.max(u.height>0?u.height+2:6,a?s.size.h/2-re+6:0);let c=n>0?Ge(o):We(o),h=n>0?We(s,f):Ge(s,f);if(a&&(s.top=S-s.size.h/2,s.lifeStart=s.top+s.size.h,h=s.x-n*(pe(s.kind)?18:s.size.w/2+1)),_&&(x+=v(o.x,S),c=o.x+n*Y),g&&(x+=v(s.x,S),h=s.x-n*Y),d>0){if(y){let t=g?h-n*(d/2+2):h;x+=rt(e,t,S,d),h=t-n*d/2}else{let t=_?c+n*(d/2+2):c;x+=rt(e,t,S,d),c=t+n*d/2}}let C=(r.atStart?Pe(r.head,c,S,-n,p*n):``)+(r.atEnd?Pe(r.head,h,S,n,p*n):``),w=c+(r.atStart?n*b:0),T=h-(r.atEnd?n*b:0);if(x=`<path d="M${l(w)},${l(S)}H${l(T)}"${m}/>`+C+x,u.width>0){let e=Math.min(c,h),n=Math.max(c,h),r=ae<0?e+k+u.width/2:ae>0?n-k-u.width/2:(e+n)/2;K(r-u.width/2,r+u.width/2),Xe+=`<g class="pele-edge-label" data-id="i${i(t.id)}">${Ue(u,r,S-4-u.height/2,``)}</g>`}a&&(Q=S+s.size.h/2-6)}Ye+=`<g class="pele-edge pele-message" data-id="i${i(t.id)}">${x}</g>`,Q=Math.max(Q,S),o.destroyAt===e&&(Q=Math.max(Q,tt(o,S))),s.destroyAt===e&&s!==o&&(Q=Math.max(Q,tt(s,S)))}}Q+=20;for(let e of I)for(;e.activations.length>0;)et(e,Q);let at=Q;if(T){let e=0;for(let t of I)t.lifeEnd>=0||(e=Math.max(e,t.size.h),Qe+=nt(t,Q,!0));at=Q+e}let ot=``;for(let e of I){Qe+=nt(e,e.top,!1);let t=e.lifeEnd>=0?e.lifeEnd:Q;t>e.lifeStart&&(ot+=`<path class="pele-lifeline" data-id="${i(e.id)}" d="M${l(e.x)},${l(e.lifeStart)}V${l(t)}"/>`)}let st=``;for(let e of V){let t=I[e.first].x-I[e.first].size.w/2-O-e.grow,n=I[e.last].x+I[e.last].size.w/2+O+e.grow,o=e.box.fill===`transparent`?``:s([`fill:${e.box.fill}`]).shape;st+=`<g class="pele-cluster pele-box"${e.box.name?` data-id="${i(e.box.name)}"`:``}><rect x="${l(t)}" y="0" width="${l(n-t)}" height="${l(at+O)}" fill="var(--_a)" stroke="var(--_b)"${r((o?``:` fill-opacity="0.5"`)+o)}/>`+a(e.title,(t+n)/2,O/2+2+e.title.height/2,` class="pele-cluster-label" fill="var(--_m)"`,C)+`</g>`}V.length>0&&(at+=O);let ct=0,lt=``,ut=d(h),dt=p(u.title,S,v,g?ut:1/0),$=g?m(dt,S,Math.max(120,ut)):dt;if(W>G&&K(0,Math.max($.width,40)),$.width>0){let e=(W+G)/2;K(e-$.width/2,e+$.width/2),ct=-$.height-12,lt=a($,e,ct+$.height/2,` class="pele-title" font-weight="var(--_tw)"`,C)}let ft=Math.ceil(G-W+2*w),pt=Math.ceil(at-ct+2*w);return{svg:e(`sequence`,ft,pt,v,h,u,`<g transform="translate(${l(w-W)},${l(w-ct)})">`+lt+(st?`<g class="pele-boxes" font-size="${y}">${st}</g>`:``)+(Ke.length>0?`<g class="pele-rects" fill="var(--_a)">${Ke.reverse().join(``)}</g>`:``)+(ot?`<g class="pele-lifelines" fill="none" stroke="var(--_b)">${ot}</g>`:``)+(qe.length>0?`<g class="pele-activations" fill="var(--_s)" stroke="var(--_b)">${qe.reverse().join(``)}</g>`:``)+(Je?`<g class="pele-frames" font-size="${y}" stroke="var(--_b)">${Je}</g>`:``)+(Ye?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${Ye}</g>`:``)+($e?`<g class="pele-destroys" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-linecap="round">${$e}</g>`:``)+(Xe?`<g class="pele-edge-labels" font-size="${y}">${Xe}</g>`:``)+(Ze?`<g class="pele-notes" font-size="${y}" fill="var(--_a)" stroke="var(--_b)">${Ze}</g>`:``)+(Qe?`<g class="pele-nodes">${Qe}</g>`:``)+`</g>`),width:ft,height:pt,links:[]}}var Le={type:`sequence`,math:!0,parse(e,t,n){let r=t.sequence??{},i=new j({wrap:typeof t.wrap==`boolean`?t.wrap:void 0,sequenceWrap:r.wrap===!0});return n&&i.setDiagramTitle(n),L(e,i),i},render:Z};export{Le as sequence};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,o as t,x as n}from"./E3FWOBN4-D5m5o2g0.js";function r(e,t,n=0){return{w:e,h:t,kind:n,pin:0,hint:NaN,key:NaN,span:0,x:0,y:0,rank:0}}function i(e,t,n=1,r=0,i=0){return{tail:e,head:t,minlen:n,labelW:r,labelH:i,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}var a=24,o=2e4,s=16,c=8,l=.125,u=3,d=18,f=10,p=14,m=2,h=28,g=12,_=12,v=8,y=4,b=.5,x=.5,S=12,C=40,w=400,T=16,E=new Float64Array(2*T+2),D=new Float64Array(2*T+2);function O(e){return e===1||e===2}function k(e,t,n,r){for(let i=t+1;i<n;i++){let n=e[i],a=r[n],o=i-1;for(;o>=t&&(r[e[o]]>a||r[e[o]]===a&&e[o]>n);)e[o+1]=e[o],o--;e[o+1]=n}}function A(e,t,n,r,i,a){let o=(e,t)=>n[e]<n[t]||n[e]===n[t]&&(i?r[e]>r[t]:r[e]<r[t]);for(let n=0;n<t;n+=8)for(let r=n+1,i=Math.min(t,n+8);r<i;r++){let t=e[r],i=r-1;for(;i>=n&&o(t,e[i]);)e[i+1]=e[i],i--;e[i+1]=t}let s=e,c=a;for(let e=8;e<t;e*=2){for(let n=0;n<t;n+=2*e){let r=Math.min(t,n+e),i=Math.min(t,n+2*e),a=n,l=r,u=n;for(;a<r&&l<i;)c[u++]=o(s[l],s[a])?s[l++]:s[a++];for(;a<r;)c[u++]=s[a++];for(;l<i;)c[u++]=s[l++]}let n=s;s=c,c=n}if(s!==e)for(let n=0;n<t;n++)e[n]=s[n]}function j(e,t,n){let r=e.length;if(r===0)return{width:0,height:0};let i=t.length;if(r===1&&i===0&&e[0].kind===0){let t=e[0];return t.rank=0,t.x=t.w/2,t.y=t.h/2,{width:t.w,height:t.h}}let a=1;if(i>0){let e=new Set;for(let n of t){let t=Math.min(n.tail,n.head),i=Math.max(n.tail,n.head),o=t*r+i;if(n.labelW>0||e.has(o)){a=2;break}e.add(o)}}M(e,t),N(e,t,a);let s=new Int32Array(i),c=0;for(let n=0;n<i;n++){let r=t[n];s[n]=Math.abs(e[r.head].rank-e[r.tail].rank),s[n]>1&&(c+=s[n]-1)}let _=new Uint8Array(i);if(c>o){let e=[];for(let t=0;t<i;t++)s[t]>1&&e.push(t);e.sort((e,t)=>s[t]-s[e]||e-t);for(let t of e){if(c<=o)break;_[t]=1,c-=s[t]-1}}let v=r+c,y=new Float64Array(v),b=new Float64Array(v),x=new Uint8Array(v),S=new Int32Array(v),C=0;for(let t=0;t<r;t++){let n=e[t];y[t]=n.w,b[t]=n.h,x[t]=n.kind,S[t]=n.rank,n.rank>C&&(C=n.rank)}let w=0;for(let e=0;e<i;e++)_[e]||(w+=s[e]);let T=new Int32Array(w),E=new Int32Array(w),D=new Float64Array(w),O=new Float64Array(w),k=new Int32Array(i).fill(-1),A=new Uint8Array(C+1),j=new Int32Array(i).fill(-1),P=!1;for(let t=0;t<r;t++)e[t].span>0&&e[t].kind===0&&(P=!0);let I=P?new Uint8Array(w):void 0,R=P?new Uint8Array(w):void 0,B=new Int32Array(i).fill(-1),ce=new Int32Array(i).fill(-1),V=new Float64Array(v).fill(NaN);for(let t=0;t<r;t++)V[t]=e[t].key;let H=!1;{let e=r,n=0;for(let r=0;r<i;r++){if(_[r])continue;let i=t[r],o=i.reversed?i.head:i.tail,s=i.reversed?i.tail:i.head,c=i.reversed?i.headDx:i.tailDx,l=i.reversed?i.tailDx:i.headDx;(c!==0||l!==0)&&(H=!0);let u=S[o],d=S[s],f=-1;i.labelW>0&&(f=u+(d-u>>1),a===2&&d-u>=4?(f&1)==1&&(f+=i.reversed?1:-1):a===2&&!(f&1)&&(f+=i.reversed?1:-1));let p=o;d-u>1&&(k[r]=e),B[r]=n,I&&!(i.reversed?i.headFixed:i.tailFixed)&&(I[n]=i.reversed?2:1);for(let t=u+1;t<d;t++){let a=e++;S[a]=t,V[a]=V[o]+(V[s]-V[o])*(t-u)/(d-u),t===f?(y[a]=i.labelW,b[a]=i.labelH,x[a]=2,j[r]=a,A[t]|=i.reversed?2:1):x[a]=1,T[n]=p,E[n]=a,D[n]=p===o?c:0,n++,p=a}T[n]=p,E[n]=s,D[n]=p===o?c:0,O[n]=l,R&&!(i.reversed?i.tailFixed:i.headFixed)&&(R[n]=i.reversed?1:2),ce[r]=n,n++}}let le;if(n.groups){let{of:e,parent:a}=n.groups;le=new Int32Array(v);for(let t=0;t<r;t++)le[t]=e[t];let o=e=>{let t=0;for(;e>=0;e=a[e])t++;return t},c=(e,t)=>{let n=o(e),r=o(t);for(;n>r;n--)e=a[e];for(;r>n;r--)t=a[t];for(;e!==t;)e=a[e],t=a[t];return e};for(let n=0;n<i;n++){if(k[n]<0)continue;let r=t[n],i=c(e[r.tail],e[r.head]);for(let e=k[n],t=e+s[n]-1;e<t;e++)le[e]=i}}let U=new Int32Array(v+1),W=new Int32Array(v+1);for(let e=0;e<w;e++)U[T[e]+1]++,W[E[e]+1]++;for(let e=0;e<v;e++)U[e+1]+=U[e],W[e+1]+=W[e];let ue=new Int32Array(w),de=new Int32Array(w);{let e=U.slice(0,v),t=W.slice(0,v);for(let n=0;n<w;n++)ue[e[T[n]]++]=n,de[t[E[n]]++]=n}let G=new Int32Array(C+2);for(let e=0;e<v;e++)G[S[e]+1]++;for(let e=0;e<=C;e++)G[e+1]+=G[e];let K=new Int32Array(v),fe=new Int32Array(v);{let e=new Int32Array(v),t=G.slice(0,C+1);for(let n=0;n<v;n++)e[t[S[n]]++]=n;for(let e=0;e<=C;e++)t[e]=G[e];let n=new Uint8Array(v),r=[];for(let i=0;i<v;i++)if(!n[e[i]])for(r.push(e[i]);r.length>0;){let e=r.pop();if(!n[e]){n[e]=1,K[t[S[e]]++]=e;for(let t=U[e+1]-1;t>=U[e];t--){let e=E[ue[t]];n[e]||r.push(e)}}}}let pe=(e,t)=>{let n=G[e],r=G[e+1];if(r-n<2)return!1;for(let e=n;e<r;e++)if(Number.isNaN(t(K[e])))return!1;let i=Array.from(K.subarray(n,r)),a=new Map;return i.forEach((e,t)=>a.set(e,t)),i.sort((e,n)=>t(e)-t(n)||a.get(e)-a.get(n)),K.set(i,n),!0};for(let e=0;e<=C;e++)pe(e,e=>V[e]);let me=!1;for(let t=0;t<r;t++)e[t].pin!==0&&(me=!0);if(me)for(let t=0;t<=C;t++){let n=Array.from(K.subarray(G[t],G[t+1])),i=new Map;n.forEach((e,t)=>i.set(e,t));let a=t=>t<r?e[t].pin:0;n.sort((e,t)=>a(e)-a(t)||i.get(e)-i.get(t)),K.set(n,G[t])}let he=new Uint8Array(C+1),ge=t=>t<r&&(e[t].kind===3||e[t].kind===4)?e[t].hint:NaN;for(let e of[0,C])pe(e,ge)&&(he[e]=1);let _e=()=>{for(let e=0;e<=C;e++){let t=G[e];for(let n=t,r=G[e+1];n<r;n++)fe[K[n]]=n-t}};_e();let q={n:v,real:r,maxRank:C,W:y,KIND:x,RANK:S,EF:T,ET:E,EFD:D,ETD:O,succStart:U,succE:ue,predStart:W,predE:de,layerStart:G,order:K,pos:fe,offsets:H,fixed:he,GRP:le,groupParent:n.groups?.parent},ve=0,ye=0;if(w>0&&C>0&&([ve,ye]=oe(q,e),_e()),n.orderOnly){let a=se(q,n);for(let t=0;t<r;t++)e[t].x=a[t];for(let e=0;e<i;e++){let n=t[e],r=n.reversed?n.head:n.tail,i=n.reversed?n.tail:n.head,o=[S[r],a[r]];if(!_[e]&&k[e]>=0)for(let t=k[e],n=t+s[e]-1;t<n;t++)o.push(S[t],a[t]);o.push(S[i],a[i]),n.points=o}return{width:0,height:0,crossings:ve,declared:ye}}I&&R&&F(q,e,I,R);let J=se(q,n),Y=re(q);if(I&&R){let r=L(q,I,R);ee(q,e,J,r,n,Y),te(q,e,J,I,R,r,Y),ne(q,J,Y,n);for(let e=0;e<i;e++){if(_[e])continue;let n=t[e],r=D[B[e]],i=O[ce[e]];n.tailDx=n.reversed?i:r,n.headDx=n.reversed?r:i}}let be=new Uint8Array(v);Y&&!n.tracks&&ie(q,J,Y,k,s,n.apart?0:n.edgeSep,be),n.tracks||ae(q,J,k,s,n.edgeSep,be);let xe=new Int32Array(i+1),X=n.tracks||I&&!n.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,Se=new Int32Array(C+1);if(X){for(let e=0;e<i;e++){if(xe[e]=X.from.length,_[e])continue;let t=k[e],r=!1;for(let i=t,a=t<0?t:t+s[e]-1;i<a;i++){let e=Y!==void 0&&Y[S[i]]===1;!n.tracks&&e!==(be[i]===1)&&(r=!0)}if(r)continue;let i=J[T[B[e]]]+D[B[e]],a=S[T[B[e]]];for(let n=t,r=t<0?t:t+s[e]-1;n<r;n++)Y&&Y[S[n]]||(X.from.push(i),X.to.push(J[n]),X.rank.push(a),X.lower.push(n),i=J[n],a=S[n]);X.from.push(i),X.to.push(J[E[ce[e]]]+O[ce[e]]),X.rank.push(a),X.lower.push(-1)}xe[i]=X.from.length}let Ce=(e,t)=>{let n=!1;for(let r=G[e];r<G[e+1];r++){let e=x[K[r]];if(e===t)n=!0;else if(e!==1)return!1}return n},we=Ce(0,3)?a:0,Te=Ce(C,4)?a:0,Ee=new Float64Array(C+1);for(let e=0;e<w;e++){let t=Math.abs(J[T[e]]+D[e]-J[E[e]]-O[e]);t>Ee[S[T[e]]]&&(Ee[S[T[e]]]=t)}let Z=new Float64Array(C+1),Q=new Float64Array(C+1),De=e=>(e<we||e>=C-Te?n.portSep:n.rankSep)/a,Oe=new Float64Array(C+1);for(let e=0;e<C;e++)Oe[e]=X?De(e):Math.max(De(e),Math.min(u*n.rankSep/a,Ee[e]*l));let ke=new Uint8Array(C+1).fill(1);for(let e=0;e<r;e++)ke[S[e]]=0;for(let e=1;e<C;e++){if(n.tracks||!ke[e]||A[e]!==1&&A[e]!==2)continue;let t=Math.min((n.headRoom??0)/2,Oe[A[e]===1?e-1:e]/2);Oe[e-1]+=A[e]===1?-t:t,Oe[e]+=A[e]===1?t:-t}let Ae=e=>x[e]===1&&ke[S[e]]&&!n.tracks?(Q[S[e]]-Z[S[e]])/4:0,je=n.tracks?d:h,Me=n.tracks?f:g,Ne=n.tracks?p:g,Pe=new Int32Array(C+1);if(X){let e=new Float64Array(C+1);for(let t=0;t<C;t++){if(Y&&Y[t])continue;let n=t+1;for(e[t]=Oe[t];n<C&&Y&&Y[n];)e[t]+=Oe[n++];Pe[t]=n}for(let t=0;t<X.from.length;t++)X.wide.push(+(Math.abs(X.from[t]-X.to[t])>m*e[X.rank[t]]));let t=new Float64Array(C+1);z(X,Se,!n.tracks,e,t);for(let r=0;r<C;r++)Se[r]>0?Oe[r]+=Math.max(0,2*je+(Se[r]-1)*Me-e[r]):t[r]>0&&(Oe[r]+=Math.max(0,Math.min(u*n.rankSep,t[r])-e[r]))}let Fe=0;for(let e=0;e<=C;e++){let t=0;for(let n=G[e];n<G[e+1];n++)b[K[n]]>t&&(t=b[K[n]]);Z[e]=Fe,Q[e]=Fe+t,Fe+=t+Oe[e]}let Ie=Fe,Le=(e,t=X.track[e])=>{let r=X.rank[e],i=Q[r],a=Z[Pe[r]],o=n.tracks?Se[r]:X.levels[e],s=o>1?Math.min(Ne,(a-i-2*je)/(o-1)):0;return(i+a)/2+(t-(o-1)/2)*s},$=1/0,Re=-1/0;for(let e=0;e<v;e++){let t=y[e]/2;J[e]-t<$&&($=J[e]-t),J[e]+t>Re&&(Re=J[e]+t)}let ze=new Uint8Array(C+1),Be=new Uint8Array(C+1);for(let e=0;e<r;e++)x[e]!==0||!I||(W[e+1]>W[e]&&(ze[S[e]]=1),U[e+1]>U[e]&&(Be[S[e]]=1));for(let t=0;t<r;t++){let n=e[t],r=n.rank;n.x=J[t]-$,n.y=x[t]===0&&Be[r]&&!ze[r]?Q[r]-n.h/2:x[t]===0&&ze[r]&&!Be[r]?Z[r]+n.h/2:(Z[r]+Q[r])/2}for(let r=0;r<i;r++){let i=t[r],a=e[i.reversed?i.head:i.tail],o=e[i.reversed?i.tail:i.head],c=[a.x+(i.reversed?i.headDx:i.tailDx),a.y+a.h/2],l=k[r];if(X&&xe[r+1]>xe[r])for(let e=xe[r];e<xe[r+1];e++){if(X.track[e]>=0&&(n.tracks||X.wide[e]===1)){let t=Le(e);c.push(X.from[e]-$,t,X.to[e]-$,t)}else X.track[e]>0&&c.push(X.from[e]-$,Le(e,X.track[e]-1));let t=X.lower[e];t<0||(c.push(J[t]-$,Z[S[t]]+Ae(t)),Q[S[t]]>Z[S[t]]&&c.push(J[t]-$,Q[S[t]]-Ae(t)))}else if(l>=0)for(let e=l,t=l+s[r]-1;e<t;e++){if(be[e])continue;let t=J[e]-$,n=Z[S[e]],r=Q[S[e]];c.push(t,n+Ae(e)),r>n&&c.push(t,r-Ae(e))}if(c.push(o.x+(i.reversed?i.tailDx:i.headDx),o.y-o.h/2),i.reversed)for(let e=0,t=c.length-2;e<t;e+=2,t-=2){let n=c[e],r=c[e+1];c[e]=c[t],c[e+1]=c[t+1],c[t]=n,c[t+1]=r}i.points=c;let u=j[r];u>=0?(i.labelX=J[u]-$,i.labelY=(Z[S[u]]+Q[S[u]])/2):i.labelW>0&&(i.labelX=(c[0]+c[c.length-2])/2,i.labelY=(c[1]+c[c.length-1])/2)}return{width:Re-$,height:Ie}}function M(e,t){let n=e.length,r=t.length,i=new Int32Array(n+1);for(let n=0;n<r;n++){let r=t[n];r.reversed=e[r.head].kind===3||e[r.tail].kind===4,r.reversed||i[r.tail+1]++}for(let e=0;e<n;e++)i[e+1]+=i[e];let a=new Int32Array(i[n]);{let e=i.slice(0,n);for(let n=0;n<r;n++)t[n].reversed||(a[e[t[n].tail]++]=n)}let o=new Uint8Array(n),s=i.slice(0,n),c=[];for(let e=0;e<n;e++)if(o[e]===0)for(c.push(e),o[e]=1;c.length>0;){let e=c[c.length-1];if(s[e]<i[e+1]){let n=t[a[s[e]++]],r=n.head;o[r]===1?n.reversed=!0:o[r]===0&&(o[r]=1,c.push(r))}else o[e]=2,c.pop()}}function N(e,t,n){let r=e.length,i=t.length,a=new Int32Array(i),o=new Int32Array(i),s=new Int32Array(i),c=new Int32Array(r+1),l=new Int32Array(r+1);for(let e=0;e<i;e++){let r=t[e],i=r.reversed?r.head:r.tail,u=r.reversed?r.tail:r.head;a[e]=i,o[e]=u,s[e]=Math.max(1,r.minlen)*n,c[i+1]++,l[u+1]++}for(let e=0;e<r;e++)c[e+1]+=c[e],l[e+1]+=l[e];let u=new Int32Array(i),d=new Int32Array(i);{let e=c.slice(0,r),t=l.slice(0,r);for(let n=0;n<i;n++)u[e[a[n]]++]=n,d[t[o[n]]++]=n}let f=new Int32Array(r),p=new Int32Array(r);for(let e=0;e<r;e++)p[e]=l[e+1]-l[e];let m=new Int32Array(r),h=0;for(let e=0;e<r;e++)p[e]===0&&(m[h++]=e);for(let e=0;e<h;e++){let t=m[e];for(let e=c[t];e<c[t+1];e++){let n=u[e],r=o[n];f[t]+s[n]>f[r]&&(f[r]=f[t]+s[n]),--p[r]===0&&(m[h++]=r)}}for(let e=0;e<8;e++){let e=!1;for(let t=h-1;t>=0;t--){let n=m[t],r=l[n+1]-l[n],i=c[n+1]-c[n];if(r===0&&i===0)continue;let p=-1/0,h=1/0;for(let e=l[n];e<l[n+1];e++){let t=d[e];p=Math.max(p,f[a[t]]+s[t])}for(let e=c[n];e<c[n+1];e++){let t=u[e];h=Math.min(h,f[o[t]]-s[t])}let g=f[n];i>r&&h!==1/0?g=h:r>i&&p!==-1/0&&(g=p),g!==f[n]&&(f[n]=g,e=!0)}if(!e)break}let g=1/0,_=-1/0,v=!1;for(let t=0;t<r;t++){let n=e[t].kind;n===3&&(v=!0),n!==3&&n!==4&&(f[t]<g&&(g=f[t]),f[t]>_&&(_=f[t]))}g===1/0&&(g=0,_=0);for(let t=0;t<r;t++)e[t].kind===3?f[t]=g-n:e[t].kind===4&&(f[t]=_+n);v&&(g-=n);for(let t=0;t<r;t++)e[t].rank=f[t]-g}function P(e,t,n,r,i,a,o){let l=n===0?e.predStart:e.succStart,u=n===0?e.predE:e.succE,d=n===0?e.EF:e.ET,f=e.pos;for(let e=l[t];e<l[t+1];e++)i[u[e]]!==0&&a.push(u[e]);if(a.length<2)return 0;a.sort((e,t)=>f[d[e]]-f[d[t]]||e-t);let p=e=>{let t=0;o[0]=0;for(let n=1;n<a.length;n++){let r=i[a[n]]===i[a[n-1]];o[n]=e(r&&i[a[n]]===1,r),t+=o[n]}return t},m=p(()=>1);if(r/m<c&&(m=p(e=>e?.5:1)),r/m<c&&(m=p((e,t)=>+!t)),m===0)return 0;let h=Math.min(s,r/m);for(let e=1;e<a.length;e++)o[e]*=h;return m*h}function F(e,t,n,r){let{real:i,W:a,EFD:o,ETD:s}=e;for(let c=0;c<i;c++){let i=Math.min(t[c].span,a[c]);if(!(i<=0||t[c].kind!==0))for(let t=0;t<2;t++){let a=[],l=[],u=P(e,c,t,i,t===0?r:n,a,l);if(u===0)continue;let d=t===0?s:o,f=-u/2;for(let e=0;e<a.length;e++)f+=l[e],d[a[e]]=f}}}function I(e,t,n,r){if(!t)return n;let{KIND:i,RANK:a,EF:o,ET:s,succStart:c,succE:l,predStart:u,predE:d}=e;for(let e=0;e<1e5;e++){let e=r===0?o[n]:s[n];if(i[e]!==1||!t[a[e]])break;n=r===0?d[u[e]]:l[c[e]]}return n}function L(e,t,n){let r=[new Int32Array(e.n),new Int32Array(e.n)];for(let i=0;i<e.EF.length;i++)n[i]!==0&&r[0][e.ET[i]]++,t[i]!==0&&r[1][e.EF[i]]++;return r}function R(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function ee(e,t,n,r,i,a){let o=i.edgeSep,{n:s,real:c,maxRank:l,KIND:u,RANK:d,W:f,EF:p,ET:m,EFD:h,ETD:g,succStart:_,succE:v,predStart:y,predE:b,layerStart:x,order:S,pos:C}=e,w=e=>u[e]===2||u[e]===1&&(a===void 0||a[d[e]]!==1),T=(e,i)=>{let a=i===0?p[e]:m[e];return[i===0?n[a]+h[e]:n[a]+g[e],a<c&&t[a].kind===0?r[1-i][a]:0]},E=e=>{let t=x[d[e]],r=t+C[e],a=t=>f[t]/2+f[e]/2+(u[t]===0?i.nodeSep/2+o/2:u[t]===u[e]?o:o/2);return[r>t?n[S[r-1]]+a(S[r-1]):-1/0,r+1<x[d[e]+1]?n[S[r+1]]-a(S[r+1]):1/0]},D=(e,t,n,r,i)=>{let a=(t[1]===n[1]?Math.abs(t[0]-e)<=Math.abs(n[0]-e):t[1]<n[1])?[t[0],n[0]]:[n[0],t[0]];return a.find(e=>e>=r&&e<=i)??Math.max(r,Math.min(i,a[0]))},k=new Uint8Array(s),A=[];for(let t=1;t<l;t++)for(let r=x[t];r<x[t+1];r++){if(!w(S[r])||k[S[r]])continue;let t=S[r];for(;O(u[p[b[y[t]]]]);)t=p[b[y[t]]];let i=t,o=-1/0,s=1/0;A.length=0;for(let e=t;O(u[e]);e=m[v[_[e]]]){if(i=e,!w(e))continue;k[e]=1,A.push(e);let[t,n]=E(e);t>o&&(o=t),n<s&&(s=n)}if(o<=s){let e=D(n[A[0]],T(b[y[t]],0),T(v[_[i]],1),o,s);for(let t of A)n[t]=e}else for(let t of A){let[r,i]=E(t);r>i||(n[t]=D(n[t],T(I(e,a,b[y[t]],0),0),T(I(e,a,v[_[t]],1),1),r,i))}}}function te(e,t,n,r,i,a,o){let{real:c,W:l,EF:u,ET:d,EFD:f,ETD:p,succStart:m,succE:h,predStart:g,predE:_,pos:v}=e,y=(s,m,h,g,_)=>{if(a[m][h]<2)return 0;s=I(e,o,s,m);let v=m===0?u[s]:d[s],y=m===0?n[v]+f[s]:n[v]+p[s];if(_&&Math.abs(y-n[h])<=g/2+x)return Math.max(-g/2,Math.min(g/2,y-n[h]));let b=y,S=0;v<c&&t[v].kind===0&&(m===0?r:i)[s]!==0&&a[1-m][v]>=2&&(S=Math.max(0,Math.min(t[v].span,l[v])),S>0&&(b=n[v]));let w=Math.max(n[h]-g/2,b-S/2),T=Math.min(n[h]+g/2,b+S/2);if(w>T+x){let e=Math.max(0,g/2-C);return Math.max(-e,Math.min(e,y-n[h]))}let E=(n[h]*S+b*g)/(S+g);return Math.max(w,Math.min(T,E))-n[h]},b=[];for(let n=0;n<c;n++){let a=Math.min(t[n].span,l[n]);if(!(a<=0||t[n].kind!==0))for(let t=0;t<2;t++){let o=t===0?u:d,s=t===0?g:m,c=t===0?_:h,l=[],f=[];if(P(e,n,t,a,t===0?i:r,l,f),l.length===0)continue;l.length===1&&(f[0]=0);let p=[];for(let e=s[n];e<s[n+1];e++)p.push(c[e]);p.sort((e,t)=>v[o[e]]-v[o[t]]||e-t),b.push({v:n,side:t,span:a,ids:l,room:f,all:p})}}for(let e=0,t=!0;t&&e<6;e++){t=!1;for(let{v:n,side:a,span:o,ids:c,room:l,all:u}of b){let d=a===0?i:r,m=a===0?p:f,h=0,g=-o/2;for(let r=0;r<=u.length;r++){let i=r<u.length&&d[u[r]]===0;if(r<u.length&&!i)continue;let f=0;for(let e=r-1;e>=0&&d[u[e]]!==0;e--)f++;let p=i?m[u[r]]-s:o/2;if(f>0){let r=[],i=[],s=0;for(let t=0;t<f;t++){t>0&&(s+=l[h+t]),r.push(y(c[h+t],a,n,o,e>0)-s),i.push(1);let u=t>0&&l[h+t]===0;for(;r.length>1&&(u||r[r.length-2]/i[i.length-2]>r[r.length-1]/i[i.length-1]);){u=!1;let e=r.pop(),t=i.pop();r[r.length-1]+=e,i[i.length-1]+=t}}let u=s,d=0;s=0;for(let e=0;e<r.length;e++){let n=p-u<g?(g+p-u)/2:Math.max(g,Math.min(p-u,r[e]/i[e]));for(let r=0;r<i[e];r++,d++)d>0&&(s+=l[h+d]),Math.abs(m[c[h+d]]-n-s)>.01&&(t=!0),m[c[h+d]]=n+s}h+=f}i&&(g=m[u[r]]+s)}}}}function ne(e,t,n,r){let{n:i,KIND:a,RANK:o,EF:s,ET:c,EFD:l,ETD:u,layerStart:d,order:f,pos:p}=e,m=e=>n!==void 0&&a[e]===1&&n[o[e]]===1,h=[],g=[],_=[],v=[];for(let t=0;t<s.length;t++){if(m(s[t]))continue;let r=I(e,n,t,1);h.push(s[t]),g.push(c[r]),_.push(l[t]),v.push(u[r])}let y=e=>t[g[e]]+v[e]-t[h[e]]-_[e],b=new Int32Array(i),x=[];for(let e=0;e<i;e++)b[e]=e,x.push([e]);let C=(e,t)=>{let n=b[e],r=b[t];if(n!==r){x[n].length<x[r].length&&([n,r]=[r,n]);for(let e of x[r])b[e]=n,x[n].push(e);x[r]=[]}},w=[];for(let e=0;e<h.length;e++){let t=Math.abs(y(e));t<.01?C(h[e],g[e]):t<=S&&w.push(e)}if(w.length===0)return;w.sort((e,t)=>Math.abs(y(e))-Math.abs(y(t))||e-t);let T=t=>B(e,r,t),E=(e,n)=>{for(let r of x[e]){let i=d[o[r]],a=d[o[r]+1],s=i+p[r];if(s>i&&b[f[s-1]]!==e&&t[r]+n-t[f[s-1]]<T(r)+T(f[s-1])-.01||s+1<a&&b[f[s+1]]!==e&&t[f[s+1]]-t[r]-n<T(r)+T(f[s+1])-.01)return!1}return!0};for(let e of w){let n=y(e);if(Math.abs(n)<.01){C(h[e],g[e]);continue}if(Math.abs(n)>S||b[h[e]]===b[g[e]])continue;let r=b[h[e]],i=b[g[e]],a=x[r].length<=x[i].length?r:i;for(let o of[a,a===r?i:r]){let i=o===r?n:-n;if(E(o,i)){for(let e of x[o])t[e]+=i;C(h[e],g[e]);break}}}}function re(e){let{maxRank:t,KIND:n,layerStart:r,order:i}=e,a=new Uint8Array(t+1),o=!1;for(let e=1;e<t;e++){let t=r[e+1]>r[e];for(let a=r[e];t&&a<r[e+1];a++)n[i[a]]!==1&&(t=!1);t&&(a[e]=1,o=!0)}return o?a:void 0}function z(e,t,n,r,i){let{from:a,to:o,rank:s,track:c,levels:l,wide:u}=e,d=a.length,f=new Map;for(let e=0;e<d;e++){if(c.push(-1),l.push(0),Math.abs(a[e]-o[e])<x)continue;let t=f.get(s[e]);t?t.push(e):f.set(s[e],[e])}if(f.size===0)return;let p=new Float64Array(d),m=new Float64Array(d);for(let e=0;e<d;e++)p[e]=Math.min(a[e],o[e]),m[e]=Math.max(a[e],o[e]);let h=(e,t)=>+(e>=p[t]-x&&e<=m[t]+x),g=(e,t)=>Math.abs(a[e]-a[t])<x||Math.abs(o[e]-o[t])<x,S=(e,t)=>p[e]<m[t]-x&&p[t]<m[e]-x,C=(e,t)=>S(e,t)&&!g(e,t),O=(e,t)=>S(e,t)||h(o[e],t)+h(a[t],e)+h(o[t],e)+h(a[e],t)>0,k=(e,t)=>h(o[e],t)+h(a[t],e),A=e=>{let t=e.map((e,t)=>t).sort((t,n)=>p[e[t]]-p[e[n]]),n=[];for(let r=0;r<t.length;r++){let i=t[r],a=m[e[i]]+4*x;for(let o=r+1;o<t.length&&p[e[t[o]]]<=a;o++){let e=t[o];n.push(Math.min(i,e),Math.max(i,e))}}return n},j=e=>{e.sort((e,t)=>m[t]-p[t]-(m[e]-p[e])||p[e]-p[t]||e-t);let t=e.length,r=[],i=e.map((e,t)=>t),a=e=>{for(;i[e]!==e;)e=i[e]=i[i[e]];return e},o=t<=w,s=o?A(e):[],u=o?e.map(()=>[]):[];for(let t=0;t<s.length;t+=2){let n=s[t],r=s[t+1];C(e[n],e[r])&&(u[n].push(r),u[r].push(n))}let d=e.map((e,t)=>t);if(o){let n=new Int32Array(t),o=[];for(let e=0;e<t;e++)r.push([]),o.push([]);for(let t=0;t<s.length;t+=2){let c=s[t],l=s[t+1],u=e[c],d=e[l];if(!O(u,d))continue;i[a(c)]=a(l);let f=k(u,d),p=k(d,u);if(f===p)continue;let m=f<p?c:l,h=f<p?l:c;r[h].push(m),o[m].push(h),n[h]++}let c=new Uint8Array(t);d=[];for(let e=0;e<t;e++){let e=-1;for(let r=0;r<t&&!(!c[r]&&((e<0||n[r]<n[e])&&(e=r),n[r]===0));r++);c[e]=1,d.push(e);for(let t of o[e])n[t]--}}let f=new Set,h=[],g=0;for(let t of d){let n=e[t],i=0;for(let n of r[t]??[])c[e[n]]>=i&&(i=c[e[n]]+1);if(o){f.clear();for(let n of u[t])f.add(c[e[n]]);for(;f.has(i);)i++}else{for(;h[i]?.some(e=>C(n,e));)i++;(h[i]??=[]).push(n)}c[n]=i,i>=g&&(g=i+1)}let _=new Int32Array(t).fill(g),v=new Int32Array(t).fill(-1);for(let n=0;n<t;n++){let t=a(n);_[t]=Math.min(_[t],c[e[n]]),v[t]=Math.max(v[t],c[e[n]])}for(let r=0;r<t;r++){let t=a(r);l[e[r]]=v[t]-_[t]+1,n&&(c[e[r]]-=_[t])}return g},M=(e,t,n)=>{let r=R(o[e]-a[e],t);for(let i=0;i<=T;i++){let s=i/T,c=1-s;n[2*i]=a[e]+(o[e]-a[e])*s*s*(3-2*s),n[2*i+1]=t*(3*r*s*c*c+3*(1-r)*s*s*c+s*s*s)}},N=(e,t,n)=>{let r=n*n*1.000000001;for(let i=0;i<=T;i++){let a=e[2*i],o=e[2*i+1];for(let e=0;e<T;e++){let i=t[2*e+2]-t[2*e],s=t[2*e+3]-t[2*e+1],c=Math.max(0,Math.min(1,((a-t[2*e])*i+(o-t[2*e+1])*s)/(i*i+s*s||1))),l=a-t[2*e]-c*i,u=o-t[2*e+1]-c*s;if(l*l+u*u<r&&Math.hypot(l,u)<n)return!0}}return!1},P=(e,t,n,r)=>{let i=Math.max(n/2,n-2*_);return M(e,i,E),M(t,i,D),N(E,D,r)||N(D,E,r)};for(let[e,s]of f){if(!n){t[e]=j(s);continue}if(s.length>w)continue;let d=s.filter(e=>u[e]===1);j(d);let f=new Set(d.filter(e=>l[e]>1)),h=A(s);for(let t=0;t<h.length;t+=2){let n=s[h[t]],i=s[h[t+1]];f.has(n)&&f.has(i)||!C(n,i)||a[n]<o[n]!=a[i]<o[i]||P(n,i,r[e],u[n]===1||u[i]===1?v:y)&&f.add(n).add(i)}for(let e of d)c[e]=-1,l[e]=0;if(f.size===0)continue;let _=0,x=0,T=new Set;for(let e=0;e<h.length;e+=2){let t=s[h[e]],n=s[h[e+1]];if(f.has(t)&&f.has(n)){if(!S(t,n))continue;a[t]<o[t]==a[n]<o[n]?g(t,n)||x++:_++}else(f.has(t)||f.has(n))&&O(t,n)&&T.add(t).add(n)}if(_>x){for(let t of s)(m[t]-p[t])*b>i[e]&&(i[e]=(m[t]-p[t])*b);continue}let E=s.filter(e=>f.has(e)||u[e]!==1&&T.has(e));j(E);let D=0;for(let e of E)l[e]>D&&(D=l[e]);t[e]=D}}function ie(e,t,n,r,i,a,o){let{maxRank:s,EF:c,ET:l,EFD:u,ETD:d,succStart:f,succE:p,predStart:m,predE:h,layerStart:g,order:_}=e,v=new Float64Array(t.length),y=new Float64Array(t.length),b=new Float64Array(t.length);for(let a=0;a<r.length;a++){let o=r[a];if(o<0)continue;let s=o+i[a]-1,g=e.RANK[o];for(let e=o;e<s;e++){if(!n[g+e-o])continue;let r=e;for(;r+1<s&&n[g+r+1-o];)r++;let i=h[m[e]],a=p[f[r]],_=t[c[i]]+u[i],x=t[l[a]]+d[a],S=r-e+2;for(let t=e;t<=r;t++)v[t]=_+(x-_)*(t-e+1)/S,y[t]=_,b[t]=x;e=r}}let x=[];for(let r=1;r<s;r++){if(!n[r])continue;let i=g[r],s=g[r+1],c=Array.from(_.subarray(i,s)).sort((e,t)=>y[e]-y[t]||b[e]-b[t]||e-t);for(let n=0;n<c.length;){x.length=0;let r=n;for(;r<c.length&&Math.abs(y[c[r]]-y[c[n]])<1&&Math.abs(b[c[r]]-b[c[n]])<1;r++)x.push(c[r]);x.sort((t,n)=>e.pos[t]-e.pos[n]);for(let e=0;e<x.length;e++){let n=x[e];t[n]=v[n]+(e-(x.length-1)/2)*a,(x.length===1||a===0)&&(o[n]=1)}n=r}}}function ae(e,t,n,r,i,a){let{maxRank:o,W:s,KIND:c,RANK:l,EF:u,ET:d,EFD:f,ETD:p,succStart:m,succE:h,predStart:g,predE:_,layerStart:v,order:y}=e,b=new Uint8Array(o+1),x=!1;for(let e=1;e<o;e++){let t=!1,n=!1;for(let r=v[e];r<v[e+1];r++){let e=c[y[r]];e===2?t=!0:e!==1&&(n=!0)}t&&!n&&(b[e]=1,x=!0)}if(x)for(let e=0;e<n.length;e++){let o=n[e];if(!(o<0))for(let n=o,x=o+r[e]-1;n<x;n++){if(c[n]!==1||!b[l[n]])continue;let e=n,r=n;for(;e>o&&a[e-1];)e--;for(;r+1<x&&a[r+1];)r++;let S=_[g[e]],C=h[m[r]],w=t[u[S]]+f[S],T=t[d[C]]+p[C],E=Math.min(w,T)-i,D=Math.max(w,T)+i,O=!0,k=l[n];for(let e=v[k];O&&e<v[k+1];e++){let n=y[e];c[n]===2&&t[n]+s[n]/2>E&&t[n]-s[n]/2<D&&(O=!1)}if(!O)continue;a[n]=1;let A=r-e+2;for(let n=e;n<=r;n++)t[n]=w+(T-w)*(n-e+1)/A}}}function oe(e,t){let{n,real:r,maxRank:i,W:o,EF:s,ET:c,EFD:l,ETD:u,succStart:d,succE:f,predStart:p,predE:m,layerStart:h,order:g,pos:_,offsets:v,fixed:y,GRP:b,groupParent:x}=e,S=0;for(let e=0;e<=i;e++)S=Math.max(S,h[e+1]-h[e]);if(S<2)return[0,0];let C=v?new Int32Array(s.length):void 0,w=new Int32Array(C?s.length:0),T=new Int32Array(C?n:0),E=C?f.slice():f,D=new Uint8Array(C?n:0);if(C){let e=m.slice(),t=(e,t,n,r)=>{for(let i=t+1;i<n;i++)if(r[e[i]]!==r[e[t]])return e.subarray(t,n).sort((e,t)=>r[e]-r[t]),!0;return!1};for(let r=0;r<n;r++){if(T[r]=1,t(e,p[r],p[r+1],u))for(let t=p[r]+1;t<p[r+1];t++)u[e[t]]!==u[e[t-1]]&&T[r]++,w[e[t]]=T[r]-1;t(E,d[r],d[r+1],l)&&(D[r]=1)}}let O=1;for(;O<(C?S+s.length:S);)O<<=1;let k=new Int32Array(2*O),j=new Int32Array(s.length),M=()=>{let e=0;for(let t=0;t<i;t++){let n=h[t+2]-h[t+1];if(C){let e=0;for(let n=h[t+1];n<h[t+2];n++){let t=g[n];for(let n=p[t];n<p[t+1];n++)C[m[n]]=e+w[m[n]];e+=T[t]}n=e}if(n<2)continue;let r=0;for(let e=h[t];e<h[t+1];e++){let t=g[e],n=d[t],i=d[t+1],a=r;for(let e=n;e<i;e++)j[r++]=C?C[E[e]]:_[c[f[e]]];let o=r-a;if(!(o<2)){if(C&&D[t])for(let e=a+1;e<r;e++){let t=j[e],r=l[E[n+e-a]],i=e-1;for(;i>=a&&l[E[n+i-a]]===r&&j[i]>t;)j[i+1]=j[i],i--;j[i+1]=t}else if(o<=12)for(let e=a+1;e<r;e++){let t=j[e],n=e-1;for(;n>=a&&j[n]>t;)j[n+1]=j[n],n--;j[n+1]=t}else j.subarray(a,r).sort()}}if(r<2)continue;let i=1;for(;i<n;)i<<=1;k.fill(0,0,2*i);for(let t=0;t<r;t++){let n=j[t]+i;for(k[n]++;n>1;)!(n&1)&&(e+=k[n+1]),n>>=1,k[n]++}}return e},N=M(),P=new Float64Array(n),F=new Int32Array(S),I=new Int32Array(S),L=x?x.length:0,R=new Int32Array(L);for(let e=0;e<L;e++)for(let t=e;t>=0;t=x[t])R[e]++;let ee=new Float64Array(L),te=new Int32Array(L),ne=new Int32Array(L),re=(e,t)=>{let r=h[e],i=h[e+1];for(let e=r;e<i;e++)for(let t=b[g[e]];t>=0;t=x[t])ee[t]=0,te[t]=0;for(let e=r;e<i;e++){let n=g[e];for(let r=b[n];r>=0;r=x[r])te[r]===0&&(ne[r]=e),ee[r]+=t[n],te[r]++}let a=e=>e>=n?ee[e-n]/te[e-n]:t[e],o=e=>e>=n?ne[e-n]:r+_[e],s=Array.from(g.subarray(r,i)).sort((e,t)=>{let r=e,i=t,s=b[e],c=b[t],l=s<0?0:R[s],u=c<0?0:R[c];for(;l>u;l--)r=n+s,s=x[s];for(;u>l;u--)i=n+c,c=x[c];for(;s!==c;)r=n+s,s=x[s],i=n+c,c=x[c];return a(r)-a(i)||o(r)-o(i)});g.set(s,r);for(let e=r;e<i;e++)_[g[e]]=e-r};if(b){let e=new Float64Array(n);for(let t=0;t<=i;t++){for(let n=h[t];n<h[t+1];n++)e[g[n]]=n-h[t];re(t,e)}}let z=b?M():N;if(z===0)return[0,N];let ie=g.slice(),ae=Math.min(z,N),oe=(e,n)=>{let a=e?p:d,x=e?m:f,S=e?s:c,C=e?l:u;for(let s=1;s<=i;s++){let c=e?s:i-s;if(y[c])continue;let l=h[c],u=h[c+1],d=0;for(let n=l;n<u;n++){let i=g[n],s=i<r?t[i].pin:0;if(s!==0){P[i]=s*1e9,F[d++]=i;continue}let f=a[i],p=a[i+1];if(f===p){if(b){let t=e?h[c]-h[c-1]:h[c+2]-h[c+1];P[i]=(n-l)*t/(u-l);continue}P[i]=-1;continue}let m=0;for(let e=f;e<p;e++){let t=S[x[e]];m+=_[t],v&&o[t]>0&&(m+=C[x[e]]/o[t])}P[i]=m/(p-f),F[d++]=i}if(b){re(c,P);continue}if(d<2)continue;A(F,d,P,_,n,I);let f=0;for(let e=l;e<u;e++)P[g[e]]!==-1&&(g[e]=F[f++]);for(let e=l;e<u;e++)_[g[e]]=e-l}},B=()=>{let e=0;for(let t=0;t<=i;t++)for(let n=h[t];n<h[t+1];n++)if(!(g[n]>=r))for(let r=n+1;r<h[t+1];r++)g[r]<g[n]&&e++;return e},se=()=>{for(let e=0;e<=i;e++)for(let t=h[e];t<h[e+1];t++)_[g[t]]=t-h[e]},ce=e=>e<r?t[e].pin:0,V=(e,t)=>{let n=t?s[e]:c[e];return v&&o[n]>0?_[n]+(t?l[e]:u[e])/o[n]:_[n]},H=(e,t)=>{let n=0;for(let r=p[e];r<p[e+1];r++){let e=V(m[r],!0);for(let r=p[t];r<p[t+1];r++)e>V(m[r],!0)&&n++}for(let r=d[e];r<d[e+1];r++){let e=V(f[r],!1);for(let r=d[t];r<d[t+1];r++)e>V(f[r],!1)&&n++}return n},le=()=>{for(let e=0;e<8;e++){let e=!1;for(let t=0;t<=i;t++){if(y[t])continue;let n=h[t];for(let r=n;r+1<h[t+1];r++){let t=g[r],i=g[r+1];ce(t)!==ce(i)||b&&b[t]!==b[i]||H(i,t)>=H(t,i)||(g[r]=i,g[r+1]=t,_[i]=r-n,_[t]=r+1-n,e=!0)}}if(!e)break}},U=g.slice(),W=n<=600,ue=ie,de=1/0;for(let e=0;e<(W?2:1);e++){e>0&&(g.set(U),se());let t=ae,n=U.slice();for(let r=0,i=0;i<4&&r<a;r++,i++){oe((r+e)%2==0,r%4>=2);let a=M();if(a<t&&(t=a,n.set(g),i=0,a===0))break}if(g.set(n),W&&t>0){se(),le();let e=M();e<t&&(t=e,n.set(g))}let r=W?B():0;(e===0||t<z||t===z&&r<de)&&(z=t,ue=n,de=r)}if(g.set(ue),se(),ie.set(ue),b&&(z=M()),!W)return[z,N];for(let e=0;e<r;e++)if(t[e].pin!==0)return[z,N];if(de===0||y[0]||y[i])return[z,N];for(let e=0;e<=i;e++)g.subarray(h[e],h[e+1]).reverse();return se(),(M()>z||B()>=de)&&g.set(ie),[z,N]}function B(e,t,n){return e.W[n]/2+(e.KIND[n]===0?t.nodeSep:t.edgeSep)/2}function se(e,t){let{n,maxRank:r,W:i,KIND:a,EF:o,ET:s,EFD:c,ETD:l,succStart:u,succE:d,predStart:f,predE:p,layerStart:m,order:h,pos:g}=e,_=o.length,v=new Float64Array(n);for(let r=0;r<n;r++)v[r]=B(e,t,r);let y=new Int32Array(_);for(let e=0;e<_;e++)y[e]=g[s[e]];for(let e=0;e<n;e++)u[e+1]-u[e]>1&&k(d,u[e],u[e+1],y);for(let e=0;e<_;e++)y[e]=g[o[e]];for(let e=0;e<n;e++)f[e+1]-f[e]>1&&k(p,f[e],f[e+1],y);let b=new Uint8Array(_);for(let e=1;e<=r;e++){let t=m[e]-m[e-1],n=m[e],r=m[e+1],i=0,s=n;for(let e=n;e<r;e++){let n=h[e],c=-1;if(O(a[n])){let e=o[p[f[n]]];O(a[e])&&(c=e)}let l=c>=0?g[c]:t;if(c>=0||e===r-1){for(let t=s;t<=e;t++){let e=h[t],n=O(a[e]);for(let t=f[e];t<f[e+1];t++){let e=p[t],r=g[o[e]];(r<i||l<r)&&!(n&&O(a[o[e]]))&&(b[e]=1)}}s=e+1,i=l}}}let x=[],S=new Int32Array(n),C=new Int32Array(n),w=new Float64Array(n),T=new Int32Array(n),E=new Int32Array(n),D=new Float64Array(n),A=new Int32Array(n),j=new Int32Array(n+1),M=new Int32Array(n),N=new Int32Array(n),P=new Int32Array(n),F=new Float64Array(n);for(let e=0;e<4;e++){let t=e<2,i=(e&1)==1,a=t?f:u,_=t?p:d,y=t?o:s,O=t?l:c,k=t?c:l;for(let e=0;e<n;e++)S[e]=e,C[e]=e,w[e]=0,A[e]=0,j[e+1]=0,F[e]=0;for(let e=0;e<=r;e++){let n=t?e:r-e,o=m[n],s=m[n+1],c=t?n-1:n+1,l=c>=0&&c<=r?m[c+1]-m[c]-1:0,u=-1;for(let e=i?s-1:o;i?e>=o:e<s;i?e--:e++){let t=h[e],n=a[t],r=a[t+1]-n;if(r===0)continue;let o=n+(r-1>>1),s=n+(r>>1);for(let e=0;e<2&&(e!==1||o!==s);e++){let n=_[e===0===i?s:o],r=y[n],a=i?l-g[r]:g[r];C[t]===t&&u<a&&b[n]===0&&(C[r]=t,C[t]=S[t]=S[r],w[t]=w[r]+k[n]-O[n],u=a)}}}let I=0;for(let e=0;e<=r;e++){let t=m[e],n=m[e+1];for(let e=t+1;e<n;e++){let t=i?h[e]:h[e-1],n=i?h[e-1]:h[e],r=v[t]+v[n];T[I]=S[t],E[I]=S[n],D[I]=i?r-w[t]+w[n]:r+w[t]-w[n],A[S[n]]++,j[S[t]+1]++,I++}}for(let e=0;e<n;e++)j[e+1]+=j[e];for(let e=0;e<n;e++)N[e]=j[e];for(let e=0;e<I;e++)M[N[T[e]]++]=e;let L=0;for(let e=0;e<n;e++)S[e]===e&&A[e]===0&&(P[L++]=e);for(let e=0;e<L;e++){let t=P[e];for(let e=j[t];e<j[t+1];e++){let n=M[e],r=E[n];F[t]+D[n]>F[r]&&(F[r]=F[t]+D[n]),--A[r]===0&&(P[L++]=r)}}for(let e=L-1;e>=0;e--){let t=P[e],n=1/0;for(let e=j[t];e<j[t+1];e++){let t=M[e],r=F[E[t]]-D[t];r<n&&(n=r)}n!==1/0&&n>F[t]&&(F[t]=n)}let R=new Float64Array(n);for(let e=0;e<n;e++)R[e]=(i?-F[S[e]]:F[S[e]])+w[e];x.push(R)}let I=0,L=1/0,R=[],ee=[];for(let e=0;e<4;e++){let t=1/0,r=-1/0,a=x[e];for(let e=0;e<n;e++){let n=i[e]/2;a[e]-n<t&&(t=a[e]-n),a[e]+n>r&&(r=a[e]+n)}R.push(t),ee.push(r),r-t<L&&(L=r-t,I=e)}for(let e=0;e<4;e++){let t=e&1?ee[I]-ee[e]:R[I]-R[e];if(t!==0){let r=x[e];for(let e=0;e<n;e++)r[e]+=t}}let te=new Float64Array(n);for(let e=0;e<n;e++){let t=x[0][e],n=x[1][e],r=x[2][e],i=x[3][e],a;t>n&&(a=t,t=n,n=a),r>i&&(a=r,r=i,i=a),t>r&&(a=t,t=r,r=a),n>i&&(a=n,n=i,i=a),n>r&&(a=n,n=r,r=a),te[e]=(n+r)/2}return te}var ce=12,V=.62,H=6;function le(){let e=new Map;return{add(t,n,r){let i=W(r);n>=0&&i>0&&i+H>(e.get(t*4+n)??0)&&e.set(t*4+n,i+H)},of:(t,n)=>n>=0?e.get(t*4+n)??0:0}}function U(e,t,r,i,a=r>0?r+H:0,o=i>0?i+H:0){let s=t===`linear`,c=t===`step`||t===`stepBefore`||t===`stepAfter`,l=[],u=[],d=[],f=(e,t,n,r)=>Math.abs(e-n)<.01&&Math.abs(t-r)<.01;for(let n=0;n<e.length;n+=3){let r=e[n],i=e[n+1],a=e[n+2],o=l.length-1;if(c&&o>=0&&Math.abs(r-l[o])>=.01&&Math.abs(i-u[o])>=.01){let e=l[o],n=u[o],s=t===`stepBefore`?n:t===`stepAfter`?i:(n+i)/2,c=t===`stepBefore`?e:t===`stepAfter`?r:(e+r)/2,p=a===0?[e,s,r,s]:[c,n,c,i];for(let t=0;t<4;t+=2)f(p[t],p[t+1],e,n)||f(p[t],p[t+1],r,i)||(l.push(p[t]),u.push(p[t+1]),d.push(a))}l.push(r),u.push(i),d.push(a)}let p=l.length-1,m=e=>Math.abs(l[e]-l[e-1])<.01||Math.abs(u[e]-u[e-1])<.01,h=e=>s||m(e),g=(e,t,n)=>{if(!h(Math.max(e,t)))return n===0?[0,Math.sign(u[t]-u[e])||1]:[Math.sign(l[t]-l[e])||1,0];let r=l[t]-l[e],i=u[t]-u[e],a=Math.hypot(r,i)||1;return[r/a,i/a]},[_,v]=g(0,1,d[1]),[y,b]=g(p-1,p,d[p]),x=l[0],S=u[0],C=l[p],w=u[p];l[0]+=_*r,u[0]+=v*r,l[p]-=y*i,u[p]-=b*i;let T=e=>Math.abs(l[e]-l[e-1])+Math.abs(u[e]-u[e-1]),E=e=>!s&&e>0&&e<p&&m(e)&&m(e+1)&&T(e)>=.01&&T(e+1)>=.01&&Math.abs(l[e]-l[e-1])<.01!=Math.abs(l[e+1]-l[e])<.01,D=(e,t,n)=>Math.abs(l[e]-l[e-1])*Math.abs(t)+Math.abs(u[e]-u[e-1])*Math.abs(n),O=(e,t,n)=>{let r=Math.min(Math.max(0,e-H-t),n/4);return r+Math.min(e-t-r,(n-r)/4)},k=o>i&&(!h(p)||E(p-1))?O(o,i,D(p,y,b)):0,A=a>r&&(!h(1)||E(1))?O(a,r,D(1,_,v)):0;k>=1&&(l.splice(p,0,l[p]-y*k),u.splice(p,0,u[p]-b*k),d.splice(p,0,d[p]),p++),A>=1&&(l.splice(1,0,l[0]+_*A),u.splice(1,0,u[0]+v*A),d.splice(1,0,d[1]),p++);let j=`M${n(l[0])},${n(u[0])}`,M=l[0],N=u[0],P=(e,t)=>{f(e,t,M,N)||(j+=`L${n(e)},${n(t)}`,M=e,N=t)};for(let e=1;e<=p;e++){let t=l[e],r=u[e];if(!h(e)){let i=d[e]===0,a=i?r-N:t-M,o=Math.abs(a)*R(i?t-M:r-N,a),s=i?0:Math.sign(a)*o,c=i?Math.sign(a)*o:0;j+=`C${n(M+s)},${n(N+c)} ${n(t-s)},${n(r-c)} ${n(t)},${n(r)}`,M=t,N=r;continue}if(!E(e)){if(e<p&&m(e)&&m(e+1)&&(t-l[e-1])*(l[e+1]-t)+(r-u[e-1])*(u[e+1]-r)>0)continue;P(t,r);continue}let i=E(e-1)?T(e)/2:T(e),a=E(e+1)?T(e+1)/2:T(e+1);c&&(i=a=Math.min(ce,i,a));let[o,s]=g(e-1,e,d[e]),[f,_]=g(e,e+1,d[e+1]);P(t-o*i,r-s*i),M=t+f*a,N=r+_*a,j+=c?`Q${n(t)},${n(r)} ${n(M)},${n(N)}`:`C${n(t-o*i*(1-V))},${n(r-s*i*(1-V))} ${n(t+f*a*(1-V))},${n(r+_*a*(1-V))} ${n(M)},${n(N)}`}return{d:j,sx:x,sy:S,sdx:-_,sdy:-v,ex:C,ey:w,edx:y,edy:b}}function W(e){return e===`arrow_point`?7:e===`arrow_circle`?8:e===`arrow_cross`?4:0}function ue(e,t,r,i,a,o){let s=-a,c=i;if(e===`arrow_point`){let e=t-i*8,l=r-a*8,u=3.36;return`<path class="pele-marker" d="M${n(t)},${n(r)}L${n(e+s*u)},${n(l+c*u)}L${n(e-s*u)},${n(l-c*u)}Z" fill="${o}" stroke="none"/>`}if(e===`arrow_circle`)return`<circle class="pele-marker" cx="${n(t-i*4)}" cy="${n(r-a*4)}" r="3.5" fill="${o}" stroke="none"/>`;if(e===`arrow_cross`){let e=t-i*4,o=r-a*4,l=3.5,u=(i+s)*l,d=(a+c)*l,f=(i-s)*l,p=(a-c)*l;return`<path class="pele-marker" d="M${n(e-u)},${n(o-d)}L${n(e+u)},${n(o+d)}M${n(e-f)},${n(o-p)}L${n(e+f)},${n(o+p)}"/>`}return``}function de(r,i,a,o,s,c){let l=i.width+8,u=i.height;return`<g class="pele-edge-label" data-id="${e(r)}"><rect x="${n(a-l/2)}" y="${n(o-u/2)}" width="${n(l)}" height="${n(u)}" rx="3" fill="var(--_bg)"/>`+t(i,a,o,s,c)+`</g>`}function G(e,t,r,i,a,o,s,c){let l=(a?t:r)/2,u=Math.min(l-4,8+i*6),d=o+i*8,f=Math.hypot(d,u)||1,p=(i,o)=>a?`${n(e.x+o)},${n(e.y+r/2+i)}`:`${n(e.x+t/2+i)},${n(e.y+o)}`,m=d/f*s,h=u/f*s;return a?(c.labelX=e.x,c.labelY=e.y+r/2+d+4+c.labelH/2):(c.labelX=e.x+t/2+d+4+c.labelW/2,c.labelY=e.y),{d:`M${p(0,-u)}C${p(d,-u*2)} ${p(d,u*2)} ${p(m,u+h)}`,sx:a?e.x-u:e.x+t/2,sy:a?e.y+r/2:e.y-u,sdx:a?0:-1,sdy:a?-1:0,ex:a?e.x+u:e.x+t/2,ey:a?e.y+r/2:e.y+u,edx:a?-u/f:-d/f,edy:a?-d/f:-u/f}}export{W as a,j as c,le as d,M as f,de as i,U as l,N as n,r as o,R as r,ue as s,i as t,G as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./C5HTQT3I-7U13x70S.js";var t=/[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*({))/y;function n(){let e=!1;return(n,r)=>{t.lastIndex=r;let i=t.exec(n);if(i===null)return-1;let a=t.lastIndex;if(i[1]===void 0)return a;if(e)return-1;let o=n.indexOf(`}`,a);return e=o===-1,o+1||-1}}function r(t=`ACC_DESCR`){return{...e,name:t,scanner:n}}export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,x as t}from"./E3FWOBN4-D5m5o2g0.js";function n(e,t){for(let n=0;n<t.length;n+=3){let r=Math.round(t[n+1]),i=e.get(r);i?i.push(t[n]):e.set(r,[t[n]])}}function r(e,t,n,r){if(t===0)return e.x;let i=e.y-e.h/2,a=e.x-e.w/2,o=t/2,s=[a+r-6+o,e.x,a+e.w-r+6-o],c=n.get(Math.round(i));if(c===void 0)return s[0];let l=s[0],u=-1;for(let t of s){let n=1/0;for(let r of c)r>a&&r<a+e.w&&(n=Math.min(n,Math.abs(r-t)-o));if(n>=6)return t;n>u+.5&&(u=n,l=t)}return l}function i(e,t,n,r){let i=t>0?r.get(Math.round(e.y-e.h/2)):void 0;if(i===void 0)return!1;let a=e.x-e.w/2;for(let r of i)if(r>a&&r<a+e.w&&Math.abs(r-n)<t/2+4)return!0;return!1}function a(n,r,i,a,o,s,c,l){let u=1;for(let e=s[c].parent;e>=0&&u<8;e=s[e].parent)u++;let d=`color-mix(in srgb,var(--_a) ${t(100*(1-.5**u))}%,var(--_bg))`;return`<g class="pele-cluster-title" data-id="${o}">`+e(n,r,i,` fill="none" stroke="${d}" stroke-width="5" stroke-linejoin="round"`,l)+e(n,r,i,a,l)+`</g>`}export{i,r as n,n as r,a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t,n,r){let i=r(t,!1),a=e.maxWidth;if(a===void 0||!(a>0)||i.width<=a)return i;let o=Math.min(n,t),s=t;i=r(s,!0);for(let e=0;e<3&&i.width>a&&s>o;e++)s=Math.max(o,s-(i.width-a)),i=r(s,!0);return i}function t(e){let t=e.maxWidth;return t!==void 0&&t>0?Math.max(80,t-2*(e.padding??8)):4e3}function n(e,t,n,r=0){let i=e.maxWidth;return i===void 0||!(i>0)?t:Math.max(Math.min(n,t),Math.min(t,i-r))}function r(e,t){let n=t(!1),r=e.maxWidth;if(e.autoDirection===!1||r===void 0||!(r>0)||n.width<=r)return n;let i=e.directionBreakpoint;if(r>=(i!==void 0&&i>0?i:640))return n;let a=t(!0);return a.width<n.width?a:n}function i(e){return e===`LR`||e===`RL`}function a(e,t){let n=t(!1),r=e.maxWidth;if(r===void 0||!(r>0)||n.width<=r)return n;let i=t(!0);return i.width<n.width?i:n}export{i as a,n as i,e as n,a as o,t as r,r as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e,c as t,h as n,m as r,o as i,t as a,x as o}from"./E3FWOBN4-D5m5o2g0.js";var s=/\s/;function c(e,t,n,r,i=0){let a=[];for(let o of e.split(`
|
|
2
|
+
`)){let e=Array.from(o);e.length===0&&a.push(``);let c=0;for(;c<e.length;){let o=a=>t.width(e.slice(c,c+a).join(``),n,i)<=r,l=1;for(;l<e.length-c&&o(l);)l=Math.min(e.length-c,l*2);let u=1;for(;u<l;){let e=Math.ceil((u+l)/2);o(e)?u=e:l=e-1}let d=u,f=c+d<e.length;if(f&&!s.test(e[c+d])){for(let t=d-1;t>0;t--)if(s.test(e[c+t])){d=t+1;break}}let p=e.slice(c,c+d).join(``);for(a.push(f&&p.trimEnd()||p),c+=d;f&&c<e.length&&s.test(e[c]);)c++}}e===``&&(a.length=0);let o=a.map(e=>t.width(e,n,i)),c=0;for(let e of o)c=Math.max(c,e);let l=Math.round(n*1.5);return{lines:a.map((e,t)=>[{text:e,style:i,width:o[t]}]),widths:o,width:c,height:a.length*l,size:n,lineHeight:l}}function l(e,t,r){if(e.width<=r)return e;let i=[],a=[];for(let n=0;n<e.lines.length;n++){if(e.widths[n]<=r){i.push(e.lines[n]),a.push(e.widths[n]);continue}let o=[],s=0,c=()=>{i.push(o),a.push(s),o=[],s=0};for(let i of e.lines[n])if(i.icon!==void 0||i.math)o.length&&s+i.width>r&&c(),o.push(i),s+=i.width;else for(let n of Array.from(i.text)){let a=o[o.length-1],l=a&&a.icon===void 0&&a.math===void 0&&a.style===i.style,u=t.width(l?a.text+n:n,e.size,i.style)-(l?a.width:0);o.length&&s+u>r&&(c(),a=void 0,u=t.width(n,e.size,i.style)),a&&a.icon===void 0&&a.math===void 0&&a.style===i.style?(a.text+=n,a.width+=u):o.push({text:n,style:i.style,width:u}),s+=u}(o.length||!e.lines[n].length)&&c()}let o=0;for(let e of a)o=Math.max(o,e);let s={...e,lines:i,widths:a,width:o,height:i.length*e.lineHeight};return e.heights?n(s):s}function u(n,s,c,l){let u=t(n),d=`<text`+a(l,u),f=``;for(let t=0;t<n.lines.length;t++){let a=n.lines[t],p=c+(t+.5)*n.lineHeight;if(a.some(e=>e.icon!==void 0)){let e=n.widths[t];f+=i({...n,lines:[a],widths:[e],width:e,height:n.lineHeight},s+e/2,p,l);continue}let m=``;for(let t of a){let n=r(t.style&~u);m+=n?`<tspan${n}>${e(t.text)}</tspan>`:e(t.text)}m!==``&&(f+=`${d} x="${o(s)}" y="${o(p+n.size*.35)}" text-anchor="start" xml:space="preserve">${m}</text>`)}return f}export{u as n,l as r,c as t};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{d as e,f as t,m as n,p as r}from"./lazy-DaMZI1F7.js";var i=/[&<>"\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]/u,a=/[&<>"]|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]+/gu,o={"&":`&`,"<":`<`,">":`>`,'"':`"`},s=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]/u;function c(e){return i.test(e)?e.replace(a,e=>o[e]??``):e}function l(t){return c(e(t))}var u=[];for(let e=0;e<100;e++)u.push(e===0?``:e%10==0?`.`+e/10:`.`+(e<10?`0`+e:e));function d(e){let t=Math.round(e*100);if(t===0)return`0`;if(t>0){if(t<1e11){let e=Math.floor(t/100);return e+u[t-e*100]}}else if(t>-1e11){let e=-t,n=Math.floor(e/100);return`-`+n+u[e-n*100]}return String(t/100)}function f(e,t,n,r,i){let a=e.lines;if(a.length===0)return``;let o=e.lineHeight,s=e.heights,u=e.size*.35,f=n-e.height/2,p=a.length===1&&a[0].length===1?a[0][0]:void 0;if(p&&p.icon===void 0&&p.math===void 0&&p.style===0)return`<text${r} x="${d(t)}" y="${d(f+o/2+u)}" text-anchor="middle">${c(p.text)}</text>`;let m=T(e),h=r,g;r=E(r,m);let _=``,b=``;for(let n=0;n<a.length;n++){let r=a[n],p=s?s[n]:o,x=f+p/2,S=x+u,C=!1;for(let e of r)(e.icon!==void 0||e.math)&&(C=!0);if(C){let a=t-e.widths[n]/2;for(let t of r){if(t.math){let n=`x="${d(a)}" y="${d(x-t.math.height/2)}" width="${d(t.math.width)}" height="${d(t.math.height)}"`;g??=v(h),b+=g.halo===void 0?y(t.math,n,e.size,g.attrs):`<rect ${n} rx="2" fill="${g.halo}"/>`}else if(t.icon!==void 0){let n=e.size*1.1,r=i?.(t.icon)??``;b+=`<svg class="pele-icon" data-icon="${l(t.icon)}" x="${d(a)}" y="${d(x-n/2)}" width="${d(n)}" height="${d(n)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`}else t.text!==``&&(_+=`<tspan x="${d(a)}" y="${d(S)}" text-anchor="start"${w(t.style&~m)}>${c(t.text)}</tspan>`);a+=t.width}}else{for(let e=0;e<r.length;e++){let n=r[e],i=e===0?` x="${d(t)}" y="${d(S)}"`:``;_+=`<tspan${i}${w(n.style&~m)}>${c(n.text)}</tspan>`}r.length===0&&(_+=`<tspan x="${d(t)}" y="${d(S)}"> </tspan>`)}f+=p}return`<text${r} text-anchor="middle" xml:space="preserve">${_}</text>${b}`}var p=/ fill="([^"]*)"/,m=/ stroke="([^"]*)"/,h=/ style="([^"]*)"/,g=/(?:^|;)\s*fill:([^;]*)/,_=/(?:^|;)\s*opacity:([^;]*)/;function v(e){let t=h.exec(e)?.[1]??``,n=(g.exec(t)?.[1]??p.exec(e)?.[1]??``).trim();if(n===`none`)return{attrs:``,halo:m.exec(e)?.[1]??`none`};let r=_.exec(t)?.[1].trim();return{attrs:(n===``?``:` color="${n}"`)+(r?` opacity="${r}"`:``)}}function y(e,t,n,r){return`svg`in e?`<svg class="pele-math" ${t} overflow="visible"${r}>${e.svg}</svg>`:`<foreignObject class="pele-math" ${t} overflow="visible"${r}><div xmlns="http://www.w3.org/1999/xhtml" style="display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:${d(n)}px;line-height:normal;white-space:nowrap">${e.html}</div></foreignObject>`}var b=` font-weight="var(--_w)"`,x=` font-style="italic"`,S=` text-decoration="underline"`,C=` font-family="var(--_fm)"`,ee=` baseline-shift="sub" font-size="smaller"`,te=` baseline-shift="super" font-size="smaller"`;function w(e){return(e&1?b:``)+(e&2?x:``)+(e&4?C:``)+(e&32?S:``)+(e&8?ee:e&16?te:``)}function T(e){let t=7,n=!1;for(let r of e.lines)for(let e of r)e.icon!==void 0||e.text===``||(t&=e.style,n=!0);return n?t:0}function E(e,t){return e+(t&1&&!e.includes(` font-weight="`)?b:``)+(t&2&&!e.includes(` font-style="`)?x:``)+(t&4&&!e.includes(` font-family="`)?C:``)}var ne=1.5,D=1.3,re=/<br\s*\/?>|\\n|\n/gi,O=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,k=/(fa[bklrs]?):fa-([\w-]+)/g,A=/[<\\\n*_]|fa[bklrs]?:fa-/,j=new Map([[`b`,1],[`strong`,1],[`i`,2],[`em`,2],[`cite`,2],[`dfn`,2],[`var`,2],[`code`,4],[`kbd`,4],[`samp`,4],[`tt`,4],[`sub`,8],[`sup`,16],[`u`,32],[`ins`,32]]),ie=24,ae=new Set(`a abbr address article aside audio b bdi bdo big blockquote body br button caption center cite code col colgroup data dd del details dfn dialog div dl dt em embed fieldset figcaption figure font footer form h1 h2 h3 h4 h5 h6 head header hr html i iframe img input ins kbd label legend li link main map mark meta meter nav noscript object ol optgroup option output p picture pre progress q rp rt ruby s samp script section select small source span strike strong style sub summary sup table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr`.split(` `)),M=`\\u2e80-\\u9fff\\uf900-\\ufaff\\uff00-\\uff60`,N=`、。,.:;!?)]}」』】〕〉》〙〗ー…‥・ゝゞぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ,.:;!?)\\]}`,oe=`([{「『【〔〈《〘〖([{`,se=RegExp(`[${M}]`),P=`\\u200b\\u00ad`,ce=RegExp(`[${P}]`),le=RegExp(`\\s*(?:[${oe}]*[${M}][${N}]*|[^\\s${M}${P}]+[${P}]*[${N}]*|[${P}]+)\\s*|\\s+`,`g`),F=57344,I=6400,L=/\$\$(.+?)\$\$/g,R=/[\ue000-\uf8ff]/,z=/([\ue000-\uf8ff])/,B,V={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function H(e){let t=e.split(`
|
|
2
|
+
`),n=1/0;for(let e of t){if(e.trim()===``)continue;let t=e.length-e.trimStart().length;t<n&&(n=t)}return n===1/0||n===0?e:t.map(e=>e.slice(Math.min(n,e.length-e.trimStart().length))).join(`
|
|
3
|
+
`)}function U(e){return e!==void 0&&e.icon===void 0&&e.math===void 0}function W(e,t,n){if(t!==``){if(B!==void 0&&R.test(t)){let r=B,i=t.split(z);for(let t=0;t<i.length;t++){if(t%2==0){i[t]!==``&&G(e,i[t],n);continue}let a=i[t].charCodeAt(0)-F,o=r.math[a];o?e.push({text:``,style:n,math:o,width:o.width}):G(e,`$$${r.tex[a]}$$`,n)}return}G(e,t,n)}}function G(t,n,r){let i=e(n),a=t[t.length-1];U(a)&&a.style===r?a.text+=i:t.push({text:i,style:r,width:0})}function ue(e,n,r){if(!n.includes(`:fa-`)){W(e,n,r);return}let i=0;k.lastIndex=0;let a;for(;(a=k.exec(n))!==null;){let o=`${a[1]}:fa-${a[2]}`;if(W(e,n.slice(i,a.index),r),i=a.index+a[0].length,t(o)!==``)e.push({text:``,style:r,icon:o,width:0});else if(n[i]===` `)i++;else if(i===n.length){let t=e[e.length-1];U(t)&&(t.text=t.text.trimEnd())}}W(e,n.slice(i),r)}function de(e,t,n,r,i){let a=i.style,o=0,s=``,c=0,l=t.length,u=()=>{ue(e,s,a|(i.shifts[i.shifts.length-1]??0)),s=``};for(;c<l;){let e=t[c];if(e===`<`){O.lastIndex=c;let e=O.exec(t);if(e&&e.index===c){let n=e[1].toLowerCase(),o=t[c+1]===`/`,s=j.get(n)??0;if(s&ie){u();let e=i.shifts.lastIndexOf(s);o?e!==-1&&i.shifts.splice(e,1):i.shifts.push(s)}else s&&(u(),i.style=o?i.style&~s|r&s:i.style|s,a=o?a&~s|r&s:a|s);if(s||ae.has(n)){c+=e[0].length;continue}}}else if(n&&(e===`*`||e===`_`)){let n=t[c+1]===e,i=n?1:2,s=n?2:1,d=(o&i)===0,f=c>0?t[c-1]:` `,p=c+s<l?t[c+s]:` `,m=d&&p.trim()!==``&&t.indexOf(n?e+e:e,c+s)!==-1,h=!d&&f.trim()!==``,g=e===`_`&&/\w/.test(f)&&/\w/.test(p);if((m||h)&&!g){u(),o=m?o|i:o&~i,a=m?a|i:a&~i|r&i,c+=s;continue}}s+=e,c++}u()}function fe(e,t,n){let r=0;for(let i of e)i.width=i.icon===void 0?i.math?i.math.width:t.width(i.text,n,i.style):n*1.25,r+=i.width;return r}function K(e,t,n,r,i,a){let o=[],s=0,c=(e=!1)=>{let r=o[o.length-1];if(U(r)){let i=r.text.trimEnd();if(e&&r.text.endsWith(``)&&(i=i.slice(0,-1)+`-`),i!==r.text){r.text=i;let e=t.width(i,n,r.style);s+=e-r.width,r.width=e}}i.push(o),a.push(s),o=[],s=0};for(let i of e){if(i.icon!==void 0||i.math){let e=i.math?i.math.width:n*1.25;s>0&&s+e>r&&c(),o.push({...i,width:e}),s+=e;continue}let a=i.text.match(le)??[],l=i.text.includes(``),u=l?a.length:0,d=new Float64Array(u),f=new Float64Array(u+1);for(let r=u-1;r>=0;r--){let o=a[r].endsWith(``),s=a[r].trimEnd();d[r]=t.width(o?s.slice(0,-1):s,n,i.style),f[r]=o?r===u-1?i===e[e.length-1]?d[r]:1/0:d[r]+f[r+1]:d[r]}for(let e=0;e<a.length;e++){let u=a[e],p=l?d[e]:t.width(u.trimEnd(),n,i.style),m=!l||!u.endsWith(``)?s+p<=r:s+t.width(u.slice(0,-1)+`-`,n,i.style)<=r||s+f[e]<=r;s>0&&!m&&(c(u.trimStart()===u),u=u.trimStart());let h=o[o.length-1];if(U(h)&&h.style===i.style){if(h.text+=u,p>0||u.trimEnd()!==u){let e=h.width;h.width=t.width(h.text,n,h.style),s+=h.width-e}}else{let e=t.width(u,n,i.style);o.push({text:u,style:i.style,width:e}),s+=e}}}(o.length>0||i.length===0)&&c()}function pe(t,i,a,o,s,c=0){if(t===void 0||t===``)return V;let l=Math.round(o*ne);if(r()&&t.includes(`$$`)&&!R.test(t)){let r={tex:[],math:[]},u=t.replace(L,(e,t)=>r.tex.length===I?e:(r.tex.push(t),String.fromCharCode(F+r.tex.length-1)));if(r.tex.length>0){for(let t of r.tex)r.math.push(n(e(t),o));return q(u,i,a,o,s,c,l,r)}}if(!A.test(t)&&!t.includes(`&`)&&!t.includes(`fl`)){let e=t.trim(),n=a.width(e,o,c);if(n<=s||!(e.includes(` `)||se.test(e)||ce.test(e)))return{lines:[[{text:e,style:c,width:n}]],widths:[n],width:n,height:l,size:o,lineHeight:l};let r=[],i=[];K([{text:e,style:c,width:n}],a,o,s,r,i);let u=0;for(let e of i)e>u&&(u=e);let d=r.length>1?Math.round(o*D):l;return{lines:r,widths:i,width:u,height:r.length*d,size:o,lineHeight:d}}return q(t,i,a,o,s,c,l)}function q(e,t,n,r,i,a,o,s){let c=B;B=s;try{let c=me(e,t,n,r,i,a,o);return s?J(c):c}finally{B=c}}function me(e,t,n,r,i,a,o){let s=t?H(e.replace(/\r\n?/g,`
|
|
4
|
+
`)).trim():e.trim(),c=[],l=[],u=0,d={style:a,shifts:[]};for(let e of s.split(re)){let o=[];de(o,e.trim(),t,a,d);let s=fe(o,n,r);s>i?K(o,n,r,i,c,l):(c.push(o),l.push(s))}for(let e of l)e>u&&(u=e);let f=c.length>1?Math.round(r*D):o;return{lines:c,widths:l,width:u,height:c.length*f,size:r,lineHeight:f}}function J(e){let t;for(let n=0;n<e.lines.length;n++){let r=e.lineHeight;for(let t of e.lines[n])t.math&&(r=Math.max(r,Math.ceil(t.math.height+e.size/4)));r!==e.lineHeight&&t===void 0&&(t=e.lines.map(()=>e.lineHeight)),t&&(t[n]=r)}if(t===void 0)return e.heights===void 0?e:{...e,heights:void 0,height:e.lines.length*e.lineHeight};let n=0;for(let e of t)n+=e;return{...e,heights:t,height:n}}function he(e){for(let t of e)if(t.math)return!0;return!1}function ge(e,t){let n=e.heights;if(!n)return(t+.5)*e.lineHeight;let r=0;for(let e=0;e<t;e++)r+=n[e];return r+n[t]/2}function _e(e,t){let n=e.widths[t],r=e.heights?e.heights[t]:e.lineHeight,i={lines:[e.lines[t]],widths:[n],width:n,height:r,size:e.size,lineHeight:e.lineHeight};return r!==e.lineHeight&&(i.heights=[r]),i}var ve=`--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg)`,ye=`var(--_fm)`,be=`var(--pele-radius,4px)`,Y=` style="rx:var(--_r)"`;function xe(e){let t=e.indexOf(` style="`);return t<0?e+Y:`${e.slice(0,t+8)}rx:var(--_r);${e.slice(t+8)}`}var Se=`var(--pele-critical,#e45756)`,X=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,Ce=new RegExp(String.raw`^\s*${X}(?:\s*,\s*${X})*\s*$`,`u`);function Z(e,t){return e&&Ce.test(e)?e:t}function we(e,t,n){return`;--_fm:var(--pele-font-mono,${Z(n,`monospace`)});font:${e}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${Z(t,`sans-serif`)})`}var Te=new Set([`fill`,`fill-opacity`,`stroke`,`stroke-width`,`stroke-dasharray`,`stroke-dashoffset`,`stroke-linecap`,`stroke-linejoin`,`stroke-opacity`,`opacity`,`rx`,`ry`]),Ee=new Set([`color`,`font-size`,`font-family`,`font-weight`,`font-style`,`text-decoration`,`letter-spacing`,`word-spacing`,`opacity`]),De=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,Q={shape:``,line:``,text:``,stroke:void 0,bold:!1,italic:!1,fontSize:void 0};function $(e){if(e.length===0)return Q;let t=new Map,n=new Map;for(let r of e){let e=r.indexOf(`:`);if(e<=0)continue;let i=r.slice(0,e).trim().toLowerCase(),a=r.slice(e+1).replace(/!important/gi,``).trim();a===``||De.test(a)||s.test(a)||(Te.has(i)&&t.set(i,a),Ee.has(i)&&n.set(i===`color`?`fill`:i,a))}if(t.size===0&&n.size===0)return Q;let r=``,i=``;for(let[e,n]of t)r+=`${e}:${n};`,e!==`fill`&&e!==`fill-opacity`&&(i+=`${e}:${n};`);let a=``;for(let[e,t]of n)a+=`${e}:${t};`;let o=n.get(`font-weight`),l=n.get(`font-size`),u=l&&/^[\d.]+(px)?$/.test(l)?parseFloat(l):void 0;return{shape:r?` style="${c(r)}"`:``,line:i?` style="${c(i)}"`:``,text:a?` style="${c(a)}"`:``,stroke:t.get(`stroke`),bold:o===`bold`||o===`bolder`||Number(o)>=600,italic:n.get(`font-style`)===`italic`,fontSize:u!==void 0&&u>0&&u<=200?u:void 0}}var Oe=/[^\w-]+/g;function ke(e){let t=e.replace(Oe,` `).trim();return t===``?``:` `+t}var Ae=[`#4c78a8`,`#f58518`,`#54a24b`,`#e45756`,`#72b7b2`,`#eeca3b`,`#b279a2`,`#9d755d`];function je(e){let t=(e%8+8)%8;return`var(--pele-series-${t+1},${Ae[t]})`}var Me=[[`tw`,`title`],[`hw`,`heading`],[`w`,`bold`]],Ne=/var\(--_(r|tw|hw|w)\)/g;function Pe(e,t,n,r,i,a,o){let s=c(i.idPrefix??`pele`),u=``,d=``;a.accTitle&&(u+=`<title id="${s}-title">${l(a.accTitle)}</title>`,d+=` aria-labelledby="${s}-title"`),a.accDescr&&(u+=`<desc id="${s}-desc">${l(a.accDescr)}</desc>`,d+=` aria-describedby="${s}-desc"`);let f=i.responsive===!1?``:`max-width:100%;height:auto;`,p=new Set;for(let[,e]of o.matchAll(Ne))if(p.add(e),p.size===4)break;let m=p.has(`r`)?`;--_r:${be}`:``;for(let[e,t]of Me)p.has(e)&&(m+=`;--_${e}:var(--pele-${t}-weight,bold)`);return`<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-${e}" viewBox="0 0 ${t} ${n}" width="${t}" height="${n}" style="${f}${ve}${m}${c(we(r,i.fontFamily,i.fontFamilyMono))}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${e}"${d}>`+u+o+`</svg>`}export{Pe as _,c as a,ke as b,T as c,xe as d,je as f,Se as g,J as h,l as i,ye as l,w as m,s as n,f as o,ge as p,Y as r,$ as s,E as t,pe as u,he as v,d as x,_e as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,u as t,x as n}from"./E3FWOBN4-D5m5o2g0.js";import{l as r}from"./lazy-DaMZI1F7.js";function i(e,n,i,a){return r(()=>t(e,!1,n,i,a,1))}function a(t,r,a,o,s,c,l){let u=i(t,r,a,4e3);if(u.height===0)return{width:s,height:c,content:l};let d=u.height+12,f=Math.max(s,Math.ceil(u.width+2*o));return{width:f,height:Math.ceil(c+d),content:e(u,f/2,o+u.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${n((f-s)/2)},${n(d)})">${l}</g>`}}export{a as n,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=[[`rect`,`proc`,`process`,`rectangle`,`squareRect`],[`rounded`,`event`,`roundedRect`],[`stadium`,`terminal`,`pill`],[`fr-rect`,`subprocess`,`subproc`,`framed-rectangle`,`subroutine`],[`cyl`,`db`,`database`,`cylinder`],[`datastore`,`data-store`],[`folder`,`directory`],[`bucket`],[`console`],[`browser`],[`person`],[`circle`,`circ`],[`bang`],[`cloud`],[`diam`,`decision`,`diamond`,`question`],[`hex`,`hexagon`,`prepare`],[`lean-r`,`lean-right`,`in-out`,`lean_right`],[`lean-l`,`lean-left`,`out-in`,`lean_left`],[`trap-b`,`priority`,`trapezoid-bottom`,`trapezoid`],[`trap-t`,`manual`,`trapezoid-top`,`inv-trapezoid`,`inv_trapezoid`],[`dbl-circ`,`double-circle`,`doublecircle`],[`text`],[`notch-rect`,`card`,`notched-rectangle`],[`lin-rect`,`lined-rectangle`,`lined-process`,`lin-proc`,`shaded-process`],[`sm-circ`,`start`,`small-circle`,`stateStart`],[`fr-circ`,`stop`,`framed-circle`,`stateEnd`],[`fork`,`join`,`forkJoin`],[`hourglass`,`collate`],[`brace`,`comment`,`brace-l`],[`brace-r`],[`braces`],[`bolt`,`com-link`,`lightning-bolt`],[`doc`,`document`],[`delay`,`half-rounded-rectangle`],[`h-cyl`,`das`,`horizontal-cylinder`],[`lin-cyl`,`disk`,`lined-cylinder`],[`curv-trap`,`curved-trapezoid`,`display`],[`div-rect`,`div-proc`,`divided-rectangle`,`divided-process`],[`tri`,`extract`,`triangle`],[`win-pane`,`internal-storage`,`window-pane`],[`f-circ`,`junction`,`filled-circle`],[`notch-pent`,`loop-limit`,`notched-pentagon`],[`flip-tri`,`manual-file`,`flipped-triangle`],[`sl-rect`,`manual-input`,`sloped-rectangle`],[`docs`,`documents`,`st-doc`,`stacked-document`],[`st-rect`,`procs`,`processes`,`stacked-rectangle`],[`bow-rect`,`stored-data`,`bow-tie-rectangle`],[`cross-circ`,`summary`,`crossed-circle`],[`tag-doc`,`tagged-document`],[`tag-rect`,`tagged-rectangle`,`tag-proc`,`tagged-process`],[`flag`,`paper-tape`],[`odd`,`rect_left_inv_arrow`],[`lin-doc`,`lined-document`]],t=`state.choice.note.composite.rectWithTitle.labelRect.block_arrow.collapsedGroup.iconSquare.iconCircle.icon.iconRounded.imageSquare.anchor.kanbanItem.mindmapCircle.defaultMindmapNode.classBox.erBox.requirementBox.usecaseActor.usecaseActorHollow.usecaseActorAwesome.usecaseActorIcon.usecaseBusiness.usecaseEllipse.usecaseJsonTable`.split(`.`),n=new Map([[`square`,`rect`],[`round`,`rounded`],[`ellipse`,`ellipse`],[`hexagon`,`hex`],[`diamond`,`diam`]]),r=new Map;for(let t of e)for(let e of t)r.set(e,t[0]);for(let e of t)r.set(e,e);function i(e){return r.has(e)}function a(e){return e===void 0?`rect`:n.get(e)??r.get(e)??`rect`}export{a as n,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){let t=0;for(let n=e.indexOf(`~`);n!==-1;n=e.indexOf(`~`,n+1))t++;return t}function t(t){let n=e(t);if(n<=1)return t;let r=n%2!=0&&t.startsWith(`~`),i=t.split(``),a=[];for(let e=+!!r;e<i.length;e++)i[e]===`~`&&a.push(e);for(let e=0,t=a.length-1;e<t;e++,t--)i[a[e]]=`<`,i[a[t]]=`>`;return i.join(``)}function n(n){if(!n.includes(`~`))return n;let r=n.split(/(,)/),i=[];for(let n=0;n<r.length;n++){let a=r[n];a===`,`&&n>0&&n+1<r.length&&e(r[n-1])===1&&e(r[n+1])===1&&(a=r[n-1]+`,`+r[n+1],n++,i.pop()),i.push(t(a))}return i.join(``)}export{n as t};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{_ as e,a as t,b as n,d as r,i,o as a,p as o,s,u as c,x as l,y as u}from"./E3FWOBN4-D5m5o2g0.js";import{a as d,t as f}from"./DKTLEL5E-DciMwFJ1.js";import{a as p,i as m,l as h,s as g}from"./CUVCMPQX-JTGMOfG2.js";import{t as _}from"./E65FQMJL-Bg5F0Zo8.js";import{r as v}from"./DHKBVIA3-CVnlqiEq.js";import{i as y,n as b,r as x,t as ee}from"./3JIRLDUO-C1CwW1Ha.js";import{PeleError as S,a as C,b as w,r as T,u as te,v as E,x as D,y as O}from"./lazy-DaMZI1F7.js";var k=`EOF USECASE ACTOR SYSTEM_BOUNDARY END DIRECTION TD TB BT LR RL NOTE FOR JSON CLASS_DEF CLASS STYLE INCLUDE EXTEND TRUE FALSE IDENTIFIER NUMBER AT COMMA COLON HASH_COLOR CSS_IDENTIFIER CSS_ESCAPED_COMMA DASH DOT PERCENT CSS_PUNCTUATION LABEL_PUNCTUATION LABEL_SYMBOL PLAIN_STRING MARKDOWN_STRING UNCLOSED_MARKDOWN_STRING COMMENT NEWLINE ACC_DESCR_BLOCK ACC_TITLE_LINE ACC_DESCR_LINE JSON_DECLARATION_START JSON_OBJECT_LITERAL UNCLOSED_JSON_OBJECT_LITERAL GENERALIZATION DEPENDENCY_ARROW STEREOTYPE_START STEREOTYPE_END STEREOTYPE_TEXT UNCLOSED_STEREOTYPE_TEXT CLASS_SEPARATOR FORWARD_SOLID BACKWARD_SOLID FORWARD_CIRCLE BACKWARD_CIRCLE FORWARD_CROSS BACKWARD_CROSS MARKERLESS_SOLID METADATA_START LBRACE RBRACE LBRACKET RBRACKET LPAREN RPAREN`.split(` `),A=1,j=2,M=new Uint8Array(128);for(let e=48;e<=57;e++)M[e]=A;for(let e=65;e<=90;e++)M[e]=M[e+32]=A;M[95]=A;for(let e of`!#$&*+/=?^|~`)M[e.charCodeAt(0)]=j;var ne=[0,12,5,14,3,9,2,2,2,2,2,4,3,4,8,5,5,7,6,4,5];function N(e){return e<128&&(M[e]&A)!==0}function P(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function re(e,t,n){switch(n){case 97:return e.startsWith(`actor`,t)?2:0;case 115:return e.startsWith(`systemBoundary`,t)?3:e.startsWith(`style`,t)?16:0;case 101:return e.startsWith(`end`,t)?4:P(e,t,`extend`)?18:0;case 69:return P(e,t,`extend`)?18:0;case 100:return e.startsWith(`direction`,t)?5:0;case 84:return e.startsWith(`TD`,t)?6:e.startsWith(`TB`,t)?7:0;case 66:return e.startsWith(`BT`,t)?8:0;case 76:return e.startsWith(`LR`,t)?9:0;case 82:return e.startsWith(`RL`,t)?10:0;case 110:return e.startsWith(`note`,t)?11:0;case 102:return e.startsWith(`for`,t)?12:e.startsWith(`false`,t)?20:0;case 106:return e.startsWith(`json`,t)?13:0;case 99:return e.startsWith(`classDef`,t)?14:e.startsWith(`class`,t)?15:0;case 105:case 73:return P(e,t,`include`)?17:0;case 116:return e.startsWith(`true`,t)?19:0;case 117:return+!!e.startsWith(`usecase-beta`,t);default:return 0}}function F(e,t){[e,t]=C(e,t);let n=1,r=0;for(let i=0;i<t;i++){let a=e.charCodeAt(i);a!==10&&a!==13||(a===13&&i+1<t&&e.charCodeAt(i+1)===10&&i++,n++,r=i+1)}return[n,t-r+1]}function ie(e,t,n){let[r,i]=F(e,t);return`line ${r}, column ${i} [${C(e,t)[1]},${C(e,n)[1]})`}function ae(e,t,n){for(let r=t+1;r<e.length;r++){let t=e.charCodeAt(r);if(t===n)return r+1;if(t===10||t===13)return-1}return-1}function oe(e,t){let n=e.charCodeAt(t);return n!==34&&n!==39||n===34&&e.charCodeAt(t+1)===96||ae(e,t,n)!==-1}function se(e,t,n){let[r,i]=F(e,t),[a,o]=[C(e,t)[1],C(e,t+n)[1]];return new S(`Error lexing usecase diagram: unexpected character: ->${e.charAt(t)}<- at offset: ${a}, skipped ${o-a} characters. at line ${r}, column ${i} [${a},${o})`,`syntax`,{type:`usecase`,line:r,column:i})}function ce(e){let t=[],n=[],r=[],i=e.length,a=0,o=!0,s=!1;for(;a<i;){let c=e.charCodeAt(a);if(c===32||c===9){a++;continue}let l,u=a+1,d=!1;if(c<128&&(M[c]&A)!==0){if(l=0,c===97&&o&&e.startsWith(`acc`,a)){let t=e.startsWith(`Descr`,a+3);if(t||e.startsWith(`Title`,a+3)){let n=a+8;for(;E(e.charCodeAt(n));)n++;let r=e.charCodeAt(n);if(r===58)for(l=t?42:41,u=n+1;u<i&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;else if(r===123&&t&&!s){let t=e.indexOf(`}`,n+1);t===-1?s=!0:(l=40,u=t+1)}}}else if(c===106&&e.startsWith(`json`,a)&&E(e.charCodeAt(a+4))){let s=a+5;for(;E(e.charCodeAt(s));)s++;let c=s;for(;N(e.charCodeAt(s));)s++;if(s>c){for(;E(e.charCodeAt(s));)s++;if(e.charCodeAt(s)===64){for(s++;E(e.charCodeAt(s));)s++;if(e.charCodeAt(s)===123){t.push(43),n.push(a),r.push(s),a=s;let c=0,l=!1,u=!1,d=s;for(;d<i;d++){let t=e.charCodeAt(d);if(l)u?u=!1:t===92?u=!0:t===34&&(l=!1);else if(t===34)l=!0;else if(t===123)c++;else if(t===125&&--c===0)break}t.push(d<i?44:45),n.push(s),a=d<i?d+1:i,r.push(a),o=!1;continue}}}}if(l===0){for(;u<i&&N(e.charCodeAt(u));)u++;let t=re(e,a,c);if(t!==0)t===1||u-a===ne[t]?(l=t,u=a+ne[t]):l=21;else if((c===111||c===120)&&e.charCodeAt(a+1)===45&&e.charCodeAt(a+2)===45)l=c===111?56:58,u=a+3;else if(O(c)){let t=a+1;for(;O(e.charCodeAt(t));)t++;if(e.charCodeAt(t)===46&&O(e.charCodeAt(t+1))){for(l=22,u=t+2;O(e.charCodeAt(u));)u++;for(;w(e.charCodeAt(u));)u++}else l=21}else for(l=21;e.charCodeAt(u)===45&&N(e.charCodeAt(u+1));)for(l=27,u+=2;N(e.charCodeAt(u));)u++}}else if(c===10)l=39,d=!0;else if(c===13)l=39,d=!0,e.charCodeAt(u)===10&&u++;else if(c===34||c===39){if(c===34&&e.charCodeAt(a+1)===96){let t=e.indexOf('`"',a+2);l=t===-1?37:36,u=t===-1?i:t+2}else if(l=35,u=ae(e,a,c),u===-1){let t=a+1;for(;t<i&&!oe(e,t);)t++;throw se(e,a,t-a)}}else if(c===37){if(o&&e.charCodeAt(u)===37)for(l=38;u<i&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;else l=31}else if(c===45){if(e.charCodeAt(u)!==45)l=29;else{for(;e.charCodeAt(u)===45;)u++;let t=e.charCodeAt(u),n=u-a===2;n&&t===124&&e.charCodeAt(u+1)===62?(l=46,u+=2):t===62?(l=53,u++):n&&(t===111||t===120)?(l=t===111?55:57,u++):l=59}}else if(c===46){let t=e.charCodeAt(u);if(t===46&&e.charCodeAt(u+1)===62)l=47,u+=2;else if(O(t)){for(l=22;O(e.charCodeAt(u));)u++;for(;w(e.charCodeAt(u));)u++}else l=30}else if(c===60){if(e.charCodeAt(u)===60){if(t.push(48),n.push(a),r.push(a+2),o=!1,a+=2,a>=i)break;if(e.charCodeAt(a)===62&&e.charCodeAt(a+1)===62)l=49,u=a+2;else{let o=a,s=!1;for(;o<i;o++){let t=e.charCodeAt(o);if(t===10||t===13)break;if(t===62&&e.charCodeAt(o+1)===62){s=!0;break}}if(s&&e.slice(a,o).trim()!==``)t.push(50),n.push(a),r.push(o),l=49,a=o,u=o+2;else{for(;o<i&&e.charCodeAt(o)!==10&&e.charCodeAt(o)!==13;)o++;if(o===a){for(;o<i&&(e.charCodeAt(o)===10||e.charCodeAt(o)===13);)o++;throw se(e,a,o-a)}l=51,u=o}}}else if(e.charCodeAt(u)===45&&e.charCodeAt(u+1)===45)for(l=54,u+=2;e.charCodeAt(u)===45;)u++;else l=33}else if(c===58)e.charCodeAt(u)===58&&e.charCodeAt(u+1)===58?(l=52,u+=2):l=25;else if(c===64)e.charCodeAt(u)===123?(l=60,u++):l=23;else if(c===123)l=61;else if(c===125)l=62;else if(c===91)l=63;else if(c===93)l=64;else if(c===40)l=65;else if(c===41)l=66;else if(c===44)l=24;else if(c===35){for(;D(e.charCodeAt(u));)u++;l=u>a+1?26:32}else if(c===92)e.charCodeAt(u)===44?(l=28,u++):l=33;else if(c<127&&c>32)l=(M[c]&j)===0?33:32;else for(l=34;u<i;){let t=e.charCodeAt(u);if(t>=32&&t<127||t===9||t===10||t===13)break;u++}t.push(l),n.push(a),r.push(u),a=u,o=d}for(let e=0;e<3;e++)t.push(0),n.push(i),r.push(i);return{types:t,starts:n,ends:r}}function le(){return{type:`usecase`,actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,direction:`LR`,title:void 0,accTitle:``,accDescr:``,accDescription:``,source:``,headerSpan:[0,0],statements:[]}}function ue(){return{elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:``,accDescription:``}}function I(e,t){if(t.length===0)return;let n=new Set(e);for(let r of t)n.has(r)||(n.add(r),e.push(r))}function de(e){let t=new Set([`actor`,`usecase`,`boundary`,`edge`]);for(let{key:n,value:r}of e)if(n===`icon`)t.clear(),t.add(`actor`);else if(n===`animate`||n===`animation`)t.clear(),t.add(`edge`);else if(n===`type`)t.clear(),r===`rect`||r===`package`?t.add(`boundary`):(r===`normal`||r===`hollow`||r===`awesome`)&&t.add(`actor`);else if(n===`business`)t.delete(`boundary`),t.delete(`edge`);else return;return t.size===1?[...t][0]:void 0}function fe(e,t,n,r,i){let a=le(),{actors:o,useCases:s,systemBoundaries:c}=a,l=new Map,u=new Map,d=new Map,f=new Map,p=new Map,m=t=>ie(e,t[0],t[1]),h=(t,n)=>{let[r,i]=F(e,n[0]);return new S(t,`semantic`,{type:`usecase`,line:r,column:i})},g=(e,t)=>{throw h(`${e} at ${m(t)}`,t)},_=(e,t,n,r,i)=>{let a=e=>e===void 0?``:` (label "${e}")`;throw h(`${e} at ${m(t)}${a(r)}; previous declaration at ${m(n)}${a(i)}`,t)},v=(e,t,n)=>g(`Metadata property '${n.key}' is invalid for ${t} '${e}'`,n.keySpan),y=(e,t)=>{let n=p.get(e);(n===void 0||t<n)&&p.set(e,t)},b=e=>[...e].sort((e,t)=>(p.get(e.id)??0)-(p.get(t.id)??0)),x=(e,t)=>{l.set(e.id,{kind:t,span:e.span,generated:e.generated,label:e.label.text})},ee=(e,t)=>{let n=l.get(e.id);if(!n)return;let r=e.generated?e.label.text:void 0,i=n.generated?n.label:void 0;n.kind!==t&&_(`ID '${e.id}' is declared as both ${n.kind} and ${t}`,e.span,n.span,r,i),(n.generated||e.generated)&&_(`Generated ID '${e.id}' collides with another declaration`,e.span,n.span,r,i)},C=(e,t,n)=>{let r=l.get(e);r&&_(`ID '${e}' is declared more than once (${r.kind} and ${t})`,n,r.span,void 0,r.generated?r.label:void 0),l.set(e,{kind:t,span:n,generated:!1})},w=(e,t,n)=>{let{key:r,value:i}=t,a=a=>{!n&&a!==void 0&&a!==i&&_(`Actor '${e.id}' has conflicting ${r} metadata`,t.keySpan,e.span)};r===`type`&&(i===`normal`||i===`hollow`||i===`awesome`)?(a(e.actorType),e.actorType=i):r===`icon`&&typeof i==`string`?(a(e.icon),e.icon=i):r===`business`&&typeof i==`boolean`?(a(e.business),e.business=i):v(e.id,`actor`,t)},T=(e,t,n)=>{for(let r of t??[])e.kind===`actor`?w(e,r,n):r.key===`business`&&typeof r.value==`boolean`?(!n&&e.business!==void 0&&e.business!==r.value&&_(`Use case '${e.id}' has conflicting business metadata`,r.keySpan,e.span),e.business=r.value):v(e.id,`usecase`,r)},te=e=>{let t;if(e.kind===`actor`){s.delete(e.id);let n={id:e.id,label:e.label.text,labelType:e.label.type,business:e.business??!1,classes:[...e.classes],type:e.icon?`icon`:e.actorType??`normal`,styles:o.get(e.id)?.styles??[]};e.icon&&(n.icon=e.icon),o.set(e.id,n),t=n}else o.delete(e.id),t={id:e.id,label:e.label.text,labelType:e.label.type,business:e.business??!1,classes:[...e.classes],shape:e.shape??`ellipse`,styles:s.get(e.id)?.styles??[]},s.set(e.id,t);e.stereotype&&(t.stereotype=e.stereotype),e.parent?.id&&(t.parentId=e.parent.id)},E=e=>{ee(e,e.kind);let t=e.parent?.id?e.parent:void 0,n=u.get(e.id);if(n)(n.label.text!==e.label.text||n.label.type!==e.label.type)&&_(`ID '${e.id}' has conflicting labels`,e.span,n.span),e.shape&&n.shape&&e.shape!==n.shape&&_(`Use case '${e.id}' has conflicting shapes`,e.span,n.span),t&&n.parent?.id&&t.id!==n.parent.id&&_(`Element '${e.id}' belongs to more than one system boundary`,t.span,n.parent.span),e.stereotype&&n.stereotype&&e.stereotype!==n.stereotype&&_(`Element '${e.id}' has conflicting stereotypes`,e.span,n.stereotypeSpan??n.span),n.shape??=e.shape,n.parent??=e.parent,n.stereotype??=e.stereotype,n.stereotypeSpan??=e.stereotype?e.span:void 0,I(n.classes,e.classes),T(n,e.metadata,!1);else{let n={kind:e.kind,id:e.id,label:e.label,span:e.span,generated:e.generated,classes:[...e.classes],parent:t,shape:e.shape,stereotype:e.stereotype,stereotypeSpan:e.stereotype?e.span:void 0};T(n,e.metadata,!1),u.set(e.id,n),x(e,e.kind)}},D=e=>{ee(e,`boundary`);let t=d.get(e.id);t?((t.label.text!==e.label.text||t.label.type!==e.label.type)&&_(`Boundary '${e.id}' has conflicting titles`,e.span,t.span),I(t.classes,e.classes)):(d.set(e.id,{...e,classes:[...e.classes],members:[]}),x(e,`boundary`))},O=e=>{e.classed&&!e.declares&&g(`Relationship endpoint '${e.id}' uses ::: without declaring the node`,e.span);let t=l.get(e.id);return t?t.kind:(u.set(e.id,{...e,kind:`usecase`,shape:`ellipse`,classes:[]}),x(e,`usecase`),y(e.id,e.span[0]),`usecase`)},k=(e,t)=>{let n=l.get(e)?.kind;return(n===`actor`?o.get(e):n===`usecase`?s.get(e):n===`boundary`?c.get(e):n===`json`?a.jsonNodes.get(e):f.get(e))??g(`Class/style target '${e}' is unresolved or anonymous`,t)},A=[];for(let{source:e,target:n}of t.relationships)y(e.id,e.span[0]),y(n.id,n.span[0]);for(let e of t.elements)y(e.id,e.span[0]),A.push({offset:e.span[0],run:()=>E(e)});for(let e of t.boundaries)y(e.id,e.span[0]),A.push({offset:e.span[0],run:()=>D(e)});for(let e of t.jsons)y(e.id,e.span[0]),A.push({offset:e.span[0],run:()=>C(e.id,`json`,e.span)});for(let{id:e,idSpan:n}of t.relationships)e&&n&&A.push({offset:n[0],run:()=>C(e,`edge`,n)});A.sort((e,t)=>e.offset-t.offset);for(let e of A)e.run();for(let e of b(u.values()))te(e);for(let e of b(d.values()))c.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:`rect`,members:[],classes:[],styles:[]});for(let e of b(t.jsons))a.jsonNodes.set(e.id,{id:e.id,value:e.value,propertyOrder:e.propertyOrder,classes:[...e.classes],styles:[]});let j=0;for(let e of t.relationships){let{source:t,target:n,type:r}=e,i=O(t),o=O(n),s=e=>e===`actor`||e===`usecase`||e===`json`;s(i)||_(`Relationship source '${t.id}' cannot be ${i}`,t.span,l.get(t.id).span),s(o)||_(`Relationship target '${n.id}' cannot be ${o}`,n.span,l.get(n.id).span),r!==`include`&&r!==`extend`||i===`usecase`&&o===`usecase`||g(`${r} relationship requires use-case endpoints`,e.span),r===`generalization`&&(i===`json`||i!==o)&&g(`Generalization requires actor-to-actor or use-case-to-use-case endpoints`,e.span),r===`association`&&(i===`json`||o===`json`)&&e.arrowType>2&&g(`JSON relationship '${t.id}' to '${n.id}' permits only point, reversed-point, or markerless solid association`,e.span);let c=e.id??`edge-${j++}`,u={id:c,explicitId:!!e.id,source:t.id,target:n.id,type:r,arrowType:e.arrowType,minlen:e.minlen,classes:[],styles:[],animate:!1};e.label&&(u.label=e.label.text,u.labelType=e.label.type),a.relationships.push(u),f.set(c,u)}let M=new Map(o),ne=new Map(s);o.clear(),s.clear();for(let e of b(u.values())){let t=M.get(e.id),n=ne.get(e.id);t?o.set(e.id,t):n?s.set(e.id,n):te(e)}for(let{target:e,span:n,properties:r,statement:i}of t.metadata){let t=l.get(e);if(!t){let t=de(r);return g(`Metadata target '${e}' is unresolved${t?` (metadata implies ${t})`:``}`,n)}let a=t.kind;a===`actor`||a===`usecase`?T(u.get(e),r,!0):a===`edge`&&(i.kind=`edgeMetadata`,i.edges=[{id:e,span:i.span,idSpan:n,metadata:i.metadata}],delete i.nodes);let o=d.get(e),s=f.get(e);for(let t of a===`actor`||a===`usecase`?[]:r){let{key:n,value:r}=t;a===`boundary`&&o&&n===`type`&&(r===`rect`||r===`package`)?o.type=r:a===`edge`&&s&&n===`animate`&&typeof r==`boolean`?s.animate=r:a===`edge`&&s&&n===`animation`&&(r===`fast`||r===`slow`)?(s.animation=r,s.animate=!0):v(e,a,t)}}for(let e of a.relationships)e.animation&&(e.animate=!0);for(let e of u.values())e.kind===`actor`?(e.icon&&e.actorType&&e.actorType!==`normal`&&g(`Actor '${e.id}' cannot combine icon with type '${e.actorType}'`,e.span),e.business&&(e.icon||e.actorType===`awesome`)&&g(`Business actor '${e.id}' must use normal or hollow geometry`,e.span)):e.shape===`rect`&&e.business&&g(`Rectangular use case '${e.id}' cannot be a business use case`,e.span),te(e);for(let e of[...t.elements].sort((e,t)=>e.span[0]-t.span[0])){if(!e.parent?.id)continue;let t=d.get(e.parent.id).members;t.includes(e.id)||t.push(e.id)}for(let e of d.values()){let t=c.get(e.id);t.type=e.type??`rect`,t.members=e.members,t.classes=[...e.classes]}let N=0;for(let e of t.notes){let t=l.get(e.target);if(!t)return g(`Note target '${e.target}' is unresolved`,e.span);t.kind!==`actor`&&t.kind!==`usecase`&&_(`Note target '${e.target}' must be an actor or use case, not ${t.kind}`,e.span,t.span);let n=`note-${N++}`;a.notes.set(n,{id:n,target:e.target,label:e.label.text,labelType:e.label.type})}for(let e of t.classDefs)for(let t of e.ids)a.classDefs.set(t,{id:t,styles:[...e.styles]});for(let e of t.classes)for(let t of e.targets)I(k(t.id,t.span).classes,e.classes);for(let e of t.styles)k(e.target,e.span).styles.push(...e.styles);return a.direction=t.direction??a.direction,a.title=i,a.accTitle=t.accTitle,a.accDescription=t.accDescription,a.accDescr=t.accDescription.replace(/\n\s+/g,`
|
|
2
|
+
`),a.source=e,a.headerSpan=n,a.statements=r,a}var L=class extends Error{constructor(e){super(`Invalid JSON token`),this.offset=e}offset};function pe(e){let t=new Map,n=[],r=[],i=e.length,a=0,o=``,s=0,c=()=>{for(;a<i;){let t=e.charCodeAt(a);if(t!==32&&t!==9&&t!==10&&t!==13)return;a++}},l=t=>{a++;let n=``;for(;a<i;){let r=a,i=e[a++];if(i===`"`)return n;if(i.charCodeAt(0)<32)throw new L(r);if(i!==`\\`){t&&(n+=i);continue}let o=a,s=e[a++],c;if(s===`"`||s===`\\`||s===`/`)c=s;else if(s===`b`)c=`\b`;else if(s===`f`)c=`\f`;else if(s===`n`)c=`
|
|
3
|
+
`;else if(s===`r`)c=`\r`;else if(s===`t`)c=` `;else if(s===`u`){let t=e.slice(a,a+4);if(!/^[\dA-Fa-f]{4}$/.test(t))throw new L(a);c=String.fromCharCode(parseInt(t,16)),a+=4}else throw new L(o);t&&(n+=c)}throw new L(a)},u=t=>{for(let n=0;n<t.length;n++)if(e[a+n]!==t[n])throw new L(a+n);a+=t.length},d=()=>{if(e.charCodeAt(a)===45&&a++,e.charCodeAt(a)===48)a++;else if(O(e.charCodeAt(a)))for(;O(e.charCodeAt(a));)a++;else throw new L(a);if(e.charCodeAt(a)===46){if(a++,!O(e.charCodeAt(a)))throw new L(a);for(;O(e.charCodeAt(a));)a++}if((e.charCodeAt(a)|32)==101){if(a++,(e.charCodeAt(a)===43||e.charCodeAt(a)===45)&&a++,!O(e.charCodeAt(a)))throw new L(a);for(;O(e.charCodeAt(a));)a++}};for(c();;)if(s===0){c();let i=e.charCodeAt(a);if(s=2,i===123){a++;let i=[];t.set(o,i),n.push(o),c(),e.charCodeAt(a)===125?a++:(r.push({object:!0,pointer:o,keys:i,ranges:new Map,key:``,from:0,index:0}),s=1)}else if(i===91)a++,c(),e.charCodeAt(a)===93?a++:(r.push({object:!1,pointer:o,keys:[],ranges:new Map,key:``,from:0,index:0}),o+=`/0`,s=0);else if(i===34)l(!1);else if(i===116)u(`true`);else if(i===102)u(`false`);else if(i===110)u(`null`);else if(i===45||O(i))d();else throw new L(a)}else if(s===1){let i=r[r.length-1];if(e.charCodeAt(a)!==34)throw new L(a);let u=l(!0),d=i.ranges.get(u);if(d===void 0)i.keys.push(u);else for(let e=d[0];e<d[1];e++)t.delete(n[e]);if(i.key=u,i.from=n.length,c(),e.charCodeAt(a)!==58)throw new L(a);a++,o=`${i.pointer}/${u.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`,s=0}else{let t=r[r.length-1];if(t===void 0)break;t.object?t.ranges.set(t.key,[t.from,n.length]):t.index++,c();let i=e.charCodeAt(a);if(i===(t.object?125:93))a++,r.pop();else{if(i!==44)throw new L(a);a++,c(),o=`${t.pointer}/${t.index}`,s=+!!t.object}}if(c(),a!==i)throw new L(a);return t}function me(e,t,n,r){let i=Math.min(Math.max(t,0),e.length);for(let t=0;t<i;t++){let i=e.charCodeAt(t);i===13?(n++,r=1):i===10?(t===0||e.charCodeAt(t-1)!==13)&&(n++,r=1):r++}return[n,r]}function he(e,t,n,r){let i=/\bposition (\d+)\b/.exec(e);if(i)return me(t,parseInt(i[1],10),n,r);let a=/\bline (\d+) column (\d+)\b/.exec(e);if(a){let e=parseInt(a[1],10),t=parseInt(a[2],10);return[n+e-1,e===1?r+t-1:t]}if(/unexpected end|end of json input/i.test(e))return me(t,t.length,n,r)}function ge(e,t,n){return new S(`${e} (line ${t}, column ${n})`,`syntax`,{type:`usecase`,line:t,column:n})}function _e(e,t){let n;try{n=JSON.parse(e)}catch(n){let r=n instanceof Error?n.message:String(n),i=T(e);if(i!==e)try{JSON.parse(i)}catch(e){e instanceof Error&&(r=e.message)}let[a,o]=t(),s=he(r,i,a,o);if(!s){let e=0;try{pe(i)}catch(t){t instanceof L&&(e=t.offset)}s=me(i,e,a,o)}throw ge(`Invalid JSON: ${r}`,s[0],s[1])}if(typeof n!=`object`||!n||Array.isArray(n)){let[e,n]=t();throw ge(`JSON value must have an object root`,e,n)}return{value:n,propertyOrder:pe(e)}}var ve=1,ye=2,be=4,xe=8,Se=16,Ce=32,we=64,Te=`DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS`,Ee=`IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING`,De=`PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT`,Oe=`ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE`,ke=`WORD|PLAIN_STRING|NUMBER|HASH_COLOR|CSS_IDENTIFIER|CSS_ESCAPED_COMMA|DASH|DOT|PERCENT|CSS_PUNCTUATION|COLON|LPAREN|RPAREN|LBRACKET|RBRACKET|LBRACE|RBRACE|AT|MARKERLESS_SOLID`,R=new Uint8Array(67);function z(e,t){for(let n of e.split(`|`))if(n===`WORD`)for(let e=1;e<=21;e++)R[e]|=t;else R[k.indexOf(n)]|=t}z(`NEWLINE|COMMENT|${Oe}|${Ee}`,ve),z(`IDENTIFIER|${Te}`,ye),z(ke,be),z(`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${Te}|NEWLINE|EOF`,xe),z(`NEWLINE|COMMENT|ACTOR|${Ee}`,Se),z(`FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS`,Ce),z(`NEWLINE|IDENTIFIER|PLAIN_STRING|RBRACE`,we);var Ae=new Set([`allowmixing`,`newpage`,`package`,`rectangle`,`skinparam`]),B=``,V=[],H=[],U=[],W=0,je=0,G,Me,Ne=[],Pe=0,Fe=0;function K(e){return B.slice(H[e],U[e])}function q(e){return[H[e],U[e]]}function Ie(e){let[t,n]=F(B,H[W]);throw new S(`Error parsing usecase diagram: ${e} at ${ie(B,H[W],U[W])}`,`syntax`,{type:`usecase`,line:t,column:n})}function Le(e){Ie(`Expecting token of type --> ${e} <-- but found --> '${K(W)}' <--`)}function J(e){return V[W]!==e&&Le(k[e]),W++}function Y(e){Ie(`Expecting: one of these possible Token sequences:
|
|
4
|
+
${e.split(`|`).map((e,t)=>` ${t+1}. [${e}]`).join(`
|
|
5
|
+
`)}
|
|
6
|
+
but found: '${K(W)}'`)}function Re(){let e=Ee.split(`|`),t=e.flatMap(e=>[`NEWLINE`,`IDENTIFIER`,`PLAIN_STRING`,`RBRACE`].map(t=>`${e}, METADATA_START, ${t}`)),n=`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${Te}|NEWLINE|EOF`.split(`|`),r=e.flatMap((e,t)=>(t===0?[`LPAREN`,`LBRACKET`,...n]:n).map(t=>`${e}, ${t}`));return[Oe,...t,...r,...t].join(`|`)}function ze(e){return e>=1&&e<=21}function Be(e){return e>=1&&e<=34}function X(){je=U[W-1],V[W]===39?W++:V[W]!==0&&Y(`NEWLINE|EOF`)}function Ve(e){let t=V[e]===36?2:+(V[e]===35);return[H[e]+t,U[e]-t]}function He(e){let t=Ve(e);return{text:B.slice(t[0],t[1]),type:V[e]===36?`markdown`:`text`,span:t}}function Ue(e){return e.replace(/\W/g,`_`)}function We(){let e=V[W];if(e===35||e===36)return He(W++);Be(e)||Y(De);let t=W;for(;Be(V[W]);)W++;let n=[H[t],U[W-1]];return{text:B.slice(n[0],n[1]),type:`text`,span:n}}function Z(e){return e===21||e===35}function Ge(){let e=W;Z(V[W])||Y(`IDENTIFIER|PLAIN_STRING`),W++,J(25);let t=W,n=V[W];!Z(n)&&n!==19&&n!==20&&Y(`IDENTIFIER|PLAIN_STRING|TRUE|FALSE`),W++;let r=Ve(e),i=Ve(t);return{key:B.slice(r[0],r[1]),value:n===19||n!==20&&B.slice(i[0],i[1]),span:[H[e],U[t]],keySpan:r,valueSpan:i}}function Ke(){let e=V[W],t=V[W+1],n=V[W+2];return e===24?Z(t)||t===39&&(n===39||Z(n)):e===39?t===24||Z(t)||t===39&&(n===39||n===24||Z(n)):!1}function qe(){J(60);let e=[];for(;V[W]===39;)W++;if(Z(V[W])){for(e.push(Ge());Ke();){if(V[W]===24)W++;else{for(;V[W]===39;)W++;V[W]===24&&W++}for(;V[W]===39;)W++;e.push(Ge())}for(V[W]===24&&W++;V[W]===39;)W++}return J(62),e}function Je(e){return e.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))}function Ye(e,t){do{W++;let n=J(21);e.push(K(n)),t.push(q(n))}while(V[W]===24)}function Xe(e){let t=W,n=V[W],r={id:``,label:void 0,span:Ve(t),generated:n!==21,classes:[],classSpans:[],explicit:!1,nodeSpan:[0,0]};if(n===21){W++,r.id=K(t);let n=V[W];n===65||e&&n===63?(W++,r.label=We(),J(n===65?66:64),r.shape=n===65?`ellipse`:`rect`):r.label=He(t)}else n===35||n===36?(W++,r.label=He(t),r.id=Ue(r.label.text)):Y(Ee);return r}function Ze(e){let t=W,n=Xe(!e);if(e&&(n.shape=void 0),V[W]===60&&(n.metadata=qe()),V[W]===48){W++;let e=J(50);J(49),n.stereotype=K(e).trim(),n.stereotypeSpan=q(e)}return V[W]===52&&Ye(n.classes,n.classSpans),n.explicit=!!(n.shape||n.metadata||n.stereotype),n.nodeSpan=[H[t],U[W-1]],n}function Qe(e,t){return{id:e.id,kind:t,label:e.label,span:e.span,generated:e.generated,parent:Me,shape:e.shape,metadata:e.metadata,stereotype:e.stereotype,classes:e.classes}}function $e(e,t){return{id:e.id,label:e.label,span:e.span,generated:e.generated,declares:t,classed:e.classes.length>0}}function et(e,t){let n={id:e.id,span:e.nodeSpan,idSpan:e.span,labelSpan:e.label.span};return t&&(n.defines=!0),e.stereotypeSpan&&(n.stereotypeSpan=e.stereotypeSpan),e.metadata&&(n.metadata=Je(e.metadata)),e.classSpans.length>0&&(n.classSpans=e.classSpans),n}function tt(e){if(V[W]<1||V[W]>36)return!1;for(let t=W+1;;t++){let n=V[t];if(n===59||(R[n]&e)!==0)return!0;if(n<1||n>36)return!1}}function nt(e){let t=U[e]-H[e]-(V[e]===59?0:1);return Math.max(1,t-1)}function rt(){let e=W,t={type:`association`,arrowType:0,minlen:1,target:void 0,span:[0,0]};V[W]===21&&V[W+1]===23&&(t.explicitId=K(W),t.explicitIdSpan=q(W),W+=2);let n=W,r=V[W++];if(r===47)J(25),V[W]!==17&&V[W]!==18&&Y(`INCLUDE|EXTEND`),t.type=V[W]===17?`include`:`extend`,t.label={text:t.type,type:`text`,span:q(W)},W++;else if(r===46)t.type=`generalization`;else if(r===53)t.minlen=nt(n);else if(r===54)t.arrowType=1,U[n]-H[n]===3&&tt(0)?(t.label=We(),t.minlen=nt(J(59))):t.minlen=nt(n);else if(r===59){if(t.arrowType=2,U[n]-H[n]===2&&tt(Ce)){t.label=We();let e=V[W];e===53?t.arrowType=0:e===55?t.arrowType=3:e===57?t.arrowType=4:e!==59&&Y(`FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS`),(t.arrowType===0||t.arrowType===2)&&(t.minlen=nt(W)),W++}else t.minlen=nt(n)}else r===55?t.arrowType=3:r===57?t.arrowType=4:r===56||r===58?(t.arrowType=r===56?5:6,tt(0)&&(t.label=We(),J(59))):(W--,Y(Te));return t.target=Ze(!1),t.span=[H[e],U[W-1]],t}function Q(e){return{kind:e,span:[0,0]}}function it(e,t,n,r){let i=n.target;i.explicit&&G.elements.push(Qe(i,`usecase`)),G.relationships.push({source:$e(e,t),target:$e(i,i.explicit),span:n.span,id:n.explicitId,idSpan:n.explicitIdSpan,type:n.type,arrowType:n.arrowType,label:n.label,minlen:n.minlen}),r.push(et(i,i.explicit));let a=Q(`edge`);return a.nodes=r,a.edges=[{id:n.explicitId??`edge-${Pe++}`,span:a.span}],n.explicitIdSpan&&(a.edges[0].idSpan=n.explicitIdSpan),n.label&&(a.edges[0].labelSpan=n.label.span),a}function at(e){let t=Q(`node`);return t.nodes=e,t}function ot(e){W++;let t=[Ze(!0)],n;if(V[W]===24)do W++,t.push(Ze(!0));while(V[W]===24);else e&&(R[V[W]]&ye)!==0&&(n=rt());X();for(let e of t)G.elements.push(Qe(e,`actor`));let r=t.map(e=>et(e,!0));return n?it(t[0],!0,n,r):at(r)}function st(e){let t=Ze(!1),n=e&&(R[V[W]]&ye)!==0?rt():void 0;X(),n||(t.explicit=!0,t.shape??=`ellipse`),t.explicit&&G.elements.push(Qe(t,`usecase`));let r=[et(t,t.explicit)];return n?it(t,t.explicit,n,r):at(r)}function ct(){W++;let e=Xe(!0),t={id:e.id,label:e.label,span:e.span,generated:e.generated,classes:e.classes},n=V[W]===60?qe():void 0;V[W]===52&&Ye(e.classes,e.classSpans),X(),G.boundaries.push(t),Me=t;let r=[];for(;(R[V[W]]&Se)!==0;)r.push(mt(!1));Me=void 0;let i=J(4);X();let a=Q(`group`);return a.group=t.id,a.idSpan=t.span,a.titleSpan=t.label.span,a.endSpan=q(i),a.classSpans=e.classSpans,r.length>0&&(a.children=r),n&&(a.metadata=Je(n),G.metadata.push({target:t.id,span:t.span,properties:n,statement:a})),a}function lt(){let e=W,t=V[W];for(ze(t)||t===27?W++:t===59?(W++,ze(V[W])||Le(`WORD`),W++):Y(`WORD|CSS_IDENTIFIER|MARKERLESS_SOLID`),J(25),(R[V[W]]&be)===0&&Ie(`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
|
|
7
|
+
<[${ke.replaceAll(`|`,`] ,[`)}]>
|
|
8
|
+
but found: '${K(W)}'`);(R[V[W]]&be)!==0;)W++;return B.slice(H[e],U[W-1]).replaceAll(`\\,`,`,`)}function ut(){let e=[lt()];for(;V[W]===24;)W++,e.push(lt());return e}function dt(){let e=[J(21)];for(;V[W]===24;)W++,e.push(J(21));return e}function ft(e){let t=Ve(e);return{id:K(e),span:t,idSpan:t}}function pt(){let e=W,t=V[W],n;if(t===41||t===42||t===40){W++;let r=K(e);t===40?G.accDescription=r.slice(r.indexOf(`{`)+1,r.lastIndexOf(`}`)).trim():t===42?G.accDescription=r.slice(r.indexOf(`:`)+1).trim():G.accTitle=r.slice(r.indexOf(`:`)+1).trim(),n=Q(t===41?`accTitle`:`accDescr`)}else if(t===5){W++;let e=V[W];(e<6||e>10)&&Y(`TD|TB|BT|LR|RL`),G.direction=e===6?`TB`:K(W),W++,n=Q(`direction`)}else{if(t===2)return ot(!0);if(t===3)return ct();if(t===11){W++,J(12);let e=J(21),t=We();G.notes.push({target:K(e),span:q(e),label:t}),n=Q(`note`),n.ref=`note-${Fe++}`,n.refSpan=t.span,n.nodes=[ft(e)]}else if(t===43){W++;let t=J(44),r=[],i=[];V[W]===52&&Ye(r,i);let a=H[e]+4;for(;B.charCodeAt(a)===32||B.charCodeAt(a)===9;)a++;let o=a;for(;/\w/.test(B.charAt(o));)o++;let s={id:B.slice(a,o),value:{},propertyOrder:new Map,span:[a,o],classes:r};G.jsons.push(s),Ne.push([s,t]),n=Q(`json`),n.nodes=[{id:s.id,span:s.span,idSpan:s.span,defines:!0,classSpans:i}],n.classSpans=i}else if(t===14){W++;let e=dt();G.classDefs.push({ids:e.map(K),styles:ut()}),n=Q(`classDef`),n.ref=K(e[0]),n.refSpan=q(e[0])}else if(t===15){W++;let e=dt(),t=dt();G.classes.push({targets:e.map(e=>({id:K(e),span:q(e)})),classes:t.map(K)}),n=Q(`classAssign`),n.ref=K(t[0]),n.refSpan=q(t[0]),n.nodes=e.map(ft)}else if(t===16){W++;let e=J(21);G.styles.push({target:K(e),span:q(e),styles:ut()}),n=Q(`style`),n.nodes=[ft(e)]}else{let r=V[W+1];if(r===60){(R[V[W+2]]&we)===0&&Y(Re()),W++;let r=ft(e);t!==21&&(r.id=Ue(B.slice(r.span[0],r.span[1])));let i=qe();n=Q(`metadata`),n.nodes=[r],n.metadata=Je(i),G.metadata.push({target:r.id,span:r.span,properties:i,statement:n})}else return((R[r]&xe)===0&&(t!==21||r!==65&&r!==63)||t===21&&Ae.has(K(e).toLowerCase()))&&Y(Re()),st(!0)}}return X(),n}function mt(e){let t=W,n=V[W];if(n===39)return W++,{kind:`blank`,span:q(t)};if(n===38)return W++,X(),{kind:`comment`,span:q(t)};let r=e?pt():n===2?ot(!1):st(!1);if(r.span=[H[t],je],r.edges)for(let e of r.edges)e.span=r.span;return r}function ht(e,t){B=e,{types:V,starts:H,ends:U}=ce(e),W=0,G=ue(),Me=void 0,Ne=[],Pe=0,Fe=0;try{let n=J(1);X();let r=[];for(;(R[V[W]]&ve)!==0;)r.push(mt(!0));V[W]!==0&&Ie(`Redundant input, expecting EOF but found: ${K(W)}`);for(let[t,n]of Ne){let r=_e(K(n),()=>F(e,H[n]));t.value=r.value,t.propertyOrder=r.propertyOrder}return fe(e,G,q(n),r,t)}finally{B=``,V=H=U=Ne=[]}}var gt={normal:`usecaseActor`,hollow:`usecaseActorHollow`,awesome:`usecaseActorAwesome`,icon:`usecaseActorIcon`},_t=[[`none`,`arrow_point`],[`arrow_point`,`none`],[`none`,`none`],[`none`,`arrow_circle`],[`none`,`arrow_cross`],[`arrow_circle`,`none`],[`arrow_cross`,`none`]];function vt(e){return typeof e==`string`?e:e===null?`null`:String(e)}function yt(e){let t=[],n=[[e.value,``,``]],r=[];for(;n.length>0;){let[i,a,o]=n.pop();if(r.length=0,Array.isArray(i))i.length===0?t.push({key:a,accessibleKey:a,value:`[]`}):i.every(e=>typeof e!=`object`||!e)?i.forEach((e,n)=>t.push({key:n===0?a:``,accessibleKey:a,value:vt(e)})):i.forEach((e,t)=>r.push([e,`${a}[${t}]`,`${o}/${t}`]));else if(typeof i==`object`&&i){let n=i,s=e.propertyOrder.get(o)??Object.keys(n);s.length===0&&t.push({key:a,accessibleKey:a,value:`{}`});for(let e of s)r.push([Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0,a?`${a}.${e}`:e,`${o}/${e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`])}else t.push({key:a,accessibleKey:a,value:vt(i)});for(let e=r.length-1;e>=0;e--)n.push(r[e])}return t}function bt(...e){return e.filter(Boolean).join(` `)}function xt(e){return e.type===`generalization`?[`none`,`extension`]:e.type===`association`?_t[e.arrowType]??_t[2]:_t[0]}function St(e){let t=[],n=[],r=t=>{let n=new Map;for(let r of[`default`,...t]){let t=e.classDefs.get(r);if(t)for(let e of t.styles){let t=e.trim(),r=t.indexOf(`:`),i=(r===-1?t:t.slice(0,r)).trim();i&&n.set(i,t)}}return[...n.values()]};for(let n of e.actors.values())t.push({id:n.id,label:n.label,labelType:n.labelType,shape:gt[n.type],isGroup:!1,padding:10,cssClasses:bt(`default`,`usecase-actor`,`usecase-actor-${n.type}`,n.business&&`usecase-business`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(n.classes),actorType:n.type,business:n.business,icon:n.icon||void 0,stereotype:n.stereotype||void 0,parentId:n.parentId||void 0});for(let n of e.useCases.values()){let e=n.shape===`ellipse`;t.push({id:n.id,label:n.label,labelType:n.labelType,shape:e?n.business?`usecaseBusiness`:`usecaseEllipse`:`rect`,isGroup:!1,padding:e?20:10,cssClasses:bt(`default`,`usecase-element`,`usecase-${n.shape}`,n.business&&`usecase-business`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(n.classes),business:n.business,stereotype:n.stereotype||void 0,parentId:n.parentId||void 0})}for(let n of e.notes.values())t.push({id:n.id,label:n.label,labelType:n.labelType,shape:`note`,isGroup:!1,padding:10,cssClasses:`default usecase-note`,cssStyles:[],cssCompiledStyles:r([]),noteTarget:n.target});for(let n of e.jsonNodes.values())t.push({id:n.id,label:n.id,labelType:`text`,shape:`usecaseJsonTable`,isGroup:!1,padding:10,cssClasses:bt(`default`,`usecase-json-table`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(n.classes),jsonRows:yt(n)});for(let n of e.systemBoundaries.values())t.push({id:n.id,label:n.label,labelType:n.labelType,shape:`usecaseSystemBoundary`,isGroup:!0,padding:20,cssClasses:bt(`default`,`system-boundary`,`system-boundary-${n.type}`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(n.classes),boundaryType:n.type});for(let t of e.relationships){let e=t.type===`include`||t.type===`extend`,[i,a]=xt(t),o=t.animate||t.animation!==void 0,s={id:t.id,start:t.source,end:t.target,relationshipType:t.type,pattern:e?`dotted`:`solid`,arrowTypeStart:i,arrowTypeEnd:a,classes:bt(`default`,`relationship`,`relationship-${t.type}`,...t.classes,o&&`edge-animation-${t.animation??`fast`}`),style:[...t.styles],cssCompiledStyles:r(t.classes),animate:t.animate,animation:t.animation,minlen:t.minlen,explicitId:t.explicitId,internal:!1};e?(s.label=t.type,s.labelType=`text`):t.type===`association`&&(t.label&&(s.label=t.label),t.labelType&&(s.labelType=t.labelType)),n.push(s)}for(let t of e.notes.values())n.push({id:`${t.id}-edge`,start:t.id,end:t.target,relationshipType:`note`,pattern:`dotted`,arrowTypeStart:`none`,arrowTypeEnd:`none`,classes:`default relationship relationship-note`,style:[],cssCompiledStyles:r([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:t,edges:n}}var Ct=32,wt=16,Tt=72,Et=20,Dt=26,Ot=40,kt=60,At=6,jt=6,Mt=10,Nt=8,Pt=9,Ft=12,It=14,Lt=` fill="var(--_s)" stroke="var(--_b)"`;function Rt(e,t,n){let r=e.usecase?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function zt(e){return e.replace(/[&<>\\]/g,e=>`&#${e.charCodeAt(0)};`)}function $(e,t,n,r,i,a=0){return c(e&&!t?zt(e):e,t,n,r,i,a)}function Bt(e,t,n,r){let i=n===1||n===2?1:-1,a=n===1||n===3,o=(a?e.w:e.h)/2,s=0;if(e.kind===0)a?(o=Ot/2+3,s=(kt-e.h)/2):o+=2;else if(e.kind===1){let t=(a?e.h:e.w)/2;o*=Math.sqrt(Math.max(1-(r/t)**2,0))}return a?[t.x+i*o,t.y+s+r]:[t.x+r,t.y+i*o]}function Vt(e,t){let n=t===1||t===3;if(e.kind===0)return n?kt*.5:Ot*.6;let r=n?e.h:e.w;return e.kind===1?r*.6:r-16}function Ht(e,t,n){let r=new Map,i=(e,n,i,a)=>{let o=t[e];if(o.isGroup)return;let s=n[i]-o.x,c=n[i+1]-o.y,l;if(Math.abs(Math.abs(c)-o.h/2)<.5)l=c<0?0:2;else if(Math.abs(Math.abs(s)-o.w/2)<.5)l=s<0?3:1;else return;let u=e*4+l,d={route:n,at:i,toward:n[a+(l&1?1:0)]},f=r.get(u);f?f.push(d):r.set(u,[d])};for(let t of e){let e=t.route.length-3;t.src===t.dst||e<3||(i(t.src,t.route,0,3),i(t.dst,t.route,e,e-3))}for(let[e,i]of r){let r=e>>2,a=e&3,o=n[r],s=i.length>1?Math.min(It,Vt(o,a)/(i.length-1)):0;i.sort((e,t)=>e.toward-t.toward);for(let e=0;e<i.length;e++){let[n,c]=Bt(o,t[r],a,(e-(i.length-1)/2)*s);i[e].route[i[e].at]=n,i[e].route[i[e].at+1]=c}}}function Ut(e,t,n,r,i){let a=e-n*Ft,o=t-r*Ft,s=Ft*.5;return`<path class="pele-marker" d="M${l(e)},${l(t)}L${l(a-r*s)},${l(o+n*s)}L${l(a+r*s)},${l(o-n*s)}Z" fill="var(--_bg)" stroke="${i}" stroke-linejoin="round"/>`}function Wt(e){return e===`extension`?Ft:p(e)}function Gt(e,t,n,r,i,a){return e===`extension`?Ut(t,n,r,i,a):g(e,t,n,r,i,a)}function Kt(e,t){let n=e.node,a=e.style.shape,o=` fill="none" stroke="var(--_b)"${e.style.line}`,s=-21,c=9,u;return n.actorType===`hollow`?(c=8,u=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${a}/><path d="M-20,-9H20V0H5.5L20,15.5L12,25.5L0,12L-12,25.5L-20,15.5L-5.5,0H-20Z" fill="var(--_bg)" stroke="var(--_b)" stroke-linejoin="round"${a}/>`):n.actorType===`awesome`?u=`<path d="M0,-30A11,11 0 1 1 0,-8A11,11 0 1 1 0,-30ZM-20,25C-20,9 -12,-3 0,-3C12,-3 20,9 20,25C20,28 18,30 15,30H-15C-18,30 -20,28 -20,25Z" fill="var(--_b)"${a}/>`:n.actorType===`icon`?(s=-14,c=12,u=`<rect x="-22" y="-26" width="44" height="44"${r(Lt+a)}/><svg class="pele-icon" data-icon="${i(n.icon??``)}" x="-14" y="-18" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t?.(n.icon??``)??``}</svg>`):u=`<circle cy="-21" r="9"${Lt}${a}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${o}/>`,n.business&&(u+=`<path class="pele-business" d="M${l(.12*c)},${l(s+.99*c)}L${l(.92*c)},${l(s-.39*c)}"${o}/>`),u}function qt(e,t,n){return d(e.direction)?f(n,r=>Jt(e,t,n,r)):Jt(e,t,n,!1)}function Jt(o,c,u,d){let f=St(o),p=u.fontSize??16,g=Math.round(p*.875),S=Math.round(p*.8125),C=u.measurer??te(u.fontFamily,u.fontFamilyMono),w=u.padding??8,T=u.icons,E=d?`TB`:x(o.direction),D=E===`LR`||E===`RL`,O=new Map,k=[],A=[];f.nodes.forEach((e,t)=>O.set(e.id,t));for(let e of f.nodes){let t=s(e.cssStyles.length>0?e.cssCompiledStyles.concat(e.cssStyles):e.cssCompiledStyles),n=+!!t.bold|(t.italic?2:0),r=t.fontSize??p,i=e.labelType===`markdown`,a=$(e.stereotype&&`«${e.stereotype}»`,!1,C,S,200,n),o={node:e,kind:2,style:t,label:a,stereotype:a,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},c;if(e.isGroup){o.kind=4,o.label=$(e.label,i,C,r,4e3,n);let t=o.label.height;c=ee(0,0),c.isGroup=!0,c.padX=Et,c.padBottom=Et,c.padTop=e.boundaryType===`package`?t+2*jt+16:t>0?t+16:Et,c.minW=o.label.width+2*Et}else{if(e.jsonRows){o.kind=3,o.label=$(e.label,!1,C,r,4e3,n|1);let t=0;for(let r of e.jsonRows){let e=$(r.key,!1,C,g,4e3,n),i=$(r.value,!1,C,g,260,n);o.rows.push([e,i]),o.keyW=Math.max(o.keyW,e.width),t=Math.max(t,i.width),o.h+=Math.max(e.height,i.height,Math.round(g*1.5))+Nt}o.keyW>0&&(o.keyW+=2*Mt),o.headH=Math.max(o.label.height,Math.round(r*1.5))+Nt,o.w=Math.max(o.label.width+2*Mt,o.rows.length>0?o.keyW+t+2*Mt:0,72),o.h+=o.headH}else if(e.actorType)o.kind=0,o.label=$(e.label,i,C,r,140,n),o.w=Math.max(Ot,o.label.width,a.width),o.h=kt+At+a.height+o.label.height;else{o.label=$(e.label,i,C,e.shape===`note`?g:r,180,n);let t=Math.max(o.label.width,a.width),s=o.label.height+a.height;e.shape===`usecaseEllipse`||e.shape===`usecaseBusiness`?(o.kind=1,o.w=Math.max(t+2*e.padding+(e.business?16:4),88),o.h=Math.max(s+28,48)):e.shape===`note`?(o.w=t+2*e.padding+6,o.h=s+18):(o.w=Math.max(t+2*e.padding+12,80),o.h=Math.max(s+24,44))}c=ee(o.w,o.h)}c.seq=k.length,k.push(o),A.push(c)}f.nodes.forEach((e,t)=>{A[t].parent=e.parentId===void 0?-1:O.get(e.parentId)??-1});let j=[],M=[],ne=[];for(let e of f.edges){let t=O.get(e.start),n=O.get(e.end);if(t===void 0||n===void 0)continue;let r=$(e.relationshipType===`include`||e.relationshipType===`extend`?`«${e.label}»`:e.label,e.labelType===`markdown`,C,g,200);t===n&&(k[t].loops++,D?A[t].h+=2*(Dt+(r.height>0?r.height+8:0)):A[t].w+=2*(Dt+(r.width>0?r.width+12:0))),ne.push(e),M.push(r),j.push({src:t,dst:n,minlen:e.minlen,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}let N=y(A,j,E,{nodeSep:Rt(c,`nodeSpacing`,Ct),edgeSep:wt,rankSep:Rt(c,`rankSpacing`,Tt),portSep:20}),P=_(o.title,C,p,4e3),re=P.height>0?P.height+12:0,F=Math.max(N.width,P.width),ie=w+(F-N.width)/2,ae=w+re;b(A,j,ie,ae);let oe=Math.ceil(F+2*w),se=Math.ceil(N.height+re+2*w),ce=new Map;for(let e of j)v(ce,e.route);Ht(j,A,k);let le=``,ue=``;for(let e=0;e<k.length;e++){let t=k[e],o=A[e],s=t.node,c=n(s.cssClasses.replace(/^default\s?/,``)),u=i(s.id),d=t.style.text,f=t.style.shape,p=t.w,m=t.h;if(t.kind===4){let e=o.x-o.w/2,n=o.y-o.h/2,i=` fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${f}`,p=` class="pele-cluster-label" fill="var(--_m)"${d}`,m;if(s.boundaryType===`package`){let r=Math.min(t.label.width+2*jt+8,o.w),s=t.label.height+2*jt;m=`<rect class="pele-boundary-tab" x="${l(e)}" y="${l(n)}" width="${l(r)}" height="${l(s)}"${i}/><rect x="${l(e)}" y="${l(n+s)}" width="${l(o.w)}" height="${l(o.h-s)}"${i}/>`+a(t.label,e+r/2,n+s/2,p,T)}else m=`<rect x="${l(e)}" y="${l(n)}" width="${l(o.w)}" height="${l(o.h)}"${r(i)}/>`+a(t.label,Yt(o,t.label.width,ce),n+8+t.label.height/2,p,T);le+=`<g class="pele-cluster pele-boundary${c}" data-id="${u}">${m}</g>`;continue}let h,_;if(t.kind===0){_=`pele-actor`;let e=-m/2,n=e+kt+At+t.stereotype.height/2;h=`<g class="pele-actor-figure" transform="translate(0,${l(e+kt/2)})">${Kt(t,T)}</g>`+a(t.stereotype,0,n,` class="pele-stereotype" font-size="${S}" fill="var(--_m)"`,T)+a(t.label,0,m/2-t.label.height/2,` class="pele-label"${d}`,T)}else if(t.kind===3){_=`pele-json`;let e=-p/2,n=-m/2+t.headH,i=``,o=`M${l(e)},${l(n)}H${l(e+p)}`;t.keyW>0&&(o+=`M${l(e+t.keyW)},${l(n)}V${l(m/2)}`);for(let[r,o]of t.rows){let s=Math.max(r.height,o.height,Math.round(g*1.5))+Nt;i+=a(r,e+Mt+r.width/2,n+s/2,` class="pele-json-key" fill="var(--_m)"`,T)+Xt(o,e+t.keyW+Mt,n+s/2,` class="pele-json-value"${d}`,T),n+=s}h=`<rect x="${l(e)}" y="${l(-m/2)}" width="${l(p)}" height="${l(m)}"${r(Lt+f)}/><path class="pele-json-lines" d="${o}" fill="none" stroke="var(--_b)"${t.style.line}/>`+a(t.label,0,-m/2+t.headH/2,` class="pele-label" font-weight="var(--_hw)"${d}`,T)+`<g font-size="${g}">${i}</g>`}else{let e=t.stereotype.height/2,n;if(t.kind===1){if(_=`pele-usecase`,n=`<ellipse rx="${l(p/2)}" ry="${l(m/2)}"${Lt}${f}/>`,s.business){let e=p/2-15,r=p/2-5,i=e=>m/2*Math.sqrt(1-(e/(p/2))**2);n+=`<path class="pele-business" d="M${l(e)},${l(i(e))}L${l(r)},${l(-i(r))}" fill="none" stroke="var(--_b)"${t.style.line}/>`}}else if(s.shape===`note`){_=`pele-note`;let e=p/2,r=m/2;n=`<path d="M${l(-e)},${l(-r)}H${l(e-Pt)}L${l(e)},${l(Pt-r)}V${l(r)}H${l(-e)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${f}/><path d="M${l(e-Pt)},${l(-r)}V${l(Pt-r)}H${l(e)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${t.style.line}/>`}else _=`pele-usecase`,n=`<rect x="${l(-p/2)}" y="${l(-m/2)}" width="${l(p)}" height="${l(m)}"${r(Lt+f)}/>`;h=n+a(t.stereotype,0,-t.label.height/2,` class="pele-stereotype" font-size="${S}" fill="var(--_m)"`,T)+a(t.label,0,e,` class="pele-label"${s.shape===`note`?` font-size="${g}"`:``}${d}`,T)}ue+=`<g class="pele-node ${_}${c}" data-id="${u}" transform="translate(${l(o.x)},${l(o.y)})">${h}</g>`}let I=``,de=``,fe=new Map;for(let e=0;e<j.length;e++){let r=j[e],a=ne[e],o=M[e],c=a.style.length>0||a.cssCompiledStyles.length>0?s(a.cssCompiledStyles.concat(a.style)):void 0,u=a.arrowTypeStart,d=a.arrowTypeEnd,f;if(r.src===r.dst){let e=A[r.src],t=k[r.src],n=fe.get(r.src)??0;fe.set(r.src,n+1);let i=D?2:1,a=Math.min(Vt(t,i)/2,8+n*6),s=Dt+n*8,[c,p]=Bt(t,e,i,-a),[m,h]=Bt(t,e,i,a),g=Math.hypot(s,a)||1,_=D?a/g:s/g,v=D?s/g:a/g,y=Wt(u),b=Wt(d),x=(e,t,n,r)=>D?`${l(e+n*a*+!!r)},${l(t+r)}`:`${l(e+r)},${l(t+n*a*+!!r)}`,ee=D?c-_*y:c+_*y,S=D?p+v*y:p-v*y,C=m+_*b,w=h+v*b;f={d:`M${l(ee)},${l(S)}C${x(c,p,-1,s)} ${x(m,h,1,s)} ${l(C)},${l(w)}`,sx:c,sy:p,sdx:D?_:-_,sdy:D?-v:v,ex:m,ey:h,edx:-_,edy:-v},D?(r.labelX=e.x,r.labelY=Math.max(p,h)+s*.75+6+o.height/2):(r.labelX=Math.max(c,m)+s*.75+8+o.width/2,r.labelY=e.y)}else{if(r.route.length<6)continue;f=h(r.route,void 0,Wt(u),Wt(d))}let p=c?.stroke?t(c.stroke):`var(--_l)`,g=a.internal?`2 3`:a.pattern===`dotted`?`5 4`:a.animate?`9 5`:``;if(I+=`<g class="pele-edge pele-${a.relationshipType}${n(a.classes.replace(/^default relationship relationship-\S+\s?/,``))}" data-id="${i(a.id)}"${c?.line??``}><path d="${f.d}"${g?` stroke-dasharray="${g}"`:``}/>`+Gt(u,f.sx,f.sy,f.sdx,f.sdy,p)+Gt(d,f.ex,f.ey,f.edx,f.edy,p)+`</g>`,o.width>0){let e=r.labelX,t=r.labelY,n=a.relationshipType===`include`||a.relationshipType===`extend`;de+=m(a.id,o,e,t,(n?` fill="var(--_m)"`:``)+(c?.text??``),T)}}return{svg:e(`usecase`,oe,se,p,u,o,a(P,oe/2,w+P.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(le?`<g class="pele-clusters">${le}</g>`:``)+(I?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${I}</g>`:``)+(de?`<g class="pele-edge-labels" font-size="${g}">${de}</g>`:``)+`<g class="pele-nodes">${ue}</g>`),width:oe,height:se,links:[]}}function Yt(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(t===0||r===void 0)return e.x;let i=e.x-e.w/2+6,a=e.x+e.w/2-6,o=r.filter(e=>e>i&&e<a).sort((e,t)=>e-t);o.push(a);let s=t/2+6,c=e.x,l=1/0,u=0,d=i;for(let t of o){if(t-d>=2*s){let n=Math.min(Math.max(e.x,d+s),t-s);Math.abs(n-e.x)<l&&(l=Math.abs(n-e.x),c=n)}else l===1/0&&t-d>u&&(u=t-d,c=(d+t)/2);d=t}return c}function Xt(e,t,n,r,i){if(e.lines.length<2)return a(e,t+e.width/2,n,r,i);let s=``;for(let c=0;c<e.lines.length;c++)s+=a(u(e,c),t+e.widths[c]/2,n-e.height/2+o(e,c),r,i);return s}var Zt={type:`usecase`,math:!0,parse:(e,t,n)=>ht(e,n),render:qt};export{Zt as usecase};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{_ as e,a as t,b as n,i as r,o as i,s as a,u as o,x as s}from"./E3FWOBN4-D5m5o2g0.js";import{a as c,t as l}from"./DKTLEL5E-DciMwFJ1.js";import{a as u,d,i as f,l as p,s as m}from"./CUVCMPQX-JTGMOfG2.js";import{n as h}from"./E65FQMJL-Bg5F0Zo8.js";import{n as g}from"./A255FCTW-woaH7Mj_.js";import{i as _,t as v}from"./SPBWZ4VS-EqfCsJ5V.js";import{i as y,r as b,t as x}from"./3JIRLDUO-C1CwW1Ha.js";import{PeleError as S,d as C,g as w,h as T,o as E,s as D,u as O}from"./lazy-DaMZI1F7.js";function k(e){let t=`TB`;for(let n of e)typeof n!=`string`&&n.stmt===`dir`&&(t=n.value);return t}function A(e,t,n){let r=[],i=[],a=new Map,o=new Map,s=new Map,c=0,l=0,u=e=>{if(!e.id||e.id===`</join></fork>`||e.id===`</choice>`)return;if(e.cssClasses){let t;for(let r of e.cssClasses.split(` `)){let i=n.get(r);if(i){t??=e.cssCompiledStyles.slice();for(let e of i.styles)t.push(e)}}t&&(e.cssCompiledStyles=t)}let t=a.get(e.id);if(t){let n=e.parentId??t.parentId;Object.assign(t,e),n!==void 0&&(t.parentId=n)}else a.set(e.id,e),r.push(e)},d=(e,n,r)=>{let a=n.id;if(a===`root`)return;let d=t.get(a),f=d?.classes?.join(` `)??``,p=d?.styles??[],m=o.get(a);if(!m){let e=`rect`;n.start===!0?e=`stateStart`:n.start===!1&&(e=`stateEnd`),n.type!=="default"&&(e=n.type),m={shape:e,description:a,cssClasses:`${f} statediagram-state`,cssStyles:p,type:void 0,dir:void 0,colorIndex:void 0},o.set(a,m)}if(n.description&&(Array.isArray(m.description)?(m.shape=`rectWithTitle`,m.description=m.description.concat(n.description)):m.description.length>0?(m.shape=`rectWithTitle`,m.description=m.description===a?[n.description].flat():[m.description,n.description].flat()):(m.shape=`rect`,m.description=Array.isArray(n.description)?n.description.slice():n.description)),m.description.length===1&&m.shape===`rectWithTitle`&&(m.shape=m.type===`group`?`roundedWithTitle`:`rect`),!m.type&&n.doc){if(m.type=`group`,m.dir=k(n.doc),m.shape=n.type===`divider`?`divider`:`roundedWithTitle`,m.shape===`divider`&&e?.id!==void 0&&s.has(e.id))m.colorIndex=s.get(e.id);else{let e=l++;m.colorIndex=f.trim()!==``||p.length>0?void 0:e}s.set(a,m.colorIndex),m.cssClasses=`${m.cssClasses} statediagram-cluster ${r?`statediagram-cluster-alt`:``}`}let h=m.description,g={id:a,shape:m.shape,label:Array.isArray(h)?h[0]:h,description:Array.isArray(h)?h.slice(1):[],cssClasses:m.cssClasses,cssCompiledStyles:[],cssStyles:m.cssStyles,type:m.type,isGroup:m.type===`group`,dir:m.dir,colorIndex:m.colorIndex};g.shape===`divider`&&(g.label=``),e&&e.id!==`root`&&(g.parentId=e.id);let _=n.note;if(!_){u(g);return}let v=(e,t,n,r)=>({id:e,shape:t,label:_.text,description:[],cssClasses:n,cssCompiledStyles:[],cssStyles:[],type:r?`group`:`node`,isGroup:r,dir:void 0,position:_.position}),y=v(`${a}----note-${c++}`,`note`,`statediagram-note`,!1);y.parentId=`${a}----parent`,y.noteFor=a,u(v(y.parentId,`noteGroup`,m.cssClasses,!0)),u(y),u(g);let b=_.position===`left of`,x=b?y.id:a,S=b?a:y.id;i.push({id:`${x}-${S}`,start:x,end:S,label:``,classes:`transition note-edge`,pattern:`dashed`})},f=[{item:void 0,doc:e,at:0,alt:!0}];for(;f.length>0;){let e=f[f.length-1];if(e.at>=e.doc.length){f.pop();continue}let t=e.doc[e.at++];typeof t!=`string`&&(t.stmt===`state`?(d(e.item,t,e.alt),t.doc&&f.push({item:t,doc:t.doc,at:0,alt:!e.alt})):t.stmt===`relation`&&(d(e.item,t.state1,e.alt),d(e.item,t.state2,e.alt),i.push({id:`edge${c++}`,start:t.state1.id,end:t.state2.id,label:t.description??``,classes:`transition`})))}for(let e of r)if(e.isGroup&&e.description.length>0)throw new S(`Group nodes can only have label. Remove the additional description for node [${e.id}]`,`semantic`,{type:`state`});return{nodes:r,edges:i}}var j=class{type=`state`;rootDoc=[];states=new Map;relations=[];classes=new Map;links=new Map;graph={nodes:[],edges:[]};title;accTitle;accDescr;dividerCount=0;get direction(){let e=`TB`;for(let t of this.rootDoc)typeof t!=`string`&&t.stmt===`dir`&&(e=t.value);return e}setRootDoc(e){this.rootDoc=e,this.translate(),this.extract(e)}extract(e){this.states=new Map,this.relations=[],this.classes=new Map;let t=Array.isArray(e)?e:e.doc;for(let e of t)if(typeof e!=`string`)switch(e.stmt){case`state`:this.addState(e.id.trim(),e.type,e.doc,e.description,e.note);break;case`relation`:this.addRelation(e.state1,e.state2,e.description);break;case`classDef`:this.addStyleClass(e.id.trim(),e.classes);break;case`style`:{let t=e.styleClass.split(`,`).map(e=>e.replace(/;/g,``).trim());for(let n of this.named(e.id.trim()))n.styles=t.slice();break}case`applyClass`:this.setCssClass(e.id.trim(),e.styleClass);break;case`click`:this.addLink(typeof e.id==`string`?e.id:e.id.id,e.url,e.tooltip)}this.graph=A(t,this.states,this.classes)}translate(){let e=[[`root`,{stmt:`root`,id:`root`,doc:this.rootDoc},!0]];for(;e.length>0;){let[t,n,r]=e.pop();if(typeof n==`string`)continue;if(n.stmt===`relation`){e.push([t,n.state2,!1],[t,n.state1,!0]);continue}if(n.stmt===`state`)n.id===`[*]`?(n.id=t+(r?`_start`:`_end`),n.start=r):n.id=n.id.trim();else if(n.stmt!==`root`)continue;if(!n.doc)continue;let i=[],a=[];for(let e of n.doc)typeof e!=`string`&&e.stmt===`state`&&e.type===`divider`&&!e.doc?(i.push({...e,doc:a}),a=[]):a.push(e);i.length>0&&(a.length>0&&i.push({stmt:`state`,id:this.getDividerId(),type:`divider`,doc:a}),n.doc=i);for(let t=n.doc.length-1;t>=0;t--)e.push([n.id,n.doc[t],!0])}}addState(e,t=`default`,n,r,i,a){let o=e.trim(),s=this.states.get(o);if(s?(s.doc||(s.doc=n),s.type||(s.type=t)):(s={stmt:`state`,id:o,descriptions:[],type:t,doc:n,note:i,classes:[],styles:[],textStyles:[]},this.states.set(o,s)),r)for(let e of Array.isArray(r)?r:[r])this.addDescription(o,e.trim());if(i&&(s.note=i),a)for(let e of a)this.setCssClass(o,e.trim())}getState(e){return this.states.get(e)}addLink(e,t,n){this.links.set(e,{url:t,tooltip:n})}addRelation(e,t,n=``){for(let n of[e,t])this.addState(n.id,n.type,n.doc,n.description,n.note,n.classes);this.relations.push({id1:e.id.trim(),id2:t.id.trim(),relationTitle:n})}addDescription(e,t){this.states.get(e)?.descriptions?.push(t.startsWith(`:`)?t.replace(`:`,``).trim():t)}getDividerId(){return`divider-id-${++this.dividerCount}`}addStyleClass(e,t=``){let n=this.classes.get(e);if(n||(n={id:e,styles:[],textStyles:[]},this.classes.set(e,n)),t)for(let e of t.split(`,`)){let t=e.replace(`;`,``).trim();e.includes(`color`)&&n.textStyles.push(t.replace(`fill`,`bgFill`).replace(`color`,`fill`)),n.styles.push(t)}}setCssClass(e,t){for(let n of this.named(e))n.classes?.push(t)}getDirection(){for(let e of this.rootDoc)if(typeof e!=`string`&&e.stmt===`dir`)return e.value;return`TB`}setDirection(e){for(let t of this.rootDoc)if(typeof t!=`string`&&t.stmt===`dir`){t.value=e;return}this.rootDoc.unshift({stmt:`dir`,value:e})}trimColon(e){return e.startsWith(`:`)?e.slice(1).trim():e.trim()}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
2
|
+
`)}named(e){let t=[];for(let n of e.split(`,`)){let e=this.states.get(n);e||=(this.addState(n),this.states.get(n.trim())),e&&t.push(e)}return t}},M=`$end.INVALID.NL.SD.DESCR.-->.HIDE_EMPTY.scale.WIDTH.COMPOSIT_STATE.STRUCT_START.STRUCT_STOP.STATE_DESCR.AS.ID.FORK.JOIN.CHOICE.CONCURRENT.note.NOTE_TEXT.acc_title.acc_title_value.acc_descr.acc_descr_value.acc_descr_multiline_value.CLICK.STRING.HREF.classDef.CLASSDEF_ID.DEFAULT_CLASSDEF_ID.CLASSDEF_STYLEOPTS.DEFAULT.style.STYLE_IDS.STYLEDEF_STYLEOPTS.class.CLASSENTITY_IDS.STYLECLASS.direction_tb.direction_bt.direction_rl.direction_lr.EDGE_STATE.STYLE_SEPARATOR.left_of.right_of.INVALID`.split(`.`),N=/direction/gi,ee=/<<(?:fork|join|choice)>>|\[\[(?:fork|join|choice)\]\]/gi,te=/[\n\r\u2028\u2029]/g,P=/%%/g,F=/\{/g;function I(e,t){let n=0,r=-2;return i=>{if(r===-2||i<n||r!==-1&&i>r){e.lastIndex=i;let a=e.exec(t);r=a?a.index:-1,n=i}return r}}function L(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c,l=I(N,e),u=I(ee,e),d=I(te,e),f=I(P,e),p=I(F,e),m=-1,h=-1,g=[-1,-1,-1,-1],_=[0,0,0,0],v=-1,y=-1,b=[-1,-1,-1,-1,-1,-1],x=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},S=(e,t,a,o)=>{n.push(e),r.push(t),i.push(a),s=o},C=e=>{a.push(o),o=e},E=()=>{a.length>0&&(o=a.pop())},D=(t,n)=>{for(let r=0;r<t.length;r++){let i=t.charCodeAt(r),a=e.charCodeAt(n+r);if(a!==i&&!(i>=97&&i<=122&&a===i-32))return!1}return!0},O=n=>{let r=n;for(;r<t&&T(e.charCodeAt(r));)r++;return r},k=n=>{let r=n;for(;r<t&&w(e.charCodeAt(r));)r++;return r},A=n=>{let r=e.indexOf(`
|
|
3
|
+
`,n);return r===-1?t:r},j=e=>{let n=d(e);return n===-1?t:n},M=e=>{if(e<m||e>h){let n=l(e),r=n===-1?t:j(e);m=e,h=r,g[0]=g[1]=g[2]=g[3]=-1;for(let e=n;e!==-1&&e<r;e=l(e+1)){let t=O(e+9);if(t===e+9)continue;let n=D(`tb`,t)?0:D(`bt`,t)?1:D(`rl`,t)?2:D(`lr`,t)?3:-1;n!==-1&&(g[n]=e,_[n]=t+2)}}for(let t=0;t<4;t++)if(g[t]>=e)return t;return-1},L=n=>{if(n<v||n>y){let r=u(n),i=r===-1?t:j(n);v=n,y=i,b.fill(-1);for(let t=r;t!==-1&&t<i;t=u(t+1)){let n=e.charCodeAt(t+2)|32;b[(e.charCodeAt(t)===60?0:3)+(n===102?0:n===106?1:2)]=t}}for(let e=0;e<6;e++)if(b[e]>=n)return e;return-1},R=(e,t)=>{let n=f(e);return n===-1||n+2>t?(x(14,e,t),!0):n===e?(s=t,!1):(x(14,e,n),!0)},z=e=>(n.push(e),r.push(``),i.push(s),{types:n,texts:r,starts:i,error:c});for(;;){if(s>=t){switch(o){case 0:x(2,t,t);break;case 6:x(22,t,t);break;case 7:x(24,t,t);break;case 8:x(25,t,t);break;case 10:x(32,t,t);break;case 12:x(39,t,t);break;case 14:x(36,t,t);break;case 3:x(12,t,t);break;case 18:x(20,t,t);break;case 4:case 19:x(14,t,t)}return z(0)}let n=e.charCodeAt(s);switch(o){case 0:case 1:{let r=o===0,i=n|32;if(r){if(i===99&&D(`click`,s)&&!w(e.charCodeAt(s+5))){x(26,s,s+5);continue}if(i===104&&D(`href`,s)&&!w(e.charCodeAt(s+4))){x(28,s,s+4);continue}if(n===34){let t=e.indexOf(`"`,s+1);if(t!==-1){x(27,s,t+1);continue}}if(i===100&&D(`default`,s)&&!w(e.charCodeAt(s+7))){x(33,s,s+7);continue}let t=M(s);if(t!==-1){x(40+t,s,A(_[t]));continue}if(n===10){let t=s+1;for(;e.charCodeAt(t)===10;)t++;x(2,s,t);continue}if(T(n)){s=O(s);continue}}else if(n!==10&&T(n)){let n=s+1;for(;n<t&&e.charCodeAt(n)!==10&&T(e.charCodeAt(n));)n++;s=n;continue}if(n===35||n===37&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)!==123){s=A(s);continue}if(i===115){if(r&&D(`scale`,s)){let e=O(s+5);if(e>s+5){x(7,s,e),C(5);continue}}if(D(`style`,s)){let e=O(s+5);if(e>s+5){x(34,s,e),C(13);continue}}if(D(`state`,s)){let e=O(s+5);if(e>s+5){s=e,C(2);continue}if(r&&D(`diagram`,s+5)){let t=D(`-v2`,s+12)?s+15:s+12;if(e=O(t),e>t){x(3,s,e);continue}}}}else if(i===99){if(D(`class`,s)){let e=D(`def`,s+5),t=e?s+8:s+5,n=O(t);if(n>t){x(e?29:37,s,n),C(e?9:11);continue}}}else if(i===97&&r&&(D(`acctitle`,s)||D(`accdescr`,s))){let t=(e.charCodeAt(s+3)|32)==116,n=O(s+8),r=e.charCodeAt(n);if(r===58){x(t?21:23,s,O(n+1)),C(t?6:7);continue}if(r===123&&!t){s=O(n+1),C(8);continue}}if(r){if(n===123){x(10,s,s+1),C(1);continue}}else{let e=M(s);if(e!==-1){x(40+e,s,A(_[e]));continue}if(n===125){x(11,s,s+1),E();continue}if(n===10){s++;continue}}if(i===110&&D(`note`,s)){let e=O(s+4);if(e>s+4){x(19,s,e),C(15);continue}}if(r&&i===104&&D(`hide empty description`,s)&&!w(e.charCodeAt(s+22))){x(6,s,s+22);continue}if(n===91&&e.charCodeAt(s+1)===42&&e.charCodeAt(s+2)===93){x(44,s,s+3);continue}let a=s;for(;a<t;){let t=e.charCodeAt(a);if(t===58||t===45||t===123||T(t))break;a++}if(a>s){R(s,a);continue}if(n===58){for(a=s+1;a<t;){let n=e.charCodeAt(a);if(n===10||n===59)break;if(n===58){let n=e.charCodeAt(a+1);if(a+1>=t||n===58||n===10||n===59)break;a++}a++}if(a>s+1){S(4,e.slice(s,a).trim(),s,a);continue}if(e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58){x(45,s,s+3);continue}}else if(n===45&&e.charCodeAt(s+1)===45){if(e.charCodeAt(s+2)===62){x(5,s,s+3);continue}if(!r){x(18,s,s+2);continue}}if(!r)return z(1);x(48,s,s+1);continue}case 2:{if(n!==10&&T(n)){let n=s+1;for(;n<t&&e.charCodeAt(n)!==10&&T(e.charCodeAt(n));)n++;s=n;continue}if(n===35||n===37&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)!==123){s=A(s);continue}let r=L(s);if(r!==-1){let t=b[r],n=r===2||r===5;S(n?17:r%3==0?15:16,e.slice(s,t).trim(),s,t+(n?10:8)),E();continue}if(n===34){s++,C(3);continue}let i=n===10?O(s):s;if(D(`as`,i)){let e=O(i+2);if(e>i+2){x(13,s,e),C(4);continue}}if(n===10){s++,E();continue}if(n===123){x(10,s,s+1),E(),C(1);continue}if(w(n)){let t=k(s),n=O(t);if(n>t&&w(e.charCodeAt(n))){let t=p(n+1);if(t!==-1&&t<j(n))return c=`Error: State name must be a single word. Found: "${e.slice(s,t+1).trim()}"`,z(1)}}let a=s+1;for(;a<t;){let t=e.charCodeAt(a);if(t===123||T(t))break;a++}x(9,s,a);continue}case 3:{if(n===34){s++,E();continue}let r=e.indexOf(`"`,s);x(12,s,r===-1?t:r);continue}case 4:{let n=s;for(;n<t;){let t=e.charCodeAt(n);if(t===10||t===123)break;n++}R(s,n)&&E();continue}case 5:{if(n>=48&&n<=57){let n=s+1;for(;n<t&&e.charCodeAt(n)>=48&&e.charCodeAt(n)<=57;)n++;x(8,s,n);continue}let r=O(s);if(r>s&&D(`width`,r)&&!w(e.charCodeAt(r+5))){s=r+5,E();continue}return z(1)}case 6:x(22,s,A(s)),E();continue;case 7:x(24,s,A(s)),E();continue;case 8:{if(n===125){s++,E();continue}let r=e.indexOf(`}`,s);x(25,s,r===-1?t:r);continue}case 9:{let e=D(`default`,s)&&O(s+7)>s+7,t=e?s+7:k(s),n=O(t);if(t===s||n===t)return z(1);x(e?31:30,s,n),E(),C(10);continue}case 10:x(32,s,A(s)),E();continue;case 11:{let t=k(s);if(t===s)return z(1);for(;e.charCodeAt(t)===44;){let e=O(t+1),n=k(e);if(n===e)break;t=n}x(38,s,t),E(),C(12);continue}case 12:x(39,s,A(s)),E();continue;case 13:{let n=s;for(;n<t&&(w(e.charCodeAt(n))||e.charCodeAt(n)===44);)n++;let r=O(n);if(n===s||r===n)return z(1);x(35,s,r),E(),C(14);continue}case 14:x(36,s,A(s)),E();continue;case 15:if(D(`left of`,s)&&!w(e.charCodeAt(s+7))){x(46,s,s+7),E(),C(16);continue}if(D(`right of`,s)&&!w(e.charCodeAt(s+8))){x(47,s,s+8),E(),C(16);continue}if(n===34){s++,E(),C(18);continue}return z(1);case 16:{let n=O(s),r=n;for(;r<t;){let t=e.charCodeAt(r);if(t===58||t===45||T(t))break;r++}if(r===n)return z(1);R(s,r)&&(E(),C(17));continue}case 17:{let n=O(s);if(e.charCodeAt(n)===58){let r=n+1;for(;r<t;){let t=e.charCodeAt(r);if(t===58||t===10||t===59)break;r++}if(r>n+1){S(20,e.slice(s+2,r).trim(),s,r),E();continue}}let r=e.indexOf(`
|
|
4
|
+
`,s),i=-1;for(;r!==-1&&(i=O(r),!D(`end note`,i)||w(e.charCodeAt(i+8)));)r=e.indexOf(`
|
|
5
|
+
`,i);if(r===-1)return z(1);S(20,e.slice(s,i).trim(),s,i+8),E();continue}case 18:{let r=O(s);if(D(`as`,r)){x(13,s,O(r+2)),E(),C(19);continue}if(n===34){s++;continue}let i=e.indexOf(`"`,s);x(20,s,i===-1?t:i);continue}case 19:R(s,A(s))&&E();continue}}}var R=[`TB`,`BT`,`RL`,`LR`],z=`'NL', 'ID', 'HIDE_EMPTY', 'scale', 'COMPOSIT_STATE', 'STATE_DESCR', 'FORK', 'JOIN', 'CHOICE', 'CONCURRENT', 'note', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'CLICK', 'classDef', 'style', 'class', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'EDGE_STATE'`;function B(e,t){let{types:n,texts:r,starts:i,error:a}=L(e),o=0,s=t=>{let r=n[o];throw r===1?a===void 0?D(`state`,e,i[o],``,!0):new S(a,`syntax`,{type:`state`,...E(e,i[o])}):D(`state`,e,i[o],`Expecting ${t}, got '${M[r]}'`)},c=e=>(n[o]!==e&&s(`'${M[e]}'`),r[o++]),l=()=>{let e=n[o];e!==14&&e!==44&&s(`'ID', 'EDGE_STATE'`);let t=r[o++].trim();return n[o]===45?(o++,{stmt:`state`,id:t,classes:[c(14).trim()],type:`default`,description:``}):{stmt:`state`,id:t,type:`default`,description:``}};for(;n[o]===2;)o++;n[o]!==3&&s(`'NL', 'SD'`),o++;let u=[],d=[],f=e=>{e!==`nl`&&u.push(e)},p=(e,t)=>{o++;let n=[];u.push({stmt:`state`,id:e,type:`default`,description:t,doc:n}),d.push(u),u=n};for(;;){let e=n[o];switch(e){case 2:o++;break;case 14:case 44:{let e=l();if(n[o]===4)e.description=t.trimColon(r[o++]),f(e);else if(n[o]===5){o++;let i=l();n[o]===4?f({stmt:`relation`,state1:e,state2:i,description:t.trimColon(r[o++])}):f({stmt:`relation`,state1:e,state2:i})}else f(e);break}case 6:f(r[o++]);break;case 7:o++,c(8),f(r[o-2]);break;case 9:n[o+1]===10?p(r[o++],``):f(r[o++]);break;case 12:{let e=r[o++];c(13);let t=c(14);if(n[o]===10)p(t,e);else if(t.includes(`:`)){let n=t.split(`:`);f({stmt:`state`,id:n[0],type:`default`,description:[e.trim(),n[1]]})}else f({stmt:`state`,id:t,type:`default`,description:e.trim()});break}case 15:f({stmt:`state`,id:r[o++],type:`fork`});break;case 16:f({stmt:`state`,id:r[o++],type:`join`});break;case 17:f({stmt:`state`,id:r[o++],type:`choice`});break;case 18:o++,f({stmt:`state`,id:t.getDividerId(),type:`divider`});break;case 19:{let e=r[o++];if(n[o]===46||n[o]===47){let e=r[o++].trim();f({stmt:`state`,id:c(14).trim(),note:{position:e,text:c(20).trim()}})}else n[o]!==20&&s(`'NOTE_TEXT', 'left_of', 'right_of'`),o++,c(13),c(14),f(e);break}case 40:case 41:case 42:case 43:{let n=R[e-40];o++,t.setDirection(n),f({stmt:`dir`,value:n});break}case 21:{o++;let e=c(22).trim();t.setAccTitle(e),f(e);break}case 23:{o++;let e=c(24).trim();t.setAccDescription(e),f(e);break}case 25:{let e=r[o++].trim();t.setAccDescription(e),f(e);break}case 26:{o++;let e=l(),t,i=``;n[o]===28?(o++,t=c(27)):(n[o]!==27&&s(`'STRING', 'HREF'`),t=r[o++],i=c(27)),c(2),f({stmt:`click`,id:e,url:t,tooltip:i});break}case 29:o++,f({stmt:`classDef`,id:c(30).trim(),classes:c(32).trim()});break;case 34:o++,f({stmt:`style`,id:c(35).trim(),styleClass:c(36).trim()});break;case 37:o++,f({stmt:`applyClass`,id:c(38).trim(),styleClass:c(39).trim()});break;case 11:d.length===0&&s(`'$end', ${z}`),o++,u=d.pop();break;case 0:return d.length>0&&s(`'STRUCT_STOP', ${z}`),t.setRootDoc(u),u;default:s(d.length>0?`'STRUCT_STOP', ${z}`:`'$end', ${z}`)}}}var ne=40,re=16,ie=44,V=16,ae=10,oe=16,se=10,ce=26,le=8,ue=320,de=10,fe=8,pe=` fill="var(--_s)" stroke="var(--_b)"`,H=` fill="none" stroke="var(--_b)"`,me=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g,he=new Map([[`rectWithTitle`,1],[`stateStart`,2],[`stateEnd`,3],[`choice`,4],[`fork`,5],[`join`,6],[`note`,7],[`divider`,10]]),ge=[`pele-node pele-state`,`pele-node pele-state`,`pele-node pele-state-start`,`pele-node pele-state-end`,`pele-node pele-state-choice`,`pele-node pele-state-fork`,`pele-node pele-state-join`,`pele-note`,`pele-cluster pele-state-composite`];function _e(e){return e===`TB`||e===`BT`}function ve(e,t,n){let r=e.state?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function ye(e){let t=0,n=e.length;for(;t<n&&e.charCodeAt(t)===34;)t++;for(;n>t&&e.charCodeAt(n-1)===34;)n--;return e.slice(t,n)}function be(e,t,n){return e<t?t:e>n?n:e}function xe(e,t,n,r,i){return`<rect x="${s(e)}" y="${s(t)}" width="${s(n)}" height="${s(r)}"${i}/>`}function Se(e,t,n,r){let i=x(0,0);return i.isGroup=!0,i.dir=e,i.padX=t,i.padTop=n,i.padBottom=r,i}function U(e,t,n){return c(e.direction)?l(n,r=>W(e,t,n,r)):W(e,t,n,!1)}function W(c,l,S,w){let T=c.graph,E=l.flowchart?.curve,D=S.fontSize??16,k=Math.round(D*.875),A=S.measurer??O(S.fontFamily,S.fontFamilyMono),j=ve(l,`wrappingWidth`,200),M=S.padding??8,N=S.icons,ee=w?`TB`:b(c.direction),te=o(void 0,!1,A,D,0),P=(e,t,n,r=0)=>o(e,!0,A,t,n,r),F=new Map,I=[],L=[],R=(e,t,n)=>(I.push({node:e,kind:t,style:void 0,label:te,lines:[],w:0,h:0,titleH:0}),n&&L.push(n),I.length-1);for(let e of T.nodes){if(e.shape===`noteGroup`)continue;let t=e.isGroup?e.shape===`divider`?9:8:he.get(e.shape)??0;F.set(e.id,R(e,t,void 0))}let z=I.length,B=[];for(let e=0;e<z;e++){let t=I[e].node.parentId,n=t===void 0?void 0:F.get(t);B.push(n!==void 0&&n!==e&&I[n].node.isGroup?n:-1)}{let e=[];for(let t=0;t<z;t++)e.push([]);let t=[],n=new Uint8Array(z);for(let r=0;r<z;r++)B[r]===-1?(n[r]=1,t.push(r)):e[B[r]].push(r);let r=0,i=()=>{for(;r<t.length;r++)for(let i of e[t[r]])n[i]||(n[i]=1,t.push(i))};i();let a=new Int32Array(z).fill(-1);for(let e=0;e<z;e++){if(n[e])continue;let r=e;for(;a[r]!==e;)a[r]=e,r=B[r];B[r]=-1,n[r]=1,t.push(r),i()}}let U=new Int32Array(z).fill(-1);for(let e=0;e<z;e++){let t=I[e].node.noteFor,n=t===void 0?void 0:F.get(t);n!==void 0&&(U[e]=n,B[e]=B[n])}let W=e=>b(I[e].node.dir),G=e=>_e(B[e]===-1?ee:W(B[e])),K=new Int32Array(z),we=new Uint8Array(z),q=Array(z).fill(1/0),Te=0,Ee=new Int32Array(2*z);for(let e of T.edges){let t=F.get(e.start),n=F.get(e.end);if(t!==void 0&&n!==void 0){if(e.pattern===`dashed`){we[I[t].kind===7?n:t]=1;continue}K[t]=Math.max(K[t],++Ee[2*t]),K[n]=Math.max(K[n],++Ee[2*n+1]),q[t]===1/0&&(q[t]=Te++),q[n]===1/0&&(q[n]=Te++)}}for(let e=0;e<z;e++){let t=I[e],n=t.node,r=a(n.cssStyles.length>0?n.cssCompiledStyles.concat(n.cssStyles):n.cssCompiledStyles),i=+!!r.bold|(r.italic?2:0),o=r.fontSize??D;t.style=r;let s;switch(t.kind){case 8:t.label=P(n.label,o,4e3,i),t.titleH=t.label.height>0?t.label.height+12:0,s=Se(W(e),V,t.titleH+V,V),s.minW=t.label.width+2*V;break;case 9:s=Se(W(e),ae,ae,ae);break;case 2:t.w=t.h=14;break;case 3:t.w=t.h=18;break;case 4:t.w=t.h=30;break;case 5:case 6:{let n=be(40*K[e]+16,72,320);t.w=G(e)?n:fe,t.h=G(e)?fe:n;break}case 10:break;case 7:t.label=P(n.label,k,Math.max(j,ue)),t.w=t.label.width+24,t.h=t.label.height+16;break;default:{t.label=P(n.label,o,j,i);let e=t.label.width,r=t.label.height+2*se;if(t.kind===1){r+=14;for(let a of n.description){let n=P(a===``?` `:a,k,j,i);t.lines.push(n),n.width>e&&(e=n.width),r+=n.height}}t.w=Math.max(e+2*oe,56),t.h=r}}s??=x(t.w,t.h),(t.kind===0||t.kind===1)&&(s.span=(G(e)?t.w:t.h)-24),L.push(s)}let J=[],De=[],Oe=[],Y=new Int32Array(z),X=new Float64Array(z),Z=new Float64Array(z),ke=new Map,Ae=(e,t)=>{if(!L[e].isGroup)return!1;for(let n=B[t];n!==-1;n=B[n])if(n===e)return!0;return!1},je=(e,t)=>(ke.set(J.length,e),q.push(t?-1:1/0),R(void 0,10,x(0,0,e)));for(let e of T.edges){let t=F.get(e.start),n=F.get(e.end);if(t===void 0||n===void 0)continue;let r=P(e.label,k,j),i=r.width>0?r.width+12:0;t===n?(Y[t]++,X[t]=Math.max(X[t],i),Z[t]+=r.height):Ae(t,n)?t=je(t,!0):Ae(n,t)&&(n=je(n,!1)),Oe.push(e),De.push(r),J.push({src:t,dst:n,minlen:1,labelW:i,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}for(let e=0;e<z;e++){if(U[e]!==-1)continue;let t=L[e],n=0;if(Y[e]>0){let r=ce+(Y[e]-1)*8;n=G(e)?r+X[e]:r*.75+4+Z[e],t.isGroup||(G(e)?(t.w+=2*n,t.h=Math.max(t.h,Z[e])):(t.h+=2*n,t.w=Math.max(t.w,X[e])),n=0)}if(!we[e]&&n===0){t.parent=B[e];continue}let r=G(e)?Se(`LR`,n,0,0):Se(`TB`,0,n,n);r.parent=B[e],q.push(q[e]),L[e].parent=R(void 0,10,r)}for(let e=0;e<z;e++)U[e]!==-1&&(L[e].parent=L[U[e]].parent);{let e=[];for(let t=0;t<L.length;t++)e.push([]);let t=[];for(let n=0;n<L.length;n++){let r=L[n].parent;r>=0?e[r].push(n):t.push(n)}let n=e=>I[e].kind===2?0:1,r=(e,t)=>n(e)-n(t)||(q[e]===q[t]?0:q[e]<q[t]?-1:1)||e-t,i=0,a=t.sort(r).reverse();for(;a.length>0;){let t=a.pop();L[t].seq=i++;let n=e[t].sort(r);for(let e=n.length-1;e>=0;e--)a.push(n[e])}}let Me=y(L,J,ee,{nodeSep:ve(l,`nodeSpacing`,ne),edgeSep:re,rankSep:ve(l,`rankSpacing`,ie),portSep:20,tracks:E===`step`||E===`stepBefore`||E===`stepAfter`,straight:E===`linear`,headRoom:u(`arrow_point`)}),Ne=Math.ceil(Me.width+2*M),Pe=Math.ceil(Me.height+2*M),Fe=[],Ie=new Map;for(let e of J){let t=e.route;for(let e=3;e<t.length-3;e+=3){let n=Math.round(t[e+1]),r=Ie.get(n);r?r.push(t[e]):Ie.set(n,[t[e]])}}let Le=[];for(let e=0;e<L.length;e++)Le.push([]);let Q=[];for(let e=0;e<L.length;e++){let t=L[e].parent;t>=0?Le[t].push(e):Q.push(e)}let Re=Q.slice();for(let e=0;e<Q.length;e++)for(let t of Le[Q[e]])Q.push(t);let ze=``,Be=``,Ve=``,He=``,Ue=(e,t,n,r,i)=>{let a=e.filter(e=>I[e].kind===9);if(a.length<2)return;let o=(e,t)=>t?L[e].x-L[e].w/2:L[e].y-L[e].h/2,c=(e,t)=>t?L[e].x+L[e].w/2:L[e].y+L[e].h/2;for(let e of[!0,!1]){let l=a.slice().sort((t,n)=>o(t,e)-o(n,e)||t-n),u=!0;for(let t=1;t<l.length;t++)c(l[t-1],e)>o(l[t],e)+.5&&(u=!1);if(u){for(let a=1;a<l.length;a++){let u=s((c(l[a-1],e)+o(l[a],e))/2+M);Be+=`<path class="pele-divider" d="M${e?`${u},${s(n)}V${s(i)}`:`${s(t)},${u}H${s(r)}`}"/>`}return}}for(let e of a){let t=L[e];Be+=xe(t.x-t.w/2+M,t.y-t.h/2+M,t.w,t.h,` class="pele-divider" rx="${de}"`)}};Ue(Re,M/2,M/2,Ne-M/2,Pe-M/2);for(let e of Q){let a=I[e],o=a.node,l=a.style;if(o===void 0||l===void 0||a.kind>=9)continue;let u=L[e],d=u.x+M,f=u.y+M,p=a.w,m=a.h,h=` class="pele-label"${l.text}`,g;switch(a.kind){case 8:{let t=d-u.w/2,n=f-u.h/2;g=xe(t,n,u.w,u.h,` rx="${de}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${l.shape}`),a.titleH>0&&(g+=`<path d="M${s(t)},${s(n+a.titleH)}H${s(t+u.w)}"${H}${l.line}/>`+i(a.label,Ce(u,a.label.width,Ie)+M,n+a.titleH/2,` class="pele-cluster-label"${l.text}`,N)),Ue(Le[e],t,n+a.titleH,t+u.w,n+u.h);break}case 2:g=`<circle r="7" fill="var(--_l)"${l.shape}/>`;break;case 3:g=`<circle r="8.5" fill="var(--_bg)" stroke="var(--_l)"${l.line}/><circle r="5" fill="var(--_l)"${l.shape}/>`;break;case 4:g=`<polygon points="0,${s(-m/2)} ${s(p/2)},0 0,${s(m/2)} ${s(-p/2)},0"${pe}${l.shape}/>`;break;case 5:case 6:g=xe(-p/2,-m/2,p,m,` rx="2" fill="var(--_l)"${l.shape}`);break;case 7:{let e=s(p/2),t=s(m/2),n=s(p/2-le),r=s(le-m/2);g=`<path d="M-${e},-${t}H${n}L${e},${r}V${t}H-${e}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${n},-${t}V${r}H${e}"${H}/>`+i(a.label,0,0,` class="pele-label" font-size="${k}" fill="var(--_m)"`,N);break}default:{if(g=xe(-p/2,-m/2,p,m,` rx="${s(Math.min(de,m/2))}"${pe}${l.shape}`),a.kind===0){g+=i(a.label,0,0,h,N);break}let e=se-m/2+a.label.height;g+=`<path d="M${s(-p/2)},${s(e+6)}H${s(p/2)}"${H}${l.line}/>`+i(a.label,0,e-a.label.height/2,h,N),e+=14;for(let t of a.lines)g+=i(t,0,e+t.height/2,` class="pele-state-description" font-size="${k}"${l.text}`,N),e+=t.height}}let y=c.links.get(o.id);if(y){let e=C(ye(y.tooltip));e&&(g=`<title>${t(e)}</title>`+g),g=v(g,_(ye(y.url)),o.id,Fe,S,` target="_blank"`)}let b=`<g class="${ge[a.kind]}${n(o.cssClasses.replace(me,``))}" data-id="${r(o.id)}"`;a.kind===8?ze+=`${b}>${g}</g>`:a.kind===7?He+=`${b} transform="translate(${s(d)},${s(f)})">${g}</g>`:Ve+=`${b} transform="translate(${s(d)},${s(f)})">${g}</g>`}let We=(e,t,n)=>{let r=L[n];if(r.isGroup)return;let i=I[n],a=i.kind===5||i.kind===6,o=t===0?3:t-3;for(let n of[1,0]){let s=n?r.h:r.w,c=n?i.h:i.w,l=n?i.w:i.h,u=(n?r.y:r.x)+M,d=(n?r.x:r.y)+M,f=e[t+n]-u;if(!(Math.abs(Math.abs(f)-s/2)>=.5)){e[t+n]-=Math.sign(f)*(s-c)/2,a&&l>c&&(e[t+1-n]=be(e[o+1-n],d-l/2+6,d+l/2-6));return}}},Ge=d();for(let e=0;e<J.length;e++){let t=J[e];t.src===t.dst||t.route.length<6||Oe[e].pattern===`dashed`||Ge.add(t.dst,g(t.route,t.route.length-3,L[t.dst]),`arrow_point`)}let Ke=``,qe=``,Je=new Int32Array(z),Ye=new Float64Array(z);for(let e=0;e<J.length;e++){let t=J[e],n=Oe[e],i=De[e],a=n.pattern===`dashed`,o=a?`none`:`arrow_point`,c;if(t.src===t.dst){let e=L[t.src],n=I[t.src],r=Je[t.src]++,a=G(t.src),l=e.isGroup?e.w:n.w,d=e.isGroup?e.h:n.h,f=(a?l:d)/2,p=Math.max(Math.min((a?d:l)/2-4,8+r*6),2),m=ce+r*8,h=u(o)/(Math.hypot(m,p)||1),g=(t,n)=>e.x+M+(a?f+t:-n),_=(t,n)=>e.y+M+(a?n:f+t),v=(e,t)=>`${s(g(e,t))},${s(_(e,t))}`;c={d:`M${v(0,-p)}C${v(m,-2*p)} ${v(m,2*p)} ${v(m*h,p+p*h)}`,sx:0,sy:0,sdx:0,sdy:0,ex:g(0,p),ey:_(0,p),edx:g(-m,-p)-g(0,0),edy:_(-m,-p)-_(0,0)};let y=Math.hypot(c.edx,c.edy)||1;c.edx/=y,c.edy/=y;let b=ce+(Y[t.src]-1)*8,x=Ye[t.src]+i.height/2;Ye[t.src]+=i.height,t.labelX=a?e.x+f+b+4+t.labelW/2:e.x,t.labelY=a?e.y-Z[t.src]/2+x:e.y+f+b*.75+4+x}else{let n=t.route.slice(),r=Ge.of(t.src,g(n,0,L[t.src])),i=Ge.of(t.dst,g(n,n.length-3,L[t.dst]));for(let e=0;e<n.length;e+=3)n[e]+=M,n[e+1]+=M;We(n,0,t.src),We(n,n.length-3,t.dst);let a=ke.get(e);if(a!==void 0&&n.length>=6){let e=L[a],r=I[t.src].kind===10,i=r?0:n.length-3,o=(e.dir===`TB`||e.dir===`LR`)===r,s=_e(e.dir)?[n[i],e.y+M+(o?I[a].titleH-e.h/2:e.h/2),0]:[e.x+M+(o?-e.w/2:e.w/2),n[i+1],1];n=r?s.concat(n):n.concat(s)}c=p(n,typeof E==`string`?E:void 0,0,u(o),r,i)}if(Ke+=`<g class="pele-edge ${a?`pele-note-edge" stroke="var(--_b)" stroke-dasharray="3 4`:`pele-transition`}" data-id="${r(n.id)}"><path d="${c.d}"/>`+m(o,c.ex,c.ey,c.edx,c.edy,`var(--_l)`)+`</g>`,i.width>0){let e=t.labelX+M,r=t.labelY+M;qe+=f(n.id,i,e,r,``,N)}}let $=h(c.title,A,D,M,Ne,Pe,(ze?`<g class="pele-clusters">${ze}</g>`:``)+(Be?`<g class="pele-dividers" stroke-dasharray="4 4"${H}>${Be}</g>`:``)+(Ke?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${Ke}</g>`:``)+(qe?`<g class="pele-edge-labels" font-size="${k}">${qe}</g>`:``)+`<g class="pele-nodes">${Ve}${He}</g>`);return{svg:e(`state`,$.width,$.height,D,S,c,$.content),width:$.width,height:$.height,links:Fe}}function Ce(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(r===void 0||t===0)return e.x;let i=e.x-e.w/2,a=t/2,o=e.x,s=-1;for(let t of[e.x,i+V+a,i+e.w-V-a]){let n=1/0;for(let o of r)o>i&&o<i+e.w&&(n=Math.min(n,Math.abs(o-t)-a));if(n>=6)return t;n>s+.5&&(s=n,o=t)}return o}var G={type:`state`,math:!0,parse(e,t,n){let r=new j;return n&&(r.title=n),B(e,r),r},render:U};export{G as state};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,o as t,u as n}from"./E3FWOBN4-D5m5o2g0.js";import{a as r,c as i,d as a,g as o,h as s,i as c,l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"./C5HTQT3I-7U13x70S.js";import{u as _}from"./lazy-DaMZI1F7.js";function v(e,t){return{type:`info`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
2
|
+
`):void 0}}var y=[c(`showInfo`),c(`info`),r,h,f,l,g,p,d,m];function b(e){let t=new s(u(e,y,`info`),y,`info`),n={$type:`Info`};for(;t.kind===5;)t.i++;for(t.expect(1);t.kind===5;)t.i++;if(t.accept(0))for(;t.kind===5;)t.i++;for(;t.kind!==-1;){let e=t.kind;if(e===2?n.accDescr=i(t.take()):e===3?n.accTitle=o(t.take()):e===4?n.title=a(t.take()):t.fail(`a title or the end of input`),t.kind===-1)break;for(t.kind!==5&&t.fail(`a line break or the end of input`);t.kind===5;)t.i++}return n}var x=`1.10.0`;function S(r,i,a){let o=a.fontSize??16,s=a.measurer??_(a.fontFamily,a.fontFamilyMono),c=a.padding??8,l=n(r.title,!1,s,o,4e3,1),u=l.height>0?l.height+8:0,d=n(`Pele v${x}`,!1,s,o,4e3),f=Math.ceil(Math.max(l.width,d.width)+2*c),p=Math.ceil(u+d.height+2*c),m=t(l,f/2,c+l.height/2,` class="pele-title" font-weight="var(--_tw)"`)+t(d,f/2,c+u+d.height/2,` class="pele-version" fill="var(--_m)"`);return{svg:e(`info`,f,p,o,a,r,m),width:f,height:p,links:[]}}var C={type:`info`,parse:(e,t,n)=>v(b(e),n),render:S};export{C as info};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,i as t,o as n,r,u as i,x as a}from"./E3FWOBN4-D5m5o2g0.js";import{o,r as s}from"./DKTLEL5E-DciMwFJ1.js";import{a as c,i as l,s as u}from"./CUVCMPQX-JTGMOfG2.js";import{a as d,c as f,d as p,f as m,g as h,h as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T}from"./C5HTQT3I-7U13x70S.js";import{PeleError as E,u as ee}from"./lazy-DaMZI1F7.js";function D(e){throw new E(e,`semantic`,{type:`architecture`})}var O=class{type=`architecture`;title;accTitle;accDescr;nodes=new Map;groups=new Map;edges=[];layoutHints=[];registered=new Map;register(e,t,n){this.registered.has(t)&&D(`The ${e} id [${t}] is already in use by another ${this.registered.get(t)}`),n!==void 0&&(t===n&&D(`The ${e} [${t}] cannot be placed within itself`),this.registered.has(n)||D(`The ${e} [${t}]'s parent does not exist. Please make sure the parent is created before this ${e}`),this.registered.get(n)===`node`&&D(`The ${e} [${t}]'s parent is not a group`)),this.registered.set(t,e===`group`?`group`:`node`)}addService({id:e,icon:t,iconText:n,title:r,in:i}){this.register(`service`,e,i),this.nodes.set(e,{id:e,type:`service`,icon:t,iconText:n,title:r,in:i})}addJunction({id:e,in:t}){this.register(`junction`,e,t),this.nodes.set(e,{id:e,type:`junction`,in:t})}addGroup({id:e,icon:t,title:n,in:r}){this.register(`group`,e,r),this.groups.set(e,{id:e,icon:t,title:n,in:r})}addEdge({lhsId:e,rhsId:t,lhsDir:n,rhsDir:r,lhsInto:i,rhsInto:a,lhsGroup:o,rhsGroup:s,title:c}){let l=[[`left`,e,o],[`right`,t,s]];for(let[e,t]of l)this.registered.has(t)||D(`The ${e}-hand id [${t}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[e,t]of l)this.nodes.has(t)||D(`The ${e}-hand id [${t}] is a group. Add {group} to a service inside it instead.`);let u=this.nodes.get(e).in;if(u!==void 0&&u===this.nodes.get(t).in)for(let[e,t,n]of l)n&&D(`The ${e}-hand id [${t}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);this.edges.push({lhsId:e,lhsDir:n,lhsInto:i,lhsGroup:o,rhsId:t,rhsDir:r,rhsInto:a,rhsGroup:s,title:c})}addLayoutHint(e){e.members.length<2&&D(`An align directive requires at least two members; got ${e.members.length}`);let t=new Set;for(let n of e.members)this.registered.get(n)!==`node`&&D(`align ${e.direction} references [${n}], which is not a service or junction`),t.has(n)&&D(`align ${e.direction} lists [${n}] more than once`),t.add(n);this.layoutHints.push(e)}};function k(e,t){e.accDescr&&(t.accDescr=e.accDescr.replace(/\n\s+/g,`
|
|
2
|
+
`)),e.accTitle&&(t.accTitle=e.accTitle.replace(/^\s+/g,``)),e.title&&(t.title=e.title);for(let n of e.groups)t.addGroup(n);for(let n of e.services)t.addService(n);for(let n of e.junctions)t.addJunction(n);for(let n of e.edges)t.addEdge(n);for(let n of e.alignments)t.addLayoutHint({direction:n.direction,members:[...n.members]})}var A={name:`ID`,pattern:/[\w]([-\w]*\w)?/y};function j(e){return{name:e,pattern:e,longer:[A]}}var M=[j(`architecture-beta`),j(`junction`),j(`service`),j(`column`),j(`group`),j(`align`),j(`row`),{name:`--`,pattern:`--`,longer:[S]},j(`in`),{name:`:`,pattern:`:`},{name:`-`,pattern:`-`,longer:[S]},{name:`ARROW_DIRECTION`,pattern:/L|R|T|B/y},{name:`ARROW_GROUP`,pattern:/\{group\}/y},{name:`ARROW_INTO`,pattern:/<|>/y},d,w,x,v,A,_,T,S,b,C,{name:`ARCH_ICON`,pattern:/\([\w-:]+\)/y},{name:`ARCH_TITLE`,pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];function N(e){let t=e.slice(1,-1).trim();return(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).replace(/\\"/g,`"`).replace(/\\'/g,`'`)),t.trim()}function P(e){let t=new g(y(e,M,`architecture`),M,`architecture`),n={$type:`Architecture`,groups:[],services:[],junctions:[],edges:[],alignments:[]},r=e=>t.kinds[t.i]===e,i=()=>{if(t.kind!==-1)for(t.kind!==19&&t.fail(`a line break or the end of input`);t.kind===19;)t.i++};for(;t.kind===19;)t.i++;for(t.expect(0);t.kind!==-1;){switch(t.kind){case 19:t.i++;continue;case 14:n.accDescr=f(t.take());break;case 15:n.accTitle=h(t.take());break;case 16:n.title=p(t.take());break;case 4:{t.i++;let e={$type:`Group`,id:t.expect(18)};r(24)&&(e.icon=t.take().slice(1,-1)),r(25)&&(e.title=N(t.take())),t.accept(8)&&(e.in=t.expect(18)),n.groups.push(e);break}case 2:{t.i++;let e={$type:`Service`,id:t.expect(18)};r(17)?e.iconText=m(t.take()):r(24)&&(e.icon=t.take().slice(1,-1)),r(25)&&(e.title=N(t.take())),t.accept(8)&&(e.in=t.expect(18)),n.services.push(e);break}case 1:{t.i++;let e={$type:`Junction`,id:t.expect(18)};t.accept(8)&&(e.in=t.expect(18)),n.junctions.push(e);break}case 18:{let e=t.take(),i=t.accept(12);t.expect(9);let a=t.expect(11),o=t.accept(13),s;t.accept(7)||(r(10)||t.fail(`'--' or '-'`),t.i++,s=N(t.expect(25)),t.expect(10));let c=t.accept(13),l=t.expect(11);t.expect(9);let u=t.expect(18),d=t.accept(12);n.edges.push({$type:`Edge`,lhsId:e,lhsGroup:i,lhsDir:a,lhsInto:o,title:s,rhsInto:c,rhsDir:l,rhsId:u,rhsGroup:d});break}case 5:{t.i++,!r(6)&&!r(3)&&t.fail(`'row' or 'column'`);let e=t.take(),i=[t.expect(18),t.expect(18)];for(;r(18);)i.push(t.take());n.alignments.push({$type:`Alignment`,direction:e,members:i});break}default:t.fail(`a group, a service, a junction, an edge, an alignment, a title, or a line break`)}i()}return n}var F=new Map([[`database`,`M4 6a8 3 0 1 0 16 0a8 3 0 1 0-16 0M4 6v12a8 3 0 0 0 16 0V6M4 12a8 3 0 0 0 16 0`],[`server`,`M3 4h18v7H3zM3 13h18v7H3zM7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6`],[`disk`,`M5 3h14v18H5zM12 6.5a4 4 0 1 0 0 8a4 4 0 1 0 0-8M12 10.5h.01M8 18h3`],[`internet`,`M3 12a9 9 0 1 0 18 0a9 9 0 1 0-18 0M3 12h18M12 3a13 13 0 0 0 0 18M12 3a13 13 0 0 1 0 18`],[`cloud`,`M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9.5a4.25 4.25 0 0 1-.5 8.5z`]]);function I(e){let t=F.get(e);return t===void 0?``:`<path d="${t}" stroke="var(--_fg)" stroke-width="1.5"/>`}var L=[-1,1,0,0],R=[0,0,-1,1];function te(e){return e===`L`?0:e===`R`?1:e===`T`?2:3}var z=64,B=2**25,V=2**26;function ne(e,t,n,r){let i=e.length,a=t.length,o=a,s=new Map,c=new Map,l=new Int32Array(i+a).fill(o),u=new Int32Array(a+1),d=[];for(let e=0;e<=a;e++)d.push([]);t.forEach((e,t)=>{c.set(e.id,t);let n=e.in===void 0?void 0:c.get(e.in);n!==void 0&&n!==t?(l[i+t]=n,u[t]=u[n]+1):u[t]=1}),e.forEach((e,t)=>{s.set(e.id,t);let n=e.in===void 0?void 0:c.get(e.in);n!==void 0&&(l[t]=n),d[l[t]].push(t)});for(let e=0;e<a;e++)d[l[i+e]].push(i+e);let f=[],p=[],m=[],h=[],g=[],_=[],v=Array(i+a),y=Array(i+a),b=(e,t,n,r,a)=>{if(e===t)return;let o=e,s=t,c=l[e],d=l[t];for(;c!==d;)u[c]>=u[d]?(o=i+c,c=l[o]):(s=i+d,d=l[s]);let v=f.length;f.push(e),p.push(t),m.push(n),h.push(r),g.push(o),_.push(s),(a[o]??=[]).push(v),(a[s]??=[]).push(v)};for(let e of r){let t=e.direction===`row`;for(let n=1;n<e.members.length;n++){let r=s.get(e.members[n-1]),i=s.get(e.members[n]);r!==void 0&&i!==void 0&&b(r,i,t?1:3,t?0:2,v)}}for(let e of[!1,!0])for(let t of n){if(t.lhsDir===t.rhsDir!==e)continue;let n=s.get(t.lhsId),r=s.get(t.rhsId);n!==void 0&&r!==void 0&&b(n,r,te(t.lhsDir),te(t.rhsDir),y)}let x=new Int32Array(i+a),S=new Int32Array(i+a),C=new Int32Array(i+a).fill(1),w=new Int32Array(i+a).fill(1),T=new Uint8Array(i+a),E=[],ee=new Map,D=[],O=new Map,k=0,A=0,j=0,M=(e,t)=>{A=0,j=0;for(let n=e;n!==t;n=i+l[n])A+=x[n],j+=S[n]},N=(e,t,n)=>{if(x[e]=t,S[e]=n,T[e]=1,E.push(e),C[e]*w[e]>z)D.push(e);else for(let r=n;r<n+w[e];r++)for(let n=t;n<t+C[e];n++)ee.set((n+B)*V+r+B,e)},P=(e,t,n,r,i)=>x[e]<t+r&&t<x[e]+C[e]&&S[e]<n+i&&n<S[e]+w[e],F=(e,t,n,r)=>{if(n*r>z){for(let i=k;i<E.length;i++)if(P(E[i],e,t,n,r))return E[i];return-1}for(let i=t;i<t+r;i++)for(let t=e;t<e+n;t++){let e=ee.get((t+B)*V+i+B);if(e!==void 0)return e}for(let i of D)if(P(i,e,t,n,r))return i;return-1},I=(e,t,n,r,i,a)=>{let o=`${e},${t},${n},${r},${i},${a}`,s=O.get(o)??0;for(;;){let o=F(e+s*i,t+s*a,n,r);if(o<0)break;s=i>0?x[o]+C[o]-e:i<0?e+n-x[o]:a>0?S[o]+w[o]-t:t+r-S[o]}return O.set(o,s),s},ne=(e,t)=>{let n=g[t]===e,r=n?_[t]:g[t];if(T[r])return;let i=n?m[t]:h[t],a=n?h[t]:m[t];M(n?f[t]:p[t],e);let o=A,s=j;M(n?p[t]:f[t],r);let c=L[i],l=R[i],u=0,d=0,v=L[i]+L[a]===0&&R[i]+R[a]===0;i===a?(c=+(L[i]===0),l=1-c):v||(u=-L[a],d=-R[a]);let b,E;if(c===0?(E=l>0?S[e]+w[e]:S[e]-w[r],b=x[e]+o+u-A):(b=c>0?x[e]+C[e]:x[e]-C[r],E=S[e]+s+d-j),v){let e=y[r];if(e!==void 0&&e.length>1){let t=[];for(let n of e){let e=_[n]===r,o=e?g[n]:_[n];if(!T[o]||(e?m[n]:h[n])!==i||(e?h[n]:m[n])!==a)continue;M(e?f[n]:p[n],o);let s=c===0?x[o]+A:S[o]+j;M(e?p[n]:f[n],r),t.push(s-(c===0?A:j))}t.length>1&&(t.sort((e,t)=>e-t),c===0?b=t[t.length-1>>1]:E=t[t.length-1>>1])}let t=+(c===0),n=1-t,o=I(b,E,C[r],w[r],t,n),s=o===0?0:I(b,E,C[r],w[r],-t,-n),l=o<=s?o:-s;b+=t*l,E+=n*l}else{let e=I(b,E,C[r],w[r],c,l);b+=c*e,E+=l*e}N(r,b,E)},H=e=>{let t=d[e];if(t.length===0)return;E.length=0;let n=[];for(let e of t){if(T[e])continue;k=E.length,n.push(k),ee.clear(),D.length=0,O.clear(),N(e,0,0);let t=k,r=k,i=0;for(;;){if(t<E.length){let e=E[t++],n=v[e];if(n!==void 0)for(let t of n)ne(e,t);continue}if(r>=E.length)break;let e=y[E[r]];e===void 0||i>=e.length?(r++,i=0):ne(E[r],e[i++])}}n.push(E.length);let r=n.length-1,o=Array(r),s=Array(r),c=Array(r),l=Array(r),u=0,f=0;for(let e=0;e<r;e++){let t=1/0,r=1/0,i=-1/0,a=-1/0;for(let o=n[e];o<n[e+1];o++){let e=E[o];t=Math.min(t,x[e]),r=Math.min(r,S[e]),i=Math.max(i,x[e]+C[e]),a=Math.max(a,S[e]+w[e])}o[e]=t,s[e]=r,c[e]=i-t,l[e]=a-r,u+=c[e]*l[e],f=Math.max(f,c[e])}let p=Math.max(f,Math.ceil(Math.sqrt(u*2))),m=0,h=0,g=0,_=0;for(let e=0;e<r;e++){m>0&&m+c[e]>p&&(h+=g,m=0,g=0);for(let t=n[e];t<n[e+1];t++)x[E[t]]+=m-o[e],S[E[t]]+=h-s[e];m+=c[e],g=Math.max(g,l[e]),_=Math.max(_,m)}e<a&&(C[i+e]=_,w[i+e]=h+g)};for(let e=a-1;e>=0;e--)H(e);H(o);let U=new Int32Array(a),W=new Int32Array(a),re=new Int32Array(a),ie=new Uint8Array(a);for(let e=0;e<a;e++){let t=l[i+e];re[e]=t===o?-1:t,U[e]=x[i+e]+(t===o?0:U[t]),W[e]=S[i+e]+(t===o?0:W[t]),d[e].length===0&&(ie[e]=1)}let ae=new Int32Array(i),oe=new Int32Array(i),se=new Int32Array(i);for(let e=0;e<i;e++){let t=l[e];se[e]=t===o?-1:t,ae[e]=x[e]+(t===o?0:U[t]),oe[e]=S[e]+(t===o?0:W[t])}return{col:ae,row:oe,groupCol:U,groupRow:W,groupCols:C.slice(i),groupRows:w.slice(i),groupParent:re,groupEmpty:ie,nodeParent:se}}var H=12,U=6,W=4,re=3,ie=[-1,1,0,0],ae=[0,0,-1,1];function oe(e,t,n,r,i){let a=e.architecture,o=typeof a==`object`&&a&&!Array.isArray(a)?a[t]:void 0;return typeof o==`number`&&Number.isFinite(o)?Math.min(i,Math.max(r,o)):n}function se(e){let t=new Map;for(let n of e.sort((e,t)=>e-t))t.has(n)||t.set(n,t.size);return t}function ce(e,n,r,i,o){return`<svg class="pele-icon" data-icon="${t(e)}" x="${a(n)}" y="${a(r)}" width="${a(i)}" height="${a(i)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${o?.(e)??I(e)}</svg>`}function le(e,t,n,r){let i=e.lines.length>n;if(!i&&e.width<=t)return e;let a=r.width(`…`,e.size,0),o=[],s=[],c=0;for(let l=0;l<Math.min(n,e.lines.length);l++){let u=e.lines[l].map(e=>({...e})),d=e.widths[l];if(d>t||i&&l===n-1)for(;;){let n=u[u.length-1];if(n===void 0){u.push({text:`…`,style:0,width:a}),d=a;break}let i=d-n.width;if(n.icon===void 0&&i+a<t){let o=0,s=n.text.length;for(;o<s;){let c=o+s+1>>1;i+r.width(n.text.slice(0,c),e.size,n.style)+a<=t?o=c:s=c-1}let c=o>0?n.text.charCodeAt(o-1):0;c>=55296&&c<=56319&&o--,n.text=n.text.slice(0,o).trimEnd()+`…`,n.width=r.width(n.text,e.size,n.style),d=i+n.width;break}u.pop(),d=i}o.push(u),s.push(d),c=Math.max(c,d)}return{...e,lines:o,widths:s,width:c,height:o.length*e.lineHeight}}function ue(e,t){let{x:n,y:r,dx:i,dy:a}=e,{x:o,y:s,dx:c,dy:l}=t,u=n+i*H,d=r+a*H,f=o+c*H,p=s+l*H;if(i*c+a*l===0){let e=i===0?n:o,t=i===0?s:r;return(e-n)*i+(t-r)*a>0&&(e-o)*c+(t-s)*l>0?[n,r,e,t,o,s]:i===0?[n,r,u,d,f,d,f,p,o,s]:[n,r,u,d,u,p,f,p,o,s]}let m=i!==0,h=m?s-r:o-n;if(i===-c&&a===-l){if((o-n)*i+(s-r)*a>0){if(Math.abs(h)<.5)return[n,r,o,s];if(m){let a=i>0?e.x1:t.x1,c=i>0?t.x0:e.x0,l=a<c?(a+c)/2:(n+o)/2;return[n,r,l,r,l,s,o,s]}let c=a>0?e.y1:t.y1,l=a>0?t.y0:e.y0,u=c<l?(c+l)/2:(r+s)/2;return[n,r,n,u,o,u,o,s]}}else if(Math.abs(h)>=1){if(m){let e=i>0?Math.max(n,o)+H:Math.min(n,o)-H;return[n,r,e,r,e,s,o,s]}let e=a>0?Math.max(r,s)+H:Math.min(r,s)-H;return[n,r,n,e,o,e,o,s]}if(m){let i=e.y1+H<=t.y0?(e.y1+t.y0)/2:t.y1+H<=e.y0?(t.y1+e.y0)/2:Math.max(e.y1,t.y1)+H;return[n,r,u,r,u,i,f,i,f,s,o,s]}let g=e.x1+H<=t.x0?(e.x1+t.x0)/2:t.x1+H<=e.x0?(t.x1+e.x0)/2:Math.max(e.x1,t.x1)+H;return[n,r,n,d,g,d,g,p,o,p,o,s]}function de(e){let t=[e[0],e[1]];for(let n=2;n<e.length;n+=2){let r=e[n],i=e[n+1],a=t.length,o=Math.abs(r-t[a-2])<.01,s=Math.abs(i-t[a-1])<.01;o&&s||(a>=4&&(o&&Math.abs(t[a-4]-t[a-2])<.01||s&&Math.abs(t[a-3]-t[a-1])<.01)?(t[a-2]=r,t[a-1]=i):t.push(r,i))}return t}function fe(e,t,n){let r=e.length/2,i=Array(r),o=Array(r);for(let t=0;t<r;t++)i[t]=e[t*2],o[t]=e[t*2+1];let s=(e,t,n)=>{let r=Math.hypot(i[t]-i[e],o[t]-o[e]),a=Math.min(n,Math.max(0,r-1));r>0&&a>0&&(i[e]+=(i[t]-i[e])/r*a,o[e]+=(o[t]-o[e])/r*a)};s(0,1,t),s(r-1,r-2,n);let c=`M${a(i[0])},${a(o[0])}`;for(let e=1;e<r-1;e++){let t=Math.hypot(i[e]-i[e-1],o[e]-o[e-1]),n=Math.hypot(i[e+1]-i[e],o[e+1]-o[e]),r=Math.min(U,t/2,n/2);if(r<.5){c+=`L${a(i[e])},${a(o[e])}`;continue}let s=i[e]-(i[e]-i[e-1])/t*r,l=o[e]-(o[e]-o[e-1])/t*r,u=i[e]+(i[e+1]-i[e])/n*r,d=o[e]+(o[e+1]-o[e])/n*r;c+=`L${a(s)},${a(l)}Q${a(i[e])},${a(o[e])} ${a(u)},${a(d)}`}return c+`L${a(i[r-1])},${a(o[r-1])}`}function G(e,t,n){return o(n,r=>K(e,t,n,r))}function K(o,d,f,p){let m=oe(d,`iconSize`,48,8,512),h=oe(d,`fontSize`,f.fontSize??16,4,128),g=Math.min(oe(d,`padding`,20,0,256),p?12:1/0),_=Math.round(h*.875),v=f.measurer??ee(f.fontFamily,f.fontFamilyMono),y=f.padding??8,b=f.icons,x=m/2,S=[...o.nodes.values()],C=[...o.groups.values()],w=S.length,T=C.length,E=ne(S,C,o.edges,o.layoutHints),D=new Map;S.forEach((e,t)=>D.set(e.id,t));let O=Array(w),k=new Float64Array(w),A=new Float64Array(w),j=p?Math.max(m,64):Math.max(m*2.25,96);for(let e=0;e<w;e++){let t=S[e],n=i(t.type===`service`?t.title:void 0,!0,v,h,j);O[e]=n,k[e]=Math.max(m,2*Math.ceil(n.width/2)),A[e]=m+(n.height>0?W+n.height:0)}let M=[],N=[];for(let e=0;e<w;e++)M.push(E.col[e]),N.push(E.row[e]);for(let e=0;e<T;e++)E.groupEmpty[e]&&(M.push(E.groupCol[e]),N.push(E.groupRow[e]));let P=se(M),F=se(N),I=P.size,L=F.size,R=new Float64Array(I),z=new Float64Array(L),B=p?Math.max(24,2*H):Math.max(40,Math.round(m*.75)),V=new Float64Array(I).fill(B),U=new Float64Array(L).fill(B),G=new Int32Array(w),K=new Int32Array(w);for(let e=0;e<w;e++){let t=G[e]=P.get(E.col[e]),n=K[e]=F.get(E.row[e]);R[t]=Math.max(R[t],k[e]),z[n]=Math.max(z[n],A[e])}for(let e=0;e<T;e++){if(!E.groupEmpty[e])continue;let t=P.get(E.groupCol[e]),n=F.get(E.groupRow[e]);R[t]=Math.max(R[t],m),z[n]=Math.max(z[n],x)}let pe=o.edges.length,me=Array(pe),he=new Int32Array(pe*2);for(let e=0;e<pe;e++){let t=o.edges[e],n=he[e*2]=D.get(t.lhsId)??-1,r=he[e*2+1]=D.get(t.rhsId)??-1,a=i(t.title,!0,v,_,160);if(me[e]=a,!(a.width===0||n<0||r<0)){if(G[n]!==G[r]){let e=Math.min(G[n],G[r]);V[e]=Math.max(V[e],Math.ceil(a.width)+28)}else if(R[G[n]]=Math.max(R[G[n]],2*Math.ceil(a.width/2)+8),K[n]!==K[r]){let e=Math.min(K[n],K[r]);U[e]=Math.max(U[e],Math.ceil(a.height)+24)}}}let ge=Array(T),q=new Int32Array(T),J=new Int32Array(T),_e=new Int32Array(T),Y=new Int32Array(T),ve=new Float64Array(T),ye=new Float64Array(T),be=new Float64Array(T),xe=new Float64Array(T),X=new Float64Array(T),Se=new Float64Array(T),Ce=new Float64Array(I),we=new Float64Array(I),Te=new Float64Array(L),Ee=new Float64Array(L),De=Math.round(h*1.25);for(let e=0;e<T;e++){q[e]=P.get(E.groupCol[e]),J[e]=P.get(E.groupCol[e]+E.groupCols[e]-1),_e[e]=F.get(E.groupRow[e]),Y[e]=F.get(E.groupRow[e]+E.groupRows[e]-1);let t=i(C[e].title,!0,v,h,p?Math.max(80,s(f)/2):320);ge[e]=t;let n=C[e].icon?De:0;X[e]=t.width+n+(t.width>0&&n>0?6:0),Se[e]=Math.max(t.height,n)}for(let e=T-1;e>=0;e--){let t=g+ve[e],n=g+ye[e],r=(Se[e]>0?Math.max(g,Se[e]+12):g)+be[e],i=g+xe[e];if(X[e]>0){let r=t+n;for(let t=q[e];t<=J[e];t++)r+=R[t]+(t<J[e]?we[t]+V[t]+Ce[t+1]:0);X[e]+20>r&&(n+=Math.ceil(X[e]+20-r))}ve[e]=t,ye[e]=n,be[e]=r,xe[e]=i,Ce[q[e]]=Math.max(Ce[q[e]],t),we[J[e]]=Math.max(we[J[e]],n),Te[_e[e]]=Math.max(Te[_e[e]],r),Ee[Y[e]]=Math.max(Ee[Y[e]],i);let a=E.groupParent[e];a<0||(q[a]===q[e]&&(ve[a]=Math.max(ve[a],t)),J[a]===J[e]&&(ye[a]=Math.max(ye[a],n)),_e[a]===_e[e]&&(be[a]=Math.max(be[a],r)),Y[a]===Y[e]&&(xe[a]=Math.max(xe[a],i)))}let Oe=new Float64Array(I),Z=new Float64Array(L),ke=0;for(let e=0;e<I;e++)Oe[e]=ke+Ce[e],ke=Oe[e]+R[e]+we[e]+(e<I-1?V[e]:0);let Ae=0;for(let e=0;e<L;e++)Z[e]=Ae+Te[e],Ae=Z[e]+z[e]+Ee[e]+(e<L-1?U[e]:0);let Q=0,je=0,Me=ke,Ne=Ae,Pe=e=>Oe[q[e]]-ve[e],Fe=e=>Oe[J[e]]+R[J[e]]+ye[e],Ie=e=>Z[_e[e]]-be[e],Le=e=>Z[Y[e]]+z[Y[e]]+xe[e],Re=e=>Oe[G[e]]+R[G[e]]/2,ze=(e,t,n)=>{let r=ie[t],i=ae[t],a=Re(e),o=Z[K[e]],s={x:a,y:o+x,dx:r,dy:i,x0:a-k[e]/2,y0:o,x1:a+k[e]/2,y1:o+A[e],gap:0,wire:!1};S[e].type===`junction`?(s.x0=s.x1=a,s.y0=s.y1=s.y,s.gap=re):r===0?s.y=i<0?o:o+A[e]+(O[e].height>0?2:0):s.x=a+r*x;let c=n?E.nodeParent[e]:-1;return c>=0&&(s.x0=Pe(c),s.x1=Fe(c),s.y0=Ie(c),s.y1=Le(c),s.gap=0,s.wire=S[e].type===`junction`,r===0?s.y=i<0?s.y0:s.y1:s.x=r<0?s.x0:s.x1),s},Be=``,Ve=``,$=[],He=c(`arrow_point`);for(let e=0;e<pe;e++){let n=o.edges[e],r=he[e*2],i=he[e*2+1];if(r<0||i<0)continue;let a=ze(r,te(n.lhsDir),n.lhsGroup),s=ze(i,te(n.rhsDir),n.rhsGroup);a.x===s.x&&a.y===s.y&&a.dx===s.dx&&(a.x-=8*Math.abs(a.dy),a.y-=8*Math.abs(a.dx),s.x+=8*Math.abs(a.dy),s.y+=8*Math.abs(a.dx));let c=ue(a,s);a.wire&&c.unshift(Re(r),Z[K[r]]+x),s.wire&&c.push(Re(i),Z[K[i]]+x);let d=de(c);if(d.length<4)continue;let f=t(`${n.lhsId}-${n.rhsId}`);Be+=`<g class="pele-edge" data-id="${f}"><path d="${fe(d,n.lhsInto&&!a.wire?He+a.gap:0,n.rhsInto&&!s.wire?He+s.gap:0)}"/>`+(n.lhsInto?u(`arrow_point`,a.x+a.dx*a.gap,a.y+a.dy*a.gap,-a.dx,-a.dy,`var(--_l)`):``)+(n.rhsInto?u(`arrow_point`,s.x+s.dx*s.gap,s.y+s.dy*s.gap,-s.dx,-s.dy,`var(--_l)`):``)+`</g>`;let p=-1,m=-1,h=-1,g=-1,_=me[e];for(let e=0;e<d.length;e+=2)Q=Math.min(Q,d[e]-4),Me=Math.max(Me,d[e]+4),je=Math.min(je,d[e+1]-4),Ne=Math.max(Ne,d[e+1]+4);for(let e=0;e+3<d.length;e+=2){let t=Math.abs(d[e+1]-d[e+3])<.01,n=Math.abs(d[e]-d[e+2])+Math.abs(d[e+1]-d[e+3]);t||$.push(d[e],Math.min(d[e+1],d[e+3]),Math.max(d[e+1],d[e+3])),n>m&&(p=e,m=n),t&&n>g&&(h=e,g=n)}if(_.width>0){let e=g>=_.width+8?h:p,t=(d[e]+d[e+2])/2,r=(d[e+1]+d[e+3])/2,i=_.width+8,o=Math.abs(d[e]-d[e+2])<.01;for(let e of[a,s])t+i/2<=e.x0||t-i/2>=e.x1||r+_.height/2<=e.y0||r-_.height/2>=e.y1||(o?t=t>=(e.x0+e.x1)/2?e.x1+i/2+4:e.x0-i/2-4:r=r>=(e.y0+e.y1)/2?e.y1+_.height/2+4:e.y0-_.height/2-4);Q=Math.min(Q,t-i/2),Me=Math.max(Me,t+i/2),je=Math.min(je,r-_.height/2),Ne=Math.max(Ne,r+_.height/2),Ve+=l(`${n.lhsId}-${n.rhsId}`,_,t,r,``,b)}}let Ue=``;for(let e=0;e<T;e++){let i=C[e],o=Pe(e),s=Ie(e),c=Fe(e)-o,l=ge[e],u=``;if(X[e]>0){let t=s+Se[e]+12,r=[];for(let e=0;e<$.length;e+=3)$[e+1]<t&&$[e+2]>s&&$[e]>o&&$[e]<o+c&&r.push($[e]);r.sort((e,t)=>e-t),r.push(o+c-4);let a=o+10;for(let t of r){if(t-6-a>=X[e])break;a=Math.max(a,t+6)}a+X[e]>o+c-4&&(a=o+10);let d=s+6+Se[e]/2,f=a;i.icon&&(u+=ce(i.icon,a,d-De/2,De,b),f+=De+6),u+=n(l,f+l.width/2,d,` class="pele-cluster-label" fill="var(--_m)"`,b)}Ue+=`<g class="pele-cluster" data-id="${t(i.id)}"><rect x="${a(o)}" y="${a(s)}" width="${a(c)}" height="${a(Le(e)-s)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${r}/>`+u+`</g>`}let We=``,Ge=m*.5,Ke=Math.max(6,Math.round(h*.75));for(let e=0;e<w;e++){let o=S[e],s=`data-id="${t(o.id)}" transform="translate(${a(Re(e))},${a(Z[K[e]])})"`;if(o.type===`junction`){We+=`<g class="pele-node pele-junction" ${s}><circle cy="${a(x)}" r="${re}" fill="var(--_l)"/></g>`;continue}let c=``;if(o.icon)c=ce(o.icon,-Ge/2,(m-Ge)/2,Ge,b);else if(o.iconText){let e=i(o.iconText,!1,v,Ke,m-8),t=Math.max(1,Math.floor((m-4)/(e.lineHeight||1)));c=n(le(e,m-8,t,v),0,x,` class="pele-icon-text" font-size="${Ke}"`,b)}We+=`<g class="pele-node pele-service" ${s}><rect x="${a(-x)}" width="${a(m)}" height="${a(m)}" fill="var(--_s)" stroke="var(--_b)"${r}/>`+c+n(O[e],0,m+W+O[e].height/2,` class="pele-label"`,b)+`</g>`}let qe=i(o.title,!1,v,h,p?s(f):4e3,1),Je=qe.height>0?qe.height+12:0,Ye=Math.ceil(Math.max(Me-Q,qe.width)+2*y),Xe=Math.ceil(Ne-je+Je+2*y),Ze=Math.round((Ye-(Me-Q))/2-Q),Qe=Math.round(y+Je-je),$e=(Ue?`<g class="pele-clusters">${Ue}</g>`:``)+(Be?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${Be}</g>`:``)+(Ve?`<g class="pele-edge-labels" font-size="${_}">${Ve}</g>`:``)+(We?`<g class="pele-nodes">${We}</g>`:``);return{svg:e(`architecture`,Ye,Xe,h,f,o,n(qe,Ye/2,y+qe.height/2,` class="pele-title" font-weight="var(--_tw)"`)+($e?`<g transform="translate(${Ze},${Qe})">${$e}</g>`:``)),width:Ye,height:Xe,links:[]}}var pe={type:`architecture`,parse(e,t,n){let r=new O;return n&&(r.title=n),k(P(e),r),r},render:G};export{pe as architecture};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,f as t,i as n,o as r,r as i,u as a,x as o}from"./E3FWOBN4-D5m5o2g0.js";import{a as s,s as c}from"./CUVCMPQX-JTGMOfG2.js";import{a as l,c as u,d,f,g as p,h as m,i as h,l as g,m as ee,n as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./C5HTQT3I-7U13x70S.js";import{u as te}from"./lazy-DaMZI1F7.js";var w=class{domains=new Map;transitions=[];setDomains(e){if(e)for(let t of e){let e=t.domain;this.domains.set(e,{name:e,items:(t.items??[]).map(e=>({label:e.label}))})}}setTransitions(e){e&&(this.transitions=e.filter(e=>e.from!==e.to).map(e=>({from:e.from,to:e.to,label:e.label||void 0})))}};function T(e,t){let n=new w;return n.setDomains(e.domains),n.setTransitions(e.transitions),{type:`cynefin`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
2
|
+
`):void 0,domains:n.domains,transitions:n.transitions}}var E=[{name:`cynefin-beta:`,pattern:`cynefin-beta:`},h(`cynefin-beta`),{name:`-->`,pattern:`-->`},{name:`:`,pattern:`:`},{name:`DOMAIN_NAME`,pattern:/complex|complicated|clear|chaotic|confusion/y},l,S,y,ee,g,C,b,v,x];function D(e){let t=new m(_(e,E,`cynefin`),E,`cynefin`),n={$type:`Cynefin`,domains:[],transitions:[]},r=()=>{for(;t.kinds[t.i]===9;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==9&&t.fail(`a line break or the end of input`),r())};for(r(),t.kind!==1&&t.kind!==0&&t.fail(`'cynefin-beta'`),t.i++;t.kind!==-1;)switch(t.kind){case 9:t.i++;break;case 5:n.accDescr=u(t.take()),i();break;case 6:n.accTitle=p(t.take()),i();break;case 7:n.title=d(t.take()),i();break;case 4:{let e=t.take();if(t.accept(2)){let r={$type:`Transition`,from:e,to:t.expect(4)};t.accept(3)&&(r.label=f(t.expect(8))),i(),n.transitions.push(r);break}let a={$type:`DomainBlock`,domain:e,items:[]};for(r();t.kinds[t.i]===8;)a.items.push({$type:`DomainItem`,label:f(t.take())}),r();n.domains.push(a);break}default:t.fail(`a domain, a transition, a title, or a line break`)}return n}function O(e){let t=e+1831565813|0;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function k(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}function ne(e,t){return typeof e==`number`&&Number.isFinite(e)&&e!==0?e:k(t)}var re={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},A={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};function j(e,t,n,r,i,a){let o=(t-e)/a.segments,s=[],c=[];for(let t=0;t<=a.segments;t++){let l=t===0&&a.pinStart||t===a.segments&&a.pinEnd;s.push(e+t*o),c.push(l?n:n+O(r+t*a.pointStep)*i*2-i)}let l=a.vertical?[c[0],s[0]]:[s[0],c[0]];for(let e=0;e<a.segments;e++){let t=(s[e]+s[e+1])/2,n=i*1.5*(e%2==0?1:-1)*O(r+e*a.controlStep+a.controlShift);a.vertical?l.push(c[e]+n,t,c[e+1]-n,t,c[e+1],s[e+1]):l.push(t,c[e]+n,t,c[e+1]-n,s[e+1],c[e+1])}return l}function ie(e,t,n,r){let i=n-t;return[e,t,e+r,t+i*.2,e-r*1.5,t+i*.55,e+r*.5,t+i*.75,e-r,t+i*.85,e+r*.3,t+i*.95,e,n]}function M(e){let t=``;for(let n=2;n<e.length;n+=6)t+=`C${o(e[n])},${o(e[n+1])} ${o(e[n+2])},${o(e[n+3])} ${o(e[n+4])},${o(e[n+5])}`;return t}function N(e){let t=``;for(let n=e.length-6;n>=2;n-=6)t+=`C${o(e[n+2])},${o(e[n+3])} ${o(e[n])},${o(e[n+1])} ${o(e[n-2])},${o(e[n-1])}`;return t}function P(e){return`M${o(e[0])},${o(e[1])}${M(e)}`}function F(e,t,n,r){let i=`${o(n)},${o(r)}`;return`M${o(e-n)},${o(t)}A${i} 0 1,1 ${o(e+n)},${o(t)}A${i} 0 1,1 ${o(e-n)},${o(t)}Z`}var I=[[`complex`,0,0,0],[`complicated`,1,0,1],[`chaotic`,0,1,3],[`clear`,1,1,2]],ae=4,L=new Map([[`complex`,[`Complex`,`Probe → Sense → Respond`,`Emergent Practices`]],[`complicated`,[`Complicated`,`Sense → Analyse → Respond`,`Good Practices`]],[`clear`,[`Clear`,`Sense → Categorise → Respond`,`Best Practices`]],[`chaotic`,[`Chaotic`,`Act → Sense → Respond`,`Novel Practices`]],[`confusion`,[`Confusion`,``,`Disorder`]]]),oe=3,se=200,ce=10,le=4,R=6,ue=10,de=20,z=10;function B(e,t,n,r,i){let a=e.cynefin?.[t];return typeof a==`number`&&a>=r&&a<=i?a:n}function V(l,u,d){let f=d.fontSize??16,p=Math.round(f*.8125),m=Math.round(f*.875),h=d.measurer??te(d.fontFamily,d.fontFamilyMono),g=d.padding??8,ee=d.icons,_=u.cynefin?.showDomainDescriptions!==!1,v=B(u,`boundaryAmplitude`,8,0,50),y=ne(B(u,`seed`,0,-0x38d7ea4c68000,0x38d7ea4c68000),d.idPrefix??`pele`),b=Math.round(m*1.5),x=(e,t)=>{let n=a(e,!1,h,m,se);return{text:e,label:n,w:n.width+2*ce,h:Math.max(n.height,b)+2*le,overflow:t}},S=e=>{let t=L.get(e),n=a(t[0],!1,h,f,4e3,1),r=[];if(_)for(let e of[t[1],t[2]])e&&r.push(a(e,!1,h,p,4e3,2));let i=l.domains.get(e)?.items??[],o=e===`confusion`&&i.length>oe?oe:i.length,s=[];for(let e=0;e<o;e++)s.push(x(i[e].label,!1));o<i.length&&s.push(x(`+${i.length-o} more`,!0));let c=n.width,u=n.height;for(let e of r)c=Math.max(c,e.width),u+=e.height;s.length>0&&(u+=ue-R);for(let e of s)c=Math.max(c,e.w),u+=R+e.h;return{name:e,title:n,subtitles:r,badges:s,w:c,h:u,cx:0,cy:0}},C=I.map(([e])=>S(e)),w=S(`confusion`),T=Math.max(88,w.w*.71+8),E=Math.max(64,w.h*.71+6),D=B(u,`width`,640,100,1e4)/2,O=B(u,`height`,440,100,1e4)/2;for(let e of C)D=Math.max(D,e.w+2*de),O=Math.max(O,e.h+2*de);for(let e of C){let t=(D-e.w)/2,n=(O-e.h)/2;if((t/(T+z))**2+(n/(E+z))**2>=1)continue;let r=e.w+2*(T+z),i=e.h+2*(E+z);r*O<=D*i?D=Math.max(D,r):O=Math.max(O,i)}let k=a(l.title,!1,h,f,4e3,1),V=k.height>0?k.height+12:0,H=2*D,fe=2*O,U=g,W=g+V,G=U+D,K=W+O,q=U+H,pe=W+fe,J=j(W,K,G,y,v,{...re,segments:4,pinEnd:!0}),Y=j(U,G,K,y+100,v,{...A,segments:4,pinEnd:!0}),X=j(G,q,K,y+200,v,{...A,segments:4,pinStart:!0}),Z=ie(G,K,pe,H*.03),Q=(e,t)=>t?`${o(e[e.length-2])},${o(e[e.length-1])}`:`${o(e[0])},${o(e[1])}`,me=new Map([[`complex`,`M${o(U)},${o(W)}L${Q(J,!1)}${M(J)}${N(Y)}Z`],[`complicated`,`M${Q(J,!1)}L${o(q)},${o(W)}L${Q(X,!0)}${N(X)}${N(J)}Z`],[`chaotic`,`M${Q(Y,!1)}${M(Y)}${M(Z)}L${o(U)},${o(pe)}Z`],[`clear`,`M${Q(X,!1)}${M(X)}L${o(q)},${o(pe)}L${Q(Z,!0)}${N(Z)}Z`]]),he=``;for(let[e,,,n]of I)he+=`<path class="pele-cynefin-region" data-id="${e}" d="${me.get(e)}" fill="${t(n)}" fill-opacity="0.14"/>`;let ge=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${P(J)}"/><path d="${P(Y)}"/><path d="${P(X)}"/><path class="pele-cynefin-cliff" d="${P(Z)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,_e=F(G,K,T,E),ve=`<path d="${_e}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${_e}" fill="${t(ae)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,ye=e=>{let t=e.cy-e.h/2,a=r(e.title,e.cx,t+e.title.height/2,` class="pele-label" font-weight="var(--_hw)"`);t+=e.title.height;for(let n of e.subtitles)a+=r(n,e.cx,t+n.height/2,` class="pele-cynefin-subtitle" font-size="${p}" font-style="italic" fill="var(--_m)"`),t+=n.height;t+=ue-R;for(let s of e.badges)t+=R,a+=`<g class="pele-node${s.overflow?` pele-cynefin-overflow`:``}"${s.overflow?``:` data-id="${n(s.text)}"`}><rect x="${o(e.cx-s.w/2)}" y="${o(t)}" width="${o(s.w)}" height="${o(s.h)}" fill="var(--_bg)" stroke="var(--_b)"${s.overflow?` stroke-dasharray="3 2"`:``}${i}/>`+r(s.label,e.cx,t+s.h/2,` class="pele-label" font-size="${m}"${s.overflow?` fill="var(--_m)"`:``}`,ee)+`</g>`,t+=s.h;return`<g class="pele-cynefin-domain" data-id="${e.name}">${a}</g>`},$=new Map,be=``;I.forEach(([e,t,n],r)=>{let i=C[r];i.cx=U+D*(t+.5),i.cy=W+O*(n+.5),$.set(e,i),be+=ye(i)}),w.cx=G,w.cy=K,$.set(`confusion`,w),be+=ye(w);let xe=(e,t,n)=>e===w?((t-G)/(T+4))**2+((n-K)/(E+4))**2<=1:Math.abs(t-e.cx)<=e.w/2+8&&Math.abs(n-e.cy)<=e.h/2+8,Se=``,Ce=new Map;for(let e of l.transitions){let t=$.get(e.from),n=$.get(e.to);if(!t||!n||t===n)continue;let i=e.from<e.to?`${e.from} ${e.to}`:`${e.to} ${e.from}`,l=Ce.get(i)??0;Ce.set(i,l+1);let u=n.cx-t.cx,d=n.cy-t.cy,f=Math.hypot(u,d)||1,m=(t.cx+n.cx)/2,g=(t.cy+n.cy)/2,_=-d*(m-G)+u*(g-K)>=0?1:-1,v=-d/f*_,y=u/f*_,b=(t!==w&&n!==w&&Math.abs(u)>1&&Math.abs(d)>1?2*(Math.hypot(T*v,E*y)+16):f*.15)+l*56,x=m+v*b,S=g+y*b,C=e=>{let r=1-e;return[r*r*t.cx+2*r*e*x+e*e*n.cx,r*r*t.cy+2*r*e*S+e*e*n.cy]},te=(e,t,n,r)=>{for(let i=0;i<16;i++){let i=(t+n)/2;xe(e,...C(i))===r?t=i:n=i}return(t+n)/2},D=1;for(;D<=48&&xe(t,...C(D/48));)D++;if(D>48)continue;let O=te(t,(D-1)/48,D/48,!0);for(;D<=48&&!xe(n,...C(D/48));)D++;let k=D>48?1:te(n,(D-1)/48,D/48,!1),[ne,re]=C(O),[A,j]=C(k),ie=(e,t,n)=>(1-O)*(1-k)*e+((1-O)*k+O*(1-k))*t+O*k*n,M=ie(t.cx,x,n.cx),N=ie(t.cy,S,n.cy),P=Math.hypot(A-M,j-N)||1,F=(A-M)/P,I=(j-N)/P,ae=c(`arrow_point`,A,j,F,I,`var(--_l)`);A-=F*s(`arrow_point`),j-=I*s(`arrow_point`);let L=``;if(e.label){let t=a(e.label,!1,h,p,se),[n,i]=C((O+k)/2),o=Math.abs(v)*t.width/2+Math.abs(y)*t.height/2+6,s=t.width/2+4,c=Math.min(Math.max(n+v*o,U+s),Math.max(q-s,U+s));L=r(t,c,i+y*o,` class="pele-edge-label" font-size="${p}"`,ee)}Se+=`<g class="pele-edge" data-id="${e.from}-${e.to}"><path d="M${o(ne)},${o(re)}Q${o(M)},${o(N)} ${o(A)},${o(j)}" fill="none" stroke="var(--_l)"/>`+ae+L+`</g>`}let we=Math.ceil(Math.max(H,k.width)+2*g),Te=Math.ceil(fe+V+2*g),Ee=r(k,U+H/2,g+k.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g class="pele-cynefin-regions">${he}</g>`+ge+ve+be+(Se?`<g class="pele-edges">${Se}</g>`:``);return{svg:e(`cynefin`,we,Te,f,d,l,Ee),width:we,height:Te,links:[]}}var H={type:`cynefin`,parse:(e,t,n)=>T(D(e),n),render:V};export{H as cynefin};
|