@synnaxlabs/pluto 0.28.5 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +1 -1
  2. package/dist/{Animated-BpXi9NWe.js → Animated-CADTcu8B.js} +2 -2
  3. package/dist/{Animated-DFza4wCT.cjs → Animated-DZSBu1oS.cjs} +1 -1
  4. package/dist/{Keyboard-D7ybWHn0.js → Keyboard-Bc_uxMTG.js} +2 -2
  5. package/dist/{Keyboard-CbKUH8Eh.cjs → Keyboard-BvHL3Wf2.cjs} +1 -1
  6. package/dist/{LinePlot-BK8esSwO.js → LinePlot-CUYMMNNX.js} +2292 -2247
  7. package/dist/LinePlot-DUHbDcz3.cjs +66 -0
  8. package/dist/{Link-B8NxnNli.cjs → Link-BUlcFhdF.cjs} +1 -1
  9. package/dist/{Link-D2fnWjvq.js → Link-CurnG57L.js} +1 -1
  10. package/dist/{List-Dukgv-S0.js → List-DD-MkX0Z.js} +2 -2
  11. package/dist/{List-DFXYScV1.cjs → List-d1KJe77_.cjs} +1 -1
  12. package/dist/{Pack-BNnq0Pnk.cjs → Pack-BgzS2BHo.cjs} +1 -1
  13. package/dist/{Pack-CcDPYCmE.js → Pack-l3j3YWpE.js} +4 -2
  14. package/dist/{Toggle-m9N7HK8Z.js → Toggle-BGyo9v6o.js} +7898 -7846
  15. package/dist/Toggle-DWKDszrQ.cjs +143 -0
  16. package/dist/{Video-CA6Au-LV.js → Video-Ciw4h8eF.js} +1 -1
  17. package/dist/{Video-Ch_mMn__.cjs → Video-JYqTPKDk.cjs} +1 -1
  18. package/dist/aggregator-C7n8uv-R.cjs +57 -0
  19. package/dist/{aggregator-J7DZKy5x.js → aggregator-Dgqx_W5g.js} +2170 -2171
  20. package/dist/align.cjs +1 -1
  21. package/dist/align.js +1 -1
  22. package/dist/button.cjs +1 -1
  23. package/dist/button.js +1 -1
  24. package/dist/color.cjs +1 -1
  25. package/dist/color.js +1 -1
  26. package/dist/css-Cc1vb61S.cjs +1 -0
  27. package/dist/{css-BHfxGWOW.js → css-CiSR0WsA.js} +10 -10
  28. package/dist/css.cjs +1 -1
  29. package/dist/css.js +2 -2
  30. package/dist/dropdown.cjs +1 -1
  31. package/dist/dropdown.js +1 -1
  32. package/dist/ether.cjs +1 -1
  33. package/dist/ether.js +33 -32
  34. package/dist/{external-BrqfXbHQ.cjs → external--tP96O6n.cjs} +1 -1
  35. package/dist/{external-QDpeV2Bg.cjs → external-1ZU7gP__.cjs} +1 -1
  36. package/dist/{external-fuYYBaX1.cjs → external-5teQpcGD.cjs} +1 -1
  37. package/dist/{external-ecHPjGBQ.js → external-B-gkanM-.js} +4 -4
  38. package/dist/{external-DqipSbJg.js → external-B-qyhpkX.js} +2 -2
  39. package/dist/{external-D8deprwW.js → external-B0zpdR1h.js} +3 -3
  40. package/dist/{external-CObl_IIp.js → external-B6F5s5aQ.js} +4 -4
  41. package/dist/{external-DVOz9Cj-.cjs → external-B8UhV4HB.cjs} +1 -1
  42. package/dist/{external-Cv1PHg1z.js → external-B_mVlkww.js} +1 -1
  43. package/dist/{external-BdCCLUUg.js → external-BjZo74zS.js} +7 -7
  44. package/dist/{external-Cg7eMkiE.js → external-C2rLSz0G.js} +5 -5
  45. package/dist/{external-CpeeWTtO.cjs → external-C4beOlX2.cjs} +1 -1
  46. package/dist/{external-BEfayRpy.cjs → external-C5nr86pR.cjs} +1 -1
  47. package/dist/{external-Bad1CwNW.cjs → external-CNl6YOd-.cjs} +1 -1
  48. package/dist/{external-PZRTTZBD.cjs → external-CTth9RPW.cjs} +1 -1
  49. package/dist/{external-CuEzRxQ1.js → external-CW9xTNHG.js} +7 -7
  50. package/dist/{external-BCVvWczs.cjs → external-Clb-pmsS.cjs} +1 -1
  51. package/dist/{external-DY98yrhu.cjs → external-Co2r9DLy.cjs} +1 -1
  52. package/dist/{external-BMtI6oH4.js → external-CulLnj8B.js} +4 -4
  53. package/dist/{external-DsWUD-xw.js → external-Dds3S09i.js} +4 -4
  54. package/dist/{external-qVdtuqZn.js → external-Dh0igrIc.js} +5 -5
  55. package/dist/{external-DiHS7NGb.js → external-E30UptW0.js} +2 -2
  56. package/dist/{external-Drm1djcp.cjs → external-FuH8ekoj.cjs} +1 -1
  57. package/dist/{external-CwLyjDOU.cjs → external-HLgDxDKN.cjs} +1 -1
  58. package/dist/header.cjs +1 -1
  59. package/dist/header.js +1 -1
  60. package/dist/index.cjs +1 -1
  61. package/dist/index.js +2341 -2265
  62. package/dist/input.cjs +1 -1
  63. package/dist/input.js +1 -1
  64. package/dist/list.cjs +1 -1
  65. package/dist/list.js +1 -1
  66. package/dist/menu.cjs +1 -1
  67. package/dist/menu.js +1 -1
  68. package/dist/src/aether/aether/aether.d.ts.map +1 -1
  69. package/dist/src/align/Pack.d.ts.map +1 -1
  70. package/dist/src/breadcrumb/Breadcrumb.d.ts +6 -1
  71. package/dist/src/breadcrumb/Breadcrumb.d.ts.map +1 -1
  72. package/dist/src/icon/Icon.d.ts +1 -1
  73. package/dist/src/input/DragButton.d.ts.map +1 -1
  74. package/dist/src/menu/ContextMenu.d.ts +2 -2
  75. package/dist/src/menu/ContextMenu.d.ts.map +1 -1
  76. package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
  77. package/dist/src/status/aether/aggregator.d.ts.map +1 -1
  78. package/dist/src/status/aether/types.d.ts.map +1 -1
  79. package/dist/src/synnax/aether/provider.d.ts +18 -18
  80. package/dist/src/synnax/aether/provider.d.ts.map +1 -1
  81. package/dist/src/telem/aether/remote.d.ts.map +1 -1
  82. package/dist/src/telem/aether/transformers.d.ts.map +1 -1
  83. package/dist/src/telem/control/aether/chip.d.ts +12 -12
  84. package/dist/src/telem/control/aether/chip.d.ts.map +1 -1
  85. package/dist/src/telem/control/aether/indicator.d.ts.map +1 -1
  86. package/dist/src/telem/control/aether/legend.d.ts.map +1 -1
  87. package/dist/src/telem/control/aether/state.d.ts.map +1 -1
  88. package/dist/src/tooltip/wrap.d.ts.map +1 -1
  89. package/dist/src/triggers/Text.d.ts.map +1 -1
  90. package/dist/src/vis/canvas/aether/canvas.d.ts.map +1 -1
  91. package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
  92. package/dist/src/vis/diagram/aether/Diagram.d.ts.map +1 -1
  93. package/dist/src/vis/diagram/aether/types.d.ts.map +1 -1
  94. package/dist/src/vis/diagram/edge/connector/connector.d.ts.map +1 -1
  95. package/dist/src/vis/draw2d/canvas.d.ts +1 -1
  96. package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
  97. package/dist/src/vis/eraser/aether/eraser.d.ts.map +1 -1
  98. package/dist/src/vis/legend/Container.d.ts.map +1 -1
  99. package/dist/src/vis/light/aether/index.d.ts +2 -0
  100. package/dist/src/vis/light/aether/index.d.ts.map +1 -0
  101. package/dist/src/vis/light/aether/light.d.ts +112 -0
  102. package/dist/src/vis/light/aether/light.d.ts.map +1 -0
  103. package/dist/src/vis/light/index.d.ts +2 -0
  104. package/dist/src/vis/light/index.d.ts.map +1 -0
  105. package/dist/src/vis/light/use.d.ts +9 -0
  106. package/dist/src/vis/light/use.d.ts.map +1 -0
  107. package/dist/src/vis/lineplot/aether/LinePlot.d.ts.map +1 -1
  108. package/dist/src/vis/lineplot/aether/axis.d.ts.map +1 -1
  109. package/dist/src/vis/lineplot/range/aether/annotation.d.ts.map +1 -1
  110. package/dist/src/vis/lineplot/range/aether/provider.d.ts +40 -40
  111. package/dist/src/vis/lineplot/range/aether/provider.d.ts.map +1 -1
  112. package/dist/src/vis/lineplot/tooltip/aether/tooltip.d.ts.map +1 -1
  113. package/dist/src/vis/measure/aether/measure.d.ts.map +1 -1
  114. package/dist/src/vis/schematic/Forms.d.ts +1 -5
  115. package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
  116. package/dist/src/vis/schematic/Symbols.d.ts +15 -14
  117. package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
  118. package/dist/src/vis/schematic/primitives/Primitives.d.ts +13 -16
  119. package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
  120. package/dist/src/vis/schematic/registry.d.ts.map +1 -1
  121. package/dist/src/vis/value/aether/value.d.ts.map +1 -1
  122. package/dist/src/vis/value/use.d.ts.map +1 -1
  123. package/dist/style.css +1 -1
  124. package/dist/tabs.cjs +1 -1
  125. package/dist/tabs.js +1 -1
  126. package/dist/text.cjs +1 -1
  127. package/dist/text.js +2 -2
  128. package/dist/theming.cjs +1 -1
  129. package/dist/theming.js +2 -2
  130. package/dist/tree.cjs +1 -1
  131. package/dist/tree.js +1 -1
  132. package/dist/triggers.cjs +1 -1
  133. package/dist/triggers.js +1 -1
  134. package/dist/{units-t-SdMRna.js → units-BAK8qzqy.js} +1 -1
  135. package/dist/{units-CKv8dczK.cjs → units-C59nowP2.cjs} +1 -1
  136. package/dist/video.cjs +1 -1
  137. package/dist/video.js +1 -1
  138. package/package.json +21 -21
  139. package/dist/LinePlot-D-BHnuDg.cjs +0 -66
  140. package/dist/Toggle-CGbCK-dz.cjs +0 -143
  141. package/dist/aggregator-C5NNOlCt.cjs +0 -57
  142. package/dist/css-C4GOlJsi.cjs +0 -1
@@ -0,0 +1,66 @@
1
+ "use strict";var Vh=Object.defineProperty;var Xh=(t,e,n)=>e in t?Vh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var m=(t,e,n)=>Xh(t,typeof e!="symbol"?e+"":e,n);const E=require("./aggregator-C7n8uv-R.cjs"),T=require("zod"),f=require("./css-Cc1vb61S.cjs"),x=require("react");require("react-dom");const Gh=Object.freeze(Object.defineProperty({__proto__:null,ALIGNMENTS:f.u,ORDERS:f.d,alignment:f.D,order:f.j$1},Symbol.toStringTag,{value:"Module"}));var Wh=Object.defineProperty,Kh=(t,e,n)=>e in t?Wh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,br=(t,e,n)=>Kh(t,typeof e!="symbol"?e+"":e,n);class jh{constructor(e,n){br(this,"handlers"),br(this,"transform"),br(this,"closer"),this.transform=e,this.handlers=n??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let n=e;if(this.transform!=null){const[r,s]=this.transform(e);if(!s)return;n=r}this.handlers.forEach((r,s)=>s(n))}setCloser(e){this.closer=e}async close(){var e;return await((e=this.closer)==null?void 0:e.call(this))}}class Jh{constructor(e){br(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((n,r)=>r(e))}}const Mo=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Jh,Observer:jh},Symbol.toStringTag,{value:"Module"})),Qh=T.z.object({props:E.Ay.nullable(),state:E.$y.connectivity.connectionStateZ.nullable()}),Ao={synnax:null,state:E.$y.connectivity.DEFAULT};var Qt;let kr=(Qt=class extends E.Composite{constructor(){super(...arguments);m(this,"schema",Qt.stateZ)}async afterUpdate(){var n;if(this.ctx.has(No)||Ds(this.ctx,Ao),this.state.props==null){this.internal.synnax!=null&&(this.setState(r=>({...r,state:E.$y.connectivity.DEFAULT})),(n=this.internal.synnax)==null||n.close(),this.internal.synnax=null),Ds(this.ctx,this.internal);return}this.prevState.props!=null&&E._.equal(this.state.props,this.prevState.props)&&this.internal.synnax!=null||(this.internal.synnax=new E.$y(this.state.props),this.internal.synnax.connectivity.onChange(r=>this.setState(s=>({...s,state:r}))),Ds(this.ctx,this.internal))}},m(Qt,"TYPE","SynnaxProvider"),m(Qt,"stateZ",Qh),Qt);const No="pluto-client-context",Ds=(t,e)=>t.set(No,e),tr=t=>t.get(No).synnax,nc={[kr.TYPE]:kr},tf=Object.freeze(Object.defineProperty({__proto__:null,Provider:kr,REGISTRY:nc,ZERO_CONTEXT_VALUE:Ao,use:tr},Symbol.toStringTag,{value:"Module"})),rc="pluto-telem-context",gs=t=>t.get(rc),sc=(t,e)=>t.set(rc,e),oc=(t,e)=>gs(t).registerFactory(e);class Ni{constructor(e,n,r){m(this,"spec");m(this,"wrapped");m(this,"prevKey");this.wrapped=e,this.spec=r,this.prevKey=n.clusterKey}async value(){return await this.wrapped.value()}async cleanup(){var e,n;await((n=(e=this.wrapped).cleanup)==null?void 0:n.call(e))}onChange(e){return this.wrapped.onChange(e)}shouldUpdate(e,n){return this.prevKey!==e.clusterKey||!E._.equal(this.spec,n)}}class Di{constructor(e,n,r){m(this,"spec");m(this,"prov");m(this,"prevKey");m(this,"wrapped");this.wrapped=e,this.spec=r,this.prov=n,this.prevKey=n.clusterKey}async set(e){return await this.wrapped.set(e)}async cleanup(){var e,n;await((n=(e=this.wrapped).cleanup)==null?void 0:n.call(e))}shouldUpdate(e,n){return this.prevKey!==e.clusterKey||!E._.equal(this.spec,n)}}const Lt=async(t,e,n)=>{var s;const r=gs(t);if(n instanceof Ni){if(!n.shouldUpdate(r,e))return n;await((s=n.cleanup)==null?void 0:s.call(n))}return new Ni(r.create(e),r,e)},er=async(t,e,n)=>{var s;const r=gs(t);if(n instanceof Di){if(!n.shouldUpdate(r,e))return n;await((s=n.cleanup)==null?void 0:s.call(n))}return new Di(r.create(e),r,e)};class ve extends Mo.Observer{async cleanup(){}}class Mr extends ve{async set(){return await Promise.resolve()}}m(Mr,"TYPE","noop-boolean-sink");const ms={type:Mr.TYPE,props:{},variant:"sink",valueType:"boolean"};class Ar extends ve{async set(){return await Promise.resolve()}}m(Ar,"TYPE","noop-numeric-sink");const ic={type:Ar.TYPE,props:{},variant:"sink",valueType:"number"};class Nr extends ve{async value(){return await Promise.resolve(!1)}}m(Nr,"TYPE","noop-boolean-source");const Do={type:Nr.TYPE,props:{},variant:"source",valueType:"boolean"};class Dr extends ve{async value(){return 0}}m(Dr,"TYPE","noop-numeric-source");const ac={type:Dr.TYPE,props:{},variant:"source",valueType:"number"};class Or extends ve{async value(){return""}}m(Or,"TYPE","noop-string-source");const cc={type:Or.TYPE,props:{},variant:"source",valueType:"string"};class zr extends ve{async value(){return{key:"noop",variant:"disabled",message:"unknown",time:E.m.now()}}}m(zr,"TYPE","noop-status-source");const Oo={type:zr.TYPE,props:{},variant:"source",valueType:"status"};class Ir extends ve{async value(){return f.ZERO}}m(Ir,"TYPE","noop-color-source");const lc={type:Ir.TYPE,props:{},variant:"source",valueType:"color"},ef={[Mr.TYPE]:Mr,[Ar.TYPE]:Ar,[Nr.TYPE]:Nr,[Dr.TYPE]:Dr,[zr.TYPE]:zr,[Ir.TYPE]:Ir,[Or.TYPE]:Or};class uc{constructor(){m(this,"type","noop")}create(e){const n=ef[e.type];return n==null?null:new n}}const nf=T.z.instanceof(ArrayBuffer),nr=T.z.object({type:T.z.string(),variant:T.z.enum(["source","sink","source-transformer","sink-transformer"]),valueType:T.z.string(),props:T.z.any(),transfer:T.z.array(nf).optional()}),re=nr.extend({variant:T.z.literal("source")}),ys=nr.extend({variant:T.z.literal("sink")}),hc=nr.extend({variant:T.z.literal("source-transformer")}),fc=nr.extend({variant:T.z.literal("sink-transformer")}),no=re.extend({valueType:T.z.literal("series")}),zo=re.extend({valueType:T.z.literal("boolean")}),ws=ys.extend({valueType:T.z.literal("boolean")}),rf=fc.extend({valueType:T.z.literal("boolean")}),sf=hc.extend({valueType:T.z.literal("boolean")}),dc=re.extend({valueType:T.z.literal("number")}),pc=ys.extend({valueType:T.z.literal("number")}),gc=re.extend({valueType:T.z.literal("color")}),Io=re.extend({valueType:T.z.literal("status")}),mc=re.extend({valueType:T.z.literal("string")});class xs extends Mo.BaseObserver{constructor(n){super();m(this,"props_");m(this,"uProps_");m(this,"schema");this.uProps_=n}get props(){if(this.props_==null){const n=this._schema.safeParse(this.uProps_);if(n.success)this.props_=n.data;else throw new E.D(`[BaseTelem] - expected props to be valid, but found the following errors:
2
+ ${n.error.message}`)}return this.props_}get _schema(){if(this.schema==null)throw new E.D(`[BaseTelem] - expected subclass to define props schema, but none was found.
3
+ Make sure to define a property 'schema' on the class.`);return this.schema}async cleanup(){}}class _t extends xs{}class Ss extends xs{}class rr extends _t{constructor(){super(...arguments);m(this,"sources",{})}get source(){const[n]=Object.values(this.sources);if(n==null)throw new E.D("[UnarySourceTransformer] - expected source to exist, but none was found.");return n}async value(){return this.transform(await this.source.value())}onChange(n){return this.source.onChange(()=>{this.source.value().then(r=>{this.shouldNotify(r)&&n()}).catch(console.error)})}setSources(n){this.sources=n}shouldNotify(n){return!0}transform(n){throw new E.D(`[UnarySourceTransformer] - expected subclass to define transform method, but none was found.
4
+ Make sure to define a method 'transform' on the class.`)}}class yc extends _t{constructor(){super(...arguments);m(this,"sources",{})}async value(){const n=Object.fromEntries(await Promise.all(Object.entries(this.sources).map(async([r,s])=>[r,await s.value()])));return this.transform(n)}setSources(n){this.sources={...this.sources,...n}}transform(n){throw new E.D(`[MultiSourceTransformer] - expected subclass to define transform method, but none was found.
5
+ Make sure to define a method 'transform' on the class.`)}}class wc extends xs{constructor(){super(...arguments);m(this,"sinks",{})}get sink(){const[n]=Object.values(this.sinks);if(n==null)throw new E.D("[UnarySinkTransformer] - expected sink to exist, but none was found.");return n}async set(n){return await this.sink.set(this.transform(n))}setSinks(n){this.sinks={...this.sinks,...n}}transform(n){throw new E.D(`[UnarySinkTransformer] - expected subclass to define transform method, but none was found.
6
+ Make sure to define a method 'transform' on the class.`)}}const xc=T.z.object({from:T.z.string(),to:T.z.string()}),Lo=T.z.object({connections:T.z.array(xc),outlet:T.z.string(),segments:T.z.record(re)});class Sc{constructor(e){m(this,"type","pipeline");m(this,"factory");this.factory=e}create(e){switch(e.type){case Nn.TYPE:return new Nn(e.props,this.factory);case Dn.TYPE:return new Dn(e.props,this.factory);default:return null}}}class Nn extends _t{constructor(n,r){super(n);m(this,"schema",Lo);m(this,"sources",{});const{connections:s,segments:o}=this.props;Object.entries(o).forEach(([i,a])=>{const c=r.create(a);c!=null&&(this.sources[i]=c)}),s.forEach(({from:i,to:a})=>{const c=this.sources[i],l=this.sources[a];c==null||l==null||"setSources"in l&&l.setSources({[i]:c})})}get outlet(){const{outlet:n}=this.props,r=this.sources[n];if(r==null)throw new E.D(`[SourcePipeline] - expected source to exist at outlet '${n}', but none was found.`);return r}async value(){return await this.outlet.value()}onChange(n){return this.outlet.onChange(n)}async cleanup(){await Promise.all(Object.values(this.sources).map(async n=>{var r;return await((r=n.cleanup)==null?void 0:r.call(n))}))}}m(Nn,"TYPE","source-pipeline");const vc=(t,e)=>({variant:"source",props:e,type:Nn.TYPE,valueType:t}),$o=T.z.object({connections:T.z.array(xc),inlet:T.z.string(),segments:T.z.record(ys)});class Dn extends Ss{constructor(n,r){super(n);m(this,"schema",$o);m(this,"sinks",{});const{connections:s,segments:o}=this.props;Object.entries(o).forEach(([i,a])=>{const c=r.create(a);c!=null&&(this.sinks[i]=c)}),s.forEach(({from:i,to:a})=>{const c=this.sinks[i],l=this.sinks[a];c==null||l==null||"setSinks"in c&&c.setSinks({[a]:l})})}get inlet(){const{inlet:n}=this.props,r=this.sinks[n];if(r==null)throw new E.D(`[SinkPipeline] - expected source to exist at inlet '${n}', but none was found.`);return r}async set(n){return await this.inlet.set(n)}async cleanup(){await Promise.all(Object.values(this.sinks).map(async n=>{var r;return await((r=n.cleanup)==null?void 0:r.call(n))}))}}m(Dn,"TYPE","sink-pipeline");const bc=(t,e)=>({variant:"sink",props:e,type:Dn.TYPE,valueType:t}),Yo=T.z.object({channel:T.z.number().or(T.z.string())});class On extends _t{constructor(n,r){super(r);m(this,"client");m(this,"removeStreamHandler",null);m(this,"channelKey",0);m(this,"schema",Yo);m(this,"leadingBuffer",null);m(this,"valid",!1);this.client=n}get testingOnlyLeadingBuffer(){return this.leadingBuffer}get testingOnlyValid(){return this.valid}async cleanup(){var n,r;await((n=this.removeStreamHandler)==null?void 0:n.call(this)),this.valid=!1,(r=this.leadingBuffer)==null||r.release(),this.leadingBuffer=null,this.removeStreamHandler=null}async value(){return E.S$1(this.props.channel)||(this.channelKey===0&&(this.channelKey=(await Bo(this.client,this.props.channel,!1)).key),this.valid||await this.read(),this.leadingBuffer==null||this.leadingBuffer.length===0)?0:this.leadingBuffer.at(-1,!0)}async read(){this.valid=!0,await this.updateStreamHandler()}async updateStreamHandler(){var r;await((r=this.removeStreamHandler)==null?void 0:r.call(this));const n=s=>{var a;const i=s[this.channelKey].data;if(i.length!==0){const c=i[i.length-1];c.acquire(),(a=this.leadingBuffer)==null||a.release(),this.leadingBuffer=c}this.notify()};this.removeStreamHandler=await this.client.stream(n,[this.channelKey])}}m(On,"TYPE","stream-channel-value");const Bo=async(t,e,n)=>{const r=await t.retrieveChannel(e);return!n||r.isIndex?{key:r.key,dataType:r.dataType}:{key:r.index,dataType:E.d.TIMESTAMP}},of=T.z.object({timeRange:E.U.z,channel:T.z.number().or(T.z.string()),useIndexOfChannel:T.z.boolean().optional().default(!1)});class zn extends _t{constructor(n,r){super(r);m(this,"client");m(this,"data",[]);m(this,"valid",!1);m(this,"schema",of);this.client=n}async cleanup(){this.data.forEach(n=>n.release()),this.valid=!1}async value(){const{timeRange:n,channel:r,useIndexOfChannel:s}=this.props;if(n.isZero||r===0)return[f.R.ZERO,[]];const o=await Bo(this.client,r,s);this.valid||await this.readFixed(o.key);let i=f.R.max(this.data.map(a=>a.bounds));return o.dataType.equals(E.d.TIMESTAMP)&&(i={upper:Math.min(i.upper,Number(this.props.timeRange.end.valueOf())),lower:Math.max(i.lower,Number(this.props.timeRange.start.valueOf()))}),[i,this.data]}async readFixed(n){const s=(await this.client.read(this.props.timeRange,[n]))[n].data;s.forEach(o=>o.acquire()),this.data=s,this.valid=!0}}m(zn,"TYPE","series-source");const af=T.z.object({channel:T.z.number().or(T.z.string()),useIndexOfChannel:T.z.boolean().optional().default(!1),timeSpan:E.w.z,keepFor:E.w.z.optional()});class In extends _t{constructor(n,r){super(r);m(this,"client");m(this,"data",[]);m(this,"stopStreaming");m(this,"valid",!1);m(this,"schema",af);this.client=n}async value(){const{channel:n,useIndexOfChannel:r,timeSpan:s}=this.props;if(n===0)return[f.R.ZERO,[]];const o=E.m.now(),i=await Bo(this.client,n,r);this.valid||await this.read(i.key);let a=f.R.max(this.data.filter(c=>c.timeRange.end.after(o.sub(s))).map(c=>c.bounds));return i.dataType.equals(E.d.TIMESTAMP)&&(a={upper:a.upper,lower:Math.max(a.lower,a.upper-Number(s.valueOf()))}),[a,this.data]}async read(n){const r=E.m.now().spanRange(-this.props.timeSpan),o=(await this.client.read(r,[n]))[n].data;o.forEach(i=>i.acquire()),this.data.push(...o),await this.updateStreamHandler(n),this.valid=!0}async updateStreamHandler(n){this.stopStreaming!=null&&await this.stopStreaming();const r=s=>{const o=s[n].data;o.forEach(i=>i.acquire()),this.data.push(...o),this.gcOutOfRangeData(),this.notify()};this.stopStreaming=await this.client.stream(r,[n])}gcOutOfRangeData(){const n=E.m.now().sub(this.props.keepFor??this.props.timeSpan),r=this.data.findIndex(s=>s.timeRange.end.before(n));r!==-1&&(this.data.splice(r,1).forEach(s=>s.release()),this.gcOutOfRangeData())}async cleanup(){var n;await((n=this.stopStreaming)==null?void 0:n.call(this)),this.stopStreaming=void 0,this.data.forEach(r=>r.release())}}m(In,"TYPE","dynamic-series-source");const cf={[zn.TYPE]:zn,[In.TYPE]:In,[On.TYPE]:On};class Tc{constructor(e){m(this,"type","remote");m(this,"client");this.client=e}create(e){const n=cf[e.type];return n==null?null:new n(this.client,e.props)}}const Ec=t=>({type:zn.TYPE,props:t,variant:"source",valueType:"series"}),_c=t=>({type:In.TYPE,props:t,variant:"source",valueType:"series"}),Cc=t=>({type:On.TYPE,props:t,variant:"source",valueType:"number"});class Pc{constructor(){m(this,"type","static")}create(e){switch(e.type){case Lr.TYPE:return new Lr(e.props);case Ln.TYPE:return new Ln(e.props);case $n.TYPE:return new $n(e.props);case Yn.TYPE:return new Yn(e.props);default:return null}}}const qo=T.z.object({data:T.z.array(E.wt),offsets:T.z.array(T.z.number()).optional().default([])});class Lr extends _t{constructor(n){super(n);m(this,"data");m(this,"schema",qo);this.data=this.props.data.map((r,s)=>new E.N({data:r,dataType:E.d.FLOAT32,timeRange:E.U.ZERO,sampleOffset:this.props.offsets[s]??0}))}async value(){return[f.R.max(this.data.map(r=>r.bounds)),this.data]}}m(Lr,"TYPE","static-series");const Rc=qo.extend({rate:E.$.z,yOffset:T.z.number().optional().default(0),scroll:T.z.number().optional().default(0),startPosition:T.z.number().optional().default(0),scrollBounds:T.z.boolean().optional().default(!1)});class Ln extends _t{constructor(n){super(n);m(this,"schema",Rc);m(this,"position");m(this,"interval");m(this,"data");this.position=this.props.startPosition,this.start(this.props.rate),this.data=this.props.data.map((r,s)=>new E.N({data:r,dataType:E.d.FLOAT32,timeRange:E.U.ZERO,sampleOffset:this.props.offsets[s]??0}))}async value(){const n=this.data.map(s=>s.slice(0,this.position));if(this.props.scrollBounds){const s=n[0].data[this.position-this.props.scroll<0?0:this.position-this.props.scroll],o=n[0].data[this.position-1];return[{lower:Number(s),upper:Number(o)},n]}return[f.R.max(n.map(s=>s.bounds)),n]}start(n){this.interval!=null&&clearInterval(this.interval),this.interval=setInterval(()=>{var r;(r=this.notify)==null||r.call(this),this.position++},n.period.milliseconds)}async cleanup(){clearInterval(this.interval),this.interval=void 0}}m(Ln,"TYPE","iterative-series");const kc=T.z.number();class $n extends _t{constructor(){super(...arguments);m(this,"schema",kc)}async value(){return this.props}}m($n,"TYPE","static-numeric");const Mc=T.z.string();class Yn extends _t{constructor(){super(...arguments);m(this,"schema",Mc)}async value(){return this.props}}m(Yn,"TYPE","static-string");const lf=t=>({type:Lr.TYPE,props:t,variant:"source",valueType:"series"}),uf=t=>({type:Ln.TYPE,props:t,variant:"source",valueType:"series"}),hf=t=>({type:$n.TYPE,props:t,variant:"source",valueType:"number"}),ff=t=>({type:Yn.TYPE,props:t,variant:"source",valueType:"string"});class Ac{constructor(){m(this,"type","transformer")}create(e){switch(e.type){case Ze.TYPE:return new Ze(e.props);case He.TYPE:return new He(e.props);case Ve.TYPE:return new Ve(e.props);case Xe.TYPE:return new Xe(e.props);case Ge.TYPE:return new Ge(e.props);case We.TYPE:return new We(e.props)}return null}}const df=T.z.object({truthy:T.z.number().optional().default(1),falsy:T.z.number().optional().default(0)}),Nc=t=>({props:t,type:Ze.TYPE,variant:"sink",valueType:"boolean"}),Cn=class Cn extends wc{constructor(){super(...arguments);m(this,"schema",Cn.propsZ)}transform(n){return n?this.props.truthy:this.props.falsy}};m(Cn,"TYPE","boolean-numeric-converter-sink"),m(Cn,"propsZ",df);let Ze=Cn;const pf=T.z.object({trueBound:f.R.bounds}),Dc=t=>({props:t,type:He.TYPE,variant:"source",valueType:"boolean"}),Pn=class Pn extends rr{constructor(){super(...arguments);m(this,"schema",Pn.propsZ);m(this,"curr",null)}shouldNotify(n){const r=f.R.contains(this.props.trueBound,n)!==this.curr;return this.curr=f.R.contains(this.props.trueBound,n),r}transform(n){return this.curr=f.R.contains(this.props.trueBound,n),this.curr}};m(Pn,"TYPE","boolean-source"),m(Pn,"propsZ",pf);let He=Pn;const Oc=T.z.object({}),Rn=class Rn extends yc{constructor(){super(...arguments);m(this,"schema",Rn.propsZ)}transform(n){return Object.values(n).reduce((r,s)=>r+s,0)/Object.keys(n).length}};m(Rn,"TYPE","mean"),m(Rn,"propsZ",Oc);let Ve=Rn;const gf=t=>({props:t,type:Ve.TYPE,variant:"source",valueType:"boolean"}),zc=T.z.object({trueVariant:E.variantZ.optional().default("success")}),kn=class kn extends rr{constructor(){super(...arguments);m(this,"schema",kn.propsZ)}transform(n){return n.variant===this.props.trueVariant}};m(kn,"TYPE","boolean-status"),m(kn,"propsZ",zc);let Xe=kn;const mf=t=>({props:t,type:Xe.TYPE,variant:"source",valueType:"boolean"}),Fo=T.z.object({precision:T.z.number().optional().default(2),prefix:T.z.string().optional().default(""),suffix:T.z.string().optional().default("")}),Mn=class Mn extends rr{constructor(){super(...arguments);m(this,"schema",Mn.propsZ)}transform(n){return`${this.props.prefix}${n.toFixed(this.props.precision)}${this.props.suffix}`}};m(Mn,"TYPE","stringify-number"),m(Mn,"propsZ",Fo);let Ge=Mn;const Ic=t=>({props:t,type:Ge.TYPE,variant:"source",valueType:"string"}),Uo=T.z.object({windowSize:T.z.number().optional().default(5)});class We extends rr{constructor(){super(...arguments);m(this,"schema",Uo);m(this,"values",[])}transform(n){return this.props.windowSize<2?n:this.values.reduce((r,s)=>r+s,0)/this.values.length}shouldNotify(n){return this.props.windowSize<2?!0:(this.values.length>this.props.windowSize&&(this.values=[]),this.values.push(n),this.values.length===this.props.windowSize)}}m(We,"TYPE","rolling-average"),m(We,"propsZ",Oc);const Lc=t=>({props:t,type:We.TYPE,variant:"source",valueType:"number"});class $c{constructor(e){m(this,"factories");m(this,"type","compound");this.factories=e}add(e){this.factories=[...this.factories.filter(n=>n.type!==e.type),e]}create(e){for(const n of this.factories){const r=n.create(e);if(r!=null)return r}return null}}const Yc=t=>{const e=[new Ac,new Pc,new uc],n=new $c(e);return t!=null&&n.add(new Tc(t)),n.add(new Sc(n)),n},Bc=T.z.object({include:T.z.string().array().optional(),exclude:T.z.string().array().optional(),level:T.z.enum(E.g.LOG_LEVELS).optional().default("info")}),ro="alamos-provider";var eo;let so=(eo=class extends E.Composite{constructor(){super(...arguments);m(this,"schema",Bc)}async afterUpdate(){if(this.ctx.getOptional(ro)!=null)return;const r=[],{include:s,exclude:o,level:i}=this.state;(s!=null||o!=null)&&r.push(E.g.logLevelKeyFiler({include:s,exclude:o})),i!=null&&r.push(E.g.logThresholdFilter(i)),r.length===0&&r.push(()=>!1),this.internal.ins=new E.g.Instrumentation({key:"aether",logger:new E.g.Logger({filters:r})}),this.ctx.set(ro,this.internal.ins)}},m(eo,"TYPE","AlamosProvider"),eo);const sr=(t,e)=>{const n=t.get(ro);if(n==null)throw new Error("No instrumentation provider");return e==null?n:n.child(e)},yf={[so.TYPE]:so},qc=(t,e)=>(e==null&&t.dataType.equals(E.d.TIMESTAMP)&&(e=BigInt(t.data[0])),t.convert(E.d.FLOAT32,e)),Fc=()=>({purgedSeries:0,purgedBytes:E.C.bytes(0)}),Uc={instrumentation:E.g.NOOP,staleEntryThreshold:E.w.seconds(20)};class wf{constructor(e){m(this,"data",[]);m(this,"props");this.props={...Uc,...e}}write(e){e.length!==0&&(e.forEach(n=>this.writeOne(qc(n))),this.checkIntegrity(e))}dirtyRead(e){const n=this.data.filter(({data:i})=>i.timeRange.overlapsWith(e)).map(({data:i})=>i);if(n.length===0)return{series:[],gaps:[e]};const r=n.map((i,a)=>a===0?E.U.ZERO:new E.U(n[a-1].timeRange.end,i.timeRange.start)).filter(i=>!i.isZero&&i.isValid),s=new E.U(e.start,n[0].timeRange.start),o=new E.U(n[n.length-1].timeRange.end,e.end);return s.isValid&&!s.isZero&&r.unshift(s),o.isValid&&!o.isZero&&r.push(o),{series:n,gaps:r}}gc(){const{staleEntryThreshold:e}=this.props,n=Fc(),r=this.data.filter(s=>{const o=s.data.refCount>0||E.m.since(s.addedAt).lessThan(e);return o||(n.purgedBytes=n.purgedBytes.add(s.data.byteCapacity)),o});return n.purgedSeries=this.data.length-r.length,this.data=r,n}close(){this.data=[]}writeOne(e){const{instrumentation:{L:n}}=this.props;if(e.length===0)return;const r=f.R.buildInsertionPlan(this.data.map(c=>c.data.alignmentBounds),e.alignmentBounds);if(r===null)return n.debug("Found no viable insertion plan",{inserting:e.digest,cacheContents:this.data.map(c=>c.data.digest)});const{removeBefore:s,removeAfter:o,insertInto:i,deleteInBetween:a}=r;e=e.slice(s,e.data.length-Number(o)),e.length!==0&&this.data.splice(i,a,{data:e,addedAt:E.m.now()})}checkIntegrity(e){const{instrumentation:{L:n}}=this.props,r=this.data.map(o=>o.data.alignmentBounds);if(r.some((o,i)=>r.some((a,c)=>i===c?!1:f.R.overlapsWith(o,a))))throw n.debug("Cache is in an invalid state - bounds overlap!",()=>({write:e.map(o=>o.digest),cacheContents:this.data.map(o=>o.data.digest)})),new Error("Invalid state")}}const xf=100,Sf=1e6,vf=1e4,bf=100;class Tf{constructor(e){m(this,"props");m(this,"counter",0);m(this,"buffer");m(this,"avgRate",0);m(this,"timeOfLastWrite");m(this,"totalWrites",0);m(this,"now",()=>E.m.now());this.props=e,this.buffer=null,e.testingNow!=null&&(this.now=e.testingNow),this.timeOfLastWrite=this.now()}get length(){var e;return((e=this.buffer)==null?void 0:e.length)??0}get leadingBuffer(){return this.buffer}write(e){const n=e.flatMap(r=>this._write(r));return{flushed:n.flatMap(r=>r.flushed),allocated:n.flatMap(r=>r.allocated)}}allocate(e,n,r){return this.counter++,E.N.alloc({capacity:e,dataType:E.d.FLOAT32,timeRange:r.range(E.m.MAX),sampleOffset:this.props.dataType.equals(E.d.TIMESTAMP)?BigInt(r.valueOf()):0,glBufferUsage:"dynamic",alignment:n,key:`dynamic-${this.counter}`})}_write(e){const n=this.nextBufferSize(),r={flushed:[],allocated:[]};if(this.buffer==null)this.buffer=this.allocate(n,e.alignment,this.now()),r.allocated.push(this.buffer);else if(Math.abs(Number(this.buffer.alignment+BigInt(this.buffer.length)-e.alignment))>1){const c=this.now();this.buffer.timeRange.end=c,r.flushed.push(this.buffer),this.buffer=this.allocate(n,e.alignment,c),r.allocated.push(this.buffer)}const s=qc(e,this.buffer.sampleOffset),o=this.buffer.write(s);if(o===e.length)return this.updateAvgRate(e),r;const i=this.now();this.buffer.timeRange.end=i,r.flushed.push(this.buffer),this.buffer=this.allocate(n,e.alignment+BigInt(o),i),r.allocated.push(this.buffer);const a=this._write(e.slice(o));return r.flushed.push(...a.flushed),r.allocated.push(...a.allocated),r}updateAvgRate(e){if(typeof this.props.dynamicBufferSize=="number")return;const n=e.length/this.now().span(this.timeOfLastWrite).seconds;this.totalWrites>0&&isFinite(n)&&n>0&&(this.avgRate=(this.avgRate*(this.totalWrites-1)+n)/this.totalWrites),this.totalWrites++,this.timeOfLastWrite=this.now()}nextBufferSize(){const{dynamicBufferSize:e}=this.props;if(typeof e=="number")return e;if(this.totalWrites<bf)return vf;const n=f.C.roundToNearestMagnitude(this.avgRate*e.seconds);return Math.round(Math.max(Math.min(n,Sf),xf))}close(){this.buffer=null}}class Ef{constructor(e){m(this,"channel");m(this,"closed",!1);m(this,"ins");m(this,"static");m(this,"dynamic");this.channel=e.channel,this.ins=e.instrumentation??E.g.NOOP,this.static=new wf(e),this.dynamic=new Tf({dynamicBufferSize:e.dynamicBufferSize,dataType:this.channel.dataType})}writeDynamic(e){if(this.closed)return this.ins.L.warn(`Ignoring attempted dynamic write to a closed cache for channel ${this.channel.name}`),[];const{flushed:n,allocated:r}=this.dynamic.write(e);return n.length>0&&this.static.write(n),r}get leadingBuffer(){return this.dynamic.leadingBuffer}writeStatic(e){if(this.closed)return this.ins.L.warn(`Ignoring attempted static write to a closed cache for channel ${this.channel.name}`);this.static.write(e)}read(e){return this.closed?(this.ins.L.warn(`Ignoring attempted dirty read from a closed cache for channel ${this.channel.name}`),{series:[],gaps:[]}):this.static.dirtyRead(e)}gc(){return this.closed?(this.ins.L.warn(`Ignoring attempted garbage collection on a closed cache for channel ${this.channel.name}`),{purgedSeries:0,purgedBytes:E.C.bytes(0)}):this.static.gc()}close(){this.closed=!0,this.dynamic.close(),this.static.close()}}const _f=E.S.seconds(60);class Cf{constructor(e){m(this,"props");m(this,"cache",new Map);m(this,"gcInterval");this.props={dynamicBufferSize:_f,gcInterval:E.S.seconds(30),...Uc,...e},this.gcInterval=setInterval(()=>this.gc(),this.props.gcInterval.milliseconds)}async populateMissing(e){const{instrumentation:n,channelRetriever:r,dynamicBufferSize:s}=this.props,o=[];for(const a of e)this.cache.has(a)||o.push(a);if(o.length===0)return;const i=await r.retrieve(o);for(const a of i){const c=new Ef({channel:a,dynamicBufferSize:s,instrumentation:n.child(`cache-${a.name}-${a.key}`)});this.cache.has(a.key)||this.cache.set(a.key,c)}}get(e){const n=this.cache.get(e);if(n!=null)return n;throw new E.Se(`cache entry for ${e} not found`)}gc(){const{instrumentation:{L:e}}=this.props;e.info("starting garbage collection");const n=Fc();this.cache.forEach(r=>{const s=r.gc();n.purgedSeries+=s.purgedSeries,n.purgedBytes=n.purgedBytes.add(s.purgedBytes)}),e.info("garbage collection complete",{purgedSeries:n.purgedSeries,purgedBytes:n.purgedBytes.toString()},!0)}close(){clearInterval(this.gcInterval),this.cache.forEach(e=>e.close()),this.cache.clear()}}class $r{constructor(e,n){m(this,"channel");m(this,"data");this.channel=e,this.data=n}get timeRange(){if(this.data.length===0)return E.V.ZERO;const e=this.data[0].timeRange,n=this.data[this.data.length-1].timeRange;return new E.V(e.start,n.end)}get digest(){return{channel:this.channel.key,timeRange:this.timeRange.toPrettyString(),series:this.data.map(e=>e.digest)}}}const Os=t=>t.map(e=>e.digest);class Pf{constructor(e){m(this,"props");m(this,"debouncedRead");m(this,"guarded",{mu:new E.Mutex,requests:new Map});this.props={instrumentation:E.g.NOOP,batchDebounce:E.w.milliseconds(50),...e},this.debouncedRead=E.o$1(()=>{this.batchRead()},this.props.batchDebounce.milliseconds)}async read(e,n){const{instrumentation:{L:r},cache:s}=this.props;r.debug("starting read",{tr:e.toPrettyString(),channels:n});const o=performance.now(),i=new Map,a={};await s.populateMissing(n);try{for(const u of n){const h=s.get(u),{series:d,gaps:p}=h.read(e);p.length===0&&(a[u]=new $r(h.channel,d)),p.forEach(w=>{const y=i.get(w.toString());y==null?i.set(w.toString(),[w,new Set([u])]):i.set(w.toString(),[w,new Set([...y[1],u])])})}if(i.size===0)return r.debug("read satisfied by cache",()=>({tr:e.toPrettyString(),channels:n,responses:Os(Object.values(a)),time:E.w.milliseconds(performance.now()-o).toString()})),a;r.debug("read cache miss",()=>({tr:e.toPrettyString(),channels:n,toFetch:Array.from(i.values()).map(([u,h])=>({timeRange:u.toPrettyString(),channels:h})),responses:Os(Object.values(a))}));const{mu:c,requests:l}=this.guarded;for(const[,[u,h]]of i)await new Promise((d,p)=>{c.runExclusive(async()=>{l.set([u,h],{resolve:d,reject:p}),this.debouncedRead()})})}catch(c){throw r.error("read failed",{tr:e.toPrettyString(),channels:n,error:c}),c}for(const c of n){const l=s.get(c),{series:u}=l.read(e);a[c]=new $r(l.channel,u)}return r.debug("read satisfied by fetch",()=>({tr:e.toPrettyString(),channels:n,responses:Os(Object.values(a)),time:E.w.milliseconds(performance.now()-o).toString()})),a}async batchRead(){const{instrumentation:{L:e},readRemote:n,cache:r}=this.props,{mu:s,requests:o}=this.guarded;await s.runExclusive(async()=>{const i=[];try{o.forEach((a,c)=>{const[l,u]=c,h=i.find(([d])=>d.start.span(l.start).lessThan(E.w.milliseconds(5))&&d.end.span(l.end).lessThan(E.w.milliseconds(5)));h==null?i.push([l,u]):h[1]=new Set([...h[1],...u])}),e.debug("batch read",{toFetch:i.map(([a,c])=>({timeRange:a.toPrettyString(),channels:c}))});for(const[a,c]of i){const l=Array.from(c),u=await n(a,l);l.forEach(h=>{const d=r.get(h),p=u.get(h);d.writeStatic(p.series)})}o.forEach(a=>a.resolve())}catch(a){e.error("batch read failed",{error:a},!0),o.forEach(c=>c.reject(a))}finally{o.clear()}})}}class Rf{constructor(e){m(this,"props");m(this,"mu",new E.Mutex);m(this,"listeners",new Map);m(this,"streamerRunLoop",null);m(this,"streamer",null);m(this,"closed",!1);this.props={instrumentation:E.g.NOOP,...e}}async stream(e,n){const{cache:r,instrumentation:{L:s}}=this.props;return await r.populateMissing(n),await this.mu.runExclusive(async()=>{s.debug("adding stream handler",{keys:n}),this.listeners.set(e,{valid:!0,keys:n});const o={};for(const i of n){const a=r.get(i),c=a.leadingBuffer!=null?[a.leadingBuffer]:[];o[i]=new $r(a.channel,c)}return e(o),await this.updateStreamer(),async()=>await this.removeStreamHandler(e)})}async removeStreamHandler(e){const{instrumentation:{L:n}}=this.props;await this.mu.runExclusive(()=>{const r=this.listeners.get(e);r!=null&&(r.valid=!1)}),setTimeout(()=>{this.mu.runExclusive(async()=>{if(n.debug("removing stream handler"),this.listeners.delete(e))return await this.updateStreamer();n.warn("attempted to remove non-existent stream handler")})},5e3)}async updateStreamer(){var o,i;if(this.closed)return;const{instrumentation:{L:e},core:n}=this.props,r=new Set;if(this.listeners.forEach(a=>a.keys.forEach(c=>r.add(c))),r.size===0){e.info("no keys to stream, closing streamer"),(o=this.streamer)==null||o.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop,this.streamer=null,e.info("streamer closed successfully");return}const s=Array.from(r);if(E.y.primitiveArrays(s,((i=this.streamer)==null?void 0:i.keys)??[])===E.y.EQUAL){e.debug("streamer keys unchanged",{keys:s});return}this.streamer==null&&(e.info("creating new streamer",{keys:s}),this.streamer=await n.openStreamer(s),this.streamerRunLoop=this.runStreamer(this.streamer)),e.debug("updating streamer",{prev:this.streamer.keys,next:s});try{await this.streamer.update(s)}catch(a){throw e.error("failed to update streamer",{error:a}),a}}async runStreamer(e){const{cache:n,instrumentation:{L:r}}=this.props;try{for await(const s of e){const o=[];for(const i of s.keys){const a=s.get(i),c=n.get(i),l=c.writeDynamic(a.series);o.push(new $r(c.channel,l))}this.listeners.forEach((i,a)=>{if(!i.valid)return;const c=o.filter(u=>i.keys.includes(u.channel.key));if(c.length===0)return;const l=Object.fromEntries(c.map(u=>[u.channel.key,u]));a(l)})}}catch(s){throw r.error("streamer run loop failed",{error:s},!0),s}}async close(){var e;(e=this.streamer)==null||e.close(),this.streamerRunLoop!=null&&await this.streamerRunLoop,this.closed=!0}}class kf{constructor(){m(this,"key",E.mt.id());m(this,"_client",null)}async swap(e){var n;this.key=E.mt.id(),await((n=this._client)==null?void 0:n.close()),this._client=e}async retrieveChannel(e){return await this.client.retrieveChannel(e)}async read(e,n){return await this.client.read(e,n)}async stream(e,n){return await this.client.stream(e,n)}async close(){await this.client.close()}get client(){if(this._client==null)throw new E.Q("No cluster has been connected");return this._client}}class Mf{constructor({instrumentation:e,core:n}){m(this,"key",E.mt.id());m(this,"ins");m(this,"cache");m(this,"reader");m(this,"streamer");m(this,"channelRetriever");this.ins=e??E.g.NOOP,this.channelRetriever=n.channels.createDebouncedBatchRetriever(10),this.cache=new Cf({channelRetriever:this.channelRetriever,instrumentation:this.ins.child("cache")}),this.reader=new Pf({cache:this.cache,readRemote:async(r,s)=>await n.read(r,s),instrumentation:this.ins.child("reader")}),this.streamer=new Rf({cache:this.cache,core:n,instrumentation:this.ins.child("streamer")})}async retrieveChannel(e){const n=await this.channelRetriever.retrieve([e]);if(n.length===0)throw new E.Q(`channel ${e} not found`);return n[0]}async read(e,n){return await this.reader.read(e,n)}async stream(e,n){return await this.streamer.stream(e,n)}async close(){this.ins.L.info("closing client",{key:this.key}),await this.streamer.close(),this.cache.close()}}const Zo=T.z.object({}),Le=class Le extends E.Composite{constructor(){super(...arguments);m(this,"client",new kf);m(this,"factory",Yc(this.client));m(this,"schema",Le.stateZ);m(this,"prevClient",null)}create(n){const{instrumentation:r}=this.internal;r.L.debug("creating telem",{spec:n});const s=this.factory.create(n);if(s==null)throw new E.Se(`Telemetry service could not find a source for type ${n.type}`);return s}get clusterKey(){return this.client.key}registerFactory(n){this.factory.add(n)}equals(n){return n instanceof Le?this.client._client===n.client._client:!1}async afterUpdate(){const n=tr(this.ctx),r=sr(this.ctx,"telem");this.internal.instrumentation=r.child("provider"),n!==this.prevClient&&(r.L.info("swapping client",{client:n}),n==null?await this.client.swap(null):await this.client.swap(new Mf({core:n,instrumentation:r})),this.prevClient=n,sc(this.ctx,this))}};m(Le,"TYPE","TelemProvider"),m(Le,"stateZ",Zo);let Ke=Le;const Zc={[Ke.TYPE]:Ke},Af=Object.freeze(Object.defineProperty({__proto__:null,AbstractSink:Ss,AbstractSource:_t,Base:xs,BaseProvider:Ke,BooleanStatus:Xe,ChannelData:zn,CompoundTelemFactory:$c,FixedNumber:$n,FixedString:Yn,IterativeSeries:Ln,Mean:Ve,MultiSourceTransformer:yc,NoopFactory:uc,PipelineFactory:Sc,REGISTRY:Zc,RemoteFactory:Tc,RollingAverage:We,SetPoint:Ze,SinkPipeline:Dn,SourcePipeline:Nn,StaticFactory:Pc,StreamChannelData:In,StreamChannelValue:On,StringifyNumber:Ge,TransformerFactory:Ac,UnarySinkTransformer:wc,UnarySourceTransformer:rr,WithinBounds:He,booleanSinkSpecZ:ws,booleanSinkTransformerSpecZ:rf,booleanSourceSpecZ:zo,booleanSourceTransformerSpecZ:sf,booleanStatus:mf,booleanStatusProps:zc,channelData:Ec,colorSourceSpecZ:gc,factory:Yc,fixedArray:lf,fixedNumber:hf,fixedNumberPropsZ:kc,fixedSeriesPropsZ:qo,fixedString:ff,fixedStringPropsZ:Mc,iterativeArray:uf,iterativeSeriesPropsZ:Rc,mean:gf,noopBooleanSinkSpec:ms,noopBooleanSourceSpec:Do,noopColorSourceSpec:lc,noopNumericSinkSpec:ic,noopNumericSourceSpec:ac,noopStatusSourceSpec:Oo,noopStringSourceSpec:cc,numberSinkSpecZ:pc,numberSourceSpecZ:dc,providerStateZ:Zo,registerFactory:oc,rollingAverage:Lc,rollingAverageProps:Uo,seriesSourceSpecZ:no,setProvider:sc,setpoint:Nc,sinkPipeline:bc,sinkPipelinePropsZ:$o,sinkSpecZ:ys,sinkTransformerSpecZ:fc,sourcePipeline:vc,sourcePipelinePropsZ:Lo,sourceSpecZ:re,sourceTransformerSpecZ:hc,specZ:nr,statusSourceSpecZ:Io,streamChannelData:_c,streamChannelValue:Cc,streamChannelValuePropsZ:Yo,stringSourceSpecZ:mc,stringifyNumber:Ic,stringifyNumberProps:Fo,useProvider:gs,useSink:er,useSource:Lt,withinBounds:Dc},Symbol.toStringTag,{value:"Module"})),Hc=T.z.object({key:T.z.string(),size:T.z.number(),order:Gh.order,loc:f.J.outer});T.z.record(Hc);const fe=(t,e)=>Object.values(e).filter(({loc:n})=>n===t).sort((n,r)=>E.y.order(n.order,r.order)),Nf=(t,e,n)=>{const r=e[t];if(r==null)return f.q.ZERO;const s=f.J.construct(r.loc),o=fe(s,e),i=f.J.construct(f.g.swap(f.J.direction(s))),a=fe(i,e),c=o.findIndex(({key:h})=>h===t),l=o.slice(0,c).reduce((h,{size:d})=>h+d,0),u=a.reduce((h,{size:d})=>h+d,0);switch(s){case"left":return f.q.translate(f.To.topLeft(n),[l,u]);case"right":return f.q.translate(f.To.topRight(n),[l-r.size,u]);case"top":return f.q.translate(f.To.topLeft(n),[l,u]);default:return f.q.translate(f.To.bottomLeft(n),[u,l-r.size])}},Df=(t,e)=>{const n=fe("left",t),r=fe("right",t),s=fe("top",t),o=fe("bottom",t),i=n.reduce((u,{size:h})=>u+h,0),a=r.reduce((u,{size:h})=>u+h,0),c=s.reduce((u,{size:h})=>u+h,0),l=o.reduce((u,{size:h})=>u+h,0);return f.To.construct(f.q.translate(f.To.topLeft(e),{x:i,y:c}),f.To.width(e)-i-a,f.To.height(e)-c-l)};function Tr(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Of(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Ho(t){let e,n,r;t.length!==2?(e=Tr,n=(a,c)=>Tr(t(a),c),r=(a,c)=>t(a)-c):(e=t===Tr||t===Of?t:zf,n=t,r=t);function s(a,c,l=0,u=a.length){if(l<u){if(e(c,c)!==0)return u;do{const h=l+u>>>1;n(a[h],c)<0?l=h+1:u=h}while(l<u)}return l}function o(a,c,l=0,u=a.length){if(l<u){if(e(c,c)!==0)return u;do{const h=l+u>>>1;n(a[h],c)<=0?l=h+1:u=h}while(l<u)}return l}function i(a,c,l=0,u=a.length){const h=s(a,c,l,u-1);return h>l&&r(a[h-1],c)>-r(a[h],c)?h-1:h}return{left:s,center:i,right:o}}function zf(){return 0}function If(t){return t===null?NaN:+t}const Lf=Ho(Tr),$f=Lf.right;Ho(If).center;const Yf=Math.sqrt(50),Bf=Math.sqrt(10),qf=Math.sqrt(2);function Yr(t,e,n){const r=(e-t)/Math.max(0,n),s=Math.floor(Math.log10(r)),o=r/Math.pow(10,s),i=o>=Yf?10:o>=Bf?5:o>=qf?2:1;let a,c,l;return s<0?(l=Math.pow(10,-s)/i,a=Math.round(t*l),c=Math.round(e*l),a/l<t&&++a,c/l>e&&--c,l=-l):(l=Math.pow(10,s)*i,a=Math.round(t/l),c=Math.round(e/l),a*l<t&&++a,c*l>e&&--c),c<a&&.5<=n&&n<2?Yr(t,e,n*2):[a,c,l]}function Ff(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[s,o,i]=r?Yr(e,t,n):Yr(t,e,n);if(!(o>=s))return[];const a=o-s+1,c=new Array(a);if(r)if(i<0)for(let l=0;l<a;++l)c[l]=(o-l)/-i;else for(let l=0;l<a;++l)c[l]=(o-l)*i;else if(i<0)for(let l=0;l<a;++l)c[l]=(s+l)/-i;else for(let l=0;l<a;++l)c[l]=(s+l)*i;return c}function oo(t,e,n){return e=+e,t=+t,n=+n,Yr(t,e,n)[2]}function io(t,e,n){e=+e,t=+t,n=+n;const r=e<t,s=r?oo(e,t,n):oo(t,e,n);return(r?-1:1)*(s<0?1/-s:s)}function Vc(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Vo(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Xc(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function or(){}var Bn=.7,Br=1/Bn,Be="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",It="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Uf=/^#([0-9a-f]{3,8})$/,Zf=new RegExp(`^rgb\\(${Be},${Be},${Be}\\)$`),Hf=new RegExp(`^rgb\\(${It},${It},${It}\\)$`),Vf=new RegExp(`^rgba\\(${Be},${Be},${Be},${qn}\\)$`),Xf=new RegExp(`^rgba\\(${It},${It},${It},${qn}\\)$`),Gf=new RegExp(`^hsl\\(${qn},${It},${It}\\)$`),Wf=new RegExp(`^hsla\\(${qn},${It},${It},${qn}\\)$`),Oi={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Vo(or,ye,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:zi,formatHex:zi,formatHex8:Kf,formatHsl:jf,formatRgb:Ii,toString:Ii});function zi(){return this.rgb().formatHex()}function Kf(){return this.rgb().formatHex8()}function jf(){return Gc(this).formatHsl()}function Ii(){return this.rgb().formatRgb()}function ye(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Uf.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Li(e):n===3?new yt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?ur(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?ur(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Zf.exec(t))?new yt(e[1],e[2],e[3],1):(e=Hf.exec(t))?new yt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Vf.exec(t))?ur(e[1],e[2],e[3],e[4]):(e=Xf.exec(t))?ur(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Gf.exec(t))?Bi(e[1],e[2]/100,e[3]/100,1):(e=Wf.exec(t))?Bi(e[1],e[2]/100,e[3]/100,e[4]):Oi.hasOwnProperty(t)?Li(Oi[t]):t==="transparent"?new yt(NaN,NaN,NaN,0):null}function Li(t){return new yt(t>>16&255,t>>8&255,t&255,1)}function ur(t,e,n,r){return r<=0&&(t=e=n=NaN),new yt(t,e,n,r)}function Jf(t){return t instanceof or||(t=ye(t)),t?(t=t.rgb(),new yt(t.r,t.g,t.b,t.opacity)):new yt}function ao(t,e,n,r){return arguments.length===1?Jf(t):new yt(t,e,n,r??1)}function yt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}Vo(yt,ao,Xc(or,{brighter(t){return t=t==null?Br:Math.pow(Br,t),new yt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Bn:Math.pow(Bn,t),new yt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new yt(ge(this.r),ge(this.g),ge(this.b),qr(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:$i,formatHex:$i,formatHex8:Qf,formatRgb:Yi,toString:Yi}));function $i(){return`#${de(this.r)}${de(this.g)}${de(this.b)}`}function Qf(){return`#${de(this.r)}${de(this.g)}${de(this.b)}${de((isNaN(this.opacity)?1:this.opacity)*255)}`}function Yi(){const t=qr(this.opacity);return`${t===1?"rgb(":"rgba("}${ge(this.r)}, ${ge(this.g)}, ${ge(this.b)}${t===1?")":`, ${t})`}`}function qr(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ge(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function de(t){return t=ge(t),(t<16?"0":"")+t.toString(16)}function Bi(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Rt(t,e,n,r)}function Gc(t){if(t instanceof Rt)return new Rt(t.h,t.s,t.l,t.opacity);if(t instanceof or||(t=ye(t)),!t)return new Rt;if(t instanceof Rt)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,s=Math.min(e,n,r),o=Math.max(e,n,r),i=NaN,a=o-s,c=(o+s)/2;return a?(e===o?i=(n-r)/a+(n<r)*6:n===o?i=(r-e)/a+2:i=(e-n)/a+4,a/=c<.5?o+s:2-o-s,i*=60):a=c>0&&c<1?0:i,new Rt(i,a,c,t.opacity)}function td(t,e,n,r){return arguments.length===1?Gc(t):new Rt(t,e,n,r??1)}function Rt(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}Vo(Rt,td,Xc(or,{brighter(t){return t=t==null?Br:Math.pow(Br,t),new Rt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Bn:Math.pow(Bn,t),new Rt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,s=2*n-r;return new yt(zs(t>=240?t-240:t+120,s,r),zs(t,s,r),zs(t<120?t+240:t-120,s,r),this.opacity)},clamp(){return new Rt(qi(this.h),hr(this.s),hr(this.l),qr(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=qr(this.opacity);return`${t===1?"hsl(":"hsla("}${qi(this.h)}, ${hr(this.s)*100}%, ${hr(this.l)*100}%${t===1?")":`, ${t})`}`}}));function qi(t){return t=(t||0)%360,t<0?t+360:t}function hr(t){return Math.max(0,Math.min(1,t||0))}function zs(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const Xo=t=>()=>t;function ed(t,e){return function(n){return t+n*e}}function nd(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function rd(t){return(t=+t)==1?Wc:function(e,n){return n-e?nd(e,n,t):Xo(isNaN(e)?n:e)}}function Wc(t,e){var n=e-t;return n?ed(t,n):Xo(isNaN(t)?e:t)}const Fr=function t(e){var n=rd(e);function r(s,o){var i=n((s=ao(s)).r,(o=ao(o)).r),a=n(s.g,o.g),c=n(s.b,o.b),l=Wc(s.opacity,o.opacity);return function(u){return s.r=i(u),s.g=a(u),s.b=c(u),s.opacity=l(u),s+""}}return r.gamma=t,r}(1);function sd(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),s;return function(o){for(s=0;s<n;++s)r[s]=t[s]*(1-o)+e[s]*o;return r}}function od(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function id(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,s=new Array(r),o=new Array(n),i;for(i=0;i<r;++i)s[i]=Go(t[i],e[i]);for(;i<n;++i)o[i]=e[i];return function(a){for(i=0;i<r;++i)o[i]=s[i](a);return o}}function ad(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Pt(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function cd(t,e){var n={},r={},s;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(s in e)s in t?n[s]=Go(t[s],e[s]):r[s]=e[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var co=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Is=new RegExp(co.source,"g");function ld(t){return function(){return t}}function ud(t){return function(e){return t(e)+""}}function Kc(t,e){var n=co.lastIndex=Is.lastIndex=0,r,s,o,i=-1,a=[],c=[];for(t=t+"",e=e+"";(r=co.exec(t))&&(s=Is.exec(e));)(o=s.index)>n&&(o=e.slice(n,o),a[i]?a[i]+=o:a[++i]=o),(r=r[0])===(s=s[0])?a[i]?a[i]+=s:a[++i]=s:(a[++i]=null,c.push({i,x:Pt(r,s)})),n=Is.lastIndex;return n<e.length&&(o=e.slice(n),a[i]?a[i]+=o:a[++i]=o),a.length<2?c[0]?ud(c[0].x):ld(e):(e=c.length,function(l){for(var u=0,h;u<e;++u)a[(h=c[u]).i]=h.x(l);return a.join("")})}function Go(t,e){var n=typeof e,r;return e==null||n==="boolean"?Xo(e):(n==="number"?Pt:n==="string"?(r=ye(e))?(e=r,Fr):Kc:e instanceof ye?Fr:e instanceof Date?ad:od(e)?sd:Array.isArray(e)?id:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?cd:Pt)(t,e)}function hd(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var Fi=180/Math.PI,lo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function jc(t,e,n,r,s,o){var i,a,c;return(i=Math.sqrt(t*t+e*e))&&(t/=i,e/=i),(c=t*n+e*r)&&(n-=t*c,r-=e*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),t*r<e*n&&(t=-t,e=-e,c=-c,i=-i),{translateX:s,translateY:o,rotate:Math.atan2(e,t)*Fi,skewX:Math.atan(c)*Fi,scaleX:i,scaleY:a}}var fr;function fd(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?lo:jc(e.a,e.b,e.c,e.d,e.e,e.f)}function dd(t){return t==null||(fr||(fr=document.createElementNS("http://www.w3.org/2000/svg","g")),fr.setAttribute("transform",t),!(t=fr.transform.baseVal.consolidate()))?lo:(t=t.matrix,jc(t.a,t.b,t.c,t.d,t.e,t.f))}function Jc(t,e,n,r){function s(l){return l.length?l.pop()+" ":""}function o(l,u,h,d,p,w){if(l!==h||u!==d){var y=p.push("translate(",null,e,null,n);w.push({i:y-4,x:Pt(l,h)},{i:y-2,x:Pt(u,d)})}else(h||d)&&p.push("translate("+h+e+d+n)}function i(l,u,h,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:h.push(s(h)+"rotate(",null,r)-2,x:Pt(l,u)})):u&&h.push(s(h)+"rotate("+u+r)}function a(l,u,h,d){l!==u?d.push({i:h.push(s(h)+"skewX(",null,r)-2,x:Pt(l,u)}):u&&h.push(s(h)+"skewX("+u+r)}function c(l,u,h,d,p,w){if(l!==h||u!==d){var y=p.push(s(p)+"scale(",null,",",null,")");w.push({i:y-4,x:Pt(l,h)},{i:y-2,x:Pt(u,d)})}else(h!==1||d!==1)&&p.push(s(p)+"scale("+h+","+d+")")}return function(l,u){var h=[],d=[];return l=t(l),u=t(u),o(l.translateX,l.translateY,u.translateX,u.translateY,h,d),i(l.rotate,u.rotate,h,d),a(l.skewX,u.skewX,h,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,h,d),l=u=null,function(p){for(var w=-1,y=d.length,b;++w<y;)h[(b=d[w]).i]=b.x(p);return h.join("")}}}var pd=Jc(fd,"px, ","px)","deg)"),gd=Jc(dd,", ",")",")"),md=1e-12;function Ui(t){return((t=Math.exp(t))+1/t)/2}function yd(t){return((t=Math.exp(t))-1/t)/2}function wd(t){return((t=Math.exp(2*t))-1)/(t+1)}const xd=function t(e,n,r){function s(o,i){var a=o[0],c=o[1],l=o[2],u=i[0],h=i[1],d=i[2],p=u-a,w=h-c,y=p*p+w*w,b,S;if(y<md)S=Math.log(d/l)/e,b=function(D){return[a+D*p,c+D*w,l*Math.exp(e*D*S)]};else{var k=Math.sqrt(y),_=(d*d-l*l+r*y)/(2*l*n*k),v=(d*d-l*l-r*y)/(2*d*n*k),M=Math.log(Math.sqrt(_*_+1)-_),C=Math.log(Math.sqrt(v*v+1)-v);S=(C-M)/e,b=function(D){var $=D*S,O=Ui(M),U=l/(n*k)*(O*wd(e*$+M)-yd(M));return[a+U*p,c+U*w,l*O/Ui(e*$+M)]}}return b.duration=S*1e3*e/Math.SQRT2,b}return s.rho=function(o){var i=Math.max(.001,+o),a=i*i,c=a*a;return t(i,a,c)},s}(Math.SQRT2,2,4);function Sd(t){return function(){return t}}function vd(t){return+t}var Zi=[0,1];function Oe(t){return t}function uo(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Sd(isNaN(e)?NaN:.5)}function bd(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Td(t,e,n){var r=t[0],s=t[1],o=e[0],i=e[1];return s<r?(r=uo(s,r),o=n(i,o)):(r=uo(r,s),o=n(o,i)),function(a){return o(r(a))}}function Ed(t,e,n){var r=Math.min(t.length,e.length)-1,s=new Array(r),o=new Array(r),i=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++i<r;)s[i]=uo(t[i],t[i+1]),o[i]=n(e[i],e[i+1]);return function(a){var c=$f(t,a,1,r)-1;return o[c](s[c](a))}}function Qc(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function _d(){var t=Zi,e=Zi,n=Go,r,s,o,i=Oe,a,c,l;function u(){var d=Math.min(t.length,e.length);return i!==Oe&&(i=bd(t[0],t[d-1])),a=d>2?Ed:Td,c=l=null,h}function h(d){return d==null||isNaN(d=+d)?o:(c||(c=a(t.map(r),e,n)))(r(i(d)))}return h.invert=function(d){return i(s((l||(l=a(e,t.map(r),Pt)))(d)))},h.domain=function(d){return arguments.length?(t=Array.from(d,vd),u()):t.slice()},h.range=function(d){return arguments.length?(e=Array.from(d),u()):e.slice()},h.rangeRound=function(d){return e=Array.from(d),n=hd,u()},h.clamp=function(d){return arguments.length?(i=d?!0:Oe,u()):i!==Oe},h.interpolate=function(d){return arguments.length?(n=d,u()):n},h.unknown=function(d){return arguments.length?(o=d,h):o},function(d,p){return r=d,s=p,u()}}function tl(){return _d()(Oe,Oe)}function Cd(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Ur(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function je(t){return t=Ur(Math.abs(t)),t?t[1]:NaN}function Pd(t,e){return function(n,r){for(var s=n.length,o=[],i=0,a=t[0],c=0;s>0&&a>0&&(c+a+1>r&&(a=Math.max(1,r-c)),o.push(n.substring(s-=a,s+a)),!((c+=a+1)>r));)a=t[i=(i+1)%t.length];return o.reverse().join(e)}}function Rd(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var kd=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Zr(t){if(!(e=kd.exec(t)))throw new Error("invalid format: "+t);var e;return new Wo({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Zr.prototype=Wo.prototype;function Wo(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}Wo.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Md(t){t:for(var e=t.length,n=1,r=-1,s;n<e;++n)switch(t[n]){case".":r=s=n;break;case"0":r===0&&(r=n),s=n;break;default:if(!+t[n])break t;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(s+1):t}var el;function Ad(t,e){var n=Ur(t,e);if(!n)return t+"";var r=n[0],s=n[1],o=s-(el=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,i=r.length;return o===i?r:o>i?r+new Array(o-i+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Ur(t,Math.max(0,e+o-1))[0]}function Hi(t,e){var n=Ur(t,e);if(!n)return t+"";var r=n[0],s=n[1];return s<0?"0."+new Array(-s).join("0")+r:r.length>s+1?r.slice(0,s+1)+"."+r.slice(s+1):r+new Array(s-r.length+2).join("0")}const Vi={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Cd,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Hi(t*100,e),r:Hi,s:Ad,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Xi(t){return t}var Gi=Array.prototype.map,Wi=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Nd(t){var e=t.grouping===void 0||t.thousands===void 0?Xi:Pd(Gi.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",s=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?Xi:Rd(Gi.call(t.numerals,String)),i=t.percent===void 0?"%":t.percent+"",a=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function l(h){h=Zr(h);var d=h.fill,p=h.align,w=h.sign,y=h.symbol,b=h.zero,S=h.width,k=h.comma,_=h.precision,v=h.trim,M=h.type;M==="n"?(k=!0,M="g"):Vi[M]||(_===void 0&&(_=12),v=!0,M="g"),(b||d==="0"&&p==="=")&&(b=!0,d="0",p="=");var C=y==="$"?n:y==="#"&&/[boxX]/.test(M)?"0"+M.toLowerCase():"",D=y==="$"?r:/[%p]/.test(M)?i:"",$=Vi[M],O=/[defgprs%]/.test(M);_=_===void 0?6:/[gprs]/.test(M)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function U(N){var Z=C,Y=D,g,A,R;if(M==="c")Y=$(N)+Y,N="";else{N=+N;var z=N<0||1/N<0;if(N=isNaN(N)?c:$(Math.abs(N),_),v&&(N=Md(N)),z&&+N==0&&w!=="+"&&(z=!1),Z=(z?w==="("?w:a:w==="-"||w==="("?"":w)+Z,Y=(M==="s"?Wi[8+el/3]:"")+Y+(z&&w==="("?")":""),O){for(g=-1,A=N.length;++g<A;)if(R=N.charCodeAt(g),48>R||R>57){Y=(R===46?s+N.slice(g+1):N.slice(g))+Y,N=N.slice(0,g);break}}}k&&!b&&(N=e(N,1/0));var B=Z.length+N.length+Y.length,P=B<S?new Array(S-B+1).join(d):"";switch(k&&b&&(N=e(P+N,P.length?S-Y.length:1/0),P=""),p){case"<":N=Z+N+Y+P;break;case"=":N=Z+P+N+Y;break;case"^":N=P.slice(0,B=P.length>>1)+Z+N+Y+P.slice(B);break;default:N=P+Z+N+Y;break}return o(N)}return U.toString=function(){return h+""},U}function u(h,d){var p=l((h=Zr(h),h.type="f",h)),w=Math.max(-8,Math.min(8,Math.floor(je(d)/3)))*3,y=Math.pow(10,-w),b=Wi[8+w/3];return function(S){return p(y*S)+b}}return{format:l,formatPrefix:u}}var dr,nl,rl;Dd({thousands:",",grouping:[3],currency:["$",""]});function Dd(t){return dr=Nd(t),nl=dr.format,rl=dr.formatPrefix,dr}function Od(t){return Math.max(0,-je(Math.abs(t)))}function zd(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(je(e)/3)))*3-je(Math.abs(t)))}function Id(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,je(e)-je(t))+1}function Ld(t,e,n,r){var s=io(t,e,n),o;switch(r=Zr(r??",f"),r.type){case"s":{var i=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(o=zd(s,i))&&(r.precision=o),rl(r,i)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=Id(s,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=Od(s))&&(r.precision=o-(r.type==="%")*2);break}}return nl(r)}function $d(t){var e=t.domain;return t.ticks=function(n){var r=e();return Ff(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var s=e();return Ld(s[0],s[s.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),s=0,o=r.length-1,i=r[s],a=r[o],c,l,u=10;for(a<i&&(l=i,i=a,a=l,l=s,s=o,o=l);u-- >0;){if(l=oo(i,a,n),l===c)return r[s]=i,r[o]=a,e(r);if(l>0)i=Math.floor(i/l)*l,a=Math.ceil(a/l)*l;else if(l<0)i=Math.ceil(i*l)/l,a=Math.floor(a*l)/l;else break;c=l}return t},t}function sl(){var t=tl();return t.copy=function(){return Qc(t,sl())},Vc.apply(t,arguments),$d(t)}function Yd(t,e){t=t.slice();var n=0,r=t.length-1,s=t[n],o=t[r],i;return o<s&&(i=n,n=r,r=i,i=s,s=o,o=i),t[n]=e.floor(s),t[r]=e.ceil(o),t}const Ls=new Date,$s=new Date;function ut(t,e,n,r){function s(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return s.floor=o=>(t(o=new Date(+o)),o),s.ceil=o=>(t(o=new Date(o-1)),e(o,1),t(o),o),s.round=o=>{const i=s(o),a=s.ceil(o);return o-i<a-o?i:a},s.offset=(o,i)=>(e(o=new Date(+o),i==null?1:Math.floor(i)),o),s.range=(o,i,a)=>{const c=[];if(o=s.ceil(o),a=a==null?1:Math.floor(a),!(o<i)||!(a>0))return c;let l;do c.push(l=new Date(+o)),e(o,a),t(o);while(l<o&&o<i);return c},s.filter=o=>ut(i=>{if(i>=i)for(;t(i),!o(i);)i.setTime(i-1)},(i,a)=>{if(i>=i)if(a<0)for(;++a<=0;)for(;e(i,-1),!o(i););else for(;--a>=0;)for(;e(i,1),!o(i););}),n&&(s.count=(o,i)=>(Ls.setTime(+o),$s.setTime(+i),t(Ls),t($s),Math.floor(n(Ls,$s))),s.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?s.filter(r?i=>r(i)%o===0:i=>s.count(0,i)%o===0):s)),s}const Hr=ut(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Hr.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?ut(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Hr);Hr.range;const Ut=1e3,Tt=Ut*60,Zt=Tt*60,Vt=Zt*24,Ko=Vt*7,Ki=Vt*30,Ys=Vt*365,ze=ut(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Ut)},(t,e)=>(e-t)/Ut,t=>t.getUTCSeconds());ze.range;const jo=ut(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Ut)},(t,e)=>{t.setTime(+t+e*Tt)},(t,e)=>(e-t)/Tt,t=>t.getMinutes());jo.range;const Bd=ut(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Tt)},(t,e)=>(e-t)/Tt,t=>t.getUTCMinutes());Bd.range;const Jo=ut(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Ut-t.getMinutes()*Tt)},(t,e)=>{t.setTime(+t+e*Zt)},(t,e)=>(e-t)/Zt,t=>t.getHours());Jo.range;const qd=ut(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Zt)},(t,e)=>(e-t)/Zt,t=>t.getUTCHours());qd.range;const ir=ut(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Tt)/Vt,t=>t.getDate()-1);ir.range;const Qo=ut(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Vt,t=>t.getUTCDate()-1);Qo.range;const Fd=ut(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Vt,t=>Math.floor(t/Vt));Fd.range;function be(t){return ut(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*Tt)/Ko)}const vs=be(0),Vr=be(1),Ud=be(2),Zd=be(3),Je=be(4),Hd=be(5),Vd=be(6);vs.range;Vr.range;Ud.range;Zd.range;Je.range;Hd.range;Vd.range;function Te(t){return ut(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/Ko)}const ol=Te(0),Xr=Te(1),Xd=Te(2),Gd=Te(3),Qe=Te(4),Wd=Te(5),Kd=Te(6);ol.range;Xr.range;Xd.range;Gd.range;Qe.range;Wd.range;Kd.range;const ti=ut(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());ti.range;const jd=ut(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());jd.range;const Xt=ut(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Xt.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ut(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});Xt.range;const we=ut(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());we.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ut(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});we.range;function Jd(t,e,n,r,s,o){const i=[[ze,1,Ut],[ze,5,5*Ut],[ze,15,15*Ut],[ze,30,30*Ut],[o,1,Tt],[o,5,5*Tt],[o,15,15*Tt],[o,30,30*Tt],[s,1,Zt],[s,3,3*Zt],[s,6,6*Zt],[s,12,12*Zt],[r,1,Vt],[r,2,2*Vt],[n,1,Ko],[e,1,Ki],[e,3,3*Ki],[t,1,Ys]];function a(l,u,h){const d=u<l;d&&([l,u]=[u,l]);const p=h&&typeof h.range=="function"?h:c(l,u,h),w=p?p.range(l,+u+1):[];return d?w.reverse():w}function c(l,u,h){const d=Math.abs(u-l)/h,p=Ho(([,,b])=>b).right(i,d);if(p===i.length)return t.every(io(l/Ys,u/Ys,h));if(p===0)return Hr.every(Math.max(io(l,u,h),1));const[w,y]=i[d/i[p-1][2]<i[p][2]/d?p-1:p];return w.every(y)}return[a,c]}const[Qd,tp]=Jd(Xt,ti,vs,ir,Jo,jo);function Bs(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function qs(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function gn(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function ep(t){var e=t.dateTime,n=t.date,r=t.time,s=t.periods,o=t.days,i=t.shortDays,a=t.months,c=t.shortMonths,l=mn(s),u=yn(s),h=mn(o),d=yn(o),p=mn(i),w=yn(i),y=mn(a),b=yn(a),S=mn(c),k=yn(c),_={a:z,A:B,b:P,B:I,c:null,d:na,e:na,f:Ep,g:Op,G:Ip,H:vp,I:bp,j:Tp,L:il,m:_p,M:Cp,p:q,q:F,Q:oa,s:ia,S:Pp,u:Rp,U:kp,V:Mp,w:Ap,W:Np,x:null,X:null,y:Dp,Y:zp,Z:Lp,"%":sa},v={a:X,A:V,b:K,B:tt,c:null,d:ra,e:ra,f:qp,g:jp,G:Qp,H:$p,I:Yp,j:Bp,L:cl,m:Fp,M:Up,p:et,q:ot,Q:oa,s:ia,S:Zp,u:Hp,U:Vp,V:Xp,w:Gp,W:Wp,x:null,X:null,y:Kp,Y:Jp,Z:tg,"%":sa},M={a:U,A:N,b:Z,B:Y,c:g,d:ta,e:ta,f:yp,g:Qi,G:Ji,H:ea,I:ea,j:dp,L:mp,m:fp,M:pp,p:O,q:hp,Q:xp,s:Sp,S:gp,u:ip,U:ap,V:cp,w:op,W:lp,x:A,X:R,y:Qi,Y:Ji,Z:up,"%":wp};_.x=C(n,_),_.X=C(r,_),_.c=C(e,_),v.x=C(n,v),v.X=C(r,v),v.c=C(e,v);function C(H,G){return function(j){var L=[],it=-1,J=0,nt=H.length,at,rt,W;for(j instanceof Date||(j=new Date(+j));++it<nt;)H.charCodeAt(it)===37&&(L.push(H.slice(J,it)),(rt=ji[at=H.charAt(++it)])!=null?at=H.charAt(++it):rt=at==="e"?" ":"0",(W=G[at])&&(at=W(j,rt)),L.push(at),J=it+1);return L.push(H.slice(J,it)),L.join("")}}function D(H,G){return function(j){var L=gn(1900,void 0,1),it=$(L,H,j+="",0),J,nt;if(it!=j.length)return null;if("Q"in L)return new Date(L.Q);if("s"in L)return new Date(L.s*1e3+("L"in L?L.L:0));if(G&&!("Z"in L)&&(L.Z=0),"p"in L&&(L.H=L.H%12+L.p*12),L.m===void 0&&(L.m="q"in L?L.q:0),"V"in L){if(L.V<1||L.V>53)return null;"w"in L||(L.w=1),"Z"in L?(J=qs(gn(L.y,0,1)),nt=J.getUTCDay(),J=nt>4||nt===0?Xr.ceil(J):Xr(J),J=Qo.offset(J,(L.V-1)*7),L.y=J.getUTCFullYear(),L.m=J.getUTCMonth(),L.d=J.getUTCDate()+(L.w+6)%7):(J=Bs(gn(L.y,0,1)),nt=J.getDay(),J=nt>4||nt===0?Vr.ceil(J):Vr(J),J=ir.offset(J,(L.V-1)*7),L.y=J.getFullYear(),L.m=J.getMonth(),L.d=J.getDate()+(L.w+6)%7)}else("W"in L||"U"in L)&&("w"in L||(L.w="u"in L?L.u%7:"W"in L?1:0),nt="Z"in L?qs(gn(L.y,0,1)).getUTCDay():Bs(gn(L.y,0,1)).getDay(),L.m=0,L.d="W"in L?(L.w+6)%7+L.W*7-(nt+5)%7:L.w+L.U*7-(nt+6)%7);return"Z"in L?(L.H+=L.Z/100|0,L.M+=L.Z%100,qs(L)):Bs(L)}}function $(H,G,j,L){for(var it=0,J=G.length,nt=j.length,at,rt;it<J;){if(L>=nt)return-1;if(at=G.charCodeAt(it++),at===37){if(at=G.charAt(it++),rt=M[at in ji?G.charAt(it++):at],!rt||(L=rt(H,j,L))<0)return-1}else if(at!=j.charCodeAt(L++))return-1}return L}function O(H,G,j){var L=l.exec(G.slice(j));return L?(H.p=u.get(L[0].toLowerCase()),j+L[0].length):-1}function U(H,G,j){var L=p.exec(G.slice(j));return L?(H.w=w.get(L[0].toLowerCase()),j+L[0].length):-1}function N(H,G,j){var L=h.exec(G.slice(j));return L?(H.w=d.get(L[0].toLowerCase()),j+L[0].length):-1}function Z(H,G,j){var L=S.exec(G.slice(j));return L?(H.m=k.get(L[0].toLowerCase()),j+L[0].length):-1}function Y(H,G,j){var L=y.exec(G.slice(j));return L?(H.m=b.get(L[0].toLowerCase()),j+L[0].length):-1}function g(H,G,j){return $(H,e,G,j)}function A(H,G,j){return $(H,n,G,j)}function R(H,G,j){return $(H,r,G,j)}function z(H){return i[H.getDay()]}function B(H){return o[H.getDay()]}function P(H){return c[H.getMonth()]}function I(H){return a[H.getMonth()]}function q(H){return s[+(H.getHours()>=12)]}function F(H){return 1+~~(H.getMonth()/3)}function X(H){return i[H.getUTCDay()]}function V(H){return o[H.getUTCDay()]}function K(H){return c[H.getUTCMonth()]}function tt(H){return a[H.getUTCMonth()]}function et(H){return s[+(H.getUTCHours()>=12)]}function ot(H){return 1+~~(H.getUTCMonth()/3)}return{format:function(H){var G=C(H+="",_);return G.toString=function(){return H},G},parse:function(H){var G=D(H+="",!1);return G.toString=function(){return H},G},utcFormat:function(H){var G=C(H+="",v);return G.toString=function(){return H},G},utcParse:function(H){var G=D(H+="",!0);return G.toString=function(){return H},G}}}var ji={"-":"",_:" ",0:"0"},ft=/^\s*\d+/,np=/^%/,rp=/[\\^$*+?|[\]().{}]/g;function st(t,e,n){var r=t<0?"-":"",s=(r?-t:t)+"",o=s.length;return r+(o<n?new Array(n-o+1).join(e)+s:s)}function sp(t){return t.replace(rp,"\\$&")}function mn(t){return new RegExp("^(?:"+t.map(sp).join("|")+")","i")}function yn(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function op(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function ip(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function ap(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function cp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function lp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Ji(t,e,n){var r=ft.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Qi(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function up(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function hp(t,e,n){var r=ft.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function fp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ta(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function dp(t,e,n){var r=ft.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function ea(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function pp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function gp(t,e,n){var r=ft.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function mp(t,e,n){var r=ft.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function yp(t,e,n){var r=ft.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function wp(t,e,n){var r=np.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function xp(t,e,n){var r=ft.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Sp(t,e,n){var r=ft.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function na(t,e){return st(t.getDate(),e,2)}function vp(t,e){return st(t.getHours(),e,2)}function bp(t,e){return st(t.getHours()%12||12,e,2)}function Tp(t,e){return st(1+ir.count(Xt(t),t),e,3)}function il(t,e){return st(t.getMilliseconds(),e,3)}function Ep(t,e){return il(t,e)+"000"}function _p(t,e){return st(t.getMonth()+1,e,2)}function Cp(t,e){return st(t.getMinutes(),e,2)}function Pp(t,e){return st(t.getSeconds(),e,2)}function Rp(t){var e=t.getDay();return e===0?7:e}function kp(t,e){return st(vs.count(Xt(t)-1,t),e,2)}function al(t){var e=t.getDay();return e>=4||e===0?Je(t):Je.ceil(t)}function Mp(t,e){return t=al(t),st(Je.count(Xt(t),t)+(Xt(t).getDay()===4),e,2)}function Ap(t){return t.getDay()}function Np(t,e){return st(Vr.count(Xt(t)-1,t),e,2)}function Dp(t,e){return st(t.getFullYear()%100,e,2)}function Op(t,e){return t=al(t),st(t.getFullYear()%100,e,2)}function zp(t,e){return st(t.getFullYear()%1e4,e,4)}function Ip(t,e){var n=t.getDay();return t=n>=4||n===0?Je(t):Je.ceil(t),st(t.getFullYear()%1e4,e,4)}function Lp(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+st(e/60|0,"0",2)+st(e%60,"0",2)}function ra(t,e){return st(t.getUTCDate(),e,2)}function $p(t,e){return st(t.getUTCHours(),e,2)}function Yp(t,e){return st(t.getUTCHours()%12||12,e,2)}function Bp(t,e){return st(1+Qo.count(we(t),t),e,3)}function cl(t,e){return st(t.getUTCMilliseconds(),e,3)}function qp(t,e){return cl(t,e)+"000"}function Fp(t,e){return st(t.getUTCMonth()+1,e,2)}function Up(t,e){return st(t.getUTCMinutes(),e,2)}function Zp(t,e){return st(t.getUTCSeconds(),e,2)}function Hp(t){var e=t.getUTCDay();return e===0?7:e}function Vp(t,e){return st(ol.count(we(t)-1,t),e,2)}function ll(t){var e=t.getUTCDay();return e>=4||e===0?Qe(t):Qe.ceil(t)}function Xp(t,e){return t=ll(t),st(Qe.count(we(t),t)+(we(t).getUTCDay()===4),e,2)}function Gp(t){return t.getUTCDay()}function Wp(t,e){return st(Xr.count(we(t)-1,t),e,2)}function Kp(t,e){return st(t.getUTCFullYear()%100,e,2)}function jp(t,e){return t=ll(t),st(t.getUTCFullYear()%100,e,2)}function Jp(t,e){return st(t.getUTCFullYear()%1e4,e,4)}function Qp(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Qe(t):Qe.ceil(t),st(t.getUTCFullYear()%1e4,e,4)}function tg(){return"+0000"}function sa(){return"%"}function oa(t){return+t}function ia(t){return Math.floor(+t/1e3)}var ke,ul;eg({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function eg(t){return ke=ep(t),ul=ke.format,ke.parse,ke.utcFormat,ke.utcParse,ke}function ng(t){return new Date(t)}function rg(t){return t instanceof Date?+t:+new Date(+t)}function hl(t,e,n,r,s,o,i,a,c,l){var u=tl(),h=u.invert,d=u.domain,p=l(".%L"),w=l(":%S"),y=l("%I:%M"),b=l("%I %p"),S=l("%a %d"),k=l("%b %d"),_=l("%B"),v=l("%Y");function M(C){return(c(C)<C?p:a(C)<C?w:i(C)<C?y:o(C)<C?b:r(C)<C?s(C)<C?S:k:n(C)<C?_:v)(C)}return u.invert=function(C){return new Date(h(C))},u.domain=function(C){return arguments.length?d(Array.from(C,rg)):d().map(ng)},u.ticks=function(C){var D=d();return t(D[0],D[D.length-1],C??10)},u.tickFormat=function(C,D){return D==null?M:l(D)},u.nice=function(C){var D=d();return(!C||typeof C.range!="function")&&(C=e(D[0],D[D.length-1],C??10)),C?d(Yd(D,C)):u},u.copy=function(){return Qc(u,hl(t,e,n,r,s,o,i,a,c,l))},u}function sg(){return Vc.apply(hl(Qd,tp,Xt,ti,vs,ir,Jo,jo,ze,ul).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}const ei=T.z.enum(["linear","time"]),ni=T.z.object({tickSpacing:T.z.number().default(75),type:ei.optional().default("linear")}),ho=t=>{const e=ni.parse(t);return ag[e.type](e)};class og{constructor(e){m(this,"props");this.props=e}generate({decimalToDataScale:e,size:n}){const r=[0,n],s=[new E.m(e.pos(0)).date(),new E.m(e.pos(1)).date()],o=sg().domain(s).range(r);return o.ticks(fl(n,this.props.tickSpacing)).map(a=>({label:this.tickLabel(a),position:o(a)}))}tickLabel(e){const n=new E.m(e).date();let r=`:${n.getSeconds()}`;if(n.getMilliseconds()!==0){const o=Math.round(n.getMilliseconds()).toString().padStart(3,"0").replace(/0+$/,"");r+=`.${o}`}return n.getSeconds()===0&&n.getMilliseconds()===0&&(r=`${n.getHours()}:${n.getMinutes().toString().padStart(2,"0")}`),r}}class ig{constructor(e){m(this,"props");this.props=e}generate({decimalToDataScale:e,size:n}){const r=[0,n],s=[e.pos(0),e.pos(1)],o=sl().domain(s).range(r),i=fl(n,this.props.tickSpacing);return o.ticks(i).map(c=>({label:this.tickLabel(c),position:o(c)}))}tickLabel(e){return e.toString()}}const fl=(t,e)=>{const n=Math.floor(t/e);return n>0?n:1},ag={linear:t=>new ig(t),time:t=>new og(t)},ri=ni.extend({color:f.Color.z,type:ei.optional().default("linear"),font:T.z.string(),showGrid:T.z.boolean().optional().default(!0),location:f.J.outer,gridColor:f.Color.z}),Dt=4;let dl=class{constructor(e,n){m(this,"ctx");m(this,"state");m(this,"tickFactory");this.ctx=e,this.state=n,this.tickFactory=ho(this.state)}setState(e){this.state=E.prettyParse(ri,e),this.tickFactory=ho(e)}render(e){const{lower2d:n}=this.ctx;switch(n.font=this.state.font,n.fillStyle=this.state.color.hex,n.lineWidth=1,this.state.location){case"left":return this.drawLeft(e);case"right":return this.drawRight(e);case"top":return this.drawTop(e);default:return this.drawBottom(e)}}drawBottom(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.To.width(r),o=f.To.height(r),i=e.position,a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"x",l.position),f.q.translate(i,{x:l.position,y:-o})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"x",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x+u.position,i.y),n.lineTo(i.x+u.position,i.y+Dt),n.stroke(),n.fillText(u.label,i.x+u.position-l.width/2,i.y+5+l.height)}).height+Dt}}drawTop(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.To.width(r),o=f.To.height(r),i=f.q.translate(e.position,"y",e.size),a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"x",l.position),f.q.translate(i,{x:l.position,y:o})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"x",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x+u.position,i.y),n.lineTo(i.x+u.position,i.y-Dt),n.stroke(),n.fillText(u.label,i.x+u.position-l.width/2,i.y-5-l.height)}).height+Dt}}drawLeft(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.To.height(r),o=f.To.width(r),i=f.q.translate(e.position,"x",e.size),a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"y",l.position),f.q.translate(i,{x:o,y:l.position})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"y",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x,i.y+u.position),n.lineTo(i.x-Dt,i.y+u.position),n.stroke(),n.fillText(u.label,i.x-l.width-Dt*2,i.y+u.position+l.height/3)}).width+Dt*2}}drawRight(e){const{lower2d:n}=this.ctx,{plot:r}=e,s=f.To.height(r),o=f.To.width(r),i=e.position,a=this.tickFactory.generate({...e,size:s});return this.maybeDrawGrid(s,a,l=>[f.q.translate(i,"y",l.position),f.q.translate(i,{x:-o,y:l.position})]),n.strokeStyle=this.state.color.hex,this.drawLine(i,f.q.translate(i,"y",s)),{size:this.drawTicks(a,(l,u)=>{n.moveTo(i.x,i.y+u.position),n.lineTo(i.x+Dt,i.y+u.position),n.stroke(),n.fillText(u.label,i.x+Dt+2,i.y+u.position+l.height/3)}).width+Dt*2}}drawLine(e,n){const{lower2d:r}=this.ctx;r.beginPath(),r.moveTo(...f.q.couple(e)),r.lineTo(...f.q.couple(n)),r.stroke()}drawTicks(e,n){let r=f._$1.ZERO;return e.forEach(s=>{const o=E.dimensions(s.label,this.state.font,this.ctx.lower2d);r=f._$1.max([r,o]),n(o,s)}),r}maybeDrawGrid(e,n,r){const{showGrid:s,gridColor:o}=this.state;if(s){const i=f.R.construct(-1,1),a=f.R.construct(e-1,e+1);this.ctx.lower2d.strokeStyle=o.hex,n.filter(({position:c})=>!f.R.contains(i,c)&&!f.R.contains(a,c)).forEach(c=>this.drawLine(...r(c)))}}};const Er=(t,e)=>f.To.construct(f.To.left(t)-e.x,f.To.top(t)-e.y,f.To.width(t)+e.x*2,f.To.height(t)+e.y*2);class Gr{constructor(e,n=f.k.XY.IDENTITY){m(this,"scale_");m(this,"wrapped");this.wrapped=e,this.scale_=n}get fontStretch(){return this.wrapped.fontStretch}set fontStretch(e){this.wrapped.fontStretch=e}get fontVariantCaps(){return this.wrapped.fontVariantCaps}set fontVariantCaps(e){this.wrapped.fontVariantCaps=e}isContextLost(){return this.wrapped.isContextLost()}get wordSpacing(){return this.wrapped.wordSpacing}set wordSpacing(e){this.wrapped.wordSpacing=e}get letterSpacing(){return this.wrapped.letterSpacing}set letterSpacing(e){this.wrapped.letterSpacing=e}get textRendering(){return this.wrapped.textRendering}set textRendering(e){this.wrapped.textRendering=e}reset(){this.wrapped.reset()}applyScale(e){return new Gr(this,e)}get canvas(){return this.wrapped.canvas}get miterLimit(){return this.wrapped.miterLimit}set miterLimit(e){this.wrapped.miterLimit=this.scale_.x.dim(e)}get globalAlpha(){return this.wrapped.globalAlpha}set globalAlpha(e){this.wrapped.globalAlpha=e}get globalCompositeOperation(){return this.wrapped.globalCompositeOperation}set globalCompositeOperation(e){this.wrapped.globalCompositeOperation=e}get fillStyle(){return this.wrapped.fillStyle}set fillStyle(e){this.wrapped.fillStyle=e}get strokeStyle(){return this.wrapped.strokeStyle}set strokeStyle(e){this.wrapped.strokeStyle=e}drawImage(e,n,r,s,o,i,a,c,l){this.wrapped.drawImage(e,n,r,s,o,i,a,c,l)}beginPath(){this.wrapped.beginPath()}clip(e,n){this.wrapped.clip(e,n)}fill(e,n){if(e==null)return this.wrapped.fill();this.wrapped.fill(e,n)}isPointInPath(e,n,r,s){return this.wrapped.isPointInPath(e,n,r,s)}isPointInStroke(e,n,r){return this.wrapped.isPointInStroke(e,n,r)}stroke(e){if(e==null)return this.wrapped.stroke();this.wrapped.stroke(e)}createConicGradient(e,n,r){return this.wrapped.createConicGradient(e,n,r)}createLinearGradient(e,n,r,s){return this.wrapped.createLinearGradient(e,n,r,s)}createPattern(e,n){return this.wrapped.createPattern(e,n)}createRadialGradient(e,n,r,s,o,i){return this.wrapped.createRadialGradient(e,n,r,s,o,i)}get filter(){return this.wrapped.filter}set filter(e){this.wrapped.filter=e}createImageData(e,n,r){return this.wrapped.createImageData(e,n,r)}getImageData(e,n,r,s,o){return this.wrapped.getImageData(e,n,r,s,o)}putImageData(e,n,r,s,o,i,a){this.wrapped.putImageData(e,n,r,s,o,i,a)}get imageSmoothingEnabled(){return this.wrapped.imageSmoothingEnabled}set imageSmoothingEnabled(e){this.wrapped.imageSmoothingEnabled=e}get imageSmoothingQuality(){return this.wrapped.imageSmoothingQuality}set imageSmoothingQuality(e){this.wrapped.imageSmoothingQuality=e}arc(e,n,r,s,o,i){this.wrapped.arc(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),s,o,i)}arcTo(e,n,r,s,o){this.wrapped.arcTo(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.pos(r),this.scale_.y.pos(s),this.scale_.x.dim(o))}bezierCurveTo(e,n,r,s,o,i){this.wrapped.bezierCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.pos(r),this.scale_.y.pos(s),this.scale_.x.pos(o),this.scale_.y.pos(i))}closePath(){this.wrapped.closePath()}ellipse(e,n,r,s,o,i,a,c){this.wrapped.ellipse(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s),o,i,a,c)}lineTo(e,n){this.wrapped.lineTo(this.scale_.x.pos(e),this.scale_.y.pos(n))}moveTo(e,n){this.wrapped.moveTo(this.scale_.x.pos(e),this.scale_.y.pos(n))}quadraticCurveTo(e,n,r,s){this.wrapped.quadraticCurveTo(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.pos(r),this.scale_.y.pos(s))}rect(e,n,r,s){this.wrapped.rect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s))}roundRect(e,n,r,s,o){this.wrapped.roundRect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s),typeof o=="number"?this.scale_.x.dim(o):o)}get lineCap(){return this.wrapped.lineCap}set lineCap(e){this.wrapped.lineCap=e}get lineDashOffset(){return this.wrapped.lineDashOffset}set lineDashOffset(e){this.wrapped.lineDashOffset=this.scale_.x.dim(e)}get lineJoin(){return this.wrapped.lineJoin}set lineJoin(e){this.wrapped.lineJoin=e}get lineWidth(){return this.wrapped.lineWidth}set lineWidth(e){this.wrapped.lineWidth=this.scale_.x.dim(e)}getLineDash(){return this.wrapped.getLineDash()}setLineDash(e){const n=Array.from(e).map(r=>this.scale_.x.dim(r));this.wrapped.setLineDash(n)}clearRect(e,n,r,s){this.wrapped.clearRect(e,n,r,s)}fillRect(e,n,r,s){this.wrapped.fillRect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s))}strokeRect(e,n,r,s){this.wrapped.strokeRect(this.scale_.x.pos(e),this.scale_.y.pos(n),this.scale_.x.dim(r),this.scale_.y.dim(s))}get shadowBlur(){return this.wrapped.shadowBlur}set shadowBlur(e){this.wrapped.shadowBlur=e}get shadowColor(){return this.wrapped.shadowColor}set shadowColor(e){this.wrapped.shadowColor=e}get shadowOffsetX(){return this.wrapped.shadowOffsetX}set shadowOffsetX(e){this.wrapped.shadowOffsetX=e}get shadowOffsetY(){return this.wrapped.shadowOffsetY}restore(){this.wrapped.restore()}save(){this.wrapped.save()}fillText(e,n,r,s){this.wrapped.fillText(e,this.scale_.x.pos(n),this.scale_.y.pos(r),s!=null?this.scale_.x.dim(s):void 0)}measureText(e){this.wrapped.font=Fs(this.wrapped.font,this.scale_.x.reverse());const n=this.wrapped.measureText(e);return this.wrapped.font=Fs(this.wrapped.font,this.scale_.x),n}strokeText(e,n,r,s){this.wrapped.strokeText(e,this.scale_.x.pos(n),this.scale_.y.pos(r),s!=null?this.scale_.x.dim(s):void 0)}get direction(){return this.wrapped.direction}set direction(e){this.wrapped.direction=e}get font(){return this.wrapped.font}set font(e){this.wrapped.font=Fs(e,this.scale_.x)}get fontKerning(){return this.wrapped.fontKerning}set fontKerning(e){this.wrapped.fontKerning=e}get textAlign(){return this.wrapped.textAlign}set textAlign(e){this.wrapped.textAlign=e}get textBaseline(){return this.wrapped.textBaseline}set textBaseline(e){this.wrapped.textBaseline=e}getTransform(){return this.wrapped.getTransform()}resetTransform(){this.wrapped.resetTransform()}rotate(e){this.wrapped.rotate(e)}scale(e,n){this.wrapped.scale(e,n)}scissor(e,n=f.q.ZERO){const r=new Path2D;return e=Er(e,n),r.rect(...f.q.couple(f.To.topLeft(e)),...f._$1.couple(f.To.dims(e))),this.save(),this.clip(r),()=>this.restore()}setTransform(e,n,r,s,o,i){this.wrapped.setTransform(e,n,r,s,o,i)}transform(e,n,r,s,o,i){this.wrapped.transform(e,n,r,s,o,i)}translate(e,n){this.wrapped.translate(e,n)}}const aa=/(\d+(\.\d+)?)px/,Fs=(t,e)=>{var s;const n=Number((s=t.match(aa))==null?void 0:s[1]);if(n==null)return t;const r=e.dim(n);return t.replace(aa,`${r}px`)},cg=`precision mediump float;
7
+
8
+ void main(void) {
9
+ gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
10
+ }
11
+ `,lg=`attribute vec4 a_position;
12
+
13
+ void main(void) {
14
+ gl_Position = a_position;
15
+ }
16
+ `,ca=t=>new Error(`failed to compile webgl program: ${t}`),ug=new Error("null shader encountered");class si{constructor(e,n,r){m(this,"ctx");m(this,"prog");m(this,"vertShader");m(this,"fragShader");m(this,"uniformLocCache",new Map);this.ctx=e;const s=e.gl.createProgram();if(s==null)throw ca("failed to create program");this.prog=s,this.vertShader=n,this.fragShader=r,this.compile()}setAsActive(){return this.ctx.gl.useProgram(this.prog),()=>this.ctx.gl.useProgram(null)}uniformXY(e,n){this.ctx.gl.uniform2fv(this.getUniformLoc(e),f.q.couple(f.q.construct(n)))}uniformColor(e,n){this.ctx.gl.uniform4fv(this.getUniformLoc(e),n.rgba1)}getUniformLoc(e){const n=this.uniformLocCache.get(e);if(n!=null)return n;const r=this.ctx.gl.getUniformLocation(this.prog,e);if(r==null)throw new Error(`unexpected missing uniform ${e}`);return this.uniformLocCache.set(e,r),r}compile(){const e=this.ctx.gl;this.compileShader(this.vertShader,e.VERTEX_SHADER),this.compileShader(this.fragShader,e.FRAGMENT_SHADER),e.linkProgram(this.prog)}compileShader(e,n){const r=this.ctx.gl,s=r.createShader(n);if(s==null)throw ug;if(r.shaderSource(s,e),r.compileShader(s),!r.getShaderParameter(s,r.COMPILE_STATUS)){const i=r.getShaderInfoLog(s);throw r.deleteShader(s),ca(i??"unknown")}r.attachShader(this.prog,s)}}const hg=new Float32Array([0,0,0,0,0,0]);class fg extends si{constructor(n){super(n,lg,cg);m(this,"positionBuffer");const r=n.gl.createBuffer();if(r==null)throw new E.Se("webgl: failed to create buffer");this.positionBuffer=r,n.gl.bindBuffer(n.gl.ARRAY_BUFFER,this.positionBuffer),n.gl.bufferData(n.gl.ARRAY_BUFFER,hg,n.gl.STATIC_DRAW)}exec(){const{gl:n}=this.ctx,r=n.getAttribLocation(this.prog,"a_position");n.bindBuffer(n.ARRAY_BUFFER,this.positionBuffer);const s=n.createVertexArray();n.bindVertexArray(s),n.enableVertexAttribArray(r),n.vertexAttribPointer(r,2,n.FLOAT,!1,0,0),this.setAsActive(),n.drawArrays(n.TRIANGLES,0,3)}}const la={high:1,low:0};class pl{constructor(e){m(this,"mutex",new E.Mutex);m(this,"requests",new Map);m(this,"cleanup",new Map);m(this,"afterRender");this.start(),this.afterRender=e}async set(e){let n;e.priority==="high"&&(n=await this.mutex.acquire());const r=this.requests.get(e.key);if(r==null)this.requests.set(e.key,e);else{const s=la[e.priority]>=la[r.priority],o=e.canvases.length>=r.canvases.length;s&&o&&this.requests.set(e.key,e)}n==null||n()}async render(){await this.mutex.runExclusive(async()=>{var i;const e=performance.now();if(this.requests.size===0)return;const{requests:n,cleanup:r}=this;for(const[a,c]of r.entries()){const l=n.get(a);l!=null&&(await c(l),r.delete(a))}for(const a of n.values())try{const c=await a.render();c!=null&&this.cleanup.set(a.key,c)}catch(c){console.error(c)}const s=performance.now(),o=E.w.milliseconds(s-e);o.greaterThan(E.w.milliseconds(25))&&console.warn(`Render loop for ${this.requests.size} took longer than 16ms to execute: ${o.milliseconds}`),this.requests.clear(),(i=this.afterRender)==null||i.call(this)})}async start(){do{try{await this.render()}catch(e){console.error(e)}await this.sleep()}while(!0)}async sleep(){return await new Promise(requestAnimationFrame)}}var Mt;let gt=(Mt=class{constructor(e,n,r,s){m(this,"glCanvas");m(this,"upper2dCanvas");m(this,"lower2dCanvas");m(this,"gl");m(this,"lower2d");m(this,"upper2d");m(this,"region");m(this,"dpr");m(this,"loop");m(this,"clearProgram");m(this,"os");this.upper2dCanvas=r,this.lower2dCanvas=n,this.glCanvas=e,this.os=s;const o=this.lower2dCanvas.getContext("2d");if(o==null)throw new Error("Could not get 2D context");this.lower2d=new Gr(o);const i=this.upper2dCanvas.getContext("2d");if(i==null)throw new Error("Could not get 2D context");this.upper2d=new Gr(i);const a={preserveDrawingBuffer:!0,powerPreference:"high-performance",stencil:!1,depth:!1},c=this.glCanvas.getContext("webgl2",a);if(c==null)throw new Error("Could not get WebGL context");c.disable(c.DEPTH_TEST),c.disable(c.STENCIL_TEST),c.disable(c.CULL_FACE),c.disable(c.DITHER),this.gl=c,this.glCanvas.oncontextlost=console.log;const l=()=>{this.gl.flush(),this.gl.finish()};this.loop=new pl(l),this.region=f.To.ZERO,this.dpr=1,this.os==="Windows"&&(this.clearProgram=new fg(this))}static create(e,n,r,s,o){const i=new Mt(n,r,s,o);return e.set(Mt.CONTEXT_KEY,i),i}static useOptional(e){return e.getOptional(Mt.CONTEXT_KEY)}static use(e){return e.get(Mt.CONTEXT_KEY)}update(e){e.set(Mt.CONTEXT_KEY,this)}resize(e,n){f.To.equals(this.region,e)&&this.dpr===n||(this.region=e,this.dpr=n,this.resizeCanvas(this.glCanvas),this.resizeCanvas(this.upper2dCanvas),this.resizeCanvas(this.lower2dCanvas),this.lower2d.scale(this.dpr,this.dpr),this.upper2d.scale(this.dpr,this.dpr),this.gl.viewport(0,0,f.To.width(e)*n,f.To.height(e)*n))}resizeCanvas(e){e.width=f.To.width(this.region)*this.dpr,e.height=f.To.height(this.region)*this.dpr}get aspect(){return f.To.aspect(this.region)}scaleRegion(e){return new f.k.XY(f.k.Scale.scale(0,1).scale(f.To.width(e)).translate(f.To.left(e)).reBound(f.To.width(this.region)).scale(-1,1),f.k.Scale.scale(0,1).scale(f.To.height(e)).invert().translate(f.To.top(e)).reBound(f.To.height(this.region)).scale(-1,1).invert())}scissor(e,n=f.q.ZERO,r){const s=[];return r.includes("upper2d")&&s.push(this.upper2d.scissor(e,n)),r.includes("lower2d")&&s.push(this.lower2d.scissor(e,n)),r.includes("gl")&&s.push(this.scissorGL(e,n)),()=>s.forEach(o=>o())}scissorGL(e,n=f.q.ZERO){return this.gl.enable(this.gl.SCISSOR_TEST),e=Er(e,n),this.gl.scissor(f.To.left(e)*this.dpr,(f.To.height(this.region)-f.To.bottom(e))*this.dpr,f.To.width(e)*this.dpr,f.To.height(e)*this.dpr),()=>this.gl.disable(this.gl.SCISSOR_TEST)}erase(e,n=f.q.ZERO,...r){n=f.q.construct(n),r.length===0&&(r=["upper2d","lower2d","gl"]),r.includes("upper2d")&&this.eraseCanvas(this.upper2d,e,n),r.includes("lower2d")&&this.eraseCanvas(this.lower2d,e,n),r.includes("gl")&&this.eraseGL(e,n)}eraseGL(e,n=f.q.ZERO){var o;const{gl:r}=this,s=this.scissorGL(Er(e,n));r.clearColor(...f.ZERO.rgba1),r.clear(r.COLOR_BUFFER_BIT),this.os==="Windows"&&((o=this.clearProgram)==null||o.exec()),s()}eraseCanvas(e,n,r=f.q.ZERO){const s=Er(n,r);e.clearRect(...f.q.couple(f.To.topLeft(s)),...f._$1.couple(f.To.dims(s)))}},m(Mt,"CONTEXT_KEY",f.CSS.B("render-context")),Mt);const $t="layout",fo="data",Gt="tool";var zt;let mt=(zt=class{constructor(e){m(this,"f");this.f=e}static control(e,n){e.set(zt.CONTEXT_KEY,new zt(n),!1)}static useRequest(e){return e.get(zt.CONTEXT_KEY).f}static useOptionalRequest(e){var n;return((n=e.getOptional(zt.CONTEXT_KEY))==null?void 0:n.f)??null}static requestRender(e,n){this.useRequest(e)(n)}},m(zt,"CONTEXT_KEY","pluto-vis-renderer"),zt),oi=class{constructor(){m(this,"prevErase",f.To.ZERO)}erase(e,n,r,s,o){!f.To.equals(r,n)&&!f.To.equals(this.prevErase,r)?(e.erase(r,s,...o),this.prevErase=r):e.erase(n,s,...o)}};const ar=ri.extend({bounds:f.R.bounds.optional(),autoBounds:T.z.object({lower:T.z.boolean().optional().default(!0),upper:T.z.boolean().optional().default(!0)}).or(T.z.boolean().optional().default(!0)),autoBoundPadding:T.z.number().optional(),autoBoundUpdateInterval:E.w.z.optional().default(E.w.seconds(2)),size:T.z.number().optional().default(0),label:T.z.string().optional().default(""),labelSize:T.z.number().optional().default(0)}).partial({color:!0,font:!0,gridColor:!0}),dg=2,pg=7,gl=(t,e)=>f.R.contains({lower:t-pg,upper:t+dg},e),gg=f.R.DECIMAL,ua=E.m.now(),mg={lower:Number(ua.valueOf()),upper:Number(ua.add(E.w.HOUR).valueOf())},ml=t=>t==="linear"?gg:mg,yg=(t,e=.1,n)=>{const r=f.R.max(t.filter(f.R.isFinite));if(!f.R.isFinite(r))return ml(n);const{lower:s,upper:o}=r;if(o===s)return{lower:s-1,upper:o+1};const i=(o-s)*e;return{lower:s-i,upper:o+i}},wg=.01,xg=.1;class yl extends E.Composite{async afterUpdate(){var n;this.internal.render=gt.use(this.ctx);const e=E.use(this.ctx);(n=this.state).autoBoundPadding??(n.autoBoundPadding=f.g.construct(this.state.location)==="x"?xg:wg),this.internal.core=new dl(this.internal.render,{color:e.colors.gray.l8,font:E.fontString(e,"small"),gridColor:e.colors.gray.l2,...this.state}),mt.requestRender(this.ctx,$t),this.internal.updateBounds==null&&(this.internal.updateBounds=E.r(r=>{this.setState(s=>({...s,bounds:r}))},this.state.autoBoundUpdateInterval.milliseconds))}async afterDelete(){mt.requestRender(this.ctx,$t)}renderAxis(e,n){if(!e.canvases.includes("lower2d"))return;const{core:r}=this.internal,{grid:s,container:o}=e,i=Nf(`${this.type}-${this.key}`,s,o),a={...e,position:i,decimalToDataScale:n,size:this.state.size+this.state.labelSize},{size:c}=r.render(a);gl(this.state.size,c)||this.setState(l=>({...l,size:c}))}async bounds(e,n){var l,u;if(e&&this.internal.boundSnapshot!=null)return[this.internal.boundSnapshot,null];const{lower:r,upper:s}=wl(this.state.autoBounds);if(!r&&!s&&this.state.bounds!=null)return this.internal.boundSnapshot=this.state.bounds,[this.state.bounds,null];const o=h=>({upper:s||this.state.bounds==null?h.upper:this.state.bounds.upper,lower:r||this.state.bounds==null?h.lower:this.state.bounds.lower});let i,a=null;try{const h=await n();i=yg(h,this.state.autoBoundPadding,this.state.type)}catch(h){i=ml(this.state.type),a=h}const c=o(i);return this.internal.boundSnapshot=c,(this.state.bounds==null||r&&this.state.bounds.lower!==c.lower||s&&this.state.bounds.upper!==c.upper)&&((u=(l=this.internal).updateBounds)==null||u.call(l,c)),[c,a]}async dataToDecimalScale(e,n,r){const[s,o]=await this.bounds(e,n),i=f.g.swap(f.g.construct(this.state.location));return[f.k.Scale.scale(s).scale(1).translate(-f.To.root(r)[i]).magnify(1/f.To.dim(r,i)),o]}}const wl=t=>typeof t=="boolean"?{lower:t,upper:t}:{lower:(t==null?void 0:t.lower)??!0,upper:(t==null?void 0:t.upper)??!0},Sg=`precision lowp float;
17
+ uniform lowp vec4 u_color;
18
+
19
+ void main(void) {
20
+ gl_FragColor = u_color;
21
+ }
22
+ `,vg=`attribute float a_x;
23
+ attribute float a_y;
24
+ attribute lowp vec2 a_translate;
25
+
26
+ uniform lowp vec2 u_scale_aggregate;
27
+ uniform lowp vec2 u_offset_aggregate;
28
+
29
+ void main(void) {
30
+ vec2 transformed = u_scale_aggregate * vec2(a_x,a_y) + u_offset_aggregate;
31
+ transformed = transformed + a_translate;
32
+ gl_Position = vec4(transformed, 0.0, 1.0);
33
+ }
34
+ `,ha=E.d.FLOAT32.density.valueOf(),xl=T.z.object({x:no,y:no,label:T.z.string().optional(),color:f.Color.z,strokeWidth:T.z.number().default(1),downsample:T.z.number().min(1).max(50).optional().default(1)}),bg=(t,e,n)=>t===-1||e===-1||t>=n.length?NaN:Number(n[t].at(e)),Tg=E.w.milliseconds(2);f.q.NAN,f.q.NAN,f.ZERO;const $e=class $e extends si{constructor(n){super(n,vg,Sg);m(this,"translationBufferCache",new Map);this.translationBufferCache=new Map}bindState({strokeWidth:n,color:r}){return this.uniformColor("u_color",r),this.attrStrokeWidth(n)}bindScale(n,r){const s=f.q.scale(n.scale,r.scale),o=f.q.translate(f.q.scale(r.scale,n.offset),r.offset);this.uniformXY("u_scale_aggregate",s),this.uniformXY("u_offset_aggregate",o)}draw({x:n,y:r,count:s,downsample:o,xOffset:i,yOffset:a},c){const{gl:l}=this.ctx;this.bindAttrBuffer("x",n.glBuffer,o,i),this.bindAttrBuffer("y",r.glBuffer,o,a),l.drawArraysInstanced(l.LINE_STRIP,0,s/o,c)}static create(n){const r=gt.use(n),s=new $e(r);return n.set($e.CONTEXT_KEY,s),s}static use(n){return n.get($e.CONTEXT_KEY)}bindAttrBuffer(n,r,s,o=0){const{gl:i}=this.ctx;i.bindBuffer(i.ARRAY_BUFFER,r);const a=i.getAttribLocation(this.prog,`a_${n}`);i.vertexAttribPointer(a,1,i.FLOAT,!1,ha*s,ha*o),i.enableVertexAttribArray(a)}getAndBindTranslationBuffer(n){const{gl:r}=this.ctx,s=`${this.ctx.aspect}:${n}`,o=this.translationBufferCache.get(s);if(o!=null)return r.bindBuffer(r.ARRAY_BUFFER,o.glBuffer),o;const i=r.createBuffer();if(i==null)throw new E.Se("Failed to create buffer from WebGL context");const a=_g(this.ctx.aspect,n);r.bindBuffer(r.ARRAY_BUFFER,i),r.bufferData(r.ARRAY_BUFFER,a,r.DYNAMIC_DRAW);const c={glBuffer:i,jsBuffer:a};return this.translationBufferCache.set(s,c),c}attrStrokeWidth(n){const{gl:r}=this.ctx,{jsBuffer:s}=this.getAndBindTranslationBuffer(n),o=r.getAttribLocation(this.prog,"a_translate");return r.vertexAttribPointer(o,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(o),r.vertexAttribDivisor(o,1),s.length/2}};m($e,"CONTEXT_KEY","pluto-line-gl-program");let Wr=$e;class Fn extends E.Leaf{constructor(){super(...arguments);m(this,"schema",xl)}async afterUpdate(){if(this.deleted)return;const{internal:n}=this;n.xTelem=await Lt(this.ctx,this.state.x,n.xTelem),n.yTelem=await Lt(this.ctx,this.state.y,n.yTelem),n.instrumentation=sr(this.ctx,"line"),n.prog=Wr.use(this.ctx),n.requestRender=mt.useRequest(this.ctx),n.xTelem.onChange(()=>n.requestRender(fo)),n.yTelem.onChange(()=>n.requestRender(fo)),n.requestRender($t)}async afterDelete(){var r,s,o,i;const{internal:n}=this;await((s=(r=n.xTelem).cleanup)==null?void 0:s.call(r)),await((i=(o=n.yTelem).cleanup)==null?void 0:i.call(o)),n.requestRender($t)}async xBounds(){return(await this.internal.xTelem.value())[0]}async yBounds(){return(await this.internal.yTelem.value())[0]}async findByXValue(n,r){const{xTelem:s,yTelem:o}=this.internal,[,i]=await s.value();let[a,c]=[-1,-1];i.find((S,k)=>{const _=S.binarySearch(r),v=_>=0&&_<S.length;return v&&([a,c]=[_,k]),v});const{key:l}=this,{color:u,label:h}=this.state,d={key:l,color:u,label:h,position:{x:0,y:0},value:{x:NaN,y:NaN}};if(a===-1||c===-1)return d;const p=i[c];d.value.x=bg(c,a,i);const[,w]=await o.value(),y=w.find(S=>f.R.contains(S.alignmentBounds,p.alignment+BigInt(a)));if(y==null)return d;const b=Number(y.alignment-p.alignment);return d.value.y=Number(y.at(a-b)),d.position={x:n.dataToDecimalScale.x.pos(d.value.x),y:n.dataToDecimalScale.y.pos(d.value.y)},d}async render(n){if(this.deleted)return;const{downsample:r}=this.state,{xTelem:s,yTelem:o,prog:i}=this.internal,{dataToDecimalScale:a,exposure:c}=n,[[,l],[,u]]=await Promise.all([s.value(),o.value()]);l.forEach(y=>y.updateGLBuffer(i.ctx.gl)),u.forEach(y=>y.updateGLBuffer(i.ctx.gl));const h=Ag(l,u,c,r,Tg);this.internal.instrumentation.L.debug("render",()=>({key:this.key,downsample:r,scale:f.k.xyScaleToTransform(a),props:n.region,ops:Ng(h)}));const d=i.setAsActive(),p=i.bindState(this.state),w=f.k.xyScaleToTransform(i.ctx.scaleRegion(n.region));h.forEach(y=>{const b=f.k.xyScaleToTransform(kg(a,y));i.bindScale(b,w),i.draw(y,p)}),d()}}m(Fn,"TYPE","line");const Eg=5e3,_g=(t,e)=>Rg(Pg(t),e).map((n,r)=>Math.floor(r/Cg)*(1/(Eg*t))*n),Cg=5,Pg=t=>new Float32Array([0,0,0,t,0,-t,1,0,-1,0]),Rg=(t,e)=>{const n=new Float32Array(t.length*e);for(let r=0;r<e;r++)n.set(t,r*t.length);return n},kg=(t,e)=>t.translate(t.x.dim(Number(e.x.sampleOffset)),t.y.dim(Number(e.y.sampleOffset))),Mg={[Fn.TYPE]:Fn},Ag=(t,e,n,r,s)=>{if(t.length===0||e.length===0)return[];const o=[];return t.forEach(i=>e.forEach(a=>{if(!Dg(i,a,s))return;let c=0,l=0;i.alignment<a.alignment?c=Number(a.alignment-i.alignment):a.alignment<i.alignment&&(l=Number(i.alignment-a.alignment));const u=Math.min(i.length-c,a.length-l);if(u===0)return;const h=f.j(Math.round(n*4*u),r,51);o.push({x:i,y:a,xOffset:c,yOffset:l,count:u,downsample:h})})),o},Ng=t=>t.map(e=>({...e,x:e.x.digest,y:e.y.digest})),Dg=(t,e,n)=>{if(!(t._timeRange!=null&&e._timeRange!=null))throw new E.Se(`Encountered series without time range in buildDrawOperations. X series present: ${t._timeRange!=null}, Y series present: ${e._timeRange!=null}`);const s=t.timeRange.overlapsWith(e.timeRange,n),o=f.R.overlapsWith(t.alignmentBounds,e.alignmentBounds);return s&&o};class cr{constructor(e,n){m(this,"canvas");m(this,"theme");this.canvas=e,this.theme=n}rule({direction:e,region:n,position:r,...s}){return e==="x"?this.line({start:f.q.construct(f.To.left(n),r),end:f.q.construct(f.To.right(n),r),...s}):this.line({start:f.q.construct(r,f.To.top(n)),end:f.q.construct(r,f.To.bottom(n)),...s})}line({stroke:e,lineWidth:n,lineDash:r,start:s,end:o}){const i=this.canvas;i.strokeStyle=e.hex,i.lineWidth=n,i.setLineDash([r]),i.beginPath(),i.moveTo(...f.q.couple(s)),i.lineTo(...f.q.couple(o)),i.stroke()}circle({fill:e,radius:n,position:r}){const s=this.canvas;s.fillStyle=e.hex,s.beginPath(),s.arc(...f.q.couple(r),n,0,2*Math.PI),s.fill()}resolveColor(e,n){return e==null?this.resolveColor(n):typeof e=="function"?e(this.theme):new f.Color(e)}border({region:e,color:n,width:r,radius:s,location:o}){const i=this.canvas;i.strokeStyle=this.resolveColor(n,this.theme.colors.border).hex,i.lineWidth=r??this.theme.sizes.border.width,s??(s=this.theme.sizes.border.radius),o==null||o===!0?s>0?(i.roundRect(...f.q.couple(f.To.topLeft(e)),...f.q.couple(f.To.dims(e)),s),i.stroke()):(i.rect(...f.q.couple(f.To.topLeft(e)),...f.q.couple(f.To.dims(e))),i.stroke()):E.A(o).forEach(a=>{const[c,l]=f.To.edgePoints(e,a);i.beginPath(),i.moveTo(...f.q.couple(c)),i.lineTo(...f.q.couple(l)),i.stroke()})}container({region:e,bordered:n=!0,rounded:r=!0,borderColor:s,borderRadius:o,borderWidth:i,backgroundColor:a}){o==null&&(o=this.theme.sizes.border.radius),i==null&&(i=1);const c=this.canvas;c.fillStyle=this.resolveColor(a,this.theme.colors.gray.l1).hex,c.strokeStyle=this.resolveColor(s,this.theme.colors.border).hex,c.setLineDash([]),c.lineWidth=1,c.beginPath(),r?c.roundRect(...f.q.couple(f.To.topLeft(e)),...f.q.couple(f.To.dims(e)),o):c.rect(...f.q.couple(f.To.topLeft(e)),...f.q.couple(f.To.dims(e))),c.fill(),n&&this.border({region:e,color:s,radius:o,width:i,location:n})}textContainer(e){const[n,r]=this.spacedTextDrawF(e);n.width+=12,n.height+=12;const{root:s=f.J.TOP_LEFT,offset:o=f.q.ZERO}=e,i={...e.position};s.x==="right"?i.x-=n.width+o.x:i.x+=o.x,s.y==="bottom"?i.y-=n.height+o.y:i.y+=o.y,this.container({region:f.To.construct(i,n.width,n.height),...e}),this.canvas.filter="none",r(f.q.translate(i,[6,6]))}spacedTextDrawF({text:e,direction:n,spacing:r=1,level:s="p"}){const o=E.fontString(this.theme,s),i=e.map(l=>E.dimensions(l,o,this.canvas)),a=this.theme.sizes.base*r,c=Math.max(...i.map(l=>l[f.g.dimension(n)]))+a;return[{[f.g.dimension(f.g.swap(n))]:Math.max(...i.map(l=>l[f.g.dimension(f.g.swap(n))])),[f.g.dimension(n)]:c*e.length-a},l=>{const u=E.fontString(this.theme,s);this.canvas.font=u,this.canvas.fillStyle=this.theme.colors.text.hex,this.canvas.textBaseline="top",e.forEach((h,d)=>{this.canvas.fillText(h,l.x,l.y+c*d)})}]}drawTextInCenter({box:e,text:n,level:r}){const s=E.dimensions(n,this.canvas.font,this.canvas),o=f.To.positionInCenter(f.To.construct(f.q.ZERO,s),e);return this.text({text:n,position:f.To.topLeft(o),level:r})}text({text:e,position:n,level:r="p",weight:s,shade:o,maxWidth:i}){this.canvas.font=E.fontString(this.theme,r,s),o==null?this.canvas.fillStyle=this.theme.colors.text.hex:this.canvas.fillStyle=this.theme.colors.gray[`l${o}`].hex,this.canvas.textBaseline="top";let a;i!=null&&(a=this.canvas.scissor(f.To.construct(n,i,1e3))),this.canvas.fillText(e,n.x,n.y),a==null||a()}}const ii=T.z.object({position:T.z.number().optional(),pixelPosition:T.z.number().optional(),dragging:T.z.boolean(),lineWidth:T.z.number().optional().default(1),lineDash:T.z.number().optional().default(20),color:f.Color.z});class tn extends E.Leaf{constructor(){super(...arguments);m(this,"schema",ii)}async afterUpdate(){this.internal.renderCtx=gt.use(this.ctx);const n=E.use(this.ctx);this.internal.draw=new cr(this.internal.renderCtx.upper2d,n),mt.requestRender(this.ctx,Gt)}async afterDelete(){mt.requestRender(this.ctx,Gt)}updatePositions({decimalToDataScale:n,plot:r,container:s}){if(this.state.dragging&&this.state.pixelPosition!=null){const i=n.pos((this.state.pixelPosition-f.To.top(r)+f.To.top(s))/f.To.height(r));return this.setState(a=>({...a,position:i})),this.state.pixelPosition}if(this.state.position==null){const i=n.pos(.5);this.setState(a=>({...a,position:i}))}const o=n.reverse().pos(this.state.position)*f.To.height(r)+f.To.top(r)-f.To.top(s);return isNaN(o)||this.setState(i=>({...i,pixelPosition:o})),o}async render(n){if(this.deleted)return;const{renderCtx:r}=this.internal,{location:s,plot:o}=n,i=f.J.direction(s),{upper2d:a}=r,c=this.internal.draw;let l=this.updatePositions(n);l+=f.To.top(n.container),c.rule({stroke:this.state.color,lineWidth:this.state.lineWidth,lineDash:this.state.lineDash,direction:i,region:o,position:l}),a.fillStyle=this.state.color.hex,a.beginPath(),s==="left"?(a.moveTo(f.To.left(o),l),a.lineTo(f.To.left(o)-5,l-5),a.lineTo(f.To.left(o)-5,l+5)):s==="right"&&(a.moveTo(f.To.right(o),l),a.lineTo(f.To.right(o)+5,l-5),a.lineTo(f.To.right(o)+5,l+5)),a.closePath(),a.fill()}}m(tn,"TYPE","Rule");const Sl={[tn.TYPE]:tn},Og=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:Sl,Rule:tn,ruleStateZ:ii},Symbol.toStringTag,{value:"Module"})),zg=ar.extend({location:f.J.x.optional().default("left")});class Un extends yl{constructor(){super(...arguments);m(this,"schema",ar)}async xBounds(){return f.R.max(await Promise.all(this.lines.map(async n=>await n.xBounds())))}async render(n){if(this.deleted)return;const[r,s]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport),o=r.invert().reverse();if(this.renderAxis(n,o),await this.renderLines(n,r),await this.renderRules(n,o),s!=null)throw s}async renderLines({xDataToDecimalScale:n,plot:r,canvases:s,exposure:o},i){if(!s.includes("gl"))return;const a={region:r,dataToDecimalScale:new f.k.XY(n,i),exposure:o};await Promise.all(this.lines.map(async c=>await c.render(a)))}async renderRules({container:n,plot:r,canvases:s},o){if(!s.includes("upper2d"))return;const{location:i}=this.state,{render:a}=this.internal,c=f.To.construct(f.To.left(n),f.To.top(r),f.To.width(n),f.To.height(r)),l=a.scissor(c,f.q.ZERO,["upper2d"]),u={container:n,plot:r,decimalToDataScale:o,location:i};await Promise.all(this.rules.map(async h=>await h.render(u))),l()}async findByXValue({xDataToDecimalScale:n,plot:r,viewport:s,hold:o,exposure:i},a){const[c,l]=await this.dataToDecimalScale(o,this.dataBounds.bind(this),s);if(l!=null)throw l;const u=new f.k.XY(n,c),h={region:r,dataToDecimalScale:u,exposure:i};return(await Promise.all(this.lines.map(async d=>await d.findByXValue(h,a)))).map(d=>({...d,units:this.state.label}))}async dataBounds(){return await Promise.all(this.lines.map(async n=>await n.yBounds()))}get lines(){return this.childrenOfType(Fn.TYPE)}get rules(){return this.childrenOfType(tn.TYPE)}}m(Un,"TYPE","YAxis");const vl=T.z.object({start:E.m.z,end:E.m.z});class Kr extends E.Leaf{constructor(){super(...arguments);m(this,"schema",vl)}async afterUpdate(){this.internal.render=gt.use(this.ctx),this.internal.draw=new cr(this.internal.render.upper2d,E.use(this.ctx))}async render(){}}m(Kr,"TYPE","range-annotation");const bl=T.z.object({triggered:T.z.boolean(),status:E.specZ$1,sink:ws.optional().default(ms),source:Io.optional().default(Oo)});class jr extends E.Leaf{constructor(){super(...arguments);m(this,"schema",bl)}async afterUpdate(){var s,o,i;const{sink:n,source:r}=this.state;this.internal.source=await Lt(this.ctx,r,this.internal.source),this.internal.sink=await er(this.ctx,n,this.internal.sink),this.state.triggered&&!this.prevState.triggered&&this.internal.sink.set(((s=this.state.status.data)==null?void 0:s.authority)!==E.kd.Absolute.valueOf()).catch(console.error),await this.updateEnabledState(),(i=(o=this.internal).stopListening)==null||i.call(o),this.internal.stopListening=this.internal.source.onChange(()=>{this.updateEnabledState()})}async updateEnabledState(){const n=await this.internal.source.value();n.time.equals(this.state.status.time)||this.setState(r=>({...r,status:n,triggered:!1}))}async afterDelete(){this.asyncAfterDelete().catch(console.error)}async asyncAfterDelete(){var n,r,s,o;this.internal.stopListening(),await((r=(n=this.internal.source).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.sink).cleanup)==null?void 0:o.call(s))}render(){}}m(jr,"TYPE","Chip");const Tl=T.z.object({}),fa="control-state-provider",El=E.id.stateZ.extend({subjectColor:f.Color.z});class en extends E.Composite{constructor(){super(...arguments);m(this,"schema",Tl);m(this,"colors",new Map);m(this,"tracker");m(this,"disconnectTrackerChange");m(this,"obs",new Mo.Observer)}static use(n){return n.get(fa)}async afterUpdate(){const{internal:n}=this;n.instrumentation=sr(this.ctx,"control-state");const r=E.use(this.ctx);n.palette=r.colors.visualization.palettes.default,n.defaultColor=r.colors.gray.l6;const s=tr(this.ctx);n.client!=null&&s===n.client||(n.client=s,this.ctx.set(fa,this),await this.maybeCloseTracker(),n.client!=null&&(this.internal.instrumentation.L.debug("starting state tracker"),await this.openTracker(n.client)))}async maybeCloseTracker(){var n;this.tracker!=null&&(this.internal.instrumentation.L.debug("stopping state tracker"),(n=this.disconnectTrackerChange)==null||n.call(this),await this.tracker.close(),this.tracker=void 0)}async afterDelete(){await this.maybeCloseTracker()}onChange(n){return this.obs.onChange(n)}get(n){return Array.isArray(n)?E.n(n).map(r=>this.getOne(r)).filter(r=>r!=null):this.getOne(n)}getOne(n){if(this.tracker==null)return;const r=this.tracker.states.get(n);if(r!=null)return{...r,subjectColor:this.colors.get(r.subject.key)??this.internal.defaultColor}}async openTracker(n){var o;const{internal:r}=this,{instrumentation:s}=r;try{this.tracker=await n.control.openStateTracker()}catch{s.L.error("failed to open state tracker");return}(o=this.disconnectTrackerChange)==null||o.call(this),this.disconnectTrackerChange=this.tracker.onChange(i=>{if(s.L.debug("transfer",{transfers:i.map(a=>E.id.transferString(a))}),this.tracker==null)throw new E.Se("tracker is null inside it's own onChange callback!");this.updateColors(this.tracker),this.obs.notify(i)})}updateColors(n){const r=n.subjects(),s=r.map(a=>a.key),o=Array.from(this.colors.values());this.colors.forEach((a,c)=>!s.includes(c)&&this.colors.delete(c));const{palette:i}=this.internal;r.forEach(a=>{if(this.colors.has(a.key))return;const c=i.find(l=>!o.includes(l))??i[0];this.colors.set(a.key,c),o.push(c)})}}m(en,"TYPE","StateProvider");const _l=["acquired","released","overridden","failed"],Cl=T.z.enum(_l),Pl=T.z.object({name:T.z.string(),authority:T.z.number().default(0),acquireTrigger:T.z.number(),status:Cl.optional(),needsControlOf:E.Hy.keyZ.array().optional().default([])});class Jr extends E.Composite{constructor(){super(...arguments);m(this,"schema",Pl);m(this,"registry",new Map);m(this,"writer")}async afterUpdate(){this.internal.instrumentation=sr(this.ctx),(this.internal.prevTrigger==null||Math.abs(this.state.acquireTrigger-this.internal.prevTrigger)>1)&&(this.internal.prevTrigger=this.state.acquireTrigger);const n=tr(this.ctx),r=en.use(this.ctx);this.internal.client=n,this.internal.client==null&&await this.release(),this.internal.stateProv=r,oc(this.ctx,this),this.internal.addStatus=E.useAggregate(this.ctx),this.state.acquireTrigger>this.internal.prevTrigger?(this.acquire(),this.internal.prevTrigger=this.state.acquireTrigger):this.state.acquireTrigger<this.internal.prevTrigger&&(this.release(),this.internal.prevTrigger=this.state.acquireTrigger)}async afterDelete(){await this.release()}async updateNeedsControlOf(){if(this.internal.client==null)throw new E.Se("No cluster connected but channelKeys were requested");const n=new Set([]);for(const s of this.registry.keys())(await s.needsControlOf(this.internal.client)).forEach(i=>i!==0&&n.add(i));const r=Array.from(n);E.y.unorderedPrimitiveArrays(this.state.needsControlOf,r)!==E.y.EQUAL&&this.setState(s=>({...s,needsControlOf:r}))}async acquire(){const{client:n,addStatus:r}=this.internal;if(n==null)return r({message:`Cannot acquire control on ${this.state.name} because no cluster has been connected.`,variant:"warning"});try{await this.updateNeedsControlOf();const s=this.state.needsControlOf;if(s.length===0)return r({message:`Cannot acquire control on ${this.state.name} because there are no channels to control.`,variant:"warning"});this.writer=await n.openWriter({start:E.k.now(),channels:s,controlSubject:{key:this.key,name:this.state.name},authorities:this.state.authority}),this.setState(o=>({...o,status:"acquired"}))}catch(s){this.setState(o=>({...o,status:"failed"})),r({message:`${this.state.name} failed to acquire control: ${s.message}`,variant:"error"})}}async release(){var n;try{await((n=this.writer)==null?void 0:n.close()),this.setState(r=>({...r,status:"released"}))}catch(r){this.internal.addStatus({message:`${this.state.name} failed to release control: ${r.message}`,variant:"error"})}finally{this.writer=void 0}}async set(n){var r;this.writer==null&&await this.acquire(),await((r=this.writer)==null?void 0:r.write(n))}async setAuthority(n,r){var s;this.writer==null&&await this.acquire(),await((s=this.writer)==null?void 0:s.setAuthority(Object.fromEntries(n.map(o=>[o,r]))))}async releaseAuthority(n){var r;this.writer==null&&await this.acquire(),await((r=this.writer)==null?void 0:r.setAuthority(Object.fromEntries(n.map(s=>[s,this.state.authority]))))}deleteTelem(n){this.registry.delete(n),this.updateNeedsControlOf()}create(n){const s=(()=>{switch(n.type){case Zn.TYPE:{const o=new Zn(this,n.props);return this.registry.set(o,null),o}case Vn.TYPE:{const o=new Vn(this,this.internal.stateProv,n.props);return this.registry.set(o,null),o}case Hn.TYPE:return new Hn(this,n.props);default:return null}})();return s!=null&&this.updateNeedsControlOf(),s}}m(Jr,"TYPE","Controller");const Rl=T.z.object({channel:T.z.number()});class Zn extends Ss{constructor(n,r){super(r);m(this,"controller");m(this,"schema",Rl);this.controller=n}invalidate(){}async cleanup(){this.controller.deleteTelem(this)}async needsControlOf(n){if(this.props.channel===0)return[];const r=await n.channels.retrieve(this.props.channel),s=[r.key];return r.index!==0&&s.push(r.index),s}async set(n){const{client:r}=this.controller.internal;if(r==null)return;const s=await r.channels.retrieve(this.props.channel),o={[s.key]:n};if(s.index!==0){const i=await r.channels.retrieve(s.index);o[i.key]=E.k.now()}await this.controller.set(o)}}m(Zn,"TYPE","controlled-numeric-telem-sink");const Ig=t=>({type:Zn.TYPE,props:t,variant:"sink",valueType:"number"}),kl=T.z.object({authority:T.z.number().default(E.id.Authority.Absolute.valueOf()),channel:T.z.number()});class Hn extends Ss{constructor(n,r){super(r);m(this,"controller");m(this,"schema",kl);this.controller=n}async cleanup(){this.controller.deleteTelem(this)}async needsControlOf(n){const r=await n.channels.retrieve(this.props.channel),s=[r.key];return r.index!==0&&s.push(r.index),s}async set(n){const{controller:r}=this,{client:s}=r.internal;if(s==null)return;const o=await s.channels.retrieve(this.props.channel),i=[o.key];o.index!==0&&i.push(o.index),n?await this.controller.setAuthority(i,this.props.authority):await this.controller.releaseAuthority(i)}}m(Hn,"TYPE","acquire-channel-control");const Lg=t=>({type:Hn.TYPE,props:t,variant:"sink",valueType:"boolean"}),Ml=T.z.object({channel:T.z.number()});class Vn extends _t{constructor(n,r,s){super(s);m(this,"prov");m(this,"valid",!1);m(this,"stopListening");m(this,"controller");m(this,"schema",Ml);this.prov=r,this.controller=n}async needsControlOf(){return[]}maybeRevalidate(){var s;if(this.valid)return;const{channel:n}=this.props;(s=this.stopListening)==null||s.call(this);const r=E._$1.filterTransfersByChannelKey(n);this.stopListening=this.prov.onChange(o=>{var i;r(o).length!==0&&((i=this.notify)==null||i.call(this))}),this.valid=!0}async value(){this.maybeRevalidate();const n=E.k.now();if(this.props.channel===0)return{key:this.controller.key,variant:"disabled",message:"No Channel",time:n,data:{valid:!1,authority:0}};const r=this.prov.get(this.props.channel);return r==null?{key:this.controller.key,variant:"disabled",message:"Uncontrolled",time:n,data:{valid:!0,color:void 0,authority:0}}:{key:r.subject.key,variant:r.subject.key===this.controller.key?"success":"error",message:`Controlled by ${r.subject.name}`,time:n,data:{valid:!0,color:r.subjectColor,authority:r.authority}}}async cleanup(){var n;this.controller.deleteTelem(this),(n=this.stopListening)==null||n.call(this)}}m(Vn,"TYPE","controlled-status-source");const $g=t=>({type:Vn.TYPE,props:t,variant:"source",valueType:"status"}),Al=T.z.object({statusSource:Io.optional().default(Oo),colorSource:gc.optional().default(lc),status:E.specZ$1,color:f.Color.z.optional()});class Qr extends E.Leaf{constructor(){super(...arguments);m(this,"schema",Al);m(this,"stopListeningStatus");m(this,"stopListeningColor")}async afterUpdate(){var r,s;const{internal:n}=this;n.statusSource=await Lt(this.ctx,this.state.statusSource,n.statusSource),n.colorSource=await Lt(this.ctx,this.state.colorSource,n.colorSource),await this.updateState(),(r=this.stopListeningStatus)==null||r.call(this),this.stopListeningStatus=n.statusSource.onChange(()=>{this.updateState()}),(s=this.stopListeningColor)==null||s.call(this),this.stopListeningColor=n.colorSource.onChange(()=>{this.updateState()})}async afterDelete(){this.internalAfterDelete().catch(console.error)}async internalAfterDelete(){var n,r,s,o;await((r=(n=this.internal.statusSource).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.colorSource).cleanup)==null?void 0:o.call(s))}async render(){}async updateState(){const n=await this.internal.colorSource.value(),r=await this.internal.statusSource.value();n.equals(this.state.color)&&r.message===this.state.status.message||this.setState(s=>({...s,color:n,status:r}))}}m(Qr,"TYPE","Indicator");const Nl=T.z.object({needsControlOf:E.Hy.keyZ.array(),states:El.array()});class ts extends E.Leaf{constructor(){super(...arguments);m(this,"schema",Nl)}async afterUpdate(){var i;const{internal:n}=this;n.stateProv=en.use(this.ctx);const r=this.state.needsControlOf;(i=n.disconnectStateProv)==null||i.call(n);const s=E._$1.filterTransfersByChannelKey(...r),o=n.stateProv.get(r);this.setState(a=>({...a,states:o})),n.disconnectStateProv=n.stateProv.onChange(a=>{if(s(a).length===0)return;const c=n.stateProv.get(r);this.setState(l=>({...l,states:c}))})}async afterDelete(){var r;const{internal:n}=this;(r=n.disconnectStateProv)==null||r.call(n)}async render(){}}m(ts,"TYPE","Legend");const Yg={[Jr.TYPE]:Jr,[en.TYPE]:en,[Qr.TYPE]:Qr,[jr.TYPE]:jr,[ts.TYPE]:ts},Dl=T.z.object({trigger:T.z.number(),sink:ws.optional().default(ms)});class es extends E.Leaf{constructor(){super(...arguments);m(this,"schema",Dl)}async afterUpdate(){const{sink:n}=this.state;this.internal.prevTrigger==null&&(this.internal.prevTrigger=this.state.trigger),this.internal.sink=await er(this.ctx,n,this.internal.sink);const r=this.internal.prevTrigger;this.internal.prevTrigger=this.state.trigger,!(this.state.trigger<=r)&&this.internal.sink.set(!0).catch(console.error)}render(){}async afterDelete(){await this.internalAfterDelete()}async internalAfterDelete(){var r,s;const{internal:n}=this;await((s=(r=n.sink).cleanup)==null?void 0:s.call(r))}}m(es,"TYPE","Button");const Bg={[es.TYPE]:es},ai=T.z.object({dpr:T.z.number(),region:f.To.box,bootstrap:T.z.boolean().optional().default(!1),bootstrapped:T.z.boolean().optional().default(!1),glCanvas:T.z.any().optional(),upper2dCanvas:T.z.any().optional(),lower2dCanvas:T.z.any().optional(),os:E.w$1.osZ});class Xn extends E.Composite{constructor(){super(...arguments);m(this,"schema",ai);m(this,"renderContextSet",!1)}async afterUpdate(){let n=gt.useOptional(this.ctx);if(n==null){if(this.renderContextSet)throw new E.Se("[vis.worker.Canvas] - expected render context to be set");if(!this.state.bootstrap)return;const{glCanvas:r,lower2dCanvas:s,upper2dCanvas:o,os:i}=this.state;if(r==null||s==null||o==null)throw new E.Se("[vis.worker.Canvas] - expected render context bootstrap to include all canvases");n=gt.create(this.ctx,r,s,o,i),Wr.create(this.ctx),this.setState(a=>({...a,bootstrap:!1,bootstrapped:!0,glCanvas:void 0,lower2dCanvas:void 0,upper2dCanvas:void 0}))}else n.update(this.ctx);n.resize(this.state.region,this.state.dpr)}}m(Xn,"TYPE","Canvas");const Ol={[Xn.TYPE]:Xn},qg=Object.freeze(Object.defineProperty({__proto__:null,Canvas:Xn,REGISTRY:Ol,canvasStateZ:ai},Symbol.toStringTag,{value:"Module"}));function vt(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,r;n<t.length;n++)(r=vt(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var po={exports:{}},Us={},pr={exports:{}},Zs={};/**
35
+ * @license React
36
+ * use-sync-external-store-shim.production.min.js
37
+ *
38
+ * Copyright (c) Facebook, Inc. and its affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */var da;function Fg(){if(da)return Zs;da=1;var t=x;function e(h,d){return h===d&&(h!==0||1/h===1/d)||h!==h&&d!==d}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,o=t.useLayoutEffect,i=t.useDebugValue;function a(h,d){var p=d(),w=r({inst:{value:p,getSnapshot:d}}),y=w[0].inst,b=w[1];return o(function(){y.value=p,y.getSnapshot=d,c(y)&&b({inst:y})},[h,p,d]),s(function(){return c(y)&&b({inst:y}),h(function(){c(y)&&b({inst:y})})},[h]),i(p),p}function c(h){var d=h.getSnapshot;h=h.value;try{var p=d();return!n(h,p)}catch{return!0}}function l(h,d){return d()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Zs.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,Zs}var Hs={};/**
43
+ * @license React
44
+ * use-sync-external-store-shim.development.js
45
+ *
46
+ * Copyright (c) Facebook, Inc. and its affiliates.
47
+ *
48
+ * This source code is licensed under the MIT license found in the
49
+ * LICENSE file in the root directory of this source tree.
50
+ */var pa;function Ug(){return pa||(pa=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=x,e=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(_){{for(var v=arguments.length,M=new Array(v>1?v-1:0),C=1;C<v;C++)M[C-1]=arguments[C];r("error",_,M)}}function r(_,v,M){{var C=e.ReactDebugCurrentFrame,D=C.getStackAddendum();D!==""&&(v+="%s",M=M.concat([D]));var $=M.map(function(O){return String(O)});$.unshift("Warning: "+v),Function.prototype.apply.call(console[_],console,$)}}function s(_,v){return _===v&&(_!==0||1/_===1/v)||_!==_&&v!==v}var o=typeof Object.is=="function"?Object.is:s,i=t.useState,a=t.useEffect,c=t.useLayoutEffect,l=t.useDebugValue,u=!1,h=!1;function d(_,v,M){u||t.startTransition!==void 0&&(u=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var C=v();if(!h){var D=v();o(C,D)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),h=!0)}var $=i({inst:{value:C,getSnapshot:v}}),O=$[0].inst,U=$[1];return c(function(){O.value=C,O.getSnapshot=v,p(O)&&U({inst:O})},[_,C,v]),a(function(){p(O)&&U({inst:O});var N=function(){p(O)&&U({inst:O})};return _(N)},[_]),l(C),C}function p(_){var v=_.getSnapshot,M=_.value;try{var C=v();return!o(M,C)}catch{return!0}}function w(_,v,M){return v()}var y=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",b=!y,S=b?w:d,k=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:S;Hs.useSyncExternalStore=k,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Hs}var ga;function zl(){return ga||(ga=1,process.env.NODE_ENV==="production"?pr.exports=Fg():pr.exports=Ug()),pr.exports}/**
51
+ * @license React
52
+ * use-sync-external-store-shim/with-selector.production.min.js
53
+ *
54
+ * Copyright (c) Facebook, Inc. and its affiliates.
55
+ *
56
+ * This source code is licensed under the MIT license found in the
57
+ * LICENSE file in the root directory of this source tree.
58
+ */var ma;function Zg(){if(ma)return Us;ma=1;var t=x,e=zl();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,o=t.useRef,i=t.useEffect,a=t.useMemo,c=t.useDebugValue;return Us.useSyncExternalStoreWithSelector=function(l,u,h,d,p){var w=o(null);if(w.current===null){var y={hasValue:!1,value:null};w.current=y}else y=w.current;w=a(function(){function S(C){if(!k){if(k=!0,_=C,C=d(C),p!==void 0&&y.hasValue){var D=y.value;if(p(D,C))return v=D}return v=C}if(D=v,r(_,C))return D;var $=d(C);return p!==void 0&&p(D,$)?D:(_=C,v=$)}var k=!1,_,v,M=h===void 0?null:h;return[function(){return S(u())},M===null?void 0:function(){return S(M())}]},[u,h,d,p]);var b=s(l,w[0],w[1]);return i(function(){y.hasValue=!0,y.value=b},[b]),c(b),b},Us}var Vs={};/**
59
+ * @license React
60
+ * use-sync-external-store-shim/with-selector.development.js
61
+ *
62
+ * Copyright (c) Facebook, Inc. and its affiliates.
63
+ *
64
+ * This source code is licensed under the MIT license found in the
65
+ * LICENSE file in the root directory of this source tree.
66
+ */var ya;function Hg(){return ya||(ya=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=x,e=zl();function n(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,o=t.useRef,i=t.useEffect,a=t.useMemo,c=t.useDebugValue;function l(u,h,d,p,w){var y=o(null),b;y.current===null?(b={hasValue:!1,value:null},y.current=b):b=y.current;var S=a(function(){var M=!1,C,D,$=function(Z){if(!M){M=!0,C=Z;var Y=p(Z);if(w!==void 0&&b.hasValue){var g=b.value;if(w(g,Y))return D=g,g}return D=Y,Y}var A=C,R=D;if(r(A,Z))return R;var z=p(Z);return w!==void 0&&w(R,z)?R:(C=Z,D=z,z)},O=d===void 0?null:d,U=function(){return $(h())},N=O===null?void 0:function(){return $(O())};return[U,N]},[h,d,p,w]),k=S[0],_=S[1],v=s(u,k,_);return i(function(){b.hasValue=!0,b.value=v},[v]),c(v),v}Vs.useSyncExternalStoreWithSelector=l,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Vs}process.env.NODE_ENV==="production"?po.exports=Zg():po.exports=Hg();var Vg=po.exports;const Xg=E.getDefaultExportFromCjs(Vg),Gg={BASE_URL:"/pluto/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},wa=t=>{let e;const n=new Set,r=(u,h)=>{const d=typeof u=="function"?u(e):u;if(!Object.is(d,e)){const p=e;e=h??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(w=>w(e,p))}},s=()=>e,c={setState:r,getState:s,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Gg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=e=t(r,s,c);return c},Wg=t=>t?wa(t):wa,{useDebugValue:Kg}=x,{useSyncExternalStoreWithSelector:jg}=Xg,Jg=t=>t;function Il(t,e=Jg,n){const r=jg(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return Kg(r),r}const xa=(t,e)=>{const n=Wg(t),r=(s,o=e)=>Il(n,s,o);return Object.assign(r,n),r},Qg=(t,e)=>t?xa(t,e):xa;function pt(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[r,s]of t)if(!Object.is(s,e.get(r)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const r of t)if(!e.has(r))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||!Object.is(t[r],e[r]))return!1;return!0}var tm={value:()=>{}};function bs(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new _r(n)}function _r(t){this._=t}function em(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}_r.prototype=bs.prototype={constructor:_r,on:function(t,e){var n=this._,r=em(t+"",n),s,o=-1,i=r.length;if(arguments.length<2){for(;++o<i;)if((s=(t=r[o]).type)&&(s=nm(n[s],t.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<i;)if(s=(t=r[o]).type)n[s]=Sa(n[s],t.name,e);else if(e==null)for(s in n)n[s]=Sa(n[s],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new _r(t)},call:function(t,e){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,o;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,s=o.length;r<s;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],s=0,o=r.length;s<o;++s)r[s].value.apply(e,n)}};function nm(t,e){for(var n=0,r=t.length,s;n<r;++n)if((s=t[n]).name===e)return s.value}function Sa(t,e,n){for(var r=0,s=t.length;r<s;++r)if(t[r].name===e){t[r]=tm,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var go="http://www.w3.org/1999/xhtml";const va={svg:"http://www.w3.org/2000/svg",xhtml:go,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ts(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),va.hasOwnProperty(e)?{space:va[e],local:t}:t}function rm(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===go&&e.documentElement.namespaceURI===go?e.createElement(t):e.createElementNS(n,t)}}function sm(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ll(t){var e=Ts(t);return(e.local?sm:rm)(e)}function om(){}function ci(t){return t==null?om:function(){return this.querySelector(t)}}function im(t){typeof t!="function"&&(t=ci(t));for(var e=this._groups,n=e.length,r=new Array(n),s=0;s<n;++s)for(var o=e[s],i=o.length,a=r[s]=new Array(i),c,l,u=0;u<i;++u)(c=o[u])&&(l=t.call(c,c.__data__,u,o))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new xt(r,this._parents)}function am(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function cm(){return[]}function $l(t){return t==null?cm:function(){return this.querySelectorAll(t)}}function lm(t){return function(){return am(t.apply(this,arguments))}}function um(t){typeof t=="function"?t=lm(t):t=$l(t);for(var e=this._groups,n=e.length,r=[],s=[],o=0;o<n;++o)for(var i=e[o],a=i.length,c,l=0;l<a;++l)(c=i[l])&&(r.push(t.call(c,c.__data__,l,i)),s.push(c));return new xt(r,s)}function Yl(t){return function(){return this.matches(t)}}function Bl(t){return function(e){return e.matches(t)}}var hm=Array.prototype.find;function fm(t){return function(){return hm.call(this.children,t)}}function dm(){return this.firstElementChild}function pm(t){return this.select(t==null?dm:fm(typeof t=="function"?t:Bl(t)))}var gm=Array.prototype.filter;function mm(){return Array.from(this.children)}function ym(t){return function(){return gm.call(this.children,t)}}function wm(t){return this.selectAll(t==null?mm:ym(typeof t=="function"?t:Bl(t)))}function xm(t){typeof t!="function"&&(t=Yl(t));for(var e=this._groups,n=e.length,r=new Array(n),s=0;s<n;++s)for(var o=e[s],i=o.length,a=r[s]=[],c,l=0;l<i;++l)(c=o[l])&&t.call(c,c.__data__,l,o)&&a.push(c);return new xt(r,this._parents)}function ql(t){return new Array(t.length)}function Sm(){return new xt(this._enter||this._groups.map(ql),this._parents)}function ns(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}ns.prototype={constructor:ns,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function vm(t){return function(){return t}}function bm(t,e,n,r,s,o){for(var i=0,a,c=e.length,l=o.length;i<l;++i)(a=e[i])?(a.__data__=o[i],r[i]=a):n[i]=new ns(t,o[i]);for(;i<c;++i)(a=e[i])&&(s[i]=a)}function Tm(t,e,n,r,s,o,i){var a,c,l=new Map,u=e.length,h=o.length,d=new Array(u),p;for(a=0;a<u;++a)(c=e[a])&&(d[a]=p=i.call(c,c.__data__,a,e)+"",l.has(p)?s[a]=c:l.set(p,c));for(a=0;a<h;++a)p=i.call(t,o[a],a,o)+"",(c=l.get(p))?(r[a]=c,c.__data__=o[a],l.delete(p)):n[a]=new ns(t,o[a]);for(a=0;a<u;++a)(c=e[a])&&l.get(d[a])===c&&(s[a]=c)}function Em(t){return t.__data__}function _m(t,e){if(!arguments.length)return Array.from(this,Em);var n=e?Tm:bm,r=this._parents,s=this._groups;typeof t!="function"&&(t=vm(t));for(var o=s.length,i=new Array(o),a=new Array(o),c=new Array(o),l=0;l<o;++l){var u=r[l],h=s[l],d=h.length,p=Cm(t.call(u,u&&u.__data__,l,r)),w=p.length,y=a[l]=new Array(w),b=i[l]=new Array(w),S=c[l]=new Array(d);n(u,h,y,b,S,p,e);for(var k=0,_=0,v,M;k<w;++k)if(v=y[k]){for(k>=_&&(_=k+1);!(M=b[_])&&++_<w;);v._next=M||null}}return i=new xt(i,r),i._enter=a,i._exit=c,i}function Cm(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Pm(){return new xt(this._exit||this._groups.map(ql),this._parents)}function Rm(t,e,n){var r=this.enter(),s=this,o=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(s=e(s),s&&(s=s.selection())),n==null?o.remove():n(o),r&&s?r.merge(s).order():s}function km(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,s=n.length,o=r.length,i=Math.min(s,o),a=new Array(s),c=0;c<i;++c)for(var l=n[c],u=r[c],h=l.length,d=a[c]=new Array(h),p,w=0;w<h;++w)(p=l[w]||u[w])&&(d[w]=p);for(;c<s;++c)a[c]=n[c];return new xt(a,this._parents)}function Mm(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],s=r.length-1,o=r[s],i;--s>=0;)(i=r[s])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function Am(t){t||(t=Nm);function e(h,d){return h&&d?t(h.__data__,d.__data__):!h-!d}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var i=n[o],a=i.length,c=s[o]=new Array(a),l,u=0;u<a;++u)(l=i[u])&&(c[u]=l);c.sort(e)}return new xt(s,this._parents).order()}function Nm(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Dm(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Om(){return Array.from(this)}function zm(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],s=0,o=r.length;s<o;++s){var i=r[s];if(i)return i}return null}function Im(){let t=0;for(const e of this)++t;return t}function Lm(){return!this.node()}function $m(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var s=e[n],o=0,i=s.length,a;o<i;++o)(a=s[o])&&t.call(a,a.__data__,o,s);return this}function Ym(t){return function(){this.removeAttribute(t)}}function Bm(t){return function(){this.removeAttributeNS(t.space,t.local)}}function qm(t,e){return function(){this.setAttribute(t,e)}}function Fm(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Um(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function Zm(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Hm(t,e){var n=Ts(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?Bm:Ym:typeof e=="function"?n.local?Zm:Um:n.local?Fm:qm)(n,e))}function Fl(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Vm(t){return function(){this.style.removeProperty(t)}}function Xm(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Gm(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function Wm(t,e,n){return arguments.length>1?this.each((e==null?Vm:typeof e=="function"?Gm:Xm)(t,e,n??"")):nn(this.node(),t)}function nn(t,e){return t.style.getPropertyValue(e)||Fl(t).getComputedStyle(t,null).getPropertyValue(e)}function Km(t){return function(){delete this[t]}}function jm(t,e){return function(){this[t]=e}}function Jm(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Qm(t,e){return arguments.length>1?this.each((e==null?Km:typeof e=="function"?Jm:jm)(t,e)):this.node()[t]}function Ul(t){return t.trim().split(/^|\s+/)}function li(t){return t.classList||new Zl(t)}function Zl(t){this._node=t,this._names=Ul(t.getAttribute("class")||"")}Zl.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Hl(t,e){for(var n=li(t),r=-1,s=e.length;++r<s;)n.add(e[r])}function Vl(t,e){for(var n=li(t),r=-1,s=e.length;++r<s;)n.remove(e[r])}function ty(t){return function(){Hl(this,t)}}function ey(t){return function(){Vl(this,t)}}function ny(t,e){return function(){(e.apply(this,arguments)?Hl:Vl)(this,t)}}function ry(t,e){var n=Ul(t+"");if(arguments.length<2){for(var r=li(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof e=="function"?ny:e?ty:ey)(n,e))}function sy(){this.textContent=""}function oy(t){return function(){this.textContent=t}}function iy(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function ay(t){return arguments.length?this.each(t==null?sy:(typeof t=="function"?iy:oy)(t)):this.node().textContent}function cy(){this.innerHTML=""}function ly(t){return function(){this.innerHTML=t}}function uy(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function hy(t){return arguments.length?this.each(t==null?cy:(typeof t=="function"?uy:ly)(t)):this.node().innerHTML}function fy(){this.nextSibling&&this.parentNode.appendChild(this)}function dy(){return this.each(fy)}function py(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function gy(){return this.each(py)}function my(t){var e=typeof t=="function"?t:Ll(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function yy(){return null}function wy(t,e){var n=typeof t=="function"?t:Ll(t),r=e==null?yy:typeof e=="function"?e:ci(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function xy(){var t=this.parentNode;t&&t.removeChild(this)}function Sy(){return this.each(xy)}function vy(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function by(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ty(t){return this.select(t?by:vy)}function Ey(t){return arguments.length?this.property("__data__",t):this.node().__data__}function _y(t){return function(e){t.call(this,e,this.__data__)}}function Cy(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function Py(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,s=e.length,o;n<s;++n)o=e[n],(!t.type||o.type===t.type)&&o.name===t.name?this.removeEventListener(o.type,o.listener,o.options):e[++r]=o;++r?e.length=r:delete this.__on}}}function Ry(t,e,n){return function(){var r=this.__on,s,o=_y(e);if(r){for(var i=0,a=r.length;i<a;++i)if((s=r[i]).type===t.type&&s.name===t.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=o,s.options=n),s.value=e;return}}this.addEventListener(t.type,o,n),s={type:t.type,name:t.name,value:e,listener:o,options:n},r?r.push(s):this.__on=[s]}}function ky(t,e,n){var r=Cy(t+""),s,o=r.length,i;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(s=0,u=a[c];s<o;++s)if((i=r[s]).type===u.type&&i.name===u.name)return u.value}return}for(a=e?Ry:Py,s=0;s<o;++s)this.each(a(r[s],e,n));return this}function Xl(t,e,n){var r=Fl(t),s=r.CustomEvent;typeof s=="function"?s=new s(e,n):(s=r.document.createEvent("Event"),n?(s.initEvent(e,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(e,!1,!1)),t.dispatchEvent(s)}function My(t,e){return function(){return Xl(this,t,e)}}function Ay(t,e){return function(){return Xl(this,t,e.apply(this,arguments))}}function Ny(t,e){return this.each((typeof e=="function"?Ay:My)(t,e))}function*Dy(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],s=0,o=r.length,i;s<o;++s)(i=r[s])&&(yield i)}var Gl=[null];function xt(t,e){this._groups=t,this._parents=e}function lr(){return new xt([[document.documentElement]],Gl)}function Oy(){return this}xt.prototype=lr.prototype={constructor:xt,select:im,selectAll:um,selectChild:pm,selectChildren:wm,filter:xm,data:_m,enter:Sm,exit:Pm,join:Rm,merge:km,selection:Oy,order:Mm,sort:Am,call:Dm,nodes:Om,node:zm,size:Im,empty:Lm,each:$m,attr:Hm,style:Wm,property:Qm,classed:ry,text:ay,html:hy,raise:dy,lower:gy,append:my,insert:wy,remove:Sy,clone:Ty,datum:Ey,on:ky,dispatch:Ny,[Symbol.iterator]:Dy};function kt(t){return typeof t=="string"?new xt([[document.querySelector(t)]],[document.documentElement]):new xt([[t]],Gl)}function zy(t){let e;for(;e=t.sourceEvent;)t=e;return t}function Ot(t,e){if(t=zy(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[t.clientX-s.left-e.clientLeft,t.clientY-s.top-e.clientTop]}}return[t.pageX,t.pageY]}const Iy={passive:!1},Gn={capture:!0,passive:!1};function Xs(t){t.stopImmediatePropagation()}function qe(t){t.preventDefault(),t.stopImmediatePropagation()}function Wl(t){var e=t.document.documentElement,n=kt(t).on("dragstart.drag",qe,Gn);"onselectstart"in e?n.on("selectstart.drag",qe,Gn):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Kl(t,e){var n=t.document.documentElement,r=kt(t).on("dragstart.drag",null);e&&(r.on("click.drag",qe,Gn),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const gr=t=>()=>t;function mo(t,{sourceEvent:e,subject:n,target:r,identifier:s,active:o,x:i,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}mo.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Ly(t){return!t.ctrlKey&&!t.button}function $y(){return this.parentNode}function Yy(t,e){return e??{x:t.x,y:t.y}}function By(){return navigator.maxTouchPoints||"ontouchstart"in this}function qy(){var t=Ly,e=$y,n=Yy,r=By,s={},o=bs("start","drag","end"),i=0,a,c,l,u,h=0;function d(v){v.on("mousedown.drag",p).filter(r).on("touchstart.drag",b).on("touchmove.drag",S,Iy).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(v,M){if(!(u||!t.call(this,v,M))){var C=_(this,e.call(this,v,M),v,M,"mouse");C&&(kt(v.view).on("mousemove.drag",w,Gn).on("mouseup.drag",y,Gn),Wl(v.view),Xs(v),l=!1,a=v.clientX,c=v.clientY,C("start",v))}}function w(v){if(qe(v),!l){var M=v.clientX-a,C=v.clientY-c;l=M*M+C*C>h}s.mouse("drag",v)}function y(v){kt(v.view).on("mousemove.drag mouseup.drag",null),Kl(v.view,l),qe(v),s.mouse("end",v)}function b(v,M){if(t.call(this,v,M)){var C=v.changedTouches,D=e.call(this,v,M),$=C.length,O,U;for(O=0;O<$;++O)(U=_(this,D,v,M,C[O].identifier,C[O]))&&(Xs(v),U("start",v,C[O]))}}function S(v){var M=v.changedTouches,C=M.length,D,$;for(D=0;D<C;++D)($=s[M[D].identifier])&&(qe(v),$("drag",v,M[D]))}function k(v){var M=v.changedTouches,C=M.length,D,$;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),D=0;D<C;++D)($=s[M[D].identifier])&&(Xs(v),$("end",v,M[D]))}function _(v,M,C,D,$,O){var U=o.copy(),N=Ot(O||C,M),Z,Y,g;if((g=n.call(v,new mo("beforestart",{sourceEvent:C,target:d,identifier:$,active:i,x:N[0],y:N[1],dx:0,dy:0,dispatch:U}),D))!=null)return Z=g.x-N[0]||0,Y=g.y-N[1]||0,function A(R,z,B){var P=N,I;switch(R){case"start":s[$]=A,I=i++;break;case"end":delete s[$],--i;case"drag":N=Ot(B||z,M),I=i;break}U.call(R,v,new mo(R,{sourceEvent:z,subject:g,target:d,identifier:$,active:I,x:N[0]+Z,y:N[1]+Y,dx:N[0]-P[0],dy:N[1]-P[1],dispatch:U}),D)}}return d.filter=function(v){return arguments.length?(t=typeof v=="function"?v:gr(!!v),d):t},d.container=function(v){return arguments.length?(e=typeof v=="function"?v:gr(v),d):e},d.subject=function(v){return arguments.length?(n=typeof v=="function"?v:gr(v),d):n},d.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:gr(!!v),d):r},d.on=function(){var v=o.on.apply(o,arguments);return v===o?d:v},d.clickDistance=function(v){return arguments.length?(h=(v=+v)*v,d):Math.sqrt(h)},d}var rn=0,Tn=0,wn=0,jl=1e3,rs,En,ss=0,xe=0,Es=0,Wn=typeof performance=="object"&&performance.now?performance:Date,Jl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ui(){return xe||(Jl(Fy),xe=Wn.now()+Es)}function Fy(){xe=0}function os(){this._call=this._time=this._next=null}os.prototype=Ql.prototype={constructor:os,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?ui():+n)+(e==null?0:+e),!this._next&&En!==this&&(En?En._next=this:rs=this,En=this),this._call=t,this._time=n,yo()},stop:function(){this._call&&(this._call=null,this._time=1/0,yo())}};function Ql(t,e,n){var r=new os;return r.restart(t,e,n),r}function Uy(){ui(),++rn;for(var t=rs,e;t;)(e=xe-t._time)>=0&&t._call.call(void 0,e),t=t._next;--rn}function ba(){xe=(ss=Wn.now())+Es,rn=Tn=0;try{Uy()}finally{rn=0,Hy(),xe=0}}function Zy(){var t=Wn.now(),e=t-ss;e>jl&&(Es-=e,ss=t)}function Hy(){for(var t,e=rs,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:rs=n);En=t,yo(r)}function yo(t){if(!rn){Tn&&(Tn=clearTimeout(Tn));var e=t-xe;e>24?(t<1/0&&(Tn=setTimeout(ba,t-Wn.now()-Es)),wn&&(wn=clearInterval(wn))):(wn||(ss=Wn.now(),wn=setInterval(Zy,jl)),rn=1,Jl(ba))}}function Ta(t,e,n){var r=new os;return e=e==null?0:+e,r.restart(s=>{r.stop(),t(s+e)},e,n),r}var Vy=bs("start","end","cancel","interrupt"),Xy=[],tu=0,Ea=1,wo=2,Cr=3,_a=4,xo=5,Pr=6;function _s(t,e,n,r,s,o){var i=t.__transition;if(!i)t.__transition={};else if(n in i)return;Gy(t,n,{name:e,index:r,group:s,on:Vy,tween:Xy,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:tu})}function hi(t,e){var n=At(t,e);if(n.state>tu)throw new Error("too late; already scheduled");return n}function Yt(t,e){var n=At(t,e);if(n.state>Cr)throw new Error("too late; already running");return n}function At(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Gy(t,e,n){var r=t.__transition,s;r[e]=n,n.timer=Ql(o,0,n.time);function o(l){n.state=Ea,n.timer.restart(i,n.delay,n.time),n.delay<=l&&i(l-n.delay)}function i(l){var u,h,d,p;if(n.state!==Ea)return c();for(u in r)if(p=r[u],p.name===n.name){if(p.state===Cr)return Ta(i);p.state===_a?(p.state=Pr,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete r[u]):+u<e&&(p.state=Pr,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete r[u])}if(Ta(function(){n.state===Cr&&(n.state=_a,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=wo,n.on.call("start",t,t.__data__,n.index,n.group),n.state===wo){for(n.state=Cr,s=new Array(d=n.tween.length),u=0,h=-1;u<d;++u)(p=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(s[++h]=p);s.length=h+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=xo,1),h=-1,d=s.length;++h<d;)s[h].call(t,u);n.state===xo&&(n.on.call("end",t,t.__data__,n.index,n.group),c())}function c(){n.state=Pr,n.timer.stop(),delete r[e];for(var l in r)return;delete t.__transition}}function Rr(t,e){var n=t.__transition,r,s,o=!0,i;if(n){e=e==null?null:e+"";for(i in n){if((r=n[i]).name!==e){o=!1;continue}s=r.state>wo&&r.state<xo,r.state=Pr,r.timer.stop(),r.on.call(s?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[i]}o&&delete t.__transition}}function Wy(t){return this.each(function(){Rr(this,t)})}function Ky(t,e){var n,r;return function(){var s=Yt(this,t),o=s.tween;if(o!==n){r=n=o;for(var i=0,a=r.length;i<a;++i)if(r[i].name===e){r=r.slice(),r.splice(i,1);break}}s.tween=r}}function jy(t,e,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Yt(this,t),i=o.tween;if(i!==r){s=(r=i).slice();for(var a={name:e,value:n},c=0,l=s.length;c<l;++c)if(s[c].name===e){s[c]=a;break}c===l&&s.push(a)}o.tween=s}}function Jy(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=At(this.node(),n).tween,s=0,o=r.length,i;s<o;++s)if((i=r[s]).name===t)return i.value;return null}return this.each((e==null?Ky:jy)(n,t,e))}function fi(t,e,n){var r=t._id;return t.each(function(){var s=Yt(this,r);(s.value||(s.value={}))[e]=n.apply(this,arguments)}),function(s){return At(s,r).value[e]}}function eu(t,e){var n;return(typeof e=="number"?Pt:e instanceof ye?Fr:(n=ye(e))?(e=n,Fr):Kc)(t,e)}function Qy(t){return function(){this.removeAttribute(t)}}function t0(t){return function(){this.removeAttributeNS(t.space,t.local)}}function e0(t,e,n){var r,s=n+"",o;return function(){var i=this.getAttribute(t);return i===s?null:i===r?o:o=e(r=i,n)}}function n0(t,e,n){var r,s=n+"",o;return function(){var i=this.getAttributeNS(t.space,t.local);return i===s?null:i===r?o:o=e(r=i,n)}}function r0(t,e,n){var r,s,o;return function(){var i,a=n(this),c;return a==null?void this.removeAttribute(t):(i=this.getAttribute(t),c=a+"",i===c?null:i===r&&c===s?o:(s=c,o=e(r=i,a)))}}function s0(t,e,n){var r,s,o;return function(){var i,a=n(this),c;return a==null?void this.removeAttributeNS(t.space,t.local):(i=this.getAttributeNS(t.space,t.local),c=a+"",i===c?null:i===r&&c===s?o:(s=c,o=e(r=i,a)))}}function o0(t,e){var n=Ts(t),r=n==="transform"?gd:eu;return this.attrTween(t,typeof e=="function"?(n.local?s0:r0)(n,r,fi(this,"attr."+t,e)):e==null?(n.local?t0:Qy)(n):(n.local?n0:e0)(n,r,e))}function i0(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function a0(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function c0(t,e){var n,r;function s(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&a0(t,o)),n}return s._value=e,s}function l0(t,e){var n,r;function s(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&i0(t,o)),n}return s._value=e,s}function u0(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=Ts(t);return this.tween(n,(r.local?c0:l0)(r,e))}function h0(t,e){return function(){hi(this,t).delay=+e.apply(this,arguments)}}function f0(t,e){return e=+e,function(){hi(this,t).delay=e}}function d0(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?h0:f0)(e,t)):At(this.node(),e).delay}function p0(t,e){return function(){Yt(this,t).duration=+e.apply(this,arguments)}}function g0(t,e){return e=+e,function(){Yt(this,t).duration=e}}function m0(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?p0:g0)(e,t)):At(this.node(),e).duration}function y0(t,e){if(typeof e!="function")throw new Error;return function(){Yt(this,t).ease=e}}function w0(t){var e=this._id;return arguments.length?this.each(y0(e,t)):At(this.node(),e).ease}function x0(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;Yt(this,t).ease=n}}function S0(t){if(typeof t!="function")throw new Error;return this.each(x0(this._id,t))}function v0(t){typeof t!="function"&&(t=Yl(t));for(var e=this._groups,n=e.length,r=new Array(n),s=0;s<n;++s)for(var o=e[s],i=o.length,a=r[s]=[],c,l=0;l<i;++l)(c=o[l])&&t.call(c,c.__data__,l,o)&&a.push(c);return new Wt(r,this._parents,this._name,this._id)}function b0(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,s=n.length,o=Math.min(r,s),i=new Array(r),a=0;a<o;++a)for(var c=e[a],l=n[a],u=c.length,h=i[a]=new Array(u),d,p=0;p<u;++p)(d=c[p]||l[p])&&(h[p]=d);for(;a<r;++a)i[a]=e[a];return new Wt(i,this._parents,this._name,this._id)}function T0(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function E0(t,e,n){var r,s,o=T0(e)?hi:Yt;return function(){var i=o(this,t),a=i.on;a!==r&&(s=(r=a).copy()).on(e,n),i.on=s}}function _0(t,e){var n=this._id;return arguments.length<2?At(this.node(),n).on.on(t):this.each(E0(n,t,e))}function C0(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function P0(){return this.on("end.remove",C0(this._id))}function R0(t){var e=this._name,n=this._id;typeof t!="function"&&(t=ci(t));for(var r=this._groups,s=r.length,o=new Array(s),i=0;i<s;++i)for(var a=r[i],c=a.length,l=o[i]=new Array(c),u,h,d=0;d<c;++d)(u=a[d])&&(h=t.call(u,u.__data__,d,a))&&("__data__"in u&&(h.__data__=u.__data__),l[d]=h,_s(l[d],e,n,d,l,At(u,n)));return new Wt(o,this._parents,e,n)}function k0(t){var e=this._name,n=this._id;typeof t!="function"&&(t=$l(t));for(var r=this._groups,s=r.length,o=[],i=[],a=0;a<s;++a)for(var c=r[a],l=c.length,u,h=0;h<l;++h)if(u=c[h]){for(var d=t.call(u,u.__data__,h,c),p,w=At(u,n),y=0,b=d.length;y<b;++y)(p=d[y])&&_s(p,e,n,y,d,w);o.push(d),i.push(u)}return new Wt(o,i,e,n)}var M0=lr.prototype.constructor;function A0(){return new M0(this._groups,this._parents)}function N0(t,e){var n,r,s;return function(){var o=nn(this,t),i=(this.style.removeProperty(t),nn(this,t));return o===i?null:o===n&&i===r?s:s=e(n=o,r=i)}}function nu(t){return function(){this.style.removeProperty(t)}}function D0(t,e,n){var r,s=n+"",o;return function(){var i=nn(this,t);return i===s?null:i===r?o:o=e(r=i,n)}}function O0(t,e,n){var r,s,o;return function(){var i=nn(this,t),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(t),nn(this,t))),i===c?null:i===r&&c===s?o:(s=c,o=e(r=i,a))}}function z0(t,e){var n,r,s,o="style."+e,i="end."+o,a;return function(){var c=Yt(this,t),l=c.on,u=c.value[o]==null?a||(a=nu(e)):void 0;(l!==n||s!==u)&&(r=(n=l).copy()).on(i,s=u),c.on=r}}function I0(t,e,n){var r=(t+="")=="transform"?pd:eu;return e==null?this.styleTween(t,N0(t,r)).on("end.style."+t,nu(t)):typeof e=="function"?this.styleTween(t,O0(t,r,fi(this,"style."+t,e))).each(z0(this._id,t)):this.styleTween(t,D0(t,r,e),n).on("end.style."+t,null)}function L0(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function $0(t,e,n){var r,s;function o(){var i=e.apply(this,arguments);return i!==s&&(r=(s=i)&&L0(t,i,n)),r}return o._value=e,o}function Y0(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,$0(t,e,n??""))}function B0(t){return function(){this.textContent=t}}function q0(t){return function(){var e=t(this);this.textContent=e??""}}function F0(t){return this.tween("text",typeof t=="function"?q0(fi(this,"text",t)):B0(t==null?"":t+""))}function U0(t){return function(e){this.textContent=t.call(this,e)}}function Z0(t){var e,n;function r(){var s=t.apply(this,arguments);return s!==n&&(e=(n=s)&&U0(s)),e}return r._value=t,r}function H0(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,Z0(t))}function V0(){for(var t=this._name,e=this._id,n=ru(),r=this._groups,s=r.length,o=0;o<s;++o)for(var i=r[o],a=i.length,c,l=0;l<a;++l)if(c=i[l]){var u=At(c,e);_s(c,t,n,l,i,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Wt(r,this._parents,t,n)}function X0(){var t,e,n=this,r=n._id,s=n.size();return new Promise(function(o,i){var a={value:i},c={value:function(){--s===0&&o()}};n.each(function(){var l=Yt(this,r),u=l.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(c)),l.on=e}),s===0&&o()})}var G0=0;function Wt(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function ru(){return++G0}var Ft=lr.prototype;Wt.prototype={constructor:Wt,select:R0,selectAll:k0,selectChild:Ft.selectChild,selectChildren:Ft.selectChildren,filter:v0,merge:b0,selection:A0,transition:V0,call:Ft.call,nodes:Ft.nodes,node:Ft.node,size:Ft.size,empty:Ft.empty,each:Ft.each,on:_0,attr:o0,attrTween:u0,style:I0,styleTween:Y0,text:F0,textTween:H0,remove:P0,tween:Jy,delay:d0,duration:m0,ease:w0,easeVarying:S0,end:X0,[Symbol.iterator]:Ft[Symbol.iterator]};function W0(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var K0={time:null,delay:0,duration:250,ease:W0};function j0(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function J0(t){var e,n;t instanceof Wt?(e=t._id,t=t._name):(e=ru(),(n=K0).time=ui(),t=t==null?null:t+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var i=r[o],a=i.length,c,l=0;l<a;++l)(c=i[l])&&_s(c,t,e,l,i,n||j0(c,e));return new Wt(r,this._parents,t,e)}lr.prototype.interrupt=Wy;lr.prototype.transition=J0;const mr=t=>()=>t;function Q0(t,{sourceEvent:e,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Ht(t,e,n){this.k=t,this.x=e,this.y=n}Ht.prototype={constructor:Ht,scale:function(t){return t===1?this:new Ht(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Ht(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ee=new Ht(1,0,0);Ht.prototype;function Gs(t){t.stopImmediatePropagation()}function xn(t){t.preventDefault(),t.stopImmediatePropagation()}function tw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function ew(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function Ca(){return this.__zoom||ee}function nw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function rw(){return navigator.maxTouchPoints||"ontouchstart"in this}function sw(t,e,n){var r=t.invertX(e[0][0])-n[0][0],s=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],i=t.invertY(e[1][1])-n[1][1];return t.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function ow(){var t=tw,e=ew,n=sw,r=nw,s=rw,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,c=xd,l=bs("start","zoom","end"),u,h,d,p=500,w=150,y=0,b=10;function S(g){g.property("__zoom",Ca).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",U).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",Y).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(g,A,R,z){var B=g.selection?g.selection():g;B.property("__zoom",Ca),g!==B?M(g,A,R,z):B.interrupt().each(function(){C(this,arguments).event(z).start().zoom(null,typeof A=="function"?A.apply(this,arguments):A).end()})},S.scaleBy=function(g,A,R,z){S.scaleTo(g,function(){var B=this.__zoom.k,P=typeof A=="function"?A.apply(this,arguments):A;return B*P},R,z)},S.scaleTo=function(g,A,R,z){S.transform(g,function(){var B=e.apply(this,arguments),P=this.__zoom,I=R==null?v(B):typeof R=="function"?R.apply(this,arguments):R,q=P.invert(I),F=typeof A=="function"?A.apply(this,arguments):A;return n(_(k(P,F),I,q),B,i)},R,z)},S.translateBy=function(g,A,R,z){S.transform(g,function(){return n(this.__zoom.translate(typeof A=="function"?A.apply(this,arguments):A,typeof R=="function"?R.apply(this,arguments):R),e.apply(this,arguments),i)},null,z)},S.translateTo=function(g,A,R,z,B){S.transform(g,function(){var P=e.apply(this,arguments),I=this.__zoom,q=z==null?v(P):typeof z=="function"?z.apply(this,arguments):z;return n(ee.translate(q[0],q[1]).scale(I.k).translate(typeof A=="function"?-A.apply(this,arguments):-A,typeof R=="function"?-R.apply(this,arguments):-R),P,i)},z,B)};function k(g,A){return A=Math.max(o[0],Math.min(o[1],A)),A===g.k?g:new Ht(A,g.x,g.y)}function _(g,A,R){var z=A[0]-R[0]*g.k,B=A[1]-R[1]*g.k;return z===g.x&&B===g.y?g:new Ht(g.k,z,B)}function v(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function M(g,A,R,z){g.on("start.zoom",function(){C(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(z).end()}).tween("zoom",function(){var B=this,P=arguments,I=C(B,P).event(z),q=e.apply(B,P),F=R==null?v(q):typeof R=="function"?R.apply(B,P):R,X=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),V=B.__zoom,K=typeof A=="function"?A.apply(B,P):A,tt=c(V.invert(F).concat(X/V.k),K.invert(F).concat(X/K.k));return function(et){if(et===1)et=K;else{var ot=tt(et),H=X/ot[2];et=new Ht(H,F[0]-ot[0]*H,F[1]-ot[1]*H)}I.zoom(null,et)}})}function C(g,A,R){return!R&&g.__zooming||new D(g,A)}function D(g,A){this.that=g,this.args=A,this.active=0,this.sourceEvent=null,this.extent=e.apply(g,A),this.taps=0}D.prototype={event:function(g){return g&&(this.sourceEvent=g),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(g,A){return this.mouse&&g!=="mouse"&&(this.mouse[1]=A.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=A.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=A.invert(this.touch1[0])),this.that.__zoom=A,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var A=kt(this.that).datum();l.call(g,this.that,new Q0(g,{sourceEvent:this.sourceEvent,target:S,type:g,transform:this.that.__zoom,dispatch:l}),A)}};function $(g,...A){if(!t.apply(this,arguments))return;var R=C(this,A).event(g),z=this.__zoom,B=Math.max(o[0],Math.min(o[1],z.k*Math.pow(2,r.apply(this,arguments)))),P=Ot(g);if(R.wheel)(R.mouse[0][0]!==P[0]||R.mouse[0][1]!==P[1])&&(R.mouse[1]=z.invert(R.mouse[0]=P)),clearTimeout(R.wheel);else{if(z.k===B)return;R.mouse=[P,z.invert(P)],Rr(this),R.start()}xn(g),R.wheel=setTimeout(I,w),R.zoom("mouse",n(_(k(z,B),R.mouse[0],R.mouse[1]),R.extent,i));function I(){R.wheel=null,R.end()}}function O(g,...A){if(d||!t.apply(this,arguments))return;var R=g.currentTarget,z=C(this,A,!0).event(g),B=kt(g.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",X,!0),P=Ot(g,R),I=g.clientX,q=g.clientY;Wl(g.view),Gs(g),z.mouse=[P,this.__zoom.invert(P)],Rr(this),z.start();function F(V){if(xn(V),!z.moved){var K=V.clientX-I,tt=V.clientY-q;z.moved=K*K+tt*tt>y}z.event(V).zoom("mouse",n(_(z.that.__zoom,z.mouse[0]=Ot(V,R),z.mouse[1]),z.extent,i))}function X(V){B.on("mousemove.zoom mouseup.zoom",null),Kl(V.view,z.moved),xn(V),z.event(V).end()}}function U(g,...A){if(t.apply(this,arguments)){var R=this.__zoom,z=Ot(g.changedTouches?g.changedTouches[0]:g,this),B=R.invert(z),P=R.k*(g.shiftKey?.5:2),I=n(_(k(R,P),z,B),e.apply(this,A),i);xn(g),a>0?kt(this).transition().duration(a).call(M,I,z,g):kt(this).call(S.transform,I,z,g)}}function N(g,...A){if(t.apply(this,arguments)){var R=g.touches,z=R.length,B=C(this,A,g.changedTouches.length===z).event(g),P,I,q,F;for(Gs(g),I=0;I<z;++I)q=R[I],F=Ot(q,this),F=[F,this.__zoom.invert(F),q.identifier],B.touch0?!B.touch1&&B.touch0[2]!==F[2]&&(B.touch1=F,B.taps=0):(B.touch0=F,P=!0,B.taps=1+!!u);u&&(u=clearTimeout(u)),P&&(B.taps<2&&(h=F[0],u=setTimeout(function(){u=null},p)),Rr(this),B.start())}}function Z(g,...A){if(this.__zooming){var R=C(this,A).event(g),z=g.changedTouches,B=z.length,P,I,q,F;for(xn(g),P=0;P<B;++P)I=z[P],q=Ot(I,this),R.touch0&&R.touch0[2]===I.identifier?R.touch0[0]=q:R.touch1&&R.touch1[2]===I.identifier&&(R.touch1[0]=q);if(I=R.that.__zoom,R.touch1){var X=R.touch0[0],V=R.touch0[1],K=R.touch1[0],tt=R.touch1[1],et=(et=K[0]-X[0])*et+(et=K[1]-X[1])*et,ot=(ot=tt[0]-V[0])*ot+(ot=tt[1]-V[1])*ot;I=k(I,Math.sqrt(et/ot)),q=[(X[0]+K[0])/2,(X[1]+K[1])/2],F=[(V[0]+tt[0])/2,(V[1]+tt[1])/2]}else if(R.touch0)q=R.touch0[0],F=R.touch0[1];else return;R.zoom("touch",n(_(I,q,F),R.extent,i))}}function Y(g,...A){if(this.__zooming){var R=C(this,A).event(g),z=g.changedTouches,B=z.length,P,I;for(Gs(g),d&&clearTimeout(d),d=setTimeout(function(){d=null},p),P=0;P<B;++P)I=z[P],R.touch0&&R.touch0[2]===I.identifier?delete R.touch0:R.touch1&&R.touch1[2]===I.identifier&&delete R.touch1;if(R.touch1&&!R.touch0&&(R.touch0=R.touch1,delete R.touch1),R.touch0)R.touch0[1]=this.__zoom.invert(R.touch0[0]);else if(R.end(),R.taps===2&&(I=Ot(I,this),Math.hypot(h[0]-I[0],h[1]-I[1])<b)){var q=kt(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return S.wheelDelta=function(g){return arguments.length?(r=typeof g=="function"?g:mr(+g),S):r},S.filter=function(g){return arguments.length?(t=typeof g=="function"?g:mr(!!g),S):t},S.touchable=function(g){return arguments.length?(s=typeof g=="function"?g:mr(!!g),S):s},S.extent=function(g){return arguments.length?(e=typeof g=="function"?g:mr([[+g[0][0],+g[0][1]],[+g[1][0],+g[1][1]]]),S):e},S.scaleExtent=function(g){return arguments.length?(o[0]=+g[0],o[1]=+g[1],S):[o[0],o[1]]},S.translateExtent=function(g){return arguments.length?(i[0][0]=+g[0][0],i[1][0]=+g[1][0],i[0][1]=+g[0][1],i[1][1]=+g[1][1],S):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},S.constrain=function(g){return arguments.length?(n=g,S):n},S.duration=function(g){return arguments.length?(a=+g,S):a},S.interpolate=function(g){return arguments.length?(c=g,S):c},S.on=function(){var g=l.on.apply(l,arguments);return g===l?S:g},S.clickDistance=function(g){return arguments.length?(y=(g=+g)*g,S):Math.sqrt(y)},S.tapDistance=function(g){return arguments.length?(b=+g,S):b},S}const Cs=x.createContext(null),iw=Cs.Provider,St={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,e)=>`Couldn't create edge for ${t?"target":"source"} handle id: "${t?e.targetHandle:e.sourceHandle}", edge id: ${e.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},su=St.error001();function lt(t,e){const n=x.useContext(Cs);if(n===null)throw new Error(su);return Il(n,t,e)}const ht=()=>{const t=x.useContext(Cs);if(t===null)throw new Error(su);return x.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy}),[t])},aw=t=>t.userSelectionActive?"none":"all";function cw({position:t,children:e,className:n,style:r,...s}){const o=lt(aw),i=`${t}`.split("-");return x.createElement("div",{className:vt(["react-flow__panel",n,...i]),style:{...r,pointerEvents:o},...s},e)}function lw({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:x.createElement(cw,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},x.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const uw=({x:t,y:e,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...u})=>{const h=x.useRef(null),[d,p]=x.useState({x:0,y:0,width:0,height:0}),w=vt(["react-flow__edge-textwrapper",l]);return x.useEffect(()=>{if(h.current){const y=h.current.getBBox();p({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),typeof n>"u"||!n?null:x.createElement("g",{transform:`translate(${t-d.width/2} ${e-d.height/2})`,className:w,visibility:d.width?"visible":"hidden",...u},s&&x.createElement("rect",{width:d.width+2*i[0],x:-i[0],y:-i[1],height:d.height+2*i[1],className:"react-flow__edge-textbg",style:o,rx:a,ry:a}),x.createElement("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:h,style:r},n),c)};var hw=x.memo(uw);const di=t=>({width:t.offsetWidth,height:t.offsetHeight}),sn=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),pi=(t={x:0,y:0},e)=>({x:sn(t.x,e[0][0],e[1][0]),y:sn(t.y,e[0][1],e[1][1])}),Pa=(t,e,n)=>t<e?sn(Math.abs(t-e),1,50)/50:t>n?-sn(Math.abs(t-n),1,50)/50:0,ou=(t,e)=>{const n=Pa(t.x,35,e.width-35)*20,r=Pa(t.y,35,e.height-35)*20;return[n,r]},iu=t=>{var e;return((e=t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},fw=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),gi=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),dw=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),Ra=t=>({...t.positionAbsolute||{x:0,y:0},width:t.width||0,height:t.height||0}),So=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*r)},pw=t=>Et(t.width)&&Et(t.height)&&Et(t.x)&&Et(t.y),Et=t=>!isNaN(t)&&isFinite(t),ct=Symbol.for("internals"),au=["Enter"," ","Escape"],is=(t,e)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${e} Help: https://reactflow.dev/error#${t}`)},gw=t=>"nativeEvent"in t;function vo(t){var s,o;const e=gw(t)?t.nativeEvent:t,n=((o=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:o[0])||t.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const cu=t=>"clientX"in t,ne=(t,e)=>{var o,i;const n=cu(t),r=n?t.clientX:(o=t.touches)==null?void 0:o[0].clientX,s=n?t.clientY:(i=t.touches)==null?void 0:i[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:s-((e==null?void 0:e.top)??0)}},as=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0},un=({id:t,path:e,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:d,interactionWidth:p=20})=>x.createElement(x.Fragment,null,x.createElement("path",{id:t,style:u,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:d}),p&&x.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:p,className:"react-flow__edge-interaction"}),s&&Et(n)&&Et(r)?x.createElement(hw,{x:n,y:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l}):null);un.displayName="BaseEdge";function Sn(t,e,n){return n===void 0?n:r=>{const s=e().edges.find(o=>o.id===t);s&&n(r,{...s})}}function lu({sourceX:t,sourceY:e,targetX:n,targetY:r}){const s=Math.abs(n-t)/2,o=n<t?n+s:n-s,i=Math.abs(r-e)/2,a=r<e?r+i:r-i;return[o,a,s,i]}function uu({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:i,targetControlY:a}){const c=t*.125+s*.375+i*.375+n*.125,l=e*.125+o*.375+a*.375+r*.125,u=Math.abs(c-t),h=Math.abs(l-e);return[c,l,u,h]}exports.ConnectionMode=void 0;(function(t){t.Strict="strict",t.Loose="loose"})(exports.ConnectionMode||(exports.ConnectionMode={}));var pe;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(pe||(pe={}));exports.SelectionMode=void 0;(function(t){t.Partial="partial",t.Full="full"})(exports.SelectionMode||(exports.SelectionMode={}));var Jt;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Jt||(Jt={}));var cs;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(cs||(cs={}));exports.Position=void 0;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(exports.Position||(exports.Position={}));function ka({pos:t,x1:e,y1:n,x2:r,y2:s}){return t===exports.Position.Left||t===exports.Position.Right?[.5*(e+r),n]:[e,.5*(n+s)]}function hu({sourceX:t,sourceY:e,sourcePosition:n=exports.Position.Bottom,targetX:r,targetY:s,targetPosition:o=exports.Position.Top}){const[i,a]=ka({pos:n,x1:t,y1:e,x2:r,y2:s}),[c,l]=ka({pos:o,x1:r,y1:s,x2:t,y2:e}),[u,h,d,p]=uu({sourceX:t,sourceY:e,targetX:r,targetY:s,sourceControlX:i,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${t},${e} C${i},${a} ${c},${l} ${r},${s}`,u,h,d,p]}const mi=x.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,sourcePosition:s=exports.Position.Bottom,targetPosition:o=exports.Position.Top,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:w,interactionWidth:y})=>{const[b,S,k]=hu({sourceX:t,sourceY:e,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return x.createElement(un,{path:b,labelX:S,labelY:k,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:w,interactionWidth:y})});mi.displayName="SimpleBezierEdge";const Ma={[exports.Position.Left]:{x:-1,y:0},[exports.Position.Right]:{x:1,y:0},[exports.Position.Top]:{x:0,y:-1},[exports.Position.Bottom]:{x:0,y:1}},mw=({source:t,sourcePosition:e=exports.Position.Bottom,target:n})=>e===exports.Position.Left||e===exports.Position.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},Aa=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function yw({source:t,sourcePosition:e=exports.Position.Bottom,target:n,targetPosition:r=exports.Position.Top,center:s,offset:o}){const i=Ma[e],a=Ma[r],c={x:t.x+i.x*o,y:t.y+i.y*o},l={x:n.x+a.x*o,y:n.y+a.y*o},u=mw({source:c,sourcePosition:e,target:l}),h=u.x!==0?"x":"y",d=u[h];let p=[],w,y;const b={x:0,y:0},S={x:0,y:0},[k,_,v,M]=lu({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(i[h]*a[h]===-1){w=s.x??k,y=s.y??_;const D=[{x:w,y:c.y},{x:w,y:l.y}],$=[{x:c.x,y},{x:l.x,y}];i[h]===d?p=h==="x"?D:$:p=h==="x"?$:D}else{const D=[{x:c.x,y:l.y}],$=[{x:l.x,y:c.y}];if(h==="x"?p=i.x===d?$:D:p=i.y===d?D:$,e===r){const Y=Math.abs(t[h]-n[h]);if(Y<=o){const g=Math.min(o-1,o-Y);i[h]===d?b[h]=(c[h]>t[h]?-1:1)*g:S[h]=(l[h]>n[h]?-1:1)*g}}if(e!==r){const Y=h==="x"?"y":"x",g=i[h]===a[Y],A=c[Y]>l[Y],R=c[Y]<l[Y];(i[h]===1&&(!g&&A||g&&R)||i[h]!==1&&(!g&&R||g&&A))&&(p=h==="x"?D:$)}const O={x:c.x+b.x,y:c.y+b.y},U={x:l.x+S.x,y:l.y+S.y},N=Math.max(Math.abs(O.x-p[0].x),Math.abs(U.x-p[0].x)),Z=Math.max(Math.abs(O.y-p[0].y),Math.abs(U.y-p[0].y));N>=Z?(w=(O.x+U.x)/2,y=p[0].y):(w=p[0].x,y=(O.y+U.y)/2)}return[[t,{x:c.x+b.x,y:c.y+b.y},...p,{x:l.x+S.x,y:l.y+S.y},n],w,y,v,M]}function ww(t,e,n,r){const s=Math.min(Aa(t,e)/2,Aa(e,n)/2,r),{x:o,y:i}=e;if(t.x===o&&o===n.x||t.y===i&&i===n.y)return`L${o} ${i}`;if(t.y===i){const l=t.x<n.x?-1:1,u=t.y<n.y?1:-1;return`L ${o+s*l},${i}Q ${o},${i} ${o},${i+s*u}`}const a=t.x<n.x?1:-1,c=t.y<n.y?-1:1;return`L ${o},${i+s*c}Q ${o},${i} ${o+s*a},${i}`}function bo({sourceX:t,sourceY:e,sourcePosition:n=exports.Position.Bottom,targetX:r,targetY:s,targetPosition:o=exports.Position.Top,borderRadius:i=5,centerX:a,centerY:c,offset:l=20}){const[u,h,d,p,w]=yw({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:a,y:c},offset:l});return[u.reduce((b,S,k)=>{let _="";return k>0&&k<u.length-1?_=ww(u[k-1],S,u[k+1],i):_=`${k===0?"M":"L"}${S.x} ${S.y}`,b+=_,b},""),h,d,p,w]}const Ps=x.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,sourcePosition:h=exports.Position.Bottom,targetPosition:d=exports.Position.Top,markerEnd:p,markerStart:w,pathOptions:y,interactionWidth:b})=>{const[S,k,_]=bo({sourceX:t,sourceY:e,sourcePosition:h,targetX:n,targetY:r,targetPosition:d,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset});return x.createElement(un,{path:S,labelX:k,labelY:_,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:p,markerStart:w,interactionWidth:b})});Ps.displayName="SmoothStepEdge";const yi=x.memo(t=>{var e;return x.createElement(Ps,{...t,pathOptions:x.useMemo(()=>{var n;return{borderRadius:0,offset:(n=t.pathOptions)==null?void 0:n.offset}},[(e=t.pathOptions)==null?void 0:e.offset])})});yi.displayName="StepEdge";function xw({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[s,o,i,a]=lu({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,s,o,i,a]}const wi=x.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:d,interactionWidth:p})=>{const[w,y,b]=xw({sourceX:t,sourceY:e,targetX:n,targetY:r});return x.createElement(un,{path:w,labelX:y,labelY:b,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:d,interactionWidth:p})});wi.displayName="StraightEdge";function yr(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function Na({pos:t,x1:e,y1:n,x2:r,y2:s,c:o}){switch(t){case exports.Position.Left:return[e-yr(e-r,o),n];case exports.Position.Right:return[e+yr(r-e,o),n];case exports.Position.Top:return[e,n-yr(n-s,o)];case exports.Position.Bottom:return[e,n+yr(s-n,o)]}}function fu({sourceX:t,sourceY:e,sourcePosition:n=exports.Position.Bottom,targetX:r,targetY:s,targetPosition:o=exports.Position.Top,curvature:i=.25}){const[a,c]=Na({pos:n,x1:t,y1:e,x2:r,y2:s,c:i}),[l,u]=Na({pos:o,x1:r,y1:s,x2:t,y2:e,c:i}),[h,d,p,w]=uu({sourceX:t,sourceY:e,targetX:r,targetY:s,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${t},${e} C${a},${c} ${l},${u} ${r},${s}`,h,d,p,w]}const ls=x.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,sourcePosition:s=exports.Position.Bottom,targetPosition:o=exports.Position.Top,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:w,pathOptions:y,interactionWidth:b})=>{const[S,k,_]=fu({sourceX:t,sourceY:e,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:y==null?void 0:y.curvature});return x.createElement(un,{path:S,labelX:k,labelY:_,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:d,markerEnd:p,markerStart:w,interactionWidth:b})});ls.displayName="BezierEdge";const xi=x.createContext(null),Sw=xi.Provider;xi.Consumer;const vw=()=>x.useContext(xi),bw=t=>"id"in t&&"source"in t&&"target"in t,du=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`reactflow__edge-${t}${e||""}-${n}${r||""}`,To=(t,e)=>typeof t>"u"?"":typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`,Tw=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),pu=(t,e)=>{if(!t.source||!t.target)return is("006",St.error006()),e;let n;return bw(t)?n={...t}:n={...t,id:du(t)},Tw(n,e)?e:e.concat(n)},Ew=(t,e,n,r={shouldReplaceId:!0})=>{const{id:s,...o}=t;if(!e.source||!e.target)return is("006",St.error006()),n;if(!n.find(c=>c.id===s))return is("007",St.error007(s)),n;const a={...o,id:r.shouldReplaceId?du(e):s,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle};return n.filter(c=>c.id!==s).concat(a)},_w=(t,e,n,r={shouldReplaceId:!0})=>(console.warn("[DEPRECATED] `updateEdge` is deprecated. Instead use `reconnectEdge` https://reactflow.dev/api-reference/utils/reconnect-edge"),Ew(t,e,n,r)),Eo=({x:t,y:e},[n,r,s],o,[i,a])=>{const c={x:(t-n)/s,y:(e-r)/s};return o?{x:i*Math.round(c.x/i),y:a*Math.round(c.y/a)}:c},gu=({x:t,y:e},[n,r,s])=>({x:t*s+n,y:e*s+r}),Fe=(t,e=[0,0])=>{if(!t)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(t.width??0)*e[0],r=(t.height??0)*e[1],s={x:t.position.x-n,y:t.position.y-r};return{...s,positionAbsolute:t.positionAbsolute?{x:t.positionAbsolute.x-n,y:t.positionAbsolute.y-r}:s}},Si=(t,e=[0,0])=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((r,s)=>{const{x:o,y:i}=Fe(s,e).positionAbsolute;return fw(r,gi({x:o,y:i,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return dw(n)},mu=(t,e,[n,r,s]=[0,0,1],o=!1,i=!1,a=[0,0])=>{const c={x:(e.x-n)/s,y:(e.y-r)/s,width:e.width/s,height:e.height/s},l=[];return t.forEach(u=>{const{width:h,height:d,selectable:p=!0,hidden:w=!1}=u;if(i&&!p||w)return!1;const{positionAbsolute:y}=Fe(u,a),b={x:y.x,y:y.y,width:h||0,height:d||0},S=So(c,b),k=typeof h>"u"||typeof d>"u"||h===null||d===null,_=o&&S>0,v=(h||0)*(d||0);(k||_||S>=v||u.dragging)&&l.push(u)}),l},yu=(t,e)=>{const n=t.map(r=>r.id);return e.filter(r=>n.includes(r.source)||n.includes(r.target))},wu=(t,e,n,r,s,o=.1)=>{const i=e/(t.width*(1+o)),a=n/(t.height*(1+o)),c=Math.min(i,a),l=sn(c,r,s),u=t.x+t.width/2,h=t.y+t.height/2,d=e/2-u*l,p=n/2-h*l;return{x:d,y:p,zoom:l}},he=(t,e=0)=>t.transition().duration(e);function Da(t,e,n,r){return(e[n]||[]).reduce((s,o)=>{var i,a;return`${t.id}-${o.id}-${n}`!==r&&s.push({id:o.id||null,type:n,nodeId:t.id,x:(((i=t.positionAbsolute)==null?void 0:i.x)??0)+o.x+o.width/2,y:(((a=t.positionAbsolute)==null?void 0:a.y)??0)+o.y+o.height/2}),s},[])}function Cw(t,e,n,r,s,o){const{x:i,y:a}=ne(t),l=e.elementsFromPoint(i,a).find(w=>w.classList.contains("react-flow__handle"));if(l){const w=l.getAttribute("data-nodeid");if(w){const y=vi(void 0,l),b=l.getAttribute("data-handleid"),S=o({nodeId:w,id:b,type:y});if(S){const k=s.find(_=>_.nodeId===w&&_.type===y&&_.id===b);return{handle:{id:b,type:y,nodeId:w,x:(k==null?void 0:k.x)||n.x,y:(k==null?void 0:k.y)||n.y},validHandleResult:S}}}}let u=[],h=1/0;if(s.forEach(w=>{const y=Math.sqrt((w.x-n.x)**2+(w.y-n.y)**2);if(y<=r){const b=o(w);y<=h&&(y<h?u=[{handle:w,validHandleResult:b}]:y===h&&u.push({handle:w,validHandleResult:b}),h=y)}}),!u.length)return{handle:null,validHandleResult:xu()};if(u.length===1)return u[0];const d=u.some(({validHandleResult:w})=>w.isValid),p=u.some(({handle:w})=>w.type==="target");return u.find(({handle:w,validHandleResult:y})=>p?w.type==="target":d?y.isValid:!0)||u[0]}const Pw={source:null,target:null,sourceHandle:null,targetHandle:null},xu=()=>({handleDomNode:null,isValid:!1,connection:Pw,endHandle:null});function Su(t,e,n,r,s,o,i){const a=s==="target",c=i.querySelector(`.react-flow__handle[data-id="${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`),l={...xu(),handleDomNode:c};if(c){const u=vi(void 0,c),h=c.getAttribute("data-nodeid"),d=c.getAttribute("data-handleid"),p=c.classList.contains("connectable"),w=c.classList.contains("connectableend"),y={source:a?h:n,sourceHandle:a?d:r,target:a?n:h,targetHandle:a?r:d};l.connection=y,p&&w&&(e===exports.ConnectionMode.Strict?a&&u==="source"||!a&&u==="target":h!==n||d!==r)&&(l.endHandle={nodeId:h,handleId:d,type:u},l.isValid=o(y))}return l}function Rw({nodes:t,nodeId:e,handleId:n,handleType:r}){return t.reduce((s,o)=>{if(o[ct]){const{handleBounds:i}=o[ct];let a=[],c=[];i&&(a=Da(o,i,"source",`${e}-${n}-${r}`),c=Da(o,i,"target",`${e}-${n}-${r}`)),s.push(...a,...c)}return s},[])}function vi(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function Ws(t){t==null||t.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function kw(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function vu({event:t,handleId:e,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:i,isValidConnection:a,edgeUpdaterType:c,onReconnectEnd:l}){const u=iu(t.target),{connectionMode:h,domNode:d,autoPanOnConnect:p,connectionRadius:w,onConnectStart:y,panBy:b,getNodes:S,cancelConnection:k}=o();let _=0,v;const{x:M,y:C}=ne(t),D=u==null?void 0:u.elementFromPoint(M,C),$=vi(c,D),O=d==null?void 0:d.getBoundingClientRect();if(!O||!$)return;let U,N=ne(t,O),Z=!1,Y=null,g=!1,A=null;const R=Rw({nodes:S(),nodeId:n,handleId:e,handleType:$}),z=()=>{if(!p)return;const[I,q]=ou(N,O);b({x:I,y:q}),_=requestAnimationFrame(z)};i({connectionPosition:N,connectionStatus:null,connectionNodeId:n,connectionHandleId:e,connectionHandleType:$,connectionStartHandle:{nodeId:n,handleId:e,type:$},connectionEndHandle:null}),y==null||y(t,{nodeId:n,handleId:e,handleType:$});function B(I){const{transform:q}=o();N=ne(I,O);const{handle:F,validHandleResult:X}=Cw(I,u,Eo(N,q,!1,[1,1]),w,R,V=>Su(V,h,n,e,s?"target":"source",a,u));if(v=F,Z||(z(),Z=!0),A=X.handleDomNode,Y=X.connection,g=X.isValid,i({connectionPosition:v&&g?gu({x:v.x,y:v.y},q):N,connectionStatus:kw(!!v,g),connectionEndHandle:X.endHandle}),!v&&!g&&!A)return Ws(U);Y.source!==Y.target&&A&&(Ws(U),U=A,A.classList.add("connecting","react-flow__handle-connecting"),A.classList.toggle("valid",g),A.classList.toggle("react-flow__handle-valid",g))}function P(I){var q,F;(v||A)&&Y&&g&&(r==null||r(Y)),(F=(q=o()).onConnectEnd)==null||F.call(q,I),c&&(l==null||l(I)),Ws(U),k(),cancelAnimationFrame(_),Z=!1,g=!1,Y=null,A=null,u.removeEventListener("mousemove",B),u.removeEventListener("mouseup",P),u.removeEventListener("touchmove",B),u.removeEventListener("touchend",P)}u.addEventListener("mousemove",B),u.addEventListener("mouseup",P),u.addEventListener("touchmove",B),u.addEventListener("touchend",P)}const Oa=()=>!0,Mw=t=>({connectionStartHandle:t.connectionStartHandle,connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName}),Aw=(t,e,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:o,connectionClickStartHandle:i}=r;return{connecting:(s==null?void 0:s.nodeId)===t&&(s==null?void 0:s.handleId)===e&&(s==null?void 0:s.type)===n||(o==null?void 0:o.nodeId)===t&&(o==null?void 0:o.handleId)===e&&(o==null?void 0:o.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===t&&(i==null?void 0:i.handleId)===e&&(i==null?void 0:i.type)===n}},bu=x.forwardRef(({type:t="source",position:e=exports.Position.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:i,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:h,...d},p)=>{var O,U;const w=i||null,y=t==="target",b=ht(),S=vw(),{connectOnClick:k,noPanClassName:_}=lt(Mw,pt),{connecting:v,clickConnecting:M}=lt(Aw(S,w,t),pt);S||(U=(O=b.getState()).onError)==null||U.call(O,"010",St.error010());const C=N=>{const{defaultEdgeOptions:Z,onConnect:Y,hasDefaultEdges:g}=b.getState(),A={...Z,...N};if(g){const{edges:R,setEdges:z}=b.getState();z(pu(A,R))}Y==null||Y(A),a==null||a(A)},D=N=>{if(!S)return;const Z=cu(N);s&&(Z&&N.button===0||!Z)&&vu({event:N,handleId:w,nodeId:S,onConnect:C,isTarget:y,getState:b.getState,setState:b.setState,isValidConnection:n||b.getState().isValidConnection||Oa}),Z?u==null||u(N):h==null||h(N)},$=N=>{const{onClickConnectStart:Z,onClickConnectEnd:Y,connectionClickStartHandle:g,connectionMode:A,isValidConnection:R}=b.getState();if(!S||!g&&!s)return;if(!g){Z==null||Z(N,{nodeId:S,handleId:w,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:S,type:t,handleId:w}});return}const z=iu(N.target),B=n||R||Oa,{connection:P,isValid:I}=Su({nodeId:S,id:w,type:t},A,g.nodeId,g.handleId||null,g.type,B,z);I&&C(P),Y==null||Y(N),b.setState({connectionClickStartHandle:null})};return x.createElement("div",{"data-handleid":w,"data-nodeid":S,"data-handlepos":e,"data-id":`${S}-${w}-${t}`,className:vt(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",_,l,{source:!y,target:y,connectable:r,connectablestart:s,connectableend:o,connecting:M,connectionindicator:r&&(s&&!v||o&&v)}]),onMouseDown:D,onTouchStart:D,onClick:k?$:void 0,ref:p,...d},c)});bu.displayName="Handle";var Kn=x.memo(bu);const Tu=({data:t,isConnectable:e,targetPosition:n=exports.Position.Top,sourcePosition:r=exports.Position.Bottom})=>x.createElement(x.Fragment,null,x.createElement(Kn,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,x.createElement(Kn,{type:"source",position:r,isConnectable:e}));Tu.displayName="DefaultNode";var _o=x.memo(Tu);const Eu=({data:t,isConnectable:e,sourcePosition:n=exports.Position.Bottom})=>x.createElement(x.Fragment,null,t==null?void 0:t.label,x.createElement(Kn,{type:"source",position:n,isConnectable:e}));Eu.displayName="InputNode";var _u=x.memo(Eu);const Cu=({data:t,isConnectable:e,targetPosition:n=exports.Position.Top})=>x.createElement(x.Fragment,null,x.createElement(Kn,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label);Cu.displayName="OutputNode";var Pu=x.memo(Cu);const bi=()=>null;bi.displayName="GroupNode";const Nw=t=>({selectedNodes:t.getNodes().filter(e=>e.selected),selectedEdges:t.edges.filter(e=>e.selected).map(e=>({...e}))}),wr=t=>t.id;function Dw(t,e){return pt(t.selectedNodes.map(wr),e.selectedNodes.map(wr))&&pt(t.selectedEdges.map(wr),e.selectedEdges.map(wr))}const Ru=x.memo(({onSelectionChange:t})=>{const e=ht(),{selectedNodes:n,selectedEdges:r}=lt(Nw,Dw);return x.useEffect(()=>{const s={nodes:n,edges:r};t==null||t(s),e.getState().onSelectionChange.forEach(o=>o(s))},[n,r,t]),null});Ru.displayName="SelectionListener";const Ow=t=>!!t.onSelectionChange;function zw({onSelectionChange:t}){const e=lt(Ow);return t||e?x.createElement(Ru,{onSelectionChange:t}):null}const Iw=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset});function Me(t,e){x.useEffect(()=>{typeof t<"u"&&e(t)},[t])}function Q(t,e,n){x.useEffect(()=>{typeof e<"u"&&n({[t]:e})},[e])}const Lw=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:i,onClickConnectStart:a,onClickConnectEnd:c,nodesDraggable:l,nodesConnectable:u,nodesFocusable:h,edgesFocusable:d,edgesUpdatable:p,elevateNodesOnSelect:w,minZoom:y,maxZoom:b,nodeExtent:S,onNodesChange:k,onEdgesChange:_,elementsSelectable:v,connectionMode:M,snapGrid:C,snapToGrid:D,translateExtent:$,connectOnClick:O,defaultEdgeOptions:U,fitView:N,fitViewOptions:Z,onNodesDelete:Y,onEdgesDelete:g,onNodeDrag:A,onNodeDragStart:R,onNodeDragStop:z,onSelectionDrag:B,onSelectionDragStart:P,onSelectionDragStop:I,noPanClassName:q,nodeOrigin:F,rfId:X,autoPanOnConnect:V,autoPanOnNodeDrag:K,onError:tt,connectionRadius:et,isValidConnection:ot,nodeDragThreshold:H})=>{const{setNodes:G,setEdges:j,setDefaultNodesAndEdges:L,setMinZoom:it,setMaxZoom:J,setTranslateExtent:nt,setNodeExtent:at,reset:rt}=lt(Iw,pt),W=ht();return x.useEffect(()=>{const wt=r==null?void 0:r.map(se=>({...se,...U}));return L(n,wt),()=>{rt()}},[]),Q("defaultEdgeOptions",U,W.setState),Q("connectionMode",M,W.setState),Q("onConnect",s,W.setState),Q("onConnectStart",o,W.setState),Q("onConnectEnd",i,W.setState),Q("onClickConnectStart",a,W.setState),Q("onClickConnectEnd",c,W.setState),Q("nodesDraggable",l,W.setState),Q("nodesConnectable",u,W.setState),Q("nodesFocusable",h,W.setState),Q("edgesFocusable",d,W.setState),Q("edgesUpdatable",p,W.setState),Q("elementsSelectable",v,W.setState),Q("elevateNodesOnSelect",w,W.setState),Q("snapToGrid",D,W.setState),Q("snapGrid",C,W.setState),Q("onNodesChange",k,W.setState),Q("onEdgesChange",_,W.setState),Q("connectOnClick",O,W.setState),Q("fitViewOnInit",N,W.setState),Q("fitViewOnInitOptions",Z,W.setState),Q("onNodesDelete",Y,W.setState),Q("onEdgesDelete",g,W.setState),Q("onNodeDrag",A,W.setState),Q("onNodeDragStart",R,W.setState),Q("onNodeDragStop",z,W.setState),Q("onSelectionDrag",B,W.setState),Q("onSelectionDragStart",P,W.setState),Q("onSelectionDragStop",I,W.setState),Q("noPanClassName",q,W.setState),Q("nodeOrigin",F,W.setState),Q("rfId",X,W.setState),Q("autoPanOnConnect",V,W.setState),Q("autoPanOnNodeDrag",K,W.setState),Q("onError",tt,W.setState),Q("connectionRadius",et,W.setState),Q("isValidConnection",ot,W.setState),Q("nodeDragThreshold",H,W.setState),Me(t,G),Me(e,j),Me(y,it),Me(b,J),Me($,nt),Me(S,at),null},za={display:"none"},$w={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ku="react-flow__node-desc",Mu="react-flow__edge-desc",Yw="react-flow__aria-live",Bw=t=>t.ariaLiveMessage;function qw({rfId:t}){const e=lt(Bw);return x.createElement("div",{id:`${Yw}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:$w},e)}function Fw({rfId:t,disableKeyboardA11y:e}){return x.createElement(x.Fragment,null,x.createElement("div",{id:`${ku}-${t}`,style:za},"Press enter or space to select a node.",!e&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),x.createElement("div",{id:`${Mu}-${t}`,style:za},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&x.createElement(qw,{rfId:t}))}var jn=(t=null,e={actInsideInputWithModifier:!0})=>{const[n,r]=x.useState(!1),s=x.useRef(!1),o=x.useRef(new Set([])),[i,a]=x.useMemo(()=>{if(t!==null){const l=(Array.isArray(t)?t:[t]).filter(h=>typeof h=="string").map(h=>h.split("+")),u=l.reduce((h,d)=>h.concat(...d),[]);return[l,u]}return[[],[]]},[t]);return x.useEffect(()=>{const c=typeof document<"u"?document:null,l=(e==null?void 0:e.target)||c;if(t!==null){const u=p=>{if(s.current=p.ctrlKey||p.metaKey||p.shiftKey,(!s.current||s.current&&!e.actInsideInputWithModifier)&&vo(p))return!1;const y=La(p.code,a);o.current.add(p[y]),Ia(i,o.current,!1)&&(p.preventDefault(),r(!0))},h=p=>{if((!s.current||s.current&&!e.actInsideInputWithModifier)&&vo(p))return!1;const y=La(p.code,a);Ia(i,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(p[y]),p.key==="Meta"&&o.current.clear(),s.current=!1},d=()=>{o.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",u),l==null||l.addEventListener("keyup",h),window.addEventListener("blur",d),()=>{l==null||l.removeEventListener("keydown",u),l==null||l.removeEventListener("keyup",h),window.removeEventListener("blur",d)}}},[t,r]),n};function Ia(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(s=>e.has(s)))}function La(t,e){return e.includes(t)?"code":"key"}function Au(t,e,n,r){var a,c;const s=t.parentNode||t.parentId;if(!s)return n;const o=e.get(s),i=Fe(o,r);return Au(o,e,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((a=o[ct])==null?void 0:a.z)??0)>(n.z??0)?((c=o[ct])==null?void 0:c.z)??0:n.z??0},r)}function Nu(t,e,n){t.forEach(r=>{var o;const s=r.parentNode||r.parentId;if(s&&!t.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[r.id]){const{x:i,y:a,z:c}=Au(r,t,{...r.position,z:((o=r[ct])==null?void 0:o.z)??0},e);r.positionAbsolute={x:i,y:a},r[ct].z=c,n!=null&&n[r.id]&&(r[ct].isParent=!0)}})}function Ks(t,e,n,r){const s=new Map,o={},i=r?1e3:0;return t.forEach(a=>{var p;const c=(Et(a.zIndex)?a.zIndex:0)+(a.selected?i:0),l=e.get(a.id),u={...a,positionAbsolute:{x:a.position.x,y:a.position.y}},h=a.parentNode||a.parentId;h&&(o[h]=!0);const d=(l==null?void 0:l.type)&&(l==null?void 0:l.type)!==a.type;Object.defineProperty(u,ct,{enumerable:!1,value:{handleBounds:d||(p=l==null?void 0:l[ct])==null?void 0:p.handleBounds,z:c}}),s.set(a.id,u)}),Nu(s,n,o),s}function Du(t,e={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:i,d3Zoom:a,d3Selection:c,fitViewOnInitDone:l,fitViewOnInit:u,nodeOrigin:h}=t(),d=e.initial&&!l&&u;if(a&&c&&(d||!e.initial)){const w=n().filter(b=>{var k;const S=e.includeHiddenNodes?b.width&&b.height:!b.hidden;return(k=e.nodes)!=null&&k.length?S&&e.nodes.some(_=>_.id===b.id):S}),y=w.every(b=>b.width&&b.height);if(w.length>0&&y){const b=Si(w,h),{x:S,y:k,zoom:_}=wu(b,r,s,e.minZoom??o,e.maxZoom??i,e.padding??.1),v=ee.translate(S,k).scale(_);return typeof e.duration=="number"&&e.duration>0?a.transform(he(c,e.duration),v):a.transform(c,v),!0}}return!1}function Uw(t,e){return t.forEach(n=>{const r=e.get(n.id);r&&e.set(r.id,{...r,[ct]:r[ct],selected:n.selected})}),new Map(e)}function Zw(t,e){return e.map(n=>{const r=t.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function xr({changedNodes:t,changedEdges:e,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:i,onEdgesChange:a,hasDefaultNodes:c,hasDefaultEdges:l}=n();t!=null&&t.length&&(c&&r({nodeInternals:Uw(t,s)}),i==null||i(t)),e!=null&&e.length&&(l&&r({edges:Zw(e,o)}),a==null||a(e))}const Ae=()=>{},Hw={zoomIn:Ae,zoomOut:Ae,zoomTo:Ae,getZoom:()=>1,setViewport:Ae,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Ae,fitBounds:Ae,project:t=>t,screenToFlowPosition:t=>t,flowToScreenPosition:t=>t,viewportInitialized:!1},Vw=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection}),Xw=()=>{const t=ht(),{d3Zoom:e,d3Selection:n}=lt(Vw,pt);return x.useMemo(()=>n&&e?{zoomIn:s=>e.scaleBy(he(n,s==null?void 0:s.duration),1.2),zoomOut:s=>e.scaleBy(he(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>e.scaleTo(he(n,o==null?void 0:o.duration),s),getZoom:()=>t.getState().transform[2],setViewport:(s,o)=>{const[i,a,c]=t.getState().transform,l=ee.translate(s.x??i,s.y??a).scale(s.zoom??c);e.transform(he(n,o==null?void 0:o.duration),l)},getViewport:()=>{const[s,o,i]=t.getState().transform;return{x:s,y:o,zoom:i}},fitView:s=>Du(t.getState,s),setCenter:(s,o,i)=>{const{width:a,height:c,maxZoom:l}=t.getState(),u=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:l,h=a/2-s*u,d=c/2-o*u,p=ee.translate(h,d).scale(u);e.transform(he(n,i==null?void 0:i.duration),p)},fitBounds:(s,o)=>{const{width:i,height:a,minZoom:c,maxZoom:l}=t.getState(),{x:u,y:h,zoom:d}=wu(s,i,a,c,l,(o==null?void 0:o.padding)??.1),p=ee.translate(u,h).scale(d);e.transform(he(n,o==null?void 0:o.duration),p)},project:s=>{const{transform:o,snapToGrid:i,snapGrid:a}=t.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Eo(s,o,i,a)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:i,snapGrid:a,domNode:c}=t.getState();if(!c)return s;const{x:l,y:u}=c.getBoundingClientRect(),h={x:s.x-l,y:s.y-u};return Eo(h,o,i,a)},flowToScreenPosition:s=>{const{transform:o,domNode:i}=t.getState();if(!i)return s;const{x:a,y:c}=i.getBoundingClientRect(),l=gu(s,o);return{x:l.x+a,y:l.y+c}},viewportInitialized:!0}:Hw,[e,n])};function Rs(){const t=Xw(),e=ht(),n=x.useCallback(()=>e.getState().getNodes().map(y=>({...y})),[]),r=x.useCallback(y=>e.getState().nodeInternals.get(y),[]),s=x.useCallback(()=>{const{edges:y=[]}=e.getState();return y.map(b=>({...b}))},[]),o=x.useCallback(y=>{const{edges:b=[]}=e.getState();return b.find(S=>S.id===y)},[]),i=x.useCallback(y=>{const{getNodes:b,setNodes:S,hasDefaultNodes:k,onNodesChange:_}=e.getState(),v=b(),M=typeof y=="function"?y(v):y;if(k)S(M);else if(_){const C=M.length===0?v.map(D=>({type:"remove",id:D.id})):M.map(D=>({item:D,type:"reset"}));_(C)}},[]),a=x.useCallback(y=>{const{edges:b=[],setEdges:S,hasDefaultEdges:k,onEdgesChange:_}=e.getState(),v=typeof y=="function"?y(b):y;if(k)S(v);else if(_){const M=v.length===0?b.map(C=>({type:"remove",id:C.id})):v.map(C=>({item:C,type:"reset"}));_(M)}},[]),c=x.useCallback(y=>{const b=Array.isArray(y)?y:[y],{getNodes:S,setNodes:k,hasDefaultNodes:_,onNodesChange:v}=e.getState();if(_){const C=[...S(),...b];k(C)}else if(v){const M=b.map(C=>({item:C,type:"add"}));v(M)}},[]),l=x.useCallback(y=>{const b=Array.isArray(y)?y:[y],{edges:S=[],setEdges:k,hasDefaultEdges:_,onEdgesChange:v}=e.getState();if(_)k([...S,...b]);else if(v){const M=b.map(C=>({item:C,type:"add"}));v(M)}},[]),u=x.useCallback(()=>{const{getNodes:y,edges:b=[],transform:S}=e.getState(),[k,_,v]=S;return{nodes:y().map(M=>({...M})),edges:b.map(M=>({...M})),viewport:{x:k,y:_,zoom:v}}},[]),h=x.useCallback(({nodes:y,edges:b})=>{const{nodeInternals:S,getNodes:k,edges:_,hasDefaultNodes:v,hasDefaultEdges:M,onNodesDelete:C,onEdgesDelete:D,onNodesChange:$,onEdgesChange:O}=e.getState(),U=(y||[]).map(A=>A.id),N=(b||[]).map(A=>A.id),Z=k().reduce((A,R)=>{const z=R.parentNode||R.parentId,B=!U.includes(R.id)&&z&&A.find(I=>I.id===z);return(typeof R.deletable=="boolean"?R.deletable:!0)&&(U.includes(R.id)||B)&&A.push(R),A},[]),Y=_.filter(A=>typeof A.deletable=="boolean"?A.deletable:!0),g=Y.filter(A=>N.includes(A.id));if(Z||g){const A=yu(Z,Y),R=[...g,...A],z=R.reduce((B,P)=>(B.includes(P.id)||B.push(P.id),B),[]);if((M||v)&&(M&&e.setState({edges:_.filter(B=>!z.includes(B.id))}),v&&(Z.forEach(B=>{S.delete(B.id)}),e.setState({nodeInternals:new Map(S)}))),z.length>0&&(D==null||D(R),O&&O(z.map(B=>({id:B,type:"remove"})))),Z.length>0&&(C==null||C(Z),$)){const B=Z.map(P=>({id:P.id,type:"remove"}));$(B)}}},[]),d=x.useCallback(y=>{const b=pw(y),S=b?null:e.getState().nodeInternals.get(y.id);return!b&&!S?[null,null,b]:[b?y:Ra(S),S,b]},[]),p=x.useCallback((y,b=!0,S)=>{const[k,_,v]=d(y);return k?(S||e.getState().getNodes()).filter(M=>{if(!v&&(M.id===_.id||!M.positionAbsolute))return!1;const C=Ra(M),D=So(C,k);return b&&D>0||D>=k.width*k.height}):[]},[]),w=x.useCallback((y,b,S=!0)=>{const[k]=d(y);if(!k)return!1;const _=So(k,b);return S&&_>0||_>=k.width*k.height},[]);return x.useMemo(()=>({...t,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:i,setEdges:a,addNodes:c,addEdges:l,toObject:u,deleteElements:h,getIntersectingNodes:p,isNodeIntersecting:w}),[t,n,r,s,o,i,a,c,l,u,h,p,w])}const Gw={actInsideInputWithModifier:!1};var Ww=({deleteKeyCode:t,multiSelectionKeyCode:e})=>{const n=ht(),{deleteElements:r}=Rs(),s=jn(t,Gw),o=jn(e);x.useEffect(()=>{if(s){const{edges:i,getNodes:a}=n.getState(),c=a().filter(u=>u.selected),l=i.filter(u=>u.selected);r({nodes:c,edges:l}),n.setState({nodesSelectionActive:!1})}},[s]),x.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function Kw(t){const e=ht();x.useEffect(()=>{let n;const r=()=>{var o,i;if(!t.current)return;const s=di(t.current);(s.height===0||s.width===0)&&((i=(o=e.getState()).onError)==null||i.call(o,"004",St.error004())),e.setState({width:s.width||500,height:s.height||500})};return r(),window.addEventListener("resize",r),t.current&&(n=new ResizeObserver(()=>r()),n.observe(t.current)),()=>{window.removeEventListener("resize",r),n&&t.current&&n.unobserve(t.current)}},[])}const Ti={position:"absolute",width:"100%",height:"100%",top:0,left:0},jw=(t,e)=>t.x!==e.x||t.y!==e.y||t.zoom!==e.k,Sr=t=>({x:t.x,y:t.y,zoom:t.k}),Ne=(t,e)=>t.target.closest(`.${e}`),$a=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),Ya=t=>{const e=t.ctrlKey&&as()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e},Jw=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection,d3ZoomHandler:t.d3ZoomHandler,userSelectionActive:t.userSelectionActive}),Qw=({onMove:t,onMoveStart:e,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:a=.5,panOnScrollMode:c=pe.Free,zoomOnDoubleClick:l=!0,elementsSelectable:u,panOnDrag:h=!0,defaultViewport:d,translateExtent:p,minZoom:w,maxZoom:y,zoomActivationKeyCode:b,preventScrolling:S=!0,children:k,noWheelClassName:_,noPanClassName:v})=>{const M=x.useRef(),C=ht(),D=x.useRef(!1),$=x.useRef(!1),O=x.useRef(null),U=x.useRef({x:0,y:0,zoom:0}),{d3Zoom:N,d3Selection:Z,d3ZoomHandler:Y,userSelectionActive:g}=lt(Jw,pt),A=jn(b),R=x.useRef(0),z=x.useRef(!1),B=x.useRef();return Kw(O),x.useEffect(()=>{if(O.current){const P=O.current.getBoundingClientRect(),I=ow().scaleExtent([w,y]).translateExtent(p),q=kt(O.current).call(I),F=ee.translate(d.x,d.y).scale(sn(d.zoom,w,y)),X=[[0,0],[P.width,P.height]],V=I.constrain()(F,X,p);I.transform(q,V),I.wheelDelta(Ya),C.setState({d3Zoom:I,d3Selection:q,d3ZoomHandler:q.on("wheel.zoom"),transform:[V.x,V.y,V.k],domNode:O.current.closest(".react-flow")})}},[]),x.useEffect(()=>{Z&&N&&(i&&!A&&!g?Z.on("wheel.zoom",P=>{if(Ne(P,_))return!1;P.preventDefault(),P.stopImmediatePropagation();const I=Z.property("__zoom").k||1;if(P.ctrlKey&&o){const ot=Ot(P),H=Ya(P),G=I*Math.pow(2,H);N.scaleTo(Z,G,ot,P);return}const q=P.deltaMode===1?20:1;let F=c===pe.Vertical?0:P.deltaX*q,X=c===pe.Horizontal?0:P.deltaY*q;!as()&&P.shiftKey&&c!==pe.Vertical&&(F=P.deltaY*q,X=0),N.translateBy(Z,-(F/I)*a,-(X/I)*a,{internal:!0});const V=Sr(Z.property("__zoom")),{onViewportChangeStart:K,onViewportChange:tt,onViewportChangeEnd:et}=C.getState();clearTimeout(B.current),z.current||(z.current=!0,e==null||e(P,V),K==null||K(V)),z.current&&(t==null||t(P,V),tt==null||tt(V),B.current=setTimeout(()=>{n==null||n(P,V),et==null||et(V),z.current=!1},150))},{passive:!1}):typeof Y<"u"&&Z.on("wheel.zoom",function(P,I){if(!S&&P.type==="wheel"&&!P.ctrlKey||Ne(P,_))return null;P.preventDefault(),Y.call(this,P,I)},{passive:!1}))},[g,i,c,Z,N,Y,A,o,S,_,e,t,n]),x.useEffect(()=>{N&&N.on("start",P=>{var F,X;if(!P.sourceEvent||P.sourceEvent.internal)return null;R.current=(F=P.sourceEvent)==null?void 0:F.button;const{onViewportChangeStart:I}=C.getState(),q=Sr(P.transform);D.current=!0,U.current=q,((X=P.sourceEvent)==null?void 0:X.type)==="mousedown"&&C.setState({paneDragging:!0}),I==null||I(q),e==null||e(P.sourceEvent,q)})},[N,e]),x.useEffect(()=>{N&&(g&&!D.current?N.on("zoom",null):g||N.on("zoom",P=>{var q;const{onViewportChange:I}=C.getState();if(C.setState({transform:[P.transform.x,P.transform.y,P.transform.k]}),$.current=!!(r&&$a(h,R.current??0)),(t||I)&&!((q=P.sourceEvent)!=null&&q.internal)){const F=Sr(P.transform);I==null||I(F),t==null||t(P.sourceEvent,F)}}))},[g,N,t,h,r]),x.useEffect(()=>{N&&N.on("end",P=>{if(!P.sourceEvent||P.sourceEvent.internal)return null;const{onViewportChangeEnd:I}=C.getState();if(D.current=!1,C.setState({paneDragging:!1}),r&&$a(h,R.current??0)&&!$.current&&r(P.sourceEvent),$.current=!1,(n||I)&&jw(U.current,P.transform)){const q=Sr(P.transform);U.current=q,clearTimeout(M.current),M.current=setTimeout(()=>{I==null||I(q),n==null||n(P.sourceEvent,q)},i?150:0)}})},[N,i,h,n,r]),x.useEffect(()=>{N&&N.filter(P=>{const I=A||s,q=o&&P.ctrlKey;if((h===!0||Array.isArray(h)&&h.includes(1))&&P.button===1&&P.type==="mousedown"&&(Ne(P,"react-flow__node")||Ne(P,"react-flow__edge")))return!0;if(!h&&!I&&!i&&!l&&!o||g||!l&&P.type==="dblclick"||Ne(P,_)&&P.type==="wheel"||Ne(P,v)&&(P.type!=="wheel"||i&&P.type==="wheel"&&!A)||!o&&P.ctrlKey&&P.type==="wheel"||!I&&!i&&!q&&P.type==="wheel"||!h&&(P.type==="mousedown"||P.type==="touchstart")||Array.isArray(h)&&!h.includes(P.button)&&P.type==="mousedown")return!1;const F=Array.isArray(h)&&h.includes(P.button)||!P.button||P.button<=1;return(!P.ctrlKey||P.type==="wheel")&&F})},[g,N,s,o,i,l,h,u,A]),x.createElement("div",{className:"react-flow__renderer",ref:O,style:Ti},k)},tx=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function ex(){const{userSelectionActive:t,userSelectionRect:e}=lt(tx,pt);return t&&e?x.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function Ba(t,e){const n=e.parentNode||e.parentId,r=t.find(s=>s.id===n);if(r){const s=e.position.x+e.width-r.width,o=e.position.y+e.height-r.height;if(s>0||o>0||e.position.x<0||e.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),o>0&&(r.style.height+=o),e.position.x<0){const i=Math.abs(e.position.x);r.position.x=r.position.x-i,r.style.width+=i,e.position.x=0}if(e.position.y<0){const i=Math.abs(e.position.y);r.position.y=r.position.y-i,r.style.height+=i,e.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function Ou(t,e){if(t.some(r=>r.type==="reset"))return t.filter(r=>r.type==="reset").map(r=>r.item);const n=t.filter(r=>r.type==="add").map(r=>r.item);return e.reduce((r,s)=>{const o=t.filter(a=>a.id===s.id);if(o.length===0)return r.push(s),r;const i={...s};for(const a of o)if(a)switch(a.type){case"select":{i.selected=a.selected;break}case"position":{typeof a.position<"u"&&(i.position=a.position),typeof a.positionAbsolute<"u"&&(i.positionAbsolute=a.positionAbsolute),typeof a.dragging<"u"&&(i.dragging=a.dragging),i.expandParent&&Ba(r,i);break}case"dimensions":{typeof a.dimensions<"u"&&(i.width=a.dimensions.width,i.height=a.dimensions.height),typeof a.updateStyle<"u"&&(i.style={...i.style||{},...a.dimensions}),typeof a.resizing=="boolean"&&(i.resizing=a.resizing),i.expandParent&&Ba(r,i);break}case"remove":return r}return r.push(i),r},n)}function zu(t,e){return Ou(t,e)}function nx(t,e){return Ou(t,e)}const jt=(t,e)=>({id:t,type:"select",selected:e});function Ie(t,e){return t.reduce((n,r)=>{const s=e.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(jt(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(jt(r.id,!1))),n},[])}const js=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},rx=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging}),Iu=x.memo(({isSelecting:t,selectionMode:e=exports.SelectionMode.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:a,onPaneMouseEnter:c,onPaneMouseMove:l,onPaneMouseLeave:u,children:h})=>{const d=x.useRef(null),p=ht(),w=x.useRef(0),y=x.useRef(0),b=x.useRef(),{userSelectionActive:S,elementsSelectable:k,dragging:_}=lt(rx,pt),v=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),w.current=0,y.current=0},M=Y=>{o==null||o(Y),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},C=Y=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){Y.preventDefault();return}i==null||i(Y)},D=a?Y=>a(Y):void 0,$=Y=>{const{resetSelectedElements:g,domNode:A}=p.getState();if(b.current=A==null?void 0:A.getBoundingClientRect(),!k||!t||Y.button!==0||Y.target!==d.current||!b.current)return;const{x:R,y:z}=ne(Y,b.current);g(),p.setState({userSelectionRect:{width:0,height:0,startX:R,startY:z,x:R,y:z}}),r==null||r(Y)},O=Y=>{const{userSelectionRect:g,nodeInternals:A,edges:R,transform:z,onNodesChange:B,onEdgesChange:P,nodeOrigin:I,getNodes:q}=p.getState();if(!t||!b.current||!g)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});const F=ne(Y,b.current),X=g.startX??0,V=g.startY??0,K={...g,x:F.x<X?F.x:X,y:F.y<V?F.y:V,width:Math.abs(F.x-X),height:Math.abs(F.y-V)},tt=q(),et=mu(A,K,z,e===exports.SelectionMode.Partial,!0,I),ot=yu(et,R).map(G=>G.id),H=et.map(G=>G.id);if(w.current!==H.length){w.current=H.length;const G=Ie(tt,H);G.length&&(B==null||B(G))}if(y.current!==ot.length){y.current=ot.length;const G=Ie(R,ot);G.length&&(P==null||P(G))}p.setState({userSelectionRect:K})},U=Y=>{if(Y.button!==0)return;const{userSelectionRect:g}=p.getState();!S&&g&&Y.target===d.current&&(M==null||M(Y)),p.setState({nodesSelectionActive:w.current>0}),v(),s==null||s(Y)},N=Y=>{S&&(p.setState({nodesSelectionActive:w.current>0}),s==null||s(Y)),v()},Z=k&&(t||S);return x.createElement("div",{className:vt(["react-flow__pane",{dragging:_,selection:t}]),onClick:Z?void 0:js(M,d),onContextMenu:js(C,d),onWheel:js(D,d),onMouseEnter:Z?void 0:c,onMouseDown:Z?$:void 0,onMouseMove:Z?O:l,onMouseUp:Z?U:void 0,onMouseLeave:Z?N:u,ref:d,style:Ti},h,x.createElement(ex,null))});Iu.displayName="Pane";function Lu(t,e){const n=t.parentNode||t.parentId;if(!n)return!1;const r=e.get(n);return r?r.selected?!0:Lu(r,e):!1}function qa(t,e,n){let r=t;do{if(r!=null&&r.matches(e))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function sx(t,e,n,r){return Array.from(t.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!Lu(s,t))&&(s.draggable||e&&typeof s.draggable>"u")).map(s=>{var o,i;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=s.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((i=s.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function ox(t,e){return!e||e==="parent"?e:[e[0],[e[1][0]-(t.width||0),e[1][1]-(t.height||0)]]}function $u(t,e,n,r,s=[0,0],o){const i=ox(t,t.extent||r);let a=i;const c=t.parentNode||t.parentId;if(t.extent==="parent"&&!t.expandParent)if(c&&t.width&&t.height){const h=n.get(c),{x:d,y:p}=Fe(h,s).positionAbsolute;a=h&&Et(d)&&Et(p)&&Et(h.width)&&Et(h.height)?[[d+t.width*s[0],p+t.height*s[1]],[d+h.width-t.width+t.width*s[0],p+h.height-t.height+t.height*s[1]]]:a}else o==null||o("005",St.error005()),a=i;else if(t.extent&&c&&t.extent!=="parent"){const h=n.get(c),{x:d,y:p}=Fe(h,s).positionAbsolute;a=[[t.extent[0][0]+d,t.extent[0][1]+p],[t.extent[1][0]+d,t.extent[1][1]+p]]}let l={x:0,y:0};if(c){const h=n.get(c);l=Fe(h,s).positionAbsolute}const u=a&&a!=="parent"?pi(e,a):e;return{position:{x:u.x-l.x,y:u.y-l.y},positionAbsolute:u}}function Js({nodeId:t,dragItems:e,nodeInternals:n}){const r=e.map(s=>({...n.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[t?r.find(s=>s.id===t):r[0],r]}const Fa=(t,e,n,r)=>{const s=e.querySelectorAll(t);if(!s||!s.length)return null;const o=Array.from(s),i=e.getBoundingClientRect(),a={x:i.width*r[0],y:i.height*r[1]};return o.map(c=>{const l=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),position:c.getAttribute("data-handlepos"),x:(l.left-i.left-a.x)/n,y:(l.top-i.top-a.y)/n,...di(c)}})};function vn(t,e,n){return n===void 0?n:r=>{const s=e().nodeInternals.get(t);s&&n(r,{...s})}}function Co({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:a,onError:c}=e.getState(),l=a.get(t);if(!l){c==null||c("012",St.error012(t));return}e.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&i)&&(o({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):s([t])}function ix(){const t=ht();return x.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:o}=t.getState(),i=n.touches?n.touches[0].clientX:n.clientX,a=n.touches?n.touches[0].clientY:n.clientY,c={x:(i-r[0])/r[2],y:(a-r[1])/r[2]};return{xSnapped:o?s[0]*Math.round(c.x/s[0]):c.x,ySnapped:o?s[1]*Math.round(c.y/s[1]):c.y,...c}},[])}function Qs(t){return(e,n,r)=>t==null?void 0:t(e,r)}function Yu({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:i}){const a=ht(),[c,l]=x.useState(!1),u=x.useRef([]),h=x.useRef({x:null,y:null}),d=x.useRef(0),p=x.useRef(null),w=x.useRef({x:0,y:0}),y=x.useRef(null),b=x.useRef(!1),S=x.useRef(!1),k=x.useRef(!1),_=ix();return x.useEffect(()=>{if(t!=null&&t.current){const v=kt(t.current),M=({x:$,y:O})=>{const{nodeInternals:U,onNodeDrag:N,onSelectionDrag:Z,updateNodePositions:Y,nodeExtent:g,snapGrid:A,snapToGrid:R,nodeOrigin:z,onError:B}=a.getState();h.current={x:$,y:O};let P=!1,I={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&g){const F=Si(u.current,z);I=gi(F)}if(u.current=u.current.map(F=>{const X={x:$-F.distance.x,y:O-F.distance.y};R&&(X.x=A[0]*Math.round(X.x/A[0]),X.y=A[1]*Math.round(X.y/A[1]));const V=[[g[0][0],g[0][1]],[g[1][0],g[1][1]]];u.current.length>1&&g&&!F.extent&&(V[0][0]=F.positionAbsolute.x-I.x+g[0][0],V[1][0]=F.positionAbsolute.x+(F.width??0)-I.x2+g[1][0],V[0][1]=F.positionAbsolute.y-I.y+g[0][1],V[1][1]=F.positionAbsolute.y+(F.height??0)-I.y2+g[1][1]);const K=$u(F,X,U,V,z,B);return P=P||F.position.x!==K.position.x||F.position.y!==K.position.y,F.position=K.position,F.positionAbsolute=K.positionAbsolute,F}),!P)return;Y(u.current,!0,!0),l(!0);const q=s?N:Qs(Z);if(q&&y.current){const[F,X]=Js({nodeId:s,dragItems:u.current,nodeInternals:U});q(y.current,F,X)}},C=()=>{if(!p.current)return;const[$,O]=ou(w.current,p.current);if($!==0||O!==0){const{transform:U,panBy:N}=a.getState();h.current.x=(h.current.x??0)-$/U[2],h.current.y=(h.current.y??0)-O/U[2],N({x:$,y:O})&&M(h.current)}d.current=requestAnimationFrame(C)},D=$=>{var z;const{nodeInternals:O,multiSelectionActive:U,nodesDraggable:N,unselectNodesAndEdges:Z,onNodeDragStart:Y,onSelectionDragStart:g}=a.getState();S.current=!0;const A=s?Y:Qs(g);(!i||!o)&&!U&&s&&((z=O.get(s))!=null&&z.selected||Z()),s&&o&&i&&Co({id:s,store:a,nodeRef:t});const R=_($);if(h.current=R,u.current=sx(O,N,R,s),A&&u.current){const[B,P]=Js({nodeId:s,dragItems:u.current,nodeInternals:O});A($.sourceEvent,B,P)}};if(e)v.on(".drag",null);else{const $=qy().on("start",O=>{const{domNode:U,nodeDragThreshold:N}=a.getState();N===0&&D(O),k.current=!1;const Z=_(O);h.current=Z,p.current=(U==null?void 0:U.getBoundingClientRect())||null,w.current=ne(O.sourceEvent,p.current)}).on("drag",O=>{var Y,g;const U=_(O),{autoPanOnNodeDrag:N,nodeDragThreshold:Z}=a.getState();if(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1&&(k.current=!0),!k.current){if(!b.current&&S.current&&N&&(b.current=!0,C()),!S.current){const A=U.xSnapped-(((Y=h==null?void 0:h.current)==null?void 0:Y.x)??0),R=U.ySnapped-(((g=h==null?void 0:h.current)==null?void 0:g.y)??0);Math.sqrt(A*A+R*R)>Z&&D(O)}(h.current.x!==U.xSnapped||h.current.y!==U.ySnapped)&&u.current&&S.current&&(y.current=O.sourceEvent,w.current=ne(O.sourceEvent,p.current),M(U))}}).on("end",O=>{if(!(!S.current||k.current)&&(l(!1),b.current=!1,S.current=!1,cancelAnimationFrame(d.current),u.current)){const{updateNodePositions:U,nodeInternals:N,onNodeDragStop:Z,onSelectionDragStop:Y}=a.getState(),g=s?Z:Qs(Y);if(U(u.current,!1,!1),g){const[A,R]=Js({nodeId:s,dragItems:u.current,nodeInternals:N});g(O.sourceEvent,A,R)}}}).filter(O=>{const U=O.target;return!O.button&&(!n||!qa(U,`.${n}`,t))&&(!r||qa(U,r,t))});return v.call($),()=>{v.on(".drag",null)}}}},[t,e,n,r,o,a,s,i,_]),c}function Bu(){const t=ht();return x.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:i,snapToGrid:a,snapGrid:c,onError:l,nodesDraggable:u}=t.getState(),h=i().filter(k=>k.selected&&(k.draggable||u&&typeof k.draggable>"u")),d=a?c[0]:5,p=a?c[1]:5,w=n.isShiftPressed?4:1,y=n.x*d*w,b=n.y*p*w,S=h.map(k=>{if(k.positionAbsolute){const _={x:k.positionAbsolute.x+y,y:k.positionAbsolute.y+b};a&&(_.x=c[0]*Math.round(_.x/c[0]),_.y=c[1]*Math.round(_.y/c[1]));const{positionAbsolute:v,position:M}=$u(k,_,r,s,void 0,l);k.position=M,k.positionAbsolute=v}return k});o(S,!0,!1)},[])}const Ue={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var bn=t=>{const e=({id:n,type:r,data:s,xPos:o,yPos:i,xPosOrigin:a,yPosOrigin:c,selected:l,onClick:u,onMouseEnter:h,onMouseMove:d,onMouseLeave:p,onContextMenu:w,onDoubleClick:y,style:b,className:S,isDraggable:k,isSelectable:_,isConnectable:v,isFocusable:M,selectNodesOnDrag:C,sourcePosition:D,targetPosition:$,hidden:O,resizeObserver:U,dragHandle:N,zIndex:Z,isParent:Y,noDragClassName:g,noPanClassName:A,initialized:R,disableKeyboardA11y:z,ariaLabel:B,rfId:P,hasHandleBounds:I})=>{const q=ht(),F=x.useRef(null),X=x.useRef(null),V=x.useRef(D),K=x.useRef($),tt=x.useRef(r),et=_||k||u||h||d||p,ot=Bu(),H=vn(n,q.getState,h),G=vn(n,q.getState,d),j=vn(n,q.getState,p),L=vn(n,q.getState,w),it=vn(n,q.getState,y),J=rt=>{const{nodeDragThreshold:W}=q.getState();if(_&&(!C||!k||W>0)&&Co({id:n,store:q,nodeRef:F}),u){const wt=q.getState().nodeInternals.get(n);wt&&u(rt,{...wt})}},nt=rt=>{if(!vo(rt)&&!z)if(au.includes(rt.key)&&_){const W=rt.key==="Escape";Co({id:n,store:q,unselect:W,nodeRef:F})}else k&&l&&Object.prototype.hasOwnProperty.call(Ue,rt.key)&&(q.setState({ariaLiveMessage:`Moved selected node ${rt.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),ot({x:Ue[rt.key].x,y:Ue[rt.key].y,isShiftPressed:rt.shiftKey}))};x.useEffect(()=>()=>{X.current&&(U==null||U.unobserve(X.current),X.current=null)},[]),x.useEffect(()=>{if(F.current&&!O){const rt=F.current;(!R||!I||X.current!==rt)&&(X.current&&(U==null||U.unobserve(X.current)),U==null||U.observe(rt),X.current=rt)}},[O,R,I]),x.useEffect(()=>{const rt=tt.current!==r,W=V.current!==D,wt=K.current!==$;F.current&&(rt||W||wt)&&(rt&&(tt.current=r),W&&(V.current=D),wt&&(K.current=$),q.getState().updateNodeDimensions([{id:n,nodeElement:F.current,forceUpdate:!0}]))},[n,r,D,$]);const at=Yu({nodeRef:F,disabled:O||!k,noDragClassName:g,handleSelector:N,nodeId:n,isSelectable:_,selectNodesOnDrag:C});return O?null:x.createElement("div",{className:vt(["react-flow__node",`react-flow__node-${r}`,{[A]:k},S,{selected:l,selectable:_,parent:Y,dragging:at}]),ref:F,style:{zIndex:Z,transform:`translate(${a}px,${c}px)`,pointerEvents:et?"all":"none",visibility:R?"visible":"hidden",...b},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:H,onMouseMove:G,onMouseLeave:j,onContextMenu:L,onClick:J,onDoubleClick:it,onKeyDown:M?nt:void 0,tabIndex:M?0:void 0,role:M?"button":void 0,"aria-describedby":z?void 0:`${ku}-${P}`,"aria-label":B},x.createElement(Sw,{value:n},x.createElement(t,{id:n,data:s,type:r,xPos:o,yPos:i,selected:l,isConnectable:v,sourcePosition:D,targetPosition:$,dragging:at,dragHandle:N,zIndex:Z})))};return e.displayName="NodeWrapper",x.memo(e)};const ax=t=>{const e=t.getNodes().filter(n=>n.selected);return{...Si(e,t.nodeOrigin),transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`,userSelectionActive:t.userSelectionActive}};function cx({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=ht(),{width:s,height:o,x:i,y:a,transformString:c,userSelectionActive:l}=lt(ax,pt),u=Bu(),h=x.useRef(null);if(x.useEffect(()=>{var w;n||(w=h.current)==null||w.focus({preventScroll:!0})},[n]),Yu({nodeRef:h}),l||!s||!o)return null;const d=t?w=>{const y=r.getState().getNodes().filter(b=>b.selected);t(w,y)}:void 0,p=w=>{Object.prototype.hasOwnProperty.call(Ue,w.key)&&u({x:Ue[w.key].x,y:Ue[w.key].y,isShiftPressed:w.shiftKey})};return x.createElement("div",{className:vt(["react-flow__nodesselection","react-flow__container",e]),style:{transform:c}},x.createElement("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:o,top:a,left:i}}))}var lx=x.memo(cx);const ux=t=>t.nodesSelectionActive,qu=({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:a,onMove:c,onMoveStart:l,onMoveEnd:u,selectionKeyCode:h,selectionOnDrag:d,selectionMode:p,onSelectionStart:w,onSelectionEnd:y,multiSelectionKeyCode:b,panActivationKeyCode:S,zoomActivationKeyCode:k,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:M,panOnScroll:C,panOnScrollSpeed:D,panOnScrollMode:$,zoomOnDoubleClick:O,panOnDrag:U,defaultViewport:N,translateExtent:Z,minZoom:Y,maxZoom:g,preventScrolling:A,onSelectionContextMenu:R,noWheelClassName:z,noPanClassName:B,disableKeyboardA11y:P})=>{const I=lt(ux),q=jn(h),F=jn(S),X=F||U,V=F||C,K=q||d&&X!==!0;return Ww({deleteKeyCode:a,multiSelectionKeyCode:b}),x.createElement(Qw,{onMove:c,onMoveStart:l,onMoveEnd:u,onPaneContextMenu:o,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:M,panOnScroll:V,panOnScrollSpeed:D,panOnScrollMode:$,zoomOnDoubleClick:O,panOnDrag:!q&&X,defaultViewport:N,translateExtent:Z,minZoom:Y,maxZoom:g,zoomActivationKeyCode:k,preventScrolling:A,noWheelClassName:z,noPanClassName:B},x.createElement(Iu,{onSelectionStart:w,onSelectionEnd:y,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:X,isSelecting:!!K,selectionMode:p},t,I&&x.createElement(lx,{onSelectionContextMenu:R,noPanClassName:B,disableKeyboardA11y:P})))};qu.displayName="FlowRenderer";var hx=x.memo(qu);function fx(t){return lt(x.useCallback(n=>t?mu(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[t]))}function dx(t){const e={input:bn(t.input||_u),default:bn(t.default||_o),output:bn(t.output||Pu),group:bn(t.group||bi)},n={},r=Object.keys(t).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=bn(t[o]||_o),s),n);return{...e,...r}}const px=({x:t,y:e,width:n,height:r,origin:s})=>!n||!r?{x:t,y:e}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:t,y:e}:{x:t-n*s[0],y:e-r*s[1]},gx=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError}),Fu=t=>{const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:i}=lt(gx,pt),a=fx(t.onlyRenderVisibleElements),c=x.useRef(),l=x.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(h=>{const d=h.map(p=>({id:p.target.getAttribute("data-id"),nodeElement:p.target,forceUpdate:!0}));o(d)});return c.current=u,u},[]);return x.useEffect(()=>()=>{var u;(u=c==null?void 0:c.current)==null||u.disconnect()},[]),x.createElement("div",{className:"react-flow__nodes",style:Ti},a.map(u=>{var M,C,D;let h=u.type||"default";t.nodeTypes[h]||(i==null||i("003",St.error003(h)),h="default");const d=t.nodeTypes[h]||t.nodeTypes.default,p=!!(u.draggable||e&&typeof u.draggable>"u"),w=!!(u.selectable||s&&typeof u.selectable>"u"),y=!!(u.connectable||n&&typeof u.connectable>"u"),b=!!(u.focusable||r&&typeof u.focusable>"u"),S=t.nodeExtent?pi(u.positionAbsolute,t.nodeExtent):u.positionAbsolute,k=(S==null?void 0:S.x)??0,_=(S==null?void 0:S.y)??0,v=px({x:k,y:_,width:u.width??0,height:u.height??0,origin:t.nodeOrigin});return x.createElement(d,{key:u.id,id:u.id,className:u.className,style:u.style,type:h,data:u.data,sourcePosition:u.sourcePosition||exports.Position.Bottom,targetPosition:u.targetPosition||exports.Position.Top,hidden:u.hidden,xPos:k,yPos:_,xPosOrigin:v.x,yPosOrigin:v.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!u.selected,isDraggable:p,isSelectable:w,isConnectable:y,isFocusable:b,resizeObserver:l,dragHandle:u.dragHandle,zIndex:((M=u[ct])==null?void 0:M.z)??0,isParent:!!((C=u[ct])!=null&&C.isParent),noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!u.width&&!!u.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!((D=u[ct])!=null&&D.handleBounds)})}))};Fu.displayName="NodeRenderer";var mx=x.memo(Fu);const yx=(t,e,n)=>n===exports.Position.Left?t-e:n===exports.Position.Right?t+e:t,wx=(t,e,n)=>n===exports.Position.Top?t-e:n===exports.Position.Bottom?t+e:t,Ua="react-flow__edgeupdater",Za=({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:i,type:a})=>x.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:i,className:vt([Ua,`${Ua}-${a}`]),cx:yx(e,r,t),cy:wx(n,r,t),r,stroke:"transparent",fill:"transparent"}),xx=()=>!0;var De=t=>{const e=({id:n,className:r,type:s,data:o,onClick:i,onEdgeDoubleClick:a,selected:c,animated:l,label:u,labelStyle:h,labelShowBg:d,labelBgStyle:p,labelBgPadding:w,labelBgBorderRadius:y,style:b,source:S,target:k,sourceX:_,sourceY:v,targetX:M,targetY:C,sourcePosition:D,targetPosition:$,elementsSelectable:O,hidden:U,sourceHandleId:N,targetHandleId:Z,onContextMenu:Y,onMouseEnter:g,onMouseMove:A,onMouseLeave:R,reconnectRadius:z,onReconnect:B,onReconnectStart:P,onReconnectEnd:I,markerEnd:q,markerStart:F,rfId:X,ariaLabel:V,isFocusable:K,isReconnectable:tt,pathOptions:et,interactionWidth:ot,disableKeyboardA11y:H})=>{const G=x.useRef(null),[j,L]=x.useState(!1),[it,J]=x.useState(!1),nt=ht(),at=x.useMemo(()=>`url('#${To(F,X)}')`,[F,X]),rt=x.useMemo(()=>`url('#${To(q,X)}')`,[q,X]);if(U)return null;const W=dt=>{var Nt;const{edges:Ct,addSelectedEdges:ae,unselectNodesAndEdges:ce,multiSelectionActive:le}=nt.getState(),qt=Ct.find(dn=>dn.id===n);qt&&(O&&(nt.setState({nodesSelectionActive:!1}),qt.selected&&le?(ce({nodes:[],edges:[qt]}),(Nt=G.current)==null||Nt.blur()):ae([n])),i&&i(dt,qt))},wt=Sn(n,nt.getState,a),se=Sn(n,nt.getState,Y),hn=Sn(n,nt.getState,g),Ee=Sn(n,nt.getState,A),_e=Sn(n,nt.getState,R),Bt=(dt,Ct)=>{if(dt.button!==0)return;const{edges:ae,isValidConnection:ce}=nt.getState(),le=Ct?k:S,qt=(Ct?Z:N)||null,Nt=Ct?"target":"source",dn=ce||xx,Ms=Ct,pn=ae.find(ue=>ue.id===n);J(!0),P==null||P(dt,pn,Nt);const As=ue=>{J(!1),I==null||I(ue,pn,Nt)};vu({event:dt,handleId:qt,nodeId:le,onConnect:ue=>B==null?void 0:B(pn,ue),isTarget:Ms,getState:nt.getState,setState:nt.setState,isValidConnection:dn,edgeUpdaterType:Nt,onReconnectEnd:As})},Ce=dt=>Bt(dt,!0),oe=dt=>Bt(dt,!1),ie=()=>L(!0),Pe=()=>L(!1),Re=!O&&!i,fn=dt=>{var Ct;if(!H&&au.includes(dt.key)&&O){const{unselectNodesAndEdges:ae,addSelectedEdges:ce,edges:le}=nt.getState();dt.key==="Escape"?((Ct=G.current)==null||Ct.blur(),ae({edges:[le.find(Nt=>Nt.id===n)]})):ce([n])}};return x.createElement("g",{className:vt(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:c,animated:l,inactive:Re,updating:j}]),onClick:W,onDoubleClick:wt,onContextMenu:se,onMouseEnter:hn,onMouseMove:Ee,onMouseLeave:_e,onKeyDown:K?fn:void 0,tabIndex:K?0:void 0,role:K?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":V===null?void 0:V||`Edge from ${S} to ${k}`,"aria-describedby":K?`${Mu}-${X}`:void 0,ref:G},!it&&x.createElement(t,{id:n,source:S,target:k,selected:c,animated:l,label:u,labelStyle:h,labelShowBg:d,labelBgStyle:p,labelBgPadding:w,labelBgBorderRadius:y,data:o,style:b,sourceX:_,sourceY:v,targetX:M,targetY:C,sourcePosition:D,targetPosition:$,sourceHandleId:N,targetHandleId:Z,markerStart:at,markerEnd:rt,pathOptions:et,interactionWidth:ot}),tt&&x.createElement(x.Fragment,null,(tt==="source"||tt===!0)&&x.createElement(Za,{position:D,centerX:_,centerY:v,radius:z,onMouseDown:Ce,onMouseEnter:ie,onMouseOut:Pe,type:"source"}),(tt==="target"||tt===!0)&&x.createElement(Za,{position:$,centerX:M,centerY:C,radius:z,onMouseDown:oe,onMouseEnter:ie,onMouseOut:Pe,type:"target"})))};return e.displayName="EdgeWrapper",x.memo(e)};function Sx(t){const e={default:De(t.default||ls),straight:De(t.bezier||wi),step:De(t.step||yi),smoothstep:De(t.step||Ps),simplebezier:De(t.simplebezier||mi)},n={},r=Object.keys(t).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=De(t[o]||ls),s),n);return{...e,...r}}function Ha(t,e,n=null){const r=((n==null?void 0:n.x)||0)+e.x,s=((n==null?void 0:n.y)||0)+e.y,o=(n==null?void 0:n.width)||e.width,i=(n==null?void 0:n.height)||e.height;switch(t){case exports.Position.Top:return{x:r+o/2,y:s};case exports.Position.Right:return{x:r+o,y:s+i/2};case exports.Position.Bottom:return{x:r+o/2,y:s+i};case exports.Position.Left:return{x:r,y:s+i/2}}}function Va(t,e){return t?t.length===1||!e?t[0]:e&&t.find(n=>n.id===e)||null:null}const vx=(t,e,n,r,s,o)=>{const i=Ha(n,t,e),a=Ha(o,r,s);return{sourceX:i.x,sourceY:i.y,targetX:a.x,targetY:a.y}};function bx({sourcePos:t,targetPos:e,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:i,height:a,transform:c}){const l={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x+n,e.x+s),y2:Math.max(t.y+r,e.y+o)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const u=gi({x:(0-c[0])/c[2],y:(0-c[1])/c[2],width:i/c[2],height:a/c[2]}),h=Math.max(0,Math.min(u.x2,l.x2)-Math.max(u.x,l.x)),d=Math.max(0,Math.min(u.y2,l.y2)-Math.max(u.y,l.y));return Math.ceil(h*d)>0}function Xa(t){var r,s,o,i,a;const e=((r=t==null?void 0:t[ct])==null?void 0:r.handleBounds)||null,n=e&&(t==null?void 0:t.width)&&(t==null?void 0:t.height)&&typeof((s=t==null?void 0:t.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((o=t==null?void 0:t.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((i=t==null?void 0:t.positionAbsolute)==null?void 0:i.x)||0,y:((a=t==null?void 0:t.positionAbsolute)==null?void 0:a.y)||0,width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0},e,!!n]}const Tx=[{level:0,isMaxLevel:!0,edges:[]}];function Ex(t,e,n=!1){let r=-1;const s=t.reduce((i,a)=>{var u,h;const c=Et(a.zIndex);let l=c?a.zIndex:0;if(n){const d=e.get(a.target),p=e.get(a.source),w=a.selected||(d==null?void 0:d.selected)||(p==null?void 0:p.selected),y=Math.max(((u=p==null?void 0:p[ct])==null?void 0:u.z)||0,((h=d==null?void 0:d[ct])==null?void 0:h.z)||0,1e3);l=(c?a.zIndex:0)+(w?y:0)}return i[l]?i[l].push(a):i[l]=[a],r=l>r?l:r,i},{}),o=Object.entries(s).map(([i,a])=>{const c=+i;return{edges:a,level:c,isMaxLevel:c===r}});return o.length===0?Tx:o}function _x(t,e,n){const r=lt(x.useCallback(s=>t?s.edges.filter(o=>{const i=e.get(o.source),a=e.get(o.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(a==null?void 0:a.width)&&(a==null?void 0:a.height)&&bx({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:a.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:a.width,targetHeight:a.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[t,e]));return Ex(r,e,n)}const Cx=({color:t="none",strokeWidth:e=1})=>x.createElement("polyline",{style:{stroke:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Px=({color:t="none",strokeWidth:e=1})=>x.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Ga={[cs.Arrow]:Cx,[cs.ArrowClosed]:Px};function Rx(t){const e=ht();return x.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(Ga,t)?Ga[t]:((o=(s=e.getState()).onError)==null||o.call(s,"009",St.error009(t)),null)},[t])}const kx=({id:t,type:e,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{const c=Rx(e);return c?x.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:a,refX:"0",refY:"0"},x.createElement(c,{color:n,strokeWidth:i})):null},Mx=({defaultColor:t,rfId:e})=>n=>{const r=[];return n.edges.reduce((s,o)=>([o.markerStart,o.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const a=To(i,e);r.includes(a)||(s.push({id:a,color:i.color||t,...i}),r.push(a))}}),s),[]).sort((s,o)=>s.id.localeCompare(o.id))},Uu=({defaultColor:t,rfId:e})=>{const n=lt(x.useCallback(Mx({defaultColor:t,rfId:e}),[t,e]),(r,s)=>!(r.length!==s.length||r.some((o,i)=>o.id!==s[i].id)));return x.createElement("defs",null,n.map(r=>x.createElement(kx,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};Uu.displayName="MarkerDefinitions";var Ax=x.memo(Uu);const Nx=t=>({nodesConnectable:t.nodesConnectable,edgesFocusable:t.edgesFocusable,edgesUpdatable:t.edgesUpdatable,elementsSelectable:t.elementsSelectable,width:t.width,height:t.height,connectionMode:t.connectionMode,nodeInternals:t.nodeInternals,onError:t.onError}),Zu=({defaultMarkerColor:t,onlyRenderVisibleElements:e,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,onEdgeDoubleClick:h,onReconnect:d,onReconnectStart:p,onReconnectEnd:w,reconnectRadius:y,children:b,disableKeyboardA11y:S})=>{const{edgesFocusable:k,edgesUpdatable:_,elementsSelectable:v,width:M,height:C,connectionMode:D,nodeInternals:$,onError:O}=lt(Nx,pt),U=_x(e,$,n);return M?x.createElement(x.Fragment,null,U.map(({level:N,edges:Z,isMaxLevel:Y})=>x.createElement("svg",{key:N,style:{zIndex:N},width:M,height:C,className:"react-flow__edges react-flow__container"},Y&&x.createElement(Ax,{defaultColor:t,rfId:r}),x.createElement("g",null,Z.map(g=>{const[A,R,z]=Xa($.get(g.source)),[B,P,I]=Xa($.get(g.target));if(!z||!I)return null;let q=g.type||"default";s[q]||(O==null||O("011",St.error011(q)),q="default");const F=s[q]||s.default,X=D===exports.ConnectionMode.Strict?P.target:(P.target??[]).concat(P.source??[]),V=Va(R.source,g.sourceHandle),K=Va(X,g.targetHandle),tt=(V==null?void 0:V.position)||exports.Position.Bottom,et=(K==null?void 0:K.position)||exports.Position.Top,ot=!!(g.focusable||k&&typeof g.focusable>"u"),H=g.reconnectable||g.updatable,G=typeof d<"u"&&(H||_&&typeof H>"u");if(!V||!K)return O==null||O("008",St.error008(V,g)),null;const{sourceX:j,sourceY:L,targetX:it,targetY:J}=vx(A,V,tt,B,K,et);return x.createElement(F,{key:g.id,id:g.id,className:vt([g.className,o]),type:q,data:g.data,selected:!!g.selected,animated:!!g.animated,hidden:!!g.hidden,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,style:g.style,source:g.source,target:g.target,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerEnd:g.markerEnd,markerStart:g.markerStart,sourceX:j,sourceY:L,targetX:it,targetY:J,sourcePosition:tt,targetPosition:et,elementsSelectable:v,onContextMenu:i,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:u,onEdgeDoubleClick:h,onReconnect:d,onReconnectStart:p,onReconnectEnd:w,reconnectRadius:y,rfId:r,ariaLabel:g.ariaLabel,isFocusable:ot,isReconnectable:G,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth,disableKeyboardA11y:S})})))),b):null};Zu.displayName="EdgeRenderer";var Dx=x.memo(Zu);const Ox=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function zx({children:t}){const e=lt(Ox);return x.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},t)}function Ix(t){const e=Rs(),n=x.useRef(!1);x.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const Lx={[exports.Position.Left]:exports.Position.Right,[exports.Position.Right]:exports.Position.Left,[exports.Position.Top]:exports.Position.Bottom,[exports.Position.Bottom]:exports.Position.Top},Hu=({nodeId:t,handleType:e,style:n,type:r=Jt.Bezier,CustomComponent:s,connectionStatus:o})=>{var C,D,$;const{fromNode:i,handleId:a,toX:c,toY:l,connectionMode:u}=lt(x.useCallback(O=>({fromNode:O.nodeInternals.get(t),handleId:O.connectionHandleId,toX:(O.connectionPosition.x-O.transform[0])/O.transform[2],toY:(O.connectionPosition.y-O.transform[1])/O.transform[2],connectionMode:O.connectionMode}),[t]),pt),h=(C=i==null?void 0:i[ct])==null?void 0:C.handleBounds;let d=h==null?void 0:h[e];if(u===exports.ConnectionMode.Loose&&(d=d||(h==null?void 0:h[e==="source"?"target":"source"])),!i||!d)return null;const p=a?d.find(O=>O.id===a):d[0],w=p?p.x+p.width/2:(i.width??0)/2,y=p?p.y+p.height/2:i.height??0,b=(((D=i.positionAbsolute)==null?void 0:D.x)??0)+w,S=((($=i.positionAbsolute)==null?void 0:$.y)??0)+y,k=p==null?void 0:p.position,_=k?Lx[k]:null;if(!k||!_)return null;if(s)return x.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:i,fromHandle:p,fromX:b,fromY:S,toX:c,toY:l,fromPosition:k,toPosition:_,connectionStatus:o});let v="";const M={sourceX:b,sourceY:S,sourcePosition:k,targetX:c,targetY:l,targetPosition:_};return r===Jt.Bezier?[v]=fu(M):r===Jt.Step?[v]=bo({...M,borderRadius:0}):r===Jt.SmoothStep?[v]=bo(M):r===Jt.SimpleBezier?[v]=hu(M):v=`M${b},${S} ${c},${l}`,x.createElement("path",{d:v,fill:"none",className:"react-flow__connection-path",style:n})};Hu.displayName="ConnectionLine";const $x=t=>({nodeId:t.connectionNodeId,handleType:t.connectionHandleType,nodesConnectable:t.nodesConnectable,connectionStatus:t.connectionStatus,width:t.width,height:t.height});function Yx({containerStyle:t,style:e,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:i,width:a,height:c,connectionStatus:l}=lt($x,pt);return!(s&&o&&a&&i)?null:x.createElement("svg",{style:t,width:a,height:c,className:"react-flow__edges react-flow__connectionline react-flow__container"},x.createElement("g",{className:vt(["react-flow__connection",l])},x.createElement(Hu,{nodeId:s,handleType:o,style:e,type:n,CustomComponent:r,connectionStatus:l})))}function Wa(t,e){const n=x.useRef(null),r=ht();return x.useMemo(()=>{var o,i;if(process.env.NODE_ENV==="development"){const a=Object.keys(t);pt(n.current,a)&&((i=(o=r.getState()).onError)==null||i.call(o,"002",St.error002())),n.current=a}return e(t)},[t])}const Vu=({nodeTypes:t,edgeTypes:e,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:i,onEdgeClick:a,onNodeDoubleClick:c,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:p,onSelectionContextMenu:w,onSelectionStart:y,onSelectionEnd:b,connectionLineType:S,connectionLineStyle:k,connectionLineComponent:_,connectionLineContainerStyle:v,selectionKeyCode:M,selectionOnDrag:C,selectionMode:D,multiSelectionKeyCode:$,panActivationKeyCode:O,zoomActivationKeyCode:U,deleteKeyCode:N,onlyRenderVisibleElements:Z,elementsSelectable:Y,selectNodesOnDrag:g,defaultViewport:A,translateExtent:R,minZoom:z,maxZoom:B,preventScrolling:P,defaultMarkerColor:I,zoomOnScroll:q,zoomOnPinch:F,panOnScroll:X,panOnScrollSpeed:V,panOnScrollMode:K,zoomOnDoubleClick:tt,panOnDrag:et,onPaneClick:ot,onPaneMouseEnter:H,onPaneMouseMove:G,onPaneMouseLeave:j,onPaneScroll:L,onPaneContextMenu:it,onEdgeContextMenu:J,onEdgeMouseEnter:nt,onEdgeMouseMove:at,onEdgeMouseLeave:rt,onReconnect:W,onReconnectStart:wt,onReconnectEnd:se,reconnectRadius:hn,noDragClassName:Ee,noWheelClassName:_e,noPanClassName:Bt,elevateEdgesOnSelect:Ce,disableKeyboardA11y:oe,nodeOrigin:ie,nodeExtent:Pe,rfId:Re})=>{const fn=Wa(t,dx),dt=Wa(e,Sx);return Ix(o),x.createElement(hx,{onPaneClick:ot,onPaneMouseEnter:H,onPaneMouseMove:G,onPaneMouseLeave:j,onPaneContextMenu:it,onPaneScroll:L,deleteKeyCode:N,selectionKeyCode:M,selectionOnDrag:C,selectionMode:D,onSelectionStart:y,onSelectionEnd:b,multiSelectionKeyCode:$,panActivationKeyCode:O,zoomActivationKeyCode:U,elementsSelectable:Y,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:q,zoomOnPinch:F,zoomOnDoubleClick:tt,panOnScroll:X,panOnScrollSpeed:V,panOnScrollMode:K,panOnDrag:et,defaultViewport:A,translateExtent:R,minZoom:z,maxZoom:B,onSelectionContextMenu:w,preventScrolling:P,noDragClassName:Ee,noWheelClassName:_e,noPanClassName:Bt,disableKeyboardA11y:oe},x.createElement(zx,null,x.createElement(Dx,{edgeTypes:dt,onEdgeClick:a,onEdgeDoubleClick:l,onlyRenderVisibleElements:Z,onEdgeContextMenu:J,onEdgeMouseEnter:nt,onEdgeMouseMove:at,onEdgeMouseLeave:rt,onReconnect:W,onReconnectStart:wt,onReconnectEnd:se,reconnectRadius:hn,defaultMarkerColor:I,noPanClassName:Bt,elevateEdgesOnSelect:!!Ce,disableKeyboardA11y:oe,rfId:Re},x.createElement(Yx,{style:k,type:S,component:_,containerStyle:v})),x.createElement("div",{className:"react-flow__edgelabel-renderer"}),x.createElement(mx,{nodeTypes:fn,onNodeClick:i,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:p,selectNodesOnDrag:g,onlyRenderVisibleElements:Z,noPanClassName:Bt,noDragClassName:Ee,disableKeyboardA11y:oe,nodeOrigin:ie,nodeExtent:Pe,rfId:Re})))};Vu.displayName="GraphView";var Bx=x.memo(Vu);const Po=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Kt={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Po,nodeExtent:Po,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:exports.ConnectionMode.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:is,isValidConnection:void 0},qx=()=>Qg((t,e)=>({...Kt,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=e();t({nodeInternals:Ks(n,r,s,o)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=e();t({edges:n.map(s=>({...r,...s}))})},setDefaultNodesAndEdges:(n,r)=>{const s=typeof n<"u",o=typeof r<"u",i=s?Ks(n,new Map,e().nodeOrigin,e().elevateNodesOnSelect):new Map;t({nodeInternals:i,edges:o?r:[],hasDefaultNodes:s,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:o,fitViewOnInitDone:i,fitViewOnInitOptions:a,domNode:c,nodeOrigin:l}=e(),u=c==null?void 0:c.querySelector(".react-flow__viewport");if(!u)return;const h=window.getComputedStyle(u),{m22:d}=new window.DOMMatrixReadOnly(h.transform),p=n.reduce((y,b)=>{const S=s.get(b.id);if(S!=null&&S.hidden)s.set(S.id,{...S,[ct]:{...S[ct],handleBounds:void 0}});else if(S){const k=di(b.nodeElement);!!(k.width&&k.height&&(S.width!==k.width||S.height!==k.height||b.forceUpdate))&&(s.set(S.id,{...S,[ct]:{...S[ct],handleBounds:{source:Fa(".source",b.nodeElement,d,l),target:Fa(".target",b.nodeElement,d,l)}},...k}),y.push({id:S.id,type:"dimensions",dimensions:k}))}return y},[]);Nu(s,l);const w=i||o&&!i&&Du(e,{initial:!0,...a});t({nodeInternals:new Map(s),fitViewOnInitDone:w}),(p==null?void 0:p.length)>0&&(r==null||r(p))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:o}=e(),i=n.map(a=>{const c={id:a.id,type:"position",dragging:s};return r&&(c.positionAbsolute=a.positionAbsolute,c.position=a.position),c});o(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:o,nodeOrigin:i,getNodes:a,elevateNodesOnSelect:c}=e();if(n!=null&&n.length){if(o){const l=zu(n,a()),u=Ks(l,s,i,c);t({nodeInternals:u})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=e();let i,a=null;r?i=n.map(c=>jt(c,!0)):(i=Ie(o(),n),a=Ie(s,[])),xr({changedNodes:i,changedEdges:a,get:e,set:t})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=e();let i,a=null;r?i=n.map(c=>jt(c,!0)):(i=Ie(s,n),a=Ie(o(),[])),xr({changedNodes:a,changedEdges:i,get:e,set:t})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:o}=e(),i=n||o(),a=r||s,c=i.map(u=>(u.selected=!1,jt(u.id,!1))),l=a.map(u=>jt(u.id,!1));xr({changedNodes:c,changedEdges:l,get:e,set:t})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=e();r==null||r.scaleExtent([n,s]),t({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=e();r==null||r.scaleExtent([s,n]),t({maxZoom:n})},setTranslateExtent:n=>{var r;(r=e().d3Zoom)==null||r.translateExtent(n),t({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=e(),o=r().filter(a=>a.selected).map(a=>jt(a.id,!1)),i=n.filter(a=>a.selected).map(a=>jt(a.id,!1));xr({changedNodes:o,changedEdges:i,get:e,set:t})},setNodeExtent:n=>{const{nodeInternals:r}=e();r.forEach(s=>{s.positionAbsolute=pi(s.position,n)}),t({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:o,d3Zoom:i,d3Selection:a,translateExtent:c}=e();if(!i||!a||!n.x&&!n.y)return!1;const l=ee.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[s,o]],h=i==null?void 0:i.constrain()(l,u,c);return i.transform(a,h),r[0]!==h.x||r[1]!==h.y||r[2]!==h.k},cancelConnection:()=>t({connectionNodeId:Kt.connectionNodeId,connectionHandleId:Kt.connectionHandleId,connectionHandleType:Kt.connectionHandleType,connectionStatus:Kt.connectionStatus,connectionStartHandle:Kt.connectionStartHandle,connectionEndHandle:Kt.connectionEndHandle}),reset:()=>t({...Kt})}),Object.is),Ei=({children:t})=>{const e=x.useRef(null);return e.current||(e.current=qx()),x.createElement(iw,{value:e.current},t)};Ei.displayName="ReactFlowProvider";const Xu=({children:t})=>x.useContext(Cs)?x.createElement(x.Fragment,null,t):x.createElement(Ei,null,t);Xu.displayName="ReactFlowWrapper";const Fx={input:_u,default:_o,output:Pu,group:bi},Ux={default:ls,straight:wi,step:yi,smoothstep:Ps,simplebezier:mi},Zx=[0,0],Hx=[15,15],Vx={x:0,y:0,zoom:1},Xx={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Gu=x.forwardRef(({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=Fx,edgeTypes:i=Ux,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:h,onMoveEnd:d,onConnect:p,onConnectStart:w,onConnectEnd:y,onClickConnectStart:b,onClickConnectEnd:S,onNodeMouseEnter:k,onNodeMouseMove:_,onNodeMouseLeave:v,onNodeContextMenu:M,onNodeDoubleClick:C,onNodeDragStart:D,onNodeDrag:$,onNodeDragStop:O,onNodesDelete:U,onEdgesDelete:N,onSelectionChange:Z,onSelectionDragStart:Y,onSelectionDrag:g,onSelectionDragStop:A,onSelectionContextMenu:R,onSelectionStart:z,onSelectionEnd:B,connectionMode:P=exports.ConnectionMode.Strict,connectionLineType:I=Jt.Bezier,connectionLineStyle:q,connectionLineComponent:F,connectionLineContainerStyle:X,deleteKeyCode:V="Backspace",selectionKeyCode:K="Shift",selectionOnDrag:tt=!1,selectionMode:et=exports.SelectionMode.Full,panActivationKeyCode:ot="Space",multiSelectionKeyCode:H=as()?"Meta":"Control",zoomActivationKeyCode:G=as()?"Meta":"Control",snapToGrid:j=!1,snapGrid:L=Hx,onlyRenderVisibleElements:it=!1,selectNodesOnDrag:J=!0,nodesDraggable:nt,nodesConnectable:at,nodesFocusable:rt,nodeOrigin:W=Zx,edgesFocusable:wt,edgesUpdatable:se,elementsSelectable:hn,defaultViewport:Ee=Vx,minZoom:_e=.5,maxZoom:Bt=2,translateExtent:Ce=Po,preventScrolling:oe=!0,nodeExtent:ie,defaultMarkerColor:Pe="#b1b1b7",zoomOnScroll:Re=!0,zoomOnPinch:fn=!0,panOnScroll:dt=!1,panOnScrollSpeed:Ct=.5,panOnScrollMode:ae=pe.Free,zoomOnDoubleClick:ce=!0,panOnDrag:le=!0,onPaneClick:qt,onPaneMouseEnter:Nt,onPaneMouseMove:dn,onPaneMouseLeave:Ms,onPaneScroll:pn,onPaneContextMenu:As,children:Ri,onEdgeContextMenu:ue,onEdgeDoubleClick:dh,onEdgeMouseEnter:ph,onEdgeMouseMove:gh,onEdgeMouseLeave:mh,onEdgeUpdate:yh,onEdgeUpdateStart:wh,onEdgeUpdateEnd:xh,onReconnect:Sh,onReconnectStart:vh,onReconnectEnd:bh,reconnectRadius:Th=10,edgeUpdaterRadius:Eh=10,onNodesChange:_h,onEdgesChange:Ch,noDragClassName:Ph="nodrag",noWheelClassName:Rh="nowheel",noPanClassName:ki="nopan",fitView:kh=!1,fitViewOptions:Mh,connectOnClick:Ah=!0,attributionPosition:Nh,proOptions:Dh,defaultEdgeOptions:Oh,elevateNodesOnSelect:zh=!0,elevateEdgesOnSelect:Ih=!1,disableKeyboardA11y:Mi=!1,autoPanOnConnect:Lh=!0,autoPanOnNodeDrag:$h=!0,connectionRadius:Yh=20,isValidConnection:Bh,onError:qh,style:Fh,id:Ai,nodeDragThreshold:Uh,...Zh},Hh)=>{const Ns=Ai||"1";return x.createElement("div",{...Zh,style:{...Fh,...Xx},ref:Hh,className:vt(["react-flow",s]),"data-testid":"rf__wrapper",id:Ai},x.createElement(Xu,null,x.createElement(Bx,{onInit:l,onMove:u,onMoveStart:h,onMoveEnd:d,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:_,onNodeMouseLeave:v,onNodeContextMenu:M,onNodeDoubleClick:C,nodeTypes:o,edgeTypes:i,connectionLineType:I,connectionLineStyle:q,connectionLineComponent:F,connectionLineContainerStyle:X,selectionKeyCode:K,selectionOnDrag:tt,selectionMode:et,deleteKeyCode:V,multiSelectionKeyCode:H,panActivationKeyCode:ot,zoomActivationKeyCode:G,onlyRenderVisibleElements:it,selectNodesOnDrag:J,defaultViewport:Ee,translateExtent:Ce,minZoom:_e,maxZoom:Bt,preventScrolling:oe,zoomOnScroll:Re,zoomOnPinch:fn,zoomOnDoubleClick:ce,panOnScroll:dt,panOnScrollSpeed:Ct,panOnScrollMode:ae,panOnDrag:le,onPaneClick:qt,onPaneMouseEnter:Nt,onPaneMouseMove:dn,onPaneMouseLeave:Ms,onPaneScroll:pn,onPaneContextMenu:As,onSelectionContextMenu:R,onSelectionStart:z,onSelectionEnd:B,onEdgeContextMenu:ue,onEdgeDoubleClick:dh,onEdgeMouseEnter:ph,onEdgeMouseMove:gh,onEdgeMouseLeave:mh,onReconnect:Sh??yh,onReconnectStart:vh??wh,onReconnectEnd:bh??xh,reconnectRadius:Th??Eh,defaultMarkerColor:Pe,noDragClassName:Ph,noWheelClassName:Rh,noPanClassName:ki,elevateEdgesOnSelect:Ih,rfId:Ns,disableKeyboardA11y:Mi,nodeOrigin:W,nodeExtent:ie}),x.createElement(Lw,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:w,onConnectEnd:y,onClickConnectStart:b,onClickConnectEnd:S,nodesDraggable:nt,nodesConnectable:at,nodesFocusable:rt,edgesFocusable:wt,edgesUpdatable:se,elementsSelectable:hn,elevateNodesOnSelect:zh,minZoom:_e,maxZoom:Bt,nodeExtent:ie,onNodesChange:_h,onEdgesChange:Ch,snapToGrid:j,snapGrid:L,connectionMode:P,translateExtent:Ce,connectOnClick:Ah,defaultEdgeOptions:Oh,fitView:kh,fitViewOptions:Mh,onNodesDelete:U,onEdgesDelete:N,onNodeDragStart:D,onNodeDrag:$,onNodeDragStop:O,onSelectionDrag:g,onSelectionDragStart:Y,onSelectionDragStop:A,noPanClassName:ki,nodeOrigin:W,rfId:Ns,autoPanOnConnect:Lh,autoPanOnNodeDrag:$h,onError:qh,connectionRadius:Yh,isValidConnection:Bh,nodeDragThreshold:Uh}),x.createElement(zw,{onSelectionChange:Z}),Ri,x.createElement(lw,{proOptions:Dh,position:Nh}),x.createElement(Fw,{rfId:Ns,disableKeyboardA11y:Mi})))});Gu.displayName="ReactFlow";function Gx(){const t=ht();return x.useCallback(e=>{const{domNode:n,updateNodeDimensions:r}=t.getState(),o=(Array.isArray(e)?e:[e]).reduce((i,a)=>{const c=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);return c&&i.push({id:a,nodeElement:c,forceUpdate:!0}),i},[]);requestAnimationFrame(()=>r(o))},[])}function Wx({onStart:t,onChange:e,onEnd:n}){const r=ht();x.useEffect(()=>{r.setState({onViewportChangeStart:t})},[t]),x.useEffect(()=>{r.setState({onViewportChange:e})},[e]),x.useEffect(()=>{r.setState({onViewportChangeEnd:n})},[n])}const Kx=({sourcePos:t,targetPos:e,next:n,prev:r})=>{const s=_n(t,...n);return f.q.distance(s,e)<1?!0:(console.warn("Connector is out of sync with target"),console.log("Theoretical target",s),console.log("Actual target",e),console.log("Segments",n),console.log("Prev segments",r),!1)},Ka=({sourceStumpTip:t,sourceOrientation:e,sourceBox:n,targetStumpTip:r,targetOrientation:s,targetBox:o})=>{if(!Jx({sourcePos:t,sourceOrientation:e,targetPos:r}))return;const i=f.g.construct(e),a=f.g.swap(i);let c=me(a,r[a]-t[a]);const l=f.To.loc(n,c);if(f.J.swap(e)===s){const u=f.To.loc(o,f.J.swap(c));Math.abs(l-u)<bt&&(c=f.J.swap(c))}return{direction:a,length:l-t[a]+Se(c,bt)}},Ro=T.z.object({direction:f.g.direction,length:T.z.number()}),_n=(t,...e)=>{let n=t;for(const r of e)n=f.q.translate(n,r.direction,r.length);return n},jx=(t,e,n,r)=>{try{let s=t;const o=[t,...e.map(p=>(s=f.q.translate(s,p.direction,p.length),s))];if(!r)return o;const i=e[0],a=me(i.direction,i.length),c=ja(a),l=4*(2-n**.5);o[0]=f.q.translate(o[0],{[i.direction]:-1*c*l,[f.g.swap(i.direction)]:0});const u=e[e.length-1],h=me(u.direction,u.length),d=ja(h);return o[o.length-1]=f.q.translate(o[o.length-1],{[u.direction]:d*l,[f.g.swap(u.direction)]:0}),o}catch{return[]}},bt=10,ja=t=>t==="top"||t==="left"?-1:1,Se=(t,e)=>t==="top"||t==="left"?-e:e,me=(t,e)=>t==="x"?e>0?"right":"left":e>0?"bottom":"top",te=t=>me(t.direction,t.length),Jx=({sourcePos:t,targetPos:e,sourceOrientation:n})=>{const r=f.g.construct(n),s=e[r]-t[r];return Se(n,s)<0},vr=t=>({direction:f.g.construct(t),length:Se(t,bt)}),Ja={top:vr("top"),bottom:vr("bottom"),left:vr("left"),right:vr("right")},Qx=4,tS=.25,ks=t=>ko(eS(ko(t))),eS=t=>{const e=[...t],n=t.findIndex((r,s)=>{const o=Math.abs(r.length);if(o<Qx){if(o<tS)return!0;if(s===0||s===t.length-1||t.length<=3)return!1;if(s+2<t.length){const i=e[s+2];if(i.direction!==r.direction)return!1;e[s+2]={...i,length:i.length+r.length}}else{const i=e[s-2];if(i.direction!==r.direction)return!1;e[s-2]={...i,length:i.length+r.length}}return!0}return!1});return n!==-1&&e.splice(n,1),e},ko=t=>{const e=[...t];return t.findIndex((r,s)=>{const o=e[s-1];if(s===0||r.direction!==o.direction)return!1;if(s===1){const i=s-1,a=s,c=te(o),l=te(r);if(c===l)return e[s-1]={direction:e[s-1].direction,length:e[s-1].length+e[s].length},e.splice(s,1),!0;if(Math.abs(o.length)===bt)return!1;const u=Se(c,bt),h=e[i].length-u,d=e[a].length+h;return Math.abs(d)<bt?!1:(e[i]={...e[i],length:u},e[a]={...e[a],length:d},!0)}if(s===t.length-1){const i=s,a=s-1,c=te(r),l=te(o);if(c===l)return e[s-1]={direction:e[s-1].direction,length:e[s-1].length+e[s].length},e.splice(s,1),!0;if(Math.abs(r.length)===bt)return!1;const u=Se(c,bt),h=e[i].length-u,d=e[a].length+h;return Math.abs(d)<bt?!1:(e[i]={...e[i],length:u},e[a]={...e[a],length:d},!0)}return e[s-1]={direction:e[s-1].direction,length:e[s-1].length+e[s].length},e.splice(s,1),!0})!==-1?ko(e):e},nS=t=>ks(rS(t)),rS=({sourceBox:t,targetBox:e,sourcePos:n,targetPos:r,targetOrientation:s,sourceOrientation:o})=>{let i=o,a=s,c={...Ja[o]},l=_n(n,c);const u={...Ja[s]};let h=_n(r,u);const d=[c],p=Ka({sourceStumpTip:l,sourceOrientation:o,sourceBox:t,targetStumpTip:h,targetOrientation:s,targetBox:e});p!=null&&(d.push(p),l=_n(l,p),i=te(p),c=p);const w=Ka({sourceStumpTip:h,sourceOrientation:a,sourceBox:e,targetStumpTip:l,targetOrientation:i,targetBox:t});w!=null&&(h=_n(h,w),a=me(w.direction,w.length));const y=()=>{w!=null&&(w.length*=-1,d.push(w)),u.length*=-1,d.push(u)};if(f.J.swap(i)===s){const M=f.g.construct(i),C=(h[M]-l[M])/2;d.push({direction:M,length:C});const D=f.g.swap(M);return d.push({direction:D,length:h[D]-l[D]}),d.push({direction:M,length:C}),y(),d}const b=h[c.direction]-l[c.direction];let S=f.g.swap(c.direction);const k=l[S]-h[S];let _;me(c.direction,b)===i&&me(S,k)===a?_={direction:c.direction,length:b}:(_={direction:S,length:h[S]-l[S]},S=f.g.swap(S)),d.push(_);const v={direction:S,length:h[S]-l[S]};return d.push(v),y(),d},sS=t=>ks(oS(t)),oS=({segments:t,index:e,magnitude:n})=>{const r=[...t],s=r[e],o=f.g.swap(s.direction),i=te(s);if(e===0){r.unshift({direction:o,length:n});const a=Se(i,bt);r.unshift({direction:s.direction,length:a}),e+=2,r[e]={...r[e],length:r[e].length-a}}else r[e-1]={direction:r[e-1].direction,length:r[e-1].length+n};if(e===r.length-1){r.push({direction:o,length:-n});const a=Se(i,bt);r.push({direction:s.direction,length:a}),r[e]={...r[e],length:r[e].length-a}}else r[e+1]={direction:r[e+1].direction,length:r[e+1].length-n};return r},iS=(t,e)=>{for(let n=t.length-1;n>=0;n--)if(e(t[n],n))return n;return-1},aS=(t,e,n=!1,...r)=>{const s=(o,i)=>!r.includes(i)&&e(o,i);return n?iS(t,s):t.findIndex(s)},cS=({delta:t,segments:e})=>ks(Wu(t,e,!1)),lS=({delta:t,segments:e})=>ks(Wu(t,e,!0)),Wu=(t,e,n)=>{let r=[...e];return t.x!==0&&(r=tc("x",t,r,n)),t.y!==0&&(r=tc("y",t,r,n)),r},Qa=(t,e,n)=>{if(e.direction!==t)return!1;const r={...e,length:e.length-n[t]},s=te(e),o=te(r);return Math.abs(r.length)>bt&&s===o},tc=(t,e,n,r)=>{const s=f.g.swap(t),o=r?n.length-1:0,i=n[o];if(Qa(t,i,e))return n[o]={...i,length:i.length-e[t]},n;const a=r?0:n.length-1,l=aS(n,h=>h.direction===t,r,o);if(l===a){const h=n[a];return Qa(t,h,e)?(n[a]={...h,length:h.length-e[t]},n):(i.direction===t?n[o]={...i,length:i.length-e[t]}:n[a]={...h,length:h.length-e[t]},n)}if(l===-1)return n.length===1?n[0].direction===t?[{direction:t,length:n[0].length-e[t]}]:[{direction:s,length:n[0].length/2},{direction:t,length:-e[t]},{direction:s,length:n[0].length/2}]:i.direction===t?(n[o]={...i,length:i.length-e[t]},n):[{direction:s,length:n[0].length},{direction:t,length:-e[t]},...n.slice(1)];const u=n[l];return n[l]={...u,length:u.length-e[t]},n},uS=T.z.object({position:f.q.xy,zoom:T.z.number()}),Ku=T.z.object({color:f.crudeZ,segments:T.z.array(Ro)}),hS=Ku.extend({key:T.z.string(),source:T.z.string(),target:T.z.string(),segments:T.z.array(Ro),color:f.crudeZ,id:T.z.string(),data:T.z.object({segments:T.z.array(Ro),color:f.crudeZ}).optional(),selected:T.z.boolean(),sourceHandle:T.z.string().nullable().optional(),targetHandle:T.z.string().nullable().optional()}),fS=T.z.object({key:T.z.string(),position:f.q.xy,selected:T.z.boolean().optional(),zIndex:T.z.number().optional(),id:T.z.string().optional(),type:T.z.string().optional(),data:T.z.unknown().optional(),width:T.z.number().optional().nullable(),height:T.z.number().optional().nullable()}),ju=t=>t.map(e=>({...e,id:e.key,type:"custom",zIndex:8,data:{}})),Ju=t=>t.map(({segments:e,color:n,...r})=>({...r,id:r.key,data:{segments:e,color:n}})),Qu=t=>t.map(e=>({key:e.id,selected:e.selected,...e})),th=(t,e)=>t.map(n=>{var r,s;return n.data==null&&(n.data={segments:[],color:e}),{key:n.id,segments:((r=n.data)==null?void 0:r.segments)??[],selected:n.selected??!1,color:((s=n.data)==null?void 0:s.color)??e,...n}}),dS=t=>({...t.position,zoom:t.zoom}),eh=t=>({position:f.q.construct(t),zoom:t.zoom}),pS=(t,e)=>Qu(e(ju(t))),gS=(t,e,n)=>th(e(Ju(t)),n),_i=T.z.object({position:f.q.xy,zoom:T.z.number(),region:f.To.box,clearOverScan:f.q.crudeZ.optional().default(10)}),to=["upper2d","lower2d"],nh=()=>{const t=Rs();return x.useRef(eh(t.getViewport())).current},Ye=class Ye extends E.Composite{constructor(){super(...arguments);m(this,"eraser",new oi);m(this,"schema",Ye.stateZ)}async afterUpdate(){this.internal.renderCtx=gt.use(this.ctx),this.internal.addStatus=E.useAggregate(this.ctx),mt.control(this.ctx,()=>this.requestRender("low")),this.requestRender("high")}async afterDelete(){this.requestRender("high")}async render(){if(this.deleted)return;const{renderCtx:n,addStatus:r}=this.internal,{zoom:s,position:o}=this.state,i=f.To.construct(this.state.region),a=n.scissor(i,f.q.ZERO,to),c=f.k.XY.magnify(f.q.construct(s)).translate(f.To.topLeft(i)).translate(o);try{await Promise.all(this.children.map(async u=>await u.render({viewportScale:c})))}catch(u){r({variant:"error",message:u.message})}finally{a()}const l=f.To.copy(this.state.region);return async()=>{this.internal.renderCtx.erase(l,this.state.clearOverScan,...to)}}requestRender(n){const{renderCtx:r}=this.internal;r.loop.set({key:`${Ye.TYPE}-${this.key}`,render:async()=>await this.render(),priority:n,canvases:to})}};m(Ye,"TYPE","Diagram"),m(Ye,"stateZ",_i);let on=Ye;const rh={[on.TYPE]:on},mS=Object.freeze(Object.defineProperty({__proto__:null,Diagram:on,REGISTRY:rh,diagramStateZ:_i,useInitialViewport:nh},Symbol.toStringTag,{value:"Module"})),sh=T.z.object({region:f.To.box,enabled:T.z.boolean().optional().default(!1)});class us extends E.Leaf{constructor(){super(...arguments);m(this,"schema",sh);m(this,"eraser",new oi)}async afterUpdate(){this.deleted||(this.internal.render=gt.use(this.ctx),await this.internal.render.loop.set({key:`${this.type}-${this.key}`,render:this.render.bind(this),priority:"high",canvases:["gl","lower2d","upper2d"]}))}async afterDelete(){await this.internal.render.loop.set({key:`${this.type}-${this.key}`,render:this.render.bind(this),priority:"high",canvases:["gl","lower2d","upper2d"]})}async render(){this.deleted||!this.state.enabled||this.internal.render.erase(this.state.region,f.q.construct(0),"gl","lower2d","upper2d")}}m(us,"TYPE","eraser");const yS={[us.TYPE]:us},oh=T.z.object({enabled:T.z.boolean(),source:zo.optional().default(Do)});class hs extends E.Leaf{constructor(){super(...arguments);m(this,"schema",oh)}async afterUpdate(){var s;this.internal.addStatus=E.useOptionalAggregate(this.ctx);const{source:n}=this.state,{internal:r}=this;this.internal.source=await Lt(this.ctx,n,this.internal.source),await this.updateEnabledState(),(s=r.stopListening)==null||s.call(r),r.stopListening=r.source.onChange(()=>this.updateEnabledState().catch(this.reportError.bind(this)))}reportError(n){this.internal.addStatus({key:this.key,variant:"error",message:`Failed to update Light: ${n.message}`})}async updateEnabledState(){const n=await this.internal.source.value();n!==this.state.enabled&&this.setState(r=>({...r,enabled:n}))}async afterDelete(){await this.internalAfterDelete()}async internalAfterDelete(){var n,r;this.internal.stopListening(),await((r=(n=this.internal.source).cleanup)==null?void 0:r.call(n))}async render(){}}m(hs,"TYPE","Light");const wS={[hs.TYPE]:hs},Ci=T.z.object({position:f.q.xy.or(T.z.null()),textColor:f.Color.z.optional().default(f.ZERO),backgroundColor:f.Color.z.optional().default(f.ZERO),borderColor:f.Color.z.optional().default(f.ZERO),ruleColor:f.Color.z.optional().default(f.ZERO),ruleStrokeWidth:T.z.number().optional().default(1),ruleStrokeDash:T.z.number().default(0)});class an extends E.Leaf{constructor(){super(...arguments);m(this,"schema",Ci)}async afterUpdate(){const n=E.use(this.ctx);this.state.textColor.isZero&&(this.state.textColor=n.colors.text),this.state.backgroundColor.isZero&&(this.state.backgroundColor=n.colors.gray.l1),this.state.borderColor.isZero&&(this.state.borderColor=n.colors.border),this.state.ruleColor.isZero&&(this.state.ruleColor=n.colors.gray.l5),this.internal.dotColor=n.colors.text,this.internal.dotColorContrast=n.colors.textInverted,this.internal.render=gt.use(this.ctx),this.internal.draw=new cr(this.internal.render.upper2d,n),mt.requestRender(this.ctx,Gt)}async afterDelete(){mt.requestRender(this.ctx,Gt)}async render(n){if(this.deleted||this.state.position==null)return;const{region:r}=n,s=f.k.XY.scale(f.To.DECIMAL).scale(r),o=f.k.XY.scale(r).scale(f.To.DECIMAL),i=await n.findByXDecimal(o.x.pos(this.state.position.x)),a=i.filter(w=>f.q.isFinite(w.value)),{draw:c}=this.internal,l=a.reduce((w,y)=>w+y.position.x,0)/a.length,u=new E.m(a.reduce((w,y)=>w+y.value.x,0)/a.length),h=s.x.pos(l);if(!f.R.contains(f.To.xBounds(r),h))return;c.rule({stroke:this.state.ruleColor,lineWidth:this.state.ruleStrokeWidth,lineDash:this.state.ruleStrokeDash,direction:"y",region:r,position:h}),a.forEach(w=>{const y=s.pos(w.position);c.circle({fill:w.color.setAlpha(.5),radius:8,position:y}),c.circle({fill:w.color.setAlpha(.8),radius:5,position:y}),c.circle({fill:w.color.pickByContrast(this.internal.dotColor,this.internal.dotColorContrast),radius:2,position:y})});const d=i.map(w=>`${w.label??""}: ${w.value.y.toFixed(2)}`);d.unshift(`Time: ${u.fString("preciseDate","local")}`);const p=o.pos(this.state.position);c.textContainer({text:d,backgroundColor:this.state.backgroundColor,borderColor:this.state.borderColor,position:this.state.position,direction:"y",level:"small",spacing:.5,offset:{x:12,y:12},root:{x:p.x>.8?"right":"left",y:p.y>.8?"top":"bottom"}})}}m(an,"TYPE","tooltip");const ih={[an.TYPE]:an},xS=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:ih,Tooltip:an,tooltipStateZ:Ci},Symbol.toStringTag,{value:"Module"})),Pi=T.z.object({one:f.q.xy.nullable(),two:f.q.xy.nullable(),hover:f.q.xy.nullable(),color:T.z.union([f.Color.z,T.z.object({verticalLine:f.Color.z.optional().default(f.ZERO),horizontalLine:f.Color.z.optional().default(f.ZERO),obliqueLine:f.Color.z.optional().default(f.ZERO)})]).optional().default(f.ZERO),strokeWidth:T.z.number().optional().default(1),strokeDash:T.z.number().optional().default(2)});class cn extends E.Leaf{constructor(){super(...arguments);m(this,"schema",Pi)}async afterUpdate(){const n=gt.use(this.ctx);this.internal.theme=E.use(this.ctx),this.internal.render=n,this.internal.draw=new cr(n.upper2d,this.internal.theme),mt.requestRender(this.ctx,Gt)}async afterDelete(){mt.requestRender(this.ctx,$t)}get verticalLineColor(){return this.state.color instanceof f.Color?this.state.color.isZero?this.internal.theme.colors.gray.l6:this.state.color:this.state.color.verticalLine.isZero?this.internal.theme.colors.gray.l6:this.state.color.verticalLine}get horizontalLineColor(){return this.state.color instanceof f.Color?this.state.color.isZero?this.internal.theme.colors.gray.l6:this.state.color:this.state.color.horizontalLine.isZero?this.internal.theme.colors.gray.l6:this.state.color.horizontalLine}get obliqueLineColor(){return this.state.color instanceof f.Color?this.state.color.isZero?this.internal.theme.colors.gray.l6:this.state.color:this.state.color.obliqueLine.isZero?this.internal.theme.colors.gray.l6:this.state.color.obliqueLine}async find(n){const{one:r,two:s}=this.state;if(r==null||s==null)return null;const{one:o,two:i}=this.prevState,{dataOne:a,dataTwo:c}=this.internal;if(o!=null&&f.q.equals(r,o)&&i!=null&&f.q.equals(s,i)&&a!=null&&c!=null){const[b,S]=[await n.findByXValue(a.x),await n.findByXValue(c.x)];return b.length===0||S.length===0?null:[b.sort((k,_)=>f.q.distance(a,k.value)-f.q.distance(a,_.value))[0],S.sort((k,_)=>f.q.distance(c,k.value)-f.q.distance(c,_.value))[0]]}const l=f.k.XY.scale(n.region).scale(f.To.DECIMAL),[u,h]=[l.pos(r),l.pos(s)],[d,p]=[await n.findByXDecimal(u.x),await n.findByXDecimal(h.x)];if(d.length===0||p.length===0)return null;const[w,y]=[d.sort((b,S)=>f.q.distance(u,b.position)-f.q.distance(u,S.position))[0],p.sort((b,S)=>f.q.distance(h,b.position)-f.q.distance(h,S.position))[0]];return this.internal.dataOne=w.value,this.internal.dataTwo=y.value,[w,y]}async renderHover(n){if(this.state.hover==null)return;const r=this.state.hover,s=f.k.XY.scale(n.region).scale(f.To.DECIMAL),o=s.pos(r),i=await n.findByXDecimal(s.pos(r).x);if(i.length===0)return;const a=i.sort((l,u)=>f.q.distance(o,l.position)-f.q.distance(o,u.position))[0],{draw:c}=this.internal;c.circle({fill:a.color.setAlpha(.5),radius:9,position:s.reverse().pos(a.position)})}async render(n){if(this.deleted)return;await this.renderHover(n);const r=await this.find(n);if(r==null)return;const[s,o]=r,{draw:i}=this.internal,{strokeDash:a,strokeWidth:c}=this.state,l=f.k.XY.scale(f.To.DECIMAL).scale(n.region),u=l.pos(s.position),h=l.pos(o.position),d=new E.w(Math.abs(s.value.x-o.value.x)),p=Math.abs(s.value.y-o.value.y),w=p/d.seconds;i.line({start:f.q.construct(u.x,u.y),end:f.q.construct(u.x,h.y),stroke:this.verticalLineColor,lineDash:a,lineWidth:c}),i.textContainer({text:[`${p.toFixed(2)} ${s.units??""}`],direction:"x",position:f.q.construct(u.x,(u.y+h.y)/2),level:"small"}),i.line({start:f.q.construct(u.x,h.y),end:f.q.construct(h.x,h.y),stroke:this.horizontalLineColor,lineDash:a,lineWidth:c}),i.textContainer({text:[d.truncate(E.w.MILLISECOND).toString()],direction:"x",position:f.q.construct((u.x+h.x)/2,h.y),level:"small"}),i.line({start:f.q.construct(u.x,u.y),end:f.q.construct(h.x,h.y),stroke:this.obliqueLineColor,lineDash:a,lineWidth:c}),i.textContainer({text:[`${w.toFixed(2)} ${s.units??""} / S`],direction:"x",position:f.q.construct((u.x+h.x)/2,(u.y+h.y)/2),level:"small"}),i.circle({fill:s.color.setAlpha(.5),radius:8,position:u}),i.circle({fill:s.color.setAlpha(.8),radius:5,position:u}),i.circle({fill:new f.Color("#ffffff"),radius:2,position:u}),i.circle({fill:o.color.setAlpha(.5),radius:8,position:h}),i.circle({fill:o.color.setAlpha(.8),radius:5,position:h}),i.circle({fill:new f.Color("#ffffff"),radius:2,position:h})}}m(cn,"TYPE","measure");const ah={[cn.TYPE]:cn},SS=Object.freeze(Object.defineProperty({__proto__:null,Measure:cn,REGISTRY:ah,measureStateZ:Pi},Symbol.toStringTag,{value:"Module"})),ch=T.z.object({trigger:T.z.number(),command:T.z.number().optional(),value:T.z.number(),sink:pc.optional().default(ic),source:dc.optional().default(ac)});class fs extends E.Leaf{constructor(){super(...arguments);m(this,"schema",ch)}async afterUpdate(){var c;this.internal.addStatus=E.useOptionalAggregate(this.ctx);const{sink:n,source:r,trigger:s,command:o}=this.state,{trigger:i}=this.prevState,{internal:a}=this;this.internal.source=await Lt(this.ctx,r,this.internal.source),a.sink=await er(this.ctx,n,a.sink),s!==i&&o!=null&&this.internal.sink.set(o),await this.updateValue(),(c=a.stopListening)==null||c.call(a),a.stopListening=a.source.onChange(()=>{this.updateValue().catch(this.reportError.bind(this))})}reportError(n){this.internal.addStatus({key:this.key,variant:"error",message:`Failed to update Setpoint: ${n.message}`})}async updateValue(){const n=await this.internal.source.value();n!==this.state.value&&this.setState(r=>({...r,value:n,triggered:!1}))}async afterDelete(){await this.internalAfterDelete()}async internalAfterDelete(){var n,r,s,o;this.internal.stopListening(),await((r=(n=this.internal.source).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.sink).cleanup)==null?void 0:o.call(s))}async render(){}}m(fs,"TYPE","Setpoint");const vS={[fs.TYPE]:fs},lh=T.z.object({triggered:T.z.boolean(),enabled:T.z.boolean(),sink:ws.optional().default(ms),source:zo.optional().default(Do)});class ds extends E.Leaf{constructor(){super(...arguments);m(this,"schema",lh)}async afterUpdate(){var c;this.internal.addStatus=E.useOptionalAggregate(this.ctx);const{sink:n,source:r,triggered:s,enabled:o}=this.state,{triggered:i}=this.prevState,{internal:a}=this;this.internal.source=await Lt(this.ctx,r,this.internal.source),a.sink=await er(this.ctx,n,a.sink),s&&!i&&await a.sink.set(!o),await this.updateEnabledState(),(c=a.stopListening)==null||c.call(a),a.stopListening=a.source.onChange(()=>{this.updateEnabledState().catch(this.reportError.bind(this))})}reportError(n){this.internal.addStatus({key:this.key,variant:"error",message:`Failed to update Toggle: ${n.message}`})}async updateEnabledState(){const n=await this.internal.source.value();n!==this.state.enabled&&this.setState(r=>({...r,enabled:n,triggered:!1}))}async afterDelete(){await this.internalAfterDelete()}async internalAfterDelete(){var n,r,s,o;this.internal.stopListening(),await((r=(n=this.internal.source).cleanup)==null?void 0:r.call(n)),await((o=(s=this.internal.sink).cleanup)==null?void 0:o.call(s))}async render(){}}m(ds,"TYPE","Toggle");const bS={[ds.TYPE]:ds},TS=T.z.object({box:f.To.box,telem:mc.optional().default(cc),font:E.levelZ.optional().default("p"),color:f.Color.z.optional().default(f.ZERO),precision:T.z.number().optional().default(2),minWidth:T.z.number().optional().default(60),width:T.z.number().optional()}),An=class An extends E.Leaf{constructor(){super(...arguments);m(this,"schema",An.z)}async afterUpdate(){const{internal:n}=this;n.render=gt.use(this.ctx),n.theme=E.use(this.ctx),this.state.color.isZero?this.internal.textColor=n.theme.colors.gray.l8:n.textColor=this.state.color,n.telem=await Lt(this.ctx,this.state.telem,n.telem),this.internal.telem.onChange(()=>this.requestRender()),this.internal.requestRender=mt.useOptionalRequest(this.ctx),this.requestRender()}async afterDelete(){var o;const{requestRender:n,telem:r,render:s}=this.internal;await((o=r.cleanup)==null?void 0:o.call(r)),n==null?s.erase(f.To.construct(this.state.box),f.q.ZERO,"upper2d"):n($t)}requestRender(){const{requestRender:n}=this.internal;n!=null?n($t):this.render({})}async render({viewportScale:n=f.k.XY.IDENTITY}){const{render:r,telem:s,theme:o}=this.internal,i=f.To.construct(this.state.box);if(f.To.areaIsZero(i))return;const a=r.upper2d.applyScale(n),c=await s.value();a.font=this.state.font;const l=o.typography[this.state.font].size*o.sizes.base,u=E.dimensions(c,E.fontString(this.internal.theme,this.state.font),a).width;this.internal.requestRender==null&&r.erase(f.To.construct(this.prevState.box));const h=u+o.sizes.base*4;(this.state.width==null||this.state.width<h||this.state.minWidth>h&&this.state.width!==this.state.minWidth)&&this.setState(p=>({...p,width:Math.max(h,p.minWidth)}));const d=f.q.couple(f.q.translate(f.To.topLeft(i),{x:0,y:f.To.height(i)/2},{y:l/2,x:12}));a.fillStyle=this.internal.textColor.hex,a.fillText(c,...d)}};m(An,"TYPE","value"),m(An,"z",TS);let ln=An;const uh={[ln.TYPE]:ln},ES=Object.freeze(Object.defineProperty({__proto__:null,REGISTRY:uh,Value:ln},Symbol.toStringTag,{value:"Module"})),_S=E.vd.payloadZ.extend({viewport:f.R.bounds}),ec=t=>f.Color.z.safeParse(t).success,hh=T.z.object({cursor:f.q.xy.or(T.z.null()),hovered:_S.or(T.z.null()),count:T.z.number()});class Jn extends E.Leaf{constructor(){super(...arguments);m(this,"schema",hh);m(this,"fetchedInitial",E.U.ZERO)}async afterUpdate(){const{internal:n}=this;n.render=gt.use(this.ctx),n.draw=new cr(n.render.upper2d,E.use(this.ctx)),n.ranges==null&&(n.ranges=new Map);const r=tr(this.ctx);r!=null&&(n.client=r,n.tracker==null&&(n.tracker=await n.client.ranges.openTracker(),n.tracker.onChange(async s=>{s.forEach(async o=>{o.variant==="delete"?n.ranges.delete(o.key):ec(o.value.color)&&n.ranges.set(o.key,o.value)}),mt.requestRender(this.ctx,Gt),this.setState(o=>({...o,count:n.ranges.size}))}),mt.requestRender(this.ctx,Gt)))}async fetchInitial(n){const{internal:r}=this;if(r.client==null||this.fetchedInitial.roughlyEquals(n,E.w.minutes(1)))return;this.fetchedInitial=n,(await r.client.ranges.retrieve(n)).forEach(o=>{ec(o.color)&&r.ranges.set(o.key,o)}),this.setState(o=>({...o,count:r.ranges.size}))}async render(n){const{dataToDecimalScale:r,region:s,viewport:o,timeRange:i}=n;await this.fetchInitial(i);const{draw:a,ranges:c}=this.internal,l=r.scale(f.To.xBounds(s)),u=this.state.cursor==null?null:this.state.cursor.x;let h=null;const d=a.canvas.scissor(f.To.construct({x:f.To.left(s),y:f.To.top(s)-35},{x:f.To.right(s),y:f.To.bottom(s)}));c.forEach(p=>{const w=f.Color.z.safeParse(p.color);if(!w.success)return;const y=w.data;let b=l.pos(Number(p.timeRange.start.valueOf()));const S=l.pos(Number(p.timeRange.end.valueOf()));if(S<f.To.left(s)||b>f.To.right(s))return;b=f.j(b,f.To.left(s)-2,f.To.right(s)-1);let k=!1;u!=null&&(k=f.R.contains({lower:b,upper:S},u)),k&&(h={key:p.key,name:p.name,color:p.color,timeRange:p.timeRange,viewport:{lower:r.scale(f.To.xBounds(o)).pos(Number(p.timeRange.start.valueOf())),upper:r.scale(f.To.xBounds(o)).pos(Number(p.timeRange.end.valueOf()))}}),a.container({region:f.To.construct({x:b,y:f.To.top(s)-1},{x:S,y:f.To.bottom(s)-1}),backgroundColor:y.setAlpha(.2),bordered:!1});const _=f.To.construct({x:b+1,y:f.To.top(s)-34},{x:S-1,y:f.To.top(s)-12});a.container({region:_,backgroundColor:f.To.width(_)<20?y.setAlpha(.4):v=>k?v.colors.gray.l2:v.colors.gray.l0,bordered:!0,borderWidth:1,borderRadius:2,borderColor:y.setAlpha(.8)}),a.text({text:p.name,position:{x:b+8,y:f.To.top(s)-30},level:"small",shade:8,weight:500,maxWidth:S-b-16})}),d(),h!=null?this.setState(p=>({...p,hovered:h})):this.state.hovered&&this.setState(p=>({...p,hovered:null}))}}m(Jn,"TYPE","range-provider");const CS={[Kr.TYPE]:Kr,[Jn.TYPE]:Jn},PS=ar;class Qn extends yl{constructor(){super(...arguments);m(this,"schema",ar)}async render(n){if(this.deleted)return;const[r,s]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport);if(this.renderAxis(n,r.reverse()),await this.renderYAxes(n,r),await this.renderRangeAnnotations(n,r),s!=null)throw s}async findByXDecimal(n,r){const[s,o]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport);if(o!=null)throw o;return await this.findByXValue(n,s.reverse().pos(r))}async findByXValue(n,r){const[s,o]=await this.dataToDecimalScale(n.hold,this.dataBounds.bind(this),n.viewport);if(o!=null)throw o;const i={...n,xDataToDecimalScale:s},a=this.yAxes.map(async c=>await c.findByXValue(i,r));return(await Promise.all(a)).flat()}async renderYAxes(n,r){const s={...n,xDataToDecimalScale:r};await Promise.all(this.yAxes.map(async o=>await o.render(s)))}get yAxes(){return this.childrenOfType(Un.TYPE)}get rangeAnnotations(){return this.childrenOfType(Jn.TYPE)}async renderRangeAnnotations(n,r){const[s,o]=await this.bounds(n.hold,this.dataBounds.bind(this));if(o!=null)throw o;await Promise.all(this.rangeAnnotations.map(async i=>await i.render({dataToDecimalScale:r,region:n.plot,viewport:n.viewport,timeRange:new E.U(s.lower,s.upper)})))}async dataBounds(){return await Promise.all(this.yAxes.map(async n=>await n.xBounds()))}}m(Qn,"TYPE","XAxis");const fh=T.z.object({container:f.To.box,viewport:f.To.box,hold:T.z.boolean().optional().default(!1),grid:T.z.record(Hc),clearOverScan:f.q.crudeZ.optional().default(f.q.ZERO)}),RS=(t,e)=>{const n=f.To.width(t)*Math.sqrt(f.To.height(t)),r=f.To.width(e)*Math.sqrt(f.To.height(e));return n/r};class ps extends E.Composite{constructor(){super(...arguments);m(this,"schema",fh)}async afterUpdate(){this.internal.instrumentation=sr(this.ctx,"lineplot"),this.internal.aggregate=E.useAggregate(this.ctx),this.internal.renderCtx=gt.use(this.ctx),mt.control(this.ctx,n=>this.requestRender("low",n)),this.requestRender("high",$t)}async afterDelete(){this.internal.renderCtx=gt.use(this.ctx),this.requestRender("high",$t)}async findByXDecimal(n){const r={...this.state,plot:this.calculatePlot(),exposure:this.exposure},s=this.axes.flatMap(async o=>await o.findByXDecimal(r,n));return(await Promise.all(s)).flat()}async findByXValue(n){const r={...this.state,plot:this.calculatePlot(),exposure:this.exposure},s=this.axes.flatMap(async o=>await o.findByXValue(r,n));return(await Promise.all(s)).flat()}get axes(){return this.childrenOfType(Qn.TYPE)}get tooltips(){return this.childrenOfType(an.TYPE)}get measures(){return this.childrenOfType(cn.TYPE)}get exposure(){return RS(this.state.viewport,this.state.container)}async renderAxes(n,r){const s={...this.state,plot:n,canvases:r,exposure:this.exposure};await Promise.all(this.axes.map(async o=>await o.render(s)))}async renderTooltips(n,r){const s={findByXDecimal:this.findByXDecimal.bind(this),region:n,canvases:r};await Promise.all(this.tooltips.map(async o=>await o.render(s)))}async renderMeasures(n,r){const s={findByXDecimal:this.findByXDecimal.bind(this),findByXValue:this.findByXValue.bind(this),region:n,canvases:r};await Promise.all(this.measures.map(async o=>await o.render(s)))}calculatePlot(){return Df(this.state.grid,this.state.container)}async render(n){const{renderCtx:r}=this.internal,{instrumentation:s}=this.internal;if(this.deleted){s.L.debug("deleted, skipping render",{key:this.key});return}const o=this.calculatePlot();s.L.debug("rendering",{key:this.key,viewport:this.state.viewport,container:this.state.container,grid:this.state.grid,plot:o,canvases:n});const i=f.q.construct(this.state.clearOverScan),a=r.scissor(this.state.container,i,n.filter(u=>u!=="gl")),c=r.scissor(o,f.q.ZERO,n.filter(u=>u==="gl"));try{await this.renderAxes(o,n),await this.renderTooltips(o,n),await this.renderMeasures(o,n),r.gl.finish(),r.gl.flush(),r.gl.finish()}catch(u){if(u.message.toLowerCase().includes("bigint"))return;this.internal.aggregate({key:`${this.type}-${this.key}`,variant:"error",message:u.message})}finally{a(),c()}s.L.debug("rendered",{key:this.key});const l=f.To.copy(this.state.container);return async({canvases:u})=>r.erase(l,this.state.clearOverScan,...u)}requestRender(n,r){const{renderCtx:s}=this.internal;let o=["upper2d","lower2d","gl"];r===Gt&&(o=["upper2d"]),s.loop.set({key:`${this.type}-${this.key}`,render:async()=>await this.render(o),priority:n,canvases:o})}}m(ps,"TYPE","LinePlot");const kS={[ps.TYPE]:ps,[Qn.TYPE]:Qn,[Un.TYPE]:Un};exports.AcquireChannelControl=Hn;exports.Annotation=Kr;exports.AuthoritySource=Vn;exports.BaseEdge=un;exports.BaseProvider=Ke;exports.Button=es;exports.Canvas=dl;exports.Canvas$1=Xn;exports.Chip=jr;exports.Context=gt;exports.Controller=mt;exports.Controller$1=Jr;exports.Diagram=mS;exports.Diagram$1=on;exports.Eraser=oi;exports.Eraser$1=us;exports.GLProgram=si;exports.Handle$1=Kn;exports.Indicator=Qr;exports.Legend=ts;exports.Light=hs;exports.Line=Fn;exports.LinePlot=ps;exports.Loop=pl;exports.Measure=cn;exports.Provider=kr;exports.Provider$1=Jn;exports.Provider$2=so;exports.REASON_DATA=fo;exports.REASON_LAYOUT=$t;exports.REASON_TOOL=Gt;exports.REGISTRY=yf;exports.REGISTRY$1=Bg;exports.REGISTRY$10=CS;exports.REGISTRY$11=Sl;exports.REGISTRY$12=vS;exports.REGISTRY$13=nc;exports.REGISTRY$14=Zc;exports.REGISTRY$15=bS;exports.REGISTRY$16=ih;exports.REGISTRY$17=uh;exports.REGISTRY$2=Ol;exports.REGISTRY$3=Yg;exports.REGISTRY$4=rh;exports.REGISTRY$5=yS;exports.REGISTRY$6=wS;exports.REGISTRY$7=Mg;exports.REGISTRY$8=kS;exports.REGISTRY$9=ah;exports.ReactFlow=Gu;exports.ReactFlowProvider=Ei;exports.Rule=tn;exports.STATUSES=_l;exports.SetChannelValue=Zn;exports.Setpoint=fs;exports.StateProvider=en;exports.Toggle=ds;exports.Tooltip=an;exports.Value=ln;exports.XAxis=Qn;exports.YAxis=Un;exports.ZERO_CONTEXT_VALUE=Ao;exports.acquireChannelControl=Lg;exports.acquireChannelControlPropsZ=kl;exports.addEdge=pu;exports.aether=Og;exports.annotationStateZ=vl;exports.applyEdgeChanges=nx;exports.applyNodeChanges=zu;exports.authoritySource=$g;exports.authoritySourceProps=Ml;exports.axisStateZ=ri;exports.buildNew=nS;exports.buttonStateZ=Dl;exports.canvas=qg;exports.canvasStateZ=ai;exports.cc=vt;exports.channelData=Ec;exports.checkIntegrity=Kx;exports.chipStateZ=bl;exports.controllerStateZ=Pl;exports.coreAxisStateZ=ar;exports.diagramStateZ=_i;exports.dragSegment=sS;exports.edgeConverter=gS;exports.edgeZ=hS;exports.eraserStateZ=sh;exports.external=Af;exports.filterGridEntries=fe;exports.indicatorStateZ=Al;exports.legendStateZ=Nl;exports.lightStateZ=oh;exports.linePlotStateZ=fh;exports.measure=SS;exports.measureStateZ=Pi;exports.moveSourceNode=cS;exports.moveTargetNode=lS;exports.newTickFactory=ho;exports.nodeConverter=pS;exports.nodeZ=fS;exports.parseAutoBounds=wl;exports.provider=tf;exports.providerStateZ=hh;exports.providerStateZ$1=Bc;exports.providerStateZ$2=Zo;exports.rfEdgeDataZ=Ku;exports.rollingAverage=Lc;exports.rollingAverageProps=Uo;exports.ruleStateZ=ii;exports.segmentsToPoints=jx;exports.setChannelValue=Ig;exports.setChannelValuePropsZ=Rl;exports.setpoint=Nc;exports.setpointStateZ=ch;exports.shallow$1=pt;exports.sinkPipeline=bc;exports.sinkPipelinePropsZ=$o;exports.sourcePipeline=vc;exports.sourcePipelinePropsZ=Lo;exports.stateProviderStateZ=Tl;exports.stateZ=xl;exports.statusZ=Cl;exports.streamChannelData=_c;exports.streamChannelValue=Cc;exports.streamChannelValuePropsZ=Yo;exports.stringifyNumber=Ic;exports.stringifyNumberProps=Fo;exports.sugaredStateZ=El;exports.tickFactoryProps=ni;exports.tickType=ei;exports.toggleStateZ=lh;exports.tooltip=xS;exports.tooltipStateZ=Ci;exports.translateEdgesBackward=th;exports.translateEdgesForward=Ju;exports.translateNodesBackward=Qu;exports.translateNodesForward=ju;exports.translateViewportBackward=eh;exports.translateViewportForward=dS;exports.updateEdge=_w;exports.useInitialViewport=nh;exports.useOnViewportChange=Wx;exports.useReactFlow=Rs;exports.useStore=lt;exports.useUpdateNodeInternals=Gx;exports.value=ES;exports.viewportZ=uS;exports.withinBounds=Dc;exports.withinSizeThreshold=gl;exports.xAxisStateZ=PS;exports.yAxisStateZ=zg;