@synnaxlabs/pluto 0.44.7 → 0.44.8
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/{Animated-D5LYKEkW.cjs → Animated-CyK_c82a.cjs} +1 -1
- package/dist/{Animated-DdcRuSba.js → Animated-fJsLX-Tt.js} +1 -1
- package/dist/{Editable-7Abx7gK5.cjs → Editable-B8pvBXQS.cjs} +39 -39
- package/dist/{Editable-BrtvNf66.js → Editable-MR16HLlJ.js} +3408 -3404
- package/dist/{Toggle-BVFmU1mL.cjs → Toggle-Bqp97ujd.cjs} +1 -1
- package/dist/{Toggle-DfINNQZ3.js → Toggle-BsP_WecR.js} +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/color.cjs +1 -1
- package/dist/color.js +1 -1
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/external-0zUBjsWc.cjs +1 -0
- package/dist/{external-vdf1a_j1.cjs → external-1ebWGBIY.cjs} +1 -1
- package/dist/{external-D-FHwqls.cjs → external-B4A9qxs2.cjs} +1 -1
- package/dist/{external-FrSPoRvt.js → external-B5vTtpm8.js} +1 -1
- package/dist/{external-C3hm9xgd.cjs → external-BNagUgId.cjs} +1 -1
- package/dist/{external-V3Tbt95R.js → external-BWwSCjxj.js} +2 -2
- package/dist/{external-CoVeaXHg.cjs → external-Bbrq8Uh2.cjs} +1 -1
- package/dist/{external-DkZwoQZk.js → external-BhMf86-b.js} +1 -1
- package/dist/{external-mX8u0eSb.cjs → external-BoI3SDJy.cjs} +1 -1
- package/dist/{external-BNwo0Mju.js → external-C1_CUNeZ.js} +1 -1
- package/dist/{external-B33LW5pz.cjs → external-CbHi1R5M.cjs} +1 -1
- package/dist/{external-IBErJ3kF.cjs → external-Cd_bzIsx.cjs} +1 -1
- package/dist/{external-ClD0dLdB.js → external-CuYkHdQ-.js} +1 -1
- package/dist/{external-Cs-XdMNw.cjs → external-Cw9nrwGS.cjs} +1 -1
- package/dist/{external-J5kFGShS.js → external-CzyQFMzI.js} +2 -2
- package/dist/{external-D91gCQ3U.cjs → external-D0FRmOeg.cjs} +1 -1
- package/dist/{external-CoEPLcYb.js → external-D4Cbm19R.js} +1 -1
- package/dist/{external-CE5Gf1U4.cjs → external-DHgpDWNu.cjs} +1 -1
- package/dist/{external-CtRU4mkG.js → external-DVsTr26y.js} +1 -1
- package/dist/{external-C_25EtbW.js → external-DpjNdrhL.js} +1 -1
- package/dist/{external-DXm6LsSg.cjs → external-H1IGckxo.cjs} +1 -1
- package/dist/{external-CSkXMvdW.js → external-IBOALZ2N.js} +1 -1
- package/dist/{external-GS2AbOOd.js → external-NISlPgIR.js} +1 -1
- package/dist/{external-CsZA1s33.js → external-Poa7jfNM.js} +2 -2
- package/dist/{external-Ds3Wz9sk.js → external-YHSSoyM9.js} +2 -2
- package/dist/{external-DSkHe-2Y.cjs → external-lcuUe52o.cjs} +1 -1
- package/dist/flex.cjs +1 -1
- package/dist/flex.js +1 -1
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +53 -45
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/list.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.cjs +1 -1
- package/dist/menu.js +1 -1
- package/dist/pluto.css +1 -1
- package/dist/src/dialog/Frame.d.ts.map +1 -1
- package/dist/src/dialog/position.d.ts.map +1 -1
- package/dist/src/vis/legend/Grouped.d.ts.map +1 -1
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text.cjs +1 -1
- package/dist/text.js +2 -2
- package/dist/theming.cjs +1 -1
- package/dist/theming.js +2 -2
- package/dist/tree.cjs +1 -1
- package/dist/tree.js +1 -1
- package/dist/triggers.cjs +1 -1
- package/dist/triggers.js +1 -1
- package/package.json +3 -3
- package/dist/external-DE-uFhwW.cjs +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./Editable-7Abx7gK5.cjs"),o=require("./jsx-runtime-CITbqOLs.cjs"),j=require("react"),u=require("./css-CZ_XGkIB.cjs"),P=require("./eraser-DiJNbabo.cjs"),qh=require("./external-DE-uFhwW.cjs"),$l=require("./Animated-D5LYKEkW.cjs"),zl=require("react-dom"),O=require("./LinePlot-DslwDvAo.cjs"),ks=require("./external-CoVeaXHg.cjs"),te=require("zod"),Pe=require("./external-DSkHe-2Y.cjs"),Vl=require("./external-D91gCQ3U.cjs"),nt=require("./external-mX8u0eSb.cjs"),Fl=require("./external-CE5Gf1U4.cjs"),Ie=require("./external-C3hm9xgd.cjs"),pe=require("./external-DXm6LsSg.cjs"),Hl=require("./units-Cqxg-SBx.cjs"),Qh=require("./external-B33LW5pz.cjs"),Jh=require("./external-D-FHwqls.cjs"),Me=require("./external-Cs-XdMNw.cjs"),eg=require("./external-IBErJ3kF.cjs"),tg=require("./external-vdf1a_j1.cjs"),ng=require("./Video-CbaEeyGH.cjs"),Zl=require("./Toggle-BVFmU1mL.cjs"),sg=e=>e.nullable().transform(t=>t===null?void 0:t).optional(),og=e=>te.array(e).or(e.transform(t=>[t])),Kl=e=>P.p(e,(t,n,s)=>{const r=n===s.length-1,i=!isNaN(parseInt(t)),l=!isNaN(parseInt(s[n+1]));return i&&(t="element"),r||l?t:[t,"shape"]}),fi=(e,t)=>{if(e==null)return null;const n=e[t];return n==null&&typeof e=="object"&&"sourceType"in e?e.sourceType()[t]:n},rg=(e,t,n)=>t===""?e:P.c(fi(e,"shape"),Kl(t),{...n,getter:fi}),ig=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:rg,getFieldSchemaPath:Kl,nullToUndefined:sg,toArray:og},Symbol.toStringTag,{value:"Module"})),Yl=Symbol(),qo=Symbol(),xn="a",os="w";let lg=(e,t)=>new Proxy(e,t);const Co=Object.getPrototypeOf,hi=new WeakMap,Qo=e=>e&&(hi.has(e)?hi.get(e):Co(e)===Object.prototype||Co(e)===Array.prototype),gi=e=>typeof e=="object"&&e!==null,ji=new WeakMap,Gl=e=>e[qo]||e,Ul=(e,t,n)=>{if(!Qo(e))return e;const s=Gl(e),r=(l=>Object.isFrozen(l)||Object.values(Object.getOwnPropertyDescriptors(l)).some(a=>!a.writable))(s);let i=n&&n.get(s);return i&&i[1].f===r||(i=((l,a)=>{const c={f:a};let d=!1;const x=(m,h)=>{if(!d){let g=c[xn].get(l);if(g||(g={},c[xn].set(l,g)),m===os)g[os]=!0;else{let E=g[m];E||(E=new Set,g[m]=E),E.add(h)}}},p={get:(m,h)=>h===qo?l:(x("k",h),Ul(Reflect.get(m,h),c[xn],c.c)),has:(m,h)=>h===Yl?(d=!0,c[xn].delete(l),!0):(x("h",h),Reflect.has(m,h)),getOwnPropertyDescriptor:(m,h)=>(x("o",h),Reflect.getOwnPropertyDescriptor(m,h)),ownKeys:m=>(x(os),Reflect.ownKeys(m))};return a&&(p.set=p.deleteProperty=()=>!1),[p,c]})(s,r),i[1].p=lg(r?(l=>{let a=ji.get(l);if(!a){if(Array.isArray(l))a=Array.from(l);else{const c=Object.getOwnPropertyDescriptors(l);Object.values(c).forEach(d=>{d.configurable=!0}),a=Object.create(Co(l),c)}ji.set(l,a)}return a})(s):s,i[0]),n&&n.set(s,i)),i[1][xn]=t,i[1].c=n,i[1].p},Wl=(e,t,n,s)=>{if(Object.is(e,t))return!1;if(!gi(e)||!gi(t))return!0;const r=n.get(Gl(e));if(!r)return!0;if(s){const l=s.get(e);if(l&&l.n===t)return l.g;s.set(e,{n:t,g:!1})}let i=null;try{for(const l of r.h||[])if(i=Reflect.has(e,l)!==Reflect.has(t,l),i)return i;if(r[os]===!0){if(i=((l,a)=>{const c=Reflect.ownKeys(l),d=Reflect.ownKeys(a);return c.length!==d.length||c.some((x,p)=>x!==d[p])})(e,t),i)return i}else for(const l of r.o||[])if(i=!!Reflect.getOwnPropertyDescriptor(e,l)!=!!Reflect.getOwnPropertyDescriptor(t,l),i)return i;for(const l of r.k||[])if(i=Wl(e[l],t[l],n,s),i)return i;return i===null&&(i=!0),i}finally{s&&s.set(e,{n:t,g:i})}},ag=e=>!!Qo(e)&&Yl in e,Xl=e=>Qo(e)&&e[qo]||null,cg="h",ug="w",dg="o",xg="k",wo=e=>typeof e=="object"&&e!==null,ql=(e,t)=>{if(!wo(e))return e;const n=Xl(e);return n!==null?(ag(e),n):(t.has(e)||(t.add(e),Object.entries(e).forEach(([s,r])=>{const i=ql(r,t);Object.is(i,r)||(e[s]=i)})),e)},bo=(e,t,n)=>{var s,r,i;if(!wo(e)||!wo(t))return;const l=n.get(Xl(t)||t);l&&((s=l[cg])==null||s.forEach(a=>{Reflect.has(e,a)}),l[ug]===!0&&Reflect.ownKeys(e),(r=l[dg])==null||r.forEach(a=>{Reflect.getOwnPropertyDescriptor(e,a)}),(i=l[xg])==null||i.forEach(a=>{bo(e[a],t[a],n)}))},to="o",no="r",so="a";function pg(e,t){var n;let s=0;const r=(n=t?.size)!=null?n:1,i=[],l=t!=null&&t.noWeakMap?null:new WeakMap;return c=>{const d=l?.get(c);if(d)return d[no];for(let g=0;g<r;g+=1){const E=i[(s+g)%r];if(!E)break;if(!Wl(E[to],c,E[so],new WeakMap))return bo(c,E[to],E[so]),l?.set(c,E),E[no]}const x=new WeakMap,p=Ul(c,x),m=ql(e(p),new Set);bo(c,c,x);const h={[to]:c,[no]:m,[so]:x};return s=(s-1+r)%r,i[s]=h,l?.set(c,h),m}}const mg=(e,t)=>u.S.RUNTIME==="browser"?pg(e,t):e,It=(e,t)=>{j.useEffect(()=>{const n=new AbortController,s=n.signal,i=(async()=>(await u.dr(),await e(s)))().catch(console.error);return()=>{n.abort(),i.then(l=>l?.()).catch(console.error)}},t)},Ls=()=>{const e=j.useRef([]),t=j.useMemo(()=>({cleanup:()=>{e.current.forEach(n=>n()),e.current=[]},set:n=>{n!=null&&e.current.push(...P.t.toArray(n))}}),[]);return j.useEffect(()=>t.cleanup,[t.cleanup]),t},fg=Object.freeze(Object.defineProperty({__proto__:null,Access:f.Access,Acquire:f.Acquire,Add:f.Add,Align:f.Align,Analyze:f.Analyze,Annotate:f.Annotate,Array:f.Array,Arrow:f.Arrow,Attachment:f.Attachment,Auto:f.Auto,AutoFitWidth:f.AutoFitWidth,Binary:f.Binary,Bolt:f.Bolt,Box:f.Box$1,Bridge:f.Bridge,CSV:f.CSV,Calculation:f.Calculation,Calendar:f.Calendar$1,Caret:f.Caret,Channel:f.Channel,Check:f.Check,Circle:f.Circle,Click:f.Click,Close:f.Close,Cluster:f.Cluster,Commit:f.Commit,Concepts:f.Concepts,Connect:f.Connect,Constant:f.Constant,Control:f.Control,Copy:f.Copy,Decimal:f.Decimal,Delete:f.Delete,Details:f.Details,Device:f.Device,Disable:f.Disable,Disconnect:f.Disconnect,Download:f.Download,Downsample:f.Downsample,Drag:f.Drag,Dynamic:f.Dynamic,Edit:f.Edit,EditOff:f.EditOff,Enable:f.Enable,Expand:f.Expand,Explore:f.Explore,Export:f.Export,Feedback:f.Feedback,Filter:f.Filter,Focus:f.Focus,Function:f.Function,Group:f.Group,Guide:f.Guide,Hardware:f.Hardware,Heart:f.Heart,Hidden:f.Hidden,Import:f.Import,Index:f.Index,Info:f.Info,JSON:f.JSON,Keyboard:f.Keyboard,Label:f.Label,LinePlot:f.LinePlot,Linear:f.Linear,Link:f.Link,LinkExternal:f.LinkExternal,Loading:f.Loading,Log:f.Log,Logo:f.Logo,Map:f.Map,Menu:f.Menu$1,MoveToMainWindow:f.MoveToMainWindow,NPM:f.NPM,Node:f.Node,None:f.None,OpenExternal:f.OpenExternal,OpenInNewWindow:f.OpenInNewWindow,PNPM:f.PNPM,Pan:f.Pan,Pause:f.Pause,Play:f.Play,Python:f.Python,QuestionMark:f.QuestionMark,Rack:f.Rack,Range:f.Range,Reference:f.Reference,Refresh:f.Refresh,Release:f.Release,Rename:f.Rename,Resources:f.Resources,Rotate:f.Rotate,Rule:f.Rule,Save:f.Save,Schematic:f.Schematic,Search:f.Search,Selection:f.Selection,Settings:f.Settings,Snapshot:f.Snapshot,Snooze:f.Snooze,Sound:f.Sound,SplitX:f.SplitX,SplitY:f.SplitY,StarFilled:f.StarFilled,StarOutlined:f.StarOutlined,String:f.String,StrokeWidth:f.StrokeWidth,Subtract:f.Subtract,Sync:f.Sync,Table:f.Table,Tare:f.Tare,Task:f.Task,Terminal:f.Terminal,Text:f.Text$3,TextAlign:f.TextAlign,Time:f.Time$1,Tooltip:f.Tooltip,Type:f.Type,TypeScript:f.TypeScript,Units:f.Units,User:f.User,Value:f.Value,Variable:f.Variable,Virtual:f.Virtual,Visible:f.Visible,Visualize:f.Visualize,Warning:f.Warning,Wave:f.Wave,Workspace:f.Workspace,Yarn:f.Yarn,Zoom:f.Zoom,createComposite:f.createComposite,resolve:f.resolve,wrapSVGIcon:f.wrapSVGIcon},Symbol.toStringTag,{value:"Module"})),hg=Object.freeze(Object.defineProperty({__proto__:null,Config:f.Config,Dialog:f.Dialog$1,chooseLocation:f.chooseLocation,formatTip:f.formatTip,useConfig:f.useConfig,wrap:f.wrap},Symbol.toStringTag,{value:"Module"})),Jo=({ref:e,location:t,style:n,size:s,className:r,children:i,onDragStart:l,sizeUnits:a="px",showHandle:c=!0,...d})=>{const x=u.K$1.construct(t),p=u.K$1.direction(x),m=u.p.dimension(p);return o.jsxRuntimeExports.jsxs(f.Box,{className:u.CSS(u.CSS.B("resize"),u.CSS.loc(x),r),style:{[m]:`${s}${a}`,...n},ref:e,direction:p,empty:!0,...d,children:[i,c&&o.jsxRuntimeExports.jsx("div",{draggable:!0,className:u.CSS(u.CSS.BE("resize","handle"),u.CSS.bordered(u.K$1.swap(x))),onDragStart:l,onDrag:f.preventDefault,onDragEnd:f.preventDefault})]})},Ql=({onResize:e,count:t,initialSizes:n=[],minSize:s=100,direction:r="x"})=>{const i=j.useRef(null),[l,a]=j.useState({sizeDistribution:gg(n,t),root:null}),c=j.useCallback((p,m,h)=>{if(i.current==null)return;const g=u.Ho.dim(u.Ho.construct(i.current),r);a(E=>ro(E,g,p,s,m,h))},[s,a,r]);j.useEffect(()=>e?.(l.sizeDistribution),[l.sizeDistribution,e]);const d=j.useCallback((p,m)=>{p.preventDefault();const h=r==="x"?"clientX":"clientY",g=S=>c(m,S[h]),E=()=>{a(S=>({...S,root:null})),document.removeEventListener("mousemove",g)};a(S=>({...S,root:p[h]})),document.addEventListener("mousemove",g),document.addEventListener("mouseup",E,{once:!0})},[a,r,ro]);return{setSize:j.useCallback((p,m)=>c(p,void 0,m),[ro]),props:{direction:r,sizeDistribution:l.sizeDistribution,onDragHandle:d,ref:i}}},Jl=({ref:e,direction:t="x",children:n,sizeDistribution:s,onDragHandle:r,className:i,...l})=>{const a=u.p.construct(t),c=j.Children.toArray(n);return s=jg(s),o.jsxRuntimeExports.jsx(f.Box,{...l,ref:e,direction:a,className:u.CSS(u.CSS.B("resize-multiple"),i),empty:!0,grow:!0,children:c.map((d,x)=>o.jsxRuntimeExports.jsx(Jo,{onDragStart:p=>r(p,x),location:u.p.location(a),size:s[x]*100,sizeUnits:"%",showHandle:x!==c.length-1,children:d},x))})},gg=(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)},oo=.001,jg=e=>e.every(t=>u.or.closeTo(t,1/e.length),oo)?e.map((t,n)=>n%2===0?t+oo:n===e.length-1?t:t-oo):e,ro=(e,t,n,s,r,i)=>{const l=ea(e,t,n,r,i),[a,c]=Eg(e.sizeDistribution,n,l,s/t),d=c?r??null:e.root;return{...e,sizeDistribution:a,root:d}},ea=(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},Eg=(e,t,n,s)=>{let r=t;for(;r>0&&e[r]+n<=s;)r--;const i=e[r]+n,l=yg(r,e,s,n),a=e[l]-n;return i<s||a<s?[e,!1]:[e.map((c,d)=>d===r?i:d===l?a:c),!0]},yg=(e,t,n,s)=>(e===t.length-1?Rg:Sg)(e,t,n,s),Sg=(e,t,n,s)=>{let r=e+1;for(;r<t.length-1&&t[r]-s<=n;)r++;return r},Rg=(e,t,n,s)=>{let r=e-1;for(;r>0&&t[r]-s<=n;)r--;return r},io=2,Cg=100,ta=({onCollapse:e,onResize:t,location:n="left",minSize:s,maxSize:r,initialSize:i=200,collapseThreshold:l=1/0,className:a,...c})=>{const[d,x]=j.useState(u.R(i,s,r)),p=j.useRef(null),m=u.K$1.construct(n),h=j.useCallback(y=>{if(p.current===null)return 0;const C=u.Ho.dim(y,u.K$1.direction(m),!0)*(1-2*Number(["bottom","right"].includes(m))),_=p.current+C,M=u.R(_,s,r);return(M-_)/(s??Cg)>l?io:M},[m,s,r,l]),g=j.useRef(null),E=j.useCallback(y=>{const C=h(y);x(C),g.current!=null&&t?.(C,u.Ho.construct(g.current))},[t,h]),S=j.useCallback(()=>x(y=>(p.current=y,y)),[x]),R=j.useCallback(y=>h(y)===io&&e?.(),[e,h]);j.useEffect(()=>{s==null||r==null||x(y=>{const C=u.R(y,s,r);return p.current=C,C})},[s,r]);const v=Pe.useCursorDrag({onMove:E,onStart:S,onEnd:R});return o.jsxRuntimeExports.jsx(Jo,{ref:g,location:m,size:d,onDragStart:v,className:u.clsx(a,u.CSS.expanded(d!==io)),...c})},wg=Object.freeze(Object.defineProperty({__proto__:null,Core:Jo,Multiple:Jl,Single:ta,calculateDiffPercentage:ea,useMultiple:Ql},Symbol.toStringTag,{value:"Module"})),er=({aetherKey:e,enabled:t=!0})=>{const{setState:n}=f.useLifecycle({aetherKey:e,type:P.Eraser.TYPE,schema:P.eraserStateZ,initialState:{region:u.Ho.ZERO,enabled:t}}),s=f.useSyncedRef(t);return{erase:j.useCallback(i=>{n({enabled:s.current,region:i})},[n,s])}},bg=({aetherKey:e,children:t})=>{const{erase:n}=er({aetherKey:e}),s=f.useResize(n);return o.jsxRuntimeExports.jsx("div",{ref:s,className:u.CSS(u.CSS.inheritDims()),children:t})},vg=Object.freeze(Object.defineProperty({__proto__:null,Eraser:bg,use:er},Symbol.toStringTag,{value:"Module"})),_g=({items:e,initialKey:t})=>{const[n,s]=j.useState(t),r=l=>s(l===n?void 0:l),i=e.find(l=>l.key===n);return{onSelect:r,activeItem:i}},kg=({activeItem:e,children:t,onSelect:n,location:s="left",collapseThreshold:r=.65,className:i,onResize:l,onCollapse:a,eraseEnabled:c,...d})=>{const x=u.K$1.direction(s);c??=e!=null;const p=j.useCallback(()=>{a?a():e!=null&&n?.(e.key)},[n,e?.key,a]),{erase:m}=er({enabled:c}),h=j.useCallback((v,y)=>{l?.(v,y),m(y)},[l,m]),{content:g,minSize:E,maxSize:S,initialSize:R=0}=e??{};return o.jsxRuntimeExports.jsx(ta,{className:u.CSS(u.CSS.B("nav-drawer"),u.CSS.dir(x),u.CSS.visible(e!=null),i),collapseThreshold:r,onCollapse:p,location:s,onResize:h,minSize:E,maxSize:S,initialSize:R,...d,children:g})},Lg=Object.freeze(Object.defineProperty({__proto__:null,Bar:f.Bar,Drawer:kg,useDrawer:_g},Symbol.toStringTag,{value:"Module"})),tr={info:"var(--pluto-text-color)",error:"var(--pluto-error-z)",warning:"var(--pluto-warning-m1)",success:"var(--pluto-primary-z)",loading:"var(--pluto-text-color)",disabled:"var(--pluto-gray-l8)"},nr=({variant:e,...t})=>e==="loading"?o.jsxRuntimeExports.jsx(f.Loading,{...t}):o.jsxRuntimeExports.jsx(f.Circle,{color:e!=null?tr[e]:void 0,...t}),Mg=({action:e})=>j.isValidElement(e)?e:j.createElement(f.Button,{...e,key:e.key,size:"tiny"}),Ng=({status:{key:e,time:t,count:n,message:s,description:r,variant:i},silence:l,actions:a,className:c,children:d,...x})=>{const p=j.useRef(null);return o.jsxRuntimeExports.jsxs(f.Box,{className:u.CSS(u.CSS.B("notification"),c),y:!0,empty:!0,ref:p,...x,children:[o.jsxRuntimeExports.jsxs(f.Box,{x:!0,justify:"between",grow:!0,style:{width:"100%"},children:[o.jsxRuntimeExports.jsxs(f.Box,{x:!0,align:"center",gap:"small",children:[o.jsxRuntimeExports.jsx(nr,{style:{height:"2.25rem",width:"2.5rem"},variant:i}),o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:`x${n}`}),o.jsxRuntimeExports.jsx(f.DateTime,{className:u.CSS(u.CSS.BE("notification","time")),level:"small",format:"time",children:t})]}),o.jsxRuntimeExports.jsx(f.Button,{className:u.CSS(u.CSS.BE("notification","silence")),variant:"outlined",size:"small",onClick:()=>l(e),children:o.jsxRuntimeExports.jsx(f.Close,{})})]}),o.jsxRuntimeExports.jsxs(f.Box,{y:!0,align:"start",className:u.CSS(u.CSS.BE("notification","content")),gap:"small",children:[d??o.jsxRuntimeExports.jsx(f.Text,{className:u.CSS(u.CSS.BE("notification","message")),style:{flexGrow:1},children:s}),r!=null&&o.jsxRuntimeExports.jsx(f.Text,{className:u.CSS(u.CSS.BE("notification","description")),level:"small",style:{flexGrow:1},children:r})]}),a!=null&&o.jsxRuntimeExports.jsx(f.Box,{x:!0,align:"center",justify:"end",className:u.CSS(u.CSS.BE("notification","actions")),children:P.t.toArray(a).map(m=>o.jsxRuntimeExports.jsx(Mg,{action:m},m.key))})]},t.toString())},Pg=Object.freeze(Object.defineProperty({__proto__:null,Aggregator:f.Aggregator,Indicator:nr,Notification:Ng,Summary:f.Summary,VARIANT_COLORS:tr,useAdder:f.useAdder,useAsyncErrorHandler:f.useAsyncErrorHandler,useErrorHandler:f.useErrorHandler,useNotifications:f.useNotifications},Symbol.toStringTag,{value:"Module"})),na=e=>e==="preview"?"connected":e,sa=e=>e==="preview"?"preview":void 0,Ms=({resourceName:e,value:t,onChange:n,data:s,getItem:r,subscribe:i,haulType:l,icon:a,disabled:c,onSearch:d,emptyContent:x,status:p,onFetchMore:m,children:h,renderTag:g,actions:E,allowNone:S,replaceOnSingle:R,triggerProps:v,virtual:y=!0,dialogProps:C,variant:_="connected",...M})=>o.jsxRuntimeExports.jsx(f.Frame,{variant:na(_),...M,children:o.jsxRuntimeExports.jsxs(f.Frame$1,{multiple:!0,value:t,onChange:n,data:s,getItem:r,subscribe:i,onFetchMore:m,allowNone:S,replaceOnSingle:R,virtual:y,children:[o.jsxRuntimeExports.jsx(ra,{haulType:l,icon:a,placeholder:`Select ${e}s`,disabled:c,variant:sa(_),...v,children:g}),o.jsxRuntimeExports.jsx(f.Dialog$2,{onSearch:d,emptyContent:x,status:p,actions:E,resourceName:e,...C,children:h})]})}),Xe=(e,t)=>{const n={};t.forEach(r=>n[r]=void 0);const s=r=>{const{...i}={...r,...n};return o.jsxRuntimeExports.jsx(e,{...i})};return s.displayName=`RemoveProps(${e.displayName})`,s},oa=e=>o.jsxRuntimeExports.jsxs(pe.Buttons,{...e,keys:P.SIZES,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"tiny",children:"L"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"small",children:"M"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"medium",children:"L"})]}),Tg=Object.freeze(Object.defineProperty({__proto__:null,SIZES:P.SIZES,SelectSize:oa,isRenderProp:f.isRenderProp,isSize:P.isSize,removeProps:Xe,renderProp:f.renderProp,size:P.size},Symbol.toStringTag,{value:"Module"})),Ns=({children:e="",size:t="medium",color:n,icon:s,onClose:r,className:i,onDragStart:l,...a})=>{const c=u.cr.cssString(n);s==null&&n!=null&&(s=o.jsxRuntimeExports.jsx(f.Circle,{color:c}));const d=r==null?void 0:o.jsxRuntimeExports.jsx(f.Button,{"aria-label":"close",size:t==="tiny"?"small":t,variant:"text",className:u.CSS.BE("tag","close"),sharp:!0,onClick:x=>{x.stopPropagation(),r()},children:o.jsxRuntimeExports.jsx(f.Close,{})});return o.jsxRuntimeExports.jsxs(f.Button,{el:"div",className:u.CSS(i,u.CSS.B("tag"),r!=null&&u.CSS.BM("tag","closeable")),size:t,overflow:"nowrap",align:"center",gap:"small",onDragStart:l,...a,children:[s,d,e]})},sr=({children:e,onClick:t,variant:n="outlined",size:s="medium",...r})=>o.jsxRuntimeExports.jsx(f.Button,{el:"div",variant:n,size:s,x:!0,onClick:t,align:"center",gap:"small",style:{padding:"0rem 0.5rem",paddingRight:"2rem"},rounded:!0,...r,children:e}),Ig=Object.freeze(Object.defineProperty({__proto__:null,Tag:Ns,Tags:sr},Symbol.toStringTag,{value:"Module"})),Og=({itemKey:e,icon:t,onDragStart:n})=>{const s=f.useItem(e),{onSelect:r}=f.useItemState(e);return o.jsxRuntimeExports.jsx(Ns,{onClose:r,onDragStart:()=>n(e),draggable:!0,size:"small",status:s==null?"error":void 0,icon:s?.icon??t,children:s?.name??e})},Ag=f.renderProp(Og),or=({items:e},t,n,s)=>{if(t===""||s===!0)return!1;const r=f.filterByType(t,e);return r.length>0&&!r.every(i=>n.includes(i.key))},ra=({haulType:e="",disabled:t,placeholder:n="Select...",variant:s="outlined",icon:r,children:i=Ag})=>{const l=f.useSelection(),a=f.useSyncedRef(l),{setSelected:c}=f.useContext$3(),{toggle:d,visible:x}=f.useContext$2(),p=j.useCallback(v=>or(v,e,P.t.toArray(l),t),[e,l,t]),{startDrag:m,...h}=f.useDragAndDrop({type:e,canDrop:p,onDrop:f.useFilterByTypeCallback(e,({items:v})=>{const y=P.t.toArray(a.current);return c(u.c.unique([...P.t.toArray(y),...v.map(C=>C.key)])),v},[c])}),g=j.useCallback(({dropped:v})=>{const y=l.filter(C=>!v.some(_=>_.key===C));c(y)},[c,l]),E=j.useCallback(v=>{m([{key:v,type:e}],g)},[m,g,e]),S=f.useDraggingState(),R=s==="text"&&l.length!==0;return o.jsxRuntimeExports.jsxs(sr,{full:"x",onClick:()=>{R||d()},...h,className:u.CSS(u.CSS.dropRegion(p(S)),u.CSS.BE("dialog","trigger"),u.CSS.BM("variant",s)),variant:s,preventClick:R,grow:!0,children:[l.length===0&&o.jsxRuntimeExports.jsxs(f.Text,{color:8,weight:400,style:{padding:"0 1rem"},children:[r,n]}),l.map(v=>i({key:v,itemKey:v,onDragStart:E,icon:r})),s!=="text"&&o.jsxRuntimeExports.jsx($l.Animated,{className:u.CSS.level("p"),enabled:x,enabledLoc:"bottom",disabledLoc:"left",color:8}),R&&o.jsxRuntimeExports.jsx(f.Button,{variant:s,onClick:v=>{v.stopPropagation(),d()},children:o.jsxRuntimeExports.jsx(f.Add,{color:8})})]})},Ot=({resourceName:e,onChange:t,value:n,allowNone:s,emptyContent:r,haulType:i,data:l,getItem:a,subscribe:c,itemHeight:d,onFetchMore:x,disabled:p,onSearch:m,status:h,icon:g,children:E,variant:S="connected",actions:R,dialogProps:v,triggerProps:y,virtual:C=!0,closeDialogOnSelect:_=!0,...M})=>o.jsxRuntimeExports.jsx(f.Frame,{...M,variant:na(S),children:o.jsxRuntimeExports.jsxs(f.Frame$1,{value:n,onChange:t,data:l,getItem:a,subscribe:c,allowNone:s,onFetchMore:x,itemHeight:d,virtual:C,closeDialogOnSelect:_,children:[o.jsxRuntimeExports.jsx(ia,{haulType:i,icon:g,placeholder:`Select a ${e}`,disabled:p,variant:sa(S),...y}),o.jsxRuntimeExports.jsx(f.Dialog$2,{onSearch:m,resourceName:e,emptyContent:r,status:h,actions:R,...v,children:E})]})}),ia=({haulType:e="",placeholder:t,icon:n,disabled:s,iconOnly:r=!1,hideCaret:i=!1,...l})=>{const a=f.useSelection(),{setSelected:c}=f.useContext$3(),[d]=a,x=f.useItem(d),{name:p,icon:m}=x??{},h=j.useCallback(S=>or(S,e,a,s),[e,a,s]),g=f.useDrop({type:e,canDrop:h,onDrop:f.useFilterByTypeCallback(e,({items:S})=>(S.length!==0&&c([S[0].key]),S),[c])}),E=f.useDraggingState();return o.jsxRuntimeExports.jsxs(Fl.Trigger,{variant:"outlined",gap:"small",className:u.CSS(u.CSS.dropRegion(h(E))),disabled:s,...g,...l,hideCaret:i||r,textColor:p==null?8:void 0,children:[m??n,!r&&(p??t)]})},Dg=f.renderProp(e=>{const{itemKey:t}=e,n=f.useItem(t);if(n==null)return null;const{name:s,icon:r}=n;return o.jsxRuntimeExports.jsxs(f.ListItem,{...e,children:[r,s]})}),Pn=({data:e,filter:t,children:n=Dg,virtual:s=!1,...r})=>{const{retrieve:i,...l}=f.useStaticData({data:e,filter:t}),{search:a}=nt.usePager({retrieve:i});return o.jsxRuntimeExports.jsx(Ot,{...r,...l,onSearch:a,virtual:s,children:n})},on=e=>o.jsxRuntimeExports.jsxs(pe.Buttons,{...e,keys:P.LEVELS,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"h2",square:!0,children:"XL"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"h3",square:!0,children:"L"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"h4",square:!0,children:"M"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"h5",square:!0,children:"S"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"small",square:!0,children:"XS"})]}),Bg=[250,400,500,600],la=e=>o.jsxRuntimeExports.jsxs(pe.Buttons,{...e,keys:Bg,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:250,children:"Light"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:400,children:"Normal"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:500,children:"Medium"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:600,children:"Bold"})]}),$g=Object.freeze(Object.defineProperty({__proto__:null,Level:on,Weight:la},Symbol.toStringTag,{value:"Module"})),zg=Object.freeze(Object.defineProperty({__proto__:null,Button:pe.Button,Buttons:pe.Buttons,Core:f.Core,Dialog:f.Dialog$2,Frame:f.Frame$1,ListItem:f.ListItem,Multiple:Ms,MultipleTrigger:ra,Single:Ot,SingleTrigger:ia,Static:Pn,Text:$g,staticCanDrop:or,useClear:f.useClear,useContext:f.useContext$3,useHover:f.useHover,useItemState:f.useItemState,useMultiple:f.useMultiple,useSelection:f.useSelection,useSingle:f.useSingle},Symbol.toStringTag,{value:"Module"})),Vg=()=>o.jsxRuntimeExports.jsx(f.Caret.Right,{className:u.CSS.BE("breadcrumb","separator")}),Rn=({children:e,...t})=>o.jsxRuntimeExports.jsx(f.Text,{className:u.CSS.BE("breadcrumb","segment"),...t,defaultEl:"span",children:e}),rr=({children:e,highlightVariant:t,...n})=>o.jsxRuntimeExports.jsx(f.Text,{className:u.CSS(u.CSS.B("breadcrumb"),t!=null&&u.CSS.BM("breadcrumb","highlight",t)),x:!0,align:"center",gap:"small",...n,children:j.Children.map(e,(s,r)=>s==null||typeof s=="boolean"?null:o.jsxRuntimeExports.jsxs(j.Fragment,{children:[r>0&&o.jsxRuntimeExports.jsx(Vg,{}),typeof s=="string"?o.jsxRuntimeExports.jsx(Rn,{children:s}):s]},r))}),Fg=(e,t)=>{const n=e.split("/");return n.map((s,r)=>t({href:n.slice(0,r+1).join("/"),segment:s,index:r}))},Hg=Object.freeze(Object.defineProperty({__proto__:null,Breadcrumb:rr,Segment:Rn,mapURLSegments:Fg},Symbol.toStringTag,{value:"Module"})),Zg=({channelKey:e,rangeKey:t,shadow:n,className:s,...r})=>{const{value:i,onChange:l}=r,[a,c]=j.useState(!1),{update:d}=Ja.useDirect({params:{rangeKey:t,channelKey:e}}),{data:x}=Rr.useDirect({params:{key:e,rangeKey:t}}),p=async C=>{d(C)},m=x?.alias,h=x?.alias??x?.name;let g=o.jsxRuntimeExports.jsx(f.Rename,{});a?g=o.jsxRuntimeExports.jsx(f.Loading,{}):m===i&&(g=o.jsxRuntimeExports.jsx(f.Check,{}));const E=p!=null&&!a&&m!==i&&e!==0,S=f.useErrorHandler(),R=()=>{E&&S(async()=>{c(!0);try{await p(i),c(!1)}catch(C){throw c(!1),C}},"Failed to set channel alias")},v=()=>{m!=null&&l?.(m)},y=e===0?o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:"Select a channel to enable alias syncing with this label"}):p==null?o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:"Select a range to enable alias syncing with this label"}):i.length===0?o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:"Enter a value to enable alias syncing with this label"}):m===i?o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:"Alias synced with this label"}):o.jsxRuntimeExports.jsxs(f.Text,{level:"small",children:["Sync alias for ",h," with this label"]});return o.jsxRuntimeExports.jsxs(f.Text$2,{selectOnFocus:!0,...r,children:[E&&o.jsxRuntimeExports.jsx(f.Button,{onClick:v,tooltip:o.jsxRuntimeExports.jsxs(f.Text,{level:"small",children:["Set ",h," as label"]}),tooltipLocation:{y:"top"},variant:"outlined",children:o.jsxRuntimeExports.jsx(f.Sync,{})}),o.jsxRuntimeExports.jsx(f.Button,{onClick:R,disabled:!E,tooltip:y,tooltipLocation:{y:"top"},variant:"outlined",children:g})]})},vt="channel";var Ei=180/Math.PI,vo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function aa(e,t,n,s,r,i){var l,a,c;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(c=e*n+t*s)&&(n-=e*c,s-=t*c),(a=Math.sqrt(n*n+s*s))&&(n/=a,s/=a,c/=a),e*s<t*n&&(e=-e,t=-t,c=-c,l=-l),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Ei,skewX:Math.atan(c)*Ei,scaleX:l,scaleY:a}}var Gn;function Kg(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?vo:aa(t.a,t.b,t.c,t.d,t.e,t.f)}function Yg(e){return e==null||(Gn||(Gn=document.createElementNS("http://www.w3.org/2000/svg","g")),Gn.setAttribute("transform",e),!(e=Gn.transform.baseVal.consolidate()))?vo:(e=e.matrix,aa(e.a,e.b,e.c,e.d,e.e,e.f))}function ca(e,t,n,s){function r(d){return d.length?d.pop()+" ":""}function i(d,x,p,m,h,g){if(d!==p||x!==m){var E=h.push("translate(",null,t,null,n);g.push({i:E-4,x:O.interpolateNumber(d,p)},{i:E-2,x:O.interpolateNumber(x,m)})}else(p||m)&&h.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:O.interpolateNumber(d,x)})):x&&p.push(r(p)+"rotate("+x+s)}function a(d,x,p,m){d!==x?m.push({i:p.push(r(p)+"skewX(",null,s)-2,x:O.interpolateNumber(d,x)}):x&&p.push(r(p)+"skewX("+x+s)}function c(d,x,p,m,h,g){if(d!==p||x!==m){var E=h.push(r(h)+"scale(",null,",",null,")");g.push({i:E-4,x:O.interpolateNumber(d,p)},{i:E-2,x:O.interpolateNumber(x,m)})}else(p!==1||m!==1)&&h.push(r(h)+"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),a(d.skewX,x.skewX,p,m),c(d.scaleX,d.scaleY,x.scaleX,x.scaleY,p,m),d=x=null,function(h){for(var g=-1,E=m.length,S;++g<E;)p[(S=m[g]).i]=S.x(h);return p.join("")}}}var Gg=ca(Kg,"px, ","px)","deg)"),Ug=ca(Yg,", ",")",")"),Wg=1e-12;function yi(e){return((e=Math.exp(e))+1/e)/2}function Xg(e){return((e=Math.exp(e))-1/e)/2}function qg(e){return((e=Math.exp(2*e))-1)/(e+1)}const rs=function e(t,n,s){function r(i,l){var a=i[0],c=i[1],d=i[2],x=l[0],p=l[1],m=l[2],h=x-a,g=p-c,E=h*h+g*g,S,R;if(E<Wg)R=Math.log(m/d)/t,S=function(I){return[a+I*h,c+I*g,d*Math.exp(t*I*R)]};else{var v=Math.sqrt(E),y=(m*m-d*d+s*E)/(2*d*n*v),C=(m*m-d*d-s*E)/(2*m*n*v),_=Math.log(Math.sqrt(y*y+1)-y),M=Math.log(Math.sqrt(C*C+1)-C);R=(M-_)/t,S=function(I){var A=I*R,B=yi(_),z=d/(n*v)*(B*qg(t*A+_)-Xg(_));return[a+z*h,c+z*g,d*B/yi(t*A+_)]}}return S.duration=R*1e3*t/Math.SQRT2,S}return r.rho=function(i){var l=Math.max(.001,+i),a=l*l,c=a*a;return e(l,a,c)},r}(Math.SQRT2,2,4),Qg=Object.freeze(Object.defineProperty({__proto__:null,Base:O.Base,Bottom:O.Bottom,Right:O.Right,Top:O.Top,axisStateZ:O.axisStateZ,newCanvas:O.newCanvas,newTickFactory:O.newTickFactory,tickFactoryProps:O.tickFactoryProps,tickType:O.tickType},Symbol.toStringTag,{value:"Module"})),Jg=Object.freeze(Object.defineProperty({__proto__:null,AcquireChannelControl:O.AcquireChannelControl,AuthoritySource:O.AuthoritySource,Chip:O.Chip,Controller:O.Controller,Indicator:O.Indicator,Legend:O.Legend,REGISTRY:O.REGISTRY$15,STATUSES:O.STATUSES,SetChannelValue:O.SetChannelValue,StateProvider:O.StateProvider,acquireChannelControl:O.acquireChannelControl,acquireChannelControlPropsZ:O.acquireChannelControlPropsZ,authoritySource:O.authoritySource,authoritySourceDetailsZ:O.authoritySourceDetailsZ,authoritySourceProps:O.authoritySourceProps,chipStateZ:O.chipStateZ,chipStatusDetailsZ:O.chipStatusDetailsZ,controllerStateZ:O.controllerStateZ,indicatorStateZ:O.indicatorStateZ,indicatorStatusDetailsZ:O.indicatorStatusDetailsZ,legendStateZ:O.legendStateZ,setChannelValue:O.setChannelValue,setChannelValuePropsZ:O.setChannelValuePropsZ,stateProviderStateZ:O.stateProviderStateZ,statusZ:O.statusZ,sugaredStateZ:O.sugaredStateZ},Symbol.toStringTag,{value:"Module"})),e1={region:u.Ho.ZERO,dpr:1,os:u.S.getOS()},t1={gl:null,lower2d:null,upper2d:null,bootstrapped:!1},n1=({children:e,resizeDebounce:t=100,className:n,...s})=>{const[{path:r},{bootstrapped:i,dpr:l},a]=f.use$2({type:O.Canvas.TYPE,schema:O.canvasStateZ,initialState:e1}),c=j.useRef({...t1}),d=j.useRef(!1),x=j.useCallback(E=>{c.current.bootstrapped&&(a(()=>({bootstrapped:!0,region:E,dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})})),d.current=!0)},[a]),p=j.useRef(null),m=f.useResize(x,{debounce:t}),h=f.useCombinedRefs(p,m);j.useEffect(()=>{const E=()=>{window.devicePixelRatio===l||!c.current.bootstrapped||p.current==null||a(S=>({...S,region:u.Ho.construct(p.current),dpr:window.devicePixelRatio}))};window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`).addEventListener("change",E,{once:!0})},[l]),j.useEffect(()=>{const E=()=>{!c.current.bootstrapped||p.current==null||a(S=>({...S,region:u.Ho.construct(p.current),glCanvas:void 0,upper2dCanvas:void 0,lower2dCanvas:void 0}))};window.addEventListener("focus",E),window.addEventListener("blur",E)},[a]);const g=j.useCallback(E=>{if(E==null)return;E.className.includes("gl")?c.current.gl=E:E.className.includes("upper2d")?c.current.upper2d=E:c.current.lower2d=E;const{gl:S,lower2d:R,upper2d:v,bootstrapped:y}=c.current;if(S==null||R==null||v==null||y)return;c.current.bootstrapped=!0;const C=S.transferControlToOffscreen(),_=v.transferControlToOffscreen(),M=R.transferControlToOffscreen();a({glCanvas:C,upper2dCanvas:_,lower2dCanvas:M,bootstrap:!0,bootstrapped:!1,region:u.Ho.construct(S),dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})},[C,_,M])},[a]);return o.jsxRuntimeExports.jsxs("div",{ref:h,className:u.CSS(u.CSS.B("canvas-container"),n),...s,children:[o.jsxRuntimeExports.jsx("canvas",{ref:g,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","lower2d"))}),o.jsxRuntimeExports.jsx("canvas",{ref:g,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","gl"))}),o.jsxRuntimeExports.jsx("canvas",{ref:g,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","upper2d"))}),o.jsxRuntimeExports.jsx(f.Composite,{path:r,children:i&&e})]})},Tn=(e,t)=>f.useResize(j.useCallback((n,s)=>{const r=document.querySelector(".pluto-canvas--lower2d");r!=null&&e(u.C.XY.translate(u.K.scale(u.Ho.topLeft(r),-1)).box(n),s)},[e]),t),s1=Object.freeze(Object.defineProperty({__proto__:null,Canvas:n1,useRegion:Tn},Symbol.toStringTag,{value:"Module"})),ua=j.createContext(null),ct=e=>{const t=j.use(ua);if(t==null)throw new Error(`Cannot use ${e} as a non-child of LinePlot.`);return t},da=e=>{const{addViewportHandler:t}=ct("Viewport");j.useEffect(()=>t(e),[t,e])},In=(e,t)=>{const{setGridEntry:n,removeGridEntry:s}=ct(t),{key:r}=e;return f.useEffectCompare(()=>{u.K$1.outer.parse(e.loc),n(e)},([a],[c])=>P.N.equal(a,c),[e]),j.useEffect(()=>()=>s(r),[]),{gridArea:u.p.swap(u.K$1.direction(e.loc))==="x"?`axis-start-${r} / plot-start / axis-end-${r} / plot-end`:`plot-start / axis-start-${r} / plot-end / axis-end-${r}`}},xa=({aetherKey:e,style:t,resizeDebounce:n=0,clearOverScan:s=u.K.ZERO,children:r,hold:i=!1,onHold:l,visible:a,...c})=>{const[d,x]=j.useState([]),p=f.useMemoDeepEqual({clearOverScan:s,hold:i,visible:a}),[{path:m},{grid:h},g]=f.use$2({aetherKey:e,type:O.LinePlot.TYPE,schema:O.linePlotStateZ,initialState:{container:u.Ho.ZERO,viewport:u.Ho.DECIMAL,grid:{},...p}}),E=j.useCallback(D=>{a&&g(V=>({...V,container:D}))},[g,a]),S=Tn(E,{debounce:n});j.useEffect(()=>g(D=>({...D,...p})),[p]);const R=j.useRef(new Map),v=j.useCallback(D=>(R.current.set(D,null),()=>R.current.delete(D)),[R]),y=j.useCallback(D=>{const{mode:V,box:b,stage:k}=D;(V==="pan"&&k!=="start"||V==="zoom"||V==="zoomReset"&&k==="start")&&g(L=>({...L,viewport:b})),R.current.forEach((L,N)=>N(D))},[g]),C=j.useCallback(D=>{g(V=>({...V,grid:{...V.grid,[D.key]:D}}))},[g]),_=j.useCallback(D=>g(V=>{const{[D]:b,...k}=V.grid;return{...V,grid:k}}),[g]),M=j.useCallback(D=>{x(V=>[...V.filter(({key:b})=>b!==D.key),D])},[x]),I=j.useCallback(D=>x(V=>V.filter(({key:b})=>b!==D)),[M]),A=j.useMemo(()=>o1(h),[h]),B=j.useCallback(D=>{g(V=>({...V,hold:D})),l?.(D)},[g,l]),z=`line-plot-${e}`,$=j.useMemo(()=>({lines:d,setGridEntry:C,removeGridEntry:_,setLine:M,removeLine:I,setViewport:y,addViewportHandler:v,setHold:B,id:z}),[z,d,C,_,M,I,y,v,B]);return o.jsxRuntimeExports.jsx("div",{id:z,className:u.CSS.B("line-plot"),style:{...t,...A},ref:S,...c,children:o.jsxRuntimeExports.jsx(ua,{value:$,children:o.jsxRuntimeExports.jsx(f.Composite,{path:m,children:r})})})},o1=e=>{const t=u.CSS.newGridBuilder();return O.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)"),O.regions("bottom",e).reverse().forEach(({key:n,size:s})=>t.row(`axis-start-${n}`,`axis-end-${n}`,s)),O.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)"),O.regions("right",e).forEach(({key:n,size:s})=>t.col(`axis-start-${n}`,`axis-end-${n}`,s)),t.build()},ir=e=>{const t=e==="x"?"bottom":"left",n=e==="x"?O.XAxis.TYPE:O.YAxis.TYPE,s=`${e}-axis`,r=({aetherKey:i,children:l,location:a=t,label:c="",labelLevel:d="small",labelDirection:x=e,onLabelChange:p,color:m,labelSize:h,showGrid:g,type:E,bounds:S,className:R,tickSpacing:v,autoBounds:y,axisKey:C,autoBoundUpdateInterval:_,onAutoBoundsChange:M,style:I,...A})=>{const B=(c?.length??0)>0,z=f.useUniqueKey(i),$=f.useMemoDeepEqual({location:a,showGrid:g,type:E,bounds:S,axisKey:C,label:c,labelDirection:x,tickSpacing:v,autoBounds:y,autoBoundUpdateInterval:_}),[{path:D},{size:V,labelSize:b,...k},L]=f.use$2({aetherKey:z,type:n,schema:O.coreAxisStateZ,initialState:$});j.useEffect(()=>L(K=>({...K,...$})),[$]),j.useEffect(()=>{const{lower:K,upper:Z}=O.parseAutoBounds(k.autoBounds);k.bounds!=null&&(K&&S?.lower!==k.bounds.lower||Z&&S?.upper!==k.bounds.upper)&&M?.(k.bounds)},[k.autoBounds,k.bounds]);const N=In({loc:a,key:`${n}-${z}`,size:V+b,order:1},`${e.toUpperCase()}Axis`),F=ks.useTypography(d).toString(),H=j.useRef(0);return j.useEffect(()=>{if(e==="y"){if(c==null)return;let Z=P.dimensions(c,F)[u.p.dimension(u.p.construct(x))];Z>0&&(Z+=9),L(Y=>({...Y,labelSize:Z}))}else{let Z=P.dimensions(c,F).height*1.3;Z>0&&(Z+=12);const Y=H.current;O.withinSizeThreshold(Y,Z)||(H.current=Z,L(ne=>({...ne,labelSize:Z})))}},[c,x,F]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(f.Box,{className:u.CSS(R,u.CSS.B("axis"),u.CSS.B(s),u.CSS.loc(a)),style:{...I,...N},align:"center",justify:a!=="left"?"end":"start",direction:u.p.swap(e),...A,children:B&&o.jsxRuntimeExports.jsx(f.MaybeEditable,{className:u.CSS(u.CSS.BE("axis","label"),u.CSS.dir(x)),value:c,onChange:p,level:d})}),o.jsxRuntimeExports.jsx(f.Composite,{path:D,children:l})]})};return r.displayName=`${e.toUpperCase()}Axis`,r},pa=ir("x"),ma=ir("y"),r1=u.K.xy.extend({root:u.K$1.corner,units:te.z.object({x:te.z.enum(["px","decimal"]),y:te.z.enum(["px","decimal"])})}),i1=r1.partial({root:!0,units:!0}),l1=e=>{const t={};return t[e.root?.x??"left"]=e?.units?.x==="px"?`${e.x}px`:`${e.x*100}%`,t[e.root?.y??"top"]=e?.units?.y==="px"?`${e.y}px`:`${e.y*100}%`,t},a1=(e,t)=>{const n={x:e.x,y:e.y};if(t.current==null)return n;const s=u.Ho.construct(t.current),r=u.Ho.construct(t.current.parentElement);return e.units?.x==="decimal"?e.root?.x==="right"&&(n.x=1-e.x):e.root?.x==="right"?n.x=1-(e.x+u.Ho.width(s))/u.Ho.width(r):n.x/=u.Ho.width(r),e.units?.y==="decimal"?e.root?.y==="bottom"&&(n.y=1-e.y):e.root?.y==="bottom"?n.y=1-(e.y+u.Ho.height(s))/u.Ho.height(r):n.y/=u.Ho.height(r),n},c1=(e,t)=>{if(t.current==null)return null;const n=u.Ho.construct(t.current.parentElement),s=u.Ho.construct(t.current),r={x:e.x,y:e.y,root:{...u.K$1.TOP_LEFT},units:{x:"px",y:"px"}};return e.x>.8?(r.x=(1-e.x)*u.Ho.width(n)-u.Ho.width(s),r.root.x="right"):e.x<.2?r.x=e.x*u.Ho.width(n):r.units.x="decimal",e.y>.8?(r.y=(1-e.y)*u.Ho.height(n)-u.Ho.height(s),r.root.y="bottom"):e.y<.2?r.y=e.y*u.Ho.height(n):r.units.y="decimal",r.x=Math.round(r.x*100)/100,{...r,...u.K.truncate(r,3)}},Si=u.Ho.reRoot(u.Ho.DECIMAL,u.K$1.TOP_LEFT),u1={x:.1,y:.1,root:u.K$1.TOP_LEFT,units:{x:"decimal",y:"decimal"}},Ps=j.memo(({className:e,value:t,onChange:n,style:s,draggable:r=!0,initial:i=u1,...l})=>{const[a,c]=P.usePurePassthrough({value:t,onChange:n,initial:i}),d=j.useRef(a),x=f.useSyncedRef(r===!1),p=j.useRef(null);a!==null&&(s={...s,...l1(a)});const m=j.useCallback(g=>{if(p.current?.parentElement==null)return d.current;const E=u.Ho.construct(p.current.parentElement),S=u.C.XY.scale(E).scale(Si),R=S.box(u.Ho.construct(p.current)),v=u.C.XY.clamp(u.Ho.construct(u.Ho.topLeft(Si),{width:1-u.Ho.width(R),height:1-u.Ho.height(R)})),y=u.K.translate(u.K.construct(d.current),u.Ho.signedDims(S.box(g))),C=v.pos(y);return c1(C,p)},[]),h=Pe.useCursorDrag({onStart:j.useCallback(()=>{d.current=a1(d.current,p)},[]),onMove:j.useCallback(g=>{if(x.current)return;const E=m(g);E!==null&&c(E)},[]),onEnd:j.useCallback(g=>{if(x.current)return;const E=m(g);E!==null&&(d.current=E)},[])});return o.jsxRuntimeExports.jsx(f.Box,{className:u.CSS(e,u.CSS.B("legend")),bordered:!0,style:s,onDragStart:h,draggable:r,borderColor:5,ref:p,onDrag:f.preventDefault,onDragEnd:f.preventDefault,background:1,rounded:1,...l})});Ps.displayName="Legend.Container";const On=j.memo(({data:e,allowVisibleChange:t=!0,background:n=1,entryProps:s,...r})=>o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:e.sort((i,l)=>i.label.localeCompare(l.label)).map(({key:i,visible:l=!0,...a})=>o.jsxRuntimeExports.jsx(d1,{entry:{key:i,visible:l,...a},allowVisibleChange:t,background:n,...s,...r},i))}));On.displayName="Legend.Entries";const d1=({allowVisibleChange:e=!0,background:t,entry:n,onEntryChange:s,colorPickerVisible:r,onColorPickerVisibleChange:i,className:l,...a})=>{const{color:c,key:d,label:x,visible:p}=n;return o.jsxRuntimeExports.jsxs(f.Box,{align:"center",className:u.CSS(u.CSS.B("legend-entry"),l),gap:"small",x:!0,...a,children:[o.jsxRuntimeExports.jsxs(f.Box,{align:"center",gap:"small",x:!0,children:[o.jsxRuntimeExports.jsx(Pe.Swatch,{allowChange:s!=null,draggable:!1,onChange:m=>s?.({...n,color:m}),size:"tiny",value:c,visible:r,onVisibleChange:i}),o.jsxRuntimeExports.jsx(f.MaybeEditable,{color:n.visible?10:7,level:"small",onChange:m=>s?.({...n,label:m}),onDoubleClick:f.stopPropagation,overflow:"nowrap",value:x})]}),e&&o.jsxRuntimeExports.jsx(f.Button,{className:u.CSS.B("visible-toggle"),contrast:t,onClick:m=>{m.stopPropagation(),s?.({...n,visible:!p})},onDoubleClick:f.stopPropagation,size:"tiny",variant:"text",children:p?o.jsxRuntimeExports.jsx(f.Visible,{}):o.jsxRuntimeExports.jsx(f.Hidden,{})})]},d)},fa=({data:e,background:t=1,allowVisibleChange:n=!0,onEntryChange:s,position:r,onPositionChange:i,...l})=>{const[a,c]=j.useState(!1);return e.length===0?null:o.jsxRuntimeExports.jsx(Ps,{...l,draggable:!a,value:r,onChange:i,gap:"small",background:t,className:u.CSS.B("legend-grouped"),children:e.map(({key:d,name:x,data:p},m)=>o.jsxRuntimeExports.jsxs(j.Fragment,{children:[o.jsxRuntimeExports.jsx(f.Text,{level:"small",className:u.CSS.B("legend-name"),children:x}),o.jsxRuntimeExports.jsx(f.Box,{y:!0,grow:!0,className:u.CSS.B("legend-entries"),children:o.jsxRuntimeExports.jsx(On,{data:p,onEntryChange:s,colorPickerVisible:a,onColorPickerVisibleChange:c,allowVisibleChange:n,background:t,entryProps:x1})}),m!==e.length-1&&o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("legend-divider")})]},d))})},x1={justify:"between",grow:!0},lr=({data:e=[],onEntryChange:t,position:n,onPositionChange:s,allowVisibleChange:r=!0,background:i=1,...l})=>{const[a,c]=j.useState(!1);return e.length===0?null:o.jsxRuntimeExports.jsx(Ps,{...l,draggable:!a,value:n,onChange:s,gap:"small",background:i,children:o.jsxRuntimeExports.jsx(On,{data:e,onEntryChange:t,colorPickerVisible:a,onColorPickerVisibleChange:c,allowVisibleChange:r,background:i,entryProps:p1})})},p1={justify:"between",grow:!0},m1=Object.freeze(Object.defineProperty({__proto__:null,Container:Ps,Grouped:fa,Simple:lr,stickyXYz:i1},Symbol.toStringTag,{value:"Module"})),ha=({variant:e="floating",...t})=>e==="floating"?o.jsxRuntimeExports.jsx(ga,{...t}):o.jsxRuntimeExports.jsx(f1,{...t}),ga=j.memo(({onLineChange:e,...t})=>{const{lines:n}=ct("FloatingLegend"),s=ja(n);return s.length===1?o.jsxRuntimeExports.jsx(lr,{data:s[0].data,onEntryChange:e,...t}):o.jsxRuntimeExports.jsx(fa,{data:s,onEntryChange:e,...t})});ga.displayName="LinePlot.FloatingLegend";const ja=e=>j.useMemo(()=>{const n={};for(const r of e){const i=n[r.legendGroup];i!=null?i.push(r):n[r.legendGroup]=[r]}const s=Object.entries(n).map(([r,i])=>({key:r,name:r,data:i}));return s.sort((r,i)=>r.name.localeCompare(i.name)),s},[e]),f1=({onLineChange:e})=>{const{lines:t}=ct("FixedLegend"),n=ja(t),s=f.useUniqueKey(),r=In({key:s,size:t.length>0?36:0,loc:"top",order:5},"Legend");return n.length===0?null:n.length===1?o.jsxRuntimeExports.jsx(f.Box,{align:"center",justify:"start",x:!0,style:r,children:o.jsxRuntimeExports.jsx(On,{data:n[0].data,onEntryChange:e,background:0})}):o.jsxRuntimeExports.jsxs(f.Box,{align:"center",justify:"start",x:!0,style:r,gap:"huge",children:[o.jsxRuntimeExports.jsx(Ri,{name:"Y1",data:n[0].data,onLineChange:e}),o.jsxRuntimeExports.jsx(Ri,{name:"Y2",data:n[1].data,onLineChange:e})]})},Ri=({name:e,data:t,onLineChange:n})=>o.jsxRuntimeExports.jsxs(f.Box,{x:!0,children:[o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:e}),o.jsxRuntimeExports.jsx(On,{data:t,onEntryChange:n,background:0})]}),ar=j.memo(({aetherKey:e,...t})=>(f.useUnidirectional({aetherKey:e,type:O.Line.TYPE,schema:O.stateZ,state:t}),null));ar.displayName="Line";const h1=Object.freeze(Object.defineProperty({__proto__:null,Line:ar},Symbol.toStringTag,{value:"Module"})),cr=({aetherKey:e,color:t,label:n="",legendGroup:s,visible:r=!0,...i})=>{const l=f.useUniqueKey(e),{setLine:a,removeLine:c}=ct("Line");return j.useEffect(()=>(a({key:l,color:t,label:n,visible:r,legendGroup:s}),()=>c(l)),[n,t,r,s]),o.jsxRuntimeExports.jsx(ar,{aetherKey:l,color:t,label:n,visible:r,...i})},Ea=({level:e="h2",...t})=>{const n=f.useUniqueKey(),s=ks.useTypography(e),r=In({key:n,size:(s.lineHeight+2)*s.baseSize,loc:"top",order:10},"Title");return o.jsxRuntimeExports.jsx(f.Box,{justify:"center",align:"center",style:r,children:o.jsxRuntimeExports.jsx(f.MaybeEditable,{...t,level:e})})},ya=({aetherKey:e,...t})=>{const n=f.useUniqueKey(e),[,,s]=f.use$2({aetherKey:n,type:O.Tooltip.TYPE,schema:O.tooltipStateZ,initialState:{position:null,...t}}),r=j.useRef(null),i=j.useCallback(a=>{const c=document.querySelector(".pluto-canvas-container");if(c==null)return;const d=u.Ho.topLeft(c);s({position:u.K.translation(d,u.K.construct(a))})},[s]),l=j.useCallback(()=>s({position:null}),[s]);return j.useEffect(()=>{if(r.current===null)return;const a=r.current.parentElement;if(a!=null)return a.addEventListener("mousemove",i),a.addEventListener("mouseleave",l),()=>{a.removeEventListener("mousemove",i),a.removeEventListener("mouseleave",l)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:r})},g1=Object.freeze(Object.defineProperty({__proto__:null,Tooltip:ya},Symbol.toStringTag,{value:"Module"})),Sa=()=>{const e=j.useRef(new Map),t=j.useCallback(s=>{const{request:r,response:i}=s,l=e.current.get(r);l!=null&&(l(i.bounds),e.current.delete(r))},[]),[,,n]=f.use$2({type:O.BoundQuerier.TYPE,schema:O.boundQuerierStateZ,onAetherChange:t,initialState:{request:"",response:{request:"",bounds:{}}}});return j.useCallback(async()=>await new Promise(s=>{const r=u.kt.create();e.current.set(r,s),n(i=>({...i,request:r}))}),[])},j1=({ref:e})=>(e.current=Sa(),null),E1={select:"pointer",zoom:"crosshair",pan:"grab",zoomReset:"crosshair",click:"pointer",cancel:"default"},Ra=({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:E1[t],...r},...i,children:[o.jsxRuntimeExports.jsx("div",{style:{...u.Ho.css(n),display:u.Ho.areaIsZero(n)?"none":"block"},className:u.CSS.BE("viewport-mask","selection")}),s]}),y1=(e,t)=>{for(;e!=null&&!t(e);)e=e.parentElement;return e},S1=11,R1=6,C1=2,Ci=5,w1=e=>u.Ho.width(e)<Ci&&u.Ho.height(e)<Ci,fn=e=>{const t=u.Ho.width(e),n=u.Ho.height(e);return Math.min(t,n)<.001?S1:R1},b1=["zoom","pan","select","zoomReset","cancel"],ur=[...b1,"click"],v1=te.z.enum(ur),Ca=["zoom","select"],hn={defaultMode:"zoom",zoom:[["MouseLeft"]],zoomReset:[["MouseLeft","Control"]],pan:[["MouseLeft","Shift"],["MouseMiddle"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},wa={defaultMode:"pan",pan:[["MouseLeft"],["MouseMiddle"]],zoom:[["MouseLeft","Shift"]],zoomReset:[["MouseLeft","Control"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},ba={defaultMode:"select",select:[["MouseLeft"]],pan:[["MouseLeft","Shift"],["MouseMiddle"]],zoom:[["MouseLeft","Alt"]],zoomReset:[["MouseLeft","Control"]],cancel:[["Escape"]]},dr={zoom:hn,pan:wa,select:ba,zoomReset:hn,click:hn,cancel:hn},_1=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)]))},k1=u.Ho.construct(0,0,1,1,u.K$1.TOP_LEFT),L1={width:30,height:50},va=({onChange:e,triggers:t,initial:n=k1,threshold:s=L1,ref:r})=>{const i=t?.defaultMode??"zoom",[l,a]=j.useState(u.Ho.ZERO),[c,d]=j.useState(i),[x,p]=f.useStateRef(n),m=j.useRef(u.K.ZERO),h=j.useRef(null),g=u._.construct(s);j.useEffect(()=>p(()=>u.Ho.truncate(n,fn(n))),[n]),j.useEffect(()=>d(i),[i]);const[E,S,R,v]=f.useMemoCompare(()=>{const A={...dr[i],...t},B=f.flattenConfig(A),z=_1(A);return[A,B,z,f.flattenConfig(z)]},f.compareModeConfigs,[t]),y=j.useCallback(({box:A,triggers:B,stage:z,cursor:$})=>{if(h.current==null)return;const D=f.determineMode(E,B),V=u.Ho.construct(h.current);if(D==null)return;if(D==="cancel"){a(u.Ho.ZERO),e?.({box:x.current,mode:D,stage:z,cursor:$});return}if(D==="zoomReset")return a(u.Ho.ZERO),e?.({box:u.Ho.DECIMAL,mode:D,stage:z,cursor:$}),p(u.Ho.DECIMAL);const b=w1(A);if(z==="end"){if(b){D==="zoom"&&a(u.Ho.ZERO),e?.({box:x.current,mode:"click",stage:z,cursor:$});return}return p(L=>{if(D==="pan"){const F=wi(A,L,V);return F===null||u.Ho.equals(F,L)?L:(e?.({box:F,mode:D,stage:z,cursor:$}),F)}const N=C(A,L,V);return N===null?L:(e?.({box:N,mode:D,stage:z,cursor:$}),D==="zoom"?(a(u.Ho.ZERO),N):u.Ho.truncate(L,fn(L)))})}if(Ca.includes(D))return b?void 0:a(u.C.XY.scale(V).clamp(V).translate({x:-u.Ho.left(V),y:-u.Ho.top(V)}).box(bi(g,A,V)));if(a(L=>u.Ho.areaIsZero(L)?L:u.Ho.ZERO),u.K.distance($,m.current)<C1)return;m.current=$;const k=wi(A,x.current,V);e?.({box:k,mode:D,stage:z,cursor:$})},[a,d,e,E,s.height,s.width,p,h,fn]);j.useImperativeHandle(r,()=>({reset:()=>{a(u.Ho.ZERO),p(u.Ho.DECIMAL),e?.({box:u.Ho.DECIMAL,mode:"zoomReset",stage:"start",cursor:u.K.ZERO})}}),[e]);const C=j.useCallback((A,B,z)=>{const $=_o(B,z).box(bi(g,A,z));return u.Ho.truncate($,fn($))},[s]),_=f.useHeldRef({triggers:[["Control"]]}),M=f.useHeldRef({triggers:[["Alt"]]});j.useEffect(()=>{const A=B=>{if(h.current==null)return;let z=1;B.deltaY<0?z-=.035:z+=.035;const $=u.Ho.construct(h.current),D=u.K.construct(B);if(Array.from(h.current.children).push(h.current),!u.Ho.contains($,D)||h.current!==B.target&&y1(B.target,F=>F===h.current)==null)return;const k=_o(x.current,u.Ho.construct(h.current)).pos(u.K.construct(B));let N=u.C.XY.magnify({x:_.current.held?1:z,y:M.current.held?1:z}).box(x.current);N=u.Ho.translate(N,{x:_.current.held?0:k.x*(1-z),y:M.current.held?0:k.y*(1-z)}),p(N),e?.({stage:"end",box:N,cursor:u.K.construct(B),mode:"zoom"})};return window.addEventListener("wheel",A),()=>window.removeEventListener("wheel",A)},[p,e]),Vl.useDrag({bound:h,onDrag:y,triggers:S,loose:!0});const I=j.useCallback(({triggers:A,stage:B})=>{if(B==="end")return d(i);const z=f.determineMode(R,A);z!=null&&d(z)},[R,i,e]);return f.use$1({triggers:v,callback:I,region:h}),{maskBox:l,ref:h,mode:c}},_o=(e,t)=>u.C.XY.scale(t).clamp(t).scale(e),wi=(e,t,n)=>{let s=u.Ho.signedDims(_o(t,n).box(e));s={signedWidth:-s.signedWidth,signedHeight:-s.signedHeight};const r=u.C.XY.translate(u.K.construct(s)).box(t);return u.Ho.truncate(r,fn(r))},bi=(e,t,n)=>u.Ho.height(t)<=e.height?u.Ho.construct(u.Ho.left(t),u.Ho.top(n),u.Ho.width(t),u.Ho.height(n)):u.Ho.width(t)<=e.width?u.Ho.construct(u.Ho.left(n),u.Ho.top(t),u.Ho.width(n),u.Ho.height(t)):t,Gt=({mode:e,triggers:t})=>o.jsxRuntimeExports.jsxs(f.Text,{level:"small",children:[u.z.capitalize(e),o.jsxRuntimeExports.jsx(f.Text$1,{trigger:t[0],el:"span"})]}),M1=({triggers:e,value:t,onChange:n,disable:s=["zoomReset","click","cancel"],tooltipDelay:r,tooltipLocation:i,hideTooltip:l,...a})=>{const c=j.useMemo(()=>ur.filter(x=>!s.includes(x)),[s]),d={tooltipDelay:r,tooltipLocation:i,hideTooltip:l,size:"small"};return o.jsxRuntimeExports.jsxs(pe.Buttons,{...a,keys:c,value:t,onChange:n,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"zoom",tooltip:o.jsxRuntimeExports.jsx(Gt,{mode:"zoom",triggers:e.zoom}),...d,children:o.jsxRuntimeExports.jsx(f.Zoom,{})}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"pan",tooltip:o.jsxRuntimeExports.jsx(Gt,{mode:"pan",triggers:e.pan}),...d,children:o.jsxRuntimeExports.jsx(f.Pan,{})}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"select",tooltip:o.jsxRuntimeExports.jsx(Gt,{mode:"select",triggers:e.select}),...d,children:o.jsxRuntimeExports.jsx(f.Selection,{})})]})},N1=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_TRIGGERS:dr,MASK_MODES:Ca,MODES:ur,Mask:Ra,PAN_DEFAULT_TRIGGERS:wa,SELECT_DEFAULT_TRIGGERS:ba,SelectMode:M1,TooltipText:Gt,ZOOM_DEFAULT_TRIGGERS:hn,modeZ:v1,use:va},Symbol.toStringTag,{value:"Module"})),P1=e=>e==null?null:e.closest(".pluto-line-plot__viewport")??null,_a=({ref:e,children:t,initial:n=u.Ho.DECIMAL,onChange:s,...r})=>{const{setViewport:i}=ct("Viewport");j.useLayoutEffect(()=>{i({box:n,mode:"zoom",cursor:u.K.ZERO,stage:"start"})},[i,n]);const l=j.useCallback(c=>{i(c),s?.(c)},[s,i]),a=va({onChange:l,initial:n,ref:e,...r});return o.jsxRuntimeExports.jsx(Ra,{className:u.CSS.BE("line-plot","viewport"),...a,children:t})},T1=Object.freeze(Object.defineProperty({__proto__:null,BoundsQuerier:j1,Legend:ha,Line:cr,LinePlot:xa,Title:Ea,Tooltip:g1,Viewport:_a,XAxis:pa,YAxis:ma,axisFactory:ir,selectViewportEl:P1,useBoundQuerier:Sa,useContext:ct,useGridEntry:In,useViewport:da},Symbol.toStringTag,{value:"Module"})),I1=({aetherKey:e,...t})=>(f.use$2({aetherKey:e,type:O.Annotation.TYPE,schema:O.annotationStateZ,initialState:t}),null),ka=({aetherKey:e,menu:t,...n})=>{const s=f.useUniqueKey(e),{setViewport:r,setHold:i}=ct("Range.Provider"),[,{hovered:l,count:a},c]=f.use$2({aetherKey:s,type:O.Provider.TYPE,schema:O.providerStateZ,initialState:{...n,cursor:null,hovered:null,count:0}}),d=In({key:s,loc:"top",size:a>0?32:0,order:3},"Annotation.Provider"),x=f.useContextMenu(),p=f.useSyncedRef(x.visible),m=j.useCallback(g=>c(E=>({...E,cursor:{x:g.clientX,y:g.clientY}})),[c]),h=j.useCallback(()=>{p.current||c(g=>({...g,cursor:null}))},[c,p]);return o.jsxRuntimeExports.jsx(f.ContextMenu,{...x,menu:()=>t==null||l==null?null:t(l),children:o.jsxRuntimeExports.jsx(f.Box,{style:{...d,cursor:l!=null?"pointer":"default",width:"100%",height:"100%"},onContextMenu:x.open,className:x.className,onClick:()=>{l!=null&&(r({box:u.Ho.construct({x:l.viewport.lower,y:0},{x:l.viewport.upper,y:1}),mode:"zoom",cursor:u.K.ZERO,stage:"start"}),i(!0))},onMouseMove:m,onMouseLeave:h})})},O1=Object.freeze(Object.defineProperty({__proto__:null,Annotation:I1,Provider:ka},Symbol.toStringTag,{value:"Module"})),La={defaultMode:"empty",one:[["1"]],two:[["2"]],clear:[["Shift"]],empty:[[]]},A1=f.flattenConfig(La),Ma=({aetherKey:e})=>{const t=f.useUniqueKey(e),[,,n]=f.use$2({aetherKey:t,type:O.Measure.TYPE,schema:O.measureStateZ,initialState:{hover:null,one:null,two:null}}),s=j.useRef(null),r=f.useHeldRef({triggers:A1,loose:!0}),i=j.useCallback(({mode:c,cursor:d})=>{if(c==="click"){const x=f.determineMode(La,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]);da(i);const l=j.useCallback(c=>n(d=>({...d,hover:u.K.construct(c)})),[n]),a=j.useCallback(()=>{n(c=>({...c,hover:null}))},[n]);return j.useEffect(()=>{if(s.current===null)return;const c=s.current.parentElement;if(c!=null)return c.addEventListener("mousemove",l),c.addEventListener("mouseleave",a),()=>{c.removeEventListener("mousemove",l),c.removeEventListener("mouseleave",a)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:s})},D1=Object.freeze(Object.defineProperty({__proto__:null,Measure:Ma},Symbol.toStringTag,{value:"Module"})),xr=({aetherKey:e,label:t,position:n,onLabelChange:s,onPositionChange:r,onUnitsChange:i,units:l="",color:a,lineWidth:c,lineDash:d,className:x,onSelect:p,style:m,...h})=>{const[g,E]=P.usePurePassthrough({value:t,onChange:s,initial:""}),S=f.useSyncedRef(r),[,{pixelPosition:R},v]=f.use$2({aetherKey:e,type:O.Rule.TYPE,schema:O.ruleStateZ,initialState:{color:a,dragging:!1,position:n,lineWidth:c,lineDash:d},onAetherChange:j.useCallback(({position:D})=>{D!=null&&S.current?.(D)},[S])}),y=j.useRef(R);R!==y.current&&(y.current=R);const{id:C}=ct("Rule"),M=document.getElementById(C)?.querySelector(".pluto-line-plot__viewport"),I=j.useRef(R);j.useEffect(()=>{v(D=>({...D,position:n,color:a,lineWidth:c,lineDash:d}))},[n,a,c,d]);const A=Pe.useCursorDrag({onStart:j.useCallback(()=>{p?.(),v(D=>({...D,dragging:!0})),I.current=y.current},[]),onMove:D=>{v(V=>({...V,pixelPosition:(I.current??0)+u.Ho.signedHeight(D)}))},onEnd:j.useCallback(()=>{v(D=>({...D,dragging:!1})),I.current=R},[])}),B=j.useRef(null);if(n==null||R==null)return null;const z=u.cr.pickByContrast(a,u.cr.BLACK,u.cr.WHITE),$=o.jsxRuntimeExports.jsxs("div",{ref:B,className:u.CSS.B("rule"),style:{top:`calc(${R}px - 0.5rem)`},children:[o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("rule","drag-handle"),onDragStart:A,draggable:!0}),o.jsxRuntimeExports.jsxs(f.Box,{x:!0,align:"center",className:u.CSS(x,u.CSS.BE("rule","tag")),bordered:!0,onClick:p,empty:!0,rounded:!0,style:{borderColor:u.cr.cssString(a),backgroundColor:u.cr.hex(u.cr.setAlpha(a,.7)),...m},...h,children:[o.jsxRuntimeExports.jsx(f.Editable,{className:u.CSS.BE("rule","label"),level:"small",value:g,onChange:E,color:z}),o.jsxRuntimeExports.jsx(f.Divider$1,{y:!0,style:{borderColor:u.cr.cssString(a)}}),o.jsxRuntimeExports.jsxs(f.Box,{x:!0,align:"center",className:u.CSS.BE("rule","value"),children:[o.jsxRuntimeExports.jsx(f.Editable,{value:n.toFixed(2),onChange:D=>{const V=Number(D);isFinite(V)&&r?.(V)},level:"small",color:z}),l.length>0&&o.jsxRuntimeExports.jsx(f.MaybeEditable,{level:"small",color:z,value:l,onChange:i})]})]})]});return M==null?$:zl.createPortal($,M)},B1=Object.freeze(Object.defineProperty({__proto__:null,Rule:xr},Symbol.toStringTag,{value:"Module"})),Na=f.canDropOfType(vt),$1=({lines:e,axes:t,showTitle:n=!0,title:s="",onTitleChange:r,showLegend:i=!0,legendPosition:l,onLegendPositionChange:a,titleLevel:c="h4",onLineChange:d,onRuleChange:x,onAxisChannelDrop:p,onAxisChange:m,rules:h,enableTooltip:g=!0,enableMeasure:E=!1,initialViewport:S=u.Ho.DECIMAL,legendVariant:R,onViewportChange:v,viewportTriggers:y,rangeAnnotationProvider:C,onSelectRule:_,children:M,...I})=>{const A=t.filter(({location:V})=>u.K$1.isY(V)),B=j.useRef(null),z=f.usePrevious(e.length),$=f.usePrevious(I.hold),D=z===0&&e.length!==0||$===!0&&I.hold===!1;return j.useEffect(()=>{D&&B.current?.reset()},[D]),o.jsxRuntimeExports.jsxs(xa,{...I,children:[A.map((V,b)=>{const k=e.filter(F=>F.axes.x===V.key),L=t.filter(({location:F})=>u.K$1.isX(F)),N=h?.filter(F=>[...L.map(({key:H})=>H),V.key].includes(F.axis));return o.jsxRuntimeExports.jsx(z1,{axis:V,index:b,lines:k,yAxes:L,rules:N,onAxisChannelDrop:p,onAxisChange:m,annotationProvider:C,onRuleChange:x,onSelectRule:_},V.key)}),i&&o.jsxRuntimeExports.jsx(ha,{onLineChange:d,position:l,onPositionChange:a,variant:R}),n&&o.jsxRuntimeExports.jsx(Ea,{value:s,onChange:r,level:c}),o.jsxRuntimeExports.jsxs(_a,{initial:S,onChange:v,triggers:y,ref:B,children:[g&&o.jsxRuntimeExports.jsx(ya,{}),E&&o.jsxRuntimeExports.jsx(Ma,{}),M]})]})},z1=({yAxes:e,lines:t,index:n,rules:s,onRuleChange:r,onSelectRule:i,onAxisChannelDrop:l,onAxisChange:a,axis:{location:c,key:d,showGrid:x,...p},annotationProvider:m})=>{const h=f.useDrop({type:"Channel.LinePlot.XAxis",canDrop:Na,onDrop:j.useCallback(({items:S})=>{const R=f.filterByType(vt,S);return l?.(d,R.map(({key:v})=>v)),R},[d,l])}),g=s?.filter(S=>S.axis===d),E=f.useDraggingState();return o.jsxRuntimeExports.jsxs(pa,{...p,...h,location:c,axisKey:d,showGrid:x??n===0,className:u.CSS(u.CSS.dropRegion(f.canDropOfType(vt)(E))),onAutoBoundsChange:S=>a?.({key:d,bounds:S}),onLabelChange:S=>a?.({key:d,label:S}),children:[e.map((S,R)=>{const v=t.filter(C=>C.axes.y===S.key),y=s?.filter(C=>C.axis===S.key);return o.jsxRuntimeExports.jsx(F1,{axis:{...S,showGrid:x??(n===0&&R===0)},lines:v,rules:y,onRuleChange:r,onAxisChannelDrop:l,onAxisChange:a,onSelectRule:i},S.key)}),g?.map(S=>j.createElement(xr,{aetherKey:S.key,...S,key:S.key,onLabelChange:R=>r?.({key:S.key,label:R}),onPositionChange:R=>r?.({key:S.key,position:R}),onUnitsChange:R=>r?.({key:S.key,units:R}),onSelect:()=>i?.(S.key)})),o.jsxRuntimeExports.jsx(ka,{...m})]})},V1=({channels:{x:e,y:t}})=>`${e??0}-${t}`,F1=({lines:e,rules:t,onRuleChange:n,onAxisChannelDrop:s,onAxisChange:r,axis:{key:i,location:l,...a},onSelectRule:c})=>{const d=f.useDrop({type:"Channel.LinePlot.YAxis",canDrop:Na,onDrop:j.useCallback(({items:p})=>{const m=f.filterByType(vt,p);return s?.(i,m.map(({key:h})=>h)),m},[i,s])}),x=f.useDraggingState();return o.jsxRuntimeExports.jsxs(ma,{...a,...d,location:l,axisKey:i,className:u.CSS(u.CSS.dropRegion(f.canDropOfType(vt)(x))),onAutoBoundsChange:p=>r?.({key:i,bounds:p}),onLabelChange:p=>r?.({key:i,label:p}),children:[e.map(p=>o.jsxRuntimeExports.jsx(H1,{line:p},V1(p))),t?.map(p=>j.createElement(xr,{aetherKey:p.key,...p,key:p.key,onLabelChange:m=>n?.({key:p.key,label:m}),onPositionChange:m=>n?.({key:p.key,position:m}),onUnitsChange:m=>n?.({key:p.key,units:m}),onClick:()=>c?.(p.key)}))]})},H1=({line:e})=>e.variant==="static"?o.jsxRuntimeExports.jsx(K1,{line:e}):o.jsxRuntimeExports.jsx(Z1,{line:e}),Z1=({line:{key:e,timeSpan:t,channels:{x:n,y:s},axes:r,...i}})=>{const{xTelem:l,yTelem:a}=j.useMemo(()=>{const c=Number(t.valueOf())*3,d=O.streamChannelData({timeSpan:t,channel:s,keepFor:c}),x=n!=null&&n!==0;return{xTelem:O.streamChannelData({timeSpan:t,channel:x?n:s,useIndexOfChannel:!x,keepFor:c}),yTelem:d}},[t.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(cr,{aetherKey:e,y:a,x:l,legendGroup:r.y.toUpperCase(),...i},e)},K1=({line:{timeRange:e,key:t,channels:{x:n,y:s},...r}})=>{const{xTelem:i,yTelem:l}=j.useMemo(()=>{const a=O.channelData({timeRange:e,channel:s}),c=n!=null&&n!==0;return{xTelem:O.channelData({timeRange:e,channel:c?n:s,useIndexOfChannel:!c}),yTelem:a}},[e.start.valueOf(),e.end.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(cr,{aetherKey:t,y:l,x:i,legendGroup:r.axes.y.toUpperCase(),...r},t)},lt=(e,t,n)=>({variant:"loading",status:u.wr.create({variant:"loading",message:`${u.z.capitalize(t)} ${e}`}),data:n}),Ve=(e,t,n)=>({variant:"success",status:u.wr.create({variant:"success",message:`${u.z.capitalize(t)} ${e}`}),data:n}),_t=(e,t,n)=>({variant:"error",status:u.wr.fromException(n,`Failed to ${t} ${e}`),data:void 0}),Wt=(e,t)=>({variant:"disabled",status:u.wr.create({variant:"disabled",message:`Failed to ${t} ${e}`,description:`Cannot ${t} ${e} because no cluster is connected.`}),data:void 0}),pr=j.createContext({mode:"normal",bind:()=>()=>{},set:()=>{},reset:()=>{},remove:()=>{},get:()=>({value:void 0,status:{key:"",variant:"success",message:""},touched:!1,required:!1}),validate:()=>!1,validateAsync:()=>Promise.resolve(!1),value:()=>({}),has:()=>!1,setStatus:()=>{},clearStatuses:()=>{},setCurrentStateAsInitialValues:()=>{},getStatuses:()=>[]}),rn=e=>{const t=j.use(pr);return e??t},Et=(e,t={})=>{const{optional:n=!1,onChange:s,defaultValue:r}=t,i=rn(t?.ctx),{get:l,bind:a,set:c,setStatus:d}=i,x=j.useCallback(g=>{s?.(g,{...i,path:e}),c(e,g)},[e,c,s]),p=j.useCallback(g=>d(e,g),[e,d]),m=j.useSyncExternalStore(a,j.useCallback(()=>l(e,{optional:n,defaultValue:r}),[e,l,n,r]));if(m==null){if(!n)throw new Error(`Field state is null: ${e}`);return null}const h=i.mode==="preview"?"preview":void 0;return{onChange:x,setStatus:p,variant:h,...m}},mr=(e,t)=>{const{get:n,bind:s}=rn(t?.ctx);return j.useSyncExternalStore(s,j.useCallback(()=>n(e,t),[e,n,t]))},fr=(e,t)=>mr(e,t)?.value??null,Y1=e=>mr(e,{optional:!0})?.status?.variant==="success",Pa=(e,t)=>({value:()=>e.get(t).value,add:(n,s)=>{const r=u.yr(e.get(t).value);r.splice(s,0,...P.t.toArray(n)),e.set(t,r)},push:(n,s)=>{const r=u.yr(e.get(t).value);r.push(...P.t.toArray(n)),s!=null&&r.sort(s),e.set(t,r)},remove:n=>{const s=e.get(t).value,r=new Set(P.t.toArray(n)),i=s.filter(({key:l})=>!r.has(l));return e.set(t,i),i.map(({key:l})=>l)},keepOnly:n=>{const s=e.get(t).value,r=new Set(P.t.toArray(n)),i=s.filter(({key:l})=>r.has(l));return e.set(t,i),i.map(({key:l})=>l)},set:n=>e.set(t,P.executeSetter(n,e.get(t).value)),sort:n=>{const s=u.yr(e.get(t).value);s.sort(n),e.set(t,s)}}),G1=(e,t={})=>{const n=rn(t?.ctx),s=fr(e,t);return j.useMemo(()=>({data:s.map(({key:r})=>r),...Pa(n,e)}),[s,n,e])},U1=f.renderProp(e=>o.jsxRuntimeExports.jsx(f.Text$2,{...e})),Ee=({path:e,children:t=U1,label:n,padHelpText:s=!0,visible:r=!0,hideIfNull:i=!0,optional:l,onChange:a,className:c,defaultValue:d,...x})=>{const p=Et(e,{optional:l??i,onChange:a,defaultValue:d}),m=rn();if(p==null)return null;if(e==null)throw new Error("No path provided to Form Field");if(n??=u.z.capitalize(P.N.element(e,-1)),r=typeof r=="function"?r(p,m):r,!r)return null;const h=p.status.message,{onChange:g,value:E}=p,S={onChange:g,value:E};return p.variant!=null&&(S.variant=p.variant),o.jsxRuntimeExports.jsx(Ie.Item,{padHelpText:s,helpText:h,status:p.status.variant,label:n,required:p.required,className:u.CSS(c,u.CSS.BE("field",e.split(".").join("-")),u.CSS.M(p.status.variant)),...x,children:t(S)})},An=e=>({fieldKey:t,fieldProps:n,inputProps:s})=>{const r=({inputProps:i,path:l,fieldKey:a=t,optional:c,defaultValue:d,...x})=>o.jsxRuntimeExports.jsx(Ee,{...n,...x,defaultValue:d,optional:c,path:a?`${l}.${a}`:l,children:p=>o.jsxRuntimeExports.jsx(e,{...p,...s,...i})});return r.displayName=e.displayName,r},Ta=An(f.Numeric),$e=Ta({inputProps:{}}),Ia=An(f.Text$2),hr=Ia({inputProps:{}}),Oa=An(f.Switch$1),Ts=Oa({inputProps:{}}),W1=e=>An(Pn)(e),X1=({children:e,...t})=>o.jsxRuntimeExports.jsx(pr,{value:t,children:e}),q1=e=>e.code==="custom"&&e.params!=null&&"variant"in e.params?e.params.variant:"error";class Q1 extends O.a.Observer{schema;values;initialValues;statuses;touched;cachedRefs;constructor(t,n){super(),this.schema=n,this.values=P.N.copy(t),this.statuses=new Map,this.touched=new Set,this.cachedRefs=new Map,this.initialValues=P.N.copy(this.values)}setValue(t,n){t==""?this.values=P.N.copy(n):P.N.set(this.values,t,n),this.checkTouched(t,n),this.updateCachedRefs(t)}checkTouched(t,n){const s=P.N.get(this.initialValues,t,{optional:!0});P.N.equal(s,n)?(this.clearTouched(t),this.clearOrphanedTouchedPaths(t)):this.setTouched(t)}clearOrphanedTouchedPaths(t){const n=new Set;this.touched.forEach(s=>{P.N.pathsMatch(s,t)&&s!==t&&!P.N.has(this.values,s)&&n.add(s)}),n.forEach(s=>{this.touched.delete(s),this.cachedRefs.delete(s)})}setStatus(t,n){this.statuses.set(t,n),this.updateCachedRefs(t)}clearStatus(t=""){this.statuses.delete(t),this.updateCachedRefs(t)}reset(t){if(P.N.equal(this.values,t??this.initialValues))return;t!=null&&(this.initialValues=P.N.copy(t));const n=P.N.copy(this.initialValues);this.statuses.clear(),this.touched.clear();const s=new Set;this.cachedRefs.forEach((r,i)=>{const l=P.N.get(this.values,i,{optional:!0}),a=P.N.get(n,i,{optional:!0});P.N.equal(l,a)||s.add(i)}),s.forEach(r=>this.cachedRefs.delete(r)),this.values=n}setCurrentStateAsInitialValues(){this.initialValues=P.N.copy(this.values),this.touched.clear(),this.cachedRefs.clear()}setTouched(t){this.touched.add(t),this.updateCachedRefs(t)}clearTouched(t=""){t===""?this.touched.clear():this.touched.delete(t),this.updateCachedRefs(t),this.notify()}remove(t){P.N.remove(this.values,t),this.statuses.delete(t),this.clearTouched(t),this.cachedRefs.delete(t)}validate(t,n){if(this.schema==null)return!0;const s=this.schema.safeParse(this.values);return this.processValidation(t,s,n)}async validateAsync(t,n){if(this.schema==null)return!0;const s=await this.schema.safeParseAsync(this.values);return this.processValidation(t,s,n)}errorsToStatuses(t,n,s){return t.forEach(r=>{const i=[...n,...r.path],l=P.N.resolvePath(i.join("."),this.values);if(s.push({key:l,variant:q1(r),message:r.message}),r.code==="invalid_union"&&r.errors!=null&&r.errors.length>0){const a=r.errors.map(d=>d.filter(x=>P.N.has(this.values,[...i,...x.path].join("."))));a.sort((d,x)=>d.length-x.length);const c=a.find(d=>d.length>0);if(c==null)return;this.errorsToStatuses(c,i,s)}}),s}processValidation(t=!1,n,s){if(this.schema==null)return!0;const r=new Set;if(this.statuses.forEach((a,c)=>{a.variant!=="success"&&r.add(c)}),r.forEach(a=>this.clearStatus(a)),n.success)return!0;let i=!0;return this.errorsToStatuses(n.error.issues,[],[]).forEach(a=>{const{key:c,message:d,variant:x}=a;if(c==null)return;const p=s==null||P.N.pathsMatch(c,s)||P.N.pathsMatch(s,c),m=t||this.touched.has(c);!p||!m||(x!=="warning"&&(i=!1),this.setStatus(c,{key:c,variant:x,message:d}))}),i}get hasBeenTouched(){return this.touched.size>0}getStatuses(){return Array.from(this.statuses.values()).filter(t=>t.variant!=="success")}getState(t,n={}){const{optional:s=!1,defaultValue:r=void 0}=n,i=u.pr.getOrSetDefault(this.cachedRefs,t,{});let l=P.N.get(this.values,t,{optional:s||r!=null});if(l==null){if(r==null)return null;l=r,this.setValue(t,l)}if(i.value=l,i.required=!1,this.schema!=null){const a=ig.getFieldSchema(this.schema,t,{optional:!0});a!=null&&(i.required=!a.safeParse(void 0).success)}return i.status=u.pr.getOrSetDefault(this.statuses,t,{key:t,variant:"success",message:""}),i.touched=this.touched.has(t),i}updateCachedRefs(t){this.cachedRefs.forEach((n,s)=>{(P.N.pathsMatch(s,t)||P.N.pathsMatch(t,s))&&this.cachedRefs.set(s,{})})}}const gr=({values:e,sync:t=!1,schema:n,mode:s="normal",onChange:r,onHasTouched:i})=>{const l=f.useInitializerRef(()=>new Q1(e,n)),a=f.useSyncedRef(r),c=f.useErrorHandler(),d=f.useSyncedRef(i),x=j.useCallback(()=>{l.current.setCurrentStateAsInitialValues(),d.current?.(!1)},[]),p=j.useCallback(_=>l.current.onChange(_),[]),m=j.useCallback((_,M)=>l.current.getState(_,M),[]),h=j.useCallback(_=>{l.current.remove(_),l.current.notify()},[]),g=j.useCallback(_=>{const M=l.current.values,I=l.current.hasBeenTouched;l.current.reset(_),M!==l.current.values&&a.current?.({values:l.current.values,path:"",prev:M,valid:!0}),l.current.notify();const B=l.current.hasBeenTouched;B!==I&&d.current?.(B)},[]),E=j.useCallback(async _=>{const M=await l.current.validateAsync(!0,_);return l.current.notify(),M},[]),S=j.useCallback(_=>{const M=l.current.validate(!0,_);return l.current.notify(),M},[]),R=j.useCallback((_,M,I)=>{const{notifyOnChange:A=!0}=I??{},B=P.N.get(l.current.values,_,{optional:!0}),z=l.current.hasBeenTouched;l.current.setValue(_,M);const $=()=>{A&&a.current?.({values:l.current.values,path:_,prev:B,valid:!0}),l.current.notify();const D=l.current.hasBeenTouched;D!==z&&d.current?.(D)};try{l.current.validate()}catch{return c(async()=>{await l.current.validateAsync(),$()},"Failed to validate form")}$()},[]),v=j.useCallback(_=>P.N.has(l.current.values,_),[]),y=j.useCallback((_,M)=>{const I=l.current.hasBeenTouched;l.current.setStatus(_,M),l.current.notify();const A=l.current.hasBeenTouched;A!==I&&d.current?.(A)},[]),C=j.useCallback(()=>{l.current.clearStatus(),l.current.notify()},[]);return j.useEffect(()=>{t&&(l.current.reset(e),l.current.notify())},[t,e]),j.useMemo(()=>({bind:p,set:R,get:m,mode:s,validate:S,validateAsync:E,value:()=>l.current.values,has:v,remove:h,setStatus:y,clearStatuses:C,reset:g,setCurrentStateAsInitialValues:x,getStatuses:()=>l.current.getStatuses()}),[p,R,m,S,E,v,h,y,C,g,s,x])},Aa=({key:e,open:t,onChange:n})=>{const s=f.useMemoPrimitiveArray(e);It(async()=>{if(t==null)return;const r=await t();if(r==null)return;const i=r.onChange(n);return async()=>{i(),await r.close()}},[t==null,s])},J1=Object.freeze(Object.defineProperty({__proto__:null,useListener:Aa},Symbol.toStringTag,{value:"Module"})),En={...O.ZERO_CONTEXT_VALUE,state:P.Sm.connectivity.DEFAULT},e0={maxRetries:4,baseInterval:P.O$1.seconds(1),scale:2},jr=j.createContext(En),Da=()=>j.use(jr),At=()=>Da().client,t0=()=>Da().state,ko={connected:"success",connecting:"loading",disconnected:"disabled",failed:"error"},Ba="serverVersionMismatch",n0=(e,t,n)=>`Cluster version ${n!=null?`${n} `:""}is ${e?"older":"newer"} than client version ${t}. Compatibility issues may arise.`,s0=({children:e,client:t})=>{const{path:n}=f.useUnidirectional({type:O.Provider$1.TYPE,schema:O.Provider$1.stateZ,state:{props:null,state:null}});return o.jsxRuntimeExports.jsx(jr,{value:{...En,client:t},children:o.jsxRuntimeExports.jsx(f.Composite,{path:n,children:e})})},$a=({children:e,connParams:t})=>{const[n,s,r]=f.useCombinedStateAndRef(En),{path:i}=f.useUnidirectional({type:O.Provider$1.TYPE,schema:O.Provider$1.stateZ,state:{props:t??null,state:null}}),l=f.useAdder(),a=j.useCallback(c=>{r.current.state.status!==c.status&&l({variant:ko[c.status],message:c.message??u.z.capitalize(c.status)}),s(d=>({...d,state:c}))},[l]);return It(async c=>{if(n.client!=null&&n.client.close(),t==null)return s(En);const d=new P.Sm({retry:e0,...t,connectivityPollFrequency:P.O$1.seconds(2)});s({client:d,state:{clusterKey:"",status:"connecting",message:"Connecting...",clientServerCompatible:!1,clientVersion:d.clientVersion}});const x=await d.connectivity.check();if(!c.aborted){if(s({client:d,state:x}),l({variant:ko[x.status],message:x.message??x.status.toUpperCase()}),x.status==="connected"&&!x.clientServerCompatible){const p=x.nodeVersion==null||u.gr.semVerOlder(x.nodeVersion,x.clientVersion),m=n0(p,x.clientVersion,x.nodeVersion);l({variant:"warning",message:"Incompatible cluster version",description:m,details:{type:Ba,oldServer:p,nodeVersion:x.nodeVersion,clientVersion:x.clientVersion}})}return d.connectivity.onChange(a),()=>{d.close(),s(En)}}},[t,a]),o.jsxRuntimeExports.jsx(jr,{value:n,children:o.jsxRuntimeExports.jsx(f.Composite,{path:i,children:e})})},o0=Object.freeze(Object.defineProperty({__proto__:null,CONNECTION_STATE_VARIANTS:ko,Provider:$a,SERVER_VERSION_MISMATCH:Ba,TestProvider:s0,use:At,useConnectionState:t0},Symbol.toStringTag,{value:"Module"})),r0=({key:e,name:t,queryFn:n,values:s,openObservable:r,applyChanges:i,applyObservable:l,...a})=>{const c=At(),d=f.useErrorHandler(),x=f.useMemoPrimitiveArray(e),p=gr({values:s,...a,sync:!1,onChange:g=>{c!=null&&d(async()=>{await i?.({...g,client:c})},`Failed to apply changes for ${t}`)}});It(async()=>{if(c!=null)try{const g=await n({client:c});p.set("",g)}catch(g){d(g,`Failed to retrieve ${t}`)}},[x,c?.key]);const m=j.useCallback(async()=>{if(c!=null)return await r?.(c)},[x,c?.key]),h=j.useCallback(g=>l?.({changes:g,ctx:p}),[x,l]);return Aa({key:x,open:m,onChange:h}),p},i0=Object.freeze(Object.defineProperty({__proto__:null,Context:pr,Field:Ee,Form:X1,NumericField:$e,SwitchField:Ts,TextField:hr,buildNumericField:Ta,buildSelectField:W1,buildSwitchField:Oa,buildTextField:Ia,fieldBuilder:An,fieldListUtils:Pa,use:gr,useContext:rn,useField:Et,useFieldList:G1,useFieldState:mr,useFieldValid:Y1,useFieldValue:fr,useSynced:r0},Symbol.toStringTag,{value:"Module"})),Dt=({name:e,schema:t,retrieve:n,mountListeners:s,update:r,initialValues:i})=>({params:l,initialValues:a,autoSave:c=!1,afterSave:d,beforeSave:x,sync:p,onHasTouched:m,mode:h,scope:g})=>{const[E,S]=j.useState(lt(e,"retrieving",void 0)),R=f.useUniqueKey(g),v=At(),y=He(R),C=Ls(),_=gr({schema:t,values:a??i,onChange:({path:$})=>{c&&$!==""&&z()},sync:p,onHasTouched:m,mode:h}),M=j.useCallback(($,D,V)=>_.set($,D,{...V,notifyOnChange:!1}),[_]),I=j.useCallback(async($,D={})=>{const{signal:V}=D;try{if(v==null)return S(Wt(e,"retrieve"));if(S(k=>lt(e,"retrieving",k.data)),V?.aborted)return;const b={client:v,params:$,store:y,..._,set:M};if(await n(b),V?.aborted)return;C.cleanup(),C.set(s?.(b)),S(Ve(e,"retrieved",void 0))}catch(b){if(V?.aborted)return;S(_t(e,"retrieve",b))}},[v,e,_,y,M]),A=f.useMemoDeepEqual(l);It(async $=>await I(A,{signal:$}),[I,A]);const B=j.useCallback(async($={})=>{const{signal:D}=$;try{if(v==null)return S(Wt(e,"update")),!1;const V={client:v,params:l,store:y,..._,set:M};return await _.validateAsync()?(S(lt(e,"updating",void 0)),await x?.(V)===!1?(S(Ve(e,"updated",void 0)),!1):D?.aborted===!0?!1:(await r(V),S(Ve(e,"updated",void 0)),d?.(V),!0)):!1}catch(V){return D?.aborted!==!0&&S(_t(e,"update",V)),!1}},[e,l,x,d]),z=j.useCallback($=>void B($),[B]);return{form:_,save:z,...E}},za=j.createContext(null),He=e=>{const t=f.useRequiredContext(za),n=f.useUniqueKey(e);return j.useMemo(()=>t.scopedStore(n),[t,n])},Va=({children:e,...t})=>{const n=At(),s=f.useErrorHandler(),r=f.useAsyncErrorHandler(),{path:i}=f.useLifecycle({type:O.PROVIDER_TYPE,schema:O.providerStateZ$1,initialState:{}}),l=()=>"client"in t?t.client:new O.Client({client:n,storeConfig:t.storeConfig,handleError:s,handleAsyncError:r}),a=f.useInitializerRef(l),c=j.useRef(null);return n?.key!==c.current?.key&&(c.current=n,a.current=l()),o.jsxRuntimeExports.jsx(f.Composite,{path:i,children:o.jsxRuntimeExports.jsx(za,{value:a.current,children:e})})},l0=()=>!0,a0=u.i.milliseconds(100),c0=(e,t,n,s,r,i)=>{if(e==null)return;let l=e({params:t.current??{},store:i});if(n.current!=null&&(l=l.filter(n.current)),s.current!=null&&(l=l.sort(s.current)),l.length!==0)return l.forEach(a=>r.current.set(a.key,a)),l.map(a=>a.key)},Ke=({name:e,mountListeners:t,retrieve:n,retrieveByKey:s,retrieveCached:r})=>(i={})=>{const{filter:l=l0,sort:a,initialParams:c,retrieveDebounce:d=a0}=i,x=f.useSyncedRef(l),p=f.useSyncedRef(a),m=At(),h=j.useRef(new Map),g=f.useInitializerRef(()=>new Map),E=He(),S=j.useRef(c??null),[R,v,y]=f.useCombinedStateAndRef(()=>lt(e,"retrieving",c0(r,S,x,p,h,E))),C=j.useRef(!0),_=Ls(),M=j.useRef(!1),I=j.useCallback(k=>g.current.forEach((L,N)=>{L===k&&N()}),[g.current]),A=j.useCallback(k=>{if(p.current==null)return k;const L=k.map(N=>h.current.get(N)).filter(N=>N!=null);return L.sort(p.current),L.map(N=>N.key)},[p]),B=j.useCallback(()=>{m!=null&&(M.current=!0,_.cleanup(),_.set(t?.({client:m,store:E,params:S.current??{},onDelete:k=>{h.current.delete(k),v(L=>L.data==null?L:{...L,data:L.data.filter(N=>N!==k)})},onChange:(k,L,N={})=>{const{mode:F="append"}=N,H=h.current.get(k)??null;if(H!=null&&!x.current(H))return;const K=P.executeSetter(L,H);K==null||!x.current(K)||(h.current.set(k,K),v(Z=>{if(Z.data==null)return Z;let Y;if(H==null)p.current!=null?Y=A([...Z.data,k]):Y=F==="prepend"?[k,...Z.data]:[...Z.data,k];else if(p.current!=null){const ne=Z.data.indexOf(k),J=A(Z.data),ce=J.indexOf(k);ne!==ce?Y=J:Y=Z.data}else Y=Z.data;return{...Z,data:Y}}),I(k))}})))},[t,_]),z=j.useCallback(async(k,L={})=>{const{signal:N,mode:F="replace"}=L,H=P.executeSetter(k,S.current??{});S.current=H;try{if(m==null)return v(Wt(e,"retrieve"));if(v(Y=>lt(e,"retrieving",Y.data)),F==="replace")C.current=!0;else if(F==="append"&&!C.current)return v(Y=>Ve(e,"retrieved",Y.data??[]));let K=await n({client:m,params:H,store:E});if(N?.aborted)return;K=K.filter(x.current),p.current!=null&&(K=K.sort(p.current)),K.length===0&&(C.current=!1);const Z=K.map(Y=>Y.key);return B(),y.current.data!=null&&u.k.primitiveArrays(y.current.data,Z)===u.k.EQUAL?v(Y=>Ve(e,"retrieved",Y.data??[])):(K.forEach(Y=>h.current.set(Y.key,Y)),v(Y=>{if(F==="replace"||Y.data==null)return Ve(e,"retrieved",Z);const ne=new Set(Z);return Ve(e,"retrieved",[...Y.data.filter(J=>!ne.has(J)),...Z])}))}catch(K){if(N?.aborted)return;v(_t(e,"retrieve",K))}},[m,e,E,x,B]),$=j.useCallback((k,L={})=>{const{signal:N}=L;(async()=>{M.current||B();try{if(m==null||u.O$1.isZero(k))return;const F=await s({client:m,key:k,params:S.current??{},store:E});if(N?.aborted||F==null)return;if(!x.current(F)){h.current.set(k,null);return}h.current.set(k,F),I(k)}catch(F){if(N?.aborted)return;h.current.set(k,null),v(_t(e,"retrieve",F))}})()},[s,m,I,B]),D=j.useCallback(k=>{if(k==null)return;if(Array.isArray(k))return k.map(N=>D(N)).filter(N=>N!=null);const L=h.current.get(k);return L===void 0&&$(k),L},[$]),V=j.useCallback((k,L)=>L==null?()=>{}:(g.current.set(k,L),()=>g.current.delete(k)),[]);return{retrieve:Pe.useDebouncedCallback((k,L={})=>void z(k,L),new u.i(d).milliseconds,[z]),retrieveAsync:z,subscribe:V,getItem:D,...R,data:R?.data??[]}},u0=({key:e,subscribe:t,getItem:n})=>j.useSyncExternalStore(j.useCallback(s=>t(s,e),[t,e]),j.useCallback(()=>n(e),[n,e])),Fa=e=>lt(e,"retrieving",void 0),Ha=e=>{const[t,n]=j.useState(Fa(e.name));return{...t,...Za({...e,onChange:n})}},Za=({retrieve:e,mountListeners:t,name:n,onChange:s,scope:r})=>{const i=At(),l=j.useRef(null),a=He(r),c=Ls(),d=j.useCallback(m=>s(h=>{if(h.data===void 0)return h;const g=P.executeSetter(m,h.data);return Ve(n,"retrieved",g)}),[s,n]),x=j.useCallback(async(m,h={})=>{const{signal:g}=h,E=P.executeSetter(m,l.current??{});l.current=E;try{if(i==null)return s(Wt(n,"retrieve"));if(s(v=>lt(n,"retrieving",v.data)),g?.aborted)return;const S={client:i,params:E,store:a},R=await e(S);if(g?.aborted)return;c.cleanup(),c.set(t?.({...S,onChange:d})),s(Ve(n,"retrieved",R))}catch(S){if(g?.aborted)return;s(_t(n,"retrieve",S))}},[i,n]);return{retrieve:j.useCallback((m,h)=>void x(m,h),[x]),retrieveAsync:x}},d0=({params:e,...t})=>{const{retrieveAsync:n,retrieve:s,...r}=Ha(t),i=f.useMemoDeepEqual(e);return It(async l=>await n(i,{signal:l}),[n,i]),r},x0=({params:e,...t})=>{const n=j.useRef(Fa(t.name)),{retrieveAsync:s}=Za({...t,onChange:i=>{n.current=P.executeSetter(i,n.current),t.onChange?.(n.current)}}),r=f.useMemoDeepEqual(e);It(async i=>{r!=null&&await s(r,{signal:i})},[s,r])},qe=e=>({useDirect:t=>d0({...e,...t}),useStateful:()=>Ha(e),useEffect:t=>x0({...e,...t})}),Ka=({onChange:e,params:t,update:n,name:s,scope:r,beforeUpdate:i,afterUpdate:l})=>{const a=At(),c=He(r),d=j.useCallback(async(p,m={})=>{const{signal:h}=m;try{if(a==null)return e(Wt(s,"update")),!1;e(E=>lt(s,"updating",E.data));let g=!1;if(i!=null){const E=await i({client:a,value:p});if(E==null)return!1;p=E}return await n({client:a,onChange:E=>{g=!0,e(Ve(s,"updated",E))},value:p,params:t,store:c}),h?.aborted===!0?!1:(g||e(Ve(s,"updated",p)),l!=null&&await l({client:a,value:p}),!0)}catch(g){return h?.aborted!==!0&&e(_t(s,"update",g)),!1}},[s,t]);return{update:j.useCallback((p,m)=>void d(p,m),[d]),updateAsync:d}},p0=({params:e,name:t,...n})=>{const[s,r]=j.useState(Ve(t,"updated",void 0)),i=Ka({...n,name:t,onChange:r,params:e});return{...s,...i}},Qe=e=>({useObservable:t=>Ka({...t,...e}),useDirect:t=>p0({...t,...e})}),m0=Object.freeze(Object.defineProperty({__proto__:null,Client:O.Client,Provider:Va,ScopedUnaryStore:O.ScopedUnaryStore,createForm:Dt,createList:Ke,createRetrieve:qe,createStore:O.createStore,createUpdate:Qe,errorResult:_t,nullClientResult:Wt,pendingResult:lt,scopeStore:O.scopeStore,successResult:Ve,useListItem:u0,useStore:He},Symbol.toStringTag,{value:"Module"})),Ya="channels",f0={channel:P.ow.SET_CHANNEL_NAME,schema:P.ow.keyZ,onChange:async({store:e,changed:t,client:n})=>e.channels.set(t,await n.channels.retrieve(t))},h0={channel:P.ow.DELETE_CHANNEL_NAME,schema:P.ow.keyZ,onChange:({store:e,changed:t})=>e.channels.delete(t)},g0={channel:P.ow.CALCULATION_STATUS_CHANNEL_NAME,schema:P.ow.statusZ,onChange:async({store:e,changed:t,client:n})=>e.channels.set(Number(t.key),s=>s==null?s:n.channels.sugar({...s,status:t}))},j0=e=>{const t=He();j.useEffect(()=>t.channels.onSet(n=>{n.status!=null&&e(n.status)}),[t])},Ga={equal:(e,t)=>P.N.equal(e.payload,t.payload),listeners:[f0,h0,g0]},Er=P.ow.newZ.extend({name:te.z.string().min(1,"Name must not be empty"),dataType:P.I.z.transform(e=>e.toString())}).refine(e=>!e.isIndex||P.I.z.parse(e.dataType).equals(P.I.TIMESTAMP),{message:"Index channel must have data type TIMESTAMP",path:["dataType"]}).refine(e=>e.isIndex||e.index!==0||e.virtual,{message:"Data channel must have an index",path:["index"]}).refine(e=>e.virtual||!P.I.z.parse(e.dataType).isVariable,{message:"Persisted channels must have a fixed-size data type",path:["dataType"]}),Ua=Er.extend({expression:te.z.string().min(1,"Expression must not be empty").refine(e=>e.includes("return"),{message:"Expression must contain a return statement"})}).refine(e=>e.requires?.length>0,{message:"Expression must use at least one channel",path:["requires"]}),Wa=e=>({...e.payload,dataType:e.dataType.toString()}),yr={key:0,name:"",index:0,dataType:P.I.FLOAT32.toString(),internal:!1,isIndex:!1,leaseholder:0,virtual:!1,expression:"",requires:[]},Sr=async({client:e,params:{key:t,rangeKey:n},store:s})=>{let r=s.channels.get(t);if(r==null&&(r=await e.channels.retrieve(t),s.channels.set(r.key,r)),n!=null){const i=P.Iw.aliasKey({range:n,channel:r.key});let l=s.rangeAliases.get(i);if(l==null)try{l={alias:await e.ranges.retrieveAlias(n,r.key),channel:r.key,range:n}}finally{s.rangeAliases.set(i,{channel:r.key,range:n})}l!=null&&(r.alias=l.alias)}return r},E0=async({client:e,params:{keys:t,rangeKey:n},store:s})=>{const r=s.channels.get(t),i=new Set(r?.map(a=>a.key)),l=t.filter(a=>!i.has(a));if(l.length>0){const a=await e.channels.retrieve(l);r.push(...a),s.channels.set(a)}if(n!=null){const a=t.map(p=>P.Iw.aliasKey({range:n,channel:p})),c=s.rangeAliases.get(a);c.forEach(p=>{if(p==null)return;const m=r.find(h=>h.key===p.channel);m!=null&&(m.alias=p.alias)});const d=new Set(c.map(p=>p.channel)),x=t.filter(p=>!d.has(p));if(x.length>0){const p=await e.ranges.retrieveAliases(n,x);Object.entries(p).forEach(([m,h])=>{const g=Number(m),E=r.find(R=>R.key===g);E!=null&&(E.alias=h);const S=P.Iw.aliasKey({range:n,channel:g});s.rangeAliases.set(S,{alias:h,channel:g,range:n})})}}return r},Xa=async({params:{key:e,rangeKey:t},store:n,client:s,reset:r})=>{if(e==null)return;const i=await Sr({client:s,store:n,params:{key:e,rangeKey:t}});r(Wa(i))},Rr=qe({name:"Channel",retrieve:Sr,mountListeners:({store:e,onChange:t,params:{key:n,rangeKey:s},client:r})=>{const i=e.channels.onSet(d=>{if(s!=null){const x=e.rangeAliases.get(P.Iw.aliasKey({range:s,channel:n}));x!=null&&(d.alias=x.alias)}t(d)},n);if(s==null)return i;const l=P.Iw.aliasKey({range:s,channel:n}),a=e.rangeAliases.onSet(d=>{d!=null&&t(x=>r.channels.sugar({...x,alias:d.alias}))},l),c=e.rangeAliases.onDelete(()=>t(d=>r.channels.sugar({...d,alias:void 0})),l);return[i,a,c]}}),y0=qe({name:"Channels",retrieve:E0,mountListeners:({store:e,onChange:t,params:{keys:n,rangeKey:s},client:r})=>{const i=new Set(n),l=e.channels.onSet(async d=>{if(i.has(d.key)){if(s!=null){const x=P.Iw.aliasKey({range:s,channel:d.key});let p=e.rangeAliases.get(x);if(p==null)try{p={alias:await r.ranges.retrieveAlias(s,d.key),channel:d.key,range:s},e.rangeAliases.set(x,p)}catch(m){console.error(m)}p!=null&&(d.alias=p.alias)}t(x=>x.map(p=>p.key===d.key?d:p))}});if(s==null)return l;const a=e.rangeAliases.onSet(d=>{d!=null&&t(x=>x.map(p=>p.key===d.channel?r.channels.sugar({...p,alias:d.alias}):p))}),c=e.rangeAliases.onDelete(d=>{const x=P.Iw.decodeDeleteAliasChange(d);t(p=>p.map(m=>m.key===x.channel?r.channels.sugar({...m,alias:void 0}):m))});return[l,a,c]}}),qa=async({client:e,store:t,set:n,value:s})=>{const r=await e.channels.create(s());t.channels.set(r.key,r),n("key",r.key)},Qa=({store:e,get:t,reset:n})=>e.channels.onSet(s=>{t("key").value===s.key&&n(Wa(s))}),S0=Dt({name:"Channel",schema:Er,initialValues:yr,retrieve:Xa,update:qa,mountListeners:Qa}),R0=Dt({name:"Calculated Channel",schema:Ua,initialValues:yr,retrieve:Xa,update:qa,mountListeners:Qa}),C0={internal:!1},Cr=Ke({name:"Channels",retrieveCached:({params:e,store:t})=>e.searchTerm!=null&&e.searchTerm.length>0?[]:t.channels.get(n=>!(e.internal!=null&&n.internal!==e.internal||e.calculated!=null&&n.isCalculated!==e.calculated||u.O$1.isNonZero(e.notDataTypes)&&e.notDataTypes.some(s=>new P.I(s).equals(n.dataType))||u.O$1.isNonZero(e.dataTypes)&&!e.dataTypes.some(s=>new P.I(s).equals(n.dataType))||e.isIndex!=null&&n.isIndex!==e.isIndex||e.virtual!=null&&n.virtual!==e.virtual)),retrieve:async({client:e,params:t,store:n})=>{const s=await e.channels.retrieve({...C0,...t});return n.channels.set(s),s},retrieveByKey:async({client:e,key:t,store:n})=>await Sr({client:e,params:{key:t},store:n}),mountListeners:({store:e,onChange:t,onDelete:n})=>[e.channels.onSet(s=>t(s.key,s)),e.channels.onDelete(s=>n(s))]}),w0=Qe({name:"Channel",update:async({client:e,value:t,store:n})=>{const s=await e.channels.create(t);n.channels.set(s.key,s)}}),b0=Qe({name:"Channel",update:async({client:e,value:t,store:n,params:{key:s}})=>{s!=null&&(await e.channels.rename(s,t),n.channels.set(s,r=>r==null?r:e.channels.sugar({...r,name:t})))}}),Ja=Qe({name:"Channel Alias",update:async({client:e,value:t,store:n,params:{rangeKey:s,channelKey:r}})=>{if(s==null)return;const i={alias:t,channel:r,range:s};await e.ranges.setAlias(s,r,t),n.rangeAliases.set(P.Iw.aliasKey(i),i)}}),ec=e=>{if(e==null)return f.Channel;if(P.ow.isCalculated(e))return f.Calculation;if(e.isIndex)return f.Index;const t=new u.n(e.dataType);return t.isInteger?f.Binary:t.isFloat?f.Decimal:t.equals(u.n.STRING)?f.String:t.equals(u.n.JSON)?f.JSON:f.Channel},tc=f.renderProp(({itemKey:e,...t})=>{const n=f.useItem(e),s=ec(n?.payload);return o.jsxRuntimeExports.jsxs(f.ListItem,{itemKey:e,...t,children:[o.jsxRuntimeExports.jsx(s,{}),n?.name]})}),v0=({onChange:e,value:t,emptyContent:n,initialParams:s,filter:r,...i})=>{const{data:l,retrieve:a,getItem:c,subscribe:d,status:x}=Cr({initialParams:s,filter:r}),{fetchMore:p,search:m}=nt.usePager({retrieve:a});return o.jsxRuntimeExports.jsx(Ms,{resourceName:"Channel",value:t,onChange:e,data:l,haulType:vt,getItem:c,subscribe:d,onFetchMore:p,onSearch:m,emptyContent:n,status:x,icon:o.jsxRuntimeExports.jsx(f.Channel,{}),...i,children:tc})},kt=({onChange:e,value:t,allowNone:n,emptyContent:s,initialParams:r,filter:i,...l})=>{const{data:a,retrieve:c,getItem:d,subscribe:x,status:p}=Cr({initialParams:r,filter:i}),{fetchMore:m,search:h}=nt.usePager({retrieve:c});return o.jsxRuntimeExports.jsx(Ot,{resourceName:"Channel",onChange:e,value:t,allowNone:n,emptyContent:s,onFetchMore:m,onSearch:h,data:a,getItem:d,subscribe:x,status:p,haulType:vt,icon:o.jsxRuntimeExports.jsx(f.Channel,{}),...l,children:tc})},_0=Object.freeze(Object.defineProperty({__proto__:null,AliasInput:Zg,FLUX_STORE_CONFIG:Ga,FLUX_STORE_KEY:Ya,LinePlot:$1,SelectMultiple:v0,SelectSingle:kt,ZERO_FORM_VALUES:yr,calculatedFormSchema:Ua,formSchema:Er,rename:b0,resolveIcon:ec,retrieve:Rr,retrieveMany:y0,update:w0,updateAlias:Ja,useCalculatedForm:R0,useForm:S0,useList:Cr,useListenForCalculationStatus:j0},Symbol.toStringTag,{value:"Module"})),nc=({yDirection:e="up",...t})=>o.jsxRuntimeExports.jsxs(pe.Buttons,{...t,keys:u.p.DIRECTIONS,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"x",children:o.jsxRuntimeExports.jsx(f.Arrow.Right,{})}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"y",children:e==="up"?o.jsxRuntimeExports.jsx(f.Arrow.Up,{}):o.jsxRuntimeExports.jsx(f.Arrow.Down,{})})]}),k0=Object.freeze(Object.defineProperty({__proto__:null,Select:nc},Symbol.toStringTag,{value:"Module"})),sc="devices",L0={channel:P.bw.SET_CHANNEL_NAME,schema:P.bw.deviceZ,onChange:({store:e,changed:t})=>e.devices.set(t.key,n=>n==null?t:{...t,status:n.status})},M0={channel:P.bw.DELETE_CHANNEL_NAME,schema:P.bw.keyZ,onChange:({store:e,changed:t})=>e.devices.delete(t)},N0={channel:P.bw.STATUS_CHANNEL_NAME,schema:P.bw.statusZ,onChange:({store:e,changed:t})=>{e.devices.set(t.details.device,n=>n==null?n:{...n,status:t})}},oc={listeners:[L0,M0,N0]},P0=e=>{const t=He();j.useEffect(()=>t.devices.onSet(e),[t])},rc=async(e,t,n)=>{const s=t.devices.get(n.key);if(s!=null)return s;const r=await e.hardware.devices.retrieve({...n,includeStatus:!0});return t.devices.set(n.key,r),r},T0=()=>qe({name:"Device",retrieve:async({client:e,params:t,store:n})=>await rc(e,n,t),mountListeners:({store:e,onChange:t,params:{key:n}})=>[e.devices.onSet(s=>t(s),n)]}),ic=Ke({name:"Devices",retrieveCached:({store:e,params:t})=>e.devices.get(n=>!(u.O$1.isNonZero(t.makes)&&!t.makes.includes(n.make)||u.O$1.isNonZero(t.models)&&!t.models.includes(n.model)||u.O$1.isNonZero(t.racks)&&!t.racks.includes(n.rack)||u.O$1.isNonZero(t.locations)&&!t.locations.includes(n.location)||u.O$1.isNonZero(t.names)&&!t.names.includes(n.name)||u.O$1.isNonZero(t.keys)&&!t.keys.includes(n.key))),retrieve:async({client:e,params:t,store:n})=>{const s=await e.hardware.devices.retrieve({includeStatus:!0,...t});return s.forEach(r=>n.devices.set(r.key,r)),s},retrieveByKey:async({client:e,key:t,store:n})=>await rc(e,n,{key:t}),mountListeners:({store:e,onChange:t,onDelete:n})=>[e.devices.onSet(s=>t(s.key,s)),e.devices.onDelete(n)]}),I0=f.renderProp(({itemKey:e,...t})=>{const n=f.useItem(e);return o.jsxRuntimeExports.jsxs(f.ListItem,{itemKey:e,...t,className:u.CSS.BE("device","list-item"),justify:"between",align:"center",children:[o.jsxRuntimeExports.jsxs(f.Text,{align:"center",children:[o.jsxRuntimeExports.jsx(lc,{status:n?.status}),n?.name]}),o.jsxRuntimeExports.jsx(rr,{level:"small",color:9,weight:450,style:{marginTop:"0.25rem"},gap:"tiny",children:n?.location.split(".").map(s=>o.jsxRuntimeExports.jsx(Rn,{children:s},s))})]})}),O0=({onChange:e,value:t,filter:n,allowNone:s,emptyContent:r,initialParams:i,disabled:l,icon:a=o.jsxRuntimeExports.jsx(f.Device,{}),...c})=>{const{data:d,retrieve:x,getItem:p,subscribe:m,status:h}=ic({filter:n,initialParams:i}),{fetchMore:g,search:E}=nt.usePager({retrieve:x});return o.jsxRuntimeExports.jsx(Ot,{resourceName:"Device",value:t,onChange:e,data:d,getItem:p,subscribe:m,onFetchMore:g,onSearch:E,emptyContent:r,status:h,disabled:l,icon:a,...c,children:I0})},lc=({status:e,tooltipLocation:t="right"})=>{const n=e?.variant??"disabled",s=e?.message??"Device Status Unknown";return o.jsxRuntimeExports.jsxs(f.Dialog$1,{location:t,children:[o.jsxRuntimeExports.jsx(f.Summary,{variant:n,hideIcon:!0,level:"small",weight:450,children:s}),o.jsxRuntimeExports.jsx(nr,{variant:n,className:u.CSS.BE("device","status-indicator")})]})},A0=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:oc,FLUX_STORE_KEY:sc,SelectSingle:O0,StatusIndicator:lc,retrieve:T0,useList:ic,useSetSynchronizer:P0},Symbol.toStringTag,{value:"Module"})),ac="racks",D0={channel:P.vw.SET_CHANNEL_NAME,schema:P.vw.keyZ,onChange:async({store:e,changed:t,client:n})=>{const s=await n.hardware.racks.retrieve({key:t,includeStatus:!0});e.racks.set(t,s.payload)}},B0={channel:P.vw.DELETE_CHANNEL_NAME,schema:P.vw.keyZ,onChange:({store:e,changed:t})=>e.racks.delete(t)},$0={channel:P.vw.STATUS_CHANNEL_NAME,schema:P.vw.statusZ,onChange:({store:e,changed:t})=>e.racks.set(t.details.rack,n=>n==null?n:{...n,status:t})},cc={listeners:[D0,B0,$0]},uc={includeStatus:!0},dc=async({client:e,params:t,store:n})=>{let s=n.racks.get(t.key);return s==null&&(s=await e.hardware.racks.retrieve({...uc,...t}),n.racks.set(s.key,s)),s},xc=Ke({name:"Racks",retrieveCached:({store:e})=>e.racks.list(),retrieve:async({client:e,params:t,store:n})=>{const s=await e.hardware.racks.retrieve({...uc,...t});return n.racks.set(s),s},retrieveByKey:async({client:e,key:t,store:n})=>await dc({client:e,params:{key:t},store:n}),mountListeners:({store:e,onChange:t,onDelete:n})=>[e.racks.onSet(s=>t(s.key,s)),e.racks.onDelete(n)]}),z0=qe({name:"Rack",retrieve:dc,mountListeners:({store:e,onChange:t,params:{key:n}})=>[e.racks.onSet(t,n)]}),V0=f.renderProp(e=>{const{itemKey:t}=e,n=f.useItem(t);return o.jsxRuntimeExports.jsxs(f.ListItem,{...e,align:"center",justify:"between",children:[o.jsxRuntimeExports.jsx(f.Text,{children:n?.name}),o.jsxRuntimeExports.jsx(pc,{status:n?.status,tooltipLocation:"left"})]})}),F0=({value:e,onChange:t,filter:n,allowNone:s,emptyContent:r,initialParams:i,...l})=>{const{data:a,retrieve:c,getItem:d,subscribe:x,status:p}=xc({initialParams:{includeStatus:!0,...i},filter:n}),{fetchMore:m,search:h}=nt.usePager({retrieve:c});return o.jsxRuntimeExports.jsx(Ot,{resourceName:"Driver",value:e,onChange:t,data:a,getItem:d,subscribe:x,onFetchMore:m,onSearch:h,emptyContent:r,status:p,icon:o.jsxRuntimeExports.jsx(f.Rack,{}),...l,children:V0})},pc=({status:e,tooltipLocation:t="right"})=>{const n=j.useRef(null),s=e?.variant??"disabled";return j.useEffect(()=>{if(s!=="success")return;const r=n.current;r&&(r.classList.remove(u.CSS.BEM("rack","heartbeat","beat")),requestAnimationFrame(()=>r.classList.add(u.CSS.BEM("rack","heartbeat","beat"))))},[e]),o.jsxRuntimeExports.jsxs(f.Dialog$1,{location:t,children:[o.jsxRuntimeExports.jsx(f.Summary,{variant:s,hideIcon:!0,level:"small",weight:450,children:e?.message}),o.jsxRuntimeExports.jsx(f.Heart,{ref:n,className:u.CSS.BE("rack","heartbeat"),style:{color:tr[s]}})]})},H0=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:cc,FLUX_STORE_KEY:ac,SelectSingle:F0,StatusIndicator:pc,retrieve:z0,useList:xc},Symbol.toStringTag,{value:"Module"})),mc="tasks",Z0=["start","stop"],K0={channel:P.Ow.SET_CHANNEL_NAME,schema:P.Ow.keyZ,onChange:async({store:e,changed:t,client:n})=>e.tasks.set(t,await n.hardware.tasks.retrieve({key:t,includeStatus:!0}))},Y0={channel:P.Ow.DELETE_CHANNEL_NAME,schema:P.Ow.keyZ,onChange:({store:e,changed:t})=>e.tasks.delete(t)},G0=P.Ow.statusZ(te.z.unknown()),U0={channel:P.Ow.STATUS_CHANNEL_NAME,schema:G0,onChange:async({store:e,changed:t,client:n})=>{if(!e.tasks.has(t.details.task)){const r=await n.hardware.tasks.retrieve({key:t.details.task});e.tasks.set(t.details.task,r)}e.tasks.set(t.details.task,r=>r==null?r:n.hardware.tasks.sugar({...r,status:t}))}},W0={channel:P.Ow.COMMAND_CHANNEL_NAME,schema:P.Ow.commandZ,onChange:({store:e,changed:t,client:n})=>e.tasks.set(t.task,s=>s==null||!Z0.includes(t.type)?s:n.hardware.tasks.sugar({...s,status:{...s.status,variant:"loading",message:`Running ${t.type} command...`,details:{task:t.task,running:!0,data:{}}}}))},X0=e=>{const t=He();j.useEffect(()=>t.tasks.onSet(n=>{n.status!=null&&e(n.status)}),[t])},fc={listeners:[K0,Y0,U0,W0]},wr=async(e,t,n,s)=>{const r=t.tasks.get(n.key);if(r!=null)return r;const i=await e.hardware.tasks.retrieve({...n,includeStatus:!0,schemas:s});return t.tasks.set(n.key,i),i},q0=e=>qe({name:"Task",retrieve:async({client:t,params:n,store:s})=>n.key==null?null:await wr(t,s,{key:n.key,includeStatus:!0},e),mountListeners:({store:t,params:{key:n},onChange:s})=>[t.tasks.onSet(r=>{n==null||r.key!==n||s(r)},n)]}),Q0=Ke({name:"Task",retrieveCached:({store:e})=>e.tasks.list(),retrieve:async({client:e,params:t,store:n})=>{const s=await e.hardware.tasks.retrieve({includeStatus:!0,...t});return s.forEach(r=>n.tasks.set(r.key,r)),s},retrieveByKey:async({client:e,key:t,store:n})=>await wr(e,n,{key:t}),mountListeners:({store:e,onChange:t,onDelete:n})=>[e.tasks.onSet(s=>t(s.key,s)),e.tasks.onDelete(n)]}),J0=e=>te.z.object({key:P.Ow.keyZ.optional(),name:te.z.string(),rackKey:te.z.number(),type:e.typeSchema,snapshot:te.z.boolean(),config:e.configSchema,status:P.Ow.statusZ(e.statusDataSchema).optional().nullable()}),Un=e=>({key:e.key,name:e.name,rackKey:e.key==null?0:P.Ow.rackKey(e.key),type:e.type,config:e.config,status:e.status,snapshot:e.snapshot??!1}),ej=({schemas:e,initialValues:t})=>{const n=J0(e),s=Un(t);return Dt({name:"Task",schema:n,initialValues:s,retrieve:async({client:r,store:i,params:{key:l},reset:a})=>{l!=null&&a(Un(await wr(r,i,{key:l},e)))},update:async({client:r,params:i,store:l,...a})=>{const c=a.value(),x=await(await r.hardware.racks.retrieve({key:c.rackKey})).createTask({key:i.key,name:c.name,type:c.type,config:c.config});l.tasks.set(x.key,m=>m==null?m:(x.status=m.status,x));const p=Un(x.payload);a.set("key",p.key),a.set("name",p.name),a.set("rackKey",p.rackKey),a.set("type",p.type),a.set("config",p.config),a.set("snapshot",p.snapshot)},mountListeners:({store:r,get:i,reset:l})=>[r.tasks.onSet(a=>{const c=i("key",{optional:!0})?.value;c==null||c!==a.key||l(Un(a))})]})},tj=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:fc,FLUX_STORE_KEY:mc,createForm:ej,createRetrieveQuery:q0,useList:Q0,useStatusSynchronizer:X0},Symbol.toStringTag,{value:"Module"})),hc="labels",nj={channel:P.Sw.SET_CHANNEL_NAME,schema:P.Sw.labelZ,onChange:({store:e,changed:t})=>e.labels.set(t.key,t)},sj={channel:P.Sw.DELETE_CHANNEL_NAME,schema:P.Sw.keyZ,onChange:({store:e,changed:t})=>e.labels.delete(t)},gc={listeners:[nj,sj]},Xt=(e,t)=>P.ew.matchRelationship(e,{from:t,type:P.Sw.LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE}),jc=qe({name:"Labels",retrieve:async({client:e,params:{id:t}})=>await e.labels.retrieve({for:t}),mountListeners:({client:e,store:t,params:{id:n},onChange:s})=>[t.labels.onSet(r=>{s(i=>{const l=i.filter(a=>a.key!==r.key);return l.length===i.length?i:[...l,r]})}),t.labels.onDelete(r=>s(i=>i.filter(l=>l.key!==r))),t.relationships.onSet(async r=>{if(!Xt(r,n))return;const{key:i}=r.to,l=await e.labels.retrieve({key:i});t.labels.set(i,l),s(a=>[...a.filter(c=>c.key!==i),l])}),t.relationships.onDelete(r=>{const i=P.ew.relationshipZ.parse(r);Xt(i,n)&&s(l=>l.filter(a=>a.key!==i.to.key))})]}),br=Ke({name:"Labels",retrieve:async({client:e,params:t})=>await e.labels.retrieve(t),retrieveByKey:async({client:e,key:t})=>await e.labels.retrieve({key:t}),mountListeners:({store:e,onChange:t,onDelete:n,params:{keys:s}})=>{const r=s?new Set(s):void 0;return[e.labels.onSet(async i=>{r!=null&&!r.has(i.key)||t(i.key,i,{mode:"prepend"})}),e.labels.onDelete(async i=>n(i))]}}),Ec=P.Sw.labelZ.partial({key:!0}),oj=Dt({name:"Label",initialValues:{name:"",color:"#000000"},schema:Ec,retrieve:async({client:e,params:{key:t},reset:n})=>{t!=null&&n(await e.labels.retrieve({key:t}))},update:async({client:e,value:t,reset:n})=>{const s=await e.labels.create(t());n(s)},mountListeners:({store:e,params:{key:t},reset:n})=>[e.labels.onSet(async s=>{t==null||s.key!==t||n(s)},t)]}),rj=Qe({name:"Label",update:async({client:e,params:{key:t}})=>await e.labels.delete(t)}).useDirect,vr="label",ij=({itemKey:e,...t})=>{const n=f.useItem(e),{selected:s,onSelect:r,hovered:i}=f.useItemState(e);return n==null?null:o.jsxRuntimeExports.jsx(f.Item,{itemKey:e,onSelect:r,selected:s,hovered:i,...t,children:o.jsxRuntimeExports.jsxs(f.Text,{align:"center",children:[o.jsxRuntimeExports.jsx(f.Circle,{color:n?.color,size:"2.5em"}),n?.name]})})},yc=f.renderProp(ij),lj=f.renderProp(e=>{const{itemKey:t}=e,n=f.useItem(t),{onSelect:s}=f.useItemState(t);return n==null?null:o.jsxRuntimeExports.jsx(Ns,{color:n.color,onClose:s,size:"small",children:n.name})}),aj={variant:"text"},cj=({onChange:e,value:t,emptyContent:n,filter:s,initialParams:r,...i})=>{const{data:l,retrieve:a,getItem:c,subscribe:d,status:x}=br({filter:s,initialParams:r}),{fetchMore:p,search:m}=nt.usePager({retrieve:a});return o.jsxRuntimeExports.jsx(Ms,{resourceName:"Label",haulType:vr,value:t,onChange:e,data:l,getItem:c,subscribe:d,onFetchMore:p,onSearch:m,emptyContent:n,status:x,renderTag:lj,icon:o.jsxRuntimeExports.jsx(f.Label,{}),triggerProps:aj,variant:"floating",...i,children:yc})},uj=({onChange:e,value:t,allowNone:n,emptyContent:s,filter:r,initialParams:i,...l})=>{const{data:a,retrieve:c,getItem:d,subscribe:x,status:p}=br({filter:r,initialParams:i}),{fetchMore:m,search:h}=nt.usePager({retrieve:c});return o.jsxRuntimeExports.jsx(Ot,{resourceName:"Label",value:t,onChange:e,data:a,getItem:d,subscribe:x,allowNone:n,onFetchMore:m,onSearch:h,emptyContent:s,status:p,haulType:vr,...l,children:yc})},dj=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:gc,FLUX_STORE_KEY:hc,HAUL_TYPE:vr,SelectMultiple:cj,SelectSingle:uj,formSchema:Ec,matchRelationship:Xt,retrieveLabelsOf:jc,useDelete:rj,useForm:oj,useList:br},Symbol.toStringTag,{value:"Module"})),Is=new Error("Tab not found"),xj=new Error("Invalid Mosaic"),ds=(e,t,n="center",s,r)=>{if(e=Ze(e),s===void 0)return Lo(e,t);const i=Mo(e,s);if(n==="center")return i.tabs||=[],r!==void 0&&r>=0&&r<=i.tabs.length?i.tabs.splice(r,0,t):i.tabs.push(t),i.selected=t.tabKey,e;const l=i.key*2,a=i.key*2+1,c=n==="top"||n==="left"?l:a;if(Mo(e,c).key!==i.key)return ds(e,t,"center",c);if(i.tabs==null||i.tabs.length===0)return ds(e,t,"center",s);const[d,x,p]=jj(n);if(i.direction=p,i[d]={key:0,tabs:[t],selected:t.tabKey},i[x]={key:0,tabs:i.tabs,selected:i.selected},i.first==null||i.last==null)throw xj;return i.first.key=l,i.last.key=a,i.tabs=void 0,i.size=void 0,i.selected=void 0,e},pj=(e,t,n)=>{e=Ze(e);const[s,r]=Lt(e,t);if(s==null||r==null)throw Is;return r.tabs=r.tabs?.map(i=>i.tabKey===t?n(i):i),e},Lo=(e,t)=>(e=Ze(e),e.tabs!=null?(e.tabs.push(t),e.selected=t.tabKey,e):(e.first!=null?e.first=Lo(e.first,t):e.last!=null&&(e.last=Lo(e.last,t)),e)),xs=e=>{e=Ze(e);const t=[];if(e.tabs!=null&&(e.selected=Me.resetSelection(e.selected,e.tabs),e.selected!=null&&t.push(e.selected)),e.first!=null){const[n,s]=xs(e.first);e.first=n,t.push(...s)}if(e.last!=null){const[n,s]=xs(e.last);e.last=n,t.push(...s)}return[e,t]},_r=(e,t)=>{e=Ze(e);const[,n]=Lt(e,t);if(n==null)return[e,null];n.tabs=n.tabs?.filter(r=>r.tabKey!==t),n.selected=Me.resetSelection(n.selected,n.tabs),e=gj(e);const s=n.selected??ps(e);return[e,s]},ps=e=>e.selected!=null?e.selected:e.first!=null?ps(e.first):e.last!=null?ps(e.last):null,Sc=(e,t)=>{e=Ze(e);const[n,s]=Lt(e,t);if(n==null||s==null)throw Is;return s.selected=t,e},Rc=(e,t,n,s,r)=>{e=Ze(e);const[i,l]=Lt(e,t);if(i==null||l==null)throw Is;const[a,c]=_r(e,t);return[ds(a,i,n,s,r),c]},Cn=(e,t)=>{if(e.tabs!=null)return e.tabs.some(n=>n.tabKey===t)?e:void 0;if(e.first!=null){const n=Cn(e.first,t);if(n!=null)return n}if(e.last!=null){const n=Cn(e.last,t);if(n!=null)return n}},Cc=(e,t,n)=>{const s=ms(e,t);if(s==null)throw new Error("Node not found");return s.size=n,e},mj=(e,t,n)=>{e=Ze(e);const s=Cn(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,c={key:s.key*2+1,tabs:[i],selected:i.tabKey},d={key:l,tabs:s.tabs,selected:s.selected};return d.selected=Me.resetSelection(d.selected,d.tabs),s.direction=n,s.first=d,s.last=c,s.tabs=void 0,s.selected=void 0,e},fj=(e,t)=>{const n=Cn(e,t);return n==null?!1:n.tabs!=null&&n.tabs.length>1},wc=(e,t,n)=>{e=Ze(e);const[,s]=Lt(e,t);if(s?.tabs==null)throw Is;return s.tabs=Me.rename(t,n,s?.tabs??[]),e},hj=e=>e.tabs!=null?e.tabs.length===0:e.first==null&&e.last==null,Mo=(e,t)=>{const n=ms(e,t);if(n!=null)return n;const s=Math.floor(t/2);return s===0?e:Mo(e,s)},gj=e=>{let t=!0;for(;t;)[e,t]=No(e);return e=To(e,1),e},No=e=>{if(e.first==null||e.last==null)return[e,!1];if(_i(e.first))return[vi(e.last),!0];if(_i(e.last))return[vi(e.first),!0];let t,n;return[e.first,t]=No(e.first),[e.last,n]=No(e.last),[e,t||n]},vi=e=>(e.size=void 0,e),_i=e=>e.first==null&&e.last==null&&(e.tabs==null||e.tabs.length===0),Lt=(e,t)=>{if(e.tabs!=null){const l=e.tabs.find(a=>a.tabKey===t);if(l!=null)return[l,e]}if(e.first==null||e.last==null)return[void 0,void 0];const[n,s]=Lt(e.first,t);if(n!=null&&s!=null)return[n,s];const[r,i]=Lt(e.last,t);return[r,i]},ms=(e,t)=>{if(e.key===t)return e;if(e.first==null||e.last==null)return;const n=ms(e.first,t);return n??ms(e.last,t)},jj=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")}},Ze=e=>({...e,first:e.first!=null?Ze(e.first):void 0,last:e.last!=null?Ze(e.last):void 0}),fs=(e,t,n=[])=>(n.push(t(e)),e.first!=null&&fs(e.first,t,n),e.last!=null&&fs(e.last,t,n),n),Po=(e,t)=>{t(e),e.first!=null&&Po(e.first,t),e.last!=null&&Po(e.last,t)},To=(e,t)=>(e=Ze(e),e.key=t,e.first!=null&&(e.first=To(e.first,t*2)),e.last!=null&&(e.last=To(e.last,t*2+1)),e);class bc{parent;stub;el;constructor(t={}){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 Ej=({node:e})=>{const t=j.createRef(),n=j.useRef(e);return j.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)}},[]),j.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})},vc=({node:e,children:t})=>zl.createPortal(t,e.el),yj=Object.freeze(Object.defineProperty({__proto__:null,In:vc,Node:bc,Out:Ej},Symbol.toStringTag,{value:"Module"})),hs=j.memo(({root:e,onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,activeTab:l,emptyContent:a,onSelect:c,onClose:d,onRename:x,onReorder:p,contextMenu:m,addTooltip:h,className:g,...E})=>{const{tabs:S,direction:R,first:v,last:y,key:C,size:_}=e,M={onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,onClose:d,contextMenu:m,onSelect:c,onRename:x,onReorder:p,activeTab:l,addTooltip:h},I=j.useCallback(([$])=>n(C,$),[n]),{props:A}=Ql({direction:R,onResize:I,count:2,initialSizes:_!=null?[_]:void 0});let B={};C==1&&(B={...E,className:u.CSS(u.CSS.B("mosaic"),g)});let z;return S!==void 0?z=o.jsxRuntimeExports.jsx(_c,{root:e,emptyContent:a,...B,...M}):v!=null&&y!=null?z=o.jsxRuntimeExports.jsxs(Jl,{id:`mosaic-${C}`,align:"stretch",...A,...B,children:[o.jsxRuntimeExports.jsx(hs,{...M,root:v,onResize:n},v.key),o.jsxRuntimeExports.jsx(hs,{...M,root:y,onResize:n},y.key)]}):(z=null,console.warn("Mosaic tree is malformed")),z});hs.displayName="Mosaic";const gs="pluto-mosaic-tab-drop",kr="pluto-mosaic-tab-create",Sj=(e,t,n)=>{if(f.filterByType(f.FILE_TYPE,t).length>0&&n)return!0;const r=f.filterByType(gs,t).map(a=>a.key),i=e.filter(a=>!r.includes(a.tabKey)).length>0;return f.filterByType(kr,t).length>0||r.length>0&&(i||e.length===0)},_c=j.memo(({root:e,onDrop:t,onCreate:n,activeTab:s,children:r,className:i,onReorder:l,onFileDrop:a,addTooltip:c,...d})=>{const{key:x,tabs:p}=e,[m,h]=j.useState(null),g=a!=null,E=j.useCallback(({items:B})=>Sj(p,B,g),[p,g]),S=j.useCallback(({items:B,event:z})=>{if(z==null)return[];const $=Cj(z);h(null);const D=f.filterByType(f.FILE_TYPE,B).length>0,{percents:V}=ki(z),b=p.length===0?"center":Li(V);if(D)return a?.(x,b,z),B;const k=f.filterByType(gs,B);if(k.length>0){const N=k.map(({key:F})=>F)[0];t(x,N,b,$)}const L=f.filterByType(kr,B);if(L.length>0){const N=L.map(({key:F})=>F);n?.(x,b,N)}return k},[t,p.length]),R=j.useCallback(({event:B})=>{if(B==null)return;const{percents:z,inSelector:$}=ki(B);let D=null;$||(D=p.length===0?"center":Li(z)),h(D)},[p.length]),{startDrag:v,...y}=f.useDragAndDrop({type:"Mosaic",canDrop:E,onDrop:S,onDragOver:R}),C=E(f.useDraggingState()),_=j.useCallback(()=>h(null),[]),M=j.useCallback((B,{tabKey:z})=>{v([{key:z,type:gs,elementID:B.currentTarget.id}])},[v]),I=j.useCallback(()=>n?.(x,"center"),[x]),A=x==1&&p.length==0;return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:o.jsxRuntimeExports.jsxs(Me.Tabs,{id:`tab-${x}`,tabs:p,className:u.CSS(i,A&&m!=null&&u.CSS.M("drag-over")),onDragLeave:_,selected:e.selected,selectedAltColor:s===e.selected,onDragStart:M,onCreate:I,addTooltip:c,...y,...d,children:[e.selected!=null&&r(p.find(B=>B.tabKey===e.selected)),C&&o.jsxRuntimeExports.jsx("div",{style:{zIndex:1e3,position:"absolute",top:0,left:0,width:"100%",height:"100%"}}),m!=null&&o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("mosaic","mask"),style:Rj[m]})]})})});_c.displayName="MosaicTabLeaf";const Rj={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%"}},ki=e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;return s<24?{percents:{x:.5,y:.5},inSelector:!0}:{percents:{x:n/t.width,y:s/t.height},inSelector:!1}},Cj=e=>{const t=e.target.closest(".pluto-tabs-selector__btn");if(t!=null)return Array.from(t.parentElement?.children??[]).indexOf(t)},wj=e=>e,bj=e=>1-e,Li=({x:e,y:t})=>{if(e>.33&&e<.66&&t>.33&&t<.66)return"center";const[n,s]=[wj(e),bj(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")},vj=({root:e,onSelect:t,children:n})=>{const s=j.useRef(new Map),r=new Set,i=fs(e,l=>l.tabs?.map(a=>{let c=s.current.get(a.tabKey);return a==null?null:(c==null&&(c=new bc({style:"width: 100%; height: 100%; position: relative;"}),c.el.addEventListener("click",()=>t?.(a.tabKey)),s.current.set(a.tabKey,c)),r.add(a.tabKey),o.jsxRuntimeExports.jsx(vc,{node:c,children:n({...a,visible:a.tabKey===l.selected})},a.tabKey))})).flat().filter(l=>l!=null);return s.current.forEach((l,a)=>!r.has(a)&&s.current.delete(a)),[s,i]},Io=te.z.object({key:te.z.number(),tabs:te.z.array(Me.tabZ).optional(),selected:te.z.string().optional(),direction:u.p.direction.optional(),size:te.z.number().optional(),get first(){return Io.optional()},get last(){return Io.optional()}}),_j=({allowRename:e=!1,initialTree:t})=>{const[n,s]=j.useState(t);return j.useEffect(()=>s(xs(t)[0]),[t]),{root:n,onDrop:(d,x,p)=>s(m=>Rc(m,x,p,d)[0]),onClose:d=>s(x=>_r(x,d)[0]),onSelect:d=>s(x=>Sc(x,d)),onResize:(d,x)=>s(p=>Cc(p,d,x)),onRename:e?(d,x)=>s(p=>wc(p,d,x)):void 0}},kj=Object.freeze(Object.defineProperty({__proto__:null,HAUL_CREATE_TYPE:kr,HAUL_DROP_TYPE:gs,Mosaic:hs,autoSelectTabs:xs,canSplit:fj,findSelected:ps,findTabNode:Cn,forEachNode:Po,insertTab:ds,isEmpty:hj,mapNodes:fs,moveTab:Rc,nodeZ:Io,removeTab:_r,renameTab:wc,resizeNode:Cc,selectTab:Sc,split:mj,updateTab:pj,use:_j,usePortal:vj},Symbol.toStringTag,{value:"Module"})),Lj=({variant:e,className:t,...n})=>o.jsxRuntimeExports.jsx(f.Box,{className:u.CSS(t,u.CSS.B("note"),u.CSS.M(e)),align:"stretch",empty:!0,...n}),Mj=Object.freeze(Object.defineProperty({__proto__:null,Note:Lj},Symbol.toStringTag,{value:"Module"})),kc="relationships",Lc="resources",Nj={channel:P.ew.RELATIONSHIP_SET_CHANNEL_NAME,schema:P.ew.relationshipZ,onChange:({store:e,changed:t})=>e.relationships.set(P.ew.relationshipToString(t),t)},Pj={channel:P.ew.RELATIONSHIP_DELETE_CHANNEL_NAME,schema:P.ew.relationshipZ,onChange:({store:e,changed:t})=>e.relationships.delete(P.ew.relationshipToString(t))},Mc={listeners:[Nj,Pj]},Tj={channel:P.ew.RESOURCE_SET_CHANNEL_NAME,schema:P.ew.idZ,onChange:async({store:e,changed:t,client:n})=>e.resources.set(P.ew.idToString(t),await n.ontology.retrieve(t))},Ij={channel:P.ew.RESOURCE_DELETE_CHANNEL_NAME,schema:P.ew.idZ,onChange:({store:e,changed:t})=>e.resources.delete(t.key)},Nc={listeners:[Tj,Ij]},Oj=e=>{const t=He();j.useEffect(()=>t.resources.onSet(e),[t.resources])},Aj=e=>{const t=He();j.useEffect(()=>{const n=t.resources.onDelete(async s=>e(P.ew.idZ.parse(s)));return()=>n()},[t.resources])},Dj=e=>{const t=He();j.useEffect(()=>t.relationships.onSet(e),[t.relationships])},Bj=e=>{const t=He();j.useEffect(()=>t.relationships.onDelete(n=>e(P.ew.relationshipZ.parse(n))),[t.relationships])},Pc=e=>Ke({name:"useDependents",retrieve:async({client:t,params:{id:n}})=>n==null?[]:await t.ontology.retrieve([n],{children:e==="to",parents:e==="from"}),retrieveByKey:async({client:t,key:n})=>await t.ontology.retrieve(n),mountListeners:({store:t,onChange:n,onDelete:s,client:r,params:{id:i}})=>[t.relationships.onSet(async l=>{if(P.ew.matchRelationship(l,{type:"parent",[P.ew.oppositeRelationshipDirection(e)]:i})){const a=await r.ontology.retrieve(l[e]);n(a.key,a)}}),t.relationships.onDelete(l=>{const a=P.ew.relationshipZ.parse(l);P.ew.matchRelationship(a,{type:"parent",[P.ew.oppositeRelationshipDirection(e)]:i})&&s(P.ew.idToString(a[e]))}),t.resources.onSet(l=>n(l.key,a=>a==null?null:{...a,...l})),t.resources.onDelete(async l=>s(l))]}),$j=Pc("to"),zj=Ke({name:"useResourceList",retrieveCached:({store:e})=>e.resources.list(),retrieve:async({client:e,params:t,store:n})=>{const s=await e.ontology.retrieve(t);return s.forEach(r=>n.resources.set(r.key,r)),s},retrieveByKey:async({client:e,key:t,store:n})=>{const s=await e.ontology.retrieve(P.ew.idZ.parse(t));return n.resources.set(t,s),s},mountListeners:({store:e,onChange:t,onDelete:n})=>[e.resources.onSet(async s=>t(s.key,s)),e.resources.onDelete(async s=>n(s))]}),Vj=qe({name:"useParentID",retrieve:async({client:e,params:t})=>{const n=await e.ontology.retrieveParents(t.id);if(t.type==null)return n[0].id;const s=n.find(({id:r})=>r.type===t.type);return s==null?null:s.id},mountListeners:({store:e,onChange:t,client:n,params:{id:s}})=>[e.relationships.onSet(async r=>{if(P.ew.matchRelationship(r,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:s})){const i=await n.ontology.retrieve(r.from);t(i.id)}else t(null)}),e.relationships.onDelete(async r=>{const i=P.ew.relationshipZ.parse(r);P.ew.matchRelationship(i,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:s})&&t(null)})]}),Fj=Object.freeze(Object.defineProperty({__proto__:null,RELATIONSHIPS_FLUX_STORE_KEY:kc,RELATIONSHIP_FLUX_STORE_CONFIG:Mc,RESOURCES_FLUX_STORE_KEY:Lc,RESOURCE_FLUX_STORE_CONFIG:Nc,createDependentsListHook:Pc,retrieveParentID:Vj,useChildren:$j,useRelationshipDeleteSynchronizer:Bj,useRelationshipSetSynchronizer:Dj,useResourceDeleteSynchronizer:Aj,useResourceList:zj,useResourceSetSynchronizer:Oj},Symbol.toStringTag,{value:"Module"})),lo={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"})]})},Hj=({disabled:e=[],className:t,focused:n=!0,onMinimize:s,onMaximize:r,onFullscreen:i,onClose:l,...a})=>o.jsxRuntimeExports.jsxs(f.Box,{gap:1.5,x:!0,className:u.CSS(u.CSS.B("macos-controls"),!n&&u.CSS.BM("macos-controls","blurred"),t),...a,children:[o.jsxRuntimeExports.jsx(ao,{onClick:l,className:u.CSS.BM("macos-control","close"),disabled:e.includes("close"),children:lo.Close}),o.jsxRuntimeExports.jsx(ao,{onClick:s,className:u.CSS.BM("macos-control","minimize"),disabled:e.includes("minimize"),children:lo.Minimize}),o.jsxRuntimeExports.jsx(ao,{onClick:i,className:u.CSS.BM("macos-control","maximize"),disabled:e.includes("maximize"),children:lo.Maximize})]}),ao=({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,...s}),Zj=({disabled:e=[],onMinimize:t,onMaximize:n,onClose:s,onFullscreen:r,focused:i,contrast:l=2,...a})=>o.jsxRuntimeExports.jsxs(f.Box,{pack:!0,...a,children:[o.jsxRuntimeExports.jsx(co,{className:u.CSS.BM("windows-control","minimize"),onClick:t,disabled:e.includes("minimize"),contrast:l,children:o.jsxRuntimeExports.jsx(f.Subtract,{})}),o.jsxRuntimeExports.jsx(co,{className:u.CSS.BM("windows-control","maximize"),onClick:n,disabled:e.includes("maximize"),contrast:l,children:o.jsxRuntimeExports.jsx(f.Box$1,{})}),o.jsxRuntimeExports.jsx(co,{onClick:s,className:u.CSS.BM("windows-control","close"),disabled:e.includes("close"),contrast:l,children:o.jsxRuntimeExports.jsx(f.Close,{})})]}),co=({disabled:e=!1,className:t,...n})=>e?null:o.jsxRuntimeExports.jsx(f.Button,{className:u.CSS(u.CSS.B("windows-control"),t),tabIndex:-1,...n}),Tc=u.S.getOS,Kj="Windows",Yj=({forceOS:e,visibleIfOS:t,...n})=>{const s=Tc({force:e,default:Kj});if(t!=null&&t!==s)return null;const r=s==="macOS"?Hj:Zj;return o.jsxRuntimeExports.jsx(r,{...n})},Gj=Object.freeze(Object.defineProperty({__proto__:null,Controls:Yj,use:Tc},Symbol.toStringTag,{value:"Module"})),Uj=(e,t)=>{const n=s=>o.jsxRuntimeExports.jsx(e,{...t,...s});return n.displayName=e.displayName,n},Wj=Object.freeze(Object.defineProperty({__proto__:null,createComponent:Uj},Symbol.toStringTag,{value:"Module"}));j.createContext({instrumentation:P.O.NOOP});const Xj=({children:e,...t})=>{const{path:n}=f.useUnidirectional({type:P.Provider$1.TYPE,schema:P.providerStateZ,state:t});return o.jsxRuntimeExports.jsx(f.Composite,{path:n,children:e})},qj="groups",Qj={channel:P.Jm.SET_CHANNEL_NAME,schema:P.Jm.groupZ,onChange:({store:e,changed:t})=>e.groups.set(t.key,t)},Jj={channel:P.Jm.DELETE_CHANNEL_NAME,schema:P.Jm.keyZ,onChange:({store:e,changed:t})=>e.groups.delete(t)},e2={listeners:[Qj,Jj]};Qe({name:"Group",update:async({client:e,value:t,params:n})=>await e.ontology.groups.rename(n.key,t)}).useDirect;Qe({name:"Group",update:async({client:e,params:t})=>await e.ontology.groups.delete(t.key)}).useDirect;const t2="data:video/mp2t;base64,Ly8gQ29weXJpZ2h0IDIwMjUgU3lubmF4IExhYnMsIEluYy4KLy8KLy8gVXNlIG9mIHRoaXMgc29mdHdhcmUgaXMgZ292ZXJuZWQgYnkgdGhlIEJ1c2luZXNzIFNvdXJjZSBMaWNlbnNlIGluY2x1ZGVkIGluIHRoZSBmaWxlCi8vIGxpY2Vuc2VzL0JTTC50eHQuCi8vCi8vIEFzIG9mIHRoZSBDaGFuZ2UgRGF0ZSBzcGVjaWZpZWQgaW4gdGhhdCBmaWxlLCBpbiBhY2NvcmRhbmNlIHdpdGggdGhlIEJ1c2luZXNzIFNvdXJjZQovLyBMaWNlbnNlLCB1c2Ugb2YgdGhpcyBzb2Z0d2FyZSB3aWxsIGJlIGdvdmVybmVkIGJ5IHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAsCi8vIGluY2x1ZGVkIGluIHRoZSBmaWxlIGxpY2Vuc2VzL0FQTC50eHQuCgppbXBvcnQgeyBwbHV0byB9IGZyb20gIkAvcGx1dG8vYWV0aGVyIjsKCnBsdXRvLnJlbmRlcigpOwo=",Ic="rangeKV",Oc="rangeAliases",wn=async(e,t,n)=>{const s=t.ranges.get(n);if(s!=null)return s;const r=await e.ranges.retrieve({keys:[n],includeParent:!0,includeLabels:!0});return t.ranges.set(n,r[0]),r[0]},n2=async(e,t,n)=>{const s=await e.ranges.retrieve({...n,includeParent:!0,includeLabels:!0});return t.ranges.set(s),s},s2=e=>{const t=He();j.useEffect(()=>t.ranges.onSet(n=>e(n.payload)),[t])},Ac=async(e,t,n,s)=>{if(P.ew.matchRelationship(e,{from:{type:"range"},type:P.Sw.LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE,to:{type:"label"}})){let i=s.labels.get(e.to.key);i==null&&(i=await n.labels.retrieve({key:e.to.key}),s.labels.set(e.to.key,i)),t(e.from.key,l=>l==null?l:n.ranges.sugarOne({...l,labels:[...l.labels?.filter(a=>a.key!==e.to.key)??[],i]}))}},Dc=async(e,t,n,s)=>{if(P.ew.matchRelationship(e,{from:{type:"range"},type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:{type:"range"}})){const i=await n.ranges.retrieve(e.from.key);s.ranges.set(e.from.key,i),t(e.to.key,l=>l==null?l:n.ranges.sugarOne({...l,parent:i}))}},o2=Ke({name:"Range",retrieve:async({client:e,params:{key:t},store:n})=>{const s=await e.ontology.retrieveChildren(P.Iw.ontologyID(t),{types:["range"]});return s.length===0?[]:await n2(e,n,{keys:s.map(({id:{key:r}})=>r)})},retrieveByKey:async({client:e,key:t,store:n})=>await wn(e,n,t),mountListeners:({store:e,onChange:t,onDelete:n,client:s,params:{key:r}})=>[e.ranges.onSet(i=>{t(i.key,l=>l==null?l:s.ranges.sugarOne({...i,parent:i.parent??l.parent,labels:i.labels??l.labels}))}),e.ranges.onDelete(async i=>n(i)),e.relationships.onSet(async i=>{if(r==null)return;if(await Dc(i,t,s,e),await Ac(i,t,s,e),P.ew.matchRelationship(i,{from:P.Iw.ontologyID(r),type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:{type:"range"}})){const a=await s.ranges.retrieve({keys:[i.to.key],includeParent:!0,includeLabels:!0});return t(i.to.key,a[0])}}),e.relationships.onDelete(async i=>{if(r==null)return;const l=P.ew.relationshipZ.parse(i);if(P.ew.matchRelationship(l,{from:P.Iw.ontologyID(r),type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:{type:"range"}}))return n(l.to.key);l.type===P.Sw.LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE&&t(l.from.key,d=>d==null?d:s.ranges.sugarOne({...d,labels:d.labels?.filter(x=>x.key!==l.to.key)}))})]}),r2=qe({name:"Range",retrieve:async({client:e,params:{id:t}})=>{const s=(await e.ontology.retrieveParents(t)).find(({id:{type:r}})=>r==="range");return s==null?null:e.ranges.sugarOntologyResource(s)},mountListeners:({store:e,onChange:t,client:n,params:{id:s}})=>[e.ranges.onSet(r=>{t(i=>i==null||i.key!==r.key?i:n.ranges.sugarOne({...r,parent:r.parent??i.parent,labels:r.labels??i.labels}))}),e.relationships.onSet(async r=>{if(!P.ew.matchRelationship(r,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:s}))return;if(!(r.from.type==="range"))return t(null);const a=await wn(n,e,r.from.key);t(n.ranges.sugarOne(a.payload))}),e.relationships.onDelete(async r=>{const i=P.ew.relationshipZ.parse(r);P.ew.matchRelationship(i,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:s})&&t(null),P.ew.matchRelationship(i,{type:P.Sw.LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE,to:s})&&t(c=>c==null?c:n.ranges.sugarOne({...c,labels:c.labels?.filter(d=>d.key!==i.to.key)}))})]}),Bc=qe({name:"Range",retrieve:async({client:e,params:{key:t},store:n})=>await wn(e,n,t),mountListeners:({store:e,onChange:t,client:n,params:{key:s}})=>[e.ranges.onSet(async r=>{if(r!=null)return t(r)},s),e.relationships.onSet(async r=>{if(Xt(r,P.Iw.ontologyID(s))){const a=await n.labels.retrieve({key:r.to.key});e.labels.set(r.to.key,a),t(c=>c==null?c:n.ranges.sugarOne({...c,labels:[...(c.labels??[]).filter(d=>d.key!==a.key),a]}))}if(P.ew.matchRelationship(r,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:P.Iw.ontologyID(s)})){const a=await n.ranges.retrieve(r.from.key);e.ranges.set(r.from.key,a),t(c=>c==null?c:n.ranges.sugarOne({...c,parent:a}))}},s)]}),i2=Bc.useDirect,$c=te.z.object({...P.Iw.payloadZ.omit({timeRange:!0}).partial({key:!0}).shape,labels:te.z.array(P.Sw.keyZ),parent:te.z.string().optional(),timeRange:te.z.object({start:te.z.number(),end:te.z.number()})}),Oo=async e=>({...e.payload,timeRange:e.timeRange.numeric,parent:e.parent?.key,labels:e.labels?.map(t=>t.key)??[]}),l2={name:"",labels:[],parent:"",timeRange:{start:0,end:0}},a2=Dt({name:"Range",schema:$c,initialValues:l2,retrieve:async({client:e,params:{key:t},store:n,reset:s})=>{t!=null&&s(await Oo(await wn(e,n,t)))},update:async({client:e,value:t,reset:n,store:s})=>{const r=t(),i=r.parent,l=u.O$1.isNonZero(i)?P.Iw.ontologyID(i):void 0,a=await e.ranges.create(r,{parent:l});await e.labels.label(a.ontologyID,r.labels,{replace:!0});const c=s.labels.get(r.labels),d=new Set(c.map(m=>m.key)),x=r.labels.filter(m=>!d.has(m));if(x.length>0){const m=await e.labels.retrieve({keys:x});c.push(...m),s.labels.set(m)}let p=null;u.O$1.isNonZero(i)&&(p=await wn(e,s,i)),s.ranges.set(a.key,e.ranges.sugarOne({...a.payload,labels:c,parent:p?.payload??null})),n({...r,...a.payload,timeRange:a.timeRange.numeric,labels:r.labels,parent:r.parent})},mountListeners:({store:e,reset:t,get:n,set:s})=>[e.ranges.onSet(async r=>{const i=await Oo(r),l=n("key",{optional:!0})?.value;if(l==null||l!==r.key)return;const a=n("parent",{optional:!0})?.value,c=n("labels").value;t({...i,labels:c,parent:a})}),e.relationships.onSet(r=>{const i=n("key",{optional:!0})?.value;if(i==null)return;const l=P.Iw.ontologyID(i);if(Xt(r,l)){const d=n("labels").value;return s("labels",[...d.filter(x=>x!==r.to.key),r.to.key])}P.ew.matchRelationship(r,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:l})&&s("parent",r.from.key)}),e.relationships.onDelete(r=>{const i=n("key",{optional:!0})?.value;if(i==null)return;const l=P.ew.relationshipZ.parse(r),a=P.Iw.ontologyID(i);if(Xt(l,a))return s("labels",n("labels").value.filter(x=>x!==l.to.key));if(P.ew.matchRelationship(l,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:a}))return s("parent",void 0)})]}),c2=e=>jc.useDirect({params:{id:P.Iw.ontologyID(e)}}),u2={includeParent:!0,includeLabels:!0},Lr=Ke({name:"Ranges",retrieveCached:({store:e,params:t})=>e.ranges.get(n=>u.O$1.isNonZero(t.keys)?t.keys.includes(n.key):!0),retrieve:async({client:e,params:t})=>await e.ranges.retrieve({...u2,...t}),retrieveByKey:async({client:e,key:t,store:n})=>{const s=n.ranges.get(t);if(s!=null)return s;const r=await e.ranges.retrieve(t);return n.ranges.set(t,r),r},mountListeners:({store:e,onChange:t,onDelete:n,client:s,params:{keys:r}})=>{const i=r!=null&&r.length>0,l=new Set(r);return[e.ranges.onSet(a=>{i&&!l.has(a.key)||t(a.key,c=>c==null?a:s.ranges.sugarOne({...a.payload,labels:a.labels??c.labels}))}),e.ranges.onDelete(async a=>n(a)),e.relationships.onSet(async a=>{await Dc(a,t,s,e),await Ac(a,t,s,e)})]}}),d2=te.z.object({pairs:te.z.array(te.z.object({key:te.z.string(),value:te.z.string()}))}),zc=te.z.string().transform(e=>e.split("<--->")).transform(([e,t])=>({key:t,range:e})),x2={channel:P.Iw.KV_SET_CHANNEL,schema:P.Iw.kvPairZ,onChange:({store:e,changed:t})=>{e.rangeKV.set(P.Iw.kvPairKey(t),t)}},p2={channel:P.Iw.KV_DELETE_CHANNEL,schema:zc,onChange:({store:e,changed:t})=>e.rangeKV.delete(P.Iw.kvPairKey(t))},Vc={listeners:[x2,p2]},m2=Ke({name:"Range Meta Data",retrieve:async({client:e,params:{rangeKey:t}})=>{const s=await e.ranges.getKV(t).list();return Object.entries(s).map(([r,i])=>({key:r,value:i,range:t}))},retrieveByKey:async({client:e,key:t,params:{rangeKey:n}})=>{if(n==null)return;const r=await e.ranges.getKV(n).get(t);return{key:t,value:r,range:n}},mountListeners:({store:e,onChange:t,onDelete:n,params:{rangeKey:s}})=>[e.rangeKV.onSet(r=>{r.range===s&&t(r.key,r)}),e.rangeKV.onDelete(r=>{const i=zc.parse(r);i.range===s&&n(i.key)})]}),Fc=P.Iw.kvPairZ,f2=Dt({name:"Range Meta Data",schema:Fc,retrieve:async()=>{},update:async({client:e,value:t})=>{const{key:n,value:s,range:r}=t();await e.ranges.getKV(r).set(n,s)},initialValues:{key:"",value:"",range:""}}),h2=Qe({name:"Range Meta Data",update:async({client:e,value:t,params:{rangeKey:n}})=>{await e.ranges.getKV(n).delete(t)}}),g2=Qe({name:"Range Meta Data",update:async({client:e,value:t,onChange:n})=>{await e.ranges.getKV(t.range).set(t.key,t.value),n(t)}}),j2=Qe({name:"Range",update:async({client:e,value:t,onChange:n,store:s})=>{const r=await e.ranges.create(t);s.ranges.set(r.key,r),n(r)}}),E2=Qe({name:"Range",update:async({client:e,value:t,store:n})=>{await e.ranges.delete(t),n.ranges.delete(t)}}),y2={channel:P.Iw.SET_ALIAS_CHANNEL_NAME,schema:P.Iw.aliasZ,onChange:({store:e,changed:t})=>{e.rangeAliases.set(P.Iw.aliasKey(t),t)}},S2=te.z.string().transform(e=>P.Iw.decodeDeleteAliasChange(e)),R2={channel:P.Iw.DELETE_ALIAS_CHANNEL_NAME,schema:S2,onChange:({store:e,changed:t})=>e.rangeAliases.delete(P.Iw.aliasKey(t))},Hc={listeners:[y2,R2]},Zc=({timeRange:e,level:t="p",color:n=9,showSpan:s=!1,...r})=>{const i=new u.r(e.start),l=i.isToday?"time":"dateTime",a=new u.r(e.end),c=a.equals(u.r.MAX),d=a.span(i)<u.i.DAY?"time":"dateTime",x=i.span(a),p=o.jsxRuntimeExports.jsxs(f.Text,{x:!0,align:"center",gap:"small",children:[i.isToday&&o.jsxRuntimeExports.jsx(f.Text,{level:t,color:n,weight:450,children:"Today"}),o.jsxRuntimeExports.jsx(f.DateTime,{el:"span",level:t,displayTZ:"local",format:l,color:n,weight:450,children:i})]}),m=o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[c?o.jsxRuntimeExports.jsx(f.Text,{level:t,el:"span",children:"Now"}):o.jsxRuntimeExports.jsx(f.DateTime,{level:t,el:"span",displayTZ:"local",format:d,color:n,weight:450,children:a}),!x.isZero&&s&&o.jsxRuntimeExports.jsxs(f.Text,{level:t,color:n,weight:450,el:"span",children:["(",i.span(a).truncate(u.i.MILLISECOND).toString(),")"]})]});return o.jsxRuntimeExports.jsxs(f.Text,{x:!0,gap:"small",className:u.CSS(u.CSS.B("time-range-chip")),align:"center",level:t,color:n,...r,children:[p,o.jsxRuntimeExports.jsx(f.Arrow.Right,{color:9}),m]})},Mr="range",Nr=j.memo(({itemKey:e,showParent:t=!0,showLabels:n=!0,...s})=>{const r=f.useItem(e);if(r==null)return null;const{name:i,parent:l,timeRange:a,labels:c}=r;return o.jsxRuntimeExports.jsxs(f.ListItem,{itemKey:e,justify:"between",...s,children:[o.jsxRuntimeExports.jsxs(rr,{children:[o.jsxRuntimeExports.jsx(Rn,{weight:450,color:10,children:i}),l!=null&&t&&o.jsxRuntimeExports.jsx(Rn,{weight:400,color:8,children:l.name})]}),o.jsxRuntimeExports.jsxs(f.Box,{x:!0,children:[o.jsxRuntimeExports.jsx(Zc,{level:"small",timeRange:a}),n&&o.jsxRuntimeExports.jsx(sr,{variant:"text",children:c?.map(d=>o.jsxRuntimeExports.jsx(Ns,{color:d.color,size:"small",children:d.name},d.key))})]})]})});Nr.displayName="Ranger.ListItem";const Kc=f.renderProp(Nr),Yc=o.jsxRuntimeExports.jsx(f.Range,{}),C2=({onChange:e,value:t,emptyContent:n,filter:s,initialParams:r,...i})=>{const{data:l,retrieve:a,getItem:c,subscribe:d,status:x}=Lr({filter:s,initialParams:r}),{fetchMore:p,search:m}=nt.usePager({retrieve:a});return o.jsxRuntimeExports.jsx(Ms,{resourceName:"Range",haulType:Mr,value:t,onChange:e,data:l,getItem:c,icon:Yc,subscribe:d,onFetchMore:p,onSearch:m,emptyContent:n,status:x,...i,children:Kc})},w2={style:{width:800}},b2=({onChange:e,value:t,filter:n,allowNone:s,emptyContent:r,initialParams:i,...l})=>{const{data:a,retrieve:c,subscribe:d,getItem:x,status:p}=Lr({filter:n,initialParams:i}),{fetchMore:m,search:h}=nt.usePager({retrieve:c});return o.jsxRuntimeExports.jsx(Ot,{resourceName:"Range",variant:"modal",value:t,onChange:e,data:a,allowNone:s,haulType:Mr,onFetchMore:m,getItem:x,subscribe:d,status:p,onSearch:h,emptyContent:r,icon:Yc,itemHeight:45,dialogProps:w2,...l,children:Kc})},v2=Object.freeze(Object.defineProperty({__proto__:null,ALIAS_FLUX_STORE_CONFIG:Hc,HAUL_TYPE:Mr,KV_FLUX_STORE_CONFIG:Vc,ListItem:Nr,RANGE_ALIASES_FLUX_STORE_KEY:Oc,RANGE_KV_FLUX_STORE_KEY:Ic,SelectMultiple:C2,SelectSingle:b2,TimeRangeChip:Zc,formSchema:$c,kvPairFormSchema:Fc,metaDataFormSchema:d2,retrieve:Bc,retrieveParent:r2,toFormValues:Oo,useChildren:o2,useDelete:E2,useDeleteKV:h2,useForm:a2,useKVPairForm:f2,useLabels:c2,useList:Lr,useListKV:m2,useRetrieve:i2,useSetSynchronizer:s2,useUpdate:j2,useUpdateKV:g2},Symbol.toStringTag,{value:"Module"})),Gc=({children:e})=>{const{path:t}=f.useUnidirectional({type:O.BaseProvider.TYPE,schema:O.providerStateZ$2,state:{}});return o.jsxRuntimeExports.jsx(f.Composite,{path:t,children:e})},_2=new Set([u.n.UUID,u.n.JSON]),k2=e=>{if(e.equals(u.n.JSON))return o.jsxRuntimeExports.jsx(f.JSON,{});if(e.isInteger)return o.jsxRuntimeExports.jsx(f.Binary,{});if(e.isFloat)return o.jsxRuntimeExports.jsx(f.Decimal,{});if(e.equals(u.n.STRING)||e.equals(u.n.UUID))return o.jsxRuntimeExports.jsx(f.String,{});if(e.equals(u.n.TIMESTAMP))return o.jsxRuntimeExports.jsx(f.Time$1,{})},Uc=u.n.ALL.filter(e=>e!==u.n.UNKNOWN).map(e=>({key:e.toString(),name:_2.has(e)?e.toString().toUpperCase():u.z.capitalize(e.toString()),icon:k2(e)})),L2=Uc.filter(e=>!new u.n(e.key).isVariable),M2=({hideVariableDensity:e=!1,...t})=>{const n=e?L2:Uc;return o.jsxRuntimeExports.jsx(Pn,{...t,data:n,resourceName:"Data Type"})},N2=Object.freeze(Object.defineProperty({__proto__:null,Provider:Gc,SelectDataType:M2},Symbol.toStringTag,{value:"Module"})),P2=e=>{switch(e.variant){case"disabled":return e.details?.valid===!0?{message:"Uncontrolled. Click to take control.",chipColor:"var(--pluto-gray-l12)"}:{message:"No channel connected. This element cannot be controlled.",chipColor:"var(--pluto-gray-l7)",disabled:!0};case"error":return{message:"Not controlled by you. Click to take absolute control.",chipColor:"var(--pluto-error-z)"};case"success":return e.details?.authority===P.gw.ABSOLUTE_AUTHORITY?{message:"You have absolute control. Click to release.",chipColor:"var(--pluto-secondary-z)",buttonStyle:{background:"var(--pluto-secondary-z-30)"}}:{message:"You're in control. Release schematic to release control.",chipColor:"var(--pluto-primary-z)"};default:return{message:"Unexpected status.",chipColor:"var(--pluto-error-z)"}}},Wc=({source:e,sink:t,className:n,...s})=>{const r=f.useMemoDeepEqual({source:e,sink:t}),[,{status:i},l]=f.use$2({type:O.Chip.TYPE,schema:O.chipStateZ,initialState:{triggered:!1,...r,status:{key:"no_chip",variant:"disabled",message:"No chip connected.",time:u.r.now(),details:{}}}});j.useEffect(()=>{l(m=>({...m,...r}))},[r,l]);const a=j.useCallback(()=>l(m=>({...m,triggered:!m.triggered})),[l]),{message:c,chipColor:d,buttonStyle:x,disabled:p}=P2(i);return o.jsxRuntimeExports.jsx(f.Button,{variant:"text",className:u.CSS(u.CSS.B("control-chip"),n),disabled:p,onClick:a,tooltip:o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:c}),style:x,...s,children:o.jsxRuntimeExports.jsx(f.Circle,{color:d})})},Xc=j.createContext({needsControlOf:[]}),qc=()=>j.use(Xc),T2=({children:e,onStatusChange:t,...n})=>{const s=f.useMemoDeepEqual(n),[{path:r},{status:i,needsControlOf:l},a]=f.use$2({type:O.Controller.TYPE,schema:O.controllerStateZ,initialState:s});return j.useEffect(()=>{i!=null&&t?.(i)},[i,t]),j.useEffect(()=>{a(c=>({...c,...s}))},[s,a]),j.useEffect(()=>()=>t?.("released"),[]),o.jsxRuntimeExports.jsxs(Xc,{value:{needsControlOf:l},children:[o.jsxRuntimeExports.jsx(f.Composite,{path:r,children:e}),";"]})},Qc=({colorSource:e,statusSource:t})=>{const n=f.useMemoDeepEqual({colorSource:e,statusSource:t}),[,{color:s,status:r},i]=f.use$2({type:O.Indicator.TYPE,initialState:{...n,status:{key:"no_chip",variant:"warning",message:"No chip connected.",time:u.r.now(),details:{color:void 0}}},schema:O.indicatorStateZ});j.useEffect(()=>{i(a=>({...a,...n}))},[n,i]);let l;return r.details?.color!=null?l=u.cr.colorZ.parse(r.details.color):s!=null&&!u.cr.isZero(s)?l=s:l="var(--pluto-gray-l10)",o.jsxRuntimeExports.jsxs(f.Dialog$1,{location:{x:"center",y:"bottom"},children:[o.jsxRuntimeExports.jsx(f.Text,{children:r.message}),o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("indicator"),style:{backgroundColor:u.cr.cssString(l),flexGrow:1}})]})},I2=e=>{const{needsControlOf:t}=qc(),[,{states:n},s]=f.use$2({type:O.Legend.TYPE,schema:O.legendStateZ,initialState:{states:[],needsControlOf:t}});j.useEffect(()=>{s(l=>({...l,needsControlOf:t}))},[t]);const i=u.c.unique(n.map(l=>l.subject.key)).map(l=>{const a=n.find(c=>c.subject.key===l);if(a==null)throw new P.ht("Legend subject not found");return{key:a.subject.key,label:a.subject.name,color:a.subjectColor}});return o.jsxRuntimeExports.jsx(lr,{data:i,...e})},Jc=({children:e})=>{const[{path:t}]=f.use$2({type:O.StateProvider.TYPE,schema:O.stateProviderStateZ,initialState:{}});return o.jsxRuntimeExports.jsx(f.Composite,{path:t,children:e})},O2=Object.freeze(Object.defineProperty({__proto__:null,Chip:Wc,Controller:T2,Indicator:Qc,Legend:I2,StateProvider:Jc,useContext:qc},Symbol.toStringTag,{value:"Module"})),eu=e=>{const t=({disabled:n=!1,...s})=>n?s.children:o.jsxRuntimeExports.jsx(e,{...s});return t.displayName=e.displayName,t},tu="workspaces",A2={channel:P.Dw.SET_CHANNEL_NAME,schema:P.Dw.workspaceZ,onChange:({store:e,changed:t})=>e.workspaces.set(t.key,t)},D2={channel:P.Dw.DELETE_CHANNEL_NAME,schema:P.Dw.keyZ,onChange:({store:e,changed:t})=>e.workspaces.delete(t)},nu={listeners:[A2,D2]},B2=qe({name:"Workspace",retrieve:({params:e,client:t})=>t.workspaces.retrieve(e.key),mountListeners:({store:e,params:t,onChange:n})=>[e.workspaces.onSet(n,t.key)]}),$2=Ke({name:"Workspace",retrieve:async({client:e,params:t})=>await e.workspaces.retrieve(t),retrieveByKey:async({client:e,key:t})=>await e.workspaces.retrieve(t),mountListeners:({store:e,onChange:t,onDelete:n})=>[e.workspaces.onSet(s=>t(s.key,s)),e.workspaces.onDelete(n)]}),z2=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:nu,FLUX_STORE_KEY:tu,retrieve:B2,useList:$2},Symbol.toStringTag,{value:"Module"})),V2=eu(Gc),F2=eu(f.Provider$4),su={[O.FLUX_STORE_KEY]:O.FLUX_STORE_CONFIG,[hc]:gc,[ac]:cc,[sc]:oc,[mc]:fc,[tu]:nu,[kc]:Mc,[Lc]:Nc,[Ic]:Vc,[Ya]:Ga,[Oc]:Hc,[qj]:e2},H2=({children:e,connParams:t,workerEnabled:n=!0,workerURL:s,theming:r,tooltip:i,triggers:l,alamos:a,haul:c,telem:d,color:x})=>o.jsxRuntimeExports.jsx(f.Provider$1,{...l,children:o.jsxRuntimeExports.jsx(f.Config,{...i,children:o.jsxRuntimeExports.jsx(f.Provider$2,{...c,children:o.jsxRuntimeExports.jsx(f.Provider$3,{url:s??t2,enabled:n,children:o.jsxRuntimeExports.jsx(F2,{workerKey:"vis",children:o.jsxRuntimeExports.jsx(Xj,{...a,children:o.jsxRuntimeExports.jsx(f.Aggregator,{children:o.jsxRuntimeExports.jsx($a,{connParams:t,children:o.jsxRuntimeExports.jsx(Va,{storeConfig:su,children:o.jsxRuntimeExports.jsx(Pe.Provider,{...x,children:o.jsxRuntimeExports.jsx(f.Provider,{...r,children:o.jsxRuntimeExports.jsx(V2,{...d,children:o.jsxRuntimeExports.jsx(Jc,{children:e})})})})})})})})})})})})}),Z2=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:su,Provider:H2},Symbol.toStringTag,{value:"Module"})),K2=({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}%`}})}),Y2=Object.freeze(Object.defineProperty({__proto__:null,Progress:K2},Symbol.toStringTag,{value:"Module"})),G2=({steps:e,value:t,onChange:n,...s})=>{const r=e.findIndex(i=>i.key===t);return o.jsxRuntimeExports.jsx(f.Box,{x:!0,align:"center",className:u.CSS.B("steps"),...s,children:e.map((i,l)=>o.jsxRuntimeExports.jsxs(j.Fragment,{children:[o.jsxRuntimeExports.jsxs(f.Button,{onClick:()=>n(i.key),variant:"outlined",disabled:l>r,children:[l+1,". ",i.title]},i.key),l!==e.length-1&&o.jsxRuntimeExports.jsx(f.Arrow.Right,{style:{fontSize:"15px",color:"var(--pluto-gray-l10)"}})]},i.key))})},U2=Object.freeze(Object.defineProperty({__proto__:null,Steps:G2},Symbol.toStringTag,{value:"Module"})),W2=({children:e,className:t,visible:n,...s})=>{const[{path:r},,i]=f.use$2({type:O.Table.TYPE,schema:O.Table.stateZ,initialState:{region:u.Ho.ZERO,visible:n}});j.useEffect(()=>{i(a=>({...a,visible:n}))},[n]);const l=Tn(a=>i(c=>({...c,region:a})));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(f.Composite,{path:r,children:e})})})]})},X2=({children:e,className:t,size:n,index:s,onResize:r,onSelect:i,position:l,...a})=>o.jsxRuntimeExports.jsxs("tr",{className:u.CSS(u.CSS.BE("table","row"),t),...a,children:[r!=null&&o.jsxRuntimeExports.jsx(ru,{onSelect:i,index:s,value:n,onChange:r,position:l,direction:"y"}),e]}),Pr=({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}),ou="ABCDEFGHIJKLMNOPQRSTUVWXYZ",q2=e=>ou[e],ru=({value:e,selected:t=!1,index:n,onChange:s,position:r,direction:i="x",onSelect:l})=>{const a=f.useSyncedRef(e),c=j.useRef(e),d=Pe.useCursorDrag({onStart:j.useCallback(()=>{c.current=a.current},[]),onMove:j.useCallback(x=>s(c.current+u.Ho.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),f.CONTEXT_TARGET,t&&f.CONTEXT_SELECTED),style:{[u.p.dimension(i)]:e},onClick:()=>l(n),onContextMenu:()=>l(n),children:[o.jsxRuntimeExports.jsx(f.Text,{full:"x",justify:"center",align:"center",square:!1,children:i==="x"?ou[n]:n+1}),o.jsxRuntimeExports.jsx("button",{onClick:x=>x.stopPropagation(),style:{[u.p.location(i)]:r+e},onDragStart:d,draggable:!0})]})},Q2=({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 a=r;return r+=i,o.jsxRuntimeExports.jsx(ru,{onSelect:t,position:a,selected:e.includes(l),index:l,value:i,onChange:c=>s(c,l),direction:"x"},l)})]})},J2=Object.freeze(Object.defineProperty({__proto__:null,Cell:Pr,ColumnIndicators:Q2,Row:X2,Table:W2,getCellColumn:q2},Symbol.toStringTag,{value:"Module"})),iu=te.z.object({bounds:u.H.bounds,gradient:u.cr.gradientZ}),Tr={bounds:{lower:0,upper:1},gradient:[]},Mi={size:"small",showDragHandle:!1},Ni={width:60},eE=u.C.Scale.scale(0,1),Ir=({path:e})=>{const{set:t,get:n}=rn(),s=fr(`${e}.bounds`),r=eE.scale(s);return o.jsxRuntimeExports.jsxs(f.Box,{x:!0,grow:!0,children:[o.jsxRuntimeExports.jsx($e,{inputProps:Mi,style:Ni,label:"Lower",path:`${e}.bounds.lower`}),o.jsxRuntimeExports.jsx(Ee,{path:`${e}.gradient`,label:"Gradient",align:"start",padHelpText:!1,children:({value:i,onChange:l})=>o.jsxRuntimeExports.jsx(Pe.GradientPicker,{value:P.N.copy(i),scale:r,onChange:a=>{const d={...n(`${e}.bounds`).value},x=a.map(S=>S.position),p=r.pos(Math.max(...x)),m=r.pos(Math.min(...x)),h=p>d.upper,g=m<d.lower;h&&(a[a.length-1].position=1,d.upper=p),g&&(a[0].position=0,d.lower=m);const E=a.map(S=>({...S,color:u.cr.hex(S.color)}));h||g?t(e,{bounds:d,gradient:E}):l(a.map(S=>({...S,color:u.cr.hex(S.color)})))}})}),o.jsxRuntimeExports.jsx($e,{inputProps:Mi,style:Ni,label:"Upper",path:`${e}.bounds.upper`})]})},tE=e=>o.jsxRuntimeExports.jsxs(pe.Buttons,{...e,keys:u.br.NOTATIONS,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"standard",children:"Standard"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"scientific",children:"Scientific"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"engineering",children:"Engineering"})]}),nE=[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],Or=({path:e})=>{const{value:t,onChange:n}=Et(e),s=O.sourcePipelinePropsZ.parse(t.telem?.props),r=O.streamChannelValuePropsZ.parse(s.segments.valueStream.props),i=O.stringifyNumberProps.parse(s.segments.stringifier.props),l=O.rollingAverageProps.parse(s.segments.rollingAverage.props),a=h=>{const g=O.sourcePipeline("string",{connections:nE,segments:{valueStream:O.streamChannelValue({channel:r.channel}),stringifier:O.stringifyNumber({precision:i.precision??2,notation:i.notation}),rollingAverage:O.rollingAverage({windowSize:l.windowSize??1}),...h},outlet:"stringifier"});n({...t,telem:g})},c=h=>a({valueStream:O.streamChannelValue({channel:h??0})}),d=h=>a({stringifier:O.stringifyNumber({...i,notation:h})}),x=h=>a({stringifier:O.stringifyNumber({...i,precision:h})}),p=h=>a({rollingAverage:O.rollingAverage({windowSize:h})});if(typeof r.channel!="number")throw new Error("Must pass in a channel by key to Value.TelemForm");const{data:m}=Rr.useDirect({params:{key:r.channel}});return j.useEffect(()=>{m!=null&&n({...t,tooltip:[m.name]})},[m?.name,n]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(Ie.Item,{label:"Input Channel",grow:!0,children:o.jsxRuntimeExports.jsx(kt,{value:r.channel,onChange:c})}),o.jsxRuntimeExports.jsxs(f.Box,{x:!0,children:[o.jsxRuntimeExports.jsx(Ie.Item,{label:"Notation",children:o.jsxRuntimeExports.jsx(tE,{value:i.notation,onChange:d})}),o.jsxRuntimeExports.jsx(Ie.Item,{label:"Precision",align:"start",children:o.jsxRuntimeExports.jsx(f.Numeric,{value:i.precision??2,bounds:{lower:0,upper:10},onChange:x})}),o.jsxRuntimeExports.jsx(Ie.Item,{label:"Averaging Window",align:"start",children:o.jsxRuntimeExports.jsx(f.Numeric,{value:l.windowSize??1,bounds:{lower:1,upper:100},onChange:p})})]})]})},sE=O.Value.z.partial({color:!0}).extend({level:P.levelZ.optional()}),Ar=({aetherKey:e,box:t,telem:n,color:s,precision:r,minWidth:i,level:l="small",backgroundTelem:a,notation:c,location:d,useWidthForBackground:x,valueBackgroundOverScan:p,valueBackgroundShift:m})=>{const h=f.useMemoDeepEqual({box:t,telem:n,color:s,precision:r,level:l,minWidth:i,notation:c,backgroundTelem:a,location:d,useWidthForBackground:x,valueBackgroundOverScan:p,valueBackgroundShift:m}),[,g,E]=f.use$2({aetherKey:e,type:O.Value.TYPE,schema:O.Value.z,initialState:h});return j.useEffect(()=>E(S=>({...S,...h})),[h]),{width:g.width??g.minWidth}},oE=Object.freeze(Object.defineProperty({__proto__:null,RedlineForm:Ir,TelemForm:Or,ZERO_READLINE:Tr,corePropsZ:sE,redlineZ:iu,use:Ar},Symbol.toStringTag,{value:"Module"})),rE="text",lu=te.z.object({value:te.z.string(),level:P.levelZ,weight:P.weightZ,align:u.K$1.x.or(u.K$1.center),backgroundColor:u.cr.crudeZ}),au=({cellKey:e,onChange:t,value:n,selected:s,onSelect:r,align:i,level:l,weight:a,backgroundColor:c})=>{const d=p=>r(e,p),x=p=>t({level:l,value:p,weight:a,align:i,backgroundColor:c});return o.jsxRuntimeExports.jsx(Pr,{id:e,className:u.CSS(f.CONTEXT_TARGET,s&&f.CONTEXT_SELECTED,u.CSS.BEM("table","cell","text")),selected:s,onClick:d,onContextMenu:d,style:{backgroundColor:u.cr.cssString(c)},children:o.jsxRuntimeExports.jsx(f.Editable,{level:l,value:n,weight:a,onChange:x,style:{justifyContent:i},allowEmpty:!0,outline:!1})})},iE="value",cu=te.z.object({telem:O.stringSourceSpecZ,redline:iu,level:P.levelZ,color:te.z.string(),units:te.z.string()}),uu=({cellKey:e,telem:t,level:n,color:s,redline:{gradient:r,bounds:i},selected:l,box:a,onSelect:c})=>{const{width:d}=Ar({aetherKey:e,box:a,telem:t,level:n,color:s,backgroundTelem:O.sourcePipeline("color",{connections:[{from:"source",to:"scale"},{from:"scale",to:"gradient"}],segments:{source:t,scale:O.scaleNumber({scale:u.C.Scale.scale(i).scale(0,1).transform}),gradient:O.colorGradient({gradient:r})},outlet:"gradient"}),location:{x:"center",y:"center"}}),x=p=>c(e,p);return o.jsxRuntimeExports.jsx(Pr,{id:e,selected:l,onClick:x,onContextMenu:x,style:{height:"5rem",width:d},className:u.CSS(f.CONTEXT_TARGET,l&&f.CONTEXT_SELECTED,u.CSS.BEM("table","cell","value"))})},lE={padding:"2rem"},uo=e=>o.jsxRuntimeExports.jsx(f.Box,{...e,style:lE,y:!0}),aE=[{tabKey:"style",name:"Style"},{tabKey:"telem",name:"Telemetry"},{tabKey:"redline",name:"Redline"}],du=({onVariantChange:e})=>{const t=j.useCallback(({tabKey:s})=>{switch(s){case"telem":return o.jsxRuntimeExports.jsx(uo,{children:o.jsxRuntimeExports.jsx(Or,{path:""})});case"redline":return o.jsxRuntimeExports.jsx(uo,{children:o.jsxRuntimeExports.jsx(Ir,{path:"redline"})});default:return o.jsxRuntimeExports.jsx(uo,{children:o.jsxRuntimeExports.jsxs(f.Box,{x:!0,children:[o.jsxRuntimeExports.jsx(Ie.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Dr,{onChange:e,value:"value"})}),o.jsxRuntimeExports.jsx(Ee,{hideIfNull:!0,label:"Color",align:"start",padHelpText:!1,path:"color",children:({value:r,onChange:i,variant:l,...a})=>o.jsxRuntimeExports.jsx(Pe.Swatch,{value:r??u.cr.setAlpha(u.cr.ZERO,1),onChange:i,...a,bordered:!0})}),o.jsxRuntimeExports.jsx(Ee,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:({value:r,onChange:i,variant:l,...a})=>o.jsxRuntimeExports.jsx(on,{value:r,onChange:i,...a})})]})})}},[]),n=Me.useStatic({tabs:aE,content:t});return o.jsxRuntimeExports.jsx(Me.Tabs,{...n,size:"small"})},cE={padding:"2rem"},xu=({onVariantChange:e})=>o.jsxRuntimeExports.jsxs(f.Box,{x:!0,grow:!0,style:cE,children:[o.jsxRuntimeExports.jsx(Ie.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Dr,{onChange:e,value:"text"})}),o.jsxRuntimeExports.jsx(hr,{path:"value",label:"Text"}),o.jsxRuntimeExports.jsx(Ee,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:({value:t,onChange:n,variant:s,...r})=>o.jsxRuntimeExports.jsx(on,{value:t,onChange:n,...r})}),o.jsxRuntimeExports.jsx(Ee,{path:"weight",label:"Weight",padHelpText:!1,children:({value:t,onChange:n,variant:s,...r})=>o.jsxRuntimeExports.jsx(la,{value:t,onChange:n,...r})}),o.jsxRuntimeExports.jsx(Ee,{path:"align",label:"Alignment",hideIfNull:!0,children:({value:t,onChange:n,variant:s,...r})=>o.jsxRuntimeExports.jsx(pe.SelectAlignment,{value:t,onChange:n,...r})}),o.jsxRuntimeExports.jsx(Ee,{path:"backgroundColor",label:"Background",align:"start",padHelpText:!1,children:({value:t,onChange:n})=>o.jsxRuntimeExports.jsx(Pe.Swatch,{value:t,onChange:n})})]}),uE=[{key:"text",name:"Text",icon:o.jsxRuntimeExports.jsx(f.Text$3,{})},{key:"value",name:"Value",icon:o.jsxRuntimeExports.jsx(f.Channel,{})}],Dr=e=>o.jsxRuntimeExports.jsx(Pn,{...e,data:uE,resourceName:"Variant"}),dE=["text","value"],xE=te.z.enum(dE),pE={key:"value",name:"Value",Form:du,Cell:uu,defaultProps:e=>({telem:O.sourcePipeline("string",{connections:[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],segments:{valueStream:O.streamChannelValue({channel:0}),rollingAverage:O.rollingAverage({windowSize:1}),stringifier:O.stringifyNumber({precision:2,notation:"standard"})},outlet:"stringifier"}),redline:Tr,color:u.cr.hex(e.colors.gray.l10),level:"h5",units:""}),schema:cu},mE={key:"text",name:"Text",Form:xu,Cell:au,defaultProps:()=>({value:"",level:"h5",units:"",weight:400,align:"center",backgroundColor:"#00000000"}),schema:lu},fE={text:mE,value:pE},hE=Object.freeze(Object.defineProperty({__proto__:null,CELLS:fE,SelectVariant:Dr,TEXT_TYPE:rE,Text:au,TextForm:xu,VALUE_TYPE:iE,Value:uu,ValueForm:du,textPropsZ:lu,valuePropsZ:cu,variantZ:xE},Symbol.toStringTag,{value:"Module"})),Pi=({sourcePos:e,targetPos:t,next:n,prev:s})=>{const r=Rt(e,...n);return u.K.distance(r,t)<1?!0:(console.warn("Connector is out of sync with target"),console.log("Theoretical target",r),console.log("Actual target",t),console.log("Segments",n),console.log("Prev segments",s),!1)},Ti=({sourceStumpTip:e,sourceOrientation:t,sourceBox:n,targetStumpTip:s,targetOrientation:r,targetBox:i})=>{if(!gE({sourcePos:e,sourceOrientation:t,targetPos:s}))return;const l=u.p.construct(t),a=u.p.swap(l);let c=wt(a,s[a]-e[a]);const d=u.Ho.loc(n,c);if(u.K$1.swap(t)===r){const x=u.Ho.loc(i,u.K$1.swap(c));Math.abs(d-x)<De&&(c=u.K$1.swap(c))}return{direction:a,length:d-e[a]+Mt(c,De)}},Ao=te.z.object({direction:u.p.direction,length:te.z.number()}),Rt=(e,...t)=>{let n=e;for(const s of t)n=u.K.translate(n,s.direction,s.length);return n},pu=(e,t,n,s)=>{try{let r=e;const i=[e,...t.map(h=>(r=u.K.translate(r,h.direction,h.length),r))];if(!s)return i;const l=t[0],a=wt(l.direction,l.length),c=Ii(a),d=4*(2-n**.5);i[0]=u.K.translate(i[0],{[l.direction]:-1*c*d,[u.p.swap(l.direction)]:0});const x=t[t.length-1],p=wt(x.direction,x.length),m=Ii(p);return i[i.length-1]=u.K.translate(i[i.length-1],{[x.direction]:m*d,[u.p.swap(x.direction)]:0}),i}catch{return[]}},De=10,Ii=e=>e==="top"||e==="left"?-1:1,Mt=(e,t)=>e==="top"||e==="left"?-t:t,wt=(e,t)=>e==="x"?t>0?"right":"left":t>0?"bottom":"top",ht=e=>wt(e.direction,e.length),gE=({sourcePos:e,targetPos:t,sourceOrientation:n})=>{const s=u.p.construct(n),r=t[s]-e[s];return Mt(n,r)<0},Wn=e=>({direction:u.p.construct(e),length:Mt(e,De)}),Oi={top:Wn("top"),bottom:Wn("bottom"),left:Wn("left"),right:Wn("right")},jE=4,EE=.25,Os=e=>Do(yE(Do(e))),yE=e=>{const t=[...e],n=e.findIndex((s,r)=>{const i=Math.abs(s.length);if(i<jE){if(r===0||r===e.length-1)return!1;if(i<EE)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},Do=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,a=r,c=ht(i),d=ht(s);if(c===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)===De)return!1;const x=Mt(c,De),p=t[l].length-x,m=t[a].length+p;return Math.abs(m)<De?!1:(t[l]={...t[l],length:x},t[a]={...t[a],length:m},!0)}if(r===e.length-1){const l=r,a=r-1,c=ht(s),d=ht(i);if(c===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)===De)return!1;const x=Mt(c,De),p=t[l].length-x,m=t[a].length+p;return Math.abs(m)<De?!1:(t[l]={...t[l],length:x},t[a]={...t[a],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?Do(t):t},Zt=e=>Os(SE(e)),SE=({sourceBox:e,targetBox:t,sourcePos:n,targetPos:s,targetOrientation:r,sourceOrientation:i})=>{let l=i,a=r,c={...Oi[i]},d=Rt(n,c);const x={...Oi[r]};let p=Rt(s,x);const m=Math.abs(d.x-p.x),h=Math.abs(d.y-p.y);m<2*De&&h<10&&(c.length-=m/2,x.length+=m/2,d=Rt(n,c),p=Rt(s,x));const g=[c],E=Ti({sourceStumpTip:d,sourceOrientation:i,sourceBox:e,targetStumpTip:p,targetOrientation:r,targetBox:t});E!=null&&(g.push(E),d=Rt(d,E),l=ht(E),c=E);const S=Ti({sourceStumpTip:p,sourceOrientation:a,sourceBox:t,targetStumpTip:d,targetOrientation:l,targetBox:e});S!=null&&(p=Rt(p,S),a=wt(S.direction,S.length));const R=()=>{S!=null&&(S.length*=-1,g.push(S)),x.length*=-1,g.push(x)};if(u.K$1.swap(l)===r){const I=u.p.construct(l),A=(p[I]-d[I])/2;g.push({direction:I,length:A});const B=u.p.swap(I);return g.push({direction:B,length:p[B]-d[B]}),g.push({direction:I,length:A}),R(),g}const v=p[c.direction]-d[c.direction];let y=u.p.swap(c.direction);const C=d[y]-p[y];let _;wt(c.direction,v)===l&&wt(y,C)===a?_={direction:c.direction,length:v}:(_={direction:y,length:p[y]-d[y]},y=u.p.swap(y)),g.push(_);const M={direction:y,length:p[y]-d[y]};return g.push(M),R(),g},RE=e=>Os(CE(e)),CE=({segments:e,index:t,magnitude:n})=>{const s=[...e],r=s[t],i=u.p.swap(r.direction),l=ht(r);if(t===0){s.unshift({direction:i,length:n});const a=Mt(l,De);s.unshift({direction:r.direction,length:a}),t+=2,s[t]={...s[t],length:s[t].length-a}}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 a=Mt(l,De);s.push({direction:r.direction,length:a}),s[t]={...s[t],length:s[t].length-a}}else s[t+1]={direction:s[t+1].direction,length:s[t+1].length-n};return s},wE=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n],n))return n;return-1},bE=(e,t,n=!1,...s)=>{const r=(i,l)=>!s.includes(l)&&t(i,l);return n?wE(e,r):e.findIndex(r)},vE=({delta:e,segments:t})=>Os(mu(e,t,!1)),_E=({delta:e,segments:t})=>Os(mu(e,t,!0)),mu=(e,t,n)=>{let s=[...t];return e.x!==0&&(s=Di("x",e,s,n)),e.y!==0&&(s=Di("y",e,s,n)),s},Ai=(e,t,n)=>{if(t.direction!==e)return!1;const s={...t,length:t.length-n[e]},r=ht(t),i=ht(s),l=Math.abs(s.length),a=Math.abs(t.length);return(l>a||l>De)&&r===i},Di=(e,t,n,s)=>{const r=u.p.swap(e),i=s?n.length-1:0,l=n[i];if(Ai(e,l,t)){const p=n[n.length-1];return p.direction===e&&Math.abs(l.length)<De?(n[n.length-1]={...p,length:p.length-t[e]},n):(n[i]={...l,length:l.length-t[e]},n)}const a=s?0:n.length-1,d=bE(n,p=>p.direction===e,s,i);if(d===a){const p=n[a];return Ai(e,p,t)?(n[a]={...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[a]={...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},kE=te.z.object({position:u.K.xy,zoom:te.z.number()}),fu=te.z.object({color:u.cr.crudeZ,variant:te.z.string().optional(),segments:te.z.array(Ao)}),LE=fu.extend({key:te.z.string(),source:te.z.string(),target:te.z.string(),segments:te.z.array(Ao),color:u.cr.crudeZ,id:te.z.string(),data:te.z.object({segments:te.z.array(Ao),color:u.cr.crudeZ,variant:te.z.string().optional()}).optional(),selected:te.z.boolean(),sourceHandle:te.z.string().nullable().optional(),targetHandle:te.z.string().nullable().optional()}),ME=te.z.object({key:te.z.string(),position:u.K.xy,selected:te.z.boolean().optional(),zIndex:te.z.number().optional(),type:te.z.string().optional(),data:u.l.unknownZ.optional(),measured:te.z.object({width:te.z.number().optional(),height:te.z.number().optional()}).optional()}),Br=(e,t)=>e.map(n=>({id:n.key,type:"custom",zIndex:n.zIndex,measured:{...n.measured},position:{...n.position},selected:n.selected,data:{},dragHandle:t})),$r=e=>e.map(({segments:t,color:n,variant:s,...r})=>({...r,id:r.key,data:{segments:t,color:n,variant:s}})),hu=e=>e.map(t=>({key:t.id,...t})),gu=(e,t)=>e.map(n=>(n.data??={segments:[],color:t,variant:"pipe"},{key:n.id,segments:n.data?.segments??[],selected:n.selected??!1,color:n.data?.color??t,variant:n.data?.variant??"pipe",...n})),ju=e=>({...e.position,zoom:e.zoom}),Eu=e=>({position:u.K.construct(e),zoom:e.zoom}),yu=(e,t)=>hu(t(Br(e))),is=(e,t,n)=>gu(t($r(e)),n),NE=(e,t="x")=>{if(e.length===0)return[];const n=u.K$1.construct(t),s=u.K$1.swap(n);return e.sort((r,i)=>u.Ho.loc(r.box,n)-u.Ho.loc(i.box,n)),e.forEach((r,i)=>{if(i===0)return;const a=e[i-1].handles.find(h=>h.orientation===s),c=r.handles.find(h=>h.orientation===n);if(a==null||c==null)return;const d=a.absolutePosition,x=c.absolutePosition,p=u.K.set(u.K.translation(x,d),t,0),m=u.K.translate(u.Ho.topLeft(r.box),p);r.box=u.Ho.construct(m,u.Ho.dims(r.box))}),e};function Le(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=Le(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var PE={value:()=>{}};function As(){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 ls(n)}function ls(e){this._=e}function TE(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}})}ls.prototype=As.prototype={constructor:ls,on:function(e,t){var n=this._,s=TE(e+"",n),r,i=-1,l=s.length;if(arguments.length<2){for(;++i<l;)if((r=(e=s[i]).type)&&(r=IE(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]=Bi(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Bi(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 ls(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 IE(e,t){for(var n=0,s=e.length,r;n<s;++n)if((r=e[n]).name===t)return r.value}function Bi(e,t,n){for(var s=0,r=e.length;s<r;++s)if(e[s].name===t){e[s]=PE,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Bo="http://www.w3.org/1999/xhtml";const $i={svg:"http://www.w3.org/2000/svg",xhtml:Bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ds(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),$i.hasOwnProperty(t)?{space:$i[t],local:e}:e}function OE(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Bo&&t.documentElement.namespaceURI===Bo?t.createElement(e):t.createElementNS(n,e)}}function AE(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Su(e){var t=Ds(e);return(t.local?AE:OE)(t)}function DE(){}function zr(e){return e==null?DE:function(){return this.querySelector(e)}}function BE(e){typeof e!="function"&&(e=zr(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,a=s[r]=new Array(l),c,d,x=0;x<l;++x)(c=i[x])&&(d=e.call(c,c.__data__,x,i))&&("__data__"in c&&(d.__data__=c.__data__),a[x]=d);return new Fe(s,this._parents)}function $E(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function zE(){return[]}function Ru(e){return e==null?zE:function(){return this.querySelectorAll(e)}}function VE(e){return function(){return $E(e.apply(this,arguments))}}function FE(e){typeof e=="function"?e=VE(e):e=Ru(e);for(var t=this._groups,n=t.length,s=[],r=[],i=0;i<n;++i)for(var l=t[i],a=l.length,c,d=0;d<a;++d)(c=l[d])&&(s.push(e.call(c,c.__data__,d,l)),r.push(c));return new Fe(s,r)}function Cu(e){return function(){return this.matches(e)}}function wu(e){return function(t){return t.matches(e)}}var HE=Array.prototype.find;function ZE(e){return function(){return HE.call(this.children,e)}}function KE(){return this.firstElementChild}function YE(e){return this.select(e==null?KE:ZE(typeof e=="function"?e:wu(e)))}var GE=Array.prototype.filter;function UE(){return Array.from(this.children)}function WE(e){return function(){return GE.call(this.children,e)}}function XE(e){return this.selectAll(e==null?UE:WE(typeof e=="function"?e:wu(e)))}function qE(e){typeof e!="function"&&(e=Cu(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,a=s[r]=[],c,d=0;d<l;++d)(c=i[d])&&e.call(c,c.__data__,d,i)&&a.push(c);return new Fe(s,this._parents)}function bu(e){return new Array(e.length)}function QE(){return new Fe(this._enter||this._groups.map(bu),this._parents)}function js(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}js.prototype={constructor:js,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 JE(e){return function(){return e}}function e3(e,t,n,s,r,i){for(var l=0,a,c=t.length,d=i.length;l<d;++l)(a=t[l])?(a.__data__=i[l],s[l]=a):n[l]=new js(e,i[l]);for(;l<c;++l)(a=t[l])&&(r[l]=a)}function t3(e,t,n,s,r,i,l){var a,c,d=new Map,x=t.length,p=i.length,m=new Array(x),h;for(a=0;a<x;++a)(c=t[a])&&(m[a]=h=l.call(c,c.__data__,a,t)+"",d.has(h)?r[a]=c:d.set(h,c));for(a=0;a<p;++a)h=l.call(e,i[a],a,i)+"",(c=d.get(h))?(s[a]=c,c.__data__=i[a],d.delete(h)):n[a]=new js(e,i[a]);for(a=0;a<x;++a)(c=t[a])&&d.get(m[a])===c&&(r[a]=c)}function n3(e){return e.__data__}function s3(e,t){if(!arguments.length)return Array.from(this,n3);var n=t?t3:e3,s=this._parents,r=this._groups;typeof e!="function"&&(e=JE(e));for(var i=r.length,l=new Array(i),a=new Array(i),c=new Array(i),d=0;d<i;++d){var x=s[d],p=r[d],m=p.length,h=o3(e.call(x,x&&x.__data__,d,s)),g=h.length,E=a[d]=new Array(g),S=l[d]=new Array(g),R=c[d]=new Array(m);n(x,p,E,S,R,h,t);for(var v=0,y=0,C,_;v<g;++v)if(C=E[v]){for(v>=y&&(y=v+1);!(_=S[y])&&++y<g;);C._next=_||null}}return l=new Fe(l,s),l._enter=a,l._exit=c,l}function o3(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function r3(){return new Fe(this._exit||this._groups.map(bu),this._parents)}function i3(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 l3(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),a=new Array(r),c=0;c<l;++c)for(var d=n[c],x=s[c],p=d.length,m=a[c]=new Array(p),h,g=0;g<p;++g)(h=d[g]||x[g])&&(m[g]=h);for(;c<r;++c)a[c]=n[c];return new Fe(a,this._parents)}function a3(){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 c3(e){e||(e=u3);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],a=l.length,c=r[i]=new Array(a),d,x=0;x<a;++x)(d=l[x])&&(c[x]=d);c.sort(t)}return new Fe(r,this._parents).order()}function u3(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function d3(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function x3(){return Array.from(this)}function p3(){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 m3(){let e=0;for(const t of this)++e;return e}function f3(){return!this.node()}function h3(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var r=t[n],i=0,l=r.length,a;i<l;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function g3(e){return function(){this.removeAttribute(e)}}function j3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function E3(e,t){return function(){this.setAttribute(e,t)}}function y3(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function S3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function R3(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 C3(e,t){var n=Ds(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?j3:g3:typeof t=="function"?n.local?R3:S3:n.local?y3:E3)(n,t))}function vu(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function w3(e){return function(){this.style.removeProperty(e)}}function b3(e,t,n){return function(){this.style.setProperty(e,t,n)}}function v3(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function _3(e,t,n){return arguments.length>1?this.each((t==null?w3:typeof t=="function"?v3:b3)(e,t,n??"")):qt(this.node(),e)}function qt(e,t){return e.style.getPropertyValue(t)||vu(e).getComputedStyle(e,null).getPropertyValue(t)}function k3(e){return function(){delete this[e]}}function L3(e,t){return function(){this[e]=t}}function M3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function N3(e,t){return arguments.length>1?this.each((t==null?k3:typeof t=="function"?M3:L3)(e,t)):this.node()[e]}function _u(e){return e.trim().split(/^|\s+/)}function Vr(e){return e.classList||new ku(e)}function ku(e){this._node=e,this._names=_u(e.getAttribute("class")||"")}ku.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 Lu(e,t){for(var n=Vr(e),s=-1,r=t.length;++s<r;)n.add(t[s])}function Mu(e,t){for(var n=Vr(e),s=-1,r=t.length;++s<r;)n.remove(t[s])}function P3(e){return function(){Lu(this,e)}}function T3(e){return function(){Mu(this,e)}}function I3(e,t){return function(){(t.apply(this,arguments)?Lu:Mu)(this,e)}}function O3(e,t){var n=_u(e+"");if(arguments.length<2){for(var s=Vr(this.node()),r=-1,i=n.length;++r<i;)if(!s.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?I3:t?P3:T3)(n,t))}function A3(){this.textContent=""}function D3(e){return function(){this.textContent=e}}function B3(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function $3(e){return arguments.length?this.each(e==null?A3:(typeof e=="function"?B3:D3)(e)):this.node().textContent}function z3(){this.innerHTML=""}function V3(e){return function(){this.innerHTML=e}}function F3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function H3(e){return arguments.length?this.each(e==null?z3:(typeof e=="function"?F3:V3)(e)):this.node().innerHTML}function Z3(){this.nextSibling&&this.parentNode.appendChild(this)}function K3(){return this.each(Z3)}function Y3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function G3(){return this.each(Y3)}function U3(e){var t=typeof e=="function"?e:Su(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function W3(){return null}function X3(e,t){var n=typeof e=="function"?e:Su(e),s=t==null?W3:typeof t=="function"?t:zr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function q3(){var e=this.parentNode;e&&e.removeChild(this)}function Q3(){return this.each(q3)}function J3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function e5(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function t5(e){return this.select(e?e5:J3)}function n5(e){return arguments.length?this.property("__data__",e):this.node().__data__}function s5(e){return function(t){e.call(this,t,this.__data__)}}function o5(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 r5(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 i5(e,t,n){return function(){var s=this.__on,r,i=s5(t);if(s){for(var l=0,a=s.length;l<a;++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 l5(e,t,n){var s=o5(e+""),r,i=s.length,l;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,d=a.length,x;c<d;++c)for(r=0,x=a[c];r<i;++r)if((l=s[r]).type===x.type&&l.name===x.name)return x.value}return}for(a=t?i5:r5,r=0;r<i;++r)this.each(a(s[r],t,n));return this}function Nu(e,t,n){var s=vu(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 a5(e,t){return function(){return Nu(this,e,t)}}function c5(e,t){return function(){return Nu(this,e,t.apply(this,arguments))}}function u5(e,t){return this.each((typeof t=="function"?c5:a5)(e,t))}function*d5(){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 Pu=[null];function Fe(e,t){this._groups=e,this._parents=t}function Dn(){return new Fe([[document.documentElement]],Pu)}function x5(){return this}Fe.prototype=Dn.prototype={constructor:Fe,select:BE,selectAll:FE,selectChild:YE,selectChildren:XE,filter:qE,data:s3,enter:QE,exit:r3,join:i3,merge:l3,selection:x5,order:a3,sort:c3,call:d3,nodes:x3,node:p3,size:m3,empty:f3,each:h3,attr:C3,style:_3,property:N3,classed:O3,text:$3,html:H3,raise:K3,lower:G3,append:U3,insert:X3,remove:Q3,clone:t5,datum:n5,on:l5,dispatch:u5,[Symbol.iterator]:d5};function ze(e){return typeof e=="string"?new Fe([[document.querySelector(e)]],[document.documentElement]):new Fe([[e]],Pu)}function p5(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ge(e,t){if(e=p5(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 m5={passive:!1},bn={capture:!0,passive:!1};function xo(e){e.stopImmediatePropagation()}function Ut(e){e.preventDefault(),e.stopImmediatePropagation()}function Tu(e){var t=e.document.documentElement,n=ze(e).on("dragstart.drag",Ut,bn);"onselectstart"in t?n.on("selectstart.drag",Ut,bn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Iu(e,t){var n=e.document.documentElement,s=ze(e).on("dragstart.drag",null);t&&(s.on("click.drag",Ut,bn),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Xn=e=>()=>e;function $o(e,{sourceEvent:t,subject:n,target:s,identifier:r,active:i,x:l,y:a,dx:c,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:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:x}})}$o.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function f5(e){return!e.ctrlKey&&!e.button}function h5(){return this.parentNode}function g5(e,t){return t??{x:e.x,y:e.y}}function j5(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ou(){var e=f5,t=h5,n=g5,s=j5,r={},i=As("start","drag","end"),l=0,a,c,d,x,p=0;function m(C){C.on("mousedown.drag",h).filter(s).on("touchstart.drag",S).on("touchmove.drag",R,m5).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(C,_){if(!(x||!e.call(this,C,_))){var M=y(this,t.call(this,C,_),C,_,"mouse");M&&(ze(C.view).on("mousemove.drag",g,bn).on("mouseup.drag",E,bn),Tu(C.view),xo(C),d=!1,a=C.clientX,c=C.clientY,M("start",C))}}function g(C){if(Ut(C),!d){var _=C.clientX-a,M=C.clientY-c;d=_*_+M*M>p}r.mouse("drag",C)}function E(C){ze(C.view).on("mousemove.drag mouseup.drag",null),Iu(C.view,d),Ut(C),r.mouse("end",C)}function S(C,_){if(e.call(this,C,_)){var M=C.changedTouches,I=t.call(this,C,_),A=M.length,B,z;for(B=0;B<A;++B)(z=y(this,I,C,_,M[B].identifier,M[B]))&&(xo(C),z("start",C,M[B]))}}function R(C){var _=C.changedTouches,M=_.length,I,A;for(I=0;I<M;++I)(A=r[_[I].identifier])&&(Ut(C),A("drag",C,_[I]))}function v(C){var _=C.changedTouches,M=_.length,I,A;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),I=0;I<M;++I)(A=r[_[I].identifier])&&(xo(C),A("end",C,_[I]))}function y(C,_,M,I,A,B){var z=i.copy(),$=Ge(B||M,_),D,V,b;if((b=n.call(C,new $o("beforestart",{sourceEvent:M,target:m,identifier:A,active:l,x:$[0],y:$[1],dx:0,dy:0,dispatch:z}),I))!=null)return D=b.x-$[0]||0,V=b.y-$[1]||0,function k(L,N,F){var H=$,K;switch(L){case"start":r[A]=k,K=l++;break;case"end":delete r[A],--l;case"drag":$=Ge(F||N,_),K=l;break}z.call(L,C,new $o(L,{sourceEvent:N,subject:b,target:m,identifier:A,active:K,x:$[0]+D,y:$[1]+V,dx:$[0]-H[0],dy:$[1]-H[1],dispatch:z}),I)}}return m.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Xn(!!C),m):e},m.container=function(C){return arguments.length?(t=typeof C=="function"?C:Xn(C),m):t},m.subject=function(C){return arguments.length?(n=typeof C=="function"?C:Xn(C),m):n},m.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:Xn(!!C),m):s},m.on=function(){var C=i.on.apply(i,arguments);return C===i?m:C},m.clickDistance=function(C){return arguments.length?(p=(C=+C)*C,m):Math.sqrt(p)},m}var Qt=0,gn=0,pn=0,Au=1e3,Es,jn,ys=0,Nt=0,Bs=0,vn=typeof performance=="object"&&performance.now?performance:Date,Du=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Fr(){return Nt||(Du(E5),Nt=vn.now()+Bs)}function E5(){Nt=0}function Ss(){this._call=this._time=this._next=null}Ss.prototype=Bu.prototype={constructor:Ss,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Fr():+n)+(t==null?0:+t),!this._next&&jn!==this&&(jn?jn._next=this:Es=this,jn=this),this._call=e,this._time=n,zo()},stop:function(){this._call&&(this._call=null,this._time=1/0,zo())}};function Bu(e,t,n){var s=new Ss;return s.restart(e,t,n),s}function y5(){Fr(),++Qt;for(var e=Es,t;e;)(t=Nt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Qt}function zi(){Nt=(ys=vn.now())+Bs,Qt=gn=0;try{y5()}finally{Qt=0,R5(),Nt=0}}function S5(){var e=vn.now(),t=e-ys;t>Au&&(Bs-=t,ys=e)}function R5(){for(var e,t=Es,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:Es=n);jn=e,zo(s)}function zo(e){if(!Qt){gn&&(gn=clearTimeout(gn));var t=e-Nt;t>24?(e<1/0&&(gn=setTimeout(zi,e-vn.now()-Bs)),pn&&(pn=clearInterval(pn))):(pn||(ys=vn.now(),pn=setInterval(S5,Au)),Qt=1,Du(zi))}}function Vi(e,t,n){var s=new Ss;return t=t==null?0:+t,s.restart(r=>{s.stop(),e(r+t)},t,n),s}var C5=As("start","end","cancel","interrupt"),w5=[],$u=0,Fi=1,Vo=2,as=3,Hi=4,Fo=5,cs=6;function $s(e,t,n,s,r,i){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;b5(e,n,{name:t,index:s,group:r,on:C5,tween:w5,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:$u})}function Hr(e,t){var n=Je(e,t);if(n.state>$u)throw new Error("too late; already scheduled");return n}function st(e,t){var n=Je(e,t);if(n.state>as)throw new Error("too late; already running");return n}function Je(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function b5(e,t,n){var s=e.__transition,r;s[t]=n,n.timer=Bu(i,0,n.time);function i(d){n.state=Fi,n.timer.restart(l,n.delay,n.time),n.delay<=d&&l(d-n.delay)}function l(d){var x,p,m,h;if(n.state!==Fi)return c();for(x in s)if(h=s[x],h.name===n.name){if(h.state===as)return Vi(l);h.state===Hi?(h.state=cs,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete s[x]):+x<t&&(h.state=cs,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete s[x])}if(Vi(function(){n.state===as&&(n.state=Hi,n.timer.restart(a,n.delay,n.time),a(d))}),n.state=Vo,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Vo){for(n.state=as,r=new Array(m=n.tween.length),x=0,p=-1;x<m;++x)(h=n.tween[x].value.call(e,e.__data__,n.index,n.group))&&(r[++p]=h);r.length=p+1}}function a(d){for(var x=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=Fo,1),p=-1,m=r.length;++p<m;)r[p].call(e,x);n.state===Fo&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=cs,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function us(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>Vo&&s.state<Fo,s.state=cs,s.timer.stop(),s.on.call(r?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[l]}i&&delete e.__transition}}function v5(e){return this.each(function(){us(this,e)})}function _5(e,t){var n,s;return function(){var r=st(this,e),i=r.tween;if(i!==n){s=n=i;for(var l=0,a=s.length;l<a;++l)if(s[l].name===t){s=s.slice(),s.splice(l,1);break}}r.tween=s}}function k5(e,t,n){var s,r;if(typeof n!="function")throw new Error;return function(){var i=st(this,e),l=i.tween;if(l!==s){r=(s=l).slice();for(var a={name:t,value:n},c=0,d=r.length;c<d;++c)if(r[c].name===t){r[c]=a;break}c===d&&r.push(a)}i.tween=r}}function L5(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Je(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?_5:k5)(n,e,t))}function Zr(e,t,n){var s=e._id;return e.each(function(){var r=st(this,s);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Je(r,s).value[t]}}function zu(e,t){var n;return(typeof t=="number"?O.interpolateNumber:t instanceof O.color?O.interpolateRgb:(n=O.color(t))?(t=n,O.interpolateRgb):O.interpolateString)(e,t)}function M5(e){return function(){this.removeAttribute(e)}}function N5(e){return function(){this.removeAttributeNS(e.space,e.local)}}function P5(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 T5(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 I5(e,t,n){var s,r,i;return function(){var l,a=n(this),c;return a==null?void this.removeAttribute(e):(l=this.getAttribute(e),c=a+"",l===c?null:l===s&&c===r?i:(r=c,i=t(s=l,a)))}}function O5(e,t,n){var s,r,i;return function(){var l,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),c=a+"",l===c?null:l===s&&c===r?i:(r=c,i=t(s=l,a)))}}function A5(e,t){var n=Ds(e),s=n==="transform"?Ug:zu;return this.attrTween(e,typeof t=="function"?(n.local?O5:I5)(n,s,Zr(this,"attr."+e,t)):t==null?(n.local?N5:M5)(n):(n.local?T5:P5)(n,s,t))}function D5(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function B5(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function $5(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&B5(e,i)),n}return r._value=t,r}function z5(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&D5(e,i)),n}return r._value=t,r}function V5(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=Ds(e);return this.tween(n,(s.local?$5:z5)(s,t))}function F5(e,t){return function(){Hr(this,e).delay=+t.apply(this,arguments)}}function H5(e,t){return t=+t,function(){Hr(this,e).delay=t}}function Z5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?F5:H5)(t,e)):Je(this.node(),t).delay}function K5(e,t){return function(){st(this,e).duration=+t.apply(this,arguments)}}function Y5(e,t){return t=+t,function(){st(this,e).duration=t}}function G5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?K5:Y5)(t,e)):Je(this.node(),t).duration}function U5(e,t){if(typeof t!="function")throw new Error;return function(){st(this,e).ease=t}}function W5(e){var t=this._id;return arguments.length?this.each(U5(t,e)):Je(this.node(),t).ease}function X5(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;st(this,e).ease=n}}function q5(e){if(typeof e!="function")throw new Error;return this.each(X5(this._id,e))}function Q5(e){typeof e!="function"&&(e=Cu(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,a=s[r]=[],c,d=0;d<l;++d)(c=i[d])&&e.call(c,c.__data__,d,i)&&a.push(c);return new at(s,this._parents,this._name,this._id)}function J5(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),a=0;a<i;++a)for(var c=t[a],d=n[a],x=c.length,p=l[a]=new Array(x),m,h=0;h<x;++h)(m=c[h]||d[h])&&(p[h]=m);for(;a<s;++a)l[a]=t[a];return new at(l,this._parents,this._name,this._id)}function ey(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 ty(e,t,n){var s,r,i=ey(t)?Hr:st;return function(){var l=i(this,e),a=l.on;a!==s&&(r=(s=a).copy()).on(t,n),l.on=r}}function ny(e,t){var n=this._id;return arguments.length<2?Je(this.node(),n).on.on(e):this.each(ty(n,e,t))}function sy(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function oy(){return this.on("end.remove",sy(this._id))}function ry(e){var t=this._name,n=this._id;typeof e!="function"&&(e=zr(e));for(var s=this._groups,r=s.length,i=new Array(r),l=0;l<r;++l)for(var a=s[l],c=a.length,d=i[l]=new Array(c),x,p,m=0;m<c;++m)(x=a[m])&&(p=e.call(x,x.__data__,m,a))&&("__data__"in x&&(p.__data__=x.__data__),d[m]=p,$s(d[m],t,n,m,d,Je(x,n)));return new at(i,this._parents,t,n)}function iy(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ru(e));for(var s=this._groups,r=s.length,i=[],l=[],a=0;a<r;++a)for(var c=s[a],d=c.length,x,p=0;p<d;++p)if(x=c[p]){for(var m=e.call(x,x.__data__,p,c),h,g=Je(x,n),E=0,S=m.length;E<S;++E)(h=m[E])&&$s(h,t,n,E,m,g);i.push(m),l.push(x)}return new at(i,l,t,n)}var ly=Dn.prototype.constructor;function ay(){return new ly(this._groups,this._parents)}function cy(e,t){var n,s,r;return function(){var i=qt(this,e),l=(this.style.removeProperty(e),qt(this,e));return i===l?null:i===n&&l===s?r:r=t(n=i,s=l)}}function Vu(e){return function(){this.style.removeProperty(e)}}function uy(e,t,n){var s,r=n+"",i;return function(){var l=qt(this,e);return l===r?null:l===s?i:i=t(s=l,n)}}function dy(e,t,n){var s,r,i;return function(){var l=qt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),qt(this,e))),l===c?null:l===s&&c===r?i:(r=c,i=t(s=l,a))}}function xy(e,t){var n,s,r,i="style."+t,l="end."+i,a;return function(){var c=st(this,e),d=c.on,x=c.value[i]==null?a||(a=Vu(t)):void 0;(d!==n||r!==x)&&(s=(n=d).copy()).on(l,r=x),c.on=s}}function py(e,t,n){var s=(e+="")=="transform"?Gg:zu;return t==null?this.styleTween(e,cy(e,s)).on("end.style."+e,Vu(e)):typeof t=="function"?this.styleTween(e,dy(e,s,Zr(this,"style."+e,t))).each(xy(this._id,e)):this.styleTween(e,uy(e,s,t),n).on("end.style."+e,null)}function my(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function fy(e,t,n){var s,r;function i(){var l=t.apply(this,arguments);return l!==r&&(s=(r=l)&&my(e,l,n)),s}return i._value=t,i}function hy(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,fy(e,t,n??""))}function gy(e){return function(){this.textContent=e}}function jy(e){return function(){var t=e(this);this.textContent=t??""}}function Ey(e){return this.tween("text",typeof e=="function"?jy(Zr(this,"text",e)):gy(e==null?"":e+""))}function yy(e){return function(t){this.textContent=e.call(this,t)}}function Sy(e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&yy(r)),t}return s._value=e,s}function Ry(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,Sy(e))}function Cy(){for(var e=this._name,t=this._id,n=Fu(),s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],a=l.length,c,d=0;d<a;++d)if(c=l[d]){var x=Je(c,t);$s(c,e,n,d,l,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new at(s,this._parents,e,n)}function wy(){var e,t,n=this,s=n._id,r=n.size();return new Promise(function(i,l){var a={value:l},c={value:function(){--r===0&&i()}};n.each(function(){var d=st(this,s),x=d.on;x!==e&&(t=(e=x).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),d.on=t}),r===0&&i()})}var by=0;function at(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Fu(){return++by}var ot=Dn.prototype;at.prototype={constructor:at,select:ry,selectAll:iy,selectChild:ot.selectChild,selectChildren:ot.selectChildren,filter:Q5,merge:J5,selection:ay,transition:Cy,call:ot.call,nodes:ot.nodes,node:ot.node,size:ot.size,empty:ot.empty,each:ot.each,on:ny,attr:A5,attrTween:V5,style:py,styleTween:hy,text:Ey,textTween:Ry,remove:oy,tween:L5,delay:Z5,duration:G5,ease:W5,easeVarying:q5,end:wy,[Symbol.iterator]:ot[Symbol.iterator]};function vy(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var _y={time:null,delay:0,duration:250,ease:vy};function ky(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 Ly(e){var t,n;e instanceof at?(t=e._id,e=e._name):(t=Fu(),(n=_y).time=Fr(),e=e==null?null:e+"");for(var s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],a=l.length,c,d=0;d<a;++d)(c=l[d])&&$s(c,e,t,d,l,n||ky(c,t));return new at(s,this._parents,e,t)}Dn.prototype.interrupt=v5;Dn.prototype.transition=Ly;const qn=e=>()=>e;function My(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 it(e,t,n){this.k=e,this.x=t,this.y=n}it.prototype={constructor:it,scale:function(e){return e===1?this:new it(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new it(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 zs=new it(1,0,0);Hu.prototype=it.prototype;function Hu(e){for(;!e.__zoom;)if(!(e=e.parentNode))return zs;return e.__zoom}function po(e){e.stopImmediatePropagation()}function mn(e){e.preventDefault(),e.stopImmediatePropagation()}function Ny(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Py(){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 Zi(){return this.__zoom||zs}function Ty(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Iy(){return navigator.maxTouchPoints||"ontouchstart"in this}function Oy(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 Zu(){var e=Ny,t=Py,n=Oy,s=Ty,r=Iy,i=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],a=250,c=rs,d=As("start","zoom","end"),x,p,m,h=500,g=150,E=0,S=10;function R(b){b.property("__zoom",Zi).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",z).filter(r).on("touchstart.zoom",$).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}R.transform=function(b,k,L,N){var F=b.selection?b.selection():b;F.property("__zoom",Zi),b!==F?_(b,k,L,N):F.interrupt().each(function(){M(this,arguments).event(N).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},R.scaleBy=function(b,k,L,N){R.scaleTo(b,function(){var F=this.__zoom.k,H=typeof k=="function"?k.apply(this,arguments):k;return F*H},L,N)},R.scaleTo=function(b,k,L,N){R.transform(b,function(){var F=t.apply(this,arguments),H=this.__zoom,K=L==null?C(F):typeof L=="function"?L.apply(this,arguments):L,Z=H.invert(K),Y=typeof k=="function"?k.apply(this,arguments):k;return n(y(v(H,Y),K,Z),F,l)},L,N)},R.translateBy=function(b,k,L,N){R.transform(b,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof L=="function"?L.apply(this,arguments):L),t.apply(this,arguments),l)},null,N)},R.translateTo=function(b,k,L,N,F){R.transform(b,function(){var H=t.apply(this,arguments),K=this.__zoom,Z=N==null?C(H):typeof N=="function"?N.apply(this,arguments):N;return n(zs.translate(Z[0],Z[1]).scale(K.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof L=="function"?-L.apply(this,arguments):-L),H,l)},N,F)};function v(b,k){return k=Math.max(i[0],Math.min(i[1],k)),k===b.k?b:new it(k,b.x,b.y)}function y(b,k,L){var N=k[0]-L[0]*b.k,F=k[1]-L[1]*b.k;return N===b.x&&F===b.y?b:new it(b.k,N,F)}function C(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function _(b,k,L,N){b.on("start.zoom",function(){M(this,arguments).event(N).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event(N).end()}).tween("zoom",function(){var F=this,H=arguments,K=M(F,H).event(N),Z=t.apply(F,H),Y=L==null?C(Z):typeof L=="function"?L.apply(F,H):L,ne=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),J=F.__zoom,ce=typeof k=="function"?k.apply(F,H):k,le=c(J.invert(Y).concat(ne/J.k),ce.invert(Y).concat(ne/ce.k));return function(se){if(se===1)se=ce;else{var ee=le(se),re=ne/ee[2];se=new it(re,Y[0]-ee[0]*re,Y[1]-ee[1]*re)}K.zoom(null,se)}})}function M(b,k,L){return!L&&b.__zooming||new I(b,k)}function I(b,k){this.that=b,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,k),this.taps=0}I.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,k){return this.mouse&&b!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var k=ze(this.that).datum();d.call(b,this.that,new My(b,{sourceEvent:this.sourceEvent,target:R,transform:this.that.__zoom,dispatch:d}),k)}};function A(b,...k){if(!e.apply(this,arguments))return;var L=M(this,k).event(b),N=this.__zoom,F=Math.max(i[0],Math.min(i[1],N.k*Math.pow(2,s.apply(this,arguments)))),H=Ge(b);if(L.wheel)(L.mouse[0][0]!==H[0]||L.mouse[0][1]!==H[1])&&(L.mouse[1]=N.invert(L.mouse[0]=H)),clearTimeout(L.wheel);else{if(N.k===F)return;L.mouse=[H,N.invert(H)],us(this),L.start()}mn(b),L.wheel=setTimeout(K,g),L.zoom("mouse",n(y(v(N,F),L.mouse[0],L.mouse[1]),L.extent,l));function K(){L.wheel=null,L.end()}}function B(b,...k){if(m||!e.apply(this,arguments))return;var L=b.currentTarget,N=M(this,k,!0).event(b),F=ze(b.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",ne,!0),H=Ge(b,L),K=b.clientX,Z=b.clientY;Tu(b.view),po(b),N.mouse=[H,this.__zoom.invert(H)],us(this),N.start();function Y(J){if(mn(J),!N.moved){var ce=J.clientX-K,le=J.clientY-Z;N.moved=ce*ce+le*le>E}N.event(J).zoom("mouse",n(y(N.that.__zoom,N.mouse[0]=Ge(J,L),N.mouse[1]),N.extent,l))}function ne(J){F.on("mousemove.zoom mouseup.zoom",null),Iu(J.view,N.moved),mn(J),N.event(J).end()}}function z(b,...k){if(e.apply(this,arguments)){var L=this.__zoom,N=Ge(b.changedTouches?b.changedTouches[0]:b,this),F=L.invert(N),H=L.k*(b.shiftKey?.5:2),K=n(y(v(L,H),N,F),t.apply(this,k),l);mn(b),a>0?ze(this).transition().duration(a).call(_,K,N,b):ze(this).call(R.transform,K,N,b)}}function $(b,...k){if(e.apply(this,arguments)){var L=b.touches,N=L.length,F=M(this,k,b.changedTouches.length===N).event(b),H,K,Z,Y;for(po(b),K=0;K<N;++K)Z=L[K],Y=Ge(Z,this),Y=[Y,this.__zoom.invert(Y),Z.identifier],F.touch0?!F.touch1&&F.touch0[2]!==Y[2]&&(F.touch1=Y,F.taps=0):(F.touch0=Y,H=!0,F.taps=1+!!x);x&&(x=clearTimeout(x)),H&&(F.taps<2&&(p=Y[0],x=setTimeout(function(){x=null},h)),us(this),F.start())}}function D(b,...k){if(this.__zooming){var L=M(this,k).event(b),N=b.changedTouches,F=N.length,H,K,Z,Y;for(mn(b),H=0;H<F;++H)K=N[H],Z=Ge(K,this),L.touch0&&L.touch0[2]===K.identifier?L.touch0[0]=Z:L.touch1&&L.touch1[2]===K.identifier&&(L.touch1[0]=Z);if(K=L.that.__zoom,L.touch1){var ne=L.touch0[0],J=L.touch0[1],ce=L.touch1[0],le=L.touch1[1],se=(se=ce[0]-ne[0])*se+(se=ce[1]-ne[1])*se,ee=(ee=le[0]-J[0])*ee+(ee=le[1]-J[1])*ee;K=v(K,Math.sqrt(se/ee)),Z=[(ne[0]+ce[0])/2,(ne[1]+ce[1])/2],Y=[(J[0]+le[0])/2,(J[1]+le[1])/2]}else if(L.touch0)Z=L.touch0[0],Y=L.touch0[1];else return;L.zoom("touch",n(y(K,Z,Y),L.extent,l))}}function V(b,...k){if(this.__zooming){var L=M(this,k).event(b),N=b.changedTouches,F=N.length,H,K;for(po(b),m&&clearTimeout(m),m=setTimeout(function(){m=null},h),H=0;H<F;++H)K=N[H],L.touch0&&L.touch0[2]===K.identifier?delete L.touch0:L.touch1&&L.touch1[2]===K.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(K=Ge(K,this),Math.hypot(p[0]-K[0],p[1]-K[1])<S)){var Z=ze(this).on("dblclick.zoom");Z&&Z.apply(this,arguments)}}}return R.wheelDelta=function(b){return arguments.length?(s=typeof b=="function"?b:qn(+b),R):s},R.filter=function(b){return arguments.length?(e=typeof b=="function"?b:qn(!!b),R):e},R.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:qn(!!b),R):r},R.extent=function(b){return arguments.length?(t=typeof b=="function"?b:qn([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),R):t},R.scaleExtent=function(b){return arguments.length?(i[0]=+b[0],i[1]=+b[1],R):[i[0],i[1]]},R.translateExtent=function(b){return arguments.length?(l[0][0]=+b[0][0],l[1][0]=+b[1][0],l[0][1]=+b[0][1],l[1][1]=+b[1][1],R):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},R.constrain=function(b){return arguments.length?(n=b,R):n},R.duration=function(b){return arguments.length?(a=+b,R):a},R.interpolate=function(b){return arguments.length?(c=b,R):c},R.on=function(){var b=d.on.apply(d,arguments);return b===d?R:b},R.clickDistance=function(b){return arguments.length?(E=(b=+b)*b,R):Math.sqrt(E)},R.tapDistance=function(b){return arguments.length?(S=+b,R):S},R}const Oe={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:s}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},_n=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ku=["Enter"," ","Escape"],Yu={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Pt;(function(e){e.Strict="strict",e.Loose="loose"})(Pt||(Pt={}));var bt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(bt||(bt={}));var Jt;(function(e){e.Partial="partial",e.Full="full"})(Jt||(Jt={}));const Gu={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var ft;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ft||(ft={}));var Rs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Rs||(Rs={}));var Q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Q||(Q={}));const Ki={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top};function Uu(e){return e===null?null:e?"valid":"invalid"}const Wu=e=>"id"in e&&"source"in e&&"target"in e,Ay=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Kr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Bn=(e,t=[0,0])=>{const{width:n,height:s}=ut(e),r=e.origin??t,i=n*r[0],l=s*r[1];return{x:e.position.x-i,y:e.position.y-l}},Dy=(e,t={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!t.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,r)=>{const i=typeof r=="string";let l=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(l=i?t.nodeLookup.get(r):Kr(r)?r:t.nodeLookup.get(r.id));const a=l?Cs(l,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Vs(s,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Fs(n)},$n=(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=Vs(n,r)}}),Fs(n)},Yr=(e,t,[n,s,r]=[0,0,1],i=!1,l=!1)=>{const a={...zn(t,[n,s,r]),width:t.width/r,height:t.height/r},c=[];for(const d of e.values()){const{measured:x,selectable:p=!0,hidden:m=!1}=d;if(l&&!p||m)continue;const h=x.width??d.width??d.initialWidth??null,g=x.height??d.height??d.initialHeight??null,E=kn(a,tn(d)),S=(h??0)*(g??0),R=i&&E>0;(!d.internals.handleBounds||R||E>=S||d.dragging)&&c.push(d)}return c},By=(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 $y(e,t){const n=new Map,s=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!s||s.has(r.id))&&n.set(r.id,r)}),n}async function zy({nodes:e,width:t,height:n,panZoom:s,minZoom:r,maxZoom:i},l){if(e.size===0)return Promise.resolve(!0);const a=$y(e,l),c=$n(a),d=Gr(c,t,n,l?.minZoom??r,l?.maxZoom??i,l?.padding??.1);return await s.setViewport(d,{duration:l?.duration,ease:l?.ease,interpolate:l?.interpolate}),Promise.resolve(!0)}function Xu({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:r,onError:i}){const l=n.get(e),a=l.parentId?n.get(l.parentId):void 0,{x:c,y:d}=a?a.internals.positionAbsolute:{x:0,y:0},x=l.origin??s;let p=r;if(l.extent==="parent"&&!l.expandParent)if(!a)i?.("005",Oe.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(p=[[c,d],[c+h,d+g]])}else a&&nn(l.extent)&&(p=[[l.extent[0][0]+c,l.extent[0][1]+d],[l.extent[1][0]+c,l.extent[1][1]+d]]);const m=nn(p)?Tt(t,p,l.measured):t;return(l.measured.width===void 0||l.measured.height===void 0)&&i?.("015",Oe.error015()),{position:{x:m.x-c+(l.measured.width??0)*x[0],y:m.y-d+(l.measured.height??0)*x[1]},positionAbsolute:m}}async function Vy({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 h=i.has(m.id),g=!h&&m.parentId&&l.find(E=>E.id===m.parentId);(h||g)&&l.push(m)}const a=new Set(t.map(m=>m.id)),c=s.filter(m=>m.deletable!==!1),x=By(l,c);for(const m of c)a.has(m.id)&&!x.find(g=>g.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 en=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Tt=(e={x:0,y:0},t,n)=>({x:en(e.x,t[0][0],t[1][0]-(n?.width??0)),y:en(e.y,t[0][1],t[1][1]-(n?.height??0))});function qu(e,t,n){const{width:s,height:r}=ut(n),{x:i,y:l}=n.internals.positionAbsolute;return Tt(e,[[i,l],[i+s,l+r]],t)}const Yi=(e,t,n)=>e<t?en(Math.abs(e-t),1,t)/t:e>n?-en(Math.abs(e-n),1,t)/t:0,Qu=(e,t,n=15,s=40)=>{const r=Yi(e.x,s,t.width-s)*n,i=Yi(e.y,s,t.height-s)*n;return[r,i]},Vs=(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)}),Ho=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),Fs=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),tn=(e,t=[0,0])=>{const{x:n,y:s}=Kr(e)?e.internals.positionAbsolute:Bn(e,t);return{x:n,y:s,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Cs=(e,t=[0,0])=>{const{x:n,y:s}=Kr(e)?e.internals.positionAbsolute:Bn(e,t);return{x:n,y:s,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:s+(e.measured?.height??e.height??e.initialHeight??0)}},Ju=(e,t)=>Fs(Vs(Ho(e),Ho(t))),kn=(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)},Gi=e=>Ue(e.width)&&Ue(e.height)&&Ue(e.x)&&Ue(e.y),Ue=e=>!isNaN(e)&&isFinite(e),ws=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},Hs=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),zn=({x:e,y:t},[n,s,r],i=!1,l=[1,1])=>{const a={x:(e-n)/r,y:(t-s)/r};return i?Hs(a,l):a},bs=({x:e,y:t},[n,s,r])=>({x:e*r+n,y:t*r+s});function Ht(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Fy(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=Ht(e,n),r=Ht(e,t);return{top:s,right:r,bottom:s,left:r,x:r*2,y:s*2}}if(typeof e=="object"){const s=Ht(e.top??e.y??0,n),r=Ht(e.bottom??e.y??0,n),i=Ht(e.left??e.x??0,t),l=Ht(e.right??e.x??0,t);return{top:s,right:l,bottom:r,left:i,x:i+l,y:s+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Hy(e,t,n,s,r,i){const{x:l,y:a}=bs(e,[t,n,s]),{x:c,y:d}=bs({x:e.x+e.width,y:e.y+e.height},[t,n,s]),x=r-c,p=i-d;return{left:Math.floor(l),top:Math.floor(a),right:Math.floor(x),bottom:Math.floor(p)}}const Gr=(e,t,n,s,r,i)=>{const l=Fy(i,t,n),a=(t-l.x)/e.width,c=(n-l.y)/e.height,d=Math.min(a,c),x=en(d,s,r),p=e.x+e.width/2,m=e.y+e.height/2,h=t/2-p*x,g=n/2-m*x,E=Hy(e,h,g,x,t,n),S={left:Math.min(E.left-l.left,0),top:Math.min(E.top-l.top,0),right:Math.min(E.right-l.right,0),bottom:Math.min(E.bottom-l.bottom,0)};return{x:h-S.left+S.right,y:g-S.top+S.bottom,zoom:x}},vs=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function nn(e){return e!==void 0&&e!=="parent"}function ut(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function ed(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function td(e,t={width:0,height:0},n,s,r){const i={...e},l=s.get(n);if(l){const a=l.origin||r;i.x+=l.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=l.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Ui(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Zy(){let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}}function Ky(e){return{...Yu,...e||{}}}function yn(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:r}){const{x:i,y:l}=tt(e),a=zn({x:i-(r?.left??0),y:l-(r?.top??0)},s),{x:c,y:d}=n?Hs(a,t):a;return{xSnapped:c,ySnapped:d,...a}}const Ur=e=>({width:e.offsetWidth,height:e.offsetHeight}),nd=e=>e?.getRootNode?.()||window?.document,Yy=["INPUT","SELECT","TEXTAREA"];function sd(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:Yy.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const od=e=>"clientX"in e,tt=(e,t)=>{const n=od(e),s=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:s-(t?.left??0),y:r-(t?.top??0)}},Wi=(e,t,n,s,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(l=>{const a=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:r,position:l.getAttribute("data-handlepos"),x:(a.left-n.left)/s,y:(a.top-n.top)/s,...Ur(l)}})};function rd({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:r,sourceControlY:i,targetControlX:l,targetControlY:a}){const c=e*.125+r*.375+l*.375+n*.125,d=t*.125+i*.375+a*.375+s*.125,x=Math.abs(c-e),p=Math.abs(d-t);return[c,d,x,p]}function Qn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Xi({pos:e,x1:t,y1:n,x2:s,y2:r,c:i}){switch(e){case Q.Left:return[t-Qn(t-s,i),n];case Q.Right:return[t+Qn(s-t,i),n];case Q.Top:return[t,n-Qn(n-r,i)];case Q.Bottom:return[t,n+Qn(r-n,i)]}}function id({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:s,targetY:r,targetPosition:i=Q.Top,curvature:l=.25}){const[a,c]=Xi({pos:n,x1:e,y1:t,x2:s,y2:r,c:l}),[d,x]=Xi({pos:i,x1:s,y1:r,x2:e,y2:t,c:l}),[p,m,h,g]=rd({sourceX:e,sourceY:t,targetX:s,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:d,targetControlY:x});return[`M${e},${t} C${a},${c} ${d},${x} ${s},${r}`,p,m,h,g]}function ld({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,a=s<t?s+l:s-l;return[i,a,r,l]}function Gy({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s,elevateOnSelect:r=!1}){if(s!==void 0)return s;const i=r&&n?1e3:0,l=Math.max(e.parentId?e.internals.z:0,t.parentId?t.internals.z:0);return i+l}function Uy({sourceNode:e,targetNode:t,width:n,height:s,transform:r}){const i=Vs(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 kn(l,Fs(i))>0}const ad=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,Wy=(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)),cd=(e,t)=>{if(!e.source||!e.target)return ws("006",Oe.error006()),t;let n;return Wu(e)?n={...e}:n={...e,id:ad(e)},Wy(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))},Xy=(e,t,n,s={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return ws("006",Oe.error006()),n;if(!n.find(c=>c.id===e.id))return ws("007",Oe.error007(r)),n;const a={...i,id:s.shouldReplaceId?ad(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(c=>c.id!==r).concat(a)};function ud({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[r,i,l,a]=ld({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,r,i,l,a]}const qi={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},qy=({source:e,sourcePosition:t=Q.Bottom,target:n})=>t===Q.Left||t===Q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Qi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Qy({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:s=Q.Top,center:r,offset:i}){const l=qi[t],a=qi[s],c={x:e.x+l.x*i,y:e.y+l.y*i},d={x:n.x+a.x*i,y:n.y+a.y*i},x=qy({source:c,sourcePosition:t,target:d}),p=x.x!==0?"x":"y",m=x[p];let h=[],g,E;const S={x:0,y:0},R={x:0,y:0},[v,y,C,_]=ld({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*a[p]===-1){g=r.x??v,E=r.y??y;const I=[{x:g,y:c.y},{x:g,y:d.y}],A=[{x:c.x,y:E},{x:d.x,y:E}];l[p]===m?h=p==="x"?I:A:h=p==="x"?A:I}else{const I=[{x:c.x,y:d.y}],A=[{x:d.x,y:c.y}];if(p==="x"?h=l.x===m?A:I:h=l.y===m?I:A,t===s){const V=Math.abs(e[p]-n[p]);if(V<=i){const b=Math.min(i-1,i-V);l[p]===m?S[p]=(c[p]>e[p]?-1:1)*b:R[p]=(d[p]>n[p]?-1:1)*b}}if(t!==s){const V=p==="x"?"y":"x",b=l[p]===a[V],k=c[V]>d[V],L=c[V]<d[V];(l[p]===1&&(!b&&k||b&&L)||l[p]!==1&&(!b&&L||b&&k))&&(h=p==="x"?I:A)}const B={x:c.x+S.x,y:c.y+S.y},z={x:d.x+R.x,y:d.y+R.y},$=Math.max(Math.abs(B.x-h[0].x),Math.abs(z.x-h[0].x)),D=Math.max(Math.abs(B.y-h[0].y),Math.abs(z.y-h[0].y));$>=D?(g=(B.x+z.x)/2,E=h[0].y):(g=h[0].x,E=(B.y+z.y)/2)}return[[e,{x:c.x+S.x,y:c.y+S.y},...h,{x:d.x+R.x,y:d.y+R.y},n],g,E,C,_]}function Jy(e,t,n,s){const r=Math.min(Qi(e,t)/2,Qi(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 a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${l+r*c}Q ${i},${l} ${i+r*a},${l}`}function Zo({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:s,targetY:r,targetPosition:i=Q.Top,borderRadius:l=5,centerX:a,centerY:c,offset:d=20}){const[x,p,m,h,g]=Qy({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:r},targetPosition:i,center:{x:a,y:c},offset:d});return[x.reduce((S,R,v)=>{let y="";return v>0&&v<x.length-1?y=Jy(x[v-1],R,x[v+1],l):y=`${v===0?"M":"L"}${R.x} ${R.y}`,S+=y,S},""),p,m,h,g]}function Ji(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function eS(e){const{sourceNode:t,targetNode:n}=e;if(!Ji(t)||!Ji(n))return null;const s=t.internals.handleBounds||el(t.handles),r=n.internals.handleBounds||el(n.handles),i=tl(s?.source??[],e.sourceHandle),l=tl(e.connectionMode===Pt.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!l)return e.onError?.("008",Oe.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||Q.Bottom,c=l?.position||Q.Top,d=Ln(t,i,a),x=Ln(n,l,c);return{sourceX:d.x,sourceY:d.y,targetX:x.x,targetY:x.y,sourcePosition:a,targetPosition:c}}function el(e){if(!e)return null;const t=[],n=[];for(const s of e)s.width=s.width??1,s.height=s.height??1,s.type==="source"?t.push(s):s.type==="target"&&n.push(s);return{source:t,target:n}}function Ln(e,t,n=Q.Left,s=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:l,height:a}=t??ut(e);if(s)return{x:r+l/2,y:i+a/2};switch(t?.position??n){case Q.Top:return{x:r+l/2,y:i};case Q.Right:return{x:r+l,y:i+a/2};case Q.Bottom:return{x:r+l/2,y:i+a};case Q.Left:return{x:r,y:i+a/2}}}function tl(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ko(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function tS(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:r}){const i=new Set;return e.reduce((l,a)=>([a.markerStart||s,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const d=Ko(c,t);i.has(d)||(l.push({id:d,color:c.color||n,...c}),i.add(d))}}),l),[]).sort((l,a)=>l.id.localeCompare(a.id))}const Wr={nodeOrigin:[0,0],nodeExtent:_n,elevateNodesOnSelect:!0,defaults:{}},nS={...Wr,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 sS(e,t,n){const s=Xr(Wr,n);for(const r of e.values())if(r.parentId)qr(r,e,t,s);else{const i=Bn(r,s.nodeOrigin),l=nn(r.extent)?r.extent:s.nodeExtent,a=Tt(i,l,ut(r));r.internals.positionAbsolute=a}}function Yo(e,t,n,s){const r=Xr(nS,s);let i=e.length>0;const l=new Map(t),a=r?.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const c of e){let d=l.get(c.id);if(r.checkEquality&&c===d?.internals.userNode)t.set(c.id,d);else{const x=Bn(c,r.nodeOrigin),p=nn(c.extent)?c.extent:r.nodeExtent,m=Tt(x,p,ut(c));d={...r.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:m,handleBounds:c.measured?d?.internals.handleBounds:void 0,z:dd(c,a),userNode:c}},t.set(c.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(i=!1),c.parentId&&qr(d,t,n,s)}return i}function oS(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 qr(e,t,n,s){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:l}=Xr(Wr,s),a=e.parentId,c=t.get(a);if(!c){console.warn(`Parent node ${a} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}oS(e,n);const d=r?1e3:0,{x,y:p,z:m}=rS(e,c,i,l,d),{positionAbsolute:h}=e.internals,g=x!==h.x||p!==h.y;(g||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:g?{x,y:p}:h,z:m}})}function dd(e,t){return(Ue(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function rS(e,t,n,s,r){const{x:i,y:l}=t.internals.positionAbsolute,a=ut(e),c=Bn(e,n),d=nn(e.extent)?Tt(c,e.extent,a):c;let x=Tt({x:i+d.x,y:l+d.y},s,a);e.extent==="parent"&&(x=qu(x,a,t));const p=dd(e,r),m=t.internals.z??0;return{x:x.x,y:x.y,z:m>=p?m+1:p}}function Qr(e,t,n,s=[0,0]){const r=[],i=new Map;for(const l of e){const a=t.get(l.parentId);if(!a)continue;const c=i.get(l.parentId)?.expandedRect??tn(a),d=Ju(c,l.rect);i.set(l.parentId,{expandedRect:d,parent:a})}return i.size>0&&i.forEach(({expandedRect:l,parent:a},c)=>{const d=a.internals.positionAbsolute,x=ut(a),p=a.origin??s,m=l.x<d.x?Math.round(Math.abs(d.x-l.x)):0,h=l.y<d.y?Math.round(Math.abs(d.y-l.y)):0,g=Math.max(x.width,Math.round(l.width)),E=Math.max(x.height,Math.round(l.height)),S=(g-x.width)*p[0],R=(E-x.height)*p[1];(m>0||h>0||S||R)&&(r.push({id:c,type:"position",position:{x:a.position.x-m+S,y:a.position.y-h+R}}),n.get(c)?.forEach(v=>{e.some(y=>y.id===v.id)||r.push({id:v.id,type:"position",position:{x:v.position.x+m,y:v.position.y+h}})})),(x.width<l.width||x.height<l.height||m||h)&&r.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:g+(m?p[0]*m-S:0),height:E+(h?p[1]*h-R:0)}})}),r}function iS(e,t,n,s,r,i){const l=s?.querySelector(".xyflow__viewport");let a=!1;if(!l)return{changes:[],updatedInternals:a};const c=[],d=window.getComputedStyle(l),{m22:x}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const m of e.values()){const h=t.get(m.id);if(!h)continue;if(h.hidden){t.set(h.id,{...h,internals:{...h.internals,handleBounds:void 0}}),a=!0;continue}const g=Ur(m.nodeElement),E=h.measured.width!==g.width||h.measured.height!==g.height;if(!!(g.width&&g.height&&(E||!h.internals.handleBounds||m.force))){const R=m.nodeElement.getBoundingClientRect(),v=nn(h.extent)?h.extent:i;let{positionAbsolute:y}=h.internals;h.parentId&&h.extent==="parent"?y=qu(y,g,t.get(h.parentId)):v&&(y=Tt(y,v,g));const C={...h,measured:g,internals:{...h.internals,positionAbsolute:y,handleBounds:{source:Wi("source",m.nodeElement,R,x,h.id),target:Wi("target",m.nodeElement,R,x,h.id)}}};t.set(h.id,C),h.parentId&&qr(C,t,n,{nodeOrigin:r}),a=!0,E&&(c.push({id:h.id,type:"dimensions",dimensions:g}),h.expandParent&&h.parentId&&p.push({id:h.id,parentId:h.parentId,rect:tn(C,r)}))}}if(p.length>0){const m=Qr(p,t,n,r);c.push(...m)}return{changes:c,updatedInternals:a}}async function lS({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),a=!!l&&(l.x!==n[0]||l.y!==n[1]||l.k!==n[2]);return Promise.resolve(a)}function nl(e,t,n,s,r,i){let l=r;const a=s.get(l)||new Map;s.set(l,a.set(n,t)),l=`${r}-${e}`;const c=s.get(l)||new Map;if(s.set(l,c.set(n,t)),i){l=`${r}-${e}-${i}`;const d=s.get(l)||new Map;s.set(l,d.set(n,t))}}function xd(e,t,n){e.clear(),t.clear();for(const s of n){const{source:r,target:i,sourceHandle:l=null,targetHandle:a=null}=s,c={edgeId:s.id,source:r,target:i,sourceHandle:l,targetHandle:a},d=`${r}-${l}--${i}-${a}`,x=`${i}-${a}--${r}-${l}`;nl("source",c,x,e,r,l),nl("target",c,d,e,i,a),t.set(s.id,s)}}function pd(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:pd(n,t):!1}function sl(e,t,n){let s=e;do{if(s?.matches?.(t))return!0;if(s===n)return!1;s=s?.parentElement}while(s);return!1}function aS(e,t,n,s){const r=new Map;for(const[i,l]of e)if((l.selected||l.id===s)&&(!l.parentId||!pd(l,e))&&(l.draggable||t&&typeof l.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function mo({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){const r=[];for(const[l,a]of t){const c=n.get(l)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:s})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:s}:r[0],r]}function cS({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:r}){let i={x:null,y:null},l=0,a=new Map,c=!1,d={x:0,y:0},x=null,p=!1,m=null,h=!1,g=!1;function E({noDragClassName:R,handleSelector:v,domNode:y,isSelectable:C,nodeId:_,nodeClickDistance:M=0}){m=ze(y);function I({x:$,y:D},V){const{nodeLookup:b,nodeExtent:k,snapGrid:L,snapToGrid:N,nodeOrigin:F,onNodeDrag:H,onSelectionDrag:K,onError:Z,updateNodePositions:Y}=t();i={x:$,y:D};let ne=!1,J={x:0,y:0,x2:0,y2:0};if(a.size>1&&k){const ce=$n(a);J=Ho(ce)}for(const[ce,le]of a){if(!b.has(ce))continue;let se={x:$-le.distance.x,y:D-le.distance.y};N&&(se=Hs(se,L));let ee=[[k[0][0],k[0][1]],[k[1][0],k[1][1]]];if(a.size>1&&k&&!le.extent){const{positionAbsolute:Se}=le.internals,ue=Se.x-J.x+k[0][0],me=Se.x+le.measured.width-J.x2+k[1][0],X=Se.y-J.y+k[0][1],de=Se.y+le.measured.height-J.y2+k[1][1];ee=[[ue,X],[me,de]]}const{position:re,positionAbsolute:ye}=Xu({nodeId:ce,nextPosition:se,nodeLookup:b,nodeExtent:ee,nodeOrigin:F,onError:Z});ne=ne||le.position.x!==re.x||le.position.y!==re.y,le.position=re,le.internals.positionAbsolute=ye}if(g=g||ne,!!ne&&(Y(a,!0),V&&(s||H||!_&&K))){const[ce,le]=mo({nodeId:_,dragItems:a,nodeLookup:b});s?.(V,a,ce,le),H?.(V,ce,le),_||K?.(V,le)}}async function A(){if(!x)return;const{transform:$,panBy:D,autoPanSpeed:V,autoPanOnNodeDrag:b}=t();if(!b){c=!1,cancelAnimationFrame(l);return}const[k,L]=Qu(d,x,V);(k!==0||L!==0)&&(i.x=(i.x??0)-k/$[2],i.y=(i.y??0)-L/$[2],await D({x:k,y:L})&&I(i,null)),l=requestAnimationFrame(A)}function B($){const{nodeLookup:D,multiSelectionActive:V,nodesDraggable:b,transform:k,snapGrid:L,snapToGrid:N,selectNodesOnDrag:F,onNodeDragStart:H,onSelectionDragStart:K,unselectNodesAndEdges:Z}=t();p=!0,(!F||!C)&&!V&&_&&(D.get(_)?.selected||Z()),C&&F&&_&&e?.(_);const Y=yn($.sourceEvent,{transform:k,snapGrid:L,snapToGrid:N,containerBounds:x});if(i=Y,a=aS(D,b,Y,_),a.size>0&&(n||H||!_&&K)){const[ne,J]=mo({nodeId:_,dragItems:a,nodeLookup:D});n?.($.sourceEvent,a,ne,J),H?.($.sourceEvent,ne,J),_||K?.($.sourceEvent,J)}}const z=Ou().clickDistance(M).on("start",$=>{const{domNode:D,nodeDragThreshold:V,transform:b,snapGrid:k,snapToGrid:L}=t();x=D?.getBoundingClientRect()||null,h=!1,g=!1,V===0&&B($),i=yn($.sourceEvent,{transform:b,snapGrid:k,snapToGrid:L,containerBounds:x}),d=tt($.sourceEvent,x)}).on("drag",$=>{const{autoPanOnNodeDrag:D,transform:V,snapGrid:b,snapToGrid:k,nodeDragThreshold:L,nodeLookup:N}=t(),F=yn($.sourceEvent,{transform:V,snapGrid:b,snapToGrid:k,containerBounds:x});if(($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||_&&!N.has(_))&&(h=!0),!h){if(!c&&D&&p&&(c=!0,A()),!p){const H=F.xSnapped-(i.x??0),K=F.ySnapped-(i.y??0);Math.sqrt(H*H+K*K)>L&&B($)}(i.x!==F.xSnapped||i.y!==F.ySnapped)&&a&&p&&(d=tt($.sourceEvent,x),I(F,$.sourceEvent))}}).on("end",$=>{if(!(!p||h)&&(c=!1,p=!1,cancelAnimationFrame(l),a.size>0)){const{nodeLookup:D,updateNodePositions:V,onNodeDragStop:b,onSelectionDragStop:k}=t();if(g&&(V(a,!1),g=!1),r||b||!_&&k){const[L,N]=mo({nodeId:_,dragItems:a,nodeLookup:D,dragging:!1});r?.($.sourceEvent,a,L,N),b?.($.sourceEvent,L,N),_||k?.($.sourceEvent,N)}}}).filter($=>{const D=$.target;return!$.button&&(!R||!sl(D,`.${R}`,y))&&(!v||sl(D,v,y))});m.call(z)}function S(){m?.on(".drag",null)}return{update:E,destroy:S}}function uS(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())kn(r,tn(i))>0&&s.push(i);return s}const dS=250;function xS(e,t,n,s){let r=[],i=1/0;const l=uS(e,n,t+dS);for(const a of l){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const d of c){if(s.nodeId===d.nodeId&&s.type===d.type&&s.id===d.id)continue;const{x,y:p}=Ln(a,d,d.position,!0),m=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(p-e.y,2));m>t||(m<i?(r=[{...d,x,y:p}],i=m):m===i&&r.push({...d,x,y:p}))}}if(!r.length)return null;if(r.length>1){const a=s.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function md(e,t,n,s,r,i=!1){const l=s.get(e);if(!l)return null;const a=r==="strict"?l.internals.handleBounds?.[t]:[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]],c=(n?a?.find(d=>d.id===n):a?.[0])??null;return c&&i?{...c,...Ln(l,c,c.position,!0)}:c}function fd(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function pS(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const hd=()=>!0;function mS(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:r,edgeUpdaterType:i,isTarget:l,domNode:a,nodeLookup:c,lib:d,autoPanOnConnect:x,flowId:p,panBy:m,cancelConnection:h,onConnectStart:g,onConnect:E,onConnectEnd:S,isValidConnection:R=hd,onReconnectEnd:v,updateConnection:y,getTransform:C,getFromHandle:_,autoPanSpeed:M,dragThreshold:I=1}){const A=nd(e.target);let B=0,z;const{x:$,y:D}=tt(e),V=A?.elementFromPoint($,D),b=fd(i,V),k=a?.getBoundingClientRect();let L=!1;if(!k||!b)return;const N=md(r,b,s,c,t);if(!N)return;let F=tt(e,k),H=!1,K=null,Z=!1,Y=null;function ne(){if(!x||!k)return;const[Se,ue]=Qu(F,k,M);m({x:Se,y:ue}),B=requestAnimationFrame(ne)}const J={...N,nodeId:r,type:b,position:N.position},ce=c.get(r);let se={inProgress:!0,isValid:null,from:Ln(ce,J,Q.Left,!0),fromHandle:J,fromPosition:J.position,fromNode:ce,to:F,toHandle:null,toPosition:Ki[J.position],toNode:null};function ee(){L=!0,y(se),g?.(e,{nodeId:r,handleId:s,handleType:b})}I===0&&ee();function re(Se){if(!L){const{x:de,y:be}=tt(Se),Te=de-$,et=be-D;if(!(Te*Te+et*et>I*I))return;ee()}if(!_()||!J){ye(Se);return}const ue=C();F=tt(Se,k),z=xS(zn(F,ue,!1,[1,1]),n,c,J),H||(ne(),H=!0);const me=gd(Se,{handle:z,connectionMode:t,fromNodeId:r,fromHandleId:s,fromType:l?"target":"source",isValidConnection:R,doc:A,lib:d,flowId:p,nodeLookup:c});Y=me.handleDomNode,K=me.connection,Z=pS(!!z,me.isValid);const X={...se,isValid:Z,to:me.toHandle&&Z?bs({x:me.toHandle.x,y:me.toHandle.y},ue):F,toHandle:me.toHandle,toPosition:Z&&me.toHandle?me.toHandle.position:Ki[J.position],toNode:me.toHandle?c.get(me.toHandle.nodeId):null};Z&&z&&se.toHandle&&X.toHandle&&se.toHandle.type===X.toHandle.type&&se.toHandle.nodeId===X.toHandle.nodeId&&se.toHandle.id===X.toHandle.id&&se.to.x===X.to.x&&se.to.y===X.to.y||(y(X),se=X)}function ye(Se){if(L){(z||Y)&&K&&Z&&E?.(K);const{inProgress:ue,...me}=se,X={...me,toPosition:se.toHandle?se.toPosition:null};S?.(Se,X),i&&v?.(Se,X)}h(),cancelAnimationFrame(B),H=!1,Z=!1,K=null,Y=null,A.removeEventListener("mousemove",re),A.removeEventListener("mouseup",ye),A.removeEventListener("touchmove",re),A.removeEventListener("touchend",ye)}A.addEventListener("mousemove",re),A.addEventListener("mouseup",ye),A.addEventListener("touchmove",re),A.addEventListener("touchend",ye)}function gd(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:r,fromType:i,doc:l,lib:a,flowId:c,isValidConnection:d=hd,nodeLookup:x}){const p=i==="target",m=t?l.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=tt(e),E=l.elementFromPoint(h,g),S=E?.classList.contains(`${a}-flow__handle`)?E:m,R={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const v=fd(void 0,S),y=S.getAttribute("data-nodeid"),C=S.getAttribute("data-handleid"),_=S.classList.contains("connectable"),M=S.classList.contains("connectableend");if(!y||!v)return R;const I={source:p?y:s,sourceHandle:p?C:r,target:p?s:y,targetHandle:p?r:C};R.connection=I;const B=_&&M&&(n===Pt.Strict?p&&v==="source"||!p&&v==="target":y!==s||C!==r);R.isValid=B&&d(I),R.toHandle=md(y,v,C,x,n,!0)}return R}const Go={onPointerDown:mS,isValid:gd};function fS({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const r=ze(e);function i({translateExtent:a,width:c,height:d,zoomStep:x=10,pannable:p=!0,zoomable:m=!0,inversePan:h=!1}){const g=y=>{const C=n();if(y.sourceEvent.type!=="wheel"||!t)return;const _=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*x,M=C[2]*Math.pow(2,_);t.scaleTo(M)};let E=[0,0];const S=y=>{(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(E=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY])},R=y=>{const C=n();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!t)return;const _=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY],M=[_[0]-E[0],_[1]-E[1]];E=_;const I=s()*Math.max(C[2],Math.log(C[2]))*(h?-1:1),A={x:C[0]-M[0]*I,y:C[1]-M[1]*I},B=[[0,0],[c,d]];t.setViewportConstrained({x:A.x,y:A.y,zoom:C[2]},B,a)},v=Zu().on("start",S).on("zoom",p?R:null).on("zoom.wheel",m?g:null);r.call(v,{})}function l(){r.on("zoom",null)}return{update:i,destroy:l,pointer:Ge}}const hS=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Zs=e=>({x:e.x,y:e.y,zoom:e.k}),fo=({x:e,y:t,zoom:n})=>zs.translate(e,t).scale(n),Kt=(e,t)=>e.target.closest(`.${t}`),jd=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),gS=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ho=(e,t=0,n=gS,s=()=>{})=>{const r=typeof t=="number"&&t>0;return r||s(),r?e.transition().duration(t).ease(n).on("end",s):e},Ed=e=>{const t=e.ctrlKey&&vs()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function jS({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:l,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:d}){return x=>{if(Kt(x,t))return!1;x.preventDefault(),x.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(x.ctrlKey&&l){const S=Ge(x),R=Ed(x),v=p*Math.pow(2,R);s.scaleTo(n,v,S,x);return}const m=x.deltaMode===1?20:1;let h=r===bt.Vertical?0:x.deltaX*m,g=r===bt.Horizontal?0:x.deltaY*m;!vs()&&x.shiftKey&&r!==bt.Vertical&&(h=x.deltaY*m,g=0),s.translateBy(n,-(h/p)*i,-(g/p)*i,{internal:!0});const E=Zs(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,a?.(x,E)),e.isPanScrolling&&(c?.(x,E),e.panScrollTimeout=setTimeout(()=>{d?.(x,E),e.isPanScrolling=!1},150))}}function ES({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,r){const i=s.type==="wheel",l=!t&&i&&!s.ctrlKey,a=Kt(s,e);if(s.ctrlKey&&i&&a&&s.preventDefault(),l||a)return null;s.preventDefault(),n.call(this,s,r)}}function yS({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{if(s.sourceEvent?.internal)return;const r=Zs(s.transform);e.mouseButton=s.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,s.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(s.sourceEvent,r)}}function SS({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&jd(t,e.mouseButton??0)),i.sourceEvent?.sync||s([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,Zs(i.transform))}}function RS({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:r,onPaneContextMenu:i}){return l=>{if(!l.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&jd(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&i(l.sourceEvent),e.usedRightMouseButton=!1,s(!1),r&&hS(e.prevViewport,l.transform))){const a=Zs(l.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(l.sourceEvent,a)},n?150:0)}}}function CS({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:l,noWheelClassName:a,noPanClassName:c,lib:d}){return x=>{const p=e||t,m=n&&x.ctrlKey;if(x.button===1&&x.type==="mousedown"&&(Kt(x,`${d}-flow__node`)||Kt(x,`${d}-flow__edge`)))return!0;if(!s&&!p&&!r&&!i&&!n||l||Kt(x,a)&&x.type==="wheel"||Kt(x,c)&&(x.type!=="wheel"||r&&x.type==="wheel"&&!e)||!n&&x.ctrlKey&&x.type==="wheel")return!1;if(!n&&x.type==="touchstart"&&x.touches?.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 h=Array.isArray(s)&&s.includes(x.button)||!x.button||x.button<=1;return(!x.ctrlKey||x.type==="wheel")&&h}}function wS({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:s,translateExtent:r,viewport:i,onPanZoom:l,onPanZoomStart:a,onPanZoomEnd:c,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=Zu().clickDistance(!Ue(s)||s<0?0:s).scaleExtent([t,n]).translateExtent(r),h=ze(e).call(m);y({x:i.x,y:i.y,zoom:en(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const g=h.on("wheel.zoom"),E=h.on("dblclick.zoom");m.wheelDelta(Ed);function S(D,V){return h?new Promise(b=>{m?.interpolate(V?.interpolate==="linear"?O.interpolate:rs).transform(ho(h,V?.duration,V?.ease,()=>b(!0)),D)}):Promise.resolve(!1)}function R({noWheelClassName:D,noPanClassName:V,onPaneContextMenu:b,userSelectionActive:k,panOnScroll:L,panOnDrag:N,panOnScrollMode:F,panOnScrollSpeed:H,preventScrolling:K,zoomOnPinch:Z,zoomOnScroll:Y,zoomOnDoubleClick:ne,zoomActivationKeyPressed:J,lib:ce,onTransformChange:le}){k&&!x.isZoomingOrPanning&&v();const ee=L&&!J&&!k?jS({zoomPanValues:x,noWheelClassName:D,d3Selection:h,d3Zoom:m,panOnScrollMode:F,panOnScrollSpeed:H,zoomOnPinch:Z,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}):ES({noWheelClassName:D,preventScrolling:K,d3ZoomHandler:g});if(h.on("wheel.zoom",ee,{passive:!1}),!k){const ye=yS({zoomPanValues:x,onDraggingChange:d,onPanZoomStart:a});m.on("start",ye);const Se=SS({zoomPanValues:x,panOnDrag:N,onPaneContextMenu:!!b,onPanZoom:l,onTransformChange:le});m.on("zoom",Se);const ue=RS({zoomPanValues:x,panOnDrag:N,panOnScroll:L,onPaneContextMenu:b,onPanZoomEnd:c,onDraggingChange:d});m.on("end",ue)}const re=CS({zoomActivationKeyPressed:J,panOnDrag:N,zoomOnScroll:Y,panOnScroll:L,zoomOnDoubleClick:ne,zoomOnPinch:Z,userSelectionActive:k,noPanClassName:V,noWheelClassName:D,lib:ce});m.filter(re),ne?h.on("dblclick.zoom",E):h.on("dblclick.zoom",null)}function v(){m.on("zoom",null)}async function y(D,V,b){const k=fo(D),L=m?.constrain()(k,V,b);return L&&await S(L),new Promise(N=>N(L))}async function C(D,V){const b=fo(D);return await S(b,V),new Promise(k=>k(b))}function _(D){if(h){const V=fo(D),b=h.property("__zoom");(b.k!==D.zoom||b.x!==D.x||b.y!==D.y)&&m?.transform(h,V,null,{sync:!0})}}function M(){const D=h?Hu(h.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}function I(D,V){return h?new Promise(b=>{m?.interpolate(V?.interpolate==="linear"?O.interpolate:rs).scaleTo(ho(h,V?.duration,V?.ease,()=>b(!0)),D)}):Promise.resolve(!1)}function A(D,V){return h?new Promise(b=>{m?.interpolate(V?.interpolate==="linear"?O.interpolate:rs).scaleBy(ho(h,V?.duration,V?.ease,()=>b(!0)),D)}):Promise.resolve(!1)}function B(D){m?.scaleExtent(D)}function z(D){m?.translateExtent(D)}function $(D){const V=!Ue(D)||D<0?0:D;m?.clickDistance(V)}return{update:R,destroy:v,setViewport:C,setViewportConstrained:y,getViewport:M,scaleTo:I,scaleBy:A,setScaleExtent:B,setTranslateExtent:z,syncViewport:_,setClickDistance:$}}var sn;(function(e){e.Line="line",e.Handle="handle"})(sn||(sn={}));function bS({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:r,affectsY:i}){const l=e-t,a=n-s,c=[l>0?1:l<0?-1:0,a>0?1:a<0?-1:0];return l&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function vS(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 xt(e,t){return Math.max(0,t-e)}function pt(e,t){return Math.max(0,e-t)}function Jn(e,t,n){return Math.max(0,t-e,e-n)}function ol(e,t){return e?!t:t}function _S(e,t,n,s,r,i,l,a){let{affectsX:c,affectsY:d}=t;const{isHorizontal:x,isVertical:p}=t,m=x&&p,{xSnapped:h,ySnapped:g}=n,{minWidth:E,maxWidth:S,minHeight:R,maxHeight:v}=s,{x:y,y:C,width:_,height:M,aspectRatio:I}=e;let A=Math.floor(x?h-e.pointerX:0),B=Math.floor(p?g-e.pointerY:0);const z=_+(c?-A:A),$=M+(d?-B:B),D=-i[0]*_,V=-i[1]*M;let b=Jn(z,E,S),k=Jn($,R,v);if(l){let F=0,H=0;c&&A<0?F=xt(y+A+D,l[0][0]):!c&&A>0&&(F=pt(y+z+D,l[1][0])),d&&B<0?H=xt(C+B+V,l[0][1]):!d&&B>0&&(H=pt(C+$+V,l[1][1])),b=Math.max(b,F),k=Math.max(k,H)}if(a){let F=0,H=0;c&&A>0?F=pt(y+A,a[0][0]):!c&&A<0&&(F=xt(y+z,a[1][0])),d&&B>0?H=pt(C+B,a[0][1]):!d&&B<0&&(H=xt(C+$,a[1][1])),b=Math.max(b,F),k=Math.max(k,H)}if(r){if(x){const F=Jn(z/I,R,v)*I;if(b=Math.max(b,F),l){let H=0;!c&&!d||c&&!d&&m?H=pt(C+V+z/I,l[1][1])*I:H=xt(C+V+(c?A:-A)/I,l[0][1])*I,b=Math.max(b,H)}if(a){let H=0;!c&&!d||c&&!d&&m?H=xt(C+z/I,a[1][1])*I:H=pt(C+(c?A:-A)/I,a[0][1])*I,b=Math.max(b,H)}}if(p){const F=Jn($*I,E,S)/I;if(k=Math.max(k,F),l){let H=0;!c&&!d||d&&!c&&m?H=pt(y+$*I+D,l[1][0])/I:H=xt(y+(d?B:-B)*I+D,l[0][0])/I,k=Math.max(k,H)}if(a){let H=0;!c&&!d||d&&!c&&m?H=xt(y+$*I,a[1][0])/I:H=pt(y+(d?B:-B)*I,a[0][0])/I,k=Math.max(k,H)}}}B=B+(B<0?k:-k),A=A+(A<0?b:-b),r&&(m?z>$*I?B=(ol(c,d)?-A:A)/I:A=(ol(c,d)?-B:B)*I:x?(B=A/I,d=c):(A=B*I,c=d));const L=c?y+A:y,N=d?C+B:C;return{width:_+(c?-A:A),height:M+(d?-B:B),x:i[0]*A*(c?-1:1)+L,y:i[1]*B*(d?-1:1)+N}}const yd={width:0,height:0,x:0,y:0},kS={...yd,pointerX:0,pointerY:0,aspectRatio:1};function LS(e){return[[0,0],[e.measured.width,e.measured.height]]}function MS(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,a=n[0]*i,c=n[1]*l;return[[s-a,r-c],[s+i-a,r+l-c]]}function NS({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:r}){const i=ze(e);function l({controlPosition:c,boundaries:d,keepAspectRatio:x,resizeDirection:p,onResizeStart:m,onResize:h,onResizeEnd:g,shouldResize:E}){let S={...yd},R={...kS};const v=vS(c);let y,C=null,_=[],M,I,A;const B=Ou().on("start",z=>{const{nodeLookup:$,transform:D,snapGrid:V,snapToGrid:b,nodeOrigin:k,paneDomNode:L}=n();if(y=$.get(t),!y)return;C=L?.getBoundingClientRect()??null;const{xSnapped:N,ySnapped:F}=yn(z.sourceEvent,{transform:D,snapGrid:V,snapToGrid:b,containerBounds:C});S={width:y.measured.width??0,height:y.measured.height??0,x:y.position.x??0,y:y.position.y??0},R={...S,pointerX:N,pointerY:F,aspectRatio:S.width/S.height},M=void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(M=$.get(y.parentId),I=M&&y.extent==="parent"?LS(M):void 0),_=[],A=void 0;for(const[H,K]of $)if(K.parentId===t&&(_.push({id:H,position:{...K.position},extent:K.extent}),K.extent==="parent"||K.expandParent)){const Z=MS(K,y,K.origin??k);A?A=[[Math.min(Z[0][0],A[0][0]),Math.min(Z[0][1],A[0][1])],[Math.max(Z[1][0],A[1][0]),Math.max(Z[1][1],A[1][1])]]:A=Z}m?.(z,{...S})}).on("drag",z=>{const{transform:$,snapGrid:D,snapToGrid:V,nodeOrigin:b}=n(),k=yn(z.sourceEvent,{transform:$,snapGrid:D,snapToGrid:V,containerBounds:C}),L=[];if(!y)return;const{x:N,y:F,width:H,height:K}=S,Z={},Y=y.origin??b,{width:ne,height:J,x:ce,y:le}=_S(R,v,k,d,x,Y,I,A),se=ne!==H,ee=J!==K,re=ce!==N&&se,ye=le!==F&ⅇif(!re&&!ye&&!se&&!ee)return;if((re||ye||Y[0]===1||Y[1]===1)&&(Z.x=re?ce:S.x,Z.y=ye?le:S.y,S.x=Z.x,S.y=Z.y,_.length>0)){const X=ce-N,de=le-F;for(const be of _)be.position={x:be.position.x-X+Y[0]*(ne-H),y:be.position.y-de+Y[1]*(J-K)},L.push(be)}if((se||ee)&&(Z.width=se&&(!p||p==="horizontal")?ne:S.width,Z.height=ee&&(!p||p==="vertical")?J:S.height,S.width=Z.width,S.height=Z.height),M&&y.expandParent){const X=Y[0]*(Z.width??0);Z.x&&Z.x<X&&(S.x=X,R.x=R.x-(Z.x-X));const de=Y[1]*(Z.height??0);Z.y&&Z.y<de&&(S.y=de,R.y=R.y-(Z.y-de))}const Se=bS({width:S.width,prevWidth:H,height:S.height,prevHeight:K,affectsX:v.affectsX,affectsY:v.affectsY}),ue={...S,direction:Se};E?.(z,ue)!==!1&&(h?.(z,ue),s(Z,L))}).on("end",z=>{g?.(z,{...S}),r?.({...S})});i.call(B)}function a(){i.on(".drag",null)}return{update:l,destroy:a}}var es={exports:{}},go={},ts={exports:{}},jo={};/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./Editable-B8pvBXQS.cjs"),o=require("./jsx-runtime-CITbqOLs.cjs"),j=require("react"),u=require("./css-CZ_XGkIB.cjs"),P=require("./eraser-DiJNbabo.cjs"),qh=require("./external-0zUBjsWc.cjs"),$l=require("./Animated-CyK_c82a.cjs"),zl=require("react-dom"),O=require("./LinePlot-DslwDvAo.cjs"),ks=require("./external-Bbrq8Uh2.cjs"),te=require("zod"),Pe=require("./external-lcuUe52o.cjs"),Vl=require("./external-D0FRmOeg.cjs"),nt=require("./external-BoI3SDJy.cjs"),Fl=require("./external-DHgpDWNu.cjs"),Ie=require("./external-BNagUgId.cjs"),pe=require("./external-H1IGckxo.cjs"),Hl=require("./units-Cqxg-SBx.cjs"),Qh=require("./external-CbHi1R5M.cjs"),Jh=require("./external-B4A9qxs2.cjs"),Me=require("./external-Cw9nrwGS.cjs"),eg=require("./external-Cd_bzIsx.cjs"),tg=require("./external-1ebWGBIY.cjs"),ng=require("./Video-CbaEeyGH.cjs"),Zl=require("./Toggle-Bqp97ujd.cjs"),sg=e=>e.nullable().transform(t=>t===null?void 0:t).optional(),og=e=>te.array(e).or(e.transform(t=>[t])),Kl=e=>P.p(e,(t,n,s)=>{const r=n===s.length-1,i=!isNaN(parseInt(t)),l=!isNaN(parseInt(s[n+1]));return i&&(t="element"),r||l?t:[t,"shape"]}),fi=(e,t)=>{if(e==null)return null;const n=e[t];return n==null&&typeof e=="object"&&"sourceType"in e?e.sourceType()[t]:n},rg=(e,t,n)=>t===""?e:P.c(fi(e,"shape"),Kl(t),{...n,getter:fi}),ig=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:rg,getFieldSchemaPath:Kl,nullToUndefined:sg,toArray:og},Symbol.toStringTag,{value:"Module"})),Yl=Symbol(),qo=Symbol(),xn="a",os="w";let lg=(e,t)=>new Proxy(e,t);const Co=Object.getPrototypeOf,hi=new WeakMap,Qo=e=>e&&(hi.has(e)?hi.get(e):Co(e)===Object.prototype||Co(e)===Array.prototype),gi=e=>typeof e=="object"&&e!==null,ji=new WeakMap,Gl=e=>e[qo]||e,Ul=(e,t,n)=>{if(!Qo(e))return e;const s=Gl(e),r=(l=>Object.isFrozen(l)||Object.values(Object.getOwnPropertyDescriptors(l)).some(a=>!a.writable))(s);let i=n&&n.get(s);return i&&i[1].f===r||(i=((l,a)=>{const c={f:a};let d=!1;const x=(m,h)=>{if(!d){let g=c[xn].get(l);if(g||(g={},c[xn].set(l,g)),m===os)g[os]=!0;else{let E=g[m];E||(E=new Set,g[m]=E),E.add(h)}}},p={get:(m,h)=>h===qo?l:(x("k",h),Ul(Reflect.get(m,h),c[xn],c.c)),has:(m,h)=>h===Yl?(d=!0,c[xn].delete(l),!0):(x("h",h),Reflect.has(m,h)),getOwnPropertyDescriptor:(m,h)=>(x("o",h),Reflect.getOwnPropertyDescriptor(m,h)),ownKeys:m=>(x(os),Reflect.ownKeys(m))};return a&&(p.set=p.deleteProperty=()=>!1),[p,c]})(s,r),i[1].p=lg(r?(l=>{let a=ji.get(l);if(!a){if(Array.isArray(l))a=Array.from(l);else{const c=Object.getOwnPropertyDescriptors(l);Object.values(c).forEach(d=>{d.configurable=!0}),a=Object.create(Co(l),c)}ji.set(l,a)}return a})(s):s,i[0]),n&&n.set(s,i)),i[1][xn]=t,i[1].c=n,i[1].p},Wl=(e,t,n,s)=>{if(Object.is(e,t))return!1;if(!gi(e)||!gi(t))return!0;const r=n.get(Gl(e));if(!r)return!0;if(s){const l=s.get(e);if(l&&l.n===t)return l.g;s.set(e,{n:t,g:!1})}let i=null;try{for(const l of r.h||[])if(i=Reflect.has(e,l)!==Reflect.has(t,l),i)return i;if(r[os]===!0){if(i=((l,a)=>{const c=Reflect.ownKeys(l),d=Reflect.ownKeys(a);return c.length!==d.length||c.some((x,p)=>x!==d[p])})(e,t),i)return i}else for(const l of r.o||[])if(i=!!Reflect.getOwnPropertyDescriptor(e,l)!=!!Reflect.getOwnPropertyDescriptor(t,l),i)return i;for(const l of r.k||[])if(i=Wl(e[l],t[l],n,s),i)return i;return i===null&&(i=!0),i}finally{s&&s.set(e,{n:t,g:i})}},ag=e=>!!Qo(e)&&Yl in e,Xl=e=>Qo(e)&&e[qo]||null,cg="h",ug="w",dg="o",xg="k",wo=e=>typeof e=="object"&&e!==null,ql=(e,t)=>{if(!wo(e))return e;const n=Xl(e);return n!==null?(ag(e),n):(t.has(e)||(t.add(e),Object.entries(e).forEach(([s,r])=>{const i=ql(r,t);Object.is(i,r)||(e[s]=i)})),e)},bo=(e,t,n)=>{var s,r,i;if(!wo(e)||!wo(t))return;const l=n.get(Xl(t)||t);l&&((s=l[cg])==null||s.forEach(a=>{Reflect.has(e,a)}),l[ug]===!0&&Reflect.ownKeys(e),(r=l[dg])==null||r.forEach(a=>{Reflect.getOwnPropertyDescriptor(e,a)}),(i=l[xg])==null||i.forEach(a=>{bo(e[a],t[a],n)}))},to="o",no="r",so="a";function pg(e,t){var n;let s=0;const r=(n=t?.size)!=null?n:1,i=[],l=t!=null&&t.noWeakMap?null:new WeakMap;return c=>{const d=l?.get(c);if(d)return d[no];for(let g=0;g<r;g+=1){const E=i[(s+g)%r];if(!E)break;if(!Wl(E[to],c,E[so],new WeakMap))return bo(c,E[to],E[so]),l?.set(c,E),E[no]}const x=new WeakMap,p=Ul(c,x),m=ql(e(p),new Set);bo(c,c,x);const h={[to]:c,[no]:m,[so]:x};return s=(s-1+r)%r,i[s]=h,l?.set(c,h),m}}const mg=(e,t)=>u.S.RUNTIME==="browser"?pg(e,t):e,It=(e,t)=>{j.useEffect(()=>{const n=new AbortController,s=n.signal,i=(async()=>(await u.dr(),await e(s)))().catch(console.error);return()=>{n.abort(),i.then(l=>l?.()).catch(console.error)}},t)},Ls=()=>{const e=j.useRef([]),t=j.useMemo(()=>({cleanup:()=>{e.current.forEach(n=>n()),e.current=[]},set:n=>{n!=null&&e.current.push(...P.t.toArray(n))}}),[]);return j.useEffect(()=>t.cleanup,[t.cleanup]),t},fg=Object.freeze(Object.defineProperty({__proto__:null,Access:f.Access,Acquire:f.Acquire,Add:f.Add,Align:f.Align,Analyze:f.Analyze,Annotate:f.Annotate,Array:f.Array,Arrow:f.Arrow,Attachment:f.Attachment,Auto:f.Auto,AutoFitWidth:f.AutoFitWidth,Binary:f.Binary,Bolt:f.Bolt,Box:f.Box$1,Bridge:f.Bridge,CSV:f.CSV,Calculation:f.Calculation,Calendar:f.Calendar$1,Caret:f.Caret,Channel:f.Channel,Check:f.Check,Circle:f.Circle,Click:f.Click,Close:f.Close,Cluster:f.Cluster,Commit:f.Commit,Concepts:f.Concepts,Connect:f.Connect,Constant:f.Constant,Control:f.Control,Copy:f.Copy,Decimal:f.Decimal,Delete:f.Delete,Details:f.Details,Device:f.Device,Disable:f.Disable,Disconnect:f.Disconnect,Download:f.Download,Downsample:f.Downsample,Drag:f.Drag,Dynamic:f.Dynamic,Edit:f.Edit,EditOff:f.EditOff,Enable:f.Enable,Expand:f.Expand,Explore:f.Explore,Export:f.Export,Feedback:f.Feedback,Filter:f.Filter,Focus:f.Focus,Function:f.Function,Group:f.Group,Guide:f.Guide,Hardware:f.Hardware,Heart:f.Heart,Hidden:f.Hidden,Import:f.Import,Index:f.Index,Info:f.Info,JSON:f.JSON,Keyboard:f.Keyboard,Label:f.Label,LinePlot:f.LinePlot,Linear:f.Linear,Link:f.Link,LinkExternal:f.LinkExternal,Loading:f.Loading,Log:f.Log,Logo:f.Logo,Map:f.Map,Menu:f.Menu$1,MoveToMainWindow:f.MoveToMainWindow,NPM:f.NPM,Node:f.Node,None:f.None,OpenExternal:f.OpenExternal,OpenInNewWindow:f.OpenInNewWindow,PNPM:f.PNPM,Pan:f.Pan,Pause:f.Pause,Play:f.Play,Python:f.Python,QuestionMark:f.QuestionMark,Rack:f.Rack,Range:f.Range,Reference:f.Reference,Refresh:f.Refresh,Release:f.Release,Rename:f.Rename,Resources:f.Resources,Rotate:f.Rotate,Rule:f.Rule,Save:f.Save,Schematic:f.Schematic,Search:f.Search,Selection:f.Selection,Settings:f.Settings,Snapshot:f.Snapshot,Snooze:f.Snooze,Sound:f.Sound,SplitX:f.SplitX,SplitY:f.SplitY,StarFilled:f.StarFilled,StarOutlined:f.StarOutlined,String:f.String,StrokeWidth:f.StrokeWidth,Subtract:f.Subtract,Sync:f.Sync,Table:f.Table,Tare:f.Tare,Task:f.Task,Terminal:f.Terminal,Text:f.Text$3,TextAlign:f.TextAlign,Time:f.Time$1,Tooltip:f.Tooltip,Type:f.Type,TypeScript:f.TypeScript,Units:f.Units,User:f.User,Value:f.Value,Variable:f.Variable,Virtual:f.Virtual,Visible:f.Visible,Visualize:f.Visualize,Warning:f.Warning,Wave:f.Wave,Workspace:f.Workspace,Yarn:f.Yarn,Zoom:f.Zoom,createComposite:f.createComposite,resolve:f.resolve,wrapSVGIcon:f.wrapSVGIcon},Symbol.toStringTag,{value:"Module"})),hg=Object.freeze(Object.defineProperty({__proto__:null,Config:f.Config,Dialog:f.Dialog$1,chooseLocation:f.chooseLocation,formatTip:f.formatTip,useConfig:f.useConfig,wrap:f.wrap},Symbol.toStringTag,{value:"Module"})),Jo=({ref:e,location:t,style:n,size:s,className:r,children:i,onDragStart:l,sizeUnits:a="px",showHandle:c=!0,...d})=>{const x=u.K$1.construct(t),p=u.K$1.direction(x),m=u.p.dimension(p);return o.jsxRuntimeExports.jsxs(f.Box,{className:u.CSS(u.CSS.B("resize"),u.CSS.loc(x),r),style:{[m]:`${s}${a}`,...n},ref:e,direction:p,empty:!0,...d,children:[i,c&&o.jsxRuntimeExports.jsx("div",{draggable:!0,className:u.CSS(u.CSS.BE("resize","handle"),u.CSS.bordered(u.K$1.swap(x))),onDragStart:l,onDrag:f.preventDefault,onDragEnd:f.preventDefault})]})},Ql=({onResize:e,count:t,initialSizes:n=[],minSize:s=100,direction:r="x"})=>{const i=j.useRef(null),[l,a]=j.useState({sizeDistribution:gg(n,t),root:null}),c=j.useCallback((p,m,h)=>{if(i.current==null)return;const g=u.Ho.dim(u.Ho.construct(i.current),r);a(E=>ro(E,g,p,s,m,h))},[s,a,r]);j.useEffect(()=>e?.(l.sizeDistribution),[l.sizeDistribution,e]);const d=j.useCallback((p,m)=>{p.preventDefault();const h=r==="x"?"clientX":"clientY",g=S=>c(m,S[h]),E=()=>{a(S=>({...S,root:null})),document.removeEventListener("mousemove",g)};a(S=>({...S,root:p[h]})),document.addEventListener("mousemove",g),document.addEventListener("mouseup",E,{once:!0})},[a,r,ro]);return{setSize:j.useCallback((p,m)=>c(p,void 0,m),[ro]),props:{direction:r,sizeDistribution:l.sizeDistribution,onDragHandle:d,ref:i}}},Jl=({ref:e,direction:t="x",children:n,sizeDistribution:s,onDragHandle:r,className:i,...l})=>{const a=u.p.construct(t),c=j.Children.toArray(n);return s=jg(s),o.jsxRuntimeExports.jsx(f.Box,{...l,ref:e,direction:a,className:u.CSS(u.CSS.B("resize-multiple"),i),empty:!0,grow:!0,children:c.map((d,x)=>o.jsxRuntimeExports.jsx(Jo,{onDragStart:p=>r(p,x),location:u.p.location(a),size:s[x]*100,sizeUnits:"%",showHandle:x!==c.length-1,children:d},x))})},gg=(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)},oo=.001,jg=e=>e.every(t=>u.or.closeTo(t,1/e.length),oo)?e.map((t,n)=>n%2===0?t+oo:n===e.length-1?t:t-oo):e,ro=(e,t,n,s,r,i)=>{const l=ea(e,t,n,r,i),[a,c]=Eg(e.sizeDistribution,n,l,s/t),d=c?r??null:e.root;return{...e,sizeDistribution:a,root:d}},ea=(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},Eg=(e,t,n,s)=>{let r=t;for(;r>0&&e[r]+n<=s;)r--;const i=e[r]+n,l=yg(r,e,s,n),a=e[l]-n;return i<s||a<s?[e,!1]:[e.map((c,d)=>d===r?i:d===l?a:c),!0]},yg=(e,t,n,s)=>(e===t.length-1?Rg:Sg)(e,t,n,s),Sg=(e,t,n,s)=>{let r=e+1;for(;r<t.length-1&&t[r]-s<=n;)r++;return r},Rg=(e,t,n,s)=>{let r=e-1;for(;r>0&&t[r]-s<=n;)r--;return r},io=2,Cg=100,ta=({onCollapse:e,onResize:t,location:n="left",minSize:s,maxSize:r,initialSize:i=200,collapseThreshold:l=1/0,className:a,...c})=>{const[d,x]=j.useState(u.R(i,s,r)),p=j.useRef(null),m=u.K$1.construct(n),h=j.useCallback(y=>{if(p.current===null)return 0;const C=u.Ho.dim(y,u.K$1.direction(m),!0)*(1-2*Number(["bottom","right"].includes(m))),_=p.current+C,M=u.R(_,s,r);return(M-_)/(s??Cg)>l?io:M},[m,s,r,l]),g=j.useRef(null),E=j.useCallback(y=>{const C=h(y);x(C),g.current!=null&&t?.(C,u.Ho.construct(g.current))},[t,h]),S=j.useCallback(()=>x(y=>(p.current=y,y)),[x]),R=j.useCallback(y=>h(y)===io&&e?.(),[e,h]);j.useEffect(()=>{s==null||r==null||x(y=>{const C=u.R(y,s,r);return p.current=C,C})},[s,r]);const v=Pe.useCursorDrag({onMove:E,onStart:S,onEnd:R});return o.jsxRuntimeExports.jsx(Jo,{ref:g,location:m,size:d,onDragStart:v,className:u.clsx(a,u.CSS.expanded(d!==io)),...c})},wg=Object.freeze(Object.defineProperty({__proto__:null,Core:Jo,Multiple:Jl,Single:ta,calculateDiffPercentage:ea,useMultiple:Ql},Symbol.toStringTag,{value:"Module"})),er=({aetherKey:e,enabled:t=!0})=>{const{setState:n}=f.useLifecycle({aetherKey:e,type:P.Eraser.TYPE,schema:P.eraserStateZ,initialState:{region:u.Ho.ZERO,enabled:t}}),s=f.useSyncedRef(t);return{erase:j.useCallback(i=>{n({enabled:s.current,region:i})},[n,s])}},bg=({aetherKey:e,children:t})=>{const{erase:n}=er({aetherKey:e}),s=f.useResize(n);return o.jsxRuntimeExports.jsx("div",{ref:s,className:u.CSS(u.CSS.inheritDims()),children:t})},vg=Object.freeze(Object.defineProperty({__proto__:null,Eraser:bg,use:er},Symbol.toStringTag,{value:"Module"})),_g=({items:e,initialKey:t})=>{const[n,s]=j.useState(t),r=l=>s(l===n?void 0:l),i=e.find(l=>l.key===n);return{onSelect:r,activeItem:i}},kg=({activeItem:e,children:t,onSelect:n,location:s="left",collapseThreshold:r=.65,className:i,onResize:l,onCollapse:a,eraseEnabled:c,...d})=>{const x=u.K$1.direction(s);c??=e!=null;const p=j.useCallback(()=>{a?a():e!=null&&n?.(e.key)},[n,e?.key,a]),{erase:m}=er({enabled:c}),h=j.useCallback((v,y)=>{l?.(v,y),m(y)},[l,m]),{content:g,minSize:E,maxSize:S,initialSize:R=0}=e??{};return o.jsxRuntimeExports.jsx(ta,{className:u.CSS(u.CSS.B("nav-drawer"),u.CSS.dir(x),u.CSS.visible(e!=null),i),collapseThreshold:r,onCollapse:p,location:s,onResize:h,minSize:E,maxSize:S,initialSize:R,...d,children:g})},Lg=Object.freeze(Object.defineProperty({__proto__:null,Bar:f.Bar,Drawer:kg,useDrawer:_g},Symbol.toStringTag,{value:"Module"})),tr={info:"var(--pluto-text-color)",error:"var(--pluto-error-z)",warning:"var(--pluto-warning-m1)",success:"var(--pluto-primary-z)",loading:"var(--pluto-text-color)",disabled:"var(--pluto-gray-l8)"},nr=({variant:e,...t})=>e==="loading"?o.jsxRuntimeExports.jsx(f.Loading,{...t}):o.jsxRuntimeExports.jsx(f.Circle,{color:e!=null?tr[e]:void 0,...t}),Mg=({action:e})=>j.isValidElement(e)?e:j.createElement(f.Button,{...e,key:e.key,size:"tiny"}),Ng=({status:{key:e,time:t,count:n,message:s,description:r,variant:i},silence:l,actions:a,className:c,children:d,...x})=>{const p=j.useRef(null);return o.jsxRuntimeExports.jsxs(f.Box,{className:u.CSS(u.CSS.B("notification"),c),y:!0,empty:!0,ref:p,...x,children:[o.jsxRuntimeExports.jsxs(f.Box,{x:!0,justify:"between",grow:!0,style:{width:"100%"},children:[o.jsxRuntimeExports.jsxs(f.Box,{x:!0,align:"center",gap:"small",children:[o.jsxRuntimeExports.jsx(nr,{style:{height:"2.25rem",width:"2.5rem"},variant:i}),o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:`x${n}`}),o.jsxRuntimeExports.jsx(f.DateTime,{className:u.CSS(u.CSS.BE("notification","time")),level:"small",format:"time",children:t})]}),o.jsxRuntimeExports.jsx(f.Button,{className:u.CSS(u.CSS.BE("notification","silence")),variant:"outlined",size:"small",onClick:()=>l(e),children:o.jsxRuntimeExports.jsx(f.Close,{})})]}),o.jsxRuntimeExports.jsxs(f.Box,{y:!0,align:"start",className:u.CSS(u.CSS.BE("notification","content")),gap:"small",children:[d??o.jsxRuntimeExports.jsx(f.Text,{className:u.CSS(u.CSS.BE("notification","message")),style:{flexGrow:1},children:s}),r!=null&&o.jsxRuntimeExports.jsx(f.Text,{className:u.CSS(u.CSS.BE("notification","description")),level:"small",style:{flexGrow:1},children:r})]}),a!=null&&o.jsxRuntimeExports.jsx(f.Box,{x:!0,align:"center",justify:"end",className:u.CSS(u.CSS.BE("notification","actions")),children:P.t.toArray(a).map(m=>o.jsxRuntimeExports.jsx(Mg,{action:m},m.key))})]},t.toString())},Pg=Object.freeze(Object.defineProperty({__proto__:null,Aggregator:f.Aggregator,Indicator:nr,Notification:Ng,Summary:f.Summary,VARIANT_COLORS:tr,useAdder:f.useAdder,useAsyncErrorHandler:f.useAsyncErrorHandler,useErrorHandler:f.useErrorHandler,useNotifications:f.useNotifications},Symbol.toStringTag,{value:"Module"})),na=e=>e==="preview"?"connected":e,sa=e=>e==="preview"?"preview":void 0,Ms=({resourceName:e,value:t,onChange:n,data:s,getItem:r,subscribe:i,haulType:l,icon:a,disabled:c,onSearch:d,emptyContent:x,status:p,onFetchMore:m,children:h,renderTag:g,actions:E,allowNone:S,replaceOnSingle:R,triggerProps:v,virtual:y=!0,dialogProps:C,variant:_="connected",...M})=>o.jsxRuntimeExports.jsx(f.Frame,{variant:na(_),...M,children:o.jsxRuntimeExports.jsxs(f.Frame$1,{multiple:!0,value:t,onChange:n,data:s,getItem:r,subscribe:i,onFetchMore:m,allowNone:S,replaceOnSingle:R,virtual:y,children:[o.jsxRuntimeExports.jsx(ra,{haulType:l,icon:a,placeholder:`Select ${e}s`,disabled:c,variant:sa(_),...v,children:g}),o.jsxRuntimeExports.jsx(f.Dialog$2,{onSearch:d,emptyContent:x,status:p,actions:E,resourceName:e,...C,children:h})]})}),Xe=(e,t)=>{const n={};t.forEach(r=>n[r]=void 0);const s=r=>{const{...i}={...r,...n};return o.jsxRuntimeExports.jsx(e,{...i})};return s.displayName=`RemoveProps(${e.displayName})`,s},oa=e=>o.jsxRuntimeExports.jsxs(pe.Buttons,{...e,keys:P.SIZES,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"tiny",children:"L"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"small",children:"M"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"medium",children:"L"})]}),Tg=Object.freeze(Object.defineProperty({__proto__:null,SIZES:P.SIZES,SelectSize:oa,isRenderProp:f.isRenderProp,isSize:P.isSize,removeProps:Xe,renderProp:f.renderProp,size:P.size},Symbol.toStringTag,{value:"Module"})),Ns=({children:e="",size:t="medium",color:n,icon:s,onClose:r,className:i,onDragStart:l,...a})=>{const c=u.cr.cssString(n);s==null&&n!=null&&(s=o.jsxRuntimeExports.jsx(f.Circle,{color:c}));const d=r==null?void 0:o.jsxRuntimeExports.jsx(f.Button,{"aria-label":"close",size:t==="tiny"?"small":t,variant:"text",className:u.CSS.BE("tag","close"),sharp:!0,onClick:x=>{x.stopPropagation(),r()},children:o.jsxRuntimeExports.jsx(f.Close,{})});return o.jsxRuntimeExports.jsxs(f.Button,{el:"div",className:u.CSS(i,u.CSS.B("tag"),r!=null&&u.CSS.BM("tag","closeable")),size:t,overflow:"nowrap",align:"center",gap:"small",onDragStart:l,...a,children:[s,d,e]})},sr=({children:e,onClick:t,variant:n="outlined",size:s="medium",...r})=>o.jsxRuntimeExports.jsx(f.Button,{el:"div",variant:n,size:s,x:!0,onClick:t,align:"center",gap:"small",style:{padding:"0rem 0.5rem",paddingRight:"2rem"},rounded:!0,...r,children:e}),Ig=Object.freeze(Object.defineProperty({__proto__:null,Tag:Ns,Tags:sr},Symbol.toStringTag,{value:"Module"})),Og=({itemKey:e,icon:t,onDragStart:n})=>{const s=f.useItem(e),{onSelect:r}=f.useItemState(e);return o.jsxRuntimeExports.jsx(Ns,{onClose:r,onDragStart:()=>n(e),draggable:!0,size:"small",status:s==null?"error":void 0,icon:s?.icon??t,children:s?.name??e})},Ag=f.renderProp(Og),or=({items:e},t,n,s)=>{if(t===""||s===!0)return!1;const r=f.filterByType(t,e);return r.length>0&&!r.every(i=>n.includes(i.key))},ra=({haulType:e="",disabled:t,placeholder:n="Select...",variant:s="outlined",icon:r,children:i=Ag})=>{const l=f.useSelection(),a=f.useSyncedRef(l),{setSelected:c}=f.useContext$3(),{toggle:d,visible:x}=f.useContext$2(),p=j.useCallback(v=>or(v,e,P.t.toArray(l),t),[e,l,t]),{startDrag:m,...h}=f.useDragAndDrop({type:e,canDrop:p,onDrop:f.useFilterByTypeCallback(e,({items:v})=>{const y=P.t.toArray(a.current);return c(u.c.unique([...P.t.toArray(y),...v.map(C=>C.key)])),v},[c])}),g=j.useCallback(({dropped:v})=>{const y=l.filter(C=>!v.some(_=>_.key===C));c(y)},[c,l]),E=j.useCallback(v=>{m([{key:v,type:e}],g)},[m,g,e]),S=f.useDraggingState(),R=s==="text"&&l.length!==0;return o.jsxRuntimeExports.jsxs(sr,{full:"x",onClick:()=>{R||d()},...h,className:u.CSS(u.CSS.dropRegion(p(S)),u.CSS.BE("dialog","trigger"),u.CSS.BM("variant",s)),variant:s,preventClick:R,grow:!0,children:[l.length===0&&o.jsxRuntimeExports.jsxs(f.Text,{color:8,weight:400,style:{padding:"0 1rem"},children:[r,n]}),l.map(v=>i({key:v,itemKey:v,onDragStart:E,icon:r})),s!=="text"&&o.jsxRuntimeExports.jsx($l.Animated,{className:u.CSS.level("p"),enabled:x,enabledLoc:"bottom",disabledLoc:"left",color:8}),R&&o.jsxRuntimeExports.jsx(f.Button,{variant:s,onClick:v=>{v.stopPropagation(),d()},children:o.jsxRuntimeExports.jsx(f.Add,{color:8})})]})},Ot=({resourceName:e,onChange:t,value:n,allowNone:s,emptyContent:r,haulType:i,data:l,getItem:a,subscribe:c,itemHeight:d,onFetchMore:x,disabled:p,onSearch:m,status:h,icon:g,children:E,variant:S="connected",actions:R,dialogProps:v,triggerProps:y,virtual:C=!0,closeDialogOnSelect:_=!0,...M})=>o.jsxRuntimeExports.jsx(f.Frame,{...M,variant:na(S),children:o.jsxRuntimeExports.jsxs(f.Frame$1,{value:n,onChange:t,data:l,getItem:a,subscribe:c,allowNone:s,onFetchMore:x,itemHeight:d,virtual:C,closeDialogOnSelect:_,children:[o.jsxRuntimeExports.jsx(ia,{haulType:i,icon:g,placeholder:`Select a ${e}`,disabled:p,variant:sa(S),...y}),o.jsxRuntimeExports.jsx(f.Dialog$2,{onSearch:m,resourceName:e,emptyContent:r,status:h,actions:R,...v,children:E})]})}),ia=({haulType:e="",placeholder:t,icon:n,disabled:s,iconOnly:r=!1,hideCaret:i=!1,...l})=>{const a=f.useSelection(),{setSelected:c}=f.useContext$3(),[d]=a,x=f.useItem(d),{name:p,icon:m}=x??{},h=j.useCallback(S=>or(S,e,a,s),[e,a,s]),g=f.useDrop({type:e,canDrop:h,onDrop:f.useFilterByTypeCallback(e,({items:S})=>(S.length!==0&&c([S[0].key]),S),[c])}),E=f.useDraggingState();return o.jsxRuntimeExports.jsxs(Fl.Trigger,{variant:"outlined",gap:"small",className:u.CSS(u.CSS.dropRegion(h(E))),disabled:s,...g,...l,hideCaret:i||r,textColor:p==null?8:void 0,children:[m??n,!r&&(p??t)]})},Dg=f.renderProp(e=>{const{itemKey:t}=e,n=f.useItem(t);if(n==null)return null;const{name:s,icon:r}=n;return o.jsxRuntimeExports.jsxs(f.ListItem,{...e,children:[r,s]})}),Pn=({data:e,filter:t,children:n=Dg,virtual:s=!1,...r})=>{const{retrieve:i,...l}=f.useStaticData({data:e,filter:t}),{search:a}=nt.usePager({retrieve:i});return o.jsxRuntimeExports.jsx(Ot,{...r,...l,onSearch:a,virtual:s,children:n})},on=e=>o.jsxRuntimeExports.jsxs(pe.Buttons,{...e,keys:P.LEVELS,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"h2",square:!0,children:"XL"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"h3",square:!0,children:"L"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"h4",square:!0,children:"M"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"h5",square:!0,children:"S"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"small",square:!0,children:"XS"})]}),Bg=[250,400,500,600],la=e=>o.jsxRuntimeExports.jsxs(pe.Buttons,{...e,keys:Bg,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:250,children:"Light"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:400,children:"Normal"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:500,children:"Medium"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:600,children:"Bold"})]}),$g=Object.freeze(Object.defineProperty({__proto__:null,Level:on,Weight:la},Symbol.toStringTag,{value:"Module"})),zg=Object.freeze(Object.defineProperty({__proto__:null,Button:pe.Button,Buttons:pe.Buttons,Core:f.Core,Dialog:f.Dialog$2,Frame:f.Frame$1,ListItem:f.ListItem,Multiple:Ms,MultipleTrigger:ra,Single:Ot,SingleTrigger:ia,Static:Pn,Text:$g,staticCanDrop:or,useClear:f.useClear,useContext:f.useContext$3,useHover:f.useHover,useItemState:f.useItemState,useMultiple:f.useMultiple,useSelection:f.useSelection,useSingle:f.useSingle},Symbol.toStringTag,{value:"Module"})),Vg=()=>o.jsxRuntimeExports.jsx(f.Caret.Right,{className:u.CSS.BE("breadcrumb","separator")}),Rn=({children:e,...t})=>o.jsxRuntimeExports.jsx(f.Text,{className:u.CSS.BE("breadcrumb","segment"),...t,defaultEl:"span",children:e}),rr=({children:e,highlightVariant:t,...n})=>o.jsxRuntimeExports.jsx(f.Text,{className:u.CSS(u.CSS.B("breadcrumb"),t!=null&&u.CSS.BM("breadcrumb","highlight",t)),x:!0,align:"center",gap:"small",...n,children:j.Children.map(e,(s,r)=>s==null||typeof s=="boolean"?null:o.jsxRuntimeExports.jsxs(j.Fragment,{children:[r>0&&o.jsxRuntimeExports.jsx(Vg,{}),typeof s=="string"?o.jsxRuntimeExports.jsx(Rn,{children:s}):s]},r))}),Fg=(e,t)=>{const n=e.split("/");return n.map((s,r)=>t({href:n.slice(0,r+1).join("/"),segment:s,index:r}))},Hg=Object.freeze(Object.defineProperty({__proto__:null,Breadcrumb:rr,Segment:Rn,mapURLSegments:Fg},Symbol.toStringTag,{value:"Module"})),Zg=({channelKey:e,rangeKey:t,shadow:n,className:s,...r})=>{const{value:i,onChange:l}=r,[a,c]=j.useState(!1),{update:d}=Ja.useDirect({params:{rangeKey:t,channelKey:e}}),{data:x}=Rr.useDirect({params:{key:e,rangeKey:t}}),p=async C=>{d(C)},m=x?.alias,h=x?.alias??x?.name;let g=o.jsxRuntimeExports.jsx(f.Rename,{});a?g=o.jsxRuntimeExports.jsx(f.Loading,{}):m===i&&(g=o.jsxRuntimeExports.jsx(f.Check,{}));const E=p!=null&&!a&&m!==i&&e!==0,S=f.useErrorHandler(),R=()=>{E&&S(async()=>{c(!0);try{await p(i),c(!1)}catch(C){throw c(!1),C}},"Failed to set channel alias")},v=()=>{m!=null&&l?.(m)},y=e===0?o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:"Select a channel to enable alias syncing with this label"}):p==null?o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:"Select a range to enable alias syncing with this label"}):i.length===0?o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:"Enter a value to enable alias syncing with this label"}):m===i?o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:"Alias synced with this label"}):o.jsxRuntimeExports.jsxs(f.Text,{level:"small",children:["Sync alias for ",h," with this label"]});return o.jsxRuntimeExports.jsxs(f.Text$2,{selectOnFocus:!0,...r,children:[E&&o.jsxRuntimeExports.jsx(f.Button,{onClick:v,tooltip:o.jsxRuntimeExports.jsxs(f.Text,{level:"small",children:["Set ",h," as label"]}),tooltipLocation:{y:"top"},variant:"outlined",children:o.jsxRuntimeExports.jsx(f.Sync,{})}),o.jsxRuntimeExports.jsx(f.Button,{onClick:R,disabled:!E,tooltip:y,tooltipLocation:{y:"top"},variant:"outlined",children:g})]})},vt="channel";var Ei=180/Math.PI,vo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function aa(e,t,n,s,r,i){var l,a,c;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(c=e*n+t*s)&&(n-=e*c,s-=t*c),(a=Math.sqrt(n*n+s*s))&&(n/=a,s/=a,c/=a),e*s<t*n&&(e=-e,t=-t,c=-c,l=-l),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Ei,skewX:Math.atan(c)*Ei,scaleX:l,scaleY:a}}var Gn;function Kg(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?vo:aa(t.a,t.b,t.c,t.d,t.e,t.f)}function Yg(e){return e==null||(Gn||(Gn=document.createElementNS("http://www.w3.org/2000/svg","g")),Gn.setAttribute("transform",e),!(e=Gn.transform.baseVal.consolidate()))?vo:(e=e.matrix,aa(e.a,e.b,e.c,e.d,e.e,e.f))}function ca(e,t,n,s){function r(d){return d.length?d.pop()+" ":""}function i(d,x,p,m,h,g){if(d!==p||x!==m){var E=h.push("translate(",null,t,null,n);g.push({i:E-4,x:O.interpolateNumber(d,p)},{i:E-2,x:O.interpolateNumber(x,m)})}else(p||m)&&h.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:O.interpolateNumber(d,x)})):x&&p.push(r(p)+"rotate("+x+s)}function a(d,x,p,m){d!==x?m.push({i:p.push(r(p)+"skewX(",null,s)-2,x:O.interpolateNumber(d,x)}):x&&p.push(r(p)+"skewX("+x+s)}function c(d,x,p,m,h,g){if(d!==p||x!==m){var E=h.push(r(h)+"scale(",null,",",null,")");g.push({i:E-4,x:O.interpolateNumber(d,p)},{i:E-2,x:O.interpolateNumber(x,m)})}else(p!==1||m!==1)&&h.push(r(h)+"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),a(d.skewX,x.skewX,p,m),c(d.scaleX,d.scaleY,x.scaleX,x.scaleY,p,m),d=x=null,function(h){for(var g=-1,E=m.length,S;++g<E;)p[(S=m[g]).i]=S.x(h);return p.join("")}}}var Gg=ca(Kg,"px, ","px)","deg)"),Ug=ca(Yg,", ",")",")"),Wg=1e-12;function yi(e){return((e=Math.exp(e))+1/e)/2}function Xg(e){return((e=Math.exp(e))-1/e)/2}function qg(e){return((e=Math.exp(2*e))-1)/(e+1)}const rs=function e(t,n,s){function r(i,l){var a=i[0],c=i[1],d=i[2],x=l[0],p=l[1],m=l[2],h=x-a,g=p-c,E=h*h+g*g,S,R;if(E<Wg)R=Math.log(m/d)/t,S=function(I){return[a+I*h,c+I*g,d*Math.exp(t*I*R)]};else{var v=Math.sqrt(E),y=(m*m-d*d+s*E)/(2*d*n*v),C=(m*m-d*d-s*E)/(2*m*n*v),_=Math.log(Math.sqrt(y*y+1)-y),M=Math.log(Math.sqrt(C*C+1)-C);R=(M-_)/t,S=function(I){var A=I*R,B=yi(_),z=d/(n*v)*(B*qg(t*A+_)-Xg(_));return[a+z*h,c+z*g,d*B/yi(t*A+_)]}}return S.duration=R*1e3*t/Math.SQRT2,S}return r.rho=function(i){var l=Math.max(.001,+i),a=l*l,c=a*a;return e(l,a,c)},r}(Math.SQRT2,2,4),Qg=Object.freeze(Object.defineProperty({__proto__:null,Base:O.Base,Bottom:O.Bottom,Right:O.Right,Top:O.Top,axisStateZ:O.axisStateZ,newCanvas:O.newCanvas,newTickFactory:O.newTickFactory,tickFactoryProps:O.tickFactoryProps,tickType:O.tickType},Symbol.toStringTag,{value:"Module"})),Jg=Object.freeze(Object.defineProperty({__proto__:null,AcquireChannelControl:O.AcquireChannelControl,AuthoritySource:O.AuthoritySource,Chip:O.Chip,Controller:O.Controller,Indicator:O.Indicator,Legend:O.Legend,REGISTRY:O.REGISTRY$15,STATUSES:O.STATUSES,SetChannelValue:O.SetChannelValue,StateProvider:O.StateProvider,acquireChannelControl:O.acquireChannelControl,acquireChannelControlPropsZ:O.acquireChannelControlPropsZ,authoritySource:O.authoritySource,authoritySourceDetailsZ:O.authoritySourceDetailsZ,authoritySourceProps:O.authoritySourceProps,chipStateZ:O.chipStateZ,chipStatusDetailsZ:O.chipStatusDetailsZ,controllerStateZ:O.controllerStateZ,indicatorStateZ:O.indicatorStateZ,indicatorStatusDetailsZ:O.indicatorStatusDetailsZ,legendStateZ:O.legendStateZ,setChannelValue:O.setChannelValue,setChannelValuePropsZ:O.setChannelValuePropsZ,stateProviderStateZ:O.stateProviderStateZ,statusZ:O.statusZ,sugaredStateZ:O.sugaredStateZ},Symbol.toStringTag,{value:"Module"})),e1={region:u.Ho.ZERO,dpr:1,os:u.S.getOS()},t1={gl:null,lower2d:null,upper2d:null,bootstrapped:!1},n1=({children:e,resizeDebounce:t=100,className:n,...s})=>{const[{path:r},{bootstrapped:i,dpr:l},a]=f.use$2({type:O.Canvas.TYPE,schema:O.canvasStateZ,initialState:e1}),c=j.useRef({...t1}),d=j.useRef(!1),x=j.useCallback(E=>{c.current.bootstrapped&&(a(()=>({bootstrapped:!0,region:E,dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})})),d.current=!0)},[a]),p=j.useRef(null),m=f.useResize(x,{debounce:t}),h=f.useCombinedRefs(p,m);j.useEffect(()=>{const E=()=>{window.devicePixelRatio===l||!c.current.bootstrapped||p.current==null||a(S=>({...S,region:u.Ho.construct(p.current),dpr:window.devicePixelRatio}))};window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`).addEventListener("change",E,{once:!0})},[l]),j.useEffect(()=>{const E=()=>{!c.current.bootstrapped||p.current==null||a(S=>({...S,region:u.Ho.construct(p.current),glCanvas:void 0,upper2dCanvas:void 0,lower2dCanvas:void 0}))};window.addEventListener("focus",E),window.addEventListener("blur",E)},[a]);const g=j.useCallback(E=>{if(E==null)return;E.className.includes("gl")?c.current.gl=E:E.className.includes("upper2d")?c.current.upper2d=E:c.current.lower2d=E;const{gl:S,lower2d:R,upper2d:v,bootstrapped:y}=c.current;if(S==null||R==null||v==null||y)return;c.current.bootstrapped=!0;const C=S.transferControlToOffscreen(),_=v.transferControlToOffscreen(),M=R.transferControlToOffscreen();a({glCanvas:C,upper2dCanvas:_,lower2dCanvas:M,bootstrap:!0,bootstrapped:!1,region:u.Ho.construct(S),dpr:window.devicePixelRatio,os:u.S.getOS({default:"Windows"})},[C,_,M])},[a]);return o.jsxRuntimeExports.jsxs("div",{ref:h,className:u.CSS(u.CSS.B("canvas-container"),n),...s,children:[o.jsxRuntimeExports.jsx("canvas",{ref:g,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","lower2d"))}),o.jsxRuntimeExports.jsx("canvas",{ref:g,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","gl"))}),o.jsxRuntimeExports.jsx("canvas",{ref:g,className:u.CSS(u.CSS.B("canvas"),u.CSS.BM("canvas","upper2d"))}),o.jsxRuntimeExports.jsx(f.Composite,{path:r,children:i&&e})]})},Tn=(e,t)=>f.useResize(j.useCallback((n,s)=>{const r=document.querySelector(".pluto-canvas--lower2d");r!=null&&e(u.C.XY.translate(u.K.scale(u.Ho.topLeft(r),-1)).box(n),s)},[e]),t),s1=Object.freeze(Object.defineProperty({__proto__:null,Canvas:n1,useRegion:Tn},Symbol.toStringTag,{value:"Module"})),ua=j.createContext(null),ct=e=>{const t=j.use(ua);if(t==null)throw new Error(`Cannot use ${e} as a non-child of LinePlot.`);return t},da=e=>{const{addViewportHandler:t}=ct("Viewport");j.useEffect(()=>t(e),[t,e])},In=(e,t)=>{const{setGridEntry:n,removeGridEntry:s}=ct(t),{key:r}=e;return f.useEffectCompare(()=>{u.K$1.outer.parse(e.loc),n(e)},([a],[c])=>P.N.equal(a,c),[e]),j.useEffect(()=>()=>s(r),[]),{gridArea:u.p.swap(u.K$1.direction(e.loc))==="x"?`axis-start-${r} / plot-start / axis-end-${r} / plot-end`:`plot-start / axis-start-${r} / plot-end / axis-end-${r}`}},xa=({aetherKey:e,style:t,resizeDebounce:n=0,clearOverScan:s=u.K.ZERO,children:r,hold:i=!1,onHold:l,visible:a,...c})=>{const[d,x]=j.useState([]),p=f.useMemoDeepEqual({clearOverScan:s,hold:i,visible:a}),[{path:m},{grid:h},g]=f.use$2({aetherKey:e,type:O.LinePlot.TYPE,schema:O.linePlotStateZ,initialState:{container:u.Ho.ZERO,viewport:u.Ho.DECIMAL,grid:{},...p}}),E=j.useCallback(D=>{a&&g(V=>({...V,container:D}))},[g,a]),S=Tn(E,{debounce:n});j.useEffect(()=>g(D=>({...D,...p})),[p]);const R=j.useRef(new Map),v=j.useCallback(D=>(R.current.set(D,null),()=>R.current.delete(D)),[R]),y=j.useCallback(D=>{const{mode:V,box:b,stage:k}=D;(V==="pan"&&k!=="start"||V==="zoom"||V==="zoomReset"&&k==="start")&&g(L=>({...L,viewport:b})),R.current.forEach((L,N)=>N(D))},[g]),C=j.useCallback(D=>{g(V=>({...V,grid:{...V.grid,[D.key]:D}}))},[g]),_=j.useCallback(D=>g(V=>{const{[D]:b,...k}=V.grid;return{...V,grid:k}}),[g]),M=j.useCallback(D=>{x(V=>[...V.filter(({key:b})=>b!==D.key),D])},[x]),I=j.useCallback(D=>x(V=>V.filter(({key:b})=>b!==D)),[M]),A=j.useMemo(()=>o1(h),[h]),B=j.useCallback(D=>{g(V=>({...V,hold:D})),l?.(D)},[g,l]),z=`line-plot-${e}`,$=j.useMemo(()=>({lines:d,setGridEntry:C,removeGridEntry:_,setLine:M,removeLine:I,setViewport:y,addViewportHandler:v,setHold:B,id:z}),[z,d,C,_,M,I,y,v,B]);return o.jsxRuntimeExports.jsx("div",{id:z,className:u.CSS.B("line-plot"),style:{...t,...A},ref:S,...c,children:o.jsxRuntimeExports.jsx(ua,{value:$,children:o.jsxRuntimeExports.jsx(f.Composite,{path:m,children:r})})})},o1=e=>{const t=u.CSS.newGridBuilder();return O.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)"),O.regions("bottom",e).reverse().forEach(({key:n,size:s})=>t.row(`axis-start-${n}`,`axis-end-${n}`,s)),O.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)"),O.regions("right",e).forEach(({key:n,size:s})=>t.col(`axis-start-${n}`,`axis-end-${n}`,s)),t.build()},ir=e=>{const t=e==="x"?"bottom":"left",n=e==="x"?O.XAxis.TYPE:O.YAxis.TYPE,s=`${e}-axis`,r=({aetherKey:i,children:l,location:a=t,label:c="",labelLevel:d="small",labelDirection:x=e,onLabelChange:p,color:m,labelSize:h,showGrid:g,type:E,bounds:S,className:R,tickSpacing:v,autoBounds:y,axisKey:C,autoBoundUpdateInterval:_,onAutoBoundsChange:M,style:I,...A})=>{const B=(c?.length??0)>0,z=f.useUniqueKey(i),$=f.useMemoDeepEqual({location:a,showGrid:g,type:E,bounds:S,axisKey:C,label:c,labelDirection:x,tickSpacing:v,autoBounds:y,autoBoundUpdateInterval:_}),[{path:D},{size:V,labelSize:b,...k},L]=f.use$2({aetherKey:z,type:n,schema:O.coreAxisStateZ,initialState:$});j.useEffect(()=>L(K=>({...K,...$})),[$]),j.useEffect(()=>{const{lower:K,upper:Z}=O.parseAutoBounds(k.autoBounds);k.bounds!=null&&(K&&S?.lower!==k.bounds.lower||Z&&S?.upper!==k.bounds.upper)&&M?.(k.bounds)},[k.autoBounds,k.bounds]);const N=In({loc:a,key:`${n}-${z}`,size:V+b,order:1},`${e.toUpperCase()}Axis`),F=ks.useTypography(d).toString(),H=j.useRef(0);return j.useEffect(()=>{if(e==="y"){if(c==null)return;let Z=P.dimensions(c,F)[u.p.dimension(u.p.construct(x))];Z>0&&(Z+=9),L(Y=>({...Y,labelSize:Z}))}else{let Z=P.dimensions(c,F).height*1.3;Z>0&&(Z+=12);const Y=H.current;O.withinSizeThreshold(Y,Z)||(H.current=Z,L(ne=>({...ne,labelSize:Z})))}},[c,x,F]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(f.Box,{className:u.CSS(R,u.CSS.B("axis"),u.CSS.B(s),u.CSS.loc(a)),style:{...I,...N},align:"center",justify:a!=="left"?"end":"start",direction:u.p.swap(e),...A,children:B&&o.jsxRuntimeExports.jsx(f.MaybeEditable,{className:u.CSS(u.CSS.BE("axis","label"),u.CSS.dir(x)),value:c,onChange:p,level:d})}),o.jsxRuntimeExports.jsx(f.Composite,{path:D,children:l})]})};return r.displayName=`${e.toUpperCase()}Axis`,r},pa=ir("x"),ma=ir("y"),r1=u.K.xy.extend({root:u.K$1.corner,units:te.z.object({x:te.z.enum(["px","decimal"]),y:te.z.enum(["px","decimal"])})}),i1=r1.partial({root:!0,units:!0}),l1=e=>{const t={};return t[e.root?.x??"left"]=e?.units?.x==="px"?`${e.x}px`:`${e.x*100}%`,t[e.root?.y??"top"]=e?.units?.y==="px"?`${e.y}px`:`${e.y*100}%`,t},a1=(e,t)=>{const n={x:e.x,y:e.y};if(t.current==null)return n;const s=u.Ho.construct(t.current),r=u.Ho.construct(t.current.parentElement);return e.units?.x==="decimal"?e.root?.x==="right"&&(n.x=1-e.x):e.root?.x==="right"?n.x=1-(e.x+u.Ho.width(s))/u.Ho.width(r):n.x/=u.Ho.width(r),e.units?.y==="decimal"?e.root?.y==="bottom"&&(n.y=1-e.y):e.root?.y==="bottom"?n.y=1-(e.y+u.Ho.height(s))/u.Ho.height(r):n.y/=u.Ho.height(r),n},c1=(e,t)=>{if(t.current==null)return null;const n=u.Ho.construct(t.current.parentElement),s=u.Ho.construct(t.current),r={x:e.x,y:e.y,root:{...u.K$1.TOP_LEFT},units:{x:"px",y:"px"}};return e.x>.8?(r.x=(1-e.x)*u.Ho.width(n)-u.Ho.width(s),r.root.x="right"):e.x<.2?r.x=e.x*u.Ho.width(n):r.units.x="decimal",e.y>.8?(r.y=(1-e.y)*u.Ho.height(n)-u.Ho.height(s),r.root.y="bottom"):e.y<.2?r.y=e.y*u.Ho.height(n):r.units.y="decimal",r.x=Math.round(r.x*100)/100,{...r,...u.K.truncate(r,3)}},Si=u.Ho.reRoot(u.Ho.DECIMAL,u.K$1.TOP_LEFT),u1={x:.1,y:.1,root:u.K$1.TOP_LEFT,units:{x:"decimal",y:"decimal"}},Ps=j.memo(({className:e,value:t,onChange:n,style:s,draggable:r=!0,initial:i=u1,...l})=>{const[a,c]=P.usePurePassthrough({value:t,onChange:n,initial:i}),d=j.useRef(a),x=f.useSyncedRef(r===!1),p=j.useRef(null);a!==null&&(s={...s,...l1(a)});const m=j.useCallback(g=>{if(p.current?.parentElement==null)return d.current;const E=u.Ho.construct(p.current.parentElement),S=u.C.XY.scale(E).scale(Si),R=S.box(u.Ho.construct(p.current)),v=u.C.XY.clamp(u.Ho.construct(u.Ho.topLeft(Si),{width:1-u.Ho.width(R),height:1-u.Ho.height(R)})),y=u.K.translate(u.K.construct(d.current),u.Ho.signedDims(S.box(g))),C=v.pos(y);return c1(C,p)},[]),h=Pe.useCursorDrag({onStart:j.useCallback(()=>{d.current=a1(d.current,p)},[]),onMove:j.useCallback(g=>{if(x.current)return;const E=m(g);E!==null&&c(E)},[]),onEnd:j.useCallback(g=>{if(x.current)return;const E=m(g);E!==null&&(d.current=E)},[])});return o.jsxRuntimeExports.jsx(f.Box,{className:u.CSS(e,u.CSS.B("legend")),bordered:!0,style:s,onDragStart:h,draggable:r,borderColor:5,ref:p,onDrag:f.preventDefault,onDragEnd:f.preventDefault,background:1,rounded:1,...l})});Ps.displayName="Legend.Container";const On=j.memo(({data:e,allowVisibleChange:t=!0,background:n=1,entryProps:s,...r})=>o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:e.sort((i,l)=>i.label.localeCompare(l.label)).map(({key:i,visible:l=!0,...a})=>o.jsxRuntimeExports.jsx(d1,{entry:{key:i,visible:l,...a},allowVisibleChange:t,background:n,...s,...r},i))}));On.displayName="Legend.Entries";const d1=({allowVisibleChange:e=!0,entry:t,onEntryChange:n,colorPickerVisible:s,onColorPickerVisibleChange:r,className:i,background:l,...a})=>{const{color:c,key:d,label:x,visible:p}=t;return o.jsxRuntimeExports.jsxs(f.Box,{align:"center",className:u.CSS(u.CSS.B("legend-entry"),i),gap:"small",x:!0,...a,children:[o.jsxRuntimeExports.jsxs(f.Box,{align:"center",gap:"small",x:!0,children:[o.jsxRuntimeExports.jsx(Pe.Swatch,{allowChange:n!=null,draggable:!1,onChange:m=>n?.({...t,color:m}),size:"tiny",value:c,onVisibleChange:r}),o.jsxRuntimeExports.jsx(f.MaybeEditable,{color:t.visible?10:7,level:"small",onChange:m=>n?.({...t,label:m}),onDoubleClick:f.stopPropagation,overflow:"nowrap",value:x})]}),e&&o.jsxRuntimeExports.jsx(f.Button,{className:u.CSS.B("visible-toggle"),contrast:l,onClick:m=>{m.stopPropagation(),n?.({...t,visible:!p})},onDoubleClick:f.stopPropagation,size:"tiny",variant:"text",children:p?o.jsxRuntimeExports.jsx(f.Visible,{}):o.jsxRuntimeExports.jsx(f.Hidden,{})})]},d)},fa=({data:e,background:t=1,allowVisibleChange:n=!0,onEntryChange:s,position:r,onPositionChange:i,...l})=>{const[a,c]=j.useState(!1);return e.length===0?null:o.jsxRuntimeExports.jsx(Ps,{...l,draggable:!a,value:r,onChange:i,gap:"small",background:t,className:u.CSS.B("legend-grouped"),children:e.map(({key:d,name:x,data:p},m)=>o.jsxRuntimeExports.jsxs(j.Fragment,{children:[o.jsxRuntimeExports.jsx(f.Text,{level:"small",color:9,weight:500,className:u.CSS.B("legend-name"),children:x}),o.jsxRuntimeExports.jsx(f.Box,{y:!0,grow:!0,className:u.CSS.B("legend-entries"),empty:!0,children:o.jsxRuntimeExports.jsx(On,{data:p,onEntryChange:s,colorPickerVisible:a,onColorPickerVisibleChange:c,allowVisibleChange:n,background:t,entryProps:x1})}),m!==e.length-1&&o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("legend-divider")})]},d))})},x1={justify:"between",grow:!0},lr=({data:e=[],onEntryChange:t,position:n,onPositionChange:s,allowVisibleChange:r=!0,background:i=1,...l})=>{const[a,c]=j.useState(!1);return e.length===0?null:o.jsxRuntimeExports.jsx(Ps,{...l,draggable:!a,value:n,onChange:s,background:i,empty:!0,children:o.jsxRuntimeExports.jsx(On,{data:e,onEntryChange:t,colorPickerVisible:a,onColorPickerVisibleChange:c,allowVisibleChange:r,background:i,entryProps:p1})})},p1={justify:"between",grow:!0},m1=Object.freeze(Object.defineProperty({__proto__:null,Container:Ps,Grouped:fa,Simple:lr,stickyXYz:i1},Symbol.toStringTag,{value:"Module"})),ha=({variant:e="floating",...t})=>e==="floating"?o.jsxRuntimeExports.jsx(ga,{...t}):o.jsxRuntimeExports.jsx(f1,{...t}),ga=j.memo(({onLineChange:e,...t})=>{const{lines:n}=ct("FloatingLegend"),s=ja(n);return s.length===1?o.jsxRuntimeExports.jsx(lr,{data:s[0].data,onEntryChange:e,...t}):o.jsxRuntimeExports.jsx(fa,{data:s,onEntryChange:e,...t})});ga.displayName="LinePlot.FloatingLegend";const ja=e=>j.useMemo(()=>{const n={};for(const r of e){const i=n[r.legendGroup];i!=null?i.push(r):n[r.legendGroup]=[r]}const s=Object.entries(n).map(([r,i])=>({key:r,name:r,data:i}));return s.sort((r,i)=>r.name.localeCompare(i.name)),s},[e]),f1=({onLineChange:e})=>{const{lines:t}=ct("FixedLegend"),n=ja(t),s=f.useUniqueKey(),r=In({key:s,size:t.length>0?36:0,loc:"top",order:5},"Legend");return n.length===0?null:n.length===1?o.jsxRuntimeExports.jsx(f.Box,{align:"center",justify:"start",x:!0,style:r,children:o.jsxRuntimeExports.jsx(On,{data:n[0].data,onEntryChange:e,background:0})}):o.jsxRuntimeExports.jsxs(f.Box,{align:"center",justify:"start",x:!0,style:r,gap:"huge",children:[o.jsxRuntimeExports.jsx(Ri,{name:"Y1",data:n[0].data,onLineChange:e}),o.jsxRuntimeExports.jsx(Ri,{name:"Y2",data:n[1].data,onLineChange:e})]})},Ri=({name:e,data:t,onLineChange:n})=>o.jsxRuntimeExports.jsxs(f.Box,{x:!0,children:[o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:e}),o.jsxRuntimeExports.jsx(On,{data:t,onEntryChange:n,background:0})]}),ar=j.memo(({aetherKey:e,...t})=>(f.useUnidirectional({aetherKey:e,type:O.Line.TYPE,schema:O.stateZ,state:t}),null));ar.displayName="Line";const h1=Object.freeze(Object.defineProperty({__proto__:null,Line:ar},Symbol.toStringTag,{value:"Module"})),cr=({aetherKey:e,color:t,label:n="",legendGroup:s,visible:r=!0,...i})=>{const l=f.useUniqueKey(e),{setLine:a,removeLine:c}=ct("Line");return j.useEffect(()=>(a({key:l,color:t,label:n,visible:r,legendGroup:s}),()=>c(l)),[n,t,r,s]),o.jsxRuntimeExports.jsx(ar,{aetherKey:l,color:t,label:n,visible:r,...i})},Ea=({level:e="h2",...t})=>{const n=f.useUniqueKey(),s=ks.useTypography(e),r=In({key:n,size:(s.lineHeight+2)*s.baseSize,loc:"top",order:10},"Title");return o.jsxRuntimeExports.jsx(f.Box,{justify:"center",align:"center",style:r,children:o.jsxRuntimeExports.jsx(f.MaybeEditable,{...t,level:e})})},ya=({aetherKey:e,...t})=>{const n=f.useUniqueKey(e),[,,s]=f.use$2({aetherKey:n,type:O.Tooltip.TYPE,schema:O.tooltipStateZ,initialState:{position:null,...t}}),r=j.useRef(null),i=j.useCallback(a=>{const c=document.querySelector(".pluto-canvas-container");if(c==null)return;const d=u.Ho.topLeft(c);s({position:u.K.translation(d,u.K.construct(a))})},[s]),l=j.useCallback(()=>s({position:null}),[s]);return j.useEffect(()=>{if(r.current===null)return;const a=r.current.parentElement;if(a!=null)return a.addEventListener("mousemove",i),a.addEventListener("mouseleave",l),()=>{a.removeEventListener("mousemove",i),a.removeEventListener("mouseleave",l)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:r})},g1=Object.freeze(Object.defineProperty({__proto__:null,Tooltip:ya},Symbol.toStringTag,{value:"Module"})),Sa=()=>{const e=j.useRef(new Map),t=j.useCallback(s=>{const{request:r,response:i}=s,l=e.current.get(r);l!=null&&(l(i.bounds),e.current.delete(r))},[]),[,,n]=f.use$2({type:O.BoundQuerier.TYPE,schema:O.boundQuerierStateZ,onAetherChange:t,initialState:{request:"",response:{request:"",bounds:{}}}});return j.useCallback(async()=>await new Promise(s=>{const r=u.kt.create();e.current.set(r,s),n(i=>({...i,request:r}))}),[])},j1=({ref:e})=>(e.current=Sa(),null),E1={select:"pointer",zoom:"crosshair",pan:"grab",zoomReset:"crosshair",click:"pointer",cancel:"default"},Ra=({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:E1[t],...r},...i,children:[o.jsxRuntimeExports.jsx("div",{style:{...u.Ho.css(n),display:u.Ho.areaIsZero(n)?"none":"block"},className:u.CSS.BE("viewport-mask","selection")}),s]}),y1=(e,t)=>{for(;e!=null&&!t(e);)e=e.parentElement;return e},S1=11,R1=6,C1=2,Ci=5,w1=e=>u.Ho.width(e)<Ci&&u.Ho.height(e)<Ci,fn=e=>{const t=u.Ho.width(e),n=u.Ho.height(e);return Math.min(t,n)<.001?S1:R1},b1=["zoom","pan","select","zoomReset","cancel"],ur=[...b1,"click"],v1=te.z.enum(ur),Ca=["zoom","select"],hn={defaultMode:"zoom",zoom:[["MouseLeft"]],zoomReset:[["MouseLeft","Control"]],pan:[["MouseLeft","Shift"],["MouseMiddle"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},wa={defaultMode:"pan",pan:[["MouseLeft"],["MouseMiddle"]],zoom:[["MouseLeft","Shift"]],zoomReset:[["MouseLeft","Control"]],select:[["MouseLeft","Alt"]],cancel:[["Escape"]]},ba={defaultMode:"select",select:[["MouseLeft"]],pan:[["MouseLeft","Shift"],["MouseMiddle"]],zoom:[["MouseLeft","Alt"]],zoomReset:[["MouseLeft","Control"]],cancel:[["Escape"]]},dr={zoom:hn,pan:wa,select:ba,zoomReset:hn,click:hn,cancel:hn},_1=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)]))},k1=u.Ho.construct(0,0,1,1,u.K$1.TOP_LEFT),L1={width:30,height:50},va=({onChange:e,triggers:t,initial:n=k1,threshold:s=L1,ref:r})=>{const i=t?.defaultMode??"zoom",[l,a]=j.useState(u.Ho.ZERO),[c,d]=j.useState(i),[x,p]=f.useStateRef(n),m=j.useRef(u.K.ZERO),h=j.useRef(null),g=u._.construct(s);j.useEffect(()=>p(()=>u.Ho.truncate(n,fn(n))),[n]),j.useEffect(()=>d(i),[i]);const[E,S,R,v]=f.useMemoCompare(()=>{const A={...dr[i],...t},B=f.flattenConfig(A),z=_1(A);return[A,B,z,f.flattenConfig(z)]},f.compareModeConfigs,[t]),y=j.useCallback(({box:A,triggers:B,stage:z,cursor:$})=>{if(h.current==null)return;const D=f.determineMode(E,B),V=u.Ho.construct(h.current);if(D==null)return;if(D==="cancel"){a(u.Ho.ZERO),e?.({box:x.current,mode:D,stage:z,cursor:$});return}if(D==="zoomReset")return a(u.Ho.ZERO),e?.({box:u.Ho.DECIMAL,mode:D,stage:z,cursor:$}),p(u.Ho.DECIMAL);const b=w1(A);if(z==="end"){if(b){D==="zoom"&&a(u.Ho.ZERO),e?.({box:x.current,mode:"click",stage:z,cursor:$});return}return p(L=>{if(D==="pan"){const F=wi(A,L,V);return F===null||u.Ho.equals(F,L)?L:(e?.({box:F,mode:D,stage:z,cursor:$}),F)}const N=C(A,L,V);return N===null?L:(e?.({box:N,mode:D,stage:z,cursor:$}),D==="zoom"?(a(u.Ho.ZERO),N):u.Ho.truncate(L,fn(L)))})}if(Ca.includes(D))return b?void 0:a(u.C.XY.scale(V).clamp(V).translate({x:-u.Ho.left(V),y:-u.Ho.top(V)}).box(bi(g,A,V)));if(a(L=>u.Ho.areaIsZero(L)?L:u.Ho.ZERO),u.K.distance($,m.current)<C1)return;m.current=$;const k=wi(A,x.current,V);e?.({box:k,mode:D,stage:z,cursor:$})},[a,d,e,E,s.height,s.width,p,h,fn]);j.useImperativeHandle(r,()=>({reset:()=>{a(u.Ho.ZERO),p(u.Ho.DECIMAL),e?.({box:u.Ho.DECIMAL,mode:"zoomReset",stage:"start",cursor:u.K.ZERO})}}),[e]);const C=j.useCallback((A,B,z)=>{const $=_o(B,z).box(bi(g,A,z));return u.Ho.truncate($,fn($))},[s]),_=f.useHeldRef({triggers:[["Control"]]}),M=f.useHeldRef({triggers:[["Alt"]]});j.useEffect(()=>{const A=B=>{if(h.current==null)return;let z=1;B.deltaY<0?z-=.035:z+=.035;const $=u.Ho.construct(h.current),D=u.K.construct(B);if(Array.from(h.current.children).push(h.current),!u.Ho.contains($,D)||h.current!==B.target&&y1(B.target,F=>F===h.current)==null)return;const k=_o(x.current,u.Ho.construct(h.current)).pos(u.K.construct(B));let N=u.C.XY.magnify({x:_.current.held?1:z,y:M.current.held?1:z}).box(x.current);N=u.Ho.translate(N,{x:_.current.held?0:k.x*(1-z),y:M.current.held?0:k.y*(1-z)}),p(N),e?.({stage:"end",box:N,cursor:u.K.construct(B),mode:"zoom"})};return window.addEventListener("wheel",A),()=>window.removeEventListener("wheel",A)},[p,e]),Vl.useDrag({bound:h,onDrag:y,triggers:S,loose:!0});const I=j.useCallback(({triggers:A,stage:B})=>{if(B==="end")return d(i);const z=f.determineMode(R,A);z!=null&&d(z)},[R,i,e]);return f.use$1({triggers:v,callback:I,region:h}),{maskBox:l,ref:h,mode:c}},_o=(e,t)=>u.C.XY.scale(t).clamp(t).scale(e),wi=(e,t,n)=>{let s=u.Ho.signedDims(_o(t,n).box(e));s={signedWidth:-s.signedWidth,signedHeight:-s.signedHeight};const r=u.C.XY.translate(u.K.construct(s)).box(t);return u.Ho.truncate(r,fn(r))},bi=(e,t,n)=>u.Ho.height(t)<=e.height?u.Ho.construct(u.Ho.left(t),u.Ho.top(n),u.Ho.width(t),u.Ho.height(n)):u.Ho.width(t)<=e.width?u.Ho.construct(u.Ho.left(n),u.Ho.top(t),u.Ho.width(n),u.Ho.height(t)):t,Gt=({mode:e,triggers:t})=>o.jsxRuntimeExports.jsxs(f.Text,{level:"small",children:[u.z.capitalize(e),o.jsxRuntimeExports.jsx(f.Text$1,{trigger:t[0],el:"span"})]}),M1=({triggers:e,value:t,onChange:n,disable:s=["zoomReset","click","cancel"],tooltipDelay:r,tooltipLocation:i,hideTooltip:l,...a})=>{const c=j.useMemo(()=>ur.filter(x=>!s.includes(x)),[s]),d={tooltipDelay:r,tooltipLocation:i,hideTooltip:l,size:"small"};return o.jsxRuntimeExports.jsxs(pe.Buttons,{...a,keys:c,value:t,onChange:n,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"zoom",tooltip:o.jsxRuntimeExports.jsx(Gt,{mode:"zoom",triggers:e.zoom}),...d,children:o.jsxRuntimeExports.jsx(f.Zoom,{})}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"pan",tooltip:o.jsxRuntimeExports.jsx(Gt,{mode:"pan",triggers:e.pan}),...d,children:o.jsxRuntimeExports.jsx(f.Pan,{})}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"select",tooltip:o.jsxRuntimeExports.jsx(Gt,{mode:"select",triggers:e.select}),...d,children:o.jsxRuntimeExports.jsx(f.Selection,{})})]})},N1=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_TRIGGERS:dr,MASK_MODES:Ca,MODES:ur,Mask:Ra,PAN_DEFAULT_TRIGGERS:wa,SELECT_DEFAULT_TRIGGERS:ba,SelectMode:M1,TooltipText:Gt,ZOOM_DEFAULT_TRIGGERS:hn,modeZ:v1,use:va},Symbol.toStringTag,{value:"Module"})),P1=e=>e==null?null:e.closest(".pluto-line-plot__viewport")??null,_a=({ref:e,children:t,initial:n=u.Ho.DECIMAL,onChange:s,...r})=>{const{setViewport:i}=ct("Viewport");j.useLayoutEffect(()=>{i({box:n,mode:"zoom",cursor:u.K.ZERO,stage:"start"})},[i,n]);const l=j.useCallback(c=>{i(c),s?.(c)},[s,i]),a=va({onChange:l,initial:n,ref:e,...r});return o.jsxRuntimeExports.jsx(Ra,{className:u.CSS.BE("line-plot","viewport"),...a,children:t})},T1=Object.freeze(Object.defineProperty({__proto__:null,BoundsQuerier:j1,Legend:ha,Line:cr,LinePlot:xa,Title:Ea,Tooltip:g1,Viewport:_a,XAxis:pa,YAxis:ma,axisFactory:ir,selectViewportEl:P1,useBoundQuerier:Sa,useContext:ct,useGridEntry:In,useViewport:da},Symbol.toStringTag,{value:"Module"})),I1=({aetherKey:e,...t})=>(f.use$2({aetherKey:e,type:O.Annotation.TYPE,schema:O.annotationStateZ,initialState:t}),null),ka=({aetherKey:e,menu:t,...n})=>{const s=f.useUniqueKey(e),{setViewport:r,setHold:i}=ct("Range.Provider"),[,{hovered:l,count:a},c]=f.use$2({aetherKey:s,type:O.Provider.TYPE,schema:O.providerStateZ,initialState:{...n,cursor:null,hovered:null,count:0}}),d=In({key:s,loc:"top",size:a>0?32:0,order:3},"Annotation.Provider"),x=f.useContextMenu(),p=f.useSyncedRef(x.visible),m=j.useCallback(g=>c(E=>({...E,cursor:{x:g.clientX,y:g.clientY}})),[c]),h=j.useCallback(()=>{p.current||c(g=>({...g,cursor:null}))},[c,p]);return o.jsxRuntimeExports.jsx(f.ContextMenu,{...x,menu:()=>t==null||l==null?null:t(l),children:o.jsxRuntimeExports.jsx(f.Box,{style:{...d,cursor:l!=null?"pointer":"default",width:"100%",height:"100%"},onContextMenu:x.open,className:x.className,onClick:()=>{l!=null&&(r({box:u.Ho.construct({x:l.viewport.lower,y:0},{x:l.viewport.upper,y:1}),mode:"zoom",cursor:u.K.ZERO,stage:"start"}),i(!0))},onMouseMove:m,onMouseLeave:h})})},O1=Object.freeze(Object.defineProperty({__proto__:null,Annotation:I1,Provider:ka},Symbol.toStringTag,{value:"Module"})),La={defaultMode:"empty",one:[["1"]],two:[["2"]],clear:[["Shift"]],empty:[[]]},A1=f.flattenConfig(La),Ma=({aetherKey:e})=>{const t=f.useUniqueKey(e),[,,n]=f.use$2({aetherKey:t,type:O.Measure.TYPE,schema:O.measureStateZ,initialState:{hover:null,one:null,two:null}}),s=j.useRef(null),r=f.useHeldRef({triggers:A1,loose:!0}),i=j.useCallback(({mode:c,cursor:d})=>{if(c==="click"){const x=f.determineMode(La,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]);da(i);const l=j.useCallback(c=>n(d=>({...d,hover:u.K.construct(c)})),[n]),a=j.useCallback(()=>{n(c=>({...c,hover:null}))},[n]);return j.useEffect(()=>{if(s.current===null)return;const c=s.current.parentElement;if(c!=null)return c.addEventListener("mousemove",l),c.addEventListener("mouseleave",a),()=>{c.removeEventListener("mousemove",l),c.removeEventListener("mouseleave",a)}},[i]),o.jsxRuntimeExports.jsx("span",{ref:s})},D1=Object.freeze(Object.defineProperty({__proto__:null,Measure:Ma},Symbol.toStringTag,{value:"Module"})),xr=({aetherKey:e,label:t,position:n,onLabelChange:s,onPositionChange:r,onUnitsChange:i,units:l="",color:a,lineWidth:c,lineDash:d,className:x,onSelect:p,style:m,...h})=>{const[g,E]=P.usePurePassthrough({value:t,onChange:s,initial:""}),S=f.useSyncedRef(r),[,{pixelPosition:R},v]=f.use$2({aetherKey:e,type:O.Rule.TYPE,schema:O.ruleStateZ,initialState:{color:a,dragging:!1,position:n,lineWidth:c,lineDash:d},onAetherChange:j.useCallback(({position:D})=>{D!=null&&S.current?.(D)},[S])}),y=j.useRef(R);R!==y.current&&(y.current=R);const{id:C}=ct("Rule"),M=document.getElementById(C)?.querySelector(".pluto-line-plot__viewport"),I=j.useRef(R);j.useEffect(()=>{v(D=>({...D,position:n,color:a,lineWidth:c,lineDash:d}))},[n,a,c,d]);const A=Pe.useCursorDrag({onStart:j.useCallback(()=>{p?.(),v(D=>({...D,dragging:!0})),I.current=y.current},[]),onMove:D=>{v(V=>({...V,pixelPosition:(I.current??0)+u.Ho.signedHeight(D)}))},onEnd:j.useCallback(()=>{v(D=>({...D,dragging:!1})),I.current=R},[])}),B=j.useRef(null);if(n==null||R==null)return null;const z=u.cr.pickByContrast(a,u.cr.BLACK,u.cr.WHITE),$=o.jsxRuntimeExports.jsxs("div",{ref:B,className:u.CSS.B("rule"),style:{top:`calc(${R}px - 0.5rem)`},children:[o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("rule","drag-handle"),onDragStart:A,draggable:!0}),o.jsxRuntimeExports.jsxs(f.Box,{x:!0,align:"center",className:u.CSS(x,u.CSS.BE("rule","tag")),bordered:!0,onClick:p,empty:!0,rounded:!0,style:{borderColor:u.cr.cssString(a),backgroundColor:u.cr.hex(u.cr.setAlpha(a,.7)),...m},...h,children:[o.jsxRuntimeExports.jsx(f.Editable,{className:u.CSS.BE("rule","label"),level:"small",value:g,onChange:E,color:z}),o.jsxRuntimeExports.jsx(f.Divider$1,{y:!0,style:{borderColor:u.cr.cssString(a)}}),o.jsxRuntimeExports.jsxs(f.Box,{x:!0,align:"center",className:u.CSS.BE("rule","value"),children:[o.jsxRuntimeExports.jsx(f.Editable,{value:n.toFixed(2),onChange:D=>{const V=Number(D);isFinite(V)&&r?.(V)},level:"small",color:z}),l.length>0&&o.jsxRuntimeExports.jsx(f.MaybeEditable,{level:"small",color:z,value:l,onChange:i})]})]})]});return M==null?$:zl.createPortal($,M)},B1=Object.freeze(Object.defineProperty({__proto__:null,Rule:xr},Symbol.toStringTag,{value:"Module"})),Na=f.canDropOfType(vt),$1=({lines:e,axes:t,showTitle:n=!0,title:s="",onTitleChange:r,showLegend:i=!0,legendPosition:l,onLegendPositionChange:a,titleLevel:c="h4",onLineChange:d,onRuleChange:x,onAxisChannelDrop:p,onAxisChange:m,rules:h,enableTooltip:g=!0,enableMeasure:E=!1,initialViewport:S=u.Ho.DECIMAL,legendVariant:R,onViewportChange:v,viewportTriggers:y,rangeAnnotationProvider:C,onSelectRule:_,children:M,...I})=>{const A=t.filter(({location:V})=>u.K$1.isY(V)),B=j.useRef(null),z=f.usePrevious(e.length),$=f.usePrevious(I.hold),D=z===0&&e.length!==0||$===!0&&I.hold===!1;return j.useEffect(()=>{D&&B.current?.reset()},[D]),o.jsxRuntimeExports.jsxs(xa,{...I,children:[A.map((V,b)=>{const k=e.filter(F=>F.axes.x===V.key),L=t.filter(({location:F})=>u.K$1.isX(F)),N=h?.filter(F=>[...L.map(({key:H})=>H),V.key].includes(F.axis));return o.jsxRuntimeExports.jsx(z1,{axis:V,index:b,lines:k,yAxes:L,rules:N,onAxisChannelDrop:p,onAxisChange:m,annotationProvider:C,onRuleChange:x,onSelectRule:_},V.key)}),i&&o.jsxRuntimeExports.jsx(ha,{onLineChange:d,position:l,onPositionChange:a,variant:R}),n&&o.jsxRuntimeExports.jsx(Ea,{value:s,onChange:r,level:c}),o.jsxRuntimeExports.jsxs(_a,{initial:S,onChange:v,triggers:y,ref:B,children:[g&&o.jsxRuntimeExports.jsx(ya,{}),E&&o.jsxRuntimeExports.jsx(Ma,{}),M]})]})},z1=({yAxes:e,lines:t,index:n,rules:s,onRuleChange:r,onSelectRule:i,onAxisChannelDrop:l,onAxisChange:a,axis:{location:c,key:d,showGrid:x,...p},annotationProvider:m})=>{const h=f.useDrop({type:"Channel.LinePlot.XAxis",canDrop:Na,onDrop:j.useCallback(({items:S})=>{const R=f.filterByType(vt,S);return l?.(d,R.map(({key:v})=>v)),R},[d,l])}),g=s?.filter(S=>S.axis===d),E=f.useDraggingState();return o.jsxRuntimeExports.jsxs(pa,{...p,...h,location:c,axisKey:d,showGrid:x??n===0,className:u.CSS(u.CSS.dropRegion(f.canDropOfType(vt)(E))),onAutoBoundsChange:S=>a?.({key:d,bounds:S}),onLabelChange:S=>a?.({key:d,label:S}),children:[e.map((S,R)=>{const v=t.filter(C=>C.axes.y===S.key),y=s?.filter(C=>C.axis===S.key);return o.jsxRuntimeExports.jsx(F1,{axis:{...S,showGrid:x??(n===0&&R===0)},lines:v,rules:y,onRuleChange:r,onAxisChannelDrop:l,onAxisChange:a,onSelectRule:i},S.key)}),g?.map(S=>j.createElement(xr,{aetherKey:S.key,...S,key:S.key,onLabelChange:R=>r?.({key:S.key,label:R}),onPositionChange:R=>r?.({key:S.key,position:R}),onUnitsChange:R=>r?.({key:S.key,units:R}),onSelect:()=>i?.(S.key)})),o.jsxRuntimeExports.jsx(ka,{...m})]})},V1=({channels:{x:e,y:t}})=>`${e??0}-${t}`,F1=({lines:e,rules:t,onRuleChange:n,onAxisChannelDrop:s,onAxisChange:r,axis:{key:i,location:l,...a},onSelectRule:c})=>{const d=f.useDrop({type:"Channel.LinePlot.YAxis",canDrop:Na,onDrop:j.useCallback(({items:p})=>{const m=f.filterByType(vt,p);return s?.(i,m.map(({key:h})=>h)),m},[i,s])}),x=f.useDraggingState();return o.jsxRuntimeExports.jsxs(ma,{...a,...d,location:l,axisKey:i,className:u.CSS(u.CSS.dropRegion(f.canDropOfType(vt)(x))),onAutoBoundsChange:p=>r?.({key:i,bounds:p}),onLabelChange:p=>r?.({key:i,label:p}),children:[e.map(p=>o.jsxRuntimeExports.jsx(H1,{line:p},V1(p))),t?.map(p=>j.createElement(xr,{aetherKey:p.key,...p,key:p.key,onLabelChange:m=>n?.({key:p.key,label:m}),onPositionChange:m=>n?.({key:p.key,position:m}),onUnitsChange:m=>n?.({key:p.key,units:m}),onClick:()=>c?.(p.key)}))]})},H1=({line:e})=>e.variant==="static"?o.jsxRuntimeExports.jsx(K1,{line:e}):o.jsxRuntimeExports.jsx(Z1,{line:e}),Z1=({line:{key:e,timeSpan:t,channels:{x:n,y:s},axes:r,...i}})=>{const{xTelem:l,yTelem:a}=j.useMemo(()=>{const c=Number(t.valueOf())*3,d=O.streamChannelData({timeSpan:t,channel:s,keepFor:c}),x=n!=null&&n!==0;return{xTelem:O.streamChannelData({timeSpan:t,channel:x?n:s,useIndexOfChannel:!x,keepFor:c}),yTelem:d}},[t.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(cr,{aetherKey:e,y:a,x:l,legendGroup:r.y.toUpperCase(),...i},e)},K1=({line:{timeRange:e,key:t,channels:{x:n,y:s},...r}})=>{const{xTelem:i,yTelem:l}=j.useMemo(()=>{const a=O.channelData({timeRange:e,channel:s}),c=n!=null&&n!==0;return{xTelem:O.channelData({timeRange:e,channel:c?n:s,useIndexOfChannel:!c}),yTelem:a}},[e.start.valueOf(),e.end.valueOf(),n,s]);return o.jsxRuntimeExports.jsx(cr,{aetherKey:t,y:l,x:i,legendGroup:r.axes.y.toUpperCase(),...r},t)},lt=(e,t,n)=>({variant:"loading",status:u.wr.create({variant:"loading",message:`${u.z.capitalize(t)} ${e}`}),data:n}),Ve=(e,t,n)=>({variant:"success",status:u.wr.create({variant:"success",message:`${u.z.capitalize(t)} ${e}`}),data:n}),_t=(e,t,n)=>({variant:"error",status:u.wr.fromException(n,`Failed to ${t} ${e}`),data:void 0}),Wt=(e,t)=>({variant:"disabled",status:u.wr.create({variant:"disabled",message:`Failed to ${t} ${e}`,description:`Cannot ${t} ${e} because no cluster is connected.`}),data:void 0}),pr=j.createContext({mode:"normal",bind:()=>()=>{},set:()=>{},reset:()=>{},remove:()=>{},get:()=>({value:void 0,status:{key:"",variant:"success",message:""},touched:!1,required:!1}),validate:()=>!1,validateAsync:()=>Promise.resolve(!1),value:()=>({}),has:()=>!1,setStatus:()=>{},clearStatuses:()=>{},setCurrentStateAsInitialValues:()=>{},getStatuses:()=>[]}),rn=e=>{const t=j.use(pr);return e??t},Et=(e,t={})=>{const{optional:n=!1,onChange:s,defaultValue:r}=t,i=rn(t?.ctx),{get:l,bind:a,set:c,setStatus:d}=i,x=j.useCallback(g=>{s?.(g,{...i,path:e}),c(e,g)},[e,c,s]),p=j.useCallback(g=>d(e,g),[e,d]),m=j.useSyncExternalStore(a,j.useCallback(()=>l(e,{optional:n,defaultValue:r}),[e,l,n,r]));if(m==null){if(!n)throw new Error(`Field state is null: ${e}`);return null}const h=i.mode==="preview"?"preview":void 0;return{onChange:x,setStatus:p,variant:h,...m}},mr=(e,t)=>{const{get:n,bind:s}=rn(t?.ctx);return j.useSyncExternalStore(s,j.useCallback(()=>n(e,t),[e,n,t]))},fr=(e,t)=>mr(e,t)?.value??null,Y1=e=>mr(e,{optional:!0})?.status?.variant==="success",Pa=(e,t)=>({value:()=>e.get(t).value,add:(n,s)=>{const r=u.yr(e.get(t).value);r.splice(s,0,...P.t.toArray(n)),e.set(t,r)},push:(n,s)=>{const r=u.yr(e.get(t).value);r.push(...P.t.toArray(n)),s!=null&&r.sort(s),e.set(t,r)},remove:n=>{const s=e.get(t).value,r=new Set(P.t.toArray(n)),i=s.filter(({key:l})=>!r.has(l));return e.set(t,i),i.map(({key:l})=>l)},keepOnly:n=>{const s=e.get(t).value,r=new Set(P.t.toArray(n)),i=s.filter(({key:l})=>r.has(l));return e.set(t,i),i.map(({key:l})=>l)},set:n=>e.set(t,P.executeSetter(n,e.get(t).value)),sort:n=>{const s=u.yr(e.get(t).value);s.sort(n),e.set(t,s)}}),G1=(e,t={})=>{const n=rn(t?.ctx),s=fr(e,t);return j.useMemo(()=>({data:s.map(({key:r})=>r),...Pa(n,e)}),[s,n,e])},U1=f.renderProp(e=>o.jsxRuntimeExports.jsx(f.Text$2,{...e})),Ee=({path:e,children:t=U1,label:n,padHelpText:s=!0,visible:r=!0,hideIfNull:i=!0,optional:l,onChange:a,className:c,defaultValue:d,...x})=>{const p=Et(e,{optional:l??i,onChange:a,defaultValue:d}),m=rn();if(p==null)return null;if(e==null)throw new Error("No path provided to Form Field");if(n??=u.z.capitalize(P.N.element(e,-1)),r=typeof r=="function"?r(p,m):r,!r)return null;const h=p.status.message,{onChange:g,value:E}=p,S={onChange:g,value:E};return p.variant!=null&&(S.variant=p.variant),o.jsxRuntimeExports.jsx(Ie.Item,{padHelpText:s,helpText:h,status:p.status.variant,label:n,required:p.required,className:u.CSS(c,u.CSS.BE("field",e.split(".").join("-")),u.CSS.M(p.status.variant)),...x,children:t(S)})},An=e=>({fieldKey:t,fieldProps:n,inputProps:s})=>{const r=({inputProps:i,path:l,fieldKey:a=t,optional:c,defaultValue:d,...x})=>o.jsxRuntimeExports.jsx(Ee,{...n,...x,defaultValue:d,optional:c,path:a?`${l}.${a}`:l,children:p=>o.jsxRuntimeExports.jsx(e,{...p,...s,...i})});return r.displayName=e.displayName,r},Ta=An(f.Numeric),$e=Ta({inputProps:{}}),Ia=An(f.Text$2),hr=Ia({inputProps:{}}),Oa=An(f.Switch$1),Ts=Oa({inputProps:{}}),W1=e=>An(Pn)(e),X1=({children:e,...t})=>o.jsxRuntimeExports.jsx(pr,{value:t,children:e}),q1=e=>e.code==="custom"&&e.params!=null&&"variant"in e.params?e.params.variant:"error";class Q1 extends O.a.Observer{schema;values;initialValues;statuses;touched;cachedRefs;constructor(t,n){super(),this.schema=n,this.values=P.N.copy(t),this.statuses=new Map,this.touched=new Set,this.cachedRefs=new Map,this.initialValues=P.N.copy(this.values)}setValue(t,n){t==""?this.values=P.N.copy(n):P.N.set(this.values,t,n),this.checkTouched(t,n),this.updateCachedRefs(t)}checkTouched(t,n){const s=P.N.get(this.initialValues,t,{optional:!0});P.N.equal(s,n)?(this.clearTouched(t),this.clearOrphanedTouchedPaths(t)):this.setTouched(t)}clearOrphanedTouchedPaths(t){const n=new Set;this.touched.forEach(s=>{P.N.pathsMatch(s,t)&&s!==t&&!P.N.has(this.values,s)&&n.add(s)}),n.forEach(s=>{this.touched.delete(s),this.cachedRefs.delete(s)})}setStatus(t,n){this.statuses.set(t,n),this.updateCachedRefs(t)}clearStatus(t=""){this.statuses.delete(t),this.updateCachedRefs(t)}reset(t){if(P.N.equal(this.values,t??this.initialValues))return;t!=null&&(this.initialValues=P.N.copy(t));const n=P.N.copy(this.initialValues);this.statuses.clear(),this.touched.clear();const s=new Set;this.cachedRefs.forEach((r,i)=>{const l=P.N.get(this.values,i,{optional:!0}),a=P.N.get(n,i,{optional:!0});P.N.equal(l,a)||s.add(i)}),s.forEach(r=>this.cachedRefs.delete(r)),this.values=n}setCurrentStateAsInitialValues(){this.initialValues=P.N.copy(this.values),this.touched.clear(),this.cachedRefs.clear()}setTouched(t){this.touched.add(t),this.updateCachedRefs(t)}clearTouched(t=""){t===""?this.touched.clear():this.touched.delete(t),this.updateCachedRefs(t),this.notify()}remove(t){P.N.remove(this.values,t),this.statuses.delete(t),this.clearTouched(t),this.cachedRefs.delete(t)}validate(t,n){if(this.schema==null)return!0;const s=this.schema.safeParse(this.values);return this.processValidation(t,s,n)}async validateAsync(t,n){if(this.schema==null)return!0;const s=await this.schema.safeParseAsync(this.values);return this.processValidation(t,s,n)}errorsToStatuses(t,n,s){return t.forEach(r=>{const i=[...n,...r.path],l=P.N.resolvePath(i.join("."),this.values);if(s.push({key:l,variant:q1(r),message:r.message}),r.code==="invalid_union"&&r.errors!=null&&r.errors.length>0){const a=r.errors.map(d=>d.filter(x=>P.N.has(this.values,[...i,...x.path].join("."))));a.sort((d,x)=>d.length-x.length);const c=a.find(d=>d.length>0);if(c==null)return;this.errorsToStatuses(c,i,s)}}),s}processValidation(t=!1,n,s){if(this.schema==null)return!0;const r=new Set;if(this.statuses.forEach((a,c)=>{a.variant!=="success"&&r.add(c)}),r.forEach(a=>this.clearStatus(a)),n.success)return!0;let i=!0;return this.errorsToStatuses(n.error.issues,[],[]).forEach(a=>{const{key:c,message:d,variant:x}=a;if(c==null)return;const p=s==null||P.N.pathsMatch(c,s)||P.N.pathsMatch(s,c),m=t||this.touched.has(c);!p||!m||(x!=="warning"&&(i=!1),this.setStatus(c,{key:c,variant:x,message:d}))}),i}get hasBeenTouched(){return this.touched.size>0}getStatuses(){return Array.from(this.statuses.values()).filter(t=>t.variant!=="success")}getState(t,n={}){const{optional:s=!1,defaultValue:r=void 0}=n,i=u.pr.getOrSetDefault(this.cachedRefs,t,{});let l=P.N.get(this.values,t,{optional:s||r!=null});if(l==null){if(r==null)return null;l=r,this.setValue(t,l)}if(i.value=l,i.required=!1,this.schema!=null){const a=ig.getFieldSchema(this.schema,t,{optional:!0});a!=null&&(i.required=!a.safeParse(void 0).success)}return i.status=u.pr.getOrSetDefault(this.statuses,t,{key:t,variant:"success",message:""}),i.touched=this.touched.has(t),i}updateCachedRefs(t){this.cachedRefs.forEach((n,s)=>{(P.N.pathsMatch(s,t)||P.N.pathsMatch(t,s))&&this.cachedRefs.set(s,{})})}}const gr=({values:e,sync:t=!1,schema:n,mode:s="normal",onChange:r,onHasTouched:i})=>{const l=f.useInitializerRef(()=>new Q1(e,n)),a=f.useSyncedRef(r),c=f.useErrorHandler(),d=f.useSyncedRef(i),x=j.useCallback(()=>{l.current.setCurrentStateAsInitialValues(),d.current?.(!1)},[]),p=j.useCallback(_=>l.current.onChange(_),[]),m=j.useCallback((_,M)=>l.current.getState(_,M),[]),h=j.useCallback(_=>{l.current.remove(_),l.current.notify()},[]),g=j.useCallback(_=>{const M=l.current.values,I=l.current.hasBeenTouched;l.current.reset(_),M!==l.current.values&&a.current?.({values:l.current.values,path:"",prev:M,valid:!0}),l.current.notify();const B=l.current.hasBeenTouched;B!==I&&d.current?.(B)},[]),E=j.useCallback(async _=>{const M=await l.current.validateAsync(!0,_);return l.current.notify(),M},[]),S=j.useCallback(_=>{const M=l.current.validate(!0,_);return l.current.notify(),M},[]),R=j.useCallback((_,M,I)=>{const{notifyOnChange:A=!0}=I??{},B=P.N.get(l.current.values,_,{optional:!0}),z=l.current.hasBeenTouched;l.current.setValue(_,M);const $=()=>{A&&a.current?.({values:l.current.values,path:_,prev:B,valid:!0}),l.current.notify();const D=l.current.hasBeenTouched;D!==z&&d.current?.(D)};try{l.current.validate()}catch{return c(async()=>{await l.current.validateAsync(),$()},"Failed to validate form")}$()},[]),v=j.useCallback(_=>P.N.has(l.current.values,_),[]),y=j.useCallback((_,M)=>{const I=l.current.hasBeenTouched;l.current.setStatus(_,M),l.current.notify();const A=l.current.hasBeenTouched;A!==I&&d.current?.(A)},[]),C=j.useCallback(()=>{l.current.clearStatus(),l.current.notify()},[]);return j.useEffect(()=>{t&&(l.current.reset(e),l.current.notify())},[t,e]),j.useMemo(()=>({bind:p,set:R,get:m,mode:s,validate:S,validateAsync:E,value:()=>l.current.values,has:v,remove:h,setStatus:y,clearStatuses:C,reset:g,setCurrentStateAsInitialValues:x,getStatuses:()=>l.current.getStatuses()}),[p,R,m,S,E,v,h,y,C,g,s,x])},Aa=({key:e,open:t,onChange:n})=>{const s=f.useMemoPrimitiveArray(e);It(async()=>{if(t==null)return;const r=await t();if(r==null)return;const i=r.onChange(n);return async()=>{i(),await r.close()}},[t==null,s])},J1=Object.freeze(Object.defineProperty({__proto__:null,useListener:Aa},Symbol.toStringTag,{value:"Module"})),En={...O.ZERO_CONTEXT_VALUE,state:P.Sm.connectivity.DEFAULT},e0={maxRetries:4,baseInterval:P.O$1.seconds(1),scale:2},jr=j.createContext(En),Da=()=>j.use(jr),At=()=>Da().client,t0=()=>Da().state,ko={connected:"success",connecting:"loading",disconnected:"disabled",failed:"error"},Ba="serverVersionMismatch",n0=(e,t,n)=>`Cluster version ${n!=null?`${n} `:""}is ${e?"older":"newer"} than client version ${t}. Compatibility issues may arise.`,s0=({children:e,client:t})=>{const{path:n}=f.useUnidirectional({type:O.Provider$1.TYPE,schema:O.Provider$1.stateZ,state:{props:null,state:null}});return o.jsxRuntimeExports.jsx(jr,{value:{...En,client:t},children:o.jsxRuntimeExports.jsx(f.Composite,{path:n,children:e})})},$a=({children:e,connParams:t})=>{const[n,s,r]=f.useCombinedStateAndRef(En),{path:i}=f.useUnidirectional({type:O.Provider$1.TYPE,schema:O.Provider$1.stateZ,state:{props:t??null,state:null}}),l=f.useAdder(),a=j.useCallback(c=>{r.current.state.status!==c.status&&l({variant:ko[c.status],message:c.message??u.z.capitalize(c.status)}),s(d=>({...d,state:c}))},[l]);return It(async c=>{if(n.client!=null&&n.client.close(),t==null)return s(En);const d=new P.Sm({retry:e0,...t,connectivityPollFrequency:P.O$1.seconds(2)});s({client:d,state:{clusterKey:"",status:"connecting",message:"Connecting...",clientServerCompatible:!1,clientVersion:d.clientVersion}});const x=await d.connectivity.check();if(!c.aborted){if(s({client:d,state:x}),l({variant:ko[x.status],message:x.message??x.status.toUpperCase()}),x.status==="connected"&&!x.clientServerCompatible){const p=x.nodeVersion==null||u.gr.semVerOlder(x.nodeVersion,x.clientVersion),m=n0(p,x.clientVersion,x.nodeVersion);l({variant:"warning",message:"Incompatible cluster version",description:m,details:{type:Ba,oldServer:p,nodeVersion:x.nodeVersion,clientVersion:x.clientVersion}})}return d.connectivity.onChange(a),()=>{d.close(),s(En)}}},[t,a]),o.jsxRuntimeExports.jsx(jr,{value:n,children:o.jsxRuntimeExports.jsx(f.Composite,{path:i,children:e})})},o0=Object.freeze(Object.defineProperty({__proto__:null,CONNECTION_STATE_VARIANTS:ko,Provider:$a,SERVER_VERSION_MISMATCH:Ba,TestProvider:s0,use:At,useConnectionState:t0},Symbol.toStringTag,{value:"Module"})),r0=({key:e,name:t,queryFn:n,values:s,openObservable:r,applyChanges:i,applyObservable:l,...a})=>{const c=At(),d=f.useErrorHandler(),x=f.useMemoPrimitiveArray(e),p=gr({values:s,...a,sync:!1,onChange:g=>{c!=null&&d(async()=>{await i?.({...g,client:c})},`Failed to apply changes for ${t}`)}});It(async()=>{if(c!=null)try{const g=await n({client:c});p.set("",g)}catch(g){d(g,`Failed to retrieve ${t}`)}},[x,c?.key]);const m=j.useCallback(async()=>{if(c!=null)return await r?.(c)},[x,c?.key]),h=j.useCallback(g=>l?.({changes:g,ctx:p}),[x,l]);return Aa({key:x,open:m,onChange:h}),p},i0=Object.freeze(Object.defineProperty({__proto__:null,Context:pr,Field:Ee,Form:X1,NumericField:$e,SwitchField:Ts,TextField:hr,buildNumericField:Ta,buildSelectField:W1,buildSwitchField:Oa,buildTextField:Ia,fieldBuilder:An,fieldListUtils:Pa,use:gr,useContext:rn,useField:Et,useFieldList:G1,useFieldState:mr,useFieldValid:Y1,useFieldValue:fr,useSynced:r0},Symbol.toStringTag,{value:"Module"})),Dt=({name:e,schema:t,retrieve:n,mountListeners:s,update:r,initialValues:i})=>({params:l,initialValues:a,autoSave:c=!1,afterSave:d,beforeSave:x,sync:p,onHasTouched:m,mode:h,scope:g})=>{const[E,S]=j.useState(lt(e,"retrieving",void 0)),R=f.useUniqueKey(g),v=At(),y=He(R),C=Ls(),_=gr({schema:t,values:a??i,onChange:({path:$})=>{c&&$!==""&&z()},sync:p,onHasTouched:m,mode:h}),M=j.useCallback(($,D,V)=>_.set($,D,{...V,notifyOnChange:!1}),[_]),I=j.useCallback(async($,D={})=>{const{signal:V}=D;try{if(v==null)return S(Wt(e,"retrieve"));if(S(k=>lt(e,"retrieving",k.data)),V?.aborted)return;const b={client:v,params:$,store:y,..._,set:M};if(await n(b),V?.aborted)return;C.cleanup(),C.set(s?.(b)),S(Ve(e,"retrieved",void 0))}catch(b){if(V?.aborted)return;S(_t(e,"retrieve",b))}},[v,e,_,y,M]),A=f.useMemoDeepEqual(l);It(async $=>await I(A,{signal:$}),[I,A]);const B=j.useCallback(async($={})=>{const{signal:D}=$;try{if(v==null)return S(Wt(e,"update")),!1;const V={client:v,params:l,store:y,..._,set:M};return await _.validateAsync()?(S(lt(e,"updating",void 0)),await x?.(V)===!1?(S(Ve(e,"updated",void 0)),!1):D?.aborted===!0?!1:(await r(V),S(Ve(e,"updated",void 0)),d?.(V),!0)):!1}catch(V){return D?.aborted!==!0&&S(_t(e,"update",V)),!1}},[e,l,x,d]),z=j.useCallback($=>void B($),[B]);return{form:_,save:z,...E}},za=j.createContext(null),He=e=>{const t=f.useRequiredContext(za),n=f.useUniqueKey(e);return j.useMemo(()=>t.scopedStore(n),[t,n])},Va=({children:e,...t})=>{const n=At(),s=f.useErrorHandler(),r=f.useAsyncErrorHandler(),{path:i}=f.useLifecycle({type:O.PROVIDER_TYPE,schema:O.providerStateZ$1,initialState:{}}),l=()=>"client"in t?t.client:new O.Client({client:n,storeConfig:t.storeConfig,handleError:s,handleAsyncError:r}),a=f.useInitializerRef(l),c=j.useRef(null);return n?.key!==c.current?.key&&(c.current=n,a.current=l()),o.jsxRuntimeExports.jsx(f.Composite,{path:i,children:o.jsxRuntimeExports.jsx(za,{value:a.current,children:e})})},l0=()=>!0,a0=u.i.milliseconds(100),c0=(e,t,n,s,r,i)=>{if(e==null)return;let l=e({params:t.current??{},store:i});if(n.current!=null&&(l=l.filter(n.current)),s.current!=null&&(l=l.sort(s.current)),l.length!==0)return l.forEach(a=>r.current.set(a.key,a)),l.map(a=>a.key)},Ke=({name:e,mountListeners:t,retrieve:n,retrieveByKey:s,retrieveCached:r})=>(i={})=>{const{filter:l=l0,sort:a,initialParams:c,retrieveDebounce:d=a0}=i,x=f.useSyncedRef(l),p=f.useSyncedRef(a),m=At(),h=j.useRef(new Map),g=f.useInitializerRef(()=>new Map),E=He(),S=j.useRef(c??null),[R,v,y]=f.useCombinedStateAndRef(()=>lt(e,"retrieving",c0(r,S,x,p,h,E))),C=j.useRef(!0),_=Ls(),M=j.useRef(!1),I=j.useCallback(k=>g.current.forEach((L,N)=>{L===k&&N()}),[g.current]),A=j.useCallback(k=>{if(p.current==null)return k;const L=k.map(N=>h.current.get(N)).filter(N=>N!=null);return L.sort(p.current),L.map(N=>N.key)},[p]),B=j.useCallback(()=>{m!=null&&(M.current=!0,_.cleanup(),_.set(t?.({client:m,store:E,params:S.current??{},onDelete:k=>{h.current.delete(k),v(L=>L.data==null?L:{...L,data:L.data.filter(N=>N!==k)})},onChange:(k,L,N={})=>{const{mode:F="append"}=N,H=h.current.get(k)??null;if(H!=null&&!x.current(H))return;const K=P.executeSetter(L,H);K==null||!x.current(K)||(h.current.set(k,K),v(Z=>{if(Z.data==null)return Z;let Y;if(H==null)p.current!=null?Y=A([...Z.data,k]):Y=F==="prepend"?[k,...Z.data]:[...Z.data,k];else if(p.current!=null){const ne=Z.data.indexOf(k),J=A(Z.data),ce=J.indexOf(k);ne!==ce?Y=J:Y=Z.data}else Y=Z.data;return{...Z,data:Y}}),I(k))}})))},[t,_]),z=j.useCallback(async(k,L={})=>{const{signal:N,mode:F="replace"}=L,H=P.executeSetter(k,S.current??{});S.current=H;try{if(m==null)return v(Wt(e,"retrieve"));if(v(Y=>lt(e,"retrieving",Y.data)),F==="replace")C.current=!0;else if(F==="append"&&!C.current)return v(Y=>Ve(e,"retrieved",Y.data??[]));let K=await n({client:m,params:H,store:E});if(N?.aborted)return;K=K.filter(x.current),p.current!=null&&(K=K.sort(p.current)),K.length===0&&(C.current=!1);const Z=K.map(Y=>Y.key);return B(),y.current.data!=null&&u.k.primitiveArrays(y.current.data,Z)===u.k.EQUAL?v(Y=>Ve(e,"retrieved",Y.data??[])):(K.forEach(Y=>h.current.set(Y.key,Y)),v(Y=>{if(F==="replace"||Y.data==null)return Ve(e,"retrieved",Z);const ne=new Set(Z);return Ve(e,"retrieved",[...Y.data.filter(J=>!ne.has(J)),...Z])}))}catch(K){if(N?.aborted)return;v(_t(e,"retrieve",K))}},[m,e,E,x,B]),$=j.useCallback((k,L={})=>{const{signal:N}=L;(async()=>{M.current||B();try{if(m==null||u.O$1.isZero(k))return;const F=await s({client:m,key:k,params:S.current??{},store:E});if(N?.aborted||F==null)return;if(!x.current(F)){h.current.set(k,null);return}h.current.set(k,F),I(k)}catch(F){if(N?.aborted)return;h.current.set(k,null),v(_t(e,"retrieve",F))}})()},[s,m,I,B]),D=j.useCallback(k=>{if(k==null)return;if(Array.isArray(k))return k.map(N=>D(N)).filter(N=>N!=null);const L=h.current.get(k);return L===void 0&&$(k),L},[$]),V=j.useCallback((k,L)=>L==null?()=>{}:(g.current.set(k,L),()=>g.current.delete(k)),[]);return{retrieve:Pe.useDebouncedCallback((k,L={})=>void z(k,L),new u.i(d).milliseconds,[z]),retrieveAsync:z,subscribe:V,getItem:D,...R,data:R?.data??[]}},u0=({key:e,subscribe:t,getItem:n})=>j.useSyncExternalStore(j.useCallback(s=>t(s,e),[t,e]),j.useCallback(()=>n(e),[n,e])),Fa=e=>lt(e,"retrieving",void 0),Ha=e=>{const[t,n]=j.useState(Fa(e.name));return{...t,...Za({...e,onChange:n})}},Za=({retrieve:e,mountListeners:t,name:n,onChange:s,scope:r})=>{const i=At(),l=j.useRef(null),a=He(r),c=Ls(),d=j.useCallback(m=>s(h=>{if(h.data===void 0)return h;const g=P.executeSetter(m,h.data);return Ve(n,"retrieved",g)}),[s,n]),x=j.useCallback(async(m,h={})=>{const{signal:g}=h,E=P.executeSetter(m,l.current??{});l.current=E;try{if(i==null)return s(Wt(n,"retrieve"));if(s(v=>lt(n,"retrieving",v.data)),g?.aborted)return;const S={client:i,params:E,store:a},R=await e(S);if(g?.aborted)return;c.cleanup(),c.set(t?.({...S,onChange:d})),s(Ve(n,"retrieved",R))}catch(S){if(g?.aborted)return;s(_t(n,"retrieve",S))}},[i,n]);return{retrieve:j.useCallback((m,h)=>void x(m,h),[x]),retrieveAsync:x}},d0=({params:e,...t})=>{const{retrieveAsync:n,retrieve:s,...r}=Ha(t),i=f.useMemoDeepEqual(e);return It(async l=>await n(i,{signal:l}),[n,i]),r},x0=({params:e,...t})=>{const n=j.useRef(Fa(t.name)),{retrieveAsync:s}=Za({...t,onChange:i=>{n.current=P.executeSetter(i,n.current),t.onChange?.(n.current)}}),r=f.useMemoDeepEqual(e);It(async i=>{r!=null&&await s(r,{signal:i})},[s,r])},qe=e=>({useDirect:t=>d0({...e,...t}),useStateful:()=>Ha(e),useEffect:t=>x0({...e,...t})}),Ka=({onChange:e,params:t,update:n,name:s,scope:r,beforeUpdate:i,afterUpdate:l})=>{const a=At(),c=He(r),d=j.useCallback(async(p,m={})=>{const{signal:h}=m;try{if(a==null)return e(Wt(s,"update")),!1;e(E=>lt(s,"updating",E.data));let g=!1;if(i!=null){const E=await i({client:a,value:p});if(E==null)return!1;p=E}return await n({client:a,onChange:E=>{g=!0,e(Ve(s,"updated",E))},value:p,params:t,store:c}),h?.aborted===!0?!1:(g||e(Ve(s,"updated",p)),l!=null&&await l({client:a,value:p}),!0)}catch(g){return h?.aborted!==!0&&e(_t(s,"update",g)),!1}},[s,t]);return{update:j.useCallback((p,m)=>void d(p,m),[d]),updateAsync:d}},p0=({params:e,name:t,...n})=>{const[s,r]=j.useState(Ve(t,"updated",void 0)),i=Ka({...n,name:t,onChange:r,params:e});return{...s,...i}},Qe=e=>({useObservable:t=>Ka({...t,...e}),useDirect:t=>p0({...t,...e})}),m0=Object.freeze(Object.defineProperty({__proto__:null,Client:O.Client,Provider:Va,ScopedUnaryStore:O.ScopedUnaryStore,createForm:Dt,createList:Ke,createRetrieve:qe,createStore:O.createStore,createUpdate:Qe,errorResult:_t,nullClientResult:Wt,pendingResult:lt,scopeStore:O.scopeStore,successResult:Ve,useListItem:u0,useStore:He},Symbol.toStringTag,{value:"Module"})),Ya="channels",f0={channel:P.ow.SET_CHANNEL_NAME,schema:P.ow.keyZ,onChange:async({store:e,changed:t,client:n})=>e.channels.set(t,await n.channels.retrieve(t))},h0={channel:P.ow.DELETE_CHANNEL_NAME,schema:P.ow.keyZ,onChange:({store:e,changed:t})=>e.channels.delete(t)},g0={channel:P.ow.CALCULATION_STATUS_CHANNEL_NAME,schema:P.ow.statusZ,onChange:async({store:e,changed:t,client:n})=>e.channels.set(Number(t.key),s=>s==null?s:n.channels.sugar({...s,status:t}))},j0=e=>{const t=He();j.useEffect(()=>t.channels.onSet(n=>{n.status!=null&&e(n.status)}),[t])},Ga={equal:(e,t)=>P.N.equal(e.payload,t.payload),listeners:[f0,h0,g0]},Er=P.ow.newZ.extend({name:te.z.string().min(1,"Name must not be empty"),dataType:P.I.z.transform(e=>e.toString())}).refine(e=>!e.isIndex||P.I.z.parse(e.dataType).equals(P.I.TIMESTAMP),{message:"Index channel must have data type TIMESTAMP",path:["dataType"]}).refine(e=>e.isIndex||e.index!==0||e.virtual,{message:"Data channel must have an index",path:["index"]}).refine(e=>e.virtual||!P.I.z.parse(e.dataType).isVariable,{message:"Persisted channels must have a fixed-size data type",path:["dataType"]}),Ua=Er.extend({expression:te.z.string().min(1,"Expression must not be empty").refine(e=>e.includes("return"),{message:"Expression must contain a return statement"})}).refine(e=>e.requires?.length>0,{message:"Expression must use at least one channel",path:["requires"]}),Wa=e=>({...e.payload,dataType:e.dataType.toString()}),yr={key:0,name:"",index:0,dataType:P.I.FLOAT32.toString(),internal:!1,isIndex:!1,leaseholder:0,virtual:!1,expression:"",requires:[]},Sr=async({client:e,params:{key:t,rangeKey:n},store:s})=>{let r=s.channels.get(t);if(r==null&&(r=await e.channels.retrieve(t),s.channels.set(r.key,r)),n!=null){const i=P.Iw.aliasKey({range:n,channel:r.key});let l=s.rangeAliases.get(i);if(l==null)try{l={alias:await e.ranges.retrieveAlias(n,r.key),channel:r.key,range:n}}finally{s.rangeAliases.set(i,{channel:r.key,range:n})}l!=null&&(r.alias=l.alias)}return r},E0=async({client:e,params:{keys:t,rangeKey:n},store:s})=>{const r=s.channels.get(t),i=new Set(r?.map(a=>a.key)),l=t.filter(a=>!i.has(a));if(l.length>0){const a=await e.channels.retrieve(l);r.push(...a),s.channels.set(a)}if(n!=null){const a=t.map(p=>P.Iw.aliasKey({range:n,channel:p})),c=s.rangeAliases.get(a);c.forEach(p=>{if(p==null)return;const m=r.find(h=>h.key===p.channel);m!=null&&(m.alias=p.alias)});const d=new Set(c.map(p=>p.channel)),x=t.filter(p=>!d.has(p));if(x.length>0){const p=await e.ranges.retrieveAliases(n,x);Object.entries(p).forEach(([m,h])=>{const g=Number(m),E=r.find(R=>R.key===g);E!=null&&(E.alias=h);const S=P.Iw.aliasKey({range:n,channel:g});s.rangeAliases.set(S,{alias:h,channel:g,range:n})})}}return r},Xa=async({params:{key:e,rangeKey:t},store:n,client:s,reset:r})=>{if(e==null)return;const i=await Sr({client:s,store:n,params:{key:e,rangeKey:t}});r(Wa(i))},Rr=qe({name:"Channel",retrieve:Sr,mountListeners:({store:e,onChange:t,params:{key:n,rangeKey:s},client:r})=>{const i=e.channels.onSet(d=>{if(s!=null){const x=e.rangeAliases.get(P.Iw.aliasKey({range:s,channel:n}));x!=null&&(d.alias=x.alias)}t(d)},n);if(s==null)return i;const l=P.Iw.aliasKey({range:s,channel:n}),a=e.rangeAliases.onSet(d=>{d!=null&&t(x=>r.channels.sugar({...x,alias:d.alias}))},l),c=e.rangeAliases.onDelete(()=>t(d=>r.channels.sugar({...d,alias:void 0})),l);return[i,a,c]}}),y0=qe({name:"Channels",retrieve:E0,mountListeners:({store:e,onChange:t,params:{keys:n,rangeKey:s},client:r})=>{const i=new Set(n),l=e.channels.onSet(async d=>{if(i.has(d.key)){if(s!=null){const x=P.Iw.aliasKey({range:s,channel:d.key});let p=e.rangeAliases.get(x);if(p==null)try{p={alias:await r.ranges.retrieveAlias(s,d.key),channel:d.key,range:s},e.rangeAliases.set(x,p)}catch(m){console.error(m)}p!=null&&(d.alias=p.alias)}t(x=>x.map(p=>p.key===d.key?d:p))}});if(s==null)return l;const a=e.rangeAliases.onSet(d=>{d!=null&&t(x=>x.map(p=>p.key===d.channel?r.channels.sugar({...p,alias:d.alias}):p))}),c=e.rangeAliases.onDelete(d=>{const x=P.Iw.decodeDeleteAliasChange(d);t(p=>p.map(m=>m.key===x.channel?r.channels.sugar({...m,alias:void 0}):m))});return[l,a,c]}}),qa=async({client:e,store:t,set:n,value:s})=>{const r=await e.channels.create(s());t.channels.set(r.key,r),n("key",r.key)},Qa=({store:e,get:t,reset:n})=>e.channels.onSet(s=>{t("key").value===s.key&&n(Wa(s))}),S0=Dt({name:"Channel",schema:Er,initialValues:yr,retrieve:Xa,update:qa,mountListeners:Qa}),R0=Dt({name:"Calculated Channel",schema:Ua,initialValues:yr,retrieve:Xa,update:qa,mountListeners:Qa}),C0={internal:!1},Cr=Ke({name:"Channels",retrieveCached:({params:e,store:t})=>e.searchTerm!=null&&e.searchTerm.length>0?[]:t.channels.get(n=>!(e.internal!=null&&n.internal!==e.internal||e.calculated!=null&&n.isCalculated!==e.calculated||u.O$1.isNonZero(e.notDataTypes)&&e.notDataTypes.some(s=>new P.I(s).equals(n.dataType))||u.O$1.isNonZero(e.dataTypes)&&!e.dataTypes.some(s=>new P.I(s).equals(n.dataType))||e.isIndex!=null&&n.isIndex!==e.isIndex||e.virtual!=null&&n.virtual!==e.virtual)),retrieve:async({client:e,params:t,store:n})=>{const s=await e.channels.retrieve({...C0,...t});return n.channels.set(s),s},retrieveByKey:async({client:e,key:t,store:n})=>await Sr({client:e,params:{key:t},store:n}),mountListeners:({store:e,onChange:t,onDelete:n})=>[e.channels.onSet(s=>t(s.key,s)),e.channels.onDelete(s=>n(s))]}),w0=Qe({name:"Channel",update:async({client:e,value:t,store:n})=>{const s=await e.channels.create(t);n.channels.set(s.key,s)}}),b0=Qe({name:"Channel",update:async({client:e,value:t,store:n,params:{key:s}})=>{s!=null&&(await e.channels.rename(s,t),n.channels.set(s,r=>r==null?r:e.channels.sugar({...r,name:t})))}}),Ja=Qe({name:"Channel Alias",update:async({client:e,value:t,store:n,params:{rangeKey:s,channelKey:r}})=>{if(s==null)return;const i={alias:t,channel:r,range:s};await e.ranges.setAlias(s,r,t),n.rangeAliases.set(P.Iw.aliasKey(i),i)}}),ec=e=>{if(e==null)return f.Channel;if(P.ow.isCalculated(e))return f.Calculation;if(e.isIndex)return f.Index;const t=new u.n(e.dataType);return t.isInteger?f.Binary:t.isFloat?f.Decimal:t.equals(u.n.STRING)?f.String:t.equals(u.n.JSON)?f.JSON:f.Channel},tc=f.renderProp(({itemKey:e,...t})=>{const n=f.useItem(e),s=ec(n?.payload);return o.jsxRuntimeExports.jsxs(f.ListItem,{itemKey:e,...t,children:[o.jsxRuntimeExports.jsx(s,{}),n?.name]})}),v0=({onChange:e,value:t,emptyContent:n,initialParams:s,filter:r,...i})=>{const{data:l,retrieve:a,getItem:c,subscribe:d,status:x}=Cr({initialParams:s,filter:r}),{fetchMore:p,search:m}=nt.usePager({retrieve:a});return o.jsxRuntimeExports.jsx(Ms,{resourceName:"Channel",value:t,onChange:e,data:l,haulType:vt,getItem:c,subscribe:d,onFetchMore:p,onSearch:m,emptyContent:n,status:x,icon:o.jsxRuntimeExports.jsx(f.Channel,{}),...i,children:tc})},kt=({onChange:e,value:t,allowNone:n,emptyContent:s,initialParams:r,filter:i,...l})=>{const{data:a,retrieve:c,getItem:d,subscribe:x,status:p}=Cr({initialParams:r,filter:i}),{fetchMore:m,search:h}=nt.usePager({retrieve:c});return o.jsxRuntimeExports.jsx(Ot,{resourceName:"Channel",onChange:e,value:t,allowNone:n,emptyContent:s,onFetchMore:m,onSearch:h,data:a,getItem:d,subscribe:x,status:p,haulType:vt,icon:o.jsxRuntimeExports.jsx(f.Channel,{}),...l,children:tc})},_0=Object.freeze(Object.defineProperty({__proto__:null,AliasInput:Zg,FLUX_STORE_CONFIG:Ga,FLUX_STORE_KEY:Ya,LinePlot:$1,SelectMultiple:v0,SelectSingle:kt,ZERO_FORM_VALUES:yr,calculatedFormSchema:Ua,formSchema:Er,rename:b0,resolveIcon:ec,retrieve:Rr,retrieveMany:y0,update:w0,updateAlias:Ja,useCalculatedForm:R0,useForm:S0,useList:Cr,useListenForCalculationStatus:j0},Symbol.toStringTag,{value:"Module"})),nc=({yDirection:e="up",...t})=>o.jsxRuntimeExports.jsxs(pe.Buttons,{...t,keys:u.p.DIRECTIONS,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"x",children:o.jsxRuntimeExports.jsx(f.Arrow.Right,{})}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"y",children:e==="up"?o.jsxRuntimeExports.jsx(f.Arrow.Up,{}):o.jsxRuntimeExports.jsx(f.Arrow.Down,{})})]}),k0=Object.freeze(Object.defineProperty({__proto__:null,Select:nc},Symbol.toStringTag,{value:"Module"})),sc="devices",L0={channel:P.bw.SET_CHANNEL_NAME,schema:P.bw.deviceZ,onChange:({store:e,changed:t})=>e.devices.set(t.key,n=>n==null?t:{...t,status:n.status})},M0={channel:P.bw.DELETE_CHANNEL_NAME,schema:P.bw.keyZ,onChange:({store:e,changed:t})=>e.devices.delete(t)},N0={channel:P.bw.STATUS_CHANNEL_NAME,schema:P.bw.statusZ,onChange:({store:e,changed:t})=>{e.devices.set(t.details.device,n=>n==null?n:{...n,status:t})}},oc={listeners:[L0,M0,N0]},P0=e=>{const t=He();j.useEffect(()=>t.devices.onSet(e),[t])},rc=async(e,t,n)=>{const s=t.devices.get(n.key);if(s!=null)return s;const r=await e.hardware.devices.retrieve({...n,includeStatus:!0});return t.devices.set(n.key,r),r},T0=()=>qe({name:"Device",retrieve:async({client:e,params:t,store:n})=>await rc(e,n,t),mountListeners:({store:e,onChange:t,params:{key:n}})=>[e.devices.onSet(s=>t(s),n)]}),ic=Ke({name:"Devices",retrieveCached:({store:e,params:t})=>e.devices.get(n=>!(u.O$1.isNonZero(t.makes)&&!t.makes.includes(n.make)||u.O$1.isNonZero(t.models)&&!t.models.includes(n.model)||u.O$1.isNonZero(t.racks)&&!t.racks.includes(n.rack)||u.O$1.isNonZero(t.locations)&&!t.locations.includes(n.location)||u.O$1.isNonZero(t.names)&&!t.names.includes(n.name)||u.O$1.isNonZero(t.keys)&&!t.keys.includes(n.key))),retrieve:async({client:e,params:t,store:n})=>{const s=await e.hardware.devices.retrieve({includeStatus:!0,...t});return s.forEach(r=>n.devices.set(r.key,r)),s},retrieveByKey:async({client:e,key:t,store:n})=>await rc(e,n,{key:t}),mountListeners:({store:e,onChange:t,onDelete:n})=>[e.devices.onSet(s=>t(s.key,s)),e.devices.onDelete(n)]}),I0=f.renderProp(({itemKey:e,...t})=>{const n=f.useItem(e);return o.jsxRuntimeExports.jsxs(f.ListItem,{itemKey:e,...t,className:u.CSS.BE("device","list-item"),justify:"between",align:"center",children:[o.jsxRuntimeExports.jsxs(f.Text,{align:"center",children:[o.jsxRuntimeExports.jsx(lc,{status:n?.status}),n?.name]}),o.jsxRuntimeExports.jsx(rr,{level:"small",color:9,weight:450,style:{marginTop:"0.25rem"},gap:"tiny",children:n?.location.split(".").map(s=>o.jsxRuntimeExports.jsx(Rn,{children:s},s))})]})}),O0=({onChange:e,value:t,filter:n,allowNone:s,emptyContent:r,initialParams:i,disabled:l,icon:a=o.jsxRuntimeExports.jsx(f.Device,{}),...c})=>{const{data:d,retrieve:x,getItem:p,subscribe:m,status:h}=ic({filter:n,initialParams:i}),{fetchMore:g,search:E}=nt.usePager({retrieve:x});return o.jsxRuntimeExports.jsx(Ot,{resourceName:"Device",value:t,onChange:e,data:d,getItem:p,subscribe:m,onFetchMore:g,onSearch:E,emptyContent:r,status:h,disabled:l,icon:a,...c,children:I0})},lc=({status:e,tooltipLocation:t="right"})=>{const n=e?.variant??"disabled",s=e?.message??"Device Status Unknown";return o.jsxRuntimeExports.jsxs(f.Dialog$1,{location:t,children:[o.jsxRuntimeExports.jsx(f.Summary,{variant:n,hideIcon:!0,level:"small",weight:450,children:s}),o.jsxRuntimeExports.jsx(nr,{variant:n,className:u.CSS.BE("device","status-indicator")})]})},A0=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:oc,FLUX_STORE_KEY:sc,SelectSingle:O0,StatusIndicator:lc,retrieve:T0,useList:ic,useSetSynchronizer:P0},Symbol.toStringTag,{value:"Module"})),ac="racks",D0={channel:P.vw.SET_CHANNEL_NAME,schema:P.vw.keyZ,onChange:async({store:e,changed:t,client:n})=>{const s=await n.hardware.racks.retrieve({key:t,includeStatus:!0});e.racks.set(t,s.payload)}},B0={channel:P.vw.DELETE_CHANNEL_NAME,schema:P.vw.keyZ,onChange:({store:e,changed:t})=>e.racks.delete(t)},$0={channel:P.vw.STATUS_CHANNEL_NAME,schema:P.vw.statusZ,onChange:({store:e,changed:t})=>e.racks.set(t.details.rack,n=>n==null?n:{...n,status:t})},cc={listeners:[D0,B0,$0]},uc={includeStatus:!0},dc=async({client:e,params:t,store:n})=>{let s=n.racks.get(t.key);return s==null&&(s=await e.hardware.racks.retrieve({...uc,...t}),n.racks.set(s.key,s)),s},xc=Ke({name:"Racks",retrieveCached:({store:e})=>e.racks.list(),retrieve:async({client:e,params:t,store:n})=>{const s=await e.hardware.racks.retrieve({...uc,...t});return n.racks.set(s),s},retrieveByKey:async({client:e,key:t,store:n})=>await dc({client:e,params:{key:t},store:n}),mountListeners:({store:e,onChange:t,onDelete:n})=>[e.racks.onSet(s=>t(s.key,s)),e.racks.onDelete(n)]}),z0=qe({name:"Rack",retrieve:dc,mountListeners:({store:e,onChange:t,params:{key:n}})=>[e.racks.onSet(t,n)]}),V0=f.renderProp(e=>{const{itemKey:t}=e,n=f.useItem(t);return o.jsxRuntimeExports.jsxs(f.ListItem,{...e,align:"center",justify:"between",children:[o.jsxRuntimeExports.jsx(f.Text,{children:n?.name}),o.jsxRuntimeExports.jsx(pc,{status:n?.status,tooltipLocation:"left"})]})}),F0=({value:e,onChange:t,filter:n,allowNone:s,emptyContent:r,initialParams:i,...l})=>{const{data:a,retrieve:c,getItem:d,subscribe:x,status:p}=xc({initialParams:{includeStatus:!0,...i},filter:n}),{fetchMore:m,search:h}=nt.usePager({retrieve:c});return o.jsxRuntimeExports.jsx(Ot,{resourceName:"Driver",value:e,onChange:t,data:a,getItem:d,subscribe:x,onFetchMore:m,onSearch:h,emptyContent:r,status:p,icon:o.jsxRuntimeExports.jsx(f.Rack,{}),...l,children:V0})},pc=({status:e,tooltipLocation:t="right"})=>{const n=j.useRef(null),s=e?.variant??"disabled";return j.useEffect(()=>{if(s!=="success")return;const r=n.current;r&&(r.classList.remove(u.CSS.BEM("rack","heartbeat","beat")),requestAnimationFrame(()=>r.classList.add(u.CSS.BEM("rack","heartbeat","beat"))))},[e]),o.jsxRuntimeExports.jsxs(f.Dialog$1,{location:t,children:[o.jsxRuntimeExports.jsx(f.Summary,{variant:s,hideIcon:!0,level:"small",weight:450,children:e?.message}),o.jsxRuntimeExports.jsx(f.Heart,{ref:n,className:u.CSS.BE("rack","heartbeat"),style:{color:tr[s]}})]})},H0=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:cc,FLUX_STORE_KEY:ac,SelectSingle:F0,StatusIndicator:pc,retrieve:z0,useList:xc},Symbol.toStringTag,{value:"Module"})),mc="tasks",Z0=["start","stop"],K0={channel:P.Ow.SET_CHANNEL_NAME,schema:P.Ow.keyZ,onChange:async({store:e,changed:t,client:n})=>e.tasks.set(t,await n.hardware.tasks.retrieve({key:t,includeStatus:!0}))},Y0={channel:P.Ow.DELETE_CHANNEL_NAME,schema:P.Ow.keyZ,onChange:({store:e,changed:t})=>e.tasks.delete(t)},G0=P.Ow.statusZ(te.z.unknown()),U0={channel:P.Ow.STATUS_CHANNEL_NAME,schema:G0,onChange:async({store:e,changed:t,client:n})=>{if(!e.tasks.has(t.details.task)){const r=await n.hardware.tasks.retrieve({key:t.details.task});e.tasks.set(t.details.task,r)}e.tasks.set(t.details.task,r=>r==null?r:n.hardware.tasks.sugar({...r,status:t}))}},W0={channel:P.Ow.COMMAND_CHANNEL_NAME,schema:P.Ow.commandZ,onChange:({store:e,changed:t,client:n})=>e.tasks.set(t.task,s=>s==null||!Z0.includes(t.type)?s:n.hardware.tasks.sugar({...s,status:{...s.status,variant:"loading",message:`Running ${t.type} command...`,details:{task:t.task,running:!0,data:{}}}}))},X0=e=>{const t=He();j.useEffect(()=>t.tasks.onSet(n=>{n.status!=null&&e(n.status)}),[t])},fc={listeners:[K0,Y0,U0,W0]},wr=async(e,t,n,s)=>{const r=t.tasks.get(n.key);if(r!=null)return r;const i=await e.hardware.tasks.retrieve({...n,includeStatus:!0,schemas:s});return t.tasks.set(n.key,i),i},q0=e=>qe({name:"Task",retrieve:async({client:t,params:n,store:s})=>n.key==null?null:await wr(t,s,{key:n.key,includeStatus:!0},e),mountListeners:({store:t,params:{key:n},onChange:s})=>[t.tasks.onSet(r=>{n==null||r.key!==n||s(r)},n)]}),Q0=Ke({name:"Task",retrieveCached:({store:e})=>e.tasks.list(),retrieve:async({client:e,params:t,store:n})=>{const s=await e.hardware.tasks.retrieve({includeStatus:!0,...t});return s.forEach(r=>n.tasks.set(r.key,r)),s},retrieveByKey:async({client:e,key:t,store:n})=>await wr(e,n,{key:t}),mountListeners:({store:e,onChange:t,onDelete:n})=>[e.tasks.onSet(s=>t(s.key,s)),e.tasks.onDelete(n)]}),J0=e=>te.z.object({key:P.Ow.keyZ.optional(),name:te.z.string(),rackKey:te.z.number(),type:e.typeSchema,snapshot:te.z.boolean(),config:e.configSchema,status:P.Ow.statusZ(e.statusDataSchema).optional().nullable()}),Un=e=>({key:e.key,name:e.name,rackKey:e.key==null?0:P.Ow.rackKey(e.key),type:e.type,config:e.config,status:e.status,snapshot:e.snapshot??!1}),ej=({schemas:e,initialValues:t})=>{const n=J0(e),s=Un(t);return Dt({name:"Task",schema:n,initialValues:s,retrieve:async({client:r,store:i,params:{key:l},reset:a})=>{l!=null&&a(Un(await wr(r,i,{key:l},e)))},update:async({client:r,params:i,store:l,...a})=>{const c=a.value(),x=await(await r.hardware.racks.retrieve({key:c.rackKey})).createTask({key:i.key,name:c.name,type:c.type,config:c.config});l.tasks.set(x.key,m=>m==null?m:(x.status=m.status,x));const p=Un(x.payload);a.set("key",p.key),a.set("name",p.name),a.set("rackKey",p.rackKey),a.set("type",p.type),a.set("config",p.config),a.set("snapshot",p.snapshot)},mountListeners:({store:r,get:i,reset:l})=>[r.tasks.onSet(a=>{const c=i("key",{optional:!0})?.value;c==null||c!==a.key||l(Un(a))})]})},tj=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:fc,FLUX_STORE_KEY:mc,createForm:ej,createRetrieveQuery:q0,useList:Q0,useStatusSynchronizer:X0},Symbol.toStringTag,{value:"Module"})),hc="labels",nj={channel:P.Sw.SET_CHANNEL_NAME,schema:P.Sw.labelZ,onChange:({store:e,changed:t})=>e.labels.set(t.key,t)},sj={channel:P.Sw.DELETE_CHANNEL_NAME,schema:P.Sw.keyZ,onChange:({store:e,changed:t})=>e.labels.delete(t)},gc={listeners:[nj,sj]},Xt=(e,t)=>P.ew.matchRelationship(e,{from:t,type:P.Sw.LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE}),jc=qe({name:"Labels",retrieve:async({client:e,params:{id:t}})=>await e.labels.retrieve({for:t}),mountListeners:({client:e,store:t,params:{id:n},onChange:s})=>[t.labels.onSet(r=>{s(i=>{const l=i.filter(a=>a.key!==r.key);return l.length===i.length?i:[...l,r]})}),t.labels.onDelete(r=>s(i=>i.filter(l=>l.key!==r))),t.relationships.onSet(async r=>{if(!Xt(r,n))return;const{key:i}=r.to,l=await e.labels.retrieve({key:i});t.labels.set(i,l),s(a=>[...a.filter(c=>c.key!==i),l])}),t.relationships.onDelete(r=>{const i=P.ew.relationshipZ.parse(r);Xt(i,n)&&s(l=>l.filter(a=>a.key!==i.to.key))})]}),br=Ke({name:"Labels",retrieve:async({client:e,params:t})=>await e.labels.retrieve(t),retrieveByKey:async({client:e,key:t})=>await e.labels.retrieve({key:t}),mountListeners:({store:e,onChange:t,onDelete:n,params:{keys:s}})=>{const r=s?new Set(s):void 0;return[e.labels.onSet(async i=>{r!=null&&!r.has(i.key)||t(i.key,i,{mode:"prepend"})}),e.labels.onDelete(async i=>n(i))]}}),Ec=P.Sw.labelZ.partial({key:!0}),oj=Dt({name:"Label",initialValues:{name:"",color:"#000000"},schema:Ec,retrieve:async({client:e,params:{key:t},reset:n})=>{t!=null&&n(await e.labels.retrieve({key:t}))},update:async({client:e,value:t,reset:n})=>{const s=await e.labels.create(t());n(s)},mountListeners:({store:e,params:{key:t},reset:n})=>[e.labels.onSet(async s=>{t==null||s.key!==t||n(s)},t)]}),rj=Qe({name:"Label",update:async({client:e,params:{key:t}})=>await e.labels.delete(t)}).useDirect,vr="label",ij=({itemKey:e,...t})=>{const n=f.useItem(e),{selected:s,onSelect:r,hovered:i}=f.useItemState(e);return n==null?null:o.jsxRuntimeExports.jsx(f.Item,{itemKey:e,onSelect:r,selected:s,hovered:i,...t,children:o.jsxRuntimeExports.jsxs(f.Text,{align:"center",children:[o.jsxRuntimeExports.jsx(f.Circle,{color:n?.color,size:"2.5em"}),n?.name]})})},yc=f.renderProp(ij),lj=f.renderProp(e=>{const{itemKey:t}=e,n=f.useItem(t),{onSelect:s}=f.useItemState(t);return n==null?null:o.jsxRuntimeExports.jsx(Ns,{color:n.color,onClose:s,size:"small",children:n.name})}),aj={variant:"text"},cj=({onChange:e,value:t,emptyContent:n,filter:s,initialParams:r,...i})=>{const{data:l,retrieve:a,getItem:c,subscribe:d,status:x}=br({filter:s,initialParams:r}),{fetchMore:p,search:m}=nt.usePager({retrieve:a});return o.jsxRuntimeExports.jsx(Ms,{resourceName:"Label",haulType:vr,value:t,onChange:e,data:l,getItem:c,subscribe:d,onFetchMore:p,onSearch:m,emptyContent:n,status:x,renderTag:lj,icon:o.jsxRuntimeExports.jsx(f.Label,{}),triggerProps:aj,variant:"floating",...i,children:yc})},uj=({onChange:e,value:t,allowNone:n,emptyContent:s,filter:r,initialParams:i,...l})=>{const{data:a,retrieve:c,getItem:d,subscribe:x,status:p}=br({filter:r,initialParams:i}),{fetchMore:m,search:h}=nt.usePager({retrieve:c});return o.jsxRuntimeExports.jsx(Ot,{resourceName:"Label",value:t,onChange:e,data:a,getItem:d,subscribe:x,allowNone:n,onFetchMore:m,onSearch:h,emptyContent:s,status:p,haulType:vr,...l,children:yc})},dj=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:gc,FLUX_STORE_KEY:hc,HAUL_TYPE:vr,SelectMultiple:cj,SelectSingle:uj,formSchema:Ec,matchRelationship:Xt,retrieveLabelsOf:jc,useDelete:rj,useForm:oj,useList:br},Symbol.toStringTag,{value:"Module"})),Is=new Error("Tab not found"),xj=new Error("Invalid Mosaic"),ds=(e,t,n="center",s,r)=>{if(e=Ze(e),s===void 0)return Lo(e,t);const i=Mo(e,s);if(n==="center")return i.tabs||=[],r!==void 0&&r>=0&&r<=i.tabs.length?i.tabs.splice(r,0,t):i.tabs.push(t),i.selected=t.tabKey,e;const l=i.key*2,a=i.key*2+1,c=n==="top"||n==="left"?l:a;if(Mo(e,c).key!==i.key)return ds(e,t,"center",c);if(i.tabs==null||i.tabs.length===0)return ds(e,t,"center",s);const[d,x,p]=jj(n);if(i.direction=p,i[d]={key:0,tabs:[t],selected:t.tabKey},i[x]={key:0,tabs:i.tabs,selected:i.selected},i.first==null||i.last==null)throw xj;return i.first.key=l,i.last.key=a,i.tabs=void 0,i.size=void 0,i.selected=void 0,e},pj=(e,t,n)=>{e=Ze(e);const[s,r]=Lt(e,t);if(s==null||r==null)throw Is;return r.tabs=r.tabs?.map(i=>i.tabKey===t?n(i):i),e},Lo=(e,t)=>(e=Ze(e),e.tabs!=null?(e.tabs.push(t),e.selected=t.tabKey,e):(e.first!=null?e.first=Lo(e.first,t):e.last!=null&&(e.last=Lo(e.last,t)),e)),xs=e=>{e=Ze(e);const t=[];if(e.tabs!=null&&(e.selected=Me.resetSelection(e.selected,e.tabs),e.selected!=null&&t.push(e.selected)),e.first!=null){const[n,s]=xs(e.first);e.first=n,t.push(...s)}if(e.last!=null){const[n,s]=xs(e.last);e.last=n,t.push(...s)}return[e,t]},_r=(e,t)=>{e=Ze(e);const[,n]=Lt(e,t);if(n==null)return[e,null];n.tabs=n.tabs?.filter(r=>r.tabKey!==t),n.selected=Me.resetSelection(n.selected,n.tabs),e=gj(e);const s=n.selected??ps(e);return[e,s]},ps=e=>e.selected!=null?e.selected:e.first!=null?ps(e.first):e.last!=null?ps(e.last):null,Sc=(e,t)=>{e=Ze(e);const[n,s]=Lt(e,t);if(n==null||s==null)throw Is;return s.selected=t,e},Rc=(e,t,n,s,r)=>{e=Ze(e);const[i,l]=Lt(e,t);if(i==null||l==null)throw Is;const[a,c]=_r(e,t);return[ds(a,i,n,s,r),c]},Cn=(e,t)=>{if(e.tabs!=null)return e.tabs.some(n=>n.tabKey===t)?e:void 0;if(e.first!=null){const n=Cn(e.first,t);if(n!=null)return n}if(e.last!=null){const n=Cn(e.last,t);if(n!=null)return n}},Cc=(e,t,n)=>{const s=ms(e,t);if(s==null)throw new Error("Node not found");return s.size=n,e},mj=(e,t,n)=>{e=Ze(e);const s=Cn(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,c={key:s.key*2+1,tabs:[i],selected:i.tabKey},d={key:l,tabs:s.tabs,selected:s.selected};return d.selected=Me.resetSelection(d.selected,d.tabs),s.direction=n,s.first=d,s.last=c,s.tabs=void 0,s.selected=void 0,e},fj=(e,t)=>{const n=Cn(e,t);return n==null?!1:n.tabs!=null&&n.tabs.length>1},wc=(e,t,n)=>{e=Ze(e);const[,s]=Lt(e,t);if(s?.tabs==null)throw Is;return s.tabs=Me.rename(t,n,s?.tabs??[]),e},hj=e=>e.tabs!=null?e.tabs.length===0:e.first==null&&e.last==null,Mo=(e,t)=>{const n=ms(e,t);if(n!=null)return n;const s=Math.floor(t/2);return s===0?e:Mo(e,s)},gj=e=>{let t=!0;for(;t;)[e,t]=No(e);return e=To(e,1),e},No=e=>{if(e.first==null||e.last==null)return[e,!1];if(_i(e.first))return[vi(e.last),!0];if(_i(e.last))return[vi(e.first),!0];let t,n;return[e.first,t]=No(e.first),[e.last,n]=No(e.last),[e,t||n]},vi=e=>(e.size=void 0,e),_i=e=>e.first==null&&e.last==null&&(e.tabs==null||e.tabs.length===0),Lt=(e,t)=>{if(e.tabs!=null){const l=e.tabs.find(a=>a.tabKey===t);if(l!=null)return[l,e]}if(e.first==null||e.last==null)return[void 0,void 0];const[n,s]=Lt(e.first,t);if(n!=null&&s!=null)return[n,s];const[r,i]=Lt(e.last,t);return[r,i]},ms=(e,t)=>{if(e.key===t)return e;if(e.first==null||e.last==null)return;const n=ms(e.first,t);return n??ms(e.last,t)},jj=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")}},Ze=e=>({...e,first:e.first!=null?Ze(e.first):void 0,last:e.last!=null?Ze(e.last):void 0}),fs=(e,t,n=[])=>(n.push(t(e)),e.first!=null&&fs(e.first,t,n),e.last!=null&&fs(e.last,t,n),n),Po=(e,t)=>{t(e),e.first!=null&&Po(e.first,t),e.last!=null&&Po(e.last,t)},To=(e,t)=>(e=Ze(e),e.key=t,e.first!=null&&(e.first=To(e.first,t*2)),e.last!=null&&(e.last=To(e.last,t*2+1)),e);class bc{parent;stub;el;constructor(t={}){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 Ej=({node:e})=>{const t=j.createRef(),n=j.useRef(e);return j.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)}},[]),j.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})},vc=({node:e,children:t})=>zl.createPortal(t,e.el),yj=Object.freeze(Object.defineProperty({__proto__:null,In:vc,Node:bc,Out:Ej},Symbol.toStringTag,{value:"Module"})),hs=j.memo(({root:e,onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,activeTab:l,emptyContent:a,onSelect:c,onClose:d,onRename:x,onReorder:p,contextMenu:m,addTooltip:h,className:g,...E})=>{const{tabs:S,direction:R,first:v,last:y,key:C,size:_}=e,M={onDrop:t,onResize:n,onCreate:s,onFileDrop:r,children:i,onClose:d,contextMenu:m,onSelect:c,onRename:x,onReorder:p,activeTab:l,addTooltip:h},I=j.useCallback(([$])=>n(C,$),[n]),{props:A}=Ql({direction:R,onResize:I,count:2,initialSizes:_!=null?[_]:void 0});let B={};C==1&&(B={...E,className:u.CSS(u.CSS.B("mosaic"),g)});let z;return S!==void 0?z=o.jsxRuntimeExports.jsx(_c,{root:e,emptyContent:a,...B,...M}):v!=null&&y!=null?z=o.jsxRuntimeExports.jsxs(Jl,{id:`mosaic-${C}`,align:"stretch",...A,...B,children:[o.jsxRuntimeExports.jsx(hs,{...M,root:v,onResize:n},v.key),o.jsxRuntimeExports.jsx(hs,{...M,root:y,onResize:n},y.key)]}):(z=null,console.warn("Mosaic tree is malformed")),z});hs.displayName="Mosaic";const gs="pluto-mosaic-tab-drop",kr="pluto-mosaic-tab-create",Sj=(e,t,n)=>{if(f.filterByType(f.FILE_TYPE,t).length>0&&n)return!0;const r=f.filterByType(gs,t).map(a=>a.key),i=e.filter(a=>!r.includes(a.tabKey)).length>0;return f.filterByType(kr,t).length>0||r.length>0&&(i||e.length===0)},_c=j.memo(({root:e,onDrop:t,onCreate:n,activeTab:s,children:r,className:i,onReorder:l,onFileDrop:a,addTooltip:c,...d})=>{const{key:x,tabs:p}=e,[m,h]=j.useState(null),g=a!=null,E=j.useCallback(({items:B})=>Sj(p,B,g),[p,g]),S=j.useCallback(({items:B,event:z})=>{if(z==null)return[];const $=Cj(z);h(null);const D=f.filterByType(f.FILE_TYPE,B).length>0,{percents:V}=ki(z),b=p.length===0?"center":Li(V);if(D)return a?.(x,b,z),B;const k=f.filterByType(gs,B);if(k.length>0){const N=k.map(({key:F})=>F)[0];t(x,N,b,$)}const L=f.filterByType(kr,B);if(L.length>0){const N=L.map(({key:F})=>F);n?.(x,b,N)}return k},[t,p.length]),R=j.useCallback(({event:B})=>{if(B==null)return;const{percents:z,inSelector:$}=ki(B);let D=null;$||(D=p.length===0?"center":Li(z)),h(D)},[p.length]),{startDrag:v,...y}=f.useDragAndDrop({type:"Mosaic",canDrop:E,onDrop:S,onDragOver:R}),C=E(f.useDraggingState()),_=j.useCallback(()=>h(null),[]),M=j.useCallback((B,{tabKey:z})=>{v([{key:z,type:gs,elementID:B.currentTarget.id}])},[v]),I=j.useCallback(()=>n?.(x,"center"),[x]),A=x==1&&p.length==0;return o.jsxRuntimeExports.jsx(o.jsxRuntimeExports.Fragment,{children:o.jsxRuntimeExports.jsxs(Me.Tabs,{id:`tab-${x}`,tabs:p,className:u.CSS(i,A&&m!=null&&u.CSS.M("drag-over")),onDragLeave:_,selected:e.selected,selectedAltColor:s===e.selected,onDragStart:M,onCreate:I,addTooltip:c,...y,...d,children:[e.selected!=null&&r(p.find(B=>B.tabKey===e.selected)),C&&o.jsxRuntimeExports.jsx("div",{style:{zIndex:1e3,position:"absolute",top:0,left:0,width:"100%",height:"100%"}}),m!=null&&o.jsxRuntimeExports.jsx("div",{className:u.CSS.BE("mosaic","mask"),style:Rj[m]})]})})});_c.displayName="MosaicTabLeaf";const Rj={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%"}},ki=e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;return s<24?{percents:{x:.5,y:.5},inSelector:!0}:{percents:{x:n/t.width,y:s/t.height},inSelector:!1}},Cj=e=>{const t=e.target.closest(".pluto-tabs-selector__btn");if(t!=null)return Array.from(t.parentElement?.children??[]).indexOf(t)},wj=e=>e,bj=e=>1-e,Li=({x:e,y:t})=>{if(e>.33&&e<.66&&t>.33&&t<.66)return"center";const[n,s]=[wj(e),bj(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")},vj=({root:e,onSelect:t,children:n})=>{const s=j.useRef(new Map),r=new Set,i=fs(e,l=>l.tabs?.map(a=>{let c=s.current.get(a.tabKey);return a==null?null:(c==null&&(c=new bc({style:"width: 100%; height: 100%; position: relative;"}),c.el.addEventListener("click",()=>t?.(a.tabKey)),s.current.set(a.tabKey,c)),r.add(a.tabKey),o.jsxRuntimeExports.jsx(vc,{node:c,children:n({...a,visible:a.tabKey===l.selected})},a.tabKey))})).flat().filter(l=>l!=null);return s.current.forEach((l,a)=>!r.has(a)&&s.current.delete(a)),[s,i]},Io=te.z.object({key:te.z.number(),tabs:te.z.array(Me.tabZ).optional(),selected:te.z.string().optional(),direction:u.p.direction.optional(),size:te.z.number().optional(),get first(){return Io.optional()},get last(){return Io.optional()}}),_j=({allowRename:e=!1,initialTree:t})=>{const[n,s]=j.useState(t);return j.useEffect(()=>s(xs(t)[0]),[t]),{root:n,onDrop:(d,x,p)=>s(m=>Rc(m,x,p,d)[0]),onClose:d=>s(x=>_r(x,d)[0]),onSelect:d=>s(x=>Sc(x,d)),onResize:(d,x)=>s(p=>Cc(p,d,x)),onRename:e?(d,x)=>s(p=>wc(p,d,x)):void 0}},kj=Object.freeze(Object.defineProperty({__proto__:null,HAUL_CREATE_TYPE:kr,HAUL_DROP_TYPE:gs,Mosaic:hs,autoSelectTabs:xs,canSplit:fj,findSelected:ps,findTabNode:Cn,forEachNode:Po,insertTab:ds,isEmpty:hj,mapNodes:fs,moveTab:Rc,nodeZ:Io,removeTab:_r,renameTab:wc,resizeNode:Cc,selectTab:Sc,split:mj,updateTab:pj,use:_j,usePortal:vj},Symbol.toStringTag,{value:"Module"})),Lj=({variant:e,className:t,...n})=>o.jsxRuntimeExports.jsx(f.Box,{className:u.CSS(t,u.CSS.B("note"),u.CSS.M(e)),align:"stretch",empty:!0,...n}),Mj=Object.freeze(Object.defineProperty({__proto__:null,Note:Lj},Symbol.toStringTag,{value:"Module"})),kc="relationships",Lc="resources",Nj={channel:P.ew.RELATIONSHIP_SET_CHANNEL_NAME,schema:P.ew.relationshipZ,onChange:({store:e,changed:t})=>e.relationships.set(P.ew.relationshipToString(t),t)},Pj={channel:P.ew.RELATIONSHIP_DELETE_CHANNEL_NAME,schema:P.ew.relationshipZ,onChange:({store:e,changed:t})=>e.relationships.delete(P.ew.relationshipToString(t))},Mc={listeners:[Nj,Pj]},Tj={channel:P.ew.RESOURCE_SET_CHANNEL_NAME,schema:P.ew.idZ,onChange:async({store:e,changed:t,client:n})=>e.resources.set(P.ew.idToString(t),await n.ontology.retrieve(t))},Ij={channel:P.ew.RESOURCE_DELETE_CHANNEL_NAME,schema:P.ew.idZ,onChange:({store:e,changed:t})=>e.resources.delete(t.key)},Nc={listeners:[Tj,Ij]},Oj=e=>{const t=He();j.useEffect(()=>t.resources.onSet(e),[t.resources])},Aj=e=>{const t=He();j.useEffect(()=>{const n=t.resources.onDelete(async s=>e(P.ew.idZ.parse(s)));return()=>n()},[t.resources])},Dj=e=>{const t=He();j.useEffect(()=>t.relationships.onSet(e),[t.relationships])},Bj=e=>{const t=He();j.useEffect(()=>t.relationships.onDelete(n=>e(P.ew.relationshipZ.parse(n))),[t.relationships])},Pc=e=>Ke({name:"useDependents",retrieve:async({client:t,params:{id:n}})=>n==null?[]:await t.ontology.retrieve([n],{children:e==="to",parents:e==="from"}),retrieveByKey:async({client:t,key:n})=>await t.ontology.retrieve(n),mountListeners:({store:t,onChange:n,onDelete:s,client:r,params:{id:i}})=>[t.relationships.onSet(async l=>{if(P.ew.matchRelationship(l,{type:"parent",[P.ew.oppositeRelationshipDirection(e)]:i})){const a=await r.ontology.retrieve(l[e]);n(a.key,a)}}),t.relationships.onDelete(l=>{const a=P.ew.relationshipZ.parse(l);P.ew.matchRelationship(a,{type:"parent",[P.ew.oppositeRelationshipDirection(e)]:i})&&s(P.ew.idToString(a[e]))}),t.resources.onSet(l=>n(l.key,a=>a==null?null:{...a,...l})),t.resources.onDelete(async l=>s(l))]}),$j=Pc("to"),zj=Ke({name:"useResourceList",retrieveCached:({store:e})=>e.resources.list(),retrieve:async({client:e,params:t,store:n})=>{const s=await e.ontology.retrieve(t);return s.forEach(r=>n.resources.set(r.key,r)),s},retrieveByKey:async({client:e,key:t,store:n})=>{const s=await e.ontology.retrieve(P.ew.idZ.parse(t));return n.resources.set(t,s),s},mountListeners:({store:e,onChange:t,onDelete:n})=>[e.resources.onSet(async s=>t(s.key,s)),e.resources.onDelete(async s=>n(s))]}),Vj=qe({name:"useParentID",retrieve:async({client:e,params:t})=>{const n=await e.ontology.retrieveParents(t.id);if(t.type==null)return n[0].id;const s=n.find(({id:r})=>r.type===t.type);return s==null?null:s.id},mountListeners:({store:e,onChange:t,client:n,params:{id:s}})=>[e.relationships.onSet(async r=>{if(P.ew.matchRelationship(r,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:s})){const i=await n.ontology.retrieve(r.from);t(i.id)}else t(null)}),e.relationships.onDelete(async r=>{const i=P.ew.relationshipZ.parse(r);P.ew.matchRelationship(i,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:s})&&t(null)})]}),Fj=Object.freeze(Object.defineProperty({__proto__:null,RELATIONSHIPS_FLUX_STORE_KEY:kc,RELATIONSHIP_FLUX_STORE_CONFIG:Mc,RESOURCES_FLUX_STORE_KEY:Lc,RESOURCE_FLUX_STORE_CONFIG:Nc,createDependentsListHook:Pc,retrieveParentID:Vj,useChildren:$j,useRelationshipDeleteSynchronizer:Bj,useRelationshipSetSynchronizer:Dj,useResourceDeleteSynchronizer:Aj,useResourceList:zj,useResourceSetSynchronizer:Oj},Symbol.toStringTag,{value:"Module"})),lo={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"})]})},Hj=({disabled:e=[],className:t,focused:n=!0,onMinimize:s,onMaximize:r,onFullscreen:i,onClose:l,...a})=>o.jsxRuntimeExports.jsxs(f.Box,{gap:1.5,x:!0,className:u.CSS(u.CSS.B("macos-controls"),!n&&u.CSS.BM("macos-controls","blurred"),t),...a,children:[o.jsxRuntimeExports.jsx(ao,{onClick:l,className:u.CSS.BM("macos-control","close"),disabled:e.includes("close"),children:lo.Close}),o.jsxRuntimeExports.jsx(ao,{onClick:s,className:u.CSS.BM("macos-control","minimize"),disabled:e.includes("minimize"),children:lo.Minimize}),o.jsxRuntimeExports.jsx(ao,{onClick:i,className:u.CSS.BM("macos-control","maximize"),disabled:e.includes("maximize"),children:lo.Maximize})]}),ao=({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,...s}),Zj=({disabled:e=[],onMinimize:t,onMaximize:n,onClose:s,onFullscreen:r,focused:i,contrast:l=2,...a})=>o.jsxRuntimeExports.jsxs(f.Box,{pack:!0,...a,children:[o.jsxRuntimeExports.jsx(co,{className:u.CSS.BM("windows-control","minimize"),onClick:t,disabled:e.includes("minimize"),contrast:l,children:o.jsxRuntimeExports.jsx(f.Subtract,{})}),o.jsxRuntimeExports.jsx(co,{className:u.CSS.BM("windows-control","maximize"),onClick:n,disabled:e.includes("maximize"),contrast:l,children:o.jsxRuntimeExports.jsx(f.Box$1,{})}),o.jsxRuntimeExports.jsx(co,{onClick:s,className:u.CSS.BM("windows-control","close"),disabled:e.includes("close"),contrast:l,children:o.jsxRuntimeExports.jsx(f.Close,{})})]}),co=({disabled:e=!1,className:t,...n})=>e?null:o.jsxRuntimeExports.jsx(f.Button,{className:u.CSS(u.CSS.B("windows-control"),t),tabIndex:-1,...n}),Tc=u.S.getOS,Kj="Windows",Yj=({forceOS:e,visibleIfOS:t,...n})=>{const s=Tc({force:e,default:Kj});if(t!=null&&t!==s)return null;const r=s==="macOS"?Hj:Zj;return o.jsxRuntimeExports.jsx(r,{...n})},Gj=Object.freeze(Object.defineProperty({__proto__:null,Controls:Yj,use:Tc},Symbol.toStringTag,{value:"Module"})),Uj=(e,t)=>{const n=s=>o.jsxRuntimeExports.jsx(e,{...t,...s});return n.displayName=e.displayName,n},Wj=Object.freeze(Object.defineProperty({__proto__:null,createComponent:Uj},Symbol.toStringTag,{value:"Module"}));j.createContext({instrumentation:P.O.NOOP});const Xj=({children:e,...t})=>{const{path:n}=f.useUnidirectional({type:P.Provider$1.TYPE,schema:P.providerStateZ,state:t});return o.jsxRuntimeExports.jsx(f.Composite,{path:n,children:e})},qj="groups",Qj={channel:P.Jm.SET_CHANNEL_NAME,schema:P.Jm.groupZ,onChange:({store:e,changed:t})=>e.groups.set(t.key,t)},Jj={channel:P.Jm.DELETE_CHANNEL_NAME,schema:P.Jm.keyZ,onChange:({store:e,changed:t})=>e.groups.delete(t)},e2={listeners:[Qj,Jj]};Qe({name:"Group",update:async({client:e,value:t,params:n})=>await e.ontology.groups.rename(n.key,t)}).useDirect;Qe({name:"Group",update:async({client:e,params:t})=>await e.ontology.groups.delete(t.key)}).useDirect;const t2="data:video/mp2t;base64,Ly8gQ29weXJpZ2h0IDIwMjUgU3lubmF4IExhYnMsIEluYy4KLy8KLy8gVXNlIG9mIHRoaXMgc29mdHdhcmUgaXMgZ292ZXJuZWQgYnkgdGhlIEJ1c2luZXNzIFNvdXJjZSBMaWNlbnNlIGluY2x1ZGVkIGluIHRoZSBmaWxlCi8vIGxpY2Vuc2VzL0JTTC50eHQuCi8vCi8vIEFzIG9mIHRoZSBDaGFuZ2UgRGF0ZSBzcGVjaWZpZWQgaW4gdGhhdCBmaWxlLCBpbiBhY2NvcmRhbmNlIHdpdGggdGhlIEJ1c2luZXNzIFNvdXJjZQovLyBMaWNlbnNlLCB1c2Ugb2YgdGhpcyBzb2Z0d2FyZSB3aWxsIGJlIGdvdmVybmVkIGJ5IHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAsCi8vIGluY2x1ZGVkIGluIHRoZSBmaWxlIGxpY2Vuc2VzL0FQTC50eHQuCgppbXBvcnQgeyBwbHV0byB9IGZyb20gIkAvcGx1dG8vYWV0aGVyIjsKCnBsdXRvLnJlbmRlcigpOwo=",Ic="rangeKV",Oc="rangeAliases",wn=async(e,t,n)=>{const s=t.ranges.get(n);if(s!=null)return s;const r=await e.ranges.retrieve({keys:[n],includeParent:!0,includeLabels:!0});return t.ranges.set(n,r[0]),r[0]},n2=async(e,t,n)=>{const s=await e.ranges.retrieve({...n,includeParent:!0,includeLabels:!0});return t.ranges.set(s),s},s2=e=>{const t=He();j.useEffect(()=>t.ranges.onSet(n=>e(n.payload)),[t])},Ac=async(e,t,n,s)=>{if(P.ew.matchRelationship(e,{from:{type:"range"},type:P.Sw.LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE,to:{type:"label"}})){let i=s.labels.get(e.to.key);i==null&&(i=await n.labels.retrieve({key:e.to.key}),s.labels.set(e.to.key,i)),t(e.from.key,l=>l==null?l:n.ranges.sugarOne({...l,labels:[...l.labels?.filter(a=>a.key!==e.to.key)??[],i]}))}},Dc=async(e,t,n,s)=>{if(P.ew.matchRelationship(e,{from:{type:"range"},type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:{type:"range"}})){const i=await n.ranges.retrieve(e.from.key);s.ranges.set(e.from.key,i),t(e.to.key,l=>l==null?l:n.ranges.sugarOne({...l,parent:i}))}},o2=Ke({name:"Range",retrieve:async({client:e,params:{key:t},store:n})=>{const s=await e.ontology.retrieveChildren(P.Iw.ontologyID(t),{types:["range"]});return s.length===0?[]:await n2(e,n,{keys:s.map(({id:{key:r}})=>r)})},retrieveByKey:async({client:e,key:t,store:n})=>await wn(e,n,t),mountListeners:({store:e,onChange:t,onDelete:n,client:s,params:{key:r}})=>[e.ranges.onSet(i=>{t(i.key,l=>l==null?l:s.ranges.sugarOne({...i,parent:i.parent??l.parent,labels:i.labels??l.labels}))}),e.ranges.onDelete(async i=>n(i)),e.relationships.onSet(async i=>{if(r==null)return;if(await Dc(i,t,s,e),await Ac(i,t,s,e),P.ew.matchRelationship(i,{from:P.Iw.ontologyID(r),type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:{type:"range"}})){const a=await s.ranges.retrieve({keys:[i.to.key],includeParent:!0,includeLabels:!0});return t(i.to.key,a[0])}}),e.relationships.onDelete(async i=>{if(r==null)return;const l=P.ew.relationshipZ.parse(i);if(P.ew.matchRelationship(l,{from:P.Iw.ontologyID(r),type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:{type:"range"}}))return n(l.to.key);l.type===P.Sw.LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE&&t(l.from.key,d=>d==null?d:s.ranges.sugarOne({...d,labels:d.labels?.filter(x=>x.key!==l.to.key)}))})]}),r2=qe({name:"Range",retrieve:async({client:e,params:{id:t}})=>{const s=(await e.ontology.retrieveParents(t)).find(({id:{type:r}})=>r==="range");return s==null?null:e.ranges.sugarOntologyResource(s)},mountListeners:({store:e,onChange:t,client:n,params:{id:s}})=>[e.ranges.onSet(r=>{t(i=>i==null||i.key!==r.key?i:n.ranges.sugarOne({...r,parent:r.parent??i.parent,labels:r.labels??i.labels}))}),e.relationships.onSet(async r=>{if(!P.ew.matchRelationship(r,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:s}))return;if(!(r.from.type==="range"))return t(null);const a=await wn(n,e,r.from.key);t(n.ranges.sugarOne(a.payload))}),e.relationships.onDelete(async r=>{const i=P.ew.relationshipZ.parse(r);P.ew.matchRelationship(i,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:s})&&t(null),P.ew.matchRelationship(i,{type:P.Sw.LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE,to:s})&&t(c=>c==null?c:n.ranges.sugarOne({...c,labels:c.labels?.filter(d=>d.key!==i.to.key)}))})]}),Bc=qe({name:"Range",retrieve:async({client:e,params:{key:t},store:n})=>await wn(e,n,t),mountListeners:({store:e,onChange:t,client:n,params:{key:s}})=>[e.ranges.onSet(async r=>{if(r!=null)return t(r)},s),e.relationships.onSet(async r=>{if(Xt(r,P.Iw.ontologyID(s))){const a=await n.labels.retrieve({key:r.to.key});e.labels.set(r.to.key,a),t(c=>c==null?c:n.ranges.sugarOne({...c,labels:[...(c.labels??[]).filter(d=>d.key!==a.key),a]}))}if(P.ew.matchRelationship(r,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:P.Iw.ontologyID(s)})){const a=await n.ranges.retrieve(r.from.key);e.ranges.set(r.from.key,a),t(c=>c==null?c:n.ranges.sugarOne({...c,parent:a}))}},s)]}),i2=Bc.useDirect,$c=te.z.object({...P.Iw.payloadZ.omit({timeRange:!0}).partial({key:!0}).shape,labels:te.z.array(P.Sw.keyZ),parent:te.z.string().optional(),timeRange:te.z.object({start:te.z.number(),end:te.z.number()})}),Oo=async e=>({...e.payload,timeRange:e.timeRange.numeric,parent:e.parent?.key,labels:e.labels?.map(t=>t.key)??[]}),l2={name:"",labels:[],parent:"",timeRange:{start:0,end:0}},a2=Dt({name:"Range",schema:$c,initialValues:l2,retrieve:async({client:e,params:{key:t},store:n,reset:s})=>{t!=null&&s(await Oo(await wn(e,n,t)))},update:async({client:e,value:t,reset:n,store:s})=>{const r=t(),i=r.parent,l=u.O$1.isNonZero(i)?P.Iw.ontologyID(i):void 0,a=await e.ranges.create(r,{parent:l});await e.labels.label(a.ontologyID,r.labels,{replace:!0});const c=s.labels.get(r.labels),d=new Set(c.map(m=>m.key)),x=r.labels.filter(m=>!d.has(m));if(x.length>0){const m=await e.labels.retrieve({keys:x});c.push(...m),s.labels.set(m)}let p=null;u.O$1.isNonZero(i)&&(p=await wn(e,s,i)),s.ranges.set(a.key,e.ranges.sugarOne({...a.payload,labels:c,parent:p?.payload??null})),n({...r,...a.payload,timeRange:a.timeRange.numeric,labels:r.labels,parent:r.parent})},mountListeners:({store:e,reset:t,get:n,set:s})=>[e.ranges.onSet(async r=>{const i=await Oo(r),l=n("key",{optional:!0})?.value;if(l==null||l!==r.key)return;const a=n("parent",{optional:!0})?.value,c=n("labels").value;t({...i,labels:c,parent:a})}),e.relationships.onSet(r=>{const i=n("key",{optional:!0})?.value;if(i==null)return;const l=P.Iw.ontologyID(i);if(Xt(r,l)){const d=n("labels").value;return s("labels",[...d.filter(x=>x!==r.to.key),r.to.key])}P.ew.matchRelationship(r,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:l})&&s("parent",r.from.key)}),e.relationships.onDelete(r=>{const i=n("key",{optional:!0})?.value;if(i==null)return;const l=P.ew.relationshipZ.parse(r),a=P.Iw.ontologyID(i);if(Xt(l,a))return s("labels",n("labels").value.filter(x=>x!==l.to.key));if(P.ew.matchRelationship(l,{type:P.ew.PARENT_OF_RELATIONSHIP_TYPE,to:a}))return s("parent",void 0)})]}),c2=e=>jc.useDirect({params:{id:P.Iw.ontologyID(e)}}),u2={includeParent:!0,includeLabels:!0},Lr=Ke({name:"Ranges",retrieveCached:({store:e,params:t})=>e.ranges.get(n=>u.O$1.isNonZero(t.keys)?t.keys.includes(n.key):!0),retrieve:async({client:e,params:t})=>await e.ranges.retrieve({...u2,...t}),retrieveByKey:async({client:e,key:t,store:n})=>{const s=n.ranges.get(t);if(s!=null)return s;const r=await e.ranges.retrieve(t);return n.ranges.set(t,r),r},mountListeners:({store:e,onChange:t,onDelete:n,client:s,params:{keys:r}})=>{const i=r!=null&&r.length>0,l=new Set(r);return[e.ranges.onSet(a=>{i&&!l.has(a.key)||t(a.key,c=>c==null?a:s.ranges.sugarOne({...a.payload,labels:a.labels??c.labels}))}),e.ranges.onDelete(async a=>n(a)),e.relationships.onSet(async a=>{await Dc(a,t,s,e),await Ac(a,t,s,e)})]}}),d2=te.z.object({pairs:te.z.array(te.z.object({key:te.z.string(),value:te.z.string()}))}),zc=te.z.string().transform(e=>e.split("<--->")).transform(([e,t])=>({key:t,range:e})),x2={channel:P.Iw.KV_SET_CHANNEL,schema:P.Iw.kvPairZ,onChange:({store:e,changed:t})=>{e.rangeKV.set(P.Iw.kvPairKey(t),t)}},p2={channel:P.Iw.KV_DELETE_CHANNEL,schema:zc,onChange:({store:e,changed:t})=>e.rangeKV.delete(P.Iw.kvPairKey(t))},Vc={listeners:[x2,p2]},m2=Ke({name:"Range Meta Data",retrieve:async({client:e,params:{rangeKey:t}})=>{const s=await e.ranges.getKV(t).list();return Object.entries(s).map(([r,i])=>({key:r,value:i,range:t}))},retrieveByKey:async({client:e,key:t,params:{rangeKey:n}})=>{if(n==null)return;const r=await e.ranges.getKV(n).get(t);return{key:t,value:r,range:n}},mountListeners:({store:e,onChange:t,onDelete:n,params:{rangeKey:s}})=>[e.rangeKV.onSet(r=>{r.range===s&&t(r.key,r)}),e.rangeKV.onDelete(r=>{const i=zc.parse(r);i.range===s&&n(i.key)})]}),Fc=P.Iw.kvPairZ,f2=Dt({name:"Range Meta Data",schema:Fc,retrieve:async()=>{},update:async({client:e,value:t})=>{const{key:n,value:s,range:r}=t();await e.ranges.getKV(r).set(n,s)},initialValues:{key:"",value:"",range:""}}),h2=Qe({name:"Range Meta Data",update:async({client:e,value:t,params:{rangeKey:n}})=>{await e.ranges.getKV(n).delete(t)}}),g2=Qe({name:"Range Meta Data",update:async({client:e,value:t,onChange:n})=>{await e.ranges.getKV(t.range).set(t.key,t.value),n(t)}}),j2=Qe({name:"Range",update:async({client:e,value:t,onChange:n,store:s})=>{const r=await e.ranges.create(t);s.ranges.set(r.key,r),n(r)}}),E2=Qe({name:"Range",update:async({client:e,value:t,store:n})=>{await e.ranges.delete(t),n.ranges.delete(t)}}),y2={channel:P.Iw.SET_ALIAS_CHANNEL_NAME,schema:P.Iw.aliasZ,onChange:({store:e,changed:t})=>{e.rangeAliases.set(P.Iw.aliasKey(t),t)}},S2=te.z.string().transform(e=>P.Iw.decodeDeleteAliasChange(e)),R2={channel:P.Iw.DELETE_ALIAS_CHANNEL_NAME,schema:S2,onChange:({store:e,changed:t})=>e.rangeAliases.delete(P.Iw.aliasKey(t))},Hc={listeners:[y2,R2]},Zc=({timeRange:e,level:t="p",color:n=9,showSpan:s=!1,...r})=>{const i=new u.r(e.start),l=i.isToday?"time":"dateTime",a=new u.r(e.end),c=a.equals(u.r.MAX),d=a.span(i)<u.i.DAY?"time":"dateTime",x=i.span(a),p=o.jsxRuntimeExports.jsxs(f.Text,{x:!0,align:"center",gap:"small",children:[i.isToday&&o.jsxRuntimeExports.jsx(f.Text,{level:t,color:n,weight:450,children:"Today"}),o.jsxRuntimeExports.jsx(f.DateTime,{el:"span",level:t,displayTZ:"local",format:l,color:n,weight:450,children:i})]}),m=o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[c?o.jsxRuntimeExports.jsx(f.Text,{level:t,el:"span",children:"Now"}):o.jsxRuntimeExports.jsx(f.DateTime,{level:t,el:"span",displayTZ:"local",format:d,color:n,weight:450,children:a}),!x.isZero&&s&&o.jsxRuntimeExports.jsxs(f.Text,{level:t,color:n,weight:450,el:"span",children:["(",i.span(a).truncate(u.i.MILLISECOND).toString(),")"]})]});return o.jsxRuntimeExports.jsxs(f.Text,{x:!0,gap:"small",className:u.CSS(u.CSS.B("time-range-chip")),align:"center",level:t,color:n,...r,children:[p,o.jsxRuntimeExports.jsx(f.Arrow.Right,{color:9}),m]})},Mr="range",Nr=j.memo(({itemKey:e,showParent:t=!0,showLabels:n=!0,...s})=>{const r=f.useItem(e);if(r==null)return null;const{name:i,parent:l,timeRange:a,labels:c}=r;return o.jsxRuntimeExports.jsxs(f.ListItem,{itemKey:e,justify:"between",...s,children:[o.jsxRuntimeExports.jsxs(rr,{children:[o.jsxRuntimeExports.jsx(Rn,{weight:450,color:10,children:i}),l!=null&&t&&o.jsxRuntimeExports.jsx(Rn,{weight:400,color:8,children:l.name})]}),o.jsxRuntimeExports.jsxs(f.Box,{x:!0,children:[o.jsxRuntimeExports.jsx(Zc,{level:"small",timeRange:a}),n&&o.jsxRuntimeExports.jsx(sr,{variant:"text",children:c?.map(d=>o.jsxRuntimeExports.jsx(Ns,{color:d.color,size:"small",children:d.name},d.key))})]})]})});Nr.displayName="Ranger.ListItem";const Kc=f.renderProp(Nr),Yc=o.jsxRuntimeExports.jsx(f.Range,{}),C2=({onChange:e,value:t,emptyContent:n,filter:s,initialParams:r,...i})=>{const{data:l,retrieve:a,getItem:c,subscribe:d,status:x}=Lr({filter:s,initialParams:r}),{fetchMore:p,search:m}=nt.usePager({retrieve:a});return o.jsxRuntimeExports.jsx(Ms,{resourceName:"Range",haulType:Mr,value:t,onChange:e,data:l,getItem:c,icon:Yc,subscribe:d,onFetchMore:p,onSearch:m,emptyContent:n,status:x,...i,children:Kc})},w2={style:{width:800}},b2=({onChange:e,value:t,filter:n,allowNone:s,emptyContent:r,initialParams:i,...l})=>{const{data:a,retrieve:c,subscribe:d,getItem:x,status:p}=Lr({filter:n,initialParams:i}),{fetchMore:m,search:h}=nt.usePager({retrieve:c});return o.jsxRuntimeExports.jsx(Ot,{resourceName:"Range",variant:"modal",value:t,onChange:e,data:a,allowNone:s,haulType:Mr,onFetchMore:m,getItem:x,subscribe:d,status:p,onSearch:h,emptyContent:r,icon:Yc,itemHeight:45,dialogProps:w2,...l,children:Kc})},v2=Object.freeze(Object.defineProperty({__proto__:null,ALIAS_FLUX_STORE_CONFIG:Hc,HAUL_TYPE:Mr,KV_FLUX_STORE_CONFIG:Vc,ListItem:Nr,RANGE_ALIASES_FLUX_STORE_KEY:Oc,RANGE_KV_FLUX_STORE_KEY:Ic,SelectMultiple:C2,SelectSingle:b2,TimeRangeChip:Zc,formSchema:$c,kvPairFormSchema:Fc,metaDataFormSchema:d2,retrieve:Bc,retrieveParent:r2,toFormValues:Oo,useChildren:o2,useDelete:E2,useDeleteKV:h2,useForm:a2,useKVPairForm:f2,useLabels:c2,useList:Lr,useListKV:m2,useRetrieve:i2,useSetSynchronizer:s2,useUpdate:j2,useUpdateKV:g2},Symbol.toStringTag,{value:"Module"})),Gc=({children:e})=>{const{path:t}=f.useUnidirectional({type:O.BaseProvider.TYPE,schema:O.providerStateZ$2,state:{}});return o.jsxRuntimeExports.jsx(f.Composite,{path:t,children:e})},_2=new Set([u.n.UUID,u.n.JSON]),k2=e=>{if(e.equals(u.n.JSON))return o.jsxRuntimeExports.jsx(f.JSON,{});if(e.isInteger)return o.jsxRuntimeExports.jsx(f.Binary,{});if(e.isFloat)return o.jsxRuntimeExports.jsx(f.Decimal,{});if(e.equals(u.n.STRING)||e.equals(u.n.UUID))return o.jsxRuntimeExports.jsx(f.String,{});if(e.equals(u.n.TIMESTAMP))return o.jsxRuntimeExports.jsx(f.Time$1,{})},Uc=u.n.ALL.filter(e=>e!==u.n.UNKNOWN).map(e=>({key:e.toString(),name:_2.has(e)?e.toString().toUpperCase():u.z.capitalize(e.toString()),icon:k2(e)})),L2=Uc.filter(e=>!new u.n(e.key).isVariable),M2=({hideVariableDensity:e=!1,...t})=>{const n=e?L2:Uc;return o.jsxRuntimeExports.jsx(Pn,{...t,data:n,resourceName:"Data Type"})},N2=Object.freeze(Object.defineProperty({__proto__:null,Provider:Gc,SelectDataType:M2},Symbol.toStringTag,{value:"Module"})),P2=e=>{switch(e.variant){case"disabled":return e.details?.valid===!0?{message:"Uncontrolled. Click to take control.",chipColor:"var(--pluto-gray-l12)"}:{message:"No channel connected. This element cannot be controlled.",chipColor:"var(--pluto-gray-l7)",disabled:!0};case"error":return{message:"Not controlled by you. Click to take absolute control.",chipColor:"var(--pluto-error-z)"};case"success":return e.details?.authority===P.gw.ABSOLUTE_AUTHORITY?{message:"You have absolute control. Click to release.",chipColor:"var(--pluto-secondary-z)",buttonStyle:{background:"var(--pluto-secondary-z-30)"}}:{message:"You're in control. Release schematic to release control.",chipColor:"var(--pluto-primary-z)"};default:return{message:"Unexpected status.",chipColor:"var(--pluto-error-z)"}}},Wc=({source:e,sink:t,className:n,...s})=>{const r=f.useMemoDeepEqual({source:e,sink:t}),[,{status:i},l]=f.use$2({type:O.Chip.TYPE,schema:O.chipStateZ,initialState:{triggered:!1,...r,status:{key:"no_chip",variant:"disabled",message:"No chip connected.",time:u.r.now(),details:{}}}});j.useEffect(()=>{l(m=>({...m,...r}))},[r,l]);const a=j.useCallback(()=>l(m=>({...m,triggered:!m.triggered})),[l]),{message:c,chipColor:d,buttonStyle:x,disabled:p}=P2(i);return o.jsxRuntimeExports.jsx(f.Button,{variant:"text",className:u.CSS(u.CSS.B("control-chip"),n),disabled:p,onClick:a,tooltip:o.jsxRuntimeExports.jsx(f.Text,{level:"small",children:c}),style:x,...s,children:o.jsxRuntimeExports.jsx(f.Circle,{color:d})})},Xc=j.createContext({needsControlOf:[]}),qc=()=>j.use(Xc),T2=({children:e,onStatusChange:t,...n})=>{const s=f.useMemoDeepEqual(n),[{path:r},{status:i,needsControlOf:l},a]=f.use$2({type:O.Controller.TYPE,schema:O.controllerStateZ,initialState:s});return j.useEffect(()=>{i!=null&&t?.(i)},[i,t]),j.useEffect(()=>{a(c=>({...c,...s}))},[s,a]),j.useEffect(()=>()=>t?.("released"),[]),o.jsxRuntimeExports.jsxs(Xc,{value:{needsControlOf:l},children:[o.jsxRuntimeExports.jsx(f.Composite,{path:r,children:e}),";"]})},Qc=({colorSource:e,statusSource:t})=>{const n=f.useMemoDeepEqual({colorSource:e,statusSource:t}),[,{color:s,status:r},i]=f.use$2({type:O.Indicator.TYPE,initialState:{...n,status:{key:"no_chip",variant:"warning",message:"No chip connected.",time:u.r.now(),details:{color:void 0}}},schema:O.indicatorStateZ});j.useEffect(()=>{i(a=>({...a,...n}))},[n,i]);let l;return r.details?.color!=null?l=u.cr.colorZ.parse(r.details.color):s!=null&&!u.cr.isZero(s)?l=s:l="var(--pluto-gray-l10)",o.jsxRuntimeExports.jsxs(f.Dialog$1,{location:{x:"center",y:"bottom"},children:[o.jsxRuntimeExports.jsx(f.Text,{children:r.message}),o.jsxRuntimeExports.jsx("div",{className:u.CSS.B("indicator"),style:{backgroundColor:u.cr.cssString(l),flexGrow:1}})]})},I2=e=>{const{needsControlOf:t}=qc(),[,{states:n},s]=f.use$2({type:O.Legend.TYPE,schema:O.legendStateZ,initialState:{states:[],needsControlOf:t}});j.useEffect(()=>{s(l=>({...l,needsControlOf:t}))},[t]);const i=u.c.unique(n.map(l=>l.subject.key)).map(l=>{const a=n.find(c=>c.subject.key===l);if(a==null)throw new P.ht("Legend subject not found");return{key:a.subject.key,label:a.subject.name,color:a.subjectColor}});return o.jsxRuntimeExports.jsx(lr,{data:i,...e})},Jc=({children:e})=>{const[{path:t}]=f.use$2({type:O.StateProvider.TYPE,schema:O.stateProviderStateZ,initialState:{}});return o.jsxRuntimeExports.jsx(f.Composite,{path:t,children:e})},O2=Object.freeze(Object.defineProperty({__proto__:null,Chip:Wc,Controller:T2,Indicator:Qc,Legend:I2,StateProvider:Jc,useContext:qc},Symbol.toStringTag,{value:"Module"})),eu=e=>{const t=({disabled:n=!1,...s})=>n?s.children:o.jsxRuntimeExports.jsx(e,{...s});return t.displayName=e.displayName,t},tu="workspaces",A2={channel:P.Dw.SET_CHANNEL_NAME,schema:P.Dw.workspaceZ,onChange:({store:e,changed:t})=>e.workspaces.set(t.key,t)},D2={channel:P.Dw.DELETE_CHANNEL_NAME,schema:P.Dw.keyZ,onChange:({store:e,changed:t})=>e.workspaces.delete(t)},nu={listeners:[A2,D2]},B2=qe({name:"Workspace",retrieve:({params:e,client:t})=>t.workspaces.retrieve(e.key),mountListeners:({store:e,params:t,onChange:n})=>[e.workspaces.onSet(n,t.key)]}),$2=Ke({name:"Workspace",retrieve:async({client:e,params:t})=>await e.workspaces.retrieve(t),retrieveByKey:async({client:e,key:t})=>await e.workspaces.retrieve(t),mountListeners:({store:e,onChange:t,onDelete:n})=>[e.workspaces.onSet(s=>t(s.key,s)),e.workspaces.onDelete(n)]}),z2=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:nu,FLUX_STORE_KEY:tu,retrieve:B2,useList:$2},Symbol.toStringTag,{value:"Module"})),V2=eu(Gc),F2=eu(f.Provider$4),su={[O.FLUX_STORE_KEY]:O.FLUX_STORE_CONFIG,[hc]:gc,[ac]:cc,[sc]:oc,[mc]:fc,[tu]:nu,[kc]:Mc,[Lc]:Nc,[Ic]:Vc,[Ya]:Ga,[Oc]:Hc,[qj]:e2},H2=({children:e,connParams:t,workerEnabled:n=!0,workerURL:s,theming:r,tooltip:i,triggers:l,alamos:a,haul:c,telem:d,color:x})=>o.jsxRuntimeExports.jsx(f.Provider$1,{...l,children:o.jsxRuntimeExports.jsx(f.Config,{...i,children:o.jsxRuntimeExports.jsx(f.Provider$2,{...c,children:o.jsxRuntimeExports.jsx(f.Provider$3,{url:s??t2,enabled:n,children:o.jsxRuntimeExports.jsx(F2,{workerKey:"vis",children:o.jsxRuntimeExports.jsx(Xj,{...a,children:o.jsxRuntimeExports.jsx(f.Aggregator,{children:o.jsxRuntimeExports.jsx($a,{connParams:t,children:o.jsxRuntimeExports.jsx(Va,{storeConfig:su,children:o.jsxRuntimeExports.jsx(Pe.Provider,{...x,children:o.jsxRuntimeExports.jsx(f.Provider,{...r,children:o.jsxRuntimeExports.jsx(V2,{...d,children:o.jsxRuntimeExports.jsx(Jc,{children:e})})})})})})})})})})})})}),Z2=Object.freeze(Object.defineProperty({__proto__:null,FLUX_STORE_CONFIG:su,Provider:H2},Symbol.toStringTag,{value:"Module"})),K2=({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}%`}})}),Y2=Object.freeze(Object.defineProperty({__proto__:null,Progress:K2},Symbol.toStringTag,{value:"Module"})),G2=({steps:e,value:t,onChange:n,...s})=>{const r=e.findIndex(i=>i.key===t);return o.jsxRuntimeExports.jsx(f.Box,{x:!0,align:"center",className:u.CSS.B("steps"),...s,children:e.map((i,l)=>o.jsxRuntimeExports.jsxs(j.Fragment,{children:[o.jsxRuntimeExports.jsxs(f.Button,{onClick:()=>n(i.key),variant:"outlined",disabled:l>r,children:[l+1,". ",i.title]},i.key),l!==e.length-1&&o.jsxRuntimeExports.jsx(f.Arrow.Right,{style:{fontSize:"15px",color:"var(--pluto-gray-l10)"}})]},i.key))})},U2=Object.freeze(Object.defineProperty({__proto__:null,Steps:G2},Symbol.toStringTag,{value:"Module"})),W2=({children:e,className:t,visible:n,...s})=>{const[{path:r},,i]=f.use$2({type:O.Table.TYPE,schema:O.Table.stateZ,initialState:{region:u.Ho.ZERO,visible:n}});j.useEffect(()=>{i(a=>({...a,visible:n}))},[n]);const l=Tn(a=>i(c=>({...c,region:a})));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(f.Composite,{path:r,children:e})})})]})},X2=({children:e,className:t,size:n,index:s,onResize:r,onSelect:i,position:l,...a})=>o.jsxRuntimeExports.jsxs("tr",{className:u.CSS(u.CSS.BE("table","row"),t),...a,children:[r!=null&&o.jsxRuntimeExports.jsx(ru,{onSelect:i,index:s,value:n,onChange:r,position:l,direction:"y"}),e]}),Pr=({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}),ou="ABCDEFGHIJKLMNOPQRSTUVWXYZ",q2=e=>ou[e],ru=({value:e,selected:t=!1,index:n,onChange:s,position:r,direction:i="x",onSelect:l})=>{const a=f.useSyncedRef(e),c=j.useRef(e),d=Pe.useCursorDrag({onStart:j.useCallback(()=>{c.current=a.current},[]),onMove:j.useCallback(x=>s(c.current+u.Ho.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),f.CONTEXT_TARGET,t&&f.CONTEXT_SELECTED),style:{[u.p.dimension(i)]:e},onClick:()=>l(n),onContextMenu:()=>l(n),children:[o.jsxRuntimeExports.jsx(f.Text,{full:"x",justify:"center",align:"center",square:!1,children:i==="x"?ou[n]:n+1}),o.jsxRuntimeExports.jsx("button",{onClick:x=>x.stopPropagation(),style:{[u.p.location(i)]:r+e},onDragStart:d,draggable:!0})]})},Q2=({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 a=r;return r+=i,o.jsxRuntimeExports.jsx(ru,{onSelect:t,position:a,selected:e.includes(l),index:l,value:i,onChange:c=>s(c,l),direction:"x"},l)})]})},J2=Object.freeze(Object.defineProperty({__proto__:null,Cell:Pr,ColumnIndicators:Q2,Row:X2,Table:W2,getCellColumn:q2},Symbol.toStringTag,{value:"Module"})),iu=te.z.object({bounds:u.H.bounds,gradient:u.cr.gradientZ}),Tr={bounds:{lower:0,upper:1},gradient:[]},Mi={size:"small",showDragHandle:!1},Ni={width:60},eE=u.C.Scale.scale(0,1),Ir=({path:e})=>{const{set:t,get:n}=rn(),s=fr(`${e}.bounds`),r=eE.scale(s);return o.jsxRuntimeExports.jsxs(f.Box,{x:!0,grow:!0,children:[o.jsxRuntimeExports.jsx($e,{inputProps:Mi,style:Ni,label:"Lower",path:`${e}.bounds.lower`}),o.jsxRuntimeExports.jsx(Ee,{path:`${e}.gradient`,label:"Gradient",align:"start",padHelpText:!1,children:({value:i,onChange:l})=>o.jsxRuntimeExports.jsx(Pe.GradientPicker,{value:P.N.copy(i),scale:r,onChange:a=>{const d={...n(`${e}.bounds`).value},x=a.map(S=>S.position),p=r.pos(Math.max(...x)),m=r.pos(Math.min(...x)),h=p>d.upper,g=m<d.lower;h&&(a[a.length-1].position=1,d.upper=p),g&&(a[0].position=0,d.lower=m);const E=a.map(S=>({...S,color:u.cr.hex(S.color)}));h||g?t(e,{bounds:d,gradient:E}):l(a.map(S=>({...S,color:u.cr.hex(S.color)})))}})}),o.jsxRuntimeExports.jsx($e,{inputProps:Mi,style:Ni,label:"Upper",path:`${e}.bounds.upper`})]})},tE=e=>o.jsxRuntimeExports.jsxs(pe.Buttons,{...e,keys:u.br.NOTATIONS,children:[o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"standard",children:"Standard"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"scientific",children:"Scientific"}),o.jsxRuntimeExports.jsx(pe.Button,{itemKey:"engineering",children:"Engineering"})]}),nE=[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],Or=({path:e})=>{const{value:t,onChange:n}=Et(e),s=O.sourcePipelinePropsZ.parse(t.telem?.props),r=O.streamChannelValuePropsZ.parse(s.segments.valueStream.props),i=O.stringifyNumberProps.parse(s.segments.stringifier.props),l=O.rollingAverageProps.parse(s.segments.rollingAverage.props),a=h=>{const g=O.sourcePipeline("string",{connections:nE,segments:{valueStream:O.streamChannelValue({channel:r.channel}),stringifier:O.stringifyNumber({precision:i.precision??2,notation:i.notation}),rollingAverage:O.rollingAverage({windowSize:l.windowSize??1}),...h},outlet:"stringifier"});n({...t,telem:g})},c=h=>a({valueStream:O.streamChannelValue({channel:h??0})}),d=h=>a({stringifier:O.stringifyNumber({...i,notation:h})}),x=h=>a({stringifier:O.stringifyNumber({...i,precision:h})}),p=h=>a({rollingAverage:O.rollingAverage({windowSize:h})});if(typeof r.channel!="number")throw new Error("Must pass in a channel by key to Value.TelemForm");const{data:m}=Rr.useDirect({params:{key:r.channel}});return j.useEffect(()=>{m!=null&&n({...t,tooltip:[m.name]})},[m?.name,n]),o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx(Ie.Item,{label:"Input Channel",grow:!0,children:o.jsxRuntimeExports.jsx(kt,{value:r.channel,onChange:c})}),o.jsxRuntimeExports.jsxs(f.Box,{x:!0,children:[o.jsxRuntimeExports.jsx(Ie.Item,{label:"Notation",children:o.jsxRuntimeExports.jsx(tE,{value:i.notation,onChange:d})}),o.jsxRuntimeExports.jsx(Ie.Item,{label:"Precision",align:"start",children:o.jsxRuntimeExports.jsx(f.Numeric,{value:i.precision??2,bounds:{lower:0,upper:10},onChange:x})}),o.jsxRuntimeExports.jsx(Ie.Item,{label:"Averaging Window",align:"start",children:o.jsxRuntimeExports.jsx(f.Numeric,{value:l.windowSize??1,bounds:{lower:1,upper:100},onChange:p})})]})]})},sE=O.Value.z.partial({color:!0}).extend({level:P.levelZ.optional()}),Ar=({aetherKey:e,box:t,telem:n,color:s,precision:r,minWidth:i,level:l="small",backgroundTelem:a,notation:c,location:d,useWidthForBackground:x,valueBackgroundOverScan:p,valueBackgroundShift:m})=>{const h=f.useMemoDeepEqual({box:t,telem:n,color:s,precision:r,level:l,minWidth:i,notation:c,backgroundTelem:a,location:d,useWidthForBackground:x,valueBackgroundOverScan:p,valueBackgroundShift:m}),[,g,E]=f.use$2({aetherKey:e,type:O.Value.TYPE,schema:O.Value.z,initialState:h});return j.useEffect(()=>E(S=>({...S,...h})),[h]),{width:g.width??g.minWidth}},oE=Object.freeze(Object.defineProperty({__proto__:null,RedlineForm:Ir,TelemForm:Or,ZERO_READLINE:Tr,corePropsZ:sE,redlineZ:iu,use:Ar},Symbol.toStringTag,{value:"Module"})),rE="text",lu=te.z.object({value:te.z.string(),level:P.levelZ,weight:P.weightZ,align:u.K$1.x.or(u.K$1.center),backgroundColor:u.cr.crudeZ}),au=({cellKey:e,onChange:t,value:n,selected:s,onSelect:r,align:i,level:l,weight:a,backgroundColor:c})=>{const d=p=>r(e,p),x=p=>t({level:l,value:p,weight:a,align:i,backgroundColor:c});return o.jsxRuntimeExports.jsx(Pr,{id:e,className:u.CSS(f.CONTEXT_TARGET,s&&f.CONTEXT_SELECTED,u.CSS.BEM("table","cell","text")),selected:s,onClick:d,onContextMenu:d,style:{backgroundColor:u.cr.cssString(c)},children:o.jsxRuntimeExports.jsx(f.Editable,{level:l,value:n,weight:a,onChange:x,style:{justifyContent:i},allowEmpty:!0,outline:!1})})},iE="value",cu=te.z.object({telem:O.stringSourceSpecZ,redline:iu,level:P.levelZ,color:te.z.string(),units:te.z.string()}),uu=({cellKey:e,telem:t,level:n,color:s,redline:{gradient:r,bounds:i},selected:l,box:a,onSelect:c})=>{const{width:d}=Ar({aetherKey:e,box:a,telem:t,level:n,color:s,backgroundTelem:O.sourcePipeline("color",{connections:[{from:"source",to:"scale"},{from:"scale",to:"gradient"}],segments:{source:t,scale:O.scaleNumber({scale:u.C.Scale.scale(i).scale(0,1).transform}),gradient:O.colorGradient({gradient:r})},outlet:"gradient"}),location:{x:"center",y:"center"}}),x=p=>c(e,p);return o.jsxRuntimeExports.jsx(Pr,{id:e,selected:l,onClick:x,onContextMenu:x,style:{height:"5rem",width:d},className:u.CSS(f.CONTEXT_TARGET,l&&f.CONTEXT_SELECTED,u.CSS.BEM("table","cell","value"))})},lE={padding:"2rem"},uo=e=>o.jsxRuntimeExports.jsx(f.Box,{...e,style:lE,y:!0}),aE=[{tabKey:"style",name:"Style"},{tabKey:"telem",name:"Telemetry"},{tabKey:"redline",name:"Redline"}],du=({onVariantChange:e})=>{const t=j.useCallback(({tabKey:s})=>{switch(s){case"telem":return o.jsxRuntimeExports.jsx(uo,{children:o.jsxRuntimeExports.jsx(Or,{path:""})});case"redline":return o.jsxRuntimeExports.jsx(uo,{children:o.jsxRuntimeExports.jsx(Ir,{path:"redline"})});default:return o.jsxRuntimeExports.jsx(uo,{children:o.jsxRuntimeExports.jsxs(f.Box,{x:!0,children:[o.jsxRuntimeExports.jsx(Ie.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Dr,{onChange:e,value:"value"})}),o.jsxRuntimeExports.jsx(Ee,{hideIfNull:!0,label:"Color",align:"start",padHelpText:!1,path:"color",children:({value:r,onChange:i,variant:l,...a})=>o.jsxRuntimeExports.jsx(Pe.Swatch,{value:r??u.cr.setAlpha(u.cr.ZERO,1),onChange:i,...a,bordered:!0})}),o.jsxRuntimeExports.jsx(Ee,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:({value:r,onChange:i,variant:l,...a})=>o.jsxRuntimeExports.jsx(on,{value:r,onChange:i,...a})})]})})}},[]),n=Me.useStatic({tabs:aE,content:t});return o.jsxRuntimeExports.jsx(Me.Tabs,{...n,size:"small"})},cE={padding:"2rem"},xu=({onVariantChange:e})=>o.jsxRuntimeExports.jsxs(f.Box,{x:!0,grow:!0,style:cE,children:[o.jsxRuntimeExports.jsx(Ie.Item,{label:"Variant",padHelpText:!1,children:o.jsxRuntimeExports.jsx(Dr,{onChange:e,value:"text"})}),o.jsxRuntimeExports.jsx(hr,{path:"value",label:"Text"}),o.jsxRuntimeExports.jsx(Ee,{path:"level",label:"Size",hideIfNull:!0,padHelpText:!1,children:({value:t,onChange:n,variant:s,...r})=>o.jsxRuntimeExports.jsx(on,{value:t,onChange:n,...r})}),o.jsxRuntimeExports.jsx(Ee,{path:"weight",label:"Weight",padHelpText:!1,children:({value:t,onChange:n,variant:s,...r})=>o.jsxRuntimeExports.jsx(la,{value:t,onChange:n,...r})}),o.jsxRuntimeExports.jsx(Ee,{path:"align",label:"Alignment",hideIfNull:!0,children:({value:t,onChange:n,variant:s,...r})=>o.jsxRuntimeExports.jsx(pe.SelectAlignment,{value:t,onChange:n,...r})}),o.jsxRuntimeExports.jsx(Ee,{path:"backgroundColor",label:"Background",align:"start",padHelpText:!1,children:({value:t,onChange:n})=>o.jsxRuntimeExports.jsx(Pe.Swatch,{value:t,onChange:n})})]}),uE=[{key:"text",name:"Text",icon:o.jsxRuntimeExports.jsx(f.Text$3,{})},{key:"value",name:"Value",icon:o.jsxRuntimeExports.jsx(f.Channel,{})}],Dr=e=>o.jsxRuntimeExports.jsx(Pn,{...e,data:uE,resourceName:"Variant"}),dE=["text","value"],xE=te.z.enum(dE),pE={key:"value",name:"Value",Form:du,Cell:uu,defaultProps:e=>({telem:O.sourcePipeline("string",{connections:[{from:"valueStream",to:"rollingAverage"},{from:"rollingAverage",to:"stringifier"}],segments:{valueStream:O.streamChannelValue({channel:0}),rollingAverage:O.rollingAverage({windowSize:1}),stringifier:O.stringifyNumber({precision:2,notation:"standard"})},outlet:"stringifier"}),redline:Tr,color:u.cr.hex(e.colors.gray.l10),level:"h5",units:""}),schema:cu},mE={key:"text",name:"Text",Form:xu,Cell:au,defaultProps:()=>({value:"",level:"h5",units:"",weight:400,align:"center",backgroundColor:"#00000000"}),schema:lu},fE={text:mE,value:pE},hE=Object.freeze(Object.defineProperty({__proto__:null,CELLS:fE,SelectVariant:Dr,TEXT_TYPE:rE,Text:au,TextForm:xu,VALUE_TYPE:iE,Value:uu,ValueForm:du,textPropsZ:lu,valuePropsZ:cu,variantZ:xE},Symbol.toStringTag,{value:"Module"})),Pi=({sourcePos:e,targetPos:t,next:n,prev:s})=>{const r=Rt(e,...n);return u.K.distance(r,t)<1?!0:(console.warn("Connector is out of sync with target"),console.log("Theoretical target",r),console.log("Actual target",t),console.log("Segments",n),console.log("Prev segments",s),!1)},Ti=({sourceStumpTip:e,sourceOrientation:t,sourceBox:n,targetStumpTip:s,targetOrientation:r,targetBox:i})=>{if(!gE({sourcePos:e,sourceOrientation:t,targetPos:s}))return;const l=u.p.construct(t),a=u.p.swap(l);let c=wt(a,s[a]-e[a]);const d=u.Ho.loc(n,c);if(u.K$1.swap(t)===r){const x=u.Ho.loc(i,u.K$1.swap(c));Math.abs(d-x)<De&&(c=u.K$1.swap(c))}return{direction:a,length:d-e[a]+Mt(c,De)}},Ao=te.z.object({direction:u.p.direction,length:te.z.number()}),Rt=(e,...t)=>{let n=e;for(const s of t)n=u.K.translate(n,s.direction,s.length);return n},pu=(e,t,n,s)=>{try{let r=e;const i=[e,...t.map(h=>(r=u.K.translate(r,h.direction,h.length),r))];if(!s)return i;const l=t[0],a=wt(l.direction,l.length),c=Ii(a),d=4*(2-n**.5);i[0]=u.K.translate(i[0],{[l.direction]:-1*c*d,[u.p.swap(l.direction)]:0});const x=t[t.length-1],p=wt(x.direction,x.length),m=Ii(p);return i[i.length-1]=u.K.translate(i[i.length-1],{[x.direction]:m*d,[u.p.swap(x.direction)]:0}),i}catch{return[]}},De=10,Ii=e=>e==="top"||e==="left"?-1:1,Mt=(e,t)=>e==="top"||e==="left"?-t:t,wt=(e,t)=>e==="x"?t>0?"right":"left":t>0?"bottom":"top",ht=e=>wt(e.direction,e.length),gE=({sourcePos:e,targetPos:t,sourceOrientation:n})=>{const s=u.p.construct(n),r=t[s]-e[s];return Mt(n,r)<0},Wn=e=>({direction:u.p.construct(e),length:Mt(e,De)}),Oi={top:Wn("top"),bottom:Wn("bottom"),left:Wn("left"),right:Wn("right")},jE=4,EE=.25,Os=e=>Do(yE(Do(e))),yE=e=>{const t=[...e],n=e.findIndex((s,r)=>{const i=Math.abs(s.length);if(i<jE){if(r===0||r===e.length-1)return!1;if(i<EE)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},Do=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,a=r,c=ht(i),d=ht(s);if(c===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)===De)return!1;const x=Mt(c,De),p=t[l].length-x,m=t[a].length+p;return Math.abs(m)<De?!1:(t[l]={...t[l],length:x},t[a]={...t[a],length:m},!0)}if(r===e.length-1){const l=r,a=r-1,c=ht(s),d=ht(i);if(c===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)===De)return!1;const x=Mt(c,De),p=t[l].length-x,m=t[a].length+p;return Math.abs(m)<De?!1:(t[l]={...t[l],length:x},t[a]={...t[a],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?Do(t):t},Zt=e=>Os(SE(e)),SE=({sourceBox:e,targetBox:t,sourcePos:n,targetPos:s,targetOrientation:r,sourceOrientation:i})=>{let l=i,a=r,c={...Oi[i]},d=Rt(n,c);const x={...Oi[r]};let p=Rt(s,x);const m=Math.abs(d.x-p.x),h=Math.abs(d.y-p.y);m<2*De&&h<10&&(c.length-=m/2,x.length+=m/2,d=Rt(n,c),p=Rt(s,x));const g=[c],E=Ti({sourceStumpTip:d,sourceOrientation:i,sourceBox:e,targetStumpTip:p,targetOrientation:r,targetBox:t});E!=null&&(g.push(E),d=Rt(d,E),l=ht(E),c=E);const S=Ti({sourceStumpTip:p,sourceOrientation:a,sourceBox:t,targetStumpTip:d,targetOrientation:l,targetBox:e});S!=null&&(p=Rt(p,S),a=wt(S.direction,S.length));const R=()=>{S!=null&&(S.length*=-1,g.push(S)),x.length*=-1,g.push(x)};if(u.K$1.swap(l)===r){const I=u.p.construct(l),A=(p[I]-d[I])/2;g.push({direction:I,length:A});const B=u.p.swap(I);return g.push({direction:B,length:p[B]-d[B]}),g.push({direction:I,length:A}),R(),g}const v=p[c.direction]-d[c.direction];let y=u.p.swap(c.direction);const C=d[y]-p[y];let _;wt(c.direction,v)===l&&wt(y,C)===a?_={direction:c.direction,length:v}:(_={direction:y,length:p[y]-d[y]},y=u.p.swap(y)),g.push(_);const M={direction:y,length:p[y]-d[y]};return g.push(M),R(),g},RE=e=>Os(CE(e)),CE=({segments:e,index:t,magnitude:n})=>{const s=[...e],r=s[t],i=u.p.swap(r.direction),l=ht(r);if(t===0){s.unshift({direction:i,length:n});const a=Mt(l,De);s.unshift({direction:r.direction,length:a}),t+=2,s[t]={...s[t],length:s[t].length-a}}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 a=Mt(l,De);s.push({direction:r.direction,length:a}),s[t]={...s[t],length:s[t].length-a}}else s[t+1]={direction:s[t+1].direction,length:s[t+1].length-n};return s},wE=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n],n))return n;return-1},bE=(e,t,n=!1,...s)=>{const r=(i,l)=>!s.includes(l)&&t(i,l);return n?wE(e,r):e.findIndex(r)},vE=({delta:e,segments:t})=>Os(mu(e,t,!1)),_E=({delta:e,segments:t})=>Os(mu(e,t,!0)),mu=(e,t,n)=>{let s=[...t];return e.x!==0&&(s=Di("x",e,s,n)),e.y!==0&&(s=Di("y",e,s,n)),s},Ai=(e,t,n)=>{if(t.direction!==e)return!1;const s={...t,length:t.length-n[e]},r=ht(t),i=ht(s),l=Math.abs(s.length),a=Math.abs(t.length);return(l>a||l>De)&&r===i},Di=(e,t,n,s)=>{const r=u.p.swap(e),i=s?n.length-1:0,l=n[i];if(Ai(e,l,t)){const p=n[n.length-1];return p.direction===e&&Math.abs(l.length)<De?(n[n.length-1]={...p,length:p.length-t[e]},n):(n[i]={...l,length:l.length-t[e]},n)}const a=s?0:n.length-1,d=bE(n,p=>p.direction===e,s,i);if(d===a){const p=n[a];return Ai(e,p,t)?(n[a]={...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[a]={...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},kE=te.z.object({position:u.K.xy,zoom:te.z.number()}),fu=te.z.object({color:u.cr.crudeZ,variant:te.z.string().optional(),segments:te.z.array(Ao)}),LE=fu.extend({key:te.z.string(),source:te.z.string(),target:te.z.string(),segments:te.z.array(Ao),color:u.cr.crudeZ,id:te.z.string(),data:te.z.object({segments:te.z.array(Ao),color:u.cr.crudeZ,variant:te.z.string().optional()}).optional(),selected:te.z.boolean(),sourceHandle:te.z.string().nullable().optional(),targetHandle:te.z.string().nullable().optional()}),ME=te.z.object({key:te.z.string(),position:u.K.xy,selected:te.z.boolean().optional(),zIndex:te.z.number().optional(),type:te.z.string().optional(),data:u.l.unknownZ.optional(),measured:te.z.object({width:te.z.number().optional(),height:te.z.number().optional()}).optional()}),Br=(e,t)=>e.map(n=>({id:n.key,type:"custom",zIndex:n.zIndex,measured:{...n.measured},position:{...n.position},selected:n.selected,data:{},dragHandle:t})),$r=e=>e.map(({segments:t,color:n,variant:s,...r})=>({...r,id:r.key,data:{segments:t,color:n,variant:s}})),hu=e=>e.map(t=>({key:t.id,...t})),gu=(e,t)=>e.map(n=>(n.data??={segments:[],color:t,variant:"pipe"},{key:n.id,segments:n.data?.segments??[],selected:n.selected??!1,color:n.data?.color??t,variant:n.data?.variant??"pipe",...n})),ju=e=>({...e.position,zoom:e.zoom}),Eu=e=>({position:u.K.construct(e),zoom:e.zoom}),yu=(e,t)=>hu(t(Br(e))),is=(e,t,n)=>gu(t($r(e)),n),NE=(e,t="x")=>{if(e.length===0)return[];const n=u.K$1.construct(t),s=u.K$1.swap(n);return e.sort((r,i)=>u.Ho.loc(r.box,n)-u.Ho.loc(i.box,n)),e.forEach((r,i)=>{if(i===0)return;const a=e[i-1].handles.find(h=>h.orientation===s),c=r.handles.find(h=>h.orientation===n);if(a==null||c==null)return;const d=a.absolutePosition,x=c.absolutePosition,p=u.K.set(u.K.translation(x,d),t,0),m=u.K.translate(u.Ho.topLeft(r.box),p);r.box=u.Ho.construct(m,u.Ho.dims(r.box))}),e};function Le(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=Le(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var PE={value:()=>{}};function As(){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 ls(n)}function ls(e){this._=e}function TE(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}})}ls.prototype=As.prototype={constructor:ls,on:function(e,t){var n=this._,s=TE(e+"",n),r,i=-1,l=s.length;if(arguments.length<2){for(;++i<l;)if((r=(e=s[i]).type)&&(r=IE(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]=Bi(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Bi(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 ls(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 IE(e,t){for(var n=0,s=e.length,r;n<s;++n)if((r=e[n]).name===t)return r.value}function Bi(e,t,n){for(var s=0,r=e.length;s<r;++s)if(e[s].name===t){e[s]=PE,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Bo="http://www.w3.org/1999/xhtml";const $i={svg:"http://www.w3.org/2000/svg",xhtml:Bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ds(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),$i.hasOwnProperty(t)?{space:$i[t],local:e}:e}function OE(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Bo&&t.documentElement.namespaceURI===Bo?t.createElement(e):t.createElementNS(n,e)}}function AE(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Su(e){var t=Ds(e);return(t.local?AE:OE)(t)}function DE(){}function zr(e){return e==null?DE:function(){return this.querySelector(e)}}function BE(e){typeof e!="function"&&(e=zr(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,a=s[r]=new Array(l),c,d,x=0;x<l;++x)(c=i[x])&&(d=e.call(c,c.__data__,x,i))&&("__data__"in c&&(d.__data__=c.__data__),a[x]=d);return new Fe(s,this._parents)}function $E(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function zE(){return[]}function Ru(e){return e==null?zE:function(){return this.querySelectorAll(e)}}function VE(e){return function(){return $E(e.apply(this,arguments))}}function FE(e){typeof e=="function"?e=VE(e):e=Ru(e);for(var t=this._groups,n=t.length,s=[],r=[],i=0;i<n;++i)for(var l=t[i],a=l.length,c,d=0;d<a;++d)(c=l[d])&&(s.push(e.call(c,c.__data__,d,l)),r.push(c));return new Fe(s,r)}function Cu(e){return function(){return this.matches(e)}}function wu(e){return function(t){return t.matches(e)}}var HE=Array.prototype.find;function ZE(e){return function(){return HE.call(this.children,e)}}function KE(){return this.firstElementChild}function YE(e){return this.select(e==null?KE:ZE(typeof e=="function"?e:wu(e)))}var GE=Array.prototype.filter;function UE(){return Array.from(this.children)}function WE(e){return function(){return GE.call(this.children,e)}}function XE(e){return this.selectAll(e==null?UE:WE(typeof e=="function"?e:wu(e)))}function qE(e){typeof e!="function"&&(e=Cu(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,a=s[r]=[],c,d=0;d<l;++d)(c=i[d])&&e.call(c,c.__data__,d,i)&&a.push(c);return new Fe(s,this._parents)}function bu(e){return new Array(e.length)}function QE(){return new Fe(this._enter||this._groups.map(bu),this._parents)}function js(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}js.prototype={constructor:js,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 JE(e){return function(){return e}}function e3(e,t,n,s,r,i){for(var l=0,a,c=t.length,d=i.length;l<d;++l)(a=t[l])?(a.__data__=i[l],s[l]=a):n[l]=new js(e,i[l]);for(;l<c;++l)(a=t[l])&&(r[l]=a)}function t3(e,t,n,s,r,i,l){var a,c,d=new Map,x=t.length,p=i.length,m=new Array(x),h;for(a=0;a<x;++a)(c=t[a])&&(m[a]=h=l.call(c,c.__data__,a,t)+"",d.has(h)?r[a]=c:d.set(h,c));for(a=0;a<p;++a)h=l.call(e,i[a],a,i)+"",(c=d.get(h))?(s[a]=c,c.__data__=i[a],d.delete(h)):n[a]=new js(e,i[a]);for(a=0;a<x;++a)(c=t[a])&&d.get(m[a])===c&&(r[a]=c)}function n3(e){return e.__data__}function s3(e,t){if(!arguments.length)return Array.from(this,n3);var n=t?t3:e3,s=this._parents,r=this._groups;typeof e!="function"&&(e=JE(e));for(var i=r.length,l=new Array(i),a=new Array(i),c=new Array(i),d=0;d<i;++d){var x=s[d],p=r[d],m=p.length,h=o3(e.call(x,x&&x.__data__,d,s)),g=h.length,E=a[d]=new Array(g),S=l[d]=new Array(g),R=c[d]=new Array(m);n(x,p,E,S,R,h,t);for(var v=0,y=0,C,_;v<g;++v)if(C=E[v]){for(v>=y&&(y=v+1);!(_=S[y])&&++y<g;);C._next=_||null}}return l=new Fe(l,s),l._enter=a,l._exit=c,l}function o3(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function r3(){return new Fe(this._exit||this._groups.map(bu),this._parents)}function i3(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 l3(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),a=new Array(r),c=0;c<l;++c)for(var d=n[c],x=s[c],p=d.length,m=a[c]=new Array(p),h,g=0;g<p;++g)(h=d[g]||x[g])&&(m[g]=h);for(;c<r;++c)a[c]=n[c];return new Fe(a,this._parents)}function a3(){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 c3(e){e||(e=u3);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],a=l.length,c=r[i]=new Array(a),d,x=0;x<a;++x)(d=l[x])&&(c[x]=d);c.sort(t)}return new Fe(r,this._parents).order()}function u3(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function d3(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function x3(){return Array.from(this)}function p3(){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 m3(){let e=0;for(const t of this)++e;return e}function f3(){return!this.node()}function h3(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var r=t[n],i=0,l=r.length,a;i<l;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function g3(e){return function(){this.removeAttribute(e)}}function j3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function E3(e,t){return function(){this.setAttribute(e,t)}}function y3(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function S3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function R3(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 C3(e,t){var n=Ds(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?j3:g3:typeof t=="function"?n.local?R3:S3:n.local?y3:E3)(n,t))}function vu(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function w3(e){return function(){this.style.removeProperty(e)}}function b3(e,t,n){return function(){this.style.setProperty(e,t,n)}}function v3(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function _3(e,t,n){return arguments.length>1?this.each((t==null?w3:typeof t=="function"?v3:b3)(e,t,n??"")):qt(this.node(),e)}function qt(e,t){return e.style.getPropertyValue(t)||vu(e).getComputedStyle(e,null).getPropertyValue(t)}function k3(e){return function(){delete this[e]}}function L3(e,t){return function(){this[e]=t}}function M3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function N3(e,t){return arguments.length>1?this.each((t==null?k3:typeof t=="function"?M3:L3)(e,t)):this.node()[e]}function _u(e){return e.trim().split(/^|\s+/)}function Vr(e){return e.classList||new ku(e)}function ku(e){this._node=e,this._names=_u(e.getAttribute("class")||"")}ku.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 Lu(e,t){for(var n=Vr(e),s=-1,r=t.length;++s<r;)n.add(t[s])}function Mu(e,t){for(var n=Vr(e),s=-1,r=t.length;++s<r;)n.remove(t[s])}function P3(e){return function(){Lu(this,e)}}function T3(e){return function(){Mu(this,e)}}function I3(e,t){return function(){(t.apply(this,arguments)?Lu:Mu)(this,e)}}function O3(e,t){var n=_u(e+"");if(arguments.length<2){for(var s=Vr(this.node()),r=-1,i=n.length;++r<i;)if(!s.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?I3:t?P3:T3)(n,t))}function A3(){this.textContent=""}function D3(e){return function(){this.textContent=e}}function B3(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function $3(e){return arguments.length?this.each(e==null?A3:(typeof e=="function"?B3:D3)(e)):this.node().textContent}function z3(){this.innerHTML=""}function V3(e){return function(){this.innerHTML=e}}function F3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function H3(e){return arguments.length?this.each(e==null?z3:(typeof e=="function"?F3:V3)(e)):this.node().innerHTML}function Z3(){this.nextSibling&&this.parentNode.appendChild(this)}function K3(){return this.each(Z3)}function Y3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function G3(){return this.each(Y3)}function U3(e){var t=typeof e=="function"?e:Su(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function W3(){return null}function X3(e,t){var n=typeof e=="function"?e:Su(e),s=t==null?W3:typeof t=="function"?t:zr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function q3(){var e=this.parentNode;e&&e.removeChild(this)}function Q3(){return this.each(q3)}function J3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function e5(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function t5(e){return this.select(e?e5:J3)}function n5(e){return arguments.length?this.property("__data__",e):this.node().__data__}function s5(e){return function(t){e.call(this,t,this.__data__)}}function o5(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 r5(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 i5(e,t,n){return function(){var s=this.__on,r,i=s5(t);if(s){for(var l=0,a=s.length;l<a;++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 l5(e,t,n){var s=o5(e+""),r,i=s.length,l;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,d=a.length,x;c<d;++c)for(r=0,x=a[c];r<i;++r)if((l=s[r]).type===x.type&&l.name===x.name)return x.value}return}for(a=t?i5:r5,r=0;r<i;++r)this.each(a(s[r],t,n));return this}function Nu(e,t,n){var s=vu(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 a5(e,t){return function(){return Nu(this,e,t)}}function c5(e,t){return function(){return Nu(this,e,t.apply(this,arguments))}}function u5(e,t){return this.each((typeof t=="function"?c5:a5)(e,t))}function*d5(){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 Pu=[null];function Fe(e,t){this._groups=e,this._parents=t}function Dn(){return new Fe([[document.documentElement]],Pu)}function x5(){return this}Fe.prototype=Dn.prototype={constructor:Fe,select:BE,selectAll:FE,selectChild:YE,selectChildren:XE,filter:qE,data:s3,enter:QE,exit:r3,join:i3,merge:l3,selection:x5,order:a3,sort:c3,call:d3,nodes:x3,node:p3,size:m3,empty:f3,each:h3,attr:C3,style:_3,property:N3,classed:O3,text:$3,html:H3,raise:K3,lower:G3,append:U3,insert:X3,remove:Q3,clone:t5,datum:n5,on:l5,dispatch:u5,[Symbol.iterator]:d5};function ze(e){return typeof e=="string"?new Fe([[document.querySelector(e)]],[document.documentElement]):new Fe([[e]],Pu)}function p5(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ge(e,t){if(e=p5(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 m5={passive:!1},bn={capture:!0,passive:!1};function xo(e){e.stopImmediatePropagation()}function Ut(e){e.preventDefault(),e.stopImmediatePropagation()}function Tu(e){var t=e.document.documentElement,n=ze(e).on("dragstart.drag",Ut,bn);"onselectstart"in t?n.on("selectstart.drag",Ut,bn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Iu(e,t){var n=e.document.documentElement,s=ze(e).on("dragstart.drag",null);t&&(s.on("click.drag",Ut,bn),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Xn=e=>()=>e;function $o(e,{sourceEvent:t,subject:n,target:s,identifier:r,active:i,x:l,y:a,dx:c,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:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:x}})}$o.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function f5(e){return!e.ctrlKey&&!e.button}function h5(){return this.parentNode}function g5(e,t){return t??{x:e.x,y:e.y}}function j5(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ou(){var e=f5,t=h5,n=g5,s=j5,r={},i=As("start","drag","end"),l=0,a,c,d,x,p=0;function m(C){C.on("mousedown.drag",h).filter(s).on("touchstart.drag",S).on("touchmove.drag",R,m5).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(C,_){if(!(x||!e.call(this,C,_))){var M=y(this,t.call(this,C,_),C,_,"mouse");M&&(ze(C.view).on("mousemove.drag",g,bn).on("mouseup.drag",E,bn),Tu(C.view),xo(C),d=!1,a=C.clientX,c=C.clientY,M("start",C))}}function g(C){if(Ut(C),!d){var _=C.clientX-a,M=C.clientY-c;d=_*_+M*M>p}r.mouse("drag",C)}function E(C){ze(C.view).on("mousemove.drag mouseup.drag",null),Iu(C.view,d),Ut(C),r.mouse("end",C)}function S(C,_){if(e.call(this,C,_)){var M=C.changedTouches,I=t.call(this,C,_),A=M.length,B,z;for(B=0;B<A;++B)(z=y(this,I,C,_,M[B].identifier,M[B]))&&(xo(C),z("start",C,M[B]))}}function R(C){var _=C.changedTouches,M=_.length,I,A;for(I=0;I<M;++I)(A=r[_[I].identifier])&&(Ut(C),A("drag",C,_[I]))}function v(C){var _=C.changedTouches,M=_.length,I,A;for(x&&clearTimeout(x),x=setTimeout(function(){x=null},500),I=0;I<M;++I)(A=r[_[I].identifier])&&(xo(C),A("end",C,_[I]))}function y(C,_,M,I,A,B){var z=i.copy(),$=Ge(B||M,_),D,V,b;if((b=n.call(C,new $o("beforestart",{sourceEvent:M,target:m,identifier:A,active:l,x:$[0],y:$[1],dx:0,dy:0,dispatch:z}),I))!=null)return D=b.x-$[0]||0,V=b.y-$[1]||0,function k(L,N,F){var H=$,K;switch(L){case"start":r[A]=k,K=l++;break;case"end":delete r[A],--l;case"drag":$=Ge(F||N,_),K=l;break}z.call(L,C,new $o(L,{sourceEvent:N,subject:b,target:m,identifier:A,active:K,x:$[0]+D,y:$[1]+V,dx:$[0]-H[0],dy:$[1]-H[1],dispatch:z}),I)}}return m.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Xn(!!C),m):e},m.container=function(C){return arguments.length?(t=typeof C=="function"?C:Xn(C),m):t},m.subject=function(C){return arguments.length?(n=typeof C=="function"?C:Xn(C),m):n},m.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:Xn(!!C),m):s},m.on=function(){var C=i.on.apply(i,arguments);return C===i?m:C},m.clickDistance=function(C){return arguments.length?(p=(C=+C)*C,m):Math.sqrt(p)},m}var Qt=0,gn=0,pn=0,Au=1e3,Es,jn,ys=0,Nt=0,Bs=0,vn=typeof performance=="object"&&performance.now?performance:Date,Du=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Fr(){return Nt||(Du(E5),Nt=vn.now()+Bs)}function E5(){Nt=0}function Ss(){this._call=this._time=this._next=null}Ss.prototype=Bu.prototype={constructor:Ss,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Fr():+n)+(t==null?0:+t),!this._next&&jn!==this&&(jn?jn._next=this:Es=this,jn=this),this._call=e,this._time=n,zo()},stop:function(){this._call&&(this._call=null,this._time=1/0,zo())}};function Bu(e,t,n){var s=new Ss;return s.restart(e,t,n),s}function y5(){Fr(),++Qt;for(var e=Es,t;e;)(t=Nt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Qt}function zi(){Nt=(ys=vn.now())+Bs,Qt=gn=0;try{y5()}finally{Qt=0,R5(),Nt=0}}function S5(){var e=vn.now(),t=e-ys;t>Au&&(Bs-=t,ys=e)}function R5(){for(var e,t=Es,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:Es=n);jn=e,zo(s)}function zo(e){if(!Qt){gn&&(gn=clearTimeout(gn));var t=e-Nt;t>24?(e<1/0&&(gn=setTimeout(zi,e-vn.now()-Bs)),pn&&(pn=clearInterval(pn))):(pn||(ys=vn.now(),pn=setInterval(S5,Au)),Qt=1,Du(zi))}}function Vi(e,t,n){var s=new Ss;return t=t==null?0:+t,s.restart(r=>{s.stop(),e(r+t)},t,n),s}var C5=As("start","end","cancel","interrupt"),w5=[],$u=0,Fi=1,Vo=2,as=3,Hi=4,Fo=5,cs=6;function $s(e,t,n,s,r,i){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;b5(e,n,{name:t,index:s,group:r,on:C5,tween:w5,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:$u})}function Hr(e,t){var n=Je(e,t);if(n.state>$u)throw new Error("too late; already scheduled");return n}function st(e,t){var n=Je(e,t);if(n.state>as)throw new Error("too late; already running");return n}function Je(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function b5(e,t,n){var s=e.__transition,r;s[t]=n,n.timer=Bu(i,0,n.time);function i(d){n.state=Fi,n.timer.restart(l,n.delay,n.time),n.delay<=d&&l(d-n.delay)}function l(d){var x,p,m,h;if(n.state!==Fi)return c();for(x in s)if(h=s[x],h.name===n.name){if(h.state===as)return Vi(l);h.state===Hi?(h.state=cs,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete s[x]):+x<t&&(h.state=cs,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete s[x])}if(Vi(function(){n.state===as&&(n.state=Hi,n.timer.restart(a,n.delay,n.time),a(d))}),n.state=Vo,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Vo){for(n.state=as,r=new Array(m=n.tween.length),x=0,p=-1;x<m;++x)(h=n.tween[x].value.call(e,e.__data__,n.index,n.group))&&(r[++p]=h);r.length=p+1}}function a(d){for(var x=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=Fo,1),p=-1,m=r.length;++p<m;)r[p].call(e,x);n.state===Fo&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=cs,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function us(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>Vo&&s.state<Fo,s.state=cs,s.timer.stop(),s.on.call(r?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[l]}i&&delete e.__transition}}function v5(e){return this.each(function(){us(this,e)})}function _5(e,t){var n,s;return function(){var r=st(this,e),i=r.tween;if(i!==n){s=n=i;for(var l=0,a=s.length;l<a;++l)if(s[l].name===t){s=s.slice(),s.splice(l,1);break}}r.tween=s}}function k5(e,t,n){var s,r;if(typeof n!="function")throw new Error;return function(){var i=st(this,e),l=i.tween;if(l!==s){r=(s=l).slice();for(var a={name:t,value:n},c=0,d=r.length;c<d;++c)if(r[c].name===t){r[c]=a;break}c===d&&r.push(a)}i.tween=r}}function L5(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Je(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?_5:k5)(n,e,t))}function Zr(e,t,n){var s=e._id;return e.each(function(){var r=st(this,s);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Je(r,s).value[t]}}function zu(e,t){var n;return(typeof t=="number"?O.interpolateNumber:t instanceof O.color?O.interpolateRgb:(n=O.color(t))?(t=n,O.interpolateRgb):O.interpolateString)(e,t)}function M5(e){return function(){this.removeAttribute(e)}}function N5(e){return function(){this.removeAttributeNS(e.space,e.local)}}function P5(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 T5(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 I5(e,t,n){var s,r,i;return function(){var l,a=n(this),c;return a==null?void this.removeAttribute(e):(l=this.getAttribute(e),c=a+"",l===c?null:l===s&&c===r?i:(r=c,i=t(s=l,a)))}}function O5(e,t,n){var s,r,i;return function(){var l,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),c=a+"",l===c?null:l===s&&c===r?i:(r=c,i=t(s=l,a)))}}function A5(e,t){var n=Ds(e),s=n==="transform"?Ug:zu;return this.attrTween(e,typeof t=="function"?(n.local?O5:I5)(n,s,Zr(this,"attr."+e,t)):t==null?(n.local?N5:M5)(n):(n.local?T5:P5)(n,s,t))}function D5(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function B5(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function $5(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&B5(e,i)),n}return r._value=t,r}function z5(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&D5(e,i)),n}return r._value=t,r}function V5(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=Ds(e);return this.tween(n,(s.local?$5:z5)(s,t))}function F5(e,t){return function(){Hr(this,e).delay=+t.apply(this,arguments)}}function H5(e,t){return t=+t,function(){Hr(this,e).delay=t}}function Z5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?F5:H5)(t,e)):Je(this.node(),t).delay}function K5(e,t){return function(){st(this,e).duration=+t.apply(this,arguments)}}function Y5(e,t){return t=+t,function(){st(this,e).duration=t}}function G5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?K5:Y5)(t,e)):Je(this.node(),t).duration}function U5(e,t){if(typeof t!="function")throw new Error;return function(){st(this,e).ease=t}}function W5(e){var t=this._id;return arguments.length?this.each(U5(t,e)):Je(this.node(),t).ease}function X5(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;st(this,e).ease=n}}function q5(e){if(typeof e!="function")throw new Error;return this.each(X5(this._id,e))}function Q5(e){typeof e!="function"&&(e=Cu(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,a=s[r]=[],c,d=0;d<l;++d)(c=i[d])&&e.call(c,c.__data__,d,i)&&a.push(c);return new at(s,this._parents,this._name,this._id)}function J5(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),a=0;a<i;++a)for(var c=t[a],d=n[a],x=c.length,p=l[a]=new Array(x),m,h=0;h<x;++h)(m=c[h]||d[h])&&(p[h]=m);for(;a<s;++a)l[a]=t[a];return new at(l,this._parents,this._name,this._id)}function ey(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 ty(e,t,n){var s,r,i=ey(t)?Hr:st;return function(){var l=i(this,e),a=l.on;a!==s&&(r=(s=a).copy()).on(t,n),l.on=r}}function ny(e,t){var n=this._id;return arguments.length<2?Je(this.node(),n).on.on(e):this.each(ty(n,e,t))}function sy(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function oy(){return this.on("end.remove",sy(this._id))}function ry(e){var t=this._name,n=this._id;typeof e!="function"&&(e=zr(e));for(var s=this._groups,r=s.length,i=new Array(r),l=0;l<r;++l)for(var a=s[l],c=a.length,d=i[l]=new Array(c),x,p,m=0;m<c;++m)(x=a[m])&&(p=e.call(x,x.__data__,m,a))&&("__data__"in x&&(p.__data__=x.__data__),d[m]=p,$s(d[m],t,n,m,d,Je(x,n)));return new at(i,this._parents,t,n)}function iy(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ru(e));for(var s=this._groups,r=s.length,i=[],l=[],a=0;a<r;++a)for(var c=s[a],d=c.length,x,p=0;p<d;++p)if(x=c[p]){for(var m=e.call(x,x.__data__,p,c),h,g=Je(x,n),E=0,S=m.length;E<S;++E)(h=m[E])&&$s(h,t,n,E,m,g);i.push(m),l.push(x)}return new at(i,l,t,n)}var ly=Dn.prototype.constructor;function ay(){return new ly(this._groups,this._parents)}function cy(e,t){var n,s,r;return function(){var i=qt(this,e),l=(this.style.removeProperty(e),qt(this,e));return i===l?null:i===n&&l===s?r:r=t(n=i,s=l)}}function Vu(e){return function(){this.style.removeProperty(e)}}function uy(e,t,n){var s,r=n+"",i;return function(){var l=qt(this,e);return l===r?null:l===s?i:i=t(s=l,n)}}function dy(e,t,n){var s,r,i;return function(){var l=qt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),qt(this,e))),l===c?null:l===s&&c===r?i:(r=c,i=t(s=l,a))}}function xy(e,t){var n,s,r,i="style."+t,l="end."+i,a;return function(){var c=st(this,e),d=c.on,x=c.value[i]==null?a||(a=Vu(t)):void 0;(d!==n||r!==x)&&(s=(n=d).copy()).on(l,r=x),c.on=s}}function py(e,t,n){var s=(e+="")=="transform"?Gg:zu;return t==null?this.styleTween(e,cy(e,s)).on("end.style."+e,Vu(e)):typeof t=="function"?this.styleTween(e,dy(e,s,Zr(this,"style."+e,t))).each(xy(this._id,e)):this.styleTween(e,uy(e,s,t),n).on("end.style."+e,null)}function my(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function fy(e,t,n){var s,r;function i(){var l=t.apply(this,arguments);return l!==r&&(s=(r=l)&&my(e,l,n)),s}return i._value=t,i}function hy(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,fy(e,t,n??""))}function gy(e){return function(){this.textContent=e}}function jy(e){return function(){var t=e(this);this.textContent=t??""}}function Ey(e){return this.tween("text",typeof e=="function"?jy(Zr(this,"text",e)):gy(e==null?"":e+""))}function yy(e){return function(t){this.textContent=e.call(this,t)}}function Sy(e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&yy(r)),t}return s._value=e,s}function Ry(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,Sy(e))}function Cy(){for(var e=this._name,t=this._id,n=Fu(),s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],a=l.length,c,d=0;d<a;++d)if(c=l[d]){var x=Je(c,t);$s(c,e,n,d,l,{time:x.time+x.delay+x.duration,delay:0,duration:x.duration,ease:x.ease})}return new at(s,this._parents,e,n)}function wy(){var e,t,n=this,s=n._id,r=n.size();return new Promise(function(i,l){var a={value:l},c={value:function(){--r===0&&i()}};n.each(function(){var d=st(this,s),x=d.on;x!==e&&(t=(e=x).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),d.on=t}),r===0&&i()})}var by=0;function at(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Fu(){return++by}var ot=Dn.prototype;at.prototype={constructor:at,select:ry,selectAll:iy,selectChild:ot.selectChild,selectChildren:ot.selectChildren,filter:Q5,merge:J5,selection:ay,transition:Cy,call:ot.call,nodes:ot.nodes,node:ot.node,size:ot.size,empty:ot.empty,each:ot.each,on:ny,attr:A5,attrTween:V5,style:py,styleTween:hy,text:Ey,textTween:Ry,remove:oy,tween:L5,delay:Z5,duration:G5,ease:W5,easeVarying:q5,end:wy,[Symbol.iterator]:ot[Symbol.iterator]};function vy(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var _y={time:null,delay:0,duration:250,ease:vy};function ky(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 Ly(e){var t,n;e instanceof at?(t=e._id,e=e._name):(t=Fu(),(n=_y).time=Fr(),e=e==null?null:e+"");for(var s=this._groups,r=s.length,i=0;i<r;++i)for(var l=s[i],a=l.length,c,d=0;d<a;++d)(c=l[d])&&$s(c,e,t,d,l,n||ky(c,t));return new at(s,this._parents,e,t)}Dn.prototype.interrupt=v5;Dn.prototype.transition=Ly;const qn=e=>()=>e;function My(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 it(e,t,n){this.k=e,this.x=t,this.y=n}it.prototype={constructor:it,scale:function(e){return e===1?this:new it(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new it(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 zs=new it(1,0,0);Hu.prototype=it.prototype;function Hu(e){for(;!e.__zoom;)if(!(e=e.parentNode))return zs;return e.__zoom}function po(e){e.stopImmediatePropagation()}function mn(e){e.preventDefault(),e.stopImmediatePropagation()}function Ny(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Py(){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 Zi(){return this.__zoom||zs}function Ty(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Iy(){return navigator.maxTouchPoints||"ontouchstart"in this}function Oy(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 Zu(){var e=Ny,t=Py,n=Oy,s=Ty,r=Iy,i=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],a=250,c=rs,d=As("start","zoom","end"),x,p,m,h=500,g=150,E=0,S=10;function R(b){b.property("__zoom",Zi).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",z).filter(r).on("touchstart.zoom",$).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}R.transform=function(b,k,L,N){var F=b.selection?b.selection():b;F.property("__zoom",Zi),b!==F?_(b,k,L,N):F.interrupt().each(function(){M(this,arguments).event(N).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},R.scaleBy=function(b,k,L,N){R.scaleTo(b,function(){var F=this.__zoom.k,H=typeof k=="function"?k.apply(this,arguments):k;return F*H},L,N)},R.scaleTo=function(b,k,L,N){R.transform(b,function(){var F=t.apply(this,arguments),H=this.__zoom,K=L==null?C(F):typeof L=="function"?L.apply(this,arguments):L,Z=H.invert(K),Y=typeof k=="function"?k.apply(this,arguments):k;return n(y(v(H,Y),K,Z),F,l)},L,N)},R.translateBy=function(b,k,L,N){R.transform(b,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof L=="function"?L.apply(this,arguments):L),t.apply(this,arguments),l)},null,N)},R.translateTo=function(b,k,L,N,F){R.transform(b,function(){var H=t.apply(this,arguments),K=this.__zoom,Z=N==null?C(H):typeof N=="function"?N.apply(this,arguments):N;return n(zs.translate(Z[0],Z[1]).scale(K.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof L=="function"?-L.apply(this,arguments):-L),H,l)},N,F)};function v(b,k){return k=Math.max(i[0],Math.min(i[1],k)),k===b.k?b:new it(k,b.x,b.y)}function y(b,k,L){var N=k[0]-L[0]*b.k,F=k[1]-L[1]*b.k;return N===b.x&&F===b.y?b:new it(b.k,N,F)}function C(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function _(b,k,L,N){b.on("start.zoom",function(){M(this,arguments).event(N).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event(N).end()}).tween("zoom",function(){var F=this,H=arguments,K=M(F,H).event(N),Z=t.apply(F,H),Y=L==null?C(Z):typeof L=="function"?L.apply(F,H):L,ne=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),J=F.__zoom,ce=typeof k=="function"?k.apply(F,H):k,le=c(J.invert(Y).concat(ne/J.k),ce.invert(Y).concat(ne/ce.k));return function(se){if(se===1)se=ce;else{var ee=le(se),re=ne/ee[2];se=new it(re,Y[0]-ee[0]*re,Y[1]-ee[1]*re)}K.zoom(null,se)}})}function M(b,k,L){return!L&&b.__zooming||new I(b,k)}function I(b,k){this.that=b,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,k),this.taps=0}I.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,k){return this.mouse&&b!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var k=ze(this.that).datum();d.call(b,this.that,new My(b,{sourceEvent:this.sourceEvent,target:R,transform:this.that.__zoom,dispatch:d}),k)}};function A(b,...k){if(!e.apply(this,arguments))return;var L=M(this,k).event(b),N=this.__zoom,F=Math.max(i[0],Math.min(i[1],N.k*Math.pow(2,s.apply(this,arguments)))),H=Ge(b);if(L.wheel)(L.mouse[0][0]!==H[0]||L.mouse[0][1]!==H[1])&&(L.mouse[1]=N.invert(L.mouse[0]=H)),clearTimeout(L.wheel);else{if(N.k===F)return;L.mouse=[H,N.invert(H)],us(this),L.start()}mn(b),L.wheel=setTimeout(K,g),L.zoom("mouse",n(y(v(N,F),L.mouse[0],L.mouse[1]),L.extent,l));function K(){L.wheel=null,L.end()}}function B(b,...k){if(m||!e.apply(this,arguments))return;var L=b.currentTarget,N=M(this,k,!0).event(b),F=ze(b.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",ne,!0),H=Ge(b,L),K=b.clientX,Z=b.clientY;Tu(b.view),po(b),N.mouse=[H,this.__zoom.invert(H)],us(this),N.start();function Y(J){if(mn(J),!N.moved){var ce=J.clientX-K,le=J.clientY-Z;N.moved=ce*ce+le*le>E}N.event(J).zoom("mouse",n(y(N.that.__zoom,N.mouse[0]=Ge(J,L),N.mouse[1]),N.extent,l))}function ne(J){F.on("mousemove.zoom mouseup.zoom",null),Iu(J.view,N.moved),mn(J),N.event(J).end()}}function z(b,...k){if(e.apply(this,arguments)){var L=this.__zoom,N=Ge(b.changedTouches?b.changedTouches[0]:b,this),F=L.invert(N),H=L.k*(b.shiftKey?.5:2),K=n(y(v(L,H),N,F),t.apply(this,k),l);mn(b),a>0?ze(this).transition().duration(a).call(_,K,N,b):ze(this).call(R.transform,K,N,b)}}function $(b,...k){if(e.apply(this,arguments)){var L=b.touches,N=L.length,F=M(this,k,b.changedTouches.length===N).event(b),H,K,Z,Y;for(po(b),K=0;K<N;++K)Z=L[K],Y=Ge(Z,this),Y=[Y,this.__zoom.invert(Y),Z.identifier],F.touch0?!F.touch1&&F.touch0[2]!==Y[2]&&(F.touch1=Y,F.taps=0):(F.touch0=Y,H=!0,F.taps=1+!!x);x&&(x=clearTimeout(x)),H&&(F.taps<2&&(p=Y[0],x=setTimeout(function(){x=null},h)),us(this),F.start())}}function D(b,...k){if(this.__zooming){var L=M(this,k).event(b),N=b.changedTouches,F=N.length,H,K,Z,Y;for(mn(b),H=0;H<F;++H)K=N[H],Z=Ge(K,this),L.touch0&&L.touch0[2]===K.identifier?L.touch0[0]=Z:L.touch1&&L.touch1[2]===K.identifier&&(L.touch1[0]=Z);if(K=L.that.__zoom,L.touch1){var ne=L.touch0[0],J=L.touch0[1],ce=L.touch1[0],le=L.touch1[1],se=(se=ce[0]-ne[0])*se+(se=ce[1]-ne[1])*se,ee=(ee=le[0]-J[0])*ee+(ee=le[1]-J[1])*ee;K=v(K,Math.sqrt(se/ee)),Z=[(ne[0]+ce[0])/2,(ne[1]+ce[1])/2],Y=[(J[0]+le[0])/2,(J[1]+le[1])/2]}else if(L.touch0)Z=L.touch0[0],Y=L.touch0[1];else return;L.zoom("touch",n(y(K,Z,Y),L.extent,l))}}function V(b,...k){if(this.__zooming){var L=M(this,k).event(b),N=b.changedTouches,F=N.length,H,K;for(po(b),m&&clearTimeout(m),m=setTimeout(function(){m=null},h),H=0;H<F;++H)K=N[H],L.touch0&&L.touch0[2]===K.identifier?delete L.touch0:L.touch1&&L.touch1[2]===K.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(K=Ge(K,this),Math.hypot(p[0]-K[0],p[1]-K[1])<S)){var Z=ze(this).on("dblclick.zoom");Z&&Z.apply(this,arguments)}}}return R.wheelDelta=function(b){return arguments.length?(s=typeof b=="function"?b:qn(+b),R):s},R.filter=function(b){return arguments.length?(e=typeof b=="function"?b:qn(!!b),R):e},R.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:qn(!!b),R):r},R.extent=function(b){return arguments.length?(t=typeof b=="function"?b:qn([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),R):t},R.scaleExtent=function(b){return arguments.length?(i[0]=+b[0],i[1]=+b[1],R):[i[0],i[1]]},R.translateExtent=function(b){return arguments.length?(l[0][0]=+b[0][0],l[1][0]=+b[1][0],l[0][1]=+b[0][1],l[1][1]=+b[1][1],R):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},R.constrain=function(b){return arguments.length?(n=b,R):n},R.duration=function(b){return arguments.length?(a=+b,R):a},R.interpolate=function(b){return arguments.length?(c=b,R):c},R.on=function(){var b=d.on.apply(d,arguments);return b===d?R:b},R.clickDistance=function(b){return arguments.length?(E=(b=+b)*b,R):Math.sqrt(E)},R.tapDistance=function(b){return arguments.length?(S=+b,R):S},R}const Oe={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:s}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},_n=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ku=["Enter"," ","Escape"],Yu={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Pt;(function(e){e.Strict="strict",e.Loose="loose"})(Pt||(Pt={}));var bt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(bt||(bt={}));var Jt;(function(e){e.Partial="partial",e.Full="full"})(Jt||(Jt={}));const Gu={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var ft;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ft||(ft={}));var Rs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Rs||(Rs={}));var Q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Q||(Q={}));const Ki={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top};function Uu(e){return e===null?null:e?"valid":"invalid"}const Wu=e=>"id"in e&&"source"in e&&"target"in e,Ay=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Kr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Bn=(e,t=[0,0])=>{const{width:n,height:s}=ut(e),r=e.origin??t,i=n*r[0],l=s*r[1];return{x:e.position.x-i,y:e.position.y-l}},Dy=(e,t={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!t.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,r)=>{const i=typeof r=="string";let l=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(l=i?t.nodeLookup.get(r):Kr(r)?r:t.nodeLookup.get(r.id));const a=l?Cs(l,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Vs(s,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Fs(n)},$n=(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=Vs(n,r)}}),Fs(n)},Yr=(e,t,[n,s,r]=[0,0,1],i=!1,l=!1)=>{const a={...zn(t,[n,s,r]),width:t.width/r,height:t.height/r},c=[];for(const d of e.values()){const{measured:x,selectable:p=!0,hidden:m=!1}=d;if(l&&!p||m)continue;const h=x.width??d.width??d.initialWidth??null,g=x.height??d.height??d.initialHeight??null,E=kn(a,tn(d)),S=(h??0)*(g??0),R=i&&E>0;(!d.internals.handleBounds||R||E>=S||d.dragging)&&c.push(d)}return c},By=(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 $y(e,t){const n=new Map,s=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!s||s.has(r.id))&&n.set(r.id,r)}),n}async function zy({nodes:e,width:t,height:n,panZoom:s,minZoom:r,maxZoom:i},l){if(e.size===0)return Promise.resolve(!0);const a=$y(e,l),c=$n(a),d=Gr(c,t,n,l?.minZoom??r,l?.maxZoom??i,l?.padding??.1);return await s.setViewport(d,{duration:l?.duration,ease:l?.ease,interpolate:l?.interpolate}),Promise.resolve(!0)}function Xu({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:r,onError:i}){const l=n.get(e),a=l.parentId?n.get(l.parentId):void 0,{x:c,y:d}=a?a.internals.positionAbsolute:{x:0,y:0},x=l.origin??s;let p=r;if(l.extent==="parent"&&!l.expandParent)if(!a)i?.("005",Oe.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(p=[[c,d],[c+h,d+g]])}else a&&nn(l.extent)&&(p=[[l.extent[0][0]+c,l.extent[0][1]+d],[l.extent[1][0]+c,l.extent[1][1]+d]]);const m=nn(p)?Tt(t,p,l.measured):t;return(l.measured.width===void 0||l.measured.height===void 0)&&i?.("015",Oe.error015()),{position:{x:m.x-c+(l.measured.width??0)*x[0],y:m.y-d+(l.measured.height??0)*x[1]},positionAbsolute:m}}async function Vy({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 h=i.has(m.id),g=!h&&m.parentId&&l.find(E=>E.id===m.parentId);(h||g)&&l.push(m)}const a=new Set(t.map(m=>m.id)),c=s.filter(m=>m.deletable!==!1),x=By(l,c);for(const m of c)a.has(m.id)&&!x.find(g=>g.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 en=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Tt=(e={x:0,y:0},t,n)=>({x:en(e.x,t[0][0],t[1][0]-(n?.width??0)),y:en(e.y,t[0][1],t[1][1]-(n?.height??0))});function qu(e,t,n){const{width:s,height:r}=ut(n),{x:i,y:l}=n.internals.positionAbsolute;return Tt(e,[[i,l],[i+s,l+r]],t)}const Yi=(e,t,n)=>e<t?en(Math.abs(e-t),1,t)/t:e>n?-en(Math.abs(e-n),1,t)/t:0,Qu=(e,t,n=15,s=40)=>{const r=Yi(e.x,s,t.width-s)*n,i=Yi(e.y,s,t.height-s)*n;return[r,i]},Vs=(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)}),Ho=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),Fs=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),tn=(e,t=[0,0])=>{const{x:n,y:s}=Kr(e)?e.internals.positionAbsolute:Bn(e,t);return{x:n,y:s,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Cs=(e,t=[0,0])=>{const{x:n,y:s}=Kr(e)?e.internals.positionAbsolute:Bn(e,t);return{x:n,y:s,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:s+(e.measured?.height??e.height??e.initialHeight??0)}},Ju=(e,t)=>Fs(Vs(Ho(e),Ho(t))),kn=(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)},Gi=e=>Ue(e.width)&&Ue(e.height)&&Ue(e.x)&&Ue(e.y),Ue=e=>!isNaN(e)&&isFinite(e),ws=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},Hs=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),zn=({x:e,y:t},[n,s,r],i=!1,l=[1,1])=>{const a={x:(e-n)/r,y:(t-s)/r};return i?Hs(a,l):a},bs=({x:e,y:t},[n,s,r])=>({x:e*r+n,y:t*r+s});function Ht(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Fy(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=Ht(e,n),r=Ht(e,t);return{top:s,right:r,bottom:s,left:r,x:r*2,y:s*2}}if(typeof e=="object"){const s=Ht(e.top??e.y??0,n),r=Ht(e.bottom??e.y??0,n),i=Ht(e.left??e.x??0,t),l=Ht(e.right??e.x??0,t);return{top:s,right:l,bottom:r,left:i,x:i+l,y:s+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Hy(e,t,n,s,r,i){const{x:l,y:a}=bs(e,[t,n,s]),{x:c,y:d}=bs({x:e.x+e.width,y:e.y+e.height},[t,n,s]),x=r-c,p=i-d;return{left:Math.floor(l),top:Math.floor(a),right:Math.floor(x),bottom:Math.floor(p)}}const Gr=(e,t,n,s,r,i)=>{const l=Fy(i,t,n),a=(t-l.x)/e.width,c=(n-l.y)/e.height,d=Math.min(a,c),x=en(d,s,r),p=e.x+e.width/2,m=e.y+e.height/2,h=t/2-p*x,g=n/2-m*x,E=Hy(e,h,g,x,t,n),S={left:Math.min(E.left-l.left,0),top:Math.min(E.top-l.top,0),right:Math.min(E.right-l.right,0),bottom:Math.min(E.bottom-l.bottom,0)};return{x:h-S.left+S.right,y:g-S.top+S.bottom,zoom:x}},vs=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function nn(e){return e!==void 0&&e!=="parent"}function ut(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function ed(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function td(e,t={width:0,height:0},n,s,r){const i={...e},l=s.get(n);if(l){const a=l.origin||r;i.x+=l.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=l.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Ui(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Zy(){let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}}function Ky(e){return{...Yu,...e||{}}}function yn(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:r}){const{x:i,y:l}=tt(e),a=zn({x:i-(r?.left??0),y:l-(r?.top??0)},s),{x:c,y:d}=n?Hs(a,t):a;return{xSnapped:c,ySnapped:d,...a}}const Ur=e=>({width:e.offsetWidth,height:e.offsetHeight}),nd=e=>e?.getRootNode?.()||window?.document,Yy=["INPUT","SELECT","TEXTAREA"];function sd(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:Yy.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const od=e=>"clientX"in e,tt=(e,t)=>{const n=od(e),s=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:s-(t?.left??0),y:r-(t?.top??0)}},Wi=(e,t,n,s,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(l=>{const a=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:r,position:l.getAttribute("data-handlepos"),x:(a.left-n.left)/s,y:(a.top-n.top)/s,...Ur(l)}})};function rd({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:r,sourceControlY:i,targetControlX:l,targetControlY:a}){const c=e*.125+r*.375+l*.375+n*.125,d=t*.125+i*.375+a*.375+s*.125,x=Math.abs(c-e),p=Math.abs(d-t);return[c,d,x,p]}function Qn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Xi({pos:e,x1:t,y1:n,x2:s,y2:r,c:i}){switch(e){case Q.Left:return[t-Qn(t-s,i),n];case Q.Right:return[t+Qn(s-t,i),n];case Q.Top:return[t,n-Qn(n-r,i)];case Q.Bottom:return[t,n+Qn(r-n,i)]}}function id({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:s,targetY:r,targetPosition:i=Q.Top,curvature:l=.25}){const[a,c]=Xi({pos:n,x1:e,y1:t,x2:s,y2:r,c:l}),[d,x]=Xi({pos:i,x1:s,y1:r,x2:e,y2:t,c:l}),[p,m,h,g]=rd({sourceX:e,sourceY:t,targetX:s,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:d,targetControlY:x});return[`M${e},${t} C${a},${c} ${d},${x} ${s},${r}`,p,m,h,g]}function ld({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,a=s<t?s+l:s-l;return[i,a,r,l]}function Gy({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s,elevateOnSelect:r=!1}){if(s!==void 0)return s;const i=r&&n?1e3:0,l=Math.max(e.parentId?e.internals.z:0,t.parentId?t.internals.z:0);return i+l}function Uy({sourceNode:e,targetNode:t,width:n,height:s,transform:r}){const i=Vs(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 kn(l,Fs(i))>0}const ad=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,Wy=(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)),cd=(e,t)=>{if(!e.source||!e.target)return ws("006",Oe.error006()),t;let n;return Wu(e)?n={...e}:n={...e,id:ad(e)},Wy(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))},Xy=(e,t,n,s={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return ws("006",Oe.error006()),n;if(!n.find(c=>c.id===e.id))return ws("007",Oe.error007(r)),n;const a={...i,id:s.shouldReplaceId?ad(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(c=>c.id!==r).concat(a)};function ud({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[r,i,l,a]=ld({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,r,i,l,a]}const qi={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},qy=({source:e,sourcePosition:t=Q.Bottom,target:n})=>t===Q.Left||t===Q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Qi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Qy({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:s=Q.Top,center:r,offset:i}){const l=qi[t],a=qi[s],c={x:e.x+l.x*i,y:e.y+l.y*i},d={x:n.x+a.x*i,y:n.y+a.y*i},x=qy({source:c,sourcePosition:t,target:d}),p=x.x!==0?"x":"y",m=x[p];let h=[],g,E;const S={x:0,y:0},R={x:0,y:0},[v,y,C,_]=ld({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*a[p]===-1){g=r.x??v,E=r.y??y;const I=[{x:g,y:c.y},{x:g,y:d.y}],A=[{x:c.x,y:E},{x:d.x,y:E}];l[p]===m?h=p==="x"?I:A:h=p==="x"?A:I}else{const I=[{x:c.x,y:d.y}],A=[{x:d.x,y:c.y}];if(p==="x"?h=l.x===m?A:I:h=l.y===m?I:A,t===s){const V=Math.abs(e[p]-n[p]);if(V<=i){const b=Math.min(i-1,i-V);l[p]===m?S[p]=(c[p]>e[p]?-1:1)*b:R[p]=(d[p]>n[p]?-1:1)*b}}if(t!==s){const V=p==="x"?"y":"x",b=l[p]===a[V],k=c[V]>d[V],L=c[V]<d[V];(l[p]===1&&(!b&&k||b&&L)||l[p]!==1&&(!b&&L||b&&k))&&(h=p==="x"?I:A)}const B={x:c.x+S.x,y:c.y+S.y},z={x:d.x+R.x,y:d.y+R.y},$=Math.max(Math.abs(B.x-h[0].x),Math.abs(z.x-h[0].x)),D=Math.max(Math.abs(B.y-h[0].y),Math.abs(z.y-h[0].y));$>=D?(g=(B.x+z.x)/2,E=h[0].y):(g=h[0].x,E=(B.y+z.y)/2)}return[[e,{x:c.x+S.x,y:c.y+S.y},...h,{x:d.x+R.x,y:d.y+R.y},n],g,E,C,_]}function Jy(e,t,n,s){const r=Math.min(Qi(e,t)/2,Qi(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 a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${l+r*c}Q ${i},${l} ${i+r*a},${l}`}function Zo({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:s,targetY:r,targetPosition:i=Q.Top,borderRadius:l=5,centerX:a,centerY:c,offset:d=20}){const[x,p,m,h,g]=Qy({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:r},targetPosition:i,center:{x:a,y:c},offset:d});return[x.reduce((S,R,v)=>{let y="";return v>0&&v<x.length-1?y=Jy(x[v-1],R,x[v+1],l):y=`${v===0?"M":"L"}${R.x} ${R.y}`,S+=y,S},""),p,m,h,g]}function Ji(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function eS(e){const{sourceNode:t,targetNode:n}=e;if(!Ji(t)||!Ji(n))return null;const s=t.internals.handleBounds||el(t.handles),r=n.internals.handleBounds||el(n.handles),i=tl(s?.source??[],e.sourceHandle),l=tl(e.connectionMode===Pt.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!l)return e.onError?.("008",Oe.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||Q.Bottom,c=l?.position||Q.Top,d=Ln(t,i,a),x=Ln(n,l,c);return{sourceX:d.x,sourceY:d.y,targetX:x.x,targetY:x.y,sourcePosition:a,targetPosition:c}}function el(e){if(!e)return null;const t=[],n=[];for(const s of e)s.width=s.width??1,s.height=s.height??1,s.type==="source"?t.push(s):s.type==="target"&&n.push(s);return{source:t,target:n}}function Ln(e,t,n=Q.Left,s=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:l,height:a}=t??ut(e);if(s)return{x:r+l/2,y:i+a/2};switch(t?.position??n){case Q.Top:return{x:r+l/2,y:i};case Q.Right:return{x:r+l,y:i+a/2};case Q.Bottom:return{x:r+l/2,y:i+a};case Q.Left:return{x:r,y:i+a/2}}}function tl(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ko(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function tS(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:r}){const i=new Set;return e.reduce((l,a)=>([a.markerStart||s,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const d=Ko(c,t);i.has(d)||(l.push({id:d,color:c.color||n,...c}),i.add(d))}}),l),[]).sort((l,a)=>l.id.localeCompare(a.id))}const Wr={nodeOrigin:[0,0],nodeExtent:_n,elevateNodesOnSelect:!0,defaults:{}},nS={...Wr,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 sS(e,t,n){const s=Xr(Wr,n);for(const r of e.values())if(r.parentId)qr(r,e,t,s);else{const i=Bn(r,s.nodeOrigin),l=nn(r.extent)?r.extent:s.nodeExtent,a=Tt(i,l,ut(r));r.internals.positionAbsolute=a}}function Yo(e,t,n,s){const r=Xr(nS,s);let i=e.length>0;const l=new Map(t),a=r?.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const c of e){let d=l.get(c.id);if(r.checkEquality&&c===d?.internals.userNode)t.set(c.id,d);else{const x=Bn(c,r.nodeOrigin),p=nn(c.extent)?c.extent:r.nodeExtent,m=Tt(x,p,ut(c));d={...r.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:m,handleBounds:c.measured?d?.internals.handleBounds:void 0,z:dd(c,a),userNode:c}},t.set(c.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(i=!1),c.parentId&&qr(d,t,n,s)}return i}function oS(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 qr(e,t,n,s){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:l}=Xr(Wr,s),a=e.parentId,c=t.get(a);if(!c){console.warn(`Parent node ${a} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}oS(e,n);const d=r?1e3:0,{x,y:p,z:m}=rS(e,c,i,l,d),{positionAbsolute:h}=e.internals,g=x!==h.x||p!==h.y;(g||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:g?{x,y:p}:h,z:m}})}function dd(e,t){return(Ue(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function rS(e,t,n,s,r){const{x:i,y:l}=t.internals.positionAbsolute,a=ut(e),c=Bn(e,n),d=nn(e.extent)?Tt(c,e.extent,a):c;let x=Tt({x:i+d.x,y:l+d.y},s,a);e.extent==="parent"&&(x=qu(x,a,t));const p=dd(e,r),m=t.internals.z??0;return{x:x.x,y:x.y,z:m>=p?m+1:p}}function Qr(e,t,n,s=[0,0]){const r=[],i=new Map;for(const l of e){const a=t.get(l.parentId);if(!a)continue;const c=i.get(l.parentId)?.expandedRect??tn(a),d=Ju(c,l.rect);i.set(l.parentId,{expandedRect:d,parent:a})}return i.size>0&&i.forEach(({expandedRect:l,parent:a},c)=>{const d=a.internals.positionAbsolute,x=ut(a),p=a.origin??s,m=l.x<d.x?Math.round(Math.abs(d.x-l.x)):0,h=l.y<d.y?Math.round(Math.abs(d.y-l.y)):0,g=Math.max(x.width,Math.round(l.width)),E=Math.max(x.height,Math.round(l.height)),S=(g-x.width)*p[0],R=(E-x.height)*p[1];(m>0||h>0||S||R)&&(r.push({id:c,type:"position",position:{x:a.position.x-m+S,y:a.position.y-h+R}}),n.get(c)?.forEach(v=>{e.some(y=>y.id===v.id)||r.push({id:v.id,type:"position",position:{x:v.position.x+m,y:v.position.y+h}})})),(x.width<l.width||x.height<l.height||m||h)&&r.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:g+(m?p[0]*m-S:0),height:E+(h?p[1]*h-R:0)}})}),r}function iS(e,t,n,s,r,i){const l=s?.querySelector(".xyflow__viewport");let a=!1;if(!l)return{changes:[],updatedInternals:a};const c=[],d=window.getComputedStyle(l),{m22:x}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const m of e.values()){const h=t.get(m.id);if(!h)continue;if(h.hidden){t.set(h.id,{...h,internals:{...h.internals,handleBounds:void 0}}),a=!0;continue}const g=Ur(m.nodeElement),E=h.measured.width!==g.width||h.measured.height!==g.height;if(!!(g.width&&g.height&&(E||!h.internals.handleBounds||m.force))){const R=m.nodeElement.getBoundingClientRect(),v=nn(h.extent)?h.extent:i;let{positionAbsolute:y}=h.internals;h.parentId&&h.extent==="parent"?y=qu(y,g,t.get(h.parentId)):v&&(y=Tt(y,v,g));const C={...h,measured:g,internals:{...h.internals,positionAbsolute:y,handleBounds:{source:Wi("source",m.nodeElement,R,x,h.id),target:Wi("target",m.nodeElement,R,x,h.id)}}};t.set(h.id,C),h.parentId&&qr(C,t,n,{nodeOrigin:r}),a=!0,E&&(c.push({id:h.id,type:"dimensions",dimensions:g}),h.expandParent&&h.parentId&&p.push({id:h.id,parentId:h.parentId,rect:tn(C,r)}))}}if(p.length>0){const m=Qr(p,t,n,r);c.push(...m)}return{changes:c,updatedInternals:a}}async function lS({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),a=!!l&&(l.x!==n[0]||l.y!==n[1]||l.k!==n[2]);return Promise.resolve(a)}function nl(e,t,n,s,r,i){let l=r;const a=s.get(l)||new Map;s.set(l,a.set(n,t)),l=`${r}-${e}`;const c=s.get(l)||new Map;if(s.set(l,c.set(n,t)),i){l=`${r}-${e}-${i}`;const d=s.get(l)||new Map;s.set(l,d.set(n,t))}}function xd(e,t,n){e.clear(),t.clear();for(const s of n){const{source:r,target:i,sourceHandle:l=null,targetHandle:a=null}=s,c={edgeId:s.id,source:r,target:i,sourceHandle:l,targetHandle:a},d=`${r}-${l}--${i}-${a}`,x=`${i}-${a}--${r}-${l}`;nl("source",c,x,e,r,l),nl("target",c,d,e,i,a),t.set(s.id,s)}}function pd(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:pd(n,t):!1}function sl(e,t,n){let s=e;do{if(s?.matches?.(t))return!0;if(s===n)return!1;s=s?.parentElement}while(s);return!1}function aS(e,t,n,s){const r=new Map;for(const[i,l]of e)if((l.selected||l.id===s)&&(!l.parentId||!pd(l,e))&&(l.draggable||t&&typeof l.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function mo({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){const r=[];for(const[l,a]of t){const c=n.get(l)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:s})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:s}:r[0],r]}function cS({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:r}){let i={x:null,y:null},l=0,a=new Map,c=!1,d={x:0,y:0},x=null,p=!1,m=null,h=!1,g=!1;function E({noDragClassName:R,handleSelector:v,domNode:y,isSelectable:C,nodeId:_,nodeClickDistance:M=0}){m=ze(y);function I({x:$,y:D},V){const{nodeLookup:b,nodeExtent:k,snapGrid:L,snapToGrid:N,nodeOrigin:F,onNodeDrag:H,onSelectionDrag:K,onError:Z,updateNodePositions:Y}=t();i={x:$,y:D};let ne=!1,J={x:0,y:0,x2:0,y2:0};if(a.size>1&&k){const ce=$n(a);J=Ho(ce)}for(const[ce,le]of a){if(!b.has(ce))continue;let se={x:$-le.distance.x,y:D-le.distance.y};N&&(se=Hs(se,L));let ee=[[k[0][0],k[0][1]],[k[1][0],k[1][1]]];if(a.size>1&&k&&!le.extent){const{positionAbsolute:Se}=le.internals,ue=Se.x-J.x+k[0][0],me=Se.x+le.measured.width-J.x2+k[1][0],X=Se.y-J.y+k[0][1],de=Se.y+le.measured.height-J.y2+k[1][1];ee=[[ue,X],[me,de]]}const{position:re,positionAbsolute:ye}=Xu({nodeId:ce,nextPosition:se,nodeLookup:b,nodeExtent:ee,nodeOrigin:F,onError:Z});ne=ne||le.position.x!==re.x||le.position.y!==re.y,le.position=re,le.internals.positionAbsolute=ye}if(g=g||ne,!!ne&&(Y(a,!0),V&&(s||H||!_&&K))){const[ce,le]=mo({nodeId:_,dragItems:a,nodeLookup:b});s?.(V,a,ce,le),H?.(V,ce,le),_||K?.(V,le)}}async function A(){if(!x)return;const{transform:$,panBy:D,autoPanSpeed:V,autoPanOnNodeDrag:b}=t();if(!b){c=!1,cancelAnimationFrame(l);return}const[k,L]=Qu(d,x,V);(k!==0||L!==0)&&(i.x=(i.x??0)-k/$[2],i.y=(i.y??0)-L/$[2],await D({x:k,y:L})&&I(i,null)),l=requestAnimationFrame(A)}function B($){const{nodeLookup:D,multiSelectionActive:V,nodesDraggable:b,transform:k,snapGrid:L,snapToGrid:N,selectNodesOnDrag:F,onNodeDragStart:H,onSelectionDragStart:K,unselectNodesAndEdges:Z}=t();p=!0,(!F||!C)&&!V&&_&&(D.get(_)?.selected||Z()),C&&F&&_&&e?.(_);const Y=yn($.sourceEvent,{transform:k,snapGrid:L,snapToGrid:N,containerBounds:x});if(i=Y,a=aS(D,b,Y,_),a.size>0&&(n||H||!_&&K)){const[ne,J]=mo({nodeId:_,dragItems:a,nodeLookup:D});n?.($.sourceEvent,a,ne,J),H?.($.sourceEvent,ne,J),_||K?.($.sourceEvent,J)}}const z=Ou().clickDistance(M).on("start",$=>{const{domNode:D,nodeDragThreshold:V,transform:b,snapGrid:k,snapToGrid:L}=t();x=D?.getBoundingClientRect()||null,h=!1,g=!1,V===0&&B($),i=yn($.sourceEvent,{transform:b,snapGrid:k,snapToGrid:L,containerBounds:x}),d=tt($.sourceEvent,x)}).on("drag",$=>{const{autoPanOnNodeDrag:D,transform:V,snapGrid:b,snapToGrid:k,nodeDragThreshold:L,nodeLookup:N}=t(),F=yn($.sourceEvent,{transform:V,snapGrid:b,snapToGrid:k,containerBounds:x});if(($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||_&&!N.has(_))&&(h=!0),!h){if(!c&&D&&p&&(c=!0,A()),!p){const H=F.xSnapped-(i.x??0),K=F.ySnapped-(i.y??0);Math.sqrt(H*H+K*K)>L&&B($)}(i.x!==F.xSnapped||i.y!==F.ySnapped)&&a&&p&&(d=tt($.sourceEvent,x),I(F,$.sourceEvent))}}).on("end",$=>{if(!(!p||h)&&(c=!1,p=!1,cancelAnimationFrame(l),a.size>0)){const{nodeLookup:D,updateNodePositions:V,onNodeDragStop:b,onSelectionDragStop:k}=t();if(g&&(V(a,!1),g=!1),r||b||!_&&k){const[L,N]=mo({nodeId:_,dragItems:a,nodeLookup:D,dragging:!1});r?.($.sourceEvent,a,L,N),b?.($.sourceEvent,L,N),_||k?.($.sourceEvent,N)}}}).filter($=>{const D=$.target;return!$.button&&(!R||!sl(D,`.${R}`,y))&&(!v||sl(D,v,y))});m.call(z)}function S(){m?.on(".drag",null)}return{update:E,destroy:S}}function uS(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())kn(r,tn(i))>0&&s.push(i);return s}const dS=250;function xS(e,t,n,s){let r=[],i=1/0;const l=uS(e,n,t+dS);for(const a of l){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const d of c){if(s.nodeId===d.nodeId&&s.type===d.type&&s.id===d.id)continue;const{x,y:p}=Ln(a,d,d.position,!0),m=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(p-e.y,2));m>t||(m<i?(r=[{...d,x,y:p}],i=m):m===i&&r.push({...d,x,y:p}))}}if(!r.length)return null;if(r.length>1){const a=s.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function md(e,t,n,s,r,i=!1){const l=s.get(e);if(!l)return null;const a=r==="strict"?l.internals.handleBounds?.[t]:[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]],c=(n?a?.find(d=>d.id===n):a?.[0])??null;return c&&i?{...c,...Ln(l,c,c.position,!0)}:c}function fd(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function pS(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const hd=()=>!0;function mS(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:r,edgeUpdaterType:i,isTarget:l,domNode:a,nodeLookup:c,lib:d,autoPanOnConnect:x,flowId:p,panBy:m,cancelConnection:h,onConnectStart:g,onConnect:E,onConnectEnd:S,isValidConnection:R=hd,onReconnectEnd:v,updateConnection:y,getTransform:C,getFromHandle:_,autoPanSpeed:M,dragThreshold:I=1}){const A=nd(e.target);let B=0,z;const{x:$,y:D}=tt(e),V=A?.elementFromPoint($,D),b=fd(i,V),k=a?.getBoundingClientRect();let L=!1;if(!k||!b)return;const N=md(r,b,s,c,t);if(!N)return;let F=tt(e,k),H=!1,K=null,Z=!1,Y=null;function ne(){if(!x||!k)return;const[Se,ue]=Qu(F,k,M);m({x:Se,y:ue}),B=requestAnimationFrame(ne)}const J={...N,nodeId:r,type:b,position:N.position},ce=c.get(r);let se={inProgress:!0,isValid:null,from:Ln(ce,J,Q.Left,!0),fromHandle:J,fromPosition:J.position,fromNode:ce,to:F,toHandle:null,toPosition:Ki[J.position],toNode:null};function ee(){L=!0,y(se),g?.(e,{nodeId:r,handleId:s,handleType:b})}I===0&&ee();function re(Se){if(!L){const{x:de,y:be}=tt(Se),Te=de-$,et=be-D;if(!(Te*Te+et*et>I*I))return;ee()}if(!_()||!J){ye(Se);return}const ue=C();F=tt(Se,k),z=xS(zn(F,ue,!1,[1,1]),n,c,J),H||(ne(),H=!0);const me=gd(Se,{handle:z,connectionMode:t,fromNodeId:r,fromHandleId:s,fromType:l?"target":"source",isValidConnection:R,doc:A,lib:d,flowId:p,nodeLookup:c});Y=me.handleDomNode,K=me.connection,Z=pS(!!z,me.isValid);const X={...se,isValid:Z,to:me.toHandle&&Z?bs({x:me.toHandle.x,y:me.toHandle.y},ue):F,toHandle:me.toHandle,toPosition:Z&&me.toHandle?me.toHandle.position:Ki[J.position],toNode:me.toHandle?c.get(me.toHandle.nodeId):null};Z&&z&&se.toHandle&&X.toHandle&&se.toHandle.type===X.toHandle.type&&se.toHandle.nodeId===X.toHandle.nodeId&&se.toHandle.id===X.toHandle.id&&se.to.x===X.to.x&&se.to.y===X.to.y||(y(X),se=X)}function ye(Se){if(L){(z||Y)&&K&&Z&&E?.(K);const{inProgress:ue,...me}=se,X={...me,toPosition:se.toHandle?se.toPosition:null};S?.(Se,X),i&&v?.(Se,X)}h(),cancelAnimationFrame(B),H=!1,Z=!1,K=null,Y=null,A.removeEventListener("mousemove",re),A.removeEventListener("mouseup",ye),A.removeEventListener("touchmove",re),A.removeEventListener("touchend",ye)}A.addEventListener("mousemove",re),A.addEventListener("mouseup",ye),A.addEventListener("touchmove",re),A.addEventListener("touchend",ye)}function gd(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:r,fromType:i,doc:l,lib:a,flowId:c,isValidConnection:d=hd,nodeLookup:x}){const p=i==="target",m=t?l.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=tt(e),E=l.elementFromPoint(h,g),S=E?.classList.contains(`${a}-flow__handle`)?E:m,R={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const v=fd(void 0,S),y=S.getAttribute("data-nodeid"),C=S.getAttribute("data-handleid"),_=S.classList.contains("connectable"),M=S.classList.contains("connectableend");if(!y||!v)return R;const I={source:p?y:s,sourceHandle:p?C:r,target:p?s:y,targetHandle:p?r:C};R.connection=I;const B=_&&M&&(n===Pt.Strict?p&&v==="source"||!p&&v==="target":y!==s||C!==r);R.isValid=B&&d(I),R.toHandle=md(y,v,C,x,n,!0)}return R}const Go={onPointerDown:mS,isValid:gd};function fS({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const r=ze(e);function i({translateExtent:a,width:c,height:d,zoomStep:x=10,pannable:p=!0,zoomable:m=!0,inversePan:h=!1}){const g=y=>{const C=n();if(y.sourceEvent.type!=="wheel"||!t)return;const _=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*x,M=C[2]*Math.pow(2,_);t.scaleTo(M)};let E=[0,0];const S=y=>{(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(E=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY])},R=y=>{const C=n();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!t)return;const _=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY],M=[_[0]-E[0],_[1]-E[1]];E=_;const I=s()*Math.max(C[2],Math.log(C[2]))*(h?-1:1),A={x:C[0]-M[0]*I,y:C[1]-M[1]*I},B=[[0,0],[c,d]];t.setViewportConstrained({x:A.x,y:A.y,zoom:C[2]},B,a)},v=Zu().on("start",S).on("zoom",p?R:null).on("zoom.wheel",m?g:null);r.call(v,{})}function l(){r.on("zoom",null)}return{update:i,destroy:l,pointer:Ge}}const hS=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Zs=e=>({x:e.x,y:e.y,zoom:e.k}),fo=({x:e,y:t,zoom:n})=>zs.translate(e,t).scale(n),Kt=(e,t)=>e.target.closest(`.${t}`),jd=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),gS=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ho=(e,t=0,n=gS,s=()=>{})=>{const r=typeof t=="number"&&t>0;return r||s(),r?e.transition().duration(t).ease(n).on("end",s):e},Ed=e=>{const t=e.ctrlKey&&vs()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function jS({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:l,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:d}){return x=>{if(Kt(x,t))return!1;x.preventDefault(),x.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(x.ctrlKey&&l){const S=Ge(x),R=Ed(x),v=p*Math.pow(2,R);s.scaleTo(n,v,S,x);return}const m=x.deltaMode===1?20:1;let h=r===bt.Vertical?0:x.deltaX*m,g=r===bt.Horizontal?0:x.deltaY*m;!vs()&&x.shiftKey&&r!==bt.Vertical&&(h=x.deltaY*m,g=0),s.translateBy(n,-(h/p)*i,-(g/p)*i,{internal:!0});const E=Zs(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,a?.(x,E)),e.isPanScrolling&&(c?.(x,E),e.panScrollTimeout=setTimeout(()=>{d?.(x,E),e.isPanScrolling=!1},150))}}function ES({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,r){const i=s.type==="wheel",l=!t&&i&&!s.ctrlKey,a=Kt(s,e);if(s.ctrlKey&&i&&a&&s.preventDefault(),l||a)return null;s.preventDefault(),n.call(this,s,r)}}function yS({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{if(s.sourceEvent?.internal)return;const r=Zs(s.transform);e.mouseButton=s.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,s.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(s.sourceEvent,r)}}function SS({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&jd(t,e.mouseButton??0)),i.sourceEvent?.sync||s([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,Zs(i.transform))}}function RS({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:r,onPaneContextMenu:i}){return l=>{if(!l.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&jd(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&i(l.sourceEvent),e.usedRightMouseButton=!1,s(!1),r&&hS(e.prevViewport,l.transform))){const a=Zs(l.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(l.sourceEvent,a)},n?150:0)}}}function CS({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:l,noWheelClassName:a,noPanClassName:c,lib:d}){return x=>{const p=e||t,m=n&&x.ctrlKey;if(x.button===1&&x.type==="mousedown"&&(Kt(x,`${d}-flow__node`)||Kt(x,`${d}-flow__edge`)))return!0;if(!s&&!p&&!r&&!i&&!n||l||Kt(x,a)&&x.type==="wheel"||Kt(x,c)&&(x.type!=="wheel"||r&&x.type==="wheel"&&!e)||!n&&x.ctrlKey&&x.type==="wheel")return!1;if(!n&&x.type==="touchstart"&&x.touches?.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 h=Array.isArray(s)&&s.includes(x.button)||!x.button||x.button<=1;return(!x.ctrlKey||x.type==="wheel")&&h}}function wS({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:s,translateExtent:r,viewport:i,onPanZoom:l,onPanZoomStart:a,onPanZoomEnd:c,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=Zu().clickDistance(!Ue(s)||s<0?0:s).scaleExtent([t,n]).translateExtent(r),h=ze(e).call(m);y({x:i.x,y:i.y,zoom:en(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const g=h.on("wheel.zoom"),E=h.on("dblclick.zoom");m.wheelDelta(Ed);function S(D,V){return h?new Promise(b=>{m?.interpolate(V?.interpolate==="linear"?O.interpolate:rs).transform(ho(h,V?.duration,V?.ease,()=>b(!0)),D)}):Promise.resolve(!1)}function R({noWheelClassName:D,noPanClassName:V,onPaneContextMenu:b,userSelectionActive:k,panOnScroll:L,panOnDrag:N,panOnScrollMode:F,panOnScrollSpeed:H,preventScrolling:K,zoomOnPinch:Z,zoomOnScroll:Y,zoomOnDoubleClick:ne,zoomActivationKeyPressed:J,lib:ce,onTransformChange:le}){k&&!x.isZoomingOrPanning&&v();const ee=L&&!J&&!k?jS({zoomPanValues:x,noWheelClassName:D,d3Selection:h,d3Zoom:m,panOnScrollMode:F,panOnScrollSpeed:H,zoomOnPinch:Z,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}):ES({noWheelClassName:D,preventScrolling:K,d3ZoomHandler:g});if(h.on("wheel.zoom",ee,{passive:!1}),!k){const ye=yS({zoomPanValues:x,onDraggingChange:d,onPanZoomStart:a});m.on("start",ye);const Se=SS({zoomPanValues:x,panOnDrag:N,onPaneContextMenu:!!b,onPanZoom:l,onTransformChange:le});m.on("zoom",Se);const ue=RS({zoomPanValues:x,panOnDrag:N,panOnScroll:L,onPaneContextMenu:b,onPanZoomEnd:c,onDraggingChange:d});m.on("end",ue)}const re=CS({zoomActivationKeyPressed:J,panOnDrag:N,zoomOnScroll:Y,panOnScroll:L,zoomOnDoubleClick:ne,zoomOnPinch:Z,userSelectionActive:k,noPanClassName:V,noWheelClassName:D,lib:ce});m.filter(re),ne?h.on("dblclick.zoom",E):h.on("dblclick.zoom",null)}function v(){m.on("zoom",null)}async function y(D,V,b){const k=fo(D),L=m?.constrain()(k,V,b);return L&&await S(L),new Promise(N=>N(L))}async function C(D,V){const b=fo(D);return await S(b,V),new Promise(k=>k(b))}function _(D){if(h){const V=fo(D),b=h.property("__zoom");(b.k!==D.zoom||b.x!==D.x||b.y!==D.y)&&m?.transform(h,V,null,{sync:!0})}}function M(){const D=h?Hu(h.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}function I(D,V){return h?new Promise(b=>{m?.interpolate(V?.interpolate==="linear"?O.interpolate:rs).scaleTo(ho(h,V?.duration,V?.ease,()=>b(!0)),D)}):Promise.resolve(!1)}function A(D,V){return h?new Promise(b=>{m?.interpolate(V?.interpolate==="linear"?O.interpolate:rs).scaleBy(ho(h,V?.duration,V?.ease,()=>b(!0)),D)}):Promise.resolve(!1)}function B(D){m?.scaleExtent(D)}function z(D){m?.translateExtent(D)}function $(D){const V=!Ue(D)||D<0?0:D;m?.clickDistance(V)}return{update:R,destroy:v,setViewport:C,setViewportConstrained:y,getViewport:M,scaleTo:I,scaleBy:A,setScaleExtent:B,setTranslateExtent:z,syncViewport:_,setClickDistance:$}}var sn;(function(e){e.Line="line",e.Handle="handle"})(sn||(sn={}));function bS({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:r,affectsY:i}){const l=e-t,a=n-s,c=[l>0?1:l<0?-1:0,a>0?1:a<0?-1:0];return l&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function vS(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 xt(e,t){return Math.max(0,t-e)}function pt(e,t){return Math.max(0,e-t)}function Jn(e,t,n){return Math.max(0,t-e,e-n)}function ol(e,t){return e?!t:t}function _S(e,t,n,s,r,i,l,a){let{affectsX:c,affectsY:d}=t;const{isHorizontal:x,isVertical:p}=t,m=x&&p,{xSnapped:h,ySnapped:g}=n,{minWidth:E,maxWidth:S,minHeight:R,maxHeight:v}=s,{x:y,y:C,width:_,height:M,aspectRatio:I}=e;let A=Math.floor(x?h-e.pointerX:0),B=Math.floor(p?g-e.pointerY:0);const z=_+(c?-A:A),$=M+(d?-B:B),D=-i[0]*_,V=-i[1]*M;let b=Jn(z,E,S),k=Jn($,R,v);if(l){let F=0,H=0;c&&A<0?F=xt(y+A+D,l[0][0]):!c&&A>0&&(F=pt(y+z+D,l[1][0])),d&&B<0?H=xt(C+B+V,l[0][1]):!d&&B>0&&(H=pt(C+$+V,l[1][1])),b=Math.max(b,F),k=Math.max(k,H)}if(a){let F=0,H=0;c&&A>0?F=pt(y+A,a[0][0]):!c&&A<0&&(F=xt(y+z,a[1][0])),d&&B>0?H=pt(C+B,a[0][1]):!d&&B<0&&(H=xt(C+$,a[1][1])),b=Math.max(b,F),k=Math.max(k,H)}if(r){if(x){const F=Jn(z/I,R,v)*I;if(b=Math.max(b,F),l){let H=0;!c&&!d||c&&!d&&m?H=pt(C+V+z/I,l[1][1])*I:H=xt(C+V+(c?A:-A)/I,l[0][1])*I,b=Math.max(b,H)}if(a){let H=0;!c&&!d||c&&!d&&m?H=xt(C+z/I,a[1][1])*I:H=pt(C+(c?A:-A)/I,a[0][1])*I,b=Math.max(b,H)}}if(p){const F=Jn($*I,E,S)/I;if(k=Math.max(k,F),l){let H=0;!c&&!d||d&&!c&&m?H=pt(y+$*I+D,l[1][0])/I:H=xt(y+(d?B:-B)*I+D,l[0][0])/I,k=Math.max(k,H)}if(a){let H=0;!c&&!d||d&&!c&&m?H=xt(y+$*I,a[1][0])/I:H=pt(y+(d?B:-B)*I,a[0][0])/I,k=Math.max(k,H)}}}B=B+(B<0?k:-k),A=A+(A<0?b:-b),r&&(m?z>$*I?B=(ol(c,d)?-A:A)/I:A=(ol(c,d)?-B:B)*I:x?(B=A/I,d=c):(A=B*I,c=d));const L=c?y+A:y,N=d?C+B:C;return{width:_+(c?-A:A),height:M+(d?-B:B),x:i[0]*A*(c?-1:1)+L,y:i[1]*B*(d?-1:1)+N}}const yd={width:0,height:0,x:0,y:0},kS={...yd,pointerX:0,pointerY:0,aspectRatio:1};function LS(e){return[[0,0],[e.measured.width,e.measured.height]]}function MS(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,a=n[0]*i,c=n[1]*l;return[[s-a,r-c],[s+i-a,r+l-c]]}function NS({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:r}){const i=ze(e);function l({controlPosition:c,boundaries:d,keepAspectRatio:x,resizeDirection:p,onResizeStart:m,onResize:h,onResizeEnd:g,shouldResize:E}){let S={...yd},R={...kS};const v=vS(c);let y,C=null,_=[],M,I,A;const B=Ou().on("start",z=>{const{nodeLookup:$,transform:D,snapGrid:V,snapToGrid:b,nodeOrigin:k,paneDomNode:L}=n();if(y=$.get(t),!y)return;C=L?.getBoundingClientRect()??null;const{xSnapped:N,ySnapped:F}=yn(z.sourceEvent,{transform:D,snapGrid:V,snapToGrid:b,containerBounds:C});S={width:y.measured.width??0,height:y.measured.height??0,x:y.position.x??0,y:y.position.y??0},R={...S,pointerX:N,pointerY:F,aspectRatio:S.width/S.height},M=void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(M=$.get(y.parentId),I=M&&y.extent==="parent"?LS(M):void 0),_=[],A=void 0;for(const[H,K]of $)if(K.parentId===t&&(_.push({id:H,position:{...K.position},extent:K.extent}),K.extent==="parent"||K.expandParent)){const Z=MS(K,y,K.origin??k);A?A=[[Math.min(Z[0][0],A[0][0]),Math.min(Z[0][1],A[0][1])],[Math.max(Z[1][0],A[1][0]),Math.max(Z[1][1],A[1][1])]]:A=Z}m?.(z,{...S})}).on("drag",z=>{const{transform:$,snapGrid:D,snapToGrid:V,nodeOrigin:b}=n(),k=yn(z.sourceEvent,{transform:$,snapGrid:D,snapToGrid:V,containerBounds:C}),L=[];if(!y)return;const{x:N,y:F,width:H,height:K}=S,Z={},Y=y.origin??b,{width:ne,height:J,x:ce,y:le}=_S(R,v,k,d,x,Y,I,A),se=ne!==H,ee=J!==K,re=ce!==N&&se,ye=le!==F&ⅇif(!re&&!ye&&!se&&!ee)return;if((re||ye||Y[0]===1||Y[1]===1)&&(Z.x=re?ce:S.x,Z.y=ye?le:S.y,S.x=Z.x,S.y=Z.y,_.length>0)){const X=ce-N,de=le-F;for(const be of _)be.position={x:be.position.x-X+Y[0]*(ne-H),y:be.position.y-de+Y[1]*(J-K)},L.push(be)}if((se||ee)&&(Z.width=se&&(!p||p==="horizontal")?ne:S.width,Z.height=ee&&(!p||p==="vertical")?J:S.height,S.width=Z.width,S.height=Z.height),M&&y.expandParent){const X=Y[0]*(Z.width??0);Z.x&&Z.x<X&&(S.x=X,R.x=R.x-(Z.x-X));const de=Y[1]*(Z.height??0);Z.y&&Z.y<de&&(S.y=de,R.y=R.y-(Z.y-de))}const Se=bS({width:S.width,prevWidth:H,height:S.height,prevHeight:K,affectsX:v.affectsX,affectsY:v.affectsY}),ue={...S,direction:Se};E?.(z,ue)!==!1&&(h?.(z,ue),s(Z,L))}).on("end",z=>{g?.(z,{...S}),r?.({...S})});i.call(B)}function a(){i.on(".drag",null)}return{update:l,destroy:a}}var es={exports:{}},go={},ts={exports:{}},jo={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-shim.production.js
|
|
4
4
|
*
|