@astrale-os/cli 1.0.0-beta.7 → 1.0.0-beta.9

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 (75) hide show
  1. package/README.md +1 -1
  2. package/dist/astrale.js +1531 -1356
  3. package/dist/public/connect-core.js +4 -4
  4. package/dist/types/admin/binding.d.ts +19 -0
  5. package/dist/types/admin/instance/client.d.ts +22 -0
  6. package/dist/types/admin/instance/index.d.ts +2 -0
  7. package/dist/types/admin/instance/model.d.ts +3 -9
  8. package/dist/types/connection/auth.d.ts +3 -0
  9. package/dist/types/connection/call.d.ts +3 -0
  10. package/dist/types/connection/command.d.ts +27 -0
  11. package/dist/types/connection/credential.d.ts +14 -0
  12. package/dist/types/connection/errors.d.ts +1 -0
  13. package/dist/types/connection/exchange.d.ts +9 -0
  14. package/dist/types/connection/failure/classify.d.ts +2 -0
  15. package/dist/types/connection/failure/index.d.ts +5 -0
  16. package/dist/types/connection/failure/model.d.ts +25 -0
  17. package/dist/types/connection/failure/render.d.ts +3 -0
  18. package/dist/types/connection/index.d.ts +8 -0
  19. package/dist/types/connection/reasons.d.ts +37 -0
  20. package/dist/types/connection/self.d.ts +37 -0
  21. package/dist/types/connection/session.d.ts +31 -0
  22. package/dist/types/connection/target.d.ts +38 -0
  23. package/dist/types/lib/admin-instance.d.ts +17 -0
  24. package/dist/types/lib/failure-debug.d.ts +1 -0
  25. package/dist/types/lib/instance.d.ts +7 -1
  26. package/dist/types/lib/log.d.ts +3 -1
  27. package/dist/types/lib/self.d.ts +9 -0
  28. package/package.json +1 -1
  29. package/src/admin/instance/__tests__/client.test.ts +4 -104
  30. package/src/admin/instance/client.ts +2 -96
  31. package/src/admin/instance/index.ts +1 -2
  32. package/src/admin/instance/model.ts +4 -14
  33. package/src/commands/__tests__/admin-instance.test.ts +11 -8
  34. package/src/commands/__tests__/instance-list-rows.test.ts +1 -1
  35. package/src/commands/call-describe.ts +1 -1
  36. package/src/commands/call.ts +2 -2
  37. package/src/commands/domain/list.ts +1 -1
  38. package/src/commands/domain/publish.ts +14 -11
  39. package/src/commands/get.ts +1 -1
  40. package/src/commands/instance/create.ts +8 -16
  41. package/src/commands/instance/delete.ts +7 -6
  42. package/src/commands/instance/list.ts +2 -2
  43. package/src/commands/instance/status.ts +4 -4
  44. package/src/commands/instance/use.ts +16 -12
  45. package/src/commands/introspect.ts +5 -5
  46. package/src/commands/view.ts +3 -3
  47. package/src/connection/__tests__/credential.test.ts +19 -0
  48. package/src/connection/__tests__/target.test.ts +1 -0
  49. package/src/connection/auth.ts +13 -0
  50. package/src/connection/failure/index.ts +1 -1
  51. package/src/connection/session.ts +12 -1
  52. package/src/lib/__tests__/command-dx.test.ts +1 -1
  53. package/src/lib/__tests__/domain-publication.test.ts +6 -1
  54. package/src/lib/__tests__/instance-candidates.test.ts +1 -3
  55. package/src/lib/__tests__/instance-target.test.ts +1 -0
  56. package/src/lib/__tests__/log-errors.test.ts +11 -0
  57. package/src/lib/admin-instance.ts +14 -8
  58. package/src/lib/command-dx.ts +8 -5
  59. package/src/lib/domain-publication.ts +8 -6
  60. package/src/lib/instance-candidates.ts +2 -2
  61. package/src/lib/instance.ts +14 -10
  62. package/src/lib/log.ts +6 -4
  63. package/src/lib/provision-instance.ts +34 -57
  64. package/src/program/__tests__/program.test.ts +20 -4
  65. package/src/program/build.ts +2 -2
  66. package/src/setup/__tests__/instance-step.test.ts +27 -10
  67. package/src/setup/steps/instance.ts +22 -15
  68. package/studio/client/dist/assets/{elk-api-Di4OXGNH.js → elk-api-ByzoDZWH.js} +1 -1
  69. package/studio/client/dist/assets/{index-DTjvkOUX.js → index-B0RCgUOT.js} +4 -4
  70. package/studio/client/dist/assets/{index-BLm6J11H.js → index-N8J8EKlB.js} +2 -2
  71. package/studio/client/dist/index.html +1 -1
  72. package/studio/server/introspect/runtime.test.ts +2 -2
  73. package/viewer/dist/main.js +28 -28
  74. package/src/commands/__tests__/instance-create-hosts.test.ts +0 -29
  75. /package/src/{connection/failure/debug.ts → lib/failure-debug.ts} +0 -0
@@ -1,8 +1,8 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/elk-api-Di4OXGNH.js","assets/index-BLm6J11H.js","assets/index-BiGR8Oo9.css"])))=>i.map(i=>d[i]);
2
- import{S as Ed,n as Is,s as Cd,r as Sd,Q as zi,u as Zn,a as _d,b as Md,c as N,e as Id,d as $d,f as Rd,g as Ad,h as sr,i as Dd,j as Pd,k as be,l as Li,m as Td,R as Od,o as a,p as zd,_ as Ld,q as Hi,t as X,P as $t,v as no,M as Vi,w as ae,x as Rt,T as so,y as Hd,B as Ve,z as mt,A as Me,N as Vd,C as Fi,D as Fd,E as Gn,F as Un,G as Be,H as Bd,I as _e,J as Wd,K as Yd,L as Xd,O as qd,U as Zd,V as Bi,W as $s,X as oo,Y as Gd,Z as Wi,$ as ro,a0 as At,a1 as ct,a2 as Ft,a3 as Yi,a4 as qe,a5 as Ud,a6 as ve,a7 as Kd,a8 as Dt,a9 as Qd,aa as gt,ab as Xi,ac as Jd,ad as io,ae as Kn,af as Qn,ag as Jn,ah as eu,ai as tu,aj as ye,ak as nu,al as su,am as kt,an as ou,ao as ru,ap as iu,aq as au,ar as or,as as ao,at as co,au as lo,av as nn,aw as uo,ax as cu,ay as lu,az as du,aA as uu,aB as fu,aC as qi,aD as fo,aE as Mn,aF as Zi,aG as Gi,aH as Ui,aI as In,aJ as Fe,aK as hu,aL as rt,aM as Ki,aN as Qi,aO as pu,aP as mu,aQ as xe,aR as Ji,aS as gu,aT as xu,aU as yu}from"./index-BLm6J11H.js";function rr(e,t){const n=new Set(t);return e.filter(s=>!n.has(s))}function wu(e,t,n){const s=e.slice(0);return s[t]=n,s}var vu=class extends Ed{#o;#e;#r;#n;#t;#s;#i;#a;#c;#l=[];constructor(e,t,n){super(),this.#o=e,this.#n=n,this.#r=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#h(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#n=t,Is.batch(()=>{const n=this.#t,s=this.#f(this.#r);s.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const o=s.map(u=>u.observer),r=o.map(u=>u.getCurrentResult()),i=n.length!==o.length,c=o.some((u,h)=>u!==n[h]),l=i||c,d=l?!0:r.some((u,h)=>{const f=this.#e[h];return!f||!Cd(u,f)});!l&&!d||(l&&(this.#l=s,this.#t=o),this.#e=r,this.hasListeners()&&(l&&(rr(n,o).forEach(u=>{u.destroy()}),rr(o,n).forEach(u=>{u.subscribe(h=>{this.#h(u,h)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const n=this.#f(e),s=n.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions)),o=n.map(r=>r.defaultedQueryOptions.queryHash);return[s,r=>this.#u(r??s,t,o),()=>this.#d(s,n)]}#d(e,t){const n=new Set;return t.map((s,o)=>{const r=e[o];return s.defaultedQueryOptions.notifyOnChangeProps?r:s.observer.trackResult(r,i=>{n.has(i)||(n.add(i),t.forEach(c=>{c.observer.trackProp(i)}))})})}#u(e,t,n){if(t){const s=this.#c,o=n!==void 0&&s!==void 0&&(s.length!==n.length||n.some((r,i)=>r!==s[i]));return(this.#e!==this.#a||o||t!==this.#i)&&(this.#i=t,this.#a=this.#e,n!==void 0&&(this.#c=n),this.#s=Sd(this.#s,t(e))),this.#s}return e}#m(){return!this.#n?.combine||this.#t.some((e,t)=>e.options.suspense&&this.#e[t]?.data===void 0)}#f(e){const t=new Map;this.#t.forEach(s=>{const o=s.options.queryHash;if(!o)return;const r=t.get(o);r?r.push(s):t.set(o,[s])});const n=[];return e.forEach(s=>{const o=this.#o.defaultQueryOptions(s),r=t.get(o.queryHash)?.shift()??new zi(this.#o,o);n.push({defaultedQueryOptions:o,observer:r})}),n}#h(e,t){const n=this.#t.indexOf(e);n!==-1&&(this.#e=wu(this.#e,n,t),this.#p())}#p(){if(this.hasListeners()){const e=this.#m(),t=this.#s,n=e?t:this.#u(this.#d(this.#e,this.#l),this.#n?.combine);(e||t!==n)&&Is.batch(()=>{this.listeners.forEach(s=>{s(this.#e)})})}}};function hn({queries:e,...t},n){const s=Zn(),o=_d(),r=Md(),i=t.subscribed!==!1,c=N.useMemo(()=>e.map(w=>{const x=s.defaultQueryOptions(w);return x._optimisticResults=o?"isRestoring":i?"optimistic":void 0,x}),[e,s,o,i]);c.forEach(w=>{Id(w);const x=s.getQueryCache().get(w.queryHash);$d(w,r,x)}),Rd(r);const[l]=N.useState(()=>new vu(s,c,t)),[d,u,h]=l.getOptimisticResult(c,t.combine),f=!o&&i;N.useSyncExternalStore(N.useCallback(w=>f?l.subscribe(Is.batchCalls(w)):Ad,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),N.useEffect(()=>{l.setQueries(c,t)},[c,t,l]);const p=d.some((w,x)=>sr(c[x],w))?d.flatMap((w,x)=>{const y=c[x];if(y&&sr(y,w)){const j=new zi(s,y);return Dd(y,j,r)}return[]}):[];if(p.length>0)throw Promise.all(p);const m=d.find((w,x)=>{const y=c[x];return y&&Pd({result:w,errorResetBoundary:r,throwOnError:y.throwOnError,query:s.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(m?.error)throw m.error;return u(h())}const bu=[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]],sn=be("AppWindow",bu);const Nu=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],ju=be("ArrowLeft",Nu);const ku=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ho=be("CircleAlert",ku);const Eu=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M2 10h20",key:"1ir3d8"}]],on=be("FolderClosed",Eu);const Cu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Su=be("FolderOpen",Cu);const _u=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Mu=be("FolderTree",_u);const Iu=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],$u=be("Hexagon",Iu);const Ru=[["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"}]],ea=be("LayoutGrid",Ru);const Au=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]],Du=be("MessageSquarePlus",Au);const Pu=[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]],ir=be("MonitorPlay",Pu);const Tu=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],po=be("Plug",Tu);const Ou=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ta=be("Plus",Ou);const zu=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],ar=be("Unplug",zu);const Lu=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],Hu=be("UserRound",Lu);function me(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=me(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Vu={value:()=>{}};function es(){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 kn(n)}function kn(e){this._=e}function Fu(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}})}kn.prototype=es.prototype={constructor:kn,on:function(e,t){var n=this._,s=Fu(e+"",n),o,r=-1,i=s.length;if(arguments.length<2){for(;++r<i;)if((o=(e=s[r]).type)&&(o=Bu(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++r<i;)if(o=(e=s[r]).type)n[o]=cr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=cr(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 kn(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),s=0,o,r;s<o;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(r=this._[e],s=0,o=r.length;s<o;++s)r[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,r=s.length;o<r;++o)s[o].value.apply(t,n)}};function Bu(e,t){for(var n=0,s=e.length,o;n<s;++n)if((o=e[n]).name===t)return o.value}function cr(e,t,n){for(var s=0,o=e.length;s<o;++s)if(e[s].name===t){e[s]=Vu,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Rs="http://www.w3.org/1999/xhtml";const lr={svg:"http://www.w3.org/2000/svg",xhtml:Rs,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ts(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),lr.hasOwnProperty(t)?{space:lr[t],local:e}:e}function Wu(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Rs&&t.documentElement.namespaceURI===Rs?t.createElement(e):t.createElementNS(n,e)}}function Yu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function na(e){var t=ts(e);return(t.local?Yu:Wu)(t)}function Xu(){}function mo(e){return e==null?Xu:function(){return this.querySelector(e)}}function qu(e){typeof e!="function"&&(e=mo(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var r=t[o],i=r.length,c=s[o]=new Array(i),l,d,u=0;u<i;++u)(l=r[u])&&(d=e.call(l,l.__data__,u,r))&&("__data__"in l&&(d.__data__=l.__data__),c[u]=d);return new Ee(s,this._parents)}function Zu(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Gu(){return[]}function sa(e){return e==null?Gu:function(){return this.querySelectorAll(e)}}function Uu(e){return function(){return Zu(e.apply(this,arguments))}}function Ku(e){typeof e=="function"?e=Uu(e):e=sa(e);for(var t=this._groups,n=t.length,s=[],o=[],r=0;r<n;++r)for(var i=t[r],c=i.length,l,d=0;d<c;++d)(l=i[d])&&(s.push(e.call(l,l.__data__,d,i)),o.push(l));return new Ee(s,o)}function oa(e){return function(){return this.matches(e)}}function ra(e){return function(t){return t.matches(e)}}var Qu=Array.prototype.find;function Ju(e){return function(){return Qu.call(this.children,e)}}function ef(){return this.firstElementChild}function tf(e){return this.select(e==null?ef:Ju(typeof e=="function"?e:ra(e)))}var nf=Array.prototype.filter;function sf(){return Array.from(this.children)}function of(e){return function(){return nf.call(this.children,e)}}function rf(e){return this.selectAll(e==null?sf:of(typeof e=="function"?e:ra(e)))}function af(e){typeof e!="function"&&(e=oa(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var r=t[o],i=r.length,c=s[o]=[],l,d=0;d<i;++d)(l=r[d])&&e.call(l,l.__data__,d,r)&&c.push(l);return new Ee(s,this._parents)}function ia(e){return new Array(e.length)}function cf(){return new Ee(this._enter||this._groups.map(ia),this._parents)}function $n(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}$n.prototype={constructor:$n,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 lf(e){return function(){return e}}function df(e,t,n,s,o,r){for(var i=0,c,l=t.length,d=r.length;i<d;++i)(c=t[i])?(c.__data__=r[i],s[i]=c):n[i]=new $n(e,r[i]);for(;i<l;++i)(c=t[i])&&(o[i]=c)}function uf(e,t,n,s,o,r,i){var c,l,d=new Map,u=t.length,h=r.length,f=new Array(u),p;for(c=0;c<u;++c)(l=t[c])&&(f[c]=p=i.call(l,l.__data__,c,t)+"",d.has(p)?o[c]=l:d.set(p,l));for(c=0;c<h;++c)p=i.call(e,r[c],c,r)+"",(l=d.get(p))?(s[c]=l,l.__data__=r[c],d.delete(p)):n[c]=new $n(e,r[c]);for(c=0;c<u;++c)(l=t[c])&&d.get(f[c])===l&&(o[c]=l)}function ff(e){return e.__data__}function hf(e,t){if(!arguments.length)return Array.from(this,ff);var n=t?uf:df,s=this._parents,o=this._groups;typeof e!="function"&&(e=lf(e));for(var r=o.length,i=new Array(r),c=new Array(r),l=new Array(r),d=0;d<r;++d){var u=s[d],h=o[d],f=h.length,p=pf(e.call(u,u&&u.__data__,d,s)),m=p.length,w=c[d]=new Array(m),x=i[d]=new Array(m),y=l[d]=new Array(f);n(u,h,w,x,y,p,t);for(var j=0,g=0,v,E;j<m;++j)if(v=w[j]){for(j>=g&&(g=j+1);!(E=x[g])&&++g<m;);v._next=E||null}}return i=new Ee(i,s),i._enter=c,i._exit=l,i}function pf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function mf(){return new Ee(this._exit||this._groups.map(ia),this._parents)}function gf(e,t,n){var s=this.enter(),o=this,r=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?r.remove():n(r),s&&o?s.merge(o).order():o}function xf(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,o=n.length,r=s.length,i=Math.min(o,r),c=new Array(o),l=0;l<i;++l)for(var d=n[l],u=s[l],h=d.length,f=c[l]=new Array(h),p,m=0;m<h;++m)(p=d[m]||u[m])&&(f[m]=p);for(;l<o;++l)c[l]=n[l];return new Ee(c,this._parents)}function yf(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],o=s.length-1,r=s[o],i;--o>=0;)(i=s[o])&&(r&&i.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(i,r),r=i);return this}function wf(e){e||(e=vf);function t(h,f){return h&&f?e(h.__data__,f.__data__):!h-!f}for(var n=this._groups,s=n.length,o=new Array(s),r=0;r<s;++r){for(var i=n[r],c=i.length,l=o[r]=new Array(c),d,u=0;u<c;++u)(d=i[u])&&(l[u]=d);l.sort(t)}return new Ee(o,this._parents).order()}function vf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function bf(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Nf(){return Array.from(this)}function jf(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,r=s.length;o<r;++o){var i=s[o];if(i)return i}return null}function kf(){let e=0;for(const t of this)++e;return e}function Ef(){return!this.node()}function Cf(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var o=t[n],r=0,i=o.length,c;r<i;++r)(c=o[r])&&e.call(c,c.__data__,r,o);return this}function Sf(e){return function(){this.removeAttribute(e)}}function _f(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Mf(e,t){return function(){this.setAttribute(e,t)}}function If(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function $f(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Rf(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 Af(e,t){var n=ts(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?_f:Sf:typeof t=="function"?n.local?Rf:$f:n.local?If:Mf)(n,t))}function aa(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Df(e){return function(){this.style.removeProperty(e)}}function Pf(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Tf(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function Of(e,t,n){return arguments.length>1?this.each((t==null?Df:typeof t=="function"?Tf:Pf)(e,t,n??"")):Et(this.node(),e)}function Et(e,t){return e.style.getPropertyValue(t)||aa(e).getComputedStyle(e,null).getPropertyValue(t)}function zf(e){return function(){delete this[e]}}function Lf(e,t){return function(){this[e]=t}}function Hf(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Vf(e,t){return arguments.length>1?this.each((t==null?zf:typeof t=="function"?Hf:Lf)(e,t)):this.node()[e]}function ca(e){return e.trim().split(/^|\s+/)}function go(e){return e.classList||new la(e)}function la(e){this._node=e,this._names=ca(e.getAttribute("class")||"")}la.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 da(e,t){for(var n=go(e),s=-1,o=t.length;++s<o;)n.add(t[s])}function ua(e,t){for(var n=go(e),s=-1,o=t.length;++s<o;)n.remove(t[s])}function Ff(e){return function(){da(this,e)}}function Bf(e){return function(){ua(this,e)}}function Wf(e,t){return function(){(t.apply(this,arguments)?da:ua)(this,e)}}function Yf(e,t){var n=ca(e+"");if(arguments.length<2){for(var s=go(this.node()),o=-1,r=n.length;++o<r;)if(!s.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?Wf:t?Ff:Bf)(n,t))}function Xf(){this.textContent=""}function qf(e){return function(){this.textContent=e}}function Zf(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Gf(e){return arguments.length?this.each(e==null?Xf:(typeof e=="function"?Zf:qf)(e)):this.node().textContent}function Uf(){this.innerHTML=""}function Kf(e){return function(){this.innerHTML=e}}function Qf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Jf(e){return arguments.length?this.each(e==null?Uf:(typeof e=="function"?Qf:Kf)(e)):this.node().innerHTML}function eh(){this.nextSibling&&this.parentNode.appendChild(this)}function th(){return this.each(eh)}function nh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function sh(){return this.each(nh)}function oh(e){var t=typeof e=="function"?e:na(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function rh(){return null}function ih(e,t){var n=typeof e=="function"?e:na(e),s=t==null?rh:typeof t=="function"?t:mo(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function ah(){var e=this.parentNode;e&&e.removeChild(this)}function ch(){return this.each(ah)}function lh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function dh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function uh(e){return this.select(e?dh:lh)}function fh(e){return arguments.length?this.property("__data__",e):this.node().__data__}function hh(e){return function(t){e.call(this,t,this.__data__)}}function ph(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 mh(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,o=t.length,r;n<o;++n)r=t[n],(!e.type||r.type===e.type)&&r.name===e.name?this.removeEventListener(r.type,r.listener,r.options):t[++s]=r;++s?t.length=s:delete this.__on}}}function gh(e,t,n){return function(){var s=this.__on,o,r=hh(t);if(s){for(var i=0,c=s.length;i<c;++i)if((o=s[i]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=r,o.options=n),o.value=t;return}}this.addEventListener(e.type,r,n),o={type:e.type,name:e.name,value:t,listener:r,options:n},s?s.push(o):this.__on=[o]}}function xh(e,t,n){var s=ph(e+""),o,r=s.length,i;if(arguments.length<2){var c=this.node().__on;if(c){for(var l=0,d=c.length,u;l<d;++l)for(o=0,u=c[l];o<r;++o)if((i=s[o]).type===u.type&&i.name===u.name)return u.value}return}for(c=t?gh:mh,o=0;o<r;++o)this.each(c(s[o],t,n));return this}function fa(e,t,n){var s=aa(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 yh(e,t){return function(){return fa(this,e,t)}}function wh(e,t){return function(){return fa(this,e,t.apply(this,arguments))}}function vh(e,t){return this.each((typeof t=="function"?wh:yh)(e,t))}function*bh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,r=s.length,i;o<r;++o)(i=s[o])&&(yield i)}var ha=[null];function Ee(e,t){this._groups=e,this._parents=t}function rn(){return new Ee([[document.documentElement]],ha)}function Nh(){return this}Ee.prototype=rn.prototype={constructor:Ee,select:qu,selectAll:Ku,selectChild:tf,selectChildren:rf,filter:af,data:hf,enter:cf,exit:mf,join:gf,merge:xf,selection:Nh,order:yf,sort:wf,call:bf,nodes:Nf,node:jf,size:kf,empty:Ef,each:Cf,attr:Af,style:Of,property:Vf,classed:Yf,text:Gf,html:Jf,raise:th,lower:sh,append:oh,insert:ih,remove:ch,clone:uh,datum:fh,on:xh,dispatch:vh,[Symbol.iterator]:bh};function ke(e){return typeof e=="string"?new Ee([[document.querySelector(e)]],[document.documentElement]):new Ee([[e]],ha)}function jh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function $e(e,t){if(e=jh(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 kh={passive:!1},Yt={capture:!0,passive:!1};function gs(e){e.stopImmediatePropagation()}function Nt(e){e.preventDefault(),e.stopImmediatePropagation()}function pa(e){var t=e.document.documentElement,n=ke(e).on("dragstart.drag",Nt,Yt);"onselectstart"in t?n.on("selectstart.drag",Nt,Yt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function ma(e,t){var n=e.document.documentElement,s=ke(e).on("dragstart.drag",null);t&&(s.on("click.drag",Nt,Yt),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 pn=e=>()=>e;function As(e,{sourceEvent:t,subject:n,target:s,identifier:o,active:r,x:i,y:c,dx:l,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}As.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Eh(e){return!e.ctrlKey&&!e.button}function Ch(){return this.parentNode}function Sh(e,t){return t??{x:e.x,y:e.y}}function _h(){return navigator.maxTouchPoints||"ontouchstart"in this}function ga(){var e=Eh,t=Ch,n=Sh,s=_h,o={},r=es("start","drag","end"),i=0,c,l,d,u,h=0;function f(v){v.on("mousedown.drag",p).filter(s).on("touchstart.drag",x).on("touchmove.drag",y,kh).on("touchend.drag touchcancel.drag",j).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(v,E){if(!(u||!e.call(this,v,E))){var k=g(this,t.call(this,v,E),v,E,"mouse");k&&(ke(v.view).on("mousemove.drag",m,Yt).on("mouseup.drag",w,Yt),pa(v.view),gs(v),d=!1,c=v.clientX,l=v.clientY,k("start",v))}}function m(v){if(Nt(v),!d){var E=v.clientX-c,k=v.clientY-l;d=E*E+k*k>h}o.mouse("drag",v)}function w(v){ke(v.view).on("mousemove.drag mouseup.drag",null),ma(v.view,d),Nt(v),o.mouse("end",v)}function x(v,E){if(e.call(this,v,E)){var k=v.changedTouches,C=t.call(this,v,E),I=k.length,R,H;for(R=0;R<I;++R)(H=g(this,C,v,E,k[R].identifier,k[R]))&&(gs(v),H("start",v,k[R]))}}function y(v){var E=v.changedTouches,k=E.length,C,I;for(C=0;C<k;++C)(I=o[E[C].identifier])&&(Nt(v),I("drag",v,E[C]))}function j(v){var E=v.changedTouches,k=E.length,C,I;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),C=0;C<k;++C)(I=o[E[C].identifier])&&(gs(v),I("end",v,E[C]))}function g(v,E,k,C,I,R){var H=r.copy(),T=$e(R||k,E),$,A,b;if((b=n.call(v,new As("beforestart",{sourceEvent:k,target:f,identifier:I,active:i,x:T[0],y:T[1],dx:0,dy:0,dispatch:H}),C))!=null)return $=b.x-T[0]||0,A=b.y-T[1]||0,function S(_,M,D){var P=T,L;switch(_){case"start":o[I]=S,L=i++;break;case"end":delete o[I],--i;case"drag":T=$e(D||M,E),L=i;break}H.call(_,v,new As(_,{sourceEvent:M,subject:b,target:f,identifier:I,active:L,x:T[0]+$,y:T[1]+A,dx:T[0]-P[0],dy:T[1]-P[1],dispatch:H}),C)}}return f.filter=function(v){return arguments.length?(e=typeof v=="function"?v:pn(!!v),f):e},f.container=function(v){return arguments.length?(t=typeof v=="function"?v:pn(v),f):t},f.subject=function(v){return arguments.length?(n=typeof v=="function"?v:pn(v),f):n},f.touchable=function(v){return arguments.length?(s=typeof v=="function"?v:pn(!!v),f):s},f.on=function(){var v=r.on.apply(r,arguments);return v===r?f:v},f.clickDistance=function(v){return arguments.length?(h=(v=+v)*v,f):Math.sqrt(h)},f}function xo(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function xa(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function an(){}var Xt=.7,Rn=1/Xt,jt="\\s*([+-]?\\d+)\\s*",qt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",We="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Mh=/^#([0-9a-f]{3,8})$/,Ih=new RegExp(`^rgb\\(${jt},${jt},${jt}\\)$`),$h=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),Rh=new RegExp(`^rgba\\(${jt},${jt},${jt},${qt}\\)$`),Ah=new RegExp(`^rgba\\(${We},${We},${We},${qt}\\)$`),Dh=new RegExp(`^hsl\\(${qt},${We},${We}\\)$`),Ph=new RegExp(`^hsla\\(${qt},${We},${We},${qt}\\)$`),dr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};xo(an,lt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ur,formatHex:ur,formatHex8:Th,formatHsl:Oh,formatRgb:fr,toString:fr});function ur(){return this.rgb().formatHex()}function Th(){return this.rgb().formatHex8()}function Oh(){return ya(this).formatHsl()}function fr(){return this.rgb().formatRgb()}function lt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Mh.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?hr(t):n===3?new we(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?mn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?mn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Ih.exec(e))?new we(t[1],t[2],t[3],1):(t=$h.exec(e))?new we(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Rh.exec(e))?mn(t[1],t[2],t[3],t[4]):(t=Ah.exec(e))?mn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Dh.exec(e))?gr(t[1],t[2]/100,t[3]/100,1):(t=Ph.exec(e))?gr(t[1],t[2]/100,t[3]/100,t[4]):dr.hasOwnProperty(e)?hr(dr[e]):e==="transparent"?new we(NaN,NaN,NaN,0):null}function hr(e){return new we(e>>16&255,e>>8&255,e&255,1)}function mn(e,t,n,s){return s<=0&&(e=t=n=NaN),new we(e,t,n,s)}function zh(e){return e instanceof an||(e=lt(e)),e?(e=e.rgb(),new we(e.r,e.g,e.b,e.opacity)):new we}function Ds(e,t,n,s){return arguments.length===1?zh(e):new we(e,t,n,s??1)}function we(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}xo(we,Ds,xa(an,{brighter(e){return e=e==null?Rn:Math.pow(Rn,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Xt:Math.pow(Xt,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new we(it(this.r),it(this.g),it(this.b),An(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:pr,formatHex:pr,formatHex8:Lh,formatRgb:mr,toString:mr}));function pr(){return`#${ot(this.r)}${ot(this.g)}${ot(this.b)}`}function Lh(){return`#${ot(this.r)}${ot(this.g)}${ot(this.b)}${ot((isNaN(this.opacity)?1:this.opacity)*255)}`}function mr(){const e=An(this.opacity);return`${e===1?"rgb(":"rgba("}${it(this.r)}, ${it(this.g)}, ${it(this.b)}${e===1?")":`, ${e})`}`}function An(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function it(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ot(e){return e=it(e),(e<16?"0":"")+e.toString(16)}function gr(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Re(e,t,n,s)}function ya(e){if(e instanceof Re)return new Re(e.h,e.s,e.l,e.opacity);if(e instanceof an||(e=lt(e)),!e)return new Re;if(e instanceof Re)return e;e=e.rgb();var t=e.r/255,n=e.g/255,s=e.b/255,o=Math.min(t,n,s),r=Math.max(t,n,s),i=NaN,c=r-o,l=(r+o)/2;return c?(t===r?i=(n-s)/c+(n<s)*6:n===r?i=(s-t)/c+2:i=(t-n)/c+4,c/=l<.5?r+o:2-r-o,i*=60):c=l>0&&l<1?0:i,new Re(i,c,l,e.opacity)}function Hh(e,t,n,s){return arguments.length===1?ya(e):new Re(e,t,n,s??1)}function Re(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}xo(Re,Hh,xa(an,{brighter(e){return e=e==null?Rn:Math.pow(Rn,e),new Re(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Xt:Math.pow(Xt,e),new Re(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,s=n+(n<.5?n:1-n)*t,o=2*n-s;return new we(xs(e>=240?e-240:e+120,o,s),xs(e,o,s),xs(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new Re(xr(this.h),gn(this.s),gn(this.l),An(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=An(this.opacity);return`${e===1?"hsl(":"hsla("}${xr(this.h)}, ${gn(this.s)*100}%, ${gn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function xr(e){return e=(e||0)%360,e<0?e+360:e}function gn(e){return Math.max(0,Math.min(1,e||0))}function xs(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const yo=e=>()=>e;function Vh(e,t){return function(n){return e+n*t}}function Fh(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(s){return Math.pow(e+s*t,n)}}function Bh(e){return(e=+e)==1?wa:function(t,n){return n-t?Fh(t,n,e):yo(isNaN(t)?n:t)}}function wa(e,t){var n=t-e;return n?Vh(e,n):yo(isNaN(e)?t:e)}const Dn=(function e(t){var n=Bh(t);function s(o,r){var i=n((o=Ds(o)).r,(r=Ds(r)).r),c=n(o.g,r.g),l=n(o.b,r.b),d=wa(o.opacity,r.opacity);return function(u){return o.r=i(u),o.g=c(u),o.b=l(u),o.opacity=d(u),o+""}}return s.gamma=e,s})(1);function Wh(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,s=t.slice(),o;return function(r){for(o=0;o<n;++o)s[o]=e[o]*(1-r)+t[o]*r;return s}}function Yh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Xh(e,t){var n=t?t.length:0,s=e?Math.min(n,e.length):0,o=new Array(s),r=new Array(n),i;for(i=0;i<s;++i)o[i]=Bt(e[i],t[i]);for(;i<n;++i)r[i]=t[i];return function(c){for(i=0;i<s;++i)r[i]=o[i](c);return r}}function qh(e,t){var n=new Date;return e=+e,t=+t,function(s){return n.setTime(e*(1-s)+t*s),n}}function He(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Zh(e,t){var n={},s={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=Bt(e[o],t[o]):s[o]=t[o];return function(r){for(o in n)s[o]=n[o](r);return s}}var Ps=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ys=new RegExp(Ps.source,"g");function Gh(e){return function(){return e}}function Uh(e){return function(t){return e(t)+""}}function va(e,t){var n=Ps.lastIndex=ys.lastIndex=0,s,o,r,i=-1,c=[],l=[];for(e=e+"",t=t+"";(s=Ps.exec(e))&&(o=ys.exec(t));)(r=o.index)>n&&(r=t.slice(n,r),c[i]?c[i]+=r:c[++i]=r),(s=s[0])===(o=o[0])?c[i]?c[i]+=o:c[++i]=o:(c[++i]=null,l.push({i,x:He(s,o)})),n=ys.lastIndex;return n<t.length&&(r=t.slice(n),c[i]?c[i]+=r:c[++i]=r),c.length<2?l[0]?Uh(l[0].x):Gh(t):(t=l.length,function(d){for(var u=0,h;u<t;++u)c[(h=l[u]).i]=h.x(d);return c.join("")})}function Bt(e,t){var n=typeof t,s;return t==null||n==="boolean"?yo(t):(n==="number"?He:n==="string"?(s=lt(t))?(t=s,Dn):va:t instanceof lt?Dn:t instanceof Date?qh:Yh(t)?Wh:Array.isArray(t)?Xh:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Zh:He)(e,t)}var yr=180/Math.PI,Ts={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ba(e,t,n,s,o,r){var i,c,l;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(l=e*n+t*s)&&(n-=e*l,s-=t*l),(c=Math.sqrt(n*n+s*s))&&(n/=c,s/=c,l/=c),e*s<t*n&&(e=-e,t=-t,l=-l,i=-i),{translateX:o,translateY:r,rotate:Math.atan2(t,e)*yr,skewX:Math.atan(l)*yr,scaleX:i,scaleY:c}}var xn;function Kh(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ts:ba(t.a,t.b,t.c,t.d,t.e,t.f)}function Qh(e){return e==null||(xn||(xn=document.createElementNS("http://www.w3.org/2000/svg","g")),xn.setAttribute("transform",e),!(e=xn.transform.baseVal.consolidate()))?Ts:(e=e.matrix,ba(e.a,e.b,e.c,e.d,e.e,e.f))}function Na(e,t,n,s){function o(d){return d.length?d.pop()+" ":""}function r(d,u,h,f,p,m){if(d!==h||u!==f){var w=p.push("translate(",null,t,null,n);m.push({i:w-4,x:He(d,h)},{i:w-2,x:He(u,f)})}else(h||f)&&p.push("translate("+h+t+f+n)}function i(d,u,h,f){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),f.push({i:h.push(o(h)+"rotate(",null,s)-2,x:He(d,u)})):u&&h.push(o(h)+"rotate("+u+s)}function c(d,u,h,f){d!==u?f.push({i:h.push(o(h)+"skewX(",null,s)-2,x:He(d,u)}):u&&h.push(o(h)+"skewX("+u+s)}function l(d,u,h,f,p,m){if(d!==h||u!==f){var w=p.push(o(p)+"scale(",null,",",null,")");m.push({i:w-4,x:He(d,h)},{i:w-2,x:He(u,f)})}else(h!==1||f!==1)&&p.push(o(p)+"scale("+h+","+f+")")}return function(d,u){var h=[],f=[];return d=e(d),u=e(u),r(d.translateX,d.translateY,u.translateX,u.translateY,h,f),i(d.rotate,u.rotate,h,f),c(d.skewX,u.skewX,h,f),l(d.scaleX,d.scaleY,u.scaleX,u.scaleY,h,f),d=u=null,function(p){for(var m=-1,w=f.length,x;++m<w;)h[(x=f[m]).i]=x.x(p);return h.join("")}}}var Jh=Na(Kh,"px, ","px)","deg)"),ep=Na(Qh,", ",")",")"),tp=1e-12;function wr(e){return((e=Math.exp(e))+1/e)/2}function np(e){return((e=Math.exp(e))-1/e)/2}function sp(e){return((e=Math.exp(2*e))-1)/(e+1)}const En=(function e(t,n,s){function o(r,i){var c=r[0],l=r[1],d=r[2],u=i[0],h=i[1],f=i[2],p=u-c,m=h-l,w=p*p+m*m,x,y;if(w<tp)y=Math.log(f/d)/t,x=function(C){return[c+C*p,l+C*m,d*Math.exp(t*C*y)]};else{var j=Math.sqrt(w),g=(f*f-d*d+s*w)/(2*d*n*j),v=(f*f-d*d-s*w)/(2*f*n*j),E=Math.log(Math.sqrt(g*g+1)-g),k=Math.log(Math.sqrt(v*v+1)-v);y=(k-E)/t,x=function(C){var I=C*y,R=wr(E),H=d/(n*j)*(R*sp(t*I+E)-np(E));return[c+H*p,l+H*m,d*R/wr(t*I+E)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return o.rho=function(r){var i=Math.max(.001,+r),c=i*i,l=c*c;return e(i,c,l)},o})(Math.SQRT2,2,4);var Ct=0,Lt=0,Ot=0,ja=1e3,Pn,Ht,Tn=0,dt=0,ns=0,Zt=typeof performance=="object"&&performance.now?performance:Date,ka=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function wo(){return dt||(ka(op),dt=Zt.now()+ns)}function op(){dt=0}function On(){this._call=this._time=this._next=null}On.prototype=Ea.prototype={constructor:On,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?wo():+n)+(t==null?0:+t),!this._next&&Ht!==this&&(Ht?Ht._next=this:Pn=this,Ht=this),this._call=e,this._time=n,Os()},stop:function(){this._call&&(this._call=null,this._time=1/0,Os())}};function Ea(e,t,n){var s=new On;return s.restart(e,t,n),s}function rp(){wo(),++Ct;for(var e=Pn,t;e;)(t=dt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ct}function vr(){dt=(Tn=Zt.now())+ns,Ct=Lt=0;try{rp()}finally{Ct=0,ap(),dt=0}}function ip(){var e=Zt.now(),t=e-Tn;t>ja&&(ns-=t,Tn=e)}function ap(){for(var e,t=Pn,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:Pn=n);Ht=e,Os(s)}function Os(e){if(!Ct){Lt&&(Lt=clearTimeout(Lt));var t=e-dt;t>24?(e<1/0&&(Lt=setTimeout(vr,e-Zt.now()-ns)),Ot&&(Ot=clearInterval(Ot))):(Ot||(Tn=Zt.now(),Ot=setInterval(ip,ja)),Ct=1,ka(vr))}}function br(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 cp=es("start","end","cancel","interrupt"),lp=[],Ca=0,Nr=1,zs=2,Cn=3,jr=4,Ls=5,Sn=6;function ss(e,t,n,s,o,r){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;dp(e,n,{name:t,index:s,group:o,on:cp,tween:lp,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:Ca})}function vo(e,t){var n=Oe(e,t);if(n.state>Ca)throw new Error("too late; already scheduled");return n}function Ye(e,t){var n=Oe(e,t);if(n.state>Cn)throw new Error("too late; already running");return n}function Oe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function dp(e,t,n){var s=e.__transition,o;s[t]=n,n.timer=Ea(r,0,n.time);function r(d){n.state=Nr,n.timer.restart(i,n.delay,n.time),n.delay<=d&&i(d-n.delay)}function i(d){var u,h,f,p;if(n.state!==Nr)return l();for(u in s)if(p=s[u],p.name===n.name){if(p.state===Cn)return br(i);p.state===jr?(p.state=Sn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete s[u]):+u<t&&(p.state=Sn,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete s[u])}if(br(function(){n.state===Cn&&(n.state=jr,n.timer.restart(c,n.delay,n.time),c(d))}),n.state=zs,n.on.call("start",e,e.__data__,n.index,n.group),n.state===zs){for(n.state=Cn,o=new Array(f=n.tween.length),u=0,h=-1;u<f;++u)(p=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++h]=p);o.length=h+1}}function c(d){for(var u=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(l),n.state=Ls,1),h=-1,f=o.length;++h<f;)o[h].call(e,u);n.state===Ls&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Sn,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function _n(e,t){var n=e.__transition,s,o,r=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((s=n[i]).name!==t){r=!1;continue}o=s.state>zs&&s.state<Ls,s.state=Sn,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[i]}r&&delete e.__transition}}function up(e){return this.each(function(){_n(this,e)})}function fp(e,t){var n,s;return function(){var o=Ye(this,e),r=o.tween;if(r!==n){s=n=r;for(var i=0,c=s.length;i<c;++i)if(s[i].name===t){s=s.slice(),s.splice(i,1);break}}o.tween=s}}function hp(e,t,n){var s,o;if(typeof n!="function")throw new Error;return function(){var r=Ye(this,e),i=r.tween;if(i!==s){o=(s=i).slice();for(var c={name:t,value:n},l=0,d=o.length;l<d;++l)if(o[l].name===t){o[l]=c;break}l===d&&o.push(c)}r.tween=o}}function pp(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Oe(this.node(),n).tween,o=0,r=s.length,i;o<r;++o)if((i=s[o]).name===e)return i.value;return null}return this.each((t==null?fp:hp)(n,e,t))}function bo(e,t,n){var s=e._id;return e.each(function(){var o=Ye(this,s);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Oe(o,s).value[t]}}function Sa(e,t){var n;return(typeof t=="number"?He:t instanceof lt?Dn:(n=lt(t))?(t=n,Dn):va)(e,t)}function mp(e){return function(){this.removeAttribute(e)}}function gp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xp(e,t,n){var s,o=n+"",r;return function(){var i=this.getAttribute(e);return i===o?null:i===s?r:r=t(s=i,n)}}function yp(e,t,n){var s,o=n+"",r;return function(){var i=this.getAttributeNS(e.space,e.local);return i===o?null:i===s?r:r=t(s=i,n)}}function wp(e,t,n){var s,o,r;return function(){var i,c=n(this),l;return c==null?void this.removeAttribute(e):(i=this.getAttribute(e),l=c+"",i===l?null:i===s&&l===o?r:(o=l,r=t(s=i,c)))}}function vp(e,t,n){var s,o,r;return function(){var i,c=n(this),l;return c==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),l=c+"",i===l?null:i===s&&l===o?r:(o=l,r=t(s=i,c)))}}function bp(e,t){var n=ts(e),s=n==="transform"?ep:Sa;return this.attrTween(e,typeof t=="function"?(n.local?vp:wp)(n,s,bo(this,"attr."+e,t)):t==null?(n.local?gp:mp)(n):(n.local?yp:xp)(n,s,t))}function Np(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function jp(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function kp(e,t){var n,s;function o(){var r=t.apply(this,arguments);return r!==s&&(n=(s=r)&&jp(e,r)),n}return o._value=t,o}function Ep(e,t){var n,s;function o(){var r=t.apply(this,arguments);return r!==s&&(n=(s=r)&&Np(e,r)),n}return o._value=t,o}function Cp(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=ts(e);return this.tween(n,(s.local?kp:Ep)(s,t))}function Sp(e,t){return function(){vo(this,e).delay=+t.apply(this,arguments)}}function _p(e,t){return t=+t,function(){vo(this,e).delay=t}}function Mp(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Sp:_p)(t,e)):Oe(this.node(),t).delay}function Ip(e,t){return function(){Ye(this,e).duration=+t.apply(this,arguments)}}function $p(e,t){return t=+t,function(){Ye(this,e).duration=t}}function Rp(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ip:$p)(t,e)):Oe(this.node(),t).duration}function Ap(e,t){if(typeof t!="function")throw new Error;return function(){Ye(this,e).ease=t}}function Dp(e){var t=this._id;return arguments.length?this.each(Ap(t,e)):Oe(this.node(),t).ease}function Pp(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ye(this,e).ease=n}}function Tp(e){if(typeof e!="function")throw new Error;return this.each(Pp(this._id,e))}function Op(e){typeof e!="function"&&(e=oa(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var r=t[o],i=r.length,c=s[o]=[],l,d=0;d<i;++d)(l=r[d])&&e.call(l,l.__data__,d,r)&&c.push(l);return new Ge(s,this._parents,this._name,this._id)}function zp(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,o=n.length,r=Math.min(s,o),i=new Array(s),c=0;c<r;++c)for(var l=t[c],d=n[c],u=l.length,h=i[c]=new Array(u),f,p=0;p<u;++p)(f=l[p]||d[p])&&(h[p]=f);for(;c<s;++c)i[c]=t[c];return new Ge(i,this._parents,this._name,this._id)}function Lp(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 Hp(e,t,n){var s,o,r=Lp(t)?vo:Ye;return function(){var i=r(this,e),c=i.on;c!==s&&(o=(s=c).copy()).on(t,n),i.on=o}}function Vp(e,t){var n=this._id;return arguments.length<2?Oe(this.node(),n).on.on(e):this.each(Hp(n,e,t))}function Fp(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Bp(){return this.on("end.remove",Fp(this._id))}function Wp(e){var t=this._name,n=this._id;typeof e!="function"&&(e=mo(e));for(var s=this._groups,o=s.length,r=new Array(o),i=0;i<o;++i)for(var c=s[i],l=c.length,d=r[i]=new Array(l),u,h,f=0;f<l;++f)(u=c[f])&&(h=e.call(u,u.__data__,f,c))&&("__data__"in u&&(h.__data__=u.__data__),d[f]=h,ss(d[f],t,n,f,d,Oe(u,n)));return new Ge(r,this._parents,t,n)}function Yp(e){var t=this._name,n=this._id;typeof e!="function"&&(e=sa(e));for(var s=this._groups,o=s.length,r=[],i=[],c=0;c<o;++c)for(var l=s[c],d=l.length,u,h=0;h<d;++h)if(u=l[h]){for(var f=e.call(u,u.__data__,h,l),p,m=Oe(u,n),w=0,x=f.length;w<x;++w)(p=f[w])&&ss(p,t,n,w,f,m);r.push(f),i.push(u)}return new Ge(r,i,t,n)}var Xp=rn.prototype.constructor;function qp(){return new Xp(this._groups,this._parents)}function Zp(e,t){var n,s,o;return function(){var r=Et(this,e),i=(this.style.removeProperty(e),Et(this,e));return r===i?null:r===n&&i===s?o:o=t(n=r,s=i)}}function _a(e){return function(){this.style.removeProperty(e)}}function Gp(e,t,n){var s,o=n+"",r;return function(){var i=Et(this,e);return i===o?null:i===s?r:r=t(s=i,n)}}function Up(e,t,n){var s,o,r;return function(){var i=Et(this,e),c=n(this),l=c+"";return c==null&&(l=c=(this.style.removeProperty(e),Et(this,e))),i===l?null:i===s&&l===o?r:(o=l,r=t(s=i,c))}}function Kp(e,t){var n,s,o,r="style."+t,i="end."+r,c;return function(){var l=Ye(this,e),d=l.on,u=l.value[r]==null?c||(c=_a(t)):void 0;(d!==n||o!==u)&&(s=(n=d).copy()).on(i,o=u),l.on=s}}function Qp(e,t,n){var s=(e+="")=="transform"?Jh:Sa;return t==null?this.styleTween(e,Zp(e,s)).on("end.style."+e,_a(e)):typeof t=="function"?this.styleTween(e,Up(e,s,bo(this,"style."+e,t))).each(Kp(this._id,e)):this.styleTween(e,Gp(e,s,t),n).on("end.style."+e,null)}function Jp(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function em(e,t,n){var s,o;function r(){var i=t.apply(this,arguments);return i!==o&&(s=(o=i)&&Jp(e,i,n)),s}return r._value=t,r}function tm(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,em(e,t,n??""))}function nm(e){return function(){this.textContent=e}}function sm(e){return function(){var t=e(this);this.textContent=t??""}}function om(e){return this.tween("text",typeof e=="function"?sm(bo(this,"text",e)):nm(e==null?"":e+""))}function rm(e){return function(t){this.textContent=e.call(this,t)}}function im(e){var t,n;function s(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&rm(o)),t}return s._value=e,s}function am(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,im(e))}function cm(){for(var e=this._name,t=this._id,n=Ma(),s=this._groups,o=s.length,r=0;r<o;++r)for(var i=s[r],c=i.length,l,d=0;d<c;++d)if(l=i[d]){var u=Oe(l,t);ss(l,e,n,d,i,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Ge(s,this._parents,e,n)}function lm(){var e,t,n=this,s=n._id,o=n.size();return new Promise(function(r,i){var c={value:i},l={value:function(){--o===0&&r()}};n.each(function(){var d=Ye(this,s),u=d.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(l)),d.on=t}),o===0&&r()})}var dm=0;function Ge(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Ma(){return++dm}var Xe=rn.prototype;Ge.prototype={constructor:Ge,select:Wp,selectAll:Yp,selectChild:Xe.selectChild,selectChildren:Xe.selectChildren,filter:Op,merge:zp,selection:qp,transition:cm,call:Xe.call,nodes:Xe.nodes,node:Xe.node,size:Xe.size,empty:Xe.empty,each:Xe.each,on:Vp,attr:bp,attrTween:Cp,style:Qp,styleTween:tm,text:om,textTween:am,remove:Bp,tween:pp,delay:Mp,duration:Rp,ease:Dp,easeVarying:Tp,end:lm,[Symbol.iterator]:Xe[Symbol.iterator]};function um(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var fm={time:null,delay:0,duration:250,ease:um};function hm(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 pm(e){var t,n;e instanceof Ge?(t=e._id,e=e._name):(t=Ma(),(n=fm).time=wo(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,r=0;r<o;++r)for(var i=s[r],c=i.length,l,d=0;d<c;++d)(l=i[d])&&ss(l,e,t,d,i,n||hm(l,t));return new Ge(s,this._parents,e,t)}rn.prototype.interrupt=up;rn.prototype.transition=pm;const yn=e=>()=>e;function mm(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 Ze(e,t,n){this.k=e,this.x=t,this.y=n}Ze.prototype={constructor:Ze,scale:function(e){return e===1?this:new Ze(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ze(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 os=new Ze(1,0,0);Ia.prototype=Ze.prototype;function Ia(e){for(;!e.__zoom;)if(!(e=e.parentNode))return os;return e.__zoom}function ws(e){e.stopImmediatePropagation()}function zt(e){e.preventDefault(),e.stopImmediatePropagation()}function gm(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function xm(){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 kr(){return this.__zoom||os}function ym(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function wm(){return navigator.maxTouchPoints||"ontouchstart"in this}function vm(e,t,n){var s=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],r=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i))}function $a(){var e=gm,t=xm,n=vm,s=ym,o=wm,r=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],c=250,l=En,d=es("start","zoom","end"),u,h,f,p=500,m=150,w=0,x=10;function y(b){b.property("__zoom",kr).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",H).filter(o).on("touchstart.zoom",T).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(b,S,_,M){var D=b.selection?b.selection():b;D.property("__zoom",kr),b!==D?E(b,S,_,M):D.interrupt().each(function(){k(this,arguments).event(M).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},y.scaleBy=function(b,S,_,M){y.scaleTo(b,function(){var D=this.__zoom.k,P=typeof S=="function"?S.apply(this,arguments):S;return D*P},_,M)},y.scaleTo=function(b,S,_,M){y.transform(b,function(){var D=t.apply(this,arguments),P=this.__zoom,L=_==null?v(D):typeof _=="function"?_.apply(this,arguments):_,V=P.invert(L),F=typeof S=="function"?S.apply(this,arguments):S;return n(g(j(P,F),L,V),D,i)},_,M)},y.translateBy=function(b,S,_,M){y.transform(b,function(){return n(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof _=="function"?_.apply(this,arguments):_),t.apply(this,arguments),i)},null,M)},y.translateTo=function(b,S,_,M,D){y.transform(b,function(){var P=t.apply(this,arguments),L=this.__zoom,V=M==null?v(P):typeof M=="function"?M.apply(this,arguments):M;return n(os.translate(V[0],V[1]).scale(L.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof _=="function"?-_.apply(this,arguments):-_),P,i)},M,D)};function j(b,S){return S=Math.max(r[0],Math.min(r[1],S)),S===b.k?b:new Ze(S,b.x,b.y)}function g(b,S,_){var M=S[0]-_[0]*b.k,D=S[1]-_[1]*b.k;return M===b.x&&D===b.y?b:new Ze(b.k,M,D)}function v(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function E(b,S,_,M){b.on("start.zoom",function(){k(this,arguments).event(M).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(M).end()}).tween("zoom",function(){var D=this,P=arguments,L=k(D,P).event(M),V=t.apply(D,P),F=_==null?v(V):typeof _=="function"?_.apply(D,P):_,O=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),B=D.__zoom,W=typeof S=="function"?S.apply(D,P):S,Q=l(B.invert(F).concat(O/B.k),W.invert(F).concat(O/W.k));return function(G){if(G===1)G=W;else{var z=Q(G),Z=O/z[2];G=new Ze(Z,F[0]-z[0]*Z,F[1]-z[1]*Z)}L.zoom(null,G)}})}function k(b,S,_){return!_&&b.__zooming||new C(b,S)}function C(b,S){this.that=b,this.args=S,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,S),this.taps=0}C.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,S){return this.mouse&&b!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var S=ke(this.that).datum();d.call(b,this.that,new mm(b,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),S)}};function I(b,...S){if(!e.apply(this,arguments))return;var _=k(this,S).event(b),M=this.__zoom,D=Math.max(r[0],Math.min(r[1],M.k*Math.pow(2,s.apply(this,arguments)))),P=$e(b);if(_.wheel)(_.mouse[0][0]!==P[0]||_.mouse[0][1]!==P[1])&&(_.mouse[1]=M.invert(_.mouse[0]=P)),clearTimeout(_.wheel);else{if(M.k===D)return;_.mouse=[P,M.invert(P)],_n(this),_.start()}zt(b),_.wheel=setTimeout(L,m),_.zoom("mouse",n(g(j(M,D),_.mouse[0],_.mouse[1]),_.extent,i));function L(){_.wheel=null,_.end()}}function R(b,...S){if(f||!e.apply(this,arguments))return;var _=b.currentTarget,M=k(this,S,!0).event(b),D=ke(b.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",O,!0),P=$e(b,_),L=b.clientX,V=b.clientY;pa(b.view),ws(b),M.mouse=[P,this.__zoom.invert(P)],_n(this),M.start();function F(B){if(zt(B),!M.moved){var W=B.clientX-L,Q=B.clientY-V;M.moved=W*W+Q*Q>w}M.event(B).zoom("mouse",n(g(M.that.__zoom,M.mouse[0]=$e(B,_),M.mouse[1]),M.extent,i))}function O(B){D.on("mousemove.zoom mouseup.zoom",null),ma(B.view,M.moved),zt(B),M.event(B).end()}}function H(b,...S){if(e.apply(this,arguments)){var _=this.__zoom,M=$e(b.changedTouches?b.changedTouches[0]:b,this),D=_.invert(M),P=_.k*(b.shiftKey?.5:2),L=n(g(j(_,P),M,D),t.apply(this,S),i);zt(b),c>0?ke(this).transition().duration(c).call(E,L,M,b):ke(this).call(y.transform,L,M,b)}}function T(b,...S){if(e.apply(this,arguments)){var _=b.touches,M=_.length,D=k(this,S,b.changedTouches.length===M).event(b),P,L,V,F;for(ws(b),L=0;L<M;++L)V=_[L],F=$e(V,this),F=[F,this.__zoom.invert(F),V.identifier],D.touch0?!D.touch1&&D.touch0[2]!==F[2]&&(D.touch1=F,D.taps=0):(D.touch0=F,P=!0,D.taps=1+!!u);u&&(u=clearTimeout(u)),P&&(D.taps<2&&(h=F[0],u=setTimeout(function(){u=null},p)),_n(this),D.start())}}function $(b,...S){if(this.__zooming){var _=k(this,S).event(b),M=b.changedTouches,D=M.length,P,L,V,F;for(zt(b),P=0;P<D;++P)L=M[P],V=$e(L,this),_.touch0&&_.touch0[2]===L.identifier?_.touch0[0]=V:_.touch1&&_.touch1[2]===L.identifier&&(_.touch1[0]=V);if(L=_.that.__zoom,_.touch1){var O=_.touch0[0],B=_.touch0[1],W=_.touch1[0],Q=_.touch1[1],G=(G=W[0]-O[0])*G+(G=W[1]-O[1])*G,z=(z=Q[0]-B[0])*z+(z=Q[1]-B[1])*z;L=j(L,Math.sqrt(G/z)),V=[(O[0]+W[0])/2,(O[1]+W[1])/2],F=[(B[0]+Q[0])/2,(B[1]+Q[1])/2]}else if(_.touch0)V=_.touch0[0],F=_.touch0[1];else return;_.zoom("touch",n(g(L,V,F),_.extent,i))}}function A(b,...S){if(this.__zooming){var _=k(this,S).event(b),M=b.changedTouches,D=M.length,P,L;for(ws(b),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),P=0;P<D;++P)L=M[P],_.touch0&&_.touch0[2]===L.identifier?delete _.touch0:_.touch1&&_.touch1[2]===L.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&(L=$e(L,this),Math.hypot(h[0]-L[0],h[1]-L[1])<x)){var V=ke(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return y.wheelDelta=function(b){return arguments.length?(s=typeof b=="function"?b:yn(+b),y):s},y.filter=function(b){return arguments.length?(e=typeof b=="function"?b:yn(!!b),y):e},y.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:yn(!!b),y):o},y.extent=function(b){return arguments.length?(t=typeof b=="function"?b:yn([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),y):t},y.scaleExtent=function(b){return arguments.length?(r[0]=+b[0],r[1]=+b[1],y):[r[0],r[1]]},y.translateExtent=function(b){return arguments.length?(i[0][0]=+b[0][0],i[1][0]=+b[1][0],i[0][1]=+b[0][1],i[1][1]=+b[1][1],y):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},y.constrain=function(b){return arguments.length?(n=b,y):n},y.duration=function(b){return arguments.length?(c=+b,y):c},y.interpolate=function(b){return arguments.length?(l=b,y):l},y.on=function(){var b=d.on.apply(d,arguments);return b===d?y:b},y.clickDistance=function(b){return arguments.length?(w=(b=+b)*b,y):Math.sqrt(w)},y.tapDistance=function(b){return arguments.length?(x=+b,y):x},y}const Te={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle: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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Gt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ra=["Enter"," ","Escape"],Aa={"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 St;(function(e){e.Strict="strict",e.Loose="loose"})(St||(St={}));var at;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(at||(at={}));var Ut;(function(e){e.Partial="partial",e.Full="full"})(Ut||(Ut={}));const Da={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Je;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Je||(Je={}));var ut;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ut||(ut={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));const Er={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top};function Pa(e){return e===null?null:e?"valid":"invalid"}const Ta=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,bm=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),No=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),cn=(e,t=[0,0])=>{const{width:n,height:s}=ze(e),o=e.origin??t,r=n*o[0],i=s*o[1];return{x:e.position.x-r,y:e.position.y-i}},Nm=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const s=e.reduce((o,r)=>{const i=typeof r=="string";let c=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(c=i?t.nodeLookup.get(r):No(r)?r:t.nodeLookup.get(r.id)),c?(n=!0,rs(o,zn(c,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?is(s):{x:0,y:0,width:0,height:0}},ln=(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=rs(n,zn(o)),s=!0)}),s?is(n):{x:0,y:0,width:0,height:0}},jo=(e,t,[n,s,o]=[0,0,1],r=!1,i=!1)=>{const c=(t.x-n)/o,l=(t.y-s)/o,d=t.width/o,u=t.height/o,h=[];for(const f of e.values()){const{measured:p,selectable:m=!0,hidden:w=!1}=f;if(i&&!m||w)continue;const x=p.width??f.width??f.initialWidth??0,y=p.height??f.height??f.initialHeight??0,{x:j,y:g}=f.internals.positionAbsolute,v=Ha(c,l,d,u,j,g,x,y),E=x*y,k=r&&v>0;(!f.internals.handleBounds||k||v>=E||f.dragging)&&h.push(f)}return h},jm=(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 km(e,t){const n=new Map,s=t?.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{let r;if(t?.includeHiddenNodes){const{width:i,height:c}=ze(o);r=i>0&&c>0}else r=!!(o.measured.width&&o.measured.height&&!o.hidden);r&&(!s||s.has(o.id))&&n.set(o.id,o)}),n}async function Em({nodes:e,width:t,height:n,panZoom:s,minZoom:o,maxZoom:r},i){if(e.size===0)return!0;const c=km(e,i),l=ln(c),d=Eo(l,t,n,i?.minZoom??o,i?.maxZoom??r,i?.padding??.1);return await s.setViewport(d,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),!0}function Oa({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:o,onError:r}){const i=n.get(e),c=i.parentId?n.get(i.parentId):void 0,{x:l,y:d}=c?c.internals.positionAbsolute:{x:0,y:0},u=i.origin??s;let h=i.extent||o;if(i.extent==="parent"&&!i.expandParent)if(!c)r?.("005",Te.error005());else{const{width:p,height:m}=ze(c);p&&m&&(h=[[l,d],[l+p,d+m]])}else c&&ht(i.extent)&&(h=[[i.extent[0][0]+l,i.extent[0][1]+d],[i.extent[1][0]+l,i.extent[1][1]+d]]);const f=ht(h)?ft(t,h,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&r?.("015",Te.error015()),{position:{x:f.x-l+(i.measured.width??0)*u[0],y:f.y-d+(i.measured.height??0)*u[1]},positionAbsolute:f}}async function Cm({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:o}){const r=new Set(e.map(f=>f.id)),i=[];for(const f of n){if(f.deletable===!1)continue;const p=r.has(f.id),m=!p&&f.parentId&&i.find(w=>w.id===f.parentId);(p||m)&&i.push(f)}const c=new Set(t.map(f=>f.id)),l=s.filter(f=>f.deletable!==!1),u=jm(i,l);for(const f of l)c.has(f.id)&&!u.find(m=>m.id===f.id)&&u.push(f);if(!o)return{edges:u,nodes:i};const h=await o({nodes:i,edges:u});return typeof h=="boolean"?h?{edges:u,nodes:i}:{edges:[],nodes:[]}:h}const _t=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ft=(e={x:0,y:0},t,n)=>({x:_t(e.x,t[0][0],t[1][0]-(n?.width??0)),y:_t(e.y,t[0][1],t[1][1]-(n?.height??0))});function za(e,t,n){const{width:s,height:o}=ze(n),{x:r,y:i}=n.internals.positionAbsolute;return ft(e,[[r,i],[r+s,i+o]],t)}const Cr=(e,t,n)=>e<t?_t(Math.abs(e-t),1,t)/t:e>n?-_t(Math.abs(e-n),1,t)/t:0,ko=(e,t,n=15,s=40)=>{const o=Cr(e.x,s,t.width-s)*n,r=Cr(e.y,s,t.height-s)*n;return[o,r]},rs=(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)}),Hs=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),is=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),Kt=(e,t=[0,0])=>{const{x:n,y:s}=No(e)?e.internals.positionAbsolute:cn(e,t);return{x:n,y:s,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},zn=(e,t=[0,0])=>{const{x:n,y:s}=No(e)?e.internals.positionAbsolute:cn(e,t);return{x:n,y:s,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:s+(e.measured?.height??e.height??e.initialHeight??0)}},La=(e,t)=>is(rs(Hs(e),Hs(t))),Ha=(e,t,n,s,o,r,i,c)=>{const l=Math.max(0,Math.min(e+n,o+i)-Math.max(e,o)),d=Math.max(0,Math.min(t+s,r+c)-Math.max(t,r));return Math.ceil(l*d)},Ln=(e,t)=>Ha(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Sr=e=>Ae(e.width)&&Ae(e.height)&&Ae(e.x)&&Ae(e.y),Ae=e=>!isNaN(e)&&isFinite(e),Va=(e,t)=>(n,s)=>{},dn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),un=({x:e,y:t},[n,s,o],r=!1,i=[1,1])=>{const c={x:(e-n)/o,y:(t-s)/o};return r?dn(c,i):c},Mt=({x:e,y:t},[n,s,o])=>({x:e*o+n,y:t*o+s});function xt(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(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Sm(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=xt(e,n),o=xt(e,t);return{top:s,right:o,bottom:s,left:o,x:o*2,y:s*2}}if(typeof e=="object"){const s=xt(e.top??e.y??0,n),o=xt(e.bottom??e.y??0,n),r=xt(e.left??e.x??0,t),i=xt(e.right??e.x??0,t);return{top:s,right:i,bottom:o,left:r,x:r+i,y:s+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function _m(e,t,n,s,o,r){const{x:i,y:c}=Mt(e,[t,n,s]),{x:l,y:d}=Mt({x:e.x+e.width,y:e.y+e.height},[t,n,s]),u=o-l,h=r-d;return{left:Math.floor(i),top:Math.floor(c),right:Math.floor(u),bottom:Math.floor(h)}}const Eo=(e,t,n,s,o,r)=>{const i=Sm(r,t,n),c=(t-i.x)/e.width,l=(n-i.y)/e.height,d=Math.min(c,l),u=_t(d,s,o),h=e.x+e.width/2,f=e.y+e.height/2,p=t/2-h*u,m=n/2-f*u,w=_m(e,p,m,u,t,n),x={left:Math.min(w.left-i.left,0),top:Math.min(w.top-i.top,0),right:Math.min(w.right-i.right,0),bottom:Math.min(w.bottom-i.bottom,0)};return{x:p-x.left+x.right,y:m-x.top+x.bottom,zoom:u}},Qt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function ht(e){return e!=null&&e!=="parent"}function ze(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Fa(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Ba(e,t={width:0,height:0},n,s,o){const r={...e},i=s.get(n);if(i){const c=i.origin||o;r.x+=i.internals.positionAbsolute.x-(t.width??0)*c[0],r.y+=i.internals.positionAbsolute.y-(t.height??0)*c[1]}return r}function _r(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Mm(){let e,t;return{promise:new Promise((s,o)=>{e=s,t=o}),resolve:e,reject:t}}function Im(e){return{...Aa,...e||{}}}function Wt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:o}){const{x:r,y:i}=De(e),c=un({x:r-(o?.left??0),y:i-(o?.top??0)},s),{x:l,y:d}=n?dn(c,t):c;return{xSnapped:l,ySnapped:d,...c}}const Co=e=>({width:e.offsetWidth,height:e.offsetHeight}),Wa=e=>e?.getRootNode?.()||window?.document,$m=["INPUT","SELECT","TEXTAREA"];function Ya(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:$m.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Xa=e=>"clientX"in e,De=(e,t)=>{const n=Xa(e),s=n?e.clientX:e.touches?.[0].clientX,o=n?e.clientY:e.touches?.[0].clientY;return{x:s-(t?.left??0),y:o-(t?.top??0)}},Mr=(e,t,n,s,o)=>{const r=t.querySelectorAll(`.${e}`);return!r||!r.length?null:Array.from(r).map(i=>{const c=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:o,position:i.getAttribute("data-handlepos"),x:(c.left-n.left)/s,y:(c.top-n.top)/s,...Co(i)}})};function qa({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:o,sourceControlY:r,targetControlX:i,targetControlY:c}){const l=e*.125+o*.375+i*.375+n*.125,d=t*.125+r*.375+c*.375+s*.125,u=Math.abs(l-e),h=Math.abs(d-t);return[l,d,u,h]}function wn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Ir({pos:e,x1:t,y1:n,x2:s,y2:o,c:r}){switch(e){case q.Left:return[t-wn(t-s,r),n];case q.Right:return[t+wn(s-t,r),n];case q.Top:return[t,n-wn(n-o,r)];case q.Bottom:return[t,n+wn(o-n,r)]}}function So({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:r=q.Top,curvature:i=.25}){const[c,l]=Ir({pos:n,x1:e,y1:t,x2:s,y2:o,c:i}),[d,u]=Ir({pos:r,x1:s,y1:o,x2:e,y2:t,c:i}),[h,f,p,m]=qa({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:c,sourceControlY:l,targetControlX:d,targetControlY:u});return[`M${e},${t} C${c},${l} ${d},${u} ${s},${o}`,h,f,p,m]}function Za({sourceX:e,sourceY:t,targetX:n,targetY:s}){const o=Math.abs(n-e)/2,r=n<e?n+o:n-o,i=Math.abs(s-t)/2,c=s<t?s+i:s-i;return[r,c,o,i]}function Rm({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:o=!1,zIndexMode:r="basic"}){if(r==="manual")return s;const i=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 i+c}function Am({sourceNode:e,targetNode:t,width:n,height:s,transform:o}){const r=rs(zn(e),zn(t));r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1);const i={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:s/o[2]};return Ln(i,is(r))>0}const Dm=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,Pm=(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)),Tm=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",Te.error006()),t;const s=n.getEdgeId||Dm;let o;return Ta(e)?o={...e}:o={...e,id:s(e)},Pm(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function Ga({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[o,r,i,c]=Za({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,o,r,i,c]}const $r={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},Om=({source:e,sourcePosition:t=q.Bottom,target:n})=>t===q.Left||t===q.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},Rr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function zm({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:s=q.Top,center:o,offset:r,stepPosition:i}){const c=$r[t],l=$r[s],d={x:e.x+c.x*r,y:e.y+c.y*r},u={x:n.x+l.x*r,y:n.y+l.y*r},h=Om({source:d,sourcePosition:t,target:u}),f=h.x!==0?"x":"y",p=h[f];let m=[],w,x;const y={x:0,y:0},j={x:0,y:0},[,,g,v]=Za({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[f]*l[f]===-1){f==="x"?(w=o.x??d.x+(u.x-d.x)*i,x=o.y??(d.y+u.y)/2):(w=o.x??(d.x+u.x)/2,x=o.y??d.y+(u.y-d.y)*i);const I=[{x:w,y:d.y},{x:w,y:u.y}],R=[{x:d.x,y:x},{x:u.x,y:x}];c[f]===p?m=f==="x"?I:R:m=f==="x"?R:I}else{const I=[{x:d.x,y:u.y}],R=[{x:u.x,y:d.y}];if(f==="x"?m=c.x===p?R:I:m=c.y===p?I:R,t===s){const b=Math.abs(e[f]-n[f]);if(b<=r){const S=Math.min(r-1,r-b);c[f]===p?y[f]=(d[f]>e[f]?-1:1)*S:j[f]=(u[f]>n[f]?-1:1)*S}}if(t!==s){const b=f==="x"?"y":"x",S=c[f]===l[b],_=d[b]>u[b],M=d[b]<u[b];(c[f]===1&&(!S&&_||S&&M)||c[f]!==1&&(!S&&M||S&&_))&&(m=f==="x"?I:R)}const H={x:d.x+y.x,y:d.y+y.y},T={x:u.x+j.x,y:u.y+j.y},$=Math.max(Math.abs(H.x-m[0].x),Math.abs(T.x-m[0].x)),A=Math.max(Math.abs(H.y-m[0].y),Math.abs(T.y-m[0].y));$>=A?(w=(H.x+T.x)/2,x=m[0].y):(w=m[0].x,x=(H.y+T.y)/2)}const E={x:d.x+y.x,y:d.y+y.y},k={x:u.x+j.x,y:u.y+j.y};return[[e,...E.x!==m[0].x||E.y!==m[0].y?[E]:[],...m,...k.x!==m[m.length-1].x||k.y!==m[m.length-1].y?[k]:[],n],w,x,g,v]}function Lm(e,t,n,s){const o=Math.min(Rr(e,t)/2,Rr(t,n)/2,s),{x:r,y:i}=t;if(e.x===r&&r===n.x||e.y===i&&i===n.y)return`L${r} ${i}`;if(e.y===i){const d=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${r+o*d},${i}Q ${r},${i} ${r},${i+o*u}`}const c=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${r},${i+o*l}Q ${r},${i} ${r+o*c},${i}`}function Hn({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:r=q.Top,borderRadius:i=5,centerX:c,centerY:l,offset:d=20,stepPosition:u=.5}){const[h,f,p,m,w]=zm({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:o},targetPosition:r,center:{x:c,y:l},offset:d,stepPosition:u});let x=`M${h[0].x} ${h[0].y}`;for(let y=1;y<h.length-1;y++)x+=Lm(h[y-1],h[y],h[y+1],i);return x+=`L${h[h.length-1].x} ${h[h.length-1].y}`,[x,f,p,m,w]}function Ar(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Hm(e){const{sourceNode:t,targetNode:n}=e;if(!Ar(t)||!Ar(n))return null;const s=t.internals.handleBounds||Dr(t.handles),o=n.internals.handleBounds||Dr(n.handles),r=Pr(s?.source??[],e.sourceHandle),i=Pr(e.connectionMode===St.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!r||!i)return e.onError?.("008",Te.error008(r?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=r?.position||q.Bottom,l=i?.position||q.Top,d=pt(t,r,c),u=pt(n,i,l);return{sourceX:d.x,sourceY:d.y,targetX:u.x,targetY:u.y,sourcePosition:c,targetPosition:l}}function Dr(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 pt(e,t,n=q.Left,s=!1){const o=(t?.x??0)+e.internals.positionAbsolute.x,r=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:c}=t??ze(e);if(s)return{x:o+i/2,y:r+c/2};switch(t?.position??n){case q.Top:return{x:o+i/2,y:r};case q.Right:return{x:o+i,y:r+c/2};case q.Bottom:return{x:o+i/2,y:r+c};case q.Left:return{x:o,y:r+c/2}}}function Pr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Vs(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function Vm(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:o}){const r=new Set;return e.reduce((i,c)=>([c.markerStart||s,c.markerEnd||o].forEach(l=>{if(l&&typeof l=="object"){const d=Vs(l,t);r.has(d)||(i.push({id:d,color:l.color||n,...l}),r.add(d))}}),i),[]).sort((i,c)=>i.id.localeCompare(c.id))}const Ua=1e3,Fm=10,_o={nodeOrigin:[0,0],nodeExtent:Gt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Bm={..._o,checkEquality:!0};function Mo(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function Wm(e,t,n){const s=Mo(_o,n);for(const o of e.values())if(o.parentId)$o(o,e,t,s);else{const r=cn(o,s.nodeOrigin),i=ht(o.extent)?o.extent:s.nodeExtent,c=ft(r,i,ze(o));o.internals.positionAbsolute=c}}function Ym(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],s=[];for(const o of e.handles){const r={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(r):o.type==="target"&&s.push(r)}return{source:n,target:s}}function Io(e){return e==="manual"}function Fs(e,t,n,s={}){const o=Mo(Bm,s),r={i:0},i=new Map(t),c=o?.elevateNodesOnSelect&&!Io(o.zIndexMode)?Ua:0;let l=e.length>0,d=!1;t.clear(),n.clear();for(const u of e){let h=i.get(u.id);if(o.checkEquality&&u===h?.internals.userNode)t.set(u.id,h);else{const f=cn(u,o.nodeOrigin),p=ht(u.extent)?u.extent:o.nodeExtent,m=ft(f,p,ze(u));h={...o.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:m,handleBounds:Ym(u,h),z:Ka(u,c,o.zIndexMode),userNode:u}},t.set(u.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),u.parentId&&$o(h,t,n,s,r),d||=u.selected??!1}return{nodesInitialized:l,hasSelectedNodes:d}}function Xm(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 $o(e,t,n,s,o){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:c,zIndexMode:l}=Mo(_o,s),d=e.parentId,u=t.get(d);if(!u){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Xm(e,n),o&&!u.parentId&&u.internals.rootParentIndex===void 0&&l==="auto"&&(u.internals.rootParentIndex=++o.i,u.internals.z=u.internals.z+o.i*Fm),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const h=r&&!Io(l)?Ua:0,{x:f,y:p,z:m}=qm(e,u,i,c,h,l),{positionAbsolute:w}=e.internals,x=f!==w.x||p!==w.y;(x||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:p}:w,z:m}})}function Ka(e,t,n){const s=Ae(e.zIndex)?e.zIndex:0;return Io(n)?s:s+(e.selected?t:0)}function qm(e,t,n,s,o,r){const{x:i,y:c}=t.internals.positionAbsolute,l=ze(e),d=cn(e,n),u=ht(e.extent)?ft(d,e.extent,l):d;let h=ft({x:i+u.x,y:c+u.y},s,l);e.extent==="parent"&&(h=za(h,l,t));const f=Ka(e,o,r),p=t.internals.z??0;return{x:h.x,y:h.y,z:p>=f?p+1:f}}function Ro(e,t,n,s=[0,0]){const o=[],r=new Map;for(const i of e){const c=t.get(i.parentId);if(!c)continue;const l=r.get(i.parentId)?.expandedRect??Kt(c),d=La(l,i.rect);r.set(i.parentId,{expandedRect:d,parent:c})}return r.size>0&&r.forEach(({expandedRect:i,parent:c},l)=>{const d=c.internals.positionAbsolute,u=ze(c),h=c.origin??s,f=i.x<d.x?Math.round(Math.abs(d.x-i.x)):0,p=i.y<d.y?Math.round(Math.abs(d.y-i.y)):0,m=Math.max(u.width,Math.round(i.width)),w=Math.max(u.height,Math.round(i.height)),x=(m-u.width)*h[0],y=(w-u.height)*h[1];(f>0||p>0||x||y)&&(o.push({id:l,type:"position",position:{x:c.position.x-f+x,y:c.position.y-p+y}}),n.get(l)?.forEach(j=>{e.some(g=>g.id===j.id)||o.push({id:j.id,type:"position",position:{x:j.position.x+f,y:j.position.y+p}})})),(u.width<i.width||u.height<i.height||f||p)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:m+(f?h[0]*f-x:0),height:w+(p?h[1]*p-y:0)}})}),o}function Zm(e,t,n,s,o,r,i){const c=s?.querySelector(".xyflow__viewport");let l=!1;if(!c)return{changes:[],updatedInternals:l};const d=[],u=window.getComputedStyle(c),{m22:h}=new window.DOMMatrixReadOnly(u.transform),f=[];for(const p of e.values()){const m=t.get(p.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),l=!0;continue}const w=Co(p.nodeElement),x=m.measured.width!==w.width||m.measured.height!==w.height;if(!!(w.width&&w.height&&(x||!m.internals.handleBounds||p.force))){const j=p.nodeElement.getBoundingClientRect(),g=ht(m.extent)?m.extent:r;let{positionAbsolute:v}=m.internals;if(m.parentId&&m.extent==="parent"){const k=t.get(m.parentId);k&&(v=za(v,w,k))}else g&&(v=ft(v,g,w));const E={...m,measured:w,internals:{...m.internals,positionAbsolute:v,handleBounds:{source:Mr("source",p.nodeElement,j,h,m.id),target:Mr("target",p.nodeElement,j,h,m.id)}}};t.set(m.id,E),m.parentId&&$o(E,t,n,{nodeOrigin:o,zIndexMode:i}),l=!0,x&&(d.push({id:m.id,type:"dimensions",dimensions:w}),m.expandParent&&m.parentId&&f.push({id:m.id,parentId:m.parentId,rect:Kt(E,o)}))}}if(f.length>0){const p=Ro(f,t,n,o);d.push(...p)}return{changes:d,updatedInternals:l}}async function Gm({delta:e,panZoom:t,transform:n,translateExtent:s,width:o,height:r}){if(!t||!e.x&&!e.y)return!1;const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,r]],s);return!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2])}function Tr(e,t,n,s,o,r){let i=o;const c=s.get(i)||new Map;s.set(i,c.set(n,t)),i=`${o}-${e}`;const l=s.get(i)||new Map;if(s.set(i,l.set(n,t)),r){i=`${o}-${e}-${r}`;const d=s.get(i)||new Map;s.set(i,d.set(n,t))}}function Qa(e,t,n){e.clear(),t.clear();for(const s of n){const{source:o,target:r,sourceHandle:i=null,targetHandle:c=null}=s,l={edgeId:s.id,source:o,target:r,sourceHandle:i,targetHandle:c},d=`${o}-${i}--${r}-${c}`,u=`${r}-${c}--${o}-${i}`;Tr("source",l,u,e,o,i),Tr("target",l,d,e,r,c),t.set(s.id,s)}}function Ja(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ja(n,t):!1}function Or(e,t,n){let s=e;do{if(s?.matches?.(t))return!0;if(s===n)return!1;s=s?.parentElement}while(s);return!1}function Um(e,t,n,s){const o=new Map;for(const[r,i]of e)if((i.selected||i.id===s)&&(!i.parentId||!Ja(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const c=e.get(r);c&&o.set(r,{id:r,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 vs({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){const o=[];for(const[i,c]of t){const l=n.get(i)?.internals.userNode;l&&o.push({...l,position:c.position,dragging:s})}if(!e)return[o[0],o];const r=n.get(e)?.internals.userNode;return[r?{...r,position:t.get(e)?.position||r.position,dragging:s}:o[0],o]}function Km({dragItems:e,snapGrid:t,x:n,y:s}){const o=e.values().next().value;if(!o)return null;const r={x:n-o.distance.x,y:s-o.distance.y},i=dn(r,t);return{x:i.x-r.x,y:i.y-r.y}}function Qm({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:o}){let r={x:null,y:null},i=0,c=new Map,l=!1,d={x:0,y:0},u=null,h=!1,f=null,p=!1,m=!1,w=null;function x({noDragClassName:j,handleSelector:g,domNode:v,isSelectable:E,nodeId:k,nodeClickDistance:C=0}){f=ke(v);function I({x:$,y:A}){const{nodeLookup:b,nodeExtent:S,snapGrid:_,snapToGrid:M,nodeOrigin:D,onNodeDrag:P,onSelectionDrag:L,onError:V,updateNodePositions:F}=t();r={x:$,y:A};let O=!1;const B=c.size>1,W=B&&S?Hs(ln(c)):null,Q=B&&M?Km({dragItems:c,snapGrid:_,x:$,y:A}):null;for(const[G,z]of c){if(!b.has(G))continue;let Z={x:$-z.distance.x,y:A-z.distance.y};M&&(Z=Q?{x:Math.round(Z.x+Q.x),y:Math.round(Z.y+Q.y)}:dn(Z,_));let te=null;if(B&&S&&!z.extent&&W){const{positionAbsolute:K}=z.internals,ne=K.x-W.x+S[0][0],ie=K.x+z.measured.width-W.x2+S[1][0],ce=K.y-W.y+S[0][1],pe=K.y+z.measured.height-W.y2+S[1][1];te=[[ne,ce],[ie,pe]]}const{position:ee,positionAbsolute:U}=Oa({nodeId:G,nextPosition:Z,nodeLookup:b,nodeExtent:te||S,nodeOrigin:D,onError:V});O=O||z.position.x!==ee.x||z.position.y!==ee.y,z.position=ee,z.internals.positionAbsolute=U}if(m=m||O,!!O&&(F(c,!0),w&&(s||P||!k&&L))){const[G,z]=vs({nodeId:k,dragItems:c,nodeLookup:b});s?.(w,c,G,z),P?.(w,G,z),k||L?.(w,z)}}async function R(){if(!u)return;const{transform:$,panBy:A,autoPanSpeed:b,autoPanOnNodeDrag:S}=t();if(!S){l=!1,cancelAnimationFrame(i);return}const[_,M]=ko(d,u,b);(_!==0||M!==0)&&(r.x=(r.x??0)-_/$[2],r.y=(r.y??0)-M/$[2],await A({x:_,y:M})&&I(r)),i=requestAnimationFrame(R)}function H($){const{nodeLookup:A,multiSelectionActive:b,nodesDraggable:S,transform:_,snapGrid:M,snapToGrid:D,selectNodesOnDrag:P,onNodeDragStart:L,onSelectionDragStart:V,unselectNodesAndEdges:F}=t();h=!0,(!P||!E)&&!b&&k&&(A.get(k)?.selected||F()),E&&P&&k&&e?.(k);const O=Wt($.sourceEvent,{transform:_,snapGrid:M,snapToGrid:D,containerBounds:u});if(r=O,c=Um(A,S,O,k),c.size>0&&(n||L||!k&&V)){const[B,W]=vs({nodeId:k,dragItems:c,nodeLookup:A});n?.($.sourceEvent,c,B,W),L?.($.sourceEvent,B,W),k||V?.($.sourceEvent,W)}}const T=ga().clickDistance(C).on("start",$=>{const{domNode:A,nodeDragThreshold:b,transform:S,snapGrid:_,snapToGrid:M}=t();u=A?.getBoundingClientRect()||null,p=!1,m=!1,w=$.sourceEvent,b===0&&H($),r=Wt($.sourceEvent,{transform:S,snapGrid:_,snapToGrid:M,containerBounds:u}),d=De($.sourceEvent,u)}).on("drag",$=>{const{autoPanOnNodeDrag:A,transform:b,snapGrid:S,snapToGrid:_,nodeDragThreshold:M,nodeLookup:D}=t(),P=Wt($.sourceEvent,{transform:b,snapGrid:S,snapToGrid:_,containerBounds:u});if(w=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||k&&!D.has(k))&&(p=!0),!p){if(!l&&A&&h&&(l=!0,R()),!h){const L=De($.sourceEvent,u),V=L.x-d.x,F=L.y-d.y;Math.sqrt(V*V+F*F)>M&&H($)}(r.x!==P.xSnapped||r.y!==P.ySnapped)&&c&&h&&(d=De($.sourceEvent,u),I(P))}}).on("end",$=>{if(!h||p){p&&c.size>0&&t().updateNodePositions(c,!1);return}if(l=!1,h=!1,cancelAnimationFrame(i),c.size>0){const{nodeLookup:A,updateNodePositions:b,onNodeDragStop:S,onSelectionDragStop:_}=t();if(m&&(b(c,!1),m=!1),o||S||!k&&_){const[M,D]=vs({nodeId:k,dragItems:c,nodeLookup:A,dragging:!1});o?.($.sourceEvent,c,M,D),S?.($.sourceEvent,M,D),k||_?.($.sourceEvent,D)}}}).filter($=>{const A=$.target;return!$.button&&(!j||!Or(A,`.${j}`,v))&&(!g||Or(A,g,v))});f.call(T)}function y(){f?.on(".drag",null)}return{update:x,destroy:y}}function Jm(e,t,n){const s=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const r of t.values())Ln(o,Kt(r))>0&&s.push(r);return s}const eg=250;function tg(e,t,n,s){let o=[],r=1/0;const i=Jm(e,n,t+eg);for(const c of i){const l=[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]];for(const d of l){if(s.nodeId===d.nodeId&&s.type===d.type&&s.id===d.id)continue;const{x:u,y:h}=pt(c,d,d.position,!0),f=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(h-e.y,2));f>t||(f<r?(o=[{...d,x:u,y:h}],r=f):f===r&&o.push({...d,x:u,y:h}))}}if(!o.length)return null;if(o.length>1){const c=s.type==="source"?"target":"source";return o.find(l=>l.type===c)??o[0]}return o[0]}function ec(e,t,n,s,o,r=!1){const i=s.get(e);if(!i)return null;const c=o==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],l=(n?c?.find(d=>d.id===n):c?.[0])??null;return l&&r?{...l,...pt(i,l,l.position,!0)}:l}function tc(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function ng(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const nc=()=>!0;function sg(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:o,edgeUpdaterType:r,isTarget:i,domNode:c,nodeLookup:l,lib:d,autoPanOnConnect:u,flowId:h,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:w,onConnectEnd:x,isValidConnection:y=nc,onReconnectEnd:j,updateConnection:g,getTransform:v,getFromHandle:E,autoPanSpeed:k,dragThreshold:C=1,handleDomNode:I}){const R=Wa(e.target);let H=0,T;const{x:$,y:A}=De(e),b=tc(r,I),S=c?.getBoundingClientRect();let _=!1;if(!S||!b)return;const M=ec(o,b,s,l,t);if(!M)return;let D=De(e,S),P=!1,L=null,V=!1,F=null;function O(){if(!u||!S)return;const[ee,U]=ko(D,S,k);f({x:ee,y:U}),H=requestAnimationFrame(O)}const B={...M,nodeId:o,type:b,position:M.position},W=l.get(o);let G={inProgress:!0,isValid:null,from:pt(W,B,q.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:W,to:D,toHandle:null,toPosition:Er[B.position],toNode:null,pointer:D};function z(){_=!0,g(G),m?.(e,{nodeId:o,handleId:s,handleType:b})}C===0&&z();function Z(ee){if(!_){const{x:pe,y:Ne}=De(ee),Ce=pe-$,Se=Ne-A;if(!(Ce*Ce+Se*Se>C*C))return;z()}if(!E()||!B){te(ee);return}const U=v();D=De(ee,S),T=tg(un(D,U,!1,[1,1]),n,l,B),P||(O(),P=!0);const K=sc(ee,{handle:T,connectionMode:t,fromNodeId:o,fromHandleId:s,fromType:i?"target":"source",isValidConnection:y,doc:R,lib:d,flowId:h,nodeLookup:l});F=K.handleDomNode,L=K.connection,V=ng(!!T,K.isValid);const ne=l.get(o),ie=ne?pt(ne,B,q.Left,!0):G.from,ce={...G,from:ie,isValid:V,to:K.toHandle&&V?Mt({x:K.toHandle.x,y:K.toHandle.y},U):D,toHandle:K.toHandle,toPosition:V&&K.toHandle?K.toHandle.position:Er[B.position],toNode:K.toHandle?l.get(K.toHandle.nodeId):null,pointer:D};g(ce),G=ce}function te(ee){if(!("touches"in ee&&ee.touches.length>0)){if(_){(T||F)&&L&&V&&w?.(L);const{inProgress:U,...K}=G,ne={...K,toPosition:G.toHandle?G.toPosition:null};x?.(ee,ne),r&&j?.(ee,ne)}p(),cancelAnimationFrame(H),P=!1,V=!1,L=null,F=null,R.removeEventListener("mousemove",Z),R.removeEventListener("mouseup",te),R.removeEventListener("touchmove",Z),R.removeEventListener("touchend",te)}}R.addEventListener("mousemove",Z),R.addEventListener("mouseup",te),R.addEventListener("touchmove",Z),R.addEventListener("touchend",te)}function sc(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:r,doc:i,lib:c,flowId:l,isValidConnection:d=nc,nodeLookup:u}){const h=r==="target",f=t?i.querySelector(`.${c}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=De(e),w=i.elementFromPoint(p,m),x=w?.classList.contains(`${c}-flow__handle`)?w:f,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const j=tc(void 0,x),g=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),E=x.classList.contains("connectable"),k=x.classList.contains("connectableend");if(!g||!j)return y;const C={source:h?g:s,sourceHandle:h?v:o,target:h?s:g,targetHandle:h?o:v};y.connection=C;const R=E&&k&&(n===St.Strict?h&&j==="source"||!h&&j==="target":g!==s||v!==o);y.isValid=R&&d(C),y.toHandle=ec(g,j,v,u,n,!0)}return y}const Bs={onPointerDown:sg,isValid:sc};function og({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const o=ke(e);function r({translateExtent:c,width:l,height:d,zoomStep:u=1,pannable:h=!0,zoomable:f=!0,inversePan:p=!1}){const m=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const v=n(),E=g.sourceEvent.ctrlKey&&Qt()?10:1,k=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*u,C=v[2]*Math.pow(2,k*E);t.scaleTo(C)};let w=[0,0];const x=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(w=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},y=g=>{const v=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const E=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],k=[E[0]-w[0],E[1]-w[1]];w=E;const C=s()*Math.max(v[2],Math.log(v[2]))*(p?-1:1),I={x:v[0]-k[0]*C,y:v[1]-k[1]*C},R=[[0,0],[l,d]];t.setViewportConstrained({x:I.x,y:I.y,zoom:v[2]},R,c)},j=$a().on("start",x).on("zoom",h?y:null).on("zoom.wheel",f?m:null);o.call(j,{})}function i(){o.on("zoom",null)}return{update:r,destroy:i,pointer:$e}}const as=e=>({x:e.x,y:e.y,zoom:e.k}),bs=({x:e,y:t,zoom:n})=>os.translate(e,t).scale(n),Qe=(e,t)=>e.target.closest(`.${t}`),oc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),rg=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ns=(e,t=0,n=rg,s=()=>{})=>{const o=typeof t=="number"&&t>0;return o||s(),o?e.transition().duration(t).ease(n).on("end",s):e},rc=e=>{const t=e.ctrlKey&&Qt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function ig({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:o,panOnScrollSpeed:r,zoomOnPinch:i,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:d}){return u=>{if(Qe(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const h=n.property("__zoom").k||1;if(u.ctrlKey&&i){const x=$e(u),y=rc(u),j=h*Math.pow(2,y);s.scaleTo(n,j,x,u);return}const f=u.deltaMode===1?20:1;let p=o===at.Vertical?0:u.deltaX*f,m=o===at.Horizontal?0:u.deltaY*f;!Qt()&&u.shiftKey&&o!==at.Vertical&&(p=u.deltaY*f,m=0),s.translateBy(n,-(p/h)*r,-(m/h)*r,{internal:!0});const w=as(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?l?.(u,w):(e.isPanScrolling=!0,c?.(u,w)),e.panScrollTimeout=setTimeout(()=>{d?.(u,w),e.isPanScrolling=!1},150)}}function ag({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,o){const r=s.type==="wheel",i=!t&&r&&!s.ctrlKey,c=Qe(s,e);if(s.ctrlKey&&r&&c&&s.preventDefault(),i||c)return null;s.preventDefault(),n.call(this,s,o)}}function cg({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{if(s.sourceEvent?.internal)return;const o=as(s.transform);e.mouseButton=s.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,s.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(s.sourceEvent,o)}}function lg({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:o}){return r=>{e.usedRightMouseButton=!!(n&&oc(t,e.mouseButton??0)),r.sourceEvent?.sync||s([r.transform.x,r.transform.y,r.transform.k]),o&&!r.sourceEvent?.internal&&o?.(r.sourceEvent,as(r.transform))}}function dg({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:o,onPaneContextMenu:r}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,r&&oc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&r(i.sourceEvent),e.usedRightMouseButton=!1,s(!1),o)){const c=as(i.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(i.sourceEvent,c)},n?150:0)}}}function ug({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:c,noWheelClassName:l,noPanClassName:d,lib:u,connectionInProgress:h}){return f=>{const p=t||n,m=s&&f.ctrlKey,w=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Qe(f,`${u}-flow__node`)||Qe(f,`${u}-flow__edge`)||Qe(f,`${u}-flow__selection`)||Qe(f,`${u}-flow__nodesselection`)))return!0;if(!o&&!p&&!r&&!i&&!s||c||h&&!w||Qe(f,l)&&w||Qe(f,d)&&(!w||r&&w&&!t)||!s&&f.ctrlKey&&w)return!1;if(!s&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!r&&!m&&w||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const x=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||w||e)&&x}}function fg({domNode:e,minZoom:t,maxZoom:n,translateExtent:s,viewport:o,onPanZoom:r,onPanZoomStart:i,onPanZoomEnd:c,onDraggingChange:l}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let h=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(A=>{const b=A[0];b&&(h=[[0,0],[b.contentRect.width,b.contentRect.height]])}):null)?.observe(e);const p=$a().extent(()=>h).scaleExtent([t,n]).translateExtent(s),m=ke(e).call(p);v({x:o.x,y:o.y,zoom:_t(o.zoom,t,n)},[[0,0],[u.width,u.height]],s);const w=m.on("wheel.zoom"),x=m.on("dblclick.zoom");p.wheelDelta(rc);async function y(A,b){return m?new Promise(S=>{p?.interpolate(b?.interpolate==="linear"?Bt:En).transform(Ns(m,b?.duration,b?.ease,()=>S(!0)),A)}):!1}function j({noWheelClassName:A,noPanClassName:b,onPaneContextMenu:S,userSelectionActive:_,panOnScroll:M,panOnDrag:D,panOnScrollMode:P,panOnScrollSpeed:L,preventScrolling:V,zoomOnPinch:F,zoomOnScroll:O,zoomOnDoubleClick:B,panActivationKeyPressed:W=!1,zoomActivationKeyPressed:Q,lib:G,onTransformChange:z,connectionInProgress:Z,paneClickDistance:te,selectionOnDrag:ee}){_&&!d.isZoomingOrPanning&&g();const U=M&&!Q&&!_;p.clickDistance(ee?1/0:!Ae(te)||te<0?0:te);const K=U?ig({zoomPanValues:d,noWheelClassName:A,d3Selection:m,d3Zoom:p,panOnScrollMode:P,panOnScrollSpeed:L,zoomOnPinch:F,onPanZoomStart:i,onPanZoom:r,onPanZoomEnd:c}):ag({noWheelClassName:A,preventScrolling:V,d3ZoomHandler:w});m.on("wheel.zoom",K,{passive:!1});const ne=cg({zoomPanValues:d,onDraggingChange:l,onPanZoomStart:i});p.on("start",ne);const ie=lg({zoomPanValues:d,panOnDrag:D,onPaneContextMenu:!!S,onPanZoom:r,onTransformChange:z});p.on("zoom",ie);const ce=dg({zoomPanValues:d,panOnDrag:D,panOnScroll:M,onPaneContextMenu:S,onPanZoomEnd:c,onDraggingChange:l});p.on("end",ce);const pe=ug({panActivationKeyPressed:W,zoomActivationKeyPressed:Q,panOnDrag:D,zoomOnScroll:O,panOnScroll:M,zoomOnDoubleClick:B,zoomOnPinch:F,userSelectionActive:_,noPanClassName:b,noWheelClassName:A,lib:G,connectionInProgress:Z});p.filter(pe),B?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function g(){p.on("zoom",null)}async function v(A,b,S){const _=bs(A),M=p?.constrain()(_,b,S);return M&&await y(M),M}async function E(A,b){const S=bs(A);return await y(S,b),S}function k(A){if(m){const b=bs(A),S=m.property("__zoom");(S.k!==A.zoom||S.x!==A.x||S.y!==A.y)&&p?.transform(m,b,null,{sync:!0})}}function C(){const A=m?Ia(m.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}async function I(A,b){return m?new Promise(S=>{p?.interpolate(b?.interpolate==="linear"?Bt:En).scaleTo(Ns(m,b?.duration,b?.ease,()=>S(!0)),A)}):!1}async function R(A,b){return m?new Promise(S=>{p?.interpolate(b?.interpolate==="linear"?Bt:En).scaleBy(Ns(m,b?.duration,b?.ease,()=>S(!0)),A)}):!1}function H(A){p?.scaleExtent(A)}function T(A){p?.translateExtent(A)}function $(A){const b=!Ae(A)||A<0?0:A;p?.clickDistance(b)}return{update:j,destroy:g,setViewport:E,setViewportConstrained:v,getViewport:C,scaleTo:I,scaleBy:R,setScaleExtent:H,setTranslateExtent:T,syncViewport:k,setClickDistance:$}}var It;(function(e){e.Line="line",e.Handle="handle"})(It||(It={}));function hg({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:o,affectsY:r}){const i=e-t,c=n-s,l=[i>0?1:i<0?-1:0,c>0?1:c<0?-1:0];return i&&o&&(l[0]=l[0]*-1),c&&r&&(l[1]=l[1]*-1),l}function zr(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 Ue(e,t){return Math.max(0,t-e)}function Ke(e,t){return Math.max(0,e-t)}function vn(e,t,n){return Math.max(0,t-e,e-n)}function Lr(e,t){return e?!t:t}function pg(e,t,n,s,o,r,i,c){let{affectsX:l,affectsY:d}=t;const{isHorizontal:u,isVertical:h}=t,f=u&&h,{xSnapped:p,ySnapped:m}=n,{minWidth:w,maxWidth:x,minHeight:y,maxHeight:j}=s,{x:g,y:v,width:E,height:k,aspectRatio:C}=e;let I=Math.floor(u?p-e.pointerX:0),R=Math.floor(h?m-e.pointerY:0);const H=E+(l?-I:I),T=k+(d?-R:R),$=-r[0]*E,A=-r[1]*k;let b=vn(H,w,x),S=vn(T,y,j);if(i){let D=0,P=0;l&&I<0?D=Ue(g+I+$,i[0][0]):!l&&I>0&&(D=Ke(g+H+$,i[1][0])),d&&R<0?P=Ue(v+R+A,i[0][1]):!d&&R>0&&(P=Ke(v+T+A,i[1][1])),b=Math.max(b,D),S=Math.max(S,P)}if(c){let D=0,P=0;l&&I>0?D=Ke(g+I,c[0][0]):!l&&I<0&&(D=Ue(g+H,c[1][0])),d&&R>0?P=Ke(v+R,c[0][1]):!d&&R<0&&(P=Ue(v+T,c[1][1])),b=Math.max(b,D),S=Math.max(S,P)}if(o){if(u){const D=vn(H/C,y,j)*C;if(b=Math.max(b,D),i){let P=0;!l&&!d||l&&!d&&f?P=Ke(v+A+H/C,i[1][1])*C:P=Ue(v+A+(l?I:-I)/C,i[0][1])*C,b=Math.max(b,P)}if(c){let P=0;!l&&!d||l&&!d&&f?P=Ue(v+H/C,c[1][1])*C:P=Ke(v+(l?I:-I)/C,c[0][1])*C,b=Math.max(b,P)}}if(h){const D=vn(T*C,w,x)/C;if(S=Math.max(S,D),i){let P=0;!l&&!d||d&&!l&&f?P=Ke(g+T*C+$,i[1][0])/C:P=Ue(g+(d?R:-R)*C+$,i[0][0])/C,S=Math.max(S,P)}if(c){let P=0;!l&&!d||d&&!l&&f?P=Ue(g+T*C,c[1][0])/C:P=Ke(g+(d?R:-R)*C,c[0][0])/C,S=Math.max(S,P)}}}R=R+(R<0?S:-S),I=I+(I<0?b:-b),o&&(f?H>T*C?R=(Lr(l,d)?-I:I)/C:I=(Lr(l,d)?-R:R)*C:u?(R=I/C,d=l):(I=R*C,l=d));const _=l?g+I:g,M=d?v+R:v;return{width:E+(l?-I:I),height:k+(d?-R:R),x:r[0]*I*(l?-1:1)+_,y:r[1]*R*(d?-1:1)+M}}const ic={width:0,height:0,x:0,y:0},mg={...ic,pointerX:0,pointerY:0,aspectRatio:1};function gg(e,t,n){const s=t.position.x+e.position.x,o=t.position.y+e.position.y,r=e.measured.width??0,i=e.measured.height??0,c=n[0]*r,l=n[1]*i;return[[s-c,o-l],[s+r-c,o+i-l]]}function xg({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:o}){const r=ke(e);let i={controlDirection:zr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:d,boundaries:u,keepAspectRatio:h,resizeDirection:f,onResizeStart:p,onResize:m,onResizeEnd:w,shouldResize:x}){let y={...ic},j={...mg};i={boundaries:u,resizeDirection:f,keepAspectRatio:h,controlDirection:zr(d)};let g,v=null,E=[],k,C,I,R=!1;const H=ga().on("start",T=>{const{nodeLookup:$,transform:A,snapGrid:b,snapToGrid:S,nodeOrigin:_,paneDomNode:M}=n();if(g=$.get(t),!g)return;v=M?.getBoundingClientRect()??null;const{xSnapped:D,ySnapped:P}=Wt(T.sourceEvent,{transform:A,snapGrid:b,snapToGrid:S,containerBounds:v});y={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},j={...y,pointerX:D,pointerY:P,aspectRatio:y.width/y.height},k=void 0,C=ht(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(k=$.get(g.parentId)),k&&g.extent==="parent"&&(C=[[0,0],[k.measured.width,k.measured.height]]),E=[],I=void 0;for(const[L,V]of $)if(V.parentId===t&&(E.push({id:L,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const F=gg(V,g,V.origin??_);I?I=[[Math.min(F[0][0],I[0][0]),Math.min(F[0][1],I[0][1])],[Math.max(F[1][0],I[1][0]),Math.max(F[1][1],I[1][1])]]:I=F}p?.(T,{...y})}).on("drag",T=>{const{transform:$,snapGrid:A,snapToGrid:b,nodeOrigin:S}=n(),_=Wt(T.sourceEvent,{transform:$,snapGrid:A,snapToGrid:b,containerBounds:v}),M=[];if(!g)return;const{x:D,y:P,width:L,height:V}=y,F={},O=g.origin??S,{width:B,height:W,x:Q,y:G}=pg(j,i.controlDirection,_,i.boundaries,i.keepAspectRatio,O,C,I),z=B!==L,Z=W!==V,te=Q!==D&&z,ee=G!==P&&Z;if(!te&&!ee&&!z&&!Z)return;if((te||ee||O[0]===1||O[1]===1)&&(F.x=te?Q:y.x,F.y=ee?G:y.y,y.x=F.x,y.y=F.y,E.length>0)){const ie=Q-D,ce=G-P;for(const pe of E)pe.position={x:pe.position.x-ie+O[0]*(B-L),y:pe.position.y-ce+O[1]*(W-V)},M.push(pe)}if((z||Z)&&(F.width=z&&(!i.resizeDirection||i.resizeDirection==="horizontal")?B:y.width,F.height=Z&&(!i.resizeDirection||i.resizeDirection==="vertical")?W:y.height,y.width=F.width,y.height=F.height),k&&g.expandParent){const ie=O[0]*(F.width??0);F.x&&F.x<ie&&(y.x=ie,j.x=j.x-(F.x-ie));const ce=O[1]*(F.height??0);F.y&&F.y<ce&&(y.y=ce,j.y=j.y-(F.y-ce))}const U=hg({width:y.width,prevWidth:L,height:y.height,prevHeight:V,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),K={...y,direction:U};x?.(T,K)!==!1&&(R=!0,m?.(T,K),s(F,M))}).on("end",T=>{R&&(w?.(T,{...y}),o?.({...y}),R=!1)});r.call(H)}function l(){r.on(".drag",null)}return{update:c,destroy:l}}var js={exports:{}},ks={},Es={exports:{}},Cs={};var Hr;function yg(){if(Hr)return Cs;Hr=1;var e=Li();function t(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,o=e.useEffect,r=e.useLayoutEffect,i=e.useDebugValue;function c(h,f){var p=f(),m=s({inst:{value:p,getSnapshot:f}}),w=m[0].inst,x=m[1];return r(function(){w.value=p,w.getSnapshot=f,l(w)&&x({inst:w})},[h,p,f]),o(function(){return l(w)&&x({inst:w}),h(function(){l(w)&&x({inst:w})})},[h]),i(p),p}function l(h){var f=h.getSnapshot;h=h.value;try{var p=f();return!n(h,p)}catch{return!0}}function d(h,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:c;return Cs.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Cs}var Vr;function wg(){return Vr||(Vr=1,Es.exports=yg()),Es.exports}var Fr;function vg(){if(Fr)return ks;Fr=1;var e=Li(),t=wg();function n(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var s=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,r=e.useRef,i=e.useEffect,c=e.useMemo,l=e.useDebugValue;return ks.useSyncExternalStoreWithSelector=function(d,u,h,f,p){var m=r(null);if(m.current===null){var w={hasValue:!1,value:null};m.current=w}else w=m.current;m=c(function(){function y(k){if(!j){if(j=!0,g=k,k=f(k),p!==void 0&&w.hasValue){var C=w.value;if(p(C,k))return v=C}return v=k}if(C=v,s(g,k))return C;var I=f(k);return p!==void 0&&p(C,I)?(g=k,C):(g=k,v=I)}var j=!1,g,v,E=h===void 0?null:h;return[function(){return y(u())},E===null?void 0:function(){return y(E())}]},[u,h,f,p]);var x=o(d,m[0],m[1]);return i(function(){w.hasValue=!0,w.value=x},[x]),l(x),x},ks}var Br;function bg(){return Br||(Br=1,js.exports=vg()),js.exports}var Ng=bg();const jg=Td(Ng),kg={},Wr=e=>{let t;const n=new Set,s=(u,h)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const p=t;t=h??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(m=>m(t,p))}},o=()=>t,l={setState:s,getState:o,getInitialState:()=>d,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(kg?"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()}},d=t=e(s,o,l);return l},Eg=e=>e?Wr(e):Wr,{useDebugValue:Cg}=Od,{useSyncExternalStoreWithSelector:Sg}=jg,_g=e=>e;function ac(e,t=_g,n){const s=Sg(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Cg(s),s}const Yr=(e,t)=>{const n=Eg(e),s=(o,r=t)=>ac(n,o,r);return Object.assign(s,n),s},Mg=(e,t)=>e?Yr(e,t):Yr;function ue(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 cs=N.createContext(null),Ig=cs.Provider,cc=Te.error001("react");function re(e,t){const n=N.useContext(cs);if(n===null)throw new Error(cc);return ac(n,e,t)}function le(){const e=N.useContext(cs);if(e===null)throw new Error(cc);return N.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Xr={display:"none"},$g={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},lc="react-flow__node-desc",dc="react-flow__edge-desc",Rg="react-flow__aria-live",Ag=e=>e.ariaLiveMessage,Dg=e=>e.ariaLabelConfig;function Pg({rfId:e}){const t=re(Ag);return a.jsx("div",{id:`${Rg}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:$g,children:t})}function Tg({rfId:e,disableKeyboardA11y:t}){const n=re(Dg);return a.jsxs(a.Fragment,{children:[a.jsx("div",{id:`${lc}-${e}`,style:Xr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),a.jsx("div",{id:`${dc}-${e}`,style:Xr,children:n["edge.a11yDescription.default"]}),!t&&a.jsx(Pg,{rfId:e})]})}const tt=N.forwardRef(({position:e="top-left",children:t,className:n,style:s,...o},r)=>{const i=`${e}`.split("-");return a.jsx("div",{className:me(["react-flow__panel",n,...i]),style:s,ref:r,...o,children:t})});tt.displayName="Panel";const qr="https://reactflow.dev?utm_source=attribution";function Og({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:a.jsx(tt,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${qr}`,children:a.jsx("a",{href:qr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const zg=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}},bn=e=>e.id;function Lg(e,t){return ue(e.selectedNodes.map(bn),t.selectedNodes.map(bn))&&ue(e.selectedEdges.map(bn),t.selectedEdges.map(bn))}function Hg({onSelectionChange:e}){const t=le(),{selectedNodes:n,selectedEdges:s}=re(zg,Lg);return N.useEffect(()=>{const o={nodes:n,edges:s};e?.(o),t.getState().onSelectionChangeHandlers.forEach(r=>r(o))},[n,s,e]),null}const Vg=e=>!!e.onSelectionChangeHandlers;function Fg({onSelectionChange:e}){const t=re(Vg);return e||t?a.jsx(Hg,{onSelectionChange:e}):null}const uc=[0,0],Bg={x:0,y:0,zoom:1},Wg=["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"],Zr=[...Wg,"rfId"],Yg=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}),Gr={translateExtent:Gt,nodeOrigin:uc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Xg(e){const{setNodes:t,setEdges:n,setMinZoom:s,setMaxZoom:o,setTranslateExtent:r,setNodeExtent:i,reset:c,setDefaultNodesAndEdges:l}=re(Yg,ue),d=le();N.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{u.current=Gr,c()}),[]);const u=N.useRef(Gr);return N.useEffect(()=>{for(const h of Zr){const f=e[h],p=u.current[h];f!==p&&(typeof e[h]>"u"||(h==="nodes"?t(f):h==="edges"?n(f):h==="minZoom"?s(f):h==="maxZoom"?o(f):h==="translateExtent"?r(f):h==="nodeExtent"?i(f):h==="ariaLabelConfig"?d.setState({ariaLabelConfig:Im(f)}):h==="fitView"?d.setState({fitViewQueued:f}):h==="fitViewOptions"?d.setState({fitViewOptions:f}):d.setState({[h]:f})))}u.current=e},Zr.map(h=>e[h])),null}function Ur(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function qg(e){const[t,n]=N.useState(e==="system"?null:e);return N.useEffect(()=>{if(e!=="system"){n(e);return}const s=Ur(),o=()=>n(s?.matches?"dark":"light");return o(),s?.addEventListener("change",o),()=>{s?.removeEventListener("change",o)}},[e]),t!==null?t:Ur()?.matches?"dark":"light"}const Kr=typeof document<"u"?document:null;function Jt(e=null,t={target:Kr,actInsideInputWithModifier:!0}){const[n,s]=N.useState(!1),o=N.useRef(!1),r=N.useRef(new Set([])),[i,c]=N.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(h=>typeof h=="string").map(h=>h.replace(/\+/g,`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/elk-api-ByzoDZWH.js","assets/index-N8J8EKlB.js","assets/index-BiGR8Oo9.css"])))=>i.map(i=>d[i]);
2
+ import{S as Ed,n as Is,s as Cd,r as Sd,Q as zi,u as Zn,a as _d,b as Md,c as N,e as Id,d as $d,f as Rd,g as Ad,h as sr,i as Dd,j as Pd,k as be,l as Li,m as Td,R as Od,o as a,p as zd,_ as Ld,q as Hi,t as X,P as $t,v as no,M as Vi,w as ae,x as Rt,T as so,y as Hd,B as Ve,z as mt,A as Me,N as Vd,C as Fi,D as Fd,E as Gn,F as Un,G as Be,H as Bd,I as _e,J as Wd,K as Yd,L as Xd,O as qd,U as Zd,V as Bi,W as $s,X as oo,Y as Gd,Z as Wi,$ as ro,a0 as At,a1 as ct,a2 as Ft,a3 as Yi,a4 as qe,a5 as Ud,a6 as ve,a7 as Kd,a8 as Dt,a9 as Qd,aa as gt,ab as Xi,ac as Jd,ad as io,ae as Kn,af as Qn,ag as Jn,ah as eu,ai as tu,aj as ye,ak as nu,al as su,am as kt,an as ou,ao as ru,ap as iu,aq as au,ar as or,as as ao,at as co,au as lo,av as nn,aw as uo,ax as cu,ay as lu,az as du,aA as uu,aB as fu,aC as qi,aD as fo,aE as Mn,aF as Zi,aG as Gi,aH as Ui,aI as In,aJ as Fe,aK as hu,aL as rt,aM as Ki,aN as Qi,aO as pu,aP as mu,aQ as xe,aR as Ji,aS as gu,aT as xu,aU as yu}from"./index-N8J8EKlB.js";function rr(e,t){const n=new Set(t);return e.filter(s=>!n.has(s))}function wu(e,t,n){const s=e.slice(0);return s[t]=n,s}var vu=class extends Ed{#o;#e;#r;#n;#t;#s;#i;#a;#c;#l=[];constructor(e,t,n){super(),this.#o=e,this.#n=n,this.#r=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#h(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#n=t,Is.batch(()=>{const n=this.#t,s=this.#f(this.#r);s.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const o=s.map(u=>u.observer),r=o.map(u=>u.getCurrentResult()),i=n.length!==o.length,c=o.some((u,h)=>u!==n[h]),l=i||c,d=l?!0:r.some((u,h)=>{const f=this.#e[h];return!f||!Cd(u,f)});!l&&!d||(l&&(this.#l=s,this.#t=o),this.#e=r,this.hasListeners()&&(l&&(rr(n,o).forEach(u=>{u.destroy()}),rr(o,n).forEach(u=>{u.subscribe(h=>{this.#h(u,h)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const n=this.#f(e),s=n.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions)),o=n.map(r=>r.defaultedQueryOptions.queryHash);return[s,r=>this.#u(r??s,t,o),()=>this.#d(s,n)]}#d(e,t){const n=new Set;return t.map((s,o)=>{const r=e[o];return s.defaultedQueryOptions.notifyOnChangeProps?r:s.observer.trackResult(r,i=>{n.has(i)||(n.add(i),t.forEach(c=>{c.observer.trackProp(i)}))})})}#u(e,t,n){if(t){const s=this.#c,o=n!==void 0&&s!==void 0&&(s.length!==n.length||n.some((r,i)=>r!==s[i]));return(this.#e!==this.#a||o||t!==this.#i)&&(this.#i=t,this.#a=this.#e,n!==void 0&&(this.#c=n),this.#s=Sd(this.#s,t(e))),this.#s}return e}#m(){return!this.#n?.combine||this.#t.some((e,t)=>e.options.suspense&&this.#e[t]?.data===void 0)}#f(e){const t=new Map;this.#t.forEach(s=>{const o=s.options.queryHash;if(!o)return;const r=t.get(o);r?r.push(s):t.set(o,[s])});const n=[];return e.forEach(s=>{const o=this.#o.defaultQueryOptions(s),r=t.get(o.queryHash)?.shift()??new zi(this.#o,o);n.push({defaultedQueryOptions:o,observer:r})}),n}#h(e,t){const n=this.#t.indexOf(e);n!==-1&&(this.#e=wu(this.#e,n,t),this.#p())}#p(){if(this.hasListeners()){const e=this.#m(),t=this.#s,n=e?t:this.#u(this.#d(this.#e,this.#l),this.#n?.combine);(e||t!==n)&&Is.batch(()=>{this.listeners.forEach(s=>{s(this.#e)})})}}};function hn({queries:e,...t},n){const s=Zn(),o=_d(),r=Md(),i=t.subscribed!==!1,c=N.useMemo(()=>e.map(w=>{const x=s.defaultQueryOptions(w);return x._optimisticResults=o?"isRestoring":i?"optimistic":void 0,x}),[e,s,o,i]);c.forEach(w=>{Id(w);const x=s.getQueryCache().get(w.queryHash);$d(w,r,x)}),Rd(r);const[l]=N.useState(()=>new vu(s,c,t)),[d,u,h]=l.getOptimisticResult(c,t.combine),f=!o&&i;N.useSyncExternalStore(N.useCallback(w=>f?l.subscribe(Is.batchCalls(w)):Ad,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),N.useEffect(()=>{l.setQueries(c,t)},[c,t,l]);const p=d.some((w,x)=>sr(c[x],w))?d.flatMap((w,x)=>{const y=c[x];if(y&&sr(y,w)){const j=new zi(s,y);return Dd(y,j,r)}return[]}):[];if(p.length>0)throw Promise.all(p);const m=d.find((w,x)=>{const y=c[x];return y&&Pd({result:w,errorResetBoundary:r,throwOnError:y.throwOnError,query:s.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(m?.error)throw m.error;return u(h())}const bu=[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]],sn=be("AppWindow",bu);const Nu=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],ju=be("ArrowLeft",Nu);const ku=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ho=be("CircleAlert",ku);const Eu=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M2 10h20",key:"1ir3d8"}]],on=be("FolderClosed",Eu);const Cu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Su=be("FolderOpen",Cu);const _u=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Mu=be("FolderTree",_u);const Iu=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],$u=be("Hexagon",Iu);const Ru=[["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"}]],ea=be("LayoutGrid",Ru);const Au=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]],Du=be("MessageSquarePlus",Au);const Pu=[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]],ir=be("MonitorPlay",Pu);const Tu=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],po=be("Plug",Tu);const Ou=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ta=be("Plus",Ou);const zu=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],ar=be("Unplug",zu);const Lu=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],Hu=be("UserRound",Lu);function me(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=me(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Vu={value:()=>{}};function es(){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 kn(n)}function kn(e){this._=e}function Fu(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}})}kn.prototype=es.prototype={constructor:kn,on:function(e,t){var n=this._,s=Fu(e+"",n),o,r=-1,i=s.length;if(arguments.length<2){for(;++r<i;)if((o=(e=s[r]).type)&&(o=Bu(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++r<i;)if(o=(e=s[r]).type)n[o]=cr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=cr(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 kn(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),s=0,o,r;s<o;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(r=this._[e],s=0,o=r.length;s<o;++s)r[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,r=s.length;o<r;++o)s[o].value.apply(t,n)}};function Bu(e,t){for(var n=0,s=e.length,o;n<s;++n)if((o=e[n]).name===t)return o.value}function cr(e,t,n){for(var s=0,o=e.length;s<o;++s)if(e[s].name===t){e[s]=Vu,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Rs="http://www.w3.org/1999/xhtml";const lr={svg:"http://www.w3.org/2000/svg",xhtml:Rs,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ts(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),lr.hasOwnProperty(t)?{space:lr[t],local:e}:e}function Wu(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Rs&&t.documentElement.namespaceURI===Rs?t.createElement(e):t.createElementNS(n,e)}}function Yu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function na(e){var t=ts(e);return(t.local?Yu:Wu)(t)}function Xu(){}function mo(e){return e==null?Xu:function(){return this.querySelector(e)}}function qu(e){typeof e!="function"&&(e=mo(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var r=t[o],i=r.length,c=s[o]=new Array(i),l,d,u=0;u<i;++u)(l=r[u])&&(d=e.call(l,l.__data__,u,r))&&("__data__"in l&&(d.__data__=l.__data__),c[u]=d);return new Ee(s,this._parents)}function Zu(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Gu(){return[]}function sa(e){return e==null?Gu:function(){return this.querySelectorAll(e)}}function Uu(e){return function(){return Zu(e.apply(this,arguments))}}function Ku(e){typeof e=="function"?e=Uu(e):e=sa(e);for(var t=this._groups,n=t.length,s=[],o=[],r=0;r<n;++r)for(var i=t[r],c=i.length,l,d=0;d<c;++d)(l=i[d])&&(s.push(e.call(l,l.__data__,d,i)),o.push(l));return new Ee(s,o)}function oa(e){return function(){return this.matches(e)}}function ra(e){return function(t){return t.matches(e)}}var Qu=Array.prototype.find;function Ju(e){return function(){return Qu.call(this.children,e)}}function ef(){return this.firstElementChild}function tf(e){return this.select(e==null?ef:Ju(typeof e=="function"?e:ra(e)))}var nf=Array.prototype.filter;function sf(){return Array.from(this.children)}function of(e){return function(){return nf.call(this.children,e)}}function rf(e){return this.selectAll(e==null?sf:of(typeof e=="function"?e:ra(e)))}function af(e){typeof e!="function"&&(e=oa(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var r=t[o],i=r.length,c=s[o]=[],l,d=0;d<i;++d)(l=r[d])&&e.call(l,l.__data__,d,r)&&c.push(l);return new Ee(s,this._parents)}function ia(e){return new Array(e.length)}function cf(){return new Ee(this._enter||this._groups.map(ia),this._parents)}function $n(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}$n.prototype={constructor:$n,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 lf(e){return function(){return e}}function df(e,t,n,s,o,r){for(var i=0,c,l=t.length,d=r.length;i<d;++i)(c=t[i])?(c.__data__=r[i],s[i]=c):n[i]=new $n(e,r[i]);for(;i<l;++i)(c=t[i])&&(o[i]=c)}function uf(e,t,n,s,o,r,i){var c,l,d=new Map,u=t.length,h=r.length,f=new Array(u),p;for(c=0;c<u;++c)(l=t[c])&&(f[c]=p=i.call(l,l.__data__,c,t)+"",d.has(p)?o[c]=l:d.set(p,l));for(c=0;c<h;++c)p=i.call(e,r[c],c,r)+"",(l=d.get(p))?(s[c]=l,l.__data__=r[c],d.delete(p)):n[c]=new $n(e,r[c]);for(c=0;c<u;++c)(l=t[c])&&d.get(f[c])===l&&(o[c]=l)}function ff(e){return e.__data__}function hf(e,t){if(!arguments.length)return Array.from(this,ff);var n=t?uf:df,s=this._parents,o=this._groups;typeof e!="function"&&(e=lf(e));for(var r=o.length,i=new Array(r),c=new Array(r),l=new Array(r),d=0;d<r;++d){var u=s[d],h=o[d],f=h.length,p=pf(e.call(u,u&&u.__data__,d,s)),m=p.length,w=c[d]=new Array(m),x=i[d]=new Array(m),y=l[d]=new Array(f);n(u,h,w,x,y,p,t);for(var j=0,g=0,v,E;j<m;++j)if(v=w[j]){for(j>=g&&(g=j+1);!(E=x[g])&&++g<m;);v._next=E||null}}return i=new Ee(i,s),i._enter=c,i._exit=l,i}function pf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function mf(){return new Ee(this._exit||this._groups.map(ia),this._parents)}function gf(e,t,n){var s=this.enter(),o=this,r=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?r.remove():n(r),s&&o?s.merge(o).order():o}function xf(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,o=n.length,r=s.length,i=Math.min(o,r),c=new Array(o),l=0;l<i;++l)for(var d=n[l],u=s[l],h=d.length,f=c[l]=new Array(h),p,m=0;m<h;++m)(p=d[m]||u[m])&&(f[m]=p);for(;l<o;++l)c[l]=n[l];return new Ee(c,this._parents)}function yf(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],o=s.length-1,r=s[o],i;--o>=0;)(i=s[o])&&(r&&i.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(i,r),r=i);return this}function wf(e){e||(e=vf);function t(h,f){return h&&f?e(h.__data__,f.__data__):!h-!f}for(var n=this._groups,s=n.length,o=new Array(s),r=0;r<s;++r){for(var i=n[r],c=i.length,l=o[r]=new Array(c),d,u=0;u<c;++u)(d=i[u])&&(l[u]=d);l.sort(t)}return new Ee(o,this._parents).order()}function vf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function bf(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Nf(){return Array.from(this)}function jf(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,r=s.length;o<r;++o){var i=s[o];if(i)return i}return null}function kf(){let e=0;for(const t of this)++e;return e}function Ef(){return!this.node()}function Cf(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var o=t[n],r=0,i=o.length,c;r<i;++r)(c=o[r])&&e.call(c,c.__data__,r,o);return this}function Sf(e){return function(){this.removeAttribute(e)}}function _f(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Mf(e,t){return function(){this.setAttribute(e,t)}}function If(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function $f(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Rf(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 Af(e,t){var n=ts(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?_f:Sf:typeof t=="function"?n.local?Rf:$f:n.local?If:Mf)(n,t))}function aa(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Df(e){return function(){this.style.removeProperty(e)}}function Pf(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Tf(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function Of(e,t,n){return arguments.length>1?this.each((t==null?Df:typeof t=="function"?Tf:Pf)(e,t,n??"")):Et(this.node(),e)}function Et(e,t){return e.style.getPropertyValue(t)||aa(e).getComputedStyle(e,null).getPropertyValue(t)}function zf(e){return function(){delete this[e]}}function Lf(e,t){return function(){this[e]=t}}function Hf(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Vf(e,t){return arguments.length>1?this.each((t==null?zf:typeof t=="function"?Hf:Lf)(e,t)):this.node()[e]}function ca(e){return e.trim().split(/^|\s+/)}function go(e){return e.classList||new la(e)}function la(e){this._node=e,this._names=ca(e.getAttribute("class")||"")}la.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 da(e,t){for(var n=go(e),s=-1,o=t.length;++s<o;)n.add(t[s])}function ua(e,t){for(var n=go(e),s=-1,o=t.length;++s<o;)n.remove(t[s])}function Ff(e){return function(){da(this,e)}}function Bf(e){return function(){ua(this,e)}}function Wf(e,t){return function(){(t.apply(this,arguments)?da:ua)(this,e)}}function Yf(e,t){var n=ca(e+"");if(arguments.length<2){for(var s=go(this.node()),o=-1,r=n.length;++o<r;)if(!s.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?Wf:t?Ff:Bf)(n,t))}function Xf(){this.textContent=""}function qf(e){return function(){this.textContent=e}}function Zf(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Gf(e){return arguments.length?this.each(e==null?Xf:(typeof e=="function"?Zf:qf)(e)):this.node().textContent}function Uf(){this.innerHTML=""}function Kf(e){return function(){this.innerHTML=e}}function Qf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Jf(e){return arguments.length?this.each(e==null?Uf:(typeof e=="function"?Qf:Kf)(e)):this.node().innerHTML}function eh(){this.nextSibling&&this.parentNode.appendChild(this)}function th(){return this.each(eh)}function nh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function sh(){return this.each(nh)}function oh(e){var t=typeof e=="function"?e:na(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function rh(){return null}function ih(e,t){var n=typeof e=="function"?e:na(e),s=t==null?rh:typeof t=="function"?t:mo(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function ah(){var e=this.parentNode;e&&e.removeChild(this)}function ch(){return this.each(ah)}function lh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function dh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function uh(e){return this.select(e?dh:lh)}function fh(e){return arguments.length?this.property("__data__",e):this.node().__data__}function hh(e){return function(t){e.call(this,t,this.__data__)}}function ph(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 mh(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,o=t.length,r;n<o;++n)r=t[n],(!e.type||r.type===e.type)&&r.name===e.name?this.removeEventListener(r.type,r.listener,r.options):t[++s]=r;++s?t.length=s:delete this.__on}}}function gh(e,t,n){return function(){var s=this.__on,o,r=hh(t);if(s){for(var i=0,c=s.length;i<c;++i)if((o=s[i]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=r,o.options=n),o.value=t;return}}this.addEventListener(e.type,r,n),o={type:e.type,name:e.name,value:t,listener:r,options:n},s?s.push(o):this.__on=[o]}}function xh(e,t,n){var s=ph(e+""),o,r=s.length,i;if(arguments.length<2){var c=this.node().__on;if(c){for(var l=0,d=c.length,u;l<d;++l)for(o=0,u=c[l];o<r;++o)if((i=s[o]).type===u.type&&i.name===u.name)return u.value}return}for(c=t?gh:mh,o=0;o<r;++o)this.each(c(s[o],t,n));return this}function fa(e,t,n){var s=aa(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 yh(e,t){return function(){return fa(this,e,t)}}function wh(e,t){return function(){return fa(this,e,t.apply(this,arguments))}}function vh(e,t){return this.each((typeof t=="function"?wh:yh)(e,t))}function*bh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,r=s.length,i;o<r;++o)(i=s[o])&&(yield i)}var ha=[null];function Ee(e,t){this._groups=e,this._parents=t}function rn(){return new Ee([[document.documentElement]],ha)}function Nh(){return this}Ee.prototype=rn.prototype={constructor:Ee,select:qu,selectAll:Ku,selectChild:tf,selectChildren:rf,filter:af,data:hf,enter:cf,exit:mf,join:gf,merge:xf,selection:Nh,order:yf,sort:wf,call:bf,nodes:Nf,node:jf,size:kf,empty:Ef,each:Cf,attr:Af,style:Of,property:Vf,classed:Yf,text:Gf,html:Jf,raise:th,lower:sh,append:oh,insert:ih,remove:ch,clone:uh,datum:fh,on:xh,dispatch:vh,[Symbol.iterator]:bh};function ke(e){return typeof e=="string"?new Ee([[document.querySelector(e)]],[document.documentElement]):new Ee([[e]],ha)}function jh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function $e(e,t){if(e=jh(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 kh={passive:!1},Yt={capture:!0,passive:!1};function gs(e){e.stopImmediatePropagation()}function Nt(e){e.preventDefault(),e.stopImmediatePropagation()}function pa(e){var t=e.document.documentElement,n=ke(e).on("dragstart.drag",Nt,Yt);"onselectstart"in t?n.on("selectstart.drag",Nt,Yt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function ma(e,t){var n=e.document.documentElement,s=ke(e).on("dragstart.drag",null);t&&(s.on("click.drag",Nt,Yt),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 pn=e=>()=>e;function As(e,{sourceEvent:t,subject:n,target:s,identifier:o,active:r,x:i,y:c,dx:l,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}As.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Eh(e){return!e.ctrlKey&&!e.button}function Ch(){return this.parentNode}function Sh(e,t){return t??{x:e.x,y:e.y}}function _h(){return navigator.maxTouchPoints||"ontouchstart"in this}function ga(){var e=Eh,t=Ch,n=Sh,s=_h,o={},r=es("start","drag","end"),i=0,c,l,d,u,h=0;function f(v){v.on("mousedown.drag",p).filter(s).on("touchstart.drag",x).on("touchmove.drag",y,kh).on("touchend.drag touchcancel.drag",j).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(v,E){if(!(u||!e.call(this,v,E))){var k=g(this,t.call(this,v,E),v,E,"mouse");k&&(ke(v.view).on("mousemove.drag",m,Yt).on("mouseup.drag",w,Yt),pa(v.view),gs(v),d=!1,c=v.clientX,l=v.clientY,k("start",v))}}function m(v){if(Nt(v),!d){var E=v.clientX-c,k=v.clientY-l;d=E*E+k*k>h}o.mouse("drag",v)}function w(v){ke(v.view).on("mousemove.drag mouseup.drag",null),ma(v.view,d),Nt(v),o.mouse("end",v)}function x(v,E){if(e.call(this,v,E)){var k=v.changedTouches,C=t.call(this,v,E),I=k.length,R,V;for(R=0;R<I;++R)(V=g(this,C,v,E,k[R].identifier,k[R]))&&(gs(v),V("start",v,k[R]))}}function y(v){var E=v.changedTouches,k=E.length,C,I;for(C=0;C<k;++C)(I=o[E[C].identifier])&&(Nt(v),I("drag",v,E[C]))}function j(v){var E=v.changedTouches,k=E.length,C,I;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),C=0;C<k;++C)(I=o[E[C].identifier])&&(gs(v),I("end",v,E[C]))}function g(v,E,k,C,I,R){var V=r.copy(),T=$e(R||k,E),$,A,b;if((b=n.call(v,new As("beforestart",{sourceEvent:k,target:f,identifier:I,active:i,x:T[0],y:T[1],dx:0,dy:0,dispatch:V}),C))!=null)return $=b.x-T[0]||0,A=b.y-T[1]||0,function S(_,M,D){var P=T,L;switch(_){case"start":o[I]=S,L=i++;break;case"end":delete o[I],--i;case"drag":T=$e(D||M,E),L=i;break}V.call(_,v,new As(_,{sourceEvent:M,subject:b,target:f,identifier:I,active:L,x:T[0]+$,y:T[1]+A,dx:T[0]-P[0],dy:T[1]-P[1],dispatch:V}),C)}}return f.filter=function(v){return arguments.length?(e=typeof v=="function"?v:pn(!!v),f):e},f.container=function(v){return arguments.length?(t=typeof v=="function"?v:pn(v),f):t},f.subject=function(v){return arguments.length?(n=typeof v=="function"?v:pn(v),f):n},f.touchable=function(v){return arguments.length?(s=typeof v=="function"?v:pn(!!v),f):s},f.on=function(){var v=r.on.apply(r,arguments);return v===r?f:v},f.clickDistance=function(v){return arguments.length?(h=(v=+v)*v,f):Math.sqrt(h)},f}function xo(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function xa(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function an(){}var Xt=.7,Rn=1/Xt,jt="\\s*([+-]?\\d+)\\s*",qt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",We="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Mh=/^#([0-9a-f]{3,8})$/,Ih=new RegExp(`^rgb\\(${jt},${jt},${jt}\\)$`),$h=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),Rh=new RegExp(`^rgba\\(${jt},${jt},${jt},${qt}\\)$`),Ah=new RegExp(`^rgba\\(${We},${We},${We},${qt}\\)$`),Dh=new RegExp(`^hsl\\(${qt},${We},${We}\\)$`),Ph=new RegExp(`^hsla\\(${qt},${We},${We},${qt}\\)$`),dr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};xo(an,lt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ur,formatHex:ur,formatHex8:Th,formatHsl:Oh,formatRgb:fr,toString:fr});function ur(){return this.rgb().formatHex()}function Th(){return this.rgb().formatHex8()}function Oh(){return ya(this).formatHsl()}function fr(){return this.rgb().formatRgb()}function lt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Mh.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?hr(t):n===3?new we(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?mn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?mn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Ih.exec(e))?new we(t[1],t[2],t[3],1):(t=$h.exec(e))?new we(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Rh.exec(e))?mn(t[1],t[2],t[3],t[4]):(t=Ah.exec(e))?mn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Dh.exec(e))?gr(t[1],t[2]/100,t[3]/100,1):(t=Ph.exec(e))?gr(t[1],t[2]/100,t[3]/100,t[4]):dr.hasOwnProperty(e)?hr(dr[e]):e==="transparent"?new we(NaN,NaN,NaN,0):null}function hr(e){return new we(e>>16&255,e>>8&255,e&255,1)}function mn(e,t,n,s){return s<=0&&(e=t=n=NaN),new we(e,t,n,s)}function zh(e){return e instanceof an||(e=lt(e)),e?(e=e.rgb(),new we(e.r,e.g,e.b,e.opacity)):new we}function Ds(e,t,n,s){return arguments.length===1?zh(e):new we(e,t,n,s??1)}function we(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}xo(we,Ds,xa(an,{brighter(e){return e=e==null?Rn:Math.pow(Rn,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Xt:Math.pow(Xt,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new we(it(this.r),it(this.g),it(this.b),An(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:pr,formatHex:pr,formatHex8:Lh,formatRgb:mr,toString:mr}));function pr(){return`#${ot(this.r)}${ot(this.g)}${ot(this.b)}`}function Lh(){return`#${ot(this.r)}${ot(this.g)}${ot(this.b)}${ot((isNaN(this.opacity)?1:this.opacity)*255)}`}function mr(){const e=An(this.opacity);return`${e===1?"rgb(":"rgba("}${it(this.r)}, ${it(this.g)}, ${it(this.b)}${e===1?")":`, ${e})`}`}function An(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function it(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ot(e){return e=it(e),(e<16?"0":"")+e.toString(16)}function gr(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Re(e,t,n,s)}function ya(e){if(e instanceof Re)return new Re(e.h,e.s,e.l,e.opacity);if(e instanceof an||(e=lt(e)),!e)return new Re;if(e instanceof Re)return e;e=e.rgb();var t=e.r/255,n=e.g/255,s=e.b/255,o=Math.min(t,n,s),r=Math.max(t,n,s),i=NaN,c=r-o,l=(r+o)/2;return c?(t===r?i=(n-s)/c+(n<s)*6:n===r?i=(s-t)/c+2:i=(t-n)/c+4,c/=l<.5?r+o:2-r-o,i*=60):c=l>0&&l<1?0:i,new Re(i,c,l,e.opacity)}function Hh(e,t,n,s){return arguments.length===1?ya(e):new Re(e,t,n,s??1)}function Re(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}xo(Re,Hh,xa(an,{brighter(e){return e=e==null?Rn:Math.pow(Rn,e),new Re(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Xt:Math.pow(Xt,e),new Re(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,s=n+(n<.5?n:1-n)*t,o=2*n-s;return new we(xs(e>=240?e-240:e+120,o,s),xs(e,o,s),xs(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new Re(xr(this.h),gn(this.s),gn(this.l),An(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=An(this.opacity);return`${e===1?"hsl(":"hsla("}${xr(this.h)}, ${gn(this.s)*100}%, ${gn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function xr(e){return e=(e||0)%360,e<0?e+360:e}function gn(e){return Math.max(0,Math.min(1,e||0))}function xs(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const yo=e=>()=>e;function Vh(e,t){return function(n){return e+n*t}}function Fh(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(s){return Math.pow(e+s*t,n)}}function Bh(e){return(e=+e)==1?wa:function(t,n){return n-t?Fh(t,n,e):yo(isNaN(t)?n:t)}}function wa(e,t){var n=t-e;return n?Vh(e,n):yo(isNaN(e)?t:e)}const Dn=(function e(t){var n=Bh(t);function s(o,r){var i=n((o=Ds(o)).r,(r=Ds(r)).r),c=n(o.g,r.g),l=n(o.b,r.b),d=wa(o.opacity,r.opacity);return function(u){return o.r=i(u),o.g=c(u),o.b=l(u),o.opacity=d(u),o+""}}return s.gamma=e,s})(1);function Wh(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,s=t.slice(),o;return function(r){for(o=0;o<n;++o)s[o]=e[o]*(1-r)+t[o]*r;return s}}function Yh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Xh(e,t){var n=t?t.length:0,s=e?Math.min(n,e.length):0,o=new Array(s),r=new Array(n),i;for(i=0;i<s;++i)o[i]=Bt(e[i],t[i]);for(;i<n;++i)r[i]=t[i];return function(c){for(i=0;i<s;++i)r[i]=o[i](c);return r}}function qh(e,t){var n=new Date;return e=+e,t=+t,function(s){return n.setTime(e*(1-s)+t*s),n}}function He(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Zh(e,t){var n={},s={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=Bt(e[o],t[o]):s[o]=t[o];return function(r){for(o in n)s[o]=n[o](r);return s}}var Ps=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ys=new RegExp(Ps.source,"g");function Gh(e){return function(){return e}}function Uh(e){return function(t){return e(t)+""}}function va(e,t){var n=Ps.lastIndex=ys.lastIndex=0,s,o,r,i=-1,c=[],l=[];for(e=e+"",t=t+"";(s=Ps.exec(e))&&(o=ys.exec(t));)(r=o.index)>n&&(r=t.slice(n,r),c[i]?c[i]+=r:c[++i]=r),(s=s[0])===(o=o[0])?c[i]?c[i]+=o:c[++i]=o:(c[++i]=null,l.push({i,x:He(s,o)})),n=ys.lastIndex;return n<t.length&&(r=t.slice(n),c[i]?c[i]+=r:c[++i]=r),c.length<2?l[0]?Uh(l[0].x):Gh(t):(t=l.length,function(d){for(var u=0,h;u<t;++u)c[(h=l[u]).i]=h.x(d);return c.join("")})}function Bt(e,t){var n=typeof t,s;return t==null||n==="boolean"?yo(t):(n==="number"?He:n==="string"?(s=lt(t))?(t=s,Dn):va:t instanceof lt?Dn:t instanceof Date?qh:Yh(t)?Wh:Array.isArray(t)?Xh:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Zh:He)(e,t)}var yr=180/Math.PI,Ts={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ba(e,t,n,s,o,r){var i,c,l;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(l=e*n+t*s)&&(n-=e*l,s-=t*l),(c=Math.sqrt(n*n+s*s))&&(n/=c,s/=c,l/=c),e*s<t*n&&(e=-e,t=-t,l=-l,i=-i),{translateX:o,translateY:r,rotate:Math.atan2(t,e)*yr,skewX:Math.atan(l)*yr,scaleX:i,scaleY:c}}var xn;function Kh(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ts:ba(t.a,t.b,t.c,t.d,t.e,t.f)}function Qh(e){return e==null||(xn||(xn=document.createElementNS("http://www.w3.org/2000/svg","g")),xn.setAttribute("transform",e),!(e=xn.transform.baseVal.consolidate()))?Ts:(e=e.matrix,ba(e.a,e.b,e.c,e.d,e.e,e.f))}function Na(e,t,n,s){function o(d){return d.length?d.pop()+" ":""}function r(d,u,h,f,p,m){if(d!==h||u!==f){var w=p.push("translate(",null,t,null,n);m.push({i:w-4,x:He(d,h)},{i:w-2,x:He(u,f)})}else(h||f)&&p.push("translate("+h+t+f+n)}function i(d,u,h,f){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),f.push({i:h.push(o(h)+"rotate(",null,s)-2,x:He(d,u)})):u&&h.push(o(h)+"rotate("+u+s)}function c(d,u,h,f){d!==u?f.push({i:h.push(o(h)+"skewX(",null,s)-2,x:He(d,u)}):u&&h.push(o(h)+"skewX("+u+s)}function l(d,u,h,f,p,m){if(d!==h||u!==f){var w=p.push(o(p)+"scale(",null,",",null,")");m.push({i:w-4,x:He(d,h)},{i:w-2,x:He(u,f)})}else(h!==1||f!==1)&&p.push(o(p)+"scale("+h+","+f+")")}return function(d,u){var h=[],f=[];return d=e(d),u=e(u),r(d.translateX,d.translateY,u.translateX,u.translateY,h,f),i(d.rotate,u.rotate,h,f),c(d.skewX,u.skewX,h,f),l(d.scaleX,d.scaleY,u.scaleX,u.scaleY,h,f),d=u=null,function(p){for(var m=-1,w=f.length,x;++m<w;)h[(x=f[m]).i]=x.x(p);return h.join("")}}}var Jh=Na(Kh,"px, ","px)","deg)"),ep=Na(Qh,", ",")",")"),tp=1e-12;function wr(e){return((e=Math.exp(e))+1/e)/2}function np(e){return((e=Math.exp(e))-1/e)/2}function sp(e){return((e=Math.exp(2*e))-1)/(e+1)}const En=(function e(t,n,s){function o(r,i){var c=r[0],l=r[1],d=r[2],u=i[0],h=i[1],f=i[2],p=u-c,m=h-l,w=p*p+m*m,x,y;if(w<tp)y=Math.log(f/d)/t,x=function(C){return[c+C*p,l+C*m,d*Math.exp(t*C*y)]};else{var j=Math.sqrt(w),g=(f*f-d*d+s*w)/(2*d*n*j),v=(f*f-d*d-s*w)/(2*f*n*j),E=Math.log(Math.sqrt(g*g+1)-g),k=Math.log(Math.sqrt(v*v+1)-v);y=(k-E)/t,x=function(C){var I=C*y,R=wr(E),V=d/(n*j)*(R*sp(t*I+E)-np(E));return[c+V*p,l+V*m,d*R/wr(t*I+E)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return o.rho=function(r){var i=Math.max(.001,+r),c=i*i,l=c*c;return e(i,c,l)},o})(Math.SQRT2,2,4);var Ct=0,Lt=0,Ot=0,ja=1e3,Pn,Ht,Tn=0,dt=0,ns=0,Zt=typeof performance=="object"&&performance.now?performance:Date,ka=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function wo(){return dt||(ka(op),dt=Zt.now()+ns)}function op(){dt=0}function On(){this._call=this._time=this._next=null}On.prototype=Ea.prototype={constructor:On,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?wo():+n)+(t==null?0:+t),!this._next&&Ht!==this&&(Ht?Ht._next=this:Pn=this,Ht=this),this._call=e,this._time=n,Os()},stop:function(){this._call&&(this._call=null,this._time=1/0,Os())}};function Ea(e,t,n){var s=new On;return s.restart(e,t,n),s}function rp(){wo(),++Ct;for(var e=Pn,t;e;)(t=dt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ct}function vr(){dt=(Tn=Zt.now())+ns,Ct=Lt=0;try{rp()}finally{Ct=0,ap(),dt=0}}function ip(){var e=Zt.now(),t=e-Tn;t>ja&&(ns-=t,Tn=e)}function ap(){for(var e,t=Pn,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:Pn=n);Ht=e,Os(s)}function Os(e){if(!Ct){Lt&&(Lt=clearTimeout(Lt));var t=e-dt;t>24?(e<1/0&&(Lt=setTimeout(vr,e-Zt.now()-ns)),Ot&&(Ot=clearInterval(Ot))):(Ot||(Tn=Zt.now(),Ot=setInterval(ip,ja)),Ct=1,ka(vr))}}function br(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 cp=es("start","end","cancel","interrupt"),lp=[],Ca=0,Nr=1,zs=2,Cn=3,jr=4,Ls=5,Sn=6;function ss(e,t,n,s,o,r){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;dp(e,n,{name:t,index:s,group:o,on:cp,tween:lp,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:Ca})}function vo(e,t){var n=Oe(e,t);if(n.state>Ca)throw new Error("too late; already scheduled");return n}function Ye(e,t){var n=Oe(e,t);if(n.state>Cn)throw new Error("too late; already running");return n}function Oe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function dp(e,t,n){var s=e.__transition,o;s[t]=n,n.timer=Ea(r,0,n.time);function r(d){n.state=Nr,n.timer.restart(i,n.delay,n.time),n.delay<=d&&i(d-n.delay)}function i(d){var u,h,f,p;if(n.state!==Nr)return l();for(u in s)if(p=s[u],p.name===n.name){if(p.state===Cn)return br(i);p.state===jr?(p.state=Sn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete s[u]):+u<t&&(p.state=Sn,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete s[u])}if(br(function(){n.state===Cn&&(n.state=jr,n.timer.restart(c,n.delay,n.time),c(d))}),n.state=zs,n.on.call("start",e,e.__data__,n.index,n.group),n.state===zs){for(n.state=Cn,o=new Array(f=n.tween.length),u=0,h=-1;u<f;++u)(p=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++h]=p);o.length=h+1}}function c(d){for(var u=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(l),n.state=Ls,1),h=-1,f=o.length;++h<f;)o[h].call(e,u);n.state===Ls&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Sn,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function _n(e,t){var n=e.__transition,s,o,r=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((s=n[i]).name!==t){r=!1;continue}o=s.state>zs&&s.state<Ls,s.state=Sn,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[i]}r&&delete e.__transition}}function up(e){return this.each(function(){_n(this,e)})}function fp(e,t){var n,s;return function(){var o=Ye(this,e),r=o.tween;if(r!==n){s=n=r;for(var i=0,c=s.length;i<c;++i)if(s[i].name===t){s=s.slice(),s.splice(i,1);break}}o.tween=s}}function hp(e,t,n){var s,o;if(typeof n!="function")throw new Error;return function(){var r=Ye(this,e),i=r.tween;if(i!==s){o=(s=i).slice();for(var c={name:t,value:n},l=0,d=o.length;l<d;++l)if(o[l].name===t){o[l]=c;break}l===d&&o.push(c)}r.tween=o}}function pp(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Oe(this.node(),n).tween,o=0,r=s.length,i;o<r;++o)if((i=s[o]).name===e)return i.value;return null}return this.each((t==null?fp:hp)(n,e,t))}function bo(e,t,n){var s=e._id;return e.each(function(){var o=Ye(this,s);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Oe(o,s).value[t]}}function Sa(e,t){var n;return(typeof t=="number"?He:t instanceof lt?Dn:(n=lt(t))?(t=n,Dn):va)(e,t)}function mp(e){return function(){this.removeAttribute(e)}}function gp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xp(e,t,n){var s,o=n+"",r;return function(){var i=this.getAttribute(e);return i===o?null:i===s?r:r=t(s=i,n)}}function yp(e,t,n){var s,o=n+"",r;return function(){var i=this.getAttributeNS(e.space,e.local);return i===o?null:i===s?r:r=t(s=i,n)}}function wp(e,t,n){var s,o,r;return function(){var i,c=n(this),l;return c==null?void this.removeAttribute(e):(i=this.getAttribute(e),l=c+"",i===l?null:i===s&&l===o?r:(o=l,r=t(s=i,c)))}}function vp(e,t,n){var s,o,r;return function(){var i,c=n(this),l;return c==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),l=c+"",i===l?null:i===s&&l===o?r:(o=l,r=t(s=i,c)))}}function bp(e,t){var n=ts(e),s=n==="transform"?ep:Sa;return this.attrTween(e,typeof t=="function"?(n.local?vp:wp)(n,s,bo(this,"attr."+e,t)):t==null?(n.local?gp:mp)(n):(n.local?yp:xp)(n,s,t))}function Np(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function jp(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function kp(e,t){var n,s;function o(){var r=t.apply(this,arguments);return r!==s&&(n=(s=r)&&jp(e,r)),n}return o._value=t,o}function Ep(e,t){var n,s;function o(){var r=t.apply(this,arguments);return r!==s&&(n=(s=r)&&Np(e,r)),n}return o._value=t,o}function Cp(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=ts(e);return this.tween(n,(s.local?kp:Ep)(s,t))}function Sp(e,t){return function(){vo(this,e).delay=+t.apply(this,arguments)}}function _p(e,t){return t=+t,function(){vo(this,e).delay=t}}function Mp(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Sp:_p)(t,e)):Oe(this.node(),t).delay}function Ip(e,t){return function(){Ye(this,e).duration=+t.apply(this,arguments)}}function $p(e,t){return t=+t,function(){Ye(this,e).duration=t}}function Rp(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ip:$p)(t,e)):Oe(this.node(),t).duration}function Ap(e,t){if(typeof t!="function")throw new Error;return function(){Ye(this,e).ease=t}}function Dp(e){var t=this._id;return arguments.length?this.each(Ap(t,e)):Oe(this.node(),t).ease}function Pp(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ye(this,e).ease=n}}function Tp(e){if(typeof e!="function")throw new Error;return this.each(Pp(this._id,e))}function Op(e){typeof e!="function"&&(e=oa(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var r=t[o],i=r.length,c=s[o]=[],l,d=0;d<i;++d)(l=r[d])&&e.call(l,l.__data__,d,r)&&c.push(l);return new Ge(s,this._parents,this._name,this._id)}function zp(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,o=n.length,r=Math.min(s,o),i=new Array(s),c=0;c<r;++c)for(var l=t[c],d=n[c],u=l.length,h=i[c]=new Array(u),f,p=0;p<u;++p)(f=l[p]||d[p])&&(h[p]=f);for(;c<s;++c)i[c]=t[c];return new Ge(i,this._parents,this._name,this._id)}function Lp(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 Hp(e,t,n){var s,o,r=Lp(t)?vo:Ye;return function(){var i=r(this,e),c=i.on;c!==s&&(o=(s=c).copy()).on(t,n),i.on=o}}function Vp(e,t){var n=this._id;return arguments.length<2?Oe(this.node(),n).on.on(e):this.each(Hp(n,e,t))}function Fp(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Bp(){return this.on("end.remove",Fp(this._id))}function Wp(e){var t=this._name,n=this._id;typeof e!="function"&&(e=mo(e));for(var s=this._groups,o=s.length,r=new Array(o),i=0;i<o;++i)for(var c=s[i],l=c.length,d=r[i]=new Array(l),u,h,f=0;f<l;++f)(u=c[f])&&(h=e.call(u,u.__data__,f,c))&&("__data__"in u&&(h.__data__=u.__data__),d[f]=h,ss(d[f],t,n,f,d,Oe(u,n)));return new Ge(r,this._parents,t,n)}function Yp(e){var t=this._name,n=this._id;typeof e!="function"&&(e=sa(e));for(var s=this._groups,o=s.length,r=[],i=[],c=0;c<o;++c)for(var l=s[c],d=l.length,u,h=0;h<d;++h)if(u=l[h]){for(var f=e.call(u,u.__data__,h,l),p,m=Oe(u,n),w=0,x=f.length;w<x;++w)(p=f[w])&&ss(p,t,n,w,f,m);r.push(f),i.push(u)}return new Ge(r,i,t,n)}var Xp=rn.prototype.constructor;function qp(){return new Xp(this._groups,this._parents)}function Zp(e,t){var n,s,o;return function(){var r=Et(this,e),i=(this.style.removeProperty(e),Et(this,e));return r===i?null:r===n&&i===s?o:o=t(n=r,s=i)}}function _a(e){return function(){this.style.removeProperty(e)}}function Gp(e,t,n){var s,o=n+"",r;return function(){var i=Et(this,e);return i===o?null:i===s?r:r=t(s=i,n)}}function Up(e,t,n){var s,o,r;return function(){var i=Et(this,e),c=n(this),l=c+"";return c==null&&(l=c=(this.style.removeProperty(e),Et(this,e))),i===l?null:i===s&&l===o?r:(o=l,r=t(s=i,c))}}function Kp(e,t){var n,s,o,r="style."+t,i="end."+r,c;return function(){var l=Ye(this,e),d=l.on,u=l.value[r]==null?c||(c=_a(t)):void 0;(d!==n||o!==u)&&(s=(n=d).copy()).on(i,o=u),l.on=s}}function Qp(e,t,n){var s=(e+="")=="transform"?Jh:Sa;return t==null?this.styleTween(e,Zp(e,s)).on("end.style."+e,_a(e)):typeof t=="function"?this.styleTween(e,Up(e,s,bo(this,"style."+e,t))).each(Kp(this._id,e)):this.styleTween(e,Gp(e,s,t),n).on("end.style."+e,null)}function Jp(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function em(e,t,n){var s,o;function r(){var i=t.apply(this,arguments);return i!==o&&(s=(o=i)&&Jp(e,i,n)),s}return r._value=t,r}function tm(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,em(e,t,n??""))}function nm(e){return function(){this.textContent=e}}function sm(e){return function(){var t=e(this);this.textContent=t??""}}function om(e){return this.tween("text",typeof e=="function"?sm(bo(this,"text",e)):nm(e==null?"":e+""))}function rm(e){return function(t){this.textContent=e.call(this,t)}}function im(e){var t,n;function s(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&rm(o)),t}return s._value=e,s}function am(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,im(e))}function cm(){for(var e=this._name,t=this._id,n=Ma(),s=this._groups,o=s.length,r=0;r<o;++r)for(var i=s[r],c=i.length,l,d=0;d<c;++d)if(l=i[d]){var u=Oe(l,t);ss(l,e,n,d,i,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Ge(s,this._parents,e,n)}function lm(){var e,t,n=this,s=n._id,o=n.size();return new Promise(function(r,i){var c={value:i},l={value:function(){--o===0&&r()}};n.each(function(){var d=Ye(this,s),u=d.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(l)),d.on=t}),o===0&&r()})}var dm=0;function Ge(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Ma(){return++dm}var Xe=rn.prototype;Ge.prototype={constructor:Ge,select:Wp,selectAll:Yp,selectChild:Xe.selectChild,selectChildren:Xe.selectChildren,filter:Op,merge:zp,selection:qp,transition:cm,call:Xe.call,nodes:Xe.nodes,node:Xe.node,size:Xe.size,empty:Xe.empty,each:Xe.each,on:Vp,attr:bp,attrTween:Cp,style:Qp,styleTween:tm,text:om,textTween:am,remove:Bp,tween:pp,delay:Mp,duration:Rp,ease:Dp,easeVarying:Tp,end:lm,[Symbol.iterator]:Xe[Symbol.iterator]};function um(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var fm={time:null,delay:0,duration:250,ease:um};function hm(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 pm(e){var t,n;e instanceof Ge?(t=e._id,e=e._name):(t=Ma(),(n=fm).time=wo(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,r=0;r<o;++r)for(var i=s[r],c=i.length,l,d=0;d<c;++d)(l=i[d])&&ss(l,e,t,d,i,n||hm(l,t));return new Ge(s,this._parents,e,t)}rn.prototype.interrupt=up;rn.prototype.transition=pm;const yn=e=>()=>e;function mm(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 Ze(e,t,n){this.k=e,this.x=t,this.y=n}Ze.prototype={constructor:Ze,scale:function(e){return e===1?this:new Ze(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ze(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 os=new Ze(1,0,0);Ia.prototype=Ze.prototype;function Ia(e){for(;!e.__zoom;)if(!(e=e.parentNode))return os;return e.__zoom}function ws(e){e.stopImmediatePropagation()}function zt(e){e.preventDefault(),e.stopImmediatePropagation()}function gm(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function xm(){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 kr(){return this.__zoom||os}function ym(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function wm(){return navigator.maxTouchPoints||"ontouchstart"in this}function vm(e,t,n){var s=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],r=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i))}function $a(){var e=gm,t=xm,n=vm,s=ym,o=wm,r=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],c=250,l=En,d=es("start","zoom","end"),u,h,f,p=500,m=150,w=0,x=10;function y(b){b.property("__zoom",kr).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",V).filter(o).on("touchstart.zoom",T).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(b,S,_,M){var D=b.selection?b.selection():b;D.property("__zoom",kr),b!==D?E(b,S,_,M):D.interrupt().each(function(){k(this,arguments).event(M).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},y.scaleBy=function(b,S,_,M){y.scaleTo(b,function(){var D=this.__zoom.k,P=typeof S=="function"?S.apply(this,arguments):S;return D*P},_,M)},y.scaleTo=function(b,S,_,M){y.transform(b,function(){var D=t.apply(this,arguments),P=this.__zoom,L=_==null?v(D):typeof _=="function"?_.apply(this,arguments):_,H=P.invert(L),F=typeof S=="function"?S.apply(this,arguments):S;return n(g(j(P,F),L,H),D,i)},_,M)},y.translateBy=function(b,S,_,M){y.transform(b,function(){return n(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof _=="function"?_.apply(this,arguments):_),t.apply(this,arguments),i)},null,M)},y.translateTo=function(b,S,_,M,D){y.transform(b,function(){var P=t.apply(this,arguments),L=this.__zoom,H=M==null?v(P):typeof M=="function"?M.apply(this,arguments):M;return n(os.translate(H[0],H[1]).scale(L.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof _=="function"?-_.apply(this,arguments):-_),P,i)},M,D)};function j(b,S){return S=Math.max(r[0],Math.min(r[1],S)),S===b.k?b:new Ze(S,b.x,b.y)}function g(b,S,_){var M=S[0]-_[0]*b.k,D=S[1]-_[1]*b.k;return M===b.x&&D===b.y?b:new Ze(b.k,M,D)}function v(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function E(b,S,_,M){b.on("start.zoom",function(){k(this,arguments).event(M).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(M).end()}).tween("zoom",function(){var D=this,P=arguments,L=k(D,P).event(M),H=t.apply(D,P),F=_==null?v(H):typeof _=="function"?_.apply(D,P):_,O=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),B=D.__zoom,Y=typeof S=="function"?S.apply(D,P):S,Q=l(B.invert(F).concat(O/B.k),Y.invert(F).concat(O/Y.k));return function(G){if(G===1)G=Y;else{var z=Q(G),Z=O/z[2];G=new Ze(Z,F[0]-z[0]*Z,F[1]-z[1]*Z)}L.zoom(null,G)}})}function k(b,S,_){return!_&&b.__zooming||new C(b,S)}function C(b,S){this.that=b,this.args=S,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,S),this.taps=0}C.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,S){return this.mouse&&b!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var S=ke(this.that).datum();d.call(b,this.that,new mm(b,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),S)}};function I(b,...S){if(!e.apply(this,arguments))return;var _=k(this,S).event(b),M=this.__zoom,D=Math.max(r[0],Math.min(r[1],M.k*Math.pow(2,s.apply(this,arguments)))),P=$e(b);if(_.wheel)(_.mouse[0][0]!==P[0]||_.mouse[0][1]!==P[1])&&(_.mouse[1]=M.invert(_.mouse[0]=P)),clearTimeout(_.wheel);else{if(M.k===D)return;_.mouse=[P,M.invert(P)],_n(this),_.start()}zt(b),_.wheel=setTimeout(L,m),_.zoom("mouse",n(g(j(M,D),_.mouse[0],_.mouse[1]),_.extent,i));function L(){_.wheel=null,_.end()}}function R(b,...S){if(f||!e.apply(this,arguments))return;var _=b.currentTarget,M=k(this,S,!0).event(b),D=ke(b.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",O,!0),P=$e(b,_),L=b.clientX,H=b.clientY;pa(b.view),ws(b),M.mouse=[P,this.__zoom.invert(P)],_n(this),M.start();function F(B){if(zt(B),!M.moved){var Y=B.clientX-L,Q=B.clientY-H;M.moved=Y*Y+Q*Q>w}M.event(B).zoom("mouse",n(g(M.that.__zoom,M.mouse[0]=$e(B,_),M.mouse[1]),M.extent,i))}function O(B){D.on("mousemove.zoom mouseup.zoom",null),ma(B.view,M.moved),zt(B),M.event(B).end()}}function V(b,...S){if(e.apply(this,arguments)){var _=this.__zoom,M=$e(b.changedTouches?b.changedTouches[0]:b,this),D=_.invert(M),P=_.k*(b.shiftKey?.5:2),L=n(g(j(_,P),M,D),t.apply(this,S),i);zt(b),c>0?ke(this).transition().duration(c).call(E,L,M,b):ke(this).call(y.transform,L,M,b)}}function T(b,...S){if(e.apply(this,arguments)){var _=b.touches,M=_.length,D=k(this,S,b.changedTouches.length===M).event(b),P,L,H,F;for(ws(b),L=0;L<M;++L)H=_[L],F=$e(H,this),F=[F,this.__zoom.invert(F),H.identifier],D.touch0?!D.touch1&&D.touch0[2]!==F[2]&&(D.touch1=F,D.taps=0):(D.touch0=F,P=!0,D.taps=1+!!u);u&&(u=clearTimeout(u)),P&&(D.taps<2&&(h=F[0],u=setTimeout(function(){u=null},p)),_n(this),D.start())}}function $(b,...S){if(this.__zooming){var _=k(this,S).event(b),M=b.changedTouches,D=M.length,P,L,H,F;for(zt(b),P=0;P<D;++P)L=M[P],H=$e(L,this),_.touch0&&_.touch0[2]===L.identifier?_.touch0[0]=H:_.touch1&&_.touch1[2]===L.identifier&&(_.touch1[0]=H);if(L=_.that.__zoom,_.touch1){var O=_.touch0[0],B=_.touch0[1],Y=_.touch1[0],Q=_.touch1[1],G=(G=Y[0]-O[0])*G+(G=Y[1]-O[1])*G,z=(z=Q[0]-B[0])*z+(z=Q[1]-B[1])*z;L=j(L,Math.sqrt(G/z)),H=[(O[0]+Y[0])/2,(O[1]+Y[1])/2],F=[(B[0]+Q[0])/2,(B[1]+Q[1])/2]}else if(_.touch0)H=_.touch0[0],F=_.touch0[1];else return;_.zoom("touch",n(g(L,H,F),_.extent,i))}}function A(b,...S){if(this.__zooming){var _=k(this,S).event(b),M=b.changedTouches,D=M.length,P,L;for(ws(b),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),P=0;P<D;++P)L=M[P],_.touch0&&_.touch0[2]===L.identifier?delete _.touch0:_.touch1&&_.touch1[2]===L.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&(L=$e(L,this),Math.hypot(h[0]-L[0],h[1]-L[1])<x)){var H=ke(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return y.wheelDelta=function(b){return arguments.length?(s=typeof b=="function"?b:yn(+b),y):s},y.filter=function(b){return arguments.length?(e=typeof b=="function"?b:yn(!!b),y):e},y.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:yn(!!b),y):o},y.extent=function(b){return arguments.length?(t=typeof b=="function"?b:yn([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),y):t},y.scaleExtent=function(b){return arguments.length?(r[0]=+b[0],r[1]=+b[1],y):[r[0],r[1]]},y.translateExtent=function(b){return arguments.length?(i[0][0]=+b[0][0],i[1][0]=+b[1][0],i[0][1]=+b[0][1],i[1][1]=+b[1][1],y):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},y.constrain=function(b){return arguments.length?(n=b,y):n},y.duration=function(b){return arguments.length?(c=+b,y):c},y.interpolate=function(b){return arguments.length?(l=b,y):l},y.on=function(){var b=d.on.apply(d,arguments);return b===d?y:b},y.clickDistance=function(b){return arguments.length?(w=(b=+b)*b,y):Math.sqrt(w)},y.tapDistance=function(b){return arguments.length?(x=+b,y):x},y}const Te={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle: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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Gt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ra=["Enter"," ","Escape"],Aa={"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 St;(function(e){e.Strict="strict",e.Loose="loose"})(St||(St={}));var at;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(at||(at={}));var Ut;(function(e){e.Partial="partial",e.Full="full"})(Ut||(Ut={}));const Da={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Je;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Je||(Je={}));var ut;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ut||(ut={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));const Er={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top};function Pa(e){return e===null?null:e?"valid":"invalid"}const Ta=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,bm=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),No=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),cn=(e,t=[0,0])=>{const{width:n,height:s}=ze(e),o=e.origin??t,r=n*o[0],i=s*o[1];return{x:e.position.x-r,y:e.position.y-i}},Nm=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const s=e.reduce((o,r)=>{const i=typeof r=="string";let c=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(c=i?t.nodeLookup.get(r):No(r)?r:t.nodeLookup.get(r.id)),c?(n=!0,rs(o,zn(c,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?is(s):{x:0,y:0,width:0,height:0}},ln=(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=rs(n,zn(o)),s=!0)}),s?is(n):{x:0,y:0,width:0,height:0}},jo=(e,t,[n,s,o]=[0,0,1],r=!1,i=!1)=>{const c=(t.x-n)/o,l=(t.y-s)/o,d=t.width/o,u=t.height/o,h=[];for(const f of e.values()){const{measured:p,selectable:m=!0,hidden:w=!1}=f;if(i&&!m||w)continue;const x=p.width??f.width??f.initialWidth??0,y=p.height??f.height??f.initialHeight??0,{x:j,y:g}=f.internals.positionAbsolute,v=Ha(c,l,d,u,j,g,x,y),E=x*y,k=r&&v>0;(!f.internals.handleBounds||k||v>=E||f.dragging)&&h.push(f)}return h},jm=(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 km(e,t){const n=new Map,s=t?.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{let r;if(t?.includeHiddenNodes){const{width:i,height:c}=ze(o);r=i>0&&c>0}else r=!!(o.measured.width&&o.measured.height&&!o.hidden);r&&(!s||s.has(o.id))&&n.set(o.id,o)}),n}async function Em({nodes:e,width:t,height:n,panZoom:s,minZoom:o,maxZoom:r},i){if(e.size===0)return!0;const c=km(e,i),l=ln(c),d=Eo(l,t,n,i?.minZoom??o,i?.maxZoom??r,i?.padding??.1);return await s.setViewport(d,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),!0}function Oa({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:o,onError:r}){const i=n.get(e),c=i.parentId?n.get(i.parentId):void 0,{x:l,y:d}=c?c.internals.positionAbsolute:{x:0,y:0},u=i.origin??s;let h=i.extent||o;if(i.extent==="parent"&&!i.expandParent)if(!c)r?.("005",Te.error005());else{const{width:p,height:m}=ze(c);p&&m&&(h=[[l,d],[l+p,d+m]])}else c&&ht(i.extent)&&(h=[[i.extent[0][0]+l,i.extent[0][1]+d],[i.extent[1][0]+l,i.extent[1][1]+d]]);const f=ht(h)?ft(t,h,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&r?.("015",Te.error015()),{position:{x:f.x-l+(i.measured.width??0)*u[0],y:f.y-d+(i.measured.height??0)*u[1]},positionAbsolute:f}}async function Cm({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:o}){const r=new Set(e.map(f=>f.id)),i=[];for(const f of n){if(f.deletable===!1)continue;const p=r.has(f.id),m=!p&&f.parentId&&i.find(w=>w.id===f.parentId);(p||m)&&i.push(f)}const c=new Set(t.map(f=>f.id)),l=s.filter(f=>f.deletable!==!1),u=jm(i,l);for(const f of l)c.has(f.id)&&!u.find(m=>m.id===f.id)&&u.push(f);if(!o)return{edges:u,nodes:i};const h=await o({nodes:i,edges:u});return typeof h=="boolean"?h?{edges:u,nodes:i}:{edges:[],nodes:[]}:h}const _t=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ft=(e={x:0,y:0},t,n)=>({x:_t(e.x,t[0][0],t[1][0]-(n?.width??0)),y:_t(e.y,t[0][1],t[1][1]-(n?.height??0))});function za(e,t,n){const{width:s,height:o}=ze(n),{x:r,y:i}=n.internals.positionAbsolute;return ft(e,[[r,i],[r+s,i+o]],t)}const Cr=(e,t,n)=>e<t?_t(Math.abs(e-t),1,t)/t:e>n?-_t(Math.abs(e-n),1,t)/t:0,ko=(e,t,n=15,s=40)=>{const o=Cr(e.x,s,t.width-s)*n,r=Cr(e.y,s,t.height-s)*n;return[o,r]},rs=(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)}),Hs=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),is=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),Kt=(e,t=[0,0])=>{const{x:n,y:s}=No(e)?e.internals.positionAbsolute:cn(e,t);return{x:n,y:s,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},zn=(e,t=[0,0])=>{const{x:n,y:s}=No(e)?e.internals.positionAbsolute:cn(e,t);return{x:n,y:s,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:s+(e.measured?.height??e.height??e.initialHeight??0)}},La=(e,t)=>is(rs(Hs(e),Hs(t))),Ha=(e,t,n,s,o,r,i,c)=>{const l=Math.max(0,Math.min(e+n,o+i)-Math.max(e,o)),d=Math.max(0,Math.min(t+s,r+c)-Math.max(t,r));return Math.ceil(l*d)},Ln=(e,t)=>Ha(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Sr=e=>Ae(e.width)&&Ae(e.height)&&Ae(e.x)&&Ae(e.y),Ae=e=>!isNaN(e)&&isFinite(e),Va=(e,t)=>(n,s)=>{},dn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),un=({x:e,y:t},[n,s,o],r=!1,i=[1,1])=>{const c={x:(e-n)/o,y:(t-s)/o};return r?dn(c,i):c},Mt=({x:e,y:t},[n,s,o])=>({x:e*o+n,y:t*o+s});function xt(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(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Sm(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=xt(e,n),o=xt(e,t);return{top:s,right:o,bottom:s,left:o,x:o*2,y:s*2}}if(typeof e=="object"){const s=xt(e.top??e.y??0,n),o=xt(e.bottom??e.y??0,n),r=xt(e.left??e.x??0,t),i=xt(e.right??e.x??0,t);return{top:s,right:i,bottom:o,left:r,x:r+i,y:s+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function _m(e,t,n,s,o,r){const{x:i,y:c}=Mt(e,[t,n,s]),{x:l,y:d}=Mt({x:e.x+e.width,y:e.y+e.height},[t,n,s]),u=o-l,h=r-d;return{left:Math.floor(i),top:Math.floor(c),right:Math.floor(u),bottom:Math.floor(h)}}const Eo=(e,t,n,s,o,r)=>{const i=Sm(r,t,n),c=(t-i.x)/e.width,l=(n-i.y)/e.height,d=Math.min(c,l),u=_t(d,s,o),h=e.x+e.width/2,f=e.y+e.height/2,p=t/2-h*u,m=n/2-f*u,w=_m(e,p,m,u,t,n),x={left:Math.min(w.left-i.left,0),top:Math.min(w.top-i.top,0),right:Math.min(w.right-i.right,0),bottom:Math.min(w.bottom-i.bottom,0)};return{x:p-x.left+x.right,y:m-x.top+x.bottom,zoom:u}},Qt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function ht(e){return e!=null&&e!=="parent"}function ze(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Fa(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Ba(e,t={width:0,height:0},n,s,o){const r={...e},i=s.get(n);if(i){const c=i.origin||o;r.x+=i.internals.positionAbsolute.x-(t.width??0)*c[0],r.y+=i.internals.positionAbsolute.y-(t.height??0)*c[1]}return r}function _r(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Mm(){let e,t;return{promise:new Promise((s,o)=>{e=s,t=o}),resolve:e,reject:t}}function Im(e){return{...Aa,...e||{}}}function Wt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:o}){const{x:r,y:i}=De(e),c=un({x:r-(o?.left??0),y:i-(o?.top??0)},s),{x:l,y:d}=n?dn(c,t):c;return{xSnapped:l,ySnapped:d,...c}}const Co=e=>({width:e.offsetWidth,height:e.offsetHeight}),Wa=e=>e?.getRootNode?.()||window?.document,$m=["INPUT","SELECT","TEXTAREA"];function Ya(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:$m.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Xa=e=>"clientX"in e,De=(e,t)=>{const n=Xa(e),s=n?e.clientX:e.touches?.[0].clientX,o=n?e.clientY:e.touches?.[0].clientY;return{x:s-(t?.left??0),y:o-(t?.top??0)}},Mr=(e,t,n,s,o)=>{const r=t.querySelectorAll(`.${e}`);return!r||!r.length?null:Array.from(r).map(i=>{const c=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:o,position:i.getAttribute("data-handlepos"),x:(c.left-n.left)/s,y:(c.top-n.top)/s,...Co(i)}})};function qa({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:o,sourceControlY:r,targetControlX:i,targetControlY:c}){const l=e*.125+o*.375+i*.375+n*.125,d=t*.125+r*.375+c*.375+s*.125,u=Math.abs(l-e),h=Math.abs(d-t);return[l,d,u,h]}function wn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Ir({pos:e,x1:t,y1:n,x2:s,y2:o,c:r}){switch(e){case q.Left:return[t-wn(t-s,r),n];case q.Right:return[t+wn(s-t,r),n];case q.Top:return[t,n-wn(n-o,r)];case q.Bottom:return[t,n+wn(o-n,r)]}}function So({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:r=q.Top,curvature:i=.25}){const[c,l]=Ir({pos:n,x1:e,y1:t,x2:s,y2:o,c:i}),[d,u]=Ir({pos:r,x1:s,y1:o,x2:e,y2:t,c:i}),[h,f,p,m]=qa({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:c,sourceControlY:l,targetControlX:d,targetControlY:u});return[`M${e},${t} C${c},${l} ${d},${u} ${s},${o}`,h,f,p,m]}function Za({sourceX:e,sourceY:t,targetX:n,targetY:s}){const o=Math.abs(n-e)/2,r=n<e?n+o:n-o,i=Math.abs(s-t)/2,c=s<t?s+i:s-i;return[r,c,o,i]}function Rm({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:o=!1,zIndexMode:r="basic"}){if(r==="manual")return s;const i=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 i+c}function Am({sourceNode:e,targetNode:t,width:n,height:s,transform:o}){const r=rs(zn(e),zn(t));r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1);const i={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:s/o[2]};return Ln(i,is(r))>0}const Dm=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,Pm=(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)),Tm=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",Te.error006()),t;const s=n.getEdgeId||Dm;let o;return Ta(e)?o={...e}:o={...e,id:s(e)},Pm(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function Ga({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[o,r,i,c]=Za({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,o,r,i,c]}const $r={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},Om=({source:e,sourcePosition:t=q.Bottom,target:n})=>t===q.Left||t===q.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},Rr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function zm({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:s=q.Top,center:o,offset:r,stepPosition:i}){const c=$r[t],l=$r[s],d={x:e.x+c.x*r,y:e.y+c.y*r},u={x:n.x+l.x*r,y:n.y+l.y*r},h=Om({source:d,sourcePosition:t,target:u}),f=h.x!==0?"x":"y",p=h[f];let m=[],w,x;const y={x:0,y:0},j={x:0,y:0},[,,g,v]=Za({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[f]*l[f]===-1){f==="x"?(w=o.x??d.x+(u.x-d.x)*i,x=o.y??(d.y+u.y)/2):(w=o.x??(d.x+u.x)/2,x=o.y??d.y+(u.y-d.y)*i);const I=[{x:w,y:d.y},{x:w,y:u.y}],R=[{x:d.x,y:x},{x:u.x,y:x}];c[f]===p?m=f==="x"?I:R:m=f==="x"?R:I}else{const I=[{x:d.x,y:u.y}],R=[{x:u.x,y:d.y}];if(f==="x"?m=c.x===p?R:I:m=c.y===p?I:R,t===s){const b=Math.abs(e[f]-n[f]);if(b<=r){const S=Math.min(r-1,r-b);c[f]===p?y[f]=(d[f]>e[f]?-1:1)*S:j[f]=(u[f]>n[f]?-1:1)*S}}if(t!==s){const b=f==="x"?"y":"x",S=c[f]===l[b],_=d[b]>u[b],M=d[b]<u[b];(c[f]===1&&(!S&&_||S&&M)||c[f]!==1&&(!S&&M||S&&_))&&(m=f==="x"?I:R)}const V={x:d.x+y.x,y:d.y+y.y},T={x:u.x+j.x,y:u.y+j.y},$=Math.max(Math.abs(V.x-m[0].x),Math.abs(T.x-m[0].x)),A=Math.max(Math.abs(V.y-m[0].y),Math.abs(T.y-m[0].y));$>=A?(w=(V.x+T.x)/2,x=m[0].y):(w=m[0].x,x=(V.y+T.y)/2)}const E={x:d.x+y.x,y:d.y+y.y},k={x:u.x+j.x,y:u.y+j.y};return[[e,...E.x!==m[0].x||E.y!==m[0].y?[E]:[],...m,...k.x!==m[m.length-1].x||k.y!==m[m.length-1].y?[k]:[],n],w,x,g,v]}function Lm(e,t,n,s){const o=Math.min(Rr(e,t)/2,Rr(t,n)/2,s),{x:r,y:i}=t;if(e.x===r&&r===n.x||e.y===i&&i===n.y)return`L${r} ${i}`;if(e.y===i){const d=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${r+o*d},${i}Q ${r},${i} ${r},${i+o*u}`}const c=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${r},${i+o*l}Q ${r},${i} ${r+o*c},${i}`}function Hn({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:r=q.Top,borderRadius:i=5,centerX:c,centerY:l,offset:d=20,stepPosition:u=.5}){const[h,f,p,m,w]=zm({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:o},targetPosition:r,center:{x:c,y:l},offset:d,stepPosition:u});let x=`M${h[0].x} ${h[0].y}`;for(let y=1;y<h.length-1;y++)x+=Lm(h[y-1],h[y],h[y+1],i);return x+=`L${h[h.length-1].x} ${h[h.length-1].y}`,[x,f,p,m,w]}function Ar(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Hm(e){const{sourceNode:t,targetNode:n}=e;if(!Ar(t)||!Ar(n))return null;const s=t.internals.handleBounds||Dr(t.handles),o=n.internals.handleBounds||Dr(n.handles),r=Pr(s?.source??[],e.sourceHandle),i=Pr(e.connectionMode===St.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!r||!i)return e.onError?.("008",Te.error008(r?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=r?.position||q.Bottom,l=i?.position||q.Top,d=pt(t,r,c),u=pt(n,i,l);return{sourceX:d.x,sourceY:d.y,targetX:u.x,targetY:u.y,sourcePosition:c,targetPosition:l}}function Dr(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 pt(e,t,n=q.Left,s=!1){const o=(t?.x??0)+e.internals.positionAbsolute.x,r=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:c}=t??ze(e);if(s)return{x:o+i/2,y:r+c/2};switch(t?.position??n){case q.Top:return{x:o+i/2,y:r};case q.Right:return{x:o+i,y:r+c/2};case q.Bottom:return{x:o+i/2,y:r+c};case q.Left:return{x:o,y:r+c/2}}}function Pr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Vs(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function Vm(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:o}){const r=new Set;return e.reduce((i,c)=>([c.markerStart||s,c.markerEnd||o].forEach(l=>{if(l&&typeof l=="object"){const d=Vs(l,t);r.has(d)||(i.push({id:d,color:l.color||n,...l}),r.add(d))}}),i),[]).sort((i,c)=>i.id.localeCompare(c.id))}const Ua=1e3,Fm=10,_o={nodeOrigin:[0,0],nodeExtent:Gt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Bm={..._o,checkEquality:!0};function Mo(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function Wm(e,t,n){const s=Mo(_o,n);for(const o of e.values())if(o.parentId)$o(o,e,t,s);else{const r=cn(o,s.nodeOrigin),i=ht(o.extent)?o.extent:s.nodeExtent,c=ft(r,i,ze(o));o.internals.positionAbsolute=c}}function Ym(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],s=[];for(const o of e.handles){const r={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(r):o.type==="target"&&s.push(r)}return{source:n,target:s}}function Io(e){return e==="manual"}function Fs(e,t,n,s={}){const o=Mo(Bm,s),r={i:0},i=new Map(t),c=o?.elevateNodesOnSelect&&!Io(o.zIndexMode)?Ua:0;let l=e.length>0,d=!1;t.clear(),n.clear();for(const u of e){let h=i.get(u.id);if(o.checkEquality&&u===h?.internals.userNode)t.set(u.id,h);else{const f=cn(u,o.nodeOrigin),p=ht(u.extent)?u.extent:o.nodeExtent,m=ft(f,p,ze(u));h={...o.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:m,handleBounds:Ym(u,h),z:Ka(u,c,o.zIndexMode),userNode:u}},t.set(u.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),u.parentId&&$o(h,t,n,s,r),d||=u.selected??!1}return{nodesInitialized:l,hasSelectedNodes:d}}function Xm(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 $o(e,t,n,s,o){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:c,zIndexMode:l}=Mo(_o,s),d=e.parentId,u=t.get(d);if(!u){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Xm(e,n),o&&!u.parentId&&u.internals.rootParentIndex===void 0&&l==="auto"&&(u.internals.rootParentIndex=++o.i,u.internals.z=u.internals.z+o.i*Fm),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const h=r&&!Io(l)?Ua:0,{x:f,y:p,z:m}=qm(e,u,i,c,h,l),{positionAbsolute:w}=e.internals,x=f!==w.x||p!==w.y;(x||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:p}:w,z:m}})}function Ka(e,t,n){const s=Ae(e.zIndex)?e.zIndex:0;return Io(n)?s:s+(e.selected?t:0)}function qm(e,t,n,s,o,r){const{x:i,y:c}=t.internals.positionAbsolute,l=ze(e),d=cn(e,n),u=ht(e.extent)?ft(d,e.extent,l):d;let h=ft({x:i+u.x,y:c+u.y},s,l);e.extent==="parent"&&(h=za(h,l,t));const f=Ka(e,o,r),p=t.internals.z??0;return{x:h.x,y:h.y,z:p>=f?p+1:f}}function Ro(e,t,n,s=[0,0]){const o=[],r=new Map;for(const i of e){const c=t.get(i.parentId);if(!c)continue;const l=r.get(i.parentId)?.expandedRect??Kt(c),d=La(l,i.rect);r.set(i.parentId,{expandedRect:d,parent:c})}return r.size>0&&r.forEach(({expandedRect:i,parent:c},l)=>{const d=c.internals.positionAbsolute,u=ze(c),h=c.origin??s,f=i.x<d.x?Math.round(Math.abs(d.x-i.x)):0,p=i.y<d.y?Math.round(Math.abs(d.y-i.y)):0,m=Math.max(u.width,Math.round(i.width)),w=Math.max(u.height,Math.round(i.height)),x=(m-u.width)*h[0],y=(w-u.height)*h[1];(f>0||p>0||x||y)&&(o.push({id:l,type:"position",position:{x:c.position.x-f+x,y:c.position.y-p+y}}),n.get(l)?.forEach(j=>{e.some(g=>g.id===j.id)||o.push({id:j.id,type:"position",position:{x:j.position.x+f,y:j.position.y+p}})})),(u.width<i.width||u.height<i.height||f||p)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:m+(f?h[0]*f-x:0),height:w+(p?h[1]*p-y:0)}})}),o}function Zm(e,t,n,s,o,r,i){const c=s?.querySelector(".xyflow__viewport");let l=!1;if(!c)return{changes:[],updatedInternals:l};const d=[],u=window.getComputedStyle(c),{m22:h}=new window.DOMMatrixReadOnly(u.transform),f=[];for(const p of e.values()){const m=t.get(p.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),l=!0;continue}const w=Co(p.nodeElement),x=m.measured.width!==w.width||m.measured.height!==w.height;if(!!(w.width&&w.height&&(x||!m.internals.handleBounds||p.force))){const j=p.nodeElement.getBoundingClientRect(),g=ht(m.extent)?m.extent:r;let{positionAbsolute:v}=m.internals;if(m.parentId&&m.extent==="parent"){const k=t.get(m.parentId);k&&(v=za(v,w,k))}else g&&(v=ft(v,g,w));const E={...m,measured:w,internals:{...m.internals,positionAbsolute:v,handleBounds:{source:Mr("source",p.nodeElement,j,h,m.id),target:Mr("target",p.nodeElement,j,h,m.id)}}};t.set(m.id,E),m.parentId&&$o(E,t,n,{nodeOrigin:o,zIndexMode:i}),l=!0,x&&(d.push({id:m.id,type:"dimensions",dimensions:w}),m.expandParent&&m.parentId&&f.push({id:m.id,parentId:m.parentId,rect:Kt(E,o)}))}}if(f.length>0){const p=Ro(f,t,n,o);d.push(...p)}return{changes:d,updatedInternals:l}}async function Gm({delta:e,panZoom:t,transform:n,translateExtent:s,width:o,height:r}){if(!t||!e.x&&!e.y)return!1;const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,r]],s);return!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2])}function Tr(e,t,n,s,o,r){let i=o;const c=s.get(i)||new Map;s.set(i,c.set(n,t)),i=`${o}-${e}`;const l=s.get(i)||new Map;if(s.set(i,l.set(n,t)),r){i=`${o}-${e}-${r}`;const d=s.get(i)||new Map;s.set(i,d.set(n,t))}}function Qa(e,t,n){e.clear(),t.clear();for(const s of n){const{source:o,target:r,sourceHandle:i=null,targetHandle:c=null}=s,l={edgeId:s.id,source:o,target:r,sourceHandle:i,targetHandle:c},d=`${o}-${i}--${r}-${c}`,u=`${r}-${c}--${o}-${i}`;Tr("source",l,u,e,o,i),Tr("target",l,d,e,r,c),t.set(s.id,s)}}function Ja(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ja(n,t):!1}function Or(e,t,n){let s=e;do{if(s?.matches?.(t))return!0;if(s===n)return!1;s=s?.parentElement}while(s);return!1}function Um(e,t,n,s){const o=new Map;for(const[r,i]of e)if((i.selected||i.id===s)&&(!i.parentId||!Ja(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const c=e.get(r);c&&o.set(r,{id:r,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 vs({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){const o=[];for(const[i,c]of t){const l=n.get(i)?.internals.userNode;l&&o.push({...l,position:c.position,dragging:s})}if(!e)return[o[0],o];const r=n.get(e)?.internals.userNode;return[r?{...r,position:t.get(e)?.position||r.position,dragging:s}:o[0],o]}function Km({dragItems:e,snapGrid:t,x:n,y:s}){const o=e.values().next().value;if(!o)return null;const r={x:n-o.distance.x,y:s-o.distance.y},i=dn(r,t);return{x:i.x-r.x,y:i.y-r.y}}function Qm({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:o}){let r={x:null,y:null},i=0,c=new Map,l=!1,d={x:0,y:0},u=null,h=!1,f=null,p=!1,m=!1,w=null;function x({noDragClassName:j,handleSelector:g,domNode:v,isSelectable:E,nodeId:k,nodeClickDistance:C=0}){f=ke(v);function I({x:$,y:A}){const{nodeLookup:b,nodeExtent:S,snapGrid:_,snapToGrid:M,nodeOrigin:D,onNodeDrag:P,onSelectionDrag:L,onError:H,updateNodePositions:F}=t();r={x:$,y:A};let O=!1;const B=c.size>1,Y=B&&S?Hs(ln(c)):null,Q=B&&M?Km({dragItems:c,snapGrid:_,x:$,y:A}):null;for(const[G,z]of c){if(!b.has(G))continue;let Z={x:$-z.distance.x,y:A-z.distance.y};M&&(Z=Q?{x:Math.round(Z.x+Q.x),y:Math.round(Z.y+Q.y)}:dn(Z,_));let te=null;if(B&&S&&!z.extent&&Y){const{positionAbsolute:K}=z.internals,ne=K.x-Y.x+S[0][0],ie=K.x+z.measured.width-Y.x2+S[1][0],ce=K.y-Y.y+S[0][1],pe=K.y+z.measured.height-Y.y2+S[1][1];te=[[ne,ce],[ie,pe]]}const{position:ee,positionAbsolute:U}=Oa({nodeId:G,nextPosition:Z,nodeLookup:b,nodeExtent:te||S,nodeOrigin:D,onError:H});O=O||z.position.x!==ee.x||z.position.y!==ee.y,z.position=ee,z.internals.positionAbsolute=U}if(m=m||O,!!O&&(F(c,!0),w&&(s||P||!k&&L))){const[G,z]=vs({nodeId:k,dragItems:c,nodeLookup:b});s?.(w,c,G,z),P?.(w,G,z),k||L?.(w,z)}}async function R(){if(!u)return;const{transform:$,panBy:A,autoPanSpeed:b,autoPanOnNodeDrag:S}=t();if(!S){l=!1,cancelAnimationFrame(i);return}const[_,M]=ko(d,u,b);(_!==0||M!==0)&&(r.x=(r.x??0)-_/$[2],r.y=(r.y??0)-M/$[2],await A({x:_,y:M})&&I(r)),i=requestAnimationFrame(R)}function V($){const{nodeLookup:A,multiSelectionActive:b,nodesDraggable:S,transform:_,snapGrid:M,snapToGrid:D,selectNodesOnDrag:P,onNodeDragStart:L,onSelectionDragStart:H,unselectNodesAndEdges:F}=t();h=!0,(!P||!E)&&!b&&k&&(A.get(k)?.selected||F()),E&&P&&k&&e?.(k);const O=Wt($.sourceEvent,{transform:_,snapGrid:M,snapToGrid:D,containerBounds:u});if(r=O,c=Um(A,S,O,k),c.size>0&&(n||L||!k&&H)){const[B,Y]=vs({nodeId:k,dragItems:c,nodeLookup:A});n?.($.sourceEvent,c,B,Y),L?.($.sourceEvent,B,Y),k||H?.($.sourceEvent,Y)}}const T=ga().clickDistance(C).on("start",$=>{const{domNode:A,nodeDragThreshold:b,transform:S,snapGrid:_,snapToGrid:M}=t();u=A?.getBoundingClientRect()||null,p=!1,m=!1,w=$.sourceEvent,b===0&&V($),r=Wt($.sourceEvent,{transform:S,snapGrid:_,snapToGrid:M,containerBounds:u}),d=De($.sourceEvent,u)}).on("drag",$=>{const{autoPanOnNodeDrag:A,transform:b,snapGrid:S,snapToGrid:_,nodeDragThreshold:M,nodeLookup:D}=t(),P=Wt($.sourceEvent,{transform:b,snapGrid:S,snapToGrid:_,containerBounds:u});if(w=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||k&&!D.has(k))&&(p=!0),!p){if(!l&&A&&h&&(l=!0,R()),!h){const L=De($.sourceEvent,u),H=L.x-d.x,F=L.y-d.y;Math.sqrt(H*H+F*F)>M&&V($)}(r.x!==P.xSnapped||r.y!==P.ySnapped)&&c&&h&&(d=De($.sourceEvent,u),I(P))}}).on("end",$=>{if(!h||p){p&&c.size>0&&t().updateNodePositions(c,!1);return}if(l=!1,h=!1,cancelAnimationFrame(i),c.size>0){const{nodeLookup:A,updateNodePositions:b,onNodeDragStop:S,onSelectionDragStop:_}=t();if(m&&(b(c,!1),m=!1),o||S||!k&&_){const[M,D]=vs({nodeId:k,dragItems:c,nodeLookup:A,dragging:!1});o?.($.sourceEvent,c,M,D),S?.($.sourceEvent,M,D),k||_?.($.sourceEvent,D)}}}).filter($=>{const A=$.target;return!$.button&&(!j||!Or(A,`.${j}`,v))&&(!g||Or(A,g,v))});f.call(T)}function y(){f?.on(".drag",null)}return{update:x,destroy:y}}function Jm(e,t,n){const s=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const r of t.values())Ln(o,Kt(r))>0&&s.push(r);return s}const eg=250;function tg(e,t,n,s){let o=[],r=1/0;const i=Jm(e,n,t+eg);for(const c of i){const l=[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]];for(const d of l){if(s.nodeId===d.nodeId&&s.type===d.type&&s.id===d.id)continue;const{x:u,y:h}=pt(c,d,d.position,!0),f=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(h-e.y,2));f>t||(f<r?(o=[{...d,x:u,y:h}],r=f):f===r&&o.push({...d,x:u,y:h}))}}if(!o.length)return null;if(o.length>1){const c=s.type==="source"?"target":"source";return o.find(l=>l.type===c)??o[0]}return o[0]}function ec(e,t,n,s,o,r=!1){const i=s.get(e);if(!i)return null;const c=o==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],l=(n?c?.find(d=>d.id===n):c?.[0])??null;return l&&r?{...l,...pt(i,l,l.position,!0)}:l}function tc(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function ng(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const nc=()=>!0;function sg(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:o,edgeUpdaterType:r,isTarget:i,domNode:c,nodeLookup:l,lib:d,autoPanOnConnect:u,flowId:h,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:w,onConnectEnd:x,isValidConnection:y=nc,onReconnectEnd:j,updateConnection:g,getTransform:v,getFromHandle:E,autoPanSpeed:k,dragThreshold:C=1,handleDomNode:I}){const R=Wa(e.target);let V=0,T;const{x:$,y:A}=De(e),b=tc(r,I),S=c?.getBoundingClientRect();let _=!1;if(!S||!b)return;const M=ec(o,b,s,l,t);if(!M)return;let D=De(e,S),P=!1,L=null,H=!1,F=null;function O(){if(!u||!S)return;const[ee,U]=ko(D,S,k);f({x:ee,y:U}),V=requestAnimationFrame(O)}const B={...M,nodeId:o,type:b,position:M.position},Y=l.get(o);let G={inProgress:!0,isValid:null,from:pt(Y,B,q.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:Y,to:D,toHandle:null,toPosition:Er[B.position],toNode:null,pointer:D};function z(){_=!0,g(G),m?.(e,{nodeId:o,handleId:s,handleType:b})}C===0&&z();function Z(ee){if(!_){const{x:pe,y:Ne}=De(ee),Ce=pe-$,Se=Ne-A;if(!(Ce*Ce+Se*Se>C*C))return;z()}if(!E()||!B){te(ee);return}const U=v();D=De(ee,S),T=tg(un(D,U,!1,[1,1]),n,l,B),P||(O(),P=!0);const K=sc(ee,{handle:T,connectionMode:t,fromNodeId:o,fromHandleId:s,fromType:i?"target":"source",isValidConnection:y,doc:R,lib:d,flowId:h,nodeLookup:l});F=K.handleDomNode,L=K.connection,H=ng(!!T,K.isValid);const ne=l.get(o),ie=ne?pt(ne,B,q.Left,!0):G.from,ce={...G,from:ie,isValid:H,to:K.toHandle&&H?Mt({x:K.toHandle.x,y:K.toHandle.y},U):D,toHandle:K.toHandle,toPosition:H&&K.toHandle?K.toHandle.position:Er[B.position],toNode:K.toHandle?l.get(K.toHandle.nodeId):null,pointer:D};g(ce),G=ce}function te(ee){if(!("touches"in ee&&ee.touches.length>0)){if(_){(T||F)&&L&&H&&w?.(L);const{inProgress:U,...K}=G,ne={...K,toPosition:G.toHandle?G.toPosition:null};x?.(ee,ne),r&&j?.(ee,ne)}p(),cancelAnimationFrame(V),P=!1,H=!1,L=null,F=null,R.removeEventListener("mousemove",Z),R.removeEventListener("mouseup",te),R.removeEventListener("touchmove",Z),R.removeEventListener("touchend",te)}}R.addEventListener("mousemove",Z),R.addEventListener("mouseup",te),R.addEventListener("touchmove",Z),R.addEventListener("touchend",te)}function sc(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:r,doc:i,lib:c,flowId:l,isValidConnection:d=nc,nodeLookup:u}){const h=r==="target",f=t?i.querySelector(`.${c}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=De(e),w=i.elementFromPoint(p,m),x=w?.classList.contains(`${c}-flow__handle`)?w:f,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const j=tc(void 0,x),g=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),E=x.classList.contains("connectable"),k=x.classList.contains("connectableend");if(!g||!j)return y;const C={source:h?g:s,sourceHandle:h?v:o,target:h?s:g,targetHandle:h?o:v};y.connection=C;const R=E&&k&&(n===St.Strict?h&&j==="source"||!h&&j==="target":g!==s||v!==o);y.isValid=R&&d(C),y.toHandle=ec(g,j,v,u,n,!0)}return y}const Bs={onPointerDown:sg,isValid:sc};function og({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const o=ke(e);function r({translateExtent:c,width:l,height:d,zoomStep:u=1,pannable:h=!0,zoomable:f=!0,inversePan:p=!1}){const m=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const v=n(),E=g.sourceEvent.ctrlKey&&Qt()?10:1,k=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*u,C=v[2]*Math.pow(2,k*E);t.scaleTo(C)};let w=[0,0];const x=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(w=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},y=g=>{const v=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const E=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],k=[E[0]-w[0],E[1]-w[1]];w=E;const C=s()*Math.max(v[2],Math.log(v[2]))*(p?-1:1),I={x:v[0]-k[0]*C,y:v[1]-k[1]*C},R=[[0,0],[l,d]];t.setViewportConstrained({x:I.x,y:I.y,zoom:v[2]},R,c)},j=$a().on("start",x).on("zoom",h?y:null).on("zoom.wheel",f?m:null);o.call(j,{})}function i(){o.on("zoom",null)}return{update:r,destroy:i,pointer:$e}}const as=e=>({x:e.x,y:e.y,zoom:e.k}),bs=({x:e,y:t,zoom:n})=>os.translate(e,t).scale(n),Qe=(e,t)=>e.target.closest(`.${t}`),oc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),rg=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ns=(e,t=0,n=rg,s=()=>{})=>{const o=typeof t=="number"&&t>0;return o||s(),o?e.transition().duration(t).ease(n).on("end",s):e},rc=e=>{const t=e.ctrlKey&&Qt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function ig({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:o,panOnScrollSpeed:r,zoomOnPinch:i,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:d}){return u=>{if(Qe(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const h=n.property("__zoom").k||1;if(u.ctrlKey&&i){const x=$e(u),y=rc(u),j=h*Math.pow(2,y);s.scaleTo(n,j,x,u);return}const f=u.deltaMode===1?20:1;let p=o===at.Vertical?0:u.deltaX*f,m=o===at.Horizontal?0:u.deltaY*f;!Qt()&&u.shiftKey&&o!==at.Vertical&&(p=u.deltaY*f,m=0),s.translateBy(n,-(p/h)*r,-(m/h)*r,{internal:!0});const w=as(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?l?.(u,w):(e.isPanScrolling=!0,c?.(u,w)),e.panScrollTimeout=setTimeout(()=>{d?.(u,w),e.isPanScrolling=!1},150)}}function ag({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,o){const r=s.type==="wheel",i=!t&&r&&!s.ctrlKey,c=Qe(s,e);if(s.ctrlKey&&r&&c&&s.preventDefault(),i||c)return null;s.preventDefault(),n.call(this,s,o)}}function cg({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{if(s.sourceEvent?.internal)return;const o=as(s.transform);e.mouseButton=s.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,s.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(s.sourceEvent,o)}}function lg({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:o}){return r=>{e.usedRightMouseButton=!!(n&&oc(t,e.mouseButton??0)),r.sourceEvent?.sync||s([r.transform.x,r.transform.y,r.transform.k]),o&&!r.sourceEvent?.internal&&o?.(r.sourceEvent,as(r.transform))}}function dg({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:o,onPaneContextMenu:r}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,r&&oc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&r(i.sourceEvent),e.usedRightMouseButton=!1,s(!1),o)){const c=as(i.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(i.sourceEvent,c)},n?150:0)}}}function ug({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:c,noWheelClassName:l,noPanClassName:d,lib:u,connectionInProgress:h}){return f=>{const p=t||n,m=s&&f.ctrlKey,w=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Qe(f,`${u}-flow__node`)||Qe(f,`${u}-flow__edge`)||Qe(f,`${u}-flow__selection`)||Qe(f,`${u}-flow__nodesselection`)))return!0;if(!o&&!p&&!r&&!i&&!s||c||h&&!w||Qe(f,l)&&w||Qe(f,d)&&(!w||r&&w&&!t)||!s&&f.ctrlKey&&w)return!1;if(!s&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!r&&!m&&w||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const x=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||w||e)&&x}}function fg({domNode:e,minZoom:t,maxZoom:n,translateExtent:s,viewport:o,onPanZoom:r,onPanZoomStart:i,onPanZoomEnd:c,onDraggingChange:l}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let h=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(A=>{const b=A[0];b&&(h=[[0,0],[b.contentRect.width,b.contentRect.height]])}):null)?.observe(e);const p=$a().extent(()=>h).scaleExtent([t,n]).translateExtent(s),m=ke(e).call(p);v({x:o.x,y:o.y,zoom:_t(o.zoom,t,n)},[[0,0],[u.width,u.height]],s);const w=m.on("wheel.zoom"),x=m.on("dblclick.zoom");p.wheelDelta(rc);async function y(A,b){return m?new Promise(S=>{p?.interpolate(b?.interpolate==="linear"?Bt:En).transform(Ns(m,b?.duration,b?.ease,()=>S(!0)),A)}):!1}function j({noWheelClassName:A,noPanClassName:b,onPaneContextMenu:S,userSelectionActive:_,panOnScroll:M,panOnDrag:D,panOnScrollMode:P,panOnScrollSpeed:L,preventScrolling:H,zoomOnPinch:F,zoomOnScroll:O,zoomOnDoubleClick:B,panActivationKeyPressed:Y=!1,zoomActivationKeyPressed:Q,lib:G,onTransformChange:z,connectionInProgress:Z,paneClickDistance:te,selectionOnDrag:ee}){_&&!d.isZoomingOrPanning&&g();const U=M&&!Q&&!_;p.clickDistance(ee?1/0:!Ae(te)||te<0?0:te);const K=U?ig({zoomPanValues:d,noWheelClassName:A,d3Selection:m,d3Zoom:p,panOnScrollMode:P,panOnScrollSpeed:L,zoomOnPinch:F,onPanZoomStart:i,onPanZoom:r,onPanZoomEnd:c}):ag({noWheelClassName:A,preventScrolling:H,d3ZoomHandler:w});m.on("wheel.zoom",K,{passive:!1});const ne=cg({zoomPanValues:d,onDraggingChange:l,onPanZoomStart:i});p.on("start",ne);const ie=lg({zoomPanValues:d,panOnDrag:D,onPaneContextMenu:!!S,onPanZoom:r,onTransformChange:z});p.on("zoom",ie);const ce=dg({zoomPanValues:d,panOnDrag:D,panOnScroll:M,onPaneContextMenu:S,onPanZoomEnd:c,onDraggingChange:l});p.on("end",ce);const pe=ug({panActivationKeyPressed:Y,zoomActivationKeyPressed:Q,panOnDrag:D,zoomOnScroll:O,panOnScroll:M,zoomOnDoubleClick:B,zoomOnPinch:F,userSelectionActive:_,noPanClassName:b,noWheelClassName:A,lib:G,connectionInProgress:Z});p.filter(pe),B?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function g(){p.on("zoom",null)}async function v(A,b,S){const _=bs(A),M=p?.constrain()(_,b,S);return M&&await y(M),M}async function E(A,b){const S=bs(A);return await y(S,b),S}function k(A){if(m){const b=bs(A),S=m.property("__zoom");(S.k!==A.zoom||S.x!==A.x||S.y!==A.y)&&p?.transform(m,b,null,{sync:!0})}}function C(){const A=m?Ia(m.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}async function I(A,b){return m?new Promise(S=>{p?.interpolate(b?.interpolate==="linear"?Bt:En).scaleTo(Ns(m,b?.duration,b?.ease,()=>S(!0)),A)}):!1}async function R(A,b){return m?new Promise(S=>{p?.interpolate(b?.interpolate==="linear"?Bt:En).scaleBy(Ns(m,b?.duration,b?.ease,()=>S(!0)),A)}):!1}function V(A){p?.scaleExtent(A)}function T(A){p?.translateExtent(A)}function $(A){const b=!Ae(A)||A<0?0:A;p?.clickDistance(b)}return{update:j,destroy:g,setViewport:E,setViewportConstrained:v,getViewport:C,scaleTo:I,scaleBy:R,setScaleExtent:V,setTranslateExtent:T,syncViewport:k,setClickDistance:$}}var It;(function(e){e.Line="line",e.Handle="handle"})(It||(It={}));function hg({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:o,affectsY:r}){const i=e-t,c=n-s,l=[i>0?1:i<0?-1:0,c>0?1:c<0?-1:0];return i&&o&&(l[0]=l[0]*-1),c&&r&&(l[1]=l[1]*-1),l}function zr(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 Ue(e,t){return Math.max(0,t-e)}function Ke(e,t){return Math.max(0,e-t)}function vn(e,t,n){return Math.max(0,t-e,e-n)}function Lr(e,t){return e?!t:t}function pg(e,t,n,s,o,r,i,c){let{affectsX:l,affectsY:d}=t;const{isHorizontal:u,isVertical:h}=t,f=u&&h,{xSnapped:p,ySnapped:m}=n,{minWidth:w,maxWidth:x,minHeight:y,maxHeight:j}=s,{x:g,y:v,width:E,height:k,aspectRatio:C}=e;let I=Math.floor(u?p-e.pointerX:0),R=Math.floor(h?m-e.pointerY:0);const V=E+(l?-I:I),T=k+(d?-R:R),$=-r[0]*E,A=-r[1]*k;let b=vn(V,w,x),S=vn(T,y,j);if(i){let D=0,P=0;l&&I<0?D=Ue(g+I+$,i[0][0]):!l&&I>0&&(D=Ke(g+V+$,i[1][0])),d&&R<0?P=Ue(v+R+A,i[0][1]):!d&&R>0&&(P=Ke(v+T+A,i[1][1])),b=Math.max(b,D),S=Math.max(S,P)}if(c){let D=0,P=0;l&&I>0?D=Ke(g+I,c[0][0]):!l&&I<0&&(D=Ue(g+V,c[1][0])),d&&R>0?P=Ke(v+R,c[0][1]):!d&&R<0&&(P=Ue(v+T,c[1][1])),b=Math.max(b,D),S=Math.max(S,P)}if(o){if(u){const D=vn(V/C,y,j)*C;if(b=Math.max(b,D),i){let P=0;!l&&!d||l&&!d&&f?P=Ke(v+A+V/C,i[1][1])*C:P=Ue(v+A+(l?I:-I)/C,i[0][1])*C,b=Math.max(b,P)}if(c){let P=0;!l&&!d||l&&!d&&f?P=Ue(v+V/C,c[1][1])*C:P=Ke(v+(l?I:-I)/C,c[0][1])*C,b=Math.max(b,P)}}if(h){const D=vn(T*C,w,x)/C;if(S=Math.max(S,D),i){let P=0;!l&&!d||d&&!l&&f?P=Ke(g+T*C+$,i[1][0])/C:P=Ue(g+(d?R:-R)*C+$,i[0][0])/C,S=Math.max(S,P)}if(c){let P=0;!l&&!d||d&&!l&&f?P=Ue(g+T*C,c[1][0])/C:P=Ke(g+(d?R:-R)*C,c[0][0])/C,S=Math.max(S,P)}}}R=R+(R<0?S:-S),I=I+(I<0?b:-b),o&&(f?V>T*C?R=(Lr(l,d)?-I:I)/C:I=(Lr(l,d)?-R:R)*C:u?(R=I/C,d=l):(I=R*C,l=d));const _=l?g+I:g,M=d?v+R:v;return{width:E+(l?-I:I),height:k+(d?-R:R),x:r[0]*I*(l?-1:1)+_,y:r[1]*R*(d?-1:1)+M}}const ic={width:0,height:0,x:0,y:0},mg={...ic,pointerX:0,pointerY:0,aspectRatio:1};function gg(e,t,n){const s=t.position.x+e.position.x,o=t.position.y+e.position.y,r=e.measured.width??0,i=e.measured.height??0,c=n[0]*r,l=n[1]*i;return[[s-c,o-l],[s+r-c,o+i-l]]}function xg({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:o}){const r=ke(e);let i={controlDirection:zr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:d,boundaries:u,keepAspectRatio:h,resizeDirection:f,onResizeStart:p,onResize:m,onResizeEnd:w,shouldResize:x}){let y={...ic},j={...mg};i={boundaries:u,resizeDirection:f,keepAspectRatio:h,controlDirection:zr(d)};let g,v=null,E=[],k,C,I,R=!1;const V=ga().on("start",T=>{const{nodeLookup:$,transform:A,snapGrid:b,snapToGrid:S,nodeOrigin:_,paneDomNode:M}=n();if(g=$.get(t),!g)return;v=M?.getBoundingClientRect()??null;const{xSnapped:D,ySnapped:P}=Wt(T.sourceEvent,{transform:A,snapGrid:b,snapToGrid:S,containerBounds:v});y={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},j={...y,pointerX:D,pointerY:P,aspectRatio:y.width/y.height},k=void 0,C=ht(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(k=$.get(g.parentId)),k&&g.extent==="parent"&&(C=[[0,0],[k.measured.width,k.measured.height]]),E=[],I=void 0;for(const[L,H]of $)if(H.parentId===t&&(E.push({id:L,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const F=gg(H,g,H.origin??_);I?I=[[Math.min(F[0][0],I[0][0]),Math.min(F[0][1],I[0][1])],[Math.max(F[1][0],I[1][0]),Math.max(F[1][1],I[1][1])]]:I=F}p?.(T,{...y})}).on("drag",T=>{const{transform:$,snapGrid:A,snapToGrid:b,nodeOrigin:S}=n(),_=Wt(T.sourceEvent,{transform:$,snapGrid:A,snapToGrid:b,containerBounds:v}),M=[];if(!g)return;const{x:D,y:P,width:L,height:H}=y,F={},O=g.origin??S,{width:B,height:Y,x:Q,y:G}=pg(j,i.controlDirection,_,i.boundaries,i.keepAspectRatio,O,C,I),z=B!==L,Z=Y!==H,te=Q!==D&&z,ee=G!==P&&Z;if(!te&&!ee&&!z&&!Z)return;if((te||ee||O[0]===1||O[1]===1)&&(F.x=te?Q:y.x,F.y=ee?G:y.y,y.x=F.x,y.y=F.y,E.length>0)){const ie=Q-D,ce=G-P;for(const pe of E)pe.position={x:pe.position.x-ie+O[0]*(B-L),y:pe.position.y-ce+O[1]*(Y-H)},M.push(pe)}if((z||Z)&&(F.width=z&&(!i.resizeDirection||i.resizeDirection==="horizontal")?B:y.width,F.height=Z&&(!i.resizeDirection||i.resizeDirection==="vertical")?Y:y.height,y.width=F.width,y.height=F.height),k&&g.expandParent){const ie=O[0]*(F.width??0);F.x&&F.x<ie&&(y.x=ie,j.x=j.x-(F.x-ie));const ce=O[1]*(F.height??0);F.y&&F.y<ce&&(y.y=ce,j.y=j.y-(F.y-ce))}const U=hg({width:y.width,prevWidth:L,height:y.height,prevHeight:H,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),K={...y,direction:U};x?.(T,K)!==!1&&(R=!0,m?.(T,K),s(F,M))}).on("end",T=>{R&&(w?.(T,{...y}),o?.({...y}),R=!1)});r.call(V)}function l(){r.on(".drag",null)}return{update:c,destroy:l}}var js={exports:{}},ks={},Es={exports:{}},Cs={};var Hr;function yg(){if(Hr)return Cs;Hr=1;var e=Li();function t(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,o=e.useEffect,r=e.useLayoutEffect,i=e.useDebugValue;function c(h,f){var p=f(),m=s({inst:{value:p,getSnapshot:f}}),w=m[0].inst,x=m[1];return r(function(){w.value=p,w.getSnapshot=f,l(w)&&x({inst:w})},[h,p,f]),o(function(){return l(w)&&x({inst:w}),h(function(){l(w)&&x({inst:w})})},[h]),i(p),p}function l(h){var f=h.getSnapshot;h=h.value;try{var p=f();return!n(h,p)}catch{return!0}}function d(h,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:c;return Cs.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Cs}var Vr;function wg(){return Vr||(Vr=1,Es.exports=yg()),Es.exports}var Fr;function vg(){if(Fr)return ks;Fr=1;var e=Li(),t=wg();function n(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var s=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,r=e.useRef,i=e.useEffect,c=e.useMemo,l=e.useDebugValue;return ks.useSyncExternalStoreWithSelector=function(d,u,h,f,p){var m=r(null);if(m.current===null){var w={hasValue:!1,value:null};m.current=w}else w=m.current;m=c(function(){function y(k){if(!j){if(j=!0,g=k,k=f(k),p!==void 0&&w.hasValue){var C=w.value;if(p(C,k))return v=C}return v=k}if(C=v,s(g,k))return C;var I=f(k);return p!==void 0&&p(C,I)?(g=k,C):(g=k,v=I)}var j=!1,g,v,E=h===void 0?null:h;return[function(){return y(u())},E===null?void 0:function(){return y(E())}]},[u,h,f,p]);var x=o(d,m[0],m[1]);return i(function(){w.hasValue=!0,w.value=x},[x]),l(x),x},ks}var Br;function bg(){return Br||(Br=1,js.exports=vg()),js.exports}var Ng=bg();const jg=Td(Ng),kg={},Wr=e=>{let t;const n=new Set,s=(u,h)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const p=t;t=h??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(m=>m(t,p))}},o=()=>t,l={setState:s,getState:o,getInitialState:()=>d,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(kg?"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()}},d=t=e(s,o,l);return l},Eg=e=>e?Wr(e):Wr,{useDebugValue:Cg}=Od,{useSyncExternalStoreWithSelector:Sg}=jg,_g=e=>e;function ac(e,t=_g,n){const s=Sg(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Cg(s),s}const Yr=(e,t)=>{const n=Eg(e),s=(o,r=t)=>ac(n,o,r);return Object.assign(s,n),s},Mg=(e,t)=>e?Yr(e,t):Yr;function ue(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 cs=N.createContext(null),Ig=cs.Provider,cc=Te.error001("react");function re(e,t){const n=N.useContext(cs);if(n===null)throw new Error(cc);return ac(n,e,t)}function le(){const e=N.useContext(cs);if(e===null)throw new Error(cc);return N.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Xr={display:"none"},$g={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},lc="react-flow__node-desc",dc="react-flow__edge-desc",Rg="react-flow__aria-live",Ag=e=>e.ariaLiveMessage,Dg=e=>e.ariaLabelConfig;function Pg({rfId:e}){const t=re(Ag);return a.jsx("div",{id:`${Rg}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:$g,children:t})}function Tg({rfId:e,disableKeyboardA11y:t}){const n=re(Dg);return a.jsxs(a.Fragment,{children:[a.jsx("div",{id:`${lc}-${e}`,style:Xr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),a.jsx("div",{id:`${dc}-${e}`,style:Xr,children:n["edge.a11yDescription.default"]}),!t&&a.jsx(Pg,{rfId:e})]})}const tt=N.forwardRef(({position:e="top-left",children:t,className:n,style:s,...o},r)=>{const i=`${e}`.split("-");return a.jsx("div",{className:me(["react-flow__panel",n,...i]),style:s,ref:r,...o,children:t})});tt.displayName="Panel";const qr="https://reactflow.dev?utm_source=attribution";function Og({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:a.jsx(tt,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${qr}`,children:a.jsx("a",{href:qr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const zg=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}},bn=e=>e.id;function Lg(e,t){return ue(e.selectedNodes.map(bn),t.selectedNodes.map(bn))&&ue(e.selectedEdges.map(bn),t.selectedEdges.map(bn))}function Hg({onSelectionChange:e}){const t=le(),{selectedNodes:n,selectedEdges:s}=re(zg,Lg);return N.useEffect(()=>{const o={nodes:n,edges:s};e?.(o),t.getState().onSelectionChangeHandlers.forEach(r=>r(o))},[n,s,e]),null}const Vg=e=>!!e.onSelectionChangeHandlers;function Fg({onSelectionChange:e}){const t=re(Vg);return e||t?a.jsx(Hg,{onSelectionChange:e}):null}const uc=[0,0],Bg={x:0,y:0,zoom:1},Wg=["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"],Zr=[...Wg,"rfId"],Yg=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}),Gr={translateExtent:Gt,nodeOrigin:uc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Xg(e){const{setNodes:t,setEdges:n,setMinZoom:s,setMaxZoom:o,setTranslateExtent:r,setNodeExtent:i,reset:c,setDefaultNodesAndEdges:l}=re(Yg,ue),d=le();N.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{u.current=Gr,c()}),[]);const u=N.useRef(Gr);return N.useEffect(()=>{for(const h of Zr){const f=e[h],p=u.current[h];f!==p&&(typeof e[h]>"u"||(h==="nodes"?t(f):h==="edges"?n(f):h==="minZoom"?s(f):h==="maxZoom"?o(f):h==="translateExtent"?r(f):h==="nodeExtent"?i(f):h==="ariaLabelConfig"?d.setState({ariaLabelConfig:Im(f)}):h==="fitView"?d.setState({fitViewQueued:f}):h==="fitViewOptions"?d.setState({fitViewOptions:f}):d.setState({[h]:f})))}u.current=e},Zr.map(h=>e[h])),null}function Ur(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function qg(e){const[t,n]=N.useState(e==="system"?null:e);return N.useEffect(()=>{if(e!=="system"){n(e);return}const s=Ur(),o=()=>n(s?.matches?"dark":"light");return o(),s?.addEventListener("change",o),()=>{s?.removeEventListener("change",o)}},[e]),t!==null?t:Ur()?.matches?"dark":"light"}const Kr=typeof document<"u"?document:null;function Jt(e=null,t={target:Kr,actInsideInputWithModifier:!0}){const[n,s]=N.useState(!1),o=N.useRef(!1),r=N.useRef(new Set([])),[i,c]=N.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(h=>typeof h=="string").map(h=>h.replace(/\+/g,`
3
3
  `).replace(`
4
4
 
5
5
  `,`
6
6
  +`).split(`
7
- `)),u=d.reduce((h,f)=>h.concat(...f),[]);return[d,u]}return[[],[]]},[e]);return N.useEffect(()=>{const l=t?.target??Kr,d=t?.actInsideInputWithModifier??!0;if(e!==null){const u=p=>{if(o.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!o.current||o.current&&!d)&&Ya(p))return!1;const w=Jr(p.code,c);if(r.current.add(p[w]),Qr(i,r.current,!1)){const x=p.composedPath?.()?.[0]||p.target,y=x?.nodeName==="BUTTON"||x?.nodeName==="A";t.preventDefault!==!1&&(o.current||!y)&&p.preventDefault(),s(!0)}},h=p=>{const m=Jr(p.code,c);Qr(i,r.current,!0)?(s(!1),r.current.clear()):r.current.delete(p[m]),p.key==="Meta"&&r.current.clear(),o.current=!1},f=()=>{r.current.clear(),s(!1)};return l?.addEventListener("keydown",u),l?.addEventListener("keyup",h),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{l?.removeEventListener("keydown",u),l?.removeEventListener("keyup",h),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,s]),n}function Qr(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 Zg=()=>{const e=le();return N.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[s,o,r],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??s,y:t.y??o,zoom:t.zoom??r},n),!0):!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:r,maxZoom:i,panZoom:c}=e.getState(),l=Eo(t,s,o,r,i,n?.padding??.1);return c?(await c.setViewport(l,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:s,snapGrid:o,snapToGrid:r,domNode:i}=e.getState();if(!i)return t;const{x:c,y:l}=i.getBoundingClientRect(),d={x:t.x-c,y:t.y-l},u=n.snapGrid??o,h=n.snapToGrid??r;return un(d,s,h,u)},flowToScreenPosition:t=>{const{transform:n,domNode:s}=e.getState();if(!s)return t;const{x:o,y:r}=s.getBoundingClientRect(),i=Mt(t,n);return{x:i.x+o,y:i.y+r}}}),[])};function fc(e,t){const n=[],s=new Map,o=[];for(const r of e)if(r.type==="add"){o.push(r);continue}else if(r.type==="remove"||r.type==="replace")s.set(r.id,[r]);else{const i=s.get(r.id);i?i.push(r):s.set(r.id,[r])}for(const r of t){const i=s.get(r.id);if(!i){n.push(r);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const c={...r};for(const l of i)Gg(l,c);n.push(c)}return o.length&&o.forEach(r=>{r.index!==void 0?n.splice(r.index,0,{...r.item}):n.push({...r.item})}),n}function Gg(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 ls(e,t){return fc(e,t)}function ds(e,t){return fc(e,t)}function nt(e,t){return{id:e,type:"select",selected:t}}function vt(e,t=new Set,n=!1){const s=[];for(const[o,r]of e){const i=t.has(o);!(r.selected===void 0&&!i)&&r.selected!==i&&(n&&(r.selected=i),s.push(nt(r.id,i)))}return s}function ei({items:e=[],lookup:t}){const n=[],s=new Map(e.map(o=>[o.id,o]));for(const[o,r]of e.entries()){const i=t.get(r.id),c=i?.internals?.userNode??i;c!==void 0&&c!==r&&n.push({id:r.id,item:r,type:"replace"}),c===void 0&&n.push({item:r,type:"add",index:o})}for(const[o]of t)s.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function ti(e){return{id:e.id,type:"remove"}}const Ug=Va();function Kg(e,t,n={}){return Tm(e,t,{...n,onError:n.onError??Ug})}const ni=e=>bm(e),Qg=e=>Ta(e);function hc(e){return N.forwardRef(e)}const pc=typeof window<"u"?N.useLayoutEffect:N.useEffect;function si(e){const[t,n]=N.useState(BigInt(0)),[s]=N.useState(()=>Jg(()=>n(o=>o+BigInt(1))));return pc(()=>{const o=s.get();o.length&&(e(o),s.reset())},[t]),s}function Jg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const mc=N.createContext(null);function ex({children:e}){const t=le(),n=N.useCallback(c=>{const{nodes:l=[],setNodes:d,hasDefaultNodes:u,onNodesChange:h,nodeLookup:f,fitViewQueued:p,onNodesChangeMiddlewareMap:m}=t.getState();let w=l;for(const y of c)w=typeof y=="function"?y(w):y;let x=ei({items:w,lookup:f});for(const y of m.values())x=y(x);u&&d(w),x.length>0?h?.(x):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:j,setNodes:g}=t.getState();y&&g(j)})},[]),s=si(n),o=N.useCallback(c=>{const{edges:l=[],setEdges:d,hasDefaultEdges:u,onEdgesChange:h,edgeLookup:f}=t.getState();let p=l;for(const m of c)p=typeof m=="function"?m(p):m;u?d(p):h&&h(ei({items:p,lookup:f}))},[]),r=si(o),i=N.useMemo(()=>({nodeQueue:s,edgeQueue:r}),[]);return a.jsx(mc.Provider,{value:i,children:e})}function tx(){const e=N.useContext(mc);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const nx=e=>!!e.panZoom;function Pt(){const e=Zg(),t=le(),n=tx(),s=re(nx),o=N.useMemo(()=>{const r=h=>t.getState().nodeLookup.get(h),i=h=>{n.nodeQueue.push(h)},c=h=>{n.edgeQueue.push(h)},l=h=>{const{nodeLookup:f,nodeOrigin:p}=t.getState(),m=ni(h)?h:f.get(h.id),w=m.parentId?Ba(m.position,m.measured,m.parentId,f,p):m.position,x={...m,position:w,width:m.measured?.width??m.width,height:m.measured?.height??m.height};return Kt(x)},d=(h,f,p={replace:!1})=>{i(m=>m.map(w=>{if(w.id===h){const x=typeof f=="function"?f(w):f;return p.replace&&ni(x)?x:{...w,...x}}return w}))},u=(h,f,p={replace:!1})=>{c(m=>m.map(w=>{if(w.id===h){const x=typeof f=="function"?f(w):f;return p.replace&&Qg(x)?x:{...w,...x}}return w}))};return{getNodes:()=>t.getState().nodes.map(h=>({...h})),getNode:h=>r(h)?.internals.userNode,getInternalNode:r,getEdges:()=>{const{edges:h=[]}=t.getState();return h.map(f=>({...f}))},getEdge:h=>t.getState().edgeLookup.get(h),setNodes:i,setEdges:c,addNodes:h=>{const f=Array.isArray(h)?h:[h];n.nodeQueue.push(p=>[...p,...f])},addEdges:h=>{const f=Array.isArray(h)?h:[h];n.edgeQueue.push(p=>[...p,...f])},toObject:()=>{const{nodes:h=[],edges:f=[],transform:p}=t.getState(),[m,w,x]=p;return{nodes:h.map(y=>({...y})),edges:f.map(y=>({...y})),viewport:{x:m,y:w,zoom:x}}},deleteElements:async({nodes:h=[],edges:f=[]})=>{const{nodes:p,edges:m,onNodesDelete:w,onEdgesDelete:x,triggerNodeChanges:y,triggerEdgeChanges:j,onDelete:g,onBeforeDelete:v}=t.getState(),{nodes:E,edges:k}=await Cm({nodesToRemove:h,edgesToRemove:f,nodes:p,edges:m,onBeforeDelete:v}),C=k.length>0,I=E.length>0;if(C){const R=k.map(ti);x?.(k),j(R)}if(I){const R=E.map(ti);w?.(E),y(R)}return(I||C)&&g?.({nodes:E,edges:k}),{deletedNodes:E,deletedEdges:k}},getIntersectingNodes:(h,f=!0,p)=>{const m=Sr(h),w=m?h:l(h),x=p!==void 0;return w?(p||t.getState().nodes).filter(y=>{const j=t.getState().nodeLookup.get(y.id);if(j&&!m&&(y.id===h.id||!j.internals.positionAbsolute))return!1;const g=Kt(x?y:j),v=Ln(g,w);return f&&v>0||v>=g.width*g.height||v>=w.width*w.height}):[]},isNodeIntersecting:(h,f,p=!0)=>{const w=Sr(h)?h:l(h);if(!w)return!1;const x=Ln(w,f);return p&&x>0||x>=f.width*f.height||x>=w.width*w.height},updateNode:d,updateNodeData:(h,f,p={replace:!1})=>{d(h,m=>{const w=typeof f=="function"?f(m):f;return p.replace?{...m,data:w}:{...m,data:{...m.data,...w}}},p)},updateEdge:u,updateEdgeData:(h,f,p={replace:!1})=>{u(h,m=>{const w=typeof f=="function"?f(m):f;return p.replace?{...m,data:w}:{...m,data:{...m.data,...w}}},p)},getNodesBounds:h=>{const{nodeLookup:f,nodeOrigin:p}=t.getState();return Nm(h,{nodeLookup:f,nodeOrigin:p})},getHandleConnections:({type:h,id:f,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}-${h}${f?`-${f}`:""}`)?.values()??[]),getNodeConnections:({type:h,handleId:f,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}${h?f?`-${h}-${f}`:`-${h}`:""}`)?.values()??[]),fitView:async h=>{const f=t.getState().fitViewResolver??Mm();return t.setState({fitViewQueued:!0,fitViewOptions:h,fitViewResolver:f}),n.nodeQueue.push(p=>[...p]),f.promise}}},[]);return N.useMemo(()=>({...o,...e,viewportInitialized:s}),[s])}const oi=e=>e.selected,sx=typeof window<"u"?window:void 0;function ox({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=le(),{deleteElements:s}=Pt(),o=Jt(e,{actInsideInputWithModifier:!1}),r=Jt(t,{target:sx});N.useEffect(()=>{if(o){const{edges:i,nodes:c}=n.getState();s({nodes:c.filter(oi),edges:i.filter(oi)}),n.setState({nodesSelectionActive:!1})}},[o]),N.useEffect(()=>{n.setState({multiSelectionActive:r})},[r])}function rx(e){const t=le();N.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const s=Co(e.current);(s.height===0||s.width===0)&&t.getState().onError?.("004",Te.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 us={position:"absolute",width:"100%",height:"100%",top:0,left:0},ix=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function ax({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:s=!1,panActivationKeyPressed:o,panOnScrollSpeed:r=.5,panOnScrollMode:i=at.Free,zoomOnDoubleClick:c=!0,panOnDrag:l=!0,defaultViewport:d,translateExtent:u,minZoom:h,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:w,noWheelClassName:x,noPanClassName:y,onViewportChange:j,isControlledViewport:g,paneClickDistance:v,selectionOnDrag:E}){const k=le(),C=N.useRef(null),{userSelectionActive:I,lib:R,connectionInProgress:H}=re(ix,ue),T=Jt(p),$=N.useRef();rx(C);const A=N.useCallback(b=>{j?.({x:b[0],y:b[1],zoom:b[2]}),g||k.setState({transform:b})},[j,g]);return N.useEffect(()=>{if(C.current){$.current=fg({domNode:C.current,minZoom:h,maxZoom:f,translateExtent:u,viewport:d,onDraggingChange:M=>k.setState(D=>D.paneDragging===M?D:{paneDragging:M}),onPanZoomStart:(M,D)=>{const{onViewportChangeStart:P,onMoveStart:L}=k.getState();L?.(M,D),P?.(D)},onPanZoom:(M,D)=>{const{onViewportChange:P,onMove:L}=k.getState();L?.(M,D),P?.(D)},onPanZoomEnd:(M,D)=>{const{onViewportChangeEnd:P,onMoveEnd:L}=k.getState();L?.(M,D),P?.(D)}});const{x:b,y:S,zoom:_}=$.current.getViewport();return k.setState({panZoom:$.current,transform:[b,S,_],domNode:C.current.closest(".react-flow")}),()=>{$.current?.destroy()}}},[]),N.useEffect(()=>{$.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:s,panActivationKeyPressed:o,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:c,panOnDrag:l,zoomActivationKeyPressed:T,preventScrolling:m,noPanClassName:y,userSelectionActive:I,noWheelClassName:x,lib:R,onTransformChange:A,connectionInProgress:H,selectionOnDrag:E,paneClickDistance:v})},[e,t,n,s,o,r,i,c,l,T,m,y,I,x,R,A,H,E,v]),a.jsx("div",{className:"react-flow__renderer",ref:C,style:us,children:w})}const cx=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function lx(){const{userSelectionActive:e,userSelectionRect:t}=re(cx,ue);return e&&t?a.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 Ss=(e,t)=>n=>{n.target===t.current&&e?.(n)},dx=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function ux({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Ut.Full,panOnDrag:s,autoPanOnSelection:o,paneClickDistance:r,selectionOnDrag:i,onSelectionStart:c,onSelectionEnd:l,onPaneClick:d,onPaneContextMenu:u,onPaneScroll:h,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:w}){const x=N.useRef(0),y=le(),{userSelectionActive:j,elementsSelectable:g,dragging:v,panBy:E,autoPanSpeed:k}=re(dx,ue),C=g&&(e||j),I=N.useRef(null),R=N.useRef(),H=N.useRef(new Set),T=N.useRef(new Set),$=N.useRef(!1),A=N.useRef(!1),b=N.useRef({x:0,y:0}),S=N.useRef(!1),_=z=>{if(A.current||$.current||y.getState().connection.inProgress){A.current=!1,$.current=!1;return}d?.(z),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},M=z=>{if(Array.isArray(s)&&s?.includes(2)){z.preventDefault();return}u?.(z)},D=h?z=>h(z):void 0,P=z=>{A.current&&(z.stopPropagation(),A.current=!1)},L=z=>{if(z.pointerType==="touch"&&s!==!1&&!t)return;const{domNode:Z,transform:te}=y.getState();if(R.current=Z?.getBoundingClientRect(),!R.current)return;const ee=z.target===I.current;if(!ee&&!!z.target.closest(".nokey")||!e||!(i&&ee||t)||z.button!==0||!z.isPrimary)return;z.target?.setPointerCapture?.(z.pointerId),A.current=!1;const{x:ne,y:ie}=De(z.nativeEvent,R.current),ce=un({x:ne,y:ie},te);y.setState({userSelectionRect:{width:0,height:0,startX:ce.x,startY:ce.y,x:ne,y:ie}}),ee||(z.stopPropagation(),z.preventDefault())};function V(z,Z){const{userSelectionRect:te}=y.getState();if(!te)return;const{transform:ee,nodeLookup:U,edgeLookup:K,connectionLookup:ne,triggerNodeChanges:ie,triggerEdgeChanges:ce,defaultEdgeOptions:pe}=y.getState(),Ne={x:te.startX,y:te.startY},{x:Ce,y:Se}=Mt(Ne,ee),Y={startX:Ne.x,startY:Ne.y,x:z<Ce?z:Ce,y:Z<Se?Z:Se,width:Math.abs(z-Ce),height:Math.abs(Z-Se)},J=H.current,oe=T.current;H.current=new Set(jo(U,Y,ee,n===Ut.Partial,!0).map(se=>se.id)),T.current=new Set;const he=pe?.selectable??!0;for(const se of H.current){const fe=ne.get(se);if(fe)for(const{edgeId:de}of fe.values()){const je=K.get(de);je&&(je.selectable??he)&&T.current.add(de)}}if(!_r(J,H.current)){const se=vt(U,H.current,!0);ie(se)}if(!_r(oe,T.current)){const se=vt(K,T.current);ce(se)}y.setState({userSelectionRect:Y,userSelectionActive:!0,nodesSelectionActive:!1})}function F(){if(!o||!R.current)return;const[z,Z]=ko(b.current,R.current,k);E({x:z,y:Z}).then(te=>{if(!A.current||!te){x.current=requestAnimationFrame(F);return}const{x:ee,y:U}=b.current;V(ee,U),x.current=requestAnimationFrame(F)})}const O=()=>{cancelAnimationFrame(x.current),x.current=0,S.current=!1};N.useEffect(()=>()=>O(),[]);const B=z=>{const{userSelectionRect:Z,transform:te,resetSelectedElements:ee}=y.getState();if(!R.current||!Z)return;const{x:U,y:K}=De(z.nativeEvent,R.current);b.current={x:U,y:K};const ne=Mt({x:Z.startX,y:Z.startY},te);if(!A.current){const ie=t?0:r;if(Math.hypot(U-ne.x,K-ne.y)<=ie)return;ee(),c?.(z)}A.current=!0,S.current||(F(),S.current=!0),V(U,K)},W=z=>{if(!C){z.target===I.current&&y.getState().connection.inProgress&&($.current=!0);return}z.button===0&&(z.target?.releasePointerCapture?.(z.pointerId),!j&&z.target===I.current&&y.getState().userSelectionRect&&_?.(z),y.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(l?.(z),y.setState({nodesSelectionActive:H.current.size>0})),O())},Q=z=>{z.target?.releasePointerCapture?.(z.pointerId),O()},G=s===!0||Array.isArray(s)&&s.includes(0);return a.jsxs("div",{className:me(["react-flow__pane",{draggable:G,dragging:v,selection:e}]),onClick:C?void 0:Ss(_,I),onContextMenu:Ss(M,I),onWheel:Ss(D,I),onPointerEnter:C?void 0:f,onPointerMove:C?B:p,onPointerUp:W,onPointerCancel:C?Q:void 0,onPointerDownCapture:C?L:void 0,onClickCapture:C?P:void 0,onPointerLeave:m,ref:I,style:us,children:[w,a.jsx(lx,{})]})}function Ws({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:r,multiSelectionActive:i,nodeLookup:c,onError:l}=t.getState(),d=c.get(e);if(!d){l?.("012",Te.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(r({nodes:[d],edges:[]}),requestAnimationFrame(()=>s?.current?.blur())):o([e])}function gc({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:o,isSelectable:r,nodeClickDistance:i}){const c=le(),[l,d]=N.useState(!1),u=N.useRef();return N.useEffect(()=>{if(!t)return u.current=Qm({getStoreItems:()=>c.getState(),onNodeMouseDown:h=>{Ws({id:h,store:c,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,c,e]),N.useEffect(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:s,domNode:e.current,isSelectable:r,nodeId:o,nodeClickDistance:i})},[n,s,t,r,e,o,i]),l}const fx=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function xc(){const e=le();return N.useCallback(n=>{const{nodeExtent:s,snapToGrid:o,snapGrid:r,nodesDraggable:i,onError:c,updateNodePositions:l,nodeLookup:d,nodeOrigin:u}=e.getState(),h=new Map,f=fx(i),p=o?r[0]:5,m=o?r[1]:5,w=n.direction.x*p*n.factor,x=n.direction.y*m*n.factor;for(const[,y]of d){if(!f(y))continue;let j={x:y.internals.positionAbsolute.x+w,y:y.internals.positionAbsolute.y+x};o&&(j=dn(j,r));const{position:g,positionAbsolute:v}=Oa({nodeId:y.id,nextPosition:j,nodeLookup:d,nodeExtent:s,nodeOrigin:u,onError:c});y.position=g,y.internals.positionAbsolute=v,h.set(y.id,y)}l(h)},[])}const Ao=N.createContext(null),hx=Ao.Provider;Ao.Consumer;const yc=()=>N.useContext(Ao),px=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),wc=N.createContext(null);function mx({children:e}){const t=re(px,ue);return a.jsx(wc.Provider,{value:t,children:e})}function gx(){const e=N.useContext(wc);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const xx={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},yx=(e,t,n)=>s=>{const{connectionClickStartHandle:o,connectionMode:r,connection:i}=s,{fromHandle:c,toHandle:l,isValid:d}=i;if(!c&&!o)return xx;const u=l?.nodeId===e&&l?.id===t&&l?.type===n;return{connectingFrom:c?.nodeId===e&&c?.id===t&&c?.type===n,connectingTo:u,clickConnecting:o?.nodeId===e&&o?.id===t&&o?.type===n,isPossibleEndHandle:r===St.Strict?c?.type!==n:e!==c?.nodeId||t!==c?.id,connectionInProcess:!!c,clickConnectionInProcess:!!o,valid:u&&d}};function wx({type:e="source",position:t=q.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:r=!0,id:i,onConnect:c,children:l,className:d,onMouseDown:u,onTouchStart:h,...f},p){const m=i||null,w=e==="target",x=le(),y=yc(),{connectOnClick:j,noPanClassName:g,rfId:v}=gx(),{connectingFrom:E,connectingTo:k,clickConnecting:C,isPossibleEndHandle:I,connectionInProcess:R,clickConnectionInProcess:H,valid:T}=re(yx(y,m,e),ue);y||x.getState().onError?.("010",Te.error010());const $=S=>{const{defaultEdgeOptions:_,onConnect:M,hasDefaultEdges:D}=x.getState(),P={..._,...S};if(D){const{edges:L,setEdges:V,onError:F}=x.getState();V(Kg(P,L,{onError:F}))}M?.(P),c?.(P)},A=S=>{if(!y)return;const _=Xa(S.nativeEvent);if(o&&(_&&S.button===0||!_)){const M=x.getState();Bs.onPointerDown(S.nativeEvent,{handleDomNode:S.currentTarget,autoPanOnConnect:M.autoPanOnConnect,connectionMode:M.connectionMode,connectionRadius:M.connectionRadius,domNode:M.domNode,nodeLookup:M.nodeLookup,lib:M.lib,isTarget:w,handleId:m,nodeId:y,flowId:M.rfId,panBy:M.panBy,cancelConnection:M.cancelConnection,onConnectStart:M.onConnectStart,onConnectEnd:(...D)=>x.getState().onConnectEnd?.(...D),updateConnection:M.updateConnection,onConnect:$,isValidConnection:n||((...D)=>x.getState().isValidConnection?.(...D)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:M.autoPanSpeed,dragThreshold:M.connectionDragThreshold})}_?u?.(S):h?.(S)},b=S=>{const{onClickConnectStart:_,onClickConnectEnd:M,connectionClickStartHandle:D,connectionMode:P,isValidConnection:L,lib:V,rfId:F,nodeLookup:O,connection:B}=x.getState();if(!y||!D&&!o)return;if(!D){_?.(S.nativeEvent,{nodeId:y,handleId:m,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,id:m}});return}const W=Wa(S.target),Q=n||L,{connection:G,isValid:z}=Bs.isValid(S.nativeEvent,{handle:{nodeId:y,id:m,type:e},connectionMode:P,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:Q,flowId:F,doc:W,lib:V,nodeLookup:O});z&&G&&$(G);const Z=structuredClone(B);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,M?.(S,Z),x.setState({connectionClickStartHandle:null})};return a.jsx("div",{"data-handleid":m,"data-nodeid":y,"data-handlepos":t,"data-id":`${v}-${y}-${m}-${e}`,className:me(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,d,{source:!w,target:w,connectable:s,connectablestart:o,connectableend:r,clickconnecting:C,connectingfrom:E,connectingto:k,valid:T,connectionindicator:s&&(!R||I)&&(R||H?r:o)}]),onMouseDown:A,onTouchStart:A,onClick:j?b:void 0,ref:p,...f,children:l})}const Ie=N.memo(hc(wx));function vx({data:e,isConnectable:t,sourcePosition:n=q.Bottom}){return a.jsxs(a.Fragment,{children:[e?.label,a.jsx(Ie,{type:"source",position:n,isConnectable:t})]})}function bx({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:s=q.Bottom}){return a.jsxs(a.Fragment,{children:[a.jsx(Ie,{type:"target",position:n,isConnectable:t}),e?.label,a.jsx(Ie,{type:"source",position:s,isConnectable:t})]})}function Nx(){return null}function jx({data:e,isConnectable:t,targetPosition:n=q.Top}){return a.jsxs(a.Fragment,{children:[a.jsx(Ie,{type:"target",position:n,isConnectable:t}),e?.label]})}const Vn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ri={input:vx,default:bx,output:jx,group:Nx};function kx(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const Ex=e=>{const{width:t,height:n,x:s,y:o}=ln(e.nodeLookup,{filter:r=>!!r.selected});return{width:Ae(t)?t:null,height:Ae(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 Cx({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=le(),{width:o,height:r,transformString:i,userSelectionActive:c}=re(Ex,ue),l=xc(),d=N.useRef(null);N.useEffect(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const u=!c&&o!==null&&r!==null;if(gc({nodeRef:d,disabled:!u}),!u)return null;const h=e?p=>{const m=s.getState().nodes.filter(w=>w.selected);e(p,m)}:void 0,f=p=>{Object.prototype.hasOwnProperty.call(Vn,p.key)&&(p.preventDefault(),l({direction:Vn[p.key],factor:p.shiftKey?4:1}))};return a.jsx("div",{className:me(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:a.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:r}})})}const ii=typeof window<"u"?window:void 0,Sx=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function vc({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:r,onPaneScroll:i,paneClickDistance:c,deleteKeyCode:l,selectionKeyCode:d,selectionOnDrag:u,selectionMode:h,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:w,zoomActivationKeyCode:x,elementsSelectable:y,zoomOnScroll:j,zoomOnPinch:g,panOnScroll:v,panOnScrollSpeed:E,panOnScrollMode:k,zoomOnDoubleClick:C,panOnDrag:I,autoPanOnSelection:R,defaultViewport:H,translateExtent:T,minZoom:$,maxZoom:A,preventScrolling:b,onSelectionContextMenu:S,noWheelClassName:_,noPanClassName:M,disableKeyboardA11y:D,onViewportChange:P,isControlledViewport:L}){const{nodesSelectionActive:V,userSelectionActive:F}=re(Sx,ue),O=Jt(d,{target:ii}),B=Jt(w,{target:ii}),W=B||I,Q=B||v,G=u&&W!==!0,z=O||F||G;return ox({deleteKeyCode:l,multiSelectionKeyCode:m}),a.jsx(ax,{onPaneContextMenu:r,elementsSelectable:y,zoomOnScroll:j,zoomOnPinch:g,panOnScroll:Q,panActivationKeyPressed:B,panOnScrollSpeed:E,panOnScrollMode:k,zoomOnDoubleClick:C,panOnDrag:!O&&W,defaultViewport:H,translateExtent:T,minZoom:$,maxZoom:A,zoomActivationKeyCode:x,preventScrolling:b,noWheelClassName:_,noPanClassName:M,onViewportChange:P,isControlledViewport:L,paneClickDistance:c,selectionOnDrag:G,children:a.jsxs(ux,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:r,onPaneScroll:i,panOnDrag:W,autoPanOnSelection:R,isSelecting:!!z,selectionMode:h,selectionKeyPressed:O,paneClickDistance:c,selectionOnDrag:G,children:[e,V&&a.jsx(Cx,{onSelectionContextMenu:S,noPanClassName:M,disableKeyboardA11y:D})]})})}vc.displayName="FlowRenderer";const _x=N.memo(vc),Mx=e=>t=>e?jo(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 Ix(e){return re(N.useCallback(Mx(e),[e]),ue)}const $x=e=>e.updateNodeInternals;function Rx(){const e=re($x),[t]=N.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const s=new Map;n.forEach(o=>{const r=o.target.getAttribute("data-id");s.set(r,{id:r,nodeElement:o.target,force:!0})}),e(s)}));return N.useEffect(()=>()=>{t?.disconnect()},[t]),t}function Ax({node:e,nodeType:t,hasDimensions:n,resizeObserver:s}){const o=le(),r=N.useRef(null),i=N.useRef(null),c=N.useRef(e.sourcePosition),l=N.useRef(e.targetPosition),d=N.useRef(t),u=n&&!!e.internals.handleBounds;return N.useEffect(()=>{r.current&&!e.hidden&&(!u||i.current!==r.current)&&(i.current&&s?.unobserve(i.current),s?.observe(r.current),i.current=r.current)},[u,e.hidden]),N.useEffect(()=>()=>{i.current&&(s?.unobserve(i.current),i.current=null)},[]),N.useEffect(()=>{if(r.current){const h=d.current!==t,f=c.current!==e.sourcePosition,p=l.current!==e.targetPosition;(h||f||p)&&(d.current=t,c.current=e.sourcePosition,l.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:r.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),r}function Dx({id:e,onClick:t,onMouseEnter:n,onMouseMove:s,onMouseLeave:o,onContextMenu:r,onDoubleClick:i,nodesDraggable:c,elementsSelectable:l,nodesConnectable:d,nodesFocusable:u,resizeObserver:h,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:w,nodeTypes:x,nodeClickDistance:y,onError:j}){const{node:g,internals:v,isParent:E}=re(z=>{const Z=z.nodeLookup.get(e),te=z.parentLookup.has(e);return{node:Z,internals:Z.internals,isParent:te}},ue);let k=g.type||"default",C=x?.[k]||ri[k];C===void 0&&(j?.("003",Te.error003(k)),k="default",C=x?.default||ri.default);const I=!!(g.draggable||c&&typeof g.draggable>"u"),R=!!(g.selectable||l&&typeof g.selectable>"u"),H=!!(g.connectable||d&&typeof g.connectable>"u"),T=!!(g.focusable||u&&typeof g.focusable>"u"),$=le(),A=Fa(g),b=Ax({node:g,nodeType:k,hasDimensions:A,resizeObserver:h}),S=gc({nodeRef:b,disabled:g.hidden||!I,noDragClassName:f,handleSelector:g.dragHandle,nodeId:e,isSelectable:R,nodeClickDistance:y}),_=xc();if(g.hidden)return null;const M=ze(g),D=kx(g),P=R||I||t||n||s||o,L=n?z=>n(z,{...v.userNode}):void 0,V=s?z=>s(z,{...v.userNode}):void 0,F=o?z=>o(z,{...v.userNode}):void 0,O=r?z=>r(z,{...v.userNode}):void 0,B=i?z=>i(z,{...v.userNode}):void 0,W=z=>{const{selectNodesOnDrag:Z,nodeDragThreshold:te}=$.getState();R&&(!Z||!I||te>0)&&Ws({id:e,store:$,nodeRef:b}),t&&t(z,{...v.userNode})},Q=z=>{if(!(Ya(z.nativeEvent)||m)){if(Ra.includes(z.key)&&R){const Z=z.key==="Escape";Ws({id:e,store:$,unselect:Z,nodeRef:b})}else if(I&&g.selected&&Object.prototype.hasOwnProperty.call(Vn,z.key)){z.preventDefault();const{ariaLabelConfig:Z}=$.getState();$.setState({ariaLiveMessage:Z["node.a11yDescription.ariaLiveMessage"]({direction:z.key.replace("Arrow","").toLowerCase(),x:~~v.positionAbsolute.x,y:~~v.positionAbsolute.y})}),_({direction:Vn[z.key],factor:z.shiftKey?4:1})}}},G=()=>{if(m||!b.current?.matches(":focus-visible"))return;const{transform:z,width:Z,height:te,autoPanOnNodeFocus:ee,setCenter:U}=$.getState();if(!ee)return;jo(new Map([[e,g]]),{x:0,y:0,width:Z,height:te},z,!0).length>0||U(g.position.x+M.width/2,g.position.y+M.height/2,{zoom:z[2]})};return a.jsx("div",{className:me(["react-flow__node",`react-flow__node-${k}`,{[p]:I},g.className,{selected:g.selected,selectable:R,parent:E,draggable:I,dragging:S}]),ref:b,style:{zIndex:v.z,transform:`translate(${v.positionAbsolute.x}px,${v.positionAbsolute.y}px)`,pointerEvents:P?"all":"none",visibility:A?"visible":"hidden",...g.style,...D},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:V,onMouseLeave:F,onContextMenu:O,onClick:W,onDoubleClick:B,onKeyDown:T?Q:void 0,tabIndex:T?0:void 0,onFocus:T?G:void 0,role:g.ariaRole??(T?"group":void 0),"aria-roledescription":"node","aria-describedby":m?void 0:`${lc}-${w}`,"aria-label":g.ariaLabel,...g.domAttributes,children:a.jsx(hx,{value:e,children:a.jsx(C,{id:e,data:g.data,type:k,positionAbsoluteX:v.positionAbsolute.x,positionAbsoluteY:v.positionAbsolute.y,selected:g.selected??!1,selectable:R,draggable:I,deletable:g.deletable??!0,isConnectable:H,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:S,dragHandle:g.dragHandle,zIndex:v.z,parentId:g.parentId,...M})})})}var Px=N.memo(Dx);const Tx=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function bc(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:s,onError:o}=re(Tx,ue),r=Ix(e.onlyRenderVisibleElements),i=Rx();return a.jsx("div",{className:"react-flow__nodes",style:us,children:r.map(c=>a.jsx(Px,{id:c,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:i,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:o},c))})}bc.displayName="NodeRenderer";const Ox=N.memo(bc);function zx(e){return re(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 r=n.nodeLookup.get(o.source),i=n.nodeLookup.get(o.target);r&&i&&Am({sourceNode:r,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&s.push(o.id)}return s},[e]),ue)}const Lx=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return a.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Hx=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return a.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ai={[ut.Arrow]:Lx,[ut.ArrowClosed]:Hx};function Vx(e){const t=le();return N.useMemo(()=>Object.prototype.hasOwnProperty.call(ai,e)?ai[e]:(t.getState().onError?.("009",Te.error009(e)),null),[e])}const Fx=({id:e,type:t,color:n,width:s=12.5,height:o=12.5,markerUnits:r="strokeWidth",strokeWidth:i,orient:c="auto-start-reverse"})=>{const l=Vx(t);return l?a.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:r,orient:c,refX:"0",refY:"0",children:a.jsx(l,{color:n,strokeWidth:i})}):null},Nc=({defaultColor:e,rfId:t})=>{const n=re(r=>r.edges),s=re(r=>r.defaultEdgeOptions),o=N.useMemo(()=>Vm(n,{id:t,defaultColor:e,defaultMarkerStart:s?.markerStart,defaultMarkerEnd:s?.markerEnd}),[n,s,t,e]);return o.length?a.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:a.jsx("defs",{children:o.map(r=>a.jsx(Fx,{id:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient},r.id))})}):null};Nc.displayName="MarkerDefinitions";var Bx=N.memo(Nc);function jc({x:e,y:t,label:n,labelStyle:s,labelShowBg:o=!0,labelBgStyle:r,labelBgPadding:i=[2,4],labelBgBorderRadius:c=2,children:l,className:d,...u}){const[h,f]=N.useState({x:1,y:0,width:0,height:0}),p=me(["react-flow__edge-textwrapper",d]),m=N.useRef(null);return N.useEffect(()=>{if(m.current){const w=m.current.getBBox();f({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?a.jsxs("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:p,visibility:h.width?"visible":"hidden",...u,children:[o&&a.jsx("rect",{width:h.width+2*i[0],x:-i[0],y:-i[1],height:h.height+2*i[1],className:"react-flow__edge-textbg",style:r,rx:c,ry:c}),a.jsx("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:m,style:s,children:n}),l]}):null}jc.displayName="EdgeText";const Wx=N.memo(jc);function Tt({path:e,labelX:t,labelY:n,label:s,labelStyle:o,labelShowBg:r,labelBgStyle:i,labelBgPadding:c,labelBgBorderRadius:l,interactionWidth:d=20,...u}){return a.jsxs(a.Fragment,{children:[a.jsx("path",{...u,d:e,fill:"none",className:me(["react-flow__edge-path",u.className])}),d?a.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,s&&Ae(t)&&Ae(n)?a.jsx(Wx,{x:t,y:n,label:s,labelStyle:o,labelShowBg:r,labelBgStyle:i,labelBgPadding:c,labelBgBorderRadius:l}):null]})}function ci({pos:e,x1:t,y1:n,x2:s,y2:o}){return e===q.Left||e===q.Right?[.5*(t+s),n]:[t,.5*(n+o)]}function kc({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:r=q.Top}){const[i,c]=ci({pos:n,x1:e,y1:t,x2:s,y2:o}),[l,d]=ci({pos:r,x1:s,y1:o,x2:e,y2:t}),[u,h,f,p]=qa({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:i,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${e},${t} C${i},${c} ${l},${d} ${s},${o}`,u,h,f,p]}function Ec(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:r,sourcePosition:i,targetPosition:c,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,interactionWidth:y})=>{const[j,g,v]=kc({sourceX:n,sourceY:s,sourcePosition:i,targetX:o,targetY:r,targetPosition:c}),E=e.isInternal?void 0:t;return a.jsx(Tt,{id:E,path:j,labelX:g,labelY:v,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,interactionWidth:y})})}const Yx=Ec({isInternal:!1}),Cc=Ec({isInternal:!0});Yx.displayName="SimpleBezierEdge";Cc.displayName="SimpleBezierEdgeInternal";function Sc(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:r,label:i,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,sourcePosition:p=q.Bottom,targetPosition:m=q.Top,markerEnd:w,markerStart:x,pathOptions:y,interactionWidth:j})=>{const[g,v,E]=Hn({sourceX:n,sourceY:s,sourcePosition:p,targetX:o,targetY:r,targetPosition:m,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),k=e.isInternal?void 0:t;return a.jsx(Tt,{id:k,path:g,labelX:v,labelY:E,label:i,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:w,markerStart:x,interactionWidth:j})})}const _c=Sc({isInternal:!1}),Mc=Sc({isInternal:!0});_c.displayName="SmoothStepEdge";Mc.displayName="SmoothStepEdgeInternal";function Ic(e){return N.memo(({id:t,...n})=>{const s=e.isInternal?void 0:t;return a.jsx(_c,{...n,id:s,pathOptions:N.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const Xx=Ic({isInternal:!1}),$c=Ic({isInternal:!0});Xx.displayName="StepEdge";$c.displayName="StepEdgeInternal";function Rc(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:r,label:i,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})=>{const[x,y,j]=Ga({sourceX:n,sourceY:s,targetX:o,targetY:r}),g=e.isInternal?void 0:t;return a.jsx(Tt,{id:g,path:x,labelX:y,labelY:j,label:i,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})})}const qx=Rc({isInternal:!1}),Ac=Rc({isInternal:!0});qx.displayName="StraightEdge";Ac.displayName="StraightEdgeInternal";function Dc(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:r,sourcePosition:i=q.Bottom,targetPosition:c=q.Top,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,pathOptions:y,interactionWidth:j})=>{const[g,v,E]=So({sourceX:n,sourceY:s,sourcePosition:i,targetX:o,targetY:r,targetPosition:c,curvature:y?.curvature}),k=e.isInternal?void 0:t;return a.jsx(Tt,{id:k,path:g,labelX:v,labelY:E,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,interactionWidth:j})})}const Zx=Dc({isInternal:!1}),Pc=Dc({isInternal:!0});Zx.displayName="BezierEdge";Pc.displayName="BezierEdgeInternal";const li={default:Pc,straight:Ac,step:$c,smoothstep:Mc,simplebezier:Cc},di={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Gx=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,Ux=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,ui="react-flow__edgeupdater";function fi({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:o,onMouseEnter:r,onMouseOut:i,type:c}){return a.jsx("circle",{onMouseDown:o,onMouseEnter:r,onMouseOut:i,className:me([ui,`${ui}-${c}`]),cx:Gx(t,s,e),cy:Ux(n,s,e),r:s,stroke:"transparent",fill:"transparent"})}function Kx({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:s,sourceY:o,targetX:r,targetY:i,sourcePosition:c,targetPosition:l,onReconnect:d,onReconnectStart:u,onReconnectEnd:h,setReconnecting:f,setUpdateHover:p}){const m=le(),w=(v,E)=>{if(v.button!==0)return;const{autoPanOnConnect:k,domNode:C,connectionMode:I,connectionRadius:R,lib:H,onConnectStart:T,cancelConnection:$,nodeLookup:A,rfId:b,panBy:S,updateConnection:_}=m.getState(),M=E.type==="target",D=(V,F)=>{f(!1),h?.(V,n,E.type,F)},P=V=>d?.(n,V),L=(V,F)=>{f(!0),u?.(v,n,E.type),T?.(V,F)};Bs.onPointerDown(v.nativeEvent,{autoPanOnConnect:k,connectionMode:I,connectionRadius:R,domNode:C,handleId:E.id,nodeId:E.nodeId,nodeLookup:A,isTarget:M,edgeUpdaterType:E.type,lib:H,flowId:b,cancelConnection:$,panBy:S,isValidConnection:(...V)=>m.getState().isValidConnection?.(...V)??!0,onConnect:P,onConnectStart:L,onConnectEnd:(...V)=>m.getState().onConnectEnd?.(...V),onReconnectEnd:D,updateConnection:_,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:v.currentTarget})},x=v=>w(v,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=v=>w(v,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),j=()=>p(!0),g=()=>p(!1);return a.jsxs(a.Fragment,{children:[(e===!0||e==="source")&&a.jsx(fi,{position:c,centerX:s,centerY:o,radius:t,onMouseDown:x,onMouseEnter:j,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&a.jsx(fi,{position:l,centerX:r,centerY:i,radius:t,onMouseDown:y,onMouseEnter:j,onMouseOut:g,type:"target"})]})}function Qx({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:s,onClick:o,onDoubleClick:r,onContextMenu:i,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,reconnectRadius:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:w,noPanClassName:x,onError:y,disableKeyboardA11y:j}){let g=re(U=>U.edgeLookup.get(e));const v=re(U=>U.defaultEdgeOptions);g=v?{...v,...g}:g;let E=g.type||"default",k=w?.[E]||li[E];k===void 0&&(y?.("011",Te.error011(E)),E="default",k=w?.default||li.default);const C=!!(g.focusable||t&&typeof g.focusable>"u"),I=typeof h<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),R=!!(g.selectable||s&&typeof g.selectable>"u"),H=N.useRef(null),[T,$]=N.useState(!1),[A,b]=N.useState(!1),S=le(),{zIndex:_=g.zIndex,sourceX:M,sourceY:D,targetX:P,targetY:L,sourcePosition:V,targetPosition:F}=re(N.useCallback(U=>{const K=U.nodeLookup.get(g.source),ne=U.nodeLookup.get(g.target);if(!K||!ne)return di;const ie=Hm({id:e,sourceNode:K,targetNode:ne,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:U.connectionMode,onError:y}),ce=Rm({selected:g.selected,zIndex:g.zIndex,sourceNode:K,targetNode:ne,elevateOnSelect:U.elevateEdgesOnSelect,zIndexMode:U.zIndexMode});return{...ie||di,zIndex:ce}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex,y]),ue),O=N.useMemo(()=>g.markerStart?`url('#${Vs(g.markerStart,m)}')`:void 0,[g.markerStart,m]),B=N.useMemo(()=>g.markerEnd?`url('#${Vs(g.markerEnd,m)}')`:void 0,[g.markerEnd,m]);if(g.hidden||M===null||D===null||P===null||L===null)return null;const W=U=>{const{addSelectedEdges:K,unselectNodesAndEdges:ne,multiSelectionActive:ie}=S.getState();R&&(S.setState({nodesSelectionActive:!1}),g.selected&&ie?(ne({nodes:[],edges:[g]}),H.current?.blur()):K([e])),o&&o(U,g)},Q=r?U=>{r(U,{...g})}:void 0,G=i?U=>{i(U,{...g})}:void 0,z=c?U=>{c(U,{...g})}:void 0,Z=l?U=>{l(U,{...g})}:void 0,te=d?U=>{d(U,{...g})}:void 0,ee=U=>{if(!j&&Ra.includes(U.key)&&R){const{unselectNodesAndEdges:K,addSelectedEdges:ne}=S.getState();U.key==="Escape"?(H.current?.blur(),K({edges:[g]})):ne([e])}};return a.jsx("svg",{style:{zIndex:_},children:a.jsxs("g",{className:me(["react-flow__edge",`react-flow__edge-${E}`,g.className,x,{selected:g.selected,animated:g.animated,inactive:!R&&!o,updating:T,selectable:R}]),onClick:W,onDoubleClick:Q,onContextMenu:G,onMouseEnter:z,onMouseMove:Z,onMouseLeave:te,onKeyDown:C?ee:void 0,tabIndex:C?0:void 0,role:g.ariaRole??(C?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":C?`${dc}-${m}`:void 0,ref:H,...g.domAttributes,children:[!A&&a.jsx(k,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:R,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:M,sourceY:D,targetX:P,targetY:L,sourcePosition:V,targetPosition:F,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:O,markerEnd:B,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),I&&a.jsx(Kx,{edge:g,isReconnectable:I,reconnectRadius:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,sourceX:M,sourceY:D,targetX:P,targetY:L,sourcePosition:V,targetPosition:F,setUpdateHover:$,setReconnecting:b})]})})}var Jx=N.memo(Qx);const e0=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Tc({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:s,noPanClassName:o,onReconnect:r,onEdgeContextMenu:i,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:d,onEdgeClick:u,reconnectRadius:h,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:w}){const{edgesFocusable:x,edgesReconnectable:y,elementsSelectable:j,onError:g}=re(e0,ue),v=zx(t);return a.jsxs("div",{className:"react-flow__edges",children:[a.jsx(Bx,{defaultColor:e,rfId:n}),v.map(E=>a.jsx(Jx,{id:E,edgesFocusable:x,edgesReconnectable:y,elementsSelectable:j,noPanClassName:o,onReconnect:r,onContextMenu:i,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,onClick:u,reconnectRadius:h,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:g,edgeTypes:s,disableKeyboardA11y:w},E))]})}Tc.displayName="EdgeRenderer";const t0=N.memo(Tc),hi=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function n0({children:e}){const t=le(),n=N.useRef(null),[s]=N.useState(()=>t.getState().transform);return pc(()=>{let o=null;const r=()=>{const i=t.getState().transform;o&&i[0]===o[0]&&i[1]===o[1]&&i[2]===o[2]||(o=i,n.current&&(n.current.style.transform=hi(i)))};return r(),t.subscribe(r)},[t]),a.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:hi(s)},children:e})}function s0(e){const t=Pt(),n=N.useRef(!1);N.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const o0=e=>e.panZoom?.syncViewport;function r0(e){const t=re(o0),n=le();return N.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function i0(e){return e.connection.inProgress?{...e.connection,to:un(e.connection.to,e.transform)}:{...e.connection}}function a0(e){return i0}function c0(e){const t=a0();return re(t,ue)}const l0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function d0({containerStyle:e,style:t,type:n,component:s}){const{nodesConnectable:o,width:r,height:i,isValid:c,inProgress:l}=re(l0,ue);return!(r&&o&&l)?null:a.jsx("svg",{style:e,width:r,height:i,className:"react-flow__connectionline react-flow__container",children:a.jsx("g",{className:me(["react-flow__connection",Pa(c)]),children:a.jsx(Oc,{style:t,type:n,CustomComponent:s,isValid:c})})})}const Oc=({style:e,type:t=Je.Bezier,CustomComponent:n,isValid:s})=>{const{inProgress:o,from:r,fromNode:i,fromHandle:c,fromPosition:l,to:d,toNode:u,toHandle:h,toPosition:f,pointer:p}=c0();if(!o)return;if(n)return a.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:c,fromX:r.x,fromY:r.y,toX:d.x,toY:d.y,fromPosition:l,toPosition:f,connectionStatus:Pa(s),toNode:u,toHandle:h,pointer:p});let m="";const w={sourceX:r.x,sourceY:r.y,sourcePosition:l,targetX:d.x,targetY:d.y,targetPosition:f};switch(t){case Je.Bezier:[m]=So(w);break;case Je.SimpleBezier:[m]=kc(w);break;case Je.Step:[m]=Hn({...w,borderRadius:0});break;case Je.SmoothStep:[m]=Hn(w);break;default:[m]=Ga(w)}return a.jsx("path",{d:m,fill:"none",className:"react-flow__connection-path",style:e})};Oc.displayName="ConnectionLine";const u0={};function pi(e=u0){N.useRef(e),le(),N.useEffect(()=>{},[e])}function f0(){le(),N.useRef(!1),N.useEffect(()=>{},[])}function zc({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:s,onEdgeClick:o,onNodeDoubleClick:r,onEdgeDoubleClick:i,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:u,onSelectionContextMenu:h,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:w,connectionLineComponent:x,connectionLineContainerStyle:y,selectionKeyCode:j,selectionOnDrag:g,selectionMode:v,multiSelectionKeyCode:E,panActivationKeyCode:k,zoomActivationKeyCode:C,deleteKeyCode:I,onlyRenderVisibleElements:R,elementsSelectable:H,defaultViewport:T,translateExtent:$,minZoom:A,maxZoom:b,preventScrolling:S,defaultMarkerColor:_,zoomOnScroll:M,zoomOnPinch:D,panOnScroll:P,panOnScrollSpeed:L,panOnScrollMode:V,zoomOnDoubleClick:F,panOnDrag:O,autoPanOnSelection:B,onPaneClick:W,onPaneMouseEnter:Q,onPaneMouseMove:G,onPaneMouseLeave:z,onPaneScroll:Z,onPaneContextMenu:te,paneClickDistance:ee,nodeClickDistance:U,onEdgeContextMenu:K,onEdgeMouseEnter:ne,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:pe,onReconnect:Ne,onReconnectStart:Ce,onReconnectEnd:Se,noDragClassName:Y,noWheelClassName:J,noPanClassName:oe,disableKeyboardA11y:he,nodeExtent:se,rfId:fe,viewport:de,onViewportChange:je,nodesDraggable:hs}){return pi(e),pi(t),f0(),s0(n),r0(de),a.jsx(_x,{onPaneClick:W,onPaneMouseEnter:Q,onPaneMouseMove:G,onPaneMouseLeave:z,onPaneContextMenu:te,onPaneScroll:Z,paneClickDistance:ee,deleteKeyCode:I,selectionKeyCode:j,selectionOnDrag:g,selectionMode:v,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:E,panActivationKeyCode:k,zoomActivationKeyCode:C,elementsSelectable:H,zoomOnScroll:M,zoomOnPinch:D,zoomOnDoubleClick:F,panOnScroll:P,panOnScrollSpeed:L,panOnScrollMode:V,panOnDrag:O,autoPanOnSelection:B,defaultViewport:T,translateExtent:$,minZoom:A,maxZoom:b,onSelectionContextMenu:h,preventScrolling:S,noDragClassName:Y,noWheelClassName:J,noPanClassName:oe,disableKeyboardA11y:he,onViewportChange:je,isControlledViewport:!!de,children:a.jsxs(n0,{children:[a.jsx(t0,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:i,onReconnect:Ne,onReconnectStart:Ce,onReconnectEnd:Se,onlyRenderVisibleElements:R,onEdgeContextMenu:K,onEdgeMouseEnter:ne,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:pe,defaultMarkerColor:_,noPanClassName:oe,disableKeyboardA11y:he,rfId:fe}),a.jsx(d0,{style:w,type:m,component:x,containerStyle:y}),a.jsx("div",{className:"react-flow__edgelabel-renderer"}),a.jsx(Ox,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:r,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:u,nodeClickDistance:U,onlyRenderVisibleElements:R,noPanClassName:oe,noDragClassName:Y,disableKeyboardA11y:he,nodeExtent:se,rfId:fe,nodesDraggable:hs}),a.jsx("div",{className:"react-flow__viewport-portal"})]})})}zc.displayName="GraphView";const h0=N.memo(zc),p0=Va(),mi=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:r,fitView:i,fitViewOptions:c,minZoom:l=.5,maxZoom:d=2,nodeOrigin:u,nodeExtent:h,zIndexMode:f="basic"}={})=>{const p=new Map,m=new Map,w=new Map,x=new Map,y=s??t??[],j=n??e??[],g=u??[0,0],v=h??Gt;Qa(w,x,y);const{nodesInitialized:E}=Fs(j,p,m,{nodeOrigin:g,nodeExtent:v,zIndexMode:f});let k=[0,0,1];if(i&&o&&r){const C=ln(p,{filter:T=>!!((T.width||T.initialWidth)&&(T.height||T.initialHeight))}),{x:I,y:R,zoom:H}=Eo(C,o,r,l,d,c?.padding??.1);k=[I,R,H]}return{rfId:"1",width:o??0,height:r??0,transform:k,nodes:j,nodesInitialized:E,nodeLookup:p,parentLookup:m,edges:y,edgeLookup:x,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:l,maxZoom:d,translateExtent:Gt,nodeExtent:v,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:St.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:g,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:i??!1,fitViewOptions:c,fitViewResolver:null,connection:{...Da},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:p0,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Aa,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},m0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:r,fitView:i,fitViewOptions:c,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:h,zIndexMode:f})=>Mg((p,m)=>{async function w(){const{nodeLookup:x,panZoom:y,fitViewOptions:j,fitViewResolver:g,width:v,height:E,minZoom:k,maxZoom:C}=m();y&&(await Em({nodes:x,width:v,height:E,panZoom:y,minZoom:k,maxZoom:C},j),g?.resolve(!0),p({fitViewResolver:null}))}return{...mi({nodes:e,edges:t,width:o,height:r,fitView:i,fitViewOptions:c,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:h,defaultNodes:n,defaultEdges:s,zIndexMode:f}),setNodes:x=>{const{nodeLookup:y,parentLookup:j,nodeOrigin:g,nodeExtent:v,elevateNodesOnSelect:E,fitViewQueued:k,zIndexMode:C,nodesSelectionActive:I}=m(),{nodesInitialized:R,hasSelectedNodes:H}=Fs(x,y,j,{nodeOrigin:g,nodeExtent:v,elevateNodesOnSelect:E,checkEquality:!0,zIndexMode:C}),T=I&&H;k&&R?(w(),p({nodes:x,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:T})):p({nodes:x,nodesInitialized:R,nodesSelectionActive:T})},setEdges:x=>{const{connectionLookup:y,edgeLookup:j}=m();Qa(y,j,x),p({edges:x})},setDefaultNodesAndEdges:(x,y)=>{if(x){const{setNodes:j}=m();j(x),p({hasDefaultNodes:!0})}if(y){const{setEdges:j}=m();j(y),p({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:y,nodeLookup:j,parentLookup:g,domNode:v,nodeOrigin:E,nodeExtent:k,debug:C,fitViewQueued:I,zIndexMode:R}=m(),{changes:H,updatedInternals:T}=Zm(x,j,g,v,E,k,R);T&&(Wm(j,g,{nodeOrigin:E,nodeExtent:k,zIndexMode:R}),I?(w(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),H?.length>0&&(C&&console.log("React Flow: trigger node changes",H),y?.(H)))},updateNodePositions:(x,y=!1)=>{const j=[];let g=[];const{nodeLookup:v,triggerNodeChanges:E,connection:k,updateConnection:C,onNodesChangeMiddlewareMap:I}=m();for(const[R,H]of x){const T=v.get(R),$=!!(T?.expandParent&&T?.parentId&&H?.position),A={id:R,type:"position",position:$?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:y};if(T&&k.inProgress&&k.fromNode.id===T.id){const b=pt(T,k.fromHandle,q.Left,!0);C({...k,from:b})}$&&T.parentId&&j.push({id:R,parentId:T.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),g.push(A)}if(j.length>0){const{parentLookup:R,nodeOrigin:H}=m(),T=Ro(j,v,R,H);g.push(...T)}for(const R of I.values())g=R(g);E(g)},triggerNodeChanges:x=>{const{onNodesChange:y,setNodes:j,nodes:g,hasDefaultNodes:v,debug:E}=m();if(x?.length){if(v){const k=ls(x,g);j(k)}E&&console.log("React Flow: trigger node changes",x),y?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:y,setEdges:j,edges:g,hasDefaultEdges:v,debug:E}=m();if(x?.length){if(v){const k=ds(x,g);j(k)}E&&console.log("React Flow: trigger edge changes",x),y?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:y,edgeLookup:j,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:E}=m();if(y){const k=x.map(C=>nt(C,!0));v(k);return}v(vt(g,new Set([...x]),!0)),E(vt(j))},addSelectedEdges:x=>{const{multiSelectionActive:y,edgeLookup:j,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:E}=m();if(y){const k=x.map(C=>nt(C,!0));E(k);return}E(vt(j,new Set([...x]))),v(vt(g,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:y}={})=>{const{edges:j,nodes:g,nodeLookup:v,triggerNodeChanges:E,triggerEdgeChanges:k}=m(),C=x||g,I=y||j,R=[];for(const T of C){if(!T.selected)continue;const $=v.get(T.id);$&&($.selected=!1),R.push(nt(T.id,!1))}const H=[];for(const T of I)T.selected&&H.push(nt(T.id,!1));E(R),k(H)},setMinZoom:x=>{const{panZoom:y,maxZoom:j}=m();y?.setScaleExtent([x,j]),p({minZoom:x})},setMaxZoom:x=>{const{panZoom:y,minZoom:j}=m();y?.setScaleExtent([j,x]),p({maxZoom:x})},setTranslateExtent:x=>{m().panZoom?.setTranslateExtent(x),p({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:y,triggerNodeChanges:j,triggerEdgeChanges:g,elementsSelectable:v}=m();if(!v)return;const E=y.reduce((C,I)=>I.selected?[...C,nt(I.id,!1)]:C,[]),k=x.reduce((C,I)=>I.selected?[...C,nt(I.id,!1)]:C,[]);j(E),g(k)},setNodeExtent:x=>{const{nodes:y,nodeLookup:j,parentLookup:g,nodeOrigin:v,elevateNodesOnSelect:E,nodeExtent:k,zIndexMode:C}=m();x[0][0]===k[0][0]&&x[0][1]===k[0][1]&&x[1][0]===k[1][0]&&x[1][1]===k[1][1]||(Fs(y,j,g,{nodeOrigin:v,nodeExtent:x,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:C}),p({nodeExtent:x}))},panBy:x=>{const{transform:y,width:j,height:g,panZoom:v,translateExtent:E}=m();return Gm({delta:x,panZoom:v,transform:y,translateExtent:E,width:j,height:g})},setCenter:async(x,y,j)=>{const{width:g,height:v,maxZoom:E,panZoom:k}=m();if(!k)return!1;const C=typeof j?.zoom<"u"?j.zoom:E;return await k.setViewport({x:g/2-x*C,y:v/2-y*C,zoom:C},{duration:j?.duration,ease:j?.ease,interpolate:j?.interpolate}),!0},cancelConnection:()=>{p({connection:{...Da}})},updateConnection:x=>{p({connection:x})},reset:()=>p({...mi()})}},Object.is);function Do({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:s,initialWidth:o,initialHeight:r,initialMinZoom:i,initialMaxZoom:c,initialFitViewOptions:l,fitView:d,nodeOrigin:u,nodeExtent:h,zIndexMode:f,children:p}){const[m]=N.useState(()=>m0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:r,fitView:d,minZoom:i,maxZoom:c,fitViewOptions:l,nodeOrigin:u,nodeExtent:h,zIndexMode:f}));return a.jsx(Ig,{value:m,children:a.jsx(ex,{children:a.jsx(mx,{children:p})})})}function g0({children:e,nodes:t,edges:n,defaultNodes:s,defaultEdges:o,width:r,height:i,fitView:c,fitViewOptions:l,minZoom:d,maxZoom:u,nodeOrigin:h,nodeExtent:f,zIndexMode:p}){return N.useContext(cs)?a.jsx(a.Fragment,{children:e}):a.jsx(Do,{initialNodes:t,initialEdges:n,defaultNodes:s,defaultEdges:o,initialWidth:r,initialHeight:i,fitView:c,initialFitViewOptions:l,initialMinZoom:d,initialMaxZoom:u,nodeOrigin:h,nodeExtent:f,zIndexMode:p,children:e})}const x0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function y0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:o,nodeTypes:r,edgeTypes:i,onNodeClick:c,onEdgeClick:l,onInit:d,onMove:u,onMoveStart:h,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:w,onClickConnectStart:x,onClickConnectEnd:y,onNodeMouseEnter:j,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:k,onNodeDragStart:C,onNodeDrag:I,onNodeDragStop:R,onNodesDelete:H,onEdgesDelete:T,onDelete:$,onSelectionChange:A,onSelectionDragStart:b,onSelectionDrag:S,onSelectionDragStop:_,onSelectionContextMenu:M,onSelectionStart:D,onSelectionEnd:P,onBeforeDelete:L,connectionMode:V,connectionLineType:F=Je.Bezier,connectionLineStyle:O,connectionLineComponent:B,connectionLineContainerStyle:W,deleteKeyCode:Q="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:z=!1,selectionMode:Z=Ut.Full,panActivationKeyCode:te="Space",multiSelectionKeyCode:ee=Qt()?"Meta":"Control",zoomActivationKeyCode:U=Qt()?"Meta":"Control",snapToGrid:K,snapGrid:ne,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ce,nodesDraggable:pe,autoPanOnNodeFocus:Ne,nodesConnectable:Ce,nodesFocusable:Se,nodeOrigin:Y=uc,edgesFocusable:J,edgesReconnectable:oe,elementsSelectable:he=!0,defaultViewport:se=Bg,minZoom:fe=.5,maxZoom:de=2,translateExtent:je=Gt,preventScrolling:hs=!0,nodeExtent:ps,defaultMarkerColor:Nl="#b1b1b7",zoomOnScroll:jl=!0,zoomOnPinch:kl=!0,panOnScroll:El=!1,panOnScrollSpeed:Cl=.5,panOnScrollMode:Sl=at.Free,zoomOnDoubleClick:_l=!0,panOnDrag:Ml=!0,onPaneClick:Il,onPaneMouseEnter:$l,onPaneMouseMove:Rl,onPaneMouseLeave:Al,onPaneScroll:Dl,onPaneContextMenu:Pl,paneClickDistance:Tl=1,nodeClickDistance:Ol=0,children:zl,onReconnect:Ll,onReconnectStart:Hl,onReconnectEnd:Vl,onEdgeContextMenu:Fl,onEdgeDoubleClick:Bl,onEdgeMouseEnter:Wl,onEdgeMouseMove:Yl,onEdgeMouseLeave:Xl,reconnectRadius:ql=10,onNodesChange:Zl,onEdgesChange:Gl,noDragClassName:Ul="nodrag",noWheelClassName:Kl="nowheel",noPanClassName:Go="nopan",fitView:Uo,fitViewOptions:Ko,connectOnClick:Ql,attributionPosition:Jl,proOptions:ed,defaultEdgeOptions:td,elevateNodesOnSelect:nd=!0,elevateEdgesOnSelect:sd=!1,disableKeyboardA11y:Qo=!1,autoPanOnConnect:od,autoPanOnNodeDrag:rd,autoPanOnSelection:id=!0,autoPanSpeed:ad,connectionRadius:cd,isValidConnection:ld,onError:dd,style:ud,id:Jo,nodeDragThreshold:fd,connectionDragThreshold:hd,viewport:pd,onViewportChange:md,width:gd,height:xd,colorMode:yd="light",debug:wd,onScroll:er,ariaLabelConfig:vd,zIndexMode:tr="basic",...bd},Nd){const ms=Jo||"1",jd=qg(yd),kd=N.useCallback(nr=>{nr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),er?.(nr)},[er]);return a.jsx("div",{"data-testid":"rf__wrapper",...bd,onScroll:kd,style:{...ud,...x0},ref:Nd,className:me(["react-flow",o,jd]),id:Jo,role:"application",children:a.jsxs(g0,{nodes:e,edges:t,width:gd,height:xd,fitView:Uo,fitViewOptions:Ko,minZoom:fe,maxZoom:de,nodeOrigin:Y,nodeExtent:ps,zIndexMode:tr,children:[a.jsx(Xg,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:p,onConnectStart:m,onConnectEnd:w,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:pe,autoPanOnNodeFocus:Ne,nodesConnectable:Ce,nodesFocusable:Se,edgesFocusable:J,edgesReconnectable:oe,elementsSelectable:he,elevateNodesOnSelect:nd,elevateEdgesOnSelect:sd,minZoom:fe,maxZoom:de,nodeExtent:ps,onNodesChange:Zl,onEdgesChange:Gl,snapToGrid:K,snapGrid:ne,connectionMode:V,translateExtent:je,connectOnClick:Ql,defaultEdgeOptions:td,fitView:Uo,fitViewOptions:Ko,onNodesDelete:H,onEdgesDelete:T,onDelete:$,onNodeDragStart:C,onNodeDrag:I,onNodeDragStop:R,onSelectionDrag:S,onSelectionDragStart:b,onSelectionDragStop:_,onMove:u,onMoveStart:h,onMoveEnd:f,noPanClassName:Go,nodeOrigin:Y,rfId:ms,autoPanOnConnect:od,autoPanOnNodeDrag:rd,autoPanSpeed:ad,onError:dd,connectionRadius:cd,isValidConnection:ld,selectNodesOnDrag:ce,nodeDragThreshold:fd,connectionDragThreshold:hd,onBeforeDelete:L,debug:wd,ariaLabelConfig:vd,zIndexMode:tr}),a.jsx(h0,{onInit:d,onNodeClick:c,onEdgeClick:l,onNodeMouseEnter:j,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:k,nodeTypes:r,edgeTypes:i,connectionLineType:F,connectionLineStyle:O,connectionLineComponent:B,connectionLineContainerStyle:W,selectionKeyCode:G,selectionOnDrag:z,selectionMode:Z,deleteKeyCode:Q,multiSelectionKeyCode:ee,panActivationKeyCode:te,zoomActivationKeyCode:U,onlyRenderVisibleElements:ie,defaultViewport:se,translateExtent:je,minZoom:fe,maxZoom:de,preventScrolling:hs,zoomOnScroll:jl,zoomOnPinch:kl,zoomOnDoubleClick:_l,panOnScroll:El,panOnScrollSpeed:Cl,panOnScrollMode:Sl,panOnDrag:Ml,autoPanOnSelection:id,onPaneClick:Il,onPaneMouseEnter:$l,onPaneMouseMove:Rl,onPaneMouseLeave:Al,onPaneScroll:Dl,onPaneContextMenu:Pl,paneClickDistance:Tl,nodeClickDistance:Ol,onSelectionContextMenu:M,onSelectionStart:D,onSelectionEnd:P,onReconnect:Ll,onReconnectStart:Hl,onReconnectEnd:Vl,onEdgeContextMenu:Fl,onEdgeDoubleClick:Bl,onEdgeMouseEnter:Wl,onEdgeMouseMove:Yl,onEdgeMouseLeave:Xl,reconnectRadius:ql,defaultMarkerColor:Nl,noDragClassName:Ul,noWheelClassName:Kl,noPanClassName:Go,rfId:ms,disableKeyboardA11y:Qo,nodeExtent:ps,viewport:pd,onViewportChange:md,nodesDraggable:pe}),a.jsx(Fg,{onSelectionChange:A}),zl,a.jsx(Og,{proOptions:ed,position:Jl}),a.jsx(Tg,{rfId:ms,disableKeyboardA11y:Qo})]})})}var Po=hc(y0);const w0=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function v0({children:e}){const t=re(w0);return t?zd.createPortal(e,t):null}function Fn(e){return re(N.useCallback(n=>n.nodeLookup.get(e),[e]),ue)}function b0({dimensions:e,lineWidth:t,variant:n,className:s}){return a.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:me(["react-flow__background-pattern",n,s])})}function N0({radius:e,className:t}){return a.jsx("circle",{cx:e,cy:e,r:e,className:me(["react-flow__background-pattern","dots",t])})}var et;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(et||(et={}));const j0={[et.Dots]:1,[et.Lines]:1,[et.Cross]:6},k0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Lc({id:e,variant:t=et.Dots,gap:n=20,size:s,lineWidth:o=1,offset:r=0,color:i,bgColor:c,style:l,className:d,patternClassName:u}){const h=N.useRef(null),{transform:f,patternId:p}=re(k0,ue),m=s||j0[t],w=t===et.Dots,x=t===et.Cross,y=Array.isArray(n)?n:[n,n],j=[y[0]*f[2]||1,y[1]*f[2]||1],g=m*f[2],v=Array.isArray(r)?r:[r,r],E=x?[g,g]:j,k=[v[0]*f[2]+E[0]/2,v[1]*f[2]+E[1]/2],C=`${p}${e||""}`;return a.jsxs("svg",{className:me(["react-flow__background",d]),style:{...l,...us,"--xy-background-color-props":c,"--xy-background-pattern-color-props":i},ref:h,"data-testid":"rf__background",children:[a.jsx("pattern",{id:C,x:f[0]%j[0],y:f[1]%j[1],width:j[0],height:j[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:w?a.jsx(N0,{radius:g/2,className:u}):a.jsx(b0,{dimensions:E,lineWidth:o,variant:t,className:u})}),a.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${C})`})]})}Lc.displayName="Background";const To=N.memo(Lc);function E0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:a.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function C0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:a.jsx("path",{d:"M0 0h32v4.2H0z"})})}function S0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:a.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 _0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a.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 M0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a.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 bt({children:e,className:t,...n}){return a.jsx("button",{type:"button",className:me(["react-flow__controls-button",t]),...n,children:e})}const I0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Hc({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:r,onZoomOut:i,onFitView:c,onInteractiveChange:l,className:d,children:u,position:h="bottom-left",orientation:f="vertical","aria-label":p}){const m=le(),{isInteractive:w,minZoomReached:x,maxZoomReached:y,ariaLabelConfig:j}=re(I0,ue),{zoomIn:g,zoomOut:v,fitView:E}=Pt(),k=()=>{g(),r?.()},C=()=>{v(),i?.()},I=()=>{E(o),c?.()},R=()=>{m.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),l?.(!w)},H=f==="horizontal"?"horizontal":"vertical";return a.jsxs(tt,{className:me(["react-flow__controls",H,d]),position:h,style:e,"data-testid":"rf__controls","aria-label":p??j["controls.ariaLabel"],children:[t&&a.jsxs(a.Fragment,{children:[a.jsx(bt,{onClick:k,className:"react-flow__controls-zoomin",title:j["controls.zoomIn.ariaLabel"],"aria-label":j["controls.zoomIn.ariaLabel"],disabled:y,children:a.jsx(E0,{})}),a.jsx(bt,{onClick:C,className:"react-flow__controls-zoomout",title:j["controls.zoomOut.ariaLabel"],"aria-label":j["controls.zoomOut.ariaLabel"],disabled:x,children:a.jsx(C0,{})})]}),n&&a.jsx(bt,{className:"react-flow__controls-fitview",onClick:I,title:j["controls.fitView.ariaLabel"],"aria-label":j["controls.fitView.ariaLabel"],children:a.jsx(S0,{})}),s&&a.jsx(bt,{className:"react-flow__controls-interactive",onClick:R,title:j["controls.interactive.ariaLabel"],"aria-label":j["controls.interactive.ariaLabel"],children:w?a.jsx(M0,{}):a.jsx(_0,{})}),u]})}Hc.displayName="Controls";const Oo=N.memo(Hc);function $0({id:e,x:t,y:n,width:s,height:o,style:r,color:i,strokeColor:c,strokeWidth:l,className:d,borderRadius:u,shapeRendering:h,selected:f,onClick:p}){const{background:m,backgroundColor:w}=r||{},x=i||m||w;return a.jsx("rect",{className:me(["react-flow__minimap-node",{selected:f},d]),x:t,y:n,rx:u,ry:u,width:s,height:o,style:{fill:x,stroke:c,strokeWidth:l},shapeRendering:h,onClick:p?y=>p(y,e):void 0})}const R0=N.memo($0),A0=e=>e.nodes.map(t=>t.id),_s=e=>e instanceof Function?e:()=>e;function D0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:o,nodeComponent:r=R0,onClick:i}){const c=re(A0,ue),l=_s(t),d=_s(e),u=_s(n),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return a.jsx(a.Fragment,{children:c.map(f=>a.jsx(T0,{id:f,nodeColorFunc:l,nodeStrokeColorFunc:d,nodeClassNameFunc:u,nodeBorderRadius:s,nodeStrokeWidth:o,NodeComponent:r,onClick:i,shapeRendering:h},f))})}function P0({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:s,nodeBorderRadius:o,nodeStrokeWidth:r,shapeRendering:i,NodeComponent:c,onClick:l}){const{node:d,x:u,y:h,width:f,height:p}=re(m=>{const w=m.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const x=w.internals.userNode,{x:y,y:j}=w.internals.positionAbsolute,{width:g,height:v}=ze(x);return{node:x,x:y,y:j,width:g,height:v}},ue);return!d||d.hidden||!Fa(d)?null:a.jsx(c,{x:u,y:h,width:f,height:p,style:d.style,selected:!!d.selected,className:s(d),color:t(d),borderRadius:o,strokeColor:n(d),strokeWidth:r,shapeRendering:i,onClick:l,id:d.id})}const T0=N.memo(P0);var O0=N.memo(D0);const z0=200,L0=150,H0=e=>!e.hidden,V0=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?La(ln(e.nodeLookup,{filter:H0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},gi=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,F0=(e,t)=>gi(e.viewBB,t.viewBB)&&gi(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,B0="react-flow__minimap-desc";function Vc({style:e,className:t,nodeStrokeColor:n,nodeColor:s,nodeClassName:o="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:c,bgColor:l,maskColor:d,maskStrokeColor:u,maskStrokeWidth:h,position:f="bottom-right",onClick:p,onNodeClick:m,pannable:w=!1,zoomable:x=!1,ariaLabel:y,inversePan:j,zoomStep:g=1,offsetScale:v=5}){const E=le(),k=N.useRef(null),{boundingRect:C,viewBB:I,rfId:R,panZoom:H,translateExtent:T,flowWidth:$,flowHeight:A,ariaLabelConfig:b}=re(V0,F0),S=e?.width??z0,_=e?.height??L0,M=C.width/S,D=C.height/_,P=Math.max(M,D),L=P*S,V=P*_,F=v*P,O=C.x-(L-C.width)/2-F,B=C.y-(V-C.height)/2-F,W=L+F*2,Q=V+F*2,G=`${B0}-${R}`,z=N.useRef(0),Z=N.useRef();z.current=P,N.useEffect(()=>{if(k.current&&H)return Z.current=og({domNode:k.current,panZoom:H,getTransform:()=>E.getState().transform,getViewScale:()=>z.current}),()=>{Z.current?.destroy()}},[H]),N.useEffect(()=>{Z.current?.update({translateExtent:T,width:$,height:A,inversePan:j,pannable:w,zoomStep:g,zoomable:x})},[w,x,j,g,T,$,A]);const te=p?K=>{const[ne,ie]=Z.current?.pointer(K)||[0,0];p(K,{x:ne,y:ie})}:void 0,ee=m?N.useCallback((K,ne)=>{const ie=E.getState().nodeLookup.get(ne).internals.userNode;m(K,ie)},[]):void 0,U=y??b["minimap.ariaLabel"];return a.jsx(tt,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof h=="number"?h*P: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 i=="number"?i:void 0},className:me(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:a.jsxs("svg",{width:S,height:_,viewBox:`${O} ${B} ${W} ${Q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":G,ref:k,onClick:te,children:[U&&a.jsx("title",{id:G,children:U}),a.jsx(O0,{onClick:ee,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:r,nodeClassName:o,nodeStrokeWidth:i,nodeComponent:c}),a.jsx("path",{className:"react-flow__minimap-mask",d:`M${O-F},${B-F}h${W+F*2}v${Q+F*2}h${-W-F*2}z
8
- M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Vc.displayName="MiniMap";const zo=N.memo(Vc),W0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Y0={[It.Line]:"right",[It.Handle]:"bottom-right"};function X0({nodeId:e,position:t,variant:n=It.Handle,className:s,style:o=void 0,children:r,color:i,minWidth:c=10,minHeight:l=10,maxWidth:d=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:h=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:w,onResize:x,onResizeEnd:y}){const j=yc(),g=typeof e=="string"?e:j,v=le(),E=N.useRef(null),k=n===It.Handle,C=re(N.useCallback(W0(k&&p),[k,p]),ue),I=N.useRef(null),R=t??Y0[n];N.useEffect(()=>{if(!(!E.current||!g))return I.current||(I.current=xg({domNode:E.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:T,transform:$,snapGrid:A,snapToGrid:b,nodeOrigin:S,domNode:_}=v.getState();return{nodeLookup:T,transform:$,snapGrid:A,snapToGrid:b,nodeOrigin:S,paneDomNode:_}},onChange:(T,$)=>{const{triggerNodeChanges:A,nodeLookup:b,parentLookup:S,nodeOrigin:_}=v.getState(),M=[],D={x:T.x,y:T.y},P=b.get(g);if(P&&P.expandParent&&P.parentId){const L=P.origin??_,V=T.width??P.measured.width??0,F=T.height??P.measured.height??0,O={id:P.id,parentId:P.parentId,rect:{width:V,height:F,...Ba({x:T.x??P.position.x,y:T.y??P.position.y},{width:V,height:F},P.parentId,b,L)}},B=Ro([O],b,S,_);M.push(...B),D.x=T.x?Math.max(L[0]*V,T.x):void 0,D.y=T.y?Math.max(L[1]*F,T.y):void 0}if(D.x!==void 0&&D.y!==void 0){const L={id:g,type:"position",position:{...D}};M.push(L)}if(T.width!==void 0&&T.height!==void 0){const V={id:g,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:T.width,height:T.height}};M.push(V)}for(const L of $){const V={...L,type:"position"};M.push(V)}A(M)},onEnd:({width:T,height:$})=>{const A={id:g,type:"dimensions",resizing:!1,dimensions:{width:T,height:$}};v.getState().triggerNodeChanges([A])}})),I.current.update({controlPosition:R,boundaries:{minWidth:c,minHeight:l,maxWidth:d,maxHeight:u},keepAspectRatio:h,resizeDirection:f,onResizeStart:w,onResize:x,onResizeEnd:y,shouldResize:m}),()=>{I.current?.destroy()}},[R,c,l,d,u,h,w,x,y,m]);const H=R.split("-");return a.jsx("div",{className:me(["react-flow__resize-control","nodrag",...H,n,s]),ref:E,style:{...o,scale:C,...i&&{[k?"backgroundColor":"borderColor"]:i}},children:r})}const q0=N.memo(X0),Z0="/assets/elk-worker.min-C9JGDOE-.js";let xi;function G0(){return xi??=Ld(async()=>{const{default:e}=await import("./elk-api-Di4OXGNH.js").then(t=>t.e);return{default:e}},__vite__mapDeps([0,1,2])).then(({default:e})=>new e({workerUrl:Z0})),xi}const yi={"elk.algorithm":"layered","elk.direction":"RIGHT","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.layered.spacing.nodeNodeBetweenLayers":"70","elk.spacing.nodeNode":"44","elk.spacing.componentComponent":"70","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=34,left=14,bottom=14,right=14]"},U0=160,K0=88;async function Bn(e,t){if(e.length===0)return e;const n=new Map,s=new Set;for(const d of e)d.parentId&&s.add(d.parentId);for(const d of e){const u=d.type==="classNode"||d.type==="coreNode"||d.type==="moduleNode"||d.type==="group"&&!s.has(d.id),h=typeof d.style?.width=="number"?d.style.width:void 0,f=typeof d.style?.height=="number"?d.style.height:void 0;n.set(d.id,{id:d.id,...u?{width:h??d.measured?.width??U0,height:f??d.measured?.height??K0}:{layoutOptions:yi},children:[]})}const o=[];for(const d of e){const u=n.get(d.id);d.parentId&&n.has(d.parentId)?n.get(d.parentId).children.push(u):o.push(u)}const r={id:"root",layoutOptions:yi,children:o,edges:t.map(d=>({id:d.id,sources:[d.source],targets:[d.target]}))};let i;try{i=await(await G0()).layout(r)}catch{return e}const c=new Map,l=d=>{c.set(d.id,{x:d.x??0,y:d.y??0,w:d.width??0,h:d.height??0}),d.children?.forEach(l)};return i.children?.forEach(l),e.map(d=>{const u=c.get(d.id);if(!u)return d;const h={...d,position:{x:u.x,y:u.y}};return d.type==="group"&&(h.style={...d.style,width:u.w,height:u.h}),h})}const Q0=32;function Wn(e){const t=new Map;for(const s of e){if(s.type!=="floating"||s.source===s.target)continue;const[o,r]=[s.source,s.target].sort(),i=`${o}\0${r}`,c=t.get(i);c?c.push(s):t.set(i,[s])}const n=new Map;for(const s of t.values()){if(s.length<2)continue;const o=[...s].sort((i,c)=>{const l=String(i.data?.label??i.data?.edgeClass??""),d=String(c.data?.label??c.data?.edgeClass??"");return l.localeCompare(d)||i.id.localeCompare(c.id)}),r=(o.length-1)/2;o.forEach((i,c)=>{const l=(c-r)*Q0,d=i.source<i.target?1:-1;n.set(i.id,{parallelCount:o.length,parallelOffset:l*d})})}return e.map(s=>{const o=n.get(s.id);return o?{...s,data:{...s.data,...o}}:s})}function wi(e,t){const n=(e.measured.width??0)/2,s=(e.measured.height??0)/2,o=e.internals.positionAbsolute,r=t.internals.positionAbsolute,i=o.x+n,c=o.y+s,l=r.x+(t.measured.width??0)/2,d=r.y+(t.measured.height??0)/2,u=(l-i)/(2*n)-(d-c)/(2*s),h=(l-i)/(2*n)+(d-c)/(2*s),f=1/(Math.abs(u)+Math.abs(h)||1),p=f*u,m=f*h;return{x:n*(p+m)+i,y:s*(-p+m)+c}}function vi(e,t){const n=e.internals.positionAbsolute,s=Math.round(n.x),o=Math.round(n.y),r=Math.round(t.x),i=Math.round(t.y);return r<=s+1?q.Left:r>=s+(e.measured.width??0)-1?q.Right:i<=o+1?q.Top:q.Bottom}function J0(e,t){const n=wi(e,t),s=wi(t,e);return{sx:n.x,sy:n.y,tx:s.x,ty:s.y,sourcePos:vi(e,n),targetPos:vi(t,s)}}function ey({sx:e,sy:t,tx:n,ty:s,offset:o}){const r=n-e,i=s-t,c=Math.hypot(r,i)||1,l=-i/c,d=r/c,u=(e+n)/2+l*o*2,h=(t+s)/2+d*o*2,f=e*.25+u*.5+n*.25,p=t*.25+h*.5+s*.25;return[`M ${e},${t} Q ${u},${h} ${n},${s}`,f,p]}function ty({id:e,source:t,target:n,markerStart:s,markerEnd:o,style:r,data:i}){const c=Fn(t),l=Fn(n);if(!c||!l)return null;const{sx:d,sy:u,tx:h,ty:f,sourcePos:p,targetPos:m}=J0(c,l),w=i,[x,y,j]=(w?.parallelCount??1)>1?ey({sx:d,sy:u,tx:h,ty:f,offset:w?.parallelOffset??0}):So({sourceX:d,sourceY:u,sourcePosition:p,targetX:h,targetY:f,targetPosition:m,curvature:.25}),g=w?.label,v=w?.selected===!0,E=v?"var(--color-primary)":r?.stroke??"var(--color-muted-foreground)",k=v?{...r,stroke:E,strokeWidth:3}:r;return a.jsxs(a.Fragment,{children:[a.jsx(Tt,{id:e,path:x,markerStart:s,markerEnd:o,style:k,interactionWidth:18}),g&&a.jsx(v0,{children:a.jsx("div",{className:"absolute font-mono font-extrabold text-[9px] px-1 rounded pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${y}px, ${j}px)`,color:E,background:"oklch(0.17 0.01 270)"},children:g})})]})}function ny({id:e,source:t,target:n,style:s}){const o=Fn(t),r=Fn(n);if(!o||!r)return null;const i=o.internals.positionAbsolute,c=r.internals.positionAbsolute,l=o.measured.width??0,d=o.measured.height??0,u=r.measured.width??0,h=r.measured.height??0,f=c.x>=i.x,[p]=Hn({sourceX:f?i.x+l:i.x,sourceY:i.y+d/2,sourcePosition:f?q.Right:q.Left,targetX:f?c.x:c.x+u,targetY:c.y+h/2,targetPosition:f?q.Left:q.Right,borderRadius:16});return a.jsx(Tt,{id:e,path:p,style:s,interactionWidth:18})}const Lo={floating:ty,tree:ny};function Ho({domainId:e,anchorRef:t,kind:n,excerpt:s,className:o}){const{threads:r,status:i,orphaned:c}=Hi(t,e),l=N.useId(),d=X(m=>m.openAnchorRef),u=X(m=>m.openAnchorId),h=e?`${e}::${t}`:t,f=d===h&&(u===null||u===l),p=X(m=>m.setOpenAnchor);return r.length===0?null:a.jsxs($t,{modal:!1,open:f,onOpenChange:m=>p(m?h:null,m?l:null),children:[a.jsx(no,{asChild:!0,children:a.jsxs("button",{type:"button",title:"View comments",onClick:m=>{m.stopPropagation(),p(f?null:h,l)},className:ae("nodrag nopan absolute right-1 top-1 z-30 flex h-[18px] min-w-[18px] items-center justify-center gap-0.5 rounded-full px-1 text-[10px] font-bold shadow-md ring-2 ring-card hover:brightness-110",c?"bg-destructive text-white":i==="open"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground",o),children:[a.jsx(Vi,{className:"h-2.5 w-2.5"}),r.length]})}),a.jsx(Rt,{side:"top",align:"end",className:"w-80",children:a.jsx(so,{domainId:e,anchor:{ref:t,kind:n},excerpt:s,threads:r,onClose:()=>p(null)})})]})}function sy(e){const t=e.trim();if(!t.startsWith("<svg"))return null;let n=t;return n=n.replace(/<script[\s\S]*?<\/script>/gi,""),n=n.replace(/<foreignObject[\s\S]*?<\/foreignObject>/gi,""),n=n.replace(/\son\w+\s*=\s*"[^"]*"/gi,""),n=n.replace(/\son\w+\s*=\s*'[^']*'/gi,""),n=n.replace(/(href|xlink:href)\s*=\s*"(?!#)[^"]*"/gi,""),n=n.replace(/<!--[\s\S]*?-->/g,""),n=n.replace(/<svg\b([^>]*)>/i,(s,o)=>{let r=o.replace(/\swidth\s*=\s*"[^"]*"/i,"").replace(/\sheight\s*=\s*"[^"]*"/i,"");return/viewBox=/i.test(r)||(r+=' viewBox="0 0 24 24"'),`<svg${r} width="100%" height="100%" preserveAspectRatio="xMidYMid meet">`}),n}function ge({svg:e,className:t}){const n=N.useMemo(()=>e?sy(e):null,[e]);return n?a.jsx("span",{className:ae("inline-flex shrink-0 items-center justify-center [&>svg]:h-full [&>svg]:w-full",t),dangerouslySetInnerHTML:{__html:n}}):null}const Le=e=>`core.node.${e}`,Vo=e=>e.split("/").filter(Boolean).pop()??e,oy=/^.+:class\.[A-Za-z][A-Za-z0-9_]*\.property\.([A-Za-z][A-Za-z0-9_]*)$/;function Fo(e){const t=Object.entries(e).map(([s,o])=>({key:s,shortName:oy.exec(s)?.[1]??s,value:o})),n=new Map;for(const s of t)n.set(s.shortName,(n.get(s.shortName)??0)+1);return t.map(({key:s,shortName:o,value:r})=>({key:s,label:n.get(o)===1?o:s,value:r}))}function Fc(e,t){const n=Fo(e);return t.flatMap(s=>n.filter(o=>o.label===s))[0]}function en(e){const t=Fc(e.data,["name","title"])?.value;return typeof t=="string"&&t?t:Vo(e.path)}function Bo(e){const t=[...new Set(e.nodes.map(n=>n.className))].sort();return new Map(t.map((n,s)=>[n,Hd(s)]))}const Wo=e=>e==null?"—":typeof e=="string"?e:Array.isArray(e)?e.map(Wo).join(", "):JSON.stringify(e);function ry(e,t=2){const n=Fc(e.data,["name","title"]);return Fo(e.data).filter(s=>s.key!==n?.key).slice(0,t).map(({label:s,value:o})=>[s,Wo(o)])}function Yo(e,t){return e.ir?.classes?.[t]?.icon}function iy(e,t,n){const s=new Set(e.nodes.map(c=>Le(c.path))),o=e.nodes.map(c=>{const l=ry(c);return{id:Le(c.path),type:"coreNode",position:{x:0,y:0},data:{path:c.path,className:c.className,title:en(c),hue:n.get(c.className)??264,icon:Yo(t,c.className),fields:l,selected:!1},style:{width:184,height:50+l.length*15}}}),r=`/:${e.domain}`;for(const c of new Set(e.edges.flatMap(l=>[l.from,l.to]))){const l=Le(c);if(s.has(l))continue;const d=c===r;o.push({id:l,type:"coreNode",position:{x:0,y:0},selectable:!1,focusable:!1,data:{path:c,className:d?"Domain":"External",title:d?e.domain:Vo(c),hue:d?210:264,fields:[],selected:!1,virtual:!0},style:{width:184,height:50}}),s.add(l)}const i=[];for(const c of e.nodes){if(!c.parent)continue;const l=Le(c.parent),d=Le(c.path);!s.has(l)||!s.has(d)||i.push({id:`core.struct.${c.path}`,source:l,target:d,type:"tree",data:{structural:!0},style:{stroke:"oklch(0.5 0.02 264)",strokeWidth:1.4,strokeDasharray:"4 4"}})}for(const c of e.edges){const l=Le(c.from),d=Le(c.to);if(!s.has(l)||!s.has(d))continue;const u="oklch(0.72 0.16 35)";i.push({id:`core.edge.${c.from}__${c.edgeName}__${c.to}`,source:l,target:d,type:"floating",data:{label:c.edgeName},markerEnd:{type:ut.ArrowClosed,color:u,width:16,height:16},style:{stroke:u,strokeWidth:2}})}return{nodes:o,edges:i}}function Bc({count:e}){const t=X(o=>o.canvasMode),n=X(o=>o.setCanvasMode),s=t==="core";return a.jsxs(Ve,{size:"xs",variant:s?"default":"outline",onClick:()=>n(s?"schema":"core"),"aria-pressed":s,title:s?"Back to the schema graph":"Show core (genesis) data",children:[s?a.jsx(Vd,{className:"h-3.5 w-3.5"}):a.jsx(Fi,{className:"h-3.5 w-3.5"}),s?"Schema":"Core",!s&&e!==void 0&&a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:e})]})}function ay({data:e}){const t=e,n=t.className==="Folder";return a.jsxs("div",{className:ae("relative rounded-lg border bg-card shadow-sm w-[184px] transition-shadow",t.selected?"ring-2 ring-primary":"hover:shadow-md"),style:{borderLeft:`3px solid oklch(0.72 0.15 ${t.hue})`},children:[!t.virtual&&a.jsx(Ho,{anchorRef:Le(t.path),kind:"section",excerpt:`${t.title} (${t.className})`}),a.jsx(Ie,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsxs("div",{className:"px-2.5 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{style:{color:`oklch(0.82 0.14 ${t.hue})`},className:"shrink-0",children:t.icon?a.jsx(ge,{svg:t.icon,className:"h-5 w-5"}):n?a.jsx(on,{className:"h-5 w-5"}):a.jsx(Me,{className:"h-5 w-5"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-[13px] font-extrabold truncate leading-tight",children:t.title}),a.jsx("div",{className:"text-[10px] font-mono text-muted-foreground/70 truncate leading-tight",children:t.className})]})]}),t.fields.length>0&&a.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:t.fields.map(([s,o])=>a.jsxs("div",{className:"flex items-baseline gap-1 text-[10px] leading-tight",children:[a.jsx("span",{className:"font-mono text-muted-foreground/60 shrink-0",children:s}),a.jsx("span",{className:"truncate text-foreground/80",children:o})]},s))})]}),a.jsx(Ie,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}const cy={coreNode:ay};function ly({core:e,bundle:t,selectedPath:n,onSelect:s}){const{fitView:o}=Pt(),r=X(k=>k.setOpenAnchor),i=N.useMemo(()=>Bo(e),[e]),c=N.useMemo(()=>iy(e,t,i),[e,t,i]),[l,d]=N.useState([]),[u,h]=N.useState([]);N.useEffect(()=>{let k=!1;return Bn(c.nodes,c.edges).then(C=>{k||(d(C),h(Wn(c.edges)),requestAnimationFrame(()=>o({padding:.2,duration:400})))}),()=>{k=!0}},[c,o]);const f=N.useCallback(k=>d(C=>ls(k,C)),[]),p=N.useCallback(k=>h(C=>ds(k,C)),[]),[m,w]=N.useState(!0),[x,y]=N.useState(!0),j=N.useMemo(()=>l.filter(k=>{const C=k.data;return!(!m&&C.className==="Folder"||!x&&C.virtual)}),[l,x,m]),g=N.useMemo(()=>new Set(j.map(k=>k.id)),[j]),v=N.useMemo(()=>j.map(k=>{const C=k.data.path===n;return k.data.selected===C?k:{...k,data:{...k.data,selected:C}}}),[j,n]),E=N.useMemo(()=>u.filter(k=>!g.has(k.source)||!g.has(k.target)?!1:k.type==="tree"?m:x),[u,g,m,x]);return a.jsxs(Po,{nodes:v,edges:E,nodeTypes:cy,edgeTypes:Lo,onNodesChange:f,onEdgesChange:p,onNodeClick:(k,C)=>{const I=C.data;I.virtual||s(I.path)},onPaneClick:()=>{s(null),r(null)},minZoom:.15,nodesConnectable:!1,proOptions:{hideAttribution:!0},children:[a.jsx(To,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(Oo,{className:"!bg-card !border !border-border [&_button]:!bg-card [&_button]:!border-border [&_button]:!fill-foreground",showInteractive:!1}),a.jsx(zo,{pannable:!0,zoomable:!0,className:"!bg-card !border !border-border",nodeColor:k=>`oklch(0.6 0.13 ${k.data.hue})`,nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.7)"}),a.jsxs(tt,{position:"top-right",className:"flex gap-1.5",children:[a.jsxs(Ve,{size:"xs",variant:m?"default":"outline",onClick:()=>w(k=>!k),"aria-pressed":m,title:"Folders & the parent→child tree — toggle to focus on the semantic graph alone",children:[a.jsx(Mu,{className:"h-3.5 w-3.5"})," Structure"]}),a.jsxs(Ve,{size:"xs",variant:x?"default":"outline",onClick:()=>y(k=>!k),"aria-pressed":x,title:"Typed (semantic) edges — toggle to focus on the tree/organization alone",children:[a.jsx(mt,{className:"h-3.5 w-3.5"})," Semantics"]}),a.jsx(Bc,{})]})]})}function fn({anchor:e,excerpt:t,children:n,className:s}){const o=N.useId(),r=X(f=>f.openAnchorRef),i=X(f=>f.openAnchorId),c=r===e.ref&&(i===null||i===o),l=X(f=>f.setOpenAnchor),{threads:d,status:u,orphaned:h}=Hi(e.ref);return a.jsxs($t,{modal:!1,open:c,onOpenChange:f=>l(f?e.ref:null,f?o:null),children:[a.jsx(no,{asChild:!0,children:a.jsxs("span",{"data-anchor-ref":e.ref,"data-commentable":"",className:ae("group relative block",s),children:[n,a.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),l(c?null:e.ref,o)},title:`Comment on ${e.ref}`,className:ae("absolute right-1 top-1 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border bg-card text-muted-foreground shadow-sm transition-opacity hover:text-primary",c?"opacity-100":"opacity-40 group-hover:opacity-100"),children:a.jsx(Du,{className:"h-3 w-3"})}),d.length>0&&a.jsx(Fd,{count:d.length,status:u,orphaned:h,onClick:()=>l(c?null:e.ref,o),className:"absolute -right-1.5 -top-1.5 z-10"})]})}),a.jsx(Rt,{onInteractOutside:f=>f.preventDefault(),className:"max-h-[var(--radix-popover-content-available-height)] overflow-y-auto",children:a.jsx(so,{anchor:e,excerpt:t,threads:d,onClose:()=>l(null)})})]})}function dy({core:e,bundle:t,selectedPath:n}){const s=N.useMemo(()=>e.nodes.find(u=>u.path===n)??null,[e,n]),o=N.useMemo(()=>Bo(e),[e]);if(!s)return a.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground/70",children:"Select a core node to see what's set on it."});const r=o.get(s.className)??264,i=Yo(t,s.className),c=s.className==="Folder",l=Fo(s.data),d=e.edges.filter(u=>u.from===s.path||u.to===s.path);return a.jsxs("div",{className:"h-full overflow-y-auto",children:[a.jsx(fn,{anchor:{ref:Le(s.path),kind:"section"},excerpt:`${en(s)} (${s.className})`,className:"block",children:a.jsxs("div",{className:"flex items-center gap-2.5 border-b px-4 py-3",children:[a.jsx("span",{style:{color:`oklch(0.82 0.14 ${r})`},className:"shrink-0",children:i?a.jsx(ge,{svg:i,className:"h-7 w-7"}):c?a.jsx(on,{className:"h-6 w-6"}):a.jsx(Me,{className:"h-6 w-6"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-extrabold truncate",children:en(s)}),a.jsx("div",{className:"text-[11px] font-mono text-muted-foreground/70",children:s.className})]})]})}),a.jsxs("div",{className:"px-4 py-3",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Path"}),a.jsx("div",{className:"mt-1 break-all font-mono text-[11px] text-foreground/80",children:s.path})]}),a.jsxs("div",{className:"px-4 pb-3",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Data"}),l.length===0?a.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground/60",children:"No fields set."}):a.jsx("div",{className:"mt-1.5 flex flex-col gap-1.5",children:l.map(({key:u,label:h,value:f})=>a.jsxs("div",{className:"flex flex-col gap-0.5 rounded-md border bg-card/40 px-2.5 py-1.5",children:[a.jsx("span",{className:"font-mono text-[11px] text-muted-foreground/70",title:h===u?void 0:u,children:h}),a.jsx("span",{className:"break-words text-[13px] text-foreground/90",children:Wo(f)})]},u))})]}),d.length>0&&a.jsxs("div",{className:"px-4 pb-4",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Edges"}),a.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:d.map((u,h)=>{const f=u.from===s.path,p=f?u.to:u.from;return a.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[a.jsx(mt,{className:"h-3.5 w-3.5 shrink-0 text-amber-400"}),a.jsx("span",{className:"font-mono text-amber-300",children:u.edgeName}),a.jsx("span",{className:"text-muted-foreground/60",children:f?"→":"←"}),a.jsx("span",{className:"truncate text-foreground/80",title:p,children:Vo(p)})]},`${u.edgeName}-${h}`)})})]})]})}function uy(e){const t=new Set(e.nodes.map(r=>r.path)),n=new Map,s=[];for(const r of e.nodes)if(r.parent&&t.has(r.parent)){const i=n.get(r.parent)??[];i.push(r),n.set(r.parent,i)}else s.push(r);const o=r=>({node:r,children:(n.get(r.path)??[]).map(o)});return s.map(o)}function Wc({item:e,depth:t,bundle:n,hues:s,selectedPath:o,onSelect:r}){const[i,c]=N.useState(!0),l=e.node,d=e.children.length>0,u=o===l.path,h=s.get(l.className)??264,f=Yo(n,l.className),p=l.className==="Folder";return a.jsxs("div",{children:[a.jsxs("div",{className:ae("group/row flex items-center gap-0.5 pr-2 rounded-md hover:bg-accent/50",u&&"bg-accent text-accent-foreground"),style:{paddingLeft:6+t*12},children:[d?a.jsx("button",{type:"button",onClick:()=>c(m=>!m),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-white/5",title:i?"Collapse":"Expand",children:i?a.jsx(Gn,{className:"h-3 w-3"}):a.jsx(Un,{className:"h-3 w-3"})}):a.jsx("span",{className:"w-4 shrink-0"}),a.jsx(fn,{anchor:{ref:Le(l.path),kind:"section"},excerpt:`${en(l)} (${l.className})`,className:"flex-1 min-w-0",children:a.jsxs("button",{type:"button",onClick:()=>r(l.path),className:"flex w-full items-center gap-1.5 py-1 text-left min-w-0",children:[a.jsx("span",{style:{color:`oklch(0.8 0.13 ${h})`},className:"shrink-0",children:f?a.jsx(ge,{svg:f,className:"h-4 w-4"}):p?a.jsx(on,{className:"h-3.5 w-3.5"}):a.jsx(Me,{className:"h-3.5 w-3.5"})}),a.jsx("span",{className:"truncate font-bold",children:en(l)}),a.jsx("span",{className:"ml-auto text-[10px] font-mono text-muted-foreground/50 shrink-0",children:l.className})]})})]}),i&&d&&a.jsx("div",{children:e.children.map(m=>a.jsx(Wc,{item:m,depth:t+1,bundle:n,hues:s,selectedPath:o,onSelect:r},m.node.path))})]})}function fy({core:e,bundle:t,selectedPath:n,onSelect:s}){const o=N.useMemo(()=>Bo(e),[e]),r=N.useMemo(()=>uy(e),[e]);return a.jsxs("div",{className:"text-sm py-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 px-3 pb-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[a.jsx(Fi,{className:"h-3.5 w-3.5"})," Core",a.jsx("span",{className:"ml-auto tabular-nums text-muted-foreground/50",children:e.nodes.length})]}),r.length===0?a.jsx("p",{className:"px-3 pt-2 text-[12px] text-muted-foreground/60",children:e.error?e.error.message:"This domain defines no core (genesis) data."}):r.map(i=>a.jsx(Wc,{item:i,depth:0,bundle:t,hues:o,selectedPath:n,onSelect:s},i.node.path))]})}const Yc="kernel.astrale.ai",hy=new Set(["Node","Edge"]);function Yn(e,t){const n=e.ir;if(n)return typeof t=="string"?n.classes[t]:t.origin===n.domain?n.classes[t.name]:n.importedClassesByKey[Be(t)]}function py(e,t){return t.origin===e.ir?.domain?"local":t.origin===Yc?"kernel":"external"}function my(e,t){const n=e.ir?.classes[t];if(!n)return[];const s=new Set(Object.keys(n.properties)),o=new Set(Object.keys(n.methods)),r=new Set(s),i=new Set,c=new Set,l=[...n.extendsRefs??[]],d=[];for(;l.length>0;){const h=l.shift(),f=Be(h);if(c.has(f)||h.origin===Yc&&hy.has(h.name))continue;c.add(f);const p=Yn(e,h);if(!p)continue;l.push(...p.extendsRefs??[]);const m=Object.entries(p.properties).filter(([x])=>!r.has(x)).map(([x,y])=>[x,y,!(p.required??[]).includes(x)]),w=Object.entries(p.methods).filter(([x])=>!i.has(x)).map(([x,y])=>({name:x,method:y,overridden:o.has(x)}));for(const[x]of m)r.add(x);for(const{name:x}of w)i.add(x);m.length===0&&w.length===0||d.push({owner:h.name,ref:h,tier:py(e,h),...h.origin===e.ir?.domain?{}:{origin:h.origin},props:m,methods:w})}const u={local:0,external:1,kernel:2};return d.sort((h,f)=>u[h.tier]-u[f.tier])}function gy(e){return e.reduce((t,n)=>t+n.props.length+n.methods.length,0)}function xy({domainId:e,view:t,open:n,onOpenChange:s}){const o=Bd(e,t.slug,n),r=o.data,[i,c]=N.useState(""),[l,d]=N.useState(0),[u,h]=N.useState(!1),[f,p]=N.useState({phase:"idle"}),m=N.useRef("");N.useEffect(()=>{if(!n){m.current="",c(""),p({phase:"idle"});return}if(!r)return;const j=`${e}:${t.slug}:${r.instance??"none"}`;m.current!==j&&(m.current=j,c(r.targets.selected?.id??""))},[e,n,r,t.slug]);const w=!!r&&(!r.targetRequired||r.targets.items.some(j=>j.id===i)),x=n&&!u&&!!r?.instance&&w;N.useEffect(()=>{if(!x){p({phase:"idle"});return}let j=!1,g=null;return p({phase:"launching"}),_e.launchView(e,t.slug,i?{targetId:i}:{}).then(v=>{v.status==="ready"?(g=v.sessionId,j?_e.closeViewSession(e,v.sessionId):p({phase:"ready",session:v})):j||p({phase:"error",reason:v.reason})}).catch(v=>{j||p({phase:"error",reason:v instanceof Error?v.message:String(v)})}),()=>{j=!0,g&&_e.closeViewSession(e,g)}},[l,e,x,r?.instance,i,t.slug]),N.useEffect(()=>{if(f.phase!=="ready")return;const j=()=>{const g=`/api/domain/${encodeURIComponent(e)}/views/sessions/close`;navigator.sendBeacon(g,new Blob([JSON.stringify({sessionId:f.session.sessionId})],{type:"application/json"}))};return window.addEventListener("pagehide",j),()=>window.removeEventListener("pagehide",j)},[e,f]);const y=async()=>{if(!u){h(!0),p({phase:"idle"});try{await o.refetch(),d(j=>j+1)}catch(j){p({phase:"error",reason:j instanceof Error?j.message:String(j)})}finally{h(!1)}}};return a.jsx(Wd,{open:n,onOpenChange:s,children:a.jsxs(Yd,{className:"grid h-[90vh] w-[95vw] max-w-[1500px] grid-rows-[auto_auto_1fr] gap-0 overflow-hidden rounded-2xl p-0",children:[a.jsxs("header",{className:"flex min-w-0 items-center gap-3 border-b bg-card/95 px-4 py-3 pr-12",children:[a.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-sky-500/12 text-sky-400",children:a.jsx(ir,{className:"h-[18px] w-[18px]"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xd,{className:"truncate text-sm font-semibold",children:t.slug}),a.jsxs("code",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:["view.",t.slug]})]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:t.description??"Domain view preview"})]}),a.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[f.phase==="ready"&&a.jsxs("a",{href:f.session.pageUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-8 items-center gap-1.5 rounded-lg px-2.5 text-[11px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:[a.jsx(qd,{className:"h-3.5 w-3.5"})," Open separately"]}),a.jsx("button",{type:"button",onClick:()=>{y()},disabled:u,title:"Retry the CLI-resolved View session",className:"grid h-8 w-8 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-30",children:a.jsx(Zd,{className:ae("h-3.5 w-3.5",u&&"animate-spin")})})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-muted/15 px-4 py-3",children:[r?.targetRequired?a.jsx(yy,{result:r.targets,value:i,onChange:c,instance:r.instance}):a.jsxs("div",{className:"inline-flex h-9 items-center gap-2 rounded-xl border bg-background/60 px-3 text-[11px]",children:[a.jsx(Bi,{className:"h-3.5 w-3.5 text-emerald-400"}),a.jsx("span",{className:"font-medium",children:"Standalone view"}),a.jsx("span",{className:"text-muted-foreground",children:"No target required"})]}),a.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[a.jsxs("div",{className:ae("inline-flex h-9 items-center gap-2 rounded-xl border px-3 text-[10px]",r?.instance?"border-emerald-500/20 bg-emerald-500/8 text-emerald-200":"bg-background/60 text-muted-foreground"),title:"The Astrale CLI resolves the verified View placement installed on this instance.",children:[r?.instance?a.jsxs("span",{className:"relative flex h-2 w-2",children:[a.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-30"}),a.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-emerald-400"})]}):r?a.jsx(ho,{className:"h-3 w-3 text-amber-400"}):a.jsx($s,{className:"h-3 w-3 animate-spin"}),a.jsx(ir,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"font-medium",children:"CLI-resolved View"})]}),a.jsxs("div",{className:"h-9 rounded-xl border bg-background/60 px-3 py-1.5 text-right text-[9px] uppercase leading-tight tracking-wider text-muted-foreground",children:[a.jsx("div",{children:"Data instance"}),a.jsx("div",{className:"max-w-40 truncate text-[10px] font-medium normal-case tracking-normal text-foreground",children:r?.instance??"not selected"})]})]})]}),a.jsx("main",{className:"relative min-h-0 overflow-hidden bg-[#0d0d11]",children:f.phase==="ready"?a.jsx("iframe",{src:f.session.pageUrl,title:`${t.slug} preview`,className:"h-full w-full border-0 bg-white",allow:"clipboard-read; clipboard-write"},f.session.sessionId):a.jsx(vy,{loading:o.isLoading||u||f.phase==="launching",runtimeError:o.isError,runtime:r,targetId:i,sessionError:f.phase==="error"?f.reason:void 0,onRetry:()=>{y()}})})]})})}function yy({result:e,value:t,onChange:n,instance:s}){const[o,r]=N.useState(!1),[i,c]=N.useState(""),l=e.items.find(u=>u.id===t)??null,d=N.useMemo(()=>{const u=i.trim().toLocaleLowerCase();return u?e.items.filter(h=>[h.label,h.description,h.className,h.status,h.id].filter(Boolean).some(f=>f.toLocaleLowerCase().includes(u))):e.items},[e.items,i]);return a.jsxs($t,{open:o,onOpenChange:u=>{r(u),u||c("")},children:[a.jsx(oo,{asChild:!0,children:a.jsxs("button",{type:"button",className:ae("flex h-9 min-w-64 max-w-[28rem] items-center gap-2 rounded-xl border bg-background/60 px-3 text-left transition-colors hover:bg-accent/40",e.stale&&!l&&"border-amber-500/40"),children:[a.jsx("span",{className:ae("h-2 w-2 shrink-0 rounded-full",l?"bg-emerald-400":e.stale?"bg-amber-400":"bg-muted-foreground/30")}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block text-[9px] uppercase tracking-wider text-muted-foreground",children:"Target"}),a.jsx("span",{className:"block truncate text-[11px] font-medium",children:l?.label??e.stale?.label??"Select a target"})]}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:e.items.length}),a.jsx(Gd,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),a.jsxs(Rt,{side:"bottom",align:"start",className:"z-[70] w-[28rem] p-0",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[a.jsx(Wi,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.jsx("input",{autoFocus:!0,value:i,onChange:u=>c(u.target.value),placeholder:"Search visible targets…",className:"min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground/60"}),a.jsx("span",{className:"text-[9px] uppercase tracking-wider text-muted-foreground",children:s??"no instance"})]}),e.stale&&a.jsxs("div",{className:"m-2 flex gap-2 rounded-lg border border-amber-500/25 bg-amber-500/8 p-2.5 text-[11px] text-amber-200",children:[a.jsx(ho,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsxs("span",{children:[a.jsx("strong",{children:e.stale.label})," was remembered, but it was deleted or is no longer visible. Pick a replacement."]})]}),a.jsx("div",{className:"max-h-80 overflow-y-auto p-1.5",children:e.status==="unavailable"?a.jsx(bi,{children:e.reason??"Targets could not be queried."}):d.length===0?a.jsx(bi,{children:e.items.length===0?"No eligible targets are visible.":"No matches."}):d.map(u=>a.jsx(wy,{item:u,selected:u.id===t,onClick:()=>{n(u.id),r(!1)}},u.id))}),e.truncated&&a.jsx("div",{className:"border-t px-3 py-2 text-[10px] text-muted-foreground",children:"Showing the first 200 visible targets per class."})]})]})}function wy({item:e,selected:t,onClick:n}){return a.jsxs("button",{type:"button",onClick:n,className:ae("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-accent",t&&"bg-accent/70"),children:[a.jsx("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-lg bg-sky-500/10 text-[10px] font-semibold text-sky-300",children:e.className.slice(0,2).toUpperCase()}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate text-xs font-medium",children:e.label}),a.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:[e.className,e.description,e.status].filter(Boolean).join(" · ")})]}),a.jsx("code",{className:"text-[9px] text-muted-foreground/50",children:e.id.slice(0,8)}),t&&a.jsx(Bi,{className:"h-3.5 w-3.5 text-primary"})]})}function bi({children:e}){return a.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-muted-foreground",children:e})}function vy({loading:e,runtimeError:t,runtime:n,targetId:s,sessionError:o,onRetry:r}){if(e)return a.jsx(yt,{icon:a.jsx($s,{className:"animate-spin"}),title:"Resolving installed View",children:"The Astrale CLI is resolving the View and connecting it to the active data instance."});if(t)return a.jsx(yt,{icon:a.jsx(ar,{}),title:"The Studio runtime did not respond",action:r,children:"Retry the View session. The schema canvas is unaffected."});if(!n?.instance)return a.jsx(yt,{icon:a.jsx(ar,{}),title:"Choose an Astrale instance",children:"The installed View reads data from the active instance in the Studio header."});if(n.targetRequired&&!n.targets.items.some(i=>i.id===s)){const i=n.targets.stale;return a.jsx(yt,{icon:a.jsx(Wi,{}),title:i?"The remembered target is gone":"Choose what this view should open",children:i?`${i.label} was deleted or is no longer visible. Use the target selector above.`:n.targets.items.length?`${n.targets.items.length} visible candidate${n.targets.items.length===1?"":"s"} found on ${n.instance}.`:n.targets.reason||"No eligible targets are currently visible."})}return o?a.jsx(yt,{icon:a.jsx(ho,{}),title:"The view could not be opened",action:r,children:o}):a.jsx(yt,{icon:a.jsx($s,{className:"animate-spin"}),title:"Opening view session",children:"Studio is preparing the authenticated CLI-owned Shell session."})}function yt({icon:e,title:t,children:n,action:s}){return a.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-8 text-center text-zinc-200",children:[a.jsx("div",{className:"mb-3 grid h-11 w-11 place-items-center rounded-2xl border border-white/10 bg-white/5 text-zinc-400 [&_svg]:h-5 [&_svg]:w-5",children:e}),a.jsx("h2",{className:"text-sm font-semibold",children:t}),a.jsx("div",{className:"mt-1.5 max-w-md text-[12px] leading-relaxed text-zinc-500",children:n}),s&&a.jsx("button",{type:"button",onClick:s,className:"mt-4 rounded-lg border border-white/10 bg-white/5 px-3 py-1.5 text-[11px] transition-colors hover:bg-white/10",children:"Restart preview"})]})}function by({kind:e,className:t}){const n=e==="inline-html"?Qd:e==="spa"?sn:gt;return a.jsx(n,{className:t})}function Xn({domainId:e,view:t,icon:n}){const[s,o]=N.useState(!1),r=Ud(t.drift),i=[t.kind,t.mount,t.auth,t.unbound?"standalone":"targeted"].filter(Boolean).join(" · "),c=`view.${t.slug}`;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-domain-id":e,"data-anchor-ref":c,"data-anchor-excerpt":t.slug,className:"group flex w-full items-center gap-2.5 rounded-lg px-2 py-1.5 transition-colors hover:bg-accent/60",children:[a.jsxs("button",{type:"button",onClick:()=>o(!0),title:"Open live view",className:"flex min-w-0 flex-1 items-center gap-2.5 text-left",children:[a.jsx(ve,{tone:"sky",size:"sm",children:n?a.jsx(ge,{svg:n,className:"h-3.5 w-3.5"}):a.jsx(by,{kind:t.kind,className:"h-3.5 w-3.5"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:t.slug}),a.jsx("div",{className:"truncate text-[11px] leading-tight text-muted-foreground/70",children:i})]}),r&&a.jsxs("span",{className:ae("inline-flex shrink-0 items-center gap-1 text-[10px] font-medium",r.tone==="warn"?"text-warning":"text-muted-foreground/70"),children:[r.tone==="warn"&&a.jsx(ct,{className:"h-3 w-3"}),r.text]}),a.jsx(Kd,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/0 transition-colors group-hover:text-primary"})]}),a.jsx(Dt,{domainId:e,anchorRef:{ref:c,kind:"section",file:t.file},excerpt:t.slug,className:"ml-1"})]}),s&&a.jsx(xy,{domainId:e,view:t,open:s,onOpenChange:o})]})}function Ny({domainId:e,model:t}){const{data:n}=ro(e),s=X(i=>i.selectClass),o=[...t.byClass.keys()].sort(),r=i=>n?.ir?.classes[i]?.icon;return a.jsx(At,{className:"h-full",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Views"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:t.all.length}),t.hasDrift&&a.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-warning",children:[a.jsx(ct,{className:"h-3.5 w-3.5"})," drift"]})]}),t.all.length===0&&a.jsx(Ft,{icon:a.jsx(sn,{}),title:"No views",hint:"This domain declares no views."}),o.map(i=>{const c=r(i),l=t.byClass.get(i);return a.jsxs("section",{className:"mb-6",children:[a.jsxs("button",{type:"button",onClick:()=>s(`class.${i}`),title:`Open ${i}`,className:"group mb-1.5 flex w-full items-center gap-1.5 px-1 text-left",children:[a.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:c?a.jsx(ge,{svg:c,className:"h-4 w-4"}):a.jsx(Me,{className:"h-4 w-4"})}),a.jsx("span",{className:"text-[13px] font-semibold transition-colors group-hover:text-primary",children:i}),a.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:l.length}),a.jsx(Yi,{className:"ml-auto h-3.5 w-3.5 text-muted-foreground/0 transition-colors group-hover:text-muted-foreground/60"})]}),a.jsx("div",{className:"flex flex-col gap-0.5",children:l.map(d=>a.jsx(Xn,{domainId:e,view:d,icon:c},d.slug))})]},i)}),t.unbound.length>0&&a.jsx(qe,{label:"Standalone",hint:"opens without a target",children:a.jsx("div",{className:"flex flex-col gap-0.5",children:t.unbound.map(i=>a.jsx(Xn,{domainId:e,view:i},i.slug))})}),t.orphanRoutes.length>0&&a.jsx(qe,{label:"Orphan client routes",hint:"no declaring view",children:a.jsx("div",{className:"flex flex-col gap-1",children:t.orphanRoutes.map(i=>a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-2 py-1.5 text-[12px] text-warning",children:[a.jsx(ct,{className:"h-3.5 w-3.5 shrink-0"}),a.jsx("code",{className:"truncate",children:i})]},i))})})]})})}function Ys(e){return e?e.max===null?e.min<=0?"*":`${e.min}..*`:e.min===e.max?`${e.max}`:`${e.min}..${e.max}`:"*"}const Nn=e=>!e||e.max===null||e.max>1,Ni=e=>!e||e.min<=0;function Xs(e){return e?e==="kernel.astrale.ai"?"kernel":e.split(".")[0]:"this domain"}function Xc({doc:e}){return a.jsxs(Kn,{openDelay:80,children:[a.jsx(Qn,{asChild:!0,children:a.jsx("button",{type:"button","aria-label":"Description",className:"text-muted-foreground/40 hover:text-foreground transition-colors",children:a.jsx(au,{className:"h-3.5 w-3.5"})})}),a.jsx(Jn,{className:"w-auto max-w-xs text-[13px] leading-relaxed text-muted-foreground",children:e})]})}function qc({bundle:e,refBase:t,pname:n,schema:s,optional:o}){const r=`${t}.property.${n}`,i=e.overlay.sourceSpans[r]?.doc,c=Xi(s,o),l=c.icon,d=e.overlay.annotations.filter(h=>h.target===r),u=Jd(s);return a.jsx(io,{anchorRef:r,anchorExcerpt:n,leading:a.jsx(ve,{tone:"sky",size:"sm",children:a.jsx(l,{})}),title:a.jsxs("span",{className:"flex items-center gap-1.5",children:[n,i&&a.jsx(Xc,{doc:i}),c.optional&&a.jsx(ye,{tone:"default",children:"optional"}),d.map(h=>a.jsx(ye,{tone:"warning",title:h.message,children:h.code},h.code))]}),subtitle:a.jsxs(Kn,{openDelay:140,children:[a.jsx(Qn,{asChild:!0,children:a.jsx("span",{className:"cursor-default",children:c.label})}),a.jsx(Jn,{className:"w-auto max-w-sm",children:a.jsx(eu,{items:[{label:"type",value:tu(u)+(c.optional?" (optional)":"")},{label:"key",value:r}]})})]}),trailing:a.jsx(Dt,{anchorRef:{ref:r,kind:"schema",file:e.overlay.sourceSpans[r]?.file},excerpt:n})})}function Zc({bundle:e,owner:t,ownerKind:n="class",handlerOwnerLocal:s=!0,refBase:o,mname:r,method:i,overridden:c=!1}){const l=`${o}.method.${r}`,d=s?nu(e.overlay.handlerLinks,t,r,n):void 0,u=e.overlay.sourceSpans[l]?.doc,h=su(i),f=h.icon,p=d&&!d.implemented,m=d?.unlinked;return a.jsxs(kt,{className:"px-3 py-2.5","data-anchor-ref":l,"data-anchor-excerpt":`${t}.${r}`,"data-commentable":"",children:[a.jsx(io,{className:"px-0 py-0 hover:bg-transparent",leading:a.jsx(ve,{tone:h.tone,size:"sm",children:a.jsx(f,{})}),title:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:ae(c&&"line-through text-muted-foreground/70"),children:r}),a.jsx(ou,{method:i}),u&&a.jsx(Xc,{doc:u}),i.inheritance==="sealed"&&a.jsx(ye,{tone:"warning",children:"sealed"}),i.inheritance==="abstract"&&a.jsx(ye,{tone:"fuchsia",children:"contract"}),c&&a.jsx(ye,{tone:"default",children:"overridden"}),p&&a.jsx(ye,{tone:"warning",children:"needs handler"}),m&&a.jsx(ye,{tone:"default",children:"unlinked"})]}),trailing:a.jsx(Dt,{anchorRef:{ref:l,kind:"schema",file:e.overlay.sourceSpans[l]?.file},excerpt:`${t}.${r}`})}),a.jsx("div",{className:"pl-[2.625rem] pt-1.5",children:a.jsx(ru,{label:"Details",children:a.jsx(jy,{method:i,link:d,owner:t})})})]})}function jy({method:e,link:t,owner:n}){const s=Object.entries(e.input.properties??{}),o=new Set(e.input.required??[]);return a.jsxs("div",{className:"space-y-3 pb-1",children:[s.length>0&&a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Input"}),a.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[13px]",children:s.map(([r,i])=>{const c=!o.has(r),l=Xi(i,c);return a.jsxs("span",{className:"inline-flex items-baseline gap-1.5",children:[a.jsx("span",{className:"font-medium",children:r}),a.jsxs("span",{className:"text-muted-foreground",children:[l.label,l.optional?"?":""]})]},r)})})]}),a.jsx(ky,{owner:n,isStatic:e.static}),t?.kernelCalls&&t.kernelCalls.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.kernelCalls.map(r=>a.jsx(ye,{tone:"outline",className:"font-mono",children:r},r))}),a.jsxs("div",{className:"pt-0.5",children:[a.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"returns "}),e.output.mode==="binary"?a.jsx(ye,{tone:"outline",children:"Binary"}):e.output.mode==="stream"?a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx(ye,{tone:"outline",children:"Stream"}),a.jsx(or,{schema:e.output.item})]}):a.jsx(or,{schema:e.output.schema})]})]})}function ky({owner:e,isStatic:t}){return a.jsxs(Kn,{openDelay:80,children:[a.jsx(Qn,{asChild:!0,children:a.jsx("button",{type:"button",className:"cursor-default rounded-full",children:a.jsxs(ye,{tone:"outline",children:[t?a.jsx(ao,{className:"h-3 w-3"}):a.jsx(Me,{className:"h-3 w-3"})," ",t?`on the ${e} type`:`on a ${e}`]})})}),a.jsx(Jn,{className:"w-auto max-w-[15rem]",children:a.jsx("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:t?a.jsxs(a.Fragment,{children:["Acts on the ",a.jsxs("span",{className:"font-medium text-foreground/90",children:[e," type"]}),"."," ",a.jsx("span",{className:"text-muted-foreground/60",children:"(static)"})]}):a.jsxs(a.Fragment,{children:["Acts on a single ",a.jsx("span",{className:"font-medium text-foreground/90",children:e}),"."," ",a.jsx("span",{className:"text-muted-foreground/60",children:"(instance)"})]})})})]})}function Ey({bundle:e,groups:t,originIcon:n}){const s=X(o=>o.selectClass);return a.jsx(qe,{label:"Inherited",hint:`${gy(t)}`,children:a.jsx("div",{className:"space-y-5",children:t.map(o=>{const r=o.tier==="local"?"border-l-fuchsia-500/40":o.tier==="external"?"border-l-sky-500/40":"border-l-border",i=o.tier==="local"?"fuchsia":o.tier==="external"?"sky":"muted",c=o.ref.origin===e.ir?.domain?`class.${o.owner}`:`class.${Be(o.ref)}`;return a.jsxs("div",{className:ae("border-l-2 pl-3.5",r),children:[a.jsxs("button",{type:"button",onClick:()=>s(c),title:o.origin??"this domain",className:"group/ih mb-2.5 flex w-full items-center gap-2.5 text-left",children:[a.jsx(ve,{tone:i,size:"sm",children:a.jsx(Cy,{tier:o.tier,iconSvg:n(o.origin)})}),a.jsx("span",{className:"text-sm font-semibold tracking-tight group-hover/ih:text-foreground transition-colors",children:o.owner}),a.jsx(ye,{tone:o.tier==="local"?"fuchsia":"outline",children:o.tier==="local"?"base class":Xs(o.origin)}),a.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[11px] text-muted-foreground/50 group-hover/ih:text-muted-foreground transition-colors",children:["inherited ",a.jsx(iu,{className:"h-3.5 w-3.5"})]})]}),a.jsxs("div",{className:"space-y-2.5",children:[o.props.length>0&&a.jsx(kt,{className:"divide-y divide-border/70",children:o.props.map(([l,d,u])=>a.jsx(qc,{bundle:e,refBase:c,pname:l,schema:d,optional:u},`p-${l}`))}),o.methods.map(l=>a.jsx(Zc,{bundle:e,owner:o.owner,ownerKind:"class",handlerOwnerLocal:o.tier==="local",refBase:c,mname:l.name,method:l.method,overridden:l.overridden},`m-${l.name}`))]})]},c)})})})}function Cy({tier:e,iconSvg:t}){return e==="local"?a.jsx(Me,{}):t?a.jsx(ge,{svg:t,className:"h-4 w-4"}):e==="kernel"?a.jsx($u,{}):a.jsx(gt,{})}function Sy({bundle:e,endpoints:t,edgeName:n}){const[s,o]=t;return a.jsx(kt,{className:"px-3 py-5",children:a.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-stretch gap-1",children:[a.jsx(ji,{bundle:e,endpoint:s,edgeName:n}),a.jsx(_y,{edgeName:n,from:s,to:o}),a.jsx(ji,{bundle:e,endpoint:o,edgeName:n})]})})}function ji({bundle:e,endpoint:t,edgeName:n}){const s=X(f=>f.selectClass);if(!t)return null;const o=e.ir;if(!o)return null;const r=t.refs!==void 0?t.refs.filter(co).map(f=>({name:f.name,ref:f})):t.types.map(f=>({name:f}));r.length===0&&r.push({name:"—"});const i=t.cardinality,c=t.name?lo(`edge.${n}.endpoint.${t.name}`,t.name):{},l=({name:f,ref:p})=>{if(p){const x=p.origin===o.domain,y=x?o.classes[f]:Yn(e,p),j=!!y;return{t:f,key:Be(p),origin:x?void 0:p.origin,resolvable:j,selectionId:x?`class.${p.name}`:`class.${Be(p)}`,icon:y?.icon}}const m=o.classes[f],w=!!m;return{t:f,key:`class:${f}`,origin:void 0,resolvable:w,selectionId:w?`class.${f}`:void 0,icon:m?.icon}},d=f=>()=>{f.resolvable&&f.selectionId&&s(f.selectionId)},u=a.jsx("div",{className:"inline-flex max-w-full items-center rounded-full bg-muted/60 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/80",children:a.jsx("span",{className:"truncate",children:t.name})}),h=a.jsx("span",{className:"inline-flex items-center rounded-full border border-border/70 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground/80",title:"declared cardinality",children:Ys(i)});if(r.length===1){const f=l(r[0]);return a.jsxs("button",{type:"button",onClick:f.resolvable?d(f):void 0,disabled:!f.resolvable,title:f.resolvable?`Open ${f.t}`:f.origin?`${f.t} · ${f.origin}`:f.t,...c,className:ae("group/ep flex flex-col items-center gap-2.5 rounded-xl px-2 py-3 text-center min-w-0 transition-colors",f.resolvable?"hover:bg-accent/60 cursor-pointer":"cursor-default"),children:[a.jsx(ve,{tone:f.origin?"sky":"violet",size:"lg",className:"transition-transform group-hover/ep:-translate-y-0.5",children:f.icon?a.jsx(ge,{svg:f.icon,className:"h-5 w-5"}):a.jsx(Me,{})}),a.jsxs("div",{className:"min-w-0 w-full space-y-1.5",children:[a.jsx("div",{className:"text-sm font-bold break-words leading-tight",children:f.t}),a.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1",children:[u,h]})]})]})}return a.jsxs("div",{...c,className:"flex flex-col items-center gap-2.5 rounded-xl px-2 py-3 text-center min-w-0",children:[a.jsx("div",{className:"flex flex-wrap items-center justify-center gap-1.5",children:r.map(f=>{const p=l(f);return a.jsxs("button",{type:"button",onClick:p.resolvable?d(p):void 0,disabled:!p.resolvable,title:p.resolvable?`Open ${p.t}`:p.origin?`${p.t} · ${p.origin}`:p.t,className:ae("inline-flex items-center gap-1.5 rounded-lg border border-border/70 pl-1 pr-2 py-1 transition-colors",p.resolvable?"hover:bg-accent/60 cursor-pointer":"cursor-default"),children:[a.jsx(ve,{tone:p.origin?"sky":"violet",size:"sm",children:p.icon?a.jsx(ge,{svg:p.icon,className:"h-3.5 w-3.5"}):a.jsx(Me,{})}),a.jsx("span",{className:"text-[13px] font-semibold",children:p.t})]},p.key)})}),a.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1",children:[a.jsx("span",{className:"text-[10px] lowercase tracking-wide text-muted-foreground/60",children:"any of"}),u,h]})]})}function _y({edgeName:e,from:t,to:n}){const s=t?.cardinality,o=n?.cardinality,r=`${Nn(s)?"many":"one"}-to-${Nn(o)?"many":"one"}`;return a.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 self-center px-1.5 min-w-[84px]",children:[a.jsxs("div",{className:"flex w-full items-center text-muted-foreground/45",children:[a.jsx(ki,{many:Nn(s),optional:Ni(s),side:"left"}),a.jsx("span",{className:"h-px flex-1 bg-border"}),a.jsx(Yi,{className:"h-[18px] w-[18px] shrink-0 text-muted-foreground/70"}),a.jsx("span",{className:"h-px flex-1 bg-border"}),a.jsx(ki,{many:Nn(o),optional:Ni(o),side:"right"})]}),a.jsxs(Kn,{openDelay:80,children:[a.jsx(Qn,{asChild:!0,children:a.jsx("button",{type:"button",className:"rounded-full border border-border/70 px-2 py-0.5 text-[10px] font-medium text-muted-foreground/75 transition-colors hover:text-muted-foreground cursor-default",children:r})}),a.jsx(Jn,{className:"w-60",children:a.jsxs("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:[a.jsx("span",{className:"font-mono text-foreground/90",children:e})," links"," ",a.jsx("span",{className:"font-mono text-foreground/90",children:Ys(s)})," ",t?.name," to"," ",a.jsx("span",{className:"font-mono text-foreground/90",children:Ys(o)})," ",n?.name,"."]})})]})]})}function ki({many:e,optional:t,side:n}){return a.jsx("svg",{viewBox:"0 0 24 16",className:ae("h-4 w-6 shrink-0",n==="right"&&"rotate-180"),fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e?a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M22 8 L9 2 M22 8 L9 8 M22 8 L9 14"}),!t&&a.jsx("circle",{cx:"16",cy:"8",r:"2.2",fill:"currentColor",stroke:"none"})]}):a.jsx("circle",{cx:"9",cy:"8",r:"3",fill:t?"none":"currentColor",stroke:t?"currentColor":"none"})})}function Gc(){const e=X(n=>n.back);return X(n=>n.selectionHistory.length>0)?a.jsx("div",{className:"px-3 pt-3",children:a.jsxs("button",{type:"button",onClick:()=>e(),title:"Back to previous selection",className:"group inline-flex items-center gap-1 rounded-md px-2 py-1 text-[12px] text-muted-foreground/55 transition-colors hover:bg-accent/50 hover:text-muted-foreground",children:[a.jsx(ju,{className:"h-3.5 w-3.5 transition-transform group-hover:-translate-x-0.5"}),"Back"]})}):null}function Uc({bundle:e,selected:t}){const n=e.ir,s=X(E=>E.selectClass),{data:o}=nn(),r=uo(e.domainId),i=E=>E?o?.find(k=>k.origin===E)?.icon:void 0;if(!n||!t)return a.jsx("div",{className:"h-full flex items-center justify-center px-6",children:a.jsx(Ft,{icon:a.jsx(cu,{}),title:"Nothing selected",hint:"Pick a Class or relationship to inspect its properties, methods, handlers, and Views."})});if(t.startsWith("module."))return a.jsx(My,{bundle:e,path:t.slice(7)});const c=t.startsWith("class.")?t.slice(6):t,l=lu(c),d=l===void 0||l.origin===n.domain,u=l?.name??c,h=d?n.classes[u]:Yn(e,l);if(!h)return a.jsx("div",{className:"h-full flex items-center justify-center px-6",children:a.jsx(Ft,{title:"Not found",hint:t})});const f=l??{origin:n.domain,kind:"class",name:u},p=h.type==="edge",w=d?du(p?"edge":"class",u):`class.${Be(f)}`,x=d?e.overlay.sourceSpans[w]:void 0,y=Object.entries(h.properties),j=Object.entries(h.methods),g=d&&!p?my(e,u):[],v=d&&!p?uu(r,u):[];return a.jsxs("div",{className:"h-full overflow-y-auto",...lo(w,u),children:[a.jsx(Gc,{}),a.jsxs("div",{className:"px-5 py-6 space-y-7",children:[a.jsxs("header",{className:"group space-y-3",children:[a.jsxs("div",{className:"flex items-start gap-3.5",children:[a.jsx(ve,{tone:"violet",size:"lg",children:h.icon?a.jsx(ge,{svg:h.icon,className:"h-5 w-5"}):p?a.jsx(mt,{}):a.jsx(Me,{})}),a.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-lg font-extrabold tracking-tight truncate",children:u}),p&&a.jsx(ye,{tone:"outline",children:"edge"}),!d&&a.jsx(ye,{tone:"outline",children:Xs(f.origin)}),a.jsx(Dt,{anchorRef:{ref:w,kind:"schema",file:x?.file},excerpt:u,className:"ml-auto"})]}),(x?.doc??h.description)&&a.jsx("p",{className:"text-[13px] text-muted-foreground mt-1 leading-relaxed",children:x?.doc??h.description})]})]}),(h.extendsRefs??[]).length>0&&a.jsx("div",{className:"flex flex-wrap items-center gap-1.5 pl-[3.25rem]",children:(h.extendsRefs??[]).map(E=>{const k=Yn(e,E)!==void 0,C=E.origin===n.domain?`class.${E.name}`:`class.${Be(E)}`;return a.jsx("button",{type:"button",disabled:!k,onClick:()=>k&&s(C),children:a.jsxs(ye,{tone:"outline",children:["extends ",E.name,E.origin===n.domain?"":` · ${Xs(E.origin)}`]})},Be(E))})})]}),p&&(h.endpoints?.length??0)>=2&&a.jsx(qe,{label:"Relationship",children:a.jsx(Sy,{bundle:e,endpoints:h.endpoints,edgeName:u})}),y.length>0&&a.jsx(qe,{label:"Properties",hint:`${y.length}`,children:a.jsx(kt,{className:"divide-y divide-border/70",children:y.map(([E,k])=>a.jsx(qc,{bundle:e,refBase:w,pname:E,schema:k,optional:!(h.required??[]).includes(E)},E))})}),j.length>0&&a.jsx(qe,{label:"Methods",hint:j.length,children:a.jsx("div",{className:"space-y-2.5",children:j.map(([E,k])=>a.jsx(Zc,{bundle:e,owner:u,ownerKind:"class",handlerOwnerLocal:d,refBase:w,mname:E,method:k},E))})}),v.length>0&&a.jsx(qe,{label:"Views",hint:`${v.length}`,children:a.jsx("div",{className:"flex flex-col gap-0.5",children:v.map(E=>a.jsx(Xn,{domainId:e.domainId,view:E,icon:h.icon},E.slug))})}),g.length>0&&a.jsx(Ey,{bundle:e,groups:g,originIcon:i}),y.length===0&&j.length===0&&g.length===0&&!p&&a.jsx(Ft,{title:"No properties or methods",hint:"This Class declares no own members."})]})]})}function My({bundle:e,path:t}){const n=X(r=>r.selectClass),s=fu(e,t),o=r=>a.jsx(io,{onClick:()=>n(r.selectId),anchorRef:r.ref,anchorExcerpt:r.name,leading:a.jsx(ve,{tone:r.kind==="edge"?"amber":"sky",size:"sm",children:r.icon?a.jsx(ge,{svg:r.icon,className:"h-4 w-4"}):r.kind==="edge"?a.jsx(mt,{}):a.jsx(Me,{})}),title:r.name},r.selectId);return a.jsxs("div",{className:"h-full overflow-y-auto",...lo(`module.${t}`,s.label),children:[a.jsx(Gc,{}),a.jsxs("div",{className:"px-5 py-6 space-y-7",children:[a.jsxs("header",{className:"flex items-start gap-3.5",children:[a.jsx(ve,{tone:"muted",size:"lg",style:{color:`oklch(0.82 0.12 ${s.hue})`},children:a.jsx(on,{})}),a.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[a.jsx("h2",{className:"text-lg font-extrabold tracking-tight truncate",children:s.label}),a.jsxs("p",{className:"text-[13px] text-muted-foreground mt-1",children:[s.classes.length," ",s.classes.length===1?"class":"classes",s.edges.length>0&&` · ${s.edges.length} relationship${s.edges.length===1?"":"s"}`]})]})]}),s.classes.length>0&&a.jsx(qe,{label:"Classes",children:a.jsx(kt,{className:"divide-y divide-border/70",children:s.classes.map(o)})}),s.edges.length>0&&a.jsx(qe,{label:"Relationships",children:a.jsx(kt,{className:"divide-y divide-border/70",children:s.edges.map(o)})})]})]})}function Kc(e,t){return`extmember.${e}.class.${t}`}function qs(e){return e?e.refs!==void 0?e.refs.filter(co).map(t=>({name:t.name,ref:t})):e.types.map(t=>({name:t})):[]}function Qc(e,t){const n=qs(t).flatMap(({name:s,ref:o})=>(o===void 0||o.origin===e.domain)&&e.classes[s]?.type==="node"?[s]:[]);return[...new Set(n)].map(s=>({className:s}))}function Jc(e){const t=e.ir;if(!t)return[];const n=[];for(const[s,o]of Object.entries(t.classes)){if(o.type!=="edge"||!o.endpoints)continue;const r=o.endpoints[0],i=o.endpoints[1];if(!(!r||!i))for(const[c,l]of[[r,i],[i,r]]){const d=qs(c).filter(({name:h,ref:f})=>(f===void 0||f.origin===t.domain)&&t.classes[h]?.type==="node"),u=qs(l).flatMap(({name:h,ref:f})=>{if(f===void 0||f.origin===t.domain)return[];const p=t.importsByKey[Be(f)];return p===void 0?[]:[{name:h,ref:p.ref}]});for(const h of u)for(const f of d)n.push({edge:s,from:f.name,origin:h.ref.origin,to:h.name,...f.ref===void 0?{}:{fromRef:f.ref},toRef:h.ref,fromCard:c.cardinality,toCard:l.cardinality})}}return n}function el(e){const t=new Map;for(const n of Jc(e)){const s=t.get(n.origin)??new Map;s.set(Be(n.toRef),{name:n.to,ref:n.toRef}),t.set(n.origin,s)}return[...t].map(([n,s])=>({origin:n,kind:n==="kernel.astrale.ai"?"kernel":"external",members:[...s.values()].sort((o,r)=>o.name.localeCompare(r.name))})).sort((n,s)=>n.kind===s.kind?n.origin.localeCompare(s.origin):n.kind==="kernel"?1:-1)}const Iy={hidden:{},showInheritedEdges:!0},tn=e=>qi("class",e),tl=e=>qi("edge",e),Zs=e=>`domain.${e}`;function Pe(e,t){return t[e]===!0}function Ei(e,t){if(e.showInheritedEdges!==t.showInheritedEdges)return!1;const n=Object.keys(e.hidden);return n.length===Object.keys(t.hidden).length&&n.every(s=>t.hidden[s])}function $y(e,t){return!Pe(tn(e),t)}function Ry(e,t){return!Pe(Zs(e),t)}function nl(e,t,n){return!Pe(tl(e.edgeName),t)&&!Pe(tn(e.aClass),t)&&!Pe(tn(e.bClass),t)}const Gs="domain.import.",sl=e=>`${Gs}${e}`;function ol(){const{data:e}=nn(),t=new Map((e??[]).map(n=>[n.origin,n]));return n=>t.get(n)??{name:n.split(".")[0]||n,icon:""}}function Ay({domain:e}){const t=ol(),n=X(c=>Pe(Zs(e.origin),c.hidden)),s=X(c=>c.toggleHidden),o=t(e.origin),r=e.kind==="kernel"?"violet":"emerald",i=e.members.length;return a.jsxs("div",{className:ae("group flex items-center gap-2 rounded-lg px-1.5 py-1 transition-opacity",n&&"opacity-50"),children:[a.jsx(ve,{tone:r,size:"sm",children:o.icon?a.jsx(ge,{svg:o.icon,className:"h-3.5 w-3.5"}):a.jsx(gt,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:o.name}),a.jsxs("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:[i," linked ",i===1?"type":"types"]})]}),a.jsx("button",{type:"button",onClick:()=>s(Zs(e.origin)),title:n?"Show in canvas":"Hide in canvas",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent/60 hover:text-foreground",children:n?a.jsx(Zi,{className:"h-3.5 w-3.5"}):a.jsx(Gi,{className:"h-3.5 w-3.5"})})]})}function Dy({origin:e}){const n=ol()(e);return a.jsx(fn,{anchor:{ref:sl(e),kind:"section"},excerpt:`Import ${n.name}`,children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-1.5 py-1",children:[a.jsx(ve,{tone:"amber",size:"sm",children:n.icon?a.jsx(ge,{svg:n.icon,className:"h-3.5 w-3.5"}):a.jsx(gt,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:n.name}),a.jsx("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:"import requested"})]})]})})}function Py({domainId:e,taken:t}){const{data:n}=nn(),{create:s}=Ui(e),o=X(c=>c.setOpenAnchor),r=c=>{const l=sl(c.origin);s.mutate({anchors:[c.origin],anchorRefs:[{ref:l,kind:"section"}],text:`Import the ${c.name} domain (${c.origin}) — add it to this domain's imports and wire up the types we depend on.`,firstRole:"user",type:"text"},{onSuccess:()=>{o(l),In.success("Import requested — add the why/how in the comment")},onError:d=>In.error(String(d))})},i=(n??[]).filter(c=>c.kind!=="kernel"&&c.origin!==e&&!t.has(c.origin));return a.jsxs($t,{children:[a.jsx(oo,{asChild:!0,children:a.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[a.jsx(ta,{className:"h-3.5 w-3.5"}),"Import a domain"]})}),a.jsxs(Rt,{align:"start",side:"top",className:"w-64 p-1.5",children:[a.jsx("div",{className:"px-1.5 pb-1.5 pt-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Catalog"}),i.length===0?a.jsx("div",{className:"px-1.5 py-3 text-center text-xs text-muted-foreground/60",children:"Everything imported"}):a.jsx("div",{className:"flex flex-col gap-0.5",children:i.map(c=>a.jsxs("button",{type:"button",onClick:()=>r(c),disabled:s.isPending,className:"group/imp flex items-center gap-2.5 rounded-lg px-1.5 py-1.5 text-left transition-colors hover:bg-accent/60 disabled:opacity-50",children:[a.jsx(ve,{tone:c.kind==="external"?"emerald":"sky",size:"sm",children:c.icon?a.jsx(ge,{svg:c.icon,className:"h-3.5 w-3.5"}):a.jsx(gt,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:c.name}),a.jsx("div",{className:"truncate text-[11px] text-muted-foreground/70 leading-tight",children:c.description})]}),a.jsx("span",{className:"shrink-0 text-[11px] font-medium text-primary opacity-0 transition-opacity group-hover/imp:opacity-100",children:"Import"})]},c.origin))})]})]})}function Ty({domainId:e}){const{data:t}=ro(e),{data:n}=fo(e),s=N.useMemo(()=>t?el(t):[],[t]),o=N.useMemo(()=>new Set(s.map(c=>c.origin)),[s]),r=N.useMemo(()=>{const c=new Set(["kernel.astrale.ai",...o]);for(const l of t?.overlay.requires??[])c.add(l);for(const l of t?.overlay.crossDomainImports??[])c.add(l.origin);return c},[o,t]),i=N.useMemo(()=>{const c=new Set,l=[];for(const d of n?.comments??[])if(d.status==="open")for(const u of d.anchorRefs){if(!u.ref.startsWith(Gs))continue;const h=u.ref.slice(Gs.length);o.has(h)||c.has(h)||(c.add(h),l.push(h))}return l},[n,o]);return a.jsx(At,{className:"h-full",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Domains"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:s.length})]}),s.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Imported domains"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:s.map(c=>a.jsx(Ay,{domain:c},c.origin))})]}),i.length>0&&a.jsxs(a.Fragment,{children:[s.length>0&&a.jsx(Mn,{className:"my-2 opacity-60"}),a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Requested"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:i.map(c=>a.jsx(Dy,{origin:c},c))})]}),s.length===0&&i.length===0&&a.jsx("p",{className:"px-2 pb-1 pt-0.5 text-[11px] text-muted-foreground/60",children:"No imported domains yet."}),a.jsx(Mn,{className:"my-3 opacity-60"}),a.jsx(Py,{domainId:e,taken:r})]})})}const Oy=18,zy=3,Ly=[{id:"erd-many",draw:a.jsx("path",{d:"M6 11 L18 4 L13.5 11 L18 18 Z",fill:"context-stroke",stroke:"none"})},{id:"erd-one",draw:a.jsx("circle",{cx:15,cy:11,r:2.9,fill:"context-stroke",stroke:"none"})}];function rl(){return a.jsx("svg",{width:"0",height:"0","aria-hidden":!0,className:"absolute",style:{position:"absolute"},children:a.jsx("defs",{children:Ly.map(({id:e,draw:t})=>a.jsx("marker",{id:e,viewBox:"0 0 24 22",refX:Oy+zy,refY:11,markerWidth:24,markerHeight:22,markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",children:a.jsx("g",{fill:"none",stroke:"context-stroke",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round",children:t})},e))})})}function Ci(e){return e?e.max===null||e.max>1?"erd-many":"erd-one":"erd-many"}function Xo(e,t){return{markerStart:Ci(e),markerEnd:Ci(t)}}const Si=88,Ms=24;function fs(e){if(e.type!=="group")return{};const t=(typeof e.measured?.width=="number"?e.measured.width:void 0)??(typeof e.style?.width=="number"?e.style.width:void 0),n=(typeof e.measured?.height=="number"?e.measured.height:void 0)??(typeof e.style?.height=="number"?e.style.height:void 0);return t!==void 0&&n!==void 0?{w:Math.round(t),h:Math.round(n)}:{}}function il(e,t){const n=t[e.id];if(!n)return e;const s={...e,position:{x:n.x,y:n.y}};return e.type==="group"&&n.w!==void 0&&n.h!==void 0&&(s.style={...e.style,width:n.w,height:n.h}),s}function Us(e){const t={};for(const n of e)t[n.id]={x:Math.round(n.position.x),y:Math.round(n.position.y),...fs(n)};return t}function al(e,t){let n=0,s=Number.POSITIVE_INFINITY;const o=new Map;for(const{node:l,position:d}of e)if(l.parentId){const u=d.y+(l.style?.height??Si)+Ms;o.set(l.parentId,Math.max(o.get(l.parentId)??34,u))}else n=Math.max(n,d.x+(l.style?.width??200)),s=Math.min(s,d.y);Number.isFinite(s)||(s=0);const r=n+96;let i=s;const c={};for(const l of t)if(l.parentId){const d=o.get(l.parentId)??34;c[l.id]={x:14,y:d},o.set(l.parentId,d+Si+Ms)}else c[l.id]={x:r,y:i,...fs(l)},i+=(l.style?.height??120)+Ms;return c}function cl(){const e=Zn(),t=N.useRef(new Map),n=N.useRef(new Map),s=N.useCallback(r=>{const i=n.current.get(r);i&&clearTimeout(i),n.current.delete(r);const c=t.current.get(r);t.current.delete(r),c&&Object.keys(c).length>0&&_e.setLayout(r,c).catch(()=>{})},[]),o=N.useCallback((r,i)=>{e.setQueryData(Fe.layout(r),l=>({renderFingerprint:l?.renderFingerprint,positions:{...l?.positions,...i}})),t.current.set(r,{...t.current.get(r),...i});const c=n.current.get(r);c&&clearTimeout(c),n.current.set(r,setTimeout(()=>s(r),500))},[s,e]);return N.useEffect(()=>()=>{for(const r of t.current.keys())s(r)},[s]),{commitLayout:o,flushLayout:s}}function Hy(e){const t=e.filter(n=>n.origin==="kernel.astrale.ai");return t.some(n=>n.name==="Identity")?"identity":t.some(n=>n.name==="Container")?"container":null}function ll(e,t,n,s){const o=e.ir;if(!o)return{nodes:[],edges:[]};const r=hu(e).filter(u=>u.classes.length>0),i=[];for(const u of r){const h=`grp-${u.path}`,f=t.has(u.path);if(i.push({id:h,type:f?"moduleNode":"group",position:{x:0,y:0},selectable:!0,data:{domainId:e.domainId,domainOrigin:o.domain,label:u.label,path:u.path,hue:u.hue,collapsed:f,classCount:u.classes.length},style:f?{width:200,height:44}:{width:200,height:120}}),!f)for(const p of u.classes){if(!$y(p,n))continue;const m=o.classes[p];i.push({id:`class.${p}`,type:"classNode",parentId:h,extent:"parent",expandParent:!0,position:{x:0,y:0},data:{domainId:e.domainId,domainOrigin:o.domain,name:p,props:Object.keys(m?.properties??{}).length,methods:Object.keys(m?.methods??{}).length,bases:(m?.extendsRefs??[]).map(w=>w.name),coreRole:Hy(m?.extendsRefs??[]),hue:u.hue,icon:m?.icon}})}}const c=u=>{const h=rt(e,u);return t.has(h)?`grp-${h}`:`class.${u}`},l=u=>Qc(o,u),d=[];for(const u of Object.values(o.classes)){if(u.type!=="edge")continue;const h=l(u.endpoints?.[0]),f=l(u.endpoints?.[1]),p=Xo(u.endpoints?.[0]?.cardinality,u.endpoints?.[1]?.cardinality);for(const m of h)for(const w of f){const x=c(m.className),y=c(w.className);if(x===y||!nl({edgeName:u.name,aClass:m.className,bClass:w.className},n))continue;const j=rt(e,m.className)!==rt(e,w.className);d.push({id:`edge-${u.name}__${x}__${y}`,source:x,target:y,type:"floating",data:{label:u.name,edgeClass:u.name,ownerDomainId:e.domainId},markerStart:p.markerStart,markerEnd:p.markerEnd,style:{stroke:j?"oklch(0.72 0.16 35)":"oklch(0.62 0.07 264)",strokeWidth:j?2.4:1.8}})}}if(s){for(const[u,h]of Object.entries(o.classes))if(!(h.type!=="node"||Pe(tn(u),n)))for(const f of h.extendsRefs??[]){if(f.origin!==o.domain||o.classes[f.name]?.type!=="node")continue;const p=c(u),m=c(f.name);p!==m&&d.push({id:`extends-${u}__${f.name}`,source:p,target:m,type:"floating",data:{label:"extends",kind:"extends",ownerDomainId:e.domainId},markerEnd:{type:ut.ArrowClosed,color:"oklch(0.72 0.18 330)",width:16,height:16},style:{stroke:"oklch(0.72 0.18 330)",strokeWidth:1.6,strokeDasharray:"2 4"}})}}return{nodes:i,edges:d}}function Vy({data:e}){const t=e;X(i=>i.selectClass),X(i=>i.setDomain);const n=X(i=>i.domainId===t.domainId&&i.selectedClass===`class.${t.name}`),o=re(i=>i.transform[2])<.5,r=t.coreRole?{container:"schema-core-container",identity:"schema-core-identity"}[t.coreRole]:void 0;return a.jsxs("div",{"data-domain-id":t.domainId,"data-core-role":t.coreRole??void 0,className:ae("relative rounded-lg border bg-card shadow-sm w-[160px] transition-shadow",r,n?"ring-2 ring-primary":"hover:shadow-md"),style:{borderLeft:`3px solid oklch(0.72 0.15 ${t.hue})`},children:[t.coreRole==="identity"&&a.jsx("span",{title:"Identity",className:"schema-core-identity-icon",children:a.jsx(Hu,{className:"h-3 w-3"})}),a.jsx(Ho,{domainId:t.domainId,anchorRef:`class.${t.name}`,kind:"schema",excerpt:t.name,className:t.coreRole==="identity"?"top-6":void 0}),a.jsx(Ie,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsxs("div",{className:"px-2.5 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[t.icon?a.jsx("span",{style:{color:`oklch(0.82 0.14 ${t.hue})`},className:"shrink-0",children:a.jsx(ge,{svg:t.icon,className:"h-6 w-6"})}):a.jsx("span",{className:"h-2.5 w-2.5 rounded-sm shrink-0",style:{background:`oklch(0.7 0.15 ${t.hue})`}}),a.jsx("span",{className:"text-sm font-extrabold truncate",children:t.name})]}),!o&&t.bases.length>0&&a.jsx("div",{className:"rf-meta mt-1.5 flex flex-wrap gap-1",children:t.bases.map(i=>a.jsx("span",{title:`extends ${i}`,className:"rounded bg-fuchsia-500/15 px-1 py-0.5 font-mono text-[9px] text-fuchsia-300",children:i},i))})]}),a.jsx(Ie,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}function Ks({data:e}){const t=e,n=X(r=>r.setDomain),s=X(r=>r.toggleModule),o=X(r=>r.domainId===t.domainId&&r.selectedClass===`module.${t.path}`);return a.jsxs("div",{"data-domain-id":t.domainId,className:ae("relative w-full h-full rounded-xl border transition-shadow",o?"ring-2 ring-primary":t.collapsed&&"hover:shadow-md cursor-pointer"),style:{borderColor:`oklch(0.55 0.1 ${t.hue} / 0.45)`,background:`oklch(0.5 0.12 ${t.hue} / ${t.collapsed?.12:.07})`},children:[a.jsx(Ho,{domainId:t.domainId,anchorRef:`module.${t.path}`,kind:"section",excerpt:t.label}),a.jsx(Ie,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsx(Ie,{type:"source",position:q.Bottom,className:"!opacity-0"}),a.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1.5 text-[13px]",style:{color:`oklch(0.85 0.12 ${t.hue})`},children:[a.jsx("button",{type:"button",title:t.collapsed?"Show classes":"Hide classes",onClick:r=>{r.stopPropagation(),t.onToggleModule?t.onToggleModule(t.domainId,t.path):(X.getState().domainId!==t.domainId&&n(t.domainId),s(t.path))},className:"rounded p-0.5 hover:bg-white/10 shrink-0",children:t.collapsed?a.jsx(Un,{className:"h-3.5 w-3.5"}):a.jsx(Gn,{className:"h-3.5 w-3.5"})}),a.jsx("span",{className:"font-extrabold truncate",children:t.label}),t.collapsed&&a.jsx("span",{className:"ml-auto text-[10px] opacity-60 shrink-0 pr-1",children:t.classCount})]})]})}function Fy({data:e}){const t=e,n=t.kind==="kernel"?285:158;return a.jsx("div",{className:"w-full h-full rounded-xl border border-dashed",style:{borderColor:`oklch(0.6 0.1 ${n} / 0.55)`,background:`oklch(0.5 0.1 ${n} / 0.06)`},children:a.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5",style:{color:`oklch(0.84 0.11 ${n})`},children:[a.jsx("span",{className:"shrink-0",children:t.icon?a.jsx(ge,{svg:t.icon,className:"h-4 w-4"}):a.jsx(gt,{className:"h-4 w-4"})}),a.jsx("span",{className:"text-[13px] font-extrabold truncate",children:t.name}),a.jsx("span",{className:"ml-auto text-[9px] uppercase tracking-wider opacity-60 shrink-0",children:t.kind})]})})}function By({data:e}){const t=e,n=t.kind==="kernel"?285:158;return a.jsxs("div",{className:"w-full h-full rounded-lg border bg-card flex items-center gap-1.5 px-2 shadow-sm",style:{borderLeft:`3px solid oklch(0.72 0.14 ${n})`},children:[a.jsx(Ie,{type:"target",position:q.Left,className:"!opacity-0"}),a.jsx(Me,{className:"h-4 w-4 shrink-0",style:{color:`oklch(0.78 0.13 ${n})`}}),a.jsx("span",{className:"text-[12px] font-extrabold truncate",children:t.name}),a.jsx(Ie,{type:"source",position:q.Right,className:"!opacity-0"})]})}function Wy({data:e}){const t=e;return a.jsx("div",{className:"relative w-full h-full rounded-2xl border-2 border-dashed",style:{borderColor:"oklch(0.62 0.04 264 / 0.38)",background:"oklch(0.6 0.03 264 / 0.025)"},children:a.jsx("span",{className:"absolute -top-2.5 left-5 px-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/55 whitespace-nowrap",style:{background:"var(--color-canvas)"},children:t.label})})}function Yy({data:e}){const t=e;return a.jsx(ul,{threads:t.comments,anchor:t.anchor,excerpt:t.excerpt,className:"nodrag nopan"})}const dl={classNode:Vy,group:Ks,moduleNode:Ks,extDomain:Fy,extMember:By,internalRegion:Wy,canvasComment:Yy};function ul({threads:e,anchor:t,excerpt:n,className:s}){const[o,r]=N.useState(!1);if(e.length===0)return null;const i=e.some(l=>l.status==="open")?"open":"resolved",c=e.some(l=>l.orphaned);return a.jsxs($t,{modal:!1,open:o,onOpenChange:r,children:[a.jsx(no,{asChild:!0,children:a.jsxs("button",{type:"button",title:"Schema canvas comments",onClick:l=>{l.stopPropagation(),r(d=>!d)},className:ae("flex h-6 min-w-6 items-center justify-center gap-1 rounded-full px-1.5 text-[11px] font-bold shadow-md ring-2 ring-card transition-colors hover:brightness-110",i==="open"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground",c&&"bg-destructive text-white",s),children:[a.jsx(Vi,{className:"h-3 w-3"}),e.length]})}),a.jsx(Rt,{side:"top",align:"center",className:"w-80",onInteractOutside:l=>l.preventDefault(),children:a.jsx(so,{anchor:t,excerpt:n,threads:e,onClose:()=>r(!1)})})]})}function Xy(e,t,n,s){let o=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const g of e){if(g.parentId)continue;const v=s?.[g.id]??g.position,E=g.style?.width??200,k=g.style?.height??120;o=Math.min(o,v.x),r=Math.max(r,v.x+E),i=Math.min(i,v.y),c=Math.max(c,v.y+k)}Number.isFinite(o)||(o=0,i=0,r=400,c=400);const l=56,d=o-l,u=i-l,h=r-o+2*l,f=new Map((n??[]).map(g=>[g.origin,g])),p=36,m=44,w=8,x=d+h+96,y=[];let j=u+24;for(const g of t){const v=f.get(g.origin),E=p+g.members.length*(m+w)+8,k=`extdom.${g.origin}`;y.push({id:k,type:"extDomain",position:s?.[k]??{x,y:j},draggable:!0,selectable:!1,data:{name:v?.name??g.origin.split(".")[0],origin:g.origin,kind:g.kind,icon:v?.icon},style:{width:216,height:E}}),g.members.forEach((C,I)=>{y.push({id:Kc(g.origin,C.name),type:"extMember",parentId:k,extent:"parent",draggable:!1,position:{x:12,y:p+I*(m+w)},data:{name:C.name,kind:g.kind},style:{width:192,height:m}})}),j+=E+40}return{extNodes:y}}function qy(e,t){let n=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const c of e){if(!c.id.startsWith("grp-"))continue;const l=c.style?.width??200,d=c.style?.height??120;n=Math.min(n,c.position.x),s=Math.min(s,c.position.y),o=Math.max(o,c.position.x+l),r=Math.max(r,c.position.y+d)}if(!Number.isFinite(n))return null;const i=56;return{id:"region",type:"internalRegion",position:{x:n-i,y:s-i},draggable:!1,selectable:!1,zIndex:-1,data:{label:t},style:{width:o-n+2*i,height:r-s+2*i}}}function Zy(e,t,n,s,o,r,i){const c=s.ir;if(!c)return[];const l=[];for(const d of e){if(!t.has(d.origin))continue;const u=Kc(d.origin,d.to);if(!n.has(u))continue;const h=d.fromRef?{types:[d.from],refs:[d.fromRef]}:{types:[d.from]};for(const f of Qc(c,h)){if(!nl({edgeName:d.edge,aClass:f.className,bClass:""},r))continue;const p=o.has(rt(s,f.className))?`grp-${rt(s,f.className)}`:`class.${f.className}`;if(!n.has(p))continue;const m="oklch(0.72 0.16 35)",w=Xo(d.fromCard,d.toCard);l.push({id:`edge-${d.edge}__${p}__${u}`,source:p,target:u,type:"floating",data:{label:d.edge,edgeClass:d.edge},markerStart:w.markerStart,markerEnd:w.markerEnd,style:{stroke:m,strokeWidth:2}})}}return l}function qo(e){return!e||!Number.isFinite(e.x)||!Number.isFinite(e.y)?null:{x:e.x,y:e.y}}function Gy(e){const t=new Map;for(const n of e??[]){const s=n.anchorRefs.find(c=>c.ref==="section.schema");if(!s)continue;const o=qo(s);if(!o)continue;const r=`${Math.round(o.x/12)*12}:${Math.round(o.y/12)*12}`,i=t.get(r);i?i.comments.push(n):t.set(r,{key:r,anchor:s,comments:[n]})}return[...t.values()]}function Uy(e){return(e??[]).filter(t=>{const n=t.anchorRefs.find(s=>s.ref==="section.schema");return!!n&&!qo(n)})}function Ky(e){return e.map(t=>{const n=qo(t.anchor)??{x:0,y:0};return{id:`canvas-comment.${t.key}`,type:"canvasComment",position:{x:n.x,y:n.y},draggable:!1,selectable:!1,data:{comments:t.comments,anchor:t.anchor,excerpt:"Schema canvas"},style:{width:24,height:24},zIndex:40}})}function Qy(e,t){const n=new Set([e]),s=new Set;for(const o of t)o.source===e?(n.add(o.target),s.add(o.id)):o.target===e&&(n.add(o.source),s.add(o.id));return{nodeIds:n,edgeIds:s}}function Jy({bundle:e,domainId:t,saved:n}){const{fitView:s,getNodes:o}=Pt(),r=X(Y=>Y.focusId),i=X(Y=>Y.focusClass),c=X(Y=>Y.panelOverlay),l=X(Y=>Y.setPanelOverlay),d=uo(t).all.length,u=Ki(t).data?.detectedIntegrations?.length??0,h=Qi(t).data,f=(h?.nodes.length??0)+(h?.edges.length??0),p=X(Y=>Y.selectClass),m=X(Y=>Y.selectedClass),w=X(Y=>Y.setFocus),x=X(Y=>Y.setOpenAnchor),y=X(Y=>Y.collapsedModules),j=X(Y=>Y.toggleModule),g=X(Y=>Y.hidden),v=X(Y=>Y.showInheritedEdges),E=X(Y=>Y.toggleInheritedEdges),k=X(Y=>Y.setVisibility),{data:C}=nn(),{data:I}=fo(t),{data:R}=pu(t),H=N.useRef(!1),[T,$]=N.useState([]),[A,b]=N.useState([]),[S,_]=N.useState(null),M=N.useMemo(()=>ll(e,new Set(y),g,v),[e.renderFingerprint,e,y,g,v]),D=N.useMemo(()=>el(e),[e]),P=N.useMemo(()=>Jc(e),[e]),L=Object.keys(g).sort().join(",")+`|${v}`;N.useEffect(()=>{if(!m?.startsWith("class."))return;const Y=rt(e,m.slice(6));y.includes(Y)&&j(Y)},[m,e,y,j]);const V=Zn(),F=N.useRef(!1),{commitLayout:O}=cl(),B=N.useCallback(Y=>{O(t,Y)},[O,t]);N.useEffect(()=>{if(!R)return;const Y=R,J=X.getState(),oe={hidden:Y.hidden,showInheritedEdges:Y.showInheritedEdges};Ei(oe,J)||k(oe),H.current=!0},[t,R,k]),N.useEffect(()=>{if(!H.current)return;const Y=X.getState(),J={hidden:Y.hidden,showInheritedEdges:Y.showInheritedEdges},oe=V.getQueryData(Fe.visibility(t))??Iy;Ei(J,oe)||(V.setQueryData(Fe.visibility(t),J),_e.setVisibility(t,J).catch(()=>{}))},[g,v,t,V]);const W=N.useCallback(Y=>{const J=M.nodes.map(de=>il(de,Y)),oe=D.filter(de=>Ry(de.origin,g)),{extNodes:he}=Xy(J,oe,C,Y),se=[...J,...he],fe=new Set(se.map(de=>de.id));$(se),b(Wn([...M.edges,...Zy(P,new Set(oe.map(de=>de.origin)),fe,e,new Set(y),g)]))},[M,D,g,C,P,e,y,v]),Q=N.useCallback(()=>{F.current||(F.current=!0,requestAnimationFrame(()=>{s({padding:.18,duration:400})}))},[s]),G=N.useRef(n);G.current=n;const z=n!==void 0;N.useEffect(()=>{const Y=G.current;if(!Y)return;const J=M.nodes.filter(se=>Y[se.id]),oe=M.nodes.filter(se=>!Y[se.id]);if(oe.length===0){W(Y),Q();return}if(J.length===0){let se=!1;return Bn(M.nodes,M.edges).then(fe=>{if(se)return;const de=Us(fe);W(de),B(de),Q()}),()=>{se=!0}}const he=al(J.map(se=>({node:se,position:Y[se.id]})),oe);W({...Y,...he}),B(he),Q()},[M,z,D,P,C,L]);const Z=N.useCallback(Y=>$(J=>ls(Y.filter(oe=>oe.id!=="region"),J)),[]),te=N.useCallback(Y=>b(J=>ds(Y,J)),[]),ee=N.useCallback((Y,J)=>{const oe={[J.id]:{x:Math.round(J.position.x),y:Math.round(J.position.y),...fs(J)}};if(J.parentId){const he=o(),se=he.find(fe=>fe.id===J.parentId);if(se){let fe=se.measured?.width??(typeof se.style?.width=="number"?se.style.width:200),de=se.measured?.height??(typeof se.style?.height=="number"?se.style.height:120);for(const je of he)je.parentId===J.parentId&&(fe=Math.max(fe,je.position.x+(je.measured?.width??160)),de=Math.max(de,je.position.y+(je.measured?.height??88)));oe[se.id]={x:Math.round(se.position.x),y:Math.round(se.position.y),w:Math.round(fe),h:Math.round(de)}}}B(oe)},[B,o]),U=N.useCallback(async()=>{await _e.resetLayout(t).catch(()=>{});const Y=await Bn(M.nodes,M.edges),J=Us(Y);W(J),V.setQueryData(Fe.layout(t),{positions:J}),_e.setLayout(t,J).catch(()=>{}),requestAnimationFrame(()=>s({padding:.18,duration:400}))},[t,M,s,W,V]),K=r??S,ne=N.useMemo(()=>K?Qy(K,A):null,[K,A]),ie=N.useMemo(()=>qy(T,e.overlay.origin),[T,e.overlay.origin]),ce=N.useMemo(()=>Gy(I?.comments),[I?.comments]),pe=N.useMemo(()=>Uy(I?.comments),[I?.comments]),Ne=N.useMemo(()=>Ky(ce),[ce]),Ce=N.useMemo(()=>{const Y=T.map(oe=>{if(oe.type!=="classNode")return oe.className?{...oe,className:void 0}:oe;const he=ne&&!ne.nodeIds.has(oe.id)?"is-dimmed":void 0;return oe.className===he?oe:{...oe,className:he}}),J=ie?[ie,...Y]:Y;return Ne.length?[...J,...Ne]:J},[T,ne,ie,Ne]),Se=N.useMemo(()=>A.map(Y=>{const J=Y.data?.edgeClass??Y.id.replace(/^edge-/,""),oe=m===`class.${J}`,he=ne?ne.edgeIds.has(Y.id)?"is-on":"is-dimmed":void 0,se=oe?ae("is-selected",he):he;if(oe){const fe="var(--color-primary)";return{...Y,className:se,data:{...Y.data,selected:!0},style:{...Y.style,stroke:fe,strokeWidth:3},markerEnd:typeof Y.markerEnd=="object"?{...Y.markerEnd,color:fe}:Y.markerEnd}}return Y.className===se&&!Y.data?.selected?Y:{...Y,className:se,data:{...Y.data,selected:!1}}}),[A,ne,m]);return a.jsxs(Po,{nodes:Ce,edges:Se,nodeTypes:dl,edgeTypes:Lo,onNodesChange:Z,onEdgesChange:te,onNodeDragStop:ee,onNodeClick:(Y,J)=>{J.id.startsWith("class.")?i(J.id):J.id.startsWith("grp-")&&p(`module.${J.id.slice(4)}`)},onNodeMouseEnter:(Y,J)=>J.id.startsWith("class.")&&_(J.id),onNodeMouseLeave:()=>_(null),onEdgeClick:(Y,J)=>{if(!J.id.startsWith("edge-"))return;const oe=J.data?.edgeClass??J.id.slice(5);p(`class.${oe}`)},onPaneClick:()=>{w(null),x(null)},minZoom:.15,nodesConnectable:!1,edgesFocusable:!0,proOptions:{hideAttribution:!0},children:[a.jsx(To,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(rl,{}),a.jsx(Oo,{className:"!bg-card !border !border-border [&_button]:!bg-card [&_button]:!border-border [&_button]:!fill-foreground",showInteractive:!1,children:a.jsx(bt,{onClick:U,title:"Auto-arrange (ELK) — clears manual layout",children:a.jsx(ea,{className:"h-4 w-4 text-foreground"})})}),a.jsx(zo,{pannable:!0,zoomable:!0,className:"!bg-card !border !border-border",nodeColor:Y=>Y.type==="classNode"?`oklch(0.6 0.13 ${Y.data.hue})`:"transparent",nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.7)"}),a.jsxs(tt,{position:"top-right",className:"flex gap-1.5",children:[pe.length>0&&a.jsx(ul,{threads:pe,anchor:{ref:"section.schema",kind:"section"},excerpt:"Schema canvas"}),a.jsxs(Ve,{size:"xs",variant:c==="domains"?"default":"outline",onClick:()=>l(c==="domains"?null:"domains"),title:"Imported domains — shown in the right panel",children:[a.jsx(gt,{className:"h-3.5 w-3.5"})," Domains",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:D.length})]}),a.jsxs(Ve,{size:"xs",variant:c==="views"?"default":"outline",onClick:()=>l(c==="views"?null:"views"),title:"Views — shown in the right panel",children:[a.jsx(sn,{className:"h-3.5 w-3.5"})," Views",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:d})]}),a.jsxs(Ve,{size:"xs",variant:c==="integrations"?"default":"outline",onClick:()=>l(c==="integrations"?null:"integrations"),title:"Integrations — shown in the right panel",children:[a.jsx(po,{className:"h-3.5 w-3.5"})," Integrations",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:u})]}),a.jsxs(Ve,{size:"xs",variant:v?"default":"outline",onClick:E,title:"Toggle Class inheritance edges",children:[a.jsx(mt,{className:"h-3.5 w-3.5"})," Inherited"]}),a.jsx(Bc,{count:f})]})]})}const Qs="integration.request.",fl=e=>`${Qs}${e}`,ew=e=>e.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"integration";function tw({name:e}){return a.jsx(fn,{anchor:{ref:`section.integrations.${e}`,kind:"section"},excerpt:`${e} integration`,children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-1.5 py-1",children:[a.jsx(ve,{tone:"emerald",size:"sm",children:a.jsx(po,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:e}),a.jsx("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:"in integrations/"})]})]})})}function nw({slug:e,label:t}){return a.jsx(fn,{anchor:{ref:fl(e),kind:"section"},excerpt:`Add ${t} integration`,children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-1.5 py-1",children:[a.jsx(ve,{tone:"amber",size:"sm",children:a.jsx(po,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:t}),a.jsx("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:"requested"})]})]})})}function sw({domainId:e,taken:t}){const{create:n}=Ui(e),s=X(h=>h.setOpenAnchor),[o,r]=N.useState(!1),[i,c]=N.useState(""),[l,d]=N.useState(""),u=()=>{const h=i.trim();if(!h)return;const f=fl(ew(h)),p=`Add a "${h}" integration under the integrations/ folder${l.trim()?` — ${l.trim()}`:""}. Wire it up the Astrale way (DI, secrets, idempotency).`;n.mutate({anchors:[h],anchorRefs:[{ref:f,kind:"section"}],text:p,firstRole:"user",type:"text"},{onSuccess:()=>{c(""),d(""),r(!1),s(f),In.success("Integration requested — add the why/how in the comment")},onError:m=>In.error(String(m))})};return a.jsxs($t,{open:o,onOpenChange:r,children:[a.jsx(oo,{asChild:!0,children:a.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[a.jsx(ta,{className:"h-3.5 w-3.5"}),"Request an integration"]})}),a.jsxs(Rt,{align:"start",side:"top",className:"w-64 p-2.5",children:[a.jsx("div",{className:"pb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Request an integration"}),a.jsx("input",{autoFocus:!0,value:i,onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Enter"&&u()},placeholder:"Name (e.g. Stripe)",className:"mb-1.5 w-full rounded-md border bg-background px-2 py-1.5 text-[13px] outline-none focus:border-primary"}),a.jsx("textarea",{value:l,onChange:h=>d(h.target.value),placeholder:"Why / what for (optional)",rows:2,className:"mb-2 w-full resize-none rounded-md border bg-background px-2 py-1.5 text-[13px] outline-none focus:border-primary"}),a.jsx("button",{type:"button",onClick:u,disabled:!i.trim()||n.isPending,className:"w-full rounded-md bg-primary px-2 py-1.5 text-[12px] font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",children:"Request"}),t.size>0&&a.jsxs("p",{className:"pt-2 text-[10px] leading-snug text-muted-foreground/50",children:["Already present: ",[...t].join(", ")]})]})]})}function ow({domainId:e}){const{data:t}=Ki(e),{data:n}=fo(e),s=t?.detectedIntegrations??[],o=N.useMemo(()=>new Set(s),[s]),r=N.useMemo(()=>{const i=new Set,c=[];for(const l of n?.comments??[])if(l.status==="open")for(const d of l.anchorRefs){if(!d.ref.startsWith(Qs))continue;const u=d.ref.slice(Qs.length);o.has(u)||i.has(u)||(i.add(u),c.push({slug:u,label:l.anchors[0]??u}))}return c},[n,o]);return a.jsx(At,{className:"h-full",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Integrations"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:s.length})]}),s.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Detected"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:s.map(i=>a.jsx(tw,{name:i},i))})]}),r.length>0&&a.jsxs(a.Fragment,{children:[s.length>0&&a.jsx(Mn,{className:"my-2 opacity-60"}),a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Requested"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:r.map(i=>a.jsx(nw,{slug:i.slug,label:i.label},i.slug))})]}),s.length===0&&r.length===0&&a.jsx("p",{className:"px-2 pb-1 pt-0.5 text-[11px] text-muted-foreground/60",children:"No integrations detected."}),a.jsx(Mn,{className:"my-3 opacity-60"}),a.jsx(sw,{domainId:e,taken:o})]})})}function st({onClose:e,children:t}){return a.jsxs("div",{className:"relative min-h-0 w-[420px] shrink-0 border-l bg-card/30",children:[a.jsx("button",{type:"button",onClick:e,"aria-label":"Close panel",title:"Close (Esc)",className:"absolute right-3.5 top-3.5 z-20 inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/50 transition-colors hover:bg-accent hover:text-foreground",children:a.jsx(mu,{className:"h-4 w-4"})}),t]})}function Js(e,t){return t?e.members.some(n=>n.selectId===t)?!0:e.children.some(n=>Js(n,t)):!1}function hl({root:e,selected:t,onSelect:n,controls:s}){return a.jsxs("div",{className:"text-sm py-2","data-domain-id":s?.domainId,children:[a.jsx("div",{className:"px-3 pb-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Modules"}),e.children.map(o=>a.jsx(pl,{node:o,depth:0,selected:t,onSelect:n,controls:s},o.path)),e.members.map(o=>a.jsx(ml,{m:o,depth:1,selected:t,onSelect:n,controls:s},o.selectId))]})}function pl({node:e,depth:t,selected:n,onSelect:s,controls:o}){const r=X(j=>j.collapsedModules),i=X(j=>j.toggleModule),c=o?.collapsedModules??r,l=o?.toggleModule??i,[d,u]=N.useState(!0),h=`module.${e.path}`,f=n===h,p=e.members.length>0,m=p?!c.includes(e.path)||Js(e,n):d||Js(e,n),w=()=>p?l(e.path):u(j=>!j),x={paddingLeft:8+t*12},y=m?Su:on;return a.jsxs("div",{children:[a.jsxs("div",{"data-anchor-ref":h,"data-anchor-excerpt":e.path,className:ae("flex items-center gap-0.5 pr-2 hover:bg-accent/50 rounded-md",f&&"bg-accent text-accent-foreground"),style:x,children:[a.jsx("button",{type:"button",onClick:w,className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-white/5",title:m?"Collapse":"Expand",children:m?a.jsx(Gn,{className:"h-3 w-3"}):a.jsx(Un,{className:"h-3 w-3"})}),a.jsxs("button",{type:"button",onClick:()=>s(h),className:ae("flex items-center gap-1.5 flex-1 min-w-0 py-1 text-left font-bold",f&&"font-extrabold"),children:[a.jsx(y,{className:"h-3.5 w-3.5 shrink-0",style:{color:`oklch(0.78 0.12 ${e.hue})`}}),a.jsx("span",{className:"truncate",children:e.name})]}),a.jsx(Dt,{domainId:o?.domainId,anchorRef:{ref:h,kind:"section"},excerpt:e.path,className:"ml-1"})]}),m&&a.jsxs("div",{children:[e.children.map(j=>a.jsx(pl,{node:j,depth:t+1,selected:n,onSelect:s,controls:o},j.path)),e.members.map(j=>a.jsx(ml,{m:j,depth:t+1,selected:n,onSelect:s,controls:o},j.selectId))]})]})}function ml({m:e,depth:t,selected:n,onSelect:s,controls:o}){const r=n===e.selectId,i=X(m=>Pe(e.ref,m.hidden)),c=X(m=>m.toggleHidden),l=o?Pe(e.ref,o.hidden):i,d=o?.toggleHidden??c,u=l,h=e.kind==="edge"?mt:Me,f=e.kind==="edge"?"text-amber-400":"text-sky-300",p=N.useRef(null);return N.useEffect(()=>{r&&p.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[r]),a.jsxs("div",{ref:p,"data-anchor-ref":e.selectId,"data-anchor-excerpt":`${e.kind} ${e.name}`,className:ae("group w-full flex items-center pr-2 hover:bg-accent/50",r&&"bg-accent text-accent-foreground font-black",u&&"opacity-50"),style:{paddingLeft:8+(t+1)*12+12},title:`${e.kind} ${e.name}`,children:[a.jsxs("button",{type:"button",onClick:()=>s(e.selectId),className:"flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left font-extrabold",children:[e.icon?a.jsx(ge,{svg:e.icon,className:ae("h-4 w-4 shrink-0",f)}):a.jsx(h,{className:ae("h-3.5 w-3.5 shrink-0",f)}),a.jsx("span",{className:"truncate",children:e.name})]}),a.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),d(e.ref)},title:l?"Show in canvas":"Hide in canvas",className:ae("ml-1 shrink-0 rounded p-0.5 text-muted-foreground/60 transition hover:bg-white/5 hover:text-foreground",l?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l?a.jsx(Zi,{className:"h-3.5 w-3.5"}):a.jsx(Gi,{className:"h-3.5 w-3.5"})}),a.jsx(Dt,{domainId:o?.domainId,anchorRef:{ref:e.selectId,kind:"schema"},excerpt:`${e.kind} ${e.name}`,className:"ml-1"})]})}const Vt={width:360,height:220},gl={width:200,height:120},jn=52,rw=48,qn=112,iw=1900;function aw(e){const t=e.type==="classNode"?{width:160,height:44}:e.type==="moduleNode"?{width:200,height:44}:gl;return{width:e.measured?.width??(typeof e.style?.width=="number"?e.style.width:t.width),height:e.measured?.height??(typeof e.style?.height=="number"?e.style.height:t.height)}}function cw(e){const t=e.filter(i=>!i.parentId);if(t.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let n=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const i of t){const c=aw(i);n=Math.min(n,i.position.x),s=Math.min(s,i.position.y),o=Math.max(o,i.position.x+c.width),r=Math.max(r,i.position.y+c.height)}return{minX:n,minY:s,maxX:o,maxY:r}}function lw(e){const t=[];let n=0,s=0,o=0;for(const r of e)n>0&&n+r.size.width>iw&&(n=0,s+=o+qn,o=0),t.push({x:n,y:s}),n+=r.size.width+qn,o=Math.max(o,r.size.height);return t}function dw(e,t){const n=e.filter(r=>t[r.domainId]);if(n.length===0)return lw(e);let s=n.reduce((r,i)=>{const c=t[i.domainId];return Math.max(r,c.x+i.size.width)},0);const o=n.reduce((r,i)=>Math.min(r,t[i.domainId].y),Number.POSITIVE_INFINITY);return e.map(r=>{const i=t[r.domainId];if(i)return i;s+=qn;const c={x:s,y:Number.isFinite(o)?o:0};return s+=r.size.width,c})}function uw(e,t,n,s){const o=e.map(i=>{const c=cw(i.nodes),l=s[i.domainId]??{x:jn-c.minX,y:jn+rw-c.minY},d={width:Math.max(Vt.width,c.maxX+l.x),height:Math.max(Vt.height,c.maxY+l.y)},u={width:Math.max(Vt.width,c.maxX+l.x+jn),height:Math.max(Vt.height,c.maxY+l.y+jn)},h=n[i.domainId];return{domainId:i.domainId,contentOffset:l,size:{width:h?Math.max(d.width,h.width):u.width,height:h?Math.max(d.height,h.height):u.height}}}),r=dw(o,t);return o.map((i,c)=>({...i,position:r[c]}))}function xl(e){return e.data?.workspaceGeometry??null}function _i(e,t){const n=xl(e);return n?{domainId:n.domainId,updates:{[n.localId]:{x:Math.round(e.position.x-n.offset.x),y:Math.round(e.position.y-n.offset.y),...t?{w:Math.round(t.width),h:Math.round(t.height)}:fs(e)}}}:null}const yl=N.createContext(null);function fw({actions:e,children:t}){return a.jsx(yl.Provider,{value:e,children:t})}function Zo(){const e=N.useContext(yl);if(!e)throw new Error("Workspace nodes require WorkspaceNodeActionsProvider");return e}function wl({nodeId:e,minimum:t,label:n,placement:s="module"}){const o=Zo();return a.jsx(q0,{position:"bottom-right",minWidth:t.width,minHeight:t.height,onResizeEnd:(r,i)=>o.resizeNode(e,{width:Math.round(i.width),height:Math.round(i.height)}),style:s==="domain"?{left:"calc(100% - 6px)",top:"calc(100% + 20px)"}:{left:"calc(100% + 20px)",top:"calc(100% + 20px)"},className:"nodrag nopan !flex !h-6 !w-6 !cursor-se-resize !items-start !justify-start !border-0 !bg-transparent !p-0",children:a.jsx("span",{"data-testid":`workspace-resize-${e}`,title:n,className:"block h-3 w-3 rounded-br-[3px] border-b-2 border-r-2 border-sky-300/60 opacity-45 transition-[opacity,border-color] hover:border-sky-200 hover:opacity-100 active:border-sky-100 active:opacity-100"})})}function hw({id:e,data:t}){const n=Zo(),s=t;return a.jsxs("div",{"data-domain-id":s.domainId,title:s.active?void 0:`Click to activate ${s.origin}`,className:ae("relative h-full w-full rounded-[22px] border-2 bg-card/[0.035] shadow-[0_24px_80px_-48px_rgba(0,0,0,0.9)] transition-colors",s.active?"border-sky-400/55 bg-sky-400/[0.045]":"cursor-pointer border-border/55 hover:border-border"),children:[a.jsxs("div",{"data-testid":`workspace-domain-header-${s.domainId}`,title:`Drag ${s.origin}`,onPointerDownCapture:()=>n.activateDomain(s.domainId),className:"workspace-domain-drag-handle absolute inset-x-0 top-0 flex h-12 cursor-grab select-none items-center gap-2 border-b border-border/35 px-4 active:cursor-grabbing",children:[a.jsx("span",{className:ae("h-2 w-2 rounded-full",s.active?"bg-sky-300 shadow-[0_0_12px_rgba(125,211,252,0.8)]":"bg-muted-foreground/35")}),a.jsx("span",{className:"truncate text-[13px] font-extrabold tracking-tight",children:s.origin}),a.jsx("span",{className:"ml-auto rounded-full bg-muted/70 px-1.5 py-0.5 text-[9px] font-semibold tabular-nums text-muted-foreground",children:s.memberCount})]}),s.active&&a.jsx(wl,{nodeId:e,minimum:Vt,label:`Resize ${s.origin}`,placement:"domain"})]})}function Mi(e){const t=Zo(),n=xl(e),s=e.data;return a.jsxs("div",{className:"relative h-full w-full",children:[a.jsx(Ks,{...e,data:{...s,onToggleModule:t.toggleModule}}),e.type==="group"&&n?.active&&a.jsx(wl,{nodeId:e.id,minimum:gl,label:"Resize module"})]})}const pw={...dl,group:Mi,moduleNode:Mi,workspaceDomain:hw},mw=216,gw=48,vl=52,xw=12,Ii=40,yw=e=>`workspace-external:${encodeURIComponent(e)}`,bl=(e,t,n)=>`workspace-external-member:${encodeURIComponent(e)}:${n?`${n}:`:""}${encodeURIComponent(t)}`;function ww(e,t,n){return e.position.x<t.position.x+t.size.width+n&&e.position.x+e.size.width+n>t.position.x&&e.position.y<t.position.y+t.size.height+n&&e.position.y+e.size.height+n>t.position.y}function vw(e,t,n,s){const o=e.ownerDomainIds.map(l=>t.get(l)).filter(l=>!!l),r=o.length>0?o:n,i=r.reduce((l,d)=>Math.max(l,d.position.x+d.size.width),0)+qn;let c=r.reduce((l,d)=>Math.min(l,d.position.y),Number.POSITIVE_INFINITY);for(Number.isFinite(c)||(c=0);;){const l={position:{x:i,y:c},size:e.size},d=s.find(u=>ww(l,u,Ii));if(!d)return l.position;c=d.position.y+d.size.height+Ii}}function bw(e,t,n){const s=[...e].sort((i,c)=>i.origin.localeCompare(c.origin)).map(i=>({...i,size:{width:mw,height:gw+i.members.length*vl+xw}})),o=new Map(t.map(i=>[i.domainId,i])),r=t.map(({position:i,size:c})=>({position:i,size:c}));for(const i of s){const c=n[i.origin];c&&r.push({position:c,size:i.size})}return s.map(i=>{const c=n[i.origin],l=c??vw(i,o,t,r);return c||r.push({position:l,size:i.size}),{...i,position:l}})}function Nw(e,t,n,s){const o=new Map((s??[]).map(c=>[c.origin,c])),r=bw(e,t,n),i=[];for(const c of r){const l=o.get(c.origin),d=yw(c.origin),u=c.origin==="kernel.astrale.ai"?"kernel":"external";i.push({id:d,type:"extDomain",position:c.position,draggable:!1,selectable:!1,data:{name:l?.name??c.origin.split(".")[0],origin:c.origin,kind:u,icon:l?.icon},style:c.size}),c.members.forEach((h,f)=>{i.push({id:bl(c.origin,h.name,h.definition),type:"extMember",parentId:d,extent:"parent",draggable:!1,position:{x:12,y:42+f*vl},data:{name:h.name,kind:u,definition:h.definition},style:{width:192,height:44}})})}return{nodes:i,positions:Object.fromEntries(r.map(c=>[c.origin,c.position]))}}const jw="oklch(0.76 0.16 35)",$i="oklch(0.72 0.18 330)",kw=e=>`workspace-domain:${e}`,wt=(e,t)=>`workspace:${encodeURIComponent(e)}:${t}`;async function Ew(e,t){const n=new Set(t),s=ll(e.bundle,n,e.visibility.hidden,e.visibility.showInheritedEdges),o=e.layout.positions,r=s.nodes.filter(l=>o[l.id]),i=s.nodes.filter(l=>!o[l.id]);let c;return i.length===0?c=o:r.length===0?c=Us(await Bn(s.nodes,s.edges)):c={...o,...al(r.map(l=>({node:l,position:o[l.id]})),i)},{input:e,collapsed:n,nodes:s.nodes.map(l=>il(l,c)),edges:s.edges}}function Ri(e){return e.refs!==void 0?e.refs.filter(co):e.types}function eo(e,t){const n=e.input.bundle.ir;if(!n||n.classes[t]?.type!=="node"||Pe(tn(t),e.input.visibility.hidden))return;const s=rt(e.input.bundle,t),o=e.collapsed.has(s)?`grp-${s}`:`class.${t}`;return{nodeId:wt(e.input.summary.id,o),domainId:e.input.summary.id,className:t}}function Cw(e,t){const n=e.input.bundle.ir;if(n)return Object.values(n.importsByKey).find(s=>s.ref.name===t)?.ref}function to(e,t,n,s){const o=e.input.bundle.ir;if(!o)return[];const r=typeof t=="string"?Cw(e,t)??{origin:o.domain,name:t}:t;if(r.origin===o.domain){const c=eo(e,r.name);return c?[c]:[]}const i=n.get(r.origin)??[];if(i.length>1&&s.add(`Multiple selected folders declare ${r.origin}; ${r.name} stays external.`),i.length===1){const c=eo(i[0],r.name);if(c)return[c];s.add(`${e.input.summary.origin} imports ${r.origin}:class.${r.name}, but the selected schema does not expose it.`)}return[{nodeId:bl(r.origin,r.name,"class"),domainId:null,className:null,unresolved:{origin:r.origin,name:r.name,definition:"class"}}]}function Sw(e,t,n,s){return`workspace-edge:${encodeURIComponent(e)}:${t}:${n}:${s}`}function _w(e,t,n){const s=[],o=new Map,r=new Set,i=(c,l)=>{if(!c.unresolved)return;const d=o.get(c.unresolved.origin)??{members:new Map,ownerDomainIds:new Set};d.members.set(c.unresolved.name,c.unresolved),d.ownerDomainIds.add(l),o.set(c.unresolved.origin,d)};for(const c of e){const l=c.input.bundle.ir;if(l)for(const d of Object.values(l.classes)){if(d.type!=="edge"||d.endpoints?.length!==2||Pe(tl(d.name),c.input.visibility.hidden))continue;const u=Ri(d.endpoints[0]).flatMap(p=>to(c,p,t,n)),h=Ri(d.endpoints[1]).flatMap(p=>to(c,p,t,n)),f=Xo(d.endpoints[0].cardinality,d.endpoints[1].cardinality);for(const p of u)for(const m of h){if(!(p.domainId!==c.input.summary.id||m.domainId!==c.input.summary.id)||p.nodeId===m.nodeId)continue;i(p,c.input.summary.id),i(m,c.input.summary.id);const x=Sw(c.input.summary.id,d.name,p.nodeId,m.nodeId);r.has(x)||(r.add(x),s.push({id:x,source:p.nodeId,target:m.nodeId,type:"floating",data:{label:d.name,edgeClass:d.name,ownerDomainId:c.input.summary.id},markerStart:f.markerStart,markerEnd:f.markerEnd,style:{stroke:jw,strokeWidth:2.5}}))}}}return{edges:s,unresolved:[...o.entries()].map(([c,l])=>({origin:c,members:[...l.members.values()].sort((d,u)=>d.name.localeCompare(u.name)),ownerDomainIds:[...l.ownerDomainIds]}))}}function Mw(e,t,n){const s=[],o=new Set;for(const r of e){const i=r.input.bundle.ir;if(!(!i||!r.input.visibility.showInheritedEdges))for(const[c,l]of Object.entries(i.classes)){if(l.type!=="node")continue;const d=eo(r,c);if(d)for(const u of l.extendsRefs??[])for(const h of to(r,u,t,n)){if(h.unresolved||h.nodeId===d.nodeId)continue;const f=`workspace-extends:${d.nodeId}:${h.nodeId}`;o.has(f)||(o.add(f),s.push({id:f,source:d.nodeId,target:h.nodeId,type:"floating",data:{label:"extends",kind:"extends",ownerDomainId:r.input.summary.id},markerEnd:{type:ut.ArrowClosed,color:$i,width:16,height:16},style:{stroke:$i,strokeWidth:1.7,strokeDasharray:"2 4"}}))}}}return s}function Iw(e,{activeDomainId:t,domainPositions:n={},externalPositions:s={},contentOffsets:o={},domainSizes:r={},catalog:i}){const c=new Set,l=new Map;for(const x of e){const y=x.input.bundle.ir?.domain??x.input.summary.origin;l.set(y,[...l.get(y)??[],x])}const d=uw(e.map(x=>({domainId:x.input.summary.id,nodes:x.nodes})),n,r,o),u=new Map(d.map(x=>[x.domainId,x])),h=[],f=[];for(const x of e){const y=x.input.summary.id,j=u.get(y),g=kw(y),v=y===t;h.push({id:g,type:"workspaceDomain",position:j.position,draggable:!0,dragHandle:".workspace-domain-drag-handle",selectable:!0,data:{domainId:y,origin:x.input.summary.origin,memberCount:Object.keys(x.input.bundle.ir?.classes??{}).length,active:v},style:{width:j.size.width,height:j.size.height}});for(const E of x.nodes){const k=!E.parentId,C=k?j.contentOffset:{x:0,y:0};h.push({...E,id:wt(y,E.id),parentId:k?g:wt(y,E.parentId),position:{x:E.position.x+C.x,y:E.position.y+C.y},data:{...E.data,workspaceGeometry:{domainId:y,localId:E.id,offset:C,active:v}},extent:"parent",expandParent:!1,draggable:v,selectable:v,focusable:v,style:{...E.style,...v?{}:{pointerEvents:"none"}}})}for(const E of x.edges)f.push({...E,id:wt(y,E.id),source:wt(y,E.source),target:wt(y,E.target)})}const p=_w(e,l,c),m=Mw(e,l,c),w=Nw(p.unresolved,d,s,i);return h.push(...w.nodes),f.push(...p.edges,...m),{nodes:h,edges:f,diagnostics:[...c].sort(),domainPositions:Object.fromEntries(d.map(x=>[x.domainId,x.position])),externalPositions:w.positions,contentOffsets:Object.fromEntries(d.map(x=>[x.domainId,x.contentOffset]))}}function $w(e){if(!e.startsWith("workspace:"))return null;const[,t,...n]=e.split(":");return!t||n.length===0?null:{domainId:decodeURIComponent(t),localId:n.join(":")}}function Rw({domains:e,viewsCount:t,onToggleInherited:n}){const{fitView:s,getNode:o}=Pt(),{data:r}=nn(),i=X(O=>O.domainId)??e[0]?.input.summary.id??"",c=X(O=>O.selectedClass),l=X(O=>O.setDomain),d=X(O=>O.setPanelOverlay),u=X(O=>O.panelOverlay),h=xe(O=>O.domainPositions),f=xe(O=>O.externalPositions),p=xe(O=>O.domainSizes),m=xe(O=>O.domainContentOffsets),w=xe(O=>O.setDomainPosition),x=xe(O=>O.setDomainSize),y=xe(O=>O.ensureDomainPositions),j=xe(O=>O.ensureExternalPositions),g=xe(O=>O.ensureDomainContentOffsets),v=xe(O=>O.resetWorkspaceFrames),E=xe(O=>O.toggleModule),{commitLayout:k}=cl(),C=N.useRef(""),I=N.useRef(!1),R=N.useCallback((O,B)=>{if(O.startsWith("workspace-domain:")){x(O.slice(17),B);return}const W=o(O);if(!W||W.type!=="group")return;const Q=_i(W,B);Q&&k(Q.domainId,Q.updates)},[k,o,x]),H=N.useCallback((O,B)=>{if(X.getState().domainId!==O){l(O);return}B&&X.getState().selectClass(B)},[l]),T=N.useCallback((O,B)=>{if(X.getState().domainId!==O){l(O);return}E(O,B)},[l,E]),$=N.useMemo(()=>({activateDomain:H,resizeNode:R,toggleModule:T}),[H,R,T]),A=N.useMemo(()=>Iw(e,{activeDomainId:i,catalog:r,contentOffsets:m,domainPositions:h,domainSizes:p,externalPositions:f}),[i,r,m,h,p,e,f]),[b,S]=N.useState(A.nodes),[_,M]=N.useState(()=>Wn(A.edges));N.useEffect(()=>{if(y(A.domainPositions),j(A.externalPositions),g(A.contentOffsets),S(A.nodes),M(Wn(A.edges)),I.current){I.current=!1;const W=requestAnimationFrame(()=>s({padding:.12,duration:420}));return()=>cancelAnimationFrame(W)}const O=e.map(W=>W.input.summary.id).join("|");if(C.current===O)return;C.current=O;const B=requestAnimationFrame(()=>s({padding:.12,duration:420}));return()=>cancelAnimationFrame(B)},[e,g,y,j,s,A]);const D=N.useCallback(O=>S(B=>ls(O.filter(W=>W.type!=="remove"),B)),[]),P=N.useCallback(O=>M(B=>ds(O.filter(W=>W.type!=="remove"),B)),[]),L=e.every(O=>O.input.visibility.showInheritedEdges),V=N.useCallback((O,B)=>{if(B.id.startsWith("workspace-domain:")){w(B.id.slice(17),{x:Math.round(B.position.x),y:Math.round(B.position.y)});return}const W=_i(B);W&&k(W.domainId,W.updates)},[k,w]),F=N.useMemo(()=>_.map(O=>{const B=O.data?.ownerDomainId,W=O.data?.edgeClass;if(!(!!W&&B===i&&c===`class.${W}`))return O;const G="var(--color-primary)";return{...O,className:ae(O.className,"is-selected"),data:{...O.data,selected:!0},style:{...O.style,stroke:G,strokeWidth:3},markerEnd:typeof O.markerEnd=="object"?{...O.markerEnd,color:G}:O.markerEnd}}),[i,_,c]);return a.jsx(fw,{actions:$,children:a.jsxs(Po,{"data-testid":"workspace-schema-canvas",nodes:b,edges:F,nodeTypes:pw,edgeTypes:Lo,onNodesChange:D,onEdgesChange:P,onNodeDragStop:V,onNodeClick:(O,B)=>{if(B.id.startsWith("workspace-domain:")){H(B.id.slice(17));return}const W=$w(B.id);W&&(W.localId.startsWith("class.")?H(W.domainId,W.localId):W.localId.startsWith("iface.")?H(W.domainId,`interface.${W.localId.slice(6)}`):W.localId.startsWith("grp-")&&H(W.domainId,`module.${W.localId.slice(4)}`))},onEdgeClick:(O,B)=>{const W=B.data?.ownerDomainId,Q=B.data?.edgeClass;W&&Q&&H(W,`class.${Q}`)},onPaneClick:()=>X.getState().setFocus(null),minZoom:.08,nodesConnectable:!1,edgesFocusable:!0,onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},children:[a.jsx(To,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(rl,{}),a.jsx(Oo,{className:"!border !border-border !bg-card [&_button]:!border-border [&_button]:!bg-card [&_button]:!fill-foreground",showInteractive:!1,children:a.jsx(bt,{onClick:()=>{I.current=!0,v()},title:"Reset and auto-pack workspace regions",children:a.jsx(ea,{className:"h-4 w-4 text-foreground"})})}),a.jsx(zo,{pannable:!0,zoomable:!0,className:"!border !border-border !bg-card",nodeColor:O=>O.type==="classNode"?`oklch(0.6 0.13 ${O.data.hue})`:O.type==="workspaceDomain"?"oklch(0.52 0.08 225 / 0.45)":"transparent",nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.72)"}),A.diagnostics.length>0&&a.jsx(tt,{position:"top-center",className:"max-w-xl",children:a.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-warning/30 bg-card/95 px-3 py-2 text-[11px] text-warning shadow-lg backdrop-blur",children:[a.jsx(ct,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("span",{children:A.diagnostics.join(" ")})]})}),a.jsxs(tt,{position:"top-right",className:"flex gap-1.5",children:[a.jsxs(Ve,{size:"xs",variant:"outline",disabled:!0,title:"Selected workspace domains",children:[a.jsx(ao,{className:"h-3.5 w-3.5"})," Domains",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:e.length})]}),a.jsxs(Ve,{size:"xs",variant:u==="views"?"default":"outline",onClick:()=>d(u==="views"?null:"views"),title:"Views across selected domains",children:[a.jsx(sn,{className:"h-3.5 w-3.5"})," Views",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:t})]}),a.jsxs(Ve,{size:"xs",variant:L?"default":"outline",onClick:n,title:"Toggle inherited edges in every selected domain",children:[a.jsx(mt,{className:"h-3.5 w-3.5"})," Inherited"]})]})]})})}function Aw({domains:e,onToggleHidden:t}){const n=X(u=>u.domainId),s=X(u=>u.selectedClass),o=X(u=>u.setDomain),r=xe(u=>u.collapsedModules),i=xe(u=>u.toggleModule),[c,l]=N.useState({}),d=(u,h)=>{X.getState().domainId!==u&&o(u),h&&X.getState().selectClass(h)};return a.jsxs("div",{className:"py-2","data-testid":"workspace-module-tree",children:[a.jsxs("div",{className:"flex items-center gap-1.5 px-3 pb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[a.jsx(ao,{className:"h-3 w-3"})," Workspace modules"]}),e.map(u=>{const h=u.input.summary.id,f=n===h,p=!!c[h],m={domainId:h,collapsedModules:r[h]??[],hidden:u.input.visibility.hidden,toggleModule:x=>i(h,x),toggleHidden:x=>t(h,x)},w=Ji(u.input.bundle);return a.jsxs("section",{className:"border-b border-border/40 last:border-b-0",children:[a.jsxs("div",{"data-domain-id":h,className:ae("flex items-center gap-1 px-2 py-2 transition-colors",f?"bg-sky-400/[0.075]":"hover:bg-accent/30"),children:[a.jsx("button",{type:"button",onClick:()=>l(x=>{const y={...x};return y[h]?delete y[h]:y[h]=!0,y}),className:"rounded p-0.5 text-muted-foreground hover:bg-white/5",title:p?"Expand domain":"Collapse domain",children:p?a.jsx(Un,{className:"h-3.5 w-3.5"}):a.jsx(Gn,{className:"h-3.5 w-3.5"})}),a.jsx("button",{type:"button",onClick:()=>d(h),className:"min-w-0 flex-1 truncate text-left text-[12px] font-extrabold",title:`Make ${u.input.summary.origin} active`,children:u.input.summary.origin}),f&&a.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-sky-300",title:"Active"})]}),!p&&a.jsx("div",{className:"border-t border-border/25 bg-background/15",children:a.jsx(hl,{root:w,selected:f?s:void 0,onSelect:x=>d(h,x),controls:m})})]},h)})]})}const Dw={positions:{}},Pw={hidden:{},showInheritedEdges:!0};function Tw(e,t){const n=hn({queries:e.map(i=>({queryKey:Fe.bundle(i),queryFn:()=>_e.bundle(i)}))}),s=hn({queries:e.map(i=>({queryKey:Fe.anatomy(i),queryFn:()=>_e.anatomy(i)}))}),o=hn({queries:e.map(i=>({queryKey:Fe.layout(i),queryFn:()=>_e.layout(i)}))}),r=hn({queries:e.map(i=>({queryKey:Fe.visibility(i),queryFn:()=>_e.visibility(i)}))});return N.useMemo(()=>{const i=new Map((t??[]).map(u=>[u.id,u])),c=[],l=[];let d=!1;return e.forEach((u,h)=>{const f=i.get(u),p=n[h]?.data,m=s[h]?.data,w=n[h]?.error??s[h]?.error;if(w&&l.push(`${f?.origin??u}: ${String(w)}`),!f||!p||!m){d=d||!w;return}c.push({summary:f,bundle:p,anatomy:m,layout:o[h]?.data??Dw,visibility:r[h]?.data??Pw})}),{inputs:c,pending:d,errors:l}},[s,n,t,e,o,r])}function Ow({inputs:e}){const t=e.map(o=>({input:o,model:gu(o.anatomy,o.bundle)})),n=t.reduce((o,r)=>o+r.model.all.length,0),s=t.some(o=>o.model.hasDrift);return a.jsx(At,{className:"h-full","data-testid":"workspace-views-panel",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Workspace views"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:n}),s&&a.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-warning",children:[a.jsx(ct,{className:"h-3.5 w-3.5"})," drift"]})]}),n===0&&a.jsx(Ft,{icon:a.jsx(sn,{}),title:"No views",hint:"The selected domains declare no views."}),a.jsx("div",{className:"space-y-7",children:t.filter(o=>o.model.all.length>0).map(({input:o,model:r})=>a.jsxs("section",{"data-domain-id":o.summary.id,children:[a.jsxs("div",{className:"mb-2 flex items-center gap-2 border-b border-border/45 pb-2",children:[a.jsx("span",{className:"h-2 w-2 rounded-full bg-sky-300/80"}),a.jsx("h2",{className:"min-w-0 flex-1 truncate text-[13px] font-extrabold",children:o.summary.origin}),a.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground",children:r.all.length})]}),a.jsx("div",{className:"space-y-0.5",children:r.all.map(i=>{const c=i.boundClass?o.bundle.ir?.classes[i.boundClass]?.icon:void 0;return a.jsx(Xn,{domainId:o.summary.id,view:i,icon:c},`${o.summary.id}:${i.slug}`)})})]},o.summary.id))})]})})}const Ai=220,Di=620,zw=300;function Pi(e,t){return[e.summary.id,e.summary.origin,e.bundle.renderFingerprint,Object.keys(e.visibility.hidden).sort().join(","),e.visibility.showInheritedEdges,Object.entries(e.layout.positions).sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}:${s.x}:${s.y}:${s.w??""}:${s.h??""}`).join(","),t.slice().sort().join(",")].join("|")}function Lw({domainIds:e}){const{data:t}=xu(),{inputs:n,pending:s,errors:o}=Tw(e,t),r=Zn(),i=X($=>$.domainId),c=X($=>$.selectedClass),l=X($=>$.selectClass),d=X($=>$.setFocus),u=X($=>$.panelOverlay),h=X($=>$.setPanelOverlay),f=X($=>$.setCanvasMode),p=xe($=>$.collapsedModules),[m,w]=N.useState([]),x=N.useRef(new Map),[y,j]=N.useState(()=>{try{const $=Number(localStorage.getItem("studio.workspaceModulesWidth"));if(Number.isFinite($)&&$>=Ai&&$<=Di)return $}catch{}return zw});N.useEffect(()=>{f("schema"),X.getState().panelOverlay&&X.getState().panelOverlay!=="views"&&h(null)},[f,h]);const g=N.useMemo(()=>n.map($=>Pi($,p[$.summary.id]??[])).join("::"),[p,n]);N.useEffect(()=>{let $=!1;const A=new Set(n.map(b=>b.summary.id));for(const b of x.current.keys())A.has(b)||x.current.delete(b);return Promise.all(n.map(async b=>{const S=b.summary.id,_=p[S]??[],M=Pi(b,_),D=x.current.get(S);if(D?.key===M)return{...D.projection,input:b};const P=await Ew(b,_);return $||x.current.set(S,{key:M,projection:P}),P})).then(b=>{$||w(b)}),()=>{$=!0}},[g]),N.useEffect(()=>{const $=A=>{A.key!=="Escape"||A.defaultPrevented||(d(null),l(void 0),h(null))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[l,d,h]);const v=N.useCallback(($,A)=>{const b=n.find(_=>_.summary.id===$);if(!b)return;const S=A(b.visibility);r.setQueryData(Fe.visibility($),S),_e.setVisibility($,S).catch(()=>{r.invalidateQueries({queryKey:Fe.visibility($)})})},[n,r]),E=N.useCallback(($,A)=>v($,b=>{const S={...b.hidden};return S[A]?delete S[A]:S[A]=!0,{...b,hidden:S}}),[v]),k=N.useCallback(()=>{const $=!n.every(A=>A.visibility.showInheritedEdges);for(const A of n)v(A.summary.id,b=>({...b,showInheritedEdges:$}))},[n,v]),C=$=>{$.preventDefault();const A=$.clientX,b=y;let S=b;const _=D=>{S=Math.min(Di,Math.max(Ai,b+D.clientX-A)),j(S)},M=()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",M),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("studio.workspaceModulesWidth",String(S))}catch{}};document.addEventListener("pointermove",_),document.addEventListener("pointerup",M),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},I=n.find($=>$.summary.id===i),R=n.reduce(($,A)=>$+A.anatomy.views.length,0),H=m.length===n.length&&n.length===e.length,T=m.map($=>`${$.input.summary.id}:${$.input.bundle.renderFingerprint}`).join("|");return(s||!H)&&o.length===0?a.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Composing workspace…"}):a.jsxs("div",{className:"flex h-full flex-col","data-testid":"workspace-schema-section",children:[(o.length>0||n.some($=>$.bundle.error))&&a.jsxs("div",{className:"flex items-start gap-2 border-b border-warning/30 bg-warning/10 px-4 py-2 text-sm text-warning",children:[a.jsx(ct,{className:"mt-0.5 h-4 w-4 shrink-0"}),a.jsx("span",{children:[...o,...n.flatMap($=>$.bundle.error?.message??[])].join(" ")})]}),a.jsxs("div",{className:"flex min-h-0 flex-1",children:[a.jsxs("div",{className:"relative min-h-0 shrink-0 border-r",style:{width:y},children:[a.jsx(At,{className:"h-full",children:a.jsx(Aw,{domains:m,onToggleHidden:E})}),a.jsx("div",{role:"separator","aria-orientation":"vertical",onPointerDown:C,title:"Drag to resize",className:"group absolute right-0 top-0 z-20 h-full w-1.5 translate-x-1/2 cursor-col-resize",children:a.jsx("div",{className:"mx-auto h-full w-px bg-transparent transition-colors group-hover:bg-primary/50"})})]}),a.jsx("div",{className:"relative min-w-0 flex-1",children:a.jsx(Do,{children:a.jsx(Rw,{domains:m,viewsCount:R,onToggleInherited:k})},T)}),u==="views"?a.jsx(st,{onClose:()=>h(null),children:a.jsx(Ow,{inputs:n})}):c&&I?a.jsx(st,{onClose:()=>l(void 0),children:a.jsx(Uc,{bundle:I.bundle,selected:c})}):null]})]})}const Ti=180,Oi=560,Hw=240;function Bw({domainId:e}){const t=xe(s=>s.selectedDomainIds),n=t.includes(e)?t:[e,...t];return n.length>1?a.jsx(Lw,{domainIds:n}):a.jsx(Vw,{domainId:e})}function Vw({domainId:e}){const{data:t,isLoading:n}=ro(e),{data:s}=yu(e),{data:o}=Qi(e),r=X(g=>g.selectedClass),i=X(g=>g.selectClass),c=X(g=>g.setFocus),l=X(g=>g.canvasMode),d=l==="core",u=X(g=>g.panelOverlay),h=X(g=>g.setPanelOverlay),f=uo(e),[p,m]=N.useState(()=>{try{const g=Number(localStorage.getItem("studio.modulesWidth"));if(Number.isFinite(g)&&g>=Ti&&g<=Oi)return g}catch{}return Hw}),w=g=>{g.preventDefault();const v=g.clientX,E=p;let k=E;const C=R=>{k=Math.min(Oi,Math.max(Ti,E+(R.clientX-v))),m(k)},I=()=>{document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",I),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("studio.modulesWidth",String(k))}catch{}};document.addEventListener("pointermove",C),document.addEventListener("pointerup",I),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[x,y]=N.useState(null);N.useEffect(()=>y(null),[e,l]),N.useEffect(()=>{const g=v=>{v.key!=="Escape"||v.defaultPrevented||(c(null),i(void 0),y(null),h(null))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[c,i,h]);const j=N.useMemo(()=>t?.ir?Ji(t):null,[t]);return n||!t?a.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Introspecting schema…"}):a.jsxs("div",{className:"h-full flex flex-col",children:[t.error&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-warning/10 border-b border-warning/30 text-warning text-sm",children:[a.jsx(ct,{className:"h-4 w-4 shrink-0"}),a.jsxs("span",{children:[t.error.message,!t.depsInstalled&&" — showing the static structure; run `pnpm install` in the domain for full fidelity."]})]}),t.ir?a.jsxs("div",{className:"flex-1 flex min-h-0",children:[a.jsxs("div",{className:"relative border-r shrink-0 min-h-0",style:{width:p},children:[a.jsx(At,{className:"h-full",children:d?o&&a.jsx(fy,{core:o,bundle:t,selectedPath:x,onSelect:y}):j&&a.jsx(hl,{root:j,selected:r,onSelect:i})}),a.jsx("div",{role:"separator","aria-orientation":"vertical",onPointerDown:w,title:"Drag to resize",className:"group absolute right-0 top-0 z-20 h-full w-1.5 translate-x-1/2 cursor-col-resize",children:a.jsx("div",{className:"mx-auto h-full w-px bg-transparent transition-colors group-hover:bg-primary/50"})})]}),a.jsx("div",{className:"flex-1 min-w-0 relative",children:a.jsx(Do,{children:d?o?a.jsx(ly,{core:o,bundle:t,selectedPath:x,onSelect:y}):a.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Extracting core…"}):a.jsx(Jy,{bundle:t,domainId:e,saved:s?.positions},e)},`${e}:${l}`)}),d?x&&o&&a.jsx(st,{onClose:()=>y(null),children:a.jsx(dy,{core:o,bundle:t,selectedPath:x})}):u==="views"?a.jsx(st,{onClose:()=>h(null),children:a.jsx(Ny,{domainId:e,model:f})}):u==="domains"?a.jsx(st,{onClose:()=>h(null),children:a.jsx(Ty,{domainId:e})}):u==="integrations"?a.jsx(st,{onClose:()=>h(null),children:a.jsx(ow,{domainId:e})}):r?a.jsx(st,{onClose:()=>i(void 0),children:a.jsx(Uc,{bundle:t,selected:r})}):null]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm p-6 text-center",children:"No compiled schema available."})]})}export{Bw as SchemaSection};
7
+ `)),u=d.reduce((h,f)=>h.concat(...f),[]);return[d,u]}return[[],[]]},[e]);return N.useEffect(()=>{const l=t?.target??Kr,d=t?.actInsideInputWithModifier??!0;if(e!==null){const u=p=>{if(o.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!o.current||o.current&&!d)&&Ya(p))return!1;const w=Jr(p.code,c);if(r.current.add(p[w]),Qr(i,r.current,!1)){const x=p.composedPath?.()?.[0]||p.target,y=x?.nodeName==="BUTTON"||x?.nodeName==="A";t.preventDefault!==!1&&(o.current||!y)&&p.preventDefault(),s(!0)}},h=p=>{const m=Jr(p.code,c);Qr(i,r.current,!0)?(s(!1),r.current.clear()):r.current.delete(p[m]),p.key==="Meta"&&r.current.clear(),o.current=!1},f=()=>{r.current.clear(),s(!1)};return l?.addEventListener("keydown",u),l?.addEventListener("keyup",h),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{l?.removeEventListener("keydown",u),l?.removeEventListener("keyup",h),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,s]),n}function Qr(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 Zg=()=>{const e=le();return N.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[s,o,r],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??s,y:t.y??o,zoom:t.zoom??r},n),!0):!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:r,maxZoom:i,panZoom:c}=e.getState(),l=Eo(t,s,o,r,i,n?.padding??.1);return c?(await c.setViewport(l,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:s,snapGrid:o,snapToGrid:r,domNode:i}=e.getState();if(!i)return t;const{x:c,y:l}=i.getBoundingClientRect(),d={x:t.x-c,y:t.y-l},u=n.snapGrid??o,h=n.snapToGrid??r;return un(d,s,h,u)},flowToScreenPosition:t=>{const{transform:n,domNode:s}=e.getState();if(!s)return t;const{x:o,y:r}=s.getBoundingClientRect(),i=Mt(t,n);return{x:i.x+o,y:i.y+r}}}),[])};function fc(e,t){const n=[],s=new Map,o=[];for(const r of e)if(r.type==="add"){o.push(r);continue}else if(r.type==="remove"||r.type==="replace")s.set(r.id,[r]);else{const i=s.get(r.id);i?i.push(r):s.set(r.id,[r])}for(const r of t){const i=s.get(r.id);if(!i){n.push(r);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const c={...r};for(const l of i)Gg(l,c);n.push(c)}return o.length&&o.forEach(r=>{r.index!==void 0?n.splice(r.index,0,{...r.item}):n.push({...r.item})}),n}function Gg(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 ls(e,t){return fc(e,t)}function ds(e,t){return fc(e,t)}function nt(e,t){return{id:e,type:"select",selected:t}}function vt(e,t=new Set,n=!1){const s=[];for(const[o,r]of e){const i=t.has(o);!(r.selected===void 0&&!i)&&r.selected!==i&&(n&&(r.selected=i),s.push(nt(r.id,i)))}return s}function ei({items:e=[],lookup:t}){const n=[],s=new Map(e.map(o=>[o.id,o]));for(const[o,r]of e.entries()){const i=t.get(r.id),c=i?.internals?.userNode??i;c!==void 0&&c!==r&&n.push({id:r.id,item:r,type:"replace"}),c===void 0&&n.push({item:r,type:"add",index:o})}for(const[o]of t)s.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function ti(e){return{id:e.id,type:"remove"}}const Ug=Va();function Kg(e,t,n={}){return Tm(e,t,{...n,onError:n.onError??Ug})}const ni=e=>bm(e),Qg=e=>Ta(e);function hc(e){return N.forwardRef(e)}const pc=typeof window<"u"?N.useLayoutEffect:N.useEffect;function si(e){const[t,n]=N.useState(BigInt(0)),[s]=N.useState(()=>Jg(()=>n(o=>o+BigInt(1))));return pc(()=>{const o=s.get();o.length&&(e(o),s.reset())},[t]),s}function Jg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const mc=N.createContext(null);function ex({children:e}){const t=le(),n=N.useCallback(c=>{const{nodes:l=[],setNodes:d,hasDefaultNodes:u,onNodesChange:h,nodeLookup:f,fitViewQueued:p,onNodesChangeMiddlewareMap:m}=t.getState();let w=l;for(const y of c)w=typeof y=="function"?y(w):y;let x=ei({items:w,lookup:f});for(const y of m.values())x=y(x);u&&d(w),x.length>0?h?.(x):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:j,setNodes:g}=t.getState();y&&g(j)})},[]),s=si(n),o=N.useCallback(c=>{const{edges:l=[],setEdges:d,hasDefaultEdges:u,onEdgesChange:h,edgeLookup:f}=t.getState();let p=l;for(const m of c)p=typeof m=="function"?m(p):m;u?d(p):h&&h(ei({items:p,lookup:f}))},[]),r=si(o),i=N.useMemo(()=>({nodeQueue:s,edgeQueue:r}),[]);return a.jsx(mc.Provider,{value:i,children:e})}function tx(){const e=N.useContext(mc);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const nx=e=>!!e.panZoom;function Pt(){const e=Zg(),t=le(),n=tx(),s=re(nx),o=N.useMemo(()=>{const r=h=>t.getState().nodeLookup.get(h),i=h=>{n.nodeQueue.push(h)},c=h=>{n.edgeQueue.push(h)},l=h=>{const{nodeLookup:f,nodeOrigin:p}=t.getState(),m=ni(h)?h:f.get(h.id),w=m.parentId?Ba(m.position,m.measured,m.parentId,f,p):m.position,x={...m,position:w,width:m.measured?.width??m.width,height:m.measured?.height??m.height};return Kt(x)},d=(h,f,p={replace:!1})=>{i(m=>m.map(w=>{if(w.id===h){const x=typeof f=="function"?f(w):f;return p.replace&&ni(x)?x:{...w,...x}}return w}))},u=(h,f,p={replace:!1})=>{c(m=>m.map(w=>{if(w.id===h){const x=typeof f=="function"?f(w):f;return p.replace&&Qg(x)?x:{...w,...x}}return w}))};return{getNodes:()=>t.getState().nodes.map(h=>({...h})),getNode:h=>r(h)?.internals.userNode,getInternalNode:r,getEdges:()=>{const{edges:h=[]}=t.getState();return h.map(f=>({...f}))},getEdge:h=>t.getState().edgeLookup.get(h),setNodes:i,setEdges:c,addNodes:h=>{const f=Array.isArray(h)?h:[h];n.nodeQueue.push(p=>[...p,...f])},addEdges:h=>{const f=Array.isArray(h)?h:[h];n.edgeQueue.push(p=>[...p,...f])},toObject:()=>{const{nodes:h=[],edges:f=[],transform:p}=t.getState(),[m,w,x]=p;return{nodes:h.map(y=>({...y})),edges:f.map(y=>({...y})),viewport:{x:m,y:w,zoom:x}}},deleteElements:async({nodes:h=[],edges:f=[]})=>{const{nodes:p,edges:m,onNodesDelete:w,onEdgesDelete:x,triggerNodeChanges:y,triggerEdgeChanges:j,onDelete:g,onBeforeDelete:v}=t.getState(),{nodes:E,edges:k}=await Cm({nodesToRemove:h,edgesToRemove:f,nodes:p,edges:m,onBeforeDelete:v}),C=k.length>0,I=E.length>0;if(C){const R=k.map(ti);x?.(k),j(R)}if(I){const R=E.map(ti);w?.(E),y(R)}return(I||C)&&g?.({nodes:E,edges:k}),{deletedNodes:E,deletedEdges:k}},getIntersectingNodes:(h,f=!0,p)=>{const m=Sr(h),w=m?h:l(h),x=p!==void 0;return w?(p||t.getState().nodes).filter(y=>{const j=t.getState().nodeLookup.get(y.id);if(j&&!m&&(y.id===h.id||!j.internals.positionAbsolute))return!1;const g=Kt(x?y:j),v=Ln(g,w);return f&&v>0||v>=g.width*g.height||v>=w.width*w.height}):[]},isNodeIntersecting:(h,f,p=!0)=>{const w=Sr(h)?h:l(h);if(!w)return!1;const x=Ln(w,f);return p&&x>0||x>=f.width*f.height||x>=w.width*w.height},updateNode:d,updateNodeData:(h,f,p={replace:!1})=>{d(h,m=>{const w=typeof f=="function"?f(m):f;return p.replace?{...m,data:w}:{...m,data:{...m.data,...w}}},p)},updateEdge:u,updateEdgeData:(h,f,p={replace:!1})=>{u(h,m=>{const w=typeof f=="function"?f(m):f;return p.replace?{...m,data:w}:{...m,data:{...m.data,...w}}},p)},getNodesBounds:h=>{const{nodeLookup:f,nodeOrigin:p}=t.getState();return Nm(h,{nodeLookup:f,nodeOrigin:p})},getHandleConnections:({type:h,id:f,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}-${h}${f?`-${f}`:""}`)?.values()??[]),getNodeConnections:({type:h,handleId:f,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}${h?f?`-${h}-${f}`:`-${h}`:""}`)?.values()??[]),fitView:async h=>{const f=t.getState().fitViewResolver??Mm();return t.setState({fitViewQueued:!0,fitViewOptions:h,fitViewResolver:f}),n.nodeQueue.push(p=>[...p]),f.promise}}},[]);return N.useMemo(()=>({...o,...e,viewportInitialized:s}),[s])}const oi=e=>e.selected,sx=typeof window<"u"?window:void 0;function ox({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=le(),{deleteElements:s}=Pt(),o=Jt(e,{actInsideInputWithModifier:!1}),r=Jt(t,{target:sx});N.useEffect(()=>{if(o){const{edges:i,nodes:c}=n.getState();s({nodes:c.filter(oi),edges:i.filter(oi)}),n.setState({nodesSelectionActive:!1})}},[o]),N.useEffect(()=>{n.setState({multiSelectionActive:r})},[r])}function rx(e){const t=le();N.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const s=Co(e.current);(s.height===0||s.width===0)&&t.getState().onError?.("004",Te.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 us={position:"absolute",width:"100%",height:"100%",top:0,left:0},ix=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function ax({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:s=!1,panActivationKeyPressed:o,panOnScrollSpeed:r=.5,panOnScrollMode:i=at.Free,zoomOnDoubleClick:c=!0,panOnDrag:l=!0,defaultViewport:d,translateExtent:u,minZoom:h,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:w,noWheelClassName:x,noPanClassName:y,onViewportChange:j,isControlledViewport:g,paneClickDistance:v,selectionOnDrag:E}){const k=le(),C=N.useRef(null),{userSelectionActive:I,lib:R,connectionInProgress:V}=re(ix,ue),T=Jt(p),$=N.useRef();rx(C);const A=N.useCallback(b=>{j?.({x:b[0],y:b[1],zoom:b[2]}),g||k.setState({transform:b})},[j,g]);return N.useEffect(()=>{if(C.current){$.current=fg({domNode:C.current,minZoom:h,maxZoom:f,translateExtent:u,viewport:d,onDraggingChange:M=>k.setState(D=>D.paneDragging===M?D:{paneDragging:M}),onPanZoomStart:(M,D)=>{const{onViewportChangeStart:P,onMoveStart:L}=k.getState();L?.(M,D),P?.(D)},onPanZoom:(M,D)=>{const{onViewportChange:P,onMove:L}=k.getState();L?.(M,D),P?.(D)},onPanZoomEnd:(M,D)=>{const{onViewportChangeEnd:P,onMoveEnd:L}=k.getState();L?.(M,D),P?.(D)}});const{x:b,y:S,zoom:_}=$.current.getViewport();return k.setState({panZoom:$.current,transform:[b,S,_],domNode:C.current.closest(".react-flow")}),()=>{$.current?.destroy()}}},[]),N.useEffect(()=>{$.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:s,panActivationKeyPressed:o,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:c,panOnDrag:l,zoomActivationKeyPressed:T,preventScrolling:m,noPanClassName:y,userSelectionActive:I,noWheelClassName:x,lib:R,onTransformChange:A,connectionInProgress:V,selectionOnDrag:E,paneClickDistance:v})},[e,t,n,s,o,r,i,c,l,T,m,y,I,x,R,A,V,E,v]),a.jsx("div",{className:"react-flow__renderer",ref:C,style:us,children:w})}const cx=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function lx(){const{userSelectionActive:e,userSelectionRect:t}=re(cx,ue);return e&&t?a.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 Ss=(e,t)=>n=>{n.target===t.current&&e?.(n)},dx=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function ux({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Ut.Full,panOnDrag:s,autoPanOnSelection:o,paneClickDistance:r,selectionOnDrag:i,onSelectionStart:c,onSelectionEnd:l,onPaneClick:d,onPaneContextMenu:u,onPaneScroll:h,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:w}){const x=N.useRef(0),y=le(),{userSelectionActive:j,elementsSelectable:g,dragging:v,panBy:E,autoPanSpeed:k}=re(dx,ue),C=g&&(e||j),I=N.useRef(null),R=N.useRef(),V=N.useRef(new Set),T=N.useRef(new Set),$=N.useRef(!1),A=N.useRef(!1),b=N.useRef({x:0,y:0}),S=N.useRef(!1),_=z=>{if(A.current||$.current||y.getState().connection.inProgress){A.current=!1,$.current=!1;return}d?.(z),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},M=z=>{if(Array.isArray(s)&&s?.includes(2)){z.preventDefault();return}u?.(z)},D=h?z=>h(z):void 0,P=z=>{A.current&&(z.stopPropagation(),A.current=!1)},L=z=>{if(z.pointerType==="touch"&&s!==!1&&!t)return;const{domNode:Z,transform:te}=y.getState();if(R.current=Z?.getBoundingClientRect(),!R.current)return;const ee=z.target===I.current;if(!ee&&!!z.target.closest(".nokey")||!e||!(i&&ee||t)||z.button!==0||!z.isPrimary)return;z.target?.setPointerCapture?.(z.pointerId),A.current=!1;const{x:ne,y:ie}=De(z.nativeEvent,R.current),ce=un({x:ne,y:ie},te);y.setState({userSelectionRect:{width:0,height:0,startX:ce.x,startY:ce.y,x:ne,y:ie}}),ee||(z.stopPropagation(),z.preventDefault())};function H(z,Z){const{userSelectionRect:te}=y.getState();if(!te)return;const{transform:ee,nodeLookup:U,edgeLookup:K,connectionLookup:ne,triggerNodeChanges:ie,triggerEdgeChanges:ce,defaultEdgeOptions:pe}=y.getState(),Ne={x:te.startX,y:te.startY},{x:Ce,y:Se}=Mt(Ne,ee),W={startX:Ne.x,startY:Ne.y,x:z<Ce?z:Ce,y:Z<Se?Z:Se,width:Math.abs(z-Ce),height:Math.abs(Z-Se)},J=V.current,oe=T.current;V.current=new Set(jo(U,W,ee,n===Ut.Partial,!0).map(se=>se.id)),T.current=new Set;const he=pe?.selectable??!0;for(const se of V.current){const fe=ne.get(se);if(fe)for(const{edgeId:de}of fe.values()){const je=K.get(de);je&&(je.selectable??he)&&T.current.add(de)}}if(!_r(J,V.current)){const se=vt(U,V.current,!0);ie(se)}if(!_r(oe,T.current)){const se=vt(K,T.current);ce(se)}y.setState({userSelectionRect:W,userSelectionActive:!0,nodesSelectionActive:!1})}function F(){if(!o||!R.current)return;const[z,Z]=ko(b.current,R.current,k);E({x:z,y:Z}).then(te=>{if(!A.current||!te){x.current=requestAnimationFrame(F);return}const{x:ee,y:U}=b.current;H(ee,U),x.current=requestAnimationFrame(F)})}const O=()=>{cancelAnimationFrame(x.current),x.current=0,S.current=!1};N.useEffect(()=>()=>O(),[]);const B=z=>{const{userSelectionRect:Z,transform:te,resetSelectedElements:ee}=y.getState();if(!R.current||!Z)return;const{x:U,y:K}=De(z.nativeEvent,R.current);b.current={x:U,y:K};const ne=Mt({x:Z.startX,y:Z.startY},te);if(!A.current){const ie=t?0:r;if(Math.hypot(U-ne.x,K-ne.y)<=ie)return;ee(),c?.(z)}A.current=!0,S.current||(F(),S.current=!0),H(U,K)},Y=z=>{if(!C){z.target===I.current&&y.getState().connection.inProgress&&($.current=!0);return}z.button===0&&(z.target?.releasePointerCapture?.(z.pointerId),!j&&z.target===I.current&&y.getState().userSelectionRect&&_?.(z),y.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(l?.(z),y.setState({nodesSelectionActive:V.current.size>0})),O())},Q=z=>{z.target?.releasePointerCapture?.(z.pointerId),O()},G=s===!0||Array.isArray(s)&&s.includes(0);return a.jsxs("div",{className:me(["react-flow__pane",{draggable:G,dragging:v,selection:e}]),onClick:C?void 0:Ss(_,I),onContextMenu:Ss(M,I),onWheel:Ss(D,I),onPointerEnter:C?void 0:f,onPointerMove:C?B:p,onPointerUp:Y,onPointerCancel:C?Q:void 0,onPointerDownCapture:C?L:void 0,onClickCapture:C?P:void 0,onPointerLeave:m,ref:I,style:us,children:[w,a.jsx(lx,{})]})}function Ws({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:r,multiSelectionActive:i,nodeLookup:c,onError:l}=t.getState(),d=c.get(e);if(!d){l?.("012",Te.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(r({nodes:[d],edges:[]}),requestAnimationFrame(()=>s?.current?.blur())):o([e])}function gc({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:o,isSelectable:r,nodeClickDistance:i}){const c=le(),[l,d]=N.useState(!1),u=N.useRef();return N.useEffect(()=>{if(!t)return u.current=Qm({getStoreItems:()=>c.getState(),onNodeMouseDown:h=>{Ws({id:h,store:c,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,c,e]),N.useEffect(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:s,domNode:e.current,isSelectable:r,nodeId:o,nodeClickDistance:i})},[n,s,t,r,e,o,i]),l}const fx=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function xc(){const e=le();return N.useCallback(n=>{const{nodeExtent:s,snapToGrid:o,snapGrid:r,nodesDraggable:i,onError:c,updateNodePositions:l,nodeLookup:d,nodeOrigin:u}=e.getState(),h=new Map,f=fx(i),p=o?r[0]:5,m=o?r[1]:5,w=n.direction.x*p*n.factor,x=n.direction.y*m*n.factor;for(const[,y]of d){if(!f(y))continue;let j={x:y.internals.positionAbsolute.x+w,y:y.internals.positionAbsolute.y+x};o&&(j=dn(j,r));const{position:g,positionAbsolute:v}=Oa({nodeId:y.id,nextPosition:j,nodeLookup:d,nodeExtent:s,nodeOrigin:u,onError:c});y.position=g,y.internals.positionAbsolute=v,h.set(y.id,y)}l(h)},[])}const Ao=N.createContext(null),hx=Ao.Provider;Ao.Consumer;const yc=()=>N.useContext(Ao),px=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),wc=N.createContext(null);function mx({children:e}){const t=re(px,ue);return a.jsx(wc.Provider,{value:t,children:e})}function gx(){const e=N.useContext(wc);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const xx={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},yx=(e,t,n)=>s=>{const{connectionClickStartHandle:o,connectionMode:r,connection:i}=s,{fromHandle:c,toHandle:l,isValid:d}=i;if(!c&&!o)return xx;const u=l?.nodeId===e&&l?.id===t&&l?.type===n;return{connectingFrom:c?.nodeId===e&&c?.id===t&&c?.type===n,connectingTo:u,clickConnecting:o?.nodeId===e&&o?.id===t&&o?.type===n,isPossibleEndHandle:r===St.Strict?c?.type!==n:e!==c?.nodeId||t!==c?.id,connectionInProcess:!!c,clickConnectionInProcess:!!o,valid:u&&d}};function wx({type:e="source",position:t=q.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:r=!0,id:i,onConnect:c,children:l,className:d,onMouseDown:u,onTouchStart:h,...f},p){const m=i||null,w=e==="target",x=le(),y=yc(),{connectOnClick:j,noPanClassName:g,rfId:v}=gx(),{connectingFrom:E,connectingTo:k,clickConnecting:C,isPossibleEndHandle:I,connectionInProcess:R,clickConnectionInProcess:V,valid:T}=re(yx(y,m,e),ue);y||x.getState().onError?.("010",Te.error010());const $=S=>{const{defaultEdgeOptions:_,onConnect:M,hasDefaultEdges:D}=x.getState(),P={..._,...S};if(D){const{edges:L,setEdges:H,onError:F}=x.getState();H(Kg(P,L,{onError:F}))}M?.(P),c?.(P)},A=S=>{if(!y)return;const _=Xa(S.nativeEvent);if(o&&(_&&S.button===0||!_)){const M=x.getState();Bs.onPointerDown(S.nativeEvent,{handleDomNode:S.currentTarget,autoPanOnConnect:M.autoPanOnConnect,connectionMode:M.connectionMode,connectionRadius:M.connectionRadius,domNode:M.domNode,nodeLookup:M.nodeLookup,lib:M.lib,isTarget:w,handleId:m,nodeId:y,flowId:M.rfId,panBy:M.panBy,cancelConnection:M.cancelConnection,onConnectStart:M.onConnectStart,onConnectEnd:(...D)=>x.getState().onConnectEnd?.(...D),updateConnection:M.updateConnection,onConnect:$,isValidConnection:n||((...D)=>x.getState().isValidConnection?.(...D)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:M.autoPanSpeed,dragThreshold:M.connectionDragThreshold})}_?u?.(S):h?.(S)},b=S=>{const{onClickConnectStart:_,onClickConnectEnd:M,connectionClickStartHandle:D,connectionMode:P,isValidConnection:L,lib:H,rfId:F,nodeLookup:O,connection:B}=x.getState();if(!y||!D&&!o)return;if(!D){_?.(S.nativeEvent,{nodeId:y,handleId:m,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,id:m}});return}const Y=Wa(S.target),Q=n||L,{connection:G,isValid:z}=Bs.isValid(S.nativeEvent,{handle:{nodeId:y,id:m,type:e},connectionMode:P,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:Q,flowId:F,doc:Y,lib:H,nodeLookup:O});z&&G&&$(G);const Z=structuredClone(B);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,M?.(S,Z),x.setState({connectionClickStartHandle:null})};return a.jsx("div",{"data-handleid":m,"data-nodeid":y,"data-handlepos":t,"data-id":`${v}-${y}-${m}-${e}`,className:me(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,d,{source:!w,target:w,connectable:s,connectablestart:o,connectableend:r,clickconnecting:C,connectingfrom:E,connectingto:k,valid:T,connectionindicator:s&&(!R||I)&&(R||V?r:o)}]),onMouseDown:A,onTouchStart:A,onClick:j?b:void 0,ref:p,...f,children:l})}const Ie=N.memo(hc(wx));function vx({data:e,isConnectable:t,sourcePosition:n=q.Bottom}){return a.jsxs(a.Fragment,{children:[e?.label,a.jsx(Ie,{type:"source",position:n,isConnectable:t})]})}function bx({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:s=q.Bottom}){return a.jsxs(a.Fragment,{children:[a.jsx(Ie,{type:"target",position:n,isConnectable:t}),e?.label,a.jsx(Ie,{type:"source",position:s,isConnectable:t})]})}function Nx(){return null}function jx({data:e,isConnectable:t,targetPosition:n=q.Top}){return a.jsxs(a.Fragment,{children:[a.jsx(Ie,{type:"target",position:n,isConnectable:t}),e?.label]})}const Vn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ri={input:vx,default:bx,output:jx,group:Nx};function kx(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const Ex=e=>{const{width:t,height:n,x:s,y:o}=ln(e.nodeLookup,{filter:r=>!!r.selected});return{width:Ae(t)?t:null,height:Ae(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 Cx({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=le(),{width:o,height:r,transformString:i,userSelectionActive:c}=re(Ex,ue),l=xc(),d=N.useRef(null);N.useEffect(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const u=!c&&o!==null&&r!==null;if(gc({nodeRef:d,disabled:!u}),!u)return null;const h=e?p=>{const m=s.getState().nodes.filter(w=>w.selected);e(p,m)}:void 0,f=p=>{Object.prototype.hasOwnProperty.call(Vn,p.key)&&(p.preventDefault(),l({direction:Vn[p.key],factor:p.shiftKey?4:1}))};return a.jsx("div",{className:me(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:a.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:r}})})}const ii=typeof window<"u"?window:void 0,Sx=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function vc({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:r,onPaneScroll:i,paneClickDistance:c,deleteKeyCode:l,selectionKeyCode:d,selectionOnDrag:u,selectionMode:h,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:w,zoomActivationKeyCode:x,elementsSelectable:y,zoomOnScroll:j,zoomOnPinch:g,panOnScroll:v,panOnScrollSpeed:E,panOnScrollMode:k,zoomOnDoubleClick:C,panOnDrag:I,autoPanOnSelection:R,defaultViewport:V,translateExtent:T,minZoom:$,maxZoom:A,preventScrolling:b,onSelectionContextMenu:S,noWheelClassName:_,noPanClassName:M,disableKeyboardA11y:D,onViewportChange:P,isControlledViewport:L}){const{nodesSelectionActive:H,userSelectionActive:F}=re(Sx,ue),O=Jt(d,{target:ii}),B=Jt(w,{target:ii}),Y=B||I,Q=B||v,G=u&&Y!==!0,z=O||F||G;return ox({deleteKeyCode:l,multiSelectionKeyCode:m}),a.jsx(ax,{onPaneContextMenu:r,elementsSelectable:y,zoomOnScroll:j,zoomOnPinch:g,panOnScroll:Q,panActivationKeyPressed:B,panOnScrollSpeed:E,panOnScrollMode:k,zoomOnDoubleClick:C,panOnDrag:!O&&Y,defaultViewport:V,translateExtent:T,minZoom:$,maxZoom:A,zoomActivationKeyCode:x,preventScrolling:b,noWheelClassName:_,noPanClassName:M,onViewportChange:P,isControlledViewport:L,paneClickDistance:c,selectionOnDrag:G,children:a.jsxs(ux,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:r,onPaneScroll:i,panOnDrag:Y,autoPanOnSelection:R,isSelecting:!!z,selectionMode:h,selectionKeyPressed:O,paneClickDistance:c,selectionOnDrag:G,children:[e,H&&a.jsx(Cx,{onSelectionContextMenu:S,noPanClassName:M,disableKeyboardA11y:D})]})})}vc.displayName="FlowRenderer";const _x=N.memo(vc),Mx=e=>t=>e?jo(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 Ix(e){return re(N.useCallback(Mx(e),[e]),ue)}const $x=e=>e.updateNodeInternals;function Rx(){const e=re($x),[t]=N.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const s=new Map;n.forEach(o=>{const r=o.target.getAttribute("data-id");s.set(r,{id:r,nodeElement:o.target,force:!0})}),e(s)}));return N.useEffect(()=>()=>{t?.disconnect()},[t]),t}function Ax({node:e,nodeType:t,hasDimensions:n,resizeObserver:s}){const o=le(),r=N.useRef(null),i=N.useRef(null),c=N.useRef(e.sourcePosition),l=N.useRef(e.targetPosition),d=N.useRef(t),u=n&&!!e.internals.handleBounds;return N.useEffect(()=>{r.current&&!e.hidden&&(!u||i.current!==r.current)&&(i.current&&s?.unobserve(i.current),s?.observe(r.current),i.current=r.current)},[u,e.hidden]),N.useEffect(()=>()=>{i.current&&(s?.unobserve(i.current),i.current=null)},[]),N.useEffect(()=>{if(r.current){const h=d.current!==t,f=c.current!==e.sourcePosition,p=l.current!==e.targetPosition;(h||f||p)&&(d.current=t,c.current=e.sourcePosition,l.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:r.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),r}function Dx({id:e,onClick:t,onMouseEnter:n,onMouseMove:s,onMouseLeave:o,onContextMenu:r,onDoubleClick:i,nodesDraggable:c,elementsSelectable:l,nodesConnectable:d,nodesFocusable:u,resizeObserver:h,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:w,nodeTypes:x,nodeClickDistance:y,onError:j}){const{node:g,internals:v,isParent:E}=re(z=>{const Z=z.nodeLookup.get(e),te=z.parentLookup.has(e);return{node:Z,internals:Z.internals,isParent:te}},ue);let k=g.type||"default",C=x?.[k]||ri[k];C===void 0&&(j?.("003",Te.error003(k)),k="default",C=x?.default||ri.default);const I=!!(g.draggable||c&&typeof g.draggable>"u"),R=!!(g.selectable||l&&typeof g.selectable>"u"),V=!!(g.connectable||d&&typeof g.connectable>"u"),T=!!(g.focusable||u&&typeof g.focusable>"u"),$=le(),A=Fa(g),b=Ax({node:g,nodeType:k,hasDimensions:A,resizeObserver:h}),S=gc({nodeRef:b,disabled:g.hidden||!I,noDragClassName:f,handleSelector:g.dragHandle,nodeId:e,isSelectable:R,nodeClickDistance:y}),_=xc();if(g.hidden)return null;const M=ze(g),D=kx(g),P=R||I||t||n||s||o,L=n?z=>n(z,{...v.userNode}):void 0,H=s?z=>s(z,{...v.userNode}):void 0,F=o?z=>o(z,{...v.userNode}):void 0,O=r?z=>r(z,{...v.userNode}):void 0,B=i?z=>i(z,{...v.userNode}):void 0,Y=z=>{const{selectNodesOnDrag:Z,nodeDragThreshold:te}=$.getState();R&&(!Z||!I||te>0)&&Ws({id:e,store:$,nodeRef:b}),t&&t(z,{...v.userNode})},Q=z=>{if(!(Ya(z.nativeEvent)||m)){if(Ra.includes(z.key)&&R){const Z=z.key==="Escape";Ws({id:e,store:$,unselect:Z,nodeRef:b})}else if(I&&g.selected&&Object.prototype.hasOwnProperty.call(Vn,z.key)){z.preventDefault();const{ariaLabelConfig:Z}=$.getState();$.setState({ariaLiveMessage:Z["node.a11yDescription.ariaLiveMessage"]({direction:z.key.replace("Arrow","").toLowerCase(),x:~~v.positionAbsolute.x,y:~~v.positionAbsolute.y})}),_({direction:Vn[z.key],factor:z.shiftKey?4:1})}}},G=()=>{if(m||!b.current?.matches(":focus-visible"))return;const{transform:z,width:Z,height:te,autoPanOnNodeFocus:ee,setCenter:U}=$.getState();if(!ee)return;jo(new Map([[e,g]]),{x:0,y:0,width:Z,height:te},z,!0).length>0||U(g.position.x+M.width/2,g.position.y+M.height/2,{zoom:z[2]})};return a.jsx("div",{className:me(["react-flow__node",`react-flow__node-${k}`,{[p]:I},g.className,{selected:g.selected,selectable:R,parent:E,draggable:I,dragging:S}]),ref:b,style:{zIndex:v.z,transform:`translate(${v.positionAbsolute.x}px,${v.positionAbsolute.y}px)`,pointerEvents:P?"all":"none",visibility:A?"visible":"hidden",...g.style,...D},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:H,onMouseLeave:F,onContextMenu:O,onClick:Y,onDoubleClick:B,onKeyDown:T?Q:void 0,tabIndex:T?0:void 0,onFocus:T?G:void 0,role:g.ariaRole??(T?"group":void 0),"aria-roledescription":"node","aria-describedby":m?void 0:`${lc}-${w}`,"aria-label":g.ariaLabel,...g.domAttributes,children:a.jsx(hx,{value:e,children:a.jsx(C,{id:e,data:g.data,type:k,positionAbsoluteX:v.positionAbsolute.x,positionAbsoluteY:v.positionAbsolute.y,selected:g.selected??!1,selectable:R,draggable:I,deletable:g.deletable??!0,isConnectable:V,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:S,dragHandle:g.dragHandle,zIndex:v.z,parentId:g.parentId,...M})})})}var Px=N.memo(Dx);const Tx=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function bc(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:s,onError:o}=re(Tx,ue),r=Ix(e.onlyRenderVisibleElements),i=Rx();return a.jsx("div",{className:"react-flow__nodes",style:us,children:r.map(c=>a.jsx(Px,{id:c,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:i,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:o},c))})}bc.displayName="NodeRenderer";const Ox=N.memo(bc);function zx(e){return re(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 r=n.nodeLookup.get(o.source),i=n.nodeLookup.get(o.target);r&&i&&Am({sourceNode:r,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&s.push(o.id)}return s},[e]),ue)}const Lx=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return a.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Hx=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return a.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ai={[ut.Arrow]:Lx,[ut.ArrowClosed]:Hx};function Vx(e){const t=le();return N.useMemo(()=>Object.prototype.hasOwnProperty.call(ai,e)?ai[e]:(t.getState().onError?.("009",Te.error009(e)),null),[e])}const Fx=({id:e,type:t,color:n,width:s=12.5,height:o=12.5,markerUnits:r="strokeWidth",strokeWidth:i,orient:c="auto-start-reverse"})=>{const l=Vx(t);return l?a.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:r,orient:c,refX:"0",refY:"0",children:a.jsx(l,{color:n,strokeWidth:i})}):null},Nc=({defaultColor:e,rfId:t})=>{const n=re(r=>r.edges),s=re(r=>r.defaultEdgeOptions),o=N.useMemo(()=>Vm(n,{id:t,defaultColor:e,defaultMarkerStart:s?.markerStart,defaultMarkerEnd:s?.markerEnd}),[n,s,t,e]);return o.length?a.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:a.jsx("defs",{children:o.map(r=>a.jsx(Fx,{id:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient},r.id))})}):null};Nc.displayName="MarkerDefinitions";var Bx=N.memo(Nc);function jc({x:e,y:t,label:n,labelStyle:s,labelShowBg:o=!0,labelBgStyle:r,labelBgPadding:i=[2,4],labelBgBorderRadius:c=2,children:l,className:d,...u}){const[h,f]=N.useState({x:1,y:0,width:0,height:0}),p=me(["react-flow__edge-textwrapper",d]),m=N.useRef(null);return N.useEffect(()=>{if(m.current){const w=m.current.getBBox();f({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?a.jsxs("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:p,visibility:h.width?"visible":"hidden",...u,children:[o&&a.jsx("rect",{width:h.width+2*i[0],x:-i[0],y:-i[1],height:h.height+2*i[1],className:"react-flow__edge-textbg",style:r,rx:c,ry:c}),a.jsx("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:m,style:s,children:n}),l]}):null}jc.displayName="EdgeText";const Wx=N.memo(jc);function Tt({path:e,labelX:t,labelY:n,label:s,labelStyle:o,labelShowBg:r,labelBgStyle:i,labelBgPadding:c,labelBgBorderRadius:l,interactionWidth:d=20,...u}){return a.jsxs(a.Fragment,{children:[a.jsx("path",{...u,d:e,fill:"none",className:me(["react-flow__edge-path",u.className])}),d?a.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,s&&Ae(t)&&Ae(n)?a.jsx(Wx,{x:t,y:n,label:s,labelStyle:o,labelShowBg:r,labelBgStyle:i,labelBgPadding:c,labelBgBorderRadius:l}):null]})}function ci({pos:e,x1:t,y1:n,x2:s,y2:o}){return e===q.Left||e===q.Right?[.5*(t+s),n]:[t,.5*(n+o)]}function kc({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:r=q.Top}){const[i,c]=ci({pos:n,x1:e,y1:t,x2:s,y2:o}),[l,d]=ci({pos:r,x1:s,y1:o,x2:e,y2:t}),[u,h,f,p]=qa({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:i,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${e},${t} C${i},${c} ${l},${d} ${s},${o}`,u,h,f,p]}function Ec(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:r,sourcePosition:i,targetPosition:c,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,interactionWidth:y})=>{const[j,g,v]=kc({sourceX:n,sourceY:s,sourcePosition:i,targetX:o,targetY:r,targetPosition:c}),E=e.isInternal?void 0:t;return a.jsx(Tt,{id:E,path:j,labelX:g,labelY:v,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,interactionWidth:y})})}const Yx=Ec({isInternal:!1}),Cc=Ec({isInternal:!0});Yx.displayName="SimpleBezierEdge";Cc.displayName="SimpleBezierEdgeInternal";function Sc(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:r,label:i,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,sourcePosition:p=q.Bottom,targetPosition:m=q.Top,markerEnd:w,markerStart:x,pathOptions:y,interactionWidth:j})=>{const[g,v,E]=Hn({sourceX:n,sourceY:s,sourcePosition:p,targetX:o,targetY:r,targetPosition:m,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),k=e.isInternal?void 0:t;return a.jsx(Tt,{id:k,path:g,labelX:v,labelY:E,label:i,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:w,markerStart:x,interactionWidth:j})})}const _c=Sc({isInternal:!1}),Mc=Sc({isInternal:!0});_c.displayName="SmoothStepEdge";Mc.displayName="SmoothStepEdgeInternal";function Ic(e){return N.memo(({id:t,...n})=>{const s=e.isInternal?void 0:t;return a.jsx(_c,{...n,id:s,pathOptions:N.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const Xx=Ic({isInternal:!1}),$c=Ic({isInternal:!0});Xx.displayName="StepEdge";$c.displayName="StepEdgeInternal";function Rc(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:r,label:i,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})=>{const[x,y,j]=Ga({sourceX:n,sourceY:s,targetX:o,targetY:r}),g=e.isInternal?void 0:t;return a.jsx(Tt,{id:g,path:x,labelX:y,labelY:j,label:i,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})})}const qx=Rc({isInternal:!1}),Ac=Rc({isInternal:!0});qx.displayName="StraightEdge";Ac.displayName="StraightEdgeInternal";function Dc(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:r,sourcePosition:i=q.Bottom,targetPosition:c=q.Top,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,pathOptions:y,interactionWidth:j})=>{const[g,v,E]=So({sourceX:n,sourceY:s,sourcePosition:i,targetX:o,targetY:r,targetPosition:c,curvature:y?.curvature}),k=e.isInternal?void 0:t;return a.jsx(Tt,{id:k,path:g,labelX:v,labelY:E,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,interactionWidth:j})})}const Zx=Dc({isInternal:!1}),Pc=Dc({isInternal:!0});Zx.displayName="BezierEdge";Pc.displayName="BezierEdgeInternal";const li={default:Pc,straight:Ac,step:$c,smoothstep:Mc,simplebezier:Cc},di={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Gx=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,Ux=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,ui="react-flow__edgeupdater";function fi({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:o,onMouseEnter:r,onMouseOut:i,type:c}){return a.jsx("circle",{onMouseDown:o,onMouseEnter:r,onMouseOut:i,className:me([ui,`${ui}-${c}`]),cx:Gx(t,s,e),cy:Ux(n,s,e),r:s,stroke:"transparent",fill:"transparent"})}function Kx({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:s,sourceY:o,targetX:r,targetY:i,sourcePosition:c,targetPosition:l,onReconnect:d,onReconnectStart:u,onReconnectEnd:h,setReconnecting:f,setUpdateHover:p}){const m=le(),w=(v,E)=>{if(v.button!==0)return;const{autoPanOnConnect:k,domNode:C,connectionMode:I,connectionRadius:R,lib:V,onConnectStart:T,cancelConnection:$,nodeLookup:A,rfId:b,panBy:S,updateConnection:_}=m.getState(),M=E.type==="target",D=(H,F)=>{f(!1),h?.(H,n,E.type,F)},P=H=>d?.(n,H),L=(H,F)=>{f(!0),u?.(v,n,E.type),T?.(H,F)};Bs.onPointerDown(v.nativeEvent,{autoPanOnConnect:k,connectionMode:I,connectionRadius:R,domNode:C,handleId:E.id,nodeId:E.nodeId,nodeLookup:A,isTarget:M,edgeUpdaterType:E.type,lib:V,flowId:b,cancelConnection:$,panBy:S,isValidConnection:(...H)=>m.getState().isValidConnection?.(...H)??!0,onConnect:P,onConnectStart:L,onConnectEnd:(...H)=>m.getState().onConnectEnd?.(...H),onReconnectEnd:D,updateConnection:_,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:v.currentTarget})},x=v=>w(v,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=v=>w(v,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),j=()=>p(!0),g=()=>p(!1);return a.jsxs(a.Fragment,{children:[(e===!0||e==="source")&&a.jsx(fi,{position:c,centerX:s,centerY:o,radius:t,onMouseDown:x,onMouseEnter:j,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&a.jsx(fi,{position:l,centerX:r,centerY:i,radius:t,onMouseDown:y,onMouseEnter:j,onMouseOut:g,type:"target"})]})}function Qx({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:s,onClick:o,onDoubleClick:r,onContextMenu:i,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,reconnectRadius:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:w,noPanClassName:x,onError:y,disableKeyboardA11y:j}){let g=re(U=>U.edgeLookup.get(e));const v=re(U=>U.defaultEdgeOptions);g=v?{...v,...g}:g;let E=g.type||"default",k=w?.[E]||li[E];k===void 0&&(y?.("011",Te.error011(E)),E="default",k=w?.default||li.default);const C=!!(g.focusable||t&&typeof g.focusable>"u"),I=typeof h<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),R=!!(g.selectable||s&&typeof g.selectable>"u"),V=N.useRef(null),[T,$]=N.useState(!1),[A,b]=N.useState(!1),S=le(),{zIndex:_=g.zIndex,sourceX:M,sourceY:D,targetX:P,targetY:L,sourcePosition:H,targetPosition:F}=re(N.useCallback(U=>{const K=U.nodeLookup.get(g.source),ne=U.nodeLookup.get(g.target);if(!K||!ne)return di;const ie=Hm({id:e,sourceNode:K,targetNode:ne,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:U.connectionMode,onError:y}),ce=Rm({selected:g.selected,zIndex:g.zIndex,sourceNode:K,targetNode:ne,elevateOnSelect:U.elevateEdgesOnSelect,zIndexMode:U.zIndexMode});return{...ie||di,zIndex:ce}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex,y]),ue),O=N.useMemo(()=>g.markerStart?`url('#${Vs(g.markerStart,m)}')`:void 0,[g.markerStart,m]),B=N.useMemo(()=>g.markerEnd?`url('#${Vs(g.markerEnd,m)}')`:void 0,[g.markerEnd,m]);if(g.hidden||M===null||D===null||P===null||L===null)return null;const Y=U=>{const{addSelectedEdges:K,unselectNodesAndEdges:ne,multiSelectionActive:ie}=S.getState();R&&(S.setState({nodesSelectionActive:!1}),g.selected&&ie?(ne({nodes:[],edges:[g]}),V.current?.blur()):K([e])),o&&o(U,g)},Q=r?U=>{r(U,{...g})}:void 0,G=i?U=>{i(U,{...g})}:void 0,z=c?U=>{c(U,{...g})}:void 0,Z=l?U=>{l(U,{...g})}:void 0,te=d?U=>{d(U,{...g})}:void 0,ee=U=>{if(!j&&Ra.includes(U.key)&&R){const{unselectNodesAndEdges:K,addSelectedEdges:ne}=S.getState();U.key==="Escape"?(V.current?.blur(),K({edges:[g]})):ne([e])}};return a.jsx("svg",{style:{zIndex:_},children:a.jsxs("g",{className:me(["react-flow__edge",`react-flow__edge-${E}`,g.className,x,{selected:g.selected,animated:g.animated,inactive:!R&&!o,updating:T,selectable:R}]),onClick:Y,onDoubleClick:Q,onContextMenu:G,onMouseEnter:z,onMouseMove:Z,onMouseLeave:te,onKeyDown:C?ee:void 0,tabIndex:C?0:void 0,role:g.ariaRole??(C?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":C?`${dc}-${m}`:void 0,ref:V,...g.domAttributes,children:[!A&&a.jsx(k,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:R,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:M,sourceY:D,targetX:P,targetY:L,sourcePosition:H,targetPosition:F,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:O,markerEnd:B,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),I&&a.jsx(Kx,{edge:g,isReconnectable:I,reconnectRadius:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,sourceX:M,sourceY:D,targetX:P,targetY:L,sourcePosition:H,targetPosition:F,setUpdateHover:$,setReconnecting:b})]})})}var Jx=N.memo(Qx);const e0=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Tc({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:s,noPanClassName:o,onReconnect:r,onEdgeContextMenu:i,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:d,onEdgeClick:u,reconnectRadius:h,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:w}){const{edgesFocusable:x,edgesReconnectable:y,elementsSelectable:j,onError:g}=re(e0,ue),v=zx(t);return a.jsxs("div",{className:"react-flow__edges",children:[a.jsx(Bx,{defaultColor:e,rfId:n}),v.map(E=>a.jsx(Jx,{id:E,edgesFocusable:x,edgesReconnectable:y,elementsSelectable:j,noPanClassName:o,onReconnect:r,onContextMenu:i,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,onClick:u,reconnectRadius:h,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:g,edgeTypes:s,disableKeyboardA11y:w},E))]})}Tc.displayName="EdgeRenderer";const t0=N.memo(Tc),hi=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function n0({children:e}){const t=le(),n=N.useRef(null),[s]=N.useState(()=>t.getState().transform);return pc(()=>{let o=null;const r=()=>{const i=t.getState().transform;o&&i[0]===o[0]&&i[1]===o[1]&&i[2]===o[2]||(o=i,n.current&&(n.current.style.transform=hi(i)))};return r(),t.subscribe(r)},[t]),a.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:hi(s)},children:e})}function s0(e){const t=Pt(),n=N.useRef(!1);N.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const o0=e=>e.panZoom?.syncViewport;function r0(e){const t=re(o0),n=le();return N.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function i0(e){return e.connection.inProgress?{...e.connection,to:un(e.connection.to,e.transform)}:{...e.connection}}function a0(e){return i0}function c0(e){const t=a0();return re(t,ue)}const l0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function d0({containerStyle:e,style:t,type:n,component:s}){const{nodesConnectable:o,width:r,height:i,isValid:c,inProgress:l}=re(l0,ue);return!(r&&o&&l)?null:a.jsx("svg",{style:e,width:r,height:i,className:"react-flow__connectionline react-flow__container",children:a.jsx("g",{className:me(["react-flow__connection",Pa(c)]),children:a.jsx(Oc,{style:t,type:n,CustomComponent:s,isValid:c})})})}const Oc=({style:e,type:t=Je.Bezier,CustomComponent:n,isValid:s})=>{const{inProgress:o,from:r,fromNode:i,fromHandle:c,fromPosition:l,to:d,toNode:u,toHandle:h,toPosition:f,pointer:p}=c0();if(!o)return;if(n)return a.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:c,fromX:r.x,fromY:r.y,toX:d.x,toY:d.y,fromPosition:l,toPosition:f,connectionStatus:Pa(s),toNode:u,toHandle:h,pointer:p});let m="";const w={sourceX:r.x,sourceY:r.y,sourcePosition:l,targetX:d.x,targetY:d.y,targetPosition:f};switch(t){case Je.Bezier:[m]=So(w);break;case Je.SimpleBezier:[m]=kc(w);break;case Je.Step:[m]=Hn({...w,borderRadius:0});break;case Je.SmoothStep:[m]=Hn(w);break;default:[m]=Ga(w)}return a.jsx("path",{d:m,fill:"none",className:"react-flow__connection-path",style:e})};Oc.displayName="ConnectionLine";const u0={};function pi(e=u0){N.useRef(e),le(),N.useEffect(()=>{},[e])}function f0(){le(),N.useRef(!1),N.useEffect(()=>{},[])}function zc({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:s,onEdgeClick:o,onNodeDoubleClick:r,onEdgeDoubleClick:i,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:u,onSelectionContextMenu:h,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:w,connectionLineComponent:x,connectionLineContainerStyle:y,selectionKeyCode:j,selectionOnDrag:g,selectionMode:v,multiSelectionKeyCode:E,panActivationKeyCode:k,zoomActivationKeyCode:C,deleteKeyCode:I,onlyRenderVisibleElements:R,elementsSelectable:V,defaultViewport:T,translateExtent:$,minZoom:A,maxZoom:b,preventScrolling:S,defaultMarkerColor:_,zoomOnScroll:M,zoomOnPinch:D,panOnScroll:P,panOnScrollSpeed:L,panOnScrollMode:H,zoomOnDoubleClick:F,panOnDrag:O,autoPanOnSelection:B,onPaneClick:Y,onPaneMouseEnter:Q,onPaneMouseMove:G,onPaneMouseLeave:z,onPaneScroll:Z,onPaneContextMenu:te,paneClickDistance:ee,nodeClickDistance:U,onEdgeContextMenu:K,onEdgeMouseEnter:ne,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:pe,onReconnect:Ne,onReconnectStart:Ce,onReconnectEnd:Se,noDragClassName:W,noWheelClassName:J,noPanClassName:oe,disableKeyboardA11y:he,nodeExtent:se,rfId:fe,viewport:de,onViewportChange:je,nodesDraggable:hs}){return pi(e),pi(t),f0(),s0(n),r0(de),a.jsx(_x,{onPaneClick:Y,onPaneMouseEnter:Q,onPaneMouseMove:G,onPaneMouseLeave:z,onPaneContextMenu:te,onPaneScroll:Z,paneClickDistance:ee,deleteKeyCode:I,selectionKeyCode:j,selectionOnDrag:g,selectionMode:v,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:E,panActivationKeyCode:k,zoomActivationKeyCode:C,elementsSelectable:V,zoomOnScroll:M,zoomOnPinch:D,zoomOnDoubleClick:F,panOnScroll:P,panOnScrollSpeed:L,panOnScrollMode:H,panOnDrag:O,autoPanOnSelection:B,defaultViewport:T,translateExtent:$,minZoom:A,maxZoom:b,onSelectionContextMenu:h,preventScrolling:S,noDragClassName:W,noWheelClassName:J,noPanClassName:oe,disableKeyboardA11y:he,onViewportChange:je,isControlledViewport:!!de,children:a.jsxs(n0,{children:[a.jsx(t0,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:i,onReconnect:Ne,onReconnectStart:Ce,onReconnectEnd:Se,onlyRenderVisibleElements:R,onEdgeContextMenu:K,onEdgeMouseEnter:ne,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:pe,defaultMarkerColor:_,noPanClassName:oe,disableKeyboardA11y:he,rfId:fe}),a.jsx(d0,{style:w,type:m,component:x,containerStyle:y}),a.jsx("div",{className:"react-flow__edgelabel-renderer"}),a.jsx(Ox,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:r,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:u,nodeClickDistance:U,onlyRenderVisibleElements:R,noPanClassName:oe,noDragClassName:W,disableKeyboardA11y:he,nodeExtent:se,rfId:fe,nodesDraggable:hs}),a.jsx("div",{className:"react-flow__viewport-portal"})]})})}zc.displayName="GraphView";const h0=N.memo(zc),p0=Va(),mi=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:r,fitView:i,fitViewOptions:c,minZoom:l=.5,maxZoom:d=2,nodeOrigin:u,nodeExtent:h,zIndexMode:f="basic"}={})=>{const p=new Map,m=new Map,w=new Map,x=new Map,y=s??t??[],j=n??e??[],g=u??[0,0],v=h??Gt;Qa(w,x,y);const{nodesInitialized:E}=Fs(j,p,m,{nodeOrigin:g,nodeExtent:v,zIndexMode:f});let k=[0,0,1];if(i&&o&&r){const C=ln(p,{filter:T=>!!((T.width||T.initialWidth)&&(T.height||T.initialHeight))}),{x:I,y:R,zoom:V}=Eo(C,o,r,l,d,c?.padding??.1);k=[I,R,V]}return{rfId:"1",width:o??0,height:r??0,transform:k,nodes:j,nodesInitialized:E,nodeLookup:p,parentLookup:m,edges:y,edgeLookup:x,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:l,maxZoom:d,translateExtent:Gt,nodeExtent:v,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:St.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:g,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:i??!1,fitViewOptions:c,fitViewResolver:null,connection:{...Da},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:p0,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Aa,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},m0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:r,fitView:i,fitViewOptions:c,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:h,zIndexMode:f})=>Mg((p,m)=>{async function w(){const{nodeLookup:x,panZoom:y,fitViewOptions:j,fitViewResolver:g,width:v,height:E,minZoom:k,maxZoom:C}=m();y&&(await Em({nodes:x,width:v,height:E,panZoom:y,minZoom:k,maxZoom:C},j),g?.resolve(!0),p({fitViewResolver:null}))}return{...mi({nodes:e,edges:t,width:o,height:r,fitView:i,fitViewOptions:c,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:h,defaultNodes:n,defaultEdges:s,zIndexMode:f}),setNodes:x=>{const{nodeLookup:y,parentLookup:j,nodeOrigin:g,nodeExtent:v,elevateNodesOnSelect:E,fitViewQueued:k,zIndexMode:C,nodesSelectionActive:I}=m(),{nodesInitialized:R,hasSelectedNodes:V}=Fs(x,y,j,{nodeOrigin:g,nodeExtent:v,elevateNodesOnSelect:E,checkEquality:!0,zIndexMode:C}),T=I&&V;k&&R?(w(),p({nodes:x,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:T})):p({nodes:x,nodesInitialized:R,nodesSelectionActive:T})},setEdges:x=>{const{connectionLookup:y,edgeLookup:j}=m();Qa(y,j,x),p({edges:x})},setDefaultNodesAndEdges:(x,y)=>{if(x){const{setNodes:j}=m();j(x),p({hasDefaultNodes:!0})}if(y){const{setEdges:j}=m();j(y),p({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:y,nodeLookup:j,parentLookup:g,domNode:v,nodeOrigin:E,nodeExtent:k,debug:C,fitViewQueued:I,zIndexMode:R}=m(),{changes:V,updatedInternals:T}=Zm(x,j,g,v,E,k,R);T&&(Wm(j,g,{nodeOrigin:E,nodeExtent:k,zIndexMode:R}),I?(w(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),V?.length>0&&(C&&console.log("React Flow: trigger node changes",V),y?.(V)))},updateNodePositions:(x,y=!1)=>{const j=[];let g=[];const{nodeLookup:v,triggerNodeChanges:E,connection:k,updateConnection:C,onNodesChangeMiddlewareMap:I}=m();for(const[R,V]of x){const T=v.get(R),$=!!(T?.expandParent&&T?.parentId&&V?.position),A={id:R,type:"position",position:$?{x:Math.max(0,V.position.x),y:Math.max(0,V.position.y)}:V.position,dragging:y};if(T&&k.inProgress&&k.fromNode.id===T.id){const b=pt(T,k.fromHandle,q.Left,!0);C({...k,from:b})}$&&T.parentId&&j.push({id:R,parentId:T.parentId,rect:{...V.internals.positionAbsolute,width:V.measured.width??0,height:V.measured.height??0}}),g.push(A)}if(j.length>0){const{parentLookup:R,nodeOrigin:V}=m(),T=Ro(j,v,R,V);g.push(...T)}for(const R of I.values())g=R(g);E(g)},triggerNodeChanges:x=>{const{onNodesChange:y,setNodes:j,nodes:g,hasDefaultNodes:v,debug:E}=m();if(x?.length){if(v){const k=ls(x,g);j(k)}E&&console.log("React Flow: trigger node changes",x),y?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:y,setEdges:j,edges:g,hasDefaultEdges:v,debug:E}=m();if(x?.length){if(v){const k=ds(x,g);j(k)}E&&console.log("React Flow: trigger edge changes",x),y?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:y,edgeLookup:j,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:E}=m();if(y){const k=x.map(C=>nt(C,!0));v(k);return}v(vt(g,new Set([...x]),!0)),E(vt(j))},addSelectedEdges:x=>{const{multiSelectionActive:y,edgeLookup:j,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:E}=m();if(y){const k=x.map(C=>nt(C,!0));E(k);return}E(vt(j,new Set([...x]))),v(vt(g,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:y}={})=>{const{edges:j,nodes:g,nodeLookup:v,triggerNodeChanges:E,triggerEdgeChanges:k}=m(),C=x||g,I=y||j,R=[];for(const T of C){if(!T.selected)continue;const $=v.get(T.id);$&&($.selected=!1),R.push(nt(T.id,!1))}const V=[];for(const T of I)T.selected&&V.push(nt(T.id,!1));E(R),k(V)},setMinZoom:x=>{const{panZoom:y,maxZoom:j}=m();y?.setScaleExtent([x,j]),p({minZoom:x})},setMaxZoom:x=>{const{panZoom:y,minZoom:j}=m();y?.setScaleExtent([j,x]),p({maxZoom:x})},setTranslateExtent:x=>{m().panZoom?.setTranslateExtent(x),p({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:y,triggerNodeChanges:j,triggerEdgeChanges:g,elementsSelectable:v}=m();if(!v)return;const E=y.reduce((C,I)=>I.selected?[...C,nt(I.id,!1)]:C,[]),k=x.reduce((C,I)=>I.selected?[...C,nt(I.id,!1)]:C,[]);j(E),g(k)},setNodeExtent:x=>{const{nodes:y,nodeLookup:j,parentLookup:g,nodeOrigin:v,elevateNodesOnSelect:E,nodeExtent:k,zIndexMode:C}=m();x[0][0]===k[0][0]&&x[0][1]===k[0][1]&&x[1][0]===k[1][0]&&x[1][1]===k[1][1]||(Fs(y,j,g,{nodeOrigin:v,nodeExtent:x,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:C}),p({nodeExtent:x}))},panBy:x=>{const{transform:y,width:j,height:g,panZoom:v,translateExtent:E}=m();return Gm({delta:x,panZoom:v,transform:y,translateExtent:E,width:j,height:g})},setCenter:async(x,y,j)=>{const{width:g,height:v,maxZoom:E,panZoom:k}=m();if(!k)return!1;const C=typeof j?.zoom<"u"?j.zoom:E;return await k.setViewport({x:g/2-x*C,y:v/2-y*C,zoom:C},{duration:j?.duration,ease:j?.ease,interpolate:j?.interpolate}),!0},cancelConnection:()=>{p({connection:{...Da}})},updateConnection:x=>{p({connection:x})},reset:()=>p({...mi()})}},Object.is);function Do({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:s,initialWidth:o,initialHeight:r,initialMinZoom:i,initialMaxZoom:c,initialFitViewOptions:l,fitView:d,nodeOrigin:u,nodeExtent:h,zIndexMode:f,children:p}){const[m]=N.useState(()=>m0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:r,fitView:d,minZoom:i,maxZoom:c,fitViewOptions:l,nodeOrigin:u,nodeExtent:h,zIndexMode:f}));return a.jsx(Ig,{value:m,children:a.jsx(ex,{children:a.jsx(mx,{children:p})})})}function g0({children:e,nodes:t,edges:n,defaultNodes:s,defaultEdges:o,width:r,height:i,fitView:c,fitViewOptions:l,minZoom:d,maxZoom:u,nodeOrigin:h,nodeExtent:f,zIndexMode:p}){return N.useContext(cs)?a.jsx(a.Fragment,{children:e}):a.jsx(Do,{initialNodes:t,initialEdges:n,defaultNodes:s,defaultEdges:o,initialWidth:r,initialHeight:i,fitView:c,initialFitViewOptions:l,initialMinZoom:d,initialMaxZoom:u,nodeOrigin:h,nodeExtent:f,zIndexMode:p,children:e})}const x0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function y0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:o,nodeTypes:r,edgeTypes:i,onNodeClick:c,onEdgeClick:l,onInit:d,onMove:u,onMoveStart:h,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:w,onClickConnectStart:x,onClickConnectEnd:y,onNodeMouseEnter:j,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:k,onNodeDragStart:C,onNodeDrag:I,onNodeDragStop:R,onNodesDelete:V,onEdgesDelete:T,onDelete:$,onSelectionChange:A,onSelectionDragStart:b,onSelectionDrag:S,onSelectionDragStop:_,onSelectionContextMenu:M,onSelectionStart:D,onSelectionEnd:P,onBeforeDelete:L,connectionMode:H,connectionLineType:F=Je.Bezier,connectionLineStyle:O,connectionLineComponent:B,connectionLineContainerStyle:Y,deleteKeyCode:Q="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:z=!1,selectionMode:Z=Ut.Full,panActivationKeyCode:te="Space",multiSelectionKeyCode:ee=Qt()?"Meta":"Control",zoomActivationKeyCode:U=Qt()?"Meta":"Control",snapToGrid:K,snapGrid:ne,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ce,nodesDraggable:pe,autoPanOnNodeFocus:Ne,nodesConnectable:Ce,nodesFocusable:Se,nodeOrigin:W=uc,edgesFocusable:J,edgesReconnectable:oe,elementsSelectable:he=!0,defaultViewport:se=Bg,minZoom:fe=.5,maxZoom:de=2,translateExtent:je=Gt,preventScrolling:hs=!0,nodeExtent:ps,defaultMarkerColor:Nl="#b1b1b7",zoomOnScroll:jl=!0,zoomOnPinch:kl=!0,panOnScroll:El=!1,panOnScrollSpeed:Cl=.5,panOnScrollMode:Sl=at.Free,zoomOnDoubleClick:_l=!0,panOnDrag:Ml=!0,onPaneClick:Il,onPaneMouseEnter:$l,onPaneMouseMove:Rl,onPaneMouseLeave:Al,onPaneScroll:Dl,onPaneContextMenu:Pl,paneClickDistance:Tl=1,nodeClickDistance:Ol=0,children:zl,onReconnect:Ll,onReconnectStart:Hl,onReconnectEnd:Vl,onEdgeContextMenu:Fl,onEdgeDoubleClick:Bl,onEdgeMouseEnter:Wl,onEdgeMouseMove:Yl,onEdgeMouseLeave:Xl,reconnectRadius:ql=10,onNodesChange:Zl,onEdgesChange:Gl,noDragClassName:Ul="nodrag",noWheelClassName:Kl="nowheel",noPanClassName:Go="nopan",fitView:Uo,fitViewOptions:Ko,connectOnClick:Ql,attributionPosition:Jl,proOptions:ed,defaultEdgeOptions:td,elevateNodesOnSelect:nd=!0,elevateEdgesOnSelect:sd=!1,disableKeyboardA11y:Qo=!1,autoPanOnConnect:od,autoPanOnNodeDrag:rd,autoPanOnSelection:id=!0,autoPanSpeed:ad,connectionRadius:cd,isValidConnection:ld,onError:dd,style:ud,id:Jo,nodeDragThreshold:fd,connectionDragThreshold:hd,viewport:pd,onViewportChange:md,width:gd,height:xd,colorMode:yd="light",debug:wd,onScroll:er,ariaLabelConfig:vd,zIndexMode:tr="basic",...bd},Nd){const ms=Jo||"1",jd=qg(yd),kd=N.useCallback(nr=>{nr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),er?.(nr)},[er]);return a.jsx("div",{"data-testid":"rf__wrapper",...bd,onScroll:kd,style:{...ud,...x0},ref:Nd,className:me(["react-flow",o,jd]),id:Jo,role:"application",children:a.jsxs(g0,{nodes:e,edges:t,width:gd,height:xd,fitView:Uo,fitViewOptions:Ko,minZoom:fe,maxZoom:de,nodeOrigin:W,nodeExtent:ps,zIndexMode:tr,children:[a.jsx(Xg,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:p,onConnectStart:m,onConnectEnd:w,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:pe,autoPanOnNodeFocus:Ne,nodesConnectable:Ce,nodesFocusable:Se,edgesFocusable:J,edgesReconnectable:oe,elementsSelectable:he,elevateNodesOnSelect:nd,elevateEdgesOnSelect:sd,minZoom:fe,maxZoom:de,nodeExtent:ps,onNodesChange:Zl,onEdgesChange:Gl,snapToGrid:K,snapGrid:ne,connectionMode:H,translateExtent:je,connectOnClick:Ql,defaultEdgeOptions:td,fitView:Uo,fitViewOptions:Ko,onNodesDelete:V,onEdgesDelete:T,onDelete:$,onNodeDragStart:C,onNodeDrag:I,onNodeDragStop:R,onSelectionDrag:S,onSelectionDragStart:b,onSelectionDragStop:_,onMove:u,onMoveStart:h,onMoveEnd:f,noPanClassName:Go,nodeOrigin:W,rfId:ms,autoPanOnConnect:od,autoPanOnNodeDrag:rd,autoPanSpeed:ad,onError:dd,connectionRadius:cd,isValidConnection:ld,selectNodesOnDrag:ce,nodeDragThreshold:fd,connectionDragThreshold:hd,onBeforeDelete:L,debug:wd,ariaLabelConfig:vd,zIndexMode:tr}),a.jsx(h0,{onInit:d,onNodeClick:c,onEdgeClick:l,onNodeMouseEnter:j,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:k,nodeTypes:r,edgeTypes:i,connectionLineType:F,connectionLineStyle:O,connectionLineComponent:B,connectionLineContainerStyle:Y,selectionKeyCode:G,selectionOnDrag:z,selectionMode:Z,deleteKeyCode:Q,multiSelectionKeyCode:ee,panActivationKeyCode:te,zoomActivationKeyCode:U,onlyRenderVisibleElements:ie,defaultViewport:se,translateExtent:je,minZoom:fe,maxZoom:de,preventScrolling:hs,zoomOnScroll:jl,zoomOnPinch:kl,zoomOnDoubleClick:_l,panOnScroll:El,panOnScrollSpeed:Cl,panOnScrollMode:Sl,panOnDrag:Ml,autoPanOnSelection:id,onPaneClick:Il,onPaneMouseEnter:$l,onPaneMouseMove:Rl,onPaneMouseLeave:Al,onPaneScroll:Dl,onPaneContextMenu:Pl,paneClickDistance:Tl,nodeClickDistance:Ol,onSelectionContextMenu:M,onSelectionStart:D,onSelectionEnd:P,onReconnect:Ll,onReconnectStart:Hl,onReconnectEnd:Vl,onEdgeContextMenu:Fl,onEdgeDoubleClick:Bl,onEdgeMouseEnter:Wl,onEdgeMouseMove:Yl,onEdgeMouseLeave:Xl,reconnectRadius:ql,defaultMarkerColor:Nl,noDragClassName:Ul,noWheelClassName:Kl,noPanClassName:Go,rfId:ms,disableKeyboardA11y:Qo,nodeExtent:ps,viewport:pd,onViewportChange:md,nodesDraggable:pe}),a.jsx(Fg,{onSelectionChange:A}),zl,a.jsx(Og,{proOptions:ed,position:Jl}),a.jsx(Tg,{rfId:ms,disableKeyboardA11y:Qo})]})})}var Po=hc(y0);const w0=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function v0({children:e}){const t=re(w0);return t?zd.createPortal(e,t):null}function Fn(e){return re(N.useCallback(n=>n.nodeLookup.get(e),[e]),ue)}function b0({dimensions:e,lineWidth:t,variant:n,className:s}){return a.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:me(["react-flow__background-pattern",n,s])})}function N0({radius:e,className:t}){return a.jsx("circle",{cx:e,cy:e,r:e,className:me(["react-flow__background-pattern","dots",t])})}var et;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(et||(et={}));const j0={[et.Dots]:1,[et.Lines]:1,[et.Cross]:6},k0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Lc({id:e,variant:t=et.Dots,gap:n=20,size:s,lineWidth:o=1,offset:r=0,color:i,bgColor:c,style:l,className:d,patternClassName:u}){const h=N.useRef(null),{transform:f,patternId:p}=re(k0,ue),m=s||j0[t],w=t===et.Dots,x=t===et.Cross,y=Array.isArray(n)?n:[n,n],j=[y[0]*f[2]||1,y[1]*f[2]||1],g=m*f[2],v=Array.isArray(r)?r:[r,r],E=x?[g,g]:j,k=[v[0]*f[2]+E[0]/2,v[1]*f[2]+E[1]/2],C=`${p}${e||""}`;return a.jsxs("svg",{className:me(["react-flow__background",d]),style:{...l,...us,"--xy-background-color-props":c,"--xy-background-pattern-color-props":i},ref:h,"data-testid":"rf__background",children:[a.jsx("pattern",{id:C,x:f[0]%j[0],y:f[1]%j[1],width:j[0],height:j[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:w?a.jsx(N0,{radius:g/2,className:u}):a.jsx(b0,{dimensions:E,lineWidth:o,variant:t,className:u})}),a.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${C})`})]})}Lc.displayName="Background";const To=N.memo(Lc);function E0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:a.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function C0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:a.jsx("path",{d:"M0 0h32v4.2H0z"})})}function S0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:a.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 _0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a.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 M0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a.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 bt({children:e,className:t,...n}){return a.jsx("button",{type:"button",className:me(["react-flow__controls-button",t]),...n,children:e})}const I0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Hc({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:r,onZoomOut:i,onFitView:c,onInteractiveChange:l,className:d,children:u,position:h="bottom-left",orientation:f="vertical","aria-label":p}){const m=le(),{isInteractive:w,minZoomReached:x,maxZoomReached:y,ariaLabelConfig:j}=re(I0,ue),{zoomIn:g,zoomOut:v,fitView:E}=Pt(),k=()=>{g(),r?.()},C=()=>{v(),i?.()},I=()=>{E(o),c?.()},R=()=>{m.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),l?.(!w)},V=f==="horizontal"?"horizontal":"vertical";return a.jsxs(tt,{className:me(["react-flow__controls",V,d]),position:h,style:e,"data-testid":"rf__controls","aria-label":p??j["controls.ariaLabel"],children:[t&&a.jsxs(a.Fragment,{children:[a.jsx(bt,{onClick:k,className:"react-flow__controls-zoomin",title:j["controls.zoomIn.ariaLabel"],"aria-label":j["controls.zoomIn.ariaLabel"],disabled:y,children:a.jsx(E0,{})}),a.jsx(bt,{onClick:C,className:"react-flow__controls-zoomout",title:j["controls.zoomOut.ariaLabel"],"aria-label":j["controls.zoomOut.ariaLabel"],disabled:x,children:a.jsx(C0,{})})]}),n&&a.jsx(bt,{className:"react-flow__controls-fitview",onClick:I,title:j["controls.fitView.ariaLabel"],"aria-label":j["controls.fitView.ariaLabel"],children:a.jsx(S0,{})}),s&&a.jsx(bt,{className:"react-flow__controls-interactive",onClick:R,title:j["controls.interactive.ariaLabel"],"aria-label":j["controls.interactive.ariaLabel"],children:w?a.jsx(M0,{}):a.jsx(_0,{})}),u]})}Hc.displayName="Controls";const Oo=N.memo(Hc);function $0({id:e,x:t,y:n,width:s,height:o,style:r,color:i,strokeColor:c,strokeWidth:l,className:d,borderRadius:u,shapeRendering:h,selected:f,onClick:p}){const{background:m,backgroundColor:w}=r||{},x=i||m||w;return a.jsx("rect",{className:me(["react-flow__minimap-node",{selected:f},d]),x:t,y:n,rx:u,ry:u,width:s,height:o,style:{fill:x,stroke:c,strokeWidth:l},shapeRendering:h,onClick:p?y=>p(y,e):void 0})}const R0=N.memo($0),A0=e=>e.nodes.map(t=>t.id),_s=e=>e instanceof Function?e:()=>e;function D0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:o,nodeComponent:r=R0,onClick:i}){const c=re(A0,ue),l=_s(t),d=_s(e),u=_s(n),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return a.jsx(a.Fragment,{children:c.map(f=>a.jsx(T0,{id:f,nodeColorFunc:l,nodeStrokeColorFunc:d,nodeClassNameFunc:u,nodeBorderRadius:s,nodeStrokeWidth:o,NodeComponent:r,onClick:i,shapeRendering:h},f))})}function P0({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:s,nodeBorderRadius:o,nodeStrokeWidth:r,shapeRendering:i,NodeComponent:c,onClick:l}){const{node:d,x:u,y:h,width:f,height:p}=re(m=>{const w=m.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const x=w.internals.userNode,{x:y,y:j}=w.internals.positionAbsolute,{width:g,height:v}=ze(x);return{node:x,x:y,y:j,width:g,height:v}},ue);return!d||d.hidden||!Fa(d)?null:a.jsx(c,{x:u,y:h,width:f,height:p,style:d.style,selected:!!d.selected,className:s(d),color:t(d),borderRadius:o,strokeColor:n(d),strokeWidth:r,shapeRendering:i,onClick:l,id:d.id})}const T0=N.memo(P0);var O0=N.memo(D0);const z0=200,L0=150,H0=e=>!e.hidden,V0=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?La(ln(e.nodeLookup,{filter:H0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},gi=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,F0=(e,t)=>gi(e.viewBB,t.viewBB)&&gi(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,B0="react-flow__minimap-desc";function Vc({style:e,className:t,nodeStrokeColor:n,nodeColor:s,nodeClassName:o="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:c,bgColor:l,maskColor:d,maskStrokeColor:u,maskStrokeWidth:h,position:f="bottom-right",onClick:p,onNodeClick:m,pannable:w=!1,zoomable:x=!1,ariaLabel:y,inversePan:j,zoomStep:g=1,offsetScale:v=5}){const E=le(),k=N.useRef(null),{boundingRect:C,viewBB:I,rfId:R,panZoom:V,translateExtent:T,flowWidth:$,flowHeight:A,ariaLabelConfig:b}=re(V0,F0),S=e?.width??z0,_=e?.height??L0,M=C.width/S,D=C.height/_,P=Math.max(M,D),L=P*S,H=P*_,F=v*P,O=C.x-(L-C.width)/2-F,B=C.y-(H-C.height)/2-F,Y=L+F*2,Q=H+F*2,G=`${B0}-${R}`,z=N.useRef(0),Z=N.useRef();z.current=P,N.useEffect(()=>{if(k.current&&V)return Z.current=og({domNode:k.current,panZoom:V,getTransform:()=>E.getState().transform,getViewScale:()=>z.current}),()=>{Z.current?.destroy()}},[V]),N.useEffect(()=>{Z.current?.update({translateExtent:T,width:$,height:A,inversePan:j,pannable:w,zoomStep:g,zoomable:x})},[w,x,j,g,T,$,A]);const te=p?K=>{const[ne,ie]=Z.current?.pointer(K)||[0,0];p(K,{x:ne,y:ie})}:void 0,ee=m?N.useCallback((K,ne)=>{const ie=E.getState().nodeLookup.get(ne).internals.userNode;m(K,ie)},[]):void 0,U=y??b["minimap.ariaLabel"];return a.jsx(tt,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof h=="number"?h*P: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 i=="number"?i:void 0},className:me(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:a.jsxs("svg",{width:S,height:_,viewBox:`${O} ${B} ${Y} ${Q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":G,ref:k,onClick:te,children:[U&&a.jsx("title",{id:G,children:U}),a.jsx(O0,{onClick:ee,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:r,nodeClassName:o,nodeStrokeWidth:i,nodeComponent:c}),a.jsx("path",{className:"react-flow__minimap-mask",d:`M${O-F},${B-F}h${Y+F*2}v${Q+F*2}h${-Y-F*2}z
8
+ M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Vc.displayName="MiniMap";const zo=N.memo(Vc),W0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Y0={[It.Line]:"right",[It.Handle]:"bottom-right"};function X0({nodeId:e,position:t,variant:n=It.Handle,className:s,style:o=void 0,children:r,color:i,minWidth:c=10,minHeight:l=10,maxWidth:d=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:h=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:w,onResize:x,onResizeEnd:y}){const j=yc(),g=typeof e=="string"?e:j,v=le(),E=N.useRef(null),k=n===It.Handle,C=re(N.useCallback(W0(k&&p),[k,p]),ue),I=N.useRef(null),R=t??Y0[n];N.useEffect(()=>{if(!(!E.current||!g))return I.current||(I.current=xg({domNode:E.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:T,transform:$,snapGrid:A,snapToGrid:b,nodeOrigin:S,domNode:_}=v.getState();return{nodeLookup:T,transform:$,snapGrid:A,snapToGrid:b,nodeOrigin:S,paneDomNode:_}},onChange:(T,$)=>{const{triggerNodeChanges:A,nodeLookup:b,parentLookup:S,nodeOrigin:_}=v.getState(),M=[],D={x:T.x,y:T.y},P=b.get(g);if(P&&P.expandParent&&P.parentId){const L=P.origin??_,H=T.width??P.measured.width??0,F=T.height??P.measured.height??0,O={id:P.id,parentId:P.parentId,rect:{width:H,height:F,...Ba({x:T.x??P.position.x,y:T.y??P.position.y},{width:H,height:F},P.parentId,b,L)}},B=Ro([O],b,S,_);M.push(...B),D.x=T.x?Math.max(L[0]*H,T.x):void 0,D.y=T.y?Math.max(L[1]*F,T.y):void 0}if(D.x!==void 0&&D.y!==void 0){const L={id:g,type:"position",position:{...D}};M.push(L)}if(T.width!==void 0&&T.height!==void 0){const H={id:g,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:T.width,height:T.height}};M.push(H)}for(const L of $){const H={...L,type:"position"};M.push(H)}A(M)},onEnd:({width:T,height:$})=>{const A={id:g,type:"dimensions",resizing:!1,dimensions:{width:T,height:$}};v.getState().triggerNodeChanges([A])}})),I.current.update({controlPosition:R,boundaries:{minWidth:c,minHeight:l,maxWidth:d,maxHeight:u},keepAspectRatio:h,resizeDirection:f,onResizeStart:w,onResize:x,onResizeEnd:y,shouldResize:m}),()=>{I.current?.destroy()}},[R,c,l,d,u,h,w,x,y,m]);const V=R.split("-");return a.jsx("div",{className:me(["react-flow__resize-control","nodrag",...V,n,s]),ref:E,style:{...o,scale:C,...i&&{[k?"backgroundColor":"borderColor"]:i}},children:r})}const q0=N.memo(X0),Z0="/assets/elk-worker.min-C9JGDOE-.js";let xi;function G0(){return xi??=Ld(async()=>{const{default:e}=await import("./elk-api-ByzoDZWH.js").then(t=>t.e);return{default:e}},__vite__mapDeps([0,1,2])).then(({default:e})=>new e({workerUrl:Z0})),xi}const yi={"elk.algorithm":"layered","elk.direction":"RIGHT","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.layered.spacing.nodeNodeBetweenLayers":"70","elk.spacing.nodeNode":"44","elk.spacing.componentComponent":"70","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=34,left=14,bottom=14,right=14]"},U0=160,K0=88;async function Bn(e,t){if(e.length===0)return e;const n=new Map,s=new Set;for(const d of e)d.parentId&&s.add(d.parentId);for(const d of e){const u=d.type==="classNode"||d.type==="coreNode"||d.type==="moduleNode"||d.type==="group"&&!s.has(d.id),h=typeof d.style?.width=="number"?d.style.width:void 0,f=typeof d.style?.height=="number"?d.style.height:void 0;n.set(d.id,{id:d.id,...u?{width:h??d.measured?.width??U0,height:f??d.measured?.height??K0}:{layoutOptions:yi},children:[]})}const o=[];for(const d of e){const u=n.get(d.id);d.parentId&&n.has(d.parentId)?n.get(d.parentId).children.push(u):o.push(u)}const r={id:"root",layoutOptions:yi,children:o,edges:t.map(d=>({id:d.id,sources:[d.source],targets:[d.target]}))};let i;try{i=await(await G0()).layout(r)}catch{return e}const c=new Map,l=d=>{c.set(d.id,{x:d.x??0,y:d.y??0,w:d.width??0,h:d.height??0}),d.children?.forEach(l)};return i.children?.forEach(l),e.map(d=>{const u=c.get(d.id);if(!u)return d;const h={...d,position:{x:u.x,y:u.y}};return d.type==="group"&&(h.style={...d.style,width:u.w,height:u.h}),h})}const Q0=32;function Wn(e){const t=new Map;for(const s of e){if(s.type!=="floating"||s.source===s.target)continue;const[o,r]=[s.source,s.target].sort(),i=`${o}\0${r}`,c=t.get(i);c?c.push(s):t.set(i,[s])}const n=new Map;for(const s of t.values()){if(s.length<2)continue;const o=[...s].sort((i,c)=>{const l=String(i.data?.label??i.data?.edgeClass??""),d=String(c.data?.label??c.data?.edgeClass??"");return l.localeCompare(d)||i.id.localeCompare(c.id)}),r=(o.length-1)/2;o.forEach((i,c)=>{const l=(c-r)*Q0,d=i.source<i.target?1:-1;n.set(i.id,{parallelCount:o.length,parallelOffset:l*d})})}return e.map(s=>{const o=n.get(s.id);return o?{...s,data:{...s.data,...o}}:s})}function wi(e,t){const n=(e.measured.width??0)/2,s=(e.measured.height??0)/2,o=e.internals.positionAbsolute,r=t.internals.positionAbsolute,i=o.x+n,c=o.y+s,l=r.x+(t.measured.width??0)/2,d=r.y+(t.measured.height??0)/2,u=(l-i)/(2*n)-(d-c)/(2*s),h=(l-i)/(2*n)+(d-c)/(2*s),f=1/(Math.abs(u)+Math.abs(h)||1),p=f*u,m=f*h;return{x:n*(p+m)+i,y:s*(-p+m)+c}}function vi(e,t){const n=e.internals.positionAbsolute,s=Math.round(n.x),o=Math.round(n.y),r=Math.round(t.x),i=Math.round(t.y);return r<=s+1?q.Left:r>=s+(e.measured.width??0)-1?q.Right:i<=o+1?q.Top:q.Bottom}function J0(e,t){const n=wi(e,t),s=wi(t,e);return{sx:n.x,sy:n.y,tx:s.x,ty:s.y,sourcePos:vi(e,n),targetPos:vi(t,s)}}function ey({sx:e,sy:t,tx:n,ty:s,offset:o}){const r=n-e,i=s-t,c=Math.hypot(r,i)||1,l=-i/c,d=r/c,u=(e+n)/2+l*o*2,h=(t+s)/2+d*o*2,f=e*.25+u*.5+n*.25,p=t*.25+h*.5+s*.25;return[`M ${e},${t} Q ${u},${h} ${n},${s}`,f,p]}function ty({id:e,source:t,target:n,markerStart:s,markerEnd:o,style:r,data:i}){const c=Fn(t),l=Fn(n);if(!c||!l)return null;const{sx:d,sy:u,tx:h,ty:f,sourcePos:p,targetPos:m}=J0(c,l),w=i,[x,y,j]=(w?.parallelCount??1)>1?ey({sx:d,sy:u,tx:h,ty:f,offset:w?.parallelOffset??0}):So({sourceX:d,sourceY:u,sourcePosition:p,targetX:h,targetY:f,targetPosition:m,curvature:.25}),g=w?.label,v=w?.selected===!0,E=v?"var(--color-primary)":r?.stroke??"var(--color-muted-foreground)",k=v?{...r,stroke:E,strokeWidth:3}:r;return a.jsxs(a.Fragment,{children:[a.jsx(Tt,{id:e,path:x,markerStart:s,markerEnd:o,style:k,interactionWidth:18}),g&&a.jsx(v0,{children:a.jsx("div",{className:"absolute font-mono font-extrabold text-[9px] px-1 rounded pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${y}px, ${j}px)`,color:E,background:"oklch(0.17 0.01 270)"},children:g})})]})}function ny({id:e,source:t,target:n,style:s}){const o=Fn(t),r=Fn(n);if(!o||!r)return null;const i=o.internals.positionAbsolute,c=r.internals.positionAbsolute,l=o.measured.width??0,d=o.measured.height??0,u=r.measured.width??0,h=r.measured.height??0,f=c.x>=i.x,[p]=Hn({sourceX:f?i.x+l:i.x,sourceY:i.y+d/2,sourcePosition:f?q.Right:q.Left,targetX:f?c.x:c.x+u,targetY:c.y+h/2,targetPosition:f?q.Left:q.Right,borderRadius:16});return a.jsx(Tt,{id:e,path:p,style:s,interactionWidth:18})}const Lo={floating:ty,tree:ny};function Ho({domainId:e,anchorRef:t,kind:n,excerpt:s,className:o}){const{threads:r,status:i,orphaned:c}=Hi(t,e),l=N.useId(),d=X(m=>m.openAnchorRef),u=X(m=>m.openAnchorId),h=e?`${e}::${t}`:t,f=d===h&&(u===null||u===l),p=X(m=>m.setOpenAnchor);return r.length===0?null:a.jsxs($t,{modal:!1,open:f,onOpenChange:m=>p(m?h:null,m?l:null),children:[a.jsx(no,{asChild:!0,children:a.jsxs("button",{type:"button",title:"View comments",onClick:m=>{m.stopPropagation(),p(f?null:h,l)},className:ae("nodrag nopan absolute right-1 top-1 z-30 flex h-[18px] min-w-[18px] items-center justify-center gap-0.5 rounded-full px-1 text-[10px] font-bold shadow-md ring-2 ring-card hover:brightness-110",c?"bg-destructive text-white":i==="open"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground",o),children:[a.jsx(Vi,{className:"h-2.5 w-2.5"}),r.length]})}),a.jsx(Rt,{side:"top",align:"end",className:"w-80",children:a.jsx(so,{domainId:e,anchor:{ref:t,kind:n},excerpt:s,threads:r,onClose:()=>p(null)})})]})}function sy(e){const t=e.trim();if(!t.startsWith("<svg"))return null;let n=t;return n=n.replace(/<script[\s\S]*?<\/script>/gi,""),n=n.replace(/<foreignObject[\s\S]*?<\/foreignObject>/gi,""),n=n.replace(/\son\w+\s*=\s*"[^"]*"/gi,""),n=n.replace(/\son\w+\s*=\s*'[^']*'/gi,""),n=n.replace(/(href|xlink:href)\s*=\s*"(?!#)[^"]*"/gi,""),n=n.replace(/<!--[\s\S]*?-->/g,""),n=n.replace(/<svg\b([^>]*)>/i,(s,o)=>{let r=o.replace(/\swidth\s*=\s*"[^"]*"/i,"").replace(/\sheight\s*=\s*"[^"]*"/i,"");return/viewBox=/i.test(r)||(r+=' viewBox="0 0 24 24"'),`<svg${r} width="100%" height="100%" preserveAspectRatio="xMidYMid meet">`}),n}function ge({svg:e,className:t}){const n=N.useMemo(()=>e?sy(e):null,[e]);return n?a.jsx("span",{className:ae("inline-flex shrink-0 items-center justify-center [&>svg]:h-full [&>svg]:w-full",t),dangerouslySetInnerHTML:{__html:n}}):null}const Le=e=>`core.node.${e}`,Vo=e=>e.split("/").filter(Boolean).pop()??e,oy=/^.+:class\.[A-Za-z][A-Za-z0-9_]*\.property\.([A-Za-z][A-Za-z0-9_]*)$/;function Fo(e){const t=Object.entries(e).map(([s,o])=>({key:s,shortName:oy.exec(s)?.[1]??s,value:o})),n=new Map;for(const s of t)n.set(s.shortName,(n.get(s.shortName)??0)+1);return t.map(({key:s,shortName:o,value:r})=>({key:s,label:n.get(o)===1?o:s,value:r}))}function Fc(e,t){const n=Fo(e);return t.flatMap(s=>n.filter(o=>o.label===s))[0]}function en(e){const t=Fc(e.data,["name","title"])?.value;return typeof t=="string"&&t?t:Vo(e.path)}function Bo(e){const t=[...new Set(e.nodes.map(n=>n.className))].sort();return new Map(t.map((n,s)=>[n,Hd(s)]))}const Wo=e=>e==null?"—":typeof e=="string"?e:Array.isArray(e)?e.map(Wo).join(", "):JSON.stringify(e);function ry(e,t=2){const n=Fc(e.data,["name","title"]);return Fo(e.data).filter(s=>s.key!==n?.key).slice(0,t).map(({label:s,value:o})=>[s,Wo(o)])}function Yo(e,t){return e.ir?.classes?.[t]?.icon}function iy(e,t,n){const s=new Set(e.nodes.map(c=>Le(c.path))),o=e.nodes.map(c=>{const l=ry(c);return{id:Le(c.path),type:"coreNode",position:{x:0,y:0},data:{path:c.path,className:c.className,title:en(c),hue:n.get(c.className)??264,icon:Yo(t,c.className),fields:l,selected:!1},style:{width:184,height:50+l.length*15}}}),r=`/:${e.domain}`;for(const c of new Set(e.edges.flatMap(l=>[l.from,l.to]))){const l=Le(c);if(s.has(l))continue;const d=c===r;o.push({id:l,type:"coreNode",position:{x:0,y:0},selectable:!1,focusable:!1,data:{path:c,className:d?"Domain":"External",title:d?e.domain:Vo(c),hue:d?210:264,fields:[],selected:!1,virtual:!0},style:{width:184,height:50}}),s.add(l)}const i=[];for(const c of e.nodes){if(!c.parent)continue;const l=Le(c.parent),d=Le(c.path);!s.has(l)||!s.has(d)||i.push({id:`core.struct.${c.path}`,source:l,target:d,type:"tree",data:{structural:!0},style:{stroke:"oklch(0.5 0.02 264)",strokeWidth:1.4,strokeDasharray:"4 4"}})}for(const c of e.edges){const l=Le(c.from),d=Le(c.to);if(!s.has(l)||!s.has(d))continue;const u="oklch(0.72 0.16 35)";i.push({id:`core.edge.${c.from}__${c.edgeName}__${c.to}`,source:l,target:d,type:"floating",data:{label:c.edgeName},markerEnd:{type:ut.ArrowClosed,color:u,width:16,height:16},style:{stroke:u,strokeWidth:2}})}return{nodes:o,edges:i}}function Bc({count:e}){const t=X(o=>o.canvasMode),n=X(o=>o.setCanvasMode),s=t==="core";return a.jsxs(Ve,{size:"xs",variant:s?"default":"outline",onClick:()=>n(s?"schema":"core"),"aria-pressed":s,title:s?"Back to the schema graph":"Show core (genesis) data",children:[s?a.jsx(Vd,{className:"h-3.5 w-3.5"}):a.jsx(Fi,{className:"h-3.5 w-3.5"}),s?"Schema":"Core",!s&&e!==void 0&&a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:e})]})}function ay({data:e}){const t=e,n=t.className==="Folder";return a.jsxs("div",{className:ae("relative rounded-lg border bg-card shadow-sm w-[184px] transition-shadow",t.selected?"ring-2 ring-primary":"hover:shadow-md"),style:{borderLeft:`3px solid oklch(0.72 0.15 ${t.hue})`},children:[!t.virtual&&a.jsx(Ho,{anchorRef:Le(t.path),kind:"section",excerpt:`${t.title} (${t.className})`}),a.jsx(Ie,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsxs("div",{className:"px-2.5 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{style:{color:`oklch(0.82 0.14 ${t.hue})`},className:"shrink-0",children:t.icon?a.jsx(ge,{svg:t.icon,className:"h-5 w-5"}):n?a.jsx(on,{className:"h-5 w-5"}):a.jsx(Me,{className:"h-5 w-5"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-[13px] font-extrabold truncate leading-tight",children:t.title}),a.jsx("div",{className:"text-[10px] font-mono text-muted-foreground/70 truncate leading-tight",children:t.className})]})]}),t.fields.length>0&&a.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:t.fields.map(([s,o])=>a.jsxs("div",{className:"flex items-baseline gap-1 text-[10px] leading-tight",children:[a.jsx("span",{className:"font-mono text-muted-foreground/60 shrink-0",children:s}),a.jsx("span",{className:"truncate text-foreground/80",children:o})]},s))})]}),a.jsx(Ie,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}const cy={coreNode:ay};function ly({core:e,bundle:t,selectedPath:n,onSelect:s}){const{fitView:o}=Pt(),r=X(k=>k.setOpenAnchor),i=N.useMemo(()=>Bo(e),[e]),c=N.useMemo(()=>iy(e,t,i),[e,t,i]),[l,d]=N.useState([]),[u,h]=N.useState([]);N.useEffect(()=>{let k=!1;return Bn(c.nodes,c.edges).then(C=>{k||(d(C),h(Wn(c.edges)),requestAnimationFrame(()=>o({padding:.2,duration:400})))}),()=>{k=!0}},[c,o]);const f=N.useCallback(k=>d(C=>ls(k,C)),[]),p=N.useCallback(k=>h(C=>ds(k,C)),[]),[m,w]=N.useState(!0),[x,y]=N.useState(!0),j=N.useMemo(()=>l.filter(k=>{const C=k.data;return!(!m&&C.className==="Folder"||!x&&C.virtual)}),[l,x,m]),g=N.useMemo(()=>new Set(j.map(k=>k.id)),[j]),v=N.useMemo(()=>j.map(k=>{const C=k.data.path===n;return k.data.selected===C?k:{...k,data:{...k.data,selected:C}}}),[j,n]),E=N.useMemo(()=>u.filter(k=>!g.has(k.source)||!g.has(k.target)?!1:k.type==="tree"?m:x),[u,g,m,x]);return a.jsxs(Po,{nodes:v,edges:E,nodeTypes:cy,edgeTypes:Lo,onNodesChange:f,onEdgesChange:p,onNodeClick:(k,C)=>{const I=C.data;I.virtual||s(I.path)},onPaneClick:()=>{s(null),r(null)},minZoom:.15,nodesConnectable:!1,proOptions:{hideAttribution:!0},children:[a.jsx(To,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(Oo,{className:"!bg-card !border !border-border [&_button]:!bg-card [&_button]:!border-border [&_button]:!fill-foreground",showInteractive:!1}),a.jsx(zo,{pannable:!0,zoomable:!0,className:"!bg-card !border !border-border",nodeColor:k=>`oklch(0.6 0.13 ${k.data.hue})`,nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.7)"}),a.jsxs(tt,{position:"top-right",className:"flex gap-1.5",children:[a.jsxs(Ve,{size:"xs",variant:m?"default":"outline",onClick:()=>w(k=>!k),"aria-pressed":m,title:"Folders & the parent→child tree — toggle to focus on the semantic graph alone",children:[a.jsx(Mu,{className:"h-3.5 w-3.5"})," Structure"]}),a.jsxs(Ve,{size:"xs",variant:x?"default":"outline",onClick:()=>y(k=>!k),"aria-pressed":x,title:"Typed (semantic) edges — toggle to focus on the tree/organization alone",children:[a.jsx(mt,{className:"h-3.5 w-3.5"})," Semantics"]}),a.jsx(Bc,{})]})]})}function fn({anchor:e,excerpt:t,children:n,className:s}){const o=N.useId(),r=X(f=>f.openAnchorRef),i=X(f=>f.openAnchorId),c=r===e.ref&&(i===null||i===o),l=X(f=>f.setOpenAnchor),{threads:d,status:u,orphaned:h}=Hi(e.ref);return a.jsxs($t,{modal:!1,open:c,onOpenChange:f=>l(f?e.ref:null,f?o:null),children:[a.jsx(no,{asChild:!0,children:a.jsxs("span",{"data-anchor-ref":e.ref,"data-commentable":"",className:ae("group relative block",s),children:[n,a.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),l(c?null:e.ref,o)},title:`Comment on ${e.ref}`,className:ae("absolute right-1 top-1 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border bg-card text-muted-foreground shadow-sm transition-opacity hover:text-primary",c?"opacity-100":"opacity-40 group-hover:opacity-100"),children:a.jsx(Du,{className:"h-3 w-3"})}),d.length>0&&a.jsx(Fd,{count:d.length,status:u,orphaned:h,onClick:()=>l(c?null:e.ref,o),className:"absolute -right-1.5 -top-1.5 z-10"})]})}),a.jsx(Rt,{onInteractOutside:f=>f.preventDefault(),className:"max-h-[var(--radix-popover-content-available-height)] overflow-y-auto",children:a.jsx(so,{anchor:e,excerpt:t,threads:d,onClose:()=>l(null)})})]})}function dy({core:e,bundle:t,selectedPath:n}){const s=N.useMemo(()=>e.nodes.find(u=>u.path===n)??null,[e,n]),o=N.useMemo(()=>Bo(e),[e]);if(!s)return a.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground/70",children:"Select a core node to see what's set on it."});const r=o.get(s.className)??264,i=Yo(t,s.className),c=s.className==="Folder",l=Fo(s.data),d=e.edges.filter(u=>u.from===s.path||u.to===s.path);return a.jsxs("div",{className:"h-full overflow-y-auto",children:[a.jsx(fn,{anchor:{ref:Le(s.path),kind:"section"},excerpt:`${en(s)} (${s.className})`,className:"block",children:a.jsxs("div",{className:"flex items-center gap-2.5 border-b px-4 py-3",children:[a.jsx("span",{style:{color:`oklch(0.82 0.14 ${r})`},className:"shrink-0",children:i?a.jsx(ge,{svg:i,className:"h-7 w-7"}):c?a.jsx(on,{className:"h-6 w-6"}):a.jsx(Me,{className:"h-6 w-6"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-extrabold truncate",children:en(s)}),a.jsx("div",{className:"text-[11px] font-mono text-muted-foreground/70",children:s.className})]})]})}),a.jsxs("div",{className:"px-4 py-3",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Path"}),a.jsx("div",{className:"mt-1 break-all font-mono text-[11px] text-foreground/80",children:s.path})]}),a.jsxs("div",{className:"px-4 pb-3",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Data"}),l.length===0?a.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground/60",children:"No fields set."}):a.jsx("div",{className:"mt-1.5 flex flex-col gap-1.5",children:l.map(({key:u,label:h,value:f})=>a.jsxs("div",{className:"flex flex-col gap-0.5 rounded-md border bg-card/40 px-2.5 py-1.5",children:[a.jsx("span",{className:"font-mono text-[11px] text-muted-foreground/70",title:h===u?void 0:u,children:h}),a.jsx("span",{className:"break-words text-[13px] text-foreground/90",children:Wo(f)})]},u))})]}),d.length>0&&a.jsxs("div",{className:"px-4 pb-4",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Edges"}),a.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:d.map((u,h)=>{const f=u.from===s.path,p=f?u.to:u.from;return a.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[a.jsx(mt,{className:"h-3.5 w-3.5 shrink-0 text-amber-400"}),a.jsx("span",{className:"font-mono text-amber-300",children:u.edgeName}),a.jsx("span",{className:"text-muted-foreground/60",children:f?"→":"←"}),a.jsx("span",{className:"truncate text-foreground/80",title:p,children:Vo(p)})]},`${u.edgeName}-${h}`)})})]})]})}function uy(e){const t=new Set(e.nodes.map(r=>r.path)),n=new Map,s=[];for(const r of e.nodes)if(r.parent&&t.has(r.parent)){const i=n.get(r.parent)??[];i.push(r),n.set(r.parent,i)}else s.push(r);const o=r=>({node:r,children:(n.get(r.path)??[]).map(o)});return s.map(o)}function Wc({item:e,depth:t,bundle:n,hues:s,selectedPath:o,onSelect:r}){const[i,c]=N.useState(!0),l=e.node,d=e.children.length>0,u=o===l.path,h=s.get(l.className)??264,f=Yo(n,l.className),p=l.className==="Folder";return a.jsxs("div",{children:[a.jsxs("div",{className:ae("group/row flex items-center gap-0.5 pr-2 rounded-md hover:bg-accent/50",u&&"bg-accent text-accent-foreground"),style:{paddingLeft:6+t*12},children:[d?a.jsx("button",{type:"button",onClick:()=>c(m=>!m),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-white/5",title:i?"Collapse":"Expand",children:i?a.jsx(Gn,{className:"h-3 w-3"}):a.jsx(Un,{className:"h-3 w-3"})}):a.jsx("span",{className:"w-4 shrink-0"}),a.jsx(fn,{anchor:{ref:Le(l.path),kind:"section"},excerpt:`${en(l)} (${l.className})`,className:"flex-1 min-w-0",children:a.jsxs("button",{type:"button",onClick:()=>r(l.path),className:"flex w-full items-center gap-1.5 py-1 text-left min-w-0",children:[a.jsx("span",{style:{color:`oklch(0.8 0.13 ${h})`},className:"shrink-0",children:f?a.jsx(ge,{svg:f,className:"h-4 w-4"}):p?a.jsx(on,{className:"h-3.5 w-3.5"}):a.jsx(Me,{className:"h-3.5 w-3.5"})}),a.jsx("span",{className:"truncate font-bold",children:en(l)}),a.jsx("span",{className:"ml-auto text-[10px] font-mono text-muted-foreground/50 shrink-0",children:l.className})]})})]}),i&&d&&a.jsx("div",{children:e.children.map(m=>a.jsx(Wc,{item:m,depth:t+1,bundle:n,hues:s,selectedPath:o,onSelect:r},m.node.path))})]})}function fy({core:e,bundle:t,selectedPath:n,onSelect:s}){const o=N.useMemo(()=>Bo(e),[e]),r=N.useMemo(()=>uy(e),[e]);return a.jsxs("div",{className:"text-sm py-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 px-3 pb-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[a.jsx(Fi,{className:"h-3.5 w-3.5"})," Core",a.jsx("span",{className:"ml-auto tabular-nums text-muted-foreground/50",children:e.nodes.length})]}),r.length===0?a.jsx("p",{className:"px-3 pt-2 text-[12px] text-muted-foreground/60",children:e.error?e.error.message:"This domain defines no core (genesis) data."}):r.map(i=>a.jsx(Wc,{item:i,depth:0,bundle:t,hues:o,selectedPath:n,onSelect:s},i.node.path))]})}const Yc="kernel.astrale.ai",hy=new Set(["Node","Edge"]);function Yn(e,t){const n=e.ir;if(n)return typeof t=="string"?n.classes[t]:t.origin===n.domain?n.classes[t.name]:n.importedClassesByKey[Be(t)]}function py(e,t){return t.origin===e.ir?.domain?"local":t.origin===Yc?"kernel":"external"}function my(e,t){const n=e.ir?.classes[t];if(!n)return[];const s=new Set(Object.keys(n.properties)),o=new Set(Object.keys(n.methods)),r=new Set(s),i=new Set,c=new Set,l=[...n.extendsRefs??[]],d=[];for(;l.length>0;){const h=l.shift(),f=Be(h);if(c.has(f)||h.origin===Yc&&hy.has(h.name))continue;c.add(f);const p=Yn(e,h);if(!p)continue;l.push(...p.extendsRefs??[]);const m=Object.entries(p.properties).filter(([x])=>!r.has(x)).map(([x,y])=>[x,y,!(p.required??[]).includes(x)]),w=Object.entries(p.methods).filter(([x])=>!i.has(x)).map(([x,y])=>({name:x,method:y,overridden:o.has(x)}));for(const[x]of m)r.add(x);for(const{name:x}of w)i.add(x);m.length===0&&w.length===0||d.push({owner:h.name,ref:h,tier:py(e,h),...h.origin===e.ir?.domain?{}:{origin:h.origin},props:m,methods:w})}const u={local:0,external:1,kernel:2};return d.sort((h,f)=>u[h.tier]-u[f.tier])}function gy(e){return e.reduce((t,n)=>t+n.props.length+n.methods.length,0)}function xy({domainId:e,view:t,open:n,onOpenChange:s}){const o=Bd(e,t.slug,n),r=o.data,[i,c]=N.useState(""),[l,d]=N.useState(0),[u,h]=N.useState(!1),[f,p]=N.useState({phase:"idle"}),m=N.useRef("");N.useEffect(()=>{if(!n){m.current="",c(""),p({phase:"idle"});return}if(!r)return;const j=`${e}:${t.slug}:${r.instance??"none"}`;m.current!==j&&(m.current=j,c(r.targets.selected?.id??""))},[e,n,r,t.slug]);const w=!!r&&(!r.targetRequired||r.targets.items.some(j=>j.id===i)),x=n&&!u&&!!r?.instance&&w;N.useEffect(()=>{if(!x){p({phase:"idle"});return}let j=!1,g=null;return p({phase:"launching"}),_e.launchView(e,t.slug,i?{targetId:i}:{}).then(v=>{v.status==="ready"?(g=v.sessionId,j?_e.closeViewSession(e,v.sessionId):p({phase:"ready",session:v})):j||p({phase:"error",reason:v.reason})}).catch(v=>{j||p({phase:"error",reason:v instanceof Error?v.message:String(v)})}),()=>{j=!0,g&&_e.closeViewSession(e,g)}},[l,e,x,r?.instance,i,t.slug]),N.useEffect(()=>{if(f.phase!=="ready")return;const j=()=>{const g=`/api/domain/${encodeURIComponent(e)}/views/sessions/close`;navigator.sendBeacon(g,new Blob([JSON.stringify({sessionId:f.session.sessionId})],{type:"application/json"}))};return window.addEventListener("pagehide",j),()=>window.removeEventListener("pagehide",j)},[e,f]);const y=async()=>{if(!u){h(!0),p({phase:"idle"});try{await o.refetch(),d(j=>j+1)}catch(j){p({phase:"error",reason:j instanceof Error?j.message:String(j)})}finally{h(!1)}}};return a.jsx(Wd,{open:n,onOpenChange:s,children:a.jsxs(Yd,{className:"grid h-[90vh] w-[95vw] max-w-[1500px] grid-rows-[auto_auto_1fr] gap-0 overflow-hidden rounded-2xl p-0",children:[a.jsxs("header",{className:"flex min-w-0 items-center gap-3 border-b bg-card/95 px-4 py-3 pr-12",children:[a.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-sky-500/12 text-sky-400",children:a.jsx(ir,{className:"h-[18px] w-[18px]"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xd,{className:"truncate text-sm font-semibold",children:t.slug}),a.jsxs("code",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:["view.",t.slug]})]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:t.description??"Domain view preview"})]}),a.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[f.phase==="ready"&&a.jsxs("a",{href:f.session.pageUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-8 items-center gap-1.5 rounded-lg px-2.5 text-[11px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:[a.jsx(qd,{className:"h-3.5 w-3.5"})," Open separately"]}),a.jsx("button",{type:"button",onClick:()=>{y()},disabled:u,title:"Retry the CLI-resolved View session",className:"grid h-8 w-8 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-30",children:a.jsx(Zd,{className:ae("h-3.5 w-3.5",u&&"animate-spin")})})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-muted/15 px-4 py-3",children:[r?.targetRequired?a.jsx(yy,{result:r.targets,value:i,onChange:c,instance:r.instance}):a.jsxs("div",{className:"inline-flex h-9 items-center gap-2 rounded-xl border bg-background/60 px-3 text-[11px]",children:[a.jsx(Bi,{className:"h-3.5 w-3.5 text-emerald-400"}),a.jsx("span",{className:"font-medium",children:"Standalone view"}),a.jsx("span",{className:"text-muted-foreground",children:"No target required"})]}),a.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[a.jsxs("div",{className:ae("inline-flex h-9 items-center gap-2 rounded-xl border px-3 text-[10px]",r?.instance?"border-emerald-500/20 bg-emerald-500/8 text-emerald-200":"bg-background/60 text-muted-foreground"),title:"The Astrale CLI resolves the verified View placement installed on this instance.",children:[r?.instance?a.jsxs("span",{className:"relative flex h-2 w-2",children:[a.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-30"}),a.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-emerald-400"})]}):r?a.jsx(ho,{className:"h-3 w-3 text-amber-400"}):a.jsx($s,{className:"h-3 w-3 animate-spin"}),a.jsx(ir,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"font-medium",children:"CLI-resolved View"})]}),a.jsxs("div",{className:"h-9 rounded-xl border bg-background/60 px-3 py-1.5 text-right text-[9px] uppercase leading-tight tracking-wider text-muted-foreground",children:[a.jsx("div",{children:"Data instance"}),a.jsx("div",{className:"max-w-40 truncate text-[10px] font-medium normal-case tracking-normal text-foreground",children:r?.instance??"not selected"})]})]})]}),a.jsx("main",{className:"relative min-h-0 overflow-hidden bg-[#0d0d11]",children:f.phase==="ready"?a.jsx("iframe",{src:f.session.pageUrl,title:`${t.slug} preview`,className:"h-full w-full border-0 bg-white",allow:"clipboard-read; clipboard-write"},f.session.sessionId):a.jsx(vy,{loading:o.isLoading||u||f.phase==="launching",runtimeError:o.isError,runtime:r,targetId:i,sessionError:f.phase==="error"?f.reason:void 0,onRetry:()=>{y()}})})]})})}function yy({result:e,value:t,onChange:n,instance:s}){const[o,r]=N.useState(!1),[i,c]=N.useState(""),l=e.items.find(u=>u.id===t)??null,d=N.useMemo(()=>{const u=i.trim().toLocaleLowerCase();return u?e.items.filter(h=>[h.label,h.description,h.className,h.status,h.id].filter(Boolean).some(f=>f.toLocaleLowerCase().includes(u))):e.items},[e.items,i]);return a.jsxs($t,{open:o,onOpenChange:u=>{r(u),u||c("")},children:[a.jsx(oo,{asChild:!0,children:a.jsxs("button",{type:"button",className:ae("flex h-9 min-w-64 max-w-[28rem] items-center gap-2 rounded-xl border bg-background/60 px-3 text-left transition-colors hover:bg-accent/40",e.stale&&!l&&"border-amber-500/40"),children:[a.jsx("span",{className:ae("h-2 w-2 shrink-0 rounded-full",l?"bg-emerald-400":e.stale?"bg-amber-400":"bg-muted-foreground/30")}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block text-[9px] uppercase tracking-wider text-muted-foreground",children:"Target"}),a.jsx("span",{className:"block truncate text-[11px] font-medium",children:l?.label??e.stale?.label??"Select a target"})]}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:e.items.length}),a.jsx(Gd,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),a.jsxs(Rt,{side:"bottom",align:"start",className:"z-[70] w-[28rem] p-0",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[a.jsx(Wi,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.jsx("input",{autoFocus:!0,value:i,onChange:u=>c(u.target.value),placeholder:"Search visible targets…",className:"min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground/60"}),a.jsx("span",{className:"text-[9px] uppercase tracking-wider text-muted-foreground",children:s??"no instance"})]}),e.stale&&a.jsxs("div",{className:"m-2 flex gap-2 rounded-lg border border-amber-500/25 bg-amber-500/8 p-2.5 text-[11px] text-amber-200",children:[a.jsx(ho,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsxs("span",{children:[a.jsx("strong",{children:e.stale.label})," was remembered, but it was deleted or is no longer visible. Pick a replacement."]})]}),a.jsx("div",{className:"max-h-80 overflow-y-auto p-1.5",children:e.status==="unavailable"?a.jsx(bi,{children:e.reason??"Targets could not be queried."}):d.length===0?a.jsx(bi,{children:e.items.length===0?"No eligible targets are visible.":"No matches."}):d.map(u=>a.jsx(wy,{item:u,selected:u.id===t,onClick:()=>{n(u.id),r(!1)}},u.id))}),e.truncated&&a.jsx("div",{className:"border-t px-3 py-2 text-[10px] text-muted-foreground",children:"Showing the first 200 visible targets per class."})]})]})}function wy({item:e,selected:t,onClick:n}){return a.jsxs("button",{type:"button",onClick:n,className:ae("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-accent",t&&"bg-accent/70"),children:[a.jsx("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-lg bg-sky-500/10 text-[10px] font-semibold text-sky-300",children:e.className.slice(0,2).toUpperCase()}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate text-xs font-medium",children:e.label}),a.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:[e.className,e.description,e.status].filter(Boolean).join(" · ")})]}),a.jsx("code",{className:"text-[9px] text-muted-foreground/50",children:e.id.slice(0,8)}),t&&a.jsx(Bi,{className:"h-3.5 w-3.5 text-primary"})]})}function bi({children:e}){return a.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-muted-foreground",children:e})}function vy({loading:e,runtimeError:t,runtime:n,targetId:s,sessionError:o,onRetry:r}){if(e)return a.jsx(yt,{icon:a.jsx($s,{className:"animate-spin"}),title:"Resolving installed View",children:"The Astrale CLI is resolving the View and connecting it to the active data instance."});if(t)return a.jsx(yt,{icon:a.jsx(ar,{}),title:"The Studio runtime did not respond",action:r,children:"Retry the View session. The schema canvas is unaffected."});if(!n?.instance)return a.jsx(yt,{icon:a.jsx(ar,{}),title:"Choose an Astrale instance",children:"The installed View reads data from the active instance in the Studio header."});if(n.targetRequired&&!n.targets.items.some(i=>i.id===s)){const i=n.targets.stale;return a.jsx(yt,{icon:a.jsx(Wi,{}),title:i?"The remembered target is gone":"Choose what this view should open",children:i?`${i.label} was deleted or is no longer visible. Use the target selector above.`:n.targets.items.length?`${n.targets.items.length} visible candidate${n.targets.items.length===1?"":"s"} found on ${n.instance}.`:n.targets.reason||"No eligible targets are currently visible."})}return o?a.jsx(yt,{icon:a.jsx(ho,{}),title:"The view could not be opened",action:r,children:o}):a.jsx(yt,{icon:a.jsx($s,{className:"animate-spin"}),title:"Opening view session",children:"Studio is preparing the authenticated CLI-owned Shell session."})}function yt({icon:e,title:t,children:n,action:s}){return a.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-8 text-center text-zinc-200",children:[a.jsx("div",{className:"mb-3 grid h-11 w-11 place-items-center rounded-2xl border border-white/10 bg-white/5 text-zinc-400 [&_svg]:h-5 [&_svg]:w-5",children:e}),a.jsx("h2",{className:"text-sm font-semibold",children:t}),a.jsx("div",{className:"mt-1.5 max-w-md text-[12px] leading-relaxed text-zinc-500",children:n}),s&&a.jsx("button",{type:"button",onClick:s,className:"mt-4 rounded-lg border border-white/10 bg-white/5 px-3 py-1.5 text-[11px] transition-colors hover:bg-white/10",children:"Restart preview"})]})}function by({kind:e,className:t}){const n=e==="inline-html"?Qd:e==="spa"?sn:gt;return a.jsx(n,{className:t})}function Xn({domainId:e,view:t,icon:n}){const[s,o]=N.useState(!1),r=Ud(t.drift),i=[t.kind,t.mount,t.auth,t.unbound?"standalone":"targeted"].filter(Boolean).join(" · "),c=`view.${t.slug}`;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-domain-id":e,"data-anchor-ref":c,"data-anchor-excerpt":t.slug,className:"group flex w-full items-center gap-2.5 rounded-lg px-2 py-1.5 transition-colors hover:bg-accent/60",children:[a.jsxs("button",{type:"button",onClick:()=>o(!0),title:"Open live view",className:"flex min-w-0 flex-1 items-center gap-2.5 text-left",children:[a.jsx(ve,{tone:"sky",size:"sm",children:n?a.jsx(ge,{svg:n,className:"h-3.5 w-3.5"}):a.jsx(by,{kind:t.kind,className:"h-3.5 w-3.5"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:t.slug}),a.jsx("div",{className:"truncate text-[11px] leading-tight text-muted-foreground/70",children:i})]}),r&&a.jsxs("span",{className:ae("inline-flex shrink-0 items-center gap-1 text-[10px] font-medium",r.tone==="warn"?"text-warning":"text-muted-foreground/70"),children:[r.tone==="warn"&&a.jsx(ct,{className:"h-3 w-3"}),r.text]}),a.jsx(Kd,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/0 transition-colors group-hover:text-primary"})]}),a.jsx(Dt,{domainId:e,anchorRef:{ref:c,kind:"section",file:t.file},excerpt:t.slug,className:"ml-1"})]}),s&&a.jsx(xy,{domainId:e,view:t,open:s,onOpenChange:o})]})}function Ny({domainId:e,model:t}){const{data:n}=ro(e),s=X(i=>i.selectClass),o=[...t.byClass.keys()].sort(),r=i=>n?.ir?.classes[i]?.icon;return a.jsx(At,{className:"h-full",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Views"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:t.all.length}),t.hasDrift&&a.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-warning",children:[a.jsx(ct,{className:"h-3.5 w-3.5"})," drift"]})]}),t.all.length===0&&a.jsx(Ft,{icon:a.jsx(sn,{}),title:"No views",hint:"This domain declares no views."}),o.map(i=>{const c=r(i),l=t.byClass.get(i);return a.jsxs("section",{className:"mb-6",children:[a.jsxs("button",{type:"button",onClick:()=>s(`class.${i}`),title:`Open ${i}`,className:"group mb-1.5 flex w-full items-center gap-1.5 px-1 text-left",children:[a.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:c?a.jsx(ge,{svg:c,className:"h-4 w-4"}):a.jsx(Me,{className:"h-4 w-4"})}),a.jsx("span",{className:"text-[13px] font-semibold transition-colors group-hover:text-primary",children:i}),a.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:l.length}),a.jsx(Yi,{className:"ml-auto h-3.5 w-3.5 text-muted-foreground/0 transition-colors group-hover:text-muted-foreground/60"})]}),a.jsx("div",{className:"flex flex-col gap-0.5",children:l.map(d=>a.jsx(Xn,{domainId:e,view:d,icon:c},d.slug))})]},i)}),t.unbound.length>0&&a.jsx(qe,{label:"Standalone",hint:"opens without a target",children:a.jsx("div",{className:"flex flex-col gap-0.5",children:t.unbound.map(i=>a.jsx(Xn,{domainId:e,view:i},i.slug))})}),t.orphanRoutes.length>0&&a.jsx(qe,{label:"Orphan client routes",hint:"no declaring view",children:a.jsx("div",{className:"flex flex-col gap-1",children:t.orphanRoutes.map(i=>a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-2 py-1.5 text-[12px] text-warning",children:[a.jsx(ct,{className:"h-3.5 w-3.5 shrink-0"}),a.jsx("code",{className:"truncate",children:i})]},i))})})]})})}function Ys(e){return e?e.max===null?e.min<=0?"*":`${e.min}..*`:e.min===e.max?`${e.max}`:`${e.min}..${e.max}`:"*"}const Nn=e=>!e||e.max===null||e.max>1,Ni=e=>!e||e.min<=0;function Xs(e){return e?e==="kernel.astrale.ai"?"kernel":e.split(".")[0]:"this domain"}function Xc({doc:e}){return a.jsxs(Kn,{openDelay:80,children:[a.jsx(Qn,{asChild:!0,children:a.jsx("button",{type:"button","aria-label":"Description",className:"text-muted-foreground/40 hover:text-foreground transition-colors",children:a.jsx(au,{className:"h-3.5 w-3.5"})})}),a.jsx(Jn,{className:"w-auto max-w-xs text-[13px] leading-relaxed text-muted-foreground",children:e})]})}function qc({bundle:e,refBase:t,pname:n,schema:s,optional:o}){const r=`${t}.property.${n}`,i=e.overlay.sourceSpans[r]?.doc,c=Xi(s,o),l=c.icon,d=e.overlay.annotations.filter(h=>h.target===r),u=Jd(s);return a.jsx(io,{anchorRef:r,anchorExcerpt:n,leading:a.jsx(ve,{tone:"sky",size:"sm",children:a.jsx(l,{})}),title:a.jsxs("span",{className:"flex items-center gap-1.5",children:[n,i&&a.jsx(Xc,{doc:i}),c.optional&&a.jsx(ye,{tone:"default",children:"optional"}),d.map(h=>a.jsx(ye,{tone:"warning",title:h.message,children:h.code},h.code))]}),subtitle:a.jsxs(Kn,{openDelay:140,children:[a.jsx(Qn,{asChild:!0,children:a.jsx("span",{className:"cursor-default",children:c.label})}),a.jsx(Jn,{className:"w-auto max-w-sm",children:a.jsx(eu,{items:[{label:"type",value:tu(u)+(c.optional?" (optional)":"")},{label:"key",value:r}]})})]}),trailing:a.jsx(Dt,{anchorRef:{ref:r,kind:"schema",file:e.overlay.sourceSpans[r]?.file},excerpt:n})})}function Zc({bundle:e,owner:t,ownerKind:n="class",handlerOwnerLocal:s=!0,refBase:o,mname:r,method:i,overridden:c=!1}){const l=`${o}.method.${r}`,d=s?nu(e.overlay.handlerLinks,t,r,n):void 0,u=e.overlay.sourceSpans[l]?.doc,h=su(i),f=h.icon,p=d&&!d.implemented,m=d?.unlinked;return a.jsxs(kt,{className:"px-3 py-2.5","data-anchor-ref":l,"data-anchor-excerpt":`${t}.${r}`,"data-commentable":"",children:[a.jsx(io,{className:"px-0 py-0 hover:bg-transparent",leading:a.jsx(ve,{tone:h.tone,size:"sm",children:a.jsx(f,{})}),title:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:ae(c&&"line-through text-muted-foreground/70"),children:r}),a.jsx(ou,{method:i}),u&&a.jsx(Xc,{doc:u}),i.inheritance==="sealed"&&a.jsx(ye,{tone:"warning",children:"sealed"}),i.inheritance==="abstract"&&a.jsx(ye,{tone:"fuchsia",children:"contract"}),c&&a.jsx(ye,{tone:"default",children:"overridden"}),p&&a.jsx(ye,{tone:"warning",children:"needs handler"}),m&&a.jsx(ye,{tone:"default",children:"unlinked"})]}),trailing:a.jsx(Dt,{anchorRef:{ref:l,kind:"schema",file:e.overlay.sourceSpans[l]?.file},excerpt:`${t}.${r}`})}),a.jsx("div",{className:"pl-[2.625rem] pt-1.5",children:a.jsx(ru,{label:"Details",children:a.jsx(jy,{method:i,link:d,owner:t})})})]})}function jy({method:e,link:t,owner:n}){const s=Object.entries(e.input.properties??{}),o=new Set(e.input.required??[]);return a.jsxs("div",{className:"space-y-3 pb-1",children:[s.length>0&&a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Input"}),a.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[13px]",children:s.map(([r,i])=>{const c=!o.has(r),l=Xi(i,c);return a.jsxs("span",{className:"inline-flex items-baseline gap-1.5",children:[a.jsx("span",{className:"font-medium",children:r}),a.jsxs("span",{className:"text-muted-foreground",children:[l.label,l.optional?"?":""]})]},r)})})]}),a.jsx(ky,{owner:n,isStatic:e.static}),t?.kernelCalls&&t.kernelCalls.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.kernelCalls.map(r=>a.jsx(ye,{tone:"outline",className:"font-mono",children:r},r))}),a.jsxs("div",{className:"pt-0.5",children:[a.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"returns "}),e.output.mode==="binary"?a.jsx(ye,{tone:"outline",children:"Binary"}):e.output.mode==="stream"?a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx(ye,{tone:"outline",children:"Stream"}),a.jsx(or,{schema:e.output.item})]}):a.jsx(or,{schema:e.output.schema})]})]})}function ky({owner:e,isStatic:t}){return a.jsxs(Kn,{openDelay:80,children:[a.jsx(Qn,{asChild:!0,children:a.jsx("button",{type:"button",className:"cursor-default rounded-full",children:a.jsxs(ye,{tone:"outline",children:[t?a.jsx(ao,{className:"h-3 w-3"}):a.jsx(Me,{className:"h-3 w-3"})," ",t?`on the ${e} type`:`on a ${e}`]})})}),a.jsx(Jn,{className:"w-auto max-w-[15rem]",children:a.jsx("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:t?a.jsxs(a.Fragment,{children:["Acts on the ",a.jsxs("span",{className:"font-medium text-foreground/90",children:[e," type"]}),"."," ",a.jsx("span",{className:"text-muted-foreground/60",children:"(static)"})]}):a.jsxs(a.Fragment,{children:["Acts on a single ",a.jsx("span",{className:"font-medium text-foreground/90",children:e}),"."," ",a.jsx("span",{className:"text-muted-foreground/60",children:"(instance)"})]})})})]})}function Ey({bundle:e,groups:t,originIcon:n}){const s=X(o=>o.selectClass);return a.jsx(qe,{label:"Inherited",hint:`${gy(t)}`,children:a.jsx("div",{className:"space-y-5",children:t.map(o=>{const r=o.tier==="local"?"border-l-fuchsia-500/40":o.tier==="external"?"border-l-sky-500/40":"border-l-border",i=o.tier==="local"?"fuchsia":o.tier==="external"?"sky":"muted",c=o.ref.origin===e.ir?.domain?`class.${o.owner}`:`class.${Be(o.ref)}`;return a.jsxs("div",{className:ae("border-l-2 pl-3.5",r),children:[a.jsxs("button",{type:"button",onClick:()=>s(c),title:o.origin??"this domain",className:"group/ih mb-2.5 flex w-full items-center gap-2.5 text-left",children:[a.jsx(ve,{tone:i,size:"sm",children:a.jsx(Cy,{tier:o.tier,iconSvg:n(o.origin)})}),a.jsx("span",{className:"text-sm font-semibold tracking-tight group-hover/ih:text-foreground transition-colors",children:o.owner}),a.jsx(ye,{tone:o.tier==="local"?"fuchsia":"outline",children:o.tier==="local"?"base class":Xs(o.origin)}),a.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[11px] text-muted-foreground/50 group-hover/ih:text-muted-foreground transition-colors",children:["inherited ",a.jsx(iu,{className:"h-3.5 w-3.5"})]})]}),a.jsxs("div",{className:"space-y-2.5",children:[o.props.length>0&&a.jsx(kt,{className:"divide-y divide-border/70",children:o.props.map(([l,d,u])=>a.jsx(qc,{bundle:e,refBase:c,pname:l,schema:d,optional:u},`p-${l}`))}),o.methods.map(l=>a.jsx(Zc,{bundle:e,owner:o.owner,ownerKind:"class",handlerOwnerLocal:o.tier==="local",refBase:c,mname:l.name,method:l.method,overridden:l.overridden},`m-${l.name}`))]})]},c)})})})}function Cy({tier:e,iconSvg:t}){return e==="local"?a.jsx(Me,{}):t?a.jsx(ge,{svg:t,className:"h-4 w-4"}):e==="kernel"?a.jsx($u,{}):a.jsx(gt,{})}function Sy({bundle:e,endpoints:t,edgeName:n}){const[s,o]=t;return a.jsx(kt,{className:"px-3 py-5",children:a.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-stretch gap-1",children:[a.jsx(ji,{bundle:e,endpoint:s,edgeName:n}),a.jsx(_y,{edgeName:n,from:s,to:o}),a.jsx(ji,{bundle:e,endpoint:o,edgeName:n})]})})}function ji({bundle:e,endpoint:t,edgeName:n}){const s=X(f=>f.selectClass);if(!t)return null;const o=e.ir;if(!o)return null;const r=t.refs!==void 0?t.refs.filter(co).map(f=>({name:f.name,ref:f})):t.types.map(f=>({name:f}));r.length===0&&r.push({name:"—"});const i=t.cardinality,c=t.name?lo(`edge.${n}.endpoint.${t.name}`,t.name):{},l=({name:f,ref:p})=>{if(p){const x=p.origin===o.domain,y=x?o.classes[f]:Yn(e,p),j=!!y;return{t:f,key:Be(p),origin:x?void 0:p.origin,resolvable:j,selectionId:x?`class.${p.name}`:`class.${Be(p)}`,icon:y?.icon}}const m=o.classes[f],w=!!m;return{t:f,key:`class:${f}`,origin:void 0,resolvable:w,selectionId:w?`class.${f}`:void 0,icon:m?.icon}},d=f=>()=>{f.resolvable&&f.selectionId&&s(f.selectionId)},u=a.jsx("div",{className:"inline-flex max-w-full items-center rounded-full bg-muted/60 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/80",children:a.jsx("span",{className:"truncate",children:t.name})}),h=a.jsx("span",{className:"inline-flex items-center rounded-full border border-border/70 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground/80",title:"declared cardinality",children:Ys(i)});if(r.length===1){const f=l(r[0]);return a.jsxs("button",{type:"button",onClick:f.resolvable?d(f):void 0,disabled:!f.resolvable,title:f.resolvable?`Open ${f.t}`:f.origin?`${f.t} · ${f.origin}`:f.t,...c,className:ae("group/ep flex flex-col items-center gap-2.5 rounded-xl px-2 py-3 text-center min-w-0 transition-colors",f.resolvable?"hover:bg-accent/60 cursor-pointer":"cursor-default"),children:[a.jsx(ve,{tone:f.origin?"sky":"violet",size:"lg",className:"transition-transform group-hover/ep:-translate-y-0.5",children:f.icon?a.jsx(ge,{svg:f.icon,className:"h-5 w-5"}):a.jsx(Me,{})}),a.jsxs("div",{className:"min-w-0 w-full space-y-1.5",children:[a.jsx("div",{className:"text-sm font-bold break-words leading-tight",children:f.t}),a.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1",children:[u,h]})]})]})}return a.jsxs("div",{...c,className:"flex flex-col items-center gap-2.5 rounded-xl px-2 py-3 text-center min-w-0",children:[a.jsx("div",{className:"flex flex-wrap items-center justify-center gap-1.5",children:r.map(f=>{const p=l(f);return a.jsxs("button",{type:"button",onClick:p.resolvable?d(p):void 0,disabled:!p.resolvable,title:p.resolvable?`Open ${p.t}`:p.origin?`${p.t} · ${p.origin}`:p.t,className:ae("inline-flex items-center gap-1.5 rounded-lg border border-border/70 pl-1 pr-2 py-1 transition-colors",p.resolvable?"hover:bg-accent/60 cursor-pointer":"cursor-default"),children:[a.jsx(ve,{tone:p.origin?"sky":"violet",size:"sm",children:p.icon?a.jsx(ge,{svg:p.icon,className:"h-3.5 w-3.5"}):a.jsx(Me,{})}),a.jsx("span",{className:"text-[13px] font-semibold",children:p.t})]},p.key)})}),a.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1",children:[a.jsx("span",{className:"text-[10px] lowercase tracking-wide text-muted-foreground/60",children:"any of"}),u,h]})]})}function _y({edgeName:e,from:t,to:n}){const s=t?.cardinality,o=n?.cardinality,r=`${Nn(s)?"many":"one"}-to-${Nn(o)?"many":"one"}`;return a.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 self-center px-1.5 min-w-[84px]",children:[a.jsxs("div",{className:"flex w-full items-center text-muted-foreground/45",children:[a.jsx(ki,{many:Nn(s),optional:Ni(s),side:"left"}),a.jsx("span",{className:"h-px flex-1 bg-border"}),a.jsx(Yi,{className:"h-[18px] w-[18px] shrink-0 text-muted-foreground/70"}),a.jsx("span",{className:"h-px flex-1 bg-border"}),a.jsx(ki,{many:Nn(o),optional:Ni(o),side:"right"})]}),a.jsxs(Kn,{openDelay:80,children:[a.jsx(Qn,{asChild:!0,children:a.jsx("button",{type:"button",className:"rounded-full border border-border/70 px-2 py-0.5 text-[10px] font-medium text-muted-foreground/75 transition-colors hover:text-muted-foreground cursor-default",children:r})}),a.jsx(Jn,{className:"w-60",children:a.jsxs("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:[a.jsx("span",{className:"font-mono text-foreground/90",children:e})," links"," ",a.jsx("span",{className:"font-mono text-foreground/90",children:Ys(s)})," ",t?.name," to"," ",a.jsx("span",{className:"font-mono text-foreground/90",children:Ys(o)})," ",n?.name,"."]})})]})]})}function ki({many:e,optional:t,side:n}){return a.jsx("svg",{viewBox:"0 0 24 16",className:ae("h-4 w-6 shrink-0",n==="right"&&"rotate-180"),fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e?a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M22 8 L9 2 M22 8 L9 8 M22 8 L9 14"}),!t&&a.jsx("circle",{cx:"16",cy:"8",r:"2.2",fill:"currentColor",stroke:"none"})]}):a.jsx("circle",{cx:"9",cy:"8",r:"3",fill:t?"none":"currentColor",stroke:t?"currentColor":"none"})})}function Gc(){const e=X(n=>n.back);return X(n=>n.selectionHistory.length>0)?a.jsx("div",{className:"px-3 pt-3",children:a.jsxs("button",{type:"button",onClick:()=>e(),title:"Back to previous selection",className:"group inline-flex items-center gap-1 rounded-md px-2 py-1 text-[12px] text-muted-foreground/55 transition-colors hover:bg-accent/50 hover:text-muted-foreground",children:[a.jsx(ju,{className:"h-3.5 w-3.5 transition-transform group-hover:-translate-x-0.5"}),"Back"]})}):null}function Uc({bundle:e,selected:t}){const n=e.ir,s=X(E=>E.selectClass),{data:o}=nn(),r=uo(e.domainId),i=E=>E?o?.find(k=>k.origin===E)?.icon:void 0;if(!n||!t)return a.jsx("div",{className:"h-full flex items-center justify-center px-6",children:a.jsx(Ft,{icon:a.jsx(cu,{}),title:"Nothing selected",hint:"Pick a Class or relationship to inspect its properties, methods, handlers, and Views."})});if(t.startsWith("module."))return a.jsx(My,{bundle:e,path:t.slice(7)});const c=t.startsWith("class.")?t.slice(6):t,l=lu(c),d=l===void 0||l.origin===n.domain,u=l?.name??c,h=d?n.classes[u]:Yn(e,l);if(!h)return a.jsx("div",{className:"h-full flex items-center justify-center px-6",children:a.jsx(Ft,{title:"Not found",hint:t})});const f=l??{origin:n.domain,kind:"class",name:u},p=h.type==="edge",w=d?du(p?"edge":"class",u):`class.${Be(f)}`,x=d?e.overlay.sourceSpans[w]:void 0,y=Object.entries(h.properties),j=Object.entries(h.methods),g=d&&!p?my(e,u):[],v=d&&!p?uu(r,u):[];return a.jsxs("div",{className:"h-full overflow-y-auto",...lo(w,u),children:[a.jsx(Gc,{}),a.jsxs("div",{className:"px-5 py-6 space-y-7",children:[a.jsxs("header",{className:"group space-y-3",children:[a.jsxs("div",{className:"flex items-start gap-3.5",children:[a.jsx(ve,{tone:"violet",size:"lg",children:h.icon?a.jsx(ge,{svg:h.icon,className:"h-5 w-5"}):p?a.jsx(mt,{}):a.jsx(Me,{})}),a.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-lg font-extrabold tracking-tight truncate",children:u}),p&&a.jsx(ye,{tone:"outline",children:"edge"}),!d&&a.jsx(ye,{tone:"outline",children:Xs(f.origin)}),a.jsx(Dt,{anchorRef:{ref:w,kind:"schema",file:x?.file},excerpt:u,className:"ml-auto"})]}),(x?.doc??h.description)&&a.jsx("p",{className:"text-[13px] text-muted-foreground mt-1 leading-relaxed",children:x?.doc??h.description})]})]}),(h.extendsRefs??[]).length>0&&a.jsx("div",{className:"flex flex-wrap items-center gap-1.5 pl-[3.25rem]",children:(h.extendsRefs??[]).map(E=>{const k=Yn(e,E)!==void 0,C=E.origin===n.domain?`class.${E.name}`:`class.${Be(E)}`;return a.jsx("button",{type:"button",disabled:!k,onClick:()=>k&&s(C),children:a.jsxs(ye,{tone:"outline",children:["extends ",E.name,E.origin===n.domain?"":` · ${Xs(E.origin)}`]})},Be(E))})})]}),p&&(h.endpoints?.length??0)>=2&&a.jsx(qe,{label:"Relationship",children:a.jsx(Sy,{bundle:e,endpoints:h.endpoints,edgeName:u})}),y.length>0&&a.jsx(qe,{label:"Properties",hint:`${y.length}`,children:a.jsx(kt,{className:"divide-y divide-border/70",children:y.map(([E,k])=>a.jsx(qc,{bundle:e,refBase:w,pname:E,schema:k,optional:!(h.required??[]).includes(E)},E))})}),j.length>0&&a.jsx(qe,{label:"Methods",hint:j.length,children:a.jsx("div",{className:"space-y-2.5",children:j.map(([E,k])=>a.jsx(Zc,{bundle:e,owner:u,ownerKind:"class",handlerOwnerLocal:d,refBase:w,mname:E,method:k},E))})}),v.length>0&&a.jsx(qe,{label:"Views",hint:`${v.length}`,children:a.jsx("div",{className:"flex flex-col gap-0.5",children:v.map(E=>a.jsx(Xn,{domainId:e.domainId,view:E,icon:h.icon},E.slug))})}),g.length>0&&a.jsx(Ey,{bundle:e,groups:g,originIcon:i}),y.length===0&&j.length===0&&g.length===0&&!p&&a.jsx(Ft,{title:"No properties or methods",hint:"This Class declares no own members."})]})]})}function My({bundle:e,path:t}){const n=X(r=>r.selectClass),s=fu(e,t),o=r=>a.jsx(io,{onClick:()=>n(r.selectId),anchorRef:r.ref,anchorExcerpt:r.name,leading:a.jsx(ve,{tone:r.kind==="edge"?"amber":"sky",size:"sm",children:r.icon?a.jsx(ge,{svg:r.icon,className:"h-4 w-4"}):r.kind==="edge"?a.jsx(mt,{}):a.jsx(Me,{})}),title:r.name},r.selectId);return a.jsxs("div",{className:"h-full overflow-y-auto",...lo(`module.${t}`,s.label),children:[a.jsx(Gc,{}),a.jsxs("div",{className:"px-5 py-6 space-y-7",children:[a.jsxs("header",{className:"flex items-start gap-3.5",children:[a.jsx(ve,{tone:"muted",size:"lg",style:{color:`oklch(0.82 0.12 ${s.hue})`},children:a.jsx(on,{})}),a.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[a.jsx("h2",{className:"text-lg font-extrabold tracking-tight truncate",children:s.label}),a.jsxs("p",{className:"text-[13px] text-muted-foreground mt-1",children:[s.classes.length," ",s.classes.length===1?"class":"classes",s.edges.length>0&&` · ${s.edges.length} relationship${s.edges.length===1?"":"s"}`]})]})]}),s.classes.length>0&&a.jsx(qe,{label:"Classes",children:a.jsx(kt,{className:"divide-y divide-border/70",children:s.classes.map(o)})}),s.edges.length>0&&a.jsx(qe,{label:"Relationships",children:a.jsx(kt,{className:"divide-y divide-border/70",children:s.edges.map(o)})})]})]})}function Kc(e,t){return`extmember.${e}.class.${t}`}function qs(e){return e?e.refs!==void 0?e.refs.filter(co).map(t=>({name:t.name,ref:t})):e.types.map(t=>({name:t})):[]}function Qc(e,t){const n=qs(t).flatMap(({name:s,ref:o})=>(o===void 0||o.origin===e.domain)&&e.classes[s]?.type==="node"?[s]:[]);return[...new Set(n)].map(s=>({className:s}))}function Jc(e){const t=e.ir;if(!t)return[];const n=[];for(const[s,o]of Object.entries(t.classes)){if(o.type!=="edge"||!o.endpoints)continue;const r=o.endpoints[0],i=o.endpoints[1];if(!(!r||!i))for(const[c,l]of[[r,i],[i,r]]){const d=qs(c).filter(({name:h,ref:f})=>(f===void 0||f.origin===t.domain)&&t.classes[h]?.type==="node"),u=qs(l).flatMap(({name:h,ref:f})=>{if(f===void 0||f.origin===t.domain)return[];const p=t.importsByKey[Be(f)];return p===void 0?[]:[{name:h,ref:p.ref}]});for(const h of u)for(const f of d)n.push({edge:s,from:f.name,origin:h.ref.origin,to:h.name,...f.ref===void 0?{}:{fromRef:f.ref},toRef:h.ref,fromCard:c.cardinality,toCard:l.cardinality})}}return n}function el(e){const t=new Map;for(const n of Jc(e)){const s=t.get(n.origin)??new Map;s.set(Be(n.toRef),{name:n.to,ref:n.toRef}),t.set(n.origin,s)}return[...t].map(([n,s])=>({origin:n,kind:n==="kernel.astrale.ai"?"kernel":"external",members:[...s.values()].sort((o,r)=>o.name.localeCompare(r.name))})).sort((n,s)=>n.kind===s.kind?n.origin.localeCompare(s.origin):n.kind==="kernel"?1:-1)}const Iy={hidden:{},showInheritedEdges:!0},tn=e=>qi("class",e),tl=e=>qi("edge",e),Zs=e=>`domain.${e}`;function Pe(e,t){return t[e]===!0}function Ei(e,t){if(e.showInheritedEdges!==t.showInheritedEdges)return!1;const n=Object.keys(e.hidden);return n.length===Object.keys(t.hidden).length&&n.every(s=>t.hidden[s])}function $y(e,t){return!Pe(tn(e),t)}function Ry(e,t){return!Pe(Zs(e),t)}function nl(e,t,n){return!Pe(tl(e.edgeName),t)&&!Pe(tn(e.aClass),t)&&!Pe(tn(e.bClass),t)}const Gs="domain.import.",sl=e=>`${Gs}${e}`;function ol(){const{data:e}=nn(),t=new Map((e??[]).map(n=>[n.origin,n]));return n=>t.get(n)??{name:n.split(".")[0]||n,icon:""}}function Ay({domain:e}){const t=ol(),n=X(c=>Pe(Zs(e.origin),c.hidden)),s=X(c=>c.toggleHidden),o=t(e.origin),r=e.kind==="kernel"?"violet":"emerald",i=e.members.length;return a.jsxs("div",{className:ae("group flex items-center gap-2 rounded-lg px-1.5 py-1 transition-opacity",n&&"opacity-50"),children:[a.jsx(ve,{tone:r,size:"sm",children:o.icon?a.jsx(ge,{svg:o.icon,className:"h-3.5 w-3.5"}):a.jsx(gt,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:o.name}),a.jsxs("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:[i," linked ",i===1?"type":"types"]})]}),a.jsx("button",{type:"button",onClick:()=>s(Zs(e.origin)),title:n?"Show in canvas":"Hide in canvas",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent/60 hover:text-foreground",children:n?a.jsx(Zi,{className:"h-3.5 w-3.5"}):a.jsx(Gi,{className:"h-3.5 w-3.5"})})]})}function Dy({origin:e}){const n=ol()(e);return a.jsx(fn,{anchor:{ref:sl(e),kind:"section"},excerpt:`Import ${n.name}`,children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-1.5 py-1",children:[a.jsx(ve,{tone:"amber",size:"sm",children:n.icon?a.jsx(ge,{svg:n.icon,className:"h-3.5 w-3.5"}):a.jsx(gt,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:n.name}),a.jsx("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:"import requested"})]})]})})}function Py({domainId:e,taken:t}){const{data:n}=nn(),{create:s}=Ui(e),o=X(c=>c.setOpenAnchor),r=c=>{const l=sl(c.origin);s.mutate({anchors:[c.origin],anchorRefs:[{ref:l,kind:"section"}],text:`Import the ${c.name} domain (${c.origin}) — add it to this domain's imports and wire up the types we depend on.`,firstRole:"user",type:"text"},{onSuccess:()=>{o(l),In.success("Import requested — add the why/how in the comment")},onError:d=>In.error(String(d))})},i=(n??[]).filter(c=>c.kind!=="kernel"&&c.origin!==e&&!t.has(c.origin));return a.jsxs($t,{children:[a.jsx(oo,{asChild:!0,children:a.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[a.jsx(ta,{className:"h-3.5 w-3.5"}),"Import a domain"]})}),a.jsxs(Rt,{align:"start",side:"top",className:"w-64 p-1.5",children:[a.jsx("div",{className:"px-1.5 pb-1.5 pt-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Catalog"}),i.length===0?a.jsx("div",{className:"px-1.5 py-3 text-center text-xs text-muted-foreground/60",children:"Everything imported"}):a.jsx("div",{className:"flex flex-col gap-0.5",children:i.map(c=>a.jsxs("button",{type:"button",onClick:()=>r(c),disabled:s.isPending,className:"group/imp flex items-center gap-2.5 rounded-lg px-1.5 py-1.5 text-left transition-colors hover:bg-accent/60 disabled:opacity-50",children:[a.jsx(ve,{tone:c.kind==="external"?"emerald":"sky",size:"sm",children:c.icon?a.jsx(ge,{svg:c.icon,className:"h-3.5 w-3.5"}):a.jsx(gt,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:c.name}),a.jsx("div",{className:"truncate text-[11px] text-muted-foreground/70 leading-tight",children:c.description})]}),a.jsx("span",{className:"shrink-0 text-[11px] font-medium text-primary opacity-0 transition-opacity group-hover/imp:opacity-100",children:"Import"})]},c.origin))})]})]})}function Ty({domainId:e}){const{data:t}=ro(e),{data:n}=fo(e),s=N.useMemo(()=>t?el(t):[],[t]),o=N.useMemo(()=>new Set(s.map(c=>c.origin)),[s]),r=N.useMemo(()=>{const c=new Set(["kernel.astrale.ai",...o]);for(const l of t?.overlay.requires??[])c.add(l);for(const l of t?.overlay.crossDomainImports??[])c.add(l.origin);return c},[o,t]),i=N.useMemo(()=>{const c=new Set,l=[];for(const d of n?.comments??[])if(d.status==="open")for(const u of d.anchorRefs){if(!u.ref.startsWith(Gs))continue;const h=u.ref.slice(Gs.length);o.has(h)||c.has(h)||(c.add(h),l.push(h))}return l},[n,o]);return a.jsx(At,{className:"h-full",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Domains"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:s.length})]}),s.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Imported domains"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:s.map(c=>a.jsx(Ay,{domain:c},c.origin))})]}),i.length>0&&a.jsxs(a.Fragment,{children:[s.length>0&&a.jsx(Mn,{className:"my-2 opacity-60"}),a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Requested"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:i.map(c=>a.jsx(Dy,{origin:c},c))})]}),s.length===0&&i.length===0&&a.jsx("p",{className:"px-2 pb-1 pt-0.5 text-[11px] text-muted-foreground/60",children:"No imported domains yet."}),a.jsx(Mn,{className:"my-3 opacity-60"}),a.jsx(Py,{domainId:e,taken:r})]})})}const Oy=18,zy=3,Ly=[{id:"erd-many",draw:a.jsx("path",{d:"M6 11 L18 4 L13.5 11 L18 18 Z",fill:"context-stroke",stroke:"none"})},{id:"erd-one",draw:a.jsx("circle",{cx:15,cy:11,r:2.9,fill:"context-stroke",stroke:"none"})}];function rl(){return a.jsx("svg",{width:"0",height:"0","aria-hidden":!0,className:"absolute",style:{position:"absolute"},children:a.jsx("defs",{children:Ly.map(({id:e,draw:t})=>a.jsx("marker",{id:e,viewBox:"0 0 24 22",refX:Oy+zy,refY:11,markerWidth:24,markerHeight:22,markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",children:a.jsx("g",{fill:"none",stroke:"context-stroke",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round",children:t})},e))})})}function Ci(e){return e?e.max===null||e.max>1?"erd-many":"erd-one":"erd-many"}function Xo(e,t){return{markerStart:Ci(e),markerEnd:Ci(t)}}const Si=88,Ms=24;function fs(e){if(e.type!=="group")return{};const t=(typeof e.measured?.width=="number"?e.measured.width:void 0)??(typeof e.style?.width=="number"?e.style.width:void 0),n=(typeof e.measured?.height=="number"?e.measured.height:void 0)??(typeof e.style?.height=="number"?e.style.height:void 0);return t!==void 0&&n!==void 0?{w:Math.round(t),h:Math.round(n)}:{}}function il(e,t){const n=t[e.id];if(!n)return e;const s={...e,position:{x:n.x,y:n.y}};return e.type==="group"&&n.w!==void 0&&n.h!==void 0&&(s.style={...e.style,width:n.w,height:n.h}),s}function Us(e){const t={};for(const n of e)t[n.id]={x:Math.round(n.position.x),y:Math.round(n.position.y),...fs(n)};return t}function al(e,t){let n=0,s=Number.POSITIVE_INFINITY;const o=new Map;for(const{node:l,position:d}of e)if(l.parentId){const u=d.y+(l.style?.height??Si)+Ms;o.set(l.parentId,Math.max(o.get(l.parentId)??34,u))}else n=Math.max(n,d.x+(l.style?.width??200)),s=Math.min(s,d.y);Number.isFinite(s)||(s=0);const r=n+96;let i=s;const c={};for(const l of t)if(l.parentId){const d=o.get(l.parentId)??34;c[l.id]={x:14,y:d},o.set(l.parentId,d+Si+Ms)}else c[l.id]={x:r,y:i,...fs(l)},i+=(l.style?.height??120)+Ms;return c}function cl(){const e=Zn(),t=N.useRef(new Map),n=N.useRef(new Map),s=N.useCallback(r=>{const i=n.current.get(r);i&&clearTimeout(i),n.current.delete(r);const c=t.current.get(r);t.current.delete(r),c&&Object.keys(c).length>0&&_e.setLayout(r,c).catch(()=>{})},[]),o=N.useCallback((r,i)=>{e.setQueryData(Fe.layout(r),l=>({renderFingerprint:l?.renderFingerprint,positions:{...l?.positions,...i}})),t.current.set(r,{...t.current.get(r),...i});const c=n.current.get(r);c&&clearTimeout(c),n.current.set(r,setTimeout(()=>s(r),500))},[s,e]);return N.useEffect(()=>()=>{for(const r of t.current.keys())s(r)},[s]),{commitLayout:o,flushLayout:s}}function Hy(e){const t=e.filter(n=>n.origin==="kernel.astrale.ai");return t.some(n=>n.name==="Identity")?"identity":t.some(n=>n.name==="Container")?"container":null}function ll(e,t,n,s){const o=e.ir;if(!o)return{nodes:[],edges:[]};const r=hu(e).filter(u=>u.classes.length>0),i=[];for(const u of r){const h=`grp-${u.path}`,f=t.has(u.path);if(i.push({id:h,type:f?"moduleNode":"group",position:{x:0,y:0},selectable:!0,data:{domainId:e.domainId,domainOrigin:o.domain,label:u.label,path:u.path,hue:u.hue,collapsed:f,classCount:u.classes.length},style:f?{width:200,height:44}:{width:200,height:120}}),!f)for(const p of u.classes){if(!$y(p,n))continue;const m=o.classes[p];i.push({id:`class.${p}`,type:"classNode",parentId:h,extent:"parent",expandParent:!0,position:{x:0,y:0},data:{domainId:e.domainId,domainOrigin:o.domain,name:p,props:Object.keys(m?.properties??{}).length,methods:Object.keys(m?.methods??{}).length,bases:(m?.extendsRefs??[]).map(w=>w.name),coreRole:Hy(m?.extendsRefs??[]),hue:u.hue,icon:m?.icon}})}}const c=u=>{const h=rt(e,u);return t.has(h)?`grp-${h}`:`class.${u}`},l=u=>Qc(o,u),d=[];for(const u of Object.values(o.classes)){if(u.type!=="edge")continue;const h=l(u.endpoints?.[0]),f=l(u.endpoints?.[1]),p=Xo(u.endpoints?.[0]?.cardinality,u.endpoints?.[1]?.cardinality);for(const m of h)for(const w of f){const x=c(m.className),y=c(w.className);if(x===y||!nl({edgeName:u.name,aClass:m.className,bClass:w.className},n))continue;const j=rt(e,m.className)!==rt(e,w.className);d.push({id:`edge-${u.name}__${x}__${y}`,source:x,target:y,type:"floating",data:{label:u.name,edgeClass:u.name,ownerDomainId:e.domainId},markerStart:p.markerStart,markerEnd:p.markerEnd,style:{stroke:j?"oklch(0.72 0.16 35)":"oklch(0.62 0.07 264)",strokeWidth:j?2.4:1.8}})}}if(s){for(const[u,h]of Object.entries(o.classes))if(!(h.type!=="node"||Pe(tn(u),n)))for(const f of h.extendsRefs??[]){if(f.origin!==o.domain||o.classes[f.name]?.type!=="node")continue;const p=c(u),m=c(f.name);p!==m&&d.push({id:`extends-${u}__${f.name}`,source:p,target:m,type:"floating",data:{label:"extends",kind:"extends",ownerDomainId:e.domainId},markerEnd:{type:ut.ArrowClosed,color:"oklch(0.72 0.18 330)",width:16,height:16},style:{stroke:"oklch(0.72 0.18 330)",strokeWidth:1.6,strokeDasharray:"2 4"}})}}return{nodes:i,edges:d}}function Vy({data:e}){const t=e;X(i=>i.selectClass),X(i=>i.setDomain);const n=X(i=>i.domainId===t.domainId&&i.selectedClass===`class.${t.name}`),o=re(i=>i.transform[2])<.5,r=t.coreRole?{container:"schema-core-container",identity:"schema-core-identity"}[t.coreRole]:void 0;return a.jsxs("div",{"data-domain-id":t.domainId,"data-core-role":t.coreRole??void 0,className:ae("relative rounded-lg border bg-card shadow-sm w-[160px] transition-shadow",r,n?"ring-2 ring-primary":"hover:shadow-md"),style:{borderLeft:`3px solid oklch(0.72 0.15 ${t.hue})`},children:[t.coreRole==="identity"&&a.jsx("span",{title:"Identity",className:"schema-core-identity-icon",children:a.jsx(Hu,{className:"h-3 w-3"})}),a.jsx(Ho,{domainId:t.domainId,anchorRef:`class.${t.name}`,kind:"schema",excerpt:t.name,className:t.coreRole==="identity"?"top-6":void 0}),a.jsx(Ie,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsxs("div",{className:"px-2.5 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[t.icon?a.jsx("span",{style:{color:`oklch(0.82 0.14 ${t.hue})`},className:"shrink-0",children:a.jsx(ge,{svg:t.icon,className:"h-6 w-6"})}):a.jsx("span",{className:"h-2.5 w-2.5 rounded-sm shrink-0",style:{background:`oklch(0.7 0.15 ${t.hue})`}}),a.jsx("span",{className:"text-sm font-extrabold truncate",children:t.name})]}),!o&&t.bases.length>0&&a.jsx("div",{className:"rf-meta mt-1.5 flex flex-wrap gap-1",children:t.bases.map(i=>a.jsx("span",{title:`extends ${i}`,className:"rounded bg-fuchsia-500/15 px-1 py-0.5 font-mono text-[9px] text-fuchsia-300",children:i},i))})]}),a.jsx(Ie,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}function Ks({data:e}){const t=e,n=X(r=>r.setDomain),s=X(r=>r.toggleModule),o=X(r=>r.domainId===t.domainId&&r.selectedClass===`module.${t.path}`);return a.jsxs("div",{"data-domain-id":t.domainId,className:ae("relative w-full h-full rounded-xl border transition-shadow",o?"ring-2 ring-primary":t.collapsed&&"hover:shadow-md cursor-pointer"),style:{borderColor:`oklch(0.55 0.1 ${t.hue} / 0.45)`,background:`oklch(0.5 0.12 ${t.hue} / ${t.collapsed?.12:.07})`},children:[a.jsx(Ho,{domainId:t.domainId,anchorRef:`module.${t.path}`,kind:"section",excerpt:t.label}),a.jsx(Ie,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsx(Ie,{type:"source",position:q.Bottom,className:"!opacity-0"}),a.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1.5 text-[13px]",style:{color:`oklch(0.85 0.12 ${t.hue})`},children:[a.jsx("button",{type:"button",title:t.collapsed?"Show classes":"Hide classes",onClick:r=>{r.stopPropagation(),t.onToggleModule?t.onToggleModule(t.domainId,t.path):(X.getState().domainId!==t.domainId&&n(t.domainId),s(t.path))},className:"rounded p-0.5 hover:bg-white/10 shrink-0",children:t.collapsed?a.jsx(Un,{className:"h-3.5 w-3.5"}):a.jsx(Gn,{className:"h-3.5 w-3.5"})}),a.jsx("span",{className:"font-extrabold truncate",children:t.label}),t.collapsed&&a.jsx("span",{className:"ml-auto text-[10px] opacity-60 shrink-0 pr-1",children:t.classCount})]})]})}function Fy({data:e}){const t=e,n=t.kind==="kernel"?285:158;return a.jsx("div",{className:"w-full h-full rounded-xl border border-dashed",style:{borderColor:`oklch(0.6 0.1 ${n} / 0.55)`,background:`oklch(0.5 0.1 ${n} / 0.06)`},children:a.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5",style:{color:`oklch(0.84 0.11 ${n})`},children:[a.jsx("span",{className:"shrink-0",children:t.icon?a.jsx(ge,{svg:t.icon,className:"h-4 w-4"}):a.jsx(gt,{className:"h-4 w-4"})}),a.jsx("span",{className:"text-[13px] font-extrabold truncate",children:t.name}),a.jsx("span",{className:"ml-auto text-[9px] uppercase tracking-wider opacity-60 shrink-0",children:t.kind})]})})}function By({data:e}){const t=e,n=t.kind==="kernel"?285:158;return a.jsxs("div",{className:"w-full h-full rounded-lg border bg-card flex items-center gap-1.5 px-2 shadow-sm",style:{borderLeft:`3px solid oklch(0.72 0.14 ${n})`},children:[a.jsx(Ie,{type:"target",position:q.Left,className:"!opacity-0"}),a.jsx(Me,{className:"h-4 w-4 shrink-0",style:{color:`oklch(0.78 0.13 ${n})`}}),a.jsx("span",{className:"text-[12px] font-extrabold truncate",children:t.name}),a.jsx(Ie,{type:"source",position:q.Right,className:"!opacity-0"})]})}function Wy({data:e}){const t=e;return a.jsx("div",{className:"relative w-full h-full rounded-2xl border-2 border-dashed",style:{borderColor:"oklch(0.62 0.04 264 / 0.38)",background:"oklch(0.6 0.03 264 / 0.025)"},children:a.jsx("span",{className:"absolute -top-2.5 left-5 px-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/55 whitespace-nowrap",style:{background:"var(--color-canvas)"},children:t.label})})}function Yy({data:e}){const t=e;return a.jsx(ul,{threads:t.comments,anchor:t.anchor,excerpt:t.excerpt,className:"nodrag nopan"})}const dl={classNode:Vy,group:Ks,moduleNode:Ks,extDomain:Fy,extMember:By,internalRegion:Wy,canvasComment:Yy};function ul({threads:e,anchor:t,excerpt:n,className:s}){const[o,r]=N.useState(!1);if(e.length===0)return null;const i=e.some(l=>l.status==="open")?"open":"resolved",c=e.some(l=>l.orphaned);return a.jsxs($t,{modal:!1,open:o,onOpenChange:r,children:[a.jsx(no,{asChild:!0,children:a.jsxs("button",{type:"button",title:"Schema canvas comments",onClick:l=>{l.stopPropagation(),r(d=>!d)},className:ae("flex h-6 min-w-6 items-center justify-center gap-1 rounded-full px-1.5 text-[11px] font-bold shadow-md ring-2 ring-card transition-colors hover:brightness-110",i==="open"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground",c&&"bg-destructive text-white",s),children:[a.jsx(Vi,{className:"h-3 w-3"}),e.length]})}),a.jsx(Rt,{side:"top",align:"center",className:"w-80",onInteractOutside:l=>l.preventDefault(),children:a.jsx(so,{anchor:t,excerpt:n,threads:e,onClose:()=>r(!1)})})]})}function Xy(e,t,n,s){let o=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const g of e){if(g.parentId)continue;const v=s?.[g.id]??g.position,E=g.style?.width??200,k=g.style?.height??120;o=Math.min(o,v.x),r=Math.max(r,v.x+E),i=Math.min(i,v.y),c=Math.max(c,v.y+k)}Number.isFinite(o)||(o=0,i=0,r=400,c=400);const l=56,d=o-l,u=i-l,h=r-o+2*l,f=new Map((n??[]).map(g=>[g.origin,g])),p=36,m=44,w=8,x=d+h+96,y=[];let j=u+24;for(const g of t){const v=f.get(g.origin),E=p+g.members.length*(m+w)+8,k=`extdom.${g.origin}`;y.push({id:k,type:"extDomain",position:s?.[k]??{x,y:j},draggable:!0,selectable:!1,data:{name:v?.name??g.origin.split(".")[0],origin:g.origin,kind:g.kind,icon:v?.icon},style:{width:216,height:E}}),g.members.forEach((C,I)=>{y.push({id:Kc(g.origin,C.name),type:"extMember",parentId:k,extent:"parent",draggable:!1,position:{x:12,y:p+I*(m+w)},data:{name:C.name,kind:g.kind},style:{width:192,height:m}})}),j+=E+40}return{extNodes:y}}function qy(e,t){let n=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const c of e){if(!c.id.startsWith("grp-"))continue;const l=c.style?.width??200,d=c.style?.height??120;n=Math.min(n,c.position.x),s=Math.min(s,c.position.y),o=Math.max(o,c.position.x+l),r=Math.max(r,c.position.y+d)}if(!Number.isFinite(n))return null;const i=56;return{id:"region",type:"internalRegion",position:{x:n-i,y:s-i},draggable:!1,selectable:!1,zIndex:-1,data:{label:t},style:{width:o-n+2*i,height:r-s+2*i}}}function Zy(e,t,n,s,o,r,i){const c=s.ir;if(!c)return[];const l=[];for(const d of e){if(!t.has(d.origin))continue;const u=Kc(d.origin,d.to);if(!n.has(u))continue;const h=d.fromRef?{types:[d.from],refs:[d.fromRef]}:{types:[d.from]};for(const f of Qc(c,h)){if(!nl({edgeName:d.edge,aClass:f.className,bClass:""},r))continue;const p=o.has(rt(s,f.className))?`grp-${rt(s,f.className)}`:`class.${f.className}`;if(!n.has(p))continue;const m="oklch(0.72 0.16 35)",w=Xo(d.fromCard,d.toCard);l.push({id:`edge-${d.edge}__${p}__${u}`,source:p,target:u,type:"floating",data:{label:d.edge,edgeClass:d.edge},markerStart:w.markerStart,markerEnd:w.markerEnd,style:{stroke:m,strokeWidth:2}})}}return l}function qo(e){return!e||!Number.isFinite(e.x)||!Number.isFinite(e.y)?null:{x:e.x,y:e.y}}function Gy(e){const t=new Map;for(const n of e??[]){const s=n.anchorRefs.find(c=>c.ref==="section.schema");if(!s)continue;const o=qo(s);if(!o)continue;const r=`${Math.round(o.x/12)*12}:${Math.round(o.y/12)*12}`,i=t.get(r);i?i.comments.push(n):t.set(r,{key:r,anchor:s,comments:[n]})}return[...t.values()]}function Uy(e){return(e??[]).filter(t=>{const n=t.anchorRefs.find(s=>s.ref==="section.schema");return!!n&&!qo(n)})}function Ky(e){return e.map(t=>{const n=qo(t.anchor)??{x:0,y:0};return{id:`canvas-comment.${t.key}`,type:"canvasComment",position:{x:n.x,y:n.y},draggable:!1,selectable:!1,data:{comments:t.comments,anchor:t.anchor,excerpt:"Schema canvas"},style:{width:24,height:24},zIndex:40}})}function Qy(e,t){const n=new Set([e]),s=new Set;for(const o of t)o.source===e?(n.add(o.target),s.add(o.id)):o.target===e&&(n.add(o.source),s.add(o.id));return{nodeIds:n,edgeIds:s}}function Jy({bundle:e,domainId:t,saved:n}){const{fitView:s,getNodes:o}=Pt(),r=X(W=>W.focusId),i=X(W=>W.focusClass),c=X(W=>W.panelOverlay),l=X(W=>W.setPanelOverlay),d=uo(t).all.length,u=Ki(t).data?.detectedIntegrations?.length??0,h=Qi(t).data,f=(h?.nodes.length??0)+(h?.edges.length??0),p=X(W=>W.selectClass),m=X(W=>W.selectedClass),w=X(W=>W.setFocus),x=X(W=>W.setOpenAnchor),y=X(W=>W.collapsedModules),j=X(W=>W.toggleModule),g=X(W=>W.hidden),v=X(W=>W.showInheritedEdges),E=X(W=>W.toggleInheritedEdges),k=X(W=>W.setVisibility),{data:C}=nn(),{data:I}=fo(t),{data:R}=pu(t),V=N.useRef(!1),[T,$]=N.useState([]),[A,b]=N.useState([]),[S,_]=N.useState(null),M=N.useMemo(()=>ll(e,new Set(y),g,v),[e.renderFingerprint,e,y,g,v]),D=N.useMemo(()=>el(e),[e]),P=N.useMemo(()=>Jc(e),[e]),L=Object.keys(g).sort().join(",")+`|${v}`;N.useEffect(()=>{if(!m?.startsWith("class."))return;const W=rt(e,m.slice(6));y.includes(W)&&j(W)},[m,e,y,j]);const H=Zn(),F=N.useRef(!1),{commitLayout:O}=cl(),B=N.useCallback(W=>{O(t,W)},[O,t]);N.useEffect(()=>{if(!R)return;const W=R,J=X.getState(),oe={hidden:W.hidden,showInheritedEdges:W.showInheritedEdges};Ei(oe,J)||k(oe),V.current=!0},[t,R,k]),N.useEffect(()=>{if(!V.current)return;const W=X.getState(),J={hidden:W.hidden,showInheritedEdges:W.showInheritedEdges},oe=H.getQueryData(Fe.visibility(t))??Iy;Ei(J,oe)||(H.setQueryData(Fe.visibility(t),J),_e.setVisibility(t,J).catch(()=>{}))},[g,v,t,H]);const Y=N.useCallback(W=>{const J=M.nodes.map(de=>il(de,W)),oe=D.filter(de=>Ry(de.origin,g)),{extNodes:he}=Xy(J,oe,C,W),se=[...J,...he],fe=new Set(se.map(de=>de.id));$(se),b(Wn([...M.edges,...Zy(P,new Set(oe.map(de=>de.origin)),fe,e,new Set(y),g)]))},[M,D,g,C,P,e,y,v]),Q=N.useCallback(()=>{F.current||(F.current=!0,requestAnimationFrame(()=>{s({padding:.18,duration:400})}))},[s]),G=N.useRef(n);G.current=n;const z=n!==void 0;N.useEffect(()=>{const W=G.current;if(!W)return;const J=M.nodes.filter(se=>W[se.id]),oe=M.nodes.filter(se=>!W[se.id]);if(oe.length===0){Y(W),Q();return}if(J.length===0){let se=!1;return Bn(M.nodes,M.edges).then(fe=>{if(se)return;const de=Us(fe);Y(de),B(de),Q()}),()=>{se=!0}}const he=al(J.map(se=>({node:se,position:W[se.id]})),oe);Y({...W,...he}),B(he),Q()},[M,z,D,P,C,L]);const Z=N.useCallback(W=>$(J=>ls(W.filter(oe=>oe.id!=="region"),J)),[]),te=N.useCallback(W=>b(J=>ds(W,J)),[]),ee=N.useCallback((W,J)=>{const oe={[J.id]:{x:Math.round(J.position.x),y:Math.round(J.position.y),...fs(J)}};if(J.parentId){const he=o(),se=he.find(fe=>fe.id===J.parentId);if(se){let fe=se.measured?.width??(typeof se.style?.width=="number"?se.style.width:200),de=se.measured?.height??(typeof se.style?.height=="number"?se.style.height:120);for(const je of he)je.parentId===J.parentId&&(fe=Math.max(fe,je.position.x+(je.measured?.width??160)),de=Math.max(de,je.position.y+(je.measured?.height??88)));oe[se.id]={x:Math.round(se.position.x),y:Math.round(se.position.y),w:Math.round(fe),h:Math.round(de)}}}B(oe)},[B,o]),U=N.useCallback(async()=>{await _e.resetLayout(t).catch(()=>{});const W=await Bn(M.nodes,M.edges),J=Us(W);Y(J),H.setQueryData(Fe.layout(t),{positions:J}),_e.setLayout(t,J).catch(()=>{}),requestAnimationFrame(()=>s({padding:.18,duration:400}))},[t,M,s,Y,H]),K=r??S,ne=N.useMemo(()=>K?Qy(K,A):null,[K,A]),ie=N.useMemo(()=>qy(T,e.overlay.origin),[T,e.overlay.origin]),ce=N.useMemo(()=>Gy(I?.comments),[I?.comments]),pe=N.useMemo(()=>Uy(I?.comments),[I?.comments]),Ne=N.useMemo(()=>Ky(ce),[ce]),Ce=N.useMemo(()=>{const W=T.map(oe=>{if(oe.type!=="classNode")return oe.className?{...oe,className:void 0}:oe;const he=ne&&!ne.nodeIds.has(oe.id)?"is-dimmed":void 0;return oe.className===he?oe:{...oe,className:he}}),J=ie?[ie,...W]:W;return Ne.length?[...J,...Ne]:J},[T,ne,ie,Ne]),Se=N.useMemo(()=>A.map(W=>{const J=W.data?.edgeClass??W.id.replace(/^edge-/,""),oe=m===`class.${J}`,he=ne?ne.edgeIds.has(W.id)?"is-on":"is-dimmed":void 0,se=oe?ae("is-selected",he):he;if(oe){const fe="var(--color-primary)";return{...W,className:se,data:{...W.data,selected:!0},style:{...W.style,stroke:fe,strokeWidth:3},markerEnd:typeof W.markerEnd=="object"?{...W.markerEnd,color:fe}:W.markerEnd}}return W.className===se&&!W.data?.selected?W:{...W,className:se,data:{...W.data,selected:!1}}}),[A,ne,m]);return a.jsxs(Po,{nodes:Ce,edges:Se,nodeTypes:dl,edgeTypes:Lo,onNodesChange:Z,onEdgesChange:te,onNodeDragStop:ee,onNodeClick:(W,J)=>{J.id.startsWith("class.")?i(J.id):J.id.startsWith("grp-")&&p(`module.${J.id.slice(4)}`)},onNodeMouseEnter:(W,J)=>J.id.startsWith("class.")&&_(J.id),onNodeMouseLeave:()=>_(null),onEdgeClick:(W,J)=>{if(!J.id.startsWith("edge-"))return;const oe=J.data?.edgeClass??J.id.slice(5);p(`class.${oe}`)},onPaneClick:()=>{w(null),x(null)},minZoom:.15,nodesConnectable:!1,edgesFocusable:!0,proOptions:{hideAttribution:!0},children:[a.jsx(To,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(rl,{}),a.jsx(Oo,{className:"!bg-card !border !border-border [&_button]:!bg-card [&_button]:!border-border [&_button]:!fill-foreground",showInteractive:!1,children:a.jsx(bt,{onClick:U,title:"Auto-arrange (ELK) — clears manual layout",children:a.jsx(ea,{className:"h-4 w-4 text-foreground"})})}),a.jsx(zo,{pannable:!0,zoomable:!0,className:"!bg-card !border !border-border",nodeColor:W=>W.type==="classNode"?`oklch(0.6 0.13 ${W.data.hue})`:"transparent",nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.7)"}),a.jsxs(tt,{position:"top-right",className:"flex gap-1.5",children:[pe.length>0&&a.jsx(ul,{threads:pe,anchor:{ref:"section.schema",kind:"section"},excerpt:"Schema canvas"}),a.jsxs(Ve,{size:"xs",variant:c==="domains"?"default":"outline",onClick:()=>l(c==="domains"?null:"domains"),title:"Imported domains — shown in the right panel",children:[a.jsx(gt,{className:"h-3.5 w-3.5"})," Domains",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:D.length})]}),a.jsxs(Ve,{size:"xs",variant:c==="views"?"default":"outline",onClick:()=>l(c==="views"?null:"views"),title:"Views — shown in the right panel",children:[a.jsx(sn,{className:"h-3.5 w-3.5"})," Views",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:d})]}),a.jsxs(Ve,{size:"xs",variant:c==="integrations"?"default":"outline",onClick:()=>l(c==="integrations"?null:"integrations"),title:"Integrations — shown in the right panel",children:[a.jsx(po,{className:"h-3.5 w-3.5"})," Integrations",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:u})]}),a.jsxs(Ve,{size:"xs",variant:v?"default":"outline",onClick:E,title:"Toggle Class inheritance edges",children:[a.jsx(mt,{className:"h-3.5 w-3.5"})," Inherited"]}),a.jsx(Bc,{count:f})]})]})}const Qs="integration.request.",fl=e=>`${Qs}${e}`,ew=e=>e.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"integration";function tw({name:e}){return a.jsx(fn,{anchor:{ref:`section.integrations.${e}`,kind:"section"},excerpt:`${e} integration`,children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-1.5 py-1",children:[a.jsx(ve,{tone:"emerald",size:"sm",children:a.jsx(po,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:e}),a.jsx("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:"in integrations/"})]})]})})}function nw({slug:e,label:t}){return a.jsx(fn,{anchor:{ref:fl(e),kind:"section"},excerpt:`Add ${t} integration`,children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-1.5 py-1",children:[a.jsx(ve,{tone:"amber",size:"sm",children:a.jsx(po,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:t}),a.jsx("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:"requested"})]})]})})}function sw({domainId:e,taken:t}){const{create:n}=Ui(e),s=X(h=>h.setOpenAnchor),[o,r]=N.useState(!1),[i,c]=N.useState(""),[l,d]=N.useState(""),u=()=>{const h=i.trim();if(!h)return;const f=fl(ew(h)),p=`Add a "${h}" integration under the integrations/ folder${l.trim()?` — ${l.trim()}`:""}. Wire it up the Astrale way (DI, secrets, idempotency).`;n.mutate({anchors:[h],anchorRefs:[{ref:f,kind:"section"}],text:p,firstRole:"user",type:"text"},{onSuccess:()=>{c(""),d(""),r(!1),s(f),In.success("Integration requested — add the why/how in the comment")},onError:m=>In.error(String(m))})};return a.jsxs($t,{open:o,onOpenChange:r,children:[a.jsx(oo,{asChild:!0,children:a.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[a.jsx(ta,{className:"h-3.5 w-3.5"}),"Request an integration"]})}),a.jsxs(Rt,{align:"start",side:"top",className:"w-64 p-2.5",children:[a.jsx("div",{className:"pb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Request an integration"}),a.jsx("input",{autoFocus:!0,value:i,onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Enter"&&u()},placeholder:"Name (e.g. Stripe)",className:"mb-1.5 w-full rounded-md border bg-background px-2 py-1.5 text-[13px] outline-none focus:border-primary"}),a.jsx("textarea",{value:l,onChange:h=>d(h.target.value),placeholder:"Why / what for (optional)",rows:2,className:"mb-2 w-full resize-none rounded-md border bg-background px-2 py-1.5 text-[13px] outline-none focus:border-primary"}),a.jsx("button",{type:"button",onClick:u,disabled:!i.trim()||n.isPending,className:"w-full rounded-md bg-primary px-2 py-1.5 text-[12px] font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",children:"Request"}),t.size>0&&a.jsxs("p",{className:"pt-2 text-[10px] leading-snug text-muted-foreground/50",children:["Already present: ",[...t].join(", ")]})]})]})}function ow({domainId:e}){const{data:t}=Ki(e),{data:n}=fo(e),s=t?.detectedIntegrations??[],o=N.useMemo(()=>new Set(s),[s]),r=N.useMemo(()=>{const i=new Set,c=[];for(const l of n?.comments??[])if(l.status==="open")for(const d of l.anchorRefs){if(!d.ref.startsWith(Qs))continue;const u=d.ref.slice(Qs.length);o.has(u)||i.has(u)||(i.add(u),c.push({slug:u,label:l.anchors[0]??u}))}return c},[n,o]);return a.jsx(At,{className:"h-full",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Integrations"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:s.length})]}),s.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Detected"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:s.map(i=>a.jsx(tw,{name:i},i))})]}),r.length>0&&a.jsxs(a.Fragment,{children:[s.length>0&&a.jsx(Mn,{className:"my-2 opacity-60"}),a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Requested"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:r.map(i=>a.jsx(nw,{slug:i.slug,label:i.label},i.slug))})]}),s.length===0&&r.length===0&&a.jsx("p",{className:"px-2 pb-1 pt-0.5 text-[11px] text-muted-foreground/60",children:"No integrations detected."}),a.jsx(Mn,{className:"my-3 opacity-60"}),a.jsx(sw,{domainId:e,taken:o})]})})}function st({onClose:e,children:t}){return a.jsxs("div",{className:"relative min-h-0 w-[420px] shrink-0 border-l bg-card/30",children:[a.jsx("button",{type:"button",onClick:e,"aria-label":"Close panel",title:"Close (Esc)",className:"absolute right-3.5 top-3.5 z-20 inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/50 transition-colors hover:bg-accent hover:text-foreground",children:a.jsx(mu,{className:"h-4 w-4"})}),t]})}function Js(e,t){return t?e.members.some(n=>n.selectId===t)?!0:e.children.some(n=>Js(n,t)):!1}function hl({root:e,selected:t,onSelect:n,controls:s}){return a.jsxs("div",{className:"text-sm py-2","data-domain-id":s?.domainId,children:[a.jsx("div",{className:"px-3 pb-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Modules"}),e.children.map(o=>a.jsx(pl,{node:o,depth:0,selected:t,onSelect:n,controls:s},o.path)),e.members.map(o=>a.jsx(ml,{m:o,depth:1,selected:t,onSelect:n,controls:s},o.selectId))]})}function pl({node:e,depth:t,selected:n,onSelect:s,controls:o}){const r=X(j=>j.collapsedModules),i=X(j=>j.toggleModule),c=o?.collapsedModules??r,l=o?.toggleModule??i,[d,u]=N.useState(!0),h=`module.${e.path}`,f=n===h,p=e.members.length>0,m=p?!c.includes(e.path)||Js(e,n):d||Js(e,n),w=()=>p?l(e.path):u(j=>!j),x={paddingLeft:8+t*12},y=m?Su:on;return a.jsxs("div",{children:[a.jsxs("div",{"data-anchor-ref":h,"data-anchor-excerpt":e.path,className:ae("flex items-center gap-0.5 pr-2 hover:bg-accent/50 rounded-md",f&&"bg-accent text-accent-foreground"),style:x,children:[a.jsx("button",{type:"button",onClick:w,className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-white/5",title:m?"Collapse":"Expand",children:m?a.jsx(Gn,{className:"h-3 w-3"}):a.jsx(Un,{className:"h-3 w-3"})}),a.jsxs("button",{type:"button",onClick:()=>s(h),className:ae("flex items-center gap-1.5 flex-1 min-w-0 py-1 text-left font-bold",f&&"font-extrabold"),children:[a.jsx(y,{className:"h-3.5 w-3.5 shrink-0",style:{color:`oklch(0.78 0.12 ${e.hue})`}}),a.jsx("span",{className:"truncate",children:e.name})]}),a.jsx(Dt,{domainId:o?.domainId,anchorRef:{ref:h,kind:"section"},excerpt:e.path,className:"ml-1"})]}),m&&a.jsxs("div",{children:[e.children.map(j=>a.jsx(pl,{node:j,depth:t+1,selected:n,onSelect:s,controls:o},j.path)),e.members.map(j=>a.jsx(ml,{m:j,depth:t+1,selected:n,onSelect:s,controls:o},j.selectId))]})]})}function ml({m:e,depth:t,selected:n,onSelect:s,controls:o}){const r=n===e.selectId,i=X(m=>Pe(e.ref,m.hidden)),c=X(m=>m.toggleHidden),l=o?Pe(e.ref,o.hidden):i,d=o?.toggleHidden??c,u=l,h=e.kind==="edge"?mt:Me,f=e.kind==="edge"?"text-amber-400":"text-sky-300",p=N.useRef(null);return N.useEffect(()=>{r&&p.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[r]),a.jsxs("div",{ref:p,"data-anchor-ref":e.selectId,"data-anchor-excerpt":`${e.kind} ${e.name}`,className:ae("group w-full flex items-center pr-2 hover:bg-accent/50",r&&"bg-accent text-accent-foreground font-black",u&&"opacity-50"),style:{paddingLeft:8+(t+1)*12+12},title:`${e.kind} ${e.name}`,children:[a.jsxs("button",{type:"button",onClick:()=>s(e.selectId),className:"flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left font-extrabold",children:[e.icon?a.jsx(ge,{svg:e.icon,className:ae("h-4 w-4 shrink-0",f)}):a.jsx(h,{className:ae("h-3.5 w-3.5 shrink-0",f)}),a.jsx("span",{className:"truncate",children:e.name})]}),a.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),d(e.ref)},title:l?"Show in canvas":"Hide in canvas",className:ae("ml-1 shrink-0 rounded p-0.5 text-muted-foreground/60 transition hover:bg-white/5 hover:text-foreground",l?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l?a.jsx(Zi,{className:"h-3.5 w-3.5"}):a.jsx(Gi,{className:"h-3.5 w-3.5"})}),a.jsx(Dt,{domainId:o?.domainId,anchorRef:{ref:e.selectId,kind:"schema"},excerpt:`${e.kind} ${e.name}`,className:"ml-1"})]})}const Vt={width:360,height:220},gl={width:200,height:120},jn=52,rw=48,qn=112,iw=1900;function aw(e){const t=e.type==="classNode"?{width:160,height:44}:e.type==="moduleNode"?{width:200,height:44}:gl;return{width:e.measured?.width??(typeof e.style?.width=="number"?e.style.width:t.width),height:e.measured?.height??(typeof e.style?.height=="number"?e.style.height:t.height)}}function cw(e){const t=e.filter(i=>!i.parentId);if(t.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let n=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const i of t){const c=aw(i);n=Math.min(n,i.position.x),s=Math.min(s,i.position.y),o=Math.max(o,i.position.x+c.width),r=Math.max(r,i.position.y+c.height)}return{minX:n,minY:s,maxX:o,maxY:r}}function lw(e){const t=[];let n=0,s=0,o=0;for(const r of e)n>0&&n+r.size.width>iw&&(n=0,s+=o+qn,o=0),t.push({x:n,y:s}),n+=r.size.width+qn,o=Math.max(o,r.size.height);return t}function dw(e,t){const n=e.filter(r=>t[r.domainId]);if(n.length===0)return lw(e);let s=n.reduce((r,i)=>{const c=t[i.domainId];return Math.max(r,c.x+i.size.width)},0);const o=n.reduce((r,i)=>Math.min(r,t[i.domainId].y),Number.POSITIVE_INFINITY);return e.map(r=>{const i=t[r.domainId];if(i)return i;s+=qn;const c={x:s,y:Number.isFinite(o)?o:0};return s+=r.size.width,c})}function uw(e,t,n,s){const o=e.map(i=>{const c=cw(i.nodes),l=s[i.domainId]??{x:jn-c.minX,y:jn+rw-c.minY},d={width:Math.max(Vt.width,c.maxX+l.x),height:Math.max(Vt.height,c.maxY+l.y)},u={width:Math.max(Vt.width,c.maxX+l.x+jn),height:Math.max(Vt.height,c.maxY+l.y+jn)},h=n[i.domainId];return{domainId:i.domainId,contentOffset:l,size:{width:h?Math.max(d.width,h.width):u.width,height:h?Math.max(d.height,h.height):u.height}}}),r=dw(o,t);return o.map((i,c)=>({...i,position:r[c]}))}function xl(e){return e.data?.workspaceGeometry??null}function _i(e,t){const n=xl(e);return n?{domainId:n.domainId,updates:{[n.localId]:{x:Math.round(e.position.x-n.offset.x),y:Math.round(e.position.y-n.offset.y),...t?{w:Math.round(t.width),h:Math.round(t.height)}:fs(e)}}}:null}const yl=N.createContext(null);function fw({actions:e,children:t}){return a.jsx(yl.Provider,{value:e,children:t})}function Zo(){const e=N.useContext(yl);if(!e)throw new Error("Workspace nodes require WorkspaceNodeActionsProvider");return e}function wl({nodeId:e,minimum:t,label:n,placement:s="module"}){const o=Zo();return a.jsx(q0,{position:"bottom-right",minWidth:t.width,minHeight:t.height,onResizeEnd:(r,i)=>o.resizeNode(e,{width:Math.round(i.width),height:Math.round(i.height)}),style:s==="domain"?{left:"calc(100% - 6px)",top:"calc(100% + 20px)"}:{left:"calc(100% + 20px)",top:"calc(100% + 20px)"},className:"nodrag nopan !flex !h-6 !w-6 !cursor-se-resize !items-start !justify-start !border-0 !bg-transparent !p-0",children:a.jsx("span",{"data-testid":`workspace-resize-${e}`,title:n,className:"block h-3 w-3 rounded-br-[3px] border-b-2 border-r-2 border-sky-300/60 opacity-45 transition-[opacity,border-color] hover:border-sky-200 hover:opacity-100 active:border-sky-100 active:opacity-100"})})}function hw({id:e,data:t}){const n=Zo(),s=t;return a.jsxs("div",{"data-domain-id":s.domainId,title:s.active?void 0:`Click to activate ${s.origin}`,className:ae("relative h-full w-full rounded-[22px] border-2 bg-card/[0.035] shadow-[0_24px_80px_-48px_rgba(0,0,0,0.9)] transition-colors",s.active?"border-sky-400/55 bg-sky-400/[0.045]":"cursor-pointer border-border/55 hover:border-border"),children:[a.jsxs("div",{"data-testid":`workspace-domain-header-${s.domainId}`,title:`Drag ${s.origin}`,onPointerDownCapture:()=>n.activateDomain(s.domainId),className:"workspace-domain-drag-handle absolute inset-x-0 top-0 flex h-12 cursor-grab select-none items-center gap-2 border-b border-border/35 px-4 active:cursor-grabbing",children:[a.jsx("span",{className:ae("h-2 w-2 rounded-full",s.active?"bg-sky-300 shadow-[0_0_12px_rgba(125,211,252,0.8)]":"bg-muted-foreground/35")}),a.jsx("span",{className:"truncate text-[13px] font-extrabold tracking-tight",children:s.origin}),a.jsx("span",{className:"ml-auto rounded-full bg-muted/70 px-1.5 py-0.5 text-[9px] font-semibold tabular-nums text-muted-foreground",children:s.memberCount})]}),s.active&&a.jsx(wl,{nodeId:e,minimum:Vt,label:`Resize ${s.origin}`,placement:"domain"})]})}function Mi(e){const t=Zo(),n=xl(e),s=e.data;return a.jsxs("div",{className:"relative h-full w-full",children:[a.jsx(Ks,{...e,data:{...s,onToggleModule:t.toggleModule}}),e.type==="group"&&n?.active&&a.jsx(wl,{nodeId:e.id,minimum:gl,label:"Resize module"})]})}const pw={...dl,group:Mi,moduleNode:Mi,workspaceDomain:hw},mw=216,gw=48,vl=52,xw=12,Ii=40,yw=e=>`workspace-external:${encodeURIComponent(e)}`,bl=(e,t,n)=>`workspace-external-member:${encodeURIComponent(e)}:${n?`${n}:`:""}${encodeURIComponent(t)}`;function ww(e,t,n){return e.position.x<t.position.x+t.size.width+n&&e.position.x+e.size.width+n>t.position.x&&e.position.y<t.position.y+t.size.height+n&&e.position.y+e.size.height+n>t.position.y}function vw(e,t,n,s){const o=e.ownerDomainIds.map(l=>t.get(l)).filter(l=>!!l),r=o.length>0?o:n,i=r.reduce((l,d)=>Math.max(l,d.position.x+d.size.width),0)+qn;let c=r.reduce((l,d)=>Math.min(l,d.position.y),Number.POSITIVE_INFINITY);for(Number.isFinite(c)||(c=0);;){const l={position:{x:i,y:c},size:e.size},d=s.find(u=>ww(l,u,Ii));if(!d)return l.position;c=d.position.y+d.size.height+Ii}}function bw(e,t,n){const s=[...e].sort((i,c)=>i.origin.localeCompare(c.origin)).map(i=>({...i,size:{width:mw,height:gw+i.members.length*vl+xw}})),o=new Map(t.map(i=>[i.domainId,i])),r=t.map(({position:i,size:c})=>({position:i,size:c}));for(const i of s){const c=n[i.origin];c&&r.push({position:c,size:i.size})}return s.map(i=>{const c=n[i.origin],l=c??vw(i,o,t,r);return c||r.push({position:l,size:i.size}),{...i,position:l}})}function Nw(e,t,n,s){const o=new Map((s??[]).map(c=>[c.origin,c])),r=bw(e,t,n),i=[];for(const c of r){const l=o.get(c.origin),d=yw(c.origin),u=c.origin==="kernel.astrale.ai"?"kernel":"external";i.push({id:d,type:"extDomain",position:c.position,draggable:!1,selectable:!1,data:{name:l?.name??c.origin.split(".")[0],origin:c.origin,kind:u,icon:l?.icon},style:c.size}),c.members.forEach((h,f)=>{i.push({id:bl(c.origin,h.name,h.definition),type:"extMember",parentId:d,extent:"parent",draggable:!1,position:{x:12,y:42+f*vl},data:{name:h.name,kind:u,definition:h.definition},style:{width:192,height:44}})})}return{nodes:i,positions:Object.fromEntries(r.map(c=>[c.origin,c.position]))}}const jw="oklch(0.76 0.16 35)",$i="oklch(0.72 0.18 330)",kw=e=>`workspace-domain:${e}`,wt=(e,t)=>`workspace:${encodeURIComponent(e)}:${t}`;async function Ew(e,t){const n=new Set(t),s=ll(e.bundle,n,e.visibility.hidden,e.visibility.showInheritedEdges),o=e.layout.positions,r=s.nodes.filter(l=>o[l.id]),i=s.nodes.filter(l=>!o[l.id]);let c;return i.length===0?c=o:r.length===0?c=Us(await Bn(s.nodes,s.edges)):c={...o,...al(r.map(l=>({node:l,position:o[l.id]})),i)},{input:e,collapsed:n,nodes:s.nodes.map(l=>il(l,c)),edges:s.edges}}function Ri(e){return e.refs!==void 0?e.refs.filter(co):e.types}function eo(e,t){const n=e.input.bundle.ir;if(!n||n.classes[t]?.type!=="node"||Pe(tn(t),e.input.visibility.hidden))return;const s=rt(e.input.bundle,t),o=e.collapsed.has(s)?`grp-${s}`:`class.${t}`;return{nodeId:wt(e.input.summary.id,o),domainId:e.input.summary.id,className:t}}function Cw(e,t){const n=e.input.bundle.ir;if(n)return Object.values(n.importsByKey).find(s=>s.ref.name===t)?.ref}function to(e,t,n,s){const o=e.input.bundle.ir;if(!o)return[];const r=typeof t=="string"?Cw(e,t)??{origin:o.domain,name:t}:t;if(r.origin===o.domain){const c=eo(e,r.name);return c?[c]:[]}const i=n.get(r.origin)??[];if(i.length>1&&s.add(`Multiple selected folders declare ${r.origin}; ${r.name} stays external.`),i.length===1){const c=eo(i[0],r.name);if(c)return[c];s.add(`${e.input.summary.origin} imports ${r.origin}:class.${r.name}, but the selected schema does not expose it.`)}return[{nodeId:bl(r.origin,r.name,"class"),domainId:null,className:null,unresolved:{origin:r.origin,name:r.name,definition:"class"}}]}function Sw(e,t,n,s){return`workspace-edge:${encodeURIComponent(e)}:${t}:${n}:${s}`}function _w(e,t,n){const s=[],o=new Map,r=new Set,i=(c,l)=>{if(!c.unresolved)return;const d=o.get(c.unresolved.origin)??{members:new Map,ownerDomainIds:new Set};d.members.set(c.unresolved.name,c.unresolved),d.ownerDomainIds.add(l),o.set(c.unresolved.origin,d)};for(const c of e){const l=c.input.bundle.ir;if(l)for(const d of Object.values(l.classes)){if(d.type!=="edge"||d.endpoints?.length!==2||Pe(tl(d.name),c.input.visibility.hidden))continue;const u=Ri(d.endpoints[0]).flatMap(p=>to(c,p,t,n)),h=Ri(d.endpoints[1]).flatMap(p=>to(c,p,t,n)),f=Xo(d.endpoints[0].cardinality,d.endpoints[1].cardinality);for(const p of u)for(const m of h){if(!(p.domainId!==c.input.summary.id||m.domainId!==c.input.summary.id)||p.nodeId===m.nodeId)continue;i(p,c.input.summary.id),i(m,c.input.summary.id);const x=Sw(c.input.summary.id,d.name,p.nodeId,m.nodeId);r.has(x)||(r.add(x),s.push({id:x,source:p.nodeId,target:m.nodeId,type:"floating",data:{label:d.name,edgeClass:d.name,ownerDomainId:c.input.summary.id},markerStart:f.markerStart,markerEnd:f.markerEnd,style:{stroke:jw,strokeWidth:2.5}}))}}}return{edges:s,unresolved:[...o.entries()].map(([c,l])=>({origin:c,members:[...l.members.values()].sort((d,u)=>d.name.localeCompare(u.name)),ownerDomainIds:[...l.ownerDomainIds]}))}}function Mw(e,t,n){const s=[],o=new Set;for(const r of e){const i=r.input.bundle.ir;if(!(!i||!r.input.visibility.showInheritedEdges))for(const[c,l]of Object.entries(i.classes)){if(l.type!=="node")continue;const d=eo(r,c);if(d)for(const u of l.extendsRefs??[])for(const h of to(r,u,t,n)){if(h.unresolved||h.nodeId===d.nodeId)continue;const f=`workspace-extends:${d.nodeId}:${h.nodeId}`;o.has(f)||(o.add(f),s.push({id:f,source:d.nodeId,target:h.nodeId,type:"floating",data:{label:"extends",kind:"extends",ownerDomainId:r.input.summary.id},markerEnd:{type:ut.ArrowClosed,color:$i,width:16,height:16},style:{stroke:$i,strokeWidth:1.7,strokeDasharray:"2 4"}}))}}}return s}function Iw(e,{activeDomainId:t,domainPositions:n={},externalPositions:s={},contentOffsets:o={},domainSizes:r={},catalog:i}){const c=new Set,l=new Map;for(const x of e){const y=x.input.bundle.ir?.domain??x.input.summary.origin;l.set(y,[...l.get(y)??[],x])}const d=uw(e.map(x=>({domainId:x.input.summary.id,nodes:x.nodes})),n,r,o),u=new Map(d.map(x=>[x.domainId,x])),h=[],f=[];for(const x of e){const y=x.input.summary.id,j=u.get(y),g=kw(y),v=y===t;h.push({id:g,type:"workspaceDomain",position:j.position,draggable:!0,dragHandle:".workspace-domain-drag-handle",selectable:!0,data:{domainId:y,origin:x.input.summary.origin,memberCount:Object.keys(x.input.bundle.ir?.classes??{}).length,active:v},style:{width:j.size.width,height:j.size.height}});for(const E of x.nodes){const k=!E.parentId,C=k?j.contentOffset:{x:0,y:0};h.push({...E,id:wt(y,E.id),parentId:k?g:wt(y,E.parentId),position:{x:E.position.x+C.x,y:E.position.y+C.y},data:{...E.data,workspaceGeometry:{domainId:y,localId:E.id,offset:C,active:v}},extent:"parent",expandParent:!1,draggable:v,selectable:v,focusable:v,style:{...E.style,...v?{}:{pointerEvents:"none"}}})}for(const E of x.edges)f.push({...E,id:wt(y,E.id),source:wt(y,E.source),target:wt(y,E.target)})}const p=_w(e,l,c),m=Mw(e,l,c),w=Nw(p.unresolved,d,s,i);return h.push(...w.nodes),f.push(...p.edges,...m),{nodes:h,edges:f,diagnostics:[...c].sort(),domainPositions:Object.fromEntries(d.map(x=>[x.domainId,x.position])),externalPositions:w.positions,contentOffsets:Object.fromEntries(d.map(x=>[x.domainId,x.contentOffset]))}}function $w(e){if(!e.startsWith("workspace:"))return null;const[,t,...n]=e.split(":");return!t||n.length===0?null:{domainId:decodeURIComponent(t),localId:n.join(":")}}function Rw({domains:e,viewsCount:t,onToggleInherited:n}){const{fitView:s,getNode:o}=Pt(),{data:r}=nn(),i=X(O=>O.domainId)??e[0]?.input.summary.id??"",c=X(O=>O.selectedClass),l=X(O=>O.setDomain),d=X(O=>O.setPanelOverlay),u=X(O=>O.panelOverlay),h=xe(O=>O.domainPositions),f=xe(O=>O.externalPositions),p=xe(O=>O.domainSizes),m=xe(O=>O.domainContentOffsets),w=xe(O=>O.setDomainPosition),x=xe(O=>O.setDomainSize),y=xe(O=>O.ensureDomainPositions),j=xe(O=>O.ensureExternalPositions),g=xe(O=>O.ensureDomainContentOffsets),v=xe(O=>O.resetWorkspaceFrames),E=xe(O=>O.toggleModule),{commitLayout:k}=cl(),C=N.useRef(""),I=N.useRef(!1),R=N.useCallback((O,B)=>{if(O.startsWith("workspace-domain:")){x(O.slice(17),B);return}const Y=o(O);if(!Y||Y.type!=="group")return;const Q=_i(Y,B);Q&&k(Q.domainId,Q.updates)},[k,o,x]),V=N.useCallback((O,B)=>{if(X.getState().domainId!==O){l(O);return}B&&X.getState().selectClass(B)},[l]),T=N.useCallback((O,B)=>{if(X.getState().domainId!==O){l(O);return}E(O,B)},[l,E]),$=N.useMemo(()=>({activateDomain:V,resizeNode:R,toggleModule:T}),[V,R,T]),A=N.useMemo(()=>Iw(e,{activeDomainId:i,catalog:r,contentOffsets:m,domainPositions:h,domainSizes:p,externalPositions:f}),[i,r,m,h,p,e,f]),[b,S]=N.useState(A.nodes),[_,M]=N.useState(()=>Wn(A.edges));N.useEffect(()=>{if(y(A.domainPositions),j(A.externalPositions),g(A.contentOffsets),S(A.nodes),M(Wn(A.edges)),I.current){I.current=!1;const Y=requestAnimationFrame(()=>s({padding:.12,duration:420}));return()=>cancelAnimationFrame(Y)}const O=e.map(Y=>Y.input.summary.id).join("|");if(C.current===O)return;C.current=O;const B=requestAnimationFrame(()=>s({padding:.12,duration:420}));return()=>cancelAnimationFrame(B)},[e,g,y,j,s,A]);const D=N.useCallback(O=>S(B=>ls(O.filter(Y=>Y.type!=="remove"),B)),[]),P=N.useCallback(O=>M(B=>ds(O.filter(Y=>Y.type!=="remove"),B)),[]),L=e.every(O=>O.input.visibility.showInheritedEdges),H=N.useCallback((O,B)=>{if(B.id.startsWith("workspace-domain:")){w(B.id.slice(17),{x:Math.round(B.position.x),y:Math.round(B.position.y)});return}const Y=_i(B);Y&&k(Y.domainId,Y.updates)},[k,w]),F=N.useMemo(()=>_.map(O=>{const B=O.data?.ownerDomainId,Y=O.data?.edgeClass;if(!(!!Y&&B===i&&c===`class.${Y}`))return O;const G="var(--color-primary)";return{...O,className:ae(O.className,"is-selected"),data:{...O.data,selected:!0},style:{...O.style,stroke:G,strokeWidth:3},markerEnd:typeof O.markerEnd=="object"?{...O.markerEnd,color:G}:O.markerEnd}}),[i,_,c]);return a.jsx(fw,{actions:$,children:a.jsxs(Po,{"data-testid":"workspace-schema-canvas",nodes:b,edges:F,nodeTypes:pw,edgeTypes:Lo,onNodesChange:D,onEdgesChange:P,onNodeDragStop:H,onNodeClick:(O,B)=>{if(B.id.startsWith("workspace-domain:")){V(B.id.slice(17));return}const Y=$w(B.id);Y&&(Y.localId.startsWith("class.")?V(Y.domainId,Y.localId):Y.localId.startsWith("grp-")&&V(Y.domainId,`module.${Y.localId.slice(4)}`))},onEdgeClick:(O,B)=>{const Y=B.data?.ownerDomainId,Q=B.data?.edgeClass;Y&&Q&&V(Y,`class.${Q}`)},onPaneClick:()=>X.getState().setFocus(null),minZoom:.08,nodesConnectable:!1,edgesFocusable:!0,onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},children:[a.jsx(To,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(rl,{}),a.jsx(Oo,{className:"!border !border-border !bg-card [&_button]:!border-border [&_button]:!bg-card [&_button]:!fill-foreground",showInteractive:!1,children:a.jsx(bt,{onClick:()=>{I.current=!0,v()},title:"Reset and auto-pack workspace regions",children:a.jsx(ea,{className:"h-4 w-4 text-foreground"})})}),a.jsx(zo,{pannable:!0,zoomable:!0,className:"!border !border-border !bg-card",nodeColor:O=>O.type==="classNode"?`oklch(0.6 0.13 ${O.data.hue})`:O.type==="workspaceDomain"?"oklch(0.52 0.08 225 / 0.45)":"transparent",nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.72)"}),A.diagnostics.length>0&&a.jsx(tt,{position:"top-center",className:"max-w-xl",children:a.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-warning/30 bg-card/95 px-3 py-2 text-[11px] text-warning shadow-lg backdrop-blur",children:[a.jsx(ct,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("span",{children:A.diagnostics.join(" ")})]})}),a.jsxs(tt,{position:"top-right",className:"flex gap-1.5",children:[a.jsxs(Ve,{size:"xs",variant:"outline",disabled:!0,title:"Selected workspace domains",children:[a.jsx(ao,{className:"h-3.5 w-3.5"})," Domains",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:e.length})]}),a.jsxs(Ve,{size:"xs",variant:u==="views"?"default":"outline",onClick:()=>d(u==="views"?null:"views"),title:"Views across selected domains",children:[a.jsx(sn,{className:"h-3.5 w-3.5"})," Views",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:t})]}),a.jsxs(Ve,{size:"xs",variant:L?"default":"outline",onClick:n,title:"Toggle inherited edges in every selected domain",children:[a.jsx(mt,{className:"h-3.5 w-3.5"})," Inherited"]})]})]})})}function Aw({domains:e,onToggleHidden:t}){const n=X(u=>u.domainId),s=X(u=>u.selectedClass),o=X(u=>u.setDomain),r=xe(u=>u.collapsedModules),i=xe(u=>u.toggleModule),[c,l]=N.useState({}),d=(u,h)=>{X.getState().domainId!==u&&o(u),h&&X.getState().selectClass(h)};return a.jsxs("div",{className:"py-2","data-testid":"workspace-module-tree",children:[a.jsxs("div",{className:"flex items-center gap-1.5 px-3 pb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[a.jsx(ao,{className:"h-3 w-3"})," Workspace modules"]}),e.map(u=>{const h=u.input.summary.id,f=n===h,p=!!c[h],m={domainId:h,collapsedModules:r[h]??[],hidden:u.input.visibility.hidden,toggleModule:x=>i(h,x),toggleHidden:x=>t(h,x)},w=Ji(u.input.bundle);return a.jsxs("section",{className:"border-b border-border/40 last:border-b-0",children:[a.jsxs("div",{"data-domain-id":h,className:ae("flex items-center gap-1 px-2 py-2 transition-colors",f?"bg-sky-400/[0.075]":"hover:bg-accent/30"),children:[a.jsx("button",{type:"button",onClick:()=>l(x=>{const y={...x};return y[h]?delete y[h]:y[h]=!0,y}),className:"rounded p-0.5 text-muted-foreground hover:bg-white/5",title:p?"Expand domain":"Collapse domain",children:p?a.jsx(Un,{className:"h-3.5 w-3.5"}):a.jsx(Gn,{className:"h-3.5 w-3.5"})}),a.jsx("button",{type:"button",onClick:()=>d(h),className:"min-w-0 flex-1 truncate text-left text-[12px] font-extrabold",title:`Make ${u.input.summary.origin} active`,children:u.input.summary.origin}),f&&a.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-sky-300",title:"Active"})]}),!p&&a.jsx("div",{className:"border-t border-border/25 bg-background/15",children:a.jsx(hl,{root:w,selected:f?s:void 0,onSelect:x=>d(h,x),controls:m})})]},h)})]})}const Dw={positions:{}},Pw={hidden:{},showInheritedEdges:!0};function Tw(e,t){const n=hn({queries:e.map(i=>({queryKey:Fe.bundle(i),queryFn:()=>_e.bundle(i)}))}),s=hn({queries:e.map(i=>({queryKey:Fe.anatomy(i),queryFn:()=>_e.anatomy(i)}))}),o=hn({queries:e.map(i=>({queryKey:Fe.layout(i),queryFn:()=>_e.layout(i)}))}),r=hn({queries:e.map(i=>({queryKey:Fe.visibility(i),queryFn:()=>_e.visibility(i)}))});return N.useMemo(()=>{const i=new Map((t??[]).map(u=>[u.id,u])),c=[],l=[];let d=!1;return e.forEach((u,h)=>{const f=i.get(u),p=n[h]?.data,m=s[h]?.data,w=n[h]?.error??s[h]?.error;if(w&&l.push(`${f?.origin??u}: ${String(w)}`),!f||!p||!m){d=d||!w;return}c.push({summary:f,bundle:p,anatomy:m,layout:o[h]?.data??Dw,visibility:r[h]?.data??Pw})}),{inputs:c,pending:d,errors:l}},[s,n,t,e,o,r])}function Ow({inputs:e}){const t=e.map(o=>({input:o,model:gu(o.anatomy,o.bundle)})),n=t.reduce((o,r)=>o+r.model.all.length,0),s=t.some(o=>o.model.hasDrift);return a.jsx(At,{className:"h-full","data-testid":"workspace-views-panel",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Workspace views"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:n}),s&&a.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-warning",children:[a.jsx(ct,{className:"h-3.5 w-3.5"})," drift"]})]}),n===0&&a.jsx(Ft,{icon:a.jsx(sn,{}),title:"No views",hint:"The selected domains declare no views."}),a.jsx("div",{className:"space-y-7",children:t.filter(o=>o.model.all.length>0).map(({input:o,model:r})=>a.jsxs("section",{"data-domain-id":o.summary.id,children:[a.jsxs("div",{className:"mb-2 flex items-center gap-2 border-b border-border/45 pb-2",children:[a.jsx("span",{className:"h-2 w-2 rounded-full bg-sky-300/80"}),a.jsx("h2",{className:"min-w-0 flex-1 truncate text-[13px] font-extrabold",children:o.summary.origin}),a.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground",children:r.all.length})]}),a.jsx("div",{className:"space-y-0.5",children:r.all.map(i=>{const c=i.boundClass?o.bundle.ir?.classes[i.boundClass]?.icon:void 0;return a.jsx(Xn,{domainId:o.summary.id,view:i,icon:c},`${o.summary.id}:${i.slug}`)})})]},o.summary.id))})]})})}const Ai=220,Di=620,zw=300;function Pi(e,t){return[e.summary.id,e.summary.origin,e.bundle.renderFingerprint,Object.keys(e.visibility.hidden).sort().join(","),e.visibility.showInheritedEdges,Object.entries(e.layout.positions).sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}:${s.x}:${s.y}:${s.w??""}:${s.h??""}`).join(","),t.slice().sort().join(",")].join("|")}function Lw({domainIds:e}){const{data:t}=xu(),{inputs:n,pending:s,errors:o}=Tw(e,t),r=Zn(),i=X($=>$.domainId),c=X($=>$.selectedClass),l=X($=>$.selectClass),d=X($=>$.setFocus),u=X($=>$.panelOverlay),h=X($=>$.setPanelOverlay),f=X($=>$.setCanvasMode),p=xe($=>$.collapsedModules),[m,w]=N.useState([]),x=N.useRef(new Map),[y,j]=N.useState(()=>{try{const $=Number(localStorage.getItem("studio.workspaceModulesWidth"));if(Number.isFinite($)&&$>=Ai&&$<=Di)return $}catch{}return zw});N.useEffect(()=>{f("schema"),X.getState().panelOverlay&&X.getState().panelOverlay!=="views"&&h(null)},[f,h]);const g=N.useMemo(()=>n.map($=>Pi($,p[$.summary.id]??[])).join("::"),[p,n]);N.useEffect(()=>{let $=!1;const A=new Set(n.map(b=>b.summary.id));for(const b of x.current.keys())A.has(b)||x.current.delete(b);return Promise.all(n.map(async b=>{const S=b.summary.id,_=p[S]??[],M=Pi(b,_),D=x.current.get(S);if(D?.key===M)return{...D.projection,input:b};const P=await Ew(b,_);return $||x.current.set(S,{key:M,projection:P}),P})).then(b=>{$||w(b)}),()=>{$=!0}},[g]),N.useEffect(()=>{const $=A=>{A.key!=="Escape"||A.defaultPrevented||(d(null),l(void 0),h(null))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[l,d,h]);const v=N.useCallback(($,A)=>{const b=n.find(_=>_.summary.id===$);if(!b)return;const S=A(b.visibility);r.setQueryData(Fe.visibility($),S),_e.setVisibility($,S).catch(()=>{r.invalidateQueries({queryKey:Fe.visibility($)})})},[n,r]),E=N.useCallback(($,A)=>v($,b=>{const S={...b.hidden};return S[A]?delete S[A]:S[A]=!0,{...b,hidden:S}}),[v]),k=N.useCallback(()=>{const $=!n.every(A=>A.visibility.showInheritedEdges);for(const A of n)v(A.summary.id,b=>({...b,showInheritedEdges:$}))},[n,v]),C=$=>{$.preventDefault();const A=$.clientX,b=y;let S=b;const _=D=>{S=Math.min(Di,Math.max(Ai,b+D.clientX-A)),j(S)},M=()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",M),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("studio.workspaceModulesWidth",String(S))}catch{}};document.addEventListener("pointermove",_),document.addEventListener("pointerup",M),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},I=n.find($=>$.summary.id===i),R=n.reduce(($,A)=>$+A.anatomy.views.length,0),V=m.length===n.length&&n.length===e.length,T=m.map($=>`${$.input.summary.id}:${$.input.bundle.renderFingerprint}`).join("|");return(s||!V)&&o.length===0?a.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Composing workspace…"}):a.jsxs("div",{className:"flex h-full flex-col","data-testid":"workspace-schema-section",children:[(o.length>0||n.some($=>$.bundle.error))&&a.jsxs("div",{className:"flex items-start gap-2 border-b border-warning/30 bg-warning/10 px-4 py-2 text-sm text-warning",children:[a.jsx(ct,{className:"mt-0.5 h-4 w-4 shrink-0"}),a.jsx("span",{children:[...o,...n.flatMap($=>$.bundle.error?.message??[])].join(" ")})]}),a.jsxs("div",{className:"flex min-h-0 flex-1",children:[a.jsxs("div",{className:"relative min-h-0 shrink-0 border-r",style:{width:y},children:[a.jsx(At,{className:"h-full",children:a.jsx(Aw,{domains:m,onToggleHidden:E})}),a.jsx("div",{role:"separator","aria-orientation":"vertical",onPointerDown:C,title:"Drag to resize",className:"group absolute right-0 top-0 z-20 h-full w-1.5 translate-x-1/2 cursor-col-resize",children:a.jsx("div",{className:"mx-auto h-full w-px bg-transparent transition-colors group-hover:bg-primary/50"})})]}),a.jsx("div",{className:"relative min-w-0 flex-1",children:a.jsx(Do,{children:a.jsx(Rw,{domains:m,viewsCount:R,onToggleInherited:k})},T)}),u==="views"?a.jsx(st,{onClose:()=>h(null),children:a.jsx(Ow,{inputs:n})}):c&&I?a.jsx(st,{onClose:()=>l(void 0),children:a.jsx(Uc,{bundle:I.bundle,selected:c})}):null]})]})}const Ti=180,Oi=560,Hw=240;function Bw({domainId:e}){const t=xe(s=>s.selectedDomainIds),n=t.includes(e)?t:[e,...t];return n.length>1?a.jsx(Lw,{domainIds:n}):a.jsx(Vw,{domainId:e})}function Vw({domainId:e}){const{data:t,isLoading:n}=ro(e),{data:s}=yu(e),{data:o}=Qi(e),r=X(g=>g.selectedClass),i=X(g=>g.selectClass),c=X(g=>g.setFocus),l=X(g=>g.canvasMode),d=l==="core",u=X(g=>g.panelOverlay),h=X(g=>g.setPanelOverlay),f=uo(e),[p,m]=N.useState(()=>{try{const g=Number(localStorage.getItem("studio.modulesWidth"));if(Number.isFinite(g)&&g>=Ti&&g<=Oi)return g}catch{}return Hw}),w=g=>{g.preventDefault();const v=g.clientX,E=p;let k=E;const C=R=>{k=Math.min(Oi,Math.max(Ti,E+(R.clientX-v))),m(k)},I=()=>{document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",I),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("studio.modulesWidth",String(k))}catch{}};document.addEventListener("pointermove",C),document.addEventListener("pointerup",I),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[x,y]=N.useState(null);N.useEffect(()=>y(null),[e,l]),N.useEffect(()=>{const g=v=>{v.key!=="Escape"||v.defaultPrevented||(c(null),i(void 0),y(null),h(null))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[c,i,h]);const j=N.useMemo(()=>t?.ir?Ji(t):null,[t]);return n||!t?a.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Introspecting schema…"}):a.jsxs("div",{className:"h-full flex flex-col",children:[t.error&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-warning/10 border-b border-warning/30 text-warning text-sm",children:[a.jsx(ct,{className:"h-4 w-4 shrink-0"}),a.jsxs("span",{children:[t.error.message,!t.depsInstalled&&" — showing the static structure; run `pnpm install` in the domain for full fidelity."]})]}),t.ir?a.jsxs("div",{className:"flex-1 flex min-h-0",children:[a.jsxs("div",{className:"relative border-r shrink-0 min-h-0",style:{width:p},children:[a.jsx(At,{className:"h-full",children:d?o&&a.jsx(fy,{core:o,bundle:t,selectedPath:x,onSelect:y}):j&&a.jsx(hl,{root:j,selected:r,onSelect:i})}),a.jsx("div",{role:"separator","aria-orientation":"vertical",onPointerDown:w,title:"Drag to resize",className:"group absolute right-0 top-0 z-20 h-full w-1.5 translate-x-1/2 cursor-col-resize",children:a.jsx("div",{className:"mx-auto h-full w-px bg-transparent transition-colors group-hover:bg-primary/50"})})]}),a.jsx("div",{className:"flex-1 min-w-0 relative",children:a.jsx(Do,{children:d?o?a.jsx(ly,{core:o,bundle:t,selectedPath:x,onSelect:y}):a.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Extracting core…"}):a.jsx(Jy,{bundle:t,domainId:e,saved:s?.positions},e)},`${e}:${l}`)}),d?x&&o&&a.jsx(st,{onClose:()=>y(null),children:a.jsx(dy,{core:o,bundle:t,selectedPath:x})}):u==="views"?a.jsx(st,{onClose:()=>h(null),children:a.jsx(Ny,{domainId:e,model:f})}):u==="domains"?a.jsx(st,{onClose:()=>h(null),children:a.jsx(Ty,{domainId:e})}):u==="integrations"?a.jsx(st,{onClose:()=>h(null),children:a.jsx(ow,{domainId:e})}):r?a.jsx(st,{onClose:()=>i(void 0),children:a.jsx(Uc,{bundle:t,selected:r})}):null]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm p-6 text-center",children:"No compiled schema available."})]})}export{Bw as SchemaSection};