@synnaxlabs/pluto 0.43.0 → 0.43.1

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 (71) hide show
  1. package/dist/{Item-BrHZi6Fl.cjs → Item-CB5c--eX.cjs} +1 -1
  2. package/dist/{Item-BgUwEjzV.js → Item-LAMTj0X2.js} +2 -2
  3. package/dist/{Link-Bngd8rrL.cjs → Link-CPnT8Xp9.cjs} +1 -1
  4. package/dist/{Link-y133HE5v.js → Link-DcudTtgT.js} +1 -1
  5. package/dist/{Provider-CAR23fYq.js → Provider-CLPfWTcl.js} +2 -2
  6. package/dist/{Provider-B1j7nPL9.cjs → Provider-s70PZ9lg.cjs} +1 -1
  7. package/dist/{Text-P0b041la.js → Text-BiWcjO1i.js} +1 -1
  8. package/dist/{Text-CLsJyQGy.cjs → Text-Dw0NDc2A.cjs} +1 -1
  9. package/dist/{Text-Ddc0C5JU.cjs → Text-bSIbkBIL.cjs} +1 -1
  10. package/dist/{Text-B1uUpUKk.js → Text-wL3te5S6.js} +3 -3
  11. package/dist/{Toggle-BC1o8qt5.js → Toggle-CbzT5wR_.js} +2 -2
  12. package/dist/{Toggle-D-vvd8lz.cjs → Toggle-CpDGR6M6.cjs} +1 -1
  13. package/dist/button.cjs +1 -1
  14. package/dist/button.js +1 -1
  15. package/dist/color.cjs +1 -1
  16. package/dist/color.js +1 -1
  17. package/dist/{eraser-CupVBBBp.js → eraser-BJxXs5KS.js} +2 -2
  18. package/dist/{eraser-C0Kv4_kL.cjs → eraser-CGxyWj3B.cjs} +2 -2
  19. package/dist/ether.cjs +1 -1
  20. package/dist/ether.js +6 -6
  21. package/dist/{external-8zJ3fvo2.js → external-5nVYtLDI.js} +4 -4
  22. package/dist/{external-firJ8w9n.js → external-69bqTAcN.js} +3 -3
  23. package/dist/{external-Ds5GDIp9.cjs → external-B-B5ro_s.cjs} +1 -1
  24. package/dist/{external-D38Y0J6S.cjs → external-B3Mtbu36.cjs} +1 -1
  25. package/dist/{external-DHw0SdIj.cjs → external-BgwS5D0j.cjs} +1 -1
  26. package/dist/{external-BYsOdgw5.js → external-Bn3A7Rew.js} +3 -3
  27. package/dist/{external-BgKH42un.cjs → external-Bojct8Fy.cjs} +1 -1
  28. package/dist/{external-CKag7gXR.js → external-C6mmYO7R.js} +4 -4
  29. package/dist/{external-BmeMUsxr.js → external-CnkWbciu.js} +2 -2
  30. package/dist/{external-D8mHEAIG.cjs → external-Cxwmal3D.cjs} +1 -1
  31. package/dist/{external-DuvwfKLw.js → external-Dm9rg2x7.js} +2 -2
  32. package/dist/{external-DlyrUZhP.cjs → external-EvgywGSS.cjs} +1 -1
  33. package/dist/{external-D1gwMWza.cjs → external-MJ2UMa_L.cjs} +1 -1
  34. package/dist/{external-Cjnx793K.js → external-UeyJ6mPv.js} +6 -6
  35. package/dist/{external-CjTwWT6m.cjs → external-V0yO0q2n.cjs} +1 -1
  36. package/dist/{external-IsogMmdT.cjs → external-cDUxSE0v.cjs} +1 -1
  37. package/dist/{external-BDh272rT.js → external-cJGWYB3x.js} +1 -1
  38. package/dist/{external-ZV7pEm55.js → external-fwvNilmo.js} +1 -1
  39. package/dist/{font-Cy9UYjyY.js → font-Csp00pQP.js} +2 -2
  40. package/dist/{font-C5EV9fq1.cjs → font-ifUcrCey.cjs} +1 -1
  41. package/dist/{fontString-CUy7T-OR.cjs → fontString-BWECl_1B.cjs} +1 -1
  42. package/dist/{fontString-CynarMI1.js → fontString-ap-NPnCD.js} +1 -1
  43. package/dist/header.cjs +1 -1
  44. package/dist/header.js +1 -1
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.js +177 -183
  47. package/dist/input.cjs +1 -1
  48. package/dist/input.js +1 -1
  49. package/dist/list.cjs +1 -1
  50. package/dist/list.js +1 -1
  51. package/dist/menu.cjs +1 -1
  52. package/dist/menu.js +1 -1
  53. package/dist/{provider-B8IM-N4g.cjs → provider-YWPkhTn6.cjs} +28 -28
  54. package/dist/{provider-CQqS-teQ.js → provider-gW90qzEG.js} +4439 -4409
  55. package/dist/src/aether/aether/aether.d.ts.map +1 -1
  56. package/dist/src/channel/LinePlot.d.ts +2 -2
  57. package/dist/src/channel/LinePlot.d.ts.map +1 -1
  58. package/dist/src/vis/lineplot/LinePlot.d.ts.map +1 -1
  59. package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
  60. package/dist/src/vis/lineplot/range/Provider.d.ts.map +1 -1
  61. package/dist/src/vis/lineplot/range/aether/provider.d.ts +2 -2
  62. package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +1 -1
  63. package/dist/tabs.cjs +1 -1
  64. package/dist/tabs.js +1 -1
  65. package/dist/theming.cjs +1 -1
  66. package/dist/theming.js +2 -2
  67. package/dist/tree.cjs +1 -1
  68. package/dist/tree.js +1 -1
  69. package/dist/{value-BVL4mfhG.cjs → value--TYeJRXm.cjs} +4 -4
  70. package/dist/{value-DLy5XRhS.js → value-dkHk-BsO.js} +27 -27
  71. package/package.json +4 -4
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Af=Object.defineProperty;var If=(e,t,n)=>t in e?Af(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var tt=(e,t,n)=>If(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./jsx-runtime-CITbqOLs.cjs"),g=require("react"),K=require("./Divider-D74_FAXn.cjs"),u=require("./css-C7rJrqRi.cjs"),os=require("./external-DHw0SdIj.cjs"),ce=require("./state-DwM4WaEw.cjs"),$f=require("./Stack-BbwDtaE6.cjs"),he=require("./external-IsogMmdT.cjs"),ne=require("./Space-ByFmfiTa.cjs"),De=require("./hooks-B92WH57y.cjs"),Bf=require("./useVirtualCursorDragWebKit-CUbBopD6.cjs"),Q=require("./Provider-B1j7nPL9.cjs"),Df=require("./external-GjPk23XZ.cjs"),Te=require("./external-Ds5GDIp9.cjs"),bl=require("./external-DC1RT1Js.cjs"),As=require("./WithIcon-CCnlO2LC.cjs"),Pe=require("./array-CZHEGH95.cjs"),Of=require("./external-BgKH42un.cjs"),An=require("./external-DlyrUZhP.cjs"),fe=require("./Toggle-D-vvd8lz.cjs"),pt=require("./Text-Ddc0C5JU.cjs"),bt=require("./provider-B8IM-N4g.cjs"),Ce=require("./Text-CLsJyQGy.cjs"),B=require("./value-BVL4mfhG.cjs"),me=require("./Haul-De8axVdi.cjs"),Ae=require("./useMemoCompare-BDs2sKw5.cjs"),si=require("./dimensions-BmlCx5q4.cjs"),er=require("./font-C5EV9fq1.cjs"),Ye=require("./Dropdown-BpoU-xVd.cjs"),Be=require("./deep-BRgXTyZn.cjs"),Ge=require("./external-D8mHEAIG.cjs"),Is=require("./Pack-80N7XB5O.cjs"),vt=require("./ContextMenu-BC5x7XR5.cjs"),zf=require("./Text-DTPuORh0.cjs"),vl=require("./external-DOujCKRS.cjs");require("./Item-BrHZi6Fl.cjs");const kl=require("react-dom"),kt=require("./external-CjTwWT6m.cjs"),Ml=require("./css.cjs"),Vf=require("./useClickOutside-CUa496t0.cjs"),tr=require("./useDebouncedCallback-Bx-HX76R.cjs"),Ff=require("./external-D1gwMWza.cjs"),ps=require("./eraser-C0Kv4_kL.cjs"),_o=require("./DateTime-DC19AIGq.cjs"),Hf=require("./external-D38Y0J6S.cjs"),Zf=require("./Video-BuzHLiXL.cjs"),Kf=e=>e.nullable().transform(t=>t===null?void 0:t).optional(),Pl=e=>Be.u(e,(t,n,s)=>{const r=n===s.length-1,i=!isNaN(parseInt(t)),l=!isNaN(parseInt(s[n+1]));return i&&(t="element"),r||l?t:[t,"shape"]}),oi=(e,t)=>{if(e==null)return null;const n=e[t];return n==null&&typeof e=="object"&&"sourceType"in e?e.sourceType()[t]:n},Wf=(e,t,n)=>Be.c(oi(e,"shape"),Pl(t),{...n,getter:oi}),Yf=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:Wf,getFieldSchemaPath:Pl,nullToUndefined:Kf},Symbol.toStringTag,{value:"Module"})),Gf=(e,t,n=150)=>{const[s,r]=g.useState(e);return g.useEffect(()=>{const i=setTimeout(()=>r(t),n);return()=>clearTimeout(i)},[t,n]),s},qf=Object.freeze(Object.defineProperty({__proto__:null,Config:fe.Config,Dialog:fe.Dialog,chooseLocation:fe.chooseLocation,formatTip:fe.formatTip,useConfig:fe.useConfig,wrap:fe.wrap},Symbol.toStringTag,{value:"Module"})),nr=({ref:e,location:t,style:n,size:s,className:r,children:i,onDragStart:l,sizeUnits:c="px",showHandle:a=!0,...d})=>{const x=u.K$1.construct(t),p=u.K$1.direction(x),m=u.g.dimension(p);return o.jsxRuntimeExports.jsxs(ne.Core,{className:u.CSS(u.CSS.B("resize"),u.CSS.loc(x),u.CSS.dir(p),r),style:{[m]:`${s}${c}`,...n},ref:e,...d,children:[i,a&&o.jsxRuntimeExports.jsx("div",{draggable:!0,className:u.CSS(u.CSS.BE("resize","handle"),u.CSS.bordered(u.K$1.swap(x))),onDragStart:l,onDrag:he.preventDefault,onDragEnd:he.preventDefault})]})},sr=({onResize:e,count:t,initialSizes:n=[],minSize:s=100,direction:r="x"})=>{const i=g.useRef(null),[l,c]=g.useState({sizeDistribution:Xf(n,t),root:null}),a=g.useCallback((p,m,f)=>{if(i.current==null)return;const h=u.Pt.dim(u.Pt.construct(i.current),r);c(j=>mo(j,h,p,s,m,f))},[s,c,r]);g.useEffect(()=>e==null?void 0:e(l.sizeDistribution),[l.sizeDistribution,e]);const d=g.useCallback((p,m)=>{p.preventDefault();const f=r==="x"?"clientX":"clientY",h=y=>a(m,y[f]),j=()=>{c(y=>({...y,root:null})),document.removeEventListener("mousemove",h)};c(y=>({...y,root:p[f]})),document.addEventListener("mousemove",h),document.addEventListener("mouseup",j,{once:!0})},[c,r,mo]);return{setSize:g.useCallback((p,m)=>a(p,void 0,m),[mo]),props:{direction:r,sizeDistribution:l.sizeDistribution,onDragHandle:d,ref:i}}},or=({ref:e,direction:t="x",children:n,sizeDistribution:s,onDragHandle:r,className:i,...l})=>{const c=u.g.construct(t),a=g.Children.toArray(n);return s=Uf(s),o.jsxRuntimeExports.jsx(ne.Space,{...l,ref:e,direction:c,className:u.CSS(u.CSS.B("resize-multiple"),i),empty:!0,grow:!0,children:a.map((d,x)=>o.jsxRuntimeExports.jsx(nr,{onDragStart:p=>r(p,x),location:u.g.location(c),size:s[x]*100,sizeUnits:"%",showHandle:x!==a.length-1,children:d},x))})},Xf=(e,t)=>{const n=e.reduce((r,i)=>r+i,0),s=t-e.length;if(s<=0)return e.slice(0,t).map(r=>r/n);if(e.every(r=>r<=1)){const r=1-n;return[...e,...Array(s).fill(r/s)]}return e.map(()=>1/t)},po=.001,Uf=e=>e.every(t=>u.nd.closeTo(t,1/e.length),po)?e.map((t,n)=>n%2===0?t+po:n===e.length-1?t:t-po):e,mo=(e,t,n,s,r,i)=>{const l=_l(e,t,n,r,i),[c,a]=Jf(e.sizeDistribution,n,l,s/t),d=a?r??null:e.root;return{...e,sizeDistribution:c,root:d}},_l=(e,t,n,s,r)=>{let i;if(r!=null)r>1&&(r/=t),i=r-e.sizeDistribution[n];else if(s!=null){if(e.root===null)throw new Error("resize root is null during handle drag");i=(s-e.root)/t}else throw new Error("must provide either a MouseEvent or a targetSize");return i},Jf=(e,t,n,s)=>{let r=t;for(;r>0&&e[r]+n<=s;)r--;const i=e[r]+n,l=Qf(r,e,s,n),c=e[l]-n;return i<s||c<s?[e,!1]:[e.map((a,d)=>d===r?i:d===l?c:a),!0]},Qf=(e,t,n,s)=>(e===t.length-1?th:eh)(e,t,n,s),eh=(e,t,n,s)=>{let r=e+1;for(;r<t.length-1&&t[r]-s<=n;)r++;return r},th=(e,t,n,s)=>{let r=e-1;for(;r>0&&t[r]-s<=n;)r--;return r},fo=2,nh=100,Ll=({onCollapse:e,onResize:t,location:n="left",minSize:s,maxSize:r,initialSize:i=200,collapseThreshold:l=1/0,className:c,...a})=>{const[d,x]=g.useState(u.D$1(i,s,r)),p=g.useRef(null),m=u.K$1.construct(n),f=g.useCallback(E=>{if(p.current===null)return 0;const R=u.Pt.dim(E,u.K$1.direction(m),!0)*(1-2*Number(["bottom","right"].includes(m))),M=p.current+R,_=u.D$1(M,s,r);return(_-M)/(s??nh)>l?fo:_},[m,s,r,l]),h=g.useRef(null),j=g.useCallback(E=>{const R=f(E);x(R),h.current!=null&&(t==null||t(R,u.Pt.construct(h.current)))},[t,f]),y=g.useCallback(()=>x(E=>(p.current=E,E)),[x]),S=g.useCallback(E=>f(E)===fo&&(e==null?void 0:e()),[e,f]);g.useEffect(()=>{s==null||r==null||x(E=>{const R=u.D$1(E,s,r);return p.current=R,R})},[s,r]);const b=Ge.useCursorDrag({onMove:j,onStart:y,onEnd:S});return o.jsxRuntimeExports.jsx(nr,{ref:h,location:m,size:d,onDragStart:b,className:u.clsx(c,u.CSS.expanded(d!==fo)),...a})},sh=Object.freeze(Object.defineProperty({__proto__:null,Core:nr,Multiple:or,Single:Ll,calculateDiffPercentage:_l,useMultiple:sr},Symbol.toStringTag,{value:"Module"})),rs="y",ri=28,oh=32,rh=40,ih=.5,lh=({data:e,...t})=>{const{setSize:n,props:{sizeDistribution:s,ref:r,...i}}=sr({direction:rs,count:e.length,minSize:ri}),l=c=>{if(r.current==null)return;const a=u.Pt.dim(u.Pt.construct(r.current),rs);s[c]<rh/a?n(c,e[c].initialSize??ih):n(c,ri+1)};return o.jsxRuntimeExports.jsx(or,{empty:!0,className:u.CSS.B("accordion"),sizeDistribution:s,ref:r,...t,...i,children:e.map((c,a)=>g.createElement(uh,{...c,key:c.key,index:a,direction:rs,onExpand:l,parent:r,size:s[a]}))})},ch=o.jsxRuntimeExports.jsx(K.y4.Caret.Down,{"aria-label":"contract"}),ah=o.jsxRuntimeExports.jsx(K.y4.Caret.Right,{"aria-label":"expand"}),uh=({index:e,name:t,content:n,actions:s,size:r,parent:i,onExpand:l})=>{let c=!0;if(i.current!=null){const d=u.Pt.dim(u.Pt.construct(i.current),rs);c=r*d>oh}const a=c?ch:ah;return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsxs(os.Header,{level:"p",className:u.CSS.expanded(c),empty:!0,children:[o.jsxRuntimeExports.jsx(os.ButtonTitle,{startIcon:a,onClick:()=>l(e),children:t}),s!=null&&o.jsxRuntimeExports.jsx(os.Actions,{children:s})]}),n]})},dh=Object.freeze(Object.defineProperty({__proto__:null,Accordion:lh},Symbol.toStringTag,{value:"Module"})),xh=(e,t)=>Pe.t.toArray(e).map(s=>typeof s=="string"?s.split(t).map(r=>({label:r})):s).flat(),Nl=({segments:e,shade:t,level:n,weight:s,separator:r,transform:i})=>{let c=xh(e,r);return i!=null&&(c=c.map(i)),c.map(({label:a,icon:d,href:x,...p},m)=>{const f=[o.jsxRuntimeExports.jsx(K.y4.Caret.Right,{style:{transform:"scale(0.8) translateY(0.5px)",color:u.CSS.shade(t)}},`${a}-${m}`)];if(d!=null){const j=Te.resolve(d);j!=null&&f.push(j)}const h={weight:s,shade:t,level:n,style:{marginLeft:d!=null?"0.5rem":"0"},children:a,...p};return x!=null?f.push(o.jsxRuntimeExports.jsx(bl.Link,{...h,href:x},a)):f.push(o.jsxRuntimeExports.jsx(K.Text,{...h},a)),f}).flat()},Tl=({children:e,icon:t,shade:n=9,weight:s,size:r=.5,url:i,level:l="p",separator:c=".",className:a,hideFirst:d=!0,...x})=>{i!=null&&(e=i);const p=Nl({segments:e,separator:c,shade:n,level:l,weight:s});return d&&p.shift(),o.jsxRuntimeExports.jsxs(As.WithIcon,{className:u.CSS(a,u.CSS.B("breadcrumb"),d&&u.CSS.M("hide-first")),level:l,shade:n,weight:s,size:r,x:!0,...x,children:[Te.resolve(t),...p]})},ph=({url:e,className:t,level:n="p",separator:s="/",weight:r,shade:i=9})=>{const l=Nl({segments:e,separator:s,shade:i,level:n,weight:r,transform:(c,a)=>({...c,label:c.label.split("-").map(d=>u.d$1.capitalize(d)).join(" "),href:`/${e.split(s).slice(0,a+1).join("/")}`})});return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(t,u.CSS.B("breadcrumb"),u.CSS.BM("breadcrumb","url")),x:!0,size:"small",align:"center",children:l})},mh=Object.freeze(Object.defineProperty({__proto__:null,Breadcrumb:Tl,URL:ph},Symbol.toStringTag,{value:"Module"})),Al=({variant:e="info",...t})=>e==="loading"?o.jsxRuntimeExports.jsx(K.y4.Loading,{...t}):o.jsxRuntimeExports.jsx(K.y4.Circle,{color:Ce.VARIANT_COLORS[e],...t}),fh=({action:e})=>g.isValidElement(e)?e:g.createElement(fe.Button,{...e,key:e.key}),hh=({status:{key:e,time:t,count:n,message:s,description:r,variant:i},silence:l,actions:c,className:a,children:d,...x})=>{const p=g.useRef(null);return o.jsxRuntimeExports.jsxs(ne.Space,{className:u.CSS(u.CSS.B("notification"),a),y:!0,empty:!0,ref:p,...x,children:[o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,justify:"spaceBetween",grow:!0,style:{width:"100%"},children:[o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(Al,{style:{height:"2.25rem",width:"2.5rem"},variant:i}),o.jsxRuntimeExports.jsx(K.Text,{level:"small",shade:11,children:`x${n}`}),o.jsxRuntimeExports.jsx(_o.DateTime,{className:u.CSS(u.CSS.BE("notification","time")),level:"small",format:"time",children:t})]}),o.jsxRuntimeExports.jsx(fe.Icon,{className:u.CSS(u.CSS.BE("notification","silence")),variant:"outlined",size:"small",onClick:()=>l(e),children:o.jsxRuntimeExports.jsx(K.y4.Close,{})})]}),o.jsxRuntimeExports.jsxs(ne.Space,{y:!0,align:"start",className:u.CSS(u.CSS.BE("notification","content")),size:"small",children:[d??o.jsxRuntimeExports.jsx(K.Text,{className:u.CSS(u.CSS.BE("notification","message")),level:"p",style:{flexGrow:1},children:s}),r!=null&&o.jsxRuntimeExports.jsx(K.Text,{className:u.CSS(u.CSS.BE("notification","description")),level:"small",style:{flexGrow:1},children:r})]}),c!=null&&o.jsxRuntimeExports.jsx(ne.Space,{x:!0,align:"center",justify:"end",className:u.CSS(u.CSS.BE("notification","actions")),children:Pe.t.toArray(c).map(m=>o.jsxRuntimeExports.jsx(fh,{action:m},m.key))})]},t.toString())},gh=Object.freeze(Object.defineProperty({__proto__:null,Aggregator:Ce.Aggregator,Indicator:Al,Notification:hh,Text:Ce.Text,VARIANT_COLORS:Ce.VARIANT_COLORS,specZ:bt.specZ,useAdder:Ce.useAdder,useErrorHandler:Ce.useErrorHandler,useNotifications:Ce.useNotifications},Symbol.toStringTag,{value:"Module"})),rr=({aetherKey:e,enabled:t=!0})=>{const{setState:n}=Q.useLifecycle({aetherKey:e,type:ps.Eraser.TYPE,schema:ps.eraserStateZ,initialState:{region:u.Pt.ZERO,enabled:t}}),s=K.useSyncedRef(t);return{erase:g.useCallback(i=>{n({enabled:s.current,region:i})},[n,s])}},jh=({aetherKey:e,children:t})=>{const{erase:n}=rr({aetherKey:e}),s=Ye.useResize(n);return o.jsxRuntimeExports.jsx("div",{ref:s,className:u.CSS(u.CSS.inheritDims()),children:t})},Eh=Object.freeze(Object.defineProperty({__proto__:null,Eraser:jh,use:rr},Symbol.toStringTag,{value:"Module"})),yh=({items:e,initialKey:t})=>{const[n,s]=g.useState(t),r=l=>s(l===n?void 0:l),i=e.find(l=>l.key===n);return{onSelect:r,activeItem:i}},Sh=({activeItem:e,children:t,onSelect:n,location:s="left",collapseThreshold:r=.65,className:i,onResize:l,onCollapse:c,eraseEnabled:a,...d})=>{const x=u.K$1.direction(s);a??(a=e!=null);const p=g.useCallback(()=>{c?c():e!=null&&(n==null||n(e.key))},[n,e==null?void 0:e.key,c]),{erase:m}=rr({enabled:a}),f=g.useCallback((b,E)=>{l==null||l(b,E),m(E)},[l,m]),{content:h,minSize:j,maxSize:y,initialSize:S=0}=e??{};return o.jsxRuntimeExports.jsx(Ll,{className:u.CSS(u.CSS.B("nav-drawer"),u.CSS.dir(x),u.CSS.visible(e!=null),i),collapseThreshold:r,onCollapse:p,location:s,onResize:f,minSize:j,maxSize:y,initialSize:S,...d,children:h})},Rh=Object.freeze(Object.defineProperty({__proto__:null,Bar:he.Bar,Drawer:Sh,useDrawer:yh},Symbol.toStringTag,{value:"Module"})),is={...B.ZERO_CONTEXT_VALUE,state:bt.gF.connectivity.DEFAULT},Il=g.createContext(is),$l=()=>g.use(Il),qe=()=>$l().client,Ch=()=>$l().state,Lo={connected:"success",connecting:"loading",disconnected:"info",failed:"error"},Bl="serverVersionMismatch",wh=(e,t,n)=>`Cluster version ${n!=null?`${n} `:""}is ${e?"older":"newer"} than client version ${t}. Compatibility issues may arise.`,Dl=({children:e,connParams:t})=>{const[n,s,r]=K.useCombinedStateAndRef(is),{path:i}=Q.useUnidirectional({type:B.Provider.TYPE,schema:B.Provider.stateZ,state:{props:t??null,state:null}}),l=Ce.useAdder(),c=g.useCallback(a=>{r.current.state.status!==a.status&&l({variant:Lo[a.status],message:a.message??u.d$1.capitalize(a.status)}),s(d=>({...d,state:a}))},[l]);return Q.useAsyncEffect(async()=>{if(n.client!=null&&n.client.close(),t==null)return s(is);const a=new bt.gF({...t,connectivityPollFrequency:bt.M.seconds(2)});s({client:a,state:{clusterKey:"",status:"connecting",message:"Connecting...",clientServerCompatible:!1,clientVersion:a.clientVersion}});const d=await a.connectivity.check();if(s({client:a,state:d}),l({variant:Lo[d.status],message:d.message??d.status.toUpperCase()}),d.status==="connected"&&!d.clientServerCompatible){const x=d.nodeVersion==null||u.dd.semVerOlder(d.nodeVersion,d.clientVersion),p=wh(x,d.clientVersion,d.nodeVersion);l({variant:"warning",message:"Incompatible cluster version",description:p,data:{type:Bl,oldServer:x,nodeVersion:d.nodeVersion,clientVersion:d.clientVersion}})}return a.connectivity.onChange(c),()=>{a.close(),s(is)}},[t,c]),o.jsxRuntimeExports.jsx(Il,{value:n,children:o.jsxRuntimeExports.jsx(Q.Composite,{path:i,children:e})})},bh=Object.freeze(Object.defineProperty({__proto__:null,CONNECTION_STATE_VARIANTS:Lo,Provider:Dl,SERVER_VERSION_MISMATCH:Bl,use:qe,useConnectionState:Ch},Symbol.toStringTag,{value:"Module"})),Ol=g.createContext({aliases:{},getName:async()=>await Promise.resolve(void 0),setAlias:null}),cn=()=>g.use(Ol),zl=e=>cn().aliases[e]??null,$s=()=>cn().aliases,Bs=(e,t="")=>{const{getName:n}=cn(),[s,r]=g.useState(t);return Q.useAsyncEffect(async()=>{const i=await n(e);r(i)},[e,n]),s??t},ir=()=>cn().activeRange??void 0,Vl=({activeRange:e,children:t})=>{const n=qe(),[s,r]=g.useState({}),i=g.useCallback(a=>{r(d=>{const x={...d};return a.forEach(({variant:p,key:m,value:f})=>{const h=Number(m.split("---")[1]);p==="delete"?delete x[h]:x[f.channel]=f.alias}),x})},[r]),l=g.useCallback(async(a,d)=>{if(n==null||e==null)return;await(await n.ranges.retrieve(e)).setAlias(a,d)},[n,e]),c=g.useCallback(async a=>{if(n==null||a===0)return;const d=s[a];return d??(await n.channels.retrieve(a)).name},[s,n]);return Q.useAsyncEffect(async()=>{if(n==null||e==null){r({});return}const a=await n.ranges.retrieve(e),d=await a.listAliases();r(d);const x=await a.openAliasTracker(),p=x.onChange(i);return()=>{p(),x.close()}},[n,e]),o.jsxRuntimeExports.jsx(Ol,{value:{aliases:s,activeRange:e,setAlias:e!=null?l:null,getName:c},children:t})},vh=({channelKey:e,value:t,shadow:n,className:s,...r})=>{const[i,l]=g.useState(!1),{setAlias:c}=cn(),a=zl(e),d=Bs(e);let x=o.jsxRuntimeExports.jsx(K.y4.Rename,{});i?x=o.jsxRuntimeExports.jsx(K.y4.Loading,{}):a===t&&(x=o.jsxRuntimeExports.jsx(K.y4.Check,{}));const p=c!=null&&!i&&a!==t&&e!==0,m=Ce.useErrorHandler(),f=()=>{p&&m(async()=>{l(!0),await c(e,t),l(!1)},"Failed to set channel alias")},h=()=>{var y;a!=null&&((y=r.onChange)==null||y.call(r,a))},j=()=>e===0?o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:"Select a channel to enable alias syncing with this label"}):c==null?o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:"Select a range to enable alias syncing with this label"}):t.length===0?o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:"Enter a value to enable alias syncing with this label"}):a===t?o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:"Alias synced with this label"}):o.jsxRuntimeExports.jsxs(K.Text,{level:"small",children:["Sync alias for ",d," with this label"]});return o.jsxRuntimeExports.jsxs(pt.Text,{value:t,...r,children:[p&&o.jsxRuntimeExports.jsx(fe.Icon,{onClick:h,tooltip:o.jsxRuntimeExports.jsxs(K.Text,{level:"small",children:["Set ",d," as label"]}),tooltipLocation:{y:"top"},variant:"outlined",children:o.jsxRuntimeExports.jsx(K.y4.Sync,{})}),o.jsxRuntimeExports.jsx(fe.Icon,{onClick:f,disabled:!p,tooltip:o.jsxRuntimeExports.jsx(j,{}),tooltipLocation:{y:"top"},variant:"outlined",children:x})]})},nt="channel";var ii=180/Math.PI,No={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fl(e,t,n,s,r,i){var l,c,a;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(a=e*n+t*s)&&(n-=e*a,s-=t*a),(c=Math.sqrt(n*n+s*s))&&(n/=c,s/=c,a/=c),e*s<t*n&&(e=-e,t=-t,a=-a,l=-l),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ii,skewX:Math.atan(a)*ii,scaleX:l,scaleY:c}}var Gn;function kh(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?No:Fl(t.a,t.b,t.c,t.d,t.e,t.f)}function Mh(e){return e==null||(Gn||(Gn=document.createElementNS("http://www.w3.org/2000/svg","g")),Gn.setAttribute("transform",e),!(e=Gn.transform.baseVal.consolidate()))?No:(e=e.matrix,Fl(e.a,e.b,e.c,e.d,e.e,e.f))}function Hl(e,t,n,s){function r(d){return d.length?d.pop()+" ":""}function i(d,x,p,m,f,h){if(d!==p||x!==m){var j=f.push("translate(",null,t,null,n);h.push({i:j-4,x:B.interpolateNumber(d,p)},{i:j-2,x:B.interpolateNumber(x,m)})}else(p||m)&&f.push("translate("+p+t+m+n)}function l(d,x,p,m){d!==x?(d-x>180?x+=360:x-d>180&&(d+=360),m.push({i:p.push(r(p)+"rotate(",null,s)-2,x:B.interpolateNumber(d,x)})):x&&p.push(r(p)+"rotate("+x+s)}function c(d,x,p,m){d!==x?m.push({i:p.push(r(p)+"skewX(",null,s)-2,x:B.interpolateNumber(d,x)}):x&&p.push(r(p)+"skewX("+x+s)}function a(d,x,p,m,f,h){if(d!==p||x!==m){var j=f.push(r(f)+"scale(",null,",",null,")");h.push({i:j-4,x:B.interpolateNumber(d,p)},{i:j-2,x:B.interpolateNumber(x,m)})}else(p!==1||m!==1)&&f.push(r(f)+"scale("+p+","+m+")")}return function(d,x){var p=[],m=[];return d=e(d),x=e(x),i(d.translateX,d.translateY,x.translateX,x.translateY,p,m),l(d.rotate,x.rotate,p,m),c(d.skewX,x.skewX,p,m),a(d.scaleX,d.scaleY,x.scaleX,x.scaleY,p,m),d=x=null,function(f){for(var h=-1,j=m.length,y;++h<j;)p[(y=m[h]).i]=y.x(f);return p.join("")}}}var Ph=Hl(kh,"px, ","px)","deg)"),_h=Hl(Mh,", ",")",")"),Lh=1e-12;function li(e){return((e=Math.exp(e))+1/e)/2}function Nh(e){return((e=Math.exp(e))-1/e)/2}function Th(e){return((e=Math.exp(2*e))-1)/(e+1)}const ls=function e(t,n,s){function r(i,l){var c=i[0],a=i[1],d=i[2],x=l[0],p=l[1],m=l[2],f=x-c,h=p-a,j=f*f+h*h,y,S;if(j<Lh)S=Math.log(m/d)/t,y=function(L){return[c+L*f,a+L*h,d*Math.exp(t*L*S)]};else{var b=Math.sqrt(j),E=(m*m-d*d+s*j)/(2*d*n*b),R=(m*m-d*d-s*j)/(2*m*n*b),M=Math.log(Math.sqrt(E*E+1)-E),_=Math.log(Math.sqrt(R*R+1)-R);S=(_-M)/t,y=function(L){var A=L*S,$=li(M),O=d/(n*b)*($*Th(t*A+M)-Nh(M));return[c+O*f,a+O*h,d*$/li(t*A+M)]}}return y.duration=S*1e3*t/Math.SQRT2,y}return r.rho=function(i){var l=Math.max(.001,+i),c=l*l,a=c*c;return e(l,c,a)},r}(Math.SQRT2,2,4),Ah=Object.freeze(Object.defineProperty({__proto__:null,Base:B.Base,Bottom:B.Bottom,Right:B.Right,Top:B.Top,axisStateZ:B.axisStateZ,newCanvas:B.newCanvas,newTickFactory:B.newTickFactory,tickFactoryProps:B.tickFactoryProps,tickType:B.tickType},Symbol.toStringTag,{value:"Module"})),Ih={region:u.Pt.ZERO,dpr:1,os:u.S.getOS()},$h={gl:null,lower2d:null,upper2d:null,bootstrapped:!1},Bh=({children:e,resizeDebounce:t=100,className:n,...s})=>{const[{path:r},{bootstrapped:i,dpr:l},c]=Q.use$1({type:B.Canvas.TYPE,schema:B.canvasStateZ,initialState:Ih}),a=g.useRef({...$h}),d=g.useRef(!1),x=g.useCallback(j=>{a.current.bootstrapped&&(c(()=>({bootstrapped:!0,region:j,dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})})),d.current=!0)},[c]),p=g.useRef(null),m=Ye.useResize(x,{debounce:t}),f=K.useCombinedRefs(p,m);g.useEffect(()=>{const j=()=>{window.devicePixelRatio===l||!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.Pt.construct(p.current),dpr:window.devicePixelRatio}))};window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`).addEventListener("change",j,{once:!0})},[l]),g.useEffect(()=>{const j=()=>{!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.Pt.construct(p.current),glCanvas:void 0,upper2dCanvas:void 0,lower2dCanvas:void 0}))};window.addEventListener("focus",j),window.addEventListener("blur",j)},[c]);const h=g.useCallback(j=>{if(j==null)return;j.className.includes("gl")?a.current.gl=j:j.className.includes("upper2d")?a.current.upper2d=j:a.current.lower2d=j;const{gl:y,lower2d:S,upper2d:b,bootstrapped:E}=a.current;if(y==null||S==null||b==null||E)return;a.current.bootstrapped=!0;const R=y.transferControlToOffscreen(),M=b.transferControlToOffscreen(),_=S.transferControlToOffscreen();c({glCanvas:R,upper2dCanvas:M,lower2dCanvas:_,bootstrap:!0,bootstrapped:!1,region:u.Pt.construct(y),dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})},[R,M,_])},[c]);return o.jsxRuntimeExports.jsxs("div",{ref:f,className:u.CSS(u.CSS.B("canvas-container"),n),...s,children:[o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","lower2d"))}),o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","gl"))}),o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","upper2d"))}),o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:i&&e})]})},In=(e,t)=>Ye.useResize(g.useCallback((n,s)=>{const r=document.querySelector(".pluto-canvas--lower2d");r!=null&&e(u.A.XY.translate(u.K.scale(u.Pt.topLeft(r),-1)).box(n),s)},[e]),t),Dh=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Bh,useRegion:In},Symbol.toStringTag,{value:"Module"})),Zl=g.createContext(null),st=e=>{const t=g.use(Zl);if(t==null)throw new Error(`Cannot to use ${e} as a non-child of LinePlot.`);return t},Kl=e=>{const t=st("Viewport"),{addViewportHandler:n}=t;g.useEffect(()=>n(e),[n,e])},$n=(e,t)=>{const{setGridEntry:n,removeGridEntry:s}=st(t),{key:r}=e;return Q.useEffectCompare(()=>{u.K$1.outer.parse(e.loc),n(e)},([c],[a])=>Be.J.equal(c,a),[e]),g.useEffect(()=>()=>s(r),[]),{gridArea:u.g.swap(u.K$1.direction(e.loc))==="x"?`axis-start-${r} / plot-start / axis-end-${r} / plot-end`:`plot-start / axis-start-${r} / plot-end / axis-end-${r}`}},Wl=({aetherKey:e,style:t,resizeDebounce:n=0,clearOverScan:s=u.K.ZERO,children:r,hold:i=!1,onHold:l,visible:c,...a})=>{const[d,x]=g.useState([]),p=Ae.useMemoDeepEqualProps({clearOverScan:s,hold:i,visible:c}),[{path:m},{grid:f},h]=Q.use$1({aetherKey:e,type:B.LinePlot.TYPE,schema:B.linePlotStateZ,initialState:{container:u.Pt.ZERO,viewport:u.Pt.DECIMAL,grid:{},...p}}),j=g.useCallback(z=>{c&&h(k=>({...k,container:z}))},[h,c]),y=In(j,{debounce:n});g.useEffect(()=>h(z=>({...z,...p})),[p]);const S=g.useRef(new Map),b=g.useCallback(z=>(S.current.set(z,null),()=>S.current.delete(z)),[S]),E=g.useCallback(z=>{const{mode:k,box:C,stage:P}=z;(k==="pan"&&P!=="start"||k==="zoom"||k==="zoomReset"&&P==="start")&&h(v=>({...v,viewport:C})),S.current.forEach((v,N)=>N(z))},[h]),R=g.useCallback(z=>{h(k=>({...k,grid:{...k.grid,[z.key]:z}}))},[h]),M=g.useCallback(z=>h(k=>{const{[z]:C,...P}=k.grid;return{...k,grid:P}}),[h]),_=g.useCallback(z=>{x(k=>[...k.filter(({key:C})=>C!==z.key),z])},[x]),L=g.useCallback(z=>x(k=>k.filter(({key:C})=>C!==z)),[_]),A=g.useMemo(()=>Oh(f),[f]),$=g.useCallback(z=>{h(k=>({...k,hold:z})),l==null||l(z)},[h,l]),O=`line-plot-${e}`,V=g.useMemo(()=>({lines:d,setGridEntry:R,removeGridEntry:M,setLine:_,removeLine:L,setViewport:E,addViewportHandler:b,setHold:$,id:O}),[O,d,R,M,_,L,E,b,$]);return o.jsxRuntimeExports.jsx("div",{id:O,className:u.CSS.B("line-plot"),style:{...t,...A},ref:y,...a,children:o.jsxRuntimeExports.jsx(Zl,{value:V,children:o.jsxRuntimeExports.jsx(Q.Composite,{path:m,children:r})})})},Oh=e=>{const t=u.CSS.newGridBuilder();return B.regions("top",e).forEach(({key:n,size:s})=>t.row(`axis-start-${n}`,`axis-end-${n}`,s)),t.row("plot-start","plot-end","minmax(0, 1fr)"),B.regions("bottom",e).reverse().forEach(({key:n,size:s})=>t.row(`axis-start-${n}`,`axis-end-${n}`,s)),B.regions("left",e).forEach(({key:n,size:s})=>t.col(`axis-start-${n}`,`axis-end-${n}`,s)),t.col("plot-start","plot-end","minmax(0, 1fr)"),B.regions("right",e).forEach(({key:n,size:s})=>t.col(`axis-start-${n}`,`axis-end-${n}`,s)),t.build()},lr=e=>{const t=e==="x"?"bottom":"left",n=e==="x"?B.XAxis.TYPE:B.YAxis.TYPE,s=`${e}-axis`,r=({aetherKey:i,children:l,location:c=t,label:a="",labelLevel:d="small",labelDirection:x=e,onLabelChange:p,color:m,labelSize:f,showGrid:h,type:j,bounds:y,className:S,tickSpacing:b,autoBounds:E,axisKey:R,autoBoundUpdateInterval:M,onAutoBoundsChange:_,style:L,...A})=>{const $=((a==null?void 0:a.length)??0)>0,O=Q.useUniqueKey(i),V=Ae.useMemoDeepEqualProps({location:c,showGrid:h,type:j,bounds:y,axisKey:R,label:a,labelDirection:x,tickSpacing:b,autoBounds:E,autoBoundUpdateInterval:M}),[{path:z},{size:k,labelSize:C,...P},v]=Q.use$1({aetherKey:O,type:n,schema:B.coreAxisStateZ,initialState:V});g.useEffect(()=>v(F=>({...F,...V})),[V]),g.useEffect(()=>{const{lower:F,upper:H}=B.parseAutoBounds(P.autoBounds);P.bounds!=null&&(F&&(y==null?void 0:y.lower)!==P.bounds.lower||H&&(y==null?void 0:y.upper)!==P.bounds.upper)&&(_==null||_(P.bounds))},[P.autoBounds,P.bounds]);const N=$n({loc:c,key:`${n}-${O}`,size:k+C,order:1},`${e.toUpperCase()}Axis`),D=er.useTypography(d).toString(),I=g.useRef(0);return g.useEffect(()=>{if(e==="y"){if(a==null)return;let H=si.dimensions(a,D)[u.g.dimension(u.g.construct(x))];H>0&&(H+=9),v(Z=>({...Z,labelSize:H}))}else{let H=si.dimensions(a,D).height*1.3;H>0&&(H+=12);const Z=I.current;B.withinSizeThreshold(Z,H)||(I.current=H,v(ee=>({...ee,labelSize:H})))}},[a,x,D]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(S,u.CSS.B("axis"),u.CSS.B(s),u.CSS.loc(c)),style:{...L,...N},align:"center",justify:c!=="left"?"end":"start",direction:u.g.swap(e),...A,children:$&&o.jsxRuntimeExports.jsx(K.MaybeEditable,{className:u.CSS(u.CSS.BE("axis","label"),u.CSS.dir(x)),value:a,onChange:p,level:d})}),o.jsxRuntimeExports.jsx(Q.Composite,{path:z,children:l})]})};return r.displayName=`${e.toUpperCase()}Axis`,r},Yl=lr("x"),Gl=lr("y"),ql=u.K.xy.extend({root:u.K$1.corner,units:ce.object({x:ce._enum(["px","decimal"]),y:ce._enum(["px","decimal"])})}),zh=ql.partial({root:!0,units:!0}),Vh=e=>{var n,s,r,i;const t={};return t[((n=e.root)==null?void 0:n.x)??"left"]=((s=e==null?void 0:e.units)==null?void 0:s.x)==="px"?`${e.x}px`:`${e.x*100}%`,t[((r=e.root)==null?void 0:r.y)??"top"]=((i=e==null?void 0:e.units)==null?void 0:i.y)==="px"?`${e.y}px`:`${e.y*100}%`,t},Fh=(e,t)=>{var i,l,c,a,d,x;const n={x:e.x,y:e.y};if(t.current==null)return n;const s=u.Pt.construct(t.current),r=u.Pt.construct(t.current.parentElement);return((i=e.units)==null?void 0:i.x)==="decimal"?((l=e.root)==null?void 0:l.x)==="right"&&(n.x=1-e.x):((c=e.root)==null?void 0:c.x)==="right"?n.x=1-(e.x+u.Pt.width(s))/u.Pt.width(r):n.x/=u.Pt.width(r),((a=e.units)==null?void 0:a.y)==="decimal"?((d=e.root)==null?void 0:d.y)==="bottom"&&(n.y=1-e.y):((x=e.root)==null?void 0:x.y)==="bottom"?n.y=1-(e.y+u.Pt.height(s))/u.Pt.height(r):n.y/=u.Pt.height(r),n},Xl=(e,t)=>{if(t.current==null)return null;const n=u.Pt.construct(t.current.parentElement),s=u.Pt.construct(t.current),r={x:e.x,y:e.y,root:{...u.K$1.TOP_LEFT},units:{x:"px",y:"px"}};return e.x>.8?(r.x=(1-e.x)*u.Pt.width(n)-u.Pt.width(s),r.root.x="right"):e.x<.2?r.x=e.x*u.Pt.width(n):r.units.x="decimal",e.y>.8?(r.y=(1-e.y)*u.Pt.height(n)-u.Pt.height(s),r.root.y="bottom"):e.y<.2?r.y=e.y*u.Pt.height(n):r.units.y="decimal",r.x=Math.round(r.x*100)/100,{...r,...u.K.truncate(r,3)}},ci=u.Pt.reRoot(u.Pt.DECIMAL,u.K$1.TOP_LEFT),Hh={x:.1,y:.1,root:u.K$1.TOP_LEFT,units:{x:"decimal",y:"decimal"}},cr=g.memo(({className:e,value:t,onChange:n,style:s,draggable:r=!0,initial:i=Hh,...l})=>{const[c,a]=ce.usePurePassthrough({value:t,onChange:n,initial:i}),d=g.useRef(c),x=K.useSyncedRef(r===!1),p=g.useRef(null);c!==null&&(s={...s,...Vh(c)});const m=g.useCallback(h=>{var M;if(((M=p.current)==null?void 0:M.parentElement)==null)return d.current;const j=u.Pt.construct(p.current.parentElement),y=u.A.XY.scale(j).scale(ci),S=y.box(u.Pt.construct(p.current)),b=u.A.XY.clamp(u.Pt.construct(u.Pt.topLeft(ci),{width:1-u.Pt.width(S),height:1-u.Pt.height(S)})),E=u.K.translate(u.K.construct(d.current),u.Pt.signedDims(y.box(h))),R=b.pos(E);return Xl(R,p)},[]),f=Ge.useCursorDrag({onStart:g.useCallback(()=>{d.current=Fh(d.current,p)},[]),onMove:g.useCallback(h=>{if(x.current)return;const j=m(h);j!==null&&a(j)},[]),onEnd:g.useCallback(h=>{if(x.current)return;const j=m(h);j!==null&&(d.current=j)},[])});return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(e,u.CSS.B("legend")),bordered:!0,rounded:!0,style:s,onDragStart:f,draggable:r,borderShade:5,ref:p,onDrag:he.preventDefault,onDragEnd:he.preventDefault,background:1,...l})});cr.displayName="Legend.Container";const Ds=g.memo(({data:e,onEntryChange:t,onVisibleChange:n,allowVisibleChange:s=!0,shade:r=1})=>o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:e.sort((i,l)=>i.label.localeCompare(l.label)).map(({key:i,color:l,label:c,visible:a=!0})=>o.jsxRuntimeExports.jsxs(ne.Space,{style:{cursor:"pointer"},x:!0,align:"center",size:"small",justify:"spaceBetween",grow:!0,children:[o.jsxRuntimeExports.jsxs(ne.Space,{direction:"x",align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(Ge.Swatch,{value:l,onChange:d=>t==null?void 0:t({key:i,color:d,label:c,visible:a}),onVisibleChange:n,allowChange:t!=null,draggable:!1,size:"tiny"}),o.jsxRuntimeExports.jsx(K.MaybeEditable,{level:"small",value:c,onChange:d=>t==null?void 0:t({key:i,color:l,label:d,visible:a}),noWrap:!0,shade:a?10:7,onDoubleClick:d=>d.stopPropagation()})]}),s&&o.jsxRuntimeExports.jsx(fe.Icon,{className:u.CSS.B("visible-toggle"),onClick:d=>{d.stopPropagation(),t==null||t({key:i,color:l,label:c,visible:!a})},onDoubleClick:d=>d.stopPropagation(),size:"tiny",shade:r,children:a?o.jsxRuntimeExports.jsx(K.y4.Visible,{}):o.jsxRuntimeExports.jsx(K.y4.Hidden,{})})]},i))}));Ds.displayName="LegendSwatches";const ar=({data:e=[],onEntryChange:t,position:n,onPositionChange:s,allowVisibleChange:r=!0,...i})=>{const[l,c]=g.useState(!1);return e.length===0?null:o.jsxRuntimeExports.jsx(cr,{...i,className:r?u.CSS.M("with-visible-toggle"):void 0,draggable:!l,value:n,onChange:s,size:r?0:"tiny",children:o.jsxRuntimeExports.jsx(Ds,{data:e,onEntryChange:t,onVisibleChange:c,allowVisibleChange:r})})},Zh=Object.freeze(Object.defineProperty({__proto__:null,Container:cr,LegendSwatches:Ds,Simple:ar,calcStickyPos:Xl,completeStickyXYz:ql,stickyXYz:zh},Symbol.toStringTag,{value:"Module"})),ur=g.memo(({className:e,style:t,onLineChange:n,...s})=>{const{lines:r}=st("Legend");return st("Legend"),o.jsxRuntimeExports.jsx(ar,{data:r,onEntryChange:n,...s})});ur.displayName="FloatingLegend";const Kh=({onLineChange:e})=>{const{lines:t}=st("Legend"),n=Q.useUniqueKey(),s=$n({key:n,size:t.length>0?36:0,loc:"bottom",order:5},"Legend");return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS.BE("legend","container"),align:"center",x:!0,style:{...s,padding:"0 1rem",height:"var(--pluto-height-medium)",margin:"1rem 0 ",width:"fit-content"},children:o.jsxRuntimeExports.jsx(Ds,{data:t,onEntryChange:e,shade:0})})},Ul=({variant:e="floating",...t})=>e==="floating"?o.jsxRuntimeExports.jsx(ur,{...t}):o.jsxRuntimeExports.jsx(Kh,{...t}),dr=g.memo(({aetherKey:e,...t})=>(Q.useUnidirectional({aetherKey:e,type:B.Line.TYPE,schema:B.stateZ,state:t}),null));dr.displayName="Line";const Wh=Object.freeze(Object.defineProperty({__proto__:null,Line:dr},Symbol.toStringTag,{value:"Module"})),xr=({aetherKey:e,color:t,label:n="",visible:s=!0,...r})=>{const i=Q.useUniqueKey(e),{setLine:l,removeLine:c}=st("Line");return g.useEffect(()=>(l({key:i,color:t,label:n,visible:s}),()=>c(i)),[n,t,s]),o.jsxRuntimeExports.jsx(dr,{aetherKey:i,color:t,label:n,visible:s,...r})},Jl=({level:e="h2",...t})=>{const n=Q.useUniqueKey(),s=er.useTypography(e),r=$n({key:n,size:(s.lineHeight+2)*s.baseSize,loc:"top",order:10},"Title");return o.jsxRuntimeExports.jsx(ne.Space,{justify:"center",align:"center",style:r,children:o.jsxRuntimeExports.jsx(K.MaybeEditable,{...t,level:e})})},Ql=({aetherKey:e,...t})=>{const n=Q.useUniqueKey(e),[,,s]=Q.use$1({aetherKey:n,type:B.Tooltip.TYPE,schema:B.tooltipStateZ,initialState:{position:null,...t}}),r=g.useRef(null),i=g.useCallback(c=>{const a=document.querySelector(".pluto-canvas-container");if(a==null)return;const d=u.Pt.topLeft(a);s({position:u.K.translation(d,u.K.construct(c))})},[s]),l=g.useCallback(()=>s({position:null}),[s]);return g.useEffect(()=>{if(r.current===null)return;const c=r.current.parentElement;if(c!=null)return c.addEventListener("mousemove",i),c.addEventListener("mouseleave",l),()=>{c.removeEventListener("mousemove",i),c.removeEventListener("mouseleave",l)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:r})},Yh=Object.freeze(Object.defineProperty({__proto__:null,Tooltip:Ql},Symbol.toStringTag,{value:"Module"})),ec=()=>{const e=g.useRef(new Map),t=g.useCallback(s=>{const{request:r,response:i}=s,l=e.current.get(r);l!=null&&(l(i.bounds),e.current.delete(r))},[]),[,,n]=Q.use$1({type:B.BoundQuerier.TYPE,schema:B.boundQuerierStateZ,onAetherChange:t,initialState:{request:"",response:{request:"",bounds:{}}}});return g.useCallback(async()=>await new Promise(s=>{const r=u.we.create();e.current.set(r,s),n(i=>({...i,request:r}))}),[])},Gh=({ref:e})=>(e.current=ec(),null),qh={select:"pointer",zoom:"crosshair",pan:"grab",zoomReset:"crosshair",click:"pointer",cancel:"default"},tc=({className:e,mode:t,maskBox:n,children:s,style:r,...i})=>o.jsxRuntimeExports.jsxs("div",{className:u.CSS(u.CSS.noSelect,u.CSS.BE("viewport-mask","container"),e),style:{cursor:qh[t],...r},...i,children:[o.jsxRuntimeExports.jsx("div",{style:{...u.Pt.css(n),display:u.Pt.areaIsZero(n)?"none":"block"},className:u.CSS.BE("viewport-mask","selection")}),s]}),Xh=[],pr=({data:e,emptyContent:t,value:n,onChange:s,allowMultiple:r,allowNone:i,hideColumnHeader:l=!1,columns:c=Xh,visible:a,itemHeight:d=Ce.Column.itemHeight,listItem:x=fe.componentRenderProp(Ce.Column.Item),replaceOnSingle:p,omit:m,autoSelectOnNone:f,trigger:h,extraDialogContent:j,variant:y="connected",...S})=>{let b=o.jsxRuntimeExports.jsxs(Ce.Hover,{disabled:!a,children:[j,o.jsxRuntimeExports.jsx(Ce.Column.Header,{hide:l||x!=null,columns:c,children:o.jsxRuntimeExports.jsx(Ce.Core.Virtual,{itemHeight:d,children:x})})]});return y!=="connected"&&(b=o.jsxRuntimeExports.jsx(Is.Pack,{y:!0,className:u.CSS.B("select-dialog-content"),children:b})),o.jsxRuntimeExports.jsx(Ce.List,{data:e,emptyContent:t,omit:m,children:o.jsxRuntimeExports.jsx(Ce.Selector,{value:n,onChange:s,allowMultiple:r,allowNone:i,replaceOnSingle:p,autoSelectOnNone:f,children:o.jsxRuntimeExports.jsxs(Ye.Dialog,{visible:a,className:u.CSS.B("select"),keepMounted:!1,variant:y,...S,children:[h,b]})})})},ot=({children:e=Uh,value:t,onChange:n,entryRenderKey:s="key",tooltipKey:r,allowNone:i=!1,allowMultiple:l=!1,data:c,replaceOnSingle:a,className:d,size:x="medium",actions:p,pack:m=!0,variant:f,tooltipLocation:h,tooltipDelay:j,...y})=>{const{onSelect:S}=Ce.useSelect({allowMultiple:l,allowNone:i,replaceOnSingle:a,data:c,value:t,onChange:n}),b=R=>{f!=="preview"&&S(R)},E=c==null?void 0:c.map(R=>e({key:R.key,onClick:()=>b(R.key),size:x,selected:R.key===t,entry:R,title:R[s],tooltip:r?R[r]:void 0,tooltipLocation:h,tooltipDelay:j}));return m?o.jsxRuntimeExports.jsxs(Is.Pack,{borderShade:5,className:u.CSS(u.CSS.B("select-button"),d),size:x,...y,children:[E,p]}):o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:E})},Uh=({key:e,onClick:t,selected:n,title:s,size:r,tooltip:i,tooltipLocation:l,tooltipDelay:c})=>o.jsxRuntimeExports.jsx(fe.Button,{onClick:t,variant:n?"filled":"outlined",size:r,tooltip:i,tooltipLocation:l,tooltipDelay:c,children:s},e),nc=({selected:e,renderKey:t,toggle:n,visible:s,children:r,...i})=>o.jsxRuntimeExports.jsx(fe.Button,{className:u.CSS.B("select-dropdown-button"),onClick:n,variant:"outlined",endIcon:o.jsxRuntimeExports.jsx(An.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:s}),...i,children:r??(e==null?void 0:e[t])}),sc=fe.componentRenderProp(nc),Os=({data:e,value:t,columns:n=[],children:s=sc,entryRenderKey:r="key",allowNone:i=!1,onChange:l,disabled:c,hideColumnHeader:a=!0,variant:d,dropdownVariant:x,...p})=>{const{close:m,visible:f,toggle:h}=Ye.use(),[j,y]=g.useState((e==null?void 0:e.find(E=>E.key===t))??null);g.useEffect(()=>{y((e==null?void 0:e.find(E=>E.key===t))??null)},[e,t]);const S=g.useCallback((E,R)=>{if(!(Array.isArray(E)||E===null)){if(m(),E==null)return y(null),l(t);y(R.entries[0]),l(E)}},[l,t,m,y]),b={selected:j,renderKey:r,toggle:h,visible:f,disabled:c};return d!=null&&(b.variant=d),o.jsxRuntimeExports.jsx(pr,{close:m,data:e,visible:f,value:t,onChange:S,allowMultiple:!1,allowNone:i,columns:n,hideColumnHeader:a,variant:x,trigger:o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:s(b)}),...p})},Jh=[{key:"start",icon:o.jsxRuntimeExports.jsx(K.y4.TextAlign.Left,{})},{key:"center",icon:o.jsxRuntimeExports.jsx(K.y4.TextAlign.Center,{})},{key:"end",icon:o.jsxRuntimeExports.jsx(K.y4.TextAlign.Right,{})}],Qh=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(fe.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),zs=({children:e=Qh,...t})=>o.jsxRuntimeExports.jsx(ot,{...t,allowMultiple:!1,data:Jh,children:e}),e1=[{key:"large",label:"L"},{key:"medium",label:"M"},{key:"small",label:"S"}],oc=e=>o.jsxRuntimeExports.jsx(ot,{...e,data:e1,entryRenderKey:"label"}),t1=new Set([u.m.UUID,u.m.JSON]),rc=u.m.ALL.filter(e=>e!==u.m.UNKNOWN).map(e=>({key:e.toString(),name:t1.has(e)?e.toString().toUpperCase():u.d$1.capitalize(e.toString())})),n1=rc.filter(e=>!new u.m(e.key).isVariable),s1=[{key:"name",name:"Name"}],o1=({hideVariableDensity:e=!1,...t})=>o.jsxRuntimeExports.jsx(Os,{...t,data:e?n1:rc,columns:s1,entryRenderKey:"name"}),r1=[{key:"x",icon:o.jsxRuntimeExports.jsx(K.y4.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(K.y4.Arrow.Up,{})}],i1=[{key:"x",icon:o.jsxRuntimeExports.jsx(K.y4.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(K.y4.Arrow.Down,{})}],l1=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(fe.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),ic=({children:e=l1,yDirection:t="up",...n})=>o.jsxRuntimeExports.jsx(ot,{...n,allowMultiple:!1,data:t==="up"?r1:i1,children:e}),lc=e=>o.jsxRuntimeExports.jsx(fe.Icon,{className:u.CSS.BE("select","clear"),variant:"outlined",...e,children:o.jsxRuntimeExports.jsx(K.y4.Close,{"aria-label":"clear"})}),mt=({onChange:e,value:t,entryRenderKey:n="key",data:s,inputProps:r,allowNone:i=!0,searcher:l,className:c,variant:a="button",hideColumnHeader:d=!1,disabled:x,children:p,dropdownVariant:m="connected",placeholder:f=Vs,inputPlaceholder:h=f,triggerTooltip:j,dropdownZIndex:y,filter:S,actions:b,...E})=>{const{visible:R,open:M,close:_,toggle:L}=Ye.use(),[A,$]=g.useState(null),O=l!=null;Q.useAsyncEffect(async()=>{if(Ce.selectValueIsZero(t))return $(null);if((A==null?void 0:A.key)===t)return;let P=null;if(O)try{[P]=await l.retrieve([t])}finally{P??(P=null)}else s!=null&&(P=s.find(v=>v.key===t)??null);$(P)},[l,t,s]);const V=g.useCallback((P,v)=>{Array.isArray(P)||($(P==null?null:v.entries[0]),_(),e(P,v))},[e,i]),z=g.useMemo(()=>O?kt.Search:kt.Filter,[O]),k=o.jsxRuntimeExports.jsx(z,{searcher:l,filter:S,children:({onChange:P})=>o.jsxRuntimeExports.jsx(c1,{...r,autoFocus:m==="modal",variant:a,onChange:P,onFocus:M,selected:A,entryRenderKey:n,visible:R,allowNone:i,className:c,dropdownVariant:m,disabled:x,placeholder:h,children:b})}),C=o.jsxRuntimeExports.jsx(fe.Button,{tooltip:j,variant:"outlined",onClick:L,disabled:x,children:A!=null?cc(n,A):f});return o.jsxRuntimeExports.jsx(pr,{close:_,zIndex:y,data:s,allowMultiple:!1,visible:R,value:t,hideColumnHeader:d,onChange:V,allowNone:i,listItem:p,variant:m,trigger:m!=="modal"?k:C,extraDialogContent:m==="modal"?k:void 0,keepMounted:!1,...E})},Vs="Select",cc=(e,t)=>t==null?"":typeof e=="function"?e(t):t[e].toString(),c1=({entryRenderKey:e,selected:t,visible:n,onChange:s,onFocus:r,allowNone:i=!0,placeholder:l=Vs,className:c,disabled:a,dropdownVariant:d,children:x,...p})=>{const{clear:m}=Ce.useSelectionUtils(),[f,h]=g.useState("");g.useEffect(()=>{if(!n){if(u.G$1.isZero(t==null?void 0:t.key))return h("");t!=null&&h(cc(e,t))}},[t,n,e]);const j=R=>{s(R),h(R)},y=()=>{f===""&&s(""),h(""),r==null||r()},S=R=>{n||(R.preventDefault(),r==null||r())},b=()=>{h(""),m==null||m()};let E;return d!=="modal"&&(E=o.jsxRuntimeExports.jsx(An.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:n})),o.jsxRuntimeExports.jsxs(pt.Text,{className:u.CSS(u.CSS.BE("select","input"),c),value:f,onChange:j,onFocus:y,onKeyDown:De.matchCallback([["Enter"]],R=>{R.preventDefault(),!n&&(r==null||r())}),endContent:E,style:{flexGrow:1},onClick:S,placeholder:l,disabled:a,...p,children:[x,i&&o.jsxRuntimeExports.jsx(lc,{onClick:b,disabled:a})]})},wn=({children:e="",size:t="medium",color:n,icon:s,onClose:r,className:i,onDragStart:l,...c})=>{const a=u.od.cssString(n);s==null&&n!=null&&(s=o.jsxRuntimeExports.jsx(K.y4.Circle,{fill:a}));const d=r==null?void 0:o.jsxRuntimeExports.jsx(fe.Icon,{"aria-label":"close",size:"small",className:u.CSS.BE("tag","close"),shade:1,sharp:!0,onClick:x=>{x.stopPropagation(),r()},children:o.jsxRuntimeExports.jsx(K.y4.Close,{})});return o.jsxRuntimeExports.jsx(As.WithIcon,{startIcon:s,endIcon:d,className:u.CSS(i,u.CSS.B("tag"),u.CSS.size(t),r!=null&&u.CSS.BM("tag","closeable")),level:ce.ComponentSizeLevels[t],noWrap:!0,align:"center",size:"small",onDragStart:l,...c,children:e})},a1=Object.freeze(Object.defineProperty({__proto__:null,Tag:wn},Symbol.toStringTag,{value:"Module"})),mr=({entryKey:e,entryRenderKey:t,entry:n,loading:s,...r})=>{let i=e;return n!=null&&(i=typeof t=="function"?t(n):n[t]),g.createElement(wn,{size:"small",variant:"outlined",className:u.CSS(n==null&&!s&&u.CSS.BEM("select-multiple","tag","invalid")),draggable:!0,...r,key:e.toString()},u.fd(i))},u1=fe.componentRenderProp(mr),an=({onChange:e,value:t,className:n,data:s,columns:r=[],entryRenderKey:i="key",emptyContent:l,searcher:c,renderTag:a=u1,placeholder:d,onTagDragStart:x,allowMultiple:p,allowNone:m,replaceOnSingle:f,onTagDragEnd:h,style:j,addPlaceholder:y="Add",children:S,dropdownVariant:b="connected",actions:E,...R})=>{const{visible:M,open:_,close:L}=Ye.use(),[A,$]=g.useState([]),[O,V]=g.useState(!1),z=c!=null;Q.useAsyncEffect(async()=>{V(!0),Ce.selectValueIsZero(t)&&$([]);const N=A.map(F=>F.key),D=Pe.t.toArray(t);if(u.L.unorderedPrimitiveArrays(N,D)===u.L.EQUAL)return;let I=[];if(z)try{I=await c.retrieve(D)}finally{V(!1)}else s!=null&&(I=s.filter(F=>D.includes(F.key)));$(I)},[c,z,t,s]);const k=g.useCallback((N,D)=>{N!=null&&($(D.entries),e(Pe.t.toArray(N),D))},[e]),C=g.useMemo(()=>z?kt.Search:kt.Filter,[z]);let P,v;if(b==="connected")v=o.jsxRuntimeExports.jsx(C,{searcher:c,children:({onChange:N,value:D})=>o.jsxRuntimeExports.jsx(d1,{dropdownVariant:b,value:D,selectedKeys:t,className:n,onChange:N,loading:O,selected:A,onFocus:_,entryRenderKey:i,visible:M,renderTag:a,placeholder:d,onTagDragStart:x,onTagDragEnd:h,style:j,children:E})});else{const N=Pe.t.toArray(t);v=o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",grow:!0,style:j,size:"small",children:[N.map(D=>{const I=A.find(F=>F.key===D);return a({key:D,entryKey:D,entryRenderKey:i,loading:O,entry:I,onClose:()=>{const F=N.filter(H=>H!==D);e(F,{clicked:null,clickedIndex:-1,entries:[]})},onDragStart:F=>x==null?void 0:x(F,D),onDragEnd:F=>h==null?void 0:h(F,D)})}),N.length>0?o.jsxRuntimeExports.jsx(fe.Icon,{onClick:_,children:o.jsxRuntimeExports.jsx(K.y4.Add,{style:{color:"var(--pluto-gray-l9)"}})}):o.jsxRuntimeExports.jsx(fe.Button,{onClick:_,shade:0,textShade:9,startIcon:o.jsxRuntimeExports.jsx(K.y4.Add,{}),variant:"text",children:y})]}),P=o.jsxRuntimeExports.jsx(C,{searcher:c,children:D=>o.jsxRuntimeExports.jsx(pt.Text,{autoFocus:!0,placeholder:"Search",...D,children:E})})}return o.jsxRuntimeExports.jsx(pr,{close:L,data:s,emptyContent:l,visible:M,value:t,onChange:k,allowNone:m,replaceOnSingle:f,columns:r,allowMultiple:!0,listItem:S,trigger:v,extraDialogContent:P,variant:b,...R})},d1=({selectedKeys:e,loading:t,selected:n,onChange:s,onFocus:r,visible:i,entryRenderKey:l,renderTag:c,placeholder:a=Vs,onTagDragStart:d,onTagDragEnd:x,value:p,className:m,children:f,dropdownVariant:h,...j})=>{const{onSelect:y,clear:S}=Ce.useSelectionUtils(),b=g.useRef(null);g.useLayoutEffect(()=>{var L;i&&((L=b.current)==null||L.focus())},[i,n]);const E=()=>{i||s(""),r==null||r()},R=()=>{i||r==null||r()},M=()=>{i||s("")};let _;return h!=="modal"&&(_=o.jsxRuntimeExports.jsx(An.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:i})),o.jsxRuntimeExports.jsxs(pt.Text,{ref:b,className:u.CSS(u.CSS.BE("select-multiple","input"),u.CSS.visible(i),m),onBlur:M,placeholder:a,value:p,onChange:s,onFocus:E,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",onClick:R,endContent:_,variant:"button",...j,children:[o.jsxRuntimeExports.jsx(ne.Space,{x:!0,className:u.CSS.BE("select-multiple","tags"),align:"center",grow:!0,size:"small",children:Pe.t.toArray(e).map(L=>{const A=n.find($=>$.key===L);return c({key:L,entryKey:L,entryRenderKey:l,loading:t,entry:A,onClose:()=>y==null?void 0:y(L),onDragStart:$=>d==null?void 0:d($,L),onDragEnd:$=>x==null?void 0:x($,L)})})}),f,o.jsxRuntimeExports.jsx(lc,{onClick:S})]})},x1=[{key:"h2",label:"XL"},{key:"h3",label:"L"},{key:"h4",label:"M"},{key:"h5",label:"S"},{key:"small",label:"XS"}],un=e=>o.jsxRuntimeExports.jsx(ot,{...e,data:x1,entryRenderKey:"label"}),p1=[{key:600,label:"Bold"},{key:500,label:"Medium"},{key:400,label:"Normal"},{key:250,label:"Light"}],ac=e=>o.jsxRuntimeExports.jsx(ot,{...e,data:p1,entryRenderKey:"label"}),m1=Object.freeze(Object.defineProperty({__proto__:null,Level:un,Weight:ac},Symbol.toStringTag,{value:"Module"})),f1=Object.freeze(Object.defineProperty({__proto__:null,BaseButton:nc,Button:ot,ComponentSize:oc,DEFAULT_PLACEHOLDER:Vs,DataType:o1,Direction:ic,DropdownButton:Os,Multiple:an,MultipleTag:mr,Single:mt,Text:m1,TextAlignment:zs,defaultButton:sc},Symbol.toStringTag,{value:"Module"})),h1=11,g1=6,j1=2,ai=5,E1=e=>u.Pt.width(e)<ai&&u.Pt.height(e)<ai,gn=e=>{const t=u.Pt.width(e),n=u.Pt.height(e);return Math.min(t,n)<.001?h1:g1},y1=["zoom","pan","select","zoomReset","cancel"],Sn=[...y1,"click"],S1=ce._enum(Sn),uc=["zoom","select"],jn={defaultMode:"zoom",zoom:[["MouseLeft"]],zoomReset:[["MouseLeft","Control"]],pan:[["MouseLeft","Shift"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},dc={defaultMode:"pan",pan:[["MouseLeft"]],zoom:[["MouseLeft","Shift"]],zoomReset:[["MouseLeft","Control"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},xc={defaultMode:"select",select:[["MouseLeft"]],pan:[["MouseLeft","Shift"]],zoom:[["MouseLeft","Alt"]],zoomReset:[["MouseLeft","Control"]],cancel:[["Escape"]]},fr={zoom:jn,pan:dc,select:xc,zoomReset:jn,click:jn,cancel:jn},R1=e=>{const t=Object.entries(e);return Object.fromEntries(t.map(([n,s])=>n==="defaultMode"?[n,s]:[n,s.map(r=>r.filter(i=>i!=="MouseLeft")).filter(r=>r.length>0)]))},C1=u.Pt.construct(0,0,1,1,u.K$1.TOP_LEFT),w1={width:30,height:50},pc=({onChange:e,triggers:t,initial:n=C1,threshold:s=w1,ref:r})=>{const i=(t==null?void 0:t.defaultMode)??"zoom",[l,c]=g.useState(u.Pt.ZERO),[a,d]=g.useState(i),[x,p]=K.useStateRef(n),m=g.useRef(u.K.ZERO),f=g.useRef(null),h=u.A$1.construct(s);g.useEffect(()=>p(()=>u.Pt.truncate(n,gn(n))),[n]),g.useEffect(()=>d(i),[i]);const[j,y,S,b]=Ae.useMemoCompare(()=>{const A={...fr[i],...t},$=De.flattenConfig(A),O=R1(A);return[A,$,O,De.flattenConfig(O)]},De.compareModeConfigs,[t]),E=g.useCallback(({box:A,triggers:$,stage:O,cursor:V})=>{if(f.current==null)return;const z=De.determineMode(j,$),k=u.Pt.construct(f.current);if(z==null)return;if(z==="cancel"){c(u.Pt.ZERO),e==null||e({box:x.current,mode:z,stage:O,cursor:V});return}if(z==="zoomReset")return c(u.Pt.ZERO),e==null||e({box:u.Pt.DECIMAL,mode:z,stage:O,cursor:V}),p(u.Pt.DECIMAL);const C=E1(A);if(O==="end"){if(C){z==="zoom"&&c(u.Pt.ZERO),e==null||e({box:x.current,mode:"click",stage:O,cursor:V});return}return p(v=>{if(z==="pan"){const D=ui(A,v,k);return D===null||u.Pt.equals(D,v)?v:(e==null||e({box:D,mode:z,stage:O,cursor:V}),D)}const N=R(A,v,k);return N===null?v:(e==null||e({box:N,mode:z,stage:O,cursor:V}),z==="zoom"?(c(u.Pt.ZERO),N):u.Pt.truncate(v,gn(v)))})}if(uc.includes(z))return C?void 0:c(u.A.XY.scale(k).clamp(k).translate({x:-u.Pt.left(k),y:-u.Pt.top(k)}).box(di(h,A,k)));if(c(v=>u.Pt.areaIsZero(v)?v:u.Pt.ZERO),u.K.distance(V,m.current)<j1)return;m.current=V;const P=ui(A,x.current,k);e==null||e({box:P,mode:z,stage:O,cursor:V})},[c,d,e,j,s.height,s.width,p,f,gn]);g.useImperativeHandle(r,()=>({reset:()=>{c(u.Pt.ZERO),p(u.Pt.DECIMAL),e==null||e({box:u.Pt.DECIMAL,mode:"zoomReset",stage:"start",cursor:u.K.ZERO})}}),[e]);const R=g.useCallback((A,$,O)=>{const V=To($,O).box(di(h,A,O));return u.Pt.truncate(V,gn(V))},[s]),M=De.useHeldRef({triggers:[["Control"]]}),_=De.useHeldRef({triggers:[["Alt"]]});g.useEffect(()=>{const A=$=>{if(f.current==null)return;let O=1;$.deltaY<0?O-=.035:O+=.035;const V=u.Pt.construct(f.current),z=u.K.construct($);if(Array.from(f.current.children).push(f.current),!u.Pt.contains(V,z)||f.current!==$.target&&Ye.findParent($.target,D=>D===f.current)==null)return;const P=To(x.current,u.Pt.construct(f.current)).pos(u.K.construct($));let N=u.A.XY.magnify({x:M.current.held?1:O,y:_.current.held?1:O}).box(x.current);N=u.Pt.translate(N,{x:M.current.held?0:P.x*(1-O),y:_.current.held?0:P.y*(1-O)}),p(N),e==null||e({stage:"end",box:N,cursor:u.K.construct($),mode:"zoom"})};return window.addEventListener("wheel",A),()=>window.removeEventListener("wheel",A)},[p,e]),vl.useDrag({bound:f,onDrag:E,triggers:y,loose:!0});const L=g.useCallback(({triggers:A,stage:$})=>{if($==="end")return d(i);const O=De.determineMode(S,A);O!=null&&d(O)},[S,i,e]);return De.use({triggers:b,callback:L,region:f}),{maskBox:l,ref:f,mode:a}},To=(e,t)=>u.A.XY.scale(t).clamp(t).scale(e),ui=(e,t,n)=>{let s=u.Pt.signedDims(To(t,n).box(e));s={signedWidth:-s.signedWidth,signedHeight:-s.signedHeight};const r=u.A.XY.translate(u.K.construct(s)).box(t);return u.Pt.truncate(r,gn(r))},di=(e,t,n)=>u.Pt.height(t)<=e.height?u.Pt.construct(u.Pt.left(t),u.Pt.top(n),u.Pt.width(t),u.Pt.height(n)):u.Pt.width(t)<=e.width?u.Pt.construct(u.Pt.left(n),u.Pt.top(t),u.Pt.width(n),u.Pt.height(t)):t,b1=({mode:e,triggers:t})=>o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",children:[o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:u.d$1.capitalize(e)}),o.jsxRuntimeExports.jsx(ne.Space,{empty:!0,x:!0,align:"center",children:o.jsxRuntimeExports.jsx(zf.Text,{trigger:t[0],level:"small"})})]}),v1={zoom:o.jsxRuntimeExports.jsx(K.y4.Zoom,{}),pan:o.jsxRuntimeExports.jsx(K.y4.Pan,{}),select:o.jsxRuntimeExports.jsx(K.y4.Selection,{}),zoomReset:o.jsxRuntimeExports.jsx(K.y4.Expand,{}),click:o.jsxRuntimeExports.jsx(K.y4.Bolt,{})},k1=({triggers:e,disable:t=["zoomReset","click"],...n})=>{const s=[...t,"cancel"],r=Object.entries(e).filter(([i])=>!s.includes(i)&&Sn.includes(i)).map(([i,l])=>({key:i,icon:v1[i],tooltip:o.jsxRuntimeExports.jsx(b1,{mode:i,triggers:l})})).sort((i,l)=>Sn.indexOf(i.key)-Sn.indexOf(l.key));return o.jsxRuntimeExports.jsx(ot,{...n,data:r,entryRenderKey:"icon",children:({title:i,entry:l,...c})=>g.createElement(fe.Icon,{...c,key:l.key,variant:c.selected?"filled":"outlined",size:"small",tooltip:l.tooltip,tooltipLocation:u.K$1.BOTTOM_LEFT},l.icon)})},M1=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_TRIGGERS:fr,MASK_MODES:uc,MODES:Sn,Mask:tc,PAN_DEFAULT_TRIGGERS:dc,SELECT_DEFAULT_TRIGGERS:xc,SelectMode:k1,ZOOM_DEFAULT_TRIGGERS:jn,modeZ:S1,use:pc},Symbol.toStringTag,{value:"Module"})),P1=e=>e==null?null:e.closest(".pluto-line-plot__viewport")??null,mc=({ref:e,children:t,initial:n=u.Pt.DECIMAL,onChange:s,...r})=>{const{setViewport:i}=st("Viewport");g.useLayoutEffect(()=>{i({box:n,mode:"zoom",cursor:u.K.ZERO,stage:"start"})},[i,n]);const l=g.useCallback(a=>{i(a),s==null||s(a)},[s,i]),c=pc({onChange:l,initial:n,ref:e,...r});return o.jsxRuntimeExports.jsx(tc,{className:u.CSS.BE("line-plot","viewport"),...c,children:t})},_1=Object.freeze(Object.defineProperty({__proto__:null,BoundsQuerier:Gh,Floating:ur,Legend:Ul,Line:xr,LinePlot:Wl,Title:Jl,Tooltip:Yh,Viewport:mc,XAxis:Yl,YAxis:Gl,axisFactory:lr,selectViewportEl:P1,useBoundQuerier:ec,useContext:st,useGridEntry:$n,useViewport:Kl},Symbol.toStringTag,{value:"Module"})),L1=({aetherKey:e,...t})=>(Q.use$1({aetherKey:e,type:B.Annotation.TYPE,schema:B.annotationStateZ,initialState:t}),null),fc=({aetherKey:e,menu:t,...n})=>{const s=Q.useUniqueKey(e),{setViewport:r,setHold:i}=st("Range.Provider"),[,{hovered:l,count:c},a]=Q.use$1({aetherKey:s,type:B.Provider$1.TYPE,schema:B.providerStateZ,initialState:{...n,cursor:null,hovered:null,count:0}}),d=$n({key:s,loc:"top",size:c>0?32:0,order:3},"Annotation.Provider"),x=vt.useContextMenu(),p=K.useSyncedRef(x.visible),m=g.useCallback(f=>{const h=y=>{a(S=>({...S,cursor:{x:y.clientX,y:y.clientY}}))},j=f.currentTarget;j.addEventListener("mousemove",h),j.addEventListener("mouseleave",()=>{j.removeEventListener("mousemove",h),p.current||a(y=>({...y,cursor:null}))},{once:!0})},[a]);return o.jsxRuntimeExports.jsx(vt.ContextMenu,{...x,menu:()=>t==null||l==null?null:t(l),children:o.jsxRuntimeExports.jsx(ne.Space,{style:{...d,cursor:l!=null?"pointer":"default",width:"100%",height:"100%"},onContextMenu:x.open,className:x.className,onClick:()=>{l!=null&&(r({box:u.Pt.construct({x:l.viewport.lower,y:0},{x:l.viewport.upper,y:1}),mode:"zoom",cursor:u.K.ZERO,stage:"start"}),i(!0))},onMouseEnter:m})})},N1=Object.freeze(Object.defineProperty({__proto__:null,Annotation:L1,Provider:fc},Symbol.toStringTag,{value:"Module"})),hc={defaultMode:"empty",one:[["1"]],two:[["2"]],clear:[["Shift"]],empty:[[]]},T1=De.flattenConfig(hc),gc=({aetherKey:e})=>{const t=Q.useUniqueKey(e),[,,n]=Q.use$1({aetherKey:t,type:B.Measure.TYPE,schema:B.measureStateZ,initialState:{hover:null,one:null,two:null}}),s=g.useRef(null),r=De.useHeldRef({triggers:T1,loose:!0}),i=g.useCallback(({mode:a,cursor:d})=>{if(a==="click"){const x=De.determineMode(hc,r.current.triggers,{loose:!0});if(["one","two"].includes(x))return n(p=>({...p,[x]:d}));n(x==="clear"?p=>({...p,one:null,two:null}):p=>({...p,one:p.one??d,two:p.one!==null?d:p.two}))}},[n,r]);Kl(i);const l=g.useCallback(a=>n(d=>({...d,hover:u.K.construct(a)})),[n]),c=g.useCallback(()=>{n(a=>({...a,hover:null}))},[n]);return g.useEffect(()=>{if(s.current===null)return;const a=s.current.parentElement;if(a!=null)return a.addEventListener("mousemove",l),a.addEventListener("mouseleave",c),()=>{a.removeEventListener("mousemove",l),a.removeEventListener("mouseleave",c)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:s})},A1=Object.freeze(Object.defineProperty({__proto__:null,Measure:gc},Symbol.toStringTag,{value:"Module"})),hr=({aetherKey:e,label:t,position:n,onLabelChange:s,onPositionChange:r,onUnitsChange:i,units:l="",color:c,lineWidth:a,lineDash:d,className:x,onSelect:p,style:m,...f})=>{const[h,j]=ce.usePurePassthrough({value:t,onChange:s,initial:""}),y=K.useSyncedRef(r),[,{pixelPosition:S},b]=Q.use$1({aetherKey:e,type:B.Rule.TYPE,schema:B.ruleStateZ,initialState:{color:c,dragging:!1,position:n,lineWidth:a,lineDash:d},onAetherChange:g.useCallback(({position:z})=>{var k;z!=null&&((k=y.current)==null||k.call(y,z))},[y])}),E=g.useRef(S);S!==E.current&&(E.current=S);const{id:R}=st("Rule"),M=document.getElementById(R),_=M==null?void 0:M.querySelector(".pluto-line-plot__viewport"),L=g.useRef(S);g.useEffect(()=>{b(z=>({...z,position:n,color:c,lineWidth:a,lineDash:d}))},[n,c,a,d]);const A=Ge.useCursorDrag({onStart:g.useCallback(()=>{p==null||p(),b(z=>({...z,dragging:!0})),L.current=E.current},[]),onMove:z=>{b(k=>({...k,pixelPosition:(L.current??0)+u.Pt.signedHeight(z)}))},onEnd:g.useCallback(()=>{b(z=>({...z,dragging:!1})),L.current=S},[])}),$=g.useRef(null);if(n==null||S==null)return null;const O=u.od.pickByContrast(c,u.od.BLACK,u.od.WHITE),V=o.jsxRuntimeExports.jsxs("div",{ref:$,className:u.CSS.B("rule"),style:{top:`calc(${S}px - 0.5rem)`},children:[o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("rule","drag-handle"),onDragStart:A,draggable:!0}),o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",className:u.CSS(x,u.CSS.BE("rule","tag")),bordered:!0,onClick:p,size:1,rounded:!0,style:{borderColor:u.od.cssString(c),backgroundColor:u.od.hex(u.od.setAlpha(c,.7)),...m},...f,children:[o.jsxRuntimeExports.jsx(K.Editable,{className:u.CSS.B("label"),level:"small",value:h,onChange:j,color:O}),o.jsxRuntimeExports.jsx(As.Divider,{y:!0,style:{borderColor:u.od.cssString(c)}}),o.jsxRuntimeExports.jsxs(ne.Space,{size:"small",x:!0,align:"center",children:[o.jsxRuntimeExports.jsx(K.Editable,{value:n.toFixed(2),onChange:z=>{const k=Number(z);isFinite(k)&&(r==null||r(k))},level:"small",color:O}),o.jsxRuntimeExports.jsx(K.MaybeEditable,{level:"small",color:O,value:l,onChange:i})]})]})]});return _==null?V:kl.createPortal(V,_)},I1=Object.freeze(Object.defineProperty({__proto__:null,Rule:hr},Symbol.toStringTag,{value:"Module"})),jc=me.canDropOfType(nt),$1=({lines:e,axes:t,showTitle:n=!0,title:s="",onTitleChange:r,showLegend:i=!0,legendPosition:l,onLegendPositionChange:c,titleLevel:a="h4",onLineChange:d,onRuleChange:x,onAxisChannelDrop:p,onAxisChange:m,rules:f,enableTooltip:h=!0,enableMeasure:j=!1,initialViewport:y=u.Pt.DECIMAL,legendVariant:S,onViewportChange:b,viewportTriggers:E,annotationProvider:R,onSelectRule:M,children:_,...L})=>{var z;const A=t.filter(({location:k})=>u.K$1.isY(k)),$=g.useRef(null),O=K.usePrevious(e.length),V=K.usePrevious(L.hold);return(O===0&&e.length!==0||V===!0&&L.hold===!1)&&((z=$.current)==null||z.reset()),o.jsxRuntimeExports.jsxs(Wl,{...L,children:[A.map((k,C)=>{const P=e.filter(D=>D.axes.x===k.key),v=t.filter(({location:D})=>u.K$1.isX(D)),N=f==null?void 0:f.filter(D=>[...v.map(({key:I})=>I),k.key].includes(D.axis));return o.jsxRuntimeExports.jsx(B1,{axis:k,index:C,lines:P,yAxes:v,rules:N,onAxisChannelDrop:p,onAxisChange:m,annotationProvider:R,onRuleChange:x,onSelectRule:M},k.key)}),i&&o.jsxRuntimeExports.jsx(Ul,{onLineChange:d,position:l,onPositionChange:c,variant:S}),n&&o.jsxRuntimeExports.jsx(Jl,{value:s,onChange:r,level:a}),o.jsxRuntimeExports.jsxs(mc,{initial:y,onChange:b,triggers:E,ref:$,children:[h&&o.jsxRuntimeExports.jsx(Ql,{}),j&&o.jsxRuntimeExports.jsx(gc,{}),_]})]})},B1=({yAxes:e,lines:t,index:n,rules:s,onRuleChange:r,onSelectRule:i,onAxisChannelDrop:l,onAxisChange:c,axis:{location:a,key:d,showGrid:x,...p},annotationProvider:m})=>{const f=me.useDrop({type:"Channel.LinePlot.XAxis",canDrop:jc,onDrop:g.useCallback(({items:y})=>{const S=me.filterByType(nt,y);return l==null||l(d,S.map(({key:b})=>b)),S},[d,l])}),h=s==null?void 0:s.filter(y=>y.axis===d),j=me.useDraggingState();return o.jsxRuntimeExports.jsxs(Yl,{...p,...f,location:a,axisKey:d,showGrid:x??n===0,className:u.CSS(u.CSS.dropRegion(me.canDropOfType(nt)(j))),onAutoBoundsChange:y=>c==null?void 0:c({key:d,bounds:y}),children:[e.map((y,S)=>{const b=t.filter(R=>R.axes.y===y.key),E=s==null?void 0:s.filter(R=>R.axis===y.key);return o.jsxRuntimeExports.jsx(O1,{axis:{...y,showGrid:x??(n===0&&S===0)},lines:b,rules:E,onRuleChange:r,onAxisChannelDrop:l,onAxisChange:c,onSelectRule:i},y.key)}),h==null?void 0:h.map(y=>g.createElement(hr,{aetherKey:y.key,...y,key:y.key,onLabelChange:S=>r==null?void 0:r({key:y.key,label:S}),onPositionChange:S=>r==null?void 0:r({key:y.key,position:S}),onUnitsChange:S=>r==null?void 0:r({key:y.key,units:S}),onSelect:()=>i==null?void 0:i(y.key)})),o.jsxRuntimeExports.jsx(fc,{...m})]})},D1=({channels:{x:e,y:t}})=>`${e??0}-${t}`,O1=({lines:e,rules:t,onRuleChange:n,onAxisChannelDrop:s,onAxisChange:r,axis:{key:i,location:l,...c},onSelectRule:a})=>{const d=me.useDrop({type:"Channel.LinePlot.YAxis",canDrop:jc,onDrop:g.useCallback(({items:p})=>{const m=me.filterByType(nt,p);return s==null||s(i,m.map(({key:f})=>f)),m},[i,s])}),x=me.useDraggingState();return o.jsxRuntimeExports.jsxs(Gl,{...c,...d,location:l,axisKey:i,className:u.CSS(u.CSS.dropRegion(me.canDropOfType(nt)(x))),onAutoBoundsChange:p=>r==null?void 0:r({key:i,bounds:p}),children:[e.map(p=>o.jsxRuntimeExports.jsx(z1,{line:p},D1(p))),t==null?void 0:t.map(p=>g.createElement(hr,{aetherKey:p.key,...p,key:p.key,onLabelChange:m=>n==null?void 0:n({key:p.key,label:m}),onPositionChange:m=>n==null?void 0:n({key:p.key,position:m}),onUnitsChange:m=>n==null?void 0:n({key:p.key,units:m}),onClick:()=>a==null?void 0:a(p.key)}))]})},z1=({line:e})=>e.variant==="static"?o.jsxRuntimeExports.jsx(F1,{line:e}):o.jsxRuntimeExports.jsx(V1,{line:e}),V1=({line:{key:e,timeSpan:t,channels:{x:n,y:s},axes:r,...i}})=>{const{xTelem:l,yTelem:c}=g.useMemo(()=>{const a=Number(t.valueOf())*3,d=B.streamChannelData({timeSpan:t,channel:s,keepFor:a}),x=n!=null&&n!==0;return{xTelem:B.streamChannelData({timeSpan:t,channel:x?n:s,useIndexOfChannel:!x,keepFor:a}),yTelem:d}},[t.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(xr,{aetherKey:e,y:c,x:l,...i})},F1=({line:{timeRange:e,key:t,channels:{x:n,y:s},...r}})=>{const{xTelem:i,yTelem:l}=g.useMemo(()=>{const c=B.channelData({timeRange:e,channel:s}),a=n!=null&&n!==0;return{xTelem:B.channelData({timeRange:e,channel:a?n:s,useIndexOfChannel:!a}),yTelem:c}},[e.start.valueOf(),e.end.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(xr,{aetherKey:t,y:l,x:i,...r})},xi=[{key:"name",name:"Name"},{key:"alias",name:"Alias"},{key:"rate",name:"Rate"},{key:"dataType",name:"Data Type"},{key:"index",name:"Index"},{key:"key",name:"Key"},{key:"isIndex",name:"Is Index"}],ms=({items:e},t)=>{const n=me.filterByType(nt,e);return n.length>0&&!n.every(s=>t.includes(s.key))},Ec=["name","alias"],yc=e=>{const t=$s();return g.useMemo(()=>e.length===0?xi:xi.filter(n=>e.includes(n.key)),[e,t])},Sc=e=>{if(e==null)return K.y4.Channel;if(bt.tq.isCalculated(e))return K.y4.Calculation;if(e.isIndex)return K.y4.Index;const t=new u.m(e.dataType);return t.isInteger?K.y4.Binary:t.isFloat?K.y4.Decimal:t.equals(u.m.STRING)?K.y4.String:t.equals(u.m.JSON)?K.y4.JSON:K.y4.Channel},H1=({key:e,...t})=>{const n=Sc(t.entry);return o.jsxRuntimeExports.jsx(mr,{icon:o.jsxRuntimeExports.jsx(n,{}),...t},e)},Z1=({columns:e=Ec,onChange:t,className:n,value:s,searchOptions:r,...i})=>{const l=qe(),c=$s(),a=yc(e),d=ir(),x=Ae.useMemoDeepEqualProps(r),p=g.useMemo(()=>l==null?void 0:l.channels.newSearcherWithOptions({rangeKey:d,internal:!1,...x}),[l,d,x]),m=l!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:f,onDragEnd:h,...j}=me.useDragAndDrop({type:"Channel.SelectMultiple",canDrop:g.useCallback(R=>ms(R,Pe.t.toArray(s)),[s]),onDrop:g.useCallback(({items:R})=>{const M=me.filterByType(nt,R);if(M.length===0)return[];const _=u.c.unique([...Pe.t.toArray(s),...M.map(L=>L.key)]);return t(_,{clickedIndex:null,clicked:null,entries:[]}),M},[t,s])}),y=me.useDraggingState(),S=g.useCallback(({dropped:R})=>{t(Pe.t.toArray(s).filter(M=>!R.some(_=>_.key===M)),{clickedIndex:null,clicked:null,entries:[]})},[t,s]),b=g.useCallback((R,M)=>f([{key:M,type:nt}],S),[f,S]),E=g.useCallback(R=>c[R.key]??R.name,[c]);return o.jsxRuntimeExports.jsx(an,{className:u.CSS(n,u.CSS.dropRegion(ms(y,Pe.t.toArray(s)))),value:s,onTagDragStart:b,onTagDragEnd:h,searcher:p,onChange:t,columns:a,emptyContent:m,entryRenderKey:E,renderTag:H1,...j,...i})},$t=({columns:e=Ec,onChange:t,value:n,className:s,data:r,searchOptions:i,...l})=>{const c=qe(),a=$s(),d=yc(e),x=ir(),p=Ae.useMemoDeepEqualProps(i),m=g.useMemo(()=>{if(!(r!=null&&r.length>0))return c==null?void 0:c.channels.newSearcherWithOptions({rangeKey:x,internal:!1,...p})},[c,x,r==null?void 0:r.length,p]),f=c!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),h=g.useId(),j=g.useMemo(()=>({key:h,type:"Channel.SelectMultiple"}),[h]),{startDrag:y,onDragEnd:S,...b}=me.useDragAndDrop({type:"Channel.SelectSingle",canDrop:g.useCallback(_=>ms(_,Pe.t.toArray(n)),[n]),onDrop:g.useCallback(({items:_})=>{const L=me.filterByType(nt,_);return L.length===0?[]:(t(L[0].key,{clickedIndex:null,clicked:null,entries:[]}),L)},[j,t])}),E=me.useDraggingState(),R=g.useCallback(()=>n!=null&&y([{type:nt,key:n}]),[y,n]),M=g.useCallback(_=>a[_.key]??_.name,[a]);return o.jsxRuntimeExports.jsx(mt,{data:r,className:u.CSS(s,u.CSS.dropRegion(ms(E,Pe.t.toArray(n)))),value:n,onDragStart:R,onDragEnd:S,onChange:t,searcher:m,columns:d,emptyContent:f,entryRenderKey:M,...b,...l})},K1=Object.freeze(Object.defineProperty({__proto__:null,AliasInput:vh,AliasProvider:Vl,LinePlot:$1,SelectMultiple:Z1,SelectSingle:$t,resolveIcon:Sc,useActiveRange:ir,useAlias:zl,useAliases:$s,useContext:cn,useName:Bs},Symbol.toStringTag,{value:"Module"})),Mt=({path:e,optional:t=!1,onChange:n,defaultValue:s})=>{const r=ft(),{get:i,bind:l,set:c,setStatus:a}=r,[d,x]=g.useState(()=>{const h=i(e,{optional:t||s!=null});return h!=null||s==null||t?h:{value:s,status:{key:"",variant:"success",message:""},touched:!1,required:!1}});g.useEffect(()=>(i(e,{optional:t||s!=null})==null&&s!=null&&c(e,s),x(i(e,{optional:t})),l({path:e,onChange:x,listenToChildren:!1})),[e,n,l,i,t,s]);const p=g.useCallback(h=>{n==null||n(h,{...r,path:e}),c(e,h)},[e,c,n]),m=g.useCallback(h=>a(e,h),[e,a]);if(d==null){if(!t)throw new Error(`Field state is null: ${e}`);return null}let f;return r.mode==="preview"&&(f="preview"),{onChange:p,setStatus:m,variant:f,...d}},Rc=(e,t=!1,n)=>{const{get:s,bind:r}=ft(n),[,i]=g.useState(0);return g.useEffect(()=>(i(l=>l+1),r({path:e,onChange:()=>i(l=>l+1)})),[e,r]),s(e,{optional:t})??null},Cc=(e,t=!1,n)=>{var l;const{get:s,bind:r}=ft(n),[,i]=g.useState(0);return g.useEffect(()=>(i(c=>c+1),r({path:e,onChange:()=>i(c=>c+1)})),[e,r]),((l=s(e,{optional:t}))==null?void 0:l.value)??null},W1=e=>{var t,n;return((n=(t=Rc(e,!0))==null?void 0:t.status)==null?void 0:n.variant)==="success"},Y1=({path:e,ctx:t,onChange:n})=>{const s=ft(t);g.useEffect(()=>s.bind({path:e,onChange:r=>n(r,s),listenToChildren:!1}),[e,s])},G1=({path:e,optional:t=!1})=>{const{bind:n,get:s}=ft(),[r,i]=g.useState(s(e,{optional:t}));if(g.useEffect(()=>(i(s(e,{optional:t})),n({path:e,onChange:l=>i({...l,value:u.vd(l.value)}),listenToChildren:!0})),[e,n,s]),r==null&&!t)throw new Error("Field state is null");return(r==null?void 0:r.value)??null},wc=(e,t)=>({add:(n,s)=>{const r=u.vd(e.get(t).value);r.splice(s,0,...Pe.t.toArray(n)),e.set(t,r,{validateChildren:!1})},push:(n,s)=>{const r=u.vd(e.get(t).value);r.push(...Pe.t.toArray(n)),s!=null&&r.sort(s),e.set(t,r,{validateChildren:!1})},remove:n=>{const s=e.get(t).value,r=new Set(Pe.t.toArray(n));e.set(t,s.filter((i,l)=>!r.has(l)))},keepOnly:n=>{const s=e.get(t).value,r=new Set(Pe.t.toArray(n));e.set(t,s.filter((i,l)=>r.has(l)))},set:n=>e.set(t,ce.executeSetter(n,e.get(t).value)),sort:n=>{const s=u.vd(e.get(t).value);s.sort(n),e.set(t,s)}}),q1=({path:e,updateOnChildren:t=!1,ctx:n})=>{const s=ft(n),{bind:r,get:i}=s,[l,c]=g.useState(i(e).value);return g.useEffect(()=>(c(i(e).value),r({path:e,onChange:a=>{c(u.vd(a.value))},listenToChildren:t})),[e,r,i,c]),g.useMemo(()=>({value:l,...wc(s,e)}),[l,s,e])},bc=g.createContext({mode:"normal",bind:()=>()=>{},set:()=>{},reset:()=>{},remove:()=>{},get:()=>({value:void 0,status:{key:"",variant:"success",message:""},touched:!1,required:!1}),validate:()=>!1,validateAsync:()=>Promise.resolve(!1),value:()=>({}),has:()=>!1,setStatus:()=>{},clearStatuses:()=>{},setCurrentStateAsInitialValues:()=>{}}),ft=e=>{const t=g.use(bc);return e??t},pi=e=>({key:e,variant:"success",message:""}),X1=e=>e.code===B.ZodIssueCode.custom&&e.params!=null&&"variant"in e.params?e.params.variant:"error",vc=({values:e,sync:t=!1,schema:n,mode:s="normal",onChange:r,onHasTouched:i})=>{const l=K.useInitializerRef(()=>({state:Be.J.copy(e),statuses:new Map,touched:new Set,listeners:new Map,parentListeners:new Map})),c=K.useSyncedRef(n),a=K.useSyncedRef(r),d=K.useSyncedRef(e),x=K.useSyncedRef(i),p=Ce.useErrorHandler(),m=g.useCallback(()=>{d.current=Be.J.copy(l.current.state),S()},[]),f=g.useCallback(({path:k,onChange:C,listenToChildren:P=!1})=>{var I;const{parentListeners:v,listeners:N}=l.current,D=P?v:N;return D.has(k)||D.set(k,new Set),(I=D.get(k))==null||I.add(C),()=>{var F;return(F=D.get(k))==null?void 0:F.delete(C)}},[]),h=g.useCallback((k,{optional:C}={optional:!1})=>{const{state:P,statuses:v,touched:N}=l.current,D=Be.J.get(P,k,{optional:C});if(D==null)return null;const I={value:D,status:v.get(k)??pi(k),touched:N.has(k),required:!1};if(c.current==null)return I;const F=c.current,H=Yf.getFieldSchema(F,k,{optional:!0});return H==null||"isOptional"in H&&typeof H.isOptional=="function"&&(I.required=!H.isOptional()),I},[]),j=g.useCallback(k=>{var N;const{touched:C}=l.current,P=C.size===0;C.add(k);const v=C.size===0;P!==v&&((N=x.current)==null||N.call(x,!v))},[]),y=g.useCallback(k=>{var N;const{touched:C}=l.current,P=C.size===0;C.delete(k);const v=C.size===0;P!==v&&((N=x.current)==null||N.call(x,!v))},[]),S=g.useCallback(()=>{var v;const{touched:k}=l.current,C=k.size===0;k.clear();const P=k.size===0;C!==P&&((v=x.current)==null||v.call(x,!P))},[]),b=g.useCallback(k=>{const{state:C,statuses:P,listeners:v,parentListeners:N}=l.current;Be.J.remove(C,k),P.delete(k),y(k),v.delete(k),N.delete(k)},[]),E=g.useCallback(k=>{const{statuses:C}=l.current;l.current.state=k??Be.J.copy(d.current),M(""),C.clear(),S()},[]),R=g.useCallback(k=>{var v;const{listeners:C}=l.current,P=h(k,{optional:!0});P!=null&&((v=C.get(k))==null||v.forEach(N=>N(P)))},[]),M=g.useCallback(k=>{const{listeners:C,parentListeners:P}=l.current,v=C.get(k);if(k==""&&([...C.keys()].forEach(I=>{var H;const F=h(I,{optional:!0});F!=null&&((H=C.get(I))==null||H.forEach(Z=>{Z(F)}))}),[...P.keys()].forEach(I=>{var H;const F=h(I,{optional:!0});F!=null&&((H=P.get(I))==null||H.forEach(Z=>{Z(F)}))})),v!=null){const N=h(k,{optional:!0});N!=null&&v.forEach(D=>{D(N)})}P.forEach((N,D)=>{if(Be.J.pathsMatch(k,D)){const F=h(D,{optional:!0});F!=null&&N.forEach(H=>{H(F)})}})},[]),_=g.useCallback((k,C="",P=!0)=>{const{statuses:v,listeners:N}=l.current;if(k.success){const H=[...v.keys()];return v.clear(),H.forEach(Z=>R(Z)),!0}let D=!0;const I=new Set(k.error.issues.map(H=>H.path.join(".")));let F=(H,Z)=>H===Z;return P&&(F=(H,Z)=>Be.J.pathsMatch(H,Z)),k.error.issues.forEach(H=>{var oe;const{message:Z}=H,ee=H.path.join(".");if(!F(ee,C))return;const te=X1(H);te!=="warning"&&(D=!1),v.set(ee,{key:ee,variant:te,message:Z}),j(ee);let se=h(ee,{optional:!0});se??(se={value:void 0,status:v.get(ee)??pi(ee),touched:!1,required:!1}),(oe=N.get(ee))==null||oe.forEach(xe=>xe(se))}),v.forEach((H,Z)=>{I.has(Z)||(v.delete(Z),R(Z))}),D},[]),L=g.useCallback((k,C)=>{if(c.current==null)return!0;const{state:P}=l.current,v=c.current.safeParse(P);return _(v,k,C)},[_]),A=g.useCallback(async(k,C)=>{if(c.current==null)return!0;const{state:P}=l.current,v=await c.current.safeParseAsync(P);return _(v,k,C)},[_]),$=g.useCallback((k,C,P={})=>{const v=Be.J.get(l.current.state,k,{optional:!0}),{validateChildren:N=!0}=P,{state:D}=l.current,I=Be.J.get(d.current,k,{optional:!0});Be.J.equal(I,C)?y(k):j(k),k.length===0?l.current.state=C:Be.J.set(D,k,C),M(k),p(async()=>{var Z;let H;try{H=L(k,N)}catch{H=await A(k,N)}(Z=a.current)==null||Z.call(a,{values:l.current.state,path:k,prev:v,valid:H})},"Failed to validate form")},[]),O=g.useCallback(k=>Be.J.has(l.current.state,k),[]),V=g.useCallback((k,C)=>{l.current.statuses.set(k,C),j(k),R(k)},[]),z=g.useCallback(()=>{const{statuses:k}=l.current;k.clear(),k.forEach((C,P)=>R(P))},[]);return g.useEffect(()=>{if(!t)return;const{listeners:k}=l.current;l.current.state=e,k.forEach((C,P)=>{const v=h(P,{optional:!0});v!=null&&C.forEach(N=>N(v))})},[t,e]),g.useMemo(()=>({bind:f,set:$,get:h,mode:s,validate:L,validateAsync:A,value:()=>l.current.state,has:O,remove:b,setStatus:V,clearStatuses:z,reset:E,setCurrentStateAsInitialValues:m}),[f,$,h,L,A,O,b,V,z,E,s,m])},U1=({children:e,...t})=>o.jsxRuntimeExports.jsx(bc,{value:t,children:e}),J1=fe.componentRenderProp(pt.Text),we=({path:e,children:t=J1,label:n,padHelpText:s=!0,visible:r=!0,hideIfNull:i=!1,optional:l,onChange:c,className:a,defaultValue:d,...x})=>{const p=Mt({path:e,optional:l??i,onChange:c,defaultValue:d}),m=ft();if(p==null)return null;if(e==null)throw new Error("No path provided to Form Field");if(n??(n=u.d$1.capitalize(Be.J.element(e,-1))),r=typeof r=="function"?r(p,m):r,!r)return null;const f=p.status.message,{onChange:h,value:j}=p,y={onChange:h,value:j};return p.variant!=null&&(y.variant=p.variant),o.jsxRuntimeExports.jsx(he.Item,{padHelpText:s,helpText:f,helpTextVariant:p.status.variant,label:n,required:p.required,className:u.CSS(a,u.CSS.BE("field",e.split(".").join("-")),u.CSS.M(p.status.variant)),...x,children:t(y)})},Pt=e=>({fieldKey:t,fieldProps:n,inputProps:s})=>{const r=({inputProps:i,path:l,fieldKey:c=t,optional:a,defaultValue:d,...x})=>o.jsxRuntimeExports.jsx(we,{...n,...x,defaultValue:d,optional:a,path:c?`${l}.${c}`:l,children:p=>o.jsxRuntimeExports.jsx(e,{...p,...s,...i})});return r.displayName=e.displayName,r},kc=Pt(he.Numeric),Ze=kc({}),Mc=Pt(pt.Text),gr=Mc({}),Pc=Pt(Q.Switch$1),Fs=Pc({}),Q1=Pt(mt),eg=Pt(an),tg=Pt(Os),_c=Pt(ot),jr=({key:e,open:t,onChange:n})=>{const s=Ae.useMemoPrimitiveArray(e);Q.useAsyncEffect(async()=>{if(t==null)return;const r=await t();if(r==null)return;const i=r.onChange(n);return async()=>{i(),await r.close()}},[t==null,s])},ng=({fetchInitialValue:e,...t})=>{const[n,s]=g.useState(void 0);return Q.useAsyncEffect(async()=>{s(await e())},[e]),jr({...t,onChange:s}),n},sg=Object.freeze(Object.defineProperty({__proto__:null,useListener:jr,useState:ng},Symbol.toStringTag,{value:"Module"})),og=({key:e,name:t,queryFn:n,values:s,openObservable:r,applyChanges:i,applyObservable:l,...c})=>{const a=qe(),d=Ce.useErrorHandler(),x=Ae.useMemoPrimitiveArray(e),p=vc({values:s,...c,sync:!1,onChange:h=>{a!=null&&d(async()=>{await(i==null?void 0:i({...h,client:a}))},`Failed to apply changes for ${t}`)}});Q.useAsyncEffect(async()=>{if(a!=null)try{const h=await n({client:a});p.set("",h)}catch(h){d(h,`Failed to retrieve ${t}`)}},[x,a==null?void 0:a.key]);const m=g.useCallback(async()=>{if(a!=null)return await(r==null?void 0:r(a))},[x,a==null?void 0:a.key]),f=g.useCallback(h=>l==null?void 0:l({changes:h,ctx:p}),[x,l]);return jr({key:x,open:m,onChange:f}),p},rg=Object.freeze(Object.defineProperty({__proto__:null,Field:we,Form:U1,NumericField:Ze,SwitchField:Fs,TextField:gr,buildButtonSelectField:_c,buildDropdownButtonSelectField:tg,buildNumericField:kc,buildSelectMultiField:eg,buildSelectSingleField:Q1,buildSwitchField:Pc,buildTextField:Mc,fieldArrayUtils:wc,fieldBuilder:Pt,use:vc,useChildFieldValues:G1,useContext:ft,useField:Mt,useFieldArray:q1,useFieldListener:Y1,useFieldState:Rc,useFieldValid:W1,useFieldValue:Cc,useSynced:og},Symbol.toStringTag,{value:"Module"})),ig=[{key:"name",name:"Name"},{key:"location",name:"Location",render:({entry:{location:e,rackName:t}})=>o.jsxRuntimeExports.jsx(Tl,{level:"small",shade:9,weight:450,style:{marginTop:"0.25rem"},size:"tiny",children:t?`${t}.${e}`:e})}],lg=({searchOptions:e,filter:t,...n})=>{const s=qe();let r=s==null?void 0:s.hardware.devices;e!=null&&s!=null&&(r=s.hardware.devices.newSearcherWithOptions(e));const[i,l]=g.useState(new Map),c=g.useCallback(a=>((t==null?void 0:t(a))??a).map(x=>({...x,rackName:i.get(x.rack)})),[t,i]);return Q.useAsyncEffect(async()=>{if(s==null){l(new Map);return}const a=await s.hardware.racks.retrieve([]);l(new Map(a.map(({key:d,name:x})=>[d,x])))},[s==null?void 0:s.key]),o.jsxRuntimeExports.jsx(mt,{columns:ig,searcher:r,entryRenderKey:"name",filter:c,...n})},cg=Object.freeze(Object.defineProperty({__proto__:null,SelectSingle:lg},Symbol.toStringTag,{value:"Module"})),ag=[{key:"name",name:"Name"},{key:"location",name:"Location"}],ug=e=>{const t=qe();return o.jsxRuntimeExports.jsx(mt,{columns:ag,searcher:t==null?void 0:t.hardware.racks,entryRenderKey:"name",...e})},dg=Object.freeze(Object.defineProperty({__proto__:null,SelectSingle:ug},Symbol.toStringTag,{value:"Module"})),Qt="label",Er=[{key:"color",name:"Color",render:({entry:e})=>o.jsxRuntimeExports.jsx(K.y4.Circle,{name:"circle",color:e.color,style:{height:"2.5rem",width:"2.5rem"}})},{key:"name",name:"Name"}],fs=({items:e},t)=>{const n=me.filterByType(Qt,e);return n.length>0&&!n.every(s=>t.includes(s.key))},xg=({entry:e,loading:t,entryKey:n,entryRenderKey:s,...r})=>o.jsxRuntimeExports.jsx(wn,{color:e==null?void 0:e.color,...r,children:e==null?void 0:e.name}),pg=fe.componentRenderProp(xg),mg=({onChange:e,className:t,value:n,...s})=>{const r=qe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=me.useDragAndDrop({type:"Label.SelectMultiple",canDrop:g.useCallback(m=>fs(m,Pe.t.toArray(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=me.filterByType(Qt,m);if(f.length===0)return[];const h=u.c.unique([...Pe.t.toArray(n),...f.map(j=>j.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),d=me.useDraggingState(),x=g.useCallback(({dropped:m})=>{e(Pe.t.toArray(n).filter(f=>!m.some(h=>h.key===f)),{clickedIndex:null,clicked:null,entries:[]})},[e,n]),p=g.useCallback((m,f)=>l([{key:f,type:Qt}],x),[l,x]);return o.jsxRuntimeExports.jsx(an,{className:u.CSS(t,u.CSS.dropRegion(fs(d,Pe.t.toArray(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.labels,onChange:e,columns:Er,emptyContent:i,renderTag:pg,addPlaceholder:"Label",...a,...s})},Lc=({value:e,onChange:t})=>{const n=qe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),r=g.useId(),i=g.useMemo(()=>({key:r,type:"Label.SelectMultiple"}),[r]),l=me.useDragAndDrop({type:"Label.SelectSingle",canDrop:g.useCallback(d=>fs(d,Pe.t.toArray(e)),[e]),onDrop:g.useCallback(({items:d})=>{const x=me.filterByType(Qt,d);return x.length===0?[]:(t(x[0].key,{clickedIndex:null,clicked:null,entries:[]}),x)},[i,t])}),c=me.useDraggingState(),a=g.useCallback(()=>e!=null&&l.startDrag([{type:Qt,key:e}]),[l.startDrag,e]);return{emptyContent:s,dragging:c,...l,onDragStart:a,searcher:n==null?void 0:n.labels}},fg=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=Lc({value:t,onChange:e});return o.jsxRuntimeExports.jsx(mt,{data:s,className:u.CSS(n,u.CSS.dropRegion(fs(i,Pe.t.toArray(t)))),value:t,onChange:e,columns:Er,entryRenderKey:"name",...l,...r})},hg=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=Lc({value:t,onChange:n});return o.jsxRuntimeExports.jsx(mt,{data:e,value:t,onChange:n,columns:Er,entryRenderKey:"name",...i,...s})},gg=Object.freeze(Object.defineProperty({__proto__:null,HAUL_TYPE:Qt,SelectButton:hg,SelectMultiple:mg,SelectSingle:fg},Symbol.toStringTag,{value:"Module"})),Hs=new Error("Tab not found"),jg=new Error("Invalid Mosaic"),hs=(e,t,n="center",s,r)=>{if(e=rt(e),s===void 0)return Ao(e,t);const i=Io(e,s);if(n==="center")return i.tabs||(i.tabs=[]),r!==void 0&&r>=0&&r<=i.tabs.length?i.tabs.splice(r,0,t):i.tabs.push(t),i.selected=t.tabKey,e;const l=i.key*2,c=i.key*2+1,a=n==="top"||n==="left"?l:c;if(Io(e,a).key!==i.key)return hs(e,t,"center",a);if(i.tabs==null||i.tabs.length===0)return hs(e,t,"center",s);const[d,x,p]=wg(n);if(i.direction=p,i[d]={key:0,tabs:[t],selected:t.tabKey},i[x]={key:0,tabs:i.tabs,selected:i.selected},i.first==null||i.last==null)throw jg;return i.first.key=l,i.last.key=c,i.tabs=void 0,i.size=void 0,i.selected=void 0,e},Eg=(e,t,n)=>{var i;e=rt(e);const[s,r]=Bt(e,t);if(s==null||r==null)throw Hs;return r.tabs=(i=r.tabs)==null?void 0:i.map(l=>l.tabKey===t?n(l):l),e},Ao=(e,t)=>(e=rt(e),e.tabs!=null?(e.tabs.push(t),e.selected=t.tabKey,e):(e.first!=null?e.first=Ao(e.first,t):e.last!=null&&(e.last=Ao(e.last,t)),e)),gs=e=>{e=rt(e);const t=[];if(e.tabs!=null&&(e.selected=Te.resetSelection(e.selected,e.tabs),e.selected!=null&&t.push(e.selected)),e.first!=null){const[n,s]=gs(e.first);e.first=n,t.push(...s)}if(e.last!=null){const[n,s]=gs(e.last);e.last=n,t.push(...s)}return[e,t]},yr=(e,t)=>{var r;e=rt(e);const[,n]=Bt(e,t);if(n==null)return[e,null];n.tabs=(r=n.tabs)==null?void 0:r.filter(i=>i.tabKey!==t),n.selected=Te.resetSelection(n.selected,n.tabs),e=Cg(e);const s=n.selected??js(e);return[e,s]},js=e=>e.selected!=null?e.selected:e.first!=null?js(e.first):e.last!=null?js(e.last):null,Nc=(e,t)=>{e=rt(e);const[n,s]=Bt(e,t);if(n==null||s==null)throw Hs;return s.selected=t,e},Tc=(e,t,n,s,r)=>{e=rt(e);const[i,l]=Bt(e,t);if(i==null||l==null)throw Hs;const[c,a]=yr(e,t);return[hs(c,i,n,s,r),a]},bn=(e,t)=>{if(e.tabs!=null)return e.tabs.some(n=>n.tabKey===t)?e:void 0;if(e.first!=null){const n=bn(e.first,t);if(n!=null)return n}if(e.last!=null){const n=bn(e.last,t);if(n!=null)return n}},Ac=(e,t,n)=>{const s=Es(e,t);if(s==null)throw new Error("Node not found");return s.size=n,e},yg=(e,t,n)=>{e=rt(e);const s=bn(e,t);if(s==null)throw new Error("Tab not found");if(s.tabs==null||s.tabs.length===0)throw new Error("Node has no tabs");const r=s.tabs.findIndex(x=>x.tabKey===t);if(r===-1)throw new Error("Tab not found in node");const i=s.tabs[r];s.tabs=s.tabs.filter(x=>x.tabKey!==t);const l=s.key*2,a={key:s.key*2+1,tabs:[i],selected:i.tabKey},d={key:l,tabs:s.tabs,selected:s.selected};return d.selected=Te.resetSelection(d.selected,d.tabs),s.direction=n,s.first=d,s.last=a,s.tabs=void 0,s.selected=void 0,e},Sg=(e,t)=>{const n=bn(e,t);return n==null?!1:n.tabs!=null&&n.tabs.length>1},Ic=(e,t,n)=>{e=rt(e);const[,s]=Bt(e,t);if((s==null?void 0:s.tabs)==null)throw Hs;return s.tabs=Te.rename(t,n,(s==null?void 0:s.tabs)??[]),e},Rg=e=>e.tabs!=null?e.tabs.length===0:e.first==null&&e.last==null,Io=(e,t)=>{const n=Es(e,t);if(n!=null)return n;const s=Math.floor(t/2);return s===0?e:Io(e,s)},Cg=e=>{let t=!0;for(;t;)[e,t]=$o(e);return e=Do(e,1),e},$o=e=>{if(e.first==null||e.last==null)return[e,!1];if(fi(e.first))return[mi(e.last),!0];if(fi(e.last))return[mi(e.first),!0];let t,n;return[e.first,t]=$o(e.first),[e.last,n]=$o(e.last),[e,t||n]},mi=e=>(e.size=void 0,e),fi=e=>e.first==null&&e.last==null&&(e.tabs==null||e.tabs.length===0),Bt=(e,t)=>{if(e.tabs!=null){const l=e.tabs.find(c=>c.tabKey===t);if(l!=null)return[l,e]}if(e.first==null||e.last==null)return[void 0,void 0];const[n,s]=Bt(e.first,t);if(n!=null&&s!=null)return[n,s];const[r,i]=Bt(e.last,t);return[r,i]},Es=(e,t)=>{if(e.key===t)return e;if(e.first==null||e.last==null)return;const n=Es(e.first,t);return n??Es(e.last,t)},wg=e=>{switch(e){case"top":return["first","last","y"];case"left":return["first","last","x"];case"bottom":return["last","first","y"];case"right":return["last","first","x"];case"center":throw new Error("cannot split a center placed tab")}},rt=e=>Be.J.copy(e),ys=(e,t,n=[])=>(n.push(t(e)),e.first!=null&&ys(e.first,t,n),e.last!=null&&ys(e.last,t,n),n),Bo=(e,t)=>{t(e),e.first!=null&&Bo(e.first,t),e.last!=null&&Bo(e.last,t)},Do=(e,t)=>(e=rt(e),e.key=t,e.first!=null&&(e.first=Do(e.first,t*2)),e.last!=null&&(e.last=Do(e.last,t*2+1)),e);class $c{constructor(t={}){tt(this,"parent");tt(this,"stub");tt(this,"el");this.el=document.createElement("div"),Object.entries(t).forEach(([n,s])=>this.el.setAttribute(n,s))}mount(t,n){n!==this.stub&&(this.unmount(null),t.replaceChild(this.el,n),this.parent=t,this.stub=n)}unmount(t){t!=null&&t!==this.stub||this.parent==null||this.stub==null||(this.parent.replaceChild(this.stub,this.el),this.parent=void 0,this.stub=void 0)}}const bg=({node:e})=>{const t=g.createRef(),n=g.useRef(e);return g.useEffect(()=>{const s=t.current;if(s==null)return;const r=s.parentNode;if(r!=null)return e.mount(r,s),()=>{t.current!=null&&e.unmount(t.current)}},[]),g.useEffect(()=>{n.current!=null&&e!==n.current&&(n.current.unmount(t.current),n.current=e);const s=t.current;if(s==null)return;const r=s.parentNode;r!=null&&e.mount(r,s)},[e]),o.jsxRuntimeExports.jsx("div",{ref:t})},Bc=({node:e,children:t})=>kl.createPortal(t,e.el),vg=Object.freeze(Object.defineProperty({__proto__:null,In:Bc,Node:$c,Out:bg},Symbol.toStringTag,{value:"Module"})),Ss=g.memo(({root:e,onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,activeTab:l,emptyContent:c,onSelect:a,onClose:d,onRename:x,onReorder:p,contextMenu:m,addTooltip:f,...h})=>{const{tabs:j,direction:y,first:S,last:b,key:E,size:R}=e,M={onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,onClose:d,contextMenu:m,onSelect:a,onRename:x,onReorder:p,activeTab:l,addTooltip:f},_=g.useCallback(([O])=>n(E,O),[n]),{props:L}=sr({direction:y,onResize:_,count:2,initialSizes:R!=null?[R]:void 0});let A={};E==1&&(A={...h,className:u.CSS(u.CSS.B("mosaic"))});let $;return j!==void 0?$=o.jsxRuntimeExports.jsx(Dc,{root:e,emptyContent:c,...A,...M}):S!=null&&b!=null?$=o.jsxRuntimeExports.jsxs(or,{id:`mosaic-${E}`,align:"stretch",...L,...A,children:[o.jsxRuntimeExports.jsx(Ss,{...M,root:S,onResize:n},S.key),o.jsxRuntimeExports.jsx(Ss,{...M,root:b,onResize:n},b.key)]}):($=null,console.warn("Mosaic tree is malformed")),$});Ss.displayName="Mosaic";const Rs="pluto-mosaic-tab-drop",Sr="pluto-mosaic-tab-create",kg=(e,t,n)=>{if(me.filterByType(me.FILE_TYPE,t).length>0&&n)return!0;const r=me.filterByType(Rs,t).map(c=>c.key),i=e.filter(c=>!r.includes(c.tabKey)).length>0;return me.filterByType(Sr,t).length>0||r.length>0&&(i||e.length===0)},Dc=g.memo(({root:e,onDrop:t,onCreate:n,activeTab:s,children:r,className:i,onReorder:l,onFileDrop:c,addTooltip:a,...d})=>{const{key:x,tabs:p}=e,[m,f]=g.useState(null),h=c!=null,j=g.useCallback(({items:$})=>kg(p,$,h),[p,h]),y=g.useCallback(({items:$,event:O})=>{if(O==null)return[];const V=Pg(O);f(null);const z=me.filterByType(me.FILE_TYPE,$).length>0,{percents:k}=hi(O),C=p.length===0?"center":gi(k);if(z)return c==null||c(x,C,O),$;const P=me.filterByType(Rs,$);if(P.length>0){const N=P.map(({key:D})=>D)[0];t(x,N,C,V)}const v=me.filterByType(Sr,$);if(v.length>0){const N=v.map(({key:D})=>D);n==null||n(x,C,N)}return P},[t,p.length]),S=g.useCallback(({event:$})=>{if($==null)return;const{percents:O,inSelector:V}=hi($);let z=null;V||(z=p.length===0?"center":gi(O)),f(z)},[p.length]),{startDrag:b,...E}=me.useDragAndDrop({type:"Mosaic",canDrop:j,onDrop:y,onDragOver:S}),R=j(me.useDraggingState()),M=g.useCallback(()=>f(null),[]),_=g.useCallback(($,{tabKey:O})=>{b([{key:O,type:Rs,elementID:$.currentTarget.id}])},[b]),L=g.useCallback(()=>n==null?void 0:n(x,"center"),[x]),A=x==1&&p.length==0;return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:o.jsxRuntimeExports.jsxs(Te.Tabs,{id:`tab-${x}`,tabs:p,className:u.CSS(i,A&&m!=null&&u.CSS.M("drag-over")),onDragLeave:M,selected:e.selected,selectedAltColor:s===e.selected,onDragStart:_,onCreate:L,addTooltip:a,...E,...d,children:[e.selected!=null&&r(p.find($=>$.tabKey===e.selected)),R&&o.jsxRuntimeExports.jsx("div",{style:{zIndex:1e3,position:"absolute",top:0,left:0,width:"100%",height:"100%"}}),m!=null&&o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("mosaic","mask"),style:Mg[m]})]})})});Dc.displayName="MosaicTabLeaf";const Mg={top:{left:"0%",top:"0%",width:"100%",height:"50%"},bottom:{left:"0%",top:"50%",width:"100%",height:"50%"},left:{left:"0%",top:"0%",width:"50%",height:"100%"},right:{left:"50%",top:"0%",width:"50%",height:"100%"},center:{left:"0%",top:"0%",width:"100%",height:"100%"}},hi=e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;return s<24?{percents:{x:.5,y:.5},inSelector:!0}:{percents:{x:n/t.width,y:s/t.height},inSelector:!1}},Pg=e=>{var n;const t=e.target.closest(".pluto-tabs-selector__btn");if(t!=null)return Array.from(((n=t.parentElement)==null?void 0:n.children)??[]).indexOf(t)},_g=e=>e,Lg=e=>1-e,gi=({x:e,y:t})=>{if(e>.33&&e<.66&&t>.33&&t<.66)return"center";const[n,s]=[_g(e),Lg(e)];if(t>n&&t>s)return"bottom";if(t<n&&t<s)return"top";if(t>n&&t<s)return"left";if(t<n&&t>s)return"right";throw new Error("[bug] - invalid insert position")},Ng=({root:e,onSelect:t,children:n})=>{const s=g.useRef(new Map),r=new Set,i=ys(e,l=>{var c;return(c=l.tabs)==null?void 0:c.map(a=>{let d=s.current.get(a.tabKey);return a==null?null:(d==null&&(d=new $c({style:"width: 100%; height: 100%; position: relative;"}),d.el.addEventListener("click",()=>t==null?void 0:t(a.tabKey)),s.current.set(a.tabKey,d)),r.add(a.tabKey),o.jsxRuntimeExports.jsx(Bc,{node:d,children:n({...a,visible:a.tabKey===l.selected})},a.tabKey))})}).flat().filter(l=>l!=null);return s.current.forEach((l,c)=>!r.has(c)&&s.current.delete(c)),[s,i]},Oo=ce.object({key:ce.number(),tabs:ce.array(Te.tabZ).optional(),selected:ce.string().optional(),direction:u.g.direction.optional(),size:ce.number().optional(),get first(){return Oo.optional()},get last(){return Oo.optional()}}),Tg=({allowRename:e=!1,initialTree:t})=>{const[n,s]=g.useState(t);return g.useEffect(()=>s(gs(t)[0]),[t]),{root:n,onDrop:(d,x,p)=>s(m=>Tc(m,x,p,d)[0]),onClose:d=>s(x=>yr(x,d)[0]),onSelect:d=>s(x=>Nc(x,d)),onResize:(d,x)=>s(p=>Ac(p,d,x)),onRename:e?(d,x)=>s(p=>Ic(p,d,x)):void 0}},Ag=Object.freeze(Object.defineProperty({__proto__:null,HAUL_CREATE_TYPE:Sr,HAUL_DROP_TYPE:Rs,Mosaic:Ss,autoSelectTabs:gs,canSplit:Sg,findSelected:js,findTabNode:bn,forEachNode:Bo,insertTab:hs,isEmpty:Rg,mapNodes:ys,moveTab:Tc,nodeZ:Oo,removeTab:yr,renameTab:Ic,resizeNode:Ac,selectTab:Nc,split:yg,updateTab:Eg,use:Tg,usePortal:Ng},Symbol.toStringTag,{value:"Module"})),Ig=({variant:e,className:t,...n})=>o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(t,u.CSS.B("note"),u.CSS.M(e)),align:"stretch",empty:!0,...n}),$g=Object.freeze(Object.defineProperty({__proto__:null,Note:Ig},Symbol.toStringTag,{value:"Module"})),ho={Close:o.jsxRuntimeExports.jsxs("svg",{width:"124",height:"124",viewBox:"0 0 124 124",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsxRuntimeExports.jsx("rect",{x:"26.8701",y:"88.3883",width:"87",height:"11",transform:"rotate(-45 26.8701 88.3883)",fill:"#7E0508"}),o.jsxRuntimeExports.jsx("rect",{x:"26.8701",y:"34.6482",width:"11",height:"87",transform:"rotate(-45 26.8701 34.6482)",fill:"#7E0508"})]}),Minimize:o.jsxRuntimeExports.jsx("svg",{width:"87",height:"11",viewBox:"0 0 87 11",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsxRuntimeExports.jsx("rect",{x:"15",width:"60",height:"11",fill:"#985712"})}),Maximize:o.jsxRuntimeExports.jsxs("svg",{width:"143",height:"143",viewBox:"0 0 143 143",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsxRuntimeExports.jsx("path",{d:"M108.242 32.8833C108.797 32.8817 109.247 33.3317 109.245 33.8862L109.092 87.5891C109.09 88.4786 108.014 88.9223 107.385 88.2933L53.8351 34.7432C53.2061 34.1142 53.6499 33.0387 54.5394 33.0361L108.242 32.8833Z",fill:"#0B650D"}),o.jsxRuntimeExports.jsx("path",{d:"M33.8862 109.245C33.3317 109.247 32.8818 108.797 32.8833 108.242L33.0361 54.5394C33.0387 53.6499 34.1142 53.2061 34.7432 53.8351L88.2934 107.385C88.9223 108.014 88.4786 109.09 87.5891 109.092L33.8862 109.245Z",fill:"#0B650D"})]})},Bg=({disabled:e=[],className:t,focused:n=!0,onMinimize:s,onMaximize:r,onFullscreen:i,onClose:l,...c})=>o.jsxRuntimeExports.jsxs(ne.Space,{size:1.5,x:!0,className:u.CSS(u.CSS.B("macos-controls"),!n&&u.CSS.BM("macos-controls","blurred"),t),...c,children:[o.jsxRuntimeExports.jsx(go,{onClick:l,className:u.CSS.BM("macos-control","close"),disabled:e.includes("close"),children:ho.Close}),o.jsxRuntimeExports.jsx(go,{onClick:s,className:u.CSS.BM("macos-control","minimize"),disabled:e.includes("minimize"),children:ho.Minimize}),o.jsxRuntimeExports.jsx(go,{onClick:i,className:u.CSS.BM("macos-control","maximize"),disabled:e.includes("maximize"),children:ho.Maximize})]}),go=({className:e,disabled:t,color:n,...s})=>o.jsxRuntimeExports.jsx("button",{className:u.CSS(u.CSS.B("macos-control"),u.CSS.disabled(t),e),tabIndex:-1,disabled:t,size:"",...s}),Dg=({disabled:e=[],onMinimize:t,onMaximize:n,onClose:s,onFullscreen:r,focused:i,shade:l=2,...c})=>o.jsxRuntimeExports.jsxs(Is.Pack,{...c,children:[o.jsxRuntimeExports.jsx(jo,{className:u.CSS.BM("windows-control","minimize"),onClick:t,disabled:e.includes("minimize"),shade:l,children:o.jsxRuntimeExports.jsx(K.y4.Subtract,{})}),o.jsxRuntimeExports.jsx(jo,{className:u.CSS.BM("windows-control","maximize"),onClick:n,disabled:e.includes("maximize"),shade:l,children:o.jsxRuntimeExports.jsx(K.y4.Box,{})}),o.jsxRuntimeExports.jsx(jo,{onClick:s,className:u.CSS.BM("windows-control","close"),disabled:e.includes("close"),shade:l,children:o.jsxRuntimeExports.jsx(K.y4.Close,{})})]}),jo=({disabled:e=!1,className:t,...n})=>e?null:o.jsxRuntimeExports.jsx(fe.Icon,{className:u.CSS(u.CSS.B("windows-control"),t),tabIndex:-1,...n}),Oc=u.S.getOS,Og="Windows",zg=({forceOS:e,visibleIfOS:t,...n})=>{const s=Oc({force:e,default:Og});if(t!=null&&t!==s)return null;const r=s==="macOS"?Bg:Dg;return o.jsxRuntimeExports.jsx(r,{...n})},Vg=Object.freeze(Object.defineProperty({__proto__:null,Controls:zg,use:Oc},Symbol.toStringTag,{value:"Module"})),Fg=(e,t)=>{const n=s=>o.jsxRuntimeExports.jsx(e,{...t,...s});return n.displayName=e.displayName,n},Hg=Object.freeze(Object.defineProperty({__proto__:null,createComponent:Fg},Symbol.toStringTag,{value:"Module"}));g.createContext({instrumentation:bt.C.NOOP});const Zg=({children:e,...t})=>{const{path:n}=Q.useUnidirectional({type:ps.Provider.TYPE,schema:ps.providerStateZ,state:t});return o.jsxRuntimeExports.jsx(Q.Composite,{path:n,children:e})},Kg="data:video/mp2t;base64,Ly8gQ29weXJpZ2h0IDIwMjUgU3lubmF4IExhYnMsIEluYy4KLy8KLy8gVXNlIG9mIHRoaXMgc29mdHdhcmUgaXMgZ292ZXJuZWQgYnkgdGhlIEJ1c2luZXNzIFNvdXJjZSBMaWNlbnNlIGluY2x1ZGVkIGluIHRoZSBmaWxlCi8vIGxpY2Vuc2VzL0JTTC50eHQuCi8vCi8vIEFzIG9mIHRoZSBDaGFuZ2UgRGF0ZSBzcGVjaWZpZWQgaW4gdGhhdCBmaWxlLCBpbiBhY2NvcmRhbmNlIHdpdGggdGhlIEJ1c2luZXNzIFNvdXJjZQovLyBMaWNlbnNlLCB1c2Ugb2YgdGhpcyBzb2Z0d2FyZSB3aWxsIGJlIGdvdmVybmVkIGJ5IHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAsCi8vIGluY2x1ZGVkIGluIHRoZSBmaWxlIGxpY2Vuc2VzL0FQTC50eHQuCgppbXBvcnQgeyBwbHV0byB9IGZyb20gIkAvcGx1dG8vYWV0aGVyIjsKCnBsdXRvLnJlbmRlcigpOwo=",zc=({children:e})=>{const{path:t}=Q.useUnidirectional({type:B.BaseProvider.TYPE,schema:B.providerStateZ$1,state:{}});return o.jsxRuntimeExports.jsx(Q.Composite,{path:t,children:e})},Wg=Object.freeze(Object.defineProperty({__proto__:null,Provider:zc},Symbol.toStringTag,{value:"Module"})),Yg=Object.freeze(Object.defineProperty({__proto__:null,AcquireChannelControl:B.AcquireChannelControl,AuthoritySource:B.AuthoritySource,Chip:B.Chip,Controller:B.Controller,Indicator:B.Indicator,Legend:B.Legend,REGISTRY:B.REGISTRY$15,STATUSES:B.STATUSES,SetChannelValue:B.SetChannelValue,StateProvider:B.StateProvider,acquireChannelControl:B.acquireChannelControl,acquireChannelControlPropsZ:B.acquireChannelControlPropsZ,authoritySource:B.authoritySource,authoritySourceProps:B.authoritySourceProps,chipStateZ:B.chipStateZ,controllerStateZ:B.controllerStateZ,indicatorStateZ:B.indicatorStateZ,legendStateZ:B.legendStateZ,setChannelValue:B.setChannelValue,setChannelValuePropsZ:B.setChannelValuePropsZ,stateProviderStateZ:B.stateProviderStateZ,statusZ:B.statusZ,sugaredStateZ:B.sugaredStateZ},Symbol.toStringTag,{value:"Module"})),Gg=e=>{var t,n;switch(e.variant){case"disabled":return((t=e.data)==null?void 0:t.valid)===!0?{message:"Uncontrolled. Click to take control.",chipColor:"var(--pluto-gray-l12)"}:{message:"No channel connected. This element cannot be controlled.",chipColor:"var(--pluto-gray-l7)",disabled:!0};case"error":return{message:"Not controlled by you. Click to take absolute control.",chipColor:"var(--pluto-error-z)"};case"success":return((n=e.data)==null?void 0:n.authority)===bt.dq.ABSOLUTE_AUTHORITY?{message:"You have absolute control. Click to release.",chipColor:"var(--pluto-secondary-z)",buttonStyle:{background:"var(--pluto-secondary-z-30)"}}:{message:"You're in control. Release schematic to release control.",chipColor:"var(--pluto-primary-z)"};default:return{message:"Unexpected status.",chipColor:"var(--pluto-error-z)"}}},Vc=({source:e,sink:t,className:n,...s})=>{const r=Ae.useMemoDeepEqualProps({source:e,sink:t}),[,{status:i},l]=Q.use$1({type:B.Chip.TYPE,schema:B.chipStateZ,initialState:{triggered:!1,...r,status:{key:"no_chip",variant:"disabled",message:"No chip connected.",time:u.d.now()}}});g.useEffect(()=>{l(m=>({...m,...r}))},[r,l]);const c=g.useCallback(()=>l(m=>({...m,triggered:!m.triggered})),[l]),{message:a,chipColor:d,buttonStyle:x,disabled:p}=Gg(i);return o.jsxRuntimeExports.jsx(fe.Icon,{variant:"text",className:u.CSS(u.CSS.B("control-chip"),n),disabled:p,onClick:c,tooltip:o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:a}),style:x,...s,children:o.jsxRuntimeExports.jsx(K.y4.Circle,{color:d})})},Fc=g.createContext({needsControlOf:[]}),Hc=()=>g.use(Fc),qg=({children:e,onStatusChange:t,...n})=>{const s=Ae.useMemoDeepEqualProps(n),[{path:r},{status:i,needsControlOf:l},c]=Q.use$1({type:B.Controller.TYPE,schema:B.controllerStateZ,initialState:s});return g.useEffect(()=>{i!=null&&(t==null||t(i))},[i,t]),g.useEffect(()=>{c(a=>({...a,...s}))},[s,c]),g.useEffect(()=>()=>t==null?void 0:t("released"),[]),o.jsxRuntimeExports.jsxs(Fc,{value:{needsControlOf:l},children:[o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:e}),";"]})},Zc=({colorSource:e,statusSource:t})=>{var c;const n=Ae.useMemoDeepEqualProps({colorSource:e,statusSource:t}),[,{color:s,status:r},i]=Q.use$1({type:B.Indicator.TYPE,initialState:{...n,status:{key:"no_chip",variant:"warning",message:"No chip connected.",time:u.d.now()}},schema:B.indicatorStateZ});g.useEffect(()=>{i(a=>({...a,...n}))},[n,i]);let l;return((c=r.data)==null?void 0:c.color)!=null?l=u.od.colorZ.parse(r.data.color):s!=null&&!u.od.isZero(s)?l=s:l="var(--pluto-gray-l10)",o.jsxRuntimeExports.jsxs(fe.Dialog,{location:{x:"center",y:"bottom"},children:[o.jsxRuntimeExports.jsx(K.Text,{level:"p",children:r.message}),o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("indicator"),style:{backgroundColor:u.od.cssString(l),flexGrow:1}})]})},Xg=e=>{const{needsControlOf:t}=Hc(),[,{states:n},s]=Q.use$1({type:B.Legend.TYPE,schema:B.legendStateZ,initialState:{states:[],needsControlOf:t}});g.useEffect(()=>{s(l=>({...l,needsControlOf:t}))},[t]);const i=u.c.unique(n.map(l=>l.subject.key)).map(l=>{const c=n.find(a=>a.subject.key===l);if(c==null)throw new bt.ti("Legend subject not found");return{key:c.subject.key,label:c.subject.name,color:c.subjectColor}});return o.jsxRuntimeExports.jsx(ar,{data:i,...e})},Kc=({children:e})=>{const[{path:t}]=Q.use$1({type:B.StateProvider.TYPE,schema:B.stateProviderStateZ,initialState:{}});return o.jsxRuntimeExports.jsx(Q.Composite,{path:t,children:e})},Ug=Object.freeze(Object.defineProperty({__proto__:null,Chip:Vc,Controller:qg,Indicator:Zc,Legend:Xg,StateProvider:Kc,useContext:Hc},Symbol.toStringTag,{value:"Module"})),Wc=e=>{const t=({disabled:n=!1,...s})=>n?s.children:o.jsxRuntimeExports.jsx(e,{...s});return t.displayName=e.displayName,t},Jg=Wc(zc),Qg=Wc(Q.Provider$2),e0=({children:e,connParams:t,workerEnabled:n=!0,workerURL:s,theming:r,tooltip:i,triggers:l,alamos:c,haul:a,channelAlias:d,telem:x,color:p})=>o.jsxRuntimeExports.jsx(De.Provider,{...l,children:o.jsxRuntimeExports.jsx(fe.Config,{...i,children:o.jsxRuntimeExports.jsx(me.Provider,{...a,children:o.jsxRuntimeExports.jsx(Q.Provider$1,{url:s??Kg,enabled:n,children:o.jsxRuntimeExports.jsx(Qg,{workerKey:"vis",children:o.jsxRuntimeExports.jsx(Zg,{...c,children:o.jsxRuntimeExports.jsx(Ce.Aggregator,{children:o.jsxRuntimeExports.jsx(Dl,{connParams:t,children:o.jsxRuntimeExports.jsx(Vl,{...d,children:o.jsxRuntimeExports.jsx(Ge.Provider,{...p,children:o.jsxRuntimeExports.jsx(Q.Provider,{...r,children:o.jsxRuntimeExports.jsx(Jg,{...x,children:o.jsxRuntimeExports.jsx(Kc,{children:e})})})})})})})})})})})})}),t0=Object.freeze(Object.defineProperty({__proto__:null,Provider:e0},Symbol.toStringTag,{value:"Module"})),n0=({value:e})=>o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("progress"),children:o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("progress-bar"),style:{width:`${e}%`}})}),s0=Object.freeze(Object.defineProperty({__proto__:null,Progress:n0},Symbol.toStringTag,{value:"Module"})),vn="range",Rr=[{key:"name",name:"Name"}],Cs=({items:e},t)=>{const n=me.filterByType(vn,e);return n.length>0&&!n.every(s=>t.includes(s.key))},o0=({onChange:e,className:t,value:n,...s})=>{const r=qe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=me.useDragAndDrop({type:"Ranger.SelectMultiple",canDrop:g.useCallback(m=>Cs(m,Pe.t.toArray(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=me.filterByType(vn,m);if(f.length===0)return[];const h=u.c.unique([...Pe.t.toArray(n),...f.map(j=>j.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),d=me.useDraggingState(),x=g.useCallback(({dropped:m})=>{e(Pe.t.toArray(n).filter(f=>!m.some(h=>h.key===f)),{clickedIndex:null,clicked:null,entries:[]})},[e,n]),p=g.useCallback((m,f)=>l([{key:f,type:vn}],x),[l,x]);return o.jsxRuntimeExports.jsx(an,{className:u.CSS(t,u.CSS.dropRegion(Cs(d,Pe.t.toArray(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.ranges,onChange:e,columns:Rr,emptyContent:i,entryRenderKey:"name",...a,...s})},Yc=({value:e,onChange:t})=>{const n=qe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),r=g.useId(),i=g.useMemo(()=>({key:r,type:"Ranger.SelectMultiple"}),[r]),{startDrag:l,...c}=me.useDragAndDrop({type:"Ranger.SelectSingle",canDrop:g.useCallback(x=>Cs(x,Pe.t.toArray(e)),[e]),onDrop:g.useCallback(({items:x})=>{const p=me.filterByType(vn,x);return p.length===0?[]:(t(p[0].key,{clickedIndex:null,clicked:null,entries:[]}),p)},[i,t])}),a=me.useDraggingState(),d=g.useCallback(()=>e!=null&&l([{type:vn,key:e}]),[l,e]);return{emptyContent:s,dragging:a,...c,onDragStart:d,searcher:n==null?void 0:n.ranges}},r0=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=Yc({value:t,onChange:e});return o.jsxRuntimeExports.jsx(mt,{data:s,className:u.CSS(n,u.CSS.dropRegion(Cs(i,Pe.t.toArray(t)))),value:t,onChange:e,columns:Rr,entryRenderKey:"name",...l,...r})},i0=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=Yc({value:t,onChange:n});return o.jsxRuntimeExports.jsx(mt,{data:e,value:t,onChange:n,columns:Rr,entryRenderKey:"name",...i,...s})},l0=[{key:"color",name:"Color",width:50,render:e=>o.jsxRuntimeExports.jsx(K.y4.Circle,{style:{fontSize:10,marginLeft:10,marginRight:30},color:e.entry.color})},{key:"name",name:"Name"}],c0=e=>{const t=qe();return o.jsxRuntimeExports.jsx(an,{...e,searcher:t==null?void 0:t.labels,columns:l0,renderTag:n=>n.entry==null?o.jsxRuntimeExports.jsx(wn,{color:"gray",children:n.entryKey}):o.jsxRuntimeExports.jsx(wn,{color:n.entry.color,children:n.entry.name})})},a0=({timeRange:e,level:t="p",shade:n=9,showSpan:s=!1,labeled:r=!1,...i})=>{const l=new u.d(e.start),c=l.isToday?"time":"dateTime",a=new u.d(e.end),d=a.equals(u.d.MAX),x=a.span(l)<u.g$2.DAY?"time":"dateTime",p=l.span(a);let m=o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",size:"small",children:[l.isToday&&o.jsxRuntimeExports.jsx(K.Text,{level:t,shade:n,weight:450,children:"Today"}),o.jsxRuntimeExports.jsx(_o.DateTime,{level:t,displayTZ:"local",format:c,shade:n,weight:450,children:l})]}),f=o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[d?o.jsxRuntimeExports.jsx(K.Text,{level:t,children:"Now"}):o.jsxRuntimeExports.jsx(_o.DateTime,{level:t,displayTZ:"local",format:x,shade:n,weight:450,children:a}),!p.isZero&&s&&o.jsxRuntimeExports.jsxs(K.Text,{level:t,shade:n,weight:450,children:["(",l.span(a).truncate(u.g$2.MILLISECOND).toString(),")"]})]});r&&(m=o.jsxRuntimeExports.jsx(he.Item,{label:"Start",showHelpText:!1,children:m}),f=o.jsxRuntimeExports.jsx(he.Item,{label:"End",showHelpText:!1,children:f}));const h=u.CSS.levelSizeVar(t);return o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,size:"small",className:u.CSS(u.CSS.B("time-range-chip")),align:"center",...i,children:[m,o.jsxRuntimeExports.jsx(K.y4.Arrow.Right,{color:"var(--pluto-gray-l9)",style:{width:h,height:h}}),f]})},u0=Object.freeze(Object.defineProperty({__proto__:null,SelectButton:i0,SelectLabels:c0,SelectMultiple:o0,SelectSingle:r0,TimeRangeChip:a0},Symbol.toStringTag,{value:"Module"})),d0=({steps:e,value:t,onChange:n,...s})=>{const r=e.findIndex(i=>i.key===t);return o.jsxRuntimeExports.jsx(ne.Space,{x:!0,align:"center",className:u.CSS.B("steps"),...s,children:e.map((i,l)=>o.jsxRuntimeExports.jsxs(g.Fragment,{children:[o.jsxRuntimeExports.jsxs(fe.Button,{onClick:()=>n(i.key),variant:"outlined",disabled:l>r,children:[l+1,". ",i.title]},i.key),l!==e.length-1&&o.jsxRuntimeExports.jsx(K.y4.Arrow.Right,{style:{fontSize:"15px",color:"var(--pluto-gray-l10)"}})]},i.key))})},x0=Object.freeze(Object.defineProperty({__proto__:null,Steps:d0},Symbol.toStringTag,{value:"Module"})),p0=({children:e,className:t,visible:n,...s})=>{const[{path:r},,i]=Q.use$1({type:B.Table.TYPE,schema:B.Table.stateZ,initialState:{region:u.Pt.ZERO,visible:n}});g.useEffect(()=>{i(c=>({...c,visible:n}))},[n]);const l=In(c=>i(a=>({...a,region:c})));return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx("div",{ref:l,style:{right:0,bottom:0,position:"absolute",top:6,left:6}}),o.jsxRuntimeExports.jsx("table",{className:u.CSS(u.CSS.B("table"),t),...s,children:o.jsxRuntimeExports.jsx("tbody",{children:o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:e})})})]})},m0=({children:e,className:t,size:n,index:s,onResize:r,onSelect:i,position:l,...c})=>o.jsxRuntimeExports.jsxs("tr",{className:u.CSS(u.CSS.BE("table","row"),t),...c,children:[r!=null&&o.jsxRuntimeExports.jsx(qc,{onSelect:i,index:s,value:n,onChange:r,position:l,direction:"y"}),e]}),Cr=({ref:e,children:t,className:n,selected:s=!1,...r})=>o.jsxRuntimeExports.jsx("td",{ref:e,...r,className:u.CSS(u.CSS.BE("table","cell"),u.CSS.selected(s),n),children:t}),Gc="ABCDEFGHIJKLMNOPQRSTUVWXYZ",f0=e=>Gc[e],qc=({value:e,selected:t=!1,index:n,onChange:s,position:r,direction:i="x",onSelect:l})=>{const c=K.useSyncedRef(e),a=g.useRef(e),d=Ge.useCursorDrag({onStart:g.useCallback(()=>{a.current=c.current},[]),onMove:g.useCallback(x=>s(a.current+u.Pt.dim(x,i,!0),n),[s,n])});return o.jsxRuntimeExports.jsxs("td",{id:`resizer-${i}-${n}`,className:u.CSS(u.CSS.BE("table","resizer"),u.CSS.dir(i),u.CSS.selected(t),vt.CONTEXT_TARGET,t&&vt.CONTEXT_SELECTED),style:{[u.g.dimension(i)]:e},onClick:()=>l(n),onContextMenu:()=>l(n),children:[o.jsxRuntimeExports.jsx(K.Text,{level:"p",shade:11,style:{width:"100%",textAlign:"center"},children:i==="x"?Gc[n]:n+1}),o.jsxRuntimeExports.jsx("button",{onClick:x=>x.stopPropagation(),style:{[u.g.location(i)]:r+e},onDragStart:d,draggable:!0})]})},h0=({selected:e,onSelect:t,columns:n,onResize:s})=>{let r=15;return o.jsxRuntimeExports.jsxs("tr",{className:u.CSS(u.CSS.BE("table","row"),u.CSS.BE("table","col-resizer")),children:[o.jsxRuntimeExports.jsx("td",{}),n.map((i,l)=>{const c=r;return r+=i,o.jsxRuntimeExports.jsx(qc,{onSelect:t,position:c,selected:e.includes(l),index:l,value:i,onChange:a=>s(a,l),direction:"x"},l)})]})},g0=Object.freeze(Object.defineProperty({__proto__:null,Cell:Cr,ColumnIndicators:h0,Row:m0,Table:p0,getCellColumn:f0},Symbol.toStringTag,{value:"Module"})),j0=[{key:"standard",name:"Standard"},{key:"scientific",name:"Scientific"},{key:"engineering",name:"Engineering"}],E0=e=>o.jsxRuntimeExports.jsx(ot,{...e,entryRenderKey:"name",data:j0}),Xc=[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],wr=({path:e})=>{var f;const{value:t,onChange:n}=Mt({path:e}),s=B.sourcePipelinePropsZ.parse((f=t.telem)==null?void 0:f.props),r=B.streamChannelValuePropsZ.parse(s.segments.valueStream.props),i=B.stringifyNumberProps.parse(s.segments.stringifier.props),l=B.rollingAverageProps.parse(s.segments.rollingAverage.props),c=h=>{const j=B.sourcePipeline("string",{connections:Xc,segments:{valueStream:B.streamChannelValue({channel:r.channel}),stringifier:B.stringifyNumber({precision:i.precision??2,notation:i.notation}),rollingAverage:B.rollingAverage({windowSize:l.windowSize??1}),...h},outlet:"stringifier"});n({...t,telem:j})},a=h=>c({valueStream:B.streamChannelValue({channel:h??0})}),d=h=>c({stringifier:B.stringifyNumber({...i,notation:h})}),x=h=>c({stringifier:B.stringifyNumber({...i,precision:h})}),p=h=>c({rollingAverage:B.rollingAverage({windowSize:h})}),m=Bs(r.channel);return g.useEffect(()=>n({...t,tooltip:[m]}),[m]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(he.Item,{label:"Input Channel",grow:!0,children:o.jsxRuntimeExports.jsx($t,{value:r.channel,onChange:a})}),o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,children:[o.jsxRuntimeExports.jsx(he.Item,{label:"Notation",children:o.jsxRuntimeExports.jsx(E0,{value:i.notation,onChange:d})}),o.jsxRuntimeExports.jsx(he.Item,{label:"Precision",align:"start",children:o.jsxRuntimeExports.jsx(he.Numeric,{value:i.precision??2,bounds:{lower:0,upper:10},onChange:x})}),o.jsxRuntimeExports.jsx(he.Item,{label:"Averaging Window",align:"start",children:o.jsxRuntimeExports.jsx(he.Numeric,{value:l.windowSize??1,bounds:{lower:1,upper:100},onChange:p})})]})]})},y0=B.Value.z.partial({color:!0}).extend({level:ce.levelZ.optional()}),br=({aetherKey:e,box:t,telem:n,color:s,precision:r,minWidth:i,level:l="small",backgroundTelem:c,notation:a,location:d})=>{const x=Ae.useMemoDeepEqualProps({box:t,telem:n,color:s,precision:r,level:l,minWidth:i,notation:a,backgroundTelem:c,location:d}),[,p,m]=Q.use$1({aetherKey:e,type:B.Value.TYPE,schema:B.Value.z,initialState:x});return g.useEffect(()=>m(f=>({...f,...x})),[x]),{width:p.width??p.minWidth}},S0=Object.freeze(Object.defineProperty({__proto__:null,TelemForm:wr,VALUE_CONNECTIONS:Xc,corePropsZ:y0,use:br},Symbol.toStringTag,{value:"Module"})),R0=ce.object({value:ce.string(),level:ce.levelZ,weight:ce.weightZ,align:u.K$1.x.or(u.K$1.center),backgroundColor:u.od.crudeZ}),C0=({cellKey:e,onChange:t,value:n,selected:s,onSelect:r,align:i,level:l,weight:c,backgroundColor:a})=>{const d=p=>r(e,p),x=p=>t({level:l,value:p,weight:c,align:i,backgroundColor:a});return o.jsxRuntimeExports.jsx(Cr,{id:e,className:u.CSS(vt.CONTEXT_TARGET,s&&vt.CONTEXT_SELECTED,u.CSS.BEM("table","cell","text")),selected:s,onClick:d,onContextMenu:d,style:{backgroundColor:u.od.cssString(a)},children:o.jsxRuntimeExports.jsx(K.Editable,{level:l,value:n,weight:c,onChange:x,style:{justifyContent:i},allowEmpty:!0,outline:!1})})},w0=ce.object({telem:B.stringSourceSpecZ,redline:ce.object({bounds:u.G.bounds,gradient:u.od.gradientZ}),level:ce.levelZ,color:ce.string(),units:ce.string()}),b0=({cellKey:e,telem:t,level:n,color:s,redline:{gradient:r,bounds:i},selected:l,box:c,onSelect:a})=>{const{width:d}=br({aetherKey:e,box:c,telem:t,level:n,color:s,backgroundTelem:B.sourcePipeline("color",{connections:[{from:"source",to:"scale"},{from:"scale",to:"gradient"}],segments:{source:t,scale:B.scaleNumber({scale:u.A.Scale.scale(i).scale(0,1).transform}),gradient:B.colorGradient({gradient:r})},outlet:"gradient"}),location:{x:"center",y:"center"}}),x=p=>a(e,p);return o.jsxRuntimeExports.jsx(Cr,{id:e,selected:l,onClick:x,onContextMenu:x,style:{height:"5rem",width:d},className:u.CSS(vt.CONTEXT_TARGET,l&&vt.CONTEXT_SELECTED,u.CSS.BEM("table","cell","value"))})},v0=({onVariantChange:e})=>{const t=g.useCallback(({tabKey:s})=>{switch(s){case"telem":return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(wr,{path:""})});case"redline":return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(k0,{})});default:return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,grow:!0,empty:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,children:[o.jsxRuntimeExports.jsx(he.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Uc,{onChange:e,value:"value"})}),o.jsxRuntimeExports.jsx(we,{hideIfNull:!0,label:"Color",align:"start",padHelpText:!1,path:"color",children:({value:r,onChange:i,variant:l,...c})=>o.jsxRuntimeExports.jsx(Ge.Swatch,{value:r??u.od.setAlpha(u.od.ZERO,1),onChange:i,...c,bordered:!0})}),o.jsxRuntimeExports.jsx(we,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:r=>o.jsxRuntimeExports.jsx(un,{...r})})]})})}},[]),n=Te.useStatic({tabs:[{tabKey:"style",name:"Style"},{tabKey:"telem",name:"Telemetry"},{tabKey:"redline",name:"Redline"}],content:t});return o.jsxRuntimeExports.jsx(Te.Tabs,{...n})},k0=()=>{const{set:e,get:t}=ft(),n=Cc("redline.bounds"),s=u.A.Scale.scale(0,1).scale(n);return o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,grow:!0,children:[o.jsxRuntimeExports.jsx(Ze,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Lower",path:"redline.bounds.lower"}),o.jsxRuntimeExports.jsx(we,{path:"redline.gradient",label:"Gradient",align:"start",padHelpText:!1,children:({value:r,onChange:i})=>o.jsxRuntimeExports.jsx(Ge.GradientPicker,{value:Be.J.copy(r),scale:s,onChange:l=>{const a={...t("redline.bounds").value},d=l.map(j=>j.position),x=s.pos(Math.max(...d)),p=s.pos(Math.min(...d)),m=x>a.upper,f=p<a.lower;m&&(l[l.length-1].position=1,a.upper=x),f&&(l[0].position=0,a.lower=p);const h=l.map(j=>({...j,color:u.od.hex(j.color)}));m||f?e("redline",{bounds:a,gradient:h}):i(l.map(j=>({...j,color:u.od.hex(j.color)})))}})}),o.jsxRuntimeExports.jsx(Ze,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Upper",path:"redline.bounds.upper"})]})},M0=({onVariantChange:e})=>o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,grow:!0,style:{padding:"2rem"},children:[o.jsxRuntimeExports.jsx(he.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Uc,{onChange:e,value:"text"})}),o.jsxRuntimeExports.jsx(gr,{path:"value",label:"Text"}),o.jsxRuntimeExports.jsx(we,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(un,{...t})}),o.jsxRuntimeExports.jsx(we,{path:"weight",label:"Weight",padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(ac,{...t})}),o.jsxRuntimeExports.jsx(we,{path:"align",label:"Alignment",hideIfNull:!0,children:t=>o.jsxRuntimeExports.jsx(zs,{...t})}),o.jsxRuntimeExports.jsx(we,{path:"backgroundColor",label:"Background",align:"start",padHelpText:!1,children:({value:t,onChange:n})=>o.jsxRuntimeExports.jsx(Ge.Swatch,{value:t,onChange:n})})]}),P0=[{key:"text",name:"Text"},{key:"value",name:"Value"}],Uc=e=>o.jsxRuntimeExports.jsx(ot,{...e,data:P0,allowMultiple:!1,entryRenderKey:"name"}),_0=["text","value"],L0=ce._enum(_0),N0={key:"value",name:"Value",Form:v0,Cell:b0,defaultProps:e=>({telem:B.sourcePipeline("string",{connections:[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],segments:{valueStream:B.streamChannelValue({channel:0}),rollingAverage:B.rollingAverage({windowSize:1}),stringifier:B.stringifyNumber({precision:2,notation:"standard"})},outlet:"stringifier"}),redline:{bounds:{lower:0,upper:1},gradient:[]},color:u.od.hex(e.colors.gray.l10),level:"h5",units:""}),schema:w0},T0={key:"text",name:"Text",Form:M0,Cell:C0,defaultProps:()=>({value:"",level:"h5",units:"",weight:400,align:"center",backgroundColor:"#00000000"}),schema:R0},A0={text:T0,value:N0},I0=Object.freeze(Object.defineProperty({__proto__:null,CELLS:A0,variantZ:L0},Symbol.toStringTag,{value:"Module"})),ji=({sourcePos:e,targetPos:t,next:n,prev:s})=>{const r=Nt(e,...n);return u.K.distance(r,t)<1?!0:(console.warn("Connector is out of sync with target"),console.log("Theoretical target",r),console.log("Actual target",t),console.log("Segments",n),console.log("Prev segments",s),!1)},Ei=({sourceStumpTip:e,sourceOrientation:t,sourceBox:n,targetStumpTip:s,targetOrientation:r,targetBox:i})=>{if(!$0({sourcePos:e,sourceOrientation:t,targetPos:s}))return;const l=u.g.construct(t),c=u.g.swap(l);let a=At(c,s[c]-e[c]);const d=u.Pt.loc(n,a);if(u.K$1.swap(t)===r){const x=u.Pt.loc(i,u.K$1.swap(a));Math.abs(d-x)<Fe&&(a=u.K$1.swap(a))}return{direction:c,length:d-e[c]+Dt(a,Fe)}},zo=ce.object({direction:u.g.direction,length:ce.number()}),Nt=(e,...t)=>{let n=e;for(const s of t)n=u.K.translate(n,s.direction,s.length);return n},Jc=(e,t,n,s)=>{try{let r=e;const i=[e,...t.map(f=>(r=u.K.translate(r,f.direction,f.length),r))];if(!s)return i;const l=t[0],c=At(l.direction,l.length),a=yi(c),d=4*(2-n**.5);i[0]=u.K.translate(i[0],{[l.direction]:-1*a*d,[u.g.swap(l.direction)]:0});const x=t[t.length-1],p=At(x.direction,x.length),m=yi(p);return i[i.length-1]=u.K.translate(i[i.length-1],{[x.direction]:m*d,[u.g.swap(x.direction)]:0}),i}catch{return[]}},Fe=10,yi=e=>e==="top"||e==="left"?-1:1,Dt=(e,t)=>e==="top"||e==="left"?-t:t,At=(e,t)=>e==="x"?t>0?"right":"left":t>0?"bottom":"top",Rt=e=>At(e.direction,e.length),$0=({sourcePos:e,targetPos:t,sourceOrientation:n})=>{const s=u.g.construct(n),r=t[s]-e[s];return Dt(n,r)<0},qn=e=>({direction:u.g.construct(e),length:Dt(e,Fe)}),Si={top:qn("top"),bottom:qn("bottom"),left:qn("left"),right:qn("right")},B0=4,D0=.25,Zs=e=>Vo(O0(Vo(e))),O0=e=>{const t=[...e],n=e.findIndex((s,r)=>{const i=Math.abs(s.length);if(i<B0){if(r===0||r===e.length-1)return!1;if(i<D0)return!0;if(e.length<=3)return!1;if(r+2<e.length){const l=t[r+2];if(l.direction!==s.direction)return!1;t[r+2]={...l,length:l.length+s.length}}else{const l=t[r-2];if(l.direction!==s.direction)return!1;t[r-2]={...l,length:l.length+s.length}}return!0}return!1});return n!==-1&&t.splice(n,1),t},Vo=e=>{const t=[...e];return e.findIndex((s,r)=>{const i=t[r-1];if(r===0||s.direction!==i.direction)return!1;if(r===1){const l=r-1,c=r,a=Rt(i),d=Rt(s);if(a===d)return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0;if(Math.abs(i.length)===Fe)return!1;const x=Dt(a,Fe),p=t[l].length-x,m=t[c].length+p;return Math.abs(m)<Fe?!1:(t[l]={...t[l],length:x},t[c]={...t[c],length:m},!0)}if(r===e.length-1){const l=r,c=r-1,a=Rt(s),d=Rt(i);if(a===d)return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0;if(Math.abs(s.length)===Fe)return!1;const x=Dt(a,Fe),p=t[l].length-x,m=t[c].length+p;return Math.abs(m)<Fe?!1:(t[l]={...t[l],length:x},t[c]={...t[c],length:m},!0)}return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0})!==-1?Vo(t):t},qt=e=>Zs(z0(e)),z0=({sourceBox:e,targetBox:t,sourcePos:n,targetPos:s,targetOrientation:r,sourceOrientation:i})=>{let l=i,c=r,a={...Si[i]},d=Nt(n,a);const x={...Si[r]};let p=Nt(s,x);const m=Math.abs(d.x-p.x),f=Math.abs(d.y-p.y);m<2*Fe&&f<10&&(a.length-=m/2,x.length+=m/2,d=Nt(n,a),p=Nt(s,x));const h=[a],j=Ei({sourceStumpTip:d,sourceOrientation:i,sourceBox:e,targetStumpTip:p,targetOrientation:r,targetBox:t});j!=null&&(h.push(j),d=Nt(d,j),l=Rt(j),a=j);const y=Ei({sourceStumpTip:p,sourceOrientation:c,sourceBox:t,targetStumpTip:d,targetOrientation:l,targetBox:e});y!=null&&(p=Nt(p,y),c=At(y.direction,y.length));const S=()=>{y!=null&&(y.length*=-1,h.push(y)),x.length*=-1,h.push(x)};if(u.K$1.swap(l)===r){const L=u.g.construct(l),A=(p[L]-d[L])/2;h.push({direction:L,length:A});const $=u.g.swap(L);return h.push({direction:$,length:p[$]-d[$]}),h.push({direction:L,length:A}),S(),h}const b=p[a.direction]-d[a.direction];let E=u.g.swap(a.direction);const R=d[E]-p[E];let M;At(a.direction,b)===l&&At(E,R)===c?M={direction:a.direction,length:b}:(M={direction:E,length:p[E]-d[E]},E=u.g.swap(E)),h.push(M);const _={direction:E,length:p[E]-d[E]};return h.push(_),S(),h},V0=e=>Zs(F0(e)),F0=({segments:e,index:t,magnitude:n})=>{const s=[...e],r=s[t],i=u.g.swap(r.direction),l=Rt(r);if(t===0){s.unshift({direction:i,length:n});const c=Dt(l,Fe);s.unshift({direction:r.direction,length:c}),t+=2,s[t]={...s[t],length:s[t].length-c}}else s[t-1]={direction:s[t-1].direction,length:s[t-1].length+n};if(t===s.length-1){s.push({direction:i,length:-n});const c=Dt(l,Fe);s.push({direction:r.direction,length:c}),s[t]={...s[t],length:s[t].length-c}}else s[t+1]={direction:s[t+1].direction,length:s[t+1].length-n};return s},H0=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n],n))return n;return-1},Z0=(e,t,n=!1,...s)=>{const r=(i,l)=>!s.includes(l)&&t(i,l);return n?H0(e,r):e.findIndex(r)},K0=({delta:e,segments:t})=>Zs(Qc(e,t,!1)),W0=({delta:e,segments:t})=>Zs(Qc(e,t,!0)),Qc=(e,t,n)=>{let s=[...t];return e.x!==0&&(s=Ci("x",e,s,n)),e.y!==0&&(s=Ci("y",e,s,n)),s},Ri=(e,t,n)=>{if(t.direction!==e)return!1;const s={...t,length:t.length-n[e]},r=Rt(t),i=Rt(s),l=Math.abs(s.length),c=Math.abs(t.length);return(l>c||l>Fe)&&r===i},Ci=(e,t,n,s)=>{const r=u.g.swap(e),i=s?n.length-1:0,l=n[i];if(Ri(e,l,t)){const p=n[n.length-1];return p.direction===e&&Math.abs(l.length)<Fe?(n[n.length-1]={...p,length:p.length-t[e]},n):(n[i]={...l,length:l.length-t[e]},n)}const c=s?0:n.length-1,d=Z0(n,p=>p.direction===e,s,i);if(d===c){const p=n[c];return Ri(e,p,t)?(n[c]={...p,length:p.length-t[e]},n):(l.direction===e&&Math.abs(l.length)>p.length?n[i]={...l,length:l.length-t[e]}:n[c]={...p,length:p.length-t[e]},n)}if(d===-1)return n.length===1?n[0].direction===e?[{direction:e,length:n[0].length-t[e]}]:[{direction:r,length:n[0].length/2},{direction:e,length:-t[e]},{direction:r,length:n[0].length/2}]:l.direction===e?(n[i]={...l,length:l.length-t[e]},n):[{direction:r,length:n[0].length},{direction:e,length:-t[e]},...n.slice(1)];const x=n[d];return n[d]={...x,length:x.length-t[e]},n},Y0=ce.object({position:u.K.xy,zoom:ce.number()}),ea=ce.object({color:u.od.crudeZ,variant:ce.string().optional(),segments:ce.array(zo)}),G0=ea.extend({key:ce.string(),source:ce.string(),target:ce.string(),segments:ce.array(zo),color:u.od.crudeZ,id:ce.string(),data:ce.object({segments:ce.array(zo),color:u.od.crudeZ,variant:ce.string().optional()}).optional(),selected:ce.boolean(),sourceHandle:ce.string().nullable().optional(),targetHandle:ce.string().nullable().optional()}),q0=ce.object({key:ce.string(),position:u.K.xy,selected:ce.boolean().optional(),zIndex:ce.number().optional(),type:ce.string().optional(),data:u.p.optional(),measured:ce.object({width:ce.number().optional(),height:ce.number().optional()}).optional()}),vr=(e,t)=>e.map(n=>({id:n.key,type:"custom",zIndex:n.zIndex,measured:{...n.measured},position:{...n.position},selected:n.selected,data:{},dragHandle:t})),kr=e=>e.map(({segments:t,color:n,variant:s,...r})=>({...r,id:r.key,data:{segments:t,color:n,variant:s}})),ta=e=>e.map(t=>({key:t.id,...t})),na=(e,t)=>e.map(n=>{var s,r,i;return n.data??(n.data={segments:[],color:t,variant:"pipe"}),{key:n.id,segments:((s=n.data)==null?void 0:s.segments)??[],selected:n.selected??!1,color:((r=n.data)==null?void 0:r.color)??t,variant:((i=n.data)==null?void 0:i.variant)??"pipe",...n}}),sa=e=>({...e.position,zoom:e.zoom}),oa=e=>({position:u.K.construct(e),zoom:e.zoom}),ra=(e,t)=>ta(t(vr(e))),cs=(e,t,n)=>na(t(kr(e)),n),X0=(e,t="x")=>{if(e.length===0)return[];const n=u.K$1.construct(t),s=u.K$1.swap(n);return e.sort((r,i)=>u.Pt.loc(r.box,n)-u.Pt.loc(i.box,n)),e.forEach((r,i)=>{if(i===0)return;const c=e[i-1].handles.find(f=>f.orientation===s),a=r.handles.find(f=>f.orientation===n);if(c==null||a==null)return;const d=c.absolutePosition,x=a.absolutePosition,p=u.K.set(u.K.translation(x,d),t,0),m=u.K.translate(u.Pt.topLeft(r.box),p);r.box=u.Pt.construct(m,u.Pt.dims(r.box))}),e};function $e(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=$e(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var U0={value:()=>{}};function Ks(){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 as(n)}function as(e){this._=e}function J0(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",r=n.indexOf(".");if(r>=0&&(s=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}as.prototype=Ks.prototype={constructor:as,on:function(e,t){var n=this._,s=J0(e+"",n),r,i=-1,l=s.length;if(arguments.length<2){for(;++i<l;)if((r=(e=s[i]).type)&&(r=Q0(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<l;)if(r=(e=s[i]).type)n[r]=wi(n[r],e.name,t);else if(t==null)for(r in n)n[r]=wi(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new as(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),s=0,r,i;s<r;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],s=0,r=i.length;s<r;++s)i[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)}};function Q0(e,t){for(var n=0,s=e.length,r;n<s;++n)if((r=e[n]).name===t)return r.value}function wi(e,t,n){for(var s=0,r=e.length;s<r;++s)if(e[s].name===t){e[s]=U0,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Fo="http://www.w3.org/1999/xhtml";const bi={svg:"http://www.w3.org/2000/svg",xhtml:Fo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ws(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),bi.hasOwnProperty(t)?{space:bi[t],local:e}:e}function ej(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Fo&&t.documentElement.namespaceURI===Fo?t.createElement(e):t.createElementNS(n,e)}}function tj(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ia(e){var t=Ws(e);return(t.local?tj:ej)(t)}function nj(){}function Mr(e){return e==null?nj:function(){return this.querySelector(e)}}function sj(e){typeof e!="function"&&(e=Mr(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=new Array(l),a,d,x=0;x<l;++x)(a=i[x])&&(d=e.call(a,a.__data__,x,i))&&("__data__"in a&&(d.__data__=a.__data__),c[x]=d);return new We(s,this._parents)}function oj(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function rj(){return[]}function la(e){return e==null?rj:function(){return this.querySelectorAll(e)}}function ij(e){return function(){return oj(e.apply(this,arguments))}}function lj(e){typeof e=="function"?e=ij(e):e=la(e);for(var t=this._groups,n=t.length,s=[],r=[],i=0;i<n;++i)for(var l=t[i],c=l.length,a,d=0;d<c;++d)(a=l[d])&&(s.push(e.call(a,a.__data__,d,l)),r.push(a));return new We(s,r)}function ca(e){return function(){return this.matches(e)}}function aa(e){return function(t){return t.matches(e)}}var cj=Array.prototype.find;function aj(e){return function(){return cj.call(this.children,e)}}function uj(){return this.firstElementChild}function dj(e){return this.select(e==null?uj:aj(typeof e=="function"?e:aa(e)))}var xj=Array.prototype.filter;function pj(){return Array.from(this.children)}function mj(e){return function(){return xj.call(this.children,e)}}function fj(e){return this.selectAll(e==null?pj:mj(typeof e=="function"?e:aa(e)))}function hj(e){typeof e!="function"&&(e=ca(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=[],a,d=0;d<l;++d)(a=i[d])&&e.call(a,a.__data__,d,i)&&c.push(a);return new We(s,this._parents)}function ua(e){return new Array(e.length)}function gj(){return new We(this._enter||this._groups.map(ua),this._parents)}function ws(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ws.prototype={constructor:ws,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 jj(e){return function(){return e}}function Ej(e,t,n,s,r,i){for(var l=0,c,a=t.length,d=i.length;l<d;++l)(c=t[l])?(c.__data__=i[l],s[l]=c):n[l]=new ws(e,i[l]);for(;l<a;++l)(c=t[l])&&(r[l]=c)}function yj(e,t,n,s,r,i,l){var c,a,d=new Map,x=t.length,p=i.length,m=new Array(x),f;for(c=0;c<x;++c)(a=t[c])&&(m[c]=f=l.call(a,a.__data__,c,t)+"",d.has(f)?r[c]=a:d.set(f,a));for(c=0;c<p;++c)f=l.call(e,i[c],c,i)+"",(a=d.get(f))?(s[c]=a,a.__data__=i[c],d.delete(f)):n[c]=new ws(e,i[c]);for(c=0;c<x;++c)(a=t[c])&&d.get(m[c])===a&&(r[c]=a)}function Sj(e){return e.__data__}function Rj(e,t){if(!arguments.length)return Array.from(this,Sj);var n=t?yj:Ej,s=this._parents,r=this._groups;typeof e!="function"&&(e=jj(e));for(var i=r.length,l=new Array(i),c=new Array(i),a=new Array(i),d=0;d<i;++d){var x=s[d],p=r[d],m=p.length,f=Cj(e.call(x,x&&x.__data__,d,s)),h=f.length,j=c[d]=new Array(h),y=l[d]=new Array(h),S=a[d]=new Array(m);n(x,p,j,y,S,f,t);for(var b=0,E=0,R,M;b<h;++b)if(R=j[b]){for(b>=E&&(E=b+1);!(M=y[E])&&++E<h;);R._next=M||null}}return l=new We(l,s),l._enter=c,l._exit=a,l}function Cj(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function wj(){return new We(this._exit||this._groups.map(ua),this._parents)}function bj(e,t,n){var s=this.enter(),r=this,i=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),s&&r?s.merge(r).order():r}function vj(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,r=n.length,i=s.length,l=Math.min(r,i),c=new Array(r),a=0;a<l;++a)for(var d=n[a],x=s[a],p=d.length,m=c[a]=new Array(p),f,h=0;h<p;++h)(f=d[h]||x[h])&&(m[h]=f);for(;a<r;++a)c[a]=n[a];return new We(c,this._parents)}function kj(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],r=s.length-1,i=s[r],l;--r>=0;)(l=s[r])&&(i&&l.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(l,i),i=l);return this}function Mj(e){e||(e=Pj);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var n=this._groups,s=n.length,r=new Array(s),i=0;i<s;++i){for(var l=n[i],c=l.length,a=r[i]=new Array(c),d,x=0;x<c;++x)(d=l[x])&&(a[x]=d);a.sort(t)}return new We(r,this._parents).order()}function Pj(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function _j(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Lj(){return Array.from(this)}function Nj(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,i=s.length;r<i;++r){var l=s[r];if(l)return l}return null}function Tj(){let e=0;for(const t of this)++e;return e}function Aj(){return!this.node()}function Ij(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var r=t[n],i=0,l=r.length,c;i<l;++i)(c=r[i])&&e.call(c,c.__data__,i,r);return this}function $j(e){return function(){this.removeAttribute(e)}}function Bj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Dj(e,t){return function(){this.setAttribute(e,t)}}function Oj(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function zj(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Vj(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 Fj(e,t){var n=Ws(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?Bj:$j:typeof t=="function"?n.local?Vj:zj:n.local?Oj:Dj)(n,t))}function da(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Hj(e){return function(){this.style.removeProperty(e)}}function Zj(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Kj(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function Wj(e,t,n){return arguments.length>1?this.each((t==null?Hj:typeof t=="function"?Kj:Zj)(e,t,n??"")):en(this.node(),e)}function en(e,t){return e.style.getPropertyValue(t)||da(e).getComputedStyle(e,null).getPropertyValue(t)}function Yj(e){return function(){delete this[e]}}function Gj(e,t){return function(){this[e]=t}}function qj(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Xj(e,t){return arguments.length>1?this.each((t==null?Yj:typeof t=="function"?qj:Gj)(e,t)):this.node()[e]}function xa(e){return e.trim().split(/^|\s+/)}function Pr(e){return e.classList||new pa(e)}function pa(e){this._node=e,this._names=xa(e.getAttribute("class")||"")}pa.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 ma(e,t){for(var n=Pr(e),s=-1,r=t.length;++s<r;)n.add(t[s])}function fa(e,t){for(var n=Pr(e),s=-1,r=t.length;++s<r;)n.remove(t[s])}function Uj(e){return function(){ma(this,e)}}function Jj(e){return function(){fa(this,e)}}function Qj(e,t){return function(){(t.apply(this,arguments)?ma:fa)(this,e)}}function e2(e,t){var n=xa(e+"");if(arguments.length<2){for(var s=Pr(this.node()),r=-1,i=n.length;++r<i;)if(!s.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Qj:t?Uj:Jj)(n,t))}function t2(){this.textContent=""}function n2(e){return function(){this.textContent=e}}function s2(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function o2(e){return arguments.length?this.each(e==null?t2:(typeof e=="function"?s2:n2)(e)):this.node().textContent}function r2(){this.innerHTML=""}function i2(e){return function(){this.innerHTML=e}}function l2(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function c2(e){return arguments.length?this.each(e==null?r2:(typeof e=="function"?l2:i2)(e)):this.node().innerHTML}function a2(){this.nextSibling&&this.parentNode.appendChild(this)}function u2(){return this.each(a2)}function d2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function x2(){return this.each(d2)}function p2(e){var t=typeof e=="function"?e:ia(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function m2(){return null}function f2(e,t){var n=typeof e=="function"?e:ia(e),s=t==null?m2:typeof t=="function"?t:Mr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function h2(){var e=this.parentNode;e&&e.removeChild(this)}function g2(){return this.each(h2)}function j2(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function E2(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function y2(e){return this.select(e?E2:j2)}function S2(e){return arguments.length?this.property("__data__",e):this.node().__data__}function R2(e){return function(t){e.call(this,t,this.__data__)}}function C2(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 w2(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++s]=i;++s?t.length=s:delete this.__on}}}function b2(e,t,n){return function(){var s=this.__on,r,i=R2(t);if(s){for(var l=0,c=s.length;l<c;++l)if((r=s[l]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},s?s.push(r):this.__on=[r]}}function v2(e,t,n){var s=C2(e+""),r,i=s.length,l;if(arguments.length<2){var c=this.node().__on;if(c){for(var a=0,d=c.length,x;a<d;++a)for(r=0,x=c[a];r<i;++r)if((l=s[r]).type===x.type&&l.name===x.name)return x.value}return}for(c=t?b2:w2,r=0;r<i;++r)this.each(c(s[r],t,n));return this}function ha(e,t,n){var s=da(e),r=s.CustomEvent;typeof r=="function"?r=new r(t,n):(r=s.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function k2(e,t){return function(){return ha(this,e,t)}}function M2(e,t){return function(){return ha(this,e,t.apply(this,arguments))}}function P2(e,t){return this.each((typeof t=="function"?M2:k2)(e,t))}function*_2(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,i=s.length,l;r<i;++r)(l=s[r])&&(yield l)}var ga=[null];function We(e,t){this._groups=e,this._parents=t}function Bn(){return new We([[document.documentElement]],ga)}function L2(){return this}We.prototype=Bn.prototype={constructor:We,select:sj,selectAll:lj,selectChild:dj,selectChildren:fj,filter:hj,data:Rj,enter:gj,exit:wj,join:bj,merge:vj,selection:L2,order:kj,sort:Mj,call:_j,nodes:Lj,node:Nj,size:Tj,empty:Aj,each:Ij,attr:Fj,style:Wj,property:Xj,classed:e2,text:o2,html:c2,raise:u2,lower:x2,append:p2,insert:f2,remove:g2,clone:y2,datum:S2,on:v2,dispatch:P2,[Symbol.iterator]:_2};function Ke(e){return typeof e=="string"?new We([[document.querySelector(e)]],[document.documentElement]):new We([[e]],ga)}function N2(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ue(e,t){if(e=N2(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 r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const T2={passive:!1},kn={capture:!0,passive:!1};function Eo(e){e.stopImmediatePropagation()}function Jt(e){e.preventDefault(),e.stopImmediatePropagation()}function ja(e){var t=e.document.documentElement,n=Ke(e).on("dragstart.drag",Jt,kn);"onselectstart"in t?n.on("selectstart.drag",Jt,kn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ea(e,t){var n=e.document.documentElement,s=Ke(e).on("dragstart.drag",null);t&&(s.on("click.drag",Jt,kn),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 Xn=e=>()=>e;function Ho(e,{sourceEvent:t,subject:n,target:s,identifier:r,active:i,x:l,y:c,dx:a,dy:d,dispatch:x}){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:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:x}})}Ho.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function A2(e){return!e.ctrlKey&&!e.button}function I2(){return this.parentNode}function $2(e,t){return t??{x:e.x,y:e.y}}function B2(){return navigator.maxTouchPoints||"ontouchstart"in this}function ya(){var e=A2,t=I2,n=$2,s=B2,r={},i=Ks("start","drag","end"),l=0,c,a,d,x,p=0;function m(R){R.on("mousedown.drag",f).filter(s).on("touchstart.drag",y).on("touchmove.drag",S,T2).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(R,M){if(!(x||!e.call(this,R,M))){var _=E(this,t.call(this,R,M),R,M,"mouse");_&&(Ke(R.view).on("mousemove.drag",h,kn).on("mouseup.drag",j,kn),ja(R.view),Eo(R),d=!1,c=R.clientX,a=R.clientY,_("start",R))}}function h(R){if(Jt(R),!d){var M=R.clientX-c,_=R.clientY-a;d=M*M+_*_>p}r.mouse("drag",R)}function j(R){Ke(R.view).on("mousemove.drag mouseup.drag",null),Ea(R.view,d),Jt(R),r.mouse("end",R)}function y(R,M){if(e.call(this,R,M)){var _=R.changedTouches,L=t.call(this,R,M),A=_.length,$,O;for($=0;$<A;++$)(O=E(this,L,R,M,_[$].identifier,_[$]))&&(Eo(R),O("start",R,_[$]))}}function S(R){var M=R.changedTouches,_=M.length,L,A;for(L=0;L<_;++L)(A=r[M[L].identifier])&&(Jt(R),A("drag",R,M[L]))}function b(R){var M=R.changedTouches,_=M.length,L,A;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),L=0;L<_;++L)(A=r[M[L].identifier])&&(Eo(R),A("end",R,M[L]))}function E(R,M,_,L,A,$){var O=i.copy(),V=Ue($||_,M),z,k,C;if((C=n.call(R,new Ho("beforestart",{sourceEvent:_,target:m,identifier:A,active:l,x:V[0],y:V[1],dx:0,dy:0,dispatch:O}),L))!=null)return z=C.x-V[0]||0,k=C.y-V[1]||0,function P(v,N,D){var I=V,F;switch(v){case"start":r[A]=P,F=l++;break;case"end":delete r[A],--l;case"drag":V=Ue(D||N,M),F=l;break}O.call(v,R,new Ho(v,{sourceEvent:N,subject:C,target:m,identifier:A,active:F,x:V[0]+z,y:V[1]+k,dx:V[0]-I[0],dy:V[1]-I[1],dispatch:O}),L)}}return m.filter=function(R){return arguments.length?(e=typeof R=="function"?R:Xn(!!R),m):e},m.container=function(R){return arguments.length?(t=typeof R=="function"?R:Xn(R),m):t},m.subject=function(R){return arguments.length?(n=typeof R=="function"?R:Xn(R),m):n},m.touchable=function(R){return arguments.length?(s=typeof R=="function"?R:Xn(!!R),m):s},m.on=function(){var R=i.on.apply(i,arguments);return R===i?m:R},m.clickDistance=function(R){return arguments.length?(p=(R=+R)*R,m):Math.sqrt(p)},m}var tn=0,En=0,fn=0,Sa=1e3,bs,yn,vs=0,Ot=0,Ys=0,Mn=typeof performance=="object"&&performance.now?performance:Date,Ra=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _r(){return Ot||(Ra(D2),Ot=Mn.now()+Ys)}function D2(){Ot=0}function ks(){this._call=this._time=this._next=null}ks.prototype=Ca.prototype={constructor:ks,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?_r():+n)+(t==null?0:+t),!this._next&&yn!==this&&(yn?yn._next=this:bs=this,yn=this),this._call=e,this._time=n,Zo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Zo())}};function Ca(e,t,n){var s=new ks;return s.restart(e,t,n),s}function O2(){_r(),++tn;for(var e=bs,t;e;)(t=Ot-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tn}function vi(){Ot=(vs=Mn.now())+Ys,tn=En=0;try{O2()}finally{tn=0,V2(),Ot=0}}function z2(){var e=Mn.now(),t=e-vs;t>Sa&&(Ys-=t,vs=e)}function V2(){for(var e,t=bs,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:bs=n);yn=e,Zo(s)}function Zo(e){if(!tn){En&&(En=clearTimeout(En));var t=e-Ot;t>24?(e<1/0&&(En=setTimeout(vi,e-Mn.now()-Ys)),fn&&(fn=clearInterval(fn))):(fn||(vs=Mn.now(),fn=setInterval(z2,Sa)),tn=1,Ra(vi))}}function ki(e,t,n){var s=new ks;return t=t==null?0:+t,s.restart(r=>{s.stop(),e(r+t)},t,n),s}var F2=Ks("start","end","cancel","interrupt"),H2=[],wa=0,Mi=1,Ko=2,us=3,Pi=4,Wo=5,ds=6;function Gs(e,t,n,s,r,i){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;Z2(e,n,{name:t,index:s,group:r,on:F2,tween:H2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:wa})}function Lr(e,t){var n=et(e,t);if(n.state>wa)throw new Error("too late; already scheduled");return n}function it(e,t){var n=et(e,t);if(n.state>us)throw new Error("too late; already running");return n}function et(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Z2(e,t,n){var s=e.__transition,r;s[t]=n,n.timer=Ca(i,0,n.time);function i(d){n.state=Mi,n.timer.restart(l,n.delay,n.time),n.delay<=d&&l(d-n.delay)}function l(d){var x,p,m,f;if(n.state!==Mi)return a();for(x in s)if(f=s[x],f.name===n.name){if(f.state===us)return ki(l);f.state===Pi?(f.state=ds,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete s[x]):+x<t&&(f.state=ds,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete s[x])}if(ki(function(){n.state===us&&(n.state=Pi,n.timer.restart(c,n.delay,n.time),c(d))}),n.state=Ko,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ko){for(n.state=us,r=new Array(m=n.tween.length),x=0,p=-1;x<m;++x)(f=n.tween[x].value.call(e,e.__data__,n.index,n.group))&&(r[++p]=f);r.length=p+1}}function c(d){for(var x=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(a),n.state=Wo,1),p=-1,m=r.length;++p<m;)r[p].call(e,x);n.state===Wo&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){n.state=ds,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function xs(e,t){var n=e.__transition,s,r,i=!0,l;if(n){t=t==null?null:t+"";for(l in n){if((s=n[l]).name!==t){i=!1;continue}r=s.state>Ko&&s.state<Wo,s.state=ds,s.timer.stop(),s.on.call(r?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[l]}i&&delete e.__transition}}function K2(e){return this.each(function(){xs(this,e)})}function W2(e,t){var n,s;return function(){var r=it(this,e),i=r.tween;if(i!==n){s=n=i;for(var l=0,c=s.length;l<c;++l)if(s[l].name===t){s=s.slice(),s.splice(l,1);break}}r.tween=s}}function Y2(e,t,n){var s,r;if(typeof n!="function")throw new Error;return function(){var i=it(this,e),l=i.tween;if(l!==s){r=(s=l).slice();for(var c={name:t,value:n},a=0,d=r.length;a<d;++a)if(r[a].name===t){r[a]=c;break}a===d&&r.push(c)}i.tween=r}}function G2(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=et(this.node(),n).tween,r=0,i=s.length,l;r<i;++r)if((l=s[r]).name===e)return l.value;return null}return this.each((t==null?W2:Y2)(n,e,t))}function Nr(e,t,n){var s=e._id;return e.each(function(){var r=it(this,s);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return et(r,s).value[t]}}function ba(e,t){var n;return(typeof t=="number"?B.interpolateNumber:t instanceof B.color?B.interpolateRgb:(n=B.color(t))?(t=n,B.interpolateRgb):B.interpolateString)(e,t)}function q2(e){return function(){this.removeAttribute(e)}}function X2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function U2(e,t,n){var s,r=n+"",i;return function(){var l=this.getAttribute(e);return l===r?null:l===s?i:i=t(s=l,n)}}function J2(e,t,n){var s,r=n+"",i;return function(){var l=this.getAttributeNS(e.space,e.local);return l===r?null:l===s?i:i=t(s=l,n)}}function Q2(e,t,n){var s,r,i;return function(){var l,c=n(this),a;return c==null?void this.removeAttribute(e):(l=this.getAttribute(e),a=c+"",l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c)))}}function e3(e,t,n){var s,r,i;return function(){var l,c=n(this),a;return c==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),a=c+"",l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c)))}}function t3(e,t){var n=Ws(e),s=n==="transform"?_h:ba;return this.attrTween(e,typeof t=="function"?(n.local?e3:Q2)(n,s,Nr(this,"attr."+e,t)):t==null?(n.local?X2:q2)(n):(n.local?J2:U2)(n,s,t))}function n3(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function s3(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function o3(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&s3(e,i)),n}return r._value=t,r}function r3(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&n3(e,i)),n}return r._value=t,r}function i3(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=Ws(e);return this.tween(n,(s.local?o3:r3)(s,t))}function l3(e,t){return function(){Lr(this,e).delay=+t.apply(this,arguments)}}function c3(e,t){return t=+t,function(){Lr(this,e).delay=t}}function a3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?l3:c3)(t,e)):et(this.node(),t).delay}function u3(e,t){return function(){it(this,e).duration=+t.apply(this,arguments)}}function d3(e,t){return t=+t,function(){it(this,e).duration=t}}function x3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?u3:d3)(t,e)):et(this.node(),t).duration}function p3(e,t){if(typeof t!="function")throw new Error;return function(){it(this,e).ease=t}}function m3(e){var t=this._id;return arguments.length?this.each(p3(t,e)):et(this.node(),t).ease}function f3(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;it(this,e).ease=n}}function h3(e){if(typeof e!="function")throw new Error;return this.each(f3(this._id,e))}function g3(e){typeof e!="function"&&(e=ca(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=[],a,d=0;d<l;++d)(a=i[d])&&e.call(a,a.__data__,d,i)&&c.push(a);return new xt(s,this._parents,this._name,this._id)}function j3(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,r=n.length,i=Math.min(s,r),l=new Array(s),c=0;c<i;++c)for(var a=t[c],d=n[c],x=a.length,p=l[c]=new Array(x),m,f=0;f<x;++f)(m=a[f]||d[f])&&(p[f]=m);for(;c<s;++c)l[c]=t[c];return new xt(l,this._parents,this._name,this._id)}function E3(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 y3(e,t,n){var s,r,i=E3(t)?Lr:it;return function(){var l=i(this,e),c=l.on;c!==s&&(r=(s=c).copy()).on(t,n),l.on=r}}function S3(e,t){var n=this._id;return arguments.length<2?et(this.node(),n).on.on(e):this.each(y3(n,e,t))}function R3(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function C3(){return this.on("end.remove",R3(this._id))}function w3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Mr(e));for(var s=this._groups,r=s.length,i=new Array(r),l=0;l<r;++l)for(var c=s[l],a=c.length,d=i[l]=new Array(a),x,p,m=0;m<a;++m)(x=c[m])&&(p=e.call(x,x.__data__,m,c))&&("__data__"in x&&(p.__data__=x.__data__),d[m]=p,Gs(d[m],t,n,m,d,et(x,n)));return new xt(i,this._parents,t,n)}function b3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=la(e));for(var s=this._groups,r=s.length,i=[],l=[],c=0;c<r;++c)for(var a=s[c],d=a.length,x,p=0;p<d;++p)if(x=a[p]){for(var m=e.call(x,x.__data__,p,a),f,h=et(x,n),j=0,y=m.length;j<y;++j)(f=m[j])&&Gs(f,t,n,j,m,h);i.push(m),l.push(x)}return new xt(i,l,t,n)}var v3=Bn.prototype.constructor;function k3(){return new v3(this._groups,this._parents)}function M3(e,t){var n,s,r;return function(){var i=en(this,e),l=(this.style.removeProperty(e),en(this,e));return i===l?null:i===n&&l===s?r:r=t(n=i,s=l)}}function va(e){return function(){this.style.removeProperty(e)}}function P3(e,t,n){var s,r=n+"",i;return function(){var l=en(this,e);return l===r?null:l===s?i:i=t(s=l,n)}}function _3(e,t,n){var s,r,i;return function(){var l=en(this,e),c=n(this),a=c+"";return c==null&&(a=c=(this.style.removeProperty(e),en(this,e))),l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c))}}function L3(e,t){var n,s,r,i="style."+t,l="end."+i,c;return function(){var a=it(this,e),d=a.on,x=a.value[i]==null?c||(c=va(t)):void 0;(d!==n||r!==x)&&(s=(n=d).copy()).on(l,r=x),a.on=s}}function N3(e,t,n){var s=(e+="")=="transform"?Ph:ba;return t==null?this.styleTween(e,M3(e,s)).on("end.style."+e,va(e)):typeof t=="function"?this.styleTween(e,_3(e,s,Nr(this,"style."+e,t))).each(L3(this._id,e)):this.styleTween(e,P3(e,s,t),n).on("end.style."+e,null)}function T3(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function A3(e,t,n){var s,r;function i(){var l=t.apply(this,arguments);return l!==r&&(s=(r=l)&&T3(e,l,n)),s}return i._value=t,i}function I3(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,A3(e,t,n??""))}function $3(e){return function(){this.textContent=e}}function B3(e){return function(){var t=e(this);this.textContent=t??""}}function D3(e){return this.tween("text",typeof e=="function"?B3(Nr(this,"text",e)):$3(e==null?"":e+""))}function O3(e){return function(t){this.textContent=e.call(this,t)}}function z3(e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&O3(r)),t}return s._value=e,s}function V3(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,z3(e))}function F3(){for(var e=this._name,t=this._id,n=ka(),s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],c=l.length,a,d=0;d<c;++d)if(a=l[d]){var x=et(a,t);Gs(a,e,n,d,l,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new xt(s,this._parents,e,n)}function H3(){var e,t,n=this,s=n._id,r=n.size();return new Promise(function(i,l){var c={value:l},a={value:function(){--r===0&&i()}};n.each(function(){var d=it(this,s),x=d.on;x!==e&&(t=(e=x).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(a)),d.on=t}),r===0&&i()})}var Z3=0;function xt(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function ka(){return++Z3}var ct=Bn.prototype;xt.prototype={constructor:xt,select:w3,selectAll:b3,selectChild:ct.selectChild,selectChildren:ct.selectChildren,filter:g3,merge:j3,selection:k3,transition:F3,call:ct.call,nodes:ct.nodes,node:ct.node,size:ct.size,empty:ct.empty,each:ct.each,on:S3,attr:t3,attrTween:i3,style:N3,styleTween:I3,text:D3,textTween:V3,remove:C3,tween:G2,delay:a3,duration:x3,ease:m3,easeVarying:h3,end:H3,[Symbol.iterator]:ct[Symbol.iterator]};function K3(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var W3={time:null,delay:0,duration:250,ease:K3};function Y3(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 G3(e){var t,n;e instanceof xt?(t=e._id,e=e._name):(t=ka(),(n=W3).time=_r(),e=e==null?null:e+"");for(var s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],c=l.length,a,d=0;d<c;++d)(a=l[d])&&Gs(a,e,t,d,l,n||Y3(a,t));return new xt(s,this._parents,e,t)}Bn.prototype.interrupt=K2;Bn.prototype.transition=G3;const Un=e=>()=>e;function q3(e,{sourceEvent:t,target:n,transform:s,dispatch:r}){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:r}})}function ut(e,t,n){this.k=e,this.x=t,this.y=n}ut.prototype={constructor:ut,scale:function(e){return e===1?this:new ut(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ut(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 qs=new ut(1,0,0);Ma.prototype=ut.prototype;function Ma(e){for(;!e.__zoom;)if(!(e=e.parentNode))return qs;return e.__zoom}function yo(e){e.stopImmediatePropagation()}function hn(e){e.preventDefault(),e.stopImmediatePropagation()}function X3(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function U3(){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 _i(){return this.__zoom||qs}function J3(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Q3(){return navigator.maxTouchPoints||"ontouchstart"in this}function e5(e,t,n){var s=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],l=e.invertY(t[1][1])-n[1][1];return e.translate(r>s?(s+r)/2:Math.min(0,s)||Math.max(0,r),l>i?(i+l)/2:Math.min(0,i)||Math.max(0,l))}function Pa(){var e=X3,t=U3,n=e5,s=J3,r=Q3,i=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,a=ls,d=Ks("start","zoom","end"),x,p,m,f=500,h=150,j=0,y=10;function S(C){C.property("__zoom",_i).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",V).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",k).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(C,P,v,N){var D=C.selection?C.selection():C;D.property("__zoom",_i),C!==D?M(C,P,v,N):D.interrupt().each(function(){_(this,arguments).event(N).start().zoom(null,typeof P=="function"?P.apply(this,arguments):P).end()})},S.scaleBy=function(C,P,v,N){S.scaleTo(C,function(){var D=this.__zoom.k,I=typeof P=="function"?P.apply(this,arguments):P;return D*I},v,N)},S.scaleTo=function(C,P,v,N){S.transform(C,function(){var D=t.apply(this,arguments),I=this.__zoom,F=v==null?R(D):typeof v=="function"?v.apply(this,arguments):v,H=I.invert(F),Z=typeof P=="function"?P.apply(this,arguments):P;return n(E(b(I,Z),F,H),D,l)},v,N)},S.translateBy=function(C,P,v,N){S.transform(C,function(){return n(this.__zoom.translate(typeof P=="function"?P.apply(this,arguments):P,typeof v=="function"?v.apply(this,arguments):v),t.apply(this,arguments),l)},null,N)},S.translateTo=function(C,P,v,N,D){S.transform(C,function(){var I=t.apply(this,arguments),F=this.__zoom,H=N==null?R(I):typeof N=="function"?N.apply(this,arguments):N;return n(qs.translate(H[0],H[1]).scale(F.k).translate(typeof P=="function"?-P.apply(this,arguments):-P,typeof v=="function"?-v.apply(this,arguments):-v),I,l)},N,D)};function b(C,P){return P=Math.max(i[0],Math.min(i[1],P)),P===C.k?C:new ut(P,C.x,C.y)}function E(C,P,v){var N=P[0]-v[0]*C.k,D=P[1]-v[1]*C.k;return N===C.x&&D===C.y?C:new ut(C.k,N,D)}function R(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function M(C,P,v,N){C.on("start.zoom",function(){_(this,arguments).event(N).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(N).end()}).tween("zoom",function(){var D=this,I=arguments,F=_(D,I).event(N),H=t.apply(D,I),Z=v==null?R(H):typeof v=="function"?v.apply(D,I):v,ee=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),te=D.__zoom,se=typeof P=="function"?P.apply(D,I):P,oe=a(te.invert(Z).concat(ee/te.k),se.invert(Z).concat(ee/se.k));return function(xe){if(xe===1)xe=se;else{var J=oe(xe),ae=ee/J[2];xe=new ut(ae,Z[0]-J[0]*ae,Z[1]-J[1]*ae)}F.zoom(null,xe)}})}function _(C,P,v){return!v&&C.__zooming||new L(C,P)}function L(C,P){this.that=C,this.args=P,this.active=0,this.sourceEvent=null,this.extent=t.apply(C,P),this.taps=0}L.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,P){return this.mouse&&C!=="mouse"&&(this.mouse[1]=P.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=P.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=P.invert(this.touch1[0])),this.that.__zoom=P,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var P=Ke(this.that).datum();d.call(C,this.that,new q3(C,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:d}),P)}};function A(C,...P){if(!e.apply(this,arguments))return;var v=_(this,P).event(C),N=this.__zoom,D=Math.max(i[0],Math.min(i[1],N.k*Math.pow(2,s.apply(this,arguments)))),I=Ue(C);if(v.wheel)(v.mouse[0][0]!==I[0]||v.mouse[0][1]!==I[1])&&(v.mouse[1]=N.invert(v.mouse[0]=I)),clearTimeout(v.wheel);else{if(N.k===D)return;v.mouse=[I,N.invert(I)],xs(this),v.start()}hn(C),v.wheel=setTimeout(F,h),v.zoom("mouse",n(E(b(N,D),v.mouse[0],v.mouse[1]),v.extent,l));function F(){v.wheel=null,v.end()}}function $(C,...P){if(m||!e.apply(this,arguments))return;var v=C.currentTarget,N=_(this,P,!0).event(C),D=Ke(C.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",ee,!0),I=Ue(C,v),F=C.clientX,H=C.clientY;ja(C.view),yo(C),N.mouse=[I,this.__zoom.invert(I)],xs(this),N.start();function Z(te){if(hn(te),!N.moved){var se=te.clientX-F,oe=te.clientY-H;N.moved=se*se+oe*oe>j}N.event(te).zoom("mouse",n(E(N.that.__zoom,N.mouse[0]=Ue(te,v),N.mouse[1]),N.extent,l))}function ee(te){D.on("mousemove.zoom mouseup.zoom",null),Ea(te.view,N.moved),hn(te),N.event(te).end()}}function O(C,...P){if(e.apply(this,arguments)){var v=this.__zoom,N=Ue(C.changedTouches?C.changedTouches[0]:C,this),D=v.invert(N),I=v.k*(C.shiftKey?.5:2),F=n(E(b(v,I),N,D),t.apply(this,P),l);hn(C),c>0?Ke(this).transition().duration(c).call(M,F,N,C):Ke(this).call(S.transform,F,N,C)}}function V(C,...P){if(e.apply(this,arguments)){var v=C.touches,N=v.length,D=_(this,P,C.changedTouches.length===N).event(C),I,F,H,Z;for(yo(C),F=0;F<N;++F)H=v[F],Z=Ue(H,this),Z=[Z,this.__zoom.invert(Z),H.identifier],D.touch0?!D.touch1&&D.touch0[2]!==Z[2]&&(D.touch1=Z,D.taps=0):(D.touch0=Z,I=!0,D.taps=1+!!x);x&&(x=clearTimeout(x)),I&&(D.taps<2&&(p=Z[0],x=setTimeout(function(){x=null},f)),xs(this),D.start())}}function z(C,...P){if(this.__zooming){var v=_(this,P).event(C),N=C.changedTouches,D=N.length,I,F,H,Z;for(hn(C),I=0;I<D;++I)F=N[I],H=Ue(F,this),v.touch0&&v.touch0[2]===F.identifier?v.touch0[0]=H:v.touch1&&v.touch1[2]===F.identifier&&(v.touch1[0]=H);if(F=v.that.__zoom,v.touch1){var ee=v.touch0[0],te=v.touch0[1],se=v.touch1[0],oe=v.touch1[1],xe=(xe=se[0]-ee[0])*xe+(xe=se[1]-ee[1])*xe,J=(J=oe[0]-te[0])*J+(J=oe[1]-te[1])*J;F=b(F,Math.sqrt(xe/J)),H=[(ee[0]+se[0])/2,(ee[1]+se[1])/2],Z=[(te[0]+oe[0])/2,(te[1]+oe[1])/2]}else if(v.touch0)H=v.touch0[0],Z=v.touch0[1];else return;v.zoom("touch",n(E(F,H,Z),v.extent,l))}}function k(C,...P){if(this.__zooming){var v=_(this,P).event(C),N=C.changedTouches,D=N.length,I,F;for(yo(C),m&&clearTimeout(m),m=setTimeout(function(){m=null},f),I=0;I<D;++I)F=N[I],v.touch0&&v.touch0[2]===F.identifier?delete v.touch0:v.touch1&&v.touch1[2]===F.identifier&&delete v.touch1;if(v.touch1&&!v.touch0&&(v.touch0=v.touch1,delete v.touch1),v.touch0)v.touch0[1]=this.__zoom.invert(v.touch0[0]);else if(v.end(),v.taps===2&&(F=Ue(F,this),Math.hypot(p[0]-F[0],p[1]-F[1])<y)){var H=Ke(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return S.wheelDelta=function(C){return arguments.length?(s=typeof C=="function"?C:Un(+C),S):s},S.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Un(!!C),S):e},S.touchable=function(C){return arguments.length?(r=typeof C=="function"?C:Un(!!C),S):r},S.extent=function(C){return arguments.length?(t=typeof C=="function"?C:Un([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),S):t},S.scaleExtent=function(C){return arguments.length?(i[0]=+C[0],i[1]=+C[1],S):[i[0],i[1]]},S.translateExtent=function(C){return arguments.length?(l[0][0]=+C[0][0],l[1][0]=+C[1][0],l[0][1]=+C[0][1],l[1][1]=+C[1][1],S):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},S.constrain=function(C){return arguments.length?(n=C,S):n},S.duration=function(C){return arguments.length?(c=+C,S):c},S.interpolate=function(C){return arguments.length?(a=C,S):a},S.on=function(){var C=d.on.apply(d,arguments);return C===d?S:C},S.clickDistance=function(C){return arguments.length?(j=(C=+C)*C,S):Math.sqrt(j)},S.tapDistance=function(C){return arguments.length?(y=+C,S):y},S}const Oe={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:s}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Pn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],_a=["Enter"," ","Escape"],La={"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 zt;(function(e){e.Strict="strict",e.Loose="loose"})(zt||(zt={}));var It;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(It||(It={}));var nn;(function(e){e.Partial="partial",e.Full="full"})(nn||(nn={}));const Na={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var St;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(St||(St={}));var Ms;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ms||(Ms={}));var U;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(U||(U={}));const Li={[U.Left]:U.Right,[U.Right]:U.Left,[U.Top]:U.Bottom,[U.Bottom]:U.Top};function Ta(e){return e===null?null:e?"valid":"invalid"}const Aa=e=>"id"in e&&"source"in e&&"target"in e,t5=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Tr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Dn=(e,t=[0,0])=>{const{width:n,height:s}=ht(e),r=e.origin??t,i=n*r[0],l=s*r[1];return{x:e.position.x-i,y:e.position.y-l}},n5=(e,t={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!t.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,r)=>{const i=typeof r=="string";let l=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(l=i?t.nodeLookup.get(r):Tr(r)?r:t.nodeLookup.get(r.id));const c=l?Ps(l,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Xs(s,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Us(n)},On=(e,t={})=>{if(e.size===0)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach(s=>{if(t.filter===void 0||t.filter(s)){const r=Ps(s);n=Xs(n,r)}}),Us(n)},Ar=(e,t,[n,s,r]=[0,0,1],i=!1,l=!1)=>{const c={...zn(t,[n,s,r]),width:t.width/r,height:t.height/r},a=[];for(const d of e.values()){const{measured:x,selectable:p=!0,hidden:m=!1}=d;if(l&&!p||m)continue;const f=x.width??d.width??d.initialWidth??null,h=x.height??d.height??d.initialHeight??null,j=_n(c,on(d)),y=(f??0)*(h??0),S=i&&j>0;(!d.internals.handleBounds||S||j>=y||d.dragging)&&a.push(d)}return a},s5=(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 o5(e,t){const n=new Map,s=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!s||s.has(r.id))&&n.set(r.id,r)}),n}async function r5({nodes:e,width:t,height:n,panZoom:s,minZoom:r,maxZoom:i},l){if(e.size===0)return Promise.resolve(!0);const c=o5(e,l),a=On(c),d=Ir(a,t,n,(l==null?void 0:l.minZoom)??r,(l==null?void 0:l.maxZoom)??i,(l==null?void 0:l.padding)??.1);return await s.setViewport(d,{duration:l==null?void 0:l.duration,ease:l==null?void 0:l.ease,interpolate:l==null?void 0:l.interpolate}),Promise.resolve(!0)}function Ia({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:r,onError:i}){const l=n.get(e),c=l.parentId?n.get(l.parentId):void 0,{x:a,y:d}=c?c.internals.positionAbsolute:{x:0,y:0},x=l.origin??s;let p=r;if(l.extent==="parent"&&!l.expandParent)if(!c)i==null||i("005",Oe.error005());else{const f=c.measured.width,h=c.measured.height;f&&h&&(p=[[a,d],[a+f,d+h]])}else c&&rn(l.extent)&&(p=[[l.extent[0][0]+a,l.extent[0][1]+d],[l.extent[1][0]+a,l.extent[1][1]+d]]);const m=rn(p)?Vt(t,p,l.measured):t;return(l.measured.width===void 0||l.measured.height===void 0)&&(i==null||i("015",Oe.error015())),{position:{x:m.x-a+(l.measured.width??0)*x[0],y:m.y-d+(l.measured.height??0)*x[1]},positionAbsolute:m}}async function i5({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:r}){const i=new Set(e.map(m=>m.id)),l=[];for(const m of n){if(m.deletable===!1)continue;const f=i.has(m.id),h=!f&&m.parentId&&l.find(j=>j.id===m.parentId);(f||h)&&l.push(m)}const c=new Set(t.map(m=>m.id)),a=s.filter(m=>m.deletable!==!1),x=s5(l,a);for(const m of a)c.has(m.id)&&!x.find(h=>h.id===m.id)&&x.push(m);if(!r)return{edges:x,nodes:l};const p=await r({nodes:l,edges:x});return typeof p=="boolean"?p?{edges:x,nodes:l}:{edges:[],nodes:[]}:p}const sn=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Vt=(e={x:0,y:0},t,n)=>({x:sn(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:sn(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function $a(e,t,n){const{width:s,height:r}=ht(n),{x:i,y:l}=n.internals.positionAbsolute;return Vt(e,[[i,l],[i+s,l+r]],t)}const Ni=(e,t,n)=>e<t?sn(Math.abs(e-t),1,t)/t:e>n?-sn(Math.abs(e-n),1,t)/t:0,Ba=(e,t,n=15,s=40)=>{const r=Ni(e.x,s,t.width-s)*n,i=Ni(e.y,s,t.height-s)*n;return[r,i]},Xs=(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)}),Yo=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),Us=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),on=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=Tr(e)?e.internals.positionAbsolute:Dn(e,t);return{x:n,y:s,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Ps=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=Tr(e)?e.internals.positionAbsolute:Dn(e,t);return{x:n,y:s,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:s+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Da=(e,t)=>Us(Xs(Yo(e),Yo(t))),_n=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},Ti=e=>Je(e.width)&&Je(e.height)&&Je(e.x)&&Je(e.y),Je=e=>!isNaN(e)&&isFinite(e),_s=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},Js=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),zn=({x:e,y:t},[n,s,r],i=!1,l=[1,1])=>{const c={x:(e-n)/r,y:(t-s)/r};return i?Js(c,l):c},Ls=({x:e,y:t},[n,s,r])=>({x:e*r+n,y:t*r+s});function Gt(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function l5(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=Gt(e,n),r=Gt(e,t);return{top:s,right:r,bottom:s,left:r,x:r*2,y:s*2}}if(typeof e=="object"){const s=Gt(e.top??e.y??0,n),r=Gt(e.bottom??e.y??0,n),i=Gt(e.left??e.x??0,t),l=Gt(e.right??e.x??0,t);return{top:s,right:l,bottom:r,left:i,x:i+l,y:s+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function c5(e,t,n,s,r,i){const{x:l,y:c}=Ls(e,[t,n,s]),{x:a,y:d}=Ls({x:e.x+e.width,y:e.y+e.height},[t,n,s]),x=r-a,p=i-d;return{left:Math.floor(l),top:Math.floor(c),right:Math.floor(x),bottom:Math.floor(p)}}const Ir=(e,t,n,s,r,i)=>{const l=l5(i,t,n),c=(t-l.x)/e.width,a=(n-l.y)/e.height,d=Math.min(c,a),x=sn(d,s,r),p=e.x+e.width/2,m=e.y+e.height/2,f=t/2-p*x,h=n/2-m*x,j=c5(e,f,h,x,t,n),y={left:Math.min(j.left-l.left,0),top:Math.min(j.top-l.top,0),right:Math.min(j.right-l.right,0),bottom:Math.min(j.bottom-l.bottom,0)};return{x:f-y.left+y.right,y:h-y.top+y.bottom,zoom:x}},Ns=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function rn(e){return e!==void 0&&e!=="parent"}function ht(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Oa(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function za(e,t={width:0,height:0},n,s,r){const i={...e},l=s.get(n);if(l){const c=l.origin||r;i.x+=l.internals.positionAbsolute.x-(t.width??0)*c[0],i.y+=l.internals.positionAbsolute.y-(t.height??0)*c[1]}return i}function Ai(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function a5(){let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}}function u5(e){return{...La,...e||{}}}function Rn(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:r}){const{x:i,y:l}=dt(e),c=zn({x:i-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},s),{x:a,y:d}=n?Js(c,t):c;return{xSnapped:a,ySnapped:d,...c}}const $r=e=>({width:e.offsetWidth,height:e.offsetHeight}),Va=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},d5=["INPUT","SELECT","TEXTAREA"];function Fa(e){var s,r;const t=((r=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:d5.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Ha=e=>"clientX"in e,dt=(e,t)=>{var i,l;const n=Ha(e),s=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,r=n?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},Ii=(e,t,n,s,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(l=>{const c=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:r,position:l.getAttribute("data-handlepos"),x:(c.left-n.left)/s,y:(c.top-n.top)/s,...$r(l)}})};function Za({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:r,sourceControlY:i,targetControlX:l,targetControlY:c}){const a=e*.125+r*.375+l*.375+n*.125,d=t*.125+i*.375+c*.375+s*.125,x=Math.abs(a-e),p=Math.abs(d-t);return[a,d,x,p]}function Jn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function $i({pos:e,x1:t,y1:n,x2:s,y2:r,c:i}){switch(e){case U.Left:return[t-Jn(t-s,i),n];case U.Right:return[t+Jn(s-t,i),n];case U.Top:return[t,n-Jn(n-r,i)];case U.Bottom:return[t,n+Jn(r-n,i)]}}function Ka({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:s,targetY:r,targetPosition:i=U.Top,curvature:l=.25}){const[c,a]=$i({pos:n,x1:e,y1:t,x2:s,y2:r,c:l}),[d,x]=$i({pos:i,x1:s,y1:r,x2:e,y2:t,c:l}),[p,m,f,h]=Za({sourceX:e,sourceY:t,targetX:s,targetY:r,sourceControlX:c,sourceControlY:a,targetControlX:d,targetControlY:x});return[`M${e},${t} C${c},${a} ${d},${x} ${s},${r}`,p,m,f,h]}function Wa({sourceX:e,sourceY:t,targetX:n,targetY:s}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,l=Math.abs(s-t)/2,c=s<t?s+l:s-l;return[i,c,r,l]}function x5({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:r=!1}){if(!r)return s;const i=n||t.selected||e.selected,l=Math.max(e.internals.z||0,t.internals.z||0,1e3);return s+(i?l:0)}function p5({sourceNode:e,targetNode:t,width:n,height:s,transform:r}){const i=Xs(Ps(e),Ps(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const l={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:s/r[2]};return _n(l,Us(i))>0}const Ya=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,m5=(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)),Ga=(e,t)=>{if(!e.source||!e.target)return _s("006",Oe.error006()),t;let n;return Aa(e)?n={...e}:n={...e,id:Ya(e)},m5(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))},f5=(e,t,n,s={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return _s("006",Oe.error006()),n;if(!n.find(a=>a.id===e.id))return _s("007",Oe.error007(r)),n;const c={...i,id:s.shouldReplaceId?Ya(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(a=>a.id!==r).concat(c)};function qa({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[r,i,l,c]=Wa({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,r,i,l,c]}const Bi={[U.Left]:{x:-1,y:0},[U.Right]:{x:1,y:0},[U.Top]:{x:0,y:-1},[U.Bottom]:{x:0,y:1}},h5=({source:e,sourcePosition:t=U.Bottom,target:n})=>t===U.Left||t===U.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},Di=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function g5({source:e,sourcePosition:t=U.Bottom,target:n,targetPosition:s=U.Top,center:r,offset:i}){const l=Bi[t],c=Bi[s],a={x:e.x+l.x*i,y:e.y+l.y*i},d={x:n.x+c.x*i,y:n.y+c.y*i},x=h5({source:a,sourcePosition:t,target:d}),p=x.x!==0?"x":"y",m=x[p];let f=[],h,j;const y={x:0,y:0},S={x:0,y:0},[b,E,R,M]=Wa({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){h=r.x??b,j=r.y??E;const L=[{x:h,y:a.y},{x:h,y:d.y}],A=[{x:a.x,y:j},{x:d.x,y:j}];l[p]===m?f=p==="x"?L:A:f=p==="x"?A:L}else{const L=[{x:a.x,y:d.y}],A=[{x:d.x,y:a.y}];if(p==="x"?f=l.x===m?A:L:f=l.y===m?L:A,t===s){const k=Math.abs(e[p]-n[p]);if(k<=i){const C=Math.min(i-1,i-k);l[p]===m?y[p]=(a[p]>e[p]?-1:1)*C:S[p]=(d[p]>n[p]?-1:1)*C}}if(t!==s){const k=p==="x"?"y":"x",C=l[p]===c[k],P=a[k]>d[k],v=a[k]<d[k];(l[p]===1&&(!C&&P||C&&v)||l[p]!==1&&(!C&&v||C&&P))&&(f=p==="x"?L:A)}const $={x:a.x+y.x,y:a.y+y.y},O={x:d.x+S.x,y:d.y+S.y},V=Math.max(Math.abs($.x-f[0].x),Math.abs(O.x-f[0].x)),z=Math.max(Math.abs($.y-f[0].y),Math.abs(O.y-f[0].y));V>=z?(h=($.x+O.x)/2,j=f[0].y):(h=f[0].x,j=($.y+O.y)/2)}return[[e,{x:a.x+y.x,y:a.y+y.y},...f,{x:d.x+S.x,y:d.y+S.y},n],h,j,R,M]}function j5(e,t,n,s){const r=Math.min(Di(e,t)/2,Di(t,n)/2,s),{x:i,y:l}=t;if(e.x===i&&i===n.x||e.y===l&&l===n.y)return`L${i} ${l}`;if(e.y===l){const d=e.x<n.x?-1:1,x=e.y<n.y?1:-1;return`L ${i+r*d},${l}Q ${i},${l} ${i},${l+r*x}`}const c=e.x<n.x?1:-1,a=e.y<n.y?-1:1;return`L ${i},${l+r*a}Q ${i},${l} ${i+r*c},${l}`}function Go({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:s,targetY:r,targetPosition:i=U.Top,borderRadius:l=5,centerX:c,centerY:a,offset:d=20}){const[x,p,m,f,h]=g5({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:r},targetPosition:i,center:{x:c,y:a},offset:d});return[x.reduce((y,S,b)=>{let E="";return b>0&&b<x.length-1?E=j5(x[b-1],S,x[b+1],l):E=`${b===0?"M":"L"}${S.x} ${S.y}`,y+=E,y},""),p,m,f,h]}function Oi(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function E5(e){var p;const{sourceNode:t,targetNode:n}=e;if(!Oi(t)||!Oi(n))return null;const s=t.internals.handleBounds||zi(t.handles),r=n.internals.handleBounds||zi(n.handles),i=Vi((s==null?void 0:s.source)??[],e.sourceHandle),l=Vi(e.connectionMode===zt.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!i||!l)return(p=e.onError)==null||p.call(e,"008",Oe.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(i==null?void 0:i.position)||U.Bottom,a=(l==null?void 0:l.position)||U.Top,d=Ln(t,i,c),x=Ln(n,l,a);return{sourceX:d.x,sourceY:d.y,targetX:x.x,targetY:x.y,sourcePosition:c,targetPosition:a}}function zi(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 Ln(e,t,n=U.Left,s=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:l,height:c}=t??ht(e);if(s)return{x:r+l/2,y:i+c/2};switch((t==null?void 0:t.position)??n){case U.Top:return{x:r+l/2,y:i};case U.Right:return{x:r+l,y:i+c/2};case U.Bottom:return{x:r+l/2,y:i+c};case U.Left:return{x:r,y:i+c/2}}}function Vi(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function qo(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function y5(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:r}){const i=new Set;return e.reduce((l,c)=>([c.markerStart||s,c.markerEnd||r].forEach(a=>{if(a&&typeof a=="object"){const d=qo(a,t);i.has(d)||(l.push({id:d,color:a.color||n,...a}),i.add(d))}}),l),[]).sort((l,c)=>l.id.localeCompare(c.id))}const Br={nodeOrigin:[0,0],nodeExtent:Pn,elevateNodesOnSelect:!0,defaults:{}},S5={...Br,checkEquality:!0};function Dr(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function R5(e,t,n){const s=Dr(Br,n);for(const r of e.values())if(r.parentId)Or(r,e,t,s);else{const i=Dn(r,s.nodeOrigin),l=rn(r.extent)?r.extent:s.nodeExtent,c=Vt(i,l,ht(r));r.internals.positionAbsolute=c}}function Xo(e,t,n,s){var a,d;const r=Dr(S5,s);let i=e.length>0;const l=new Map(t),c=r!=null&&r.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const x of e){let p=l.get(x.id);if(r.checkEquality&&x===(p==null?void 0:p.internals.userNode))t.set(x.id,p);else{const m=Dn(x,r.nodeOrigin),f=rn(x.extent)?x.extent:r.nodeExtent,h=Vt(m,f,ht(x));p={...r.defaults,...x,measured:{width:(a=x.measured)==null?void 0:a.width,height:(d=x.measured)==null?void 0:d.height},internals:{positionAbsolute:h,handleBounds:x.measured?p==null?void 0:p.internals.handleBounds:void 0,z:Xa(x,c),userNode:x}},t.set(x.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(i=!1),x.parentId&&Or(p,t,n,s)}return i}function C5(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 Or(e,t,n,s){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:l}=Dr(Br,s),c=e.parentId,a=t.get(c);if(!a){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}C5(e,n);const d=r?1e3:0,{x,y:p,z:m}=w5(e,a,i,l,d),{positionAbsolute:f}=e.internals,h=x!==f.x||p!==f.y;(h||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x,y:p}:f,z:m}})}function Xa(e,t){return(Je(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function w5(e,t,n,s,r){const{x:i,y:l}=t.internals.positionAbsolute,c=ht(e),a=Dn(e,n),d=rn(e.extent)?Vt(a,e.extent,c):a;let x=Vt({x:i+d.x,y:l+d.y},s,c);e.extent==="parent"&&(x=$a(x,c,t));const p=Xa(e,r),m=t.internals.z??0;return{x:x.x,y:x.y,z:m>p?m:p}}function zr(e,t,n,s=[0,0]){var l;const r=[],i=new Map;for(const c of e){const a=t.get(c.parentId);if(!a)continue;const d=((l=i.get(c.parentId))==null?void 0:l.expandedRect)??on(a),x=Da(d,c.rect);i.set(c.parentId,{expandedRect:x,parent:a})}return i.size>0&&i.forEach(({expandedRect:c,parent:a},d)=>{var E;const x=a.internals.positionAbsolute,p=ht(a),m=a.origin??s,f=c.x<x.x?Math.round(Math.abs(x.x-c.x)):0,h=c.y<x.y?Math.round(Math.abs(x.y-c.y)):0,j=Math.max(p.width,Math.round(c.width)),y=Math.max(p.height,Math.round(c.height)),S=(j-p.width)*m[0],b=(y-p.height)*m[1];(f>0||h>0||S||b)&&(r.push({id:d,type:"position",position:{x:a.position.x-f+S,y:a.position.y-h+b}}),(E=n.get(d))==null||E.forEach(R=>{e.some(M=>M.id===R.id)||r.push({id:R.id,type:"position",position:{x:R.position.x+f,y:R.position.y+h}})})),(p.width<c.width||p.height<c.height||f||h)&&r.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:j+(f?m[0]*f-S:0),height:y+(h?m[1]*h-b:0)}})}),r}function b5(e,t,n,s,r,i){const l=s==null?void 0:s.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const a=[],d=window.getComputedStyle(l),{m22:x}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const m of e.values()){const f=t.get(m.id);if(!f)continue;if(f.hidden){t.set(f.id,{...f,internals:{...f.internals,handleBounds:void 0}}),c=!0;continue}const h=$r(m.nodeElement),j=f.measured.width!==h.width||f.measured.height!==h.height;if(!!(h.width&&h.height&&(j||!f.internals.handleBounds||m.force))){const S=m.nodeElement.getBoundingClientRect(),b=rn(f.extent)?f.extent:i;let{positionAbsolute:E}=f.internals;f.parentId&&f.extent==="parent"?E=$a(E,h,t.get(f.parentId)):b&&(E=Vt(E,b,h));const R={...f,measured:h,internals:{...f.internals,positionAbsolute:E,handleBounds:{source:Ii("source",m.nodeElement,S,x,f.id),target:Ii("target",m.nodeElement,S,x,f.id)}}};t.set(f.id,R),f.parentId&&Or(R,t,n,{nodeOrigin:r}),c=!0,j&&(a.push({id:f.id,type:"dimensions",dimensions:h}),f.expandParent&&f.parentId&&p.push({id:f.id,parentId:f.parentId,rect:on(R,r)}))}}if(p.length>0){const m=zr(p,t,n,r);a.push(...m)}return{changes:a,updatedInternals:c}}async function v5({delta:e,panZoom:t,transform:n,translateExtent:s,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const l=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],s),c=!!l&&(l.x!==n[0]||l.y!==n[1]||l.k!==n[2]);return Promise.resolve(c)}function Fi(e,t,n,s,r,i){let l=r;const c=s.get(l)||new Map;s.set(l,c.set(n,t)),l=`${r}-${e}`;const a=s.get(l)||new Map;if(s.set(l,a.set(n,t)),i){l=`${r}-${e}-${i}`;const d=s.get(l)||new Map;s.set(l,d.set(n,t))}}function Ua(e,t,n){e.clear(),t.clear();for(const s of n){const{source:r,target:i,sourceHandle:l=null,targetHandle:c=null}=s,a={edgeId:s.id,source:r,target:i,sourceHandle:l,targetHandle:c},d=`${r}-${l}--${i}-${c}`,x=`${i}-${c}--${r}-${l}`;Fi("source",a,x,e,r,l),Fi("target",a,d,e,i,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 Hi(e,t,n){var r;let s=e;do{if((r=s==null?void 0:s.matches)!=null&&r.call(s,t))return!0;if(s===n)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function k5(e,t,n,s){const r=new Map;for(const[i,l]of e)if((l.selected||l.id===s)&&(!l.parentId||!Ja(l,e))&&(l.draggable||t&&typeof l.draggable>"u")){const c=e.get(i);c&&r.set(i,{id:i,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return r}function So({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){var l,c,a;const r=[];for(const[d,x]of t){const p=(l=n.get(d))==null?void 0:l.internals.userNode;p&&r.push({...p,position:x.position,dragging:s})}if(!e)return[r[0],r];const i=(c=n.get(e))==null?void 0:c.internals.userNode;return[i?{...i,position:((a=t.get(e))==null?void 0:a.position)||i.position,dragging:s}:r[0],r]}function M5({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:r}){let i={x:null,y:null},l=0,c=new Map,a=!1,d={x:0,y:0},x=null,p=!1,m=null,f=!1;function h({noDragClassName:y,handleSelector:S,domNode:b,isSelectable:E,nodeId:R,nodeClickDistance:M=0}){m=Ke(b);function _({x:O,y:V},z){const{nodeLookup:k,nodeExtent:C,snapGrid:P,snapToGrid:v,nodeOrigin:N,onNodeDrag:D,onSelectionDrag:I,onError:F,updateNodePositions:H}=t();i={x:O,y:V};let Z=!1,ee={x:0,y:0,x2:0,y2:0};if(c.size>1&&C){const te=On(c);ee=Yo(te)}for(const[te,se]of c){if(!k.has(te))continue;let oe={x:O-se.distance.x,y:V-se.distance.y};v&&(oe=Js(oe,P));let xe=[[C[0][0],C[0][1]],[C[1][0],C[1][1]]];if(c.size>1&&C&&!se.extent){const{positionAbsolute:je}=se.internals,ge=je.x-ee.x+C[0][0],W=je.x+se.measured.width-ee.x2+C[1][0],le=je.y-ee.y+C[0][1],ue=je.y+se.measured.height-ee.y2+C[1][1];xe=[[ge,le],[W,ue]]}const{position:J,positionAbsolute:ae}=Ia({nodeId:te,nextPosition:oe,nodeLookup:k,nodeExtent:xe,nodeOrigin:N,onError:F});Z=Z||se.position.x!==J.x||se.position.y!==J.y,se.position=J,se.internals.positionAbsolute=ae}if(Z&&(H(c,!0),z&&(s||D||!R&&I))){const[te,se]=So({nodeId:R,dragItems:c,nodeLookup:k});s==null||s(z,c,te,se),D==null||D(z,te,se),R||I==null||I(z,se)}}async function L(){if(!x)return;const{transform:O,panBy:V,autoPanSpeed:z,autoPanOnNodeDrag:k}=t();if(!k){a=!1,cancelAnimationFrame(l);return}const[C,P]=Ba(d,x,z);(C!==0||P!==0)&&(i.x=(i.x??0)-C/O[2],i.y=(i.y??0)-P/O[2],await V({x:C,y:P})&&_(i,null)),l=requestAnimationFrame(L)}function A(O){var Z;const{nodeLookup:V,multiSelectionActive:z,nodesDraggable:k,transform:C,snapGrid:P,snapToGrid:v,selectNodesOnDrag:N,onNodeDragStart:D,onSelectionDragStart:I,unselectNodesAndEdges:F}=t();p=!0,(!N||!E)&&!z&&R&&((Z=V.get(R))!=null&&Z.selected||F()),E&&N&&R&&(e==null||e(R));const H=Rn(O.sourceEvent,{transform:C,snapGrid:P,snapToGrid:v,containerBounds:x});if(i=H,c=k5(V,k,H,R),c.size>0&&(n||D||!R&&I)){const[ee,te]=So({nodeId:R,dragItems:c,nodeLookup:V});n==null||n(O.sourceEvent,c,ee,te),D==null||D(O.sourceEvent,ee,te),R||I==null||I(O.sourceEvent,te)}}const $=ya().clickDistance(M).on("start",O=>{const{domNode:V,nodeDragThreshold:z,transform:k,snapGrid:C,snapToGrid:P}=t();x=(V==null?void 0:V.getBoundingClientRect())||null,f=!1,z===0&&A(O),i=Rn(O.sourceEvent,{transform:k,snapGrid:C,snapToGrid:P,containerBounds:x}),d=dt(O.sourceEvent,x)}).on("drag",O=>{const{autoPanOnNodeDrag:V,transform:z,snapGrid:k,snapToGrid:C,nodeDragThreshold:P,nodeLookup:v}=t(),N=Rn(O.sourceEvent,{transform:z,snapGrid:k,snapToGrid:C,containerBounds:x});if((O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||R&&!v.has(R))&&(f=!0),!f){if(!a&&V&&p&&(a=!0,L()),!p){const D=N.xSnapped-(i.x??0),I=N.ySnapped-(i.y??0);Math.sqrt(D*D+I*I)>P&&A(O)}(i.x!==N.xSnapped||i.y!==N.ySnapped)&&c&&p&&(d=dt(O.sourceEvent,x),_(N,O.sourceEvent))}}).on("end",O=>{if(!(!p||f)&&(a=!1,p=!1,cancelAnimationFrame(l),c.size>0)){const{nodeLookup:V,updateNodePositions:z,onNodeDragStop:k,onSelectionDragStop:C}=t();if(z(c,!1),r||k||!R&&C){const[P,v]=So({nodeId:R,dragItems:c,nodeLookup:V,dragging:!1});r==null||r(O.sourceEvent,c,P,v),k==null||k(O.sourceEvent,P,v),R||C==null||C(O.sourceEvent,v)}}}).filter(O=>{const V=O.target;return!O.button&&(!y||!Hi(V,`.${y}`,b))&&(!S||Hi(V,S,b))});m.call($)}function j(){m==null||m.on(".drag",null)}return{update:h,destroy:j}}function P5(e,t,n){const s=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())_n(r,on(i))>0&&s.push(i);return s}const _5=250;function L5(e,t,n,s){var c,a;let r=[],i=1/0;const l=P5(e,n,t+_5);for(const d of l){const x=[...((c=d.internals.handleBounds)==null?void 0:c.source)??[],...((a=d.internals.handleBounds)==null?void 0:a.target)??[]];for(const p of x){if(s.nodeId===p.nodeId&&s.type===p.type&&s.id===p.id)continue;const{x:m,y:f}=Ln(d,p,p.position,!0),h=Math.sqrt(Math.pow(m-e.x,2)+Math.pow(f-e.y,2));h>t||(h<i?(r=[{...p,x:m,y:f}],i=h):h===i&&r.push({...p,x:m,y:f}))}}if(!r.length)return null;if(r.length>1){const d=s.type==="source"?"target":"source";return r.find(x=>x.type===d)??r[0]}return r[0]}function Qa(e,t,n,s,r,i=!1){var d,x,p;const l=s.get(e);if(!l)return null;const c=r==="strict"?(d=l.internals.handleBounds)==null?void 0:d[t]:[...((x=l.internals.handleBounds)==null?void 0:x.source)??[],...((p=l.internals.handleBounds)==null?void 0:p.target)??[]],a=(n?c==null?void 0:c.find(m=>m.id===n):c==null?void 0:c[0])??null;return a&&i?{...a,...Ln(l,a,a.position,!0)}:a}function eu(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function N5(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const tu=()=>!0;function T5(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:r,edgeUpdaterType:i,isTarget:l,domNode:c,nodeLookup:a,lib:d,autoPanOnConnect:x,flowId:p,panBy:m,cancelConnection:f,onConnectStart:h,onConnect:j,onConnectEnd:y,isValidConnection:S=tu,onReconnectEnd:b,updateConnection:E,getTransform:R,getFromHandle:M,autoPanSpeed:_}){const L=Va(e.target);let A=0,$;const{x:O,y:V}=dt(e),z=L==null?void 0:L.elementFromPoint(O,V),k=eu(i,z),C=c==null?void 0:c.getBoundingClientRect();if(!C||!k)return;const P=Qa(r,k,s,a,t);if(!P)return;let v=dt(e,C),N=!1,D=null,I=!1,F=null;function H(){if(!x||!C)return;const[ae,je]=Ba(v,C,_);m({x:ae,y:je}),A=requestAnimationFrame(H)}const Z={...P,nodeId:r,type:k,position:P.position},ee=a.get(r),se={inProgress:!0,isValid:null,from:Ln(ee,Z,U.Left,!0),fromHandle:Z,fromPosition:Z.position,fromNode:ee,to:v,toHandle:null,toPosition:Li[Z.position],toNode:null};E(se);let oe=se;h==null||h(e,{nodeId:r,handleId:s,handleType:k});function xe(ae){if(!M()||!Z){J(ae);return}const je=R();v=dt(ae,C),$=L5(zn(v,je,!1,[1,1]),n,a,Z),N||(H(),N=!0);const ge=nu(ae,{handle:$,connectionMode:t,fromNodeId:r,fromHandleId:s,fromType:l?"target":"source",isValidConnection:S,doc:L,lib:d,flowId:p,nodeLookup:a});F=ge.handleDomNode,D=ge.connection,I=N5(!!$,ge.isValid);const W={...oe,isValid:I,to:ge.toHandle&&I?Ls({x:ge.toHandle.x,y:ge.toHandle.y},je):v,toHandle:ge.toHandle,toPosition:I&&ge.toHandle?ge.toHandle.position:Li[Z.position],toNode:ge.toHandle?a.get(ge.toHandle.nodeId):null};I&&$&&oe.toHandle&&W.toHandle&&oe.toHandle.type===W.toHandle.type&&oe.toHandle.nodeId===W.toHandle.nodeId&&oe.toHandle.id===W.toHandle.id&&oe.to.x===W.to.x&&oe.to.y===W.to.y||(E(W),oe=W)}function J(ae){($||F)&&D&&I&&(j==null||j(D));const{inProgress:je,...ge}=oe,W={...ge,toPosition:oe.toHandle?oe.toPosition:null};y==null||y(ae,W),i&&(b==null||b(ae,W)),f(),cancelAnimationFrame(A),N=!1,I=!1,D=null,F=null,L.removeEventListener("mousemove",xe),L.removeEventListener("mouseup",J),L.removeEventListener("touchmove",xe),L.removeEventListener("touchend",J)}L.addEventListener("mousemove",xe),L.addEventListener("mouseup",J),L.addEventListener("touchmove",xe),L.addEventListener("touchend",J)}function nu(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:r,fromType:i,doc:l,lib:c,flowId:a,isValidConnection:d=tu,nodeLookup:x}){const p=i==="target",m=t?l.querySelector(`.${c}-flow__handle[data-id="${a}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:f,y:h}=dt(e),j=l.elementFromPoint(f,h),y=j!=null&&j.classList.contains(`${c}-flow__handle`)?j:m,S={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const b=eu(void 0,y),E=y.getAttribute("data-nodeid"),R=y.getAttribute("data-handleid"),M=y.classList.contains("connectable"),_=y.classList.contains("connectableend");if(!E||!b)return S;const L={source:p?E:s,sourceHandle:p?R:r,target:p?s:E,targetHandle:p?r:R};S.connection=L;const $=M&&_&&(n===zt.Strict?p&&b==="source"||!p&&b==="target":E!==s||R!==r);S.isValid=$&&d(L),S.toHandle=Qa(E,b,R,x,n,!0)}return S}const Uo={onPointerDown:T5,isValid:nu};function A5({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const r=Ke(e);function i({translateExtent:c,width:a,height:d,zoomStep:x=10,pannable:p=!0,zoomable:m=!0,inversePan:f=!1}){const h=E=>{const R=n();if(E.sourceEvent.type!=="wheel"||!t)return;const M=-E.sourceEvent.deltaY*(E.sourceEvent.deltaMode===1?.05:E.sourceEvent.deltaMode?1:.002)*x,_=R[2]*Math.pow(2,M);t.scaleTo(_)};let j=[0,0];const y=E=>{(E.sourceEvent.type==="mousedown"||E.sourceEvent.type==="touchstart")&&(j=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY])},S=E=>{const R=n();if(E.sourceEvent.type!=="mousemove"&&E.sourceEvent.type!=="touchmove"||!t)return;const M=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY],_=[M[0]-j[0],M[1]-j[1]];j=M;const L=s()*Math.max(R[2],Math.log(R[2]))*(f?-1:1),A={x:R[0]-_[0]*L,y:R[1]-_[1]*L},$=[[0,0],[a,d]];t.setViewportConstrained({x:A.x,y:A.y,zoom:R[2]},$,c)},b=Pa().on("start",y).on("zoom",p?S:null).on("zoom.wheel",m?h:null);r.call(b,{})}function l(){r.on("zoom",null)}return{update:i,destroy:l,pointer:Ue}}const I5=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Qs=e=>({x:e.x,y:e.y,zoom:e.k}),Ro=({x:e,y:t,zoom:n})=>qs.translate(e,t).scale(n),Xt=(e,t)=>e.target.closest(`.${t}`),su=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),$5=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Co=(e,t=0,n=$5,s=()=>{})=>{const r=typeof t=="number"&&t>0;return r||s(),r?e.transition().duration(t).ease(n).on("end",s):e},ou=e=>{const t=e.ctrlKey&&Ns()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function B5({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:l,onPanZoomStart:c,onPanZoom:a,onPanZoomEnd:d}){return x=>{if(Xt(x,t))return!1;x.preventDefault(),x.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(x.ctrlKey&&l){const y=Ue(x),S=ou(x),b=p*Math.pow(2,S);s.scaleTo(n,b,y,x);return}const m=x.deltaMode===1?20:1;let f=r===It.Vertical?0:x.deltaX*m,h=r===It.Horizontal?0:x.deltaY*m;!Ns()&&x.shiftKey&&r!==It.Vertical&&(f=x.deltaY*m,h=0),s.translateBy(n,-(f/p)*i,-(h/p)*i,{internal:!0});const j=Qs(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,c==null||c(x,j)),e.isPanScrolling&&(a==null||a(x,j),e.panScrollTimeout=setTimeout(()=>{d==null||d(x,j),e.isPanScrolling=!1},150))}}function D5({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,r){const i=s.type==="wheel",l=!t&&i&&!s.ctrlKey,c=Xt(s,e);if(s.ctrlKey&&i&&c&&s.preventDefault(),l||c)return null;s.preventDefault(),n.call(this,s,r)}}function O5({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{var i,l,c;if((i=s.sourceEvent)!=null&&i.internal)return;const r=Qs(s.transform);e.mouseButton=((l=s.sourceEvent)==null?void 0:l.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((c=s.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(s.sourceEvent,r))}}function z5({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:r}){return i=>{var l,c;e.usedRightMouseButton=!!(n&&su(t,e.mouseButton??0)),(l=i.sourceEvent)!=null&&l.sync||s([i.transform.x,i.transform.y,i.transform.k]),r&&!((c=i.sourceEvent)!=null&&c.internal)&&(r==null||r(i.sourceEvent,Qs(i.transform)))}}function V5({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:r,onPaneContextMenu:i}){return l=>{var c;if(!((c=l.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,i&&su(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&i(l.sourceEvent),e.usedRightMouseButton=!1,s(!1),r&&I5(e.prevViewport,l.transform))){const a=Qs(l.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,a)},n?150:0)}}}function F5({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:l,noWheelClassName:c,noPanClassName:a,lib:d}){return x=>{var h;const p=e||t,m=n&&x.ctrlKey;if(x.button===1&&x.type==="mousedown"&&(Xt(x,`${d}-flow__node`)||Xt(x,`${d}-flow__edge`)))return!0;if(!s&&!p&&!r&&!i&&!n||l||Xt(x,c)&&x.type==="wheel"||Xt(x,a)&&(x.type!=="wheel"||r&&x.type==="wheel"&&!e)||!n&&x.ctrlKey&&x.type==="wheel")return!1;if(!n&&x.type==="touchstart"&&((h=x.touches)==null?void 0:h.length)>1)return x.preventDefault(),!1;if(!p&&!r&&!m&&x.type==="wheel"||!s&&(x.type==="mousedown"||x.type==="touchstart")||Array.isArray(s)&&!s.includes(x.button)&&x.type==="mousedown")return!1;const f=Array.isArray(s)&&s.includes(x.button)||!x.button||x.button<=1;return(!x.ctrlKey||x.type==="wheel")&&f}}function H5({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:s,translateExtent:r,viewport:i,onPanZoom:l,onPanZoomStart:c,onPanZoomEnd:a,onDraggingChange:d}){const x={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),m=Pa().clickDistance(!Je(s)||s<0?0:s).scaleExtent([t,n]).translateExtent(r),f=Ke(e).call(m);E({x:i.x,y:i.y,zoom:sn(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const h=f.on("wheel.zoom"),j=f.on("dblclick.zoom");m.wheelDelta(ou);function y(z,k){return f?new Promise(C=>{m==null||m.interpolate((k==null?void 0:k.interpolate)==="linear"?B.interpolate:ls).transform(Co(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>C(!0)),z)}):Promise.resolve(!1)}function S({noWheelClassName:z,noPanClassName:k,onPaneContextMenu:C,userSelectionActive:P,panOnScroll:v,panOnDrag:N,panOnScrollMode:D,panOnScrollSpeed:I,preventScrolling:F,zoomOnPinch:H,zoomOnScroll:Z,zoomOnDoubleClick:ee,zoomActivationKeyPressed:te,lib:se,onTransformChange:oe}){P&&!x.isZoomingOrPanning&&b();const J=v&&!te&&!P?B5({zoomPanValues:x,noWheelClassName:z,d3Selection:f,d3Zoom:m,panOnScrollMode:D,panOnScrollSpeed:I,zoomOnPinch:H,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:a}):D5({noWheelClassName:z,preventScrolling:F,d3ZoomHandler:h});if(f.on("wheel.zoom",J,{passive:!1}),!P){const je=O5({zoomPanValues:x,onDraggingChange:d,onPanZoomStart:c});m.on("start",je);const ge=z5({zoomPanValues:x,panOnDrag:N,onPaneContextMenu:!!C,onPanZoom:l,onTransformChange:oe});m.on("zoom",ge);const W=V5({zoomPanValues:x,panOnDrag:N,panOnScroll:v,onPaneContextMenu:C,onPanZoomEnd:a,onDraggingChange:d});m.on("end",W)}const ae=F5({zoomActivationKeyPressed:te,panOnDrag:N,zoomOnScroll:Z,panOnScroll:v,zoomOnDoubleClick:ee,zoomOnPinch:H,userSelectionActive:P,noPanClassName:k,noWheelClassName:z,lib:se});m.filter(ae),ee?f.on("dblclick.zoom",j):f.on("dblclick.zoom",null)}function b(){m.on("zoom",null)}async function E(z,k,C){const P=Ro(z),v=m==null?void 0:m.constrain()(P,k,C);return v&&await y(v),new Promise(N=>N(v))}async function R(z,k){const C=Ro(z);return await y(C,k),new Promise(P=>P(C))}function M(z){if(f){const k=Ro(z),C=f.property("__zoom");(C.k!==z.zoom||C.x!==z.x||C.y!==z.y)&&(m==null||m.transform(f,k,null,{sync:!0}))}}function _(){const z=f?Ma(f.node()):{x:0,y:0,k:1};return{x:z.x,y:z.y,zoom:z.k}}function L(z,k){return f?new Promise(C=>{m==null||m.interpolate((k==null?void 0:k.interpolate)==="linear"?B.interpolate:ls).scaleTo(Co(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>C(!0)),z)}):Promise.resolve(!1)}function A(z,k){return f?new Promise(C=>{m==null||m.interpolate((k==null?void 0:k.interpolate)==="linear"?B.interpolate:ls).scaleBy(Co(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>C(!0)),z)}):Promise.resolve(!1)}function $(z){m==null||m.scaleExtent(z)}function O(z){m==null||m.translateExtent(z)}function V(z){const k=!Je(z)||z<0?0:z;m==null||m.clickDistance(k)}return{update:S,destroy:b,setViewport:R,setViewportConstrained:E,getViewport:_,scaleTo:L,scaleBy:A,setScaleExtent:$,setTranslateExtent:O,syncViewport:M,setClickDistance:V}}var ln;(function(e){e.Line="line",e.Handle="handle"})(ln||(ln={}));function Z5({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:r,affectsY:i}){const l=e-t,c=n-s,a=[l>0?1:l<0?-1:0,c>0?1:c<0?-1:0];return l&&r&&(a[0]=a[0]*-1),c&&i&&(a[1]=a[1]*-1),a}function K5(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),s=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:s,affectsY:r}}function jt(e,t){return Math.max(0,t-e)}function Et(e,t){return Math.max(0,e-t)}function Qn(e,t,n){return Math.max(0,t-e,e-n)}function Zi(e,t){return e?!t:t}function W5(e,t,n,s,r,i,l,c){let{affectsX:a,affectsY:d}=t;const{isHorizontal:x,isVertical:p}=t,m=x&&p,{xSnapped:f,ySnapped:h}=n,{minWidth:j,maxWidth:y,minHeight:S,maxHeight:b}=s,{x:E,y:R,width:M,height:_,aspectRatio:L}=e;let A=Math.floor(x?f-e.pointerX:0),$=Math.floor(p?h-e.pointerY:0);const O=M+(a?-A:A),V=_+(d?-$:$),z=-i[0]*M,k=-i[1]*_;let C=Qn(O,j,y),P=Qn(V,S,b);if(l){let D=0,I=0;a&&A<0?D=jt(E+A+z,l[0][0]):!a&&A>0&&(D=Et(E+O+z,l[1][0])),d&&$<0?I=jt(R+$+k,l[0][1]):!d&&$>0&&(I=Et(R+V+k,l[1][1])),C=Math.max(C,D),P=Math.max(P,I)}if(c){let D=0,I=0;a&&A>0?D=Et(E+A,c[0][0]):!a&&A<0&&(D=jt(E+O,c[1][0])),d&&$>0?I=Et(R+$,c[0][1]):!d&&$<0&&(I=jt(R+V,c[1][1])),C=Math.max(C,D),P=Math.max(P,I)}if(r){if(x){const D=Qn(O/L,S,b)*L;if(C=Math.max(C,D),l){let I=0;!a&&!d||a&&!d&&m?I=Et(R+k+O/L,l[1][1])*L:I=jt(R+k+(a?A:-A)/L,l[0][1])*L,C=Math.max(C,I)}if(c){let I=0;!a&&!d||a&&!d&&m?I=jt(R+O/L,c[1][1])*L:I=Et(R+(a?A:-A)/L,c[0][1])*L,C=Math.max(C,I)}}if(p){const D=Qn(V*L,j,y)/L;if(P=Math.max(P,D),l){let I=0;!a&&!d||d&&!a&&m?I=Et(E+V*L+z,l[1][0])/L:I=jt(E+(d?$:-$)*L+z,l[0][0])/L,P=Math.max(P,I)}if(c){let I=0;!a&&!d||d&&!a&&m?I=jt(E+V*L,c[1][0])/L:I=Et(E+(d?$:-$)*L,c[0][0])/L,P=Math.max(P,I)}}}$=$+($<0?P:-P),A=A+(A<0?C:-C),r&&(m?O>V*L?$=(Zi(a,d)?-A:A)/L:A=(Zi(a,d)?-$:$)*L:x?($=A/L,d=a):(A=$*L,a=d));const v=a?E+A:E,N=d?R+$:R;return{width:M+(a?-A:A),height:_+(d?-$:$),x:i[0]*A*(a?-1:1)+v,y:i[1]*$*(d?-1:1)+N}}const ru={width:0,height:0,x:0,y:0},Y5={...ru,pointerX:0,pointerY:0,aspectRatio:1};function G5(e){return[[0,0],[e.measured.width,e.measured.height]]}function q5(e,t,n){const s=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,l=e.measured.height??0,c=n[0]*i,a=n[1]*l;return[[s-c,r-a],[s+i-c,r+l-a]]}function X5({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:r}){const i=Ke(e);function l({controlPosition:a,boundaries:d,keepAspectRatio:x,resizeDirection:p,onResizeStart:m,onResize:f,onResizeEnd:h,shouldResize:j}){let y={...ru},S={...Y5};const b=K5(a);let E,R=null,M=[],_,L,A;const $=ya().on("start",O=>{const{nodeLookup:V,transform:z,snapGrid:k,snapToGrid:C,nodeOrigin:P,paneDomNode:v}=n();if(E=V.get(t),!E)return;R=(v==null?void 0:v.getBoundingClientRect())??null;const{xSnapped:N,ySnapped:D}=Rn(O.sourceEvent,{transform:z,snapGrid:k,snapToGrid:C,containerBounds:R});y={width:E.measured.width??0,height:E.measured.height??0,x:E.position.x??0,y:E.position.y??0},S={...y,pointerX:N,pointerY:D,aspectRatio:y.width/y.height},_=void 0,E.parentId&&(E.extent==="parent"||E.expandParent)&&(_=V.get(E.parentId),L=_&&E.extent==="parent"?G5(_):void 0),M=[],A=void 0;for(const[I,F]of V)if(F.parentId===t&&(M.push({id:I,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const H=q5(F,E,F.origin??P);A?A=[[Math.min(H[0][0],A[0][0]),Math.min(H[0][1],A[0][1])],[Math.max(H[1][0],A[1][0]),Math.max(H[1][1],A[1][1])]]:A=H}m==null||m(O,{...y})}).on("drag",O=>{const{transform:V,snapGrid:z,snapToGrid:k,nodeOrigin:C}=n(),P=Rn(O.sourceEvent,{transform:V,snapGrid:z,snapToGrid:k,containerBounds:R}),v=[];if(!E)return;const{x:N,y:D,width:I,height:F}=y,H={},Z=E.origin??C,{width:ee,height:te,x:se,y:oe}=W5(S,b,P,d,x,Z,L,A),xe=ee!==I,J=te!==F,ae=se!==N&&xe,je=oe!==D&&J;if(!ae&&!je&&!xe&&!J)return;if((ae||je||Z[0]===1||Z[1]===1)&&(H.x=ae?se:y.x,H.y=je?oe:y.y,y.x=H.x,y.y=H.y,M.length>0)){const ue=se-N,Me=oe-D;for(const Le of M)Le.position={x:Le.position.x-ue+Z[0]*(ee-I),y:Le.position.y-Me+Z[1]*(te-F)},v.push(Le)}if((xe||J)&&(H.width=xe&&(!p||p==="horizontal")?ee:y.width,H.height=J&&(!p||p==="vertical")?te:y.height,y.width=H.width,y.height=H.height),_&&E.expandParent){const ue=Z[0]*(H.width??0);H.x&&H.x<ue&&(y.x=ue,S.x=S.x-(H.x-ue));const Me=Z[1]*(H.height??0);H.y&&H.y<Me&&(y.y=Me,S.y=S.y-(H.y-Me))}const ge=Z5({width:y.width,prevWidth:I,height:y.height,prevHeight:F,affectsX:b.affectsX,affectsY:b.affectsY}),W={...y,direction:ge};(j==null?void 0:j(O,W))!==!1&&(f==null||f(O,W),s(H,v))}).on("end",O=>{h==null||h(O,{...y}),r==null||r({...y})});i.call($)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var es={exports:{}},wo={},ts={exports:{}},bo={};/**
1
+ "use strict";var Af=Object.defineProperty;var If=(e,t,n)=>t in e?Af(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var tt=(e,t,n)=>If(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./jsx-runtime-CITbqOLs.cjs"),g=require("react"),K=require("./Divider-D74_FAXn.cjs"),u=require("./css-C7rJrqRi.cjs"),os=require("./external-BgwS5D0j.cjs"),ce=require("./state-DwM4WaEw.cjs"),$f=require("./Stack-BbwDtaE6.cjs"),he=require("./external-cDUxSE0v.cjs"),ne=require("./Space-ByFmfiTa.cjs"),De=require("./hooks-B92WH57y.cjs"),Bf=require("./useVirtualCursorDragWebKit-CUbBopD6.cjs"),Q=require("./Provider-s70PZ9lg.cjs"),Df=require("./external-GjPk23XZ.cjs"),Te=require("./external-B-B5ro_s.cjs"),bl=require("./external-DC1RT1Js.cjs"),As=require("./WithIcon-CCnlO2LC.cjs"),Pe=require("./array-CZHEGH95.cjs"),Of=require("./external-Bojct8Fy.cjs"),An=require("./external-EvgywGSS.cjs"),fe=require("./Toggle-CpDGR6M6.cjs"),pt=require("./Text-bSIbkBIL.cjs"),bt=require("./provider-YWPkhTn6.cjs"),Ce=require("./Text-Dw0NDc2A.cjs"),B=require("./value--TYeJRXm.cjs"),me=require("./Haul-De8axVdi.cjs"),Ae=require("./useMemoCompare-BDs2sKw5.cjs"),si=require("./dimensions-BmlCx5q4.cjs"),er=require("./font-ifUcrCey.cjs"),Ye=require("./Dropdown-BpoU-xVd.cjs"),Be=require("./deep-BRgXTyZn.cjs"),Ge=require("./external-Cxwmal3D.cjs"),Is=require("./Pack-80N7XB5O.cjs"),vt=require("./ContextMenu-BC5x7XR5.cjs"),zf=require("./Text-DTPuORh0.cjs"),vl=require("./external-DOujCKRS.cjs");require("./Item-CB5c--eX.cjs");const kl=require("react-dom"),kt=require("./external-V0yO0q2n.cjs"),Ml=require("./css.cjs"),Vf=require("./useClickOutside-CUa496t0.cjs"),tr=require("./useDebouncedCallback-Bx-HX76R.cjs"),Ff=require("./external-MJ2UMa_L.cjs"),ps=require("./eraser-CGxyWj3B.cjs"),_o=require("./DateTime-DC19AIGq.cjs"),Hf=require("./external-B3Mtbu36.cjs"),Zf=require("./Video-BuzHLiXL.cjs"),Kf=e=>e.nullable().transform(t=>t===null?void 0:t).optional(),Pl=e=>Be.u(e,(t,n,s)=>{const r=n===s.length-1,i=!isNaN(parseInt(t)),l=!isNaN(parseInt(s[n+1]));return i&&(t="element"),r||l?t:[t,"shape"]}),oi=(e,t)=>{if(e==null)return null;const n=e[t];return n==null&&typeof e=="object"&&"sourceType"in e?e.sourceType()[t]:n},Wf=(e,t,n)=>Be.c(oi(e,"shape"),Pl(t),{...n,getter:oi}),Yf=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:Wf,getFieldSchemaPath:Pl,nullToUndefined:Kf},Symbol.toStringTag,{value:"Module"})),Gf=(e,t,n=150)=>{const[s,r]=g.useState(e);return g.useEffect(()=>{const i=setTimeout(()=>r(t),n);return()=>clearTimeout(i)},[t,n]),s},qf=Object.freeze(Object.defineProperty({__proto__:null,Config:fe.Config,Dialog:fe.Dialog,chooseLocation:fe.chooseLocation,formatTip:fe.formatTip,useConfig:fe.useConfig,wrap:fe.wrap},Symbol.toStringTag,{value:"Module"})),nr=({ref:e,location:t,style:n,size:s,className:r,children:i,onDragStart:l,sizeUnits:c="px",showHandle:a=!0,...d})=>{const x=u.K$1.construct(t),p=u.K$1.direction(x),m=u.g.dimension(p);return o.jsxRuntimeExports.jsxs(ne.Core,{className:u.CSS(u.CSS.B("resize"),u.CSS.loc(x),u.CSS.dir(p),r),style:{[m]:`${s}${c}`,...n},ref:e,...d,children:[i,a&&o.jsxRuntimeExports.jsx("div",{draggable:!0,className:u.CSS(u.CSS.BE("resize","handle"),u.CSS.bordered(u.K$1.swap(x))),onDragStart:l,onDrag:he.preventDefault,onDragEnd:he.preventDefault})]})},sr=({onResize:e,count:t,initialSizes:n=[],minSize:s=100,direction:r="x"})=>{const i=g.useRef(null),[l,c]=g.useState({sizeDistribution:Xf(n,t),root:null}),a=g.useCallback((p,m,f)=>{if(i.current==null)return;const h=u.Pt.dim(u.Pt.construct(i.current),r);c(j=>mo(j,h,p,s,m,f))},[s,c,r]);g.useEffect(()=>e==null?void 0:e(l.sizeDistribution),[l.sizeDistribution,e]);const d=g.useCallback((p,m)=>{p.preventDefault();const f=r==="x"?"clientX":"clientY",h=y=>a(m,y[f]),j=()=>{c(y=>({...y,root:null})),document.removeEventListener("mousemove",h)};c(y=>({...y,root:p[f]})),document.addEventListener("mousemove",h),document.addEventListener("mouseup",j,{once:!0})},[c,r,mo]);return{setSize:g.useCallback((p,m)=>a(p,void 0,m),[mo]),props:{direction:r,sizeDistribution:l.sizeDistribution,onDragHandle:d,ref:i}}},or=({ref:e,direction:t="x",children:n,sizeDistribution:s,onDragHandle:r,className:i,...l})=>{const c=u.g.construct(t),a=g.Children.toArray(n);return s=Uf(s),o.jsxRuntimeExports.jsx(ne.Space,{...l,ref:e,direction:c,className:u.CSS(u.CSS.B("resize-multiple"),i),empty:!0,grow:!0,children:a.map((d,x)=>o.jsxRuntimeExports.jsx(nr,{onDragStart:p=>r(p,x),location:u.g.location(c),size:s[x]*100,sizeUnits:"%",showHandle:x!==a.length-1,children:d},x))})},Xf=(e,t)=>{const n=e.reduce((r,i)=>r+i,0),s=t-e.length;if(s<=0)return e.slice(0,t).map(r=>r/n);if(e.every(r=>r<=1)){const r=1-n;return[...e,...Array(s).fill(r/s)]}return e.map(()=>1/t)},po=.001,Uf=e=>e.every(t=>u.nd.closeTo(t,1/e.length),po)?e.map((t,n)=>n%2===0?t+po:n===e.length-1?t:t-po):e,mo=(e,t,n,s,r,i)=>{const l=_l(e,t,n,r,i),[c,a]=Jf(e.sizeDistribution,n,l,s/t),d=a?r??null:e.root;return{...e,sizeDistribution:c,root:d}},_l=(e,t,n,s,r)=>{let i;if(r!=null)r>1&&(r/=t),i=r-e.sizeDistribution[n];else if(s!=null){if(e.root===null)throw new Error("resize root is null during handle drag");i=(s-e.root)/t}else throw new Error("must provide either a MouseEvent or a targetSize");return i},Jf=(e,t,n,s)=>{let r=t;for(;r>0&&e[r]+n<=s;)r--;const i=e[r]+n,l=Qf(r,e,s,n),c=e[l]-n;return i<s||c<s?[e,!1]:[e.map((a,d)=>d===r?i:d===l?c:a),!0]},Qf=(e,t,n,s)=>(e===t.length-1?th:eh)(e,t,n,s),eh=(e,t,n,s)=>{let r=e+1;for(;r<t.length-1&&t[r]-s<=n;)r++;return r},th=(e,t,n,s)=>{let r=e-1;for(;r>0&&t[r]-s<=n;)r--;return r},fo=2,nh=100,Ll=({onCollapse:e,onResize:t,location:n="left",minSize:s,maxSize:r,initialSize:i=200,collapseThreshold:l=1/0,className:c,...a})=>{const[d,x]=g.useState(u.D$1(i,s,r)),p=g.useRef(null),m=u.K$1.construct(n),f=g.useCallback(E=>{if(p.current===null)return 0;const R=u.Pt.dim(E,u.K$1.direction(m),!0)*(1-2*Number(["bottom","right"].includes(m))),M=p.current+R,_=u.D$1(M,s,r);return(_-M)/(s??nh)>l?fo:_},[m,s,r,l]),h=g.useRef(null),j=g.useCallback(E=>{const R=f(E);x(R),h.current!=null&&(t==null||t(R,u.Pt.construct(h.current)))},[t,f]),y=g.useCallback(()=>x(E=>(p.current=E,E)),[x]),S=g.useCallback(E=>f(E)===fo&&(e==null?void 0:e()),[e,f]);g.useEffect(()=>{s==null||r==null||x(E=>{const R=u.D$1(E,s,r);return p.current=R,R})},[s,r]);const b=Ge.useCursorDrag({onMove:j,onStart:y,onEnd:S});return o.jsxRuntimeExports.jsx(nr,{ref:h,location:m,size:d,onDragStart:b,className:u.clsx(c,u.CSS.expanded(d!==fo)),...a})},sh=Object.freeze(Object.defineProperty({__proto__:null,Core:nr,Multiple:or,Single:Ll,calculateDiffPercentage:_l,useMultiple:sr},Symbol.toStringTag,{value:"Module"})),rs="y",ri=28,oh=32,rh=40,ih=.5,lh=({data:e,...t})=>{const{setSize:n,props:{sizeDistribution:s,ref:r,...i}}=sr({direction:rs,count:e.length,minSize:ri}),l=c=>{if(r.current==null)return;const a=u.Pt.dim(u.Pt.construct(r.current),rs);s[c]<rh/a?n(c,e[c].initialSize??ih):n(c,ri+1)};return o.jsxRuntimeExports.jsx(or,{empty:!0,className:u.CSS.B("accordion"),sizeDistribution:s,ref:r,...t,...i,children:e.map((c,a)=>g.createElement(uh,{...c,key:c.key,index:a,direction:rs,onExpand:l,parent:r,size:s[a]}))})},ch=o.jsxRuntimeExports.jsx(K.y4.Caret.Down,{"aria-label":"contract"}),ah=o.jsxRuntimeExports.jsx(K.y4.Caret.Right,{"aria-label":"expand"}),uh=({index:e,name:t,content:n,actions:s,size:r,parent:i,onExpand:l})=>{let c=!0;if(i.current!=null){const d=u.Pt.dim(u.Pt.construct(i.current),rs);c=r*d>oh}const a=c?ch:ah;return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsxs(os.Header,{level:"p",className:u.CSS.expanded(c),empty:!0,children:[o.jsxRuntimeExports.jsx(os.ButtonTitle,{startIcon:a,onClick:()=>l(e),children:t}),s!=null&&o.jsxRuntimeExports.jsx(os.Actions,{children:s})]}),n]})},dh=Object.freeze(Object.defineProperty({__proto__:null,Accordion:lh},Symbol.toStringTag,{value:"Module"})),xh=(e,t)=>Pe.t.toArray(e).map(s=>typeof s=="string"?s.split(t).map(r=>({label:r})):s).flat(),Nl=({segments:e,shade:t,level:n,weight:s,separator:r,transform:i})=>{let c=xh(e,r);return i!=null&&(c=c.map(i)),c.map(({label:a,icon:d,href:x,...p},m)=>{const f=[o.jsxRuntimeExports.jsx(K.y4.Caret.Right,{style:{transform:"scale(0.8) translateY(0.5px)",color:u.CSS.shade(t)}},`${a}-${m}`)];if(d!=null){const j=Te.resolve(d);j!=null&&f.push(j)}const h={weight:s,shade:t,level:n,style:{marginLeft:d!=null?"0.5rem":"0"},children:a,...p};return x!=null?f.push(o.jsxRuntimeExports.jsx(bl.Link,{...h,href:x},a)):f.push(o.jsxRuntimeExports.jsx(K.Text,{...h},a)),f}).flat()},Tl=({children:e,icon:t,shade:n=9,weight:s,size:r=.5,url:i,level:l="p",separator:c=".",className:a,hideFirst:d=!0,...x})=>{i!=null&&(e=i);const p=Nl({segments:e,separator:c,shade:n,level:l,weight:s});return d&&p.shift(),o.jsxRuntimeExports.jsxs(As.WithIcon,{className:u.CSS(a,u.CSS.B("breadcrumb"),d&&u.CSS.M("hide-first")),level:l,shade:n,weight:s,size:r,x:!0,...x,children:[Te.resolve(t),...p]})},ph=({url:e,className:t,level:n="p",separator:s="/",weight:r,shade:i=9})=>{const l=Nl({segments:e,separator:s,shade:i,level:n,weight:r,transform:(c,a)=>({...c,label:c.label.split("-").map(d=>u.d$1.capitalize(d)).join(" "),href:`/${e.split(s).slice(0,a+1).join("/")}`})});return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(t,u.CSS.B("breadcrumb"),u.CSS.BM("breadcrumb","url")),x:!0,size:"small",align:"center",children:l})},mh=Object.freeze(Object.defineProperty({__proto__:null,Breadcrumb:Tl,URL:ph},Symbol.toStringTag,{value:"Module"})),Al=({variant:e="info",...t})=>e==="loading"?o.jsxRuntimeExports.jsx(K.y4.Loading,{...t}):o.jsxRuntimeExports.jsx(K.y4.Circle,{color:Ce.VARIANT_COLORS[e],...t}),fh=({action:e})=>g.isValidElement(e)?e:g.createElement(fe.Button,{...e,key:e.key}),hh=({status:{key:e,time:t,count:n,message:s,description:r,variant:i},silence:l,actions:c,className:a,children:d,...x})=>{const p=g.useRef(null);return o.jsxRuntimeExports.jsxs(ne.Space,{className:u.CSS(u.CSS.B("notification"),a),y:!0,empty:!0,ref:p,...x,children:[o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,justify:"spaceBetween",grow:!0,style:{width:"100%"},children:[o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(Al,{style:{height:"2.25rem",width:"2.5rem"},variant:i}),o.jsxRuntimeExports.jsx(K.Text,{level:"small",shade:11,children:`x${n}`}),o.jsxRuntimeExports.jsx(_o.DateTime,{className:u.CSS(u.CSS.BE("notification","time")),level:"small",format:"time",children:t})]}),o.jsxRuntimeExports.jsx(fe.Icon,{className:u.CSS(u.CSS.BE("notification","silence")),variant:"outlined",size:"small",onClick:()=>l(e),children:o.jsxRuntimeExports.jsx(K.y4.Close,{})})]}),o.jsxRuntimeExports.jsxs(ne.Space,{y:!0,align:"start",className:u.CSS(u.CSS.BE("notification","content")),size:"small",children:[d??o.jsxRuntimeExports.jsx(K.Text,{className:u.CSS(u.CSS.BE("notification","message")),level:"p",style:{flexGrow:1},children:s}),r!=null&&o.jsxRuntimeExports.jsx(K.Text,{className:u.CSS(u.CSS.BE("notification","description")),level:"small",style:{flexGrow:1},children:r})]}),c!=null&&o.jsxRuntimeExports.jsx(ne.Space,{x:!0,align:"center",justify:"end",className:u.CSS(u.CSS.BE("notification","actions")),children:Pe.t.toArray(c).map(m=>o.jsxRuntimeExports.jsx(fh,{action:m},m.key))})]},t.toString())},gh=Object.freeze(Object.defineProperty({__proto__:null,Aggregator:Ce.Aggregator,Indicator:Al,Notification:hh,Text:Ce.Text,VARIANT_COLORS:Ce.VARIANT_COLORS,specZ:bt.specZ,useAdder:Ce.useAdder,useErrorHandler:Ce.useErrorHandler,useNotifications:Ce.useNotifications},Symbol.toStringTag,{value:"Module"})),rr=({aetherKey:e,enabled:t=!0})=>{const{setState:n}=Q.useLifecycle({aetherKey:e,type:ps.Eraser.TYPE,schema:ps.eraserStateZ,initialState:{region:u.Pt.ZERO,enabled:t}}),s=K.useSyncedRef(t);return{erase:g.useCallback(i=>{n({enabled:s.current,region:i})},[n,s])}},jh=({aetherKey:e,children:t})=>{const{erase:n}=rr({aetherKey:e}),s=Ye.useResize(n);return o.jsxRuntimeExports.jsx("div",{ref:s,className:u.CSS(u.CSS.inheritDims()),children:t})},Eh=Object.freeze(Object.defineProperty({__proto__:null,Eraser:jh,use:rr},Symbol.toStringTag,{value:"Module"})),yh=({items:e,initialKey:t})=>{const[n,s]=g.useState(t),r=l=>s(l===n?void 0:l),i=e.find(l=>l.key===n);return{onSelect:r,activeItem:i}},Sh=({activeItem:e,children:t,onSelect:n,location:s="left",collapseThreshold:r=.65,className:i,onResize:l,onCollapse:c,eraseEnabled:a,...d})=>{const x=u.K$1.direction(s);a??(a=e!=null);const p=g.useCallback(()=>{c?c():e!=null&&(n==null||n(e.key))},[n,e==null?void 0:e.key,c]),{erase:m}=rr({enabled:a}),f=g.useCallback((b,E)=>{l==null||l(b,E),m(E)},[l,m]),{content:h,minSize:j,maxSize:y,initialSize:S=0}=e??{};return o.jsxRuntimeExports.jsx(Ll,{className:u.CSS(u.CSS.B("nav-drawer"),u.CSS.dir(x),u.CSS.visible(e!=null),i),collapseThreshold:r,onCollapse:p,location:s,onResize:f,minSize:j,maxSize:y,initialSize:S,...d,children:h})},Rh=Object.freeze(Object.defineProperty({__proto__:null,Bar:he.Bar,Drawer:Sh,useDrawer:yh},Symbol.toStringTag,{value:"Module"})),is={...B.ZERO_CONTEXT_VALUE,state:bt.bF.connectivity.DEFAULT},Il=g.createContext(is),$l=()=>g.use(Il),qe=()=>$l().client,Ch=()=>$l().state,Lo={connected:"success",connecting:"loading",disconnected:"info",failed:"error"},Bl="serverVersionMismatch",wh=(e,t,n)=>`Cluster version ${n!=null?`${n} `:""}is ${e?"older":"newer"} than client version ${t}. Compatibility issues may arise.`,Dl=({children:e,connParams:t})=>{const[n,s,r]=K.useCombinedStateAndRef(is),{path:i}=Q.useUnidirectional({type:B.Provider.TYPE,schema:B.Provider.stateZ,state:{props:t??null,state:null}}),l=Ce.useAdder(),c=g.useCallback(a=>{r.current.state.status!==a.status&&l({variant:Lo[a.status],message:a.message??u.d$1.capitalize(a.status)}),s(d=>({...d,state:a}))},[l]);return Q.useAsyncEffect(async()=>{if(n.client!=null&&n.client.close(),t==null)return s(is);const a=new bt.bF({...t,connectivityPollFrequency:bt.M.seconds(2)});s({client:a,state:{clusterKey:"",status:"connecting",message:"Connecting...",clientServerCompatible:!1,clientVersion:a.clientVersion}});const d=await a.connectivity.check();if(s({client:a,state:d}),l({variant:Lo[d.status],message:d.message??d.status.toUpperCase()}),d.status==="connected"&&!d.clientServerCompatible){const x=d.nodeVersion==null||u.dd.semVerOlder(d.nodeVersion,d.clientVersion),p=wh(x,d.clientVersion,d.nodeVersion);l({variant:"warning",message:"Incompatible cluster version",description:p,data:{type:Bl,oldServer:x,nodeVersion:d.nodeVersion,clientVersion:d.clientVersion}})}return a.connectivity.onChange(c),()=>{a.close(),s(is)}},[t,c]),o.jsxRuntimeExports.jsx(Il,{value:n,children:o.jsxRuntimeExports.jsx(Q.Composite,{path:i,children:e})})},bh=Object.freeze(Object.defineProperty({__proto__:null,CONNECTION_STATE_VARIANTS:Lo,Provider:Dl,SERVER_VERSION_MISMATCH:Bl,use:qe,useConnectionState:Ch},Symbol.toStringTag,{value:"Module"})),Ol=g.createContext({aliases:{},getName:async()=>await Promise.resolve(void 0),setAlias:null}),cn=()=>g.use(Ol),zl=e=>cn().aliases[e]??null,$s=()=>cn().aliases,Bs=(e,t="")=>{const{getName:n}=cn(),[s,r]=g.useState(t);return Q.useAsyncEffect(async()=>{const i=await n(e);r(i)},[e,n]),s??t},ir=()=>cn().activeRange??void 0,Vl=({activeRange:e,children:t})=>{const n=qe(),[s,r]=g.useState({}),i=g.useCallback(a=>{r(d=>{const x={...d};return a.forEach(({variant:p,key:m,value:f})=>{const h=Number(m.split("---")[1]);p==="delete"?delete x[h]:x[f.channel]=f.alias}),x})},[r]),l=g.useCallback(async(a,d)=>{if(n==null||e==null)return;await(await n.ranges.retrieve(e)).setAlias(a,d)},[n,e]),c=g.useCallback(async a=>{if(n==null||a===0)return;const d=s[a];return d??(await n.channels.retrieve(a)).name},[s,n]);return Q.useAsyncEffect(async()=>{if(n==null||e==null){r({});return}const a=await n.ranges.retrieve(e),d=await a.listAliases();r(d);const x=await a.openAliasTracker(),p=x.onChange(i);return()=>{p(),x.close()}},[n,e]),o.jsxRuntimeExports.jsx(Ol,{value:{aliases:s,activeRange:e,setAlias:e!=null?l:null,getName:c},children:t})},vh=({channelKey:e,value:t,shadow:n,className:s,...r})=>{const[i,l]=g.useState(!1),{setAlias:c}=cn(),a=zl(e),d=Bs(e);let x=o.jsxRuntimeExports.jsx(K.y4.Rename,{});i?x=o.jsxRuntimeExports.jsx(K.y4.Loading,{}):a===t&&(x=o.jsxRuntimeExports.jsx(K.y4.Check,{}));const p=c!=null&&!i&&a!==t&&e!==0,m=Ce.useErrorHandler(),f=()=>{p&&m(async()=>{l(!0),await c(e,t),l(!1)},"Failed to set channel alias")},h=()=>{var y;a!=null&&((y=r.onChange)==null||y.call(r,a))},j=()=>e===0?o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:"Select a channel to enable alias syncing with this label"}):c==null?o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:"Select a range to enable alias syncing with this label"}):t.length===0?o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:"Enter a value to enable alias syncing with this label"}):a===t?o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:"Alias synced with this label"}):o.jsxRuntimeExports.jsxs(K.Text,{level:"small",children:["Sync alias for ",d," with this label"]});return o.jsxRuntimeExports.jsxs(pt.Text,{value:t,...r,children:[p&&o.jsxRuntimeExports.jsx(fe.Icon,{onClick:h,tooltip:o.jsxRuntimeExports.jsxs(K.Text,{level:"small",children:["Set ",d," as label"]}),tooltipLocation:{y:"top"},variant:"outlined",children:o.jsxRuntimeExports.jsx(K.y4.Sync,{})}),o.jsxRuntimeExports.jsx(fe.Icon,{onClick:f,disabled:!p,tooltip:o.jsxRuntimeExports.jsx(j,{}),tooltipLocation:{y:"top"},variant:"outlined",children:x})]})},nt="channel";var ii=180/Math.PI,No={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fl(e,t,n,s,r,i){var l,c,a;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(a=e*n+t*s)&&(n-=e*a,s-=t*a),(c=Math.sqrt(n*n+s*s))&&(n/=c,s/=c,a/=c),e*s<t*n&&(e=-e,t=-t,a=-a,l=-l),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ii,skewX:Math.atan(a)*ii,scaleX:l,scaleY:c}}var Gn;function kh(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?No:Fl(t.a,t.b,t.c,t.d,t.e,t.f)}function Mh(e){return e==null||(Gn||(Gn=document.createElementNS("http://www.w3.org/2000/svg","g")),Gn.setAttribute("transform",e),!(e=Gn.transform.baseVal.consolidate()))?No:(e=e.matrix,Fl(e.a,e.b,e.c,e.d,e.e,e.f))}function Hl(e,t,n,s){function r(d){return d.length?d.pop()+" ":""}function i(d,x,p,m,f,h){if(d!==p||x!==m){var j=f.push("translate(",null,t,null,n);h.push({i:j-4,x:B.interpolateNumber(d,p)},{i:j-2,x:B.interpolateNumber(x,m)})}else(p||m)&&f.push("translate("+p+t+m+n)}function l(d,x,p,m){d!==x?(d-x>180?x+=360:x-d>180&&(d+=360),m.push({i:p.push(r(p)+"rotate(",null,s)-2,x:B.interpolateNumber(d,x)})):x&&p.push(r(p)+"rotate("+x+s)}function c(d,x,p,m){d!==x?m.push({i:p.push(r(p)+"skewX(",null,s)-2,x:B.interpolateNumber(d,x)}):x&&p.push(r(p)+"skewX("+x+s)}function a(d,x,p,m,f,h){if(d!==p||x!==m){var j=f.push(r(f)+"scale(",null,",",null,")");h.push({i:j-4,x:B.interpolateNumber(d,p)},{i:j-2,x:B.interpolateNumber(x,m)})}else(p!==1||m!==1)&&f.push(r(f)+"scale("+p+","+m+")")}return function(d,x){var p=[],m=[];return d=e(d),x=e(x),i(d.translateX,d.translateY,x.translateX,x.translateY,p,m),l(d.rotate,x.rotate,p,m),c(d.skewX,x.skewX,p,m),a(d.scaleX,d.scaleY,x.scaleX,x.scaleY,p,m),d=x=null,function(f){for(var h=-1,j=m.length,y;++h<j;)p[(y=m[h]).i]=y.x(f);return p.join("")}}}var Ph=Hl(kh,"px, ","px)","deg)"),_h=Hl(Mh,", ",")",")"),Lh=1e-12;function li(e){return((e=Math.exp(e))+1/e)/2}function Nh(e){return((e=Math.exp(e))-1/e)/2}function Th(e){return((e=Math.exp(2*e))-1)/(e+1)}const ls=function e(t,n,s){function r(i,l){var c=i[0],a=i[1],d=i[2],x=l[0],p=l[1],m=l[2],f=x-c,h=p-a,j=f*f+h*h,y,S;if(j<Lh)S=Math.log(m/d)/t,y=function(L){return[c+L*f,a+L*h,d*Math.exp(t*L*S)]};else{var b=Math.sqrt(j),E=(m*m-d*d+s*j)/(2*d*n*b),R=(m*m-d*d-s*j)/(2*m*n*b),M=Math.log(Math.sqrt(E*E+1)-E),_=Math.log(Math.sqrt(R*R+1)-R);S=(_-M)/t,y=function(L){var A=L*S,$=li(M),O=d/(n*b)*($*Th(t*A+M)-Nh(M));return[c+O*f,a+O*h,d*$/li(t*A+M)]}}return y.duration=S*1e3*t/Math.SQRT2,y}return r.rho=function(i){var l=Math.max(.001,+i),c=l*l,a=c*c;return e(l,c,a)},r}(Math.SQRT2,2,4),Ah=Object.freeze(Object.defineProperty({__proto__:null,Base:B.Base,Bottom:B.Bottom,Right:B.Right,Top:B.Top,axisStateZ:B.axisStateZ,newCanvas:B.newCanvas,newTickFactory:B.newTickFactory,tickFactoryProps:B.tickFactoryProps,tickType:B.tickType},Symbol.toStringTag,{value:"Module"})),Ih={region:u.Pt.ZERO,dpr:1,os:u.S.getOS()},$h={gl:null,lower2d:null,upper2d:null,bootstrapped:!1},Bh=({children:e,resizeDebounce:t=100,className:n,...s})=>{const[{path:r},{bootstrapped:i,dpr:l},c]=Q.use$1({type:B.Canvas.TYPE,schema:B.canvasStateZ,initialState:Ih}),a=g.useRef({...$h}),d=g.useRef(!1),x=g.useCallback(j=>{a.current.bootstrapped&&(c(()=>({bootstrapped:!0,region:j,dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})})),d.current=!0)},[c]),p=g.useRef(null),m=Ye.useResize(x,{debounce:t}),f=K.useCombinedRefs(p,m);g.useEffect(()=>{const j=()=>{window.devicePixelRatio===l||!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.Pt.construct(p.current),dpr:window.devicePixelRatio}))};window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`).addEventListener("change",j,{once:!0})},[l]),g.useEffect(()=>{const j=()=>{!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.Pt.construct(p.current),glCanvas:void 0,upper2dCanvas:void 0,lower2dCanvas:void 0}))};window.addEventListener("focus",j),window.addEventListener("blur",j)},[c]);const h=g.useCallback(j=>{if(j==null)return;j.className.includes("gl")?a.current.gl=j:j.className.includes("upper2d")?a.current.upper2d=j:a.current.lower2d=j;const{gl:y,lower2d:S,upper2d:b,bootstrapped:E}=a.current;if(y==null||S==null||b==null||E)return;a.current.bootstrapped=!0;const R=y.transferControlToOffscreen(),M=b.transferControlToOffscreen(),_=S.transferControlToOffscreen();c({glCanvas:R,upper2dCanvas:M,lower2dCanvas:_,bootstrap:!0,bootstrapped:!1,region:u.Pt.construct(y),dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})},[R,M,_])},[c]);return o.jsxRuntimeExports.jsxs("div",{ref:f,className:u.CSS(u.CSS.B("canvas-container"),n),...s,children:[o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","lower2d"))}),o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","gl"))}),o.jsxRuntimeExports.jsx("canvas",{ref:h,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","upper2d"))}),o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:i&&e})]})},In=(e,t)=>Ye.useResize(g.useCallback((n,s)=>{const r=document.querySelector(".pluto-canvas--lower2d");r!=null&&e(u.A.XY.translate(u.K.scale(u.Pt.topLeft(r),-1)).box(n),s)},[e]),t),Dh=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Bh,useRegion:In},Symbol.toStringTag,{value:"Module"})),Zl=g.createContext(null),st=e=>{const t=g.use(Zl);if(t==null)throw new Error(`Cannot to use ${e} as a non-child of LinePlot.`);return t},Kl=e=>{const{addViewportHandler:t}=st("Viewport");g.useEffect(()=>t(e),[t,e])},$n=(e,t)=>{const{setGridEntry:n,removeGridEntry:s}=st(t),{key:r}=e;return Q.useEffectCompare(()=>{u.K$1.outer.parse(e.loc),n(e)},([c],[a])=>Be.J.equal(c,a),[e]),g.useEffect(()=>()=>s(r),[]),{gridArea:u.g.swap(u.K$1.direction(e.loc))==="x"?`axis-start-${r} / plot-start / axis-end-${r} / plot-end`:`plot-start / axis-start-${r} / plot-end / axis-end-${r}`}},Wl=({aetherKey:e,style:t,resizeDebounce:n=0,clearOverScan:s=u.K.ZERO,children:r,hold:i=!1,onHold:l,visible:c,...a})=>{const[d,x]=g.useState([]),p=Ae.useMemoDeepEqualProps({clearOverScan:s,hold:i,visible:c}),[{path:m},{grid:f},h]=Q.use$1({aetherKey:e,type:B.LinePlot.TYPE,schema:B.linePlotStateZ,initialState:{container:u.Pt.ZERO,viewport:u.Pt.DECIMAL,grid:{},...p}}),j=g.useCallback(z=>{c&&h(k=>({...k,container:z}))},[h,c]),y=In(j,{debounce:n});g.useEffect(()=>h(z=>({...z,...p})),[p]);const S=g.useRef(new Map),b=g.useCallback(z=>(S.current.set(z,null),()=>S.current.delete(z)),[S]),E=g.useCallback(z=>{const{mode:k,box:C,stage:P}=z;(k==="pan"&&P!=="start"||k==="zoom"||k==="zoomReset"&&P==="start")&&h(v=>({...v,viewport:C})),S.current.forEach((v,N)=>N(z))},[h]),R=g.useCallback(z=>{h(k=>({...k,grid:{...k.grid,[z.key]:z}}))},[h]),M=g.useCallback(z=>h(k=>{const{[z]:C,...P}=k.grid;return{...k,grid:P}}),[h]),_=g.useCallback(z=>{x(k=>[...k.filter(({key:C})=>C!==z.key),z])},[x]),L=g.useCallback(z=>x(k=>k.filter(({key:C})=>C!==z)),[_]),A=g.useMemo(()=>Oh(f),[f]),$=g.useCallback(z=>{h(k=>({...k,hold:z})),l==null||l(z)},[h,l]),O=`line-plot-${e}`,V=g.useMemo(()=>({lines:d,setGridEntry:R,removeGridEntry:M,setLine:_,removeLine:L,setViewport:E,addViewportHandler:b,setHold:$,id:O}),[O,d,R,M,_,L,E,b,$]);return o.jsxRuntimeExports.jsx("div",{id:O,className:u.CSS.B("line-plot"),style:{...t,...A},ref:y,...a,children:o.jsxRuntimeExports.jsx(Zl,{value:V,children:o.jsxRuntimeExports.jsx(Q.Composite,{path:m,children:r})})})},Oh=e=>{const t=u.CSS.newGridBuilder();return B.regions("top",e).forEach(({key:n,size:s})=>t.row(`axis-start-${n}`,`axis-end-${n}`,s)),t.row("plot-start","plot-end","minmax(0, 1fr)"),B.regions("bottom",e).reverse().forEach(({key:n,size:s})=>t.row(`axis-start-${n}`,`axis-end-${n}`,s)),B.regions("left",e).forEach(({key:n,size:s})=>t.col(`axis-start-${n}`,`axis-end-${n}`,s)),t.col("plot-start","plot-end","minmax(0, 1fr)"),B.regions("right",e).forEach(({key:n,size:s})=>t.col(`axis-start-${n}`,`axis-end-${n}`,s)),t.build()},lr=e=>{const t=e==="x"?"bottom":"left",n=e==="x"?B.XAxis.TYPE:B.YAxis.TYPE,s=`${e}-axis`,r=({aetherKey:i,children:l,location:c=t,label:a="",labelLevel:d="small",labelDirection:x=e,onLabelChange:p,color:m,labelSize:f,showGrid:h,type:j,bounds:y,className:S,tickSpacing:b,autoBounds:E,axisKey:R,autoBoundUpdateInterval:M,onAutoBoundsChange:_,style:L,...A})=>{const $=((a==null?void 0:a.length)??0)>0,O=Q.useUniqueKey(i),V=Ae.useMemoDeepEqualProps({location:c,showGrid:h,type:j,bounds:y,axisKey:R,label:a,labelDirection:x,tickSpacing:b,autoBounds:E,autoBoundUpdateInterval:M}),[{path:z},{size:k,labelSize:C,...P},v]=Q.use$1({aetherKey:O,type:n,schema:B.coreAxisStateZ,initialState:V});g.useEffect(()=>v(F=>({...F,...V})),[V]),g.useEffect(()=>{const{lower:F,upper:H}=B.parseAutoBounds(P.autoBounds);P.bounds!=null&&(F&&(y==null?void 0:y.lower)!==P.bounds.lower||H&&(y==null?void 0:y.upper)!==P.bounds.upper)&&(_==null||_(P.bounds))},[P.autoBounds,P.bounds]);const N=$n({loc:c,key:`${n}-${O}`,size:k+C,order:1},`${e.toUpperCase()}Axis`),D=er.useTypography(d).toString(),I=g.useRef(0);return g.useEffect(()=>{if(e==="y"){if(a==null)return;let H=si.dimensions(a,D)[u.g.dimension(u.g.construct(x))];H>0&&(H+=9),v(Z=>({...Z,labelSize:H}))}else{let H=si.dimensions(a,D).height*1.3;H>0&&(H+=12);const Z=I.current;B.withinSizeThreshold(Z,H)||(I.current=H,v(ee=>({...ee,labelSize:H})))}},[a,x,D]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(S,u.CSS.B("axis"),u.CSS.B(s),u.CSS.loc(c)),style:{...L,...N},align:"center",justify:c!=="left"?"end":"start",direction:u.g.swap(e),...A,children:$&&o.jsxRuntimeExports.jsx(K.MaybeEditable,{className:u.CSS(u.CSS.BE("axis","label"),u.CSS.dir(x)),value:a,onChange:p,level:d})}),o.jsxRuntimeExports.jsx(Q.Composite,{path:z,children:l})]})};return r.displayName=`${e.toUpperCase()}Axis`,r},Yl=lr("x"),Gl=lr("y"),ql=u.K.xy.extend({root:u.K$1.corner,units:ce.object({x:ce._enum(["px","decimal"]),y:ce._enum(["px","decimal"])})}),zh=ql.partial({root:!0,units:!0}),Vh=e=>{var n,s,r,i;const t={};return t[((n=e.root)==null?void 0:n.x)??"left"]=((s=e==null?void 0:e.units)==null?void 0:s.x)==="px"?`${e.x}px`:`${e.x*100}%`,t[((r=e.root)==null?void 0:r.y)??"top"]=((i=e==null?void 0:e.units)==null?void 0:i.y)==="px"?`${e.y}px`:`${e.y*100}%`,t},Fh=(e,t)=>{var i,l,c,a,d,x;const n={x:e.x,y:e.y};if(t.current==null)return n;const s=u.Pt.construct(t.current),r=u.Pt.construct(t.current.parentElement);return((i=e.units)==null?void 0:i.x)==="decimal"?((l=e.root)==null?void 0:l.x)==="right"&&(n.x=1-e.x):((c=e.root)==null?void 0:c.x)==="right"?n.x=1-(e.x+u.Pt.width(s))/u.Pt.width(r):n.x/=u.Pt.width(r),((a=e.units)==null?void 0:a.y)==="decimal"?((d=e.root)==null?void 0:d.y)==="bottom"&&(n.y=1-e.y):((x=e.root)==null?void 0:x.y)==="bottom"?n.y=1-(e.y+u.Pt.height(s))/u.Pt.height(r):n.y/=u.Pt.height(r),n},Xl=(e,t)=>{if(t.current==null)return null;const n=u.Pt.construct(t.current.parentElement),s=u.Pt.construct(t.current),r={x:e.x,y:e.y,root:{...u.K$1.TOP_LEFT},units:{x:"px",y:"px"}};return e.x>.8?(r.x=(1-e.x)*u.Pt.width(n)-u.Pt.width(s),r.root.x="right"):e.x<.2?r.x=e.x*u.Pt.width(n):r.units.x="decimal",e.y>.8?(r.y=(1-e.y)*u.Pt.height(n)-u.Pt.height(s),r.root.y="bottom"):e.y<.2?r.y=e.y*u.Pt.height(n):r.units.y="decimal",r.x=Math.round(r.x*100)/100,{...r,...u.K.truncate(r,3)}},ci=u.Pt.reRoot(u.Pt.DECIMAL,u.K$1.TOP_LEFT),Hh={x:.1,y:.1,root:u.K$1.TOP_LEFT,units:{x:"decimal",y:"decimal"}},cr=g.memo(({className:e,value:t,onChange:n,style:s,draggable:r=!0,initial:i=Hh,...l})=>{const[c,a]=ce.usePurePassthrough({value:t,onChange:n,initial:i}),d=g.useRef(c),x=K.useSyncedRef(r===!1),p=g.useRef(null);c!==null&&(s={...s,...Vh(c)});const m=g.useCallback(h=>{var M;if(((M=p.current)==null?void 0:M.parentElement)==null)return d.current;const j=u.Pt.construct(p.current.parentElement),y=u.A.XY.scale(j).scale(ci),S=y.box(u.Pt.construct(p.current)),b=u.A.XY.clamp(u.Pt.construct(u.Pt.topLeft(ci),{width:1-u.Pt.width(S),height:1-u.Pt.height(S)})),E=u.K.translate(u.K.construct(d.current),u.Pt.signedDims(y.box(h))),R=b.pos(E);return Xl(R,p)},[]),f=Ge.useCursorDrag({onStart:g.useCallback(()=>{d.current=Fh(d.current,p)},[]),onMove:g.useCallback(h=>{if(x.current)return;const j=m(h);j!==null&&a(j)},[]),onEnd:g.useCallback(h=>{if(x.current)return;const j=m(h);j!==null&&(d.current=j)},[])});return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(e,u.CSS.B("legend")),bordered:!0,rounded:!0,style:s,onDragStart:f,draggable:r,borderShade:5,ref:p,onDrag:he.preventDefault,onDragEnd:he.preventDefault,background:1,...l})});cr.displayName="Legend.Container";const Ds=g.memo(({data:e,onEntryChange:t,onVisibleChange:n,allowVisibleChange:s=!0,shade:r=1})=>o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:e.sort((i,l)=>i.label.localeCompare(l.label)).map(({key:i,color:l,label:c,visible:a=!0})=>o.jsxRuntimeExports.jsxs(ne.Space,{style:{cursor:"pointer"},x:!0,align:"center",size:"small",justify:"spaceBetween",grow:!0,children:[o.jsxRuntimeExports.jsxs(ne.Space,{direction:"x",align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(Ge.Swatch,{value:l,onChange:d=>t==null?void 0:t({key:i,color:d,label:c,visible:a}),onVisibleChange:n,allowChange:t!=null,draggable:!1,size:"tiny"}),o.jsxRuntimeExports.jsx(K.MaybeEditable,{level:"small",value:c,onChange:d=>t==null?void 0:t({key:i,color:l,label:d,visible:a}),noWrap:!0,shade:a?10:7,onDoubleClick:d=>d.stopPropagation()})]}),s&&o.jsxRuntimeExports.jsx(fe.Icon,{className:u.CSS.B("visible-toggle"),onClick:d=>{d.stopPropagation(),t==null||t({key:i,color:l,label:c,visible:!a})},onDoubleClick:d=>d.stopPropagation(),size:"tiny",shade:r,children:a?o.jsxRuntimeExports.jsx(K.y4.Visible,{}):o.jsxRuntimeExports.jsx(K.y4.Hidden,{})})]},i))}));Ds.displayName="LegendSwatches";const ar=({data:e=[],onEntryChange:t,position:n,onPositionChange:s,allowVisibleChange:r=!0,...i})=>{const[l,c]=g.useState(!1);return e.length===0?null:o.jsxRuntimeExports.jsx(cr,{...i,className:r?u.CSS.M("with-visible-toggle"):void 0,draggable:!l,value:n,onChange:s,size:r?0:"tiny",children:o.jsxRuntimeExports.jsx(Ds,{data:e,onEntryChange:t,onVisibleChange:c,allowVisibleChange:r})})},Zh=Object.freeze(Object.defineProperty({__proto__:null,Container:cr,LegendSwatches:Ds,Simple:ar,calcStickyPos:Xl,completeStickyXYz:ql,stickyXYz:zh},Symbol.toStringTag,{value:"Module"})),ur=g.memo(({className:e,style:t,onLineChange:n,...s})=>{const{lines:r}=st("Legend");return st("Legend"),o.jsxRuntimeExports.jsx(ar,{data:r,onEntryChange:n,...s})});ur.displayName="FloatingLegend";const Kh=({onLineChange:e})=>{const{lines:t}=st("Legend"),n=Q.useUniqueKey(),s=$n({key:n,size:t.length>0?36:0,loc:"bottom",order:5},"Legend");return o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS.BE("legend","container"),align:"center",x:!0,style:{...s,padding:"0 1rem",height:"var(--pluto-height-medium)",margin:"1rem 0 ",width:"fit-content"},children:o.jsxRuntimeExports.jsx(Ds,{data:t,onEntryChange:e,shade:0})})},Ul=({variant:e="floating",...t})=>e==="floating"?o.jsxRuntimeExports.jsx(ur,{...t}):o.jsxRuntimeExports.jsx(Kh,{...t}),dr=g.memo(({aetherKey:e,...t})=>(Q.useUnidirectional({aetherKey:e,type:B.Line.TYPE,schema:B.stateZ,state:t}),null));dr.displayName="Line";const Wh=Object.freeze(Object.defineProperty({__proto__:null,Line:dr},Symbol.toStringTag,{value:"Module"})),xr=({aetherKey:e,color:t,label:n="",visible:s=!0,...r})=>{const i=Q.useUniqueKey(e),{setLine:l,removeLine:c}=st("Line");return g.useEffect(()=>(l({key:i,color:t,label:n,visible:s}),()=>c(i)),[n,t,s]),o.jsxRuntimeExports.jsx(dr,{aetherKey:i,color:t,label:n,visible:s,...r})},Jl=({level:e="h2",...t})=>{const n=Q.useUniqueKey(),s=er.useTypography(e),r=$n({key:n,size:(s.lineHeight+2)*s.baseSize,loc:"top",order:10},"Title");return o.jsxRuntimeExports.jsx(ne.Space,{justify:"center",align:"center",style:r,children:o.jsxRuntimeExports.jsx(K.MaybeEditable,{...t,level:e})})},Ql=({aetherKey:e,...t})=>{const n=Q.useUniqueKey(e),[,,s]=Q.use$1({aetherKey:n,type:B.Tooltip.TYPE,schema:B.tooltipStateZ,initialState:{position:null,...t}}),r=g.useRef(null),i=g.useCallback(c=>{const a=document.querySelector(".pluto-canvas-container");if(a==null)return;const d=u.Pt.topLeft(a);s({position:u.K.translation(d,u.K.construct(c))})},[s]),l=g.useCallback(()=>s({position:null}),[s]);return g.useEffect(()=>{if(r.current===null)return;const c=r.current.parentElement;if(c!=null)return c.addEventListener("mousemove",i),c.addEventListener("mouseleave",l),()=>{c.removeEventListener("mousemove",i),c.removeEventListener("mouseleave",l)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:r})},Yh=Object.freeze(Object.defineProperty({__proto__:null,Tooltip:Ql},Symbol.toStringTag,{value:"Module"})),ec=()=>{const e=g.useRef(new Map),t=g.useCallback(s=>{const{request:r,response:i}=s,l=e.current.get(r);l!=null&&(l(i.bounds),e.current.delete(r))},[]),[,,n]=Q.use$1({type:B.BoundQuerier.TYPE,schema:B.boundQuerierStateZ,onAetherChange:t,initialState:{request:"",response:{request:"",bounds:{}}}});return g.useCallback(async()=>await new Promise(s=>{const r=u.we.create();e.current.set(r,s),n(i=>({...i,request:r}))}),[])},Gh=({ref:e})=>(e.current=ec(),null),qh={select:"pointer",zoom:"crosshair",pan:"grab",zoomReset:"crosshair",click:"pointer",cancel:"default"},tc=({className:e,mode:t,maskBox:n,children:s,style:r,...i})=>o.jsxRuntimeExports.jsxs("div",{className:u.CSS(u.CSS.noSelect,u.CSS.BE("viewport-mask","container"),e),style:{cursor:qh[t],...r},...i,children:[o.jsxRuntimeExports.jsx("div",{style:{...u.Pt.css(n),display:u.Pt.areaIsZero(n)?"none":"block"},className:u.CSS.BE("viewport-mask","selection")}),s]}),Xh=[],pr=({data:e,emptyContent:t,value:n,onChange:s,allowMultiple:r,allowNone:i,hideColumnHeader:l=!1,columns:c=Xh,visible:a,itemHeight:d=Ce.Column.itemHeight,listItem:x=fe.componentRenderProp(Ce.Column.Item),replaceOnSingle:p,omit:m,autoSelectOnNone:f,trigger:h,extraDialogContent:j,variant:y="connected",...S})=>{let b=o.jsxRuntimeExports.jsxs(Ce.Hover,{disabled:!a,children:[j,o.jsxRuntimeExports.jsx(Ce.Column.Header,{hide:l||x!=null,columns:c,children:o.jsxRuntimeExports.jsx(Ce.Core.Virtual,{itemHeight:d,children:x})})]});return y!=="connected"&&(b=o.jsxRuntimeExports.jsx(Is.Pack,{y:!0,className:u.CSS.B("select-dialog-content"),children:b})),o.jsxRuntimeExports.jsx(Ce.List,{data:e,emptyContent:t,omit:m,children:o.jsxRuntimeExports.jsx(Ce.Selector,{value:n,onChange:s,allowMultiple:r,allowNone:i,replaceOnSingle:p,autoSelectOnNone:f,children:o.jsxRuntimeExports.jsxs(Ye.Dialog,{visible:a,className:u.CSS.B("select"),keepMounted:!1,variant:y,...S,children:[h,b]})})})},ot=({children:e=Uh,value:t,onChange:n,entryRenderKey:s="key",tooltipKey:r,allowNone:i=!1,allowMultiple:l=!1,data:c,replaceOnSingle:a,className:d,size:x="medium",actions:p,pack:m=!0,variant:f,tooltipLocation:h,tooltipDelay:j,...y})=>{const{onSelect:S}=Ce.useSelect({allowMultiple:l,allowNone:i,replaceOnSingle:a,data:c,value:t,onChange:n}),b=R=>{f!=="preview"&&S(R)},E=c==null?void 0:c.map(R=>e({key:R.key,onClick:()=>b(R.key),size:x,selected:R.key===t,entry:R,title:R[s],tooltip:r?R[r]:void 0,tooltipLocation:h,tooltipDelay:j}));return m?o.jsxRuntimeExports.jsxs(Is.Pack,{borderShade:5,className:u.CSS(u.CSS.B("select-button"),d),size:x,...y,children:[E,p]}):o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:E})},Uh=({key:e,onClick:t,selected:n,title:s,size:r,tooltip:i,tooltipLocation:l,tooltipDelay:c})=>o.jsxRuntimeExports.jsx(fe.Button,{onClick:t,variant:n?"filled":"outlined",size:r,tooltip:i,tooltipLocation:l,tooltipDelay:c,children:s},e),nc=({selected:e,renderKey:t,toggle:n,visible:s,children:r,...i})=>o.jsxRuntimeExports.jsx(fe.Button,{className:u.CSS.B("select-dropdown-button"),onClick:n,variant:"outlined",endIcon:o.jsxRuntimeExports.jsx(An.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:s}),...i,children:r??(e==null?void 0:e[t])}),sc=fe.componentRenderProp(nc),Os=({data:e,value:t,columns:n=[],children:s=sc,entryRenderKey:r="key",allowNone:i=!1,onChange:l,disabled:c,hideColumnHeader:a=!0,variant:d,dropdownVariant:x,...p})=>{const{close:m,visible:f,toggle:h}=Ye.use(),[j,y]=g.useState((e==null?void 0:e.find(E=>E.key===t))??null);g.useEffect(()=>{y((e==null?void 0:e.find(E=>E.key===t))??null)},[e,t]);const S=g.useCallback((E,R)=>{if(!(Array.isArray(E)||E===null)){if(m(),E==null)return y(null),l(t);y(R.entries[0]),l(E)}},[l,t,m,y]),b={selected:j,renderKey:r,toggle:h,visible:f,disabled:c};return d!=null&&(b.variant=d),o.jsxRuntimeExports.jsx(pr,{close:m,data:e,visible:f,value:t,onChange:S,allowMultiple:!1,allowNone:i,columns:n,hideColumnHeader:a,variant:x,trigger:o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:s(b)}),...p})},Jh=[{key:"start",icon:o.jsxRuntimeExports.jsx(K.y4.TextAlign.Left,{})},{key:"center",icon:o.jsxRuntimeExports.jsx(K.y4.TextAlign.Center,{})},{key:"end",icon:o.jsxRuntimeExports.jsx(K.y4.TextAlign.Right,{})}],Qh=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(fe.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),zs=({children:e=Qh,...t})=>o.jsxRuntimeExports.jsx(ot,{...t,allowMultiple:!1,data:Jh,children:e}),e1=[{key:"large",label:"L"},{key:"medium",label:"M"},{key:"small",label:"S"}],oc=e=>o.jsxRuntimeExports.jsx(ot,{...e,data:e1,entryRenderKey:"label"}),t1=new Set([u.m.UUID,u.m.JSON]),rc=u.m.ALL.filter(e=>e!==u.m.UNKNOWN).map(e=>({key:e.toString(),name:t1.has(e)?e.toString().toUpperCase():u.d$1.capitalize(e.toString())})),n1=rc.filter(e=>!new u.m(e.key).isVariable),s1=[{key:"name",name:"Name"}],o1=({hideVariableDensity:e=!1,...t})=>o.jsxRuntimeExports.jsx(Os,{...t,data:e?n1:rc,columns:s1,entryRenderKey:"name"}),r1=[{key:"x",icon:o.jsxRuntimeExports.jsx(K.y4.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(K.y4.Arrow.Up,{})}],i1=[{key:"x",icon:o.jsxRuntimeExports.jsx(K.y4.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(K.y4.Arrow.Down,{})}],l1=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(fe.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),ic=({children:e=l1,yDirection:t="up",...n})=>o.jsxRuntimeExports.jsx(ot,{...n,allowMultiple:!1,data:t==="up"?r1:i1,children:e}),lc=e=>o.jsxRuntimeExports.jsx(fe.Icon,{className:u.CSS.BE("select","clear"),variant:"outlined",...e,children:o.jsxRuntimeExports.jsx(K.y4.Close,{"aria-label":"clear"})}),mt=({onChange:e,value:t,entryRenderKey:n="key",data:s,inputProps:r,allowNone:i=!0,searcher:l,className:c,variant:a="button",hideColumnHeader:d=!1,disabled:x,children:p,dropdownVariant:m="connected",placeholder:f=Vs,inputPlaceholder:h=f,triggerTooltip:j,dropdownZIndex:y,filter:S,actions:b,...E})=>{const{visible:R,open:M,close:_,toggle:L}=Ye.use(),[A,$]=g.useState(null),O=l!=null;Q.useAsyncEffect(async()=>{if(Ce.selectValueIsZero(t))return $(null);if((A==null?void 0:A.key)===t)return;let P=null;if(O)try{[P]=await l.retrieve([t])}finally{P??(P=null)}else s!=null&&(P=s.find(v=>v.key===t)??null);$(P)},[l,t,s]);const V=g.useCallback((P,v)=>{Array.isArray(P)||($(P==null?null:v.entries[0]),_(),e(P,v))},[e,i]),z=g.useMemo(()=>O?kt.Search:kt.Filter,[O]),k=o.jsxRuntimeExports.jsx(z,{searcher:l,filter:S,children:({onChange:P})=>o.jsxRuntimeExports.jsx(c1,{...r,autoFocus:m==="modal",variant:a,onChange:P,onFocus:M,selected:A,entryRenderKey:n,visible:R,allowNone:i,className:c,dropdownVariant:m,disabled:x,placeholder:h,children:b})}),C=o.jsxRuntimeExports.jsx(fe.Button,{tooltip:j,variant:"outlined",onClick:L,disabled:x,children:A!=null?cc(n,A):f});return o.jsxRuntimeExports.jsx(pr,{close:_,zIndex:y,data:s,allowMultiple:!1,visible:R,value:t,hideColumnHeader:d,onChange:V,allowNone:i,listItem:p,variant:m,trigger:m!=="modal"?k:C,extraDialogContent:m==="modal"?k:void 0,keepMounted:!1,...E})},Vs="Select",cc=(e,t)=>t==null?"":typeof e=="function"?e(t):t[e].toString(),c1=({entryRenderKey:e,selected:t,visible:n,onChange:s,onFocus:r,allowNone:i=!0,placeholder:l=Vs,className:c,disabled:a,dropdownVariant:d,children:x,...p})=>{const{clear:m}=Ce.useSelectionUtils(),[f,h]=g.useState("");g.useEffect(()=>{if(!n){if(u.G$1.isZero(t==null?void 0:t.key))return h("");t!=null&&h(cc(e,t))}},[t,n,e]);const j=R=>{s(R),h(R)},y=()=>{f===""&&s(""),h(""),r==null||r()},S=R=>{n||(R.preventDefault(),r==null||r())},b=()=>{h(""),m==null||m()};let E;return d!=="modal"&&(E=o.jsxRuntimeExports.jsx(An.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:n})),o.jsxRuntimeExports.jsxs(pt.Text,{className:u.CSS(u.CSS.BE("select","input"),c),value:f,onChange:j,onFocus:y,onKeyDown:De.matchCallback([["Enter"]],R=>{R.preventDefault(),!n&&(r==null||r())}),endContent:E,style:{flexGrow:1},onClick:S,placeholder:l,disabled:a,...p,children:[x,i&&o.jsxRuntimeExports.jsx(lc,{onClick:b,disabled:a})]})},wn=({children:e="",size:t="medium",color:n,icon:s,onClose:r,className:i,onDragStart:l,...c})=>{const a=u.od.cssString(n);s==null&&n!=null&&(s=o.jsxRuntimeExports.jsx(K.y4.Circle,{fill:a}));const d=r==null?void 0:o.jsxRuntimeExports.jsx(fe.Icon,{"aria-label":"close",size:"small",className:u.CSS.BE("tag","close"),shade:1,sharp:!0,onClick:x=>{x.stopPropagation(),r()},children:o.jsxRuntimeExports.jsx(K.y4.Close,{})});return o.jsxRuntimeExports.jsx(As.WithIcon,{startIcon:s,endIcon:d,className:u.CSS(i,u.CSS.B("tag"),u.CSS.size(t),r!=null&&u.CSS.BM("tag","closeable")),level:ce.ComponentSizeLevels[t],noWrap:!0,align:"center",size:"small",onDragStart:l,...c,children:e})},a1=Object.freeze(Object.defineProperty({__proto__:null,Tag:wn},Symbol.toStringTag,{value:"Module"})),mr=({entryKey:e,entryRenderKey:t,entry:n,loading:s,...r})=>{let i=e;return n!=null&&(i=typeof t=="function"?t(n):n[t]),g.createElement(wn,{size:"small",variant:"outlined",className:u.CSS(n==null&&!s&&u.CSS.BEM("select-multiple","tag","invalid")),draggable:!0,...r,key:e.toString()},u.fd(i))},u1=fe.componentRenderProp(mr),an=({onChange:e,value:t,className:n,data:s,columns:r=[],entryRenderKey:i="key",emptyContent:l,searcher:c,renderTag:a=u1,placeholder:d,onTagDragStart:x,allowMultiple:p,allowNone:m,replaceOnSingle:f,onTagDragEnd:h,style:j,addPlaceholder:y="Add",children:S,dropdownVariant:b="connected",actions:E,...R})=>{const{visible:M,open:_,close:L}=Ye.use(),[A,$]=g.useState([]),[O,V]=g.useState(!1),z=c!=null;Q.useAsyncEffect(async()=>{V(!0),Ce.selectValueIsZero(t)&&$([]);const N=A.map(F=>F.key),D=Pe.t.toArray(t);if(u.L.unorderedPrimitiveArrays(N,D)===u.L.EQUAL)return;let I=[];if(z)try{I=await c.retrieve(D)}finally{V(!1)}else s!=null&&(I=s.filter(F=>D.includes(F.key)));$(I)},[c,z,t,s]);const k=g.useCallback((N,D)=>{N!=null&&($(D.entries),e(Pe.t.toArray(N),D))},[e]),C=g.useMemo(()=>z?kt.Search:kt.Filter,[z]);let P,v;if(b==="connected")v=o.jsxRuntimeExports.jsx(C,{searcher:c,children:({onChange:N,value:D})=>o.jsxRuntimeExports.jsx(d1,{dropdownVariant:b,value:D,selectedKeys:t,className:n,onChange:N,loading:O,selected:A,onFocus:_,entryRenderKey:i,visible:M,renderTag:a,placeholder:d,onTagDragStart:x,onTagDragEnd:h,style:j,children:E})});else{const N=Pe.t.toArray(t);v=o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",grow:!0,style:j,size:"small",children:[N.map(D=>{const I=A.find(F=>F.key===D);return a({key:D,entryKey:D,entryRenderKey:i,loading:O,entry:I,onClose:()=>{const F=N.filter(H=>H!==D);e(F,{clicked:null,clickedIndex:-1,entries:[]})},onDragStart:F=>x==null?void 0:x(F,D),onDragEnd:F=>h==null?void 0:h(F,D)})}),N.length>0?o.jsxRuntimeExports.jsx(fe.Icon,{onClick:_,children:o.jsxRuntimeExports.jsx(K.y4.Add,{style:{color:"var(--pluto-gray-l9)"}})}):o.jsxRuntimeExports.jsx(fe.Button,{onClick:_,shade:0,textShade:9,startIcon:o.jsxRuntimeExports.jsx(K.y4.Add,{}),variant:"text",children:y})]}),P=o.jsxRuntimeExports.jsx(C,{searcher:c,children:D=>o.jsxRuntimeExports.jsx(pt.Text,{autoFocus:!0,placeholder:"Search",...D,children:E})})}return o.jsxRuntimeExports.jsx(pr,{close:L,data:s,emptyContent:l,visible:M,value:t,onChange:k,allowNone:m,replaceOnSingle:f,columns:r,allowMultiple:!0,listItem:S,trigger:v,extraDialogContent:P,variant:b,...R})},d1=({selectedKeys:e,loading:t,selected:n,onChange:s,onFocus:r,visible:i,entryRenderKey:l,renderTag:c,placeholder:a=Vs,onTagDragStart:d,onTagDragEnd:x,value:p,className:m,children:f,dropdownVariant:h,...j})=>{const{onSelect:y,clear:S}=Ce.useSelectionUtils(),b=g.useRef(null);g.useLayoutEffect(()=>{var L;i&&((L=b.current)==null||L.focus())},[i,n]);const E=()=>{i||s(""),r==null||r()},R=()=>{i||r==null||r()},M=()=>{i||s("")};let _;return h!=="modal"&&(_=o.jsxRuntimeExports.jsx(An.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:i})),o.jsxRuntimeExports.jsxs(pt.Text,{ref:b,className:u.CSS(u.CSS.BE("select-multiple","input"),u.CSS.visible(i),m),onBlur:M,placeholder:a,value:p,onChange:s,onFocus:E,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",onClick:R,endContent:_,variant:"button",...j,children:[o.jsxRuntimeExports.jsx(ne.Space,{x:!0,className:u.CSS.BE("select-multiple","tags"),align:"center",grow:!0,size:"small",children:Pe.t.toArray(e).map(L=>{const A=n.find($=>$.key===L);return c({key:L,entryKey:L,entryRenderKey:l,loading:t,entry:A,onClose:()=>y==null?void 0:y(L),onDragStart:$=>d==null?void 0:d($,L),onDragEnd:$=>x==null?void 0:x($,L)})})}),f,o.jsxRuntimeExports.jsx(lc,{onClick:S})]})},x1=[{key:"h2",label:"XL"},{key:"h3",label:"L"},{key:"h4",label:"M"},{key:"h5",label:"S"},{key:"small",label:"XS"}],un=e=>o.jsxRuntimeExports.jsx(ot,{...e,data:x1,entryRenderKey:"label"}),p1=[{key:600,label:"Bold"},{key:500,label:"Medium"},{key:400,label:"Normal"},{key:250,label:"Light"}],ac=e=>o.jsxRuntimeExports.jsx(ot,{...e,data:p1,entryRenderKey:"label"}),m1=Object.freeze(Object.defineProperty({__proto__:null,Level:un,Weight:ac},Symbol.toStringTag,{value:"Module"})),f1=Object.freeze(Object.defineProperty({__proto__:null,BaseButton:nc,Button:ot,ComponentSize:oc,DEFAULT_PLACEHOLDER:Vs,DataType:o1,Direction:ic,DropdownButton:Os,Multiple:an,MultipleTag:mr,Single:mt,Text:m1,TextAlignment:zs,defaultButton:sc},Symbol.toStringTag,{value:"Module"})),h1=11,g1=6,j1=2,ai=5,E1=e=>u.Pt.width(e)<ai&&u.Pt.height(e)<ai,gn=e=>{const t=u.Pt.width(e),n=u.Pt.height(e);return Math.min(t,n)<.001?h1:g1},y1=["zoom","pan","select","zoomReset","cancel"],Sn=[...y1,"click"],S1=ce._enum(Sn),uc=["zoom","select"],jn={defaultMode:"zoom",zoom:[["MouseLeft"]],zoomReset:[["MouseLeft","Control"]],pan:[["MouseLeft","Shift"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},dc={defaultMode:"pan",pan:[["MouseLeft"]],zoom:[["MouseLeft","Shift"]],zoomReset:[["MouseLeft","Control"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},xc={defaultMode:"select",select:[["MouseLeft"]],pan:[["MouseLeft","Shift"]],zoom:[["MouseLeft","Alt"]],zoomReset:[["MouseLeft","Control"]],cancel:[["Escape"]]},fr={zoom:jn,pan:dc,select:xc,zoomReset:jn,click:jn,cancel:jn},R1=e=>{const t=Object.entries(e);return Object.fromEntries(t.map(([n,s])=>n==="defaultMode"?[n,s]:[n,s.map(r=>r.filter(i=>i!=="MouseLeft")).filter(r=>r.length>0)]))},C1=u.Pt.construct(0,0,1,1,u.K$1.TOP_LEFT),w1={width:30,height:50},pc=({onChange:e,triggers:t,initial:n=C1,threshold:s=w1,ref:r})=>{const i=(t==null?void 0:t.defaultMode)??"zoom",[l,c]=g.useState(u.Pt.ZERO),[a,d]=g.useState(i),[x,p]=K.useStateRef(n),m=g.useRef(u.K.ZERO),f=g.useRef(null),h=u.A$1.construct(s);g.useEffect(()=>p(()=>u.Pt.truncate(n,gn(n))),[n]),g.useEffect(()=>d(i),[i]);const[j,y,S,b]=Ae.useMemoCompare(()=>{const A={...fr[i],...t},$=De.flattenConfig(A),O=R1(A);return[A,$,O,De.flattenConfig(O)]},De.compareModeConfigs,[t]),E=g.useCallback(({box:A,triggers:$,stage:O,cursor:V})=>{if(f.current==null)return;const z=De.determineMode(j,$),k=u.Pt.construct(f.current);if(z==null)return;if(z==="cancel"){c(u.Pt.ZERO),e==null||e({box:x.current,mode:z,stage:O,cursor:V});return}if(z==="zoomReset")return c(u.Pt.ZERO),e==null||e({box:u.Pt.DECIMAL,mode:z,stage:O,cursor:V}),p(u.Pt.DECIMAL);const C=E1(A);if(O==="end"){if(C){z==="zoom"&&c(u.Pt.ZERO),e==null||e({box:x.current,mode:"click",stage:O,cursor:V});return}return p(v=>{if(z==="pan"){const D=ui(A,v,k);return D===null||u.Pt.equals(D,v)?v:(e==null||e({box:D,mode:z,stage:O,cursor:V}),D)}const N=R(A,v,k);return N===null?v:(e==null||e({box:N,mode:z,stage:O,cursor:V}),z==="zoom"?(c(u.Pt.ZERO),N):u.Pt.truncate(v,gn(v)))})}if(uc.includes(z))return C?void 0:c(u.A.XY.scale(k).clamp(k).translate({x:-u.Pt.left(k),y:-u.Pt.top(k)}).box(di(h,A,k)));if(c(v=>u.Pt.areaIsZero(v)?v:u.Pt.ZERO),u.K.distance(V,m.current)<j1)return;m.current=V;const P=ui(A,x.current,k);e==null||e({box:P,mode:z,stage:O,cursor:V})},[c,d,e,j,s.height,s.width,p,f,gn]);g.useImperativeHandle(r,()=>({reset:()=>{c(u.Pt.ZERO),p(u.Pt.DECIMAL),e==null||e({box:u.Pt.DECIMAL,mode:"zoomReset",stage:"start",cursor:u.K.ZERO})}}),[e]);const R=g.useCallback((A,$,O)=>{const V=To($,O).box(di(h,A,O));return u.Pt.truncate(V,gn(V))},[s]),M=De.useHeldRef({triggers:[["Control"]]}),_=De.useHeldRef({triggers:[["Alt"]]});g.useEffect(()=>{const A=$=>{if(f.current==null)return;let O=1;$.deltaY<0?O-=.035:O+=.035;const V=u.Pt.construct(f.current),z=u.K.construct($);if(Array.from(f.current.children).push(f.current),!u.Pt.contains(V,z)||f.current!==$.target&&Ye.findParent($.target,D=>D===f.current)==null)return;const P=To(x.current,u.Pt.construct(f.current)).pos(u.K.construct($));let N=u.A.XY.magnify({x:M.current.held?1:O,y:_.current.held?1:O}).box(x.current);N=u.Pt.translate(N,{x:M.current.held?0:P.x*(1-O),y:_.current.held?0:P.y*(1-O)}),p(N),e==null||e({stage:"end",box:N,cursor:u.K.construct($),mode:"zoom"})};return window.addEventListener("wheel",A),()=>window.removeEventListener("wheel",A)},[p,e]),vl.useDrag({bound:f,onDrag:E,triggers:y,loose:!0});const L=g.useCallback(({triggers:A,stage:$})=>{if($==="end")return d(i);const O=De.determineMode(S,A);O!=null&&d(O)},[S,i,e]);return De.use({triggers:b,callback:L,region:f}),{maskBox:l,ref:f,mode:a}},To=(e,t)=>u.A.XY.scale(t).clamp(t).scale(e),ui=(e,t,n)=>{let s=u.Pt.signedDims(To(t,n).box(e));s={signedWidth:-s.signedWidth,signedHeight:-s.signedHeight};const r=u.A.XY.translate(u.K.construct(s)).box(t);return u.Pt.truncate(r,gn(r))},di=(e,t,n)=>u.Pt.height(t)<=e.height?u.Pt.construct(u.Pt.left(t),u.Pt.top(n),u.Pt.width(t),u.Pt.height(n)):u.Pt.width(t)<=e.width?u.Pt.construct(u.Pt.left(n),u.Pt.top(t),u.Pt.width(n),u.Pt.height(t)):t,b1=({mode:e,triggers:t})=>o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",children:[o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:u.d$1.capitalize(e)}),o.jsxRuntimeExports.jsx(ne.Space,{empty:!0,x:!0,align:"center",children:o.jsxRuntimeExports.jsx(zf.Text,{trigger:t[0],level:"small"})})]}),v1={zoom:o.jsxRuntimeExports.jsx(K.y4.Zoom,{}),pan:o.jsxRuntimeExports.jsx(K.y4.Pan,{}),select:o.jsxRuntimeExports.jsx(K.y4.Selection,{}),zoomReset:o.jsxRuntimeExports.jsx(K.y4.Expand,{}),click:o.jsxRuntimeExports.jsx(K.y4.Bolt,{})},k1=({triggers:e,disable:t=["zoomReset","click"],...n})=>{const s=[...t,"cancel"],r=Object.entries(e).filter(([i])=>!s.includes(i)&&Sn.includes(i)).map(([i,l])=>({key:i,icon:v1[i],tooltip:o.jsxRuntimeExports.jsx(b1,{mode:i,triggers:l})})).sort((i,l)=>Sn.indexOf(i.key)-Sn.indexOf(l.key));return o.jsxRuntimeExports.jsx(ot,{...n,data:r,entryRenderKey:"icon",children:({title:i,entry:l,...c})=>g.createElement(fe.Icon,{...c,key:l.key,variant:c.selected?"filled":"outlined",size:"small",tooltip:l.tooltip,tooltipLocation:u.K$1.BOTTOM_LEFT},l.icon)})},M1=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_TRIGGERS:fr,MASK_MODES:uc,MODES:Sn,Mask:tc,PAN_DEFAULT_TRIGGERS:dc,SELECT_DEFAULT_TRIGGERS:xc,SelectMode:k1,ZOOM_DEFAULT_TRIGGERS:jn,modeZ:S1,use:pc},Symbol.toStringTag,{value:"Module"})),P1=e=>e==null?null:e.closest(".pluto-line-plot__viewport")??null,mc=({ref:e,children:t,initial:n=u.Pt.DECIMAL,onChange:s,...r})=>{const{setViewport:i}=st("Viewport");g.useLayoutEffect(()=>{i({box:n,mode:"zoom",cursor:u.K.ZERO,stage:"start"})},[i,n]);const l=g.useCallback(a=>{i(a),s==null||s(a)},[s,i]),c=pc({onChange:l,initial:n,ref:e,...r});return o.jsxRuntimeExports.jsx(tc,{className:u.CSS.BE("line-plot","viewport"),...c,children:t})},_1=Object.freeze(Object.defineProperty({__proto__:null,BoundsQuerier:Gh,Floating:ur,Legend:Ul,Line:xr,LinePlot:Wl,Title:Jl,Tooltip:Yh,Viewport:mc,XAxis:Yl,YAxis:Gl,axisFactory:lr,selectViewportEl:P1,useBoundQuerier:ec,useContext:st,useGridEntry:$n,useViewport:Kl},Symbol.toStringTag,{value:"Module"})),L1=({aetherKey:e,...t})=>(Q.use$1({aetherKey:e,type:B.Annotation.TYPE,schema:B.annotationStateZ,initialState:t}),null),fc=({aetherKey:e,menu:t,...n})=>{const s=Q.useUniqueKey(e),{setViewport:r,setHold:i}=st("Range.Provider"),[,{hovered:l,count:c},a]=Q.use$1({aetherKey:s,type:B.Provider$1.TYPE,schema:B.providerStateZ,initialState:{...n,cursor:null,hovered:null,count:0}}),d=$n({key:s,loc:"top",size:c>0?32:0,order:3},"Annotation.Provider"),x=vt.useContextMenu(),p=K.useSyncedRef(x.visible),m=g.useCallback(h=>a(j=>({...j,cursor:{x:h.clientX,y:h.clientY}})),[a]),f=g.useCallback(()=>{p.current||a(h=>({...h,cursor:null}))},[a,p]);return o.jsxRuntimeExports.jsx(vt.ContextMenu,{...x,menu:()=>t==null||l==null?null:t(l),children:o.jsxRuntimeExports.jsx(ne.Space,{style:{...d,cursor:l!=null?"pointer":"default",width:"100%",height:"100%"},onContextMenu:x.open,className:x.className,onClick:()=>{l!=null&&(r({box:u.Pt.construct({x:l.viewport.lower,y:0},{x:l.viewport.upper,y:1}),mode:"zoom",cursor:u.K.ZERO,stage:"start"}),i(!0))},onMouseMove:m,onMouseLeave:f})})},N1=Object.freeze(Object.defineProperty({__proto__:null,Annotation:L1,Provider:fc},Symbol.toStringTag,{value:"Module"})),hc={defaultMode:"empty",one:[["1"]],two:[["2"]],clear:[["Shift"]],empty:[[]]},T1=De.flattenConfig(hc),gc=({aetherKey:e})=>{const t=Q.useUniqueKey(e),[,,n]=Q.use$1({aetherKey:t,type:B.Measure.TYPE,schema:B.measureStateZ,initialState:{hover:null,one:null,two:null}}),s=g.useRef(null),r=De.useHeldRef({triggers:T1,loose:!0}),i=g.useCallback(({mode:a,cursor:d})=>{if(a==="click"){const x=De.determineMode(hc,r.current.triggers,{loose:!0});if(["one","two"].includes(x))return n(p=>({...p,[x]:d}));n(x==="clear"?p=>({...p,one:null,two:null}):p=>({...p,one:p.one??d,two:p.one!==null?d:p.two}))}},[n,r]);Kl(i);const l=g.useCallback(a=>n(d=>({...d,hover:u.K.construct(a)})),[n]),c=g.useCallback(()=>{n(a=>({...a,hover:null}))},[n]);return g.useEffect(()=>{if(s.current===null)return;const a=s.current.parentElement;if(a!=null)return a.addEventListener("mousemove",l),a.addEventListener("mouseleave",c),()=>{a.removeEventListener("mousemove",l),a.removeEventListener("mouseleave",c)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:s})},A1=Object.freeze(Object.defineProperty({__proto__:null,Measure:gc},Symbol.toStringTag,{value:"Module"})),hr=({aetherKey:e,label:t,position:n,onLabelChange:s,onPositionChange:r,onUnitsChange:i,units:l="",color:c,lineWidth:a,lineDash:d,className:x,onSelect:p,style:m,...f})=>{const[h,j]=ce.usePurePassthrough({value:t,onChange:s,initial:""}),y=K.useSyncedRef(r),[,{pixelPosition:S},b]=Q.use$1({aetherKey:e,type:B.Rule.TYPE,schema:B.ruleStateZ,initialState:{color:c,dragging:!1,position:n,lineWidth:a,lineDash:d},onAetherChange:g.useCallback(({position:z})=>{var k;z!=null&&((k=y.current)==null||k.call(y,z))},[y])}),E=g.useRef(S);S!==E.current&&(E.current=S);const{id:R}=st("Rule"),M=document.getElementById(R),_=M==null?void 0:M.querySelector(".pluto-line-plot__viewport"),L=g.useRef(S);g.useEffect(()=>{b(z=>({...z,position:n,color:c,lineWidth:a,lineDash:d}))},[n,c,a,d]);const A=Ge.useCursorDrag({onStart:g.useCallback(()=>{p==null||p(),b(z=>({...z,dragging:!0})),L.current=E.current},[]),onMove:z=>{b(k=>({...k,pixelPosition:(L.current??0)+u.Pt.signedHeight(z)}))},onEnd:g.useCallback(()=>{b(z=>({...z,dragging:!1})),L.current=S},[])}),$=g.useRef(null);if(n==null||S==null)return null;const O=u.od.pickByContrast(c,u.od.BLACK,u.od.WHITE),V=o.jsxRuntimeExports.jsxs("div",{ref:$,className:u.CSS.B("rule"),style:{top:`calc(${S}px - 0.5rem)`},children:[o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("rule","drag-handle"),onDragStart:A,draggable:!0}),o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",className:u.CSS(x,u.CSS.BE("rule","tag")),bordered:!0,onClick:p,size:1,rounded:!0,style:{borderColor:u.od.cssString(c),backgroundColor:u.od.hex(u.od.setAlpha(c,.7)),...m},...f,children:[o.jsxRuntimeExports.jsx(K.Editable,{className:u.CSS.B("label"),level:"small",value:h,onChange:j,color:O}),o.jsxRuntimeExports.jsx(As.Divider,{y:!0,style:{borderColor:u.od.cssString(c)}}),o.jsxRuntimeExports.jsxs(ne.Space,{size:"small",x:!0,align:"center",children:[o.jsxRuntimeExports.jsx(K.Editable,{value:n.toFixed(2),onChange:z=>{const k=Number(z);isFinite(k)&&(r==null||r(k))},level:"small",color:O}),o.jsxRuntimeExports.jsx(K.MaybeEditable,{level:"small",color:O,value:l,onChange:i})]})]})]});return _==null?V:kl.createPortal(V,_)},I1=Object.freeze(Object.defineProperty({__proto__:null,Rule:hr},Symbol.toStringTag,{value:"Module"})),jc=me.canDropOfType(nt),$1=({lines:e,axes:t,showTitle:n=!0,title:s="",onTitleChange:r,showLegend:i=!0,legendPosition:l,onLegendPositionChange:c,titleLevel:a="h4",onLineChange:d,onRuleChange:x,onAxisChannelDrop:p,onAxisChange:m,rules:f,enableTooltip:h=!0,enableMeasure:j=!1,initialViewport:y=u.Pt.DECIMAL,legendVariant:S,onViewportChange:b,viewportTriggers:E,rangeAnnotationProvider:R,onSelectRule:M,children:_,...L})=>{const A=t.filter(({location:k})=>u.K$1.isY(k)),$=g.useRef(null),O=K.usePrevious(e.length),V=K.usePrevious(L.hold),z=O===0&&e.length!==0||V===!0&&L.hold===!1;return g.useEffect(()=>{var k;z&&((k=$.current)==null||k.reset())},[z]),o.jsxRuntimeExports.jsxs(Wl,{...L,children:[A.map((k,C)=>{const P=e.filter(D=>D.axes.x===k.key),v=t.filter(({location:D})=>u.K$1.isX(D)),N=f==null?void 0:f.filter(D=>[...v.map(({key:I})=>I),k.key].includes(D.axis));return o.jsxRuntimeExports.jsx(B1,{axis:k,index:C,lines:P,yAxes:v,rules:N,onAxisChannelDrop:p,onAxisChange:m,annotationProvider:R,onRuleChange:x,onSelectRule:M},k.key)}),i&&o.jsxRuntimeExports.jsx(Ul,{onLineChange:d,position:l,onPositionChange:c,variant:S}),n&&o.jsxRuntimeExports.jsx(Jl,{value:s,onChange:r,level:a}),o.jsxRuntimeExports.jsxs(mc,{initial:y,onChange:b,triggers:E,ref:$,children:[h&&o.jsxRuntimeExports.jsx(Ql,{}),j&&o.jsxRuntimeExports.jsx(gc,{}),_]})]})},B1=({yAxes:e,lines:t,index:n,rules:s,onRuleChange:r,onSelectRule:i,onAxisChannelDrop:l,onAxisChange:c,axis:{location:a,key:d,showGrid:x,...p},annotationProvider:m})=>{const f=me.useDrop({type:"Channel.LinePlot.XAxis",canDrop:jc,onDrop:g.useCallback(({items:y})=>{const S=me.filterByType(nt,y);return l==null||l(d,S.map(({key:b})=>b)),S},[d,l])}),h=s==null?void 0:s.filter(y=>y.axis===d),j=me.useDraggingState();return o.jsxRuntimeExports.jsxs(Yl,{...p,...f,location:a,axisKey:d,showGrid:x??n===0,className:u.CSS(u.CSS.dropRegion(me.canDropOfType(nt)(j))),onAutoBoundsChange:y=>c==null?void 0:c({key:d,bounds:y}),children:[e.map((y,S)=>{const b=t.filter(R=>R.axes.y===y.key),E=s==null?void 0:s.filter(R=>R.axis===y.key);return o.jsxRuntimeExports.jsx(O1,{axis:{...y,showGrid:x??(n===0&&S===0)},lines:b,rules:E,onRuleChange:r,onAxisChannelDrop:l,onAxisChange:c,onSelectRule:i},y.key)}),h==null?void 0:h.map(y=>g.createElement(hr,{aetherKey:y.key,...y,key:y.key,onLabelChange:S=>r==null?void 0:r({key:y.key,label:S}),onPositionChange:S=>r==null?void 0:r({key:y.key,position:S}),onUnitsChange:S=>r==null?void 0:r({key:y.key,units:S}),onSelect:()=>i==null?void 0:i(y.key)})),o.jsxRuntimeExports.jsx(fc,{...m})]})},D1=({channels:{x:e,y:t}})=>`${e??0}-${t}`,O1=({lines:e,rules:t,onRuleChange:n,onAxisChannelDrop:s,onAxisChange:r,axis:{key:i,location:l,...c},onSelectRule:a})=>{const d=me.useDrop({type:"Channel.LinePlot.YAxis",canDrop:jc,onDrop:g.useCallback(({items:p})=>{const m=me.filterByType(nt,p);return s==null||s(i,m.map(({key:f})=>f)),m},[i,s])}),x=me.useDraggingState();return o.jsxRuntimeExports.jsxs(Gl,{...c,...d,location:l,axisKey:i,className:u.CSS(u.CSS.dropRegion(me.canDropOfType(nt)(x))),onAutoBoundsChange:p=>r==null?void 0:r({key:i,bounds:p}),children:[e.map(p=>o.jsxRuntimeExports.jsx(z1,{line:p},D1(p))),t==null?void 0:t.map(p=>g.createElement(hr,{aetherKey:p.key,...p,key:p.key,onLabelChange:m=>n==null?void 0:n({key:p.key,label:m}),onPositionChange:m=>n==null?void 0:n({key:p.key,position:m}),onUnitsChange:m=>n==null?void 0:n({key:p.key,units:m}),onClick:()=>a==null?void 0:a(p.key)}))]})},z1=({line:e})=>e.variant==="static"?o.jsxRuntimeExports.jsx(F1,{line:e}):o.jsxRuntimeExports.jsx(V1,{line:e}),V1=({line:{key:e,timeSpan:t,channels:{x:n,y:s},axes:r,...i}})=>{const{xTelem:l,yTelem:c}=g.useMemo(()=>{const a=Number(t.valueOf())*3,d=B.streamChannelData({timeSpan:t,channel:s,keepFor:a}),x=n!=null&&n!==0;return{xTelem:B.streamChannelData({timeSpan:t,channel:x?n:s,useIndexOfChannel:!x,keepFor:a}),yTelem:d}},[t.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(xr,{aetherKey:e,y:c,x:l,...i})},F1=({line:{timeRange:e,key:t,channels:{x:n,y:s},...r}})=>{const{xTelem:i,yTelem:l}=g.useMemo(()=>{const c=B.channelData({timeRange:e,channel:s}),a=n!=null&&n!==0;return{xTelem:B.channelData({timeRange:e,channel:a?n:s,useIndexOfChannel:!a}),yTelem:c}},[e.start.valueOf(),e.end.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(xr,{aetherKey:t,y:l,x:i,...r})},xi=[{key:"name",name:"Name"},{key:"alias",name:"Alias"},{key:"rate",name:"Rate"},{key:"dataType",name:"Data Type"},{key:"index",name:"Index"},{key:"key",name:"Key"},{key:"isIndex",name:"Is Index"}],ms=({items:e},t)=>{const n=me.filterByType(nt,e);return n.length>0&&!n.every(s=>t.includes(s.key))},Ec=["name","alias"],yc=e=>{const t=$s();return g.useMemo(()=>e.length===0?xi:xi.filter(n=>e.includes(n.key)),[e,t])},Sc=e=>{if(e==null)return K.y4.Channel;if(bt.iq.isCalculated(e))return K.y4.Calculation;if(e.isIndex)return K.y4.Index;const t=new u.m(e.dataType);return t.isInteger?K.y4.Binary:t.isFloat?K.y4.Decimal:t.equals(u.m.STRING)?K.y4.String:t.equals(u.m.JSON)?K.y4.JSON:K.y4.Channel},H1=({key:e,...t})=>{const n=Sc(t.entry);return o.jsxRuntimeExports.jsx(mr,{icon:o.jsxRuntimeExports.jsx(n,{}),...t},e)},Z1=({columns:e=Ec,onChange:t,className:n,value:s,searchOptions:r,...i})=>{const l=qe(),c=$s(),a=yc(e),d=ir(),x=Ae.useMemoDeepEqualProps(r),p=g.useMemo(()=>l==null?void 0:l.channels.newSearcherWithOptions({rangeKey:d,internal:!1,...x}),[l,d,x]),m=l!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:f,onDragEnd:h,...j}=me.useDragAndDrop({type:"Channel.SelectMultiple",canDrop:g.useCallback(R=>ms(R,Pe.t.toArray(s)),[s]),onDrop:g.useCallback(({items:R})=>{const M=me.filterByType(nt,R);if(M.length===0)return[];const _=u.c.unique([...Pe.t.toArray(s),...M.map(L=>L.key)]);return t(_,{clickedIndex:null,clicked:null,entries:[]}),M},[t,s])}),y=me.useDraggingState(),S=g.useCallback(({dropped:R})=>{t(Pe.t.toArray(s).filter(M=>!R.some(_=>_.key===M)),{clickedIndex:null,clicked:null,entries:[]})},[t,s]),b=g.useCallback((R,M)=>f([{key:M,type:nt}],S),[f,S]),E=g.useCallback(R=>c[R.key]??R.name,[c]);return o.jsxRuntimeExports.jsx(an,{className:u.CSS(n,u.CSS.dropRegion(ms(y,Pe.t.toArray(s)))),value:s,onTagDragStart:b,onTagDragEnd:h,searcher:p,onChange:t,columns:a,emptyContent:m,entryRenderKey:E,renderTag:H1,...j,...i})},$t=({columns:e=Ec,onChange:t,value:n,className:s,data:r,searchOptions:i,...l})=>{const c=qe(),a=$s(),d=yc(e),x=ir(),p=Ae.useMemoDeepEqualProps(i),m=g.useMemo(()=>{if(!(r!=null&&r.length>0))return c==null?void 0:c.channels.newSearcherWithOptions({rangeKey:x,internal:!1,...p})},[c,x,r==null?void 0:r.length,p]),f=c!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),h=g.useId(),j=g.useMemo(()=>({key:h,type:"Channel.SelectMultiple"}),[h]),{startDrag:y,onDragEnd:S,...b}=me.useDragAndDrop({type:"Channel.SelectSingle",canDrop:g.useCallback(_=>ms(_,Pe.t.toArray(n)),[n]),onDrop:g.useCallback(({items:_})=>{const L=me.filterByType(nt,_);return L.length===0?[]:(t(L[0].key,{clickedIndex:null,clicked:null,entries:[]}),L)},[j,t])}),E=me.useDraggingState(),R=g.useCallback(()=>n!=null&&y([{type:nt,key:n}]),[y,n]),M=g.useCallback(_=>a[_.key]??_.name,[a]);return o.jsxRuntimeExports.jsx(mt,{data:r,className:u.CSS(s,u.CSS.dropRegion(ms(E,Pe.t.toArray(n)))),value:n,onDragStart:R,onDragEnd:S,onChange:t,searcher:m,columns:d,emptyContent:f,entryRenderKey:M,...b,...l})},K1=Object.freeze(Object.defineProperty({__proto__:null,AliasInput:vh,AliasProvider:Vl,LinePlot:$1,SelectMultiple:Z1,SelectSingle:$t,resolveIcon:Sc,useActiveRange:ir,useAlias:zl,useAliases:$s,useContext:cn,useName:Bs},Symbol.toStringTag,{value:"Module"})),Mt=({path:e,optional:t=!1,onChange:n,defaultValue:s})=>{const r=ft(),{get:i,bind:l,set:c,setStatus:a}=r,[d,x]=g.useState(()=>{const h=i(e,{optional:t||s!=null});return h!=null||s==null||t?h:{value:s,status:{key:"",variant:"success",message:""},touched:!1,required:!1}});g.useEffect(()=>(i(e,{optional:t||s!=null})==null&&s!=null&&c(e,s),x(i(e,{optional:t})),l({path:e,onChange:x,listenToChildren:!1})),[e,n,l,i,t,s]);const p=g.useCallback(h=>{n==null||n(h,{...r,path:e}),c(e,h)},[e,c,n]),m=g.useCallback(h=>a(e,h),[e,a]);if(d==null){if(!t)throw new Error(`Field state is null: ${e}`);return null}let f;return r.mode==="preview"&&(f="preview"),{onChange:p,setStatus:m,variant:f,...d}},Rc=(e,t=!1,n)=>{const{get:s,bind:r}=ft(n),[,i]=g.useState(0);return g.useEffect(()=>(i(l=>l+1),r({path:e,onChange:()=>i(l=>l+1)})),[e,r]),s(e,{optional:t})??null},Cc=(e,t=!1,n)=>{var l;const{get:s,bind:r}=ft(n),[,i]=g.useState(0);return g.useEffect(()=>(i(c=>c+1),r({path:e,onChange:()=>i(c=>c+1)})),[e,r]),((l=s(e,{optional:t}))==null?void 0:l.value)??null},W1=e=>{var t,n;return((n=(t=Rc(e,!0))==null?void 0:t.status)==null?void 0:n.variant)==="success"},Y1=({path:e,ctx:t,onChange:n})=>{const s=ft(t);g.useEffect(()=>s.bind({path:e,onChange:r=>n(r,s),listenToChildren:!1}),[e,s])},G1=({path:e,optional:t=!1})=>{const{bind:n,get:s}=ft(),[r,i]=g.useState(s(e,{optional:t}));if(g.useEffect(()=>(i(s(e,{optional:t})),n({path:e,onChange:l=>i({...l,value:u.vd(l.value)}),listenToChildren:!0})),[e,n,s]),r==null&&!t)throw new Error("Field state is null");return(r==null?void 0:r.value)??null},wc=(e,t)=>({add:(n,s)=>{const r=u.vd(e.get(t).value);r.splice(s,0,...Pe.t.toArray(n)),e.set(t,r,{validateChildren:!1})},push:(n,s)=>{const r=u.vd(e.get(t).value);r.push(...Pe.t.toArray(n)),s!=null&&r.sort(s),e.set(t,r,{validateChildren:!1})},remove:n=>{const s=e.get(t).value,r=new Set(Pe.t.toArray(n));e.set(t,s.filter((i,l)=>!r.has(l)))},keepOnly:n=>{const s=e.get(t).value,r=new Set(Pe.t.toArray(n));e.set(t,s.filter((i,l)=>r.has(l)))},set:n=>e.set(t,ce.executeSetter(n,e.get(t).value)),sort:n=>{const s=u.vd(e.get(t).value);s.sort(n),e.set(t,s)}}),q1=({path:e,updateOnChildren:t=!1,ctx:n})=>{const s=ft(n),{bind:r,get:i}=s,[l,c]=g.useState(i(e).value);return g.useEffect(()=>(c(i(e).value),r({path:e,onChange:a=>{c(u.vd(a.value))},listenToChildren:t})),[e,r,i,c]),g.useMemo(()=>({value:l,...wc(s,e)}),[l,s,e])},bc=g.createContext({mode:"normal",bind:()=>()=>{},set:()=>{},reset:()=>{},remove:()=>{},get:()=>({value:void 0,status:{key:"",variant:"success",message:""},touched:!1,required:!1}),validate:()=>!1,validateAsync:()=>Promise.resolve(!1),value:()=>({}),has:()=>!1,setStatus:()=>{},clearStatuses:()=>{},setCurrentStateAsInitialValues:()=>{}}),ft=e=>{const t=g.use(bc);return e??t},pi=e=>({key:e,variant:"success",message:""}),X1=e=>e.code===B.ZodIssueCode.custom&&e.params!=null&&"variant"in e.params?e.params.variant:"error",vc=({values:e,sync:t=!1,schema:n,mode:s="normal",onChange:r,onHasTouched:i})=>{const l=K.useInitializerRef(()=>({state:Be.J.copy(e),statuses:new Map,touched:new Set,listeners:new Map,parentListeners:new Map})),c=K.useSyncedRef(n),a=K.useSyncedRef(r),d=K.useSyncedRef(e),x=K.useSyncedRef(i),p=Ce.useErrorHandler(),m=g.useCallback(()=>{d.current=Be.J.copy(l.current.state),S()},[]),f=g.useCallback(({path:k,onChange:C,listenToChildren:P=!1})=>{var I;const{parentListeners:v,listeners:N}=l.current,D=P?v:N;return D.has(k)||D.set(k,new Set),(I=D.get(k))==null||I.add(C),()=>{var F;return(F=D.get(k))==null?void 0:F.delete(C)}},[]),h=g.useCallback((k,{optional:C}={optional:!1})=>{const{state:P,statuses:v,touched:N}=l.current,D=Be.J.get(P,k,{optional:C});if(D==null)return null;const I={value:D,status:v.get(k)??pi(k),touched:N.has(k),required:!1};if(c.current==null)return I;const F=c.current,H=Yf.getFieldSchema(F,k,{optional:!0});return H==null||"isOptional"in H&&typeof H.isOptional=="function"&&(I.required=!H.isOptional()),I},[]),j=g.useCallback(k=>{var N;const{touched:C}=l.current,P=C.size===0;C.add(k);const v=C.size===0;P!==v&&((N=x.current)==null||N.call(x,!v))},[]),y=g.useCallback(k=>{var N;const{touched:C}=l.current,P=C.size===0;C.delete(k);const v=C.size===0;P!==v&&((N=x.current)==null||N.call(x,!v))},[]),S=g.useCallback(()=>{var v;const{touched:k}=l.current,C=k.size===0;k.clear();const P=k.size===0;C!==P&&((v=x.current)==null||v.call(x,!P))},[]),b=g.useCallback(k=>{const{state:C,statuses:P,listeners:v,parentListeners:N}=l.current;Be.J.remove(C,k),P.delete(k),y(k),v.delete(k),N.delete(k)},[]),E=g.useCallback(k=>{const{statuses:C}=l.current;l.current.state=k??Be.J.copy(d.current),M(""),C.clear(),S()},[]),R=g.useCallback(k=>{var v;const{listeners:C}=l.current,P=h(k,{optional:!0});P!=null&&((v=C.get(k))==null||v.forEach(N=>N(P)))},[]),M=g.useCallback(k=>{const{listeners:C,parentListeners:P}=l.current,v=C.get(k);if(k==""&&([...C.keys()].forEach(I=>{var H;const F=h(I,{optional:!0});F!=null&&((H=C.get(I))==null||H.forEach(Z=>{Z(F)}))}),[...P.keys()].forEach(I=>{var H;const F=h(I,{optional:!0});F!=null&&((H=P.get(I))==null||H.forEach(Z=>{Z(F)}))})),v!=null){const N=h(k,{optional:!0});N!=null&&v.forEach(D=>{D(N)})}P.forEach((N,D)=>{if(Be.J.pathsMatch(k,D)){const F=h(D,{optional:!0});F!=null&&N.forEach(H=>{H(F)})}})},[]),_=g.useCallback((k,C="",P=!0)=>{const{statuses:v,listeners:N}=l.current;if(k.success){const H=[...v.keys()];return v.clear(),H.forEach(Z=>R(Z)),!0}let D=!0;const I=new Set(k.error.issues.map(H=>H.path.join(".")));let F=(H,Z)=>H===Z;return P&&(F=(H,Z)=>Be.J.pathsMatch(H,Z)),k.error.issues.forEach(H=>{var oe;const{message:Z}=H,ee=H.path.join(".");if(!F(ee,C))return;const te=X1(H);te!=="warning"&&(D=!1),v.set(ee,{key:ee,variant:te,message:Z}),j(ee);let se=h(ee,{optional:!0});se??(se={value:void 0,status:v.get(ee)??pi(ee),touched:!1,required:!1}),(oe=N.get(ee))==null||oe.forEach(xe=>xe(se))}),v.forEach((H,Z)=>{I.has(Z)||(v.delete(Z),R(Z))}),D},[]),L=g.useCallback((k,C)=>{if(c.current==null)return!0;const{state:P}=l.current,v=c.current.safeParse(P);return _(v,k,C)},[_]),A=g.useCallback(async(k,C)=>{if(c.current==null)return!0;const{state:P}=l.current,v=await c.current.safeParseAsync(P);return _(v,k,C)},[_]),$=g.useCallback((k,C,P={})=>{const v=Be.J.get(l.current.state,k,{optional:!0}),{validateChildren:N=!0}=P,{state:D}=l.current,I=Be.J.get(d.current,k,{optional:!0});Be.J.equal(I,C)?y(k):j(k),k.length===0?l.current.state=C:Be.J.set(D,k,C),M(k),p(async()=>{var Z;let H;try{H=L(k,N)}catch{H=await A(k,N)}(Z=a.current)==null||Z.call(a,{values:l.current.state,path:k,prev:v,valid:H})},"Failed to validate form")},[]),O=g.useCallback(k=>Be.J.has(l.current.state,k),[]),V=g.useCallback((k,C)=>{l.current.statuses.set(k,C),j(k),R(k)},[]),z=g.useCallback(()=>{const{statuses:k}=l.current;k.clear(),k.forEach((C,P)=>R(P))},[]);return g.useEffect(()=>{if(!t)return;const{listeners:k}=l.current;l.current.state=e,k.forEach((C,P)=>{const v=h(P,{optional:!0});v!=null&&C.forEach(N=>N(v))})},[t,e]),g.useMemo(()=>({bind:f,set:$,get:h,mode:s,validate:L,validateAsync:A,value:()=>l.current.state,has:O,remove:b,setStatus:V,clearStatuses:z,reset:E,setCurrentStateAsInitialValues:m}),[f,$,h,L,A,O,b,V,z,E,s,m])},U1=({children:e,...t})=>o.jsxRuntimeExports.jsx(bc,{value:t,children:e}),J1=fe.componentRenderProp(pt.Text),we=({path:e,children:t=J1,label:n,padHelpText:s=!0,visible:r=!0,hideIfNull:i=!1,optional:l,onChange:c,className:a,defaultValue:d,...x})=>{const p=Mt({path:e,optional:l??i,onChange:c,defaultValue:d}),m=ft();if(p==null)return null;if(e==null)throw new Error("No path provided to Form Field");if(n??(n=u.d$1.capitalize(Be.J.element(e,-1))),r=typeof r=="function"?r(p,m):r,!r)return null;const f=p.status.message,{onChange:h,value:j}=p,y={onChange:h,value:j};return p.variant!=null&&(y.variant=p.variant),o.jsxRuntimeExports.jsx(he.Item,{padHelpText:s,helpText:f,helpTextVariant:p.status.variant,label:n,required:p.required,className:u.CSS(a,u.CSS.BE("field",e.split(".").join("-")),u.CSS.M(p.status.variant)),...x,children:t(y)})},Pt=e=>({fieldKey:t,fieldProps:n,inputProps:s})=>{const r=({inputProps:i,path:l,fieldKey:c=t,optional:a,defaultValue:d,...x})=>o.jsxRuntimeExports.jsx(we,{...n,...x,defaultValue:d,optional:a,path:c?`${l}.${c}`:l,children:p=>o.jsxRuntimeExports.jsx(e,{...p,...s,...i})});return r.displayName=e.displayName,r},kc=Pt(he.Numeric),Ze=kc({}),Mc=Pt(pt.Text),gr=Mc({}),Pc=Pt(Q.Switch$1),Fs=Pc({}),Q1=Pt(mt),eg=Pt(an),tg=Pt(Os),_c=Pt(ot),jr=({key:e,open:t,onChange:n})=>{const s=Ae.useMemoPrimitiveArray(e);Q.useAsyncEffect(async()=>{if(t==null)return;const r=await t();if(r==null)return;const i=r.onChange(n);return async()=>{i(),await r.close()}},[t==null,s])},ng=({fetchInitialValue:e,...t})=>{const[n,s]=g.useState(void 0);return Q.useAsyncEffect(async()=>{s(await e())},[e]),jr({...t,onChange:s}),n},sg=Object.freeze(Object.defineProperty({__proto__:null,useListener:jr,useState:ng},Symbol.toStringTag,{value:"Module"})),og=({key:e,name:t,queryFn:n,values:s,openObservable:r,applyChanges:i,applyObservable:l,...c})=>{const a=qe(),d=Ce.useErrorHandler(),x=Ae.useMemoPrimitiveArray(e),p=vc({values:s,...c,sync:!1,onChange:h=>{a!=null&&d(async()=>{await(i==null?void 0:i({...h,client:a}))},`Failed to apply changes for ${t}`)}});Q.useAsyncEffect(async()=>{if(a!=null)try{const h=await n({client:a});p.set("",h)}catch(h){d(h,`Failed to retrieve ${t}`)}},[x,a==null?void 0:a.key]);const m=g.useCallback(async()=>{if(a!=null)return await(r==null?void 0:r(a))},[x,a==null?void 0:a.key]),f=g.useCallback(h=>l==null?void 0:l({changes:h,ctx:p}),[x,l]);return jr({key:x,open:m,onChange:f}),p},rg=Object.freeze(Object.defineProperty({__proto__:null,Field:we,Form:U1,NumericField:Ze,SwitchField:Fs,TextField:gr,buildButtonSelectField:_c,buildDropdownButtonSelectField:tg,buildNumericField:kc,buildSelectMultiField:eg,buildSelectSingleField:Q1,buildSwitchField:Pc,buildTextField:Mc,fieldArrayUtils:wc,fieldBuilder:Pt,use:vc,useChildFieldValues:G1,useContext:ft,useField:Mt,useFieldArray:q1,useFieldListener:Y1,useFieldState:Rc,useFieldValid:W1,useFieldValue:Cc,useSynced:og},Symbol.toStringTag,{value:"Module"})),ig=[{key:"name",name:"Name"},{key:"location",name:"Location",render:({entry:{location:e,rackName:t}})=>o.jsxRuntimeExports.jsx(Tl,{level:"small",shade:9,weight:450,style:{marginTop:"0.25rem"},size:"tiny",children:t?`${t}.${e}`:e})}],lg=({searchOptions:e,filter:t,...n})=>{const s=qe();let r=s==null?void 0:s.hardware.devices;e!=null&&s!=null&&(r=s.hardware.devices.newSearcherWithOptions(e));const[i,l]=g.useState(new Map),c=g.useCallback(a=>((t==null?void 0:t(a))??a).map(x=>({...x,rackName:i.get(x.rack)})),[t,i]);return Q.useAsyncEffect(async()=>{if(s==null){l(new Map);return}const a=await s.hardware.racks.retrieve([]);l(new Map(a.map(({key:d,name:x})=>[d,x])))},[s==null?void 0:s.key]),o.jsxRuntimeExports.jsx(mt,{columns:ig,searcher:r,entryRenderKey:"name",filter:c,...n})},cg=Object.freeze(Object.defineProperty({__proto__:null,SelectSingle:lg},Symbol.toStringTag,{value:"Module"})),ag=[{key:"name",name:"Name"},{key:"location",name:"Location"}],ug=e=>{const t=qe();return o.jsxRuntimeExports.jsx(mt,{columns:ag,searcher:t==null?void 0:t.hardware.racks,entryRenderKey:"name",...e})},dg=Object.freeze(Object.defineProperty({__proto__:null,SelectSingle:ug},Symbol.toStringTag,{value:"Module"})),Qt="label",Er=[{key:"color",name:"Color",render:({entry:e})=>o.jsxRuntimeExports.jsx(K.y4.Circle,{name:"circle",color:e.color,style:{height:"2.5rem",width:"2.5rem"}})},{key:"name",name:"Name"}],fs=({items:e},t)=>{const n=me.filterByType(Qt,e);return n.length>0&&!n.every(s=>t.includes(s.key))},xg=({entry:e,loading:t,entryKey:n,entryRenderKey:s,...r})=>o.jsxRuntimeExports.jsx(wn,{color:e==null?void 0:e.color,...r,children:e==null?void 0:e.name}),pg=fe.componentRenderProp(xg),mg=({onChange:e,className:t,value:n,...s})=>{const r=qe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=me.useDragAndDrop({type:"Label.SelectMultiple",canDrop:g.useCallback(m=>fs(m,Pe.t.toArray(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=me.filterByType(Qt,m);if(f.length===0)return[];const h=u.c.unique([...Pe.t.toArray(n),...f.map(j=>j.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),d=me.useDraggingState(),x=g.useCallback(({dropped:m})=>{e(Pe.t.toArray(n).filter(f=>!m.some(h=>h.key===f)),{clickedIndex:null,clicked:null,entries:[]})},[e,n]),p=g.useCallback((m,f)=>l([{key:f,type:Qt}],x),[l,x]);return o.jsxRuntimeExports.jsx(an,{className:u.CSS(t,u.CSS.dropRegion(fs(d,Pe.t.toArray(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.labels,onChange:e,columns:Er,emptyContent:i,renderTag:pg,addPlaceholder:"Label",...a,...s})},Lc=({value:e,onChange:t})=>{const n=qe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),r=g.useId(),i=g.useMemo(()=>({key:r,type:"Label.SelectMultiple"}),[r]),l=me.useDragAndDrop({type:"Label.SelectSingle",canDrop:g.useCallback(d=>fs(d,Pe.t.toArray(e)),[e]),onDrop:g.useCallback(({items:d})=>{const x=me.filterByType(Qt,d);return x.length===0?[]:(t(x[0].key,{clickedIndex:null,clicked:null,entries:[]}),x)},[i,t])}),c=me.useDraggingState(),a=g.useCallback(()=>e!=null&&l.startDrag([{type:Qt,key:e}]),[l.startDrag,e]);return{emptyContent:s,dragging:c,...l,onDragStart:a,searcher:n==null?void 0:n.labels}},fg=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=Lc({value:t,onChange:e});return o.jsxRuntimeExports.jsx(mt,{data:s,className:u.CSS(n,u.CSS.dropRegion(fs(i,Pe.t.toArray(t)))),value:t,onChange:e,columns:Er,entryRenderKey:"name",...l,...r})},hg=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=Lc({value:t,onChange:n});return o.jsxRuntimeExports.jsx(mt,{data:e,value:t,onChange:n,columns:Er,entryRenderKey:"name",...i,...s})},gg=Object.freeze(Object.defineProperty({__proto__:null,HAUL_TYPE:Qt,SelectButton:hg,SelectMultiple:mg,SelectSingle:fg},Symbol.toStringTag,{value:"Module"})),Hs=new Error("Tab not found"),jg=new Error("Invalid Mosaic"),hs=(e,t,n="center",s,r)=>{if(e=rt(e),s===void 0)return Ao(e,t);const i=Io(e,s);if(n==="center")return i.tabs||(i.tabs=[]),r!==void 0&&r>=0&&r<=i.tabs.length?i.tabs.splice(r,0,t):i.tabs.push(t),i.selected=t.tabKey,e;const l=i.key*2,c=i.key*2+1,a=n==="top"||n==="left"?l:c;if(Io(e,a).key!==i.key)return hs(e,t,"center",a);if(i.tabs==null||i.tabs.length===0)return hs(e,t,"center",s);const[d,x,p]=wg(n);if(i.direction=p,i[d]={key:0,tabs:[t],selected:t.tabKey},i[x]={key:0,tabs:i.tabs,selected:i.selected},i.first==null||i.last==null)throw jg;return i.first.key=l,i.last.key=c,i.tabs=void 0,i.size=void 0,i.selected=void 0,e},Eg=(e,t,n)=>{var i;e=rt(e);const[s,r]=Bt(e,t);if(s==null||r==null)throw Hs;return r.tabs=(i=r.tabs)==null?void 0:i.map(l=>l.tabKey===t?n(l):l),e},Ao=(e,t)=>(e=rt(e),e.tabs!=null?(e.tabs.push(t),e.selected=t.tabKey,e):(e.first!=null?e.first=Ao(e.first,t):e.last!=null&&(e.last=Ao(e.last,t)),e)),gs=e=>{e=rt(e);const t=[];if(e.tabs!=null&&(e.selected=Te.resetSelection(e.selected,e.tabs),e.selected!=null&&t.push(e.selected)),e.first!=null){const[n,s]=gs(e.first);e.first=n,t.push(...s)}if(e.last!=null){const[n,s]=gs(e.last);e.last=n,t.push(...s)}return[e,t]},yr=(e,t)=>{var r;e=rt(e);const[,n]=Bt(e,t);if(n==null)return[e,null];n.tabs=(r=n.tabs)==null?void 0:r.filter(i=>i.tabKey!==t),n.selected=Te.resetSelection(n.selected,n.tabs),e=Cg(e);const s=n.selected??js(e);return[e,s]},js=e=>e.selected!=null?e.selected:e.first!=null?js(e.first):e.last!=null?js(e.last):null,Nc=(e,t)=>{e=rt(e);const[n,s]=Bt(e,t);if(n==null||s==null)throw Hs;return s.selected=t,e},Tc=(e,t,n,s,r)=>{e=rt(e);const[i,l]=Bt(e,t);if(i==null||l==null)throw Hs;const[c,a]=yr(e,t);return[hs(c,i,n,s,r),a]},bn=(e,t)=>{if(e.tabs!=null)return e.tabs.some(n=>n.tabKey===t)?e:void 0;if(e.first!=null){const n=bn(e.first,t);if(n!=null)return n}if(e.last!=null){const n=bn(e.last,t);if(n!=null)return n}},Ac=(e,t,n)=>{const s=Es(e,t);if(s==null)throw new Error("Node not found");return s.size=n,e},yg=(e,t,n)=>{e=rt(e);const s=bn(e,t);if(s==null)throw new Error("Tab not found");if(s.tabs==null||s.tabs.length===0)throw new Error("Node has no tabs");const r=s.tabs.findIndex(x=>x.tabKey===t);if(r===-1)throw new Error("Tab not found in node");const i=s.tabs[r];s.tabs=s.tabs.filter(x=>x.tabKey!==t);const l=s.key*2,a={key:s.key*2+1,tabs:[i],selected:i.tabKey},d={key:l,tabs:s.tabs,selected:s.selected};return d.selected=Te.resetSelection(d.selected,d.tabs),s.direction=n,s.first=d,s.last=a,s.tabs=void 0,s.selected=void 0,e},Sg=(e,t)=>{const n=bn(e,t);return n==null?!1:n.tabs!=null&&n.tabs.length>1},Ic=(e,t,n)=>{e=rt(e);const[,s]=Bt(e,t);if((s==null?void 0:s.tabs)==null)throw Hs;return s.tabs=Te.rename(t,n,(s==null?void 0:s.tabs)??[]),e},Rg=e=>e.tabs!=null?e.tabs.length===0:e.first==null&&e.last==null,Io=(e,t)=>{const n=Es(e,t);if(n!=null)return n;const s=Math.floor(t/2);return s===0?e:Io(e,s)},Cg=e=>{let t=!0;for(;t;)[e,t]=$o(e);return e=Do(e,1),e},$o=e=>{if(e.first==null||e.last==null)return[e,!1];if(fi(e.first))return[mi(e.last),!0];if(fi(e.last))return[mi(e.first),!0];let t,n;return[e.first,t]=$o(e.first),[e.last,n]=$o(e.last),[e,t||n]},mi=e=>(e.size=void 0,e),fi=e=>e.first==null&&e.last==null&&(e.tabs==null||e.tabs.length===0),Bt=(e,t)=>{if(e.tabs!=null){const l=e.tabs.find(c=>c.tabKey===t);if(l!=null)return[l,e]}if(e.first==null||e.last==null)return[void 0,void 0];const[n,s]=Bt(e.first,t);if(n!=null&&s!=null)return[n,s];const[r,i]=Bt(e.last,t);return[r,i]},Es=(e,t)=>{if(e.key===t)return e;if(e.first==null||e.last==null)return;const n=Es(e.first,t);return n??Es(e.last,t)},wg=e=>{switch(e){case"top":return["first","last","y"];case"left":return["first","last","x"];case"bottom":return["last","first","y"];case"right":return["last","first","x"];case"center":throw new Error("cannot split a center placed tab")}},rt=e=>Be.J.copy(e),ys=(e,t,n=[])=>(n.push(t(e)),e.first!=null&&ys(e.first,t,n),e.last!=null&&ys(e.last,t,n),n),Bo=(e,t)=>{t(e),e.first!=null&&Bo(e.first,t),e.last!=null&&Bo(e.last,t)},Do=(e,t)=>(e=rt(e),e.key=t,e.first!=null&&(e.first=Do(e.first,t*2)),e.last!=null&&(e.last=Do(e.last,t*2+1)),e);class $c{constructor(t={}){tt(this,"parent");tt(this,"stub");tt(this,"el");this.el=document.createElement("div"),Object.entries(t).forEach(([n,s])=>this.el.setAttribute(n,s))}mount(t,n){n!==this.stub&&(this.unmount(null),t.replaceChild(this.el,n),this.parent=t,this.stub=n)}unmount(t){t!=null&&t!==this.stub||this.parent==null||this.stub==null||(this.parent.replaceChild(this.stub,this.el),this.parent=void 0,this.stub=void 0)}}const bg=({node:e})=>{const t=g.createRef(),n=g.useRef(e);return g.useEffect(()=>{const s=t.current;if(s==null)return;const r=s.parentNode;if(r!=null)return e.mount(r,s),()=>{t.current!=null&&e.unmount(t.current)}},[]),g.useEffect(()=>{n.current!=null&&e!==n.current&&(n.current.unmount(t.current),n.current=e);const s=t.current;if(s==null)return;const r=s.parentNode;r!=null&&e.mount(r,s)},[e]),o.jsxRuntimeExports.jsx("div",{ref:t})},Bc=({node:e,children:t})=>kl.createPortal(t,e.el),vg=Object.freeze(Object.defineProperty({__proto__:null,In:Bc,Node:$c,Out:bg},Symbol.toStringTag,{value:"Module"})),Ss=g.memo(({root:e,onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,activeTab:l,emptyContent:c,onSelect:a,onClose:d,onRename:x,onReorder:p,contextMenu:m,addTooltip:f,...h})=>{const{tabs:j,direction:y,first:S,last:b,key:E,size:R}=e,M={onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,onClose:d,contextMenu:m,onSelect:a,onRename:x,onReorder:p,activeTab:l,addTooltip:f},_=g.useCallback(([O])=>n(E,O),[n]),{props:L}=sr({direction:y,onResize:_,count:2,initialSizes:R!=null?[R]:void 0});let A={};E==1&&(A={...h,className:u.CSS(u.CSS.B("mosaic"))});let $;return j!==void 0?$=o.jsxRuntimeExports.jsx(Dc,{root:e,emptyContent:c,...A,...M}):S!=null&&b!=null?$=o.jsxRuntimeExports.jsxs(or,{id:`mosaic-${E}`,align:"stretch",...L,...A,children:[o.jsxRuntimeExports.jsx(Ss,{...M,root:S,onResize:n},S.key),o.jsxRuntimeExports.jsx(Ss,{...M,root:b,onResize:n},b.key)]}):($=null,console.warn("Mosaic tree is malformed")),$});Ss.displayName="Mosaic";const Rs="pluto-mosaic-tab-drop",Sr="pluto-mosaic-tab-create",kg=(e,t,n)=>{if(me.filterByType(me.FILE_TYPE,t).length>0&&n)return!0;const r=me.filterByType(Rs,t).map(c=>c.key),i=e.filter(c=>!r.includes(c.tabKey)).length>0;return me.filterByType(Sr,t).length>0||r.length>0&&(i||e.length===0)},Dc=g.memo(({root:e,onDrop:t,onCreate:n,activeTab:s,children:r,className:i,onReorder:l,onFileDrop:c,addTooltip:a,...d})=>{const{key:x,tabs:p}=e,[m,f]=g.useState(null),h=c!=null,j=g.useCallback(({items:$})=>kg(p,$,h),[p,h]),y=g.useCallback(({items:$,event:O})=>{if(O==null)return[];const V=Pg(O);f(null);const z=me.filterByType(me.FILE_TYPE,$).length>0,{percents:k}=hi(O),C=p.length===0?"center":gi(k);if(z)return c==null||c(x,C,O),$;const P=me.filterByType(Rs,$);if(P.length>0){const N=P.map(({key:D})=>D)[0];t(x,N,C,V)}const v=me.filterByType(Sr,$);if(v.length>0){const N=v.map(({key:D})=>D);n==null||n(x,C,N)}return P},[t,p.length]),S=g.useCallback(({event:$})=>{if($==null)return;const{percents:O,inSelector:V}=hi($);let z=null;V||(z=p.length===0?"center":gi(O)),f(z)},[p.length]),{startDrag:b,...E}=me.useDragAndDrop({type:"Mosaic",canDrop:j,onDrop:y,onDragOver:S}),R=j(me.useDraggingState()),M=g.useCallback(()=>f(null),[]),_=g.useCallback(($,{tabKey:O})=>{b([{key:O,type:Rs,elementID:$.currentTarget.id}])},[b]),L=g.useCallback(()=>n==null?void 0:n(x,"center"),[x]),A=x==1&&p.length==0;return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:o.jsxRuntimeExports.jsxs(Te.Tabs,{id:`tab-${x}`,tabs:p,className:u.CSS(i,A&&m!=null&&u.CSS.M("drag-over")),onDragLeave:M,selected:e.selected,selectedAltColor:s===e.selected,onDragStart:_,onCreate:L,addTooltip:a,...E,...d,children:[e.selected!=null&&r(p.find($=>$.tabKey===e.selected)),R&&o.jsxRuntimeExports.jsx("div",{style:{zIndex:1e3,position:"absolute",top:0,left:0,width:"100%",height:"100%"}}),m!=null&&o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("mosaic","mask"),style:Mg[m]})]})})});Dc.displayName="MosaicTabLeaf";const Mg={top:{left:"0%",top:"0%",width:"100%",height:"50%"},bottom:{left:"0%",top:"50%",width:"100%",height:"50%"},left:{left:"0%",top:"0%",width:"50%",height:"100%"},right:{left:"50%",top:"0%",width:"50%",height:"100%"},center:{left:"0%",top:"0%",width:"100%",height:"100%"}},hi=e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;return s<24?{percents:{x:.5,y:.5},inSelector:!0}:{percents:{x:n/t.width,y:s/t.height},inSelector:!1}},Pg=e=>{var n;const t=e.target.closest(".pluto-tabs-selector__btn");if(t!=null)return Array.from(((n=t.parentElement)==null?void 0:n.children)??[]).indexOf(t)},_g=e=>e,Lg=e=>1-e,gi=({x:e,y:t})=>{if(e>.33&&e<.66&&t>.33&&t<.66)return"center";const[n,s]=[_g(e),Lg(e)];if(t>n&&t>s)return"bottom";if(t<n&&t<s)return"top";if(t>n&&t<s)return"left";if(t<n&&t>s)return"right";throw new Error("[bug] - invalid insert position")},Ng=({root:e,onSelect:t,children:n})=>{const s=g.useRef(new Map),r=new Set,i=ys(e,l=>{var c;return(c=l.tabs)==null?void 0:c.map(a=>{let d=s.current.get(a.tabKey);return a==null?null:(d==null&&(d=new $c({style:"width: 100%; height: 100%; position: relative;"}),d.el.addEventListener("click",()=>t==null?void 0:t(a.tabKey)),s.current.set(a.tabKey,d)),r.add(a.tabKey),o.jsxRuntimeExports.jsx(Bc,{node:d,children:n({...a,visible:a.tabKey===l.selected})},a.tabKey))})}).flat().filter(l=>l!=null);return s.current.forEach((l,c)=>!r.has(c)&&s.current.delete(c)),[s,i]},Oo=ce.object({key:ce.number(),tabs:ce.array(Te.tabZ).optional(),selected:ce.string().optional(),direction:u.g.direction.optional(),size:ce.number().optional(),get first(){return Oo.optional()},get last(){return Oo.optional()}}),Tg=({allowRename:e=!1,initialTree:t})=>{const[n,s]=g.useState(t);return g.useEffect(()=>s(gs(t)[0]),[t]),{root:n,onDrop:(d,x,p)=>s(m=>Tc(m,x,p,d)[0]),onClose:d=>s(x=>yr(x,d)[0]),onSelect:d=>s(x=>Nc(x,d)),onResize:(d,x)=>s(p=>Ac(p,d,x)),onRename:e?(d,x)=>s(p=>Ic(p,d,x)):void 0}},Ag=Object.freeze(Object.defineProperty({__proto__:null,HAUL_CREATE_TYPE:Sr,HAUL_DROP_TYPE:Rs,Mosaic:Ss,autoSelectTabs:gs,canSplit:Sg,findSelected:js,findTabNode:bn,forEachNode:Bo,insertTab:hs,isEmpty:Rg,mapNodes:ys,moveTab:Tc,nodeZ:Oo,removeTab:yr,renameTab:Ic,resizeNode:Ac,selectTab:Nc,split:yg,updateTab:Eg,use:Tg,usePortal:Ng},Symbol.toStringTag,{value:"Module"})),Ig=({variant:e,className:t,...n})=>o.jsxRuntimeExports.jsx(ne.Space,{className:u.CSS(t,u.CSS.B("note"),u.CSS.M(e)),align:"stretch",empty:!0,...n}),$g=Object.freeze(Object.defineProperty({__proto__:null,Note:Ig},Symbol.toStringTag,{value:"Module"})),ho={Close:o.jsxRuntimeExports.jsxs("svg",{width:"124",height:"124",viewBox:"0 0 124 124",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsxRuntimeExports.jsx("rect",{x:"26.8701",y:"88.3883",width:"87",height:"11",transform:"rotate(-45 26.8701 88.3883)",fill:"#7E0508"}),o.jsxRuntimeExports.jsx("rect",{x:"26.8701",y:"34.6482",width:"11",height:"87",transform:"rotate(-45 26.8701 34.6482)",fill:"#7E0508"})]}),Minimize:o.jsxRuntimeExports.jsx("svg",{width:"87",height:"11",viewBox:"0 0 87 11",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsxRuntimeExports.jsx("rect",{x:"15",width:"60",height:"11",fill:"#985712"})}),Maximize:o.jsxRuntimeExports.jsxs("svg",{width:"143",height:"143",viewBox:"0 0 143 143",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsxRuntimeExports.jsx("path",{d:"M108.242 32.8833C108.797 32.8817 109.247 33.3317 109.245 33.8862L109.092 87.5891C109.09 88.4786 108.014 88.9223 107.385 88.2933L53.8351 34.7432C53.2061 34.1142 53.6499 33.0387 54.5394 33.0361L108.242 32.8833Z",fill:"#0B650D"}),o.jsxRuntimeExports.jsx("path",{d:"M33.8862 109.245C33.3317 109.247 32.8818 108.797 32.8833 108.242L33.0361 54.5394C33.0387 53.6499 34.1142 53.2061 34.7432 53.8351L88.2934 107.385C88.9223 108.014 88.4786 109.09 87.5891 109.092L33.8862 109.245Z",fill:"#0B650D"})]})},Bg=({disabled:e=[],className:t,focused:n=!0,onMinimize:s,onMaximize:r,onFullscreen:i,onClose:l,...c})=>o.jsxRuntimeExports.jsxs(ne.Space,{size:1.5,x:!0,className:u.CSS(u.CSS.B("macos-controls"),!n&&u.CSS.BM("macos-controls","blurred"),t),...c,children:[o.jsxRuntimeExports.jsx(go,{onClick:l,className:u.CSS.BM("macos-control","close"),disabled:e.includes("close"),children:ho.Close}),o.jsxRuntimeExports.jsx(go,{onClick:s,className:u.CSS.BM("macos-control","minimize"),disabled:e.includes("minimize"),children:ho.Minimize}),o.jsxRuntimeExports.jsx(go,{onClick:i,className:u.CSS.BM("macos-control","maximize"),disabled:e.includes("maximize"),children:ho.Maximize})]}),go=({className:e,disabled:t,color:n,...s})=>o.jsxRuntimeExports.jsx("button",{className:u.CSS(u.CSS.B("macos-control"),u.CSS.disabled(t),e),tabIndex:-1,disabled:t,size:"",...s}),Dg=({disabled:e=[],onMinimize:t,onMaximize:n,onClose:s,onFullscreen:r,focused:i,shade:l=2,...c})=>o.jsxRuntimeExports.jsxs(Is.Pack,{...c,children:[o.jsxRuntimeExports.jsx(jo,{className:u.CSS.BM("windows-control","minimize"),onClick:t,disabled:e.includes("minimize"),shade:l,children:o.jsxRuntimeExports.jsx(K.y4.Subtract,{})}),o.jsxRuntimeExports.jsx(jo,{className:u.CSS.BM("windows-control","maximize"),onClick:n,disabled:e.includes("maximize"),shade:l,children:o.jsxRuntimeExports.jsx(K.y4.Box,{})}),o.jsxRuntimeExports.jsx(jo,{onClick:s,className:u.CSS.BM("windows-control","close"),disabled:e.includes("close"),shade:l,children:o.jsxRuntimeExports.jsx(K.y4.Close,{})})]}),jo=({disabled:e=!1,className:t,...n})=>e?null:o.jsxRuntimeExports.jsx(fe.Icon,{className:u.CSS(u.CSS.B("windows-control"),t),tabIndex:-1,...n}),Oc=u.S.getOS,Og="Windows",zg=({forceOS:e,visibleIfOS:t,...n})=>{const s=Oc({force:e,default:Og});if(t!=null&&t!==s)return null;const r=s==="macOS"?Bg:Dg;return o.jsxRuntimeExports.jsx(r,{...n})},Vg=Object.freeze(Object.defineProperty({__proto__:null,Controls:zg,use:Oc},Symbol.toStringTag,{value:"Module"})),Fg=(e,t)=>{const n=s=>o.jsxRuntimeExports.jsx(e,{...t,...s});return n.displayName=e.displayName,n},Hg=Object.freeze(Object.defineProperty({__proto__:null,createComponent:Fg},Symbol.toStringTag,{value:"Module"}));g.createContext({instrumentation:bt.C.NOOP});const Zg=({children:e,...t})=>{const{path:n}=Q.useUnidirectional({type:ps.Provider.TYPE,schema:ps.providerStateZ,state:t});return o.jsxRuntimeExports.jsx(Q.Composite,{path:n,children:e})},Kg="data:video/mp2t;base64,Ly8gQ29weXJpZ2h0IDIwMjUgU3lubmF4IExhYnMsIEluYy4KLy8KLy8gVXNlIG9mIHRoaXMgc29mdHdhcmUgaXMgZ292ZXJuZWQgYnkgdGhlIEJ1c2luZXNzIFNvdXJjZSBMaWNlbnNlIGluY2x1ZGVkIGluIHRoZSBmaWxlCi8vIGxpY2Vuc2VzL0JTTC50eHQuCi8vCi8vIEFzIG9mIHRoZSBDaGFuZ2UgRGF0ZSBzcGVjaWZpZWQgaW4gdGhhdCBmaWxlLCBpbiBhY2NvcmRhbmNlIHdpdGggdGhlIEJ1c2luZXNzIFNvdXJjZQovLyBMaWNlbnNlLCB1c2Ugb2YgdGhpcyBzb2Z0d2FyZSB3aWxsIGJlIGdvdmVybmVkIGJ5IHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAsCi8vIGluY2x1ZGVkIGluIHRoZSBmaWxlIGxpY2Vuc2VzL0FQTC50eHQuCgppbXBvcnQgeyBwbHV0byB9IGZyb20gIkAvcGx1dG8vYWV0aGVyIjsKCnBsdXRvLnJlbmRlcigpOwo=",zc=({children:e})=>{const{path:t}=Q.useUnidirectional({type:B.BaseProvider.TYPE,schema:B.providerStateZ$1,state:{}});return o.jsxRuntimeExports.jsx(Q.Composite,{path:t,children:e})},Wg=Object.freeze(Object.defineProperty({__proto__:null,Provider:zc},Symbol.toStringTag,{value:"Module"})),Yg=Object.freeze(Object.defineProperty({__proto__:null,AcquireChannelControl:B.AcquireChannelControl,AuthoritySource:B.AuthoritySource,Chip:B.Chip,Controller:B.Controller,Indicator:B.Indicator,Legend:B.Legend,REGISTRY:B.REGISTRY$15,STATUSES:B.STATUSES,SetChannelValue:B.SetChannelValue,StateProvider:B.StateProvider,acquireChannelControl:B.acquireChannelControl,acquireChannelControlPropsZ:B.acquireChannelControlPropsZ,authoritySource:B.authoritySource,authoritySourceProps:B.authoritySourceProps,chipStateZ:B.chipStateZ,controllerStateZ:B.controllerStateZ,indicatorStateZ:B.indicatorStateZ,legendStateZ:B.legendStateZ,setChannelValue:B.setChannelValue,setChannelValuePropsZ:B.setChannelValuePropsZ,stateProviderStateZ:B.stateProviderStateZ,statusZ:B.statusZ,sugaredStateZ:B.sugaredStateZ},Symbol.toStringTag,{value:"Module"})),Gg=e=>{var t,n;switch(e.variant){case"disabled":return((t=e.data)==null?void 0:t.valid)===!0?{message:"Uncontrolled. Click to take control.",chipColor:"var(--pluto-gray-l12)"}:{message:"No channel connected. This element cannot be controlled.",chipColor:"var(--pluto-gray-l7)",disabled:!0};case"error":return{message:"Not controlled by you. Click to take absolute control.",chipColor:"var(--pluto-error-z)"};case"success":return((n=e.data)==null?void 0:n.authority)===bt.hq.ABSOLUTE_AUTHORITY?{message:"You have absolute control. Click to release.",chipColor:"var(--pluto-secondary-z)",buttonStyle:{background:"var(--pluto-secondary-z-30)"}}:{message:"You're in control. Release schematic to release control.",chipColor:"var(--pluto-primary-z)"};default:return{message:"Unexpected status.",chipColor:"var(--pluto-error-z)"}}},Vc=({source:e,sink:t,className:n,...s})=>{const r=Ae.useMemoDeepEqualProps({source:e,sink:t}),[,{status:i},l]=Q.use$1({type:B.Chip.TYPE,schema:B.chipStateZ,initialState:{triggered:!1,...r,status:{key:"no_chip",variant:"disabled",message:"No chip connected.",time:u.d.now()}}});g.useEffect(()=>{l(m=>({...m,...r}))},[r,l]);const c=g.useCallback(()=>l(m=>({...m,triggered:!m.triggered})),[l]),{message:a,chipColor:d,buttonStyle:x,disabled:p}=Gg(i);return o.jsxRuntimeExports.jsx(fe.Icon,{variant:"text",className:u.CSS(u.CSS.B("control-chip"),n),disabled:p,onClick:c,tooltip:o.jsxRuntimeExports.jsx(K.Text,{level:"small",children:a}),style:x,...s,children:o.jsxRuntimeExports.jsx(K.y4.Circle,{color:d})})},Fc=g.createContext({needsControlOf:[]}),Hc=()=>g.use(Fc),qg=({children:e,onStatusChange:t,...n})=>{const s=Ae.useMemoDeepEqualProps(n),[{path:r},{status:i,needsControlOf:l},c]=Q.use$1({type:B.Controller.TYPE,schema:B.controllerStateZ,initialState:s});return g.useEffect(()=>{i!=null&&(t==null||t(i))},[i,t]),g.useEffect(()=>{c(a=>({...a,...s}))},[s,c]),g.useEffect(()=>()=>t==null?void 0:t("released"),[]),o.jsxRuntimeExports.jsxs(Fc,{value:{needsControlOf:l},children:[o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:e}),";"]})},Zc=({colorSource:e,statusSource:t})=>{var c;const n=Ae.useMemoDeepEqualProps({colorSource:e,statusSource:t}),[,{color:s,status:r},i]=Q.use$1({type:B.Indicator.TYPE,initialState:{...n,status:{key:"no_chip",variant:"warning",message:"No chip connected.",time:u.d.now()}},schema:B.indicatorStateZ});g.useEffect(()=>{i(a=>({...a,...n}))},[n,i]);let l;return((c=r.data)==null?void 0:c.color)!=null?l=u.od.colorZ.parse(r.data.color):s!=null&&!u.od.isZero(s)?l=s:l="var(--pluto-gray-l10)",o.jsxRuntimeExports.jsxs(fe.Dialog,{location:{x:"center",y:"bottom"},children:[o.jsxRuntimeExports.jsx(K.Text,{level:"p",children:r.message}),o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("indicator"),style:{backgroundColor:u.od.cssString(l),flexGrow:1}})]})},Xg=e=>{const{needsControlOf:t}=Hc(),[,{states:n},s]=Q.use$1({type:B.Legend.TYPE,schema:B.legendStateZ,initialState:{states:[],needsControlOf:t}});g.useEffect(()=>{s(l=>({...l,needsControlOf:t}))},[t]);const i=u.c.unique(n.map(l=>l.subject.key)).map(l=>{const c=n.find(a=>a.subject.key===l);if(c==null)throw new bt.ti("Legend subject not found");return{key:c.subject.key,label:c.subject.name,color:c.subjectColor}});return o.jsxRuntimeExports.jsx(ar,{data:i,...e})},Kc=({children:e})=>{const[{path:t}]=Q.use$1({type:B.StateProvider.TYPE,schema:B.stateProviderStateZ,initialState:{}});return o.jsxRuntimeExports.jsx(Q.Composite,{path:t,children:e})},Ug=Object.freeze(Object.defineProperty({__proto__:null,Chip:Vc,Controller:qg,Indicator:Zc,Legend:Xg,StateProvider:Kc,useContext:Hc},Symbol.toStringTag,{value:"Module"})),Wc=e=>{const t=({disabled:n=!1,...s})=>n?s.children:o.jsxRuntimeExports.jsx(e,{...s});return t.displayName=e.displayName,t},Jg=Wc(zc),Qg=Wc(Q.Provider$2),e0=({children:e,connParams:t,workerEnabled:n=!0,workerURL:s,theming:r,tooltip:i,triggers:l,alamos:c,haul:a,channelAlias:d,telem:x,color:p})=>o.jsxRuntimeExports.jsx(De.Provider,{...l,children:o.jsxRuntimeExports.jsx(fe.Config,{...i,children:o.jsxRuntimeExports.jsx(me.Provider,{...a,children:o.jsxRuntimeExports.jsx(Q.Provider$1,{url:s??Kg,enabled:n,children:o.jsxRuntimeExports.jsx(Qg,{workerKey:"vis",children:o.jsxRuntimeExports.jsx(Zg,{...c,children:o.jsxRuntimeExports.jsx(Ce.Aggregator,{children:o.jsxRuntimeExports.jsx(Dl,{connParams:t,children:o.jsxRuntimeExports.jsx(Vl,{...d,children:o.jsxRuntimeExports.jsx(Ge.Provider,{...p,children:o.jsxRuntimeExports.jsx(Q.Provider,{...r,children:o.jsxRuntimeExports.jsx(Jg,{...x,children:o.jsxRuntimeExports.jsx(Kc,{children:e})})})})})})})})})})})})}),t0=Object.freeze(Object.defineProperty({__proto__:null,Provider:e0},Symbol.toStringTag,{value:"Module"})),n0=({value:e})=>o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("progress"),children:o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("progress-bar"),style:{width:`${e}%`}})}),s0=Object.freeze(Object.defineProperty({__proto__:null,Progress:n0},Symbol.toStringTag,{value:"Module"})),vn="range",Rr=[{key:"name",name:"Name"}],Cs=({items:e},t)=>{const n=me.filterByType(vn,e);return n.length>0&&!n.every(s=>t.includes(s.key))},o0=({onChange:e,className:t,value:n,...s})=>{const r=qe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=me.useDragAndDrop({type:"Ranger.SelectMultiple",canDrop:g.useCallback(m=>Cs(m,Pe.t.toArray(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=me.filterByType(vn,m);if(f.length===0)return[];const h=u.c.unique([...Pe.t.toArray(n),...f.map(j=>j.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),d=me.useDraggingState(),x=g.useCallback(({dropped:m})=>{e(Pe.t.toArray(n).filter(f=>!m.some(h=>h.key===f)),{clickedIndex:null,clicked:null,entries:[]})},[e,n]),p=g.useCallback((m,f)=>l([{key:f,type:vn}],x),[l,x]);return o.jsxRuntimeExports.jsx(an,{className:u.CSS(t,u.CSS.dropRegion(Cs(d,Pe.t.toArray(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.ranges,onChange:e,columns:Rr,emptyContent:i,entryRenderKey:"name",...a,...s})},Yc=({value:e,onChange:t})=>{const n=qe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(Ce.Text.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),r=g.useId(),i=g.useMemo(()=>({key:r,type:"Ranger.SelectMultiple"}),[r]),{startDrag:l,...c}=me.useDragAndDrop({type:"Ranger.SelectSingle",canDrop:g.useCallback(x=>Cs(x,Pe.t.toArray(e)),[e]),onDrop:g.useCallback(({items:x})=>{const p=me.filterByType(vn,x);return p.length===0?[]:(t(p[0].key,{clickedIndex:null,clicked:null,entries:[]}),p)},[i,t])}),a=me.useDraggingState(),d=g.useCallback(()=>e!=null&&l([{type:vn,key:e}]),[l,e]);return{emptyContent:s,dragging:a,...c,onDragStart:d,searcher:n==null?void 0:n.ranges}},r0=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=Yc({value:t,onChange:e});return o.jsxRuntimeExports.jsx(mt,{data:s,className:u.CSS(n,u.CSS.dropRegion(Cs(i,Pe.t.toArray(t)))),value:t,onChange:e,columns:Rr,entryRenderKey:"name",...l,...r})},i0=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=Yc({value:t,onChange:n});return o.jsxRuntimeExports.jsx(mt,{data:e,value:t,onChange:n,columns:Rr,entryRenderKey:"name",...i,...s})},l0=[{key:"color",name:"Color",width:50,render:e=>o.jsxRuntimeExports.jsx(K.y4.Circle,{style:{fontSize:10,marginLeft:10,marginRight:30},color:e.entry.color})},{key:"name",name:"Name"}],c0=e=>{const t=qe();return o.jsxRuntimeExports.jsx(an,{...e,searcher:t==null?void 0:t.labels,columns:l0,renderTag:n=>n.entry==null?o.jsxRuntimeExports.jsx(wn,{color:"gray",children:n.entryKey}):o.jsxRuntimeExports.jsx(wn,{color:n.entry.color,children:n.entry.name})})},a0=({timeRange:e,level:t="p",shade:n=9,showSpan:s=!1,labeled:r=!1,...i})=>{const l=new u.d(e.start),c=l.isToday?"time":"dateTime",a=new u.d(e.end),d=a.equals(u.d.MAX),x=a.span(l)<u.g$2.DAY?"time":"dateTime",p=l.span(a);let m=o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,align:"center",size:"small",children:[l.isToday&&o.jsxRuntimeExports.jsx(K.Text,{level:t,shade:n,weight:450,children:"Today"}),o.jsxRuntimeExports.jsx(_o.DateTime,{level:t,displayTZ:"local",format:c,shade:n,weight:450,children:l})]}),f=o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[d?o.jsxRuntimeExports.jsx(K.Text,{level:t,children:"Now"}):o.jsxRuntimeExports.jsx(_o.DateTime,{level:t,displayTZ:"local",format:x,shade:n,weight:450,children:a}),!p.isZero&&s&&o.jsxRuntimeExports.jsxs(K.Text,{level:t,shade:n,weight:450,children:["(",l.span(a).truncate(u.g$2.MILLISECOND).toString(),")"]})]});r&&(m=o.jsxRuntimeExports.jsx(he.Item,{label:"Start",showHelpText:!1,children:m}),f=o.jsxRuntimeExports.jsx(he.Item,{label:"End",showHelpText:!1,children:f}));const h=u.CSS.levelSizeVar(t);return o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,size:"small",className:u.CSS(u.CSS.B("time-range-chip")),align:"center",...i,children:[m,o.jsxRuntimeExports.jsx(K.y4.Arrow.Right,{color:"var(--pluto-gray-l9)",style:{width:h,height:h}}),f]})},u0=Object.freeze(Object.defineProperty({__proto__:null,SelectButton:i0,SelectLabels:c0,SelectMultiple:o0,SelectSingle:r0,TimeRangeChip:a0},Symbol.toStringTag,{value:"Module"})),d0=({steps:e,value:t,onChange:n,...s})=>{const r=e.findIndex(i=>i.key===t);return o.jsxRuntimeExports.jsx(ne.Space,{x:!0,align:"center",className:u.CSS.B("steps"),...s,children:e.map((i,l)=>o.jsxRuntimeExports.jsxs(g.Fragment,{children:[o.jsxRuntimeExports.jsxs(fe.Button,{onClick:()=>n(i.key),variant:"outlined",disabled:l>r,children:[l+1,". ",i.title]},i.key),l!==e.length-1&&o.jsxRuntimeExports.jsx(K.y4.Arrow.Right,{style:{fontSize:"15px",color:"var(--pluto-gray-l10)"}})]},i.key))})},x0=Object.freeze(Object.defineProperty({__proto__:null,Steps:d0},Symbol.toStringTag,{value:"Module"})),p0=({children:e,className:t,visible:n,...s})=>{const[{path:r},,i]=Q.use$1({type:B.Table.TYPE,schema:B.Table.stateZ,initialState:{region:u.Pt.ZERO,visible:n}});g.useEffect(()=>{i(c=>({...c,visible:n}))},[n]);const l=In(c=>i(a=>({...a,region:c})));return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx("div",{ref:l,style:{right:0,bottom:0,position:"absolute",top:6,left:6}}),o.jsxRuntimeExports.jsx("table",{className:u.CSS(u.CSS.B("table"),t),...s,children:o.jsxRuntimeExports.jsx("tbody",{children:o.jsxRuntimeExports.jsx(Q.Composite,{path:r,children:e})})})]})},m0=({children:e,className:t,size:n,index:s,onResize:r,onSelect:i,position:l,...c})=>o.jsxRuntimeExports.jsxs("tr",{className:u.CSS(u.CSS.BE("table","row"),t),...c,children:[r!=null&&o.jsxRuntimeExports.jsx(qc,{onSelect:i,index:s,value:n,onChange:r,position:l,direction:"y"}),e]}),Cr=({ref:e,children:t,className:n,selected:s=!1,...r})=>o.jsxRuntimeExports.jsx("td",{ref:e,...r,className:u.CSS(u.CSS.BE("table","cell"),u.CSS.selected(s),n),children:t}),Gc="ABCDEFGHIJKLMNOPQRSTUVWXYZ",f0=e=>Gc[e],qc=({value:e,selected:t=!1,index:n,onChange:s,position:r,direction:i="x",onSelect:l})=>{const c=K.useSyncedRef(e),a=g.useRef(e),d=Ge.useCursorDrag({onStart:g.useCallback(()=>{a.current=c.current},[]),onMove:g.useCallback(x=>s(a.current+u.Pt.dim(x,i,!0),n),[s,n])});return o.jsxRuntimeExports.jsxs("td",{id:`resizer-${i}-${n}`,className:u.CSS(u.CSS.BE("table","resizer"),u.CSS.dir(i),u.CSS.selected(t),vt.CONTEXT_TARGET,t&&vt.CONTEXT_SELECTED),style:{[u.g.dimension(i)]:e},onClick:()=>l(n),onContextMenu:()=>l(n),children:[o.jsxRuntimeExports.jsx(K.Text,{level:"p",shade:11,style:{width:"100%",textAlign:"center"},children:i==="x"?Gc[n]:n+1}),o.jsxRuntimeExports.jsx("button",{onClick:x=>x.stopPropagation(),style:{[u.g.location(i)]:r+e},onDragStart:d,draggable:!0})]})},h0=({selected:e,onSelect:t,columns:n,onResize:s})=>{let r=15;return o.jsxRuntimeExports.jsxs("tr",{className:u.CSS(u.CSS.BE("table","row"),u.CSS.BE("table","col-resizer")),children:[o.jsxRuntimeExports.jsx("td",{}),n.map((i,l)=>{const c=r;return r+=i,o.jsxRuntimeExports.jsx(qc,{onSelect:t,position:c,selected:e.includes(l),index:l,value:i,onChange:a=>s(a,l),direction:"x"},l)})]})},g0=Object.freeze(Object.defineProperty({__proto__:null,Cell:Cr,ColumnIndicators:h0,Row:m0,Table:p0,getCellColumn:f0},Symbol.toStringTag,{value:"Module"})),j0=[{key:"standard",name:"Standard"},{key:"scientific",name:"Scientific"},{key:"engineering",name:"Engineering"}],E0=e=>o.jsxRuntimeExports.jsx(ot,{...e,entryRenderKey:"name",data:j0}),Xc=[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],wr=({path:e})=>{var f;const{value:t,onChange:n}=Mt({path:e}),s=B.sourcePipelinePropsZ.parse((f=t.telem)==null?void 0:f.props),r=B.streamChannelValuePropsZ.parse(s.segments.valueStream.props),i=B.stringifyNumberProps.parse(s.segments.stringifier.props),l=B.rollingAverageProps.parse(s.segments.rollingAverage.props),c=h=>{const j=B.sourcePipeline("string",{connections:Xc,segments:{valueStream:B.streamChannelValue({channel:r.channel}),stringifier:B.stringifyNumber({precision:i.precision??2,notation:i.notation}),rollingAverage:B.rollingAverage({windowSize:l.windowSize??1}),...h},outlet:"stringifier"});n({...t,telem:j})},a=h=>c({valueStream:B.streamChannelValue({channel:h??0})}),d=h=>c({stringifier:B.stringifyNumber({...i,notation:h})}),x=h=>c({stringifier:B.stringifyNumber({...i,precision:h})}),p=h=>c({rollingAverage:B.rollingAverage({windowSize:h})}),m=Bs(r.channel);return g.useEffect(()=>n({...t,tooltip:[m]}),[m]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(he.Item,{label:"Input Channel",grow:!0,children:o.jsxRuntimeExports.jsx($t,{value:r.channel,onChange:a})}),o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,children:[o.jsxRuntimeExports.jsx(he.Item,{label:"Notation",children:o.jsxRuntimeExports.jsx(E0,{value:i.notation,onChange:d})}),o.jsxRuntimeExports.jsx(he.Item,{label:"Precision",align:"start",children:o.jsxRuntimeExports.jsx(he.Numeric,{value:i.precision??2,bounds:{lower:0,upper:10},onChange:x})}),o.jsxRuntimeExports.jsx(he.Item,{label:"Averaging Window",align:"start",children:o.jsxRuntimeExports.jsx(he.Numeric,{value:l.windowSize??1,bounds:{lower:1,upper:100},onChange:p})})]})]})},y0=B.Value.z.partial({color:!0}).extend({level:ce.levelZ.optional()}),br=({aetherKey:e,box:t,telem:n,color:s,precision:r,minWidth:i,level:l="small",backgroundTelem:c,notation:a,location:d})=>{const x=Ae.useMemoDeepEqualProps({box:t,telem:n,color:s,precision:r,level:l,minWidth:i,notation:a,backgroundTelem:c,location:d}),[,p,m]=Q.use$1({aetherKey:e,type:B.Value.TYPE,schema:B.Value.z,initialState:x});return g.useEffect(()=>m(f=>({...f,...x})),[x]),{width:p.width??p.minWidth}},S0=Object.freeze(Object.defineProperty({__proto__:null,TelemForm:wr,VALUE_CONNECTIONS:Xc,corePropsZ:y0,use:br},Symbol.toStringTag,{value:"Module"})),R0=ce.object({value:ce.string(),level:ce.levelZ,weight:ce.weightZ,align:u.K$1.x.or(u.K$1.center),backgroundColor:u.od.crudeZ}),C0=({cellKey:e,onChange:t,value:n,selected:s,onSelect:r,align:i,level:l,weight:c,backgroundColor:a})=>{const d=p=>r(e,p),x=p=>t({level:l,value:p,weight:c,align:i,backgroundColor:a});return o.jsxRuntimeExports.jsx(Cr,{id:e,className:u.CSS(vt.CONTEXT_TARGET,s&&vt.CONTEXT_SELECTED,u.CSS.BEM("table","cell","text")),selected:s,onClick:d,onContextMenu:d,style:{backgroundColor:u.od.cssString(a)},children:o.jsxRuntimeExports.jsx(K.Editable,{level:l,value:n,weight:c,onChange:x,style:{justifyContent:i},allowEmpty:!0,outline:!1})})},w0=ce.object({telem:B.stringSourceSpecZ,redline:ce.object({bounds:u.G.bounds,gradient:u.od.gradientZ}),level:ce.levelZ,color:ce.string(),units:ce.string()}),b0=({cellKey:e,telem:t,level:n,color:s,redline:{gradient:r,bounds:i},selected:l,box:c,onSelect:a})=>{const{width:d}=br({aetherKey:e,box:c,telem:t,level:n,color:s,backgroundTelem:B.sourcePipeline("color",{connections:[{from:"source",to:"scale"},{from:"scale",to:"gradient"}],segments:{source:t,scale:B.scaleNumber({scale:u.A.Scale.scale(i).scale(0,1).transform}),gradient:B.colorGradient({gradient:r})},outlet:"gradient"}),location:{x:"center",y:"center"}}),x=p=>a(e,p);return o.jsxRuntimeExports.jsx(Cr,{id:e,selected:l,onClick:x,onContextMenu:x,style:{height:"5rem",width:d},className:u.CSS(vt.CONTEXT_TARGET,l&&vt.CONTEXT_SELECTED,u.CSS.BEM("table","cell","value"))})},v0=({onVariantChange:e})=>{const t=g.useCallback(({tabKey:s})=>{switch(s){case"telem":return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(wr,{path:""})});case"redline":return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(k0,{})});default:return o.jsxRuntimeExports.jsx(ne.Space,{y:!0,grow:!0,empty:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,children:[o.jsxRuntimeExports.jsx(he.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Uc,{onChange:e,value:"value"})}),o.jsxRuntimeExports.jsx(we,{hideIfNull:!0,label:"Color",align:"start",padHelpText:!1,path:"color",children:({value:r,onChange:i,variant:l,...c})=>o.jsxRuntimeExports.jsx(Ge.Swatch,{value:r??u.od.setAlpha(u.od.ZERO,1),onChange:i,...c,bordered:!0})}),o.jsxRuntimeExports.jsx(we,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:r=>o.jsxRuntimeExports.jsx(un,{...r})})]})})}},[]),n=Te.useStatic({tabs:[{tabKey:"style",name:"Style"},{tabKey:"telem",name:"Telemetry"},{tabKey:"redline",name:"Redline"}],content:t});return o.jsxRuntimeExports.jsx(Te.Tabs,{...n})},k0=()=>{const{set:e,get:t}=ft(),n=Cc("redline.bounds"),s=u.A.Scale.scale(0,1).scale(n);return o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,grow:!0,children:[o.jsxRuntimeExports.jsx(Ze,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Lower",path:"redline.bounds.lower"}),o.jsxRuntimeExports.jsx(we,{path:"redline.gradient",label:"Gradient",align:"start",padHelpText:!1,children:({value:r,onChange:i})=>o.jsxRuntimeExports.jsx(Ge.GradientPicker,{value:Be.J.copy(r),scale:s,onChange:l=>{const a={...t("redline.bounds").value},d=l.map(j=>j.position),x=s.pos(Math.max(...d)),p=s.pos(Math.min(...d)),m=x>a.upper,f=p<a.lower;m&&(l[l.length-1].position=1,a.upper=x),f&&(l[0].position=0,a.lower=p);const h=l.map(j=>({...j,color:u.od.hex(j.color)}));m||f?e("redline",{bounds:a,gradient:h}):i(l.map(j=>({...j,color:u.od.hex(j.color)})))}})}),o.jsxRuntimeExports.jsx(Ze,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Upper",path:"redline.bounds.upper"})]})},M0=({onVariantChange:e})=>o.jsxRuntimeExports.jsxs(ne.Space,{x:!0,grow:!0,style:{padding:"2rem"},children:[o.jsxRuntimeExports.jsx(he.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Uc,{onChange:e,value:"text"})}),o.jsxRuntimeExports.jsx(gr,{path:"value",label:"Text"}),o.jsxRuntimeExports.jsx(we,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(un,{...t})}),o.jsxRuntimeExports.jsx(we,{path:"weight",label:"Weight",padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(ac,{...t})}),o.jsxRuntimeExports.jsx(we,{path:"align",label:"Alignment",hideIfNull:!0,children:t=>o.jsxRuntimeExports.jsx(zs,{...t})}),o.jsxRuntimeExports.jsx(we,{path:"backgroundColor",label:"Background",align:"start",padHelpText:!1,children:({value:t,onChange:n})=>o.jsxRuntimeExports.jsx(Ge.Swatch,{value:t,onChange:n})})]}),P0=[{key:"text",name:"Text"},{key:"value",name:"Value"}],Uc=e=>o.jsxRuntimeExports.jsx(ot,{...e,data:P0,allowMultiple:!1,entryRenderKey:"name"}),_0=["text","value"],L0=ce._enum(_0),N0={key:"value",name:"Value",Form:v0,Cell:b0,defaultProps:e=>({telem:B.sourcePipeline("string",{connections:[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],segments:{valueStream:B.streamChannelValue({channel:0}),rollingAverage:B.rollingAverage({windowSize:1}),stringifier:B.stringifyNumber({precision:2,notation:"standard"})},outlet:"stringifier"}),redline:{bounds:{lower:0,upper:1},gradient:[]},color:u.od.hex(e.colors.gray.l10),level:"h5",units:""}),schema:w0},T0={key:"text",name:"Text",Form:M0,Cell:C0,defaultProps:()=>({value:"",level:"h5",units:"",weight:400,align:"center",backgroundColor:"#00000000"}),schema:R0},A0={text:T0,value:N0},I0=Object.freeze(Object.defineProperty({__proto__:null,CELLS:A0,variantZ:L0},Symbol.toStringTag,{value:"Module"})),ji=({sourcePos:e,targetPos:t,next:n,prev:s})=>{const r=Nt(e,...n);return u.K.distance(r,t)<1?!0:(console.warn("Connector is out of sync with target"),console.log("Theoretical target",r),console.log("Actual target",t),console.log("Segments",n),console.log("Prev segments",s),!1)},Ei=({sourceStumpTip:e,sourceOrientation:t,sourceBox:n,targetStumpTip:s,targetOrientation:r,targetBox:i})=>{if(!$0({sourcePos:e,sourceOrientation:t,targetPos:s}))return;const l=u.g.construct(t),c=u.g.swap(l);let a=At(c,s[c]-e[c]);const d=u.Pt.loc(n,a);if(u.K$1.swap(t)===r){const x=u.Pt.loc(i,u.K$1.swap(a));Math.abs(d-x)<Fe&&(a=u.K$1.swap(a))}return{direction:c,length:d-e[c]+Dt(a,Fe)}},zo=ce.object({direction:u.g.direction,length:ce.number()}),Nt=(e,...t)=>{let n=e;for(const s of t)n=u.K.translate(n,s.direction,s.length);return n},Jc=(e,t,n,s)=>{try{let r=e;const i=[e,...t.map(f=>(r=u.K.translate(r,f.direction,f.length),r))];if(!s)return i;const l=t[0],c=At(l.direction,l.length),a=yi(c),d=4*(2-n**.5);i[0]=u.K.translate(i[0],{[l.direction]:-1*a*d,[u.g.swap(l.direction)]:0});const x=t[t.length-1],p=At(x.direction,x.length),m=yi(p);return i[i.length-1]=u.K.translate(i[i.length-1],{[x.direction]:m*d,[u.g.swap(x.direction)]:0}),i}catch{return[]}},Fe=10,yi=e=>e==="top"||e==="left"?-1:1,Dt=(e,t)=>e==="top"||e==="left"?-t:t,At=(e,t)=>e==="x"?t>0?"right":"left":t>0?"bottom":"top",Rt=e=>At(e.direction,e.length),$0=({sourcePos:e,targetPos:t,sourceOrientation:n})=>{const s=u.g.construct(n),r=t[s]-e[s];return Dt(n,r)<0},qn=e=>({direction:u.g.construct(e),length:Dt(e,Fe)}),Si={top:qn("top"),bottom:qn("bottom"),left:qn("left"),right:qn("right")},B0=4,D0=.25,Zs=e=>Vo(O0(Vo(e))),O0=e=>{const t=[...e],n=e.findIndex((s,r)=>{const i=Math.abs(s.length);if(i<B0){if(r===0||r===e.length-1)return!1;if(i<D0)return!0;if(e.length<=3)return!1;if(r+2<e.length){const l=t[r+2];if(l.direction!==s.direction)return!1;t[r+2]={...l,length:l.length+s.length}}else{const l=t[r-2];if(l.direction!==s.direction)return!1;t[r-2]={...l,length:l.length+s.length}}return!0}return!1});return n!==-1&&t.splice(n,1),t},Vo=e=>{const t=[...e];return e.findIndex((s,r)=>{const i=t[r-1];if(r===0||s.direction!==i.direction)return!1;if(r===1){const l=r-1,c=r,a=Rt(i),d=Rt(s);if(a===d)return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0;if(Math.abs(i.length)===Fe)return!1;const x=Dt(a,Fe),p=t[l].length-x,m=t[c].length+p;return Math.abs(m)<Fe?!1:(t[l]={...t[l],length:x},t[c]={...t[c],length:m},!0)}if(r===e.length-1){const l=r,c=r-1,a=Rt(s),d=Rt(i);if(a===d)return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0;if(Math.abs(s.length)===Fe)return!1;const x=Dt(a,Fe),p=t[l].length-x,m=t[c].length+p;return Math.abs(m)<Fe?!1:(t[l]={...t[l],length:x},t[c]={...t[c],length:m},!0)}return t[r-1]={direction:t[r-1].direction,length:t[r-1].length+t[r].length},t.splice(r,1),!0})!==-1?Vo(t):t},qt=e=>Zs(z0(e)),z0=({sourceBox:e,targetBox:t,sourcePos:n,targetPos:s,targetOrientation:r,sourceOrientation:i})=>{let l=i,c=r,a={...Si[i]},d=Nt(n,a);const x={...Si[r]};let p=Nt(s,x);const m=Math.abs(d.x-p.x),f=Math.abs(d.y-p.y);m<2*Fe&&f<10&&(a.length-=m/2,x.length+=m/2,d=Nt(n,a),p=Nt(s,x));const h=[a],j=Ei({sourceStumpTip:d,sourceOrientation:i,sourceBox:e,targetStumpTip:p,targetOrientation:r,targetBox:t});j!=null&&(h.push(j),d=Nt(d,j),l=Rt(j),a=j);const y=Ei({sourceStumpTip:p,sourceOrientation:c,sourceBox:t,targetStumpTip:d,targetOrientation:l,targetBox:e});y!=null&&(p=Nt(p,y),c=At(y.direction,y.length));const S=()=>{y!=null&&(y.length*=-1,h.push(y)),x.length*=-1,h.push(x)};if(u.K$1.swap(l)===r){const L=u.g.construct(l),A=(p[L]-d[L])/2;h.push({direction:L,length:A});const $=u.g.swap(L);return h.push({direction:$,length:p[$]-d[$]}),h.push({direction:L,length:A}),S(),h}const b=p[a.direction]-d[a.direction];let E=u.g.swap(a.direction);const R=d[E]-p[E];let M;At(a.direction,b)===l&&At(E,R)===c?M={direction:a.direction,length:b}:(M={direction:E,length:p[E]-d[E]},E=u.g.swap(E)),h.push(M);const _={direction:E,length:p[E]-d[E]};return h.push(_),S(),h},V0=e=>Zs(F0(e)),F0=({segments:e,index:t,magnitude:n})=>{const s=[...e],r=s[t],i=u.g.swap(r.direction),l=Rt(r);if(t===0){s.unshift({direction:i,length:n});const c=Dt(l,Fe);s.unshift({direction:r.direction,length:c}),t+=2,s[t]={...s[t],length:s[t].length-c}}else s[t-1]={direction:s[t-1].direction,length:s[t-1].length+n};if(t===s.length-1){s.push({direction:i,length:-n});const c=Dt(l,Fe);s.push({direction:r.direction,length:c}),s[t]={...s[t],length:s[t].length-c}}else s[t+1]={direction:s[t+1].direction,length:s[t+1].length-n};return s},H0=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n],n))return n;return-1},Z0=(e,t,n=!1,...s)=>{const r=(i,l)=>!s.includes(l)&&t(i,l);return n?H0(e,r):e.findIndex(r)},K0=({delta:e,segments:t})=>Zs(Qc(e,t,!1)),W0=({delta:e,segments:t})=>Zs(Qc(e,t,!0)),Qc=(e,t,n)=>{let s=[...t];return e.x!==0&&(s=Ci("x",e,s,n)),e.y!==0&&(s=Ci("y",e,s,n)),s},Ri=(e,t,n)=>{if(t.direction!==e)return!1;const s={...t,length:t.length-n[e]},r=Rt(t),i=Rt(s),l=Math.abs(s.length),c=Math.abs(t.length);return(l>c||l>Fe)&&r===i},Ci=(e,t,n,s)=>{const r=u.g.swap(e),i=s?n.length-1:0,l=n[i];if(Ri(e,l,t)){const p=n[n.length-1];return p.direction===e&&Math.abs(l.length)<Fe?(n[n.length-1]={...p,length:p.length-t[e]},n):(n[i]={...l,length:l.length-t[e]},n)}const c=s?0:n.length-1,d=Z0(n,p=>p.direction===e,s,i);if(d===c){const p=n[c];return Ri(e,p,t)?(n[c]={...p,length:p.length-t[e]},n):(l.direction===e&&Math.abs(l.length)>p.length?n[i]={...l,length:l.length-t[e]}:n[c]={...p,length:p.length-t[e]},n)}if(d===-1)return n.length===1?n[0].direction===e?[{direction:e,length:n[0].length-t[e]}]:[{direction:r,length:n[0].length/2},{direction:e,length:-t[e]},{direction:r,length:n[0].length/2}]:l.direction===e?(n[i]={...l,length:l.length-t[e]},n):[{direction:r,length:n[0].length},{direction:e,length:-t[e]},...n.slice(1)];const x=n[d];return n[d]={...x,length:x.length-t[e]},n},Y0=ce.object({position:u.K.xy,zoom:ce.number()}),ea=ce.object({color:u.od.crudeZ,variant:ce.string().optional(),segments:ce.array(zo)}),G0=ea.extend({key:ce.string(),source:ce.string(),target:ce.string(),segments:ce.array(zo),color:u.od.crudeZ,id:ce.string(),data:ce.object({segments:ce.array(zo),color:u.od.crudeZ,variant:ce.string().optional()}).optional(),selected:ce.boolean(),sourceHandle:ce.string().nullable().optional(),targetHandle:ce.string().nullable().optional()}),q0=ce.object({key:ce.string(),position:u.K.xy,selected:ce.boolean().optional(),zIndex:ce.number().optional(),type:ce.string().optional(),data:u.p.optional(),measured:ce.object({width:ce.number().optional(),height:ce.number().optional()}).optional()}),vr=(e,t)=>e.map(n=>({id:n.key,type:"custom",zIndex:n.zIndex,measured:{...n.measured},position:{...n.position},selected:n.selected,data:{},dragHandle:t})),kr=e=>e.map(({segments:t,color:n,variant:s,...r})=>({...r,id:r.key,data:{segments:t,color:n,variant:s}})),ta=e=>e.map(t=>({key:t.id,...t})),na=(e,t)=>e.map(n=>{var s,r,i;return n.data??(n.data={segments:[],color:t,variant:"pipe"}),{key:n.id,segments:((s=n.data)==null?void 0:s.segments)??[],selected:n.selected??!1,color:((r=n.data)==null?void 0:r.color)??t,variant:((i=n.data)==null?void 0:i.variant)??"pipe",...n}}),sa=e=>({...e.position,zoom:e.zoom}),oa=e=>({position:u.K.construct(e),zoom:e.zoom}),ra=(e,t)=>ta(t(vr(e))),cs=(e,t,n)=>na(t(kr(e)),n),X0=(e,t="x")=>{if(e.length===0)return[];const n=u.K$1.construct(t),s=u.K$1.swap(n);return e.sort((r,i)=>u.Pt.loc(r.box,n)-u.Pt.loc(i.box,n)),e.forEach((r,i)=>{if(i===0)return;const c=e[i-1].handles.find(f=>f.orientation===s),a=r.handles.find(f=>f.orientation===n);if(c==null||a==null)return;const d=c.absolutePosition,x=a.absolutePosition,p=u.K.set(u.K.translation(x,d),t,0),m=u.K.translate(u.Pt.topLeft(r.box),p);r.box=u.Pt.construct(m,u.Pt.dims(r.box))}),e};function $e(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=$e(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var U0={value:()=>{}};function Ks(){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 as(n)}function as(e){this._=e}function J0(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",r=n.indexOf(".");if(r>=0&&(s=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}as.prototype=Ks.prototype={constructor:as,on:function(e,t){var n=this._,s=J0(e+"",n),r,i=-1,l=s.length;if(arguments.length<2){for(;++i<l;)if((r=(e=s[i]).type)&&(r=Q0(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<l;)if(r=(e=s[i]).type)n[r]=wi(n[r],e.name,t);else if(t==null)for(r in n)n[r]=wi(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new as(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),s=0,r,i;s<r;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],s=0,r=i.length;s<r;++s)i[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)}};function Q0(e,t){for(var n=0,s=e.length,r;n<s;++n)if((r=e[n]).name===t)return r.value}function wi(e,t,n){for(var s=0,r=e.length;s<r;++s)if(e[s].name===t){e[s]=U0,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Fo="http://www.w3.org/1999/xhtml";const bi={svg:"http://www.w3.org/2000/svg",xhtml:Fo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ws(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),bi.hasOwnProperty(t)?{space:bi[t],local:e}:e}function ej(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Fo&&t.documentElement.namespaceURI===Fo?t.createElement(e):t.createElementNS(n,e)}}function tj(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ia(e){var t=Ws(e);return(t.local?tj:ej)(t)}function nj(){}function Mr(e){return e==null?nj:function(){return this.querySelector(e)}}function sj(e){typeof e!="function"&&(e=Mr(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=new Array(l),a,d,x=0;x<l;++x)(a=i[x])&&(d=e.call(a,a.__data__,x,i))&&("__data__"in a&&(d.__data__=a.__data__),c[x]=d);return new We(s,this._parents)}function oj(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function rj(){return[]}function la(e){return e==null?rj:function(){return this.querySelectorAll(e)}}function ij(e){return function(){return oj(e.apply(this,arguments))}}function lj(e){typeof e=="function"?e=ij(e):e=la(e);for(var t=this._groups,n=t.length,s=[],r=[],i=0;i<n;++i)for(var l=t[i],c=l.length,a,d=0;d<c;++d)(a=l[d])&&(s.push(e.call(a,a.__data__,d,l)),r.push(a));return new We(s,r)}function ca(e){return function(){return this.matches(e)}}function aa(e){return function(t){return t.matches(e)}}var cj=Array.prototype.find;function aj(e){return function(){return cj.call(this.children,e)}}function uj(){return this.firstElementChild}function dj(e){return this.select(e==null?uj:aj(typeof e=="function"?e:aa(e)))}var xj=Array.prototype.filter;function pj(){return Array.from(this.children)}function mj(e){return function(){return xj.call(this.children,e)}}function fj(e){return this.selectAll(e==null?pj:mj(typeof e=="function"?e:aa(e)))}function hj(e){typeof e!="function"&&(e=ca(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=[],a,d=0;d<l;++d)(a=i[d])&&e.call(a,a.__data__,d,i)&&c.push(a);return new We(s,this._parents)}function ua(e){return new Array(e.length)}function gj(){return new We(this._enter||this._groups.map(ua),this._parents)}function ws(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ws.prototype={constructor:ws,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 jj(e){return function(){return e}}function Ej(e,t,n,s,r,i){for(var l=0,c,a=t.length,d=i.length;l<d;++l)(c=t[l])?(c.__data__=i[l],s[l]=c):n[l]=new ws(e,i[l]);for(;l<a;++l)(c=t[l])&&(r[l]=c)}function yj(e,t,n,s,r,i,l){var c,a,d=new Map,x=t.length,p=i.length,m=new Array(x),f;for(c=0;c<x;++c)(a=t[c])&&(m[c]=f=l.call(a,a.__data__,c,t)+"",d.has(f)?r[c]=a:d.set(f,a));for(c=0;c<p;++c)f=l.call(e,i[c],c,i)+"",(a=d.get(f))?(s[c]=a,a.__data__=i[c],d.delete(f)):n[c]=new ws(e,i[c]);for(c=0;c<x;++c)(a=t[c])&&d.get(m[c])===a&&(r[c]=a)}function Sj(e){return e.__data__}function Rj(e,t){if(!arguments.length)return Array.from(this,Sj);var n=t?yj:Ej,s=this._parents,r=this._groups;typeof e!="function"&&(e=jj(e));for(var i=r.length,l=new Array(i),c=new Array(i),a=new Array(i),d=0;d<i;++d){var x=s[d],p=r[d],m=p.length,f=Cj(e.call(x,x&&x.__data__,d,s)),h=f.length,j=c[d]=new Array(h),y=l[d]=new Array(h),S=a[d]=new Array(m);n(x,p,j,y,S,f,t);for(var b=0,E=0,R,M;b<h;++b)if(R=j[b]){for(b>=E&&(E=b+1);!(M=y[E])&&++E<h;);R._next=M||null}}return l=new We(l,s),l._enter=c,l._exit=a,l}function Cj(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function wj(){return new We(this._exit||this._groups.map(ua),this._parents)}function bj(e,t,n){var s=this.enter(),r=this,i=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),s&&r?s.merge(r).order():r}function vj(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,r=n.length,i=s.length,l=Math.min(r,i),c=new Array(r),a=0;a<l;++a)for(var d=n[a],x=s[a],p=d.length,m=c[a]=new Array(p),f,h=0;h<p;++h)(f=d[h]||x[h])&&(m[h]=f);for(;a<r;++a)c[a]=n[a];return new We(c,this._parents)}function kj(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],r=s.length-1,i=s[r],l;--r>=0;)(l=s[r])&&(i&&l.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(l,i),i=l);return this}function Mj(e){e||(e=Pj);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var n=this._groups,s=n.length,r=new Array(s),i=0;i<s;++i){for(var l=n[i],c=l.length,a=r[i]=new Array(c),d,x=0;x<c;++x)(d=l[x])&&(a[x]=d);a.sort(t)}return new We(r,this._parents).order()}function Pj(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function _j(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Lj(){return Array.from(this)}function Nj(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,i=s.length;r<i;++r){var l=s[r];if(l)return l}return null}function Tj(){let e=0;for(const t of this)++e;return e}function Aj(){return!this.node()}function Ij(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var r=t[n],i=0,l=r.length,c;i<l;++i)(c=r[i])&&e.call(c,c.__data__,i,r);return this}function $j(e){return function(){this.removeAttribute(e)}}function Bj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Dj(e,t){return function(){this.setAttribute(e,t)}}function Oj(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function zj(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Vj(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 Fj(e,t){var n=Ws(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?Bj:$j:typeof t=="function"?n.local?Vj:zj:n.local?Oj:Dj)(n,t))}function da(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Hj(e){return function(){this.style.removeProperty(e)}}function Zj(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Kj(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function Wj(e,t,n){return arguments.length>1?this.each((t==null?Hj:typeof t=="function"?Kj:Zj)(e,t,n??"")):en(this.node(),e)}function en(e,t){return e.style.getPropertyValue(t)||da(e).getComputedStyle(e,null).getPropertyValue(t)}function Yj(e){return function(){delete this[e]}}function Gj(e,t){return function(){this[e]=t}}function qj(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Xj(e,t){return arguments.length>1?this.each((t==null?Yj:typeof t=="function"?qj:Gj)(e,t)):this.node()[e]}function xa(e){return e.trim().split(/^|\s+/)}function Pr(e){return e.classList||new pa(e)}function pa(e){this._node=e,this._names=xa(e.getAttribute("class")||"")}pa.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 ma(e,t){for(var n=Pr(e),s=-1,r=t.length;++s<r;)n.add(t[s])}function fa(e,t){for(var n=Pr(e),s=-1,r=t.length;++s<r;)n.remove(t[s])}function Uj(e){return function(){ma(this,e)}}function Jj(e){return function(){fa(this,e)}}function Qj(e,t){return function(){(t.apply(this,arguments)?ma:fa)(this,e)}}function e2(e,t){var n=xa(e+"");if(arguments.length<2){for(var s=Pr(this.node()),r=-1,i=n.length;++r<i;)if(!s.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Qj:t?Uj:Jj)(n,t))}function t2(){this.textContent=""}function n2(e){return function(){this.textContent=e}}function s2(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function o2(e){return arguments.length?this.each(e==null?t2:(typeof e=="function"?s2:n2)(e)):this.node().textContent}function r2(){this.innerHTML=""}function i2(e){return function(){this.innerHTML=e}}function l2(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function c2(e){return arguments.length?this.each(e==null?r2:(typeof e=="function"?l2:i2)(e)):this.node().innerHTML}function a2(){this.nextSibling&&this.parentNode.appendChild(this)}function u2(){return this.each(a2)}function d2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function x2(){return this.each(d2)}function p2(e){var t=typeof e=="function"?e:ia(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function m2(){return null}function f2(e,t){var n=typeof e=="function"?e:ia(e),s=t==null?m2:typeof t=="function"?t:Mr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function h2(){var e=this.parentNode;e&&e.removeChild(this)}function g2(){return this.each(h2)}function j2(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function E2(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function y2(e){return this.select(e?E2:j2)}function S2(e){return arguments.length?this.property("__data__",e):this.node().__data__}function R2(e){return function(t){e.call(this,t,this.__data__)}}function C2(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 w2(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++s]=i;++s?t.length=s:delete this.__on}}}function b2(e,t,n){return function(){var s=this.__on,r,i=R2(t);if(s){for(var l=0,c=s.length;l<c;++l)if((r=s[l]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},s?s.push(r):this.__on=[r]}}function v2(e,t,n){var s=C2(e+""),r,i=s.length,l;if(arguments.length<2){var c=this.node().__on;if(c){for(var a=0,d=c.length,x;a<d;++a)for(r=0,x=c[a];r<i;++r)if((l=s[r]).type===x.type&&l.name===x.name)return x.value}return}for(c=t?b2:w2,r=0;r<i;++r)this.each(c(s[r],t,n));return this}function ha(e,t,n){var s=da(e),r=s.CustomEvent;typeof r=="function"?r=new r(t,n):(r=s.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function k2(e,t){return function(){return ha(this,e,t)}}function M2(e,t){return function(){return ha(this,e,t.apply(this,arguments))}}function P2(e,t){return this.each((typeof t=="function"?M2:k2)(e,t))}function*_2(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,i=s.length,l;r<i;++r)(l=s[r])&&(yield l)}var ga=[null];function We(e,t){this._groups=e,this._parents=t}function Bn(){return new We([[document.documentElement]],ga)}function L2(){return this}We.prototype=Bn.prototype={constructor:We,select:sj,selectAll:lj,selectChild:dj,selectChildren:fj,filter:hj,data:Rj,enter:gj,exit:wj,join:bj,merge:vj,selection:L2,order:kj,sort:Mj,call:_j,nodes:Lj,node:Nj,size:Tj,empty:Aj,each:Ij,attr:Fj,style:Wj,property:Xj,classed:e2,text:o2,html:c2,raise:u2,lower:x2,append:p2,insert:f2,remove:g2,clone:y2,datum:S2,on:v2,dispatch:P2,[Symbol.iterator]:_2};function Ke(e){return typeof e=="string"?new We([[document.querySelector(e)]],[document.documentElement]):new We([[e]],ga)}function N2(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ue(e,t){if(e=N2(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 r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const T2={passive:!1},kn={capture:!0,passive:!1};function Eo(e){e.stopImmediatePropagation()}function Jt(e){e.preventDefault(),e.stopImmediatePropagation()}function ja(e){var t=e.document.documentElement,n=Ke(e).on("dragstart.drag",Jt,kn);"onselectstart"in t?n.on("selectstart.drag",Jt,kn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ea(e,t){var n=e.document.documentElement,s=Ke(e).on("dragstart.drag",null);t&&(s.on("click.drag",Jt,kn),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 Xn=e=>()=>e;function Ho(e,{sourceEvent:t,subject:n,target:s,identifier:r,active:i,x:l,y:c,dx:a,dy:d,dispatch:x}){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:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:x}})}Ho.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function A2(e){return!e.ctrlKey&&!e.button}function I2(){return this.parentNode}function $2(e,t){return t??{x:e.x,y:e.y}}function B2(){return navigator.maxTouchPoints||"ontouchstart"in this}function ya(){var e=A2,t=I2,n=$2,s=B2,r={},i=Ks("start","drag","end"),l=0,c,a,d,x,p=0;function m(R){R.on("mousedown.drag",f).filter(s).on("touchstart.drag",y).on("touchmove.drag",S,T2).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(R,M){if(!(x||!e.call(this,R,M))){var _=E(this,t.call(this,R,M),R,M,"mouse");_&&(Ke(R.view).on("mousemove.drag",h,kn).on("mouseup.drag",j,kn),ja(R.view),Eo(R),d=!1,c=R.clientX,a=R.clientY,_("start",R))}}function h(R){if(Jt(R),!d){var M=R.clientX-c,_=R.clientY-a;d=M*M+_*_>p}r.mouse("drag",R)}function j(R){Ke(R.view).on("mousemove.drag mouseup.drag",null),Ea(R.view,d),Jt(R),r.mouse("end",R)}function y(R,M){if(e.call(this,R,M)){var _=R.changedTouches,L=t.call(this,R,M),A=_.length,$,O;for($=0;$<A;++$)(O=E(this,L,R,M,_[$].identifier,_[$]))&&(Eo(R),O("start",R,_[$]))}}function S(R){var M=R.changedTouches,_=M.length,L,A;for(L=0;L<_;++L)(A=r[M[L].identifier])&&(Jt(R),A("drag",R,M[L]))}function b(R){var M=R.changedTouches,_=M.length,L,A;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),L=0;L<_;++L)(A=r[M[L].identifier])&&(Eo(R),A("end",R,M[L]))}function E(R,M,_,L,A,$){var O=i.copy(),V=Ue($||_,M),z,k,C;if((C=n.call(R,new Ho("beforestart",{sourceEvent:_,target:m,identifier:A,active:l,x:V[0],y:V[1],dx:0,dy:0,dispatch:O}),L))!=null)return z=C.x-V[0]||0,k=C.y-V[1]||0,function P(v,N,D){var I=V,F;switch(v){case"start":r[A]=P,F=l++;break;case"end":delete r[A],--l;case"drag":V=Ue(D||N,M),F=l;break}O.call(v,R,new Ho(v,{sourceEvent:N,subject:C,target:m,identifier:A,active:F,x:V[0]+z,y:V[1]+k,dx:V[0]-I[0],dy:V[1]-I[1],dispatch:O}),L)}}return m.filter=function(R){return arguments.length?(e=typeof R=="function"?R:Xn(!!R),m):e},m.container=function(R){return arguments.length?(t=typeof R=="function"?R:Xn(R),m):t},m.subject=function(R){return arguments.length?(n=typeof R=="function"?R:Xn(R),m):n},m.touchable=function(R){return arguments.length?(s=typeof R=="function"?R:Xn(!!R),m):s},m.on=function(){var R=i.on.apply(i,arguments);return R===i?m:R},m.clickDistance=function(R){return arguments.length?(p=(R=+R)*R,m):Math.sqrt(p)},m}var tn=0,En=0,fn=0,Sa=1e3,bs,yn,vs=0,Ot=0,Ys=0,Mn=typeof performance=="object"&&performance.now?performance:Date,Ra=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _r(){return Ot||(Ra(D2),Ot=Mn.now()+Ys)}function D2(){Ot=0}function ks(){this._call=this._time=this._next=null}ks.prototype=Ca.prototype={constructor:ks,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?_r():+n)+(t==null?0:+t),!this._next&&yn!==this&&(yn?yn._next=this:bs=this,yn=this),this._call=e,this._time=n,Zo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Zo())}};function Ca(e,t,n){var s=new ks;return s.restart(e,t,n),s}function O2(){_r(),++tn;for(var e=bs,t;e;)(t=Ot-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tn}function vi(){Ot=(vs=Mn.now())+Ys,tn=En=0;try{O2()}finally{tn=0,V2(),Ot=0}}function z2(){var e=Mn.now(),t=e-vs;t>Sa&&(Ys-=t,vs=e)}function V2(){for(var e,t=bs,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:bs=n);yn=e,Zo(s)}function Zo(e){if(!tn){En&&(En=clearTimeout(En));var t=e-Ot;t>24?(e<1/0&&(En=setTimeout(vi,e-Mn.now()-Ys)),fn&&(fn=clearInterval(fn))):(fn||(vs=Mn.now(),fn=setInterval(z2,Sa)),tn=1,Ra(vi))}}function ki(e,t,n){var s=new ks;return t=t==null?0:+t,s.restart(r=>{s.stop(),e(r+t)},t,n),s}var F2=Ks("start","end","cancel","interrupt"),H2=[],wa=0,Mi=1,Ko=2,us=3,Pi=4,Wo=5,ds=6;function Gs(e,t,n,s,r,i){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;Z2(e,n,{name:t,index:s,group:r,on:F2,tween:H2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:wa})}function Lr(e,t){var n=et(e,t);if(n.state>wa)throw new Error("too late; already scheduled");return n}function it(e,t){var n=et(e,t);if(n.state>us)throw new Error("too late; already running");return n}function et(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Z2(e,t,n){var s=e.__transition,r;s[t]=n,n.timer=Ca(i,0,n.time);function i(d){n.state=Mi,n.timer.restart(l,n.delay,n.time),n.delay<=d&&l(d-n.delay)}function l(d){var x,p,m,f;if(n.state!==Mi)return a();for(x in s)if(f=s[x],f.name===n.name){if(f.state===us)return ki(l);f.state===Pi?(f.state=ds,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete s[x]):+x<t&&(f.state=ds,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete s[x])}if(ki(function(){n.state===us&&(n.state=Pi,n.timer.restart(c,n.delay,n.time),c(d))}),n.state=Ko,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ko){for(n.state=us,r=new Array(m=n.tween.length),x=0,p=-1;x<m;++x)(f=n.tween[x].value.call(e,e.__data__,n.index,n.group))&&(r[++p]=f);r.length=p+1}}function c(d){for(var x=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(a),n.state=Wo,1),p=-1,m=r.length;++p<m;)r[p].call(e,x);n.state===Wo&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){n.state=ds,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function xs(e,t){var n=e.__transition,s,r,i=!0,l;if(n){t=t==null?null:t+"";for(l in n){if((s=n[l]).name!==t){i=!1;continue}r=s.state>Ko&&s.state<Wo,s.state=ds,s.timer.stop(),s.on.call(r?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[l]}i&&delete e.__transition}}function K2(e){return this.each(function(){xs(this,e)})}function W2(e,t){var n,s;return function(){var r=it(this,e),i=r.tween;if(i!==n){s=n=i;for(var l=0,c=s.length;l<c;++l)if(s[l].name===t){s=s.slice(),s.splice(l,1);break}}r.tween=s}}function Y2(e,t,n){var s,r;if(typeof n!="function")throw new Error;return function(){var i=it(this,e),l=i.tween;if(l!==s){r=(s=l).slice();for(var c={name:t,value:n},a=0,d=r.length;a<d;++a)if(r[a].name===t){r[a]=c;break}a===d&&r.push(c)}i.tween=r}}function G2(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=et(this.node(),n).tween,r=0,i=s.length,l;r<i;++r)if((l=s[r]).name===e)return l.value;return null}return this.each((t==null?W2:Y2)(n,e,t))}function Nr(e,t,n){var s=e._id;return e.each(function(){var r=it(this,s);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return et(r,s).value[t]}}function ba(e,t){var n;return(typeof t=="number"?B.interpolateNumber:t instanceof B.color?B.interpolateRgb:(n=B.color(t))?(t=n,B.interpolateRgb):B.interpolateString)(e,t)}function q2(e){return function(){this.removeAttribute(e)}}function X2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function U2(e,t,n){var s,r=n+"",i;return function(){var l=this.getAttribute(e);return l===r?null:l===s?i:i=t(s=l,n)}}function J2(e,t,n){var s,r=n+"",i;return function(){var l=this.getAttributeNS(e.space,e.local);return l===r?null:l===s?i:i=t(s=l,n)}}function Q2(e,t,n){var s,r,i;return function(){var l,c=n(this),a;return c==null?void this.removeAttribute(e):(l=this.getAttribute(e),a=c+"",l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c)))}}function e3(e,t,n){var s,r,i;return function(){var l,c=n(this),a;return c==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),a=c+"",l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c)))}}function t3(e,t){var n=Ws(e),s=n==="transform"?_h:ba;return this.attrTween(e,typeof t=="function"?(n.local?e3:Q2)(n,s,Nr(this,"attr."+e,t)):t==null?(n.local?X2:q2)(n):(n.local?J2:U2)(n,s,t))}function n3(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function s3(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function o3(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&s3(e,i)),n}return r._value=t,r}function r3(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&n3(e,i)),n}return r._value=t,r}function i3(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=Ws(e);return this.tween(n,(s.local?o3:r3)(s,t))}function l3(e,t){return function(){Lr(this,e).delay=+t.apply(this,arguments)}}function c3(e,t){return t=+t,function(){Lr(this,e).delay=t}}function a3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?l3:c3)(t,e)):et(this.node(),t).delay}function u3(e,t){return function(){it(this,e).duration=+t.apply(this,arguments)}}function d3(e,t){return t=+t,function(){it(this,e).duration=t}}function x3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?u3:d3)(t,e)):et(this.node(),t).duration}function p3(e,t){if(typeof t!="function")throw new Error;return function(){it(this,e).ease=t}}function m3(e){var t=this._id;return arguments.length?this.each(p3(t,e)):et(this.node(),t).ease}function f3(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;it(this,e).ease=n}}function h3(e){if(typeof e!="function")throw new Error;return this.each(f3(this._id,e))}function g3(e){typeof e!="function"&&(e=ca(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],l=i.length,c=s[r]=[],a,d=0;d<l;++d)(a=i[d])&&e.call(a,a.__data__,d,i)&&c.push(a);return new xt(s,this._parents,this._name,this._id)}function j3(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,r=n.length,i=Math.min(s,r),l=new Array(s),c=0;c<i;++c)for(var a=t[c],d=n[c],x=a.length,p=l[c]=new Array(x),m,f=0;f<x;++f)(m=a[f]||d[f])&&(p[f]=m);for(;c<s;++c)l[c]=t[c];return new xt(l,this._parents,this._name,this._id)}function E3(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 y3(e,t,n){var s,r,i=E3(t)?Lr:it;return function(){var l=i(this,e),c=l.on;c!==s&&(r=(s=c).copy()).on(t,n),l.on=r}}function S3(e,t){var n=this._id;return arguments.length<2?et(this.node(),n).on.on(e):this.each(y3(n,e,t))}function R3(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function C3(){return this.on("end.remove",R3(this._id))}function w3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Mr(e));for(var s=this._groups,r=s.length,i=new Array(r),l=0;l<r;++l)for(var c=s[l],a=c.length,d=i[l]=new Array(a),x,p,m=0;m<a;++m)(x=c[m])&&(p=e.call(x,x.__data__,m,c))&&("__data__"in x&&(p.__data__=x.__data__),d[m]=p,Gs(d[m],t,n,m,d,et(x,n)));return new xt(i,this._parents,t,n)}function b3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=la(e));for(var s=this._groups,r=s.length,i=[],l=[],c=0;c<r;++c)for(var a=s[c],d=a.length,x,p=0;p<d;++p)if(x=a[p]){for(var m=e.call(x,x.__data__,p,a),f,h=et(x,n),j=0,y=m.length;j<y;++j)(f=m[j])&&Gs(f,t,n,j,m,h);i.push(m),l.push(x)}return new xt(i,l,t,n)}var v3=Bn.prototype.constructor;function k3(){return new v3(this._groups,this._parents)}function M3(e,t){var n,s,r;return function(){var i=en(this,e),l=(this.style.removeProperty(e),en(this,e));return i===l?null:i===n&&l===s?r:r=t(n=i,s=l)}}function va(e){return function(){this.style.removeProperty(e)}}function P3(e,t,n){var s,r=n+"",i;return function(){var l=en(this,e);return l===r?null:l===s?i:i=t(s=l,n)}}function _3(e,t,n){var s,r,i;return function(){var l=en(this,e),c=n(this),a=c+"";return c==null&&(a=c=(this.style.removeProperty(e),en(this,e))),l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c))}}function L3(e,t){var n,s,r,i="style."+t,l="end."+i,c;return function(){var a=it(this,e),d=a.on,x=a.value[i]==null?c||(c=va(t)):void 0;(d!==n||r!==x)&&(s=(n=d).copy()).on(l,r=x),a.on=s}}function N3(e,t,n){var s=(e+="")=="transform"?Ph:ba;return t==null?this.styleTween(e,M3(e,s)).on("end.style."+e,va(e)):typeof t=="function"?this.styleTween(e,_3(e,s,Nr(this,"style."+e,t))).each(L3(this._id,e)):this.styleTween(e,P3(e,s,t),n).on("end.style."+e,null)}function T3(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function A3(e,t,n){var s,r;function i(){var l=t.apply(this,arguments);return l!==r&&(s=(r=l)&&T3(e,l,n)),s}return i._value=t,i}function I3(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,A3(e,t,n??""))}function $3(e){return function(){this.textContent=e}}function B3(e){return function(){var t=e(this);this.textContent=t??""}}function D3(e){return this.tween("text",typeof e=="function"?B3(Nr(this,"text",e)):$3(e==null?"":e+""))}function O3(e){return function(t){this.textContent=e.call(this,t)}}function z3(e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&O3(r)),t}return s._value=e,s}function V3(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,z3(e))}function F3(){for(var e=this._name,t=this._id,n=ka(),s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],c=l.length,a,d=0;d<c;++d)if(a=l[d]){var x=et(a,t);Gs(a,e,n,d,l,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new xt(s,this._parents,e,n)}function H3(){var e,t,n=this,s=n._id,r=n.size();return new Promise(function(i,l){var c={value:l},a={value:function(){--r===0&&i()}};n.each(function(){var d=it(this,s),x=d.on;x!==e&&(t=(e=x).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(a)),d.on=t}),r===0&&i()})}var Z3=0;function xt(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function ka(){return++Z3}var ct=Bn.prototype;xt.prototype={constructor:xt,select:w3,selectAll:b3,selectChild:ct.selectChild,selectChildren:ct.selectChildren,filter:g3,merge:j3,selection:k3,transition:F3,call:ct.call,nodes:ct.nodes,node:ct.node,size:ct.size,empty:ct.empty,each:ct.each,on:S3,attr:t3,attrTween:i3,style:N3,styleTween:I3,text:D3,textTween:V3,remove:C3,tween:G2,delay:a3,duration:x3,ease:m3,easeVarying:h3,end:H3,[Symbol.iterator]:ct[Symbol.iterator]};function K3(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var W3={time:null,delay:0,duration:250,ease:K3};function Y3(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 G3(e){var t,n;e instanceof xt?(t=e._id,e=e._name):(t=ka(),(n=W3).time=_r(),e=e==null?null:e+"");for(var s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],c=l.length,a,d=0;d<c;++d)(a=l[d])&&Gs(a,e,t,d,l,n||Y3(a,t));return new xt(s,this._parents,e,t)}Bn.prototype.interrupt=K2;Bn.prototype.transition=G3;const Un=e=>()=>e;function q3(e,{sourceEvent:t,target:n,transform:s,dispatch:r}){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:r}})}function ut(e,t,n){this.k=e,this.x=t,this.y=n}ut.prototype={constructor:ut,scale:function(e){return e===1?this:new ut(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ut(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 qs=new ut(1,0,0);Ma.prototype=ut.prototype;function Ma(e){for(;!e.__zoom;)if(!(e=e.parentNode))return qs;return e.__zoom}function yo(e){e.stopImmediatePropagation()}function hn(e){e.preventDefault(),e.stopImmediatePropagation()}function X3(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function U3(){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 _i(){return this.__zoom||qs}function J3(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Q3(){return navigator.maxTouchPoints||"ontouchstart"in this}function e5(e,t,n){var s=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],l=e.invertY(t[1][1])-n[1][1];return e.translate(r>s?(s+r)/2:Math.min(0,s)||Math.max(0,r),l>i?(i+l)/2:Math.min(0,i)||Math.max(0,l))}function Pa(){var e=X3,t=U3,n=e5,s=J3,r=Q3,i=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,a=ls,d=Ks("start","zoom","end"),x,p,m,f=500,h=150,j=0,y=10;function S(C){C.property("__zoom",_i).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",V).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",k).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(C,P,v,N){var D=C.selection?C.selection():C;D.property("__zoom",_i),C!==D?M(C,P,v,N):D.interrupt().each(function(){_(this,arguments).event(N).start().zoom(null,typeof P=="function"?P.apply(this,arguments):P).end()})},S.scaleBy=function(C,P,v,N){S.scaleTo(C,function(){var D=this.__zoom.k,I=typeof P=="function"?P.apply(this,arguments):P;return D*I},v,N)},S.scaleTo=function(C,P,v,N){S.transform(C,function(){var D=t.apply(this,arguments),I=this.__zoom,F=v==null?R(D):typeof v=="function"?v.apply(this,arguments):v,H=I.invert(F),Z=typeof P=="function"?P.apply(this,arguments):P;return n(E(b(I,Z),F,H),D,l)},v,N)},S.translateBy=function(C,P,v,N){S.transform(C,function(){return n(this.__zoom.translate(typeof P=="function"?P.apply(this,arguments):P,typeof v=="function"?v.apply(this,arguments):v),t.apply(this,arguments),l)},null,N)},S.translateTo=function(C,P,v,N,D){S.transform(C,function(){var I=t.apply(this,arguments),F=this.__zoom,H=N==null?R(I):typeof N=="function"?N.apply(this,arguments):N;return n(qs.translate(H[0],H[1]).scale(F.k).translate(typeof P=="function"?-P.apply(this,arguments):-P,typeof v=="function"?-v.apply(this,arguments):-v),I,l)},N,D)};function b(C,P){return P=Math.max(i[0],Math.min(i[1],P)),P===C.k?C:new ut(P,C.x,C.y)}function E(C,P,v){var N=P[0]-v[0]*C.k,D=P[1]-v[1]*C.k;return N===C.x&&D===C.y?C:new ut(C.k,N,D)}function R(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function M(C,P,v,N){C.on("start.zoom",function(){_(this,arguments).event(N).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(N).end()}).tween("zoom",function(){var D=this,I=arguments,F=_(D,I).event(N),H=t.apply(D,I),Z=v==null?R(H):typeof v=="function"?v.apply(D,I):v,ee=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),te=D.__zoom,se=typeof P=="function"?P.apply(D,I):P,oe=a(te.invert(Z).concat(ee/te.k),se.invert(Z).concat(ee/se.k));return function(xe){if(xe===1)xe=se;else{var J=oe(xe),ae=ee/J[2];xe=new ut(ae,Z[0]-J[0]*ae,Z[1]-J[1]*ae)}F.zoom(null,xe)}})}function _(C,P,v){return!v&&C.__zooming||new L(C,P)}function L(C,P){this.that=C,this.args=P,this.active=0,this.sourceEvent=null,this.extent=t.apply(C,P),this.taps=0}L.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,P){return this.mouse&&C!=="mouse"&&(this.mouse[1]=P.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=P.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=P.invert(this.touch1[0])),this.that.__zoom=P,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var P=Ke(this.that).datum();d.call(C,this.that,new q3(C,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:d}),P)}};function A(C,...P){if(!e.apply(this,arguments))return;var v=_(this,P).event(C),N=this.__zoom,D=Math.max(i[0],Math.min(i[1],N.k*Math.pow(2,s.apply(this,arguments)))),I=Ue(C);if(v.wheel)(v.mouse[0][0]!==I[0]||v.mouse[0][1]!==I[1])&&(v.mouse[1]=N.invert(v.mouse[0]=I)),clearTimeout(v.wheel);else{if(N.k===D)return;v.mouse=[I,N.invert(I)],xs(this),v.start()}hn(C),v.wheel=setTimeout(F,h),v.zoom("mouse",n(E(b(N,D),v.mouse[0],v.mouse[1]),v.extent,l));function F(){v.wheel=null,v.end()}}function $(C,...P){if(m||!e.apply(this,arguments))return;var v=C.currentTarget,N=_(this,P,!0).event(C),D=Ke(C.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",ee,!0),I=Ue(C,v),F=C.clientX,H=C.clientY;ja(C.view),yo(C),N.mouse=[I,this.__zoom.invert(I)],xs(this),N.start();function Z(te){if(hn(te),!N.moved){var se=te.clientX-F,oe=te.clientY-H;N.moved=se*se+oe*oe>j}N.event(te).zoom("mouse",n(E(N.that.__zoom,N.mouse[0]=Ue(te,v),N.mouse[1]),N.extent,l))}function ee(te){D.on("mousemove.zoom mouseup.zoom",null),Ea(te.view,N.moved),hn(te),N.event(te).end()}}function O(C,...P){if(e.apply(this,arguments)){var v=this.__zoom,N=Ue(C.changedTouches?C.changedTouches[0]:C,this),D=v.invert(N),I=v.k*(C.shiftKey?.5:2),F=n(E(b(v,I),N,D),t.apply(this,P),l);hn(C),c>0?Ke(this).transition().duration(c).call(M,F,N,C):Ke(this).call(S.transform,F,N,C)}}function V(C,...P){if(e.apply(this,arguments)){var v=C.touches,N=v.length,D=_(this,P,C.changedTouches.length===N).event(C),I,F,H,Z;for(yo(C),F=0;F<N;++F)H=v[F],Z=Ue(H,this),Z=[Z,this.__zoom.invert(Z),H.identifier],D.touch0?!D.touch1&&D.touch0[2]!==Z[2]&&(D.touch1=Z,D.taps=0):(D.touch0=Z,I=!0,D.taps=1+!!x);x&&(x=clearTimeout(x)),I&&(D.taps<2&&(p=Z[0],x=setTimeout(function(){x=null},f)),xs(this),D.start())}}function z(C,...P){if(this.__zooming){var v=_(this,P).event(C),N=C.changedTouches,D=N.length,I,F,H,Z;for(hn(C),I=0;I<D;++I)F=N[I],H=Ue(F,this),v.touch0&&v.touch0[2]===F.identifier?v.touch0[0]=H:v.touch1&&v.touch1[2]===F.identifier&&(v.touch1[0]=H);if(F=v.that.__zoom,v.touch1){var ee=v.touch0[0],te=v.touch0[1],se=v.touch1[0],oe=v.touch1[1],xe=(xe=se[0]-ee[0])*xe+(xe=se[1]-ee[1])*xe,J=(J=oe[0]-te[0])*J+(J=oe[1]-te[1])*J;F=b(F,Math.sqrt(xe/J)),H=[(ee[0]+se[0])/2,(ee[1]+se[1])/2],Z=[(te[0]+oe[0])/2,(te[1]+oe[1])/2]}else if(v.touch0)H=v.touch0[0],Z=v.touch0[1];else return;v.zoom("touch",n(E(F,H,Z),v.extent,l))}}function k(C,...P){if(this.__zooming){var v=_(this,P).event(C),N=C.changedTouches,D=N.length,I,F;for(yo(C),m&&clearTimeout(m),m=setTimeout(function(){m=null},f),I=0;I<D;++I)F=N[I],v.touch0&&v.touch0[2]===F.identifier?delete v.touch0:v.touch1&&v.touch1[2]===F.identifier&&delete v.touch1;if(v.touch1&&!v.touch0&&(v.touch0=v.touch1,delete v.touch1),v.touch0)v.touch0[1]=this.__zoom.invert(v.touch0[0]);else if(v.end(),v.taps===2&&(F=Ue(F,this),Math.hypot(p[0]-F[0],p[1]-F[1])<y)){var H=Ke(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return S.wheelDelta=function(C){return arguments.length?(s=typeof C=="function"?C:Un(+C),S):s},S.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Un(!!C),S):e},S.touchable=function(C){return arguments.length?(r=typeof C=="function"?C:Un(!!C),S):r},S.extent=function(C){return arguments.length?(t=typeof C=="function"?C:Un([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),S):t},S.scaleExtent=function(C){return arguments.length?(i[0]=+C[0],i[1]=+C[1],S):[i[0],i[1]]},S.translateExtent=function(C){return arguments.length?(l[0][0]=+C[0][0],l[1][0]=+C[1][0],l[0][1]=+C[0][1],l[1][1]=+C[1][1],S):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},S.constrain=function(C){return arguments.length?(n=C,S):n},S.duration=function(C){return arguments.length?(c=+C,S):c},S.interpolate=function(C){return arguments.length?(a=C,S):a},S.on=function(){var C=d.on.apply(d,arguments);return C===d?S:C},S.clickDistance=function(C){return arguments.length?(j=(C=+C)*C,S):Math.sqrt(j)},S.tapDistance=function(C){return arguments.length?(y=+C,S):y},S}const Oe={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:s}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Pn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],_a=["Enter"," ","Escape"],La={"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 zt;(function(e){e.Strict="strict",e.Loose="loose"})(zt||(zt={}));var It;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(It||(It={}));var nn;(function(e){e.Partial="partial",e.Full="full"})(nn||(nn={}));const Na={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var St;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(St||(St={}));var Ms;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ms||(Ms={}));var U;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(U||(U={}));const Li={[U.Left]:U.Right,[U.Right]:U.Left,[U.Top]:U.Bottom,[U.Bottom]:U.Top};function Ta(e){return e===null?null:e?"valid":"invalid"}const Aa=e=>"id"in e&&"source"in e&&"target"in e,t5=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Tr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Dn=(e,t=[0,0])=>{const{width:n,height:s}=ht(e),r=e.origin??t,i=n*r[0],l=s*r[1];return{x:e.position.x-i,y:e.position.y-l}},n5=(e,t={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!t.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,r)=>{const i=typeof r=="string";let l=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(l=i?t.nodeLookup.get(r):Tr(r)?r:t.nodeLookup.get(r.id));const c=l?Ps(l,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Xs(s,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Us(n)},On=(e,t={})=>{if(e.size===0)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach(s=>{if(t.filter===void 0||t.filter(s)){const r=Ps(s);n=Xs(n,r)}}),Us(n)},Ar=(e,t,[n,s,r]=[0,0,1],i=!1,l=!1)=>{const c={...zn(t,[n,s,r]),width:t.width/r,height:t.height/r},a=[];for(const d of e.values()){const{measured:x,selectable:p=!0,hidden:m=!1}=d;if(l&&!p||m)continue;const f=x.width??d.width??d.initialWidth??null,h=x.height??d.height??d.initialHeight??null,j=_n(c,on(d)),y=(f??0)*(h??0),S=i&&j>0;(!d.internals.handleBounds||S||j>=y||d.dragging)&&a.push(d)}return a},s5=(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 o5(e,t){const n=new Map,s=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!s||s.has(r.id))&&n.set(r.id,r)}),n}async function r5({nodes:e,width:t,height:n,panZoom:s,minZoom:r,maxZoom:i},l){if(e.size===0)return Promise.resolve(!0);const c=o5(e,l),a=On(c),d=Ir(a,t,n,(l==null?void 0:l.minZoom)??r,(l==null?void 0:l.maxZoom)??i,(l==null?void 0:l.padding)??.1);return await s.setViewport(d,{duration:l==null?void 0:l.duration,ease:l==null?void 0:l.ease,interpolate:l==null?void 0:l.interpolate}),Promise.resolve(!0)}function Ia({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:r,onError:i}){const l=n.get(e),c=l.parentId?n.get(l.parentId):void 0,{x:a,y:d}=c?c.internals.positionAbsolute:{x:0,y:0},x=l.origin??s;let p=r;if(l.extent==="parent"&&!l.expandParent)if(!c)i==null||i("005",Oe.error005());else{const f=c.measured.width,h=c.measured.height;f&&h&&(p=[[a,d],[a+f,d+h]])}else c&&rn(l.extent)&&(p=[[l.extent[0][0]+a,l.extent[0][1]+d],[l.extent[1][0]+a,l.extent[1][1]+d]]);const m=rn(p)?Vt(t,p,l.measured):t;return(l.measured.width===void 0||l.measured.height===void 0)&&(i==null||i("015",Oe.error015())),{position:{x:m.x-a+(l.measured.width??0)*x[0],y:m.y-d+(l.measured.height??0)*x[1]},positionAbsolute:m}}async function i5({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:r}){const i=new Set(e.map(m=>m.id)),l=[];for(const m of n){if(m.deletable===!1)continue;const f=i.has(m.id),h=!f&&m.parentId&&l.find(j=>j.id===m.parentId);(f||h)&&l.push(m)}const c=new Set(t.map(m=>m.id)),a=s.filter(m=>m.deletable!==!1),x=s5(l,a);for(const m of a)c.has(m.id)&&!x.find(h=>h.id===m.id)&&x.push(m);if(!r)return{edges:x,nodes:l};const p=await r({nodes:l,edges:x});return typeof p=="boolean"?p?{edges:x,nodes:l}:{edges:[],nodes:[]}:p}const sn=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Vt=(e={x:0,y:0},t,n)=>({x:sn(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:sn(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function $a(e,t,n){const{width:s,height:r}=ht(n),{x:i,y:l}=n.internals.positionAbsolute;return Vt(e,[[i,l],[i+s,l+r]],t)}const Ni=(e,t,n)=>e<t?sn(Math.abs(e-t),1,t)/t:e>n?-sn(Math.abs(e-n),1,t)/t:0,Ba=(e,t,n=15,s=40)=>{const r=Ni(e.x,s,t.width-s)*n,i=Ni(e.y,s,t.height-s)*n;return[r,i]},Xs=(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)}),Yo=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),Us=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),on=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=Tr(e)?e.internals.positionAbsolute:Dn(e,t);return{x:n,y:s,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Ps=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=Tr(e)?e.internals.positionAbsolute:Dn(e,t);return{x:n,y:s,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:s+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Da=(e,t)=>Us(Xs(Yo(e),Yo(t))),_n=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},Ti=e=>Je(e.width)&&Je(e.height)&&Je(e.x)&&Je(e.y),Je=e=>!isNaN(e)&&isFinite(e),_s=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},Js=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),zn=({x:e,y:t},[n,s,r],i=!1,l=[1,1])=>{const c={x:(e-n)/r,y:(t-s)/r};return i?Js(c,l):c},Ls=({x:e,y:t},[n,s,r])=>({x:e*r+n,y:t*r+s});function Gt(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function l5(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=Gt(e,n),r=Gt(e,t);return{top:s,right:r,bottom:s,left:r,x:r*2,y:s*2}}if(typeof e=="object"){const s=Gt(e.top??e.y??0,n),r=Gt(e.bottom??e.y??0,n),i=Gt(e.left??e.x??0,t),l=Gt(e.right??e.x??0,t);return{top:s,right:l,bottom:r,left:i,x:i+l,y:s+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function c5(e,t,n,s,r,i){const{x:l,y:c}=Ls(e,[t,n,s]),{x:a,y:d}=Ls({x:e.x+e.width,y:e.y+e.height},[t,n,s]),x=r-a,p=i-d;return{left:Math.floor(l),top:Math.floor(c),right:Math.floor(x),bottom:Math.floor(p)}}const Ir=(e,t,n,s,r,i)=>{const l=l5(i,t,n),c=(t-l.x)/e.width,a=(n-l.y)/e.height,d=Math.min(c,a),x=sn(d,s,r),p=e.x+e.width/2,m=e.y+e.height/2,f=t/2-p*x,h=n/2-m*x,j=c5(e,f,h,x,t,n),y={left:Math.min(j.left-l.left,0),top:Math.min(j.top-l.top,0),right:Math.min(j.right-l.right,0),bottom:Math.min(j.bottom-l.bottom,0)};return{x:f-y.left+y.right,y:h-y.top+y.bottom,zoom:x}},Ns=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function rn(e){return e!==void 0&&e!=="parent"}function ht(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Oa(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function za(e,t={width:0,height:0},n,s,r){const i={...e},l=s.get(n);if(l){const c=l.origin||r;i.x+=l.internals.positionAbsolute.x-(t.width??0)*c[0],i.y+=l.internals.positionAbsolute.y-(t.height??0)*c[1]}return i}function Ai(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function a5(){let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}}function u5(e){return{...La,...e||{}}}function Rn(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:r}){const{x:i,y:l}=dt(e),c=zn({x:i-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},s),{x:a,y:d}=n?Js(c,t):c;return{xSnapped:a,ySnapped:d,...c}}const $r=e=>({width:e.offsetWidth,height:e.offsetHeight}),Va=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},d5=["INPUT","SELECT","TEXTAREA"];function Fa(e){var s,r;const t=((r=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:d5.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Ha=e=>"clientX"in e,dt=(e,t)=>{var i,l;const n=Ha(e),s=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,r=n?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},Ii=(e,t,n,s,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(l=>{const c=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:r,position:l.getAttribute("data-handlepos"),x:(c.left-n.left)/s,y:(c.top-n.top)/s,...$r(l)}})};function Za({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:r,sourceControlY:i,targetControlX:l,targetControlY:c}){const a=e*.125+r*.375+l*.375+n*.125,d=t*.125+i*.375+c*.375+s*.125,x=Math.abs(a-e),p=Math.abs(d-t);return[a,d,x,p]}function Jn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function $i({pos:e,x1:t,y1:n,x2:s,y2:r,c:i}){switch(e){case U.Left:return[t-Jn(t-s,i),n];case U.Right:return[t+Jn(s-t,i),n];case U.Top:return[t,n-Jn(n-r,i)];case U.Bottom:return[t,n+Jn(r-n,i)]}}function Ka({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:s,targetY:r,targetPosition:i=U.Top,curvature:l=.25}){const[c,a]=$i({pos:n,x1:e,y1:t,x2:s,y2:r,c:l}),[d,x]=$i({pos:i,x1:s,y1:r,x2:e,y2:t,c:l}),[p,m,f,h]=Za({sourceX:e,sourceY:t,targetX:s,targetY:r,sourceControlX:c,sourceControlY:a,targetControlX:d,targetControlY:x});return[`M${e},${t} C${c},${a} ${d},${x} ${s},${r}`,p,m,f,h]}function Wa({sourceX:e,sourceY:t,targetX:n,targetY:s}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,l=Math.abs(s-t)/2,c=s<t?s+l:s-l;return[i,c,r,l]}function x5({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:r=!1}){if(!r)return s;const i=n||t.selected||e.selected,l=Math.max(e.internals.z||0,t.internals.z||0,1e3);return s+(i?l:0)}function p5({sourceNode:e,targetNode:t,width:n,height:s,transform:r}){const i=Xs(Ps(e),Ps(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const l={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:s/r[2]};return _n(l,Us(i))>0}const Ya=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,m5=(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)),Ga=(e,t)=>{if(!e.source||!e.target)return _s("006",Oe.error006()),t;let n;return Aa(e)?n={...e}:n={...e,id:Ya(e)},m5(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))},f5=(e,t,n,s={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return _s("006",Oe.error006()),n;if(!n.find(a=>a.id===e.id))return _s("007",Oe.error007(r)),n;const c={...i,id:s.shouldReplaceId?Ya(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(a=>a.id!==r).concat(c)};function qa({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[r,i,l,c]=Wa({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,r,i,l,c]}const Bi={[U.Left]:{x:-1,y:0},[U.Right]:{x:1,y:0},[U.Top]:{x:0,y:-1},[U.Bottom]:{x:0,y:1}},h5=({source:e,sourcePosition:t=U.Bottom,target:n})=>t===U.Left||t===U.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},Di=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function g5({source:e,sourcePosition:t=U.Bottom,target:n,targetPosition:s=U.Top,center:r,offset:i}){const l=Bi[t],c=Bi[s],a={x:e.x+l.x*i,y:e.y+l.y*i},d={x:n.x+c.x*i,y:n.y+c.y*i},x=h5({source:a,sourcePosition:t,target:d}),p=x.x!==0?"x":"y",m=x[p];let f=[],h,j;const y={x:0,y:0},S={x:0,y:0},[b,E,R,M]=Wa({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){h=r.x??b,j=r.y??E;const L=[{x:h,y:a.y},{x:h,y:d.y}],A=[{x:a.x,y:j},{x:d.x,y:j}];l[p]===m?f=p==="x"?L:A:f=p==="x"?A:L}else{const L=[{x:a.x,y:d.y}],A=[{x:d.x,y:a.y}];if(p==="x"?f=l.x===m?A:L:f=l.y===m?L:A,t===s){const k=Math.abs(e[p]-n[p]);if(k<=i){const C=Math.min(i-1,i-k);l[p]===m?y[p]=(a[p]>e[p]?-1:1)*C:S[p]=(d[p]>n[p]?-1:1)*C}}if(t!==s){const k=p==="x"?"y":"x",C=l[p]===c[k],P=a[k]>d[k],v=a[k]<d[k];(l[p]===1&&(!C&&P||C&&v)||l[p]!==1&&(!C&&v||C&&P))&&(f=p==="x"?L:A)}const $={x:a.x+y.x,y:a.y+y.y},O={x:d.x+S.x,y:d.y+S.y},V=Math.max(Math.abs($.x-f[0].x),Math.abs(O.x-f[0].x)),z=Math.max(Math.abs($.y-f[0].y),Math.abs(O.y-f[0].y));V>=z?(h=($.x+O.x)/2,j=f[0].y):(h=f[0].x,j=($.y+O.y)/2)}return[[e,{x:a.x+y.x,y:a.y+y.y},...f,{x:d.x+S.x,y:d.y+S.y},n],h,j,R,M]}function j5(e,t,n,s){const r=Math.min(Di(e,t)/2,Di(t,n)/2,s),{x:i,y:l}=t;if(e.x===i&&i===n.x||e.y===l&&l===n.y)return`L${i} ${l}`;if(e.y===l){const d=e.x<n.x?-1:1,x=e.y<n.y?1:-1;return`L ${i+r*d},${l}Q ${i},${l} ${i},${l+r*x}`}const c=e.x<n.x?1:-1,a=e.y<n.y?-1:1;return`L ${i},${l+r*a}Q ${i},${l} ${i+r*c},${l}`}function Go({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:s,targetY:r,targetPosition:i=U.Top,borderRadius:l=5,centerX:c,centerY:a,offset:d=20}){const[x,p,m,f,h]=g5({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:r},targetPosition:i,center:{x:c,y:a},offset:d});return[x.reduce((y,S,b)=>{let E="";return b>0&&b<x.length-1?E=j5(x[b-1],S,x[b+1],l):E=`${b===0?"M":"L"}${S.x} ${S.y}`,y+=E,y},""),p,m,f,h]}function Oi(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function E5(e){var p;const{sourceNode:t,targetNode:n}=e;if(!Oi(t)||!Oi(n))return null;const s=t.internals.handleBounds||zi(t.handles),r=n.internals.handleBounds||zi(n.handles),i=Vi((s==null?void 0:s.source)??[],e.sourceHandle),l=Vi(e.connectionMode===zt.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!i||!l)return(p=e.onError)==null||p.call(e,"008",Oe.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(i==null?void 0:i.position)||U.Bottom,a=(l==null?void 0:l.position)||U.Top,d=Ln(t,i,c),x=Ln(n,l,a);return{sourceX:d.x,sourceY:d.y,targetX:x.x,targetY:x.y,sourcePosition:c,targetPosition:a}}function zi(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 Ln(e,t,n=U.Left,s=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:l,height:c}=t??ht(e);if(s)return{x:r+l/2,y:i+c/2};switch((t==null?void 0:t.position)??n){case U.Top:return{x:r+l/2,y:i};case U.Right:return{x:r+l,y:i+c/2};case U.Bottom:return{x:r+l/2,y:i+c};case U.Left:return{x:r,y:i+c/2}}}function Vi(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function qo(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function y5(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:r}){const i=new Set;return e.reduce((l,c)=>([c.markerStart||s,c.markerEnd||r].forEach(a=>{if(a&&typeof a=="object"){const d=qo(a,t);i.has(d)||(l.push({id:d,color:a.color||n,...a}),i.add(d))}}),l),[]).sort((l,c)=>l.id.localeCompare(c.id))}const Br={nodeOrigin:[0,0],nodeExtent:Pn,elevateNodesOnSelect:!0,defaults:{}},S5={...Br,checkEquality:!0};function Dr(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function R5(e,t,n){const s=Dr(Br,n);for(const r of e.values())if(r.parentId)Or(r,e,t,s);else{const i=Dn(r,s.nodeOrigin),l=rn(r.extent)?r.extent:s.nodeExtent,c=Vt(i,l,ht(r));r.internals.positionAbsolute=c}}function Xo(e,t,n,s){var a,d;const r=Dr(S5,s);let i=e.length>0;const l=new Map(t),c=r!=null&&r.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const x of e){let p=l.get(x.id);if(r.checkEquality&&x===(p==null?void 0:p.internals.userNode))t.set(x.id,p);else{const m=Dn(x,r.nodeOrigin),f=rn(x.extent)?x.extent:r.nodeExtent,h=Vt(m,f,ht(x));p={...r.defaults,...x,measured:{width:(a=x.measured)==null?void 0:a.width,height:(d=x.measured)==null?void 0:d.height},internals:{positionAbsolute:h,handleBounds:x.measured?p==null?void 0:p.internals.handleBounds:void 0,z:Xa(x,c),userNode:x}},t.set(x.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(i=!1),x.parentId&&Or(p,t,n,s)}return i}function C5(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 Or(e,t,n,s){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:l}=Dr(Br,s),c=e.parentId,a=t.get(c);if(!a){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}C5(e,n);const d=r?1e3:0,{x,y:p,z:m}=w5(e,a,i,l,d),{positionAbsolute:f}=e.internals,h=x!==f.x||p!==f.y;(h||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x,y:p}:f,z:m}})}function Xa(e,t){return(Je(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function w5(e,t,n,s,r){const{x:i,y:l}=t.internals.positionAbsolute,c=ht(e),a=Dn(e,n),d=rn(e.extent)?Vt(a,e.extent,c):a;let x=Vt({x:i+d.x,y:l+d.y},s,c);e.extent==="parent"&&(x=$a(x,c,t));const p=Xa(e,r),m=t.internals.z??0;return{x:x.x,y:x.y,z:m>p?m:p}}function zr(e,t,n,s=[0,0]){var l;const r=[],i=new Map;for(const c of e){const a=t.get(c.parentId);if(!a)continue;const d=((l=i.get(c.parentId))==null?void 0:l.expandedRect)??on(a),x=Da(d,c.rect);i.set(c.parentId,{expandedRect:x,parent:a})}return i.size>0&&i.forEach(({expandedRect:c,parent:a},d)=>{var E;const x=a.internals.positionAbsolute,p=ht(a),m=a.origin??s,f=c.x<x.x?Math.round(Math.abs(x.x-c.x)):0,h=c.y<x.y?Math.round(Math.abs(x.y-c.y)):0,j=Math.max(p.width,Math.round(c.width)),y=Math.max(p.height,Math.round(c.height)),S=(j-p.width)*m[0],b=(y-p.height)*m[1];(f>0||h>0||S||b)&&(r.push({id:d,type:"position",position:{x:a.position.x-f+S,y:a.position.y-h+b}}),(E=n.get(d))==null||E.forEach(R=>{e.some(M=>M.id===R.id)||r.push({id:R.id,type:"position",position:{x:R.position.x+f,y:R.position.y+h}})})),(p.width<c.width||p.height<c.height||f||h)&&r.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:j+(f?m[0]*f-S:0),height:y+(h?m[1]*h-b:0)}})}),r}function b5(e,t,n,s,r,i){const l=s==null?void 0:s.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const a=[],d=window.getComputedStyle(l),{m22:x}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const m of e.values()){const f=t.get(m.id);if(!f)continue;if(f.hidden){t.set(f.id,{...f,internals:{...f.internals,handleBounds:void 0}}),c=!0;continue}const h=$r(m.nodeElement),j=f.measured.width!==h.width||f.measured.height!==h.height;if(!!(h.width&&h.height&&(j||!f.internals.handleBounds||m.force))){const S=m.nodeElement.getBoundingClientRect(),b=rn(f.extent)?f.extent:i;let{positionAbsolute:E}=f.internals;f.parentId&&f.extent==="parent"?E=$a(E,h,t.get(f.parentId)):b&&(E=Vt(E,b,h));const R={...f,measured:h,internals:{...f.internals,positionAbsolute:E,handleBounds:{source:Ii("source",m.nodeElement,S,x,f.id),target:Ii("target",m.nodeElement,S,x,f.id)}}};t.set(f.id,R),f.parentId&&Or(R,t,n,{nodeOrigin:r}),c=!0,j&&(a.push({id:f.id,type:"dimensions",dimensions:h}),f.expandParent&&f.parentId&&p.push({id:f.id,parentId:f.parentId,rect:on(R,r)}))}}if(p.length>0){const m=zr(p,t,n,r);a.push(...m)}return{changes:a,updatedInternals:c}}async function v5({delta:e,panZoom:t,transform:n,translateExtent:s,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const l=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],s),c=!!l&&(l.x!==n[0]||l.y!==n[1]||l.k!==n[2]);return Promise.resolve(c)}function Fi(e,t,n,s,r,i){let l=r;const c=s.get(l)||new Map;s.set(l,c.set(n,t)),l=`${r}-${e}`;const a=s.get(l)||new Map;if(s.set(l,a.set(n,t)),i){l=`${r}-${e}-${i}`;const d=s.get(l)||new Map;s.set(l,d.set(n,t))}}function Ua(e,t,n){e.clear(),t.clear();for(const s of n){const{source:r,target:i,sourceHandle:l=null,targetHandle:c=null}=s,a={edgeId:s.id,source:r,target:i,sourceHandle:l,targetHandle:c},d=`${r}-${l}--${i}-${c}`,x=`${i}-${c}--${r}-${l}`;Fi("source",a,x,e,r,l),Fi("target",a,d,e,i,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 Hi(e,t,n){var r;let s=e;do{if((r=s==null?void 0:s.matches)!=null&&r.call(s,t))return!0;if(s===n)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function k5(e,t,n,s){const r=new Map;for(const[i,l]of e)if((l.selected||l.id===s)&&(!l.parentId||!Ja(l,e))&&(l.draggable||t&&typeof l.draggable>"u")){const c=e.get(i);c&&r.set(i,{id:i,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return r}function So({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){var l,c,a;const r=[];for(const[d,x]of t){const p=(l=n.get(d))==null?void 0:l.internals.userNode;p&&r.push({...p,position:x.position,dragging:s})}if(!e)return[r[0],r];const i=(c=n.get(e))==null?void 0:c.internals.userNode;return[i?{...i,position:((a=t.get(e))==null?void 0:a.position)||i.position,dragging:s}:r[0],r]}function M5({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:r}){let i={x:null,y:null},l=0,c=new Map,a=!1,d={x:0,y:0},x=null,p=!1,m=null,f=!1;function h({noDragClassName:y,handleSelector:S,domNode:b,isSelectable:E,nodeId:R,nodeClickDistance:M=0}){m=Ke(b);function _({x:O,y:V},z){const{nodeLookup:k,nodeExtent:C,snapGrid:P,snapToGrid:v,nodeOrigin:N,onNodeDrag:D,onSelectionDrag:I,onError:F,updateNodePositions:H}=t();i={x:O,y:V};let Z=!1,ee={x:0,y:0,x2:0,y2:0};if(c.size>1&&C){const te=On(c);ee=Yo(te)}for(const[te,se]of c){if(!k.has(te))continue;let oe={x:O-se.distance.x,y:V-se.distance.y};v&&(oe=Js(oe,P));let xe=[[C[0][0],C[0][1]],[C[1][0],C[1][1]]];if(c.size>1&&C&&!se.extent){const{positionAbsolute:je}=se.internals,ge=je.x-ee.x+C[0][0],W=je.x+se.measured.width-ee.x2+C[1][0],le=je.y-ee.y+C[0][1],ue=je.y+se.measured.height-ee.y2+C[1][1];xe=[[ge,le],[W,ue]]}const{position:J,positionAbsolute:ae}=Ia({nodeId:te,nextPosition:oe,nodeLookup:k,nodeExtent:xe,nodeOrigin:N,onError:F});Z=Z||se.position.x!==J.x||se.position.y!==J.y,se.position=J,se.internals.positionAbsolute=ae}if(Z&&(H(c,!0),z&&(s||D||!R&&I))){const[te,se]=So({nodeId:R,dragItems:c,nodeLookup:k});s==null||s(z,c,te,se),D==null||D(z,te,se),R||I==null||I(z,se)}}async function L(){if(!x)return;const{transform:O,panBy:V,autoPanSpeed:z,autoPanOnNodeDrag:k}=t();if(!k){a=!1,cancelAnimationFrame(l);return}const[C,P]=Ba(d,x,z);(C!==0||P!==0)&&(i.x=(i.x??0)-C/O[2],i.y=(i.y??0)-P/O[2],await V({x:C,y:P})&&_(i,null)),l=requestAnimationFrame(L)}function A(O){var Z;const{nodeLookup:V,multiSelectionActive:z,nodesDraggable:k,transform:C,snapGrid:P,snapToGrid:v,selectNodesOnDrag:N,onNodeDragStart:D,onSelectionDragStart:I,unselectNodesAndEdges:F}=t();p=!0,(!N||!E)&&!z&&R&&((Z=V.get(R))!=null&&Z.selected||F()),E&&N&&R&&(e==null||e(R));const H=Rn(O.sourceEvent,{transform:C,snapGrid:P,snapToGrid:v,containerBounds:x});if(i=H,c=k5(V,k,H,R),c.size>0&&(n||D||!R&&I)){const[ee,te]=So({nodeId:R,dragItems:c,nodeLookup:V});n==null||n(O.sourceEvent,c,ee,te),D==null||D(O.sourceEvent,ee,te),R||I==null||I(O.sourceEvent,te)}}const $=ya().clickDistance(M).on("start",O=>{const{domNode:V,nodeDragThreshold:z,transform:k,snapGrid:C,snapToGrid:P}=t();x=(V==null?void 0:V.getBoundingClientRect())||null,f=!1,z===0&&A(O),i=Rn(O.sourceEvent,{transform:k,snapGrid:C,snapToGrid:P,containerBounds:x}),d=dt(O.sourceEvent,x)}).on("drag",O=>{const{autoPanOnNodeDrag:V,transform:z,snapGrid:k,snapToGrid:C,nodeDragThreshold:P,nodeLookup:v}=t(),N=Rn(O.sourceEvent,{transform:z,snapGrid:k,snapToGrid:C,containerBounds:x});if((O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||R&&!v.has(R))&&(f=!0),!f){if(!a&&V&&p&&(a=!0,L()),!p){const D=N.xSnapped-(i.x??0),I=N.ySnapped-(i.y??0);Math.sqrt(D*D+I*I)>P&&A(O)}(i.x!==N.xSnapped||i.y!==N.ySnapped)&&c&&p&&(d=dt(O.sourceEvent,x),_(N,O.sourceEvent))}}).on("end",O=>{if(!(!p||f)&&(a=!1,p=!1,cancelAnimationFrame(l),c.size>0)){const{nodeLookup:V,updateNodePositions:z,onNodeDragStop:k,onSelectionDragStop:C}=t();if(z(c,!1),r||k||!R&&C){const[P,v]=So({nodeId:R,dragItems:c,nodeLookup:V,dragging:!1});r==null||r(O.sourceEvent,c,P,v),k==null||k(O.sourceEvent,P,v),R||C==null||C(O.sourceEvent,v)}}}).filter(O=>{const V=O.target;return!O.button&&(!y||!Hi(V,`.${y}`,b))&&(!S||Hi(V,S,b))});m.call($)}function j(){m==null||m.on(".drag",null)}return{update:h,destroy:j}}function P5(e,t,n){const s=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())_n(r,on(i))>0&&s.push(i);return s}const _5=250;function L5(e,t,n,s){var c,a;let r=[],i=1/0;const l=P5(e,n,t+_5);for(const d of l){const x=[...((c=d.internals.handleBounds)==null?void 0:c.source)??[],...((a=d.internals.handleBounds)==null?void 0:a.target)??[]];for(const p of x){if(s.nodeId===p.nodeId&&s.type===p.type&&s.id===p.id)continue;const{x:m,y:f}=Ln(d,p,p.position,!0),h=Math.sqrt(Math.pow(m-e.x,2)+Math.pow(f-e.y,2));h>t||(h<i?(r=[{...p,x:m,y:f}],i=h):h===i&&r.push({...p,x:m,y:f}))}}if(!r.length)return null;if(r.length>1){const d=s.type==="source"?"target":"source";return r.find(x=>x.type===d)??r[0]}return r[0]}function Qa(e,t,n,s,r,i=!1){var d,x,p;const l=s.get(e);if(!l)return null;const c=r==="strict"?(d=l.internals.handleBounds)==null?void 0:d[t]:[...((x=l.internals.handleBounds)==null?void 0:x.source)??[],...((p=l.internals.handleBounds)==null?void 0:p.target)??[]],a=(n?c==null?void 0:c.find(m=>m.id===n):c==null?void 0:c[0])??null;return a&&i?{...a,...Ln(l,a,a.position,!0)}:a}function eu(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function N5(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const tu=()=>!0;function T5(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:r,edgeUpdaterType:i,isTarget:l,domNode:c,nodeLookup:a,lib:d,autoPanOnConnect:x,flowId:p,panBy:m,cancelConnection:f,onConnectStart:h,onConnect:j,onConnectEnd:y,isValidConnection:S=tu,onReconnectEnd:b,updateConnection:E,getTransform:R,getFromHandle:M,autoPanSpeed:_}){const L=Va(e.target);let A=0,$;const{x:O,y:V}=dt(e),z=L==null?void 0:L.elementFromPoint(O,V),k=eu(i,z),C=c==null?void 0:c.getBoundingClientRect();if(!C||!k)return;const P=Qa(r,k,s,a,t);if(!P)return;let v=dt(e,C),N=!1,D=null,I=!1,F=null;function H(){if(!x||!C)return;const[ae,je]=Ba(v,C,_);m({x:ae,y:je}),A=requestAnimationFrame(H)}const Z={...P,nodeId:r,type:k,position:P.position},ee=a.get(r),se={inProgress:!0,isValid:null,from:Ln(ee,Z,U.Left,!0),fromHandle:Z,fromPosition:Z.position,fromNode:ee,to:v,toHandle:null,toPosition:Li[Z.position],toNode:null};E(se);let oe=se;h==null||h(e,{nodeId:r,handleId:s,handleType:k});function xe(ae){if(!M()||!Z){J(ae);return}const je=R();v=dt(ae,C),$=L5(zn(v,je,!1,[1,1]),n,a,Z),N||(H(),N=!0);const ge=nu(ae,{handle:$,connectionMode:t,fromNodeId:r,fromHandleId:s,fromType:l?"target":"source",isValidConnection:S,doc:L,lib:d,flowId:p,nodeLookup:a});F=ge.handleDomNode,D=ge.connection,I=N5(!!$,ge.isValid);const W={...oe,isValid:I,to:ge.toHandle&&I?Ls({x:ge.toHandle.x,y:ge.toHandle.y},je):v,toHandle:ge.toHandle,toPosition:I&&ge.toHandle?ge.toHandle.position:Li[Z.position],toNode:ge.toHandle?a.get(ge.toHandle.nodeId):null};I&&$&&oe.toHandle&&W.toHandle&&oe.toHandle.type===W.toHandle.type&&oe.toHandle.nodeId===W.toHandle.nodeId&&oe.toHandle.id===W.toHandle.id&&oe.to.x===W.to.x&&oe.to.y===W.to.y||(E(W),oe=W)}function J(ae){($||F)&&D&&I&&(j==null||j(D));const{inProgress:je,...ge}=oe,W={...ge,toPosition:oe.toHandle?oe.toPosition:null};y==null||y(ae,W),i&&(b==null||b(ae,W)),f(),cancelAnimationFrame(A),N=!1,I=!1,D=null,F=null,L.removeEventListener("mousemove",xe),L.removeEventListener("mouseup",J),L.removeEventListener("touchmove",xe),L.removeEventListener("touchend",J)}L.addEventListener("mousemove",xe),L.addEventListener("mouseup",J),L.addEventListener("touchmove",xe),L.addEventListener("touchend",J)}function nu(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:r,fromType:i,doc:l,lib:c,flowId:a,isValidConnection:d=tu,nodeLookup:x}){const p=i==="target",m=t?l.querySelector(`.${c}-flow__handle[data-id="${a}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:f,y:h}=dt(e),j=l.elementFromPoint(f,h),y=j!=null&&j.classList.contains(`${c}-flow__handle`)?j:m,S={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const b=eu(void 0,y),E=y.getAttribute("data-nodeid"),R=y.getAttribute("data-handleid"),M=y.classList.contains("connectable"),_=y.classList.contains("connectableend");if(!E||!b)return S;const L={source:p?E:s,sourceHandle:p?R:r,target:p?s:E,targetHandle:p?r:R};S.connection=L;const $=M&&_&&(n===zt.Strict?p&&b==="source"||!p&&b==="target":E!==s||R!==r);S.isValid=$&&d(L),S.toHandle=Qa(E,b,R,x,n,!0)}return S}const Uo={onPointerDown:T5,isValid:nu};function A5({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const r=Ke(e);function i({translateExtent:c,width:a,height:d,zoomStep:x=10,pannable:p=!0,zoomable:m=!0,inversePan:f=!1}){const h=E=>{const R=n();if(E.sourceEvent.type!=="wheel"||!t)return;const M=-E.sourceEvent.deltaY*(E.sourceEvent.deltaMode===1?.05:E.sourceEvent.deltaMode?1:.002)*x,_=R[2]*Math.pow(2,M);t.scaleTo(_)};let j=[0,0];const y=E=>{(E.sourceEvent.type==="mousedown"||E.sourceEvent.type==="touchstart")&&(j=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY])},S=E=>{const R=n();if(E.sourceEvent.type!=="mousemove"&&E.sourceEvent.type!=="touchmove"||!t)return;const M=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY],_=[M[0]-j[0],M[1]-j[1]];j=M;const L=s()*Math.max(R[2],Math.log(R[2]))*(f?-1:1),A={x:R[0]-_[0]*L,y:R[1]-_[1]*L},$=[[0,0],[a,d]];t.setViewportConstrained({x:A.x,y:A.y,zoom:R[2]},$,c)},b=Pa().on("start",y).on("zoom",p?S:null).on("zoom.wheel",m?h:null);r.call(b,{})}function l(){r.on("zoom",null)}return{update:i,destroy:l,pointer:Ue}}const I5=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Qs=e=>({x:e.x,y:e.y,zoom:e.k}),Ro=({x:e,y:t,zoom:n})=>qs.translate(e,t).scale(n),Xt=(e,t)=>e.target.closest(`.${t}`),su=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),$5=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Co=(e,t=0,n=$5,s=()=>{})=>{const r=typeof t=="number"&&t>0;return r||s(),r?e.transition().duration(t).ease(n).on("end",s):e},ou=e=>{const t=e.ctrlKey&&Ns()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function B5({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:l,onPanZoomStart:c,onPanZoom:a,onPanZoomEnd:d}){return x=>{if(Xt(x,t))return!1;x.preventDefault(),x.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(x.ctrlKey&&l){const y=Ue(x),S=ou(x),b=p*Math.pow(2,S);s.scaleTo(n,b,y,x);return}const m=x.deltaMode===1?20:1;let f=r===It.Vertical?0:x.deltaX*m,h=r===It.Horizontal?0:x.deltaY*m;!Ns()&&x.shiftKey&&r!==It.Vertical&&(f=x.deltaY*m,h=0),s.translateBy(n,-(f/p)*i,-(h/p)*i,{internal:!0});const j=Qs(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,c==null||c(x,j)),e.isPanScrolling&&(a==null||a(x,j),e.panScrollTimeout=setTimeout(()=>{d==null||d(x,j),e.isPanScrolling=!1},150))}}function D5({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,r){const i=s.type==="wheel",l=!t&&i&&!s.ctrlKey,c=Xt(s,e);if(s.ctrlKey&&i&&c&&s.preventDefault(),l||c)return null;s.preventDefault(),n.call(this,s,r)}}function O5({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{var i,l,c;if((i=s.sourceEvent)!=null&&i.internal)return;const r=Qs(s.transform);e.mouseButton=((l=s.sourceEvent)==null?void 0:l.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((c=s.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(s.sourceEvent,r))}}function z5({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:r}){return i=>{var l,c;e.usedRightMouseButton=!!(n&&su(t,e.mouseButton??0)),(l=i.sourceEvent)!=null&&l.sync||s([i.transform.x,i.transform.y,i.transform.k]),r&&!((c=i.sourceEvent)!=null&&c.internal)&&(r==null||r(i.sourceEvent,Qs(i.transform)))}}function V5({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:r,onPaneContextMenu:i}){return l=>{var c;if(!((c=l.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,i&&su(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&i(l.sourceEvent),e.usedRightMouseButton=!1,s(!1),r&&I5(e.prevViewport,l.transform))){const a=Qs(l.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,a)},n?150:0)}}}function F5({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:l,noWheelClassName:c,noPanClassName:a,lib:d}){return x=>{var h;const p=e||t,m=n&&x.ctrlKey;if(x.button===1&&x.type==="mousedown"&&(Xt(x,`${d}-flow__node`)||Xt(x,`${d}-flow__edge`)))return!0;if(!s&&!p&&!r&&!i&&!n||l||Xt(x,c)&&x.type==="wheel"||Xt(x,a)&&(x.type!=="wheel"||r&&x.type==="wheel"&&!e)||!n&&x.ctrlKey&&x.type==="wheel")return!1;if(!n&&x.type==="touchstart"&&((h=x.touches)==null?void 0:h.length)>1)return x.preventDefault(),!1;if(!p&&!r&&!m&&x.type==="wheel"||!s&&(x.type==="mousedown"||x.type==="touchstart")||Array.isArray(s)&&!s.includes(x.button)&&x.type==="mousedown")return!1;const f=Array.isArray(s)&&s.includes(x.button)||!x.button||x.button<=1;return(!x.ctrlKey||x.type==="wheel")&&f}}function H5({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:s,translateExtent:r,viewport:i,onPanZoom:l,onPanZoomStart:c,onPanZoomEnd:a,onDraggingChange:d}){const x={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),m=Pa().clickDistance(!Je(s)||s<0?0:s).scaleExtent([t,n]).translateExtent(r),f=Ke(e).call(m);E({x:i.x,y:i.y,zoom:sn(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const h=f.on("wheel.zoom"),j=f.on("dblclick.zoom");m.wheelDelta(ou);function y(z,k){return f?new Promise(C=>{m==null||m.interpolate((k==null?void 0:k.interpolate)==="linear"?B.interpolate:ls).transform(Co(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>C(!0)),z)}):Promise.resolve(!1)}function S({noWheelClassName:z,noPanClassName:k,onPaneContextMenu:C,userSelectionActive:P,panOnScroll:v,panOnDrag:N,panOnScrollMode:D,panOnScrollSpeed:I,preventScrolling:F,zoomOnPinch:H,zoomOnScroll:Z,zoomOnDoubleClick:ee,zoomActivationKeyPressed:te,lib:se,onTransformChange:oe}){P&&!x.isZoomingOrPanning&&b();const J=v&&!te&&!P?B5({zoomPanValues:x,noWheelClassName:z,d3Selection:f,d3Zoom:m,panOnScrollMode:D,panOnScrollSpeed:I,zoomOnPinch:H,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:a}):D5({noWheelClassName:z,preventScrolling:F,d3ZoomHandler:h});if(f.on("wheel.zoom",J,{passive:!1}),!P){const je=O5({zoomPanValues:x,onDraggingChange:d,onPanZoomStart:c});m.on("start",je);const ge=z5({zoomPanValues:x,panOnDrag:N,onPaneContextMenu:!!C,onPanZoom:l,onTransformChange:oe});m.on("zoom",ge);const W=V5({zoomPanValues:x,panOnDrag:N,panOnScroll:v,onPaneContextMenu:C,onPanZoomEnd:a,onDraggingChange:d});m.on("end",W)}const ae=F5({zoomActivationKeyPressed:te,panOnDrag:N,zoomOnScroll:Z,panOnScroll:v,zoomOnDoubleClick:ee,zoomOnPinch:H,userSelectionActive:P,noPanClassName:k,noWheelClassName:z,lib:se});m.filter(ae),ee?f.on("dblclick.zoom",j):f.on("dblclick.zoom",null)}function b(){m.on("zoom",null)}async function E(z,k,C){const P=Ro(z),v=m==null?void 0:m.constrain()(P,k,C);return v&&await y(v),new Promise(N=>N(v))}async function R(z,k){const C=Ro(z);return await y(C,k),new Promise(P=>P(C))}function M(z){if(f){const k=Ro(z),C=f.property("__zoom");(C.k!==z.zoom||C.x!==z.x||C.y!==z.y)&&(m==null||m.transform(f,k,null,{sync:!0}))}}function _(){const z=f?Ma(f.node()):{x:0,y:0,k:1};return{x:z.x,y:z.y,zoom:z.k}}function L(z,k){return f?new Promise(C=>{m==null||m.interpolate((k==null?void 0:k.interpolate)==="linear"?B.interpolate:ls).scaleTo(Co(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>C(!0)),z)}):Promise.resolve(!1)}function A(z,k){return f?new Promise(C=>{m==null||m.interpolate((k==null?void 0:k.interpolate)==="linear"?B.interpolate:ls).scaleBy(Co(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>C(!0)),z)}):Promise.resolve(!1)}function $(z){m==null||m.scaleExtent(z)}function O(z){m==null||m.translateExtent(z)}function V(z){const k=!Je(z)||z<0?0:z;m==null||m.clickDistance(k)}return{update:S,destroy:b,setViewport:R,setViewportConstrained:E,getViewport:_,scaleTo:L,scaleBy:A,setScaleExtent:$,setTranslateExtent:O,syncViewport:M,setClickDistance:V}}var ln;(function(e){e.Line="line",e.Handle="handle"})(ln||(ln={}));function Z5({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:r,affectsY:i}){const l=e-t,c=n-s,a=[l>0?1:l<0?-1:0,c>0?1:c<0?-1:0];return l&&r&&(a[0]=a[0]*-1),c&&i&&(a[1]=a[1]*-1),a}function K5(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),s=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:s,affectsY:r}}function jt(e,t){return Math.max(0,t-e)}function Et(e,t){return Math.max(0,e-t)}function Qn(e,t,n){return Math.max(0,t-e,e-n)}function Zi(e,t){return e?!t:t}function W5(e,t,n,s,r,i,l,c){let{affectsX:a,affectsY:d}=t;const{isHorizontal:x,isVertical:p}=t,m=x&&p,{xSnapped:f,ySnapped:h}=n,{minWidth:j,maxWidth:y,minHeight:S,maxHeight:b}=s,{x:E,y:R,width:M,height:_,aspectRatio:L}=e;let A=Math.floor(x?f-e.pointerX:0),$=Math.floor(p?h-e.pointerY:0);const O=M+(a?-A:A),V=_+(d?-$:$),z=-i[0]*M,k=-i[1]*_;let C=Qn(O,j,y),P=Qn(V,S,b);if(l){let D=0,I=0;a&&A<0?D=jt(E+A+z,l[0][0]):!a&&A>0&&(D=Et(E+O+z,l[1][0])),d&&$<0?I=jt(R+$+k,l[0][1]):!d&&$>0&&(I=Et(R+V+k,l[1][1])),C=Math.max(C,D),P=Math.max(P,I)}if(c){let D=0,I=0;a&&A>0?D=Et(E+A,c[0][0]):!a&&A<0&&(D=jt(E+O,c[1][0])),d&&$>0?I=Et(R+$,c[0][1]):!d&&$<0&&(I=jt(R+V,c[1][1])),C=Math.max(C,D),P=Math.max(P,I)}if(r){if(x){const D=Qn(O/L,S,b)*L;if(C=Math.max(C,D),l){let I=0;!a&&!d||a&&!d&&m?I=Et(R+k+O/L,l[1][1])*L:I=jt(R+k+(a?A:-A)/L,l[0][1])*L,C=Math.max(C,I)}if(c){let I=0;!a&&!d||a&&!d&&m?I=jt(R+O/L,c[1][1])*L:I=Et(R+(a?A:-A)/L,c[0][1])*L,C=Math.max(C,I)}}if(p){const D=Qn(V*L,j,y)/L;if(P=Math.max(P,D),l){let I=0;!a&&!d||d&&!a&&m?I=Et(E+V*L+z,l[1][0])/L:I=jt(E+(d?$:-$)*L+z,l[0][0])/L,P=Math.max(P,I)}if(c){let I=0;!a&&!d||d&&!a&&m?I=jt(E+V*L,c[1][0])/L:I=Et(E+(d?$:-$)*L,c[0][0])/L,P=Math.max(P,I)}}}$=$+($<0?P:-P),A=A+(A<0?C:-C),r&&(m?O>V*L?$=(Zi(a,d)?-A:A)/L:A=(Zi(a,d)?-$:$)*L:x?($=A/L,d=a):(A=$*L,a=d));const v=a?E+A:E,N=d?R+$:R;return{width:M+(a?-A:A),height:_+(d?-$:$),x:i[0]*A*(a?-1:1)+v,y:i[1]*$*(d?-1:1)+N}}const ru={width:0,height:0,x:0,y:0},Y5={...ru,pointerX:0,pointerY:0,aspectRatio:1};function G5(e){return[[0,0],[e.measured.width,e.measured.height]]}function q5(e,t,n){const s=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,l=e.measured.height??0,c=n[0]*i,a=n[1]*l;return[[s-c,r-a],[s+i-c,r+l-a]]}function X5({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:r}){const i=Ke(e);function l({controlPosition:a,boundaries:d,keepAspectRatio:x,resizeDirection:p,onResizeStart:m,onResize:f,onResizeEnd:h,shouldResize:j}){let y={...ru},S={...Y5};const b=K5(a);let E,R=null,M=[],_,L,A;const $=ya().on("start",O=>{const{nodeLookup:V,transform:z,snapGrid:k,snapToGrid:C,nodeOrigin:P,paneDomNode:v}=n();if(E=V.get(t),!E)return;R=(v==null?void 0:v.getBoundingClientRect())??null;const{xSnapped:N,ySnapped:D}=Rn(O.sourceEvent,{transform:z,snapGrid:k,snapToGrid:C,containerBounds:R});y={width:E.measured.width??0,height:E.measured.height??0,x:E.position.x??0,y:E.position.y??0},S={...y,pointerX:N,pointerY:D,aspectRatio:y.width/y.height},_=void 0,E.parentId&&(E.extent==="parent"||E.expandParent)&&(_=V.get(E.parentId),L=_&&E.extent==="parent"?G5(_):void 0),M=[],A=void 0;for(const[I,F]of V)if(F.parentId===t&&(M.push({id:I,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const H=q5(F,E,F.origin??P);A?A=[[Math.min(H[0][0],A[0][0]),Math.min(H[0][1],A[0][1])],[Math.max(H[1][0],A[1][0]),Math.max(H[1][1],A[1][1])]]:A=H}m==null||m(O,{...y})}).on("drag",O=>{const{transform:V,snapGrid:z,snapToGrid:k,nodeOrigin:C}=n(),P=Rn(O.sourceEvent,{transform:V,snapGrid:z,snapToGrid:k,containerBounds:R}),v=[];if(!E)return;const{x:N,y:D,width:I,height:F}=y,H={},Z=E.origin??C,{width:ee,height:te,x:se,y:oe}=W5(S,b,P,d,x,Z,L,A),xe=ee!==I,J=te!==F,ae=se!==N&&xe,je=oe!==D&&J;if(!ae&&!je&&!xe&&!J)return;if((ae||je||Z[0]===1||Z[1]===1)&&(H.x=ae?se:y.x,H.y=je?oe:y.y,y.x=H.x,y.y=H.y,M.length>0)){const ue=se-N,Me=oe-D;for(const Le of M)Le.position={x:Le.position.x-ue+Z[0]*(ee-I),y:Le.position.y-Me+Z[1]*(te-F)},v.push(Le)}if((xe||J)&&(H.width=xe&&(!p||p==="horizontal")?ee:y.width,H.height=J&&(!p||p==="vertical")?te:y.height,y.width=H.width,y.height=H.height),_&&E.expandParent){const ue=Z[0]*(H.width??0);H.x&&H.x<ue&&(y.x=ue,S.x=S.x-(H.x-ue));const Me=Z[1]*(H.height??0);H.y&&H.y<Me&&(y.y=Me,S.y=S.y-(H.y-Me))}const ge=Z5({width:y.width,prevWidth:I,height:y.height,prevHeight:F,affectsX:b.affectsX,affectsY:b.affectsY}),W={...y,direction:ge};(j==null?void 0:j(O,W))!==!1&&(f==null||f(O,W),s(H,v))}).on("end",O=>{h==null||h(O,{...y}),r==null||r({...y})});i.call($)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var es={exports:{}},wo={},ts={exports:{}},bo={};/**
2
2
  * @license React
3
3
  * use-sync-external-store-shim.production.js
4
4
  *