orbital-command 0.3.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +67 -42
  2. package/bin/commands/config.js +19 -0
  3. package/bin/commands/events.js +40 -0
  4. package/bin/commands/launch.js +126 -0
  5. package/bin/commands/manifest.js +283 -0
  6. package/bin/commands/registry.js +104 -0
  7. package/bin/commands/update.js +24 -0
  8. package/bin/lib/helpers.js +229 -0
  9. package/bin/orbital.js +95 -870
  10. package/dist/assets/Landing-CfQdHR0N.js +11 -0
  11. package/dist/assets/PrimitivesConfig-DThSipFy.js +32 -0
  12. package/dist/assets/QualityGates-B4kxM5UU.js +26 -0
  13. package/dist/assets/SessionTimeline-Bz1iZnmg.js +1 -0
  14. package/dist/assets/Settings-DLcZwbCT.js +12 -0
  15. package/dist/assets/SourceControl-BMNIz7Lt.js +36 -0
  16. package/dist/assets/WorkflowVisualizer-CxuSBOYu.js +69 -0
  17. package/dist/assets/{arrow-down-CPy85_J6.js → arrow-down-DVPp6_qp.js} +1 -1
  18. package/dist/assets/bot-NFaJBDn_.js +6 -0
  19. package/dist/assets/{charts-DbDg0Psc.js → charts-LGLb8hyU.js} +1 -1
  20. package/dist/assets/{circle-x-Cwz6ZQDV.js → circle-x-IsFCkBZu.js} +1 -1
  21. package/dist/assets/{file-text-C46Xr65c.js → file-text-J1cebZXF.js} +1 -1
  22. package/dist/assets/{globe-Cn2yNZUD.js → globe-WzeyHsUc.js} +1 -1
  23. package/dist/assets/index-BdJ57EhC.css +1 -0
  24. package/dist/assets/index-o4ScMAuR.js +349 -0
  25. package/dist/assets/{key-OPaNTWJ5.js → key-CKR8JJSj.js} +1 -1
  26. package/dist/assets/{minus-GMsbpKym.js → minus-CHBsJyjp.js} +1 -1
  27. package/dist/assets/radio-xqZaR-Uk.js +6 -0
  28. package/dist/assets/rocket-D_xvvNG6.js +6 -0
  29. package/dist/assets/{shield-DwAFkDYI.js → shield-TdB1yv_a.js} +1 -1
  30. package/dist/assets/useSocketListener-0L5yiN5i.js +1 -0
  31. package/dist/assets/useWorkflowEditor-CqeRWVQX.js +11 -0
  32. package/dist/assets/workflow-constants-Rw-GmgHZ.js +6 -0
  33. package/dist/assets/zap-C9wqYMpl.js +6 -0
  34. package/dist/index.html +3 -3
  35. package/dist/server/server/__tests__/data-routes.test.js +2 -0
  36. package/dist/server/server/__tests__/scope-routes.test.js +1 -0
  37. package/dist/server/server/config-migrator.js +0 -3
  38. package/dist/server/server/config.js +35 -6
  39. package/dist/server/server/database.js +0 -22
  40. package/dist/server/server/index.js +26 -814
  41. package/dist/server/server/init.js +32 -399
  42. package/dist/server/server/launch.js +1 -1
  43. package/dist/server/server/parsers/event-parser.js +4 -1
  44. package/dist/server/server/project-context.js +19 -9
  45. package/dist/server/server/project-manager.js +6 -6
  46. package/dist/server/server/routes/aggregate-routes.js +871 -0
  47. package/dist/server/server/routes/config-routes.js +41 -88
  48. package/dist/server/server/routes/data-routes.js +5 -15
  49. package/dist/server/server/routes/dispatch-routes.js +24 -8
  50. package/dist/server/server/routes/manifest-routes.js +1 -1
  51. package/dist/server/server/routes/scope-routes.js +10 -7
  52. package/dist/server/server/schema.js +1 -0
  53. package/dist/server/server/services/batch-orchestrator.js +17 -3
  54. package/dist/server/server/services/config-service.js +10 -1
  55. package/dist/server/server/services/scope-service.js +7 -7
  56. package/dist/server/server/services/sprint-orchestrator.js +24 -11
  57. package/dist/server/server/services/sprint-service.js +2 -2
  58. package/dist/server/server/uninstall.js +195 -0
  59. package/dist/server/server/update.js +212 -0
  60. package/dist/server/server/utils/dispatch-utils.js +8 -6
  61. package/dist/server/server/utils/flag-builder.js +54 -0
  62. package/dist/server/server/utils/json-fields.js +14 -0
  63. package/dist/server/server/utils/json-fields.test.js +73 -0
  64. package/dist/server/server/utils/route-helpers.js +37 -0
  65. package/dist/server/server/utils/route-helpers.test.js +115 -0
  66. package/dist/server/server/watchers/event-watcher.js +28 -13
  67. package/dist/server/server/wizard/config-editor.js +4 -4
  68. package/dist/server/server/wizard/doctor.js +2 -2
  69. package/dist/server/server/wizard/index.js +224 -39
  70. package/dist/server/server/wizard/phases/welcome.js +1 -4
  71. package/dist/server/server/wizard/ui.js +6 -7
  72. package/dist/server/shared/api-types.js +80 -1
  73. package/dist/server/shared/workflow-engine.js +1 -1
  74. package/package.json +20 -20
  75. package/schemas/orbital.config.schema.json +1 -19
  76. package/scripts/postinstall.js +6 -42
  77. package/scripts/release.sh +53 -0
  78. package/server/__tests__/data-routes.test.ts +2 -0
  79. package/server/__tests__/scope-routes.test.ts +1 -0
  80. package/server/config-migrator.ts +0 -3
  81. package/server/config.ts +39 -11
  82. package/server/database.ts +0 -26
  83. package/server/global-config.ts +4 -0
  84. package/server/index.ts +29 -894
  85. package/server/init.ts +32 -443
  86. package/server/launch.ts +1 -1
  87. package/server/parsers/event-parser.ts +4 -1
  88. package/server/project-context.ts +26 -10
  89. package/server/project-manager.ts +5 -6
  90. package/server/routes/aggregate-routes.ts +968 -0
  91. package/server/routes/config-routes.ts +41 -81
  92. package/server/routes/data-routes.ts +7 -16
  93. package/server/routes/dispatch-routes.ts +29 -8
  94. package/server/routes/manifest-routes.ts +1 -1
  95. package/server/routes/scope-routes.ts +12 -7
  96. package/server/schema.ts +1 -0
  97. package/server/services/batch-orchestrator.ts +18 -2
  98. package/server/services/config-service.ts +10 -1
  99. package/server/services/scope-service.ts +6 -6
  100. package/server/services/sprint-orchestrator.ts +24 -9
  101. package/server/services/sprint-service.ts +2 -2
  102. package/server/uninstall.ts +214 -0
  103. package/server/update.ts +263 -0
  104. package/server/utils/dispatch-utils.ts +8 -6
  105. package/server/utils/flag-builder.ts +56 -0
  106. package/server/utils/json-fields.test.ts +83 -0
  107. package/server/utils/json-fields.ts +14 -0
  108. package/server/utils/route-helpers.test.ts +144 -0
  109. package/server/utils/route-helpers.ts +38 -0
  110. package/server/watchers/event-watcher.ts +24 -12
  111. package/server/wizard/config-editor.ts +4 -4
  112. package/server/wizard/doctor.ts +2 -2
  113. package/server/wizard/index.ts +291 -40
  114. package/server/wizard/phases/welcome.ts +1 -5
  115. package/server/wizard/ui.ts +6 -7
  116. package/shared/api-types.ts +106 -0
  117. package/shared/workflow-engine.ts +1 -1
  118. package/templates/agents/QUICK-REFERENCE.md +1 -0
  119. package/templates/agents/README.md +1 -0
  120. package/templates/agents/SKILL-TRIGGERS.md +11 -0
  121. package/templates/agents/green-team/deep-dive.md +361 -0
  122. package/templates/hooks/end-session.sh +1 -0
  123. package/templates/hooks/init-session.sh +1 -0
  124. package/templates/hooks/scope-commit-logger.sh +2 -2
  125. package/templates/hooks/scope-create-gate.sh +2 -4
  126. package/templates/hooks/scope-gate.sh +4 -6
  127. package/templates/hooks/scope-helpers.sh +10 -1
  128. package/templates/hooks/scope-lifecycle-gate.sh +14 -5
  129. package/templates/hooks/scope-prepare.sh +1 -1
  130. package/templates/hooks/scope-transition.sh +14 -6
  131. package/templates/hooks/time-tracker.sh +2 -5
  132. package/templates/orbital.config.json +1 -4
  133. package/templates/presets/development.json +4 -4
  134. package/templates/presets/gitflow.json +7 -0
  135. package/templates/prompts/README.md +23 -0
  136. package/templates/prompts/deep-dive-audit.md +94 -0
  137. package/templates/quick/rules.md +56 -5
  138. package/templates/skills/git-commit/SKILL.md +21 -6
  139. package/templates/skills/git-dev/SKILL.md +8 -4
  140. package/templates/skills/git-main/SKILL.md +8 -4
  141. package/templates/skills/git-production/SKILL.md +6 -3
  142. package/templates/skills/git-staging/SKILL.md +6 -3
  143. package/templates/skills/scope-fix-review/SKILL.md +8 -4
  144. package/templates/skills/scope-implement/SKILL.md +13 -5
  145. package/templates/skills/scope-post-review/SKILL.md +16 -4
  146. package/templates/skills/scope-pre-review/SKILL.md +6 -2
  147. package/dist/assets/PrimitivesConfig-CrmQXYh4.js +0 -32
  148. package/dist/assets/QualityGates-BbasOsF3.js +0 -21
  149. package/dist/assets/SessionTimeline-CGeJsVvy.js +0 -1
  150. package/dist/assets/Settings-oiM496mc.js +0 -12
  151. package/dist/assets/SourceControl-B1fP2nJL.js +0 -41
  152. package/dist/assets/WorkflowVisualizer-CWLYf-f0.js +0 -74
  153. package/dist/assets/formatDistanceToNow-BMqsSP44.js +0 -1
  154. package/dist/assets/index-Aj4sV8Al.css +0 -1
  155. package/dist/assets/index-Bc9dK3MW.js +0 -354
  156. package/dist/assets/useWorkflowEditor-BJkTX_NR.js +0 -16
  157. package/dist/assets/zap-DfbUoOty.js +0 -11
  158. package/dist/server/server/services/telemetry-service.js +0 -143
  159. package/server/services/telemetry-service.ts +0 -195
  160. /package/{shared/default-workflow.json → templates/presets/default.json} +0 -0
@@ -1,74 +0,0 @@
1
- import{j as r,x as ss,t as rs,O as os,v as is,y as as,w as Ke}from"./ui-BmsSg9jU.js";import{r as Xr,g as lc,d as cs,a as N,b as dc}from"./vendor-Bqt8AJn2.js";import{i as uc,e as Hs,f as Fs,g as fc,h as hc,j as pc,k as qt,l as Mn}from"./charts-DbDg0Psc.js";import{c as be,u as ls,p as qr,al as Ur,q as Kr,X as he,G as Zr,E as Ct,T as ye,S as hn,b as we,l as ds,Q as Le,I as Jt,C as xc,ao as mc,e as us,P as Ae,a1 as gc,a3 as bc,a4 as yc,a5 as wc,a6 as vc,d as Nc,H as Qr,O as Jr,g as eo,a7 as jc,a8 as to,aw as no,ax as Te,ay as Cc,az as zc,aA as kc,aB as Sc,aC as Ec,aD as _c,aE as so,n as Mc,f as Ic,aF as Tc,aG as Ac,aH as fs,aI as $c,r as Pc,t as Bs,aJ as Dc,z as Lc,D as Rc,aK as Oc,aL as Hc,aM as Fc,au as ro,aN as Bc,k as Vc,J as Yc,aO as Gc,w as Wc,aP as Xc}from"./index-Bc9dK3MW.js";import{Z as rt,C as pn}from"./zap-DfbUoOty.js";import{K as qc}from"./key-OPaNTWJ5.js";import{G as hs}from"./globe-Cn2yNZUD.js";import{S as oo,B as en,u as Uc,P as Kc}from"./useWorkflowEditor-BJkTX_NR.js";import{M as io}from"./minus-GMsbpKym.js";import{S as xn}from"./shield-DwAFkDYI.js";import{C as Zc}from"./circle-x-Cwz6ZQDV.js";/**
2
- * @license lucide-react v0.577.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Qc=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],Jc=be("clipboard-check",Qc);/**
7
- * @license lucide-react v0.577.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const el=[["path",{d:"m10 15 5 5 5-5",key:"1hpjnr"}],["path",{d:"M4 4h7a4 4 0 0 1 4 4v12",key:"wcbgct"}]],ao=be("corner-right-down",el);/**
12
- * @license lucide-react v0.577.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const tl=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],tn=be("file-code-corner",tl);/**
17
- * @license lucide-react v0.577.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const nl=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],sl=be("folder-input",nl);/**
22
- * @license lucide-react v0.577.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const rl=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],ol=be("grip-vertical",rl);/**
27
- * @license lucide-react v0.577.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const il=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],al=be("layout-grid",il);/**
32
- * @license lucide-react v0.577.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const cl=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ps=be("radio",cl);/**
37
- * @license lucide-react v0.577.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const ll=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],dl=be("redo-2",ll);/**
42
- * @license lucide-react v0.577.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const ul=[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],fl=be("server-off",ul);/**
47
- * @license lucide-react v0.577.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const hl=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],pl=be("user",hl);function oe(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=oe(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var xl={value:()=>{}};function mn(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new Ut(n)}function Ut(e){this._=e}function ml(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",o=n.indexOf(".");if(o>=0&&(s=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}Ut.prototype=mn.prototype={constructor:Ut,on:function(e,t){var n=this._,s=ml(e+"",n),o,i=-1,a=s.length;if(arguments.length<2){for(;++i<a;)if((o=(e=s[i]).type)&&(o=gl(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(o=(e=s[i]).type)n[o]=Vs(n[o],e.name,t);else if(t==null)for(o in n)n[o]=Vs(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ut(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),s=0,o,i;s<o;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],s=0,o=i.length;s<o;++s)i[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],o=0,i=s.length;o<i;++o)s[o].value.apply(t,n)}};function gl(e,t){for(var n=0,s=e.length,o;n<s;++n)if((o=e[n]).name===t)return o.value}function Vs(e,t,n){for(var s=0,o=e.length;s<o;++s)if(e[s].name===t){e[s]=xl,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Xn="http://www.w3.org/1999/xhtml";const Ys={svg:"http://www.w3.org/2000/svg",xhtml:Xn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function gn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ys.hasOwnProperty(t)?{space:Ys[t],local:e}:e}function bl(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Xn&&t.documentElement.namespaceURI===Xn?t.createElement(e):t.createElementNS(n,e)}}function yl(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function co(e){var t=gn(e);return(t.local?yl:bl)(t)}function wl(){}function xs(e){return e==null?wl:function(){return this.querySelector(e)}}function vl(e){typeof e!="function"&&(e=xs(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,c=s[o]=new Array(a),l,f,h=0;h<a;++h)(l=i[h])&&(f=e.call(l,l.__data__,h,i))&&("__data__"in l&&(f.__data__=l.__data__),c[h]=f);return new ce(s,this._parents)}function Nl(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function jl(){return[]}function lo(e){return e==null?jl:function(){return this.querySelectorAll(e)}}function Cl(e){return function(){return Nl(e.apply(this,arguments))}}function zl(e){typeof e=="function"?e=Cl(e):e=lo(e);for(var t=this._groups,n=t.length,s=[],o=[],i=0;i<n;++i)for(var a=t[i],c=a.length,l,f=0;f<c;++f)(l=a[f])&&(s.push(e.call(l,l.__data__,f,a)),o.push(l));return new ce(s,o)}function uo(e){return function(){return this.matches(e)}}function fo(e){return function(t){return t.matches(e)}}var kl=Array.prototype.find;function Sl(e){return function(){return kl.call(this.children,e)}}function El(){return this.firstElementChild}function _l(e){return this.select(e==null?El:Sl(typeof e=="function"?e:fo(e)))}var Ml=Array.prototype.filter;function Il(){return Array.from(this.children)}function Tl(e){return function(){return Ml.call(this.children,e)}}function Al(e){return this.selectAll(e==null?Il:Tl(typeof e=="function"?e:fo(e)))}function $l(e){typeof e!="function"&&(e=uo(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,c=s[o]=[],l,f=0;f<a;++f)(l=i[f])&&e.call(l,l.__data__,f,i)&&c.push(l);return new ce(s,this._parents)}function ho(e){return new Array(e.length)}function Pl(){return new ce(this._enter||this._groups.map(ho),this._parents)}function nn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}nn.prototype={constructor:nn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Dl(e){return function(){return e}}function Ll(e,t,n,s,o,i){for(var a=0,c,l=t.length,f=i.length;a<f;++a)(c=t[a])?(c.__data__=i[a],s[a]=c):n[a]=new nn(e,i[a]);for(;a<l;++a)(c=t[a])&&(o[a]=c)}function Rl(e,t,n,s,o,i,a){var c,l,f=new Map,h=t.length,d=i.length,u=new Array(h),p;for(c=0;c<h;++c)(l=t[c])&&(u[c]=p=a.call(l,l.__data__,c,t)+"",f.has(p)?o[c]=l:f.set(p,l));for(c=0;c<d;++c)p=a.call(e,i[c],c,i)+"",(l=f.get(p))?(s[c]=l,l.__data__=i[c],f.delete(p)):n[c]=new nn(e,i[c]);for(c=0;c<h;++c)(l=t[c])&&f.get(u[c])===l&&(o[c]=l)}function Ol(e){return e.__data__}function Hl(e,t){if(!arguments.length)return Array.from(this,Ol);var n=t?Rl:Ll,s=this._parents,o=this._groups;typeof e!="function"&&(e=Dl(e));for(var i=o.length,a=new Array(i),c=new Array(i),l=new Array(i),f=0;f<i;++f){var h=s[f],d=o[f],u=d.length,p=Fl(e.call(h,h&&h.__data__,f,s)),x=p.length,b=c[f]=new Array(x),v=a[f]=new Array(x),y=l[f]=new Array(u);n(h,d,b,v,y,p,t);for(var g=0,m=0,w,C;g<x;++g)if(w=b[g]){for(g>=m&&(m=g+1);!(C=v[m])&&++m<x;);w._next=C||null}}return a=new ce(a,s),a._enter=c,a._exit=l,a}function Fl(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Bl(){return new ce(this._exit||this._groups.map(ho),this._parents)}function Vl(e,t,n){var s=this.enter(),o=this,i=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),s&&o?s.merge(o).order():o}function Yl(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,o=n.length,i=s.length,a=Math.min(o,i),c=new Array(o),l=0;l<a;++l)for(var f=n[l],h=s[l],d=f.length,u=c[l]=new Array(d),p,x=0;x<d;++x)(p=f[x]||h[x])&&(u[x]=p);for(;l<o;++l)c[l]=n[l];return new ce(c,this._parents)}function Gl(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],o=s.length-1,i=s[o],a;--o>=0;)(a=s[o])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Wl(e){e||(e=Xl);function t(d,u){return d&&u?e(d.__data__,u.__data__):!d-!u}for(var n=this._groups,s=n.length,o=new Array(s),i=0;i<s;++i){for(var a=n[i],c=a.length,l=o[i]=new Array(c),f,h=0;h<c;++h)(f=a[h])&&(l[h]=f);l.sort(t)}return new ce(o,this._parents).order()}function Xl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ql(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ul(){return Array.from(this)}function Kl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,i=s.length;o<i;++o){var a=s[o];if(a)return a}return null}function Zl(){let e=0;for(const t of this)++e;return e}function Ql(){return!this.node()}function Jl(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var o=t[n],i=0,a=o.length,c;i<a;++i)(c=o[i])&&e.call(c,c.__data__,i,o);return this}function ed(e){return function(){this.removeAttribute(e)}}function td(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nd(e,t){return function(){this.setAttribute(e,t)}}function sd(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function rd(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function od(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function id(e,t){var n=gn(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?td:ed:typeof t=="function"?n.local?od:rd:n.local?sd:nd)(n,t))}function po(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ad(e){return function(){this.style.removeProperty(e)}}function cd(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ld(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function dd(e,t,n){return arguments.length>1?this.each((t==null?ad:typeof t=="function"?ld:cd)(e,t,n??"")):Ze(this.node(),e)}function Ze(e,t){return e.style.getPropertyValue(t)||po(e).getComputedStyle(e,null).getPropertyValue(t)}function ud(e){return function(){delete this[e]}}function fd(e,t){return function(){this[e]=t}}function hd(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function pd(e,t){return arguments.length>1?this.each((t==null?ud:typeof t=="function"?hd:fd)(e,t)):this.node()[e]}function xo(e){return e.trim().split(/^|\s+/)}function ms(e){return e.classList||new mo(e)}function mo(e){this._node=e,this._names=xo(e.getAttribute("class")||"")}mo.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function go(e,t){for(var n=ms(e),s=-1,o=t.length;++s<o;)n.add(t[s])}function bo(e,t){for(var n=ms(e),s=-1,o=t.length;++s<o;)n.remove(t[s])}function xd(e){return function(){go(this,e)}}function md(e){return function(){bo(this,e)}}function gd(e,t){return function(){(t.apply(this,arguments)?go:bo)(this,e)}}function bd(e,t){var n=xo(e+"");if(arguments.length<2){for(var s=ms(this.node()),o=-1,i=n.length;++o<i;)if(!s.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?gd:t?xd:md)(n,t))}function yd(){this.textContent=""}function wd(e){return function(){this.textContent=e}}function vd(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Nd(e){return arguments.length?this.each(e==null?yd:(typeof e=="function"?vd:wd)(e)):this.node().textContent}function jd(){this.innerHTML=""}function Cd(e){return function(){this.innerHTML=e}}function zd(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function kd(e){return arguments.length?this.each(e==null?jd:(typeof e=="function"?zd:Cd)(e)):this.node().innerHTML}function Sd(){this.nextSibling&&this.parentNode.appendChild(this)}function Ed(){return this.each(Sd)}function _d(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Md(){return this.each(_d)}function Id(e){var t=typeof e=="function"?e:co(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Td(){return null}function Ad(e,t){var n=typeof e=="function"?e:co(e),s=t==null?Td:typeof t=="function"?t:xs(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function $d(){var e=this.parentNode;e&&e.removeChild(this)}function Pd(){return this.each($d)}function Dd(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ld(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Rd(e){return this.select(e?Ld:Dd)}function Od(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Hd(e){return function(t){e.call(this,t,this.__data__)}}function Fd(e){return e.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");return s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),{type:t,name:n}})}function Bd(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++s]=i;++s?t.length=s:delete this.__on}}}function Vd(e,t,n){return function(){var s=this.__on,o,i=Hd(t);if(s){for(var a=0,c=s.length;a<c;++a)if((o=s[a]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},s?s.push(o):this.__on=[o]}}function Yd(e,t,n){var s=Fd(e+""),o,i=s.length,a;if(arguments.length<2){var c=this.node().__on;if(c){for(var l=0,f=c.length,h;l<f;++l)for(o=0,h=c[l];o<i;++o)if((a=s[o]).type===h.type&&a.name===h.name)return h.value}return}for(c=t?Vd:Bd,o=0;o<i;++o)this.each(c(s[o],t,n));return this}function yo(e,t,n){var s=po(e),o=s.CustomEvent;typeof o=="function"?o=new o(t,n):(o=s.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Gd(e,t){return function(){return yo(this,e,t)}}function Wd(e,t){return function(){return yo(this,e,t.apply(this,arguments))}}function Xd(e,t){return this.each((typeof t=="function"?Wd:Gd)(e,t))}function*qd(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,i=s.length,a;o<i;++o)(a=s[o])&&(yield a)}var wo=[null];function ce(e,t){this._groups=e,this._parents=t}function zt(){return new ce([[document.documentElement]],wo)}function Ud(){return this}ce.prototype=zt.prototype={constructor:ce,select:vl,selectAll:zl,selectChild:_l,selectChildren:Al,filter:$l,data:Hl,enter:Pl,exit:Bl,join:Vl,merge:Yl,selection:Ud,order:Gl,sort:Wl,call:ql,nodes:Ul,node:Kl,size:Zl,empty:Ql,each:Jl,attr:id,style:dd,property:pd,classed:bd,text:Nd,html:kd,raise:Ed,lower:Md,append:Id,insert:Ad,remove:Pd,clone:Rd,datum:Od,on:Yd,dispatch:Xd,[Symbol.iterator]:qd};function ae(e){return typeof e=="string"?new ce([[document.querySelector(e)]],[document.documentElement]):new ce([[e]],wo)}function Kd(e){let t;for(;t=e.sourceEvent;)e=t;return e}function le(e,t){if(e=Kd(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const Zd={passive:!1},gt={capture:!0,passive:!1};function In(e){e.stopImmediatePropagation()}function Ue(e){e.preventDefault(),e.stopImmediatePropagation()}function vo(e){var t=e.document.documentElement,n=ae(e).on("dragstart.drag",Ue,gt);"onselectstart"in t?n.on("selectstart.drag",Ue,gt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function No(e,t){var n=e.document.documentElement,s=ae(e).on("dragstart.drag",null);t&&(s.on("click.drag",Ue,gt),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const At=e=>()=>e;function qn(e,{sourceEvent:t,subject:n,target:s,identifier:o,active:i,x:a,y:c,dx:l,dy:f,dispatch:h}){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:s,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:h}})}qn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Qd(e){return!e.ctrlKey&&!e.button}function Jd(){return this.parentNode}function eu(e,t){return t??{x:e.x,y:e.y}}function tu(){return navigator.maxTouchPoints||"ontouchstart"in this}function jo(){var e=Qd,t=Jd,n=eu,s=tu,o={},i=mn("start","drag","end"),a=0,c,l,f,h,d=0;function u(w){w.on("mousedown.drag",p).filter(s).on("touchstart.drag",v).on("touchmove.drag",y,Zd).on("touchend.drag touchcancel.drag",g).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,C){if(!(h||!e.call(this,w,C))){var z=m(this,t.call(this,w,C),w,C,"mouse");z&&(ae(w.view).on("mousemove.drag",x,gt).on("mouseup.drag",b,gt),vo(w.view),In(w),f=!1,c=w.clientX,l=w.clientY,z("start",w))}}function x(w){if(Ue(w),!f){var C=w.clientX-c,z=w.clientY-l;f=C*C+z*z>d}o.mouse("drag",w)}function b(w){ae(w.view).on("mousemove.drag mouseup.drag",null),No(w.view,f),Ue(w),o.mouse("end",w)}function v(w,C){if(e.call(this,w,C)){var z=w.changedTouches,k=t.call(this,w,C),$=z.length,P,F;for(P=0;P<$;++P)(F=m(this,k,w,C,z[P].identifier,z[P]))&&(In(w),F("start",w,z[P]))}}function y(w){var C=w.changedTouches,z=C.length,k,$;for(k=0;k<z;++k)($=o[C[k].identifier])&&(Ue(w),$("drag",w,C[k]))}function g(w){var C=w.changedTouches,z=C.length,k,$;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),k=0;k<z;++k)($=o[C[k].identifier])&&(In(w),$("end",w,C[k]))}function m(w,C,z,k,$,P){var F=i.copy(),M=le(P||z,C),A,O,j;if((j=n.call(w,new qn("beforestart",{sourceEvent:z,target:u,identifier:$,active:a,x:M[0],y:M[1],dx:0,dy:0,dispatch:F}),k))!=null)return A=j.x-M[0]||0,O=j.y-M[1]||0,function T(S,I,E){var _=M,L;switch(S){case"start":o[$]=T,L=a++;break;case"end":delete o[$],--a;case"drag":M=le(E||I,C),L=a;break}F.call(S,w,new qn(S,{sourceEvent:I,subject:j,target:u,identifier:$,active:L,x:M[0]+A,y:M[1]+O,dx:M[0]-_[0],dy:M[1]-_[1],dispatch:F}),k)}}return u.filter=function(w){return arguments.length?(e=typeof w=="function"?w:At(!!w),u):e},u.container=function(w){return arguments.length?(t=typeof w=="function"?w:At(w),u):t},u.subject=function(w){return arguments.length?(n=typeof w=="function"?w:At(w),u):n},u.touchable=function(w){return arguments.length?(s=typeof w=="function"?w:At(!!w),u):s},u.on=function(){var w=i.on.apply(i,arguments);return w===i?u:w},u.clickDistance=function(w){return arguments.length?(d=(w=+w)*w,u):Math.sqrt(d)},u}var Qe=0,pt=0,lt=0,Co=1e3,sn,xt,rn=0,Re=0,bn=0,bt=typeof performance=="object"&&performance.now?performance:Date,zo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function gs(){return Re||(zo(nu),Re=bt.now()+bn)}function nu(){Re=0}function on(){this._call=this._time=this._next=null}on.prototype=ko.prototype={constructor:on,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?gs():+n)+(t==null?0:+t),!this._next&&xt!==this&&(xt?xt._next=this:sn=this,xt=this),this._call=e,this._time=n,Un()},stop:function(){this._call&&(this._call=null,this._time=1/0,Un())}};function ko(e,t,n){var s=new on;return s.restart(e,t,n),s}function su(){gs(),++Qe;for(var e=sn,t;e;)(t=Re-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Qe}function Gs(){Re=(rn=bt.now())+bn,Qe=pt=0;try{su()}finally{Qe=0,ou(),Re=0}}function ru(){var e=bt.now(),t=e-rn;t>Co&&(bn-=t,rn=e)}function ou(){for(var e,t=sn,n,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:sn=n);xt=e,Un(s)}function Un(e){if(!Qe){pt&&(pt=clearTimeout(pt));var t=e-Re;t>24?(e<1/0&&(pt=setTimeout(Gs,e-bt.now()-bn)),lt&&(lt=clearInterval(lt))):(lt||(rn=bt.now(),lt=setInterval(ru,Co)),Qe=1,zo(Gs))}}function Ws(e,t,n){var s=new on;return t=t==null?0:+t,s.restart(o=>{s.stop(),e(o+t)},t,n),s}var iu=mn("start","end","cancel","interrupt"),au=[],So=0,Xs=1,Kn=2,Kt=3,qs=4,Zn=5,Zt=6;function yn(e,t,n,s,o,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;cu(e,n,{name:t,index:s,group:o,on:iu,tween:au,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:So})}function bs(e,t){var n=pe(e,t);if(n.state>So)throw new Error("too late; already scheduled");return n}function ve(e,t){var n=pe(e,t);if(n.state>Kt)throw new Error("too late; already running");return n}function pe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function cu(e,t,n){var s=e.__transition,o;s[t]=n,n.timer=ko(i,0,n.time);function i(f){n.state=Xs,n.timer.restart(a,n.delay,n.time),n.delay<=f&&a(f-n.delay)}function a(f){var h,d,u,p;if(n.state!==Xs)return l();for(h in s)if(p=s[h],p.name===n.name){if(p.state===Kt)return Ws(a);p.state===qs?(p.state=Zt,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete s[h]):+h<t&&(p.state=Zt,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete s[h])}if(Ws(function(){n.state===Kt&&(n.state=qs,n.timer.restart(c,n.delay,n.time),c(f))}),n.state=Kn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Kn){for(n.state=Kt,o=new Array(u=n.tween.length),h=0,d=-1;h<u;++h)(p=n.tween[h].value.call(e,e.__data__,n.index,n.group))&&(o[++d]=p);o.length=d+1}}function c(f){for(var h=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(l),n.state=Zn,1),d=-1,u=o.length;++d<u;)o[d].call(e,h);n.state===Zn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Zt,n.timer.stop(),delete s[t];for(var f in s)return;delete e.__transition}}function Qt(e,t){var n=e.__transition,s,o,i=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((s=n[a]).name!==t){i=!1;continue}o=s.state>Kn&&s.state<Zn,s.state=Zt,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[a]}i&&delete e.__transition}}function lu(e){return this.each(function(){Qt(this,e)})}function du(e,t){var n,s;return function(){var o=ve(this,e),i=o.tween;if(i!==n){s=n=i;for(var a=0,c=s.length;a<c;++a)if(s[a].name===t){s=s.slice(),s.splice(a,1);break}}o.tween=s}}function uu(e,t,n){var s,o;if(typeof n!="function")throw new Error;return function(){var i=ve(this,e),a=i.tween;if(a!==s){o=(s=a).slice();for(var c={name:t,value:n},l=0,f=o.length;l<f;++l)if(o[l].name===t){o[l]=c;break}l===f&&o.push(c)}i.tween=o}}function fu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=pe(this.node(),n).tween,o=0,i=s.length,a;o<i;++o)if((a=s[o]).name===e)return a.value;return null}return this.each((t==null?du:uu)(n,e,t))}function ys(e,t,n){var s=e._id;return e.each(function(){var o=ve(this,s);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return pe(o,s).value[t]}}function Eo(e,t){var n;return(typeof t=="number"?uc:t instanceof Hs?Fs:(n=Hs(t))?(t=n,Fs):fc)(e,t)}function hu(e){return function(){this.removeAttribute(e)}}function pu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xu(e,t,n){var s,o=n+"",i;return function(){var a=this.getAttribute(e);return a===o?null:a===s?i:i=t(s=a,n)}}function mu(e,t,n){var s,o=n+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===o?null:a===s?i:i=t(s=a,n)}}function gu(e,t,n){var s,o,i;return function(){var a,c=n(this),l;return c==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=c+"",a===l?null:a===s&&l===o?i:(o=l,i=t(s=a,c)))}}function bu(e,t,n){var s,o,i;return function(){var a,c=n(this),l;return c==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=c+"",a===l?null:a===s&&l===o?i:(o=l,i=t(s=a,c)))}}function yu(e,t){var n=gn(e),s=n==="transform"?hc:Eo;return this.attrTween(e,typeof t=="function"?(n.local?bu:gu)(n,s,ys(this,"attr."+e,t)):t==null?(n.local?pu:hu)(n):(n.local?mu:xu)(n,s,t))}function wu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function vu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Nu(e,t){var n,s;function o(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&vu(e,i)),n}return o._value=t,o}function ju(e,t){var n,s;function o(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&wu(e,i)),n}return o._value=t,o}function Cu(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var s=gn(e);return this.tween(n,(s.local?Nu:ju)(s,t))}function zu(e,t){return function(){bs(this,e).delay=+t.apply(this,arguments)}}function ku(e,t){return t=+t,function(){bs(this,e).delay=t}}function Su(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?zu:ku)(t,e)):pe(this.node(),t).delay}function Eu(e,t){return function(){ve(this,e).duration=+t.apply(this,arguments)}}function _u(e,t){return t=+t,function(){ve(this,e).duration=t}}function Mu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Eu:_u)(t,e)):pe(this.node(),t).duration}function Iu(e,t){if(typeof t!="function")throw new Error;return function(){ve(this,e).ease=t}}function Tu(e){var t=this._id;return arguments.length?this.each(Iu(t,e)):pe(this.node(),t).ease}function Au(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ve(this,e).ease=n}}function $u(e){if(typeof e!="function")throw new Error;return this.each(Au(this._id,e))}function Pu(e){typeof e!="function"&&(e=uo(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,c=s[o]=[],l,f=0;f<a;++f)(l=i[f])&&e.call(l,l.__data__,f,i)&&c.push(l);return new ze(s,this._parents,this._name,this._id)}function Du(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,o=n.length,i=Math.min(s,o),a=new Array(s),c=0;c<i;++c)for(var l=t[c],f=n[c],h=l.length,d=a[c]=new Array(h),u,p=0;p<h;++p)(u=l[p]||f[p])&&(d[p]=u);for(;c<s;++c)a[c]=t[c];return new ze(a,this._parents,this._name,this._id)}function Lu(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Ru(e,t,n){var s,o,i=Lu(t)?bs:ve;return function(){var a=i(this,e),c=a.on;c!==s&&(o=(s=c).copy()).on(t,n),a.on=o}}function Ou(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(Ru(n,e,t))}function Hu(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Fu(){return this.on("end.remove",Hu(this._id))}function Bu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=xs(e));for(var s=this._groups,o=s.length,i=new Array(o),a=0;a<o;++a)for(var c=s[a],l=c.length,f=i[a]=new Array(l),h,d,u=0;u<l;++u)(h=c[u])&&(d=e.call(h,h.__data__,u,c))&&("__data__"in h&&(d.__data__=h.__data__),f[u]=d,yn(f[u],t,n,u,f,pe(h,n)));return new ze(i,this._parents,t,n)}function Vu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=lo(e));for(var s=this._groups,o=s.length,i=[],a=[],c=0;c<o;++c)for(var l=s[c],f=l.length,h,d=0;d<f;++d)if(h=l[d]){for(var u=e.call(h,h.__data__,d,l),p,x=pe(h,n),b=0,v=u.length;b<v;++b)(p=u[b])&&yn(p,t,n,b,u,x);i.push(u),a.push(h)}return new ze(i,a,t,n)}var Yu=zt.prototype.constructor;function Gu(){return new Yu(this._groups,this._parents)}function Wu(e,t){var n,s,o;return function(){var i=Ze(this,e),a=(this.style.removeProperty(e),Ze(this,e));return i===a?null:i===n&&a===s?o:o=t(n=i,s=a)}}function _o(e){return function(){this.style.removeProperty(e)}}function Xu(e,t,n){var s,o=n+"",i;return function(){var a=Ze(this,e);return a===o?null:a===s?i:i=t(s=a,n)}}function qu(e,t,n){var s,o,i;return function(){var a=Ze(this,e),c=n(this),l=c+"";return c==null&&(l=c=(this.style.removeProperty(e),Ze(this,e))),a===l?null:a===s&&l===o?i:(o=l,i=t(s=a,c))}}function Uu(e,t){var n,s,o,i="style."+t,a="end."+i,c;return function(){var l=ve(this,e),f=l.on,h=l.value[i]==null?c||(c=_o(t)):void 0;(f!==n||o!==h)&&(s=(n=f).copy()).on(a,o=h),l.on=s}}function Ku(e,t,n){var s=(e+="")=="transform"?pc:Eo;return t==null?this.styleTween(e,Wu(e,s)).on("end.style."+e,_o(e)):typeof t=="function"?this.styleTween(e,qu(e,s,ys(this,"style."+e,t))).each(Uu(this._id,e)):this.styleTween(e,Xu(e,s,t),n).on("end.style."+e,null)}function Zu(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function Qu(e,t,n){var s,o;function i(){var a=t.apply(this,arguments);return a!==o&&(s=(o=a)&&Zu(e,a,n)),s}return i._value=t,i}function Ju(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,Qu(e,t,n??""))}function ef(e){return function(){this.textContent=e}}function tf(e){return function(){var t=e(this);this.textContent=t??""}}function nf(e){return this.tween("text",typeof e=="function"?tf(ys(this,"text",e)):ef(e==null?"":e+""))}function sf(e){return function(t){this.textContent=e.call(this,t)}}function rf(e){var t,n;function s(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&sf(o)),t}return s._value=e,s}function of(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,rf(e))}function af(){for(var e=this._name,t=this._id,n=Mo(),s=this._groups,o=s.length,i=0;i<o;++i)for(var a=s[i],c=a.length,l,f=0;f<c;++f)if(l=a[f]){var h=pe(l,t);yn(l,e,n,f,a,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new ze(s,this._parents,e,n)}function cf(){var e,t,n=this,s=n._id,o=n.size();return new Promise(function(i,a){var c={value:a},l={value:function(){--o===0&&i()}};n.each(function(){var f=ve(this,s),h=f.on;h!==e&&(t=(e=h).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(l)),f.on=t}),o===0&&i()})}var lf=0;function ze(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Mo(){return++lf}var je=zt.prototype;ze.prototype={constructor:ze,select:Bu,selectAll:Vu,selectChild:je.selectChild,selectChildren:je.selectChildren,filter:Pu,merge:Du,selection:Gu,transition:af,call:je.call,nodes:je.nodes,node:je.node,size:je.size,empty:je.empty,each:je.each,on:Ou,attr:yu,attrTween:Cu,style:Ku,styleTween:Ju,text:nf,textTween:of,remove:Fu,tween:fu,delay:Su,duration:Mu,ease:Tu,easeVarying:$u,end:cf,[Symbol.iterator]:je[Symbol.iterator]};function df(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var uf={time:null,delay:0,duration:250,ease:df};function ff(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function hf(e){var t,n;e instanceof ze?(t=e._id,e=e._name):(t=Mo(),(n=uf).time=gs(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,i=0;i<o;++i)for(var a=s[i],c=a.length,l,f=0;f<c;++f)(l=a[f])&&yn(l,e,t,f,a,n||ff(l,t));return new ze(s,this._parents,e,t)}zt.prototype.interrupt=lu;zt.prototype.transition=hf;const $t=e=>()=>e;function pf(e,{sourceEvent:t,target:n,transform:s,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:o}})}function Ce(e,t,n){this.k=e,this.x=t,this.y=n}Ce.prototype={constructor:Ce,scale:function(e){return e===1?this:new Ce(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ce(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var wn=new Ce(1,0,0);Io.prototype=Ce.prototype;function Io(e){for(;!e.__zoom;)if(!(e=e.parentNode))return wn;return e.__zoom}function Tn(e){e.stopImmediatePropagation()}function dt(e){e.preventDefault(),e.stopImmediatePropagation()}function xf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function mf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Us(){return this.__zoom||wn}function gf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function bf(){return navigator.maxTouchPoints||"ontouchstart"in this}function yf(e,t,n){var s=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function To(){var e=xf,t=mf,n=yf,s=gf,o=bf,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],c=250,l=qt,f=mn("start","zoom","end"),h,d,u,p=500,x=150,b=0,v=10;function y(j){j.property("__zoom",Us).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",F).filter(o).on("touchstart.zoom",M).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(j,T,S,I){var E=j.selection?j.selection():j;E.property("__zoom",Us),j!==E?C(j,T,S,I):E.interrupt().each(function(){z(this,arguments).event(I).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},y.scaleBy=function(j,T,S,I){y.scaleTo(j,function(){var E=this.__zoom.k,_=typeof T=="function"?T.apply(this,arguments):T;return E*_},S,I)},y.scaleTo=function(j,T,S,I){y.transform(j,function(){var E=t.apply(this,arguments),_=this.__zoom,L=S==null?w(E):typeof S=="function"?S.apply(this,arguments):S,R=_.invert(L),D=typeof T=="function"?T.apply(this,arguments):T;return n(m(g(_,D),L,R),E,a)},S,I)},y.translateBy=function(j,T,S,I){y.transform(j,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof S=="function"?S.apply(this,arguments):S),t.apply(this,arguments),a)},null,I)},y.translateTo=function(j,T,S,I,E){y.transform(j,function(){var _=t.apply(this,arguments),L=this.__zoom,R=I==null?w(_):typeof I=="function"?I.apply(this,arguments):I;return n(wn.translate(R[0],R[1]).scale(L.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof S=="function"?-S.apply(this,arguments):-S),_,a)},I,E)};function g(j,T){return T=Math.max(i[0],Math.min(i[1],T)),T===j.k?j:new Ce(T,j.x,j.y)}function m(j,T,S){var I=T[0]-S[0]*j.k,E=T[1]-S[1]*j.k;return I===j.x&&E===j.y?j:new Ce(j.k,I,E)}function w(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function C(j,T,S,I){j.on("start.zoom",function(){z(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(I).end()}).tween("zoom",function(){var E=this,_=arguments,L=z(E,_).event(I),R=t.apply(E,_),D=S==null?w(R):typeof S=="function"?S.apply(E,_):S,V=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),G=E.__zoom,X=typeof T=="function"?T.apply(E,_):T,K=l(G.invert(D).concat(V/G.k),X.invert(D).concat(V/X.k));return function(B){if(B===1)B=X;else{var H=K(B),Y=V/H[2];B=new Ce(Y,D[0]-H[0]*Y,D[1]-H[1]*Y)}L.zoom(null,B)}})}function z(j,T,S){return!S&&j.__zooming||new k(j,T)}function k(j,T){this.that=j,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(j,T),this.taps=0}k.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,T){return this.mouse&&j!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var T=ae(this.that).datum();f.call(j,this.that,new pf(j,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:f}),T)}};function $(j,...T){if(!e.apply(this,arguments))return;var S=z(this,T).event(j),I=this.__zoom,E=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,s.apply(this,arguments)))),_=le(j);if(S.wheel)(S.mouse[0][0]!==_[0]||S.mouse[0][1]!==_[1])&&(S.mouse[1]=I.invert(S.mouse[0]=_)),clearTimeout(S.wheel);else{if(I.k===E)return;S.mouse=[_,I.invert(_)],Qt(this),S.start()}dt(j),S.wheel=setTimeout(L,x),S.zoom("mouse",n(m(g(I,E),S.mouse[0],S.mouse[1]),S.extent,a));function L(){S.wheel=null,S.end()}}function P(j,...T){if(u||!e.apply(this,arguments))return;var S=j.currentTarget,I=z(this,T,!0).event(j),E=ae(j.view).on("mousemove.zoom",D,!0).on("mouseup.zoom",V,!0),_=le(j,S),L=j.clientX,R=j.clientY;vo(j.view),Tn(j),I.mouse=[_,this.__zoom.invert(_)],Qt(this),I.start();function D(G){if(dt(G),!I.moved){var X=G.clientX-L,K=G.clientY-R;I.moved=X*X+K*K>b}I.event(G).zoom("mouse",n(m(I.that.__zoom,I.mouse[0]=le(G,S),I.mouse[1]),I.extent,a))}function V(G){E.on("mousemove.zoom mouseup.zoom",null),No(G.view,I.moved),dt(G),I.event(G).end()}}function F(j,...T){if(e.apply(this,arguments)){var S=this.__zoom,I=le(j.changedTouches?j.changedTouches[0]:j,this),E=S.invert(I),_=S.k*(j.shiftKey?.5:2),L=n(m(g(S,_),I,E),t.apply(this,T),a);dt(j),c>0?ae(this).transition().duration(c).call(C,L,I,j):ae(this).call(y.transform,L,I,j)}}function M(j,...T){if(e.apply(this,arguments)){var S=j.touches,I=S.length,E=z(this,T,j.changedTouches.length===I).event(j),_,L,R,D;for(Tn(j),L=0;L<I;++L)R=S[L],D=le(R,this),D=[D,this.__zoom.invert(D),R.identifier],E.touch0?!E.touch1&&E.touch0[2]!==D[2]&&(E.touch1=D,E.taps=0):(E.touch0=D,_=!0,E.taps=1+!!h);h&&(h=clearTimeout(h)),_&&(E.taps<2&&(d=D[0],h=setTimeout(function(){h=null},p)),Qt(this),E.start())}}function A(j,...T){if(this.__zooming){var S=z(this,T).event(j),I=j.changedTouches,E=I.length,_,L,R,D;for(dt(j),_=0;_<E;++_)L=I[_],R=le(L,this),S.touch0&&S.touch0[2]===L.identifier?S.touch0[0]=R:S.touch1&&S.touch1[2]===L.identifier&&(S.touch1[0]=R);if(L=S.that.__zoom,S.touch1){var V=S.touch0[0],G=S.touch0[1],X=S.touch1[0],K=S.touch1[1],B=(B=X[0]-V[0])*B+(B=X[1]-V[1])*B,H=(H=K[0]-G[0])*H+(H=K[1]-G[1])*H;L=g(L,Math.sqrt(B/H)),R=[(V[0]+X[0])/2,(V[1]+X[1])/2],D=[(G[0]+K[0])/2,(G[1]+K[1])/2]}else if(S.touch0)R=S.touch0[0],D=S.touch0[1];else return;S.zoom("touch",n(m(L,R,D),S.extent,a))}}function O(j,...T){if(this.__zooming){var S=z(this,T).event(j),I=j.changedTouches,E=I.length,_,L;for(Tn(j),u&&clearTimeout(u),u=setTimeout(function(){u=null},p),_=0;_<E;++_)L=I[_],S.touch0&&S.touch0[2]===L.identifier?delete S.touch0:S.touch1&&S.touch1[2]===L.identifier&&delete S.touch1;if(S.touch1&&!S.touch0&&(S.touch0=S.touch1,delete S.touch1),S.touch0)S.touch0[1]=this.__zoom.invert(S.touch0[0]);else if(S.end(),S.taps===2&&(L=le(L,this),Math.hypot(d[0]-L[0],d[1]-L[1])<v)){var R=ae(this).on("dblclick.zoom");R&&R.apply(this,arguments)}}}return y.wheelDelta=function(j){return arguments.length?(s=typeof j=="function"?j:$t(+j),y):s},y.filter=function(j){return arguments.length?(e=typeof j=="function"?j:$t(!!j),y):e},y.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:$t(!!j),y):o},y.extent=function(j){return arguments.length?(t=typeof j=="function"?j:$t([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),y):t},y.scaleExtent=function(j){return arguments.length?(i[0]=+j[0],i[1]=+j[1],y):[i[0],i[1]]},y.translateExtent=function(j){return arguments.length?(a[0][0]=+j[0][0],a[1][0]=+j[1][0],a[0][1]=+j[0][1],a[1][1]=+j[1][1],y):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},y.constrain=function(j){return arguments.length?(n=j,y):n},y.duration=function(j){return arguments.length?(c=+j,y):c},y.interpolate=function(j){return arguments.length?(l=j,y):l},y.on=function(){var j=f.on.apply(f,arguments);return j===f?y:j},y.clickDistance=function(j){return arguments.length?(b=(j=+j)*j,y):Math.sqrt(b)},y.tapDistance=function(j){return arguments.length?(v=+j,y):v},y}const ge={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.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 React Flow 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:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:s}", 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."},yt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ao=["Enter"," ","Escape"],$o={"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"};var Je;(function(e){e.Strict="strict",e.Loose="loose"})(Je||(Je={}));var De;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(De||(De={}));var wt;(function(e){e.Partial="partial",e.Full="full"})(wt||(wt={}));const Po={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var an;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(an||(an={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const Ks={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top};function Do(e){return e===null?null:e?"valid":"invalid"}const Lo=e=>"id"in e&&"source"in e&&"target"in e,wf=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),ws=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),kt=(e,t=[0,0])=>{const{width:n,height:s}=ke(e),o=e.origin??t,i=n*o[0],a=s*o[1];return{x:e.position.x-i,y:e.position.y-a}},vf=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,o)=>{const i=typeof o=="string";let a=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(o):ws(o)?o:t.nodeLookup.get(o.id));const c=a?cn(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return vn(s,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Nn(n)},St=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=vn(n,cn(o)),s=!0)}),s?Nn(n):{x:0,y:0,width:0,height:0}},vs=(e,t,[n,s,o]=[0,0,1],i=!1,a=!1)=>{const c={..._t(t,[n,s,o]),width:t.width/o,height:t.height/o},l=[];for(const f of e.values()){const{measured:h,selectable:d=!0,hidden:u=!1}=f;if(a&&!d||u)continue;const p=h.width??f.width??f.initialWidth??null,x=h.height??f.height??f.initialHeight??null,b=vt(c,tt(f)),v=(p??0)*(x??0),y=i&&b>0;(!f.internals.handleBounds||y||b>=v||f.dragging)&&l.push(f)}return l},Nf=(e,t)=>{const n=new Set;return e.forEach(s=>{n.add(s.id)}),t.filter(s=>n.has(s.source)||n.has(s.target))};function jf(e,t){const n=new Map,s=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!s||s.has(o.id))&&n.set(o.id,o)}),n}async function Cf({nodes:e,width:t,height:n,panZoom:s,minZoom:o,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const c=jf(e,a),l=St(c),f=Ns(l,t,n,(a==null?void 0:a.minZoom)??o,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await s.setViewport(f,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function Ro({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:o,onError:i}){const a=n.get(e),c=a.parentId?n.get(a.parentId):void 0,{x:l,y:f}=c?c.internals.positionAbsolute:{x:0,y:0},h=a.origin??s;let d=a.extent||o;if(a.extent==="parent"&&!a.expandParent)if(!c)i==null||i("005",ge.error005());else{const p=c.measured.width,x=c.measured.height;p&&x&&(d=[[l,f],[l+p,f+x]])}else c&&nt(a.extent)&&(d=[[a.extent[0][0]+l,a.extent[0][1]+f],[a.extent[1][0]+l,a.extent[1][1]+f]]);const u=nt(d)?Oe(t,d,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",ge.error015())),{position:{x:u.x-l+(a.measured.width??0)*h[0],y:u.y-f+(a.measured.height??0)*h[1]},positionAbsolute:u}}async function zf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:o}){const i=new Set(e.map(u=>u.id)),a=[];for(const u of n){if(u.deletable===!1)continue;const p=i.has(u.id),x=!p&&u.parentId&&a.find(b=>b.id===u.parentId);(p||x)&&a.push(u)}const c=new Set(t.map(u=>u.id)),l=s.filter(u=>u.deletable!==!1),h=Nf(a,l);for(const u of l)c.has(u.id)&&!h.find(x=>x.id===u.id)&&h.push(u);if(!o)return{edges:h,nodes:a};const d=await o({nodes:a,edges:h});return typeof d=="boolean"?d?{edges:h,nodes:a}:{edges:[],nodes:[]}:d}const et=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Oe=(e={x:0,y:0},t,n)=>({x:et(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:et(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Oo(e,t,n){const{width:s,height:o}=ke(n),{x:i,y:a}=n.internals.positionAbsolute;return Oe(e,[[i,a],[i+s,a+o]],t)}const Zs=(e,t,n)=>e<t?et(Math.abs(e-t),1,t)/t:e>n?-et(Math.abs(e-n),1,t)/t:0,Ho=(e,t,n=15,s=40)=>{const o=Zs(e.x,s,t.width-s)*n,i=Zs(e.y,s,t.height-s)*n;return[o,i]},vn=(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)}),Qn=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),Nn=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),tt=(e,t=[0,0])=>{var o,i;const{x:n,y:s}=ws(e)?e.internals.positionAbsolute:kt(e,t);return{x:n,y:s,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},cn=(e,t=[0,0])=>{var o,i;const{x:n,y:s}=ws(e)?e.internals.positionAbsolute:kt(e,t);return{x:n,y:s,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:s+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Fo=(e,t)=>Nn(vn(Qn(e),Qn(t))),vt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},Qs=e=>ue(e.width)&&ue(e.height)&&ue(e.x)&&ue(e.y),ue=e=>!isNaN(e)&&isFinite(e),kf=(e,t)=>{},Et=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),_t=({x:e,y:t},[n,s,o],i=!1,a=[1,1])=>{const c={x:(e-n)/o,y:(t-s)/o};return i?Et(c,a):c},ln=({x:e,y:t},[n,s,o])=>({x:e*o+n,y:t*o+s});function Be(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Sf(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=Be(e,n),o=Be(e,t);return{top:s,right:o,bottom:s,left:o,x:o*2,y:s*2}}if(typeof e=="object"){const s=Be(e.top??e.y??0,n),o=Be(e.bottom??e.y??0,n),i=Be(e.left??e.x??0,t),a=Be(e.right??e.x??0,t);return{top:s,right:a,bottom:o,left:i,x:i+a,y:s+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ef(e,t,n,s,o,i){const{x:a,y:c}=ln(e,[t,n,s]),{x:l,y:f}=ln({x:e.x+e.width,y:e.y+e.height},[t,n,s]),h=o-l,d=i-f;return{left:Math.floor(a),top:Math.floor(c),right:Math.floor(h),bottom:Math.floor(d)}}const Ns=(e,t,n,s,o,i)=>{const a=Sf(i,t,n),c=(t-a.x)/e.width,l=(n-a.y)/e.height,f=Math.min(c,l),h=et(f,s,o),d=e.x+e.width/2,u=e.y+e.height/2,p=t/2-d*h,x=n/2-u*h,b=Ef(e,p,x,h,t,n),v={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:p-v.left+v.right,y:x-v.top+v.bottom,zoom:h}},Nt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function nt(e){return e!=null&&e!=="parent"}function ke(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Bo(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Vo(e,t={width:0,height:0},n,s,o){const i={...e},a=s.get(n);if(a){const c=a.origin||o;i.x+=a.internals.positionAbsolute.x-(t.width??0)*c[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*c[1]}return i}function Js(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function _f(){let e,t;return{promise:new Promise((s,o)=>{e=s,t=o}),resolve:e,reject:t}}function Mf(e){return{...$o,...e||{}}}function mt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:o}){const{x:i,y:a}=fe(e),c=_t({x:i-((o==null?void 0:o.left)??0),y:a-((o==null?void 0:o.top)??0)},s),{x:l,y:f}=n?Et(c,t):c;return{xSnapped:l,ySnapped:f,...c}}const js=e=>({width:e.offsetWidth,height:e.offsetHeight}),Yo=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},If=["INPUT","SELECT","TEXTAREA"];function Go(e){var s,o;const t=((o=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:If.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Wo=e=>"clientX"in e,fe=(e,t)=>{var i,a;const n=Wo(e),s=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},er=(e,t,n,s,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(a=>{const c=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:o,position:a.getAttribute("data-handlepos"),x:(c.left-n.left)/s,y:(c.top-n.top)/s,...js(a)}})};function Xo({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:o,sourceControlY:i,targetControlX:a,targetControlY:c}){const l=e*.125+o*.375+a*.375+n*.125,f=t*.125+i*.375+c*.375+s*.125,h=Math.abs(l-e),d=Math.abs(f-t);return[l,f,h,d]}function Pt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function tr({pos:e,x1:t,y1:n,x2:s,y2:o,c:i}){switch(e){case W.Left:return[t-Pt(t-s,i),n];case W.Right:return[t+Pt(s-t,i),n];case W.Top:return[t,n-Pt(n-o,i)];case W.Bottom:return[t,n+Pt(o-n,i)]}}function qo({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:s,targetY:o,targetPosition:i=W.Top,curvature:a=.25}){const[c,l]=tr({pos:n,x1:e,y1:t,x2:s,y2:o,c:a}),[f,h]=tr({pos:i,x1:s,y1:o,x2:e,y2:t,c:a}),[d,u,p,x]=Xo({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:c,sourceControlY:l,targetControlX:f,targetControlY:h});return[`M${e},${t} C${c},${l} ${f},${h} ${s},${o}`,d,u,p,x]}function Uo({sourceX:e,sourceY:t,targetX:n,targetY:s}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,a=Math.abs(s-t)/2,c=s<t?s+a:s-a;return[i,c,o,a]}function Tf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return s;const a=o&&n?s+1e3:s,c=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return a+c}function Af({sourceNode:e,targetNode:t,width:n,height:s,transform:o}){const i=vn(cn(e),cn(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:s/o[2]};return vt(a,Nn(i))>0}const $f=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,Pf=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Df=(e,t,n={})=>{if(!e.source||!e.target)return t;const s=n.getEdgeId||$f;let o;return Lo(e)?o={...e}:o={...e,id:s(e)},Pf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function Ko({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[o,i,a,c]=Uo({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,o,i,a,c]}const nr={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},Lf=({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},sr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Rf({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:s=W.Top,center:o,offset:i,stepPosition:a}){const c=nr[t],l=nr[s],f={x:e.x+c.x*i,y:e.y+c.y*i},h={x:n.x+l.x*i,y:n.y+l.y*i},d=Lf({source:f,sourcePosition:t,target:h}),u=d.x!==0?"x":"y",p=d[u];let x=[],b,v;const y={x:0,y:0},g={x:0,y:0},[,,m,w]=Uo({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[u]*l[u]===-1){u==="x"?(b=o.x??f.x+(h.x-f.x)*a,v=o.y??(f.y+h.y)/2):(b=o.x??(f.x+h.x)/2,v=o.y??f.y+(h.y-f.y)*a);const z=[{x:b,y:f.y},{x:b,y:h.y}],k=[{x:f.x,y:v},{x:h.x,y:v}];c[u]===p?x=u==="x"?z:k:x=u==="x"?k:z}else{const z=[{x:f.x,y:h.y}],k=[{x:h.x,y:f.y}];if(u==="x"?x=c.x===p?k:z:x=c.y===p?z:k,t===s){const A=Math.abs(e[u]-n[u]);if(A<=i){const O=Math.min(i-1,i-A);c[u]===p?y[u]=(f[u]>e[u]?-1:1)*O:g[u]=(h[u]>n[u]?-1:1)*O}}if(t!==s){const A=u==="x"?"y":"x",O=c[u]===l[A],j=f[A]>h[A],T=f[A]<h[A];(c[u]===1&&(!O&&j||O&&T)||c[u]!==1&&(!O&&T||O&&j))&&(x=u==="x"?z:k)}const $={x:f.x+y.x,y:f.y+y.y},P={x:h.x+g.x,y:h.y+g.y},F=Math.max(Math.abs($.x-x[0].x),Math.abs(P.x-x[0].x)),M=Math.max(Math.abs($.y-x[0].y),Math.abs(P.y-x[0].y));F>=M?(b=($.x+P.x)/2,v=x[0].y):(b=x[0].x,v=($.y+P.y)/2)}return[[e,{x:f.x+y.x,y:f.y+y.y},...x,{x:h.x+g.x,y:h.y+g.y},n],b,v,m,w]}function Of(e,t,n,s){const o=Math.min(sr(e,t)/2,sr(t,n)/2,s),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const f=e.x<n.x?-1:1,h=e.y<n.y?1:-1;return`L ${i+o*f},${a}Q ${i},${a} ${i},${a+o*h}`}const c=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${a+o*l}Q ${i},${a} ${i+o*c},${a}`}function dn({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:s,targetY:o,targetPosition:i=W.Top,borderRadius:a=5,centerX:c,centerY:l,offset:f=20,stepPosition:h=.5}){const[d,u,p,x,b]=Rf({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:o},targetPosition:i,center:{x:c,y:l},offset:f,stepPosition:h});return[d.reduce((y,g,m)=>{let w="";return m>0&&m<d.length-1?w=Of(d[m-1],g,d[m+1],a):w=`${m===0?"M":"L"}${g.x} ${g.y}`,y+=w,y},""),u,p,x,b]}function rr(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Hf(e){var d;const{sourceNode:t,targetNode:n}=e;if(!rr(t)||!rr(n))return null;const s=t.internals.handleBounds||or(t.handles),o=n.internals.handleBounds||or(n.handles),i=ir((s==null?void 0:s.source)??[],e.sourceHandle),a=ir(e.connectionMode===Je.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!a)return(d=e.onError)==null||d.call(e,"008",ge.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(i==null?void 0:i.position)||W.Bottom,l=(a==null?void 0:a.position)||W.Top,f=He(t,i,c),h=He(n,a,l);return{sourceX:f.x,sourceY:f.y,targetX:h.x,targetY:h.y,sourcePosition:c,targetPosition:l}}function or(e){if(!e)return null;const t=[],n=[];for(const s of e)s.width=s.width??1,s.height=s.height??1,s.type==="source"?t.push(s):s.type==="target"&&n.push(s);return{source:t,target:n}}function He(e,t,n=W.Left,s=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:c}=t??ke(e);if(s)return{x:o+a/2,y:i+c/2};switch((t==null?void 0:t.position)??n){case W.Top:return{x:o+a/2,y:i};case W.Right:return{x:o+a,y:i+c/2};case W.Bottom:return{x:o+a/2,y:i+c};case W.Left:return{x:o,y:i+c/2}}}function ir(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Jn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function Ff(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:o}){const i=new Set;return e.reduce((a,c)=>([c.markerStart||s,c.markerEnd||o].forEach(l=>{if(l&&typeof l=="object"){const f=Jn(l,t);i.has(f)||(a.push({id:f,color:l.color||n,...l}),i.add(f))}}),a),[]).sort((a,c)=>a.id.localeCompare(c.id))}const Zo=1e3,Bf=10,Cs={nodeOrigin:[0,0],nodeExtent:yt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Vf={...Cs,checkEquality:!0};function zs(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function Yf(e,t,n){const s=zs(Cs,n);for(const o of e.values())if(o.parentId)Ss(o,e,t,s);else{const i=kt(o,s.nodeOrigin),a=nt(o.extent)?o.extent:s.nodeExtent,c=Oe(i,a,ke(o));o.internals.positionAbsolute=c}}function Gf(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],s=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&s.push(i)}return{source:n,target:s}}function ks(e){return e==="manual"}function es(e,t,n,s={}){var f,h;const o=zs(Vf,s),i={i:0},a=new Map(t),c=o!=null&&o.elevateNodesOnSelect&&!ks(o.zIndexMode)?Zo:0;let l=e.length>0;t.clear(),n.clear();for(const d of e){let u=a.get(d.id);if(o.checkEquality&&d===(u==null?void 0:u.internals.userNode))t.set(d.id,u);else{const p=kt(d,o.nodeOrigin),x=nt(d.extent)?d.extent:o.nodeExtent,b=Oe(p,x,ke(d));u={...o.defaults,...d,measured:{width:(f=d.measured)==null?void 0:f.width,height:(h=d.measured)==null?void 0:h.height},internals:{positionAbsolute:b,handleBounds:Gf(d,u),z:Qo(d,c,o.zIndexMode),userNode:d}},t.set(d.id,u)}(u.measured===void 0||u.measured.width===void 0||u.measured.height===void 0)&&!u.hidden&&(l=!1),d.parentId&&Ss(u,t,n,s,i)}return l}function Wf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Ss(e,t,n,s,o){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:c,zIndexMode:l}=zs(Cs,s),f=e.parentId,h=t.get(f);if(!h){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Wf(e,n),o&&!h.parentId&&h.internals.rootParentIndex===void 0&&l==="auto"&&(h.internals.rootParentIndex=++o.i,h.internals.z=h.internals.z+o.i*Bf),o&&h.internals.rootParentIndex!==void 0&&(o.i=h.internals.rootParentIndex);const d=i&&!ks(l)?Zo:0,{x:u,y:p,z:x}=Xf(e,h,a,c,d,l),{positionAbsolute:b}=e.internals,v=u!==b.x||p!==b.y;(v||x!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:u,y:p}:b,z:x}})}function Qo(e,t,n){const s=ue(e.zIndex)?e.zIndex:0;return ks(n)?s:s+(e.selected?t:0)}function Xf(e,t,n,s,o,i){const{x:a,y:c}=t.internals.positionAbsolute,l=ke(e),f=kt(e,n),h=nt(e.extent)?Oe(f,e.extent,l):f;let d=Oe({x:a+h.x,y:c+h.y},s,l);e.extent==="parent"&&(d=Oo(d,l,t));const u=Qo(e,o,i),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=u?p+1:u}}function Es(e,t,n,s=[0,0]){var a;const o=[],i=new Map;for(const c of e){const l=t.get(c.parentId);if(!l)continue;const f=((a=i.get(c.parentId))==null?void 0:a.expandedRect)??tt(l),h=Fo(f,c.rect);i.set(c.parentId,{expandedRect:h,parent:l})}return i.size>0&&i.forEach(({expandedRect:c,parent:l},f)=>{var m;const h=l.internals.positionAbsolute,d=ke(l),u=l.origin??s,p=c.x<h.x?Math.round(Math.abs(h.x-c.x)):0,x=c.y<h.y?Math.round(Math.abs(h.y-c.y)):0,b=Math.max(d.width,Math.round(c.width)),v=Math.max(d.height,Math.round(c.height)),y=(b-d.width)*u[0],g=(v-d.height)*u[1];(p>0||x>0||y||g)&&(o.push({id:f,type:"position",position:{x:l.position.x-p+y,y:l.position.y-x+g}}),(m=n.get(f))==null||m.forEach(w=>{e.some(C=>C.id===w.id)||o.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+x}})})),(d.width<c.width||d.height<c.height||p||x)&&o.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:b+(p?u[0]*p-y:0),height:v+(x?u[1]*x-g:0)}})}),o}function qf(e,t,n,s,o,i,a){const c=s==null?void 0:s.querySelector(".xyflow__viewport");let l=!1;if(!c)return{changes:[],updatedInternals:l};const f=[],h=window.getComputedStyle(c),{m22:d}=new window.DOMMatrixReadOnly(h.transform),u=[];for(const p of e.values()){const x=t.get(p.id);if(!x)continue;if(x.hidden){t.set(x.id,{...x,internals:{...x.internals,handleBounds:void 0}}),l=!0;continue}const b=js(p.nodeElement),v=x.measured.width!==b.width||x.measured.height!==b.height;if(!!(b.width&&b.height&&(v||!x.internals.handleBounds||p.force))){const g=p.nodeElement.getBoundingClientRect(),m=nt(x.extent)?x.extent:i;let{positionAbsolute:w}=x.internals;x.parentId&&x.extent==="parent"?w=Oo(w,b,t.get(x.parentId)):m&&(w=Oe(w,m,b));const C={...x,measured:b,internals:{...x.internals,positionAbsolute:w,handleBounds:{source:er("source",p.nodeElement,g,d,x.id),target:er("target",p.nodeElement,g,d,x.id)}}};t.set(x.id,C),x.parentId&&Ss(C,t,n,{nodeOrigin:o,zIndexMode:a}),l=!0,v&&(f.push({id:x.id,type:"dimensions",dimensions:b}),x.expandParent&&x.parentId&&u.push({id:x.id,parentId:x.parentId,rect:tt(C,o)}))}}if(u.length>0){const p=Es(u,t,n,o);f.push(...p)}return{changes:f,updatedInternals:l}}async function Uf({delta:e,panZoom:t,transform:n,translateExtent:s,width:o,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],s),c=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(c)}function ar(e,t,n,s,o,i){let a=o;const c=s.get(a)||new Map;s.set(a,c.set(n,t)),a=`${o}-${e}`;const l=s.get(a)||new Map;if(s.set(a,l.set(n,t)),i){a=`${o}-${e}-${i}`;const f=s.get(a)||new Map;s.set(a,f.set(n,t))}}function Jo(e,t,n){e.clear(),t.clear();for(const s of n){const{source:o,target:i,sourceHandle:a=null,targetHandle:c=null}=s,l={edgeId:s.id,source:o,target:i,sourceHandle:a,targetHandle:c},f=`${o}-${a}--${i}-${c}`,h=`${i}-${c}--${o}-${a}`;ar("source",l,h,e,o,a),ar("target",l,f,e,i,c),t.set(s.id,s)}}function ei(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ei(n,t):!1}function cr(e,t,n){var o;let s=e;do{if((o=s==null?void 0:s.matches)!=null&&o.call(s,t))return!0;if(s===n)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function Kf(e,t,n,s){const o=new Map;for(const[i,a]of e)if((a.selected||a.id===s)&&(!a.parentId||!ei(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const c=e.get(i);c&&o.set(i,{id:i,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return o}function An({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){var a,c,l;const o=[];for(const[f,h]of t){const d=(a=n.get(f))==null?void 0:a.internals.userNode;d&&o.push({...d,position:h.position,dragging:s})}if(!e)return[o[0],o];const i=(c=n.get(e))==null?void 0:c.internals.userNode;return[i?{...i,position:((l=t.get(e))==null?void 0:l.position)||i.position,dragging:s}:o[0],o]}function Zf({dragItems:e,snapGrid:t,x:n,y:s}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:s-o.distance.y},a=Et(i,t);return{x:a.x-i.x,y:a.y-i.y}}function Qf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:o}){let i={x:null,y:null},a=0,c=new Map,l=!1,f={x:0,y:0},h=null,d=!1,u=null,p=!1,x=!1,b=null;function v({noDragClassName:g,handleSelector:m,domNode:w,isSelectable:C,nodeId:z,nodeClickDistance:k=0}){u=ae(w);function $({x:A,y:O}){const{nodeLookup:j,nodeExtent:T,snapGrid:S,snapToGrid:I,nodeOrigin:E,onNodeDrag:_,onSelectionDrag:L,onError:R,updateNodePositions:D}=t();i={x:A,y:O};let V=!1;const G=c.size>1,X=G&&T?Qn(St(c)):null,K=G&&I?Zf({dragItems:c,snapGrid:S,x:A,y:O}):null;for(const[B,H]of c){if(!j.has(B))continue;let Y={x:A-H.distance.x,y:O-H.distance.y};I&&(Y=K?{x:Math.round(Y.x+K.x),y:Math.round(Y.y+K.y)}:Et(Y,S));let q=null;if(G&&T&&!H.extent&&X){const{positionAbsolute:U}=H.internals,ee=U.x-X.x+T[0][0],ne=U.x+H.measured.width-X.x2+T[1][0],te=U.y-X.y+T[0][1],ie=U.y+H.measured.height-X.y2+T[1][1];q=[[ee,te],[ne,ie]]}const{position:Q,positionAbsolute:Z}=Ro({nodeId:B,nextPosition:Y,nodeLookup:j,nodeExtent:q||T,nodeOrigin:E,onError:R});V=V||H.position.x!==Q.x||H.position.y!==Q.y,H.position=Q,H.internals.positionAbsolute=Z}if(x=x||V,!!V&&(D(c,!0),b&&(s||_||!z&&L))){const[B,H]=An({nodeId:z,dragItems:c,nodeLookup:j});s==null||s(b,c,B,H),_==null||_(b,B,H),z||L==null||L(b,H)}}async function P(){if(!h)return;const{transform:A,panBy:O,autoPanSpeed:j,autoPanOnNodeDrag:T}=t();if(!T){l=!1,cancelAnimationFrame(a);return}const[S,I]=Ho(f,h,j);(S!==0||I!==0)&&(i.x=(i.x??0)-S/A[2],i.y=(i.y??0)-I/A[2],await O({x:S,y:I})&&$(i)),a=requestAnimationFrame(P)}function F(A){var G;const{nodeLookup:O,multiSelectionActive:j,nodesDraggable:T,transform:S,snapGrid:I,snapToGrid:E,selectNodesOnDrag:_,onNodeDragStart:L,onSelectionDragStart:R,unselectNodesAndEdges:D}=t();d=!0,(!_||!C)&&!j&&z&&((G=O.get(z))!=null&&G.selected||D()),C&&_&&z&&(e==null||e(z));const V=mt(A.sourceEvent,{transform:S,snapGrid:I,snapToGrid:E,containerBounds:h});if(i=V,c=Kf(O,T,V,z),c.size>0&&(n||L||!z&&R)){const[X,K]=An({nodeId:z,dragItems:c,nodeLookup:O});n==null||n(A.sourceEvent,c,X,K),L==null||L(A.sourceEvent,X,K),z||R==null||R(A.sourceEvent,K)}}const M=jo().clickDistance(k).on("start",A=>{const{domNode:O,nodeDragThreshold:j,transform:T,snapGrid:S,snapToGrid:I}=t();h=(O==null?void 0:O.getBoundingClientRect())||null,p=!1,x=!1,b=A.sourceEvent,j===0&&F(A),i=mt(A.sourceEvent,{transform:T,snapGrid:S,snapToGrid:I,containerBounds:h}),f=fe(A.sourceEvent,h)}).on("drag",A=>{const{autoPanOnNodeDrag:O,transform:j,snapGrid:T,snapToGrid:S,nodeDragThreshold:I,nodeLookup:E}=t(),_=mt(A.sourceEvent,{transform:j,snapGrid:T,snapToGrid:S,containerBounds:h});if(b=A.sourceEvent,(A.sourceEvent.type==="touchmove"&&A.sourceEvent.touches.length>1||z&&!E.has(z))&&(p=!0),!p){if(!l&&O&&d&&(l=!0,P()),!d){const L=fe(A.sourceEvent,h),R=L.x-f.x,D=L.y-f.y;Math.sqrt(R*R+D*D)>I&&F(A)}(i.x!==_.xSnapped||i.y!==_.ySnapped)&&c&&d&&(f=fe(A.sourceEvent,h),$(_))}}).on("end",A=>{if(!(!d||p)&&(l=!1,d=!1,cancelAnimationFrame(a),c.size>0)){const{nodeLookup:O,updateNodePositions:j,onNodeDragStop:T,onSelectionDragStop:S}=t();if(x&&(j(c,!1),x=!1),o||T||!z&&S){const[I,E]=An({nodeId:z,dragItems:c,nodeLookup:O,dragging:!1});o==null||o(A.sourceEvent,c,I,E),T==null||T(A.sourceEvent,I,E),z||S==null||S(A.sourceEvent,E)}}}).filter(A=>{const O=A.target;return!A.button&&(!g||!cr(O,`.${g}`,w))&&(!m||cr(O,m,w))});u.call(M)}function y(){u==null||u.on(".drag",null)}return{update:v,destroy:y}}function Jf(e,t,n){const s=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())vt(o,tt(i))>0&&s.push(i);return s}const eh=250;function th(e,t,n,s){var c,l;let o=[],i=1/0;const a=Jf(e,n,t+eh);for(const f of a){const h=[...((c=f.internals.handleBounds)==null?void 0:c.source)??[],...((l=f.internals.handleBounds)==null?void 0:l.target)??[]];for(const d of h){if(s.nodeId===d.nodeId&&s.type===d.type&&s.id===d.id)continue;const{x:u,y:p}=He(f,d,d.position,!0),x=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(p-e.y,2));x>t||(x<i?(o=[{...d,x:u,y:p}],i=x):x===i&&o.push({...d,x:u,y:p}))}}if(!o.length)return null;if(o.length>1){const f=s.type==="source"?"target":"source";return o.find(h=>h.type===f)??o[0]}return o[0]}function ti(e,t,n,s,o,i=!1){var f,h,d;const a=s.get(e);if(!a)return null;const c=o==="strict"?(f=a.internals.handleBounds)==null?void 0:f[t]:[...((h=a.internals.handleBounds)==null?void 0:h.source)??[],...((d=a.internals.handleBounds)==null?void 0:d.target)??[]],l=(n?c==null?void 0:c.find(u=>u.id===n):c==null?void 0:c[0])??null;return l&&i?{...l,...He(a,l,l.position,!0)}:l}function ni(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function nh(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const si=()=>!0;function sh(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:o,edgeUpdaterType:i,isTarget:a,domNode:c,nodeLookup:l,lib:f,autoPanOnConnect:h,flowId:d,panBy:u,cancelConnection:p,onConnectStart:x,onConnect:b,onConnectEnd:v,isValidConnection:y=si,onReconnectEnd:g,updateConnection:m,getTransform:w,getFromHandle:C,autoPanSpeed:z,dragThreshold:k=1,handleDomNode:$}){const P=Yo(e.target);let F=0,M;const{x:A,y:O}=fe(e),j=ni(i,$),T=c==null?void 0:c.getBoundingClientRect();let S=!1;if(!T||!j)return;const I=ti(o,j,s,l,t);if(!I)return;let E=fe(e,T),_=!1,L=null,R=!1,D=null;function V(){if(!h||!T)return;const[Q,Z]=Ho(E,T,z);u({x:Q,y:Z}),F=requestAnimationFrame(V)}const G={...I,nodeId:o,type:j,position:I.position},X=l.get(o);let B={inProgress:!0,isValid:null,from:He(X,G,W.Left,!0),fromHandle:G,fromPosition:G.position,fromNode:X,to:E,toHandle:null,toPosition:Ks[G.position],toNode:null,pointer:E};function H(){S=!0,m(B),x==null||x(e,{nodeId:o,handleId:s,handleType:j})}k===0&&H();function Y(Q){if(!S){const{x:ie,y:Se}=fe(Q),Ne=ie-A,$e=Se-O;if(!(Ne*Ne+$e*$e>k*k))return;H()}if(!C()||!G){q(Q);return}const Z=w();E=fe(Q,T),M=th(_t(E,Z,!1,[1,1]),n,l,G),_||(V(),_=!0);const U=ri(Q,{handle:M,connectionMode:t,fromNodeId:o,fromHandleId:s,fromType:a?"target":"source",isValidConnection:y,doc:P,lib:f,flowId:d,nodeLookup:l});D=U.handleDomNode,L=U.connection,R=nh(!!M,U.isValid);const ee=l.get(o),ne=ee?He(ee,G,W.Left,!0):B.from,te={...B,from:ne,isValid:R,to:U.toHandle&&R?ln({x:U.toHandle.x,y:U.toHandle.y},Z):E,toHandle:U.toHandle,toPosition:R&&U.toHandle?U.toHandle.position:Ks[G.position],toNode:U.toHandle?l.get(U.toHandle.nodeId):null,pointer:E};m(te),B=te}function q(Q){if(!("touches"in Q&&Q.touches.length>0)){if(S){(M||D)&&L&&R&&(b==null||b(L));const{inProgress:Z,...U}=B,ee={...U,toPosition:B.toHandle?B.toPosition:null};v==null||v(Q,ee),i&&(g==null||g(Q,ee))}p(),cancelAnimationFrame(F),_=!1,R=!1,L=null,D=null,P.removeEventListener("mousemove",Y),P.removeEventListener("mouseup",q),P.removeEventListener("touchmove",Y),P.removeEventListener("touchend",q)}}P.addEventListener("mousemove",Y),P.addEventListener("mouseup",q),P.addEventListener("touchmove",Y),P.addEventListener("touchend",q)}function ri(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:i,doc:a,lib:c,flowId:l,isValidConnection:f=si,nodeLookup:h}){const d=i==="target",u=t?a.querySelector(`.${c}-flow__handle[data-id="${l}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:p,y:x}=fe(e),b=a.elementFromPoint(p,x),v=b!=null&&b.classList.contains(`${c}-flow__handle`)?b:u,y={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const g=ni(void 0,v),m=v.getAttribute("data-nodeid"),w=v.getAttribute("data-handleid"),C=v.classList.contains("connectable"),z=v.classList.contains("connectableend");if(!m||!g)return y;const k={source:d?m:s,sourceHandle:d?w:o,target:d?s:m,targetHandle:d?o:w};y.connection=k;const P=C&&z&&(n===Je.Strict?d&&g==="source"||!d&&g==="target":m!==s||w!==o);y.isValid=P&&f(k),y.toHandle=ti(m,g,w,h,n,!0)}return y}const ts={onPointerDown:sh,isValid:ri};function rh({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const o=ae(e);function i({translateExtent:c,width:l,height:f,zoomStep:h=1,pannable:d=!0,zoomable:u=!0,inversePan:p=!1}){const x=m=>{if(m.sourceEvent.type!=="wheel"||!t)return;const w=n(),C=m.sourceEvent.ctrlKey&&Nt()?10:1,z=-m.sourceEvent.deltaY*(m.sourceEvent.deltaMode===1?.05:m.sourceEvent.deltaMode?1:.002)*h,k=w[2]*Math.pow(2,z*C);t.scaleTo(k)};let b=[0,0];const v=m=>{(m.sourceEvent.type==="mousedown"||m.sourceEvent.type==="touchstart")&&(b=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY])},y=m=>{const w=n();if(m.sourceEvent.type!=="mousemove"&&m.sourceEvent.type!=="touchmove"||!t)return;const C=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY],z=[C[0]-b[0],C[1]-b[1]];b=C;const k=s()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),$={x:w[0]-z[0]*k,y:w[1]-z[1]*k},P=[[0,0],[l,f]];t.setViewportConstrained({x:$.x,y:$.y,zoom:w[2]},P,c)},g=To().on("start",v).on("zoom",d?y:null).on("zoom.wheel",u?x:null);o.call(g,{})}function a(){o.on("zoom",null)}return{update:i,destroy:a,pointer:le}}const jn=e=>({x:e.x,y:e.y,zoom:e.k}),$n=({x:e,y:t,zoom:n})=>wn.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),oi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),oh=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Pn=(e,t=0,n=oh,s=()=>{})=>{const o=typeof t=="number"&&t>0;return o||s(),o?e.transition().duration(t).ease(n).on("end",s):e},ii=e=>{const t=e.ctrlKey&&Nt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function ih({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:f}){return h=>{if(Xe(h,t))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(h.ctrlKey&&a){const v=le(h),y=ii(h),g=d*Math.pow(2,y);s.scaleTo(n,g,v,h);return}const u=h.deltaMode===1?20:1;let p=o===De.Vertical?0:h.deltaX*u,x=o===De.Horizontal?0:h.deltaY*u;!Nt()&&h.shiftKey&&o!==De.Vertical&&(p=h.deltaY*u,x=0),s.translateBy(n,-(p/d)*i,-(x/d)*i,{internal:!0});const b=jn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l==null||l(h,b),e.panScrollTimeout=setTimeout(()=>{f==null||f(h,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(h,b))}}function ah({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,o){const i=s.type==="wheel",a=!t&&i&&!s.ctrlKey,c=Xe(s,e);if(s.ctrlKey&&i&&c&&s.preventDefault(),a||c)return null;s.preventDefault(),n.call(this,s,o)}}function ch({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{var i,a,c;if((i=s.sourceEvent)!=null&&i.internal)return;const o=jn(s.transform);e.mouseButton=((a=s.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((c=s.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(s.sourceEvent,o))}}function lh({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:o}){return i=>{var a,c;e.usedRightMouseButton=!!(n&&oi(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||s([i.transform.x,i.transform.y,i.transform.k]),o&&!((c=i.sourceEvent)!=null&&c.internal)&&(o==null||o(i.sourceEvent,jn(i.transform)))}}function dh({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:o,onPaneContextMenu:i}){return a=>{var c;if(!((c=a.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,i&&oi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,s(!1),o)){const l=jn(a.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(a.sourceEvent,l)},n?150:0)}}}function uh({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:f,connectionInProgress:h}){return d=>{var v;const u=e||t,p=n&&d.ctrlKey,x=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${f}-flow__node`)||Xe(d,`${f}-flow__edge`)))return!0;if(!s&&!u&&!o&&!i&&!n||a||h&&!x||Xe(d,c)&&x||Xe(d,l)&&(!x||o&&x&&!e)||!n&&d.ctrlKey&&x)return!1;if(!n&&d.type==="touchstart"&&((v=d.touches)==null?void 0:v.length)>1)return d.preventDefault(),!1;if(!u&&!o&&!p&&x||!s&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(s)&&!s.includes(d.button)&&d.type==="mousedown")return!1;const b=Array.isArray(s)&&s.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||x)&&b}}function fh({domNode:e,minZoom:t,maxZoom:n,translateExtent:s,viewport:o,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:c,onDraggingChange:l}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect(),d=To().scaleExtent([t,n]).translateExtent(s),u=ae(e).call(d);g({x:o.x,y:o.y,zoom:et(o.zoom,t,n)},[[0,0],[h.width,h.height]],s);const p=u.on("wheel.zoom"),x=u.on("dblclick.zoom");d.wheelDelta(ii);function b(M,A){return u?new Promise(O=>{d==null||d.interpolate((A==null?void 0:A.interpolate)==="linear"?Mn:qt).transform(Pn(u,A==null?void 0:A.duration,A==null?void 0:A.ease,()=>O(!0)),M)}):Promise.resolve(!1)}function v({noWheelClassName:M,noPanClassName:A,onPaneContextMenu:O,userSelectionActive:j,panOnScroll:T,panOnDrag:S,panOnScrollMode:I,panOnScrollSpeed:E,preventScrolling:_,zoomOnPinch:L,zoomOnScroll:R,zoomOnDoubleClick:D,zoomActivationKeyPressed:V,lib:G,onTransformChange:X,connectionInProgress:K,paneClickDistance:B,selectionOnDrag:H}){j&&!f.isZoomingOrPanning&&y();const Y=T&&!V&&!j;d.clickDistance(H?1/0:!ue(B)||B<0?0:B);const q=Y?ih({zoomPanValues:f,noWheelClassName:M,d3Selection:u,d3Zoom:d,panOnScrollMode:I,panOnScrollSpeed:E,zoomOnPinch:L,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:c}):ah({noWheelClassName:M,preventScrolling:_,d3ZoomHandler:p});if(u.on("wheel.zoom",q,{passive:!1}),!j){const Z=ch({zoomPanValues:f,onDraggingChange:l,onPanZoomStart:a});d.on("start",Z);const U=lh({zoomPanValues:f,panOnDrag:S,onPaneContextMenu:!!O,onPanZoom:i,onTransformChange:X});d.on("zoom",U);const ee=dh({zoomPanValues:f,panOnDrag:S,panOnScroll:T,onPaneContextMenu:O,onPanZoomEnd:c,onDraggingChange:l});d.on("end",ee)}const Q=uh({zoomActivationKeyPressed:V,panOnDrag:S,zoomOnScroll:R,panOnScroll:T,zoomOnDoubleClick:D,zoomOnPinch:L,userSelectionActive:j,noPanClassName:A,noWheelClassName:M,lib:G,connectionInProgress:K});d.filter(Q),D?u.on("dblclick.zoom",x):u.on("dblclick.zoom",null)}function y(){d.on("zoom",null)}async function g(M,A,O){const j=$n(M),T=d==null?void 0:d.constrain()(j,A,O);return T&&await b(T),new Promise(S=>S(T))}async function m(M,A){const O=$n(M);return await b(O,A),new Promise(j=>j(O))}function w(M){if(u){const A=$n(M),O=u.property("__zoom");(O.k!==M.zoom||O.x!==M.x||O.y!==M.y)&&(d==null||d.transform(u,A,null,{sync:!0}))}}function C(){const M=u?Io(u.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}function z(M,A){return u?new Promise(O=>{d==null||d.interpolate((A==null?void 0:A.interpolate)==="linear"?Mn:qt).scaleTo(Pn(u,A==null?void 0:A.duration,A==null?void 0:A.ease,()=>O(!0)),M)}):Promise.resolve(!1)}function k(M,A){return u?new Promise(O=>{d==null||d.interpolate((A==null?void 0:A.interpolate)==="linear"?Mn:qt).scaleBy(Pn(u,A==null?void 0:A.duration,A==null?void 0:A.ease,()=>O(!0)),M)}):Promise.resolve(!1)}function $(M){d==null||d.scaleExtent(M)}function P(M){d==null||d.translateExtent(M)}function F(M){const A=!ue(M)||M<0?0:M;d==null||d.clickDistance(A)}return{update:v,destroy:y,setViewport:m,setViewportConstrained:g,getViewport:C,scaleTo:z,scaleBy:k,setScaleExtent:$,setTranslateExtent:P,syncViewport:w,setClickDistance:F}}var st;(function(e){e.Line="line",e.Handle="handle"})(st||(st={}));function hh({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:o,affectsY:i}){const a=e-t,c=n-s,l=[a>0?1:a<0?-1:0,c>0?1:c<0?-1:0];return a&&o&&(l[0]=l[0]*-1),c&&i&&(l[1]=l[1]*-1),l}function lr(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),s=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:s,affectsY:o}}function Ee(e,t){return Math.max(0,t-e)}function _e(e,t){return Math.max(0,e-t)}function Dt(e,t,n){return Math.max(0,t-e,e-n)}function dr(e,t){return e?!t:t}function ph(e,t,n,s,o,i,a,c){let{affectsX:l,affectsY:f}=t;const{isHorizontal:h,isVertical:d}=t,u=h&&d,{xSnapped:p,ySnapped:x}=n,{minWidth:b,maxWidth:v,minHeight:y,maxHeight:g}=s,{x:m,y:w,width:C,height:z,aspectRatio:k}=e;let $=Math.floor(h?p-e.pointerX:0),P=Math.floor(d?x-e.pointerY:0);const F=C+(l?-$:$),M=z+(f?-P:P),A=-i[0]*C,O=-i[1]*z;let j=Dt(F,b,v),T=Dt(M,y,g);if(a){let E=0,_=0;l&&$<0?E=Ee(m+$+A,a[0][0]):!l&&$>0&&(E=_e(m+F+A,a[1][0])),f&&P<0?_=Ee(w+P+O,a[0][1]):!f&&P>0&&(_=_e(w+M+O,a[1][1])),j=Math.max(j,E),T=Math.max(T,_)}if(c){let E=0,_=0;l&&$>0?E=_e(m+$,c[0][0]):!l&&$<0&&(E=Ee(m+F,c[1][0])),f&&P>0?_=_e(w+P,c[0][1]):!f&&P<0&&(_=Ee(w+M,c[1][1])),j=Math.max(j,E),T=Math.max(T,_)}if(o){if(h){const E=Dt(F/k,y,g)*k;if(j=Math.max(j,E),a){let _=0;!l&&!f||l&&!f&&u?_=_e(w+O+F/k,a[1][1])*k:_=Ee(w+O+(l?$:-$)/k,a[0][1])*k,j=Math.max(j,_)}if(c){let _=0;!l&&!f||l&&!f&&u?_=Ee(w+F/k,c[1][1])*k:_=_e(w+(l?$:-$)/k,c[0][1])*k,j=Math.max(j,_)}}if(d){const E=Dt(M*k,b,v)/k;if(T=Math.max(T,E),a){let _=0;!l&&!f||f&&!l&&u?_=_e(m+M*k+A,a[1][0])/k:_=Ee(m+(f?P:-P)*k+A,a[0][0])/k,T=Math.max(T,_)}if(c){let _=0;!l&&!f||f&&!l&&u?_=Ee(m+M*k,c[1][0])/k:_=_e(m+(f?P:-P)*k,c[0][0])/k,T=Math.max(T,_)}}}P=P+(P<0?T:-T),$=$+($<0?j:-j),o&&(u?F>M*k?P=(dr(l,f)?-$:$)/k:$=(dr(l,f)?-P:P)*k:h?(P=$/k,f=l):($=P*k,l=f));const S=l?m+$:m,I=f?w+P:w;return{width:C+(l?-$:$),height:z+(f?-P:P),x:i[0]*$*(l?-1:1)+S,y:i[1]*P*(f?-1:1)+I}}const ai={width:0,height:0,x:0,y:0},xh={...ai,pointerX:0,pointerY:0,aspectRatio:1};function mh(e){return[[0,0],[e.measured.width,e.measured.height]]}function gh(e,t,n){const s=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,c=n[0]*i,l=n[1]*a;return[[s-c,o-l],[s+i-c,o+a-l]]}function bh({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:o}){const i=ae(e);let a={controlDirection:lr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:f,boundaries:h,keepAspectRatio:d,resizeDirection:u,onResizeStart:p,onResize:x,onResizeEnd:b,shouldResize:v}){let y={...ai},g={...xh};a={boundaries:h,resizeDirection:u,keepAspectRatio:d,controlDirection:lr(f)};let m,w=null,C=[],z,k,$,P=!1;const F=jo().on("start",M=>{const{nodeLookup:A,transform:O,snapGrid:j,snapToGrid:T,nodeOrigin:S,paneDomNode:I}=n();if(m=A.get(t),!m)return;w=(I==null?void 0:I.getBoundingClientRect())??null;const{xSnapped:E,ySnapped:_}=mt(M.sourceEvent,{transform:O,snapGrid:j,snapToGrid:T,containerBounds:w});y={width:m.measured.width??0,height:m.measured.height??0,x:m.position.x??0,y:m.position.y??0},g={...y,pointerX:E,pointerY:_,aspectRatio:y.width/y.height},z=void 0,m.parentId&&(m.extent==="parent"||m.expandParent)&&(z=A.get(m.parentId),k=z&&m.extent==="parent"?mh(z):void 0),C=[],$=void 0;for(const[L,R]of A)if(R.parentId===t&&(C.push({id:L,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const D=gh(R,m,R.origin??S);$?$=[[Math.min(D[0][0],$[0][0]),Math.min(D[0][1],$[0][1])],[Math.max(D[1][0],$[1][0]),Math.max(D[1][1],$[1][1])]]:$=D}p==null||p(M,{...y})}).on("drag",M=>{const{transform:A,snapGrid:O,snapToGrid:j,nodeOrigin:T}=n(),S=mt(M.sourceEvent,{transform:A,snapGrid:O,snapToGrid:j,containerBounds:w}),I=[];if(!m)return;const{x:E,y:_,width:L,height:R}=y,D={},V=m.origin??T,{width:G,height:X,x:K,y:B}=ph(g,a.controlDirection,S,a.boundaries,a.keepAspectRatio,V,k,$),H=G!==L,Y=X!==R,q=K!==E&&H,Q=B!==_&&Y;if(!q&&!Q&&!H&&!Y)return;if((q||Q||V[0]===1||V[1]===1)&&(D.x=q?K:y.x,D.y=Q?B:y.y,y.x=D.x,y.y=D.y,C.length>0)){const ne=K-E,te=B-_;for(const ie of C)ie.position={x:ie.position.x-ne+V[0]*(G-L),y:ie.position.y-te+V[1]*(X-R)},I.push(ie)}if((H||Y)&&(D.width=H&&(!a.resizeDirection||a.resizeDirection==="horizontal")?G:y.width,D.height=Y&&(!a.resizeDirection||a.resizeDirection==="vertical")?X:y.height,y.width=D.width,y.height=D.height),z&&m.expandParent){const ne=V[0]*(D.width??0);D.x&&D.x<ne&&(y.x=ne,g.x=g.x-(D.x-ne));const te=V[1]*(D.height??0);D.y&&D.y<te&&(y.y=te,g.y=g.y-(D.y-te))}const Z=hh({width:y.width,prevWidth:L,height:y.height,prevHeight:R,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),U={...y,direction:Z};(v==null?void 0:v(M,U))!==!1&&(P=!0,x==null||x(M,U),s(D,I))}).on("end",M=>{P&&(b==null||b(M,{...y}),o==null||o({...y}),P=!1)});i.call(F)}function l(){i.on(".drag",null)}return{update:c,destroy:l}}var Dn={exports:{}},Ln={},Rn={exports:{}},On={};/**
52
- * @license React
53
- * use-sync-external-store-shim.production.js
54
- *
55
- * Copyright (c) Meta Platforms, Inc. and affiliates.
56
- *
57
- * This source code is licensed under the MIT license found in the
58
- * LICENSE file in the root directory of this source tree.
59
- */var ur;function yh(){if(ur)return On;ur=1;var e=Xr();function t(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,o=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function c(d,u){var p=u(),x=s({inst:{value:p,getSnapshot:u}}),b=x[0].inst,v=x[1];return i(function(){b.value=p,b.getSnapshot=u,l(b)&&v({inst:b})},[d,p,u]),o(function(){return l(b)&&v({inst:b}),d(function(){l(b)&&v({inst:b})})},[d]),a(p),p}function l(d){var u=d.getSnapshot;d=d.value;try{var p=u();return!n(d,p)}catch{return!0}}function f(d,u){return u()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return On.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,On}var fr;function wh(){return fr||(fr=1,Rn.exports=yh()),Rn.exports}/**
60
- * @license React
61
- * use-sync-external-store-shim/with-selector.production.js
62
- *
63
- * Copyright (c) Meta Platforms, Inc. and affiliates.
64
- *
65
- * This source code is licensed under the MIT license found in the
66
- * LICENSE file in the root directory of this source tree.
67
- */var hr;function vh(){if(hr)return Ln;hr=1;var e=Xr(),t=wh();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var s=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,c=e.useMemo,l=e.useDebugValue;return Ln.useSyncExternalStoreWithSelector=function(f,h,d,u,p){var x=i(null);if(x.current===null){var b={hasValue:!1,value:null};x.current=b}else b=x.current;x=c(function(){function y(z){if(!g){if(g=!0,m=z,z=u(z),p!==void 0&&b.hasValue){var k=b.value;if(p(k,z))return w=k}return w=z}if(k=w,s(m,z))return k;var $=u(z);return p!==void 0&&p(k,$)?(m=z,k):(m=z,w=$)}var g=!1,m,w,C=d===void 0?null:d;return[function(){return y(h())},C===null?void 0:function(){return y(C())}]},[h,d,u,p]);var v=o(f,x[0],x[1]);return a(function(){b.hasValue=!0,b.value=v},[v]),l(v),v},Ln}var pr;function Nh(){return pr||(pr=1,Dn.exports=vh()),Dn.exports}var jh=Nh();const Ch=lc(jh),zh={},xr=e=>{let t;const n=new Set,s=(h,d)=>{const u=typeof h=="function"?h(t):h;if(!Object.is(u,t)){const p=t;t=d??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(x=>x(t,p))}},o=()=>t,l={setState:s,getState:o,getInitialState:()=>f,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(zh?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},f=t=e(s,o,l);return l},kh=e=>e?xr(e):xr,{useDebugValue:Sh}=cs,{useSyncExternalStoreWithSelector:Eh}=Ch,_h=e=>e;function ci(e,t=_h,n){const s=Eh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Sh(s),s}const mr=(e,t)=>{const n=kh(e),s=(o,i=t)=>ci(n,o,i);return Object.assign(s,n),s},Mh=(e,t)=>e?mr(e,t):mr;function se(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,o]of e)if(!Object.is(o,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||!Object.is(e[s],t[s]))return!1;return!0}const Cn=N.createContext(null),Ih=Cn.Provider,li=ge.error001();function J(e,t){const n=N.useContext(Cn);if(n===null)throw new Error(li);return ci(n,e,t)}function re(){const e=N.useContext(Cn);if(e===null)throw new Error(li);return N.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const gr={display:"none"},Th={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},di="react-flow__node-desc",ui="react-flow__edge-desc",Ah="react-flow__aria-live",$h=e=>e.ariaLiveMessage,Ph=e=>e.ariaLabelConfig;function Dh({rfId:e}){const t=J($h);return r.jsx("div",{id:`${Ah}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Th,children:t})}function Lh({rfId:e,disableKeyboardA11y:t}){const n=J(Ph);return r.jsxs(r.Fragment,{children:[r.jsx("div",{id:`${di}-${e}`,style:gr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),r.jsx("div",{id:`${ui}-${e}`,style:gr,children:n["edge.a11yDescription.default"]}),!t&&r.jsx(Dh,{rfId:e})]})}const zn=N.forwardRef(({position:e="top-left",children:t,className:n,style:s,...o},i)=>{const a=`${e}`.split("-");return r.jsx("div",{className:oe(["react-flow__panel",n,...a]),style:s,ref:i,...o,children:t})});zn.displayName="Panel";function Rh({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:r.jsx(zn,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:r.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Oh=e=>{const t=[],n=[];for(const[,s]of e.nodeLookup)s.selected&&t.push(s.internals.userNode);for(const[,s]of e.edgeLookup)s.selected&&n.push(s);return{selectedNodes:t,selectedEdges:n}},Lt=e=>e.id;function Hh(e,t){return se(e.selectedNodes.map(Lt),t.selectedNodes.map(Lt))&&se(e.selectedEdges.map(Lt),t.selectedEdges.map(Lt))}function Fh({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:s}=J(Oh,Hh);return N.useEffect(()=>{const o={nodes:n,edges:s};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,s,e]),null}const Bh=e=>!!e.onSelectionChangeHandlers;function Vh({onSelectionChange:e}){const t=J(Bh);return e||t?r.jsx(Fh,{onSelectionChange:e}):null}const fi=[0,0],Yh={x:0,y:0,zoom:1},Gh=["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"],br=[...Gh,"rfId"],Wh=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}),yr={translateExtent:yt,nodeOrigin:fi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Xh(e){const{setNodes:t,setEdges:n,setMinZoom:s,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:a,reset:c,setDefaultNodesAndEdges:l}=J(Wh,se),f=re();N.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{h.current=yr,c()}),[]);const h=N.useRef(yr);return N.useEffect(()=>{for(const d of br){const u=e[d],p=h.current[d];u!==p&&(typeof e[d]>"u"||(d==="nodes"?t(u):d==="edges"?n(u):d==="minZoom"?s(u):d==="maxZoom"?o(u):d==="translateExtent"?i(u):d==="nodeExtent"?a(u):d==="ariaLabelConfig"?f.setState({ariaLabelConfig:Mf(u)}):d==="fitView"?f.setState({fitViewQueued:u}):d==="fitViewOptions"?f.setState({fitViewOptions:u}):f.setState({[d]:u})))}h.current=e},br.map(d=>e[d])),null}function wr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function qh(e){var s;const[t,n]=N.useState(e==="system"?null:e);return N.useEffect(()=>{if(e!=="system"){n(e);return}const o=wr(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(s=wr())!=null&&s.matches?"dark":"light"}const vr=typeof document<"u"?document:null;function jt(e=null,t={target:vr,actInsideInputWithModifier:!0}){const[n,s]=N.useState(!1),o=N.useRef(!1),i=N.useRef(new Set([])),[a,c]=N.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
68
- `).replace(`
69
-
70
- `,`
71
- +`).split(`
72
- `)),h=f.reduce((d,u)=>d.concat(...u),[]);return[f,h]}return[[],[]]},[e]);return N.useEffect(()=>{const l=(t==null?void 0:t.target)??vr,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const h=p=>{var v,y;if(o.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!o.current||o.current&&!f)&&Go(p))return!1;const b=jr(p.code,c);if(i.current.add(p[b]),Nr(a,i.current,!1)){const g=((y=(v=p.composedPath)==null?void 0:v.call(p))==null?void 0:y[0])||p.target,m=(g==null?void 0:g.nodeName)==="BUTTON"||(g==null?void 0:g.nodeName)==="A";t.preventDefault!==!1&&(o.current||!m)&&p.preventDefault(),s(!0)}},d=p=>{const x=jr(p.code,c);Nr(a,i.current,!0)?(s(!1),i.current.clear()):i.current.delete(p[x]),p.key==="Meta"&&i.current.clear(),o.current=!1},u=()=>{i.current.clear(),s(!1)};return l==null||l.addEventListener("keydown",h),l==null||l.addEventListener("keyup",d),window.addEventListener("blur",u),window.addEventListener("contextmenu",u),()=>{l==null||l.removeEventListener("keydown",h),l==null||l.removeEventListener("keyup",d),window.removeEventListener("blur",u),window.removeEventListener("contextmenu",u)}}},[e,s]),n}function Nr(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(o=>t.has(o)))}function jr(e,t){return t.includes(e)?"code":"key"}const Uh=()=>{const e=re();return N.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[s,o,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??s,y:t.y??o,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,s]=e.getState().transform;return{x:t,y:n,zoom:s}},setCenter:async(t,n,s)=>e.getState().setCenter(t,n,s),fitBounds:async(t,n)=>{const{width:s,height:o,minZoom:i,maxZoom:a,panZoom:c}=e.getState(),l=Ns(t,s,o,i,a,(n==null?void 0:n.padding)??.1);return c?(await c.setViewport(l,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:s,snapGrid:o,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;const{x:c,y:l}=a.getBoundingClientRect(),f={x:t.x-c,y:t.y-l},h=n.snapGrid??o,d=n.snapToGrid??i;return _t(f,s,d,h)},flowToScreenPosition:t=>{const{transform:n,domNode:s}=e.getState();if(!s)return t;const{x:o,y:i}=s.getBoundingClientRect(),a=ln(t,n);return{x:a.x+o,y:a.y+i}}}),[])};function hi(e,t){const n=[],s=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")s.set(i.id,[i]);else{const a=s.get(i.id);a?a.push(i):s.set(i.id,[i])}for(const i of t){const a=s.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const c={...i};for(const l of a)Kh(l,c);n.push(c)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Kh(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function pi(e,t){return hi(e,t)}function xi(e,t){return hi(e,t)}function Pe(e,t){return{id:e,type:"select",selected:t}}function qe(e,t=new Set,n=!1){const s=[];for(const[o,i]of e){const a=t.has(o);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),s.push(Pe(i.id,a)))}return s}function Cr({items:e=[],lookup:t}){var o;const n=[],s=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const c=t.get(a.id),l=((o=c==null?void 0:c.internals)==null?void 0:o.userNode)??c;l!==void 0&&l!==a&&n.push({id:a.id,item:a,type:"replace"}),l===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)s.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function zr(e){return{id:e.id,type:"remove"}}const kr=e=>wf(e),Zh=e=>Lo(e);function mi(e){return N.forwardRef(e)}const Qh=typeof window<"u"?N.useLayoutEffect:N.useEffect;function Sr(e){const[t,n]=N.useState(BigInt(0)),[s]=N.useState(()=>Jh(()=>n(o=>o+BigInt(1))));return Qh(()=>{const o=s.get();o.length&&(e(o),s.reset())},[t]),s}function Jh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const gi=N.createContext(null);function ep({children:e}){const t=re(),n=N.useCallback(c=>{const{nodes:l=[],setNodes:f,hasDefaultNodes:h,onNodesChange:d,nodeLookup:u,fitViewQueued:p,onNodesChangeMiddlewareMap:x}=t.getState();let b=l;for(const y of c)b=typeof y=="function"?y(b):y;let v=Cr({items:b,lookup:u});for(const y of x.values())v=y(v);h&&f(b),v.length>0?d==null||d(v):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:g,setNodes:m}=t.getState();y&&m(g)})},[]),s=Sr(n),o=N.useCallback(c=>{const{edges:l=[],setEdges:f,hasDefaultEdges:h,onEdgesChange:d,edgeLookup:u}=t.getState();let p=l;for(const x of c)p=typeof x=="function"?x(p):x;h?f(p):d&&d(Cr({items:p,lookup:u}))},[]),i=Sr(o),a=N.useMemo(()=>({nodeQueue:s,edgeQueue:i}),[]);return r.jsx(gi.Provider,{value:a,children:e})}function tp(){const e=N.useContext(gi);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const np=e=>!!e.panZoom;function _s(){const e=Uh(),t=re(),n=tp(),s=J(np),o=N.useMemo(()=>{const i=d=>t.getState().nodeLookup.get(d),a=d=>{n.nodeQueue.push(d)},c=d=>{n.edgeQueue.push(d)},l=d=>{var y,g;const{nodeLookup:u,nodeOrigin:p}=t.getState(),x=kr(d)?d:u.get(d.id),b=x.parentId?Vo(x.position,x.measured,x.parentId,u,p):x.position,v={...x,position:b,width:((y=x.measured)==null?void 0:y.width)??x.width,height:((g=x.measured)==null?void 0:g.height)??x.height};return tt(v)},f=(d,u,p={replace:!1})=>{a(x=>x.map(b=>{if(b.id===d){const v=typeof u=="function"?u(b):u;return p.replace&&kr(v)?v:{...b,...v}}return b}))},h=(d,u,p={replace:!1})=>{c(x=>x.map(b=>{if(b.id===d){const v=typeof u=="function"?u(b):u;return p.replace&&Zh(v)?v:{...b,...v}}return b}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var u;return(u=i(d))==null?void 0:u.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(u=>({...u}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:a,setEdges:c,addNodes:d=>{const u=Array.isArray(d)?d:[d];n.nodeQueue.push(p=>[...p,...u])},addEdges:d=>{const u=Array.isArray(d)?d:[d];n.edgeQueue.push(p=>[...p,...u])},toObject:()=>{const{nodes:d=[],edges:u=[],transform:p}=t.getState(),[x,b,v]=p;return{nodes:d.map(y=>({...y})),edges:u.map(y=>({...y})),viewport:{x,y:b,zoom:v}}},deleteElements:async({nodes:d=[],edges:u=[]})=>{const{nodes:p,edges:x,onNodesDelete:b,onEdgesDelete:v,triggerNodeChanges:y,triggerEdgeChanges:g,onDelete:m,onBeforeDelete:w}=t.getState(),{nodes:C,edges:z}=await zf({nodesToRemove:d,edgesToRemove:u,nodes:p,edges:x,onBeforeDelete:w}),k=z.length>0,$=C.length>0;if(k){const P=z.map(zr);v==null||v(z),g(P)}if($){const P=C.map(zr);b==null||b(C),y(P)}return($||k)&&(m==null||m({nodes:C,edges:z})),{deletedNodes:C,deletedEdges:z}},getIntersectingNodes:(d,u=!0,p)=>{const x=Qs(d),b=x?d:l(d),v=p!==void 0;return b?(p||t.getState().nodes).filter(y=>{const g=t.getState().nodeLookup.get(y.id);if(g&&!x&&(y.id===d.id||!g.internals.positionAbsolute))return!1;const m=tt(v?y:g),w=vt(m,b);return u&&w>0||w>=m.width*m.height||w>=b.width*b.height}):[]},isNodeIntersecting:(d,u,p=!0)=>{const b=Qs(d)?d:l(d);if(!b)return!1;const v=vt(b,u);return p&&v>0||v>=u.width*u.height||v>=b.width*b.height},updateNode:f,updateNodeData:(d,u,p={replace:!1})=>{f(d,x=>{const b=typeof u=="function"?u(x):u;return p.replace?{...x,data:b}:{...x,data:{...x.data,...b}}},p)},updateEdge:h,updateEdgeData:(d,u,p={replace:!1})=>{h(d,x=>{const b=typeof u=="function"?u(x):u;return p.replace?{...x,data:b}:{...x,data:{...x.data,...b}}},p)},getNodesBounds:d=>{const{nodeLookup:u,nodeOrigin:p}=t.getState();return vf(d,{nodeLookup:u,nodeOrigin:p})},getHandleConnections:({type:d,id:u,nodeId:p})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${p}-${d}${u?`-${u}`:""}`))==null?void 0:x.values())??[])},getNodeConnections:({type:d,handleId:u,nodeId:p})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${p}${d?u?`-${d}-${u}`:`-${d}`:""}`))==null?void 0:x.values())??[])},fitView:async d=>{const u=t.getState().fitViewResolver??_f();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:u}),n.nodeQueue.push(p=>[...p]),u.promise}}},[]);return N.useMemo(()=>({...o,...e,viewportInitialized:s}),[s])}const Er=e=>e.selected,sp=typeof window<"u"?window:void 0;function rp({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=re(),{deleteElements:s}=_s(),o=jt(e,{actInsideInputWithModifier:!1}),i=jt(t,{target:sp});N.useEffect(()=>{if(o){const{edges:a,nodes:c}=n.getState();s({nodes:c.filter(Er),edges:a.filter(Er)}),n.setState({nodesSelectionActive:!1})}},[o]),N.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function op(e){const t=re();N.useEffect(()=>{const n=()=>{var o,i,a,c;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const s=js(e.current);(s.height===0||s.width===0)&&((c=(a=t.getState()).onError)==null||c.call(a,"004",ge.error004())),t.setState({width:s.width||500,height:s.height||500})};if(e.current){n(),window.addEventListener("resize",n);const s=new ResizeObserver(()=>n());return s.observe(e.current),()=>{window.removeEventListener("resize",n),s&&e.current&&s.unobserve(e.current)}}},[])}const kn={position:"absolute",width:"100%",height:"100%",top:0,left:0},ip=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function ap({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:s=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=De.Free,zoomOnDoubleClick:a=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:f,minZoom:h,maxZoom:d,zoomActivationKeyCode:u,preventScrolling:p=!0,children:x,noWheelClassName:b,noPanClassName:v,onViewportChange:y,isControlledViewport:g,paneClickDistance:m,selectionOnDrag:w}){const C=re(),z=N.useRef(null),{userSelectionActive:k,lib:$,connectionInProgress:P}=J(ip,se),F=jt(u),M=N.useRef();op(z);const A=N.useCallback(O=>{y==null||y({x:O[0],y:O[1],zoom:O[2]}),g||C.setState({transform:O})},[y,g]);return N.useEffect(()=>{if(z.current){M.current=fh({domNode:z.current,minZoom:h,maxZoom:d,translateExtent:f,viewport:l,onDraggingChange:S=>C.setState(I=>I.paneDragging===S?I:{paneDragging:S}),onPanZoomStart:(S,I)=>{const{onViewportChangeStart:E,onMoveStart:_}=C.getState();_==null||_(S,I),E==null||E(I)},onPanZoom:(S,I)=>{const{onViewportChange:E,onMove:_}=C.getState();_==null||_(S,I),E==null||E(I)},onPanZoomEnd:(S,I)=>{const{onViewportChangeEnd:E,onMoveEnd:_}=C.getState();_==null||_(S,I),E==null||E(I)}});const{x:O,y:j,zoom:T}=M.current.getViewport();return C.setState({panZoom:M.current,transform:[O,j,T],domNode:z.current.closest(".react-flow")}),()=>{var S;(S=M.current)==null||S.destroy()}}},[]),N.useEffect(()=>{var O;(O=M.current)==null||O.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:s,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:c,zoomActivationKeyPressed:F,preventScrolling:p,noPanClassName:v,userSelectionActive:k,noWheelClassName:b,lib:$,onTransformChange:A,connectionInProgress:P,selectionOnDrag:w,paneClickDistance:m})},[e,t,n,s,o,i,a,c,F,p,v,k,b,$,A,P,w,m]),r.jsx("div",{className:"react-flow__renderer",ref:z,style:kn,children:x})}const cp=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function lp(){const{userSelectionActive:e,userSelectionRect:t}=J(cp,se);return e&&t?r.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Hn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},dp=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function up({isSelecting:e,selectionKeyPressed:t,selectionMode:n=wt.Full,panOnDrag:s,paneClickDistance:o,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:f,onPaneScroll:h,onPaneMouseEnter:d,onPaneMouseMove:u,onPaneMouseLeave:p,children:x}){const b=re(),{userSelectionActive:v,elementsSelectable:y,dragging:g,connectionInProgress:m}=J(dp,se),w=y&&(e||v),C=N.useRef(null),z=N.useRef(),k=N.useRef(new Set),$=N.useRef(new Set),P=N.useRef(!1),F=E=>{if(P.current||m){P.current=!1;return}l==null||l(E),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},M=E=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){E.preventDefault();return}f==null||f(E)},A=h?E=>h(E):void 0,O=E=>{P.current&&(E.stopPropagation(),P.current=!1)},j=E=>{var X,K;const{domNode:_}=b.getState();if(z.current=_==null?void 0:_.getBoundingClientRect(),!z.current)return;const L=E.target===C.current;if(!L&&!!E.target.closest(".nokey")||!e||!(i&&L||t)||E.button!==0||!E.isPrimary)return;(K=(X=E.target)==null?void 0:X.setPointerCapture)==null||K.call(X,E.pointerId),P.current=!1;const{x:V,y:G}=fe(E.nativeEvent,z.current);b.setState({userSelectionRect:{width:0,height:0,startX:V,startY:G,x:V,y:G}}),L||(E.stopPropagation(),E.preventDefault())},T=E=>{const{userSelectionRect:_,transform:L,nodeLookup:R,edgeLookup:D,connectionLookup:V,triggerNodeChanges:G,triggerEdgeChanges:X,defaultEdgeOptions:K,resetSelectedElements:B}=b.getState();if(!z.current||!_)return;const{x:H,y:Y}=fe(E.nativeEvent,z.current),{startX:q,startY:Q}=_;if(!P.current){const te=t?0:o;if(Math.hypot(H-q,Y-Q)<=te)return;B(),a==null||a(E)}P.current=!0;const Z={startX:q,startY:Q,x:H<q?H:q,y:Y<Q?Y:Q,width:Math.abs(H-q),height:Math.abs(Y-Q)},U=k.current,ee=$.current;k.current=new Set(vs(R,Z,L,n===wt.Partial,!0).map(te=>te.id)),$.current=new Set;const ne=(K==null?void 0:K.selectable)??!0;for(const te of k.current){const ie=V.get(te);if(ie)for(const{edgeId:Se}of ie.values()){const Ne=D.get(Se);Ne&&(Ne.selectable??ne)&&$.current.add(Se)}}if(!Js(U,k.current)){const te=qe(R,k.current,!0);G(te)}if(!Js(ee,$.current)){const te=qe(D,$.current);X(te)}b.setState({userSelectionRect:Z,userSelectionActive:!0,nodesSelectionActive:!1})},S=E=>{var _,L;E.button===0&&((L=(_=E.target)==null?void 0:_.releasePointerCapture)==null||L.call(_,E.pointerId),!v&&E.target===C.current&&b.getState().userSelectionRect&&(F==null||F(E)),b.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(c==null||c(E),b.setState({nodesSelectionActive:k.current.size>0})))},I=s===!0||Array.isArray(s)&&s.includes(0);return r.jsxs("div",{className:oe(["react-flow__pane",{draggable:I,dragging:g,selection:e}]),onClick:w?void 0:Hn(F,C),onContextMenu:Hn(M,C),onWheel:Hn(A,C),onPointerEnter:w?void 0:d,onPointerMove:w?T:u,onPointerUp:w?S:void 0,onPointerDownCapture:w?j:void 0,onClickCapture:w?O:void 0,onPointerLeave:p,ref:C,style:kn,children:[x,r.jsx(lp,{})]})}function ns({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:c,onError:l}=t.getState(),f=c.get(e);if(!f){l==null||l("012",ge.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&a)&&(i({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var h;return(h=s==null?void 0:s.current)==null?void 0:h.blur()})):o([e])}function bi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:o,isSelectable:i,nodeClickDistance:a}){const c=re(),[l,f]=N.useState(!1),h=N.useRef();return N.useEffect(()=>{h.current=Qf({getStoreItems:()=>c.getState(),onNodeMouseDown:d=>{ns({id:d,store:c,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),N.useEffect(()=>{if(!(t||!e.current||!h.current))return h.current.update({noDragClassName:n,handleSelector:s,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:a}),()=>{var d;(d=h.current)==null||d.destroy()}},[n,s,t,i,e,o,a]),l}const fp=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function yi(){const e=re();return N.useCallback(n=>{const{nodeExtent:s,snapToGrid:o,snapGrid:i,nodesDraggable:a,onError:c,updateNodePositions:l,nodeLookup:f,nodeOrigin:h}=e.getState(),d=new Map,u=fp(a),p=o?i[0]:5,x=o?i[1]:5,b=n.direction.x*p*n.factor,v=n.direction.y*x*n.factor;for(const[,y]of f){if(!u(y))continue;let g={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+v};o&&(g=Et(g,i));const{position:m,positionAbsolute:w}=Ro({nodeId:y.id,nextPosition:g,nodeLookup:f,nodeExtent:s,nodeOrigin:h,onError:c});y.position=m,y.internals.positionAbsolute=w,d.set(y.id,y)}l(d)},[])}const Ms=N.createContext(null),hp=Ms.Provider;Ms.Consumer;const wi=()=>N.useContext(Ms),pp=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),xp=(e,t,n)=>s=>{const{connectionClickStartHandle:o,connectionMode:i,connection:a}=s,{fromHandle:c,toHandle:l,isValid:f}=a,h=(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n,connectingTo:h,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===Je.Strict?(c==null?void 0:c.type)!==n:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!o,valid:h&&f}};function mp({type:e="source",position:t=W.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:a,onConnect:c,children:l,className:f,onMouseDown:h,onTouchStart:d,...u},p){var T,S;const x=a||null,b=e==="target",v=re(),y=wi(),{connectOnClick:g,noPanClassName:m,rfId:w}=J(pp,se),{connectingFrom:C,connectingTo:z,clickConnecting:k,isPossibleEndHandle:$,connectionInProcess:P,clickConnectionInProcess:F,valid:M}=J(xp(y,x,e),se);y||(S=(T=v.getState()).onError)==null||S.call(T,"010",ge.error010());const A=I=>{const{defaultEdgeOptions:E,onConnect:_,hasDefaultEdges:L}=v.getState(),R={...E,...I};if(L){const{edges:D,setEdges:V}=v.getState();V(Df(R,D))}_==null||_(R),c==null||c(R)},O=I=>{if(!y)return;const E=Wo(I.nativeEvent);if(o&&(E&&I.button===0||!E)){const _=v.getState();ts.onPointerDown(I.nativeEvent,{handleDomNode:I.currentTarget,autoPanOnConnect:_.autoPanOnConnect,connectionMode:_.connectionMode,connectionRadius:_.connectionRadius,domNode:_.domNode,nodeLookup:_.nodeLookup,lib:_.lib,isTarget:b,handleId:x,nodeId:y,flowId:_.rfId,panBy:_.panBy,cancelConnection:_.cancelConnection,onConnectStart:_.onConnectStart,onConnectEnd:(...L)=>{var R,D;return(D=(R=v.getState()).onConnectEnd)==null?void 0:D.call(R,...L)},updateConnection:_.updateConnection,onConnect:A,isValidConnection:n||((...L)=>{var R,D;return((D=(R=v.getState()).isValidConnection)==null?void 0:D.call(R,...L))??!0}),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:_.autoPanSpeed,dragThreshold:_.connectionDragThreshold})}E?h==null||h(I):d==null||d(I)},j=I=>{const{onClickConnectStart:E,onClickConnectEnd:_,connectionClickStartHandle:L,connectionMode:R,isValidConnection:D,lib:V,rfId:G,nodeLookup:X,connection:K}=v.getState();if(!y||!L&&!o)return;if(!L){E==null||E(I.nativeEvent,{nodeId:y,handleId:x,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:y,type:e,id:x}});return}const B=Yo(I.target),H=n||D,{connection:Y,isValid:q}=ts.isValid(I.nativeEvent,{handle:{nodeId:y,id:x,type:e},connectionMode:R,fromNodeId:L.nodeId,fromHandleId:L.id||null,fromType:L.type,isValidConnection:H,flowId:G,doc:B,lib:V,nodeLookup:X});q&&Y&&A(Y);const Q=structuredClone(K);delete Q.inProgress,Q.toPosition=Q.toHandle?Q.toHandle.position:null,_==null||_(I,Q),v.setState({connectionClickStartHandle:null})};return r.jsx("div",{"data-handleid":x,"data-nodeid":y,"data-handlepos":t,"data-id":`${w}-${y}-${x}-${e}`,className:oe(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",m,f,{source:!b,target:b,connectable:s,connectablestart:o,connectableend:i,clickconnecting:k,connectingfrom:C,connectingto:z,valid:M,connectionindicator:s&&(!P||$)&&(P||F?i:o)}]),onMouseDown:O,onTouchStart:O,onClick:g?j:void 0,ref:p,...u,children:l})}const de=N.memo(mi(mp));function gp({data:e,isConnectable:t,sourcePosition:n=W.Bottom}){return r.jsxs(r.Fragment,{children:[e==null?void 0:e.label,r.jsx(de,{type:"source",position:n,isConnectable:t})]})}function bp({data:e,isConnectable:t,targetPosition:n=W.Top,sourcePosition:s=W.Bottom}){return r.jsxs(r.Fragment,{children:[r.jsx(de,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,r.jsx(de,{type:"source",position:s,isConnectable:t})]})}function yp(){return null}function wp({data:e,isConnectable:t,targetPosition:n=W.Top}){return r.jsxs(r.Fragment,{children:[r.jsx(de,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const un={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},_r={input:gp,default:bp,output:wp,group:yp};function vp(e){var t,n,s,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((s=e.style)==null?void 0:s.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const Np=e=>{const{width:t,height:n,x:s,y:o}=St(e.nodeLookup,{filter:i=>!!i.selected});return{width:ue(t)?t:null,height:ue(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${s}px,${o}px)`}};function jp({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=re(),{width:o,height:i,transformString:a,userSelectionActive:c}=J(Np,se),l=yi(),f=N.useRef(null);N.useEffect(()=>{var p;n||(p=f.current)==null||p.focus({preventScroll:!0})},[n]);const h=!c&&o!==null&&i!==null;if(bi({nodeRef:f,disabled:!h}),!h)return null;const d=e?p=>{const x=s.getState().nodes.filter(b=>b.selected);e(p,x)}:void 0,u=p=>{Object.prototype.hasOwnProperty.call(un,p.key)&&(p.preventDefault(),l({direction:un[p.key],factor:p.shiftKey?4:1}))};return r.jsx("div",{className:oe(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:r.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:u,style:{width:o,height:i}})})}const Mr=typeof window<"u"?window:void 0,Cp=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function vi({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:c,deleteKeyCode:l,selectionKeyCode:f,selectionOnDrag:h,selectionMode:d,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:b,zoomActivationKeyCode:v,elementsSelectable:y,zoomOnScroll:g,zoomOnPinch:m,panOnScroll:w,panOnScrollSpeed:C,panOnScrollMode:z,zoomOnDoubleClick:k,panOnDrag:$,defaultViewport:P,translateExtent:F,minZoom:M,maxZoom:A,preventScrolling:O,onSelectionContextMenu:j,noWheelClassName:T,noPanClassName:S,disableKeyboardA11y:I,onViewportChange:E,isControlledViewport:_}){const{nodesSelectionActive:L,userSelectionActive:R}=J(Cp,se),D=jt(f,{target:Mr}),V=jt(b,{target:Mr}),G=V||$,X=V||w,K=h&&G!==!0,B=D||R||K;return rp({deleteKeyCode:l,multiSelectionKeyCode:x}),r.jsx(ap,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:g,zoomOnPinch:m,panOnScroll:X,panOnScrollSpeed:C,panOnScrollMode:z,zoomOnDoubleClick:k,panOnDrag:!D&&G,defaultViewport:P,translateExtent:F,minZoom:M,maxZoom:A,zoomActivationKeyCode:v,preventScrolling:O,noWheelClassName:T,noPanClassName:S,onViewportChange:E,isControlledViewport:_,paneClickDistance:c,selectionOnDrag:K,children:r.jsxs(up,{onSelectionStart:u,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:G,isSelecting:!!B,selectionMode:d,selectionKeyPressed:D,paneClickDistance:c,selectionOnDrag:K,children:[e,L&&r.jsx(jp,{onSelectionContextMenu:j,noPanClassName:S,disableKeyboardA11y:I})]})})}vi.displayName="FlowRenderer";const zp=N.memo(vi),kp=e=>t=>e?vs(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function Sp(e){return J(N.useCallback(kp(e),[e]),se)}const Ep=e=>e.updateNodeInternals;function _p(){const e=J(Ep),[t]=N.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const s=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");s.set(i,{id:i,nodeElement:o.target,force:!0})}),e(s)}));return N.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Mp({node:e,nodeType:t,hasDimensions:n,resizeObserver:s}){const o=re(),i=N.useRef(null),a=N.useRef(null),c=N.useRef(e.sourcePosition),l=N.useRef(e.targetPosition),f=N.useRef(t),h=n&&!!e.internals.handleBounds;return N.useEffect(()=>{i.current&&!e.hidden&&(!h||a.current!==i.current)&&(a.current&&(s==null||s.unobserve(a.current)),s==null||s.observe(i.current),a.current=i.current)},[h,e.hidden]),N.useEffect(()=>()=>{a.current&&(s==null||s.unobserve(a.current),a.current=null)},[]),N.useEffect(()=>{if(i.current){const d=f.current!==t,u=c.current!==e.sourcePosition,p=l.current!==e.targetPosition;(d||u||p)&&(f.current=t,c.current=e.sourcePosition,l.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function Ip({id:e,onClick:t,onMouseEnter:n,onMouseMove:s,onMouseLeave:o,onContextMenu:i,onDoubleClick:a,nodesDraggable:c,elementsSelectable:l,nodesConnectable:f,nodesFocusable:h,resizeObserver:d,noDragClassName:u,noPanClassName:p,disableKeyboardA11y:x,rfId:b,nodeTypes:v,nodeClickDistance:y,onError:g}){const{node:m,internals:w,isParent:C}=J(H=>{const Y=H.nodeLookup.get(e),q=H.parentLookup.has(e);return{node:Y,internals:Y.internals,isParent:q}},se);let z=m.type||"default",k=(v==null?void 0:v[z])||_r[z];k===void 0&&(g==null||g("003",ge.error003(z)),z="default",k=(v==null?void 0:v.default)||_r.default);const $=!!(m.draggable||c&&typeof m.draggable>"u"),P=!!(m.selectable||l&&typeof m.selectable>"u"),F=!!(m.connectable||f&&typeof m.connectable>"u"),M=!!(m.focusable||h&&typeof m.focusable>"u"),A=re(),O=Bo(m),j=Mp({node:m,nodeType:z,hasDimensions:O,resizeObserver:d}),T=bi({nodeRef:j,disabled:m.hidden||!$,noDragClassName:u,handleSelector:m.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:y}),S=yi();if(m.hidden)return null;const I=ke(m),E=vp(m),_=P||$||t||n||s||o,L=n?H=>n(H,{...w.userNode}):void 0,R=s?H=>s(H,{...w.userNode}):void 0,D=o?H=>o(H,{...w.userNode}):void 0,V=i?H=>i(H,{...w.userNode}):void 0,G=a?H=>a(H,{...w.userNode}):void 0,X=H=>{const{selectNodesOnDrag:Y,nodeDragThreshold:q}=A.getState();P&&(!Y||!$||q>0)&&ns({id:e,store:A,nodeRef:j}),t&&t(H,{...w.userNode})},K=H=>{if(!(Go(H.nativeEvent)||x)){if(Ao.includes(H.key)&&P){const Y=H.key==="Escape";ns({id:e,store:A,unselect:Y,nodeRef:j})}else if($&&m.selected&&Object.prototype.hasOwnProperty.call(un,H.key)){H.preventDefault();const{ariaLabelConfig:Y}=A.getState();A.setState({ariaLiveMessage:Y["node.a11yDescription.ariaLiveMessage"]({direction:H.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),S({direction:un[H.key],factor:H.shiftKey?4:1})}}},B=()=>{var ee;if(x||!((ee=j.current)!=null&&ee.matches(":focus-visible")))return;const{transform:H,width:Y,height:q,autoPanOnNodeFocus:Q,setCenter:Z}=A.getState();if(!Q)return;vs(new Map([[e,m]]),{x:0,y:0,width:Y,height:q},H,!0).length>0||Z(m.position.x+I.width/2,m.position.y+I.height/2,{zoom:H[2]})};return r.jsx("div",{className:oe(["react-flow__node",`react-flow__node-${z}`,{[p]:$},m.className,{selected:m.selected,selectable:P,parent:C,draggable:$,dragging:T}]),ref:j,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:_?"all":"none",visibility:O?"visible":"hidden",...m.style,...E},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:R,onMouseLeave:D,onContextMenu:V,onClick:X,onDoubleClick:G,onKeyDown:M?K:void 0,tabIndex:M?0:void 0,onFocus:M?B:void 0,role:m.ariaRole??(M?"group":void 0),"aria-roledescription":"node","aria-describedby":x?void 0:`${di}-${b}`,"aria-label":m.ariaLabel,...m.domAttributes,children:r.jsx(hp,{value:e,children:r.jsx(k,{id:e,data:m.data,type:z,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:m.selected??!1,selectable:P,draggable:$,deletable:m.deletable??!0,isConnectable:F,sourcePosition:m.sourcePosition,targetPosition:m.targetPosition,dragging:T,dragHandle:m.dragHandle,zIndex:w.z,parentId:m.parentId,...I})})})}var Tp=N.memo(Ip);const Ap=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ni(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:o,onError:i}=J(Ap,se),a=Sp(e.onlyRenderVisibleElements),c=_p();return r.jsx("div",{className:"react-flow__nodes",style:kn,children:a.map(l=>r.jsx(Tp,{id:l,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:i},l))})}Ni.displayName="NodeRenderer";const $p=N.memo(Ni);function Pp(e){return J(N.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const s=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),a=n.nodeLookup.get(o.target);i&&a&&Af({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&s.push(o.id)}return s},[e]),se)}const Dp=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return r.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Lp=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return r.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Ir={[an.Arrow]:Dp,[an.ArrowClosed]:Lp};function Rp(e){const t=re();return N.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(Ir,e)?Ir[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",ge.error009(e)),null)},[e])}const Op=({id:e,type:t,color:n,width:s=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:c="auto-start-reverse"})=>{const l=Rp(t);return l?r.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:c,refX:"0",refY:"0",children:r.jsx(l,{color:n,strokeWidth:a})}):null},ji=({defaultColor:e,rfId:t})=>{const n=J(i=>i.edges),s=J(i=>i.defaultEdgeOptions),o=N.useMemo(()=>Ff(n,{id:t,defaultColor:e,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[n,s,t,e]);return o.length?r.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:r.jsx("defs",{children:o.map(i=>r.jsx(Op,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};ji.displayName="MarkerDefinitions";var Hp=N.memo(ji);function Ci({x:e,y:t,label:n,labelStyle:s,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:c=2,children:l,className:f,...h}){const[d,u]=N.useState({x:1,y:0,width:0,height:0}),p=oe(["react-flow__edge-textwrapper",f]),x=N.useRef(null);return N.useEffect(()=>{if(x.current){const b=x.current.getBBox();u({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?r.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?"visible":"hidden",...h,children:[o&&r.jsx("rect",{width:d.width+2*a[0],x:-a[0],y:-a[1],height:d.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:c,ry:c}),r.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:x,style:s,children:n}),l]}):null}Ci.displayName="EdgeText";const Fp=N.memo(Ci);function Mt({path:e,labelX:t,labelY:n,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,interactionWidth:f=20,...h}){return r.jsxs(r.Fragment,{children:[r.jsx("path",{...h,d:e,fill:"none",className:oe(["react-flow__edge-path",h.className])}),f?r.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,s&&ue(t)&&ue(n)?r.jsx(Fp,{x:t,y:n,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l}):null]})}function Tr({pos:e,x1:t,y1:n,x2:s,y2:o}){return e===W.Left||e===W.Right?[.5*(t+s),n]:[t,.5*(n+o)]}function zi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:s,targetY:o,targetPosition:i=W.Top}){const[a,c]=Tr({pos:n,x1:e,y1:t,x2:s,y2:o}),[l,f]=Tr({pos:i,x1:s,y1:o,x2:e,y2:t}),[h,d,u,p]=Xo({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:f});return[`M${e},${t} C${a},${c} ${l},${f} ${s},${o}`,h,d,u,p]}function ki(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,sourcePosition:a,targetPosition:c,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:v,interactionWidth:y})=>{const[g,m,w]=zi({sourceX:n,sourceY:s,sourcePosition:a,targetX:o,targetY:i,targetPosition:c}),C=e.isInternal?void 0:t;return r.jsx(Mt,{id:C,path:g,labelX:m,labelY:w,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:v,interactionWidth:y})})}const Bp=ki({isInternal:!1}),Si=ki({isInternal:!0});Bp.displayName="SimpleBezierEdge";Si.displayName="SimpleBezierEdgeInternal";function Ei(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,sourcePosition:p=W.Bottom,targetPosition:x=W.Top,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:g})=>{const[m,w,C]=dn({sourceX:n,sourceY:s,sourcePosition:p,targetX:o,targetY:i,targetPosition:x,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),z=e.isInternal?void 0:t;return r.jsx(Mt,{id:z,path:m,labelX:w,labelY:C,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:b,markerStart:v,interactionWidth:g})})}const _i=Ei({isInternal:!1}),Mi=Ei({isInternal:!0});_i.displayName="SmoothStepEdge";Mi.displayName="SmoothStepEdgeInternal";function Ii(e){return N.memo(({id:t,...n})=>{var o;const s=e.isInternal?void 0:t;return r.jsx(_i,{...n,id:s,pathOptions:N.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const Vp=Ii({isInternal:!1}),Ti=Ii({isInternal:!0});Vp.displayName="StepEdge";Ti.displayName="StepEdgeInternal";function Ai(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:x,interactionWidth:b})=>{const[v,y,g]=Ko({sourceX:n,sourceY:s,targetX:o,targetY:i}),m=e.isInternal?void 0:t;return r.jsx(Mt,{id:m,path:v,labelX:y,labelY:g,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:x,interactionWidth:b})})}const Yp=Ai({isInternal:!1}),$i=Ai({isInternal:!0});Yp.displayName="StraightEdge";$i.displayName="StraightEdgeInternal";function Pi(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,sourcePosition:a=W.Bottom,targetPosition:c=W.Top,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:g})=>{const[m,w,C]=qo({sourceX:n,sourceY:s,sourcePosition:a,targetX:o,targetY:i,targetPosition:c,curvature:y==null?void 0:y.curvature}),z=e.isInternal?void 0:t;return r.jsx(Mt,{id:z,path:m,labelX:w,labelY:C,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:v,interactionWidth:g})})}const Gp=Pi({isInternal:!1}),Di=Pi({isInternal:!0});Gp.displayName="BezierEdge";Di.displayName="BezierEdgeInternal";const Ar={default:Di,straight:$i,step:Ti,smoothstep:Mi,simplebezier:Si},$r={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Wp=(e,t,n)=>n===W.Left?e-t:n===W.Right?e+t:e,Xp=(e,t,n)=>n===W.Top?e-t:n===W.Bottom?e+t:e,Pr="react-flow__edgeupdater";function Dr({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:o,onMouseEnter:i,onMouseOut:a,type:c}){return r.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:a,className:oe([Pr,`${Pr}-${c}`]),cx:Wp(t,s,e),cy:Xp(n,s,e),r:s,stroke:"transparent",fill:"transparent"})}function qp({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:s,sourceY:o,targetX:i,targetY:a,sourcePosition:c,targetPosition:l,onReconnect:f,onReconnectStart:h,onReconnectEnd:d,setReconnecting:u,setUpdateHover:p}){const x=re(),b=(w,C)=>{if(w.button!==0)return;const{autoPanOnConnect:z,domNode:k,connectionMode:$,connectionRadius:P,lib:F,onConnectStart:M,cancelConnection:A,nodeLookup:O,rfId:j,panBy:T,updateConnection:S}=x.getState(),I=C.type==="target",E=(R,D)=>{u(!1),d==null||d(R,n,C.type,D)},_=R=>f==null?void 0:f(n,R),L=(R,D)=>{u(!0),h==null||h(w,n,C.type),M==null||M(R,D)};ts.onPointerDown(w.nativeEvent,{autoPanOnConnect:z,connectionMode:$,connectionRadius:P,domNode:k,handleId:C.id,nodeId:C.nodeId,nodeLookup:O,isTarget:I,edgeUpdaterType:C.type,lib:F,flowId:j,cancelConnection:A,panBy:T,isValidConnection:(...R)=>{var D,V;return((V=(D=x.getState()).isValidConnection)==null?void 0:V.call(D,...R))??!0},onConnect:_,onConnectStart:L,onConnectEnd:(...R)=>{var D,V;return(V=(D=x.getState()).onConnectEnd)==null?void 0:V.call(D,...R)},onReconnectEnd:E,updateConnection:S,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,dragThreshold:x.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},v=w=>b(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=w=>b(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),g=()=>p(!0),m=()=>p(!1);return r.jsxs(r.Fragment,{children:[(e===!0||e==="source")&&r.jsx(Dr,{position:c,centerX:s,centerY:o,radius:t,onMouseDown:v,onMouseEnter:g,onMouseOut:m,type:"source"}),(e===!0||e==="target")&&r.jsx(Dr,{position:l,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:g,onMouseOut:m,type:"target"})]})}function Up({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:s,onClick:o,onDoubleClick:i,onContextMenu:a,onMouseEnter:c,onMouseMove:l,onMouseLeave:f,reconnectRadius:h,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,rfId:x,edgeTypes:b,noPanClassName:v,onError:y,disableKeyboardA11y:g}){let m=J(Z=>Z.edgeLookup.get(e));const w=J(Z=>Z.defaultEdgeOptions);m=w?{...w,...m}:m;let C=m.type||"default",z=(b==null?void 0:b[C])||Ar[C];z===void 0&&(y==null||y("011",ge.error011(C)),C="default",z=(b==null?void 0:b.default)||Ar.default);const k=!!(m.focusable||t&&typeof m.focusable>"u"),$=typeof d<"u"&&(m.reconnectable||n&&typeof m.reconnectable>"u"),P=!!(m.selectable||s&&typeof m.selectable>"u"),F=N.useRef(null),[M,A]=N.useState(!1),[O,j]=N.useState(!1),T=re(),{zIndex:S,sourceX:I,sourceY:E,targetX:_,targetY:L,sourcePosition:R,targetPosition:D}=J(N.useCallback(Z=>{const U=Z.nodeLookup.get(m.source),ee=Z.nodeLookup.get(m.target);if(!U||!ee)return{zIndex:m.zIndex,...$r};const ne=Hf({id:e,sourceNode:U,targetNode:ee,sourceHandle:m.sourceHandle||null,targetHandle:m.targetHandle||null,connectionMode:Z.connectionMode,onError:y});return{zIndex:Tf({selected:m.selected,zIndex:m.zIndex,sourceNode:U,targetNode:ee,elevateOnSelect:Z.elevateEdgesOnSelect,zIndexMode:Z.zIndexMode}),...ne||$r}},[m.source,m.target,m.sourceHandle,m.targetHandle,m.selected,m.zIndex]),se),V=N.useMemo(()=>m.markerStart?`url('#${Jn(m.markerStart,x)}')`:void 0,[m.markerStart,x]),G=N.useMemo(()=>m.markerEnd?`url('#${Jn(m.markerEnd,x)}')`:void 0,[m.markerEnd,x]);if(m.hidden||I===null||E===null||_===null||L===null)return null;const X=Z=>{var te;const{addSelectedEdges:U,unselectNodesAndEdges:ee,multiSelectionActive:ne}=T.getState();P&&(T.setState({nodesSelectionActive:!1}),m.selected&&ne?(ee({nodes:[],edges:[m]}),(te=F.current)==null||te.blur()):U([e])),o&&o(Z,m)},K=i?Z=>{i(Z,{...m})}:void 0,B=a?Z=>{a(Z,{...m})}:void 0,H=c?Z=>{c(Z,{...m})}:void 0,Y=l?Z=>{l(Z,{...m})}:void 0,q=f?Z=>{f(Z,{...m})}:void 0,Q=Z=>{var U;if(!g&&Ao.includes(Z.key)&&P){const{unselectNodesAndEdges:ee,addSelectedEdges:ne}=T.getState();Z.key==="Escape"?((U=F.current)==null||U.blur(),ee({edges:[m]})):ne([e])}};return r.jsx("svg",{style:{zIndex:S},children:r.jsxs("g",{className:oe(["react-flow__edge",`react-flow__edge-${C}`,m.className,v,{selected:m.selected,animated:m.animated,inactive:!P&&!o,updating:M,selectable:P}]),onClick:X,onDoubleClick:K,onContextMenu:B,onMouseEnter:H,onMouseMove:Y,onMouseLeave:q,onKeyDown:k?Q:void 0,tabIndex:k?0:void 0,role:m.ariaRole??(k?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":m.ariaLabel===null?void 0:m.ariaLabel||`Edge from ${m.source} to ${m.target}`,"aria-describedby":k?`${ui}-${x}`:void 0,ref:F,...m.domAttributes,children:[!O&&r.jsx(z,{id:e,source:m.source,target:m.target,type:m.type,selected:m.selected,animated:m.animated,selectable:P,deletable:m.deletable??!0,label:m.label,labelStyle:m.labelStyle,labelShowBg:m.labelShowBg,labelBgStyle:m.labelBgStyle,labelBgPadding:m.labelBgPadding,labelBgBorderRadius:m.labelBgBorderRadius,sourceX:I,sourceY:E,targetX:_,targetY:L,sourcePosition:R,targetPosition:D,data:m.data,style:m.style,sourceHandleId:m.sourceHandle,targetHandleId:m.targetHandle,markerStart:V,markerEnd:G,pathOptions:"pathOptions"in m?m.pathOptions:void 0,interactionWidth:m.interactionWidth}),$&&r.jsx(qp,{edge:m,isReconnectable:$,reconnectRadius:h,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,sourceX:I,sourceY:E,targetX:_,targetY:L,sourcePosition:R,targetPosition:D,setUpdateHover:A,setReconnecting:j})]})})}var Kp=N.memo(Up);const Zp=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Li({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:s,noPanClassName:o,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:f,onEdgeClick:h,reconnectRadius:d,onEdgeDoubleClick:u,onReconnectStart:p,onReconnectEnd:x,disableKeyboardA11y:b}){const{edgesFocusable:v,edgesReconnectable:y,elementsSelectable:g,onError:m}=J(Zp,se),w=Pp(t);return r.jsxs("div",{className:"react-flow__edges",children:[r.jsx(Hp,{defaultColor:e,rfId:n}),w.map(C=>r.jsx(Kp,{id:C,edgesFocusable:v,edgesReconnectable:y,elementsSelectable:g,noPanClassName:o,onReconnect:i,onContextMenu:a,onMouseEnter:c,onMouseMove:l,onMouseLeave:f,onClick:h,reconnectRadius:d,onDoubleClick:u,onReconnectStart:p,onReconnectEnd:x,rfId:n,onError:m,edgeTypes:s,disableKeyboardA11y:b},C))]})}Li.displayName="EdgeRenderer";const Qp=N.memo(Li),Jp=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function e0({children:e}){const t=J(Jp);return r.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function t0(e){const t=_s(),n=N.useRef(!1);N.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const n0=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function s0(e){const t=J(n0),n=re();return N.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function r0(e){return e.connection.inProgress?{...e.connection,to:_t(e.connection.to,e.transform)}:{...e.connection}}function o0(e){return r0}function i0(e){const t=o0();return J(t,se)}const a0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function c0({containerStyle:e,style:t,type:n,component:s}){const{nodesConnectable:o,width:i,height:a,isValid:c,inProgress:l}=J(a0,se);return!(i&&o&&l)?null:r.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:r.jsx("g",{className:oe(["react-flow__connection",Do(c)]),children:r.jsx(Ri,{style:t,type:n,CustomComponent:s,isValid:c})})})}const Ri=({style:e,type:t=Ie.Bezier,CustomComponent:n,isValid:s})=>{const{inProgress:o,from:i,fromNode:a,fromHandle:c,fromPosition:l,to:f,toNode:h,toHandle:d,toPosition:u,pointer:p}=i0();if(!o)return;if(n)return r.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:c,fromX:i.x,fromY:i.y,toX:f.x,toY:f.y,fromPosition:l,toPosition:u,connectionStatus:Do(s),toNode:h,toHandle:d,pointer:p});let x="";const b={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:f.x,targetY:f.y,targetPosition:u};switch(t){case Ie.Bezier:[x]=qo(b);break;case Ie.SimpleBezier:[x]=zi(b);break;case Ie.Step:[x]=dn({...b,borderRadius:0});break;case Ie.SmoothStep:[x]=dn(b);break;default:[x]=Ko(b)}return r.jsx("path",{d:x,fill:"none",className:"react-flow__connection-path",style:e})};Ri.displayName="ConnectionLine";const l0={};function Lr(e=l0){N.useRef(e),re(),N.useEffect(()=>{},[e])}function d0(){re(),N.useRef(!1),N.useEffect(()=>{},[])}function Oi({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:s,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:f,onNodeContextMenu:h,onSelectionContextMenu:d,onSelectionStart:u,onSelectionEnd:p,connectionLineType:x,connectionLineStyle:b,connectionLineComponent:v,connectionLineContainerStyle:y,selectionKeyCode:g,selectionOnDrag:m,selectionMode:w,multiSelectionKeyCode:C,panActivationKeyCode:z,zoomActivationKeyCode:k,deleteKeyCode:$,onlyRenderVisibleElements:P,elementsSelectable:F,defaultViewport:M,translateExtent:A,minZoom:O,maxZoom:j,preventScrolling:T,defaultMarkerColor:S,zoomOnScroll:I,zoomOnPinch:E,panOnScroll:_,panOnScrollSpeed:L,panOnScrollMode:R,zoomOnDoubleClick:D,panOnDrag:V,onPaneClick:G,onPaneMouseEnter:X,onPaneMouseMove:K,onPaneMouseLeave:B,onPaneScroll:H,onPaneContextMenu:Y,paneClickDistance:q,nodeClickDistance:Q,onEdgeContextMenu:Z,onEdgeMouseEnter:U,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,onReconnect:ie,onReconnectStart:Se,onReconnectEnd:Ne,noDragClassName:$e,noWheelClassName:ot,noPanClassName:it,disableKeyboardA11y:at,nodeExtent:Sn,rfId:It,viewport:Fe,onViewportChange:ct}){return Lr(e),Lr(t),d0(),t0(n),s0(Fe),r.jsx(zp,{onPaneClick:G,onPaneMouseEnter:X,onPaneMouseMove:K,onPaneMouseLeave:B,onPaneContextMenu:Y,onPaneScroll:H,paneClickDistance:q,deleteKeyCode:$,selectionKeyCode:g,selectionOnDrag:m,selectionMode:w,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:C,panActivationKeyCode:z,zoomActivationKeyCode:k,elementsSelectable:F,zoomOnScroll:I,zoomOnPinch:E,zoomOnDoubleClick:D,panOnScroll:_,panOnScrollSpeed:L,panOnScrollMode:R,panOnDrag:V,defaultViewport:M,translateExtent:A,minZoom:O,maxZoom:j,onSelectionContextMenu:d,preventScrolling:T,noDragClassName:$e,noWheelClassName:ot,noPanClassName:it,disableKeyboardA11y:at,onViewportChange:ct,isControlledViewport:!!Fe,children:r.jsxs(e0,{children:[r.jsx(Qp,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:a,onReconnect:ie,onReconnectStart:Se,onReconnectEnd:Ne,onlyRenderVisibleElements:P,onEdgeContextMenu:Z,onEdgeMouseEnter:U,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,defaultMarkerColor:S,noPanClassName:it,disableKeyboardA11y:at,rfId:It}),r.jsx(c0,{style:b,type:x,component:v,containerStyle:y}),r.jsx("div",{className:"react-flow__edgelabel-renderer"}),r.jsx($p,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:i,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:f,onNodeContextMenu:h,nodeClickDistance:Q,onlyRenderVisibleElements:P,noPanClassName:it,noDragClassName:$e,disableKeyboardA11y:at,nodeExtent:Sn,rfId:It}),r.jsx("div",{className:"react-flow__viewport-portal"})]})})}Oi.displayName="GraphView";const u0=N.memo(Oi),Rr=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:a,fitViewOptions:c,minZoom:l=.5,maxZoom:f=2,nodeOrigin:h,nodeExtent:d,zIndexMode:u="basic"}={})=>{const p=new Map,x=new Map,b=new Map,v=new Map,y=s??t??[],g=n??e??[],m=h??[0,0],w=d??yt;Jo(b,v,y);const C=es(g,p,x,{nodeOrigin:m,nodeExtent:w,zIndexMode:u});let z=[0,0,1];if(a&&o&&i){const k=St(p,{filter:M=>!!((M.width||M.initialWidth)&&(M.height||M.initialHeight))}),{x:$,y:P,zoom:F}=Ns(k,o,i,l,f,(c==null?void 0:c.padding)??.1);z=[$,P,F]}return{rfId:"1",width:o??0,height:i??0,transform:z,nodes:g,nodesInitialized:C,nodeLookup:p,parentLookup:x,edges:y,edgeLookup:v,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:l,maxZoom:f,translateExtent:yt,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Je.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:m,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:c,fitViewResolver:null,connection:{...Po},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:kf,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:$o,zIndexMode:u,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},f0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:f,nodeOrigin:h,nodeExtent:d,zIndexMode:u})=>Mh((p,x)=>{async function b(){const{nodeLookup:v,panZoom:y,fitViewOptions:g,fitViewResolver:m,width:w,height:C,minZoom:z,maxZoom:k}=x();y&&(await Cf({nodes:v,width:w,height:C,panZoom:y,minZoom:z,maxZoom:k},g),m==null||m.resolve(!0),p({fitViewResolver:null}))}return{...Rr({nodes:e,edges:t,width:o,height:i,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:f,nodeOrigin:h,nodeExtent:d,defaultNodes:n,defaultEdges:s,zIndexMode:u}),setNodes:v=>{const{nodeLookup:y,parentLookup:g,nodeOrigin:m,elevateNodesOnSelect:w,fitViewQueued:C,zIndexMode:z}=x(),k=es(v,y,g,{nodeOrigin:m,nodeExtent:d,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:z});C&&k?(b(),p({nodes:v,nodesInitialized:k,fitViewQueued:!1,fitViewOptions:void 0})):p({nodes:v,nodesInitialized:k})},setEdges:v=>{const{connectionLookup:y,edgeLookup:g}=x();Jo(y,g,v),p({edges:v})},setDefaultNodesAndEdges:(v,y)=>{if(v){const{setNodes:g}=x();g(v),p({hasDefaultNodes:!0})}if(y){const{setEdges:g}=x();g(y),p({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:y,nodeLookup:g,parentLookup:m,domNode:w,nodeOrigin:C,nodeExtent:z,debug:k,fitViewQueued:$,zIndexMode:P}=x(),{changes:F,updatedInternals:M}=qf(v,g,m,w,C,z,P);M&&(Yf(g,m,{nodeOrigin:C,nodeExtent:z,zIndexMode:P}),$?(b(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(F==null?void 0:F.length)>0&&(k&&console.log("React Flow: trigger node changes",F),y==null||y(F)))},updateNodePositions:(v,y=!1)=>{const g=[];let m=[];const{nodeLookup:w,triggerNodeChanges:C,connection:z,updateConnection:k,onNodesChangeMiddlewareMap:$}=x();for(const[P,F]of v){const M=w.get(P),A=!!(M!=null&&M.expandParent&&(M!=null&&M.parentId)&&(F!=null&&F.position)),O={id:P,type:"position",position:A?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:y};if(M&&z.inProgress&&z.fromNode.id===M.id){const j=He(M,z.fromHandle,W.Left,!0);k({...z,from:j})}A&&M.parentId&&g.push({id:P,parentId:M.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),m.push(O)}if(g.length>0){const{parentLookup:P,nodeOrigin:F}=x(),M=Es(g,w,P,F);m.push(...M)}for(const P of $.values())m=P(m);C(m)},triggerNodeChanges:v=>{const{onNodesChange:y,setNodes:g,nodes:m,hasDefaultNodes:w,debug:C}=x();if(v!=null&&v.length){if(w){const z=pi(v,m);g(z)}C&&console.log("React Flow: trigger node changes",v),y==null||y(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:y,setEdges:g,edges:m,hasDefaultEdges:w,debug:C}=x();if(v!=null&&v.length){if(w){const z=xi(v,m);g(z)}C&&console.log("React Flow: trigger edge changes",v),y==null||y(v)}},addSelectedNodes:v=>{const{multiSelectionActive:y,edgeLookup:g,nodeLookup:m,triggerNodeChanges:w,triggerEdgeChanges:C}=x();if(y){const z=v.map(k=>Pe(k,!0));w(z);return}w(qe(m,new Set([...v]),!0)),C(qe(g))},addSelectedEdges:v=>{const{multiSelectionActive:y,edgeLookup:g,nodeLookup:m,triggerNodeChanges:w,triggerEdgeChanges:C}=x();if(y){const z=v.map(k=>Pe(k,!0));C(z);return}C(qe(g,new Set([...v]))),w(qe(m,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:y}={})=>{const{edges:g,nodes:m,nodeLookup:w,triggerNodeChanges:C,triggerEdgeChanges:z}=x(),k=v||m,$=y||g,P=[];for(const M of k){if(!M.selected)continue;const A=w.get(M.id);A&&(A.selected=!1),P.push(Pe(M.id,!1))}const F=[];for(const M of $)M.selected&&F.push(Pe(M.id,!1));C(P),z(F)},setMinZoom:v=>{const{panZoom:y,maxZoom:g}=x();y==null||y.setScaleExtent([v,g]),p({minZoom:v})},setMaxZoom:v=>{const{panZoom:y,minZoom:g}=x();y==null||y.setScaleExtent([g,v]),p({maxZoom:v})},setTranslateExtent:v=>{var y;(y=x().panZoom)==null||y.setTranslateExtent(v),p({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:y,triggerNodeChanges:g,triggerEdgeChanges:m,elementsSelectable:w}=x();if(!w)return;const C=y.reduce((k,$)=>$.selected?[...k,Pe($.id,!1)]:k,[]),z=v.reduce((k,$)=>$.selected?[...k,Pe($.id,!1)]:k,[]);g(C),m(z)},setNodeExtent:v=>{const{nodes:y,nodeLookup:g,parentLookup:m,nodeOrigin:w,elevateNodesOnSelect:C,nodeExtent:z,zIndexMode:k}=x();v[0][0]===z[0][0]&&v[0][1]===z[0][1]&&v[1][0]===z[1][0]&&v[1][1]===z[1][1]||(es(y,g,m,{nodeOrigin:w,nodeExtent:v,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:k}),p({nodeExtent:v}))},panBy:v=>{const{transform:y,width:g,height:m,panZoom:w,translateExtent:C}=x();return Uf({delta:v,panZoom:w,transform:y,translateExtent:C,width:g,height:m})},setCenter:async(v,y,g)=>{const{width:m,height:w,maxZoom:C,panZoom:z}=x();if(!z)return Promise.resolve(!1);const k=typeof(g==null?void 0:g.zoom)<"u"?g.zoom:C;return await z.setViewport({x:m/2-v*k,y:w/2-y*k,zoom:k},{duration:g==null?void 0:g.duration,ease:g==null?void 0:g.ease,interpolate:g==null?void 0:g.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...Po}})},updateConnection:v=>{p({connection:v})},reset:()=>p({...Rr()})}},Object.is);function h0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:s,initialWidth:o,initialHeight:i,initialMinZoom:a,initialMaxZoom:c,initialFitViewOptions:l,fitView:f,nodeOrigin:h,nodeExtent:d,zIndexMode:u,children:p}){const[x]=N.useState(()=>f0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:f,minZoom:a,maxZoom:c,fitViewOptions:l,nodeOrigin:h,nodeExtent:d,zIndexMode:u}));return r.jsx(Ih,{value:x,children:r.jsx(ep,{children:p})})}function p0({children:e,nodes:t,edges:n,defaultNodes:s,defaultEdges:o,width:i,height:a,fitView:c,fitViewOptions:l,minZoom:f,maxZoom:h,nodeOrigin:d,nodeExtent:u,zIndexMode:p}){return N.useContext(Cn)?r.jsx(r.Fragment,{children:e}):r.jsx(h0,{initialNodes:t,initialEdges:n,defaultNodes:s,defaultEdges:o,initialWidth:i,initialHeight:a,fitView:c,initialFitViewOptions:l,initialMinZoom:f,initialMaxZoom:h,nodeOrigin:d,nodeExtent:u,zIndexMode:p,children:e})}const x0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function m0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:o,nodeTypes:i,edgeTypes:a,onNodeClick:c,onEdgeClick:l,onInit:f,onMove:h,onMoveStart:d,onMoveEnd:u,onConnect:p,onConnectStart:x,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:g,onNodeMouseMove:m,onNodeMouseLeave:w,onNodeContextMenu:C,onNodeDoubleClick:z,onNodeDragStart:k,onNodeDrag:$,onNodeDragStop:P,onNodesDelete:F,onEdgesDelete:M,onDelete:A,onSelectionChange:O,onSelectionDragStart:j,onSelectionDrag:T,onSelectionDragStop:S,onSelectionContextMenu:I,onSelectionStart:E,onSelectionEnd:_,onBeforeDelete:L,connectionMode:R,connectionLineType:D=Ie.Bezier,connectionLineStyle:V,connectionLineComponent:G,connectionLineContainerStyle:X,deleteKeyCode:K="Backspace",selectionKeyCode:B="Shift",selectionOnDrag:H=!1,selectionMode:Y=wt.Full,panActivationKeyCode:q="Space",multiSelectionKeyCode:Q=Nt()?"Meta":"Control",zoomActivationKeyCode:Z=Nt()?"Meta":"Control",snapToGrid:U,snapGrid:ee,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:te,nodesDraggable:ie,autoPanOnNodeFocus:Se,nodesConnectable:Ne,nodesFocusable:$e,nodeOrigin:ot=fi,edgesFocusable:it,edgesReconnectable:at,elementsSelectable:Sn=!0,defaultViewport:It=Yh,minZoom:Fe=.5,maxZoom:ct=2,translateExtent:Ts=yt,preventScrolling:ia=!0,nodeExtent:En,defaultMarkerColor:aa="#b1b1b7",zoomOnScroll:ca=!0,zoomOnPinch:la=!0,panOnScroll:da=!1,panOnScrollSpeed:ua=.5,panOnScrollMode:fa=De.Free,zoomOnDoubleClick:ha=!0,panOnDrag:pa=!0,onPaneClick:xa,onPaneMouseEnter:ma,onPaneMouseMove:ga,onPaneMouseLeave:ba,onPaneScroll:ya,onPaneContextMenu:wa,paneClickDistance:va=1,nodeClickDistance:Na=0,children:ja,onReconnect:Ca,onReconnectStart:za,onReconnectEnd:ka,onEdgeContextMenu:Sa,onEdgeDoubleClick:Ea,onEdgeMouseEnter:_a,onEdgeMouseMove:Ma,onEdgeMouseLeave:Ia,reconnectRadius:Ta=10,onNodesChange:Aa,onEdgesChange:$a,noDragClassName:Pa="nodrag",noWheelClassName:Da="nowheel",noPanClassName:As="nopan",fitView:$s,fitViewOptions:Ps,connectOnClick:La,attributionPosition:Ra,proOptions:Oa,defaultEdgeOptions:Ha,elevateNodesOnSelect:Fa=!0,elevateEdgesOnSelect:Ba=!1,disableKeyboardA11y:Ds=!1,autoPanOnConnect:Va,autoPanOnNodeDrag:Ya,autoPanSpeed:Ga,connectionRadius:Wa,isValidConnection:Xa,onError:qa,style:Ua,id:Ls,nodeDragThreshold:Ka,connectionDragThreshold:Za,viewport:Qa,onViewportChange:Ja,width:ec,height:tc,colorMode:nc="light",debug:sc,onScroll:Tt,ariaLabelConfig:rc,zIndexMode:Rs="basic",...oc},ic){const _n=Ls||"1",ac=qh(nc),cc=N.useCallback(Os=>{Os.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Tt==null||Tt(Os)},[Tt]);return r.jsx("div",{"data-testid":"rf__wrapper",...oc,onScroll:cc,style:{...Ua,...x0},ref:ic,className:oe(["react-flow",o,ac]),id:Ls,role:"application",children:r.jsxs(p0,{nodes:e,edges:t,width:ec,height:tc,fitView:$s,fitViewOptions:Ps,minZoom:Fe,maxZoom:ct,nodeOrigin:ot,nodeExtent:En,zIndexMode:Rs,children:[r.jsx(u0,{onInit:f,onNodeClick:c,onEdgeClick:l,onNodeMouseEnter:g,onNodeMouseMove:m,onNodeMouseLeave:w,onNodeContextMenu:C,onNodeDoubleClick:z,nodeTypes:i,edgeTypes:a,connectionLineType:D,connectionLineStyle:V,connectionLineComponent:G,connectionLineContainerStyle:X,selectionKeyCode:B,selectionOnDrag:H,selectionMode:Y,deleteKeyCode:K,multiSelectionKeyCode:Q,panActivationKeyCode:q,zoomActivationKeyCode:Z,onlyRenderVisibleElements:ne,defaultViewport:It,translateExtent:Ts,minZoom:Fe,maxZoom:ct,preventScrolling:ia,zoomOnScroll:ca,zoomOnPinch:la,zoomOnDoubleClick:ha,panOnScroll:da,panOnScrollSpeed:ua,panOnScrollMode:fa,panOnDrag:pa,onPaneClick:xa,onPaneMouseEnter:ma,onPaneMouseMove:ga,onPaneMouseLeave:ba,onPaneScroll:ya,onPaneContextMenu:wa,paneClickDistance:va,nodeClickDistance:Na,onSelectionContextMenu:I,onSelectionStart:E,onSelectionEnd:_,onReconnect:Ca,onReconnectStart:za,onReconnectEnd:ka,onEdgeContextMenu:Sa,onEdgeDoubleClick:Ea,onEdgeMouseEnter:_a,onEdgeMouseMove:Ma,onEdgeMouseLeave:Ia,reconnectRadius:Ta,defaultMarkerColor:aa,noDragClassName:Pa,noWheelClassName:Da,noPanClassName:As,rfId:_n,disableKeyboardA11y:Ds,nodeExtent:En,viewport:Qa,onViewportChange:Ja}),r.jsx(Xh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:p,onConnectStart:x,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:ie,autoPanOnNodeFocus:Se,nodesConnectable:Ne,nodesFocusable:$e,edgesFocusable:it,edgesReconnectable:at,elementsSelectable:Sn,elevateNodesOnSelect:Fa,elevateEdgesOnSelect:Ba,minZoom:Fe,maxZoom:ct,nodeExtent:En,onNodesChange:Aa,onEdgesChange:$a,snapToGrid:U,snapGrid:ee,connectionMode:R,translateExtent:Ts,connectOnClick:La,defaultEdgeOptions:Ha,fitView:$s,fitViewOptions:Ps,onNodesDelete:F,onEdgesDelete:M,onDelete:A,onNodeDragStart:k,onNodeDrag:$,onNodeDragStop:P,onSelectionDrag:T,onSelectionDragStart:j,onSelectionDragStop:S,onMove:h,onMoveStart:d,onMoveEnd:u,noPanClassName:As,nodeOrigin:ot,rfId:_n,autoPanOnConnect:Va,autoPanOnNodeDrag:Ya,autoPanSpeed:Ga,onError:qa,connectionRadius:Wa,isValidConnection:Xa,selectNodesOnDrag:te,nodeDragThreshold:Ka,connectionDragThreshold:Za,onBeforeDelete:L,debug:sc,ariaLabelConfig:rc,zIndexMode:Rs}),r.jsx(Vh,{onSelectionChange:O}),ja,r.jsx(Rh,{proOptions:Oa,position:Ra}),r.jsx(Lh,{rfId:_n,disableKeyboardA11y:Ds})]})})}var Hi=mi(m0);const g0=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function b0({children:e}){const t=J(g0);return t?dc.createPortal(e,t):null}function y0(e){const[t,n]=N.useState(e),s=N.useCallback(o=>n(i=>pi(o,i)),[]);return[t,n,s]}function w0(e){const[t,n]=N.useState(e),s=N.useCallback(o=>n(i=>xi(o,i)),[]);return[t,n,s]}function v0({dimensions:e,lineWidth:t,variant:n,className:s}){return r.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:oe(["react-flow__background-pattern",n,s])})}function N0({radius:e,className:t}){return r.jsx("circle",{cx:e,cy:e,r:e,className:oe(["react-flow__background-pattern","dots",t])})}var me;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(me||(me={}));const j0={[me.Dots]:1,[me.Lines]:1,[me.Cross]:6},C0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Fi({id:e,variant:t=me.Dots,gap:n=20,size:s,lineWidth:o=1,offset:i=0,color:a,bgColor:c,style:l,className:f,patternClassName:h}){const d=N.useRef(null),{transform:u,patternId:p}=J(C0,se),x=s||j0[t],b=t===me.Dots,v=t===me.Cross,y=Array.isArray(n)?n:[n,n],g=[y[0]*u[2]||1,y[1]*u[2]||1],m=x*u[2],w=Array.isArray(i)?i:[i,i],C=v?[m,m]:g,z=[w[0]*u[2]||1+C[0]/2,w[1]*u[2]||1+C[1]/2],k=`${p}${e||""}`;return r.jsxs("svg",{className:oe(["react-flow__background",f]),style:{...l,...kn,"--xy-background-color-props":c,"--xy-background-pattern-color-props":a},ref:d,"data-testid":"rf__background",children:[r.jsx("pattern",{id:k,x:u[0]%g[0],y:u[1]%g[1],width:g[0],height:g[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:b?r.jsx(N0,{radius:m/2,className:h}):r.jsx(v0,{dimensions:C,lineWidth:o,variant:t,className:h})}),r.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${k})`})]})}Fi.displayName="Background";const Bi=N.memo(Fi);function z0(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:r.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function k0(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:r.jsx("path",{d:"M0 0h32v4.2H0z"})})}function S0(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:r.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function E0(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function _0(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Rt({children:e,className:t,...n}){return r.jsx("button",{type:"button",className:oe(["react-flow__controls-button",t]),...n,children:e})}const M0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Vi({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:a,onFitView:c,onInteractiveChange:l,className:f,children:h,position:d="bottom-left",orientation:u="vertical","aria-label":p}){const x=re(),{isInteractive:b,minZoomReached:v,maxZoomReached:y,ariaLabelConfig:g}=J(M0,se),{zoomIn:m,zoomOut:w,fitView:C}=_s(),z=()=>{m(),i==null||i()},k=()=>{w(),a==null||a()},$=()=>{C(o),c==null||c()},P=()=>{x.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),l==null||l(!b)},F=u==="horizontal"?"horizontal":"vertical";return r.jsxs(zn,{className:oe(["react-flow__controls",F,f]),position:d,style:e,"data-testid":"rf__controls","aria-label":p??g["controls.ariaLabel"],children:[t&&r.jsxs(r.Fragment,{children:[r.jsx(Rt,{onClick:z,className:"react-flow__controls-zoomin",title:g["controls.zoomIn.ariaLabel"],"aria-label":g["controls.zoomIn.ariaLabel"],disabled:y,children:r.jsx(z0,{})}),r.jsx(Rt,{onClick:k,className:"react-flow__controls-zoomout",title:g["controls.zoomOut.ariaLabel"],"aria-label":g["controls.zoomOut.ariaLabel"],disabled:v,children:r.jsx(k0,{})})]}),n&&r.jsx(Rt,{className:"react-flow__controls-fitview",onClick:$,title:g["controls.fitView.ariaLabel"],"aria-label":g["controls.fitView.ariaLabel"],children:r.jsx(S0,{})}),s&&r.jsx(Rt,{className:"react-flow__controls-interactive",onClick:P,title:g["controls.interactive.ariaLabel"],"aria-label":g["controls.interactive.ariaLabel"],children:b?r.jsx(_0,{}):r.jsx(E0,{})}),h]})}Vi.displayName="Controls";const I0=N.memo(Vi);function T0({id:e,x:t,y:n,width:s,height:o,style:i,color:a,strokeColor:c,strokeWidth:l,className:f,borderRadius:h,shapeRendering:d,selected:u,onClick:p}){const{background:x,backgroundColor:b}=i||{},v=a||x||b;return r.jsx("rect",{className:oe(["react-flow__minimap-node",{selected:u},f]),x:t,y:n,rx:h,ry:h,width:s,height:o,style:{fill:v,stroke:c,strokeWidth:l},shapeRendering:d,onClick:p?y=>p(y,e):void 0})}const A0=N.memo(T0),$0=e=>e.nodes.map(t=>t.id),Fn=e=>e instanceof Function?e:()=>e;function P0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:o,nodeComponent:i=A0,onClick:a}){const c=J($0,se),l=Fn(t),f=Fn(e),h=Fn(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return r.jsx(r.Fragment,{children:c.map(u=>r.jsx(L0,{id:u,nodeColorFunc:l,nodeStrokeColorFunc:f,nodeClassNameFunc:h,nodeBorderRadius:s,nodeStrokeWidth:o,NodeComponent:i,onClick:a,shapeRendering:d},u))})}function D0({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:s,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:c,onClick:l}){const{node:f,x:h,y:d,width:u,height:p}=J(x=>{const b=x.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const v=b.internals.userNode,{x:y,y:g}=b.internals.positionAbsolute,{width:m,height:w}=ke(v);return{node:v,x:y,y:g,width:m,height:w}},se);return!f||f.hidden||!Bo(f)?null:r.jsx(c,{x:h,y:d,width:u,height:p,style:f.style,selected:!!f.selected,className:s(f),color:t(f),borderRadius:o,strokeColor:n(f),strokeWidth:i,shapeRendering:a,onClick:l,id:f.id})}const L0=N.memo(D0);var R0=N.memo(P0);const O0=200,H0=150,F0=e=>!e.hidden,B0=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Fo(St(e.nodeLookup,{filter:F0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},V0="react-flow__minimap-desc";function Yi({style:e,className:t,nodeStrokeColor:n,nodeColor:s,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:c,bgColor:l,maskColor:f,maskStrokeColor:h,maskStrokeWidth:d,position:u="bottom-right",onClick:p,onNodeClick:x,pannable:b=!1,zoomable:v=!1,ariaLabel:y,inversePan:g,zoomStep:m=1,offsetScale:w=5}){const C=re(),z=N.useRef(null),{boundingRect:k,viewBB:$,rfId:P,panZoom:F,translateExtent:M,flowWidth:A,flowHeight:O,ariaLabelConfig:j}=J(B0,se),T=(e==null?void 0:e.width)??O0,S=(e==null?void 0:e.height)??H0,I=k.width/T,E=k.height/S,_=Math.max(I,E),L=_*T,R=_*S,D=w*_,V=k.x-(L-k.width)/2-D,G=k.y-(R-k.height)/2-D,X=L+D*2,K=R+D*2,B=`${V0}-${P}`,H=N.useRef(0),Y=N.useRef();H.current=_,N.useEffect(()=>{if(z.current&&F)return Y.current=rh({domNode:z.current,panZoom:F,getTransform:()=>C.getState().transform,getViewScale:()=>H.current}),()=>{var U;(U=Y.current)==null||U.destroy()}},[F]),N.useEffect(()=>{var U;(U=Y.current)==null||U.update({translateExtent:M,width:A,height:O,inversePan:g,pannable:b,zoomStep:m,zoomable:v})},[b,v,g,m,M,A,O]);const q=p?U=>{var te;const[ee,ne]=((te=Y.current)==null?void 0:te.pointer(U))||[0,0];p(U,{x:ee,y:ne})}:void 0,Q=x?N.useCallback((U,ee)=>{const ne=C.getState().nodeLookup.get(ee).internals.userNode;x(U,ne)},[]):void 0,Z=y??j["minimap.ariaLabel"];return r.jsx(zn,{position:u,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*_:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:oe(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:r.jsxs("svg",{width:T,height:S,viewBox:`${V} ${G} ${X} ${K}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":B,ref:z,onClick:q,children:[Z&&r.jsx("title",{id:B,children:Z}),r.jsx(R0,{onClick:Q,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:a,nodeComponent:c}),r.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-D},${G-D}h${X+D*2}v${K+D*2}h${-X-D*2}z
73
- M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Yi.displayName="MiniMap";N.memo(Yi);const Y0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,G0={[st.Line]:"right",[st.Handle]:"bottom-right"};function W0({nodeId:e,position:t,variant:n=st.Handle,className:s,style:o=void 0,children:i,color:a,minWidth:c=10,minHeight:l=10,maxWidth:f=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:u,autoScale:p=!0,shouldResize:x,onResizeStart:b,onResize:v,onResizeEnd:y}){const g=wi(),m=typeof e=="string"?e:g,w=re(),C=N.useRef(null),z=n===st.Handle,k=J(N.useCallback(Y0(z&&p),[z,p]),se),$=N.useRef(null),P=t??G0[n];N.useEffect(()=>{if(!(!C.current||!m))return $.current||($.current=bh({domNode:C.current,nodeId:m,getStoreItems:()=>{const{nodeLookup:M,transform:A,snapGrid:O,snapToGrid:j,nodeOrigin:T,domNode:S}=w.getState();return{nodeLookup:M,transform:A,snapGrid:O,snapToGrid:j,nodeOrigin:T,paneDomNode:S}},onChange:(M,A)=>{const{triggerNodeChanges:O,nodeLookup:j,parentLookup:T,nodeOrigin:S}=w.getState(),I=[],E={x:M.x,y:M.y},_=j.get(m);if(_&&_.expandParent&&_.parentId){const L=_.origin??S,R=M.width??_.measured.width??0,D=M.height??_.measured.height??0,V={id:_.id,parentId:_.parentId,rect:{width:R,height:D,...Vo({x:M.x??_.position.x,y:M.y??_.position.y},{width:R,height:D},_.parentId,j,L)}},G=Es([V],j,T,S);I.push(...G),E.x=M.x?Math.max(L[0]*R,M.x):void 0,E.y=M.y?Math.max(L[1]*D,M.y):void 0}if(E.x!==void 0&&E.y!==void 0){const L={id:m,type:"position",position:{...E}};I.push(L)}if(M.width!==void 0&&M.height!==void 0){const R={id:m,type:"dimensions",resizing:!0,setAttributes:u?u==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};I.push(R)}for(const L of A){const R={...L,type:"position"};I.push(R)}O(I)},onEnd:({width:M,height:A})=>{const O={id:m,type:"dimensions",resizing:!1,dimensions:{width:M,height:A}};w.getState().triggerNodeChanges([O])}})),$.current.update({controlPosition:P,boundaries:{minWidth:c,minHeight:l,maxWidth:f,maxHeight:h},keepAspectRatio:d,resizeDirection:u,onResizeStart:b,onResize:v,onResizeEnd:y,shouldResize:x}),()=>{var M;(M=$.current)==null||M.destroy()}},[P,c,l,f,h,d,b,v,y,x]);const F=P.split("-");return r.jsx("div",{className:oe(["react-flow__resize-control","nodrag",...F,n,s]),ref:C,style:{...o,scale:k,...a&&{[z?"backgroundColor":"borderColor"]:a}},children:i})}N.memo(W0);function X0(){const[e,t]=N.useState([]),[n,s]=N.useState(!0),o=ls();return N.useEffect(()=>{let i=!1;return fetch(o("/workflow/claude-hooks")).then(async a=>{if(!i&&a.ok){const c=await a.json();t(c.data)}}).catch(()=>{}).finally(()=>{i||s(!1)}),()=>{i=!0}},[o]),{ccHooks:e,loading:n}}function q0({data:e,selected:t}){const{list:n,scopeCount:s,activeHandles:o}=e,i=c=>!o||o.has(c),a=c=>(o==null?void 0:o.get(c))??n.hex;return r.jsxs("div",{className:"group relative rounded-lg border px-4 py-3 transition-all duration-200",style:{borderColor:t?n.hex:`${n.hex}66`,backgroundColor:`${n.hex}12`,boxShadow:t?`0 0 16px ${n.hex}40`:"none",minWidth:180},children:[i("left")&&r.jsx(de,{type:"target",id:"left",position:W.Left,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("left")}}),i("top")&&r.jsx(de,{type:"target",id:"top",position:W.Top,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("top"),left:"35%"}}),i("bottom-in")&&r.jsx(de,{type:"target",id:"bottom-in",position:W.Bottom,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("bottom-in"),left:"65%"}}),r.jsxs("div",{className:"flex items-center gap-2",children:[n.isEntryPoint&&r.jsx(qr,{className:"h-3.5 w-3.5 shrink-0 fill-current",style:{color:n.hex}}),r.jsx("span",{className:"text-sm font-medium text-foreground",children:n.label}),s>0&&r.jsx("span",{className:"ml-auto rounded-full px-1.5 py-0.5 text-[10px] font-semibold leading-none",style:{backgroundColor:`${n.hex}25`,color:n.hex},children:s})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",style:{minHeight:18},children:[n.supportsBatch&&r.jsxs("span",{className:"flex items-center gap-0.5 rounded bg-zinc-800/60 px-1.5 py-0.5 text-[9px] text-zinc-400",children:[r.jsx(Ur,{className:"h-2.5 w-2.5"}),"batch"]}),n.supportsSprint&&r.jsxs("span",{className:"flex items-center gap-0.5 rounded bg-zinc-800/60 px-1.5 py-0.5 text-[9px] text-zinc-400",children:[r.jsx(rt,{className:"h-2.5 w-2.5"}),"sprint"]})]}),i("top-out")&&r.jsx(de,{type:"source",id:"top-out",position:W.Top,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("top-out"),left:"65%"}}),i("right")&&r.jsx(de,{type:"source",id:"right",position:W.Right,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("right")}}),i("bottom-fwd")&&r.jsx(de,{type:"source",id:"bottom-fwd",position:W.Bottom,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("bottom-fwd"),left:"65%"}}),i("bottom")&&r.jsx(de,{type:"source",id:"bottom",position:W.Bottom,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("bottom"),left:"35%"}})]})}const Gi=N.memo(q0),U0={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"},K0={guard:{bg:"#ef4444",border:"#dc2626"},gate:{bg:"#f59e0b",border:"#d97706"},lifecycle:{bg:"#3b82f6",border:"#2563eb"},observer:{bg:"#6b7280",border:"#4b5563"}};function Z0({id:e,sourceX:t,sourceY:n,targetX:s,targetY:o,sourcePosition:i,targetPosition:a,data:c,selected:l}){const f=c==null?void 0:c.edge,h=(c==null?void 0:c.hookCount)??0,d=c==null?void 0:c.highestCategory,u=(c==null?void 0:c.showHookOverlay)??!1,p=U0[(f==null?void 0:f.direction)??"forward"]??"#22c55e",[x,b,v]=dn({sourceX:t,sourceY:n,targetX:s,targetY:o,sourcePosition:i,targetPosition:a,borderRadius:12,offset:25}),y=d?K0[d]:{bg:"#3b82f6",border:"#2563eb"};return r.jsxs(r.Fragment,{children:[r.jsx(Mt,{id:e,path:x,style:{stroke:p,strokeWidth:l?2.5:1.5,strokeDasharray:(f==null?void 0:f.direction)==="shortcut"?"6 4":void 0,opacity:l?1:.6,filter:l?`drop-shadow(0 0 4px ${p}80)`:void 0}}),r.jsx("defs",{children:r.jsxs("filter",{id:`glow-${e}`,x:"-100%",y:"-100%",width:"300%",height:"300%",children:[r.jsx("feGaussianBlur",{stdDeviation:"5",result:"blur"}),r.jsxs("feMerge",{children:[r.jsx("feMergeNode",{in:"blur"}),r.jsx("feMergeNode",{in:"blur"})]})]})}),r.jsxs("circle",{fill:p,filter:`url(#glow-${e})`,opacity:.35,children:[r.jsx("animate",{attributeName:"r",values:"3;7;3",dur:"1.5s",repeatCount:"indefinite"}),r.jsx("animateMotion",{dur:"3s",repeatCount:"indefinite",path:x})]}),r.jsx("circle",{r:"2.5",fill:p,opacity:1,children:r.jsx("animateMotion",{dur:"3s",repeatCount:"indefinite",path:x})}),r.jsxs(b0,{children:[r.jsx("div",{className:"nodrag nopan pointer-events-auto cursor-pointer rounded px-1.5 py-0.5 text-[9px] font-medium transition-opacity",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${b}px,${v}px)`,color:p,backgroundColor:"rgb(9 9 11 / 0.85)",border:`1px solid ${p}33`,opacity:l?1:0},children:(f==null?void 0:f.label)??""}),u&&h>0&&r.jsx("div",{className:"nodrag nopan pointer-events-none flex items-center justify-center rounded-full text-[8px] font-bold",style:{position:"absolute",transform:`translate(-50%, -120%) translate(${b}px,${v}px)`,width:18,height:18,backgroundColor:y.bg,color:"#fff",border:`2px solid ${y.border}`,boxShadow:`0 0 6px ${y.bg}80`},children:h})]})]})}const Wi=N.memo(Z0),Or=260,Q0=230,J0=160,Hr=140,Ot=16;function Xi(e,t,n,s){const o=[...t].sort((d,u)=>d.order-u.order),i=new Map(o.map((d,u)=>[d.id,u])),a=new Map;for(const d of o)a.set(d.id,[]);const c=[];for(const d of e)d.group&&a.has(d.group)?a.get(d.group).push(d):c.push(d);const l=new Map;let f=0;for(const d of o){l.set(d.id,f);const u=a.get(d.id).length;f+=u===1?J0:u*Q0}const h=[];for(const d of o){const u=i.get(d.id),p=l.get(d.id),x=a.get(d.id);for(let b=0;b<x.length;b++){const v=x[b];h.push({id:v.id,type:"workflow",position:{x:Ot+p+b*Or,y:Ot+u*Hr},data:{list:v,scopeCount:n.get(v.id)??0}})}}if(c.length>0){const d=o.length;for(let u=0;u<c.length;u++){const p=c[u];h.push({id:p.id,type:"workflow",position:{x:Ot+u*Or,y:Ot+d*Hr},data:{list:p,scopeCount:n.get(p.id)??0}})}}return h}function qi(e,t,n,s){const o=new Map(n.map(c=>[c.id,c])),i=new Map(t.map(c=>[c.id,c])),a=["guard","gate","lifecycle","observer"];return e.map(c=>{const l=c.hooks??[],f=l.map(v=>o.get(v)).filter(v=>v!==void 0),h=a.find(v=>f.some(y=>y.category===v)),d=i.get(c.from),u=i.get(c.to),p=(d==null?void 0:d.group)!=null&&d.group===(u==null?void 0:u.group),{sourceHandle:x,targetHandle:b}=Ki(c.direction,p);return{id:`${c.from}:${c.to}`,source:c.from,target:c.to,sourceHandle:x,targetHandle:b,type:"workflow",data:{edge:c,hookCount:l.length,hasBlockingHook:f.some(v=>v.blocking===!0),highestCategory:h,showHookOverlay:s}}})}const ex={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"};function Ui(e,t){const n=new Map(t.map(o=>[o.id,o])),s=new Map;for(const o of e){const i=n.get(o.from),a=n.get(o.to),c=(i==null?void 0:i.group)!=null&&i.group===(a==null?void 0:a.group),{sourceHandle:l,targetHandle:f}=Ki(o.direction,c),h=ex[o.direction]??"#22c55e";s.has(o.from)||s.set(o.from,new Map),s.has(o.to)||s.set(o.to,new Map),s.get(o.from).set(l,h),s.get(o.to).set(f,h)}return s}function Ki(e,t){return e==="backward"?{sourceHandle:"bottom",targetHandle:"bottom-in"}:e==="shortcut"?{sourceHandle:"top-out",targetHandle:"top"}:t?{sourceHandle:"right",targetHandle:"left"}:{sourceHandle:"bottom-fwd",targetHandle:"left"}}const tx={workflow:Gi},nx={workflow:Wi};function sx({engines:e}){const{getProjectName:t,getProjectColor:n,setActiveProjectId:s}=Kr(),o=N.useMemo(()=>[...e.entries()],[e]);return r.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto pb-4",children:o.map(([i,a])=>r.jsx(rx,{projectId:i,engine:a,name:t(i),color:n(i),onNavigate:()=>s(i)},i))})}function rx({engine:e,name:t,color:n,onNavigate:s}){const o=e.getConfig(),i=N.useMemo(()=>[...o.lists].sort((f,h)=>f.order-h.order),[o.lists]),a=N.useMemo(()=>Ui(o.edges,i),[o.edges,i]),c=N.useMemo(()=>Xi(i,o.groups??[],new Map,o.edges).map(f=>({...f,data:{...f.data,activeHandles:a.get(f.id)}})),[i,o.groups,o.edges,a]),l=N.useMemo(()=>qi(o.edges,i,o.hooks??[],!1),[o.edges,i,o.hooks]);return r.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/30",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:`hsl(${n})`}}),r.jsx("span",{className:"text-sm font-medium text-foreground/90",children:t}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[o.name," · ",i.length," lists · ",o.edges.length," edges"]})]}),r.jsx("button",{onClick:s,className:"rounded px-2.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-zinc-800 hover:text-foreground",children:"View & Edit"})]}),r.jsx("div",{className:"h-[280px]",children:r.jsx(Hi,{nodes:c,edges:l,nodeTypes:tx,edgeTypes:nx,fitView:!0,fitViewOptions:{padding:.12},minZoom:.15,maxZoom:1,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},children:r.jsx(Bi,{variant:me.Dots,gap:20,size:1,color:"#27272a"})})})]})}const Zi={guard:{icon:hn,color:"#ef4444",label:"Guards"},gate:{icon:ye,color:"#f59e0b",label:"Gates"},lifecycle:{icon:pn,color:"#3b82f6",label:"Lifecycle"},observer:{icon:Ct,color:"#6b7280",label:"Observers"}},ox=["guard","gate","lifecycle","observer"],ix={blocker:"#ef4444",advisor:"#f59e0b",operator:"#3b82f6",silent:"#6b7280"};function ax({list:e,hooks:t,connectedEdges:n,onClose:s,onHookClick:o}){if(!e)return null;const i=n.filter(l=>l.to===e.id),a=n.filter(l=>l.from===e.id),c=N.useMemo(()=>{const l=new Map;for(const f of t){const h=l.get(f.category);h?h.push(f):l.set(f.category,[f])}return l},[t]);return r.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-zinc-800 bg-zinc-900/95 backdrop-blur",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:e.hex}}),r.jsx("span",{className:"text-sm font-medium",children:e.label})]}),r.jsx("button",{onClick:s,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[r.jsxs(ut,{title:"Properties",children:[r.jsx(Ht,{label:"ID",value:e.id}),r.jsx(Ht,{label:"Order",value:String(e.order)}),e.group&&r.jsx(Ht,{label:"Group",value:e.group}),r.jsx(Ht,{label:"Color",value:e.hex})]}),r.jsxs(ut,{title:"Flags",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.isEntryPoint&&r.jsx(ft,{icon:qr,label:"Entry Point",color:e.hex}),e.supportsBatch&&r.jsx(ft,{icon:Ur,label:"Batch",color:"#22c55e"}),e.supportsSprint&&r.jsx(ft,{icon:rt,label:"Sprint",color:"#6366f1"}),e.gitBranch&&r.jsx(ft,{icon:Zr,label:e.gitBranch,color:"#f59e0b"}),e.sessionKey&&r.jsx(ft,{icon:qc,label:e.sessionKey,color:"#8b5cf6"})]}),!e.isEntryPoint&&!e.supportsBatch&&!e.supportsSprint&&!e.gitBranch&&!e.sessionKey&&r.jsx("span",{className:"text-zinc-600",children:"None"})]}),r.jsx(ut,{title:`Inbound (${i.length})`,children:i.length===0?r.jsx("span",{className:"text-zinc-600",children:"None"}):i.map(l=>r.jsx(Fr,{edge:l,showField:"from"},`${l.from}:${l.to}`))}),r.jsx(ut,{title:`Outbound (${a.length})`,children:a.length===0?r.jsx("span",{className:"text-zinc-600",children:"None"}):a.map(l=>r.jsx(Fr,{edge:l,showField:"to"},`${l.from}:${l.to}`))}),t.length>0&&r.jsx(ut,{title:`Hooks (${t.length})`,children:r.jsx("div",{className:"space-y-3",children:ox.map(l=>{const f=c.get(l);if(!(f!=null&&f.length))return null;const h=Zi[l],d=h.icon;return r.jsxs("div",{children:[r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[r.jsx(d,{className:"h-2.5 w-2.5",style:{color:h.color}}),r.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider",style:{color:h.color},children:h.label})]}),f.map(u=>r.jsx(ux,{hook:u,onClick:o},u.id))]},l)})})})]})]})}function ut({title:e,children:t}){return r.jsxs("div",{children:[r.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),r.jsx("div",{className:"space-y-1.5",children:t})]})}function Ht({label:e,value:t}){return r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-zinc-500",children:e}),r.jsx("span",{className:"font-mono text-zinc-300",children:t})]})}function ft({icon:e,label:t,color:n}){return r.jsxs("span",{className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px]",style:{backgroundColor:`${n}15`,color:n},children:[r.jsx(e,{className:"h-3 w-3"}),t]})}const cx={before:"#eab308",after:"#3b82f6"},lx={shell:"#22c55e",event:"#a855f7",webhook:"#f97316"},dx={shell:we,event:ps,webhook:hs};function ux({hook:e,onClick:t}){const n=cx[e.timing]??"#3b82f6",s=lx[e.type]??"#22c55e",o=dx[e.type]??we,i=ds(e),a=ix[i],c=Zi[e.category],l=c.icon;return r.jsxs("button",{onClick:()=>t==null?void 0:t(e),className:"w-full rounded border bg-zinc-950/50 p-2 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/70",style:{borderColor:e.blocking?"#ef444466":"#27272a"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(l,{className:"h-2.5 w-2.5",style:{color:c.color}}),r.jsx("span",{className:"text-zinc-300",children:e.label}),r.jsx("span",{className:"ml-auto rounded px-1 py-0.5 text-[8px] font-bold uppercase",style:{backgroundColor:`${a}20`,color:a},children:i})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[r.jsx("span",{className:"rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${n}20`,color:n},children:e.timing}),r.jsxs("span",{className:"flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${s}20`,color:s},children:[r.jsx(o,{className:"h-2.5 w-2.5"}),e.type]})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 rounded border border-zinc-800 bg-zinc-900 px-2 py-1 font-mono text-[10px] text-zinc-400",children:[r.jsx(o,{className:"h-3 w-3 shrink-0 text-zinc-600"}),r.jsx("span",{className:"truncate",children:e.target})]}),e.description&&r.jsx("p",{className:"mt-1 text-zinc-500",children:e.description})]})}const fx={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"};function Fr({edge:e,showField:t}){const n=fx[e.direction]??"#22c55e";return r.jsxs("div",{className:"flex items-center gap-2 rounded border border-zinc-800/50 bg-zinc-950/30 px-2 py-1.5",children:[r.jsx("span",{className:"rounded px-1 py-0.5 text-[9px] uppercase",style:{backgroundColor:`${n}20`,color:n},children:e.direction}),r.jsx("span",{className:"text-zinc-400",children:t==="from"?e.from:e.to}),r.jsx("span",{className:"ml-auto text-zinc-600",children:e.label})]})}const hx={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"},Qi={guard:{icon:hn,color:"#ef4444",label:"Guards"},gate:{icon:ye,color:"#f59e0b",label:"Gates"},lifecycle:{icon:pn,color:"#3b82f6",label:"Lifecycle"},observer:{icon:Ct,color:"#6b7280",label:"Observers"}},px=["guard","gate","lifecycle","observer"],xx={blocker:"#ef4444",advisor:"#f59e0b",operator:"#3b82f6",silent:"#6b7280"};function mx({edge:e,hooks:t,onClose:n,onHookClick:s}){if(!e)return null;const o=hx[e.direction]??"#22c55e",i=N.useMemo(()=>{const a=new Map;for(const c of t){const l=a.get(c.category);l?l.push(c):a.set(c.category,[c])}return a},[t]);return r.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-zinc-800 bg-zinc-900/95 backdrop-blur",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[r.jsx("span",{className:"text-zinc-300",children:e.from}),r.jsx(Le,{className:"h-3.5 w-3.5 text-zinc-600"}),r.jsx("span",{className:"text-zinc-300",children:e.to})]}),r.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[r.jsxs(ht,{title:"Transition",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-semibold uppercase",style:{backgroundColor:`${o}20`,color:o},children:e.direction}),r.jsx("span",{className:"text-zinc-300",children:e.label})]}),r.jsx("p",{className:"mt-1.5 text-zinc-500",children:e.description})]}),e.command&&r.jsx(ht,{title:"Command",children:r.jsxs("div",{className:"flex items-center gap-2 rounded border border-zinc-800 bg-zinc-950 px-3 py-2 font-mono text-emerald-400",children:[r.jsx(we,{className:"h-3.5 w-3.5 shrink-0 text-zinc-600"}),e.command]})}),r.jsx(ht,{title:"Behavior",children:r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(Ft,{label:"Confirm",value:e.confirmLevel}),e.dispatchOnly&&r.jsx(Ft,{label:"Dispatch Only",active:!0}),e.humanOnly&&r.jsx(Ft,{label:"Human Only",active:!0}),e.skipServerTransition&&r.jsx(Ft,{label:"Skip Server",active:!0})]})}),e.checklist&&e.checklist.length>0&&r.jsx(ht,{title:`Checklist (${e.checklist.length})`,children:r.jsx("div",{className:"space-y-1.5",children:e.checklist.map((a,c)=>r.jsxs("div",{className:"flex items-start gap-2 text-zinc-400",children:[r.jsx(Jt,{className:"mt-0.5 h-3 w-3 shrink-0 text-zinc-600"}),r.jsx("span",{children:a})]},c))})}),t.length>0&&r.jsx(ht,{title:`Hooks (${t.length})`,children:r.jsx("div",{className:"space-y-3",children:px.map(a=>{const c=i.get(a);if(!(c!=null&&c.length))return null;const l=Qi[a],f=l.icon;return r.jsxs("div",{children:[r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[r.jsx(f,{className:"h-2.5 w-2.5",style:{color:l.color}}),r.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider",style:{color:l.color},children:l.label})]}),c.map(h=>r.jsx(wx,{hook:h,onClick:s},h.id))]},a)})})})]})]})}function ht({title:e,children:t}){return r.jsxs("div",{children:[r.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}const gx={before:"#eab308",after:"#3b82f6"},bx={shell:"#22c55e",event:"#a855f7",webhook:"#f97316"},yx={shell:we,event:ps,webhook:hs};function wx({hook:e,onClick:t}){const n=gx[e.timing]??"#3b82f6",s=bx[e.type]??"#22c55e",o=yx[e.type]??we,i=ds(e),a=xx[i],c=Qi[e.category],l=c.icon;return r.jsxs("button",{onClick:()=>t==null?void 0:t(e),className:"w-full rounded border bg-zinc-950/50 p-2 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/70",style:{borderColor:e.blocking?"#ef444466":"#27272a"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(l,{className:"h-2.5 w-2.5",style:{color:c.color}}),r.jsx("span",{className:"text-zinc-300",children:e.label}),r.jsx("span",{className:"ml-auto rounded px-1 py-0.5 text-[8px] font-bold uppercase",style:{backgroundColor:`${a}20`,color:a},children:i})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[r.jsx("span",{className:"rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${n}20`,color:n},children:e.timing}),r.jsxs("span",{className:"flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${s}20`,color:s},children:[r.jsx(o,{className:"h-2.5 w-2.5"}),e.type]})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 rounded border border-zinc-800 bg-zinc-900 px-2 py-1 font-mono text-[10px] text-zinc-400",children:[r.jsx(o,{className:"h-3 w-3 shrink-0 text-zinc-600"}),r.jsx("span",{className:"truncate",children:e.target})]}),e.description&&r.jsx("p",{className:"mt-1 text-zinc-500",children:e.description})]})}function Ft({label:e,value:t,active:n}){return r.jsxs("span",{className:"rounded border px-1.5 py-0.5 text-[10px]",style:{borderColor:n?"#22c55e33":"#27272a",color:n?"#22c55e":"#a1a1aa",backgroundColor:n?"#22c55e10":"transparent"},children:[e,t?`: ${t}`:""]})}function vx({activeConfigName:e}){const[t,n]=N.useState([]),[s,o]=N.useState(!1),i=ls(),[a,c]=N.useState(!1),[l,f]=N.useState(""),[h,d]=N.useState(!1),[u,p]=N.useState(null),[x,b]=N.useState(!1),v=N.useCallback(async()=>{try{const C=await fetch(i("/workflow/presets"));if(!C.ok)return;const z=await C.json();z.success&&n(z.data)}catch{}},[i]);N.useEffect(()=>{v()},[v]);const y=async C=>{try{const z=await fetch(i(`/workflow/presets/${encodeURIComponent(C)}`));if(!z.ok)return;const k=await z.json();if(!k.success)return;const $=await fetch(i("/workflow/preview"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k.data)});if(!$.ok)return;const P=await $.json();if(!P.success)return;const F=P.data;if(F.removedLists.length===0&&F.addedLists.length===0&&F.orphanedScopes.length===0){await g(k.data,{});return}const A=(k.data.lists??[]).map(O=>O.id);p({presetName:C,config:k.data,plan:F,mappings:{...F.suggestedMappings},newListIds:A}),o(!1)}catch{}},g=async(C,z)=>{b(!0);try{await fetch(i("/workflow/apply"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:C,orphanMappings:z})}),p(null),o(!1)}catch{}finally{b(!1)}},m=async()=>{if(l.trim()){c(!0);try{await fetch(i("/workflow/presets"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l.trim()})}),f(""),d(!1),v()}catch{}finally{c(!1)}}},w=async C=>{try{await fetch(i(`/workflow/presets/${encodeURIComponent(C)}`),{method:"DELETE"}),v()}catch{}};return r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>o(!s),className:"flex items-center gap-1.5 rounded border border-zinc-800 bg-zinc-900 px-3 py-1.5 text-xs text-zinc-300 transition-colors hover:border-zinc-700 hover:text-zinc-100",children:[e,r.jsx(xc,{className:"h-3.5 w-3.5 text-zinc-500"})]}),s&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>o(!1)}),r.jsxs("div",{className:"absolute right-0 top-full z-50 mt-1.5 w-64 rounded-lg border border-zinc-800 bg-zinc-900/95 p-2 shadow-xl backdrop-blur",children:[r.jsx("div",{className:"mb-1 px-2 text-[9px] font-semibold uppercase tracking-wider text-zinc-600",children:"Presets"}),t.length===0?r.jsx("div",{className:"px-2 py-3 text-center text-xs text-zinc-600",children:"No presets saved"}):r.jsx("div",{className:"max-h-48 space-y-0.5 overflow-y-auto",children:t.map(C=>r.jsxs("div",{className:"group flex items-center gap-2 rounded px-2 py-1.5 text-xs hover:bg-zinc-800",children:[r.jsxs("button",{onClick:()=>y(C.name),className:"flex flex-1 items-center gap-2 text-left text-zinc-300",children:[r.jsx(mc,{className:"h-3 w-3 text-zinc-600"}),C.name,C.isDefault&&r.jsx("span",{className:"text-[9px] text-zinc-600",children:"(default)"})]}),!C.isDefault&&r.jsx("button",{onClick:()=>w(C.name),className:"rounded p-0.5 text-zinc-600 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:r.jsx(us,{className:"h-3 w-3"})})]},C.name))}),r.jsx("div",{className:"mt-2 border-t border-zinc-800 pt-2",children:h?r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:l,onChange:C=>f(C.target.value),onKeyDown:C=>C.key==="Enter"&&m(),placeholder:"Preset name...",className:"flex-1 rounded border border-zinc-700 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 outline-none placeholder:text-zinc-700 focus:border-zinc-600",autoFocus:!0}),r.jsx("button",{onClick:m,disabled:a||!l.trim(),className:"rounded bg-zinc-800 px-2 py-1 text-xs text-zinc-300 hover:bg-zinc-700 disabled:opacity-50",children:"Save"})]}):r.jsxs("button",{onClick:()=>d(!0),className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:[r.jsx(oo,{className:"h-3 w-3"}),"Save current as preset"]})})]})]}),u&&r.jsx(Nx,{presetName:u.presetName,plan:u.plan,mappings:u.mappings,newListIds:u.newListIds,applying:x,onUpdateMapping:(C,z)=>{p(k=>k&&{...k,mappings:{...k.mappings,[C]:z}})},onConfirm:()=>g(u.config,u.mappings),onCancel:()=>p(null)})]})}function Nx({presetName:e,plan:t,mappings:n,newListIds:s,applying:o,onUpdateMapping:i,onConfirm:a,onCancel:c}){const l=t.orphanedScopes.length>0,f=t.orphanedScopes.every(h=>n[h.listId]&&n[h.listId].trim().length>0);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-[60] bg-black/60 backdrop-blur-sm",onClick:c}),r.jsx("div",{className:"fixed inset-0 z-[61] flex items-center justify-center p-4",children:r.jsxs("div",{className:"w-full max-w-lg rounded-lg border border-zinc-800 bg-zinc-950 shadow-2xl",onClick:h=>h.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 border-b border-zinc-800 px-5 py-4",children:[r.jsx(ye,{className:"h-5 w-5 text-amber-400"}),r.jsxs("div",{children:[r.jsxs("h3",{className:"text-sm font-medium text-zinc-100",children:['Switch to "',e,'"?']}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:"This will change your workflow and may move scopes between lists."})]})]}),r.jsxs("div",{className:"max-h-[60vh] overflow-y-auto px-5 py-4 space-y-4",children:[t.removedLists.length>0&&r.jsxs("div",{children:[r.jsxs("h4",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-zinc-300",children:[r.jsx(io,{className:"h-3 w-3 text-red-400"}),"Lists being removed"]}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.removedLists.map(h=>r.jsx("span",{className:"rounded bg-red-500/10 px-2 py-0.5 text-xs text-red-300 border border-red-500/20",children:h},h))})]}),t.addedLists.length>0&&r.jsxs("div",{children:[r.jsxs("h4",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-zinc-300",children:[r.jsx(Ae,{className:"h-3 w-3 text-green-400"}),"Lists being added"]}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.addedLists.map(h=>r.jsx("span",{className:"rounded bg-green-500/10 px-2 py-0.5 text-xs text-green-300 border border-green-500/20",children:h},h))})]}),l&&r.jsxs("div",{children:[r.jsxs("h4",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-zinc-300",children:[r.jsx(sl,{className:"h-3 w-3 text-amber-400"}),"Scopes that need to move"]}),r.jsx("p",{className:"mb-3 text-xs text-zinc-500",children:"These scopes are in lists being removed. Choose where each group should be moved."}),r.jsx("div",{className:"space-y-3",children:t.orphanedScopes.map(h=>r.jsxs("div",{className:"rounded border border-zinc-800 bg-zinc-900/50 p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[r.jsx("span",{className:"rounded bg-red-500/10 px-1.5 py-0.5 text-red-300 border border-red-500/20",children:h.listId}),r.jsx(Le,{className:"h-3 w-3 text-zinc-600"}),r.jsxs("select",{value:n[h.listId]??"",onChange:d=>i(h.listId,d.target.value),className:"rounded border border-zinc-700 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"Select destination..."}),s.map(d=>r.jsx("option",{value:d,children:d},d))]})]}),r.jsxs("div",{className:"mt-2 text-xxs text-zinc-500",children:[h.scopeFiles.length," scope",h.scopeFiles.length!==1?"s":"",":"," ",r.jsxs("span",{className:"text-zinc-400",children:[h.scopeFiles.slice(0,5).join(", "),h.scopeFiles.length>5&&` +${h.scopeFiles.length-5} more`]})]})]},h.listId))})]}),t.lostEdges.length>0&&r.jsxs("div",{children:[r.jsx("h4",{className:"mb-1.5 text-xs font-medium text-zinc-300",children:"Transitions being removed"}),r.jsx("div",{className:"space-y-1",children:t.lostEdges.map((h,d)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-zinc-500",children:[r.jsx("span",{children:h.from}),r.jsx(Le,{className:"h-3 w-3"}),r.jsx("span",{children:h.to})]},d))})]}),t.impactSummary&&r.jsx("div",{className:"rounded bg-zinc-900 px-3 py-2 text-xs text-zinc-400 border border-zinc-800",children:t.impactSummary})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-3",children:[r.jsx("button",{onClick:c,className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200 transition-colors",children:"Cancel"}),r.jsx("button",{onClick:a,disabled:o||l&&!f,className:"rounded bg-amber-500/20 border border-amber-500/30 px-3 py-1.5 text-xs text-amber-300 hover:bg-amber-500/30 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:o?"Applying...":"Confirm Switch"})]})]})})]})}function jx({hook:e,open:t,onClose:n}){const[s,o]=N.useState(null),[i,a]=N.useState(!1),[c,l]=N.useState(null),f=ls();return N.useEffect(()=>{if(!e||!t){o(null),l(null);return}let h=!1;return a(!0),l(null),fetch(f(`/workflow/hooks/source?path=${encodeURIComponent(e.scriptPath)}`)).then(async d=>{if(!h)if(d.ok){const u=await d.json();o(u.data)}else{const u=await d.json().catch(()=>({error:`HTTP ${d.status}`}));l(u.error??`Failed to load source (HTTP ${d.status})`),o(null)}}).catch(d=>{h||l(d instanceof Error?d.message:"Network error")}).finally(()=>{h||a(!1)}),()=>{h=!0}},[e==null?void 0:e.id,e==null?void 0:e.scriptPath,t,f]),e?r.jsx(gc,{open:t,onOpenChange:h=>{h||n()},children:r.jsxs(bc,{className:"max-w-[min(56rem,calc(100vw_-_2rem))] h-[80vh] flex flex-col p-0 gap-0 overflow-hidden",children:[r.jsxs(yc,{className:"px-4 pt-3 pb-2",children:[r.jsxs("div",{className:"flex items-center gap-2 pr-8",children:[r.jsx(tn,{className:"h-4 w-4 shrink-0 text-zinc-500"}),r.jsx(wc,{className:"text-sm font-medium text-foreground leading-tight truncate",children:e.label})]}),r.jsx(vc,{className:"mt-1 font-mono text-[11px] text-zinc-500 truncate",children:e.scriptPath})]}),r.jsx("div",{className:"flex-1 min-h-0 border-t border-zinc-800 bg-[#0a0a12]",children:r.jsx(Nc,{className:"h-full",children:r.jsxs("div",{className:"px-2 py-3",children:[i&&r.jsxs("div",{className:"flex items-center gap-2 px-4 py-8 text-xs text-zinc-500",children:[r.jsx(Qr,{className:"h-4 w-4 animate-spin"}),"Loading source..."]}),c&&r.jsxs("div",{className:"px-4 py-8 text-xs text-red-400",children:[r.jsx(tn,{className:"mb-2 h-5 w-5 text-zinc-600"}),c]}),s&&r.jsx(Cx,{content:s.content,filePath:s.filePath}),!i&&!c&&!s&&r.jsx("div",{className:"px-4 py-8 text-xs text-zinc-600 italic",children:"No source available"})]})})}),s&&r.jsxs("div",{className:"border-t border-zinc-800 px-4 py-2 text-[10px] text-zinc-600",children:[s.lineCount," lines"]})]})}):null}function Cx({content:e,filePath:t}){const n=e.split(`
74
- `),s=String(n.length).length;return r.jsxs("div",{children:[r.jsxs("div",{className:"mb-2 flex items-center gap-2 rounded border border-zinc-800/50 bg-zinc-900/50 px-3 py-1.5 font-mono text-[10px] text-zinc-500",children:[r.jsx(tn,{className:"h-3 w-3 shrink-0"}),t]}),r.jsx("pre",{className:"font-mono text-[12px] leading-[1.6]",children:n.map((o,i)=>r.jsxs("div",{className:"flex hover:bg-white/[0.02]",children:[r.jsx("span",{className:"select-none text-right text-zinc-700 pr-3 shrink-0",style:{width:`${s+2}ch`},children:i+1}),r.jsx("span",{className:"text-zinc-300 whitespace-pre overflow-x-auto",children:o||" "})]},i))})]})}function zx(){return r.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-zinc-800 bg-zinc-950/50 p-8 text-center",children:[r.jsxs("div",{className:"flex items-center gap-2 text-zinc-600",children:[r.jsx(rt,{className:"h-4 w-4"}),r.jsx(Jr,{className:"h-4 w-4"})]}),r.jsx("span",{className:"text-xs font-medium text-zinc-500",children:"No hook execution data available"}),r.jsx("p",{className:"max-w-xs text-[10px] text-zinc-600",children:"Hook execution tracking will be added when the Hook & Event Foundation (scope 079) is implemented. This panel will show real-time hook firing events with timestamps, results, and durations."})]})}const kx={guard:{icon:hn,color:"#ef4444",label:"Guards"},gate:{icon:ye,color:"#f59e0b",label:"Gates"},lifecycle:{icon:pn,color:"#3b82f6",label:"Lifecycle"},observer:{icon:Ct,color:"#6b7280",label:"Observers"}},Sx=["guard","gate","lifecycle","observer"],Ex=["SessionStart","PreToolUse","PostToolUse","SessionEnd"],_x={SessionStart:"#22c55e",PreToolUse:"#eab308",PostToolUse:"#3b82f6",SessionEnd:"#ef4444"};function Mx({hooks:e,edges:t,onHookClick:n}){const{workflowHooks:s,ccOnlyHooks:o,stats:i}=N.useMemo(()=>{const l=[],f=[];let h=0;for(const u of e)u.source==="workflow"||u.source==="both"?(l.push(u),u.source==="both"&&h++):f.push(u);const d=t.filter(u=>(u.hooks??[]).length>0).length;return{workflowHooks:l,ccOnlyHooks:f,stats:{total:e.length,workflow:l.length,ccOnly:f.length,shared:h,edgesWithHooks:d}}},[e,t]),a=N.useMemo(()=>{const l=new Map;for(const f of s){if(!f.workflow)continue;const h=f.workflow.category,d=l.get(h);d?d.push(f):l.set(h,[f])}return l},[s]),c=N.useMemo(()=>{var f;const l=new Map;for(const h of o){if(!((f=h.ccTriggers)!=null&&f.length))continue;const d=h.ccTriggers[0],u=d.event,p=d.matcher??"(all)";l.has(u)||l.set(u,[]);const x=l.get(u),b=x.find(v=>v.matcher===p);b?b.hooks.push(h):x.push({matcher:p,hooks:[h]})}return l},[o]);return r.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[r.jsx(Ix,{stats:i}),r.jsxs("section",{children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[r.jsx(xn,{className:"h-4 w-4 text-orange-400"}),r.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Transition Enforcement"}),r.jsxs("span",{className:"text-[10px] text-zinc-500",children:[s.length," hooks on ",i.edgesWithHooks," edges"]})]}),r.jsx("p",{className:"mb-4 text-[11px] text-zinc-500",children:"Hooks that fire during scope transitions"}),r.jsxs("div",{className:"flex gap-1 items-stretch",children:[r.jsx("div",{className:"flex items-center",children:r.jsx("span",{className:"rounded-l bg-yellow-500/10 px-2 py-1 text-[9px] font-semibold uppercase tracking-wider text-yellow-500 [writing-mode:vertical-lr] rotate-180",children:"Before"})}),r.jsx("div",{className:"grid flex-1 grid-cols-3 gap-3",children:Sx.slice(0,3).map((l,f)=>r.jsx(Br,{category:l,hooks:a.get(l)??[],onHookClick:n,showArrow:f<2},l))}),r.jsx("div",{className:"flex flex-col items-center justify-center px-2",children:r.jsx("div",{className:"h-full w-px bg-zinc-800"})}),r.jsx("div",{className:"flex items-center",children:r.jsx("span",{className:"rounded-l bg-cyan-500/10 px-2 py-1 text-[9px] font-semibold uppercase tracking-wider text-cyan-500 [writing-mode:vertical-lr] rotate-180",children:"After"})}),r.jsx("div",{className:"w-56",children:r.jsx(Br,{category:"observer",hooks:a.get("observer")??[],onHookClick:n,showArrow:!1})})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[r.jsx(en,{className:"h-4 w-4 text-emerald-400"}),r.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Session Enforcement"}),r.jsxs("span",{className:"text-[10px] text-zinc-500",children:[o.length," CC hooks"]})]}),r.jsx("p",{className:"mb-4 text-[11px] text-zinc-500",children:"Hooks that fire on Claude Code tool events"}),r.jsx("div",{className:"grid grid-cols-4 gap-3",children:Ex.map((l,f)=>r.jsx(Tx,{event:l,matcherGroups:c.get(l)??[],onHookClick:n,showArrow:f<3},l))})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[r.jsx(Jr,{className:"h-4 w-4 text-zinc-500"}),r.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Execution Log"}),r.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[9px] text-zinc-500",children:"scope 079"})]}),r.jsx(zx,{})]})]})}function Ix({stats:e}){return r.jsxs("div",{className:"flex items-center gap-4 rounded-lg border border-zinc-800 bg-zinc-900/50 px-4 py-2.5",children:[r.jsx(Bn,{icon:rt,color:"#f97316",label:"hooks",value:e.total}),r.jsx(Vn,{}),r.jsx(Bn,{icon:xn,color:"#f97316",label:"workflow",value:e.workflow}),r.jsx(Vn,{}),r.jsx(Bn,{icon:en,color:"#10b981",label:"CC-only",value:e.ccOnly}),r.jsx(Vn,{}),r.jsxs("span",{className:"text-[10px] text-zinc-500",children:[e.shared," shared scripts"]})]})}function Bn({icon:e,color:t,label:n,value:s}){return r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(e,{className:"h-3.5 w-3.5",style:{color:t}}),r.jsx("span",{className:"text-sm font-semibold text-zinc-200",children:s}),r.jsx("span",{className:"text-[10px] text-zinc-500",children:n})]})}function Vn(){return r.jsx("div",{className:"h-4 w-px bg-zinc-800"})}function Br({category:e,hooks:t,onHookClick:n,showArrow:s}){const o=kx[e],i=o.icon;return r.jsxs("div",{className:"relative",children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[r.jsx(i,{className:"h-3 w-3",style:{color:o.color}}),r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:o.color},children:o.label}),r.jsxs("span",{className:"text-[9px] text-zinc-600",children:["(",t.length,")"]})]}),r.jsx("div",{className:"space-y-1.5",children:t.length===0?r.jsxs("div",{className:"rounded border border-dashed border-zinc-800 px-3 py-4 text-center text-[10px] text-zinc-700",children:["No ",o.label.toLowerCase()]}):t.map(a=>r.jsx(Ji,{hook:a,onHookClick:n},a.id))}),s&&r.jsx("div",{className:"absolute -right-2.5 top-1/2 -translate-y-1/2 text-zinc-700",children:r.jsx(eo,{className:"h-4 w-4"})})]})}function Tx({event:e,matcherGroups:t,onHookClick:n,showArrow:s}){const o=_x[e],i=t.reduce((a,c)=>a+c.hooks.length,0);return r.jsxs("div",{className:"relative",children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[r.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:o}}),r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:o},children:e}),i>0&&r.jsxs("span",{className:"text-[9px] text-zinc-600",children:["(",i,")"]})]}),r.jsx("div",{className:"space-y-2",children:t.length===0?r.jsx("div",{className:"rounded border border-dashed border-zinc-800 px-3 py-4 text-center text-[10px] text-zinc-700",children:"No hooks"}):t.map(a=>r.jsxs("div",{children:[a.matcher!=="(all)"&&r.jsx("div",{className:"mb-1 rounded bg-zinc-800/50 px-1.5 py-0.5 font-mono text-[9px] text-zinc-500 w-fit",children:a.matcher}),r.jsx("div",{className:"space-y-1.5",children:a.hooks.map(c=>r.jsx(Ji,{hook:c,onHookClick:n},c.id))})]},a.matcher))}),s&&r.jsx("div",{className:"absolute -right-2.5 top-1/2 -translate-y-1/2 text-zinc-700",children:r.jsx(eo,{className:"h-4 w-4"})})]})}function Ji({hook:e,onHookClick:t}){var o;const n=(o=e.workflow)==null?void 0:o.blocking,s=e.source==="both";return r.jsx("button",{onClick:()=>t(e),className:"w-full rounded border bg-zinc-950/50 px-2.5 py-2 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/70",style:{borderColor:n?"#ef444440":"#27272a"},children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-zinc-300 truncate",children:e.label}),n&&r.jsx(xn,{className:"h-2.5 w-2.5 shrink-0 text-red-400"}),s&&r.jsx("span",{className:"ml-auto shrink-0 rounded bg-emerald-500/15 px-1 py-0.5 text-[8px] font-bold text-emerald-400",children:"+CC"})]})})}const Ax={guard:{icon:hn,color:"#ef4444",label:"Guard"},gate:{icon:ye,color:"#f59e0b",label:"Gate"},lifecycle:{icon:pn,color:"#3b82f6",label:"Lifecycle"},observer:{icon:Ct,color:"#6b7280",label:"Observer"}},$x={blocker:{color:"#ef4444",description:"Blocks transition on failure"},advisor:{color:"#f59e0b",description:"Warns but allows transition"},operator:{color:"#3b82f6",description:"Side-effects during lifecycle"},silent:{color:"#6b7280",description:"Observes without affecting outcome"}},Px={before:"#eab308",after:"#3b82f6"},Dx={shell:we,event:ps,webhook:hs},Lx={shell:"#22c55e",event:"#a855f7",webhook:"#f97316"},Rx={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"},Ox={workflow:{label:"Workflow",color:"#f97316"},"claude-code":{label:"Claude Code",color:"#10b981"},both:{label:"Both",color:"#8b5cf6"}},Hx={SessionStart:"#22c55e",SessionEnd:"#ef4444",PreToolUse:"#eab308",PostToolUse:"#3b82f6"};function Fx({hook:e,edges:t,onClose:n,onViewSource:s,onNavigateToEdge:o}){var b;const i=N.useMemo(()=>e!=null&&e.workflow?t.filter(v=>(v.hooks??[]).includes(e.id)):[],[e,t]);if(!e)return null;const a=!!e.workflow,c=!!((b=e.ccTriggers)!=null&&b.length),l=Ox[e.source],f=a?Ax[e.workflow.category]:null,h=(f==null?void 0:f.icon)??en,d=(f==null?void 0:f.color)??"#10b981",u=a?ds({category:e.workflow.category}):null,p=u?$x[u]:null,x=a?Dx[e.workflow.type]??we:en;return r.jsxs("div",{className:"flex h-full w-96 shrink-0 flex-col rounded-lg border border-zinc-800 bg-zinc-900/95 backdrop-blur",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(h,{className:"h-4 w-4 shrink-0",style:{color:d}}),r.jsx("span",{className:"text-sm font-medium text-zinc-200 truncate",children:e.label})]}),r.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-bold uppercase",style:{backgroundColor:`${l.color}20`,color:l.color},children:l.label}),a&&u&&p&&r.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-bold uppercase",style:{backgroundColor:`${p.color}20`,color:p.color},children:u}),a&&e.workflow.blocking&&r.jsxs("span",{className:"flex items-center gap-1 rounded bg-red-500/15 px-2 py-0.5 text-[10px] font-semibold uppercase text-red-400",children:[r.jsx(xn,{className:"h-2.5 w-2.5"}),"Blocking"]})]}),a&&r.jsxs(Ve,{title:"Workflow Properties",children:[r.jsx(Bt,{label:"Timing",value:e.workflow.timing,color:Px[e.workflow.timing]}),r.jsx(Bt,{label:"Type",value:e.workflow.type,color:Lx[e.workflow.type]}),r.jsx(Bt,{label:"Category",value:e.workflow.category,color:d}),r.jsx(Bt,{label:"Blocking",value:e.workflow.blocking?"Yes":"No",color:e.workflow.blocking?"#ef4444":"#6b7280"})]}),a&&u&&p&&r.jsxs(Ve,{title:"Enforcement",children:[r.jsx("p",{className:"text-zinc-500",children:p.description}),r.jsxs("p",{className:"mt-1 text-[10px] text-zinc-600",children:[e.workflow.category," ",r.jsx("span",{className:"text-zinc-700",children:"→"})," ",r.jsx("span",{style:{color:p.color},children:u})]})]}),a&&e.workflow.description&&r.jsx(Ve,{title:"Description",children:r.jsx("p",{className:"text-zinc-400 leading-relaxed",children:e.workflow.description})}),r.jsx(Ve,{title:"Script Path",children:r.jsxs("div",{className:"flex items-center gap-2 rounded border border-zinc-800 bg-zinc-950 px-3 py-2 font-mono text-[11px] text-emerald-400",children:[r.jsx(x,{className:"h-3.5 w-3.5 shrink-0 text-zinc-600"}),r.jsx("span",{className:"truncate",children:e.scriptPath})]})}),c&&r.jsx(Ve,{title:`Claude Code Triggers (${e.ccTriggers.length})`,children:r.jsx(Bx,{triggers:e.ccTriggers})}),a&&r.jsx(Ve,{title:`Attached Edges (${i.length})`,children:i.length===0?r.jsx("span",{className:"text-zinc-600",children:"No edges reference this hook"}):r.jsx("div",{className:"space-y-1.5",children:i.map(v=>{const y=Rx[v.direction]??"#22c55e";return r.jsxs("button",{onClick:()=>o==null?void 0:o(v.from,v.to),className:"flex w-full items-center gap-2 rounded border border-zinc-800/50 bg-zinc-950/30 px-2 py-1.5 text-left transition-colors hover:border-zinc-700 hover:bg-zinc-900/50",children:[r.jsx("span",{className:"rounded px-1 py-0.5 text-[9px] uppercase",style:{backgroundColor:`${y}20`,color:y},children:v.direction}),r.jsx("span",{className:"text-zinc-300",children:v.from}),r.jsx(Le,{className:"h-2.5 w-2.5 text-zinc-600"}),r.jsx("span",{className:"text-zinc-300",children:v.to}),r.jsx(jc,{className:"ml-auto h-3 w-3 text-zinc-600"})]},`${v.from}:${v.to}`)})})})]}),r.jsx("div",{className:"border-t border-zinc-800 p-3",children:r.jsxs("button",{onClick:()=>s(e),className:"flex w-full items-center justify-center gap-2 rounded border border-zinc-700 bg-zinc-800/50 px-3 py-2 text-xs text-zinc-300 transition-colors hover:border-zinc-600 hover:bg-zinc-800",children:[r.jsx(tn,{className:"h-3.5 w-3.5"}),"View Source Code"]})})]})}function Bx({triggers:e}){return r.jsx("div",{className:"space-y-1.5",children:e.map((t,n)=>{const s=Hx[t.event]??"#10b981";return r.jsxs("div",{className:"flex items-center gap-2 rounded border border-zinc-800/50 bg-zinc-950/30 px-2 py-1.5",children:[r.jsx("span",{className:"rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${s}20`,color:s},children:t.event}),t.matcher&&r.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 font-mono text-[9px] text-zinc-400",children:t.matcher}),t.statusMessage&&r.jsx("span",{className:"ml-auto truncate text-[10px] text-zinc-600",children:t.statusMessage})]},n)})})}function Ve({title:e,children:t}){return r.jsxs("div",{children:[r.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function Bt({label:e,value:t,color:n}){return r.jsxs("div",{className:"flex items-center justify-between py-0.5",children:[r.jsx("span",{className:"text-zinc-500",children:e}),r.jsx("span",{className:"text-zinc-300",style:n?{color:n}:void 0,children:t})]})}function Vx(e){const t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,s=parseInt(e.slice(5,7),16)/255,o=Math.max(t,n,s),i=Math.min(t,n,s),a=(o+i)/2;if(o===i)return`0 0% ${Math.round(a*100)}%`;const c=o-i,l=a>.5?c/(2-o-i):c/(o+i);let f=0;return o===t?f=((n-s)/c+(n<s?6:0))/6:o===n?f=((s-t)/c+2)/6:f=((t-n)/c+4)/6,`${Math.round(f*360)} ${Math.round(l*100)}% ${Math.round(a*100)}%`}function Yx({list:e,config:t,isNew:n,onSave:s,onDelete:o,onClose:i}){const[a,c]=N.useState(()=>structuredClone(e)),[l,f]=N.useState(!1),h=N.useMemo(()=>[...new Set(t.lists.map(v=>v.group).filter(Boolean))],[t.lists]),d=N.useMemo(()=>{const b=[];return a.label.trim()||b.push("Label is required"),/^[a-z0-9-]+$/.test(a.id)||b.push("ID must be lowercase alphanumeric + hyphens"),a.id||b.push("ID is required"),t.lists.some(v=>v.id===a.id&&v.id!==e.id)&&b.push("ID already exists"),a.isEntryPoint&&t.lists.some(v=>v.isEntryPoint&&v.id!==e.id)&&b.push("Another list is already the entry point"),b},[a,t.lists,e.id]),u=N.useCallback((b,v)=>{c(y=>({...y,[b]:v}))},[]),p=N.useCallback(b=>{c(v=>({...v,hex:b,color:Vx(b)}))},[]),x=N.useCallback(()=>{d.length>0||s(a)},[a,d,s]);return r.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-cyan-500/30 bg-zinc-900/95 backdrop-blur",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:a.hex}}),r.jsx("span",{className:"text-sm font-medium",children:n?"New List":"Edit List"})]}),r.jsx("button",{onClick:i,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto p-4 text-xs",children:[r.jsx(Me,{label:"ID",children:r.jsx("input",{value:a.id,onChange:b=>u("id",b.target.value),disabled:!n,className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500 disabled:opacity-50",placeholder:"e.g. review"})}),r.jsx(Me,{label:"Label",children:r.jsx("input",{value:a.label,onChange:b=>u("label",b.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. Review"})}),r.jsx(Me,{label:"Color",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"color",value:a.hex,onChange:b=>p(b.target.value),className:"h-8 w-8 cursor-pointer rounded border border-zinc-700 bg-zinc-800 p-0.5"}),r.jsx("input",{value:a.hex,onChange:b=>p(b.target.value),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none focus:border-zinc-500"})]})}),r.jsx(Me,{label:"Order",children:r.jsx("input",{type:"number",value:a.order,onChange:b=>u("order",parseInt(b.target.value,10)||0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),r.jsx(Me,{label:"Group",children:r.jsxs("select",{value:a.group??"",onChange:b=>u("group",b.target.value||void 0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"None"}),h.map(b=>r.jsx("option",{value:b,children:b},b))]})}),r.jsx(Me,{label:"Git Branch (optional)",children:r.jsx("input",{value:a.gitBranch??"",onChange:b=>u("gitBranch",b.target.value||void 0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. dev"})}),r.jsx(Me,{label:"Session Key (optional)",children:r.jsx("input",{value:a.sessionKey??"",onChange:b=>u("sessionKey",b.target.value||void 0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. COMMIT_SESSION"})}),r.jsx(Me,{label:"Flags",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(Vt,{label:"Entry Point",checked:a.isEntryPoint??!1,onChange:b=>u("isEntryPoint",b||void 0)}),r.jsx(Vt,{label:"Has Directory",checked:a.hasDirectory,onChange:b=>u("hasDirectory",b)}),r.jsx(Vt,{label:"Supports Batch",checked:a.supportsBatch??!1,onChange:b=>u("supportsBatch",b||void 0)}),r.jsx(Vt,{label:"Supports Sprint",checked:a.supportsSprint??!1,onChange:b=>u("supportsSprint",b||void 0)})]})}),d.length>0&&r.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:d.map(b=>r.jsx("p",{className:"text-[10px] text-red-400",children:b},b))})]}),r.jsxs("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-4 py-3",children:[!n&&(l?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[10px] text-red-400",children:"Confirm?"}),r.jsx("button",{onClick:o,className:"rounded bg-red-500/20 px-2 py-1 text-[10px] text-red-400 hover:bg-red-500/30",children:"Delete"}),r.jsx("button",{onClick:()=>f(!1),className:"rounded px-2 py-1 text-[10px] text-zinc-500 hover:text-zinc-300",children:"Cancel"})]}):r.jsx("button",{onClick:()=>f(!0),className:"rounded p-1.5 text-zinc-600 hover:bg-red-500/10 hover:text-red-400",children:r.jsx(us,{className:"h-3.5 w-3.5"})})),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:x,disabled:d.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[r.jsx(to,{className:"h-3 w-3"}),"Apply"]})]})]})}function Me({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function Vt({label:e,checked:t,onChange:n}){return r.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:s=>n(s.target.checked),className:"h-3.5 w-3.5 rounded border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),r.jsx("span",{className:"text-zinc-300",children:e})]})}const Yn=[{value:"forward",label:"Forward",description:"Normal progression through the workflow",icon:Le,arrowColor:"#22c55e",bgActive:"rgba(34,197,94,0.12)",borderActive:"rgba(34,197,94,0.4)",hint:""},{value:"backward",label:"Backward",description:"Return to a previous stage for rework",icon:no,arrowColor:"#f59e0b",bgActive:"rgba(245,158,11,0.12)",borderActive:"rgba(245,158,11,0.4)",hint:"Backward edges are shown as amber dashed lines"},{value:"shortcut",label:"Shortcut",description:"Skip intermediate stages",icon:ao,arrowColor:"#6366f1",bgActive:"rgba(99,102,241,0.12)",borderActive:"rgba(99,102,241,0.4)",hint:"Shortcut edges are shown as dashed lines and may require a checklist confirmation"}];function Gx({value:e,onChange:t,fromLabel:n,toLabel:s}){const o=Yn.find(i=>i.value===e)??Yn[0];return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"space-y-1.5",children:Yn.map(i=>{const a=e===i.value,c=i.icon;return r.jsxs("button",{onClick:()=>t(i.value),className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left transition-all",style:{backgroundColor:a?i.bgActive:"transparent",border:`1px solid ${a?i.borderActive:"#27272a"}`},children:[r.jsx(c,{className:"h-4 w-4 shrink-0",style:{color:a?i.arrowColor:"#52525b"}}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-[11px] font-semibold",style:{color:a?i.arrowColor:"#a1a1aa"},children:i.label}),r.jsx("div",{className:"text-[9px] text-zinc-500 truncate",children:i.description})]})]},i.value)})}),r.jsxs("div",{className:"flex items-center justify-center gap-2 rounded-md border border-zinc-800 bg-zinc-950/50 px-3 py-2",children:[r.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[9px] font-medium text-zinc-300",children:n}),r.jsx("svg",{width:"48",height:"16",viewBox:"0 0 48 16",className:"shrink-0",children:e==="backward"?r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"40",y1:"8",x2:"8",y2:"8",stroke:o.arrowColor,strokeWidth:"1.5",strokeDasharray:"3 2"}),r.jsx("polygon",{points:"8,8 14,4 14,12",fill:o.arrowColor})]}):r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"8",y1:"8",x2:"40",y2:"8",stroke:o.arrowColor,strokeWidth:"1.5",strokeDasharray:e==="shortcut"?"3 2":"none"}),r.jsx("polygon",{points:"40,8 34,4 34,12",fill:o.arrowColor})]})}),r.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[9px] font-medium text-zinc-300",children:s})]}),o.hint&&r.jsx("p",{className:"text-[9px] text-zinc-600 leading-relaxed",children:o.hint})]})}const Wx="093",Xx=["/scope-","/git-","/test-","/session-"];function qx({value:e,onChange:t,allowedPrefixes:n}){const[s,o]=N.useState(!1),i=N.useRef(null),a=n.length>0?n:Xx,c=N.useMemo(()=>e?a.some(p=>e.startsWith(p))?{valid:!0,message:""}:{valid:!1,message:`Command must start with: ${a.join(", ")}`}:null,[e,a]),l=N.useMemo(()=>e?e.replace("{id}",Wx):null,[e]),f=N.useCallback(u=>{var p;t(u+"{id}"),o(!1),(p=i.current)==null||p.focus()},[t]),h=N.useCallback(()=>{t(null),o(!1)},[t]),d=N.useMemo(()=>{if(!e)return[];const u=[],p=a.find(x=>e.startsWith(x));if(p){u.push({text:p,type:"prefix"});const x=e.slice(p.length);Vr(x,u)}else Vr(e,u);return u},[e,a]);return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("div",{className:"flex items-center rounded border border-zinc-700 bg-zinc-800 focus-within:border-zinc-500",children:[r.jsx(we,{className:"ml-2 h-3 w-3 shrink-0 text-zinc-600"}),r.jsx("input",{ref:i,value:e??"",onChange:u=>t(u.target.value||null),onFocus:()=>!e&&o(!0),onBlur:()=>setTimeout(()=>o(!1),150),className:"flex-1 bg-transparent px-2 py-1.5 font-mono text-xs text-zinc-200 outline-none placeholder:text-zinc-600",placeholder:"/scope-implement {id}"}),e&&r.jsx("button",{onClick:h,className:"mr-1 rounded p-0.5 text-zinc-600 hover:text-zinc-300",children:r.jsx(he,{className:"h-3 w-3"})})]}),s&&!e&&r.jsx("div",{className:"absolute left-0 top-full z-10 mt-1 w-full rounded border border-zinc-700 bg-zinc-800 py-1 shadow-xl",children:a.map(u=>r.jsxs("button",{onMouseDown:()=>f(u),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-zinc-700",children:[r.jsx("span",{className:"font-mono text-cyan-400",children:u.trim()}),r.jsx("span",{className:"text-[9px] text-zinc-600",children:"{id}"})]},u))})]}),e&&d.length>0&&r.jsx("div",{className:"rounded border border-zinc-800 bg-zinc-950/70 px-2.5 py-1.5 font-mono text-xs",children:d.map((u,p)=>r.jsx("span",{style:{color:u.type==="prefix"?"#60a5fa":u.type==="placeholder"?"#facc15":"#e4e4e7"},children:u.text},p))}),l&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[9px] text-zinc-600",children:"Preview:"}),r.jsx("code",{className:"text-[9px] font-mono text-zinc-400",children:l})]}),c&&!c.valid&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-amber-400",children:[r.jsx(ye,{className:"h-3 w-3 shrink-0"}),c.message]}),r.jsxs("p",{className:"text-[9px] text-zinc-600",children:["Use ",r.jsx("code",{className:"rounded bg-zinc-800 px-1 text-yellow-400",children:"{id}"})," as the scope ID placeholder"]})]})}function Vr(e,t){const n=/\{id\}/g;let s=0,o;for(;(o=n.exec(e))!==null;)o.index>s&&t.push({text:e.slice(s,o.index),type:"arg"}),t.push({text:"{id}",type:"placeholder"}),s=o.index+o[0].length;s<e.length&&t.push({text:e.slice(s),type:"arg"})}function ea(e,t,n){const s=e.slice();return s.splice(n<0?s.length+n:n,0,s.splice(t,1)[0]),s}function Ux(e,t){return e.reduce((n,s,o)=>{const i=t.get(s);return i&&(n[o]=i),n},Array(e.length))}function Yt(e){return e!==null&&e>=0}function Kx(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Zx(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const ta=e=>{let{rects:t,activeIndex:n,overIndex:s,index:o}=e;const i=ea(t,s,n),a=t[o],c=i[o];return!c||!a?null:{x:c.left-a.left,y:c.top-a.top,scaleX:c.width/a.width,scaleY:c.height/a.height}},Gt={scaleX:1,scaleY:1},Qx=e=>{var t;let{activeIndex:n,activeNodeRect:s,index:o,rects:i,overIndex:a}=e;const c=(t=i[n])!=null?t:s;if(!c)return null;if(o===n){const f=i[a];return f?{x:0,y:n<a?f.top+f.height-(c.top+c.height):f.top-c.top,...Gt}:null}const l=Jx(i,o,n);return o>n&&o<=a?{x:0,y:-c.height-l,...Gt}:o<n&&o>=a?{x:0,y:c.height+l,...Gt}:{x:0,y:0,...Gt}};function Jx(e,t,n){const s=e[t],o=e[t-1],i=e[t+1];return s?n<t?o?s.top-(o.top+o.height):i?i.top-(s.top+s.height):0:i?i.top-(s.top+s.height):o?s.top-(o.top+o.height):0:0}const na="Sortable",sa=cs.createContext({activeIndex:-1,containerId:na,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:ta,disabled:{draggable:!1,droppable:!1}});function em(e){let{children:t,id:n,items:s,strategy:o=ta,disabled:i=!1}=e;const{active:a,dragOverlay:c,droppableRects:l,over:f,measureDroppableContainers:h}=Ec(),d=_c(na,n),u=c.rect!==null,p=N.useMemo(()=>s.map(z=>typeof z=="object"&&"id"in z?z.id:z),[s]),x=a!=null,b=a?p.indexOf(a.id):-1,v=f?p.indexOf(f.id):-1,y=N.useRef(p),g=!Kx(p,y.current),m=v!==-1&&b===-1||g,w=Zx(i);so(()=>{g&&x&&h(p)},[g,p,x,h]),N.useEffect(()=>{y.current=p},[p]);const C=N.useMemo(()=>({activeIndex:b,containerId:d,disabled:w,disableTransforms:m,items:p,overIndex:v,useDragOverlay:u,sortedRects:Ux(p,l),strategy:o}),[b,d,w.draggable,w.droppable,m,p,v,l,u,o]);return cs.createElement(sa.Provider,{value:C},t)}const tm=e=>{let{id:t,items:n,activeIndex:s,overIndex:o}=e;return ea(n,s,o).indexOf(t)},nm=e=>{let{containerId:t,isSorting:n,wasDragging:s,index:o,items:i,newIndex:a,previousItems:c,previousContainerId:l,transition:f}=e;return!f||!s||c!==i&&o===a?!1:n?!0:a!==o&&t===l},sm={duration:200,easing:"ease"},ra="transform",rm=fs.Transition.toString({property:ra,duration:0,easing:"linear"}),om={roleDescription:"sortable"};function im(e){let{disabled:t,index:n,node:s,rect:o}=e;const[i,a]=N.useState(null),c=N.useRef(n);return so(()=>{if(!t&&n!==c.current&&s.current){const l=o.current;if(l){const f=$c(s.current,{ignoreTransform:!0}),h={x:l.left-f.left,y:l.top-f.top,scaleX:l.width/f.width,scaleY:l.height/f.height};(h.x||h.y)&&a(h)}}n!==c.current&&(c.current=n)},[t,n,s,o]),N.useEffect(()=>{i&&a(null)},[i]),i}function am(e){let{animateLayoutChanges:t=nm,attributes:n,disabled:s,data:o,getNewIndex:i=tm,id:a,strategy:c,resizeObserverConfig:l,transition:f=sm}=e;const{items:h,containerId:d,activeIndex:u,disabled:p,disableTransforms:x,sortedRects:b,overIndex:v,useDragOverlay:y,strategy:g}=N.useContext(sa),m=cm(s,p),w=h.indexOf(a),C=N.useMemo(()=>({sortable:{containerId:d,index:w,items:h},...o}),[d,o,w,h]),z=N.useMemo(()=>h.slice(h.indexOf(a)),[h,a]),{rect:k,node:$,isOver:P,setNodeRef:F}=Mc({id:a,data:C,disabled:m.droppable,resizeObserverConfig:{updateMeasurementsFor:z,...l}}),{active:M,activatorEvent:A,activeNodeRect:O,attributes:j,setNodeRef:T,listeners:S,isDragging:I,over:E,setActivatorNodeRef:_,transform:L}=Ic({id:a,data:C,attributes:{...om,...n},disabled:m.draggable}),R=Tc(F,T),D=!!M,V=D&&!x&&Yt(u)&&Yt(v),G=!y&&I,X=G&&V?L:null,B=V?X??(c??g)({rects:b,activeNodeRect:O,activeIndex:u,overIndex:v,index:w}):null,H=Yt(u)&&Yt(v)?i({id:a,items:h,activeIndex:u,overIndex:v}):w,Y=M==null?void 0:M.id,q=N.useRef({activeId:Y,items:h,newIndex:H,containerId:d}),Q=h!==q.current.items,Z=t({active:M,containerId:d,isDragging:I,isSorting:D,id:a,index:w,items:h,newIndex:q.current.newIndex,previousItems:q.current.items,previousContainerId:q.current.containerId,transition:f,wasDragging:q.current.activeId!=null}),U=im({disabled:!Z,index:w,node:$,rect:k});return N.useEffect(()=>{D&&q.current.newIndex!==H&&(q.current.newIndex=H),d!==q.current.containerId&&(q.current.containerId=d),h!==q.current.items&&(q.current.items=h)},[D,H,d,h]),N.useEffect(()=>{if(Y===q.current.activeId)return;if(Y!=null&&q.current.activeId==null){q.current.activeId=Y;return}const ne=setTimeout(()=>{q.current.activeId=Y},50);return()=>clearTimeout(ne)},[Y]),{active:M,activeIndex:u,attributes:j,data:C,rect:k,index:w,newIndex:H,items:h,isOver:P,isSorting:D,isDragging:I,listeners:S,node:$,overIndex:v,over:E,setNodeRef:R,setActivatorNodeRef:_,setDroppableNodeRef:F,setDraggableNodeRef:T,transform:U??B,transition:ee()};function ee(){if(U||Q&&q.current.newIndex===w)return rm;if(!(G&&!Ac(A)||!f)&&(D||Z))return fs.Transition.toString({...f,property:ra})}}function cm(e,t){var n,s;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(s=e==null?void 0:e.droppable)!=null?s:t.droppable}}function fn(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const lm=[Te.Down,Te.Right,Te.Up,Te.Left],dm=(e,t)=>{let{context:{active:n,collisionRect:s,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:c}}=t;if(lm.includes(e.code)){if(e.preventDefault(),!n||!s)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const u=o.get(d.id);if(u)switch(e.code){case Te.Down:s.top<u.top&&l.push(d);break;case Te.Up:s.top>u.top&&l.push(d);break;case Te.Left:s.left>u.left&&l.push(d);break;case Te.Right:s.left<u.left&&l.push(d);break}});const f=Cc({collisionRect:s,droppableRects:o,droppableContainers:l});let h=zc(f,"id");if(h===(a==null?void 0:a.id)&&f.length>1&&(h=f[1].id),h!=null){const d=i.get(n.id),u=i.get(h),p=u?o.get(u.id):null,x=u==null?void 0:u.node.current;if(x&&p&&d&&u){const v=kc(x).some((z,k)=>c[k]!==z),y=oa(d,u),g=um(d,u),m=v||!y?{x:0,y:0}:{x:g?s.width-p.width:0,y:g?s.height-p.height:0},w={x:p.left,y:p.top};return m.x&&m.y?w:Sc(w,m)}}}};function oa(e,t){return!fn(e)||!fn(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function um(e,t){return!fn(e)||!fn(t)||!oa(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const fm=["Implementation is complete and tested","No merge conflicts with target branch","Tests pass on source branch","Code reviewed","Documentation updated"];function hm({items:e,onChange:t,confirmLevel:n}){const[s,o]=N.useState(""),[i,a]=N.useState(null),[c,l]=N.useState(""),f=N.useId(),h=Pc(Bs(Lc,{activationConstraint:{distance:4}}),Bs(Dc,{coordinateGetter:dm})),d=e.map((g,m)=>`checklist-${m}`),u=N.useCallback(g=>{const{active:m,over:w}=g;if(!w||m.id===w.id)return;const C=d.indexOf(String(m.id)),z=d.indexOf(String(w.id));if(C===-1||z===-1)return;const k=[...e],[$]=k.splice(C,1);k.splice(z,0,$),t(k)},[e,d,t]),p=N.useCallback(()=>{const g=s.trim();g&&(t([...e,g]),o(""))},[s,e,t]),x=N.useCallback(g=>{t(e.filter((m,w)=>w!==g)),i===g&&a(null)},[e,t,i]),b=N.useCallback(g=>{a(g),l(e[g])},[e]),v=N.useCallback(()=>{if(i===null)return;const g=c.trim();if(g&&g!==e[i]){const m=[...e];m[i]=g,t(m)}a(null)},[i,c,e,t]),y=N.useCallback(g=>{e.includes(g)||t([...e,g])},[e,t]);return r.jsxs("div",{className:"space-y-2",children:[e.length>0?r.jsx(Rc,{id:f,sensors:h,collisionDetection:Oc,onDragEnd:u,children:r.jsx(em,{items:d,strategy:Qx,children:r.jsx("div",{className:"space-y-1",children:e.map((g,m)=>r.jsx(pm,{id:d[m],item:g,index:m,isEditing:i===m,editValue:c,onEditValueChange:l,onStartEdit:b,onFinishEdit:v,onRemove:x},d[m]))})})}):r.jsxs("div",{className:"rounded border border-dashed border-zinc-800 bg-zinc-950/30 px-3 py-4 text-center",children:[r.jsx(Hc,{className:"mx-auto mb-1.5 h-4 w-4 text-zinc-700"}),r.jsx("p",{className:"text-[10px] text-zinc-600",children:"No checklist items. Add items that must be acknowledged before this transition."})]}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:s,onChange:g=>o(g.target.value),onKeyDown:g=>g.key==="Enter"&&p(),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2 py-1 text-xs text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"New item..."}),r.jsx("button",{onClick:p,disabled:!s.trim(),className:"rounded bg-zinc-800 p-1.5 text-zinc-400 hover:bg-zinc-700 hover:text-zinc-200 disabled:opacity-40",children:r.jsx(Ae,{className:"h-3 w-3"})})]}),r.jsxs("div",{children:[r.jsx("span",{className:"mb-1 block text-[9px] font-medium text-zinc-600",children:"Quick add:"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:fm.filter(g=>!e.includes(g)).map(g=>r.jsxs("button",{onClick:()=>y(g),className:"rounded border border-zinc-800 bg-zinc-950/50 px-1.5 py-0.5 text-[9px] text-zinc-500 transition-colors hover:border-zinc-700 hover:text-zinc-300",children:["+ ",g.length>30?`${g.slice(0,30)}…`:g]},g))})]}),n==="full"&&e.length>0&&r.jsxs("div",{className:"rounded border border-violet-500/20 bg-violet-500/5 p-2",children:[r.jsx("span",{className:"text-[9px] font-medium text-violet-400",children:"Dispatch preview:"}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:e.map((g,m)=>r.jsxs("li",{className:"flex items-center gap-1.5 text-[9px] text-zinc-400",children:[r.jsx("span",{className:"h-3 w-3 shrink-0 rounded border border-zinc-600"}),g]},m))})]})]})}function pm({id:e,item:t,index:n,isEditing:s,editValue:o,onEditValueChange:i,onStartEdit:a,onFinishEdit:c,onRemove:l}){const{attributes:f,listeners:h,setNodeRef:d,transform:u,transition:p,isDragging:x}=am({id:e}),b={transform:fs.Transform.toString(u),transition:p,opacity:x?.5:1};return r.jsxs("div",{ref:d,style:b,className:"group flex items-center gap-1.5 rounded border border-zinc-800 bg-zinc-950/30 px-1.5 py-1",children:[r.jsx("button",{...f,...h,className:"cursor-grab touch-none rounded p-0.5 text-zinc-700 hover:text-zinc-500 active:cursor-grabbing",children:r.jsx(ol,{className:"h-3 w-3"})}),s?r.jsx("input",{value:o,onChange:v=>i(v.target.value),onBlur:c,onKeyDown:v=>v.key==="Enter"&&c(),className:"flex-1 bg-transparent text-xs text-zinc-200 outline-none",autoFocus:!0}):r.jsx("span",{onClick:()=>a(n),className:"flex-1 cursor-text truncate text-xs text-zinc-300",children:t}),r.jsx("button",{onClick:()=>l(n),className:"rounded p-0.5 text-zinc-700 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:r.jsx(io,{className:"h-3 w-3"})})]})}function xm({dispatchOnly:e,humanOnly:t,skipServerTransition:n,confirmLevel:s,hasCommand:o,onDispatchOnlyChange:i,onHumanOnlyChange:a,onSkipServerTransitionChange:c,onConfirmLevelChange:l}){return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Gn,{icon:we,label:"Dispatch Only",description:"This transition can only be triggered by a skill command, not by manual drag-and-drop",checked:e,onChange:i}),e&&!o&&r.jsx("p",{className:"ml-6 text-[9px] text-amber-400",children:"No command configured — add one below for this toggle to be effective"}),r.jsx(Gn,{icon:pl,label:"Human Only",description:"This transition requires human confirmation and cannot be triggered by automated processes",checked:t,onChange:a,badge:t?"HUMAN":void 0,badgeColor:"#6366f1"}),r.jsx(Gn,{icon:fl,label:"Skip Server Transition",description:"The skill command handles the status change itself — the server won't move the scope",checked:n,onChange:c}),n&&r.jsx("p",{className:"ml-6 text-[9px] text-amber-400",children:"The bound skill must handle the scope move itself"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Confirmation Mode"}),r.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[r.jsx(Yr,{icon:rt,label:"Quick",description:"Immediate — one click to confirm",active:s==="quick",onClick:()=>l("quick"),color:"#f59e0b"}),r.jsx(Yr,{icon:Jc,label:"Full",description:"Review — must acknowledge checklist",active:s==="full",onClick:()=>l("full"),color:"#8b5cf6"})]}),s==="full"&&r.jsx("p",{className:"mt-1.5 text-[9px] text-violet-400",children:"Users must review the checklist before confirming this transition"})]})]})}function Gn({icon:e,label:t,description:n,checked:s,onChange:o,badge:i,badgeColor:a}){return r.jsxs("label",{className:"flex cursor-pointer gap-2 rounded-md border border-zinc-800 bg-zinc-950/30 px-2.5 py-2 transition-colors hover:border-zinc-700",children:[r.jsxs("div",{className:"relative mt-0.5 h-4 w-7 shrink-0 rounded-full transition-colors",style:{backgroundColor:s?"#22c55e":"#3f3f46"},children:[r.jsx("div",{className:"absolute top-0.5 h-3 w-3 rounded-full bg-white transition-transform",style:{transform:s?"translateX(12px)":"translateX(2px)"}}),r.jsx("input",{type:"checkbox",checked:s,onChange:c=>o(c.target.checked),className:"sr-only"})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(e,{className:"h-3 w-3 text-zinc-400"}),r.jsx("span",{className:"text-[11px] font-medium text-zinc-300",children:t}),i&&r.jsx("span",{className:"rounded px-1 py-0.5 text-[8px] font-bold",style:{backgroundColor:`${a}20`,color:a},children:i})]}),r.jsx("p",{className:"mt-0.5 text-[9px] text-zinc-600 leading-relaxed",children:n})]})]})}function Yr({icon:e,label:t,description:n,active:s,onClick:o,color:i}){return r.jsxs("button",{onClick:o,className:"rounded-md px-2.5 py-2 text-left transition-all",style:{backgroundColor:s?`${i}12`:"transparent",border:`1px solid ${s?`${i}60`:"#27272a"}`},children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(e,{className:"h-3.5 w-3.5",style:{color:s?i:"#52525b"}}),r.jsx("span",{className:"text-[10px] font-semibold",style:{color:s?i:"#a1a1aa"},children:t})]}),r.jsx("p",{className:"mt-0.5 text-[8px]",style:{color:s?"#a1a1aa":"#52525b"},children:n})]})}function mm({edge:e,lists:t}){const n=N.useMemo(()=>[...t].sort((c,l)=>c.order-l.order),[t]),s=t.find(c=>c.id===e.from),o=t.find(c=>c.id===e.to),i=(s==null?void 0:s.order)??-1,a=(o==null?void 0:o.order)??-1;return e.direction==="shortcut"?r.jsx(gm,{sortedLists:n,fromOrder:i,toOrder:a,edge:e}):e.direction==="backward"?r.jsx(bm,{edge:e,fromLabel:(s==null?void 0:s.label)??e.from,toLabel:(o==null?void 0:o.label)??e.to}):r.jsx(ym,{edge:e,fromLabel:(s==null?void 0:s.label)??e.from,toLabel:(o==null?void 0:o.label)??e.to})}function gm({sortedLists:e,fromOrder:t,toOrder:n,edge:s}){const o=e.filter(i=>i.order>Math.min(t,n)&&i.order<Math.max(t,n));return r.jsxs("div",{className:"space-y-2",children:[r.jsx(Is,{icon:ao,color:"#6366f1",label:"Shortcut — Skip Rules"}),r.jsx("div",{className:"flex items-center gap-1 rounded border border-zinc-800 bg-zinc-950/50 px-2.5 py-2 overflow-x-auto",children:e.map((i,a)=>{const c=i.id===s.from,l=i.id===s.to,f=o.some(h=>h.id===i.id);return r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"rounded px-1.5 py-0.5 text-[8px] font-medium whitespace-nowrap",style:{backgroundColor:c||l?"#6366f120":f?"#27272a":"#18181b",color:c||l?"#818cf8":f?"#52525b":"#71717a",border:c||l?"1px solid #6366f140":"1px solid transparent",textDecoration:f?"line-through":"none"},children:i.label}),a<e.length-1&&r.jsx("span",{className:"text-[8px] text-zinc-700",children:"›"})]},i.id)})}),o.length>0?r.jsxs("p",{className:"text-[9px] text-zinc-500",children:[r.jsx("span",{className:"text-indigo-400",children:s.from})," → ",r.jsx("span",{className:"text-indigo-400",children:s.to})," skips ",r.jsx("span",{className:"text-zinc-400",children:o.map(i=>i.label).join(", ")})]}):r.jsx("p",{className:"text-[9px] text-zinc-500",children:"No intermediate lists are skipped."})]})}function bm({edge:e,fromLabel:t,toLabel:n}){const s=["Issue documented","Fix scope created","Root cause identified"];return r.jsxs("div",{className:"space-y-2",children:[r.jsx(Is,{icon:no,color:"#f59e0b",label:"Backward — Revert Rules"}),r.jsxs("div",{className:"flex items-center gap-2 rounded border border-amber-500/20 bg-amber-500/5 px-2.5 py-2",children:[r.jsx("span",{className:"rounded bg-amber-500/20 px-1.5 py-0.5 text-[9px] font-medium text-amber-400",children:t}),r.jsxs("svg",{width:"24",height:"12",viewBox:"0 0 24 12",className:"shrink-0",children:[r.jsx("line",{x1:"20",y1:"6",x2:"4",y2:"6",stroke:"#f59e0b",strokeWidth:"1.5",strokeDasharray:"2 2"}),r.jsx("polygon",{points:"4,6 8,3 8,9",fill:"#f59e0b"})]}),r.jsx("span",{className:"rounded bg-amber-500/20 px-1.5 py-0.5 text-[9px] font-medium text-amber-400",children:n}),r.jsx("span",{className:"ml-auto rounded bg-amber-500/15 px-1.5 py-0.5 text-[8px] font-semibold text-amber-400",children:"REPAIR"})]}),r.jsxs("p",{className:"text-[9px] text-zinc-500",children:[t," → ",n," is a ",r.jsx("span",{className:"text-amber-400",children:"repair"})," operation. Scopes move backward for rework."]}),(!e.checklist||e.checklist.length===0)&&r.jsxs("div",{className:"rounded border border-zinc-800 bg-zinc-950/50 p-2",children:[r.jsxs("div",{className:"flex items-center gap-1 mb-1.5",children:[r.jsx(Fc,{className:"h-3 w-3 text-zinc-600"}),r.jsx("span",{className:"text-[9px] font-medium text-zinc-500",children:"Suggested checklist items"})]}),r.jsx("ul",{className:"space-y-0.5",children:s.map(o=>r.jsxs("li",{className:"text-[9px] text-zinc-600 flex items-center gap-1.5",children:[r.jsx("span",{className:"h-1 w-1 rounded-full bg-zinc-700 shrink-0"}),o]},o))})]})]})}function ym({edge:e,fromLabel:t,toLabel:n}){return r.jsxs("div",{className:"space-y-2",children:[r.jsx(Is,{icon:Le,color:"#22c55e",label:"Forward — Progression"}),r.jsxs("div",{className:"flex items-center gap-2 rounded border border-emerald-500/20 bg-emerald-500/5 px-2.5 py-2",children:[r.jsx("span",{className:"rounded bg-emerald-500/20 px-1.5 py-0.5 text-[9px] font-medium text-emerald-400",children:t}),r.jsxs("svg",{width:"24",height:"12",viewBox:"0 0 24 12",className:"shrink-0",children:[r.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6",stroke:"#22c55e",strokeWidth:"1.5"}),r.jsx("polygon",{points:"20,6 16,3 16,9",fill:"#22c55e"})]}),r.jsx("span",{className:"rounded bg-emerald-500/20 px-1.5 py-0.5 text-[9px] font-medium text-emerald-400",children:n})]}),e.dispatchOnly&&r.jsxs("p",{className:"text-[9px] text-zinc-500",children:["This transition requires a ",r.jsx("span",{className:"text-cyan-400",children:"skill command"})," to trigger."]})]})}function Is({icon:e,color:t,label:n}){return r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(e,{className:"h-3 w-3",style:{color:t}}),r.jsx("span",{className:"text-[10px] font-semibold",style:{color:t},children:n})]})}function wm({edge:e,config:t,onSave:n,onDelete:s,onClose:o}){const[i,a]=N.useState(()=>structuredClone(e)),[c,l]=N.useState(!1),f=N.useMemo(()=>t.lists.map(g=>g.id),[t.lists]),h=N.useMemo(()=>t.hooks??[],[t.hooks]),d=N.useMemo(()=>t.allowedCommandPrefixes??[],[t.allowedCommandPrefixes]),u=N.useMemo(()=>{var g;return((g=t.lists.find(m=>m.id===i.from))==null?void 0:g.label)??i.from},[t.lists,i.from]),p=N.useMemo(()=>{var g;return((g=t.lists.find(m=>m.id===i.to))==null?void 0:g.label)??i.to},[t.lists,i.to]),x=N.useMemo(()=>{const g=[];i.from||g.push("From is required"),i.to||g.push("To is required"),i.from===i.to&&g.push("From and To must be different"),i.label.trim()||g.push("Label is required"),i.description.trim()||g.push("Description is required");const m=`${i.from}:${i.to}`,w=`${e.from}:${e.to}`;return m!==w&&t.edges.some(C=>`${C.from}:${C.to}`===m)&&g.push("An edge with this from:to already exists"),g},[i,e,t.edges]),b=N.useCallback((g,m)=>{a(w=>({...w,[g]:m}))},[]),v=N.useCallback(g=>{a(m=>{const w=m.hooks??[],C=w.includes(g);return{...m,hooks:C?w.filter(z=>z!==g):[...w,g]}})},[]),y=N.useCallback(()=>{x.length>0||n(i)},[i,x,n]);return r.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-cyan-500/30 bg-zinc-900/95 backdrop-blur",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[r.jsx("span",{className:"text-sm font-medium",children:"Edit Edge"}),r.jsx("button",{onClick:o,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto p-4 text-xs",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsx(xe,{label:"From",children:r.jsx("select",{value:i.from,onChange:g=>b("from",g.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:f.map(g=>r.jsx("option",{value:g,children:g},g))})}),r.jsx(xe,{label:"To",children:r.jsx("select",{value:i.to,onChange:g=>b("to",g.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:f.map(g=>r.jsx("option",{value:g,children:g},g))})})]}),r.jsx(xe,{label:"Direction",children:r.jsx(Gx,{value:i.direction,onChange:g=>b("direction",g),fromLabel:u,toLabel:p})}),r.jsx(xe,{label:"Movement Rules",children:r.jsx(mm,{edge:i,lists:t.lists})}),r.jsx(xe,{label:"Label",children:r.jsx("input",{value:i.label,onChange:g=>b("label",g.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),r.jsx(xe,{label:"Description",children:r.jsx("textarea",{value:i.description,onChange:g=>b("description",g.target.value),rows:2,className:"w-full resize-none rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),r.jsx(xe,{label:"Skill Command",children:r.jsx(qx,{value:i.command,onChange:g=>b("command",g),allowedPrefixes:d})}),r.jsx(xe,{label:"Dispatch & Confirmation",children:r.jsx(xm,{dispatchOnly:i.dispatchOnly??!1,humanOnly:i.humanOnly??!1,skipServerTransition:i.skipServerTransition??!1,confirmLevel:i.confirmLevel,hasCommand:i.command!==null,onDispatchOnlyChange:g=>b("dispatchOnly",g||void 0),onHumanOnlyChange:g=>b("humanOnly",g||void 0),onSkipServerTransitionChange:g=>b("skipServerTransition",g||void 0),onConfirmLevelChange:g=>b("confirmLevel",g)})}),r.jsx(xe,{label:`Checklist (${(i.checklist??[]).length})`,children:r.jsx(hm,{items:i.checklist??[],onChange:g=>b("checklist",g.length>0?g:void 0),confirmLevel:i.confirmLevel})}),h.length>0&&r.jsx(xe,{label:`Hooks (${(i.hooks??[]).length} selected)`,children:r.jsx("div",{className:"space-y-1.5",children:h.map(g=>r.jsx(vm,{hook:g,checked:(i.hooks??[]).includes(g.id),onToggle:()=>v(g.id)},g.id))})}),x.length>0&&r.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:x.map(g=>r.jsx("p",{className:"text-[10px] text-red-400",children:g},g))})]}),r.jsxs("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-4 py-3",children:[c?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[10px] text-red-400",children:"Confirm?"}),r.jsx("button",{onClick:s,className:"rounded bg-red-500/20 px-2 py-1 text-[10px] text-red-400 hover:bg-red-500/30",children:"Delete"}),r.jsx("button",{onClick:()=>l(!1),className:"rounded px-2 py-1 text-[10px] text-zinc-500 hover:text-zinc-300",children:"Cancel"})]}):r.jsx("button",{onClick:()=>l(!0),className:"rounded p-1.5 text-zinc-600 hover:bg-red-500/10 hover:text-red-400",children:r.jsx(us,{className:"h-3.5 w-3.5"})}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:y,disabled:x.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[r.jsx(to,{className:"h-3 w-3"}),"Apply"]})]})]})}function xe({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function vm({hook:e,checked:t,onToggle:n}){return r.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2 py-1.5",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:n,className:"h-3.5 w-3.5 rounded border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("span",{className:"text-zinc-300",children:e.label}),r.jsxs("span",{className:"ml-1.5 text-[9px] text-zinc-600",children:[e.timing," · ",e.type]})]})]})}function Nm({canUndo:e,canRedo:t,changeCount:n,validation:s,saving:o,onAddList:i,onAddEdge:a,onConfigSettings:c,onUndo:l,onRedo:f,onSave:h,onDiscard:d,onPreview:u}){return r.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-cyan-500/30 bg-zinc-900/95 px-3 py-2 shadow-lg backdrop-blur",children:[r.jsx(Ye,{icon:Ae,label:"List",onClick:i,color:"blue"}),r.jsx(Ye,{icon:Zr,label:"Edge",onClick:a,color:"blue"}),r.jsx(Ye,{icon:ro,label:"Config",onClick:c}),r.jsx(Wn,{}),r.jsx(Ye,{icon:Bc,onClick:l,disabled:!e}),r.jsx(Ye,{icon:dl,onClick:f,disabled:!t}),n>0&&r.jsxs("span",{className:"rounded-full bg-amber-500/20 px-2 py-0.5 text-[9px] font-semibold text-amber-400",children:[n," change",n!==1?"s":""]}),r.jsx(Wn,{}),s.valid?r.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-emerald-400",children:[r.jsx(Jt,{className:"h-3.5 w-3.5"}),"Valid"]}):r.jsxs("span",{className:"group relative flex items-center gap-1 text-[10px] text-red-400",children:[r.jsx(ye,{className:"h-3.5 w-3.5"}),s.errors.length," error",s.errors.length!==1?"s":"",r.jsx("div",{className:"absolute bottom-full left-0 z-50 mb-2 hidden w-64 rounded border border-red-500/30 bg-zinc-900 p-2 shadow-xl group-hover:block",children:s.errors.map(p=>r.jsx("p",{className:"text-[10px] text-red-400",children:p},p))})]}),r.jsx(Wn,{}),r.jsx(Ye,{icon:Ct,label:"Preview",onClick:u}),r.jsxs("button",{onClick:h,disabled:!s.valid||n===0||o,className:"flex items-center gap-1.5 rounded bg-emerald-600 px-3 py-1.5 text-[11px] font-medium text-white transition-colors hover:bg-emerald-500 disabled:opacity-40",children:[r.jsx(oo,{className:"h-3 w-3"}),o?"Saving...":"Save"]}),r.jsxs("button",{onClick:d,className:"flex items-center gap-1.5 rounded bg-red-600/80 px-3 py-1.5 text-[11px] font-medium text-white transition-colors hover:bg-red-500",children:[r.jsx(Zc,{className:"h-3 w-3"}),"Discard"]})]})}function Ye({icon:e,label:t,onClick:n,disabled:s,color:o}){const i=o==="blue";return r.jsxs("button",{onClick:n,disabled:s,className:"flex items-center gap-1 rounded px-2 py-1.5 text-[10px] font-medium transition-colors disabled:opacity-30",style:{color:i?"#3b82f6":"#a1a1aa",backgroundColor:"transparent"},onMouseEnter:a=>{a.currentTarget.style.backgroundColor=i?"#3b82f615":"#27272a"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="transparent"},children:[r.jsx(e,{className:"h-3.5 w-3.5"}),t]})}function Wn(){return r.jsx("div",{className:"h-4 w-px bg-zinc-800"})}function jm(e){const t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,s=parseInt(e.slice(5,7),16)/255,o=Math.max(t,n,s),i=Math.min(t,n,s),a=(o+i)/2;if(o===i)return`0 0% ${Math.round(a*100)}%`;const c=o-i,l=a>.5?c/(2-o-i):c/(o+i);let f=0;return o===t?f=((n-s)/c+(n<s?6:0))/6:o===n?f=((s-t)/c+2)/6:f=((t-n)/c+4)/6,`${Math.round(f*360)} ${Math.round(l*100)}% ${Math.round(a*100)}%`}function Cm({open:e,onOpenChange:t,config:n,onAdd:s}){const[o,i]=N.useState(""),[a,c]=N.useState(""),[l,f]=N.useState("#3b82f6"),[h,d]=N.useState(""),u=N.useMemo(()=>[...new Set(n.lists.map(g=>g.group).filter(Boolean))],[n.lists]),p=N.useMemo(()=>Math.max(0,...n.lists.map(y=>y.order)),[n.lists]),x=N.useMemo(()=>{const y=[];return o?/^[a-z0-9-]+$/.test(o)?n.lists.some(g=>g.id===o)&&y.push("ID already exists"):y.push("ID must be lowercase alphanumeric + hyphens"):y.push("ID is required"),a.trim()||y.push("Label is required"),y},[o,a,n.lists]),b=N.useCallback(()=>{i(""),c(""),f("#3b82f6"),d("")},[]),v=N.useCallback(()=>{if(x.length>0)return;const y={id:o,label:a.trim(),order:p+1,color:jm(l),hex:l,hasDirectory:!0,...h?{group:h}:{}};s(y),b(),t(!1)},[x,o,a,l,h,p,s,b,t]);return r.jsx(ss,{open:e,onOpenChange:t,children:r.jsxs(rs,{children:[r.jsx(os,{className:"fixed inset-0 z-40 bg-black/60 backdrop-blur-sm"}),r.jsxs(is,{className:"fixed left-1/2 top-1/2 z-50 w-96 -translate-x-1/2 -translate-y-1/2 rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-5 py-4",children:[r.jsxs(as,{className:"flex items-center gap-2 text-sm font-medium text-zinc-100",children:[r.jsx(Ae,{className:"h-4 w-4 text-cyan-400"}),"Add List"]}),r.jsx(Ke,{className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"space-y-4 p-5 text-xs",children:[r.jsxs("div",{className:"flex items-center gap-3 rounded border border-zinc-800 bg-zinc-950/50 p-3",children:[r.jsx("div",{className:"h-5 w-5 rounded",style:{backgroundColor:l}}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-zinc-200",children:a||"New List"}),r.jsx("p",{className:"font-mono text-[10px] text-zinc-500",children:o||"list-id"})]})]}),r.jsx(Wt,{label:"ID",children:r.jsx("input",{value:o,onChange:y=>i(y.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. review",autoFocus:!0})}),r.jsx(Wt,{label:"Label",children:r.jsx("input",{value:a,onChange:y=>c(y.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. Review"})}),r.jsx(Wt,{label:"Color",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"color",value:l,onChange:y=>f(y.target.value),className:"h-8 w-8 cursor-pointer rounded border border-zinc-700 bg-zinc-800 p-0.5"}),r.jsx("input",{value:l,onChange:y=>f(y.target.value),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 font-mono text-zinc-200 outline-none focus:border-zinc-500"})]})}),r.jsx(Wt,{label:"Group",children:r.jsxs("select",{value:h,onChange:y=>d(y.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"None"}),u.map(y=>r.jsx("option",{value:y,children:y},y))]})}),x.length>0&&o.length>0&&r.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:x.map(y=>r.jsx("p",{className:"text-[10px] text-red-400",children:y},y))})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-4",children:[r.jsx(Ke,{className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:"Cancel"}),r.jsxs("button",{onClick:v,disabled:x.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[r.jsx(Ae,{className:"h-3.5 w-3.5"}),"Add List"]})]})]})]})})}function Wt({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}const zm=["forward","backward","shortcut"],km=["quick","full"],Sm={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"};function Em({open:e,onOpenChange:t,config:n,onAdd:s}){const[o,i]=N.useState(""),[a,c]=N.useState(""),[l,f]=N.useState("forward"),[h,d]=N.useState(""),[u,p]=N.useState(""),[x,b]=N.useState("quick"),v=N.useMemo(()=>n.lists.map(w=>w.id),[n.lists]),y=N.useMemo(()=>{const w=[];return o||w.push("From is required"),a||w.push("To is required"),o&&a&&o===a&&w.push("From and To must be different"),o&&a&&n.edges.some(C=>C.from===o&&C.to===a)&&w.push("An edge with this from:to already exists"),h.trim()||w.push("Label is required"),w},[o,a,h,n.edges]),g=N.useCallback(()=>{i(""),c(""),f("forward"),d(""),p(""),b("quick")},[]),m=N.useCallback(()=>{if(y.length>0)return;const w={from:o,to:a,direction:l,label:h.trim(),description:`Transition from ${o} to ${a}`,command:u.trim()||null,confirmLevel:x};s(w),g(),t(!1)},[y,o,a,l,h,u,x,s,g,t]);return r.jsx(ss,{open:e,onOpenChange:t,children:r.jsxs(rs,{children:[r.jsx(os,{className:"fixed inset-0 z-40 bg-black/60 backdrop-blur-sm"}),r.jsxs(is,{className:"fixed left-1/2 top-1/2 z-50 w-96 -translate-x-1/2 -translate-y-1/2 rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-5 py-4",children:[r.jsxs(as,{className:"flex items-center gap-2 text-sm font-medium text-zinc-100",children:[r.jsx(Ae,{className:"h-4 w-4 text-cyan-400"}),"Add Edge"]}),r.jsx(Ke,{className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"space-y-4 p-5 text-xs",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(Ge,{label:"From",children:r.jsxs("select",{value:o,onChange:w=>i(w.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"Select..."}),v.map(w=>r.jsx("option",{value:w,children:w},w))]})}),r.jsx(Ge,{label:"To",children:r.jsxs("select",{value:a,onChange:w=>c(w.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"Select..."}),v.map(w=>r.jsx("option",{value:w,children:w},w))]})})]}),r.jsx(Ge,{label:"Direction",children:r.jsx("div",{className:"flex gap-1",children:zm.map(w=>{const C=Sm[w];return r.jsx("button",{onClick:()=>f(w),className:"flex-1 rounded px-2 py-1.5 text-[10px] font-medium uppercase transition-colors",style:{backgroundColor:l===w?`${C}20`:"transparent",color:l===w?C:"#71717a",border:`1px solid ${l===w?`${C}40`:"#27272a"}`},children:w},w)})})}),r.jsx(Ge,{label:"Label",children:r.jsx("input",{value:h,onChange:w=>d(w.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. Implement"})}),r.jsx(Ge,{label:"Command (optional)",children:r.jsx("input",{value:u,onChange:w=>p(w.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"/scope-implement {id}"})}),r.jsx(Ge,{label:"Confirm Level",children:r.jsx("div",{className:"flex gap-1",children:km.map(w=>r.jsx("button",{onClick:()=>b(w),className:"flex-1 rounded px-2 py-1.5 text-[10px] font-medium uppercase transition-colors",style:{backgroundColor:x===w?"#22c55e20":"transparent",color:x===w?"#22c55e":"#71717a",border:`1px solid ${x===w?"#22c55e40":"#27272a"}`},children:w},w))})}),y.length>0&&o.length>0&&a.length>0&&r.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:y.map(w=>r.jsx("p",{className:"text-[10px] text-red-400",children:w},w))})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-4",children:[r.jsx(Ke,{className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:"Cancel"}),r.jsxs("button",{onClick:m,disabled:y.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[r.jsx(Ae,{className:"h-3.5 w-3.5"}),"Add Edge"]})]})]})]})})}function Ge({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function _m({open:e,onOpenChange:t,config:n,plan:s,loading:o,error:i,onApply:a}){const[c,l]=N.useState({});N.useMemo(()=>{s!=null&&s.suggestedMappings&&l({...s.suggestedMappings})},[s==null?void 0:s.suggestedMappings]);const f=N.useMemo(()=>n.lists.map(u=>u.id),[n.lists]),h=N.useMemo(()=>s?s.orphanedScopes.every(u=>c[u.listId]):!0,[s,c]),d=N.useCallback(()=>{h&&a(c)},[h,c,a]);return r.jsx(ss,{open:e,onOpenChange:t,children:r.jsxs(rs,{children:[r.jsx(os,{className:"fixed inset-0 z-40 bg-black/60 backdrop-blur-sm"}),r.jsxs(is,{className:"fixed left-1/2 top-1/2 z-50 max-h-[80vh] w-[520px] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-5 py-4",children:[r.jsxs(as,{className:"flex items-center gap-2 text-sm font-medium text-zinc-100",children:[r.jsx(ye,{className:"h-4 w-4 text-amber-400"}),"Migration Preview"]}),r.jsx(Ke,{className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-5 text-xs",children:[o&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-zinc-500",children:[r.jsx(Qr,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{children:"Computing migration impact..."})]}),i&&r.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-3 text-red-400",children:i}),s&&!o&&r.jsxs("div",{className:"space-y-4",children:[!s.valid&&r.jsxs("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-3",children:[r.jsx("p",{className:"mb-2 font-semibold text-red-400",children:"Validation Errors"}),s.validationErrors.map(u=>r.jsx("p",{className:"text-red-400",children:u},u))]}),s.valid&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"rounded border border-zinc-800 bg-zinc-950/50 p-3",children:r.jsx("p",{className:"text-zinc-300",children:s.impactSummary})}),s.addedLists.length>0&&r.jsx(Xt,{title:`Added Lists (${s.addedLists.length})`,children:r.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.addedLists.map(u=>r.jsxs("span",{className:"rounded bg-emerald-500/15 px-2 py-1 font-mono text-emerald-400",children:["+ ",u]},u))})}),s.removedLists.length>0&&r.jsx(Xt,{title:`Removed Lists (${s.removedLists.length})`,children:r.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.removedLists.map(u=>r.jsxs("span",{className:"rounded bg-red-500/15 px-2 py-1 font-mono text-red-400",children:["- ",u]},u))})}),s.lostEdges.length>0&&r.jsx(Xt,{title:`Lost Edges (${s.lostEdges.length})`,children:r.jsx("div",{className:"space-y-1",children:s.lostEdges.map(u=>r.jsxs("div",{className:"flex items-center gap-2 text-zinc-400",children:[r.jsx("span",{className:"font-mono",children:u.from}),r.jsx(Le,{className:"h-3 w-3 text-zinc-600"}),r.jsx("span",{className:"font-mono",children:u.to})]},`${u.from}:${u.to}`))})}),s.orphanedScopes.length>0&&r.jsx(Xt,{title:"Orphaned Scopes — Reassignment Required",children:r.jsx("div",{className:"space-y-3",children:s.orphanedScopes.map(u=>r.jsxs("div",{className:"rounded border border-amber-500/30 bg-amber-500/5 p-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"font-mono text-amber-400",children:u.listId}),r.jsxs("span",{className:"text-zinc-500",children:[u.scopeFiles.length," scope(s)"]})]}),r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[r.jsx("span",{className:"text-zinc-500",children:"Move to:"}),r.jsxs("select",{value:c[u.listId]??"",onChange:p=>l(x=>({...x,[u.listId]:p.target.value})),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"Select destination..."}),f.map(p=>r.jsx("option",{value:p,children:p},p))]})]}),u.scopeFiles.length<=5&&r.jsx("div",{className:"mt-2 space-y-0.5",children:u.scopeFiles.map(p=>r.jsx("p",{className:"font-mono text-[10px] text-zinc-500",children:p},p))})]},u.listId))})}),s.removedLists.length===0&&s.addedLists.length===0&&s.lostEdges.length===0&&s.orphanedScopes.length===0&&r.jsxs("div",{className:"flex items-center gap-2 rounded border border-emerald-500/30 bg-emerald-500/10 p-3 text-emerald-400",children:[r.jsx(Jt,{className:"h-4 w-4"}),r.jsx("span",{children:"No migration needed — configs are compatible"})]})]})]})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-4",children:[r.jsx(Ke,{className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:"Cancel"}),(s==null?void 0:s.valid)&&r.jsxs("button",{onClick:d,disabled:!h,className:"flex items-center gap-1.5 rounded bg-emerald-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-emerald-500 disabled:opacity-40",children:[r.jsx(Jt,{className:"h-3.5 w-3.5"}),"Apply Migration"]})]})]})]})})}function Xt({title:e,children:t}){return r.jsxs("div",{children:[r.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function Mm({prefixes:e,edges:t,onChange:n}){const[s,o]=N.useState(""),[i,a]=N.useState(null),c=N.useMemo(()=>{const d=new Map;for(const u of e){const p=t.filter(x=>{var b;return(b=x.command)==null?void 0:b.startsWith(u)}).map(x=>`${x.from} → ${x.to}`);d.set(u,p)}return d},[e,t]),l=N.useCallback(d=>d.startsWith("/")?d.endsWith(" ")?e.includes(d)?"Already exists":null:"Must end with a space":"Must start with /",[e]),f=N.useCallback(()=>{const d=s,u=l(d);if(u){a(u);return}n([...e,d]),o(""),a(null)},[s,e,n,l]),h=N.useCallback(d=>{n(e.filter(u=>u!==d))},[e,n]);return r.jsxs("div",{className:"space-y-2",children:[e.length>0?r.jsx("div",{className:"space-y-1",children:e.map(d=>{const u=c.get(d)??[];return r.jsxs("div",{className:"group flex items-start gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2.5 py-1.5",children:[r.jsx(we,{className:"mt-0.5 h-3 w-3 shrink-0 text-zinc-600"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("code",{className:"text-xs font-mono text-cyan-400",children:d.trim()}),u.length>0?r.jsxs("p",{className:"mt-0.5 text-[9px] text-zinc-600",children:["Used by: ",u.join(", ")]}):r.jsx("p",{className:"mt-0.5 text-[9px] text-zinc-700",children:"No edges use this prefix"})]}),r.jsx("button",{onClick:()=>h(d),className:"rounded p-0.5 text-zinc-700 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:r.jsx(he,{className:"h-3 w-3"})})]},d)})}):r.jsx("p",{className:"text-[10px] text-zinc-600",children:"No command prefixes configured."}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:s,onChange:d=>{o(d.target.value),a(null)},onKeyDown:d=>d.key==="Enter"&&f(),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2 py-1 font-mono text-xs text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"/prefix "}),r.jsx("button",{onClick:f,disabled:!s,className:"rounded bg-zinc-800 p-1.5 text-zinc-400 hover:bg-zinc-700 hover:text-zinc-200 disabled:opacity-40",children:r.jsx(Ae,{className:"h-3 w-3"})})]}),i&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-amber-400",children:[r.jsx(ye,{className:"h-3 w-3 shrink-0"}),i]}),r.jsxs("p",{className:"text-[9px] text-zinc-600",children:["Prefixes must start with ",r.jsx("code",{className:"text-zinc-400",children:"/"})," and end with a space"]})]})}function Im({config:e,onUpdate:t,onClose:n}){const[s,o]=N.useState(e.name),[i,a]=N.useState(e.description??""),[c,l]=N.useState(e.commitBranchPatterns??""),[f,h]=N.useState(e.branchingMode??"trunk"),d=N.useMemo(()=>e.lists.map(g=>g.id),[e.lists]),[u,p]=N.useState(new Set(e.terminalStatuses??[])),x=N.useMemo(()=>{if(!c)return null;try{return new RegExp(c),null}catch{return"Invalid regex pattern"}},[c]),b=N.useCallback(g=>{p(m=>{const w=new Set(m);return w.has(g)?w.delete(g):w.add(g),w})},[]),v=N.useCallback(g=>{t({...e,allowedCommandPrefixes:g})},[e,t]),y=N.useCallback(()=>{t({...e,name:s.trim()||e.name,description:i.trim()||void 0,branchingMode:f,terminalStatuses:[...u],commitBranchPatterns:c||void 0})},[e,s,i,f,u,c,t]);return r.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-zinc-700 bg-zinc-900/95 backdrop-blur",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ro,{className:"h-3.5 w-3.5 text-zinc-400"}),r.jsx("span",{className:"text-sm font-medium",children:"Config Settings"})]}),r.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[r.jsx(We,{label:"Config Name",children:r.jsx("input",{value:s,onChange:g=>o(g.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),r.jsx(We,{label:"Description",children:r.jsx("textarea",{value:i,onChange:g=>a(g.target.value),rows:2,className:"w-full resize-none rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",placeholder:"Optional config description..."})}),r.jsxs(We,{label:"Branching Mode",children:[r.jsx("div",{className:"flex gap-2",children:["trunk","worktree"].map(g=>r.jsxs("label",{className:"flex flex-1 cursor-pointer items-center gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2 py-1.5",children:[r.jsx("input",{type:"radio",name:"branchingMode",value:g,checked:f===g,onChange:()=>h(g),className:"h-3.5 w-3.5 border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),r.jsx("span",{className:"text-zinc-300 capitalize",children:g})]},g))}),r.jsx("p",{className:"mt-1 text-[9px] text-zinc-600",children:"Trunk: all work on current branch. Worktree: git worktree per scope for isolation."})]}),r.jsx(We,{label:"Allowed Command Prefixes",children:r.jsx(Mm,{prefixes:e.allowedCommandPrefixes??[],edges:e.edges,onChange:v})}),r.jsxs(We,{label:"Terminal Statuses",children:[r.jsx("div",{className:"space-y-1",children:d.map(g=>r.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2 py-1.5",children:[r.jsx("input",{type:"checkbox",checked:u.has(g),onChange:()=>b(g),className:"h-3.5 w-3.5 rounded border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),r.jsx("span",{className:"text-zinc-300",children:g})]},g))}),r.jsx("p",{className:"mt-1 text-[9px] text-zinc-600",children:'Terminal statuses mark a scope as "done" — no further progression expected.'})]}),r.jsxs(We,{label:"Commit Branch Patterns",children:[r.jsx("input",{value:c,onChange:g=>l(g.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"^(dev|feat/|fix/|scope/)"}),x&&r.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[9px] text-amber-400",children:[r.jsx(ye,{className:"h-3 w-3 shrink-0"}),x]}),r.jsx("p",{className:"mt-1 text-[9px] text-zinc-600",children:"Regex pattern for branches that should trigger commit-session hooks."})]})]}),r.jsx("div",{className:"flex items-center justify-end border-t border-zinc-800 px-4 py-3",children:r.jsx("button",{onClick:y,className:"rounded bg-cyan-600 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-cyan-500",children:"Apply"})})]})}function We({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function Gr(e){return e.replace(/^"?\$CLAUDE_PROJECT_DIR"?\/?/,"").replace(/^\.\//,"")}function Tm(e){return e.replace(/\.[^.]+$/,"").split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Am(e,t){const n=new Map;for(const s of e){const o=Gr(s.target);n.set(o,{id:s.id,label:s.label,scriptPath:o,source:"workflow",workflow:{timing:s.timing,type:s.type,category:s.category,blocking:s.blocking??!1,description:s.description}})}for(const s of t){const o=Gr(s.scriptPath),i={event:s.event,matcher:s.matcher,statusMessage:s.statusMessage},a=n.get(o);if(a)a.source="both",a.ccTriggers||(a.ccTriggers=[]),a.ccTriggers.push(i);else{const c=o,l=n.get(c);l?l.ccTriggers.push(i):n.set(c,{id:s.id,label:Tm(s.scriptName),scriptPath:o,source:"claude-code",ccTriggers:[i]})}}return Array.from(n.values())}const $m={workflow:Gi},Pm={workflow:Wi};function Xm(){const{engine:e}=Vc(),{scopes:t}=Yc(),{ccHooks:n}=X0(),{activeProjectId:s,hasMultipleProjects:o,projectEngines:i}=Kr(),a=o&&s===null,c=e.getConfig(),l=Uc(c),f=N.useMemo(()=>!a||i.size===0?!1:!Gc([...i.values()]),[a,i]),h=l.editMode?l.editConfig:c,d=N.useMemo(()=>[...h.lists].sort((B,H)=>B.order-H.order),[h.lists]),u=h.edges,p=h.hooks??[],x=N.useMemo(()=>Am(p,n),[p,n]),[b,v]=N.useState("graph"),[y,g]=N.useState(null),[m,w]=N.useState(null),C=N.useCallback(B=>{const H=x.find(Y=>Y.id===B.id);H&&g(H)},[x]),z=N.useCallback((B,H)=>{w(null),v("graph"),E({type:"edge",from:B,to:H})},[]),k=N.useMemo(()=>{const B=new Map;for(const H of t)B.set(H.status,(B.get(H.status)??0)+1);return B},[t]),$=N.useMemo(()=>Ui(u,d),[u,d]),P=N.useMemo(()=>Xi(d,h.groups??[],k).map(B=>({...B,data:{...B.data,activeHandles:$.get(B.id)}})),[d,h.groups,k,u,$]),F=N.useMemo(()=>qi(u,d,p,!1),[u,d,p]),[M,A,O]=y0(P),[j,T,S]=w0(F);N.useEffect(()=>{A(P)},[P,A]),N.useEffect(()=>{T(F)},[F,T]);const[I,E]=N.useState({type:"none"}),_=N.useCallback((B,H)=>{E({type:"node",listId:H.id})},[]),L=N.useCallback((B,H)=>{const[Y,q]=H.id.split(":");E({type:"edge",from:Y,to:q})},[]),R=N.useCallback(()=>E({type:"none"}),[]),D=I.type==="node"?h.lists.find(B=>B.id===I.listId)??null:null,V=I.type==="edge"?u.find(B=>B.from===I.from&&B.to===I.to)??null:null,G=N.useMemo(()=>{if(!D)return[];const B=u.filter(Y=>Y.from===D.id||Y.to===D.id),H=new Set(B.flatMap(Y=>Y.hooks??[]));return p.filter(Y=>H.has(Y.id))},[D,u,p]),X=N.useMemo(()=>D?u.filter(B=>B.from===D.id||B.to===D.id):[],[D,u]),K=N.useMemo(()=>V?(V.hooks??[]).map(B=>p.find(H=>H.id===B)).filter(B=>B!==void 0):[],[V,p]);return r.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[r.jsx(Wc,{}),r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Xc,{className:"h-4 w-4 text-primary"}),r.jsx("h1",{className:"text-xl font-light",children:"Workflow"}),a&&r.jsx("span",{className:"rounded bg-zinc-500/20 px-2 py-0.5 text-[10px] font-semibold text-zinc-400",children:"READ-ONLY"}),l.editMode&&r.jsx("span",{className:"rounded bg-cyan-500/20 px-2 py-0.5 text-[10px] font-semibold text-cyan-400",children:"EDIT MODE"}),!l.editMode&&r.jsxs("div",{className:"ml-4 flex rounded-lg border border-zinc-800 bg-zinc-900/50 p-0.5",children:[r.jsx(Wr,{active:b==="graph",onClick:()=>v("graph"),icon:r.jsx(al,{className:"h-3 w-3"}),label:"Graph"}),r.jsx(Wr,{active:b==="hooks",onClick:()=>v("hooks"),icon:r.jsx(rt,{className:"h-3 w-3"}),label:"Hooks",count:x.length})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[!l.editMode&&!a&&r.jsxs("button",{onClick:l.enterEditMode,className:"flex items-center gap-1.5 rounded border border-zinc-800 px-3 py-1.5 text-xs text-zinc-400 transition-colors hover:border-cyan-500/40 hover:text-cyan-400",children:[r.jsx(Kc,{className:"h-3.5 w-3.5"}),"Edit"]}),!l.editMode&&!a&&r.jsx(vx,{activeConfigName:c.name})]})]}),l.editMode&&r.jsx("div",{className:"mb-3",children:r.jsx(Nm,{canUndo:l.canUndo,canRedo:l.canRedo,changeCount:l.changeCount,validation:l.validation,saving:l.saving,onAddList:()=>l.setShowAddList(!0),onAddEdge:()=>l.setShowAddEdge(!0),onConfigSettings:()=>{l.setShowConfigSettings(!0),E({type:"none"})},onUndo:l.undo,onRedo:l.redo,onSave:l.save,onDiscard:l.discard,onPreview:l.preview})}),(b==="graph"||l.editMode)&&a&&f&&r.jsx(sx,{engines:i}),(b==="graph"||l.editMode)&&!(a&&f)&&r.jsxs("div",{className:"flex min-h-0 flex-1 gap-3",children:[r.jsx("div",{className:"min-h-0 flex-1 rounded-lg border bg-transparent",style:{borderColor:l.editMode?"#3b82f640":"#27272a"},children:r.jsxs(Hi,{nodes:M,edges:j,onNodesChange:O,onEdgesChange:S,nodeTypes:$m,edgeTypes:Pm,onNodeClick:_,onEdgeClick:L,onPaneClick:R,fitView:!0,fitViewOptions:{padding:.08},minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},children:[r.jsx(Bi,{variant:me.Dots,gap:20,size:1,color:"#27272a"}),r.jsx(I0,{className:"!border-zinc-800 !bg-zinc-900 [&>button]:!border-zinc-800 [&>button]:!bg-zinc-900 [&>button]:!fill-zinc-400 [&>button:hover]:!bg-zinc-800"})]})}),l.editMode&&I.type==="node"&&D&&r.jsx(Yx,{list:D,config:l.editConfig,onSave:B=>{l.updateList(D,B),E({type:"none"})},onDelete:()=>{l.deleteList(D.id),E({type:"none"})},onClose:()=>E({type:"none"})},D.id),l.editMode&&I.type==="edge"&&V&&r.jsx(wm,{edge:V,config:l.editConfig,onSave:B=>{l.updateEdge(V,B),E({type:"none"})},onDelete:()=>{l.deleteEdge(V.from,V.to),E({type:"none"})},onClose:()=>E({type:"none"})},`${V.from}:${V.to}`),l.editMode&&l.showConfigSettings&&I.type==="none"&&r.jsx(Im,{config:l.editConfig,onUpdate:l.updateConfig,onClose:()=>l.setShowConfigSettings(!1)}),!l.editMode&&I.type==="node"&&r.jsx(ax,{list:D,hooks:G,connectedEdges:X,onClose:()=>E({type:"none"}),onHookClick:C}),!l.editMode&&I.type==="edge"&&r.jsx(mx,{edge:V,hooks:K,onClose:()=>E({type:"none"}),onHookClick:C})]}),b==="hooks"&&!l.editMode&&r.jsxs("div",{className:"flex min-h-0 flex-1 gap-3",children:[r.jsx(Mx,{hooks:x,edges:u,onHookClick:w}),m&&r.jsx(Fx,{hook:m,edges:u,onClose:()=>w(null),onViewSource:g,onNavigateToEdge:z})]}),r.jsx(Cm,{open:l.showAddList,onOpenChange:l.setShowAddList,config:l.editConfig,onAdd:l.addList}),r.jsx(Em,{open:l.showAddEdge,onOpenChange:l.setShowAddEdge,config:l.editConfig,onAdd:l.addEdge}),r.jsx(_m,{open:l.showPreview,onOpenChange:l.setShowPreview,config:l.editConfig,plan:l.previewPlan,loading:l.previewLoading,error:l.previewError,onApply:l.applyMigration}),r.jsx(jx,{hook:y,open:y!==null,onClose:()=>g(null)})]})}function Wr({active:e,onClick:t,icon:n,label:s,count:o}){return r.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",style:{backgroundColor:e?"#27272a":"transparent",color:e?"#e4e4e7":"#71717a"},children:[n,s,o!==void 0&&o>0&&r.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[9px] font-semibold leading-none",style:{backgroundColor:e?"#f9731630":"#27272a",color:e?"#f97316":"#71717a"},children:o})]})}export{Xm as default};