@synnaxlabs/pluto 0.38.1 → 0.38.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var _m=Object.defineProperty;var Mm=(e,t,n)=>t in e?_m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ge=(e,t,n)=>Mm(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./jsx-runtime-D8EVjfnb.cjs"),g=require("react"),j=require("./Toggle-BOWYgKry.cjs"),u=require("./css-DT9dIVAb.cjs"),zn=require("./external-DkXE1VK8.cjs"),Z=require("./aggregator-B4RWbN9h.cjs"),te=require("./Pack-B7_tAsYd.cjs"),Lm=require("./external-CKXRIr4_.cjs"),ke=require("./external-CW61uh4b.cjs"),ve=require("./external-9Q86X8hc.cjs"),Pm=require("./external-CWIwuJks.cjs"),_o=require("./Animated-Cxl7iHik.cjs"),B=require("./LinePlot-C_uxbSzY.cjs"),ce=require("zod"),Wi=require("./external-Dt4ggRt2.cjs");require("./Item-C4SOBynl.cjs");const Mo=require("react-dom"),Gt=require("./external-8OKX45Jc.cjs"),Tm=require("./external-ok_ye4LF.cjs"),Ki=require("./units-BpKy5yTv.cjs"),Te=require("./external-SsIgRo40.cjs"),Nm=require("./external-kZBV4X9L.cjs"),Am=require("./external-CigHe3w_.cjs"),Im=require("./external-Ba8go3wq.cjs"),$m=require("./Video-usN9Roxq.cjs"),zm=(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},Yn=e=>e.preventDefault(),Lo=({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.construct(t),p=u.K.direction(x),m=u.g.dimension(p);return o.jsxRuntimeExports.jsxs("div",{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.swap(x))),onDragStart:l,onDrag:Yn,onDragEnd:Yn})]})},Po=({onResize:e,count:t,initialSizes:n=[],minSize:s=100,direction:r="x"})=>{const i=g.useRef(null),[l,c]=g.useState({sizeDistribution:Bm(n,t),root:null}),a=g.useCallback((p,m,f)=>{if(i.current==null)return;const h=u.Tt.dim(u.Tt.construct(i.current),r);c(E=>Fs(E,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]),E=()=>{c(y=>({...y,root:null})),document.removeEventListener("mousemove",h)};c(y=>({...y,root:p[f]})),document.addEventListener("mousemove",h),document.addEventListener("mouseup",E,{once:!0})},[c,r,Fs]);return{setSize:g.useCallback((p,m)=>a(p,void 0,m),[Fs]),props:{direction:r,sizeDistribution:l.sizeDistribution,onDragHandle:d,ref:i}}},To=({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=Dm(s),o.jsxRuntimeExports.jsx(te.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(Lo,{onDragStart:p=>r(p,x),location:u.g.location(c),size:s[x]*100,sizeUnits:"%",showHandle:x!==a.length-1,children:d},x))})},Bm=(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)},Vs=.001,Dm=e=>e.every(t=>u.G$1.closeTo(t,1/e.length),Vs)?e.map((t,n)=>n%2===0?t+Vs:n===e.length-1?t:t-Vs):e,Fs=(e,t,n,s,r,i)=>{const l=Xi(e,t,n,r,i),[c,a]=Om(e.sizeDistribution,n,l,s/t),d=a?r??null:e.root;return{...e,sizeDistribution:c,root:d}},Xi=(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},Om=(e,t,n,s)=>{let r=t;for(;r>0&&e[r]+n<=s;)r--;const i=e[r]+n,l=Vm(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]},Vm=(e,t,n,s)=>(e===t.length-1?Hm:Fm)(e,t,n,s),Fm=(e,t,n,s)=>{let r=e+1;for(;r<t.length-1&&t[r]-s<=n;)r++;return r},Hm=(e,t,n,s)=>{let r=e-1;for(;r>0&&t[r]-s<=n;)r--;return r},Hs=2,qi=({onCollapse:e,onResize:t,location:n="left",minSize:s=100,maxSize:r=1/0,initialSize:i=200,collapseThreshold:l=1/0,className:c,...a})=>{const[d,x]=g.useState(u.Y(i,s,r)),p=g.useRef(null),m=u.K.construct(n),f=g.useCallback(C=>{if(p.current===null)return 0;const b=u.Tt.dim(C,u.K.direction(m),!0)*(1-2*Number(["bottom","right"].includes(m))),w=p.current+b,L=u.Y(w,s,r);return(L-w)/s>l?Hs:L},[m,s,r,l]),h=g.useRef(null),E=g.useCallback(C=>{const b=f(C);x(b),h.current!=null&&(t==null||t(b,u.Tt.construct(h.current)))},[t,f]),y=g.useCallback(()=>x(C=>(p.current=C,C)),[x]),S=g.useCallback(C=>f(C)===Hs&&(e==null?void 0:e()),[e,f]);g.useEffect(()=>x(C=>{const b=u.Y(C,s,r);return p.current=b,b}),[s,r]);const k=j.useCursorDrag({onMove:E,onStart:y,onEnd:S});return o.jsxRuntimeExports.jsx(Lo,{ref:h,location:m,size:d,onDragStart:k,className:u.clsx(c,u.CSS.expanded(d!==Hs)),...a})},Zm=Object.freeze(Object.defineProperty({__proto__:null,Core:Lo,Multiple:To,Single:qi,calculateDiffPercentage:Xi,useMultiple:Po},Symbol.toStringTag,{value:"Module"})),No=({aetherKey:e})=>{const[,{region:t},n]=j.use$3({aetherKey:e,type:Z.Eraser.TYPE,schema:Z.eraserStateZ,initialState:{region:u.Tt.ZERO,enabled:!0}}),s=j.useSyncedRef(t),r=g.useCallback(l=>{u.Tt.equals(l,s.current)||n(c=>({...c,region:l}))},[n]);return{setEnabled:g.useCallback(l=>n(c=>({...c,enabled:l})),[n]),erase:r}},Gm=({aetherKey:e,children:t})=>{const{erase:n}=No({aetherKey:e}),s=j.useResize(n);return o.jsxRuntimeExports.jsx("div",{ref:s,className:u.CSS(u.CSS.inheritDims()),children:t})},Ym=Object.freeze(Object.defineProperty({__proto__:null,Eraser:Gm,use:No},Symbol.toStringTag,{value:"Module"})),Wm=({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}},Km=({activeItem:e,children:t,onSelect:n,location:s="left",collapseThreshold:r=.65,className:i,onResize:l,...c})=>{const a=u.K.direction(s),d=g.useCallback(()=>e!=null&&(n==null?void 0:n(e.key)),[n,e==null?void 0:e.key]),{erase:x,setEnabled:p}=No({}),m=g.useCallback((k,C)=>{l==null||l(k,C),x(C)},[l,x]);if(g.useLayoutEffect(()=>{p(e!=null)},[e,p]),e==null)return null;const{content:f,key:h,minSize:E,maxSize:y,initialSize:S}=e;return o.jsxRuntimeExports.jsx(qi,{className:u.CSS(u.CSS.BE("navdrawer","content"),u.CSS.dir(a),i),collapseThreshold:r,onCollapse:d,location:s,onResize:m,minSize:E,maxSize:y,initialSize:S,...c,children:f},h)},Xm=Object.freeze(Object.defineProperty({__proto__:null,Bar:j.Bar,Drawer:Km,useDrawer:Wm},Symbol.toStringTag,{value:"Module"})),Ui=({variant:e="info",...t})=>o.jsxRuntimeExports.jsx(j.Lt.Circle,{color:j.variantColors[e],...t}),qm=({status:{key:e,time:t,count:n,message:s,description:r,variant:i},silence:l,actions:c,className:a,children:d,...x})=>o.jsxRuntimeExports.jsxs(te.Space,{className:u.CSS(u.CSS.B("notification"),a),direction:"y",empty:!0,...x,children:[o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",justify:"spaceBetween",grow:!0,style:{width:"100%"},children:[o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(Ui,{style:{height:"2.25rem",width:"2.5rem"},variant:i}),o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",shade:7,children:`x${n}`}),o.jsxRuntimeExports.jsx(j.DateTime,{className:u.CSS(u.CSS.BE("notification","time")),level:"small",format:"time",children:t})]}),o.jsxRuntimeExports.jsx(j.Icon,{className:u.CSS(u.CSS.BE("notification","silence")),variant:"outlined",size:"small",onClick:()=>l(e),children:o.jsxRuntimeExports.jsx(j.Lt.Close,{})})]}),o.jsxRuntimeExports.jsxs(te.Space,{direction:"y",align:"start",className:u.CSS(u.CSS.BE("notification","content")),size:"small",children:[d??o.jsxRuntimeExports.jsx(j.Text$1,{className:u.CSS(u.CSS.BE("notification","message")),level:"p",style:{flexGrow:1},children:s}),r!=null&&o.jsxRuntimeExports.jsx(j.Text$1,{className:u.CSS(u.CSS.BE("notification","description")),level:"small",style:{flexGrow:1},children:r})]}),c!=null&&o.jsxRuntimeExports.jsx(te.Space,{direction:"x",align:"center",justify:"end",className:u.CSS(u.CSS.BE("notification","actions")),children:Z.A(c).map(p=>o.jsxRuntimeExports.jsx(Um,{action:p},p.key))})]},t.toString()),Um=({action:e})=>g.isValidElement(e)?e:o.jsxRuntimeExports.jsx(j.Button,{...e}),Jm=Object.freeze(Object.defineProperty({__proto__:null,Aggregator:j.Aggregator,Circle:Ui,Notification:qm,Text:j.Text$3,VARIANTS:Z.VARIANTS,specZ:Z.specZ$1,useAggregator:j.useAggregator,useContext:j.useContext$3,useExceptionHandler:j.useExceptionHandler,useNotifications:j.useNotifications,variantZ:Z.variantZ},Symbol.toStringTag,{value:"Module"})),Qm=Object.freeze(Object.defineProperty({__proto__:null,Config:j.Config,Context:j.Context,Dialog:j.Dialog$1,chooseLocation:j.chooseLocation,formatTip:j.formatTip,useConfig:j.useConfig,wrap:j.wrap},Symbol.toStringTag,{value:"Module"})),Bn="y",_r=28,ef=32,tf=40,nf=.5,sf=({data:e,...t})=>{const{setSize:n,props:{sizeDistribution:s,ref:r,...i}}=Po({direction:Bn,count:e.length,minSize:_r}),l=c=>{if(r.current==null)return;const a=u.Tt.dim(u.Tt.construct(r.current),Bn);s[c]<tf/a?n(c,e[c].initialSize??nf):n(c,_r+1)};return o.jsxRuntimeExports.jsx(To,{empty:!0,className:u.CSS.B("accordion"),sizeDistribution:s,ref:r,...t,...i,children:e.map((c,a)=>g.createElement(lf,{...c,key:c.key,index:a,direction:Bn,onExpand:l,parent:r,size:s[a]}))})},of=o.jsxRuntimeExports.jsx(j.Lt.Caret.Down,{"aria-label":"contract"}),rf=o.jsxRuntimeExports.jsx(j.Lt.Caret.Right,{"aria-label":"expand"}),lf=({index:e,name:t,content:n,actions:s,size:r,parent:i,onExpand:l})=>{let c=!0;if(i.current!=null){const d=u.Tt.dim(u.Tt.construct(i.current),Bn);c=r*d>ef}const a=c?of:rf;return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsxs(zn.Header,{level:"p",className:u.CSS.expanded(c),empty:!0,children:[o.jsxRuntimeExports.jsx(zn.ButtonTitle,{startIcon:a,onClick:()=>l(e),children:t}),s!=null&&o.jsxRuntimeExports.jsx(zn.Actions,{children:s})]}),n]})},cf=Object.freeze(Object.defineProperty({__proto__:null,Accordion:sf},Symbol.toStringTag,{value:"Module"})),af=(e,t)=>Z.A(e).map(s=>typeof s=="string"?s.split(t).map(r=>({label:r})):s).flat(),Ji=({segments:e,shade:t,level:n,weight:s,separator:r,transform:i})=>{let c=af(e,r);return i!=null&&(c=c.map(i)),c.map(({label:a,icon:d,href:x,...p},m)=>{const f=[o.jsxRuntimeExports.jsx(j.Lt.Caret.Right,{style:{transform:"scale(0.8) translateY(1px)",color:u.CSS.shade(t)}},`${a}-${m}`)];if(d!=null){const E=ke.resolve(d);E!=null&&f.push(E)}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(ve.Link,{...h,href:x},a)):f.push(o.jsxRuntimeExports.jsx(j.Text$1,{...h},a)),f}).flat()},uf=({children:e,icon:t,shade:n=7,weight:s,size:r=.5,url:i,level:l="p",separator:c=".",className:a,hideFirst:d=!0,...x})=>{i!=null&&(e=i);const p=Ji({segments:e,separator:c,shade:n,level:l,weight:s});return d&&p.shift(),o.jsxRuntimeExports.jsxs(j.WithIcon,{className:u.CSS(a,u.CSS.B("breadcrumb"),d&&u.CSS.M("hide-first")),level:l,shade:n,weight:s,size:r,direction:"x",...x,children:[ke.resolve(t),...p]})},df=({url:e,className:t,level:n="p",separator:s="/",weight:r,shade:i=7})=>{const l=Ji({segments:e,separator:s,shade:i,level:n,weight:r,transform:(c,a)=>({...c,label:c.label.split("-").map(d=>u.d.capitalize(d)).join(" "),href:`/${e.split(s).slice(0,a+1).join("/")}`})});return o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(t,u.CSS.B("breadcrumb"),u.CSS.BM("breadcrumb","url")),direction:"x",size:"small",align:"center",children:l})},xf=Object.freeze(Object.defineProperty({__proto__:null,Breadcrumb:uf,URL:df},Symbol.toStringTag,{value:"Module"})),Ao=g.createContext(B.ZERO_CONTEXT_VALUE),Fe=()=>g.useContext(Ao).synnax,pf=()=>g.useContext(Ao).state,Mr={connected:"success",connecting:"info",disconnected:"info",failed:"error"},Qi="serverVersionMismatch",mf=(e,t,n)=>`Cluster version ${n!=null?`${n} `:""}is ${e?"older":"newer"} than client version ${t}. Compatibility issues may arise.`,el=({children:e,connParams:t})=>{const[n,s,r]=j.useCombinedStateAndRef(B.ZERO_CONTEXT_VALUE),[{path:i},,l]=j.use$3({type:B.Provider.TYPE,schema:B.Provider.stateZ,initialState:{props:t??null,state:null}}),c=j.useAggregator(),a=g.useCallback(d=>{r.current.state.status!==d.status&&c({variant:Mr[d.status],message:d.message??u.d.capitalize(d.status)}),s(x=>({...x,state:d}))},[c]);return j.useAsyncEffect(async()=>{if(n.synnax!=null&&n.synnax.close(),t==null)return s(B.ZERO_CONTEXT_VALUE);const d=new Z.bg({...t,connectivityPollFrequency:Z.S$1.seconds(5)});s({synnax:d,state:{clusterKey:"",status:"connecting",message:"Connecting...",clientServerCompatible:!1,clientVersion:d.clientVersion}});const x=await d.connectivity.check();if(s({synnax:d,state:x}),c({variant:Mr[x.status],message:x.message??x.status.toUpperCase()}),x.status==="connected"&&!x.clientServerCompatible){const p=x.nodeVersion==null||Z.X.semVerOlder(x.nodeVersion,x.clientVersion),m=mf(p,x.clientVersion,x.nodeVersion);c({variant:"warning",message:"Incompatible cluster version",description:m,data:{type:Qi,oldServer:p,nodeVersion:x.nodeVersion,clientVersion:x.clientVersion}})}return d.connectivity.onChange(a),l({props:t,state:x}),()=>{d.close(),s(B.ZERO_CONTEXT_VALUE),l({props:null,state:null})}},[t,a]),o.jsxRuntimeExports.jsx(Ao.Provider,{value:n,children:o.jsxRuntimeExports.jsx(j.Composite,{path:i,children:e})})},ff=Object.freeze(Object.defineProperty({__proto__:null,Provider:el,SERVER_VERSION_MISMATCH:Qi,use:Fe,useConnectionState:pf},Symbol.toStringTag,{value:"Module"})),Yt=g.createContext({aliases:{},getName:async()=>await Promise.resolve(void 0),setAlias:null}),tl=()=>g.useContext(Yt),nl=e=>{const{aliases:t}=g.useContext(Yt);return t[e]??null},xs=()=>{const{aliases:e}=g.useContext(Yt);return e},ps=(e,t="")=>{const{getName:n}=g.useContext(Yt),[s,r]=g.useState(t);return j.useAsyncEffect(async()=>{const i=await n(e);r(i)},[e,n]),s??t},Io=()=>{const{activeRange:e}=g.useContext(Yt);return e??void 0},sl=({activeRange:e,children:t})=>{const n=Fe(),[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 j.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(Yt.Provider,{value:{aliases:s,activeRange:e,setAlias:e!=null?l:null,getName:c},children:t})},hf=({channelKey:e,value:t,shadow:n,className:s,...r})=>{const[i,l]=g.useState(!1),{setAlias:c}=tl(),a=nl(e),d=ps(e);let x=o.jsxRuntimeExports.jsx(j.Lt.Rename,{});i?x=o.jsxRuntimeExports.jsx(j.Lt.Loading,{}):a===t&&(x=o.jsxRuntimeExports.jsx(j.Lt.Check,{}));const p=c!=null&&!i&&a!==t&&e!==0,m=()=>{p&&(async()=>(l(!0),await c(e,t),l(!1)))()},f=()=>{var E;a!=null&&((E=r.onChange)==null||E.call(r,a))},h=()=>e===0?o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:"Select a channel to enable alias syncing with this label"}):c==null?o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:"Select a range to enable alias syncing with this label"}):t.length===0?o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:"Enter a value to enable alias syncing with this label"}):a===t?o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:"Alias synced with this label"}):o.jsxRuntimeExports.jsxs(j.Text$1,{level:"small",children:["Sync alias for ",d," with this label"]});return o.jsxRuntimeExports.jsxs(j.Text$2,{value:t,...r,children:[p&&o.jsxRuntimeExports.jsx(j.Icon,{onClick:f,tooltip:o.jsxRuntimeExports.jsxs(j.Text$1,{level:"small",children:["Set ",d," as label"]}),tooltipLocation:{y:"top"},variant:"outlined",children:o.jsxRuntimeExports.jsx(j.Lt.Sync,{})}),o.jsxRuntimeExports.jsx(j.Icon,{onClick:m,disabled:!p,tooltip:o.jsxRuntimeExports.jsx(h,{}),tooltipLocation:{y:"top"},variant:"outlined",children:x})]})},Ye="channel";var Lr=180/Math.PI,oo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ol(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)*Lr,skewX:Math.atan(a)*Lr,scaleX:l,scaleY:c}}var kn;function gf(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?oo:ol(t.a,t.b,t.c,t.d,t.e,t.f)}function jf(e){return e==null||(kn||(kn=document.createElementNS("http://www.w3.org/2000/svg","g")),kn.setAttribute("transform",e),!(e=kn.transform.baseVal.consolidate()))?oo:(e=e.matrix,ol(e.a,e.b,e.c,e.d,e.e,e.f))}function rl(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 E=f.push("translate(",null,t,null,n);h.push({i:E-4,x:B.interpolateNumber(d,p)},{i:E-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 E=f.push(r(f)+"scale(",null,",",null,")");h.push({i:E-4,x:B.interpolateNumber(d,p)},{i:E-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,E=m.length,y;++h<E;)p[(y=m[h]).i]=y.x(f);return p.join("")}}}var Ef=rl(gf,"px, ","px)","deg)"),yf=rl(jf,", ",")",")"),Sf=1e-12;function Pr(e){return((e=Math.exp(e))+1/e)/2}function Rf(e){return((e=Math.exp(e))-1/e)/2}function Cf(e){return((e=Math.exp(2*e))-1)/(e+1)}const bf=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,E=f*f+h*h,y,S;if(E<Sf)S=Math.log(m/d)/t,y=function(_){return[c+_*f,a+_*h,d*Math.exp(t*_*S)]};else{var k=Math.sqrt(E),C=(m*m-d*d+s*E)/(2*d*n*k),b=(m*m-d*d-s*E)/(2*m*n*k),w=Math.log(Math.sqrt(C*C+1)-C),L=Math.log(Math.sqrt(b*b+1)-b);S=(L-w)/t,y=function(_){var N=_*S,A=Pr(w),I=d/(n*k)*(A*Cf(t*N+w)-Rf(w));return[c+I*f,a+I*h,d*A/Pr(t*N+w)]}}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),wf=Object.freeze(Object.defineProperty({__proto__:null,Canvas:B.Canvas,axisStateZ:B.axisStateZ,newTickFactory:B.newTickFactory,tickFactoryProps:B.tickFactoryProps,tickType:B.tickType},Symbol.toStringTag,{value:"Module"})),vf=Object.freeze(Object.defineProperty({__proto__:null,AcquireChannelControl:B.AcquireChannelControl,AuthoritySource:B.AuthoritySource,Chip:B.Chip,Controller:B.Controller$1,Indicator:B.Indicator,Legend:B.Legend,REGISTRY:B.REGISTRY$3,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"})),kf={region:u.Tt.ZERO,dpr:1,os:Z.S.getOS()},_f={gl:null,lower2d:null,upper2d:null,bootstrapped:!1},Mf=({children:e,resizeDebounce:t=100,className:n,...s})=>{const[{path:r},{bootstrapped:i,dpr:l},c]=j.use$3({type:B.Canvas$1.TYPE,schema:B.canvasStateZ,initialState:kf}),a=g.useRef({..._f}),d=g.useRef(!1),x=g.useCallback(E=>{a.current.bootstrapped&&(c(()=>({bootstrapped:!0,region:E,dpr:window.devicePixelRatio,os:Z.S.getOS({default:"Windows"})})),d.current=!0)},[c]),p=g.useRef(null),m=j.useResize(x,{debounce:t}),f=j.useCombinedRefs(p,m);g.useEffect(()=>{const E=()=>{window.devicePixelRatio===l||!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.Tt.construct(p.current),dpr:window.devicePixelRatio}))};window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`).addEventListener("change",E,{once:!0})},[l]),g.useEffect(()=>{const E=()=>{!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.Tt.construct(p.current),glCanvas:void 0,upper2dCanvas:void 0,lower2dCanvas:void 0}))};window.addEventListener("focus",E),window.addEventListener("blur",E)},[c]);const h=g.useCallback(E=>{if(E==null)return;E.className.includes("gl")?a.current.gl=E:E.className.includes("upper2d")?a.current.upper2d=E:a.current.lower2d=E;const{gl:y,lower2d:S,upper2d:k,bootstrapped:C}=a.current;if(y==null||S==null||k==null||C)return;a.current.bootstrapped=!0;const b=y.transferControlToOffscreen(),w=k.transferControlToOffscreen(),L=S.transferControlToOffscreen();c({glCanvas:b,upper2dCanvas:w,lower2dCanvas:L,bootstrap:!0,bootstrapped:!1,region:u.Tt.construct(y),dpr:window.devicePixelRatio,os:Z.S.getOS({default:"Windows"})},[b,w,L])},[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(j.Composite,{path:r,children:i&&e})]})},En=(e,t)=>j.useResize(g.useCallback((n,s)=>{const r=document.querySelector(".pluto-canvas--lower2d");r!=null&&e(u.b.XY.translate(u.G.scale(u.Tt.topLeft(r),-1)).box(n),s)},[e]),t),Lf=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Mf,useRegion:En},Symbol.toStringTag,{value:"Module"})),il=g.createContext(null),We=e=>{const t=g.useContext(il);if(t==null)throw new Error(`Cannot to use ${e} as a non-child of LinePlot.`);return t},ll=e=>{const t=We("Viewport"),{addViewportHandler:n}=t;g.useEffect(()=>n(e),[n,e])},yn=(e,t)=>{const{setGridEntry:n,removeGridEntry:s}=We(t),{key:r}=e;return j.useEffectCompare(()=>{u.K.outer.parse(e.loc),n(e)},([c],[a])=>Z._.equal(c,a),[e]),g.useEffect(()=>()=>s(r),[]),{gridArea:u.g.swap(u.K.direction(e.loc))==="x"?`axis-start-${r} / plot-start / axis-end-${r} / plot-end`:`plot-start / axis-start-${r} / plot-end / axis-end-${r}`}},cl=({aetherKey:e,style:t,resizeDebounce:n=0,clearOverScan:s=u.G.ZERO,children:r,hold:i=!1,onHold:l,visible:c,...a})=>{const[d,x]=g.useState([]),p=j.useMemoDeepEqualProps({clearOverScan:s,hold:i,visible:c}),[{path:m},{grid:f},h]=j.use$3({aetherKey:e,type:B.LinePlot.TYPE,schema:B.linePlotStateZ,initialState:{container:u.Tt.ZERO,viewport:u.Tt.DECIMAL,grid:{},...p}});g.useEffect(()=>h($=>({...$,...p})),[p]);const E=g.useRef(new Map),y=g.useCallback($=>(E.current.set($,null),()=>E.current.delete($)),[E]),S=g.useCallback($=>{const{mode:z,box:R,stage:T}=$;(z==="pan"&&T!=="start"||z==="zoom"||z==="zoomReset"&&T==="start")&&h(M=>({...M,viewport:R})),E.current.forEach((M,D)=>D($))},[h]),k=g.useCallback($=>h(z=>({...z,container:$})),[h]),C=En(k,{debounce:n}),b=g.useCallback($=>h(z=>({...z,grid:{...z.grid,[$.key]:$}})),[h]),w=g.useCallback($=>h(z=>{const{[$]:R,...T}=z.grid;return{...z,grid:T}}),[h]),L=g.useCallback($=>{x(z=>[...z.filter(({key:R})=>R!==$.key),$])},[x,S]),_=g.useCallback($=>x(z=>z.filter(({key:R})=>R!==$)),[L]),N=g.useMemo(()=>Pf(f),[f]),A=g.useCallback($=>{h(z=>({...z,hold:$})),l==null||l($)},[h,l]),I=`line-plot-${e}`,F=g.useMemo(()=>({lines:d,setGridEntry:b,removeGridEntry:w,setLine:L,removeLine:_,setViewport:S,addViewportHandler:y,setHold:A,id:I}),[I,d,b,w,L,_,S,y,A]);return o.jsxRuntimeExports.jsx("div",{id:I,className:u.CSS.B("line-plot"),style:{...t,...N},ref:C,...a,children:o.jsxRuntimeExports.jsx(il.Provider,{value:F,children:o.jsxRuntimeExports.jsx(j.Composite,{path:m,children:r})})})},Pf=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()},$o=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:E,bounds:y,className:S,tickSpacing:k,autoBounds:C,autoBoundUpdateInterval:b,onAutoBoundsChange:w,style:L,..._})=>{const N=((a==null?void 0:a.length)??0)>0,A=j.useUniqueKey(i),I=j.useMemoDeepEqualProps({location:c,showGrid:h,type:E,bounds:y,label:a,labelDirection:x,tickSpacing:k,autoBounds:C,autoBoundUpdateInterval:b}),[{path:F},{size:$,labelSize:z,...R},T]=j.use$3({aetherKey:A,type:n,schema:B.coreAxisStateZ,initialState:I});g.useEffect(()=>T(V=>({...V,...I})),[I]),g.useEffect(()=>{const{lower:V,upper:H}=B.parseAutoBounds(R.autoBounds);R.bounds!=null&&(V&&(y==null?void 0:y.lower)!==R.bounds.lower||H&&(y==null?void 0:y.upper)!==R.bounds.upper)&&(w==null||w(R.bounds))},[R.autoBounds,R.bounds]);const M=yn({loc:c,key:`${n}-${A}`,size:$+z,order:1},`${e.toUpperCase()}Axis`),D=j.useTypography(d).toString(),P=g.useRef(0);return g.useEffect(()=>{if(e==="y"){if(a==null)return;let H=Z.dimensions(a,D)[u.g.dimension(u.g.construct(x))];H>0&&(H+=9),T(G=>({...G,labelSize:H}))}else{let H=Z.dimensions(a,D).height*1.3;H>0&&(H+=12);const G=P.current;B.withinSizeThreshold(G,H)||(P.current=H,T(q=>({...q,labelSize:H})))}},[a,x,D]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(S,u.CSS.B("axis"),u.CSS.B(s),u.CSS.loc(c)),style:{...L,...M},align:"center",justify:c!=="left"?"end":"start",direction:u.g.swap(e),..._,children:N&&o.jsxRuntimeExports.jsx(j.MaybeEditable,{className:u.CSS(u.CSS.BE("axis","label"),u.CSS.dir(x)),value:a,onChange:p,level:d})}),o.jsxRuntimeExports.jsx(j.Composite,{path:F,children:l})]})};return r.displayName=`${e.toUpperCase()}Axis`,r},al=$o("x"),ul=$o("y"),dl=u.G.xy.extend({root:u.K.corner,units:ce.z.object({x:ce.z.enum(["px","decimal"]),y:ce.z.enum(["px","decimal"])})}),Tf=dl.partial({root:!0,units:!0}),Nf=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},Af=(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.Tt.construct(t.current),r=u.Tt.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.Tt.width(s))/u.Tt.width(r):n.x/=u.Tt.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.Tt.height(s))/u.Tt.height(r):n.y/=u.Tt.height(r),n},xl=(e,t)=>{if(t.current==null)return null;const n=u.Tt.construct(t.current.parentElement),s=u.Tt.construct(t.current),r={x:e.x,y:e.y,root:{...u.K.TOP_LEFT},units:{x:"px",y:"px"}};return e.x>.8?(r.x=(1-e.x)*u.Tt.width(n)-u.Tt.width(s),r.root.x="right"):e.x<.2?r.x=e.x*u.Tt.width(n):r.units.x="decimal",e.y>.8?(r.y=(1-e.y)*u.Tt.height(n)-u.Tt.height(s),r.root.y="bottom"):e.y<.2?r.y=e.y*u.Tt.height(n):r.units.y="decimal",r.x=Math.round(r.x*100)/100,{...r,...u.G.truncate(r,3)}},Tr=u.Tt.reRoot(u.Tt.DECIMAL,u.K.TOP_LEFT),zo=g.memo(({className:e,value:t,onChange:n,style:s,draggable:r=!0,...i})=>{const[l,c]=Z.usePurePassthrough({value:t,onChange:n,initial:{x:.1,y:.1,root:u.K.TOP_LEFT,units:{x:"decimal",y:"decimal"}}}),a=g.useRef(l),d=j.useSyncedRef(r===!1),x=g.useRef(null);l!==null&&(s={...s,...Nf(l)});const p=g.useCallback(f=>{var b;if(((b=x.current)==null?void 0:b.parentElement)==null)return a.current;const h=u.Tt.construct(x.current.parentElement),E=u.b.XY.scale(h).scale(Tr),y=E.box(u.Tt.construct(x.current)),S=u.b.XY.clamp(u.Tt.construct(u.Tt.topLeft(Tr),{width:1-u.Tt.width(y),height:1-u.Tt.height(y)})),k=u.G.translate(u.G.construct(a.current),u.Tt.signedDims(E.box(f))),C=S.pos(k);return xl(C,x)},[]),m=j.useCursorDrag({onStart:g.useCallback(()=>{a.current=Af(a.current,x)},[]),onMove:g.useCallback(f=>{if(d.current)return;const h=p(f);h!==null&&c(h)},[]),onEnd:g.useCallback(f=>{if(d.current)return;const h=p(f);h!==null&&(a.current=h)},[])});return o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(e,u.CSS.B("legend")),bordered:!0,rounded:!0,style:s,onDragStart:m,draggable:r,ref:x,...i,onDrag:Yn,onDragEnd:Yn,empty:!0})});zo.displayName="Legend.Container";const Bo=(e,t,n)=>e.sort((s,r)=>s.label.localeCompare(r.label)).map(({key:s,color:r,label:i})=>o.jsxRuntimeExports.jsxs(te.Space,{style:{cursor:"pointer"},direction:"x",align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(j.Swatch,{value:r,onChange:l=>t==null?void 0:t({key:s,color:l,label:i}),onVisibleChange:n,allowChange:t!=null,draggable:!1,size:"small"}),o.jsxRuntimeExports.jsx(j.MaybeEditable,{level:"small",value:i,onChange:l=>t==null?void 0:t({key:s,color:r,label:l}),noWrap:!0})]},s)),Do=({data:e=[],onEntryChange:t,position:n,onPositionChange:s,...r})=>{const[i,l]=g.useState(!1);return e.length===0?null:o.jsxRuntimeExports.jsx(zo,{...r,draggable:!i,value:n,onChange:s,children:Bo(e,t,l)})},If=Object.freeze(Object.defineProperty({__proto__:null,Container:zo,Simple:Do,calcStickyPos:xl,completeStickyXYz:dl,legendSwatches:Bo,stickyXYz:Tf},Symbol.toStringTag,{value:"Module"})),Oo=g.memo(({className:e,style:t,onLineChange:n,...s})=>{const{lines:r}=We("Legend");return We("Legend"),o.jsxRuntimeExports.jsx(Do,{data:r,onEntryChange:n,...s})});Oo.displayName="FloatingLegend";const $f=({onLineChange:e})=>{const{lines:t}=We("Legend"),n=j.useUniqueKey(),s=yn({key:n,size:t.length>0?36:0,loc:"top",order:5},"Legend");return o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS.BE("legend","container"),align:"center",direction:"x",size:"large",style:{...s,padding:"0 1rem",height:"var(--pluto-height-medium)",margin:"1rem 0 "},children:Bo(t,e)})},pl=({variant:e="floating",...t})=>e==="floating"?o.jsxRuntimeExports.jsx(Oo,{...t}):o.jsxRuntimeExports.jsx($f,{...t}),Vo=g.memo(({aetherKey:e,...t})=>(j.useUnidirectional({aetherKey:e,type:B.Line.TYPE,schema:B.stateZ,state:t}),null));Vo.displayName="Line";const zf=Object.freeze(Object.defineProperty({__proto__:null,Line:Vo},Symbol.toStringTag,{value:"Module"})),Fo=({aetherKey:e,color:t,label:n="",...s})=>{const r=j.useUniqueKey(e),{setLine:i,removeLine:l}=We("Line");return g.useEffect(()=>(i({key:r,color:t,label:n}),()=>l(r)),[n,t]),o.jsxRuntimeExports.jsx(Vo,{aetherKey:r,color:t,label:n,...s})},ml=({level:e="h2",...t})=>{const n=j.useUniqueKey(),s=j.useTypography(e),r=yn({key:n,size:(s.lineHeight+2)*s.baseSize,loc:"top",order:10},"Title");return o.jsxRuntimeExports.jsx(te.Space,{justify:"center",align:"center",style:r,children:o.jsxRuntimeExports.jsx(j.MaybeEditable,{...t,level:e})})},fl=({aetherKey:e,...t})=>{const n=j.useUniqueKey(e),[,,s]=j.use$3({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.Tt.topLeft(a);s({position:u.G.translation(d,u.G.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})},Bf=Object.freeze(Object.defineProperty({__proto__:null,Tooltip:fl},Symbol.toStringTag,{value:"Module"})),Df={select:"pointer",zoom:"crosshair",pan:"grab",zoomReset:"crosshair",click:"pointer"},hl=({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:Df[t],...r},...i,children:[o.jsxRuntimeExports.jsx("div",{style:{...u.Tt.css(n),display:u.Tt.areaIsZero(n)?"none":"block"},className:u.CSS.BE("viewport-mask","selection")}),s]}),Of=[{key:"start",icon:o.jsxRuntimeExports.jsx(j.Lt.TextAlign.Left,{})},{key:"center",icon:o.jsxRuntimeExports.jsx(j.Lt.TextAlign.Center,{})},{key:"end",icon:o.jsxRuntimeExports.jsx(j.Lt.TextAlign.Right,{})}],Vf=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(j.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),ms=({children:e=Vf,...t})=>o.jsxRuntimeExports.jsx(ve.Button,{...t,allowMultiple:!1,data:Of,children:e}),Ff=[{key:"large",label:"L"},{key:"medium",label:"M"},{key:"small",label:"S"}],gl=({children:e,...t})=>o.jsxRuntimeExports.jsx(ve.Button,{...t,data:Ff,entryRenderKey:"label",children:e}),Hf=new Set([Z.g.UUID,Z.g.JSON]),jl=Z.g.ALL.filter(e=>e!==Z.g.UNKNOWN).map(e=>({key:e.toString(),name:Hf.has(e)?e.toString().toUpperCase():u.d.capitalize(e.toString())})),Zf=jl.filter(e=>!new Z.g(e.key).isVariable),Gf=[{key:"name",name:"Name"}],Yf=({hideVariableDensity:e=!1,...t})=>o.jsxRuntimeExports.jsx(ve.DropdownButton,{...t,data:e?Zf:jl,columns:Gf,entryRenderKey:"name"}),Wf=[{key:"x",icon:o.jsxRuntimeExports.jsx(j.Lt.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(j.Lt.Arrow.Up,{})}],Kf=[{key:"x",icon:o.jsxRuntimeExports.jsx(j.Lt.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(j.Lt.Arrow.Down,{})}],Xf=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(j.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),El=({children:e=Xf,yDirection:t="up",...n})=>o.jsxRuntimeExports.jsx(ve.Button,{...n,allowMultiple:!1,data:t==="up"?Wf:Kf,children:e}),yl=e=>o.jsxRuntimeExports.jsx(j.Icon,{className:u.CSS.BE("select","clear"),variant:"outlined",...e,children:o.jsxRuntimeExports.jsx(j.Lt.Close,{"aria-label":"clear"})}),xt=({onChange:e,value:t,entryRenderKey:n="key",columns:s,data:r,emptyContent:i,inputProps:l,allowNone:c=!0,searcher:a,className:d,variant:x="button",hideColumnHeader:p=!1,disabled:m,omit:f,children:h,dropdownVariant:E="connected",placeholder:y=fs,inputPlaceholder:S=y,triggerTooltip:k,dropdownZIndex:C,filter:b,actions:w,...L})=>{const{visible:_,open:N,close:A,toggle:I}=j.use$2(),[F,$]=g.useState(null),z=a!=null;j.useAsyncEffect(async()=>{if(j.selectValueIsZero(t))return $(null);if((F==null?void 0:F.key)===t)return;let P=null;if(z)try{[P]=await a.retrieve([t])}finally{P??(P=null)}else r!=null&&(P=r.find(V=>V.key===t)??null);$(P)},[a,t,r]);const R=g.useCallback((P,V)=>{Array.isArray(P)||($(P==null?null:V.entries[0]),A(),e(P,V))},[e,c]),T=g.useMemo(()=>z?j.Search:Gt.Filter,[z]),M=o.jsxRuntimeExports.jsx(T,{searcher:a,filter:b,children:({onChange:P})=>o.jsxRuntimeExports.jsx(qf,{...l,autoFocus:E==="modal",variant:x,onChange:P,onFocus:N,selected:F,entryRenderKey:n,visible:_,allowNone:c,className:d,dropdownVariant:E,disabled:m,placeholder:S,children:w})}),D=o.jsxRuntimeExports.jsx(j.Button,{tooltip:k,variant:"outlined",onClick:I,disabled:m,children:F!=null?Sl(n,F):y});return o.jsxRuntimeExports.jsx(ve.Core,{close:A,zIndex:C,open:N,data:r,omit:f,emptyContent:i,allowMultiple:!1,visible:_,value:t,hideColumnHeader:p,onChange:R,allowNone:c,columns:s,listItem:h,variant:E,trigger:E!=="modal"?M:D,extraDialogContent:E==="modal"?M:void 0,keepMounted:!1,...L})},fs="Select",Sl=(e,t)=>t==null?"":typeof e=="function"?e(t):t[e].toString(),qf=({entryRenderKey:e,selected:t,visible:n,onChange:s,onFocus:r,allowNone:i=!0,placeholder:l=fs,className:c,disabled:a,dropdownVariant:d,children:x,...p})=>{const{clear:m}=j.useSelectionUtils(),[f,h]=g.useState("");g.useEffect(()=>{if(!n){if(Z.w$1(t==null?void 0:t.key))return h("");t!=null&&h(Sl(e,t))}},[t,n,e]);const E=b=>{s(b),h(b)},y=()=>{f===""&&s(""),h(""),r==null||r()},S=b=>{n||(b.preventDefault(),r==null||r())},k=()=>{h(""),m==null||m()};let C;return d!=="modal"&&(C=o.jsxRuntimeExports.jsx(_o.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:n})),o.jsxRuntimeExports.jsxs(j.Text$2,{className:u.CSS(u.CSS.BE("select","input"),c),value:f,onChange:E,onFocus:y,onKeyDown:j.matchCallback([["Enter"]],b=>{b.preventDefault(),!n&&(r==null||r())}),endContent:C,style:{flexGrow:1},onClick:S,placeholder:l,disabled:a,...p,children:[x,i&&o.jsxRuntimeExports.jsx(yl,{onClick:k,disabled:a})]})},an=({children:e="",size:t="medium",color:n,icon:s,onClose:r,className:i,onDragStart:l,...c})=>{const a=u.cssString(n);s==null&&n!=null&&(s=o.jsxRuntimeExports.jsx(j.Lt.Circle,{fill:a}));const d=r==null?void 0:o.jsxRuntimeExports.jsx(j.Icon,{"aria-label":"close",size:"small",className:u.CSS.BE("tag","close"),onClick:x=>{x.stopPropagation(),r()},children:o.jsxRuntimeExports.jsx(j.Lt.Close,{})});return o.jsxRuntimeExports.jsx(j.WithIcon,{startIcon:s,endIcon:d,className:u.CSS(i,u.CSS.B("tag"),r!=null&&u.CSS.BM("tag","closeable")),level:Z.ComponentSizeLevels[t],noWrap:!0,align:"center",onDragStart:l,...c,children:e})},Uf=Object.freeze(Object.defineProperty({__proto__:null,Tag:an},Symbol.toStringTag,{value:"Module"})),Ho=({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(an,{size:"small",variant:"outlined",className:u.CSS(n==null&&!s&&u.CSS.BEM("select-multiple","tag","invalid")),draggable:!0,...r,key:e.toString()},Z.Y(i))},Jf=j.componentRenderProp(Ho),Wt=({onChange:e,value:t,className:n,data:s,columns:r=[],entryRenderKey:i="key",emptyContent:l,searcher:c,renderTag:a=Jf,placeholder:d,onTagDragStart:x,allowMultiple:p,allowNone:m,replaceOnSingle:f,onTagDragEnd:h,style:E,addPlaceholder:y="Add",children:S,dropdownVariant:k="connected",actions:C,...b})=>{const{visible:w,open:L,close:_}=j.use$2(),[N,A]=g.useState([]),[I,F]=g.useState(!1),$=c!=null;j.useAsyncEffect(async()=>{F(!0),j.selectValueIsZero(t)&&A([]);const D=N.map(H=>H.key),P=Z.A(t);if(Z.F.unorderedPrimitiveArrays(D,P)===Z.F.EQUAL)return;let V=[];if($)try{V=await c.retrieve(P)}finally{F(!1)}else s!=null&&(V=s.filter(H=>P.includes(H.key)));A(V)},[c,$,t,s]);const z=g.useCallback((D,P)=>{D!=null&&(A(P.entries),e(Z.A(D),P))},[e]),R=g.useMemo(()=>$?j.Search:Gt.Filter,[$]);let T,M;if(k==="connected")M=o.jsxRuntimeExports.jsx(R,{searcher:c,children:({onChange:D,value:P})=>o.jsxRuntimeExports.jsx(Qf,{dropdownVariant:k,value:P,selectedKeys:t,className:n,onChange:D,loading:I,selected:N,onFocus:L,entryRenderKey:i,visible:w,renderTag:a,placeholder:d,onTagDragStart:x,onTagDragEnd:h,style:E,children:C})});else{const D=Z.A(t);M=o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",align:"center",grow:!0,style:E,size:"small",children:[D.map(P=>{const V=N.find(H=>H.key===P);return a({key:P,entryKey:P,entryRenderKey:i,loading:I,entry:V,onClose:()=>{const H=D.filter(G=>G!==P);e(H,{clicked:null,clickedIndex:-1,entries:[]})},onDragStart:H=>x==null?void 0:x(H,P),onDragEnd:H=>h==null?void 0:h(H,P)})}),D.length>0?o.jsxRuntimeExports.jsx(j.Icon,{onClick:L,children:o.jsxRuntimeExports.jsx(j.Lt.Add,{style:{color:"var(--pluto-gray-l7)"}})}):o.jsxRuntimeExports.jsx(j.Button,{onClick:L,shade:7,startIcon:o.jsxRuntimeExports.jsx(j.Lt.Add,{}),variant:"text",children:y})]}),T=o.jsxRuntimeExports.jsx(R,{searcher:c,children:P=>o.jsxRuntimeExports.jsx(j.Text$2,{autoFocus:!0,placeholder:"Search",...P,children:C})})}return o.jsxRuntimeExports.jsx(ve.Core,{close:_,open:L,data:s,emptyContent:l,visible:w,value:t,onChange:z,allowNone:m,replaceOnSingle:f,columns:r,allowMultiple:!0,listItem:S,trigger:M,extraDialogContent:T,variant:k,...b})},Qf=({selectedKeys:e,loading:t,selected:n,onChange:s,onFocus:r,visible:i,entryRenderKey:l,renderTag:c,placeholder:a=fs,onTagDragStart:d,onTagDragEnd:x,value:p,className:m,children:f,dropdownVariant:h,...E})=>{const{onSelect:y,clear:S}=j.useSelectionUtils(),k=g.useRef(null);g.useLayoutEffect(()=>{var _;i&&((_=k.current)==null||_.focus())},[i,n]);const C=()=>{i||s(""),r==null||r()},b=()=>{i||r==null||r()},w=()=>{i||s("")};let L;return h!=="modal"&&(L=o.jsxRuntimeExports.jsx(_o.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:i})),o.jsxRuntimeExports.jsxs(j.Text$2,{ref:k,className:u.CSS(u.CSS.BE("select-multiple","input"),u.CSS.visible(i),m),onBlur:w,placeholder:a,value:p,onChange:s,onFocus:C,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",onClick:b,endContent:L,variant:"button",...E,children:[o.jsxRuntimeExports.jsx(te.Space,{direction:"x",className:u.CSS.BE("select-multiple","tags"),align:"center",grow:!0,size:"small",children:Z.A(e).map(_=>{const N=n.find(A=>A.key===_);return c({key:_,entryKey:_,entryRenderKey:l,loading:t,entry:N,onClose:()=>y==null?void 0:y(_),onDragStart:A=>d==null?void 0:d(A,_),onDragEnd:A=>x==null?void 0:x(A,_)})})}),f,o.jsxRuntimeExports.jsx(yl,{onClick:S})]})},eh=Object.freeze(Object.defineProperty({__proto__:null,BaseButton:ve.BaseButton,Button:ve.Button,ComponentSize:gl,DEFAULT_PLACEHOLDER:fs,DataType:Yf,Direction:El,DropdownButton:ve.DropdownButton,Multiple:Wt,MultipleTag:Ho,Single:xt,TextAlignment:ms,defaultButton:ve.defaultButton},Symbol.toStringTag,{value:"Module"})),Dn=6,th=2,Nr=5,nh=e=>u.Tt.width(e)<Nr&&u.Tt.height(e)<Nr,sh=["zoom","pan","select","zoomReset"],on=[...sh,"click"],oh=ce.z.enum(on),Rl=["zoom","select"],On={defaultMode:"zoom",zoom:[["MouseLeft"]],zoomReset:[["MouseLeft","Control"]],pan:[["MouseLeft","Shift"]],select:[["MouseLeft","Alt"]]},Cl={defaultMode:"pan",pan:[["MouseLeft"]],zoom:[["MouseLeft","Shift"]],zoomReset:[["MouseLeft","Control"]],select:[["MouseLeft","Alt"]]},bl={defaultMode:"select",select:[["MouseLeft"]],pan:[["MouseLeft","Shift"]],zoom:[["MouseLeft","Alt"]],zoomReset:[["MouseLeft","Control"]]},Zo={zoom:On,pan:Cl,select:bl,zoomReset:On,click:On},rh=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)]))},ih=u.Tt.construct(0,0,1,1,u.K.TOP_LEFT),lh={width:30,height:50},wl=({onChange:e,triggers:t,initial:n=ih,threshold:s=lh,ref:r})=>{const i=(t==null?void 0:t.defaultMode)??"zoom",[l,c]=g.useState(u.Tt.ZERO),[a,d]=g.useState(i),[x,p]=j.useStateRef(n),m=g.useRef(u.G.ZERO),f=g.useRef(null),h=u._.construct(s);g.useEffect(()=>p(()=>u.Tt.truncate(n,Dn)),[n]),g.useEffect(()=>d(i),[i]);const[E,y,S,k]=j.useMemoCompare(()=>{const N={...Zo[i],...t},A=j.flattenConfig(N),I=rh(N);return[N,A,I,j.flattenConfig(I)]},j.compareModeConfigs,[t]),C=g.useCallback(({box:N,triggers:A,stage:I,cursor:F})=>{if(f.current==null)return;const $=j.determineMode(E,A),z=u.Tt.construct(f.current);if($==null)return;if($==="zoomReset")return c(u.Tt.ZERO),e==null||e({box:u.Tt.DECIMAL,mode:$,stage:I,cursor:F}),p(u.Tt.DECIMAL);const R=nh(N);if(I==="end"){if(R){$==="zoom"&&c(u.Tt.ZERO),e==null||e({box:x.current,mode:"click",stage:I,cursor:F});return}return p(M=>{if($==="pan"){const P=Ar(N,M,z);return P===null||u.Tt.equals(P,M)?M:(e==null||e({box:P,mode:$,stage:I,cursor:F}),P)}const D=b(N,M,z);return D===null?M:(e==null||e({box:D,mode:$,stage:I,cursor:F}),$==="zoom"?(c(u.Tt.ZERO),D):u.Tt.truncate(M,Dn))})}if(Rl.includes($))return R?void 0:c(u.b.XY.scale(z).clamp(z).translate({x:-u.Tt.left(z),y:-u.Tt.top(z)}).box(Ir(h,N,z)));if(c(M=>u.Tt.areaIsZero(M)?M:u.Tt.ZERO),u.G.distance(F,m.current)<th)return;m.current=F;const T=Ar(N,x.current,z);e==null||e({box:T,mode:$,stage:I,cursor:F})},[c,d,e,E,s.height,s.width,p,f]);g.useImperativeHandle(r,()=>({reset:()=>{c(u.Tt.ZERO),p(u.Tt.DECIMAL),e==null||e({box:u.Tt.DECIMAL,mode:"zoomReset",stage:"start",cursor:u.G.ZERO})}}),[e]);const b=g.useCallback((N,A,I)=>u.Tt.truncate(ro(A,I).box(Ir(h,N,I)),Dn),[s]),w=j.useHeldRef({triggers:[["Control"]]}),L=j.useHeldRef({triggers:[["Alt"]]});g.useEffect(()=>{const N=A=>{if(f.current==null)return;let I=1;A.deltaY<0?I-=.035:I+=.035;const F=u.Tt.construct(f.current),$=u.G.construct(A);if(Array.from(f.current.children).push(f.current),!u.Tt.contains(F,$)||f.current!==A.target&&j.findParent(A.target,P=>P===f.current)==null)return;const T=ro(x.current,u.Tt.construct(f.current)).pos(u.G.construct(A));let D=u.b.XY.magnify({x:w.current.held?1:I,y:L.current.held?1:I}).box(x.current);D=u.Tt.translate(D,{x:w.current.held?0:T.x*(1-I),y:L.current.held?0:T.y*(1-I)}),p(D),e==null||e({stage:"end",box:D,cursor:u.G.construct(A),mode:"zoom"})};return window.addEventListener("wheel",N),()=>window.removeEventListener("wheel",N)},[p,e]),Wi.useDrag({bound:f,onDrag:C,triggers:y,loose:!0});const _=g.useCallback(({triggers:N,stage:A})=>{if(A==="end")return d(i);const I=j.determineMode(S,N);I!=null&&d(I)},[S,i,e]);return j.use$1({triggers:k,callback:_,region:f}),{maskBox:l,ref:f,mode:a}},ro=(e,t)=>u.b.XY.scale(t).clamp(t).scale(e),Ar=(e,t,n)=>{let s=u.Tt.signedDims(ro(t,n).box(e));return s={signedWidth:-s.signedWidth,signedHeight:-s.signedHeight},u.Tt.truncate(u.b.XY.translate(u.G.construct(s)).box(t),Dn)},Ir=(e,t,n)=>u.Tt.height(t)<=e.height?u.Tt.construct(u.Tt.left(t),u.Tt.top(n),u.Tt.width(t),u.Tt.height(n)):u.Tt.width(t)<=e.width?u.Tt.construct(u.Tt.left(n),u.Tt.top(t),u.Tt.width(n),u.Tt.height(t)):t,ch=({mode:e,triggers:t})=>o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",align:"center",children:[o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:u.d.capitalize(e)}),o.jsxRuntimeExports.jsx(te.Space,{empty:!0,direction:"x",align:"center",children:o.jsxRuntimeExports.jsx(j.Text,{trigger:t[0],level:"small"})})]}),ah={zoom:o.jsxRuntimeExports.jsx(j.Lt.Zoom,{}),pan:o.jsxRuntimeExports.jsx(j.Lt.Pan,{}),select:o.jsxRuntimeExports.jsx(j.Lt.Selection,{}),zoomReset:o.jsxRuntimeExports.jsx(j.Lt.Expand,{}),click:o.jsxRuntimeExports.jsx(j.Lt.Bolt,{})},uh=({triggers:e,disable:t=["zoomReset","click"],...n})=>{const s=Object.entries(e).filter(([r])=>!t.includes(r)&&on.includes(r)).map(([r,i])=>({key:r,icon:ah[r],tooltip:o.jsxRuntimeExports.jsx(ch,{mode:r,triggers:i})})).sort((r,i)=>on.indexOf(r.key)-on.indexOf(i.key));return o.jsxRuntimeExports.jsx(ve.Button,{...n,data:s,entryRenderKey:"icon",children:({title:r,entry:i,...l})=>g.createElement(j.Icon,{...l,key:i.key,variant:l.selected?"filled":"text",size:"medium",tooltip:i.tooltip,tooltipLocation:{x:"right",y:"top"}},i.icon)})},dh=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_TRIGGERS:Zo,MASK_MODES:Rl,MODES:on,Mask:hl,PAN_DEFAULT_TRIGGERS:Cl,SELECT_DEFAULT_TRIGGERS:bl,SelectMode:uh,ZOOM_DEFAULT_TRIGGERS:On,modeZ:oh,use:wl},Symbol.toStringTag,{value:"Module"})),xh=e=>e==null?null:e.closest(".pluto-line-plot__viewport")??null,vl=({ref:e,children:t,initial:n=u.Tt.DECIMAL,onChange:s,...r})=>{const{setViewport:i}=We("Viewport");g.useLayoutEffect(()=>{i({box:n,mode:"zoom",cursor:u.G.ZERO,stage:"start"})},[i,n]);const l=g.useCallback(a=>{i(a),s==null||s(a)},[s,i]),c=wl({onChange:l,initial:n,ref:e,...r});return o.jsxRuntimeExports.jsx(hl,{className:u.CSS.BE("line-plot","viewport"),...c,children:t})},ph=Object.freeze(Object.defineProperty({__proto__:null,Floating:Oo,Legend:pl,Line:Fo,LinePlot:cl,Title:ml,Tooltip:Bf,Viewport:vl,XAxis:al,YAxis:ul,axisFactory:$o,selectViewportEl:xh,useContext:We,useGridEntry:yn,useViewport:ll},Symbol.toStringTag,{value:"Module"})),mh=({aetherKey:e,...t})=>(j.use$3({aetherKey:e,type:B.Annotation.TYPE,schema:B.annotationStateZ,initialState:t}),null),kl=({aetherKey:e,menu:t,...n})=>{const s=j.useUniqueKey(e),{setViewport:r,setHold:i}=We("Range.Provider"),[,{hovered:l,count:c},a]=j.use$3({aetherKey:s,type:B.Provider$1.TYPE,schema:B.providerStateZ,initialState:{...n,cursor:null,hovered:null,count:0}}),d=yn({key:s,loc:"top",size:c>0?32:0,order:3},"Annotation.Provider"),x=j.useContextMenu(),p=j.useSyncedRef(x.visible),m=g.useCallback(f=>{const h=y=>{a(S=>({...S,cursor:{x:y.clientX,y:y.clientY}}))},E=f.currentTarget;E.addEventListener("mousemove",h),E.addEventListener("mouseleave",()=>{E.removeEventListener("mousemove",h),p.current||a(y=>({...y,cursor:null}))},{once:!0})},[a]);return o.jsxRuntimeExports.jsx(j.ContextMenu,{style:{...d,cursor:l!=null?"pointer":"default"},...x,menu:()=>t==null||l==null?null:t(l),children:o.jsxRuntimeExports.jsx(te.Space,{style:{width:"100%",height:"100%"},onClick:()=>{l!=null&&(r({box:u.Tt.construct({x:l.viewport.lower,y:0},{x:l.viewport.upper,y:1}),mode:"zoom",cursor:u.G.ZERO,stage:"start"}),i(!0))},onMouseEnter:m})})},fh=Object.freeze(Object.defineProperty({__proto__:null,Annotation:mh,Provider:kl},Symbol.toStringTag,{value:"Module"})),_l={defaultMode:"empty",one:[["1"]],two:[["2"]],clear:[["Shift"]],empty:[[]]},hh=j.flattenConfig(_l),Ml=({aetherKey:e})=>{const t=j.useUniqueKey(e),[,,n]=j.use$3({aetherKey:t,type:B.Measure.TYPE,schema:B.measureStateZ,initialState:{hover:null,one:null,two:null}}),s=g.useRef(null),r=j.useHeldRef({triggers:hh,loose:!0}),i=g.useCallback(({mode:a,cursor:d})=>{if(a==="click"){const x=j.determineMode(_l,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]);ll(i);const l=g.useCallback(a=>n(d=>({...d,hover:u.G.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})},gh=Object.freeze(Object.defineProperty({__proto__:null,Measure:Ml},Symbol.toStringTag,{value:"Module"})),Go=({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,E]=Z.usePurePassthrough({value:t,onChange:s,initial:""}),y=j.useSyncedRef(r),[,{pixelPosition:S},k]=j.use$3({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 R;z!=null&&((R=y.current)==null||R.call(y,z))},[y])}),C=g.useRef(S);S!==C.current&&(C.current=S);const{id:b}=We("Rule"),w=document.getElementById(b),L=w==null?void 0:w.querySelector(".pluto-line-plot__viewport"),_=g.useRef(S);g.useEffect(()=>{k(z=>({...z,position:n,color:c,lineWidth:a,lineDash:d}))},[n,c,a,d]);const N=j.useCursorDrag({onStart:g.useCallback(()=>{p==null||p(),k(z=>({...z,dragging:!0})),_.current=C.current},[]),onMove:z=>{k(R=>({...R,pixelPosition:(_.current??0)+u.Tt.signedHeight(z)}))},onEnd:g.useCallback(()=>{k(z=>({...z,dragging:!1})),_.current=S},[])}),A=g.useRef(null);if(n==null||S==null)return null;const F=new u.Color(c).pickByContrast("#000000","#ffffff"),$=o.jsxRuntimeExports.jsxs("div",{ref:A,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:N,draggable:!0}),o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",align:"center",className:u.CSS(x,u.CSS.BE("rule","tag")),bordered:!0,onClick:p,size:1,rounded:!0,style:{borderColor:u.cssString(c),backgroundColor:new u.Color(c).setAlpha(.7).hex,...m},...f,children:[o.jsxRuntimeExports.jsx(j.Editable,{className:u.CSS.B("label"),level:"small",value:h,onChange:E,color:F}),o.jsxRuntimeExports.jsx(j.Divider,{direction:"y",style:{borderColor:u.cssString(c)}}),o.jsxRuntimeExports.jsxs(te.Space,{size:"small",direction:"x",align:"center",children:[o.jsxRuntimeExports.jsx(j.Editable,{value:n.toFixed(2),onChange:z=>{const R=Number(z);isFinite(R)&&(r==null||r(R))},level:"small",color:F}),o.jsxRuntimeExports.jsx(j.MaybeEditable,{level:"small",color:F,value:l,onChange:i})]})]})]});return L==null?$:Mo.createPortal($,L)},jh=Object.freeze(Object.defineProperty({__proto__:null,Rule:Go},Symbol.toStringTag,{value:"Module"})),Ll=j.canDropOfType(Ye),Eh=({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:E=!1,initialViewport:y=u.Tt.DECIMAL,legendVariant:S,onViewportChange:k,viewportTriggers:C,annotationProvider:b,onSelectRule:w,...L})=>{var F;const _=t.filter(({location:$})=>u.K.isY($)),N=g.useRef(null),A=j.usePrevious(e.length),I=j.usePrevious(L.hold);return(A===0&&e.length!==0||I===!0&&L.hold===!1)&&((F=N.current)==null||F.reset()),o.jsxRuntimeExports.jsxs(cl,{...L,children:[_.map(($,z)=>{const R=e.filter(D=>D.axes.x===$.key),T=t.filter(({location:D})=>u.K.isX(D)),M=f==null?void 0:f.filter(D=>[...T.map(({key:P})=>P),$.key].includes(D.axis));return o.jsxRuntimeExports.jsx(yh,{axis:$,index:z,lines:R,yAxes:T,rules:M,onAxisChannelDrop:p,onAxisChange:m,annotationProvider:b,onRuleChange:x,onSelectRule:w},$.key)}),i&&o.jsxRuntimeExports.jsx(pl,{onLineChange:d,position:l,onPositionChange:c,variant:S}),n&&o.jsxRuntimeExports.jsx(ml,{value:s,onChange:r,level:a}),o.jsxRuntimeExports.jsxs(vl,{initial:y,onChange:k,triggers:C,ref:N,children:[h&&o.jsxRuntimeExports.jsx(fl,{}),E&&o.jsxRuntimeExports.jsx(Ml,{})]})]})},yh=({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=j.useDrop({type:"Channel.LinePlot.XAxis",canDrop:Ll,onDrop:g.useCallback(({items:y})=>{const S=j.filterByType(Ye,y);return l==null||l(d,S.map(({key:k})=>k)),S},[d,l])}),h=s==null?void 0:s.filter(y=>y.axis===d),E=j.useDraggingState();return o.jsxRuntimeExports.jsxs(al,{...p,...f,location:a,showGrid:x??n===0,className:u.CSS(u.CSS.dropRegion(j.canDropOfType(Ye)(E))),onAutoBoundsChange:y=>c==null?void 0:c({key:d,bounds:y}),children:[e.map((y,S)=>{const k=t.filter(b=>b.axes.y===y.key),C=s==null?void 0:s.filter(b=>b.axis===y.key);return o.jsxRuntimeExports.jsx(Rh,{axis:{...y,showGrid:x??(n===0&&S===0)},lines:k,rules:C,onRuleChange:r,onAxisChannelDrop:l,onAxisChange:c,onSelectRule:i},y.key)}),h==null?void 0:h.map(y=>g.createElement(Go,{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(kl,{...m})]})},Sh=({channels:{x:e,y:t}})=>`${e??0}-${t}`,Rh=({lines:e,rules:t,onRuleChange:n,onAxisChannelDrop:s,onAxisChange:r,axis:{key:i,location:l,...c},onSelectRule:a})=>{const d=j.useDrop({type:"Channel.LinePlot.YAxis",canDrop:Ll,onDrop:g.useCallback(({items:p})=>{const m=j.filterByType(Ye,p);return s==null||s(i,m.map(({key:f})=>f)),m},[i,s])}),x=j.useDraggingState();return o.jsxRuntimeExports.jsxs(ul,{...c,...d,location:l,className:u.CSS(u.CSS.dropRegion(j.canDropOfType(Ye)(x))),onAutoBoundsChange:p=>r==null?void 0:r({key:i,bounds:p}),children:[e.map(p=>o.jsxRuntimeExports.jsx(Ch,{line:p},Sh(p))),t==null?void 0:t.map(p=>g.createElement(Go,{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)}))]})},Ch=({line:e})=>e.variant==="static"?o.jsxRuntimeExports.jsx(wh,{line:e}):o.jsxRuntimeExports.jsx(bh,{line:e}),bh=({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(Fo,{aetherKey:e,y:c,x:l,...i})},wh=({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(Fo,{aetherKey:t,y:l,x:i,...r})},$r=[{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"}],Wn=({items:e},t)=>{const n=j.filterByType(Ye,e);return n.length>0&&!n.every(s=>t.includes(s.key))},Pl=["name","alias"],Tl=e=>{const t=xs();return g.useMemo(()=>e.length===0?$r:$r.filter(n=>e.includes(n.key)),[e,t])},Nl=e=>{if(e==null)return o.jsxRuntimeExports.jsx(j.Lt.Channel,{});if(Z.Fg.isCalculated(e))return o.jsxRuntimeExports.jsx(j.Lt.Calculation,{});if(e.isIndex)return o.jsxRuntimeExports.jsx(j.Lt.Index,{});const t=new Z.g(e.dataType);return t.isInteger?o.jsxRuntimeExports.jsx(j.Lt.Binary,{}):t.isFloat?o.jsxRuntimeExports.jsx(j.Lt.Decimal,{}):t.equals(Z.g.STRING)?o.jsxRuntimeExports.jsx(j.Lt.String,{}):t.equals(Z.g.JSON)?o.jsxRuntimeExports.jsx(j.Lt.JSON,{}):o.jsxRuntimeExports.jsx(j.Lt.Channel,{})},vh=({key:e,...t})=>o.jsxRuntimeExports.jsx(Ho,{icon:Nl(t.entry),...t},e),kh=({columns:e=Pl,onChange:t,className:n,value:s,searchOptions:r,...i})=>{const l=Fe(),c=xs(),a=Tl(e),d=Io(),x=j.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(j.Text$3.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:f,onDragEnd:h,...E}=j.useDragAndDrop({type:"Channel.SelectMultiple",canDrop:g.useCallback(b=>Wn(b,Z.A(s)),[s]),onDrop:g.useCallback(({items:b})=>{const w=j.filterByType(Ye,b);if(w.length===0)return[];const L=Z.c.unique([...Z.A(s),...w.map(_=>_.key)]);return t(L,{clickedIndex:null,clicked:null,entries:[]}),w},[t,s])}),y=j.useDraggingState(),S=g.useCallback(({dropped:b})=>{t(Z.A(s).filter(w=>!b.some(L=>L.key===w)),{clickedIndex:null,clicked:null,entries:[]})},[t,s]),k=g.useCallback((b,w)=>f([{key:w,type:Ye}],S),[f,S]),C=g.useCallback(b=>c[b.key]??b.name,[c]);return o.jsxRuntimeExports.jsx(Wt,{className:u.CSS(n,u.CSS.dropRegion(Wn(y,Z.A(s)))),value:s,onTagDragStart:k,onTagDragEnd:h,searcher:p,onChange:t,columns:a,emptyContent:m,entryRenderKey:C,renderTag:vh,...E,...i})},Ct=({columns:e=Pl,onChange:t,value:n,className:s,data:r,searchOptions:i,...l})=>{const c=Fe(),a=xs(),d=Tl(e),x=Io(),p=j.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(j.Text$3.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),h=g.useId(),E=g.useMemo(()=>({key:h,type:"Channel.SelectMultiple"}),[h]),{startDrag:y,onDragEnd:S,...k}=j.useDragAndDrop({type:"Channel.SelectSingle",canDrop:g.useCallback(L=>Wn(L,Z.o$1(n)),[n]),onDrop:g.useCallback(({items:L})=>{const _=j.filterByType(Ye,L);return _.length===0?[]:(t(_[0].key,{clickedIndex:null,clicked:null,entries:[]}),_)},[E,t])}),C=j.useDraggingState(),b=g.useCallback(()=>n!=null&&y([{type:Ye,key:n}]),[y,n]),w=g.useCallback(L=>a[L.key]??L.name,[a]);return o.jsxRuntimeExports.jsx(xt,{data:r,className:u.CSS(s,u.CSS.dropRegion(Wn(C,Z.o$1(n)))),value:n,onDragStart:b,onDragEnd:S,onChange:t,searcher:m,columns:d,emptyContent:f,entryRenderKey:w,...k,...l})},_h=Object.freeze(Object.defineProperty({__proto__:null,AliasInput:hf,AliasProvider:sl,LinePlot:Eh,SelectMultiple:kh,SelectSingle:Ct,resolveIcon:Nl,useActiveRange:Io,useAlias:nl,useAliases:xs,useContext:tl,useName:ps},Symbol.toStringTag,{value:"Module"})),pt=({path:e,optional:t=!1,onChange:n})=>{const s=tt(),{get:r,bind:i,set:l,setStatus:c}=s,[a,d]=g.useState(r(e,{optional:t}));g.useEffect(()=>(d(r(e,{optional:t})),i({path:e,onChange:d,listenToChildren:!1})),[e,n,i,r]);const x=g.useCallback(f=>{n==null||n(f,{...s,path:e}),l(e,f)},[e,l,n]),p=g.useCallback(f=>c(e,f),[e,c]);if(a==null){if(!t)throw new Error(`Field state is null: ${e}`);return null}let m;return s.mode==="preview"&&(m="preview"),{onChange:x,setStatus:p,variant:m,...a}},Al=(e,t=!1,n)=>{const{get:s,bind:r}=tt(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},Il=(e,t=!1,n)=>{var l;const{get:s,bind:r}=tt(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},Mh=e=>{var t,n;return((n=(t=Al(e,!0))==null?void 0:t.status)==null?void 0:n.variant)==="success"},Lh=({path:e,ctx:t,onChange:n})=>{const s=tt(t);g.useEffect(()=>s.bind({path:e,onChange:r=>n(r,s),listenToChildren:!1}),[e,s])},Ph=({path:e,optional:t=!1})=>{const{bind:n,get:s}=tt(),[r,i]=g.useState(s(e,{optional:t}));if(g.useEffect(()=>(i(s(e,{optional:t})),n({path:e,onChange:l=>i({...l,value:Z.ee(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},$l=(e,t)=>({add:(n,s)=>{const r=Z.ee(e.get(t).value);r.splice(s,0,...Z.A(n)),e.set(t,r,{validateChildren:!1})},push:(n,s)=>{const r=Z.ee(e.get(t).value);r.push(...Z.A(n)),s!=null&&r.sort(s),e.set(t,r,{validateChildren:!1})},remove:n=>{const s=e.get(t).value,r=new Set(Z.A(n));e.set(t,s.filter((i,l)=>!r.has(l)))},keepOnly:n=>{const s=e.get(t).value,r=new Set(Z.A(n));e.set(t,s.filter((i,l)=>r.has(l)))},set:n=>e.set(t,Z.executeSetter(n,e.get(t).value)),sort:n=>{const s=Z.ee(e.get(t).value);s.sort(n),e.set(t,s)}}),Th=({path:e,updateOnChildren:t=!1,ctx:n})=>{const s=tt(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(Z.ee(a.value))},listenToChildren:t})),[e,r,i,c]),g.useMemo(()=>({value:l,...$l(s,e)}),[l,s,e])},Yo=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:()=>{}}),tt=e=>{const t=g.useContext(Yo);return e??t},zr=e=>({key:e,variant:"success",message:""}),Nh=e=>e.code===ce.z.ZodIssueCode.custom&&e.params!=null&&"variant"in e.params?e.params.variant:"error",zl=({values:e,sync:t=!1,schema:n,mode:s="normal",onChange:r})=>{const i=g.useRef({state:e,statuses:new Map,touched:new Set,listeners:new Map,parentListeners:new Map}),l=j.useSyncedRef(n),c=j.useSyncedRef(r),a=g.useCallback(({path:w,onChange:L,listenToChildren:_=!1})=>{var F;const{parentListeners:N,listeners:A}=i.current,I=_?N:A;return I.has(w)||I.set(w,new Set),(F=I.get(w))==null||F.add(L),()=>{var $;return($=I.get(w))==null?void 0:$.delete(L)}},[]),d=g.useCallback((w,{optional:L}={optional:!1})=>{const{state:_,statuses:N,touched:A}=i.current,I=Z._.get(_,w,{optional:L});if(I==null)return null;const F={value:I,status:N.get(w)??zr(w),touched:A.has(w),required:!1};if(l.current==null)return F;const $=l.current,z=Z.y.getFieldSchema($,w,{optional:!0});return z==null||(F.required=!z.isOptional()),F},[]),x=g.useCallback(w=>{const{state:L,statuses:_,touched:N,listeners:A,parentListeners:I}=i.current;Z._.remove(L,w),_.delete(w),N.delete(w),A.delete(w),I.delete(w)},[]),p=g.useCallback(w=>{const{statuses:L,touched:_}=i.current;i.current.state=w,f(""),L.clear(),_.clear()},[]),m=g.useCallback(w=>{var N;const{listeners:L}=i.current,_=d(w,{optional:!0});_!=null&&((N=L.get(w))==null||N.forEach(A=>A(_)))},[]),f=g.useCallback(w=>{const{listeners:L,parentListeners:_}=i.current,N=L.get(w);if(w==""&&([...L.keys()].forEach(F=>{var z;const $=d(F,{optional:!0});$!=null&&((z=L.get(F))==null||z.forEach(R=>{R($)}))}),[..._.keys()].forEach(F=>{var z;const $=d(F,{optional:!0});$!=null&&((z=_.get(F))==null||z.forEach(R=>{R($)}))})),N!=null){const A=d(w,{optional:!0});A!=null&&N.forEach(I=>{I(A)})}_.forEach((A,I)=>{if(Z._.pathsMatch(w,I)){const $=d(I,{optional:!0});$!=null&&A.forEach(z=>{z($)})}})},[]),h=g.useCallback((w,L="",_=!0)=>{const{statuses:N,listeners:A,touched:I}=i.current;if(w.success){const R=[...N.keys()];return N.clear(),R.forEach(T=>m(T)),!0}let F=!0;const $=new Set(w.error.issues.map(R=>R.path.join(".")));let z=(R,T)=>R===T;return _&&(z=(R,T)=>Z._.pathsMatch(R,T)),w.error.issues.forEach(R=>{var V;const{message:T}=R,M=R.path.join(".");if(!z(M,L))return;const D=Nh(R);D!=="warning"&&(F=!1),N.set(M,{key:M,variant:D,message:T}),I.add(M);let P=d(M,{optional:!0});P??(P={value:void 0,status:N.get(M)??zr(M),touched:!1,required:!1}),(V=A.get(M))==null||V.forEach(H=>H(P))}),N.forEach((R,T)=>{$.has(T)||(N.delete(T),m(T))}),F},[]),E=g.useCallback((w,L)=>{if(l.current==null)return!0;const{state:_}=i.current,N=l.current.safeParse(_);return h(N,w,L)},[h]),y=g.useCallback(async(w,L)=>{if(l.current==null)return!0;const{state:_}=i.current,N=await l.current.safeParseAsync(_);return h(N,w,L)},[h]),S=g.useCallback((w,L,_={})=>{const N=Z._.get(i.current.state,w,{optional:!0}),{validateChildren:A=!0}=_,{state:I,touched:F}=i.current;F.add(w),w.length===0?i.current.state=L:Z._.set(I,w,L),f(w),(async()=>{var z;let $;try{$=E(w,A)}catch{$=await y(w,A)}(z=c.current)==null||z.call(c,{values:i.current.state,path:w,prev:N,valid:$})})()},[]),k=g.useCallback(w=>Z._.has(i.current.state,w),[]),C=g.useCallback((w,L)=>{i.current.statuses.set(w,L),i.current.touched.add(w),m(w)},[]),b=g.useCallback(()=>{const{statuses:w}=i.current;w.clear(),w.forEach((L,_)=>m(_))},[]);return g.useEffect(()=>{if(!t)return;const{listeners:w}=i.current;i.current.state=e,w.forEach((L,_)=>{const N=d(_,{optional:!0});N!=null&&L.forEach(A=>A(N))})},[t,e]),g.useMemo(()=>({bind:a,set:S,get:d,mode:s,validate:E,validateAsync:y,value:()=>i.current.state,has:k,remove:x,setStatus:C,clearStatuses:b,reset:p}),[a,S,d,E,y,k,x,C,b,p,s])},Ah=e=>o.jsxRuntimeExports.jsx(Yo.Provider,{value:e,children:e.children}),Ih=j.componentRenderProp(j.Text$2),ye=({path:e,children:t=Ih,label:n,padHelpText:s=!0,visible:r=!0,hideIfNull:i=!1,optional:l,onChange:c,className:a,...d})=>{const x=pt({path:e,optional:l??i,onChange:c}),p=tt();if(x==null)return null;if(e==null)throw new Error("No path provided to Form Field");if(n??(n=u.d.capitalize(Z._.element(e,-1))),r=typeof r=="function"?r(x,p):r,!r)return null;const m=x.status.message,{onChange:f,value:h}=x,E={onChange:f,value:h};return x.variant!=null&&(E.variant=x.variant),o.jsxRuntimeExports.jsx(Te.Item,{padHelpText:s,helpText:m,helpTextVariant:x.status.variant,label:n,required:x.required,className:u.CSS(a,u.CSS.BE("field",e.split(".").join("-")),u.CSS.M(x.status.variant)),...d,children:t(E)})},Mt=e=>({fieldKey:t,fieldProps:n,inputProps:s})=>{const r=({inputProps:i,path:l,fieldKey:c=t,...a})=>o.jsxRuntimeExports.jsx(ye,{...n,...a,path:c?`${l}.${c}`:l,children:d=>o.jsxRuntimeExports.jsx(e,{...d,...s,...i})});return r.displayName=e.displayName,r},Bl=Mt(j.Numeric),zt=Bl({}),Dl=Mt(j.Text$2),Wo=Dl({}),Ol=Mt(j.Switch$1),hs=Ol({}),$h=Mt(xt),zh=Mt(Wt),Bh=Mt(ve.DropdownButton),Ko=({key:e,open:t,onChange:n})=>{const s=j.useMemoPrimitiveArray(e);j.useAsyncEffect(async()=>{if(t==null)return;const r=await t();if(r!=null)return r.onChange(n),async()=>await r.close()},[t==null,s])},Dh=({fetchInitialValue:e,...t})=>{const[n,s]=g.useState(void 0);return j.useAsyncEffect(async()=>{s(await e())},[e]),Ko({...t,onChange:s}),n},Oh=Object.freeze(Object.defineProperty({__proto__:null,useListener:Ko,useState:Dh},Symbol.toStringTag,{value:"Module"})),Vh=({key:e,name:t,queryFn:n,values:s,openObservable:r,applyChanges:i,applyObservable:l,...c})=>{const a=Fe(),d=j.useExceptionHandler(),x=j.useMemoPrimitiveArray(e),p=zl({values:s,...c,sync:!1,onChange:h=>{a!=null&&(async()=>{try{await(i==null?void 0:i({...h,client:a}))}catch(E){d(E,`Failed to save ${t}`)}})()}});j.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 Ko({key:x,open:m,onChange:f}),p},Fh=Object.freeze(Object.defineProperty({__proto__:null,Context:Yo,Field:ye,Form:Ah,NumericField:zt,SwitchField:hs,TextField:Wo,buildDropdownButtonSelectField:Bh,buildNumericField:Bl,buildSelectMultiField:zh,buildSelectSingleField:$h,buildSwitchField:Ol,buildTextField:Dl,fieldArrayUtils:$l,fieldBuilder:Mt,use:zl,useChildFieldValues:Ph,useContext:tt,useField:pt,useFieldArray:Th,useFieldListener:Lh,useFieldState:Al,useFieldValid:Mh,useFieldValue:Il,useSynced:Vh},Symbol.toStringTag,{value:"Module"})),Hh=[{key:"name",name:"Name"},{key:"location",name:"Location"}],Zh=({searchOptions:e,...t})=>{const n=Fe();let s=n==null?void 0:n.hardware.devices;return e!=null&&n!=null&&(s=n.hardware.devices.newSearcherWithOptions(e)),o.jsxRuntimeExports.jsx(xt,{columns:Hh,searcher:s,entryRenderKey:"name",...t})},Gh=Object.freeze(Object.defineProperty({__proto__:null,SelectSingle:Zh},Symbol.toStringTag,{value:"Module"})),Bt="label",Xo=[{key:"color",name:"Color",render:({entry:e})=>o.jsxRuntimeExports.jsx(j.Lt.Circle,{name:"circle",color:e.color,style:{height:"2.5rem",width:"2.5rem"}})},{key:"name",name:"Name"}],Kn=({items:e},t)=>{const n=j.filterByType(Bt,e);return n.length>0&&!n.every(s=>t.includes(s.key))},Yh=({entry:e,loading:t,entryKey:n,entryRenderKey:s,...r})=>o.jsxRuntimeExports.jsx(an,{color:e==null?void 0:e.color,...r,children:e==null?void 0:e.name}),Wh=j.componentRenderProp(Yh),Kh=({onChange:e,className:t,value:n,...s})=>{const r=Fe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(j.Text$3.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=j.useDragAndDrop({type:"Label.SelectMultiple",canDrop:g.useCallback(m=>Kn(m,Z.A(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=j.filterByType(Bt,m);if(f.length===0)return[];const h=Z.c.unique([...Z.A(n),...f.map(E=>E.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),d=j.useDraggingState(),x=g.useCallback(({dropped:m})=>{e(Z.A(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:Bt}],x),[l,x]);return o.jsxRuntimeExports.jsx(Wt,{className:u.CSS(t,u.CSS.dropRegion(Kn(d,Z.A(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.labels,onChange:e,columns:Xo,emptyContent:i,renderTag:Wh,addPlaceholder:"Label",...a,...s})},Vl=({value:e,onChange:t})=>{const n=Fe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(j.Text$3.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=j.useDragAndDrop({type:"Label.SelectSingle",canDrop:g.useCallback(d=>Kn(d,Z.o$1(e)),[e]),onDrop:g.useCallback(({items:d})=>{const x=j.filterByType(Bt,d);return x.length===0?[]:(t(x[0].key,{clickedIndex:null,clicked:null,entries:[]}),x)},[i,t])}),c=j.useDraggingState(),a=g.useCallback(()=>e!=null&&l.startDrag([{type:Bt,key:e}]),[l.startDrag,e]);return{emptyContent:s,dragging:c,...l,onDragStart:a,searcher:n==null?void 0:n.labels}},Xh=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=Vl({value:t,onChange:e});return o.jsxRuntimeExports.jsx(xt,{data:s,className:u.CSS(n,u.CSS.dropRegion(Kn(i,Z.o$1(t)))),value:t,onChange:e,columns:Xo,entryRenderKey:"name",...l,...r})},qh=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=Vl({value:t,onChange:n});return o.jsxRuntimeExports.jsx(xt,{data:e,value:t,onChange:n,columns:Xo,entryRenderKey:"name",...i,...s})},Uh=Object.freeze(Object.defineProperty({__proto__:null,HAUL_TYPE:Bt,SelectButton:qh,SelectMultiple:Kh,SelectSingle:Xh},Symbol.toStringTag,{value:"Module"})),Fl=({children:e,centered:t,visible:n,enabled:s=!0,close:r,style:i,...l})=>{const c=g.useRef(null),a=g.useRef(n);j.useClickOutside({ref:c,exclude:x=>j.findParent(x.target,m=>m.getAttribute("role")==="dialog")!=null,onClickOutside:r});const d=g.useCallback(x=>{var m;if(!a.current||x.stage!=="start")return;const p=(m=c.current)==null?void 0:m.querySelectorAll(`.${u.CSS.visible(!0)}`);p&&p.length>0||r()},[r]);return j.use$1({triggers:[["Escape"]],callback:d,loose:!0}),o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(u.CSS.BE("modal","bg"),u.CSS.visible(n),s&&u.CSS.M("enabled-modal")),empty:!0,align:"center",children:o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(u.CSS.BE("modal","dialog"),t&&u.CSS.M("centered")),role:"dialog",empty:!0,ref:c,...l,style:{zIndex:s?11:void 0,...i},children:o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(u.CSS.BE("modal","content")),empty:!0,children:e})})})},Jh=({root:e,...t})=>Mo.createPortal(o.jsxRuntimeExports.jsx(Fl,{...t}),j.getRootElement(e)),Qh=Object.freeze(Object.defineProperty({__proto__:null,Dialog:Fl,Modal:Jh},Symbol.toStringTag,{value:"Module"})),gs=new Error("Tab not found"),eg=new Error("Invalid Mosaic"),Xn=(e,t,n="center",s)=>{var p;if(e=nt(e),s===void 0)return io(e,t);const r=lo(e,s);if(n==="center")return(p=r.tabs)==null||p.push(t),r.selected=t.tabKey,e;const i=r.key*2,l=r.key*2+1,c=n==="top"||n==="left"?i:l;if(lo(e,c).key!==r.key)return Xn(e,t,"center",c);if(r.tabs==null||r.tabs.length===0)return Xn(e,t,"center",s);const[a,d,x]=ig(n);if(r.direction=x,r[a]={key:0,tabs:[t],selected:t.tabKey},r[d]={key:0,tabs:r.tabs,selected:r.selected},r.first==null||r.last==null)throw eg;return r.first.key=i,r.last.key=l,r.tabs=void 0,r.size=void 0,r.selected=void 0,e},tg=(e,t,n)=>{var i;e=nt(e);const[s,r]=bt(e,t);if(s==null||r==null)throw gs;return r.tabs=(i=r.tabs)==null?void 0:i.map(l=>l.tabKey===t?n(l):l),e},io=(e,t)=>(e=nt(e),e.tabs!=null?(e.tabs.push(t),e.selected=t.tabKey,e):(e.first!=null?e.first=io(e.first,t):e.last!=null&&(e.last=io(e.last,t)),e)),qn=e=>{e=nt(e);const t=[];if(e.tabs!=null&&(e.selected=ke.resetSelection(e.selected,e.tabs),e.selected!=null&&t.push(e.selected)),e.first!=null){const[n,s]=qn(e.first);e.first=n,t.push(...s)}if(e.last!=null){const[n,s]=qn(e.last);e.last=n,t.push(...s)}return[e,t]},qo=(e,t)=>{var r;e=nt(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=ke.resetSelection(n.selected,n.tabs),e=rg(e);const s=n.selected??Un(e);return[e,s]},Un=e=>e.selected!=null?e.selected:e.first!=null?Un(e.first):e.last!=null?Un(e.last):null,Hl=(e,t)=>{e=nt(e);const[n,s]=bt(e,t);if(n==null||s==null)throw gs;return s.selected=t,e},Zl=(e,t,n,s)=>{e=nt(e);const[r,i]=bt(e,t);if(r==null||i==null)throw gs;const[l,c]=qo(e,t);return[Xn(l,r,n,s),c]},un=(e,t)=>{if(e.tabs!=null)return e.tabs.some(n=>n.tabKey===t)?e:void 0;if(e.first!=null){const n=un(e.first,t);if(n!=null)return n}if(e.last!=null){const n=un(e.last,t);if(n!=null)return n}},Gl=(e,t,n)=>{const s=Jn(e,t);if(s==null)throw new Error("Node not found");return s.size=n,e},ng=(e,t,n)=>{e=nt(e);const s=un(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=ke.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=un(e,t);return n==null?!1:n.tabs!=null&&n.tabs.length>1},Yl=(e,t,n)=>{e=nt(e);const[,s]=bt(e,t);if((s==null?void 0:s.tabs)==null)throw gs;return s.tabs=ke.rename(t,n,(s==null?void 0:s.tabs)??[]),e},og=e=>e.tabs!=null?e.tabs.length===0:e.first==null&&e.last==null,lo=(e,t)=>{const n=Jn(e,t);if(n!=null)return n;const s=Math.floor(t/2);return s===0?e:lo(e,s)},rg=e=>{let t=!0;for(;t;)[e,t]=co(e);return e.first==null&&e.last==null&&(e.key=1),e},co=e=>{if(e.first==null||e.last==null)return[e,!1];if(Dr(e.first))return[Br(e.last,!0),!0];if(Dr(e.last))return[Br(e.first,!1),!0];let t,n;return[e.first,t]=co(e.first),[e.last,n]=co(e.last),[e,t||n]},Br=(e,t)=>(e.size=void 0,e.key=(e.key-Number(t))/2,e),Dr=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]},Jn=(e,t)=>{if(e.key===t)return e;if(e.first==null||e.last==null)return;const n=Jn(e.first,t);return n??Jn(e.last,t)},ig=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")}},nt=e=>Z._.copy(e),Qn=(e,t,n=[])=>(n.push(t(e)),e.first!=null&&Qn(e.first,t,n),e.last!=null&&Qn(e.last,t,n),n),ao=(e,t)=>{t(e),e.first!=null&&ao(e.first,t),e.last!=null&&ao(e.last,t)};class Wl{constructor(t={}){Ge(this,"parent");Ge(this,"stub");Ge(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 lg=({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})},Kl=({node:e,children:t})=>Mo.createPortal(t,e.el),cg=Object.freeze(Object.defineProperty({__proto__:null,In:Kl,Node:Wl,Out:lg},Symbol.toStringTag,{value:"Module"})),es=g.memo(e=>{const{onResize:t,...n}=e,{root:{tabs:s,direction:r,first:i,last:l,key:c,size:a},emptyContent:d,...x}=n,p=g.useCallback(([h])=>t(c,h),[t]),{props:m}=Po({direction:r,onResize:p,count:2,initialSizes:a!=null?[a]:void 0});let f;return s!==void 0?f=o.jsxRuntimeExports.jsx(Xl,{emptyContent:d,...n}):i!=null&&l!=null?f=o.jsxRuntimeExports.jsxs(To,{id:`mosaic-${c}`,align:"stretch",className:u.CSS.BE("mosaic","resize"),...m,children:[o.jsxRuntimeExports.jsx(es,{...x,root:i,onResize:t},i.key),o.jsxRuntimeExports.jsx(es,{...x,root:l,onResize:t},l.key)]}):(f=null,console.warn("Mosaic tree is malformed")),c===1?o.jsxRuntimeExports.jsx(j.Provider$3,{children:f}):f});es.displayName="Mosaic";const ts="pluto-mosaic-tab-drop",Uo="pluto-mosaic-tab-create",ag=(e,t,n)=>{if(j.filterByType(j.FILE_TYPE,t).length>0&&n)return!0;const r=j.filterByType(ts,t).map(c=>c.key),i=e.filter(c=>!r.includes(c.tabKey)).length>0;return j.filterByType(Uo,t).length>0||r.length>0&&(i||e.length===0)},Xl=g.memo(({root:e,onDrop:t,onCreate:n,activeTab:s,children:r,onFileDrop:i,...l})=>{const{key:c,tabs:a}=e,[d,x]=g.useState(null),p=i!=null,m=g.useCallback(({items:w})=>ag(a,w,p),[a,p]),f=g.useCallback(({items:w,event:L})=>{if(L==null)return[];x(null);const _=j.filterByType(j.FILE_TYPE,w).length>0,N=a.length===0?"center":Vr(Or(L));if(_)return i==null||i(c,N,L),w;const A=j.filterByType(ts,w);if(A.length>0){const F=A.map(({key:$})=>$)[0];t(c,F,N)}const I=j.filterByType(Uo,w);if(I.length>0){const F=I.map(({key:$})=>$);n==null||n(c,N,F)}return A},[t,a.length]),h=g.useCallback(({event:w})=>{if(w==null)return;const L=a.length===0?"center":Vr(Or(w));x(L)},[a.length]),{startDrag:E,...y}=j.useDragAndDrop({type:"Mosaic",canDrop:m,onDrop:f,onDragOver:h}),S=m(j.useDraggingState()),k=g.useCallback(()=>x(null),[]),C=g.useCallback((w,{tabKey:L})=>{E([{key:L,type:ts,elementID:w.currentTarget.id}])},[E]),b=g.useCallback(()=>n==null?void 0:n(c,"center"),[c]);return o.jsxRuntimeExports.jsxs("div",{id:`mosaic-${c}`,className:u.CSS.BE("mosaic","leaf"),children:[o.jsxRuntimeExports.jsxs(ke.Tabs,{id:`tab-${c}`,tabs:a,onDragLeave:k,selected:e.selected,selectedAltColor:s===e.selected,onDragStart:C,onCreate:b,...l,...y,children:[e.selected!=null&&r(a.find(w=>w.tabKey===e.selected)),S&&o.jsxRuntimeExports.jsx("div",{style:{zIndex:1e3,position:"absolute",top:0,left:0,width:"100%",height:"100%"}})]}),d!=null&&o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("mosaic","mask"),style:ug[d]})]})});Xl.displayName="MosaicTabLeaf";const ug={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%"}},Or=e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;return s<24?{px:.5,py:.5}:{px:n/t.width,py:s/t.height}},dg=e=>e,xg=e=>1-e,Vr=({px:e,py:t})=>{if(e>.33&&e<.66&&t>.33&&t<.66)return"center";const[n,s]=[dg(e),xg(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")},pg=({root:e,onSelect:t,children:n})=>{const s=g.useRef(new Map),r=new Set,i=Qn(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 Wl({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(Kl,{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]},mg=ce.z.object({key:ce.z.number(),tabs:ce.z.array(ke.tabZ).optional(),selected:ce.z.string().optional(),direction:u.g.direction.optional(),size:ce.z.number().optional()}),uo=mg.extend({first:ce.z.lazy(()=>uo).optional(),last:ce.z.lazy(()=>uo).optional()}),fg=({allowRename:e=!1,initialTree:t})=>{const[n,s]=g.useState(t);return g.useEffect(()=>s(qn(t)[0]),[t]),{root:n,onDrop:(d,x,p)=>s(m=>Zl(m,x,p,d)[0]),onClose:d=>s(x=>qo(x,d)[0]),onSelect:d=>s(x=>Hl(x,d)),onResize:(d,x)=>s(p=>Gl(p,d,x)),onRename:e?(d,x)=>s(p=>Yl(p,d,x)):void 0}},hg=Object.freeze(Object.defineProperty({__proto__:null,HAUL_CREATE_TYPE:Uo,HAUL_DROP_TYPE:ts,Mosaic:es,autoSelectTabs:qn,canSplit:sg,findSelected:Un,findTabNode:un,forEachNode:ao,insertTab:Xn,isEmpty:og,mapNodes:Qn,moveTab:Zl,nodeZ:uo,removeTab:qo,renameTab:Yl,resizeNode:Gl,selectTab:Hl,split:ng,updateTab:tg,use:fg,usePortal:pg},Symbol.toStringTag,{value:"Module"})),gg=({variant:e,className:t,children:n,...s})=>o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(t,u.CSS.B("note"),u.CSS.M(e)),align:"stretch",empty:!0,...s,children:n}),jg=Object.freeze(Object.defineProperty({__proto__:null,Note:gg},Symbol.toStringTag,{value:"Module"})),Zs={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"})]})},Eg=({disabled:e=[],className:t,focused:n=!0,onMinimize:s,onMaximize:r,onFullscreen:i,onClose:l,...c})=>o.jsxRuntimeExports.jsxs(te.Space,{size:1.5,direction:"x",className:u.CSS(u.CSS.B("macos-controls"),!n&&u.CSS.BM("macos-controls","blurred"),t),...c,children:[o.jsxRuntimeExports.jsx(Gs,{onClick:l,className:u.CSS.BM("macos-control","close"),disabled:e.includes("close"),children:Zs.Close}),o.jsxRuntimeExports.jsx(Gs,{onClick:s,className:u.CSS.BM("macos-control","minimize"),disabled:e.includes("minimize"),children:Zs.Minimize}),o.jsxRuntimeExports.jsx(Gs,{onClick:i,className:u.CSS.BM("macos-control","maximize"),disabled:e.includes("maximize"),children:Zs.Maximize})]}),Gs=({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}),yg=({disabled:e=[],onMinimize:t,onMaximize:n,onClose:s,onFullscreen:r,focused:i,...l})=>o.jsxRuntimeExports.jsxs(te.Pack,{...l,children:[o.jsxRuntimeExports.jsx(Ys,{className:u.CSS.BM("windows-control","minimize"),onClick:t,disabled:e.includes("minimize"),children:o.jsxRuntimeExports.jsx(j.Lt.Subtract,{})}),o.jsxRuntimeExports.jsx(Ys,{className:u.CSS.BM("windows-control","maximize"),onClick:n,disabled:e.includes("maximize"),children:o.jsxRuntimeExports.jsx(j.Lt.Box,{})}),o.jsxRuntimeExports.jsx(Ys,{onClick:s,className:u.CSS.BM("windows-control","close"),disabled:e.includes("close"),children:o.jsxRuntimeExports.jsx(j.Lt.Close,{})})]}),Ys=({disabled:e=!1,className:t,...n})=>e?null:o.jsxRuntimeExports.jsx(j.Icon,{className:u.CSS(u.CSS.B("windows-control"),t),tabIndex:-1,...n}),ql=Z.S.getOS,Sg="Windows",Rg=({forceOS:e,visibleIfOS:t,...n})=>{const s=ql({force:e,default:Sg});if(t!=null&&t!==s)return null;const r=s==="macOS"?Eg:yg;return o.jsxRuntimeExports.jsx(r,{...n})},Cg=Object.freeze(Object.defineProperty({__proto__:null,Controls:Rg,use:ql},Symbol.toStringTag,{value:"Module"})),bg=(e,t)=>{const n=s=>o.jsxRuntimeExports.jsx(e,{...t,...s});return n.displayName=e.displayName,n},wg=Object.freeze(Object.defineProperty({__proto__:null,createComponent:bg},Symbol.toStringTag,{value:"Module"}));g.createContext({instrumentation:Z.B.NOOP});const vg=({children:e,...t})=>{const{path:n}=j.useUnidirectional({type:B.Provider$2.TYPE,schema:B.providerStateZ$1,state:t});return o.jsxRuntimeExports.jsx(j.Composite,{path:n,children:e})},kg="data:video/mp2t;base64,Ly8gQ29weXJpZ2h0IDIwMjUgU3lubmF4IExhYnMsIEluYy4KLy8KLy8gVXNlIG9mIHRoaXMgc29mdHdhcmUgaXMgZ292ZXJuZWQgYnkgdGhlIEJ1c2luZXNzIFNvdXJjZSBMaWNlbnNlIGluY2x1ZGVkIGluIHRoZSBmaWxlCi8vIGxpY2Vuc2VzL0JTTC50eHQuCi8vCi8vIEFzIG9mIHRoZSBDaGFuZ2UgRGF0ZSBzcGVjaWZpZWQgaW4gdGhhdCBmaWxlLCBpbiBhY2NvcmRhbmNlIHdpdGggdGhlIEJ1c2luZXNzIFNvdXJjZQovLyBMaWNlbnNlLCB1c2Ugb2YgdGhpcyBzb2Z0d2FyZSB3aWxsIGJlIGdvdmVybmVkIGJ5IHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAsCi8vIGluY2x1ZGVkIGluIHRoZSBmaWxlIGxpY2Vuc2VzL0FQTC50eHQuCgppbXBvcnQgeyBwbHV0byB9IGZyb20gIkAvcGx1dG8vYWV0aGVyIjsKCnBsdXRvLnJlbmRlcigpOwo=",Ul=({children:e})=>{const[{path:t}]=j.use$3({type:B.BaseProvider.TYPE,schema:B.providerStateZ$2,initialState:{}});return o.jsxRuntimeExports.jsx(j.Composite,{path:t,children:e})},_g=Object.freeze(Object.defineProperty({__proto__:null,Provider:Ul},Symbol.toStringTag,{value:"Module"})),Mg=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-l10)"}:{message:"No channel connected. This element cannot be controlled.",chipColor:"var(--pluto-gray-l5)",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)===Z.rp.Authority.Absolute.valueOf()?{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 P&ID to release control.",chipColor:"var(--pluto-primary-z)"};default:return{message:"Unexpected status.",chipColor:"var(--pluto-error-z)"}}},Jl=({source:e,sink:t,className:n,...s})=>{const r=j.useMemoDeepEqualProps({source:e,sink:t}),[,{status:i},l]=j.use$3({type:B.Chip.TYPE,schema:B.chipStateZ,initialState:{triggered:!1,...r,status:{key:"no_chip",variant:"disabled",message:"No chip connected.",time:Z.m.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}=Mg(i);return o.jsxRuntimeExports.jsx(j.Icon,{variant:"text",className:u.CSS(u.CSS.B("control-chip"),n),disabled:p,onClick:c,tooltip:o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:a}),style:x,...s,children:o.jsxRuntimeExports.jsx(j.Lt.Circle,{color:d})})},Ql=g.createContext({needsControlOf:[]}),ec=()=>g.useContext(Ql),Lg=({children:e,onStatusChange:t,...n})=>{const s=j.useMemoDeepEqualProps(n),[{path:r},{status:i,needsControlOf:l},c]=j.use$3({type:B.Controller$1.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(Ql.Provider,{value:{needsControlOf:l},children:[o.jsxRuntimeExports.jsx(j.Composite,{path:r,children:e}),";"]})},tc=({colorSource:e,statusSource:t})=>{var c;const n=j.useMemoDeepEqualProps({colorSource:e,statusSource:t}),[,{color:s,status:r},i]=j.use$3({type:B.Indicator.TYPE,initialState:{...n,status:{key:"no_chip",variant:"warning",message:"No chip connected.",time:Z.m.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.Color.z.parse(r.data.color):s!=null&&!s.isZero?l=s:l="var(--pluto-gray-l8)",o.jsxRuntimeExports.jsxs(j.Dialog$1,{location:{x:"center",y:"bottom"},children:[o.jsxRuntimeExports.jsx(j.Text$1,{level:"p",children:r.message}),o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("indicator"),style:{backgroundColor:u.cssString(l),flexGrow:1}})]})},Pg=({...e})=>{const{needsControlOf:t}=ec(),[,{states:n},s]=j.use$3({type:B.Legend.TYPE,schema:B.legendStateZ,initialState:{states:[],needsControlOf:t}});g.useEffect(()=>{s(l=>({...l,needsControlOf:t}))},[t]);const i=Z.c.unique(n.map(l=>l.subject.key)).map(l=>{const c=n.find(a=>a.subject.key===l);if(c==null)throw new Z.xe("Legend subject not found");return{key:c.subject.key,label:c.subject.name,color:c.subjectColor}});return o.jsxRuntimeExports.jsx(Do,{data:i,...e})},nc=({children:e})=>{const[{path:t}]=j.use$3({type:B.StateProvider.TYPE,schema:B.stateProviderStateZ,initialState:{}});return o.jsxRuntimeExports.jsx(j.Composite,{path:t,children:e})},Tg=Object.freeze(Object.defineProperty({__proto__:null,Chip:Jl,Controller:Lg,Indicator:tc,Legend:Pg,StateProvider:nc,useContext:ec},Symbol.toStringTag,{value:"Module"})),sc=e=>{const t=({disabled:n=!1,...s})=>n?s.children:o.jsxRuntimeExports.jsx(e,{...s});return t.displayName=e.displayName,t},Ng=sc(Ul),Ag=sc(j.Provider$4),Ig=({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(j.Provider$2,{...l,children:o.jsxRuntimeExports.jsx(j.Config,{...i,children:o.jsxRuntimeExports.jsx(j.Provider$3,{...a,children:o.jsxRuntimeExports.jsx(j.Provider$5,{url:s??kg,enabled:n,children:o.jsxRuntimeExports.jsx(Ag,{workerKey:"vis",children:o.jsxRuntimeExports.jsx(vg,{...c,children:o.jsxRuntimeExports.jsx(j.Aggregator,{children:o.jsxRuntimeExports.jsx(el,{connParams:t,children:o.jsxRuntimeExports.jsx(sl,{...d,children:o.jsxRuntimeExports.jsx(j.Provider$1,{...p,children:o.jsxRuntimeExports.jsx(j.Provider,{...r,children:o.jsxRuntimeExports.jsx(Ng,{...x,children:o.jsxRuntimeExports.jsx(nc,{children:e})})})})})})})})})})})})}),$g=Object.freeze(Object.defineProperty({__proto__:null,Provider:Ig},Symbol.toStringTag,{value:"Module"})),zg=({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}%`}})}),Bg=Object.freeze(Object.defineProperty({__proto__:null,Progress:zg},Symbol.toStringTag,{value:"Module"})),dn="range",Jo=[{key:"name",name:"Name"}],ns=({items:e},t)=>{const n=j.filterByType(dn,e);return n.length>0&&!n.every(s=>t.includes(s.key))},Dg=({onChange:e,className:t,value:n,...s})=>{const r=Fe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(j.Text$3.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=j.useDragAndDrop({type:"Ranger.SelectMultiple",canDrop:g.useCallback(m=>ns(m,Z.A(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=j.filterByType(dn,m);if(f.length===0)return[];const h=Z.c.unique([...Z.A(n),...f.map(E=>E.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),d=j.useDraggingState(),x=g.useCallback(({dropped:m})=>{e(Z.A(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:dn}],x),[l,x]);return o.jsxRuntimeExports.jsx(Wt,{className:u.CSS(t,u.CSS.dropRegion(ns(d,Z.A(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.ranges,onChange:e,columns:Jo,emptyContent:i,entryRenderKey:"name",...a,...s})},oc=({value:e,onChange:t})=>{const n=Fe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(j.Text$3.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}=j.useDragAndDrop({type:"Ranger.SelectSingle",canDrop:g.useCallback(x=>ns(x,Z.o$1(e)),[e]),onDrop:g.useCallback(({items:x})=>{const p=j.filterByType(dn,x);return p.length===0?[]:(t(p[0].key,{clickedIndex:null,clicked:null,entries:[]}),p)},[i,t])}),a=j.useDraggingState(),d=g.useCallback(()=>e!=null&&l([{type:dn,key:e}]),[l,e]);return{emptyContent:s,dragging:a,...c,onDragStart:d,searcher:n==null?void 0:n.ranges}},Og=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=oc({value:t,onChange:e});return o.jsxRuntimeExports.jsx(xt,{data:s,className:u.CSS(n,u.CSS.dropRegion(ns(i,Z.o$1(t)))),value:t,onChange:e,columns:Jo,entryRenderKey:"name",...l,...r})},Vg=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=oc({value:t,onChange:n});return o.jsxRuntimeExports.jsx(xt,{data:e,value:t,onChange:n,columns:Jo,entryRenderKey:"name",...i,...s})},Fg=[{key:"color",name:"Color",width:50,render:e=>o.jsxRuntimeExports.jsx(j.Lt.Circle,{style:{fontSize:10,marginLeft:10,marginRight:30},color:e.entry.color})},{key:"name",name:"Name"}],Hg=e=>{const t=Fe();return o.jsxRuntimeExports.jsx(Wt,{...e,searcher:t==null?void 0:t.labels,columns:Fg,renderTag:n=>n.entry==null?o.jsxRuntimeExports.jsx(an,{color:"gray",children:n.entryKey}):o.jsxRuntimeExports.jsx(an,{color:n.entry.color,children:n.entry.name})})},Zg=({timeRange:e,level:t="p",shade:n=7,showSpan:s=!1,...r})=>{const i=new Z.m(e.start),l=i.isToday?"time":"dateTime",c=new Z.m(e.end),a=c.equals(Z.m.MAX),d=c.span(i)<Z.w.DAY?"time":"dateTime",x=i.span(c);return o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",size:"small",className:u.CSS(u.CSS.B("time-range-chip")),align:"center",...r,children:[i.isToday&&o.jsxRuntimeExports.jsx(j.Text$1,{level:t,shade:n,weight:450,children:"Today"}),o.jsxRuntimeExports.jsx(j.DateTime,{level:t,displayTZ:"local",format:l,shade:n,weight:450,children:i}),o.jsxRuntimeExports.jsx(j.Lt.Arrow.Right,{color:"var(--pluto-text-color)"}),a?o.jsxRuntimeExports.jsx(j.Text$1,{level:t,children:"Now"}):o.jsxRuntimeExports.jsx(j.DateTime,{level:t,displayTZ:"local",format:d,shade:n,weight:450,children:c}),!x.isZero&&s&&o.jsxRuntimeExports.jsxs(j.Text$1,{level:t,shade:n,weight:450,children:["(",i.span(c).truncate(Z.w.MILLISECOND).toString(),")"]})]})},Gg=Object.freeze(Object.defineProperty({__proto__:null,SelectButton:Vg,SelectLabels:Hg,SelectMultiple:Dg,SelectSingle:Og,TimeRangeChip:Zg},Symbol.toStringTag,{value:"Module"})),Yg=({steps:e,value:t,onChange:n,...s})=>{const r=e.findIndex(i=>i.key===t);return o.jsxRuntimeExports.jsx(te.Space,{direction:"x",align:"center",className:u.CSS.B("steps"),...s,children:e.map((i,l)=>o.jsxRuntimeExports.jsxs(g.Fragment,{children:[o.jsxRuntimeExports.jsxs(j.Button,{onClick:()=>n(i.key),variant:"outlined",disabled:l>r,children:[l+1,". ",i.title]},i.key),l!==e.length-1&&o.jsxRuntimeExports.jsx(j.Lt.Arrow.Right,{style:{fontSize:"15px",color:"var(--pluto-gray-l8)"}})]},i.key))})},Wg=Object.freeze(Object.defineProperty({__proto__:null,Steps:Yg},Symbol.toStringTag,{value:"Module"})),Kg=({children:e,className:t,visible:n,...s})=>{const[{path:r},,i]=j.use$3({type:B.Table.TYPE,schema:B.Table.stateZ,initialState:{region:u.Tt.ZERO,visible:n}});g.useEffect(()=>{i(c=>({...c,visible:n}))},[n]);const l=En(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(j.Composite,{path:r,children:e})})})]})},Xg=({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(ic,{onSelect:i,index:s,value:n,onChange:r,position:l,direction:"y"}),e]}),Qo=({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}),rc="ABCDEFGHIJKLMNOPQRSTUVWXYZ",qg=e=>rc[e],ic=({value:e,selected:t=!1,index:n,onChange:s,position:r,direction:i="x",onSelect:l})=>{const c=j.useSyncedRef(e),a=g.useRef(e),d=j.useCursorDrag({onStart:g.useCallback(()=>{a.current=c.current},[]),onMove:g.useCallback(x=>s(a.current+u.Tt.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),j.CONTEXT_TARGET,t&&j.CONTEXT_SELECTED),style:{[u.g.dimension(i)]:e},onClick:()=>l(n),onContextMenu:()=>l(n),children:[o.jsxRuntimeExports.jsx(j.Text$1,{level:"p",shade:7,style:{width:"100%",textAlign:"center"},children:i==="x"?rc[n]:n+1}),o.jsxRuntimeExports.jsx("button",{onClick:x=>x.stopPropagation(),style:{[u.g.location(i)]:r+e},onDragStart:d,draggable:!0})]})},Ug=({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(ic,{onSelect:t,position:c,selected:e.includes(l),index:l,value:i,onChange:a=>s(a,l),direction:"x"},l)})]})},Jg=Object.freeze(Object.defineProperty({__proto__:null,Cell:Qo,ColumnIndicators:Ug,Row:Xg,Table:Kg,getCellColumn:qg},Symbol.toStringTag,{value:"Module"})),Qg=[{key:"standard",name:"Standard"},{key:"scientific",name:"Scientific"},{key:"engineering",name:"Engineering"}],e1=({...e})=>o.jsxRuntimeExports.jsx(ve.Button,{...e,entryRenderKey:"name",data:Qg}),lc=[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],er=({path:e})=>{var f;const{value:t,onChange:n}=pt({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 E=B.sourcePipeline("string",{connections:lc,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:E})},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=ps(r.channel);return g.useEffect(()=>n({...t,tooltip:[m]}),[m]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(Te.Item,{label:"Input Channel",grow:!0,children:o.jsxRuntimeExports.jsx(Ct,{value:r.channel,onChange:a})}),o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",children:[o.jsxRuntimeExports.jsx(Te.Item,{label:"Notation",children:o.jsxRuntimeExports.jsx(e1,{value:i.notation,onChange:d})}),o.jsxRuntimeExports.jsx(Te.Item,{label:"Precision",align:"start",children:o.jsxRuntimeExports.jsx(j.Numeric,{value:i.precision??2,bounds:{lower:0,upper:10},onChange:x})}),o.jsxRuntimeExports.jsx(Te.Item,{label:"Averaging Window",align:"start",children:o.jsxRuntimeExports.jsx(j.Numeric,{value:l.windowSize??1,bounds:{lower:1,upper:100},onChange:p})})]})]})},t1=B.Value.z.partial({color:!0}).extend({level:Z.levelZ.optional()}),tr=({aetherKey:e,box:t,telem:n,color:s,precision:r,minWidth:i,level:l="small",backgroundTelem:c,notation:a,location:d})=>{const x=j.useMemoDeepEqualProps({box:t,telem:n,color:s,precision:r,level:l,minWidth:i,notation:a,backgroundTelem:c,location:d}),[,p,m]=j.use$3({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}},n1=Object.freeze(Object.defineProperty({__proto__:null,TelemForm:er,VALUE_CONNECTIONS:lc,corePropsZ:t1,use:tr},Symbol.toStringTag,{value:"Module"})),s1=ce.z.object({value:ce.z.string(),level:Z.levelZ,weight:Z.weightZ,align:u.K.x.or(u.K.center),backgroundColor:u.crudeZ}),o1=({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(Qo,{id:e,className:u.CSS(j.CONTEXT_TARGET,s&&j.CONTEXT_SELECTED,u.CSS.BEM("table","cell","text")),selected:s,onClick:d,onContextMenu:d,style:{backgroundColor:u.cssString(a)},children:o.jsxRuntimeExports.jsx(j.Editable,{level:l,value:n,weight:c,onChange:x,style:{justifyContent:i},allowEmpty:!0,outline:!1})})},r1=ce.z.object({telem:B.stringSourceSpecZ,redline:ce.z.object({bounds:u.H.bounds,gradient:u.gradientZ}),level:Z.levelZ,color:ce.z.string(),units:ce.z.string()}),i1=({cellKey:e,telem:t,level:n,color:s,redline:{gradient:r,bounds:i},selected:l,box:c,onSelect:a})=>{const{width:d}=tr({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.b.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(Qo,{id:e,selected:l,onClick:x,onContextMenu:x,style:{height:"5rem",width:d},className:u.CSS(j.CONTEXT_TARGET,l&&j.CONTEXT_SELECTED,u.CSS.BEM("table","cell","value"))})},l1=({onVariantChange:e})=>{const t=g.useCallback(({tabKey:s})=>{switch(s){case"telem":return o.jsxRuntimeExports.jsx(te.Space,{direction:"y",style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(er,{path:""})});case"redline":return o.jsxRuntimeExports.jsx(te.Space,{direction:"y",style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(c1,{})});default:return o.jsxRuntimeExports.jsx(te.Space,{direction:"y",grow:!0,empty:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",children:[o.jsxRuntimeExports.jsx(Te.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(cc,{onChange:e,value:"value"})}),o.jsxRuntimeExports.jsx(ye,{hideIfNull:!0,label:"Color",align:"start",padHelpText:!1,path:"color",children:({value:r,onChange:i,variant:l,...c})=>o.jsxRuntimeExports.jsx(j.Swatch,{value:r??u.ZERO.setAlpha(1).rgba255,onChange:a=>i(a.rgba255),...c,bordered:!0})}),o.jsxRuntimeExports.jsx(ye,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:r=>o.jsxRuntimeExports.jsx(ve.SelectLevel,{...r})})]})})}},[]),n=ke.useStatic({tabs:[{tabKey:"style",name:"Style"},{tabKey:"telem",name:"Telemetry"},{tabKey:"redline",name:"Redline"}],content:t});return o.jsxRuntimeExports.jsx(ke.Tabs,{...n})},c1=()=>{const{set:e,get:t}=tt(),n=Il("redline.bounds"),s=u.b.Scale.scale(0,1).scale(n);return o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",grow:!0,children:[o.jsxRuntimeExports.jsx(zt,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Lower",path:"redline.bounds.lower"}),o.jsxRuntimeExports.jsx(ye,{path:"redline.gradient",label:"Gradient",align:"start",padHelpText:!1,children:({value:r,onChange:i})=>o.jsxRuntimeExports.jsx(j.GradientPicker,{value:Z._.copy(r),scale:s,onChange:l=>{const a={...t("redline.bounds").value},d=l.map(E=>E.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(E=>({...E,color:new u.Color(E.color).hex}));m||f?e("redline",{bounds:a,gradient:h}):i(l.map(E=>({...E,color:new u.Color(E.color).hex})))}})}),o.jsxRuntimeExports.jsx(zt,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Upper",path:"redline.bounds.upper"})]})},a1=({onVariantChange:e})=>o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",grow:!0,style:{padding:"2rem"},children:[o.jsxRuntimeExports.jsx(Te.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(cc,{onChange:e,value:"text"})}),o.jsxRuntimeExports.jsx(Wo,{path:"value",label:"Text"}),o.jsxRuntimeExports.jsx(ye,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(ve.SelectLevel,{...t})}),o.jsxRuntimeExports.jsx(ye,{path:"weight",label:"Weight",padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(ve.SelectWeight,{...t})}),o.jsxRuntimeExports.jsx(ye,{path:"align",label:"Alignment",hideIfNull:!0,children:t=>o.jsxRuntimeExports.jsx(ms,{...t})}),o.jsxRuntimeExports.jsx(ye,{path:"backgroundColor",label:"Background",align:"start",padHelpText:!1,children:({value:t,onChange:n})=>o.jsxRuntimeExports.jsx(j.Swatch,{value:t,onChange:n})})]}),u1=[{key:"text",name:"Text"},{key:"value",name:"Value"}],cc=({onChange:e,value:t})=>o.jsxRuntimeExports.jsx(ve.Button,{value:t,onChange:e,data:u1,allowMultiple:!1,entryRenderKey:"name"}),d1=["text","value"],x1=ce.z.enum(d1),p1={key:"value",name:"Value",Form:l1,Cell:i1,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:e.colors.gray.l8.hex,level:"h5",units:""}),schema:r1},m1={key:"text",name:"Text",Form:a1,Cell:o1,defaultProps:()=>({value:"",level:"h5",units:"",weight:400,align:"center",backgroundColor:"#00000000"}),schema:s1},f1={text:m1,value:p1},h1=Object.freeze(Object.defineProperty({__proto__:null,CELLS:f1,variantZ:x1},Symbol.toStringTag,{value:"Module"})),Fr=({sourcePos:e,targetPos:t,next:n,prev:s})=>{const r=jt(e,...n);return u.G.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)},Hr=({sourceStumpTip:e,sourceOrientation:t,sourceBox:n,targetStumpTip:s,targetOrientation:r,targetBox:i})=>{if(!g1({sourcePos:e,sourceOrientation:t,targetPos:s}))return;const l=u.g.construct(t),c=u.g.swap(l);let a=St(c,s[c]-e[c]);const d=u.Tt.loc(n,a);if(u.K.swap(t)===r){const x=u.Tt.loc(i,u.K.swap(a));Math.abs(d-x)<Ae&&(a=u.K.swap(a))}return{direction:c,length:d-e[c]+wt(a,Ae)}},xo=ce.z.object({direction:u.g.direction,length:ce.z.number()}),jt=(e,...t)=>{let n=e;for(const s of t)n=u.G.translate(n,s.direction,s.length);return n},ac=(e,t,n,s)=>{try{let r=e;const i=[e,...t.map(f=>(r=u.G.translate(r,f.direction,f.length),r))];if(!s)return i;const l=t[0],c=St(l.direction,l.length),a=Zr(c),d=4*(2-n**.5);i[0]=u.G.translate(i[0],{[l.direction]:-1*a*d,[u.g.swap(l.direction)]:0});const x=t[t.length-1],p=St(x.direction,x.length),m=Zr(p);return i[i.length-1]=u.G.translate(i[i.length-1],{[x.direction]:m*d,[u.g.swap(x.direction)]:0}),i}catch{return[]}},Ae=10,Zr=e=>e==="top"||e==="left"?-1:1,wt=(e,t)=>e==="top"||e==="left"?-t:t,St=(e,t)=>e==="x"?t>0?"right":"left":t>0?"bottom":"top",ct=e=>St(e.direction,e.length),g1=({sourcePos:e,targetPos:t,sourceOrientation:n})=>{const s=u.g.construct(n),r=t[s]-e[s];return wt(n,r)<0},_n=e=>({direction:u.g.construct(e),length:wt(e,Ae)}),Gr={top:_n("top"),bottom:_n("bottom"),left:_n("left"),right:_n("right")},j1=4,E1=.25,js=e=>po(y1(po(e))),y1=e=>{const t=[...e],n=e.findIndex((s,r)=>{const i=Math.abs(s.length);if(i<j1){if(r===0||r===e.length-1)return!1;if(i<E1)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},po=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=ct(i),d=ct(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)===Ae)return!1;const x=wt(a,Ae),p=t[l].length-x,m=t[c].length+p;return Math.abs(m)<Ae?!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=ct(s),d=ct(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)===Ae)return!1;const x=wt(a,Ae),p=t[l].length-x,m=t[c].length+p;return Math.abs(m)<Ae?!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?po(t):t},Nt=e=>js(S1(e)),S1=({sourceBox:e,targetBox:t,sourcePos:n,targetPos:s,targetOrientation:r,sourceOrientation:i})=>{let l=i,c=r,a={...Gr[i]},d=jt(n,a);const x={...Gr[r]};let p=jt(s,x);const m=Math.abs(d.x-p.x),f=Math.abs(d.y-p.y);m<2*Ae&&f<10&&(a.length-=m/2,x.length+=m/2,d=jt(n,a),p=jt(s,x));const h=[a],E=Hr({sourceStumpTip:d,sourceOrientation:i,sourceBox:e,targetStumpTip:p,targetOrientation:r,targetBox:t});E!=null&&(h.push(E),d=jt(d,E),l=ct(E),a=E);const y=Hr({sourceStumpTip:p,sourceOrientation:c,sourceBox:t,targetStumpTip:d,targetOrientation:l,targetBox:e});y!=null&&(p=jt(p,y),c=St(y.direction,y.length));const S=()=>{y!=null&&(y.length*=-1,h.push(y)),x.length*=-1,h.push(x)};if(u.K.swap(l)===r){const _=u.g.construct(l),N=(p[_]-d[_])/2;h.push({direction:_,length:N});const A=u.g.swap(_);return h.push({direction:A,length:p[A]-d[A]}),h.push({direction:_,length:N}),S(),h}const k=p[a.direction]-d[a.direction];let C=u.g.swap(a.direction);const b=d[C]-p[C];let w;St(a.direction,k)===l&&St(C,b)===c?w={direction:a.direction,length:k}:(w={direction:C,length:p[C]-d[C]},C=u.g.swap(C)),h.push(w);const L={direction:C,length:p[C]-d[C]};return h.push(L),S(),h},R1=e=>js(C1(e)),C1=({segments:e,index:t,magnitude:n})=>{const s=[...e],r=s[t],i=u.g.swap(r.direction),l=ct(r);if(t===0){s.unshift({direction:i,length:n});const c=wt(l,Ae);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=wt(l,Ae);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},b1=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n],n))return n;return-1},w1=(e,t,n=!1,...s)=>{const r=(i,l)=>!s.includes(l)&&t(i,l);return n?b1(e,r):e.findIndex(r)},v1=({delta:e,segments:t})=>js(uc(e,t,!1)),k1=({delta:e,segments:t})=>js(uc(e,t,!0)),uc=(e,t,n)=>{let s=[...t];return e.x!==0&&(s=Wr("x",e,s,n)),e.y!==0&&(s=Wr("y",e,s,n)),s},Yr=(e,t,n)=>{if(t.direction!==e)return!1;const s={...t,length:t.length-n[e]},r=ct(t),i=ct(s),l=Math.abs(s.length),c=Math.abs(t.length);return(l>c||l>Ae)&&r===i},Wr=(e,t,n,s)=>{const r=u.g.swap(e),i=s?n.length-1:0,l=n[i];if(Yr(e,l,t)){const p=n[n.length-1];return p.direction===e&&Math.abs(l.length)<Ae?(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=w1(n,p=>p.direction===e,s,i);if(d===c){const p=n[c];return Yr(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},_1=ce.z.object({position:u.G.xy,zoom:ce.z.number()}),dc=ce.z.object({color:u.crudeZ,variant:ce.z.string().optional(),segments:ce.z.array(xo)}),M1=dc.extend({key:ce.z.string(),source:ce.z.string(),target:ce.z.string(),segments:ce.z.array(xo),color:u.crudeZ,id:ce.z.string(),data:ce.z.object({segments:ce.z.array(xo),color:u.crudeZ,variant:ce.z.string().optional()}).optional(),selected:ce.z.boolean(),sourceHandle:ce.z.string().nullable().optional(),targetHandle:ce.z.string().nullable().optional()}),L1=ce.z.object({key:ce.z.string(),position:u.G.xy,selected:ce.z.boolean().optional(),zIndex:ce.z.number().optional(),type:ce.z.string().optional(),data:ce.z.record(ce.z.unknown()).optional(),measured:ce.z.object({width:ce.z.number().optional(),height:ce.z.number().optional()}).optional()}),nr=e=>e.map(t=>({id:t.key,type:"custom",zIndex:t.zIndex,measured:{...t.measured},position:{...t.position},selected:t.selected,data:{}})),sr=e=>e.map(({segments:t,color:n,variant:s,...r})=>({...r,id:r.key,data:{segments:t,color:n,variant:s}})),xc=e=>e.map(t=>({key:t.id,...t})),pc=(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}}),mc=e=>({...e.position,zoom:e.zoom}),fc=e=>({position:u.G.construct(e),zoom:e.zoom}),hc=(e,t)=>xc(t(nr(e))),Vn=(e,t,n)=>pc(t(sr(e)),n),P1=(e,t="x")=>{if(e.length===0)return[];const n=u.K.construct(t),s=u.K.swap(n);return e.sort((r,i)=>u.Tt.loc(r.box,n)-u.Tt.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.G.set(u.G.translation(x,d),t,0),m=u.G.translate(u.Tt.topLeft(r.box),p);r.box=u.Tt.construct(m,u.Tt.dims(r.box))}),e};function Me(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=Me(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var T1={value:()=>{}};function Es(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new Fn(n)}function Fn(e){this._=e}function N1(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}})}Fn.prototype=Es.prototype={constructor:Fn,on:function(e,t){var n=this._,s=N1(e+"",n),r,i=-1,l=s.length;if(arguments.length<2){for(;++i<l;)if((r=(e=s[i]).type)&&(r=A1(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]=Kr(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Kr(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 Fn(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 A1(e,t){for(var n=0,s=e.length,r;n<s;++n)if((r=e[n]).name===t)return r.value}function Kr(e,t,n){for(var s=0,r=e.length;s<r;++s)if(e[s].name===t){e[s]=T1,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var mo="http://www.w3.org/1999/xhtml";const Xr={svg:"http://www.w3.org/2000/svg",xhtml:mo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ys(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Xr.hasOwnProperty(t)?{space:Xr[t],local:e}:e}function I1(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===mo&&t.documentElement.namespaceURI===mo?t.createElement(e):t.createElementNS(n,e)}}function $1(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function gc(e){var t=ys(e);return(t.local?$1:I1)(t)}function z1(){}function or(e){return e==null?z1:function(){return this.querySelector(e)}}function B1(e){typeof e!="function"&&(e=or(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 ze(s,this._parents)}function D1(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function O1(){return[]}function jc(e){return e==null?O1:function(){return this.querySelectorAll(e)}}function V1(e){return function(){return D1(e.apply(this,arguments))}}function F1(e){typeof e=="function"?e=V1(e):e=jc(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 ze(s,r)}function Ec(e){return function(){return this.matches(e)}}function yc(e){return function(t){return t.matches(e)}}var H1=Array.prototype.find;function Z1(e){return function(){return H1.call(this.children,e)}}function G1(){return this.firstElementChild}function Y1(e){return this.select(e==null?G1:Z1(typeof e=="function"?e:yc(e)))}var W1=Array.prototype.filter;function K1(){return Array.from(this.children)}function X1(e){return function(){return W1.call(this.children,e)}}function q1(e){return this.selectAll(e==null?K1:X1(typeof e=="function"?e:yc(e)))}function U1(e){typeof e!="function"&&(e=Ec(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 ze(s,this._parents)}function Sc(e){return new Array(e.length)}function J1(){return new ze(this._enter||this._groups.map(Sc),this._parents)}function ss(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ss.prototype={constructor:ss,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 Q1(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 ss(e,i[l]);for(;l<a;++l)(c=t[l])&&(r[l]=c)}function tj(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 ss(e,i[c]);for(c=0;c<x;++c)(a=t[c])&&d.get(m[c])===a&&(r[c]=a)}function nj(e){return e.__data__}function sj(e,t){if(!arguments.length)return Array.from(this,nj);var n=t?tj:ej,s=this._parents,r=this._groups;typeof e!="function"&&(e=Q1(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=oj(e.call(x,x&&x.__data__,d,s)),h=f.length,E=c[d]=new Array(h),y=l[d]=new Array(h),S=a[d]=new Array(m);n(x,p,E,y,S,f,t);for(var k=0,C=0,b,w;k<h;++k)if(b=E[k]){for(k>=C&&(C=k+1);!(w=y[C])&&++C<h;);b._next=w||null}}return l=new ze(l,s),l._enter=c,l._exit=a,l}function oj(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function rj(){return new ze(this._exit||this._groups.map(Sc),this._parents)}function ij(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 lj(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 ze(c,this._parents)}function cj(){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 aj(e){e||(e=uj);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 ze(r,this._parents).order()}function uj(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function dj(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function xj(){return Array.from(this)}function pj(){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 mj(){let e=0;for(const t of this)++e;return e}function fj(){return!this.node()}function hj(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 gj(e){return function(){this.removeAttribute(e)}}function jj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ej(e,t){return function(){this.setAttribute(e,t)}}function yj(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Sj(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Rj(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 Cj(e,t){var n=ys(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?jj:gj:typeof t=="function"?n.local?Rj:Sj:n.local?yj:Ej)(n,t))}function Rc(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function bj(e){return function(){this.style.removeProperty(e)}}function wj(e,t,n){return function(){this.style.setProperty(e,t,n)}}function vj(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function kj(e,t,n){return arguments.length>1?this.each((t==null?bj:typeof t=="function"?vj:wj)(e,t,n??"")):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||Rc(e).getComputedStyle(e,null).getPropertyValue(t)}function _j(e){return function(){delete this[e]}}function Mj(e,t){return function(){this[e]=t}}function Lj(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Pj(e,t){return arguments.length>1?this.each((t==null?_j:typeof t=="function"?Lj:Mj)(e,t)):this.node()[e]}function Cc(e){return e.trim().split(/^|\s+/)}function rr(e){return e.classList||new bc(e)}function bc(e){this._node=e,this._names=Cc(e.getAttribute("class")||"")}bc.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 wc(e,t){for(var n=rr(e),s=-1,r=t.length;++s<r;)n.add(t[s])}function vc(e,t){for(var n=rr(e),s=-1,r=t.length;++s<r;)n.remove(t[s])}function Tj(e){return function(){wc(this,e)}}function Nj(e){return function(){vc(this,e)}}function Aj(e,t){return function(){(t.apply(this,arguments)?wc:vc)(this,e)}}function Ij(e,t){var n=Cc(e+"");if(arguments.length<2){for(var s=rr(this.node()),r=-1,i=n.length;++r<i;)if(!s.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Aj:t?Tj:Nj)(n,t))}function $j(){this.textContent=""}function zj(e){return function(){this.textContent=e}}function Bj(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Dj(e){return arguments.length?this.each(e==null?$j:(typeof e=="function"?Bj:zj)(e)):this.node().textContent}function Oj(){this.innerHTML=""}function Vj(e){return function(){this.innerHTML=e}}function Fj(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Hj(e){return arguments.length?this.each(e==null?Oj:(typeof e=="function"?Fj:Vj)(e)):this.node().innerHTML}function Zj(){this.nextSibling&&this.parentNode.appendChild(this)}function Gj(){return this.each(Zj)}function Yj(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Wj(){return this.each(Yj)}function Kj(e){var t=typeof e=="function"?e:gc(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Xj(){return null}function qj(e,t){var n=typeof e=="function"?e:gc(e),s=t==null?Xj:typeof t=="function"?t:or(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function Uj(){var e=this.parentNode;e&&e.removeChild(this)}function Jj(){return this.each(Uj)}function Qj(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function e0(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function t0(e){return this.select(e?e0:Qj)}function n0(e){return arguments.length?this.property("__data__",e):this.node().__data__}function s0(e){return function(t){e.call(this,t,this.__data__)}}function o0(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 r0(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 i0(e,t,n){return function(){var s=this.__on,r,i=s0(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 l0(e,t,n){var s=o0(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?i0:r0,r=0;r<i;++r)this.each(c(s[r],t,n));return this}function kc(e,t,n){var s=Rc(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 c0(e,t){return function(){return kc(this,e,t)}}function a0(e,t){return function(){return kc(this,e,t.apply(this,arguments))}}function u0(e,t){return this.each((typeof t=="function"?a0:c0)(e,t))}function*d0(){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 _c=[null];function ze(e,t){this._groups=e,this._parents=t}function Sn(){return new ze([[document.documentElement]],_c)}function x0(){return this}ze.prototype=Sn.prototype={constructor:ze,select:B1,selectAll:F1,selectChild:Y1,selectChildren:q1,filter:U1,data:sj,enter:J1,exit:rj,join:ij,merge:lj,selection:x0,order:cj,sort:aj,call:dj,nodes:xj,node:pj,size:mj,empty:fj,each:hj,attr:Cj,style:kj,property:Pj,classed:Ij,text:Dj,html:Hj,raise:Gj,lower:Wj,append:Kj,insert:qj,remove:Jj,clone:t0,datum:n0,on:l0,dispatch:u0,[Symbol.iterator]:d0};function $e(e){return typeof e=="string"?new ze([[document.querySelector(e)]],[document.documentElement]):new ze([[e]],_c)}function p0(e){let t;for(;t=e.sourceEvent;)e=t;return e}function De(e,t){if(e=p0(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 m0={passive:!1},xn={capture:!0,passive:!1};function Ws(e){e.stopImmediatePropagation()}function $t(e){e.preventDefault(),e.stopImmediatePropagation()}function Mc(e){var t=e.document.documentElement,n=$e(e).on("dragstart.drag",$t,xn);"onselectstart"in t?n.on("selectstart.drag",$t,xn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Lc(e,t){var n=e.document.documentElement,s=$e(e).on("dragstart.drag",null);t&&(s.on("click.drag",$t,xn),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 Mn=e=>()=>e;function fo(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}})}fo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function f0(e){return!e.ctrlKey&&!e.button}function h0(){return this.parentNode}function g0(e,t){return t??{x:e.x,y:e.y}}function j0(){return navigator.maxTouchPoints||"ontouchstart"in this}function Pc(){var e=f0,t=h0,n=g0,s=j0,r={},i=Es("start","drag","end"),l=0,c,a,d,x,p=0;function m(b){b.on("mousedown.drag",f).filter(s).on("touchstart.drag",y).on("touchmove.drag",S,m0).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(b,w){if(!(x||!e.call(this,b,w))){var L=C(this,t.call(this,b,w),b,w,"mouse");L&&($e(b.view).on("mousemove.drag",h,xn).on("mouseup.drag",E,xn),Mc(b.view),Ws(b),d=!1,c=b.clientX,a=b.clientY,L("start",b))}}function h(b){if($t(b),!d){var w=b.clientX-c,L=b.clientY-a;d=w*w+L*L>p}r.mouse("drag",b)}function E(b){$e(b.view).on("mousemove.drag mouseup.drag",null),Lc(b.view,d),$t(b),r.mouse("end",b)}function y(b,w){if(e.call(this,b,w)){var L=b.changedTouches,_=t.call(this,b,w),N=L.length,A,I;for(A=0;A<N;++A)(I=C(this,_,b,w,L[A].identifier,L[A]))&&(Ws(b),I("start",b,L[A]))}}function S(b){var w=b.changedTouches,L=w.length,_,N;for(_=0;_<L;++_)(N=r[w[_].identifier])&&($t(b),N("drag",b,w[_]))}function k(b){var w=b.changedTouches,L=w.length,_,N;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),_=0;_<L;++_)(N=r[w[_].identifier])&&(Ws(b),N("end",b,w[_]))}function C(b,w,L,_,N,A){var I=i.copy(),F=De(A||L,w),$,z,R;if((R=n.call(b,new fo("beforestart",{sourceEvent:L,target:m,identifier:N,active:l,x:F[0],y:F[1],dx:0,dy:0,dispatch:I}),_))!=null)return $=R.x-F[0]||0,z=R.y-F[1]||0,function T(M,D,P){var V=F,H;switch(M){case"start":r[N]=T,H=l++;break;case"end":delete r[N],--l;case"drag":F=De(P||D,w),H=l;break}I.call(M,b,new fo(M,{sourceEvent:D,subject:R,target:m,identifier:N,active:H,x:F[0]+$,y:F[1]+z,dx:F[0]-V[0],dy:F[1]-V[1],dispatch:I}),_)}}return m.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Mn(!!b),m):e},m.container=function(b){return arguments.length?(t=typeof b=="function"?b:Mn(b),m):t},m.subject=function(b){return arguments.length?(n=typeof b=="function"?b:Mn(b),m):n},m.touchable=function(b){return arguments.length?(s=typeof b=="function"?b:Mn(!!b),m):s},m.on=function(){var b=i.on.apply(i,arguments);return b===i?m:b},m.clickDistance=function(b){return arguments.length?(p=(b=+b)*b,m):Math.sqrt(p)},m}var Ot=0,nn=0,en=0,Tc=1e3,os,sn,rs=0,vt=0,Ss=0,pn=typeof performance=="object"&&performance.now?performance:Date,Nc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ir(){return vt||(Nc(E0),vt=pn.now()+Ss)}function E0(){vt=0}function is(){this._call=this._time=this._next=null}is.prototype=Ac.prototype={constructor:is,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ir():+n)+(t==null?0:+t),!this._next&&sn!==this&&(sn?sn._next=this:os=this,sn=this),this._call=e,this._time=n,ho()},stop:function(){this._call&&(this._call=null,this._time=1/0,ho())}};function Ac(e,t,n){var s=new is;return s.restart(e,t,n),s}function y0(){ir(),++Ot;for(var e=os,t;e;)(t=vt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ot}function qr(){vt=(rs=pn.now())+Ss,Ot=nn=0;try{y0()}finally{Ot=0,R0(),vt=0}}function S0(){var e=pn.now(),t=e-rs;t>Tc&&(Ss-=t,rs=e)}function R0(){for(var e,t=os,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:os=n);sn=e,ho(s)}function ho(e){if(!Ot){nn&&(nn=clearTimeout(nn));var t=e-vt;t>24?(e<1/0&&(nn=setTimeout(qr,e-pn.now()-Ss)),en&&(en=clearInterval(en))):(en||(rs=pn.now(),en=setInterval(S0,Tc)),Ot=1,Nc(qr))}}function Ur(e,t,n){var s=new is;return t=t==null?0:+t,s.restart(r=>{s.stop(),e(r+t)},t,n),s}var C0=Es("start","end","cancel","interrupt"),b0=[],Ic=0,Jr=1,go=2,Hn=3,Qr=4,jo=5,Zn=6;function Rs(e,t,n,s,r,i){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;w0(e,n,{name:t,index:s,group:r,on:C0,tween:b0,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ic})}function lr(e,t){var n=He(e,t);if(n.state>Ic)throw new Error("too late; already scheduled");return n}function Xe(e,t){var n=He(e,t);if(n.state>Hn)throw new Error("too late; already running");return n}function He(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function w0(e,t,n){var s=e.__transition,r;s[t]=n,n.timer=Ac(i,0,n.time);function i(d){n.state=Jr,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!==Jr)return a();for(x in s)if(f=s[x],f.name===n.name){if(f.state===Hn)return Ur(l);f.state===Qr?(f.state=Zn,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete s[x]):+x<t&&(f.state=Zn,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete s[x])}if(Ur(function(){n.state===Hn&&(n.state=Qr,n.timer.restart(c,n.delay,n.time),c(d))}),n.state=go,n.on.call("start",e,e.__data__,n.index,n.group),n.state===go){for(n.state=Hn,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=jo,1),p=-1,m=r.length;++p<m;)r[p].call(e,x);n.state===jo&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){n.state=Zn,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function Gn(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>go&&s.state<jo,s.state=Zn,s.timer.stop(),s.on.call(r?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[l]}i&&delete e.__transition}}function v0(e){return this.each(function(){Gn(this,e)})}function k0(e,t){var n,s;return function(){var r=Xe(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 _0(e,t,n){var s,r;if(typeof n!="function")throw new Error;return function(){var i=Xe(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 M0(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=He(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?k0:_0)(n,e,t))}function cr(e,t,n){var s=e._id;return e.each(function(){var r=Xe(this,s);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return He(r,s).value[t]}}function $c(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 L0(e){return function(){this.removeAttribute(e)}}function P0(e){return function(){this.removeAttributeNS(e.space,e.local)}}function T0(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 N0(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 A0(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 I0(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 $0(e,t){var n=ys(e),s=n==="transform"?yf:$c;return this.attrTween(e,typeof t=="function"?(n.local?I0:A0)(n,s,cr(this,"attr."+e,t)):t==null?(n.local?P0:L0)(n):(n.local?N0:T0)(n,s,t))}function z0(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function B0(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function D0(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&B0(e,i)),n}return r._value=t,r}function O0(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&z0(e,i)),n}return r._value=t,r}function V0(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=ys(e);return this.tween(n,(s.local?D0:O0)(s,t))}function F0(e,t){return function(){lr(this,e).delay=+t.apply(this,arguments)}}function H0(e,t){return t=+t,function(){lr(this,e).delay=t}}function Z0(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?F0:H0)(t,e)):He(this.node(),t).delay}function G0(e,t){return function(){Xe(this,e).duration=+t.apply(this,arguments)}}function Y0(e,t){return t=+t,function(){Xe(this,e).duration=t}}function W0(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?G0:Y0)(t,e)):He(this.node(),t).duration}function K0(e,t){if(typeof t!="function")throw new Error;return function(){Xe(this,e).ease=t}}function X0(e){var t=this._id;return arguments.length?this.each(K0(t,e)):He(this.node(),t).ease}function q0(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Xe(this,e).ease=n}}function U0(e){if(typeof e!="function")throw new Error;return this.each(q0(this._id,e))}function J0(e){typeof e!="function"&&(e=Ec(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 et(s,this._parents,this._name,this._id)}function Q0(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 et(l,this._parents,this._name,this._id)}function e2(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 t2(e,t,n){var s,r,i=e2(t)?lr:Xe;return function(){var l=i(this,e),c=l.on;c!==s&&(r=(s=c).copy()).on(t,n),l.on=r}}function n2(e,t){var n=this._id;return arguments.length<2?He(this.node(),n).on.on(e):this.each(t2(n,e,t))}function s2(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function o2(){return this.on("end.remove",s2(this._id))}function r2(e){var t=this._name,n=this._id;typeof e!="function"&&(e=or(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,Rs(d[m],t,n,m,d,He(x,n)));return new et(i,this._parents,t,n)}function i2(e){var t=this._name,n=this._id;typeof e!="function"&&(e=jc(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=He(x,n),E=0,y=m.length;E<y;++E)(f=m[E])&&Rs(f,t,n,E,m,h);i.push(m),l.push(x)}return new et(i,l,t,n)}var l2=Sn.prototype.constructor;function c2(){return new l2(this._groups,this._parents)}function a2(e,t){var n,s,r;return function(){var i=Dt(this,e),l=(this.style.removeProperty(e),Dt(this,e));return i===l?null:i===n&&l===s?r:r=t(n=i,s=l)}}function zc(e){return function(){this.style.removeProperty(e)}}function u2(e,t,n){var s,r=n+"",i;return function(){var l=Dt(this,e);return l===r?null:l===s?i:i=t(s=l,n)}}function d2(e,t,n){var s,r,i;return function(){var l=Dt(this,e),c=n(this),a=c+"";return c==null&&(a=c=(this.style.removeProperty(e),Dt(this,e))),l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c))}}function x2(e,t){var n,s,r,i="style."+t,l="end."+i,c;return function(){var a=Xe(this,e),d=a.on,x=a.value[i]==null?c||(c=zc(t)):void 0;(d!==n||r!==x)&&(s=(n=d).copy()).on(l,r=x),a.on=s}}function p2(e,t,n){var s=(e+="")=="transform"?Ef:$c;return t==null?this.styleTween(e,a2(e,s)).on("end.style."+e,zc(e)):typeof t=="function"?this.styleTween(e,d2(e,s,cr(this,"style."+e,t))).each(x2(this._id,e)):this.styleTween(e,u2(e,s,t),n).on("end.style."+e,null)}function m2(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function f2(e,t,n){var s,r;function i(){var l=t.apply(this,arguments);return l!==r&&(s=(r=l)&&m2(e,l,n)),s}return i._value=t,i}function h2(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,f2(e,t,n??""))}function g2(e){return function(){this.textContent=e}}function j2(e){return function(){var t=e(this);this.textContent=t??""}}function E2(e){return this.tween("text",typeof e=="function"?j2(cr(this,"text",e)):g2(e==null?"":e+""))}function y2(e){return function(t){this.textContent=e.call(this,t)}}function S2(e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&y2(r)),t}return s._value=e,s}function R2(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,S2(e))}function C2(){for(var e=this._name,t=this._id,n=Bc(),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=He(a,t);Rs(a,e,n,d,l,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new et(s,this._parents,e,n)}function b2(){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=Xe(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 w2=0;function et(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Bc(){return++w2}var Ue=Sn.prototype;et.prototype={constructor:et,select:r2,selectAll:i2,selectChild:Ue.selectChild,selectChildren:Ue.selectChildren,filter:J0,merge:Q0,selection:c2,transition:C2,call:Ue.call,nodes:Ue.nodes,node:Ue.node,size:Ue.size,empty:Ue.empty,each:Ue.each,on:n2,attr:$0,attrTween:V0,style:p2,styleTween:h2,text:E2,textTween:R2,remove:o2,tween:M0,delay:Z0,duration:W0,ease:X0,easeVarying:U0,end:b2,[Symbol.iterator]:Ue[Symbol.iterator]};function v2(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var k2={time:null,delay:0,duration:250,ease:v2};function _2(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 M2(e){var t,n;e instanceof et?(t=e._id,e=e._name):(t=Bc(),(n=k2).time=ir(),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])&&Rs(a,e,t,d,l,n||_2(a,t));return new et(s,this._parents,e,t)}Sn.prototype.interrupt=v0;Sn.prototype.transition=M2;const Ln=e=>()=>e;function L2(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 Je(e,t,n){this.k=e,this.x=t,this.y=n}Je.prototype={constructor:Je,scale:function(e){return e===1?this:new Je(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Je(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 Cs=new Je(1,0,0);Dc.prototype=Je.prototype;function Dc(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Cs;return e.__zoom}function Ks(e){e.stopImmediatePropagation()}function tn(e){e.preventDefault(),e.stopImmediatePropagation()}function P2(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function T2(){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 ei(){return this.__zoom||Cs}function N2(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function A2(){return navigator.maxTouchPoints||"ontouchstart"in this}function I2(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 Oc(){var e=P2,t=T2,n=I2,s=N2,r=A2,i=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,a=bf,d=Es("start","zoom","end"),x,p,m,f=500,h=150,E=0,y=10;function S(R){R.property("__zoom",ei).on("wheel.zoom",N,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",I).filter(r).on("touchstart.zoom",F).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(R,T,M,D){var P=R.selection?R.selection():R;P.property("__zoom",ei),R!==P?w(R,T,M,D):P.interrupt().each(function(){L(this,arguments).event(D).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},S.scaleBy=function(R,T,M,D){S.scaleTo(R,function(){var P=this.__zoom.k,V=typeof T=="function"?T.apply(this,arguments):T;return P*V},M,D)},S.scaleTo=function(R,T,M,D){S.transform(R,function(){var P=t.apply(this,arguments),V=this.__zoom,H=M==null?b(P):typeof M=="function"?M.apply(this,arguments):M,G=V.invert(H),q=typeof T=="function"?T.apply(this,arguments):T;return n(C(k(V,q),H,G),P,l)},M,D)},S.translateBy=function(R,T,M,D){S.transform(R,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),l)},null,D)},S.translateTo=function(R,T,M,D,P){S.transform(R,function(){var V=t.apply(this,arguments),H=this.__zoom,G=D==null?b(V):typeof D=="function"?D.apply(this,arguments):D;return n(Cs.translate(G[0],G[1]).scale(H.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof M=="function"?-M.apply(this,arguments):-M),V,l)},D,P)};function k(R,T){return T=Math.max(i[0],Math.min(i[1],T)),T===R.k?R:new Je(T,R.x,R.y)}function C(R,T,M){var D=T[0]-M[0]*R.k,P=T[1]-M[1]*R.k;return D===R.x&&P===R.y?R:new Je(R.k,D,P)}function b(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function w(R,T,M,D){R.on("start.zoom",function(){L(this,arguments).event(D).start()}).on("interrupt.zoom end.zoom",function(){L(this,arguments).event(D).end()}).tween("zoom",function(){var P=this,V=arguments,H=L(P,V).event(D),G=t.apply(P,V),q=M==null?b(G):typeof M=="function"?M.apply(P,V):M,oe=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),ee=P.__zoom,ne=typeof T=="function"?T.apply(P,V):T,se=a(ee.invert(q).concat(oe/ee.k),ne.invert(q).concat(oe/ne.k));return function(ie){if(ie===1)ie=ne;else{var U=se(ie),ue=oe/U[2];ie=new Je(ue,q[0]-U[0]*ue,q[1]-U[1]*ue)}H.zoom(null,ie)}})}function L(R,T,M){return!M&&R.__zooming||new _(R,T)}function _(R,T){this.that=R,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(R,T),this.taps=0}_.prototype={event:function(R){return R&&(this.sourceEvent=R),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(R,T){return this.mouse&&R!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&R!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&R!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(R){var T=$e(this.that).datum();d.call(R,this.that,new L2(R,{sourceEvent:this.sourceEvent,target:S,type:R,transform:this.that.__zoom,dispatch:d}),T)}};function N(R,...T){if(!e.apply(this,arguments))return;var M=L(this,T).event(R),D=this.__zoom,P=Math.max(i[0],Math.min(i[1],D.k*Math.pow(2,s.apply(this,arguments)))),V=De(R);if(M.wheel)(M.mouse[0][0]!==V[0]||M.mouse[0][1]!==V[1])&&(M.mouse[1]=D.invert(M.mouse[0]=V)),clearTimeout(M.wheel);else{if(D.k===P)return;M.mouse=[V,D.invert(V)],Gn(this),M.start()}tn(R),M.wheel=setTimeout(H,h),M.zoom("mouse",n(C(k(D,P),M.mouse[0],M.mouse[1]),M.extent,l));function H(){M.wheel=null,M.end()}}function A(R,...T){if(m||!e.apply(this,arguments))return;var M=R.currentTarget,D=L(this,T,!0).event(R),P=$e(R.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",oe,!0),V=De(R,M),H=R.clientX,G=R.clientY;Mc(R.view),Ks(R),D.mouse=[V,this.__zoom.invert(V)],Gn(this),D.start();function q(ee){if(tn(ee),!D.moved){var ne=ee.clientX-H,se=ee.clientY-G;D.moved=ne*ne+se*se>E}D.event(ee).zoom("mouse",n(C(D.that.__zoom,D.mouse[0]=De(ee,M),D.mouse[1]),D.extent,l))}function oe(ee){P.on("mousemove.zoom mouseup.zoom",null),Lc(ee.view,D.moved),tn(ee),D.event(ee).end()}}function I(R,...T){if(e.apply(this,arguments)){var M=this.__zoom,D=De(R.changedTouches?R.changedTouches[0]:R,this),P=M.invert(D),V=M.k*(R.shiftKey?.5:2),H=n(C(k(M,V),D,P),t.apply(this,T),l);tn(R),c>0?$e(this).transition().duration(c).call(w,H,D,R):$e(this).call(S.transform,H,D,R)}}function F(R,...T){if(e.apply(this,arguments)){var M=R.touches,D=M.length,P=L(this,T,R.changedTouches.length===D).event(R),V,H,G,q;for(Ks(R),H=0;H<D;++H)G=M[H],q=De(G,this),q=[q,this.__zoom.invert(q),G.identifier],P.touch0?!P.touch1&&P.touch0[2]!==q[2]&&(P.touch1=q,P.taps=0):(P.touch0=q,V=!0,P.taps=1+!!x);x&&(x=clearTimeout(x)),V&&(P.taps<2&&(p=q[0],x=setTimeout(function(){x=null},f)),Gn(this),P.start())}}function $(R,...T){if(this.__zooming){var M=L(this,T).event(R),D=R.changedTouches,P=D.length,V,H,G,q;for(tn(R),V=0;V<P;++V)H=D[V],G=De(H,this),M.touch0&&M.touch0[2]===H.identifier?M.touch0[0]=G:M.touch1&&M.touch1[2]===H.identifier&&(M.touch1[0]=G);if(H=M.that.__zoom,M.touch1){var oe=M.touch0[0],ee=M.touch0[1],ne=M.touch1[0],se=M.touch1[1],ie=(ie=ne[0]-oe[0])*ie+(ie=ne[1]-oe[1])*ie,U=(U=se[0]-ee[0])*U+(U=se[1]-ee[1])*U;H=k(H,Math.sqrt(ie/U)),G=[(oe[0]+ne[0])/2,(oe[1]+ne[1])/2],q=[(ee[0]+se[0])/2,(ee[1]+se[1])/2]}else if(M.touch0)G=M.touch0[0],q=M.touch0[1];else return;M.zoom("touch",n(C(H,G,q),M.extent,l))}}function z(R,...T){if(this.__zooming){var M=L(this,T).event(R),D=R.changedTouches,P=D.length,V,H;for(Ks(R),m&&clearTimeout(m),m=setTimeout(function(){m=null},f),V=0;V<P;++V)H=D[V],M.touch0&&M.touch0[2]===H.identifier?delete M.touch0:M.touch1&&M.touch1[2]===H.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(H=De(H,this),Math.hypot(p[0]-H[0],p[1]-H[1])<y)){var G=$e(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return S.wheelDelta=function(R){return arguments.length?(s=typeof R=="function"?R:Ln(+R),S):s},S.filter=function(R){return arguments.length?(e=typeof R=="function"?R:Ln(!!R),S):e},S.touchable=function(R){return arguments.length?(r=typeof R=="function"?R:Ln(!!R),S):r},S.extent=function(R){return arguments.length?(t=typeof R=="function"?R:Ln([[+R[0][0],+R[0][1]],[+R[1][0],+R[1][1]]]),S):t},S.scaleExtent=function(R){return arguments.length?(i[0]=+R[0],i[1]=+R[1],S):[i[0],i[1]]},S.translateExtent=function(R){return arguments.length?(l[0][0]=+R[0][0],l[1][0]=+R[1][0],l[0][1]=+R[0][1],l[1][1]=+R[1][1],S):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},S.constrain=function(R){return arguments.length?(n=R,S):n},S.duration=function(R){return arguments.length?(c=+R,S):c},S.interpolate=function(R){return arguments.length?(a=R,S):a},S.on=function(){var R=d.on.apply(d,arguments);return R===d?S:R},S.clickDistance=function(R){return arguments.length?(E=(R=+R)*R,S):Math.sqrt(E)},S.tapDistance=function(R){return arguments.length?(y=+R,S):y},S}const Ie={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.`},mn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Vc=["Enter"," ","Escape"];var kt;(function(e){e.Strict="strict",e.Loose="loose"})(kt||(kt={}));var Rt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Rt||(Rt={}));var Vt;(function(e){e.Partial="partial",e.Full="full"})(Vt||(Vt={}));const Fc={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var lt;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(lt||(lt={}));var ls;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ls||(ls={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const ti={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function Hc(e){return e===null?null:e?"valid":"invalid"}const Zc=e=>"id"in e&&"source"in e&&"target"in e,$2=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),ar=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Rn=(e,t=[0,0])=>{const{width:n,height:s}=st(e),r=e.origin??t,i=n*r[0],l=s*r[1];return{x:e.position.x-i,y:e.position.y-l}},z2=(e,t={nodeOrigin:[0,0],nodeLookup:void 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):ar(r)?r:t.nodeLookup.get(r.id));const c=l?cs(l,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return bs(s,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ws(n)},Cn=(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=cs(s);n=bs(n,r)}}),ws(n)},Gc=(e,t,[n,s,r]=[0,0,1],i=!1,l=!1)=>{const c={...bn(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,E=fn(c,Ht(d)),y=(f??0)*(h??0),S=i&&E>0;(!d.internals.handleBounds||S||E>=y||d.dragging)&&a.push(d)}return a},B2=(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 Eo(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 yo({nodes:e,width:t,height:n,panZoom:s,minZoom:r,maxZoom:i},l){if(e.size===0)return Promise.resolve(!1);const c=Cn(e),a=ur(c,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(a,{duration:l==null?void 0:l.duration}),Promise.resolve(!0)}function Yc({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",Ie.error005());else{const f=c.measured.width,h=c.measured.height;f&&h&&(p=[[a,d],[a+f,d+h]])}else c&&Zt(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=Zt(p)?_t(t,p,l.measured):t;return{position:{x:m.x-a+l.measured.width*x[0],y:m.y-d+l.measured.height*x[1]},positionAbsolute:m}}async function D2({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(E=>E.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=B2(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 Ft=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),_t=(e={x:0,y:0},t,n)=>({x:Ft(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Ft(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Wc(e,t,n){const{width:s,height:r}=st(n),{x:i,y:l}=n.internals.positionAbsolute;return _t(e,[[i,l],[i+s,l+r]],t)}const ni=(e,t,n)=>e<t?Ft(Math.abs(e-t),1,t)/t:e>n?-Ft(Math.abs(e-n),1,t)/t:0,Kc=(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]},bs=(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)}),So=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),ws=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),Ht=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=ar(e)?e.internals.positionAbsolute:Rn(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}},cs=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=ar(e)?e.internals.positionAbsolute:Rn(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)}},Xc=(e,t)=>ws(bs(So(e),So(t))),fn=(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)},si=e=>Oe(e.width)&&Oe(e.height)&&Oe(e.x)&&Oe(e.y),Oe=e=>!isNaN(e)&&isFinite(e),as=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},vs=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),bn=({x:e,y:t},[n,s,r],i=!1,l=[1,1])=>{const c={x:(e-n)/r,y:(t-s)/r};return i?vs(c,l):c},qc=({x:e,y:t},[n,s,r])=>({x:e*r+n,y:t*r+s}),ur=(e,t,n,s,r,i)=>{const l=t/(e.width*(1+i)),c=n/(e.height*(1+i)),a=Math.min(l,c),d=Ft(a,s,r),x=e.x+e.width/2,p=e.y+e.height/2,m=t/2-x*d,f=n/2-p*d;return{x:m,y:f,zoom:d}},us=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Zt(e){return e!==void 0&&e!=="parent"}function st(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 Uc(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 Jc(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 rn(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:r}){const{x:i,y:l}=Qe(e),c=bn({x:i-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},s),{x:a,y:d}=n?vs(c,t):c;return{xSnapped:a,ySnapped:d,...c}}const ks=e=>({width:e.offsetWidth,height:e.offsetHeight}),Qc=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},O2=["INPUT","SELECT","TEXTAREA"];function Ro(e){var s,r,i;const t=((r=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:r[0])||e.target;return O2.includes(t==null?void 0:t.nodeName)||((i=t==null?void 0:t.hasAttribute)==null?void 0:i.call(t,"contenteditable"))||!!(t!=null&&t.closest(".nokey"))}const ea=e=>"clientX"in e,Qe=(e,t)=>{var i,l;const n=ea(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)}},oi=(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,...ks(l)}})};function ta({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 Pn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ri({pos:e,x1:t,y1:n,x2:s,y2:r,c:i}){switch(e){case X.Left:return[t-Pn(t-s,i),n];case X.Right:return[t+Pn(s-t,i),n];case X.Top:return[t,n-Pn(n-r,i)];case X.Bottom:return[t,n+Pn(r-n,i)]}}function na({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:s,targetY:r,targetPosition:i=X.Top,curvature:l=.25}){const[c,a]=ri({pos:n,x1:e,y1:t,x2:s,y2:r,c:l}),[d,x]=ri({pos:i,x1:s,y1:r,x2:e,y2:t,c:l}),[p,m,f,h]=ta({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 sa({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 V2({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 F2({sourceNode:e,targetNode:t,width:n,height:s,transform:r}){const i=bs(cs(e),cs(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 fn(l,ws(i))>0}const oa=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,H2=(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)),ra=(e,t)=>{if(!e.source||!e.target)return as("006",Ie.error006()),t;let n;return Zc(e)?n={...e}:n={...e,id:oa(e)},H2(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))},Z2=(e,t,n,s={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return as("006",Ie.error006()),n;if(!n.find(a=>a.id===e.id))return as("007",Ie.error007(r)),n;const c={...i,id:s.shouldReplaceId?oa(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(a=>a.id!==r).concat(c)};function ia({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[r,i,l,c]=sa({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,r,i,l,c]}const ii={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},G2=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.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},li=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Y2({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:s=X.Top,center:r,offset:i}){const l=ii[t],c=ii[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=G2({source:a,sourcePosition:t,target:d}),p=x.x!==0?"x":"y",m=x[p];let f=[],h,E;const y={x:0,y:0},S={x:0,y:0},[k,C,b,w]=sa({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){h=r.x??k,E=r.y??C;const _=[{x:h,y:a.y},{x:h,y:d.y}],N=[{x:a.x,y:E},{x:d.x,y:E}];l[p]===m?f=p==="x"?_:N:f=p==="x"?N:_}else{const _=[{x:a.x,y:d.y}],N=[{x:d.x,y:a.y}];if(p==="x"?f=l.x===m?N:_:f=l.y===m?_:N,t===s){const z=Math.abs(e[p]-n[p]);if(z<=i){const R=Math.min(i-1,i-z);l[p]===m?y[p]=(a[p]>e[p]?-1:1)*R:S[p]=(d[p]>n[p]?-1:1)*R}}if(t!==s){const z=p==="x"?"y":"x",R=l[p]===c[z],T=a[z]>d[z],M=a[z]<d[z];(l[p]===1&&(!R&&T||R&&M)||l[p]!==1&&(!R&&M||R&&T))&&(f=p==="x"?_:N)}const A={x:a.x+y.x,y:a.y+y.y},I={x:d.x+S.x,y:d.y+S.y},F=Math.max(Math.abs(A.x-f[0].x),Math.abs(I.x-f[0].x)),$=Math.max(Math.abs(A.y-f[0].y),Math.abs(I.y-f[0].y));F>=$?(h=(A.x+I.x)/2,E=f[0].y):(h=f[0].x,E=(A.y+I.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,E,b,w]}function W2(e,t,n,s){const r=Math.min(li(e,t)/2,li(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 Co({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:s,targetY:r,targetPosition:i=X.Top,borderRadius:l=5,centerX:c,centerY:a,offset:d=20}){const[x,p,m,f,h]=Y2({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,k)=>{let C="";return k>0&&k<x.length-1?C=W2(x[k-1],S,x[k+1],l):C=`${k===0?"M":"L"}${S.x} ${S.y}`,y+=C,y},""),p,m,f,h]}function ci(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function K2(e){var p;const{sourceNode:t,targetNode:n}=e;if(!ci(t)||!ci(n))return null;const s=t.internals.handleBounds||ai(t.handles),r=n.internals.handleBounds||ai(n.handles),i=ui((s==null?void 0:s.source)??[],e.sourceHandle),l=ui(e.connectionMode===kt.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",Ie.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(i==null?void 0:i.position)||X.Bottom,a=(l==null?void 0:l.position)||X.Top,d=hn(t,i,c),x=hn(n,l,a);return{sourceX:d.x,sourceY:d.y,targetX:x.x,targetY:x.y,sourcePosition:c,targetPosition:a}}function ai(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 hn(e,t,n=X.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??st(e);if(s)return{x:r+l/2,y:i+c/2};switch((t==null?void 0:t.position)??n){case X.Top:return{x:r+l/2,y:i};case X.Right:return{x:r+l,y:i+c/2};case X.Bottom:return{x:r+l/2,y:i+c};case X.Left:return{x:r,y:i+c/2}}}function ui(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function bo(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function X2(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=bo(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 dr={nodeOrigin:[0,0],nodeExtent:mn,elevateNodesOnSelect:!0,defaults:{}},q2={...dr,checkEquality:!0};function xr(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function U2(e,t,n){const s=xr(dr,n);for(const r of e.values())if(r.parentId)pr(r,e,t,s);else{const i=Rn(r,s.nodeOrigin),l=Zt(r.extent)?r.extent:s.nodeExtent,c=_t(i,l,st(r));r.internals.positionAbsolute=c}}function wo(e,t,n,s){var c,a;const r=xr(q2,s),i=new Map(t),l=r!=null&&r.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const d of e){let x=i.get(d.id);if(r.checkEquality&&d===(x==null?void 0:x.internals.userNode))t.set(d.id,x);else{const p=Rn(d,r.nodeOrigin),m=Zt(d.extent)?d.extent:r.nodeExtent,f=_t(p,m,st(d));x={...r.defaults,...d,measured:{width:(c=d.measured)==null?void 0:c.width,height:(a=d.measured)==null?void 0:a.height},internals:{positionAbsolute:f,handleBounds:d.measured?x==null?void 0:x.internals.handleBounds:void 0,z:la(d,l),userNode:d}},t.set(d.id,x)}d.parentId&&pr(x,t,n,s)}}function J2(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 pr(e,t,n,s){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:l}=xr(dr,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}J2(e,n);const d=r?1e3:0,{x,y:p,z:m}=Q2(e,a,i,l,d),{positionAbsolute:f}=e.internals,h=x!==f.x||p!==f.y;(h||m!==e.internals.z)&&(e.internals={...e.internals,positionAbsolute:h?{x,y:p}:f,z:m})}function la(e,t){return(Oe(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function Q2(e,t,n,s,r){const{x:i,y:l}=t.internals.positionAbsolute,c=st(e),a=Rn(e,n),d=Zt(e.extent)?_t(a,e.extent,c):a;let x=_t({x:i+d.x,y:l+d.y},s,c);e.extent==="parent"&&(x=Wc(x,c,t));const p=la(e,r),m=t.internals.z??0;return{x:x.x,y:x.y,z:m>p?m:p}}function mr(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)??Ht(a),x=Xc(d,c.rect);i.set(c.parentId,{expandedRect:x,parent:a})}return i.size>0&&i.forEach(({expandedRect:c,parent:a},d)=>{var C;const x=a.internals.positionAbsolute,p=st(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,E=Math.max(p.width,Math.round(c.width)),y=Math.max(p.height,Math.round(c.height)),S=(E-p.width)*m[0],k=(y-p.height)*m[1];(f>0||h>0||S||k)&&(r.push({id:d,type:"position",position:{x:a.position.x-f+S,y:a.position.y-h+k}}),(C=n.get(d))==null||C.forEach(b=>{e.some(w=>w.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+h}})})),(p.width<c.width||p.height<c.height||f||h)&&r.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:E+(f?m[0]*f-S:0),height:y+(h?m[1]*h-k:0)}})}),r}function e3(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)if(f.hidden)f.internals={...f.internals,handleBounds:void 0},c=!0;else{const h=ks(m.nodeElement),E=f.measured.width!==h.width||f.measured.height!==h.height;if(!!(h.width&&h.height&&(E||!f.internals.handleBounds||m.force))){const S=m.nodeElement.getBoundingClientRect(),k=Zt(f.extent)?f.extent:i;let{positionAbsolute:C}=f.internals;f.parentId&&f.extent==="parent"?C=Wc(C,h,t.get(f.parentId)):k&&(C=_t(C,k,h)),f.measured=h,f.internals={...f.internals,positionAbsolute:C,handleBounds:{source:oi("source",m.nodeElement,S,x,f.id),target:oi("target",m.nodeElement,S,x,f.id)}},f.parentId&&pr(f,t,n,{nodeOrigin:r}),c=!0,E&&(a.push({id:f.id,type:"dimensions",dimensions:h}),f.expandParent&&f.parentId&&p.push({id:f.id,parentId:f.parentId,rect:Ht(f,r)}))}}}if(p.length>0){const m=mr(p,t,n,r);a.push(...m)}return{changes:a,updatedInternals:c}}async function t3({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 ca(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=`${r}-source-${l}`,d=`${i}-target-${c}`,x=e.get(a)||new Map,p=e.get(d)||new Map,m={edgeId:s.id,source:r,target:i,sourceHandle:l,targetHandle:c};t.set(s.id,s),e.set(a,x.set(`${i}-${c}`,m)),e.set(d,p.set(`${r}-${l}`,m))}}function aa(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:aa(n,t):!1}function di(e,t,n){let s=e;do{if(s!=null&&s.matches(t))return!0;if(s===n)return!1;s=s.parentElement}while(s);return!1}function n3(e,t,n,s){const r=new Map;for(const[i,l]of e)if((l.selected||l.id===s)&&(!l.parentId||!aa(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 Xs({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 s3({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:k,isSelectable:C,nodeId:b,nodeClickDistance:w=0}){m=$e(k);function L({x:I,y:F},$){const{nodeLookup:z,nodeExtent:R,snapGrid:T,snapToGrid:M,nodeOrigin:D,onNodeDrag:P,onSelectionDrag:V,onError:H,updateNodePositions:G}=t();i={x:I,y:F};let q=!1,oe={x:0,y:0,x2:0,y2:0};if(c.size>1&&R){const ee=Cn(c);oe=So(ee)}for(const[ee,ne]of c){if(!z.has(ee))continue;let se={x:I-ne.distance.x,y:F-ne.distance.y};M&&(se=vs(se,T));let ie=[[R[0][0],R[0][1]],[R[1][0],R[1][1]]];if(c.size>1&&R&&!ne.extent){const{positionAbsolute:ge}=ne.internals,pe=ge.x-oe.x+R[0][0],re=ge.x+ne.measured.width-oe.x2+R[1][0],Q=ge.y-oe.y+R[0][1],le=ge.y+ne.measured.height-oe.y2+R[1][1];ie=[[pe,Q],[re,le]]}const{position:U,positionAbsolute:ue}=Yc({nodeId:ee,nextPosition:se,nodeLookup:z,nodeExtent:ie,nodeOrigin:D,onError:H});q=q||ne.position.x!==U.x||ne.position.y!==U.y,ne.position=U,ne.internals.positionAbsolute=ue}if(q&&(G(c,!0),$&&(s||P||!b&&V))){const[ee,ne]=Xs({nodeId:b,dragItems:c,nodeLookup:z});s==null||s($,c,ee,ne),P==null||P($,ee,ne),b||V==null||V($,ne)}}async function _(){if(!x)return;const{transform:I,panBy:F,autoPanSpeed:$}=t(),[z,R]=Kc(d,x,$);(z!==0||R!==0)&&(i.x=(i.x??0)-z/I[2],i.y=(i.y??0)-R/I[2],await F({x:z,y:R})&&L(i,null)),l=requestAnimationFrame(_)}function N(I){var q;const{nodeLookup:F,multiSelectionActive:$,nodesDraggable:z,transform:R,snapGrid:T,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:P,onSelectionDragStart:V,unselectNodesAndEdges:H}=t();p=!0,(!D||!C)&&!$&&b&&((q=F.get(b))!=null&&q.selected||H()),C&&D&&b&&(e==null||e(b));const G=rn(I.sourceEvent,{transform:R,snapGrid:T,snapToGrid:M,containerBounds:x});if(i=G,c=n3(F,z,G,b),c.size>0&&(n||P||!b&&V)){const[oe,ee]=Xs({nodeId:b,dragItems:c,nodeLookup:F});n==null||n(I.sourceEvent,c,oe,ee),P==null||P(I.sourceEvent,oe,ee),b||V==null||V(I.sourceEvent,ee)}}const A=Pc().clickDistance(w).on("start",I=>{const{domNode:F,nodeDragThreshold:$,transform:z,snapGrid:R,snapToGrid:T}=t();x=(F==null?void 0:F.getBoundingClientRect())||null,f=!1,$===0&&N(I),i=rn(I.sourceEvent,{transform:z,snapGrid:R,snapToGrid:T,containerBounds:x}),d=Qe(I.sourceEvent,x)}).on("drag",I=>{const{autoPanOnNodeDrag:F,transform:$,snapGrid:z,snapToGrid:R,nodeDragThreshold:T,nodeLookup:M}=t(),D=rn(I.sourceEvent,{transform:$,snapGrid:z,snapToGrid:R,containerBounds:x});if((I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1||b&&!M.has(b))&&(f=!0),!f){if(!a&&F&&p&&(a=!0,_()),!p){const P=D.xSnapped-(i.x??0),V=D.ySnapped-(i.y??0);Math.sqrt(P*P+V*V)>T&&N(I)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&c&&p&&(d=Qe(I.sourceEvent,x),L(D,I.sourceEvent))}}).on("end",I=>{if(!(!p||f)&&(a=!1,p=!1,cancelAnimationFrame(l),c.size>0)){const{nodeLookup:F,updateNodePositions:$,onNodeDragStop:z,onSelectionDragStop:R}=t();if($(c,!1),r||z||!b&&R){const[T,M]=Xs({nodeId:b,dragItems:c,nodeLookup:F,dragging:!1});r==null||r(I.sourceEvent,c,T,M),z==null||z(I.sourceEvent,T,M),b||R==null||R(I.sourceEvent,M)}}}).filter(I=>{const F=I.target;return!I.button&&(!y||!di(F,`.${y}`,k))&&(!S||di(F,S,k))});m.call(A)}function E(){m==null||m.on(".drag",null)}return{update:h,destroy:E}}function o3(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())fn(r,Ht(i))>0&&s.push(i);return s}const r3=250;function i3(e,t,n,s){var c,a;let r=[],i=1/0;const l=o3(e,n,t+r3);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}=hn(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 ua(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,...hn(l,a,a.position,!0)}:a}function da(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function l3(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const xa=()=>!0;function c3(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:E,onConnectEnd:y,isValidConnection:S=xa,onReconnectEnd:k,updateConnection:C,getTransform:b,getFromHandle:w,autoPanSpeed:L}){const _=Qc(e.target);let N=0,A;const{x:I,y:F}=Qe(e),$=_==null?void 0:_.elementFromPoint(I,F),z=da(i,$),R=c==null?void 0:c.getBoundingClientRect();if(!R||!z)return;const T=ua(r,z,s,a,t);if(!T)return;let M=Qe(e,R),D=!1,P=null,V=!1,H=null;function G(){if(!x||!R)return;const[ue,ge]=Kc(M,R,L);m({x:ue,y:ge}),N=requestAnimationFrame(G)}const q={...T,nodeId:r,type:z,position:T.position},oe=a.get(r),ne={inProgress:!0,isValid:null,from:hn(oe,q,X.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:oe,to:M,toHandle:null,toPosition:ti[q.position],toNode:null};C(ne);let se=ne;h==null||h(e,{nodeId:r,handleId:s,handleType:z});function ie(ue){if(!w()||!q){U(ue);return}const ge=b();M=Qe(ue,R),A=i3(bn(M,ge,!1,[1,1]),n,a,q),D||(G(),D=!0);const pe=pa(ue,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:s,fromType:l?"target":"source",isValidConnection:S,doc:_,lib:d,flowId:p,nodeLookup:a});H=pe.handleDomNode,P=pe.connection,V=l3(!!A,pe.isValid);const re={...se,isValid:V,to:A&&V?qc({x:A.x,y:A.y},ge):M,toHandle:pe.toHandle,toPosition:V&&pe.toHandle?pe.toHandle.position:ti[q.position],toNode:pe.toHandle?a.get(pe.toHandle.nodeId):null};V&&A&&se.toHandle&&re.toHandle&&se.toHandle.type===re.toHandle.type&&se.toHandle.nodeId===re.toHandle.nodeId&&se.toHandle.id===re.toHandle.id&&se.to.x===re.to.x&&se.to.y===re.to.y||(C(re),se=re)}function U(ue){(A||H)&&P&&V&&(E==null||E(P));const{inProgress:ge,...pe}=se,re={...pe,toPosition:se.toHandle?se.toPosition:null};y==null||y(ue,re),i&&(k==null||k(ue,re)),f(),cancelAnimationFrame(N),D=!1,V=!1,P=null,H=null,_.removeEventListener("mousemove",ie),_.removeEventListener("mouseup",U),_.removeEventListener("touchmove",ie),_.removeEventListener("touchend",U)}_.addEventListener("mousemove",ie),_.addEventListener("mouseup",U),_.addEventListener("touchmove",ie),_.addEventListener("touchend",U)}function pa(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:r,fromType:i,doc:l,lib:c,flowId:a,isValidConnection:d=xa,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}=Qe(e),E=l.elementFromPoint(f,h),y=E!=null&&E.classList.contains(`${c}-flow__handle`)?E:m,S={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const k=da(void 0,y),C=y.getAttribute("data-nodeid"),b=y.getAttribute("data-handleid"),w=y.classList.contains("connectable"),L=y.classList.contains("connectableend");if(!C||!k)return S;const _={source:p?C:s,sourceHandle:p?b:r,target:p?s:C,targetHandle:p?r:b};S.connection=_;const A=w&&L&&(n===kt.Strict?p&&k==="source"||!p&&k==="target":C!==s||b!==r);S.isValid=A&&d(_),S.toHandle=ua(C,k,b,x,n,!1)}return S}const vo={onPointerDown:c3,isValid:pa};function a3({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const r=$e(e);function i({translateExtent:c,width:a,height:d,zoomStep:x=10,pannable:p=!0,zoomable:m=!0,inversePan:f=!1}){const h=C=>{const b=n();if(C.sourceEvent.type!=="wheel"||!t)return;const w=-C.sourceEvent.deltaY*(C.sourceEvent.deltaMode===1?.05:C.sourceEvent.deltaMode?1:.002)*x,L=b[2]*Math.pow(2,w);t.scaleTo(L)};let E=[0,0];const y=C=>{(C.sourceEvent.type==="mousedown"||C.sourceEvent.type==="touchstart")&&(E=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY])},S=C=>{const b=n();if(C.sourceEvent.type!=="mousemove"&&C.sourceEvent.type!=="touchmove"||!t)return;const w=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY],L=[w[0]-E[0],w[1]-E[1]];E=w;const _=s()*Math.max(b[2],Math.log(b[2]))*(f?-1:1),N={x:b[0]-L[0]*_,y:b[1]-L[1]*_},A=[[0,0],[a,d]];t.setViewportConstrained({x:N.x,y:N.y,zoom:b[2]},A,c)},k=Oc().on("start",y).on("zoom",p?S:null).on("zoom.wheel",m?h:null);r.call(k,{})}function l(){r.on("zoom",null)}return{update:i,destroy:l,pointer:De}}const u3=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,_s=e=>({x:e.x,y:e.y,zoom:e.k}),qs=({x:e,y:t,zoom:n})=>Cs.translate(e,t).scale(n),At=(e,t)=>e.target.closest(`.${t}`),ma=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Us=(e,t=0,n=()=>{})=>{const s=typeof t=="number"&&t>0;return s||n(),s?e.transition().duration(t).on("end",n):e},fa=e=>{const t=e.ctrlKey&&us()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function d3({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:l,onPanZoomStart:c,onPanZoom:a,onPanZoomEnd:d}){return x=>{if(At(x,t))return!1;x.preventDefault(),x.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(x.ctrlKey&&l){const y=De(x),S=fa(x),k=p*Math.pow(2,S);s.scaleTo(n,k,y,x);return}const m=x.deltaMode===1?20:1;let f=r===Rt.Vertical?0:x.deltaX*m,h=r===Rt.Horizontal?0:x.deltaY*m;!us()&&x.shiftKey&&r!==Rt.Vertical&&(f=x.deltaY*m,h=0),s.translateBy(n,-(f/p)*i,-(h/p)*i,{internal:!0});const E=_s(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,c==null||c(x,E)),e.isPanScrolling&&(a==null||a(x,E),e.panScrollTimeout=setTimeout(()=>{d==null||d(x,E),e.isPanScrolling=!1},150))}}function x3({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,r){if(!t&&s.type==="wheel"&&!s.ctrlKey||At(s,e))return null;s.preventDefault(),n.call(this,s,r)}}function p3({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{var i,l,c;if((i=s.sourceEvent)!=null&&i.internal)return;const r=_s(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 m3({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:r}){return i=>{var l,c;e.usedRightMouseButton=!!(n&&ma(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,_s(i.transform)))}}function f3({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&&ma(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&i(l.sourceEvent),e.usedRightMouseButton=!1,s(!1),r&&u3(e.prevViewport,l.transform))){const a=_s(l.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,a)},n?150:0)}}}function h3({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"&&(At(x,`${d}-flow__node`)||At(x,`${d}-flow__edge`)))return!0;if(!s&&!p&&!r&&!i&&!n||l||At(x,c)&&x.type==="wheel"||At(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 g3({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=Oc().clickDistance(!Oe(s)||s<0?0:s).scaleExtent([t,n]).translateExtent(r),f=$e(e).call(m);C({x:i.x,y:i.y,zoom:Ft(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const h=f.on("wheel.zoom"),E=f.on("dblclick.zoom");m.wheelDelta(fa);function y($,z){return f?new Promise(R=>{m==null||m.transform(Us(f,z==null?void 0:z.duration,()=>R(!0)),$)}):Promise.resolve(!1)}function S({noWheelClassName:$,noPanClassName:z,onPaneContextMenu:R,userSelectionActive:T,panOnScroll:M,panOnDrag:D,panOnScrollMode:P,panOnScrollSpeed:V,preventScrolling:H,zoomOnPinch:G,zoomOnScroll:q,zoomOnDoubleClick:oe,zoomActivationKeyPressed:ee,lib:ne,onTransformChange:se}){T&&!x.isZoomingOrPanning&&k();const U=M&&!ee&&!T?d3({zoomPanValues:x,noWheelClassName:$,d3Selection:f,d3Zoom:m,panOnScrollMode:P,panOnScrollSpeed:V,zoomOnPinch:G,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:a}):x3({noWheelClassName:$,preventScrolling:H,d3ZoomHandler:h});if(f.on("wheel.zoom",U,{passive:!1}),!T){const ge=p3({zoomPanValues:x,onDraggingChange:d,onPanZoomStart:c});m.on("start",ge);const pe=m3({zoomPanValues:x,panOnDrag:D,onPaneContextMenu:!!R,onPanZoom:l,onTransformChange:se});m.on("zoom",pe);const re=f3({zoomPanValues:x,panOnDrag:D,panOnScroll:M,onPaneContextMenu:R,onPanZoomEnd:a,onDraggingChange:d});m.on("end",re)}const ue=h3({zoomActivationKeyPressed:ee,panOnDrag:D,zoomOnScroll:q,panOnScroll:M,zoomOnDoubleClick:oe,zoomOnPinch:G,userSelectionActive:T,noPanClassName:z,noWheelClassName:$,lib:ne});m.filter(ue),oe?f.on("dblclick.zoom",E):f.on("dblclick.zoom",null)}function k(){m.on("zoom",null)}async function C($,z,R){const T=qs($),M=m==null?void 0:m.constrain()(T,z,R);return M&&await y(M),new Promise(D=>D(M))}async function b($,z){const R=qs($);return await y(R,z),new Promise(T=>T(R))}function w($){if(f){const z=qs($),R=f.property("__zoom");(R.k!==$.zoom||R.x!==$.x||R.y!==$.y)&&(m==null||m.transform(f,z,null,{sync:!0}))}}function L(){const $=f?Dc(f.node()):{x:0,y:0,k:1};return{x:$.x,y:$.y,zoom:$.k}}function _($,z){return f?new Promise(R=>{m==null||m.scaleTo(Us(f,z==null?void 0:z.duration,()=>R(!0)),$)}):Promise.resolve(!1)}function N($,z){return f?new Promise(R=>{m==null||m.scaleBy(Us(f,z==null?void 0:z.duration,()=>R(!0)),$)}):Promise.resolve(!1)}function A($){m==null||m.scaleExtent($)}function I($){m==null||m.translateExtent($)}function F($){const z=!Oe($)||$<0?0:$;m==null||m.clickDistance(z)}return{update:S,destroy:k,setViewport:b,setViewportConstrained:C,getViewport:L,scaleTo:_,scaleBy:N,setScaleExtent:A,setTranslateExtent:I,syncViewport:w,setClickDistance:F}}var ln;(function(e){e.Line="line",e.Handle="handle"})(ln||(ln={}));function j3({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 E3(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 rt(e,t){return Math.max(0,t-e)}function it(e,t){return Math.max(0,e-t)}function Tn(e,t,n){return Math.max(0,t-e,e-n)}function xi(e,t){return e?!t:t}function y3(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:E,maxWidth:y,minHeight:S,maxHeight:k}=s,{x:C,y:b,width:w,height:L,aspectRatio:_}=e;let N=Math.floor(x?f-e.pointerX:0),A=Math.floor(p?h-e.pointerY:0);const I=w+(a?-N:N),F=L+(d?-A:A),$=-i[0]*w,z=-i[1]*L;let R=Tn(I,E,y),T=Tn(F,S,k);if(l){let P=0,V=0;a&&N<0?P=rt(C+N+$,l[0][0]):!a&&N>0&&(P=it(C+I+$,l[1][0])),d&&A<0?V=rt(b+A+z,l[0][1]):!d&&A>0&&(V=it(b+F+z,l[1][1])),R=Math.max(R,P),T=Math.max(T,V)}if(c){let P=0,V=0;a&&N>0?P=it(C+N,c[0][0]):!a&&N<0&&(P=rt(C+I,c[1][0])),d&&A>0?V=it(b+A,c[0][1]):!d&&A<0&&(V=rt(b+F,c[1][1])),R=Math.max(R,P),T=Math.max(T,V)}if(r){if(x){const P=Tn(I/_,S,k)*_;if(R=Math.max(R,P),l){let V=0;!a&&!d||a&&!d&&m?V=it(b+z+I/_,l[1][1])*_:V=rt(b+z+(a?N:-N)/_,l[0][1])*_,R=Math.max(R,V)}if(c){let V=0;!a&&!d||a&&!d&&m?V=rt(b+I/_,c[1][1])*_:V=it(b+(a?N:-N)/_,c[0][1])*_,R=Math.max(R,V)}}if(p){const P=Tn(F*_,E,y)/_;if(T=Math.max(T,P),l){let V=0;!a&&!d||d&&!a&&m?V=it(C+F*_+$,l[1][0])/_:V=rt(C+(d?A:-A)*_+$,l[0][0])/_,T=Math.max(T,V)}if(c){let V=0;!a&&!d||d&&!a&&m?V=rt(C+F*_,c[1][0])/_:V=it(C+(d?A:-A)*_,c[0][0])/_,T=Math.max(T,V)}}}A=A+(A<0?T:-T),N=N+(N<0?R:-R),r&&(m?I>F*_?A=(xi(a,d)?-N:N)/_:N=(xi(a,d)?-A:A)*_:x?(A=N/_,d=a):(N=A*_,a=d));const M=a?C+N:C,D=d?b+A:b;return{width:w+(a?-N:N),height:L+(d?-A:A),x:i[0]*N*(a?-1:1)+M,y:i[1]*A*(d?-1:1)+D}}const ha={width:0,height:0,x:0,y:0},S3={...ha,pointerX:0,pointerY:0,aspectRatio:1};function R3(e){return[[0,0],[e.measured.width,e.measured.height]]}function C3(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 b3({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:r}){const i=$e(e);function l({controlPosition:a,boundaries:d,keepAspectRatio:x,onResizeStart:p,onResize:m,onResizeEnd:f,shouldResize:h}){let E={...ha},y={...S3};const S=E3(a);let k,C=null,b=[],w,L,_;const N=Pc().on("start",A=>{const{nodeLookup:I,transform:F,snapGrid:$,snapToGrid:z,nodeOrigin:R,paneDomNode:T}=n();if(k=I.get(t),!k)return;C=(T==null?void 0:T.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=rn(A.sourceEvent,{transform:F,snapGrid:$,snapToGrid:z,containerBounds:C});E={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},y={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},w=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(w=I.get(k.parentId),L=w&&k.extent==="parent"?R3(w):void 0),b=[],_=void 0;for(const[P,V]of I)if(V.parentId===t&&(b.push({id:P,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const H=C3(V,k,V.origin??R);_?_=[[Math.min(H[0][0],_[0][0]),Math.min(H[0][1],_[0][1])],[Math.max(H[1][0],_[1][0]),Math.max(H[1][1],_[1][1])]]:_=H}p==null||p(A,{...E})}).on("drag",A=>{const{transform:I,snapGrid:F,snapToGrid:$,nodeOrigin:z}=n(),R=rn(A.sourceEvent,{transform:I,snapGrid:F,snapToGrid:$,containerBounds:C}),T=[];if(!k)return;const{x:M,y:D,width:P,height:V}=E,H={},G=k.origin??z,{width:q,height:oe,x:ee,y:ne}=y3(y,S,R,d,x,G,L,_),se=q!==P,ie=oe!==V,U=ee!==M&&se,ue=ne!==D&&ie;if(!U&&!ue&&!se&&!ie)return;if((U||ue||G[0]===1||G[1]===1)&&(H.x=U?ee:E.x,H.y=ue?ne:E.y,E.x=H.x,E.y=H.y,b.length>0)){const Q=ee-M,le=ne-D;for(const je of b)je.position={x:je.position.x-Q+G[0]*(q-P),y:je.position.y-le+G[1]*(oe-V)},T.push(je)}if((se||ie)&&(H.width=se?q:E.width,H.height=ie?oe:E.height,E.width=H.width,E.height=H.height),w&&k.expandParent){const Q=G[0]*(H.width??0);H.x&&H.x<Q&&(E.x=Q,y.x=y.x-(H.x-Q));const le=G[1]*(H.height??0);H.y&&H.y<le&&(E.y=le,y.y=y.y-(H.y-le))}const ge=j3({width:E.width,prevWidth:P,height:E.height,prevHeight:V,affectsX:S.affectsX,affectsY:S.affectsY}),pe={...E,direction:ge};(h==null?void 0:h(A,pe))!==!1&&(m==null||m(A,pe),s(H,T))}).on("end",A=>{f==null||f(A,{...E}),r==null||r()});i.call(N)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var Nn={exports:{}},Js={},An={exports:{}},Qs={};/**
1
+ "use strict";var _m=Object.defineProperty;var Mm=(e,t,n)=>t in e?_m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ge=(e,t,n)=>Mm(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./jsx-runtime-D8EVjfnb.cjs"),g=require("react"),j=require("./Toggle-BOWYgKry.cjs"),u=require("./css-DT9dIVAb.cjs"),zn=require("./external-DkXE1VK8.cjs"),Z=require("./aggregator-B4RWbN9h.cjs"),te=require("./Pack-B7_tAsYd.cjs"),Lm=require("./external-CKXRIr4_.cjs"),ke=require("./external-CW61uh4b.cjs"),ve=require("./external-9Q86X8hc.cjs"),Pm=require("./external-CWIwuJks.cjs"),_o=require("./Animated-Cxl7iHik.cjs"),B=require("./LinePlot-Cys9-mEC.cjs"),ce=require("zod"),Wi=require("./external-Dt4ggRt2.cjs");require("./Item-C4SOBynl.cjs");const Mo=require("react-dom"),Gt=require("./external-8OKX45Jc.cjs"),Tm=require("./external-ok_ye4LF.cjs"),Ki=require("./units-BpKy5yTv.cjs"),Te=require("./external-SsIgRo40.cjs"),Nm=require("./external-kZBV4X9L.cjs"),Am=require("./external-CigHe3w_.cjs"),Im=require("./external-Ba8go3wq.cjs"),$m=require("./Video-usN9Roxq.cjs"),zm=(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},Yn=e=>e.preventDefault(),Lo=({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.construct(t),p=u.K.direction(x),m=u.g.dimension(p);return o.jsxRuntimeExports.jsxs("div",{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.swap(x))),onDragStart:l,onDrag:Yn,onDragEnd:Yn})]})},Po=({onResize:e,count:t,initialSizes:n=[],minSize:s=100,direction:r="x"})=>{const i=g.useRef(null),[l,c]=g.useState({sizeDistribution:Bm(n,t),root:null}),a=g.useCallback((p,m,f)=>{if(i.current==null)return;const h=u.Tt.dim(u.Tt.construct(i.current),r);c(E=>Fs(E,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]),E=()=>{c(y=>({...y,root:null})),document.removeEventListener("mousemove",h)};c(y=>({...y,root:p[f]})),document.addEventListener("mousemove",h),document.addEventListener("mouseup",E,{once:!0})},[c,r,Fs]);return{setSize:g.useCallback((p,m)=>a(p,void 0,m),[Fs]),props:{direction:r,sizeDistribution:l.sizeDistribution,onDragHandle:d,ref:i}}},To=({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=Dm(s),o.jsxRuntimeExports.jsx(te.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(Lo,{onDragStart:p=>r(p,x),location:u.g.location(c),size:s[x]*100,sizeUnits:"%",showHandle:x!==a.length-1,children:d},x))})},Bm=(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)},Vs=.001,Dm=e=>e.every(t=>u.G$1.closeTo(t,1/e.length),Vs)?e.map((t,n)=>n%2===0?t+Vs:n===e.length-1?t:t-Vs):e,Fs=(e,t,n,s,r,i)=>{const l=Xi(e,t,n,r,i),[c,a]=Om(e.sizeDistribution,n,l,s/t),d=a?r??null:e.root;return{...e,sizeDistribution:c,root:d}},Xi=(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},Om=(e,t,n,s)=>{let r=t;for(;r>0&&e[r]+n<=s;)r--;const i=e[r]+n,l=Vm(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]},Vm=(e,t,n,s)=>(e===t.length-1?Hm:Fm)(e,t,n,s),Fm=(e,t,n,s)=>{let r=e+1;for(;r<t.length-1&&t[r]-s<=n;)r++;return r},Hm=(e,t,n,s)=>{let r=e-1;for(;r>0&&t[r]-s<=n;)r--;return r},Hs=2,qi=({onCollapse:e,onResize:t,location:n="left",minSize:s=100,maxSize:r=1/0,initialSize:i=200,collapseThreshold:l=1/0,className:c,...a})=>{const[d,x]=g.useState(u.Y(i,s,r)),p=g.useRef(null),m=u.K.construct(n),f=g.useCallback(C=>{if(p.current===null)return 0;const b=u.Tt.dim(C,u.K.direction(m),!0)*(1-2*Number(["bottom","right"].includes(m))),w=p.current+b,L=u.Y(w,s,r);return(L-w)/s>l?Hs:L},[m,s,r,l]),h=g.useRef(null),E=g.useCallback(C=>{const b=f(C);x(b),h.current!=null&&(t==null||t(b,u.Tt.construct(h.current)))},[t,f]),y=g.useCallback(()=>x(C=>(p.current=C,C)),[x]),S=g.useCallback(C=>f(C)===Hs&&(e==null?void 0:e()),[e,f]);g.useEffect(()=>x(C=>{const b=u.Y(C,s,r);return p.current=b,b}),[s,r]);const k=j.useCursorDrag({onMove:E,onStart:y,onEnd:S});return o.jsxRuntimeExports.jsx(Lo,{ref:h,location:m,size:d,onDragStart:k,className:u.clsx(c,u.CSS.expanded(d!==Hs)),...a})},Zm=Object.freeze(Object.defineProperty({__proto__:null,Core:Lo,Multiple:To,Single:qi,calculateDiffPercentage:Xi,useMultiple:Po},Symbol.toStringTag,{value:"Module"})),No=({aetherKey:e})=>{const[,{region:t},n]=j.use$3({aetherKey:e,type:Z.Eraser.TYPE,schema:Z.eraserStateZ,initialState:{region:u.Tt.ZERO,enabled:!0}}),s=j.useSyncedRef(t),r=g.useCallback(l=>{u.Tt.equals(l,s.current)||n(c=>({...c,region:l}))},[n]);return{setEnabled:g.useCallback(l=>n(c=>({...c,enabled:l})),[n]),erase:r}},Gm=({aetherKey:e,children:t})=>{const{erase:n}=No({aetherKey:e}),s=j.useResize(n);return o.jsxRuntimeExports.jsx("div",{ref:s,className:u.CSS(u.CSS.inheritDims()),children:t})},Ym=Object.freeze(Object.defineProperty({__proto__:null,Eraser:Gm,use:No},Symbol.toStringTag,{value:"Module"})),Wm=({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}},Km=({activeItem:e,children:t,onSelect:n,location:s="left",collapseThreshold:r=.65,className:i,onResize:l,...c})=>{const a=u.K.direction(s),d=g.useCallback(()=>e!=null&&(n==null?void 0:n(e.key)),[n,e==null?void 0:e.key]),{erase:x,setEnabled:p}=No({}),m=g.useCallback((k,C)=>{l==null||l(k,C),x(C)},[l,x]);if(g.useLayoutEffect(()=>{p(e!=null)},[e,p]),e==null)return null;const{content:f,key:h,minSize:E,maxSize:y,initialSize:S}=e;return o.jsxRuntimeExports.jsx(qi,{className:u.CSS(u.CSS.BE("navdrawer","content"),u.CSS.dir(a),i),collapseThreshold:r,onCollapse:d,location:s,onResize:m,minSize:E,maxSize:y,initialSize:S,...c,children:f},h)},Xm=Object.freeze(Object.defineProperty({__proto__:null,Bar:j.Bar,Drawer:Km,useDrawer:Wm},Symbol.toStringTag,{value:"Module"})),Ui=({variant:e="info",...t})=>o.jsxRuntimeExports.jsx(j.Lt.Circle,{color:j.variantColors[e],...t}),qm=({status:{key:e,time:t,count:n,message:s,description:r,variant:i},silence:l,actions:c,className:a,children:d,...x})=>o.jsxRuntimeExports.jsxs(te.Space,{className:u.CSS(u.CSS.B("notification"),a),direction:"y",empty:!0,...x,children:[o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",justify:"spaceBetween",grow:!0,style:{width:"100%"},children:[o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(Ui,{style:{height:"2.25rem",width:"2.5rem"},variant:i}),o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",shade:7,children:`x${n}`}),o.jsxRuntimeExports.jsx(j.DateTime,{className:u.CSS(u.CSS.BE("notification","time")),level:"small",format:"time",children:t})]}),o.jsxRuntimeExports.jsx(j.Icon,{className:u.CSS(u.CSS.BE("notification","silence")),variant:"outlined",size:"small",onClick:()=>l(e),children:o.jsxRuntimeExports.jsx(j.Lt.Close,{})})]}),o.jsxRuntimeExports.jsxs(te.Space,{direction:"y",align:"start",className:u.CSS(u.CSS.BE("notification","content")),size:"small",children:[d??o.jsxRuntimeExports.jsx(j.Text$1,{className:u.CSS(u.CSS.BE("notification","message")),level:"p",style:{flexGrow:1},children:s}),r!=null&&o.jsxRuntimeExports.jsx(j.Text$1,{className:u.CSS(u.CSS.BE("notification","description")),level:"small",style:{flexGrow:1},children:r})]}),c!=null&&o.jsxRuntimeExports.jsx(te.Space,{direction:"x",align:"center",justify:"end",className:u.CSS(u.CSS.BE("notification","actions")),children:Z.A(c).map(p=>o.jsxRuntimeExports.jsx(Um,{action:p},p.key))})]},t.toString()),Um=({action:e})=>g.isValidElement(e)?e:o.jsxRuntimeExports.jsx(j.Button,{...e}),Jm=Object.freeze(Object.defineProperty({__proto__:null,Aggregator:j.Aggregator,Circle:Ui,Notification:qm,Text:j.Text$3,VARIANTS:Z.VARIANTS,specZ:Z.specZ$1,useAggregator:j.useAggregator,useContext:j.useContext$3,useExceptionHandler:j.useExceptionHandler,useNotifications:j.useNotifications,variantZ:Z.variantZ},Symbol.toStringTag,{value:"Module"})),Qm=Object.freeze(Object.defineProperty({__proto__:null,Config:j.Config,Context:j.Context,Dialog:j.Dialog$1,chooseLocation:j.chooseLocation,formatTip:j.formatTip,useConfig:j.useConfig,wrap:j.wrap},Symbol.toStringTag,{value:"Module"})),Bn="y",_r=28,ef=32,tf=40,nf=.5,sf=({data:e,...t})=>{const{setSize:n,props:{sizeDistribution:s,ref:r,...i}}=Po({direction:Bn,count:e.length,minSize:_r}),l=c=>{if(r.current==null)return;const a=u.Tt.dim(u.Tt.construct(r.current),Bn);s[c]<tf/a?n(c,e[c].initialSize??nf):n(c,_r+1)};return o.jsxRuntimeExports.jsx(To,{empty:!0,className:u.CSS.B("accordion"),sizeDistribution:s,ref:r,...t,...i,children:e.map((c,a)=>g.createElement(lf,{...c,key:c.key,index:a,direction:Bn,onExpand:l,parent:r,size:s[a]}))})},of=o.jsxRuntimeExports.jsx(j.Lt.Caret.Down,{"aria-label":"contract"}),rf=o.jsxRuntimeExports.jsx(j.Lt.Caret.Right,{"aria-label":"expand"}),lf=({index:e,name:t,content:n,actions:s,size:r,parent:i,onExpand:l})=>{let c=!0;if(i.current!=null){const d=u.Tt.dim(u.Tt.construct(i.current),Bn);c=r*d>ef}const a=c?of:rf;return o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsxs(zn.Header,{level:"p",className:u.CSS.expanded(c),empty:!0,children:[o.jsxRuntimeExports.jsx(zn.ButtonTitle,{startIcon:a,onClick:()=>l(e),children:t}),s!=null&&o.jsxRuntimeExports.jsx(zn.Actions,{children:s})]}),n]})},cf=Object.freeze(Object.defineProperty({__proto__:null,Accordion:sf},Symbol.toStringTag,{value:"Module"})),af=(e,t)=>Z.A(e).map(s=>typeof s=="string"?s.split(t).map(r=>({label:r})):s).flat(),Ji=({segments:e,shade:t,level:n,weight:s,separator:r,transform:i})=>{let c=af(e,r);return i!=null&&(c=c.map(i)),c.map(({label:a,icon:d,href:x,...p},m)=>{const f=[o.jsxRuntimeExports.jsx(j.Lt.Caret.Right,{style:{transform:"scale(0.8) translateY(1px)",color:u.CSS.shade(t)}},`${a}-${m}`)];if(d!=null){const E=ke.resolve(d);E!=null&&f.push(E)}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(ve.Link,{...h,href:x},a)):f.push(o.jsxRuntimeExports.jsx(j.Text$1,{...h},a)),f}).flat()},uf=({children:e,icon:t,shade:n=7,weight:s,size:r=.5,url:i,level:l="p",separator:c=".",className:a,hideFirst:d=!0,...x})=>{i!=null&&(e=i);const p=Ji({segments:e,separator:c,shade:n,level:l,weight:s});return d&&p.shift(),o.jsxRuntimeExports.jsxs(j.WithIcon,{className:u.CSS(a,u.CSS.B("breadcrumb"),d&&u.CSS.M("hide-first")),level:l,shade:n,weight:s,size:r,direction:"x",...x,children:[ke.resolve(t),...p]})},df=({url:e,className:t,level:n="p",separator:s="/",weight:r,shade:i=7})=>{const l=Ji({segments:e,separator:s,shade:i,level:n,weight:r,transform:(c,a)=>({...c,label:c.label.split("-").map(d=>u.d.capitalize(d)).join(" "),href:`/${e.split(s).slice(0,a+1).join("/")}`})});return o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(t,u.CSS.B("breadcrumb"),u.CSS.BM("breadcrumb","url")),direction:"x",size:"small",align:"center",children:l})},xf=Object.freeze(Object.defineProperty({__proto__:null,Breadcrumb:uf,URL:df},Symbol.toStringTag,{value:"Module"})),Ao=g.createContext(B.ZERO_CONTEXT_VALUE),Fe=()=>g.useContext(Ao).synnax,pf=()=>g.useContext(Ao).state,Mr={connected:"success",connecting:"info",disconnected:"info",failed:"error"},Qi="serverVersionMismatch",mf=(e,t,n)=>`Cluster version ${n!=null?`${n} `:""}is ${e?"older":"newer"} than client version ${t}. Compatibility issues may arise.`,el=({children:e,connParams:t})=>{const[n,s,r]=j.useCombinedStateAndRef(B.ZERO_CONTEXT_VALUE),[{path:i},,l]=j.use$3({type:B.Provider.TYPE,schema:B.Provider.stateZ,initialState:{props:t??null,state:null}}),c=j.useAggregator(),a=g.useCallback(d=>{r.current.state.status!==d.status&&c({variant:Mr[d.status],message:d.message??u.d.capitalize(d.status)}),s(x=>({...x,state:d}))},[c]);return j.useAsyncEffect(async()=>{if(n.synnax!=null&&n.synnax.close(),t==null)return s(B.ZERO_CONTEXT_VALUE);const d=new Z.bg({...t,connectivityPollFrequency:Z.S$1.seconds(5)});s({synnax:d,state:{clusterKey:"",status:"connecting",message:"Connecting...",clientServerCompatible:!1,clientVersion:d.clientVersion}});const x=await d.connectivity.check();if(s({synnax:d,state:x}),c({variant:Mr[x.status],message:x.message??x.status.toUpperCase()}),x.status==="connected"&&!x.clientServerCompatible){const p=x.nodeVersion==null||Z.X.semVerOlder(x.nodeVersion,x.clientVersion),m=mf(p,x.clientVersion,x.nodeVersion);c({variant:"warning",message:"Incompatible cluster version",description:m,data:{type:Qi,oldServer:p,nodeVersion:x.nodeVersion,clientVersion:x.clientVersion}})}return d.connectivity.onChange(a),l({props:t,state:x}),()=>{d.close(),s(B.ZERO_CONTEXT_VALUE),l({props:null,state:null})}},[t,a]),o.jsxRuntimeExports.jsx(Ao.Provider,{value:n,children:o.jsxRuntimeExports.jsx(j.Composite,{path:i,children:e})})},ff=Object.freeze(Object.defineProperty({__proto__:null,Provider:el,SERVER_VERSION_MISMATCH:Qi,use:Fe,useConnectionState:pf},Symbol.toStringTag,{value:"Module"})),Yt=g.createContext({aliases:{},getName:async()=>await Promise.resolve(void 0),setAlias:null}),tl=()=>g.useContext(Yt),nl=e=>{const{aliases:t}=g.useContext(Yt);return t[e]??null},xs=()=>{const{aliases:e}=g.useContext(Yt);return e},ps=(e,t="")=>{const{getName:n}=g.useContext(Yt),[s,r]=g.useState(t);return j.useAsyncEffect(async()=>{const i=await n(e);r(i)},[e,n]),s??t},Io=()=>{const{activeRange:e}=g.useContext(Yt);return e??void 0},sl=({activeRange:e,children:t})=>{const n=Fe(),[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 j.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(Yt.Provider,{value:{aliases:s,activeRange:e,setAlias:e!=null?l:null,getName:c},children:t})},hf=({channelKey:e,value:t,shadow:n,className:s,...r})=>{const[i,l]=g.useState(!1),{setAlias:c}=tl(),a=nl(e),d=ps(e);let x=o.jsxRuntimeExports.jsx(j.Lt.Rename,{});i?x=o.jsxRuntimeExports.jsx(j.Lt.Loading,{}):a===t&&(x=o.jsxRuntimeExports.jsx(j.Lt.Check,{}));const p=c!=null&&!i&&a!==t&&e!==0,m=()=>{p&&(async()=>(l(!0),await c(e,t),l(!1)))()},f=()=>{var E;a!=null&&((E=r.onChange)==null||E.call(r,a))},h=()=>e===0?o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:"Select a channel to enable alias syncing with this label"}):c==null?o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:"Select a range to enable alias syncing with this label"}):t.length===0?o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:"Enter a value to enable alias syncing with this label"}):a===t?o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:"Alias synced with this label"}):o.jsxRuntimeExports.jsxs(j.Text$1,{level:"small",children:["Sync alias for ",d," with this label"]});return o.jsxRuntimeExports.jsxs(j.Text$2,{value:t,...r,children:[p&&o.jsxRuntimeExports.jsx(j.Icon,{onClick:f,tooltip:o.jsxRuntimeExports.jsxs(j.Text$1,{level:"small",children:["Set ",d," as label"]}),tooltipLocation:{y:"top"},variant:"outlined",children:o.jsxRuntimeExports.jsx(j.Lt.Sync,{})}),o.jsxRuntimeExports.jsx(j.Icon,{onClick:m,disabled:!p,tooltip:o.jsxRuntimeExports.jsx(h,{}),tooltipLocation:{y:"top"},variant:"outlined",children:x})]})},Ye="channel";var Lr=180/Math.PI,oo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ol(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)*Lr,skewX:Math.atan(a)*Lr,scaleX:l,scaleY:c}}var kn;function gf(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?oo:ol(t.a,t.b,t.c,t.d,t.e,t.f)}function jf(e){return e==null||(kn||(kn=document.createElementNS("http://www.w3.org/2000/svg","g")),kn.setAttribute("transform",e),!(e=kn.transform.baseVal.consolidate()))?oo:(e=e.matrix,ol(e.a,e.b,e.c,e.d,e.e,e.f))}function rl(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 E=f.push("translate(",null,t,null,n);h.push({i:E-4,x:B.interpolateNumber(d,p)},{i:E-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 E=f.push(r(f)+"scale(",null,",",null,")");h.push({i:E-4,x:B.interpolateNumber(d,p)},{i:E-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,E=m.length,y;++h<E;)p[(y=m[h]).i]=y.x(f);return p.join("")}}}var Ef=rl(gf,"px, ","px)","deg)"),yf=rl(jf,", ",")",")"),Sf=1e-12;function Pr(e){return((e=Math.exp(e))+1/e)/2}function Rf(e){return((e=Math.exp(e))-1/e)/2}function Cf(e){return((e=Math.exp(2*e))-1)/(e+1)}const bf=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,E=f*f+h*h,y,S;if(E<Sf)S=Math.log(m/d)/t,y=function(_){return[c+_*f,a+_*h,d*Math.exp(t*_*S)]};else{var k=Math.sqrt(E),C=(m*m-d*d+s*E)/(2*d*n*k),b=(m*m-d*d-s*E)/(2*m*n*k),w=Math.log(Math.sqrt(C*C+1)-C),L=Math.log(Math.sqrt(b*b+1)-b);S=(L-w)/t,y=function(_){var N=_*S,A=Pr(w),I=d/(n*k)*(A*Cf(t*N+w)-Rf(w));return[c+I*f,a+I*h,d*A/Pr(t*N+w)]}}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),wf=Object.freeze(Object.defineProperty({__proto__:null,Canvas:B.Canvas,axisStateZ:B.axisStateZ,newTickFactory:B.newTickFactory,tickFactoryProps:B.tickFactoryProps,tickType:B.tickType},Symbol.toStringTag,{value:"Module"})),vf=Object.freeze(Object.defineProperty({__proto__:null,AcquireChannelControl:B.AcquireChannelControl,AuthoritySource:B.AuthoritySource,Chip:B.Chip,Controller:B.Controller$1,Indicator:B.Indicator,Legend:B.Legend,REGISTRY:B.REGISTRY$3,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"})),kf={region:u.Tt.ZERO,dpr:1,os:Z.S.getOS()},_f={gl:null,lower2d:null,upper2d:null,bootstrapped:!1},Mf=({children:e,resizeDebounce:t=100,className:n,...s})=>{const[{path:r},{bootstrapped:i,dpr:l},c]=j.use$3({type:B.Canvas$1.TYPE,schema:B.canvasStateZ,initialState:kf}),a=g.useRef({..._f}),d=g.useRef(!1),x=g.useCallback(E=>{a.current.bootstrapped&&(c(()=>({bootstrapped:!0,region:E,dpr:window.devicePixelRatio,os:Z.S.getOS({default:"Windows"})})),d.current=!0)},[c]),p=g.useRef(null),m=j.useResize(x,{debounce:t}),f=j.useCombinedRefs(p,m);g.useEffect(()=>{const E=()=>{window.devicePixelRatio===l||!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.Tt.construct(p.current),dpr:window.devicePixelRatio}))};window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`).addEventListener("change",E,{once:!0})},[l]),g.useEffect(()=>{const E=()=>{!a.current.bootstrapped||p.current==null||c(y=>({...y,region:u.Tt.construct(p.current),glCanvas:void 0,upper2dCanvas:void 0,lower2dCanvas:void 0}))};window.addEventListener("focus",E),window.addEventListener("blur",E)},[c]);const h=g.useCallback(E=>{if(E==null)return;E.className.includes("gl")?a.current.gl=E:E.className.includes("upper2d")?a.current.upper2d=E:a.current.lower2d=E;const{gl:y,lower2d:S,upper2d:k,bootstrapped:C}=a.current;if(y==null||S==null||k==null||C)return;a.current.bootstrapped=!0;const b=y.transferControlToOffscreen(),w=k.transferControlToOffscreen(),L=S.transferControlToOffscreen();c({glCanvas:b,upper2dCanvas:w,lower2dCanvas:L,bootstrap:!0,bootstrapped:!1,region:u.Tt.construct(y),dpr:window.devicePixelRatio,os:Z.S.getOS({default:"Windows"})},[b,w,L])},[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(j.Composite,{path:r,children:i&&e})]})},En=(e,t)=>j.useResize(g.useCallback((n,s)=>{const r=document.querySelector(".pluto-canvas--lower2d");r!=null&&e(u.b.XY.translate(u.G.scale(u.Tt.topLeft(r),-1)).box(n),s)},[e]),t),Lf=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Mf,useRegion:En},Symbol.toStringTag,{value:"Module"})),il=g.createContext(null),We=e=>{const t=g.useContext(il);if(t==null)throw new Error(`Cannot to use ${e} as a non-child of LinePlot.`);return t},ll=e=>{const t=We("Viewport"),{addViewportHandler:n}=t;g.useEffect(()=>n(e),[n,e])},yn=(e,t)=>{const{setGridEntry:n,removeGridEntry:s}=We(t),{key:r}=e;return j.useEffectCompare(()=>{u.K.outer.parse(e.loc),n(e)},([c],[a])=>Z._.equal(c,a),[e]),g.useEffect(()=>()=>s(r),[]),{gridArea:u.g.swap(u.K.direction(e.loc))==="x"?`axis-start-${r} / plot-start / axis-end-${r} / plot-end`:`plot-start / axis-start-${r} / plot-end / axis-end-${r}`}},cl=({aetherKey:e,style:t,resizeDebounce:n=0,clearOverScan:s=u.G.ZERO,children:r,hold:i=!1,onHold:l,visible:c,...a})=>{const[d,x]=g.useState([]),p=j.useMemoDeepEqualProps({clearOverScan:s,hold:i,visible:c}),[{path:m},{grid:f},h]=j.use$3({aetherKey:e,type:B.LinePlot.TYPE,schema:B.linePlotStateZ,initialState:{container:u.Tt.ZERO,viewport:u.Tt.DECIMAL,grid:{},...p}});g.useEffect(()=>h($=>({...$,...p})),[p]);const E=g.useRef(new Map),y=g.useCallback($=>(E.current.set($,null),()=>E.current.delete($)),[E]),S=g.useCallback($=>{const{mode:z,box:R,stage:T}=$;(z==="pan"&&T!=="start"||z==="zoom"||z==="zoomReset"&&T==="start")&&h(M=>({...M,viewport:R})),E.current.forEach((M,D)=>D($))},[h]),k=g.useCallback($=>h(z=>({...z,container:$})),[h]),C=En(k,{debounce:n}),b=g.useCallback($=>h(z=>({...z,grid:{...z.grid,[$.key]:$}})),[h]),w=g.useCallback($=>h(z=>{const{[$]:R,...T}=z.grid;return{...z,grid:T}}),[h]),L=g.useCallback($=>{x(z=>[...z.filter(({key:R})=>R!==$.key),$])},[x,S]),_=g.useCallback($=>x(z=>z.filter(({key:R})=>R!==$)),[L]),N=g.useMemo(()=>Pf(f),[f]),A=g.useCallback($=>{h(z=>({...z,hold:$})),l==null||l($)},[h,l]),I=`line-plot-${e}`,F=g.useMemo(()=>({lines:d,setGridEntry:b,removeGridEntry:w,setLine:L,removeLine:_,setViewport:S,addViewportHandler:y,setHold:A,id:I}),[I,d,b,w,L,_,S,y,A]);return o.jsxRuntimeExports.jsx("div",{id:I,className:u.CSS.B("line-plot"),style:{...t,...N},ref:C,...a,children:o.jsxRuntimeExports.jsx(il.Provider,{value:F,children:o.jsxRuntimeExports.jsx(j.Composite,{path:m,children:r})})})},Pf=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()},$o=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:E,bounds:y,className:S,tickSpacing:k,autoBounds:C,autoBoundUpdateInterval:b,onAutoBoundsChange:w,style:L,..._})=>{const N=((a==null?void 0:a.length)??0)>0,A=j.useUniqueKey(i),I=j.useMemoDeepEqualProps({location:c,showGrid:h,type:E,bounds:y,label:a,labelDirection:x,tickSpacing:k,autoBounds:C,autoBoundUpdateInterval:b}),[{path:F},{size:$,labelSize:z,...R},T]=j.use$3({aetherKey:A,type:n,schema:B.coreAxisStateZ,initialState:I});g.useEffect(()=>T(V=>({...V,...I})),[I]),g.useEffect(()=>{const{lower:V,upper:H}=B.parseAutoBounds(R.autoBounds);R.bounds!=null&&(V&&(y==null?void 0:y.lower)!==R.bounds.lower||H&&(y==null?void 0:y.upper)!==R.bounds.upper)&&(w==null||w(R.bounds))},[R.autoBounds,R.bounds]);const M=yn({loc:c,key:`${n}-${A}`,size:$+z,order:1},`${e.toUpperCase()}Axis`),D=j.useTypography(d).toString(),P=g.useRef(0);return g.useEffect(()=>{if(e==="y"){if(a==null)return;let H=Z.dimensions(a,D)[u.g.dimension(u.g.construct(x))];H>0&&(H+=9),T(G=>({...G,labelSize:H}))}else{let H=Z.dimensions(a,D).height*1.3;H>0&&(H+=12);const G=P.current;B.withinSizeThreshold(G,H)||(P.current=H,T(q=>({...q,labelSize:H})))}},[a,x,D]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(S,u.CSS.B("axis"),u.CSS.B(s),u.CSS.loc(c)),style:{...L,...M},align:"center",justify:c!=="left"?"end":"start",direction:u.g.swap(e),..._,children:N&&o.jsxRuntimeExports.jsx(j.MaybeEditable,{className:u.CSS(u.CSS.BE("axis","label"),u.CSS.dir(x)),value:a,onChange:p,level:d})}),o.jsxRuntimeExports.jsx(j.Composite,{path:F,children:l})]})};return r.displayName=`${e.toUpperCase()}Axis`,r},al=$o("x"),ul=$o("y"),dl=u.G.xy.extend({root:u.K.corner,units:ce.z.object({x:ce.z.enum(["px","decimal"]),y:ce.z.enum(["px","decimal"])})}),Tf=dl.partial({root:!0,units:!0}),Nf=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},Af=(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.Tt.construct(t.current),r=u.Tt.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.Tt.width(s))/u.Tt.width(r):n.x/=u.Tt.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.Tt.height(s))/u.Tt.height(r):n.y/=u.Tt.height(r),n},xl=(e,t)=>{if(t.current==null)return null;const n=u.Tt.construct(t.current.parentElement),s=u.Tt.construct(t.current),r={x:e.x,y:e.y,root:{...u.K.TOP_LEFT},units:{x:"px",y:"px"}};return e.x>.8?(r.x=(1-e.x)*u.Tt.width(n)-u.Tt.width(s),r.root.x="right"):e.x<.2?r.x=e.x*u.Tt.width(n):r.units.x="decimal",e.y>.8?(r.y=(1-e.y)*u.Tt.height(n)-u.Tt.height(s),r.root.y="bottom"):e.y<.2?r.y=e.y*u.Tt.height(n):r.units.y="decimal",r.x=Math.round(r.x*100)/100,{...r,...u.G.truncate(r,3)}},Tr=u.Tt.reRoot(u.Tt.DECIMAL,u.K.TOP_LEFT),zo=g.memo(({className:e,value:t,onChange:n,style:s,draggable:r=!0,...i})=>{const[l,c]=Z.usePurePassthrough({value:t,onChange:n,initial:{x:.1,y:.1,root:u.K.TOP_LEFT,units:{x:"decimal",y:"decimal"}}}),a=g.useRef(l),d=j.useSyncedRef(r===!1),x=g.useRef(null);l!==null&&(s={...s,...Nf(l)});const p=g.useCallback(f=>{var b;if(((b=x.current)==null?void 0:b.parentElement)==null)return a.current;const h=u.Tt.construct(x.current.parentElement),E=u.b.XY.scale(h).scale(Tr),y=E.box(u.Tt.construct(x.current)),S=u.b.XY.clamp(u.Tt.construct(u.Tt.topLeft(Tr),{width:1-u.Tt.width(y),height:1-u.Tt.height(y)})),k=u.G.translate(u.G.construct(a.current),u.Tt.signedDims(E.box(f))),C=S.pos(k);return xl(C,x)},[]),m=j.useCursorDrag({onStart:g.useCallback(()=>{a.current=Af(a.current,x)},[]),onMove:g.useCallback(f=>{if(d.current)return;const h=p(f);h!==null&&c(h)},[]),onEnd:g.useCallback(f=>{if(d.current)return;const h=p(f);h!==null&&(a.current=h)},[])});return o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(e,u.CSS.B("legend")),bordered:!0,rounded:!0,style:s,onDragStart:m,draggable:r,ref:x,...i,onDrag:Yn,onDragEnd:Yn,empty:!0})});zo.displayName="Legend.Container";const Bo=(e,t,n)=>e.sort((s,r)=>s.label.localeCompare(r.label)).map(({key:s,color:r,label:i})=>o.jsxRuntimeExports.jsxs(te.Space,{style:{cursor:"pointer"},direction:"x",align:"center",size:"small",children:[o.jsxRuntimeExports.jsx(j.Swatch,{value:r,onChange:l=>t==null?void 0:t({key:s,color:l,label:i}),onVisibleChange:n,allowChange:t!=null,draggable:!1,size:"small"}),o.jsxRuntimeExports.jsx(j.MaybeEditable,{level:"small",value:i,onChange:l=>t==null?void 0:t({key:s,color:r,label:l}),noWrap:!0})]},s)),Do=({data:e=[],onEntryChange:t,position:n,onPositionChange:s,...r})=>{const[i,l]=g.useState(!1);return e.length===0?null:o.jsxRuntimeExports.jsx(zo,{...r,draggable:!i,value:n,onChange:s,children:Bo(e,t,l)})},If=Object.freeze(Object.defineProperty({__proto__:null,Container:zo,Simple:Do,calcStickyPos:xl,completeStickyXYz:dl,legendSwatches:Bo,stickyXYz:Tf},Symbol.toStringTag,{value:"Module"})),Oo=g.memo(({className:e,style:t,onLineChange:n,...s})=>{const{lines:r}=We("Legend");return We("Legend"),o.jsxRuntimeExports.jsx(Do,{data:r,onEntryChange:n,...s})});Oo.displayName="FloatingLegend";const $f=({onLineChange:e})=>{const{lines:t}=We("Legend"),n=j.useUniqueKey(),s=yn({key:n,size:t.length>0?36:0,loc:"top",order:5},"Legend");return o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS.BE("legend","container"),align:"center",direction:"x",size:"large",style:{...s,padding:"0 1rem",height:"var(--pluto-height-medium)",margin:"1rem 0 "},children:Bo(t,e)})},pl=({variant:e="floating",...t})=>e==="floating"?o.jsxRuntimeExports.jsx(Oo,{...t}):o.jsxRuntimeExports.jsx($f,{...t}),Vo=g.memo(({aetherKey:e,...t})=>(j.useUnidirectional({aetherKey:e,type:B.Line.TYPE,schema:B.stateZ,state:t}),null));Vo.displayName="Line";const zf=Object.freeze(Object.defineProperty({__proto__:null,Line:Vo},Symbol.toStringTag,{value:"Module"})),Fo=({aetherKey:e,color:t,label:n="",...s})=>{const r=j.useUniqueKey(e),{setLine:i,removeLine:l}=We("Line");return g.useEffect(()=>(i({key:r,color:t,label:n}),()=>l(r)),[n,t]),o.jsxRuntimeExports.jsx(Vo,{aetherKey:r,color:t,label:n,...s})},ml=({level:e="h2",...t})=>{const n=j.useUniqueKey(),s=j.useTypography(e),r=yn({key:n,size:(s.lineHeight+2)*s.baseSize,loc:"top",order:10},"Title");return o.jsxRuntimeExports.jsx(te.Space,{justify:"center",align:"center",style:r,children:o.jsxRuntimeExports.jsx(j.MaybeEditable,{...t,level:e})})},fl=({aetherKey:e,...t})=>{const n=j.useUniqueKey(e),[,,s]=j.use$3({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.Tt.topLeft(a);s({position:u.G.translation(d,u.G.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})},Bf=Object.freeze(Object.defineProperty({__proto__:null,Tooltip:fl},Symbol.toStringTag,{value:"Module"})),Df={select:"pointer",zoom:"crosshair",pan:"grab",zoomReset:"crosshair",click:"pointer"},hl=({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:Df[t],...r},...i,children:[o.jsxRuntimeExports.jsx("div",{style:{...u.Tt.css(n),display:u.Tt.areaIsZero(n)?"none":"block"},className:u.CSS.BE("viewport-mask","selection")}),s]}),Of=[{key:"start",icon:o.jsxRuntimeExports.jsx(j.Lt.TextAlign.Left,{})},{key:"center",icon:o.jsxRuntimeExports.jsx(j.Lt.TextAlign.Center,{})},{key:"end",icon:o.jsxRuntimeExports.jsx(j.Lt.TextAlign.Right,{})}],Vf=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(j.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),ms=({children:e=Vf,...t})=>o.jsxRuntimeExports.jsx(ve.Button,{...t,allowMultiple:!1,data:Of,children:e}),Ff=[{key:"large",label:"L"},{key:"medium",label:"M"},{key:"small",label:"S"}],gl=({children:e,...t})=>o.jsxRuntimeExports.jsx(ve.Button,{...t,data:Ff,entryRenderKey:"label",children:e}),Hf=new Set([Z.g.UUID,Z.g.JSON]),jl=Z.g.ALL.filter(e=>e!==Z.g.UNKNOWN).map(e=>({key:e.toString(),name:Hf.has(e)?e.toString().toUpperCase():u.d.capitalize(e.toString())})),Zf=jl.filter(e=>!new Z.g(e.key).isVariable),Gf=[{key:"name",name:"Name"}],Yf=({hideVariableDensity:e=!1,...t})=>o.jsxRuntimeExports.jsx(ve.DropdownButton,{...t,data:e?Zf:jl,columns:Gf,entryRenderKey:"name"}),Wf=[{key:"x",icon:o.jsxRuntimeExports.jsx(j.Lt.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(j.Lt.Arrow.Up,{})}],Kf=[{key:"x",icon:o.jsxRuntimeExports.jsx(j.Lt.Arrow.Right,{})},{key:"y",icon:o.jsxRuntimeExports.jsx(j.Lt.Arrow.Down,{})}],Xf=({key:e,entry:t,onClick:n,selected:s})=>o.jsxRuntimeExports.jsx(j.Icon,{variant:s?"filled":"outlined",onClick:n,children:t.icon},e),El=({children:e=Xf,yDirection:t="up",...n})=>o.jsxRuntimeExports.jsx(ve.Button,{...n,allowMultiple:!1,data:t==="up"?Wf:Kf,children:e}),yl=e=>o.jsxRuntimeExports.jsx(j.Icon,{className:u.CSS.BE("select","clear"),variant:"outlined",...e,children:o.jsxRuntimeExports.jsx(j.Lt.Close,{"aria-label":"clear"})}),xt=({onChange:e,value:t,entryRenderKey:n="key",columns:s,data:r,emptyContent:i,inputProps:l,allowNone:c=!0,searcher:a,className:d,variant:x="button",hideColumnHeader:p=!1,disabled:m,omit:f,children:h,dropdownVariant:E="connected",placeholder:y=fs,inputPlaceholder:S=y,triggerTooltip:k,dropdownZIndex:C,filter:b,actions:w,...L})=>{const{visible:_,open:N,close:A,toggle:I}=j.use$2(),[F,$]=g.useState(null),z=a!=null;j.useAsyncEffect(async()=>{if(j.selectValueIsZero(t))return $(null);if((F==null?void 0:F.key)===t)return;let P=null;if(z)try{[P]=await a.retrieve([t])}finally{P??(P=null)}else r!=null&&(P=r.find(V=>V.key===t)??null);$(P)},[a,t,r]);const R=g.useCallback((P,V)=>{Array.isArray(P)||($(P==null?null:V.entries[0]),A(),e(P,V))},[e,c]),T=g.useMemo(()=>z?j.Search:Gt.Filter,[z]),M=o.jsxRuntimeExports.jsx(T,{searcher:a,filter:b,children:({onChange:P})=>o.jsxRuntimeExports.jsx(qf,{...l,autoFocus:E==="modal",variant:x,onChange:P,onFocus:N,selected:F,entryRenderKey:n,visible:_,allowNone:c,className:d,dropdownVariant:E,disabled:m,placeholder:S,children:w})}),D=o.jsxRuntimeExports.jsx(j.Button,{tooltip:k,variant:"outlined",onClick:I,disabled:m,children:F!=null?Sl(n,F):y});return o.jsxRuntimeExports.jsx(ve.Core,{close:A,zIndex:C,open:N,data:r,omit:f,emptyContent:i,allowMultiple:!1,visible:_,value:t,hideColumnHeader:p,onChange:R,allowNone:c,columns:s,listItem:h,variant:E,trigger:E!=="modal"?M:D,extraDialogContent:E==="modal"?M:void 0,keepMounted:!1,...L})},fs="Select",Sl=(e,t)=>t==null?"":typeof e=="function"?e(t):t[e].toString(),qf=({entryRenderKey:e,selected:t,visible:n,onChange:s,onFocus:r,allowNone:i=!0,placeholder:l=fs,className:c,disabled:a,dropdownVariant:d,children:x,...p})=>{const{clear:m}=j.useSelectionUtils(),[f,h]=g.useState("");g.useEffect(()=>{if(!n){if(Z.w$1(t==null?void 0:t.key))return h("");t!=null&&h(Sl(e,t))}},[t,n,e]);const E=b=>{s(b),h(b)},y=()=>{f===""&&s(""),h(""),r==null||r()},S=b=>{n||(b.preventDefault(),r==null||r())},k=()=>{h(""),m==null||m()};let C;return d!=="modal"&&(C=o.jsxRuntimeExports.jsx(_o.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:n})),o.jsxRuntimeExports.jsxs(j.Text$2,{className:u.CSS(u.CSS.BE("select","input"),c),value:f,onChange:E,onFocus:y,onKeyDown:j.matchCallback([["Enter"]],b=>{b.preventDefault(),!n&&(r==null||r())}),endContent:C,style:{flexGrow:1},onClick:S,placeholder:l,disabled:a,...p,children:[x,i&&o.jsxRuntimeExports.jsx(yl,{onClick:k,disabled:a})]})},an=({children:e="",size:t="medium",color:n,icon:s,onClose:r,className:i,onDragStart:l,...c})=>{const a=u.cssString(n);s==null&&n!=null&&(s=o.jsxRuntimeExports.jsx(j.Lt.Circle,{fill:a}));const d=r==null?void 0:o.jsxRuntimeExports.jsx(j.Icon,{"aria-label":"close",size:"small",className:u.CSS.BE("tag","close"),onClick:x=>{x.stopPropagation(),r()},children:o.jsxRuntimeExports.jsx(j.Lt.Close,{})});return o.jsxRuntimeExports.jsx(j.WithIcon,{startIcon:s,endIcon:d,className:u.CSS(i,u.CSS.B("tag"),r!=null&&u.CSS.BM("tag","closeable")),level:Z.ComponentSizeLevels[t],noWrap:!0,align:"center",onDragStart:l,...c,children:e})},Uf=Object.freeze(Object.defineProperty({__proto__:null,Tag:an},Symbol.toStringTag,{value:"Module"})),Ho=({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(an,{size:"small",variant:"outlined",className:u.CSS(n==null&&!s&&u.CSS.BEM("select-multiple","tag","invalid")),draggable:!0,...r,key:e.toString()},Z.Y(i))},Jf=j.componentRenderProp(Ho),Wt=({onChange:e,value:t,className:n,data:s,columns:r=[],entryRenderKey:i="key",emptyContent:l,searcher:c,renderTag:a=Jf,placeholder:d,onTagDragStart:x,allowMultiple:p,allowNone:m,replaceOnSingle:f,onTagDragEnd:h,style:E,addPlaceholder:y="Add",children:S,dropdownVariant:k="connected",actions:C,...b})=>{const{visible:w,open:L,close:_}=j.use$2(),[N,A]=g.useState([]),[I,F]=g.useState(!1),$=c!=null;j.useAsyncEffect(async()=>{F(!0),j.selectValueIsZero(t)&&A([]);const D=N.map(H=>H.key),P=Z.A(t);if(Z.F.unorderedPrimitiveArrays(D,P)===Z.F.EQUAL)return;let V=[];if($)try{V=await c.retrieve(P)}finally{F(!1)}else s!=null&&(V=s.filter(H=>P.includes(H.key)));A(V)},[c,$,t,s]);const z=g.useCallback((D,P)=>{D!=null&&(A(P.entries),e(Z.A(D),P))},[e]),R=g.useMemo(()=>$?j.Search:Gt.Filter,[$]);let T,M;if(k==="connected")M=o.jsxRuntimeExports.jsx(R,{searcher:c,children:({onChange:D,value:P})=>o.jsxRuntimeExports.jsx(Qf,{dropdownVariant:k,value:P,selectedKeys:t,className:n,onChange:D,loading:I,selected:N,onFocus:L,entryRenderKey:i,visible:w,renderTag:a,placeholder:d,onTagDragStart:x,onTagDragEnd:h,style:E,children:C})});else{const D=Z.A(t);M=o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",align:"center",grow:!0,style:E,size:"small",children:[D.map(P=>{const V=N.find(H=>H.key===P);return a({key:P,entryKey:P,entryRenderKey:i,loading:I,entry:V,onClose:()=>{const H=D.filter(G=>G!==P);e(H,{clicked:null,clickedIndex:-1,entries:[]})},onDragStart:H=>x==null?void 0:x(H,P),onDragEnd:H=>h==null?void 0:h(H,P)})}),D.length>0?o.jsxRuntimeExports.jsx(j.Icon,{onClick:L,children:o.jsxRuntimeExports.jsx(j.Lt.Add,{style:{color:"var(--pluto-gray-l7)"}})}):o.jsxRuntimeExports.jsx(j.Button,{onClick:L,shade:7,startIcon:o.jsxRuntimeExports.jsx(j.Lt.Add,{}),variant:"text",children:y})]}),T=o.jsxRuntimeExports.jsx(R,{searcher:c,children:P=>o.jsxRuntimeExports.jsx(j.Text$2,{autoFocus:!0,placeholder:"Search",...P,children:C})})}return o.jsxRuntimeExports.jsx(ve.Core,{close:_,open:L,data:s,emptyContent:l,visible:w,value:t,onChange:z,allowNone:m,replaceOnSingle:f,columns:r,allowMultiple:!0,listItem:S,trigger:M,extraDialogContent:T,variant:k,...b})},Qf=({selectedKeys:e,loading:t,selected:n,onChange:s,onFocus:r,visible:i,entryRenderKey:l,renderTag:c,placeholder:a=fs,onTagDragStart:d,onTagDragEnd:x,value:p,className:m,children:f,dropdownVariant:h,...E})=>{const{onSelect:y,clear:S}=j.useSelectionUtils(),k=g.useRef(null);g.useLayoutEffect(()=>{var _;i&&((_=k.current)==null||_.focus())},[i,n]);const C=()=>{i||s(""),r==null||r()},b=()=>{i||r==null||r()},w=()=>{i||s("")};let L;return h!=="modal"&&(L=o.jsxRuntimeExports.jsx(_o.Animated,{enabledLoc:"bottom",disabledLoc:"left",enabled:i})),o.jsxRuntimeExports.jsxs(j.Text$2,{ref:k,className:u.CSS(u.CSS.BE("select-multiple","input"),u.CSS.visible(i),m),onBlur:w,placeholder:a,value:p,onChange:s,onFocus:C,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",onClick:b,endContent:L,variant:"button",...E,children:[o.jsxRuntimeExports.jsx(te.Space,{direction:"x",className:u.CSS.BE("select-multiple","tags"),align:"center",grow:!0,size:"small",children:Z.A(e).map(_=>{const N=n.find(A=>A.key===_);return c({key:_,entryKey:_,entryRenderKey:l,loading:t,entry:N,onClose:()=>y==null?void 0:y(_),onDragStart:A=>d==null?void 0:d(A,_),onDragEnd:A=>x==null?void 0:x(A,_)})})}),f,o.jsxRuntimeExports.jsx(yl,{onClick:S})]})},eh=Object.freeze(Object.defineProperty({__proto__:null,BaseButton:ve.BaseButton,Button:ve.Button,ComponentSize:gl,DEFAULT_PLACEHOLDER:fs,DataType:Yf,Direction:El,DropdownButton:ve.DropdownButton,Multiple:Wt,MultipleTag:Ho,Single:xt,TextAlignment:ms,defaultButton:ve.defaultButton},Symbol.toStringTag,{value:"Module"})),Dn=6,th=2,Nr=5,nh=e=>u.Tt.width(e)<Nr&&u.Tt.height(e)<Nr,sh=["zoom","pan","select","zoomReset"],on=[...sh,"click"],oh=ce.z.enum(on),Rl=["zoom","select"],On={defaultMode:"zoom",zoom:[["MouseLeft"]],zoomReset:[["MouseLeft","Control"]],pan:[["MouseLeft","Shift"]],select:[["MouseLeft","Alt"]]},Cl={defaultMode:"pan",pan:[["MouseLeft"]],zoom:[["MouseLeft","Shift"]],zoomReset:[["MouseLeft","Control"]],select:[["MouseLeft","Alt"]]},bl={defaultMode:"select",select:[["MouseLeft"]],pan:[["MouseLeft","Shift"]],zoom:[["MouseLeft","Alt"]],zoomReset:[["MouseLeft","Control"]]},Zo={zoom:On,pan:Cl,select:bl,zoomReset:On,click:On},rh=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)]))},ih=u.Tt.construct(0,0,1,1,u.K.TOP_LEFT),lh={width:30,height:50},wl=({onChange:e,triggers:t,initial:n=ih,threshold:s=lh,ref:r})=>{const i=(t==null?void 0:t.defaultMode)??"zoom",[l,c]=g.useState(u.Tt.ZERO),[a,d]=g.useState(i),[x,p]=j.useStateRef(n),m=g.useRef(u.G.ZERO),f=g.useRef(null),h=u._.construct(s);g.useEffect(()=>p(()=>u.Tt.truncate(n,Dn)),[n]),g.useEffect(()=>d(i),[i]);const[E,y,S,k]=j.useMemoCompare(()=>{const N={...Zo[i],...t},A=j.flattenConfig(N),I=rh(N);return[N,A,I,j.flattenConfig(I)]},j.compareModeConfigs,[t]),C=g.useCallback(({box:N,triggers:A,stage:I,cursor:F})=>{if(f.current==null)return;const $=j.determineMode(E,A),z=u.Tt.construct(f.current);if($==null)return;if($==="zoomReset")return c(u.Tt.ZERO),e==null||e({box:u.Tt.DECIMAL,mode:$,stage:I,cursor:F}),p(u.Tt.DECIMAL);const R=nh(N);if(I==="end"){if(R){$==="zoom"&&c(u.Tt.ZERO),e==null||e({box:x.current,mode:"click",stage:I,cursor:F});return}return p(M=>{if($==="pan"){const P=Ar(N,M,z);return P===null||u.Tt.equals(P,M)?M:(e==null||e({box:P,mode:$,stage:I,cursor:F}),P)}const D=b(N,M,z);return D===null?M:(e==null||e({box:D,mode:$,stage:I,cursor:F}),$==="zoom"?(c(u.Tt.ZERO),D):u.Tt.truncate(M,Dn))})}if(Rl.includes($))return R?void 0:c(u.b.XY.scale(z).clamp(z).translate({x:-u.Tt.left(z),y:-u.Tt.top(z)}).box(Ir(h,N,z)));if(c(M=>u.Tt.areaIsZero(M)?M:u.Tt.ZERO),u.G.distance(F,m.current)<th)return;m.current=F;const T=Ar(N,x.current,z);e==null||e({box:T,mode:$,stage:I,cursor:F})},[c,d,e,E,s.height,s.width,p,f]);g.useImperativeHandle(r,()=>({reset:()=>{c(u.Tt.ZERO),p(u.Tt.DECIMAL),e==null||e({box:u.Tt.DECIMAL,mode:"zoomReset",stage:"start",cursor:u.G.ZERO})}}),[e]);const b=g.useCallback((N,A,I)=>u.Tt.truncate(ro(A,I).box(Ir(h,N,I)),Dn),[s]),w=j.useHeldRef({triggers:[["Control"]]}),L=j.useHeldRef({triggers:[["Alt"]]});g.useEffect(()=>{const N=A=>{if(f.current==null)return;let I=1;A.deltaY<0?I-=.035:I+=.035;const F=u.Tt.construct(f.current),$=u.G.construct(A);if(Array.from(f.current.children).push(f.current),!u.Tt.contains(F,$)||f.current!==A.target&&j.findParent(A.target,P=>P===f.current)==null)return;const T=ro(x.current,u.Tt.construct(f.current)).pos(u.G.construct(A));let D=u.b.XY.magnify({x:w.current.held?1:I,y:L.current.held?1:I}).box(x.current);D=u.Tt.translate(D,{x:w.current.held?0:T.x*(1-I),y:L.current.held?0:T.y*(1-I)}),p(D),e==null||e({stage:"end",box:D,cursor:u.G.construct(A),mode:"zoom"})};return window.addEventListener("wheel",N),()=>window.removeEventListener("wheel",N)},[p,e]),Wi.useDrag({bound:f,onDrag:C,triggers:y,loose:!0});const _=g.useCallback(({triggers:N,stage:A})=>{if(A==="end")return d(i);const I=j.determineMode(S,N);I!=null&&d(I)},[S,i,e]);return j.use$1({triggers:k,callback:_,region:f}),{maskBox:l,ref:f,mode:a}},ro=(e,t)=>u.b.XY.scale(t).clamp(t).scale(e),Ar=(e,t,n)=>{let s=u.Tt.signedDims(ro(t,n).box(e));return s={signedWidth:-s.signedWidth,signedHeight:-s.signedHeight},u.Tt.truncate(u.b.XY.translate(u.G.construct(s)).box(t),Dn)},Ir=(e,t,n)=>u.Tt.height(t)<=e.height?u.Tt.construct(u.Tt.left(t),u.Tt.top(n),u.Tt.width(t),u.Tt.height(n)):u.Tt.width(t)<=e.width?u.Tt.construct(u.Tt.left(n),u.Tt.top(t),u.Tt.width(n),u.Tt.height(t)):t,ch=({mode:e,triggers:t})=>o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",align:"center",children:[o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:u.d.capitalize(e)}),o.jsxRuntimeExports.jsx(te.Space,{empty:!0,direction:"x",align:"center",children:o.jsxRuntimeExports.jsx(j.Text,{trigger:t[0],level:"small"})})]}),ah={zoom:o.jsxRuntimeExports.jsx(j.Lt.Zoom,{}),pan:o.jsxRuntimeExports.jsx(j.Lt.Pan,{}),select:o.jsxRuntimeExports.jsx(j.Lt.Selection,{}),zoomReset:o.jsxRuntimeExports.jsx(j.Lt.Expand,{}),click:o.jsxRuntimeExports.jsx(j.Lt.Bolt,{})},uh=({triggers:e,disable:t=["zoomReset","click"],...n})=>{const s=Object.entries(e).filter(([r])=>!t.includes(r)&&on.includes(r)).map(([r,i])=>({key:r,icon:ah[r],tooltip:o.jsxRuntimeExports.jsx(ch,{mode:r,triggers:i})})).sort((r,i)=>on.indexOf(r.key)-on.indexOf(i.key));return o.jsxRuntimeExports.jsx(ve.Button,{...n,data:s,entryRenderKey:"icon",children:({title:r,entry:i,...l})=>g.createElement(j.Icon,{...l,key:i.key,variant:l.selected?"filled":"text",size:"medium",tooltip:i.tooltip,tooltipLocation:{x:"right",y:"top"}},i.icon)})},dh=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_TRIGGERS:Zo,MASK_MODES:Rl,MODES:on,Mask:hl,PAN_DEFAULT_TRIGGERS:Cl,SELECT_DEFAULT_TRIGGERS:bl,SelectMode:uh,ZOOM_DEFAULT_TRIGGERS:On,modeZ:oh,use:wl},Symbol.toStringTag,{value:"Module"})),xh=e=>e==null?null:e.closest(".pluto-line-plot__viewport")??null,vl=({ref:e,children:t,initial:n=u.Tt.DECIMAL,onChange:s,...r})=>{const{setViewport:i}=We("Viewport");g.useLayoutEffect(()=>{i({box:n,mode:"zoom",cursor:u.G.ZERO,stage:"start"})},[i,n]);const l=g.useCallback(a=>{i(a),s==null||s(a)},[s,i]),c=wl({onChange:l,initial:n,ref:e,...r});return o.jsxRuntimeExports.jsx(hl,{className:u.CSS.BE("line-plot","viewport"),...c,children:t})},ph=Object.freeze(Object.defineProperty({__proto__:null,Floating:Oo,Legend:pl,Line:Fo,LinePlot:cl,Title:ml,Tooltip:Bf,Viewport:vl,XAxis:al,YAxis:ul,axisFactory:$o,selectViewportEl:xh,useContext:We,useGridEntry:yn,useViewport:ll},Symbol.toStringTag,{value:"Module"})),mh=({aetherKey:e,...t})=>(j.use$3({aetherKey:e,type:B.Annotation.TYPE,schema:B.annotationStateZ,initialState:t}),null),kl=({aetherKey:e,menu:t,...n})=>{const s=j.useUniqueKey(e),{setViewport:r,setHold:i}=We("Range.Provider"),[,{hovered:l,count:c},a]=j.use$3({aetherKey:s,type:B.Provider$1.TYPE,schema:B.providerStateZ,initialState:{...n,cursor:null,hovered:null,count:0}}),d=yn({key:s,loc:"top",size:c>0?32:0,order:3},"Annotation.Provider"),x=j.useContextMenu(),p=j.useSyncedRef(x.visible),m=g.useCallback(f=>{const h=y=>{a(S=>({...S,cursor:{x:y.clientX,y:y.clientY}}))},E=f.currentTarget;E.addEventListener("mousemove",h),E.addEventListener("mouseleave",()=>{E.removeEventListener("mousemove",h),p.current||a(y=>({...y,cursor:null}))},{once:!0})},[a]);return o.jsxRuntimeExports.jsx(j.ContextMenu,{style:{...d,cursor:l!=null?"pointer":"default"},...x,menu:()=>t==null||l==null?null:t(l),children:o.jsxRuntimeExports.jsx(te.Space,{style:{width:"100%",height:"100%"},onClick:()=>{l!=null&&(r({box:u.Tt.construct({x:l.viewport.lower,y:0},{x:l.viewport.upper,y:1}),mode:"zoom",cursor:u.G.ZERO,stage:"start"}),i(!0))},onMouseEnter:m})})},fh=Object.freeze(Object.defineProperty({__proto__:null,Annotation:mh,Provider:kl},Symbol.toStringTag,{value:"Module"})),_l={defaultMode:"empty",one:[["1"]],two:[["2"]],clear:[["Shift"]],empty:[[]]},hh=j.flattenConfig(_l),Ml=({aetherKey:e})=>{const t=j.useUniqueKey(e),[,,n]=j.use$3({aetherKey:t,type:B.Measure.TYPE,schema:B.measureStateZ,initialState:{hover:null,one:null,two:null}}),s=g.useRef(null),r=j.useHeldRef({triggers:hh,loose:!0}),i=g.useCallback(({mode:a,cursor:d})=>{if(a==="click"){const x=j.determineMode(_l,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]);ll(i);const l=g.useCallback(a=>n(d=>({...d,hover:u.G.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})},gh=Object.freeze(Object.defineProperty({__proto__:null,Measure:Ml},Symbol.toStringTag,{value:"Module"})),Go=({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,E]=Z.usePurePassthrough({value:t,onChange:s,initial:""}),y=j.useSyncedRef(r),[,{pixelPosition:S},k]=j.use$3({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 R;z!=null&&((R=y.current)==null||R.call(y,z))},[y])}),C=g.useRef(S);S!==C.current&&(C.current=S);const{id:b}=We("Rule"),w=document.getElementById(b),L=w==null?void 0:w.querySelector(".pluto-line-plot__viewport"),_=g.useRef(S);g.useEffect(()=>{k(z=>({...z,position:n,color:c,lineWidth:a,lineDash:d}))},[n,c,a,d]);const N=j.useCursorDrag({onStart:g.useCallback(()=>{p==null||p(),k(z=>({...z,dragging:!0})),_.current=C.current},[]),onMove:z=>{k(R=>({...R,pixelPosition:(_.current??0)+u.Tt.signedHeight(z)}))},onEnd:g.useCallback(()=>{k(z=>({...z,dragging:!1})),_.current=S},[])}),A=g.useRef(null);if(n==null||S==null)return null;const F=new u.Color(c).pickByContrast("#000000","#ffffff"),$=o.jsxRuntimeExports.jsxs("div",{ref:A,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:N,draggable:!0}),o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",align:"center",className:u.CSS(x,u.CSS.BE("rule","tag")),bordered:!0,onClick:p,size:1,rounded:!0,style:{borderColor:u.cssString(c),backgroundColor:new u.Color(c).setAlpha(.7).hex,...m},...f,children:[o.jsxRuntimeExports.jsx(j.Editable,{className:u.CSS.B("label"),level:"small",value:h,onChange:E,color:F}),o.jsxRuntimeExports.jsx(j.Divider,{direction:"y",style:{borderColor:u.cssString(c)}}),o.jsxRuntimeExports.jsxs(te.Space,{size:"small",direction:"x",align:"center",children:[o.jsxRuntimeExports.jsx(j.Editable,{value:n.toFixed(2),onChange:z=>{const R=Number(z);isFinite(R)&&(r==null||r(R))},level:"small",color:F}),o.jsxRuntimeExports.jsx(j.MaybeEditable,{level:"small",color:F,value:l,onChange:i})]})]})]});return L==null?$:Mo.createPortal($,L)},jh=Object.freeze(Object.defineProperty({__proto__:null,Rule:Go},Symbol.toStringTag,{value:"Module"})),Ll=j.canDropOfType(Ye),Eh=({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:E=!1,initialViewport:y=u.Tt.DECIMAL,legendVariant:S,onViewportChange:k,viewportTriggers:C,annotationProvider:b,onSelectRule:w,...L})=>{var F;const _=t.filter(({location:$})=>u.K.isY($)),N=g.useRef(null),A=j.usePrevious(e.length),I=j.usePrevious(L.hold);return(A===0&&e.length!==0||I===!0&&L.hold===!1)&&((F=N.current)==null||F.reset()),o.jsxRuntimeExports.jsxs(cl,{...L,children:[_.map(($,z)=>{const R=e.filter(D=>D.axes.x===$.key),T=t.filter(({location:D})=>u.K.isX(D)),M=f==null?void 0:f.filter(D=>[...T.map(({key:P})=>P),$.key].includes(D.axis));return o.jsxRuntimeExports.jsx(yh,{axis:$,index:z,lines:R,yAxes:T,rules:M,onAxisChannelDrop:p,onAxisChange:m,annotationProvider:b,onRuleChange:x,onSelectRule:w},$.key)}),i&&o.jsxRuntimeExports.jsx(pl,{onLineChange:d,position:l,onPositionChange:c,variant:S}),n&&o.jsxRuntimeExports.jsx(ml,{value:s,onChange:r,level:a}),o.jsxRuntimeExports.jsxs(vl,{initial:y,onChange:k,triggers:C,ref:N,children:[h&&o.jsxRuntimeExports.jsx(fl,{}),E&&o.jsxRuntimeExports.jsx(Ml,{})]})]})},yh=({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=j.useDrop({type:"Channel.LinePlot.XAxis",canDrop:Ll,onDrop:g.useCallback(({items:y})=>{const S=j.filterByType(Ye,y);return l==null||l(d,S.map(({key:k})=>k)),S},[d,l])}),h=s==null?void 0:s.filter(y=>y.axis===d),E=j.useDraggingState();return o.jsxRuntimeExports.jsxs(al,{...p,...f,location:a,showGrid:x??n===0,className:u.CSS(u.CSS.dropRegion(j.canDropOfType(Ye)(E))),onAutoBoundsChange:y=>c==null?void 0:c({key:d,bounds:y}),children:[e.map((y,S)=>{const k=t.filter(b=>b.axes.y===y.key),C=s==null?void 0:s.filter(b=>b.axis===y.key);return o.jsxRuntimeExports.jsx(Rh,{axis:{...y,showGrid:x??(n===0&&S===0)},lines:k,rules:C,onRuleChange:r,onAxisChannelDrop:l,onAxisChange:c,onSelectRule:i},y.key)}),h==null?void 0:h.map(y=>g.createElement(Go,{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(kl,{...m})]})},Sh=({channels:{x:e,y:t}})=>`${e??0}-${t}`,Rh=({lines:e,rules:t,onRuleChange:n,onAxisChannelDrop:s,onAxisChange:r,axis:{key:i,location:l,...c},onSelectRule:a})=>{const d=j.useDrop({type:"Channel.LinePlot.YAxis",canDrop:Ll,onDrop:g.useCallback(({items:p})=>{const m=j.filterByType(Ye,p);return s==null||s(i,m.map(({key:f})=>f)),m},[i,s])}),x=j.useDraggingState();return o.jsxRuntimeExports.jsxs(ul,{...c,...d,location:l,className:u.CSS(u.CSS.dropRegion(j.canDropOfType(Ye)(x))),onAutoBoundsChange:p=>r==null?void 0:r({key:i,bounds:p}),children:[e.map(p=>o.jsxRuntimeExports.jsx(Ch,{line:p},Sh(p))),t==null?void 0:t.map(p=>g.createElement(Go,{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)}))]})},Ch=({line:e})=>e.variant==="static"?o.jsxRuntimeExports.jsx(wh,{line:e}):o.jsxRuntimeExports.jsx(bh,{line:e}),bh=({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(Fo,{aetherKey:e,y:c,x:l,...i})},wh=({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(Fo,{aetherKey:t,y:l,x:i,...r})},$r=[{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"}],Wn=({items:e},t)=>{const n=j.filterByType(Ye,e);return n.length>0&&!n.every(s=>t.includes(s.key))},Pl=["name","alias"],Tl=e=>{const t=xs();return g.useMemo(()=>e.length===0?$r:$r.filter(n=>e.includes(n.key)),[e,t])},Nl=e=>{if(e==null)return o.jsxRuntimeExports.jsx(j.Lt.Channel,{});if(Z.Fg.isCalculated(e))return o.jsxRuntimeExports.jsx(j.Lt.Calculation,{});if(e.isIndex)return o.jsxRuntimeExports.jsx(j.Lt.Index,{});const t=new Z.g(e.dataType);return t.isInteger?o.jsxRuntimeExports.jsx(j.Lt.Binary,{}):t.isFloat?o.jsxRuntimeExports.jsx(j.Lt.Decimal,{}):t.equals(Z.g.STRING)?o.jsxRuntimeExports.jsx(j.Lt.String,{}):t.equals(Z.g.JSON)?o.jsxRuntimeExports.jsx(j.Lt.JSON,{}):o.jsxRuntimeExports.jsx(j.Lt.Channel,{})},vh=({key:e,...t})=>o.jsxRuntimeExports.jsx(Ho,{icon:Nl(t.entry),...t},e),kh=({columns:e=Pl,onChange:t,className:n,value:s,searchOptions:r,...i})=>{const l=Fe(),c=xs(),a=Tl(e),d=Io(),x=j.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(j.Text$3.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:f,onDragEnd:h,...E}=j.useDragAndDrop({type:"Channel.SelectMultiple",canDrop:g.useCallback(b=>Wn(b,Z.A(s)),[s]),onDrop:g.useCallback(({items:b})=>{const w=j.filterByType(Ye,b);if(w.length===0)return[];const L=Z.c.unique([...Z.A(s),...w.map(_=>_.key)]);return t(L,{clickedIndex:null,clicked:null,entries:[]}),w},[t,s])}),y=j.useDraggingState(),S=g.useCallback(({dropped:b})=>{t(Z.A(s).filter(w=>!b.some(L=>L.key===w)),{clickedIndex:null,clicked:null,entries:[]})},[t,s]),k=g.useCallback((b,w)=>f([{key:w,type:Ye}],S),[f,S]),C=g.useCallback(b=>c[b.key]??b.name,[c]);return o.jsxRuntimeExports.jsx(Wt,{className:u.CSS(n,u.CSS.dropRegion(Wn(y,Z.A(s)))),value:s,onTagDragStart:k,onTagDragEnd:h,searcher:p,onChange:t,columns:a,emptyContent:m,entryRenderKey:C,renderTag:vh,...E,...i})},Ct=({columns:e=Pl,onChange:t,value:n,className:s,data:r,searchOptions:i,...l})=>{const c=Fe(),a=xs(),d=Tl(e),x=Io(),p=j.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(j.Text$3.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),h=g.useId(),E=g.useMemo(()=>({key:h,type:"Channel.SelectMultiple"}),[h]),{startDrag:y,onDragEnd:S,...k}=j.useDragAndDrop({type:"Channel.SelectSingle",canDrop:g.useCallback(L=>Wn(L,Z.o$1(n)),[n]),onDrop:g.useCallback(({items:L})=>{const _=j.filterByType(Ye,L);return _.length===0?[]:(t(_[0].key,{clickedIndex:null,clicked:null,entries:[]}),_)},[E,t])}),C=j.useDraggingState(),b=g.useCallback(()=>n!=null&&y([{type:Ye,key:n}]),[y,n]),w=g.useCallback(L=>a[L.key]??L.name,[a]);return o.jsxRuntimeExports.jsx(xt,{data:r,className:u.CSS(s,u.CSS.dropRegion(Wn(C,Z.o$1(n)))),value:n,onDragStart:b,onDragEnd:S,onChange:t,searcher:m,columns:d,emptyContent:f,entryRenderKey:w,...k,...l})},_h=Object.freeze(Object.defineProperty({__proto__:null,AliasInput:hf,AliasProvider:sl,LinePlot:Eh,SelectMultiple:kh,SelectSingle:Ct,resolveIcon:Nl,useActiveRange:Io,useAlias:nl,useAliases:xs,useContext:tl,useName:ps},Symbol.toStringTag,{value:"Module"})),pt=({path:e,optional:t=!1,onChange:n})=>{const s=tt(),{get:r,bind:i,set:l,setStatus:c}=s,[a,d]=g.useState(r(e,{optional:t}));g.useEffect(()=>(d(r(e,{optional:t})),i({path:e,onChange:d,listenToChildren:!1})),[e,n,i,r]);const x=g.useCallback(f=>{n==null||n(f,{...s,path:e}),l(e,f)},[e,l,n]),p=g.useCallback(f=>c(e,f),[e,c]);if(a==null){if(!t)throw new Error(`Field state is null: ${e}`);return null}let m;return s.mode==="preview"&&(m="preview"),{onChange:x,setStatus:p,variant:m,...a}},Al=(e,t=!1,n)=>{const{get:s,bind:r}=tt(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},Il=(e,t=!1,n)=>{var l;const{get:s,bind:r}=tt(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},Mh=e=>{var t,n;return((n=(t=Al(e,!0))==null?void 0:t.status)==null?void 0:n.variant)==="success"},Lh=({path:e,ctx:t,onChange:n})=>{const s=tt(t);g.useEffect(()=>s.bind({path:e,onChange:r=>n(r,s),listenToChildren:!1}),[e,s])},Ph=({path:e,optional:t=!1})=>{const{bind:n,get:s}=tt(),[r,i]=g.useState(s(e,{optional:t}));if(g.useEffect(()=>(i(s(e,{optional:t})),n({path:e,onChange:l=>i({...l,value:Z.ee(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},$l=(e,t)=>({add:(n,s)=>{const r=Z.ee(e.get(t).value);r.splice(s,0,...Z.A(n)),e.set(t,r,{validateChildren:!1})},push:(n,s)=>{const r=Z.ee(e.get(t).value);r.push(...Z.A(n)),s!=null&&r.sort(s),e.set(t,r,{validateChildren:!1})},remove:n=>{const s=e.get(t).value,r=new Set(Z.A(n));e.set(t,s.filter((i,l)=>!r.has(l)))},keepOnly:n=>{const s=e.get(t).value,r=new Set(Z.A(n));e.set(t,s.filter((i,l)=>r.has(l)))},set:n=>e.set(t,Z.executeSetter(n,e.get(t).value)),sort:n=>{const s=Z.ee(e.get(t).value);s.sort(n),e.set(t,s)}}),Th=({path:e,updateOnChildren:t=!1,ctx:n})=>{const s=tt(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(Z.ee(a.value))},listenToChildren:t})),[e,r,i,c]),g.useMemo(()=>({value:l,...$l(s,e)}),[l,s,e])},Yo=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:()=>{}}),tt=e=>{const t=g.useContext(Yo);return e??t},zr=e=>({key:e,variant:"success",message:""}),Nh=e=>e.code===ce.z.ZodIssueCode.custom&&e.params!=null&&"variant"in e.params?e.params.variant:"error",zl=({values:e,sync:t=!1,schema:n,mode:s="normal",onChange:r})=>{const i=g.useRef({state:e,statuses:new Map,touched:new Set,listeners:new Map,parentListeners:new Map}),l=j.useSyncedRef(n),c=j.useSyncedRef(r),a=g.useCallback(({path:w,onChange:L,listenToChildren:_=!1})=>{var F;const{parentListeners:N,listeners:A}=i.current,I=_?N:A;return I.has(w)||I.set(w,new Set),(F=I.get(w))==null||F.add(L),()=>{var $;return($=I.get(w))==null?void 0:$.delete(L)}},[]),d=g.useCallback((w,{optional:L}={optional:!1})=>{const{state:_,statuses:N,touched:A}=i.current,I=Z._.get(_,w,{optional:L});if(I==null)return null;const F={value:I,status:N.get(w)??zr(w),touched:A.has(w),required:!1};if(l.current==null)return F;const $=l.current,z=Z.y.getFieldSchema($,w,{optional:!0});return z==null||(F.required=!z.isOptional()),F},[]),x=g.useCallback(w=>{const{state:L,statuses:_,touched:N,listeners:A,parentListeners:I}=i.current;Z._.remove(L,w),_.delete(w),N.delete(w),A.delete(w),I.delete(w)},[]),p=g.useCallback(w=>{const{statuses:L,touched:_}=i.current;i.current.state=w,f(""),L.clear(),_.clear()},[]),m=g.useCallback(w=>{var N;const{listeners:L}=i.current,_=d(w,{optional:!0});_!=null&&((N=L.get(w))==null||N.forEach(A=>A(_)))},[]),f=g.useCallback(w=>{const{listeners:L,parentListeners:_}=i.current,N=L.get(w);if(w==""&&([...L.keys()].forEach(F=>{var z;const $=d(F,{optional:!0});$!=null&&((z=L.get(F))==null||z.forEach(R=>{R($)}))}),[..._.keys()].forEach(F=>{var z;const $=d(F,{optional:!0});$!=null&&((z=_.get(F))==null||z.forEach(R=>{R($)}))})),N!=null){const A=d(w,{optional:!0});A!=null&&N.forEach(I=>{I(A)})}_.forEach((A,I)=>{if(Z._.pathsMatch(w,I)){const $=d(I,{optional:!0});$!=null&&A.forEach(z=>{z($)})}})},[]),h=g.useCallback((w,L="",_=!0)=>{const{statuses:N,listeners:A,touched:I}=i.current;if(w.success){const R=[...N.keys()];return N.clear(),R.forEach(T=>m(T)),!0}let F=!0;const $=new Set(w.error.issues.map(R=>R.path.join(".")));let z=(R,T)=>R===T;return _&&(z=(R,T)=>Z._.pathsMatch(R,T)),w.error.issues.forEach(R=>{var V;const{message:T}=R,M=R.path.join(".");if(!z(M,L))return;const D=Nh(R);D!=="warning"&&(F=!1),N.set(M,{key:M,variant:D,message:T}),I.add(M);let P=d(M,{optional:!0});P??(P={value:void 0,status:N.get(M)??zr(M),touched:!1,required:!1}),(V=A.get(M))==null||V.forEach(H=>H(P))}),N.forEach((R,T)=>{$.has(T)||(N.delete(T),m(T))}),F},[]),E=g.useCallback((w,L)=>{if(l.current==null)return!0;const{state:_}=i.current,N=l.current.safeParse(_);return h(N,w,L)},[h]),y=g.useCallback(async(w,L)=>{if(l.current==null)return!0;const{state:_}=i.current,N=await l.current.safeParseAsync(_);return h(N,w,L)},[h]),S=g.useCallback((w,L,_={})=>{const N=Z._.get(i.current.state,w,{optional:!0}),{validateChildren:A=!0}=_,{state:I,touched:F}=i.current;F.add(w),w.length===0?i.current.state=L:Z._.set(I,w,L),f(w),(async()=>{var z;let $;try{$=E(w,A)}catch{$=await y(w,A)}(z=c.current)==null||z.call(c,{values:i.current.state,path:w,prev:N,valid:$})})()},[]),k=g.useCallback(w=>Z._.has(i.current.state,w),[]),C=g.useCallback((w,L)=>{i.current.statuses.set(w,L),i.current.touched.add(w),m(w)},[]),b=g.useCallback(()=>{const{statuses:w}=i.current;w.clear(),w.forEach((L,_)=>m(_))},[]);return g.useEffect(()=>{if(!t)return;const{listeners:w}=i.current;i.current.state=e,w.forEach((L,_)=>{const N=d(_,{optional:!0});N!=null&&L.forEach(A=>A(N))})},[t,e]),g.useMemo(()=>({bind:a,set:S,get:d,mode:s,validate:E,validateAsync:y,value:()=>i.current.state,has:k,remove:x,setStatus:C,clearStatuses:b,reset:p}),[a,S,d,E,y,k,x,C,b,p,s])},Ah=e=>o.jsxRuntimeExports.jsx(Yo.Provider,{value:e,children:e.children}),Ih=j.componentRenderProp(j.Text$2),ye=({path:e,children:t=Ih,label:n,padHelpText:s=!0,visible:r=!0,hideIfNull:i=!1,optional:l,onChange:c,className:a,...d})=>{const x=pt({path:e,optional:l??i,onChange:c}),p=tt();if(x==null)return null;if(e==null)throw new Error("No path provided to Form Field");if(n??(n=u.d.capitalize(Z._.element(e,-1))),r=typeof r=="function"?r(x,p):r,!r)return null;const m=x.status.message,{onChange:f,value:h}=x,E={onChange:f,value:h};return x.variant!=null&&(E.variant=x.variant),o.jsxRuntimeExports.jsx(Te.Item,{padHelpText:s,helpText:m,helpTextVariant:x.status.variant,label:n,required:x.required,className:u.CSS(a,u.CSS.BE("field",e.split(".").join("-")),u.CSS.M(x.status.variant)),...d,children:t(E)})},Mt=e=>({fieldKey:t,fieldProps:n,inputProps:s})=>{const r=({inputProps:i,path:l,fieldKey:c=t,...a})=>o.jsxRuntimeExports.jsx(ye,{...n,...a,path:c?`${l}.${c}`:l,children:d=>o.jsxRuntimeExports.jsx(e,{...d,...s,...i})});return r.displayName=e.displayName,r},Bl=Mt(j.Numeric),zt=Bl({}),Dl=Mt(j.Text$2),Wo=Dl({}),Ol=Mt(j.Switch$1),hs=Ol({}),$h=Mt(xt),zh=Mt(Wt),Bh=Mt(ve.DropdownButton),Ko=({key:e,open:t,onChange:n})=>{const s=j.useMemoPrimitiveArray(e);j.useAsyncEffect(async()=>{if(t==null)return;const r=await t();if(r!=null)return r.onChange(n),async()=>await r.close()},[t==null,s])},Dh=({fetchInitialValue:e,...t})=>{const[n,s]=g.useState(void 0);return j.useAsyncEffect(async()=>{s(await e())},[e]),Ko({...t,onChange:s}),n},Oh=Object.freeze(Object.defineProperty({__proto__:null,useListener:Ko,useState:Dh},Symbol.toStringTag,{value:"Module"})),Vh=({key:e,name:t,queryFn:n,values:s,openObservable:r,applyChanges:i,applyObservable:l,...c})=>{const a=Fe(),d=j.useExceptionHandler(),x=j.useMemoPrimitiveArray(e),p=zl({values:s,...c,sync:!1,onChange:h=>{a!=null&&(async()=>{try{await(i==null?void 0:i({...h,client:a}))}catch(E){d(E,`Failed to save ${t}`)}})()}});j.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 Ko({key:x,open:m,onChange:f}),p},Fh=Object.freeze(Object.defineProperty({__proto__:null,Context:Yo,Field:ye,Form:Ah,NumericField:zt,SwitchField:hs,TextField:Wo,buildDropdownButtonSelectField:Bh,buildNumericField:Bl,buildSelectMultiField:zh,buildSelectSingleField:$h,buildSwitchField:Ol,buildTextField:Dl,fieldArrayUtils:$l,fieldBuilder:Mt,use:zl,useChildFieldValues:Ph,useContext:tt,useField:pt,useFieldArray:Th,useFieldListener:Lh,useFieldState:Al,useFieldValid:Mh,useFieldValue:Il,useSynced:Vh},Symbol.toStringTag,{value:"Module"})),Hh=[{key:"name",name:"Name"},{key:"location",name:"Location"}],Zh=({searchOptions:e,...t})=>{const n=Fe();let s=n==null?void 0:n.hardware.devices;return e!=null&&n!=null&&(s=n.hardware.devices.newSearcherWithOptions(e)),o.jsxRuntimeExports.jsx(xt,{columns:Hh,searcher:s,entryRenderKey:"name",...t})},Gh=Object.freeze(Object.defineProperty({__proto__:null,SelectSingle:Zh},Symbol.toStringTag,{value:"Module"})),Bt="label",Xo=[{key:"color",name:"Color",render:({entry:e})=>o.jsxRuntimeExports.jsx(j.Lt.Circle,{name:"circle",color:e.color,style:{height:"2.5rem",width:"2.5rem"}})},{key:"name",name:"Name"}],Kn=({items:e},t)=>{const n=j.filterByType(Bt,e);return n.length>0&&!n.every(s=>t.includes(s.key))},Yh=({entry:e,loading:t,entryKey:n,entryRenderKey:s,...r})=>o.jsxRuntimeExports.jsx(an,{color:e==null?void 0:e.color,...r,children:e==null?void 0:e.name}),Wh=j.componentRenderProp(Yh),Kh=({onChange:e,className:t,value:n,...s})=>{const r=Fe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(j.Text$3.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=j.useDragAndDrop({type:"Label.SelectMultiple",canDrop:g.useCallback(m=>Kn(m,Z.A(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=j.filterByType(Bt,m);if(f.length===0)return[];const h=Z.c.unique([...Z.A(n),...f.map(E=>E.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),d=j.useDraggingState(),x=g.useCallback(({dropped:m})=>{e(Z.A(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:Bt}],x),[l,x]);return o.jsxRuntimeExports.jsx(Wt,{className:u.CSS(t,u.CSS.dropRegion(Kn(d,Z.A(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.labels,onChange:e,columns:Xo,emptyContent:i,renderTag:Wh,addPlaceholder:"Label",...a,...s})},Vl=({value:e,onChange:t})=>{const n=Fe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(j.Text$3.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=j.useDragAndDrop({type:"Label.SelectSingle",canDrop:g.useCallback(d=>Kn(d,Z.o$1(e)),[e]),onDrop:g.useCallback(({items:d})=>{const x=j.filterByType(Bt,d);return x.length===0?[]:(t(x[0].key,{clickedIndex:null,clicked:null,entries:[]}),x)},[i,t])}),c=j.useDraggingState(),a=g.useCallback(()=>e!=null&&l.startDrag([{type:Bt,key:e}]),[l.startDrag,e]);return{emptyContent:s,dragging:c,...l,onDragStart:a,searcher:n==null?void 0:n.labels}},Xh=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=Vl({value:t,onChange:e});return o.jsxRuntimeExports.jsx(xt,{data:s,className:u.CSS(n,u.CSS.dropRegion(Kn(i,Z.o$1(t)))),value:t,onChange:e,columns:Xo,entryRenderKey:"name",...l,...r})},qh=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=Vl({value:t,onChange:n});return o.jsxRuntimeExports.jsx(xt,{data:e,value:t,onChange:n,columns:Xo,entryRenderKey:"name",...i,...s})},Uh=Object.freeze(Object.defineProperty({__proto__:null,HAUL_TYPE:Bt,SelectButton:qh,SelectMultiple:Kh,SelectSingle:Xh},Symbol.toStringTag,{value:"Module"})),Fl=({children:e,centered:t,visible:n,enabled:s=!0,close:r,style:i,...l})=>{const c=g.useRef(null),a=g.useRef(n);j.useClickOutside({ref:c,exclude:x=>j.findParent(x.target,m=>m.getAttribute("role")==="dialog")!=null,onClickOutside:r});const d=g.useCallback(x=>{var m;if(!a.current||x.stage!=="start")return;const p=(m=c.current)==null?void 0:m.querySelectorAll(`.${u.CSS.visible(!0)}`);p&&p.length>0||r()},[r]);return j.use$1({triggers:[["Escape"]],callback:d,loose:!0}),o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(u.CSS.BE("modal","bg"),u.CSS.visible(n),s&&u.CSS.M("enabled-modal")),empty:!0,align:"center",children:o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(u.CSS.BE("modal","dialog"),t&&u.CSS.M("centered")),role:"dialog",empty:!0,ref:c,...l,style:{zIndex:s?11:void 0,...i},children:o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(u.CSS.BE("modal","content")),empty:!0,children:e})})})},Jh=({root:e,...t})=>Mo.createPortal(o.jsxRuntimeExports.jsx(Fl,{...t}),j.getRootElement(e)),Qh=Object.freeze(Object.defineProperty({__proto__:null,Dialog:Fl,Modal:Jh},Symbol.toStringTag,{value:"Module"})),gs=new Error("Tab not found"),eg=new Error("Invalid Mosaic"),Xn=(e,t,n="center",s)=>{var p;if(e=nt(e),s===void 0)return io(e,t);const r=lo(e,s);if(n==="center")return(p=r.tabs)==null||p.push(t),r.selected=t.tabKey,e;const i=r.key*2,l=r.key*2+1,c=n==="top"||n==="left"?i:l;if(lo(e,c).key!==r.key)return Xn(e,t,"center",c);if(r.tabs==null||r.tabs.length===0)return Xn(e,t,"center",s);const[a,d,x]=ig(n);if(r.direction=x,r[a]={key:0,tabs:[t],selected:t.tabKey},r[d]={key:0,tabs:r.tabs,selected:r.selected},r.first==null||r.last==null)throw eg;return r.first.key=i,r.last.key=l,r.tabs=void 0,r.size=void 0,r.selected=void 0,e},tg=(e,t,n)=>{var i;e=nt(e);const[s,r]=bt(e,t);if(s==null||r==null)throw gs;return r.tabs=(i=r.tabs)==null?void 0:i.map(l=>l.tabKey===t?n(l):l),e},io=(e,t)=>(e=nt(e),e.tabs!=null?(e.tabs.push(t),e.selected=t.tabKey,e):(e.first!=null?e.first=io(e.first,t):e.last!=null&&(e.last=io(e.last,t)),e)),qn=e=>{e=nt(e);const t=[];if(e.tabs!=null&&(e.selected=ke.resetSelection(e.selected,e.tabs),e.selected!=null&&t.push(e.selected)),e.first!=null){const[n,s]=qn(e.first);e.first=n,t.push(...s)}if(e.last!=null){const[n,s]=qn(e.last);e.last=n,t.push(...s)}return[e,t]},qo=(e,t)=>{var r;e=nt(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=ke.resetSelection(n.selected,n.tabs),e=rg(e);const s=n.selected??Un(e);return[e,s]},Un=e=>e.selected!=null?e.selected:e.first!=null?Un(e.first):e.last!=null?Un(e.last):null,Hl=(e,t)=>{e=nt(e);const[n,s]=bt(e,t);if(n==null||s==null)throw gs;return s.selected=t,e},Zl=(e,t,n,s)=>{e=nt(e);const[r,i]=bt(e,t);if(r==null||i==null)throw gs;const[l,c]=qo(e,t);return[Xn(l,r,n,s),c]},un=(e,t)=>{if(e.tabs!=null)return e.tabs.some(n=>n.tabKey===t)?e:void 0;if(e.first!=null){const n=un(e.first,t);if(n!=null)return n}if(e.last!=null){const n=un(e.last,t);if(n!=null)return n}},Gl=(e,t,n)=>{const s=Jn(e,t);if(s==null)throw new Error("Node not found");return s.size=n,e},ng=(e,t,n)=>{e=nt(e);const s=un(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=ke.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=un(e,t);return n==null?!1:n.tabs!=null&&n.tabs.length>1},Yl=(e,t,n)=>{e=nt(e);const[,s]=bt(e,t);if((s==null?void 0:s.tabs)==null)throw gs;return s.tabs=ke.rename(t,n,(s==null?void 0:s.tabs)??[]),e},og=e=>e.tabs!=null?e.tabs.length===0:e.first==null&&e.last==null,lo=(e,t)=>{const n=Jn(e,t);if(n!=null)return n;const s=Math.floor(t/2);return s===0?e:lo(e,s)},rg=e=>{let t=!0;for(;t;)[e,t]=co(e);return e.first==null&&e.last==null&&(e.key=1),e},co=e=>{if(e.first==null||e.last==null)return[e,!1];if(Dr(e.first))return[Br(e.last,!0),!0];if(Dr(e.last))return[Br(e.first,!1),!0];let t,n;return[e.first,t]=co(e.first),[e.last,n]=co(e.last),[e,t||n]},Br=(e,t)=>(e.size=void 0,e.key=(e.key-Number(t))/2,e),Dr=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]},Jn=(e,t)=>{if(e.key===t)return e;if(e.first==null||e.last==null)return;const n=Jn(e.first,t);return n??Jn(e.last,t)},ig=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")}},nt=e=>Z._.copy(e),Qn=(e,t,n=[])=>(n.push(t(e)),e.first!=null&&Qn(e.first,t,n),e.last!=null&&Qn(e.last,t,n),n),ao=(e,t)=>{t(e),e.first!=null&&ao(e.first,t),e.last!=null&&ao(e.last,t)};class Wl{constructor(t={}){Ge(this,"parent");Ge(this,"stub");Ge(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 lg=({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})},Kl=({node:e,children:t})=>Mo.createPortal(t,e.el),cg=Object.freeze(Object.defineProperty({__proto__:null,In:Kl,Node:Wl,Out:lg},Symbol.toStringTag,{value:"Module"})),es=g.memo(e=>{const{onResize:t,...n}=e,{root:{tabs:s,direction:r,first:i,last:l,key:c,size:a},emptyContent:d,...x}=n,p=g.useCallback(([h])=>t(c,h),[t]),{props:m}=Po({direction:r,onResize:p,count:2,initialSizes:a!=null?[a]:void 0});let f;return s!==void 0?f=o.jsxRuntimeExports.jsx(Xl,{emptyContent:d,...n}):i!=null&&l!=null?f=o.jsxRuntimeExports.jsxs(To,{id:`mosaic-${c}`,align:"stretch",className:u.CSS.BE("mosaic","resize"),...m,children:[o.jsxRuntimeExports.jsx(es,{...x,root:i,onResize:t},i.key),o.jsxRuntimeExports.jsx(es,{...x,root:l,onResize:t},l.key)]}):(f=null,console.warn("Mosaic tree is malformed")),c===1?o.jsxRuntimeExports.jsx(j.Provider$3,{children:f}):f});es.displayName="Mosaic";const ts="pluto-mosaic-tab-drop",Uo="pluto-mosaic-tab-create",ag=(e,t,n)=>{if(j.filterByType(j.FILE_TYPE,t).length>0&&n)return!0;const r=j.filterByType(ts,t).map(c=>c.key),i=e.filter(c=>!r.includes(c.tabKey)).length>0;return j.filterByType(Uo,t).length>0||r.length>0&&(i||e.length===0)},Xl=g.memo(({root:e,onDrop:t,onCreate:n,activeTab:s,children:r,onFileDrop:i,...l})=>{const{key:c,tabs:a}=e,[d,x]=g.useState(null),p=i!=null,m=g.useCallback(({items:w})=>ag(a,w,p),[a,p]),f=g.useCallback(({items:w,event:L})=>{if(L==null)return[];x(null);const _=j.filterByType(j.FILE_TYPE,w).length>0,N=a.length===0?"center":Vr(Or(L));if(_)return i==null||i(c,N,L),w;const A=j.filterByType(ts,w);if(A.length>0){const F=A.map(({key:$})=>$)[0];t(c,F,N)}const I=j.filterByType(Uo,w);if(I.length>0){const F=I.map(({key:$})=>$);n==null||n(c,N,F)}return A},[t,a.length]),h=g.useCallback(({event:w})=>{if(w==null)return;const L=a.length===0?"center":Vr(Or(w));x(L)},[a.length]),{startDrag:E,...y}=j.useDragAndDrop({type:"Mosaic",canDrop:m,onDrop:f,onDragOver:h}),S=m(j.useDraggingState()),k=g.useCallback(()=>x(null),[]),C=g.useCallback((w,{tabKey:L})=>{E([{key:L,type:ts,elementID:w.currentTarget.id}])},[E]),b=g.useCallback(()=>n==null?void 0:n(c,"center"),[c]);return o.jsxRuntimeExports.jsxs("div",{id:`mosaic-${c}`,className:u.CSS.BE("mosaic","leaf"),children:[o.jsxRuntimeExports.jsxs(ke.Tabs,{id:`tab-${c}`,tabs:a,onDragLeave:k,selected:e.selected,selectedAltColor:s===e.selected,onDragStart:C,onCreate:b,...l,...y,children:[e.selected!=null&&r(a.find(w=>w.tabKey===e.selected)),S&&o.jsxRuntimeExports.jsx("div",{style:{zIndex:1e3,position:"absolute",top:0,left:0,width:"100%",height:"100%"}})]}),d!=null&&o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("mosaic","mask"),style:ug[d]})]})});Xl.displayName="MosaicTabLeaf";const ug={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%"}},Or=e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;return s<24?{px:.5,py:.5}:{px:n/t.width,py:s/t.height}},dg=e=>e,xg=e=>1-e,Vr=({px:e,py:t})=>{if(e>.33&&e<.66&&t>.33&&t<.66)return"center";const[n,s]=[dg(e),xg(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")},pg=({root:e,onSelect:t,children:n})=>{const s=g.useRef(new Map),r=new Set,i=Qn(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 Wl({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(Kl,{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]},mg=ce.z.object({key:ce.z.number(),tabs:ce.z.array(ke.tabZ).optional(),selected:ce.z.string().optional(),direction:u.g.direction.optional(),size:ce.z.number().optional()}),uo=mg.extend({first:ce.z.lazy(()=>uo).optional(),last:ce.z.lazy(()=>uo).optional()}),fg=({allowRename:e=!1,initialTree:t})=>{const[n,s]=g.useState(t);return g.useEffect(()=>s(qn(t)[0]),[t]),{root:n,onDrop:(d,x,p)=>s(m=>Zl(m,x,p,d)[0]),onClose:d=>s(x=>qo(x,d)[0]),onSelect:d=>s(x=>Hl(x,d)),onResize:(d,x)=>s(p=>Gl(p,d,x)),onRename:e?(d,x)=>s(p=>Yl(p,d,x)):void 0}},hg=Object.freeze(Object.defineProperty({__proto__:null,HAUL_CREATE_TYPE:Uo,HAUL_DROP_TYPE:ts,Mosaic:es,autoSelectTabs:qn,canSplit:sg,findSelected:Un,findTabNode:un,forEachNode:ao,insertTab:Xn,isEmpty:og,mapNodes:Qn,moveTab:Zl,nodeZ:uo,removeTab:qo,renameTab:Yl,resizeNode:Gl,selectTab:Hl,split:ng,updateTab:tg,use:fg,usePortal:pg},Symbol.toStringTag,{value:"Module"})),gg=({variant:e,className:t,children:n,...s})=>o.jsxRuntimeExports.jsx(te.Space,{className:u.CSS(t,u.CSS.B("note"),u.CSS.M(e)),align:"stretch",empty:!0,...s,children:n}),jg=Object.freeze(Object.defineProperty({__proto__:null,Note:gg},Symbol.toStringTag,{value:"Module"})),Zs={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"})]})},Eg=({disabled:e=[],className:t,focused:n=!0,onMinimize:s,onMaximize:r,onFullscreen:i,onClose:l,...c})=>o.jsxRuntimeExports.jsxs(te.Space,{size:1.5,direction:"x",className:u.CSS(u.CSS.B("macos-controls"),!n&&u.CSS.BM("macos-controls","blurred"),t),...c,children:[o.jsxRuntimeExports.jsx(Gs,{onClick:l,className:u.CSS.BM("macos-control","close"),disabled:e.includes("close"),children:Zs.Close}),o.jsxRuntimeExports.jsx(Gs,{onClick:s,className:u.CSS.BM("macos-control","minimize"),disabled:e.includes("minimize"),children:Zs.Minimize}),o.jsxRuntimeExports.jsx(Gs,{onClick:i,className:u.CSS.BM("macos-control","maximize"),disabled:e.includes("maximize"),children:Zs.Maximize})]}),Gs=({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}),yg=({disabled:e=[],onMinimize:t,onMaximize:n,onClose:s,onFullscreen:r,focused:i,...l})=>o.jsxRuntimeExports.jsxs(te.Pack,{...l,children:[o.jsxRuntimeExports.jsx(Ys,{className:u.CSS.BM("windows-control","minimize"),onClick:t,disabled:e.includes("minimize"),children:o.jsxRuntimeExports.jsx(j.Lt.Subtract,{})}),o.jsxRuntimeExports.jsx(Ys,{className:u.CSS.BM("windows-control","maximize"),onClick:n,disabled:e.includes("maximize"),children:o.jsxRuntimeExports.jsx(j.Lt.Box,{})}),o.jsxRuntimeExports.jsx(Ys,{onClick:s,className:u.CSS.BM("windows-control","close"),disabled:e.includes("close"),children:o.jsxRuntimeExports.jsx(j.Lt.Close,{})})]}),Ys=({disabled:e=!1,className:t,...n})=>e?null:o.jsxRuntimeExports.jsx(j.Icon,{className:u.CSS(u.CSS.B("windows-control"),t),tabIndex:-1,...n}),ql=Z.S.getOS,Sg="Windows",Rg=({forceOS:e,visibleIfOS:t,...n})=>{const s=ql({force:e,default:Sg});if(t!=null&&t!==s)return null;const r=s==="macOS"?Eg:yg;return o.jsxRuntimeExports.jsx(r,{...n})},Cg=Object.freeze(Object.defineProperty({__proto__:null,Controls:Rg,use:ql},Symbol.toStringTag,{value:"Module"})),bg=(e,t)=>{const n=s=>o.jsxRuntimeExports.jsx(e,{...t,...s});return n.displayName=e.displayName,n},wg=Object.freeze(Object.defineProperty({__proto__:null,createComponent:bg},Symbol.toStringTag,{value:"Module"}));g.createContext({instrumentation:Z.B.NOOP});const vg=({children:e,...t})=>{const{path:n}=j.useUnidirectional({type:B.Provider$2.TYPE,schema:B.providerStateZ$1,state:t});return o.jsxRuntimeExports.jsx(j.Composite,{path:n,children:e})},kg="data:video/mp2t;base64,Ly8gQ29weXJpZ2h0IDIwMjUgU3lubmF4IExhYnMsIEluYy4KLy8KLy8gVXNlIG9mIHRoaXMgc29mdHdhcmUgaXMgZ292ZXJuZWQgYnkgdGhlIEJ1c2luZXNzIFNvdXJjZSBMaWNlbnNlIGluY2x1ZGVkIGluIHRoZSBmaWxlCi8vIGxpY2Vuc2VzL0JTTC50eHQuCi8vCi8vIEFzIG9mIHRoZSBDaGFuZ2UgRGF0ZSBzcGVjaWZpZWQgaW4gdGhhdCBmaWxlLCBpbiBhY2NvcmRhbmNlIHdpdGggdGhlIEJ1c2luZXNzIFNvdXJjZQovLyBMaWNlbnNlLCB1c2Ugb2YgdGhpcyBzb2Z0d2FyZSB3aWxsIGJlIGdvdmVybmVkIGJ5IHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAsCi8vIGluY2x1ZGVkIGluIHRoZSBmaWxlIGxpY2Vuc2VzL0FQTC50eHQuCgppbXBvcnQgeyBwbHV0byB9IGZyb20gIkAvcGx1dG8vYWV0aGVyIjsKCnBsdXRvLnJlbmRlcigpOwo=",Ul=({children:e})=>{const[{path:t}]=j.use$3({type:B.BaseProvider.TYPE,schema:B.providerStateZ$2,initialState:{}});return o.jsxRuntimeExports.jsx(j.Composite,{path:t,children:e})},_g=Object.freeze(Object.defineProperty({__proto__:null,Provider:Ul},Symbol.toStringTag,{value:"Module"})),Mg=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-l10)"}:{message:"No channel connected. This element cannot be controlled.",chipColor:"var(--pluto-gray-l5)",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)===Z.rp.Authority.Absolute.valueOf()?{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 P&ID to release control.",chipColor:"var(--pluto-primary-z)"};default:return{message:"Unexpected status.",chipColor:"var(--pluto-error-z)"}}},Jl=({source:e,sink:t,className:n,...s})=>{const r=j.useMemoDeepEqualProps({source:e,sink:t}),[,{status:i},l]=j.use$3({type:B.Chip.TYPE,schema:B.chipStateZ,initialState:{triggered:!1,...r,status:{key:"no_chip",variant:"disabled",message:"No chip connected.",time:Z.m.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}=Mg(i);return o.jsxRuntimeExports.jsx(j.Icon,{variant:"text",className:u.CSS(u.CSS.B("control-chip"),n),disabled:p,onClick:c,tooltip:o.jsxRuntimeExports.jsx(j.Text$1,{level:"small",children:a}),style:x,...s,children:o.jsxRuntimeExports.jsx(j.Lt.Circle,{color:d})})},Ql=g.createContext({needsControlOf:[]}),ec=()=>g.useContext(Ql),Lg=({children:e,onStatusChange:t,...n})=>{const s=j.useMemoDeepEqualProps(n),[{path:r},{status:i,needsControlOf:l},c]=j.use$3({type:B.Controller$1.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(Ql.Provider,{value:{needsControlOf:l},children:[o.jsxRuntimeExports.jsx(j.Composite,{path:r,children:e}),";"]})},tc=({colorSource:e,statusSource:t})=>{var c;const n=j.useMemoDeepEqualProps({colorSource:e,statusSource:t}),[,{color:s,status:r},i]=j.use$3({type:B.Indicator.TYPE,initialState:{...n,status:{key:"no_chip",variant:"warning",message:"No chip connected.",time:Z.m.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.Color.z.parse(r.data.color):s!=null&&!s.isZero?l=s:l="var(--pluto-gray-l8)",o.jsxRuntimeExports.jsxs(j.Dialog$1,{location:{x:"center",y:"bottom"},children:[o.jsxRuntimeExports.jsx(j.Text$1,{level:"p",children:r.message}),o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("indicator"),style:{backgroundColor:u.cssString(l),flexGrow:1}})]})},Pg=({...e})=>{const{needsControlOf:t}=ec(),[,{states:n},s]=j.use$3({type:B.Legend.TYPE,schema:B.legendStateZ,initialState:{states:[],needsControlOf:t}});g.useEffect(()=>{s(l=>({...l,needsControlOf:t}))},[t]);const i=Z.c.unique(n.map(l=>l.subject.key)).map(l=>{const c=n.find(a=>a.subject.key===l);if(c==null)throw new Z.xe("Legend subject not found");return{key:c.subject.key,label:c.subject.name,color:c.subjectColor}});return o.jsxRuntimeExports.jsx(Do,{data:i,...e})},nc=({children:e})=>{const[{path:t}]=j.use$3({type:B.StateProvider.TYPE,schema:B.stateProviderStateZ,initialState:{}});return o.jsxRuntimeExports.jsx(j.Composite,{path:t,children:e})},Tg=Object.freeze(Object.defineProperty({__proto__:null,Chip:Jl,Controller:Lg,Indicator:tc,Legend:Pg,StateProvider:nc,useContext:ec},Symbol.toStringTag,{value:"Module"})),sc=e=>{const t=({disabled:n=!1,...s})=>n?s.children:o.jsxRuntimeExports.jsx(e,{...s});return t.displayName=e.displayName,t},Ng=sc(Ul),Ag=sc(j.Provider$4),Ig=({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(j.Provider$2,{...l,children:o.jsxRuntimeExports.jsx(j.Config,{...i,children:o.jsxRuntimeExports.jsx(j.Provider$3,{...a,children:o.jsxRuntimeExports.jsx(j.Provider$5,{url:s??kg,enabled:n,children:o.jsxRuntimeExports.jsx(Ag,{workerKey:"vis",children:o.jsxRuntimeExports.jsx(vg,{...c,children:o.jsxRuntimeExports.jsx(j.Aggregator,{children:o.jsxRuntimeExports.jsx(el,{connParams:t,children:o.jsxRuntimeExports.jsx(sl,{...d,children:o.jsxRuntimeExports.jsx(j.Provider$1,{...p,children:o.jsxRuntimeExports.jsx(j.Provider,{...r,children:o.jsxRuntimeExports.jsx(Ng,{...x,children:o.jsxRuntimeExports.jsx(nc,{children:e})})})})})})})})})})})})}),$g=Object.freeze(Object.defineProperty({__proto__:null,Provider:Ig},Symbol.toStringTag,{value:"Module"})),zg=({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}%`}})}),Bg=Object.freeze(Object.defineProperty({__proto__:null,Progress:zg},Symbol.toStringTag,{value:"Module"})),dn="range",Jo=[{key:"name",name:"Name"}],ns=({items:e},t)=>{const n=j.filterByType(dn,e);return n.length>0&&!n.every(s=>t.includes(s.key))},Dg=({onChange:e,className:t,value:n,...s})=>{const r=Fe(),i=r!=null?void 0:o.jsxRuntimeExports.jsx(j.Text$3.Centered,{variant:"error",level:"h4",style:{height:150},children:"No client available"}),{startDrag:l,onDragEnd:c,...a}=j.useDragAndDrop({type:"Ranger.SelectMultiple",canDrop:g.useCallback(m=>ns(m,Z.A(n)),[n]),onDrop:g.useCallback(({items:m})=>{const f=j.filterByType(dn,m);if(f.length===0)return[];const h=Z.c.unique([...Z.A(n),...f.map(E=>E.key)]);return e(h,{clickedIndex:null,clicked:null,entries:[]}),f},[e,n])}),d=j.useDraggingState(),x=g.useCallback(({dropped:m})=>{e(Z.A(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:dn}],x),[l,x]);return o.jsxRuntimeExports.jsx(Wt,{className:u.CSS(t,u.CSS.dropRegion(ns(d,Z.A(n)))),value:n,onTagDragStart:p,onTagDragEnd:c,searcher:r==null?void 0:r.ranges,onChange:e,columns:Jo,emptyContent:i,entryRenderKey:"name",...a,...s})},oc=({value:e,onChange:t})=>{const n=Fe(),s=n!=null?void 0:o.jsxRuntimeExports.jsx(j.Text$3.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}=j.useDragAndDrop({type:"Ranger.SelectSingle",canDrop:g.useCallback(x=>ns(x,Z.o$1(e)),[e]),onDrop:g.useCallback(({items:x})=>{const p=j.filterByType(dn,x);return p.length===0?[]:(t(p[0].key,{clickedIndex:null,clicked:null,entries:[]}),p)},[i,t])}),a=j.useDraggingState(),d=g.useCallback(()=>e!=null&&l([{type:dn,key:e}]),[l,e]);return{emptyContent:s,dragging:a,...c,onDragStart:d,searcher:n==null?void 0:n.ranges}},Og=({onChange:e,value:t,className:n,data:s,...r})=>{const{dragging:i,...l}=oc({value:t,onChange:e});return o.jsxRuntimeExports.jsx(xt,{data:s,className:u.CSS(n,u.CSS.dropRegion(ns(i,Z.o$1(t)))),value:t,onChange:e,columns:Jo,entryRenderKey:"name",...l,...r})},Vg=({data:e,value:t,onChange:n,...s})=>{const{dragging:r,...i}=oc({value:t,onChange:n});return o.jsxRuntimeExports.jsx(xt,{data:e,value:t,onChange:n,columns:Jo,entryRenderKey:"name",...i,...s})},Fg=[{key:"color",name:"Color",width:50,render:e=>o.jsxRuntimeExports.jsx(j.Lt.Circle,{style:{fontSize:10,marginLeft:10,marginRight:30},color:e.entry.color})},{key:"name",name:"Name"}],Hg=e=>{const t=Fe();return o.jsxRuntimeExports.jsx(Wt,{...e,searcher:t==null?void 0:t.labels,columns:Fg,renderTag:n=>n.entry==null?o.jsxRuntimeExports.jsx(an,{color:"gray",children:n.entryKey}):o.jsxRuntimeExports.jsx(an,{color:n.entry.color,children:n.entry.name})})},Zg=({timeRange:e,level:t="p",shade:n=7,showSpan:s=!1,...r})=>{const i=new Z.m(e.start),l=i.isToday?"time":"dateTime",c=new Z.m(e.end),a=c.equals(Z.m.MAX),d=c.span(i)<Z.w.DAY?"time":"dateTime",x=i.span(c);return o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",size:"small",className:u.CSS(u.CSS.B("time-range-chip")),align:"center",...r,children:[i.isToday&&o.jsxRuntimeExports.jsx(j.Text$1,{level:t,shade:n,weight:450,children:"Today"}),o.jsxRuntimeExports.jsx(j.DateTime,{level:t,displayTZ:"local",format:l,shade:n,weight:450,children:i}),o.jsxRuntimeExports.jsx(j.Lt.Arrow.Right,{color:"var(--pluto-text-color)"}),a?o.jsxRuntimeExports.jsx(j.Text$1,{level:t,children:"Now"}):o.jsxRuntimeExports.jsx(j.DateTime,{level:t,displayTZ:"local",format:d,shade:n,weight:450,children:c}),!x.isZero&&s&&o.jsxRuntimeExports.jsxs(j.Text$1,{level:t,shade:n,weight:450,children:["(",i.span(c).truncate(Z.w.MILLISECOND).toString(),")"]})]})},Gg=Object.freeze(Object.defineProperty({__proto__:null,SelectButton:Vg,SelectLabels:Hg,SelectMultiple:Dg,SelectSingle:Og,TimeRangeChip:Zg},Symbol.toStringTag,{value:"Module"})),Yg=({steps:e,value:t,onChange:n,...s})=>{const r=e.findIndex(i=>i.key===t);return o.jsxRuntimeExports.jsx(te.Space,{direction:"x",align:"center",className:u.CSS.B("steps"),...s,children:e.map((i,l)=>o.jsxRuntimeExports.jsxs(g.Fragment,{children:[o.jsxRuntimeExports.jsxs(j.Button,{onClick:()=>n(i.key),variant:"outlined",disabled:l>r,children:[l+1,". ",i.title]},i.key),l!==e.length-1&&o.jsxRuntimeExports.jsx(j.Lt.Arrow.Right,{style:{fontSize:"15px",color:"var(--pluto-gray-l8)"}})]},i.key))})},Wg=Object.freeze(Object.defineProperty({__proto__:null,Steps:Yg},Symbol.toStringTag,{value:"Module"})),Kg=({children:e,className:t,visible:n,...s})=>{const[{path:r},,i]=j.use$3({type:B.Table.TYPE,schema:B.Table.stateZ,initialState:{region:u.Tt.ZERO,visible:n}});g.useEffect(()=>{i(c=>({...c,visible:n}))},[n]);const l=En(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(j.Composite,{path:r,children:e})})})]})},Xg=({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(ic,{onSelect:i,index:s,value:n,onChange:r,position:l,direction:"y"}),e]}),Qo=({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}),rc="ABCDEFGHIJKLMNOPQRSTUVWXYZ",qg=e=>rc[e],ic=({value:e,selected:t=!1,index:n,onChange:s,position:r,direction:i="x",onSelect:l})=>{const c=j.useSyncedRef(e),a=g.useRef(e),d=j.useCursorDrag({onStart:g.useCallback(()=>{a.current=c.current},[]),onMove:g.useCallback(x=>s(a.current+u.Tt.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),j.CONTEXT_TARGET,t&&j.CONTEXT_SELECTED),style:{[u.g.dimension(i)]:e},onClick:()=>l(n),onContextMenu:()=>l(n),children:[o.jsxRuntimeExports.jsx(j.Text$1,{level:"p",shade:7,style:{width:"100%",textAlign:"center"},children:i==="x"?rc[n]:n+1}),o.jsxRuntimeExports.jsx("button",{onClick:x=>x.stopPropagation(),style:{[u.g.location(i)]:r+e},onDragStart:d,draggable:!0})]})},Ug=({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(ic,{onSelect:t,position:c,selected:e.includes(l),index:l,value:i,onChange:a=>s(a,l),direction:"x"},l)})]})},Jg=Object.freeze(Object.defineProperty({__proto__:null,Cell:Qo,ColumnIndicators:Ug,Row:Xg,Table:Kg,getCellColumn:qg},Symbol.toStringTag,{value:"Module"})),Qg=[{key:"standard",name:"Standard"},{key:"scientific",name:"Scientific"},{key:"engineering",name:"Engineering"}],e1=({...e})=>o.jsxRuntimeExports.jsx(ve.Button,{...e,entryRenderKey:"name",data:Qg}),lc=[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],er=({path:e})=>{var f;const{value:t,onChange:n}=pt({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 E=B.sourcePipeline("string",{connections:lc,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:E})},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=ps(r.channel);return g.useEffect(()=>n({...t,tooltip:[m]}),[m]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(Te.Item,{label:"Input Channel",grow:!0,children:o.jsxRuntimeExports.jsx(Ct,{value:r.channel,onChange:a})}),o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",children:[o.jsxRuntimeExports.jsx(Te.Item,{label:"Notation",children:o.jsxRuntimeExports.jsx(e1,{value:i.notation,onChange:d})}),o.jsxRuntimeExports.jsx(Te.Item,{label:"Precision",align:"start",children:o.jsxRuntimeExports.jsx(j.Numeric,{value:i.precision??2,bounds:{lower:0,upper:10},onChange:x})}),o.jsxRuntimeExports.jsx(Te.Item,{label:"Averaging Window",align:"start",children:o.jsxRuntimeExports.jsx(j.Numeric,{value:l.windowSize??1,bounds:{lower:1,upper:100},onChange:p})})]})]})},t1=B.Value.z.partial({color:!0}).extend({level:Z.levelZ.optional()}),tr=({aetherKey:e,box:t,telem:n,color:s,precision:r,minWidth:i,level:l="small",backgroundTelem:c,notation:a,location:d})=>{const x=j.useMemoDeepEqualProps({box:t,telem:n,color:s,precision:r,level:l,minWidth:i,notation:a,backgroundTelem:c,location:d}),[,p,m]=j.use$3({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}},n1=Object.freeze(Object.defineProperty({__proto__:null,TelemForm:er,VALUE_CONNECTIONS:lc,corePropsZ:t1,use:tr},Symbol.toStringTag,{value:"Module"})),s1=ce.z.object({value:ce.z.string(),level:Z.levelZ,weight:Z.weightZ,align:u.K.x.or(u.K.center),backgroundColor:u.crudeZ}),o1=({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(Qo,{id:e,className:u.CSS(j.CONTEXT_TARGET,s&&j.CONTEXT_SELECTED,u.CSS.BEM("table","cell","text")),selected:s,onClick:d,onContextMenu:d,style:{backgroundColor:u.cssString(a)},children:o.jsxRuntimeExports.jsx(j.Editable,{level:l,value:n,weight:c,onChange:x,style:{justifyContent:i},allowEmpty:!0,outline:!1})})},r1=ce.z.object({telem:B.stringSourceSpecZ,redline:ce.z.object({bounds:u.H.bounds,gradient:u.gradientZ}),level:Z.levelZ,color:ce.z.string(),units:ce.z.string()}),i1=({cellKey:e,telem:t,level:n,color:s,redline:{gradient:r,bounds:i},selected:l,box:c,onSelect:a})=>{const{width:d}=tr({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.b.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(Qo,{id:e,selected:l,onClick:x,onContextMenu:x,style:{height:"5rem",width:d},className:u.CSS(j.CONTEXT_TARGET,l&&j.CONTEXT_SELECTED,u.CSS.BEM("table","cell","value"))})},l1=({onVariantChange:e})=>{const t=g.useCallback(({tabKey:s})=>{switch(s){case"telem":return o.jsxRuntimeExports.jsx(te.Space,{direction:"y",style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(er,{path:""})});case"redline":return o.jsxRuntimeExports.jsx(te.Space,{direction:"y",style:{padding:"2rem"},children:o.jsxRuntimeExports.jsx(c1,{})});default:return o.jsxRuntimeExports.jsx(te.Space,{direction:"y",grow:!0,empty:!0,style:{padding:"2rem"},children:o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",children:[o.jsxRuntimeExports.jsx(Te.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(cc,{onChange:e,value:"value"})}),o.jsxRuntimeExports.jsx(ye,{hideIfNull:!0,label:"Color",align:"start",padHelpText:!1,path:"color",children:({value:r,onChange:i,variant:l,...c})=>o.jsxRuntimeExports.jsx(j.Swatch,{value:r??u.ZERO.setAlpha(1).rgba255,onChange:a=>i(a.rgba255),...c,bordered:!0})}),o.jsxRuntimeExports.jsx(ye,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:r=>o.jsxRuntimeExports.jsx(ve.SelectLevel,{...r})})]})})}},[]),n=ke.useStatic({tabs:[{tabKey:"style",name:"Style"},{tabKey:"telem",name:"Telemetry"},{tabKey:"redline",name:"Redline"}],content:t});return o.jsxRuntimeExports.jsx(ke.Tabs,{...n})},c1=()=>{const{set:e,get:t}=tt(),n=Il("redline.bounds"),s=u.b.Scale.scale(0,1).scale(n);return o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",grow:!0,children:[o.jsxRuntimeExports.jsx(zt,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Lower",path:"redline.bounds.lower"}),o.jsxRuntimeExports.jsx(ye,{path:"redline.gradient",label:"Gradient",align:"start",padHelpText:!1,children:({value:r,onChange:i})=>o.jsxRuntimeExports.jsx(j.GradientPicker,{value:Z._.copy(r),scale:s,onChange:l=>{const a={...t("redline.bounds").value},d=l.map(E=>E.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(E=>({...E,color:new u.Color(E.color).hex}));m||f?e("redline",{bounds:a,gradient:h}):i(l.map(E=>({...E,color:new u.Color(E.color).hex})))}})}),o.jsxRuntimeExports.jsx(zt,{inputProps:{size:"small",showDragHandle:!1},style:{width:60},label:"Upper",path:"redline.bounds.upper"})]})},a1=({onVariantChange:e})=>o.jsxRuntimeExports.jsxs(te.Space,{direction:"x",grow:!0,style:{padding:"2rem"},children:[o.jsxRuntimeExports.jsx(Te.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(cc,{onChange:e,value:"text"})}),o.jsxRuntimeExports.jsx(Wo,{path:"value",label:"Text"}),o.jsxRuntimeExports.jsx(ye,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(ve.SelectLevel,{...t})}),o.jsxRuntimeExports.jsx(ye,{path:"weight",label:"Weight",padHelpText:!1,children:t=>o.jsxRuntimeExports.jsx(ve.SelectWeight,{...t})}),o.jsxRuntimeExports.jsx(ye,{path:"align",label:"Alignment",hideIfNull:!0,children:t=>o.jsxRuntimeExports.jsx(ms,{...t})}),o.jsxRuntimeExports.jsx(ye,{path:"backgroundColor",label:"Background",align:"start",padHelpText:!1,children:({value:t,onChange:n})=>o.jsxRuntimeExports.jsx(j.Swatch,{value:t,onChange:n})})]}),u1=[{key:"text",name:"Text"},{key:"value",name:"Value"}],cc=({onChange:e,value:t})=>o.jsxRuntimeExports.jsx(ve.Button,{value:t,onChange:e,data:u1,allowMultiple:!1,entryRenderKey:"name"}),d1=["text","value"],x1=ce.z.enum(d1),p1={key:"value",name:"Value",Form:l1,Cell:i1,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:e.colors.gray.l8.hex,level:"h5",units:""}),schema:r1},m1={key:"text",name:"Text",Form:a1,Cell:o1,defaultProps:()=>({value:"",level:"h5",units:"",weight:400,align:"center",backgroundColor:"#00000000"}),schema:s1},f1={text:m1,value:p1},h1=Object.freeze(Object.defineProperty({__proto__:null,CELLS:f1,variantZ:x1},Symbol.toStringTag,{value:"Module"})),Fr=({sourcePos:e,targetPos:t,next:n,prev:s})=>{const r=jt(e,...n);return u.G.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)},Hr=({sourceStumpTip:e,sourceOrientation:t,sourceBox:n,targetStumpTip:s,targetOrientation:r,targetBox:i})=>{if(!g1({sourcePos:e,sourceOrientation:t,targetPos:s}))return;const l=u.g.construct(t),c=u.g.swap(l);let a=St(c,s[c]-e[c]);const d=u.Tt.loc(n,a);if(u.K.swap(t)===r){const x=u.Tt.loc(i,u.K.swap(a));Math.abs(d-x)<Ae&&(a=u.K.swap(a))}return{direction:c,length:d-e[c]+wt(a,Ae)}},xo=ce.z.object({direction:u.g.direction,length:ce.z.number()}),jt=(e,...t)=>{let n=e;for(const s of t)n=u.G.translate(n,s.direction,s.length);return n},ac=(e,t,n,s)=>{try{let r=e;const i=[e,...t.map(f=>(r=u.G.translate(r,f.direction,f.length),r))];if(!s)return i;const l=t[0],c=St(l.direction,l.length),a=Zr(c),d=4*(2-n**.5);i[0]=u.G.translate(i[0],{[l.direction]:-1*a*d,[u.g.swap(l.direction)]:0});const x=t[t.length-1],p=St(x.direction,x.length),m=Zr(p);return i[i.length-1]=u.G.translate(i[i.length-1],{[x.direction]:m*d,[u.g.swap(x.direction)]:0}),i}catch{return[]}},Ae=10,Zr=e=>e==="top"||e==="left"?-1:1,wt=(e,t)=>e==="top"||e==="left"?-t:t,St=(e,t)=>e==="x"?t>0?"right":"left":t>0?"bottom":"top",ct=e=>St(e.direction,e.length),g1=({sourcePos:e,targetPos:t,sourceOrientation:n})=>{const s=u.g.construct(n),r=t[s]-e[s];return wt(n,r)<0},_n=e=>({direction:u.g.construct(e),length:wt(e,Ae)}),Gr={top:_n("top"),bottom:_n("bottom"),left:_n("left"),right:_n("right")},j1=4,E1=.25,js=e=>po(y1(po(e))),y1=e=>{const t=[...e],n=e.findIndex((s,r)=>{const i=Math.abs(s.length);if(i<j1){if(r===0||r===e.length-1)return!1;if(i<E1)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},po=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=ct(i),d=ct(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)===Ae)return!1;const x=wt(a,Ae),p=t[l].length-x,m=t[c].length+p;return Math.abs(m)<Ae?!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=ct(s),d=ct(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)===Ae)return!1;const x=wt(a,Ae),p=t[l].length-x,m=t[c].length+p;return Math.abs(m)<Ae?!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?po(t):t},Nt=e=>js(S1(e)),S1=({sourceBox:e,targetBox:t,sourcePos:n,targetPos:s,targetOrientation:r,sourceOrientation:i})=>{let l=i,c=r,a={...Gr[i]},d=jt(n,a);const x={...Gr[r]};let p=jt(s,x);const m=Math.abs(d.x-p.x),f=Math.abs(d.y-p.y);m<2*Ae&&f<10&&(a.length-=m/2,x.length+=m/2,d=jt(n,a),p=jt(s,x));const h=[a],E=Hr({sourceStumpTip:d,sourceOrientation:i,sourceBox:e,targetStumpTip:p,targetOrientation:r,targetBox:t});E!=null&&(h.push(E),d=jt(d,E),l=ct(E),a=E);const y=Hr({sourceStumpTip:p,sourceOrientation:c,sourceBox:t,targetStumpTip:d,targetOrientation:l,targetBox:e});y!=null&&(p=jt(p,y),c=St(y.direction,y.length));const S=()=>{y!=null&&(y.length*=-1,h.push(y)),x.length*=-1,h.push(x)};if(u.K.swap(l)===r){const _=u.g.construct(l),N=(p[_]-d[_])/2;h.push({direction:_,length:N});const A=u.g.swap(_);return h.push({direction:A,length:p[A]-d[A]}),h.push({direction:_,length:N}),S(),h}const k=p[a.direction]-d[a.direction];let C=u.g.swap(a.direction);const b=d[C]-p[C];let w;St(a.direction,k)===l&&St(C,b)===c?w={direction:a.direction,length:k}:(w={direction:C,length:p[C]-d[C]},C=u.g.swap(C)),h.push(w);const L={direction:C,length:p[C]-d[C]};return h.push(L),S(),h},R1=e=>js(C1(e)),C1=({segments:e,index:t,magnitude:n})=>{const s=[...e],r=s[t],i=u.g.swap(r.direction),l=ct(r);if(t===0){s.unshift({direction:i,length:n});const c=wt(l,Ae);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=wt(l,Ae);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},b1=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n],n))return n;return-1},w1=(e,t,n=!1,...s)=>{const r=(i,l)=>!s.includes(l)&&t(i,l);return n?b1(e,r):e.findIndex(r)},v1=({delta:e,segments:t})=>js(uc(e,t,!1)),k1=({delta:e,segments:t})=>js(uc(e,t,!0)),uc=(e,t,n)=>{let s=[...t];return e.x!==0&&(s=Wr("x",e,s,n)),e.y!==0&&(s=Wr("y",e,s,n)),s},Yr=(e,t,n)=>{if(t.direction!==e)return!1;const s={...t,length:t.length-n[e]},r=ct(t),i=ct(s),l=Math.abs(s.length),c=Math.abs(t.length);return(l>c||l>Ae)&&r===i},Wr=(e,t,n,s)=>{const r=u.g.swap(e),i=s?n.length-1:0,l=n[i];if(Yr(e,l,t)){const p=n[n.length-1];return p.direction===e&&Math.abs(l.length)<Ae?(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=w1(n,p=>p.direction===e,s,i);if(d===c){const p=n[c];return Yr(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},_1=ce.z.object({position:u.G.xy,zoom:ce.z.number()}),dc=ce.z.object({color:u.crudeZ,variant:ce.z.string().optional(),segments:ce.z.array(xo)}),M1=dc.extend({key:ce.z.string(),source:ce.z.string(),target:ce.z.string(),segments:ce.z.array(xo),color:u.crudeZ,id:ce.z.string(),data:ce.z.object({segments:ce.z.array(xo),color:u.crudeZ,variant:ce.z.string().optional()}).optional(),selected:ce.z.boolean(),sourceHandle:ce.z.string().nullable().optional(),targetHandle:ce.z.string().nullable().optional()}),L1=ce.z.object({key:ce.z.string(),position:u.G.xy,selected:ce.z.boolean().optional(),zIndex:ce.z.number().optional(),type:ce.z.string().optional(),data:ce.z.record(ce.z.unknown()).optional(),measured:ce.z.object({width:ce.z.number().optional(),height:ce.z.number().optional()}).optional()}),nr=e=>e.map(t=>({id:t.key,type:"custom",zIndex:t.zIndex,measured:{...t.measured},position:{...t.position},selected:t.selected,data:{}})),sr=e=>e.map(({segments:t,color:n,variant:s,...r})=>({...r,id:r.key,data:{segments:t,color:n,variant:s}})),xc=e=>e.map(t=>({key:t.id,...t})),pc=(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}}),mc=e=>({...e.position,zoom:e.zoom}),fc=e=>({position:u.G.construct(e),zoom:e.zoom}),hc=(e,t)=>xc(t(nr(e))),Vn=(e,t,n)=>pc(t(sr(e)),n),P1=(e,t="x")=>{if(e.length===0)return[];const n=u.K.construct(t),s=u.K.swap(n);return e.sort((r,i)=>u.Tt.loc(r.box,n)-u.Tt.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.G.set(u.G.translation(x,d),t,0),m=u.G.translate(u.Tt.topLeft(r.box),p);r.box=u.Tt.construct(m,u.Tt.dims(r.box))}),e};function Me(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=Me(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var T1={value:()=>{}};function Es(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new Fn(n)}function Fn(e){this._=e}function N1(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}})}Fn.prototype=Es.prototype={constructor:Fn,on:function(e,t){var n=this._,s=N1(e+"",n),r,i=-1,l=s.length;if(arguments.length<2){for(;++i<l;)if((r=(e=s[i]).type)&&(r=A1(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]=Kr(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Kr(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 Fn(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 A1(e,t){for(var n=0,s=e.length,r;n<s;++n)if((r=e[n]).name===t)return r.value}function Kr(e,t,n){for(var s=0,r=e.length;s<r;++s)if(e[s].name===t){e[s]=T1,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var mo="http://www.w3.org/1999/xhtml";const Xr={svg:"http://www.w3.org/2000/svg",xhtml:mo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ys(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Xr.hasOwnProperty(t)?{space:Xr[t],local:e}:e}function I1(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===mo&&t.documentElement.namespaceURI===mo?t.createElement(e):t.createElementNS(n,e)}}function $1(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function gc(e){var t=ys(e);return(t.local?$1:I1)(t)}function z1(){}function or(e){return e==null?z1:function(){return this.querySelector(e)}}function B1(e){typeof e!="function"&&(e=or(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 ze(s,this._parents)}function D1(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function O1(){return[]}function jc(e){return e==null?O1:function(){return this.querySelectorAll(e)}}function V1(e){return function(){return D1(e.apply(this,arguments))}}function F1(e){typeof e=="function"?e=V1(e):e=jc(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 ze(s,r)}function Ec(e){return function(){return this.matches(e)}}function yc(e){return function(t){return t.matches(e)}}var H1=Array.prototype.find;function Z1(e){return function(){return H1.call(this.children,e)}}function G1(){return this.firstElementChild}function Y1(e){return this.select(e==null?G1:Z1(typeof e=="function"?e:yc(e)))}var W1=Array.prototype.filter;function K1(){return Array.from(this.children)}function X1(e){return function(){return W1.call(this.children,e)}}function q1(e){return this.selectAll(e==null?K1:X1(typeof e=="function"?e:yc(e)))}function U1(e){typeof e!="function"&&(e=Ec(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 ze(s,this._parents)}function Sc(e){return new Array(e.length)}function J1(){return new ze(this._enter||this._groups.map(Sc),this._parents)}function ss(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ss.prototype={constructor:ss,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 Q1(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 ss(e,i[l]);for(;l<a;++l)(c=t[l])&&(r[l]=c)}function tj(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 ss(e,i[c]);for(c=0;c<x;++c)(a=t[c])&&d.get(m[c])===a&&(r[c]=a)}function nj(e){return e.__data__}function sj(e,t){if(!arguments.length)return Array.from(this,nj);var n=t?tj:ej,s=this._parents,r=this._groups;typeof e!="function"&&(e=Q1(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=oj(e.call(x,x&&x.__data__,d,s)),h=f.length,E=c[d]=new Array(h),y=l[d]=new Array(h),S=a[d]=new Array(m);n(x,p,E,y,S,f,t);for(var k=0,C=0,b,w;k<h;++k)if(b=E[k]){for(k>=C&&(C=k+1);!(w=y[C])&&++C<h;);b._next=w||null}}return l=new ze(l,s),l._enter=c,l._exit=a,l}function oj(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function rj(){return new ze(this._exit||this._groups.map(Sc),this._parents)}function ij(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 lj(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 ze(c,this._parents)}function cj(){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 aj(e){e||(e=uj);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 ze(r,this._parents).order()}function uj(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function dj(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function xj(){return Array.from(this)}function pj(){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 mj(){let e=0;for(const t of this)++e;return e}function fj(){return!this.node()}function hj(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 gj(e){return function(){this.removeAttribute(e)}}function jj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ej(e,t){return function(){this.setAttribute(e,t)}}function yj(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Sj(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Rj(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 Cj(e,t){var n=ys(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?jj:gj:typeof t=="function"?n.local?Rj:Sj:n.local?yj:Ej)(n,t))}function Rc(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function bj(e){return function(){this.style.removeProperty(e)}}function wj(e,t,n){return function(){this.style.setProperty(e,t,n)}}function vj(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function kj(e,t,n){return arguments.length>1?this.each((t==null?bj:typeof t=="function"?vj:wj)(e,t,n??"")):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||Rc(e).getComputedStyle(e,null).getPropertyValue(t)}function _j(e){return function(){delete this[e]}}function Mj(e,t){return function(){this[e]=t}}function Lj(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Pj(e,t){return arguments.length>1?this.each((t==null?_j:typeof t=="function"?Lj:Mj)(e,t)):this.node()[e]}function Cc(e){return e.trim().split(/^|\s+/)}function rr(e){return e.classList||new bc(e)}function bc(e){this._node=e,this._names=Cc(e.getAttribute("class")||"")}bc.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 wc(e,t){for(var n=rr(e),s=-1,r=t.length;++s<r;)n.add(t[s])}function vc(e,t){for(var n=rr(e),s=-1,r=t.length;++s<r;)n.remove(t[s])}function Tj(e){return function(){wc(this,e)}}function Nj(e){return function(){vc(this,e)}}function Aj(e,t){return function(){(t.apply(this,arguments)?wc:vc)(this,e)}}function Ij(e,t){var n=Cc(e+"");if(arguments.length<2){for(var s=rr(this.node()),r=-1,i=n.length;++r<i;)if(!s.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Aj:t?Tj:Nj)(n,t))}function $j(){this.textContent=""}function zj(e){return function(){this.textContent=e}}function Bj(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Dj(e){return arguments.length?this.each(e==null?$j:(typeof e=="function"?Bj:zj)(e)):this.node().textContent}function Oj(){this.innerHTML=""}function Vj(e){return function(){this.innerHTML=e}}function Fj(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Hj(e){return arguments.length?this.each(e==null?Oj:(typeof e=="function"?Fj:Vj)(e)):this.node().innerHTML}function Zj(){this.nextSibling&&this.parentNode.appendChild(this)}function Gj(){return this.each(Zj)}function Yj(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Wj(){return this.each(Yj)}function Kj(e){var t=typeof e=="function"?e:gc(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Xj(){return null}function qj(e,t){var n=typeof e=="function"?e:gc(e),s=t==null?Xj:typeof t=="function"?t:or(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function Uj(){var e=this.parentNode;e&&e.removeChild(this)}function Jj(){return this.each(Uj)}function Qj(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function e0(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function t0(e){return this.select(e?e0:Qj)}function n0(e){return arguments.length?this.property("__data__",e):this.node().__data__}function s0(e){return function(t){e.call(this,t,this.__data__)}}function o0(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 r0(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 i0(e,t,n){return function(){var s=this.__on,r,i=s0(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 l0(e,t,n){var s=o0(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?i0:r0,r=0;r<i;++r)this.each(c(s[r],t,n));return this}function kc(e,t,n){var s=Rc(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 c0(e,t){return function(){return kc(this,e,t)}}function a0(e,t){return function(){return kc(this,e,t.apply(this,arguments))}}function u0(e,t){return this.each((typeof t=="function"?a0:c0)(e,t))}function*d0(){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 _c=[null];function ze(e,t){this._groups=e,this._parents=t}function Sn(){return new ze([[document.documentElement]],_c)}function x0(){return this}ze.prototype=Sn.prototype={constructor:ze,select:B1,selectAll:F1,selectChild:Y1,selectChildren:q1,filter:U1,data:sj,enter:J1,exit:rj,join:ij,merge:lj,selection:x0,order:cj,sort:aj,call:dj,nodes:xj,node:pj,size:mj,empty:fj,each:hj,attr:Cj,style:kj,property:Pj,classed:Ij,text:Dj,html:Hj,raise:Gj,lower:Wj,append:Kj,insert:qj,remove:Jj,clone:t0,datum:n0,on:l0,dispatch:u0,[Symbol.iterator]:d0};function $e(e){return typeof e=="string"?new ze([[document.querySelector(e)]],[document.documentElement]):new ze([[e]],_c)}function p0(e){let t;for(;t=e.sourceEvent;)e=t;return e}function De(e,t){if(e=p0(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 m0={passive:!1},xn={capture:!0,passive:!1};function Ws(e){e.stopImmediatePropagation()}function $t(e){e.preventDefault(),e.stopImmediatePropagation()}function Mc(e){var t=e.document.documentElement,n=$e(e).on("dragstart.drag",$t,xn);"onselectstart"in t?n.on("selectstart.drag",$t,xn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Lc(e,t){var n=e.document.documentElement,s=$e(e).on("dragstart.drag",null);t&&(s.on("click.drag",$t,xn),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 Mn=e=>()=>e;function fo(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}})}fo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function f0(e){return!e.ctrlKey&&!e.button}function h0(){return this.parentNode}function g0(e,t){return t??{x:e.x,y:e.y}}function j0(){return navigator.maxTouchPoints||"ontouchstart"in this}function Pc(){var e=f0,t=h0,n=g0,s=j0,r={},i=Es("start","drag","end"),l=0,c,a,d,x,p=0;function m(b){b.on("mousedown.drag",f).filter(s).on("touchstart.drag",y).on("touchmove.drag",S,m0).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(b,w){if(!(x||!e.call(this,b,w))){var L=C(this,t.call(this,b,w),b,w,"mouse");L&&($e(b.view).on("mousemove.drag",h,xn).on("mouseup.drag",E,xn),Mc(b.view),Ws(b),d=!1,c=b.clientX,a=b.clientY,L("start",b))}}function h(b){if($t(b),!d){var w=b.clientX-c,L=b.clientY-a;d=w*w+L*L>p}r.mouse("drag",b)}function E(b){$e(b.view).on("mousemove.drag mouseup.drag",null),Lc(b.view,d),$t(b),r.mouse("end",b)}function y(b,w){if(e.call(this,b,w)){var L=b.changedTouches,_=t.call(this,b,w),N=L.length,A,I;for(A=0;A<N;++A)(I=C(this,_,b,w,L[A].identifier,L[A]))&&(Ws(b),I("start",b,L[A]))}}function S(b){var w=b.changedTouches,L=w.length,_,N;for(_=0;_<L;++_)(N=r[w[_].identifier])&&($t(b),N("drag",b,w[_]))}function k(b){var w=b.changedTouches,L=w.length,_,N;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),_=0;_<L;++_)(N=r[w[_].identifier])&&(Ws(b),N("end",b,w[_]))}function C(b,w,L,_,N,A){var I=i.copy(),F=De(A||L,w),$,z,R;if((R=n.call(b,new fo("beforestart",{sourceEvent:L,target:m,identifier:N,active:l,x:F[0],y:F[1],dx:0,dy:0,dispatch:I}),_))!=null)return $=R.x-F[0]||0,z=R.y-F[1]||0,function T(M,D,P){var V=F,H;switch(M){case"start":r[N]=T,H=l++;break;case"end":delete r[N],--l;case"drag":F=De(P||D,w),H=l;break}I.call(M,b,new fo(M,{sourceEvent:D,subject:R,target:m,identifier:N,active:H,x:F[0]+$,y:F[1]+z,dx:F[0]-V[0],dy:F[1]-V[1],dispatch:I}),_)}}return m.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Mn(!!b),m):e},m.container=function(b){return arguments.length?(t=typeof b=="function"?b:Mn(b),m):t},m.subject=function(b){return arguments.length?(n=typeof b=="function"?b:Mn(b),m):n},m.touchable=function(b){return arguments.length?(s=typeof b=="function"?b:Mn(!!b),m):s},m.on=function(){var b=i.on.apply(i,arguments);return b===i?m:b},m.clickDistance=function(b){return arguments.length?(p=(b=+b)*b,m):Math.sqrt(p)},m}var Ot=0,nn=0,en=0,Tc=1e3,os,sn,rs=0,vt=0,Ss=0,pn=typeof performance=="object"&&performance.now?performance:Date,Nc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ir(){return vt||(Nc(E0),vt=pn.now()+Ss)}function E0(){vt=0}function is(){this._call=this._time=this._next=null}is.prototype=Ac.prototype={constructor:is,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ir():+n)+(t==null?0:+t),!this._next&&sn!==this&&(sn?sn._next=this:os=this,sn=this),this._call=e,this._time=n,ho()},stop:function(){this._call&&(this._call=null,this._time=1/0,ho())}};function Ac(e,t,n){var s=new is;return s.restart(e,t,n),s}function y0(){ir(),++Ot;for(var e=os,t;e;)(t=vt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ot}function qr(){vt=(rs=pn.now())+Ss,Ot=nn=0;try{y0()}finally{Ot=0,R0(),vt=0}}function S0(){var e=pn.now(),t=e-rs;t>Tc&&(Ss-=t,rs=e)}function R0(){for(var e,t=os,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:os=n);sn=e,ho(s)}function ho(e){if(!Ot){nn&&(nn=clearTimeout(nn));var t=e-vt;t>24?(e<1/0&&(nn=setTimeout(qr,e-pn.now()-Ss)),en&&(en=clearInterval(en))):(en||(rs=pn.now(),en=setInterval(S0,Tc)),Ot=1,Nc(qr))}}function Ur(e,t,n){var s=new is;return t=t==null?0:+t,s.restart(r=>{s.stop(),e(r+t)},t,n),s}var C0=Es("start","end","cancel","interrupt"),b0=[],Ic=0,Jr=1,go=2,Hn=3,Qr=4,jo=5,Zn=6;function Rs(e,t,n,s,r,i){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;w0(e,n,{name:t,index:s,group:r,on:C0,tween:b0,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ic})}function lr(e,t){var n=He(e,t);if(n.state>Ic)throw new Error("too late; already scheduled");return n}function Xe(e,t){var n=He(e,t);if(n.state>Hn)throw new Error("too late; already running");return n}function He(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function w0(e,t,n){var s=e.__transition,r;s[t]=n,n.timer=Ac(i,0,n.time);function i(d){n.state=Jr,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!==Jr)return a();for(x in s)if(f=s[x],f.name===n.name){if(f.state===Hn)return Ur(l);f.state===Qr?(f.state=Zn,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete s[x]):+x<t&&(f.state=Zn,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete s[x])}if(Ur(function(){n.state===Hn&&(n.state=Qr,n.timer.restart(c,n.delay,n.time),c(d))}),n.state=go,n.on.call("start",e,e.__data__,n.index,n.group),n.state===go){for(n.state=Hn,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=jo,1),p=-1,m=r.length;++p<m;)r[p].call(e,x);n.state===jo&&(n.on.call("end",e,e.__data__,n.index,n.group),a())}function a(){n.state=Zn,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function Gn(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>go&&s.state<jo,s.state=Zn,s.timer.stop(),s.on.call(r?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[l]}i&&delete e.__transition}}function v0(e){return this.each(function(){Gn(this,e)})}function k0(e,t){var n,s;return function(){var r=Xe(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 _0(e,t,n){var s,r;if(typeof n!="function")throw new Error;return function(){var i=Xe(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 M0(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=He(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?k0:_0)(n,e,t))}function cr(e,t,n){var s=e._id;return e.each(function(){var r=Xe(this,s);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return He(r,s).value[t]}}function $c(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 L0(e){return function(){this.removeAttribute(e)}}function P0(e){return function(){this.removeAttributeNS(e.space,e.local)}}function T0(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 N0(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 A0(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 I0(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 $0(e,t){var n=ys(e),s=n==="transform"?yf:$c;return this.attrTween(e,typeof t=="function"?(n.local?I0:A0)(n,s,cr(this,"attr."+e,t)):t==null?(n.local?P0:L0)(n):(n.local?N0:T0)(n,s,t))}function z0(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function B0(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function D0(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&B0(e,i)),n}return r._value=t,r}function O0(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&z0(e,i)),n}return r._value=t,r}function V0(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=ys(e);return this.tween(n,(s.local?D0:O0)(s,t))}function F0(e,t){return function(){lr(this,e).delay=+t.apply(this,arguments)}}function H0(e,t){return t=+t,function(){lr(this,e).delay=t}}function Z0(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?F0:H0)(t,e)):He(this.node(),t).delay}function G0(e,t){return function(){Xe(this,e).duration=+t.apply(this,arguments)}}function Y0(e,t){return t=+t,function(){Xe(this,e).duration=t}}function W0(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?G0:Y0)(t,e)):He(this.node(),t).duration}function K0(e,t){if(typeof t!="function")throw new Error;return function(){Xe(this,e).ease=t}}function X0(e){var t=this._id;return arguments.length?this.each(K0(t,e)):He(this.node(),t).ease}function q0(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Xe(this,e).ease=n}}function U0(e){if(typeof e!="function")throw new Error;return this.each(q0(this._id,e))}function J0(e){typeof e!="function"&&(e=Ec(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 et(s,this._parents,this._name,this._id)}function Q0(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 et(l,this._parents,this._name,this._id)}function e2(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 t2(e,t,n){var s,r,i=e2(t)?lr:Xe;return function(){var l=i(this,e),c=l.on;c!==s&&(r=(s=c).copy()).on(t,n),l.on=r}}function n2(e,t){var n=this._id;return arguments.length<2?He(this.node(),n).on.on(e):this.each(t2(n,e,t))}function s2(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function o2(){return this.on("end.remove",s2(this._id))}function r2(e){var t=this._name,n=this._id;typeof e!="function"&&(e=or(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,Rs(d[m],t,n,m,d,He(x,n)));return new et(i,this._parents,t,n)}function i2(e){var t=this._name,n=this._id;typeof e!="function"&&(e=jc(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=He(x,n),E=0,y=m.length;E<y;++E)(f=m[E])&&Rs(f,t,n,E,m,h);i.push(m),l.push(x)}return new et(i,l,t,n)}var l2=Sn.prototype.constructor;function c2(){return new l2(this._groups,this._parents)}function a2(e,t){var n,s,r;return function(){var i=Dt(this,e),l=(this.style.removeProperty(e),Dt(this,e));return i===l?null:i===n&&l===s?r:r=t(n=i,s=l)}}function zc(e){return function(){this.style.removeProperty(e)}}function u2(e,t,n){var s,r=n+"",i;return function(){var l=Dt(this,e);return l===r?null:l===s?i:i=t(s=l,n)}}function d2(e,t,n){var s,r,i;return function(){var l=Dt(this,e),c=n(this),a=c+"";return c==null&&(a=c=(this.style.removeProperty(e),Dt(this,e))),l===a?null:l===s&&a===r?i:(r=a,i=t(s=l,c))}}function x2(e,t){var n,s,r,i="style."+t,l="end."+i,c;return function(){var a=Xe(this,e),d=a.on,x=a.value[i]==null?c||(c=zc(t)):void 0;(d!==n||r!==x)&&(s=(n=d).copy()).on(l,r=x),a.on=s}}function p2(e,t,n){var s=(e+="")=="transform"?Ef:$c;return t==null?this.styleTween(e,a2(e,s)).on("end.style."+e,zc(e)):typeof t=="function"?this.styleTween(e,d2(e,s,cr(this,"style."+e,t))).each(x2(this._id,e)):this.styleTween(e,u2(e,s,t),n).on("end.style."+e,null)}function m2(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function f2(e,t,n){var s,r;function i(){var l=t.apply(this,arguments);return l!==r&&(s=(r=l)&&m2(e,l,n)),s}return i._value=t,i}function h2(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,f2(e,t,n??""))}function g2(e){return function(){this.textContent=e}}function j2(e){return function(){var t=e(this);this.textContent=t??""}}function E2(e){return this.tween("text",typeof e=="function"?j2(cr(this,"text",e)):g2(e==null?"":e+""))}function y2(e){return function(t){this.textContent=e.call(this,t)}}function S2(e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&y2(r)),t}return s._value=e,s}function R2(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,S2(e))}function C2(){for(var e=this._name,t=this._id,n=Bc(),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=He(a,t);Rs(a,e,n,d,l,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new et(s,this._parents,e,n)}function b2(){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=Xe(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 w2=0;function et(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Bc(){return++w2}var Ue=Sn.prototype;et.prototype={constructor:et,select:r2,selectAll:i2,selectChild:Ue.selectChild,selectChildren:Ue.selectChildren,filter:J0,merge:Q0,selection:c2,transition:C2,call:Ue.call,nodes:Ue.nodes,node:Ue.node,size:Ue.size,empty:Ue.empty,each:Ue.each,on:n2,attr:$0,attrTween:V0,style:p2,styleTween:h2,text:E2,textTween:R2,remove:o2,tween:M0,delay:Z0,duration:W0,ease:X0,easeVarying:U0,end:b2,[Symbol.iterator]:Ue[Symbol.iterator]};function v2(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var k2={time:null,delay:0,duration:250,ease:v2};function _2(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 M2(e){var t,n;e instanceof et?(t=e._id,e=e._name):(t=Bc(),(n=k2).time=ir(),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])&&Rs(a,e,t,d,l,n||_2(a,t));return new et(s,this._parents,e,t)}Sn.prototype.interrupt=v0;Sn.prototype.transition=M2;const Ln=e=>()=>e;function L2(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 Je(e,t,n){this.k=e,this.x=t,this.y=n}Je.prototype={constructor:Je,scale:function(e){return e===1?this:new Je(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Je(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 Cs=new Je(1,0,0);Dc.prototype=Je.prototype;function Dc(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Cs;return e.__zoom}function Ks(e){e.stopImmediatePropagation()}function tn(e){e.preventDefault(),e.stopImmediatePropagation()}function P2(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function T2(){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 ei(){return this.__zoom||Cs}function N2(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function A2(){return navigator.maxTouchPoints||"ontouchstart"in this}function I2(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 Oc(){var e=P2,t=T2,n=I2,s=N2,r=A2,i=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,a=bf,d=Es("start","zoom","end"),x,p,m,f=500,h=150,E=0,y=10;function S(R){R.property("__zoom",ei).on("wheel.zoom",N,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",I).filter(r).on("touchstart.zoom",F).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(R,T,M,D){var P=R.selection?R.selection():R;P.property("__zoom",ei),R!==P?w(R,T,M,D):P.interrupt().each(function(){L(this,arguments).event(D).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},S.scaleBy=function(R,T,M,D){S.scaleTo(R,function(){var P=this.__zoom.k,V=typeof T=="function"?T.apply(this,arguments):T;return P*V},M,D)},S.scaleTo=function(R,T,M,D){S.transform(R,function(){var P=t.apply(this,arguments),V=this.__zoom,H=M==null?b(P):typeof M=="function"?M.apply(this,arguments):M,G=V.invert(H),q=typeof T=="function"?T.apply(this,arguments):T;return n(C(k(V,q),H,G),P,l)},M,D)},S.translateBy=function(R,T,M,D){S.transform(R,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),l)},null,D)},S.translateTo=function(R,T,M,D,P){S.transform(R,function(){var V=t.apply(this,arguments),H=this.__zoom,G=D==null?b(V):typeof D=="function"?D.apply(this,arguments):D;return n(Cs.translate(G[0],G[1]).scale(H.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof M=="function"?-M.apply(this,arguments):-M),V,l)},D,P)};function k(R,T){return T=Math.max(i[0],Math.min(i[1],T)),T===R.k?R:new Je(T,R.x,R.y)}function C(R,T,M){var D=T[0]-M[0]*R.k,P=T[1]-M[1]*R.k;return D===R.x&&P===R.y?R:new Je(R.k,D,P)}function b(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function w(R,T,M,D){R.on("start.zoom",function(){L(this,arguments).event(D).start()}).on("interrupt.zoom end.zoom",function(){L(this,arguments).event(D).end()}).tween("zoom",function(){var P=this,V=arguments,H=L(P,V).event(D),G=t.apply(P,V),q=M==null?b(G):typeof M=="function"?M.apply(P,V):M,oe=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),ee=P.__zoom,ne=typeof T=="function"?T.apply(P,V):T,se=a(ee.invert(q).concat(oe/ee.k),ne.invert(q).concat(oe/ne.k));return function(ie){if(ie===1)ie=ne;else{var U=se(ie),ue=oe/U[2];ie=new Je(ue,q[0]-U[0]*ue,q[1]-U[1]*ue)}H.zoom(null,ie)}})}function L(R,T,M){return!M&&R.__zooming||new _(R,T)}function _(R,T){this.that=R,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(R,T),this.taps=0}_.prototype={event:function(R){return R&&(this.sourceEvent=R),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(R,T){return this.mouse&&R!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&R!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&R!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(R){var T=$e(this.that).datum();d.call(R,this.that,new L2(R,{sourceEvent:this.sourceEvent,target:S,type:R,transform:this.that.__zoom,dispatch:d}),T)}};function N(R,...T){if(!e.apply(this,arguments))return;var M=L(this,T).event(R),D=this.__zoom,P=Math.max(i[0],Math.min(i[1],D.k*Math.pow(2,s.apply(this,arguments)))),V=De(R);if(M.wheel)(M.mouse[0][0]!==V[0]||M.mouse[0][1]!==V[1])&&(M.mouse[1]=D.invert(M.mouse[0]=V)),clearTimeout(M.wheel);else{if(D.k===P)return;M.mouse=[V,D.invert(V)],Gn(this),M.start()}tn(R),M.wheel=setTimeout(H,h),M.zoom("mouse",n(C(k(D,P),M.mouse[0],M.mouse[1]),M.extent,l));function H(){M.wheel=null,M.end()}}function A(R,...T){if(m||!e.apply(this,arguments))return;var M=R.currentTarget,D=L(this,T,!0).event(R),P=$e(R.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",oe,!0),V=De(R,M),H=R.clientX,G=R.clientY;Mc(R.view),Ks(R),D.mouse=[V,this.__zoom.invert(V)],Gn(this),D.start();function q(ee){if(tn(ee),!D.moved){var ne=ee.clientX-H,se=ee.clientY-G;D.moved=ne*ne+se*se>E}D.event(ee).zoom("mouse",n(C(D.that.__zoom,D.mouse[0]=De(ee,M),D.mouse[1]),D.extent,l))}function oe(ee){P.on("mousemove.zoom mouseup.zoom",null),Lc(ee.view,D.moved),tn(ee),D.event(ee).end()}}function I(R,...T){if(e.apply(this,arguments)){var M=this.__zoom,D=De(R.changedTouches?R.changedTouches[0]:R,this),P=M.invert(D),V=M.k*(R.shiftKey?.5:2),H=n(C(k(M,V),D,P),t.apply(this,T),l);tn(R),c>0?$e(this).transition().duration(c).call(w,H,D,R):$e(this).call(S.transform,H,D,R)}}function F(R,...T){if(e.apply(this,arguments)){var M=R.touches,D=M.length,P=L(this,T,R.changedTouches.length===D).event(R),V,H,G,q;for(Ks(R),H=0;H<D;++H)G=M[H],q=De(G,this),q=[q,this.__zoom.invert(q),G.identifier],P.touch0?!P.touch1&&P.touch0[2]!==q[2]&&(P.touch1=q,P.taps=0):(P.touch0=q,V=!0,P.taps=1+!!x);x&&(x=clearTimeout(x)),V&&(P.taps<2&&(p=q[0],x=setTimeout(function(){x=null},f)),Gn(this),P.start())}}function $(R,...T){if(this.__zooming){var M=L(this,T).event(R),D=R.changedTouches,P=D.length,V,H,G,q;for(tn(R),V=0;V<P;++V)H=D[V],G=De(H,this),M.touch0&&M.touch0[2]===H.identifier?M.touch0[0]=G:M.touch1&&M.touch1[2]===H.identifier&&(M.touch1[0]=G);if(H=M.that.__zoom,M.touch1){var oe=M.touch0[0],ee=M.touch0[1],ne=M.touch1[0],se=M.touch1[1],ie=(ie=ne[0]-oe[0])*ie+(ie=ne[1]-oe[1])*ie,U=(U=se[0]-ee[0])*U+(U=se[1]-ee[1])*U;H=k(H,Math.sqrt(ie/U)),G=[(oe[0]+ne[0])/2,(oe[1]+ne[1])/2],q=[(ee[0]+se[0])/2,(ee[1]+se[1])/2]}else if(M.touch0)G=M.touch0[0],q=M.touch0[1];else return;M.zoom("touch",n(C(H,G,q),M.extent,l))}}function z(R,...T){if(this.__zooming){var M=L(this,T).event(R),D=R.changedTouches,P=D.length,V,H;for(Ks(R),m&&clearTimeout(m),m=setTimeout(function(){m=null},f),V=0;V<P;++V)H=D[V],M.touch0&&M.touch0[2]===H.identifier?delete M.touch0:M.touch1&&M.touch1[2]===H.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(H=De(H,this),Math.hypot(p[0]-H[0],p[1]-H[1])<y)){var G=$e(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return S.wheelDelta=function(R){return arguments.length?(s=typeof R=="function"?R:Ln(+R),S):s},S.filter=function(R){return arguments.length?(e=typeof R=="function"?R:Ln(!!R),S):e},S.touchable=function(R){return arguments.length?(r=typeof R=="function"?R:Ln(!!R),S):r},S.extent=function(R){return arguments.length?(t=typeof R=="function"?R:Ln([[+R[0][0],+R[0][1]],[+R[1][0],+R[1][1]]]),S):t},S.scaleExtent=function(R){return arguments.length?(i[0]=+R[0],i[1]=+R[1],S):[i[0],i[1]]},S.translateExtent=function(R){return arguments.length?(l[0][0]=+R[0][0],l[1][0]=+R[1][0],l[0][1]=+R[0][1],l[1][1]=+R[1][1],S):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},S.constrain=function(R){return arguments.length?(n=R,S):n},S.duration=function(R){return arguments.length?(c=+R,S):c},S.interpolate=function(R){return arguments.length?(a=R,S):a},S.on=function(){var R=d.on.apply(d,arguments);return R===d?S:R},S.clickDistance=function(R){return arguments.length?(E=(R=+R)*R,S):Math.sqrt(E)},S.tapDistance=function(R){return arguments.length?(y=+R,S):y},S}const Ie={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.`},mn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Vc=["Enter"," ","Escape"];var kt;(function(e){e.Strict="strict",e.Loose="loose"})(kt||(kt={}));var Rt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Rt||(Rt={}));var Vt;(function(e){e.Partial="partial",e.Full="full"})(Vt||(Vt={}));const Fc={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var lt;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(lt||(lt={}));var ls;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ls||(ls={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const ti={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function Hc(e){return e===null?null:e?"valid":"invalid"}const Zc=e=>"id"in e&&"source"in e&&"target"in e,$2=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),ar=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Rn=(e,t=[0,0])=>{const{width:n,height:s}=st(e),r=e.origin??t,i=n*r[0],l=s*r[1];return{x:e.position.x-i,y:e.position.y-l}},z2=(e,t={nodeOrigin:[0,0],nodeLookup:void 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):ar(r)?r:t.nodeLookup.get(r.id));const c=l?cs(l,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return bs(s,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ws(n)},Cn=(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=cs(s);n=bs(n,r)}}),ws(n)},Gc=(e,t,[n,s,r]=[0,0,1],i=!1,l=!1)=>{const c={...bn(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,E=fn(c,Ht(d)),y=(f??0)*(h??0),S=i&&E>0;(!d.internals.handleBounds||S||E>=y||d.dragging)&&a.push(d)}return a},B2=(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 Eo(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 yo({nodes:e,width:t,height:n,panZoom:s,minZoom:r,maxZoom:i},l){if(e.size===0)return Promise.resolve(!1);const c=Cn(e),a=ur(c,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(a,{duration:l==null?void 0:l.duration}),Promise.resolve(!0)}function Yc({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",Ie.error005());else{const f=c.measured.width,h=c.measured.height;f&&h&&(p=[[a,d],[a+f,d+h]])}else c&&Zt(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=Zt(p)?_t(t,p,l.measured):t;return{position:{x:m.x-a+l.measured.width*x[0],y:m.y-d+l.measured.height*x[1]},positionAbsolute:m}}async function D2({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(E=>E.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=B2(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 Ft=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),_t=(e={x:0,y:0},t,n)=>({x:Ft(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Ft(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Wc(e,t,n){const{width:s,height:r}=st(n),{x:i,y:l}=n.internals.positionAbsolute;return _t(e,[[i,l],[i+s,l+r]],t)}const ni=(e,t,n)=>e<t?Ft(Math.abs(e-t),1,t)/t:e>n?-Ft(Math.abs(e-n),1,t)/t:0,Kc=(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]},bs=(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)}),So=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),ws=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),Ht=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=ar(e)?e.internals.positionAbsolute:Rn(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}},cs=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=ar(e)?e.internals.positionAbsolute:Rn(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)}},Xc=(e,t)=>ws(bs(So(e),So(t))),fn=(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)},si=e=>Oe(e.width)&&Oe(e.height)&&Oe(e.x)&&Oe(e.y),Oe=e=>!isNaN(e)&&isFinite(e),as=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},vs=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),bn=({x:e,y:t},[n,s,r],i=!1,l=[1,1])=>{const c={x:(e-n)/r,y:(t-s)/r};return i?vs(c,l):c},qc=({x:e,y:t},[n,s,r])=>({x:e*r+n,y:t*r+s}),ur=(e,t,n,s,r,i)=>{const l=t/(e.width*(1+i)),c=n/(e.height*(1+i)),a=Math.min(l,c),d=Ft(a,s,r),x=e.x+e.width/2,p=e.y+e.height/2,m=t/2-x*d,f=n/2-p*d;return{x:m,y:f,zoom:d}},us=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Zt(e){return e!==void 0&&e!=="parent"}function st(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 Uc(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 Jc(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 rn(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:r}){const{x:i,y:l}=Qe(e),c=bn({x:i-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},s),{x:a,y:d}=n?vs(c,t):c;return{xSnapped:a,ySnapped:d,...c}}const ks=e=>({width:e.offsetWidth,height:e.offsetHeight}),Qc=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},O2=["INPUT","SELECT","TEXTAREA"];function Ro(e){var s,r,i;const t=((r=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:r[0])||e.target;return O2.includes(t==null?void 0:t.nodeName)||((i=t==null?void 0:t.hasAttribute)==null?void 0:i.call(t,"contenteditable"))||!!(t!=null&&t.closest(".nokey"))}const ea=e=>"clientX"in e,Qe=(e,t)=>{var i,l;const n=ea(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)}},oi=(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,...ks(l)}})};function ta({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 Pn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ri({pos:e,x1:t,y1:n,x2:s,y2:r,c:i}){switch(e){case X.Left:return[t-Pn(t-s,i),n];case X.Right:return[t+Pn(s-t,i),n];case X.Top:return[t,n-Pn(n-r,i)];case X.Bottom:return[t,n+Pn(r-n,i)]}}function na({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:s,targetY:r,targetPosition:i=X.Top,curvature:l=.25}){const[c,a]=ri({pos:n,x1:e,y1:t,x2:s,y2:r,c:l}),[d,x]=ri({pos:i,x1:s,y1:r,x2:e,y2:t,c:l}),[p,m,f,h]=ta({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 sa({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 V2({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 F2({sourceNode:e,targetNode:t,width:n,height:s,transform:r}){const i=bs(cs(e),cs(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 fn(l,ws(i))>0}const oa=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,H2=(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)),ra=(e,t)=>{if(!e.source||!e.target)return as("006",Ie.error006()),t;let n;return Zc(e)?n={...e}:n={...e,id:oa(e)},H2(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))},Z2=(e,t,n,s={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return as("006",Ie.error006()),n;if(!n.find(a=>a.id===e.id))return as("007",Ie.error007(r)),n;const c={...i,id:s.shouldReplaceId?oa(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(a=>a.id!==r).concat(c)};function ia({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[r,i,l,c]=sa({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,r,i,l,c]}const ii={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},G2=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.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},li=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Y2({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:s=X.Top,center:r,offset:i}){const l=ii[t],c=ii[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=G2({source:a,sourcePosition:t,target:d}),p=x.x!==0?"x":"y",m=x[p];let f=[],h,E;const y={x:0,y:0},S={x:0,y:0},[k,C,b,w]=sa({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){h=r.x??k,E=r.y??C;const _=[{x:h,y:a.y},{x:h,y:d.y}],N=[{x:a.x,y:E},{x:d.x,y:E}];l[p]===m?f=p==="x"?_:N:f=p==="x"?N:_}else{const _=[{x:a.x,y:d.y}],N=[{x:d.x,y:a.y}];if(p==="x"?f=l.x===m?N:_:f=l.y===m?_:N,t===s){const z=Math.abs(e[p]-n[p]);if(z<=i){const R=Math.min(i-1,i-z);l[p]===m?y[p]=(a[p]>e[p]?-1:1)*R:S[p]=(d[p]>n[p]?-1:1)*R}}if(t!==s){const z=p==="x"?"y":"x",R=l[p]===c[z],T=a[z]>d[z],M=a[z]<d[z];(l[p]===1&&(!R&&T||R&&M)||l[p]!==1&&(!R&&M||R&&T))&&(f=p==="x"?_:N)}const A={x:a.x+y.x,y:a.y+y.y},I={x:d.x+S.x,y:d.y+S.y},F=Math.max(Math.abs(A.x-f[0].x),Math.abs(I.x-f[0].x)),$=Math.max(Math.abs(A.y-f[0].y),Math.abs(I.y-f[0].y));F>=$?(h=(A.x+I.x)/2,E=f[0].y):(h=f[0].x,E=(A.y+I.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,E,b,w]}function W2(e,t,n,s){const r=Math.min(li(e,t)/2,li(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 Co({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:s,targetY:r,targetPosition:i=X.Top,borderRadius:l=5,centerX:c,centerY:a,offset:d=20}){const[x,p,m,f,h]=Y2({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,k)=>{let C="";return k>0&&k<x.length-1?C=W2(x[k-1],S,x[k+1],l):C=`${k===0?"M":"L"}${S.x} ${S.y}`,y+=C,y},""),p,m,f,h]}function ci(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function K2(e){var p;const{sourceNode:t,targetNode:n}=e;if(!ci(t)||!ci(n))return null;const s=t.internals.handleBounds||ai(t.handles),r=n.internals.handleBounds||ai(n.handles),i=ui((s==null?void 0:s.source)??[],e.sourceHandle),l=ui(e.connectionMode===kt.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",Ie.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(i==null?void 0:i.position)||X.Bottom,a=(l==null?void 0:l.position)||X.Top,d=hn(t,i,c),x=hn(n,l,a);return{sourceX:d.x,sourceY:d.y,targetX:x.x,targetY:x.y,sourcePosition:c,targetPosition:a}}function ai(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 hn(e,t,n=X.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??st(e);if(s)return{x:r+l/2,y:i+c/2};switch((t==null?void 0:t.position)??n){case X.Top:return{x:r+l/2,y:i};case X.Right:return{x:r+l,y:i+c/2};case X.Bottom:return{x:r+l/2,y:i+c};case X.Left:return{x:r,y:i+c/2}}}function ui(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function bo(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function X2(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=bo(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 dr={nodeOrigin:[0,0],nodeExtent:mn,elevateNodesOnSelect:!0,defaults:{}},q2={...dr,checkEquality:!0};function xr(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function U2(e,t,n){const s=xr(dr,n);for(const r of e.values())if(r.parentId)pr(r,e,t,s);else{const i=Rn(r,s.nodeOrigin),l=Zt(r.extent)?r.extent:s.nodeExtent,c=_t(i,l,st(r));r.internals.positionAbsolute=c}}function wo(e,t,n,s){var c,a;const r=xr(q2,s),i=new Map(t),l=r!=null&&r.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const d of e){let x=i.get(d.id);if(r.checkEquality&&d===(x==null?void 0:x.internals.userNode))t.set(d.id,x);else{const p=Rn(d,r.nodeOrigin),m=Zt(d.extent)?d.extent:r.nodeExtent,f=_t(p,m,st(d));x={...r.defaults,...d,measured:{width:(c=d.measured)==null?void 0:c.width,height:(a=d.measured)==null?void 0:a.height},internals:{positionAbsolute:f,handleBounds:d.measured?x==null?void 0:x.internals.handleBounds:void 0,z:la(d,l),userNode:d}},t.set(d.id,x)}d.parentId&&pr(x,t,n,s)}}function J2(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 pr(e,t,n,s){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:l}=xr(dr,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}J2(e,n);const d=r?1e3:0,{x,y:p,z:m}=Q2(e,a,i,l,d),{positionAbsolute:f}=e.internals,h=x!==f.x||p!==f.y;(h||m!==e.internals.z)&&(e.internals={...e.internals,positionAbsolute:h?{x,y:p}:f,z:m})}function la(e,t){return(Oe(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function Q2(e,t,n,s,r){const{x:i,y:l}=t.internals.positionAbsolute,c=st(e),a=Rn(e,n),d=Zt(e.extent)?_t(a,e.extent,c):a;let x=_t({x:i+d.x,y:l+d.y},s,c);e.extent==="parent"&&(x=Wc(x,c,t));const p=la(e,r),m=t.internals.z??0;return{x:x.x,y:x.y,z:m>p?m:p}}function mr(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)??Ht(a),x=Xc(d,c.rect);i.set(c.parentId,{expandedRect:x,parent:a})}return i.size>0&&i.forEach(({expandedRect:c,parent:a},d)=>{var C;const x=a.internals.positionAbsolute,p=st(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,E=Math.max(p.width,Math.round(c.width)),y=Math.max(p.height,Math.round(c.height)),S=(E-p.width)*m[0],k=(y-p.height)*m[1];(f>0||h>0||S||k)&&(r.push({id:d,type:"position",position:{x:a.position.x-f+S,y:a.position.y-h+k}}),(C=n.get(d))==null||C.forEach(b=>{e.some(w=>w.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+h}})})),(p.width<c.width||p.height<c.height||f||h)&&r.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:E+(f?m[0]*f-S:0),height:y+(h?m[1]*h-k:0)}})}),r}function e3(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)if(f.hidden)f.internals={...f.internals,handleBounds:void 0},c=!0;else{const h=ks(m.nodeElement),E=f.measured.width!==h.width||f.measured.height!==h.height;if(!!(h.width&&h.height&&(E||!f.internals.handleBounds||m.force))){const S=m.nodeElement.getBoundingClientRect(),k=Zt(f.extent)?f.extent:i;let{positionAbsolute:C}=f.internals;f.parentId&&f.extent==="parent"?C=Wc(C,h,t.get(f.parentId)):k&&(C=_t(C,k,h)),f.measured=h,f.internals={...f.internals,positionAbsolute:C,handleBounds:{source:oi("source",m.nodeElement,S,x,f.id),target:oi("target",m.nodeElement,S,x,f.id)}},f.parentId&&pr(f,t,n,{nodeOrigin:r}),c=!0,E&&(a.push({id:f.id,type:"dimensions",dimensions:h}),f.expandParent&&f.parentId&&p.push({id:f.id,parentId:f.parentId,rect:Ht(f,r)}))}}}if(p.length>0){const m=mr(p,t,n,r);a.push(...m)}return{changes:a,updatedInternals:c}}async function t3({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 ca(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=`${r}-source-${l}`,d=`${i}-target-${c}`,x=e.get(a)||new Map,p=e.get(d)||new Map,m={edgeId:s.id,source:r,target:i,sourceHandle:l,targetHandle:c};t.set(s.id,s),e.set(a,x.set(`${i}-${c}`,m)),e.set(d,p.set(`${r}-${l}`,m))}}function aa(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:aa(n,t):!1}function di(e,t,n){let s=e;do{if(s!=null&&s.matches(t))return!0;if(s===n)return!1;s=s.parentElement}while(s);return!1}function n3(e,t,n,s){const r=new Map;for(const[i,l]of e)if((l.selected||l.id===s)&&(!l.parentId||!aa(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 Xs({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 s3({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:k,isSelectable:C,nodeId:b,nodeClickDistance:w=0}){m=$e(k);function L({x:I,y:F},$){const{nodeLookup:z,nodeExtent:R,snapGrid:T,snapToGrid:M,nodeOrigin:D,onNodeDrag:P,onSelectionDrag:V,onError:H,updateNodePositions:G}=t();i={x:I,y:F};let q=!1,oe={x:0,y:0,x2:0,y2:0};if(c.size>1&&R){const ee=Cn(c);oe=So(ee)}for(const[ee,ne]of c){if(!z.has(ee))continue;let se={x:I-ne.distance.x,y:F-ne.distance.y};M&&(se=vs(se,T));let ie=[[R[0][0],R[0][1]],[R[1][0],R[1][1]]];if(c.size>1&&R&&!ne.extent){const{positionAbsolute:ge}=ne.internals,pe=ge.x-oe.x+R[0][0],re=ge.x+ne.measured.width-oe.x2+R[1][0],Q=ge.y-oe.y+R[0][1],le=ge.y+ne.measured.height-oe.y2+R[1][1];ie=[[pe,Q],[re,le]]}const{position:U,positionAbsolute:ue}=Yc({nodeId:ee,nextPosition:se,nodeLookup:z,nodeExtent:ie,nodeOrigin:D,onError:H});q=q||ne.position.x!==U.x||ne.position.y!==U.y,ne.position=U,ne.internals.positionAbsolute=ue}if(q&&(G(c,!0),$&&(s||P||!b&&V))){const[ee,ne]=Xs({nodeId:b,dragItems:c,nodeLookup:z});s==null||s($,c,ee,ne),P==null||P($,ee,ne),b||V==null||V($,ne)}}async function _(){if(!x)return;const{transform:I,panBy:F,autoPanSpeed:$}=t(),[z,R]=Kc(d,x,$);(z!==0||R!==0)&&(i.x=(i.x??0)-z/I[2],i.y=(i.y??0)-R/I[2],await F({x:z,y:R})&&L(i,null)),l=requestAnimationFrame(_)}function N(I){var q;const{nodeLookup:F,multiSelectionActive:$,nodesDraggable:z,transform:R,snapGrid:T,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:P,onSelectionDragStart:V,unselectNodesAndEdges:H}=t();p=!0,(!D||!C)&&!$&&b&&((q=F.get(b))!=null&&q.selected||H()),C&&D&&b&&(e==null||e(b));const G=rn(I.sourceEvent,{transform:R,snapGrid:T,snapToGrid:M,containerBounds:x});if(i=G,c=n3(F,z,G,b),c.size>0&&(n||P||!b&&V)){const[oe,ee]=Xs({nodeId:b,dragItems:c,nodeLookup:F});n==null||n(I.sourceEvent,c,oe,ee),P==null||P(I.sourceEvent,oe,ee),b||V==null||V(I.sourceEvent,ee)}}const A=Pc().clickDistance(w).on("start",I=>{const{domNode:F,nodeDragThreshold:$,transform:z,snapGrid:R,snapToGrid:T}=t();x=(F==null?void 0:F.getBoundingClientRect())||null,f=!1,$===0&&N(I),i=rn(I.sourceEvent,{transform:z,snapGrid:R,snapToGrid:T,containerBounds:x}),d=Qe(I.sourceEvent,x)}).on("drag",I=>{const{autoPanOnNodeDrag:F,transform:$,snapGrid:z,snapToGrid:R,nodeDragThreshold:T,nodeLookup:M}=t(),D=rn(I.sourceEvent,{transform:$,snapGrid:z,snapToGrid:R,containerBounds:x});if((I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1||b&&!M.has(b))&&(f=!0),!f){if(!a&&F&&p&&(a=!0,_()),!p){const P=D.xSnapped-(i.x??0),V=D.ySnapped-(i.y??0);Math.sqrt(P*P+V*V)>T&&N(I)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&c&&p&&(d=Qe(I.sourceEvent,x),L(D,I.sourceEvent))}}).on("end",I=>{if(!(!p||f)&&(a=!1,p=!1,cancelAnimationFrame(l),c.size>0)){const{nodeLookup:F,updateNodePositions:$,onNodeDragStop:z,onSelectionDragStop:R}=t();if($(c,!1),r||z||!b&&R){const[T,M]=Xs({nodeId:b,dragItems:c,nodeLookup:F,dragging:!1});r==null||r(I.sourceEvent,c,T,M),z==null||z(I.sourceEvent,T,M),b||R==null||R(I.sourceEvent,M)}}}).filter(I=>{const F=I.target;return!I.button&&(!y||!di(F,`.${y}`,k))&&(!S||di(F,S,k))});m.call(A)}function E(){m==null||m.on(".drag",null)}return{update:h,destroy:E}}function o3(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())fn(r,Ht(i))>0&&s.push(i);return s}const r3=250;function i3(e,t,n,s){var c,a;let r=[],i=1/0;const l=o3(e,n,t+r3);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}=hn(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 ua(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,...hn(l,a,a.position,!0)}:a}function da(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function l3(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const xa=()=>!0;function c3(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:E,onConnectEnd:y,isValidConnection:S=xa,onReconnectEnd:k,updateConnection:C,getTransform:b,getFromHandle:w,autoPanSpeed:L}){const _=Qc(e.target);let N=0,A;const{x:I,y:F}=Qe(e),$=_==null?void 0:_.elementFromPoint(I,F),z=da(i,$),R=c==null?void 0:c.getBoundingClientRect();if(!R||!z)return;const T=ua(r,z,s,a,t);if(!T)return;let M=Qe(e,R),D=!1,P=null,V=!1,H=null;function G(){if(!x||!R)return;const[ue,ge]=Kc(M,R,L);m({x:ue,y:ge}),N=requestAnimationFrame(G)}const q={...T,nodeId:r,type:z,position:T.position},oe=a.get(r),ne={inProgress:!0,isValid:null,from:hn(oe,q,X.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:oe,to:M,toHandle:null,toPosition:ti[q.position],toNode:null};C(ne);let se=ne;h==null||h(e,{nodeId:r,handleId:s,handleType:z});function ie(ue){if(!w()||!q){U(ue);return}const ge=b();M=Qe(ue,R),A=i3(bn(M,ge,!1,[1,1]),n,a,q),D||(G(),D=!0);const pe=pa(ue,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:s,fromType:l?"target":"source",isValidConnection:S,doc:_,lib:d,flowId:p,nodeLookup:a});H=pe.handleDomNode,P=pe.connection,V=l3(!!A,pe.isValid);const re={...se,isValid:V,to:A&&V?qc({x:A.x,y:A.y},ge):M,toHandle:pe.toHandle,toPosition:V&&pe.toHandle?pe.toHandle.position:ti[q.position],toNode:pe.toHandle?a.get(pe.toHandle.nodeId):null};V&&A&&se.toHandle&&re.toHandle&&se.toHandle.type===re.toHandle.type&&se.toHandle.nodeId===re.toHandle.nodeId&&se.toHandle.id===re.toHandle.id&&se.to.x===re.to.x&&se.to.y===re.to.y||(C(re),se=re)}function U(ue){(A||H)&&P&&V&&(E==null||E(P));const{inProgress:ge,...pe}=se,re={...pe,toPosition:se.toHandle?se.toPosition:null};y==null||y(ue,re),i&&(k==null||k(ue,re)),f(),cancelAnimationFrame(N),D=!1,V=!1,P=null,H=null,_.removeEventListener("mousemove",ie),_.removeEventListener("mouseup",U),_.removeEventListener("touchmove",ie),_.removeEventListener("touchend",U)}_.addEventListener("mousemove",ie),_.addEventListener("mouseup",U),_.addEventListener("touchmove",ie),_.addEventListener("touchend",U)}function pa(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:r,fromType:i,doc:l,lib:c,flowId:a,isValidConnection:d=xa,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}=Qe(e),E=l.elementFromPoint(f,h),y=E!=null&&E.classList.contains(`${c}-flow__handle`)?E:m,S={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const k=da(void 0,y),C=y.getAttribute("data-nodeid"),b=y.getAttribute("data-handleid"),w=y.classList.contains("connectable"),L=y.classList.contains("connectableend");if(!C||!k)return S;const _={source:p?C:s,sourceHandle:p?b:r,target:p?s:C,targetHandle:p?r:b};S.connection=_;const A=w&&L&&(n===kt.Strict?p&&k==="source"||!p&&k==="target":C!==s||b!==r);S.isValid=A&&d(_),S.toHandle=ua(C,k,b,x,n,!1)}return S}const vo={onPointerDown:c3,isValid:pa};function a3({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const r=$e(e);function i({translateExtent:c,width:a,height:d,zoomStep:x=10,pannable:p=!0,zoomable:m=!0,inversePan:f=!1}){const h=C=>{const b=n();if(C.sourceEvent.type!=="wheel"||!t)return;const w=-C.sourceEvent.deltaY*(C.sourceEvent.deltaMode===1?.05:C.sourceEvent.deltaMode?1:.002)*x,L=b[2]*Math.pow(2,w);t.scaleTo(L)};let E=[0,0];const y=C=>{(C.sourceEvent.type==="mousedown"||C.sourceEvent.type==="touchstart")&&(E=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY])},S=C=>{const b=n();if(C.sourceEvent.type!=="mousemove"&&C.sourceEvent.type!=="touchmove"||!t)return;const w=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY],L=[w[0]-E[0],w[1]-E[1]];E=w;const _=s()*Math.max(b[2],Math.log(b[2]))*(f?-1:1),N={x:b[0]-L[0]*_,y:b[1]-L[1]*_},A=[[0,0],[a,d]];t.setViewportConstrained({x:N.x,y:N.y,zoom:b[2]},A,c)},k=Oc().on("start",y).on("zoom",p?S:null).on("zoom.wheel",m?h:null);r.call(k,{})}function l(){r.on("zoom",null)}return{update:i,destroy:l,pointer:De}}const u3=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,_s=e=>({x:e.x,y:e.y,zoom:e.k}),qs=({x:e,y:t,zoom:n})=>Cs.translate(e,t).scale(n),At=(e,t)=>e.target.closest(`.${t}`),ma=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Us=(e,t=0,n=()=>{})=>{const s=typeof t=="number"&&t>0;return s||n(),s?e.transition().duration(t).on("end",n):e},fa=e=>{const t=e.ctrlKey&&us()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function d3({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:l,onPanZoomStart:c,onPanZoom:a,onPanZoomEnd:d}){return x=>{if(At(x,t))return!1;x.preventDefault(),x.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(x.ctrlKey&&l){const y=De(x),S=fa(x),k=p*Math.pow(2,S);s.scaleTo(n,k,y,x);return}const m=x.deltaMode===1?20:1;let f=r===Rt.Vertical?0:x.deltaX*m,h=r===Rt.Horizontal?0:x.deltaY*m;!us()&&x.shiftKey&&r!==Rt.Vertical&&(f=x.deltaY*m,h=0),s.translateBy(n,-(f/p)*i,-(h/p)*i,{internal:!0});const E=_s(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,c==null||c(x,E)),e.isPanScrolling&&(a==null||a(x,E),e.panScrollTimeout=setTimeout(()=>{d==null||d(x,E),e.isPanScrolling=!1},150))}}function x3({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,r){if(!t&&s.type==="wheel"&&!s.ctrlKey||At(s,e))return null;s.preventDefault(),n.call(this,s,r)}}function p3({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{var i,l,c;if((i=s.sourceEvent)!=null&&i.internal)return;const r=_s(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 m3({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:r}){return i=>{var l,c;e.usedRightMouseButton=!!(n&&ma(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,_s(i.transform)))}}function f3({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&&ma(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&i(l.sourceEvent),e.usedRightMouseButton=!1,s(!1),r&&u3(e.prevViewport,l.transform))){const a=_s(l.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,a)},n?150:0)}}}function h3({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"&&(At(x,`${d}-flow__node`)||At(x,`${d}-flow__edge`)))return!0;if(!s&&!p&&!r&&!i&&!n||l||At(x,c)&&x.type==="wheel"||At(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 g3({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=Oc().clickDistance(!Oe(s)||s<0?0:s).scaleExtent([t,n]).translateExtent(r),f=$e(e).call(m);C({x:i.x,y:i.y,zoom:Ft(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const h=f.on("wheel.zoom"),E=f.on("dblclick.zoom");m.wheelDelta(fa);function y($,z){return f?new Promise(R=>{m==null||m.transform(Us(f,z==null?void 0:z.duration,()=>R(!0)),$)}):Promise.resolve(!1)}function S({noWheelClassName:$,noPanClassName:z,onPaneContextMenu:R,userSelectionActive:T,panOnScroll:M,panOnDrag:D,panOnScrollMode:P,panOnScrollSpeed:V,preventScrolling:H,zoomOnPinch:G,zoomOnScroll:q,zoomOnDoubleClick:oe,zoomActivationKeyPressed:ee,lib:ne,onTransformChange:se}){T&&!x.isZoomingOrPanning&&k();const U=M&&!ee&&!T?d3({zoomPanValues:x,noWheelClassName:$,d3Selection:f,d3Zoom:m,panOnScrollMode:P,panOnScrollSpeed:V,zoomOnPinch:G,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:a}):x3({noWheelClassName:$,preventScrolling:H,d3ZoomHandler:h});if(f.on("wheel.zoom",U,{passive:!1}),!T){const ge=p3({zoomPanValues:x,onDraggingChange:d,onPanZoomStart:c});m.on("start",ge);const pe=m3({zoomPanValues:x,panOnDrag:D,onPaneContextMenu:!!R,onPanZoom:l,onTransformChange:se});m.on("zoom",pe);const re=f3({zoomPanValues:x,panOnDrag:D,panOnScroll:M,onPaneContextMenu:R,onPanZoomEnd:a,onDraggingChange:d});m.on("end",re)}const ue=h3({zoomActivationKeyPressed:ee,panOnDrag:D,zoomOnScroll:q,panOnScroll:M,zoomOnDoubleClick:oe,zoomOnPinch:G,userSelectionActive:T,noPanClassName:z,noWheelClassName:$,lib:ne});m.filter(ue),oe?f.on("dblclick.zoom",E):f.on("dblclick.zoom",null)}function k(){m.on("zoom",null)}async function C($,z,R){const T=qs($),M=m==null?void 0:m.constrain()(T,z,R);return M&&await y(M),new Promise(D=>D(M))}async function b($,z){const R=qs($);return await y(R,z),new Promise(T=>T(R))}function w($){if(f){const z=qs($),R=f.property("__zoom");(R.k!==$.zoom||R.x!==$.x||R.y!==$.y)&&(m==null||m.transform(f,z,null,{sync:!0}))}}function L(){const $=f?Dc(f.node()):{x:0,y:0,k:1};return{x:$.x,y:$.y,zoom:$.k}}function _($,z){return f?new Promise(R=>{m==null||m.scaleTo(Us(f,z==null?void 0:z.duration,()=>R(!0)),$)}):Promise.resolve(!1)}function N($,z){return f?new Promise(R=>{m==null||m.scaleBy(Us(f,z==null?void 0:z.duration,()=>R(!0)),$)}):Promise.resolve(!1)}function A($){m==null||m.scaleExtent($)}function I($){m==null||m.translateExtent($)}function F($){const z=!Oe($)||$<0?0:$;m==null||m.clickDistance(z)}return{update:S,destroy:k,setViewport:b,setViewportConstrained:C,getViewport:L,scaleTo:_,scaleBy:N,setScaleExtent:A,setTranslateExtent:I,syncViewport:w,setClickDistance:F}}var ln;(function(e){e.Line="line",e.Handle="handle"})(ln||(ln={}));function j3({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 E3(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 rt(e,t){return Math.max(0,t-e)}function it(e,t){return Math.max(0,e-t)}function Tn(e,t,n){return Math.max(0,t-e,e-n)}function xi(e,t){return e?!t:t}function y3(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:E,maxWidth:y,minHeight:S,maxHeight:k}=s,{x:C,y:b,width:w,height:L,aspectRatio:_}=e;let N=Math.floor(x?f-e.pointerX:0),A=Math.floor(p?h-e.pointerY:0);const I=w+(a?-N:N),F=L+(d?-A:A),$=-i[0]*w,z=-i[1]*L;let R=Tn(I,E,y),T=Tn(F,S,k);if(l){let P=0,V=0;a&&N<0?P=rt(C+N+$,l[0][0]):!a&&N>0&&(P=it(C+I+$,l[1][0])),d&&A<0?V=rt(b+A+z,l[0][1]):!d&&A>0&&(V=it(b+F+z,l[1][1])),R=Math.max(R,P),T=Math.max(T,V)}if(c){let P=0,V=0;a&&N>0?P=it(C+N,c[0][0]):!a&&N<0&&(P=rt(C+I,c[1][0])),d&&A>0?V=it(b+A,c[0][1]):!d&&A<0&&(V=rt(b+F,c[1][1])),R=Math.max(R,P),T=Math.max(T,V)}if(r){if(x){const P=Tn(I/_,S,k)*_;if(R=Math.max(R,P),l){let V=0;!a&&!d||a&&!d&&m?V=it(b+z+I/_,l[1][1])*_:V=rt(b+z+(a?N:-N)/_,l[0][1])*_,R=Math.max(R,V)}if(c){let V=0;!a&&!d||a&&!d&&m?V=rt(b+I/_,c[1][1])*_:V=it(b+(a?N:-N)/_,c[0][1])*_,R=Math.max(R,V)}}if(p){const P=Tn(F*_,E,y)/_;if(T=Math.max(T,P),l){let V=0;!a&&!d||d&&!a&&m?V=it(C+F*_+$,l[1][0])/_:V=rt(C+(d?A:-A)*_+$,l[0][0])/_,T=Math.max(T,V)}if(c){let V=0;!a&&!d||d&&!a&&m?V=rt(C+F*_,c[1][0])/_:V=it(C+(d?A:-A)*_,c[0][0])/_,T=Math.max(T,V)}}}A=A+(A<0?T:-T),N=N+(N<0?R:-R),r&&(m?I>F*_?A=(xi(a,d)?-N:N)/_:N=(xi(a,d)?-A:A)*_:x?(A=N/_,d=a):(N=A*_,a=d));const M=a?C+N:C,D=d?b+A:b;return{width:w+(a?-N:N),height:L+(d?-A:A),x:i[0]*N*(a?-1:1)+M,y:i[1]*A*(d?-1:1)+D}}const ha={width:0,height:0,x:0,y:0},S3={...ha,pointerX:0,pointerY:0,aspectRatio:1};function R3(e){return[[0,0],[e.measured.width,e.measured.height]]}function C3(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 b3({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:r}){const i=$e(e);function l({controlPosition:a,boundaries:d,keepAspectRatio:x,onResizeStart:p,onResize:m,onResizeEnd:f,shouldResize:h}){let E={...ha},y={...S3};const S=E3(a);let k,C=null,b=[],w,L,_;const N=Pc().on("start",A=>{const{nodeLookup:I,transform:F,snapGrid:$,snapToGrid:z,nodeOrigin:R,paneDomNode:T}=n();if(k=I.get(t),!k)return;C=(T==null?void 0:T.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=rn(A.sourceEvent,{transform:F,snapGrid:$,snapToGrid:z,containerBounds:C});E={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},y={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},w=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(w=I.get(k.parentId),L=w&&k.extent==="parent"?R3(w):void 0),b=[],_=void 0;for(const[P,V]of I)if(V.parentId===t&&(b.push({id:P,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const H=C3(V,k,V.origin??R);_?_=[[Math.min(H[0][0],_[0][0]),Math.min(H[0][1],_[0][1])],[Math.max(H[1][0],_[1][0]),Math.max(H[1][1],_[1][1])]]:_=H}p==null||p(A,{...E})}).on("drag",A=>{const{transform:I,snapGrid:F,snapToGrid:$,nodeOrigin:z}=n(),R=rn(A.sourceEvent,{transform:I,snapGrid:F,snapToGrid:$,containerBounds:C}),T=[];if(!k)return;const{x:M,y:D,width:P,height:V}=E,H={},G=k.origin??z,{width:q,height:oe,x:ee,y:ne}=y3(y,S,R,d,x,G,L,_),se=q!==P,ie=oe!==V,U=ee!==M&&se,ue=ne!==D&&ie;if(!U&&!ue&&!se&&!ie)return;if((U||ue||G[0]===1||G[1]===1)&&(H.x=U?ee:E.x,H.y=ue?ne:E.y,E.x=H.x,E.y=H.y,b.length>0)){const Q=ee-M,le=ne-D;for(const je of b)je.position={x:je.position.x-Q+G[0]*(q-P),y:je.position.y-le+G[1]*(oe-V)},T.push(je)}if((se||ie)&&(H.width=se?q:E.width,H.height=ie?oe:E.height,E.width=H.width,E.height=H.height),w&&k.expandParent){const Q=G[0]*(H.width??0);H.x&&H.x<Q&&(E.x=Q,y.x=y.x-(H.x-Q));const le=G[1]*(H.height??0);H.y&&H.y<le&&(E.y=le,y.y=y.y-(H.y-le))}const ge=j3({width:E.width,prevWidth:P,height:E.height,prevHeight:V,affectsX:S.affectsX,affectsY:S.affectsY}),pe={...E,direction:ge};(h==null?void 0:h(A,pe))!==!1&&(m==null||m(A,pe),s(H,T))}).on("end",A=>{f==null||f(A,{...E}),r==null||r()});i.call(N)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var Nn={exports:{}},Js={},An={exports:{}},Qs={};/**
2
2
  * @license React
3
3
  * use-sync-external-store-shim.production.js
4
4
  *