@synnaxlabs/pluto 0.50.1 → 0.52.3
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-C4xrEVd-.js → Animated-6qL1fRZx.js} +61 -60
- package/dist/Animated-Bn4jMc7c.js +29 -0
- package/dist/Animated-vGAs0qOH.cjs +1 -0
- package/dist/Animated-xK__WUQp.cjs +1 -0
- package/dist/{Box-DLO7l9hM.js → Box-Bi280MYh.js} +28 -27
- package/dist/Box-CNUz5BsV.cjs +1 -0
- package/dist/Copy-CzkBKGca.js +337 -0
- package/dist/Copy-DuC8dTK7.cjs +1 -0
- package/dist/Dialog-DNrgykEv.cjs +1 -0
- package/dist/{Dialog-BspO7uo8.js → Dialog-Dos5l3K2.js} +13 -12
- package/dist/{Editable-DjQORuR1.js → Editable-4ZwvICC4.js} +46 -45
- package/dist/Editable-HUPqTaui.cjs +1 -0
- package/dist/{Haul-DBy-2ds_.js → Haul-CxbMtSY4.js} +18 -18
- package/dist/Haul-V5NQI3MY.cjs +1 -0
- package/dist/{Items-CX11yLMf.js → Items-CNPUoiob.js} +22 -21
- package/dist/Items-DYYNNIjr.cjs +4 -0
- package/dist/Menu-C0scum-k.cjs +1 -0
- package/dist/{Menu-GBo3ayoP.js → Menu-CTuOX5DR.js} +42 -41
- package/dist/Provider-DSMJjyuY.cjs +1 -0
- package/dist/{Provider-BkxUzTWS.js → Provider-ZIy-UlnE.js} +95 -93
- package/dist/Tags-6OV0_eBz.cjs +1 -0
- package/dist/{Tags-V7sNuGZv.js → Tags-BUDnOqms.js} +223 -222
- package/dist/{Text-XeD58Fq8.js → Text-BSTMZRuo.js} +717 -675
- package/dist/Text-C2_VsLzw.cjs +1 -0
- package/dist/Video-Bew5_j16.js +10 -0
- package/dist/Video-BryrVNlH.cjs +1 -0
- 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/css-CloSmhZB.cjs +1 -0
- package/dist/css-D90kZTM8.js +63 -0
- package/dist/css.cjs +1 -1
- package/dist/css.js +2 -2
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dimensions-CdFEW3oU.cjs +1 -0
- package/dist/{dimensions-qj2CkPTy.js → dimensions-DbMN4145.js} +8 -8
- package/dist/{eraser-DuAfpO0P.js → eraser-BShvqlBE.js} +52 -49
- package/dist/eraser-rFMFKqsg.cjs +11 -0
- package/dist/eslint.config.d.ts +2 -2
- package/dist/eslint.config.d.ts.map +1 -1
- package/dist/ether.cjs +1 -1
- package/dist/ether.js +65 -62
- package/dist/external--liXQuyF.cjs +1 -0
- package/dist/external-B3ipr7m2.cjs +1 -0
- package/dist/{external-Ct1k30Nd.js → external-B7UnU0MW.js} +27 -26
- package/dist/{external-PXU0gc_j.cjs → external-BRxBwBtj.cjs} +44 -44
- package/dist/{external-MvcifV4O.js → external-Ba2qQp_c.js} +3 -3
- package/dist/{external-g_vt4Lku.js → external-Bjd-DyWx.js} +22 -30
- package/dist/{external-B3o5P8Yw.cjs → external-BwbypKCk.cjs} +1 -1
- package/dist/external-C0rrTDhu.cjs +1 -0
- package/dist/{external-Dp5OkGYV.js → external-CG70NZqY.js} +97 -96
- package/dist/external-Ci1Iy9ku.js +32 -0
- package/dist/external-CmYpRWry.cjs +1 -0
- package/dist/{external-B-JsNciM.js → external-CoCI_tg5.js} +9 -8
- package/dist/{external-CLQdSLv0.js → external-Ctnukdzx.js} +10 -9
- package/dist/{external-DXWEyk9d.js → external-CvYxFUrc.js} +17 -17
- package/dist/{external-DNbIzfVy.js → external-Czkrdv2A.js} +55 -54
- package/dist/external-Czv2P05t.cjs +1 -0
- package/dist/{external-DxmgAHkn.js → external-DAotNquC.js} +3 -3
- package/dist/external-DFvPOUIQ.cjs +1 -0
- package/dist/{external-DojNoICL.cjs → external-DWEpl5aM.cjs} +1 -1
- package/dist/{external-xfkS0zGI.js → external-JwicH0Yv.js} +18 -17
- package/dist/external-N5bKB8Zx.cjs +1 -0
- package/dist/external-ZtJmVgiY.cjs +1 -0
- package/dist/external-ieDANY3X.cjs +28 -0
- package/dist/{external-sYHm9OG8.js → external-s6DOSL29.js} +16 -15
- package/dist/flex.cjs +1 -1
- package/dist/flex.js +1 -1
- package/dist/{fontString-CSWLcJcC.js → fontString-76R2eWDd.js} +3 -3
- package/dist/fontString-BNnhiwug.cjs +1 -0
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/hooks-C4ji1BSZ.cjs +1 -0
- package/dist/{hooks-BeSuo_di.js → hooks-CWEfATTF.js} +16 -16
- package/dist/index.cjs +35 -18
- package/dist/index.js +15379 -14087
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/{jsx-runtime-BbD0H88J.js → jsx-runtime-tc70JA_2.js} +2 -2
- 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/provider-Bt-E2O6g.js +810 -0
- package/dist/provider-DQkVj3tA.cjs +10 -0
- package/dist/src/access/policy/queries.d.ts +6 -6
- package/dist/src/button/Copy.d.ts +28 -0
- package/dist/src/button/Copy.d.ts.map +1 -0
- package/dist/src/button/Copy.spec.d.ts +2 -0
- package/dist/src/button/Copy.spec.d.ts.map +1 -0
- package/dist/src/button/external.d.ts +1 -0
- package/dist/src/button/external.d.ts.map +1 -1
- package/dist/src/channel/queries.d.ts +1 -1
- package/dist/src/channel/queries.d.ts.map +1 -1
- package/dist/src/color/Provider.d.ts +11 -1
- package/dist/src/color/Provider.d.ts.map +1 -1
- package/dist/src/device/queries.d.ts +122 -72
- package/dist/src/device/queries.d.ts.map +1 -1
- package/dist/src/errors/Fallback.d.ts.map +1 -1
- package/dist/src/flux/base/store.d.ts +2 -2
- package/dist/src/flux/base/store.d.ts.map +1 -1
- package/dist/src/flux/retrieve.d.ts +1 -1
- package/dist/src/flux/retrieve.d.ts.map +1 -1
- package/dist/src/icon/EtherCAT.d.ts +2 -0
- package/dist/src/icon/EtherCAT.d.ts.map +1 -0
- package/dist/src/icon/registry.d.ts +3 -0
- package/dist/src/icon/registry.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/input/Numeric.d.ts.map +1 -1
- package/dist/src/json/SelectType.d.ts +8 -0
- package/dist/src/json/SelectType.d.ts.map +1 -0
- package/dist/src/json/external.d.ts +3 -0
- package/dist/src/json/external.d.ts.map +1 -0
- package/dist/src/json/index.d.ts +2 -0
- package/dist/src/json/index.d.ts.map +1 -0
- package/dist/src/json/primitive.d.ts +7 -0
- package/dist/src/json/primitive.d.ts.map +1 -0
- package/dist/src/json/primitive.spec.d.ts +2 -0
- package/dist/src/json/primitive.spec.d.ts.map +1 -0
- package/dist/src/label/queries.d.ts +30 -2
- package/dist/src/label/queries.d.ts.map +1 -1
- package/dist/src/lineplot/aether/XAxis.d.ts +40 -0
- package/dist/src/lineplot/aether/XAxis.d.ts.map +1 -1
- package/dist/src/lineplot/aether/YAxis.d.ts +40 -0
- package/dist/src/lineplot/aether/YAxis.d.ts.map +1 -1
- package/dist/src/lineplot/aether/axis.d.ts +20 -0
- package/dist/src/lineplot/aether/axis.d.ts.map +1 -1
- package/dist/src/lineplot/range/aether/provider.d.ts +90 -6
- package/dist/src/lineplot/range/aether/provider.d.ts.map +1 -1
- package/dist/src/lineplot/tooltip/aether/tooltip.d.ts +80 -0
- package/dist/src/lineplot/tooltip/aether/tooltip.d.ts.map +1 -1
- package/dist/src/log/aether/Log.d.ts +30 -0
- package/dist/src/log/aether/Log.d.ts.map +1 -1
- package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
- package/dist/src/ranger/queries.d.ts +33 -5
- package/dist/src/ranger/queries.d.ts.map +1 -1
- package/dist/src/schematic/symbol/Forms.d.ts +2 -0
- package/dist/src/schematic/symbol/Forms.d.ts.map +1 -1
- package/dist/src/schematic/symbol/Primitives.d.ts +23 -0
- package/dist/src/schematic/symbol/Primitives.d.ts.map +1 -1
- package/dist/src/schematic/symbol/Symbols.d.ts +14 -0
- package/dist/src/schematic/symbol/Symbols.d.ts.map +1 -1
- package/dist/src/schematic/symbol/queries.d.ts +6 -6
- package/dist/src/schematic/symbol/registry.d.ts +2 -0
- package/dist/src/schematic/symbol/registry.d.ts.map +1 -1
- package/dist/src/status/aether/errorHandler.d.ts.map +1 -1
- package/dist/src/status/queries.d.ts +3 -2
- package/dist/src/status/queries.d.ts.map +1 -1
- package/dist/src/table/cells/Cells.d.ts +20 -0
- package/dist/src/table/cells/Cells.d.ts.map +1 -1
- package/dist/src/telem/aether/static.d.ts +10 -0
- package/dist/src/telem/aether/static.d.ts.map +1 -1
- package/dist/src/telem/aether/transformers.d.ts +15 -0
- package/dist/src/telem/aether/transformers.d.ts.map +1 -1
- package/dist/src/telem/control/Controller.d.ts +1 -0
- package/dist/src/telem/control/Controller.d.ts.map +1 -1
- package/dist/src/telem/control/Legend.d.ts +4 -2
- package/dist/src/telem/control/Legend.d.ts.map +1 -1
- package/dist/src/telem/control/aether/controller.d.ts +10 -0
- package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
- package/dist/src/telem/control/aether/indicator.d.ts +50 -0
- package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
- package/dist/src/telem/control/aether/legend.d.ts +22 -0
- package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
- package/dist/src/telem/control/aether/state.d.ts +13 -0
- package/dist/src/telem/control/aether/state.d.ts.map +1 -1
- package/dist/src/theming/aether/provider.d.ts +1413 -3
- package/dist/src/theming/aether/provider.d.ts.map +1 -1
- package/dist/src/theming/base/theme.d.ts +941 -1
- package/dist/src/theming/base/theme.d.ts.map +1 -1
- package/dist/src/user/queries.d.ts +1 -1
- package/dist/src/vis/axis/axis.d.ts +20 -0
- package/dist/src/vis/axis/axis.d.ts.map +1 -1
- package/dist/src/vis/gauge/aether/gauge.d.ts +30 -0
- package/dist/src/vis/gauge/aether/gauge.d.ts.map +1 -1
- package/dist/src/vis/gauge/use.d.ts +10 -0
- package/dist/src/vis/gauge/use.d.ts.map +1 -1
- package/dist/src/vis/line/aether/line.d.ts +10 -0
- package/dist/src/vis/line/aether/line.d.ts.map +1 -1
- package/dist/src/vis/measure/aether/measure.d.ts +80 -0
- package/dist/src/vis/measure/aether/measure.d.ts.map +1 -1
- package/dist/src/vis/rule/aether/aether.d.ts +20 -0
- package/dist/src/vis/rule/aether/aether.d.ts.map +1 -1
- package/dist/src/vis/stateIndicator/aether/index.d.ts +2 -0
- package/dist/src/vis/stateIndicator/aether/index.d.ts.map +1 -0
- package/dist/src/vis/stateIndicator/aether/stateIndicator.d.ts +48 -0
- package/dist/src/vis/stateIndicator/aether/stateIndicator.d.ts.map +1 -0
- package/dist/src/vis/stateIndicator/index.d.ts +2 -0
- package/dist/src/vis/stateIndicator/index.d.ts.map +1 -0
- package/dist/src/vis/stateIndicator/use.d.ts +9 -0
- package/dist/src/vis/stateIndicator/use.d.ts.map +1 -0
- package/dist/src/vis/value/aether/value.d.ts +60 -0
- package/dist/src/vis/value/aether/value.d.ts.map +1 -1
- package/dist/src/vis/value/redline.d.ts +5 -0
- package/dist/src/vis/value/redline.d.ts.map +1 -1
- package/dist/src/vis/value/use.d.ts +20 -0
- package/dist/src/vis/value/use.d.ts.map +1 -1
- package/dist/src/workspace/queries.d.ts +1 -1
- package/dist/stylelint.config.d.ts +3 -0
- package/dist/stylelint.config.d.ts.map +1 -0
- 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/dist/{types-B5-Tni3G.js → types-CGRCBVD4.js} +2 -2
- package/dist/{types-C0tUDfsz.cjs → types-DI2vtOGs.cjs} +1 -1
- package/dist/units-Bu36uC6z.cjs +1 -0
- package/dist/units-DMip-eZH.js +14 -0
- package/dist/value-Bfn0uQuG.cjs +53 -0
- package/dist/{value-BmuhX6zs.js → value-DimszMFu.js} +2108 -2057
- package/dist/video.cjs +1 -1
- package/dist/video.js +1 -1
- package/package.json +25 -21
- package/dist/Animated-BbeJdao0.js +0 -28
- package/dist/Animated-Dvm2k_z_.cjs +0 -1
- package/dist/Animated-umWjgTzy.cjs +0 -1
- package/dist/Box-D27bV7QJ.cjs +0 -1
- package/dist/Button-BSek5HG5.cjs +0 -1
- package/dist/Button-DLtxKGH5.js +0 -308
- package/dist/Dialog-BpjxXSmw.cjs +0 -1
- package/dist/Editable-C-z-stcD.cjs +0 -1
- package/dist/Haul-WgPKptr9.cjs +0 -1
- package/dist/Items-07R286kW.cjs +0 -4
- package/dist/Menu-58O-OOPJ.cjs +0 -1
- package/dist/Provider-BA3zQVbv.cjs +0 -1
- package/dist/Tags-DWsEZD9t.cjs +0 -1
- package/dist/Text-DW5FpCk9.cjs +0 -1
- package/dist/Video-C56z7qvH.js +0 -9
- package/dist/Video-CBPTBLTB.cjs +0 -1
- package/dist/css-BkBrZtKZ.js +0 -5328
- package/dist/css-D3NdC2sx.cjs +0 -8
- package/dist/dimensions-C7b02rFi.cjs +0 -1
- package/dist/eraser-Bocga8Eb.cjs +0 -11
- package/dist/external-5_uHky7w.cjs +0 -28
- package/dist/external-B9omdiDK.cjs +0 -1
- package/dist/external-BIbdeWQE.cjs +0 -1
- package/dist/external-BRA_zA83.cjs +0 -1
- package/dist/external-Bjh6lsVm.cjs +0 -1
- package/dist/external-BwRkgEyo.cjs +0 -1
- package/dist/external-CdHyPhLI.js +0 -31
- package/dist/external-Ct2A_YCT.cjs +0 -1
- package/dist/external-DT82RBon.cjs +0 -1
- package/dist/external-DyTk_hS7.cjs +0 -1
- package/dist/fontString-TocVNWmy.cjs +0 -1
- package/dist/hooks-Eb94kuDd.cjs +0 -1
- package/dist/provider-D0K9E52u.js +0 -16236
- package/dist/provider-DksyuJua.cjs +0 -78
- package/dist/units-Bd_mf9Ye.cjs +0 -1
- package/dist/units-CEfK1L7C.js +0 -14
- package/dist/value-CZfzRi_x.cjs +0 -53
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";const a=require("zod"),A=require("./css-D3NdC2sx.cjs"),Qe=require("./types-C0tUDfsz.cjs"),zd=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},vo=t=>{const e=(r,n=cs)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!Rn(r))return r;n=Sd(n);const s={},i=r;return"toJSON"in i&&typeof i.toJSON=="function"?e(i.toJSON(),n):(Object.keys(i).forEach(o=>{let c=i[o];const l=t(o);n.recursive&&(Rn(c)?ui(c)||(c=e(c,n)):n.recursiveInArray&&li(c)&&(c=[...c].map(u=>{let h=u;return Rn(u)?ui(h)||(h=e(u,n)):li(u)&&(h=e({key:u},n).key),h}))),s[l]=c}),s)};return e},zo=vo(zd),Od=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Td=vo(Od),kd=[Number,String,Uint8Array],cs={recursive:!0,recursiveInArray:!0},Sd=(t=cs)=>(t.recursive==null?t=cs:t.recursiveInArray??=!1,t),li=t=>t!=null&&Array.isArray(t),Rn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),ui=t=>kd.some(e=>t instanceof e);let Nd=class{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t))}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const r=JSON.parse(t),n=zo(r);return e!=null?e.parse(n):n}encodeString(t){const e=Td(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):typeof n=="bigint"?n.toString():n)}};const ls=new Nd,we=t=>t!=null&&typeof t=="object"&&"value"in t;class Gt{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}}const Ed=t=>t!=null&&typeof t=="object"&&"toString"in t,Ad=(t,e=!1)=>{const r=Ed(t)?"stringer":typeof t;let n;switch(r){case"string":n=(s,i)=>s.localeCompare(i);break;case"stringer":n=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":n=(s,i)=>Number(s)-Number(i);break;case"bigint":n=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":n=(s,i)=>Number(s)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?xd(n):n},xd=t=>(e,r)=>t(r,e);let Oo=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n};const To="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Id=`0123456789${To}`,Cd=11,jd=Oo(To,1),$d=Oo(Id,Cd-1),Md=()=>`${jd()}${$d()}`,_d=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,Zd=2**12-1,us=2n**63n-1n,Ud=2**63-1,yn=t=>(e,r)=>{if(typeof e=="bigint"){if(Pd(r))return t(e,BigInt(r));const n=t(Number(e),Number(r));return typeof n=="number"?BigInt(Math.round(n)):n}return t(Number(e),Number(r))},xr=yn((t,e)=>t-e),wt=yn((t,e)=>t+e),Pd=t=>typeof t=="bigint"?!0:Number.isInteger(t),je=yn((t,e)=>t*e),mn=yn((t,e)=>t/e),ko=a.z.tuple([a.z.number(),a.z.number()]),So=a.z.object({width:a.z.number(),height:a.z.number()}),Rd=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),Ld=["start","center","end"],pr=a.z.object({x:a.z.number(),y:a.z.number()}),Dd=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),Bd=["x","y"],No=a.z.enum(Bd),Eo=["top","right","bottom","left"];a.z.enum(Eo);const Fd=["left","right"],Ao=a.z.enum(Fd),qd=["top","bottom"],xo=a.z.enum(qd),Io=["center"],hi=a.z.enum(Io),Yd=[...Eo,...Io],Co=a.z.enum(Yd);a.z.enum(Ld);const Vd=["first","last"];a.z.enum(Vd);a.z.object({lower:a.z.number(),upper:a.z.number()});a.z.enum([...No.options,...Co.options]);a.z.union([No,Co,a.z.instanceof(String)]);const bt=(t,e,r)=>{const n={};if(typeof e=="object"&&(r=e,e=void 0),r={makeValid:!0,...r},typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else n.lower=t.lower,n.upper=t.upper;return r?.makeValid?Hd(n):n},Hd=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,di=(t,e)=>{const r=bt(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e};a.z.object({x:Ao.or(hi),y:xo.or(hi)});const jo=a.z.object({x:Ao,y:xo}),Wd=Object.freeze({x:"left",y:"top"}),Gd=(t,e)=>t.x===e.x&&t.y===e.y,fi=a.z.union([a.z.number(),pr,ko,So,Rd,Dd]),Kd=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},pi=Object.freeze({x:0,y:0}),Yr=a.z.union([a.z.number(),a.z.string()]);a.z.object({top:Yr,left:Yr,width:Yr,height:Yr});a.z.object({left:a.z.number(),top:a.z.number(),right:a.z.number(),bottom:a.z.number()});a.z.object({one:pr,two:pr,root:jo});const Xs=(t,e,r=0,n=0,s)=>{const i={one:{...pi},two:{...pi},root:s??Wd};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:s??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},Ln=t=>{const e=Xs(t);return{lower:e.one.x,upper:e.two.x}},Dn=t=>{const e=Xs(t);return{lower:e.one.y,upper:e.two.y}},Jd=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,Xd=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()});a.z.union([So,Xd,pr,ko]);const Qd=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;a.z.object({offset:fi,scale:fi});a.z.object({offset:a.z.number(),scale:a.z.number()});const ef=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],tf=t=>(e,r,n,s)=>[e,s?n/t:n*t],rf=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:s,upper:i}=e,{lower:o,upper:c}=t,l=i-s,u=c-o;if(r==="dimension")return[t,n*(u/l)];const h=(n-s)*(u/l)+o;return[t,h]},nf=t=>(e,r,n)=>[t,n],sf=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:s}=t;return[t,s-(r-n)]},af=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=Qd(n,s,i),[e,n]};class rt{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new rt().translate(e)}static magnify(e){return new rt().magnify(e)}static scale(e,r){return new rt().scale(e,r)}translate(e){const r=this.new(),n=ef(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=tf(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=bt(e,r),s=this.new(),i=rf(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=bt(e,r),s=this.new(),i=af(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=bt(e,r),s=this.new(),i=nf(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=sf();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new rt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,s],i)=>i(n,e,s,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||r.some(([o,c])=>s>=o&&s<=c))return;const i=e.ops.findIndex((o,c)=>o.type==="scale"&&c>s);i!==-1&&r.push([s,i])}),r.forEach(([n,s])=>{const i=e.ops.slice(n,s);i.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new rt}class Ie{x;y;currRoot;constructor(e=new rt,r=new rt,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new Ie().translate(e,r)}static translateX(e){return new Ie().translateX(e)}static translateY(e){return new Ie().translateY(e)}static clamp(e){return new Ie().clamp(e)}static magnify(e){return new Ie().magnify(e)}static scale(e){return new Ie().scale(e)}static reBound(e){return new Ie().reBound(e)}translate(e,r){const n=Kd(e,r),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(Jd(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!Gd(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(Ln(e)),r.y=r.y.scale(Dn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(Ln(e)),r.y=this.y.reBound(Dn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(Ln(e)),r.y=this.y.clamp(Dn(e)),r}copy(){const e=new Ie;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return Xs(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new Ie}const of=pr.extend({root:jo,units:a.object({x:a.enum(["px","decimal"]),y:a.enum(["px","decimal"])})});of.partial({root:!0,units:!0});const cf=a.z.enum(["static","dynamic"]),yi=365,Vr=30,lf=a.z.union([a.z.tuple([a.z.int()]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12)]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12),a.z.int().min(1).max(31)])]),$o=(t,e)=>{const r=new R(e);if(![g.DAY,g.HOUR,g.MINUTE,g.SECOND,g.MILLISECOND,g.MICROSECOND,g.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof R?new R(n):new g(n)};let R=class T extends Gt{constructor(e,r="UTC"){if(e==null)super(T.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*T.MILLISECOND.valueOf());else if(typeof e=="string")super(T.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(T.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=T.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e===Ud?e=us:e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=T.MAX:e=T.MIN)),we(e)&&(e=e.value),super(BigInt(e.valueOf())+n)}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new T(BigInt(s.getTime())*T.MILLISECOND.valueOf()).truncate(T.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,i]=e.split(":");let o="00",c="00";i!=null&&([o,c]=i.split("."));let l=T.hours(parseInt(n??"00")).add(T.minutes(parseInt(s??"00"))).add(T.seconds(parseInt(o??"00"))).add(T.milliseconds(parseInt(c??"00")));return r==="local"&&(l=l.add(T.utcOffset)),l.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return T.parseTimeString(e,r);if(e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let s=e,i=0;if(e.includes(".")){const u=e.split(".");s=u[0];const h=u[1]||"0";i=parseInt(h.padEnd(3,"0").slice(0,3))}const o=r==="local"?new Date(s.replace("T"," ")):new Date(`${s}Z`),c=BigInt(o.getTime())*T.MILLISECOND.valueOf(),l=BigInt(i)*T.MILLISECOND.valueOf();return c+l}const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new T(BigInt(n.getTime())*T.MILLISECOND.valueOf(),r).valueOf()}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(T.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new g(BigInt(new Date().getTimezoneOffset())*T.MINUTE.valueOf())}static since(e){return new T().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new T(e).valueOf()}span(e){return this.range(e).span}range(e){return new cr(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new T(e).valueOf()}afterEq(e){return this.valueOf()>=new T(e).valueOf()}before(e){return this.valueOf()<new T(e).valueOf()}beforeEq(e){return this.valueOf()<=new T(e).valueOf()}add(e){return new T(wt(this.valueOf(),new g(e).valueOf()))}sub(e){return new T(xr(this.valueOf(),new g(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(T.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(e){const r=this.date();return r.setUTCFullYear(e),new T(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new T(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new T(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new T(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new T(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new T(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new T(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new T(r)}toString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}remainder(e){return $o(this,e)}get isToday(){return this.truncate(g.DAY).equals(T.now().truncate(g.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(g.days(30))?"shortDate":e.greaterThanOrEqual(g.DAY)?"dateTime":e.greaterThanOrEqual(g.HOUR)?"time":e.greaterThanOrEqual(g.SECOND)?"preciseTime":"ISOTime"}static now(){return new T(new Date)}static max(...e){let r=T.MIN;for(const n of e){const s=new T(n);s.after(r)&&(r=s)}return r}static min(...e){let r=T.MAX;for(const n of e){const s=new T(n);s.before(r)&&(r=s)}return r}static nanoseconds(e,r="UTC"){return new T(e,r)}static NANOSECOND=T.nanoseconds(1);static microseconds(e,r="UTC"){return T.nanoseconds(e*1e3,r)}static MICROSECOND=T.microseconds(1);static milliseconds(e,r="UTC"){return T.microseconds(e*1e3,r)}static MILLISECOND=T.milliseconds(1);static seconds(e,r="UTC"){return T.milliseconds(e*1e3,r)}static SECOND=T.seconds(1);static minutes(e,r="UTC"){return T.seconds(e*60,r)}static MINUTE=T.minutes(1);static hours(e,r="UTC"){return T.minutes(e*60,r)}static HOUR=T.hours(1);static days(e,r="UTC"){return T.hours(e*24,r)}static DAY=T.days(1);static MAX=new T(us);static MIN=new T(0);static ZERO=new T(0);static z=a.z.union([a.z.instanceof(T),a.z.object({value:a.z.bigint()}).transform(e=>new T(e.value)),a.z.string().transform(e=>new T(BigInt(e))),a.z.number().transform(e=>new T(e)),a.z.bigint().transform(e=>new T(e)),a.z.date().transform(e=>new T(e)),a.z.custom(e=>e instanceof g).transform(e=>new T(e)),lf.transform(e=>new T(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}};class g extends Gt{constructor(e){typeof e=="number"&&(e=Math.trunc(e.valueOf())),we(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(e){return e instanceof g?e:e instanceof Bn?e.period:e instanceof R?new g(e):(we(e)&&(e=e.value),["number","bigint"].includes(typeof e)?g.seconds(e):new g(e))}static fromMilliseconds(e){return e instanceof g?e:e instanceof Bn?e.period:e instanceof R?new g(e):(we(e)&&(e=e.value),["number","bigint"].includes(typeof e)?g.milliseconds(e):new g(e))}valueOf(){return this.value}lessThan(e){return this.valueOf()<new g(e).valueOf()}greaterThan(e){return this.valueOf()>new g(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new g(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new g(e).valueOf()}remainder(e){return $o(this,e)}truncate(e){return new g(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(e="full"){if(e==="semantic")return this.toSemanticString();const r=this.truncate(g.DAY),n=this.truncate(g.HOUR),s=this.truncate(g.MINUTE),i=this.truncate(g.SECOND),o=this.truncate(g.MILLISECOND),c=this.truncate(g.MICROSECOND),l=this.truncate(g.NANOSECOND),u=r,h=n.sub(r),f=s.sub(n),d=i.sub(s),z=o.sub(i),I=c.sub(o),j=l.sub(c);let b="";return u.isZero||(b+=`${u.days}d `),h.isZero||(b+=`${h.hours}h `),f.isZero||(b+=`${f.minutes}m `),d.isZero||(b+=`${d.seconds}s `),z.isZero||(b+=`${z.milliseconds}ms `),I.isZero||(b+=`${I.microseconds}µs `),j.isZero||(b+=`${j.nanoseconds}ns`),b.trim()}toSemanticString(){const e=this.valueOf()<0n?-this.valueOf():this.valueOf(),r=new g(e),n=this.valueOf()<0n;if(r.valueOf()===0n)return"0s";if(r.lessThan(g.SECOND))return"< 1s";const s=r.days,i=r.hours,o=r.minutes,c=r.seconds,l=Math.floor(s/yi),u=Math.floor(s/Vr),h=Math.floor(s/7),f=Math.floor(s),d=Math.floor(i),z=Math.floor(o),I=Math.floor(c),j=n?"-":"";if(l>=1){let b=`${l}y`;if(l<2){const v=Math.floor(s%yi/Vr);v>0&&(b+=` ${v}mo`)}return j+b}if(h>=1&&s<Vr&&s%7===0){let b=`${h}w`;const v=Math.floor(s%7),S=Math.floor(i-h*7*24);return h<2&&(v>0?b+=` ${v}d`:S>0&&S<24&&(b+=` ${S}h`)),j+b}if(u>=1){let b=`${u}mo`;if(u<3){const v=Math.floor(s%Vr);v>0&&(b+=` ${v}d`)}return j+b}if(h>=1){let b=`${h}w`;const v=Math.floor(s%7),S=Math.floor(i-h*7*24);return h<2&&(v>0?b+=` ${v}d`:S>0&&S<24&&(b+=` ${S}h`)),j+b}if(f>=1){let b=`${f}d`;const v=Math.floor(i-f*24);return f<2&&v>0&&(b+=` ${v}h`),j+b}if(d>=1){let b=`${d}h`;if(d<3){const v=Math.floor(o-d*60);v>0&&(b+=` ${v}m`)}return j+b}if(z>=1){let b=`${z}m`;if(z<5){const v=Math.floor(c-z*60);v>0&&(b+=` ${v}s`)}return j+b}return`${j}${I}s`}mult(e){return new g(je(this.valueOf(),e))}div(e){return new g(mn(this.valueOf(),e))}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(g.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(g.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(e){return this.valueOf()===new g(e).valueOf()}add(e){return new g(this.valueOf()+new g(e).valueOf())}sub(e){return new g(this.valueOf()-new g(e).valueOf())}static nanoseconds(e=1){return new g(e)}static NANOSECOND=g.nanoseconds(1);static microseconds(e=1){return g.nanoseconds(je(e,1e3))}static MICROSECOND=g.microseconds(1);static milliseconds(e=1){return g.microseconds(je(e,1e3))}static MILLISECOND=g.milliseconds(1);static seconds(e=1){return g.milliseconds(je(e,1e3))}static SECOND=g.seconds(1);static minutes(e=1){return g.seconds(je(e,60))}static MINUTE=g.minutes(1);static hours(e){return g.minutes(je(e,60))}static HOUR=g.hours(1);static days(e){return g.hours(je(e,24))}static DAY=g.days(1);static MAX=new g(us);static MIN=new g(0);static ZERO=new g(0);static z=a.z.union([a.z.object({value:a.z.bigint()}).transform(e=>new g(e.value)),a.z.string().transform(e=>new g(BigInt(e))),a.z.number().transform(e=>new g(e)),a.z.bigint().transform(e=>new g(e)),a.z.instanceof(g),a.z.instanceof(R).transform(e=>new g(e)),a.z.custom(e=>e instanceof Bn).transform(e=>new g(e))])}let Bn=class ye extends Gt{constructor(e){we(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new ye(e).valueOf()}get period(){return g.seconds(1/this.valueOf())}sampleCount(e){return new g(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new te(r).valueOf()}span(e){return g.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new te(r).valueOf())}add(e){return new ye(wt(this.valueOf(),new ye(e).valueOf()))}sub(e){return new ye(xr(this.valueOf(),new ye(e).valueOf()))}mult(e){return new ye(je(this.valueOf(),e))}div(e){return new ye(mn(this.valueOf(),e))}static hz(e){return new ye(e)}static khz(e){return ye.hz(e*1e3)}static z=a.z.union([a.z.number().transform(e=>new ye(e)),a.z.instanceof(ye)])},te=class se extends Gt{constructor(e){we(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new hs(e*this.valueOf())}add(e){return new se(wt(this.valueOf(),new se(e).valueOf()))}sub(e){return new se(xr(this.valueOf(),new se(e).valueOf()))}mult(e){return new se(je(this.valueOf(),e))}div(e){return new se(mn(this.valueOf(),e))}static UNKNOWN=new se(0);static BIT128=new se(16);static BIT64=new se(8);static BIT32=new se(4);static BIT16=new se(2);static BIT8=new se(1);static z=a.z.union([a.z.number().transform(e=>new se(e)),a.z.instanceof(se)])},cr=class Te{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new R(e.start),this.end=new R(e.end)):(this.start=new R(e),this.end=new R(r))}get span(){return new g(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new Te(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,r=g.ZERO){if(r.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=g.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=R.max(n.start,e.start),i=R.min(n.end,e.end);return i.before(s)?!1:new g(i.sub(s)).greaterThanOrEqual(r)}contains(e){return e instanceof Te?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new Te(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}static max(...e){return new Te(R.min(...e.map(r=>r.start)),R.max(...e.map(r=>r.end)))}static MAX=new Te(R.MIN,R.MAX);static ZERO=new Te(R.ZERO,R.ZERO);static z=a.z.union([a.z.object({start:R.z,end:R.z}).transform(e=>new Te(e.start,e.end)),a.z.instanceof(Te)]);static sort(e,r){return R.sort(e.start,r.start)||R.sort(e.end,r.end)}static merge(...e){return Te.max(...e.map(r=>new Te(r).makeValid()))}},Y=class y extends Gt{constructor(e){if(we(e)&&(e=e.value),e instanceof y||typeof e=="string"||typeof e.valueOf()=="string")super(e.valueOf());else{const r=y.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r==null)throw new Error(`unable to find data type for ${e.toString()}`);super(r.valueOf())}}get Array(){const e=y.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(r=>this.equals(r))}toString(e=!1){return e?y.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(y.JSON)||this.equals(y.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(y.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=y.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsignedInteger(){return this.equals(y.UINT8)||this.equals(y.UINT16)||this.equals(y.UINT32)||this.equals(y.UINT64)}get isSignedInteger(){return this.equals(y.INT8)||this.equals(y.INT16)||this.equals(y.INT32)||this.equals(y.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsignedInteger&&e.isSignedInteger?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(y.INT32)&&e.equals(y.FLOAT64)||this.equals(y.INT8)&&e.equals(y.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsignedInteger===e.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return y.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new y("unknown");static FLOAT64=new y("float64");static FLOAT32=new y("float32");static INT64=new y("int64");static INT32=new y("int32");static INT16=new y("int16");static INT8=new y("int8");static UINT64=new y("uint64");static UINT32=new y("uint32");static UINT16=new y("uint16");static UINT8=new y("uint8");static BOOLEAN=new y("boolean");static TIMESTAMP=new y("timestamp");static UUID=new y("uuid");static STRING=new y("string");static JSON=new y("json");static ARRAY_CONSTRUCTORS=new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]]);static DENSITIES=new Map([[y.UINT8.toString(),te.BIT8],[y.UINT16.toString(),te.BIT16],[y.UINT32.toString(),te.BIT32],[y.UINT64.toString(),te.BIT64],[y.FLOAT32.toString(),te.BIT32],[y.FLOAT64.toString(),te.BIT64],[y.INT8.toString(),te.BIT8],[y.INT16.toString(),te.BIT16],[y.INT32.toString(),te.BIT32],[y.INT64.toString(),te.BIT64],[y.TIMESTAMP.toString(),te.BIT64],[y.STRING.toString(),te.UNKNOWN],[y.JSON.toString(),te.UNKNOWN],[y.UUID.toString(),te.BIT128]]);static ALL=[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON];static SHORT_STRINGS=new Map([[y.UINT8.toString(),"u8"],[y.UINT16.toString(),"u16"],[y.UINT32.toString(),"u32"],[y.UINT64.toString(),"u64"],[y.INT8.toString(),"i8"],[y.INT16.toString(),"i16"],[y.INT32.toString(),"i32"],[y.INT64.toString(),"i64"],[y.FLOAT32.toString(),"f32"],[y.FLOAT64.toString(),"f64"],[y.BOOLEAN.toString(),"bool"],[y.TIMESTAMP.toString(),"ts"],[y.UUID.toString(),"uuid"],[y.STRING.toString(),"str"],[y.JSON.toString(),"json"]]);static BIG_INT_TYPES=[y.INT64,y.UINT64,y.TIMESTAMP];static z=a.z.union([a.z.string().transform(e=>new y(e)),a.z.instanceof(y)])},hs=class $ extends Gt{constructor(e){we(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return we(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return we(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(e){return we(e)&&(e=e.value),new $(wt(this.valueOf(),e.valueOf()))}sub(e){return we(e)&&(e=e.value),new $(xr(this.valueOf(),e.valueOf()))}mult(e){return new $(je(this.valueOf(),e))}div(e){return new $(mn(this.valueOf(),e))}truncate(e){return new $(Math.trunc(this.valueOf()/new $(e).valueOf())*new $(e).valueOf())}remainder(e){return $.bytes(this.valueOf()%new $(e).valueOf())}get gigabytes(){return this.valueOf()/$.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/$.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/$.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/$.TERABYTE.valueOf()}toString(){const e=this.truncate($.TERABYTE),r=this.truncate($.GIGABYTE),n=this.truncate($.MEGABYTE),s=this.truncate($.KILOBYTE),i=this.truncate($.BYTE),o=e,c=r.sub(e),l=n.sub(r),u=s.sub(n),h=i.sub(s);let f="";return o.isZero||(f+=`${o.terabytes}TB `),c.isZero||(f+=`${c.gigabytes}GB `),l.isZero||(f+=`${l.megabytes}MB `),u.isZero||(f+=`${u.kilobytes}KB `),(!h.isZero||f==="")&&(f+=`${h.valueOf()}B`),f.trim()}static bytes(e=1){return new $(e)}static BYTE=new $(1);static kilobytes(e=1){return $.bytes(new $(e).valueOf()*1e3)}static KILOBYTE=$.kilobytes(1);static megabytes(e=1){return $.kilobytes(new $(e).valueOf()*1e3)}static MEGABYTE=$.megabytes(1);static gigabytes(e=1){return $.megabytes(new $(e).valueOf()*1e3)}static GIGABYTE=$.gigabytes(1);static terabytes(e){return $.gigabytes(new $(e).valueOf()*1e3)}static TERABYTE=$.terabytes(1);static ZERO=new $(0);static z=a.z.union([a.z.number().transform(e=>new $(e)),a.z.instanceof($)]);get isZero(){return this.valueOf()===0}};a.z.object({start:a.z.number(),end:a.z.number()});a.z.union([a.z.instanceof(Uint8Array),a.z.instanceof(Uint16Array),a.z.instanceof(Uint32Array),a.z.instanceof(BigUint64Array),a.z.instanceof(Float32Array),a.z.instanceof(Float64Array),a.z.instanceof(Int8Array),a.z.instanceof(Int16Array),a.z.instanceof(Int32Array),a.z.instanceof(BigInt64Array)]);const Mo=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof R||t instanceof g||t instanceof Date},uf=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):xr(r,n),hf=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function df(t){return typeof t=="string"&&hf.test(t)}const Q=[];for(let t=0;t<256;++t)Q.push((t+256).toString(16).slice(1));function ff(t,e=0){return(Q[t[e+0]]+Q[t[e+1]]+Q[t[e+2]]+Q[t[e+3]]+"-"+Q[t[e+4]]+Q[t[e+5]]+"-"+Q[t[e+6]]+Q[t[e+7]]+"-"+Q[t[e+8]]+Q[t[e+9]]+"-"+Q[t[e+10]]+Q[t[e+11]]+Q[t[e+12]]+Q[t[e+13]]+Q[t[e+14]]+Q[t[e+15]]).toLowerCase()}function pf(t,e=0){const r=ff(t,e);if(!df(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const _o=(t,e)=>pf(t,e),Ge=-1,yf=a.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),mf=a.z.union([a.z.null(),a.z.undefined()]).transform(()=>new Uint8Array().buffer),ds=10,gf=(t,e)=>{if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Zo="sy_x_telem_series";let Uo=class et{key;discriminator=Zo;dataType;sampleOffset;gl;_data;timeRange=cr.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Ge;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=a.z.object({timeRange:cr.z.optional(),dataType:Y.z,alignment:a.z.coerce.bigint().optional(),data:a.z.union([yf,mf,a.z.instanceof(ArrayBuffer),a.z.instanceof(Uint8Array)]),glBufferUsage:cf.default("static").optional()});static z=et.crudeZ.transform(e=>new et(e));constructor(e){wf(e)&&(e={data:e}),e.data??=[];const{dataType:r,timeRange:n,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:c=1n,key:l=Md(),data:u}=e;if(bf(u)){const d=u;this.key=d.key,this.dataType=d.dataType,this.sampleOffset=d.sampleOffset,this.gl=d.gl,this._data=d._data,this.timeRange=d.timeRange,this.alignment=d.alignment,this.alignmentMultiple=d.alignmentMultiple,this.cachedMin=d.cachedMin,this.cachedMax=d.cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this.cachedLength=d.cachedLength;return}const h=Mo(u),f=Array.isArray(u);if(r!=null)this.dataType=new Y(r);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||h){let d=u;if(!h){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");d=u[0]}if(typeof d=="string")this.dataType=Y.STRING;else if(typeof d=="number")this.dataType=Y.FLOAT64;else if(typeof d=="bigint")this.dataType=Y.INT64;else if(typeof d=="boolean")this.dataType=Y.BOOLEAN;else if(d instanceof R||d instanceof Date||d instanceof R)this.dataType=Y.TIMESTAMP;else if(typeof d=="object")this.dataType=Y.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new Y(u)}if(!f&&!h)this._data=u;else if(f&&u.length===0)this._data=new this.dataType.Array([]).buffer;else{let d=h?[u]:u;const z=d[0];(z instanceof R||z instanceof Date||z instanceof g)&&(d=d.map(I=>new R(I).valueOf())),this.dataType.equals(Y.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
2
|
-
`)}
|
|
3
|
-
`).buffer):this.dataType.equals(Y.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(I=>ls.encodeString(I)).join(`
|
|
4
|
-
`)}
|
|
5
|
-
`).buffer):this.dataType.usesBigInt&&typeof z=="number"?this._data=new this.dataType.Array(d.map(I=>BigInt(Math.round(I)))).buffer:!this.dataType.usesBigInt&&typeof z=="bigint"?this._data=new this.dataType.Array(d.map(Number)).buffer:this._data=new this.dataType.Array(d).buffer}this.key=l,this.alignment=o,this.alignmentMultiple=c,this.sampleOffset=s??0,this.timeRange=n??cr.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new Y(r).Array(e),i=new et({data:s.buffer,dataType:r,...n});return i.writePos=0,i}get refCount(){return this._refCount}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){this._refCount--,this.refCount===0&&this.gl.control!=null?this.maybeGarbageCollectGLBuffer(this.gl.control):this.refCount<0&&console.warn("cannot release a series with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Ge)return 0;const r=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,r);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this.cachedLength!=null&&(this.cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(e){if(this.writePos===Ge)return 0;const r=this.capacity-this.writePos,n=e.sub(0,r);return this.writeToUnderlyingData(n),this.cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ge?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
|
|
6
|
-
`).slice(0,-1):Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(Y.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse(ls.decodeString(r)))}get byteCapacity(){return new hs(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ge?this.byteCapacity:this.dataType.isVariable?new hs(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ge?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const r=[0];return this.data.forEach((n,s)=>{n===ds&&(e++,r.push(s+1))}),this._cachedIndexes=r,this.cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=uf(this.dataType,e,this.data[s],r);return new et({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(Y.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}return this.cachedMax}get max(){return this.calcMax()}calcMax(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this.cachedMax??=this.calcRawMax(),wt(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(Y.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}return this.cachedMin}get min(){return this.calcMin()}calcMin(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this.cachedMin??=this.calcRawMin(),wt(this.cachedMin,this.sampleOffset))}get bounds(){return bt(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(e){if(this.cachedMin!=null){const r=e.cachedMin??e.calcRawMin();r<this.cachedMin&&(this.cachedMin=r)}if(this.cachedMax!=null){const r=e.cachedMax??e.calcRawMax();r>this.cachedMax&&(this.cachedMax=r)}}atAlignment(e,r){const n=Number((e-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(r===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,r)}at(e,r=!1){if(this.dataType.isVariable)return this.atVariable(e,r??!1);if(this.dataType.equals(Y.UUID))return this.atUUID(e,r);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return wt(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=_o(new Uint8Array(this.buffer,e*this.dataType.density.valueOf()));if(n==null){if(r)throw new Error(`[series] - no value at index ${e}`);return}return n}atVariable(e,r){let n=0,s=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],s=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===ds){if(e===0){s=o;break}n=o+1,e--}if(s===0&&(s=this.data.length),n>=s||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}}const i=this.data.slice(n,s);return this.dataType.equals(Y.STRING)?new TextDecoder().decode(i):zo(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const s=Ad(e);for(;r<=n;){const i=Math.floor((r+n)/2),o=s(this.at(i,!0),e);if(o===0)return i;o<0?r=i+1:n=i-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(Y.FLOAT32)&&!this.dataType.equals(Y.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:s}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ge){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ge}as(e){return gf(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:gi(this.alignmentBounds.lower),upper:gi(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return bt(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new vf(this);return this.dataType.equals(Y.JSON)?new Qs(e):e}return this.dataType.equals(Y.UUID)?new zf(this):new Of(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new mi(this,e,r??this.length)}subAlignmentIterator(e,r){const n=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple)),s=Math.ceil(Number(r-this.alignment)/Number(this.alignmentMultiple));return new mi(this,n,s)}subBytes(e,r){if(e>=0&&(r==null||r>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,r);return new et({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,r,n){if(r<=0&&(n==null||n>=this.length))return this;let s;return e?s=this.data.subarray(r,n):s=this.data.slice(r,n),new et({data:s,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(r)})}reAlign(e){return new et({data:this.buffer,dataType:this.dataType,timeRange:cr.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){let e=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)e+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)e+=`${this.at(r)?.toString()}`,e+=",";e+="...,";for(let r=-5;r<0;r++)e+=this.at(r)?.toString(),r<-1&&(e+=",")}return e+="])",e}};const wf=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Uo?!0:Mo(t),bf=_d(Zo,Uo);let mi=class{series;end;index;constructor(t,e,r){this.series=t;const n=bt(0,t.length+1);this.end=di(n,r),this.index=di(n,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}};class vf{series;index;decoder;constructor(e){if(!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,r=this.series.data;for(;this.index<r.length&&r[this.index]!==ds;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}}class Qs{wrapped;static schema=a.z.record(a.z.string(),a.z.unknown());constructor(e){this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:ls.decodeString(e.value,Qs.schema)}}}let zf=class{series;index;data;density;constructor(t){if(!t.dataType.equals(Y.UUID))throw new Error("cannot create a UUID series iterator for a non-UUID series");this.series=t,this.index=0,this.data=new Uint8Array(t.buffer),this.density=Y.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const t=_o(this.data,this.index*this.density);return this.index++,{done:!1,value:t}}};class Of{series;index;constructor(e){this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}const gi=t=>{const e=t>>32n,r=t&0xffffffffn;return{domain:e,sample:r}},Tf=async t=>await new Promise(e=>setTimeout(e,g.fromMilliseconds(t).milliseconds));let kf=class{config;retries;interval;constructor(t){this.config={baseInterval:new g(t?.baseInterval??g.seconds(1)),maxRetries:t?.maxRetries??5,scale:t?.scale??1,sleepFn:t?.sleepFn??Tf},this.retries=0,this.interval=new g(this.config.baseInterval)}async wait(){const{maxRetries:t,scale:e,sleepFn:r}=this.config;return this.retries>=t?!1:(await r(this.interval),this.interval=this.interval.mult(e),this.retries++,!0)}get retryMessage(){return`breaker triggered ${this.retries+1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`}reset(){this.retries=0,this.interval=this.config.baseInterval}};const Sf=a.z.object({baseInterval:g.z.optional(),maxRetries:a.z.number().optional(),scale:a.z.number().optional()}),Nf=Object.freeze(Object.defineProperty({__proto__:null,Breaker:kf,breakerConfigZ:Sf},Symbol.toStringTag,{value:"Module"})),Ef=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Po=a.z.string().regex(Ef),Pt=a.z.number().min(0).max(255),Ro=a.z.number().min(0).max(1),Lo=a.z.tuple([Pt,Pt,Pt,Ro]),Af=a.z.tuple([Pt,Pt,Pt]),xf=a.z.object({rgba255:Lo}),If=a.z.number().min(0).max(360),Cf=a.z.number().min(0).max(100),jf=a.z.number().min(0).max(100),$f=a.z.tuple([If,Cf,jf,Ro]),ea=a.z.union([Po,Af,Lo,$f,xf]),Mf=ea.transform(t=>ta(t)),ta=(t,e=1)=>{if(t=ea.parse(t),typeof t=="string")return _f(t,e);if(Array.isArray(t)){if(t.length<3||t.length>4)throw new Error(`Invalid color: [${t.join(", ")}]`);return t.length===3?[...t,e]:t}return t.rgba255},_f=(t,e=1)=>(t=Po.parse(t),t=Zf(t),[Hr(t,0),Hr(t,2),Hr(t,4),t.length===8?Hr(t,6)/255:e]),Hr=(t,e)=>parseInt(t.slice(e,e+2),16),Zf=t=>t.startsWith("#")?t.slice(1):t;ta("#000000");ta("#ffffff");const Uf=a.z.object({key:a.z.string(),color:ea,position:a.z.number(),switched:a.z.boolean().optional()});a.z.array(Uf);const Pf=a.z.object({key:a.z.string(),name:a.z.string(),color:Mf});a.z.object({key:a.z.string(),name:a.z.string(),swatches:a.z.array(Pf)});a.z.int().min(0).max(255);a.z.object({name:a.z.string(),key:a.z.string()});const Rf=t=>Object.getOwnPropertySymbols(globalThis).includes(t),Lf=(t,e)=>{const r=Symbol.for(t);if(!Rf(r)){const n=e();Object.defineProperty(globalThis,r,{value:n})}return()=>globalThis[r]},Do="sy_x_error",Df=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(t):e instanceof Error?e.message.startsWith(t):typeof e!="string"?!1:e.startsWith(t),Ir=t=>class lr extends Error{static discriminator=Do;discriminator=lr.discriminator;static TYPE=t;type=lr.TYPE;static matches=Df(t);matches=lr.matches;constructor(r,n){super(r,n),this.name=lr.TYPE}static sub(r){return Ir(`${t}.${r}`)}},Bo=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==Do)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},_t="unknown",fs="nil";class Bf{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:fs,data:""};if(Bo(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:_t,data:e.message};if(typeof e=="string")return{type:_t,data:e};try{return{type:_t,data:JSON.stringify(e)}}catch{return{type:_t,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===fs)return null;if(e.type===_t)return new ps(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new ps(e.data)}}const ra=Lf("synnax-error-registry",()=>new Bf),Ff=({encode:t,decode:e})=>ra().register({encode:t,decode:e}),qf=t=>ra().encode(t),Yf=t=>t==null?null:ra().decode(t);let ps=class extends Ir("unknown"){};const Vf=a.z.object({type:a.z.string(),data:a.z.string()});let Hf=class extends Ir("canceled"){},Wf=class extends Ir("not_implemented"){};const at=Object.freeze(Object.defineProperty({__proto__:null,Canceled:Hf,NONE:fs,NotImplemented:Wf,UNKNOWN:_t,Unknown:ps,createTyped:Ir,decode:Yf,encode:qf,isTyped:Bo,payloadZ:Vf,register:Ff},Symbol.toStringTag,{value:"Module"})),Gf=a.object({jsonrpc:a.literal("2.0"),method:a.string(),params:a.any().optional(),id:a.union([a.string(),a.number(),a.null()]).optional()}),Fo=a.object({jsonrpc:a.literal("2.0"),id:a.union([a.string(),a.number(),a.null()])}),Kf=Fo.extend({result:a.json()}),Jf=Fo.extend({error:a.object({code:a.number().int(),message:a.string().optional(),data:a.json().optional()})}),Xf=a.union([Kf,Jf]);a.union([Gf,Xf]);a.z.object({key:a.z.string(),value:a.z.string()});const Qf=a.uuid();a.object({key:Qf,name:a.string().min(1),color:a.string()});a.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/);const ep=["standard","scientific","engineering"];a.z.enum(ep);const tp=a.z.union([a.z.string(),a.z.number()]);a.z.record(tp,a.z.unknown());const rp=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";rp();const np=["macOS","Windows","Linux"],sp=["macos","windows","linux"],ap={macos:"macOS",windows:"Windows",linux:"Linux"};a.z.enum(np).or(a.z.enum(sp).transform(t=>ap[t]));a.z.enum(["success","info","warning","error","loading","disabled"]);a.z.object({stack:a.z.string(),error:a.z.instanceof(Error)});const ip=(...t)=>t.map(qo).join(""),qo=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),op=t=>t.endsWith("/")?t.slice(0,-1):t,cp=(t,e="")=>t===null?"":`?${Object.entries(t).filter(([,r])=>r==null?!1:Array.isArray(r)?r.length>0:!0).map(([r,n])=>`${e}${r}=${n}`).join("&")}`;let lp=class nn{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){this.protocol=n,this.host=e,this.port=r,this.path=qo(s)}replace(e){return new nn({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new nn({...this,pathPrefix:ip(this.path,e)})}toString(){return op(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new nn({host:"unknown",port:0})};a.z.int().min(0).max(Zd);class Cr extends at.createTyped("freighter"){}let Ee=class extends Cr.sub("eof"){constructor(){super("EOF")}},Bt=class extends Cr.sub("stream_closed"){constructor(){super("StreamClosed")}},it=class extends Cr.sub("unreachable"){url;constructor(t={}){const{message:e="Unreachable",url:r=lp.UNKNOWN}=t;super(e),this.url=r}};const up=t=>{if(!t.type.startsWith(Cr.TYPE))return null;if(Ee.matches(t))return{type:Ee.TYPE,data:"EOF"};if(Bt.matches(t))return{type:Bt.TYPE,data:"StreamClosed"};if(it.matches(t))return{type:it.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},hp=t=>{if(!t.type.startsWith(Cr.TYPE))return null;switch(t.type){case Ee.TYPE:return new Ee;case Bt.TYPE:return new Bt;case it.TYPE:return new it;default:throw new at.Unknown(`Unknown error type: ${t.data}`)}};at.register({encode:up,decode:hp});let Yo=class{middleware=[];use(...t){this.middleware.push(...t)}async executeMiddleware(t,e){let r=0;const n=async s=>{if(r===this.middleware.length)return await e(s);const i=this.middleware[r];return r++,await i(s,n)};return await n(t)}};const Vo="Content-Type",dp=new Set(["ECONNREFUSED","ECONNRESET","ETIMEDOUT","EPIPE","UND_ERR_CONNECT_TIMEOUT","UND_ERR_SOCKET"]),fp=t=>{const e=t?.cause?.code??t?.code??t?.errno;if(typeof e=="string"&&dp.has(e))return!0;if(t.name==="TypeError"){const r=String(t.message||"").toLowerCase();if(/load failed|failed to fetch|networkerror|network error/.test(r))return!0}return t?.name==="AbortError"||t?.code,!1},pp=400;let yp=class extends Yo{endpoint;encoder;constructor(t,e,r=!1){return super(),this.endpoint=t.replace({protocol:r?"https":"http"}),this.encoder=e,new Proxy(this,{get:(n,s,i)=>s==="endpoint"?this.endpoint:Reflect.get(n,s,i)})}get headers(){return{[Vo]:this.encoder.contentType}}async send(t,e,r,n){e=r?.parse(e);let s=null;const i=this.endpoint.child(t),o={};o.method="POST",o.body=this.encoder.encode(e??{});const[,c]=await this.executeMiddleware({target:i.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async l=>{const u={...l,params:{}};o.headers={...this.headers,...l.params};let h;try{h=await fetch(l.target,o)}catch(d){if(!(d instanceof Error))throw d;return[u,fp(d)?new it({url:i}):d]}const f=await h.arrayBuffer();if(h?.ok)return n!=null&&(s=this.encoder.decode(f,n)),[u,null];try{if(h.status!==pp)return[u,new Error(h.statusText)];const d=this.encoder.decode(f,at.payloadZ),z=at.decode(d);return[u,z]}catch(d){return[u,new Error(`[freighter] - failed to decode error: ${h.statusText}: ${d.message}`)]}});if(c!=null)return[null,c];if(s==null)throw new Error("Response must be defined");return[s,null]}};const mp=(t,e)=>{class r{wrapped;constructor(s){this.wrapped=s}use(...s){this.wrapped.use(...s)}async send(s,i,o,c){const l=new Nf.Breaker(e);do{const[u,h]=await this.wrapped.send(s,i,o,c);if(h==null)return[u,null];if(!it.matches(h))return[null,h];if(console.warn(`[freighter] ${l.retryMessage}`,h),!await l.wait())return[u,h]}while(!0)}}return new r(t)},w=async(t,e,r,n,s)=>{const[i,o]=await t.send(e,r,n,s);if(o!=null)throw o;return i},gp=a.z.object({type:a.z.enum(["data","close","open"]),payload:a.z.unknown(),error:a.z.optional(at.payloadZ)});let wp=class{codec;reqSchema;resSchema;ws;serverClosed;sendClosed;receiveDataQueue=[];receiveCallbacksQueue=[];constructor(t,e,r,n){this.codec=e,this.reqSchema=r,this.resSchema=n,this.ws=t,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}async receiveOpenAck(){const t=await this.receiveMsg();if(t.type!=="open"){if(t.error==null)throw new Error("Message error must be defined");return at.decode(t.error)}return null}send(t){if(this.serverClosed!=null)return new Ee;if(this.sendClosed)throw new Bt;return this.ws.send(this.codec.encode({type:"data",payload:t})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const t=await this.receiveMsg();if(t.type==="close"){if(t.error==null)throw new Error("Message error must be defined");if(this.serverClosed=at.decode(t.error),this.serverClosed==null)throw new Error("Message error must be defined");return[null,this.serverClosed]}return[this.resSchema.parse(t.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const t={type:"close"};try{this.ws.send(this.codec.encode(t))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((t,e)=>this.receiveCallbacksQueue.push({resolve:t,reject:e}))}addMessage(t){const e=this.receiveCallbacksQueue.shift();e!=null?e.resolve(t):this.receiveDataQueue.push(t)}listenForMessages(){this.ws.onmessage=this.onMessage.bind(this),this.ws.onclose=this.onClose.bind(this)}onMessage(t){this.addMessage(this.codec.decode(t.data,gp))}onClose(t){this.addMessage({type:"close",error:{type:t.code===vp?Ee.TYPE:Bt.TYPE,data:""}})}};const bp="freighterctx",vp=1e3;let zp=class ys extends Yo{baseUrl;encoder;secure;static MESSAGE_TYPE="arraybuffer";constructor(e,r,n=!1){super(),this.secure=n,this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=r}withCodec(e){const r=new ys(this.baseUrl,e,this.secure);return r.use(...this.middleware),r}async stream(e,r,n){let s;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const c=new WebSocket(this.buildURL(e,o)),l={...o,params:{}};c.binaryType=ys.MESSAGE_TYPE;const u=await this.wrapSocket(c,r,n);return u instanceof Error?[l,u]:(s=u,[l,null])});if(i!=null)throw i;return s}buildURL(e,r){const n=cp({[Vo]:this.encoder.contentType,...r.params},bp);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,r,n){return await new Promise(s=>{e.onopen=()=>{const i=new wp(e,this.encoder,r,n);i.receiveOpenAck().then(o=>{o!=null?s(o):s(i)}).catch(o=>s(o))},e.onerror=i=>{const o=i;s(new Error(o.message))}})}};const Ho=t=>a.union([a.union([a.null(),a.undefined()]).transform(()=>[]),t.array()]),Op=t=>Array.isArray(t)?t:t==null?[]:[t],Wo=(t,e)=>{if(Array.isArray(e))return e.reduce((s,i)=>Wo(s,i),t??[]);if(t==null)return[e];const r=t.findIndex(s=>s==e),n=[...t];return r===-1?n.push(e):n[r]=e,n},Tp=((t,e)=>{if(t!=null)return Array.isArray(e)?t.filter(r=>!e.includes(r)):t.filter(r=>r!=e)}),Go=(t,e)=>{if(Array.isArray(e))return e.reduce((s,i)=>Go(s,i),t??[]);if(t==null)return[e];const r=t.findIndex(s=>s.key===e.key),n=[...t];return r===-1?n.push(e):n[r]=e,n},kp=((t,e)=>{if(t!=null)return Array.isArray(e)?t.filter(r=>!e.includes(r.key)):t.filter(r=>r.key!==e)}),O=Object.freeze(Object.defineProperty({__proto__:null,nullableZ:Ho,remove:Tp,removeKeyed:kp,toArray:Op,upsert:Wo,upsertKeyed:Go},Symbol.toStringTag,{value:"Module"})),Sp=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},gn=t=>{const e=(r,n=ms)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!Fn(r))return r;n=Ap(n);const s={},i=r;return"toJSON"in i&&typeof i.toJSON=="function"?e(i.toJSON(),n):(Object.keys(i).forEach(o=>{let c=i[o];const l=t(o);n.recursive&&(Fn(c)?bi(c)||(c=e(c,n)):n.recursiveInArray&&wi(c)&&(c=[...c].map(u=>{let h=u;return Fn(u)?bi(h)||(h=e(u,n)):wi(u)&&(h=e({key:u},n).key),h}))),s[l]=c}),s)};return e},na=gn(Sp),Np=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Ko=gn(Np),Jo=t=>t.length===0?t:t[0].toUpperCase()+t.slice(1),Ep=[Number,String,Uint8Array],ms={recursive:!0,recursiveInArray:!0},Ap=(t=ms)=>(t.recursive==null?t=ms:t.recursiveInArray??=!1,t),wi=t=>t!=null&&Array.isArray(t),Fn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),bi=t=>Ep.some(e=>t instanceof e),xp=t=>t.replace(/[\s_]+/g,"-").replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}-${n.toLowerCase()}`).toLowerCase(),Ip=gn(xp),Cp=t=>{if(t.length===0)return t;let e=t.replace(/[_-]/g," ");return e=e.replace(/([a-z0-9])([A-Z])/g,(r,n,s)=>`${n} ${s}`),e=e.replace(/([A-Z]+)([A-Z][a-z])/g,(r,n,s)=>`${n} ${s}`),e=e.replace(/\s+/g," ").trim(),e=e.replace(/\b\w/g,r=>r.toUpperCase()),e},jp=gn(Cp),$p=Object.freeze(Object.defineProperty({__proto__:null,camelToSnake:Ko,capitalize:Jo,snakeToCamel:na,toKebab:Ip,toProperNoun:jp},Symbol.toStringTag,{value:"Module"})),Mp=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);class Xo{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e))}decode(e,r){return this.decodeString(this.decoder.decode(e),r)}decodeString(e,r){const n=JSON.parse(e),s=na(n);return r!=null?r.parse(s):s}encodeString(e){const r=Ko(e);return JSON.stringify(r,(n,s)=>ArrayBuffer.isView(s)?Array.from(s):typeof s=="bigint"?s.toString():s)}}class Qo{contentType="text/csv";encode(e){const r=this.encodeString(e);return new TextEncoder().encode(r)}decode(e,r){const n=new TextDecoder().decode(e);return this.decodeString(n,r)}encodeString(e){if(!Array.isArray(e)||e.length===0||!Mp(e[0]))throw new Error("Payload must be an array of objects");const r=Object.keys(e[0]),n=[r.join(",")];return e.forEach(s=>{const i=r.map(o=>JSON.stringify(s[o]??""));n.push(i.join(","))}),n.join(`
|
|
7
|
-
`)}decodeString(e,r){const[n,...s]=e.trim().split(`
|
|
8
|
-
`).map(c=>c.trim());if(n.length===0)return r!=null?r.parse({}):{};const i=n.split(",").map(c=>c.trim()),o={};return i.forEach(c=>{o[c]=[]}),s.forEach(c=>{const l=c.split(",").map(u=>u.trim());i.forEach((u,h)=>{const f=this.parseValue(l[h]);f!=null&&o[u].push(f)})}),r!=null?r.parse(o):o}parseValue(e){if(e==null||e.length===0)return null;const r=Number(e);return isNaN(r)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:r}}class ec{contentType="text/plain";encode(e){if(typeof e!="string")throw new Error("TextCodec.encode payload must be a string");return new TextEncoder().encode(e)}decode(e,r){const n=new TextDecoder().decode(e);return r!=null?r.parse(n):n}}const yr=new Xo,_p=new Qo,Zp=new ec,Up=[yr],Nt=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:Qo,CSV_CODEC:_p,ENCODERS:Up,JSONCodec:Xo,JSON_CODEC:yr,TEXT_CODEC:Zp,TextCodec:ec},Symbol.toStringTag,{value:"Module"})),he=t=>t!=null&&typeof t=="object"&&"value"in t;class Et{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}}const sa=t=>t!=null&&typeof t=="object"&&"toString"in t,tc=t=>{if(sa(t))return t?.toString().length===0;switch(typeof t){case"string":return t.length===0;case"number":return t===0;case"bigint":return t===0n;case"boolean":return!t;case"undefined":return!0;case"object":return t==null;default:return!1}},Pp=t=>!tc(t),Rp=Object.freeze(Object.defineProperty({__proto__:null,ValueExtension:Et,isCrudeValueExtension:he,isNonZero:Pp,isStringer:sa,isZero:tc},Symbol.toStringTag,{value:"Module"})),gs=t=>[...new Set(t)],Lp=(t,e,r=!0)=>{const n=new Map;return t.forEach(s=>{const i=e(s);if(n.has(i)){if(r)return;n.delete(i)}n.set(i,s)}),Array.from(n.values())},vi=Object.freeze(Object.defineProperty({__proto__:null,by:Lp,unique:gs},Symbol.toStringTag,{value:"Module"})),jr=(t,e=!1)=>{const r=sa(t)?"stringer":typeof t;let n;switch(r){case"string":n=(s,i)=>s.localeCompare(i);break;case"stringer":n=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":n=(s,i)=>Number(s)-Number(i);break;case"bigint":n=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":n=(s,i)=>Number(s)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?nc(n):n},Dp=(t,e,r)=>{const n=jr(e[t],r);return(s,i)=>n(s[t],i[t])},Bp=(t,e)=>t.length!==e.length?t.length-e.length:t.every((r,n)=>r===e[n])?0:-1,rc=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const r=jr(t[0]),n=[...t].sort(r),s=[...e].sort(r);return n.every((i,o)=>i===s[o])?0:-1},Fp=(t,e)=>{const r=gs(t),n=gs(e);return rc(r,n)},qp=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,nc=t=>(e,r)=>t(r,e),At=0,Be=-1,Fe=1,sc=t=>t<At,ac=t=>t>At,Yp=t=>t>=At,ic=t=>t===At,Vp=(t,e)=>{const r=/([a-zA-Z]+)|(\d+)/g,n=t.replace(/[\s_.-]+/g,"").match(r),s=e.replace(/[\s_.-]+/g,"").match(r);if(!n||!s)return 0;for(let i=0;i<Math.min(n.length,s.length);i++){const o=n[i],c=s[i];if(isNaN(Number(o))&&isNaN(Number(c))){const l=o.localeCompare(c);if(l!==0)return l}else if(!isNaN(Number(o))&&!isNaN(Number(c))){const l=Number(o)-Number(c);if(l!==0)return l}else return isNaN(Number(o))?-1:1}return n.length-s.length},oc=(t,e,r)=>{let n=0,s=t.length;const i=r??jr(e);for(;n<s;){const o=Math.floor((n+s)/2),c=i(t[o],e);if(c===0)return o;c<0?n=o+1:s=o}return n},Hp=(t,e,r)=>{const n=oc(t,e,r);t.splice(n,0,e)},zi=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:At,GREATER_THAN:Fe,LESS_THAN:Be,insert:Hp,isEqualTo:ic,isGreaterThan:ac,isGreaterThanEqual:Yp,isLessThan:sc,newF:jr,newFieldF:Dp,order:qp,primitiveArrays:Bp,reverseF:nc,search:oc,stringsWithNumbers:Vp,uniqueUnorderedPrimitiveArrays:Fp,unorderedPrimitiveArrays:rc},Symbol.toStringTag,{value:"Module"}));let cc=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n};const lc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Wp=`0123456789${lc}`,uc=11,Gp=cc(lc,1),Kp=cc(Wp,uc-1),aa=()=>`${Gp()}${Kp()}`,Jp=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:uc,create:aa},Symbol.toStringTag,{value:"Module"})),Xp=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,Qp=2**8-1,hc=2**12-1,ey=2**16-1,ty=2**32-1,ry=2n**64n-1n,ny=2**64-1,sy=-128,ay=2**7-1,iy=-32768,oy=2**15-1,cy=-2147483648,ly=2**31-1,uy=-(2n**63n),an=2n**63n-1n,hy=-9223372036854776e3,dc=2**63-1,Kt=t=>(e,r)=>{if(typeof e=="bigint"){if(on(r))return t(e,BigInt(r));const n=t(Number(e),Number(r));return typeof n=="number"?BigInt(Math.round(n)):n}return t(Number(e),Number(r))},qe=Kt((t,e)=>t-e),Ye=Kt((t,e)=>t+e),dy=(t,e,r=1e-4)=>Math.abs(t-e)<r,ws=(t,e)=>{const r=typeof t=="bigint",n=typeof e=="bigint";return r&&n?t===e:r&&on(e)?t===BigInt(e):n&&on(t)?e===BigInt(t):t===e},fy=t=>{const e=10**Math.floor(Math.log10(t));return Math.round(t/e)*e},fc=Kt((t,e)=>t<=e?t:e),on=t=>typeof t=="bigint"?!0:Number.isInteger(t),py=Kt((t,e)=>t>=e?t:e),pc=t=>typeof t=="bigint"?t<0n?-t:t:t<0?-t:t,Se=Kt((t,e)=>t*e),$r=Kt((t,e)=>t/e),yc=a.z.tuple([a.z.number(),a.z.number()]),mc=a.z.object({width:a.z.number(),height:a.z.number()}),yy=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),my=["start","center","end"],Ft=a.z.object({x:a.z.number(),y:a.z.number()}),gc=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),ia=["x","y"],wc=a.z.enum(ia),oa=["top","right","bottom","left"],gy=a.z.enum(oa),bc=["left","right"],ca=a.z.enum(bc),la=["top","bottom"],ua=a.z.enum(la),ha=["center"],bs=a.z.enum(ha),wy=[...oa,...ha],da=a.z.enum(wy);a.z.enum(my);const by=["first","last"];a.z.enum(by);a.z.object({lower:a.z.number(),upper:a.z.number()});a.z.enum([...wc.options,...da.options]);const vy=a.z.union([wc,da,a.z.instanceof(String)]),J=(t,e,r)=>{const n={};if(typeof e=="object"&&(r=e,e=void 0),r={makeValid:!0,...r},typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else n.lower=t.lower,n.upper=t.upper;return r?.makeValid?zy(n):n},zy=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,Oi=(t,e)=>{const r=J(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e},Wr=(t,e)=>{const r=J(t);if(typeof e=="number"||typeof e=="bigint")return e>=r.lower&&e<r.upper;const n=J(e);return n.lower>=r.lower&&n.upper<=r.upper},vc=t=>{const e=J(t);return e.upper-e.lower},Oy=t=>({lower:Math.min(...t.map(e=>J(e).lower)),upper:Math.max(...t.map(e=>J(e).upper))}),Ty=(t,e,r)=>{const n=t.map(c=>J(c)),s=r>0?1:r<0?-1:0;if(s===0)return e;let i=r,o=e;for(;ws(i,0)===!1;){const c=n.findIndex(l=>s>0?o>=l.lower&&o<l.upper:o>l.lower&&o<=l.upper);if(c!==-1){const l=n[c];let u;if(s>0?u=qe(l.upper,o):u=qe(o,l.lower),u>0){const h=fc(pc(i),u);if(o=Ye(o,s>0?h:-h),i=qe(i,s>0?h:-h),ws(i,0))return o;continue}}if(s>0){const l=n.filter(u=>u.lower>o);if(l.length>0)o=l[0].lower;else return o}else{const l=n.filter(u=>u.upper<o);if(l.length>0)o=l[l.length-1].upper;else return o}}return o},ky=(t,e,r)=>{const n=t.map(o=>J(o));if(e===r)return typeof e=="bigint"?0n:0;const s=e<r?J([e,r]):J([r,e]);let i=typeof e=="bigint"?0n:0;for(const o of n){const c=o.lower>s.lower?o.lower:s.lower,l=o.upper<s.upper?o.upper:s.upper;if(c<l){const u=l-c;i=i+u}}return i},vs=2,zs=3,zc=2,Sy=(t,e)=>{if(Number.isNaN(t)||!Number.isFinite(t))return t;const r=vc(e);if(r==0)return t;let n;r>=1e3?n=vs:r>=1?n=zs:n=Math.ceil(-Math.log10(r))+zc;const s=10**n;return Math.round(t*s)/s},Ny=5,Ey=1e-10,Ay=(t,e)=>{if(Number.isNaN(t)||!Number.isFinite(t))return t;const r=Math.abs(t);if(r===0)return 0;let n=!1,s=0;if(e!=null){s=vc(e);const c=s/r;n=s>0&&c>Ey}if(n){let c;s>=1e3?c=vs:s>=1?c=zs:c=Math.ceil(-Math.log10(s))+zc;const l=10**c;return Math.round(t*l)/l}if(r>=1e3){const c=10**vs;return Math.round(t*c)/c}if(r>=1){const c=10**zs;return Math.round(t*c)/c}const i=Math.floor(Math.log10(r)),o=10**(Ny-i-1);return Math.round(t*o)/o},Os=Object.freeze(Object.defineProperty({__proto__:null,MAX_INT16:oy,MAX_INT32:ly,MAX_INT64:an,MAX_INT64_NUMBER:dc,MAX_INT8:ay,MAX_UINT12:hc,MAX_UINT16:ey,MAX_UINT32:ty,MAX_UINT64:ry,MAX_UINT64_NUMBER:ny,MAX_UINT8:Qp,MIN_INT16:iy,MIN_INT32:cy,MIN_INT64:uy,MIN_INT64_NUMBER:hy,MIN_INT8:sy,abs:pc,add:Ye,closeTo:dy,div:$r,equal:ws,isInteger:on,max:py,min:fc,mult:Se,roundBySpan:Sy,roundToNearestMagnitude:fy,smartRound:Ay,sub:qe},Symbol.toStringTag,{value:"Module"})),xy=t=>ia.includes(t)?t:la.includes(t)?"y":"x",Iy=ca,Cy=ua,jy=bs,$y={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},My={top:{clockwise:"left",counterclockwise:"right"},right:{clockwise:"top",counterclockwise:"bottom"},bottom:{clockwise:"right",counterclockwise:"left"},left:{clockwise:"bottom",counterclockwise:"top"}},_y=vy,zt=t=>t instanceof String||!ia.includes(t)?t:t==="x"?"left":"top",Zy=t=>$y[zt(t)],Uy=(t,e)=>My[t][e],mr=t=>{const e=zt(t);return e==="top"||e==="bottom"?"y":"x"},Py=a.z.object({x:ca.or(bs),y:ua.or(bs)}),fa=a.z.object({x:ca,y:ua}),pa=Object.freeze({x:"left",y:"top"}),Oc=Object.freeze({x:"right",y:"top"}),Tc=Object.freeze({x:"left",y:"bottom"}),kc=Object.freeze({x:"right",y:"bottom"}),ya=Object.freeze({x:"center",y:"center"}),Sc=Object.freeze({x:"center",y:"top"}),Nc=Object.freeze({x:"center",y:"bottom"}),Ec=Object.freeze({x:"right",y:"center"}),Ac=Object.freeze({x:"left",y:"center"}),Ry=Object.freeze([Ac,Ec,Sc,Nc,pa,Oc,Tc,kc,ya]),xc=(t,e)=>t.x===e.x&&t.y===e.y,Ly=(t,e)=>{if(typeof e=="object"){let r=!0;return"x"in e&&(t.x===e.x||(r=!1)),"y"in e&&(t.y===e.y||(r=!1)),r}return t.x===e||t.y===e},Dy=t=>[t.x,t.y],sn=t=>mr(zt(t))==="x",By=t=>mr(zt(t))==="y",Fy=t=>`${t.x}${Jo(t.y)}`,qy=(t,e)=>{let r,n;if(typeof t=="object"&&"x"in t?(r=t.x,n=t.y):(r=zt(t),n=zt(e??t)),mr(r)===mr(n)&&r!=="center"&&n!=="center")throw new Error(`[XYLocation] - encountered two locations with the same direction: ${r.toString()} - ${n.toString()}`);const s={...ya};return r==="center"?sn(n)?[s.x,s.y]=[n,r]:[s.x,s.y]=[r,n]:n==="center"?sn(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r]:sn(r)?[s.x,s.y]=[r,n]:[s.x,s.y]=[n,r],s},Yy=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:Nc,BOTTOM_LEFT:Tc,BOTTOM_RIGHT:kc,CENTER:ya,CENTER_LEFT:Ac,CENTER_LOCATIONS:ha,CENTER_RIGHT:Ec,OUTER_LOCATIONS:oa,TOP_CENTER:Sc,TOP_LEFT:pa,TOP_RIGHT:Oc,XY_LOCATIONS:Ry,X_LOCATIONS:bc,Y_LOCATIONS:la,center:jy,construct:zt,constructXY:qy,corner:fa,crude:_y,direction:mr,isX:sn,isY:By,location:da,outer:gy,rotate:Uy,swap:Zy,x:Iy,xy:Py,xyCouple:Dy,xyEquals:xc,xyMatches:Ly,xyToString:Fy,y:Cy},Symbol.toStringTag,{value:"Module"})),Ts=a.z.union([a.z.number(),Ft,yc,mc,yy,gc]),Z=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},Ot=Object.freeze({x:0,y:0}),Vy=Object.freeze({x:1,y:1}),Hy=Object.freeze({x:1/0,y:1/0}),Wy=Object.freeze({x:NaN,y:NaN}),Ic=(t,e,r=0)=>{const n=Z(t),s=Z(e);return r===0?n.x===s.x&&n.y===s.y:Math.abs(n.x-s.x)<=r&&Math.abs(n.y-s.y)<=r},Gy=t=>Ic(t,Ot),ma=(t,e,r)=>{const n=Z(t),s=Z(e,r);return{x:n.x*s.x,y:n.y*s.y}},Cc=(t,e)=>{const r=Z(t);return{x:r.x+e,y:r.y}},jc=(t,e)=>{const r=Z(t);return{x:r.x,y:r.y+e}},$c=(t,e,r,...n)=>{if(typeof e=="string"){if(typeof r!="number")throw new Error("The value must be a number.");return e==="x"?Cc(t,r):jc(t,r)}if(typeof e=="object"&&"x"in e&&typeof e.x=="string"){const s=Z(r),i=Z(t);return e.x==="left"?s.x=-s.x:e.x==="center"&&(s.x=0),e.y==="top"?s.y=-s.y:e.y==="center"&&(s.y=0),{x:i.x+s.x,y:i.y+s.y}}return[t,e,r??Ot,...n].reduce((s,i)=>{const o=Z(i);return{x:s.x+o.x,y:s.y+o.y}},Ot)},Ky=(t,e,r)=>{const n=Z(t);return xy(e)==="x"?{x:r,y:n.y}:{x:n.x,y:r}},Jy=(t,e)=>{const r=Z(t),n=Z(e);return Math.sqrt((r.x-n.x)**2+(r.y-n.y)**2)},Xy=(t,e)=>{const r=Z(t),n=Z(e);return{x:n.x-r.x,y:n.y-r.y}},Qy=t=>{const e=Z(t);return Number.isNaN(e.x)||Number.isNaN(e.y)},em=t=>{const e=Z(t);return Number.isFinite(e.x)&&Number.isFinite(e.y)},tm=t=>{const e=Z(t);return[e.x,e.y]},rm=t=>{const e=Z(t);return{left:e.x,top:e.y}},nm=(t,e=0)=>{const r=Z(t);return{x:Number(r.x.toFixed(e)),y:Number(r.y.toFixed(e))}},ur=(t,e)=>{const r=Z(t),n=Z(e);return{x:r.x-n.x,y:r.y-n.y}},hr=t=>{const e=Z(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:-e.y/r,y:e.x/r}},Mc=t=>{const e=Z(t),r=Math.hypot(e.x,e.y);return r===0?{x:0,y:0}:{x:e.x/r,y:e.y/r}},_c=(...t)=>{const e=t.reduce((r,n)=>$c(r,n),Ot);return ma(e,1/t.length)},sm=(t,e)=>{const r=[];for(let n=0;n<t.length;n++){const s=t[n];let i,o,c,l;if(n===0){const u=t[n+1],h=ur(u,s);o=hr(h),c=o,l=e}else if(n===t.length-1){const u=t[n-1],h=ur(s,u);i=hr(h),c=i,l=e}else{const u=t[n-1],h=t[n+1],f=ur(s,u),d=ur(h,s);i=hr(f),o=hr(d);const z=Math.acos((f.x*d.x+f.y*d.y)/(Math.hypot(f.x,f.y)*Math.hypot(d.x,d.y))),I=Math.sin(z/2);I===0?l=e:l=e/I,c=Mc(_c(i,o))}r.push(ma(c,l))}return r},am=t=>{const e=Z(t);return{x:e.y,y:e.x}},im=t=>{const e=Z(t);return{x:Math.round(e.x),y:Math.round(e.y)}},om=t=>{const e=Z(t);return{x:1/e.x,y:1/e.y}},cm=(t,e,r)=>{const n=Z(t),s=Z(e),i=r==="clockwise"?Math.PI/2:-Math.PI/2,o=n.x-s.x,c=n.y-s.y,l=o*Math.cos(i)-c*Math.sin(i),u=o*Math.sin(i)+c*Math.cos(i);return{x:l+s.x,y:u+s.y}},ga=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:Hy,NAN:Wy,ONE:Vy,ZERO:Ot,average:_c,calculateMiters:sm,clientXY:gc,construct:Z,couple:tm,crudeZ:Ts,css:rm,distance:Jy,equals:Ic,isFinite:em,isNan:Qy,isZero:Gy,normal:hr,normalize:Mc,reciprocal:om,rotate:cm,round:im,scale:ma,set:Ky,sub:ur,swap:am,translate:$c,translateX:Cc,translateY:jc,translation:Xy,truncate:nm,xy:Ft},Symbol.toStringTag,{value:"Module"})),Gr=a.z.union([a.z.number(),a.z.string()]);a.z.object({top:Gr,left:Gr,width:Gr,height:Gr});a.z.object({left:a.z.number(),top:a.z.number(),right:a.z.number(),bottom:a.z.number()});a.z.object({one:Ft,two:Ft,root:fa});const wa=(t,e,r=0,n=0,s)=>{const i={one:{...Ot},two:{...Ot},root:s??pa};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:s??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},qn=t=>{const e=wa(t);return{lower:e.one.x,upper:e.two.x}},Yn=t=>{const e=wa(t);return{lower:e.one.y,upper:e.two.y}},lm=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,um=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()});a.z.union([mc,um,Ft,yc]);const hm=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;a.z.object({offset:Ts,scale:Ts});a.z.object({offset:a.z.number(),scale:a.z.number()});const dm=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],fm=t=>(e,r,n,s)=>[e,s?n/t:n*t],pm=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:s,upper:i}=e,{lower:o,upper:c}=t,l=i-s,u=c-o;if(r==="dimension")return[t,n*(u/l)];const h=(n-s)*(u/l)+o;return[t,h]},ym=t=>(e,r,n)=>[t,n],mm=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:s}=t;return[t,s-(r-n)]},gm=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=hm(n,s,i),[e,n]};class nt{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new nt().translate(e)}static magnify(e){return new nt().magnify(e)}static scale(e,r){return new nt().scale(e,r)}translate(e){const r=this.new(),n=dm(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=fm(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=J(e,r),s=this.new(),i=pm(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=J(e,r),s=this.new(),i=gm(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=J(e,r),s=this.new(),i=ym(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=mm();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new nt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,s],i)=>i(n,e,s,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||r.some(([o,c])=>s>=o&&s<=c))return;const i=e.ops.findIndex((o,c)=>o.type==="scale"&&c>s);i!==-1&&r.push([s,i])}),r.forEach(([n,s])=>{const i=e.ops.slice(n,s);i.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new nt}class Ce{x;y;currRoot;constructor(e=new nt,r=new nt,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new Ce().translate(e,r)}static translateX(e){return new Ce().translateX(e)}static translateY(e){return new Ce().translateY(e)}static clamp(e){return new Ce().clamp(e)}static magnify(e){return new Ce().magnify(e)}static scale(e){return new Ce().scale(e)}static reBound(e){return new Ce().reBound(e)}translate(e,r){const n=Z(e,r),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(lm(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!xc(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(qn(e)),r.y=r.y.scale(Yn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(qn(e)),r.y=this.y.reBound(Yn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(qn(e)),r.y=this.y.clamp(Yn(e)),r}copy(){const e=new Ce;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return wa(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new Ce}const wm=Ft.extend({root:fa,units:a.object({x:a.enum(["px","decimal"]),y:a.enum(["px","decimal"])})});wm.partial({root:!0,units:!0});const bm=a.z.enum(["static","dynamic"]),Ti=365,Kr=30,vm=a.z.union([a.z.tuple([a.z.int()]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12)]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12),a.z.int().min(1).max(31)])]),Zc=(t,e)=>{const r=new C(e);if(![E.DAY,E.HOUR,E.MINUTE,E.SECOND,E.MILLISECOND,E.MICROSECOND,E.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof C?new C(n):new E(n)};let C=class k extends Et{constructor(e,r="UTC"){if(e==null)super(k.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*k.MILLISECOND.valueOf());else if(typeof e=="string")super(k.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(k.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=k.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e===dc?e=an:e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=k.MAX:e=k.MIN)),he(e)&&(e=e.value),super(BigInt(e.valueOf())+n)}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new k(BigInt(s.getTime())*k.MILLISECOND.valueOf()).truncate(k.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,i]=e.split(":");let o="00",c="00";i!=null&&([o,c]=i.split("."));let l=k.hours(parseInt(n??"00")).add(k.minutes(parseInt(s??"00"))).add(k.seconds(parseInt(o??"00"))).add(k.milliseconds(parseInt(c??"00")));return r==="local"&&(l=l.add(k.utcOffset)),l.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return k.parseTimeString(e,r);if(e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let s=e,i=0;if(e.includes(".")){const u=e.split(".");s=u[0];const h=u[1]||"0";i=parseInt(h.padEnd(3,"0").slice(0,3))}const o=r==="local"?new Date(s.replace("T"," ")):new Date(`${s}Z`),c=BigInt(o.getTime())*k.MILLISECOND.valueOf(),l=BigInt(i)*k.MILLISECOND.valueOf();return c+l}const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new k(BigInt(n.getTime())*k.MILLISECOND.valueOf(),r).valueOf()}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(k.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new E(BigInt(new Date().getTimezoneOffset())*k.MINUTE.valueOf())}static since(e){return new k().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new k(e).valueOf()}span(e){return this.range(e).span}range(e){return new B(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new k(e).valueOf()}afterEq(e){return this.valueOf()>=new k(e).valueOf()}before(e){return this.valueOf()<new k(e).valueOf()}beforeEq(e){return this.valueOf()<=new k(e).valueOf()}add(e){return new k(Ye(this.valueOf(),new E(e).valueOf()))}sub(e){return new k(qe(this.valueOf(),new E(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(E.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(E.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(E.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(E.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(k.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(k.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(e){const r=this.date();return r.setUTCFullYear(e),new k(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new k(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new k(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new k(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new k(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new k(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new k(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new k(r)}toString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}remainder(e){return Zc(this,e)}get isToday(){return this.truncate(E.DAY).equals(k.now().truncate(E.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(E.days(30))?"shortDate":e.greaterThanOrEqual(E.DAY)?"dateTime":e.greaterThanOrEqual(E.HOUR)?"time":e.greaterThanOrEqual(E.SECOND)?"preciseTime":"ISOTime"}static now(){return new k(new Date)}static max(...e){let r=k.MIN;for(const n of e){const s=new k(n);s.after(r)&&(r=s)}return r}static min(...e){let r=k.MAX;for(const n of e){const s=new k(n);s.before(r)&&(r=s)}return r}static nanoseconds(e,r="UTC"){return new k(e,r)}static NANOSECOND=k.nanoseconds(1);static microseconds(e,r="UTC"){return k.nanoseconds(e*1e3,r)}static MICROSECOND=k.microseconds(1);static milliseconds(e,r="UTC"){return k.microseconds(e*1e3,r)}static MILLISECOND=k.milliseconds(1);static seconds(e,r="UTC"){return k.milliseconds(e*1e3,r)}static SECOND=k.seconds(1);static minutes(e,r="UTC"){return k.seconds(e*60,r)}static MINUTE=k.minutes(1);static hours(e,r="UTC"){return k.minutes(e*60,r)}static HOUR=k.hours(1);static days(e,r="UTC"){return k.hours(e*24,r)}static DAY=k.days(1);static MAX=new k(an);static MIN=new k(0);static ZERO=new k(0);static z=a.z.union([a.z.instanceof(k),a.z.object({value:a.z.bigint()}).transform(e=>new k(e.value)),a.z.string().transform(e=>new k(BigInt(e))),a.z.number().transform(e=>new k(e)),a.z.bigint().transform(e=>new k(e)),a.z.date().transform(e=>new k(e)),a.z.custom(e=>e instanceof E).transform(e=>new k(e)),vm.transform(e=>new k(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}},E=class N extends Et{constructor(e){typeof e=="number"&&(e=Math.trunc(e.valueOf())),he(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(e){return e instanceof N?e:e instanceof vt?e.period:e instanceof C?new N(e):(he(e)&&(e=e.value),["number","bigint"].includes(typeof e)?N.seconds(e):new N(e))}static fromMilliseconds(e){return e instanceof N?e:e instanceof vt?e.period:e instanceof C?new N(e):(he(e)&&(e=e.value),["number","bigint"].includes(typeof e)?N.milliseconds(e):new N(e))}valueOf(){return this.value}lessThan(e){return this.valueOf()<new N(e).valueOf()}greaterThan(e){return this.valueOf()>new N(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new N(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new N(e).valueOf()}remainder(e){return Zc(this,e)}truncate(e){return new N(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(e="full"){if(e==="semantic")return this.toSemanticString();const r=this.truncate(N.DAY),n=this.truncate(N.HOUR),s=this.truncate(N.MINUTE),i=this.truncate(N.SECOND),o=this.truncate(N.MILLISECOND),c=this.truncate(N.MICROSECOND),l=this.truncate(N.NANOSECOND),u=r,h=n.sub(r),f=s.sub(n),d=i.sub(s),z=o.sub(i),I=c.sub(o),j=l.sub(c);let b="";return u.isZero||(b+=`${u.days}d `),h.isZero||(b+=`${h.hours}h `),f.isZero||(b+=`${f.minutes}m `),d.isZero||(b+=`${d.seconds}s `),z.isZero||(b+=`${z.milliseconds}ms `),I.isZero||(b+=`${I.microseconds}µs `),j.isZero||(b+=`${j.nanoseconds}ns`),b.trim()}toSemanticString(){const e=this.valueOf()<0n?-this.valueOf():this.valueOf(),r=new N(e),n=this.valueOf()<0n;if(r.valueOf()===0n)return"0s";if(r.lessThan(N.SECOND))return"< 1s";const s=r.days,i=r.hours,o=r.minutes,c=r.seconds,l=Math.floor(s/Ti),u=Math.floor(s/Kr),h=Math.floor(s/7),f=Math.floor(s),d=Math.floor(i),z=Math.floor(o),I=Math.floor(c),j=n?"-":"";if(l>=1){let b=`${l}y`;if(l<2){const v=Math.floor(s%Ti/Kr);v>0&&(b+=` ${v}mo`)}return j+b}if(h>=1&&s<Kr&&s%7===0){let b=`${h}w`;const v=Math.floor(s%7),S=Math.floor(i-h*7*24);return h<2&&(v>0?b+=` ${v}d`:S>0&&S<24&&(b+=` ${S}h`)),j+b}if(u>=1){let b=`${u}mo`;if(u<3){const v=Math.floor(s%Kr);v>0&&(b+=` ${v}d`)}return j+b}if(h>=1){let b=`${h}w`;const v=Math.floor(s%7),S=Math.floor(i-h*7*24);return h<2&&(v>0?b+=` ${v}d`:S>0&&S<24&&(b+=` ${S}h`)),j+b}if(f>=1){let b=`${f}d`;const v=Math.floor(i-f*24);return f<2&&v>0&&(b+=` ${v}h`),j+b}if(d>=1){let b=`${d}h`;if(d<3){const v=Math.floor(o-d*60);v>0&&(b+=` ${v}m`)}return j+b}if(z>=1){let b=`${z}m`;if(z<5){const v=Math.floor(c-z*60);v>0&&(b+=` ${v}s`)}return j+b}return`${j}${I}s`}mult(e){return new N(Se(this.valueOf(),e))}div(e){return new N($r(this.valueOf(),e))}get days(){return Number(this.valueOf())/Number(N.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(N.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(N.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(N.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(N.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(N.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(e){return this.valueOf()===new N(e).valueOf()}add(e){return new N(this.valueOf()+new N(e).valueOf())}sub(e){return new N(this.valueOf()-new N(e).valueOf())}static nanoseconds(e=1){return new N(e)}static NANOSECOND=N.nanoseconds(1);static microseconds(e=1){return N.nanoseconds(Se(e,1e3))}static MICROSECOND=N.microseconds(1);static milliseconds(e=1){return N.microseconds(Se(e,1e3))}static MILLISECOND=N.milliseconds(1);static seconds(e=1){return N.milliseconds(Se(e,1e3))}static SECOND=N.seconds(1);static minutes(e=1){return N.seconds(Se(e,60))}static MINUTE=N.minutes(1);static hours(e){return N.minutes(Se(e,60))}static HOUR=N.hours(1);static days(e){return N.hours(Se(e,24))}static DAY=N.days(1);static MAX=new N(an);static MIN=new N(0);static ZERO=new N(0);static z=a.z.union([a.z.object({value:a.z.bigint()}).transform(e=>new N(e.value)),a.z.string().transform(e=>new N(BigInt(e))),a.z.number().transform(e=>new N(e)),a.z.bigint().transform(e=>new N(e)),a.z.instanceof(N),a.z.instanceof(C).transform(e=>new N(e)),a.z.custom(e=>e instanceof vt).transform(e=>new N(e))])},vt=class me extends Et{constructor(e){he(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new me(e).valueOf()}get period(){return E.seconds(1/this.valueOf())}sampleCount(e){return new E(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new re(r).valueOf()}span(e){return E.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new re(r).valueOf())}add(e){return new me(Ye(this.valueOf(),new me(e).valueOf()))}sub(e){return new me(qe(this.valueOf(),new me(e).valueOf()))}mult(e){return new me(Se(this.valueOf(),e))}div(e){return new me($r(this.valueOf(),e))}static hz(e){return new me(e)}static khz(e){return me.hz(e*1e3)}static z=a.z.union([a.z.number().transform(e=>new me(e)),a.z.instanceof(me)])},re=class ae extends Et{constructor(e){he(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new qt(e*this.valueOf())}add(e){return new ae(Ye(this.valueOf(),new ae(e).valueOf()))}sub(e){return new ae(qe(this.valueOf(),new ae(e).valueOf()))}mult(e){return new ae(Se(this.valueOf(),e))}div(e){return new ae($r(this.valueOf(),e))}static UNKNOWN=new ae(0);static BIT128=new ae(16);static BIT64=new ae(8);static BIT32=new ae(4);static BIT16=new ae(2);static BIT8=new ae(1);static z=a.z.union([a.z.number().transform(e=>new ae(e)),a.z.instanceof(ae)])},B=class ke{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new C(e.start),this.end=new C(e.end)):(this.start=new C(e),this.end=new C(r))}get span(){return new E(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new ke(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,r=E.ZERO){if(r.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=E.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=C.max(n.start,e.start),i=C.min(n.end,e.end);return i.before(s)?!1:new E(i.sub(s)).greaterThanOrEqual(r)}contains(e){return e instanceof ke?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new ke(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}static max(...e){return new ke(C.min(...e.map(r=>r.start)),C.max(...e.map(r=>r.end)))}static MAX=new ke(C.MIN,C.MAX);static ZERO=new ke(C.ZERO,C.ZERO);static z=a.z.union([a.z.object({start:C.z,end:C.z}).transform(e=>new ke(e.start,e.end)),a.z.instanceof(ke)]);static sort(e,r){return C.sort(e.start,r.start)||C.sort(e.end,r.end)}static merge(...e){return ke.max(...e.map(r=>new ke(r).makeValid()))}},_=class m extends Et{constructor(e){if(he(e)&&(e=e.value),e instanceof m||typeof e=="string"||typeof e.valueOf()=="string")super(e.valueOf());else{const r=m.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r==null)throw new Error(`unable to find data type for ${e.toString()}`);super(r.valueOf())}}get Array(){const e=m.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(r=>this.equals(r))}toString(e=!1){return e?m.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(m.JSON)||this.equals(m.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(m.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=m.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsignedInteger(){return this.equals(m.UINT8)||this.equals(m.UINT16)||this.equals(m.UINT32)||this.equals(m.UINT64)}get isSignedInteger(){return this.equals(m.INT8)||this.equals(m.INT16)||this.equals(m.INT32)||this.equals(m.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsignedInteger&&e.isSignedInteger?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(m.INT32)&&e.equals(m.FLOAT64)||this.equals(m.INT8)&&e.equals(m.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsignedInteger===e.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return m.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new m("unknown");static FLOAT64=new m("float64");static FLOAT32=new m("float32");static INT64=new m("int64");static INT32=new m("int32");static INT16=new m("int16");static INT8=new m("int8");static UINT64=new m("uint64");static UINT32=new m("uint32");static UINT16=new m("uint16");static UINT8=new m("uint8");static BOOLEAN=new m("boolean");static TIMESTAMP=new m("timestamp");static UUID=new m("uuid");static STRING=new m("string");static JSON=new m("json");static ARRAY_CONSTRUCTORS=new Map([[m.UINT8.toString(),Uint8Array],[m.UINT16.toString(),Uint16Array],[m.UINT32.toString(),Uint32Array],[m.UINT64.toString(),BigUint64Array],[m.FLOAT32.toString(),Float32Array],[m.FLOAT64.toString(),Float64Array],[m.INT8.toString(),Int8Array],[m.INT16.toString(),Int16Array],[m.INT32.toString(),Int32Array],[m.INT64.toString(),BigInt64Array],[m.TIMESTAMP.toString(),BigInt64Array],[m.STRING.toString(),Uint8Array],[m.JSON.toString(),Uint8Array],[m.UUID.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,m.UINT8],[Uint16Array.name,m.UINT16],[Uint32Array.name,m.UINT32],[BigUint64Array.name,m.UINT64],[Float32Array.name,m.FLOAT32],[Float64Array.name,m.FLOAT64],[Int8Array.name,m.INT8],[Int16Array.name,m.INT16],[Int32Array.name,m.INT32],[BigInt64Array.name,m.INT64]]);static DENSITIES=new Map([[m.UINT8.toString(),re.BIT8],[m.UINT16.toString(),re.BIT16],[m.UINT32.toString(),re.BIT32],[m.UINT64.toString(),re.BIT64],[m.FLOAT32.toString(),re.BIT32],[m.FLOAT64.toString(),re.BIT64],[m.INT8.toString(),re.BIT8],[m.INT16.toString(),re.BIT16],[m.INT32.toString(),re.BIT32],[m.INT64.toString(),re.BIT64],[m.TIMESTAMP.toString(),re.BIT64],[m.STRING.toString(),re.UNKNOWN],[m.JSON.toString(),re.UNKNOWN],[m.UUID.toString(),re.BIT128]]);static ALL=[m.UNKNOWN,m.FLOAT64,m.FLOAT32,m.INT64,m.INT32,m.INT16,m.INT8,m.UINT64,m.UINT32,m.UINT16,m.UINT8,m.TIMESTAMP,m.UUID,m.STRING,m.JSON];static SHORT_STRINGS=new Map([[m.UINT8.toString(),"u8"],[m.UINT16.toString(),"u16"],[m.UINT32.toString(),"u32"],[m.UINT64.toString(),"u64"],[m.INT8.toString(),"i8"],[m.INT16.toString(),"i16"],[m.INT32.toString(),"i32"],[m.INT64.toString(),"i64"],[m.FLOAT32.toString(),"f32"],[m.FLOAT64.toString(),"f64"],[m.BOOLEAN.toString(),"bool"],[m.TIMESTAMP.toString(),"ts"],[m.UUID.toString(),"uuid"],[m.STRING.toString(),"str"],[m.JSON.toString(),"json"]]);static BIG_INT_TYPES=[m.INT64,m.UINT64,m.TIMESTAMP];static z=a.z.union([a.z.string().transform(e=>new m(e)),a.z.instanceof(m)])},qt=class M extends Et{constructor(e){he(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return he(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return he(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(e){return he(e)&&(e=e.value),new M(Ye(this.valueOf(),e.valueOf()))}sub(e){return he(e)&&(e=e.value),new M(qe(this.valueOf(),e.valueOf()))}mult(e){return new M(Se(this.valueOf(),e))}div(e){return new M($r(this.valueOf(),e))}truncate(e){return new M(Math.trunc(this.valueOf()/new M(e).valueOf())*new M(e).valueOf())}remainder(e){return M.bytes(this.valueOf()%new M(e).valueOf())}get gigabytes(){return this.valueOf()/M.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/M.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/M.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/M.TERABYTE.valueOf()}toString(){const e=this.truncate(M.TERABYTE),r=this.truncate(M.GIGABYTE),n=this.truncate(M.MEGABYTE),s=this.truncate(M.KILOBYTE),i=this.truncate(M.BYTE),o=e,c=r.sub(e),l=n.sub(r),u=s.sub(n),h=i.sub(s);let f="";return o.isZero||(f+=`${o.terabytes}TB `),c.isZero||(f+=`${c.gigabytes}GB `),l.isZero||(f+=`${l.megabytes}MB `),u.isZero||(f+=`${u.kilobytes}KB `),(!h.isZero||f==="")&&(f+=`${h.valueOf()}B`),f.trim()}static bytes(e=1){return new M(e)}static BYTE=new M(1);static kilobytes(e=1){return M.bytes(new M(e).valueOf()*1e3)}static KILOBYTE=M.kilobytes(1);static megabytes(e=1){return M.kilobytes(new M(e).valueOf()*1e3)}static MEGABYTE=M.megabytes(1);static gigabytes(e=1){return M.megabytes(new M(e).valueOf()*1e3)}static GIGABYTE=M.gigabytes(1);static terabytes(e){return M.gigabytes(new M(e).valueOf()*1e3)}static TERABYTE=M.terabytes(1);static ZERO=new M(0);static z=a.z.union([a.z.number().transform(e=>new M(e)),a.z.instanceof(M)]);get isZero(){return this.valueOf()===0}};a.z.object({start:a.z.number(),end:a.z.number()});a.z.union([a.z.instanceof(Uint8Array),a.z.instanceof(Uint16Array),a.z.instanceof(Uint32Array),a.z.instanceof(BigUint64Array),a.z.instanceof(Float32Array),a.z.instanceof(Float64Array),a.z.instanceof(Int8Array),a.z.instanceof(Int16Array),a.z.instanceof(Int32Array),a.z.instanceof(BigInt64Array)]);const Uc=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof C||t instanceof E||t instanceof Date},zm=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):qe(r,n),Om=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Tm(t){return typeof t=="string"&&Om.test(t)}const ee=[];for(let t=0;t<256;++t)ee.push((t+256).toString(16).slice(1));function km(t,e=0){return(ee[t[e+0]]+ee[t[e+1]]+ee[t[e+2]]+ee[t[e+3]]+"-"+ee[t[e+4]]+ee[t[e+5]]+"-"+ee[t[e+6]]+ee[t[e+7]]+"-"+ee[t[e+8]]+ee[t[e+9]]+"-"+ee[t[e+10]]+ee[t[e+11]]+ee[t[e+12]]+ee[t[e+13]]+ee[t[e+14]]+ee[t[e+15]]).toLowerCase()}function Sm(t,e=0){const r=km(t,e);if(!Tm(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Pc=(t,e)=>Sm(t,e),Ke=-1,ks={[Symbol.iterator]:()=>ks,next:()=>({done:!0,value:void 0})},Nm=a.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),Em=a.z.union([a.z.null(),a.z.undefined()]).transform(()=>new Uint8Array().buffer),Ss=10,Rc=(t,e)=>{if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Lc="sy_x_telem_series";let st=class tt{key;discriminator=Lc;dataType;sampleOffset;gl;_data;timeRange=B.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Ke;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=a.z.object({timeRange:B.z.optional(),dataType:_.z,alignment:a.z.coerce.bigint().optional(),data:a.z.union([Nm,Em,a.z.instanceof(ArrayBuffer),a.z.instanceof(Uint8Array)]),glBufferUsage:bm.default("static").optional()});static z=tt.crudeZ.transform(e=>new tt(e));constructor(e){Am(e)&&(e={data:e}),e.data??=[];const{dataType:r,timeRange:n,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:c=1n,key:l=aa(),data:u}=e;if(Dc(u)){const d=u;this.key=d.key,this.dataType=d.dataType,this.sampleOffset=d.sampleOffset,this.gl=d.gl,this._data=d._data,this.timeRange=d.timeRange,this.alignment=d.alignment,this.alignmentMultiple=d.alignmentMultiple,this.cachedMin=d.cachedMin,this.cachedMax=d.cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this.cachedLength=d.cachedLength;return}const h=Uc(u),f=Array.isArray(u);if(r!=null)this.dataType=new _(r);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(f||h){let d=u;if(!h){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");d=u[0]}if(typeof d=="string")this.dataType=_.STRING;else if(typeof d=="number")this.dataType=_.FLOAT64;else if(typeof d=="bigint")this.dataType=_.INT64;else if(typeof d=="boolean")this.dataType=_.BOOLEAN;else if(d instanceof C||d instanceof Date||d instanceof C)this.dataType=_.TIMESTAMP;else if(typeof d=="object")this.dataType=_.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new _(u)}if(!f&&!h)this._data=u;else if(f&&u.length===0)this._data=new this.dataType.Array([]).buffer;else{let d=h?[u]:u;const z=d[0];(z instanceof C||z instanceof Date||z instanceof E)&&(d=d.map(I=>new C(I).valueOf())),this.dataType.equals(_.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
9
|
-
`)}
|
|
10
|
-
`).buffer):this.dataType.equals(_.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(I=>yr.encodeString(I)).join(`
|
|
11
|
-
`)}
|
|
12
|
-
`).buffer):this.dataType.usesBigInt&&typeof z=="number"?this._data=new this.dataType.Array(d.map(I=>BigInt(Math.round(I)))).buffer:!this.dataType.usesBigInt&&typeof z=="bigint"?this._data=new this.dataType.Array(d.map(Number)).buffer:this._data=new this.dataType.Array(d).buffer}this.key=l,this.alignment=o,this.alignmentMultiple=c,this.sampleOffset=s??0,this.timeRange=n??B.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:r,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new _(r).Array(e),i=new tt({data:s.buffer,dataType:r,...n});return i.writePos=0,i}get refCount(){return this._refCount}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){this._refCount--,this.refCount===0&&this.gl.control!=null?this.maybeGarbageCollectGLBuffer(this.gl.control):this.refCount<0&&console.warn("cannot release a series with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Ke)return 0;const r=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,r);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this.cachedLength!=null&&(this.cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(e){if(this.writePos===Ke)return 0;const r=this.capacity-this.writePos,n=e.sub(0,r);return this.writeToUnderlyingData(n),this.cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ke?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
|
|
13
|
-
`).slice(0,-1):Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(_.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(r=>e.parse(yr.decodeString(r)))}get byteCapacity(){return new qt(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ke?this.byteCapacity:this.dataType.isVariable?new qt(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ke?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const r=[0];return this.data.forEach((n,s)=>{n===Ss&&(e++,r.push(s+1))}),this._cachedIndexes=r,this.cachedLength=e,e}convert(e,r=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=zm(this.dataType,e,this.data[s],r);return new tt({data:n.buffer,dataType:e,timeRange:this.timeRange,sampleOffset:r,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(_.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}else{const e=this.data;this.cachedMax=e.reduce((r,n)=>r>n?r:n)}return this.cachedMax}get max(){return this.calcMax()}calcMax(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this.cachedMax??=this.calcRawMax(),Ye(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(_.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}else{const e=this.data;this.cachedMin=e.reduce((r,n)=>r<n?r:n)}return this.cachedMin}get min(){return this.calcMin()}calcMin(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this.cachedMin??=this.calcRawMin(),Ye(this.cachedMin,this.sampleOffset))}get bounds(){return J(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(e){if(this.cachedMin!=null){const r=e.cachedMin??e.calcRawMin();r<this.cachedMin&&(this.cachedMin=r)}if(this.cachedMax!=null){const r=e.cachedMax??e.calcRawMax();r>this.cachedMax&&(this.cachedMax=r)}}atAlignment(e,r){const n=Number((e-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(r===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,r)}at(e,r=!1){if(this.dataType.isVariable)return this.atVariable(e,r??!1);if(this.dataType.equals(_.UUID))return this.atUUID(e,r);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(r===!0)throw new Error(`[series] - no value at index ${e}`);return}return Ye(n,this.sampleOffset)}atUUID(e,r){e<0&&(e=this.length+e);const n=Pc(new Uint8Array(this.buffer,e*this.dataType.density.valueOf()));if(n==null){if(r)throw new Error(`[series] - no value at index ${e}`);return}return n}atVariable(e,r){let n=0,s=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],s=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===Ss){if(e===0){s=o;break}n=o+1,e--}if(s===0&&(s=this.data.length),n>=s||e>0){if(r)throw new Error(`[series] - no value at index ${e}`);return}}const i=this.data.slice(n,s);return this.dataType.equals(_.STRING)?new TextDecoder().decode(i):na(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let r=0,n=this.length-1;const s=jr(e);for(;r<=n;){const i=Math.floor((r+n)/2),o=s(this.at(i,!0),e);if(o===0)return i;o<0?r=i+1:n=i-1}return r}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(_.FLOAT32)&&!this.dataType.equals(_.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:r,bufferUsage:n,prevBuffer:s}=this.gl;if(r==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ke){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ke}as(e){return Rc(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Si(this.alignmentBounds.lower),upper:Si(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return J(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new xm(this);return this.dataType.equals(_.JSON)?new ba(e):e}return this.dataType.equals(_.UUID)?new Im(this):new Cm(this)}slice(e,r){return this.sliceSub(!1,e,r)}sub(e,r){return this.sliceSub(!0,e,r)}subIterator(e,r){return new ki(this,e,r??this.length)}subAlignmentIterator(e,r){const n=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple)),s=Math.ceil(Number(r-this.alignment)/Number(this.alignmentMultiple));return new ki(this,n,s)}subBytes(e,r){if(e>=0&&(r==null||r>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,r);return new tt({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,r,n){if(r<=0&&(n==null||n>=this.length))return this;let s;return e?s=this.data.subarray(r,n):s=this.data.slice(r,n),new tt({data:s,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(r)})}reAlign(e){return new tt({data:this.buffer,dataType:this.dataType,timeRange:B.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}toString(){let e=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)e+=Array.from(this).map(r=>r.toString());else{for(let r=0;r<5;r++)e+=`${this.at(r)?.toString()}`,e+=",";e+="...,";for(let r=-5;r<0;r++)e+=this.at(r)?.toString(),r<-1&&(e+=",")}return e+="])",e}};const Am=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof st?!0:Uc(t),Dc=Xp(Lc,st);class ki{series;end;index;constructor(e,r,n){this.series=e;const s=J(0,e.length+1);this.end=Oi(s,n),this.index=Oi(s,r)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class xm{series;index;decoder;constructor(e){if(!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,r=this.series.data;for(;this.index<r.length&&r[this.index]!==Ss;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}}class ba{wrapped;static schema=a.z.record(a.z.string(),a.z.unknown());constructor(e){this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:yr.decodeString(e.value,ba.schema)}}}class Im{series;index;data;density;constructor(e){if(!e.dataType.equals(_.UUID))throw new Error("cannot create a UUID series iterator for a non-UUID series");this.series=e,this.index=0,this.data=new Uint8Array(e.buffer),this.density=_.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const e=Pc(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}}class Cm{series;index;constructor(e){this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class jm{series;constructor(e=[]){if(e.length!==0){const r=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(r))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){return Rc(e,this.dataType),this}get dataType(){return this.series.length===0?_.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?B.ZERO:new B(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?J(0n,0n):J(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){const r=()=>new Error(`cannot push a ${e.dataType.toString()} series to a ${this.dataType.toString()} multi-series`),n=e.dataType.equals(this.dataType);if(Dc(e)){if(this.series.length!==0&&!n)throw r();this.series.push(e)}else{if(this.series.length!==0&&e.series.length!==0&&!n)throw r();this.series.push(...e.series)}}get length(){return this.series.reduce((e,r)=>e+r.length,0)}atAlignment(e,r){for(const n of this.series)if(Wr(n.alignmentBounds,e))return n.atAlignment(e,r);if(r)throw new Error(`[series] - no value at alignment ${e}`)}at(e,r=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,r);e-=n.length}if(r)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,r){return new Vn(this,e,r??this.length)}subAlignmentIterator(e,r){if(e>=this.alignmentBounds.upper||r<=this.alignmentBounds.lower)return ks;let n=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)n+=o.length;else if(Wr(o.alignmentBounds,e)){n+=Math.ceil(Number(e-o.alignment)/Number(o.alignmentMultiple));break}}let s=0;for(let i=0;i<this.series.length;i++){const o=this.series[i];if(r<o.alignment)break;if(r>=o.alignmentBounds.upper)s+=o.length;else if(Wr(o.alignmentBounds,r)){s+=Math.ceil(Number(r-o.alignment)/Number(o.alignmentMultiple));break}}return new Vn(this,n,s)}subAlignmentSpanIterator(e,r){if(e>=this.alignmentBounds.upper)return ks;r=Math.min(r,Number(this.distance(e,this.alignmentBounds.upper)));let n=0;for(let s=0;s<this.series.length;s++){const i=this.series[s];if(e<i.alignment)break;if(e>=i.alignmentBounds.upper)n+=i.length;else if(Wr(i.alignmentBounds,e)){n+=Number(e-i.alignment);break}}return new Vn(this,n,n+r)}updateGLBuffer(e){this.series.forEach(r=>r.updateGLBuffer(e))}get bounds(){return Oy(this.series.map(e=>e.bounds))}get byteLength(){return new qt(this.series.reduce((e,r)=>e+r.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let r=0;for(const n of this.series)e.set(n.data,r),r+=n.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,r){const n=this.series.map(s=>s.alignmentBounds);return Ty(n,e,r)}acquire(e){this.series.forEach(r=>r.acquire(e))}release(){this.series.forEach(e=>e.release())}distance(e,r){const n=this.series.map(s=>s.alignmentBounds);return ky(n,e,r)}parseJSON(e){if(!this.dataType.equals(_.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(r=>r.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new $m(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}}class $m{series;seriesIndex;internal;constructor(e){this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}}class Vn{series;index;end;constructor(e,r,n){this.series=e,this.end=n,this.index=r}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}const Si=t=>{const e=t>>32n,r=t&0xffffffffn;return{domain:e,sample:r}},Mm=async t=>await new Promise(e=>setTimeout(e,E.fromMilliseconds(t).milliseconds));class _m{config;retries;interval;constructor(e){this.config={baseInterval:new E(e?.baseInterval??E.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??Mm},this.retries=0,this.interval=new E(this.config.baseInterval)}async wait(){const{maxRetries:e,scale:r,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(r),this.retries++,!0)}get retryMessage(){return`breaker triggered ${this.retries+1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`}reset(){this.retries=0,this.interval=this.config.baseInterval}}const Zm=a.z.object({baseInterval:E.z.optional(),maxRetries:a.z.number().optional(),scale:a.z.number().optional()}),va=Object.freeze(Object.defineProperty({__proto__:null,Breaker:_m,breakerConfigZ:Zm},Symbol.toStringTag,{value:"Module"})),Um=/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i,Bc=a.z.string().regex(Um),Rt=a.z.number().min(0).max(255),Fc=a.z.number().min(0).max(1),qc=a.z.tuple([Rt,Rt,Rt,Fc]),Pm=a.z.tuple([Rt,Rt,Rt]),Rm=a.z.object({rgba255:qc}),Lm=a.z.number().min(0).max(360),Dm=a.z.number().min(0).max(100),Bm=a.z.number().min(0).max(100),Fm=a.z.tuple([Lm,Dm,Bm,Fc]),za=a.z.union([Bc,Pm,qc,Fm,Rm]),qm=za.transform(t=>Oa(t)),Oa=(t,e=1)=>{if(t=za.parse(t),typeof t=="string")return Ym(t,e);if(Array.isArray(t)){if(t.length<3||t.length>4)throw new Error(`Invalid color: [${t.join(", ")}]`);return t.length===3?[...t,e]:t}return t.rgba255},Ym=(t,e=1)=>(t=Bc.parse(t),t=Vm(t),[Jr(t,0),Jr(t,2),Jr(t,4),t.length===8?Jr(t,6)/255:e]),Jr=(t,e)=>parseInt(t.slice(e,e+2),16),Vm=t=>t.startsWith("#")?t.slice(1):t;Oa("#000000");Oa("#ffffff");const Hm=a.z.object({key:a.z.string(),color:za,position:a.z.number(),switched:a.z.boolean().optional()});a.z.array(Hm);const Wm=a.z.object({key:a.z.string(),name:a.z.string(),color:qm});a.z.object({key:a.z.string(),name:a.z.string(),swatches:a.z.array(Wm)});const Yc=a.z.int().min(0).max(255),Vc=255,Hc=0,Gm={lower:Hc,upper:Vc+1},Wc=a.z.object({name:a.z.string(),key:a.z.string()}),gr=t=>a.z.object({subject:Wc,resource:t,authority:Yc}),Km=(...t)=>e=>e.filter(r=>{let n=!1;return r.to!=null&&(n=t.includes(r.to.resource)),r.from!=null&&!n&&(n=t.includes(r.from.resource)),n}),Gc=t=>a.z.object({from:gr(t),to:a.z.null()}),Kc=t=>a.z.object({from:a.z.null(),to:gr(t)}),Jm=t=>a.z.union([Gc(t),Kc(t),a.z.object({from:gr(t),to:gr(t)})]),be=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:Vc,AUTHORITY_BOUNDS:Gm,ZERO_AUTHORITY:Hc,acquireZ:Kc,authorityZ:Yc,filterTransfersByChannelKey:Km,releaseZ:Gc,stateZ:gr,subjectZ:Wc,transferZ:Jm},Symbol.toStringTag,{value:"Module"})),Xm=t=>{switch(typeof t){case"bigint":case"number":return t.toString();case"boolean":return t?"1":"0";case"undefined":return"";case"string":case"symbol":case"function":return Ni(t.toString());case"object":return t==null?"":Ni(JSON.stringify(t))}},Qm=/[",\n]/,Ni=t=>Qm.test(t)?`"${t.replace(/"/g,'""')}"`:t,Ei=Object.freeze(Object.defineProperty({__proto__:null,formatValue:Xm},Symbol.toStringTag,{value:"Module"})),eg=(t,e)=>{let r=null;return e===0?t:(...n)=>{r!==null&&(clearTimeout(r),r=null),r=setTimeout(()=>t(...n),e)}},Ns=".",tg=(t,e,r=Ns)=>{const n=t.split(r);return n.map((s,i)=>{const o=e(s,i,n);return o==null?null:typeof o=="string"?o:o.join(r)}).filter(s=>s!=null).join(r)},rg=(t,e)=>{if(!Array.isArray(t))return t[e];const r=t[e];if(r!=null||t.length==0)return r;const n=t[0];if(typeof n=="object"&&"key"in n)return t.find(s=>s.key===e)},ng=((t,e,r={optional:!1})=>{const{optional:n,getter:s=rg}=r;if(e==="")return t;const i=e.split(Ns);if(i.length===1){const c=s(t,i[0]);if(c===void 0){if(n)return null;throw new Error(`Path ${e} does not exist. ${i[0]} is undefined`)}return c}const o=(c,l)=>{if(l>=i.length)return c;for(let u=i.length-l;u>=1;u--){const h=i.slice(l,l+u).join(Ns),f=s(c,h);if(f!==void 0){if(l+u===i.length)return f;if(f===null){if(n)return null;throw new Error(`Path ${e} does not exist. ${h} is null`)}return o(f,l+u)}}if(n)return null;throw new Error(`Path ${e} does not exist. ${i[l]} is undefined`)};return o(t,0)}),sg=t=>Object.getOwnPropertySymbols(globalThis).includes(t),ag=(t,e)=>{const r=Symbol.for(t);if(!sg(r)){const n=e();Object.defineProperty(globalThis,r,{value:n})}return()=>globalThis[r]},Jc="sy_x_error",ig=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.startsWith(t):e instanceof Error?e.message.startsWith(t):typeof e!="string"?!1:e.startsWith(t),Mr=t=>class dr extends Error{static discriminator=Jc;discriminator=dr.discriminator;static TYPE=t;type=dr.TYPE;static matches=ig(t);matches=dr.matches;constructor(r,n){super(r,n),this.name=dr.TYPE}static sub(r){return Mr(`${t}.${r}`)}},Xc=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!==Jc)return!1;if(!("type"in e))throw new Error(`X Error is missing its type property: ${JSON.stringify(e)}`);return!0},Zt="unknown",Es="nil";class og{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Es,data:""};if(Xc(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:Zt,data:e.message};if(typeof e=="string")return{type:Zt,data:e};try{return{type:Zt,data:JSON.stringify(e)}}catch{return{type:Zt,data:"unable to encode error information"}}}decode(e){if(e==null||e.type===Es)return null;if(e.type===Zt)return new As(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new As(e.data)}}const Ta=ag("synnax-error-registry",()=>new og),cg=({encode:t,decode:e})=>Ta().register({encode:t,decode:e}),lg=t=>Ta().encode(t),ug=t=>t==null?null:Ta().decode(t);class As extends Mr("unknown"){}const hg=a.z.object({type:a.z.string(),data:a.z.string()});class dg extends Mr("canceled"){}class fg extends Mr("not_implemented"){}const He=Object.freeze(Object.defineProperty({__proto__:null,Canceled:dg,NONE:Es,NotImplemented:fg,UNKNOWN:Zt,Unknown:As,createTyped:Mr,decode:ug,encode:lg,isTyped:Xc,payloadZ:hg,register:cg},Symbol.toStringTag,{value:"Module"})),pg=a.object({jsonrpc:a.literal("2.0"),method:a.string(),params:a.any().optional(),id:a.union([a.string(),a.number(),a.null()]).optional()}),Qc=a.object({jsonrpc:a.literal("2.0"),id:a.union([a.string(),a.number(),a.null()])}),yg=Qc.extend({result:a.json()}),mg=Qc.extend({error:a.object({code:a.number().int(),message:a.string().optional(),data:a.json().optional()})}),gg=a.union([yg,mg]);a.union([pg,gg]);a.z.object({key:a.z.string(),value:a.z.string()});const el=a.uuid(),tl=a.object({key:el,name:a.string().min(1),color:a.string()}),rl=Object.freeze(Object.defineProperty({__proto__:null,keyZ:el,labelZ:tl},Symbol.toStringTag,{value:"Module"})),xs=a.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),wg=(t,e)=>{const r=t.split("."),n=e.split("."),s=Math.max(r.length,n.length);for(let i=0;i<s;i++){const o=r[i],c=n[i];if(o===void 0)return Be;if(c===void 0)return Fe;const l=/^\d+$/.test(o),u=/^\d+$/.test(c);if(l&&!u)return Be;if(!l&&u)return Fe;if(l&&u){const h=parseInt(o),f=parseInt(c);if(h<f)return Be;if(h>f)return Fe}else{if(o<c)return Be;if(o>c)return Fe}}return At},_r=((t,e,r={})=>{r.checkMajor??=!0,r.checkMinor??=!0,r.checkPatch??=!0;const n=xs.parse(t),s=xs.parse(e),[i,o]=n.split("-"),[c,l]=s.split("-"),[u,h,f]=i.split(".").map(Number),[d,z,I]=c.split(".").map(Number);if(r.checkMajor){if(u<d)return Be;if(u>d)return Fe}if(r.checkMinor){if(h<z)return Be;if(h>z)return Fe}if(r.checkPatch){if(f<I)return Be;if(f>I)return Fe}return o===void 0&&l===void 0?At:o===void 0?Fe:l===void 0?Be:wg(o,l)}),bg=(t,e,r={})=>ic(_r(t,e,r)),nl=(t,e,r={})=>ac(_r(t,e,r)),vg=(t,e,r={})=>sc(_r(t,e,r)),zg=({name:t,migrate:e})=>r=>{try{const n=e(r);return console.log(`${t} migrated: ${r.version} -> ${n.version}`),n}catch(n){throw console.log(`${t} failed to migrate from ${r.version}`),console.error(n),n}},Og=({name:t,migrations:e,targetSchema:r,defaultVersion:n,def:s})=>{const i=Object.keys(e).sort(_r).pop();if(i==null)return u=>{if(u.version??=n,u.version!==s.version)return console.log(`${t} version ${u.version} is newer than latest version of ${s.version}.
|
|
14
|
-
Returning default instead.
|
|
15
|
-
`),s;try{return r!=null?r.parse(u):u}catch(h){return console.log(`${t} failed to parse default. Exiting with default`),console.error(h),s}};const o=Object.keys(e).length;let c=!1;const l=u=>{try{if(o===0||nl(u.version,i))return console.log(c?`${t} ${u.version} now up to date`:`${t} version ${u.version} is up to date with target version ${s.version}`),u;const h=u.version,f=e[h],d=f(u);return c=!0,l(d)}catch(h){return console.log(`${t} failed to migrate from ${u.version} to ${i}`),console.error(h),s}};return u=>{try{if(u.version==null)if(n!=null)console.log(`${t} version is null. Setting version to default of ${n}`),u.version=n;else return console.log(`${t} version is null and no default version set. Exiting with default`),s;return l(u)}catch(h){return console.log(`${t} failed to parse final result. Exiting with default`),console.error(h),s}}},Ai=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:_r,createMigration:zg,migrator:Og,semVerNewer:nl,semVerOlder:vg,semVerZ:xs,versionsEqual:bg},Symbol.toStringTag,{value:"Module"})),Tg=["standard","scientific","engineering"];a.z.enum(Tg);class kg{handlers;transform;closer;constructor(e,r){this.transform=e,this.handlers=r??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let r=e;if(this.transform!=null){const[n,s]=this.transform(e);if(!s)return;r=n}this.handlers.forEach((n,s)=>s(r))}setCloser(e){this.closer=e}async close(){return await this.closer?.()}}class Sg{handlers;constructor(e){this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((r,n)=>n(e))}}const Ng=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Sg,Observer:kg},Symbol.toStringTag,{value:"Module"})),sl=a.z.union([a.z.string(),a.z.number()]),Eg=a.z.record(sl,a.z.unknown()),ka=t=>Object.entries(t),Ag=(t,e)=>Object.fromEntries(ka(t).map(([r,n])=>[r,e(n,r)])),xg=t=>Object.fromEntries(ka(t).filter(([e,r])=>r!==void 0)),Ig=(t,...e)=>{const r={...t};for(const n of e)delete r[n];return r},ze=Object.freeze(Object.defineProperty({__proto__:null,entries:ka,keyZ:sl,map:Ag,omit:Ig,purgeUndefined:xg,unknownZ:Eg},Symbol.toStringTag,{value:"Module"})),al=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Cg=al(),il=["macOS","Windows","Linux"],jg=["macos","windows","linux"],$g={macos:"macOS",windows:"Windows",linux:"Linux"},Mg=a.z.enum(il).or(a.z.enum(jg).transform(t=>$g[t])),_g=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"macOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"};let Hn;const Zg=((t={})=>{const{force:e,default:r}=t;return e??Hn??(Hn=_g(),Hn??r)}),Ug=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:il,RUNTIME:Cg,detect:al,getOS:Zg,osZ:Mg},Symbol.toStringTag,{value:"Module"})),ol=a.z.enum(["success","info","warning","error","loading","disabled"]),Pg=t=>a.z.object({key:a.z.string(),name:a.z.string().default(""),variant:ol,message:a.z.string(),description:a.z.string().optional(),time:C.z,labels:Ho(tl).optional(),details:t??a.z.unknown().optional()}),Rg=a.z.object({stack:a.z.string(),error:a.z.instanceof(Error)}),Lg=(t,e)=>{if(!(t instanceof Error))throw t;return cl({variant:"error",message:e??t.message,description:e!=null?t.message:void 0,details:{stack:t.stack??"",error:t}})},cl=t=>({key:aa(),time:C.now(),name:"",...t}),Dg=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?t:void 0:e===t?t:void 0},Bg=(t,e=[])=>{if(t!=null)return Array.isArray(e)?e.includes(t)?void 0:t:e===t?void 0:t},lt=Object.freeze(Object.defineProperty({__proto__:null,create:cl,exceptionDetailsSchema:Rg,fromException:Lg,keepVariants:Dg,removeVariants:Bg,statusZ:Pg,variantZ:ol},Symbol.toStringTag,{value:"Module"})),Fg=(t,e)=>{if(!e.has(t))return t;let r=t,n=1,s=t;for(;e.has(s);){const i=s.match(qg);i?(r=s.slice(0,i.index).trim(),n=parseInt(i[1])+1):(r=s,n=1),s=`${r} (${n})`}return s},qg=/\((\d+)\)$/,Yg=(t,e="")=>{if(typeof t=="string")return t;const r=t.length;return r===0?e:r===1?t[0]:r===2?`${t[0]} and ${t[1]}`:`${t.slice(0,-1).join(", ")}, and ${t[r-1]}`},Vg=t=>{const e=t.split(" "),r=new Set,n=e.map(o=>o.charAt(0).toLowerCase()).join("");r.add(n.replace(/-/g,"_")),r.add(n.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"));const s=/\d+/g;t.match(s)&&e.forEach((o,c)=>{if(s.test(o)){const l=e.map((u,h)=>h!==c?u.charAt(0).toLowerCase():u).join("");r.add(l.replace(/-/g,"_")),r.add(l.replace(/(.)(.)/g,"$1_$2").replace(/-/g,"_"))}});const i=e.map(o=>(o.length>3?o.substring(0,3):o).toLowerCase());return r.add(i.join("").replace(/-/g,"_")),r.add(i.join("_").replace(/-/g,"_")),Array.from(r).filter(o=>o.length>=2&&o.length<=12&&!/^\d/.test(o))},Hg=(t,e)=>t.startsWith(e)?t.slice(e.length):t,Is=Object.freeze(Object.defineProperty({__proto__:null,createShortIdentifiers:Vg,deduplicateFileName:Fg,naturalLanguageJoin:Yg,trimPrefix:Hg},Symbol.toStringTag,{value:"Module"})),Wg=(...t)=>t.map(ll).join(""),ll=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Gg=t=>t.endsWith("/")?t.slice(0,-1):t;class Lt{protocol;host;port;path;constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){this.protocol=n,this.host=e,this.port=r,this.path=ll(s)}replace(e){return new Lt({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Lt({...this,pathPrefix:Wg(this.path,e)})}toString(){return Gg(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new Lt({host:"unknown",port:0})}const Kg=t=>t.nullable().transform(e=>e===null?void 0:e).optional(),Jg=a.z.int().min(0).max(hc),Xg=t=>a.array(t).or(t.transform(e=>[e])),Qg=t=>t._zod.def.output,ul=t=>tg(t,(e,r,n)=>{const s=r===n.length-1,i=!isNaN(parseInt(e)),o=!isNaN(parseInt(n[r+1]));return i&&(e="element"),s||o?e:[e,"shape"]}),xi=(t,e)=>{if(t==null)return null;const r=t[e];return r==null&&typeof t=="object"&&"sourceType"in t?t.sourceType()[e]:r},ew=((t,e,r)=>e===""?t:ng(xi(t,"shape"),ul(e),{...r,getter:xi})),_e=Object.freeze(Object.defineProperty({__proto__:null,functionOutput:Qg,getFieldSchema:ew,getFieldSchemaPath:ul,nullToUndefined:Kg,toArray:Xg,uint12:Jg},Symbol.toStringTag,{value:"Module"})),Sa=a.z.enum(["create","delete","retrieve","update"]);class Ue extends He.createTyped("sy"){}let W=class extends Ue.sub("validation"){};class wr extends W.sub("path"){path;error;static encodedSchema=a.z.object({path:a.z.string().array(),error:He.payloadZ});constructor(e,r){const n=O.toArray(e);super(`${n.join(".")}: ${r.message}`),this.path=n.flatMap(s=>s.split(".")),this.error=r}static decode(e){const r=wr.encodedSchema.parse(JSON.parse(e.data));return new wr(r.path,He.decode(r.error))}}class br extends Ue.sub("auth"){}class Cs extends br.sub("invalid_token"){}class js extends br.sub("expired_token"){}class BA extends br.sub("access_denied"){}class ie extends Ue.sub("unexpected"){constructor(e){super(`
|
|
16
|
-
Unexpected error encountered:
|
|
17
|
-
|
|
18
|
-
${e}
|
|
19
|
-
|
|
20
|
-
Please report this to the Synnax team.
|
|
21
|
-
`)}}class ot extends Ue.sub("query"){}class Tt extends ot.sub("not_found"){}class cn extends ot.sub("multiple_results"){}class Ii extends Ue.sub("route"){path;constructor(e,r){super(e),this.path=r}}class $s extends Ue.sub("control"){}class Ci extends $s.sub("unauthorized"){}class tw extends Ue.sub("disconnected"){constructor(e="Operation failed because no Core is connected."){super(e)}}class FA extends Ue.sub("contiguity"){}const rw=t=>t.type.startsWith(Ue.TYPE)?t.type.startsWith(W.TYPE)?t.type===wr.TYPE?wr.decode(t):new W(t.data):t.type.startsWith(br.TYPE)?t.type.startsWith(Cs.TYPE)?new Cs(t.data):t.type.startsWith(js.TYPE)?new js(t.data):new br(t.data):t.type.startsWith(ie.TYPE)?new ie(t.data):t.type.startsWith(ot.TYPE)?t.type.startsWith(Tt.TYPE)?new Tt(t.data):t.type.startsWith(cn.TYPE)?new cn(t.data):new ot(t.data):t.type.startsWith($s.TYPE)?t.type.startsWith(Ci.TYPE)?new Ci(t.data):new $s(t.data):t.type.startsWith(Ii.TYPE)?new Ii(t.data,t.data):new ie(t.data):null,nw=()=>{throw new He.NotImplemented};He.register({encode:nw,decode:rw});const sw=async(t,e)=>{const[r,n]=await e(t);return n==null?[r,n]:n instanceof it?[r,new it({message:`Cannot reach Core at ${n.url.host}:${n.url.port}`,url:n.url})]:[r,n]},wn=a.z.enum(["label","log","builtin","cluster","channel","node","group","range","framer","range-alias","user","workspace","schematic","lineplot","rack","device","task","policy","role","table","arc","schematic_symbol","status","view"]),hl=a.z.string().transform(t=>{const[e,r]=t.split(":");return{type:wn.parse(e),key:r??""}}),F=a.z.object({type:wn,key:a.z.string()}).or(hl),aw={type:"builtin",key:"root"},K=t=>{const e=r=>({type:t,key:Rp.isZero(r)?"":r.toString()});return(r=>Array.isArray(r)?r.map(e):e(r))},Ze=(t=>(typeof t=="string"&&(t=hl.parse(t)),Array.isArray(t)?t.map(e=>Ze(e)):`${t.type}:${t.key}`)),iw=(t,e)=>t.type===e.type&&t.key===e.key,dl=t=>{const e=O.toArray(t);return e.length===0?[]:typeof e[0]=="object"&&"id"in e[0]?e.map(({id:r})=>r):e.map(r=>F.parse(r))},fl=a.z.object({id:F,name:a.z.string(),data:ze.unknownZ.optional().nullable()}).transform(t=>({key:Ze(t.id),...t})),ow=t=>t==="to"?"from":"to",cw=a.z.object({from:F,type:a.z.string(),to:F}).or(a.z.string().transform(t=>{const[e,r,n]=t.split("->");return{from:F.parse(e),type:r,to:F.parse(n)}})),lw=t=>`${Ze(t.from)}->${t.type}->${Ze(t.to)}`,uw="parent",hw=(t,e)=>!(e.type!=null&&e.type!==t.type||e.from?.type!=null&&e.from.type!==t.from.type||e.to?.type!=null&&e.to.type!==t.to.type||e.from?.key!=null&&e.from.key!==t.from.key||e.to?.key!=null&&e.to.key!==t.to.key),Zr=a.z.uuid(),pl=a.z.string(),bn=a.z.object({key:Zr,name:pl}),dw=K("group"),fw="sy_group_set",pw="sy_group_delete",yw=a.object({group:bn}),mw=a.object({parent:F,key:Zr.optional(),name:a.string()}),gw=a.object({key:Zr,name:a.string()}),ww=a.object({keys:a.array(Zr)});let yl=class{client;constructor(t){this.client=t}async create(t){return(await w(this.client,"/ontology/create-group",t,mw,yw)).group}async rename(t,e){await w(this.client,"/ontology/rename-group",{key:t,name:e},gw,a.object({}))}async delete(t){await w(this.client,"/ontology/delete-group",{keys:O.toArray(t)},ww,a.object({}))}};const bw=Object.freeze(Object.defineProperty({__proto__:null,Client:yl,DELETE_CHANNEL_NAME:pw,SET_CHANNEL_NAME:fw,groupZ:bn,keyZ:Zr,nameZ:pl,ontologyID:dw},Symbol.toStringTag,{value:"Module"})),ji=a.z.object({id:F,children:F.array()}),vw=a.z.object({from:F,to:F,children:F.array()}),Wn=a.z.object({});let zw=class{client;constructor(t){this.client=t}async addChildren(t,...e){await w(this.client,"/ontology/add-children",{id:t,children:e},ji,Wn)}async removeChildren(t,...e){await w(this.client,"/ontology/remove-children",{id:t,children:e},ji,Wn)}async moveChildren(t,e,...r){await w(this.client,"/ontology/move-children",{from:t,to:e,children:r},vw,Wn)}};const Ow=a.z.object({ids:F.array().optional(),children:a.z.boolean().optional(),parents:a.z.boolean().optional(),excludeFieldData:a.z.boolean().optional(),types:wn.array().optional(),searchTerm:a.z.string().optional(),limit:a.z.int().optional(),offset:a.z.int().optional()}),Tw=a.z.object({resources:fl.array()});let ml=class{type="ontology";groups;client;writer;framer;constructor(t,e){this.client=t,this.writer=new zw(t),this.groups=new yl(t),this.framer=e}async retrieve(t,e){if(!Array.isArray(t)&&typeof t=="object"&&!("key"in t))return this.execRetrieve(t);const r=dl(t),n=await this.execRetrieve({ids:r,...e});if(Array.isArray(t))return n;if(n.length===0)throw new ot(`No resource found with ID ${Is.naturalLanguageJoin(r.map(s=>Ze(s)))}`);return n[0]}async retrieveChildren(t,e){return await this.execRetrieve({ids:O.toArray(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:O.toArray(t),parents:!0,...e})}async addChildren(t,...e){return await this.writer.addChildren(t,...e)}async removeChildren(t,...e){return await this.writer.removeChildren(t,...e)}async moveChildren(t,e,...r){return await this.writer.moveChildren(t,e,...r)}async execRetrieve(t){const{resources:e}=await w(this.client,"/ontology/retrieve",t,Ow,Tw);return e}};const kw="sy_ontology_resource_set",Sw="sy_ontology_resource_delete",Nw="sy_ontology_relationship_set",Ew="sy_ontology_relationship_delete",Aw=Object.freeze(Object.defineProperty({__proto__:null,Client:ml,PARENT_OF_RELATIONSHIP_TYPE:uw,RELATIONSHIP_DELETE_CHANNEL_NAME:Ew,RELATIONSHIP_SET_CHANNEL_NAME:Nw,RESOURCE_DELETE_CHANNEL_NAME:Sw,RESOURCE_SET_CHANNEL_NAME:kw,ROOT_ID:aw,createIDFactory:K,idToString:Ze,idZ:F,idsEqual:iw,matchRelationship:hw,oppositeRelationshipDirection:ow,parseIDs:dl,relationshipToString:lw,relationshipZ:cw,resourceTypeZ:wn,resourceZ:fl},Symbol.toStringTag,{value:"Module"})),Jt=a.z.uuid(),Na=a.z.object({key:Jt,name:a.z.string(),objects:O.nullableZ(F),actions:O.nullableZ(Sa),internal:a.z.boolean()}),Ea=a.z.object({key:Jt.optional(),name:a.z.string(),objects:_e.toArray(F),actions:_e.toArray(Sa)}),gl=K("policy"),xw=gl(""),Iw="sy_policy_set",Cw="sy_policy_delete",jw=a.z.object({keys:Jt.array().optional(),subjects:F.array().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),internal:a.z.boolean().optional()}),$w=a.z.object({key:Jt}).transform(({key:t})=>({keys:[t]})),Mw=a.z.union([a.z.object({for:F}).transform(({for:t})=>({subjects:[t]})),a.z.object({for:F.array()}).transform(({for:t})=>({subjects:t})),jw]),_w=a.z.union([$w,Mw]),Zw=a.z.object({policies:O.nullableZ(Na)}),Uw=Ea.transform(t=>({policies:[t]})),wl=Ea.array().transform(t=>({policies:t})),bl=a.z.union([Uw,wl]),Pw=a.z.object({policies:Na.array()}),Rw=a.z.object({keys:Jt.array()}),Lw=a.z.object({});let vl=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/access/policy/create",t,bl,Pw);return e?r.policies:r.policies[0]}async retrieve(t){const e="key"in t,r=await w(this.client,"/access/policy/retrieve",t,_w,Zw);return e?r.policies[0]:r.policies}async delete(t){await w(this.client,"/access/policy/delete",{keys:O.toArray(t)},Rw,Lw)}};const Dw=Object.freeze(Object.defineProperty({__proto__:null,Client:vl,DELETE_CHANNEL_NAME:Cw,SET_CHANNEL_NAME:Iw,TYPE_ONTOLOGY_ID:xw,createArgsZ:bl,keyZ:Jt,multipleCreateArgsZ:wl,newZ:Ea,ontologyID:gl,policyZ:Na},Symbol.toStringTag,{value:"Module"})),ct=a.z.uuid(),vn=a.z.object({key:ct,name:a.z.string(),description:a.z.string().optional(),internal:a.z.boolean().optional()}),Aa=vn.partial({key:!0}),zl=K("role"),Bw=zl(""),Pe=a.z.uuid(),Ur=a.z.object({key:Pe,username:a.z.string().min(1,"Username is required"),firstName:a.z.string().default(""),lastName:a.z.string().default(""),rootUser:a.z.boolean().default(!1)}),Ol=Ur.omit({rootUser:!0}).partial({key:!0,firstName:!0,lastName:!0}).extend({password:a.z.string().min(1)}),Fw=a.z.object({keys:Pe.array().optional(),usernames:a.z.string().array().optional()}),qw=a.z.object({key:Pe}).transform(({key:t})=>({keys:[t]})),Yw=a.z.object({username:a.z.string()}).transform(({username:t})=>({usernames:[t]})),Vw=a.z.object({usernames:a.z.string().array()}).transform(({usernames:t})=>({usernames:t})),Hw=a.z.union([qw,Yw,Vw,Fw]),Ww=a.z.object({users:O.nullableZ(Ur)}),Gw=a.z.object({users:Ol.array()}),Kw=a.z.object({users:Ur.array()}),Jw=a.z.object({key:Pe,username:a.z.string().min(1)}),Xw=a.z.object({}),Qw=a.z.object({key:Pe,firstName:a.z.string().optional(),lastName:a.z.string().optional()}),eb=a.z.object({}),tb=a.z.object({keys:Pe.array()}),rb=a.z.object({}),nb="sy_user_set",sb="sy_user_delete";let Tl=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/user/create",{users:O.toArray(t)},Gw,Kw);return e?r.users:r.users[0]}async changeUsername(t,e){await w(this.client,"/user/change-username",{key:t,username:e},Jw,Xw)}async retrieve(t){const e="key"in t||"username"in t,r=await w(this.client,"/user/retrieve",t,Hw,Ww);if(!e)return r.users;if(r.users.length===0){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new Tt(`No user with ${n} found`)}if(r.users.length>1){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new cn(`Multiple users found with ${n}`)}return r.users[0]}async rename(t,e,r){await w(this.client,"/user/rename",{key:t,firstName:e,lastName:r},Qw,eb)}async delete(t){await w(this.client,"/user/delete",{keys:O.toArray(t)},tb,rb)}};const kl=K("user"),ab=kl(""),ib=Object.freeze(Object.defineProperty({__proto__:null,Client:Tl,DELETE_CHANNEL_NAME:sb,SET_CHANNEL_NAME:nb,TYPE_ONTOLOGY_ID:ab,keyZ:Pe,newZ:Ol,ontologyID:kl,userZ:Ur},Symbol.toStringTag,{value:"Module"})),ob=a.z.object({keys:ct.array().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),internal:a.z.boolean().optional()}),cb=a.z.object({key:ct}).transform(({key:t})=>({keys:[t]})),lb=Aa.transform(t=>({roles:[t]})),Sl=Aa.array().transform(t=>({roles:t})),Nl=a.z.union([lb,Sl]),ub=a.z.object({roles:vn.array()}),hb=a.z.object({roles:O.nullableZ(vn)}),El=a.z.union([cb,ob]),db=a.z.object({}),fb=ct.transform(t=>({keys:[t]})).or(ct.array().transform(t=>({keys:t}))),pb=a.z.object({user:Pe,role:ct}),yb=a.z.object({}),mb=a.z.object({user:Pe,role:ct}),gb=a.z.object({}),wb="sy_role_set",bb="sy_role_delete";let Al=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/access/role/create",t,Nl,ub);return e?r.roles:r.roles[0]}async retrieve(t){const e="key"in t,r=await w(this.client,"/access/role/retrieve",t,El,hb);return e?r.roles[0]:r.roles}async delete(t){await w(this.client,"/access/role/delete",t,fb,db)}async assign(t){await w(this.client,"/access/role/assign",t,pb,yb)}async unassign(t){await w(this.client,"/access/role/unassign",t,mb,gb)}};const vb=Object.freeze(Object.defineProperty({__proto__:null,Client:Al,DELETE_CHANNEL_NAME:bb,SET_CHANNEL_NAME:wb,TYPE_ONTOLOGY_ID:Bw,createArgsZ:Nl,keyZ:ct,multipleCreateArgsZ:Sl,newZ:Aa,ontologyID:zl,retrieveArgsZ:El,roleZ:vn},Symbol.toStringTag,{value:"Module"}));let xl=class{policies;roles;constructor(t){this.policies=new vl(t),this.roles=new Al(t)}};const zb=(t,e)=>{const r=O.toArray(t.objects),{action:n}=t;for(const s of r){let i=!1;for(const o of e)if(o.actions.includes(n)){for(const c of o.objects)if(c.key===""){if(c.type===s.type){i=!0;break}}else if(c.type===s.type&&c.key===s.key){i=!0;break}if(i)break}if(!i)return!1}return!0},Ob=Object.freeze(Object.defineProperty({__proto__:null,Client:xl,actionZ:Sa,allowRequest:zb,policy:Dw,role:vb},Symbol.toStringTag,{value:"Module"}));function p(t,e,r){function n(c,l){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),c._zod.traits.has(t))return;c._zod.traits.add(t),e(c,l);const u=o.prototype,h=Object.keys(u);for(let f=0;f<h.length;f++){const d=h[f];d in c||(c[d]=u[d].bind(c))}}const s=r?.Parent??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(c){var l;const u=r?.Parent?new i:this;n(u,c),(l=u._zod).deferred??(l.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}class Dt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Il extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Cl={};function kt(t){return Cl}function Tb(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,n])=>e.indexOf(+r)===-1).map(([r,n])=>n)}function Ms(t,e){return typeof e=="bigint"?e.toString():e}function xa(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Ia(t){return t==null}function Ca(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function kb(t,e){const r=(t.toString().split(".")[1]||"").length,n=e.toString();let s=(n.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(n)){const l=n.match(/\d?e-(\d?)/);l?.[1]&&(s=Number.parseInt(l[1]))}const i=r>s?r:s,o=Number.parseInt(t.toFixed(i).replace(".","")),c=Number.parseInt(e.toFixed(i).replace(".",""));return o%c/10**i}const $i=Symbol("evaluating");function L(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==$i)return n===void 0&&(n=$i,n=r()),n},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function xt(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function It(...t){const e={};for(const r of t){const n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function Mi(t){return JSON.stringify(t)}function Sb(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const jl="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ln(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const Nb=xa(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function vr(t){if(ln(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const r=e.prototype;return!(ln(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function $l(t){return vr(t)?{...t}:Array.isArray(t)?[...t]:t}const Eb=new Set(["string","number","symbol"]);function Yt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ut(t,e,r){const n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function x(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Ab(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const xb={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ib(t,e){const r=t._zod.def,n=It(t._zod.def,{get shape(){const s={};for(const i in e){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&(s[i]=r.shape[i])}return xt(this,"shape",s),s},checks:[]});return ut(t,n)}function Cb(t,e){const r=t._zod.def,n=It(t._zod.def,{get shape(){const s={...t._zod.def.shape};for(const i in e){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&delete s[i]}return xt(this,"shape",s),s},checks:[]});return ut(t,n)}function jb(t,e){if(!vr(e))throw new Error("Invalid input to extend: expected a plain object");const r=t._zod.def.checks;if(r&&r.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const n=It(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return xt(this,"shape",s),s},checks:[]});return ut(t,n)}function $b(t,e){if(!vr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const r={...t._zod.def,get shape(){const n={...t._zod.def.shape,...e};return xt(this,"shape",n),n},checks:t._zod.def.checks};return ut(t,r)}function Mb(t,e){const r=It(t._zod.def,{get shape(){const n={...t._zod.def.shape,...e._zod.def.shape};return xt(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:[]});return ut(t,r)}function _b(t,e,r){const n=It(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=t?new t({type:"optional",innerType:s[o]}):s[o])}else for(const o in s)i[o]=t?new t({type:"optional",innerType:s[o]}):s[o];return xt(this,"shape",i),i},checks:[]});return ut(e,n)}function Zb(t,e,r){const n=It(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(r)for(const o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new t({type:"nonoptional",innerType:s[o]}))}else for(const o in s)i[o]=new t({type:"nonoptional",innerType:s[o]});return xt(this,"shape",i),i},checks:[]});return ut(e,n)}function Ut(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Ml(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Xr(t){return typeof t=="string"?t:t?.message}function St(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=Xr(t.inst?._zod.def?.error?.(t))??Xr(e?.error?.(t))??Xr(r.customError?.(t))??Xr(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function ja(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function zr(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const _l=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Ms,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Zl=p("$ZodError",_l),Ul=p("$ZodError",_l,{Parent:Error});function Ub(t,e=r=>r.message){const r={},n=[];for(const s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function Pb(t,e=r=>r.message){const r={_errors:[]},n=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>n({issues:o}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(e(i));else{let o=r,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(t),r}const $a=t=>(e,r,n,s)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Dt;if(o.issues.length){const c=new(s?.Err??t)(o.issues.map(l=>St(l,i,kt())));throw jl(c,s?.callee),c}return o.value},Ma=t=>async(e,r,n,s)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const c=new(s?.Err??t)(o.issues.map(l=>St(l,i,kt())));throw jl(c,s?.callee),c}return o.value},zn=t=>(e,r,n)=>{const s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new Dt;return i.issues.length?{success:!1,error:new(t??Zl)(i.issues.map(o=>St(o,s,kt())))}:{success:!0,data:i.value}},Rb=zn(Ul),On=t=>async(e,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let i=e._zod.run({value:r,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>St(o,s,kt())))}:{success:!0,data:i.value}},Lb=On(Ul),Db=t=>(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return $a(t)(e,r,s)},Bb=t=>(e,r,n)=>$a(t)(e,r,n),Fb=t=>async(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ma(t)(e,r,s)},qb=t=>async(e,r,n)=>Ma(t)(e,r,n),Yb=t=>(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return zn(t)(e,r,s)},Vb=t=>(e,r,n)=>zn(t)(e,r,n),Hb=t=>async(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return On(t)(e,r,s)},Wb=t=>async(e,r,n)=>On(t)(e,r,n),Gb=/^[cC][^\s-]{8,}$/,Kb=/^[0-9a-z]+$/,Jb=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Xb=/^[0-9a-vA-V]{20}$/,Qb=/^[A-Za-z0-9]{27}$/,ev=/^[a-zA-Z0-9_-]{21}$/,tv=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,rv=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,_i=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,nv=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,sv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function av(){return new RegExp(sv,"u")}const iv=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ov=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,cv=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,lv=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,uv=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pl=/^[A-Za-z0-9_-]*$/,hv=/^\+(?:[0-9]){6,14}[0-9]$/,Rl="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",dv=new RegExp(`^${Rl}$`);function Ll(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function fv(t){return new RegExp(`^${Ll(t)}$`)}function pv(t){const e=Ll({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Rl}T(?:${n})$`)}const yv=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},mv=/^-?\d+$/,gv=/^-?\d+(?:\.\d+)?/,wv=/^(?:true|false)$/i,bv=/^[^A-Z]*$/,vv=/^[^a-z]*$/,oe=p("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Dl={number:"number",bigint:"bigint",object:"date"},Bl=p("$ZodCheckLessThan",(t,e)=>{oe.init(t,e);const r=Dl[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Fl=p("$ZodCheckGreaterThan",(t,e)=>{oe.init(t,e);const r=Dl[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),zv=p("$ZodCheckMultipleOf",(t,e)=>{oe.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):kb(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),Ov=p("$ZodCheckNumberFormat",(t,e)=>{oe.init(t,e),e.format=e.format||"float64";const r=e.format?.includes("int"),n=r?"int":"number",[s,i]=xb[e.format];t._zod.onattach.push(o=>{const c=o._zod.bag;c.format=e.format,c.minimum=s,c.maximum=i,r&&(c.pattern=mv)}),t._zod.check=o=>{const c=o.value;if(r){if(!Number.isInteger(c)){o.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:c,inst:t});return}if(!Number.isSafeInteger(c)){c>0?o.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):o.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}c<s&&o.issues.push({origin:"number",input:c,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),c>i&&o.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inst:t})}}),Tv=p("$ZodCheckMaxLength",(t,e)=>{var r;oe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ia(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{const s=n.value;if(s.length<=e.maximum)return;const i=ja(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),kv=p("$ZodCheckMinLength",(t,e)=>{var r;oe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ia(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{const s=n.value;if(s.length>=e.minimum)return;const i=ja(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Sv=p("$ZodCheckLengthEquals",(t,e)=>{var r;oe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ia(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{const s=n.value,i=s.length;if(i===e.length)return;const o=ja(s),c=i>e.length;n.issues.push({origin:o,...c?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Tn=p("$ZodCheckStringFormat",(t,e)=>{var r,n;oe.init(t,e),t._zod.onattach.push(s=>{const i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),Nv=p("$ZodCheckRegex",(t,e)=>{Tn.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),Ev=p("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=bv),Tn.init(t,e)}),Av=p("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=vv),Tn.init(t,e)}),xv=p("$ZodCheckIncludes",(t,e)=>{oe.init(t,e);const r=Yt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),Iv=p("$ZodCheckStartsWith",(t,e)=>{oe.init(t,e);const r=new RegExp(`^${Yt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),Cv=p("$ZodCheckEndsWith",(t,e)=>{oe.init(t,e);const r=new RegExp(`.*${Yt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),jv=p("$ZodCheckOverwrite",(t,e)=>{oe.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class $v{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
22
|
-
`).filter(i=>i),n=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(n)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const e=Function,r=this?.args,n=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...r,n.join(`
|
|
23
|
-
`))}}const Mv={major:4,minor:1,patch:13},H=p("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Mv;const n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(const s of n)for(const i of s._zod.onattach)i(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const s=(o,c,l)=>{let u=Ut(o),h;for(const f of c){if(f._zod.def.when){if(!f._zod.def.when(o))continue}else if(u)continue;const d=o.issues.length,z=f._zod.check(o);if(z instanceof Promise&&l?.async===!1)throw new Dt;if(h||z instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await z,o.issues.length!==d&&(u||(u=Ut(o,d)))});else{if(o.issues.length===d)continue;u||(u=Ut(o,d))}}return h?h.then(()=>o):o},i=(o,c,l)=>{if(Ut(o))return o.aborted=!0,o;const u=s(c,n,l);if(u instanceof Promise){if(l.async===!1)throw new Dt;return u.then(h=>t._zod.parse(h,l))}return t._zod.parse(u,l)};t._zod.run=(o,c)=>{if(c.skipChecks)return t._zod.parse(o,c);if(c.direction==="backward"){const u=t._zod.parse({value:o.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(h=>i(h,o,c)):i(u,o,c)}const l=t._zod.parse(o,c);if(l instanceof Promise){if(c.async===!1)throw new Dt;return l.then(u=>s(u,n,c))}return s(l,n,c)}}t["~standard"]={validate:s=>{try{const i=Rb(t,s);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Lb(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),_a=p("$ZodString",(t,e)=>{H.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??yv(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),q=p("$ZodStringFormat",(t,e)=>{Tn.init(t,e),_a.init(t,e)}),_v=p("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=rv),q.init(t,e)}),Zv=p("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=_i(r))}else e.pattern??(e.pattern=_i());q.init(t,e)}),Uv=p("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=nv),q.init(t,e)}),Pv=p("$ZodURL",(t,e)=>{q.init(t,e),t._zod.check=r=>{try{const n=r.value.trim(),s=new URL(n);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),e.normalize?r.value=s.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),Rv=p("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=av()),q.init(t,e)}),Lv=p("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=ev),q.init(t,e)}),Dv=p("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Gb),q.init(t,e)}),Bv=p("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Kb),q.init(t,e)}),Fv=p("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Jb),q.init(t,e)}),qv=p("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Xb),q.init(t,e)}),Yv=p("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Qb),q.init(t,e)}),Vv=p("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=pv(e)),q.init(t,e)}),Hv=p("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=dv),q.init(t,e)}),Wv=p("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=fv(e)),q.init(t,e)}),Gv=p("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=tv),q.init(t,e)}),Kv=p("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=iv),q.init(t,e),t._zod.bag.format="ipv4"}),Jv=p("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=ov),q.init(t,e),t._zod.bag.format="ipv6",t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),Xv=p("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=cv),q.init(t,e)}),Qv=p("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=lv),q.init(t,e),t._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[s,i]=n;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${s}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function ql(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const ez=p("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=uv),q.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=r=>{ql(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function tz(t){if(!Pl.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return ql(r)}const rz=p("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Pl),q.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=r=>{tz(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),nz=p("$ZodE164",(t,e)=>{e.pattern??(e.pattern=hv),q.init(t,e)});function sz(t,e=null){try{const r=t.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const az=p("$ZodJWT",(t,e)=>{q.init(t,e),t._zod.check=r=>{sz(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),Yl=p("$ZodNumber",(t,e)=>{H.init(t,e),t._zod.pattern=t._zod.bag.pattern??gv,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}const s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;const i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...i?{received:i}:{}}),r}}),iz=p("$ZodNumberFormat",(t,e)=>{Ov.init(t,e),Yl.init(t,e)}),oz=p("$ZodBoolean",(t,e)=>{H.init(t,e),t._zod.pattern=wv,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}const s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),r}}),cz=p("$ZodUnknown",(t,e)=>{H.init(t,e),t._zod.parse=r=>r}),lz=p("$ZodNever",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Zi(t,e,r){t.issues.length&&e.issues.push(...Ml(r,t.issues)),e.value[r]=t.value}const uz=p("$ZodArray",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),r;r.value=Array(s.length);const i=[];for(let o=0;o<s.length;o++){const c=s[o],l=e.element._zod.run({value:c,issues:[]},n);l instanceof Promise?i.push(l.then(u=>Zi(u,r,o))):Zi(l,r,o)}return i.length?Promise.all(i).then(()=>r):r}});function un(t,e,r,n){t.issues.length&&e.issues.push(...Ml(r,t.issues)),t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}function Vl(t){const e=Object.keys(t.shape);for(const n of e)if(!t.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=Ab(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function Hl(t,e,r,n,s,i){const o=[],c=s.keySet,l=s.catchall._zod,u=l.def.type;for(const h in e){if(c.has(h))continue;if(u==="never"){o.push(h);continue}const f=l.run({value:e[h],issues:[]},n);f instanceof Promise?t.push(f.then(d=>un(d,r,h,e))):un(f,r,h,e)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:i}),t.length?Promise.all(t).then(()=>r):r}const hz=p("$ZodObject",(t,e)=>{if(H.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){const o=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...o};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=xa(()=>Vl(e));L(t._zod,"propValues",()=>{const o=e.shape,c={};for(const l in o){const u=o[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(const h of u.values)c[l].add(h)}}return c});const n=ln,s=e.catchall;let i;t._zod.parse=(o,c)=>{i??(i=r.value);const l=o.value;if(!n(l))return o.issues.push({expected:"object",code:"invalid_type",input:l,inst:t}),o;o.value={};const u=[],h=i.shape;for(const f of i.keys){const d=h[f]._zod.run({value:l[f],issues:[]},c);d instanceof Promise?u.push(d.then(z=>un(z,o,f,l))):un(d,o,f,l)}return s?Hl(u,l,o,c,r.value,t):u.length?Promise.all(u).then(()=>o):o}}),dz=p("$ZodObjectJIT",(t,e)=>{hz.init(t,e);const r=t._zod.parse,n=xa(()=>Vl(e)),s=f=>{const d=new $v(["shape","payload","ctx"]),z=n.value,I=S=>{const U=Mi(S);return`shape[${U}]._zod.run({ value: input[${U}], issues: [] }, ctx)`};d.write("const input = payload.value;");const j=Object.create(null);let b=0;for(const S of z.keys)j[S]=`key_${b++}`;d.write("const newResult = {};");for(const S of z.keys){const U=j[S],P=Mi(S);d.write(`const ${U} = ${I(S)};`),d.write(`
|
|
24
|
-
if (${U}.issues.length) {
|
|
25
|
-
payload.issues = payload.issues.concat(${U}.issues.map(iss => ({
|
|
26
|
-
...iss,
|
|
27
|
-
path: iss.path ? [${P}, ...iss.path] : [${P}]
|
|
28
|
-
})));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (${U}.value === undefined) {
|
|
33
|
-
if (${P} in input) {
|
|
34
|
-
newResult[${P}] = undefined;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
newResult[${P}] = ${U}.value;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
`)}d.write("payload.value = newResult;"),d.write("return payload;");const v=d.compile();return(S,U)=>v(f,S,U)};let i;const o=ln,c=!Cl.jitless,l=c&&Nb.value,u=e.catchall;let h;t._zod.parse=(f,d)=>{h??(h=n.value);const z=f.value;return o(z)?c&&l&&d?.async===!1&&d.jitless!==!0?(i||(i=s(e.shape)),f=i(f,d),u?Hl([],z,f,d,h,t):f):r(f,d):(f.issues.push({expected:"object",code:"invalid_type",input:z,inst:t}),f)}});function Ui(t,e,r,n){for(const i of t)if(i.issues.length===0)return e.value=i.value,e;const s=t.filter(i=>!Ut(i));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(i=>i.issues.map(o=>St(o,n,kt())))}),e)}const fz=p("$ZodUnion",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.options.some(s=>s._zod.optin==="optional")?"optional":void 0),L(t._zod,"optout",()=>e.options.some(s=>s._zod.optout==="optional")?"optional":void 0),L(t._zod,"values",()=>{if(e.options.every(s=>s._zod.values))return new Set(e.options.flatMap(s=>Array.from(s._zod.values)))}),L(t._zod,"pattern",()=>{if(e.options.every(s=>s._zod.pattern)){const s=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${s.map(i=>Ca(i.source)).join("|")})$`)}});const r=e.options.length===1,n=e.options[0]._zod.run;t._zod.parse=(s,i)=>{if(r)return n(s,i);let o=!1;const c=[];for(const l of e.options){const u=l._zod.run({value:s.value,issues:[]},i);if(u instanceof Promise)c.push(u),o=!0;else{if(u.issues.length===0)return u;c.push(u)}}return o?Promise.all(c).then(l=>Ui(l,s,t,i)):Ui(c,s,t,i)}}),pz=p("$ZodIntersection",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{const s=r.value,i=e.left._zod.run({value:s,issues:[]},n),o=e.right._zod.run({value:s,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,l])=>Pi(r,c,l)):Pi(r,i,o)}});function _s(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(vr(t)&&vr(e)){const r=Object.keys(e),n=Object.keys(t).filter(i=>r.indexOf(i)!==-1),s={...t,...e};for(const i of n){const o=_s(t[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<t.length;n++){const s=t[n],i=e[n],o=_s(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Pi(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Ut(t))return t;const n=_s(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}const yz=p("$ZodEnum",(t,e)=>{H.init(t,e);const r=Tb(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(s=>Eb.has(typeof s)).map(s=>typeof s=="string"?Yt(s):s.toString()).join("|")})$`),t._zod.parse=(s,i)=>{const o=s.value;return n.has(o)||s.issues.push({code:"invalid_value",values:r,input:o,inst:t}),s}}),mz=p("$ZodLiteral",(t,e)=>{if(H.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?Yt(n):n?Yt(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,s)=>{const i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:e.values,input:i,inst:t}),n}}),gz=p("$ZodTransform",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Il(t.constructor.name);const s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new Dt;return r.value=s,r}});function Ri(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const wz=p("$ZodOptional",(t,e)=>{H.init(t,e),t._zod.optin="optional",t._zod.optout="optional",L(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),L(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${Ca(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Ri(i,r.value)):Ri(s,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),bz=p("$ZodNullable",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.innerType._zod.optin),L(t._zod,"optout",()=>e.innerType._zod.optout),L(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${Ca(r.source)}|null)$`):void 0}),L(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),vz=p("$ZodDefault",(t,e)=>{H.init(t,e),t._zod.optin="optional",L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Li(i,e)):Li(s,e)}});function Li(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const zz=p("$ZodPrefault",(t,e)=>{H.init(t,e),t._zod.optin="optional",L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),Oz=p("$ZodNonOptional",(t,e)=>{H.init(t,e),L(t._zod,"values",()=>{const r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Di(i,t)):Di(s,t)}});function Di(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const Tz=p("$ZodCatch",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.innerType._zod.optin),L(t._zod,"optout",()=>e.innerType._zod.optout),L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>(r.value=i.value,i.issues.length&&(r.value=e.catchValue({...r,error:{issues:i.issues.map(o=>St(o,n,kt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>St(i,n,kt()))},input:r.value}),r.issues=[]),r)}}),kz=p("$ZodPipe",(t,e)=>{H.init(t,e),L(t._zod,"values",()=>e.in._zod.values),L(t._zod,"optin",()=>e.in._zod.optin),L(t._zod,"optout",()=>e.out._zod.optout),L(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=e.out._zod.run(r,n);return i instanceof Promise?i.then(o=>Qr(o,e.in,n)):Qr(i,e.in,n)}const s=e.in._zod.run(r,n);return s instanceof Promise?s.then(i=>Qr(i,e.out,n)):Qr(s,e.out,n)}});function Qr(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},r)}const Sz=p("$ZodReadonly",(t,e)=>{H.init(t,e),L(t._zod,"propValues",()=>e.innerType._zod.propValues),L(t._zod,"values",()=>e.innerType._zod.values),L(t._zod,"optin",()=>e.innerType?._zod?.optin),L(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(Bi):Bi(s)}});function Bi(t){return t.value=Object.freeze(t.value),t}const Nz=p("$ZodCustom",(t,e)=>{oe.init(t,e),H.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{const n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(i=>Fi(i,r,n,t));Fi(s,r,n,t)}});function Fi(t,e,r,n){if(!t){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(zr(s))}}var qi;class Ez{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){const n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){const r=e._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const s={...n,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Az(){return new Ez}(qi=globalThis).__zod_globalRegistry??(qi.__zod_globalRegistry=Az());const en=globalThis.__zod_globalRegistry;function xz(t,e){return new t({type:"string",...x(e)})}function Iz(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...x(e)})}function Yi(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...x(e)})}function Wl(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...x(e)})}function Cz(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(e)})}function jz(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(e)})}function $z(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(e)})}function Mz(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...x(e)})}function _z(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...x(e)})}function Zz(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(e)})}function Uz(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...x(e)})}function Pz(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(e)})}function Rz(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...x(e)})}function Lz(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...x(e)})}function Dz(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(e)})}function Bz(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(e)})}function Fz(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(e)})}function qz(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(e)})}function Yz(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(e)})}function Vz(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...x(e)})}function Hz(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...x(e)})}function Wz(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...x(e)})}function Gz(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...x(e)})}function Kz(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(e)})}function Jz(t,e){return new t({type:"string",format:"date",check:"string_format",...x(e)})}function Xz(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...x(e)})}function Qz(t,e){return new t({type:"string",format:"duration",check:"string_format",...x(e)})}function eO(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...x(e)})}function tO(t,e){return new t({type:"boolean",...x(e)})}function rO(t){return new t({type:"unknown"})}function nO(t,e){return new t({type:"never",...x(e)})}function Vi(t,e){return new Bl({check:"less_than",...x(e),value:t,inclusive:!1})}function Gn(t,e){return new Bl({check:"less_than",...x(e),value:t,inclusive:!0})}function Hi(t,e){return new Fl({check:"greater_than",...x(e),value:t,inclusive:!1})}function Kn(t,e){return new Fl({check:"greater_than",...x(e),value:t,inclusive:!0})}function Wi(t,e){return new zv({check:"multiple_of",...x(e),value:t})}function Gl(t,e){return new Tv({check:"max_length",...x(e),maximum:t})}function hn(t,e){return new kv({check:"min_length",...x(e),minimum:t})}function Kl(t,e){return new Sv({check:"length_equals",...x(e),length:t})}function sO(t,e){return new Nv({check:"string_format",format:"regex",...x(e),pattern:t})}function aO(t){return new Ev({check:"string_format",format:"lowercase",...x(t)})}function iO(t){return new Av({check:"string_format",format:"uppercase",...x(t)})}function oO(t,e){return new xv({check:"string_format",format:"includes",...x(e),includes:t})}function cO(t,e){return new Iv({check:"string_format",format:"starts_with",...x(e),prefix:t})}function lO(t,e){return new Cv({check:"string_format",format:"ends_with",...x(e),suffix:t})}function Xt(t){return new jv({check:"overwrite",tx:t})}function uO(t){return Xt(e=>e.normalize(t))}function hO(){return Xt(t=>t.trim())}function dO(){return Xt(t=>t.toLowerCase())}function fO(){return Xt(t=>t.toUpperCase())}function pO(){return Xt(t=>Sb(t))}function yO(t,e,r){return new t({type:"array",element:e,...x(r)})}function mO(t,e,r){return new t({type:"custom",check:"custom",fn:e,...x(r)})}function gO(t){const e=wO(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(zr(n,r.value,e._zod.def));else{const s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(zr(s))}},t(r.value,r)));return e}function wO(t,e){const r=new oe({check:"custom",...x(e)});return r._zod.check=t,r}const bO=p("ZodISODateTime",(t,e)=>{Vv.init(t,e),V.init(t,e)});function vO(t){return Kz(bO,t)}const zO=p("ZodISODate",(t,e)=>{Hv.init(t,e),V.init(t,e)});function OO(t){return Jz(zO,t)}const TO=p("ZodISOTime",(t,e)=>{Wv.init(t,e),V.init(t,e)});function kO(t){return Xz(TO,t)}const SO=p("ZodISODuration",(t,e)=>{Gv.init(t,e),V.init(t,e)});function NO(t){return Qz(SO,t)}const EO=(t,e)=>{Zl.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Pb(t,r)},flatten:{value:r=>Ub(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,Ms,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,Ms,2)}},isEmpty:{get(){return t.issues.length===0}}})},Oe=p("ZodError",EO,{Parent:Error}),AO=$a(Oe),xO=Ma(Oe),IO=zn(Oe),CO=On(Oe),jO=Db(Oe),$O=Bb(Oe),MO=Fb(Oe),_O=qb(Oe),ZO=Yb(Oe),UO=Vb(Oe),PO=Hb(Oe),RO=Wb(Oe),G=p("ZodType",(t,e)=>(H.init(t,e),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone(It(e,{checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]})),t.clone=(r,n)=>ut(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>AO(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>IO(t,r,n),t.parseAsync=async(r,n)=>xO(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>CO(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>jO(t,r,n),t.decode=(r,n)=>$O(t,r,n),t.encodeAsync=async(r,n)=>MO(t,r,n),t.decodeAsync=async(r,n)=>_O(t,r,n),t.safeEncode=(r,n)=>ZO(t,r,n),t.safeDecode=(r,n)=>UO(t,r,n),t.safeEncodeAsync=async(r,n)=>PO(t,r,n),t.safeDecodeAsync=async(r,n)=>RO(t,r,n),t.refine=(r,n)=>t.check($T(r,n)),t.superRefine=r=>t.check(MT(r)),t.overwrite=r=>t.check(Xt(r)),t.optional=()=>Ji(t),t.nullable=()=>Xi(t),t.nullish=()=>Ji(Xi(t)),t.nonoptional=r=>NT(t,r),t.array=()=>dT(t),t.or=r=>Ua([t,r]),t.and=r=>mT(t,r),t.transform=r=>Qi(t,vT(r)),t.default=r=>TT(t,r),t.prefault=r=>ST(t,r),t.catch=r=>AT(t,r),t.pipe=r=>Qi(t,r),t.readonly=()=>CT(t),t.describe=r=>{const n=t.clone();return en.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return en.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return en.get(t);const n=t.clone();return en.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),Jl=p("_ZodString",(t,e)=>{_a.init(t,e),G.init(t,e);const r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(sO(...n)),t.includes=(...n)=>t.check(oO(...n)),t.startsWith=(...n)=>t.check(cO(...n)),t.endsWith=(...n)=>t.check(lO(...n)),t.min=(...n)=>t.check(hn(...n)),t.max=(...n)=>t.check(Gl(...n)),t.length=(...n)=>t.check(Kl(...n)),t.nonempty=(...n)=>t.check(hn(1,...n)),t.lowercase=n=>t.check(aO(n)),t.uppercase=n=>t.check(iO(n)),t.trim=()=>t.check(hO()),t.normalize=(...n)=>t.check(uO(...n)),t.toLowerCase=()=>t.check(dO()),t.toUpperCase=()=>t.check(fO()),t.slugify=()=>t.check(pO())}),LO=p("ZodString",(t,e)=>{_a.init(t,e),Jl.init(t,e),t.email=r=>t.check(Iz(DO,r)),t.url=r=>t.check(Mz(FO,r)),t.jwt=r=>t.check(Gz(sT,r)),t.emoji=r=>t.check(_z(qO,r)),t.guid=r=>t.check(Yi(Gi,r)),t.uuid=r=>t.check(Wl(fr,r)),t.uuidv4=r=>t.check(Cz(fr,r)),t.uuidv6=r=>t.check(jz(fr,r)),t.uuidv7=r=>t.check($z(fr,r)),t.nanoid=r=>t.check(Zz(YO,r)),t.guid=r=>t.check(Yi(Gi,r)),t.cuid=r=>t.check(Uz(VO,r)),t.cuid2=r=>t.check(Pz(HO,r)),t.ulid=r=>t.check(Rz(WO,r)),t.base64=r=>t.check(Vz(tT,r)),t.base64url=r=>t.check(Hz(rT,r)),t.xid=r=>t.check(Lz(GO,r)),t.ksuid=r=>t.check(Dz(KO,r)),t.ipv4=r=>t.check(Bz(JO,r)),t.ipv6=r=>t.check(Fz(XO,r)),t.cidrv4=r=>t.check(qz(QO,r)),t.cidrv6=r=>t.check(Yz(eT,r)),t.e164=r=>t.check(Wz(nT,r)),t.datetime=r=>t.check(vO(r)),t.date=r=>t.check(OO(r)),t.time=r=>t.check(kO(r)),t.duration=r=>t.check(NO(r))});function ve(t){return xz(LO,t)}const V=p("ZodStringFormat",(t,e)=>{q.init(t,e),Jl.init(t,e)}),DO=p("ZodEmail",(t,e)=>{Uv.init(t,e),V.init(t,e)}),Gi=p("ZodGUID",(t,e)=>{_v.init(t,e),V.init(t,e)}),fr=p("ZodUUID",(t,e)=>{Zv.init(t,e),V.init(t,e)});function BO(t){return Wl(fr,t)}const FO=p("ZodURL",(t,e)=>{Pv.init(t,e),V.init(t,e)}),qO=p("ZodEmoji",(t,e)=>{Rv.init(t,e),V.init(t,e)}),YO=p("ZodNanoID",(t,e)=>{Lv.init(t,e),V.init(t,e)}),VO=p("ZodCUID",(t,e)=>{Dv.init(t,e),V.init(t,e)}),HO=p("ZodCUID2",(t,e)=>{Bv.init(t,e),V.init(t,e)}),WO=p("ZodULID",(t,e)=>{Fv.init(t,e),V.init(t,e)}),GO=p("ZodXID",(t,e)=>{qv.init(t,e),V.init(t,e)}),KO=p("ZodKSUID",(t,e)=>{Yv.init(t,e),V.init(t,e)}),JO=p("ZodIPv4",(t,e)=>{Kv.init(t,e),V.init(t,e)}),XO=p("ZodIPv6",(t,e)=>{Jv.init(t,e),V.init(t,e)}),QO=p("ZodCIDRv4",(t,e)=>{Xv.init(t,e),V.init(t,e)}),eT=p("ZodCIDRv6",(t,e)=>{Qv.init(t,e),V.init(t,e)}),tT=p("ZodBase64",(t,e)=>{ez.init(t,e),V.init(t,e)}),rT=p("ZodBase64URL",(t,e)=>{rz.init(t,e),V.init(t,e)}),nT=p("ZodE164",(t,e)=>{nz.init(t,e),V.init(t,e)}),sT=p("ZodJWT",(t,e)=>{az.init(t,e),V.init(t,e)}),aT=p("ZodNumber",(t,e)=>{Yl.init(t,e),G.init(t,e),t.gt=(n,s)=>t.check(Hi(n,s)),t.gte=(n,s)=>t.check(Kn(n,s)),t.min=(n,s)=>t.check(Kn(n,s)),t.lt=(n,s)=>t.check(Vi(n,s)),t.lte=(n,s)=>t.check(Gn(n,s)),t.max=(n,s)=>t.check(Gn(n,s)),t.int=n=>t.check(dn(n)),t.safe=n=>t.check(dn(n)),t.positive=n=>t.check(Hi(0,n)),t.nonnegative=n=>t.check(Kn(0,n)),t.negative=n=>t.check(Vi(0,n)),t.nonpositive=n=>t.check(Gn(0,n)),t.multipleOf=(n,s)=>t.check(Wi(n,s)),t.step=(n,s)=>t.check(Wi(n,s)),t.finite=()=>t;const r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null}),iT=p("ZodNumberFormat",(t,e)=>{iz.init(t,e),aT.init(t,e)});function dn(t){return eO(iT,t)}const oT=p("ZodBoolean",(t,e)=>{oz.init(t,e),G.init(t,e)});function Za(t){return tO(oT,t)}const cT=p("ZodUnknown",(t,e)=>{cz.init(t,e),G.init(t,e)});function Ki(){return rO(cT)}const lT=p("ZodNever",(t,e)=>{lz.init(t,e),G.init(t,e)});function uT(t){return nO(lT,t)}const hT=p("ZodArray",(t,e)=>{uz.init(t,e),G.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(hn(r,n)),t.nonempty=r=>t.check(hn(1,r)),t.max=(r,n)=>t.check(Gl(r,n)),t.length=(r,n)=>t.check(Kl(r,n)),t.unwrap=()=>t.element});function dT(t,e){return yO(hT,t,e)}const fT=p("ZodObject",(t,e)=>{dz.init(t,e),G.init(t,e),L(t,"shape",()=>e.shape),t.keyof=()=>Xl(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Ki()}),t.loose=()=>t.clone({...t._zod.def,catchall:Ki()}),t.strict=()=>t.clone({...t._zod.def,catchall:uT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>jb(t,r),t.safeExtend=r=>$b(t,r),t.merge=r=>Mb(t,r),t.pick=r=>Ib(t,r),t.omit=r=>Cb(t,r),t.partial=(...r)=>_b(Ql,t,r[0]),t.required=(...r)=>Zb(eu,t,r[0])});function ne(t,e){const r={type:"object",shape:t??{},...x(e)};return new fT(r)}const pT=p("ZodUnion",(t,e)=>{fz.init(t,e),G.init(t,e),t.options=e.options});function Ua(t,e){return new pT({type:"union",options:t,...x(e)})}const yT=p("ZodIntersection",(t,e)=>{pz.init(t,e),G.init(t,e)});function mT(t,e){return new yT({type:"intersection",left:t,right:e})}const Zs=p("ZodEnum",(t,e)=>{yz.init(t,e),G.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);const r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{const i={};for(const o of n)if(r.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Zs({...e,checks:[],...x(s),entries:i})},t.exclude=(n,s)=>{const i={...e.entries};for(const o of n)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Zs({...e,checks:[],...x(s),entries:i})}});function Xl(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Zs({type:"enum",entries:r,...x(e)})}const gT=p("ZodLiteral",(t,e)=>{mz.init(t,e),G.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function wT(t,e){return new gT({type:"literal",values:Array.isArray(t)?t:[t],...x(e)})}const bT=p("ZodTransform",(t,e)=>{gz.init(t,e),G.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Il(t.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(zr(i,r.value,e));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),r.issues.push(zr(o))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(i=>(r.value=i,r)):(r.value=s,r)}});function vT(t){return new bT({type:"transform",transform:t})}const Ql=p("ZodOptional",(t,e)=>{wz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ji(t){return new Ql({type:"optional",innerType:t})}const zT=p("ZodNullable",(t,e)=>{bz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Xi(t){return new zT({type:"nullable",innerType:t})}const OT=p("ZodDefault",(t,e)=>{vz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function TT(t,e){return new OT({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():$l(e)}})}const kT=p("ZodPrefault",(t,e)=>{zz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ST(t,e){return new kT({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():$l(e)}})}const eu=p("ZodNonOptional",(t,e)=>{Oz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function NT(t,e){return new eu({type:"nonoptional",innerType:t,...x(e)})}const ET=p("ZodCatch",(t,e)=>{Tz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function AT(t,e){return new ET({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const xT=p("ZodPipe",(t,e)=>{kz.init(t,e),G.init(t,e),t.in=e.in,t.out=e.out});function Qi(t,e){return new xT({type:"pipe",in:t,out:e})}const IT=p("ZodReadonly",(t,e)=>{Sz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function CT(t){return new IT({type:"readonly",innerType:t})}const jT=p("ZodCustom",(t,e)=>{Nz.init(t,e),G.init(t,e)});function $T(t,e={}){return mO(jT,t,e)}function MT(t){return gO(t)}const Re=t=>t?JSON.parse(t):{},Pa=ne({key:ve(),type:ve(),config:ze.unknownZ.or(ve().transform(Re))}),tu=Pa.extend({position:ga.xy}),Us=ne({param:ve(),node:ve()}),Ra=ne({source:Us,target:Us}),_T=ne({nodes:Pa.array(),edges:Ra.array()}),ru=ne({nodes:tu.array(),edges:Ra.array()}),nu=ne({raw:ve()}),Pr=BO(),su=Xl(["graph","text"]).or(wT("").transform(()=>"graph")),kn=ne({key:Pr,name:ve(),graph:ru,text:nu,version:ve(),mode:su}),au=kn.partial({key:!0,mode:!0}),ZT="arc",iu=K("arc"),UT=iu(""),PT=(t,e,{convertNumericStrings:r=!0}={})=>{const n=!Array.isArray(t);let s=O.toArray(t);const i=s[0],o=typeof i;let c;return o==="string"&&r&&!isNaN(parseInt(i))&&"number"in e?(c=e.number,s=s.map(l=>parseInt(l))):c=e[o],{single:n,variant:c,normalized:s,actual:t}},ce=(t,e,r,n)=>{if(n){if(r.length===0)throw new Tt(`${t} not found matching ${JSON.stringify(e)}`);if(r.length>1)throw new cn(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${r.length}`)}},RT="sy_arc_set",LT="sy_arc_delete",DT=ne({keys:Pr.array().optional(),names:ve().array().optional(),searchTerm:ve().optional(),limit:dn().optional(),offset:dn().optional(),includeStatus:Za().optional()}),BT=ne({arcs:au.array()}),FT=ne({keys:Pr.array()}),qT=ne({arcs:O.nullableZ(kn)}),YT=ne({arcs:kn.array()}),VT=ne({}),Ps=ne({content:ve()}),HT=ne({key:Pr,includeStatus:Za().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),WT=ne({name:ve(),includeStatus:Za().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e})),ou=Ua([HT,WT]),GT=Ua([ou,DT]);let cu=class{client;streamClient;constructor(t,e){this.client=t,this.streamClient=e}async create(t){const e=Array.isArray(t),r=await w(this.client,"/arc/create",{arcs:O.toArray(t)},BT,YT);return e?r.arcs:r.arcs[0]}async retrieve(t){const e="key"in t||"name"in t,r=await w(this.client,"/arc/retrieve",t,GT,qT);return ce("Arc",t,r.arcs,e),e?r.arcs[0]:r.arcs}async delete(t){await w(this.client,"/arc/delete",{keys:O.toArray(t)},FT,VT)}async openLSP(){return await this.streamClient.stream("/arc/lsp",Ps,Ps)}};const KT=Object.freeze(Object.defineProperty({__proto__:null,Client:cu,DELETE_CHANNEL_NAME:LT,ONTOLOGY_TYPE:ZT,SET_CHANNEL_NAME:RT,TYPE_ONTOLOGY_ID:UT,arcZ:kn,edgeZ:Ra,graphNodeZ:tu,graphZ:ru,handleZ:Us,irNodeZ:Pa,irZ:_T,keyZ:Pr,lspMessageZ:Ps,modeZ:su,newZ:au,ontologyID:iu,singleRetrieveArgsZ:ou,textZ:nu},Symbol.toStringTag,{value:"Module"})),eo="Channel key must be a valid uint32.",D=a.z.uint32().or(a.z.string().refine(t=>!isNaN(Number(t)),{message:eo}).transform(Number).refine(t=>t<Os.MAX_UINT32,{message:eo})),lu=/^[a-zA-Z_][a-zA-Z0-9_]*$/,Ve=a.z.string().min(1,"Name must not be empty").regex(lu,"Name can only contain letters, digits, and underscores, and cannot start with a digit"),uu=["min","max","avg","none"],hu=a.z.enum(uu),La=a.z.object({type:hu,resetChannel:D.optional(),duration:E.z.optional()}),du=lt.statusZ(),fu=a.z.object({channel:D}),JT=lt.statusZ(fu),XT=t=>Ze(Sn(t)),Qt=a.z.object({name:a.z.string(),key:D,dataType:_.z,leaseholder:_e.uint12,index:D,isIndex:a.z.boolean(),internal:a.z.boolean(),virtual:a.z.boolean(),alias:a.z.string().optional(),expression:a.z.string().default(""),status:du.optional(),operations:O.nullableZ(La)}),pu=Qt.extend({key:D.optional(),name:Ve,leaseholder:_e.uint12.optional(),index:D.optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().default(!1),virtual:a.z.boolean().default(!1),expression:a.z.string().default(""),operations:O.nullableZ(La).optional()}),Ct=a.z.union([_e.toArray(D),_e.toArray(Ve),_e.toArray(Qt).transform(t=>t.map(e=>e.key))]),Sn=K("channel"),QT=Sn(0),ek=/[a-zA-Z0-9_]/,tk=(t,e=!1)=>{if(t==="")return e?"_":"";if(t.match(lu))return t;let r="";for(const n of t)n.match(ek)?r+=n:r+="_";return r[0].match(/^\d/)&&(r=`_${r}`),r},rk=new Error("request for lock canceled");var nk=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(h){try{u(n.next(h))}catch(f){o(f)}}function l(h){try{u(n.throw(h))}catch(f){o(f)}}function u(h){h.done?i(h.value):s(h.value).then(c,l)}u((n=n.apply(t,e||[])).next())})};class sk{constructor(e,r=rk){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,s)=>{const i={resolve:n,reject:s,weight:e,priority:r},o=yu(this._queue,c=>r<=c.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return nk(this,arguments,void 0,function*(r,n=1,s=0){const[i,o]=yield this.acquire(n,s);try{return yield r(i)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),ak(this._weightedWaiters[e-1],{resolve:n,priority:r})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const s=n.findIndex(i=>i.priority<=e);(s===-1?n:n.splice(0,s)).forEach((i=>i.resolve()))}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function ak(t,e){const r=yu(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function yu(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var ik=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(h){try{u(n.next(h))}catch(f){o(f)}}function l(h){try{u(n.throw(h))}catch(f){o(f)}}function u(h){h.done?i(h.value):s(h.value).then(c,l)}u((n=n.apply(t,e||[])).next())})};class ok{constructor(e){this._semaphore=new sk(1,e)}acquire(){return ik(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const ht=rl.keyZ,Rr=rl.labelZ,ck="labeled_by",lk="sy_label_set",uk="sy_label_delete",mu=Rr.extend({key:ht.optional()}),hk=a.object({labels:mu.array()}),dk=a.object({labels:Rr.array()}),fk=a.object({keys:ht.array()}),gu=a.object({id:F,labels:ht.array(),replace:a.boolean().optional()}),pk=gu.omit({replace:!0}),Jn=a.object({}),yk=a.object({keys:ht.array().optional(),names:a.string().array().optional(),for:F.optional(),searchTerm:a.string().optional(),offset:a.int().optional(),limit:a.int().optional()}),mk=a.object({key:ht}).transform(({key:t})=>({keys:[t]})),gk=a.union([mk,yk]),wk=a.object({labels:O.nullableZ(Rr)});let wu=class{type="label";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await w(this.client,"/label/retrieve",t,gk,wk);return ce("Label",t,r.labels,e),e?r.labels[0]:r.labels}async label(t,e,r={}){await w(this.client,"/label/set",{id:t,labels:e,replace:r.replace},gu,Jn)}async remove(t,e){await w(this.client,"/label/remove",{id:t,labels:e},pk,Jn)}async create(t){const e=Array.isArray(t),r=await w(this.client,"/label/create",{labels:O.toArray(t)},hk,dk);return e?r.labels:r.labels[0]}async delete(t){await w(this.client,"/label/delete",{keys:O.toArray(t)},fk,Jn)}};const bu=K("label"),bk=bu(""),vk=Object.freeze(Object.defineProperty({__proto__:null,Client:wu,DELETE_CHANNEL_NAME:uk,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:ck,SET_CHANNEL_NAME:lk,TYPE_ONTOLOGY_ID:bk,keyZ:ht,labelZ:Rr,newZ:mu,ontologyID:bu},Symbol.toStringTag,{value:"Module"})),X=a.z.uuid(),Da=a.z.string().min(1),Lr=a.z.object({key:X,name:Da,timeRange:B.z.refine(({isValid:t})=>t,{error:"Time range start time must be before or equal to time range end time"}).refine(({end:t})=>t.valueOf()<=Os.MAX_INT64,{error:"Time range end time must be less than or equal to the maximum value of an int64"}).refine(({start:t})=>t.valueOf()>=Os.MIN_INT64,{error:"Time range start time must be greater than or equal to the minimum value of an int64"}),color:a.z.string().optional(),labels:Rr.array().or(a.z.null().transform(()=>{})).optional(),get parent(){return Lr.optional().nullable().transform(t=>t===void 0?null:t)}}),vu=Lr.omit({parent:!0,labels:!0}).partial({key:!0}),zk=a.z.object({nodeKey:_e.uint12.optional(),keys:D.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),rangeKey:X.optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),dataTypes:_.z.array().optional(),notDataTypes:_.z.array().optional(),virtual:a.z.boolean().optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().optional(),legacyCalculated:a.z.boolean().optional()}),Ok=a.z.object({channels:O.nullableZ(Qt)}),Ne=t=>(Array.isArray(t)&&t.length>0&&typeof t[0]=="object"?t=t.map(e=>e.key):typeof t=="object"&&"key"in t&&(t=[t.key]),PT(t,{number:"keys",string:"names"}));class Ba{client;constructor(e){this.client=e}async retrieve(e,r){if(!Array.isArray(e)&&typeof e=="object")return await this.execute(e);const n=Ne(e),{variant:s}=n;let{normalized:i}=n;return s==="keys"&&i.indexOf(0)!==-1&&(i=i.filter(o=>o!==0)),i.length===0?[]:await this.execute({[s]:i,...r})}async execute(e){return(await w(this.client,"/channel/retrieve",e,zk,Ok)).channels}}class Fa{cache;namesToKeys;wrapped;constructor(e){this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async retrieve(e,r){if(!Array.isArray(e)&&typeof e=="object")return await this.wrapped.retrieve(e);const{normalized:n}=Ne(e),s=[],i=[];if(n.forEach(c=>{const l=this.get(c);l!=null?s.push(...l):i.push(c)}),i.length===0)return s;const o=await this.wrapped.retrieve(i,r);return this.set(o),s.concat(o)}delete(e){const{variant:r,normalized:n}=Ne(e);r==="names"?n.forEach(s=>{const i=this.namesToKeys.get(s);i!=null&&(i.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(s))}):n.forEach(s=>{const i=this.cache.get(s);i!=null&&(this.cache.delete(s),this.namesToKeys.delete(i.name))})}rename(e,r){e.forEach((n,s)=>{const i=r[s],o=this.cache.get(n);if(o==null)return;this.cache.delete(n);const c=this.namesToKeys.get(o.name);c!=null&&(c.delete(n),c.size===0&&this.namesToKeys.delete(o.name)),o.name=i,this.cache.set(n,o);const l=this.namesToKeys.get(i);l==null?this.namesToKeys.set(i,new Set([n])):l.add(n)})}set(e){e.forEach(r=>{this.cache.set(r.key,r);const n=this.namesToKeys.get(r.name);n==null?this.namesToKeys.set(r.name,new Set([r.key])):n.add(r.key)})}get(e){if(typeof e=="number"){const s=this.cache.get(e);return s==null?void 0:[s]}const r=this.namesToKeys.get(e);if(r==null)return;const n=[];if(r.forEach(s=>{const i=this.cache.get(s);i!=null&&n.push(i)}),n.length!==0)return n}}class zu{mu=new ok;requests=new Map;wrapped;debouncedRun;constructor(e,r){this.wrapped=e,this.debouncedRun=eg(()=>{this.run()},r)}async retrieve(e){if(!Array.isArray(e)&&typeof e=="object")return await this.wrapped.retrieve(e);const{normalized:r,variant:n}=Ne(e);return n==="names"?await this.wrapped.retrieve(r):await new Promise((s,i)=>{this.mu.runExclusive(()=>{this.requests.set(r,{resolve:s,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((r,n)=>n.forEach(s=>e.add(s)));try{const r=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,s)=>n.resolve(r.filter(i=>s.includes(i.key))))}catch(r){this.requests.forEach(n=>n.reject(r))}finally{this.requests.clear()}})}}const Ou=async(t,e)=>{const{normalized:r}=Ne(e),n=await t.retrieve(r),s=[];if(r.forEach(i=>{n.find(o=>o.name===i||o.key===i)==null&&s.push(i)}),s.length>0)throw new ot(`Could not find channels: ${JSON.stringify(s)}`);return n},Tk="sy_channel_set",kk="sy_channel_delete";class Rs{_frameClient;key;name;dataType;leaseholder;index;isIndex;internal;alias;virtual;expression;operations;status;constructor({dataType:e,name:r,leaseholder:n=0,key:s=0,isIndex:i=!1,index:o=0,internal:c=!1,virtual:l=!1,frameClient:u,alias:h,status:f,expression:d="",operations:z=[]}){this.key=D.parse(s),this.name=r,this.dataType=new _(e),this.leaseholder=n,this.index=D.parse(o),this.isIndex=i,this.internal=c,this.alias=h,this.virtual=l,this.expression=d,this.operations=z,f!=null&&(this.status=lt.create(f)),this._frameClient=u??null}get framer(){if(this._frameClient==null)throw new W("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Qt.parse({key:this.key,name:this.name,dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal,virtual:this.virtual,expression:this.expression,status:this.status,operations:this.operations})}get isCalculated(){return ku(this.payload)}get ontologyID(){return Sn(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,r){return await this.framer.write(e,this.key,r)}}const Sk=a.z.object({}),Nk=a.z.object({group:bn});let Tu=class{frameClient;client;retriever;writer;constructor(t,e,r,n){this.frameClient=t,this.retriever=e,this.client=r,this.writer=n}async create(t,e={}){const{retrieveIfNameExists:r=!1}=e,n=!Array.isArray(t);let s=O.toArray(t),i=[];if(r){const o=await this.retriever.retrieve(s.map(l=>l.name)),c=new Set(o.map(l=>l.name));s=s.filter(l=>!c.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.writer.create(s))),n?i[0]:i}async retrieve(t,e){if(typeof t=="object"&&!Array.isArray(t))return this.sugar(await this.retriever.retrieve(t));const r=!Array.isArray(t),n=this.sugar(await this.retriever.retrieve(t,e));return ce("channel",t,n,r),r?n[0]:n}async delete(t){const{normalized:e,variant:r}=Ne(t);return r==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(O.toArray(t),O.toArray(e))}createDebouncedBatchRetriever(t=10){return new Fa(new zu(new Ba(this.client),t))}sugar(t){const{frameClient:e}=this;return Array.isArray(t)?t.map(r=>new Rs({...r,frameClient:e})):new Rs({...t,frameClient:e})}async retrieveGroup(){return(await w(this.client,"/channel/retrieve-group",{},Sk,Nk)).group}};const ku=({virtual:t,expression:e})=>t&&e!=="",Ek=a.z.object({channels:pu.array()}),Ak=a.z.object({channels:Qt.array()}),xk=a.z.object({keys:D.array().optional(),names:Ve.array().optional()}),Ik=a.z.object({}),Ck=a.z.object({keys:D.array(),names:Ve.array()}),jk=a.z.object({});let Su=class{client;cache;constructor(t,e){this.client=t,this.cache=e}async create(t){const{channels:e}=await w(this.client,"/channel/create",{channels:t.map(r=>({...r,dataType:r.dataType}))},Ek,Ak);return this.cache.set(e),e}async delete(t){const e=D.array().parse(t.keys??[]);await w(this.client,"/channel/delete",t,xk,Ik),e.length>0&&this.cache.delete(e),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await w(this.client,"/channel/rename",{keys:t,names:e},Ck,jk),this.cache.rename(t,e)}};const $k=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Fa,Channel:Rs,Client:Tu,ClusterRetriever:Ba,DELETE_CHANNEL_NAME:kk,DebouncedBatchRetriever:zu,OPERATION_TYPES:uu,SET_CHANNEL_NAME:Tk,TYPE_ONTOLOGY_ID:QT,Writer:Su,analyzeParams:Ne,calculationStatusDetailsZ:fu,calculationStatusZ:JT,escapeInvalidName:tk,isCalculated:ku,keyZ:D,nameZ:Ve,newZ:pu,ontologyID:Sn,operationType:hu,operationZ:La,paramsZ:Ct,payloadZ:Qt,retrieveRequired:Ou,statusKey:XT,statusZ:du},Symbol.toStringTag,{value:"Module"})),Mk=a.z.object({username:a.z.string(),password:a.z.string()}),_k=a.z.object({token:a.z.string(),user:Ur}),to="/auth/login",Zk=3,Uk=a.z.object({username:a.z.string(),password:a.z.string(),newPassword:a.z.string().min(1)}),Pk=a.z.object({}),Rk=[Cs,js];let Lk=class{client;credentials;authState={authenticated:!1};authenticating;retryCount;constructor(t,e){this.client=t,this.credentials=e,this.retryCount=0}get authenticated(){return this.authState.authenticated}get user(){return this.authState.authenticated?this.authState.user:void 0}get token(){return this.authState.authenticated?this.authState.token:void 0}async retrieveUser(){this.authState.authenticated||await this.authenticating;const{authState:t}=this;if(!t.authenticated)throw new Error("Authentication failed: user not available");return t.user}async changePassword(t){if(!this.authenticated)throw new Error("Not authenticated");await w(this.client,"/auth/change-password",{username:this.credentials.username,password:this.credentials.password,newPassword:t},Uk,Pk),this.credentials.password=t}middleware(){const t=async(e,r)=>{if(!this.authenticated&&!e.target.endsWith(to)){this.authenticating??=new Promise((o,c)=>{this.client.send(to,this.credentials,Mk,_k).then(([l,u])=>{if(u!=null)return o(u);if(l==null)return o(new Error("No response from login"));this.authState={authenticated:!0,user:l.user,token:l.token},o(null)}).catch(c)});const i=await this.authenticating;if(i!=null)return[e,i]}e.params.Authorization=`Bearer ${this.token}`;const[n,s]=await r(e);return Rk.some(i=>i.matches(s))&&this.retryCount<Zk?(this.authState={authenticated:!1},this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,s])};return t}};const Dk=a.z.enum(["disconnected","connecting","connected","failed"]),Bk=a.z.object({status:Dk,error:a.z.instanceof(Error).optional(),message:a.z.string().optional(),clusterKey:a.z.string(),clientVersion:a.z.string(),clientServerCompatible:a.z.boolean(),nodeVersion:a.z.string().optional()}),Fk=a.z.object({clusterKey:a.z.string(),nodeVersion:a.z.string().optional()}),qk=a.z.void(),ro={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.50.0"},no=(t,e,r)=>{const n=r?"Core":"client";return`Synnax Core version ${t!=null?`${t} `:""}is too ${r?"old":"new"} for client version ${e}.
|
|
41
|
-
This may cause compatibility issues. We recommend updating the ${n}. For more information, see
|
|
42
|
-
https://docs.synnaxlabs.com/reference/client/resources/troubleshooting#old-${n}-version`};class Ls{static DEFAULT=ro;_state;pollFrequency=E.seconds(30);client;name;interval;clientVersion;onChangeHandlers=[];static connectionStateZ=Bk;versionWarned=!1;constructor(e,r=E.seconds(30),n,s){this._state={...ro},this.client=e,this.pollFrequency=r,this.clientVersion=n,this.name=s,this.check(),this.start()}stop(){this.interval!=null&&clearInterval(this.interval)}async check(){const e=this._state.status;try{const r=await w(this.client,"/connectivity/check",void 0,qk,Fk),n=r.nodeVersion,s=this.clientVersion,i=this.versionWarned;n==null?(this._state.clientServerCompatible=!1,i||(console.warn(no(null,s,!0)),this.versionWarned=!0)):Ai.versionsEqual(s,n,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,i||(console.warn(no(n,s,Ai.semVerNewer(s,n))),this.versionWarned=!0)),this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=r.clusterKey,this._state.nodeVersion=r.nodeVersion,this._state.clientVersion=this.clientVersion}catch(r){this._state.status="failed",this._state.error=r,this._state.message=this.state.error?.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(r=>r(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}start(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}}const Yk=a.z.object({keys:D.array().optional(),bounds:B.z,names:Ve.array().optional()}),Vk=a.z.object({});class Hk{client;constructor(e){this.client=e}async delete(e){await w(this.client,"/frame/delete",e,Yk,Vk)}}const so=t=>{const e=O.toArray(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},ao=(t,e)=>{const r=O.toArray(t);if(r.length===e.length)return;const n=so(t);throw so===null?new W("[Frame] - channel keys or names must be provided when constructing a frame."):new W(`[Frame] - ${n}s and series must be the same length.
|
|
43
|
-
Got ${r.length} ${n}s and ${e.length} series.`)};let ue=class ft{columns=[];series=[];constructor(e=[],r=[]){if(e instanceof ft){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,s)=>this.push(s,...O.toArray(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e;n.series??=[],n.keys??=[];const s=n.series.map(i=>Nu(i));ao(n.keys,s),n.keys.forEach((i,o)=>this.push(i,s[o]))}else Object.entries(e).forEach(([n,s])=>{const i=parseInt(n);if(!isNaN(i))return this.push(i,...O.toArray(s));this.push(n,...O.toArray(s))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=O.toArray(r),s=O.toArray(e);ao(s,n),n.forEach((i,o)=>this.push(s[o],i));return}throw new W(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
|
|
44
|
-
payload, a list of lazy series, a lazy array, a map, or a record keyed by channel
|
|
45
|
-
name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new ie("colType is not key");return this.columns??[]}get uniqueKeys(){return vi.unique(this.keys)}get names(){if(this.colType==="key")throw new ie("colType is not name");return this.columns??[]}get uniqueNames(){return vi.unique(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Eu(e)),keys:[...this.keys]}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(r=>r.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return B.ZERO;const n=C.min(...this.series.map(i=>i.timeRange.start)),s=C.max(...this.series.map(i=>i.timeRange.end));return new B(n,s)}const r=this.get(e);return r==null?B.ZERO:r.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(r=>e.includes(r)):new jm(this.series.filter((r,n)=>this.columns[n]===e))}push(e,...r){if(e instanceof ft){if(e.colType!=null&&this.colType!==null&&e.colType!==this.colType)throw new W("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...r),typeof e=="string"&&this.colType==="key")throw new W("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new W("keyVariant must match");this.columns.push(...Array.from({length:r.length},()=>e))}}concat(e){return new ft([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const r=new ft;return this.forEach((n,s,i)=>r.push(...e(n,s,i))),r}mapFilter(e){const r=new ft;return this.forEach((n,s,i)=>{const[o,c,l]=e(n,s,i);l&&r.push(o,c)}),r}forEach(e){this.columns.forEach((r,n)=>{const s=this.series[n];e(r,s,n)})}forEachUnique(e){this.uniqueColumns.forEach((r,n)=>e(r,this.get(r),n))}at(e,r=!1){const n={};return this.uniqueColumns.forEach(s=>{n[s]=this.get(s).at(e,r)}),n}filter(e){const r=new ft;return this.columns.forEach((n,s)=>{const i=this.series[s];e(n,i,s)&&r.push(n,i)}),r}get byteLength(){return new qt(this.series.reduce((e,r)=>e.add(r.byteLength),qt.ZERO))}get digest(){const e={};return this.keys.forEach((r,n)=>{const s=this.series[n].digest;r in e?e[r].push(s):e[r]=[s]}),e}get length(){return this.series.reduce((e,r)=>e+r.length,0)}toString(){let e=`Frame{
|
|
46
|
-
`;return this.uniqueColumns.forEach(r=>{e+=` ${r}: ${this.get(r).series.map(n=>n.toString()).join(",")}
|
|
47
|
-
`}),e+="}",e}};const Nn=a.z.object({keys:a.z.union([a.z.null().transform(()=>[]),a.z.number().array().default([])]),series:a.z.union([a.z.null().transform(()=>[]),st.crudeZ.array().default([])])}),Nu=t=>{const{dataType:e,data:r,timeRange:n,alignment:s}=t;return new st({data:r,dataType:e,timeRange:n,glBufferUsage:"static",alignment:s})},Eu=t=>({timeRange:t.timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment});var Me=(t=>(t[t.Open=0]="Open",t[t.Write=1]="Write",t[t.Commit=2]="Commit",t[t.SetAuthority=3]="SetAuthority",t))(Me||{});const io=t=>t.data.byteLength/t.dataType.density.valueOf(),Wk=t=>{const{keys:e,series:r}=t;e.forEach((n,s)=>{r[s].key=n}),r.sort((n,s)=>n.key-s.key),e.sort((n,s)=>n-s),r.forEach(n=>delete n.key)},oo=5,co=4,lo=3,uo=2,ho=1,fo=0,xe=_.TIMESTAMP.density.valueOf(),Je=8,Xe=4,Xn=4,Qn=4,Gk=1;class Au{contentType="application/sy-framer";states=new Map;currState;seqNum=0;constructor(e=[],r=[]){(e.length>0||r.length>0)&&this.update(e,r)}update(e,r){this.seqNum++;const n={keys:e,keyDataTypes:new Map,hasVariableDataTypes:!1};e.forEach((s,i)=>{const o=r[i];n.keyDataTypes.set(s,o),o.isVariable&&(n.hasVariableDataTypes=!0)}),n.keys.sort(),this.states.set(this.seqNum,n),this.currState=n}throwIfNotUpdated(e){if(this.seqNum<1)throw new W(`
|
|
48
|
-
The codec has not been updated with a list of channels and data types.
|
|
49
|
-
Please call the update method before calling ${e}.
|
|
50
|
-
`)}encode(e,r=0){this.throwIfNotUpdated("encode");let n=e;e!=null&&typeof e=="object"&&"toPayload"in e&&(n=e.toPayload()),Wk(n);let s=-1,i,o,c,l=r+Gk+Qn,u=!this.currState?.hasVariableDataTypes,h=!0,f=!0,d=!0,z=!0,I=!0;n.keys.length!==this.currState?.keys.length&&(d=!1,l+=n.keys.length*Xn),n.series.forEach((S,U)=>{const P=io(S),de=n.keys[U],fe=this.currState?.keyDataTypes.get(de);if(fe==null)throw new W(`Channel ${de} was not provided in the list of channels when opening the writer`);if(!fe.equals(S.dataType))throw new W(`Series data type of ${S.dataType.toString()} does not match the data type of ${fe.toString()} for channel ${de}`);if(l+=S.data.byteLength,s===-1){s=P,i=S.timeRange?.start,o=S.timeRange?.end,c=BigInt(S.alignment??0n);return}s!==P&&(u=!1),(i?.valueOf()!==S.timeRange?.start.valueOf()||o?.valueOf()!==S.timeRange?.end.valueOf())&&(h=!1),c!==BigInt(S.alignment??0)&&(z=!1)}),f=h&&i==null&&o==null,I=z&&(c===void 0||c===0n),u?l+=Xe:l+=n.keys.length*Xe,f||(h?l+=xe*2:l+=n.keys.length*xe*2),I||(z?l+=Je:l+=n.keys.length*Je);const j=new Uint8Array(l),b=new DataView(j.buffer);let v=r;return j[v]=Number(I)<<oo|Number(z)<<co|Number(u)<<lo|Number(h)<<uo|Number(f)<<ho|Number(d)<<fo,v++,b.setUint32(v,this.seqNum,!0),v+=Qn,u&&(b.setUint32(v,s,!0),v+=Xe),h&&!f&&(b.setBigUint64(v,i?.valueOf()??0n,!0),b.setBigUint64(v,o?.valueOf()??0n,!0),v+=xe*2),z&&!I&&(b.setBigUint64(v,c??0n,!0),v+=Je),n.series.forEach((S,U)=>{if(d||(b.setUint32(v,n.keys[U],!0),v+=Xn),!u){let P=S.data.byteLength;S.dataType.isVariable||(P=io(S)),b.setUint32(v,P,!0),v+=Xe}j.set(new Uint8Array(S.data),v),v+=S.data.byteLength,!h&&!f&&(b.setBigUint64(v,S.timeRange?.start.valueOf()??0n,!0),b.setBigUint64(v,S.timeRange?.end.valueOf()??0n,!0),v+=xe*2),!z&&!I&&(b.setBigUint64(v,S.alignment??0n,!0),v+=Je)}),j}decode(e,r=0){this.throwIfNotUpdated("decode");const n=e instanceof Uint8Array?e:new Uint8Array(e),s={keys:[],series:[]};let i=r,o=0,c=0,l,u,h;const f=new DataView(n.buffer,n.byteOffset,n.byteLength),d=!!(n[i]>>oo&1),z=!!(n[i]>>co&1),I=!!(n[i]>>lo&1),j=!!(n[i]>>uo&1),b=!!(n[i]>>ho&1),v=!!(n[i]>>fo&1);i++;const S=f.getUint32(i,!0);i+=Qn;const U=this.states.get(S);if(U==null)return s;if(I){if(i+Xe>f.byteLength)return s;o=f.getUint32(i,!0),i+=Xe}if(j&&!b){if(i+xe>f.byteLength)return s;l=new C(f.getBigUint64(i,!0)),i+=xe,u=new C(f.getBigUint64(i,!0)),i+=xe}if(z&&!d){if(i+Je>f.byteLength)return s;h=f.getBigUint64(i,!0),i+=Je}return v&&(s.keys=[...U.keys]),U.keys.forEach((P,de)=>{if(!v){if(i>=f.byteLength||f.getUint32(i,!0)!==P)return;i+=Xn,s.keys.push(P)}const fe=U.keyDataTypes.get(P);if(c=0,I)c=o;else{if(i+Xe>f.byteLength)return;c=f.getUint32(i,!0),i+=Xe}let pe=c;if(fe.isVariable||(pe*=fe.density.valueOf()),i+pe>f.byteLength){s.keys.splice(de,1);return}const De={dataType:fe,data:n.slice(i,i+pe).buffer};if(i+=pe,!j&&!b){if(i+xe*2>f.byteLength)return;const bd=f.getBigUint64(i,!0);i+=xe;const vd=f.getBigUint64(i,!0);i+=xe,De.timeRange=new B({start:bd,end:vd})}else b?De.timeRange=new B({start:0n,end:0n}):De.timeRange=new B({start:l?.valueOf()??0n,end:u?.valueOf()??0n});if(!z&&!d){if(i+Je>f.byteLength)return;h=f.getBigUint64(i,!0),i+=Je,De.alignment=h}else d?De.alignment=0n:De.alignment=h;s.series.push(De)}),s}}const qa=254,Kk=new Uint8Array([qa]),Jk=255,Xk=new Uint8Array([Jk]),xu="application/sy-framer";class Qk{contentType=xu;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=Nt.JSON_CODEC}encode(e){const r=e;if(r.type=="close"||r.payload?.command!=Me.Write){const s=this.lowPerfCodec.encode(r),i=new Uint8Array({length:s.byteLength+1});return i.set(Kk,0),i.set(new Uint8Array(s),1),i}const n=this.base.encode(r.payload?.frame,1);return n.set(Xk,0),n}decode(e,r){if(new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===qa)return this.lowPerfCodec.decode(e.slice(1),r);const n={type:"data"},s=this.base.decode(e,1);return n.payload={command:Me.Write,frame:s},n}}class eS{contentType=xu;base;lowPerfCodec;constructor(e){this.base=e,this.lowPerfCodec=Nt.JSON_CODEC}encode(e){return this.lowPerfCodec.encode(e)}decode(e,r){return new DataView(e instanceof Uint8Array?e.buffer:e).getUint8(0)===qa?this.lowPerfCodec.decode(e.slice(1),r):{type:"data",payload:{frame:this.base.decode(e,1)}}}}class En{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=new Set,this.codec=new Au}static async open(e,r){const n=new En(e);return await n.update(r),n}async update(e){const{variant:r,normalized:n}=Ne(e),s=await this.retriever.retrieve(n),i=s.map(c=>c.key);if(zi.uniqueUnorderedPrimitiveArrays(Array.from(this.keys),i)===zi.EQUAL)return!1;if(this.codec.update(i,s.map(c=>c.dataType)),r==="keys")return this.adapter=null,this.keys=new Set(n),!0;const o=new Map;return this.adapter=o,n.forEach(c=>{const l=s.find(u=>u.name===c);if(l==null)throw new Error(`Channel ${c} not found`);o.set(l.key,l.name)}),this.keys=new Set(this.adapter.keys()),!0}adapt(e){if(this.adapter==null){let n=!1;return e.forEach(s=>{this.keys.has(s)||(n=!0)}),n?e.filter(s=>this.keys.has(s)):e}const r=this.adapter;return e.mapFilter((n,s)=>{if(typeof n=="number"){const i=r.get(n);return i==null?[n,s,!1]:[i,s,!0]}return[n,s,!0]})}}class Ya{adapter;retriever;keys;codec;constructor(e){this.retriever=e,this.adapter=null,this.keys=[],this.codec=new Au}static async open(e,r){const n=new Ya(e);return await n.update(r),n}async adaptParams(e){const r=Ct.parse(e);return await Promise.all(r.map(async n=>await this.adaptToKey(n)))}async update(e){const r=await Ou(this.retriever,e),n=r.map(l=>l.key),s=new Set(this.keys),i=new Set(n),o=!i.isSubsetOf(s),c=!s.isSubsetOf(i);return o||c?(this.adapter=new Map(r.map(l=>[l.name,l.key])),this.keys=n,this.codec.update(this.keys,r.map(l=>l.dataType)),!0):!1}async fetchChannel(e){const r=await this.retriever.retrieve(e);if(r.length===0)throw new Error(`Channel ${JSON.stringify(e)} not found`);return r[0]}async adaptToKey(e){return typeof e=="number"?e:(await this.fetchChannel(e)).key}encode(e){return this.codec.encode(e.toPayload())}async adapt(e,r){if(typeof e=="string"||typeof e=="number"){if(r==null)throw new W(`
|
|
51
|
-
Received a single channel name or key but no series.
|
|
52
|
-
`);if(Array.isArray(r)){if(r.some(l=>l instanceof st||Array.isArray(l)))throw new W(`
|
|
53
|
-
Received a single channel name or key but multiple series.
|
|
54
|
-
`);r=r}const o=await this.fetchChannel(e),c=new st({data:r,dataType:o.dataType});return new ue(o.key,c)}if(Array.isArray(e)){if(r==null)throw new W(`
|
|
55
|
-
Received an array of channel names or keys but no series.
|
|
56
|
-
`);if(!Array.isArray(r))throw new W(`
|
|
57
|
-
Received an array of channel names or keys but no array of series.
|
|
58
|
-
`);const o=[],c=[];for(let l=0;l<e.length;l++){const u=await this.fetchChannel(e[l]);if(l>=r.length)throw new W(`
|
|
59
|
-
Received an array of channel names or keys but not enough series.
|
|
60
|
-
`);const h=new st({data:r[l],dataType:u.dataType});o.push(u.key),c.push(h)}return new ue(o,c)}if(e instanceof ue||e instanceof Map){const o=new ue(e);if(this.adapter==null)return o;const c=o.columns.map(l=>{const u=typeof l=="string"?this.adapter?.get(l):l;if(u==null)throw new W(`
|
|
61
|
-
Channel ${l} was not provided in the list of channels when opening the writer
|
|
62
|
-
`);return u});return new ue(c,o.series)}const n=[],s=[],i=Object.entries(e);for(let o=0;o<i.length;o++){const[c,l]=i[o],u=await this.fetchChannel(c),h=new st({data:l,dataType:u.dataType});n.push(u.key),s.push(h)}return new ue(n,s)}}class Iu{name;stream;constructor(e,r){this.stream=r,this.name=e}async receive(){const[e,r]=await this.stream.receive();if(r!=null)throw r;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,r]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on ${JSON.stringify(e)} closure.
|
|
63
|
-
Please report this error to the Synnax team.`),r!=null){if(Ee.matches(r))return;throw r}}}closeSend(){this.stream.closeSend()}send(e){const r=this.stream.send(e);if(r!=null)throw r}}const fn=new E(-1);var Va=(t=>(t[t.Open=0]="Open",t[t.Next=1]="Next",t[t.Prev=2]="Prev",t[t.SeekFirst=3]="SeekFirst",t[t.SeekLast=4]="SeekLast",t[t.SeekLE=5]="SeekLE",t[t.SeekGE=6]="SeekGE",t[t.Valid=7]="Valid",t[t.Error=8]="Error",t))(Va||{}),Cu=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(Cu||{});const tS=a.z.object({command:a.z.enum(Va),span:E.z.optional(),bounds:B.z.optional(),stamp:C.z.optional(),keys:D.array().optional(),chunkSize:a.z.number().optional(),downsampleFactor:a.z.int().optional()}),rS=a.z.object({variant:a.z.enum(Cu),ack:a.z.boolean(),command:a.z.enum(Va),error:He.payloadZ.optional().nullable(),frame:Nn.optional()});class Dr{stream;adapter;value;constructor(e,r){this.stream=new Iu("Iterator",e),this.value=new ue,this.adapter=r}static async _open(e,r,n,s,i={}){const o=await En.open(n,r),c=await s.stream("/frame/iterate",tS,rS),l=new Dr(c,o);return await l.execute({command:0,keys:Array.from(o.keys),bounds:new B(e),chunkSize:i.chunkSize??1e5,downsampleFactor:i.downsampleFactor??1}),l}async next(e=fn){return await this.execute({command:1,span:new E(e)})}async prev(e=fn){return await this.execute({command:2,span:new E(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new C(e)})}async seekGE(e){return await this.execute({command:6,stamp:new C(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new nS(this)}async execute(e){for(this.stream.send(e),this.value=new ue;;){const r=await this.stream.receive();if(r.variant===1)return r.ack;this.value.push(this.adapter.adapt(new ue(r.frame)))}}}class nS{iter;open=!1;constructor(e){this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}class ju{retriever;streamClient;constructor(e,r){this.retriever=e,this.streamClient=r}async read(e){const{channels:r,timeRange:n,channelNames:s,iteratorConfig:i}=e,o=await this.retriever.retrieve(r),c=new Set;o.forEach(h=>{c.add(h.key),h.index!==0&&c.add(h.index)});const l=Array.from(c).filter(h=>!o.some(f=>f.key===h));if(l.length>0){const h=await this.retriever.retrieve(l);o.push(...h)}const u=await Dr._open(n,Array.from(c),this.retriever,this.streamClient,i);return sS({iterator:u,channelPayloads:o,headers:s})}}const sS=({iterator:t,channelPayloads:e,headers:r})=>{const n=Ug.getOS()==="Windows"?`\r
|
|
64
|
-
`:`
|
|
65
|
-
`,s=new TextEncoder;let i=!1,o=!1;const c=aS(e),{columns:l,columnsByIndexKey:u,emptyGroupStrings:h}=iS(e,c,r);let f=[],d=0,z=[];const I=b=>{for(const[v]of c){const S=b.get(v);if(S.length===0)continue;const U=(u.get(v)??[]).map(P=>b.get(P.key));for(let P=0;P<S.length;P++){const de=S.at(P,!0),fe=U.map(pe=>Ei.formatValue(pe.at(P,!0)));z.push({time:de,values:fe,indexKey:v})}}},j=(b,v=!1)=>{z.length>0&&(z.sort((P,de)=>Number(P.time-de.time)),d>0&&(f=f.slice(d),d=0),f=oS(f,z),z=[]);const S=[],U=f.length;for(;d<U&&S.length<b;){const P=f[d].time;if(!v&&f[U-1].time===P)break;const de=new Map;for(;d<U&&f[d].time===P;){const pe=f[d++];de.set(pe.indexKey,pe)}const fe=[];for(const[pe]of c){const De=de.get(pe);fe.push(De?.values.join(",")??h.get(pe)??"")}S.push(fe.join(","))}return S};return new ReadableStream({async pull(b){try{if(o||(await t.seekFirst(),o=!0),!i){const S=l.map(U=>Ei.formatValue(U.header)).join(",");b.enqueue(s.encode(`${S}${n}`)),i=!0}f.length-d+z.length<po&&await t.next()&&I(t.value);const v=j(po);if(v.length>0&&b.enqueue(s.encode(`${v.join(n)}${n}`)),f.length-d===0||z.length===0){if(!await t.next()){const S=j(1/0,!0);S.length>0&&b.enqueue(s.encode(`${S.join(n)}${n}`)),await t.close(),b.close();return}I(t.value)}}catch(v){await t.close(),b.error(v)}},async cancel(){await t.close()}})},aS=t=>{const e=new Map;for(const r of t){if(r.index===0)continue;let n=e.get(r.index);n==null&&(n=[r.index],e.set(r.index,n)),!r.isIndex&&!n.includes(r.key)&&n.push(r.key)}return e},iS=(t,e,r)=>{const n=new Map(t.map(c=>[c.key,c])),s=[],i=new Map,o=new Map;for(const[c,l]of e){const u=[];for(const h of l){const f=n.get(h);if(f==null)throw new ie(`Channel ${h} not found`);const d={key:h,header:r?.[h]??r?.[f.name]??f.name};s.push(d),u.push(d)}i.set(c,u),o.set(c,",".repeat(u.length-1))}return{columns:s,columnsByIndexKey:i,emptyGroupStrings:o}},oS=(t,e)=>{const r=[];let n=0,s=0;for(;n<t.length&&s<e.length;)t[n].time<=e[s].time?r.push(t[n++]):r.push(e[s++]);return r.push(...t.slice(n),...e.slice(s)),r},po=1e3,cS=a.z.object({keys:a.z.number().array(),downsampleFactor:a.z.int(),throttleRate:vt.z.optional()}),lS=a.z.object({frame:Nn}),yo=a.z.object({channels:Ct,downsampleFactor:a.z.int().default(1),throttleRate:vt.z.default(new vt(0)),useHighPerformanceCodec:a.z.boolean().default(!0)}),Ha=yo.or(Ct.transform(t=>yo.parse({channels:t}))),$u=(t,e)=>async r=>{const n=Ha.parse(r),s=await En.open(t,n.channels);n.useHighPerformanceCodec&&(e=e.withCodec(new eS(s.codec)));const i=await e.stream("/frame/stream",cS,lS),o=new uS(i,s,n.downsampleFactor,n.throttleRate);i.send({keys:Array.from(s.keys),downsampleFactor:n.downsampleFactor,throttleRate:n.throttleRate});const[,c]=await i.receive();if(c!=null)throw c;return o},Mu=async(t,e,r)=>await $u(t,e)(r);class uS{stream;adapter;downsampleFactor;throttleRate;constructor(e,r,n=1,s=new vt(0)){this.stream=new Iu("Streamer",e),this.adapter=r,this.downsampleFactor=n,this.throttleRate=s}get keys(){return Array.from(this.adapter.keys)}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(Ee.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new ue((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e)&&this.stream.send({keys:Array.from(this.adapter.keys),downsampleFactor:this.downsampleFactor,throttleRate:this.throttleRate})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class An{wrapped_=null;breaker;opener;config;constructor(e,r,n={}){this.opener=e,this.config=Ha.parse(r);const{maxRetries:s=5e3,baseInterval:i=E.seconds(1),scale:o=1}=n??{};this.breaker=new va.Breaker({maxRetries:s,baseInterval:i,scale:o})}static async open(e,r,n){const s=new An(e,r,n);return await s.runStreamer(),s}async runStreamer(){for(;;)try{this.wrapped_!=null&&this.wrapped_.close(),this.wrapped_=await this.opener(this.config),this.breaker.reset();return}catch(e){if(this.wrapped_=null,!await this.breaker.wait())throw e;console.error("failed to open streamer",e);continue}}get wrapped(){if(this.wrapped_==null)throw new Error("stream closed");return this.wrapped_}async update(e){this.config.channels=Ct.parse(e);try{await this.wrapped.update(e)}catch{return await this.runStreamer(),await this.update(e)}}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(Ee.matches(e))return{done:!0,value:void 0};throw e}}async read(){try{const e=await this.wrapped.read();return this.breaker.reset(),e}catch(e){if(Ee.matches(e))throw e;return await this.runStreamer(),await this.read()}}close(){this.wrapped.close()}get keys(){return this.wrapped.keys}[Symbol.asyncIterator](){return this}}class _u extends Ng.Observer{streamer;closePromise;constructor(e,r){super(r),this.streamer=e,this.closePromise=this.stream()}async update(e){await this.streamer.update(e)}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}}var Or=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(Or||{});const hS=new E(-1);class Ds extends Ue.sub("writer_closed"){constructor(){super("WriterClosed")}}const dS=a.z.enum(Or).or(a.z.enum(["persist","stream","persistStream"]).transform(t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1}})),Zu=a.z.object({start:C.z.optional(),controlSubject:be.subjectZ.optional(),authorities:a.z.union([be.authorityZ.transform(t=>[t]),be.authorityZ.array()]).default([be.ABSOLUTE_AUTHORITY]),mode:dS.default(1),errOnUnauthorized:a.z.boolean().default(!1),enableAutoCommit:a.z.boolean().default(!0),autoIndexPersistInterval:E.z.default(E.SECOND),useHighPerformanceCodec:a.z.boolean().default(!0)}),fS=Zu.extend({keys:D.array().optional()}),mo=Zu.extend({channels:Ct}),Uu=mo.or(Ct.transform(t=>mo.parse({channels:t,start:C.now()}))),pS=a.z.object({command:a.z.enum(Me),config:fS.optional(),frame:Nn.optional(),buffer:a.z.instanceof(Uint8Array).optional()}),yS=a.z.object({command:a.z.enum(Me),end:C.z,err:He.payloadZ.optional()}),mS=a.z.tuple([a.z.union([a.z.record(D.or(Ve),be.authorityZ),D.or(Ve),be.authorityZ]),be.authorityZ.optional()]).transform(([t,e])=>{if(be.authorityZ.safeParse(t).success)return{keys:[],authorities:[t]};if(D.or(Ve).safeParse(t).success){if(e==null)throw new Error("authority is required when setting authority for a single channel");return{keys:[t],authorities:[e]}}const r=t;return{keys:Object.keys(r),authorities:Object.values(r)}});let Pu=class Ru{stream;adapter;closeErr=null;constructor(e,r){this.stream=e,this.adapter=r}static async _open(e,r,n){const s=Uu.parse(n),i=await Ya.open(e,s.channels);s.useHighPerformanceCodec&&(r=r.withCodec(new Qk(i.codec)));const o=await r.stream("/frame/write",pS,yS),c=new Ru(o,i);return await c.execute({command:Me.Open,config:{...s,keys:i.keys}}),c}async write(e,r){if(this.closeErr!=null)throw this.closeErr;if(this.stream.received())return await this.close();const n=await this.adapter.adapt(e,r);this.stream.send({command:Me.Write,frame:n.toPayload()})}async setAuthority(e,r){if(this.closeErr!=null)throw this.closeErr;const n=mS.parse([e,r]),s={keys:await this.adapter.adaptParams(n.keys),authorities:n.authorities};await this.execute({command:Me.SetAuthority,config:s})}async commit(){if(this.closeErr!=null)throw this.closeErr;return this.stream.received()?(await this.closeInternal(null),C.ZERO):(await this.execute({command:Me.Commit})).end}async close(){await this.closeInternal(null)}async closeInternal(e){if(this.closeErr!=null)throw this.closeErr;for(this.closeErr=e,this.stream.closeSend();;){if(this.closeErr!=null){if(Ds.matches(this.closeErr))return null;throw this.closeErr}const[r,n]=await this.stream.receive();n!=null?this.closeErr=Ee.matches(n)?new Ds:n:this.closeErr=He.decode(r?.err)}}async execute(e){const r=this.stream.send(e);for(r!=null&&await this.closeInternal(r);;){const[n,s]=await this.stream.receive();s!=null&&await this.closeInternal(s);const i=He.decode(n?.err);if(i!=null&&await this.closeInternal(i),n?.command==e.command)return n}}};const Lu=K("framer"),gS=Lu("");let Du=class{streamClient;retriever;deleter;reader;constructor(t,e,r){this.streamClient=t,this.retriever=r,this.deleter=new Hk(e),this.reader=new ju(r,t)}async openIterator(t,e,r){return await Dr._open(t,e,this.retriever,this.streamClient,r)}async openWriter(t){return await Pu._open(this.retriever,this.streamClient,t)}async openStreamer(t){return await Mu(this.retriever,this.streamClient,t)}async write(t,e,r){if(r==null){const s=e,i=await this.openWriter({start:t,channels:Object.keys(s),mode:Or.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:E.MAX});return await i.write(s),await i.close()}const n=await this.openWriter({start:t,channels:e,mode:Or.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:E.MAX});await n.write(e,r),await n.close()}async read(t,e){if(!("start"in t))return this.reader.read(t);const{single:r}=Ne(e),n=await this.readFrame(t,e);return r?n.get(e):n}async readFrame(t,e){const r=await this.openIterator(t,e),n=new ue;try{for await(const s of r)n.push(s)}finally{await r.close()}return n}async readLatest(t,e=1){const{single:r}=Ne(t),n=await this.readLatestNFrame(t,e);return r?n.get(t):n}async readLatestNFrame(t,e){const r=await this.openIterator(B.MAX,t,{chunkSize:e}),n=new ue;if(e>0)try{await r.seekLast(),await r.prev(fn),n.push(r.value)}finally{await r.close()}return n}async delete(t,e){const{normalized:r,variant:n}=Ne(t),s=new B(e);return n==="keys"?await this.deleter.delete({keys:r,bounds:s}):await this.deleter.delete({names:r,bounds:s})}};const wS=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:hS,AUTO_SPAN:fn,Client:Du,Frame:ue,HardenedStreamer:An,Iterator:Dr,ObservableStreamer:_u,Reader:ju,TYPE_ONTOLOGY_ID:gS,Writer:Pu,WriterClosedError:Ds,WriterCommand:Me,WriterMode:Or,createStreamOpener:$u,frameZ:Nn,ontologyID:Lu,openStreamer:Mu,seriesFromPayload:Nu,seriesToPayload:Eu,streamerConfigZ:Ha,writerConfigZ:Uu},Symbol.toStringTag,{value:"Module"})),bS=be.ABSOLUTE_AUTHORITY,vS=be.ZERO_AUTHORITY,zS=be.stateZ(a.z.number()),OS=t=>t.to==null?`${t.from?.resource} - ${t.from?.subject.name} -> released`:t.from==null?`${t.to.resource} - released -> ${t.to.subject.name} (${t.to.authority.toString()})`:`${t.to.resource} - ${t.from.subject.name} -> ${t.to.subject.name} (${t.to.authority.toString()})`,TS=a.z.object({transfers:a.z.array(be.transferZ(D))});class Bu extends _u{states;codec;constructor(e){super(e,r=>{const n=this.codec.decode(r.series[0].buffer,TS);return this.merge(n),[n.transfers,!0]}),this.states=new Map,this.codec=new Nt.JSONCodec}subjects(){const e=new Map;return this.states.forEach(r=>e.set(r.subject.key,r.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(r=>{r.from==null&&r.to==null&&console.warn("Invalid transfer: ",r),r.to==null?this.states.delete(r.from.resource):this.states.set(r.to.resource,r.to)})}}const Fu="sy_node_1_control";let qu=class{framer;constructor(t){this.framer=t}async openStateTracker(){const t=await An.open(async e=>await this.framer.openStreamer(e),Fu);return new Bu(t)}};const kS=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:bS,CONTROL_STATE_CHANNEL_NAME:Fu,Client:qu,StateTracker:Bu,ZERO_AUTHORITY:vS,stateZ:zS,transferString:OS},Symbol.toStringTag,{value:"Module"})),Ae=a.z.uint32(),Yu=a.z.object({rack:Ae}),Vu=lt.statusZ(Yu),xn=a.z.object({key:Ae,name:a.z.string(),status:_e.nullToUndefined(Vu)}),Hu=xn.partial({key:!0}),Wu=t=>t?Nt.JSON_CODEC.decodeString(t,ze.unknownZ):{},er=a.z.string(),Gu=a.z.object({rack:Ae,device:er}),Ku=lt.statusZ(Gu),In=a.z.object({key:er,rack:Ae.min(1,"Must select a location to connect from"),name:a.z.string().min(1,"Name is required"),make:a.z.string().min(1,"Make is required"),model:a.z.string().min(1,"Model is required"),location:a.z.string().min(1,"Location is required"),configured:a.z.boolean().optional(),properties:ze.unknownZ.or(a.z.string().transform(Wu)),status:_e.nullToUndefined(Ku)}),Ju=In.extend({properties:a.z.unknown().transform(t=>Nt.JSON_CODEC.encodeString(t))}),SS="sy_device_set",NS="sy_device_delete",ES=a.z.object({devices:Ju.array()}),AS=a.z.object({devices:In.array()}),xS=a.z.object({keys:er.array()}),IS=a.z.object({}),CS=a.z.object({keys:er.array().optional(),names:a.z.string().array().optional(),makes:a.z.string().array().optional(),models:a.z.string().array().optional(),locations:a.z.string().array().optional(),racks:Ae.array().optional(),searchTerm:a.z.string().optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),includeStatus:a.z.boolean().optional()}),jS=a.z.object({devices:O.nullableZ(In)}),$S=a.z.object({key:er,includeStatus:a.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),MS=a.z.union([$S,CS]);let Xu=class{client;constructor(t){this.client=t}async retrieve(t){const e=typeof t=="object"&&"key"in t,r=await w(this.client,"/device/retrieve",t,MS,jS);ce("Device",t,r.devices,e);const n=r.devices;return e?n[0]:n}async create(t){const e=!Array.isArray(t),r=(await w(this.client,"/device/create",{devices:O.toArray(t)},ES,AS)).devices;return e?r[0]:r}async delete(t){await w(this.client,"/device/delete",{keys:O.toArray(t)},xS,IS)}};const Wa=K("device"),_S=Wa(""),ZS=t=>Ze(Wa(t)),US=Object.freeze(Object.defineProperty({__proto__:null,Client:Xu,DELETE_CHANNEL_NAME:NS,SET_CHANNEL_NAME:SS,TYPE_ONTOLOGY_ID:_S,deviceZ:In,keyZ:er,newZ:Ju,ontologyID:Wa,statusDetailsZ:Gu,statusKey:ZS,statusZ:Ku},Symbol.toStringTag,{value:"Module"})),PS="sy_rack_set",RS="sy_rack_delete",LS=a.z.object({keys:Ae.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),embedded:a.z.boolean().optional(),hostIsNode:a.z.boolean().optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),includeStatus:a.z.boolean().optional()}),DS=a.z.object({racks:O.nullableZ(xn)}),BS=a.z.union([a.z.object({key:Ae,includeStatus:a.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),a.z.object({name:a.z.string(),includeStatus:a.z.boolean().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e}))]),FS=LS,qS=a.z.union([BS,FS]),YS=a.z.object({racks:Hu.array()}),VS=a.z.object({racks:xn.array()}),HS=a.z.object({keys:Ae.array()}),WS=a.z.object({});let Qu=class{client;tasks;constructor(t,e){this.client=t,this.tasks=e}async delete(t){await w(this.client,"/rack/delete",{keys:O.toArray(t)},HS,WS)}async create(t){const e=!Array.isArray(t),r=await w(this.client,"/rack/create",{racks:O.toArray(t)},YS,VS),n=this.sugar(r.racks);return e?n[0]:n}async retrieve(t){const e="key"in t||"name"in t,r=await w(this.client,"/rack/retrieve",t,qS,DS),n=this.sugar(r.racks);return ce("Rack",t,n,e),e?n[0]:n}sugar(t){const e=!Array.isArray(t),r=O.toArray(t).map(({key:n,name:s,status:i})=>new eh(n,s,this.tasks,i));return e?r[0]:r}};class eh{key;name;status;tasks;constructor(e,r,n,s){this.key=e,this.name=r,this.tasks=n,this.status=s}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async createTask(e,r){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e,r)}async deleteTask(e){await this.tasks.delete([e])}get payload(){return{key:this.key,name:this.name,status:this.status}}}const Ga=K("rack"),GS=Ga(0),KS=t=>Ze(Ga(t)),JS=Object.freeze(Object.defineProperty({__proto__:null,Client:Qu,DELETE_CHANNEL_NAME:RS,Rack:eh,SET_CHANNEL_NAME:PS,TYPE_ONTOLOGY_ID:GS,keyZ:Ae,newZ:Hu,ontologyID:Ga,rackZ:xn,statusDetailsZ:Yu,statusKey:KS,statusZ:Vu},Symbol.toStringTag,{value:"Module"})),XS="sy_range_alias_set",QS="sy_range_alias_delete",e0=a.z.object({range:X,aliases:a.z.string().array()}),t0=a.z.object({aliases:a.z.record(a.z.string(),D)}),r0=a.z.object({range:X,aliases:a.z.record(D,a.z.string())}),n0=a.z.unknown(),s0=a.z.object({range:X,channels:D.array()}),a0=a.z.unknown(),i0=a.z.object({range:X}),o0=a.z.object({aliases:a.z.record(a.z.string(),a.z.string())}),c0=a.z.object({range:X,channels:D.array()}),l0=a.z.object({aliases:a.z.record(a.z.string(),a.z.string())});class pt{cache=new Map;client;rangeKey;constructor(e,r){this.rangeKey=e,this.cache=new Map,this.client=r}async resolve(e){const r=[],n=typeof e=="string",s={};if(n){const o=this.cache.get(e);if(o!=null)return o;r.push(e)}else e.forEach(o=>{const c=this.cache.get(o);c!=null?s[o]=c:r.push(o)});if(r.length===0)return s;const i=await w(this.client,"/range/alias/resolve",{range:this.rangeKey,aliases:r},e0,t0);return Object.entries(i.aliases).forEach(([o,c])=>this.cache.set(o,c)),n?i.aliases[r[0]]:{...s,...i.aliases}}async set(e){await w(this.client,"/range/alias/set",{range:this.rangeKey,aliases:e},r0,n0)}async list(){return(await w(this.client,"/range/alias/list",{range:this.rangeKey},i0,o0)).aliases}async retrieve(e){const r=typeof e=="number",n=await w(this.client,"/range/alias/retrieve",{range:this.rangeKey,channels:O.toArray(e)},c0,l0);return r?n.aliases[e]:n.aliases}async delete(e){await w(this.client,"/range/alias/delete",{range:this.rangeKey,channels:O.toArray(e)},s0,a0)}}const u0=a.z.object({alias:a.z.string().optional(),channel:D,range:X}),th="---",h0=t=>`${t.range}${th}${t.channel}`,d0=t=>{const[e,r]=t.split(th);return{range:e,channel:Number(r)}},f0="sy_range_kv_set",p0="sy_range_kv_delete",Ka=a.z.object({range:X,key:a.z.string(),value:a.z.string()}),y0=({range:t,key:e})=>`${t}<--->${e}`,m0=a.z.object({range:X,keys:a.z.string().array()}),g0=a.z.object({pairs:O.nullableZ(Ka)}),w0=a.z.object({range:X,pairs:Ka.array()}),b0=a.z.object({range:X,keys:a.z.string().array()});class Bs{rangeKey;client;constructor(e,r){this.rangeKey=e,this.client=r}async get(e){const r=await w(this.client,"/range/kv/get",{range:this.rangeKey,keys:O.toArray(e)},m0,g0);return typeof e=="string"?r.pairs[0].value:Object.fromEntries(r.pairs.map(n=>[n.key,n.value]))}async list(){return this.get([])}async set(e,r=""){let n;typeof e=="string"?n=[{range:this.rangeKey,key:e,value:r}]:n=Object.entries(e).map(([s,i])=>({range:this.rangeKey,key:s,value:i})),await w(this.client,"/range/kv/set",{range:this.rangeKey,pairs:n},w0,a.z.unknown())}async delete(e){await w(this.client,"/range/kv/delete",{range:this.rangeKey,keys:O.toArray(e)},b0,a.z.unknown())}}const v0="sy_range_set",z0="sy_range_delete";class rh{key;name;kv;timeRange;color;parent;labels;channels;aliaser;frameClient;labelClient;ontologyClient;rangeClient;constructor({name:e,timeRange:r=B.ZERO,key:n,color:s,parent:i,labels:o},{frameClient:c,kv:l,aliaser:u,channels:h,labelClient:f,ontologyClient:d,rangeClient:z}){this.key=n,this.name=e,this.timeRange=r,this.parent=i,this.labels=o,this.frameClient=c,this.color=s,this.kv=l,this.aliaser=u,this.channels=h,this.labelClient=f,this.ontologyClient=d,this.rangeClient=z}get ontologyID(){return yt(this.key)}get payload(){let e=null;return this.parent!=null&&("payload"in this.parent?e=this.parent.payload:e=this.parent),{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color,labels:this.labels,parent:e}}async setAlias(e,r){const n=await this.channels.retrieve(e);if(n.length===0)throw new ot(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:r})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async resolveAlias(e){return await this.aliaser.resolve(e)}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(r=>r.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async retrieveLabels(){return await this.labelClient.retrieve({for:yt(this.key)})}async addLabel(...e){await this.labelClient.label(yt(this.key),e)}async removeLabel(...e){await this.labelClient.remove(yt(this.key),e)}static sort(e,r){return B.sort(e.timeRange,r.timeRange)}}const O0=a.z.object({keys:X.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),overlapsWith:B.z.optional(),hasLabels:ht.array().optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),includeLabels:a.z.boolean().optional(),includeParent:a.z.boolean().optional()}),T0=O0.or(X.array().transform(t=>({keys:t}))).or(X.transform(t=>({keys:[t]}))).or(a.z.string().transform(t=>({names:[t]}))).or(a.z.string().array().transform(t=>({names:t}))).or(B.z.transform(t=>({overlapsWith:t}))),k0=a.z.object({ranges:O.nullableZ(Lr)});let nh=class{type="range";frameClient;writer;unaryClient;channels;labelClient;ontologyClient;constructor(t,e,r,n,s,i){this.frameClient=t,this.writer=e,this.unaryClient=r,this.channels=n,this.labelClient=s,this.ontologyClient=i}async create(t,e){const r=!Array.isArray(t),n=this.sugarMany(await this.writer.create(O.toArray(t),e));return r?n[0]:n}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(O.toArray(t))}async retrieve(t){const e=typeof t=="string",{ranges:r}=await w(this.unaryClient,"/range/retrieve",t,T0,k0);return ce("Range",t,r,e),e?this.sugarMany(r)[0]:this.sugarMany(r)}getKV(t){return new Bs(t,this.unaryClient)}async retrieveParent(t){const e=await this.ontologyClient.retrieveParents(yt(t));if(e.length===0)return null;const r=e[0];return r.id.type!=="range"?null:await this.retrieve(r.id.key)}sugarOntologyResource(t){return this.sugarOne(sh(t))}async retrieveAlias(t,e){return await new pt(t,this.unaryClient).retrieve(e)}async retrieveAliases(t,e){return await new pt(t,this.unaryClient).retrieve(e)}async listAliases(t){return await new pt(t,this.unaryClient).list()}async setAlias(t,e,r){await new pt(t,this.unaryClient).set({[e]:r})}async deleteAlias(t,e){await new pt(t,this.unaryClient).delete(e)}sugarOne(t){return new rh(t,{frameClient:this.frameClient,kv:new Bs(t.key,this.unaryClient),aliaser:new pt(t.key,this.unaryClient),channels:this.channels,labelClient:this.labelClient,ontologyClient:this.ontologyClient,rangeClient:this})}sugarMany(t){return t.map(e=>this.sugarOne(e))}resourceToRange(t){return this.sugarOne({key:t.id.key,name:t.data?.name,timeRange:new B(t.data?.timeRange),color:t.data?.color,labels:[],parent:null})}};const yt=K("range"),S0=yt(""),N0=t=>({type:"range-alias",key:t}),sh=({data:t,id:{key:e},name:r})=>{const n=B.z.parse(t?.timeRange);return{key:e,name:r,timeRange:n,color:typeof t?.color=="string"?t.color:void 0,labels:[],parent:null}},E0=a.z.object({ranges:Lr.array()}),A0=a.z.object({parent:F.optional(),ranges:vu.array()}),x0=a.z.object({keys:X.array()}),I0=a.z.object({}),C0=a.z.object({key:X,name:Da}),j0=a.z.object({});class ah{client;constructor(e){this.client=e}async rename(e,r){await w(this.client,"/range/rename",{key:e,name:r},C0,j0)}async create(e,r){return(await w(this.client,"/range/create",{ranges:e,...r},A0,E0)).ranges}async delete(e){await w(this.client,"/range/delete",{keys:e},x0,I0)}}const $0=Object.freeze(Object.defineProperty({__proto__:null,Aliaser:pt,Client:nh,DELETE_ALIAS_CHANNEL_NAME:QS,DELETE_CHANNEL_NAME:z0,KV:Bs,KV_DELETE_CHANNEL:p0,KV_SET_CHANNEL:f0,Range:rh,SET_ALIAS_CHANNEL_NAME:XS,SET_CHANNEL_NAME:v0,TYPE_ONTOLOGY_ID:S0,Writer:ah,aliasKey:h0,aliasOntologyID:N0,aliasZ:u0,convertOntologyResourceToPayload:sh,decodeDeleteAliasChange:d0,keyZ:X,kvPairKey:y0,kvPairZ:Ka,nameZ:Da,newZ:vu,ontologyID:yt,payloadZ:Lr},Symbol.toStringTag,{value:"Module"})),Cn=a.z.string(),jn=t=>lt.statusZ(t),ih=t=>jn(t).omit({labels:!0}).partial({key:!0}),Fs="sy_status_set",M0="sy_status_delete",oh=K("status"),_0=oh(""),Z0=t=>a.object({parent:F.optional(),statuses:ih(t).array()}),U0=t=>a.object({statuses:jn(t).array()}),P0=a.object({keys:Cn.array()}),R0=a.object({}),L0=a.object({keys:Cn.array().optional(),searchTerm:a.string().optional(),offset:a.int().optional(),limit:a.int().optional(),includeLabels:a.boolean().optional(),hasLabels:ht.array().optional()}),D0=a.object({key:Cn,includeLabels:a.boolean().optional()}).transform(({key:t,includeLabels:e})=>({keys:[t],includeLabels:e})),B0=a.union([D0,L0]),F0=t=>a.object({statuses:O.nullableZ(jn(t))});let ch=class{type="status";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await w(this.client,"/status/retrieve",t,B0,F0(t.detailsSchema));ce("Status",t,r.statuses,e);const n=r.statuses;return e?n[0]:n}async set(t,e={}){const r=Array.isArray(t),n=(await w(this.client,"/status/set",{statuses:O.toArray(t),parent:e.parent},Z0(e.detailsSchema),U0(e.detailsSchema))).statuses;return r?n:n[0]}async delete(t){await w(this.client,"/status/delete",{keys:O.toArray(t)},P0,R0)}};const q0=Object.freeze(Object.defineProperty({__proto__:null,Client:ch,DELETE_CHANNEL_NAME:M0,SET_CHANNEL_NAME:Fs,TYPE_ONTOLOGY_ID:_0,keyZ:Cn,newZ:ih,ontologyID:oh,statusZ:jn},Symbol.toStringTag,{value:"Module"})),We=a.z.union([a.z.string(),a.z.bigint().transform(t=>t.toString()),a.z.number().transform(t=>t.toString())]),Ja=t=>a.z.object({task:We,running:a.z.boolean(),data:t,cmd:a.z.string().optional()}),Xa=t=>lt.statusZ(Ja(t)),Y0=t=>Ja(t).partial({task:!0}),lh=t=>lt.statusZ(Y0(t)).partial({key:!0,name:!0}),Br=(t={typeSchema:a.z.string(),configSchema:a.z.unknown(),statusDataSchema:a.z.unknown()})=>a.z.object({key:We,name:a.z.string(),type:t.typeSchema,internal:a.z.boolean().optional(),config:a.z.string().transform(Wu).or(t.configSchema),status:Xa(t.statusDataSchema).optional().nullable(),snapshot:a.z.boolean().optional()}),uh=t=>Br(t).omit({key:!0,status:!0}).extend({key:We.transform(e=>e.toString()).optional(),config:a.z.unknown().transform(e=>Nt.JSON_CODEC.encodeString(e)),status:lh(t?.statusDataSchema??a.z.unknown()).optional().nullable()}),V0=a.z.object({task:We,type:a.z.string(),key:a.z.string(),args:ze.unknownZ.or(a.z.string().transform(Re)).or(a.z.array(a.z.unknown())).or(a.z.null()).optional()}),H0=t=>Number(BigInt(t)>>32n),W0=(t,e=0)=>((BigInt(t)<<32n)+BigInt(e)).toString(),qs="sy_task_cmd",G0="sy_task_set",K0="sy_task_delete",mt=new Error("Task not created"),hh=async(t,e)=>{const r=await e.retrieveParents(Fr(t));return r.length===0?null:r[0]};class dh{key;name;internal;type;snapshot;config;status;schemas;frameClient_;ontologyClient_;rangeClient_;get frameClient(){if(this.frameClient_==null)throw mt;return this.frameClient_}get ontologyClient(){if(this.ontologyClient_==null)throw mt;return this.ontologyClient_}get rangeClient(){if(this.rangeClient_==null)throw mt;return this.rangeClient_}constructor({key:e,type:r,name:n,config:s,internal:i=!1,snapshot:o=!1,status:c},l,u,h,f){this.key=e,this.name=n,this.type=r,this.config=s,this.schemas=l??{typeSchema:a.z.string(),configSchema:a.z.unknown(),statusDataSchema:a.z.unknown()},this.internal=i,this.snapshot=o,this.status=c,this.frameClient_=u,this.ontologyClient_=h,this.rangeClient_=f}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,status:this.status,internal:this.internal}}get ontologyID(){return Fr(this.key)}async executeCommand(e){return await yh({...e,frameClient:this.frameClient,task:this.key})}async executeCommandSync(e){return await mh({...e,frameClient:this.frameClient,task:this.key,name:this.name,statusDataZ:this.schemas?.statusDataSchema})}async start(){await this.executeCommand({type:"start"})}async stop(){await this.executeCommand({type:"stop"})}async run(e){await this.start();try{return await e()}finally{await this.stop()}}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw mt;return this.snapshot?await hh(this.key,this.ontologyClient):null}}const J0=a.z.object({rack:Ae.optional(),keys:We.array().optional(),names:a.z.string().array().optional(),types:a.z.string().array().optional(),includeStatus:a.z.boolean().optional(),internal:a.z.boolean().optional(),snapshot:a.z.boolean().optional(),searchTerm:a.z.string().optional(),offset:a.z.int().optional(),limit:a.z.int().optional()}),fh=a.z.union([a.z.object({key:We,includeStatus:a.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),a.z.object({name:a.z.string(),includeStatus:a.z.boolean().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e})),a.z.object({type:a.z.string(),rack:Ae.optional()}).transform(({type:t,rack:e})=>({types:[t],rack:e}))]),X0=J0,Q0=a.z.union([fh,X0]),eN=t=>a.z.object({tasks:O.nullableZ(Br(t))}),tN=t=>a.z.object({tasks:uh(t).array()}),rN=t=>a.z.object({tasks:Br(t).array()}),nN=a.z.object({keys:We.array()}),sN=a.z.object({}),aN=a.z.object({key:We,name:a.z.string(),snapshot:a.z.boolean()}),iN=t=>a.z.object({task:Br(t)});let ph=class{type="task";client;frameClient;ontologyClient;rangeClient;constructor(t,e,r,n){this.client=t,this.frameClient=e,this.ontologyClient=r,this.rangeClient=n}async create(t,e){const r=!Array.isArray(t),n=tN(e),s=rN(e),i=await w(this.client,"/task/create",{tasks:O.toArray(t)},n,s),o=this.sugar(i.tasks,e);return r?o[0]:o}async delete(t){await w(this.client,"/task/delete",{keys:O.toArray(t)},nN,sN)}async retrieve({schemas:t,...e}){const r=fh.safeParse(e).success,n=(await w(this.client,"/task/retrieve",e,Q0,eN(t))).tasks,s=this.sugar(n,t);return ce("Task",e,s,r),r?s[0]:s}async copy(t,e,r){const n=iN(),s=await w(this.client,"/task/copy",{key:t,name:e,snapshot:r},aN,n);return this.sugar(s.task)}async list(t){const e={internal:!1};return t!==void 0&&(e.rack=t),await this.retrieve(e)}async retrieveSnapshottedTo(t){if(this.ontologyClient==null)throw mt;return await hh(t,this.ontologyClient)}sugar(t,e){const r=!Array.isArray(t),n=O.toArray(t).map(({key:s,name:i,type:o,config:c,status:l,internal:u,snapshot:h})=>new dh({key:s,name:i,type:o,config:c,internal:u,snapshot:h,status:l},e,this.frameClient,this.ontologyClient,this.rangeClient));return r?n[0]:n}async executeCommand(t){return"commands"in t?await Qa({...t,frameClient:this.frameClient}):await yh({...t,frameClient:this.frameClient})}async executeCommandSync(t){if("commands"in t){const r=async()=>{const{commands:n}=t;return(await this.retrieve({keys:n.map(s=>s.task)})).map(s=>s.name)};return await gh({...t,frameClient:this.frameClient,name:r})}const e=async()=>{const{task:r}=t;return(await this.retrieve({key:r})).name};return await mh({frameClient:this.frameClient,name:e,...t})}};const Fr=K("task"),oN=Fr(""),cN=t=>Ze(Fr(t)),yh=async({frameClient:t,task:e,type:r,args:n})=>(await Qa({frameClient:t,commands:[{args:n,task:e,type:r}]}))[0],Qa=async({frameClient:t,commands:e})=>{if(t==null)throw mt;const r=await t.openWriter(qs),n=e.map(s=>({...s,key:Jp.create()}));return await r.write(qs,n),await r.close(),n.map(s=>s.key)},mh=async({frameClient:t,task:e,type:r,timeout:n,name:s,statusDataZ:i,args:o})=>(await gh({frameClient:t,commands:[{args:o,task:e,type:r}],timeout:n,statusDataZ:i,name:s}))[0],gh=async({frameClient:t,commands:e,timeout:r=E.seconds(10),statusDataZ:n,name:s})=>{if(t==null)throw mt;const i=await t.openStreamer(Fs),o=await Qa({frameClient:t,commands:e}),c=new E(r);let l=[],u;const h=new Promise((f,d)=>{u=setTimeout(()=>{(async()=>{const z=e.map(I=>I.task);d(await lN("command",s,c,z))})()},c.milliseconds)});try{for(;;){const f=await Promise.race([i.read(),h]),d=Xa(n).safeParse(f.at(-1)[Fs]);if(!d.success)continue;const z=d.data;if(!(z.details.cmd==null||!o.includes(z.details.cmd))&&(l=[...l.filter(I=>I.key!==z.key),z],l.length===o.length))return l}}finally{clearTimeout(u),i.close()}},lN=async(t,e,r,n)=>{const s=$p.capitalize(t),i=r.toString();try{let o;typeof e=="string"?o=[e]:Array.isArray(e)?o=e:o=O.toArray(await e());const c=Is.naturalLanguageJoin(o);return new Error(`${s} command to ${c} timed out after ${i}`)}catch(o){return console.error("Failed to retrieve task name for timeout error:",o),new Error(`${s} command to task with key ${Is.naturalLanguageJoin(n)} timed out after ${i}`)}},uN=Object.freeze(Object.defineProperty({__proto__:null,COMMAND_CHANNEL_NAME:qs,Client:ph,DELETE_CHANNEL_NAME:K0,SET_CHANNEL_NAME:G0,TYPE_ONTOLOGY_ID:oN,Task:dh,commandZ:V0,keyZ:We,newKey:W0,newStatusZ:lh,newZ:uh,ontologyID:Fr,rackKey:H0,statusDetailsZ:Ja,statusKey:cN,statusZ:Xa,taskZ:Br},Symbol.toStringTag,{value:"Module"}));class wh{url;unary;stream;secure;constructor(e,r={},n=!1){this.secure=n,this.url=e.child("/api/v1/");const s=new Nt.JSONCodec;this.unary=mp(new yp(this.url,s,this.secure),r),this.stream=new zp(this.url,s,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const tr=a.uuid(),$n=a.object({key:tr,name:a.string(),type:a.string(),query:ze.unknownZ}),bh=$n.extend({key:tr.optional()}),hN="sy_view_set",dN="sy_view_delete",fN=a.z.object({views:bh.array()}),pN=a.z.object({views:$n.array()}),yN=a.z.object({keys:tr.array()}),mN=a.z.object({}),gN=a.z.object({keys:tr.array().optional(),types:a.z.string().array().optional(),searchTerm:a.z.string().optional(),offset:a.z.number().optional(),limit:a.z.number().optional()}),wN=a.z.object({key:tr}).transform(({key:t})=>({keys:[t]})),bN=a.z.union([wN,gN]),vN=a.z.object({views:O.nullableZ($n)});let vh=class{client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await w(this.client,"/view/retrieve",t,bN,vN);return ce("View",t,r.views,e),e?r.views[0]:r.views}async create(t){const e=Array.isArray(t),r=await w(this.client,"/view/create",{views:O.toArray(t)},fN,pN);return e?r.views:r.views[0]}async delete(t){await w(this.client,"/view/delete",{keys:O.toArray(t)},yN,mN)}};const zh=t=>({type:"view",key:t}),zN=zh(""),ON=Object.freeze(Object.defineProperty({__proto__:null,Client:vh,DELETE_CHANNEL_NAME:dN,SET_CHANNEL_NAME:hN,TYPE_ONTOLOGY_ID:zN,keyZ:tr,newZ:bh,ontologyID:zh,viewZ:$n},Symbol.toStringTag,{value:"Module"})),jt=a.z.uuid(),Mn=a.z.object({key:jt,name:a.z.string(),data:ze.unknownZ.or(a.z.string().transform(Re))}),Oh=Mn.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Le=a.z.uuid(),_n=a.z.object({key:Le,name:a.z.string().min(1,"Name is required"),layout:ze.unknownZ.or(a.z.string().transform(Re))}),Th=_n.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),kh=_n.omit({layout:!0}).extend({layout:a.z.string().transform(Re)}),TN=a.z.object({key:jt,name:a.z.string()}),kN=a.z.object({key:jt,data:a.z.string()}),SN=a.z.object({keys:jt.array()}),NN=a.z.object({keys:jt.array()}),Sh=a.z.object({key:jt}).transform(({key:t})=>({keys:[t]})),Nh=a.z.union([Sh,NN]),EN=a.z.object({linePlots:O.nullableZ(Mn)}),AN=a.z.object({workspace:Le,linePlots:Oh.array()}),xN=a.z.object({linePlots:Mn.array()}),es=a.z.object({});let Eh=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/lineplot/create",{workspace:t,linePlots:O.toArray(e)},AN,xN);return r?n.linePlots:n.linePlots[0]}async rename(t,e){await w(this.client,"/workspace/lineplot/rename",{key:t,name:e},TN,es)}async setData(t,e){await w(this.client,"/workspace/lineplot/set-data",{key:t,data:JSON.stringify(e)},kN,es)}async retrieve(t){const e=Sh.safeParse(t).success,r=await w(this.client,"/workspace/lineplot/retrieve",t,Nh,EN);return ce("LinePlot",t,r.linePlots,e),e?r.linePlots[0]:r.linePlots}async delete(t){await w(this.client,"/workspace/lineplot/delete",{keys:O.toArray(t)},SN,es)}};const Ah=K("lineplot"),IN=Ah(""),CN=Object.freeze(Object.defineProperty({__proto__:null,Client:Eh,TYPE_ONTOLOGY_ID:IN,keyZ:jt,linePlotZ:Mn,newZ:Oh,ontologyID:Ah,retrieveArgsZ:Nh},Symbol.toStringTag,{value:"Module"})),$t=a.z.uuid(),Zn=a.z.object({key:$t,name:a.z.string(),data:ze.unknownZ.or(a.z.string().transform(Re))}),xh=Zn.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),jN=a.z.object({key:$t,name:a.z.string()}),$N=a.z.object({key:$t,data:a.z.string()}),MN=a.z.object({keys:$t.array()}),_N=a.z.object({keys:$t.array()}),Ih=a.z.object({key:$t}).transform(({key:t})=>({keys:[t]})),Ch=a.z.union([Ih,_N]),ZN=a.z.object({logs:O.nullableZ(Zn)}),UN=a.z.object({workspace:Le,logs:xh.array()}),PN=a.z.object({logs:Zn.array()}),ts=a.z.object({});let jh=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/log/create",{workspace:t,logs:O.toArray(e)},UN,PN);return r?n.logs:n.logs[0]}async rename(t,e){await w(this.client,"/workspace/log/rename",{key:t,name:e},jN,ts)}async setData(t,e){await w(this.client,"/workspace/log/set-data",{key:t,data:JSON.stringify(e)},$N,ts)}async retrieve(t){const e=Ih.safeParse(t).success,r=await w(this.client,"/workspace/log/retrieve",t,Ch,ZN);return ce("Log",t,r.logs,e),e?r.logs[0]:r.logs}async delete(t){await w(this.client,"/workspace/log/delete",{keys:O.toArray(t)},MN,ts)}};const $h=K("log"),RN=$h(""),LN=Object.freeze(Object.defineProperty({__proto__:null,Client:jh,TYPE_ONTOLOGY_ID:RN,keyZ:$t,logZ:Zn,newZ:xh,ontologyID:$h,retrieveArgsZ:Ch},Symbol.toStringTag,{value:"Module"})),dt=a.z.uuid(),Un=a.z.object({key:dt,name:a.z.string(),data:ze.unknownZ.or(a.z.string().transform(Re)),snapshot:a.z.boolean()}),Mh=Un.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),ei=Un.extend({data:a.z.string().transform(Re)}),rr=a.z.uuid(),_h=a.z.object({key:a.z.string(),name:a.z.string(),selectors:a.z.string().array().default([]),strokeColor:a.z.string().optional(),fillColor:a.z.string().optional()}),Zh=a.z.object({key:a.z.string(),name:a.z.string(),regions:_h.array()}),Uh=a.z.object({key:a.z.string(),position:ga.xy,orientation:Yy.outer}),DN=a.z.object({zoom:a.z.number().positive().default(1),position:ga.xy}),Ph=a.z.object({svg:a.z.string().min(1,"SVG is required"),states:Zh.array(),variant:a.z.string().min(1,"Variant is required"),handles:Uh.array(),scale:a.z.number().positive().default(1),scaleStroke:a.z.boolean().default(!1),previewViewport:DN.default({zoom:1,position:{x:0,y:0}})}),Pn=a.z.object({key:rr,version:a.z.literal(1).default(1),name:a.z.string().min(1,"Name is required"),data:Ph}),Rh=Pn.partial({key:!0}),BN=a.z.object({symbols:Rh.array(),parent:F}),FN=a.z.object({key:rr,name:a.z.string()}),qN=a.z.object({keys:rr.array()}),YN=a.z.object({keys:rr.array().optional(),searchTerm:a.z.string().optional()}),VN=a.z.object({key:rr}).transform(({key:t})=>({keys:[t]})),HN=a.z.union([VN,YN]),WN=a.z.object({symbols:O.nullableZ(Pn)}),GN=a.z.object({symbols:Pn.array()}),go=a.z.object({}),KN=a.z.object({}),JN=a.z.object({group:bn}),XN="sy_schematic_symbol_set",QN="sy_schematic_symbol_delete";let Lh=class{client;constructor(t){this.client=t}async create(t){const e="symbols"in t,r=e?t.symbols:[t],n=await w(this.client,"/workspace/schematic/symbol/create",{symbols:r,parent:t.parent},BN,GN);return e?n.symbols:n.symbols[0]}async rename(t,e){await w(this.client,"/workspace/schematic/symbol/rename",{key:t,name:e},FN,go)}async retrieve(t){const e="key"in t,r=await w(this.client,"/workspace/schematic/symbol/retrieve",t,HN,WN);return ce("Schematic Symbol",t,r.symbols,e),e?r.symbols[0]:r.symbols}async delete(t){await w(this.client,"/workspace/schematic/symbol/delete",{keys:O.toArray(t)},qN,go)}async retrieveGroup(){return(await w(this.client,"/workspace/schematic/symbol/retrieve_group",{},KN,JN)).group}};const eE=K("schematic_symbol"),tE=Object.freeze(Object.defineProperty({__proto__:null,Client:Lh,DELETE_CHANNEL_NAME:QN,SET_CHANNEL_NAME:XN,handleZ:Uh,keyZ:rr,newZ:Rh,ontologyID:eE,regionZ:_h,specZ:Ph,stateZ:Zh,symbolZ:Pn},Symbol.toStringTag,{value:"Module"})),rE=a.z.object({key:dt,name:a.z.string()}),nE=a.z.object({key:dt,data:a.z.string()}),sE=a.z.object({keys:dt.array()}),aE=a.z.object({key:dt,name:a.z.string(),snapshot:a.z.boolean()}),iE=a.z.object({keys:dt.array()}),Dh=a.z.object({key:dt}).transform(({key:t})=>({keys:[t]})),Bh=a.z.union([Dh,iE]),oE=a.z.object({schematics:O.nullableZ(ei)}),cE=a.z.object({workspace:Le,schematics:Mh.array()}),lE=a.z.object({schematics:ei.array()}),uE=a.z.object({schematic:Un}),rs=a.z.object({});let Fh=class{symbols;client;constructor(t){this.client=t,this.symbols=new Lh(t)}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/schematic/create",{workspace:t,schematics:O.toArray(e)},cE,lE);return r?n.schematics:n.schematics[0]}async rename(t,e){await w(this.client,"/workspace/schematic/rename",{key:t,name:e},rE,rs)}async setData(t,e){await w(this.client,"/workspace/schematic/set-data",{key:t,data:JSON.stringify(e)},nE,rs)}async retrieve(t){const e=Dh.safeParse(t).success,r=await w(this.client,"/workspace/schematic/retrieve",t,Bh,oE);return ce("Schematic",t,r.schematics,e),e?r.schematics[0]:r.schematics}async delete(t){await w(this.client,"/workspace/schematic/delete",{keys:O.toArray(t)},sE,rs)}async copy(t){return(await w(this.client,"/workspace/schematic/copy",t,aE,uE)).schematic}};const qh=K("schematic"),hE=qh(""),dE=Object.freeze(Object.defineProperty({__proto__:null,Client:Fh,TYPE_ONTOLOGY_ID:hE,keyZ:dt,newZ:Mh,ontologyID:qh,remoteZ:ei,retrieveArgsZ:Bh,schematicZ:Un,symbol:tE},Symbol.toStringTag,{value:"Module"})),Mt=a.z.uuid(),ti=a.z.object({key:Mt,name:a.z.string(),data:ze.unknownZ.or(a.z.string().transform(Re))}),Yh=ti.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),ri=ti.extend({data:a.z.string().transform(Re)}),fE=a.z.object({key:Mt,name:a.z.string()}),pE=a.z.object({key:Mt,data:a.z.string()}),yE=a.z.object({keys:Mt.array()}),mE=a.z.object({keys:Mt.array()}),Vh=a.z.object({key:Mt}).transform(({key:t})=>({keys:[t]})),Hh=a.z.union([Vh,mE]),gE=a.z.object({tables:O.nullableZ(ri)}),wE=a.z.object({workspace:Le,tables:Yh.array()}),bE=a.z.object({tables:ri.array()}),ns=a.z.object({});let Wh=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/table/create",{workspace:t,tables:O.toArray(e)},wE,bE);return r?n.tables:n.tables[0]}async rename(t,e){await w(this.client,"/workspace/table/rename",{key:t,name:e},fE,ns)}async setData(t,e){await w(this.client,"/workspace/table/set-data",{key:t,data:JSON.stringify(e)},pE,ns)}async retrieve(t){const e=Vh.safeParse(t).success,r=await w(this.client,"/workspace/table/retrieve",t,Hh,gE);return ce("Table",t,r.tables,e),e?r.tables[0]:r.tables}async delete(t){await w(this.client,"/workspace/table/delete",{keys:O.toArray(t)},yE,ns)}};const Gh=K("table"),vE=Gh(""),zE=Object.freeze(Object.defineProperty({__proto__:null,Client:Wh,TYPE_ONTOLOGY_ID:vE,keyZ:Mt,newZ:Yh,ontologyID:Gh,remoteZ:ri,retrieveArgsZ:Hh,tableZ:ti},Symbol.toStringTag,{value:"Module"})),OE=a.z.object({keys:Le.array().optional(),searchTerm:a.z.string().optional(),author:Pe.optional(),offset:a.z.int().optional(),limit:a.z.int().optional()}),TE=a.z.object({workspaces:Th.array()}),kE=a.z.object({key:Le,name:a.z.string()}),SE=a.z.object({key:Le,layout:ze.unknownZ.transform(t=>JSON.stringify(t))}),NE=a.z.object({keys:Le.array()}),EE=a.z.object({workspaces:O.nullableZ(_n)}),AE=a.z.object({workspaces:kh.array()}),ss=a.z.object({}),xE="sy_workspace_set",IE="sy_workspace_delete";class Kh{schematics;lineplots;logs;tables;client;constructor(e){this.client=e,this.schematics=new Fh(e),this.lineplots=new Eh(e),this.logs=new jh(e),this.tables=new Wh(e)}async create(e){const r=Array.isArray(e),n=await w(this.client,"/workspace/create",{workspaces:O.toArray(e)},TE,AE);return r?n.workspaces:n.workspaces[0]}async rename(e,r){await w(this.client,"/workspace/rename",{key:e,name:r},kE,ss)}async setLayout(e,r){await w(this.client,"/workspace/set-layout",{key:e,layout:r},SE,ss)}async retrieve(e){let r;const n=typeof e!="string";typeof e=="string"||Array.isArray(e)?r={keys:O.toArray(e)}:r=e;const s=await w(this.client,"/workspace/retrieve",r,OE,EE);return n?s.workspaces:s.workspaces[0]}async delete(e){await w(this.client,"/workspace/delete",{keys:O.toArray(e)},NE,ss)}}const Jh=K("workspace"),CE=Jh(""),jE=Object.freeze(Object.defineProperty({__proto__:null,Client:Kh,DELETE_CHANNEL_NAME:IE,SET_CHANNEL_NAME:xE,TYPE_ONTOLOGY_ID:CE,keyZ:Le,newZ:Th,ontologyID:Jh,remoteZ:kh,workspaceZ:_n},Symbol.toStringTag,{value:"Module"})),Xh=a.z.object({host:a.z.string({error:"Host is required"}).min(1,"Host is required"),port:a.z.number({error:"Port is required"}).or(a.z.string({error:"Port is required"})),username:a.z.string().min(1,"Username is required"),password:a.z.string().min(1,"Password is required"),connectivityPollFrequency:E.z.default(E.seconds(30)),secure:a.z.boolean().default(!1),name:a.z.string().optional(),retry:va.breakerConfigZ.optional()});class $E extends Du{createdAt;params;ranges;channels;auth;users;access;connectivity;ontology;workspaces;labels;statuses;tasks;racks;devices;control;arcs;views;static connectivity=Ls;transport;clientVersion="0.50.0";constructor(e){const r=Xh.parse(e),{host:n,port:s,username:i,password:o,connectivityPollFrequency:c,secure:l,retry:u}=r,h=new wh(new Lt({host:n,port:Number(s)}),u,l);h.use(sw);const f=new Fa(new Ba(h.unary));super(h.stream,h.unary,f),this.auth=new Lk(h.unary,{username:i,password:o}),h.use(this.auth.middleware());const d=new Su(h.unary,f);this.createdAt=C.now(),this.params=r,this.transport=h,this.channels=new Tu(this,f,h.unary,d),this.connectivity=new Ls(h.unary,c,this.clientVersion,r.name),this.control=new qu(this),this.ontology=new ml(h.unary,this);const z=new ah(this.transport.unary);this.labels=new wu(this.transport.unary),this.statuses=new ch(this.transport.unary),this.ranges=new nh(this,z,this.transport.unary,f,this.labels,this.ontology),this.access=new xl(this.transport.unary),this.users=new Tl(this.transport.unary),this.workspaces=new Kh(this.transport.unary),this.tasks=new ph(this.transport.unary,this,this.ontology,this.ranges),this.racks=new Qu(this.transport.unary,this.tasks),this.devices=new Xu(this.transport.unary),this.arcs=new cu(this.transport.unary,this.transport.stream),this.views=new vh(this.transport.unary)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stop()}}const ME=async t=>await Qh(t).check(),Qh=t=>{const{host:e,port:r,secure:n,name:s,retry:i}=t,o=va.breakerConfigZ.optional().parse(i),c=new Lt({host:e,port:Number(r)}),l=new wh(c,o,n);return new Ls(l.unary,void 0,"0.50.0",s)};E.seconds(1);class Vt{_noop=!1;key;path;serviceName;constructor(e,r,n="",s=!1){this.key=e,this.path=r,this.serviceName=n,this._noop=s}child(e){return new Vt(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}static NOOP=new Vt("","","")}const Ys=["debug","info","warn","error"],ed=t=>{const e=Ys.indexOf(t);return({level:r})=>Ys.indexOf(r)>=e},_E=t=>{const{include:e,exclude:r}=t;return({path:n})=>!(e!=null&&!e.some(s=>n.startsWith(s))||r!=null&&r.some(s=>n.startsWith(s)))};class Ht{meta=Vt.NOOP;filters;constructor(e={}){const{filters:r=[]}=e;this.filters=r}filter(e){return!this.meta.noop&&this.filters.every(r=>r({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const r=new Ht({filters:this.filters});return r.meta=e,r}debug(e,r,n=!1){!this.filter("debug")&&!n||(r==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,tn(r)))}info(e,r,n=!1){!this.filter("info")&&!n||(r==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,tn(r)))}warn(e,r,n=!1){!this.filter("warn")&&!n||(r==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,tn(r)))}error(e,r,n=!1){!this.filter("error")&&!n||(r==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,tn(r)))}static NOOP=new Ht}const tn=t=>typeof t=="function"?t():t;var ZE=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},gt="1.9.0",wo=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function UE(t){var e=new Set([t]),r=new Set,n=t.match(wo);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(c){return c===t};function i(c){return r.add(c),!1}function o(c){return e.add(c),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(wo);if(!l)return i(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||s.major!==u.major?i(c):s.major===0?s.minor===u.minor&&s.patch<=u.patch?o(c):i(c):s.minor<=u.minor?o(c):i(c)}}var PE=UE(gt),RE=gt.split(".")[0],Tr=Symbol.for("opentelemetry.js.api."+RE),kr=ZE;function ni(t,e,r,n){var s;n===void 0&&(n=!1);var i=kr[Tr]=(s=kr[Tr])!==null&&s!==void 0?s:{version:gt};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==gt){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+gt);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+gt+"."),!0}function Sr(t){var e,r,n=(e=kr[Tr])===null||e===void 0?void 0:e.version;if(!(!n||!PE(n)))return(r=kr[Tr])===null||r===void 0?void 0:r[t]}function si(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+gt+".");var r=kr[Tr];r&&delete r[t]}var LE=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},DE=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},BE=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nr("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nr("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nr("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nr("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nr("verbose",this._namespace,e)},t})();function nr(t,e,r){var n=Sr("diag");if(n)return r.unshift(e),n[t].apply(n,DE([],LE(r),!1))}var le;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(le||(le={}));function FE(t,e){t<le.NONE?t=le.NONE:t>le.ALL&&(t=le.ALL),e=e||{};function r(n,s){var i=e[n];return typeof i=="function"&&t>=s?i.bind(e):function(){}}return{error:r("error",le.ERROR),warn:r("warn",le.WARN),info:r("info",le.INFO),debug:r("debug",le.DEBUG),verbose:r("verbose",le.VERBOSE)}}var qE=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},YE=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},VE="diag",Nr=(function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var c=Sr("diag");if(c)return c[s].apply(c,YE([],qE(i),!1))}}var r=this,n=function(s,i){var o,c,l;if(i===void 0&&(i={logLevel:le.INFO}),s===r){var u=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=u.stack)!==null&&o!==void 0?o:u.message),!1}typeof i=="number"&&(i={logLevel:i});var h=Sr("diag"),f=FE((c=i.logLevel)!==null&&c!==void 0?c:le.INFO,s);if(h&&!i.suppressOverrideMessage){var d=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";h.warn("Current logger will be overwritten from "+d),f.warn("Current logger will overwrite one already registered from "+d)}return ni("diag",f,r,!0)};r.setLogger=n,r.disable=function(){si(VE,r)},r.createComponentLogger=function(s){return new BE(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})(),HE=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},WE=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},GE=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=HE(e,2),n=r[0],s=r[1];return[n,s]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var i=new t(this._entries);try{for(var o=WE(n),c=o.next();!c.done;c=o.next()){var l=c.value;i._entries.delete(l)}}catch(u){e={error:u}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t})();Nr.instance();function KE(t){return t===void 0&&(t={}),new GE(new Map(Object.entries(t)))}function JE(t){return Symbol.for(t)}var XE=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var i=new t(r._currentContext);return i._currentContext.set(n,s),i},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t})(),QE=new XE,eA={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},tA={set:function(t,e,r){t!=null&&(t[e]=r)}},rA=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},nA=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},sA=(function(){function t(){}return t.prototype.active=function(){return QE},t.prototype.with=function(e,r,n){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return r.call.apply(r,nA([n],rA(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})(),aA=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},iA=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},as="context",oA=new sA,td=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ni(as,e,Nr.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,iA([e,r,n],aA(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Sr(as)||oA},t.prototype.disable=function(){this._getContextManager().disable(),si(as,Nr.instance())},t})(),Vs;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Vs||(Vs={}));var cA=td.getInstance(),lA=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})(),ai=JE("OpenTelemetry Baggage Key");function rd(t){return t.getValue(ai)||void 0}function uA(){return rd(td.getInstance().active())}function hA(t,e){return t.setValue(ai,e)}function dA(t){return t.deleteValue(ai)}var is="propagation",fA=new lA,pA=(function(){function t(){this.createBaggage=KE,this.getBaggage=rd,this.getActiveBaggage=uA,this.setBaggage=hA,this.deleteBaggage=dA}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ni(is,e,Nr.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=tA),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=eA),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){si(is,Nr.instance())},t.prototype._getGlobalPropagator=function(){return Sr(is)||fA},t})(),yA=pA.getInstance();const bo=["bench","debug","prod"],mA=t=>e=>bo.indexOf(e)>=bo.indexOf(t);class Er{meta=Vt.NOOP;otelTracer;filter;constructor(e,r=mA("debug")){this.otelTracer=e,this.filter=r}child(e){const r=new Er(this.otelTracer,this.filter);return r.meta=e,r}debug(e,r){return this.trace(e,"debug",r)}bench(e,r){return this.trace(e,"bench",r)}prod(e,r){return this.trace(e,"prod",r)}trace(e,r,n){const s=this.meta.noop||!this.filter(r)||this.otelTracer==null;if(n==null){if(s)return()=>{};const i=new Hs(e,this.otelTracer.startSpan(e));return i.start(),()=>i.end()}return s?n(new nd(e)):this.otelTracer.startActiveSpan(e,i=>{const o=new Hs(e,i);return n(o)})}propagate(e){if(this.meta.noop)return;const r=cA.active();yA.inject(r,e,{set:(n,s,i)=>{n[s]=i}})}static NOOP=new Er}class Hs{key;otel;constructor(e,r){this.key=e,this.otel=r}set(e,r){this.otel.setAttribute(e,r)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:Vs.ERROR}))}start(){performance.mark(`alamos.trace.start.${this.key}`)}end(){try{performance.mark(`alamos.trace.end.${this.key}`);const e=performance.measure(`alamos.trace.duration.${this.key}`,`alamos.trace.start.${this.key}`,`alamos.trace.end.${this.key}`);this.set("duration",e.duration),this.otel.end()}catch(e){console.error(e)}}}class nd{key;constructor(e){this.key=e}set(){}recordError(e){}}class Wt{meta;T;L;constructor({key:e="",serviceName:r="",logger:n=Ht.NOOP,tracer:s=Er.NOOP,noop:i=!1,__meta:o}){this.meta=o??new Vt(e,e,r,i),this.T=s.child(this.meta),this.L=n.child(this.meta)}child(e){const r=this.meta.child(e);return new Wt({__meta:r,tracer:this.T,logger:this.L})}static NOOP=new Wt({noop:!0})}const gA=Wt.NOOP,sd=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:Wt,LOG_LEVELS:Ys,Logger:Ht,NOOP:gA,NoopSpan:nd,Tracer:Er,_Span:Hs,logLevelKeyFiler:_E,logThresholdFilter:ed},Symbol.toStringTag,{value:"Module"})),Ws=(t,e,r="")=>{try{return t.parse(e)}catch(n){if(n instanceof a.z.ZodError){const s=n.issues.map(i=>i.path.length===0?i.message:`${i.path.join(".")}: ${i.message}`);throw new Error(`${r} - ${s.join(`
|
|
66
|
-
`)}`)}else throw n}},os=(t,e)=>t instanceof Error?(t.message=`[${e}] - ${t.message}`,t):new Error(e??"unknown error",{cause:t}),ii=t=>{const e=t._zod.def.output;return e instanceof a.z.ZodVoid||e instanceof a.z.ZodNever||e instanceof a.z.ZodUnknown};class oi{type;key;sender;_internalState;_state;_prevState;_deleted=!1;parentCtxValues;childCtxValues;childCtxChangedKeys;instrumentation;schema=void 0;methods=void 0;_methodImplementations=null;constructor({key:e,type:r,sender:n,instrumentation:s,parentCtxValues:i}){this.type=r,this.key=e,this.sender=n,this._internalState={},this.instrumentation=s.child(this.toString()),this.parentCtxValues=new Map,i?.forEach((o,c)=>this.parentCtxValues.set(c,o)),this.childCtxValues=new Map,this.childCtxChangedKeys=new Set}initializeMethods(){if(!(this.methods==null||this._methodImplementations!=null)){this._methodImplementations={};for(const[e,r]of Object.entries(this.methods)){const n=this[e];if(typeof n!="function")throw new Error(`Method ${e} is not a function`);this._methodImplementations[e]=ii(r)?r.implement(n.bind(this)):r.implementAsync(n.bind(this))}}}get _schema(){if(this.schema==null)throw new W(`[AetherLeaf] - expected subclass to define component schema, but none was found.
|
|
67
|
-
Make sure to define a property 'schema' on the class.`);return this.schema}setState(e){const r=Qe.executeSetter(e,this.state);this._prevState=A.il.copy(this._state),this._state=Ws(this._schema,r,`${this.toString()}`),this.sender.send({variant:"update",key:this.key,state:this._state})}get state(){if(this._state==null)throw new ie(`[AetherLeaf] - state not defined in ${this.toString()}`);return this._state}get internal(){return this._internalState}get prevState(){if(this._prevState===void 0)throw new Error("prevState not defined");return this._prevState}get deleted(){return this._deleted}get ctx(){return{get:e=>{const r=this.parentCtxValues.get(e);if(r===void 0)throw new Tt(`Context value for ${e} not found on ${this.toString()}`);return r},getOptional:e=>this.parentCtxValues.get(e),has:e=>this.parentCtxValues.has(e),wasSetPreviously:e=>this.childCtxValues.has(e),set:(e,r,n=!0)=>{this.childCtxValues.set(e,r),n&&this.childCtxChangedKeys.add(e)}}}toString(){return`${this.type}(${this.key})`}_updateState({path:e,state:r}){if(!this.deleted)try{this.initializeMethods();const n=this.instrumentation.T.debug(`${this.toString()}:updateState`);this.validatePath(e);const s=Ws(this._schema,r,`${this.toString()}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:A.Vu.difference(this.state,s)})):this.instrumentation.L.debug("setting initial state",{state:r,path:e}),this._prevState=this._state??s,this._state=s,this.afterUpdate(this.ctx),n()}catch(n){throw os(n,`${this.toString()}.updateState`)}}_updateContext(e){try{const r=this.instrumentation.T.debug(`${this.toString()}:updateContext`);e.forEach((n,s)=>this.parentCtxValues.set(s,n)),this.afterUpdate(this.ctx),r()}catch(r){throw os(r,`${this.type}.${this.key}.updateContext`)}}_delete(e){try{const r=this.instrumentation.T.debug(`${this.toString()}:delete`);this.validatePath(e),this._deleted=!0,this.afterDelete(this.ctx),r()}catch(r){throw os(r,`[${this.toString()}:delete]`)}}afterUpdate(e){}afterDelete(e){}validatePath(e){if(e.length===0)throw new ie(`[Leaf.setState] - ${this.toString()} received an empty path`);const r=e[e.length-1];if(e.length>1)throw new ie(`[Leaf.setState] - ${this.toString()} received a subPath ${e.join(".")} but is a leaf`);if(r!==this.key)throw new ie(`[Leaf.setState] - ${this.toString()} received a key ${r} but expected ${this.key}`)}handleInvokeError({method:e,key:r,args:n},s){if(!(r!=null))return console.error(`Error in fire and forget method ${e} on ${this.toString()}`,s);const o=s instanceof Error?s:new Error(String(s));this.sender.send({variant:"invoke_response",key:r,result:void 0,error:{name:o.name,message:`Failed to execute ${e}(${r}) with args ${JSON.stringify(n)} on ${this.toString()}: ${o.message}`,stack:o.stack??""}})}_invokeMethod(e){if(this.deleted)return;const{method:r,key:n,args:s}=e,i=n!=null,o=this._methodImplementations?.[r];if(o==null)return this.handleInvokeError(e,new Error(`Method ${r} not found on ${this.toString()}`));try{const c=o(...s);c instanceof Promise&&c.then(l=>{i&&this.sender.send({variant:"invoke_response",key:n,result:l})}).catch(l=>this.handleInvokeError(e,l))}catch(c){this.handleInvokeError(e,c)}}}class qr extends oi{_children=new Map;get children(){return Array.from(this._children.values())}getChild(e){return this._children.get(e)??null}childrenOfType(...e){return this.children.filter(r=>e.includes(r.type))}_updateState(e){const{path:r,type:n,create:s}=e;if(this.deleted)return;const i=this.parsePath(r);if(i.length===0){if(this.childCtxChangedKeys.clear(),super._updateState(e),this.childCtxChangedKeys.size==0)return;this.updateChildContexts();return}const c=i[0],l=this.getChild(c);if(l!=null)return l._updateState({...e,path:i});if(i.length>1){const h=r.slice(0,r.indexOf(c)+1).join("."),f=r.join(".");throw new ie(`Child of ${this.toString()} at path ${h} does not exist,
|
|
68
|
-
but an extended path ${f} was provided. This means that the aether
|
|
69
|
-
tree is attempting to create a new child of type ${n} (or nested children)
|
|
70
|
-
on a child that does not exist.
|
|
71
|
-
|
|
72
|
-
Children present: ${this.children.map(d=>`${d.type}:${d.key}`).join(".")}
|
|
73
|
-
|
|
74
|
-
`)}const u=s(this.childCtx());u._updateState({...e,path:i}),this._children.set(c,u)}_updateContext(e){super._updateContext(e),this.updateChildContexts()}childCtx(){return{get:e=>this.childCtxValues.get(e)??this.parentCtxValues.get(e),forEach:e=>{this.childCtxValues.forEach((r,n)=>e(r,n,this.childCtxValues)),this.parentCtxValues.forEach((r,n)=>{this.childCtxValues.has(n)||e(r,n,this.parentCtxValues)})}}}updateChildContexts(){const e=this.childCtx();this.children.forEach(r=>r._updateContext(e))}_delete(e){const r=this.parsePath(e);if(r.length===0){for(const s of this.children)s._delete([s.key]);this._children.clear(),super._delete([this.key])}const n=this.getChild(r[0]);if(n!=null){if(r.length>1)return n._delete(r);this._children.delete(n.key),n._delete(r)}}findChildAtPath(e){if(e.length===0)return null;const[r,...n]=e,s=this.getChild(r);return s==null?null:n.length===0?s:"findChildAtPath"in s&&typeof s.findChildAtPath=="function"?s.findChildAtPath(n):null}parsePath(e,r){const[n,...s]=e;if(n==null)throw new Error(`Composite ${this.toString()} received an empty path${r!=null?` for ${r}`:""}`);if(n!==this.key)throw new ie(`[Composite.getRequiredKey] - ${this.toString()} received a key ${n} but expected ${this.key}`);return s}}const wA=a.z.object({}),bA=()=>{throw new Error("should not call create")};class $e extends qr{static TYPE="root";static KEY="root";comms;registry;schema=wA;constructor({comms:e,instrumentation:r=sd.Instrumentation.NOOP,registry:n}){super({key:$e.KEY,type:$e.TYPE,sender:e,instrumentation:r,parentCtxValues:null}),this.comms=e,this.registry=n}static render(e){const r=new $e(e);return r._updateState({path:[$e.KEY],type:"",state:{},create:bA}),r.comms.handle(n=>{try{r.handle(n)}catch(s){const i={name:"unknown",message:JSON.stringify(s),stack:"unknown"};s instanceof Error&&(i.name=s.name,i.message=s.message,i.stack=s.stack),r.comms.send({variant:"error",error:i})}}),r}handle(e){const{variant:r}=e;if(r==="invoke_request"){this.invokeAtPath(e);return}const{path:n,type:s}=e;if(r==="delete"){this._delete(n);return}const{state:i}=e;this._updateState({path:n,type:s,state:i,create:o=>{const c=n[n.length-1];return this.create({key:c,type:s,parentCtxValues:o})}})}invokeAtPath(e){const{path:r}=e,[n,...s]=r;if(n!==$e.KEY){this.handleInvokeError(e,new Error(`Invalid path: expected root key '${$e.KEY}', got '${n}'`));return}if(s.length===0){this._invokeMethod(e);return}const i=this.findChildAtPath(s);if(i==null){this.handleInvokeError(e,new Tt(`Component at path ${r.join(".")} not found`));return}i._invokeMethod(e)}create({key:e,type:r,parentCtxValues:n}){const s=this.registry[r];if(s==null)throw new ie(`[Root.create] - ${r} not found in registry`);return new s({key:e,type:r,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:n})}}const ad=$e.render.bind($e),vA=Object.freeze(Object.defineProperty({__proto__:null,Composite:qr,Leaf:oi,Root:$e,isFireAndForget:ii,render:ad},Symbol.toStringTag,{value:"Module"})),zA=(t,e)=>Array.isArray(e)?e.some(r=>r.matches(t)):e?.matches(t)??!1,OA=t=>{const e=[`${t.variant.toUpperCase()}: ${t.message}`];if(t.description)try{const r=JSON.parse(t.description);e.push(`Description:
|
|
75
|
-
${JSON.stringify(r,null,2)}`)}catch{e.push(`Description: ${t.description}`)}"details"in t&&A.yu.isObject(t.details)&&"stack"in t.details&&e.push(`Stack Trace:
|
|
76
|
-
${String(t.details.stack)}`),console.error(e.join(`
|
|
77
|
-
|
|
78
|
-
`))},id=(t,e,r)=>{const n=A.ol.fromException(t,e);return OA(n),zA(t,r)?null:n},od=(t,e,r,n)=>{if(typeof t=="function")return!0;const s=id(t,r,n);return s!=null&&e(s),!1},cd=async(t,e,r,n)=>{try{const s=t();s!=null&&await s}catch(s){const i=id(s,r,n);if(i!=null)return e(i)}},ld=t=>(e,r,n)=>{od(e,t,r,n)&&cd(e,t,r,n)},ud=t=>async(e,r,n)=>{od(e,t,r,n)&&await cd(e,t,r,n)},hd=a.z.object({statuses:A.ol.statusZ().array()}),pn="status.aggregator";class Gs extends qr{static TYPE="status.Aggregator";schema=hd;afterUpdate(e){e.wasSetPreviously(pn)||e.set(pn,{add:this.add.bind(this),create:A.ol.create})}add(e){this.setState(r=>({...r,statuses:[...r.statuses,A.ol.create(e)]}))}}const ci=t=>t.get(pn).add,TA=t=>{const e=t.getOptional(pn);return e!=null?e.add:()=>{}},dd=t=>ld(ci(t)),kA=t=>ud(ci(t)),SA={[Gs.TYPE]:Gs},NA=a.z.object({l0:A.Zu.colorZ,l1:A.Zu.colorZ,l2:A.Zu.colorZ,l3:A.Zu.colorZ,l4:A.Zu.colorZ,l5:A.Zu.colorZ,l6:A.Zu.colorZ,l7:A.Zu.colorZ,l8:A.Zu.colorZ,l9:A.Zu.colorZ,l10:A.Zu.colorZ,l11:A.Zu.colorZ}),ge=(t,e)=>[t[0],t[1],e,t[3]],EA=a.z.object({m2:A.Zu.colorZ,m1:A.Zu.colorZ,z:A.Zu.colorZ,p1:A.Zu.colorZ,p2:A.Zu.colorZ}),rn=EA.or(A.Zu.colorZ.transform(t=>{const e=A.Zu.hsla(t);return{m2:A.Zu.fromHSLA(ge(e,40)),m1:A.Zu.fromHSLA(ge(e,45)),z:t,p1:A.Zu.fromHSLA(ge(e,55)),p2:A.Zu.fromHSLA(ge(e,65))}})),fd=a.z.object({name:a.z.string(),key:a.z.string(),colors:a.z.object({border:A.Zu.colorZ,primary:rn,gray:NA,error:rn,secondary:rn,warning:rn,palettes:a.z.record(a.z.string(),A.Zu.paletteZ),visualization:a.z.object({palettes:a.z.record(a.z.string(),a.z.array(A.Zu.colorZ))}).default({palettes:{}}),white:A.Zu.colorZ,black:A.Zu.colorZ,text:A.Zu.colorZ,textInverted:A.Zu.colorZ,textOnPrimary:A.Zu.colorZ.default(A.Zu.ZERO),primaryText:A.Zu.colorZ,errorText:A.Zu.colorZ,warningText:A.Zu.colorZ,logo:a.z.string()}),sizes:a.z.object({base:a.z.number(),border:a.z.object({radius:a.z.number(),width:a.z.number(),thickWidth:a.z.number()}),schematic:a.z.object({elementStrokeWidth:a.z.number()})}),typography:a.z.object({family:a.z.string(),codeFamily:a.z.string(),h1:Qe.specZ,h2:Qe.specZ,h3:Qe.specZ,h4:Qe.specZ,h5:Qe.specZ,p:Qe.specZ,small:Qe.specZ})}).transform(t=>((t.colors.textOnPrimary==null||A.Zu.isZero(t.colors.textOnPrimary))&&(t.colors.textOnPrimary=A.Zu.pickByContrast(t.colors.primary.z,t.colors.text,t.colors.textInverted)),t)),AA='"Inter Variable", sans-serif',xA='"Geist Mono", monospace',IA=6,sr=[357,91,55,1],ar=[48,90,55,1],CA=["#FEFEFE","#FAFAFA","#F2F2F2","#ECECEC","#E4E4E4","#D1D1D1","#BCBCBC","#ACACAC","#8F8F8F","#4F4F4F","#292929","#050505"],ir=Object.fromEntries(CA.map((t,e)=>[`l${e}`,t])),jA=()=>typeof window>"u"?!1:window.devicePixelRatio>1,$A=jA(),Ks={key:"synnaxBase",name:"Synnax Base",colors:{primary:{m2:"#041B3D",m1:"#356fc5",z:"#3774D0",p1:"#5E94EE",p2:"#8AB8FF"},secondary:{m2:"#2D8F4E",m1:"#38B261",z:"#50C878",p1:"#73D393",p2:"#96DEAE"},gray:ir,border:ir.l4,error:{m2:A.Zu.fromHSLA(ge(sr,30)),m1:A.Zu.fromHSLA(ge(sr,40)),z:A.Zu.fromHSLA(sr),p1:A.Zu.fromHSLA(ge(sr,65)),p2:A.Zu.fromHSLA(ge(sr,77))},warning:{m2:A.Zu.fromHSLA(ge(ar,30)),m1:A.Zu.fromHSLA(ge(ar,40)),z:A.Zu.fromHSLA(ar),p1:A.Zu.fromHSLA(ge(ar,65)),p2:A.Zu.fromHSLA(ge(ar,75))},palettes:{recent:{key:"recent",name:"Recent",swatches:[]}},visualization:{palettes:{default:["#DC136C","#20A4F3","#7AC74F","#FFC43D","#FE5F55","#8075FF","#D90429","#f7aef8","#f18f01","#791e94","#279af1","#d9fff5","#ff6b6b","#52ffb8"]}},logo:"url(#synnax-linear-gradient)",white:"#FFFFFF",black:"#000000",text:ir.l11,textInverted:ir.l0,textOnPrimary:ir.l0,primaryText:"#3b82f6",errorText:"#ef4444",warningText:"#f59e0b"},sizes:{base:IA,border:{radius:3,width:$A?.5:1,thickWidth:1},schematic:{elementStrokeWidth:2}},typography:{family:AA,codeFamily:xA,h1:{size:5.5,weight:"500",lineHeight:5.5*1.5},h2:{size:4.5,weight:"medium",lineHeight:4.5*1.5},h3:{size:3.5,weight:"medium",lineHeight:3.5*1.5},h4:{size:2.6666,weight:"medium",lineHeight:2.6666*1.5},h5:{size:2.333333,weight:450,lineHeight:2.333333*1.5},p:{size:2.1666666666,weight:"regular",lineHeight:2*1.5},small:{size:1.916666,weight:"regular",lineHeight:2.3333333}}},pd=Object.freeze({...Ks,key:"synnaxLight",name:"Synnax Light"}),MA=["#020202","#080808","#151515","#202020","#272727","#3B3B3B","#4A4A4A","#5C5C5C","#767676","#959595","#dadada","#FAFAFA"],or=Object.fromEntries(MA.map((t,e)=>[`l${e}`,t])),yd=Object.freeze({...Ks,key:"synnaxDark",name:"Synnax Dark",colors:{...Ks.colors,gray:or,logo:"var(--pluto-text-color)",border:or.l4,text:or.l11,textInverted:or.l0,textOnPrimary:or.l11,primaryText:"#93c5fd",errorText:"#fca5a5",warningText:"#fcd34d"}}),_A={synnaxDark:yd,synnaxLight:pd},md=["tiny","small","medium","large","huge"],gd=a.z.enum(md),ZA=t=>gd.safeParse(t).success,Js="pluto-theming-context",wd=a.z.object({name:a.z.string(),url:a.z.string()}),UA=a.z.object({theme:fd,fontURLs:a.z.array(wd)});class Ar extends qr{static TYPE="theming.Provider";static z=UA;schema=Ar.z;afterUpdate(e){if(e.getOptional(Js)!=null&&this.state.theme.key===this.prevState.theme.key)return;e.set(Js,this.state.theme),dd(e)(async()=>{await this.loadFonts()},"failed to load theme fonts")}async loadFonts(){await Promise.all(this.state.fontURLs.map(async({name:e,url:r})=>{const n=new FontFace(e,`url(${r})`);try{await n.load(),self.fonts.add(n)}catch(s){console.error(s)}}))}}const PA=t=>t.get(Js),RA={[Ar.TYPE]:Ar};exports.$A=vk;exports.$n=Tt;exports.Aggregator=Gs;exports.Composite=qr;exports.DA=US;exports.Gk=Xh;exports.HA=uN;exports.Hk=$E;exports.JA=CN;exports.Leaf=oi;exports.O=Wt;exports.PA=JS;exports.Provider=Ar;exports.QA=LN;exports.REGISTRY=RA;exports.REGISTRY$1=SA;exports.SA=Ob;exports.SIZES=md;exports.SYNNAX_DARK=yd;exports.SYNNAX_LIGHT=pd;exports.SYNNAX_THEMES=_A;exports.St=ie;exports.TA=ib;exports.UA=kS;exports.Vk=Qh;exports.W=W;exports.WA=ON;exports.YA=q0;exports._=Ht;exports.a$=ME;exports.aether=vA;exports.aggregatorStateZ=hd;exports.at=ot;exports.be=ed;exports.createAsyncErrorHandler=ud;exports.createErrorHandler=ld;exports.fA=tw;exports.fontSpecZ=wd;exports.g=sd;exports.g$1=E;exports.i$=jE;exports.isFireAndForget=ii;exports.isSize=ZA;exports.jA=wS;exports.kA=KT;exports.n$=dE;exports.pA=bw;exports.prettyParse=Ws;exports.qA=$0;exports.render=ad;exports.s$=zE;exports.size=gd;exports.themeZ=fd;exports.use=PA;exports.useAdder=ci;exports.useAsyncErrorHandler=kA;exports.useErrorHandler=dd;exports.useOptionalAdder=TA;exports.w=C;exports.wA=Aw;exports.xA=$k;exports.y=_;
|