repo-harness-operator-web 0.38.1 → 0.38.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.
Files changed (89) hide show
  1. package/dist/assets/{ArchitectureWorkspace-DEZiLX07.js → ArchitectureWorkspace-kvsRmC8B.js} +1 -1
  2. package/dist/assets/{DocsPage-CzEnpNBl.js → DocsPage-r-Sp6WlY.js} +3 -3
  3. package/dist/assets/{abnfDiagram-S7VZAUFO-CW2GGWrO.js → abnfDiagram-S7VZAUFO-D3LM5fln.js} +1 -1
  4. package/dist/assets/{architecture-WOLXFQ4H-CTrb9pmq.js → architecture-WOLXFQ4H-CabBe-sj.js} +1 -1
  5. package/dist/assets/{architectureDiagram-YGSQEFNW-CH-FENDY.js → architectureDiagram-YGSQEFNW-om0vcl52.js} +1 -1
  6. package/dist/assets/{blockDiagram-APKKGZFW-BCH3ZfhF.js → blockDiagram-APKKGZFW-CscXJf6t.js} +1 -1
  7. package/dist/assets/{c4Diagram-KJ2TOQU5-BfJIuTs0.js → c4Diagram-KJ2TOQU5-DJ-0nNLF.js} +1 -1
  8. package/dist/assets/{chunk-6MUBBAK2-C902lzgu.js → chunk-6MUBBAK2-Br-kS_pl.js} +1 -1
  9. package/dist/assets/{chunk-AXFCVDMN-D874Vknk.js → chunk-AXFCVDMN-C7XZUUII.js} +1 -1
  10. package/dist/assets/{chunk-BG4553SI-DZuKRPuE.js → chunk-BG4553SI-C8y9Fo1H.js} +1 -1
  11. package/dist/assets/{chunk-DQASFODM-C2bAunvg.js → chunk-DQASFODM-T1zQG8lU.js} +1 -1
  12. package/dist/assets/{chunk-HFQBQIA3-nTrCsapA.js → chunk-HFQBQIA3-B78kkTrN.js} +1 -1
  13. package/dist/assets/{chunk-KQLB2F66-DDL5s9_E.js → chunk-KQLB2F66-DBbhBx6L.js} +1 -1
  14. package/dist/assets/{chunk-KS47KZWR-DV84q_Au.js → chunk-KS47KZWR-CJsG3B0i.js} +1 -1
  15. package/dist/assets/{chunk-LEVMRMFU-C4X-7ikL.js → chunk-LEVMRMFU-xbPQdK6W.js} +1 -1
  16. package/dist/assets/{chunk-M57EVK23-DfOqyVKO.js → chunk-M57EVK23--k3Bab9e.js} +1 -1
  17. package/dist/assets/{chunk-OY52VR5R-D055EAjP.js → chunk-OY52VR5R-DzF3S4Lo.js} +1 -1
  18. package/dist/assets/{chunk-QB3YPZ4I-S7mRby8M.js → chunk-QB3YPZ4I-BQ1IzLj9.js} +1 -1
  19. package/dist/assets/{chunk-R3KSYZAL-CgkH0fla.js → chunk-R3KSYZAL-leQhmizL.js} +1 -1
  20. package/dist/assets/{chunk-STOXU5M4-BAdl-SmH.js → chunk-STOXU5M4-MHEj2bnZ.js} +1 -1
  21. package/dist/assets/{chunk-TU62E6Q5-CN5cRc5B.js → chunk-TU62E6Q5-BuV2OA5Y.js} +1 -1
  22. package/dist/assets/{chunk-X4PVCEUW-CwEb33bN.js → chunk-X4PVCEUW-CzvOiK7y.js} +1 -1
  23. package/dist/assets/{classDiagram-v2-L25IHNXF-Dzi7tVWz.js → classDiagram-v2-L25IHNXF-BS_ayrk7.js} +1 -1
  24. package/dist/assets/cynefin-EF2NZ3EQ-BMCiXC8M.js +1 -0
  25. package/dist/assets/{cynefinDiagram-L36ESFBY-C9YKkBGS.js → cynefinDiagram-L36ESFBY-VCFf9fQ7.js} +1 -1
  26. package/dist/assets/{dagre-SPEB5RXH-CvBbXuLF.js → dagre-SPEB5RXH-BVE-tjto.js} +1 -1
  27. package/dist/assets/{diagram-3B7GL73J-BP1nhMcu.js → diagram-3B7GL73J-C1M00tGS.js} +1 -1
  28. package/dist/assets/{diagram-DNEMPZML-Dnk9QLxN.js → diagram-DNEMPZML-C5H5I9Nw.js} +1 -1
  29. package/dist/assets/{diagram-L3MUGCDN-XlwAWBKk.js → diagram-L3MUGCDN-TMEope3q.js} +1 -1
  30. package/dist/assets/{diagram-LA4NIPWU-Bo2SE8IL.js → diagram-LA4NIPWU--dIvakvv.js} +1 -1
  31. package/dist/assets/{diagram-MHCOC4E2-BDB4PGP0.js → diagram-MHCOC4E2-DZc-Q6FM.js} +1 -1
  32. package/dist/assets/{diagram-XPFHEONP-gKkkTxEY.js → diagram-XPFHEONP-BNQjCv5f.js} +1 -1
  33. package/dist/assets/{ebnfDiagram-UZSYDL2S-BU8ZjFA3.js → ebnfDiagram-UZSYDL2S-BPkQUslL.js} +1 -1
  34. package/dist/assets/{elk-XV6XMXQE-Qu9SCRSr.js → elk-XV6XMXQE-tv04O-NP.js} +1 -1
  35. package/dist/assets/{erDiagram-EYBAPDEH-D1lJbqmh.js → erDiagram-EYBAPDEH-DxPnU6xa.js} +1 -1
  36. package/dist/assets/{eventmodeling-K75KTNOO-DNMVpzz6.js → eventmodeling-K75KTNOO-DKsITbOR.js} +1 -1
  37. package/dist/assets/flowDiagram-MALGAFMO-BkhHxSAW.js +1 -0
  38. package/dist/assets/{ganttDiagram-23REXITY-DtIOC9hy.js → ganttDiagram-23REXITY-D7-G-I-7.js} +1 -1
  39. package/dist/assets/gitGraph-VSP46ZUC-DmPC4EPW.js +1 -0
  40. package/dist/assets/{gitGraphDiagram-STJD7YCW-CXKNaMae.js → gitGraphDiagram-STJD7YCW-DVE5HfN5.js} +1 -1
  41. package/dist/assets/{index-w8rsciSQ.js → index-bVNVpteB.js} +9 -9
  42. package/dist/assets/info-OHQRW6UA-C-7q701x.js +1 -0
  43. package/dist/assets/{infoDiagram-KBXO4MBG-MT0fg2E7.js → infoDiagram-KBXO4MBG-7y3ziWtl.js} +1 -1
  44. package/dist/assets/{ishikawaDiagram-M35NCXHK-BSoj49Eh.js → ishikawaDiagram-M35NCXHK-DwEXms_5.js} +1 -1
  45. package/dist/assets/{journeyDiagram-OPLOXDXO-CFprtkDR.js → journeyDiagram-OPLOXDXO-aiVM5HxB.js} +1 -1
  46. package/dist/assets/{kanban-definition-BZKZHSQY-fycZ5N-e.js → kanban-definition-BZKZHSQY-B145-Ha3.js} +1 -1
  47. package/dist/assets/{line-5GPIn-T0.js → line-BeLi_-eF.js} +1 -1
  48. package/dist/assets/{mermaid-parser.core-CHK8gTfm.js → mermaid-parser.core-WjTqLnjJ.js} +3 -3
  49. package/dist/assets/{mermaid.core-D3kbNjMD.js → mermaid.core-BMsECKRW.js} +4 -4
  50. package/dist/assets/{mindmap-definition-I2QAS2VK-Nz0Ouq_B.js → mindmap-definition-I2QAS2VK-Dahj0vBG.js} +1 -1
  51. package/dist/assets/packet-JDAUHWVQ-Cwe-krjq.js +1 -0
  52. package/dist/assets/{pegDiagram-FD4XPPHP-CYX4N2bw.js → pegDiagram-FD4XPPHP-CZB7C1Ur.js} +1 -1
  53. package/dist/assets/pie-XZMESJXO-Dr6miCi_.js +1 -0
  54. package/dist/assets/{pieDiagram-J4AKIIQI-Ber2w3zZ.js → pieDiagram-J4AKIIQI-my8MgVDj.js} +1 -1
  55. package/dist/assets/{quadrantDiagram-XTYBLID2-CIMDNI1G.js → quadrantDiagram-XTYBLID2-DBjDhhqk.js} +1 -1
  56. package/dist/assets/radar-ABXABTNO-Dc6lp3Jw.js +1 -0
  57. package/dist/assets/railroad-I3PHUGI6-0WbSOcWv.js +1 -0
  58. package/dist/assets/{railroad-abnf-LNEFI6M7-D4t3Ck2x.js → railroad-abnf-LNEFI6M7-JdJe3A_W.js} +1 -1
  59. package/dist/assets/{railroad-ebnf-DWYD2UWJ-Db7Ms7uC.js → railroad-ebnf-DWYD2UWJ-CERW_rkq.js} +1 -1
  60. package/dist/assets/{railroad-peg-JR7BVNR7-jNEmjOnK.js → railroad-peg-JR7BVNR7-Vx-Fc2VB.js} +1 -1
  61. package/dist/assets/{railroadDiagram-MRQ6NCDL-DX8gvNEp.js → railroadDiagram-MRQ6NCDL-CdtKKjgC.js} +1 -1
  62. package/dist/assets/{requirementDiagram-Y7LWUY3S-CnZ7smsV.js → requirementDiagram-Y7LWUY3S-CZhYcXPO.js} +1 -1
  63. package/dist/assets/{sankeyDiagram-WGJFYUXA-BWRUMe1G.js → sankeyDiagram-WGJFYUXA-6rS3hyJ9.js} +1 -1
  64. package/dist/assets/{sequenceDiagram-5NDRBG5M-D8tl7eHx.js → sequenceDiagram-5NDRBG5M-BaHtfa-e.js} +1 -1
  65. package/dist/assets/{stateDiagram-v2-FJ4FJNEA-GzyUCwz9.js → stateDiagram-v2-FJ4FJNEA-BfFrHB-0.js} +1 -1
  66. package/dist/assets/{swimlanes-UMQ2AFYF-DC7e0HdV.js → swimlanes-UMQ2AFYF-DPvIIj2m.js} +1 -1
  67. package/dist/assets/swimlanesDiagram-OMPLPG4O-B6hdZjDt.js +8 -0
  68. package/dist/assets/{timeline-definition-SEUHKTQE-Hs4XFlpe.js → timeline-definition-SEUHKTQE-D6eosEKP.js} +1 -1
  69. package/dist/assets/treeView-D4JQ5SDB-9dChzUTX.js +1 -0
  70. package/dist/assets/treemap-SAJKECNS-DFlstQBx.js +1 -0
  71. package/dist/assets/{usecaseDiagram-AFA6YXN4-DsgCrrlT.js → usecaseDiagram-AFA6YXN4-Bjox5eEW.js} +1 -1
  72. package/dist/assets/{vennDiagram-NNMJR3RB-VncrHU6S.js → vennDiagram-NNMJR3RB-9KK8TfLW.js} +1 -1
  73. package/dist/assets/wardley-7MLQ67FV-DIlx1oB0.js +1 -0
  74. package/dist/assets/{wardleyDiagram-S7YFUSEH-CLZXKWGJ.js → wardleyDiagram-S7YFUSEH-BlsfvS-a.js} +1 -1
  75. package/dist/assets/{xychartDiagram-GGNKY7IX-Ckkbcvas.js → xychartDiagram-GGNKY7IX-BGQQ_jDU.js} +1 -1
  76. package/dist/index.html +1 -1
  77. package/package.json +1 -1
  78. package/dist/assets/cynefin-EF2NZ3EQ-BP8wwz9p.js +0 -1
  79. package/dist/assets/flowDiagram-MALGAFMO-DuKfWAAu.js +0 -1
  80. package/dist/assets/gitGraph-VSP46ZUC-UcIL_0pM.js +0 -1
  81. package/dist/assets/info-OHQRW6UA-DFnq4v-c.js +0 -1
  82. package/dist/assets/packet-JDAUHWVQ-Dj1AjMmL.js +0 -1
  83. package/dist/assets/pie-XZMESJXO-CFj2HYxi.js +0 -1
  84. package/dist/assets/radar-ABXABTNO-DyMiOLQF.js +0 -1
  85. package/dist/assets/railroad-I3PHUGI6-CXTf2DZr.js +0 -1
  86. package/dist/assets/swimlanesDiagram-OMPLPG4O-DoOpBoPS.js +0 -8
  87. package/dist/assets/treeView-D4JQ5SDB-BnkBp751.js +0 -1
  88. package/dist/assets/treemap-SAJKECNS-t25rCWm_.js +0 -1
  89. package/dist/assets/wardley-7MLQ67FV-BKAst9Xr.js +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,C as n,E as r,O as i,S as a,_ as o,b as s,c,g as l,h as u,j as d,l as f,n as p,o as m,p as h,v as g,x as _,y as v}from"./index-w8rsciSQ.js";import{C as y,S as b,T as x,_ as S,b as C,i as w,n as T,r as E,t as D,v as O,w as k,x as A,y as j}from"./src-C_gRsKqw.js";import{t as M}from"./value-CHmTzbgv.js";var N=e=>()=>e;function P(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}P.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function F(e){return!e.ctrlKey&&!e.button}function ee(){return this.parentNode}function te(e,t){return t??{x:e.x,y:e.y}}function I(){return navigator.maxTouchPoints||`ontouchstart`in this}function ne(){var e=F,t=ee,n=te,r=I,i={},a=x(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,C).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=w(this,t.call(this,n,r),n,r,`mouse`);i&&(k(n.view).on(`mousemove.drag`,m,A).on(`mouseup.drag`,h,A),S(n.view),b(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(j(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){k(e.view).on(`mousemove.drag mouseup.drag`,null),O(e.view,l),j(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=w(this,a,n,r,i[s].identifier,i[s]))&&(b(n),c(`start`,n,i[s]))}function _(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(j(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(b(e),a(`end`,e,t[r]))}function w(e,t,r,s,c,l){var u=a.copy(),d=y(l||r,t),p,m,h;if((h=n.call(e,new P(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=y(l||a,t),_=o}u.call(r,e,new P(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:N(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:N(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:N(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:N(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var L=e(d(),1);function re(e){return e.kind===`group`}var ie=/^capability\.[a-z0-9-]+(\.[a-z0-9-]+)+$/,ae=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,oe=[`accepted`,`acknowledged`,`deferred`,`resolved`,`rejected`,`waived`],R=e=>typeof e==`string`,se=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,ce=e=>se(e)&&e>0,le=e=>typeof e==`boolean`,ue=e=>t=>R(t)&&e.test(t),z=(...e)=>t=>e.includes(t),de=e=>t=>t===null||e(t),B=e=>t=>Array.isArray(t)&&t.every(e),V=e=>t=>{if(!t||typeof t!=`object`||Array.isArray(t))return!1;let n=t;return Object.keys(n).length===Object.keys(e).length&&Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&t(n[e]))},fe=e=>t=>R(t)&&t.length>0&&t.length<=e&&t===t.trim()&&!/[\x00-\x1f\x7f]/u.test(t),pe=e=>!e||typeof e!=`object`||Array.isArray(e)?!1:Object.entries(e).every(([e,t])=>fe(128)(e)&&(t===null||typeof t==`number`&&Number.isFinite(t))),me=ue(/^[0-9a-f]{64}$/),he=ue(ae),ge=ue(ie),_e=ue(/^recommendation\.[0-9a-f]{16}$/u),ve=ue(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/u),ye=e=>R(e)&&!e.startsWith(`/`)&&!/^[A-Za-z]:/.test(e)&&!/[\\\x00-\x1f\x7f]/.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),be=V({model_valid:z(`valid`,`invalid`,`unknown`),generated_summary:z(`fresh`,`stale`,`unknown`),section3:z(`present`,`pending`)}),xe=V({id:R,from:R,to:R,label:R,evidence:V({entrypointId:R,sourceSymbol:R,sinkId:R})}),Se=e=>V({id:R,capabilityId:ge,name:R,applicability:z(`not-applicable`),rationale:R})(e)||V({id:R,capabilityId:ge,name:R,applicability:z(`required`),participants:B(V({id:R,nodeId:R})),steps:B(xe),outcomes:B(V({id:R,kind:z(`success`,`error`),label:R,steps:B(xe),terminal:V({participant:R,label:R})}))})(e),Ce=e=>typeof e==`string`&&e.length>0&&e!==`group`,we=V({include:B(R),exclude:B(R)}),Te=e=>V({id:R,kind:Ce,name:R,role:z(`center`,`child`,`caller`,`callee`)})(e)||V({id:R,kind:z(`group`),role:z(`caller`,`callee`),count:ce,members:B(V({id:R,name:R}))})(e),Ee=V({schema_version:z(`repo-harness.architecture-modules.v1`),commit:he,modules:B(V({id:ge,domain:R,name:R,status:R,components:se,state:be}))}),De=V({schema_version:z(`repo-harness.architecture-module.v1`),commit:he,module:V({id:ge,name:R,status:R,summary:R,responsibilities:B(R),notes:B(R),source:we,verification:B(R),entrypoints:B(V({id:R,path:ye,symbols:B(V({name:R,sinks:B(V({id:R,path:ye,symbol:R}))}))})),components:B(V({id:R,kind:Ce,name:R,summary:R,source:we}))}),graph:V({center:ge,nodes:B(Te),edges:B(V({source:R,target:R,intent:R,relation_kind:R,direction:z(`directed`)}))}),flows:B(Se),section3:de(R),linked_docs:B(V({path:ye,kind:z(`contract`,`plan`),status:de(R)})),state:be}),Oe=V({schema_version:z(`repo-harness.module-review-prompt.v1`),prompt_version:R,package_version:R,repository_id:ue(/^repo_[0-9a-f]{16}$/),capability_id:ge,commit:he,mode:z(`module`,`diff`),base:de(he),head:de(he),worktree_dirty_paths:B(ye),dirty_content_sha256:de(me),model_sha256:me,doc_sha256:de(me),sources:B(V({path:ye,sha256:me,bytes:se,class:z(`required`,`optional`),disposition:z(`included`,`omitted`,`chunked`)})),budget:V({input_cap_bytes:ce,used_bytes:se,incomplete:le,omitted_sections:B(R)}),shard:V({index:ce,count:ce,bytes:se}),full_prompt_sha256:me,prompt:R,digest:me}),ke=V({accepted:se,acknowledged:se,deferred:se,resolved:se,rejected:se,waived:se}),Ae=V({recommendation_id:_e,category:z(`structural_observation`,`refactor_proposal`),kind:de(z(...g)),subject:fe(512),affected_node_ids:B(fe(256)),status:z(...v),metrics:de(pe),reason:fe(1024),decided_at:ve,head_sha:he,cli_verify_command:fe(128)}),je=V({schema_version:z(`repo-harness.architecture-refactor.v1`),adopted:le,counts:ke,decisions:B(Ae)});function Me(e){return`rh arch refactor verify ${e} --json`}function Ne(e,t){let n=oe.indexOf(e.status)-oe.indexOf(t.status);return n===0?e.recommendation_id<t.recommendation_id?-1:+(e.recommendation_id>t.recommendation_id):n}function Pe(e){if(!Ee(e))throw Error(`architecture_module_index_invalid`);return e}function Fe(e){if(!De(e))throw Error(`architecture_module_detail_invalid`);let t=e,n=new Set(t.graph.nodes.map(e=>e.id));if(t.graph.center!==t.module.id||!n.has(t.graph.center)||n.size!==t.graph.nodes.length||t.graph.edges.some(e=>!n.has(e.source)||!n.has(e.target))||t.graph.nodes.some(e=>re(e)&&e.count!==e.members.length))throw Error(`architecture_module_detail_invalid`);return t}function Ie(e){if(!Oe(e))throw Error(`architecture_review_prompt_invalid`);let t=e;if(t.shard.index>t.shard.count||(t.mode===`module`?t.base!==null||t.head!==null:t.base===null||t.head===null)||t.worktree_dirty_paths.length===0!=(t.dirty_content_sha256===null))throw Error(`architecture_review_prompt_invalid`);return t}function Le(e){if(!je(e))throw Error(`architecture_refactor_decisions_invalid`);let t=e;if(!t.adopted&&t.decisions.length>0)throw Error(`architecture_refactor_decisions_invalid`);let n=new Set;for(let e=0;e<t.decisions.length;e++){let r=t.decisions[e];if(n.has(r.recommendation_id)||(n.add(r.recommendation_id),r.category===`structural_observation`!=(r.kind!==null))||r.cli_verify_command!==Me(r.recommendation_id)||r.affected_node_ids.some((e,t)=>t>0&&e<=r.affected_node_ids[t-1])||e>0&&Ne(t.decisions[e-1],r)>=0)throw Error(`architecture_refactor_decisions_invalid`)}for(let e of oe)if(t.counts[e]!==t.decisions.filter(t=>t.status===e).length)throw Error(`architecture_refactor_decisions_invalid`);return t}var Re=Object.defineProperty,ze=(e,t,n)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Be=(e,t)=>{for(var n in t)Re(e,n,{get:t[n],enumerable:!0})},Ve=(e,t,n)=>ze(e,typeof t==`symbol`?t:t+``,n),He={};Be(He,{Graph:()=>Dt,alg:()=>tt});var Ue=Object.defineProperty,We=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},Ge=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=Je(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=Ye(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Ke(this._preds[a],i),Ke(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Xe(this._isDirected,e):Je(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Xe(this._isDirected,e):Je(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Xe(this._isDirected,e):Je(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],qe(this._preds[t],e),qe(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function Ke(e,t){e[t]?e[t]++:e[t]=1}function qe(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Je(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function Ye(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function Xe(e,t){return Je(e,t.v,t.w,t.name)}We({},{read:()=>et,write:()=>Ze});function Ze(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Qe(e),edges:$e(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Qe(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function $e(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function et(e){let t=new Ge(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var tt={};We(tt,{CycleException:()=>gt,bellmanFord:()=>rt,components:()=>at,dijkstra:()=>ct,dijkstraAll:()=>ut,findCycles:()=>ft,floydWarshall:()=>mt,isAcyclic:()=>vt,postorder:()=>St,preorder:()=>Ct,prim:()=>wt,shortestPaths:()=>Tt,tarjan:()=>dt,topsort:()=>_t});var nt=()=>1;function rt(e,t,n,r){return it(e,String(t),n||nt,r||function(t){return e.outEdges(t)??[]})}function it(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function at(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var ot=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},st=()=>1;function ct(e,t,n,r){return lt(e,String(t),n||st,r||function(t){return e.outEdges(t)??[]})}function lt(e,t,n,r){let i={},a=new ot,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function ut(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=ct(e,i,t,n),r},{})}function dt(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function ft(e){return dt(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var pt=()=>1;function mt(e,t,n){return ht(e,t||pt,n||function(t){return e.outEdges(t)??[]})}function ht(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var gt=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function _t(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new gt;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new gt;return r}function vt(e){try{_t(e)}catch(e){if(e instanceof gt)return!1;throw e}return!0}function yt(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=bt(e,t,n===`post`,o,a,r,i)}),i}function bt(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=bt(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function xt(e,t,n){return yt(e,t,n,function(e,t){return e.push(t),e},[])}function St(e,t){return xt(e,t,`post`)}function Ct(e,t){return xt(e,t,`pre`)}function wt(e,t){var n;let r=new Ge,i={},a=new ot,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function Tt(e,t,n,r){return Et(e,t,n,r??(t=>e.outEdges(t)??[]))}function Et(e,t,n,r){if(n===void 0)return ct(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return rt(e,t,n,r)}return ct(e,t,n,r)}var Dt=Ge;function Ot(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Ut(r);return n.dummy=t,e.setNode(i,n),i}function kt(e){let t=new Dt().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function At(e){let t=new Dt({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function jt(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return i===0||Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function Mt(e){let t=Wt(zt(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function Nt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Rt(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Pt(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Rt(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function Ft(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Ot(e,`border`,i,t)}function It(e,t=Lt){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Lt=65535;function Rt(e,t){return t.length>Lt?e(...It(t).map(t=>e(...t))):e(...t)}function zt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Rt(Math.max,t)}function Bt(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Vt(e,t){return t()}var Ht=0;function Ut(e){return e+(``+ ++Ht)}function Wt(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function Gt(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Kt(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function qt(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Jt=`\0`;function Yt(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var Xt=class{constructor(){Ve(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Zt(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Zt(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,Qt)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Zt(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Qt(e,t){if(e!==`_next`&&e!==`_prev`)return t}var $t=Xt,en=()=>1;function tn(e,t){if(e.nodeCount()<=1)return[];let n=an(e,t||en);return nn(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function nn(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)rn(e,t,n,o);for(;o=i.dequeue();)rn(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(rn(e,t,n,o,!0)||[]);break}}}return r}function rn(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,on(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,on(t,n,o)}),e.removeNode(r.v),o}function an(e,t){let n=new Dt,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=sn(i+r+3).map(()=>new $t),o=r+1;return n.nodes().forEach(e=>{on(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function on(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function sn(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function cn(e,t){(e.graph().acyclicer===`greedy`?tn(e,n(e)):ln(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,Ut(`rev`))});function n(e){return t=>e.edge(t).weight}}function ln(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&dn(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function un(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function dn(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function fn(e){e.graph().dummyChains=[],e.edges().forEach(t=>pn(e,t))}function pn(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=Ot(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function mn(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function hn(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=Rt(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function gn(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var _n=vn;function vn(e){let t=new Dt({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;yn(t,e)<i&&(a=bn(t,e),a);)o=t.hasNode(a.v)?gn(e,a):-gn(e,a),xn(t,e,o);return t}function yn(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!gn(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function bn(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=gn(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function xn(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Sn,postorder:Cn}=tt,wn=Tn;Tn.initLowLimValues=kn,Tn.initCutValues=En,Tn.calcCutValue=On,Tn.leaveEdge=jn,Tn.enterEdge=Mn,Tn.exchangeEdges=Nn;function Tn(e){e=kt(e),hn(e);let t=_n(e);kn(t),En(t,e);let n,r;for(;n=jn(t);)r=Mn(t,e,n),Nn(t,e,n,r)}function En(e,t){let n=Cn(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>Dn(e,t,n))}function Dn(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=On(e,t,n)}function On(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,Fn(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function kn(e,t){arguments.length<2&&(t=e.nodes()[0]),An(e,{},1,t)}function An(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=An(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function jn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Mn(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===In(e,e.node(t.v),s)&&c!==In(e,e.node(t.w),s)).reduce((e,n)=>gn(t,n)<gn(t,e)?n:e)}function Nn(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),kn(e),En(e,t),Pn(e,t)}function Pn(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Sn(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function Fn(e,t,n){return e.hasEdge(t,n)}function In(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Ln=Rn;function Rn(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Vn(e);break;case`tight-tree`:Bn(e);break;case`longest-path`:zn(e);break;case`none`:break;default:Vn(e)}}var zn=hn;function Bn(e){hn(e),_n(e)}function Vn(e){wn(e)}var Hn=Un;function Un(e){let t=Gn(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Wn(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function Wn(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function Gn(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(Jt).forEach(r),t}function Kn(e){let t=Ot(e,`root`,{},`_root`),n=Jn(e),r=Object.values(n),i=Rt(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=Yn(e)+1;e.children(Jt).forEach(r=>{qn(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function qn(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=Ft(e,`_bt`),l=Ft(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{qn(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function Jn(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(Jt).forEach(e=>n(e,1)),t}function Yn(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Xn(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Zn=Qn;function Qn(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)$n(e,`borderLeft`,`_bl`,n,i,t),$n(e,`borderRight`,`_br`,n,i,t)}}e.children(Jt).forEach(t)}function $n(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Ot(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function er(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&nr(e)}function tr(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&ir(e),(t===`lr`||t===`rl`)&&(or(e),nr(e))}function nr(e){e.nodes().forEach(t=>rr(e.node(t))),e.edges().forEach(t=>rr(e.edge(t)))}function rr(e){let t=e.width;e.width=e.height,e.height=t}function ir(e){e.nodes().forEach(t=>ar(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ar),Object.hasOwn(r,`y`)&&ar(r)})}function ar(e){e.y=-e.y}function or(e){e.nodes().forEach(t=>sr(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(sr),Object.hasOwn(r,`x`)&&sr(r)})}function sr(e){let t=e.x;e.x=e.y,e.y=t}function cr(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Wt(Rt(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return Yt(t,e.node(n),e.node(r))}return a}function lr(e,t){let n=0;for(let r=1;r<t.length;++r)n+=ur(e,t[r-1],t[r]);return n}function ur(e,t,n){let r=qt(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function dr(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function fr(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),pr(Object.values(n).filter(e=>!e.indegree))}function pr(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&mr(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>Gt(e,[`vs`,`i`,`barycenter`,`weight`]))}function mr(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function hr(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=Bt(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(_r(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=gr(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=gr(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function gr(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function _r(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=Yt(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function vr(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=dr(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=vr(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&br(t,r)}});let h=fr(m,n);yr(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]||(g[r]=h[n],h.splice(n,1),n--)}else _=!0}let v=hr(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function yr(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function br(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function xr(e,t,n,r){r||=e.nodes();let i=Sr(e),a=new Dt({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function Sr(e){let t;for(;e.hasNode(t=Ut(`_root`)););return t}function Cr(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function wr(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,wr);return}let r=zt(e),i=Tr(e,Wt(1,r+1),`inEdges`),a=Tr(e,Wt(r-1,-1,-1),`outEdges`),o=cr(e,n);if(Dr(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){Er(t%2?i:a,t%4>=2,l,n),o=Mt(e);let u=lr(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}Dr(e,c)}function Tr(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return xr(e,t,n,r.get(t)||[])})}function Er(e,t,n,r){let i=!0,a=new Dt;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=vr(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),Cr(e,a,s.vs)})}function Dr(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Or(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=Ar(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&jr(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function kr(e,t){let n={};function r(t){return e.node(t)?.dummy===`border`}if(!e.nodes().some(r))return n;function i(t,r,i,a,o){Wt(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&jr(n,t,i)})}})}function a(t,n){let a=-1,o=-1,s=0;return n.forEach((c,l)=>{if(r(c)){let t=e.predecessors(c);if(t&&t.length){let r=t[0];if(r===void 0)return;o=e.node(r).order,i(n,s,l,a,o),s=l,a=o}}i(n,s,n.length,o,t.length)}),n}return t.length&&t.reduce(a),n}function Ar(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function jr(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Mr(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function Nr(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||Hr(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>Hr(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!Mr(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function Pr(e,t,n,r,i=!1){let a={},o=Fr(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function Fr(e,t,n,r){let i=new Dt,a=e.graph(),o=Br(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function Ir(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Vr(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function Lr(e,t){let n=Object.values(t),r=Rt(Math.min,n),i=Rt(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-Rt(Math.min,c);a!==`l`&&(l=i-Rt(Math.max,c)),l&&(e[o]=Kt(s,e=>e+l))})})}function Rr(e,t=void 0){let n=e.ul;return n?Kt(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function zr(e,t){let n=Mt(e),r=Object.assign(Or(e,n),kr(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=Nr(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Pr(e,a,s.root,s.align,n===`r`);n===`r`&&(c=Kt(c,e=>-e)),i[o+n]=c})}),Lr(i,Ir(e,i)),Rr(i,e.graph().align)}function Br(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function Vr(e,t){return e.node(t).width}function Hr(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function Ur(e,t){e=At(e),Wr(e),Object.entries(zr(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Wr(e){let t=Mt(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var Gr=new WeakMap;function Kr(e,t={}){return Jr(e,Vt,t),e}function qr(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function Jr(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new Dt({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=qr(e,t.v,r),i=qr(e,t.w,r);if(n===t.v&&i===t.w)o.setEdge(t,{...e.edge(t)});else if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),Jr(o,t,n);let l=oi(o);Xr(l,t,n,null),Zr(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),isFinite(u)&&isFinite(d)&&isFinite(f)&&isFinite(p)||(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=oi(e),g=Xr(h,t,n,Gr.get(e)??null);Gr.set(e,g),Zr(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),Yr(e,n,s-l,c-u),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),Yr(e,i,a-s,o-c),delete n._dagreClusterSubgraph}})}function Yr(e,t,n,r){t.edges().forEach(i=>{if(!e.hasEdge(i))return;let a=t.edge(i),o=e.edge(i);o.points=a.points.map(e=>({x:e.x+n,y:e.y+r})),Object.hasOwn(a,`x`)&&(o.x=a.x+n,o.y=a.y+r)})}function Xr(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>si(e)),t(` removeSelfEdges`,()=>gi(e)),t(` acyclic`,()=>cn(e,s)),t(` nestingGraph.run`,()=>Kn(e)),t(` rank`,()=>Ln(At(e))),t(` injectEdgeLabelProxies`,()=>ci(e)),t(` removeEmptyRanks`,()=>Pt(e)),t(` nestingGraph.cleanup`,()=>Xn(e)),t(` normalizeRanks`,()=>Nt(e)),t(` assignRankMinMax`,()=>li(e)),t(` removeEdgeLabelProxies`,()=>ui(e)),t(` normalize.run`,()=>fn(e)),t(` parentDummyChains`,()=>Hn(e)),t(` addBorderSegments`,()=>Zn(e)),t(` order`,()=>wr(e,n,c)),t(` insertSelfEdges`,()=>_i(e)),t(` adjustCoordinateSystem`,()=>er(e)),t(` position`,()=>Ur(e,n.corePath)),t(` positionSelfEdges`,()=>vi(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>hi(e)),t(` normalize.undo`,()=>mn(e)),t(` fixupEdgeLabelCoords`,()=>pi(e)),t(` undoCoordinateSystem`,()=>tr(e)),t(` translateGraph`,()=>di(e)),t(` assignNodeIntersects`,()=>fi(e)),t(` reversePoints`,()=>mi(e)),t(` acyclic.undo`,()=>un(e)),{graph:e,rawNodes:l}}function Zr(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Qr=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],$r={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},ei=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],ti=[`width`,`height`,`rank`],ni={width:0,height:0},ri=[`minlen`,`weight`,`width`,`height`,`labeloffset`],ii={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},ai=[`labelpos`];function oi(e){let t=new Dt({multigraph:!0,compound:!0}),n=bi(e.graph());return t.setGraph(Object.assign({},$r,yi(n,Qr),Gt(n,ei))),e.nodes().forEach(n=>{let r=yi(bi(e.node(n)),ti);Object.keys(ni).forEach(e=>{r[e]===void 0&&(r[e]=ni[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=bi(e.edge(n));t.setEdge(n,Object.assign({},ii,yi(r,ri),Gt(r,ai)))}),t}function si(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function ci(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Ot(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function li(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function ui(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function di(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function fi(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(jt(r,a)),n.points.push(jt(i,o))})}function pi(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function mi(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function hi(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function gi(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function _i(e){Mt(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{Ot(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),Array.isArray(t.label.points)&&t.label.points.length===7||(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function vi(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function yi(e,t){return Kt(Gt(e,t),Number)}function bi(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}var xi=7,Si=16,Ci=1.5,wi=new Set([`M`,`W`,`m`,`w`,`@`,`%`]);function Ti(e,t){let n=0;for(let r of e)n+=r.charCodeAt(0)>=128||t===`title`&&wi.has(r)?2:1;return Math.ceil(n*xi*(t===`title`?Ci:1))}var Ei=12,Di=e=>Math.round(e*10)/10,Oi=e=>Math.round(e*100)/100,ki=(e,t)=>[Oi((e[0]+t[0])/2),Oi((e[1]+t[1])/2)],Ai=([e,t])=>`${e} ${t}`;function ji(e){let t=e.length-1;if(t===1)return`M${Ai(e[0])} L${Ai(e[1])}`;let n=[`M${Ai(e[0])}`,`L${Ai(ki(e[0],e[1]))}`];for(let r=1;r<t;r++)n.push(`Q${Ai(e[r])} ${Ai(ki(e[r],e[r+1]))}`);return n.push(`L${Ai(e[t])}`),n.join(` `)}var Mi=16;function Ni(e,t,n){return Array.from({length:Mi},(r,i)=>{let a=(i+1)/Mi,o=1-a;return[o*o*e[0]+2*o*a*t[0]+a*a*n[0],o*o*e[1]+2*o*a*t[1]+a*a*n[1]]})}var Pi=e=>e.slice(1).map((t,n)=>[e[n],t]);function Fi(e,t,n){let r=Ti(e,`label`);return{text:e,x:Di(t[0]-r/2),y:Di(t[1]-Si/2),width:r,height:Si,route:n}}function Ii(e){let t=e.slice(1).map((t,n)=>Math.hypot(t[0]-e[n][0],t[1]-e[n][1])),n=t.reduce((e,t)=>e+t,0)/2;for(let[r,i]of t.entries()){if(n<=i&&i>0){let[t,a]=[e[r],e[r+1]];return[Di(t[0]+(a[0]-t[0])*n/i),Di(t[1]+(a[1]-t[1])*n/i)]}n-=i}return e[e.length-1]}function Li(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=t[0]-n,a=t[1]-r;if(i===0&&a===0)return[Di(n),Di(e.y)];let o=Math.min(i===0?1/0:e.width/2/Math.abs(i),a===0?1/0:e.height/2/Math.abs(a));return[Di(n+i*o),Di(r+a*o)]}function Ri(e,t,n,r){let i=t[0]-e[0],a=t[1]-e[1],o=0,s=1,c=[[-i,e[0]-(n.x-r)],[i,n.x+n.width+r-e[0]],[-a,e[1]-(n.y-r)],[a,n.y+n.height+r-e[1]]];for(let[e,t]of c){if(e===0){if(t<0)return null;continue}let n=t/e;if(e<0?o=Math.max(o,n):s=Math.min(s,n),o>s)return null}return[o,s]}function zi(e,t,n){let r=Ri(e,t,n,-.5);return r!==null&&(r[1]-r[0])*Math.hypot(t[0]-e[0],t[1]-e[1])>.01}var Bi=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1]),Vi=e=>[[e.x-Ei,e.y-Ei],[e.x+e.width+Ei,e.y-Ei],[e.x-Ei,e.y+e.height+Ei],[e.x+e.width+Ei,e.y+e.height+Ei]],Hi=(e,t)=>e[0]>t.x+.5&&e[0]<t.x+t.width-.5&&e[1]>t.y+.5&&e[1]<t.y+t.height-.5;function Ui(e,t,n){let r=[e,t,...n.flatMap(Vi).filter(e=>!n.some(t=>Hi(e,t)))],i=r.map(()=>1/0),a=r.map(()=>-1),o=r.map(()=>!1);for(i[0]=0;;){let e=-1;for(let[t,n]of i.entries())!o[t]&&n<1/0&&(e<0||n<i[e])&&(e=t);if(e<0)return null;if(e===1)break;o[e]=!0;for(let[t,s]of r.entries()){let c=i[e]+Bi(r[e],s);!o[t]&&c<i[t]&&!n.some(t=>zi(r[e],s,t))&&(i[t]=c,a[t]=e)}}let s=[];for(let e=1;e>=0;e=a[e])s.unshift(r[e]);return s}function Wi(e,t){return e.flatMap((n,r)=>{let i=e[r+1];return i===void 0||!t.some(e=>zi(n,i,e))?[n]:(Ui(n,i,t)??[n,i]).slice(0,-1)})}function Gi(e){let t=[];for(let n of e){let e=t.findIndex(e=>e[0]===n[0]&&e[1]===n[1]);e>=0&&(t.length=e),t.push(n)}return t}function Ki(e,t,n){let r=Math.min(n/Math.max(Bi(e,t),.01),.25);return[Di(e[0]+(t[0]-e[0])*r),Di(e[1]+(t[1]-e[1])*r)]}function qi(e,t){let n=[...e];for(let e=0,r=8;e<6;e++,r/=2){let e=e=>e>0&&e<n.length-1&&Pi([ki(n[e-1],n[e]),...Ni(ki(n[e-1],n[e]),n[e],ki(n[e],n[e+1]))]).some(([e,n])=>t.some(t=>zi(e,n,t)));if(!n.some((t,n)=>e(n)))break;n=n.flatMap((t,i)=>e(i)?[Ki(t,n[i-1],r),t,Ki(t,n[i+1],r)]:[t])}return n}function Ji(e,t){return Gi(qi(Wi(e,t),t))}function Yi(e){let t=[...e.boxes,...e.labels,...e.routes.flatMap(e=>e.points.map(([e,t])=>({x:e,y:t,width:0,height:0})))];if(t.length===0)return{x:0,y:0,width:0,height:0};let n=Math.min(...t.map(e=>e.x)),r=Math.min(...t.map(e=>e.y));return{x:n,y:r,width:Math.max(...t.map(e=>e.x+e.width))-n,height:Math.max(...t.map(e=>e.y+e.height))-r}}function Xi(e,t,n,r=[]){let i=Yi({boxes:e,routes:t,labels:r});return{width:Math.max(0,i.x+i.width)+n,height:Math.max(0,i.y+i.height)+n}}function Zi(e,t=!0){let n=new He.Graph({multigraph:!0});n.setGraph({rankdir:`TB`,nodesep:e.nodesep,ranksep:e.ranksep,marginx:e.margin,marginy:e.margin});for(let t of e.nodes)n.setNode(t.id,{width:t.width,height:t.height});for(let t of e.edges)n.setEdge(t.source,t.target,{weight:t.weight},t.id);Kr(n);let r=e.nodes.map(e=>{let{x:t,y:r}=n.node(e.id);return{id:e.id,parent:null,x:Di(t-e.width/2),y:Di(r-e.height/2),width:e.width,height:e.height,kind:e.kind}}),i=e.edges.map(({weight:e,...i})=>{let a=n.edge(i.source,i.target,i.id).points.map(({x:e,y:t})=>[Di(e),Di(t)]),o=r.filter(e=>e.id!==i.source&&e.id!==i.target);return{...i,points:t?Ji(a,o):a}});return{boxes:r,routes:i,labels:[],extent:Xi(r,i,e.margin)}}var Qi=`text{font-family:system-ui,sans-serif;font-size:12px;fill:#1F2328}.box{fill:#F2F4F7;stroke:#D3D9E0}.frame{fill:#FFFFFF;stroke:#D3D9E0}.external{fill:#FFFFFF;stroke:#D3D9E0;stroke-dasharray:6 4}.member{fill:#FFFFFF;stroke:#D3D9E0}.writer{fill:#E4F2EA;stroke:#1F8A5B}.reader{fill:#FFFFFF;stroke:#8C96A3;stroke-dasharray:4 3}.point{fill:#E8EFFB;stroke:#2D5BB8}.title{font-size:13px;font-weight:600}.detail{fill:#5B6573}.route{fill:none;stroke:#5B6573}.route.dashed{stroke-dasharray:6 4}.label-box{fill:#FFFFFF}.label{font-family:ui-monospace,monospace;font-size:11px;fill:#1F2328}`,$i={band:`.band{fill:none;stroke:none}`,selected:`.selected{stroke:#F08A3C;stroke-width:2}`,lifeline:`.lifeline{fill:#8C96A3;stroke:none}`,fragment:`.fragment{stroke-dasharray:5 4}`,terminal:`.terminal{fill:#FFFFFF}`,success:`.fragment.success{fill:#EDF7F0;stroke:#2C6A3D}.terminal.success{stroke:#2C6A3D}`,error:`.fragment.error{fill:#FBEFEF;stroke:#B42318}.terminal.error{stroke:#B42318}`},ea=e=>e.replace(/[&<>"]/gu,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]);function ta(e,t){return e.height<32?t.length===0?``:`<text class="title" x="${e.x+8}" y="${e.y+e.height/2+4}">${ea(t[0])}</text>`:t.map((t,n)=>`<text class="${n===0?`title`:`detail`}" x="${e.x+12}" y="${e.y+20+n*16}">${ea(t)}</text>`).join(``)}function na(e,t){let{width:n,height:r}=e.extent,i=[];for(let[n,r]of e.boxes.entries())i.push(`<clipPath id="clip-${n}"><rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="10"/></clipPath>`,`<rect class="${r.kind}" x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="10"/>`,`<g clip-path="url(#clip-${n})">${ta(r,t(r))}</g>`);for(let t of e.routes){let e=`${t.arrows.start?` marker-start="url(#arrow)"`:``}${t.arrows.end?` marker-end="url(#arrow)"`:``}`;i.push(`<path class="route${t.dashed?` dashed`:``}" stroke-width="${t.width}" d="${ji(t.points)}"${e}/>`)}for(let t of e.labels)i.push(`<rect class="label-box" x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" rx="3"/>`,`<text class="label" x="${t.x+t.width/2}" y="${t.y+12}" text-anchor="middle">${ea(t.text)}</text>`);let a=new Set(e.boxes.flatMap(e=>e.kind.split(` `))),o=Object.entries($i).filter(([e])=>a.has(e)).map(([,e])=>e).join(``);return[`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${r}" viewBox="0 0 ${n} ${r}">`,`<style>${Qi}${o}</style>`,`<defs><marker id="arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0 0L8 4L0 8z" fill="#5B6573"/></marker></defs>`,`<rect width="${n}" height="${r}" fill="#FFFFFF"/>`,...i,`</svg>`].join(`
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,C as n,E as r,O as i,S as a,_ as o,b as s,c,g as l,h as u,j as d,l as f,n as p,o as m,p as h,v as g,x as _,y as v}from"./index-bVNVpteB.js";import{C as y,S as b,T as x,_ as S,b as C,i as w,n as T,r as E,t as D,v as O,w as k,x as A,y as j}from"./src-C_gRsKqw.js";import{t as M}from"./value-CHmTzbgv.js";var N=e=>()=>e;function P(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}P.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function F(e){return!e.ctrlKey&&!e.button}function ee(){return this.parentNode}function te(e,t){return t??{x:e.x,y:e.y}}function I(){return navigator.maxTouchPoints||`ontouchstart`in this}function ne(){var e=F,t=ee,n=te,r=I,i={},a=x(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,C).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=w(this,t.call(this,n,r),n,r,`mouse`);i&&(k(n.view).on(`mousemove.drag`,m,A).on(`mouseup.drag`,h,A),S(n.view),b(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(j(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){k(e.view).on(`mousemove.drag mouseup.drag`,null),O(e.view,l),j(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=w(this,a,n,r,i[s].identifier,i[s]))&&(b(n),c(`start`,n,i[s]))}function _(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(j(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(b(e),a(`end`,e,t[r]))}function w(e,t,r,s,c,l){var u=a.copy(),d=y(l||r,t),p,m,h;if((h=n.call(e,new P(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=y(l||a,t),_=o}u.call(r,e,new P(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:N(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:N(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:N(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:N(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var L=e(d(),1);function re(e){return e.kind===`group`}var ie=/^capability\.[a-z0-9-]+(\.[a-z0-9-]+)+$/,ae=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,oe=[`accepted`,`acknowledged`,`deferred`,`resolved`,`rejected`,`waived`],R=e=>typeof e==`string`,se=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,ce=e=>se(e)&&e>0,le=e=>typeof e==`boolean`,ue=e=>t=>R(t)&&e.test(t),z=(...e)=>t=>e.includes(t),de=e=>t=>t===null||e(t),B=e=>t=>Array.isArray(t)&&t.every(e),V=e=>t=>{if(!t||typeof t!=`object`||Array.isArray(t))return!1;let n=t;return Object.keys(n).length===Object.keys(e).length&&Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&t(n[e]))},fe=e=>t=>R(t)&&t.length>0&&t.length<=e&&t===t.trim()&&!/[\x00-\x1f\x7f]/u.test(t),pe=e=>!e||typeof e!=`object`||Array.isArray(e)?!1:Object.entries(e).every(([e,t])=>fe(128)(e)&&(t===null||typeof t==`number`&&Number.isFinite(t))),me=ue(/^[0-9a-f]{64}$/),he=ue(ae),ge=ue(ie),_e=ue(/^recommendation\.[0-9a-f]{16}$/u),ve=ue(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/u),ye=e=>R(e)&&!e.startsWith(`/`)&&!/^[A-Za-z]:/.test(e)&&!/[\\\x00-\x1f\x7f]/.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),be=V({model_valid:z(`valid`,`invalid`,`unknown`),generated_summary:z(`fresh`,`stale`,`unknown`),section3:z(`present`,`pending`)}),xe=V({id:R,from:R,to:R,label:R,evidence:V({entrypointId:R,sourceSymbol:R,sinkId:R})}),Se=e=>V({id:R,capabilityId:ge,name:R,applicability:z(`not-applicable`),rationale:R})(e)||V({id:R,capabilityId:ge,name:R,applicability:z(`required`),participants:B(V({id:R,nodeId:R})),steps:B(xe),outcomes:B(V({id:R,kind:z(`success`,`error`),label:R,steps:B(xe),terminal:V({participant:R,label:R})}))})(e),Ce=e=>typeof e==`string`&&e.length>0&&e!==`group`,we=V({include:B(R),exclude:B(R)}),Te=e=>V({id:R,kind:Ce,name:R,role:z(`center`,`child`,`caller`,`callee`)})(e)||V({id:R,kind:z(`group`),role:z(`caller`,`callee`),count:ce,members:B(V({id:R,name:R}))})(e),Ee=V({schema_version:z(`repo-harness.architecture-modules.v1`),commit:he,modules:B(V({id:ge,domain:R,name:R,status:R,components:se,state:be}))}),De=V({schema_version:z(`repo-harness.architecture-module.v1`),commit:he,module:V({id:ge,name:R,status:R,summary:R,responsibilities:B(R),notes:B(R),source:we,verification:B(R),entrypoints:B(V({id:R,path:ye,symbols:B(V({name:R,sinks:B(V({id:R,path:ye,symbol:R}))}))})),components:B(V({id:R,kind:Ce,name:R,summary:R,source:we}))}),graph:V({center:ge,nodes:B(Te),edges:B(V({source:R,target:R,intent:R,relation_kind:R,direction:z(`directed`)}))}),flows:B(Se),section3:de(R),linked_docs:B(V({path:ye,kind:z(`contract`,`plan`),status:de(R)})),state:be}),Oe=V({schema_version:z(`repo-harness.module-review-prompt.v1`),prompt_version:R,package_version:R,repository_id:ue(/^repo_[0-9a-f]{16}$/),capability_id:ge,commit:he,mode:z(`module`,`diff`),base:de(he),head:de(he),worktree_dirty_paths:B(ye),dirty_content_sha256:de(me),model_sha256:me,doc_sha256:de(me),sources:B(V({path:ye,sha256:me,bytes:se,class:z(`required`,`optional`),disposition:z(`included`,`omitted`,`chunked`)})),budget:V({input_cap_bytes:ce,used_bytes:se,incomplete:le,omitted_sections:B(R)}),shard:V({index:ce,count:ce,bytes:se}),full_prompt_sha256:me,prompt:R,digest:me}),ke=V({accepted:se,acknowledged:se,deferred:se,resolved:se,rejected:se,waived:se}),Ae=V({recommendation_id:_e,category:z(`structural_observation`,`refactor_proposal`),kind:de(z(...g)),subject:fe(512),affected_node_ids:B(fe(256)),status:z(...v),metrics:de(pe),reason:fe(1024),decided_at:ve,head_sha:he,cli_verify_command:fe(128)}),je=V({schema_version:z(`repo-harness.architecture-refactor.v1`),adopted:le,counts:ke,decisions:B(Ae)});function Me(e){return`rh arch refactor verify ${e} --json`}function Ne(e,t){let n=oe.indexOf(e.status)-oe.indexOf(t.status);return n===0?e.recommendation_id<t.recommendation_id?-1:+(e.recommendation_id>t.recommendation_id):n}function Pe(e){if(!Ee(e))throw Error(`architecture_module_index_invalid`);return e}function Fe(e){if(!De(e))throw Error(`architecture_module_detail_invalid`);let t=e,n=new Set(t.graph.nodes.map(e=>e.id));if(t.graph.center!==t.module.id||!n.has(t.graph.center)||n.size!==t.graph.nodes.length||t.graph.edges.some(e=>!n.has(e.source)||!n.has(e.target))||t.graph.nodes.some(e=>re(e)&&e.count!==e.members.length))throw Error(`architecture_module_detail_invalid`);return t}function Ie(e){if(!Oe(e))throw Error(`architecture_review_prompt_invalid`);let t=e;if(t.shard.index>t.shard.count||(t.mode===`module`?t.base!==null||t.head!==null:t.base===null||t.head===null)||t.worktree_dirty_paths.length===0!=(t.dirty_content_sha256===null))throw Error(`architecture_review_prompt_invalid`);return t}function Le(e){if(!je(e))throw Error(`architecture_refactor_decisions_invalid`);let t=e;if(!t.adopted&&t.decisions.length>0)throw Error(`architecture_refactor_decisions_invalid`);let n=new Set;for(let e=0;e<t.decisions.length;e++){let r=t.decisions[e];if(n.has(r.recommendation_id)||(n.add(r.recommendation_id),r.category===`structural_observation`!=(r.kind!==null))||r.cli_verify_command!==Me(r.recommendation_id)||r.affected_node_ids.some((e,t)=>t>0&&e<=r.affected_node_ids[t-1])||e>0&&Ne(t.decisions[e-1],r)>=0)throw Error(`architecture_refactor_decisions_invalid`)}for(let e of oe)if(t.counts[e]!==t.decisions.filter(t=>t.status===e).length)throw Error(`architecture_refactor_decisions_invalid`);return t}var Re=Object.defineProperty,ze=(e,t,n)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Be=(e,t)=>{for(var n in t)Re(e,n,{get:t[n],enumerable:!0})},Ve=(e,t,n)=>ze(e,typeof t==`symbol`?t:t+``,n),He={};Be(He,{Graph:()=>Dt,alg:()=>tt});var Ue=Object.defineProperty,We=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},Ge=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=Je(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=Ye(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Ke(this._preds[a],i),Ke(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Xe(this._isDirected,e):Je(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Xe(this._isDirected,e):Je(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Xe(this._isDirected,e):Je(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],qe(this._preds[t],e),qe(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function Ke(e,t){e[t]?e[t]++:e[t]=1}function qe(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Je(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function Ye(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function Xe(e,t){return Je(e,t.v,t.w,t.name)}We({},{read:()=>et,write:()=>Ze});function Ze(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Qe(e),edges:$e(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Qe(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function $e(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function et(e){let t=new Ge(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var tt={};We(tt,{CycleException:()=>gt,bellmanFord:()=>rt,components:()=>at,dijkstra:()=>ct,dijkstraAll:()=>ut,findCycles:()=>ft,floydWarshall:()=>mt,isAcyclic:()=>vt,postorder:()=>St,preorder:()=>Ct,prim:()=>wt,shortestPaths:()=>Tt,tarjan:()=>dt,topsort:()=>_t});var nt=()=>1;function rt(e,t,n,r){return it(e,String(t),n||nt,r||function(t){return e.outEdges(t)??[]})}function it(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function at(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var ot=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},st=()=>1;function ct(e,t,n,r){return lt(e,String(t),n||st,r||function(t){return e.outEdges(t)??[]})}function lt(e,t,n,r){let i={},a=new ot,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function ut(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=ct(e,i,t,n),r},{})}function dt(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function ft(e){return dt(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var pt=()=>1;function mt(e,t,n){return ht(e,t||pt,n||function(t){return e.outEdges(t)??[]})}function ht(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var gt=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function _t(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new gt;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new gt;return r}function vt(e){try{_t(e)}catch(e){if(e instanceof gt)return!1;throw e}return!0}function yt(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=bt(e,t,n===`post`,o,a,r,i)}),i}function bt(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=bt(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function xt(e,t,n){return yt(e,t,n,function(e,t){return e.push(t),e},[])}function St(e,t){return xt(e,t,`post`)}function Ct(e,t){return xt(e,t,`pre`)}function wt(e,t){var n;let r=new Ge,i={},a=new ot,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function Tt(e,t,n,r){return Et(e,t,n,r??(t=>e.outEdges(t)??[]))}function Et(e,t,n,r){if(n===void 0)return ct(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return rt(e,t,n,r)}return ct(e,t,n,r)}var Dt=Ge;function Ot(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Ut(r);return n.dummy=t,e.setNode(i,n),i}function kt(e){let t=new Dt().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function At(e){let t=new Dt({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function jt(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return i===0||Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function Mt(e){let t=Wt(zt(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function Nt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Rt(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Pt(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Rt(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function Ft(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Ot(e,`border`,i,t)}function It(e,t=Lt){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Lt=65535;function Rt(e,t){return t.length>Lt?e(...It(t).map(t=>e(...t))):e(...t)}function zt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Rt(Math.max,t)}function Bt(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Vt(e,t){return t()}var Ht=0;function Ut(e){return e+(``+ ++Ht)}function Wt(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function Gt(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Kt(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function qt(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Jt=`\0`;function Yt(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var Xt=class{constructor(){Ve(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Zt(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Zt(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,Qt)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Zt(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Qt(e,t){if(e!==`_next`&&e!==`_prev`)return t}var $t=Xt,en=()=>1;function tn(e,t){if(e.nodeCount()<=1)return[];let n=an(e,t||en);return nn(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function nn(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)rn(e,t,n,o);for(;o=i.dequeue();)rn(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(rn(e,t,n,o,!0)||[]);break}}}return r}function rn(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,on(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,on(t,n,o)}),e.removeNode(r.v),o}function an(e,t){let n=new Dt,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=sn(i+r+3).map(()=>new $t),o=r+1;return n.nodes().forEach(e=>{on(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function on(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function sn(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function cn(e,t){(e.graph().acyclicer===`greedy`?tn(e,n(e)):ln(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,Ut(`rev`))});function n(e){return t=>e.edge(t).weight}}function ln(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&dn(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function un(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function dn(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function fn(e){e.graph().dummyChains=[],e.edges().forEach(t=>pn(e,t))}function pn(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=Ot(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function mn(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function hn(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=Rt(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function gn(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var _n=vn;function vn(e){let t=new Dt({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;yn(t,e)<i&&(a=bn(t,e),a);)o=t.hasNode(a.v)?gn(e,a):-gn(e,a),xn(t,e,o);return t}function yn(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!gn(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function bn(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=gn(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function xn(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Sn,postorder:Cn}=tt,wn=Tn;Tn.initLowLimValues=kn,Tn.initCutValues=En,Tn.calcCutValue=On,Tn.leaveEdge=jn,Tn.enterEdge=Mn,Tn.exchangeEdges=Nn;function Tn(e){e=kt(e),hn(e);let t=_n(e);kn(t),En(t,e);let n,r;for(;n=jn(t);)r=Mn(t,e,n),Nn(t,e,n,r)}function En(e,t){let n=Cn(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>Dn(e,t,n))}function Dn(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=On(e,t,n)}function On(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,Fn(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function kn(e,t){arguments.length<2&&(t=e.nodes()[0]),An(e,{},1,t)}function An(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=An(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function jn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Mn(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===In(e,e.node(t.v),s)&&c!==In(e,e.node(t.w),s)).reduce((e,n)=>gn(t,n)<gn(t,e)?n:e)}function Nn(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),kn(e),En(e,t),Pn(e,t)}function Pn(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Sn(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function Fn(e,t,n){return e.hasEdge(t,n)}function In(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Ln=Rn;function Rn(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Vn(e);break;case`tight-tree`:Bn(e);break;case`longest-path`:zn(e);break;case`none`:break;default:Vn(e)}}var zn=hn;function Bn(e){hn(e),_n(e)}function Vn(e){wn(e)}var Hn=Un;function Un(e){let t=Gn(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Wn(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function Wn(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function Gn(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(Jt).forEach(r),t}function Kn(e){let t=Ot(e,`root`,{},`_root`),n=Jn(e),r=Object.values(n),i=Rt(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=Yn(e)+1;e.children(Jt).forEach(r=>{qn(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function qn(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=Ft(e,`_bt`),l=Ft(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{qn(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function Jn(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(Jt).forEach(e=>n(e,1)),t}function Yn(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Xn(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Zn=Qn;function Qn(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)$n(e,`borderLeft`,`_bl`,n,i,t),$n(e,`borderRight`,`_br`,n,i,t)}}e.children(Jt).forEach(t)}function $n(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Ot(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function er(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&nr(e)}function tr(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&ir(e),(t===`lr`||t===`rl`)&&(or(e),nr(e))}function nr(e){e.nodes().forEach(t=>rr(e.node(t))),e.edges().forEach(t=>rr(e.edge(t)))}function rr(e){let t=e.width;e.width=e.height,e.height=t}function ir(e){e.nodes().forEach(t=>ar(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ar),Object.hasOwn(r,`y`)&&ar(r)})}function ar(e){e.y=-e.y}function or(e){e.nodes().forEach(t=>sr(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(sr),Object.hasOwn(r,`x`)&&sr(r)})}function sr(e){let t=e.x;e.x=e.y,e.y=t}function cr(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Wt(Rt(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return Yt(t,e.node(n),e.node(r))}return a}function lr(e,t){let n=0;for(let r=1;r<t.length;++r)n+=ur(e,t[r-1],t[r]);return n}function ur(e,t,n){let r=qt(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function dr(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function fr(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),pr(Object.values(n).filter(e=>!e.indegree))}function pr(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&mr(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>Gt(e,[`vs`,`i`,`barycenter`,`weight`]))}function mr(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function hr(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=Bt(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(_r(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=gr(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=gr(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function gr(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function _r(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=Yt(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function vr(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=dr(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=vr(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&br(t,r)}});let h=fr(m,n);yr(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]||(g[r]=h[n],h.splice(n,1),n--)}else _=!0}let v=hr(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function yr(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function br(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function xr(e,t,n,r){r||=e.nodes();let i=Sr(e),a=new Dt({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function Sr(e){let t;for(;e.hasNode(t=Ut(`_root`)););return t}function Cr(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function wr(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,wr);return}let r=zt(e),i=Tr(e,Wt(1,r+1),`inEdges`),a=Tr(e,Wt(r-1,-1,-1),`outEdges`),o=cr(e,n);if(Dr(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){Er(t%2?i:a,t%4>=2,l,n),o=Mt(e);let u=lr(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}Dr(e,c)}function Tr(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return xr(e,t,n,r.get(t)||[])})}function Er(e,t,n,r){let i=!0,a=new Dt;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=vr(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),Cr(e,a,s.vs)})}function Dr(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Or(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=Ar(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&jr(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function kr(e,t){let n={};function r(t){return e.node(t)?.dummy===`border`}if(!e.nodes().some(r))return n;function i(t,r,i,a,o){Wt(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&jr(n,t,i)})}})}function a(t,n){let a=-1,o=-1,s=0;return n.forEach((c,l)=>{if(r(c)){let t=e.predecessors(c);if(t&&t.length){let r=t[0];if(r===void 0)return;o=e.node(r).order,i(n,s,l,a,o),s=l,a=o}}i(n,s,n.length,o,t.length)}),n}return t.length&&t.reduce(a),n}function Ar(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function jr(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Mr(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function Nr(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||Hr(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>Hr(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!Mr(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function Pr(e,t,n,r,i=!1){let a={},o=Fr(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function Fr(e,t,n,r){let i=new Dt,a=e.graph(),o=Br(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function Ir(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Vr(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function Lr(e,t){let n=Object.values(t),r=Rt(Math.min,n),i=Rt(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-Rt(Math.min,c);a!==`l`&&(l=i-Rt(Math.max,c)),l&&(e[o]=Kt(s,e=>e+l))})})}function Rr(e,t=void 0){let n=e.ul;return n?Kt(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function zr(e,t){let n=Mt(e),r=Object.assign(Or(e,n),kr(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=Nr(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Pr(e,a,s.root,s.align,n===`r`);n===`r`&&(c=Kt(c,e=>-e)),i[o+n]=c})}),Lr(i,Ir(e,i)),Rr(i,e.graph().align)}function Br(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function Vr(e,t){return e.node(t).width}function Hr(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function Ur(e,t){e=At(e),Wr(e),Object.entries(zr(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Wr(e){let t=Mt(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var Gr=new WeakMap;function Kr(e,t={}){return Jr(e,Vt,t),e}function qr(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function Jr(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new Dt({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=qr(e,t.v,r),i=qr(e,t.w,r);if(n===t.v&&i===t.w)o.setEdge(t,{...e.edge(t)});else if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),Jr(o,t,n);let l=oi(o);Xr(l,t,n,null),Zr(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),isFinite(u)&&isFinite(d)&&isFinite(f)&&isFinite(p)||(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=oi(e),g=Xr(h,t,n,Gr.get(e)??null);Gr.set(e,g),Zr(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),Yr(e,n,s-l,c-u),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),Yr(e,i,a-s,o-c),delete n._dagreClusterSubgraph}})}function Yr(e,t,n,r){t.edges().forEach(i=>{if(!e.hasEdge(i))return;let a=t.edge(i),o=e.edge(i);o.points=a.points.map(e=>({x:e.x+n,y:e.y+r})),Object.hasOwn(a,`x`)&&(o.x=a.x+n,o.y=a.y+r)})}function Xr(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>si(e)),t(` removeSelfEdges`,()=>gi(e)),t(` acyclic`,()=>cn(e,s)),t(` nestingGraph.run`,()=>Kn(e)),t(` rank`,()=>Ln(At(e))),t(` injectEdgeLabelProxies`,()=>ci(e)),t(` removeEmptyRanks`,()=>Pt(e)),t(` nestingGraph.cleanup`,()=>Xn(e)),t(` normalizeRanks`,()=>Nt(e)),t(` assignRankMinMax`,()=>li(e)),t(` removeEdgeLabelProxies`,()=>ui(e)),t(` normalize.run`,()=>fn(e)),t(` parentDummyChains`,()=>Hn(e)),t(` addBorderSegments`,()=>Zn(e)),t(` order`,()=>wr(e,n,c)),t(` insertSelfEdges`,()=>_i(e)),t(` adjustCoordinateSystem`,()=>er(e)),t(` position`,()=>Ur(e,n.corePath)),t(` positionSelfEdges`,()=>vi(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>hi(e)),t(` normalize.undo`,()=>mn(e)),t(` fixupEdgeLabelCoords`,()=>pi(e)),t(` undoCoordinateSystem`,()=>tr(e)),t(` translateGraph`,()=>di(e)),t(` assignNodeIntersects`,()=>fi(e)),t(` reversePoints`,()=>mi(e)),t(` acyclic.undo`,()=>un(e)),{graph:e,rawNodes:l}}function Zr(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Qr=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],$r={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},ei=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],ti=[`width`,`height`,`rank`],ni={width:0,height:0},ri=[`minlen`,`weight`,`width`,`height`,`labeloffset`],ii={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},ai=[`labelpos`];function oi(e){let t=new Dt({multigraph:!0,compound:!0}),n=bi(e.graph());return t.setGraph(Object.assign({},$r,yi(n,Qr),Gt(n,ei))),e.nodes().forEach(n=>{let r=yi(bi(e.node(n)),ti);Object.keys(ni).forEach(e=>{r[e]===void 0&&(r[e]=ni[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=bi(e.edge(n));t.setEdge(n,Object.assign({},ii,yi(r,ri),Gt(r,ai)))}),t}function si(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function ci(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Ot(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function li(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function ui(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function di(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function fi(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(jt(r,a)),n.points.push(jt(i,o))})}function pi(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function mi(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function hi(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function gi(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function _i(e){Mt(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{Ot(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),Array.isArray(t.label.points)&&t.label.points.length===7||(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function vi(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function yi(e,t){return Kt(Gt(e,t),Number)}function bi(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}var xi=7,Si=16,Ci=1.5,wi=new Set([`M`,`W`,`m`,`w`,`@`,`%`]);function Ti(e,t){let n=0;for(let r of e)n+=r.charCodeAt(0)>=128||t===`title`&&wi.has(r)?2:1;return Math.ceil(n*xi*(t===`title`?Ci:1))}var Ei=12,Di=e=>Math.round(e*10)/10,Oi=e=>Math.round(e*100)/100,ki=(e,t)=>[Oi((e[0]+t[0])/2),Oi((e[1]+t[1])/2)],Ai=([e,t])=>`${e} ${t}`;function ji(e){let t=e.length-1;if(t===1)return`M${Ai(e[0])} L${Ai(e[1])}`;let n=[`M${Ai(e[0])}`,`L${Ai(ki(e[0],e[1]))}`];for(let r=1;r<t;r++)n.push(`Q${Ai(e[r])} ${Ai(ki(e[r],e[r+1]))}`);return n.push(`L${Ai(e[t])}`),n.join(` `)}var Mi=16;function Ni(e,t,n){return Array.from({length:Mi},(r,i)=>{let a=(i+1)/Mi,o=1-a;return[o*o*e[0]+2*o*a*t[0]+a*a*n[0],o*o*e[1]+2*o*a*t[1]+a*a*n[1]]})}var Pi=e=>e.slice(1).map((t,n)=>[e[n],t]);function Fi(e,t,n){let r=Ti(e,`label`);return{text:e,x:Di(t[0]-r/2),y:Di(t[1]-Si/2),width:r,height:Si,route:n}}function Ii(e){let t=e.slice(1).map((t,n)=>Math.hypot(t[0]-e[n][0],t[1]-e[n][1])),n=t.reduce((e,t)=>e+t,0)/2;for(let[r,i]of t.entries()){if(n<=i&&i>0){let[t,a]=[e[r],e[r+1]];return[Di(t[0]+(a[0]-t[0])*n/i),Di(t[1]+(a[1]-t[1])*n/i)]}n-=i}return e[e.length-1]}function Li(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=t[0]-n,a=t[1]-r;if(i===0&&a===0)return[Di(n),Di(e.y)];let o=Math.min(i===0?1/0:e.width/2/Math.abs(i),a===0?1/0:e.height/2/Math.abs(a));return[Di(n+i*o),Di(r+a*o)]}function Ri(e,t,n,r){let i=t[0]-e[0],a=t[1]-e[1],o=0,s=1,c=[[-i,e[0]-(n.x-r)],[i,n.x+n.width+r-e[0]],[-a,e[1]-(n.y-r)],[a,n.y+n.height+r-e[1]]];for(let[e,t]of c){if(e===0){if(t<0)return null;continue}let n=t/e;if(e<0?o=Math.max(o,n):s=Math.min(s,n),o>s)return null}return[o,s]}function zi(e,t,n){let r=Ri(e,t,n,-.5);return r!==null&&(r[1]-r[0])*Math.hypot(t[0]-e[0],t[1]-e[1])>.01}var Bi=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1]),Vi=e=>[[e.x-Ei,e.y-Ei],[e.x+e.width+Ei,e.y-Ei],[e.x-Ei,e.y+e.height+Ei],[e.x+e.width+Ei,e.y+e.height+Ei]],Hi=(e,t)=>e[0]>t.x+.5&&e[0]<t.x+t.width-.5&&e[1]>t.y+.5&&e[1]<t.y+t.height-.5;function Ui(e,t,n){let r=[e,t,...n.flatMap(Vi).filter(e=>!n.some(t=>Hi(e,t)))],i=r.map(()=>1/0),a=r.map(()=>-1),o=r.map(()=>!1);for(i[0]=0;;){let e=-1;for(let[t,n]of i.entries())!o[t]&&n<1/0&&(e<0||n<i[e])&&(e=t);if(e<0)return null;if(e===1)break;o[e]=!0;for(let[t,s]of r.entries()){let c=i[e]+Bi(r[e],s);!o[t]&&c<i[t]&&!n.some(t=>zi(r[e],s,t))&&(i[t]=c,a[t]=e)}}let s=[];for(let e=1;e>=0;e=a[e])s.unshift(r[e]);return s}function Wi(e,t){return e.flatMap((n,r)=>{let i=e[r+1];return i===void 0||!t.some(e=>zi(n,i,e))?[n]:(Ui(n,i,t)??[n,i]).slice(0,-1)})}function Gi(e){let t=[];for(let n of e){let e=t.findIndex(e=>e[0]===n[0]&&e[1]===n[1]);e>=0&&(t.length=e),t.push(n)}return t}function Ki(e,t,n){let r=Math.min(n/Math.max(Bi(e,t),.01),.25);return[Di(e[0]+(t[0]-e[0])*r),Di(e[1]+(t[1]-e[1])*r)]}function qi(e,t){let n=[...e];for(let e=0,r=8;e<6;e++,r/=2){let e=e=>e>0&&e<n.length-1&&Pi([ki(n[e-1],n[e]),...Ni(ki(n[e-1],n[e]),n[e],ki(n[e],n[e+1]))]).some(([e,n])=>t.some(t=>zi(e,n,t)));if(!n.some((t,n)=>e(n)))break;n=n.flatMap((t,i)=>e(i)?[Ki(t,n[i-1],r),t,Ki(t,n[i+1],r)]:[t])}return n}function Ji(e,t){return Gi(qi(Wi(e,t),t))}function Yi(e){let t=[...e.boxes,...e.labels,...e.routes.flatMap(e=>e.points.map(([e,t])=>({x:e,y:t,width:0,height:0})))];if(t.length===0)return{x:0,y:0,width:0,height:0};let n=Math.min(...t.map(e=>e.x)),r=Math.min(...t.map(e=>e.y));return{x:n,y:r,width:Math.max(...t.map(e=>e.x+e.width))-n,height:Math.max(...t.map(e=>e.y+e.height))-r}}function Xi(e,t,n,r=[]){let i=Yi({boxes:e,routes:t,labels:r});return{width:Math.max(0,i.x+i.width)+n,height:Math.max(0,i.y+i.height)+n}}function Zi(e,t=!0){let n=new He.Graph({multigraph:!0});n.setGraph({rankdir:`TB`,nodesep:e.nodesep,ranksep:e.ranksep,marginx:e.margin,marginy:e.margin});for(let t of e.nodes)n.setNode(t.id,{width:t.width,height:t.height});for(let t of e.edges)n.setEdge(t.source,t.target,{weight:t.weight},t.id);Kr(n);let r=e.nodes.map(e=>{let{x:t,y:r}=n.node(e.id);return{id:e.id,parent:null,x:Di(t-e.width/2),y:Di(r-e.height/2),width:e.width,height:e.height,kind:e.kind}}),i=e.edges.map(({weight:e,...i})=>{let a=n.edge(i.source,i.target,i.id).points.map(({x:e,y:t})=>[Di(e),Di(t)]),o=r.filter(e=>e.id!==i.source&&e.id!==i.target);return{...i,points:t?Ji(a,o):a}});return{boxes:r,routes:i,labels:[],extent:Xi(r,i,e.margin)}}var Qi=`text{font-family:system-ui,sans-serif;font-size:12px;fill:#1F2328}.box{fill:#F2F4F7;stroke:#D3D9E0}.frame{fill:#FFFFFF;stroke:#D3D9E0}.external{fill:#FFFFFF;stroke:#D3D9E0;stroke-dasharray:6 4}.member{fill:#FFFFFF;stroke:#D3D9E0}.writer{fill:#E4F2EA;stroke:#1F8A5B}.reader{fill:#FFFFFF;stroke:#8C96A3;stroke-dasharray:4 3}.point{fill:#E8EFFB;stroke:#2D5BB8}.title{font-size:13px;font-weight:600}.detail{fill:#5B6573}.route{fill:none;stroke:#5B6573}.route.dashed{stroke-dasharray:6 4}.label-box{fill:#FFFFFF}.label{font-family:ui-monospace,monospace;font-size:11px;fill:#1F2328}`,$i={band:`.band{fill:none;stroke:none}`,selected:`.selected{stroke:#F08A3C;stroke-width:2}`,lifeline:`.lifeline{fill:#8C96A3;stroke:none}`,fragment:`.fragment{stroke-dasharray:5 4}`,terminal:`.terminal{fill:#FFFFFF}`,success:`.fragment.success{fill:#EDF7F0;stroke:#2C6A3D}.terminal.success{stroke:#2C6A3D}`,error:`.fragment.error{fill:#FBEFEF;stroke:#B42318}.terminal.error{stroke:#B42318}`},ea=e=>e.replace(/[&<>"]/gu,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]);function ta(e,t){return e.height<32?t.length===0?``:`<text class="title" x="${e.x+8}" y="${e.y+e.height/2+4}">${ea(t[0])}</text>`:t.map((t,n)=>`<text class="${n===0?`title`:`detail`}" x="${e.x+12}" y="${e.y+20+n*16}">${ea(t)}</text>`).join(``)}function na(e,t){let{width:n,height:r}=e.extent,i=[];for(let[n,r]of e.boxes.entries())i.push(`<clipPath id="clip-${n}"><rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="10"/></clipPath>`,`<rect class="${r.kind}" x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="10"/>`,`<g clip-path="url(#clip-${n})">${ta(r,t(r))}</g>`);for(let t of e.routes){let e=`${t.arrows.start?` marker-start="url(#arrow)"`:``}${t.arrows.end?` marker-end="url(#arrow)"`:``}`;i.push(`<path class="route${t.dashed?` dashed`:``}" stroke-width="${t.width}" d="${ji(t.points)}"${e}/>`)}for(let t of e.labels)i.push(`<rect class="label-box" x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" rx="3"/>`,`<text class="label" x="${t.x+t.width/2}" y="${t.y+12}" text-anchor="middle">${ea(t.text)}</text>`);let a=new Set(e.boxes.flatMap(e=>e.kind.split(` `))),o=Object.entries($i).filter(([e])=>a.has(e)).map(([,e])=>e).join(``);return[`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${r}" viewBox="0 0 ${n} ${r}">`,`<style>${Qi}${o}</style>`,`<defs><marker id="arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0 0L8 4L0 8z" fill="#5B6573"/></marker></defs>`,`<rect width="${n}" height="${r}" fill="#FFFFFF"/>`,...i,`</svg>`].join(`
2
2
  `)}var ra=12,ia=12,aa=24,oa=64,sa=24,ca=`removed`,la=new Set([`spawns`,`runs-in`,`deployed-on`,`mounts`,`reads`,`writes`,`publishes`,`subscribes`]);function ua(e,t){let n=Math.ceil(Math.sqrt(e.length)),r=Math.ceil(e.length/n),i=Array.from({length:n},(t,r)=>Math.max(0,...e.filter((e,t)=>t%n===r).map(e=>e.width))),a=Array.from({length:r},(t,r)=>Math.max(0,...e.slice(r*n,(r+1)*n).map(e=>e.height))),o=(e,n)=>e.slice(0,n).reduce((e,n)=>e+n+t,0);return{cells:e.map((e,t)=>({x:o(i,t%n),y:o(a,Math.floor(t/n))})),width:i.reduce((e,t)=>e+t,0)+(n-1)*t,height:a.reduce((e,t)=>e+t,0)+(r-1)*t}}function da(e){let t=new Map;for(let n of e.nodes)n.parent!==null&&t.set(n.parent,[...t.get(n.parent)??[],n]);let n=new Map,r=new Map,i=e=>{let a=r.get(e);if(a)return a;let o=t.get(e),s={width:160,height:48};if(o){let e=ua(o.map(e=>i(e.id)),ia);o.forEach((t,r)=>n.set(t.id,{x:ra+e.cells[r].x,y:36+e.cells[r].y})),s={width:Math.max(160,e.width)+24,height:36+e.height+ra}}return r.set(e,s),s},a=new Map(e.nodes.map(e=>[e.id,e.parent])),o=e=>{let t=e;for(;a.get(t);)t=a.get(t);return t},s=new Map;for(let t of e.relations){let[e,n]=[o(t.source),o(t.target)];if(e===n)continue;let r=`${t.kind}:${e}->${n}`;s.has(r)||s.set(r,{source:e,target:n,kind:t.kind,relations:[]}),s.get(r).relations.push(t.id)}let c=e.nodes.filter(e=>e.parent===null),l=new Set([...s.values()].flatMap(e=>[e.source,e.target])),u=e=>t.has(e)?`frame`:`box`,d=Zi({nodes:c.filter(e=>l.has(e.id)).map(e=>({id:e.id,kind:u(e.id),...i(e.id)})),edges:[...s].map(([e,t])=>({id:e,source:t.source,target:t.target,kind:t.kind,arrows:{start:!1,end:!0},dashed:t.kind===ca,width:t.kind===`relation`?1.5:2,weight:t.relations.length})),nodesep:aa,ranksep:oa,margin:sa}),f=c.filter(e=>!l.has(e.id)),p=d.boxes.length===0?sa:Math.max(...d.boxes.map(e=>e.y+e.height))+oa,m=f.map(e=>i(e.id)),h=ua(m,aa).cells.map((e,t)=>({id:f[t].id,parent:null,x:sa+e.x,y:p+e.y,...m[t],kind:u(f[t].id)})),g=new Map([...d.boxes,...h].map(e=>[e.id,e])),_=[],v=(e,r)=>{let a=n.get(e.id),o=r===null?g.get(e.id):{id:e.id,parent:r.id,x:r.x+a.x,y:r.y+a.y,...i(e.id),kind:u(e.id)};_.push(o);for(let n of t.get(e.id)??[])v(n,o)};for(let e of c)v(e,null);let y=d.routes;return{scene:{boxes:_,routes:y,labels:[],extent:Xi(_,y,sa)},relations:new Map([...s].map(([e,t])=>[e,t.relations]))}}var H=i();function U(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=U(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var fa={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},pa=[[-1/0,-1/0],[1/0,1/0]],ma=[`Enter`,` `,`Escape`],ha={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},ga;(function(e){e.Strict=`strict`,e.Loose=`loose`})(ga||={});var _a;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(_a||={});var va;(function(e){e.Partial=`partial`,e.Full=`full`})(va||={});var ya={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},ba;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(ba||={});var xa;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(xa||={});var W;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(W||={});var Sa={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},Ca=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,wa=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),Ta=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),Ea=(e,t=[0,0])=>{let{width:n,height:r}=oo(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Da=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):Ta(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,Ba(e,Wa(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Ha(r):{x:0,y:0,width:0,height:0}},Oa=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=Ba(n,Wa(e)),r=!0)}),r?Ha(n):{x:0,y:0,width:0,height:0}},ka=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=Ka(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},Aa=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function ja(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=oo(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function Ma({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=ro(Oa(ja(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function Na({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,fa.error005());else{let{width:e,height:t}=oo(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&ao(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=ao(d)?Ia(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,fa.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function Pa({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=Aa(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var Fa=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ia=(e={x:0,y:0},t,n)=>({x:Fa(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Fa(e.y,t[0][1],t[1][1]-(n?.height??0))});function La(e,t,n){let{width:r,height:i}=oo(n),{x:a,y:o}=n.internals.positionAbsolute;return Ia(e,[[a,o],[a+r,o+i]],t)}var Ra=(e,t,n)=>e<t?Fa(Math.abs(e-t),1,t)/t:e>n?-Fa(Math.abs(e-n),1,t)/t:0,za=(e,t,n=15,r=40)=>[Ra(e.x,r,t.width-r)*n,Ra(e.y,r,t.height-r)*n],Ba=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Va=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ha=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Ua=(e,t=[0,0])=>{let{x:n,y:r}=Ta(e)?e.internals.positionAbsolute:Ea(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Wa=(e,t=[0,0])=>{let{x:n,y:r}=Ta(e)?e.internals.positionAbsolute:Ea(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Ga=(e,t)=>Ha(Ba(Va(e),Va(t))),Ka=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},qa=(e,t)=>Ka(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Ja=e=>Ya(e.width)&&Ya(e.height)&&Ya(e.x)&&Ya(e.y),Ya=e=>!isNaN(e)&&isFinite(e),Xa=(e,t)=>(e,t)=>{},Za=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Qa=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Za(s,o):s},$a=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function eo(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function to(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=eo(e,n),i=eo(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=eo(e.top??e.y??0,n),i=eo(e.bottom??e.y??0,n),a=eo(e.left??e.x??0,t),o=eo(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function no(e,t,n,r,i,a){let{x:o,y:s}=$a(e,[t,n,r]),{x:c,y:l}=$a({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var ro=(e,t,n,r,i,a)=>{let o=to(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=Fa(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=no(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},io=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function ao(e){return e!=null&&e!==`parent`}function oo(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function so(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function co(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function lo(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function uo(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function fo(e){return{...ha,...e||{}}}function po(e){return e===null?null:e?`valid`:`invalid`}function mo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=bo(e),s=Qa({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Za(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var ho=e=>({width:e.offsetWidth,height:e.offsetHeight}),go=e=>e?.getRootNode?.()||window?.document,_o=[`INPUT`,`SELECT`,`TEXTAREA`];function vo(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?_o.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var yo=e=>`clientX`in e,bo=(e,t)=>{let n=yo(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},xo=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...ho(t)}})};function So({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function Co(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function wo({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case W.Left:return[t-Co(t-r,a),n];case W.Right:return[t+Co(r-t,a),n];case W.Top:return[t,n-Co(n-i,a)];case W.Bottom:return[t,n+Co(i-n,a)]}}function To({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:i,targetPosition:a=W.Top,curvature:o=.25}){let[s,c]=wo({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=wo({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=So({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function Eo({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function Do({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function Oo({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=Ba(Wa(e),Wa(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),qa({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},Ha(a))>0}var ko=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Ao=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),jo=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,fa.error006()),t;let r=n.getEdgeId||ko,i;return i=Ca(e)?{...e}:{...e,id:r(e)},Ao(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Mo({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=Eo({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var No={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},Po=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Fo=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Io=(e,t,n)=>e.x===t.x&&t.x===n.x&&(t.y-e.y)*(n.y-t.y)>=0||e.y===t.y&&t.y===n.y&&(t.x-e.x)*(n.x-t.x)>=0;function Lo({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:i,offset:a,stepPosition:o}){let s=No[t],c=No[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=Po({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=Eo({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y},C=[];for(let t of[e,x,...m,S,n]){let[e,n]=C.slice(-2);n&&Io(e,n,t)&&C.pop(),C.push(t)}return[C,h,g,y,b]}function Ro(e,t,n,r){let i=Math.min(Fo(e,t)/2,Fo(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function zo({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:i,targetPosition:a=W.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=Lo({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=Ro(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function Bo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Vo(e){let{sourceNode:t,targetNode:n}=e;if(!Bo(t)||!Bo(n))return null;let r=t.internals.handleBounds||Ho(t.handles),i=n.internals.handleBounds||Ho(n.handles),a=Wo(r?.source??[],e.sourceHandle),o=Wo(e.connectionMode===ga.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,fa.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||W.Bottom,c=o?.position||W.Top,l=Uo(t,a,s),u=Uo(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function Ho(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function Uo(e,t,n=W.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??oo(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case W.Top:return{x:i+o/2,y:a};case W.Right:return{x:i+o,y:a+s/2};case W.Bottom:return{x:i+o/2,y:a+s};case W.Left:return{x:i,y:a+s/2}}}function Wo(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function Go(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function Ko(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=Go(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var qo=1e3,Jo=10,Yo={nodeOrigin:[0,0],nodeExtent:pa,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Xo={...Yo,checkEquality:!0};function Zo(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Qo(e,t,n){let r=Zo(Yo,n);for(let n of e.values())if(n.parentId)rs(n,e,t,r);else{let e=Ia(Ea(n,r.nodeOrigin),ao(n.extent)?n.extent:r.nodeExtent,oo(n));n.internals.positionAbsolute=e}}function $o(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function es(e){return e===`manual`}function ts(e,t,n,r={}){let i=Zo(Xo,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!es(i.zIndexMode)?qo:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=Ia(Ea(u,i.nodeOrigin),ao(u.extent)?u.extent:i.nodeExtent,oo(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:$o(u,e),z:is(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}e.measured!==void 0&&e.measured.width!==void 0&&e.measured.height!==void 0||e.hidden||(c=!1),u.parentId&&rs(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function ns(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function rs(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Zo(Yo,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}ns(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*Jo),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=as(e,u,o,s,a&&!es(c)?qo:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function is(e,t,n){let r=Ya(e.zIndex)?e.zIndex:0;return es(n)?r:r+(e.selected?t:0)}function as(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=oo(e),l=Ea(e,n),u=ao(e.extent)?Ia(l,e.extent,c):l,d=Ia({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=La(d,c,t));let f=is(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function os(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Ga(a.get(n.parentId)?.expandedRect??Ua(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=oo(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function ss(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=ho(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=ao(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=La(h,s,n))}else m&&(h=Ia(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:xo(`source`,r.nodeElement,p,d,e.id),target:xo(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&rs(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:Ua(g,i)}))}}if(f.length>0){let e=os(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function cs({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function ls(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function us(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;ls(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),ls(`target`,s,c,e,i,o),t.set(r.id,r)}}function ds(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:ds(n,t):!1}function fs(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function ps(e,t,n,r,i){let a=new Map;for(let[o,s]of e)if((i?s.id===r:s.selected||s.id===r)&&(i||!s.parentId||!ds(s,e))&&(s.draggable||t&&s.draggable===void 0)){let t=e.get(o);t&&a.set(o,{id:o,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return a}function ms({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function hs({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=Za(a,t);return{x:o.x-a.x,y:o.y-a.y}}function gs({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=k(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?Va(Oa(s)):null,x=v&&l?hs({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:Za(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=Na({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=ms({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=za(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0;let v=!!b&&!o&&!i.get(b)?.selected;m&&y||o||!b||i.get(b)?.selected||_(),y&&m&&b&&e?.(b);let x=mo(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=x,s=ps(i,c,x,b,v),s.size>0&&(n||h||!b&&g)){let[e,t]=ms({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=ne().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=mo(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=bo(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=mo(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=bo(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=bo(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p)p&&s.size>0&&t().updateNodePositions(s,!1);else if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=ms({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!fs(t,`.${g}`,v))&&(!_||fs(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function _s(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())qa(i,Ua(e))>0&&r.push(e);return r}var vs=250;function ys(e,t,n,r){let i=[],a=1/0,o=_s(e,n,t+vs);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=Uo(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function bs(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...Uo(o,c,c.position,!0)}:c}function xs(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function Ss(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var Cs=()=>!0;function ws(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=Cs,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=go(e.target),E=0,D,{x:O,y:k}=bo(e),A=xs(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=bs(i,A,r,c,t);if(!N)return;let P=bo(e,j),F=!1,ee=null,te=!1,I=null;function ne(){if(!u||!j)return;let[e,t]=za(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ne)}let L={...N,nodeId:i,type:A,position:N.position},re=c.get(i),ie={inProgress:!0,isValid:null,from:Uo(re,L,W.Left,!0),fromHandle:L,fromPosition:L.position,fromNode:re,to:P,toHandle:null,toPosition:Sa[L.position],toNode:null,pointer:P};function ae(){M=!0,y(ie),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&ae();function oe(e){if(!M){let{x:t,y:n}=bo(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;ae()}if(!x()||!L){R(e);return}let a=b();P=bo(e,j),D=ys(Qa(P,a,!1,[1,1]),n,c,L),F||=(ne(),!0);let s=Ts(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});I=s.handleDomNode,ee=s.connection,te=Ss(!!D,s.isValid);let u=c.get(i),f=u?Uo(u,L,W.Left,!0):ie.from,p={...ie,from:f,isValid:te,to:s.toHandle&&te?$a({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:te&&s.toHandle?s.toHandle.position:Sa[L.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),ie=p}function R(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||I)&&ee&&te&&h?.(ee);let{inProgress:t,...n}=ie,r={...n,toPosition:ie.toHandle?ie.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,te=!1,ee=null,I=null,T.removeEventListener(`mousemove`,oe),T.removeEventListener(`mouseup`,R),T.removeEventListener(`touchmove`,oe),T.removeEventListener(`touchend`,R)}}T.addEventListener(`mousemove`,oe),T.addEventListener(`mouseup`,R),T.addEventListener(`touchmove`,oe),T.addEventListener(`touchend`,R)}function Ts(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Cs,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=bo(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=xs(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===ga.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=bs(t,e,a,u,n,!0)}return _}var Es={onPointerDown:ws,isValid:Ts};function Ds({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=k(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&io()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=D().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:y}}var Os=e=>({x:e.x,y:e.y,zoom:e.k}),ks=({x:e,y:t,zoom:n})=>T.translate(e,t).scale(n),As=(e,t)=>e.target.closest(`.${t}`),js=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ms=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ns=(e,t=0,n=Ms,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},Ps=e=>{let t=e.ctrlKey&&io()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Fs({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(As(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=y(u),t=d*2**Ps(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===_a.Vertical?0:u.deltaX*f,m=i===_a.Horizontal?0:u.deltaY*f;!io()&&u.shiftKey&&i!==_a.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=Os(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function Is({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=As(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Ls({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=Os(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function Rs({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&js(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,Os(a.transform))}}function zs({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&js(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=Os(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Bs({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(As(f,`${u}-flow__node`)||As(f,`${u}-flow__edge`)||As(f,`${u}-flow__selection`)||As(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||As(f,c)&&h||As(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function Vs({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]],f=typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t?.contentRect&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null;f?.observe(e);let p=D().extent(()=>d).scaleExtent([t,n]).translateExtent(r),m=k(e).call(p);b({x:i.x,y:i.y,zoom:Fa(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let h=m.on(`wheel.zoom`),g=m.on(`dblclick.zoom`);p.wheelDelta(Ps);async function _(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?M:w).transform(Ns(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function v({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:f,preventScrolling:_,zoomOnPinch:v,zoomOnScroll:y,zoomOnDoubleClick:b,panActivationKeyPressed:x=!1,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&p.on(`zoom`,null);let O=i&&!S&&!r;p.clickDistance(D?1/0:!Ya(E)||E<0?0:E);let k=O?Fs({zoomPanValues:l,noWheelClassName:e,d3Selection:m,d3Zoom:p,panOnScrollMode:d,panOnScrollSpeed:f,zoomOnPinch:v,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Is({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:h});m.on(`wheel.zoom`,k,{passive:!1});let A=Ls({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});p.on(`start`,A);let j=Rs({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});p.on(`zoom`,j);let M=zs({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});p.on(`end`,M);let N=Bs({panActivationKeyPressed:x,zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:y,panOnScroll:i,zoomOnDoubleClick:b,zoomOnPinch:v,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});p.filter(N),b?m.on(`dblclick.zoom`,g):m.on(`dblclick.zoom`,null)}function y(){p.on(`zoom`,null),f?.disconnect()}async function b(e,t,n){let r=ks(e),i=p?.constrain()(r,t,n);return i&&await _(i),i}async function x(e,t){let n=ks(e);return await _(n,t),n}function S(e){if(m){let t=ks(e),n=m.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&p?.transform(m,t,null,{sync:!0})}}function C(){let e=m?E(m.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function T(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?M:w).scaleTo(Ns(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function O(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?M:w).scaleBy(Ns(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function A(e){p?.scaleExtent(e)}function j(e){p?.translateExtent(e)}function N(e){let t=!Ya(e)||e<0?0:e;p?.clickDistance(t)}return{update:v,destroy:y,setViewport:x,setViewportConstrained:b,getViewport:C,scaleTo:T,scaleBy:O,setScaleExtent:A,setTranslateExtent:j,syncViewport:S,setClickDistance:N}}var Hs;(function(e){e.Line=`line`,e.Handle=`handle`})(Hs||={});function Us({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function Ws(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function Gs(e,t){return Math.max(0,t-e)}function Ks(e,t){return Math.max(0,e-t)}function qs(e,t,n){return Math.max(0,t-e,e-n)}function Js(e,t){return e?!t:t}function Ys(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=qs(E,h,g),j=qs(D,_,v);if(o){let e=0,t=0;c&&w<0?e=Gs(y+w+O,o[0][0]):!c&&w>0&&(e=Ks(y+E+O,o[1][0])),l&&T<0?t=Gs(b+T+k,o[0][1]):!l&&T>0&&(t=Ks(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=Ks(y+w,s[0][0]):!c&&w<0&&(e=Gs(y+E,s[1][0])),l&&T>0?t=Ks(b+T,s[0][1]):!l&&T<0&&(t=Gs(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=qs(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?Ks(b+k+E/C,o[1][1])*C:Gs(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?Gs(b+E/C,s[1][1])*C:Ks(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=qs(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?Ks(y+D*C+O,o[1][0])/C:Gs(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?Gs(y+D*C,s[1][0])/C:Ks(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(Js(c,l)?-w:w)/C:w=(Js(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var Xs={width:0,height:0,x:0,y:0},Zs={...Xs,pointerX:0,pointerY:0,aspectRatio:1};function Qs(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function $s({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=k(e),o={controlDirection:Ws(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...Xs},h={...Zs};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:Ws(e)};let g,_=null,v=[],y,b,x,S=ne().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=mo(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=ao(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Qs(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=mo(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:S,height:C}=m,w={},T=g.origin??s,{width:E,height:D,x:O,y:k}=Ys(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,T,b,x),A=E!==S,j=D!==C,M=O!==u&&A,N=k!==f&&j;if(!M&&!N&&!A&&!j)return;let P={prevValues:{...m},startX:h.x,startY:h.y,childNodes:v.map(e=>({...e,position:{...e.position}}))};if((M||N||T[0]===1||T[1]===1)&&(w.x=M?O:m.x,w.y=N?k:m.y,m.x=w.x,m.y=w.y,v.length>0)){let e=O-u,t=k-f;for(let n of v)n.position={x:n.position.x-e+T[0]*(E-S),y:n.position.y-t+T[1]*(D-C)},l.push(n)}if((A||j)&&(w.width=A&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?E:m.width,w.height=j&&(!o.resizeDirection||o.resizeDirection===`vertical`)?D:m.height,m.width=w.width,m.height=w.height),y&&g.expandParent){let e=T[0]*(w.width??0);w.x&&w.x<e&&(m.x=e,h.x-=w.x-e);let t=T[1]*(w.height??0);w.y&&w.y<t&&(m.y=t,h.y-=w.y-t)}let F=Us({width:m.width,prevWidth:S,height:m.height,prevHeight:C,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),ee={...m,direction:F};p?.(e,ee)===!1?(m=P.prevValues,h.x=P.startX,h.y=P.startY,v.forEach((e,t)=>{e.position=P.childNodes[t].position})):(d?.(e,ee),r(w,l))}).on(`end`,e=>{f?.(e,{...m}),i?.({...m})});a.call(S)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var ec=e(r(),1),tc=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},nc=e=>e?tc(e):tc,{useDebugValue:rc}=L.default,{useSyncExternalStoreWithSelector:ic}=ec.default,ac=e=>e;function oc(e,t=ac,n){let r=ic(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return rc(r),r}var sc=(e,t)=>{let n=nc(e),r=(e,r=t)=>oc(n,e,r);return Object.assign(r,n),r},cc=(e,t)=>e?sc(e,t):sc;function G(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}t();var lc=(0,L.createContext)(null),uc=lc.Provider,dc=fa.error001(`react`);function K(e,t){let n=(0,L.useContext)(lc);if(n===null)throw Error(dc);return oc(n,e,t)}function q(){let e=(0,L.useContext)(lc);if(e===null)throw Error(dc);return(0,L.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var fc={display:`none`},pc={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},mc=`react-flow__node-desc`,hc=`react-flow__edge-desc`,gc=`react-flow__aria-live`,_c=e=>e.ariaLiveMessage,vc=e=>e.ariaLabelConfig;function yc({rfId:e}){let t=K(_c);return(0,H.jsx)(`div`,{id:`${gc}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:pc,children:t})}function bc({rfId:e,disableKeyboardA11y:t}){let n=K(vc);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{id:`${mc}-${e}`,style:fc,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,H.jsx)(`div`,{id:`${hc}-${e}`,style:fc,children:n[`edge.a11yDescription.default`]}),!t&&(0,H.jsx)(yc,{rfId:e})]})}var xc=(0,L.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,H.jsx)(`div`,{className:U([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});xc.displayName=`Panel`;var Sc=`https://reactflow.dev?utm_source=attribution`;function Cc({proOptions:e,position:t=`bottom-right`}){return(0,L.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,H.jsx)(xc,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Sc}`,children:(0,H.jsx)(`a`,{href:Sc,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var wc=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Tc=e=>e.id;function Ec(e,t){return G(e.selectedNodes.map(Tc),t.selectedNodes.map(Tc))&&G(e.selectedEdges.map(Tc),t.selectedEdges.map(Tc))}function Dc({onSelectionChange:e}){let t=q(),{selectedNodes:n,selectedEdges:r}=K(wc,Ec);return(0,L.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var Oc=e=>!!e.onSelectionChangeHandlers;function kc({onSelectionChange:e}){let t=K(Oc);return e||t?(0,H.jsx)(Dc,{onSelectionChange:e}):null}var Ac=[0,0],jc={x:0,y:0,zoom:1},Mc=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],Nc=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Pc={translateExtent:pa,nodeOrigin:Ac,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Fc(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=K(Nc,G),l=q();(0,L.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Pc,s()}),[]);let u=(0,L.useRef)(Pc);return(0,L.useEffect)(()=>{for(let s of Mc){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:fo(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},Mc.map(t=>e[t])),null}function Ic(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Lc(e){let[t,n]=(0,L.useState)(e===`system`?null:e);return(0,L.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Ic(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Ic()?.matches?`dark`:`light`:t}var Rc=typeof document<`u`?document:null;function zc(e=null,t={target:Rc,actInsideInputWithModifier:!0}){let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(!1),a=(0,L.useRef)(new Set([])),[o,s]=(0,L.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
3
3
  `).replace(`
4
4