slateboard 0.1.0 → 0.1.2
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/README.md +33 -192
- package/dist/arch-3JZTL2DJ.js +1842 -0
- package/dist/bin.js +93 -17
- package/dist/{chunk-ONZFKR4I.js → chunk-6CR2V7P7.js} +172 -22
- package/dist/chunk-6YTKJKSG.js +129 -0
- package/dist/{chunk-SQHGMBUM.js → chunk-KA7Z72FC.js} +3 -2
- package/dist/{chunk-WXM4BB4D.js → chunk-OJOVDYIZ.js} +1400 -873
- package/dist/{chunk-BWNUX4FT.js → chunk-WREOGLK6.js} +4 -4
- package/dist/{chunk-FMO5B2KJ.js → chunk-ZCFHR5VG.js} +5 -5
- package/dist/{client-JHI2EG6J.js → client-BFKANUSM.js} +4 -4
- package/dist/{commands-ONES545N.js → commands-IB76RJGP.js} +1 -1
- package/dist/{doctor-H5Y5L2JZ.js → doctor-RPN73UNG.js} +3 -3
- package/dist/{hooks-2TI5OLAU.js → hooks-QJ4XG42C.js} +13 -1
- package/dist/{lifecycle-ZB5HEO5P.js → lifecycle-O7LDC735.js} +4 -4
- package/dist/{service-command-26BPMBK3.js → service-command-WG4TAU2T.js} +5 -5
- package/dist/shipped-7D2LNTAK.js +153 -0
- package/dist/{src-QZIVUACM.js → src-2MHSOXLY.js} +12 -2
- package/dist/{src-YVFB3ZLM.js → src-QB7VJHQH.js} +21 -1
- package/dist/ui/assets/abnfDiagram-XWFEHMT6-DAC8TnbO.js +1 -0
- package/dist/ui/assets/architecture-WOLXFQ4H-X8k0-LVf.js +1 -0
- package/dist/ui/assets/architectureDiagram-CSQXQB3N-CVoxvA0s.js +36 -0
- package/dist/ui/assets/blockDiagram-BEDRHYPZ-DGf5VAwB.js +140 -0
- package/dist/ui/assets/bpmnIcons-APHXDYXF-C0jbCElo.js +1 -0
- package/dist/ui/assets/c4Diagram-M2UUVUY5-PB5quCOl.js +38 -0
- package/dist/ui/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/dist/ui/assets/chunk-3GCGMST5-RRiusQp9.js +1 -0
- package/dist/ui/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- package/dist/ui/assets/chunk-7U7NFRK5-CSOOpKZT.js +88 -0
- package/dist/ui/assets/chunk-CNRTWJTD-DJuDnaYn.js +1 -0
- package/dist/ui/assets/chunk-D5HYT7QG-imLQxbAy.js +1 -0
- package/dist/ui/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
- package/dist/ui/assets/chunk-DZSZGQHW-BCXsfFfT.js +1 -0
- package/dist/ui/assets/chunk-EBZ3SEQC-CdDips7b.js +2 -0
- package/dist/ui/assets/chunk-F3AE6A5H-DTVcMSk7.js +1 -0
- package/dist/ui/assets/chunk-FGVZ23HU-BEVs0fgA.js +213 -0
- package/dist/ui/assets/chunk-GZTWQ64R-CKGVWw4I.js +62 -0
- package/dist/ui/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
- package/dist/ui/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/dist/ui/assets/chunk-KTR4FSNJ-DSr3q0Xy.js +1 -0
- package/dist/ui/assets/chunk-MDAHDJXZ-YMIkXJ0O.js +10 -0
- package/dist/ui/assets/chunk-MPYPSXSE-C-CxVwa7.js +1 -0
- package/dist/ui/assets/chunk-ND7LMLKX-lfusdDHU.js +72 -0
- package/dist/ui/assets/chunk-NGNAAXSQ-DqoPQk1a.js +136 -0
- package/dist/ui/assets/chunk-OWCVCYLK-4-W-ynqW.js +2 -0
- package/dist/ui/assets/chunk-QDWOWVBQ-Du0KmhW4.js +129 -0
- package/dist/ui/assets/chunk-T47YP6PS-CKli33QU.js +1 -0
- package/dist/ui/assets/chunk-XXDRQBXY-DSL17ZTh.js +1 -0
- package/dist/ui/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/dist/ui/assets/classDiagram-v2-KXABOMEV-CYc2BZ2y.js +217 -0
- package/dist/ui/assets/cose-bilkent-JH36ORCC-81nUs0at.js +1 -0
- package/dist/ui/assets/cynefin-EF2NZ3EQ-Clvwy422.js +1 -0
- package/dist/ui/assets/cynefinDiagram-NJNITYFG-CsgTQqAC.js +62 -0
- package/dist/ui/assets/cytoscape.esm-BPveszXl.js +321 -0
- package/dist/ui/assets/d3-scale-lXtN6-Od.js +1 -0
- package/dist/ui/assets/d3-selection-BFzs9NTX.js +1 -0
- package/dist/ui/assets/dagre-KIHZ2IZ3--BpWd3hW.js +4 -0
- package/dist/ui/assets/diagram-7YQZDPLS-Dp_m-C1a.js +41 -0
- package/dist/ui/assets/diagram-QBROCOUO-Bt-Lp7vq.js +200 -0
- package/dist/ui/assets/diagram-RJJCUUZO-DLsG2Tej.js +30 -0
- package/dist/ui/assets/diagram-WERXNKYE-D31SLp70.js +24 -0
- package/dist/ui/assets/diagram-YHHI257C-CVMeUILe.js +3 -0
- package/dist/ui/assets/diagram-YR4HJLHV-Bz9qvIhJ.js +24 -0
- package/dist/ui/assets/dist-YCovsM_S.js +1 -0
- package/dist/ui/assets/ebnfDiagram-N527522P-_FIZSf8P.js +1 -0
- package/dist/ui/assets/elk-O5DQBFGD-BK3qD3UW.js +27 -0
- package/dist/ui/assets/erDiagram-K3K3BIDK-Dmpdi5Ob.js +99 -0
- package/dist/ui/assets/eventmodeling-K75KTNOO-Dt-51L4s.js +1 -0
- package/dist/ui/assets/flowDiagram-Z6JWZHQI-Cn2ZVzvO.js +1 -0
- package/dist/ui/assets/ganttDiagram-3PRQTZWP-BaZof7eT.js +292 -0
- package/dist/ui/assets/gitGraph-VSP46ZUC-ezyaB0jQ.js +1 -0
- package/dist/ui/assets/gitGraphDiagram-VXDFKS5L-DRNdClPw.js +106 -0
- package/dist/ui/assets/graphlib-DS17s2tU.js +1 -0
- package/dist/ui/assets/grid-E2QIVN74--djCUwdI.js +1 -0
- package/dist/ui/assets/index-Bly281F6.css +1 -0
- package/dist/ui/assets/index-CXK8WmR8.js +45 -0
- package/dist/ui/assets/info-OHQRW6UA-DsFXrFWI.js +1 -0
- package/dist/ui/assets/infoDiagram-EZ3ZOAHP-e8qx3eqc.js +2 -0
- package/dist/ui/assets/ishikawaDiagram-S3EKX5GW-CuKExPKN.js +70 -0
- package/dist/ui/assets/journeyDiagram-POQNLL5X-D0GE8iji.js +139 -0
- package/dist/ui/assets/kanban-definition-BH5XI6FM-NL5dOF_0.js +89 -0
- package/dist/ui/assets/katex-BXIx1Jgr.js +257 -0
- package/dist/ui/assets/mermaid-parser.core-0pE4JCc_.js +7 -0
- package/dist/ui/assets/mermaid.core-BVgUieVU.js +44 -0
- package/dist/ui/assets/mindmap-definition-WVAN44T4-BLTtjuVH.js +98 -0
- package/dist/ui/assets/packet-JDAUHWVQ-C-7DeilZ.js +1 -0
- package/dist/ui/assets/pegDiagram-D4NLKWP3-F2SSXiqv.js +1 -0
- package/dist/ui/assets/pie-XZMESJXO-B4BkiWTy.js +1 -0
- package/dist/ui/assets/pieDiagram-36ENHN4W-BB5uEdtB.js +39 -0
- package/dist/ui/assets/quadrantDiagram-ZQUDMS73-B5iPooYO.js +7 -0
- package/dist/ui/assets/radar-ABXABTNO-Dx3jkQdr.js +1 -0
- package/dist/ui/assets/railroad-I3PHUGI6-BSh47OT_.js +1 -0
- package/dist/ui/assets/railroad-abnf-LNEFI6M7-BWFvDxOj.js +1 -0
- package/dist/ui/assets/railroad-ebnf-DWYD2UWJ-GBoLzumA.js +1 -0
- package/dist/ui/assets/railroad-peg-JR7BVNR7-DByw5Orh.js +1 -0
- package/dist/ui/assets/railroadDiagram-JIZHGYPL--ptGd2NR.js +1 -0
- package/dist/ui/assets/render-VIF2ZAQL-CzNp-J42.js +2 -0
- package/dist/ui/assets/requirementDiagram-AXW2TVFA-DBh9Dt63.js +84 -0
- package/dist/ui/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/dist/ui/assets/sankeyDiagram-FBCJTAIF-CjJtGyu8.js +40 -0
- package/dist/ui/assets/sequenceDiagram-3LA2ROMG-BzeMVuzG.js +169 -0
- package/dist/ui/assets/sizeCapture-2Q2CQKSF-DSY_W0YL.js +1 -0
- package/dist/ui/assets/stateDiagram-v2-ATKHQDJO-DYavre2v.js +291 -0
- package/dist/ui/assets/swimlanes-YQL5WMAO-CUTCsfPM.js +1 -0
- package/dist/ui/assets/swimlanesDiagram-UCCPES4V-B7bXxKVr.js +8 -0
- package/dist/ui/assets/timeline-definition-7Z437IG3-HWrtH0QT.js +120 -0
- package/dist/ui/assets/treeView-D4JQ5SDB-B5lbyI_M.js +1 -0
- package/dist/ui/assets/treemap-SAJKECNS-Ckfi-DGc.js +1 -0
- package/dist/ui/assets/usecaseDiagram-RDK6N6HP-BuKN2NAW.js +328 -0
- package/dist/ui/assets/vennDiagram-SHRQU5PJ-s2gljkjP.js +34 -0
- package/dist/ui/assets/wardley-7MLQ67FV-CjAqYBcP.js +1 -0
- package/dist/ui/assets/wardleyDiagram-F3OXNVQS-Ba_SoMTx.js +78 -0
- package/dist/ui/assets/xychartDiagram-GDYJKCDI-FsxUUoqL.js +7 -0
- package/dist/ui/index.html +2 -2
- package/dist/{upgrade-FND3UBJR.js → upgrade-M6TR3IBW.js} +15 -15
- package/migrations/0006_arch_auto.sql +8 -0
- package/package.json +1 -1
- package/dist/chunk-3ZLMW2RI.js +0 -74
- package/dist/ui/assets/index-4WzXlYHs.css +0 -1
- package/dist/ui/assets/index-ZKfByx7Q.js +0 -42
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import{n as e}from"./mermaid-parser.core-0pE4JCc_.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{n,t as r}from"./d3-selection-BFzs9NTX.js";import{C as i,G as a,Q as o,W as s,Y as c,_ as l,a as u,b as d,f,s as p,v as m,y as h}from"./chunk-QDWOWVBQ-Du0KmhW4.js";import{t as g}from"./chunk-JWPE2WC7-DVXcaiue.js";import{_,h as v,i as y}from"./chunk-OWCVCYLK-4-W-ynqW.js";import{t as b}from"./chunk-2Q5K7J3B-C1jixKkw.js";var x={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},ee=f.gitGraph,S=t(()=>y({...ee,...h().gitGraph}),`getConfig`),C=new b(()=>{let e=S(),t=e.mainBranchName,n=e.mainBranchOrder;return{mainBranchName:t,commits:new Map,head:null,branchConfig:new Map([[t,{name:t,order:n}]]),branches:new Map([[t,null]]),currBranch:t,direction:`LR`,seq:0,options:{}}});function w(){return v({length:7})}t(w,`getID`);function T(e,t){let n=Object.create(null);return e.reduce((e,r)=>{let i=t(r);return n[i]||(n[i]=!0,e.push(r)),e},[])}t(T,`uniqBy`);var te=t(function(e){C.records.direction=e},`setDirection`),ne=t(function(e){n.debug(`options str`,e),e=e?.trim(),e||=`{}`;try{C.records.options=JSON.parse(e)}catch(e){n.error(`error while parsing gitGraph options`,e.message)}},`setOptions`),re=t(function(){return C.records.options},`getOptions`),ie=t(function(e){let t=e.msg,r=e.id,i=e.type,a=e.tags;n.info(`commit`,t,r,i,a),n.debug(`Entering commit:`,t,r,i,a);let o=S();r=p.sanitizeText(r,o),t=p.sanitizeText(t,o),a=a?.map(e=>p.sanitizeText(e,o));let s={id:r||C.records.seq+`-`+w(),message:t,seq:C.records.seq++,type:i??x.NORMAL,tags:a??[],parents:C.records.head==null?[]:[C.records.head.id],branch:C.records.currBranch};C.records.head=s,n.info(`main branch`,o.mainBranchName),C.records.commits.has(s.id)&&n.warn(`Commit ID ${s.id} already exists`),C.records.commits.set(s.id,s),C.records.branches.set(C.records.currBranch,s.id),n.debug(`in pushCommit `+s.id)},`commit`),ae=t(function(e){let t=e.name,r=e.order;if(t=p.sanitizeText(t,S()),C.records.branches.has(t))throw Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${t}")`);C.records.branches.set(t,C.records.head==null?null:C.records.head.id),C.records.branchConfig.set(t,{name:t,order:r}),E(t),n.debug(`in createBranch`)},`branch`),oe=t(e=>{let t=e.branch,r=e.id,i=e.type,a=e.tags,o=S();t=p.sanitizeText(t,o),r&&=p.sanitizeText(r,o);let s=C.records.branches.get(C.records.currBranch),c=C.records.branches.get(t),l=s?C.records.commits.get(s):void 0,u=c?C.records.commits.get(c):void 0;if(l&&u&&l.branch===t)throw Error(`Cannot merge branch '${t}' into itself.`);if(C.records.currBranch===t){let e=Error(`Incorrect usage of "merge". Cannot merge a branch to itself`);throw e.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`branch abc`]},e}if(l===void 0||!l){let e=Error(`Incorrect usage of "merge". Current branch (${C.records.currBranch})has no commits`);throw e.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`commit`]},e}if(!C.records.branches.has(t)){let e=Error(`Incorrect usage of "merge". Branch to be merged (`+t+`) does not exist`);throw e.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`branch ${t}`]},e}if(u===void 0||!u){let e=Error(`Incorrect usage of "merge". Branch to be merged (`+t+`) has no commits`);throw e.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`"commit"`]},e}if(l===u){let e=Error(`Incorrect usage of "merge". Both branches have same head`);throw e.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`branch abc`]},e}if(r&&C.records.commits.has(r)){let e=Error(`Incorrect usage of "merge". Commit with id:`+r+` already exists, use different custom id`);throw e.hash={text:`merge ${t} ${r} ${i} ${a?.join(` `)}`,token:`merge ${t} ${r} ${i} ${a?.join(` `)}`,expected:[`merge ${t} ${r}_UNIQUE ${i} ${a?.join(` `)}`]},e}let d=c||``,f={id:r||`${C.records.seq}-${w()}`,message:`merged branch ${t} into ${C.records.currBranch}`,seq:C.records.seq++,parents:C.records.head==null?[]:[C.records.head.id,d],branch:C.records.currBranch,type:x.MERGE,customType:i,customId:!!r,tags:a??[]};C.records.head=f,C.records.commits.set(f.id,f),C.records.branches.set(C.records.currBranch,f.id),n.debug(C.records.branches),n.debug(`in mergeBranch`)},`merge`),se=t(function(e){let t=e.id,r=e.targetId,i=e.tags,a=e.parent;n.debug(`Entering cherryPick:`,t,r,i);let o=S();if(t=p.sanitizeText(t,o),r=p.sanitizeText(r,o),i=i?.map(e=>p.sanitizeText(e,o)),a=p.sanitizeText(a,o),!t||!C.records.commits.has(t)){let e=Error(`Incorrect usage of "cherryPick". Source commit id should exist and provided`);throw e.hash={text:`cherryPick ${t} ${r}`,token:`cherryPick ${t} ${r}`,expected:[`cherry-pick abc`]},e}let s=C.records.commits.get(t);if(s===void 0||!s)throw Error(`Incorrect usage of "cherryPick". Source commit id should exist and provided`);if(a&&!(Array.isArray(s.parents)&&s.parents.includes(a)))throw Error(`Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.`);let c=s.branch;if(s.type===x.MERGE&&!a)throw Error(`Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.`);if(!r||!C.records.commits.has(r)){if(c===C.records.currBranch){let e=Error(`Incorrect usage of "cherryPick". Source commit is already on current branch`);throw e.hash={text:`cherryPick ${t} ${r}`,token:`cherryPick ${t} ${r}`,expected:[`cherry-pick abc`]},e}let e=C.records.branches.get(C.records.currBranch);if(e===void 0||!e){let e=Error(`Incorrect usage of "cherry-pick". Current branch (${C.records.currBranch})has no commits`);throw e.hash={text:`cherryPick ${t} ${r}`,token:`cherryPick ${t} ${r}`,expected:[`cherry-pick abc`]},e}let o=C.records.commits.get(e);if(o===void 0||!o){let e=Error(`Incorrect usage of "cherry-pick". Current branch (${C.records.currBranch})has no commits`);throw e.hash={text:`cherryPick ${t} ${r}`,token:`cherryPick ${t} ${r}`,expected:[`cherry-pick abc`]},e}let l={id:C.records.seq+`-`+w(),message:`cherry-picked ${s?.message} into ${C.records.currBranch}`,seq:C.records.seq++,parents:C.records.head==null?[]:[C.records.head.id,s.id],branch:C.records.currBranch,type:x.CHERRY_PICK,tags:i?i.filter(Boolean):[`cherry-pick:${s.id}${s.type===x.MERGE?`|parent:${a}`:``}`]};C.records.head=l,C.records.commits.set(l.id,l),C.records.branches.set(C.records.currBranch,l.id),n.debug(C.records.branches),n.debug(`in cherryPick`)}},`cherryPick`),E=t(function(e){if(e=p.sanitizeText(e,S()),C.records.branches.has(e)){C.records.currBranch=e;let t=C.records.branches.get(C.records.currBranch);t===void 0||!t?C.records.head=null:C.records.head=C.records.commits.get(t)??null}else{let t=Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`);throw t.hash={text:`checkout ${e}`,token:`checkout ${e}`,expected:[`branch ${e}`]},t}},`checkout`);function D(e,t,n){let r=e.indexOf(t);r===-1?e.push(n):e.splice(r,1,n)}t(D,`upsert`);function O(e){let t=e.reduce((e,t)=>e.seq>t.seq?e:t,e[0]),r=``;e.forEach(function(e){r+=e===t?` *`:` |`});let i=[r,t.id,t.seq];for(let e in C.records.branches)C.records.branches.get(e)===t.id&&i.push(e);if(n.debug(i.join(` `)),t.parents&&t.parents.length==2&&t.parents[0]&&t.parents[1]){let n=C.records.commits.get(t.parents[0]);D(e,t,n),t.parents[1]&&e.push(C.records.commits.get(t.parents[1]))}else if(t.parents.length==0)return;else if(t.parents[0]){let n=C.records.commits.get(t.parents[0]);D(e,t,n)}e=T(e,e=>e.id),O(e)}t(O,`prettyPrintCommitHistory`);var ce=t(function(){n.debug(C.records.commits);let e=k()[0];O([e])},`prettyPrint`),le=t(function(){C.reset(),u()},`clear`),ue=t(function(){return[...C.records.branchConfig.values()].map((e,t)=>e.order!==null&&e.order!==void 0?e:{...e,order:parseFloat(`0.${t}`)}).sort((e,t)=>(e.order??0)-(t.order??0)).map(({name:e})=>({name:e}))},`getBranchesAsObjArray`),de=t(function(){return C.records.branches},`getBranches`),fe=t(function(){return C.records.commits},`getCommits`),k=t(function(){let e=[...C.records.commits.values()];return e.forEach(function(e){n.debug(e.id)}),e.sort((e,t)=>e.seq-t.seq),e},`getCommitsArray`),A={commitType:x,getConfig:S,setDirection:te,setOptions:ne,getOptions:re,commit:ie,branch:ae,merge:oe,cherryPick:se,checkout:E,prettyPrint:ce,clear:le,getBranchesAsObjArray:ue,getBranches:de,getCommits:fe,getCommitsArray:k,getCurrentBranch:t(function(){return C.records.currBranch},`getCurrentBranch`),getDirection:t(function(){return C.records.direction},`getDirection`),getHead:t(function(){return C.records.head},`getHead`),setAccTitle:a,getAccTitle:m,getAccDescription:l,setAccDescription:s,setDiagramTitle:c,getDiagramTitle:i},pe=t((e,t)=>{g(e,t),e.dir&&t.setDirection(e.dir);for(let n of e.statements)me(n,t)},`populate`),me=t((e,r)=>{let i={Commit:t(e=>r.commit(he(e)),`Commit`),Branch:t(e=>r.branch(ge(e)),`Branch`),Merge:t(e=>r.merge(_e(e)),`Merge`),Checkout:t(e=>r.checkout(ve(e)),`Checkout`),CherryPicking:t(e=>r.cherryPick(ye(e)),`CherryPicking`)}[e.$type];i?i(e):n.error(`Unknown statement type: ${e.$type}`)},`parseStatement`),he=t(e=>({id:e.id,msg:e.message??``,type:e.type===void 0?x.NORMAL:x[e.type],tags:e.tags??void 0}),`parseCommit`),ge=t(e=>({name:e.name,order:e.order??0}),`parseBranch`),_e=t(e=>({branch:e.branch,id:e.id??``,type:e.type===void 0?void 0:x[e.type],tags:e.tags??void 0}),`parseMerge`),ve=t(e=>e.branch,`parseCheckout`),ye=t(e=>({id:e.id,targetId:``,tags:e.tags?.length===0?void 0:e.tags,parent:e.parent}),`parseCherryPicking`),be={parse:t(async t=>{let r=await e(`gitGraph`,t);n.debug(r),pe(r,A)},`parse`)},j=10,M=40,N=4,P=2,F=8,I=new Set([`redux`,`redux-dark`,`redux-color`,`redux-dark-color`]),L=12,R=new Set([`redux-color`,`redux-dark-color`]),xe=new Set([`dark`,`redux-dark`,`redux-dark-color`,`neo-dark`]),z=t((e,t,n=!1)=>n&&e>0?(e-1)%(t-1)+1:e%t,`calcColorIndex`),B=new Map,V=new Map,H=30,U=new Map,W=[],G=0,K=`LR`,q=t(()=>{B.clear(),V.clear(),U.clear(),G=0,W=[],K=`LR`},`clear`),J=t(e=>{let t=document.createElementNS(`http://www.w3.org/2000/svg`,`text`);return(typeof e==`string`?e.split(/\\n|\n|<br\s*\/?>/gi):e).forEach(e=>{let n=document.createElementNS(`http://www.w3.org/2000/svg`,`tspan`);n.setAttributeNS(`http://www.w3.org/XML/1998/namespace`,`xml:space`,`preserve`),n.setAttribute(`dy`,`1em`),n.setAttribute(`x`,`0`),n.setAttribute(`class`,`row`),n.textContent=e.trim(),t.appendChild(n)}),t},`drawText`),Y=t(e=>{let n,r,i;return K===`BT`?(r=t((e,t)=>e<=t,`comparisonFunc`),i=1/0):(r=t((e,t)=>e>=t,`comparisonFunc`),i=0),e.forEach(e=>{let t=K===`TB`||K==`BT`?V.get(e)?.y:V.get(e)?.x;t!==void 0&&r(t,i)&&(n=e,i=t)}),n},`findClosestParent`),Se=t(e=>{let t=``,n=1/0;return e.forEach(e=>{let r=V.get(e).y;r<=n&&(t=e,n=r)}),t||void 0},`findClosestParentBT`),Ce=t((e,t,n)=>{let r=n,i=n,a=[];e.forEach(e=>{let n=t.get(e);if(!n)throw Error(`Commit not found for key ${e}`);n.parents.length?(r=Te(n),i=Math.max(r,i)):a.push(n),Ee(n,r)}),r=i,a.forEach(e=>{De(e,r,n)}),e.forEach(e=>{let n=t.get(e);if(n?.parents.length){let e=Se(n.parents);r=V.get(e).y-M,r<=i&&(i=r);let t=B.get(n.branch).pos,a=r-j;V.set(n.id,{x:t,y:a})}})},`setParallelBTPos`),we=t(e=>{let t=Y(e.parents.filter(e=>e!==null));if(!t)throw Error(`Closest parent not found for commit ${e.id}`);let n=V.get(t)?.y;if(n===void 0)throw Error(`Closest parent position not found for commit ${e.id}`);return n},`findClosestParentPos`),Te=t(e=>we(e)+M,`calculateCommitPosition`),Ee=t((e,t)=>{let n=B.get(e.branch);if(!n)throw Error(`Branch not found for commit ${e.id}`);let r=n.pos,i=t+j;return V.set(e.id,{x:r,y:i}),{x:r,y:i}},`setCommitPosition`),De=t((e,t,n)=>{let r=B.get(e.branch);if(!r)throw Error(`Branch not found for commit ${e.id}`);let i=t+n,a=r.pos;V.set(e.id,{x:a,y:i})},`setRootPosition`),Oe=t((e,t,n,r,i,a)=>{let{theme:o}=d(),s=I.has(o??``),c=R.has(o??``),l=xe.has(o??``);if(a===x.HIGHLIGHT)e.append(`rect`).attr(`x`,n.x-10+(s?3:0)).attr(`y`,n.y-10+(s?3:0)).attr(`width`,s?14:20).attr(`height`,s?14:20).attr(`class`,`commit ${t.id} commit-highlight${z(i,F,c)} ${r}-outer`),e.append(`rect`).attr(`x`,n.x-6+(s?2:0)).attr(`y`,n.y-6+(s?2:0)).attr(`width`,s?8:12).attr(`height`,s?8:12).attr(`class`,`commit ${t.id} commit${z(i,F,c)} ${r}-inner`);else if(a===x.CHERRY_PICK)e.append(`circle`).attr(`cx`,n.x).attr(`cy`,n.y).attr(`r`,s?7:10).attr(`class`,`commit ${t.id} ${r}`),e.append(`circle`).attr(`cx`,n.x-3).attr(`cy`,n.y+2).attr(`r`,s?2.5:2.75).attr(`fill`,l?`#000000`:`#fff`).attr(`class`,`commit ${t.id} ${r}`),e.append(`circle`).attr(`cx`,n.x+3).attr(`cy`,n.y+2).attr(`r`,s?2.5:2.75).attr(`fill`,l?`#000000`:`#fff`).attr(`class`,`commit ${t.id} ${r}`),e.append(`line`).attr(`x1`,n.x+3).attr(`y1`,n.y+1).attr(`x2`,n.x).attr(`y2`,n.y-5).attr(`stroke`,l?`#000000`:`#fff`).attr(`class`,`commit ${t.id} ${r}`),e.append(`line`).attr(`x1`,n.x-3).attr(`y1`,n.y+1).attr(`x2`,n.x).attr(`y2`,n.y-5).attr(`stroke`,l?`#000000`:`#fff`).attr(`class`,`commit ${t.id} ${r}`);else{let o=e.append(`circle`);if(o.attr(`cx`,n.x),o.attr(`cy`,n.y),o.attr(`r`,s?7:10),o.attr(`class`,`commit ${t.id} commit${z(i,F,c)}`),a===x.MERGE){let a=e.append(`circle`);a.attr(`cx`,n.x),a.attr(`cy`,n.y),a.attr(`r`,s?5:6),a.attr(`class`,`commit ${r} ${t.id} commit${z(i,F,c)}`)}if(a===x.REVERSE){let a=e.append(`path`),o=s?4:5;a.attr(`d`,`M ${n.x-o},${n.y-o}L${n.x+o},${n.y+o}M${n.x-o},${n.y+o}L${n.x+o},${n.y-o}`).attr(`class`,`commit ${r} ${t.id} commit${z(i,F,c)}`)}}},`drawCommitBullet`),ke=t((e,t,n,r,i)=>{if(t.type!==x.CHERRY_PICK&&(t.customId&&t.type===x.MERGE||t.type!==x.MERGE)&&i.showCommitLabel){let a=e.append(`g`),o=a.insert(`rect`).attr(`class`,`commit-label-bkg`),s=a.append(`text`).attr(`x`,r).attr(`y`,n.y+25).attr(`class`,`commit-label`).text(t.id),c=s.node()?.getBBox();if(c&&(o.attr(`x`,n.posWithOffset-c.width/2-P).attr(`y`,n.y+13.5).attr(`width`,c.width+2*P).attr(`height`,c.height+2*P),K===`TB`||K===`BT`?(o.attr(`x`,n.x-(c.width+4*N+5)).attr(`y`,n.y-12),s.attr(`x`,n.x-(c.width+4*N)).attr(`y`,n.y+c.height-12)):s.attr(`x`,n.posWithOffset-c.width/2),i.rotateCommitLabel)){if(K===`TB`||K===`BT`)s.attr(`transform`,`rotate(-45, `+n.x+`, `+n.y+`)`),o.attr(`transform`,`rotate(-45, `+n.x+`, `+n.y+`)`);else{let e=-7.5-(c.width+10)/25*9.5,t=10+c.width/25*8.5;a.attr(`transform`,`translate(`+e+`, `+t+`) rotate(-45, `+r+`, `+n.y+`)`)}}}},`drawCommitLabel`),Ae=t((e,t,n,r)=>{if(t.tags.length>0){let i=0,a=0,o=0,s=[];for(let r of t.tags.reverse()){let t=e.insert(`polygon`),c=e.append(`circle`),l=e.append(`text`).attr(`y`,n.y-16-i).attr(`class`,`tag-label`).text(r),u=l.node()?.getBBox();if(!u)throw Error(`Tag bbox not found`);a=Math.max(a,u.width),o=Math.max(o,u.height),l.attr(`x`,n.posWithOffset-u.width/2),s.push({tag:l,hole:c,rect:t,yOffset:i}),i+=20}for(let{tag:e,hole:t,rect:i,yOffset:c}of s){let s=o/2,l=n.y-19.2-c;if(i.attr(`class`,`tag-label-bkg`).attr(`points`,`
|
|
2
|
+
${r-a/2-N/2},${l+P}
|
|
3
|
+
${r-a/2-N/2},${l-P}
|
|
4
|
+
${n.posWithOffset-a/2-N},${l-s-P}
|
|
5
|
+
${n.posWithOffset+a/2+N},${l-s-P}
|
|
6
|
+
${n.posWithOffset+a/2+N},${l+s+P}
|
|
7
|
+
${n.posWithOffset-a/2-N},${l+s+P}`),t.attr(`cy`,l).attr(`cx`,r-a/2+N/2).attr(`r`,1.5).attr(`class`,`tag-hole`),K===`TB`||K===`BT`){let o=r+c;i.attr(`class`,`tag-label-bkg`).attr(`points`,`
|
|
8
|
+
${n.x},${o+2}
|
|
9
|
+
${n.x},${o-2}
|
|
10
|
+
${n.x+j},${o-s-2}
|
|
11
|
+
${n.x+j+a+4},${o-s-2}
|
|
12
|
+
${n.x+j+a+4},${o+s+2}
|
|
13
|
+
${n.x+j},${o+s+2}`).attr(`transform`,`translate(12,12) rotate(45, `+n.x+`,`+r+`)`),t.attr(`cx`,n.x+N/2).attr(`cy`,o).attr(`transform`,`translate(12,12) rotate(45, `+n.x+`,`+r+`)`),e.attr(`x`,n.x+5).attr(`y`,o+3).attr(`transform`,`translate(14,14) rotate(45, `+n.x+`,`+r+`)`)}}}},`drawCommitTags`),je=t(e=>{switch(e.customType??e.type){case x.NORMAL:return`commit-normal`;case x.REVERSE:return`commit-reverse`;case x.HIGHLIGHT:return`commit-highlight`;case x.MERGE:return`commit-merge`;case x.CHERRY_PICK:return`commit-cherry-pick`;default:return`commit-normal`}},`getCommitClassType`),Me=t((e,t,n,r)=>{let i={x:0,y:0};if(e.parents.length>0){let n=Y(e.parents);if(n){let a=r.get(n)??i;return t===`TB`?a.y+M:t===`BT`?(r.get(e.id)??i).y-M:a.x+M}}else if(t===`TB`)return H;else if(t===`BT`)return(r.get(e.id)??i).y-M;else return 0;return 0},`calculatePosition`),Ne=t((e,t,n)=>{let r=K===`BT`&&n?t:t+j,i=B.get(e.branch)?.pos,a=K===`TB`||K===`BT`?B.get(e.branch)?.pos:r;if(a===void 0||i===void 0)throw Error(`Position were undefined for commit ${e.id}`);let o=I.has(d().theme??``);return{x:a,y:K===`TB`||K===`BT`?r:i+(o?L/2+1:-2),posWithOffset:r}},`getCommitPosition`),X=t((e,n,r,i)=>{let a=e.append(`g`).attr(`class`,`commit-bullets`),o=e.append(`g`).attr(`class`,`commit-labels`),s=K===`TB`||K===`BT`?H:0,c=[...n.keys()],l=i.parallelCommits??!1,u=t((e,t)=>{let r=n.get(e)?.seq,i=n.get(t)?.seq;return r!==void 0&&i!==void 0?r-i:0},`sortKeys`),d=c.sort(u);K===`BT`&&(l&&Ce(d,n,s),d=d.reverse()),d.forEach(e=>{let t=n.get(e);if(!t)throw Error(`Commit not found for key ${e}`);l&&(s=Me(t,K,s,V));let c=Ne(t,s,l);if(r){let e=je(t),n=t.customType??t.type,r=B.get(t.branch)?.index??0;Oe(a,t,c,e,r,n),ke(o,t,c,s,i),Ae(o,t,c,s)}K===`TB`||K===`BT`?V.set(t.id,{x:c.x,y:c.posWithOffset}):V.set(t.id,{x:c.posWithOffset,y:c.y}),s=K===`BT`&&l?s+M:s+M+j,s>G&&(G=s)})},`drawCommits`),Pe=t((e,n,r,i,a)=>{let o=(K===`TB`||K===`BT`?r.x<i.x:r.y<i.y)?n.branch:e.branch,s=t(e=>e.branch===o,`isOnBranchToGetCurve`),c=t(t=>t.seq>e.seq&&t.seq<n.seq,`isBetweenCommits`);return[...a.values()].some(e=>c(e)&&s(e))},`shouldRerouteArrow`),Z=t((e,t,n=0)=>{let r=e+Math.abs(e-t)/2;return n>5?r:W.every(e=>Math.abs(e-r)>=10)?(W.push(r),r):Z(e,t-Math.abs(e-t)/5,n+1)},`findLane`),Fe=t((e,t,n,r)=>{let{theme:i}=d(),a=R.has(i??``),o=V.get(t.id),s=V.get(n.id);if(o===void 0||s===void 0)throw Error(`Commit positions not found for commits ${t.id} and ${n.id}`);let c=Pe(t,n,o,s,r),l=``,u=``,f=0,p=0,m=B.get(n.branch)?.index;n.type===x.MERGE&&t.id!==n.parents[0]&&(m=B.get(t.branch)?.index);let h;if(c){l=`A 10 10, 0, 0, 0,`,u=`A 10 10, 0, 0, 1,`,f=10,p=10;let e=o.y<s.y?Z(o.y,s.y):Z(s.y,o.y),n=o.x<s.x?Z(o.x,s.x):Z(s.x,o.x);K===`TB`?o.x<s.x?h=`M ${o.x} ${o.y} L ${n-f} ${o.y} ${u} ${n} ${o.y+p} L ${n} ${s.y-f} ${l} ${n+p} ${s.y} L ${s.x} ${s.y}`:(m=B.get(t.branch)?.index,h=`M ${o.x} ${o.y} L ${n+f} ${o.y} ${l} ${n} ${o.y+p} L ${n} ${s.y-f} ${u} ${n-p} ${s.y} L ${s.x} ${s.y}`):K===`BT`?o.x<s.x?h=`M ${o.x} ${o.y} L ${n-f} ${o.y} ${l} ${n} ${o.y-p} L ${n} ${s.y+f} ${u} ${n+p} ${s.y} L ${s.x} ${s.y}`:(m=B.get(t.branch)?.index,h=`M ${o.x} ${o.y} L ${n+f} ${o.y} ${u} ${n} ${o.y-p} L ${n} ${s.y+f} ${l} ${n-p} ${s.y} L ${s.x} ${s.y}`):o.y<s.y?h=`M ${o.x} ${o.y} L ${o.x} ${e-f} ${l} ${o.x+p} ${e} L ${s.x-f} ${e} ${u} ${s.x} ${e+p} L ${s.x} ${s.y}`:(m=B.get(t.branch)?.index,h=`M ${o.x} ${o.y} L ${o.x} ${e+f} ${u} ${o.x+p} ${e} L ${s.x-f} ${e} ${l} ${s.x} ${e-p} L ${s.x} ${s.y}`)}else l=`A 20 20, 0, 0, 0,`,u=`A 20 20, 0, 0, 1,`,f=20,p=20,K===`TB`?(o.x<s.x&&(h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${s.y-f} ${l} ${o.x+p} ${s.y} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${s.x-f} ${o.y} ${u} ${s.x} ${o.y+p} L ${s.x} ${s.y}`),o.x>s.x&&(l=`A 20 20, 0, 0, 0,`,u=`A 20 20, 0, 0, 1,`,f=20,p=20,h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${s.y-f} ${u} ${o.x-p} ${s.y} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${s.x+f} ${o.y} ${l} ${s.x} ${o.y+p} L ${s.x} ${s.y}`),o.x===s.x&&(h=`M ${o.x} ${o.y} L ${s.x} ${s.y}`)):K===`BT`?(o.x<s.x&&(h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${s.y+f} ${u} ${o.x+p} ${s.y} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${s.x-f} ${o.y} ${l} ${s.x} ${o.y-p} L ${s.x} ${s.y}`),o.x>s.x&&(l=`A 20 20, 0, 0, 0,`,u=`A 20 20, 0, 0, 1,`,f=20,p=20,h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${s.y+f} ${l} ${o.x-p} ${s.y} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${s.x+f} ${o.y} ${u} ${s.x} ${o.y-p} L ${s.x} ${s.y}`),o.x===s.x&&(h=`M ${o.x} ${o.y} L ${s.x} ${s.y}`)):(o.y<s.y&&(h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${s.x-f} ${o.y} ${u} ${s.x} ${o.y+p} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${o.x} ${s.y-f} ${l} ${o.x+p} ${s.y} L ${s.x} ${s.y}`),o.y>s.y&&(h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${s.x-f} ${o.y} ${l} ${s.x} ${o.y-p} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${o.x} ${s.y+f} ${u} ${o.x+p} ${s.y} L ${s.x} ${s.y}`),o.y===s.y&&(h=`M ${o.x} ${o.y} L ${s.x} ${s.y}`));if(h===void 0)throw Error(`Line definition not found`);e.append(`path`).attr(`d`,h).attr(`class`,`arrow arrow`+z(m,F,a))},`drawArrow`),Ie=t((e,t)=>{let n=e.append(`g`).attr(`class`,`commit-arrows`);[...t.keys()].forEach(e=>{let r=t.get(e);r.parents&&r.parents.length>0&&r.parents.forEach(e=>{Fe(n,t.get(e),r,t)})})},`drawArrows`),Le=t((e,t,n,r)=>{let{look:i,theme:a,themeVariables:o}=d(),{dropShadow:s,THEME_COLOR_LIMIT:c}=o,l=I.has(a??``),u=R.has(a??``),f=e.append(`g`);t.forEach((e,t)=>{let a=z(t,l?c:F,u),o=B.get(e.name)?.pos;if(o===void 0)throw Error(`Position not found for branch ${e.name}`);let d=K===`TB`||K===`BT`?o:l?o+L/2+1:o-2,p=f.append(`line`);p.attr(`x1`,0),p.attr(`y1`,d),p.attr(`x2`,G),p.attr(`y2`,d),p.attr(`class`,`branch branch`+a),K===`TB`?(p.attr(`y1`,H),p.attr(`x1`,o),p.attr(`y2`,G),p.attr(`x2`,o)):K===`BT`&&(p.attr(`y1`,G),p.attr(`x1`,o),p.attr(`y2`,H),p.attr(`x2`,o)),W.push(d);let m=e.name,h=J(m),g=f.insert(`rect`),_=f.insert(`g`).attr(`class`,`branchLabel`).insert(`g`).attr(`class`,`label branch-label`+a);_.node().appendChild(h);let v=h.getBBox(),y=l?0:4,b=l?16:0,x=l?L:0;i===`neo`&&g.attr(`data-look`,`neo`),g.attr(`class`,`branchLabelBkg label`+a).attr(`style`,i===`neo`?`filter:${l?`url(#${r}-drop-shadow)`:s}`:``).attr(`rx`,y).attr(`ry`,y).attr(`x`,-v.width-4-(n.rotateCommitLabel===!0?30:0)).attr(`y`,-v.height/2+10).attr(`width`,v.width+18+b).attr(`height`,v.height+4+x),_.attr(`transform`,`translate(`+(-v.width-14-(n.rotateCommitLabel===!0?30:0)+b/2)+`, `+(d-v.height/2-2)+`)`),K===`TB`?(g.attr(`x`,o-v.width/2-10).attr(`y`,0),_.attr(`transform`,`translate(`+(o-v.width/2-5)+`, 0)`),l&&(g.attr(`transform`,`translate(${-b/2-3}, ${-x-10})`),_.attr(`transform`,`translate(`+(o-v.width/2-5)+`, `+(-x*2+7)+`)`))):K===`BT`?(g.attr(`x`,o-v.width/2-10).attr(`y`,G),_.attr(`transform`,`translate(`+(o-v.width/2-5)+`, `+G+`)`),l&&(g.attr(`transform`,`translate(${-b/2-3}, ${x+10})`),_.attr(`transform`,`translate(`+(o-v.width/2-5)+`, `+(G+x*2+4)+`)`))):g.attr(`transform`,`translate(-19, `+(d-12-x/2)+`)`)})},`drawBranches`),Re=t(function(e,t,n,r,i){return B.set(e,{pos:t,index:n}),t+=50+(i?40:0)+(K===`TB`||K===`BT`?r.width/2:0),t},`setBranchPosition`),ze={draw:t(function(e,t,i,a){q(),n.debug(`in gitgraph renderer`,e+`
|
|
14
|
+
`,`id:`,t,i);let s=a.db;if(!s.getConfig){n.error(`getConfig method is not available on db`);return}let c=s.getConfig(),l=c.rotateCommitLabel??!1;U=s.getCommits();let u=s.getBranchesAsObjArray();K=s.getDirection();let f=r(`[id="${t}"]`),{look:p,theme:m,themeVariables:h}=d(),{useGradient:g,gradientStart:v,gradientStop:y,filterColor:b}=h;if(g){let e=f.append(`defs`).append(`linearGradient`).attr(`id`,t+`-gradient`).attr(`gradientUnits`,`objectBoundingBox`).attr(`x1`,`0%`).attr(`y1`,`0%`).attr(`x2`,`100%`).attr(`y2`,`0%`);e.append(`stop`).attr(`offset`,`0%`).attr(`stop-color`,v).attr(`stop-opacity`,1),e.append(`stop`).attr(`offset`,`100%`).attr(`stop-color`,y).attr(`stop-opacity`,1)}p===`neo`&&I.has(m??``)&&f.append(`defs`).append(`filter`).attr(`id`,t+`-drop-shadow`).attr(`height`,`130%`).attr(`width`,`130%`).append(`feDropShadow`).attr(`dx`,`4`).attr(`dy`,`4`).attr(`stdDeviation`,0).attr(`flood-opacity`,`0.06`).attr(`flood-color`,b);let x=0;u.forEach((e,t)=>{let n=J(e.name),r=f.append(`g`),i=r.insert(`g`).attr(`class`,`branchLabel`),a=i.insert(`g`).attr(`class`,`label branch-label`);a.node()?.appendChild(n);let o=n.getBBox();x=Re(e.name,x,t,o,l),a.remove(),i.remove(),r.remove()}),X(f,U,!1,c),c.showBranches&&Le(f,u,c,t),Ie(f,U),X(f,U,!0,c),_.insertTitle(f,`gitTitleText`,c.titleTopMargin??0,s.getDiagramTitle()),o(void 0,f,c.diagramPadding,c.useMaxWidth)},`draw`)},Q=8,$=new Set([`redux`,`redux-dark`,`redux-color`,`redux-dark-color`]),Be=new Set([`redux-color`,`redux-dark-color`]),Ve=new Set([`neo`,`neo-dark`]),He=new Set([`dark`,`redux-dark`,`redux-dark-color`,`neo-dark`]),Ue=new Set([`redux`,`redux-dark`,`redux-color`,`redux-dark-color`,`neo`,`neo-dark`]),We=t(e=>{let{svgId:t}=e,n=``;if(e.useGradient&&t)for(let r=0;r<e.THEME_COLOR_LIMIT;r++)n+=`
|
|
15
|
+
.label${r} { fill: ${e.mainBkg}; stroke: url(${t}-gradient); stroke-width: ${e.strokeWidth};}
|
|
16
|
+
`;return n},`genGitGraphGradient`),Ge=t(e=>{let{theme:t,themeVariables:n}=h(),{borderColorArray:r}=n,i=$.has(t);if(Ve.has(t)){let t=``;for(let n=0;n<e.THEME_COLOR_LIMIT;n++)if(n===0)t+=`
|
|
17
|
+
.branch-label${n} { fill: ${e.nodeBorder};}
|
|
18
|
+
.commit${n} { stroke: ${e.nodeBorder}; }
|
|
19
|
+
.commit-highlight${n} { stroke: ${e.nodeBorder}; fill: ${e.nodeBorder}; }
|
|
20
|
+
.arrow${n} { stroke: ${e.nodeBorder}; }
|
|
21
|
+
.commit-bullets { fill: ${e.nodeBorder}; }
|
|
22
|
+
.commit-cherry-pick${n} { stroke: ${e.nodeBorder}; }
|
|
23
|
+
${We(e)}`;else{let r=n%Q;t+=`
|
|
24
|
+
.branch-label${n} { fill: ${e[`gitBranchLabel`+r]}; }
|
|
25
|
+
.commit${n} { stroke: ${e[`git`+r]}; fill: ${e[`git`+r]}; }
|
|
26
|
+
.commit-highlight${n} { stroke: ${e[`gitInv`+r]}; fill: ${e[`gitInv`+r]}; }
|
|
27
|
+
.arrow${n} { stroke: ${e[`git`+r]}; }
|
|
28
|
+
`}return t}if(Be.has(t)){let n=``;for(let a=0;a<e.THEME_COLOR_LIMIT;a++)if(a===0)n+=`
|
|
29
|
+
.branch-label${a} { fill: ${e.nodeBorder}; ${i?`font-weight:${e.noteFontWeight}`:``} }
|
|
30
|
+
.commit${a} { stroke: ${e.nodeBorder}; }
|
|
31
|
+
.commit-highlight${a} { stroke: ${e.nodeBorder}; fill: ${e.mainBkg}; }
|
|
32
|
+
.label${a} { fill: ${e.mainBkg}; stroke: ${e.nodeBorder}; stroke-width: ${e.strokeWidth}; ${i?`font-weight:${e.noteFontWeight}`:``} }
|
|
33
|
+
.arrow${a} { stroke: ${e.nodeBorder}; }
|
|
34
|
+
.commit-bullets { fill: ${e.nodeBorder}; }
|
|
35
|
+
`;else{let o=a%r.length;n+=`
|
|
36
|
+
.branch-label${a} { fill: ${e.nodeBorder}; ${i?`font-weight:${e.noteFontWeight}`:``} }
|
|
37
|
+
.commit${a} { stroke: ${r[o]}; fill: ${r[o]}; }
|
|
38
|
+
.commit-highlight${a} { stroke: ${r[o]}; fill: ${r[o]}; }
|
|
39
|
+
.label${a} { fill: ${He.has(t)?e.mainBkg:r[o]}; stroke: ${r[o]}; stroke-width: ${e.strokeWidth}; }
|
|
40
|
+
.arrow${a} { stroke: ${r[o]}; }
|
|
41
|
+
`}return n}{let t=``;for(let n=0;n<e.THEME_COLOR_LIMIT;n++)t+=`
|
|
42
|
+
.branch-label${n} { fill: ${e.nodeBorder}; ${i?`font-weight:${e.noteFontWeight}`:``} }
|
|
43
|
+
.commit${n} { stroke: ${e.nodeBorder}; }
|
|
44
|
+
.commit-highlight${n} { stroke: ${e.nodeBorder}; fill: ${e.nodeBorder}; }
|
|
45
|
+
.label${n} { fill: ${e.mainBkg}; stroke: ${e.nodeBorder}; stroke-width: ${e.strokeWidth}; ${i?`font-weight:${e.noteFontWeight}`:``}}
|
|
46
|
+
.arrow${n} { stroke: ${e.nodeBorder}; }
|
|
47
|
+
.commit-bullets { fill: ${e.nodeBorder}; }
|
|
48
|
+
.commit-cherry-pick${n} { stroke: ${e.nodeBorder}; }
|
|
49
|
+
`;return t}},`genColor`),Ke=t(e=>`${Array.from({length:e.THEME_COLOR_LIMIT},(e,t)=>t).map(t=>{let n=t%Q;return`
|
|
50
|
+
.branch-label${t} { fill: ${e[`gitBranchLabel`+n]}; }
|
|
51
|
+
.commit${t} { stroke: ${e[`git`+n]}; fill: ${e[`git`+n]}; }
|
|
52
|
+
.commit-highlight${t} { stroke: ${e[`gitInv`+n]}; fill: ${e[`gitInv`+n]}; }
|
|
53
|
+
.label${t} { fill: ${e[`git`+n]}; }
|
|
54
|
+
.arrow${t} { stroke: ${e[`git`+n]}; }
|
|
55
|
+
`}).join(`
|
|
56
|
+
`)}`,`normalTheme`),qe={parser:be,db:A,renderer:ze,styles:t(e=>{let{theme:t}=h(),n=Ue.has(t);return`
|
|
57
|
+
.commit-id,
|
|
58
|
+
.commit-msg,
|
|
59
|
+
.branch-label {
|
|
60
|
+
fill: lightgrey;
|
|
61
|
+
color: lightgrey;
|
|
62
|
+
font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
|
63
|
+
font-family: var(--mermaid-font-family);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
${n?Ge(e):Ke(e)}
|
|
67
|
+
|
|
68
|
+
.branch {
|
|
69
|
+
stroke-width: ${e.strokeWidth};
|
|
70
|
+
stroke: ${e.commitLineColor??e.lineColor};
|
|
71
|
+
stroke-dasharray: ${n?`4 2`:`2`};
|
|
72
|
+
}
|
|
73
|
+
.commit-label { font-size: ${e.commitLabelFontSize}; fill: ${n?e.nodeBorder:e.commitLabelColor}; ${n?`font-weight:${e.noteFontWeight};`:``}}
|
|
74
|
+
.commit-label-bkg { font-size: ${e.commitLabelFontSize}; fill: ${n?`transparent`:e.commitLabelBackground}; opacity: ${n?``:.5}; }
|
|
75
|
+
.tag-label { font-size: ${e.tagLabelFontSize}; fill: ${e.tagLabelColor};}
|
|
76
|
+
.tag-label-bkg { fill: ${n?e.mainBkg:e.tagLabelBackground}; stroke: ${n?e.nodeBorder:e.tagLabelBorder}; ${n?`filter:${e.dropShadow}`:``} }
|
|
77
|
+
.tag-hole { fill: ${e.textColor}; }
|
|
78
|
+
|
|
79
|
+
.commit-merge {
|
|
80
|
+
stroke: ${n?e.mainBkg:e.primaryColor};
|
|
81
|
+
fill: ${n?e.mainBkg:e.primaryColor};
|
|
82
|
+
}
|
|
83
|
+
.commit-reverse {
|
|
84
|
+
stroke: ${n?e.mainBkg:e.primaryColor};
|
|
85
|
+
fill: ${n?e.mainBkg:e.primaryColor};
|
|
86
|
+
stroke-width: ${n?e.strokeWidth:3};
|
|
87
|
+
}
|
|
88
|
+
.commit-highlight-outer {
|
|
89
|
+
}
|
|
90
|
+
.commit-highlight-inner {
|
|
91
|
+
stroke: ${n?e.mainBkg:e.primaryColor};
|
|
92
|
+
fill: ${n?e.mainBkg:e.primaryColor};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.arrow {
|
|
96
|
+
/* Intentional: neo themes keep the bold 8px arrow (like classic themes); only redux-geometry themes use the thinner options.strokeWidth. */
|
|
97
|
+
stroke-width: ${$.has(t)?e.strokeWidth:8};
|
|
98
|
+
stroke-linecap: round;
|
|
99
|
+
fill: none
|
|
100
|
+
}
|
|
101
|
+
.gitTitleText {
|
|
102
|
+
text-anchor: middle;
|
|
103
|
+
font-size: 18px;
|
|
104
|
+
fill: ${e.textColor};
|
|
105
|
+
}
|
|
106
|
+
`},`getStyles`)};export{qe as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=typeof global==`object`&&global&&global.Object===Object&&global,t=typeof self==`object`&&self&&self.Object===Object&&self,n=e||t||Function(`return this`)(),r=n.Symbol,i=Object.prototype,a=i.hasOwnProperty,o=i.toString,s=r?r.toStringTag:void 0;function c(e){var t=a.call(e,s),n=e[s];try{e[s]=void 0;var r=!0}catch{}var i=o.call(e);return r&&(t?e[s]=n:delete e[s]),i}var l=Object.prototype.toString;function u(e){return l.call(e)}var d=`[object Null]`,f=`[object Undefined]`,p=r?r.toStringTag:void 0;function m(e){return e==null?e===void 0?f:d:p&&p in Object(e)?c(e):u(e)}function h(e){return typeof e==`object`&&!!e}var g=`[object Symbol]`;function _(e){return typeof e==`symbol`||h(e)&&m(e)==g}function v(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var y=Array.isArray,ee=1/0,te=r?r.prototype:void 0,ne=te?te.toString:void 0;function re(e){if(typeof e==`string`)return e;if(y(e))return v(e,re)+``;if(_(e))return ne?ne.call(e):``;var t=e+``;return t==`0`&&1/e==-ee?`-0`:t}function b(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}function x(e){return e}var ie=`[object AsyncFunction]`,ae=`[object Function]`,oe=`[object GeneratorFunction]`,se=`[object Proxy]`;function S(e){if(!b(e))return!1;var t=m(e);return t==ae||t==oe||t==ie||t==se}var ce=n[`__core-js_shared__`],le=function(){var e=/[^.]+$/.exec(ce&&ce.keys&&ce.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function ue(e){return!!le&&le in e}var de=Function.prototype.toString;function C(e){if(e!=null){try{return de.call(e)}catch{}try{return e+``}catch{}}return``}var fe=/[\\^$.*+?()[\]{}|]/g,pe=/^\[object .+?Constructor\]$/,me=Function.prototype,he=Object.prototype,ge=me.toString,_e=he.hasOwnProperty,ve=RegExp(`^`+ge.call(_e).replace(fe,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function ye(e){return!b(e)||ue(e)?!1:(S(e)?ve:pe).test(C(e))}function be(e,t){return e?.[t]}function w(e,t){var n=be(e,t);return ye(n)?n:void 0}var xe=w(n,`WeakMap`);function Se(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Ce(){}var we=800,Te=16,Ee=Date.now;function De(e){var t=0,n=0;return function(){var r=Ee(),i=Te-(r-n);if(n=r,i>0){if(++t>=we)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function T(e){return function(){return e}}var Oe=function(){try{var e=w(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),ke=De(Oe?function(e,t){return Oe(e,`toString`,{configurable:!0,enumerable:!1,value:T(t),writable:!0})}:x);function Ae(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function je(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function Me(e){return e!==e}function Ne(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function Pe(e,t,n){return t===t?Ne(e,t,n):je(e,Me,n)}function Fe(e,t){return!!(e!=null&&e.length)&&Pe(e,t,0)>-1}var Ie=9007199254740991,Le=/^(?:0|[1-9]\d*)$/;function Re(e,t){var n=typeof e;return t??=Ie,!!t&&(n==`number`||n!=`symbol`&&Le.test(e))&&e>-1&&e%1==0&&e<t}function ze(e,t){return e===t||e!==e&&t!==t}var Be=Math.max;function Ve(e,t,n){return t=Be(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=Be(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),Se(e,this,s)}}function He(e,t){return ke(Ve(e,t,x),e+``)}var Ue=9007199254740991;function We(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=Ue}function E(e){return e!=null&&We(e.length)&&!S(e)}var Ge=Object.prototype;function Ke(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Ge)}function qe(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Je=`[object Arguments]`;function Ye(e){return h(e)&&m(e)==Je}var Xe=Object.prototype,Ze=Xe.hasOwnProperty,Qe=Xe.propertyIsEnumerable,D=Ye(function(){return arguments}())?Ye:function(e){return h(e)&&Ze.call(e,`callee`)&&!Qe.call(e,`callee`)};function $e(){return!1}var et=typeof exports==`object`&&exports&&!exports.nodeType&&exports,tt=et&&typeof module==`object`&&module&&!module.nodeType&&module,nt=tt&&tt.exports===et?n.Buffer:void 0,O=(nt?nt.isBuffer:void 0)||$e,rt=`[object Arguments]`,it=`[object Array]`,at=`[object Boolean]`,ot=`[object Date]`,st=`[object Error]`,ct=`[object Function]`,lt=`[object Map]`,ut=`[object Number]`,dt=`[object Object]`,ft=`[object RegExp]`,pt=`[object Set]`,mt=`[object String]`,ht=`[object WeakMap]`,gt=`[object ArrayBuffer]`,_t=`[object DataView]`,vt=`[object Float32Array]`,yt=`[object Float64Array]`,bt=`[object Int8Array]`,xt=`[object Int16Array]`,St=`[object Int32Array]`,Ct=`[object Uint8Array]`,wt=`[object Uint8ClampedArray]`,Tt=`[object Uint16Array]`,Et=`[object Uint32Array]`,k={};k[vt]=k[yt]=k[bt]=k[xt]=k[St]=k[Ct]=k[wt]=k[Tt]=k[Et]=!0,k[rt]=k[it]=k[gt]=k[at]=k[_t]=k[ot]=k[st]=k[ct]=k[lt]=k[ut]=k[dt]=k[ft]=k[pt]=k[mt]=k[ht]=!1;function Dt(e){return h(e)&&We(e.length)&&!!k[m(e)]}function Ot(e){return function(t){return e(t)}}var kt=typeof exports==`object`&&exports&&!exports.nodeType&&exports,A=kt&&typeof module==`object`&&module&&!module.nodeType&&module,At=A&&A.exports===kt&&e.process,jt=function(){try{return A&&A.require&&A.require(`util`).types||At&&At.binding&&At.binding(`util`)}catch{}}(),Mt=jt&&jt.isTypedArray,j=Mt?Ot(Mt):Dt,Nt=Object.prototype.hasOwnProperty;function Pt(e,t){var n=y(e),r=!n&&D(e),i=!n&&!r&&O(e),a=!n&&!r&&!i&&j(e),o=n||r||i||a,s=o?qe(e.length,String):[],c=s.length;for(var l in e)(t||Nt.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||Re(l,c)))&&s.push(l);return s}function Ft(e,t){return function(n){return e(t(n))}}var It=Ft(Object.keys,Object),Lt=Object.prototype.hasOwnProperty;function Rt(e){if(!Ke(e))return It(e);var t=[];for(var n in Object(e))Lt.call(e,n)&&n!=`constructor`&&t.push(n);return t}function M(e){return E(e)?Pt(e):Rt(e)}var zt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Bt=/^\w*$/;function Vt(e,t){if(y(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||_(e)?!0:Bt.test(e)||!zt.test(e)||t!=null&&e in Object(t)}var N=w(Object,`create`);function Ht(){this.__data__=N?N(null):{},this.size=0}function Ut(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var Wt=`__lodash_hash_undefined__`,Gt=Object.prototype.hasOwnProperty;function Kt(e){var t=this.__data__;if(N){var n=t[e];return n===Wt?void 0:n}return Gt.call(t,e)?t[e]:void 0}var qt=Object.prototype.hasOwnProperty;function Jt(e){var t=this.__data__;return N?t[e]!==void 0:qt.call(t,e)}var Yt=`__lodash_hash_undefined__`;function Xt(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=N&&t===void 0?Yt:t,this}function P(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}P.prototype.clear=Ht,P.prototype.delete=Ut,P.prototype.get=Kt,P.prototype.has=Jt,P.prototype.set=Xt;function Zt(){this.__data__=[],this.size=0}function F(e,t){for(var n=e.length;n--;)if(ze(e[n][0],t))return n;return-1}var Qt=Array.prototype.splice;function $t(e){var t=this.__data__,n=F(t,e);return n<0?!1:(n==t.length-1?t.pop():Qt.call(t,n,1),--this.size,!0)}function en(e){var t=this.__data__,n=F(t,e);return n<0?void 0:t[n][1]}function tn(e){return F(this.__data__,e)>-1}function nn(e,t){var n=this.__data__,r=F(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function I(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}I.prototype.clear=Zt,I.prototype.delete=$t,I.prototype.get=en,I.prototype.has=tn,I.prototype.set=nn;var L=w(n,`Map`);function rn(){this.size=0,this.__data__={hash:new P,map:new(L||I),string:new P}}function an(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function R(e,t){var n=e.__data__;return an(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function on(e){var t=R(this,e).delete(e);return this.size-=+!!t,t}function sn(e){return R(this,e).get(e)}function cn(e){return R(this,e).has(e)}function ln(e,t){var n=R(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function z(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}z.prototype.clear=rn,z.prototype.delete=on,z.prototype.get=sn,z.prototype.has=cn,z.prototype.set=ln;var un=`Expected a function`;function dn(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(un);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(dn.Cache||z),n}dn.Cache=z;var fn=500;function pn(e){var t=dn(e,function(e){return n.size===fn&&n.clear(),e}),n=t.cache;return t}var mn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,hn=/\\(\\)?/g,gn=pn(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(mn,function(e,n,r,i){t.push(r?i.replace(hn,`$1`):n||e)}),t});function _n(e){return e==null?``:re(e)}function vn(e,t){return y(e)?e:Vt(e,t)?[e]:gn(_n(e))}var yn=1/0;function B(e){if(typeof e==`string`||_(e))return e;var t=e+``;return t==`0`&&1/e==-yn?`-0`:t}function bn(e,t){t=vn(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[B(t[n++])];return n&&n==r?e:void 0}function xn(e,t,n){var r=e==null?void 0:bn(e,t);return r===void 0?n:r}function Sn(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var Cn=r?r.isConcatSpreadable:void 0;function wn(e){return y(e)||D(e)||!!(Cn&&e&&e[Cn])}function Tn(e,t,n,r,i){var a=-1,o=e.length;for(n||=wn,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?Tn(s,t-1,n,r,i):Sn(i,s):r||(i[i.length]=s)}return i}function En(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function Dn(){this.__data__=new I,this.size=0}function On(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function kn(e){return this.__data__.get(e)}function An(e){return this.__data__.has(e)}var jn=200;function Mn(e,t){var n=this.__data__;if(n instanceof I){var r=n.__data__;if(!L||r.length<jn-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new z(r)}return n.set(e,t),this.size=n.size,this}function V(e){var t=this.__data__=new I(e);this.size=t.size}V.prototype.clear=Dn,V.prototype.delete=On,V.prototype.get=kn,V.prototype.has=An,V.prototype.set=Mn;function Nn(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function Pn(){return[]}var Fn=Object.prototype.propertyIsEnumerable,In=Object.getOwnPropertySymbols,Ln=In?function(e){return e==null?[]:(e=Object(e),Nn(In(e),function(t){return Fn.call(e,t)}))}:Pn;function Rn(e,t,n){var r=t(e);return y(e)?r:Sn(r,n(e))}function zn(e){return Rn(e,M,Ln)}var Bn=w(n,`DataView`),Vn=w(n,`Promise`),H=w(n,`Set`),Hn=`[object Map]`,Un=`[object Object]`,Wn=`[object Promise]`,Gn=`[object Set]`,Kn=`[object WeakMap]`,qn=`[object DataView]`,Jn=C(Bn),Yn=C(L),Xn=C(Vn),Zn=C(H),Qn=C(xe),U=m;(Bn&&U(new Bn(new ArrayBuffer(1)))!=qn||L&&U(new L)!=Hn||Vn&&U(Vn.resolve())!=Wn||H&&U(new H)!=Gn||xe&&U(new xe)!=Kn)&&(U=function(e){var t=m(e),n=t==Un?e.constructor:void 0,r=n?C(n):``;if(r)switch(r){case Jn:return qn;case Yn:return Hn;case Xn:return Wn;case Zn:return Gn;case Qn:return Kn}return t});var W=U,$n=n.Uint8Array,er=`__lodash_hash_undefined__`;function tr(e){return this.__data__.set(e,er),this}function nr(e){return this.__data__.has(e)}function G(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new z;++t<n;)this.add(e[t])}G.prototype.add=G.prototype.push=tr,G.prototype.has=nr;function rr(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function ir(e,t){return e.has(t)}var ar=1,or=2;function sr(e,t,n,r,i,a){var o=n&ar,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&or?new G:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!rr(t,function(e,t){if(!ir(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}function cr(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function lr(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var ur=1,dr=2,fr=`[object Boolean]`,pr=`[object Date]`,mr=`[object Error]`,hr=`[object Map]`,gr=`[object Number]`,_r=`[object RegExp]`,vr=`[object Set]`,yr=`[object String]`,br=`[object Symbol]`,xr=`[object ArrayBuffer]`,Sr=`[object DataView]`,Cr=r?r.prototype:void 0,wr=Cr?Cr.valueOf:void 0;function Tr(e,t,n,r,i,a,o){switch(n){case Sr:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case xr:return!(e.byteLength!=t.byteLength||!a(new $n(e),new $n(t)));case fr:case pr:case gr:return ze(+e,+t);case mr:return e.name==t.name&&e.message==t.message;case _r:case yr:return e==t+``;case hr:var s=cr;case vr:var c=r&ur;if(s||=lr,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=dr,o.set(e,t);var u=sr(s(e),s(t),r,i,a,o);return o.delete(e),u;case br:if(wr)return wr.call(e)==wr.call(t)}return!1}var Er=1,Dr=Object.prototype.hasOwnProperty;function Or(e,t,n,r,i,a){var o=n&Er,s=zn(e),c=s.length;if(c!=zn(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:Dr.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var kr=1,Ar=`[object Arguments]`,jr=`[object Array]`,K=`[object Object]`,Mr=Object.prototype.hasOwnProperty;function Nr(e,t,n,r,i,a){var o=y(e),s=y(t),c=o?jr:W(e),l=s?jr:W(t);c=c==Ar?K:c,l=l==Ar?K:l;var u=c==K,d=l==K,f=c==l;if(f&&O(e)){if(!O(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new V,o||j(e)?sr(e,t,n,r,i,a):Tr(e,t,c,n,r,i,a);if(!(n&kr)){var p=u&&Mr.call(e,`__wrapped__`),m=d&&Mr.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new V,i(h,g,n,r,a)}}return f?(a||=new V,Or(e,t,n,r,i,a)):!1}function Pr(e,t,n,r,i){return e===t?!0:e==null||t==null||!h(e)&&!h(t)?e!==e&&t!==t:Nr(e,t,n,r,Pr,i)}var Fr=1,Ir=2;function Lr(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){s=n[i];var c=s[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new V;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?Pr(u,l,Fr|Ir,r,d):f))return!1}}return!0}function Rr(e){return e===e&&!b(e)}function zr(e){for(var t=M(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Rr(i)]}return t}function Br(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}function Vr(e){var t=zr(e);return t.length==1&&t[0][2]?Br(t[0][0],t[0][1]):function(n){return n===e||Lr(n,e,t)}}function Hr(e,t){return e!=null&&t in Object(e)}function Ur(e,t,n){t=vn(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=B(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&We(i)&&Re(o,i)&&(y(e)||D(e)))}function Wr(e,t){return e!=null&&Ur(e,t,Hr)}var Gr=1,Kr=2;function qr(e,t){return Vt(e)&&Rr(t)?Br(B(e),t):function(n){var r=xn(n,e);return r===void 0&&r===t?Wr(n,e):Pr(t,r,Gr|Kr)}}function Jr(e){return function(t){return t?.[e]}}function Yr(e){return function(t){return bn(t,e)}}function Xr(e){return Vt(e)?Jr(B(e)):Yr(e)}function Zr(e){return typeof e==`function`?e:e==null?x:typeof e==`object`?y(e)?qr(e[0],e[1]):Vr(e):Xr(e)}function Qr(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var $r=Qr();function ei(e,t){return e&&$r(e,t,M)}function ti(e,t){return function(n,r){if(n==null)return n;if(!E(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}var q=ti(ei);function ni(e){return h(e)&&E(e)}function ri(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function ii(e){return typeof e==`function`?e:x}function J(e,t){return(y(e)?Ae:q)(e,ii(t))}function ai(e,t){var n=[];return q(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function Y(e,t){return(y(e)?Nn:ai)(e,Zr(t,3))}function oi(e,t){return v(t,function(t){return e[t]})}function X(e){return e==null?[]:oi(e,M(e))}var si=`[object Map]`,ci=`[object Set]`,li=Object.prototype.hasOwnProperty;function ui(e){if(e==null)return!0;if(E(e)&&(y(e)||typeof e==`string`||typeof e.splice==`function`||O(e)||j(e)||D(e)))return!e.length;var t=W(e);if(t==si||t==ci)return!e.size;if(Ke(e))return!Rt(e).length;for(var n in e)if(li.call(e,n))return!1;return!0}function Z(e){return e===void 0}function di(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function fi(e,t,n){var r=y(e)?En:di,i=arguments.length<3;return r(e,Zr(t,4),n,i,q)}var pi=H&&1/lr(new H([,-0]))[1]==1/0?function(e){return new H(e)}:Ce,mi=200;function hi(e,t,n){var r=-1,i=Fe,a=e.length,o=!0,s=[],c=s;if(n)o=!1,i=ri;else if(a>=mi){var l=t?null:pi(e);if(l)return lr(l);o=!1,i=ir,c=new G}else c=t?[]:s;outer:for(;++r<a;){var u=e[r],d=t?t(u):u;if(u=n||u!==0?u:0,o&&d===d){for(var f=c.length;f--;)if(c[f]===d)continue outer;t&&c.push(d),s.push(u)}else i(c,d,n)||(c!==s&&c.push(d),s.push(u))}return s}var gi=He(function(e){return hi(Tn(e,1,ni,!0))}),_i=`\0`,Q=`\0`,vi=``,yi=class{constructor(e={}){this._isDirected=!Object.prototype.hasOwnProperty.call(e,`directed`)||e.directed,this._isMultigraph=Object.prototype.hasOwnProperty.call(e,`multigraph`)?e.multigraph:!1,this._isCompound=Object.prototype.hasOwnProperty.call(e,`compound`)?e.compound:!1,this._label=void 0,this._defaultNodeLabelFn=T(void 0),this._defaultEdgeLabelFn=T(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[Q]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return S(e)||(e=T(e)),this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return M(this._nodes)}sources(){var e=this;return Y(this.nodes(),function(t){return ui(e._in[t])})}sinks(){var e=this;return Y(this.nodes(),function(t){return ui(e._out[t])})}setNodes(e,t){var n=arguments,r=this;return J(e,function(e){n.length>1?r.setNode(e,t):r.setNode(e)}),this}setNode(e,t){return Object.prototype.hasOwnProperty.call(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=Q,this._children[e]={},this._children[Q][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.prototype.hasOwnProperty.call(this._nodes,e)}removeNode(e){if(Object.prototype.hasOwnProperty.call(this._nodes,e)){var t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],J(this.children(e),e=>{this.setParent(e)}),delete this._children[e]),J(M(this._in[e]),t),delete this._in[e],delete this._preds[e],J(M(this._out[e]),t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(Z(t))t=Q;else{t+=``;for(var n=t;!Z(n);n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==Q)return t}}children(e){if(Z(e)&&(e=Q),this._isCompound){var t=this._children[e];if(t)return M(t)}else if(e===Q)return this.nodes();else if(this.hasNode(e))return[]}predecessors(e){var t=this._preds[e];if(t)return M(t)}successors(e){var t=this._sucs[e];if(t)return M(t)}neighbors(e){var t=this.predecessors(e);if(t)return gi(t,this.successors(e))}isLeaf(e){return(this.isDirected()?this.successors(e):this.neighbors(e)).length===0}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;J(this._nodes,function(n,r){e(r)&&t.setNode(r,n)}),J(this._edgeObjs,function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))});var r={};function i(e){var a=n.parent(e);return a===void 0||t.hasNode(a)?(r[e]=a,a):a in r?r[a]:i(a)}return this._isCompound&&J(t.nodes(),function(e){t.setParent(e,i(e))}),t}setDefaultEdgeLabel(e){return S(e)||(e=T(e)),this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return X(this._edgeObjs)}setPath(e,t){var n=this,r=arguments;return fi(e,function(e,i){return r.length>1?n.setEdge(e,i,t):n.setEdge(e,i),i}),this}setEdge(){var e,t,n,r,i=!1,a=arguments[0];typeof a==`object`&&a&&`v`in a?(e=a.v,t=a.w,n=a.name,arguments.length===2&&(r=arguments[1],i=!0)):(e=a,t=arguments[1],n=arguments[3],arguments.length>2&&(r=arguments[2],i=!0)),e=``+e,t=``+t,Z(n)||(n=``+n);var o=$(this._isDirected,e,t,n);if(Object.prototype.hasOwnProperty.call(this._edgeLabels,o))return i&&(this._edgeLabels[o]=r),this;if(!Z(n)&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(e),this.setNode(t),this._edgeLabels[o]=i?r:this._defaultEdgeLabelFn(e,t,n);var s=Si(this._isDirected,e,t,n);return e=s.v,t=s.w,Object.freeze(s),this._edgeObjs[o]=s,bi(this._preds[t],e),bi(this._sucs[e],t),this._in[t][o]=s,this._out[e][o]=s,this._edgeCount++,this}edge(e,t,n){var r=arguments.length===1?Ci(this._isDirected,arguments[0]):$(this._isDirected,e,t,n);return this._edgeLabels[r]}hasEdge(e,t,n){var r=arguments.length===1?Ci(this._isDirected,arguments[0]):$(this._isDirected,e,t,n);return Object.prototype.hasOwnProperty.call(this._edgeLabels,r)}removeEdge(e,t,n){var r=arguments.length===1?Ci(this._isDirected,arguments[0]):$(this._isDirected,e,t,n),i=this._edgeObjs[r];return i&&(e=i.v,t=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],xi(this._preds[t],e),xi(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var r=X(n);return t?Y(r,function(e){return e.v===t}):r}}outEdges(e,t){var n=this._out[e];if(n){var r=X(n);return t?Y(r,function(e){return e.w===t}):r}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}};yi.prototype._nodeCount=0,yi.prototype._edgeCount=0;function bi(e,t){e[t]?e[t]++:e[t]=1}function xi(e,t){--e[t]||delete e[t]}function $(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}return i+vi+a+vi+(Z(r)?_i:r)}function Si(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return r&&(s.name=r),s}function Ci(e,t){return $(e,t.v,t.w,t.name)}export{v as $,Rt as A,He as B,Tn as C,vn as D,B as E,Ot as F,Ae as G,ze as H,O as I,T as J,ke as K,D as L,Pt as M,j as N,_n as O,jt as P,y as Q,Ke as R,V as S,bn as T,Re as U,Ve as V,je as W,x as X,S as Y,b as Z,W as _,Y as a,Ln as b,ni as c,$r as d,_ as et,Zr as f,$n as g,Ur as h,X as i,n as it,Ft as j,M as k,q as l,Wr as m,fi as n,m as nt,J as o,Jr as p,Oe as q,Z as r,r as rt,ii as s,yi as t,h as tt,ei as u,zn as v,Sn as w,Pn as x,Rn as y,E as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{n as t}from"./d3-selection-BFzs9NTX.js";import{A as n,j as r,nt as i}from"./chunk-QDWOWVBQ-Du0KmhW4.js";import{_ as a}from"./chunk-MDAHDJXZ-YMIkXJ0O.js";import"./chunk-T47YP6PS-CKli33QU.js";import"./chunk-OWCVCYLK-4-W-ynqW.js";import"./chunk-ND7LMLKX-lfusdDHU.js";import"./chunk-DZSZGQHW-BCXsfFfT.js";import"./chunk-GZTWQ64R-CKGVWw4I.js";import"./chunk-MPYPSXSE-C-CxVwa7.js";import"./chunk-F3AE6A5H-DTVcMSk7.js";import{i as o}from"./chunk-EBZ3SEQC-CdDips7b.js";import{n as s,t as c}from"./chunk-3GCGMST5-RRiusQp9.js";var l=1;function u(e,t,n=l){let r=Math.abs(t.x-e.x),i=Math.abs(t.y-e.y);return r<=n&&i<=n?`Z`:i<=n?`H`:`V`}e(u,`segmentOrientation`);function d(e,t=l){let n=[];for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1];n.push({a:i,b:a,orientation:u(i,a,t)})}return n}e(d,`segmentsFromPoints`);function f(e,t=l){if(e.length===0)return[];let n=[],r={...e[0]};for(let i=1;i<e.length;i++){let a=e[i];if(a.orientation!==`Z`){if(r.orientation===`Z`){r={...a};continue}if(r.orientation===a.orientation){if(r.orientation===`H`&&Math.abs(r.b.y-a.a.y)<=t&&Math.abs(r.a.y-a.a.y)<=t){r.b=a.b;continue}if(r.orientation===`V`&&Math.abs(r.b.x-a.a.x)<=t&&Math.abs(r.a.x-a.a.x)<=t){r.b=a.b;continue}}r.orientation!==`Z`&&n.push(r),r={...a}}}return r.orientation!==`Z`&&n.push(r),n}e(f,`mergeCollinear`);function p(e,t=l){if(e.length<2)return{points:[...e],segments:[],bends:0};let n=f(d(e,t).filter(e=>e.orientation!==`Z`),t),r=[];for(let[e,t]of n.entries())e===0&&r.push(t.a),r.push(t.b);let i=0;for(let e=1;e<n.length;e++)n[e-1].orientation!==n[e].orientation&&i++;return{points:r.length>0?r:[...e],segments:n,bends:i}}e(p,`normalizePolyline`);function m(e,t){if(e.orientation===`Z`||t.orientation===`Z`||e.orientation===t.orientation)return!1;let n=e.orientation===`H`?e:t,r=e.orientation===`V`?e:t,i=n.a.y,a=Math.min(n.a.x,n.b.x),o=Math.max(n.a.x,n.b.x),s=r.a.x,c=Math.min(r.a.y,r.b.y),l=Math.max(r.a.y,r.b.y);if(s>=a&&s<=o&&i>=c&&i<=l){let e=1e-6,t=s,a=i,o=Math.abs(t-n.a.x)<e&&Math.abs(a-n.a.y)<e||Math.abs(t-n.b.x)<e&&Math.abs(a-n.b.y)<e,c=Math.abs(t-r.a.x)<e&&Math.abs(a-r.a.y)<e||Math.abs(t-r.b.x)<e&&Math.abs(a-r.b.y)<e;return!(o&&c)}return!1}e(m,`segmentsCross`);function h(e,t){return e<t?-1:+(e>t)}e(h,`compareCodeUnits`);function g(e){let t=e.x??0,n=e.y??0,r=e.width??40,i=e.height??40;return{cx:t,cy:n,left:t-r/2,right:t+r/2,top:n-i/2,bottom:n+i/2}}e(g,`rectForNode`);function _(e,t,n,r,i=0){if(e.length<2)return null;let a=t===`end`?e[e.length-1]:e[0],o=t===`end`?e[e.length-2]:e[1],s=o.x-a.x,c=o.y-a.y;if(Math.abs(s)<=i&&Math.abs(c)<=i)return null;if(Math.abs(c)<=i){let e=a.x+Math.sign(s)*n,t=Math.min(a.x,e),i=Math.max(a.x,e);return{cx:(t+i)/2,cy:a.y,left:t,right:i,top:a.y-r,bottom:a.y+r}}if(Math.abs(s)<=i){let e=a.y+Math.sign(c)*n,t=Math.min(a.y,e),i=Math.max(a.y,e);return{cx:a.x,cy:(t+i)/2,left:a.x-r,right:a.x+r,top:t,bottom:i}}return null}e(_,`terminalMarkerClearanceRect`);function v(e,t){let n=t===`start`?e.arrowTypeStart:e.arrowTypeEnd;if(typeof n==`string`){let e=n.trim();if(e.length>0)return e!==`none`&&e!==`arrow_open`}return typeof e.type==`string`?t===`start`&&e.type.startsWith(`double_`)?!0:t===`end`&&/arrow_(point|cross|circle|barb)|double_arrow/.test(e.type):!1}e(v,`hasTerminalMarker`);function y(e,t,n=1e-6){return Math.abs(e-t)<=n}e(y,`approxEqual`);function b(e,t,n=1e-6){for(let r=1;r<e.length;r++){let i=e[r-1],a=e[r];if(y(i.y,a.y,n)&&!y(i.x,a.x,n)){if(y(t.y,i.y,n)&&t.x>=Math.min(i.x,a.x)-n&&t.x<=Math.max(i.x,a.x)+n)return!0}else if(y(i.x,a.x,n)&&!y(i.y,a.y,n)&&y(t.x,i.x,n)&&t.y>=Math.min(i.y,a.y)-n&&t.y<=Math.max(i.y,a.y)+n)return!0}return!1}e(b,`orthogonalPolylineContainsPoint`);function x(e){let t=0;for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];t+=Math.abs(i.x-r.x)+Math.abs(i.y-r.y)}return t}e(x,`manhattanLength`);function S(e,t,n){if(e.x===t.x&&e.y===t.y)return!1;if(e.y===t.y){let r=e.y,i=Math.min(e.x,t.x),a=Math.max(e.x,t.x),o=r>=n.top&&r<=n.bottom,s=Math.max(i,n.left)<Math.min(a,n.right);return o&&s}if(e.x===t.x){let r=e.x,i=Math.min(e.y,t.y),a=Math.max(e.y,t.y),o=r>=n.left&&r<=n.right,s=Math.max(i,n.top)<Math.min(a,n.bottom);return o&&s}return!1}e(S,`segmentIntersectsRectInterior`);function C(e,t){for(let n=1;n<e.length;n++)if(S(e[n-1],e[n],t))return!0;return!1}e(C,`polylineIntersectsRect`);function w(e,t,n){return Math.max(t,Math.min(n,e))}e(w,`clamp`);var T=`__grid_root__`,E=`edge-label-`;function D(e,t,n){let r=Error(`${e}: ${t}`);return r.code=e,r.details=n,r}e(D,`gridError`);var O={columns:0,rowGap:50,columnGap:50,cellGap:20,containerPadding:20,titleGap:8,horizontalAlign:`center`,verticalAlign:`center`,curve:`rounded`,edgeCornerRadius:5};function k(e){return!!e.isEdgeLabel}e(k,`isEdgeLabelNode`);function A(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}e(A,`isFinitePositiveNumber`);var j=6,M=12,ee=2;function N(e,t){if(!A(e.width)||!A(e.height))return null;let n=t===`H`?e.width:e.height,r=t===`H`?e.height:e.width,i=Math.max(j,M),a=Math.max(j,M);return{along:n,cross:r,startInset:i,endInset:a,requiredAlongSpan:n+i+a+ee}}e(N,`gridLabelSpanRequirement`);function P(e,t){let n=t===`H`?e.width:e.height;return A(n)?n+j*2:0}e(P,`gridLabelRequiredSegmentLength`);var F=j,I=14,L=18,te=16,R=128,ne=64,re=2e6,ie=M,z=1e-6,B=7,ae=8,V=e(e=>p(e,z),`normalizePolyline`);function oe(e,t,n,r){return Math.max(0,Math.min(Math.max(e,t),Math.max(n,r))-Math.max(Math.min(e,t),Math.min(n,r)))}e(oe,`rangeOverlapLength`);function se(e){let t=V([...e]).segments;for(let e=0;e<t.length;e++){let n=t[e];for(let r=e+2;r<t.length;r++){let e=t[r];if(m(n,e))return!0;if(n.orientation!==e.orientation||n.orientation===`Z`)continue;let i=n.orientation===`H`?Math.abs(n.a.y-e.a.y)<=z:Math.abs(n.a.x-e.a.x)<=z,a=n.orientation===`H`?oe(n.a.x,n.b.x,e.a.x,e.b.x):oe(n.a.y,n.b.y,e.a.y,e.b.y);if(i&&a>z)return!0;let o=n.orientation===`H`?Math.abs(n.a.y-e.a.y):Math.abs(n.a.x-e.a.x);if(!i&&o<B&&a>=ae)return!0}}return!1}e(se,`polylineHasSelfConflict`);var ce=class extends Error{constructor(e){super(`Could not place label for edge "${e.edgeId}"`),this.details=e,this.name=`LabelPlacementSearchExhaustedError`}static{e(this,`LabelPlacementSearchExhaustedError`)}},le=class extends Error{static{e(this,`LabelIndexWorkLimitError`)}constructor(){super(`Grid label index work cap exceeded`),this.name=`LabelIndexWorkLimitError`}},ue=class{constructor(e,t){this.limit=e,this.metrics=t,this.used=0}static{e(this,`LabelIndexWorkBudget`)}charge(e){if(!(e<=0)){if(this.used+e>this.limit)throw new le;this.used+=e,H(this.metrics,`indexWorkUnits`,e)}}},de=class{constructor(e,t){this.workBudget=e,this.metrics=t,this.entriesById=new Map,this.sortedByLeft=[],this.dirty=!1}static{e(this,`CompressedBoundsIndex`)}upsert(e){let t=!this.entriesById.has(e.id);this.entriesById.set(e.id,e),this.dirty=!0,t&&this.metrics&&(this.metrics.indexCoordinateCount+=4)}remove(e){this.entriesById.delete(e)&&(this.dirty=!0)}query(e){if(this.dirty){let e=this.entriesById.size;this.workBudget.charge(e*Math.max(1,Math.ceil(Math.log2(e+1)))),this.sortedByLeft=[...this.entriesById.values()].sort((e,t)=>e.bounds.left-t.bounds.left||h(e.id,t.id)),this.dirty=!1}let t=[];for(let n of this.sortedByLeft){if(this.workBudget.charge(1),n.bounds.left>e.right)break;xe(n.bounds,e)&&t.push(n)}return t}};function fe(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}e(fe,`rectOverlap`);function pe(e,t){let n=e.width??0,r=e.height??0;return{cx:t.x,cy:t.y,left:t.x-n/2,right:t.x+n/2,top:t.y-r/2,bottom:t.y+r/2}}e(pe,`labelRectAt`);function me(e){let t=e.groupTitleRect;return t?{cx:(t.left+t.right)/2,cy:(t.top+t.bottom)/2,left:t.left,right:t.right,top:t.top,bottom:t.bottom}:null}e(me,`groupTitleRect`);function H(e,t,n=1){e&&(e[t]+=n)}e(H,`incrementMetric`);function he(e){return{...e}}e(he,`clonePoint`);function ge(e){return{left:e.left,right:e.right,top:e.top,bottom:e.bottom}}e(ge,`boundsForRect`);function _e(e){return{left:Math.min(e.a.x,e.b.x),right:Math.max(e.a.x,e.b.x),top:Math.min(e.a.y,e.b.y),bottom:Math.max(e.a.y,e.b.y)}}e(_e,`boundsForSegment`);function ve(e){if(e.length===0)return null;let t=e[0].x,n=e[0].x,r=e[0].y,i=e[0].y;for(let a of e.slice(1))t=Math.min(t,a.x),n=Math.max(n,a.x),r=Math.min(r,a.y),i=Math.max(i,a.y);return{left:t,right:n,top:r,bottom:i}}e(ve,`boundsForPoints`);function ye(e,t){return{left:Math.min(e.left,t.left),right:Math.max(e.right,t.right),top:Math.min(e.top,t.top),bottom:Math.max(e.bottom,t.bottom)}}e(ye,`mergeBounds`);function be(e,t){return{left:e.left-t,right:e.right+t,top:e.top-t,bottom:e.bottom+t}}e(be,`expandBounds`);function xe(e,t){return e.left<=t.right&&e.right>=t.left&&e.top<=t.bottom&&e.bottom>=t.top}e(xe,`boundsOverlap`);function Se(e){return(e.length<=2?e.map((e,t)=>t):[...e.slice(1,-1).map((e,t)=>t+1),0,e.length-1]).map((t,n)=>({segment:e[t],segmentIndex:t,order:n}))}e(Se,`candidateSegmentsFromSegments`);function Ce(e,t){return[`start`,`end`].filter(t=>v(e,t)).map(e=>_(t,e,ie,7,z)).filter(e=>e!==null)}e(Ce,`markerClearanceRectsFromPoints`);function we(e,t){let n=V(t);return{points:n.points,segments:n.segments,candidateSegments:Se(n.segments),markerRects:Ce(e,n.points)}}e(we,`buildEdgeGeometry`);function Te(e){return e.orientation===`H`?Math.abs(e.b.x-e.a.x):Math.abs(e.b.y-e.a.y)}e(Te,`segmentLength`);function Ee(e,t){let n=[{x:t.left,y:t.top},{x:t.right,y:t.top},{x:t.right,y:t.bottom},{x:t.left,y:t.bottom}];for(let t=0;t<n.length;t++)if(S(n[t],n[(t+1)%n.length],e))return!0;return!1}e(Ee,`borderCutsRect`);function De(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}e(De,`hasFinitePosition`);function U(e,t,n){let r=t?.get(e.id);if(r)return V(r).points;let i=n?.edgeGeometryById.get(e.id);return i?i.points:V(e.points??[]).points}e(U,`pointsForEdge`);function Oe(e,t,n){if(!t?.has(e.id)){let t=n?.edgeGeometryById.get(e.id);if(t)return t.markerRects}return Ce(e,U(e,t,n))}e(Oe,`markerClearanceRectsForEdge`);function ke(e,t,n,r){return Math.max(Math.min(e,t),Math.min(n,r))<Math.min(Math.max(e,t),Math.max(n,r))-z}e(ke,`rangeOverlaps`);function Ae(e,t,n){let r=w(Math.min(e.start,e.end),t,n),i=w(Math.max(e.start,e.end),t,n);return i-r>z?{start:r,end:i}:null}e(Ae,`clampInterval`);function je(e,t,n){let r=e.map(e=>Ae(e,t,n)).filter(e=>e!==null).sort((e,t)=>e.start-t.start||e.end-t.end);if(r.length===0)return[];let i=[r[0]];for(let e=1;e<r.length;e++){let t=r[e],n=i[i.length-1];t.start<=n.end+z?n.end=Math.max(n.end,t.end):i.push(t)}return i}e(je,`mergeBlockedLabelIntervals`);function Me(e,t,n,r){if(t-e<=z)return[];let i=[],a=e;for(let r of je(n,e,t))r.start-a>z&&i.push({start:a,end:r.start}),a=Math.max(a,r.end);t-a>z&&i.push({start:a,end:t});let o=i.map(e=>({value:w(r,e.start,e.end),start:e.start,end:e.end}));o.sort((e,t)=>{let n=Math.abs(e.value-r)-Math.abs(t.value-r);if(Math.abs(n)>z)return n;let i=t.end-t.start-(e.end-e.start);return Math.abs(i)>z?i:e.value-t.value});let s=new Set,c=[];for(let e of o){let t=Math.round(e.value*1e6)/1e6;s.has(t)||(s.add(t),c.push(e.value))}return c}e(Me,`centerCandidatesFromIntervals`);function Ne(e){return e.isGroup||k(e)&&!De(e)?null:g(e)}e(Ne,`obstacleRectForNode`);function Pe(e,t){let n=t?.edgeGeometryById.get(e.id);return n?n.candidateSegments:Se(V(e.points??[]).segments)}e(Pe,`candidateSegments`);function Fe(e,t,n){let r=e.edgeGeometryById.get(t);r&&r.segments.forEach((n,r)=>e.segmentIndex.remove(`${t}:${r}`)),e.edgeGeometryById.set(t,n),n.segments.forEach((n,r)=>{e.segmentIndex.upsert({id:`${t}:${r}`,edgeId:t,segment:n,bounds:_e(n)})})}e(Fe,`storeEdgeGeometry`);function Ie(e,t,n){let r=we(t,n);t.points=r.points.map(he),Fe(e,t.id,r)}e(Ie,`setEdgePoints`);function Le(e,t){e.placedLabelIndex.upsert({id:`label:${t.nodeId}`,nodeId:t.nodeId,rect:t.rect,bounds:ge(t.rect)})}e(Le,`upsertPlacedLabelObstacle`);function Re(t,n,r){let i={edgeById:new Map,edgeGeometryById:new Map,obstacleIndex:new de(n,r),placedLabelIndex:new de(n,r),groupBorderIndex:new de(n,r),segmentIndex:new de(n,r),searchBounds:{left:0,right:0,top:0,bottom:0},metrics:r},a=null,o=e(e=>{a=a?ye(a,e):{...e}},`rememberBounds`);for(let e of t.nodes){if(e.isGroup){let t=g(e),n=ge(t);i.groupBorderIndex.upsert({id:`border:${e.id}`,rect:t,bounds:n}),o(n);let r=me(e);if(r){let t=ge(r);i.obstacleIndex.upsert({id:`title:${e.id}`,rect:r,bounds:t}),o(t)}continue}let t=Ne(e);if(!t)continue;let n={id:`${k(e)?`label`:`node`}:${e.id}`,rect:t,bounds:ge(t),nodeId:e.id};k(e)?i.placedLabelIndex.upsert(n):i.obstacleIndex.upsert(n),o(n.bounds)}for(let e of t.edges){i.edgeById.set(e.id,e);let t=we(e,e.points??[]);Fe(i,e.id,t);let n=ve(t.points);n&&o(n)}return i.searchBounds=be(a??{left:0,right:0,top:0,bottom:0},128),i}e(Re,`createEdgeLabelContext`);function ze(t,n,r,i={}){H(t.metrics,r);let a=[],o=e(e=>{for(let t of e)(!t.nodeId||t.nodeId!==i.excludeNodeId&&!i.skipNodeIds?.has(t.nodeId))&&a.push(t)},`appendEntries`);return o(t.obstacleIndex.query(n)),o(t.placedLabelIndex.query(n)),H(t.metrics,`obstacleCandidatesVisited`,a.length),a}e(ze,`queryObstacleEntries`);function Be(e,t,n,r,i){H(e.metrics,i);let a=r?new Set(r.keys()):void 0,o=[],s=e.segmentIndex.query(t);for(let e of s)e.edgeId===n||a?.has(e.edgeId)||o.push(e);let c=s.length;if(r)for(let[i,a]of r){if(i===n)continue;let r=e.edgeById.get(i);r&&we(r,a).segments.forEach((e,n)=>{let r=_e(e);xe(r,t)&&(c+=1,o.push({id:`override:${i}:${n}`,edgeId:i,segment:e,bounds:r}))})}return H(e.metrics,`segmentCandidatesVisited`,c),o}e(Be,`queryForeignSegments`);function Ve(e,t,n,r){H(e.metrics,`foreignEdgeLookups`);let i=new Set;for(let a of Be(e,ge(t),n,r,`segmentRectQueries`))S(a.segment.a,a.segment.b,t)&&i.add(a.edgeId);return[...i].sort(h)}e(Ve,`foreignEdgeIdsIntersectingRect`);function He(e,t){return!A(t.width)||!A(t.height)?null:e.orientation===`H`?{left:Math.min(e.a.x,e.b.x)-t.width/2,right:Math.max(e.a.x,e.b.x)+t.width/2,top:e.a.y-t.height/2,bottom:e.a.y+t.height/2}:{left:e.a.x-t.width/2,right:e.a.x+t.width/2,top:Math.min(e.a.y,e.b.y)-t.height/2,bottom:Math.max(e.a.y,e.b.y)+t.height/2}}e(He,`obstacleBandQueryBounds`);function Ue(e,t,n){if(e.orientation===`H`){let r=(t.width??0)+F*2+I;return{left:Math.min(e.a.x,e.b.x)-r,right:Math.max(e.a.x,e.b.x)+r,top:n.top,bottom:n.bottom}}let r=(t.height??0)+F*2+I;return{left:n.left,right:n.right,top:Math.min(e.a.y,e.b.y)-r,bottom:Math.max(e.a.y,e.b.y)+r}}e(Ue,`detourLineQueryBounds`);function We(e,t){return e.orientation===`H`?{left:Math.min(e.a.x,e.b.x)-F,right:Math.max(e.a.x,e.b.x)+F,top:t.top,bottom:t.bottom}:{left:t.left,right:t.right,top:Math.min(e.a.y,e.b.y)-F,bottom:Math.max(e.a.y,e.b.y)+F}}e(We,`rerouteLineQueryBounds`);function Ge(e,t,n,r,i,a){for(let t of ze(r,ge(e),`obstacleRectQueries`,{excludeNodeId:n}))if(fe(e,t.rect))return!1;for(let t of r.groupBorderIndex.query(ge(e)))if(Ee(e,t.rect))return!1;for(let n of Oe(t,i,r))if(fe(e,n))return!1;for(let n of Be(r,ge(e),t.id,i,`segmentRectQueries`))if(!a?.has(n.edgeId)&&S(n.segment.a,n.segment.b,e))return!1;return!0}e(Ge,`rectSafeForLabel`);function Ke(e,t){return t.orientation===`Z`?0:P(e,t.orientation)}e(Ke,`requiredSegmentLength`);function qe(t,n,r,i,a,o){if(!A(n.width)||!A(n.height))return null;let s=n.width,c=n.height,l=r.orientation===`H`?s/2+F:c/2+F,u=r.orientation===`H`?Math.min(r.a.x,r.b.x)+l:Math.min(r.a.y,r.b.y)+l,d=r.orientation===`H`?Math.max(r.a.x,r.b.x)-l:Math.max(r.a.y,r.b.y)-l;if(d-u<=z)return null;let f=[],p=He(r,n);if(!p)return null;let m=e(e=>{if(r.orientation===`H`){ke(r.a.y-c/2,r.a.y+c/2,e.top,e.bottom)&&f.push({start:e.left-s/2,end:e.right+s/2});return}ke(r.a.x-s/2,r.a.x+s/2,e.left,e.right)&&f.push({start:e.top-c/2,end:e.bottom+c/2})},`addRect`);for(let e of ze(i,p,`obstacleBandQueries`,{excludeNodeId:n.id}))m(e.rect);for(let e of Oe(t,a,i))m(e);if(o)for(let e of Be(i,p,t.id,a,`segmentBandQueries`)){let t=e.segment;if(r.orientation===`H`){let e=r.a.y-n.height/2,i=r.a.y+n.height/2;t.orientation===`H`?e<t.a.y&&i>t.a.y&&f.push({start:Math.min(t.a.x,t.b.x)-n.width/2,end:Math.max(t.a.x,t.b.x)+n.width/2}):ke(e,i,Math.min(t.a.y,t.b.y),Math.max(t.a.y,t.b.y))&&f.push({start:t.a.x-n.width/2,end:t.a.x+n.width/2});continue}let i=r.a.x-n.width/2,a=r.a.x+n.width/2;t.orientation===`V`?i<t.a.x&&a>t.a.x&&f.push({start:Math.min(t.a.y,t.b.y)-n.height/2,end:Math.max(t.a.y,t.b.y)+n.height/2}):ke(i,a,Math.min(t.a.x,t.b.x),Math.max(t.a.x,t.b.x))&&f.push({start:t.a.y-n.height/2,end:t.a.y+n.height/2})}return{low:u,high:d,blocked:f}}e(qe,`blockedCenterIntervals`);function Je(e,t,n,r){if(Te(n)<Ke(t,n))return null;let i=qe(e,t,n,r,void 0,!0);if(!i)return null;let a=n.orientation===`H`?(Math.min(n.a.x,n.b.x)+Math.max(n.a.x,n.b.x))/2:(Math.min(n.a.y,n.b.y)+Math.max(n.a.y,n.b.y))/2,o=Me(i.low,i.high,i.blocked,a);for(let i of o){let a=n.orientation===`H`?{x:i,y:n.a.y}:{x:n.a.x,y:i};if(Ge(pe(t,a),e,t.id,r))return a}return null}e(Je,`placementOnExistingSegment`);function Ye(e,t,n,r,i){let a=qe(e,t,n,r,void 0,!1);if(!a)return null;let o=n.orientation===`H`?(Math.min(n.a.x,n.b.x)+Math.max(n.a.x,n.b.x))/2:(Math.min(n.a.y,n.b.y)+Math.max(n.a.y,n.b.y))/2,s=Me(a.low,a.high,a.blocked,o);for(let a of s){let o=n.orientation===`H`?{x:a,y:n.a.y}:{x:n.a.x,y:a},s=pe(t,o),c=new Map,l=Ve(r,s,e.id).map(e=>r.edgeById.get(e)).filter(e=>e!==void 0),u=!0;for(let e of l){let t=mt(e,s,r,i,c);if(!t){u=!1;break}c.set(e.id,t)}if(u&&Ge(s,e,t.id,r,c)){for(let[e,t]of c){let n=r.edgeById.get(e);n&&Ie(r,n,t)}return o}}return null}e(Ye,`placementOnExistingSegmentWithReroutes`);function Xe(e,t,n){for(let r of V(e).segments)for(let e of ze(t,_e(r),`obstaclePolylineQueries`,{skipNodeIds:n}))if(S(r.a,r.b,e.rect))return!0;return!1}e(Xe,`polylineHitsProtectedObstacles`);function Ze(e,t,n){let r=n.get(e);return!r||b(t,r.center,z)}e(Ze,`labelStillAnchored`);function Qe(e){let t=[];for(let n=0;n<te;n++){let r=e+I+n*L;t.push(-r,r)}return t}e(Qe,`detourOffsets`);function $e(e,t){let n=new Map;for(let t of e){let e=Math.round(t*1e6)/1e6;n.has(e)||n.set(e,t)}return[...n.values()].sort((e,n)=>{let r=Math.abs(e-t)-Math.abs(n-t);return Math.abs(r)>z?r:e-n})}e($e,`uniqueSortedCandidates`);function et(t,n,r,i){if(!A(n.width)||!A(n.height))return[];let a=n.width,o=n.height,s=r.orientation===`H`?r.a.y:r.a.x,c=r.orientation===`H`?o/2:a/2,l=Qe(c).map(e=>s+e),u=e(e=>{if(r.orientation===`H`){l.push(e.top-c-I),l.push(e.bottom+c+I);return}l.push(e.left-c-I),l.push(e.right+c+I)},`addRect`);for(let e of ze(i,Ue(r,n,i.searchBounds),`obstacleBandQueries`,{excludeNodeId:n.id}))u(e.rect);for(let e of Oe(t,void 0,i))u(e);return $e(l,s).slice(0,R)}e(et,`detourLineCandidates`);function tt(t,n,r,i,a){let o=t.orientation===`H`?t.a.y:t.a.x,s=[];for(let e of Qe(0))t.orientation===`H`?s.push(e<0?n.top+e:n.bottom+e):s.push(e<0?n.left+e:n.right+e);let c=e(e=>{if(t.orientation===`H`){s.push(e.top-I),s.push(e.bottom+I);return}s.push(e.left-I),s.push(e.right+I)},`addRect`);for(let e of ze(r,We(t,r.searchBounds),`obstacleBandQueries`,{skipNodeIds:i}))c(e.rect);let l=$e(s,o);return(a?.orientation===t.orientation?l.filter(e=>a.side===`top`?e<n.top:a.side===`bottom`?e>n.bottom:a.side===`left`?e<n.left:e>n.right):l).slice(0,R)}e(tt,`rerouteLineCandidates`);function nt(t,n,r,i,a){if(!A(n.width)||!A(n.height))return[];let o=n.width,s=n.height,c=r.orientation===`H`?{orientation:`H`,a:{x:r.a.x,y:i},b:{x:r.b.x,y:i}}:{orientation:`V`,a:{x:i,y:r.a.y},b:{x:i,y:r.b.y}},l=qe(t,n,c,a,void 0,!1);if(!l){let t=r.orientation===`H`?(Math.min(r.a.x,r.b.x)+Math.max(r.a.x,r.b.x))/2:(Math.min(r.a.y,r.b.y)+Math.max(r.a.y,r.b.y))/2,i=[t],l=He(c,n),u=e(e=>{if(r.orientation===`H`){i.push(e.left-I-o/2),i.push(e.right+I+o/2);return}i.push(e.top-I-s/2),i.push(e.bottom+I+s/2)},`addRect`);if(l)for(let e of ze(a,l,`obstacleBandQueries`,{excludeNodeId:n.id}))u(e.rect);return $e(i,t).slice(0,ne)}let u=r.orientation===`H`?(Math.min(r.a.x,r.b.x)+Math.max(r.a.x,r.b.x))/2:(Math.min(r.a.y,r.b.y)+Math.max(r.a.y,r.b.y))/2;return Me(l.low,l.high,l.blocked,u)}e(nt,`detourCenterCandidates`);function rt(e,t,n){return t+(t>=e?1:-1)*(n+F)}e(rt,`detourReturnCoordinate`);var it={along:e(e=>e.x,`along`),cross:e(e=>e.y,`cross`),point:e((e,t)=>({x:e,y:t}),`point`),labelAlongSize:e(e=>e.width??0,`labelAlongSize`),labelCrossSize:e(e=>e.height??0,`labelCrossSize`)},at={along:e(e=>e.y,`along`),cross:e(e=>e.x,`cross`),point:e((e,t)=>({x:t,y:e}),`point`),labelAlongSize:e(e=>e.height??0,`labelAlongSize`),labelCrossSize:e(e=>e.width??0,`labelCrossSize`)};function ot(e){return e.orientation===`H`?it:at}e(ot,`detourAxis`);function st(e,t,n,r,i,a){if(!A(r.width)||!A(r.height))return null;let o=e[t],s=e[t+1],c=ot(n),l=c.cross(n.a),u=c.along(o),d=c.along(s),f=c.labelAlongSize(r)+F*2,p=i-f/2,m=i+f/2,h=p<Math.min(u,d)-z,g=m>Math.max(u,d)+z,_=d>=u?1:-1,v=Math.max(0,Math.min(ie,Math.abs(d-u)/2-z)),y=u+_*v,b=d-_*v;if(!h&&!g)return V([...e.slice(0,t),o,c.point(p,l),c.point(p,a),c.point(m,a),c.point(m,l),s,...e.slice(t+2)]).points;let x=rt(l,a,c.labelCrossSize(r)/2),S=[...e.slice(0,t),o];return h?S.push(c.point(y,l),c.point(y,x),c.point(p,x),c.point(p,a)):S.push(c.point(p,l),c.point(p,a)),S.push(c.point(m,a)),g?S.push(c.point(m,x),c.point(b,x),c.point(b,l)):S.push(c.point(m,l)),S.push(s,...e.slice(t+2)),V(S).points}e(st,`buildLabelDetourPoints`);function ct(e,t,n,r,i,a,o){if(!A(r.width)||!A(r.height))return null;let s=e[t],c=e[t+1],l=o?4:2,u=ot(n),d=u.cross(n.a),f=u.along(s),p=u.along(c),m=u.labelAlongSize(r)+F*2,h=i-m/2,g=i+m/2,_=p>=f?1:-1,v=Math.max(0,Math.min(ie,Math.abs(p-f)/l-z)),y=f+_*v,b=p-_*v,x=rt(d,a,u.labelCrossSize(r)/2);return V([...e.slice(0,t),s,u.point(y,d),u.point(y,a),u.point(h,a),u.point(g,a),u.point(g,x),u.point(b,x),u.point(b,d),c,...e.slice(t+2)]).points}e(ct,`buildExtendedLabelDetourPoints`);function lt(e,t){if(!A(t.width)||!A(t.height))return[];if(e.orientation===`H`){let n=Math.min(e.a.x,e.b.x),r=Math.max(e.a.x,e.b.x);return[n-t.width/2-I,r+t.width/2+I]}let n=Math.min(e.a.y,e.b.y),r=Math.max(e.a.y,e.b.y);return[n-t.height/2-I,r+t.height/2+I]}e(lt,`externalDetourCenterCandidates`);function ut(e,t){let n=0,r=0;for(let i of V([...e]).segments)S(i.a,i.b,t)&&(n++,i.orientation===`H`?r+=Math.max(0,Math.min(Math.max(i.a.x,i.b.x),t.right)-Math.max(Math.min(i.a.x,i.b.x),t.left)):i.orientation===`V`&&(r+=Math.max(0,Math.min(Math.max(i.a.y,i.b.y),t.bottom)-Math.max(Math.min(i.a.y,i.b.y),t.top))));return{count:n,length:r}}e(ut,`blockedIntersectionScore`);function dt(e,t,n){let r=ut(e,t);return r.count<n.count||r.count===n.count&&r.length<n.length-z}e(dt,`reducesBlockedIntersections`);function ft(e,t,n){let r=V([...e]).segments.find(e=>S(e.a,e.b,t));if(!r||r.orientation===`Z`)return null;let i=r.orientation===`H`?Math.abs(r.a.y-t.top)<=Math.abs(t.bottom-r.a.y)?`top`:`bottom`:Math.abs(r.a.x-t.left)<=Math.abs(t.right-r.a.x)?`left`:`right`,a=n.map(e=>e.edgeId).sort(h);return{key:JSON.stringify([a,r.orientation,i]),orientation:r.orientation,side:i}}e(ft,`rerouteLane`);function pt(e,t,n,r,i,a,o){let s=V(t),c=ut(s.points,r),l=s.segments[n];if(!l||l.orientation===`Z`)return null;let u=s.points[n],d=s.points[n+1],f=a.get(e.id)?.nodeId,p=new Set;if(f&&p.add(f),l.orientation===`H`){let t=Math.min(u.x,d.x),f=Math.max(u.x,d.x),m=Math.max(t,r.left-F),h=Math.min(f,r.right+F);if(h-m<=z)return H(i.metrics,`rerouteRejectedDegenerateSpan`),null;for(let t of tt(l,r,i,p,o)){H(i.metrics,`rerouteCandidatesEvaluated`);let o=V([...s.points.slice(0,n),u,{x:m,y:l.a.y},{x:m,y:t},{x:h,y:t},{x:h,y:l.a.y},d,...s.points.slice(n+2)]).points;if(C(o,r)&&!dt(o,r,c)){H(i.metrics,`rerouteRejectedBlockedRect`);continue}if(C(o,r)&&H(i.metrics,`reroutePartialProgressCandidates`),Xe(o,i,p)){H(i.metrics,`rerouteRejectedProtectedObstacle`);continue}if(!Ze(e.id,o,a)){H(i.metrics,`rerouteRejectedLabelAnchor`);continue}return o}return null}let m=Math.min(u.y,d.y),h=Math.max(u.y,d.y),g=Math.max(m,r.top-F),_=Math.min(h,r.bottom+F);if(_-g<=z)return H(i.metrics,`rerouteRejectedDegenerateSpan`),null;for(let t of tt(l,r,i,p,o)){H(i.metrics,`rerouteCandidatesEvaluated`);let o=V([...s.points.slice(0,n),u,{x:l.a.x,y:g},{x:t,y:g},{x:t,y:_},{x:l.a.x,y:_},d,...s.points.slice(n+2)]).points;if(C(o,r)&&!dt(o,r,c)){H(i.metrics,`rerouteRejectedBlockedRect`);continue}if(C(o,r)&&H(i.metrics,`reroutePartialProgressCandidates`),Xe(o,i,p)){H(i.metrics,`rerouteRejectedProtectedObstacle`);continue}if(!Ze(e.id,o,a)){H(i.metrics,`rerouteRejectedLabelAnchor`);continue}return o}return null}e(pt,`rerouteSegmentAroundRect`);function mt(e,t,n,r,i,a){let o=U(e,i,n);for(let i=0;i<8;i++){if(!C(o,t))return o;let i=V(o),s=i.points.findIndex((e,n)=>n!==i.points.length-1&&S(e,i.points[n+1],t));if(s<0)return o;let c=pt(e,i.points,s,t,n,r,a);if(!c)return null;o=c}return C(o,t)?null:o}e(mt,`rerouteForeignEdgeAroundRect`);function ht(e,t,n,r,i){let a=U(e,i,n),o=a;for(let s=0;s<2;s++){let s=!1;for(let c of t){if(!C(o,c.rect))continue;H(n.metrics,`individualLabelRerouteAttempts`),i.set(e.id,o);let t=mt(e,c.rect,n,r,i);if(!t)return i.set(e.id,a),null;H(n.metrics,`individualLabelRerouteSuccesses`),o=t,s=!0}if(t.every(e=>!C(o,e.rect)))return o;if(!s)break}return i.set(e.id,a),null}e(ht,`rerouteForeignEdgeAroundLabels`);function gt(e,t,n,r,i){if(!A(t.width)||!A(t.height))return null;let a=U(e,void 0,r),o=n.segment;for(let s of et(e,t,o,r)){let c=$e(lt(o,t),o.orientation===`H`?(Math.min(o.a.x,o.b.x)+Math.max(o.a.x,o.b.x))/2:(Math.min(o.a.y,o.b.y)+Math.max(o.a.y,o.b.y))/2);for(let l of c){let c=ct(a,n.segmentIndex,o,t,l,s,e.start===e.end);if(!c||e.start===e.end&&se(c)||Xe(c,r,new Set([t.id])))continue;let u=o.orientation===`H`?{x:l,y:s}:{x:s,y:l},d=pe(t,u),f=new Map([[e.id,c]]),p=Ve(r,d,e.id,f).map(e=>r.edgeById.get(e)).filter(e=>e!==void 0),m=!0;for(let e of p){let t=mt(e,d,r,i,f);if(!t){m=!1;break}f.set(e.id,t)}if(m&&Ge(d,e,t.id,r,f)){Ie(r,e,c);for(let[t,n]of f){if(t===e.id)continue;let i=r.edgeById.get(t);i&&Ie(r,i,n)}return u}}}return null}e(gt,`labelPlacementWithExtendedDetour`);function _t(e,t,n,r,i){if(!A(t.width)||!A(t.height))return null;let a=U(e,void 0,r),o=n.segment;for(let s of et(e,t,o,r)){let c=nt(e,t,o,s,r);for(let l of c){let c=st(a,n.segmentIndex,o,t,l,s);if(!c||e.start===e.end&&se(c)||Xe(c,r,new Set([t.id])))continue;let u=o.orientation===`H`?{x:l,y:s}:{x:s,y:l},d=pe(t,u),f=new Map([[e.id,c]]),p=Ve(r,d,e.id,f).map(e=>r.edgeById.get(e)).filter(e=>e!==void 0),m=!0;for(let e of p){let t=mt(e,d,r,i,f);if(!t){m=!1;break}f.set(e.id,t)}if(m&&Ge(d,e,t.id,r,f)){Ie(r,e,c);for(let[t,n]of f){if(t===e.id)continue;let i=r.edgeById.get(t);i&&Ie(r,i,n)}return u}}}return null}e(_t,`labelPlacementWithDetour`);function vt(e){return!!(e&&k(e))}e(vt,`isPreparedLabelNode`);function yt(e,t,n){let r=e.points?.find(e=>Number.isFinite(e.x)&&Number.isFinite(e.y)),i=e.start?n.get(e.start):void 0,a=e.end?n.get(e.end):void 0,o=r??(i&&De(i)?i:void 0)??a;if(o&&Number.isFinite(o.x)&&Number.isFinite(o.y)){t.x=o.x,t.y=o.y;return}delete t.x,delete t.y}e(yt,`parkDegenerateLabel`);function bt(e,t,n){let r;for(let t of V(e.points??[]).segments)t.orientation!==`Z`&&(!r||Te(t)>Te(r))&&(r=t);if(!r){yt(e,t,n);return}t.x=(r.a.x+r.b.x)/2,t.y=(r.a.y+r.b.y)/2}e(bt,`placeLabelAtRouteMidpoint`);function xt(e){return`${E}${e.start??``}-${e.end??``}-${e.id}`}e(xt,`preferredGridLabelNodeId`);function St(e,t){let n=e.labelNodeId??xt(e),r=n,i=1;for(;;){if(!t.has(r))return r;r=`${n}-${i}`,i+=1}}e(St,`ensureUniqueGridLabelNodeId`);function Ct(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);let n=[];for(let r of e.edges){if(!r.label||r.label.length===0)continue;let e=r.start?t.get(r.start):void 0,i=r.labelNodeId?t.get(r.labelNodeId):void 0;if(vt(i)){i.label=r.label,i.labelStyle=Array.isArray(r.labelStyle)?r.labelStyle[0]:r.labelStyle??``,i.edgeStart=r.start??``,i.edgeEnd=r.end??``,e?.dir&&(i.dir=e.dir),r.label=void 0,r.text=void 0;continue}let a=St(r,t),o={id:a,label:r.label,edgeStart:r.start??``,edgeEnd:r.end??``,shape:`labelRect`,width:0,height:0,isEdgeLabel:!0,isDummy:!0,isGroup:!1,parentId:void 0,labelStyle:Array.isArray(r.labelStyle)?r.labelStyle[0]:r.labelStyle??``,...e?.dir?{dir:e.dir}:{}};n.push(o),t.set(a,o),r.labelNodeId=a,r.label=void 0,r.text=void 0}e.nodes.push(...n)}e(Ct,`prepareGridLayout`);function wt(n,r,i,a={}){let o=new Map;for(let e of n.nodes)o.set(e.id,e);let s=n.nodes.filter(k),c=new Map(s.map(e=>[e.id,{x:e.x,y:e.y}]));for(let e of s)delete e.x,delete e.y;let l=n.edges.map((e,t)=>{if(!e.labelNodeId)return null;let n=o.get(e.labelNodeId);return n?!A(n.width)||!A(n.height)?(H(r,`unmeasuredLabelsSkipped`),null):{edge:e,labelNode:n,sourceIndex:t}:null}).filter(e=>e!==null);if(l.length===0)return;let u=new Map(n.edges.map(e=>[e.id,e.points?.map(e=>({...e}))])),d=e(()=>{for(let e of n.edges){let t=u.get(e.id);t?e.points=t.map(e=>({...e})):delete e.points}},`restoreBaseEdgePoints`),f=e(()=>{d();for(let e of s){let t=c.get(e.id);t&&Number.isFinite(t.x)&&Number.isFinite(t.y)?(e.x=t.x,e.y=t.y):(delete e.x,delete e.y)}},`restoreBaseState`),p=l.filter(({edge:e,labelNode:t})=>V(e.points??[]).segments.length>0||(yt(e,t,o),H(r,`degenerateLabelRoutesSkipped`),!1)).sort((e,t)=>e.sourceIndex-t.sourceIndex||h(e.edge.id,t.edge.id));if(p.length===0)return;let m=e(()=>{d();for(let{edge:e,labelNode:t}of p)bt(e,t,o)},`placeLabelsAtRouteMidpoints`),g=a.maxIndexWork??re,_=new ue(Number.isFinite(g)&&g>=0?Math.floor(g):re,r),v=[];for(let e=1;e<=2;e++){H(r,`labelPasses`);let t=Re(n,_,r),a=new Map,o=new Map,s=new Map(n.edges.map(e=>[e.id,U(e,void 0,t).map(he)])),c=new Map;try{for(let{edge:n,labelNode:r}of p){let i=[...Pe(n,t)].sort((e,t)=>{let n=Te(t.segment)-Te(e.segment);return Math.abs(n)>z?n:e.order-t.order}),o=null;for(let e of i)if(o=Je(n,r,e.segment,t),o)break;if(!o){for(let e of i)if(o=Ye(n,r,e.segment,t,a),o)break}if(e===2&&!o){for(let e of i)if(o=_t(n,r,e,t,a),o)break}if(e===2&&!o){for(let e of i)if(o=gt(n,r,e,t,a),o)break}if(!o)throw new ce({edgeId:n.id,labelNodeId:r.id,labelWidth:r.width,labelHeight:r.height,pointCount:n.points?.length??0,points:n.points?.map(e=>({...e}))??[],segments:i.map(({segment:e})=>({orientation:e.orientation,length:Te(e),a:{...e.a},b:{...e.b}}))});r.x=o.x,r.y=o.y;let s={edgeId:n.id,nodeId:r.id,center:o,rect:pe(r,o)};a.set(n.id,s),Le(t,s)}let l=[...a.values()];H(r,`frozenReservations`,l.length),i&&(i.labelOverlayBuilds++,i.labelOverlayVertices+=l.length*4);for(let e of n.edges){let n=s.get(e.id)??[],r=U(e,void 0,t);JSON.stringify(r)!==JSON.stringify(n)&&c.set(e.id,r.map(he)),Ie(t,e,n.map(he))}for(let[e,n]of c){if(!a.has(e))continue;let r=t.edgeById.get(e);r&&Ie(t,r,n)}let u=new Set(c.keys());for(let e of n.edges){let n=a.get(e.id),r=U(e,void 0,t);for(let t of l)t.edgeId!==e.id&&C(r,t.rect)&&u.add(e.id);n&&!Ze(e.id,r,a)&&u.add(e.id)}let d=new Map;for(let i of n.edges){if(!u.has(i.id))continue;let n=U(i,void 0,t),s=new Map([[i.id,n]]),c=l.filter(e=>e.edgeId!==i.id&&C(n,e.rect));if(c.length>0){let e=c.slice(1).reduce((e,t)=>({cx:(Math.min(e.left,t.rect.left)+Math.max(e.right,t.rect.right))/2,cy:(Math.min(e.top,t.rect.top)+Math.max(e.bottom,t.rect.bottom))/2,left:Math.min(e.left,t.rect.left),right:Math.max(e.right,t.rect.right),top:Math.min(e.top,t.rect.top),bottom:Math.max(e.bottom,t.rect.bottom)}),{...c[0].rect}),l=ft(n,e,c),u=l?d.get(l.key)??0:0,f=(u+2)*12,p=mt(i,{cx:e.cx,cy:e.cy,left:e.left-f,right:e.right+f,top:e.top-f,bottom:e.bottom+f},t,a,s,l??void 0),m=p!==null;if(p??=ht(i,c,t,a,s),p)n=p,s.set(i.id,n),l&&m&&d.set(l.key,u+1);else{H(r,`labelOverlapFallbacks`);for(let e of c){if(!C(n,e.rect))continue;let t=o.get(e.edgeId)??new Set;t.has(i.id)||H(r,`labelOverlapReservations`),t.add(i.id),o.set(e.edgeId,t)}}}if(!Ze(i.id,n,a))throw D(`GRID_ROUTE_NOT_FOUND`,`Label anchor was lost for edge "${i.id}"`,{edgeId:i.id,pass:e});a.has(i.id)&&H(r,`preservedAnchors`),Ie(t,i,n),H(r,`impactedEdgeReroutes`)}for(let{edge:n,labelNode:r}of p){let i=a.get(n.id);if(!i||!Ze(n.id,U(n,void 0,t),a)||!Ge(i.rect,n,r.id,t,void 0,o.get(n.id)))throw D(`GRID_ROUTE_NOT_FOUND`,`Label pass ${e} did not validate`,{edgeId:n.id,pass:e})}return}catch(e){if(e instanceof le){m(),H(r,`indexWorkLimitFallbacks`),i&&(i.resourceLimitFallbacks++,i.fallbackReasons.label_index_work_cap++);return}if(!(e instanceof ce))throw f(),H(r,`rollbacks`),e;v.push(e),d();for(let{labelNode:e}of p)delete e.x,delete e.y}}m(),H(r,`placementSearchFallbacks`),i&&i.fallbackReasons.label_placement_exhausted++,t.warn(`[grid]`,`Label placement search exhausted; using route midpoints. Labels may overlap.`,{reason:`label_placement_exhausted`,edgeIds:p.map(({edge:e})=>e.id),failures:v.map(({details:e})=>e)})}e(wt,`positionGridEdgeLabels`);function Tt(e){return e.isGroup?e:void 0}e(Tt,`asGroup`);function Et(t){let n=new Map,r=new Map,i=new Set;for(let e of t){if(e.id===T)throw D(`GRID_INVALID_CONTAINMENT`,`Node id "${T}" is reserved for the grid layout root`,{traversedIds:[e.id]});if(n.has(e.id))throw D(`GRID_INVALID_CONTAINMENT`,`Duplicate node id "${e.id}"`,{traversedIds:[e.id]});if(n.set(e.id,e),k(e)){i.add(e.id);continue}let t=Tt(e);t&&r.set(t.id,t)}let a=new Map;a.set(T,[]);for(let e of t){if(i.has(e.id))continue;let t=e.parentId??T;if(t!==T&&!r.get(t))throw D(`GRID_INVALID_CONTAINMENT`,`Missing parent "${t}" for "${e.id}"`,{traversedIds:[e.id,t]});a.has(t)||a.set(t,[]),a.get(t).push(e)}let o=new Map,s=[],c=e(e=>(a.get(e)??[]).map(e=>Tt(e)).filter(e=>e!==void 0),`directChildGroups`),l=e(e=>{let t=o.get(e)??0;if(t===1)throw D(`GRID_INVALID_CONTAINMENT`,`Containment cycle at "${e}"`,{traversedIds:[e]});if(t===2)return;o.set(e,1);let n=[{groupId:e,childGroups:c(e),nextChildIndex:0}];for(;n.length>0;){let e=n[n.length-1],t=e.childGroups[e.nextChildIndex];if(t){e.nextChildIndex+=1;let r=o.get(t.id)??0;if(r===1)throw D(`GRID_INVALID_CONTAINMENT`,`Containment cycle at "${t.id}"`,{traversedIds:[...n.map(e=>e.groupId),t.id]});if(r===2)continue;o.set(t.id,1),n.push({groupId:t.id,childGroups:c(t.id),nextChildIndex:0});continue}n.pop(),o.set(e.groupId,2);let i=r.get(e.groupId);i&&s.push(i)}},`visit`);for(let e of a.get(T)??[]){let t=Tt(e);t&&l(t.id)}for(let e of r.keys())(o.get(e)??0)===0&&l(e);return{nodeById:n,groupById:r,childrenByParent:a,rootChildren:a.get(T)??[],postOrderGroups:s,helperNodeIds:i}}e(Et,`buildGridForest`);function Dt(e,t,n){let r=t,i=new Set;for(;r?.parentId;){if(r.parentId===e)return!0;if(i.has(r.parentId))return!1;i.add(r.parentId),r=n.get(r.parentId)}return!1}e(Dt,`isAncestorGroup`);function Ot(e,t,n){let r=new Map,i=new Map;for(let a of e.edges){if(!a.start||!a.end||!a.labelNodeId)continue;n&&n.labelSpacingEdgesExamined++;let e=t.nodeById.get(a.labelNodeId),o=t.nodeById.get(a.start),s=t.nodeById.get(a.end);if(!e||!o||!s)continue;if(a.start===a.end){let t=N(e,`H`);t&&i.set(a.id,t);continue}let c=o.parentId??T;if(c!==(s.parentId??T))continue;let l=r.get(c);l?l.push({edge:a,labelNode:e}):r.set(c,[{edge:a,labelNode:e}])}return{byContainer:r,selfLoops:i}}e(Ot,`buildGridLabelRequirements`);function kt(e,t,n){let r=new Map,i=0;for(let a of e)r.set(a,i),i+=(t.get(a)??0)+n;return r}e(kt,`trackOrigins`);function At(e,t,n,r,i){let a=kt(n,r,i),o=a.get(e),s=r.get(e);if(o===void 0||s===void 0)return!1;let c=o+s/2,l=c-t/2,u=c+t/2;return n.every(t=>{if(t===e)return!0;let n=a.get(t),i=n+(r.get(t)??0);return u<=n||l>=i})}e(At,`crossAxisFits`);function jt(e){let t=new Map;for(let n of e.values())for(let e of n.items)t.set(e.item.id,e);return t}e(jt,`placementByNodeId`);function Mt(e,t,n){let r=Math.min(e,t),i=Math.max(e,t),a=n.indexOf(r);return a>=0&&n[a+1]===i}e(Mt,`areConsecutive`);function Nt(e,t,n){e.set(t,Math.max(e.get(t)??0,n))}e(Nt,`addGapRequirement`);function Pt(t,n,r,i,a,o,s,c,l){let u=new Map,d=new Map,f=jt(n),p=e((e,t)=>N(e.labelNode,t),`requirementFor`);for(let e of t){let t=e.edge.start?f.get(e.edge.start):void 0,n=e.edge.end?f.get(e.edge.end):void 0;if(t&&n){if(t.row===n.row&&Mt(t.column,n.column,o)){let i=p(e,`H`);i&&At(t.row,i.cross,a,r,s)&&(l&&l.labelSpacingEligibleEdges++,Nt(d,Math.min(t.column,n.column),i.requiredAlongSpan));continue}if(t.column===n.column&&Mt(t.row,n.row,a)){let r=p(e,`V`);r&&At(t.column,r.cross,o,i,c)&&(l&&l.labelSpacingEligibleEdges++,Nt(u,Math.min(t.row,n.row),r.requiredAlongSpan))}}}return{rowGapAfter:u,columnGapAfter:d}}e(Pt,`deriveGridContainerLabelGaps`);var Ft=`[grid]`,It=new Set([`basis`,`bumpX`,`bumpY`,`cardinal`,`catmullRom`,`linear`,`monotoneX`,`monotoneY`,`natural`,`step`,`stepAfter`,`stepBefore`,`rounded`]);function Lt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}e(Lt,`isObjectRecord`);function Rt(e){if(!Lt(e))return{};let t={};return Object.hasOwn(e,`row`)&&(t.row=e.row),Object.hasOwn(e,`column`)&&(t.column=e.column),n(e.horizontalAlign)&&(t.horizontalAlign=e.horizontalAlign),r(e.verticalAlign)&&(t.verticalAlign=e.verticalAlign),t}e(Rt,`ownPlacementFrom`);function zt(e){let t=new Map,n=0;for(let r of e)t.has(r.id)||t.set(r.id,n++);return t}e(zt,`buildGridSourceOrder`);function Bt(e){let t=Lt(e.config?.grid)?e.config.grid:{},i=Lt(t.placements)?t.placements:{},o=new Map;for(let e of Object.keys(i)){let t=i[e],n=Array.isArray(t)?t:[t];o.set(e,n.map(e=>Rt(e)))}return{placements:o,columns:typeof t.columns==`number`&&Number.isFinite(t.columns)&&t.columns>=0?Math.trunc(t.columns):O.columns,rowGap:typeof t.rowGap==`number`&&Number.isFinite(t.rowGap)&&t.rowGap>=0?t.rowGap:O.rowGap,columnGap:typeof t.columnGap==`number`&&Number.isFinite(t.columnGap)&&t.columnGap>=0?t.columnGap:O.columnGap,cellGap:typeof t.cellGap==`number`&&Number.isFinite(t.cellGap)&&t.cellGap>=0?t.cellGap:O.cellGap,containerPadding:typeof t.containerPadding==`number`&&Number.isFinite(t.containerPadding)&&t.containerPadding>=0?t.containerPadding:O.containerPadding,titleGap:typeof t.titleGap==`number`&&Number.isFinite(t.titleGap)&&t.titleGap>=0?t.titleGap:O.titleGap,horizontalAlign:n(t.horizontalAlign)?t.horizontalAlign:O.horizontalAlign,verticalAlign:r(t.verticalAlign)?t.verticalAlign:O.verticalAlign,curve:typeof t.curve==`string`&&It.has(t.curve)?t.curve:O.curve,edgeCornerRadius:a(t.edgeCornerRadius)}}e(Bt,`readGridConfig`);function Vt(e,n){let r=new Map;for(let t of e){let e=t.placementId??t.id;r.set(e,(r.get(e)??0)+1)}for(let[e,i]of n.placements){let n=r.get(e)??0;if(n===0){t.warn(Ft,`Ignoring grid placement for unknown target "${e}"`);continue}i.length>n&&t.warn(Ft,`Ignoring ${i.length-n} extra grid placement occurrence(s) for target "${e}"; found ${n} matching node(s)`)}}e(Vt,`validateGridPlacementMap`);function Ht(e){return(t,n)=>{let r=e.get(t.id)??2**53-1,i=e.get(n.id)??2**53-1;return r===i?h(t.id,n.id):r-i}}e(Ht,`itemComparator`);function Ut(e,n,r,a){let o=e.placementId??e.id,s=r.placements.get(o)?.[a]??{},c=Rt(e.metadata);for(let n of[`row`,`column`,`horizontalAlign`,`verticalAlign`])Object.hasOwn(s,n)&&Object.hasOwn(c,n)&&s[n]!==c[n]&&t.debug(Ft,`metadata overrides placement map`,{nodeId:e.id,field:n,metadata:c[n],config:s[n]});let l=Object.hasOwn(c,`row`)?c.row:s.row,u=Object.hasOwn(c,`column`)?c.column:s.column;return i(o,`row`,l,e.id),i(o,`column`,u,e.id),{item:e,row:l??0,column:u??0,horizontalAlign:c.horizontalAlign??s.horizontalAlign??r.horizontalAlign,verticalAlign:c.verticalAlign??s.verticalAlign??r.verticalAlign,sourceOrder:n.get(e.id)??2**53-1,explicitRow:l!==void 0,explicitColumn:u!==void 0,explicitCell:l!==void 0&&u!==void 0}}e(Ut,`resolveItemPlacement`);function Wt(e,t,n){let r=n;for(;t.has(`${e}:${r}`);)r++;return r}e(Wt,`nextFreeColumn`);function Gt(e,t,n){let r=n;for(;t.has(`${r}:${e}`);)r++;return r}e(Gt,`nextFreeRow`);function Kt(e,t,n){let r=n;for(;;){let n=Math.floor(r/t)+1,i=r%t+1;if(r++,!e.has(`${n}:${i}`))return{row:n,column:i,nextIndex:r}}}e(Kt,`nextAutoCell`);function qt(e,t,n){let r=[...e].sort(Ht(t)),i=new Map,a=r.map(e=>{let r=e.placementId??e.id,a=i.get(r)??0;return i.set(r,a+1),Ut(e,t,n,a)}),o=new Map,s=new Set;for(let e of a){if(!e.explicitCell)continue;let t=`${e.row}:${e.column}`;s.add(t);let n=o.get(t);if(n){if(n.verticalAlign!==e.verticalAlign)throw D(`GRID_CELL_ALIGNMENT_CONFLICT`,`Conflicting vertical alignment in cell (${e.row}, ${e.column})`,{containerId:e.item.parentId??`root`,row:e.row,column:e.column,itemIds:[...n.items.map(e=>e.item.id),e.item.id],values:[...n.items.map(e=>e.verticalAlign),e.verticalAlign]});n.items.push(e)}else o.set(t,{row:e.row,column:e.column,items:[e],width:0,height:0,verticalAlign:e.verticalAlign})}let c=n.columns>0?n.columns:Math.max(1,Math.ceil(Math.sqrt(r.length))),l=0,u=new Map,d=new Map;for(let e of a){if(e.explicitCell)continue;if(e.explicitRow){let t=Wt(e.row,s,u.get(e.row)??1);e.column=t,u.set(e.row,t+1)}else if(e.explicitColumn){let t=Gt(e.column,s,d.get(e.column)??1);e.row=t,d.set(e.column,t+1)}else{let t=Kt(s,c,l);e.row=t.row,e.column=t.column,l=t.nextIndex}let t=`${e.row}:${e.column}`;s.add(t),o.set(t,{row:e.row,column:e.column,items:[e],width:0,height:0,verticalAlign:e.verticalAlign})}return{placements:a,cells:o}}e(qt,`resolveGridPlacements`);var Jt=class extends Error{constructor(e,t,n){super(t),this.reason=e,this.searchStateScope=n,this.name=`GridRoutingResourceLimitError`}static{e(this,`GridRoutingResourceLimitError`)}},W=6,Yt=24,Xt=5e4,Zt=4,Qt=67108864,$t=class{constructor(e,t){this.bands=e,this.strictBoundaryIntervals=t,this.byLow=new Map,this.byHigh=new Map,this.coordinateCount=new Set(e.flatMap(({low:e,high:t})=>[e,t])).size;let n=e.reduce((e,t)=>e+t.intervals.length,0);for(let e of t.values())n+=e.length;this.intervalCount=n;for(let t of e)this.byLow.set(t.low,t),this.byHigh.set(t.high,t);Object.freeze(this.bands),Object.freeze(this)}static{e(this,`CompressedIntervalIndex`)}containingBand(e){let t=0,n=this.bands.length-1;for(;t<=n;){let r=t+n>>>1,i=this.bands[r];if(e<=i.low)n=r-1;else if(e>=i.high)t=r+1;else return i}}overlaps(e,t,n){let r=0,i=e.length;for(;r<i;){let n=r+i>>>1;e[n][1]<=t?r=n+1:i=n}return r<e.length&&e[r][0]<n}intersects(e,t,n){let r=Math.min(t,n),i=Math.max(t,n),a=this.byHigh.get(e),o=this.byLow.get(e),s=a||o?void 0:this.containingBand(e);if(s)return this.overlaps(s.intervals,r,i);if(!a||!o)return!1;let c=0,l=0;for(;c<a.intervals.length&&l<o.intervals.length;){if(Math.max(r,a.intervals[c][0],o.intervals[l][0])<Math.min(i,a.intervals[c][1],o.intervals[l][1]))return!0;a.intervals[c][1]<o.intervals[l][1]?c++:l++}return!1}contains(e,t){let n=this.strictBoundaryIntervals.get(e)??this.containingBand(e)?.intervals;if(!n)return!1;let r=0,i=n.length;for(;r<i;){let e=r+i>>>1;n[e][0]<t?r=e+1:i=e}return r>0&&t<n[r-1][1]}nearestBoundary(e,t,n){let r=this.strictBoundaryIntervals.get(e)??this.containingBand(e)?.intervals;if(!r)return;if(n<0){let e=0,n=r.length;for(;e<n;){let i=e+n>>>1;r[i][1]<=t?e=i+1:n=i}return e>0?r[e-1][1]:void 0}let i=0,a=r.length;for(;i<a;){let e=i+a>>>1;r[e][0]<t?i=e+1:a=e}return i<r.length?r[i][0]:void 0}},en,tn=class{constructor(e){this.backing=e,this[en]=`ImmutableMap`,Object.freeze(this)}static{e(this,`ImmutableMap`)}get size(){return this.backing.size}entries(){return this.backing.entries()}forEach(e,t){for(let[n,r]of this.backing)e.call(t,r,n,this)}get(e){return this.backing.get(e)}has(e){return this.backing.has(e)}keys(){return this.backing.keys()}values(){return this.backing.values()}[(en=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}},nn,rn=class{constructor(e,t){this.base=e,this.overrides=t,this[nn]=`OverlayMap`}static{e(this,`OverlayMap`)}get size(){let e=0;for(let t of this.overrides.keys())this.base.has(t)||e++;return this.base.size+e}materialize(){return new Map([...this.base,...this.overrides])}entries(){return this.materialize().entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}get(e){return this.overrides.get(e)??this.base.get(e)}has(e){return this.overrides.has(e)||this.base.has(e)}keys(){return this.materialize().keys()}values(){return this.materialize().values()}[(nn=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}};function an(e,t){return new Proxy([],{get(n,r){if(r===`length`)return e.length+t.length;if(r===Symbol.iterator)return function*(){yield*e,yield*t};if(typeof r==`string`&&/^\d+$/.test(r)){let n=Number(r);return n<e.length?e[n]:t[n-e.length]}return Reflect.get(Array.prototype,r)}})}e(an,`overlayArray`);function on(e,t,n){return new Proxy([],{get(r,i){if(i===`length`)return n;if(i===Symbol.iterator)return function*(){for(let r=0;r<n;r++)yield t.get(r)??e[r]};if(typeof i==`string`&&/^\d+$/.test(i)){let n=Number(i);return t.get(n)??e[n]}return Reflect.get(Array.prototype,i)}})}e(on,`overrideArray`);var sn=class{constructor(e){this.base=e,this.addedVertices=[],this.adjacencyOverrides=new Map,this.searchAdjacencyOverrides=new Map,this.pointOverrides=new Map,this.undoLog=[],this.resetCount=0}static{e(this,`EndpointOverlayScratch`)}reset(e){if(e!==this.base)throw Error(`Endpoint overlay scratch cannot be shared across base topologies`);for(let e of this.undoLog)this.adjacencyOverrides.delete(e),this.searchAdjacencyOverrides.delete(e);this.undoLog.length=0,this.addedVertices.length=0,this.pointOverrides.clear(),this.resetCount++}setArcs(e,t){this.adjacencyOverrides.has(e)||this.undoLog.push(e),this.adjacencyOverrides.set(e,t),this.searchAdjacencyOverrides.set(e,Cn(t))}};function cn(e){return Object.is(e,-0)?0:e}e(cn,`normalizeCoordinate`);function ln(e){if(![e.left,e.right,e.top,e.bottom].every(Number.isFinite))throw Error(`Grid routing geometry must contain only finite coordinates`);let t=cn(Math.min(e.left,e.right)),n=cn(Math.max(e.left,e.right)),r=cn(Math.min(e.top,e.bottom)),i=cn(Math.max(e.top,e.bottom));if(t===n||r===i)throw Error(`Grid routing rectangles must have positive area`);return{left:t,right:n,top:r,bottom:i}}e(ln,`normalizeRect`);function un(e,t){let n=ln(e.bounds),r={id:e.id,left:Math.max(t.left,n.left-W),right:Math.min(t.right,n.right+W),top:Math.max(t.top,n.top-W),bottom:Math.min(t.bottom,n.bottom+W)};return r.left<r.right&&r.top<r.bottom?r:void 0}e(un,`inflateAndClip`);function dn(e){let t=[...e].sort((e,t)=>e.low-t.low||e.high-t.high||h(e.id,t.id)),n=[];for(let e of t){let t=n.at(-1);if(!t||e.low>t.high){n.push({...e});continue}t.high=Math.max(t.high,e.high),h(e.id,t.id)<0&&(t.id=e.id)}return n}e(dn,`mergeObstacleIntervals`);function fn(e){let t=new Map;for(let n of e){let e=t.get(n.left)??{starts:[],ends:[]};e.starts.push(n),t.set(n.left,e);let r=t.get(n.right)??{starts:[],ends:[]};r.ends.push(n),t.set(n.right,r)}let n=[...t.keys()].sort((e,t)=>e-t),r=new Set,i=[],a=new Map;for(let e=0;e<n.length-1;e++){let o=n[e],s=n[e+1],c=t.get(o);for(let e of c.ends)r.delete(e);for(let e of c.starts)r.add(e);let l=new Map;for(let e of dn([...r].map(e=>({low:e.top,high:e.bottom,id:e.id})))){let t=`${e.low}:${e.high}`,n=a.get(t);if(n)n.right=s,h(e.id,n.id)<0&&(n.id=e.id);else{let n={id:e.id,left:o,right:s,top:e.low,bottom:e.high};i.push(n),l.set(t,n);continue}l.set(t,n)}a=l}return i.sort((e,t)=>e.top-t.top||e.left-t.left||e.bottom-t.bottom||e.right-t.right||h(e.id,t.id))}e(fn,`unionObstacles`);function G(e){return`${cn(e.x)}:${cn(e.y)}`}e(G,`routingPointKey`);function pn(e){return e===`left`?0:e===`right`?1:e===`top`?2:e===`bottom`?3:4}e(pn,`topologySideOrdinal`);function mn(e,t){return h(e.kind,t.kind)||pn(e.side)-pn(t.side)||e.point.x-t.point.x||e.point.y-t.point.y||h(e.ownerId??``,t.ownerId??``)}e(mn,`vertexRecordOrder`);function hn(e){let t=new Map;for(let n of[...e].sort(mn)){let e={...n,point:{x:cn(n.point.x),y:cn(n.point.y)}},r=G(e.point);t.has(r)||t.set(r,e)}return[...t.values()]}e(hn,`canonicalRecords`);function gn(e,t,n=`corner`){return[{point:{x:e.left,y:e.top},kind:n,ownerId:t},{point:{x:e.right,y:e.top},kind:n,ownerId:t},{point:{x:e.left,y:e.bottom},kind:n,ownerId:t},{point:{x:e.right,y:e.bottom},kind:n,ownerId:t}]}e(gn,`cornerRecords`);function _n(e,t){let n=e.coordinate??(e.side===`left`?t.left:e.side===`right`?t.right:e.side===`top`?t.top:t.bottom);return(e.side===`left`||e.side===`right`?[{x:n,y:e.low},{x:n,y:e.high}]:[{x:e.low,y:n},{x:e.high,y:n}]).map(t=>({point:t,kind:`portal`,ownerId:e.ownerId,side:e.side}))}e(_n,`portalRecords`);function vn(e,t,n,r,i){if(t===`left`||t===`right`)return{x:r.nearestBoundary(e.y,e.x,t===`left`?-1:1)??(t===`left`?n.left:n.right),y:e.y};let a=i.nearestBoundary(e.x,e.y,t===`top`?-1:1)??(t===`top`?n.top:n.bottom);return{x:e.x,y:a}}e(vn,`rayHit`);function yn(t,n,r){let i=[...new Set(t.flatMap(e=>n===`H`?[e.top,e.bottom]:[e.left,e.right]))].sort((e,t)=>e-t),a=[],o=new Map,s=new Map,c=new Map;for(let e of t){let t=n===`H`?e.top:e.left,r=n===`H`?e.bottom:e.right,i=s.get(t)??[];i.push(e),s.set(t,i);let a=c.get(r)??[];a.push(e),c.set(r,a)}let l=new Set,u=e(()=>dn([...l].map(e=>n===`H`?{low:e.left,high:e.right,id:e.id}:{low:e.top,high:e.bottom,id:e.id})),`activeIntervals`),d=e(e=>{let n=r.intervalCount+e.length;return xn(bn(0,0,t.length,n),r.maxEstimatedBytes,`estimated_memory_cap`),r.intervalCount=n,Object.freeze(e.map(e=>Object.freeze([e.low,e.high])))},`freezeIntervals`);for(let e=0;e<i.length;e++){let t=i[e];for(let e of c.get(t)??[])l.delete(e);o.set(t,d(u()));for(let e of s.get(t)??[])l.add(e);let n=i[e+1];if(n===void 0)continue;let r=u();r.length>0&&a.push({low:t,high:n,intervals:d(r)})}return new $t(Object.freeze(a),new tn(o))}e(yn,`createIntervalIndex`);function bn(e,t,n,r){return e*64+t*56+n*48+r*24}e(bn,`estimatedTopologyBytes`);function xn(e,t,n){if(e>t)throw new Jt(n,`Grid routing ${n} exceeded: ${e} > ${t}`)}e(xn,`enforceCap`);function Sn(e,t){let n=new Map;for(let r of e){let e=t===`H`?r.point.y:r.point.x,i=n.get(e)??[];i.push(r),n.set(e,i)}for(let e of n.values())e.sort((e,n)=>t===`H`?e.point.x-n.point.x||e.id-n.id:e.point.y-n.point.y||e.id-n.id),Object.freeze(e);return new tn(n)}e(Sn,`indexVertexLines`);function Cn(e){return Object.freeze(e.map(e=>Object.freeze({to:e.to,orientationOrdinal:e.orientation===`H`?1:2,length:e.length,boundaryTransitions:+(e.kind===`portal`)})))}e(Cn,`searchArcs`);function wn(t,n,r,i){let a=hn(t).sort(mn),o=i.maxVertices??Xt;xn(a.length,o,`vertex_cap`);let s=a.map((e,t)=>Object.freeze({id:t,...e,point:Object.freeze({...e.point})})),c=new Map(s.map(e=>[e.id,[]])),l=e((e,t,n)=>{let r=Math.abs(e.point.x-t.point.x)+Math.abs(e.point.y-t.point.y);if(r===0)return;let i=n===`H`?Math.min(e.point.x,t.point.x):Math.min(e.point.y,t.point.y),a=i+r;for(let[o,s]of[[e,t],[t,e]])c.get(o.id).push({from:o.id,to:s.id,orientation:n,length:r,kind:`visibility`,intervalStart:i,intervalEnd:a})},`addArcPair`);for(let e of[`H`,`V`]){let t=new Map;for(let n of s){let r=e===`H`?n.point.y:n.point.x,i=t.get(r)??[];i.push(n),t.set(r,i)}for(let[i,a]of t){a.sort((t,n)=>e===`H`?t.point.x-n.point.x||t.id-n.id:t.point.y-n.point.y||t.id-n.id);for(let t=1;t<a.length;t++){let o=a[t-1],s=a[t],c=e===`H`?o.point.x:o.point.y,u=e===`H`?s.point.x:s.point.y;(e===`H`?n:r).intersects(i,c,u)||l(o,s,e)}}}let u={visibility:0,terminal:1,portal:2,lane:3},d=0,f=new Map;for(let e of s){let t=c.get(e.id);t.sort((e,t)=>u[e.kind]-u[t.kind]||h(e.orientation,t.orientation)||s[e.to].point.x-s[t.to].point.x||s[e.to].point.y-s[t.to].point.y||e.to-t.to);let n=t.filter((e,n)=>n===0||e.to!==t[n-1].to||e.orientation!==t[n-1].orientation||e.kind!==t[n-1].kind);d+=n.length,f.set(e.id,Object.freeze(n.map(e=>Object.freeze(e))))}return xn(d,i.maxAdjacencyEntries??o*Zt,`adjacency_cap`),{vertices:Object.freeze(s),adjacency:new tn(f),adjacencyEntries:d}}e(wn,`buildVisibilityGraph`);function Tn(e,t,n){let r=ln(t),i=n?ln(n):void 0,a=Math.max(r.top+W,(i?.bottom??-1/0)+W),o=r.bottom-W,s=r.left+W,c=r.right-W,l=[];return a<=o&&l.push({ownerId:e,side:`left`,low:a,high:o},{ownerId:e,side:`right`,low:a,high:o}),s<=c&&(l.push({ownerId:e,side:`bottom`,low:s,high:c}),(!i||i.bottom+W<=r.top)&&l.push({ownerId:e,side:`top`,low:s,high:c})),l}e(Tn,`derivePortalRanges`);function En(e,t,n,r,i){let a=Tn(e,t,n).find(e=>e.side===r);if(!a||i<a.low||i>a.high)throw Error(`Illegal ${r} portal for "${e}" at ${i}`);let o=r===`left`?t.left:r===`right`?t.right:r===`top`?t.top:t.bottom,s=r===`left`||r===`top`?o+W:o-W,c=r===`left`||r===`top`?o-W:o+W,l=r===`left`||r===`right`?{x:s,y:i}:{x:i,y:s},u=r===`left`||r===`right`?{x:c,y:i}:{x:i,y:c};return{ownerId:e,side:r,tangentialCoordinate:i,interior:l,exterior:u,transition:{from:l,to:u,orientation:r===`left`||r===`right`?`H`:`V`,length:W*2,kind:`portal`}}}e(En,`buildPairedPortal`);function Dn(e,t={}){let n=ln(e.bounds),r=fn([...e.obstacles,...e.titleExclusions??[]].map(e=>un(e,n)).filter(e=>!!e)),i=[...e.portalRanges??[]].sort((e,t)=>pn(e.side)-pn(t.side)||e.low-t.low||e.high-t.high||h(e.ownerId,t.ownerId)),a=hn([...gn(n,e.containerId),...r.flatMap(e=>gn(e,e.id)),...i.flatMap(e=>_n(e,n))]),o={intervalCount:0,maxEstimatedBytes:t.caps?.maxEstimatedBytes??Qt};xn(bn(0,0,r.length,0),o.maxEstimatedBytes,`estimated_memory_cap`);let s=yn(r,`H`,o),c=yn(r,`V`,o),l=[],u=[`left`,`right`,`top`,`bottom`];for(let e of a)for(let t of u){let r=vn(e.point,t,n,s,c);(r.x!==e.point.x||r.y!==e.point.y)&&l.push({point:r,kind:`projection`,side:t})}let{vertices:d,adjacency:f,adjacencyEntries:p}=wn([...a,...l],s,c,t.caps??{}),m=bn(d.length,p,r.length,s.intervalCount+c.intervalCount);return xn(m,t.caps?.maxEstimatedBytes??Qt,`estimated_memory_cap`),t.metrics&&(t.metrics.containersBuilt++,t.metrics.baseTopologyBuilds++,t.metrics.baseVertices+=d.length,t.metrics.baseAdjacencyEntries+=p,t.metrics.buildSweepEvents+=a.length*4+r.length*4,t.metrics.estimatedBytes+=m),Object.freeze({containerId:e.containerId,bounds:Object.freeze(n),obstacles:Object.freeze(r.map(e=>Object.freeze(e))),vertices:Object.freeze(d),pointVertexIds:new tn(new Map(d.map(({id:e,point:t})=>[G(t),e]))),horizontalVertexLines:Sn(d,`H`),verticalVertexLines:Sn(d,`V`),adjacency:f,adjacencyByVertex:Object.freeze(d.map(({id:e})=>f.get(e)??[])),searchAdjacencyByVertex:Object.freeze(d.map(({id:e})=>Cn(f.get(e)??[]))),adjacencyEntries:p,horizontalIntervals:s,verticalIntervals:c,portalRanges:Object.freeze(i.map(e=>Object.freeze(e))),seedCount:a.length,estimatedBytes:m})}e(Dn,`buildContainerRoutingTopology`);function On(e,t){return t.contains(e.y,e.x)}e(On,`pointInsideObstacle`);function kn(t,n,r,i,a,o=[]){let s=a??new sn(t);s.reset(t);let c=[{point:n,kind:`endpoint`,ownerId:`source`},{point:r,kind:`endpoint`,ownerId:`target`},...o.filter(e=>!On(e,t.horizontalIntervals)).map(e=>({point:e,kind:`lane`}))];for(let e of[{x:n.x,y:r.y},{x:r.x,y:n.y}])On(e,t.horizontalIntervals)||c.push({point:e,kind:`projection`});for(let e of c.slice(0,2))for(let n of[`left`,`right`,`top`,`bottom`]){let r=vn(e.point,n,t.bounds,t.horizontalIntervals,t.verticalIntervals);(r.x!==e.point.x||r.y!==e.point.y)&&c.push({point:r,kind:`projection`,side:n})}let l=hn(c).filter(({point:e})=>!t.pointVertexIds.has(G(e))).sort(mn);xn(l.length,32,`vertex_cap`),s.addedVertices.push(...l.map((e,n)=>Object.freeze({id:t.vertices.length+n,...e,point:Object.freeze({...e.point})})));let u=an(t.vertices,s.addedVertices),d=e(e=>e<t.vertices.length?t.vertices[e]:s.addedVertices[e-t.vertices.length],`vertexAt`),f=new Map,p=e(e=>{let n=f.get(e);return n||(n=[...t.adjacency.get(e)??[]],f.set(e,n)),n},`mutableArcs`);for(let e of s.addedVertices)f.set(e.id,[]);let m=new Set(s.addedVertices.map(({id:e})=>e)),g=new Set,_=e((e,n,r)=>{let i=Math.abs(e.point.x-n.point.x)+Math.abs(e.point.y-n.point.y);if(i===0)return;let a=r===`H`?Math.min(e.point.x,n.point.x):Math.min(e.point.y,n.point.y),o=a+i;for(let[s,c]of[[e,n],[n,e]]){let e=`${s.id}:${c.id}:${r}:visibility`;g.has(e)||(t.adjacency.get(s.id)??[]).some(e=>e.to===c.id&&e.orientation===r&&e.kind===`visibility`)||(g.add(e),p(s.id).push({from:s.id,to:c.id,orientation:r,length:i,kind:`visibility`,intervalStart:a,intervalEnd:o}))}},`connect`);for(let e of[`H`,`V`]){let n=e===`H`?t.horizontalVertexLines:t.verticalVertexLines,r=new Set(s.addedVertices.map(({point:t})=>e===`H`?t.y:t.x));for(let i of r){let r=[...n.get(i)??[],...s.addedVertices.filter(({point:t})=>(e===`H`?t.y:t.x)===i)];r.sort((t,n)=>e===`H`?t.point.x-n.point.x||t.id-n.id:t.point.y-n.point.y||t.id-n.id);for(let n=1;n<r.length;n++){let a=r[n-1],o=r[n];if(!m.has(a.id)&&!m.has(o.id))continue;let s=e===`H`?a.point.x:a.point.y,c=e===`H`?o.point.x:o.point.y;(e===`H`?t.horizontalIntervals:t.verticalIntervals).intersects(i,s,c)||_(a,o,e)}}}for(let[e,t]of f){t.sort((e,t)=>h(e.kind,t.kind)||h(e.orientation,t.orientation)||d(e.to).point.x-d(t.to).point.x||d(e.to).point.y-d(t.to).point.y||e.to-t.to);let n=Object.freeze(t.map(e=>Object.freeze(e)));s.setArcs(e,n)}let v=t.adjacencyEntries+g.size;xn(v,t.adjacencyEntries+64,`adjacency_cap`);let y=l.length,b=t.estimatedBytes+y*64+(v-t.adjacencyEntries)*56;i&&(i.endpointOverlayBuilds++,i.endpointOverlayVertices+=y,i.estimatedBytes=Math.max(i.estimatedBytes,b));let x=t.vertices.length+s.addedVertices.length,S=on(t.adjacencyByVertex,s.adjacencyOverrides,x),C=on(t.searchAdjacencyByVertex,s.searchAdjacencyOverrides,x);for(let e of s.addedVertices)s.pointOverrides.set(G(e.point),e.id);return Object.freeze({...t,vertices:u,pointVertexIds:new rn(t.pointVertexIds,s.pointOverrides),adjacency:new rn(t.adjacency,s.adjacencyOverrides),adjacencyByVertex:S,searchAdjacencyByVertex:C,adjacencyEntries:v,estimatedBytes:b,vertexCount:x,getVertex:d,getSearchArcs:e(e=>s.searchAdjacencyOverrides.get(e)??t.searchAdjacencyByVertex[e]??[],`getSearchArcs`)})}e(kn,`buildEndpointRoutingOverlay`);var An=4,K=20,jn=8;function Mn(e){return!!e.groupTitleRect}e(Mn,`ownerGroupTitle`);function Nn(e,t){return JSON.stringify([e,t])}e(Nn,`ownerSideKey`);function Pn(e,t){let n=g(e),r=t.x-n.cx,i=t.y-n.cy,a=e.isGroup&&Mn(e);return Math.abs(r)>=Math.abs(i)?r>=0?`right`:`left`:i>=0?`bottom`:a?r>=0?`right`:`left`:`top`}e(Pn,`preferredSide`);function Fn(e,t){let n=[],r=e.parentId??T,i=new Set;for(;n.push(r),!(r===T||i.has(r));)i.add(r),r=t.get(r)?.parentId??T;return n}e(Fn,`containerChain`);function In(e,t,n){if(e.isGroup&&Dt(e.id,t,n))return e.parentId??T;if(t.isGroup&&Dt(t.id,e,n))return t.parentId??T;let r=new Set(Fn(t,n));for(let t of Fn(e,n))if(r.has(t))return t;return T}e(In,`commonContainerId`);function Ln(e,t){return t===`left`||t===`right`?e.cy:e.cx}e(Ln,`oppositeCoordFor`);function Rn(e,t){return t===`left`||t===`right`?{x:t===`left`?e.left:e.right,y:e.cy}:{x:e.cx,y:t===`top`?e.top:e.bottom}}e(Rn,`sideMidpoint`);function zn(e,t){return t===`left`||t===`right`?e.y:e.x}e(zn,`tangentialCoordinate`);function Bn(e,t,n,r,i,a){let o=[],s=g(e),c=g(t),u={x:t.x??0,y:t.y??0},d=e;for(;;){let f=d.parentId??T,p=r.get(f),m={x:d.x??0,y:d.y??0},h=u.x-m.x,g=u.y-m.y,_=g<0&&Math.abs(h)<=l&&!!((d.isGroup?d.groupTitleRect:void 0)??p?.groupTitleRect),v=[];Math.abs(Math.abs(h)-Math.abs(g))<=l&&Math.abs(h)>l&&v.push(h>=0?`right`:`left`,g>=0?`bottom`:`top`);let y=!!((d.isGroup?d.groupTitleRect:void 0)??p?.groupTitleRect),b=(_?[`left`,`right`]:v).filter(e=>e!==`top`||!y),x=Pn(d,u);if(x===`top`&&p?.groupTitleRect&&(x=h>=0?`right`:`left`),o.push({ownerId:d.id,side:x,demandKey:JSON.stringify([i,a,d.id,x]),oppositeCoord:Ln(c,x),preferredCoord:Ln(s,x),compactPortal:d.id!==e.id,ambiguousSides:b.length>1?b:void 0,inner:o.length?{demandKey:o[o.length-1].demandKey,side:o[o.length-1].side}:void 0}),d.isGroup&&d.id===n&&Dt(d.id,t,r))return{chain:o,finalKind:`boundary`};if(f===n)return{chain:o,finalKind:`item`};if(!p?.isGroup)throw D(`GRID_INVALID_CONTAINMENT`,`Missing parent group "${f}"`,{traversedIds:o.map(e=>e.ownerId)});d=p}}e(Bn,`buildEndpointPlan`);function Vn(e){let t=new Map;for(let n of e){if(!n.start||!n.end)continue;let e=n.start<n.end?`${n.start}|${n.end}`:`${n.end}|${n.start}`;t.has(e)||t.set(e,[]),t.get(e).push(n)}let n=new Map;for(let[e,r]of t)r.sort((e,t)=>h(`${e.start}|${e.end}`,`${t.start}|${t.end}`)||h(e.id,t.id)),r.forEach((t,i)=>n.set(t.id,{index:i,size:r.length,offset:(i-(r.length-1)/2)*jn,pairKey:e}));return n}e(Vn,`buildPairLanes`);function Hn(t,n){let r=new Map,i=e((e,t)=>Nn(e,t),`reservationKey`);for(let e of t)for(let t of[...e.source.chain,...e.target.chain])if(!t.ambiguousSides){let e=i(t.ownerId,t.side);r.set(e,(r.get(e)??0)+1)}let a=e((e,t,a)=>{let o=t.chain.filter(({ambiguousSides:e})=>e);if(o.length===0)return;let s=[`right`,`bottom`,`left`,`top`].filter(e=>o.every(t=>t.ambiguousSides?.includes(e))&&o.every(t=>{let r=n.forest.nodeById.get(t.ownerId);return r!==void 0&&q(r,e)!==void 0})).sort((e,t)=>o.reduce((t,n)=>t+(r.get(i(n.ownerId,e))??0),0)-o.reduce((e,n)=>e+(r.get(i(n.ownerId,t))??0),0)||Number(e!==o[0].side)-Number(t!==o[0].side))[0];if(s){for(let e of o){e.side=s;let t=i(e.ownerId,s);r.set(t,(r.get(t)??0)+1);let a=n.forest.nodeById.get(e.ownerId);a&&(e.preferredCoord=Ln(g(a),s))}for(let[n,r]of t.chain.entries())r.demandKey=JSON.stringify([e.edge.id,a,r.ownerId,r.side]),r.inner=n>0?{demandKey:t.chain[n-1].demandKey,side:t.chain[n-1].side}:void 0}},`resolveEndpoint`),o=t.flatMap(e=>[{plan:e,endpoint:e.source,role:`source`},{plan:e,endpoint:e.target,role:`target`}]).sort((e,t)=>h(`${e.plan.edge.start??``}|${e.plan.edge.end??``}|${e.plan.edge.id}|${e.role}`,`${t.plan.edge.start??``}|${t.plan.edge.end??``}|${t.plan.edge.id}|${t.role}`));for(let{plan:e,endpoint:t,role:n}of o)a(e,t,n);for(let e of t){let t=e.source.chain.at(-1),r=e.target.chain.at(-1),i=t?n.forest.nodeById.get(t.ownerId):void 0,a=r?n.forest.nodeById.get(r.ownerId):void 0;if(!t||!r||!i||!a)continue;let o=Rn(g(i),t.side),s=Rn(g(a),r.side);for(let t of e.source.chain)t.oppositeCoord=zn(s,t.side);for(let t of e.target.chain)t.oppositeCoord=zn(o,t.side)}}e(Hn,`resolveAmbiguousEndpointSides`);function Un(e,t){let n=t.forest.nodeById,r=Vn(e.edges),i=e.edges.map(e=>{let t=e.start?n.get(e.start):void 0,i=e.end?n.get(e.end):void 0;if(!t||!i)throw D(`GRID_MISSING_ENDPOINT`,`Missing endpoint for edge "${e.id}"`,{edgeId:e.id,start:e.start,end:e.end});let a=In(t,i,n),o=r.get(e.id)??{index:0,size:1,offset:0,pairKey:qn(e)};return{edge:e,lcaContainerId:a,source:Bn(t,i,a,n,e.id,`source`),target:Bn(i,t,a,n,e.id,`target`),laneIndex:o.index,laneOffset:o.offset,bundleSize:o.size,pairKey:o.pairKey}});return Hn(i,t),i}e(Un,`collectRoutePlans`);function Wn(e,t,n){let r=[];for(let[t,n]of e.entries())r.push(t===0?n:Math.max(n,r[t-1]+An));for(let e=r.length-1;e>=0;e--)r[e]=Math.min(r[e],e===r.length-1?n:r[e+1]-An);let i=e.reduce((e,t)=>e+t,0)/e.length,a=r.reduce((e,t)=>e+t,0)/r.length,o=t-r[0],s=n-r[r.length-1],c=w(i-a,o,s);return r.map(e=>e+c)}e(Wn,`assignCompactPortalCoordinates`);function Gn(t,n,r){let i=n.forest.nodeById,a=new Map(t.map(e=>[e.edge.id,e])),o=new Map;for(let e of t)if(e.edge.start!==e.edge.end)for(let t of[...e.source.chain,...e.target.chain])o.has(t.demandKey)||o.set(t.demandKey,{ownerId:t.ownerId,side:t.side,edgeId:e.edge.id,demandKey:t.demandKey,oppositeCoord:t.oppositeCoord,preferredCoord:t.preferredCoord,compactPortal:t.compactPortal,inner:t.inner});let s=new Map;for(let e of o.values()){let t=Nn(e.ownerId,e.side),n=s.get(t)??{ownerId:e.ownerId,side:e.side,demands:[]};n.demands.push(e),s.set(t,n)}let c=e(e=>{let t=i.get(e);return t?Fn(t,i).length:0},`depthOf`),u=[...s.values()].sort((e,t)=>Number(e.demands.every(e=>e.compactPortal))-Number(t.demands.every(e=>e.compactPortal))||c(t.ownerId)-c(e.ownerId)),d=new Map;for(let{ownerId:t,side:s,demands:c}of u){let u=i.get(t);if(!u)continue;let f=g(u),p=s===`left`||s===`right`?f.top+W:f.left+W,m=s===`left`||s===`right`?f.bottom-W:f.right-W;(s===`left`||s===`right`)&&u.groupTitleRect&&(p=Math.max(p,u.groupTitleRect.bottom+W));let _=Math.max(0,m-p);c.sort((e,t)=>e.oppositeCoord-t.oppositeCoord||h(e.edgeId,t.edgeId));let v=c.map(e=>a.get(e.edgeId)),y=new Set(v.map(e=>e?.pairKey)),b=u.isGroup&&c.every(({compactPortal:e})=>e);if(!(b&&c.length===1)&&y.size===1&&v.every(e=>e&&e.bundleSize===c.length&&r.get(e.edge.start)===e.bundleSize&&r.get(e.edge.end)===e.bundleSize)){let e=(p+m)/2,t=v.map(t=>e+t.laneOffset);if(t.every(e=>e>=p&&e<=m)){c.forEach((e,n)=>d.set(e.demandKey,t[n]));continue}}if(b){let t=n.containers.get(u.id),r=s===`left`||s===`right`?t?.horizontalCorridors:t?.verticalCorridors,a=e(e=>{let t=e.inner?o.get(e.inner.demandKey):void 0,n=t?i.get(t.ownerId):void 0,r=t?d.get(t.demandKey):void 0;if(!t||!n||r===void 0)return e.preferredCoord;let a=Rn(g(n),t.side);return t.side===`left`||t.side===`right`?a.y=r:a.x=r,zn(a,s)},`innerCoordinate`),f=e(e=>{let t=e.inner?d.get(e.inner.demandKey):void 0,n=w(e.inner!==void 0&&t!==void 0&&(e.inner.side===`left`||e.inner.side===`right`)==(s===`left`||s===`right`)?t:e.preferredCoord,p,m),i=r?.reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e,r[0]);return i!==void 0&&Math.abs(i-n)<=l?i:n},`preferredCoordinate`);if(c.length===1){d.set(c[0].demandKey,f(c[0]));continue}if(_>=An*(c.length-1)){c.sort((e,t)=>a(e)-a(t)||e.oppositeCoord-t.oppositeCoord||h(e.edgeId,t.edgeId));let e=Wn(c.map(f),p,m);c.forEach((t,n)=>d.set(t.demandKey,e[n]));continue}}if(c.length===1||_<=0){d.set(c[0].demandKey,(p+m)/2);continue}let x=_/(c.length-1);c.forEach((e,t)=>{d.set(e.demandKey,p+x*t)})}for(let n of t){if(n.bundleSize!==1)continue;let t=n.source.chain.at(-1),r=n.target.chain.at(-1);if(!t||!r)continue;let a=e(e=>e===`left`||e===`right`,`verticalSide`);if(a(t.side)!==a(r.side))continue;let o=d.get(t.demandKey),s=d.get(r.demandKey);if(o===void 0||s===void 0||Math.abs(o-s)>l)continue;let c=[...n.source.chain,...n.target.chain];if(c.some(e=>a(e.side)!==a(t.side)))continue;let u=[o,s].find(e=>c.every(t=>{let n=i.get(t.ownerId),r=n?q(n,t.side):void 0;return r!==void 0&&e>=r.low-l&&e<=r.high+l}));u!==void 0&&c.forEach(e=>d.set(e.demandKey,u))}return d}e(Gn,`assignDemandCoordinates`);function Kn(e){return e===`right`?0:e===`bottom`?1:e===`left`?2:3}e(Kn,`sideOrder`);function q(e,t){let n=g(e);if(t===`top`&&e.groupTitleRect)return;let r=t===`left`||t===`right`?n.top+W:n.left+W,i=t===`left`||t===`right`?n.bottom-W:n.right-W;return(t===`left`||t===`right`)&&e.groupTitleRect&&(r=Math.max(r,e.groupTitleRect.bottom+W)),r<=i?{low:r,high:i}:void 0}e(q,`sideInterval`);function qn(e){let t=e.start??``,n=e.end??``;return t<n?`${t}|${n}`:`${n}|${t}`}e(qn,`endpointPairKey`);function Jn(e,t,n){let r=g(e.opposite),i=g(t.opposite);return(n===`left`||n===`right`?r.cy:r.cx)-(n===`left`||n===`right`?i.cy:i.cx)||h(qn(e.plan.edge),qn(t.plan.edge))||h(`${e.plan.edge.start}|${e.plan.edge.end}`,`${t.plan.edge.start}|${t.plan.edge.end}`)||h(e.plan.edge.id,t.plan.edge.id)||h(e.role,t.role)}e(Jn,`compareEndpointDemands`);function Yn(e){return`${e.plan.edge.id}:${e.role}`}e(Yn,`endpointDemandKey`);function Xn(e,t){return h(qn(e.plan.edge),qn(t.plan.edge))||h(`${e.plan.edge.start}|${e.plan.edge.end}`,`${t.plan.edge.start}|${t.plan.edge.end}`)||h(e.plan.edge.id,t.plan.edge.id)||h(e.role,t.role)}e(Xn,`compareEndpointDemandIdentity`);function Zn(e,t,n){let r=q(e,t);if(!r||n.length===0)return new Map;let i=[...n].sort((e,n)=>Jn(e,n,t));if(i.length===1){let n=g(e),a=t===`left`||t===`right`?n.cy:n.cx;return new Map([[i[0],w(a,r.low,r.high)]])}if((r.high-r.low)/(i.length-1)<An)return new Map(i.map((e,t)=>[e,r.low+t*(r.high-r.low)/(i.length-1)]));let a=Wn(i.map(({opposite:e})=>{let n=g(e);return w(t===`left`||t===`right`?n.cy:n.cx,r.low,r.high)}),r.low,r.high);return new Map(i.map((e,t)=>[e,a[t]]))}e(Zn,`preferredEndpointCoordinates`);function Qn(e,t){let n=q(e,t);return n?1+Math.floor((n.high-n.low)/An):0}e(Qn,`endpointSideCapacity`);function $n(e,t){let n=g(t.opposite),r=Pn(e,{x:n.cx,y:n.cy});return[`right`,`bottom`,`left`,`top`].filter(t=>Qn(e,t)>0).sort((t,i)=>{if(t===r)return-1;if(i===r)return 1;let a=g(e),o=Rn(a,t),s=Rn(a,i);return Math.abs(o.x-n.cx)+Math.abs(o.y-n.cy)-(Math.abs(s.x-n.cx)+Math.abs(s.y-n.cy))||Kn(t)-Kn(i)})}e($n,`endpointSidePreferences`);function er(e,t){let n=g(e),r=g(t.opposite);return Math.abs(n.cx-r.cx)<=l||Math.abs(n.cy-r.cy)<=l}e(er,`isAxisAlignedDemand`);function tr(e,t,n,r){let i=q(e,t);if(!i)return;let a=[...n],o=new Map;for(let e of r){let n=g(e.opposite),r=w(t===`left`||t===`right`?n.cy:n.cx,i.low,i.high),s=[r,i.low,i.high,...a.flatMap(e=>[e-Yt,e+Yt])].filter(e=>e>=i.low-l&&e<=i.high+l&&a.every(t=>Math.abs(e-t)>=Yt-l)).sort((e,t)=>Math.abs(e-r)-Math.abs(t-r)||e-t);if(s.length===0)return;o.set(e,s[0]),a.push(s[0])}return o}e(tr,`placePortsBesideFixed`);function nr(t,n){let r=new Map,i=new Map([`right`,`bottom`,`left`,`top`].map(e=>[e,Qn(t,e)])),a=[...n].sort(Xn),o=a.filter(e=>er(t,e)),s=a.filter(e=>!er(t,e)),c=new Set,l=new Map,u=new Map,d=e(e=>(r.get(e)?.length??0)<(i.get(e)??0),`hasCapacity`),f=e((e,t)=>{let n=r.get(t)??[];n.push(e),r.set(t,n)},`record`),p=e(e=>{let n=$n(t,e).find(d);n&&(f(e,n),c.add(n))},`assignAligned`),m=e((e,n)=>{let r=u.get(n)??new Map,i=tr(t,n,[...l.get(n)??[],...r.values()],[e]);return i?(r.set(e,i.get(e)),u.set(n,r),f(e,n),!0):!1},`tryShareReservedSide`),h=e(e=>{let n=$n(t,e).filter(d),r=n.find(e=>!c.has(e));if(n.find(t=>(r===void 0||n.indexOf(t)<n.indexOf(r))&&c.has(t)&&m(e,t)))return;let i=r??n[0];i&&f(e,i)},`assignUnaligned`);for(let e of o)p(e);for(let[e,n]of r)l.set(e,[...Zn(t,e,n).values()]);for(let e of s)h(e);let g=new Map;for(let[e,n]of r){let r=q(t,e);if(!r)continue;let i=u.get(e),a=i?n.filter(e=>!i.has(e)):n,o=new Map([...Zn(t,e,a),...i??[]]),s=[...n].sort((t,n)=>Jn(t,n,e));for(let[t,n]of s.entries()){let i=o.get(n)??(s.length===1?(r.low+r.high)/2:r.low+t*(r.high-r.low)/(s.length-1));g.set(Yn(n),{side:e,coordinate:i})}}return g}e(nr,`allocateEndpointSlots`);function rr(t,n,r,i,a,o){let s=n===`source`?t.edge.start:t.edge.end,c=n===`source`?t.edge.end:t.edge.start,l=o.forest.nodeById.get(s),u=o.forest.nodeById.get(c);if(!l||!u)throw D(`GRID_MISSING_ENDPOINT`,`Missing endpoint for edge "${t.edge.id}"`);let d=g(u),f=[],p=new Set,m=i.get(s)?.get(`${t.edge.id}:${n}`),h=a.has(s)&&m!==void 0,_=e((e,t,n)=>{let r=q(l,e);if(!r||t<r.low||t>r.high)return;let i=g(l),a=e===`left`||e===`right`?{x:e===`left`?i.left:i.right,y:t}:{x:t,y:e===`top`?i.top:i.bottom},o=`${e}:${G(a)}`;p.has(o)||(p.add(o),f.push({ownerId:s,side:e,port:a,connect:{x:a.x+(e===`left`?-K:e===`right`?K:0),y:a.y+(e===`top`?-K:e===`bottom`?K:0)},rank:n,onAssignedSide:h?e===m.side:void 0}))},`addCandidate`);if(m&&t.bundleSize===1&&_(m.side,m.coordinate,-2),t.bundleSize>1){let e=Pn(l,{x:d.cx,y:d.cy}),n=g(l);_(e,(e===`left`||e===`right`?n.cy:n.cx)+t.laneOffset,-1)}let v=[...r.get(s)??[]];for(let e of[`right`,`bottom`,`left`,`top`]){if(!q(l,e))continue;let r=Zn(l,e,v),i=v.find(e=>e.plan===t&&e.role===n),a=i?r.get(i):void 0;if(a===void 0)continue;let o=g(l),s=e===`left`||e===`right`?{x:e===`left`?o.left:o.right,y:a}:{x:a,y:e===`top`?o.top:o.bottom};_(e,a,Math.abs(s.x-d.cx)+Math.abs(s.y-d.cy))}return f.sort((e,t)=>e.rank-t.rank||Kn(e.side)-Kn(t.side)),f.forEach((e,t)=>{e.rank=t}),f}e(rr,`endpointCandidates`);function ir(t,n){let r=Un(t,n),i=new Map,a=new Map;for(let e of r){let t=qn(e.edge);i.set(t,(i.get(t)??0)+1),e.edge.start&&a.set(e.edge.start,(a.get(e.edge.start)??0)+1),e.edge.end&&e.edge.end!==e.edge.start&&a.set(e.edge.end,(a.get(e.edge.end)??0)+1)}let o=r.filter(e=>e.edge.start!==e.edge.end&&e.source.chain.length===1&&e.target.chain.length===1&&e.source.finalKind===`item`&&e.target.finalKind===`item`),s=new Map;for(let e of o){let t=n.forest.nodeById.get(e.edge.start),r=n.forest.nodeById.get(e.edge.end);if(!t||!r)continue;let i=s.get(t.id)??[];i.push({plan:e,role:`source`,opposite:r}),s.set(t.id,i);let a=s.get(r.id)??[];a.push({plan:e,role:`target`,opposite:t}),s.set(r.id,a)}let c=new Map([...s].map(([e,t])=>{let r=n.forest.nodeById.get(e);return[e,r?nr(r,t):new Map]})),l=new Set,u=new Set;for(let[e,t]of s){let r=n.forest.nodeById.get(e);if(!r)continue;let i=t.some(e=>er(r,e)),a=t.some(e=>!er(r,e));if(i&&a){u.add(e);for(let e of t)er(r,e)||l.add(e.plan.edge.id)}}let d=new Map(o.map(e=>[e.edge.id,{sources:rr(e,`source`,s,c,u,n),targets:rr(e,`target`,s,c,u,n)}])),f=new Map([...d].map(([e,t])=>[e,t.sources.length*t.targets.length])),p=e(e=>{let t=n.forest.nodeById.get(e.edge.start),r=n.forest.nodeById.get(e.edge.end);return e.edge.start===e.edge.end?0:t?.isGroup&&r&&Dt(t.id,r,n.forest.nodeById)||r?.isGroup&&t&&Dt(r.id,t,n.forest.nodeById)?1:(t?.parentId??T)===(r?.parentId??T)?i.get(qn(e.edge))>1?3:4:2},`routeClass`),m=[...r].sort((e,t)=>{let n=qn(e.edge),r=qn(t.edge),i=`${e.edge.start??``}|${e.edge.end??``}`,a=`${t.edge.start??``}|${t.edge.end??``}`,o=e.source.chain.length+e.target.chain.length-2,s=t.source.chain.length+t.target.chain.length-2;return p(e)-p(t)||s-o||(f.get(e.edge.id)??0)-(f.get(t.edge.id)??0)||h(n,r)||h(i,a)||h(e.edge.id,t.edge.id)});return{plans:r,eligiblePlans:o,eligibleIds:new Set(o.map(({edge:e})=>e.id)),orderedPlans:m,demandCoords:Gn(m,n,a),endpointCandidatesByEdge:d,endpointIncidentCounts:a,coordinatedEndpointIds:l}}e(ir,`prepareEdgeRoutes`);function ar(e){if(!(e instanceof Error)||!(`details`in e))return!1;let t=e.details;return typeof t==`object`&&!!t&&`reason`in t&&t.reason===`pair-separation`}e(ar,`isPairSeparationError`);function or(e){let t=g(e);return{left:t.left,right:t.right,top:t.top,bottom:t.bottom}}e(or,`routerRect`);function sr(e){if(e.length<2||e.some(({x:e,y:t})=>!Number.isFinite(e)||!Number.isFinite(t)))return;let t=[{...e[0]}];for(let n=1;n<e.length;n++){let r=e[n],i=t.at(-1);if(!(Math.abs(r.x-i.x)<=l&&Math.abs(r.y-i.y)<=l)){t.push({...r});continue}if(n===e.length-1){for(;t.length>1;){let e=t.at(-2);if(Math.abs(r.x-e.x)>l||Math.abs(r.y-e.y)>l)break;t.pop()}if(t.length===1)return;t[t.length-1]={...r}}}if(t.length<2)return;let n=[];for(let e=0;e<t.length-1;e++){let r=t[e],i=t[e+1],a=Math.abs(i.x-r.x);if(Math.abs(i.y-r.y)<=l)n.push(`H`);else if(a<=l)n.push(`V`);else return}let r=t.map(e=>({...e}));for(let e=0;e<n.length;){let i=n[e],a=e+1;for(;a<n.length&&n[a]===i;)a++;let o=i===`H`?`y`:`x`;if(e===0&&a===t.length-1&&t[e][o]!==t[a][o])return;let s=a===t.length-1?t[a][o]:t[e][o];for(let n=e;n<=a;n++){if(Math.abs(t[n][o]-s)>l)return;r[n][o]=s}e=a}return r}e(sr,`canonicalizeOrthogonalPolyline`);function cr(e,t,n){return e.y===t.y?e.y>n.top&&e.y<n.bottom&&Math.max(e.x,t.x)>n.left&&Math.min(e.x,t.x)<n.right:e.x!==t.x||e.x>n.left&&e.x<n.right&&Math.max(e.y,t.y)>n.top&&Math.min(e.y,t.y)<n.bottom}e(cr,`segmentEntersRect`);function lr(e){let t=or(e);return{left:t.left-W,right:t.right+W,top:t.top-W,bottom:t.bottom+W}}e(lr,`inflatedRect`);function J(e,t,n,r,i){let a=sr(e);if(!a)return!1;let o=p(a);if(o.points.length<2||o.segments.length>1&&(Math.abs(o.segments[0].a.x-o.segments[0].b.x)+Math.abs(o.segments[0].a.y-o.segments[0].b.y)<K||Math.abs(o.segments.at(-1).a.x-o.segments.at(-1).b.x)+Math.abs(o.segments.at(-1).a.y-o.segments.at(-1).b.y)<K))return!1;let s=(i.forest.childrenByParent.get(r)??[]).filter(e=>!k(e));for(let e of s){let r=lr(e);for(let i=0;i<o.points.length-1;i++){if(e.id===t.id&&i===0||e.id===n.id&&i===o.points.length-2){if(cr(o.points[i],o.points[i+1],or(e)))return!1;continue}if(cr(o.points[i],o.points[i+1],r))return!1}}return!0}e(J,`validateSameContainerRoute`);function ur(e,t,n,r,i){let a=sr(e);if(!a)return!1;let o=p(a);if(o.points.length<2)return!1;let s=(i.forest.childrenByParent.get(r)??[]).filter(e=>!k(e));for(let e of s){let r=lr(e);for(let i=0;i<o.points.length-1;i++){if(e.id===t&&i===0||e.id===n&&i===o.points.length-2){if(cr(o.points[i],o.points[i+1],or(e)))return!1;continue}if(cr(o.points[i],o.points[i+1],r))return!1}}return!0}e(ur,`validateContainerSegment`);function dr(e){return e.orientation===`H`?{low:Math.min(e.a.x,e.b.x),high:Math.max(e.a.x,e.b.x)}:{low:Math.min(e.a.y,e.b.y),high:Math.max(e.a.y,e.b.y)}}e(dr,`segmentSpan`);function fr(t){let n=p([...t]).segments.filter(e=>e.orientation!==`Z`).map(e=>({a:{...e.a},b:{...e.b},orientation:e.orientation}));if(n.length===0||n.length===1&&Math.abs(n[0].a.x-n[0].b.x)+Math.abs(n[0].a.y-n[0].b.y)<=K*2)return[];let r=e((e,t)=>{if(e.orientation===`H`){let n=Math.sign(e.b.x-e.a.x);t?e.a.x+=n*K:e.b.x-=n*K}else{let n=Math.sign(e.b.y-e.a.y);t?e.a.y+=n*K:e.b.y-=n*K}},`trim`);return r(n[0],!0),r(n[n.length-1],!1),n.filter(({a:e,b:t})=>e.x!==t.x||e.y!==t.y)}e(fr,`nonterminalSegments`);function pr(e,t){if(e.orientation!==t.orientation)return!1;let n=dr(e),r=dr(t),i=Math.max(0,Math.min(n.high,r.high)-Math.max(n.low,r.low));if(i<=0)return!1;let a=e.orientation===`H`?Math.abs(e.a.y-t.a.y):Math.abs(e.a.x-t.a.x);return a===0&&i>=jn||a>0&&a<jn}e(pr,`pairSegmentsConflict`);function Y(e,t){let n=p([...e]).points,r=[n[0],n.at(-1)],i=fr(n);return t.every(e=>{let t=p([...e]).points,n=[t[0],t.at(-1)];return!r.some(e=>n.some(t=>e.x===t.x&&e.y===t.y))&&i.every(e=>fr(t).every(t=>!pr(e,t)))})}e(Y,`routeSatisfiesPairConstraints`);function mr(e,t){let n=p([...e]).points,r=[n[0],n.at(-1)];return t.every(e=>{let t=p([...e]).points,n=[t[0],t.at(-1)];return!r.some(e=>n.some(t=>e.x===t.x&&e.y===t.y))})}e(mr,`routeHasDistinctPairPorts`);function hr(e,t,n){let r={a:e,b:t,orientation:e.y===t.y?`H`:`V`};return n.every(e=>fr(e).every(e=>!pr(r,e)))}e(hr,`pairArcAllowed`);function gr(e,t){let n=e.side===`left`||e.side===`right`?`H`:`V`,r=t.side===`left`||t.side===`right`?`H`:`V`,i=Math.abs(e.connect.x-t.connect.x),a=Math.abs(e.connect.y-t.connect.y),o;if(i===0&&a===0)o=Number(n!==r);else if(i===0||a===0){let e=i===0?`V`:`H`;o=Number(n!==e)+Number(r!==e)}else o=Math.min(Number(n!==`H`)+1+Number(r!==`V`),Number(n!==`V`)+1+Number(r!==`H`));return[K*2+i+a,o]}e(gr,`endpointPairLowerBound`);function _r(t,n){if(t.orientation!==n.orientation)return!1;let r=t.orientation===`H`,i=e(e=>r?Math.min(e.a.x,e.b.x):Math.min(e.a.y,e.b.y),`lowOf`),a=e(e=>r?Math.max(e.a.x,e.b.x):Math.max(e.a.y,e.b.y),`highOf`),o=Math.min(a(t),a(n))-Math.max(i(t),i(n)),s=Math.abs(r?t.a.y-n.a.y:t.a.x-n.a.x);return o>0&&s<Yt}e(_r,`segmentsTooClose`);var vr=class{constructor(){this.lines={H:new Map,V:new Map},this.sortedCoordinates={H:void 0,V:void 0},this.log=[]}static{e(this,`RouteOccupancyIndex`)}get size(){return this.log.length}add(e,t){for(let n of fr(e)){let e=n.orientation,r=e===`H`?n.a.y:n.a.x,i=this.lines[e].get(r);i?i.push({segment:n,pairKey:t}):(this.lines[e].set(r,[{segment:n,pairKey:t}]),this.sortedCoordinates[e]=void 0),this.log.push({orientation:e,coordinate:r})}}truncate(e){for(;this.log.length>e;){let{orientation:e,coordinate:t}=this.log.pop();this.lines[e].get(t)?.pop()}}conflictsWithRoute(e,t){return fr(e).some(e=>this.conflicts(e,t))}conflictsWithArc(e,t,n){let r=e.y===t.y?`H`:`V`;return this.conflicts({a:e,b:t,orientation:r},n)}conflicts(e,t){let n=e.orientation;if(n!==`H`&&n!==`V`)return!1;let r=n===`H`?e.a.y:e.a.x,i=this.coordinatesFor(n),a=0,o=i.length;for(;a<o;){let e=a+o>>1;i[e]<=r-Yt?a=e+1:o=e}for(let o=a;o<i.length;o++){let a=i[o];if(a>=r+Yt)break;for(let r of this.lines[n].get(a))if(r.pairKey!==t&&_r(e,r.segment))return!0}return!1}coordinatesFor(e){return this.sortedCoordinates[e]??=[...this.lines[e].keys()].sort((e,t)=>e-t)}},X=24,Z=18,Q=14,yr=4,br=18,xr=4,Sr=64,Cr=4;function wr(e,t,n,r){if(!t.conflictsWithRoute(e,n))return[...e];let i=p([...e]).points;for(let e=1;e<=Cr;e++)for(let a of[1,-1]){let o=a*e*jn;for(let e=1;e<i.length-2;e++){let a=i[e].x===i[e+1].x,s=i.map((t,n)=>n===e||n===e+1?a?{x:t.x+o,y:t.y}:{x:t.x,y:t.y+o}:t);if(!t.conflictsWithRoute(s,n)&&r(s))return s}}}e(wr,`separateRouteFromOccupied`);function Tr(t){let n=e((e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y),`stub`);return n(t[0],t[1])>=K&&n(t.at(-1),t.at(-2))>=K}e(Tr,`terminalStubsAreLongEnough`);function Er(e,t,n,r,i=3){let a=[...r.filter(e=>e>=t&&e<=n).sort((t,n)=>Math.abs(t-e)-Math.abs(n-e)||t-n),(t+n)/2,t,n],o=new Set([e]),s=[];for(let e of a)if(!o.has(e)&&(o.add(e),s.push(e),s.length===i))break;return s}e(Er,`boundedAlternativePortalCoordinates`);function Dr(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}e(Dr,`equalPoint`);function Or(e,t){return e.x===t.x||e.y===t.y}e(Or,`areExactlyAxisAligned`);function kr(e,t,n,r){let i=[...e].sort((e,r)=>Math.abs(e-t)+Math.abs(e-n)-(Math.abs(r-t)+Math.abs(r-n))||e-r);return i[Math.min(r,Math.max(0,i.length-1))]??(t+n)/2}e(kr,`chooseIntermediateCoordinate`);function Ar(e){let t=[];for(let n of e)(t.length===0||!Dr(t[t.length-1],n))&&t.push(n);return t}e(Ar,`dedupeConsecutive`);function jr(e,t,n,r,i){let a=t.containers.get(e);if(!a)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing container layout "${e}"`);let o=[n.port,n.connect];if(n.orientation===`V`&&r.orientation===`V`){if(!Dr(n.connect,r.connect)&&Math.abs(n.connect.x-r.connect.x)>1e-6){let e=kr(a.horizontalCorridors,n.connect.y,r.connect.y,i);o.push({x:n.connect.x,y:e},{x:r.connect.x,y:e})}else if(!Dr(n.connect,r.connect)&&Math.abs(n.connect.y-r.connect.y)>1e-6&&i>0){let e=a.verticalCorridors.filter(e=>Math.abs(e-n.connect.x)>1e-6),t=kr(e.length>0?e:a.verticalCorridors,n.connect.x,r.connect.x,i-1);o.push({x:t,y:n.connect.y},{x:t,y:r.connect.y})}}else if(n.orientation===`H`&&r.orientation===`H`){if(!Dr(n.connect,r.connect)&&Math.abs(n.connect.y-r.connect.y)>1e-6){let e=kr(a.verticalCorridors,n.connect.x,r.connect.x,i);o.push({x:e,y:n.connect.y},{x:e,y:r.connect.y})}}else n.orientation===`V`&&r.orientation===`H`?o.push({x:n.connect.x,y:r.connect.y}):o.push({x:r.connect.x,y:n.connect.y});return o.push(r.connect,r.port),p(Ar(o)).points}e(jr,`routeWithinContainer`);function Mr(e,t,n,r,i,a,o){let s=i.forest.nodeById.get(e),c=i.itemMeta.get(e);if(!s||!c||c.containerId!==r)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing item metadata for "${e}" in "${r}"`);let l=g(s),u=o??a.get(n)??(t===`left`||t===`right`?l.cy:l.cx);switch(t){case`left`:return{port:{x:l.left,y:u},connect:{x:c.leftCorridorX,y:u},orientation:`V`,side:t};case`right`:return{port:{x:l.right,y:u},connect:{x:c.rightCorridorX,y:u},orientation:`V`,side:t};case`top`:return{port:{x:u,y:l.top},connect:{x:u,y:c.topCorridorY},orientation:`H`,side:t};case`bottom`:return{port:{x:u,y:l.bottom},connect:{x:u,y:c.bottomCorridorY},orientation:`H`,side:t}}}e(Mr,`itemAttachment`);function Nr(e,t,n,r,i){let a=r.forest.nodeById.get(e),o=r.containers.get(e);if(!a||!o)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing boundary metadata for "${e}"`);let s=g(a),c=i.get(n)??(t===`left`||t===`right`?s.cy:s.cx);switch(t){case`left`:return{port:{x:s.left,y:c},connect:{x:o.verticalCorridors[0],y:c},orientation:`V`,side:t};case`right`:return{port:{x:s.right,y:c},connect:{x:o.verticalCorridors[o.verticalCorridors.length-1],y:c},orientation:`V`,side:t};case`top`:return{port:{x:c,y:s.top},connect:{x:c,y:o.horizontalCorridors[0]},orientation:`H`,side:t};case`bottom`:return{port:{x:c,y:s.bottom},connect:{x:c,y:o.horizontalCorridors[o.horizontalCorridors.length-1]},orientation:`H`,side:t}}}e(Nr,`boundaryAttachment`);function Pr(e){return{x:(e.interior.x+e.exterior.x)/2,y:(e.interior.y+e.exterior.y)/2}}e(Pr,`portalBoundaryPoint`);function Fr(e,t){return{ownerId:e.ownerId,port:Pr(e),connect:t?e.interior:e.exterior,orientation:e.side===`left`||e.side===`right`?`V`:`H`,side:e.side}}e(Fr,`portalAttachment`);function Ir(e,t,n,r,i){let a=r.forest.nodeById.get(e);if(!a?.isGroup)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing group endpoint "${e}"`);let o=g(a),s=i.get(n)??(t===`left`||t===`right`?o.cy:o.cx),c=t===`left`||t===`right`?{x:t===`left`?o.left:o.right,y:s}:{x:s,y:t===`top`?o.top:o.bottom};return{ownerId:e,port:c,connect:{x:c.x+(t===`left`?K:t===`right`?-K:0),y:c.y+(t===`top`?K:t===`bottom`?-K:0)},orientation:t===`left`||t===`right`?`V`:`H`,side:t}}e(Ir,`groupBoundaryEndpointAttachment`);function Lr(e){return[...e].reverse()}e(Lr,`reversePoints`);function Rr(e){let t=[];for(let n of e)for(let e of n)(t.length===0||!Dr(t[t.length-1],e))&&t.push(e);return p(t).points}e(Rr,`combinePointChains`);function zr(e,t,n,r){let i=g(e),a=Q+(n+1)*br,o=n*xr;switch(t){case`right`:{let e=r-Z/2-o,t=r+Z/2+o;return p([{x:i.right,y:e},{x:i.right+Q,y:e},{x:i.right+a,y:e},{x:i.right+a,y:t},{x:i.right+Q,y:t},{x:i.right,y:t}]).points}case`left`:{let e=r-Z/2-o,t=r+Z/2+o;return p([{x:i.left,y:e},{x:i.left-Q,y:e},{x:i.left-a,y:e},{x:i.left-a,y:t},{x:i.left-Q,y:t},{x:i.left,y:t}]).points}case`top`:{let e=r-Z/2-o,t=r+Z/2+o;return p([{x:e,y:i.top},{x:e,y:i.top-Q},{x:e,y:i.top-a},{x:t,y:i.top-a},{x:t,y:i.top-Q},{x:t,y:i.top}]).points}case`bottom`:{let e=r-Z/2-o,t=r+Z/2+o;return p([{x:e,y:i.bottom},{x:e,y:i.bottom+Q},{x:e,y:i.bottom+a},{x:t,y:i.bottom+a},{x:t,y:i.bottom+Q},{x:t,y:i.bottom}]).points}}}e(zr,`routeSelfLoop`);function Br(e,t,n,r,i){let a=g(e),o=Q+(n+1)*br,s=n*xr,c=Z+s*2,l=t===`left`||t===`right`,u=Math.max(c,(l?i.cross:i.along)+j*2+ee),d=Math.max(o,(l?i.along:i.cross)/2+j),f=l?[a.top,a.bottom]:[a.left,a.right],m=r-u/2,h=r+u/2;if(m-f[0]>=yr&&f[1]-h>=yr)switch(t){case`right`:return[p([{x:a.right,y:m},{x:a.right+d,y:m},{x:a.right+d,y:h},{x:a.right,y:h}]).points];case`left`:return[p([{x:a.left,y:m},{x:a.left-d,y:m},{x:a.left-d,y:h},{x:a.left,y:h}]).points];case`top`:return[p([{x:m,y:a.top},{x:m,y:a.top-d},{x:h,y:a.top-d},{x:h,y:a.top}]).points];case`bottom`:return[p([{x:m,y:a.bottom},{x:m,y:a.bottom+d},{x:h,y:a.bottom+d},{x:h,y:a.bottom}]).points]}let _=r-Z/2-s,v=r+Z/2+s;if(_<f[0]||v>f[1])return[];let y=r-u/2,b=r+u/2,x=Math.max(Q,K),S=Math.max(d,x+(l?i.along:i.cross)/2+j);switch(t){case`right`:return[p([{x:a.right,y:_},{x:a.right+x,y:_},{x:a.right+x,y},{x:a.right+S,y},{x:a.right+S,y:b},{x:a.right+x,y:b},{x:a.right+x,y:v},{x:a.right,y:v}]).points];case`left`:return[p([{x:a.left,y:_},{x:a.left-x,y:_},{x:a.left-x,y},{x:a.left-S,y},{x:a.left-S,y:b},{x:a.left-x,y:b},{x:a.left-x,y:v},{x:a.left,y:v}]).points];case`top`:return[p([{x:_,y:a.top},{x:_,y:a.top-x},{x:y,y:a.top-x},{x:y,y:a.top-S},{x:b,y:a.top-S},{x:b,y:a.top-x},{x:v,y:a.top-x},{x:v,y:a.top}]).points];case`bottom`:return[p([{x:_,y:a.bottom},{x:_,y:a.bottom+x},{x:y,y:a.bottom+x},{x:y,y:a.bottom+S},{x:b,y:a.bottom+S},{x:b,y:a.bottom+x},{x:v,y:a.bottom+x},{x:v,y:a.bottom}]).points]}}e(Br,`labelAwareSelfLoopCandidates`);function Vr(e,t,n){return(e.isGroup&&Mn(e)?[`left`,`right`,`bottom`]:[`left`,`right`,`top`,`bottom`]).sort((r,i)=>(t.get(Nn(e.id,r))??0)+(n.get(`${e.id}:${r}`)??0)-((t.get(Nn(e.id,i))??0)+(n.get(`${e.id}:${i}`)??0)))}e(Vr,`orderedSelfLoopSides`);function Hr(e,t){let n=[];for(let r of t.forest.nodeById.values())if(r.id!==e.id&&!r.isGroup&&r.x!==void 0&&r.y!==void 0&&n.push(g(r)),r.id!==e.id&&r.groupTitleRect){let{left:e,right:t,top:i,bottom:a}=r.groupTitleRect;n.push({cx:(e+t)/2,cy:(i+a)/2,left:e,right:t,top:i,bottom:a})}return n}e(Hr,`selfLoopObstacles`);function Ur(e,t,n,r,i,a){let o=g(e),s=Hr(e,r);for(let r of Vr(e,t,n)){let t=`${e.id}:${r}`,c=n.get(t)??0,l=r===`left`||r===`right`?o.cy:o.cx,u=i?Br(e,r,c,l,i):[zr(e,r,c,l)];i&&a&&(a.labelAwareSelfLoopCandidates+=u.length);for(let e of u)if(!s.some(t=>C(e,t)))return{points:e,side:r,index:c}}throw D(`GRID_ROUTE_NOT_FOUND`,`No obstacle-clear self-loop route for "${e.id}"`,{nodeId:e.id})}e(Ur,`routeObstacleClearSelfLoop`);function Wr(e){if(e.containers.has(T))return;let t=0,n=0,r=0,i=0,a=!0;for(let o of e.itemMeta.values())o.containerId===T&&(a?(t=o.cellLeft,n=o.cellLeft+o.cellWidth,r=o.cellTop,i=o.cellTop+o.cellHeight,a=!1):(t=Math.min(t,o.cellLeft),n=Math.max(n,o.cellLeft+o.cellWidth),r=Math.min(r,o.cellTop),i=Math.max(i,o.cellTop+o.cellHeight)));let o=new Set([r-X,i+X]),s=new Set([t-X,n+X]);for(let t of e.itemMeta.values())t.containerId===T&&(o.add(t.topCorridorY),o.add(t.bottomCorridorY),s.add(t.leftCorridorX),s.add(t.rightCorridorX));e.containers.set(T,{id:T,left:t-X,top:r-X,width:n-t+X*2,height:i-r+X*2,contentLeft:t,contentTop:r,contentRight:n,contentBottom:i,verticalCorridors:[...s].sort((e,t)=>e-t),horizontalCorridors:[...o].sort((e,t)=>e-t)})}e(Wr,`rootContainerMeta`);function Gr(e,t){let n=t.containers.get(e);if(!n)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing container layout "${e}"`);if(e===T){let e=[...t.itemMeta.values()].filter(({containerId:e})=>e===T);return e.length>0?{left:Math.min(...e.map(({cellLeft:e})=>e))-X,right:Math.max(...e.map(({cellLeft:e,cellWidth:t})=>e+t))+X,top:Math.min(...e.map(({cellTop:e})=>e))-X,bottom:Math.max(...e.map(({cellTop:e,cellHeight:t})=>e+t))+X}:{left:n.left,right:n.left+n.width,top:n.top,bottom:n.top+n.height}}let r=t.forest.nodeById.get(e);if(!r)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing container owner "${e}"`);let i=or(r);return{left:i.left+W,right:i.right-W,top:i.top+W,bottom:i.bottom-W}}e(Gr,`containerBounds`);function Kr(e,t,n){return(t===`left`?e.left:t===`right`?e.right:t===`top`?e.top:e.bottom)+(t===`left`||t===`top`?1:-1)*W*(n?1:-1)}e(Kr,`portalCoordinate`);function qr(e,t){let n=[];if(e!==T){let r=t.forest.nodeById.get(e);if(r){let t=or(r);n.push(...Tn(e,t,r.groupTitleRect).map(e=>({...e,coordinate:Kr(t,e.side,!0)})))}}for(let r of t.forest.childrenByParent.get(e)??[]){if(!r.isGroup)continue;let e=or(r);n.push(...Tn(r.id,e,r.groupTitleRect).map(t=>({...t,coordinate:Kr(e,t.side,!1)})))}return n}e(qr,`containerPortalRanges`);function Jr(e,t,n,r){let i={topologies:new Map,fallbackContainers:new Map,searchBudget:{expandedStates:0},searchBudgetWarningEmitted:!1,baseEstimatedBytes:0,metrics:n},a=0;for(let o of[...new Set(e)].sort()){let e=(t.forest.childrenByParent.get(o)??[]).filter(e=>!k(e)),s=t.forest.nodeById.get(o)?.groupTitleRect;try{let c=Dn({containerId:o,bounds:Gr(o,t),obstacles:e.map(e=>({id:e.id,bounds:or(e)})),titleExclusions:s?[{id:`${o}:title`,bounds:{...s}}]:void 0,portalRanges:qr(o,t)},{caps:r.topologyCaps}),l=r.topologyCaps?.maxEstimatedBytes??Qt;if(a+c.estimatedBytes>l){i.fallbackContainers.set(o,`estimated_memory_cap`);continue}a+=c.estimatedBytes,i.baseEstimatedBytes=a,i.topologies.set(o,c),n&&(n.containersBuilt++,n.baseTopologyBuilds++,n.baseVertices+=c.vertices.length,n.baseAdjacencyEntries+=c.adjacencyEntries,n.buildSweepEvents+=c.seedCount*4+c.obstacles.length*4,n.estimatedBytes=a)}catch(e){if(!(e instanceof Jt))throw e;i.fallbackContainers.set(o,e.reason)}}return i}e(Jr,`buildRoutingContext`);function Yr(e,t,n,r,i,a,o){let s=i();if(o&&o.compatibilitySegments++,ur(s,n.ownerId,r.ownerId,t,a))return s;throw o&&(o.compatibilityValidationFailures++,o.routesImpossible++),D(`GRID_ROUTE_NOT_FOUND`,`Invalid compatibility route for "${e}"`,{edgeId:e,containerId:t})}e(Yr,`validatedCompatibilitySegment`);function Xr(t,n,r){let i=t.source.chain.at(-1),a=t.target.chain.at(-1),o=e((e,i)=>({ownerId:i.ownerId,...e.finalKind===`boundary`?Nr(t.lcaContainerId,i.side,i.demandKey,n,r):Mr(i.ownerId,i.side,i.demandKey,t.lcaContainerId,n,r)}),`finalAttachment`);return{start:o(t.source,i),end:o(t.target,a)}}e(Xr,`compatibilityLcaAttachments`);function Zr(e,t,n){return e.chain.slice(0,-1).map((r,i)=>{let a=e.chain[i+1];return{containerId:a.ownerId,start:{ownerId:r.ownerId,...Mr(r.ownerId,r.side,r.demandKey,a.ownerId,t,n)},end:{ownerId:a.ownerId,...Nr(a.ownerId,a.side,a.demandKey,t,n)}}})}e(Zr,`compatibilityHierarchyAttachments`);function Qr(t,n,r){let i=e((e,r,i)=>ur(jr(e,n,r,i,t.laneIndex),r.ownerId,i.ownerId,e,n),`segmentIsValid`);for(let e of[t.source,t.target])for(let{containerId:t,start:a,end:o}of Zr(e,n,r))if(!i(t,a,o))return!1;let a=Xr(t,n,r);return i(t.lcaContainerId,a.start,a.end)}e(Qr,`compatibilityPlanIsValid`);function $r(t,n,r,i){let{plans:a,eligiblePlans:o,eligibleIds:s,demandCoords:c,endpointCandidatesByEdge:l,endpointIncidentCounts:u,coordinatedEndpointIds:d}=t,f=e(e=>(u.get(e.edge.start)??0)===e.bundleSize&&(u.get(e.edge.end)??0)===e.bundleSize,`hasIsolatedEndpoints`),m=e(e=>{let t=n.forest.nodeById.get(e.edge.start),r=n.forest.nodeById.get(e.edge.end);return!!(t&&r&&(t.isGroup&&Dt(t.id,r,n.forest.nodeById)||r.isGroup&&Dt(r.id,t,n.forest.nodeById)))},`hasAncestorEndpoint`),h=new Map,g=new Map,_=a.length<=Sr,v=i.topologyCaps===void 0&&i.searchCaps===void 0&&i.onDualRouteComparison===void 0;for(let e of v?o:[]){if(d.has(e.edge.id))continue;let t=l.get(e.edge.id);if(e.bundleSize!==1||!t?.sources.length||!t.targets.length)continue;let i=n.forest.nodeById.get(e.edge.start),a=n.forest.nodeById.get(e.edge.end);if(!i||!a)continue;let o=Xr(e,n,c),s=jr(e.lcaContainerId,n,o.start,o.end,e.laneIndex),u=p(s),f=u.points[0],m=u.points.at(-1);if(!f||!m)continue;let v=t.sources.find(({port:e})=>e.x===f.x&&e.y===f.y),y=t.targets.find(({port:e})=>e.x===m.x&&e.y===m.y);if(!v||!y)continue;r&&r.compatibilityFastPathAttempts++;let b=Math.abs(f.x-m.x)+Math.abs(f.y-m.y);if(!J(s,i,a,e.lcaContainerId,n)){r&&r.compatibilityFastPathValidationFailures++;continue}if(x(u.points)!==b){r&&r.compatibilityFastPathNonMinimalRoutes++;continue}let S=g.get(e.lcaContainerId);if(S||(S=new vr,g.set(e.lcaContainerId,S)),S.conflictsWithRoute(u.points,e.pairKey)&&_)continue;let C=wr(u.points,S,e.pairKey,t=>Tr(t)&&x(t)===b&&J(t,i,a,e.lcaContainerId,n))??s;S.add(C,e.pairKey),h.set(e.edge.id,C)}let y=e(e=>!s.has(e.edge.id)&&e.edge.start!==e.edge.end&&(e.bundleSize>1||f(e)||!Qr(e,n,c)),`sparseCandidate`),b=new Map,S=new Set;if(_)for(let e of t.orderedPlans){if(s.has(e.edge.id)||e.edge.start===e.edge.end||m(e)||y(e))continue;let t=Xr(e,n,c),r=jr(e.lcaContainerId,n,t.start,t.end,e.laneIndex),i=b.get(e.lcaContainerId);i||(i=new vr,b.set(e.lcaContainerId,i)),i.conflictsWithRoute(r,e.pairKey)?S.add(e.edge.id):i.add(r,e.pairKey)}let C=new Set([...a.filter(y).map(({edge:e})=>e.id),...S]),w=new Set([...C,...a.filter(m).map(({edge:e})=>e.id)]);return{overlapAvoidanceEnabled:_,compatibilityFastRoutes:h,sparseHierarchyIds:C,sparseLcaIds:w,routedContainerIds:a.filter(e=>s.has(e.edge.id)&&!h.has(e.edge.id)||w.has(e.edge.id)||e.edge.start===e.edge.end).flatMap(e=>[e.lcaContainerId,...e.source.chain.slice(1).map(({ownerId:e})=>e),...e.target.chain.slice(1).map(({ownerId:e})=>e)]),routeOccupancy:g}}e($r,`prepareRoutingModes`);var ei={containersBuilt:`cumulative`,baseTopologyBuilds:`cumulative`,baseVertices:`cumulative`,baseAdjacencyEntries:`cumulative`,buildSweepEvents:`cumulative`,endpointOverlayBuilds:`cumulative`,endpointOverlayVertices:`cumulative`,hierarchyPortalPairs:`transactional`,hierarchyPortalTransitionLength:`transactional`,hierarchyPortalAlternativeAttempts:`cumulative`,hierarchyPortalAlternativeSelections:`transactional`,hierarchyBoundaryTransitions:`transactional`,labelOverlayBuilds:`cumulative`,labelOverlayVertices:`cumulative`,labelSpacingEdgesExamined:`cumulative`,labelSpacingEligibleEdges:`cumulative`,labelSpacingBoundariesExpanded:`cumulative`,labelSpacingPixelsAdded:`cumulative`,labelAwareSelfLoopCandidates:`cumulative`,labelAwareSelfLoopsCommitted:`transactional`,labelAwareSelfLoopFallbacks:`cumulative`,searches:`cumulative`,expandedStates:`cumulative`,maxOpenSet:`cumulative`,routesFound:`transactional`,routesImpossible:`transactional`,resourceLimitFallbacks:`cumulative`,fallbackReasons:`cumulative`,fallbackValidationFailures:`cumulative`,compatibilitySegments:`transactional`,compatibilityFastPathAttempts:`cumulative`,compatibilityFastPaths:`cumulative`,compatibilityFastPathValidationFailures:`cumulative`,compatibilityFastPathNonMinimalRoutes:`cumulative`,compatibilityRecoveries:`transactional`,compatibilityValidationFailures:`cumulative`,bundleSeparationRelaxations:`transactional`,routeLength:`transactional`,bendCount:`transactional`,crossingCount:`transactional`,sharedLength:`transactional`,estimatedBytes:`cumulative`,searchWorkspaceBytes:`cumulative`,routeOrder:`transactional`,routes:`transactional`},ti=Object.keys(ei).filter(e=>ei[e]===`transactional`&&e!==`routeOrder`&&e!==`routes`);function ni(e){return{routeOrderLength:e.routeOrder.length,routesLength:e.routes.length,values:Object.fromEntries(ti.map(t=>[t,e[t]]))}}e(ni,`createGridRoutingInstrumentationCheckpoint`);function ri(e,t){e.routeOrder.length=t.routeOrderLength,e.routes.length=t.routesLength,Object.assign(e,t.values)}e(ri,`restoreGridRoutingInstrumentationCheckpoint`);function ii(e,t,n,r){return Math.max(0,Math.min(Math.max(e,t),Math.max(n,r))-Math.max(Math.min(e,t),Math.min(n,r)))}e(ii,`intervalOverlap`);function ai(e,t){let n=p(e).segments,r=p(t).segments,i=0;for(let e of n)for(let t of r)e.orientation===t.orientation&&(e.orientation===`H`&&e.a.y===t.a.y?i+=ii(e.a.x,e.b.x,t.a.x,t.b.x):e.orientation===`V`&&e.a.x===t.a.x&&(i+=ii(e.a.y,e.b.y,t.a.y,t.b.y)));return i}e(ai,`sharedSegmentLength`);function oi(e,t,n,r,i=0,a=0){let o=p(n),s=0,c=0;for(let e of r){let t=p(e).segments;for(let e of o.segments)for(let n of t)m(e,n)&&s++;c+=ai(o.points,e)}let l={edgeId:t,routeOrder:e.routes.length,laneOffset:a,routeLength:x(o.points),bendCount:o.bends,crossingCount:s,sharedLength:c,boundaryTransitionCount:i,routeSignature:JSON.stringify(o.points)};e.routeOrder.push(t),e.routes.push(l),e.routesFound++,e.routeLength+=l.routeLength,e.bendCount+=l.bendCount,e.crossingCount+=l.crossingCount,e.sharedLength+=l.sharedLength,e.hierarchyBoundaryTransitions+=i}e(oi,`recordGridRoute`);var si=1e5,ci=2e6,li=class{constructor(){this.stateVertices=new Int32Array(256),this.orientations=new Uint8Array(256),this.gLengths=new Float64Array(256),this.gBends=new Float64Array(256),this.gBoundaryTransitions=new Float64Array(256),this.fLengths=new Float64Array(256),this.fBends=new Float64Array(256),this.predecessors=new Int32Array(256),this.depths=new Int32Array(256),this.ancestor4=new Int32Array(256),this.best=new Int32Array(256),this.heapChildren=new Int32Array(256),this.heapSiblings=new Int32Array(256),this.heapPairs=[],this.touchedBestIndices=[],this.best.fill(-1)}static{e(this,`RouterSearchWorkspace`)}reset(e){let t=e*3;if(this.best.length<t)this.best=new Int32Array(t),this.best.fill(-1);else for(let e of this.touchedBestIndices)this.best[e]=-1;this.touchedBestIndices.length=0,this.heapPairs.length=0}setBest(e,t){this.best[e]<0&&this.touchedBestIndices.push(e),this.best[e]=t}ensureStateCapacity(e){if(this.stateVertices.length>=e)return;let t=Math.max(e,this.stateVertices.length*2);this.stateVertices=$(this.stateVertices,t),this.orientations=$(this.orientations,t),this.gLengths=$(this.gLengths,t),this.gBends=$(this.gBends,t),this.gBoundaryTransitions=$(this.gBoundaryTransitions,t),this.fLengths=$(this.fLengths,t),this.fBends=$(this.fBends,t),this.predecessors=$(this.predecessors,t),this.depths=$(this.depths,t),this.ancestor4=$(this.ancestor4,t),this.heapChildren=$(this.heapChildren,t),this.heapSiblings=$(this.heapSiblings,t)}estimatedBytes(){return this.stateVertices.byteLength+this.orientations.byteLength+this.gLengths.byteLength+this.gBends.byteLength+this.gBoundaryTransitions.byteLength+this.fLengths.byteLength+this.fBends.byteLength+this.predecessors.byteLength+this.depths.byteLength+this.ancestor4.byteLength+this.best.byteLength+this.heapChildren.byteLength+this.heapSiblings.byteLength+(this.heapPairs.length+this.touchedBestIndices.length)*8}};function ui(e){let t=e.caps?.maxExpandedStates??si,n=e.caps?.maxInvocationExpandedStates??ci,r=e.budget?.expandedStates??e.metrics?.expandedStates??0;if(!(t>0&&r<n))throw new Jt(`search_state_cap`,`Grid routing search-state cap exceeded`,r>=n?`invocation`:`edge`)}e(ui,`assertSearchBudgetAvailable`);function $(e,t){let n=new e.constructor(t);return n.set(e),n}e($,`growTypedArray`);function di(e,t){for(let n=0;n<4;n++){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return 0}e(di,`compareTupleCost`);function fi(e,t,n,r){return e===0&&t===0?n&&r?Number(n!==r):0:e===0?(n?Number(n!==`V`):0)+(r?Number(r!==`V`):0):t===0?(n?Number(n!==`H`):0)+(r?Number(r!==`H`):0):Math.min((n?Number(n!==`H`):0)+1+(r?Number(r!==`V`):0),(n?Number(n!==`V`):0)+1+(r?Number(r!==`H`):0))}e(fi,`minimumBends`);function pi(e){return e===void 0?0:e===`H`?1:2}e(pi,`orientationOrdinal`);function mi(e,t,n){return n===`left`?e.y===t.y&&t.x>e.x:n===`right`?e.y===t.y&&t.x<e.x:n===`top`?e.x===t.x&&t.y>e.y:e.x===t.x&&t.y<e.y}e(mi,`movesTowardOwner`);function hi(e,t){return e*3+pi(t)}e(hi,`stateIndex`);function gi(e){let t=[];for(let n of e){let e=t.at(-1);if(e&&e.x===n.x&&e.y===n.y)continue;let r=t.at(-2);r&&e&&(r.x===e.x&&e.x===n.x||r.y===e.y&&e.y===n.y)?t[t.length-1]={...n}:t.push({...n})}return t}e(gi,`normalizePoints`);function _i(e,t,n,r,i){let a=[],o=e;for(;o>=0;)a.push(t[o]),o=n[o];return a.reverse(),{points:gi(a.map(e=>i(e).point)),vertexIds:a,cost:r}}e(_i,`reconstruct`);function vi(e){for(let t of e.vertices){if(t.id<0||e.vertices[t.id]!==t||!Number.isFinite(t.point.x)||!Number.isFinite(t.point.y))throw Error(`Malformed grid routing vertex`);for(let n of e.adjacency.get(t.id)??[]){let r=e.vertices[n.to],i=r&&(n.orientation===`H`?t.point.y===r.point.y:t.point.x===r.point.x),a=r?Math.abs(t.point.x-r.point.x)+Math.abs(t.point.y-r.point.y):NaN;if(n.from!==t.id||!i||!Number.isFinite(n.length)||n.length<=0||n.length!==a)throw Error(`Malformed grid routing arc`)}}}e(vi,`validateSearchTopology`);function yi(t,n,r,i){let a=e(e=>{let n=t.getVertex?.(e)??t.vertices[e];if(!n)throw Error(`Missing grid routing vertex ${e}`);return n},`vertexAt`),o=a(n),s=a(r);i.topologyValidated||vi(t);let c=i.metrics;c&&c.searches++,ui(i);let l=i.workspace??new li;l.reset(t.vertexCount??t.vertices.length);let u=l.stateVertices,d=l.orientations,f=l.gLengths,p=l.gBends,m=l.gBoundaryTransitions,h=l.fLengths,g=l.fBends,_=l.predecessors,v=l.depths,y=l.ancestor4,b=l.heapChildren,x=l.heapSiblings,S=l.best,C=l.heapPairs,w=1,T=i.endpointCandidateRank??0,E=i.heuristic!==`zero`;function D(e,t){return u[e]-u[t]||d[e]-d[t]||_[e]-_[t]||e-t}e(D,`nonCostOrder`);function O(e,t){return h[e]-h[t]||g[e]-g[t]||m[e]-m[t]||(i.queueOrder===`reverse`?-D(e,t):D(e,t))}e(O,`compareStates`);function k(e,t){if(e===t)return 0;if(e<0)return-1;if(t<0)return 1;let n=v[e],r=v[t],i=e,a=t;for(;v[i]>v[a];)i=_[i];for(;v[a]>v[i];)a=_[a];if(i===a)return n-r;for(;y[i]>=0&&y[a]>=0&&y[i]!==y[a];)i=y[i],a=y[a];for(;_[i]!==_[a];)i=_[i],a=_[a];return u[i]-u[a]||d[i]-d[a]}e(k,`compareChains`);let A=-1,j=0;function M(e,t){return e<0?t:t<0?e:O(e,t)<=0?(x[t]=b[e],b[e]=t,e):(x[e]=b[t],b[t]=e,t)}e(M,`heapMeld`);let ee=e(e=>{b[e]=-1,x[e]=-1,A=M(A,e),j++},`heapPush`),N=e(()=>{if(A<0)return;let e=A;C.length=0;let t=b[e];for(;t>=0;){let e=x[t];x[t]=-1,C.push(t),t=e}for(let e=0;e+1<C.length;e+=2)C[e>>>1]=M(C[e],C[e+1]);let n=Math.ceil(C.length/2);for(C.length%2!=0&&(C[n-1]=C[C.length-1]),A=-1;n>0;)A=M(C[--n],A);return j--,e},`heapPop`),P=0,F=i.caps?.maxExpandedStates??si,I=i.caps?.maxInvocationExpandedStates??ci,L=i.budget?.expandedStates??c?.expandedStates??0,te=e(()=>{let e=l.estimatedBytes(),t=(i.estimatedBytesBase??0)+e;if(c&&(c.searchWorkspaceBytes=Math.max(c.searchWorkspaceBytes,e),c.estimatedBytes=Math.max(c.estimatedBytes,t)),t>(i.caps?.maxEstimatedBytes??1/0))throw new Jt(`estimated_memory_cap`,`Grid routing search workspace memory cap exceeded`)},`recordWorkspaceBytes`);te();let R=e(()=>{i.budget&&(i.budget.expandedStates+=P),c&&(c.expandedStates+=P)},`commitExpandedStates`),ne=i.initialLength??0;u[0]=n,d[0]=pi(i.initialOrientation),f[0]=ne,p[0]=0,m[0]=0;let re=Math.abs(o.point.x-s.point.x),ie=Math.abs(o.point.y-s.point.y);h[0]=ne+(E?re+ie:0),g[0]=E?fi(re,ie,i.initialOrientation,i.targetOrientation):0,_[0]=-1,v[0]=1,y[0]=-1,l.setBest(hi(n,i.initialOrientation),0),ee(0),c&&(c.maxOpenSet=Math.max(c.maxOpenSet,j));let z=-1,B,ae=e(e=>{let t=[f[e]+(i.targetLength??0),p[e]+ +(i.targetOrientation!==void 0&&d[e]!==0&&pi(i.targetOrientation)!==d[e]),m[e],T];(!B||di(t,B)<0||di(t,B)===0&&k(e,z)<0)&&(z=e,B=t)},`considerGoal`),V=e((e,t,n,o,c,C)=>{let T=a(n).point;if(i.arcAllowed&&!i.arcAllowed(t,T)||i.initialSide&&_[e]<0&&mi(t,T,i.initialSide)||i.targetSide&&n===r&&mi(s.point,t,i.targetSide))return;let D=n*3+o,O=S[D],A=f[e]+c,j=p[e]+ +(d[e]!==0&&d[e]!==o),M=m[e]+C,N=O>=0?A-f[O]||j-p[O]||M-m[O]:-1;if(O>=0&&(N>0||N===0&&k(e,_[O])>=0))return;let P=w++;w>u.length&&(l.ensureStateCapacity(w),u=l.stateVertices,d=l.orientations,f=l.gLengths,p=l.gBends,m=l.gBoundaryTransitions,h=l.fLengths,g=l.fBends,_=l.predecessors,v=l.depths,y=l.ancestor4,b=l.heapChildren,x=l.heapSiblings,te()),u[P]=n,d[P]=o,f[P]=A,p[P]=j,m[P]=M;let F=Math.abs(T.x-s.point.x),I=Math.abs(T.y-s.point.y);h[P]=A+(E?F+I:0),g[P]=j+(E?fi(F,I,o===1?`H`:`V`,i.targetOrientation):0),_[P]=e,v[P]=v[e]+1;let L=_[e],R=L>=0?_[L]:-1;y[P]=R>=0?_[R]:-1,l.setBest(D,P),ee(P)},`relaxArc`);for(;j>0;){let e=A;if(B&&(h[e]-B[0]||g[e]-B[1]||m[e]-B[2]||T-B[3])>0)break;let n=N();if(S[u[n]*3+d[n]]!==n)continue;if(P>=F||L+P>=I){if(z>=0&&B)return c&&i.recordOutcome!==!1&&c.routesFound++,R(),_i(z,u,_,B,a);throw R(),new Jt(`search_state_cap`,`Grid routing search-state cap exceeded`,L+P>=I?`invocation`:`edge`)}if(P++,u[n]===r){ae(n);continue}let o=u[n],s=a(o).point,l=t.getSearchArcs?.(o)??t.searchAdjacencyByVertex?.[o];if(l)for(let e of l)V(n,s,e.to,e.orientationOrdinal,e.length,e.boundaryTransitions);else for(let e of t.adjacencyByVertex?.[o]??t.adjacency.get(o)??[])V(n,s,e.to,pi(e.orientation),e.length,+(e.kind===`portal`));c&&(c.maxOpenSet=Math.max(c.maxOpenSet,j))}if(z<0||!B){R(),c&&i.recordOutcome!==!1&&c.routesImpossible++;return}return c&&i.recordOutcome!==!1&&c.routesFound++,R(),_i(z,u,_,B,a)}e(yi,`search`);function bi(e,t,n,r={}){return yi(e,t,n,r)}e(bi,`findShortestRoute`);var xi=`grid-router`;function Si(e,n,r,i,a){e.metrics&&(e.metrics.resourceLimitFallbacks++,e.metrics.fallbackReasons[n]++),t.debug(xi,`GRID_ROUTING_RESOURCE_FALLBACK`,{edgeId:r,containerId:i,reason:n}),n===`search_state_cap`&&a===`invocation`&&!e.searchBudgetWarningEmitted&&(e.searchBudgetWarningEmitted=!0,t.warn(xi,`GRID_ROUTING_INVOCATION_SEARCH_BUDGET_EXHAUSTED`,{edgeId:r,containerId:i,expandedStates:e.searchBudget.expandedStates}))}e(Si,`recordFallback`);function Ci({context:e,reason:t,edgeId:n,containerId:r,searchStateScope:i,route:a,isValid:o,includeContainerIdInError:s}){let c=a();if(Si(e,t,n,r,i),o(c))return c;throw e.metrics&&e.metrics.fallbackValidationFailures++,D(`GRID_ROUTE_NOT_FOUND`,`Invalid legacy fallback for "${n}"`,{edgeId:n,...s?{containerId:r}:{},reason:t})}e(Ci,`runValidatedFallback`);function wi(t,n,r,i,a,o,s,c,l,u,d,f,m){let h=c.fallbackContainers.get(t.lcaContainerId);if(h)return Ci({context:c,reason:h,edgeId:t.edge.id,containerId:t.lcaContainerId,route:o,isValid:e(e=>J(e,i,a,t.lcaContainerId,s)&&(t.bundleSize<=1||Y(e,f)),`isValid`)});let g=c.topologies.get(t.lcaContainerId);if(!g)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing routing topology "${t.lcaContainerId}"`);if(n.length===0||r.length===0)throw c.metrics&&c.metrics.routesImpossible++,D(`GRID_ROUTE_NOT_FOUND`,t.bundleSize>1?`No distinct lane route for "${t.edge.id}"`:`No legal endpoint candidates for "${t.edge.id}"`,{edgeId:t.edge.id});let _,v,y=n.flatMap(e=>r.map(t=>{let n=e.rank*r.length+t.rank,[i,a]=gr(e,t);return{sourceCandidate:e,targetCandidate:t,pairRank:n,lowerCost:[i,a,0,n]}})).sort((e,t)=>di(e.lowerCost,t.lowerCost)||Kn(e.sourceCandidate.side)-Kn(t.sourceCandidate.side)||Kn(e.targetCandidate.side)-Kn(t.targetCandidate.side)),b=e((e,n=`all`)=>{let r=t.bundleSize>1||e?(n,r)=>(t.bundleSize<=1||hr(n,r,f))&&!(e&&m.index.conflictsWithArc(n,r,m.pairKey)):void 0;for(let{sourceCandidate:o,targetCandidate:h,pairRank:b,lowerCost:x}of y)if((n!==`preferred`||b===0)&&(n!==`assigned-side`||o.onAssignedSide!==!1&&h.onAssignedSide!==!1)){if(_&&di(_.result.cost,x)<=0)break;try{ui({metrics:c.metrics,caps:d.searchCaps,budget:c.searchBudget});let n=kn(g,o.connect,h.connect,c.metrics,u,t.bundleSize>1&&(o.connect.x===h.connect.x||o.connect.y===h.connect.y)?[{x:(o.connect.x+h.connect.x)/2,y:(o.connect.y+h.connect.y)/2}]:[]),y=c.baseEstimatedBytes+n.estimatedBytes-g.estimatedBytes;if(y>(d.topologyCaps?.maxEstimatedBytes??Qt))throw new Jt(`estimated_memory_cap`,`Grid routing estimated_memory_cap exceeded`);c.metrics&&(c.metrics.estimatedBytes=Math.max(c.metrics.estimatedBytes,y));let x=n.pointVertexIds.get(G(o.connect)),S=n.pointVertexIds.get(G(h.connect));if(x===void 0||S===void 0)throw D(`GRID_ROUTE_NOT_FOUND`,`Endpoint projection is missing from the routing overlay for "${t.edge.id}"`,{edgeId:t.edge.id,containerId:t.lcaContainerId,source:o.connect,target:h.connect});let C=o.side===`left`||o.side===`right`?`H`:`V`,w=h.side===`left`||h.side===`right`?`H`:`V`,T=bi(n,x,S,{metrics:c.metrics,caps:{...d.searchCaps,maxEstimatedBytes:d.searchCaps?.maxEstimatedBytes??d.topologyCaps?.maxEstimatedBytes??Qt},endpointCandidateRank:b,recordOutcome:!1,budget:c.searchBudget,initialOrientation:C,initialLength:K,targetOrientation:w,targetLength:K,topologyValidated:!0,workspace:l,estimatedBytesBase:y,arcAllowed:r});if(!T)continue;let E=p([o.port,...T.points,h.port]).points;if(!J(E,i,a,t.lcaContainerId,s)||t.bundleSize>1&&!Y(E,f)||e&&m.index.conflictsWithRoute(E,m.pairKey))continue;(!_||di(T.cost,_.result.cost)<0)&&(_={result:T,points:E},v=void 0)}catch(e){if(!(e instanceof Jt))throw e;if(_)break;v=e;break}}},`searchPairs`),S=m!==void 0&&m.index.size>0;if(m?.prioritizeEndpointCandidates&&(b(S,`preferred`),b(S,`assigned-side`)),_||b(S),!_&&!v&&m!==void 0&&m.index.size>0&&b(!1),v)return Ci({context:c,reason:v.reason,edgeId:t.edge.id,containerId:t.lcaContainerId,searchStateScope:v.searchStateScope,route:o,isValid:e(e=>J(e,i,a,t.lcaContainerId,s)&&(t.bundleSize<=1||Y(e,f)),`isValid`)});if(!_)throw c.metrics&&c.metrics.routesImpossible++,D(`GRID_ROUTE_NOT_FOUND`,t.bundleSize>1?`No distinct lane route for "${t.edge.id}"`:`No cell-aware route for "${t.edge.id}"`,{edgeId:t.edge.id});if(d.onDualRouteComparison){let e=o(),n=p(_.points),r=p(e);d.onDualRouteComparison({edgeId:t.edge.id,sparse:{valid:!0,length:x(n.points),bends:n.bends},legacy:{valid:J(e,i,a,t.lcaContainerId,s),length:x(r.points),bends:r.bends}})}return _.points}e(wi,`sparseSameContainerRoute`);function Ti(t,n,r){let i=q(t,n);if(!i||i.high-i.low<Z)return;let a=g(t),o=(i.low+i.high)/2,s=r*xr,c=[o-Z/2-s,o+Z/2+s];if(c[0]<i.low||c[1]>i.high)return;let l=e(e=>{let r=n===`left`||n===`right`?{x:n===`left`?a.left:a.right,y:e}:{x:e,y:n===`top`?a.top:a.bottom};return{ownerId:t.id,side:n,port:r,connect:{x:r.x+(n===`left`?-K:n===`right`?K:0),y:r.y+(n===`top`?-K:n===`bottom`?K:0)},rank:0}},`candidate`);return{start:l(c[0]),target:l(c[1])}}e(Ti,`selfLoopAttachments`);function Ei(t,n,r,i,a,o,s,c,l,u){let d=n.parentId??T,f=r.labelRequirements.selfLoops.get(t.edge.id),m=i.fallbackContainers.get(d),h=e(()=>Ur(n,s,c,r,f,i.metrics),`legacyRoute`);if(m){let a=Ci({context:i,reason:m,edgeId:t.edge.id,containerId:d,route:h,isValid:e(e=>J(e.points,n,n,d,r)&&Y(e.points,l),`isValid`)});return f&&i.metrics&&i.metrics.labelAwareSelfLoopsCommitted++,a}let _=i.topologies.get(d);if(!_||!o)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing routing topology "${d}"`);let v=Vr(n,s,c);if(f){for(let e of v){let t=c.get(`${n.id}:${e}`)??0,a=g(n),o=Br(n,e,t,e===`left`||e===`right`?a.cy:a.cx,f);i.metrics&&(i.metrics.labelAwareSelfLoopCandidates+=o.length);for(let a of o)if(J(a,n,n,d,r)&&Y(a,l))return i.metrics&&i.metrics.labelAwareSelfLoopsCommitted++,{points:a,side:e,index:t}}i.metrics&&i.metrics.labelAwareSelfLoopFallbacks++}for(let s of v){let m=c.get(`${n.id}:${s}`)??0,g=Ti(n,s,m);if(!g)continue;let{start:v,target:y}=g;try{ui({metrics:i.metrics,caps:u.searchCaps,budget:i.searchBudget});let c=kn(_,v.connect,y.connect,i.metrics,o,[{x:(v.connect.x+y.connect.x)/2,y:(v.connect.y+y.connect.y)/2}]),f=c.pointVertexIds.get(G(v.connect)),h=c.pointVertexIds.get(G(y.connect));if(f===void 0||h===void 0)throw D(`GRID_ROUTE_NOT_FOUND`,`Self-loop endpoint projection is missing from the routing overlay for "${t.edge.id}"`,{edgeId:t.edge.id,containerId:d,source:v.connect,target:y.connect,side:s});let g=s===`left`||s===`right`?`H`:`V`,b=bi(c,f,h,{metrics:i.metrics,caps:{...u.searchCaps,maxEstimatedBytes:u.searchCaps?.maxEstimatedBytes??u.topologyCaps?.maxEstimatedBytes??Qt},recordOutcome:!1,budget:i.searchBudget,initialOrientation:g,initialSide:s,initialLength:K,targetOrientation:g,targetSide:s,targetLength:K,topologyValidated:!0,workspace:a,estimatedBytesBase:i.baseEstimatedBytes+c.estimatedBytes-_.estimatedBytes,arcAllowed:e((e,t)=>hr(e,t,l),`arcAllowed`)});if(!b)continue;let x=p([v.port,...b.points,y.port]).points;if(J(x,n,n,d,r)&&Y(x,l))return{points:x,side:s,index:m}}catch(a){if(!(a instanceof Jt))throw a;let o=Ci({context:i,reason:a.reason,edgeId:t.edge.id,containerId:d,searchStateScope:a.searchStateScope,route:h,isValid:e(e=>J(e.points,n,n,d,r)&&Y(e.points,l),`isValid`)});return f&&i.metrics&&i.metrics.labelAwareSelfLoopsCommitted++,o}}throw i.metrics&&i.metrics.routesImpossible++,D(`GRID_ROUTE_NOT_FOUND`,`No distinct self-loop route for "${t.edge.id}"`,{edgeId:t.edge.id,nodeId:n.id})}e(Ei,`sparseSelfLoopRoute`);function Di(t,n,r,i,a,o,s,c,l,u,d=[],f=()=>[],m=()=>[],h=!1,g){let _=s.fallbackContainers.get(n);if(_)return Ci({context:s,reason:_,edgeId:t,containerId:n,route:a,isValid:e(e=>ur(e,r.ownerId,i.ownerId,n,o)&&Y(e,d),`isValid`),includeContainerIdInError:!0});let v=s.topologies.get(n);if(!v||!l)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing routing topology "${n}"`);let y=[{start:r,end:i,select:[]}],b=!1,x=e(()=>{if(b)return;b=!0;let e=m(),t=f();y.push(...t.map(e=>({start:r,end:e.attachment,select:[e.select]})),...e.map(e=>({start:e.attachment,end:i,select:[e.select]})),...e.flatMap(e=>t.map(t=>({start:e.attachment,end:t.attachment,select:[e.select,t.select]}))))},`appendAlternatives`),S=g!==void 0&&g.index.size>0?[!0,!1]:[!1];try{for(let e of S)for(let[t,r]of y.entries()){let i=r.start,a=r.end;if(t>0&&s.metrics&&s.metrics.hierarchyPortalAlternativeAttempts++,Or(i.connect,a.connect)){let c=p([i.port,i.connect,a.connect,a.port]).points;if(ur(c,i.ownerId,a.ownerId,n,o)&&Y(c,d)&&!(e&&g.index.conflictsWithRoute(c,g.pairKey))){for(let e of r.select)e();return t>0&&s.metrics&&s.metrics.hierarchyPortalAlternativeSelections++,c}}ui({metrics:s.metrics,caps:u.searchCaps,budget:s.searchBudget});let f=kn(v,i.connect,a.connect,s.metrics,l),m=s.baseEstimatedBytes+f.estimatedBytes-v.estimatedBytes;if(m>(u.topologyCaps?.maxEstimatedBytes??Qt))throw new Jt(`estimated_memory_cap`,`Grid routing estimated_memory_cap exceeded`);let h=f.pointVertexIds.get(G(i.connect)),_=f.pointVertexIds.get(G(a.connect));if(h===void 0||_===void 0){t===0&&x();continue}let y=bi(f,h,_,{metrics:s.metrics,caps:{...u.searchCaps,maxEstimatedBytes:u.searchCaps?.maxEstimatedBytes??u.topologyCaps?.maxEstimatedBytes??Qt},recordOutcome:!1,budget:s.searchBudget,initialOrientation:i.side===`left`||i.side===`right`?`H`:`V`,initialSide:i.side,initialLength:Math.abs(i.port.x-i.connect.x)+Math.abs(i.port.y-i.connect.y),targetOrientation:a.side===`left`||a.side===`right`?`H`:`V`,targetSide:a.side,targetLength:Math.abs(a.port.x-a.connect.x)+Math.abs(a.port.y-a.connect.y),topologyValidated:!0,workspace:c,estimatedBytesBase:m,arcAllowed:d.length>0||e?(t,n)=>(d.length===0||hr(t,n,d))&&!(e&&g.index.conflictsWithArc(t,n,g.pairKey)):void 0});if(!y){t===0&&x();continue}let b=p([i.port,...y.points,a.port]).points;if(!ur(b,i.ownerId,a.ownerId,n,o)||!Y(b,d)||e&&g.index.conflictsWithRoute(b,g.pairKey)){t===0&&x();continue}for(let e of r.select)e();return t>0&&s.metrics&&s.metrics.hierarchyPortalAlternativeSelections++,b}}catch(c){if(!(c instanceof Jt))throw c;return Ci({context:s,reason:c.reason,edgeId:t,containerId:n,searchStateScope:c.searchStateScope,route:a,isValid:e(e=>ur(e,r.ownerId,i.ownerId,n,o)&&Y(e,d),`isValid`),includeContainerIdInError:!0})}let C=a();if(ur(C,r.ownerId,i.ownerId,n,o)&&(Y(C,d)||h&&mr(C,d)))return s.metrics&&(s.metrics.compatibilitySegments++,s.metrics.compatibilityRecoveries++),C;throw D(`GRID_ROUTE_NOT_FOUND`,`No hierarchy route for "${t}" in "${n}" from ${G(r.connect)} to ${G(i.connect)}`,{edgeId:t,containerId:n})}e(Di,`sparseContainerSegment`);function Oi(e,t,n,r,i,a,o){let s=e[0].pairKey,c=t.get(s),l=[...new Set(e.flatMap(e=>[...e.source.chain,...e.target.chain].map(({demandKey:e})=>e)))],u=new Map,d=new Map;for(let e of l){let t=n.get(e);t&&u.set(e,t);let i=r.get(e);i!==void 0&&d.set(e,i)}let f=o.get(e[0].lcaContainerId);return{pairKey:s,occupancy:f?{index:f,size:f.size}:void 0,pairRoutes:c?[...c]:void 0,demandKeys:l,pairedPortals:u,demandCoords:d,edges:e.map(({edge:e})=>({edge:e,points:e.points,curve:e.curve,cornerRadius:e.cornerRadius})),instrumentedRoutesLength:i?.length,metrics:a?ni(a):void 0}}e(Oi,`createBundleCheckpoint`);function ki(e,t,n,r,i,a){e.occupancy?.index.truncate(e.occupancy.size),e.pairRoutes?t.set(e.pairKey,[...e.pairRoutes]):t.delete(e.pairKey);for(let t of e.demandKeys){let i=e.pairedPortals.get(t);i?n.set(t,i):n.delete(t);let a=e.demandCoords.get(t);a===void 0?r.delete(t):r.set(t,a)}for(let t of e.edges)t.edge.points=t.points,t.edge.curve=t.curve,t.edge.cornerRadius=t.cornerRadius;i&&e.instrumentedRoutesLength!==void 0&&(i.length=e.instrumentedRoutesLength),a&&e.metrics&&ri(a,e.metrics)}e(ki,`restoreBundleCheckpoint`);var Ai=class{constructor(e,t,n,r){this.layout=e,this.result=t,this.metrics=n,this.options=r,this.searchWorkspace=new li,this.pairedPortals=new Map,this.ownerSideCounts=new Map,this.selfLoopCounts=new Map,this.pairRoutes=new Map,this.routed=!1}static{e(this,`GridEdgeRoutingSession`)}route(){if(this.routed)throw Error(`Grid edge routing session can only be run once`);this.routed=!0,this.prepare();let e=new Map;for(let t of this.prepared.orderedPlans){let n=e.get(t.pairKey)??[];n.push(t),e.set(t.pairKey,n)}for(let t of e.values())this.routeBundle(t)}prepare(){Wr(this.result),this.prepared=ir(this.layout,this.result),this.modes=$r(this.prepared,this.result,this.metrics,this.options),this.routingContext=Jr(this.modes.routedContainerIds,this.result,this.metrics,this.options),this.endpointOverlayScratch=new Map([...this.routingContext.topologies].map(([e,t])=>[e,new sn(t)])),this.instrumentedRoutes=this.metrics?[]:void 0;let e=new Set;for(let t of this.prepared.orderedPlans)if(t.edge.start!==t.edge.end)for(let n of[...t.source.chain,...t.target.chain]){if(e.has(n.demandKey))continue;e.add(n.demandKey);let t=Nn(n.ownerId,n.side);this.ownerSideCounts.set(t,(this.ownerSideCounts.get(t)??0)+1)}}pairedPortal(e){let t=this.pairedPortals.get(e.demandKey);if(t)return t;let n=this.result.forest.nodeById.get(e.ownerId);if(!n?.isGroup)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing portal owner "${e.ownerId}"`);let r=or(n),i=this.prepared.demandCoords.get(e.demandKey)??(e.side===`left`||e.side===`right`?(r.top+r.bottom)/2:(r.left+r.right)/2),a=Tn(e.ownerId,r,n.groupTitleRect).find(({side:t})=>t===e.side);if(!a)throw D(`GRID_ROUTE_NOT_FOUND`,`No legal ${e.side} portal for "${e.ownerId}"`);let o=En(e.ownerId,r,n.groupTitleRect?{...n.groupTitleRect}:void 0,e.side,w(i,a.low,a.high));return this.pairedPortals.set(e.demandKey,o),this.metrics&&(this.metrics.hierarchyPortalPairs++,this.metrics.hierarchyPortalTransitionLength+=o.transition.length),o}alternativePairedPortals(t,n=!0){let r=this.pairedPortal(t),i=this.result.forest.nodeById.get(t.ownerId);if(!i?.isGroup)return[];let a=or(i),o=Tn(t.ownerId,a,i.groupTitleRect).find(({side:e})=>e===t.side);if(!o)return[];let s=this.result.containers.get(i.id),c=t.side===`left`||t.side===`right`?s?.horizontalCorridors:s?.verticalCorridors;return Er(r.tangentialCoordinate,o.low,o.high,c??[]).map(r=>{let o=En(t.ownerId,a,i.groupTitleRect?{...i.groupTitleRect}:void 0,t.side,r);return{attachment:Fr(o,n),select:e(()=>{this.pairedPortals.set(t.demandKey,o),this.prepared.demandCoords.set(t.demandKey,r)},`select`)}})}itemSegmentAttachment(e,t){return{ownerId:e.ownerId,...Mr(e.ownerId,e.side,e.demandKey,t,this.result,this.prepared.demandCoords)}}alternativeItemAttachments(t,n,r){let i=this.itemSegmentAttachment(n,r),a=this.result.forest.nodeById.get(n.ownerId);return a?[`right`,`bottom`,`left`,`top`].filter(e=>e!==i.side&&!(e===`top`&&Mn(a))).map(e=>{let i=q(a,e);if(!i)return;let o=g(a),s=e===`left`||e===`right`?o.cy:o.cx,c=Math.max(i.low,Math.min(i.high,s+t.laneOffset));return{ownerId:n.ownerId,...Mr(n.ownerId,e,n.demandKey,r,this.result,this.prepared.demandCoords,c)}}).filter(e=>e!==void 0).slice(0,3).map(t=>({attachment:t,select:e(()=>void 0,`select`)})):[]}routePlan(t,n=!0){let r=this.result,i=this.routingContext,a=this.searchWorkspace,o=this.endpointOverlayScratch,s=this.prepared.demandCoords,c=this.ownerSideCounts,l=this.selfLoopCounts,u=this.pairRoutes,d=this.instrumentedRoutes,f=this.metrics,p=this.options,m=this.prepared.eligibleIds,h=this.prepared.endpointCandidatesByEdge,g=this.modes.compatibilityFastRoutes,_=this.modes.sparseHierarchyIds,v=this.modes.sparseLcaIds,y=t.edge,b=y.start?r.forest.nodeById.get(y.start):void 0,x=y.end?r.forest.nodeById.get(y.end):void 0;if(!b||!x)throw D(`GRID_MISSING_ENDPOINT`,`Missing endpoint for edge "${y.id}"`,{edgeId:y.id});if(b.id===x.id){let e=u.get(t.pairKey)??[],{points:n,side:s,index:m}=Ei(t,b,r,i,a,o.get(b.parentId??T),c,l,e,p),h=`${b.id}:${s}`;l.set(h,m+1),y.points=n,y.curve=r.config.curve,y.cornerRadius=r.config.edgeCornerRadius,e.push(n),u.set(t.pairKey,e),f&&d&&(oi(f,y.id,n,d,0,t.laneOffset),d.push(n));return}let S=t.source.chain[t.source.chain.length-1],C=t.target.chain[t.target.chain.length-1],w=v.has(y.id),E=w?void 0:Xr(t,r,s),O=E?E.start:t.source.finalKind===`boundary`?Ir(S.ownerId,S.side,S.demandKey,r,s):t.source.chain.length>1?Fr(this.pairedPortal(S),!1):this.itemSegmentAttachment(S,t.lcaContainerId),k=E?E.end:t.target.finalKind===`boundary`?Ir(C.ownerId,C.side,C.demandKey,r,s):t.target.chain.length>1?Fr(this.pairedPortal(C),!1):this.itemSegmentAttachment(C,t.lcaContainerId),A,j=e(()=>A??=jr(t.lcaContainerId,r,O,k,t.laneIndex),`legacyRoute`),M=g.get(y.id),ee=M?(f&&f.compatibilityFastPaths++,M):m.has(y.id)?wi(t,h.get(y.id).sources,h.get(y.id).targets,b,x,j,r,i,a,o.get(t.lcaContainerId),p,u.get(t.pairKey)??[],{index:this.occupancyFor(t.lcaContainerId),pairKey:t.pairKey,prioritizeEndpointCandidates:this.prepared.coordinatedEndpointIds.has(y.id)}):w?Di(y.id,t.lcaContainerId,O,k,j,r,i,a,o.get(t.lcaContainerId),p,u.get(t.pairKey)??[],()=>t.target.finalKind===`item`&&t.target.chain.length>1?this.alternativePairedPortals(C,!1):[],()=>t.source.finalKind===`item`&&t.source.chain.length>1?this.alternativePairedPortals(S,!1):[],t.bundleSize>1,this.modes.overlapAvoidanceEnabled?{index:this.occupancyFor(t.lcaContainerId),pairKey:t.pairKey}:void 0):Yr(y.id,t.lcaContainerId,O,k,j,r,f),N=e((e,n)=>{if(!_.has(y.id)){for(let{containerId:i,start:a,end:o}of Zr(e,r,s))n.push(Yr(y.id,i,a,o,()=>jr(i,r,a,o,t.laneIndex),r,f));return}for(let s=0;s<e.chain.length-1;s++){let c=e.chain[s],l=e.chain[s+1],d=s===0?this.itemSegmentAttachment(c,l.ownerId):Fr(this.pairedPortal(c),!1),f=Fr(this.pairedPortal(l),!0);n.push(Di(y.id,l.ownerId,d,f,()=>jr(l.ownerId,r,d,f,t.laneIndex),r,i,a,o.get(l.ownerId),p,u.get(t.pairKey)??[],()=>this.alternativePairedPortals(l),()=>s===0?this.alternativeItemAttachments(t,c,l.ownerId):[],t.bundleSize>1))}},`routeHierarchyChain`),P=[],F=[];N(t.source,P),N(t.target,F);let I=Rr([...P,ee,...F.reverse().map(e=>Lr(e))]),L=u.get(t.pairKey)??[],te=Y(I,L),R=!te&&t.bundleSize>1&&t.source.chain.length+t.target.chain.length>2&&mr(I,L);if(t.bundleSize>1&&!te&&(!R||!n))throw f&&f.routesImpossible++,D(`GRID_ROUTE_NOT_FOUND`,`No distinct lane route for "${y.id}"`,{edgeId:y.id,reason:R?`pair-separation`:`no-distinct-route`});if(R&&f&&f.bundleSeparationRelaxations++,y.points=I,y.curve=r.config.curve,y.cornerRadius=r.config.edgeCornerRadius,L.push(I),u.set(t.pairKey,L),M||this.occupancyFor(t.lcaContainerId).add(ee,t.pairKey),f&&d){let e=t.source.chain.length+t.target.chain.length-2;oi(f,y.id,I,d,e,t.laneOffset),d.push(I)}}occupancyFor(e){let t=this.modes.routeOccupancy.get(e);return t||(t=new vr,this.modes.routeOccupancy.set(e,t)),t}createBundleCheckpoint(e){return this.occupancyFor(e[0].lcaContainerId),Oi(e,this.pairRoutes,this.pairedPortals,this.prepared.demandCoords,this.instrumentedRoutes,this.metrics,this.modes.routeOccupancy)}restoreBundleCheckpoint(e){ki(e,this.pairRoutes,this.pairedPortals,this.prepared.demandCoords,this.instrumentedRoutes,this.metrics)}routeBundle(e){if(!(e.length>1&&e.length<=8&&e.every(({edge:e})=>e.start!==e.end))){for(let t of e)this.routePlan(t);return}let t=this.createBundleCheckpoint(e),n;try{for(let t of e)this.routePlan(t,!1);return}catch(e){n=e,this.restoreBundleCheckpoint(t)}if(!ar(n))throw n;for(let t of e)this.routePlan(t)}};function ji(e,t,n,r={}){new Ai(e,t,n,r).route()}e(ji,`routeGridEdges`);var Mi=24,Ni=20;function Pi(e,t){return!e.label||!e.labelBBox||!(e.labelBBox.height>0)?0:e.labelBBox.height+t}e(Pi,`titleBandFor`);function Fi(e){if(!A(e.width)||!A(e.height))throw D(`GRID_MISSING_MEASUREMENT`,`Node "${e.id}" must have width and height greater than 0 (width: ${e.width}, height: ${e.height})`,{nodeId:e.id,width:e.width,height:e.height})}e(Fi,`ensureMeasuredNode`);function Ii(e){return Fi(e),{width:e.width,height:e.height}}e(Ii,`measureChild`);function Li(t,n,r,i,a){let{forest:o,config:s,sourceOrder:c}=n,l=t===T?void 0:o.groupById.get(t),u=l?Math.max(l.padding??0,s.containerPadding):0,d=l?Pi(l,s.titleGap):0,f=l?Mi:0,p=l?u+d+f:0,{cells:m}=qt((o.childrenByParent.get(t)??[]).filter(e=>!k(e)),c,s),h=[...m.values()].sort((e,t)=>e.row-t.row||e.column-t.column),g=new Map,_=new Map,v=new Set,y=new Set;for(let e of h){let t=0,n=0;for(let r of e.items){let e=Ii(r.item);t=Math.max(t,e.width),n+=e.height}e.items.length>1&&(n+=s.cellGap*(e.items.length-1)),e.width=t,e.height=n,v.add(e.row),y.add(e.column),g.set(e.column,Math.max(g.get(e.column)??0,t)),_.set(e.row,Math.max(_.get(e.row)??0,n))}let b=[...v].sort((e,t)=>e-t),x=[...y].sort((e,t)=>e-t),S=Pt(n.labelRequirements.byContainer.get(t)??[],m,_,g,b,x,s.rowGap,s.columnGap,a),C=e(e=>Math.max(s.rowGap,S.rowGapAfter.get(e)??0),`rowGapAfter`),w=e(e=>Math.max(s.columnGap,S.columnGapAfter.get(e)??0),`columnGapAfter`);if(a){for(let e of S.rowGapAfter.values())e>s.rowGap&&(a.labelSpacingBoundariesExpanded++,a.labelSpacingPixelsAdded+=e-s.rowGap);for(let e of S.columnGapAfter.values())e>s.columnGap&&(a.labelSpacingBoundariesExpanded++,a.labelSpacingPixelsAdded+=e-s.columnGap)}let E=x.reduce((e,t,n)=>e+(g.get(t)??0)+(n<x.length-1?w(t):0),0),D=l?Math.max(E+(u+f)*2,(l.labelBBox?.width??0)+u*2):E,A=l?(D-E)/2:0,j=new Map,M=A;for(let[e,t]of x.entries())j.set(t,M),M+=(g.get(t)??0)+(e<x.length-1?w(t):0);let ee=new Map,N=p;for(let[e,t]of b.entries())ee.set(t,N),N+=(_.get(t)??0)+(e<b.length-1?C(t):0);let P=b.length?N-p:0,F=l?A-Ni:-Math.max(s.columnGap/2,O.containerPadding),I=l?A+E+Ni:A+E+Math.max(s.columnGap/2,O.containerPadding),L=l?p-Ni:-Math.max(s.rowGap/2,O.containerPadding),te=l?p+P+Ni:p+P+Math.max(s.rowGap/2,O.containerPadding),R=new Set([F,I]),ne=new Set([L,te]),re=new Map,ie=new Map,z=new Map,B=new Map;x.length>0&&(re.set(x[0],F),ie.set(x.at(-1),I));for(let e=0;e<x.length-1;e++){let t=x[e],n=x[e+1],r=(j.get(t)+(g.get(t)??0)+j.get(n))/2;R.add(r),ie.set(t,r),re.set(n,r)}b.length>0&&(z.set(b[0],L),B.set(b.at(-1),te));for(let e=0;e<b.length-1;e++){let t=b[e],n=b[e+1],r=(ee.get(t)+(_.get(t)??0)+ee.get(n))/2;ne.add(r),B.set(t,r),z.set(n,r)}for(let e of h){let n=j.get(e.column)??A,r=ee.get(e.row)??p,a=g.get(e.column)??e.width,o=_.get(e.row)??e.height,c=e.verticalAlign===`top`?0:e.verticalAlign===`bottom`?1:.5,l=r+(o-e.height)*c;for(let[c,u]of e.items.entries()){let{width:d,height:f}=Ii(u.item),p=u.horizontalAlign===`left`?0:u.horizontalAlign===`right`?1:.5,m=n+(a-d)*p;u.item.x=m+d/2,u.item.y=l+f/2;let h=c>0?l-s.cellGap/2:z.get(e.row)??L,g=c<e.items.length-1?l+f+s.cellGap/2:B.get(e.row)??te;c>0&&ne.add(h),c<e.items.length-1&&ne.add(g),i.set(u.item.id,{containerId:t,row:e.row,column:e.column,cellLeft:n,cellTop:r,cellWidth:a,cellHeight:o,leftCorridorX:re.get(e.column)??F,rightCorridorX:ie.get(e.column)??I,topCorridorY:h,bottomCorridorY:g}),l+=f+s.cellGap}}let ae=l?P+d+(u+f)*2:P;r.set(t,{id:t,left:0,top:0,width:D,height:ae,contentLeft:A,contentTop:p,contentRight:l?A+E:E,contentBottom:l?p+P:P,verticalCorridors:[...R].sort((e,t)=>e-t),horizontalCorridors:[...ne].sort((e,t)=>e-t)}),l&&(l.width=D,l.height=ae,l.x=D/2,l.y=ae/2,d>0?l.groupTitleRect={left:0,right:D,top:0,bottom:u+d}:delete l.groupTitleRect)}e(Li,`layoutContainer`);function Ri(e,t,n){return{left:e.left+t,right:e.right+t,top:e.top+n,bottom:e.bottom+n}}e(Ri,`translateRect`);function zi(e){let{forest:t,containers:n,itemMeta:r}=e,i=[{containerId:T,offsetX:0,offsetY:0,children:t.childrenByParent.get(T)??[],nextChildIndex:0,entered:!1}];for(;i.length>0;){let e=i[i.length-1];if(!e.entered){e.entered=!0;let t=n.get(e.containerId);t&&(t.left+=e.offsetX,t.top+=e.offsetY,t.contentLeft+=e.offsetX,t.contentRight+=e.offsetX,t.contentTop+=e.offsetY,t.contentBottom+=e.offsetY,t.verticalCorridors=t.verticalCorridors.map(t=>t+e.offsetX),t.horizontalCorridors=t.horizontalCorridors.map(t=>t+e.offsetY))}let a=e.children[e.nextChildIndex];if(!a){i.pop();continue}if(e.nextChildIndex+=1,k(a))continue;let o=r.get(a.id);o&&(o.cellLeft+=e.offsetX,o.cellTop+=e.offsetY,o.leftCorridorX+=e.offsetX,o.rightCorridorX+=e.offsetX,o.topCorridorY+=e.offsetY,o.bottomCorridorY+=e.offsetY),a.x=(a.x??0)+e.offsetX,a.y=(a.y??0)+e.offsetY,a.isGroup&&(a.groupTitleRect&&=Ri(a.groupTitleRect,a.x-(a.width??0)/2,a.y-(a.height??0)/2),i.push({containerId:a.id,offsetX:a.x-(a.width??0)/2,offsetY:a.y-(a.height??0)/2,children:t.childrenByParent.get(a.id)??[],nextChildIndex:0,entered:!1}))}}e(zi,`materializeAbsoluteGeometry`);function Bi(e,t){let n=new Map(e.nodes.map(e=>[e.id,e]));for(let e of t.nodes){let t=n.get(e.id);t&&(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,t.groupTitleRect?e.groupTitleRect={...t.groupTitleRect}:delete e.groupTitleRect)}let r=new Map(e.edges.map(e=>[e.id,e]));for(let e of t.edges){let t=r.get(e.id);t&&(e.points=t.points?.map(e=>({...e})),e.curve=t.curve,e.cornerRadius=t.cornerRadius,e.portClipping=`outline-orthogonal`,e.skipCornerFix=t.curve===`linear`)}}e(Bi,`commitGridGeometry`);function Vi(e){return{...e,nodes:e.nodes.map(e=>({...e,labelBBox:e.labelBBox?{...e.labelBBox}:e.labelBBox,groupTitleRect:e.groupTitleRect?{...e.groupTitleRect}:e.groupTitleRect})),edges:e.edges.map(e=>({...e,points:e.points?.map(e=>({...e}))}))}}e(Vi,`cloneGridLayoutData`);function Hi(t,n){let r=new Map(n.map(e=>[e.id,e])),i=e(e=>{let t=r.get(e.id);if(!t)throw Error(`Missing committed grid node "${e.id}"`);return t},`originalNode`),a=e(e=>{let t=i(e);if(!t.isGroup)throw Error(`Committed grid node "${e.id}" is no longer a group`);return t},`originalGroup`);return{nodeById:r,groupById:new Map([...t.groupById].map(([e,t])=>[e,a(t)])),childrenByParent:new Map([...t.childrenByParent].map(([e,t])=>[e,t.map(i)])),rootChildren:t.rootChildren.map(i),postOrderGroups:t.postOrderGroups.map(a),helperNodeIds:new Set(t.helperNodeIds)}}e(Hi,`rebindGridForest`);function Ui(e,t){let n=Et(e.nodes),r=Bt(e),i=zt(e.nodes.filter(e=>!k(e)));Vt(e.nodes.filter(e=>!k(e)),r);let a={forest:n,config:r,containers:new Map,itemMeta:new Map,sourceOrder:i,labelRequirements:Ot(e,n,t.metrics)};for(let e of n.postOrderGroups)Li(e.id,a,a.containers,a.itemMeta,t.metrics);return Li(T,a,a.containers,a.itemMeta,t.metrics),zi(a),ji(e,a,t.metrics,t.routing),wt(e,void 0,t.metrics),a}e(Ui,`runGridLayoutCoreInPlace`);function Wi(e,t={}){let n=e,r=Vi(n),i=Ui(r,t);return Bi(r,n),{...i,forest:Hi(i.forest,n.nodes)}}e(Wi,`runGridLayoutCore`);function Gi(e,{measure:t}){let n=s(e.config.grid?.lineHops);if(n===!1)return;let r=e.edges.filter(e=>Array.isArray(e.points)&&e.points.length>=2).map(e=>({id:e.id,points:e.points,curve:e.curve,cornerRadius:e.cornerRadius,arrowTypeStart:e.arrowTypeStart,arrowTypeEnd:e.arrowTypeEnd}));c(t.groups.edgePaths,r,{enabled:!0,jumpRadius:6,jumpStyle:n})}e(Gi,`applyGridLineJumps`);var Ki=o({prepareLayout:Ct,runLayoutCore:e(e=>Wi(e),`runLayoutCore`),afterPaint:Gi});export{Ct as prepareGridLayout,Ki as render,Wi as runGridLayoutCore};
|