@luxalgo/vela 0.6.12 → 0.6.14

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.
@@ -1,6 +1,6 @@
1
1
  var Vela=(function(exports){'use strict';function ve(r){return r.kind!=="candle"&&r.kind!=="bar"&&r.kind!=="markers"}var bn=class{constructor(){this.handlers=new Map;}on(e,t){let n=this.handlers.get(e);n||(n=new Set,this.handlers.set(e,n));let i=n;return i.add(t),()=>{i.delete(t);}}off(e,t){this.handlers.get(e)?.delete(t);}hasListeners(e){return (this.handlers.get(e)?.size??0)>0}emit(e,t){let n=this.handlers.get(e);if(n)for(let i of n)try{i(t);}catch(o){console.error(`[vela] event handler error for "${String(e)}"`,o);}}clear(){this.handlers.clear();}};var Xo=class{constructor(){this.records=new Map;this.counter=0;}nextId(e="ind"){return this.counter+=1,`${e}-${this.counter}`}add(e){this.records.set(e.id,e);}get(e){return this.records.get(e)}remove(e){let t=this.records.get(e);return this.records.delete(e),t}all(){return [...this.records.values()]}};var ci=new Map;function ir(r){ci.set(r.type,r);}function Ch(r){ci.delete(r);}function di(r){return ci.get(r)}function Th(){return [...ci.keys()]}function jo(){return [...ci.values()]}var qo=class{constructor(e,t,n){this.feed=e;this.market=t;this.onBar=n;this.unsubscribe=null;}start(){this.unsubscribe||(this.unsubscribe=this.feed.subscribe(this.market,this.onBar));}stop(){this.unsubscribe?.(),this.unsubscribe=null;}};var or=class{constructor(e,t,n,i){this.controller=n;this.schema=[];this.propsSchema=[];this.visibleState=true;this.bus=new bn;this.id=e,this.title=t,i!==void 0&&(this.source=i);}get inputs(){return this.schema}get props(){return this.propsSchema}get visible(){return this.visibleState}inputValues(){return this.controller.inputValuesOf(this.id)}propValues(){return this.controller.propValuesOf(this.id)}setInput(e,t){this.controller.applyInputs(this.id,{[e]:t});}setInputs(e){this.controller.applyInputs(this.id,e);}setProp(e,t){this.controller.applyProps(this.id,{[e]:t});}setProps(e){this.controller.applyProps(this.id,e);}setVisible(e){this.controller.setVisible(this.id,e);}moveTo(e){this.controller.moveIndicator(this.id,e);}on(e,t){return this.bus.on(e,t)}context(e){return this.controller.getIndicatorContext(this.id,e)}remove(){this.controller.removeIndicator(this.id);}setSchema(e){this.schema=e;}setPropsSchema(e){this.propsSchema=e;}setVisibleState(e){this.visibleState=e;}emit(e,t){this.bus.emit(e,t);}};function Cw(r){let e={};for(let i of r.series)e[i.kind]=(e[i.kind]??0)+1;let t=i=>i?.filter(o=>o.overlay===true).length??0,n=t(r.series)+t(r.fills)+t(r.backgrounds)+t(r.lines)+t(r.boxes)+t(r.labels)+t(r.polylines)+t(r.linefills)+t(r.tables);return {id:r.id,title:r.title,overlay:r.overlay,paneId:r.paneId,native:!!r.native,nativeType:r.native?.type,series:e,fills:r.fills.length,backgrounds:r.backgrounds.length,priceLines:r.priceLines.length,lines:r.lines?.length??0,boxes:r.boxes?.length??0,labels:r.labels?.length??0,polylines:r.polylines?.length??0,linefills:r.linefills?.length??0,tables:r.tables?.length??0,barColors:r.barColors?.length??0,trades:r.trades?.length??0,inputs:r.inputs.length,forcedOverlay:n}}function Eh(r){let e=r.map(Cw),t=n=>e.reduce((i,o)=>i+n(o),0);return {indicators:e,totals:{panes:new Set(e.map(n=>n.paneId??"price")).size,series:t(n=>Object.values(n.series).reduce((i,o)=>i+o,0)),fills:t(n=>n.fills),backgrounds:t(n=>n.backgrounds),priceLines:t(n=>n.priceLines),lines:t(n=>n.lines),boxes:t(n=>n.boxes),labels:t(n=>n.labels),polylines:t(n=>n.polylines),linefills:t(n=>n.linefills),tables:t(n=>n.tables),barColors:t(n=>n.barColors),trades:t(n=>n.trades),forcedOverlay:t(n=>n.forcedOverlay)}}}var Tw={"1D":864e5,"1W":6048e5,"1M":2592e6,"3M":7776e6,"6M":15552e6,"1Y":31536e6,"5Y":15768e7};function Ph(r,e){if(e.length===0)return null;let t=e[0].time,n=e[e.length-1].time;if(r==="ALL")return {from:t,to:n};let i;return r==="YTD"?i=Date.UTC(new Date(n).getUTCFullYear(),0,1):i=n-Tw[r],{from:Math.max(t,i),to:n}}var Ee="#2962ff",sr="#38c0fd",q="#089981",X="#f23645",Pe="#787b86",Mh="#e0b400",vn="#ff9800",It="#5b9cf6",kh="#ff5d00",Zo="#0ecb81",Jo="#f6465d",vk="#f97316",yk="#0ea5e9",wk="#9ca3af",ui="#3b82f6",Ih="#9aa0ad",Ah="#1e293b",Qo="#475569",Rh=Ee,Dh=X,Oh="#d500f9",Lh=[Ee,q,X,vn,"#7e57c2","#26a69a",It,"#e573b5"];function xk(r){let e=0;for(let t=0;t<r.length;t++)e=e*31+r.charCodeAt(t)>>>0;return Lh[e%Lh.length]}var R=sr;function bc(){return {lineColor:R,lineWidth:2,lineStyle:"solid"}}function At(r=""){return {value:r,size:"normal",hAlign:"left",vAlign:"top"}}var es=class es{constructor(e){this.locked=false;this.visible=true;this.zIndex=0;this.id=e.id??`dw-${es.seq+=1}`,this.paneId=e.paneId,this.anchors=(e.anchors??[]).map(t=>({time:t.time,price:t.price})),this.style=e.style?{...e.style}:bc(),this.text=e.text?{...e.text}:void 0,this.locked=e.locked??false,this.visible=e.visible??true,this.zIndex=e.zIndex??0,this.createdAt=e.createdAt??Date.now(),e.props&&this.readProps(e.props);}isComplete(){return this.anchors.length>=this.anchorSchema().min}placementMode(){return "click"}onPlaced(e){}constrainHandleDrag(e){}translateBody(e,t,n){return n.map(i=>({time:i.time+e,price:i.price+t}))}timeExtent(){if(this.anchors.length===0)return null;let e=1/0,t=-1/0;for(let n of this.anchors)n.time<e&&(e=n.time),n.time>t&&(t=n.time);return {min:e,max:t}}editableLevels(){return null}applySettings(e){for(let[t,n]of Object.entries(e))t.startsWith("text.")&&!this.text&&(this.text=At()),Fh(this,t,n);}applyProps(e){this.readProps(e);}serialize(){return {id:this.id,type:this.type,paneId:this.paneId,anchors:this.anchors.map(e=>({time:e.time,price:e.price})),style:{...this.style},text:this.text?{...this.text}:void 0,locked:this.locked,visible:this.visible,zIndex:this.zIndex,createdAt:this.createdAt,props:this.writeProps()}}writeProps(){}readProps(e){}};es.seq=0;var _=es;function Fh(r,e,t){let n=e.split("."),i=r;for(let o=0;o<n.length-1;o+=1){let s=n[o],a=i[s];(a==null||typeof a!="object")&&(a={},i[s]=a),i=a;}i[n[n.length-1]]=t;}var vc=new Map;function D(r,e){vc.set(r,e);}function ts(r){return vc.get(r)??null}function W(r){return vc.get(r)??""}function ce(r,e){return W(r).replace("<svg ",`<svg width="${e}" height="${e}" `)}function Nh(r,e=""){return `<svg viewBox="0 0 16 16" width="1em" height="1em" ${e?e+" ":""}fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`}function A(r,e=""){return `<svg viewBox="0 0 24 24" width="1em" height="1em" ${e?e+" ":""}fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`}function yc(r){return `<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none">${r}</svg>`}var B=Nh;D("style-candles",B('<path d="M4.5 2v2M4.5 12v2M11.5 2v1.5M11.5 11v3"/><rect x="2.8" y="4" width="3.4" height="8" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="3.5" width="3.4" height="7.5" rx="0.6" fill="currentColor"/>'));D("style-bars",B('<path d="M4.5 2.5v11M2.5 5h2M4.5 11h2"/><path d="M11.5 2.5v11M9.5 4.5h2M11.5 10.5h2"/>'));D("style-line",B('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/>'));D("style-area",B('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/><path d="M1.5 11.5 5.5 7l3 2.5 5-6V13.5h-12z" fill="currentColor" fill-opacity="0.25" stroke="none"/>'));D("style-baseline",B('<path d="M1.5 8h13" stroke-dasharray="2 2"/><path d="M2.5 8 5.25 4.5 8 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M2.5 8 5.25 4.5 8 8"/><path d="M8 8l2.75 3.5L13.5 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M8 8l2.75 3.5L13.5 8"/>'));D("style-heikinashi",B('<path d="M4.5 12v2M11.5 2v2"/><rect x="2.8" y="5" width="3.4" height="7" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="4" width="3.4" height="7" rx="0.6" fill="currentColor"/>'));D("indicators",B('<path d="M1.5 12.5 5 7l2.5 3.5L11 4l3.5 5"/><circle cx="11" cy="4" r="1.4" fill="currentColor" stroke="none"/>'));D("undo",B('<path d="M6.2 9.5 2.7 6l3.5-3.5"/><path d="M2.7 6h6.8a3.65 3.65 0 0 1 0 7.3H7.5"/>'));D("redo",B('<path d="M9.8 9.5 13.3 6 9.8 2.5"/><path d="M13.3 6H6.5a3.65 3.65 0 0 0 0 7.3h2"/>'));D("objects",B('<path d="M8 1.8 14 5 8 8.2 2 5z"/><path d="M2 8l6 3.2L14 8" opacity="0.7"/><path d="M2 11l6 3.2 6-3.2" opacity="0.4"/>'));D("clock",B('<circle cx="8" cy="8" r="6.2"/><path d="M8 4.8V8l2.4 1.6"/>'));D("calendar",B('<rect x="2.2" y="3.2" width="11.6" height="10.6" rx="1.4"/><path d="M5.2 1.8v2.8M10.8 1.8v2.8M2.2 6.8h11.6"/>'));D("datawindow",B('<rect x="1.8" y="2.5" width="12.4" height="11" rx="1.5"/><path d="M4.5 5.5h4M4.5 8h7M4.5 10.5h5.5"/>'));D("camera",B('<path d="M5.5 4 6.5 2.5h3L10.5 4h3A1 1 0 0 1 14.5 5v7.5a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z"/><circle cx="8" cy="8.5" r="2.6"/>'));D("gear",B('<path d="M6.55 1.4h2.9l.32 1.72c.48.14.92.38 1.3.7l1.66-.55 1.45 2.5-1.35 1.1c.08.34.12.7.12 1.07s-.04.73-.12 1.07l1.35 1.1-1.45 2.5-1.66-.55a4.3 4.3 0 0 1-1.3.7L9.45 14.6h-2.9l-.32-1.72a4.3 4.3 0 0 1-1.3-.7l-1.66.55-1.45-2.5 1.35-1.1A4.4 4.4 0 0 1 3.05 7.94c0-.37.04-.73.12-1.07l-1.35-1.1 1.45-2.5 1.66.55c.38-.32.82-.56 1.3-.7L6.55 1.4z"/><circle cx="8" cy="8" r="2.2"/>'));D("search",B('<circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/>'));D("bell",B('<path d="M8 2a4 4 0 0 0-4 4v2.5L2.5 11v1h11v-1L12 8.5V6a4 4 0 0 0-4-4z"/><path d="M6.5 13.5a1.5 1.5 0 0 0 3 0"/>'));D("market-open",A('<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>'));D("market-pre",A('<path d="M12 2v8"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m8 6 4-4 4 4"/><path d="M16 18a4 4 0 0 0-8 0"/>'));D("market-post",A('<path d="M12 10V2"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m16 14-4 4-4-4"/><path d="M16 6a4 4 0 0 0-8 0"/>'));D("market-closed",A('<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'));D("market-holiday",A('<path d="m10 20-1.25-2.5L6 16"/><path d="M10 4 8.75 6.5 6 8"/><path d="m14 20 1.25-2.5L18 16"/><path d="m14 4 1.25 2.5L18 8"/><path d="m17 10-5 5-5-5"/><path d="M4 12h16"/>'));D("chevron-right",B('<path d="m6 3.5 4.5 4.5L6 12.5"/>'));D("chevron-left",B('<path d="M10 3.5 5.5 8l4.5 4.5"/>'));D("chevron-down",B('<path d="M3.5 6 8 10.5 12.5 6"/>'));D("chevron-up",B('<path d="M3.5 10 8 5.5 12.5 10"/>'));D("chevrons-right",B('<path d="m4 3.5 4.5 4.5L4 12.5"/><path d="m8.5 3.5 4.5 4.5-4.5 4.5"/>'));D("chevrons-left",B('<path d="M12 3.5 7.5 8l4.5 4.5"/><path d="M7.5 3.5 3 8l4.5 4.5"/>'));D("check",B('<path d="m2.8 8.4 3.4 3.4 7-7.6"/>'));D("close",B('<path d="m3.8 3.8 8.4 8.4M12.2 3.8l-8.4 8.4"/>'));D("eye",B('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>'));D("eye-off",B('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z" opacity="0.45"/><path d="m3 13 10-10"/>'));D("lock",B('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.8 0V7"/>'));D("unlock",B('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.7-.7"/>'));D("trash",B('<path d="M2.5 4.3h11M6.2 4.3V3.1a1 1 0 0 1 1-1h1.6a1 1 0 0 1 1 1v1.2M4.2 4.3l.5 9.1a1.15 1.15 0 0 0 1.15 1.1h4.3a1.15 1.15 0 0 0 1.15-1.1l.5-9.1M6.5 7v4.5M9.5 7v4.5"/>'));D("group",B('<path d="M1.8 4.5V2.4a.6.6 0 0 1 .6-.6h2.1M11.5 1.8h2.1a.6.6 0 0 1 .6.6v2.1M14.2 11.5v2.1a.6.6 0 0 1-.6.6h-2.1M4.5 14.2H2.4a.6.6 0 0 1-.6-.6v-2.1"/><rect x="4" y="4" width="4.2" height="4.2" rx="0.7"/><rect x="7.8" y="7.8" width="4.2" height="4.2" rx="0.7"/>'));D("ungroup",B('<rect x="1.6" y="1.6" width="6.2" height="6.2" rx="0.9"/><rect x="8.2" y="8.2" width="6.2" height="6.2" rx="0.9" stroke-dasharray="2 1.5"/>'));D("clone",B('<rect x="5.5" y="5.5" width="9" height="9" rx="1.2"/><path d="M11 5.5v-3a1 1 0 0 0-1-1H2.5a1 1 0 0 0-1 1V10a1 1 0 0 0 1 1h3"/>'));D("arrow-up",B('<path d="M8 13.2V3M4.2 6.8 8 3l3.8 3.8"/>'));D("arrow-down",B('<path d="M8 2.8V13M4.2 9.2 8 13l3.8-3.8"/>'));D("move-vertical",B('<path d="M8 2.5v11M5 5.5 8 2.5l3 3M5 10.5l3 3 3-3"/>'));D("move",B('<path d="M8 1.8v12.4M1.8 8h12.4M5.6 4.2 8 1.8l2.4 2.4M5.6 11.8 8 14.2l2.4-2.4M4.2 5.6 1.8 8l2.4 2.4M11.8 5.6 14.2 8l-2.4 2.4"/>'));D("pen",B('<path d="m10.8 2.2 3 3-8 8-3.6.6.6-3.6z"/><path d="m9.2 3.8 3 3"/>'));D("wave",B('<path d="M1.5 10.4c1.6 0 1.9-4.8 3.4-4.8s1.8 4.8 3.4 4.8 1.8-4.8 3.4-4.8 1.6 4.8 2.8 4.8"/>'));D("folder-plus",B('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M8 7.6v3.6M6.2 9.4h3.6"/>'));D("folder-minus",B('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M6.2 9.4h3.6"/>'));D("collapse",B('<path d="M3 8h10"/>'));D("expand",B('<rect x="2.2" y="2.2" width="11.6" height="11.6" rx="1.4"/><path d="M8 5.4v5.2M5.4 8h5.2"/>'));D("plus",B('<path d="M8 2.8v10.4M2.8 8h10.4"/>'));D("minus",B('<path d="M2.8 8h10.4"/>'));D("maximize",B('<path d="M2.5 6V3a.5.5 0 0 1 .5-.5h3M10 2.5h3a.5.5 0 0 1 .5.5v3M13.5 10v3a.5.5 0 0 1-.5.5h-3M6 13.5H3a.5.5 0 0 1-.5-.5v-3"/>'));D("restore",B('<path d="M6.2 2.5v3.7H2.5M9.8 13.5V9.8h3.7M13.5 6.2H9.8V2.5M2.5 9.8h3.7v3.7"/>'));D("star",B('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>'));D("star-filled",B('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>','fill="currentColor"'));D("grip",B('<circle cx="6" cy="3.5" r="1"/><circle cx="10" cy="3.5" r="1"/><circle cx="6" cy="8" r="1"/><circle cx="10" cy="8" r="1"/><circle cx="6" cy="12.5" r="1"/><circle cx="10" cy="12.5" r="1"/>','fill="currentColor" stroke="none"'));D("kebab",B('<circle cx="8" cy="3.2" r="1.2"/><circle cx="8" cy="8" r="1.2"/><circle cx="8" cy="12.8" r="1.2"/>','fill="currentColor" stroke="none"'));D("burger",B('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));D("reset",B('<path d="M2 8a6 6 0 1 0 6-6 6.5 6.5 0 0 0-4.5 1.83L2 5.33"/><path d="M2 2v3.33h3.33"/>'));D("pane-collapse",B('<path d="M2.6 9.4h4v4M13.4 6.6h-4v-4"/><path d="m9.4 6.6 4.2-4.2M2.4 13.6l4.2-4.2"/>'));D("pane-expand",B('<path d="M9.8 2.4h3.8v3.8M6.2 13.6H2.4V9.8"/><path d="m13.6 2.4-4.4 4.4M2.4 13.6l4.4-4.4"/>'));D("cursor",A('<path d="M5 3l6 16 2-6 6-2z"/>','fill="currentColor" stroke="none"'));D("ruler",A('<path d="M21.3 15.3 8.7 2.7a1 1 0 0 0-1.4 0L2.7 7.3a1 1 0 0 0 0 1.4l12.6 12.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4Z"/><path d="m7.5 10.5 2 2"/><path d="m10.5 7.5 2 2"/><path d="m13.5 4.5 2 2"/><path d="m4.5 13.5 2 2"/>'));D("magnet",A('<path d="m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15"/><path d="m5 8 4 4"/><path d="m12 15 4 4"/>'));D("eraser",A('<path d="m7 21-4.3-4.3a1 1 0 0 1 0-1.4L13 5a2 2 0 0 1 2.8 0l4.2 4.2a2 2 0 0 1 0 2.8L12 20"/><path d="M22 21H7"/><path d="m5 11 9 9"/>'));D("pen-lock",A('<path d="M13.8 4.2a2.1 2.1 0 0 1 3 3L8.5 15.5l-3.5 1 1-3.5Z"/><rect x="13" y="14.5" width="8" height="6" rx="1.2"/><path d="M15 14.5v-1.6a2 2 0 0 1 4 0v1.6"/>'));D("pen-sync",A('<path d="M13.8 4.2a2.1 2.1 0 0 1 3 3L8.5 15.5l-3.5 1 1-3.5Z"/><rect x="12.5" y="13.5" width="6" height="4.8" rx="1"/><path d="M15.5 18.3v1a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-2.8a1 1 0 0 0-1-1h-1"/>'));D("brush",A('<path d="M9.5 12 17 4.5a2.12 2.12 0 0 1 3 3L12.5 15"/><path d="M7 14a3 3 0 0 0-3 3c0 1.3-1.2 1.5-1.5 2 .8.9 2 1.5 3.5 1.5a3.5 3.5 0 0 0 3.5-3.5 3 3 0 0 0-2.5-3Z"/>'));D("bucket",A('<path d="m18.5 11.5-7-7L4 12a1.8 1.8 0 0 0 0 2.5l5 5a1.8 1.8 0 0 0 2.5 0Z"/><path d="m5 5 4 4"/><path d="M3.5 13.5h13"/><path d="M21 17.5c0 1.1-.9 2-2 2s-2-.9-2-2c0-1 1.2-1.7 2-3 .8 1.3 2 2 2 3Z"/>'));D("type",A('<path d="M5 6V4.5h14V6"/><path d="M12 4.5v15"/><path d="M9.5 19.5h5"/>'));D("bold",A('<path d="M7 5h6a3.5 3.5 0 0 1 0 7H7Z"/><path d="M7 12h7a3.5 3.5 0 0 1 0 7H7Z"/>','stroke-width="2.4"'));D("italic",A('<path d="M15 5h-5M14 19H9M14.5 5 10 19"/>','stroke-width="2.2"'));D("price-delta",A('<path d="M12 4v16"/><path d="M8 8l4-4 4 4"/><path d="M8 16l4 4 4-4"/>'));D("date-delta",A('<path d="M4 12h16"/><path d="M8 8l-4 4 4 4"/><path d="M16 8l4 4-4 4"/>'));D("bring-front",A('<rect x="8.5" y="8.5" width="7" height="7" rx="1.5"/><path d="M4.5 10.5V6a1.5 1.5 0 0 1 1.5-1.5h4.5"/><path d="M19.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5h-4.5"/>'));D("send-back",A('<rect x="8.5" y="8.5" width="7" height="7" rx="1.5" fill="currentColor" stroke="none" opacity="0.35"/><path d="M4.5 10.5V6a1.5 1.5 0 0 1 1.5-1.5h4.5"/><path d="M19.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5h-4.5"/><rect x="8.5" y="8.5" width="7" height="7" rx="1.5"/>'));D("r-squared",'<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none"><text x="2.5" y="17.5" font-size="14" font-family="serif">R\xB2</text></svg>');D("bands",A('<path d="M3 6h18"/><path d="M3 18h18"/><path d="M3 12h18" stroke-dasharray="3 3"/>'));D("dedekind",A('<path d="M2 20h20"/><path d="M4 20a8 8 0 0 1 16 0"/><path d="M8 20a4 4 0 0 1 8 0"/><path d="M12 4v16"/>'));D("sonic",A('<circle cx="15" cy="12" r="4"/><circle cx="12" cy="12" r="2.5"/><path d="M8 5v14"/>'));D("supersonic",A('<circle cx="16" cy="12" r="3.5"/><path d="M6 12 15 6M6 12 15 18"/>'));var Le=[{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"dotted",label:"Dotted"}],F=[{path:"style.lineColor",label:"Line color",kind:"color",group:"line"},{path:"style.lineWidth",label:"Line width",kind:"number",min:1,max:10,step:1,group:"line"},{path:"style.lineStyle",label:"Line style",kind:"lineStyle",options:Le,group:"line"}],ee=[{path:"style.fillColor",label:"Fill color",kind:"color",group:"fill"}],Ze=[{value:"small",label:"Small"},{value:"normal",label:"Normal"},{value:"large",label:"Large"},{value:"huge",label:"Huge"}],N=[{path:"text.value",label:"Text",kind:"text",group:"text"},{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Ze,group:"text"},{path:"text.bold",label:"Bold",kind:"boolean",group:"text"},{path:"text.italic",label:"Italic",kind:"boolean",group:"text"}];function U(r,e,t,n,i,o){let s=i-t,a=o-n,l=s*s+a*a;if(l<=1e-9)return Math.hypot(r-t,e-n);let c=((r-t)*s+(e-n)*a)/l;return c=c<0?0:c>1?1:c,Math.hypot(r-(t+c*s),e-(n+c*a))}function ar(r,e,t){let n=1/0;for(let i=1;i<t.length;i+=1){let o=t[i-1],s=t[i],a=U(r,e,o[0],o[1],s[0],s[1]);a<n&&(n=a);}return n}function ye(r,e,t,n,i,o,s=0){let a=Math.min(t,i)-s,l=Math.max(t,i)+s,c=Math.min(n,o)-s,d=Math.max(n,o)+s;return r>=a&&r<=l&&e>=c&&e<=d}function ct(r,e,t){let n=false;for(let i=0,o=t.length-1;i<t.length;o=i,i+=1){let s=t[i],a=t[o];s[1]>e!=a[1]>e&&r<(a[0]-s[0])*(e-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}return n}function wc(r,e,t,n,i,o,s,a){let l=t-r,c=n-e,d=s-i,u=a-o,h=d*c-u*l;if(Math.abs(h)<1e-9)return null;let p=((o-e)*l-(i-r)*c)/h;return p<0||p>1?null:[i+p*d,o+p*u]}function H(r,e,t,n=6){for(let i=0;i<t.length;i+=1){let o=t[i];if(Math.hypot(r-o[0],e-o[1])<=n)return i}return -1}function se(r,e,t,n,i,o,s){if(i==="none")return [r,e,t,n];let a=t-r,l=i==="left"||i==="both",c=i==="right"||i==="both";if(Math.abs(a)<1e-6){if(l&&c)return [r,0,t,s];let m=n>=e;return c?m?[r,e,t,s]:[r,e,t,0]:m?[r,0,t,n]:[r,s,t,n]}let d=(n-e)/a,u=m=>e+d*(m-r),h=l?-2:Math.min(r,t),p=c?o+2:Math.max(r,t);return [h,u(h),p,u(p)]}var ns=class extends _{constructor(){super(...arguments);this.type="trendline";}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:[t.xOf(n.time),o,t.xOf(i.time),s]}hitTest(t,n,i,o){let s=this.pixels(i);return s!=null&&U(t,n,s[0],s[1],s[2],s[3])<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pixels(t);if(!n)return null;let i=Math.min(n[0],n[2]),o=Math.min(n[1],n[3]);return {x:i,y:o,w:Math.abs(n[2]-n[0]),h:Math.abs(n[3]-n[1])}}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,{path:"style.arrowRight",label:"Arrow",kind:"boolean",group:"line"},...N]}}};var rs=class extends _{constructor(){super(...arguments);this.type="hline";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"y"}]}}y(t){let n=this.anchors[0];return n?t.yOf(n.price,this.paneId):null}hitTest(t,n,i,o){let s=this.y(i);return s!=null&&Math.abs(n-s)<=o}handlePoints(t){let n=this.anchors[0],i=this.y(t);return !n||i==null?[]:[[t.xOf(n.time),i]]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.y(t);return n==null?null:{x:0,y:n-1,w:t.width,h:2}}priceRange(){let t=this.anchors[0];return t?{min:t.price,max:t.price}:null}timeExtent(){return null}schema(){return {fields:[...F,...N]}}};var is=class extends _{constructor(){super(...arguments);this.type="ray";}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:[t.xOf(n.time),o,t.xOf(i.time),s]}hitTest(t,n,i,o){let s=this.pixels(i);if(!s)return false;let[a,l,c,d]=se(s[0],s[1],s[2],s[3],"right",i.width,i.height);return U(t,n,a,l,c,d)<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pixels(t);return n?{x:Math.min(n[0],n[2]),y:Math.min(n[1],n[3]),w:Math.abs(n[2]-n[0]),h:Math.abs(n[3]-n[1])}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,...N]}}};var qt=class extends _{anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:[e.xOf(t.time),i,e.xOf(n.time),o]}hitTest(e,t,n,i){let o=this.pixels(n);return o!=null&&U(e,t,o[0],o[1],o[2],o[3])<=i}handlePoints(e){let t=this.pixels(e);return t?[[t[0],t[1]],[t[2],t[3]]]:[]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.pixels(e);return t?{x:Math.min(t[0],t[2]),y:Math.min(t[1],t[3]),w:Math.abs(t[2]-t[0]),h:Math.abs(t[3]-t[1])}:null}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[...F,...N]}}};var os=class extends qt{constructor(){super(...arguments);this.type="extendedline";}hitTest(t,n,i,o){let s=this.pixels(i);if(!s)return false;let[a,l,c,d]=se(s[0],s[1],s[2],s[3],"both",i.width,i.height);return U(t,n,a,l,c,d)<=o}timeExtent(){return null}};var ss=class extends _{constructor(){super(...arguments);this.type="vline";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"x"}]}}x(t){let n=this.anchors[0];return n?t.xOf(n.time):null}hitTest(t,n,i,o){let s=this.x(i);return s!=null&&Math.abs(t-s)<=o}handlePoints(t){let n=this.anchors[0],i=this.x(t);if(!n||i==null)return [];let o=t.yOf(n.price,this.paneId);return o==null?[]:[[i,o]]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.x(t);return n==null?null:{x:n-1,y:0,w:2,h:t.height}}priceRange(){return null}schema(){return {fields:[...F,...N]}}};var as=class extends _{constructor(){super(...arguments);this.type="hray";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}pt(t){let n=this.anchors[0];if(!n)return null;let i=t.yOf(n.price,this.paneId);return i==null?null:[t.xOf(n.time),i]}hitTest(t,n,i,o){let s=this.pt(i);return s!=null&&U(t,n,s[0],s[1],i.width,s[1])<=o}handlePoints(t){let n=this.pt(t);return n?[n]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pt(t);return n?{x:n[0],y:n[1]-1,w:Math.max(0,t.width-n[0]),h:2}:null}priceRange(){let t=this.anchors[0];return t?{min:t.price,max:t.price}:null}timeExtent(){let t=this.anchors[0];return t?{min:t.time,max:Number.POSITIVE_INFINITY}:null}schema(){return {fields:[...F,...N]}}};var ls=class extends _{constructor(){super(...arguments);this.type="crossline";}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}pt(t){let n=this.anchors[0];if(!n)return null;let i=t.yOf(n.price,this.paneId);return i==null?null:[t.xOf(n.time),i]}hitTest(t,n,i,o){let s=this.pt(i);return s!=null&&(Math.abs(n-s[1])<=o||Math.abs(t-s[0])<=o)}handlePoints(t){let n=this.pt(t);return n?[n]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pt(t);return n?{x:n[0]-1,y:n[1]-1,w:2,h:2}:null}priceRange(){let t=this.anchors[0];return t?{min:t.price,max:t.price}:null}timeExtent(){return null}schema(){return {fields:[...F,...N]}}};var cs=class extends qt{constructor(){super(...arguments);this.type="infoline";}};var ds=class extends qt{constructor(){super(...arguments);this.type="trendangle";}};var us=class extends _{constructor(){super(...arguments);this.type="box";}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}rect(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{x1:t.xOf(n.time),y1:o,x2:t.xOf(i.time),y2:s}}hitTest(t,n,i,o){let s=this.rect(i);return s?this.style.fillColor&&ye(t,n,s.x1,s.y1,s.x2,s.y2)?true:[[s.x1,s.y1,s.x2,s.y1],[s.x2,s.y1,s.x2,s.y2],[s.x2,s.y2,s.x1,s.y2],[s.x1,s.y2,s.x1,s.y1]].some(l=>U(t,n,l[0],l[1],l[2],l[3])<=o):false}handlePoints(t){let n=this.rect(t);return n?[[n.x1,n.y1],[n.x2,n.y2]]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.rect(t);return n?{x:Math.min(n.x1,n.x2),y:Math.min(n.y1,n.y2),w:Math.abs(n.x2-n.x1),h:Math.abs(n.y2-n.y1)}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),{path:"style.fillColor",label:"Fill color",kind:"color",group:"fill"},...N]}}};var Ew={tiny:10,small:12,normal:14,large:18,huge:24,auto:14},Zt=class extends _{defaultLabel(){return "Text"}labelText(){return this.text?.value??this.defaultLabel()}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}box(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);if(n==null)return null;let i=Ew[this.text?.size??"normal"]??14,o=this.labelText().split(`
2
2
  `),s=Math.max(1,...o.map(a=>a.length));return {x:e.xOf(t.time),y:n,w:Math.max(12,s*i*.6)+8,h:o.length*i*1.4+4}}hitTest(e,t,n,i){let o=this.box(n);return o!=null&&ye(e,t,o.x,o.y,o.x+o.w,o.y+o.h)}handlePoints(e){let t=this.anchors[0],n=t?e.yOf(t.price,this.paneId):null;return t&&n!=null?[[e.xOf(t.time),n]]:[]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){return this.box(e)}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}};var Rt=class extends Zt{constructor(t){super(t);this.type="text";this.text||(this.text={...At(),size:"large"});}schema(){return {fields:[...N],textIsContent:true}}};var yn=class extends Zt{constructor(t){super(t);this.type="note";this.text||(this.text=At("Note"));}defaultLabel(){return "Note"}schema(){return {fields:[...F,...ee,...N],textIsContent:true}}};var wn=class extends Zt{constructor(){super(...arguments);this.type="pricelabel";}labelText(){let t=this.anchors[0]?.price;return t==null?"0.00":t.toFixed(2)}schema(){return {fields:[...F,...ee,...N.filter(t=>t.path!=="text.value")]}}};var Pw={tiny:10,small:12,normal:14,large:18,huge:24,auto:14},$e=class extends _{constructor(e){super(e),this.text||(this.text=At(this.defaultLabel()));}defaultLabel(){return "Callout"}labelText(){return this.text?.value??this.defaultLabel()}anchorSchema(){return {min:2,max:2,slots:[{role:"target",free:"both"},{role:"box",free:"both"}]}}box(e){let t=this.anchors[1];if(!t)return null;let n=e.yOf(t.price,this.paneId);if(n==null)return null;let i=Pw[this.text?.size??"normal"]??14,o=this.labelText().split(`
3
- `),s=Math.max(1,...o.map(c=>c.length)),a=Math.max(20,s*i*.6)+16,l=o.length*i*1.4+12;return {x:e.xOf(t.time)-a/2,y:n-l/2,w:a,h:l}}points(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:[[e.xOf(t.time),i],[e.xOf(n.time),o]]}hitTest(e,t,n,i){let o=this.box(n);if(o&&ye(e,t,o.x,o.y,o.x+o.w,o.y+o.h,i))return true;let s=this.points(n);return s!=null&&U(e,t,s[0][0],s[0][1],s[1][0],s[1][1])<=i}handlePoints(e){let t=this.points(e);return t?[t[0]]:[]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}translateBody(e,t,n){let i=n[0],o=n[1];return !i||!o?n.map(s=>({time:s.time+e,price:s.price+t})):[{time:i.time,price:i.price},{time:o.time+e,price:o.price+t}]}bounds(e){return this.box(e)}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[...F,...ee,...N],textIsContent:true}}};var dt=class extends $e{constructor(){super(...arguments);this.type="callout";}};var xn=class extends $e{constructor(){super(...arguments);this.type="pricenote";}defaultLabel(){return ""}labelText(){let t=this.anchors[0]?.price;return t==null?"0.00":t.toFixed(2)}schema(){return {fields:[...F,...ee,...N.filter(t=>t.path!=="text.value")]}}};var Sn=class extends $e{constructor(){super(...arguments);this.type="comment";}defaultLabel(){return "Comment"}};var Cn=class extends $e{constructor(){super(...arguments);this.type="signpost";}defaultLabel(){return "Signpost"}};var te=class extends _{hitTest(e,t,n,i){let o=this.geometry(n);return o?this.style.fillColor&&o.fill&&ct(e,t,o.fill)?true:o.segments.some(s=>U(e,t,s[0],s[1],s[2],s[3])<=i):false}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}};var hs=class extends te{constructor(){super(...arguments);this.type="parallelchannel";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"offset",free:"y"}]}}offset(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];return !t||!n||!i?0:i.price-(t.price+n.price)/2}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return [];let a=[[t.xOf(n.time),o],[t.xOf(i.time),s]],l=this.anchors[2];if(l){let c=t.yOf(l.price,this.paneId);c!=null&&a.push([t.xOf((n.time+i.time)/2),c]);}return a}timeExtent(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.time,n.time),max:Math.max(t.time,n.time)}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=this.offset(),s=t.xOf(n.time),a=t.xOf(i.time),l=t.yOf(n.price,this.paneId),c=t.yOf(i.price,this.paneId),d=t.yOf(n.price+o,this.paneId),u=t.yOf(i.price+o,this.paneId);return l==null||c==null||d==null||u==null?null:{segments:[[s,l,a,c],[s,d,a,u]],fill:[[s,l],[a,c],[a,u],[s,d]]}}priceRange(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=this.offset(),o=[t.price,n.price,t.price+i,n.price+i],s=this.anchors[2];return s&&o.push(s.price),{min:Math.min(...o),max:Math.max(...o)}}schema(){return {fields:[...F,...ee,...N]}}};var ps=class extends te{constructor(){super(...arguments);this.type="disjointchannel";}anchorSchema(){return {min:4,max:4,slots:[{role:"top1",free:"both"},{role:"top2",free:"both"},{role:"bot1",free:"both"},{role:"bot2",free:"both"}]}}seg(t,n,i){let o=this.anchors[t],s=this.anchors[n];if(!o||!s)return null;let a=i.yOf(o.price,this.paneId),l=i.yOf(s.price,this.paneId);return a==null||l==null?null:[i.xOf(o.time),a,i.xOf(s.time),l]}geometry(t){let n=this.seg(0,1,t),i=this.seg(2,3,t),o=[n,i].filter(a=>a!=null);if(o.length===0)return null;let s=n&&i?[[n[0],n[1]],[n[2],n[3]],[i[2],i[3]],[i[0],i[1]]]:null;return {segments:o,fill:s}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F,...ee,...N]}}};var ms=class extends te{constructor(){super(...arguments);this.type="flattopbottom";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"flat",free:"y"}]}}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return [];let a=[[t.xOf(n.time),o],[t.xOf(i.time),s]],l=this.anchors[2];if(l){let c=t.yOf(l.price,this.paneId);c!=null&&a.push([t.xOf((n.time+i.time)/2),c]);}return a}timeExtent(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.time,n.time),max:Math.max(t.time,n.time)}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.xOf(i.time),a=t.yOf(n.price,this.paneId),l=t.yOf(i.price,this.paneId);if(a==null||l==null)return null;let c=this.anchors[2];if(!c)return {segments:[[o,a,s,l]],fill:null};let d=t.yOf(c.price,this.paneId);return d==null?null:{segments:[[o,a,s,l],[o,d,s,d]],fill:[[o,a],[s,l],[s,d],[o,d]]}}priceRange(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=[t.price,n.price],o=this.anchors[2];return o&&i.push(o.price),{min:Math.min(...i),max:Math.max(...i)}}schema(){return {fields:[...F,...ee,...N]}}};var Lw=2;function Vh(){return {midColor:Pe,midStyle:"solid",upperColor:q,upperStyle:"solid",lowerColor:X,lowerStyle:"solid",upperFill:`${q}26`,lowerFill:`${X}26`,showR2:true}}function _h(r){let e=r.length;if(e<2)return null;let t=0,n=0,i=0,o=0,s=0;for(let m=0;m<e;m+=1){let f=r[m].close;t+=m,n+=f,i+=m*f,o+=m*m,s+=f*f;}let a=e*o-t*t,l=a===0?0:(e*i-t*n)/a,c=(n-l*t)/e,d=0;for(let m=0;m<e;m+=1){let f=r[m].close-(c+l*m);d+=f*f;}let u=Math.sqrt(d/e),h=Math.sqrt(a*(e*s-n*n)),p=h===0?0:(e*i-t*n)/h;return {t0:r[0].time,t1:r[e-1].time,mid0:c,mid1:c+l*(e-1),dev:Lw*u,r2:Math.max(0,Math.min(1,p*p)),n:e}}var Dt=class extends _{constructor(t){super(t);this.type="regressionchannel";this.cachedRange=null;this.reg||(this.reg=Vh());}anchorSchema(){return {min:2,max:2,slots:[{role:"start",free:"x"},{role:"end",free:"x"}]}}fit(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=Math.min(n.time,i.time),s=Math.max(n.time,i.time),a=t.barsInRange?.(o,s)??null,l=a?_h(a):null;return l&&(this.cachedRange={min:Math.min(l.mid0,l.mid1)-l.dev,max:Math.max(l.mid0,l.mid1)+l.dev}),l}layout(t){let n=this.fit(t);if(!n)return null;let i=t.yOf(n.mid0,this.paneId),o=t.yOf(n.mid1,this.paneId),s=t.yOf(n.mid0+n.dev,this.paneId),a=t.yOf(n.mid1+n.dev,this.paneId),l=t.yOf(n.mid0-n.dev,this.paneId),c=t.yOf(n.mid1-n.dev,this.paneId);return i==null||o==null||s==null||a==null||l==null||c==null?null:{x0:t.xOf(n.t0),x1:t.xOf(n.t1),midY0:i,midY1:o,upperY0:s,upperY1:a,lowerY0:l,lowerY1:c,r2:n.r2,showR2:this.reg.showR2}}band(t){let n=this.layout(t);return n?[[n.x0,n.upperY0],[n.x1,n.upperY1],[n.x1,n.lowerY1],[n.x0,n.lowerY0]]:null}hitTest(t,n,i,o){let s=this.layout(i);if(!s)return false;let a=[[s.x0,s.upperY0],[s.x1,s.upperY1],[s.x1,s.lowerY1],[s.x0,s.lowerY0]];return ct(t,n,a)?true:[[s.x0,s.midY0,s.x1,s.midY1],[s.x0,s.upperY0,s.x1,s.upperY1],[s.x0,s.lowerY0,s.x1,s.lowerY1]].some(c=>U(t,n,c[0],c[1],c[2],c[3])<=o)}handlePoints(t){let n=this.layout(t);if(n)return [[n.x0,n.midY0],[n.x1,n.midY1]];let i=[];for(let o of this.anchors){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.band(t);if(!n)return null;let i=n.map(l=>l[0]),o=n.map(l=>l[1]),s=Math.min(...i),a=Math.min(...o);return {x:s,y:a,w:Math.max(...i)-s,h:Math.max(...o)-a}}priceRange(){if(this.cachedRange)return this.cachedRange;let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"reg.midColor",label:"Midline color",kind:"color",group:"line"},{path:"reg.midStyle",label:"Midline style",kind:"lineStyle",group:"line"},{path:"reg.upperColor",label:"Upper line color",kind:"color",group:"line"},{path:"reg.upperStyle",label:"Upper line style",kind:"lineStyle",group:"line"},{path:"reg.lowerColor",label:"Lower line color",kind:"color",group:"line"},{path:"reg.lowerStyle",label:"Lower line style",kind:"lineStyle",group:"line"},{path:"reg.upperFill",label:"Upper fill",kind:"color",group:"fill"},{path:"reg.lowerFill",label:"Lower fill",kind:"color",group:"fill"},{path:"reg.showR2",label:"Show R\xB2",kind:"boolean",group:"behavior"}]}}writeProps(){return {...this.reg}}readProps(t){this.reg={...Vh(),...t};}};var Bh=`${It}00`;function Hh(){return {midColor:It,midStyle:"solid",multiplier:1,upperColor:Bh,upperStyle:"solid",lowerColor:Bh,lowerStyle:"solid",bandFill:`${It}33`}}function zh(r,e){let t=r.length;if(t<1)return null;let n=0;for(let c of r)n+=c.volume>0?c.volume:0;let i=n>0,o=0,s=0,a=0,l=[];for(let c=0;c<t;c+=1){let d=r[c],u=(d.high+d.low+d.close)/3,h=i?Math.max(0,d.volume):1;o+=h,s+=u*h,a+=u*u*h;let p=o>0?s/o:u,m=o>0?Math.max(0,a/o-p*p):0,f=Math.sqrt(m)*e;l.push({time:d.time,mid:p,upper:p+f,lower:p-f});}return l}var Tn=class extends _{constructor(t){super(t);this.type="anchoredvwap";this.cachedRange=null;this.cachedExtent=null;this.vwap||(this.vwap=Hh());}anchorSchema(){return {min:1,max:1,slots:[{role:"anchor",free:"x"}]}}series(t){let n=this.anchors[0];if(!n)return null;let i=t.barsInRange?.(n.time,Number.POSITIVE_INFINITY)??null;if(!i||i.length<1)return null;let o=zh(i.map(s=>({time:s.time,high:s.high,low:s.low,close:s.close,volume:s.volume??0})),this.vwap.multiplier);if(o&&o.length>0){let s=1/0,a=-1/0;for(let l of o)l.lower<s&&(s=l.lower),l.upper>a&&(a=l.upper);this.cachedRange={min:s,max:a},this.cachedExtent={min:o[0].time,max:o[o.length-1].time};}return o}layout(t){let n=this.series(t);if(!n)return null;let i=[],o=[],s=[];for(let a of n){let l=t.xOf(a.time),c=t.yOf(a.mid,this.paneId),d=t.yOf(a.upper,this.paneId),u=t.yOf(a.lower,this.paneId);c==null||d==null||u==null||(i.push([l,c]),o.push([l,d]),s.push([l,u]));}return i.length>0?{mid:i,upper:o,lower:s}:null}bandPolygon(t){return [...t.upper,...[...t.lower].reverse()]}hitTest(t,n,i,o){let s=this.layout(i);return s?ct(t,n,this.bandPolygon(s))?true:xc(t,n,s.mid,o)||xc(t,n,s.upper,o)||xc(t,n,s.lower,o):false}handlePoints(t){let n=this.layout(t);if(n&&n.mid.length>0)return [n.mid[0]];let i=this.anchors[0];if(!i)return [];let o=t.yOf(i.price,this.paneId);return o==null?[]:[[t.xOf(i.time),o]]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.layout(t);if(!n)return null;let i=[...n.upper,...n.lower],o=i.map(c=>c[0]),s=i.map(c=>c[1]),a=Math.min(...o),l=Math.min(...s);return {x:a,y:l,w:Math.max(...o)-a,h:Math.max(...s)-l}}priceRange(){return this.cachedRange}timeExtent(){return this.cachedExtent}schema(){return {fields:[{path:"vwap.midColor",label:"VWAP color",kind:"color",group:"line"},{path:"vwap.midStyle",label:"VWAP style",kind:"lineStyle",group:"line"},{path:"vwap.multiplier",label:"Band multiplier",kind:"number",min:.5,max:5,step:.5,group:"behavior"},{path:"vwap.upperColor",label:"Upper band color",kind:"color",group:"line"},{path:"vwap.lowerColor",label:"Lower band color",kind:"color",group:"line"},{path:"vwap.bandFill",label:"Band fill",kind:"color",group:"fill"}]}}writeProps(){return {...this.vwap}}readProps(t){this.vwap={...Hh(),...t};}};function xc(r,e,t,n){for(let i=1;i<t.length;i+=1)if(U(r,e,t[i-1][0],t[i-1][1],t[i][0],t[i][1])<=n)return true;return false}var Mw=`${q}66`,kw=`${X}66`,Iw=`${q}BF`,Aw=`${X}BF`;function $h(){return {rows:24,valueAreaPct:70,widthPct:35,anchor:"left",upColor:Mw,downColor:kw,vaUpColor:Iw,vaDownColor:Aw,showVah:true,vahColor:Pe,vahStyle:"solid",showVal:true,valColor:Pe,valStyle:"solid",showPoc:true,pocColor:void 0,pocStyle:"solid",showDevelopingPoc:false,developingPocColor:Ee,developingPocStyle:"dotted",showDevelopingVa:false,developingVaColor:Ee,developingVaStyle:"dotted"}}function Rw(r,e){return r<0?0:r>=e?e-1:r}function Wh(r,e,t){let n=r.length,i=0,o=0;for(let d=0;d<n;d+=1){let u=r[d].up+r[d].down;i+=u,u>o&&(o=u);}let s=i*Math.min(1,Math.max(0,t)),a=e,l=e,c=o;for(;c<s&&(a>0||l<n-1);){let d=a>0?r[a-1].up+r[a-1].down:-1,u=l<n-1?r[l+1].up+r[l+1].down:-1;u>d?(l+=1,c+=u):(a-=1,c+=d);}return {vaFrom:a,vaTo:l}}function Gh(r,e,t,n){let i=n.volume;if(!(i>0))return;let o=r.length,s=n.close>=n.open?"up":"down",a=new Set;for(let l of [n.open,n.high,n.low,n.close])a.add(Rw(Math.floor((l-e)/t),o));for(let l of a)r[l][s]+=i;}function Uh(r){let e=0,t=0;for(let n=0;n<r.length;n+=1){let i=r[n].up+r[n].down;i>e&&(e=i,t=n);}return e>0?{poc:t,maxTotal:e}:null}function Yh(r,e,t){let n=1/0,i=-1/0;for(let p of r)p.volume>0&&(p.low<n&&(n=p.low),p.high>i&&(i=p.high));if(!Number.isFinite(n))return null;let o=i>n?Math.max(1,Math.round(e)):1,s=i>n?(i-n)/o:1,a=Array.from({length:o},(p,m)=>({price:n+m*s,up:0,down:0}));for(let p of r)Gh(a,n,s,p);let l=Uh(a);if(!l)return null;let{poc:c,maxTotal:d}=l,{vaFrom:u,vaTo:h}=Wh(a,c,t);return {rows:a,rowH:s,min:n,maxTotal:d,poc:c,vaFrom:u,vaTo:h}}function Kh(r,e,t,n){let i=Yh(r,e,t);if(!i)return null;if(!n||r.length<1)return {profile:i,developingPoc:[],developingVaHigh:[],developingVaLow:[]};let{min:o,rowH:s}=i,a=i.rows.length,l=Array.from({length:a},(h,p)=>({price:o+p*s,up:0,down:0})),c=[],d=[],u=[];for(let h of r){Gh(l,o,s,h);let p=Uh(l);if(!p)continue;let{poc:m}=p,{vaFrom:f,vaTo:g}=Wh(l,m,t);c.push({time:h.time,price:l[m].price+s/2}),d.push({time:h.time,price:l[g].price+s}),u.push({time:h.time,price:l[f].price});}return {profile:i,developingPoc:c,developingVaHigh:d,developingVaLow:u}}var Be=class extends _{constructor(t){super(t);this.type="fixedrangevp";this.cachedRange=null;this.frvp||(this.frvp=$h());}anchorSchema(){return {min:2,max:2,slots:[{role:"start",free:"x"},{role:"end",free:"x"}]}}barsInSpan(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=Math.min(n.time,i.time),s=Math.max(n.time,i.time),a=t.barsInRange?.(o,s)??null;return !a||a.length<1?null:a.map(l=>({time:l.time,open:l.open,high:l.high,low:l.low,close:l.close,volume:l.volume??0}))}compute(t){let n=this.barsInSpan(t);if(!n)return null;let i=this.frvp,o=i.showDevelopingPoc||i.showDevelopingVa,s=Kh(n,i.rows,i.valueAreaPct/100,o);if(s){let{profile:a}=s;this.cachedRange={min:a.min,max:a.min+a.rowH*a.rows.length};}return s}layout(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=this.compute(t);if(!o)return null;let{profile:s}=o,a=Math.min(n.time,i.time),l=Math.max(n.time,i.time),c=t.xOf(a),d=t.xOf(l),u=Math.abs(d-c),h=Math.max(1,Math.min(100,Math.max(0,this.frvp.widthPct))/100*u),p=this.frvp.anchor==="left",m=p?Math.min(c,d):Math.max(c,d),f=p?1:-1,g=[];for(let x=0;x<=s.rows.length;x+=1){let S=t.yOf(s.min+x*s.rowH,this.paneId);if(S==null)return null;g.push(S);}let b=x=>t.yOf(x,this.paneId),y=s.rows[s.vaTo].price+s.rowH,v=s.rows[s.vaFrom].price,w=s.rows[s.poc].price+s.rowH/2,E=x=>{let S=[];for(let P of x){let k=b(P.price);k!=null&&S.push([t.xOf(P.time),k]);}return S};return {x0:Math.min(c,d),x1:Math.max(c,d),anchorX:m,maxW:h,grow:f,profile:s,yEdges:g,vahY:b(y),valY:b(v),pocY:b(w),developingPoc:E(o.developingPoc),developingVaHigh:E(o.developingVaHigh),developingVaLow:E(o.developingVaLow)}}hitTest(t,n,i,o){let s=this.layout(i);if(!s)return false;let a=s.grow===1?s.anchorX:s.anchorX-s.maxW,l=s.grow===1?s.anchorX+s.maxW:s.anchorX,c=Math.min(s.yEdges[0],s.yEdges[s.yEdges.length-1]),d=Math.max(s.yEdges[0],s.yEdges[s.yEdges.length-1]);if(ct(t,n,[[a,c],[l,c],[l,d],[a,d]]))return true;let u=[[s.x0,s.vahY],[s.x0,s.valY],[s.x0,s.pocY]];for(let[,h]of u)if(h!=null&&U(t,n,s.x0,h,s.x1,h)<=o)return true;for(let h of [s.developingPoc,s.developingVaHigh,s.developingVaLow])for(let p=1;p<h.length;p+=1)if(U(t,n,h[p-1][0],h[p-1][1],h[p][0],h[p][1])<=o)return true;return false}handlePoints(t){let n=this.layout(t);if(n&&n.pocY!=null)return [[n.x0,n.pocY],[n.x1,n.pocY]];let i=[];for(let o of this.anchors){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.layout(t);if(!n)return null;let i=Math.min(n.x0,n.grow===1?n.anchorX:n.anchorX-n.maxW),o=Math.max(n.x1,n.grow===1?n.anchorX+n.maxW:n.anchorX),s=Math.min(n.yEdges[0],n.yEdges[n.yEdges.length-1]),a=Math.max(n.yEdges[0],n.yEdges[n.yEdges.length-1]);return {x:i,y:s,w:o-i,h:a-s}}priceRange(){if(this.cachedRange)return this.cachedRange;let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"frvp.rows",label:"Rows",kind:"number",min:1,max:500,step:1,group:"behavior"},{path:"frvp.valueAreaPct",label:"Value Area",kind:"number",min:0,max:100,step:1,group:"behavior"},{path:"frvp.widthPct",label:"Width %",kind:"number",min:0,max:100,step:1,group:"behavior"},{path:"frvp.anchor",label:"Anchor",kind:"select",options:[{value:"right",label:"Right"},{value:"left",label:"Left"}],group:"behavior"},{path:"frvp.upColor",label:"Up Volume",kind:"color",group:"fill"},{path:"frvp.downColor",label:"Down Volume",kind:"color",group:"fill"},{path:"frvp.vaUpColor",label:"Value Area Up",kind:"color",group:"fill"},{path:"frvp.vaDownColor",label:"Value Area Down",kind:"color",group:"fill"},{path:"frvp.showVah",label:"VAH",kind:"boolean",group:"line"},{path:"frvp.vahColor",label:"VAH color",kind:"color",group:"line"},{path:"frvp.vahStyle",label:"VAH style",kind:"lineStyle",options:Le,group:"line"},{path:"frvp.showVal",label:"VAL",kind:"boolean",group:"line"},{path:"frvp.valColor",label:"VAL color",kind:"color",group:"line"},{path:"frvp.valStyle",label:"VAL style",kind:"lineStyle",options:Le,group:"line"},{path:"frvp.showPoc",label:"POC",kind:"boolean",group:"line"},{path:"frvp.pocColor",label:"POC color",kind:"color",group:"line"},{path:"frvp.pocStyle",label:"POC style",kind:"lineStyle",options:Le,group:"line"},{path:"frvp.showDevelopingPoc",label:"Developing POC",kind:"boolean",group:"line"},{path:"frvp.developingPocColor",label:"Developing POC color",kind:"color",group:"line"},{path:"frvp.developingPocStyle",label:"Developing POC style",kind:"lineStyle",options:Le,group:"line"},{path:"frvp.showDevelopingVa",label:"Developing VA",kind:"boolean",group:"line"},{path:"frvp.developingVaColor",label:"Developing VA color",kind:"color",group:"line"},{path:"frvp.developingVaStyle",label:"Developing VA style",kind:"lineStyle",options:Le,group:"line"}]}}writeProps(){return {...this.frvp}}readProps(t){this.frvp={...$h(),...t};}};var fs=class extends te{constructor(){super(...arguments);this.type="pitchfork";}anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=g=>{let b=t.yOf(g.price,this.paneId);return b==null?null:[t.xOf(g.time),b]},a=s(n),l=s(i),c=s(o);if(!a||!l||!c)return null;let d=(l[0]+c[0])/2,u=(l[1]+c[1])/2,h=d-a[0],p=u-a[1],m=t.width,f=t.height;return {segments:[se(a[0],a[1],d,u,"right",m,f),se(l[0],l[1],l[0]+h,l[1]+p,"right",m,f),se(c[0],c[1],c[0]+h,c[1]+p,"right",m,f),[l[0],l[1],c[0],c[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F,...N]}}};var lr=class extends te{anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(e){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n||!i)return null;let o=f=>{let g=e.yOf(f.price,this.paneId);return g==null?null:[e.xOf(f.time),g]},s=o(this.medianStart(t,n,i)),a=o(n),l=o(i);if(!s||!a||!l)return null;let c=(a[0]+l[0])/2,d=(a[1]+l[1])/2,u=c-s[0],h=d-s[1],p=e.width,m=e.height;return {segments:[se(s[0],s[1],c,d,"right",p,m),se(a[0],a[1],a[0]+u,a[1]+h,"right",p,m),se(l[0],l[1],l[0]+u,l[1]+h,"right",p,m),[a[0],a[1],l[0],l[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}schema(){return {fields:[...F,...N]}}};var gs=class extends lr{constructor(){super(...arguments);this.type="schiffpitchfork";}medianStart(t,n){return {time:t.time,price:(t.price+n.price)/2}}};var bs=class extends lr{constructor(){super(...arguments);this.type="modifiedschiffpitchfork";}medianStart(t,n){return {time:(t.time+n.time)/2,price:(t.price+n.price)/2}}};var vs=class extends te{constructor(){super(...arguments);this.type="insidepitchfork";}anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=b=>{let y=t.yOf(b.price,this.paneId);return y==null?null:[t.xOf(b.time),y]},a=s({time:(n.time+i.time)/2,price:(n.price+i.price)/2}),l=s(n),c=s(i),d=s(o);if(!a||!l||!c||!d)return null;let u=(c[0]+d[0])/2,h=(c[1]+d[1])/2,p=d[0]-a[0],m=d[1]-a[1],f=t.width,g=t.height;return {segments:[se(u,h,u+p,h+m,"right",f,g),se(c[0],c[1],c[0]+p,c[1]+m,"right",f,g),se(d[0],d[1],d[0]+p,d[1]+m,"right",f,g),[c[0],c[1],d[0],d[1]],[a[0],a[1],d[0],d[1]],[l[0],l[1],c[0],c[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F,...N]}}};var ys=class extends _{constructor(){super(...arguments);this.type="arrow";}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:[t.xOf(n.time),o,t.xOf(i.time),s]}hitTest(t,n,i,o){let s=this.pixels(i);return s!=null&&U(t,n,s[0],s[1],s[2],s[3])<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pixels(t);return n?{x:Math.min(n[0],n[2]),y:Math.min(n[1],n[3]),w:Math.abs(n[2]-n[0]),h:Math.abs(n[3]-n[1])}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,{path:"style.arrowRight",label:"Head (end)",kind:"boolean",group:"line"},{path:"style.arrowLeft",label:"Head (start)",kind:"boolean",group:"line"},...N]}}};var Xh=48,ws=class extends _{constructor(){super(...arguments);this.type="ellipse";}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}oval(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:(a+l)/2,cy:(o+s)/2,rx:Math.abs(l-a)/2,ry:Math.abs(s-o)/2}}perimeter(t){let n=[];for(let i=0;i<=Xh;i+=1){let o=i/Xh*Math.PI*2;n.push([t.cx+t.rx*Math.cos(o),t.cy+t.ry*Math.sin(o)]);}return n}hitTest(t,n,i,o){let s=this.oval(i);if(!s||s.rx<1||s.ry<1)return false;let a=((t-s.cx)/s.rx)**2+((n-s.cy)/s.ry)**2;return this.style.fillColor&&a<=1?true:ar(t,n,this.perimeter(s))<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.oval(t);return n?{x:n.cx-n.rx,y:n.cy-n.ry,w:n.rx*2,h:n.ry*2}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,...ee,...N]}}};var xs=class extends te{constructor(){super(...arguments);this.type="triangle";}anchorSchema(){return {min:3,max:3,slots:[{role:"v1",free:"both"},{role:"v2",free:"both"},{role:"v3",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=d=>{let u=t.yOf(d.price,this.paneId);return u==null?null:[t.xOf(d.time),u]},a=s(n),l=s(i),c=s(o);return !a||!l||!c?null:{segments:[[a[0],a[1],l[0],l[1]],[l[0],l[1],c[0],c[1]],[c[0],c[1],a[0],a[1]]],fill:[a,l,c]}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F,...ee,...N]}}};var Dw=512,Jt=class extends te{anchorSchema(){return {min:2,max:Dw,slots:[]}}geometry(e){let t=[];for(let i of this.anchors){let o=e.yOf(i.price,this.paneId);if(o==null)return null;t.push([e.xOf(i.time),o]);}if(t.length<2)return null;let n=[];for(let i=1;i<t.length;i+=1)n.push([t[i-1][0],t[i-1][1],t[i][0],t[i][1]]);return {segments:n,fill:null}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}schema(){return {fields:[...F,...N]}}};var Ss=class extends Jt{constructor(){super(...arguments);this.type="polyline";}};var hi=class extends Jt{placementMode(){return "freehand"}handlePoints(e){return []}bounds(e){let t=[],n=[];for(let s of this.anchors){let a=e.yOf(s.price,this.paneId);a!=null&&(t.push(e.xOf(s.time)),n.push(a));}if(t.length===0)return null;let i=Math.min(...t),o=Math.min(...n);return {x:i,y:o,w:Math.max(...t)-i,h:Math.max(...n)-o}}},Cs=class extends hi{constructor(){super(...arguments);this.type="freehand";}};var Ow=[{path:"style.lineColor",label:"Color",kind:"color",group:"line"},{path:"style.lineWidth",label:"Width",kind:"number",min:4,max:60,step:1,group:"line"}],Ts=class extends hi{constructor(){super(...arguments);this.type="highlighter";}schema(){return {fields:Ow}}};var Es=class extends _{constructor(){super(...arguments);this.type="circle";}anchorSchema(){return {min:2,max:2,slots:[{role:"center",free:"both"},{role:"edge",free:"both"}]}}geom(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:a,cy:o,r:Math.hypot(l-a,s-o)}}hitTest(t,n,i,o){let s=this.geom(i);if(!s||s.r<1)return false;let a=Math.hypot(t-s.cx,n-s.cy);return this.style.fillColor&&a<=s.r?true:Math.abs(a-s.r)<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.geom(t);return n?{x:n.cx-n.r,y:n.cy-n.r,w:n.r*2,h:n.r*2}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,...ee,...N]}}};var Ps=class extends te{constructor(){super(...arguments);this.type="rotatedrect";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"w",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.px(t,2);if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=i[0]-n[0],a=i[1]-n[1],l=Math.hypot(s,a);if(l<1e-6)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let c=-a/l,d=s/l,u=(o[0]-n[0])*c+(o[1]-n[1])*d,h=c*u,p=d*u,m=n,f=i,g=[i[0]+h,i[1]+p],b=[n[0]+h,n[1]+p];return {segments:[[m[0],m[1],f[0],f[1]],[f[0],f[1],g[0],g[1]],[g[0],g[1],b[0],b[1]],[b[0],b[1],m[0],m[1]]],fill:[m,f,g,b]}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),...ee,...N]}}};var Ls=class extends Jt{constructor(){super(...arguments);this.type="path";}};var jh=40,Ms=class extends te{constructor(){super(...arguments);this.type="arc";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"apex",free:"both"}]}}pinApex(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];t&&n&&i&&(i.time=(t.time+n.time)/2);}onPlaced(){this.pinApex();}constrainHandleDrag(){this.pinApex();}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.anchors[2];if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=t.yOf(o.price,this.paneId);if(s==null)return null;let a=(n[0]+i[0])/2,l=(n[1]+i[1])/2,c=(i[0]-n[0])/2,d=(i[1]-n[1])/2,u=Math.hypot(c,d);if(u<1e-6)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let h=-d/u,p=c/u,m=(s-l)*p;m<0&&(h=-h,p=-p);let f=Math.abs(m),g=[];for(let y=0;y<=jh;y+=1){let v=y/jh*Math.PI,w=Math.cos(v),E=Math.sin(v);g.push([a+w*c+E*f*h,l+w*d+E*f*p]);}let b=[];for(let y=1;y<g.length;y+=1)b.push([g[y-1][0],g[y-1][1],g[y][0],g[y][1]]);return b.push([g[g.length-1][0],g[g.length-1][1],g[0][0],g[0][1]]),{segments:b,fill:g}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),...ee,...N]}}};var qh=40,ks=class extends te{constructor(){super(...arguments);this.type="curve";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"control",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.px(t,2);if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=[];for(let l=0;l<=qh;l+=1){let c=l/qh,d=1-c;s.push([d*d*n[0]+2*d*c*o[0]+c*c*i[0],d*d*n[1]+2*d*c*o[1]+c*c*i[1]]);}let a=[];for(let l=1;l<s.length;l+=1)a.push([s[l-1][0],s[l-1][1],s[l][0],s[l][1]]);return {segments:a,fill:s}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F,...ee,...N]}}};var Fw={head:11,headW:9,stemW:3.5,len:22},En=class extends _{anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}glyphPoints(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);if(n==null)return null;let i=e.xOf(t.time),{head:o,headW:s,stemW:a,len:l}=Fw,c=[[0,0],[-s,o],[-a,o],[-a,l],[a,l],[a,o],[s,o]],d=this.dir(),u=([h,p])=>{switch(d){case "up":return [h,p];case "down":return [h,-p];case "left":return [p,h];default:return [-p,h]}};return c.map(h=>{let[p,m]=u(h);return [i+p,n+m]})}hitTest(e,t,n,i){let o=this.glyphPoints(n);return o!=null&&ct(e,t,o)}handlePoints(e){let t=this.anchors[0];if(!t)return [];let n=e.yOf(t.price,this.paneId);return n==null?[]:[[e.xOf(t.time),n]]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.glyphPoints(e);if(!t)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}schema(){return {fields:[{path:"style.lineColor",label:"Color",kind:"color",group:"line"},...N]}}},pi=class extends En{constructor(){super(...arguments);this.type="arrowmarkup";}dir(){return "up"}},mi=class extends En{constructor(){super(...arguments);this.type="arrowmarkdown";}dir(){return "down"}};var bi=["\u2605","\u2606","\u25CF","\u25C6","\u25B2","\u25BC","\u27A4","\u2691","\u271A","\u2715","\u2764","\u2666"],Is=["small","normal","large","huge"],Zh={small:16,normal:22,large:32,huge:44},Pn=class extends _{constructor(e){super(e),this.glyph||(this.glyph=this.defaultGlyph()),this.size||(this.size="normal");}sizePx(){return Zh[this.size]??Zh.normal}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}center(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);return n==null?null:[e.xOf(t.time),n]}hitTest(e,t,n,i){let o=this.center(n);if(!o)return false;let s=this.sizePx()/2+i;return Math.abs(e-o[0])<=s&&Math.abs(t-o[1])<=s}handlePoints(e){let t=this.center(e);return t?[t]:[]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.center(e);if(!t)return null;let n=this.sizePx();return {x:t[0]-n/2,y:t[1]-n/2,w:n,h:n}}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}schema(){return {fields:[{path:"glyph",label:"Icon",kind:"select",options:bi.map(e=>({value:e,label:e})),group:"line"},{path:"size",label:"Size",kind:"select",options:Is.map(e=>({value:e,label:e})),group:"line"},{path:"style.lineColor",label:"Color",kind:"color",group:"line"},...N]}}writeProps(){return {glyph:this.glyph,size:this.size}}readProps(e){typeof e.glyph=="string"&&(this.glyph=e.glyph),typeof e.size=="string"&&(this.size=e.size);}},fi=class extends Pn{constructor(){super(...arguments);this.type="flagmark";}defaultGlyph(){return "\u2691"}},gi=class extends Pn{constructor(){super(...arguments);this.type="iconstamp";}defaultGlyph(){return "\u2605"}};var Jh=r=>r==="small"||r==="normal"||r==="large"||r==="huge";function Nw(r){if(!r||typeof r!="object")return null;let e=r;return typeof e.ratio!="number"||typeof e.color!="string"?null:{ratio:e.ratio,color:e.color,enabled:e.enabled!==false,...typeof e.label=="string"&&e.label?{label:e.label}:{}}}var re=class extends _{constructor(e){super(e),this.levels||(this.levels=this.defaultLevels().map(t=>({...t}))),this.numbersSize||(this.numbersSize="small"),this.labelsSize||(this.labelsSize="normal");}fillBands(e){return []}editableLevels(){return this.levels}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}hitTest(e,t,n,i){let o=this.entryLines(n);return o!=null&&o.some(s=>U(e,t,s.x1,s.y1,s.x2,s.y2)<=i)}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}schema(){return {fields:F.filter(e=>e.path!=="style.lineColor")}}writeProps(){return {levels:this.levels.map(e=>({...e})),numbersSize:this.numbersSize,labelsSize:this.labelsSize}}readProps(e){if(Array.isArray(e.levels)){let t=e.levels.map(Nw).filter(n=>n!=null);t.length&&(this.levels=t);}Jh(e.numbersSize)&&(this.numbersSize=e.numbersSize),Jh(e.labelsSize)&&(this.labelsSize=e.labelsSize);}};var cr=class extends re{levelLines(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.xOf(t.time),o=e.xOf(n.time),s=Math.min(i,o),a=Math.max(i,o),l=n.price-t.price,c=[];for(let d of this.levels){if(!d.enabled)continue;let u=t.price+d.ratio*l,h=e.yOf(u,this.paneId);h!=null&&c.push({ratio:d.ratio,color:d.color,label:d.label,price:u,x1:s,x2:a,y:h});}return c}entryLines(e){let t=this.levelLines(e);return t?t.map(n=>({color:n.color,label:n.label,x1:n.x1,y1:n.y,x2:n.x2,y2:n.y,numberText:`${n.ratio} (${n.price.toFixed(2)})`,numberX:n.x1+4,numberY:n.y-7,numberAlign:"left",labelX:(n.x1+n.x2)/2,labelY:n.y-7})):null}fillBands(e){let t=this.levelLines(e);if(!t)return [];let n=[];for(let i=1;i<t.length;i+=1){let o=t[i-1],s=t[i];n.push({color:s.color,x:o.x1,y:Math.min(o.y,s.y),w:o.x2-o.x1,h:Math.abs(s.y-o.y)});}return n}priceRange(){let e=this.anchors[0],t=this.anchors[1];if(!e||!t)return null;let n=t.price-e.price,i=this.levels.filter(o=>o.enabled).map(o=>e.price+o.ratio*n);return i.length===0?null:{min:Math.min(...i),max:Math.max(...i)}}};var Ln=Pe,ut=X,ht=vn,Mn="#4caf50",Qt=q,Ot=It,kn="#9c27b0",Vw="#e91e63",Sc="#26a69a",_w="#ab47bc",Bw="#ef5350",Qh="#ffb74d",Hw="#38c0fd",As="#b2b5be",dr=[Hw,Ot,Qt,Mn,ht,ut,Vw,kn,Ln,Sc,_w,Bw];function ep(r){return dr[(r%dr.length+dr.length)%dr.length]}var zw=[[0,Ln],[.125,ut],[.236,ut],[.25,ut],[.382,ht],[.5,Mn],[.618,Qt],[.75,Ot],[.786,Ot],[1,Ln],[1.272,Ot],[1.382,ht],[1.618,ut],[2,Ln],[2.382,ht],[2.618,ht],[3,Ln],[4.236,Mn],[6.854,Qt],[11.09,Ot]];function $w(r,e=0){return zw.find(([t])=>t===r)?.[1]??ep(e)}function ne(r){return r.map((e,t)=>{let n=typeof e=="number"?{ratio:e}:e;return {ratio:n.ratio,color:n.color??$w(n.ratio,t),enabled:n.enabled!==false,...n.label?{label:n.label}:{}}})}function tp(r,e=r){return Array.from({length:r},(t,n)=>({ratio:n+1,color:ep(n),enabled:n<e,label:String(n+1)}))}var Ww=ne([0,.236,.382,.5,.618,.786,1]),Rs=class extends cr{constructor(){super(...arguments);this.type="fibretracement";}defaultLevels(){return Ww}};var Gw=ne([0,.382,.618,1,1.272,1.618,{ratio:2.618,color:kn}]),Ds=class extends cr{constructor(){super(...arguments);this.type="fibextension";}defaultLevels(){return Gw}};var Uw=ne([0,.382,.5,.618,1,1.618,{ratio:2.618,color:kn}]),Os=class extends re{constructor(){super(...arguments);this.type="fibextensiontrend";}anchorSchema(){return {min:3,max:3,slots:[{role:"a",free:"both"},{role:"b",free:"both"},{role:"c",free:"both"}]}}defaultLevels(){return Uw}entryLines(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=i.price-n.price,a=[t.xOf(n.time),t.xOf(i.time),t.xOf(o.time)],l=Math.min(...a),c=Math.max(...a),d=[];for(let u of this.levels){if(!u.enabled)continue;let h=o.price+u.ratio*s,p=t.yOf(h,this.paneId);p!=null&&d.push({color:u.color,label:u.label,x1:l,y1:p,x2:c,y2:p,numberText:`${u.ratio} (${h.toFixed(2)})`,numberX:l+4,numberY:p-7,numberAlign:"left",labelX:(l+c)/2,labelY:p-7});}return d}priceRange(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n||!i)return null;let o=n.price-t.price,s=this.levels.filter(a=>a.enabled).map(a=>i.price+a.ratio*o);return s.push(t.price,n.price,i.price),{min:Math.min(...s),max:Math.max(...s)}}};var Yw=ne([.236,.382,.5,.618,.786,1]),Fs=class extends re{constructor(){super(...arguments);this.type="fibfan";}defaultLevels(){return Yw}fanLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.yOf(n.price,this.paneId);if(s==null)return null;let a=t.xOf(i.time),l=i.price-n.price,c=[];for(let d of this.levels){if(!d.enabled)continue;let u=t.yOf(n.price+d.ratio*l,this.paneId);if(u==null)continue;let[h,p,m,f]=se(o,s,a,u,"right",t.width,t.height);c.push({ratio:d.ratio,color:d.color,label:d.label,x1:h,y1:p,x2:m,y2:f,labelX:a+5,labelY:u});}return c}entryLines(t){let n=this.fanLines(t);return n?n.map(i=>({color:i.color,label:i.label,x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,numberText:String(i.ratio),numberX:i.labelX,numberY:i.labelY,numberAlign:"left",labelX:i.labelX,labelY:i.labelY+13})):null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var Kw=[0,1,2,3,5,8,13,21,34].map(r=>({ratio:r,color:R,enabled:true})),Ns=class extends re{constructor(){super(...arguments);this.type="fibtimezones";}defaultLevels(){return Kw}zoneLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=i.time-n.time;if(Math.abs(o)<1e-9)return null;let s=[];for(let a of this.levels)a.enabled&&s.push({n:a.ratio,color:a.color,label:a.label,x:t.xOf(n.time+a.ratio*o)});return s}entryLines(t){let n=this.zoneLines(t);if(!n)return null;let i=t.height;return n.map(o=>({color:o.color,label:o.label,x1:o.x,y1:0,x2:o.x,y2:i,numberText:String(o.n),numberX:o.x,numberY:9,numberAlign:"center",labelX:o.x,labelY:24}))}priceRange(){return null}timeExtent(){return null}};var Xw=ne([0,.236,.382,.5,.618,.786,1,1.618,2.618]),Vs=class extends re{constructor(){super(...arguments);this.type="fibchannel";}defaultLevels(){return Xw}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"offset",free:"both"}]}}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time),c=0,d=0,u=this.anchors[2];if(u){let p=t.yOf(u.price,this.paneId);if(p==null)return null;c=t.xOf(u.time)-a,d=p-o;}let h=[];for(let p of this.levels){if(!p.enabled)continue;let m=p.ratio*c,f=p.ratio*d,g=l+m,b=s+f;h.push({color:p.color,label:p.label,x1:a+m,y1:o+f,x2:g,y2:b,numberText:String(p.ratio),numberX:g+5,numberY:b,numberAlign:"left",labelX:g+5,labelY:b+13});}return h}priceRange(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n)return null;let o=i?i.price-t.price:0,s=1/0,a=-1/0;for(let l of this.levels)if(l.enabled)for(let c of [t.price,n.price]){let d=c+l.ratio*o;d<s&&(s=d),d>a&&(a=d);}return s<=a?{min:s,max:a}:null}};var jw=ne([0,.236,.382,.5,.618,.786,1]),_s=class extends re{constructor(){super(...arguments);this.type="fibspeedfan";}defaultLevels(){return jw}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),c=t.xOf(i.time)-a,d=s-o,u=c>=0?"right":"left",h=t.width,p=t.height,m=[];for(let f of this.levels){if(!f.enabled)continue;let g=a+c,b=o+d*f.ratio,y=se(a,o,g,b,u,h,p);if(m.push({color:f.color,label:f.label,x1:y[0],y1:y[1],x2:y[2],y2:y[3],numberText:String(f.ratio),numberX:u==="right"?g+5:g-5,numberY:b,numberAlign:u==="right"?"left":"right",labelX:g,labelY:b}),f.ratio===1)continue;let v=a+c*f.ratio,w=o+d,E=se(a,o,v,w,u,h,p);m.push({color:f.color,label:f.label,x1:E[0],y1:E[1],x2:E[2],y2:E[3],numberText:String(f.ratio),numberX:v,numberY:w+(d>=0?12:-12),numberAlign:"center",labelX:v,labelY:w+12});}return m}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var qw=ne([0,.382,{ratio:.5,enabled:false},.618,1,1.382,1.618,2,2.382,2.618,3]),Bs=class extends re{constructor(){super(...arguments);this.type="trendfibtime";}defaultLevels(){return qw}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"p3",free:"both"}]}}entryLines(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=i.time-n.time;if(Math.abs(s)<1e-9)return null;let a=t.height,l=[];for(let c of this.levels){if(!c.enabled)continue;let d=t.xOf(o.time+c.ratio*s);l.push({color:c.color,label:c.label,x1:d,y1:0,x2:d,y2:a,numberText:String(c.ratio),numberX:d,numberY:9,numberAlign:"center",labelX:d,labelY:24});}return l}priceRange(){return null}timeExtent(){return null}};function Zw(r,e,t){if(t-e>=Math.PI*2-.001)return true;let n=r-e,i=Math.PI*2;for(;n<0;)n+=i;for(;n>=i;)n-=i;return n<=t-e+1e-6}var Je=class extends re{boundingLines(e){return []}entryLines(e){return []}hitTest(e,t,n,i){let o=this.radial(n);if(o){let s=Math.hypot(e-o.cx,t-o.cy),a=Math.atan2(t-o.cy,e-o.cx);if(Zw(a,o.a0,o.a1)){for(let l of this.levels)if(l.enabled&&Math.abs(s-o.R0*l.ratio)<=i)return true}}return this.boundingLines(n).some(s=>U(e,t,s[0],s[1],s[2],s[3])<=i)}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}};var Jw=ne([.236,.382,.5,.618,.786,1,1.618,2.618]),Hs=class extends Je{constructor(){super(...arguments);this.type="fibcircles";}defaultLevels(){return Jw}radial(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:a,cy:o,R0:Math.hypot(l-a,s-o),a0:0,a1:Math.PI*2}}};var Qw=ne([.236,.382,.5,.618,.786,1,1.618,2.618]),zs=class extends Je{constructor(){super(...arguments);this.type="fibarcs";}defaultLevels(){return Qw}pts(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{cx:t.xOf(n.time),cy:o,ex:t.xOf(i.time),ey:s}}radial(t){let n=this.pts(t);if(!n)return null;let i=Math.hypot(n.ex-n.cx,n.ey-n.cy),o=Math.atan2(n.ey-n.cy,n.ex-n.cx);return {cx:n.cx,cy:n.cy,R0:i,a0:o-Math.PI/2,a1:o+Math.PI/2}}boundingLines(t){let n=this.pts(t);return n?[[n.cx,n.cy,n.ex,n.ey]]:[]}};var ex=ne([.236,.382,.5,.618,.786,1]),$s=class extends Je{constructor(){super(...arguments);this.type="fibwedge";}defaultLevels(){return ex}anchorSchema(){return {min:3,max:3,slots:[{role:"apex",free:"both"},{role:"radius",free:"both"},{role:"angle",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}radial(t){let n=this.px(t,0),i=this.px(t,1),o=this.px(t,2);if(!n||!i||!o)return null;let s=Math.hypot(i[0]-n[0],i[1]-n[1]);if(s<1)return null;let a=Math.atan2(i[1]-n[1],i[0]-n[0]),l=Math.atan2(o[1]-n[1],o[0]-n[0]),c=Math.min(a,l),d=Math.max(a,l);return d-c>Math.PI&&([c,d]=[d,c+Math.PI*2]),{cx:n[0],cy:n[1],R0:s,a0:c,a1:d}}boundingLines(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return [];let o=[[n[0],n[1],i[0],i[1]]],s=this.px(t,2);if(s){let a=Math.hypot(i[0]-n[0],i[1]-n[1]),l=Math.hypot(s[0]-n[0],s[1]-n[1]);l>1e-6&&o.push([n[0],n[1],n[0]+(s[0]-n[0])/l*a,n[1]+(s[1]-n[1])/l*a]);}return o}};var tx=1.6180339887,np=Math.log(tx)/(Math.PI/2),nx=Math.PI/64,rx=Math.PI,ix=.5,In=class extends _{constructor(){super(...arguments);this.type="fibspiral";}anchorSchema(){return {min:2,max:2,slots:[{role:"center",free:"both"},{role:"edge",free:"both"}]}}spiralPoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time),c=Math.hypot(l-a,s-o);if(c<1)return null;let d=Math.atan2(s-o,l-a),u=Math.max(Math.log(ix/c)/np,-8*Math.PI*2),h=[];for(let p=u;p<=rx;p+=nx){let m=c*Math.exp(np*p),f=d+p;h.push([a+m*Math.cos(f),o+m*Math.sin(f)]);}return h}hitTest(t,n,i,o){let s=this.spiralPoints(i);return s!=null&&s.length>=2&&ar(t,n,s)<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.handlePoints(t);if(n.length<2)return null;let i=n.map(l=>l[0]),o=n.map(l=>l[1]),s=Math.min(...i),a=Math.min(...o);return {x:s,y:a,w:Math.max(...i)-s,h:Math.max(...o)-a}}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,...N]}}};var ox=ne([{ratio:.125,color:ut,label:"1/8"},{ratio:.25,color:ht,label:"1/4"},{ratio:.333,color:Qh,label:"1/3"},{ratio:.5,color:Mn,label:"1/2"},{ratio:1,color:As,label:"1/1"},{ratio:2,color:Qt,label:"2/1"},{ratio:3,color:Ot,label:"3/1"},{ratio:4,color:Sc,label:"4/1"},{ratio:8,color:kn,label:"8/1"}]),Ws=class extends re{constructor(){super(...arguments);this.type="gannfan";}defaultLevels(){return ox}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.yOf(n.price,this.paneId);if(s==null)return null;let a=t.xOf(i.time),l=i.price-n.price,c=[];for(let d of this.levels){if(!d.enabled)continue;let u=t.yOf(n.price+l*d.ratio,this.paneId);if(u==null)continue;let[h,p,m,f]=se(o,s,a,u,"right",t.width,t.height);c.push({color:d.color,x1:h,y1:p,x2:m,y2:f,numberText:d.label??String(d.ratio),numberX:a+5,numberY:u,numberAlign:"left",labelX:a+5,labelY:u});}return c}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var sx=ne([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),Gs=class extends re{constructor(){super(...arguments);this.type="gannbox";}defaultLevels(){return sx}corners(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.xOf(i.time),a=t.yOf(n.price,this.paneId),l=t.yOf(i.price,this.paneId);return a==null||l==null?null:{c1:n,c2:i,left:Math.min(o,s),right:Math.max(o,s),top:Math.min(a,l),bot:Math.max(a,l)}}entryLines(t){let n=this.corners(t);if(!n)return null;let{c1:i,c2:o,left:s,right:a,top:l,bot:c}=n,d=[];for(let h of this.levels){if(!h.enabled)continue;let p=t.yOf(i.price+h.ratio*(o.price-i.price),this.paneId);p!=null&&d.push({color:h.color,x1:s,y1:p,x2:a,y2:p,numberText:h.label??String(h.ratio),numberX:s-5,numberY:p,numberAlign:"right",labelX:s,labelY:p});let m=t.xOf(i.time+h.ratio*(o.time-i.time));d.push({color:h.color,x1:m,y1:l,x2:m,y2:c,numberText:"",numberX:m,numberY:l,numberAlign:"center",labelX:m,labelY:l});}let u=this.levels.find(h=>h.ratio===1)?.color??Ln;return d.push({color:u,x1:s,y1:l,x2:a,y2:c,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),d.push({color:u,x1:s,y1:c,x2:a,y2:l,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),d}hitTest(t,n,i,o){let s=this.corners(i);return s!=null&&ye(t,n,s.left,s.top,s.right,s.bot,o)}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var ax=ne([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),lx=[{label:"3x1",x:3,y:1,color:ut},{label:"2x1",x:2,y:1,color:ht},{label:"1x1",x:1,y:1,color:As},{label:"1x2",x:1,y:2,color:Qt},{label:"1x3",x:1,y:3,color:Ot}],Cc=[{k:.25,color:ut},{k:.5,color:ht},{k:.75,color:Mn},{k:1,color:Qt}],An=class extends re{constructor(){super(...arguments);this.type="gannsquare";}defaultLevels(){return ax}box(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {ox:a,oy:o,bx:l-a,py:s-o,left:Math.min(a,l),top:Math.min(o,s),right:Math.max(a,l),bot:Math.max(o,s)}}arcGeom(t){let n=this.box(t);return n?{ox:n.ox,oy:n.oy,bx:n.bx,py:n.py}:null}entryLines(t){let n=this.box(t);if(!n)return null;let i=this.anchors[0],o=this.anchors[1],s=[];for(let a of this.levels){if(!a.enabled)continue;let l=t.yOf(i.price+a.ratio*(o.price-i.price),this.paneId);l!=null&&s.push({color:a.color,x1:n.left,y1:l,x2:n.right,y2:l,numberText:a.label??String(a.ratio),numberX:n.left-5,numberY:l,numberAlign:"right",labelX:n.left,labelY:l});let c=t.xOf(i.time+a.ratio*(o.time-i.time));s.push({color:a.color,x1:c,y1:n.top,x2:c,y2:n.bot,numberText:"",numberX:c,numberY:n.top,numberAlign:"center",labelX:c,labelY:n.top});}for(let a of lx){let l,c;a.x>a.y?(l=n.ox+n.bx,c=n.oy+a.y/a.x*n.py):(c=n.oy+n.py,l=n.ox+a.x/a.y*n.bx),s.push({color:a.color,x1:n.ox,y1:n.oy,x2:l,y2:c,numberText:a.label,numberX:l+4,numberY:c,numberAlign:"left",labelX:l+4,labelY:c});}return s}hitTest(t,n,i,o){let s=this.box(i);return s!=null&&ye(t,n,s.left,s.top,s.right,s.bot,o)}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var Tc=[4,8,12,16,24,32,48,64],cx=24,dx=.75;function rp(r,e){if(!Number.isInteger(r)||!Number.isInteger(e)||e<=0)return false;let t=r*r-1;return e%2===1?t%e===0:e%8===0?t%e!==0?false:t/e%2!==0:false}function ip(r){let e=[];for(let t=0;t<r;t+=1)rp(t,r)&&e.push(t);return e}var Rn=class extends _{constructor(t){super(t);this.type="dedekind";this.maxCurvature===void 0&&(this.maxCurvature=cx);}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}box(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=Math.min(t.xOf(n.time),t.xOf(i.time)),l=Math.max(t.xOf(n.time),t.xOf(i.time)),c=Math.min(o,s),d=Math.max(o,s),u=l-a,h=d-c;if(u<1||h<1)return null;let p=h,m=u/p;return {left:a,right:l,top:c,bot:d,unitPx:p,x0:0,realSpan:m}}geodesics(t){let n=this.box(t);if(!n)return null;let{left:i,top:o,bot:s,unitPx:a,x0:l,realSpan:c}=n,d=Math.max(1,Math.min(64,Math.round(this.maxCurvature))),u=l-1/d,h=l+c+1/d,p=i+c*a,m=[],f=Math.floor(u*2),g=Math.ceil(h*2);for(let b=f;b<=g;b+=1){if(b%2===0)continue;let y=i+(b/2-l)*a;y<i-.5||y>p+.5||m.push({kind:"vline",x:y,y0:s,y1:o});}for(let b=1;b<=d;b+=1){let y=1/b,v=y*a;if(v<dx)continue;let w=ip(b);if(w.length===0)continue;let E=Math.floor(u)-1,x=Math.ceil(h)+1;for(let S=E;S<=x;S+=1)for(let P of w){let k=P/b+S;if(k+y<u||k-y>h)continue;let T=i+(k-l)*a;T+v<i-1||T-v>p+1||m.push({kind:"arc",cx:T,cy:s,r:v});}}return m}hitTest(t,n,i,o){let s=this.box(i);return s!=null&&ye(t,n,s.left,s.top,s.right,s.bot,o)}handlePoints(t){let n=this.box(t);return n?[[n.left,n.top],[n.right,n.bot]]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.box(t);return n?{x:n.left,y:n.top,w:n.right-n.left,h:n.bot-n.top}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,{path:"maxCurvature",label:"Max curvature",kind:"number",min:4,max:64,step:4,group:"behavior"},...N]}}writeProps(){return {maxCurvature:this.maxCurvature}}readProps(t){typeof t.maxCurvature=="number"&&Number.isFinite(t.maxCurvature)&&(this.maxCurvature=Math.max(1,Math.min(64,Math.round(t.maxCurvature))));}};var Ec=[3,4,5,6,8,10,12],Pc=[1.5,2,2.5,3,4,5],Us=6,ux=2;function Lc(r=Us){return [...tp(dr.length,r)]}function hx(r){if(!r||typeof r!="object")return null;let e=r;return typeof e.ratio!="number"||typeof e.color!="string"?null:{ratio:e.ratio,color:e.color,enabled:e.enabled!==false,...typeof e.label=="string"&&e.label?{label:e.label}:{}}}var ur={path:"showRatios",label:"Show ratios",kind:"boolean",group:"behavior"},De=class extends _{constructor(e){super(e),this.waveCount===void 0&&(this.waveCount=Us),this.showRatios===void 0&&(this.showRatios=true);let t=Array.isArray(e.props?.levels);this.levels||(this.levels=this.defaultLevels().map(n=>({...n}))),!t&&this.shouldSyncWaveCount()&&this.syncLevelsToWaveCount();}shouldSyncWaveCount(){return true}syncLevelsToWaveCount(){let e=Math.max(1,Math.min(this.levels.length,Math.round(this.waveCount)));this.waveCount=e;for(let t=0;t<this.levels.length;t+=1)this.levels[t].enabled=t<e;}editableLevels(){return this.levels}anchorSchema(){return {min:2,max:2,slots:[{role:"d1",free:"both"},{role:"d2",free:"both"}]}}geom(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);if(i==null||o==null)return null;let s=e.xOf(t.time),a=e.xOf(n.time),l=(s+a)/2,c=(i+o)/2,d=Math.hypot(a-s,o-i)/2;if(d<1)return null;let u=a-s,h=o-i,p=Math.hypot(u,h);p<1e-9?(u=1,h=0):(u/=p,h/=p);let m=this.levels.filter(x=>x.enabled&&x.ratio>0).slice().sort((x,S)=>x.ratio-S.ratio);if(m.length===0)return null;let f=Math.max(1,this.machNumber()),g=[];for(let x of m){let S=x.ratio*d;g.push({cx:l+f*(S-d)*u,cy:c+f*(S-d)*h,r:S,color:x.color,ratio:x.ratio});}let b=l-f*d*u,y=c-f*d*h,v=g[g.length-1].r,w=f*v+2*d,E=[];if(f<=1+1e-9){let x=-h,S=u;E.push([b-x*w,y-S*w,b+x*w,y+S*w]);}else {let x=Math.asin(1/f),S=Math.cos(x),P=Math.sin(x),k=(I,V,Y)=>[I*S-V*Y*P,I*Y*P+V*S],[T,M]=k(u,h,1),[L,C]=k(u,h,-1);E.push([b,y,b+T*w,y+M*w]),E.push([b,y,b+L*w,y+C*w]);}return {c0x:l,c0y:c,R:d,fx:u,fy:h,noseX:b,noseY:y,circles:g,rays:E}}hitTest(e,t,n,i){let o=this.geom(n);if(!o)return false;for(let s of o.circles)if(Math.abs(Math.hypot(e-s.cx,t-s.cy)-s.r)<=i)return true;return o.rays.some(s=>U(e,t,s[0],s[1],s[2],s[3])<=i)}handlePoints(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return [];let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?[]:[[e.xOf(t.time),i],[e.xOf(n.time),o]]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.geom(e);if(!t)return null;let n=t.noseX,i=t.noseX,o=t.noseY,s=t.noseY;for(let a of t.circles)n=Math.min(n,a.cx-a.r),i=Math.max(i,a.cx+a.r),o=Math.min(o,a.cy-a.r),s=Math.max(s,a.cy+a.r);for(let a of t.rays)n=Math.min(n,a[0],a[2]),i=Math.max(i,a[0],a[2]),o=Math.min(o,a[1],a[3]),s=Math.max(s,a[1],a[3]);return {x:n,y:o,w:i-n,h:s-o}}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}applySettings(e){if(super.applySettings(e),Object.prototype.hasOwnProperty.call(e,"waveCount")&&typeof this.waveCount=="number"){let t=Math.max(1,Math.min(this.levels.length,Math.round(this.waveCount)));this.waveCount=t;for(let n=0;n<this.levels.length;n+=1)this.levels[n].enabled=n<t;}}schema(){return {fields:[...F,{path:"waveCount",label:"Waves",kind:"number",min:3,max:12,step:1,group:"behavior"},ur,...N]}}writeProps(){return {waveCount:this.waveCount,showRatios:this.showRatios,levels:this.levels.map(e=>({...e}))}}readProps(e){if(typeof e.waveCount=="number"&&Number.isFinite(e.waveCount)&&(this.waveCount=Math.max(2,Math.min(12,Math.round(e.waveCount)))),typeof e.showRatios=="boolean"&&(this.showRatios=e.showRatios),Array.isArray(e.levels)){let t=e.levels.map(hx).filter(n=>n!=null);t.length&&(this.levels=t);}}},vi=class extends De{constructor(){super(...arguments);this.type="sonic";}defaultLevels(){return Lc(Us)}machNumber(){return 1}},yi=class extends De{constructor(t){super(t);this.type="supersonic";this.mach===void 0&&(this.mach=ux);}defaultLevels(){return Lc(Us)}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...F,{path:"mach",label:"Mach number",kind:"number",min:1.5,max:5,step:.5,group:"behavior"},{path:"waveCount",label:"Waves",kind:"number",min:3,max:12,step:1,group:"behavior"},ur,...N]}}writeProps(){return {...super.writeProps(),mach:this.mach}}readProps(t){super.readProps(t),typeof t.mach=="number"&&Number.isFinite(t.mach)&&(this.mach=Math.max(1.01,Math.min(20,t.mach)));}};var op=ne([.236,.382,.5,.618,.786,1,1.618,2.618,4.236,6.854,11.09]),px=2,Ys=class extends De{constructor(){super(...arguments);this.type="goldensonic";}shouldSyncWaveCount(){return false}defaultLevels(){return op}machNumber(){return 1}schema(){return {fields:[...F,ur,...N]}}},Ks=class extends De{constructor(t){super(t);this.type="goldensupersonic";this.mach===void 0&&(this.mach=px);}shouldSyncWaveCount(){return false}defaultLevels(){return op}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...F,{path:"mach",label:"Mach number",kind:"number",min:1.5,max:5,step:.5,group:"behavior"},ur,...N]}}writeProps(){return {...super.writeProps(),mach:this.mach}}readProps(t){super.readProps(t),typeof t.mach=="number"&&Number.isFinite(t.mach)&&(this.mach=Math.max(1.01,Math.min(20,t.mach)));}};var be=class extends _{legRatios(){return false}fillTriangles(){return []}necklineIndices(){return null}anchorSchema(){let e=this.vertexLabels().length,t=[];for(let n=0;n<e;n+=1)t.push({role:`p${n}`,free:"both"});return {min:e,max:e,slots:t}}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitTest(e,t,n,i){let o=this.handlePoints(n);return o.length>=2&&ar(e,t,o)<=i}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}patternName(){return null}ratioOk(e){return null}valid(){return null}ratioAt(e){let t=this.anchors[e-2],n=this.anchors[e-1],i=this.anchors[e];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-n.price)/o}schema(){return {fields:[...F,...this.fillTriangles().length?ee:[]]}}};var Xs=class extends be{constructor(){super(...arguments);this.type="xabcd";}vertexLabels(){return ["X","A","B","C","D"]}legRatios(){return true}fillTriangles(){return [[0,1,2],[2,3,4]]}};var js=class extends be{constructor(){super(...arguments);this.type="abcd";}vertexLabels(){return ["A","B","C","D"]}legRatios(){return true}};var qs=class extends be{constructor(){super(...arguments);this.type="elliottimpulse";}vertexLabels(){return ["1","2","3","4","5"]}};var Zs=class extends be{constructor(){super(...arguments);this.type="elliottcorrection";}vertexLabels(){return ["A","B","C"]}};var Js=class extends be{constructor(){super(...arguments);this.type="headshoulders";}vertexLabels(){return ["","LS","","H","","RS",""]}necklineIndices(){return [2,4]}};var Oe=class extends be{vertexLabels(){return ["X","A","B","C","D"]}legRatios(){return true}fillTriangles(){return [[0,1,2],[2,3,4]]}legValue(e){let[t,n,i,o,s]=this.anchors;if(!t||!n||!i||!o||!s)return null;let a=(u,h)=>Math.abs(h.price-u.price),l=a(t,n),c=a(n,i),d=a(i,o);switch(e){case "ab":return l<1e-9?null:c/l;case "bc":return c<1e-9?null:d/c;case "cd":return d<1e-9?null:a(o,s)/d;default:return l<1e-9?null:a(n,s)/l}}inBand(e,t){return e!=null&&e>=t.min&&e<=t.max}ratioOk(e){let t=this.ranges();return e===2?this.inBand(this.legValue("ab"),t.ab):e===3?this.inBand(this.legValue("bc"),t.bc):e===4?this.inBand(this.legValue("cd"),t.cd):null}valid(){if(this.anchors.length<5)return null;let e=this.ranges();return this.inBand(this.legValue("ab"),e.ab)&&this.inBand(this.legValue("bc"),e.bc)&&this.inBand(this.legValue("cd"),e.cd)&&this.inBand(this.legValue("ad"),e.ad)}};var Qs=class extends Oe{constructor(){super(...arguments);this.type="gartley";}patternName(){return "Gartley"}ranges(){return {ab:{min:.55,max:.68},bc:{min:.382,max:.886},cd:{min:1.13,max:1.618},ad:{min:.74,max:.83}}}};var ea=class extends Oe{constructor(){super(...arguments);this.type="bat";}patternName(){return "Bat"}ranges(){return {ab:{min:.382,max:.5},bc:{min:.382,max:.886},cd:{min:1.618,max:2.618},ad:{min:.84,max:.92}}}};var ta=class extends Oe{constructor(){super(...arguments);this.type="butterfly";}patternName(){return "Butterfly"}ranges(){return {ab:{min:.74,max:.83},bc:{min:.382,max:.886},cd:{min:1.618,max:2.618},ad:{min:1.272,max:1.618}}}};var na=class extends Oe{constructor(){super(...arguments);this.type="crab";}patternName(){return "Crab"}ranges(){return {ab:{min:.382,max:.618},bc:{min:.382,max:.886},cd:{min:2.618,max:3.618},ad:{min:1.55,max:1.69}}}};var ra=class extends Oe{constructor(){super(...arguments);this.type="shark";}patternName(){return "Shark"}ranges(){return {ab:{min:.382,max:.618},bc:{min:1.13,max:1.618},cd:{min:1.618,max:2.24},ad:{min:.886,max:1.13}}}};var mx={min:1.272,max:1.414},fx={min:.74,max:.83},ia=class extends Oe{constructor(){super(...arguments);this.type="cypher";}patternName(){return "Cypher"}ranges(){return {ab:{min:.382,max:.618},bc:{min:0,max:1/0},cd:{min:0,max:1/0},ad:{min:0,max:1/0}}}xcOverXa(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[3];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-t.price)/o}cdOverXc(){let t=this.anchors[0],n=this.anchors[3],i=this.anchors[4];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-n.price)/o}ratioOk(t){return t===2?this.inBand(this.legValue("ab"),this.ranges().ab):null}valid(){return this.anchors.length<5?null:this.inBand(this.legValue("ab"),this.ranges().ab)&&this.inBand(this.xcOverXa(),mx)&&this.inBand(this.cdOverXc(),fx)}};function sp(r){return `${r>=0?"+":""}${r.toFixed(2)}`}function wi(r){let e=Math.abs(r),t=864e5,n=36e5,i=6e4;if(e>=t){let o=Math.floor(e/t),s=Math.round(e%t/n);return s?`${o}d ${s}h`:`${o}d`}if(e>=n){let o=Math.floor(e/n),s=Math.round(e%n/i);return s?`${o}h ${s}m`:`${o}h`}return e>=i?`${Math.round(e/i)}m`:`${Math.round(e/1e3)}s`}var Dn=class extends _{constructor(e){super(e),this.showPrice===void 0&&(this.showPrice=true),this.showDate===void 0&&(this.showDate=true);}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}measureLabel(e){let t=[];return this.showPrice&&t.push(this.priceLabel()),this.showDate&&t.push(this.timeLabel(e)),t}isUp(){let e=this.anchors[0],t=this.anchors[1];return e!=null&&t!=null&&t.price>=e.price}priceLabel(){let e=this.anchors[0],t=this.anchors[1];if(!e||!t)return "";let n=t.price-e.price,i=e.price!==0?n/e.price*100:0;return `${sp(n)} (${sp(i)}%)`}timeLabel(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return "";let i=wi(n.time-t.time),o=e.barsBetween?Math.round(e.barsBetween(t.time,n.time)):null;return o!=null?`${o} bars, ${i}`:i}rect(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:{x1:e.xOf(t.time),y1:i,x2:e.xOf(n.time),y2:o}}hitTest(e,t,n,i){let o=this.rect(n);return o!=null&&ye(e,t,o.x1,o.y1,o.x2,o.y2,i)}handlePoints(e){let t=this.rect(e);return t?[[t.x1,t.y1],[t.x2,t.y2]]:[]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.rect(e);return t?{x:Math.min(t.x1,t.x2),y:Math.min(t.y1,t.y2),w:Math.abs(t.x2-t.x1),h:Math.abs(t.y2-t.y1)}:null}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[{path:"showPrice",label:"Show price",kind:"boolean",group:"behavior"},{path:"showDate",label:"Show date",kind:"boolean",group:"behavior"},...F.filter(e=>e.path!=="style.lineColor"),{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Ze,group:"text"}]}}writeProps(){return {showPrice:this.showPrice,showDate:this.showDate}}readProps(e){typeof e.showPrice=="boolean"&&(this.showPrice=e.showPrice),typeof e.showDate=="boolean"&&(this.showDate=e.showDate);}};var oa=class extends Dn{constructor(){super(...arguments);this.type="datepricerange";}};var sa=[{value:"long",label:"Long"},{value:"short",label:"Short"}],de=class de extends _{constructor(t){super(t);this.type="position";this.riskPercent===void 0&&(this.riskPercent=de.DEFAULT_RISK_PERCENT),this.accountBalance===void 0&&(this.accountBalance=de.DEFAULT_ACCOUNT_BALANCE),this.showText===void 0&&(this.showText=true),this.showHeader===void 0&&(this.showHeader=true),this.showPrices===void 0&&(this.showPrices=false),this.showLossSize===void 0&&(this.showLossSize=true),this.showTargetLabel===void 0&&(this.showTargetLabel=true),this.showStopLabel===void 0&&(this.showStopLabel=true),this.profitColor===void 0&&(this.profitColor=de.DEFAULT_PROFIT_COLOR),this.lossColor===void 0&&(this.lossColor=de.DEFAULT_LOSS_COLOR);}directionLabel(){let t=this.prices();return t&&t.target>=t.entry?"LONG":"SHORT"}get direction(){return this.directionLabel()==="LONG"?"long":"short"}set direction(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];!n||!i||!o||(t==="long"||t==="short")&&t!==this.direction&&(i.price=2*n.price-i.price,o.price=2*n.price-o.price);}get quantity(){return this.positionSize()}set quantity(t){let n=this.prices();if(!n||!Number.isFinite(t)||t<0)return;let i=Math.abs(n.entry-n.stop);i<1e-9||this.accountBalance<=0||(this.riskPercent=t*i/this.accountBalance*100);}get entryPrice(){return this.anchors[0]?.price??0}set entryPrice(t){let n=this.anchors[0];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(0));}get stopPrice(){return this.anchors[1]?.price??0}set stopPrice(t){let n=this.anchors[1];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(1));}get targetPrice(){return this.anchors[2]?.price??0}set targetPrice(t){let n=this.anchors[2];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(2));}anchorSchema(){return {min:2,max:2,slots:[{role:"entry",free:"both"},{role:"stop",free:"both"},{role:"target",free:"both"}]}}onPlaced(t){let n=this.anchors[0];if(!n)return;let i=t.xOf(n.time),o=t.yOf(n.price,this.paneId);if(o==null)return;let s=this.anchors[1],a=s?t.yOf(s.price,this.paneId):null,l,c;s&&a!=null&&Math.abs(a-o)>=de.MIN_DRAG_PX?(l=a,c=i+Math.max(Math.abs(t.xOf(s.time)-i),de.MIN_WIDTH_PX)):(l=o-de.DEFAULT_RISK_PX*de.DEFAULT_RR,c=i+de.DEFAULT_WIDTH_PX);let d=o-(l-o)/de.DEFAULT_RR,u=t.pxToPoint(c,o,this.paneId).time;this.anchors=[{time:n.time,price:n.price},{time:u,price:t.pxToPoint(i,d,this.paneId).price},{time:u,price:t.pxToPoint(i,l,this.paneId).price}];}constrainHandleDrag(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return;let s=Math.sign(i.price-n.price),a=Math.sign(o.price-n.price);s===0||a===0||s!==a||(t===2?i.price=2*n.price-i.price:o.price=2*n.price-o.price);}resolved(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;if(this.anchors[2])return [t,n,this.anchors[2]];let i={time:n.time,price:t.price-(n.price-t.price)/de.DEFAULT_RR};return [t,i,n]}prices(){let t=this.resolved();return t?{entry:t[0].price,stop:t[1].price,target:t[2].price}:null}rr(){let t=this.prices();if(!t)return 0;let n=Math.abs(t.entry-t.stop);return n<1e-9?0:Math.abs(t.target-t.entry)/n}rewardPct(){let t=this.prices();return t&&t.entry!==0?Math.abs(t.target-t.entry)/t.entry*100:0}riskPct(){let t=this.prices();return t&&t.entry!==0?Math.abs(t.entry-t.stop)/t.entry*100:0}dollarLoss(){return Math.max(0,this.accountBalance)*(Math.max(0,this.riskPercent)/100)}positionSize(){let t=this.prices();if(!t)return 0;let n=Math.abs(t.entry-t.stop);return n<1e-9?0:this.dollarLoss()/n}headerLabel(){return `${this.directionLabel()} \xB7 R:R ${this.rr().toFixed(2)}`}lossSizeLabel(){return `Loss $${gx(this.dollarLoss())} \xB7 Size ${bx(this.positionSize())}`}targetLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${ap(t.target)}`:"";return `Target +${this.rewardPct().toFixed(2)}%${n}`}stopLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${ap(t.stop)}`:"";return `Stop \u2212${this.riskPct().toFixed(2)}%${n}`}levelDisplayValue(t,n){let i=this.prices();if(!i)return 0;let o=t==="stop"?i.stop:i.target;return lp(n==="price"?o:Math.abs(o-i.entry))}levelPriceFromDisplay(t,n,i){let o=this.prices();if(!o||n==="price")return i;let s=t==="stop"?o.stop:o.target,a=Math.sign(s-o.entry);return a===0&&(a=(t==="target"?1:-1)*(this.direction==="long"?1:-1)),o.entry+a*Math.abs(i)}box(t){let n=this.handlePoints(t);if(n.length<3)return null;let i=n.map(o=>o[0]);return {x1:Math.min(...i),x2:Math.max(...i),ey:n[0][1],sy:n[1][1],ty:n[2][1]}}layout(t){return this.box(t)}hitTest(t,n,i,o){let s=this.box(i);if(!s)return false;let a=Math.min(s.ey,s.sy,s.ty),l=Math.max(s.ey,s.sy,s.ty);return ye(t,n,s.x1,a,s.x2,l,o)}handlePoints(t){let n=this.resolved();if(!n)return [];let i=[];for(let o of n){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.box(t);if(!n)return null;let i=Math.min(n.ey,n.sy,n.ty);return {x:n.x1,y:i,w:n.x2-n.x1,h:Math.max(n.ey,n.sy,n.ty)-i}}priceRange(){let t=this.resolved();if(!t)return null;let n=t.map(i=>i.price);return {min:Math.min(...n),max:Math.max(...n)}}schema(){return {fields:[{path:"riskPercent",label:"Risk %",kind:"number",min:0,max:100,step:.1,group:"behavior"},{path:"accountBalance",label:"Account balance",kind:"number",min:0,max:1e12,step:1,group:"behavior"},{path:"quantity",label:"Position size",kind:"number",group:"behavior"},{path:"direction",label:"Direction",kind:"select",options:sa,group:"behavior"},{path:"entryPrice",label:"Entry price",kind:"number",group:"behavior"},{path:"stopPrice",label:"Stop price",kind:"number",group:"behavior"},{path:"targetPrice",label:"Target price",kind:"number",group:"behavior"},{path:"showText",label:"Show text",kind:"boolean",group:"behavior"},{path:"showHeader",label:"Show direction & ratio",kind:"boolean",group:"behavior"},{path:"showLossSize",label:"Show loss & size",kind:"boolean",group:"behavior"},{path:"showTargetLabel",label:"Show target label",kind:"boolean",group:"behavior"},{path:"showStopLabel",label:"Show stop label",kind:"boolean",group:"behavior"},{path:"showPrices",label:"Show level prices",kind:"boolean",group:"behavior"},{path:"profitColor",label:"Profit zone",kind:"color",group:"fill"},{path:"lossColor",label:"Loss zone",kind:"color",group:"fill"},...F.filter(t=>t.path!=="style.lineColor"),{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Ze,group:"text"}]}}writeProps(){return {riskPercent:this.riskPercent,accountBalance:this.accountBalance,showText:this.showText,showHeader:this.showHeader,showPrices:this.showPrices,showLossSize:this.showLossSize,showTargetLabel:this.showTargetLabel,showStopLabel:this.showStopLabel,profitColor:this.profitColor,lossColor:this.lossColor}}readProps(t){typeof t.riskPercent=="number"&&Number.isFinite(t.riskPercent)&&(this.riskPercent=t.riskPercent),typeof t.accountBalance=="number"&&Number.isFinite(t.accountBalance)&&(this.accountBalance=t.accountBalance),typeof t.showText=="boolean"&&(this.showText=t.showText),typeof t.showHeader=="boolean"&&(this.showHeader=t.showHeader),typeof t.showPrices=="boolean"&&(this.showPrices=t.showPrices),typeof t.showLossSize=="boolean"&&(this.showLossSize=t.showLossSize),typeof t.showTargetLabel=="boolean"&&(this.showTargetLabel=t.showTargetLabel),typeof t.showStopLabel=="boolean"&&(this.showStopLabel=t.showStopLabel),typeof t.profitColor=="string"&&(this.profitColor=t.profitColor),typeof t.lossColor=="string"&&(this.lossColor=t.lossColor);}};de.DEFAULT_RR=2,de.MIN_DRAG_PX=6,de.DEFAULT_RISK_PX=64,de.DEFAULT_WIDTH_PX=150,de.MIN_WIDTH_PX=48,de.DEFAULT_RISK_PERCENT=1,de.DEFAULT_ACCOUNT_BALANCE=1e4,de.DEFAULT_PROFIT_COLOR=Zo,de.DEFAULT_LOSS_COLOR=Jo;var We=de;function gx(r){if(!Number.isFinite(r))return "0";let e=Math.round(r*100)/100;return Number.isInteger(e)?String(e):e.toFixed(2)}function bx(r){return !Number.isFinite(r)||r===0?"0":r>=100?r.toFixed(2):r>=1?r.toFixed(4).replace(/\.?0+$/,""):r.toPrecision(4).replace(/\.?0+$/,"")}function ap(r){return Number.isFinite(r)?Math.abs(r)>=1?r.toFixed(2):r.toPrecision(4).replace(/\.?0+$/,""):"0"}function lp(r){return Math.round(r*1e8)/1e8}var On=[{value:"auto",label:"Auto",ms:0},{value:"1",label:"1m",ms:6e4},{value:"5",label:"5m",ms:3e5},{value:"15",label:"15m",ms:9e5},{value:"30",label:"30m",ms:18e5},{value:"60",label:"1h",ms:36e5},{value:"240",label:"4h",ms:144e5},{value:"D",label:"1D",ms:864e5}];function xi(r){let e=On.find(n=>n.value===r);if(e)return e.label;let t=Number(r);return Number.isFinite(t)&&t>0?t%1440===0?`${t/1440}D`:t%60===0?`${t/60}h`:`${t}m`:r}function cp(){return {timeframe:"auto",upColor:"",downColor:""}}var Fe=class extends _{constructor(t){super(t);this.type="magnifier";this.chipRect=null;this.magnifier||(this.magnifier=cp());}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}placementMode(){return "drag"}rect(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{x1:t.xOf(n.time),y1:o,x2:t.xOf(i.time),y2:s}}hitTest(t,n,i,o){let s=this.rect(i);return s?ye(t,n,s.x1,s.y1,s.x2,s.y2)?true:[[s.x1,s.y1,s.x2,s.y1],[s.x2,s.y1,s.x2,s.y2],[s.x2,s.y2,s.x1,s.y2],[s.x1,s.y2,s.x1,s.y1]].some(l=>U(t,n,l[0],l[1],l[2],l[3])<=o):false}handlePoints(t){let n=this.rect(t);return n?[[n.x1,n.y1],[n.x2,n.y2]]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.rect(t);return n?{x:Math.min(n.x1,n.x2),y:Math.min(n.y1,n.y2),w:Math.abs(n.x2-n.x1),h:Math.abs(n.y2-n.y1)}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"magnifier.timeframe",label:"Timeframe",kind:"select",options:On,group:"behavior"},...F.map(t=>({...t,label:t.label.replace("Line","Border")})),{path:"magnifier.upColor",label:"Up candles",kind:"color",group:"fill"},{path:"magnifier.downColor",label:"Down candles",kind:"color",group:"fill"}]}}writeProps(){return {...this.magnifier}}readProps(t){this.magnifier={...cp(),...t};}};var Si=new Map;function O(r){Si.set(r.type,r);}function Qe(r){return Si.get(r)}function aa(){return [...Si.values()]}function en(r,e){let t=Si.get(r);if(!t)return null;let n={...t.defaultStyle,...e.style??{}};return t.create({...e,style:n})}function Mc(r){let e=en(r.type,{paneId:r.paneId});if(!e)return;r.style={...e.style};let t=r.text?.value;e.text?(r.text={...e.text},t!==void 0&&(r.text.value=t)):r.text=void 0;let n=e.serialize().props;n!==void 0&&r.applyProps(n);}function pt(r){let e=Si.get(r.type);return e?e.create(r):null}var vx=A('<line x1="4" y1="19" x2="20" y2="5"/>'),yx=A('<line x1="3" y1="12" x2="21" y2="12"/>');O({type:"trendline",group:"lines",label:"Trend Line",icon:vx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ns(r)});O({type:"hline",group:"lines",label:"Horizontal Line",icon:yx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"dashed"},create:r=>new rs(r)});var wx=A('<line x1="3" y1="20" x2="21" y2="6"/><circle cx="3" cy="20" r="1.6" fill="currentColor"/>'),xx=A('<rect x="4" y="6" width="16" height="12" rx="1"/>'),Sx=A('<path d="M5 6h14M12 6v13"/>');O({type:"ray",group:"lines",label:"Ray",icon:wx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new is(r)});var Cx=A('<path d="M5 19 19 5"/><path d="M5 19 8.5 19M5 19 5 15.5"/><path d="M19 5 15.5 5M19 5 19 8.5"/>'),Tx=A('<line x1="12" y1="3" x2="12" y2="21"/>'),Ex=A('<line x1="5" y1="12" x2="21" y2="12"/><circle cx="5" cy="12" r="1.6" fill="currentColor"/>'),Px=A('<line x1="3" y1="12" x2="21" y2="12"/><line x1="12" y1="3" x2="12" y2="21"/>'),Lx=A('<path d="M4 20 20 4"/><rect x="9" y="9" width="9" height="6" rx="1"/>'),Mx=A('<path d="M4 20 20 6"/><path d="M4 20 15 20"/><path d="M11 20a7 7 0 0 0-2-4.9"/>');O({type:"extendedline",group:"lines",label:"Extended Line",icon:Cx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new os(r)});O({type:"vline",group:"lines",label:"Vertical Line",icon:Tx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ss(r)});O({type:"hray",group:"lines",label:"Horizontal Ray",icon:Ex,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new as(r)});O({type:"crossline",group:"lines",label:"Cross Line",icon:Px,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new ls(r)});O({type:"infoline",group:"lines",label:"Info Line",icon:Lx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new cs(r)});O({type:"trendangle",group:"lines",label:"Trend Angle",icon:Mx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ds(r)});O({type:"box",group:"shapes",label:"Rectangle",icon:xx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}26`},create:r=>new us(r)});O({type:"text",group:"annotations",label:"Text",icon:Sx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Rt(r)});var kx=A('<path d="M5 4h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-6l-5 5v-5H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z"/>');O({type:"callout",group:"annotations",label:"Callout",icon:kx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new dt(r)});var Ix=A('<path d="M5 4h14a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-7l-4 4v-4H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Z"/><path d="M8 8.5h8M8 12h5"/>'),Ax=A('<rect x="10" y="4.5" width="11" height="8" rx="1.5"/><path d="M10 8.5 4 16"/><circle cx="3.5" cy="16.5" r="1.6" fill="currentColor" stroke="none"/>'),Rx=A('<path d="M5 4.5h14a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-7l-4 4v-4H5a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2Z"/>'),Dx=A('<path d="M3 12 7 8h12a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H7Z"/><path d="M10.5 12.5h6" stroke-width="1.4"/>'),Ox=A('<path d="M12 11.5V21"/><rect x="5" y="4" width="14" height="7" rx="1"/><path d="M9 7.5h6"/>');O({type:"note",group:"annotations",label:"Note",icon:Ix,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new yn(r)});O({type:"pricenote",group:"annotations",label:"Price Note",icon:Ax,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new xn(r)});O({type:"comment",group:"annotations",label:"Comment",icon:Rx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new Sn(r)});O({type:"pricelabel",group:"annotations",label:"Price Label",icon:Dx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new wn(r)});O({type:"signpost",group:"annotations",label:"Signpost",icon:Ox,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new Cn(r)});var Fx=A('<line x1="3" y1="16" x2="21" y2="8"/><line x1="3" y1="21" x2="21" y2="13"/>'),Nx=A('<line x1="3" y1="7" x2="21" y2="10"/><line x1="3" y1="18" x2="21" y2="14"/>'),Vx=A('<circle cx="4" cy="12" r="1.6" fill="currentColor"/><line x1="4" y1="12" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>');O({type:"parallelchannel",group:"channels",label:"Parallel Channel",icon:Fx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new hs(r)});O({type:"disjointchannel",group:"channels",label:"Disjoint Channel",icon:Nx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new ps(r)});var _x=A('<line x1="3" y1="7" x2="21" y2="7"/><line x1="3" y1="18" x2="21" y2="11"/>');O({type:"flattopbottom",group:"channels",label:"Flat Top/Bottom",icon:_x,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new ms(r)});var Bx=A('<line x1="3" y1="8" x2="21" y2="4"/><line x1="3" y1="16" x2="21" y2="12"/><line x1="3" y1="12" x2="21" y2="8" stroke-dasharray="3 3"/>');O({type:"regressionchannel",group:"channels",label:"Linear Regression",icon:Bx,defaultStyle:{lineColor:Pe,lineWidth:1,lineStyle:"solid"},create:r=>new Dt(r)});O({type:"pitchfork",group:"pitchforks",label:"Pitchfork",icon:Vx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new fs(r)});var Hx=A('<circle cx="4" cy="8" r="1.6" fill="currentColor"/><line x1="4" y1="8" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>'),zx=A('<circle cx="6" cy="9" r="1.6" fill="currentColor"/><line x1="6" y1="9" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>'),$x=A('<line x1="4" y1="12" x2="10" y2="12"/><line x1="10" y1="8" x2="10" y2="16"/><line x1="10" y1="8" x2="21" y2="8"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="16" x2="21" y2="16"/>');O({type:"schiffpitchfork",group:"pitchforks",label:"Schiff Pitchfork",icon:Hx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new gs(r)});O({type:"modifiedschiffpitchfork",group:"pitchforks",label:"Modified Schiff Pitchfork",icon:zx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new bs(r)});O({type:"insidepitchfork",group:"pitchforks",label:"Inside Pitchfork",icon:$x,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new vs(r)});var Wx=A('<path d="M7 7h10v10"/><path d="M7 17 17 7"/>'),Gx=A('<ellipse cx="12" cy="12" rx="9" ry="6"/>'),Ux=A('<path d="M12 4 20 19 4 19Z"/>');O({type:"arrow",group:"shapes",label:"Arrow",icon:Wx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",arrowRight:true},create:r=>new ys(r)});O({type:"ellipse",group:"shapes",label:"Ellipse",icon:Gx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new ws(r)});O({type:"triangle",group:"shapes",label:"Triangle",icon:Ux,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new xs(r)});var Yx=A('<polyline points="3 17 9 10 13 14 21 5"/>'),Kx=A('<path d="M9.5 12 17 4.5a2.12 2.12 0 0 1 3 3L12.5 15"/><path d="M7 14a3 3 0 0 0-3 3c0 1.3-1.2 1.5-1.5 2 .8.9 2 1.5 3.5 1.5a3.5 3.5 0 0 0 3.5-3.5 3 3 0 0 0-2.5-3Z"/>'),Xx=A('<path d="M9 11 15 5l4 4-6 6H9Z"/><path d="M9 15l-2 2"/><path d="M4 21h6"/>');O({type:"polyline",group:"shapes",label:"Polyline",icon:Yx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Ss(r)});O({type:"freehand",group:"shapes",label:"Brush",icon:Kx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Cs(r)});O({type:"highlighter",group:"shapes",label:"Highlighter",icon:Xx,defaultStyle:{lineColor:`${kh}59`,lineWidth:14,lineStyle:"solid"},create:r=>new Ts(r)});var jx=A('<circle cx="12" cy="12" r="8"/>'),qx=A('<path d="M5 14 9.5 5 19 10 14.5 19 Z"/>'),Zx=A('<path d="M4 19 9 11 13 14 17 8 20 4"/><path d="M17.2 5.5 20 4 19.4 7.1"/>'),Jx=A('<path d="M4 17a8 8 0 0 1 16 0"/><path d="M4 17 20 17"/>'),Qx=A('<path d="M4 18Q12 1 20 14"/>'),eS=A('<path d="M12 5 12 19"/><path d="M6 11 12 5 18 11"/>'),tS=A('<path d="M12 5 12 19"/><path d="M6 13 12 19 18 13"/>');O({type:"circle",group:"shapes",label:"Circle",icon:jx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new Es(r)});O({type:"rotatedrect",group:"shapes",label:"Rotated Rectangle",icon:qx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}26`},create:r=>new Ps(r)});O({type:"path",group:"shapes",label:"Path",icon:Zx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Ls(r)});O({type:"arc",group:"shapes",label:"Arc",icon:Jx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}26`},create:r=>new Ms(r)});O({type:"curve",group:"shapes",label:"Curve",icon:Qx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ks(r)});O({type:"arrowmarkup",group:"shapes",label:"Arrow Mark Up",icon:eS,defaultStyle:{lineColor:q,lineWidth:1,lineStyle:"solid"},create:r=>new pi(r)});O({type:"arrowmarkdown",group:"shapes",label:"Arrow Mark Down",icon:tS,defaultStyle:{lineColor:X,lineWidth:1,lineStyle:"solid"},create:r=>new mi(r)});var nS=A('<path d="M6 21V4"/><path d="M6 5h11l-2.5 3.5L17 12H6" fill="currentColor" stroke="none"/>'),rS=A('<path d="m12 3 2.6 5.8 6.4.6-4.8 4.2 1.4 6.2L12 16.9 6.4 19.8 7.8 13.6 3 9.4l6.4-.6Z"/>');O({type:"flagmark",group:"stamps",label:"Flag",icon:nS,defaultStyle:{lineColor:Ee,lineWidth:1,lineStyle:"solid"},create:r=>new fi(r)});O({type:"iconstamp",group:"stamps",label:"Icon",icon:rS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new gi(r)});var iS=A('<line x1="3" y1="5" x2="21" y2="5"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="3" y1="14" x2="21" y2="14"/><line x1="3" y1="19" x2="21" y2="19"/>'),oS=A('<line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="11" x2="21" y2="11"/><line x1="3" y1="15" x2="14" y2="15"/><line x1="3" y1="20" x2="14" y2="20"/>');O({type:"fibretracement",group:"fibonacci",label:"Fib Retracement",icon:iS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Rs(r)});O({type:"fibextension",group:"fibonacci",label:"Fib Extension",icon:oS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ds(r)});var sS=A('<path d="M3 20 10 9l4 5"/><path d="M14 14h7M14 9h7M14 4h7"/>');O({type:"fibextensiontrend",group:"fibonacci",label:"Trend-Based Fib Extension",icon:sS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Os(r)});var aS=A('<path d="M4 20 20 5M4 20 21 11M4 20 21 17M4 20 20 20"/>'),lS=A('<path d="M3 5v14M6 5v14M11 5v14M19 5v14"/>');O({type:"fibfan",group:"fibonacci",label:"Fib Fan",icon:aS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Fs(r)});O({type:"fibtimezones",group:"fibonacci",label:"Fib Time Zones",icon:lS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"dashed"},create:r=>new Ns(r)});var cS=A('<path d="M3 18 18 9M5 21 20 12M6 13 21 4"/>'),dS=A('<path d="M4 4 20 20M4 4 20 12M4 4 12 20M4 4 20 4M4 4 4 20"/>'),uS=A('<path d="M3 19 9 8M9 8 12 5v14M14 5v14M18 5v14M21 5v14"/>');O({type:"fibchannel",group:"fibonacci",label:"Fib Channel",icon:cS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Vs(r)});O({type:"fibspeedfan",group:"fibonacci",label:"Fib Speed Resistance Fan",icon:dS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new _s(r)});O({type:"trendfibtime",group:"fibonacci",label:"Trend-Based Fib Time",icon:uS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"dashed"},create:r=>new Bs(r)});var hS=A('<circle cx="12" cy="12" r="3"/><circle cx="12" cy="12" r="6.5"/><circle cx="12" cy="12" r="10"/>'),pS=A('<path d="M8 20a4 4 0 0 1 8 0"/><path d="M4.5 20a7.5 7.5 0 0 1 15 0"/><circle cx="12" cy="20" r="1.4" fill="currentColor" stroke="none"/>'),mS=A('<path d="M4 20 20 16M4 20 14 4"/><path d="M11.8 18.1A8 8 0 0 0 8.2 13.2"/><path d="M16.6 16.9A13 13 0 0 0 10.9 9"/>'),fS=A('<path d="M13 12a2 2 0 1 1-2-2 4 4 0 0 1 4 4 6 6 0 0 1-9 5.2 9 9 0 0 1 .5-15"/>');O({type:"fibcircles",group:"fibonacci",label:"Fib Circles",icon:hS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Hs(r)});O({type:"fibarcs",group:"fibonacci",label:"Fib Speed Resistance Arcs",icon:pS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new zs(r)});O({type:"fibwedge",group:"fibonacci",label:"Fib Wedge",icon:mS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new $s(r)});O({type:"fibspiral",group:"fibonacci",label:"Fib Spiral",icon:fS,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new In(r)});var gS=A('<path d="M4 20 20 20M4 20 20 13M4 20 20 6M4 20 15 4M4 20 9 4M4 20 4 4"/>'),bS=A('<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M4 12h16M12 4v16M4 4 20 20" opacity="0.6"/>');O({type:"gannfan",group:"fibonacci",label:"Gann Fan",icon:gS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ws(r)});O({type:"gannbox",group:"fibonacci",label:"Gann Box",icon:bS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Gs(r)});var vS=A('<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M4 20 20 4M4 20 20 12M4 20 12 4" opacity="0.7"/><path d="M4 20a16 16 0 0 1 16-16" opacity="0.5"/>');O({type:"gannsquare",group:"fibonacci",label:"Gann Square",icon:vS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new An(r)});var yS=A('<path d="M2 20h20"/><path d="M4 20a8 8 0 0 1 16 0" opacity="0.9"/><path d="M6 20a4 4 0 0 1 8 0" opacity="0.75"/><path d="M10 20a2 2 0 0 1 4 0" opacity="0.6"/><path d="M8 20v-6M12 20v-9M16 20v-6" opacity="0.45"/>');O({type:"dedekind",group:"geometry",label:"Dedekind Tessellation",icon:yS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Rn(r)});var wS=A('<circle cx="16" cy="12" r="5" opacity="0.55"/><circle cx="13" cy="12" r="3.5" opacity="0.75"/><circle cx="10.5" cy="12" r="2"/><path d="M8 4v16"/>'),xS=A('<circle cx="17" cy="12" r="4.5" opacity="0.45"/><circle cx="13" cy="12" r="3" opacity="0.7"/><circle cx="10" cy="12" r="1.6"/><path d="M6 12 16 5M6 12 16 19"/>');O({type:"sonic",group:"geometry",label:"Sonic",icon:wS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new vi(r)});O({type:"supersonic",group:"geometry",label:"Supersonic",icon:xS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new yi(r)});var SS=A('<circle cx="16" cy="12" r="5" opacity="0.4"/><circle cx="13" cy="12" r="3.2" opacity="0.65"/><circle cx="10.8" cy="12" r="1.8"/><path d="M8 4v16"/><path d="M15 8.5h2M12.5 10h2" opacity="0.5"/>'),CS=A('<circle cx="17" cy="12" r="4.5" opacity="0.4"/><circle cx="12.5" cy="12" r="2.8" opacity="0.65"/><circle cx="9.8" cy="12" r="1.4"/><path d="M6 12 16 5M6 12 16 19"/>');O({type:"goldensonic",group:"geometry",label:"Golden Sonic",icon:SS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ys(r)});O({type:"goldensupersonic",group:"geometry",label:"Golden Supersonic",icon:CS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ks(r)});var TS=A('<path d="M3 18 7 8 11 14 15 6 20 16"/>'),ES=A('<path d="M4 17 9 7 14 15 20 5"/>'),PS=A('<path d="M3 19 8 9 12 13 17 5 21 9"/>'),LS=A('<path d="M4 7 11 16 20 9"/>'),MS=A('<path d="M3 18 6 12 9 16 12 5 15 16 18 12 21 18"/>');O({type:"xabcd",group:"patterns",label:"XABCD Pattern",icon:TS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Xs(r)});O({type:"abcd",group:"patterns",label:"ABCD Pattern",icon:ES,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new js(r)});O({type:"elliottimpulse",group:"patterns",label:"Elliott Impulse Wave (1-5)",icon:PS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new qs(r)});O({type:"elliottcorrection",group:"patterns",label:"Elliott Correction Wave (ABC)",icon:LS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Zs(r)});O({type:"headshoulders",group:"patterns",label:"Head & Shoulders",icon:MS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Js(r)});var kS=A('<path d="M3 17 7 6 12 14 17 5 21 16"/><path d="M3 17 21 16" opacity="0.45"/>'),hr={group:"patterns",icon:kS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"}};O({type:"gartley",label:"Gartley",...hr,create:r=>new Qs(r)});O({type:"bat",label:"Bat",...hr,create:r=>new ea(r)});O({type:"butterfly",label:"Butterfly",...hr,create:r=>new ta(r)});O({type:"crab",label:"Crab",...hr,create:r=>new na(r)});O({type:"shark",label:"Shark",...hr,create:r=>new ra(r)});O({type:"cypher",label:"Cypher",...hr,create:r=>new ia(r)});var IS=A('<rect x="4" y="6" width="16" height="12" rx="1"/><path d="M4 18 20 6" opacity="0.5"/>');O({type:"datepricerange",group:"measure",label:"Date & Price Range",icon:IS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new oa(r)});var AS=A('<rect x="4.5" y="4.5" width="15" height="7.5" rx="1" fill="currentColor" fill-opacity="0.25"/><rect x="4.5" y="12" width="15" height="7.5" rx="1"/>');O({type:"position",group:"measure",label:"Long/Short Position",icon:AS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new We(r)});var RS=A('<circle cx="10.5" cy="10.5" r="6.5"/><path d="m15.3 15.3 5.2 5.2"/><path d="M8 12.5v-3M10.5 13.5v-5.5M13 12v-2"/>');O({type:"magnifier",group:"measure",label:"Magnifier",icon:RS,defaultStyle:{lineColor:"",lineWidth:1,lineStyle:"solid"},coversSeries:true,placementHint:"Drag an area on the chart to view it at a lower timeframe",create:r=>new Fe(r)});var DS=A('<line x1="5" y1="3" x2="5" y2="21"/><path d="M5 16c4 0 5-9 8-9s3 5 8 3"/>');O({type:"anchoredvwap",group:"measure",label:"Anchored VWAP",icon:DS,defaultStyle:{lineColor:It,lineWidth:2,lineStyle:"solid"},create:r=>new Tn(r)});var OS=A('<path d="M4 4v16"/><path d="M4 8h10"/><path d="M4 12h14"/><path d="M4 16h8"/><path d="M4 20h12"/>');O({type:"fixedrangevp",group:"measure",label:"Fixed Range Volume Profile",icon:OS,defaultStyle:{lineColor:q,lineWidth:1,lineStyle:"solid"},create:r=>new Be(r)});var FS=["fibretracement","fibextension","fibextensiontrend","fibfan","fibtimezones","fibchannel","fibspeedfan","trendfibtime","fibcircles","fibarcs","fibwedge","fibspiral"],NS=["gannfan","gannbox","gannsquare"],VS=["dedekind","sonic","supersonic","goldensonic","goldensupersonic"],_S=["xabcd","abcd","headshoulders"],BS=["elliottimpulse","elliottcorrection"],HS=["gartley","bat","butterfly","crab","shark","cypher"],zS=["position","datepricerange","magnifier"],$S=["anchoredvwap","fixedrangevp"],WS=["freehand","highlighter"],GS=["arrow","arrowmarkup","arrowmarkdown"],US=["box","ellipse","triangle","polyline","circle","rotatedrect","path","arc","curve"],YS=["text","callout","note","pricenote","comment","pricelabel","signpost"],KS=["flagmark","iconstamp"],XS=[{id:"lines-channels-pitchforks",label:"Lines",sections:[{label:"Lines",registryGroup:"lines"},{label:"Channels",registryGroup:"channels"},{label:"Pitchforks",registryGroup:"pitchforks"}]},{id:"fibonacci-gann",label:"Fibonacci",sections:[{label:"Fibonacci",types:FS},{label:"Gann",types:NS},{label:"Geometry",types:VS}]},{id:"patterns-waves-harmonics",label:"Patterns",sections:[{label:"Patterns",types:_S},{label:"Elliott Waves",types:BS},{label:"Harmonics",types:HS}]},{id:"measurements",label:"Measurements",sections:[{label:"Measurements",types:zS},{label:"Volume",types:$S}]},{id:"brushes-arrows-shapes",label:"Shapes",sections:[{label:"Brushes",types:WS},{label:"Arrows",types:GS},{label:"Shapes",types:US}]},{id:"text",label:"Text",sections:[{label:"Text",types:YS}]},{id:"icons",label:"Icons",sections:[{label:"Icons",types:KS}]}];function jS(r){let e=Qe(r);return e?{type:e.type,label:e.label,icon:e.icon}:null}function qS(r){let e=new Map;for(let t of aa()){if(r&&!r.has(t.type))continue;let n={type:t.type,label:t.label,icon:t.icon};e.has(t.group)||e.set(t.group,[]),e.get(t.group).push(n);}return e}function ZS(r,e,t){return "registryGroup"in r?e.get(r.registryGroup)??[]:r.types.map(n=>t.get(n)).filter(n=>n!=null)}function dp(r){let e=qS(r),t=new Map;for(let i of e.values())for(let o of i)t.set(o.type,o);let n=[];for(let i of XS){let o=[],s=[];for(let a of i.sections){let l=ZS(a,e,t);l.length!==0&&(o.push({label:a.label,tools:l}),s.push(...l));}s.length!==0&&n.push({id:i.id,label:i.label,tools:s,sections:o.length>0?o:void 0});}return {groups:n}}function JS(r){let e=new Set;for(let t of r)Qe(t)&&e.add(t);return dp(e)}function QS(r){let e=[];for(let t of r){let n=t.tools.map(jS).filter(i=>i!=null);n.length>0&&e.push({id:t.id,label:t.label,tools:n});}return {groups:e}}function Ci(){return dp()}function Ti(r){if(r===false)return {definition:Ci(),visible:false};if(r===void 0||r===true)return {definition:Ci(),visible:true};let e=r.toolbar??true;return r.groups?{definition:QS(r.groups),visible:e}:r.tools?{definition:JS(r.tools),visible:e}:{definition:Ci(),visible:e}}function mt(r){let e=globalThis.structuredClone;return e?e(r):JSON.parse(JSON.stringify(r))}function up(r){if(!r||typeof r!="object")return false;let e=r;return typeof e.id=="string"&&typeof e.type=="string"&&typeof e.paneId=="string"&&Array.isArray(e.anchors)&&e.anchors.every(t=>t&&typeof t.time=="number"&&typeof t.price=="number")&&!!e.style&&typeof e.style=="object"}function kc(r){let e=r;return !e||typeof e!="object"||e.version!==1||!Array.isArray(e.drawings)?{version:1,drawings:[]}:{version:1,drawings:e.drawings.filter(up)}}var pr=class{constructor(){this.byId=new Map;this.seq=0;this.zCounter=1;this.listeners=new Set;}nextId(){return this.seq+=1,`dw-${this.seq}`}add(e){return e.zIndex||(e.zIndex=this.zCounter),this.zCounter=Math.max(this.zCounter,Math.ceil(e.zIndex))+1,this.byId.set(e.id,e),this.emit(),e}remove(e){let t=this.byId.delete(e);return t&&this.emit(),t}get(e){return this.byId.get(e)}has(e){return this.byId.has(e)}update(e,t){let n=this.byId.get(e);return n?(t.anchors&&(n.anchors=t.anchors.map(i=>({time:i.time,price:i.price}))),t.style&&(n.style={...t.style}),t.text!==void 0&&(n.text=t.text?{...t.text}:void 0),t.paneId!==void 0&&(n.paneId=t.paneId),t.locked!==void 0&&(n.locked=t.locked),t.visible!==void 0&&(n.visible=t.visible),t.zIndex!==void 0&&(n.zIndex=t.zIndex),t.props!==void 0&&n.applyProps(t.props),this.emit(),n):null}all(){return [...this.byId.values()].sort((e,t)=>e.zIndex-t.zIndex)}byPane(e){return this.all().filter(t=>t.paneId===e)}bringToFront(e,t=0){let n=this.byId.get(e);n&&(n.zIndex=Math.max(this.zCounter,Math.floor(t)+1),this.zCounter=n.zIndex+1,this.emit());}sendToBack(e,t=1){let n=this.byId.get(e);if(!n)return;let i=Math.min(...[...this.byId.values()].map(o=>o.zIndex),Math.ceil(t));n.zIndex=i-1,this.emit();}setLocked(e,t){let n=this.byId.get(e);n&&(n.locked=t,this.emit());}setVisible(e,t){let n=this.byId.get(e);n&&(n.visible=t,this.emit());}clear(){this.byId.size!==0&&(this.byId.clear(),this.emit());}serialize(){return {version:1,drawings:this.all().map(e=>e.serialize())}}load(e){let t=kc(e);this.byId.clear(),this.seq=0,this.zCounter=1;for(let n of t.drawings){let i=pt(n);i&&(this.byId.set(i.id,i),this.zCounter=Math.max(this.zCounter,i.zIndex)+1,this.bumpSeqPast(i.id));}this.emit();}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}bumpSeqPast(e){let t=/^dw-(\d+)$/.exec(e);t&&(this.seq=Math.max(this.seq,Number(t[1])));}emit(){for(let e of this.listeners)e();}};var la=class{constructor(e=100){this.cap=e;this.undoStack=[];this.redoStack=[];this.pending=null;this.dirtied=false;this.depth=0;}begin(e){this.depth+=1,this.depth===1&&(this.pending=mt(e),this.dirtied=false);}markDirty(){this.depth===0||this.dirtied||!this.pending||(this.push(this.pending),this.dirtied=true);}commit(){this.depth!==0&&(this.depth-=1,this.depth===0&&(this.pending=null,this.dirtied=false));}abort(){this.commit();}record(e){if(this.depth>0){this.markDirty();return}this.push(mt(e));}undo(e){let t=this.undoStack.pop();return t?(this.redoStack.push(mt(e)),t):null}redo(e){let t=this.redoStack.pop();return t?(this.undoStack.push(mt(e)),t):null}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}clear(){this.undoStack=[],this.redoStack=[],this.pending=null,this.dirtied=false,this.depth=0;}push(e){this.undoStack.push(e),this.undoStack.length>this.cap&&this.undoStack.shift(),this.redoStack=[];}};var ca=class{constructor(e,t,n,i){this.events=t;this.store=new pr;this.history=new la;this.activeTool=null;this.snapMode="off";this.stayInDrawingMode=false;this.mode=null;this.favs=new Set;this.selectedIds=[];this.clipboard=[];this.lastStyle=new Map;this.subs=[];if(this.enabled=!!e.capabilities.userDrawings&&!!e.userDrawingsPort,this.port=this.enabled?e.userDrawingsPort:null,this.port){let{definition:o,visible:s}=Ti(n);this.port.setToolbar(o),this.port.showToolbar(s),i&&this.port.setSeriesGateway?.(i),this.subs.push(this.port.onDrawingIntent(a=>this.onIntent(a))),this.subs.push(this.store.onChange(()=>this.sync()));}}get supported(){return this.enabled}setTool(e){if(!this.port)return;let t=e!==this.activeTool;this.activeTool=e,this.port.setActiveTool(e,e?this.lastStyle.get(e):void 0),t&&this.events.emit("drawing:tool",{type:e});}getTool(){return this.activeTool}getSnapMode(){return this.snapMode}setSnapMode(e){!this.port||e===this.snapMode||(this.snapMode=e,this.port.setSnapMode?.(e),this.events.emit("drawing:snap",{mode:e}));}getStayMode(){return this.stayInDrawingMode}setStayMode(e){!this.port||e===this.stayInDrawingMode||(this.stayInDrawingMode=e,this.port.setStayMode?.(e),this.events.emit("drawing:stay",{on:e}));}getMode(){return this.mode}setMode(e){!this.port||e===this.mode||(this.mode=e,this.port.setMode?.(e),this.events.emit("drawing:mode",{mode:e}));}showToolbar(e){this.port?.showToolbar(e);}favorites(){return [...this.favs]}isFavorite(e){return this.favs.has(e)}setFavorite(e,t){Qe(e)&&t!==this.favs.has(e)&&(t?this.favs.add(e):this.favs.delete(e),this.pushFavorites());}setFavorites(e){let t=e.filter(n=>Qe(n)!=null);t.length===this.favs.size&&t.every(n=>this.favs.has(n))||(this.favs=new Set(t),this.pushFavorites());}pushFavorites(){let e=[...this.favs];this.port?.setFavorites?.(e),this.events.emit("drawing:favorites",{favorites:e});}setToolbar(e){this.port?.setToolbar(Ti(e).definition);}setExternalGhost(e){this.port?.setExternalGhost?.(e);}setToolShortcuts(e){this.port?.setToolShortcuts?.(e);}add(e,t={}){if(!this.enabled)return null;let i={...this.lastStyle.get(e)??{},...t.style??{}},o=en(e,{id:this.store.nextId(),paneId:t.paneId??"price",anchors:t.anchors,style:i,text:t.text,props:t.props,zIndex:t.zIndex??this.startZ(e,t.paneId??"price")});return o?(this.history.record(this.store.serialize()),this.store.add(o),this.captureStyle(o.id),this.events.emit("drawing:created",{id:o.id}),o):null}remove(e){this.deleteMany([e]);}update(e,t){let n=this.store.serialize(),i=t.style?this.store.get(e):void 0,o=t.style&&i?{...t,style:{...i.style,...t.style}}:t;this.store.update(e,o)&&(this.history.record(n),this.captureStyle(e),this.events.emit("drawing:edited",{id:e}));}updateMany(e){this.history.begin(this.store.serialize());for(let{id:t,patch:n}of e)this.store.update(t,n)&&(this.history.markDirty(),this.events.emit("drawing:edited",{id:t}));this.history.commit();}removeMany(e){this.deleteMany(e);}setLocked(e,t){let n=this.store.serialize();this.history.record(n),this.store.setLocked(e,t),this.events.emit("drawing:edited",{id:e});}setVisible(e,t){let n=this.store.serialize();this.history.record(n),this.store.setVisible(e,t),this.events.emit("drawing:edited",{id:e});}bringToFront(e){let t=this.store.serialize();this.history.record(t),this.store.bringToFront(e,this.seriesTopZ(this.store.get(e)?.paneId)),this.events.emit("drawing:edited",{id:e});}sendToBack(e){let t=this.store.serialize();this.history.record(t),this.store.sendToBack(e,this.seriesBottomZ(this.store.get(e)?.paneId)),this.events.emit("drawing:edited",{id:e});}seriesTopZ(e){return e!==void 0?this.port?.stackRange?.(e)?.front??0:0}seriesBottomZ(e){return e!==void 0?this.port?.stackRange?.(e)?.back??1:1}startZ(e,t){let n=this.port?.stackRange?.(t);if(n)return Qe(e)?.coversSeries?n.front+.5:(n.price??n.front)-.5}select(e,t=false){this.setSelection(e,t);}openSettings(e){this.port?.openSettings(e);}undo(){let e=this.history.undo(this.store.serialize());e&&this.restoreSnapshot(e);}redo(){let e=this.history.redo(this.store.serialize());e&&this.restoreSnapshot(e);}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}duplicate(e){if(!this.enabled)return [];let t=this.resolve(e);return t.length===0?[]:this.insertClones(t.map(n=>n.serialize()))}clone(e){return this.duplicate([e])[0]??null}copy(e){let t=this.resolve(e).map(n=>mt(n.serialize()));t.length&&(this.clipboard=t);}paste(){return !this.enabled||this.clipboard.length===0?[]:this.insertClones(this.clipboard)}all(){return this.store.serialize().drawings}toJSON(){return this.store.serialize()}fromJSON(e){this.history.clear(),this.selectedIds=[],this.store.load(e);}destroy(){for(let e of this.subs)e();this.subs.length=0;}setSelection(e,t=false){let n;if(t){n=[...this.selectedIds];for(let i of e){let o=n.indexOf(i);o>=0?n.splice(o,1):n.push(i);}}else n=[...e];this.selectedIds=n.filter(i=>this.store.has(i)),this.port?.setSelection(this.selectedIds),this.events.emit("drawing:selected",{id:this.selectedIds[0]??null});}restoreSnapshot(e){this.store.load(e),this.selectedIds=this.selectedIds.filter(t=>this.store.has(t)),this.port?.setSelection(this.selectedIds),this.events.emit("drawing:selected",{id:this.selectedIds[0]??null});}deleteMany(e){this.history.begin(this.store.serialize());let t=[];for(let i of e)this.store.remove(i)&&t.push(i),this.history.markDirty();if(this.history.commit(),t.length===0)return;let n=this.selectedIds.filter(i=>this.store.has(i));n.length!==this.selectedIds.length&&this.setSelection(n);for(let i of t)this.events.emit("drawing:removed",{id:i});}insertClones(e){this.history.begin(this.store.serialize());let t=[];for(let n of e){let i=pt({...n,id:this.store.nextId()});i&&(this.store.add(i),this.history.markDirty(),t.push(i));}if(this.history.commit(),t.length){this.setSelection(t.map(n=>n.id));for(let n of t)this.events.emit("drawing:created",{id:n.id});}return t}resolve(e){return e.map(t=>this.store.get(t)).filter(t=>t!=null)}captureStyle(e){let t=this.store.get(e);t&&this.lastStyle.set(t.type,{...t.style});}sync(){this.port?.syncDrawings(this.store.serialize().drawings);}onIntent(e){switch(e.kind){case "arm":this.setTool(e.type);break;case "draft":this.events.emit("drawing:draft",{doc:e.doc});break;case "create":{let t=this.store.serialize(),n=this.lastStyle.get(e.doc.type),i=n?{...e.doc.style,...n}:e.doc.style,o=pt({...e.doc,id:this.store.nextId(),style:i});if(!o)return;o.zIndex||(o.zIndex=this.startZ(o.type,o.paneId)??0),this.history.record(t),this.store.add(o),this.captureStyle(o.id),this.events.emit("drawing:created",{id:o.id});break}case "edit":{let t=this.store.serialize();this.store.update(e.doc.id,e.doc)&&(this.history.record(t),this.captureStyle(e.doc.id),this.events.emit("drawing:edited",{id:e.doc.id}));break}case "edit-many":{this.history.begin(this.store.serialize());for(let t of e.docs)this.store.update(t.id,t)&&(this.history.markDirty(),this.events.emit("drawing:edited",{id:t.id}));this.history.commit();break}case "select":this.setSelection(e.ids,e.additive);break;case "delete":this.deleteMany(e.ids);break;case "reorder":e.to==="front"?this.bringToFront(e.id):this.sendToBack(e.id);break;case "settings":this.events.emit("drawing:settings",{id:e.id});break;case "favorite":this.setFavorite(e.type,e.on);break;case "snap-mode":e.mode!==this.snapMode&&(this.snapMode=e.mode,this.events.emit("drawing:snap",{mode:e.mode}));break;case "stay-mode":e.on!==this.stayInDrawingMode&&(this.stayInDrawingMode=e.on,this.events.emit("drawing:stay",{on:e.on}));break;case "mode":e.mode!==this.mode&&(this.mode=e.mode,this.events.emit("drawing:mode",{mode:e.mode}));break;case "tool-finished":!this.stayInDrawingMode&&e.type!=="freehand"&&e.type!=="highlighter"&&this.setTool(null);break;case "undo":this.undo();break;case "redo":this.redo();break;case "duplicate":this.duplicate(e.ids);break;case "copy":this.copy(e.ids);break;case "paste":this.paste();break}}};var pp={D:864e5,W:6048e5,M:2592e6};function et(r){let e=r.trim();if(pp[e])return pp[e];let t=/^(\d+)\s*(m|h|d|w)?$/i.exec(e);if(t){let n=parseInt(t[1],10),i=(t[2]??"m").toLowerCase();return n*(i==="m"?6e4:i==="h"?36e5:i==="d"?864e5:6048e5)}return 36e5}var e0=5e3,t0=.25,n0=16,r0=15e3,Ic=["240","60","30","15","5","1"],da=class{constructor(e){this.deps=e;this.cache=new Map;this.listeners=new Set;}seriesInRange(e,t,n){if(!this.deps.canFetch())return {state:"unavailable",reason:"no-source"};let i=this.resolveTimeframe(e);if(typeof i!="string")return {state:"unavailable",reason:i.reason};let o=et(i),s=Math.min(t,n),a=Math.max(t,n);if(!(a>s)||!(o>0))return {state:"unavailable",reason:"not-lower"};if((a-s)/o>e0)return {state:"unavailable",reason:"too-wide"};let l=`${this.deps.marketKey()}|${i}`,c=this.cache.get(l)??[],d=c.find(u=>u.from<=s&&u.to>=a);if(d){if(d.pending)return this.loading(c,i,o,s,a);if(d.failedAt>0){if(Date.now()-d.failedAt<r0)return this.loading(c,i,o,s,a);c.splice(c.indexOf(d),1);}else return this.maybeRefresh(l,d,i,o,a),{state:"ready",bars:this.slice(d.bars,s,a),timeframe:i,barMs:o}}return this.fetchWindow(l,c,i,s,a),this.loading(c,i,o,s,a)}onUpdate(e){return this.listeners.add(e),()=>this.listeners.delete(e)}resolveTimeframe(e){let t=et(this.deps.chartTimeframe()),n=Ic[Ic.length-1];if(et(n)>=t)return {reason:"none-lower"};let i=e.trim()||"auto";if(i==="auto"){for(let o of Ic)if(et(o)<=t/4)return o;return n}return et(i)<t?i:{reason:"not-lower"}}loading(e,t,n,i,o){let s=new Map;for(let l of e)if(!(l.pending||l.failedAt>0)&&!(l.to<i||l.from>o))for(let c of this.slice(l.bars,i,o))s.set(c.time,c);if(s.size===0)return {state:"loading",timeframe:t,barMs:n};let a=[...s.values()].sort((l,c)=>l.time-c.time);return {state:"loading",timeframe:t,barMs:n,bars:a}}fetchWindow(e,t,n,i,o){if(t.some(l=>l.pending&&l.to>=i&&l.from<=o))return;let s=(o-i)*t0,a={from:i-s,to:o+s,bars:[],fetchedAt:0,pending:true,failedAt:0};t.push(a),this.cache.set(e,t),this.evict(),this.deps.fetchBars(n,{from:a.from,to:a.to}).then(l=>{a.bars=l,a.fetchedAt=Date.now(),a.pending=false,this.absorbOverlaps(e,a),this.fire();}).catch(()=>{a.pending=false,a.failedAt=Date.now(),this.fire();});}maybeRefresh(e,t,n,i,o){if(t.pending)return;let s=t.bars.length>0?t.bars[t.bars.length-1].time:t.from;o<s||Date.now()-t.fetchedAt<i||(t.pending=true,this.deps.fetchBars(n,{from:t.from,to:t.to}).then(a=>{t.bars=a,t.fetchedAt=Date.now(),t.pending=false,this.fire();}).catch(()=>{t.pending=false,t.fetchedAt=Date.now();}));}absorbOverlaps(e,t){let n=this.cache.get(e);if(n)for(let i=n.length-1;i>=0;i-=1){let o=n[i];if(o===t||o.pending||o.failedAt>0||o.to<t.from||o.from>t.to)continue;let s=new Map;for(let a of o.bars)s.set(a.time,a);for(let a of t.bars)s.set(a.time,a);t.bars=[...s.values()].sort((a,l)=>a.time-l.time),t.from=Math.min(t.from,o.from),t.to=Math.max(t.to,o.to),t.fetchedAt=Math.min(t.fetchedAt,o.fetchedAt||t.fetchedAt),n.splice(i,1);}}evict(){let e=0;for(let t of this.cache.values())e+=t.length;for(;e>n0;){let t=null,n=-1,i=1/0;for(let[s,a]of this.cache)for(let l=0;l<a.length;l+=1){let c=a[l];if(c.pending)continue;let d=c.fetchedAt||c.failedAt;d<i&&(t=s,n=l,i=d);}if(t==null)return;let o=this.cache.get(t);o.splice(n,1),o.length===0&&this.cache.delete(t),e-=1;}}slice(e,t,n){let i=[];for(let o of e)if(!(o.time<t)){if(o.time>n)break;i.push(o);}return i}fire(){for(let e of [...this.listeners])e();}};function Ei(r){return r.group!=null&&r.ticker===r.group}function mp(r){return `${(r.prefix??r.provider??"").toLowerCase()}:${(r.group??"").toUpperCase()}`}function i0(r,e){let t=mp(e);return r.filter(n=>n.group!=null&&!Ei(n)&&mp(n)===t)}function fp(r,e){let t=i0(r,e),n=t.filter(i=>i.default);return (n.length===1?n[0]:t[0])??null}var ft=r=>r.trim().toLowerCase(),Ft=r=>r.trim().toUpperCase();function gt(r){let e=r.trim(),t=/^(?:([A-Za-z0-9_.]+):)?(.+)$/.exec(e);if(!t)return {provider:null,ticker:e};let n=t[1]?ft(t[1]):null,i=t[2],o=i.lastIndexOf("."),s=o>0?i.slice(o+1):void 0;return {provider:n,ticker:i,ext:s}}var ua=class{constructor(){this.entries=new Map;this.changeListeners=new Set;this.waits=new Set;this.unresolvedCbs=new Set;}register(e,t){let n=ft(e),i={name:n,provider:t,index:null,prefixIndex:null,byTicker:null,descriptors:[],settled:false,settle:Promise.resolve()};return this.entries.set(n,i),i.settle=this.buildIndex(i),queueMicrotask(()=>this.notify(false)),i.settle}async buildIndex(e){await Promise.resolve();try{if(e.provider.listSymbols){let t=await e.provider.listSymbols();e.descriptors=t,e.index=new Set(t.map(n=>Ft(n.ticker))),e.byTicker=new Map(t.map(n=>[Ft(n.ticker),n])),e.prefixIndex=new Map;for(let n of t)n.prefix&&e.prefixIndex.set(`${ft(n.prefix)}:${Ft(n.ticker)}`,n);}}catch{e.index=null;}finally{e.settled=true,this.notify(true);}}notify(e){for(let t of [...this.changeListeners])t(e);}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}unregister(e){this.entries.delete(ft(e)),this.notify(false);}has(e){return this.entries.has(ft(e))}get(e){return this.entries.get(ft(e))?.provider}names(){return [...this.entries.keys()]}parse(e){return gt(e)}resolve(e,t={}){let{provider:n,ticker:i}=this.parse(e);if(n){if(this.entries.has(n)){let a=this.entries.get(n).byTicker?.get(Ft(i));return {provider:n,ticker:a!=null&&Ei(a)?this.loadableTicker(n,a):i}}let s=`${n}:${Ft(i)}`;for(let a of this.candidateOrder(t.default)){let l=this.entries.get(a).prefixIndex?.get(s);if(l)return {provider:a,ticker:this.loadableTicker(a,l)}}return null}let o=Ft(i);for(let s of this.candidateOrder(t.default)){let a=this.entries.get(s);if(a.index?.has(o)){let l=a.byTicker?.get(o);return {provider:s,ticker:l!=null&&Ei(l)?this.loadableTicker(s,l):i}}}if(t.lenient&&this.entries.size===1){let s=this.names()[0],a=this.entries.get(s);if(a.settled&&a.index==null)return {provider:s,ticker:i}}return null}loadableTicker(e,t){return Ei(t)?fp(this.entries.get(e)?.descriptors??[],t)?.ticker??t.ticker:t.ticker}whenResolvable(e,t={}){let n=this.resolve(e,{...t,lenient:true});return n?Promise.resolve(n):new Promise(i=>{let o=this.onChange(a=>{let l=this.resolve(e,{...t,lenient:true});l?(s(),i(l)):a&&this.allSettled()&&this.reportUnresolved(e);}),s=()=>{o(),this.waits.delete(s);};this.waits.add(s);})}allSettled(){for(let e of this.entries.values())if(!e.settled)return false;return true}cancelWaits(){for(let e of [...this.waits])e();}onUnresolved(e){return this.unresolvedCbs.add(e),()=>this.unresolvedCbs.delete(e)}reportUnresolved(e){let t=this.names();console.warn(`[vela] symbol "${e}" not yet resolvable \u2014 registered providers: [${t.join(", ")||"none"}]. Register a provider that serves it.`);for(let n of this.unresolvedCbs)n({symbol:e,providers:t});}candidateOrder(e){let t=this.names();if(e){let n=ft(e);if(this.entries.has(n))return [n,...t.filter(i=>i!==n)]}return t}displayPrefixOf(e){return this.entries.get(e.provider)?.byTicker?.get(Ft(e.ticker))?.prefix??e.provider}canonicalSymbol(e){let t=this.entries.get(e.provider)?.byTicker?.get(Ft(e.ticker));return `${t?.prefix??e.provider}:${t?.ticker??e.ticker}`}symbolIconOf(e){let t=e.provider?ft(e.provider):[...this.entries.keys()][0],n=t!==void 0?this.entries.get(t):void 0;try{return n?.provider.resolveSymbolIcon?.(e)??void 0}catch{return}}symbolIcon(e){if(!e)return;let t=this.entries.get(e.provider)?.byTicker?.get(Ft(e.ticker));return this.symbolIconOf({...t??{ticker:e.ticker},provider:t?.provider??e.provider})}symbolsOf(e){return e!=null?this.entries.get(ft(e))?.descriptors??[]:[...this.entries.entries()].flatMap(([t,n])=>n.descriptors.map(i=>({...i,provider:t})))}infoOf(e){let t=ft(e),n=this.entries.get(t);if(!n)return {name:t,capabilities:{enumerate:false,stream:false,symbolInfo:false}};let i=n.provider;return i.info?.()??{name:n.name,capabilities:{enumerate:!!i.listSymbols,stream:!!i.subscribe,symbolInfo:!!i.getSymbolInfo}}}indexReady(){return Promise.all([...this.entries.values()].map(e=>e.settle)).then(()=>{})}};function mr(r){switch(r.kind){case "row":return {label:r.label,toggle:r.toggle,controls:r.controls,when:r.when};case "toggle":{let e=[];r.number&&e.push({kind:"number",...r.number});for(let t of r.colors??[])e.push({kind:"color",...t});return r.width&&e.push({kind:"width",...r.width}),{label:r.label,toggle:{key:r.key,defval:r.defval},controls:e,when:r.when}}case "number":return {label:r.label,controls:[{kind:"number",key:r.key,label:r.label,defval:r.defval,min:r.min,max:r.max,step:r.step}],when:r.when};case "color":return {label:r.label,controls:[{kind:"color",key:r.key,label:r.label,defval:r.defval}],when:r.when};case "select":return {label:r.label,controls:[{kind:"select",key:r.key,label:r.label,options:r.options,defval:r.defval}],when:r.when};case "range":return {label:r.label,controls:[{kind:"number",key:r.minKey,label:`${r.label} \u2014 min`,defval:r.defval,min:r.min,max:r.max,step:r.step,placeholder:r.placeholder},{kind:"hint",text:"\u2013"},{kind:"number",key:r.maxKey,label:`${r.label} \u2014 max`,defval:r.defval,min:r.min,max:r.max,step:r.step,placeholder:r.placeholder}],when:r.when}}}function Pi(r){if(r.kind==="heading"||r.kind==="header")return [];let e=mr(r),t=[];e.toggle&&t.push({key:e.toggle.key,type:"boolean",defval:e.toggle.defval});for(let n of e.controls)n.kind!=="hint"&&(n.kind==="color"||n.kind==="select"?t.push({key:n.key,type:"string",defval:n.defval}):t.push({key:n.key,type:"number",defval:n.defval}));return t}function Fn(r,e){return r?(Array.isArray(r)?r:[r]).every(n=>n.anyOf?n.anyOf.some(i=>i===e[n.key]):e[n.key]===n.equals):true}var Li=new Map;function Ac(r){Li.set(r.id,r);}function o0(r){Li.delete(r);}function Nt(r){return typeof r=="string"?Li.get(r):void 0}function tt(){return [...Li.values()]}function Rc(){return [...Li.values()].filter(r=>r.tickerModifier??r.barTransform!=null).map(r=>r.id)}function fr(r){return Nt(r)?.barTransform??null}function gp(r){let e=r.lastIndexOf(";");if(e<=0||e===r.length-1)return {symbol:r,modifier:null,transform:null};let t=r.slice(e+1).toLowerCase();return t!=="standard"&&!Rc().includes(t)?{symbol:r,modifier:null,transform:null}:{symbol:r.slice(0,e),modifier:t,transform:fr(t)}}var bt={background:"#151619",textColor:"#b2b5be",gridColor:"#20222c",borderColor:"#2a2b30",upColor:q,downColor:X,fontFamily:"sans-serif"},Mi={background:"#ffffff",textColor:"#1e293b",gridColor:"#cccccc",borderColor:"#d4dae3",upColor:q,downColor:X,fontFamily:"sans-serif"};function gr(r){return !r||r==="dark"?bt:r==="light"?Mi:r}var s0=150,a0=1e3,l0=300,c0=5e3,bp=1e4,d0=100,u0=1.5,vp=5e3,ha=class r{constructor(e,t,n,i,o,s){this.renderer=t;this.feed=n;this.config=o;this.dataControl=s;this.events=new bn;this.registry=new Xo;this.paneOrder=["price"];this.collapsedPanes=new Set;this.maximizedPaneId=null;this.paneActionUnsub=null;this.handles=new Map;this.engines=new Map;this.live=null;this.bars=[];this.rawBars=[];this.barTransform=null;this.typeEngines=new Map;this.typeSettings=new Map;this.activeEngineStyle=null;this.priceStyle="candles";this.unresolvedUnsub=null;this.visibleRange=null;this.viewportUnsub=null;this.viewportTimer=null;this.healing=false;this.healBuffer=[];this.lastHealAt=0;this.onVisible=null;this.barCause="tick";this.historyState="complete";this.generation=0;this.progressiveAbort=null;this.supersedeWaiters=[];this.historyCompleted=false;this.historyCompletePromise=new Promise(e=>{this.resolveHistoryComplete=e;});this.switchingMarket=false;this.loadingUp=false;this.volumeOptedOut=false;this.contextEmitAt=new Map;this.runEmitAt=new Map;for(let c of i)this.registerEngine(c.language,c);this.defaultLanguage=o.defaultLanguage,this.renderer.mount(e,o.theme),this.renderer.onInputChange(c=>c.kind==="prop"?this.applyProps(c.indicatorId,{[c.key]:c.value}):this.applyInputs(c.indicatorId,{[c.key]:c.value})),this.renderer.onRemoveIndicator(c=>this.removeIndicator(c)),this.renderer.onToggleIndicatorVisible?.((c,d)=>this.setVisible(c,d)),this.paneActionUnsub=this.renderer.onPaneAction?.(c=>this.handlePaneAction(c))??null,this.renderer.onChartTypeSettingsChange?.((c,d)=>{this.typeSettings.set(c,d),this.typeEngines.get(c)?.onSettings?.(d);}),this.renderer.onMoveIndicator?.((c,d)=>this.moveIndicator(c,d)),this.renderer.onThemeSelect?.(c=>this.setTheme(gr(c))),this.viewportUnsub=this.renderer.onViewportChange(c=>this.onViewportChange(c)),this.renderer.onPriceStyleChange?.(c=>this.syncPriceStyle(c));let a=this.renderer.readFeature("priceStyle");typeof a=="string"&&(this.priceStyle=a),this.barTransform=fr(a);let l=new da({fetchBars:(c,d)=>this.fetchSeries(this.config.market.symbol??"",c,d),canFetch:()=>!!this.feed.loadRange&&!this.config.market.data?.length&&!!this.config.market.symbol,chartTimeframe:()=>this.config.market.timeframe??"60",marketKey:()=>`${this.config.market.symbol??""}|${this.config.market.session??""}`});this.drawings=new ca(this.renderer,this.events,o.drawings,l),this.unresolvedUnsub=this.feed.onUnresolved?.(c=>{this.endLoad(),this.events.emit("data:unresolved",c);})??null,this.readyPromise=this.init(),Nt(a)?.dataEngine&&this.syncChartTypeEngine(a);}currentVisibleRange(){if(this.visibleRange)return this.visibleRange;let e=this.renderer.getVisibleRange();return e?{left:e.from,right:e.to}:void 0}engineFor(e){let t=e??this.defaultLanguage,n=this.engines.get(t);if(!n)throw new Error(`[vela] no scripting engine registered for language "${t}". Vela ships none \u2014 install one (Pine Script: @luxalgo/vela-pinets) and register it before addIndicator, e.g. chart.registerEngine('pine', new PineEngine()).`);return n}market(){return {symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",symbolInfo:this.feed.symbolInfo?.(this.config.market),chartStyle:this.priceStyle}}async fetchSeries(e,t,n){let i=gp(e),o={symbol:i.symbol,timeframe:t},s=await(this.feed.loadRange?this.feed.loadRange(o,n):this.feed.load({...o,bars:n.limit}));return i.transform?i.transform.full(s):s}onViewportChange(e){this.visibleRange={left:e.from,right:e.to},this.events.emit("viewport:changed",{from:e.from,to:e.to}),this.viewportTimer!=null&&clearTimeout(this.viewportTimer),this.viewportTimer=setTimeout(()=>{if(this.viewportTimer=null,this.switchingMarket)return;let t=this.visibleRange;if(t){for(let n of this.registry.all())!n.renderHandle||n.hidden||(n.session&&n.prepared?.reactsToViewport?(n.pendingCause="viewport",n.session.setVisibleRange(t)):n.native?.descriptor.reactsToViewport&&n.native.instance.onViewport({from:t.left,to:t.right}));this.activeEngineStyle&&this.typeEngines.get(this.activeEngineStyle)?.onViewport?.({from:t.left,to:t.right});}},s0);}async init(){let e=this.bumpGeneration();this.beginLoad(true),await this.loadMarket(e,{firstLoad:true}),this.generation===e&&(this.startLive(),this.events.emit("ready",void 0));}bumpGeneration(){let e=++this.generation;this.progressiveAbort?.abort(),this.progressiveAbort=null;for(let t of this.supersedeWaiters.splice(0))t();return e}beginLoad(e){if(this.loadingUp)return;this.loadingUp=true,this.renderer.setLoading?.(true);let t=this.config.market;this.events.emit("load:start",{symbol:t.symbol??"TEST",timeframe:t.timeframe??"60",firstLoad:e});}endLoad(){if(!this.loadingUp)return;this.loadingUp=false,this.renderer.setLoading?.(false);let e=this.config.market;this.events.emit("load:end",{symbol:e.symbol??"TEST",timeframe:e.timeframe??"60",bars:this.bars.length});}async loadMarket(e,t){try{await this.loadMarketInner(e,t);}finally{this.generation===e&&this.endLoad();}}async loadMarketInner(e,t){let n=this.config.market,i=n.bars??500,o=n.visibleRange,s=!n.data?.length&&o==null&&i>c0,a=false;if(!n.data?.length&&o==null&&this.feed.loadProgressive){let l=false,c=(u,h)=>{this.generation!==e||!h&&u.length===0||!l&&!h&&u.length<Math.min(i,d0)||(this.setBarSeries(u,l?{preserveView:true}:void 0),!l&&u.length>0&&(l=true,t.firstLoad&&this.activateBarLayers(),h||(this.historyState="backfill")));},d=new AbortController;this.progressiveAbort=d,a=await new Promise(u=>{let h=false,p=m=>{h||(h=true,u(m));};d.signal.addEventListener("abort",()=>p(true),{once:true}),this.feed.loadProgressive(n,m=>{c(m,false),l&&p(true);},{signal:d.signal}).then(m=>{if(this.progressiveAbort===d&&(this.progressiveAbort=null),m==null)return p(false);if(this.generation!==e)return p(true);c(m,true),this.completeHistory(m.length>=i?"depth":"genesis"),p(true);}).catch(()=>{this.progressiveAbort===d&&(this.progressiveAbort=null),this.generation===e&&this.completeHistory("aborted"),p(true);});});}if(!a)if(s&&this.feed.loadRange){let l=await this.feed.load({...n,bars:Math.min(i,bp)});if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers(),l.length>0&&i>l.length?(this.historyState="backfill",this.backfillHistory(e,i)):this.completeHistory("depth");}else if(s){let l=await this.feed.load({...n,bars:l0});if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers();let c=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(c,{preserveView:true}),this.completeHistory("depth");}else {let l=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers(),this.completeHistory("depth");}o!=null&&(typeof o=="string"?this.setVisibleRangePreset(o):this.renderer.setVisibleRange(o)),this.refreshPriceFormat(),this.ensurePriceFormat();}startLive(){this.config.live&&(this.live=new qo(this.feed,this.config.market,e=>this.onBar(e)),this.live.start(),typeof document<"u"&&(this.onVisible=()=>{if(document.visibilityState!=="visible")return;let e=this.bars[this.bars.length-1];!e||this.healing||!this.canHeal()||Date.now()-this.lastHealAt<=vp||this.healGap(e.time);},document.addEventListener("visibilitychange",this.onVisible)));}stopLive(){this.live?.stop(),this.live=null,this.onVisible&&typeof document<"u"&&document.removeEventListener("visibilitychange",this.onVisible),this.onVisible=null,this.healing=false,this.healBuffer=[],this.lastHealAt=0;}resetHistoryTracking(){this.resolveHistoryComplete(),this.historyCompleted=false,this.historyState="complete",this.historyCompletePromise=new Promise(e=>{this.resolveHistoryComplete=e;});}marketSnapshot(){let e=this.config.market;return {symbol:e.symbol,provider:gt(e.symbol??"").provider??void 0,timeframe:e.timeframe,bars:e.bars,session:e.session,offline:e.data!==void 0}}async setMarket(e){let t=this.config.market,n=e.symbol!==void 0&&e.symbol!==t.symbol||e.timeframe!==void 0&&e.timeframe!==t.timeframe||e.session!==void 0&&e.session!==t.session||e.data!==void 0,i=e.bars!==void 0&&e.bars!==t.bars,o=i&&!n&&this.rawBars.length>0&&!t.data?.length&&((e.bars??0)<=this.rawBars.length||typeof this.feed.loadRange=="function");if(!n&&!i){typeof e.visibleRange=="string"?this.setVisibleRangePreset(e.visibleRange):e.visibleRange&&this.renderer.setVisibleRange(e.visibleRange);return}let s={symbol:t.symbol??"TEST",timeframe:t.timeframe??"60"},l=n&&e.session!==void 0&&e.data===void 0&&(e.symbol===void 0||e.symbol===t.symbol)&&(e.timeframe===void 0||e.timeframe===t.timeframe)&&e.visibleRange===void 0?this.currentVisibleRange():void 0,c=l?this.rawBars.filter(u=>u.time>=l.left&&u.time<=l.right).length:0,d=this.bumpGeneration();this.switchingMarket=true;try{if(this.stopLive(),this.viewportTimer!=null&&(clearTimeout(this.viewportTimer),this.viewportTimer=null),this.visibleRange=null,this.resetHistoryTracking(),e.symbol!==void 0&&(t.symbol=e.symbol),e.timeframe!==void 0&&(t.timeframe=e.timeframe),e.bars!==void 0&&(t.bars=e.bars),e.session!==void 0&&(t.session=e.session),l){let u=Math.min(Math.ceil((Date.now()-l.left)/this.barIntervalMs())+50,5e3);u>(t.bars??500)&&(t.bars=u);}if(e.data!==void 0?t.data=e.data:e.symbol!==void 0&&delete t.data,t.visibleRange=e.visibleRange??(l?{from:l.left,to:l.right}:void 0),n&&(this.beginLoad(!1),this.setBarSeries([],{clearing:!0}),this.activeEngineStyle&&(this.typeEngines.get(this.activeEngineStyle)?.suspend(),this.renderer.setNativeData?.(this.activeEngineStyle,void 0),this.renderer.setNativeData?.(`${this.activeEngineStyle}-pending`,[]))),o?this.extendDepth(d,t.bars??500):await Promise.race([this.loadMarket(d,{firstLoad:!1}),new Promise(u=>this.supersedeWaiters.push(u))]),this.generation!==d)return}finally{this.generation===d&&(this.switchingMarket=false);}if(l&&c>=2&&this.rawBars.length>0){let u=this.rawBars,h=u.length-1;for(;h>0&&u[h].time>l.right;)h-=1;let p=u[Math.max(0,h-(c-1))].time;this.renderer.setVisibleRange({from:p,to:Math.max(l.right,u[h].time+1)});}o||(this.restartNativeIndicators(),this.restartChartTypeEngine(),this.reexecuteIndicators()),this.startLive(),n&&this.events.emit("market:changed",{symbol:t.symbol??"TEST",timeframe:t.timeframe??"60",prev:s});}restartNativeIndicators(){for(let e of this.registry.all())if(e.native)if(e.native.instance.stop(),e.native.instance=e.native.descriptor.create(),e.pendingStructural=true,e.hidden)e.native.stale=true;else {let t=this.handles.get(e.id);t&&this.startNativeIndicator(e.id,t);}}restartChartTypeEngine(){for(let e of this.typeEngines.values())e.stop();this.typeEngines.clear(),this.activeEngineStyle&&this.startChartTypeEngine(this.activeEngineStyle);}activateBarLayers(){this.maybeAutoAddVolume();}extendDepth(e,t){if(this.rawBars.length>t){this.setBarSeries(this.rawBars.slice(this.rawBars.length-t),{preserveView:true}),this.completeHistory("depth");return}if(this.rawBars.length===t){this.completeHistory("depth");return}this.historyState="backfill",this.backfillHistory(e,t);}async backfillHistory(e,t){try{for(;this.generation===e&&this.rawBars.length<t&&this.rawBars.length>0;){let n=t-this.rawBars.length,i=bp,o=await this.feed.loadRange(this.config.market,{to:this.rawBars[0].time,limit:Math.min(i,n)+1});if(this.generation!==e)return;let s=this.rawBars[0].time,a=o.filter(l=>l.time<s);if(a.length===0){this.completeHistory("genesis");return}for(let l=1;l<a.length;l+=1)if(a[l].time<=a[l-1].time){console.warn("[vela] non-monotonic history chunk \u2014 stopping the backfill"),this.completeHistory("aborted");return}this.setBarSeries([...a,...this.rawBars],{preserveView:!0}),this.notifySessionsBars("backfill"),this.events.emit("history:progress",{loaded:this.rawBars.length,target:t});}this.generation===e&&this.completeHistory("depth");}catch(n){console.warn(`[vela] history backfill failed \u2014 keeping ${this.rawBars.length} bars (${n instanceof Error?n.message:String(n)})`),this.generation===e&&this.completeHistory("aborted");}}completeHistory(e){this.historyCompleted||(this.historyCompleted=true,this.historyState="complete",this.notifySessionsBars("complete"),this.events.emit("history:complete",{reason:e,oldestTime:this.rawBars[0]?.time??0,barsLoaded:this.rawBars.length}),this.resolveHistoryComplete());}historyComplete(){return this.historyCompletePromise}qualifiedSymbol(){let e=this.config.market;return e.symbol?e.symbol:null}refreshPriceFormat(){if(!this.renderer.setPricePrecision)return;let e=this.feed.symbolInfo?.(this.config.market)?.mintick;this.renderer.setPricePrecision(typeof e=="number"&&e>0?e:void 0);}async ensurePriceFormat(){if(!this.renderer.setPricePrecision)return;let e=this.qualifiedSymbol();if(e)try{await this.dataControl.symbolInfo(e),this.refreshPriceFormat();}catch{}}maybeAutoAddVolume(){!this.config.volume||this.volumeOptedOut||!this.renderer.setNativeData||di("volume")&&this.addNativeIndicator("volume");}syncPriceStyle(e){typeof e=="string"&&(this.priceStyle=e),this.syncBarTransform(e),this.syncChartTypeEngine(e);}syncChartTypeEngine(e){let t=typeof e=="string"?e:null,i=Nt(t)?.dataEngine?t:null;i!==this.activeEngineStyle&&(this.activeEngineStyle&&this.typeEngines.get(this.activeEngineStyle)?.suspend(),this.activeEngineStyle=i,i&&this.startChartTypeEngine(i));}async startChartTypeEngine(e){if(!this.renderer.setNativeData||(await this.readyPromise,this.activeEngineStyle!==e))return;let t=this.typeEngines.get(e);if(t){t.resume();return}let n=Nt(e);if(!n?.dataEngine)return;let i=n.dataEngine();this.typeEngines.set(e,i);let o=this.typeSettings.get(e);o&&i.onSettings?.(o),i.start({symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",live:this.config.live??false,session:this.config.market.session,bars:()=>this.bars,data:this.dataControl,pushData:s=>this.renderer.setNativeData?.(e,s),pushPending:s=>this.renderer.setNativeData?.(`${e}-pending`,s)});}syncBarTransform(e){let t=fr(e);t!==this.barTransform&&(this.barTransform=t,this.rawBars.length!==0&&(this.bars=t?t.full(this.rawBars):this.rawBars,this.renderer.setBars(this.bars,{preserveView:true}),this.reexecuteIndicators()));}reexecuteIndicators(){for(let e of this.registry.all()){if(e.hidden||!e.session)continue;e.session.stop(),e.session=void 0,e.pendingStructural=true,e.pendingCause="market",this.setLoading(e,true);let t=this.handles.get(e.id);t&&this.executeIndicator(e.id,t);}}onBar(e){if(this.healing){this.healBuffer.push(e);return}let t=this.rawBars[this.rawBars.length-1];if(t&&this.canHeal()&&e.time>t.time+this.barIntervalMs()*u0&&Date.now()-this.lastHealAt>vp){this.healBuffer.push(e),this.healGap(t.time);return}this.applyBar(e);}setBarSeries(e,t){this.rawBars=e,this.bars=this.barTransform?this.barTransform.full(e):e,this.renderer.setBars(this.bars,{preserveView:t?.preserveView}),!t?.clearing&&this.bars.length>0&&this.endLoad();}applyBar(e,t=true){let n=this.rawBars[this.rawBars.length-1],i=e;if(n&&e.time===n.time)this.rawBars[this.rawBars.length-1]=e,this.barCause="tick",this.barTransform&&(i=this.barTransform.next(e,this.bars[this.bars.length-2]),this.bars[this.bars.length-1]=i);else if(!n||e.time>n.time)this.rawBars.push(e),this.barCause="bar",this.barTransform&&(i=this.barTransform.next(e,this.bars[this.bars.length-1]),this.bars.push(i));else return;this.renderer.updateBar(i),this.events.emit("bar",e),t&&this.notifySessionsBars(this.historyState==="backfill"?"backfill":void 0);}notifySessionsBars(e){if(this.switchingMarket)return;let t=e?"history":this.barCause;for(let n of this.registry.all())!n.renderHandle||n.hidden||(n.session?(n.pendingCause=t,n.session.notifyBars(e)):n.native&&n.native.instance.onBars());}canHeal(){return !!this.feed.loadRange&&!this.config.market.data?.length}barIntervalMs(){return et(this.config.market.timeframe??"60")}async healGap(e){let t=this.generation;this.healing=true,this.lastHealAt=Date.now();try{let n=await this.feed.loadRange(this.config.market,{from:e});if(this.generation!==t)return;for(let i of n)this.applyBar(i,!1);}catch{}finally{if(this.generation===t){this.healing=false;let n=this.healBuffer;this.healBuffer=[];for(let i of n)this.applyBar(i,false);this.notifySessionsBars(this.historyState==="backfill"?"backfill":void 0);}}}registerEngine(e,t){let n=this.engines.get(e);n&&n!==t&&console.warn(`[vela] re-registering scripting engine for language "${e}"; replacing ${n.constructor.name} with ${t.constructor.name}.`),this.engines.set(e,t);}addIndicator(e,t={}){let n=this.registry.nextId(),i=t.title??"Indicator",o=new or(n,i,this,e);return this.handles.set(n,o),this.registry.add({id:n,title:i,source:e,options:t,inputValues:{...t.inputs??{}},propValues:{...t.props??{}}}),this.startIndicator(n,e,t,o),o}addNativeIndicator(e,t={}){let n=this.registry.all().find(c=>c.native?.type===e);if(n)return this.handles.get(n.id)??new or(n.id,n.title,this);let i=di(e),o=this.registry.nextId("native"),s=i?.title??e,a=new or(o,s,this);if(this.handles.set(o,a),!i)return console.warn(`[vela] addNativeIndicator("${e}") \u2014 no native indicator registered for this type.`),a;let l={...i.defaultInputs(),...t.inputs??{}};return this.registry.add({id:o,title:s,source:e,inputValues:l,propValues:{},native:{type:e,instance:i.create(),descriptor:i}}),a.setSchema(i.inputsSchema()),this.startNativeIndicator(o,a),a}presentNativeIndicators(){return this.registry.all().map(e=>e.native?.type).filter(e=>!!e)}async availableNativeIndicators(){let e=this.qualifiedSymbol(),t=new Set(this.presentNativeIndicators());return Promise.all(jo().map(async n=>({type:n.type,title:n.title,supported:await this.isNativeSupported(n,e),present:t.has(n.type),beta:n.beta})))}async isNativeSupported(e,t){if(!e.isSupported)return true;if(!t)return false;try{return await e.isSupported(t,this.dataControl)}catch{return false}}applyInputs(e,t){let n=this.registry.get(e);!n||!n.session&&!n.native||(n.inputValues={...n.inputValues,...t},n.renderHandle&&this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues),n.pendingStructural=true,!n.hidden&&!n.native&&this.setLoading(n,true),n.pendingCause="inputs",n.session?n.session.update(n.inputValues):n.native&&!n.hidden&&n.native.instance.setInputs(n.inputValues),this.events.emit("indicator:inputs",{id:e}));}inputValuesOf(e){return {...this.registry.get(e)?.inputValues}}propValuesOf(e){return {...this.registry.get(e)?.propValues}}applyProps(e,t){let n=this.registry.get(e);n?.session&&(n.propValues={...n.propValues,...t},n.renderHandle&&this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues,n.propValues),n.pendingStructural=true,n.hidden||this.setLoading(n,true),n.pendingCause="inputs",n.session.update(n.inputValues,n.propValues),this.events.emit("indicator:inputs",{id:e}));}listIndicators(){return [...this.handles.values()]}getIndicatorContext(e,t){return this.registry.get(e)?.session?.getContext?.(t)??Promise.resolve(null)}removeIndicator(e){let t=this.registry.remove(e);t?.native?.type==="volume"&&(this.volumeOptedOut=true),t?.session?.stop(),t?.native?.instance.stop(),this.handles.delete(e),t?.renderHandle&&this.renderer.removeIndicator(t.renderHandle);let n=t?.model?.paneId;n&&n!=="price"&&!this.paneStillUsed(n)&&(this.renderer.removePane(n),this.forgetPane(n),this.events.emit("pane:changed",void 0)),this.events.emit("indicator:removed",{id:e});}setVisible(e,t){let n=this.registry.get(e);if(!(!n||n.hidden===!t)){if(n.hidden=!t,this.handles.get(e)?.setVisibleState(t),!t)n.session?.stop(),n.session=void 0,n.native?.instance.suspend(),n.renderHandle&&this.renderer.setIndicatorVisible?.(n.renderHandle,false);else if(n.renderHandle&&this.renderer.setIndicatorVisible?.(n.renderHandle,true),n.pendingStructural=true,n.native)if(n.native.stale){n.native.stale=false;let i=this.handles.get(e);i&&this.startNativeIndicator(e,i);}else n.native.instance.resume();else {this.setLoading(n,true);let i=this.handles.get(e);i&&this.executeIndicator(e,i);}this.events.emit("indicator:visibility",{id:e,visible:t});}}ready(){return this.readyPromise}inspect(){let e=[...this.registry.all()].filter(t=>!t.loading).sort((t,n)=>(n.native?1:0)-(t.native?1:0));return Eh(e.map(t=>t.model).filter(t=>t!=null))}resize(){this.renderer.resize();}setTheme(e){let t=this.config.theme;Object.keys(e).every(n=>e[n]===t[n])||(this.config.theme=e,this.renderer.setTheme(e),this.events.emit("theme:changed",e));}getVisibleRange(){return this.renderer.getVisibleRange()}setVisibleRange(e){this.renderer.setVisibleRange(e);}panBy(e){if(this.renderer.panBy){this.renderer.panBy(e);return}let t=this.renderer.getVisibleRange();if(!t)return;let n=(t.to-t.from)*e;this.renderer.setVisibleRange({from:t.from+n,to:t.to+n});}setVisibleRangePreset(e){let t=Ph(e,this.bars);t&&this.renderer.setVisibleRange(t);}destroy(){this.bumpGeneration(),this.resolveHistoryComplete(),this.stopLive(),this.viewportTimer!=null&&clearTimeout(this.viewportTimer),this.viewportUnsub?.(),this.paneActionUnsub?.();for(let e of this.registry.all())e.session?.stop(),e.native?.instance.stop();for(let e of this.typeEngines.values())e.stop();this.typeEngines.clear(),this.activeEngineStyle=null,this.unresolvedUnsub?.(),this.unresolvedUnsub=null,this.feed.destroy?.(),this.drawings.destroy(),this.renderer.destroy(),this.events.clear();}async startIndicator(e,t,n,i){try{if(await this.readyPromise,!this.registry.get(e))return;await h0();let o=this.registry.get(e);if(!o)return;let s=this.engineFor(n.language);o.engine=s;let a=await s.prepare(t,e);o.prepared=a;let l={};for(let d of a.inputs)l[d.key]=d.defval;o.inputValues={...l,...o.inputValues},i.setSchema(a.inputs);let c={};for(let d of a.props??[])c[d.key]=d.defval;o.propValues={...c,...o.propValues},i.setPropsSchema(a.props??[]),this.mountLoadingPlaceholder(e,o),this.executeIndicator(e,i);}catch(o){this.fail(e,i,o);}}executeIndicator(e,t){let n=this.registry.get(e);if(!n||!n.engine||!n.prepared||n.hidden)return;let i=this.config.live&&!n.prepared.reactsToViewport&&n.engine.capabilities.streaming?"live":"static";n.session=n.engine.execute({prepared:n.prepared,market:this.market(),bars:this.bars,getBars:()=>this.bars,fetchSeries:(o,s,a)=>this.fetchSeries(o,s,a),inputs:n.inputValues,props:n.propValues,visibleRange:this.currentVisibleRange(),mode:i,historyState:this.historyState},{onModel:o=>{let s=!n.announced,a=n.pendingCause??"history";this.applyModel(e,o)&&(n.pendingCause=void 0,this.emitContextChanged(e),this.emitScriptRun(e,a,s));},onAlert:o=>{let s=n.options?.title??n.prepared?.meta.title??n.title;this.events.emit("alert",{...o,indicator:s}),t.emit("alert",{id:o.id,message:o.message,title:o.title,time:o.time});},onWarning:o=>this.events.emit("warning",o),onError:o=>this.fail(e,t,o)}),this.emitContextChanged(e);}async startNativeIndicator(e,t){try{await this.readyPromise;let n=this.registry.get(e);if(!n?.native||n.hidden)return;let i={symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",live:this.config.live,session:this.config.market.session,bars:()=>this.bars,data:this.dataControl,emit:o=>this.applyModel(e,this.buildNativeModel(n,o)),pushData:o=>this.renderer.setNativeData?.(n.native.type,o),setStatus:o=>{n.renderHandle&&!n.hidden&&this.renderer.setIndicatorStatus?.(n.renderHandle,o);}};n.native.instance.start(i,n.inputValues);}catch(n){this.fail(e,t,n);}}buildNativeModel(e,t){let n=e.native.descriptor;return {id:e.id,title:e.title,...n.shortTitle?{shorttitle:n.shortTitle}:{},overlay:n.overlay,paneHint:n.paneHint,native:{type:e.native.type},...t.paneAxis!=null?{paneAxis:t.paneAxis}:{},series:t.series??[],fills:t.fills??[],backgrounds:t.backgrounds??[],priceLines:t.priceLines??[],...t.lines?{lines:t.lines}:{},...t.boxes?{boxes:t.boxes}:{},...t.labels?{labels:t.labels}:{},...t.polylines?{polylines:t.polylines}:{},...t.linefills?{linefills:t.linefills}:{},...t.tables?{tables:t.tables}:{},inputs:n.inputsSchema(),inputValues:e.inputValues}}mountLoadingPlaceholder(e,t){if(t.renderHandle||t.hidden||!t.prepared)return;let n=t.prepared.meta,i={id:e,title:t.options?.title??n.title,overlay:n.overlay,paneHint:n.overlay?"price":"new",series:[],fills:[],backgrounds:[],priceLines:[],inputs:t.prepared.inputs,inputValues:t.inputValues,...t.prepared.props?{props:t.prepared.props,propValues:t.propValues}:{}},o=this.routePane(e,i,t.options??{});this.placeModel(i,e,o),t.model=i,this.ensurePaneFor(o),t.renderHandle=this.renderer.mountIndicator(i),t.pendingStructural=true,this.setLoading(t,true);}setLoading(e,t){e.loading=t,e.renderHandle&&!e.hidden&&this.renderer.setIndicatorStatus?.(e.renderHandle,t?"loading":"idle");}ensurePaneFor(e){this.paneOrder.includes(e)||this.paneOrder.push(e),this.renderer.ensurePane({id:e,kind:e==="price"?"price":"study",order:this.paneOrder.indexOf(e)});}paneStillUsed(e){for(let t of this.registry.all())if(t.model?.paneId===e)return true;return false}forgetPane(e){let t=this.paneOrder.indexOf(e);t>0&&this.paneOrder.splice(t,1),this.collapsedPanes.delete(e),this.maximizedPaneId===e&&(this.maximizedPaneId=null);}paneManagementSupported(){return this.renderer.capabilities.paneManagement===true&&typeof this.renderer.setIndicatorPane=="function"}listPanes(){let e=new Map;for(let n of this.registry.all()){let i=n.model;if(!i)continue;let o=i.paneId??"price";e.has(o)||e.set(o,[]),e.get(o).push({id:n.id,title:i.title||n.title,ownScale:i.ownScale===true});}let t=[];for(let n of this.paneOrder)n!=="price"&&!e.has(n)||t.push({id:n,kind:n==="price"?"price":"study",order:t.length,collapsed:this.collapsedPanes.has(n),maximized:this.maximizedPaneId===n,indicators:e.get(n)??[]});return t}movePane(e,t){if(e==="price")return;let n=this.existingPaneIds(),i=n.indexOf(e);if(i<0)return;let o=t==="up"?i-1:i+1;o<=0||o>=n.length||([n[i],n[o]]=[n[o],n[i]],this.reorderPanes(n),this.events.emit("pane:moved",{paneId:e,dir:t}));}removePaneAndIndicators(e){if(e!=="price")for(let t of [...this.registry.all()])t.model?.paneId===e&&this.removeIndicator(t.id);}collapsePane(e,t){t?this.collapsedPanes.add(e):this.collapsedPanes.delete(e),this.renderer.setPaneCollapsed?.(e,t),this.events.emit("pane:changed",void 0);}maximizePane(e){this.maximizedPaneId=e,this.renderer.setPaneMaximized?.(e),this.events.emit("pane:changed",void 0);}moveIndicator(e,t){if(!this.paneManagementSupported()||!this.renderer.setIndicatorPane){console.warn("[vela] the active renderer does not support moving indicators between panes.");return}let n=this.registry.get(e);if(!n?.renderHandle||!n.model)return;let i=n.model,o=i.paneId??"price",s=this.resolveMoveTarget(e,i,t);if(!s)return;let{paneId:a,ownScale:l,insert:c}=s;a===o&&i.ownScale===true===l||(c?this.insertPaneOrder(a,c):this.paneOrder.includes(a)||this.paneOrder.push(a),i.ownScale=l,n.paneLocked=true,this.placeModel(i,e,a),this.ensurePaneFor(a),this.renderer.setIndicatorPane(n.renderHandle,a,{ownScale:l}),o!=="price"&&o!==a&&!this.paneStillUsed(o)&&(this.renderer.removePane(o),this.forgetPane(o)),this.reorderPanes(this.existingPaneIds()),this.events.emit("indicator:moved",{id:e,paneId:a}),this.events.emit("pane:changed",void 0));}resolveMoveTarget(e,t,n){if(n==="price"||typeof n=="object"&&"pane"in n&&n.pane==="price")return {paneId:"price",ownScale:!t.overlay};if("pane"in n)return this.existingPaneIds().includes(n.pane)?{paneId:n.pane,ownScale:true}:null;let i=n.newPane===true?{}:n.newPane;return {paneId:this.freshPaneId(e,t.paneId??"price"),ownScale:false,insert:i}}freshPaneId(e,t){let n=new Set(this.existingPaneIds()),i=`pane-${e}`;for(let o=2;i===t||n.has(i);o+=1)i=`pane-${e}-${o}`;return i}insertPaneOrder(e,t){let n=this.paneOrder.indexOf(e);n>0&&this.paneOrder.splice(n,1);let i=this.paneOrder.length;t.before&&this.paneOrder.includes(t.before)?i=this.paneOrder.indexOf(t.before):t.after&&this.paneOrder.includes(t.after)&&(i=this.paneOrder.indexOf(t.after)+1),i<1&&(i=1),this.paneOrder.splice(i,0,e);}existingPaneIds(){return this.paneOrder.filter(e=>e==="price"||this.paneStillUsed(e))}reorderPanes(e){this.paneOrder.length=0,this.paneOrder.push(...e),this.renderer.orderPanes?.(e),this.events.emit("pane:changed",void 0);}handlePaneAction(e){switch(e.type){case "remove":this.removePaneAndIndicators(e.paneId);break;case "move":{let t=this.existingPaneIds(),n=t.indexOf(e.paneId),i=e.dir==="up"?n-1:n+1;n>0&&i>0&&i<t.length&&([t[n],t[i]]=[t[i],t[n]],this.paneOrder.length=0,this.paneOrder.push(...t),this.events.emit("pane:changed",void 0),this.events.emit("pane:moved",{paneId:e.paneId,dir:e.dir}));break}case "collapse":e.collapsed?this.collapsedPanes.add(e.paneId):this.collapsedPanes.delete(e.paneId),this.events.emit("pane:changed",void 0);break;case "maximize":this.maximizedPaneId=e.maximized?e.paneId:null,this.events.emit("pane:changed",void 0);break}}announce(e,t){e.announced||(e.announced=true,this.events.emit("indicator:added",{id:e.id}),this.emitContextChanged(e.id),t?.emit("ready",void 0));}applyModel(e,t){let n=this.registry.get(e);if(!n||n.hidden)return true;if(n.loading&&this.bars.length===0&&!r.modelHasOutput(t))return false;let i=this.handles.get(e);if(!n.renderHandle){let a=this.routePane(e,t,n.options??{});return this.placeModel(t,e,a),n.model=t,this.ensurePaneFor(a),n.renderHandle=this.renderer.mountIndicator(t),n.pendingStructural=false,this.announce(n,i),true}let o=n.model?.paneId??"price",s=n.model?.ownScale===true;if(n.loading&&!n.paneLocked){let a=this.routePane(e,t,n.options??{});a!==o&&(o!=="price"&&(this.renderer.removePane(o),this.forgetPane(o)),this.ensurePaneFor(a),n.pendingStructural=true,o=a);}return this.placeModel(t,e,o),n.paneLocked&&(t.ownScale=s),n.model=t,n.pendingStructural?(n.renderHandle=this.renderer.mountIndicator(t),this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues,n.propValues),n.pendingStructural=false):this.renderer.updateIndicator(n.renderHandle,p0(t)),n.loading&&this.setLoading(n,false),this.announce(n,i),true}static modelHasOutput(e){return e.series.length>0||e.fills.length>0||e.backgrounds.length>0||e.priceLines.length>0||(e.lines?.length??0)>0||(e.boxes?.length??0)>0||(e.labels?.length??0)>0||(e.polylines?.length??0)>0||(e.linefills?.length??0)>0||(e.tables?.length??0)>0||(e.barColors?.length??0)>0||(e.trades?.length??0)>0}routePane(e,t,n){return n.pane==="new"?`pane-${e}`:n.pane==="price"||(n.overlay??t.overlay)?"price":`pane-${e}`}static plotsAtLastBar(e){let t={};for(let n of e.series)ve(n)&&(t[n.title]=n.points[n.points.length-1]?.value??null);return t}placeModel(e,t,n){e.id=t,e.paneId=n;let i=o=>o.overlay===true?"price":n;for(let o of e.series)o.paneId=i(o);for(let o of e.fills)o.paneId=i(o);for(let o of e.backgrounds)o.paneId=i(o);for(let o of e.priceLines)o.paneId=n;if(e.lines)for(let o of e.lines)o.paneId=i(o);if(e.boxes)for(let o of e.boxes)o.paneId=i(o);if(e.labels)for(let o of e.labels)o.paneId=i(o);if(e.polylines)for(let o of e.polylines)o.paneId=i(o);if(e.linefills)for(let o of e.linefills)o.paneId=i(o);if(e.tables)for(let o of e.tables)o.paneId=i(o);}emitContextChanged(e){if(!this.registry.get(e)?.session?.getContext)return;let t=Date.now();t-(this.contextEmitAt.get(e)??0)<1e3||(this.contextEmitAt.set(e,t),this.events.emit("context:changed",{id:e}));}emitScriptRun(e,t,n){let i=this.registry.get(e);if(!i||i.native||!this.events.hasListeners("script:run"))return;let o=Date.now();t==="tick"&&o-(this.runEmitAt.get(e)??0)<a0||(this.runEmitAt.set(e,o),Promise.resolve().then(()=>this.buildScriptRun(i,t,n)).then(s=>{s&&this.registry.get(e)&&this.events.emit("script:run",s);}));}async buildScriptRun(e,t,n){let i=e.model;if(!i)return null;let o=await this.pullContext(e,["variables","strategy","warnings"]),s=this.bars[this.bars.length-1];return {id:e.id,title:i.title,kind:o?.strategy||(i.trades?.length??0)>0?"strategy":"indicator",cause:t,first:n,bar:Math.max(0,this.bars.length-1),time:s?.time??0,forming:this.config.live&&this.bars.length>0,complete:this.historyState!=="backfill",plots:r.plotsAtLastBar(i),vars:o?.variables??{},...o?.strategy?{strategy:o.strategy}:{},warnings:o?.warnings??[],trades:async()=>(await this.pullContext(e,["trades"]))?.trades??[],series:async a=>((await this.pullContext(e,["plots"]))?.plots?.[a]??[]).map(c=>({time:c.time,value:typeof c.value=="number"?c.value:null}))}}async pullContext(e,t){try{return await e.session?.getContext?.(t)??null}catch{return null}}fail(e,t,n){let i=this.registry.get(e);i?.loading&&this.setLoading(i,false);let o=n instanceof Error?n:new Error(String(n));console.error(`[vela] indicator "${e}" failed:`,o.message),this.events.emit("indicator:error",{id:e,error:o}),t?.emit("error",{error:o});}};function h0(){return typeof requestAnimationFrame=="function"?new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(()=>r()))):new Promise(r=>setTimeout(r,0))}function p0(r){let e=[],t=Number.POSITIVE_INFINITY,n=0;for(let i of r.series)if(i.kind==="candle"||i.kind==="bar"){e.push({seriesId:i.id,kind:"bars",bars:i.bars});for(let o of i.bars)o.time<t&&(t=o.time),o.time>n&&(n=o.time);}else if(ve(i)){e.push({seriesId:i.id,kind:"points",points:i.points});for(let o of i.points)o.time<t&&(t=o.time),o.time>n&&(n=o.time);}return {kind:"value",indicatorId:r.id,dirty:{from:Number.isFinite(t)?t:0,to:n},anchorTime:r.anchorTime??null,series:e,lines:r.lines??[],boxes:r.boxes??[],labels:r.labels??[],polylines:r.polylines??[],linefills:r.linefills??[],tables:r.tables??[],trades:r.trades??[]}}var ki=class{constructor(e){this.renderer=e;}get name(){return this.renderer.name}get capabilities(){return this.renderer.capabilities}supports(e){return this.renderer.features.includes(e)}get(e){return this.renderer.readFeature(e)}set(e,t){let n=typeof e=="string"?[[e,t]]:Object.entries(e);for(let[i,o]of n)this.renderer.features.includes(i)?this.renderer.applyFeature(i,o):console.warn(`[vela] renderer "${this.renderer.name}" has no feature "${i}" \u2014 set ignored.`);return this}setLegendActions(e){this.renderer.setLegendActions?.(e);}setLegendCallouts(e){this.renderer.setLegendCallouts?.(e);}setLegendOverviewAction(e){return this.renderer.setLegendOverviewAction?.(e),this}get supportsIndicatorSettings(){return typeof this.renderer.openIndicatorSettings=="function"}openIndicatorSettings(e){return this.renderer.openIndicatorSettings?.(e),this}screenshot(){return typeof this.renderer.screenshot=="function"?this.renderer.screenshot():(console.warn(`[vela] renderer "${this.renderer.name}" does not support screenshot().`),null)}getConfig(){return typeof this.renderer.getConfig=="function"?this.renderer.getConfig():(console.warn(`[vela] renderer "${this.renderer.name}" does not support getConfig().`),null)}applyConfig(e){return typeof this.renderer.applyConfig=="function"?this.renderer.applyConfig(e):console.warn(`[vela] renderer "${this.renderer.name}" does not support applyConfig().`),this}onConfigChanged(e){return this.renderer.onConfigChanged?.(e)??(()=>{})}onCrosshairMove(e){return this.renderer.onCrosshairMove(e)}onAxisLongPress(e){return this.renderer.onAxisLongPress?.(e)??(()=>{})}dataWindowReadout(){return this.renderer.getDataWindowReadout?.()??null}setSymbolPicker(e){return typeof this.renderer.setSymbolPicker=="function"?this.renderer.setSymbolPicker(e):console.warn(`[vela] renderer "${this.renderer.name}" does not support setSymbolPicker().`),this}focus(){return this.renderer.focus?.(),this}get supportsExternalCrosshair(){return typeof this.renderer.setExternalCrosshair=="function"}setExternalCrosshair(e,t=null){return this.renderer.setExternalCrosshair?.(e,t),this}closeDialogs(){return this.renderer.closeDialogs?.(),this}openSettings(e){return this.renderer.openSettingsDialog?.(e),this}setSettingsSections(e){return this.renderer.setSettingsSections?.(e),this}setSettingsVisibility(e){return this.renderer.setSettingsVisibility?.(e),this}listSettingsIds(){return this.renderer.listSettingsIds?.()??[]}setLayoutMode(e){return this.renderer.setLayoutMode?.(e),this}};var br=new Map;function m0(r){let e=Object.entries(r);for(let[t,n]of e)br.set(t,n);return ()=>{for(let[t,n]of e)br.get(t)===n&&br.delete(t);}}function f0(...r){if(r.length===0)br.clear();else for(let e of r)br.delete(e);}function Dc(){return Object.fromEntries(br)}var pa=class{constructor(e){this.controller=e;}get supported(){return this.controller.paneManagementSupported()}list(){return this.controller.listPanes()}move(e,t){return this.guard()&&this.controller.movePane(e,t),this}remove(e){return this.guard()&&this.controller.removePaneAndIndicators(e),this}collapse(e,t=true){return this.guard()&&this.controller.collapsePane(e,t),this}maximize(e){return this.guard()&&this.controller.maximizePane(e),this}moveIndicator(e,t){return this.guard()&&this.controller.moveIndicator(e,t),this}guard(){return this.controller.paneManagementSupported()?true:(console.warn("[vela] the active renderer does not support pane management \u2014 chart.panes mutation ignored."),false)}};function yp(r,e,t,n){return `${r}|${e}|${t}${n&&n!=="regular"?`|${n}`:""}`}function g0(r){return r.split("|")[1]??""}var ma=class{constructor(){this.series=new Map;this.coveredFrom=new Map;this.retained=new Set;this.retainedByOwner=new Map;}get(e){return this.series.get(e)}markCovered(e,t){this.coveredFrom.set(e,Math.min(this.coveredFrom.get(e)??1/0,t));}coveredFromOf(e){return this.coveredFrom.get(e)}merge(e,t){if(t.length===0)return this.series.get(e)??[];let n=new Map;for(let o of this.series.get(e)??[])n.set(o.time,o);for(let o of t)n.set(o.time,o);let i=[...n.values()].sort((o,s)=>o.time-s.time);return this.series.set(e,i),i}retainSymbol(e){this.currentSymbol!==e&&(this.currentSymbol=e,this.purgeOutside(e));}retain(e,t="default"){e.size===0?this.retainedByOwner.delete(t):this.retainedByOwner.set(t,new Set(e));let n=new Set;for(let i of this.retainedByOwner.values())for(let o of i)n.add(o);this.retained=n,this.purgeOutside(this.currentSymbol);}purgeOutside(e){for(let t of [...this.series.keys()]){let n=g0(t);n!==e&&!this.retained.has(n)&&(this.series.delete(t),this.coveredFrom.delete(t));}}clear(){this.series.clear(),this.coveredFrom.clear();}},Ii=new ma;function Oc(r,e,t){let{provider:n,ticker:i}=gt(r);return yp(n??"",i,e,t)}var Ri=1e4,b0=Ri+1,Di=class{constructor(e,t=Ii){this.inner=e;this.store=t;}async load(e){if(e.data&&e.data.length>0)return this.inner.load(e);let t=e.symbol??"TEST",n=Oc(t,e.timeframe??"60",e.session);this.store.retainSymbol(t);let i=this.store.get(n),o=e.bars??500,s=i?.[i.length-1];if(i&&s&&i.length>=o-1&&this.inner.loadRange){let{bars:l}=await this.fetchRange(e,{from:s.time}),c=this.store.merge(n,Ai(l));return wp(c,l[l.length-1]).slice(-o)}let a=await this.inner.load(e);return this.store.merge(n,Ai(a)),a}async loadProgressive(e,t,n){if(e.data&&e.data.length>0)return this.inner.load(e);if(!this.inner.loadProgressive)return null;let i=e.symbol??"TEST",o=Oc(i,e.timeframe??"60",e.session),s=this.store.get(o),a=e.bars??500,l=s?.[s.length-1];if(s&&l&&s.length>=a-1&&this.inner.loadRange)return this.load(e);this.store.retainSymbol(i);let c=await this.inner.loadProgressive(e,t,n);return c==null?null:(this.store.merge(o,Ai(c)),c)}async loadRange(e,t){if(!this.inner.loadRange)return this.inner.load(e);let n=Oc(e.symbol??"TEST",e.timeframe??"60",e.session),i=this.store.get(n),o=i?.[i.length-1];if(t.to!=null&&o&&t.to<o.time){let d=i.filter(f=>f.time<=t.to),u=this.store.coveredFromOf(n)??1/0;if(t.limit!=null?d.length>=t.limit&&(t.from==null||u<=t.from):t.from!=null&&u<=t.from){let f=t.from!=null?d.filter(g=>g.time>=t.from):d;return t.limit!=null&&f.length>t.limit&&(f=f.slice(-t.limit)),f}let p=await this.fetchRange(e,t),m=p.bars.filter(f=>f.time<=t.to);return m.length>0&&(this.store.merge(n,m),this.store.markCovered(n,p.coveredDownTo??m[0].time)),m}if(o&&t.from!=null){let d=this.store.coveredFromOf(n);if(d!=null&&d>t.from){let{bars:u,coveredDownTo:h}=await this.fetchRange(e,{from:t.from,to:d});this.store.merge(n,u.filter(p=>p.time<=d)),this.store.markCovered(n,h??t.from),i=this.store.get(n),o=i?.[i.length-1];}}let s=this.store.coveredFromOf(n);if(!!i&&i.length>0&&!!o&&(t.from!=null?s!=null&&s<=t.from:t.limit==null||i.length>=t.limit)&&o){let{bars:d}=await this.fetchRange(e,{from:o.time,to:t.to,limit:t.limit}),u=this.store.merge(n,Ai(d)),h=wp(u,d[d.length-1]),p=t.from!=null?h.filter(m=>m.time>=t.from):h;return t.to!=null&&(p=p.filter(m=>m.time<=t.to)),p}let{bars:l,coveredDownTo:c}=await this.fetchRange(e,t);return this.store.merge(n,Ai(l)),this.store.markCovered(n,c??t.from??l[0]?.time??0),l}async fetchRange(e,t){let n=et(e.timeframe??"60"),i=v0(t,n);if(i<=b0){let c=await this.inner.loadRange(e,{...t,limit:t.limit??i});return {bars:c,coveredDownTo:t.from??c[0]?.time}}let o=new Map,s=t.to??Date.now();for(;!(t.from!=null&&s<t.from);){let c=t.limit!=null?t.limit-o.size:Ri;if(c<=0)break;let d=await this.inner.loadRange(e,{to:s,limit:Math.min(Ri,c)}),u=1/0;for(let h of d)h.time<u&&(u=h.time),h.time<=s&&(t.from==null||h.time>=t.from)&&o.set(h.time,h);if(d.length===0){if(t.from==null)break;s-=Ri*n;continue}if(u-1>=s)break;s=u-1;}let a=[...o.values()].sort((c,d)=>c.time-d.time),l=t.from!=null&&s<t.from;return {bars:a,coveredDownTo:l?t.from:a[0]?.time}}subscribe(e,t){return this.inner.subscribe(e,t)}symbolInfo(e){return this.inner.symbolInfo?.(e)}};function v0(r,e){if(r.limit!=null)return r.limit;if(r.from==null)return Ri;let t=Math.max(0,(r.to??Date.now())-r.from);return Math.ceil(t/e*1.1)+2}function Ai(r){return r.length>0?r.slice(0,-1):r}function wp(r,e){if(!e)return r;let t=r[r.length-1];return !t||e.time>t.time?[...r,e]:r}function y0(r){return {"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"2h":72e5,"4h":144e5,"1d":864e5,"1w":6048e5,"1M":2592e6,1:6e4,5:3e5,15:9e5,30:18e5,60:36e5,240:144e5,D:864e5,W:6048e5,M:2592e6}[r]??36e5}var Nn=class{constructor(e=Ii){this.registry=new ua;this.primaryProvider=null;this.liveBars=[];this.symInfoCache=new Map;this.cache=new Di(new Nc(this.registry),e);}registerProvider(e,t){return this.registry.register(e,t)}unregisterProvider(e){this.registry.unregister(e);}providers(){return this.registry.names().map(e=>this.registry.infoOf(e))}resolveSymbol(e){return this.registry.resolve(e,{default:this.primaryProvider})}displayPrefix(e){let t=this.resolveSymbol(e);return t?this.registry.displayPrefixOf(t):null}canonicalSymbol(e){let t=this.resolveSymbol(e);return t?this.registry.canonicalSymbol(t):null}providerInstance(e){return this.registry.get(e)}symbolIconOf(e){return this.registry.symbolIconOf(e)}symbolIcon(e){return this.registry.symbolIcon(this.resolveSymbol(e))}symbols(e){return this.registry.symbolsOf(e)}onUnresolved(e){return this.registry.onUnresolved(e)}destroy(){this.registry.cancelWaits();}ready(){return this.registry.indexReady()}async symbolInfoFor(e){let t=this.registry.resolve(e,{default:this.primaryProvider});if(!t)return;let n=await this.registry.get(t.provider)?.getSymbolInfo?.(t.ticker);return n&&this.symInfoCache.set(Fc(t),n),n}capabilitiesFor(e){let t=this.registry.resolve(e,{default:this.primaryProvider});if(!t)return null;let n=this.registry.get(t.provider);return n?n.capabilitiesFor?.(t.ticker)??this.registry.infoOf(t.provider).capabilities:null}async load(e){if(e.data&&e.data.length>0)return this.liveBars=e.data.map(n=>({...n})),e.data;let t=await this.registry.whenResolvable(Oi(e),{default:this.primaryProvider});return this.primaryProvider=t.provider,this.prefetchSymbolInfo(t),this.cache.load(fa(e,t))}async loadProgressive(e,t,n){if(e.data&&e.data.length>0)return this.liveBars=e.data.map(o=>({...o})),e.data;let i=await this.registry.whenResolvable(Oi(e),{default:this.primaryProvider});return this.primaryProvider=i.provider,this.prefetchSymbolInfo(i),this.cache.loadProgressive(fa(e,i),t,n)}symbolInfo(e){if(e.data&&e.data.length>0)return;let t=this.registry.resolve(Oi(e),{default:this.primaryProvider});return t?this.symInfoCache.get(Fc(t)):void 0}prefetchSymbolInfo(e){let t=Fc(e);if(this.symInfoCache.has(t))return;let n=this.registry.get(e.provider);n?.getSymbolInfo&&n.getSymbolInfo(e.ticker).then(i=>{i&&this.symInfoCache.set(t,i);}).catch(()=>{});}async loadRange(e,t){if(e.data&&e.data.length>0)return this.cache.loadRange(e,t);let n=this.registry.resolve(Oi(e),{default:this.primaryProvider});return n?this.cache.loadRange(fa(e,n),t):[]}subscribe(e,t){if(e.data&&e.data.length>0)return this.synthesizeTicks(e,t);let n=this.registry.resolve(Oi(e),{default:this.primaryProvider});return n?this.cache.subscribe(fa(e,n),t):()=>{}}synthesizeTicks(e,t){if(this.liveBars.length===0)return ()=>{};let n=y0(e.timeframe??"60"),i=setInterval(()=>{let o=this.liveBars,s=o[o.length-1];if(!s)return;let a=s.close*.0015*(Math.random()-.5)*2,l=Math.max(0,s.close+a),c={...s,close:l,high:Math.max(s.high,l),low:Math.min(s.low,l)};if(o[o.length-1]=c,t(c),Math.random()<.12){let d={time:c.time+n,open:c.close,high:c.close,low:c.close,close:c.close,volume:0};o.push(d),t(d);}},1e3);return ()=>clearInterval(i)}};function Oi(r){return r.symbol??""}function fa(r,e){return {...r,symbol:`${e.provider}:${e.ticker}`}}function Fc(r){return `${r.provider}|${r.ticker}`}async function xp(r,e,t,n){try{return await r.getBars(e,t,n)}catch(i){return console.warn(`[vela] data fetch failed for ${e} ${t} \u2014 ${i instanceof Error?i.message:String(i)}`),[]}}var Nc=class{constructor(e){this.registry=e;}load(e){let{provider:t,ticker:n}=gt(e.symbol??""),i=this.registry.get(t??"");return i?xp(i,n,e.timeframe??"60",{limit:e.bars??500,session:e.session}):Promise.resolve([])}async loadProgressive(e,t,n){let{provider:i,ticker:o}=gt(e.symbol??""),s=this.registry.get(i??"");if(!s)return [];if(!s.getBarsProgressive)return null;try{return await s.getBarsProgressive(o,e.timeframe??"60",{limit:e.bars??500,session:e.session},t,n)}catch(a){return console.warn(`[vela] progressive fetch failed for ${o} ${e.timeframe??"60"} \u2014 ${a instanceof Error?a.message:String(a)}`),[]}}loadRange(e,t){let{provider:n,ticker:i}=gt(e.symbol??""),o=this.registry.get(n??"");return o?xp(o,i,e.timeframe??"60",{...t,session:e.session}):Promise.resolve([])}subscribe(e,t){let{provider:n,ticker:i}=gt(e.symbol??""),o=this.registry.get(n??"");if(!o)return ()=>{};let s=e.timeframe??"60";if(o.subscribe)return o.subscribe(i,s,t,e.session?{session:e.session}:void 0);let a=false,l=null,c=async()=>{if(!a){try{let d=await o.getBars(i,s,{limit:2,session:e.session});if(a)return;for(let u of d)t(u);}catch{}a||(l=setTimeout(()=>{c();},3e3));}};return l=setTimeout(()=>{c();},3e3),()=>{a=true,l&&clearTimeout(l);}}};var Fi=class{constructor(e){this.registry=e instanceof Nn?e:null;}registerProvider(e,t){return this.registry?(this.registry.registerProvider(e,t),this):(console.warn(`[vela] chart.data.registerProvider("${e}") ignored \u2014 the active data feed is a custom feed (deps.dataFeed), not the default provider registry.`),this)}unregisterProvider(e){return this.registry?.unregisterProvider(e),this}providers(){return this.registry?.providers()??[]}resolve(e){return this.registry?.resolveSymbol(e)??null}displayPrefix(e){return this.registry?.displayPrefix(e)??null}canonicalSymbol(e){return this.registry?.canonicalSymbol(e)??null}providerInstance(e){return this.registry?.providerInstance(e)}symbols(e){return this.registry?.symbols(e)??[]}symbolIcon(e){return this.registry?.symbolIcon(e)}symbolInfo(e){return this.registry?.symbolInfoFor(e)??Promise.resolve(void 0)}capabilities(e){return this.registry?.capabilitiesFor(e)??null}ready(){return this.registry?.ready()??Promise.resolve()}};var Ni=class{constructor(e){this.ctrl=e;}get supported(){return this.ctrl.supported}setTool(e){return this.ok("setTool")&&this.ctrl.setTool(e),this}getTool(){return this.ctrl.getTool()}setSnapMode(e){return this.ok("setSnapMode")&&this.ctrl.setSnapMode(e),this}getSnapMode(){return this.ctrl.getSnapMode()}setStayMode(e){return this.ok("setStayMode")&&this.ctrl.setStayMode(e),this}getStayMode(){return this.ctrl.getStayMode()}setMode(e){return this.ok("setMode")&&this.ctrl.setMode(e),this}getMode(){return this.ctrl.getMode()}showToolbar(e=true){return this.ok("showToolbar")&&this.ctrl.showToolbar(e),this}setToolbar(e){return this.ok("setToolbar")&&this.ctrl.setToolbar(e),this}setToolShortcuts(e){return this.ok("setToolShortcuts")&&this.ctrl.setToolShortcuts(e),this}setExternalGhost(e){return this.ctrl.setExternalGhost(e),this}add(e,t={}){return this.ok("add")?this.ctrl.add(e,t):null}remove(e){return this.ctrl.remove(e),this}update(e,t){return this.ctrl.update(e,t),this}updateMany(e){return this.ctrl.updateMany(e),this}removeMany(e){return this.ctrl.removeMany(e),this}lock(e,t=true){return this.ctrl.setLocked(e,t),this}show(e,t=true){return this.ctrl.setVisible(e,t),this}select(e){return this.ok("select")&&this.ctrl.select(e==null?[]:typeof e=="string"?[e]:e),this}openSettings(e){return this.ok("openSettings")&&this.ctrl.openSettings(e),this}bringToFront(e){return this.ctrl.bringToFront(e),this}sendToBack(e){return this.ctrl.sendToBack(e),this}undo(){return this.ctrl.undo(),this}redo(){return this.ctrl.redo(),this}canUndo(){return this.ctrl.canUndo()}canRedo(){return this.ctrl.canRedo()}clone(e){return this.ok("clone")&&this.ctrl.clone(e),this}duplicate(e){return this.ok("duplicate")&&this.ctrl.duplicate(e),this}copyToClipboard(e){return this.ok("copy")&&this.ctrl.copy(e),this}paste(){return this.ok("paste")&&this.ctrl.paste(),this}all(){return this.ctrl.all()}toJSON(){return this.ctrl.toJSON()}fromJSON(e){return this.ctrl.fromJSON(e),this}favorites(){return this.ctrl.favorites()}isFavorite(e){return this.ctrl.isFavorite(e)}setFavorite(e,t){return this.ok("setFavorite")&&this.ctrl.setFavorite(e,t),this}setFavorites(e){return this.ok("setFavorites")&&this.ctrl.setFavorites([...e]),this}getConfig(){return this.ctrl.toJSON()}applyConfig(e){return this.ctrl.fromJSON(e),this}ok(e){return this.ctrl.supported?true:(console.warn(`[vela] chart.drawings.${e}() ignored \u2014 the active renderer has no userDrawings capability.`),false)}};function ga(r){let e=r.trim(),t=/^#([0-9a-f]{3})$/i.exec(e);if(t){let i=t[1];return {r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16)}}if(t=/^#([0-9a-f]{6})[0-9a-f]{0,2}$/i.exec(e),t){let i=t[1];return {r:parseInt(i.slice(0,2),16),g:parseInt(i.slice(2,4),16),b:parseInt(i.slice(4,6),16)}}let n=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i.exec(e);return n?{r:parseFloat(n[1]),g:parseFloat(n[2]),b:parseFloat(n[3])}:null}function $(r,e){let t=ga(r);return t?`rgba(${t.r},${t.g},${t.b},${e})`:r}function Sp(r,e,t){let n=ga(r),i=ga(e);if(!n||!i)return r;let o=(s,a)=>Math.round(s+(a-s)*t);return `rgb(${o(n.r,i.r)},${o(n.g,i.g)},${o(n.b,i.b)})`}function He(r){let e=ga(r);return e?.2126*e.r+.7152*e.g+.0722*e.b<128:true}var ba={"--vela-space-1":"4px","--vela-space-2":"8px","--vela-space-3":"12px","--vela-space-4":"16px","--vela-radius-sm":"4px","--vela-radius-md":"6px","--vela-radius-lg":"10px","--vela-z-tooltip":"60","--vela-z-menu":"50","--vela-z-dialog":"40","--vela-z-popover":"6000","--vela-ease":"cubic-bezier(0.22, 1, 0.36, 1)","--vela-dur-fast":"90ms","--vela-dur-med":"160ms","--vela-font-size-sm":"11px","--vela-font-size-md":"12px","--vela-font-size-lg":"14px"};function va(r){let e=He(r.background),t=i=>e?`rgba(255,255,255,${i})`:$(r.textColor,i+.02),n=Sp(r.background,e?"#ffffff":r.textColor,e?.03:.05);return {"--vela-font":r.fontFamily,"--vela-bg":r.background,"--vela-fg":e?"#d1d4dc":r.textColor,"--vela-fg-muted":e?"#868a96":$(r.textColor,.62),"--vela-fg-faint":$(r.textColor,.35),"--vela-fg-bright":e?"#f0f3fa":"#000000","--vela-surface":r.background,"--vela-surface-elev":n,"--vela-surface-overlay":n,"--vela-surface-sunken":r.background,"--vela-border":r.borderColor,"--vela-border-strong":e?"#34353b":$(r.textColor,.28),"--vela-border-soft":r.borderColor,"--vela-border-faint":$(r.textColor,.08),"--vela-hover":t(.06),"--vela-active":t(.1),"--vela-hover-strong":t(.16),"--vela-focus":$(r.textColor,.5),"--vela-focus-soft":$(r.textColor,.12),"--vela-separator-hover-band":$(r.textColor,.1),"--vela-separator-hover-line":$(r.textColor,.55),"--vela-scroll":$(r.textColor,.3),"--vela-accent":Ee,"--vela-accent-bright":sr,"--vela-highlight":Mh,"--vela-selected-bg":e?"#f0f3fa":r.textColor,"--vela-selected-fg":e?r.background:"#ffffff","--vela-fg-on-fill":"#ffffff","--vela-up":r.upColor,"--vela-down":r.downColor,"--vela-danger":r.downColor,"--vela-shadow":"0 8px 30px rgba(0,0,0,0.5)","--vela-shadow-dialog":"0 20px 60px rgba(0,0,0,0.5)","--vela-backdrop":"rgba(0,0,0,0.45)"}}function fe(r,e){let t=n=>{for(let i in n)r.style.setProperty(i,n[i]);};t(ba),t(va(e));}function vt(r,e){let t=null,n=null,i=()=>{t!==null&&(clearTimeout(t),t=null),n?.remove(),n=null;},o=()=>{let a=e.text();if(!a)return;n=r.ownerDocument.createElement("div"),n.textContent=a,n.style.cssText="position:absolute;z-index:var(--vela-z-tooltip);pointer-events:none;background:var(--vela-bg);border:1px solid var(--vela-border);color:var(--vela-fg);border-radius:var(--vela-radius-md);padding:4px 9px;box-shadow:var(--vela-shadow);font:var(--vela-font-size-md) var(--vela-font);"+(e.wrap?"max-width:260px;":"white-space:nowrap;"),fe(n,e.theme()),e.host.appendChild(n);let c=r.getBoundingClientRect(),d=e.host.getBoundingClientRect();if(e.placement==="right")n.style.left=`${c.right-d.left+8}px`,n.style.top=`${c.top-d.top+(c.height-n.offsetHeight)/2}px`;else {let u=Math.min(c.left-d.left,Math.max(0,d.width-n.offsetWidth-4));n.style.left=`${Math.max(0,u)}px`,n.style.top=e.placement==="above"?`${Math.max(0,c.top-d.top-n.offsetHeight-6)}px`:`${c.bottom-d.top+6}px`;}},s=a=>{a.pointerType==="mouse"&&(i(),t=window.setTimeout(o,e.delayMs??700));};return r.addEventListener("pointerenter",s),r.addEventListener("pointerleave",i),r.addEventListener("pointerdown",i),()=>{r.removeEventListener("pointerenter",s),r.removeEventListener("pointerleave",i),r.removeEventListener("pointerdown",i),i();}}var w0=Object.defineProperty,x0=(r,e,t)=>e in r?w0(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,J=(r,e,t)=>x0(r,typeof e!="symbol"?e+"":e,t);function Cp(r){return r==null?[]:Array.isArray(r)?r:[r]}var Tp=r=>r[0],Ep=r=>r[r.length-1];function Pp(r,e,t={}){let{step:n=1,loop:i=true}=t,o=e+n,s=r.length,a=s-1;return e===-1?n>0?0:a:o<0?i?a:0:o>=s?i?0:e>s?s:e:o}function Lp(r,e,t={}){return r[Pp(r,e,t)]}function S0(r,e,t={}){let{step:n=1,loop:i=true}=t;return Pp(r,e,{step:-n,loop:i})}function Mp(r,e,t={}){return r[S0(r,e,t)]}var kp=r=>r?.constructor.name==="Array",C0=(r,e)=>{if(r.length!==e.length)return false;for(let t=0;t<r.length;t++)if(!vr(r[t],e[t]))return false;return true},vr=(r,e)=>{if(Object.is(r,e))return true;if(r==null&&e!=null||r!=null&&e==null)return false;if(typeof r?.isEqual=="function"&&typeof e?.isEqual=="function")return r.isEqual(e);if(typeof r=="function"&&typeof e=="function")return r.toString()===e.toString();if(kp(r)&&kp(e))return C0(Array.from(r),Array.from(e));if(typeof r!="object"||typeof e!="object")return false;let t=Object.keys(e??Object.create(null)),n=t.length;for(let i=0;i<n;i++)if(!Reflect.has(r,t[i]))return false;for(let i=0;i<n;i++){let o=t[i];if(!vr(r[o],e[o]))return false}return true};var T0=r=>r!=null&&typeof r=="object";var yr=r=>typeof r=="string",Ne=r=>typeof r=="function",Ip=r=>r==null,Vi=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),E0=r=>Object.prototype.toString.call(r),Ap=Function.prototype.toString,P0=Ap.call(Object),Vn=r=>{if(!T0(r)||E0(r)!="[object Object]"||k0(r))return false;let e=Object.getPrototypeOf(r);if(e===null)return true;let t=Vi(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Ap.call(t)==P0},L0=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,M0=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,k0=r=>L0(r)||M0(r);var _i=(r,...e)=>(typeof r=="function"?r(...e):r)??void 0,Vc=r=>r,Rp=r=>r(),_c=()=>{},tn=(...r)=>(...e)=>{r.forEach(function(t){t?.(...e);});};function nn(r){if(!Vn(r)||r===void 0)return r;let e=Reflect.ownKeys(r).filter(n=>typeof n=="string"),t={};for(let n of e){let i=r[n];i!==void 0&&(t[n]=nn(i));}return t}function wr(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function Bc(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function Bi(r,e){if(r==null)throw new Error(e())}var I0=(...r)=>r.map(e=>e?.trim?.()).filter(Boolean).join(" "),A0=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,Dp=r=>{let e={},t;for(;t=A0.exec(r);)e[t[1]]=t[2];return e},R0=(r,e)=>{if(yr(r)){if(yr(e))return `${r};${e}`;r=Dp(r);}else yr(e)&&(e=Dp(e));return Object.assign({},r??{},e??{})};function Op(...r){let e={};for(let t of r){if(!t)continue;for(let i in e){if(i.startsWith("on")&&typeof e[i]=="function"&&typeof t[i]=="function"){e[i]=tn(t[i],e[i]);continue}if(i==="className"||i==="class"){e[i]=I0(e[i],t[i]);continue}if(i==="style"){e[i]=R0(e[i],t[i]);continue}e[i]=t[i]!==void 0?t[i]:e[i];}for(let i in t)e[i]===void 0&&(e[i]=t[i]);let n=Object.getOwnPropertySymbols(t);for(let i of n)e[i]=t[i];}return e}var rn=".",Vp="#",Fp=new WeakMap,_p=new WeakMap;function Hc(r){return r.join(rn)}function D0(r){return r.includes(rn)}function Bp(r){return r.startsWith(Vp)}function O0(r){return r.startsWith(rn)}function F0(r){return Bp(r)?r.slice(Vp.length):r}function zc(r,e){return r?`${r}${rn}${e}`:e}function N0(r){let e=new Map,t=new Map,n=(i,o)=>{e.set(i,o);let s=o.id;s&&(t.has(s)&&Bc(`[zag-js] Duplicate state id: "${s}"`),t.set(s,i));let a=o.states;if(a){Bi(o.initial,()=>`[zag-js] Compound state "${i}" has child states but no "initial" property`),o.initial in a||Bc(`[zag-js] Compound state "${i}" has initial "${String(o.initial)}" which is not a child state`);for(let[l,c]of Object.entries(a)){if(!c)continue;let d=zc(i,l);n(d,c);}}};for(let[i,o]of Object.entries(r.states))o&&n(i,o);return {index:e,idIndex:t}}function xr(r){let e=Fp.get(r);if(e)return e;let{index:t,idIndex:n}=N0(r);return Fp.set(r,t),_p.set(r,n),t}function V0(r,e){return xr(r),_p.get(r)?.get(e)}function $c(r){return r?String(r).split(rn).filter(Boolean):[]}function ya(r,e){if(!e)return [];let t=xr(r),n=$c(e),i=[],o=[];for(let s of n){o.push(s);let a=Hc(o),l=t.get(a);if(!l)break;i.push({path:a,state:l});}return i}function Hi(r,e){let t=xr(r),n=$c(e);if(!n.length)return e;let i=[];for(let a of n){i.push(a);let l=Hc(i);if(!t.has(l))return e}let o=Hc(i),s=t.get(o);for(;s?.initial;){let a=`${o}${rn}${s.initial}`,l=t.get(a);if(!l)break;o=a,s=l;}return o}function Np(r,e){return xr(r).has(e)}function Wc(r,e,t){let n=String(e);if(Bp(n)){let i=F0(n),o=V0(r,i);return Bi(o,()=>`[zag-js] Unknown state id: "${i}"`),Hi(r,o)}if(O0(n)&&t){let i=zc(t,n.slice(1));return Hi(r,i)}if(!D0(n)&&t){let i=$c(t);for(let o=i.length-1;o>=1;o--){let s=i.slice(0,o).join(rn),a=zc(s,n);if(Np(r,a))return Hi(r,a)}if(Np(r,n))return Hi(r,n)}return Hi(r,n)}function Hp(r,e,t){let n=ya(r,e);for(let o=n.length-1;o>=0;o--){let a=n[o]?.state.on?.[t];if(a)return {transitions:a,source:n[o]?.path}}return {transitions:r.on?.[t],source:void 0}}function zp(r,e,t,n){let i=e?ya(r,e):[],o=ya(r,t),s=0;for(;s<i.length&&s<o.length&&i[s]?.path===o[s]?.path;)s+=1;let a=i.slice(s).reverse(),l=o.slice(s),c=i.at(-1)?.path===o.at(-1)?.path;return n&&c&&(a=i.slice().reverse(),l=o),{exiting:a,entering:l}}function $p(r,e){return r?r===e||r.startsWith(`${e}${rn}`):false}function Wp(r,e,t){return ya(r,e).some(n=>n.state.tags?.includes(t))}function Gp(){return {and:(...r)=>function(t){return r.every(n=>t.guard(n))},or:(...r)=>function(t){return r.some(n=>t.guard(n))},not:r=>function(t){return !t.guard(r)}}}function wa(r){return xr(r),r}var Sr=(r=>(r.NotStarted="Not Started",r.Started="Started",r.Stopped="Stopped",r))(Sr||{}),zi="__init__";var _0=Object.defineProperty,B0=(r,e,t)=>e in r?_0(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,xa=(r,e,t)=>B0(r,typeof e!="symbol"?e+"":e,t);var Up=(r,e)=>r.map((t,n)=>r[(Math.max(e,0)+n)%r.length]);var $i=()=>{},Wi=r=>typeof r=="object"&&r!==null;var Ge=r=>r?"":void 0,Gc=r=>r?"true":void 0;var H0=1,z0=9,$0=11;var Q=r=>Wi(r)&&r.nodeType===H0&&typeof r.nodeName=="string",Gi=r=>Wi(r)&&r.nodeType===z0,W0=r=>Wi(r)&&r===r.window;var Yp=r=>Q(r)?r.localName||"":"#document";function Kp(r){return ["html","body","#document"].includes(Yp(r))}var Xp=r=>Wi(r)&&r.nodeType!==void 0,_n=r=>Xp(r)&&r.nodeType===$0&&"host"in r,Uc=r=>Q(r)&&r.localName==="input",jp=r=>!!r?.matches("a[href]"),qp=r=>Q(r)?r.offsetWidth>0||r.offsetHeight>0||r.getClientRects().length>0:false;function Ui(r){if(!r)return false;let e=r.getRootNode();return yt(e)===r}var G0=/(textarea|select)/;function Cr(r){if(r==null||!Q(r))return false;try{return Uc(r)&&r.selectionStart!=null||G0.test(r.localName)||r.isContentEditable||r.getAttribute("contenteditable")==="true"||r.getAttribute("contenteditable")===""}catch{return false}}function Ve(r,e){if(!r||!e||!Q(r)||!Xp(e))return false;if(Q(e)&&r===e||r.contains(e))return true;let t=e.getRootNode?.();if(t&&_n(t)){let n=e;for(;n;){if(r===n)return true;n=n.parentNode||n.host;}}return false}function ue(r){return Gi(r)?r:W0(r)?r.document:r?.ownerDocument??document}function U0(r){return ue(r).documentElement}function ae(r){return _n(r)?ae(r.host):Gi(r)?r.defaultView??window:Q(r)?r.ownerDocument?.defaultView??window:window}function yt(r){let e=r.activeElement;for(;e?.shadowRoot;){let t=e.shadowRoot.activeElement;if(!t||t===e)break;e=t;}return e}function Zp(r){if(Yp(r)==="html")return r;let e=r.assignedSlot||r.parentNode||_n(r)&&r.host||U0(r);return _n(e)?e.host:e}function Sa(r){let e;try{if(e=r.getRootNode({composed:!0}),Gi(e)||_n(e))return e}catch{}return r.ownerDocument??document}var Yc=new WeakMap;function Tr(r){return Yc.has(r)||Yc.set(r,ae(r).getComputedStyle(r)),Yc.get(r)}var Kc=new Set(["menu","listbox","dialog","grid","tree","region","application"]),Y0=r=>Kc.has(r),Jp=r=>r.getAttribute("aria-controls")?.split(" ")||[];function Ca(r,e){let t=new Set,n=Sa(r),i=o=>{let s=o.querySelectorAll("[aria-controls]");for(let a of s){if(a.getAttribute("aria-expanded")!=="true")continue;let l=Jp(a);for(let c of l){if(!c||t.has(c))continue;t.add(c);let d=n.getElementById(c);if(d){let u=d.getAttribute("role"),h=d.getAttribute("aria-modal")==="true";if(u&&Y0(u)&&!h&&(d===e||d.contains(e)||i(d)))return true}}}return false};return i(r)}function Xc(r,e){let t=Sa(r),n=new Set,i=o=>{let s=o.querySelectorAll("[aria-controls]");for(let a of s){if(a.getAttribute("aria-expanded")!=="true")continue;let l=Jp(a);for(let c of l){if(!c||n.has(c))continue;n.add(c);let d=t.getElementById(c);if(d){let u=d.getAttribute("role"),h=d.getAttribute("aria-modal")==="true";u&&Kc.has(u)&&!h&&(e(d),i(d));}}}};i(r);}function Qp(r){let e=new Set;return Xc(r,t=>{r.contains(t)||e.add(t);}),Array.from(e)}function K0(r){let e=r.getAttribute("role");return !!(e&&Kc.has(e))}function X0(r){return r.hasAttribute("aria-controls")&&r.getAttribute("aria-expanded")==="true"}function em(r){return X0(r)?true:!!r.querySelector?.('[aria-controls][aria-expanded="true"]')}function tm(r){if(!r.id)return false;let e=Sa(r),t=CSS.escape(r.id),n=`[aria-controls~="${t}"][aria-expanded="true"], [aria-controls="${t}"][aria-expanded="true"]`;return !!(e.querySelector(n)&&K0(r))}var jc=()=>typeof document<"u";function j0(){return navigator.userAgentData?.platform??navigator.platform}function q0(){let r=navigator.userAgentData;return r&&Array.isArray(r.brands)?r.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(" "):navigator.userAgent}var qc=r=>jc()&&r.test(j0()),nm=r=>jc()&&r.test(q0());var Zc=()=>jc()&&!!navigator.maxTouchPoints,Z0=()=>qc(/^iPhone/i),J0=()=>qc(/^iPad/i)||Er()&&navigator.maxTouchPoints>1,rm=()=>Z0()||J0();var Er=()=>qc(/^Mac/i);var im=()=>nm(/Firefox/i);var om=()=>nm(/Android/i);function Q0(r){return r.composedPath?.()??r.nativeEvent?.composedPath?.()}function ge(r){return Q0(r)?.[0]??r.target}function Jc(r){let e=r.currentTarget;if(!e||!e.matches("a[href], button[type='submit'], input[type='submit']"))return false;let n=r.button===1,i=eC(r);return n||i}function Qc(r){let e=r.currentTarget;if(!e)return false;let t=e.localName;return r.altKey?t==="a"||t==="button"&&e.type==="submit"||t==="input"&&e.type==="submit":false}function eC(r){return Er()?r.metaKey:r.ctrlKey}function am(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function lm(r){return r.pointerType===""&&r.isTrusted?true:om()&&r.pointerType?r.type==="click"&&r.buttons===1:r.detail===0&&!r.pointerType}var Ta=r=>r.button===2||Er()&&r.ctrlKey&&r.button===0,cm=r=>r.ctrlKey||r.altKey||r.metaKey,tC=r=>"touches"in r&&r.touches.length>0,nC={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"},sm={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft"};function ed(r,e={}){let{dir:t="ltr",orientation:n="horizontal"}=e,i=r.key;return i=nC[i]??i,t==="rtl"&&n==="horizontal"&&i in sm&&(i=sm[i]),i}function Pr(r,e="client"){let t=tC(r)?r.touches[0]||r.changedTouches[0]:r;return {x:t[`${e}X`],y:t[`${e}Y`]}}var Me=(r,e,t,n)=>{let i=typeof r=="function"?r():r;return i?.addEventListener(e,t,n),()=>{i?.removeEventListener(e,t,n);}};var dm=r=>Q(r)&&r.tagName==="IFRAME",rC=/^(audio|video|details)$/;function um(r){let e=r.getAttribute("tabindex");return e?parseInt(e,10):NaN}var iC=r=>!Number.isNaN(um(r)),oC=r=>um(r)<0;function sC(r){return Uc(r)&&r.type==="radio"}function aC(r){if(!sC(r)||!r.name||r.checked)return true;let e=`input[type="radio"][name="${CSS.escape(r.name)}"]`,t=r.form??r.ownerDocument,n=Array.from(t.querySelectorAll(e)).filter(o=>o.form===r.form&&Ue(o)),i=n.find(o=>o.checked);return i?i===r:n[0]===r}function lC(r,e){if(!e)return null;if(e===true)return r.shadowRoot||null;let t=e(r);return (t===true?r.shadowRoot:t)||null}function hm(r,e,t){let n=[...r],i=[...r],o=new Set,s=new Map;r.forEach((l,c)=>s.set(l,c));let a=0;for(;a<i.length;){let l=i[a++];if(!l||o.has(l))continue;o.add(l);let c=lC(l,e);if(c){let d=Array.from(c.querySelectorAll(Ea)).filter(t),u=s.get(l);if(u!==void 0){let h=u+1;n.splice(h,0,...d),d.forEach((p,m)=>{s.set(p,h+m);});for(let p=h+d.length;p<n.length;p++)s.set(n[p],p);}else {let h=n.length;n.push(...d),d.forEach((p,m)=>{s.set(p,h+m);});}i.push(...d);}}return n}var Ea="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type",td=(r,e={})=>{if(!r)return [];let{includeContainer:t=false,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(Ea));(t==true||t=="if-empty"&&i.length===0)&&Q(r)&&Ue(r)&&i.unshift(r);let s=[];for(let a of i)if(Ue(a)){if(dm(a)&&a.contentDocument){let l=a.contentDocument.body;s.push(...td(l,{getShadowRoot:n}));continue}s.push(a);}return n?hm(s,n,Ue):s};function Ue(r){return !Q(r)||r.closest("[inert]")?false:r.matches(Ea)&&qp(r)}function Lr(r,e={}){if(!r)return [];let{includeContainer:t,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(Ea));t&&on(r)&&i.unshift(r);let o=[];for(let s of i)if(on(s)){if(dm(s)&&s.contentDocument){let a=s.contentDocument.body;o.push(...Lr(a,{getShadowRoot:n}));continue}o.push(s);}if(n){let s=hm(o,n,on);return !s.length&&t?i:s}return !o.length&&t?i:o}function on(r){return Q(r)&&r.tabIndex>0?true:!Ue(r)||oC(r)?false:aC(r)}function pm(r,e={}){let t=Lr(r,e),n=t[0]||null,i=t[t.length-1]||null;return [n,i]}function Mr(r){return r.tabIndex<0&&(rC.test(r.localName)||Cr(r))&&!iC(r)?0:r.tabIndex}function Pa(r){let{root:e,getInitialEl:t,filter:n,enabled:i=true}=r;if(!i)return;let o=null;if(o||(o=typeof t=="function"?t():t),o||(o=e?.querySelector("[data-autofocus],[autofocus]")),!o){let s=Lr(e);o=n?s.filter(n)[0]:s[0];}return o||e||void 0}function mm(r){let e=r.currentTarget;if(!e)return false;let[t,n]=pm(e);return !(Ui(t)&&r.shiftKey||Ui(n)&&!r.shiftKey||!t&&!n)}var cC=class fm{constructor(){xa(this,"id",null),xa(this,"fn_cleanup"),xa(this,"cleanup",()=>{this.cancel();});}static create(){return new fm}request(e){this.cancel(),this.id=globalThis.requestAnimationFrame(()=>{this.id=null,this.fn_cleanup=e?.();});}cancel(){this.id!==null&&(globalThis.cancelAnimationFrame(this.id),this.id=null),this.fn_cleanup?.(),this.fn_cleanup=void 0;}isActive(){return this.id!==null}};function he(r){let e=cC.create();return e.request(r),e.cleanup}function gm(r){let e=new Set;function t(n){let i=globalThis.requestAnimationFrame(n);e.add(()=>globalThis.cancelAnimationFrame(i));}return t(()=>t(r)),function(){e.forEach(i=>i());}}function bm(r,e,t){let n=he(()=>{r.removeEventListener(e,i,true),t();}),i=()=>{n(),t();};return r.addEventListener(e,i,{once:true,capture:true}),n}function dC(r,e){if(!r)return;let{attributes:t,callback:n}=e,i=r.ownerDocument.defaultView||window,o=new i.MutationObserver(s=>{for(let a of s)a.type==="attributes"&&a.attributeName&&t.includes(a.attributeName)&&n(a);});return o.observe(r,{attributes:true,attributeFilter:t}),()=>o.disconnect()}function vm(r,e){let n=he,i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(dC(o,e));})),()=>{i.forEach(o=>o?.());}}function ym(r){let e=()=>{let t=ae(r);r.dispatchEvent(new t.MouseEvent("click"));};im()?bm(r,"keyup",e):queueMicrotask(e);}function La(r){let e=Zp(r);return Kp(e)?ue(e).body:Q(e)&&nd(e)?e:La(e)}var uC=/auto|scroll|overlay|hidden|clip/,hC=new Set(["inline","contents"]);function nd(r){let e=ae(r),{overflow:t,overflowX:n,overflowY:i,display:o}=e.getComputedStyle(r);return uC.test(t+i+n)&&!hC.has(o)}function kr(r,e){return Array.from(r?.querySelectorAll(e)??[])}var Ma=r=>r.id;function pC(r,e,t=Ma){return r.find(n=>t(n)===e)}function wm(r,e,t=Ma){let n=pC(r,e,t);return n?r.indexOf(n):-1}function mC(r){return r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth}function xm(r,e){let{rootEl:t,...n}=e||{};!r||!t||!nd(t)||!mC(t)||r.scrollIntoView(n);}var fC=r=>r.split("").map(e=>{let t=e.charCodeAt(0);return t>0&&t<128?e:t>=128&&t<=255?`/x${t.toString(16)}`.replace("/","\\"):""}).join("").trim(),gC=r=>fC(r.dataset?.valuetext??r.textContent??""),bC=(r,e)=>r.trim().toLowerCase().startsWith(e.toLowerCase());function Sm(r,e,t,n=Ma){let i=t?wm(r,t,n):-1,o=t?Up(r,i):r;return e.length===1&&(o=o.filter(a=>n(a)!==t)),o.find(a=>bC(gC(a),e))}function Yi(r,e){if(!r)return $i;let t=Object.keys(e).reduce((n,i)=>(n[i]=r.style.getPropertyValue(i),n),{});return vC(t,e)?$i:(Object.assign(r.style,e),()=>{Object.assign(r.style,t),r.style.length===0&&r.removeAttribute("style");})}function Cm(r,e,t){if(!r)return $i;let n=r.style.getPropertyValue(e);return n===t?$i:(r.style.setProperty(e,t),()=>{r.style.setProperty(e,n),r.style.length===0&&r.removeAttribute("style");})}function vC(r,e){return Object.keys(r).every(t=>r[t]===e[t])}function yC(r,e){let{state:t,activeId:n,key:i,timeout:o=350,itemToId:s}=e,a=t.keysSoFar+i,c=a.length>1&&Array.from(a).every(m=>m===a[0])?a[0]:a,d=r.slice(),u=Sm(d,c,n,s);function h(){clearTimeout(t.timer),t.timer=-1;}function p(m){t.keysSoFar=m,h(),m!==""&&(t.timer=+setTimeout(()=>{p(""),h();},o));}return p(a),u}var ka=Object.assign(yC,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:wC});function wC(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function xC(r,e,t){let{signal:n}=e;return [new Promise((s,a)=>{let l=setTimeout(()=>{a(new Error(`Timeout of ${t}ms exceeded`));},t);n.addEventListener("abort",()=>{clearTimeout(l),a(new DOMException("Promise aborted","AbortError"));}),r.then(c=>{n.aborted||(clearTimeout(l),s(c));}).catch(c=>{n.aborted||(clearTimeout(l),a(c));});}),()=>e.abort()]}function Tm(r,e){let{timeout:t,rootNode:n}=e,i=ae(n),o=ue(n),s=new i.AbortController;return xC(new Promise(a=>{let l=r();if(l){a(l);return}let c=new i.MutationObserver(()=>{let d=r();d&&d.isConnected&&(c.disconnect(),a(d));});c.observe(o.body,{childList:true,subtree:true});}),s,t)}function Em(r){let e=()=>r.getRootNode?.()??document,t=()=>ue(e());return {...r,getRootNode:e,getDoc:t,getWin:()=>t().defaultView??window,getActiveElement:()=>yt(e()),isActiveElement:Ui,getById:s=>e().getElementById(s)}}function Pm(r){return new Proxy({},{get(e,t){return t==="style"?n=>r({style:n}).style:r}})}var Lm={onFocus:"onFocusin",onBlur:"onFocusout",onChange:"onInput",onDoubleClick:"onDblclick",htmlFor:"for",className:"class",defaultValue:"value",defaultChecked:"checked"},SC=new Set(["viewBox","preserveAspectRatio"]),CC=r=>{let e="";for(let t in r){let n=r[t];n!=null&&(t.startsWith("--")||(t=t.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)),e+=`${t}:${n};`);}return e},Ir=Pm(r=>Object.entries(r).reduce((e,[t,n])=>{if(n===void 0)return e;if(t in Lm&&(t=Lm[t]),t==="style"&&typeof n=="object")return e.style=CC(n),e;let i=SC.has(t)?t:t.toLowerCase();return e[i]=n,e},{}));var Ia=new WeakMap,Mm=new Set(["value","checked","selected"]),TC=new Set(["viewBox","preserveAspectRatio","clipPath","clipRule","fillRule","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit"]),EC=r=>r.tagName==="svg"||r.namespaceURI==="http://www.w3.org/2000/svg",Aa=(r,e)=>EC(r)&&TC.has(e)?e:e.toLowerCase();function _e(r,e,t){let n=t||"default",i=Ia.get(r);i||(i=new Map,Ia.set(r,i));let o=i.get(n)||{},s=Object.keys(e),a=(f,g)=>{r.addEventListener(f.toLowerCase(),g);},l=(f,g)=>{r.removeEventListener(f.toLowerCase(),g);},c=f=>f.startsWith("on"),d=f=>!f.startsWith("on"),u=f=>a(f.substring(2),e[f]),h=f=>l(f.substring(2),e[f]),p=f=>{let g=e[f],b=o[f];if(g!==b){if(f==="class"){r.className=g??"";return}if(Mm.has(f)){r[f]=g??"";return}if(typeof g=="boolean"&&!f.includes("aria-")){r.toggleAttribute(Aa(r,f),g);return}if(f==="children"){r.innerHTML=g;return}if(g!=null){r.setAttribute(Aa(r,f),g);return}r.removeAttribute(Aa(r,f));}};for(let f in o)e[f]==null&&(f==="class"?r.className="":Mm.has(f)?r[f]="":r.removeAttribute(Aa(r,f)));return Object.keys(o).filter(c).forEach(f=>{l(f.substring(2),o[f]);}),s.filter(c).forEach(u),s.filter(d).forEach(p),i.set(n,e),function(){s.filter(c).forEach(h);let g=Ia.get(r);g&&(g.delete(n),g.size===0&&Ia.delete(r));}}function PC(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function rd(r,e){let t=PC();return t?(t[r]||(t[r]=e()),t[r]):e()}var Ar=rd("__zag__refSet",()=>new WeakSet);var LC=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,MC=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,kC=r=>typeof r=="object"&&r!==null&&"nodeType"in r&&typeof r.nodeName=="string",IC=r=>LC(r)||MC(r)||kC(r),Ra=r=>r!==null&&typeof r=="object",id=r=>Ra(r)&&!Ar.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!IC(r)&&!(r instanceof WeakMap)&&!(r instanceof WeakSet)&&!(r instanceof Error)&&!(r instanceof Number)&&!(r instanceof Date)&&!(r instanceof String)&&!(r instanceof RegExp)&&!(r instanceof ArrayBuffer)&&!(r instanceof Promise)&&!(r instanceof File)&&!(r instanceof Blob)&&!(r instanceof AbortController);var AC=Symbol();var km=Object.getPrototypeOf,od=new WeakMap,RC=r=>r&&(od.has(r)?od.get(r):km(r)===Object.prototype||km(r)===Array.prototype);var Im=r=>RC(r)&&r[AC]||null,sd=(r,e=true)=>{od.set(r,e);};var Bn=rd("__zag__proxyStateMap",()=>new WeakMap),DC=(r=Object.is,e=(a,l)=>new Proxy(a,l),t=new WeakMap,n=(a,l)=>{let c=t.get(a);if(c?.[0]===l)return c[1];let d=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return sd(d,true),t.set(a,[l,d]),Reflect.ownKeys(a).forEach(u=>{let h=Reflect.get(a,u);Ar.has(h)?(sd(h,false),d[u]=h):Bn.has(h)?d[u]=Am(h):d[u]=h;}),Object.freeze(d)},i=new WeakMap,o=[1,1],s=a=>{if(!Ra(a))throw new Error("object required");let l=i.get(a);if(l)return l;let c=o[0],d=new Set,u=(S,P=++o[0])=>{c!==P&&(c=P,d.forEach(k=>k(S,P)));},h=o[1],p=(S=++o[1])=>(h!==S&&!d.size&&(h=S,f.forEach(([P])=>{let k=P[1](S);k>c&&(c=k);})),c),m=S=>(P,k)=>{let T=[...P];T[1]=[S,...T[1]],u(T,k);},f=new Map,g=(S,P)=>{if(d.size){let k=P[3](m(S));f.set(S,[P,k]);}else f.set(S,[P]);},b=S=>{let P=f.get(S);P&&(f.delete(S),P[1]?.());},y=S=>(d.add(S),d.size===1&&f.forEach(([k,T],M)=>{let L=k[3](m(M));f.set(M,[k,L]);}),()=>{d.delete(S),d.size===0&&f.forEach(([k,T],M)=>{T&&(T(),f.set(M,[k]));});}),v=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),E=e(v,{deleteProperty(S,P){let k=Reflect.get(S,P);b(P);let T=Reflect.deleteProperty(S,P);return T&&u(["delete",[P],k]),T},set(S,P,k,T){let M=Reflect.has(S,P),L=Reflect.get(S,P,T);if(M&&(r(L,k)||i.has(k)&&r(L,i.get(k))))return true;b(P),Ra(k)&&(k=Im(k)||k);let C=k;if(!Object.getOwnPropertyDescriptor(S,P)?.set){!Bn.has(k)&&id(k)&&(C=Da(k));let I=!Ar.has(C)&&Bn.get(C);I&&g(P,I);}return Reflect.set(S,P,C,T),u(["set",[P],k,L]),true}});i.set(a,E);let x=[v,p,n,y];return Bn.set(E,x),Reflect.ownKeys(a).forEach(S=>{let P=Object.getOwnPropertyDescriptor(a,S);P.get||P.set?Object.defineProperty(v,S,P):E[S]=a[S];}),E})=>[s,Bn,Ar,r,e,id,t,n,i,o],[OC]=DC();function Da(r={}){return OC(r)}function Oa(r,e,t){let n=Bn.get(r);let i,o=[],s=n[3],a=false,c=s(d=>{if(o.push(d),t);i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(o.splice(0));}));});return a=true,()=>{a=false,c();}}function Am(r){let e=Bn.get(r);let[t,n,i]=e;return i(t,n())}function Xi(r){let e=r().value??r().defaultValue;r().debug&&console.log(`[bindable > ${r().debug}] initial`,e);let t=r().isEqual??Object.is,n=Da({value:e}),i=()=>r().value!==void 0;return {initial:e,ref:n,get(){return i()?r().value:n.value},set(o){let s=i()?r().value:n.value,a=Ne(o)?o(s):o;r().debug&&console.log(`[bindable > ${r().debug}] setValue`,{next:a,prev:s}),i()||(n.value=a),t(a,s)||r().onChange?.(a,s);},invoke(o,s){r().onChange?.(o,s);},hash(o){return r().hash?.(o)??String(o)}}}Xi.cleanup=r=>{};Xi.ref=r=>{let e=r;return {get:()=>e,set:t=>{e=t;}}};function Rm(r){let e={current:r};return {get(t){return e.current[t]},set(t,n){e.current[t]=n;}}}function ad(r,e){if(!Vn(r)||!Vn(e))return e===void 0?r:e;let t={...r};for(let n of Object.keys(e)){let i=e[n],o=r[n];i!==void 0&&(Vn(o)&&Vn(i)?t[n]=ad(o,i):t[n]=i);}return t}var ld=class{constructor(r,e={}){J(this,"machine",r),J(this,"scope"),J(this,"context"),J(this,"prop"),J(this,"state"),J(this,"refs"),J(this,"computed"),J(this,"event",{type:""}),J(this,"previousEvent",{type:""}),J(this,"effects",new Map),J(this,"transition",null),J(this,"cleanups",[]),J(this,"subscriptions",[]),J(this,"userPropsRef"),J(this,"getEvent",()=>({...this.event,current:()=>this.event,previous:()=>this.previousEvent})),J(this,"getState",()=>({...this.state,matches:(...u)=>u.some(h=>$p(this.state.get(),h)),hasTag:u=>Wp(this.machine,this.state.get(),u)})),J(this,"debug",(...u)=>{this.machine.debug&&console.log(...u);}),J(this,"notify",()=>{this.publish();}),J(this,"send",u=>{this.status===Sr.Started&&queueMicrotask(()=>{if(!u)return;this.previousEvent=this.event,this.event=u,this.debug("send",u);let h=this.state.get(),p=u.type,{transitions:m,source:f}=Hp(this.machine,h,p),g=this.choose(m);if(!g)return;this.transition=g;let b=Wc(this.machine,g.target??h,f);this.debug("transition",g),b!==h?this.state.set(b):g.reenter?this.state.invoke(h,h):this.action(g.actions);});}),J(this,"action",u=>{let h=Ne(u)?u(this.getParams()):u;if(!h)return;let p=h.map(m=>{let f=this.machine.implementations?.actions?.[m];return f||wr(`[zag-js] No implementation found for action "${JSON.stringify(m)}"`),f});for(let m of p)m?.(this.getParams());}),J(this,"guard",u=>{if(Ne(u))return u(this.getParams());let h=this.machine.implementations?.guards?.[u];return h||wr(`[zag-js] No implementation found for guard "${JSON.stringify(u)}"`),h?.(this.getParams())}),J(this,"effect",u=>{let h=Ne(u)?u(this.getParams()):u;if(!h)return;let p=h.map(f=>{let g=this.machine.implementations?.effects?.[f];return g||wr(`[zag-js] No implementation found for effect "${JSON.stringify(f)}"`),g}),m=[];for(let f of p){let g=f?.(this.getParams());g&&m.push(g);}return ()=>m.forEach(f=>f?.())}),J(this,"choose",u=>Cp(u).find(h=>{let p=!h.guard;return yr(h.guard)?p=!!this.guard(h.guard):Ne(h.guard)&&(p=h.guard(this.getParams())),p})),J(this,"subscribe",u=>(this.subscriptions.push(u),()=>{let h=this.subscriptions.indexOf(u);h>-1&&this.subscriptions.splice(h,1);})),J(this,"status",Sr.NotStarted),J(this,"publish",()=>{this.callTrackers(),this.subscriptions.forEach(u=>u(this.service));}),J(this,"trackers",[]),J(this,"setupTrackers",()=>{this.machine.watch?.(this.getParams());}),J(this,"callTrackers",()=>{this.trackers.forEach(({deps:u,fn:h})=>{let p=u.map(m=>m());vr(h.prev,p)||(h(),h.prev=p);});}),J(this,"getParams",()=>({state:this.getState(),context:this.context,event:this.getEvent(),prop:this.prop,send:this.send,action:this.action,guard:this.guard,track:(u,h)=>{h.prev=u.map(p=>p()),this.trackers.push({deps:u,fn:h});},refs:this.refs,computed:this.computed,flush:Rp,scope:this.scope,choose:this.choose})),this.userPropsRef={current:e};let{id:t,ids:n,getRootNode:i}=_i(e);this.scope=Em({id:t,ids:n,getRootNode:i});let o=u=>{let h=_i(this.userPropsRef.current);return (r.props?.({props:nn(h),scope:this.scope})??h)[u]};this.prop=o;let s=r.context?.({prop:o,bindable:Xi,scope:this.scope,flush(u){queueMicrotask(u);},getContext(){return a},getComputed(){return l},getRefs(){return c},getEvent:this.getEvent.bind(this)});s&&Object.values(s).forEach(u=>{let h=Oa(u.ref,()=>this.notify());this.cleanups.push(h);});let a={get(u){return s?.[u].get()},set(u,h){s?.[u].set(h);},initial(u){return s?.[u].initial},hash(u){let h=s?.[u].get();return s?.[u].hash(h)}};this.context=a;let l=u=>(Bi(r.computed,()=>"[zag-js] No computed object found on machine"),r.computed[u]({context:a,event:this.getEvent(),prop:o,refs:this.refs,scope:this.scope,computed:l}));this.computed=l;let c=Rm(r.refs?.({prop:o,context:a})??{});this.refs=c;let d=Xi(()=>({defaultValue:Wc(r,r.initialState({prop:o})),onChange:(u,h)=>{let{exiting:p,entering:m}=zp(this.machine,h,u,this.transition?.reenter);if(p.forEach(f=>{this.effects.get(f.path)?.(),this.effects.delete(f.path);}),p.forEach(f=>{this.action(f.state?.exit);}),this.action(this.transition?.actions),m.forEach(f=>{let g=this.effect(f.state?.effects);if(g){let b=this.effects.get(f.path);this.effects.set(f.path,b?tn(b,g):g);}}),h===zi){this.action(r.entry);let f=this.effect(r.effects);if(f){let g=this.effects.get(zi);this.effects.set(zi,g?tn(g,f):f);}}m.forEach(f=>{this.action(f.state?.entry);});}}));this.state=d,this.cleanups.push(Oa(this.state.ref,()=>this.notify()));}updateProps(r){let e=this.userPropsRef.current;this.userPropsRef.current=()=>{let t=_i(e),n=_i(r);return ad(t,n)},this.notify();}start(){this.status=Sr.Started,this.debug("initializing..."),this.state.invoke(this.state.initial,zi),this.setupTrackers();}stop(){this.effects.forEach(r=>r?.()),this.effects.clear(),this.transition=null,this.action(this.machine.exit),this.cleanups.forEach(r=>r()),this.cleanups=[],this.subscriptions=[],this.status=Sr.Stopped,this.debug("unmounting...");}get service(){return {state:this.getState(),send:this.send,context:this.context,prop:this.prop,scope:this.scope,refs:this.refs,computed:this.computed,event:this.getEvent(),getStatus:()=>this.status}}};function Fa(r,e,t){let n=new ld(r,e),i=n.subscribe(t);return n.start(),t(n.service),{service:n.service,flush:()=>t(n.service),stop:()=>{i(),n.stop();}}}var FC=0;function Na(r){return `${r}-${++FC}`}function Hn(r,e=8){return `${r}::-webkit-scrollbar{width:${e}px;height:${e}px;}${r}::-webkit-scrollbar-thumb{background:var(--vela-scroll);border-radius:4px;border:2px solid transparent;background-clip:padding-box;}${r}::-webkit-scrollbar-track{background:transparent;}${r}::-webkit-scrollbar-button{display:none;width:0;height:0;}`}var Dm="outline:none;transition:border-color .12s ease,box-shadow .12s ease;",Om="border-color:var(--vela-focus);box-shadow:0 0 0 3px var(--vela-focus-soft);";function ie(r,e,t=document){if(typeof document>"u")return;let n=t instanceof Document?t.head:t;if(t.getElementById?.(r)??n.querySelector(`#${CSS.escape(r)}`))return;let i=document.createElement("style");i.id=r,i.textContent=e,n.appendChild(i);}function ke(r,e=document){let t=e.createElement("span");t.className="vela-icon",t.setAttribute("aria-hidden","true");let n=ts(r);return n&&(t.innerHTML=n),t}var Vt=(r,e=[])=>({parts:(...t)=>{if(NC(e))return Vt(r,t);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...t)=>Vt(r,[...e,...t]),omit:(...t)=>Vt(r,e.filter(n=>!t.includes(n))),rename:t=>Vt(t,e),keys:()=>e,build:()=>[...new Set(e)].reduce((t,n)=>Object.assign(t,{[n]:{selector:[`&[data-scope="${Rr(r)}"][data-part="${Rr(n)}"]`,`& [data-scope="${Rr(r)}"][data-part="${Rr(n)}"]`].join(", "),attrs:{"data-scope":Rr(r),"data-part":Rr(n)}}}),{})}),Rr=r=>r.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),NC=r=>r.length===0;var VC=Vt("menu").parts("arrow","arrowTip","content","contextTrigger","indicator","item","itemGroup","itemGroupLabel","itemIndicator","itemText","positioner","separator","trigger","triggerItem"),Ce=VC.build();var Vm=["top","right","bottom","left"];var wt=Math.min,nt=Math.max,qi=Math.round,Zi=Math.floor,xt=r=>({x:r,y:r}),_C={left:"right",right:"left",bottom:"top",top:"bottom"};function cd(r,e,t){return nt(r,wt(e,t))}function St(r,e){return typeof r=="function"?r(e):r}function _t(r){return r.split("-")[0]}function zn(r){return r.split("-")[1]}function _a(r){return r==="x"?"y":"x"}function Ba(r){return r==="y"?"height":"width"}function rt(r){let e=r[0];return e==="t"||e==="b"?"y":"x"}function Ha(r){return _a(rt(r))}function _m(r,e,t){t===void 0&&(t=false);let n=zn(r),i=Ha(r),o=Ba(i),s=i==="x"?n===(t?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=ji(s)),[s,ji(s)]}function Bm(r){let e=ji(r);return [Va(r),e,Va(e)]}function Va(r){return r.includes("start")?r.replace("start","end"):r.replace("end","start")}var Fm=["left","right"],Nm=["right","left"],BC=["top","bottom"],HC=["bottom","top"];function zC(r,e,t){switch(r){case "top":case "bottom":return t?e?Nm:Fm:e?Fm:Nm;case "left":case "right":return e?BC:HC;default:return []}}function Hm(r,e,t,n){let i=zn(r),o=zC(_t(r),t==="start",n);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(Va)))),o}function ji(r){let e=_t(r);return _C[e]+r.slice(e.length)}function $C(r){var e,t,n,i;return {top:(e=r.top)!=null?e:0,right:(t=r.right)!=null?t:0,bottom:(n=r.bottom)!=null?n:0,left:(i=r.left)!=null?i:0}}function dd(r){return typeof r!="number"?$C(r):{top:r,right:r,bottom:r,left:r}}function $n(r){let{x:e,y:t,width:n,height:i}=r;return {width:n,height:i,top:t,left:e,right:e+n,bottom:t+i,x:e,y:t}}function zm(r,e,t){let{reference:n,floating:i}=r,o=rt(e),s=Ha(e),a=Ba(s),l=_t(e),c=o==="y",d=n.x+n.width/2-i.width/2,u=n.y+n.height/2-i.height/2,h=n[a]/2-i[a]/2,p;switch(l){case "top":p={x:d,y:n.y-i.height};break;case "bottom":p={x:d,y:n.y+n.height};break;case "right":p={x:n.x+n.width,y:u};break;case "left":p={x:n.x-i.width,y:u};break;default:p={x:n.x,y:n.y};}let m=zn(e);return m&&(p[s]+=h*(m==="end"?1:-1)*(t&&c?-1:1)),p}async function Gm(r,e){var t;e===void 0&&(e={});let{x:n,y:i,platform:o,rects:s,elements:a,strategy:l}=r,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:h=false,padding:p=0}=St(e,r),m=dd(p),g=a[h?u==="floating"?"reference":"floating":u],b=$n(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(g)))==null||t?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),y=u==="floating"?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),w=await(o.isElement==null?void 0:o.isElement(v))&&await(o.getScale==null?void 0:o.getScale(v))||{x:1,y:1},E=$n(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:v,strategy:l}):y);return {top:(b.top-E.top+m.top)/w.y,bottom:(E.bottom-b.bottom+m.bottom)/w.y,left:(b.left-E.left+m.left)/w.x,right:(E.right-b.right+m.right)/w.x}}var WC=50,Um=async(r,e,t)=>{let{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:s}=t,a=s.detectOverflow?s:{...s,detectOverflow:Gm},l=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:r,floating:e,strategy:i}),{x:d,y:u}=zm(c,n,l),h=n,p=0,m={};for(let f=0;f<o.length;f++){let g=o[f];if(!g)continue;let{name:b,fn:y}=g,{x:v,y:w,data:E,reset:x}=await y({x:d,y:u,initialPlacement:n,placement:h,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:r,floating:e}});d=v??d,u=w??u,m[b]={...m[b],...E},x&&p<WC&&(p++,typeof x=="object"&&(x.placement&&(h=x.placement),x.rects&&(c=x.rects===true?await s.getElementRects({reference:r,floating:e,strategy:i}):x.rects),{x:d,y:u}=zm(c,h,l)),f=-1);}return {x:d,y:u,placement:h,strategy:i,middlewareData:m}},Ym=r=>({name:"arrow",options:r,async fn(e){let{x:t,y:n,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=e,{element:c,padding:d=0}=St(r,e)||{};if(c==null)return {};let u=dd(d),h={x:t,y:n},p=Ha(i),m=Ba(p),f=await s.getDimensions(c),g=p==="y",b=g?"top":"left",y=g?"bottom":"right",v=g?"clientHeight":"clientWidth",w=o.reference[m]+o.reference[p]-h[p]-o.floating[m],E=h[p]-o.reference[p],x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),S=x?x[v]:0;(!S||!await(s.isElement==null?void 0:s.isElement(x)))&&(S=a.floating[v]||o.floating[m]);let P=w/2-E/2,k=S/2-f[m]/2-1,T=wt(u[b],k),M=wt(u[y],k),L=S-f[m]-M,C=S/2-f[m]/2+P,I=cd(T,C,L),V=!l.arrow&&zn(i)!=null&&C!==I&&o.reference[m]/2-(C<T?T:M)-f[m]/2<0,Y=V?C<T?C-T:C-L:0;return {[p]:h[p]+Y,data:{[p]:I,centerOffset:C-I-Y,...V&&{alignmentOffset:Y}},reset:V}}});var Km=function(r){return r===void 0&&(r={}),{name:"flip",options:r,async fn(e){var t,n;let{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:d=true,crossAxis:u=true,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:f=true,...g}=St(r,e);if((t=o.arrow)!=null&&t.alignmentOffset)return {};let b=_t(i),y=rt(a),v=_t(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),E=h||(v||!f?[ji(a)]:Bm(a)),x=m!=="none";!h&&x&&E.push(...Hm(a,f,m,w));let S=[a,...E],P=await l.detectOverflow(e,g),k=[],T=((n=o.flip)==null?void 0:n.overflows)||[];if(d&&k.push(P[b]),u){let I=_m(i,s,w);k.push(P[I[0]],P[I[1]]);}if(T=[...T,{placement:i,overflows:k}],!k.every(I=>I<=0)){var M,L;let I=(((M=o.flip)==null?void 0:M.index)||0)+1,V=S[I];if(V&&(!(u==="alignment"?y!==rt(V):false)||T.every(z=>rt(z.placement)===y?z.overflows[0]>0:true)))return {data:{index:I,overflows:T},reset:{placement:V}};let Y=(L=T.filter(K=>K.overflows[0]<=0).sort((K,z)=>K.overflows[1]-z.overflows[1])[0])==null?void 0:L.placement;if(!Y)switch(p){case "bestFit":{var C;let K=(C=T.filter(z=>{if(x){let ze=rt(z.placement);return ze===y||ze==="y"}return true}).map(z=>[z.placement,z.overflows.filter(ze=>ze>0).reduce((ze,Sw)=>ze+Sw,0)]).sort((z,ze)=>z[1]-ze[1])[0])==null?void 0:C[0];K&&(Y=K);break}case "initialPlacement":Y=a;break}if(i!==Y)return {reset:{placement:Y}}}return {}}}};function $m(r,e){return {top:r.top-e.height,right:r.right-e.width,bottom:r.bottom-e.height,left:r.left-e.width}}function Wm(r){return Vm.some(e=>r[e]>=0)}var Xm=function(r){return r===void 0&&(r={}),{name:"hide",options:r,async fn(e){let{rects:t,platform:n}=e,{strategy:i="referenceHidden",...o}=St(r,e);switch(i){case "referenceHidden":{let s=await n.detectOverflow(e,{...o,elementContext:"reference"}),a=$m(s,t.reference);return {data:{referenceHiddenOffsets:a,referenceHidden:Wm(a)}}}case "escaped":{let s=await n.detectOverflow(e,{...o,altBoundary:true}),a=$m(s,t.floating);return {data:{escapedOffsets:a,escaped:Wm(a)}}}default:return {}}}}};var jm=new Set(["left","top"]);async function GC(r,e){let{placement:t,platform:n,elements:i}=r,o=await(n.isRTL==null?void 0:n.isRTL(i.floating)),s=_t(t),a=zn(t),l=rt(t)==="y",c=jm.has(s)?-1:1,d=o&&l?-1:1,u=St(e,r),{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*d,y:h*c}:{x:h*c,y:p*d}}var qm=function(r){return r===void 0&&(r=0),{name:"offset",options:r,async fn(e){var t,n;let{x:i,y:o,placement:s,middlewareData:a}=e,l=await GC(e,r);return s===((t=a.offset)==null?void 0:t.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},Zm=function(r){return r===void 0&&(r={}),{name:"shift",options:r,async fn(e){let{x:t,y:n,placement:i,platform:o}=e,{mainAxis:s=true,crossAxis:a=false,limiter:l={fn:y=>{let{x:v,y:w}=y;return {x:v,y:w}}},...c}=St(r,e),d={x:t,y:n},u=await o.detectOverflow(e,c),h=rt(i),p=_a(h),m=d[p],f=d[h],g=(y,v)=>cd(v+u[y==="y"?"top":"left"],v,v-u[y==="y"?"bottom":"right"]);s&&(m=g(p,m)),a&&(f=g(h,f));let b=l.fn({...e,[p]:m,[h]:f});return {...b,data:{x:b.x-t,y:b.y-n,enabled:{[p]:s,[h]:a}}}}}},Jm=function(r){return r===void 0&&(r={}),{options:r,fn(e){var t,n;let{x:i,y:o,placement:s,rects:a,middlewareData:l}=e,{offset:c=0,mainAxis:d=true,crossAxis:u=true}=St(r,e),h={x:i,y:o},p=rt(s),m=_a(p),f=h[m],g=h[p],b=St(c,e),y=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:(t=b.mainAxis)!=null?t:0,crossAxis:(n=b.crossAxis)!=null?n:0};if(d){let E=m==="y"?"height":"width",x=a.reference[m]-a.floating[E]+y.mainAxis,S=a.reference[m]+a.reference[E]-y.mainAxis;f<x?f=x:f>S&&(f=S);}if(u){var v,w;let E=m==="y"?"width":"height",x=jm.has(_t(s)),S=a.reference[p]-a.floating[E]+(x&&((v=l.offset)==null?void 0:v[p])||0)+(x?0:y.crossAxis),P=a.reference[p]+a.reference[E]+(x?0:((w=l.offset)==null?void 0:w[p])||0)-(x?y.crossAxis:0);g<S?g=S:g>P&&(g=P);}return {[m]:f,[p]:g}}}},Qm=function(r){return r===void 0&&(r={}),{name:"size",options:r,async fn(e){let{placement:t,rects:n,platform:i,elements:o}=e,{apply:s=()=>{},...a}=St(r,e),l=await i.detectOverflow(e,a),c=_t(t),d=zn(t),u=rt(t)==="y",{width:h,height:p}=n.floating,m,f;c==="top"||c==="bottom"?(m=c,f=d===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(f=c,m=d==="end"?"top":"bottom");let g=p-l.top-l.bottom,b=h-l.left-l.right,y=wt(p-l[m],g),v=wt(h-l[f],b),w=e.middlewareData.shift,E=!w,x=y,S=v;w!=null&&w.enabled.x&&(S=b),w!=null&&w.enabled.y&&(x=g),E&&!d&&(u?S=h-2*nt(l.left,l.right):x=p-2*nt(l.top,l.bottom)),await s({...e,availableWidth:S,availableHeight:x});let P=await i.getDimensions(o.floating);return h!==P.width||p!==P.height?{reset:{rects:true}}:{}}}};function za(){return typeof window<"u"}function Gn(r){return tf(r)?(r.nodeName||"").toLowerCase():"#document"}function Ie(r){var e;return (r==null||(e=r.ownerDocument)==null?void 0:e.defaultView)||window}function Ct(r){var e;return (e=(tf(r)?r.ownerDocument:r.document)||window.document)==null?void 0:e.documentElement}function tf(r){return za()?r instanceof Node||r instanceof Ie(r).Node:false}function it(r){return za()?r instanceof Element||r instanceof Ie(r).Element:false}function Bt(r){return za()?r instanceof HTMLElement||r instanceof Ie(r).HTMLElement:false}function ef(r){return !za()||typeof ShadowRoot>"u"?false:r instanceof ShadowRoot||r instanceof Ie(r).ShadowRoot}function Ji(r){let{overflow:e,overflowX:t,overflowY:n,display:i}=ot(r);return /auto|scroll|overlay|hidden|clip/.test(e+n+t)&&i!=="inline"&&i!=="contents"}function nf(r){return /^(table|td|th)$/.test(Gn(r))}function Qi(r){try{if(r.matches(":popover-open"))return !0}catch{}try{return r.matches(":modal")}catch{return false}}var UC=/transform|translate|scale|rotate|perspective|filter/,YC=/paint|layout|strict|content/,Wn=r=>!!r&&r!=="none",ud;function $a(r){let e=it(r)?ot(r):r;return Wn(e.transform)||Wn(e.translate)||Wn(e.scale)||Wn(e.rotate)||Wn(e.perspective)||!Wa()&&(Wn(e.backdropFilter)||Wn(e.filter))||UC.test(e.willChange||"")||YC.test(e.contain||"")}function rf(r){let e=sn(r);for(;Bt(e)&&!Or(e);){if($a(e))return e;if(Qi(e))return null;e=sn(e);}return null}function Wa(){return ud==null&&(ud=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ud}function Or(r){return /^(html|body|#document)$/.test(Gn(r))}function ot(r){return Ie(r).getComputedStyle(r)}function eo(r){return it(r)?{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}:{scrollLeft:r.scrollX,scrollTop:r.scrollY}}function sn(r){if(Gn(r)==="html")return r;let e=r.assignedSlot||r.parentNode||ef(r)&&r.host||Ct(r);return ef(e)?e.host:e}function of(r){let e=sn(r);return Or(e)?(r.ownerDocument||r).body:Bt(e)&&Ji(e)?e:of(e)}function Dr(r,e,t){var n;e===void 0&&(e=[]),t===void 0&&(t=true);let i=of(r),o=i===((n=r.ownerDocument)==null?void 0:n.body),s=Ie(i);if(o){let a=Ga(s);return e.concat(s,s.visualViewport||[],Ji(i)?i:[],a&&t?Dr(a):[])}else return e.concat(i,Dr(i,[],t))}function Ga(r){return r.parent&&Object.getPrototypeOf(r.parent)?r.frameElement:null}function lf(r){let e=ot(r),t=parseFloat(e.width)||0,n=parseFloat(e.height)||0,i=Bt(r),o=i?r.offsetWidth:t,s=i?r.offsetHeight:n,a=qi(t)!==o||qi(n)!==s;return a&&(t=o,n=s),{width:t,height:n,$:a}}function pd(r){return it(r)?r:r.contextElement}function Fr(r){let e=pd(r);if(!Bt(e))return xt(1);let t=e.getBoundingClientRect(),{width:n,height:i,$:o}=lf(e),s=(o?qi(t.width):t.width)/n,a=(o?qi(t.height):t.height)/i;return (!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var KC=xt(0);function cf(r){let e=Ie(r);return !Wa()||!e.visualViewport?KC:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function XC(r,e,t){return e===void 0&&(e=false),!!t&&e&&t===Ie(r)}function Un(r,e,t,n){e===void 0&&(e=false),t===void 0&&(t=false);let i=r.getBoundingClientRect(),o=pd(r),s=xt(1);e&&(n?it(n)&&(s=Fr(n)):s=Fr(r));let a=XC(o,t,n)?cf(o):xt(0),l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,d=i.width/s.x,u=i.height/s.y;if(o&&n){let h=Ie(o),p=it(n)?Ie(n):n,m=h,f=Ga(m);for(;f&&p!==m;){let g=Fr(f),b=f.getBoundingClientRect(),y=ot(f),v=b.left+(f.clientLeft+parseFloat(y.paddingLeft))*g.x,w=b.top+(f.clientTop+parseFloat(y.paddingTop))*g.y;l*=g.x,c*=g.y,d*=g.x,u*=g.y,l+=v,c+=w,m=Ie(f),f=Ga(m);}}return $n({width:d,height:u,x:l,y:c})}function Ua(r,e){let t=eo(r).scrollLeft;return e?e.left+t:Un(Ct(r)).left+t}function df(r,e){let t=r.getBoundingClientRect(),n=t.left+e.scrollLeft-Ua(r,t),i=t.top+e.scrollTop;return {x:n,y:i}}function jC(r){let{elements:e,rect:t,offsetParent:n,strategy:i}=r,o=i==="fixed",s=Ct(n),a=e?Qi(e.floating):false;if(n===s||a&&o)return t;let l={scrollLeft:0,scrollTop:0},c=xt(1),d=xt(0),u=Bt(n);if((u||!o)&&((Gn(n)!=="body"||Ji(s))&&(l=eo(n)),u)){let p=Un(n);c=Fr(n),d.x=p.x+n.clientLeft,d.y=p.y+n.clientTop;}let h=s&&!u&&!o?df(s,l):xt(0);return {width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+d.x+h.x,y:t.y*c.y-l.scrollTop*c.y+d.y+h.y}}function qC(r){return r.getClientRects?Array.from(r.getClientRects()):[]}function ZC(r){let e=eo(r),t=r.ownerDocument.body,n=nt(r.scrollWidth,r.clientWidth,t.scrollWidth,t.clientWidth),i=nt(r.scrollHeight,r.clientHeight,t.scrollHeight,t.clientHeight),o=-e.scrollLeft+Ua(r),s=-e.scrollTop;return ot(t).direction==="rtl"&&(o+=nt(r.clientWidth,t.clientWidth)-n),{width:n,height:i,x:o,y:s}}var JC=25;function QC(r,e,t){t===void 0&&(t="viewport");let n=t==="layoutViewport",i=Ie(r),o=Ct(r),s=i.visualViewport,a=o.clientWidth,l=o.clientHeight,c=0,d=0;if(s){let h=!Wa()||e==="fixed";n?h||(c=-s.offsetLeft,d=-s.offsetTop):(a=s.width,l=s.height,h&&(c=s.offsetLeft,d=s.offsetTop));}if(Ua(o)<=0){let h=o.ownerDocument,p=h.body,m=getComputedStyle(p),f=h.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(o.clientWidth-p.clientWidth-f),b=getComputedStyle(o).scrollbarGutter==="stable both-edges"?g/2:g;b<=JC&&(a-=b);}return {width:a,height:l,x:c,y:d}}function e1(r,e){let t=Un(r,true,e==="fixed"),n=t.top+r.clientTop,i=t.left+r.clientLeft,o=Fr(r),s=r.clientWidth*o.x,a=r.clientHeight*o.y,l=i*o.x,c=n*o.y;return {width:s,height:a,x:l,y:c}}function sf(r,e,t){let n;if(e==="viewport"||e==="layoutViewport")n=QC(r,t,e);else if(e==="document")n=ZC(Ct(r));else if(it(e))n=e1(e,t);else {let i=cf(r);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height};}return $n(n)}function t1(r,e){let t=e.get(r);if(t)return t;let n=Dr(r,[],false).filter(a=>it(a)&&Gn(a)!=="body"),i=null,o=ot(r).position==="fixed",s=o?sn(r):r;for(;it(s)&&!Or(s);){let a=ot(s),l=$a(s),c=i?i.position:o?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?n=n.filter(u=>u!==s):i=a,s=sn(s);}return e.set(r,n),n}function n1(r){let{element:e,boundary:t,rootBoundary:n,strategy:i}=r,s=[...t==="clippingAncestors"?Qi(e)?[]:t1(e,this._c):[].concat(t),n],a=sf(e,s[0],i),l=a.top,c=a.right,d=a.bottom,u=a.left;for(let h=1;h<s.length;h++){let p=sf(e,s[h],i);l=nt(p.top,l),c=wt(p.right,c),d=wt(p.bottom,d),u=nt(p.left,u);}return {width:c-u,height:d-l,x:u,y:l}}function r1(r){let{width:e,height:t}=lf(r);return {width:e,height:t}}function i1(r,e,t){let n=Bt(e),i=Ct(e),o=t==="fixed",s=Un(r,true,o,e),a={scrollLeft:0,scrollTop:0},l=xt(0);if((n||!o)&&((Gn(e)!=="body"||Ji(i))&&(a=eo(e)),n)){let h=Un(e,true,o,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop;}!n&&i&&(l.x=Ua(i));let c=i&&!n&&!o?df(i,a):xt(0),d=s.left+a.scrollLeft-l.x-c.x,u=s.top+a.scrollTop-l.y-c.y;return {x:d,y:u,width:s.width,height:s.height}}function hd(r){return ot(r).position==="static"}function af(r,e){if(!Bt(r)||ot(r).position==="fixed")return null;if(e)return e(r);let t=r.offsetParent;return Ct(r)===t&&(t=t.ownerDocument.body),t}function uf(r,e){let t=Ie(r);if(Qi(r))return t;if(!Bt(r)){let i=sn(r);for(;i&&!Or(i);){if(it(i)&&!hd(i))return i;i=sn(i);}return t}let n=af(r,e);for(;n&&nf(n)&&hd(n);)n=af(n,e);return n&&Or(n)&&hd(n)&&!$a(n)?t:n||rf(r)||t}var o1=async function(r){let e=this.getOffsetParent||uf,t=this.getDimensions,n=await t(r.floating);return {reference:i1(r.reference,await e(r.floating),r.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function s1(r){return ot(r).direction==="rtl"}var a1={convertOffsetParentRelativeRectToViewportRelativeRect:jC,getDocumentElement:Ct,getClippingRect:n1,getOffsetParent:uf,getElementRects:o1,getClientRects:qC,getDimensions:r1,getScale:Fr,isElement:it,isRTL:s1};function hf(r,e){return r.x===e.x&&r.y===e.y&&r.width===e.width&&r.height===e.height}function l1(r,e,t){let n=null,i,o=Ct(r);function s(){var d;clearTimeout(i),(d=n)==null||d.disconnect(),n=null;}function a(d,u){d===void 0&&(d=false),u===void 0&&(u=1),s();let h=r.getBoundingClientRect(),{left:p,top:m,width:f,height:g}=h;if(d||e(),!f||!g)return;let b=Zi(m),y=Zi(o.clientWidth-(p+f)),v=Zi(o.clientHeight-(m+g)),w=Zi(p),x={rootMargin:-b+"px "+-y+"px "+-v+"px "+-w+"px",threshold:nt(0,wt(1,u))||1},S=true;function P(k){let T=k[0].intersectionRatio;if(!hf(h,r.getBoundingClientRect()))return a();if(T!==u){if(!S)return a();T?a(false,T):i=setTimeout(()=>{a(false,1e-7);},1e3);}S=false;}try{n=new IntersectionObserver(P,{...x,root:o.ownerDocument});}catch{n=new IntersectionObserver(P,x);}n.observe(r);}let l=Ie(r),c=()=>a(t);return l.addEventListener("resize",c),a(true),()=>{l.removeEventListener("resize",c),s();}}function pf(r,e,t,n){n===void 0&&(n={});let{ancestorScroll:i=true,ancestorResize:o=true,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=false}=n,c=pd(r),d=i||o?[...c?Dr(c):[],...e?Dr(e):[]]:[];d.forEach(b=>{i&&b.addEventListener("scroll",t),o&&b.addEventListener("resize",t);});let u=c&&a?l1(c,t,o):null,h=-1,p=null;s&&(p=new ResizeObserver(b=>{let[y]=b;y&&y.target===c&&p&&e&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var v;(v=p)==null||v.observe(e);})),t();}),c&&!l&&p.observe(c),e&&p.observe(e));let m,f=l?Un(r):null;l&&g();function g(){let b=Un(r);f&&!hf(f,b)&&t(),f=b,m=requestAnimationFrame(g);}return t(),()=>{var b;d.forEach(y=>{i&&y.removeEventListener("scroll",t),o&&y.removeEventListener("resize",t);}),u?.(),(b=p)==null||b.disconnect(),p=null,l&&cancelAnimationFrame(m);}}var mf=qm;var ff=Zm,gf=Km,bf=Qm,vf=Xm,yf=Ym;var wf=Jm,xf=(r,e,t)=>{let n=new Map,i=t??{},o={...a1,...i.platform,_c:n};return Um(r,e,{...i,platform:o})};function Sf(r=0,e=0,t=0,n=0){if(typeof DOMRect=="function")return new DOMRect(r,e,t,n);let i={x:r,y:e,width:t,height:n,top:e,right:r+t,bottom:e+n,left:r};return {...i,toJSON:()=>i}}function c1(r){if(!r)return Sf();let{x:e,y:t,width:n,height:i}=r;return Sf(e,t,n,i)}function Cf(r,e){return {contextElement:Q(r)?r:r?.contextElement,getBoundingClientRect:()=>{let t=r,n=e?.(t);return n||!t?c1(n):t.getBoundingClientRect()}}}var to=r=>({variable:r,reference:`var(${r})`}),Tt={arrowSize:to("--arrow-size"),arrowSizeHalf:to("--arrow-size-half"),arrowBg:to("--arrow-background"),transformOrigin:to("--transform-origin"),arrowOffset:to("--arrow-offset")},d1=r=>r==="top"||r==="bottom"?"y":"x";function Tf(r,e){return {name:"transformOrigin",fn(t){let{elements:n,middlewareData:i,placement:o,rects:s,y:a}=t,l=o.split("-")[0],c=d1(l),d=i.arrow?.x||0,u=i.arrow?.y||0,h=e?.clientWidth||0,p=e?.clientHeight||0,m=d+h/2,f=u+p/2,g=Math.abs(i.shift?.y||0),b=s.reference.height/2,y=p/2,v=r.offset?.mainAxis??r.gutter,w=typeof v=="number"?v+y:v??y,E=g>w,x={top:`${m}px calc(100% + ${w}px)`,bottom:`${m}px ${-w}px`,left:`calc(100% + ${w}px) ${f}px`,right:`${-w}px ${f}px`}[l],S=`${m}px ${s.reference.y+b-a}px`,P=!!r.overlap&&c==="y"&&E;return n.floating.style.setProperty(Tt.transformOrigin.variable,P?S:x),{data:{transformOrigin:P?S:x}}}}}var Ef={name:"rects",fn({rects:r}){return {data:r}}},Pf=r=>{if(r)return {name:"shiftArrow",fn({placement:e,middlewareData:t}){if(!t.arrow)return {};let{x:n,y:i}=t.arrow,o=e.split("-")[0];return Object.assign(r.style,{left:n!=null?`${n}px`:"",top:i!=null?`${i}px`:"",[o]:`calc(100% + ${Tt.arrowOffset.reference})`}),{}}}};function Lf(r){let[e,t]=r.split("-");return {side:e,align:t,hasAlign:t!=null}}function no(r){return r.split("-")[0]}var u1={strategy:"absolute",placement:"bottom",listeners:true,restoreStyles:false,gutter:8,flip:true,slide:true,overlap:false,sameWidth:false,fitViewport:false,overflowPadding:8,arrowPadding:4};function Mf(r,e){let t=r.devicePixelRatio||1;return Math.round(e*t)/t}function Nr(r,e){return r!=null&&Math.abs(r-e)<.5}function Ya(r){return typeof r=="function"?r():r==="clipping-ancestors"?"clippingAncestors":r}function h1(r,e,t){let n=r||e.createElement("div");return yf({element:n,padding:t.arrowPadding})}function p1(r,e){if(!Ip(e.offset??e.gutter))return mf(({placement:t})=>{let n=(r?.clientHeight||0)/2,i=e.offset?.mainAxis??e.gutter,o=typeof i=="number"?i+n:i??n,{hasAlign:s}=Lf(t),a=s?void 0:e.shift,l=e.offset?.crossAxis??a;return nn({crossAxis:l,mainAxis:o,alignmentAxis:e.shift})})}function m1(r){if(r.flip)return gf(()=>{let e=Ya(r.boundary);return {...e?{boundary:e}:void 0,padding:r.overflowPadding,fallbackPlacements:r.flip===true?void 0:r.flip}})}function f1(r){if(!(!r.slide&&!r.overlap))return ff(()=>{let e=Ya(r.boundary);return {...e?{boundary:e}:void 0,mainAxis:r.slide,crossAxis:r.overlap,padding:r.overflowPadding,limiter:wf()}})}function g1(r){if(r.sizeMiddleware===false&&!r.sameWidth&&!r.fitViewport)return;let e,t,n,i;return bf(()=>{let o=Ya(r.boundary);return {padding:r.overflowPadding,...o?{boundary:o}:void 0,apply({elements:s,rects:a,availableHeight:l,availableWidth:c}){let d=s.floating,u=Math.round(a.reference.width),h=Math.round(a.reference.height);c=Math.floor(c),l=Math.floor(l),Nr(e,u)||(d.style.setProperty("--reference-width",`${u}px`),e=u),Nr(t,h)||(d.style.setProperty("--reference-height",`${h}px`),t=h),Nr(n,c)||(d.style.setProperty("--available-width",`${c}px`),n=c),Nr(i,l)||(d.style.setProperty("--available-height",`${l}px`),i=l);}}})}function b1(r){if(r.hideWhenDetached)return vf(()=>({strategy:"referenceHidden",boundary:Ya(r.boundary)??"clippingAncestors"}))}function v1(r){return r?r===true?{ancestorResize:true,ancestorScroll:true,elementResize:true,layoutShift:true}:r:{}}var y1=["transform","visibility","pointer-events","--x","--y","--z-index","--reference-width","--reference-height","--available-width","--available-height","--transform-origin"],w1=["top","right","bottom","left"];function kf(r,e){if(!r)return _c;let t=new Map(e.map(n=>[n,r.style.getPropertyValue(n)]));return ()=>{t.forEach((n,i)=>{n?r.style.setProperty(i,n):r.style.removeProperty(i);}),r.style.length===0&&r.removeAttribute("style");}}function If(r){return r==null?null:Q(r)?r:typeof r=="object"&&r&&"contextElement"in r&&r.contextElement?r.contextElement:r}function x1(r,e,t={}){let n=()=>(typeof e=="function"?e():e)??null,i=()=>{let T=typeof r=="function"?r():r;return t.getAnchorElement?.()??T},o=()=>{let T=i();return !T&&!t.getAnchorRect?null:Cf(T,t.getAnchorRect)},s=Object.assign({},u1,t),a=[],l=null,c,d;function u(T){c?.(),d?.(),l=T,c=s.restoreStyles?kf(T,y1):void 0;let M=T.querySelector("[data-part=arrow]");d=s.restoreStyles?kf(M,w1):void 0,a=[p1(M,s),m1(s),f1(s),h1(M,T.ownerDocument,s),Pf(M),Tf({gutter:s.gutter,offset:s.offset,overlap:s.overlap},M),g1(s),b1(s),Ef];}let{placement:h,strategy:p,onComplete:m,onPositioned:f}=s,g,b,y=false,v,w,E=_c,x=v1(s.listeners);function S(){if(!s.listeners)return;let T=i(),M=o(),L=n();if(!M||!L)return;(If(T)!==If(v)||L!==w)&&(E(),v=T,w=L,E=pf(M,L,k,x));}async function P(){S();let T=n();if(!T)return;T!==l&&(u(T),y=false);let M=o();if(!M)return;let L=await xf(M,T,{placement:h,middleware:a,strategy:p});m?.(L);let C=ae(T),I=Mf(C,L.x),V=Mf(C,L.y);if(Nr(g,I)||(T.style.setProperty("--x",`${I}px`),g=I),Nr(b,V)||(T.style.setProperty("--y",`${V}px`),b=V),s.hideWhenDetached&&(L.middlewareData.hide?.referenceHidden?(T.style.setProperty("visibility","hidden"),T.style.setProperty("pointer-events","none")):(T.style.removeProperty("visibility"),T.style.removeProperty("pointer-events"))),!y){let Y=T.firstElementChild;Y&&(T.style.setProperty("--z-index",Tr(Y).zIndex),y=true);}}async function k(){t.updatePosition?(await t.updatePosition({updatePosition:P,floatingElement:n()}),f?.({placed:true})):await P();}return k(),()=>{E(),d?.(),c?.(),f?.({placed:false});}}function Ka(r,e,t={}){let{defer:n,...i}=t,o=n?he:a=>a(),s=[];return s.push(o(()=>{s.push(x1(r,e,i));})),()=>{s.forEach(a=>a?.());}}var S1={bottom:"rotate(45deg)",left:"rotate(135deg)",top:"rotate(225deg)",right:"rotate(315deg)"};function md(r={}){let{placement:e,sameWidth:t,fitViewport:n,strategy:i="absolute"}=r;return {arrow:{position:"absolute",width:Tt.arrowSize.reference,height:Tt.arrowSize.reference,[Tt.arrowSizeHalf.variable]:`calc(${Tt.arrowSize.reference} / 2)`,[Tt.arrowOffset.variable]:`calc(${Tt.arrowSizeHalf.reference} * -1)`},arrowTip:{transform:e?S1[e.split("-")[0]]:void 0,background:Tt.arrowBg.reference,top:"0",left:"0",width:"100%",height:"100%",position:"absolute",zIndex:"inherit"},floating:{position:i,isolation:"isolate",minWidth:t?void 0:"max-content",width:t?"var(--reference-width)":void 0,maxWidth:n?"var(--available-width)":void 0,maxHeight:n?"var(--available-height)":void 0,pointerEvents:e?void 0:"none",top:"0px",left:"0px",transform:e?"translate3d(var(--x), var(--y), 0)":"translate3d(0, -100vh, 0)",zIndex:"var(--z-index)"}}}var Et=(r,e)=>{let t=r.ids?.trigger;return t!=null?Ne(t)?t(e):t:e?`menu:${r.id}:trigger:${e}`:`menu:${r.id}:trigger`},Xa=(r,e)=>{let t=r.ids?.contextTrigger;return t!=null?Ne(t)?t(e):t:e?`menu:${r.id}:ctx-trigger:${e}`:`menu:${r.id}:ctx-trigger`},an=r=>r.ids?.content??`menu:${r.id}:content`,Af=r=>r.ids?.arrow??`menu:${r.id}:arrow`,fd=r=>r.ids?.positioner??`menu:${r.id}:popper`,Rf=(r,e)=>r.ids?.group?.(e)??`menu:${r.id}:group:${e}`,Yn=(r,e)=>`${r.id}/${e}`,ln=r=>r?.dataset.value??null,gd=(r,e)=>r.ids?.groupLabel?.(e)??`menu:${r.id}:group-label:${e}`,st=r=>r.getById(an(r)),bd=r=>r.getById(fd(r)),vd=r=>r.getById(Et(r)),Df=(r,e)=>e?r.getById(Yn(r,e)):null;var Of=r=>r.getById(Xa(r)),yd=r=>kr(r.getRootNode(),`[data-scope="menu"][data-part="trigger"][data-ownedby="${r.id}"]`),wd=r=>kr(r.getRootNode(),`[data-scope="menu"][data-part="context-trigger"][data-ownedby="${r.id}"]`),ro=(r,e)=>e==null?vd(r)??yd(r)[0]:r.getById(Et(r,e)),io=r=>{let t=`[role^="menuitem"][data-ownedby=${CSS.escape(an(r))}]:not([data-disabled])`;return kr(st(r),t)},Ff=r=>Tp(io(r)),Nf=r=>Ep(io(r)),xd=(r,e)=>e?r.id===e||r.dataset.value===e:false,Vf=(r,e)=>{let t=io(r),n=t.findIndex(i=>xd(i,e.value));return Lp(t,n,{loop:e.loop??e.loopFocus})},_f=(r,e)=>{let t=io(r),n=t.findIndex(i=>xd(i,e.value));return Mp(t,n,{loop:e.loop??e.loopFocus})},Bf=(r,e)=>{let t=io(r),n=t.find(i=>xd(i,e.value));return ka(t,{state:e.typeaheadState,key:e.key,activeId:n?.id??null})},oo=r=>Q(r)&&(r.dataset.disabled===""||r.hasAttribute("disabled")),Sd=r=>!!r?.getAttribute("role")?.startsWith("menuitem")&&!!r?.hasAttribute("data-controls");var ja="menu:select";function Hf(r,e){if(!r)return;let t=ae(r),n=new t.CustomEvent(ja,{detail:{value:e}});r.dispatchEvent(n);}function C1(r){let e=an(r);return st(r)??r.getDoc().getElementById(e)}function Cd(r,e){if(!Q(r))return false;for(let t in e){let n=e[t],i=C1(n.scope);if(i&&Ve(i,r))return true;let o=n.refs.get("children");if(Object.keys(o).length>0&&Cd(r,o))return true}return false}var so=(r,e)=>({x:r,y:e});function zf(r){let{x:e,y:t,width:n,height:i}=r,o=e+n/2,s=t+i/2;return {x:e,y:t,width:n,height:i,minX:e,minY:t,maxX:e+n,maxY:t+i,midX:o,midY:s,center:so(o,s)}}function $f(r){let e=so(r.minX,r.minY),t=so(r.maxX,r.minY),n=so(r.maxX,r.maxY),i=so(r.minX,r.maxY);return {top:e,right:t,bottom:n,left:i}}function Wf(r,e){let t=zf(r),{top:n,right:i,left:o,bottom:s}=$f(t),[a]=e.split("-");return {top:[o,n,i,s],right:[n,i,s,o],bottom:[n,o,s,i],left:[i,n,o,s]}[a]}function qa(r,e){let{x:t,y:n}=e,i=false;for(let o=0,s=r.length-1;o<r.length;s=o++){let a=r[o].x,l=r[o].y,c=r[s].x,d=r[s].y;l>n!=d>n&&t<(c-a)*(n-l)/(d-l)+a&&(i=!i);}return i}function Ed(r){let e=r.parent;for(;e&&e.context.get("isSubmenu");)e=e.refs.get("parent");e?.send({type:"CLOSE"});}function Gf(r,e){return r?qa(r,e):false}function Uf(r,e,t){let n=Object.keys(r).length>0;if(!e)return null;if(!n)return Yn(t,e);for(let i in r){let o=r[i],s=Et(o.scope);if(s===e)return s}return Yn(t,e)}function cn(r,e){r&&(r.refs.set("pointerRoutingLocked",e),r.context.set("pointerRoutingMode",e?"locked":"interactive"));}function Yf(r){let e=r.context.get("highlightedValue");if(!e)return false;let t=r.refs.get("children");for(let n in t){let i=t[n];if(i.state.hasTag("open")&&Et(i.scope)===e)return true}return false}function Kf(r,e){r&&(r.refs.get("pointerRoutingLocked")||e&&Yf(r)||cn(r,false));}function Xf(r){r&&(Yf(r)||cn(r,false));}function Pd(r,e){let{context:t,send:n,state:i,computed:o,prop:s,scope:a}=r,l=i.hasTag("open"),c=t.get("isSubmenu"),d=o("isTypingAhead"),u=s("composite"),h=t.get("currentPlacement"),p=h?no(h):void 0,m=t.get("anchorPoint"),f=t.get("highlightedValue"),g=t.get("triggerValue"),b=md({...s("positioning"),placement:h});function y(x){return {id:Yn(a,x.value),disabled:!!x.disabled,highlighted:f===x.value}}function v(x){let S=x.valueText??x.value;return {...x,id:x.value,valueText:S}}function w(x){return {...y(v(x)),checked:!!x.checked}}function E(x){let{closeOnSelect:S,valueText:P,value:k}=x,T=y(x),M=Yn(a,k);return e.element({...Ce.item.attrs,id:M,role:"menuitem","aria-disabled":Gc(T.disabled),"data-disabled":Ge(T.disabled),"data-ownedby":an(a),"data-highlighted":Ge(T.highlighted),"data-value":k,"data-valuetext":P,onDragStart(L){L.currentTarget.matches("a[href]")&&L.preventDefault();},onPointerMove(L){if(T.disabled||L.pointerType!=="mouse")return;let C=L.currentTarget;if(T.highlighted)return;let I=Pr(L);n({type:"ITEM_POINTERMOVE",id:M,target:C,closeOnSelect:S,point:I});},onPointerLeave(L){if(T.disabled||L.pointerType!=="mouse"||!r.event.previous()?.type.includes("POINTER"))return;let I=L.currentTarget;n({type:"ITEM_POINTERLEAVE",id:M,target:I,closeOnSelect:S});},onPointerDown(L){if(T.disabled)return;let C=L.currentTarget;n({type:"ITEM_POINTERDOWN",target:C,id:M,closeOnSelect:S});},onClick(L){if(Qc(L)||Jc(L)||T.disabled)return;let C=L.currentTarget;n({type:"ITEM_CLICK",target:C,id:M,closeOnSelect:S});}})}return {highlightedValue:f,open:l,setOpen(x){i.hasTag("open")!==x&&n({type:x?"OPEN":"CLOSE"});},triggerValue:g,setTriggerValue(x){n({type:"TRIGGER_VALUE.SET",value:x});},setHighlightedValue(x){n({type:"HIGHLIGHTED.SET",value:x});},setParent(x){n({type:"PARENT.SET",value:x,id:x.prop("id")});},setChild(x){n({type:"CHILD.SET",value:x,id:x.prop("id")});},reposition(x={}){n({type:"POSITIONING.SET",options:x});},addItemListener(x){let S=a.getById(x.id);if(!S)return;let P=()=>x.onSelect?.();return S.addEventListener(ja,P),()=>S.removeEventListener(ja,P)},getContextTriggerProps(x={}){let{value:S}=x,P=S==null?false:g===S,k=Xa(a,S);return e.element({...Ce.contextTrigger.attrs,dir:s("dir"),id:k,"data-ownedby":a.id,"data-value":S,"data-current":Ge(P),"data-state":l?"open":"closed",onPointerDown(T){if(T.pointerType==="mouse")return;let M=Pr(T);n({type:"CONTEXT_MENU_START",point:M,value:S});},onPointerCancel(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerMove(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerUp(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onContextMenu(T){let M=Pr(T),L=l&&S!=null&&!P;n({type:L?"TRIGGER_VALUE.SET":"CONTEXT_MENU",point:M,value:S}),T.preventDefault();},style:{WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"}})},getTriggerItemProps(x){let S=x.getTriggerProps();return Op(E({value:S.id}),S)},getTriggerProps(x={}){let{value:S}=x,P=S==null?false:g===S,k=Et(a,S);return e.button({...c?Ce.triggerItem.attrs:Ce.trigger.attrs,"data-placement":h,"data-side":p,type:"button",dir:s("dir"),id:k,...S!=null&&{"data-ownedby":a.id,"data-value":S,"data-current":Ge(P)},"data-uid":s("id"),"aria-haspopup":u?"menu":"dialog","aria-controls":an(a),"data-controls":an(a),"aria-expanded":S==null?l:l&&P,"data-state":l?"open":"closed",onPointerMove(T){if(T.pointerType!=="mouse"||oo(T.currentTarget)||!c)return;let L=Pr(T);n({type:"TRIGGER_POINTERMOVE",target:T.currentTarget,point:L});},onPointerLeave(T){if(oo(T.currentTarget)||T.pointerType!=="mouse"||!c)return;cn(r.refs.get("parent"),true);let M=Pr(T);n({type:"TRIGGER_POINTERLEAVE",target:T.currentTarget,point:M});},onPointerDown(T){oo(T.currentTarget)||Ta(T)||T.preventDefault();},onClick(T){if(T.defaultPrevented||oo(T.currentTarget))return;let M=l&&S!=null&&!P;n({type:M?"TRIGGER_VALUE.SET":"TRIGGER_CLICK",target:T.currentTarget,value:S});},onBlur(){n({type:"TRIGGER_BLUR"});},onFocus(){n({type:"TRIGGER_FOCUS"});},onKeyDown(T){if(T.defaultPrevented)return;let M={ArrowDown(){n({type:"ARROW_DOWN",value:S});},ArrowUp(){n({type:"ARROW_UP",value:S});},Enter(){n({type:"ARROW_DOWN",src:"enter",value:S});},Space(){n({type:"ARROW_DOWN",src:"space",value:S});}},L=ed(T,{orientation:"vertical",dir:s("dir")}),C=M[L];C&&(T.preventDefault(),C(T));}})},getIndicatorProps(){return e.element({...Ce.indicator.attrs,dir:s("dir"),"data-state":l?"open":"closed"})},getPositionerProps(){return e.element({...Ce.positioner.attrs,dir:s("dir"),id:fd(a),style:b.floating})},getArrowProps(){return e.element({id:Af(a),...Ce.arrow.attrs,dir:s("dir"),style:b.arrow})},getArrowTipProps(){return e.element({...Ce.arrowTip.attrs,dir:s("dir"),style:b.arrowTip})},getContentProps(){return e.element({...Ce.content.attrs,id:an(a),"aria-label":s("aria-label"),hidden:!l,"data-state":l?"open":"closed",role:u?"menu":"dialog",tabIndex:0,dir:s("dir"),"aria-activedescendant":o("highlightedId")||void 0,"aria-labelledby":m?Xa(a,g??void 0):Et(a,g??void 0),"data-placement":h,"data-side":p,onPointerEnter(x){x.pointerType==="mouse"&&n({type:"MENU_POINTERENTER"});},onKeyDown(x){if(x.defaultPrevented||!Ve(x.currentTarget,ge(x)))return;let S=ge(x);if(!(S?.closest("[role=menu]")===x.currentTarget||S===x.currentTarget))return;if(x.key==="Tab"&&!mm(x)){x.preventDefault();return}let k={ArrowDown(){n({type:"ARROW_DOWN"});},ArrowUp(){n({type:"ARROW_UP"});},ArrowLeft(){n({type:"ARROW_LEFT"});},ArrowRight(){n({type:"ARROW_RIGHT"});},Enter(){n({type:"ENTER"});},Space(L){d?n({type:"TYPEAHEAD",key:L.key}):k.Enter?.(L);},Home(){n({type:"HOME"});},End(){n({type:"END"});}},T=ed(x,{dir:s("dir")}),M=k[T];if(M){M(x),x.stopPropagation(),x.preventDefault();return}s("typeahead")&&am(x)&&(cm(x)||Cr(S)||(n({type:"TYPEAHEAD",key:x.key}),x.preventDefault()));}})},getSeparatorProps(){return e.element({...Ce.separator.attrs,role:"separator",dir:s("dir"),"aria-orientation":"horizontal"})},getItemState:y,getItemProps:E,getOptionItemState:w,getOptionItemProps(x){let{type:S,disabled:P,closeOnSelect:k}=x,T=v(x),M=w(x);return {...E(T),...e.element({"data-type":S,...Ce.item.attrs,dir:s("dir"),"data-value":T.value,role:`menuitem${S}`,"aria-checked":!!M.checked,"data-state":M.checked?"checked":"unchecked",onClick(L){if(P||Qc(L)||Jc(L))return;let C=L.currentTarget;n({type:"ITEM_CLICK",target:C,option:T,closeOnSelect:k});}})}},getItemIndicatorProps(x){let S=w(Vc(x)),P=S.checked?"checked":"unchecked";return e.element({...Ce.itemIndicator.attrs,dir:s("dir"),"data-disabled":Ge(S.disabled),"data-highlighted":Ge(S.highlighted),"data-state":Vi(x,"checked")?P:void 0,hidden:Vi(x,"checked")?!S.checked:void 0})},getItemTextProps(x){let S=w(Vc(x)),P=S.checked?"checked":"unchecked";return e.element({...Ce.itemText.attrs,dir:s("dir"),"data-disabled":Ge(S.disabled),"data-highlighted":Ge(S.highlighted),"data-state":Vi(x,"checked")?P:void 0})},getItemGroupLabelProps(x){return e.element({...Ce.itemGroupLabel.attrs,id:gd(a,x.htmlFor),dir:s("dir")})},getItemGroupProps(x){return e.element({id:Rf(a,x.id),...Ce.itemGroup.attrs,dir:s("dir"),"aria-labelledby":gd(a,x.id),role:"group"})}}}function jf(r){let e={each(t){for(let n=0;n<r.frames?.length;n+=1){let i=r.frames[n];i&&t(i);}},addEventListener(t,n,i){return e.each(o=>{try{o.document.addEventListener(t,n,i);}catch{}}),()=>{try{e.removeEventListener(t,n,i);}catch{}}},removeEventListener(t,n,i){e.each(o=>{try{o.document.removeEventListener(t,n,i);}catch{}});}};return e}function qf(r){let e=r.frameElement!=null?r.parent:null;return {addEventListener:(t,n,i)=>{try{e?.addEventListener(t,n,i);}catch{}return ()=>{try{e?.removeEventListener(t,n,i);}catch{}}},removeEventListener:(t,n,i)=>{try{e?.removeEventListener(t,n,i);}catch{}}}}var Zf="pointerdown.outside",Jf="focus.outside";function T1(r){for(let e of r)if(Q(e)&&Ue(e))return true;return false}var tg=r=>"clientY"in r;function E1(r,e){if(!tg(e)||!r)return false;let t=r.getBoundingClientRect();return t.width===0||t.height===0?false:t.top<=e.clientY&&e.clientY<=t.top+t.height&&t.left<=e.clientX&&e.clientX<=t.left+t.width}function P1(r,e){return r.y<=e.y&&e.y<=r.y+r.height&&r.x<=e.x&&e.x<=r.x+r.width}function Qf(r,e){if(!e||!tg(r))return false;let t=e.scrollHeight>e.clientHeight,n=t&&r.clientX>e.offsetLeft+e.clientWidth,i=e.scrollWidth>e.clientWidth,o=i&&r.clientY>e.offsetTop+e.clientHeight,s={x:e.offsetLeft,y:e.offsetTop,width:e.clientWidth+(t?16:0),height:e.clientHeight+(i?16:0)},a={x:r.clientX,y:r.clientY};return P1(s,a)?n||o:false}function L1(r,e){let{exclude:t,onFocusOutside:n,onPointerDownOutside:i,onInteractOutside:o,defer:s,followControlledElements:a=true}=e;if(!r)return;let l=ue(r),c=ae(r),d=jf(c),u=qf(c);function h(w,E){if(!Q(E)||!E.isConnected||Ve(r,E)||E1(r,w)||a&&Ca(r,E))return false;let x=l.querySelector(`[aria-controls="${r.id}"]`);if(x){let P=La(x);if(Qf(w,P))return false}let S=La(r);return Qf(w,S)?false:!t?.(E)}let p=new Set,m=_n(r?.getRootNode()),f=false;function g(w){f=true;let E=()=>{f=false;};l.addEventListener("pointerup",E,{once:true}),c.addEventListener("pointerup",E,{once:true});function x(S){let P=s&&!Zc()?he:M=>M(),k=S??w,T=k?.composedPath?.()??[k?.target];P(()=>{let M=m?T[0]:ge(w);if(!(!r||!h(w,M))){if(i||o){let L=tn(i,o);r.addEventListener(Zf,L,{once:true});}eg(r,Zf,{bubbles:false,cancelable:true,detail:{originalEvent:k,contextmenu:Ta(k),focusable:T1(T),target:M}});}});}w.pointerType==="touch"?(p.forEach(S=>S()),p.add(Me(l,"click",x,{once:true})),p.add(u.addEventListener("click",x,{once:true})),p.add(d.addEventListener("click",x,{once:true}))):x();}let b=new Set,y=setTimeout(()=>{b.add(Me(l,"pointerdown",g,true)),b.add(u.addEventListener("pointerdown",g,true)),b.add(d.addEventListener("pointerdown",g,true));},0);function v(w){if(f)return;(s?he:x=>x())(()=>{let x=w?.composedPath?.()??[w?.target],S=m?x[0]:ge(w);if(!(!r||!h(w,S))){if(n||o){let P=tn(n,o);r.addEventListener(Jf,P,{once:true});}eg(r,Jf,{bubbles:false,cancelable:true,detail:{originalEvent:w,contextmenu:false,focusable:Ue(S),target:S}});}});}return Zc()||(b.add(Me(l,"focusin",v,true)),b.add(u.addEventListener("focusin",v,true)),b.add(d.addEventListener("focusin",v,true))),()=>{clearTimeout(y),p.forEach(w=>w()),b.forEach(w=>w());}}function ng(r,e){let{defer:t}=e,n=t?he:o=>o(),i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(L1(o,e));})),()=>{i.forEach(o=>o?.());}}function eg(r,e,t){let n=r.ownerDocument.defaultView||window,i=new n.CustomEvent(e,t);return r.dispatchEvent(i)}function rg(r,e){let t=n=>{n.key==="Escape"&&(n.isComposing||e?.(n));};return Me(ue(r),"keydown",t,{capture:true})}var ig="layer:request-dismiss",Te={layers:[],branches:[],recentlyRemoved:new Set,count(){return this.layers.length},pointerBlockingLayers(){return this.layers.filter(r=>r.pointerBlocking)},topMostPointerBlockingLayer(){return [...this.pointerBlockingLayers()].slice(-1)[0]},hasPointerBlockingLayer(){return this.pointerBlockingLayers().length>0},isBelowPointerBlockingLayer(r){let e=this.indexOf(r),t=this.topMostPointerBlockingLayer()?this.indexOf(this.topMostPointerBlockingLayer()?.node):-1;return e<t},isTopMost(r){return this.layers[this.count()-1]?.node===r},getNestedLayers(r){return Array.from(this.layers).slice(this.indexOf(r)+1)},getLayersByType(r){return this.layers.filter(e=>e.type===r)},getNestedLayersByType(r,e){let t=this.indexOf(r);return t===-1?[]:this.layers.slice(t+1).filter(n=>n.type===e)},getParentLayerOfType(r,e){let t=this.indexOf(r);if(!(t<=0))return this.layers.slice(0,t).reverse().find(n=>n.type===e)},countNestedLayersOfType(r,e){return this.getNestedLayersByType(r,e).length},isInNestedLayer(r,e){return !!(this.getNestedLayers(r).some(n=>Ve(n.node,e))||this.recentlyRemoved.size>0)},isInBranch(r){return Array.from(this.branches).some(e=>Ve(e,r))},add(r){let e=this.indexOf(r.node);e!==-1&&this.layers.splice(e,1),this.layers.push(r),this.syncLayers();},addBranch(r){this.branches.push(r);},remove(r){let e=this.indexOf(r);if(e<0)return;this.layers[e].styleTargets?.forEach(n=>{let i=n();i&&M1(i);}),this.recentlyRemoved.add(r),gm(()=>this.recentlyRemoved.delete(r)),e<this.count()-1&&this.getNestedLayers(r).forEach(i=>Te.dismiss(i.node,r)),this.layers.splice(e,1),this.syncLayers();},removeBranch(r){let e=this.branches.indexOf(r);e>=0&&this.branches.splice(e,1);},syncLayers(){this.layers.forEach((r,e)=>{og(r,e,r.node),r.styleTargets?.forEach(t=>{let n=t();if(!n||n===r.node)return;og(r,e,n);let{zIndex:i}=Tr(r.node);n.style.setProperty("--z-index",i);});});},indexOf(r){return this.layers.findIndex(e=>e.node===r)},dismiss(r,e){let t=this.indexOf(r);if(t===-1)return;let n=this.layers[t];I1(r,ig,i=>{n.requestDismiss?.(i),i.defaultPrevented||n?.dismiss();}),k1(r,ig,{originalLayer:r,targetLayer:e,originalIndex:t,targetIndex:e?this.indexOf(e):-1}),this.syncLayers();},clear(){this.remove(this.layers[0].node);}};function og(r,e,t){t.style.setProperty("--layer-index",`${e}`),t.removeAttribute("data-nested"),t.removeAttribute("data-has-nested"),Te.getParentLayerOfType(r.node,r.type)&&t.setAttribute("data-nested",r.type);let i=Te.countNestedLayersOfType(r.node,r.type);i>0&&t.setAttribute("data-has-nested",r.type),t.style.setProperty("--nested-layer-count",`${i}`);}function M1(r){r.style.removeProperty("--layer-index"),r.style.removeProperty("--nested-layer-count"),r.style.removeProperty("--z-index"),r.removeAttribute("data-nested"),r.removeAttribute("data-has-nested");}function k1(r,e,t){let n=r.ownerDocument.defaultView||window,i=new n.CustomEvent(e,{cancelable:true,bubbles:true,detail:t});return r.dispatchEvent(i)}function I1(r,e,t){r.addEventListener(e,t,{once:true});}var Ld=new WeakMap,ao=new WeakMap;function A1(r){return Te.isBelowPointerBlockingLayer(r)?"none":"auto"}function sg(r){let e=A1(r);r.style.pointerEvents!==e&&(r.style.pointerEvents=e);}function R1(r){if(ao.has(r))return;let e=ae(r);if(typeof e.MutationObserver>"u")return;let t=new e.MutationObserver(()=>{ao.has(r)&&sg(r);});t.observe(r,{attributes:true,attributeFilter:["style"]}),ao.set(r,t);}function Md(){Te.layers.forEach(({node:r})=>{sg(r),R1(r);});}function ag(r){let e=ao.get(r);e&&(e.disconnect(),ao.delete(r)),r.style.pointerEvents="";}function lg(r,e){let t=ue(r),n=[];return Te.hasPointerBlockingLayer()&&!t.body.hasAttribute("data-inert")&&(Ld.set(t.body,t.body.style.pointerEvents),queueMicrotask(()=>{let i=t.body;i&&(i.style.pointerEvents="none",i.setAttribute("data-inert",""));})),e?.forEach(i=>{let[o,s]=Tm(()=>{let a=i();return Q(a)?a:null},{timeout:1e3});o.then(a=>n.push(Yi(a,{pointerEvents:"auto"}))),n.push(s);}),()=>{Te.hasPointerBlockingLayer()||(queueMicrotask(()=>{let i=t.body;if(!i)return;let o=Ld.get(i);o!==void 0&&(i.style.pointerEvents=o,Ld.delete(i)),i.removeAttribute("data-inert"),i.style.length===0&&i.removeAttribute("style");}),n.forEach(i=>i()));}}function D1(r,e){let{warnOnMissingNode:t=true}=e;if(t&&!r){wr("[@zag-js/dismissable] node is `null` or `undefined`");return}if(!r)return;let{onDismiss:n,onRequestDismiss:i,pointerBlocking:o,exclude:s,debug:a,type:l="dialog",layerStyleTargets:c}=e,d={dismiss:n,node:r,type:l,pointerBlocking:o,requestDismiss:i,styleTargets:c};Te.add(d),Md();function u(g){let b=ge(g.detail.originalEvent);Te.isBelowPointerBlockingLayer(r)||Te.isInBranch(b)||(e.onPointerDownOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onPointerDownOutside:",g.detail.originalEvent),n?.()));}function h(g){let b=ge(g.detail.originalEvent);Te.isInBranch(b)||(e.onFocusOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onFocusOutside:",g.detail.originalEvent),n?.()));}function p(g){Te.isTopMost(r)&&(e.onEscapeKeyDown?.(g),!g.defaultPrevented&&n&&(g.preventDefault(),n()));}function m(g){if(!r)return false;let b=typeof s=="function"?s():s,y=Array.isArray(b)?b:[b],v=e.persistentElements?.map(w=>w()).filter(Q);return v&&y.push(...v),y.some(w=>Ve(w,g))||Te.isInNestedLayer(r,g)}let f=[o?lg(r,e.persistentElements):void 0,rg(r,p),ng(r,{exclude:m,onFocusOutside:h,onPointerDownOutside:u,defer:e.defer})];return ()=>{Te.remove(r),Md(),ag(r),f.forEach(g=>g?.());}}function Za(r,e){let{defer:t}=e,n=t?he:o=>o(),i=[];return i.push(n(()=>{let o=Ne(r)?r():r;i.push(D1(o,e));})),()=>{i.forEach(o=>o?.());}}function O1(r){return !(r.metaKey||!Er()&&r.altKey||r.ctrlKey||r.key==="Control"||r.key==="Shift"||r.key==="Meta")}var F1=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function N1(r,e,t){let n=t?ge(t):null,i=ue(n),o=ae(n),s=yt(i);return r=r||s instanceof o.HTMLInputElement&&!F1.has(s?.type)||s instanceof o.HTMLTextAreaElement||s instanceof o.HTMLElement&&s.isContentEditable,!(r&&e==="keyboard"&&t instanceof o.KeyboardEvent&&!Reflect.has(V1,t.key))}var Ht=null,kd=new Set,Ja=new Map,Kn=false,Id=false,dg=false,V1={Tab:true,Escape:true};function el(r,e){for(let t of kd)t(r,e);}function Qa(r){Kn=true,O1(r)&&(Ht="keyboard",el("keyboard",r));}function Ye(r){Ht="pointer",(r.type==="mousedown"||r.type==="pointerdown")&&(Kn=true,el("pointer",r));}function ug(r){lm(r)&&(Kn=true,Ht="virtual");}function hg(r){let e=ge(r);e===ae(e)||e===ue(e)||dg||!r.isTrusted||(!Kn&&!Id&&(Ht="virtual",el("virtual",r)),Kn=false,Id=false);}function pg(){(Kn=false,Id=true);}function _1(r){if(typeof window>"u"||Ja.get(ae(r)))return;let e=ae(r),t=ue(r),n=e.HTMLElement.prototype.focus;function i(){Kn=true,n.apply(this,arguments);}try{Object.defineProperty(e.HTMLElement.prototype,"focus",{configurable:!0,value:i});}catch{}t.addEventListener("keydown",Qa,true),t.addEventListener("keyup",Qa,true),t.addEventListener("click",ug,true),e.addEventListener("focus",hg,true),e.addEventListener("blur",pg,false),typeof e.PointerEvent<"u"?(t.addEventListener("pointerdown",Ye,true),t.addEventListener("pointermove",Ye,true),t.addEventListener("pointerup",Ye,true)):(t.addEventListener("mousedown",Ye,true),t.addEventListener("mousemove",Ye,true),t.addEventListener("mouseup",Ye,true)),e.addEventListener("beforeunload",()=>{B1(r);},{once:true}),Ja.set(e,{focus:n});}var B1=(r,e)=>{let t=ae(r),n=ue(r);let i=Ja.get(t);if(i){try{Object.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,value:i.focus});}catch{}n.removeEventListener("keydown",Qa,true),n.removeEventListener("keyup",Qa,true),n.removeEventListener("click",ug,true),t.removeEventListener("focus",hg,true),t.removeEventListener("blur",pg,false),typeof t.PointerEvent<"u"?(n.removeEventListener("pointerdown",Ye,true),n.removeEventListener("pointermove",Ye,true),n.removeEventListener("pointerup",Ye,true)):(n.removeEventListener("mousedown",Ye,true),n.removeEventListener("mousemove",Ye,true),n.removeEventListener("mouseup",Ye,true)),Ja.delete(t);}};function mg(){return Ht}function fg(r){Ht=r,el(r,null);}function cg(){return Ht==="keyboard"||Ht==="virtual"}function gg(r={}){let{isTextInput:e,autoFocus:t,onChange:n,root:i}=r;_1(i),n?.({isFocusVisible:t||cg(),modality:Ht});let o=(s,a)=>{N1(!!e,s,a)&&n?.({isFocusVisible:cg(),modality:s});};return kd.add(o),()=>{kd.delete(o);}}var{not:Ke,and:Vr,or:H1}=Gp(),Ad=wa({props({props:r}){return {closeOnSelect:true,typeahead:true,composite:true,loopFocus:false,navigate(e){ym(e.node);},...r,positioning:{placement:"bottom-start",gutter:8,...r.positioning}}},initialState({prop:r}){return r("open")||r("defaultOpen")?"open":"idle"},context({bindable:r,prop:e,scope:t}){return {highlightedValue:r(()=>({defaultValue:e("defaultHighlightedValue")||null,value:e("highlightedValue"),onChange(n){e("onHighlightChange")?.({highlightedValue:n});}})),lastHighlightedValue:r(()=>({defaultValue:null})),currentPlacement:r(()=>({defaultValue:void 0})),intentPolygon:r(()=>({defaultValue:null})),anchorPoint:r(()=>({defaultValue:null,hash(n){return `x: ${n?.x}, y: ${n?.y}`}})),isSubmenu:r(()=>({defaultValue:false})),triggerValue:r(()=>({defaultValue:e("defaultTriggerValue")??null,value:e("triggerValue"),onChange(n){let i=e("onTriggerValueChange");if(!i)return;let o=ro(t,n);i({value:n,triggerElement:o});}})),pointerRoutingMode:r(()=>({defaultValue:"interactive"}))}},refs(){return {parent:null,children:{},pointerRoutingLocked:false,typeaheadState:{...ka.defaultOptions},positioningOverride:{}}},computed:{isRtl:({prop:r})=>r("dir")==="rtl",isTypingAhead:({refs:r})=>r.get("typeaheadState").keysSoFar!=="",highlightedId:({context:r,scope:e,refs:t})=>Uf(t.get("children"),r.get("highlightedValue"),e)},watch({track:r,action:e,context:t,prop:n}){r([()=>t.get("isSubmenu")],()=>{e(["setSubmenuPlacement"]);}),r([()=>t.hash("anchorPoint")],()=>{t.get("anchorPoint")&&e(["reposition"]);}),r([()=>n("open")],()=>{e(["toggleVisibility"]);});},on:{"TRIGGER_VALUE.SET":{actions:["setTriggerValue","setAnchorPoint","reposition","focusMenu"]},"PARENT.SET":{actions:["setParentMenu"]},"CHILD.SET":{actions:["setChildMenu"]},OPEN:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","invokeOnOpen"]}],OPEN_AUTOFOCUS:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightFirstItem","invokeOnOpen"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"HIGHLIGHTED.RESTORE":{actions:["restoreHighlightedItem"]},"HIGHLIGHTED.SET":{actions:["setHighlightedItem"]},"HIGHLIGHTED.SUGGEST":{actions:["suggestHighlightedItem"]}},states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed"},CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint","setTriggerValue"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],TRIGGER_FOCUS:{guard:Ke("isSubmenu"),target:"closed"},TRIGGER_POINTERMOVE:{guard:"isSubmenu",target:"opening"}}},"opening:contextmenu":{tags:["closed"],effects:["waitForLongPress"],on:{"CONTROLLED.OPEN":{target:"open",actions:["reposition"]},"CONTROLLED.CLOSE":{target:"closed",actions:["focusTrigger"]},CONTEXT_MENU_CANCEL:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"LONG_PRESS.OPEN":[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","invokeOnOpen","reposition"]}]}},opening:{tags:["closed"],effects:["waitForOpenDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed",actions:["focusTrigger"]},BLUR:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],TRIGGER_POINTERLEAVE:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"DELAY.OPEN":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}]}},closing:{tags:["open"],effects:["trackPointerMove","trackInteractOutside","waitForCloseDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]},MENU_POINTERENTER:{target:"open",actions:["clearIntentPolygon"]},POINTER_MOVED_AWAY_FROM_SUBMENU:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]}],"DELAY.CLOSE":[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem","invokeOnClose","releaseParentRoutingLock"]}]}},closed:{tags:["closed"],entry:["clearHighlightedItem","unlockParentOnClose","clearAnchorPoint"],on:{"CONTROLLED.OPEN":[{guard:H1("isOpenAutoFocusEvent","isArrowDownEvent"),target:"open",actions:["highlightFirstItem"]},{guard:"isArrowUpEvent",target:"open",actions:["highlightLastItem"]},{target:"open"}],CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint","setTriggerValue"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",target:"opening"},TRIGGER_BLUR:{target:"idle"},ARROW_DOWN:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightFirstItem","invokeOnOpen"]}],ARROW_UP:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightLastItem","invokeOnOpen"]}]}},open:{tags:["open"],effects:["trackInteractOutside","trackFocusVisible","trackPositioning","scrollToHighlightedItem"],entry:["focusMenu","unlockParentOnOpen"],on:{"CONTROLLED.CLOSE":[{target:"closed",guard:"isArrowLeftEvent",actions:["focusParentMenu"]},{target:"closed",actions:["focusTrigger"]}],TRIGGER_CLICK:[{guard:Vr(Ke("isTriggerItem"),"isOpenControlled"),actions:["invokeOnClose","releaseParentRoutingLock"]},{guard:Ke("isTriggerItem"),target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],CONTEXT_MENU:{actions:["setAnchorPoint","setTriggerValue","focusMenu"]},ARROW_UP:{actions:["highlightPrevItem","focusMenu"]},ARROW_DOWN:{actions:["highlightNextItem","focusMenu"]},ARROW_LEFT:[{guard:Vr("isSubmenu","isOpenControlled"),actions:["invokeOnClose","releaseParentRoutingLock"]},{guard:"isSubmenu",target:"closed",actions:["focusParentMenu","invokeOnClose","releaseParentRoutingLock"]}],HOME:{actions:["highlightFirstItem","focusMenu"]},END:{actions:["highlightLastItem","focusMenu"]},ARROW_RIGHT:{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},ENTER:[{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},{actions:["clickHighlightedItem"]}],ITEM_POINTERMOVE:[{guard:Ke("isPointerRoutingLocked"),actions:["setHighlightedItem","focusMenu","closeSiblingMenus"]},{actions:["setLastHighlightedItem","closeSiblingMenus"]}],ITEM_POINTERLEAVE:{guard:Vr(Ke("isPointerRoutingLocked"),Ke("isTriggerItem")),actions:["clearHighlightedItem"]},ITEM_CLICK:[{guard:Vr(Ke("isTriggerItemHighlighted"),Ke("isHighlightedItemEditable"),"closeOnSelect","isOpenControlled"),actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock"]},{guard:Vr(Ke("isTriggerItemHighlighted"),Ke("isHighlightedItemEditable"),"closeOnSelect"),target:"closed",actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock","focusTrigger"]},{guard:Vr(Ke("isTriggerItemHighlighted"),Ke("isHighlightedItemEditable")),actions:["invokeOnSelect","setOptionState"]},{actions:["setHighlightedItem"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",actions:["setIntentPolygon"]},TRIGGER_POINTERLEAVE:{target:"closing",actions:["setIntentPolygon"]},ITEM_POINTERDOWN:{actions:["setHighlightedItem"]},TYPEAHEAD:{actions:["highlightMatchedItem"]},FOCUS_MENU:{actions:["focusMenu"]},"POSITIONING.SET":{actions:["reposition"]}}}},implementations:{guards:{closeOnSelect:({prop:r,event:e})=>!!(e?.closeOnSelect??r("closeOnSelect")),isTriggerItem:({event:r})=>Sd(r.target),isTriggerItemHighlighted:({event:r,scope:e,computed:t})=>!!(r.target??e.getById(t("highlightedId")))?.hasAttribute("data-controls"),isSubmenu:({context:r})=>r.get("isSubmenu"),isPointerRoutingLocked:({refs:r})=>r.get("pointerRoutingLocked"),isHighlightedItemEditable:({scope:r,computed:e})=>Cr(r.getById(e("highlightedId"))),isOpenControlled:({prop:r})=>r("open")!==void 0,isArrowLeftEvent:({event:r})=>r.previousEvent?.type==="ARROW_LEFT",isArrowUpEvent:({event:r})=>r.previousEvent?.type==="ARROW_UP",isArrowDownEvent:({event:r})=>r.previousEvent?.type==="ARROW_DOWN",isOpenAutoFocusEvent:({event:r})=>r.previousEvent?.type==="OPEN_AUTOFOCUS"},effects:{waitForOpenDelay({send:r}){let e=setTimeout(()=>{r({type:"DELAY.OPEN"});},200);return ()=>clearTimeout(e)},waitForCloseDelay({send:r}){let e=setTimeout(()=>{r({type:"DELAY.CLOSE"});},100);return ()=>clearTimeout(e)},waitForLongPress({send:r}){let e=setTimeout(()=>{r({type:"LONG_PRESS.OPEN"});},700);return ()=>clearTimeout(e)},trackFocusVisible({scope:r}){return gg({root:r.getRootNode?.()})},trackPositioning({context:r,prop:e,scope:t,refs:n}){if(Of(t)||wd(t).length>0)return;let o={...e("positioning"),...n.get("positioningOverride")};return r.set("currentPlacement",o.placement),Ka(()=>ro(t,r.get("triggerValue")),()=>bd(t),{...o,defer:true,onComplete(l){r.set("currentPlacement",l.placement);}})},trackInteractOutside({refs:r,scope:e,prop:t,context:n,send:i}){let o=()=>st(e),s=true,a=l=>wd(e).some(c=>Ve(c,l));return Za(o,{type:"menu",defer:true,exclude:[vd(e),...yd(e)].filter(Boolean),onInteractOutside:t("onInteractOutside"),onRequestDismiss:t("onRequestDismiss"),onFocusOutside(l){t("onFocusOutside")?.(l);let c=ge(l.detail.originalEvent);if(a(c)){l.preventDefault();return}if(Cd(c,r.get("children"))){l.preventDefault();return}},onEscapeKeyDown(l){t("onEscapeKeyDown")?.(l),n.get("isSubmenu")&&l.preventDefault(),Ed({parent:r.get("parent")});},onPointerDownOutside(l){t("onPointerDownOutside")?.(l);let c=ge(l.detail.originalEvent);if(a(c)&&l.detail.contextmenu){l.preventDefault();return}s=!l.detail.focusable;},onDismiss(){i({type:"CLOSE",src:"interact-outside",restoreFocus:s});}})},trackPointerMove({context:r,scope:e,send:t,refs:n}){let i=n.get("parent");if(!i)return;cn(i,true);let o=e.getDoc();return Me(o,"pointermove",s=>{Gf(r.get("intentPolygon"),{x:s.clientX,y:s.clientY})||(t({type:"POINTER_MOVED_AWAY_FROM_SUBMENU"}),cn(i,false));})},scrollToHighlightedItem({scope:r,computed:e}){let t=()=>{if(mg()==="pointer")return;let o=r.getById(e("highlightedId")),s=st(r);xm(o,{rootEl:s,block:"nearest"});};return he(()=>{fg("virtual"),t();}),vm(()=>st(r),{attributes:["aria-activedescendant"],callback:t})}},actions:{setAnchorPoint({context:r,event:e}){r.set("anchorPoint",t=>vr(t,e.point)?t:e.point);},setSubmenuPlacement({context:r,computed:e,refs:t}){if(!r.get("isSubmenu"))return;let n=e("isRtl")?"left-start":"right-start";t.set("positioningOverride",{placement:n,gutter:0});},reposition({context:r,scope:e,prop:t,event:n,refs:i}){let o=()=>bd(e),s=n.point??r.get("anchorPoint"),a=s?()=>({width:0,height:0,...s}):void 0,l={...t("positioning"),...i.get("positioningOverride")},c=n.value??r.get("triggerValue");Ka(()=>ro(e,c),o,{...l,defer:true,getAnchorRect:a,...n.options??{},listeners:false,onComplete(u){r.set("currentPlacement",u.placement);}});},setOptionState({event:r}){if(!r.option)return;let{checked:e,onCheckedChange:t,type:n}=r.option;n==="radio"?t?.(true):n==="checkbox"&&t?.(!e);},clickHighlightedItem({scope:r,computed:e,prop:t,context:n}){let i=r.getById(e("highlightedId"));if(!i||i.dataset.disabled)return;let o=n.get("highlightedValue");jp(i)?t("navigate")?.({value:o,node:i,href:i.href}):queueMicrotask(()=>i.click());},setIntentPolygon({context:r,scope:e,event:t}){let n=st(e),i=r.get("currentPlacement");if(!n||!i)return;let o=n.getBoundingClientRect(),s=Wf(o,i);if(!s)return;let l=no(i)==="right"?-5:5;r.set("intentPolygon",[{...t.point,x:t.point.x+l},...s]);},clearIntentPolygon({context:r}){r.set("intentPolygon",null);},clearAnchorPoint({context:r}){r.set("anchorPoint",null);},unlockParentOnOpen({refs:r,context:e,scope:t}){let n=r.get("parent");if(e.get("isSubmenu")){let i=Et(t);n?.send({type:"HIGHLIGHTED.SUGGEST",value:i});}cn(n,false);},unlockParentOnClose({refs:r,context:e}){Kf(r.get("parent"),e.get("isSubmenu"));},setHighlightedItem({context:r,event:e}){let t=e.value||ln(e.target);r.set("highlightedValue",t);},clearHighlightedItem({context:r}){r.set("highlightedValue",null);},focusMenu({scope:r}){he(()=>{let e=st(r);Pa({root:e,enabled:!Ve(e,r.getActiveElement()),filter(n){return !n.role?.startsWith("menuitem")}})?.focus({preventScroll:true});});},highlightFirstItem({context:r,scope:e}){(st(e)?queueMicrotask:he)(()=>{let n=Ff(e);n&&r.set("highlightedValue",ln(n));});},highlightLastItem({context:r,scope:e}){(st(e)?queueMicrotask:he)(()=>{let n=Nf(e);n&&r.set("highlightedValue",ln(n));});},highlightNextItem({context:r,scope:e,event:t,prop:n}){let i=Vf(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",ln(i));},highlightPrevItem({context:r,scope:e,event:t,prop:n}){let i=_f(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",ln(i));},invokeOnSelect({context:r,prop:e,scope:t}){let n=r.get("highlightedValue");if(n==null)return;let i=Df(t,n);Hf(i,n),e("onSelect")?.({value:n});},focusTrigger({scope:r,context:e,event:t}){e.get("isSubmenu")||e.get("anchorPoint")||t.restoreFocus===false||queueMicrotask(()=>{ro(r,e.get("triggerValue"))?.focus({preventScroll:true});});},highlightMatchedItem({scope:r,context:e,event:t,refs:n}){let i=Bf(r,{key:t.key,value:e.get("highlightedValue"),typeaheadState:n.get("typeaheadState")});i&&e.set("highlightedValue",ln(i));},setParentMenu({refs:r,event:e,context:t}){r.set("parent",e.value),t.set("isSubmenu",true);},setChildMenu({refs:r,event:e}){let t=r.get("children");t[e.id]=e.value,r.set("children",t);},closeSiblingMenus({refs:r,event:e,scope:t}){let n=e.target;if(!Sd(n))return;let i=n?.getAttribute("data-uid"),o=r.get("children");for(let s in o){if(s===i)continue;let a=o[s],l=a.context.get("intentPolygon");l&&e.point&&qa(l,e.point)||(st(t)?.focus({preventScroll:true}),a.send({type:"CLOSE"}));}},closeRootMenu({refs:r}){Ed({parent:r.get("parent")});},openSubmenu({refs:r,scope:e,computed:t}){let i=e.getById(t("highlightedId"))?.getAttribute("data-uid"),o=r.get("children");(i?o[i]:null)?.send({type:"OPEN_AUTOFOCUS"});},focusParentMenu({refs:r}){r.get("parent")?.send({type:"FOCUS_MENU"});},setLastHighlightedItem({context:r,event:e}){r.set("lastHighlightedValue",ln(e.target));},suggestHighlightedItem({context:r,event:e}){let t=e.value;if(t){if(r.get("highlightedValue")!=null){r.set("lastHighlightedValue",t);return}r.set("highlightedValue",t);}},restoreHighlightedItem({context:r}){let e=r.get("lastHighlightedValue");r.set("lastHighlightedValue",null),e&&r.set("highlightedValue",e);},restoreParentHighlightedItem({refs:r}){r.get("parent")?.send({type:"HIGHLIGHTED.RESTORE"});},invokeOnOpen({prop:r}){r("onOpenChange")?.({open:true});},invokeOnClose({prop:r}){r("onOpenChange")?.({open:false});},releaseParentRoutingLock({refs:r,context:e}){e.get("isSubmenu")&&Xf(r.get("parent"));},toggleVisibility({prop:r,event:e,send:t}){t({type:r("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:e});},setTriggerValue({context:r,event:e}){e.value!==void 0&&r.set("triggerValue",e.value);}}}});function bg(r){return {machine:Ad,props:{id:r.id??Na("vela-menu"),ids:r.triggerId?{trigger:r.triggerId}:void 0,positioning:{placement:r.placement??"bottom-start",...r.getAnchorRect?{getAnchorRect:()=>r.getAnchorRect()}:{}},onSelect:e=>r.onSelect?.(e.value),onOpenChange:e=>r.onOpenChange?.(e.open)},connect:e=>Pd(e,Ir)}}var vg="vela-ui-menu",yg=`
3
+ `),s=Math.max(1,...o.map(c=>c.length)),a=Math.max(20,s*i*.6)+16,l=o.length*i*1.4+12;return {x:e.xOf(t.time)-a/2,y:n-l/2,w:a,h:l}}points(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:[[e.xOf(t.time),i],[e.xOf(n.time),o]]}hitTest(e,t,n,i){let o=this.box(n);if(o&&ye(e,t,o.x,o.y,o.x+o.w,o.y+o.h,i))return true;let s=this.points(n);return s!=null&&U(e,t,s[0][0],s[0][1],s[1][0],s[1][1])<=i}handlePoints(e){let t=this.points(e);return t?[t[0]]:[]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}translateBody(e,t,n){let i=n[0],o=n[1];return !i||!o?n.map(s=>({time:s.time+e,price:s.price+t})):[{time:i.time,price:i.price},{time:o.time+e,price:o.price+t}]}bounds(e){return this.box(e)}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[...F,...ee,...N],textIsContent:true}}};var dt=class extends $e{constructor(){super(...arguments);this.type="callout";}};var xn=class extends $e{constructor(){super(...arguments);this.type="pricenote";}defaultLabel(){return ""}labelText(){let t=this.anchors[0]?.price;return t==null?"0.00":t.toFixed(2)}schema(){return {fields:[...F,...ee,...N.filter(t=>t.path!=="text.value")]}}};var Sn=class extends $e{constructor(){super(...arguments);this.type="comment";}defaultLabel(){return "Comment"}};var Cn=class extends $e{constructor(){super(...arguments);this.type="signpost";}defaultLabel(){return "Signpost"}};var te=class extends _{hitTest(e,t,n,i){let o=this.geometry(n);return o?this.style.fillColor&&o.fill&&ct(e,t,o.fill)?true:o.segments.some(s=>U(e,t,s[0],s[1],s[2],s[3])<=i):false}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}};var hs=class extends te{constructor(){super(...arguments);this.type="parallelchannel";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"offset",free:"y"}]}}offset(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];return !t||!n||!i?0:i.price-(t.price+n.price)/2}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return [];let a=[[t.xOf(n.time),o],[t.xOf(i.time),s]],l=this.anchors[2];if(l){let c=t.yOf(l.price,this.paneId);c!=null&&a.push([t.xOf((n.time+i.time)/2),c]);}return a}timeExtent(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.time,n.time),max:Math.max(t.time,n.time)}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=this.offset(),s=t.xOf(n.time),a=t.xOf(i.time),l=t.yOf(n.price,this.paneId),c=t.yOf(i.price,this.paneId),d=t.yOf(n.price+o,this.paneId),u=t.yOf(i.price+o,this.paneId);return l==null||c==null||d==null||u==null?null:{segments:[[s,l,a,c],[s,d,a,u]],fill:[[s,l],[a,c],[a,u],[s,d]]}}priceRange(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=this.offset(),o=[t.price,n.price,t.price+i,n.price+i],s=this.anchors[2];return s&&o.push(s.price),{min:Math.min(...o),max:Math.max(...o)}}schema(){return {fields:[...F,...ee,...N]}}};var ps=class extends te{constructor(){super(...arguments);this.type="disjointchannel";}anchorSchema(){return {min:4,max:4,slots:[{role:"top1",free:"both"},{role:"top2",free:"both"},{role:"bot1",free:"both"},{role:"bot2",free:"both"}]}}seg(t,n,i){let o=this.anchors[t],s=this.anchors[n];if(!o||!s)return null;let a=i.yOf(o.price,this.paneId),l=i.yOf(s.price,this.paneId);return a==null||l==null?null:[i.xOf(o.time),a,i.xOf(s.time),l]}geometry(t){let n=this.seg(0,1,t),i=this.seg(2,3,t),o=[n,i].filter(a=>a!=null);if(o.length===0)return null;let s=n&&i?[[n[0],n[1]],[n[2],n[3]],[i[2],i[3]],[i[0],i[1]]]:null;return {segments:o,fill:s}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F,...ee,...N]}}};var ms=class extends te{constructor(){super(...arguments);this.type="flattopbottom";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"flat",free:"y"}]}}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return [];let a=[[t.xOf(n.time),o],[t.xOf(i.time),s]],l=this.anchors[2];if(l){let c=t.yOf(l.price,this.paneId);c!=null&&a.push([t.xOf((n.time+i.time)/2),c]);}return a}timeExtent(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.time,n.time),max:Math.max(t.time,n.time)}}geometry(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.xOf(i.time),a=t.yOf(n.price,this.paneId),l=t.yOf(i.price,this.paneId);if(a==null||l==null)return null;let c=this.anchors[2];if(!c)return {segments:[[o,a,s,l]],fill:null};let d=t.yOf(c.price,this.paneId);return d==null?null:{segments:[[o,a,s,l],[o,d,s,d]],fill:[[o,a],[s,l],[s,d],[o,d]]}}priceRange(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=[t.price,n.price],o=this.anchors[2];return o&&i.push(o.price),{min:Math.min(...i),max:Math.max(...i)}}schema(){return {fields:[...F,...ee,...N]}}};var Lw=2;function Vh(){return {midColor:Pe,midStyle:"solid",upperColor:q,upperStyle:"solid",lowerColor:X,lowerStyle:"solid",upperFill:`${q}26`,lowerFill:`${X}26`,showR2:true}}function _h(r){let e=r.length;if(e<2)return null;let t=0,n=0,i=0,o=0,s=0;for(let m=0;m<e;m+=1){let f=r[m].close;t+=m,n+=f,i+=m*f,o+=m*m,s+=f*f;}let a=e*o-t*t,l=a===0?0:(e*i-t*n)/a,c=(n-l*t)/e,d=0;for(let m=0;m<e;m+=1){let f=r[m].close-(c+l*m);d+=f*f;}let u=Math.sqrt(d/e),h=Math.sqrt(a*(e*s-n*n)),p=h===0?0:(e*i-t*n)/h;return {t0:r[0].time,t1:r[e-1].time,mid0:c,mid1:c+l*(e-1),dev:Lw*u,r2:Math.max(0,Math.min(1,p*p)),n:e}}var Dt=class extends _{constructor(t){super(t);this.type="regressionchannel";this.cachedRange=null;this.reg||(this.reg=Vh());}anchorSchema(){return {min:2,max:2,slots:[{role:"start",free:"x"},{role:"end",free:"x"}]}}fit(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=Math.min(n.time,i.time),s=Math.max(n.time,i.time),a=t.barsInRange?.(o,s)??null,l=a?_h(a):null;return l&&(this.cachedRange={min:Math.min(l.mid0,l.mid1)-l.dev,max:Math.max(l.mid0,l.mid1)+l.dev}),l}layout(t){let n=this.fit(t);if(!n)return null;let i=t.yOf(n.mid0,this.paneId),o=t.yOf(n.mid1,this.paneId),s=t.yOf(n.mid0+n.dev,this.paneId),a=t.yOf(n.mid1+n.dev,this.paneId),l=t.yOf(n.mid0-n.dev,this.paneId),c=t.yOf(n.mid1-n.dev,this.paneId);return i==null||o==null||s==null||a==null||l==null||c==null?null:{x0:t.xOf(n.t0),x1:t.xOf(n.t1),midY0:i,midY1:o,upperY0:s,upperY1:a,lowerY0:l,lowerY1:c,r2:n.r2,showR2:this.reg.showR2}}band(t){let n=this.layout(t);return n?[[n.x0,n.upperY0],[n.x1,n.upperY1],[n.x1,n.lowerY1],[n.x0,n.lowerY0]]:null}hitTest(t,n,i,o){let s=this.layout(i);if(!s)return false;let a=[[s.x0,s.upperY0],[s.x1,s.upperY1],[s.x1,s.lowerY1],[s.x0,s.lowerY0]];return ct(t,n,a)?true:[[s.x0,s.midY0,s.x1,s.midY1],[s.x0,s.upperY0,s.x1,s.upperY1],[s.x0,s.lowerY0,s.x1,s.lowerY1]].some(c=>U(t,n,c[0],c[1],c[2],c[3])<=o)}handlePoints(t){let n=this.layout(t);if(n)return [[n.x0,n.midY0],[n.x1,n.midY1]];let i=[];for(let o of this.anchors){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.band(t);if(!n)return null;let i=n.map(l=>l[0]),o=n.map(l=>l[1]),s=Math.min(...i),a=Math.min(...o);return {x:s,y:a,w:Math.max(...i)-s,h:Math.max(...o)-a}}priceRange(){if(this.cachedRange)return this.cachedRange;let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"reg.midColor",label:"Midline color",kind:"color",group:"line"},{path:"reg.midStyle",label:"Midline style",kind:"lineStyle",group:"line"},{path:"reg.upperColor",label:"Upper line color",kind:"color",group:"line"},{path:"reg.upperStyle",label:"Upper line style",kind:"lineStyle",group:"line"},{path:"reg.lowerColor",label:"Lower line color",kind:"color",group:"line"},{path:"reg.lowerStyle",label:"Lower line style",kind:"lineStyle",group:"line"},{path:"reg.upperFill",label:"Upper fill",kind:"color",group:"fill"},{path:"reg.lowerFill",label:"Lower fill",kind:"color",group:"fill"},{path:"reg.showR2",label:"Show R\xB2",kind:"boolean",group:"behavior"}]}}writeProps(){return {...this.reg}}readProps(t){this.reg={...Vh(),...t};}};var Bh=`${It}00`;function Hh(){return {midColor:It,midStyle:"solid",multiplier:1,upperColor:Bh,upperStyle:"solid",lowerColor:Bh,lowerStyle:"solid",bandFill:`${It}33`}}function zh(r,e){let t=r.length;if(t<1)return null;let n=0;for(let c of r)n+=c.volume>0?c.volume:0;let i=n>0,o=0,s=0,a=0,l=[];for(let c=0;c<t;c+=1){let d=r[c],u=(d.high+d.low+d.close)/3,h=i?Math.max(0,d.volume):1;o+=h,s+=u*h,a+=u*u*h;let p=o>0?s/o:u,m=o>0?Math.max(0,a/o-p*p):0,f=Math.sqrt(m)*e;l.push({time:d.time,mid:p,upper:p+f,lower:p-f});}return l}var Tn=class extends _{constructor(t){super(t);this.type="anchoredvwap";this.cachedRange=null;this.cachedExtent=null;this.vwap||(this.vwap=Hh());}anchorSchema(){return {min:1,max:1,slots:[{role:"anchor",free:"x"}]}}series(t){let n=this.anchors[0];if(!n)return null;let i=t.barsInRange?.(n.time,Number.POSITIVE_INFINITY)??null;if(!i||i.length<1)return null;let o=zh(i.map(s=>({time:s.time,high:s.high,low:s.low,close:s.close,volume:s.volume??0})),this.vwap.multiplier);if(o&&o.length>0){let s=1/0,a=-1/0;for(let l of o)l.lower<s&&(s=l.lower),l.upper>a&&(a=l.upper);this.cachedRange={min:s,max:a},this.cachedExtent={min:o[0].time,max:o[o.length-1].time};}return o}layout(t){let n=this.series(t);if(!n)return null;let i=[],o=[],s=[];for(let a of n){let l=t.xOf(a.time),c=t.yOf(a.mid,this.paneId),d=t.yOf(a.upper,this.paneId),u=t.yOf(a.lower,this.paneId);c==null||d==null||u==null||(i.push([l,c]),o.push([l,d]),s.push([l,u]));}return i.length>0?{mid:i,upper:o,lower:s}:null}bandPolygon(t){return [...t.upper,...[...t.lower].reverse()]}hitTest(t,n,i,o){let s=this.layout(i);return s?ct(t,n,this.bandPolygon(s))?true:xc(t,n,s.mid,o)||xc(t,n,s.upper,o)||xc(t,n,s.lower,o):false}handlePoints(t){let n=this.layout(t);if(n&&n.mid.length>0)return [n.mid[0]];let i=this.anchors[0];if(!i)return [];let o=t.yOf(i.price,this.paneId);return o==null?[]:[[t.xOf(i.time),o]]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.layout(t);if(!n)return null;let i=[...n.upper,...n.lower],o=i.map(c=>c[0]),s=i.map(c=>c[1]),a=Math.min(...o),l=Math.min(...s);return {x:a,y:l,w:Math.max(...o)-a,h:Math.max(...s)-l}}priceRange(){return this.cachedRange}timeExtent(){return this.cachedExtent}schema(){return {fields:[{path:"vwap.midColor",label:"VWAP color",kind:"color",group:"line"},{path:"vwap.midStyle",label:"VWAP style",kind:"lineStyle",group:"line"},{path:"vwap.multiplier",label:"Band multiplier",kind:"number",min:.5,max:5,step:.5,group:"behavior"},{path:"vwap.upperColor",label:"Upper band color",kind:"color",group:"line"},{path:"vwap.lowerColor",label:"Lower band color",kind:"color",group:"line"},{path:"vwap.bandFill",label:"Band fill",kind:"color",group:"fill"}]}}writeProps(){return {...this.vwap}}readProps(t){this.vwap={...Hh(),...t};}};function xc(r,e,t,n){for(let i=1;i<t.length;i+=1)if(U(r,e,t[i-1][0],t[i-1][1],t[i][0],t[i][1])<=n)return true;return false}var Mw=`${q}66`,kw=`${X}66`,Iw=`${q}BF`,Aw=`${X}BF`;function $h(){return {rows:24,valueAreaPct:70,widthPct:35,anchor:"left",upColor:Mw,downColor:kw,vaUpColor:Iw,vaDownColor:Aw,showVah:true,vahColor:Pe,vahStyle:"solid",showVal:true,valColor:Pe,valStyle:"solid",showPoc:true,pocColor:void 0,pocStyle:"solid",showDevelopingPoc:false,developingPocColor:Ee,developingPocStyle:"dotted",showDevelopingVa:false,developingVaColor:Ee,developingVaStyle:"dotted"}}function Rw(r,e){return r<0?0:r>=e?e-1:r}function Wh(r,e,t){let n=r.length,i=0,o=0;for(let d=0;d<n;d+=1){let u=r[d].up+r[d].down;i+=u,u>o&&(o=u);}let s=i*Math.min(1,Math.max(0,t)),a=e,l=e,c=o;for(;c<s&&(a>0||l<n-1);){let d=a>0?r[a-1].up+r[a-1].down:-1,u=l<n-1?r[l+1].up+r[l+1].down:-1;u>d?(l+=1,c+=u):(a-=1,c+=d);}return {vaFrom:a,vaTo:l}}function Gh(r,e,t,n){let i=n.volume;if(!(i>0))return;let o=r.length,s=n.close>=n.open?"up":"down",a=new Set;for(let l of [n.open,n.high,n.low,n.close])a.add(Rw(Math.floor((l-e)/t),o));for(let l of a)r[l][s]+=i;}function Uh(r){let e=0,t=0;for(let n=0;n<r.length;n+=1){let i=r[n].up+r[n].down;i>e&&(e=i,t=n);}return e>0?{poc:t,maxTotal:e}:null}function Yh(r,e,t){let n=1/0,i=-1/0;for(let p of r)p.volume>0&&(p.low<n&&(n=p.low),p.high>i&&(i=p.high));if(!Number.isFinite(n))return null;let o=i>n?Math.max(1,Math.round(e)):1,s=i>n?(i-n)/o:1,a=Array.from({length:o},(p,m)=>({price:n+m*s,up:0,down:0}));for(let p of r)Gh(a,n,s,p);let l=Uh(a);if(!l)return null;let{poc:c,maxTotal:d}=l,{vaFrom:u,vaTo:h}=Wh(a,c,t);return {rows:a,rowH:s,min:n,maxTotal:d,poc:c,vaFrom:u,vaTo:h}}function Kh(r,e,t,n){let i=Yh(r,e,t);if(!i)return null;if(!n||r.length<1)return {profile:i,developingPoc:[],developingVaHigh:[],developingVaLow:[]};let{min:o,rowH:s}=i,a=i.rows.length,l=Array.from({length:a},(h,p)=>({price:o+p*s,up:0,down:0})),c=[],d=[],u=[];for(let h of r){Gh(l,o,s,h);let p=Uh(l);if(!p)continue;let{poc:m}=p,{vaFrom:f,vaTo:g}=Wh(l,m,t);c.push({time:h.time,price:l[m].price+s/2}),d.push({time:h.time,price:l[g].price+s}),u.push({time:h.time,price:l[f].price});}return {profile:i,developingPoc:c,developingVaHigh:d,developingVaLow:u}}var Be=class extends _{constructor(t){super(t);this.type="fixedrangevp";this.cachedRange=null;this.frvp||(this.frvp=$h());}anchorSchema(){return {min:2,max:2,slots:[{role:"start",free:"x"},{role:"end",free:"x"}]}}barsInSpan(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=Math.min(n.time,i.time),s=Math.max(n.time,i.time),a=t.barsInRange?.(o,s)??null;return !a||a.length<1?null:a.map(l=>({time:l.time,open:l.open,high:l.high,low:l.low,close:l.close,volume:l.volume??0}))}compute(t){let n=this.barsInSpan(t);if(!n)return null;let i=this.frvp,o=i.showDevelopingPoc||i.showDevelopingVa,s=Kh(n,i.rows,i.valueAreaPct/100,o);if(s){let{profile:a}=s;this.cachedRange={min:a.min,max:a.min+a.rowH*a.rows.length};}return s}layout(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=this.compute(t);if(!o)return null;let{profile:s}=o,a=Math.min(n.time,i.time),l=Math.max(n.time,i.time),c=t.xOf(a),d=t.xOf(l),u=Math.abs(d-c),h=Math.max(1,Math.min(100,Math.max(0,this.frvp.widthPct))/100*u),p=this.frvp.anchor==="left",m=p?Math.min(c,d):Math.max(c,d),f=p?1:-1,g=[];for(let x=0;x<=s.rows.length;x+=1){let S=t.yOf(s.min+x*s.rowH,this.paneId);if(S==null)return null;g.push(S);}let b=x=>t.yOf(x,this.paneId),y=s.rows[s.vaTo].price+s.rowH,v=s.rows[s.vaFrom].price,w=s.rows[s.poc].price+s.rowH/2,E=x=>{let S=[];for(let P of x){let k=b(P.price);k!=null&&S.push([t.xOf(P.time),k]);}return S};return {x0:Math.min(c,d),x1:Math.max(c,d),anchorX:m,maxW:h,grow:f,profile:s,yEdges:g,vahY:b(y),valY:b(v),pocY:b(w),developingPoc:E(o.developingPoc),developingVaHigh:E(o.developingVaHigh),developingVaLow:E(o.developingVaLow)}}hitTest(t,n,i,o){let s=this.layout(i);if(!s)return false;let a=s.grow===1?s.anchorX:s.anchorX-s.maxW,l=s.grow===1?s.anchorX+s.maxW:s.anchorX,c=Math.min(s.yEdges[0],s.yEdges[s.yEdges.length-1]),d=Math.max(s.yEdges[0],s.yEdges[s.yEdges.length-1]);if(ct(t,n,[[a,c],[l,c],[l,d],[a,d]]))return true;let u=[[s.x0,s.vahY],[s.x0,s.valY],[s.x0,s.pocY]];for(let[,h]of u)if(h!=null&&U(t,n,s.x0,h,s.x1,h)<=o)return true;for(let h of [s.developingPoc,s.developingVaHigh,s.developingVaLow])for(let p=1;p<h.length;p+=1)if(U(t,n,h[p-1][0],h[p-1][1],h[p][0],h[p][1])<=o)return true;return false}handlePoints(t){let n=this.layout(t);if(n&&n.pocY!=null)return [[n.x0,n.pocY],[n.x1,n.pocY]];let i=[];for(let o of this.anchors){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.layout(t);if(!n)return null;let i=Math.min(n.x0,n.grow===1?n.anchorX:n.anchorX-n.maxW),o=Math.max(n.x1,n.grow===1?n.anchorX+n.maxW:n.anchorX),s=Math.min(n.yEdges[0],n.yEdges[n.yEdges.length-1]),a=Math.max(n.yEdges[0],n.yEdges[n.yEdges.length-1]);return {x:i,y:s,w:o-i,h:a-s}}priceRange(){if(this.cachedRange)return this.cachedRange;let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"frvp.rows",label:"Rows",kind:"number",min:1,max:500,step:1,group:"behavior"},{path:"frvp.valueAreaPct",label:"Value Area",kind:"number",min:0,max:100,step:1,group:"behavior"},{path:"frvp.widthPct",label:"Width %",kind:"number",min:0,max:100,step:1,group:"behavior"},{path:"frvp.anchor",label:"Anchor",kind:"select",options:[{value:"right",label:"Right"},{value:"left",label:"Left"}],group:"behavior"},{path:"frvp.upColor",label:"Up Volume",kind:"color",group:"fill"},{path:"frvp.downColor",label:"Down Volume",kind:"color",group:"fill"},{path:"frvp.vaUpColor",label:"Value Area Up",kind:"color",group:"fill"},{path:"frvp.vaDownColor",label:"Value Area Down",kind:"color",group:"fill"},{path:"frvp.showVah",label:"VAH",kind:"boolean",group:"line"},{path:"frvp.vahColor",label:"VAH color",kind:"color",group:"line"},{path:"frvp.vahStyle",label:"VAH style",kind:"lineStyle",options:Le,group:"line"},{path:"frvp.showVal",label:"VAL",kind:"boolean",group:"line"},{path:"frvp.valColor",label:"VAL color",kind:"color",group:"line"},{path:"frvp.valStyle",label:"VAL style",kind:"lineStyle",options:Le,group:"line"},{path:"frvp.showPoc",label:"POC",kind:"boolean",group:"line"},{path:"frvp.pocColor",label:"POC color",kind:"color",group:"line"},{path:"frvp.pocStyle",label:"POC style",kind:"lineStyle",options:Le,group:"line"},{path:"frvp.showDevelopingPoc",label:"Developing POC",kind:"boolean",group:"line"},{path:"frvp.developingPocColor",label:"Developing POC color",kind:"color",group:"line"},{path:"frvp.developingPocStyle",label:"Developing POC style",kind:"lineStyle",options:Le,group:"line"},{path:"frvp.showDevelopingVa",label:"Developing VA",kind:"boolean",group:"line"},{path:"frvp.developingVaColor",label:"Developing VA color",kind:"color",group:"line"},{path:"frvp.developingVaStyle",label:"Developing VA style",kind:"lineStyle",options:Le,group:"line"}]}}writeProps(){return {...this.frvp}}readProps(t){this.frvp={...$h(),...t};}};var fs=class extends te{constructor(){super(...arguments);this.type="pitchfork";}anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=g=>{let b=t.yOf(g.price,this.paneId);return b==null?null:[t.xOf(g.time),b]},a=s(n),l=s(i),c=s(o);if(!a||!l||!c)return null;let d=(l[0]+c[0])/2,u=(l[1]+c[1])/2,h=d-a[0],p=u-a[1],m=t.width,f=t.height;return {segments:[se(a[0],a[1],d,u,"right",m,f),se(l[0],l[1],l[0]+h,l[1]+p,"right",m,f),se(c[0],c[1],c[0]+h,c[1]+p,"right",m,f),[l[0],l[1],c[0],c[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F,...N]}}};var lr=class extends te{anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(e){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n||!i)return null;let o=f=>{let g=e.yOf(f.price,this.paneId);return g==null?null:[e.xOf(f.time),g]},s=o(this.medianStart(t,n,i)),a=o(n),l=o(i);if(!s||!a||!l)return null;let c=(a[0]+l[0])/2,d=(a[1]+l[1])/2,u=c-s[0],h=d-s[1],p=e.width,m=e.height;return {segments:[se(s[0],s[1],c,d,"right",p,m),se(a[0],a[1],a[0]+u,a[1]+h,"right",p,m),se(l[0],l[1],l[0]+u,l[1]+h,"right",p,m),[a[0],a[1],l[0],l[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}schema(){return {fields:[...F,...N]}}};var gs=class extends lr{constructor(){super(...arguments);this.type="schiffpitchfork";}medianStart(t,n){return {time:t.time,price:(t.price+n.price)/2}}};var bs=class extends lr{constructor(){super(...arguments);this.type="modifiedschiffpitchfork";}medianStart(t,n){return {time:(t.time+n.time)/2,price:(t.price+n.price)/2}}};var vs=class extends te{constructor(){super(...arguments);this.type="insidepitchfork";}anchorSchema(){return {min:3,max:3,slots:[{role:"pivot",free:"both"},{role:"upper",free:"both"},{role:"lower",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=b=>{let y=t.yOf(b.price,this.paneId);return y==null?null:[t.xOf(b.time),y]},a=s({time:(n.time+i.time)/2,price:(n.price+i.price)/2}),l=s(n),c=s(i),d=s(o);if(!a||!l||!c||!d)return null;let u=(c[0]+d[0])/2,h=(c[1]+d[1])/2,p=d[0]-a[0],m=d[1]-a[1],f=t.width,g=t.height;return {segments:[se(u,h,u+p,h+m,"right",f,g),se(c[0],c[1],c[0]+p,c[1]+m,"right",f,g),se(d[0],d[1],d[0]+p,d[1]+m,"right",f,g),[c[0],c[1],d[0],d[1]],[a[0],a[1],d[0],d[1]],[l[0],l[1],c[0],c[1]]],fill:null}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F,...N]}}};var ys=class extends _{constructor(){super(...arguments);this.type="arrow";}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}pixels(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:[t.xOf(n.time),o,t.xOf(i.time),s]}hitTest(t,n,i,o){let s=this.pixels(i);return s!=null&&U(t,n,s[0],s[1],s[2],s[3])<=o}handlePoints(t){let n=this.pixels(t);return n?[[n[0],n[1]],[n[2],n[3]]]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.pixels(t);return n?{x:Math.min(n[0],n[2]),y:Math.min(n[1],n[3]),w:Math.abs(n[2]-n[0]),h:Math.abs(n[3]-n[1])}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,{path:"style.arrowRight",label:"Head (end)",kind:"boolean",group:"line"},{path:"style.arrowLeft",label:"Head (start)",kind:"boolean",group:"line"},...N]}}};var Xh=48,ws=class extends _{constructor(){super(...arguments);this.type="ellipse";}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}oval(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:(a+l)/2,cy:(o+s)/2,rx:Math.abs(l-a)/2,ry:Math.abs(s-o)/2}}perimeter(t){let n=[];for(let i=0;i<=Xh;i+=1){let o=i/Xh*Math.PI*2;n.push([t.cx+t.rx*Math.cos(o),t.cy+t.ry*Math.sin(o)]);}return n}hitTest(t,n,i,o){let s=this.oval(i);if(!s||s.rx<1||s.ry<1)return false;let a=((t-s.cx)/s.rx)**2+((n-s.cy)/s.ry)**2;return this.style.fillColor&&a<=1?true:ar(t,n,this.perimeter(s))<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.oval(t);return n?{x:n.cx-n.rx,y:n.cy-n.ry,w:n.rx*2,h:n.ry*2}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,...ee,...N]}}};var xs=class extends te{constructor(){super(...arguments);this.type="triangle";}anchorSchema(){return {min:3,max:3,slots:[{role:"v1",free:"both"},{role:"v2",free:"both"},{role:"v3",free:"both"}]}}geometry(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=d=>{let u=t.yOf(d.price,this.paneId);return u==null?null:[t.xOf(d.time),u]},a=s(n),l=s(i),c=s(o);return !a||!l||!c?null:{segments:[[a[0],a[1],l[0],l[1]],[l[0],l[1],c[0],c[1]],[c[0],c[1],a[0],a[1]]],fill:[a,l,c]}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F,...ee,...N]}}};var Dw=512,Jt=class extends te{anchorSchema(){return {min:2,max:Dw,slots:[]}}geometry(e){let t=[];for(let i of this.anchors){let o=e.yOf(i.price,this.paneId);if(o==null)return null;t.push([e.xOf(i.time),o]);}if(t.length<2)return null;let n=[];for(let i=1;i<t.length;i+=1)n.push([t[i-1][0],t[i-1][1],t[i][0],t[i][1]]);return {segments:n,fill:null}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}schema(){return {fields:[...F,...N]}}};var Ss=class extends Jt{constructor(){super(...arguments);this.type="polyline";}};var hi=class extends Jt{placementMode(){return "freehand"}handlePoints(e){return []}bounds(e){let t=[],n=[];for(let s of this.anchors){let a=e.yOf(s.price,this.paneId);a!=null&&(t.push(e.xOf(s.time)),n.push(a));}if(t.length===0)return null;let i=Math.min(...t),o=Math.min(...n);return {x:i,y:o,w:Math.max(...t)-i,h:Math.max(...n)-o}}},Cs=class extends hi{constructor(){super(...arguments);this.type="freehand";}};var Ow=[{path:"style.lineColor",label:"Color",kind:"color",group:"line"},{path:"style.lineWidth",label:"Width",kind:"number",min:4,max:60,step:1,group:"line"}],Ts=class extends hi{constructor(){super(...arguments);this.type="highlighter";}schema(){return {fields:Ow}}};var Es=class extends _{constructor(){super(...arguments);this.type="circle";}anchorSchema(){return {min:2,max:2,slots:[{role:"center",free:"both"},{role:"edge",free:"both"}]}}geom(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:a,cy:o,r:Math.hypot(l-a,s-o)}}hitTest(t,n,i,o){let s=this.geom(i);if(!s||s.r<1)return false;let a=Math.hypot(t-s.cx,n-s.cy);return this.style.fillColor&&a<=s.r?true:Math.abs(a-s.r)<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.geom(t);return n?{x:n.cx-n.r,y:n.cy-n.r,w:n.r*2,h:n.r*2}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,...ee,...N]}}};var Ps=class extends te{constructor(){super(...arguments);this.type="rotatedrect";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"w",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.px(t,2);if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=i[0]-n[0],a=i[1]-n[1],l=Math.hypot(s,a);if(l<1e-6)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let c=-a/l,d=s/l,u=(o[0]-n[0])*c+(o[1]-n[1])*d,h=c*u,p=d*u,m=n,f=i,g=[i[0]+h,i[1]+p],b=[n[0]+h,n[1]+p];return {segments:[[m[0],m[1],f[0],f[1]],[f[0],f[1],g[0],g[1]],[g[0],g[1],b[0],b[1]],[b[0],b[1],m[0],m[1]]],fill:[m,f,g,b]}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),...ee,...N]}}};var Ls=class extends Jt{constructor(){super(...arguments);this.type="path";}};var jh=40,Ms=class extends te{constructor(){super(...arguments);this.type="arc";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"apex",free:"both"}]}}pinApex(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];t&&n&&i&&(i.time=(t.time+n.time)/2);}onPlaced(){this.pinApex();}constrainHandleDrag(){this.pinApex();}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.anchors[2];if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=t.yOf(o.price,this.paneId);if(s==null)return null;let a=(n[0]+i[0])/2,l=(n[1]+i[1])/2,c=(i[0]-n[0])/2,d=(i[1]-n[1])/2,u=Math.hypot(c,d);if(u<1e-6)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let h=-d/u,p=c/u,m=(s-l)*p;m<0&&(h=-h,p=-p);let f=Math.abs(m),g=[];for(let y=0;y<=jh;y+=1){let v=y/jh*Math.PI,w=Math.cos(v),E=Math.sin(v);g.push([a+w*c+E*f*h,l+w*d+E*f*p]);}let b=[];for(let y=1;y<g.length;y+=1)b.push([g[y-1][0],g[y-1][1],g[y][0],g[y][1]]);return b.push([g[g.length-1][0],g[g.length-1][1],g[0][0],g[0][1]]),{segments:b,fill:g}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F.map(t=>({...t,label:t.label.replace("Line","Border")})),...ee,...N]}}};var qh=40,ks=class extends te{constructor(){super(...arguments);this.type="curve";}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"control",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}geometry(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return null;let o=this.px(t,2);if(!o||this.anchors.length<3)return {segments:[[n[0],n[1],i[0],i[1]]],fill:null};let s=[];for(let l=0;l<=qh;l+=1){let c=l/qh,d=1-c;s.push([d*d*n[0]+2*d*c*o[0]+c*c*i[0],d*d*n[1]+2*d*c*o[1]+c*c*i[1]]);}let a=[];for(let l=1;l<s.length;l+=1)a.push([s[l-1][0],s[l-1][1],s[l][0],s[l][1]]);return {segments:a,fill:s}}priceRange(){if(this.anchors.length===0)return null;let t=this.anchors.map(n=>n.price);return {min:Math.min(...t),max:Math.max(...t)}}schema(){return {fields:[...F,...ee,...N]}}};var Fw={head:11,headW:9,stemW:3.5,len:22},En=class extends _{anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}glyphPoints(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);if(n==null)return null;let i=e.xOf(t.time),{head:o,headW:s,stemW:a,len:l}=Fw,c=[[0,0],[-s,o],[-a,o],[-a,l],[a,l],[a,o],[s,o]],d=this.dir(),u=([h,p])=>{switch(d){case "up":return [h,p];case "down":return [h,-p];case "left":return [p,h];default:return [-p,h]}};return c.map(h=>{let[p,m]=u(h);return [i+p,n+m]})}hitTest(e,t,n,i){let o=this.glyphPoints(n);return o!=null&&ct(e,t,o)}handlePoints(e){let t=this.anchors[0];if(!t)return [];let n=e.yOf(t.price,this.paneId);return n==null?[]:[[e.xOf(t.time),n]]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.glyphPoints(e);if(!t)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}schema(){return {fields:[{path:"style.lineColor",label:"Color",kind:"color",group:"line"},...N]}}},pi=class extends En{constructor(){super(...arguments);this.type="arrowmarkup";}dir(){return "up"}},mi=class extends En{constructor(){super(...arguments);this.type="arrowmarkdown";}dir(){return "down"}};var bi=["\u2605","\u2606","\u25CF","\u25C6","\u25B2","\u25BC","\u27A4","\u2691","\u271A","\u2715","\u2764","\u2666"],Is=["small","normal","large","huge"],Zh={small:16,normal:22,large:32,huge:44},Pn=class extends _{constructor(e){super(e),this.glyph||(this.glyph=this.defaultGlyph()),this.size||(this.size="normal");}sizePx(){return Zh[this.size]??Zh.normal}anchorSchema(){return {min:1,max:1,slots:[{role:"p",free:"both"}]}}center(e){let t=this.anchors[0];if(!t)return null;let n=e.yOf(t.price,this.paneId);return n==null?null:[e.xOf(t.time),n]}hitTest(e,t,n,i){let o=this.center(n);if(!o)return false;let s=this.sizePx()/2+i;return Math.abs(e-o[0])<=s&&Math.abs(t-o[1])<=s}handlePoints(e){let t=this.center(e);return t?[t]:[]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.center(e);if(!t)return null;let n=this.sizePx();return {x:t[0]-n/2,y:t[1]-n/2,w:n,h:n}}priceRange(){let e=this.anchors[0];return e?{min:e.price,max:e.price}:null}schema(){return {fields:[{path:"glyph",label:"Icon",kind:"select",options:bi.map(e=>({value:e,label:e})),group:"line"},{path:"size",label:"Size",kind:"select",options:Is.map(e=>({value:e,label:e})),group:"line"},{path:"style.lineColor",label:"Color",kind:"color",group:"line"},...N]}}writeProps(){return {glyph:this.glyph,size:this.size}}readProps(e){typeof e.glyph=="string"&&(this.glyph=e.glyph),typeof e.size=="string"&&(this.size=e.size);}},fi=class extends Pn{constructor(){super(...arguments);this.type="flagmark";}defaultGlyph(){return "\u2691"}},gi=class extends Pn{constructor(){super(...arguments);this.type="iconstamp";}defaultGlyph(){return "\u2605"}};var Jh=r=>r==="small"||r==="normal"||r==="large"||r==="huge";function Nw(r){if(!r||typeof r!="object")return null;let e=r;return typeof e.ratio!="number"||typeof e.color!="string"?null:{ratio:e.ratio,color:e.color,enabled:e.enabled!==false,...typeof e.label=="string"&&e.label?{label:e.label}:{}}}var re=class extends _{constructor(e){super(e),this.levels||(this.levels=this.defaultLevels().map(t=>({...t}))),this.numbersSize||(this.numbersSize="small"),this.labelsSize||(this.labelsSize="normal");}fillBands(e){return []}editableLevels(){return this.levels}anchorSchema(){return {min:2,max:2,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"}]}}hitTest(e,t,n,i){let o=this.entryLines(n);return o!=null&&o.some(s=>U(e,t,s.x1,s.y1,s.x2,s.y2)<=i)}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}schema(){return {fields:F.filter(e=>e.path!=="style.lineColor")}}writeProps(){return {levels:this.levels.map(e=>({...e})),numbersSize:this.numbersSize,labelsSize:this.labelsSize}}readProps(e){if(Array.isArray(e.levels)){let t=e.levels.map(Nw).filter(n=>n!=null);t.length&&(this.levels=t);}Jh(e.numbersSize)&&(this.numbersSize=e.numbersSize),Jh(e.labelsSize)&&(this.labelsSize=e.labelsSize);}};var cr=class extends re{levelLines(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.xOf(t.time),o=e.xOf(n.time),s=Math.min(i,o),a=Math.max(i,o),l=n.price-t.price,c=[];for(let d of this.levels){if(!d.enabled)continue;let u=t.price+d.ratio*l,h=e.yOf(u,this.paneId);h!=null&&c.push({ratio:d.ratio,color:d.color,label:d.label,price:u,x1:s,x2:a,y:h});}return c}entryLines(e){let t=this.levelLines(e);return t?t.map(n=>({color:n.color,label:n.label,x1:n.x1,y1:n.y,x2:n.x2,y2:n.y,numberText:`${n.ratio} (${n.price.toFixed(2)})`,numberX:n.x1+4,numberY:n.y-7,numberAlign:"left",labelX:(n.x1+n.x2)/2,labelY:n.y-7})):null}fillBands(e){let t=this.levelLines(e);if(!t)return [];let n=[];for(let i=1;i<t.length;i+=1){let o=t[i-1],s=t[i];n.push({color:s.color,x:o.x1,y:Math.min(o.y,s.y),w:o.x2-o.x1,h:Math.abs(s.y-o.y)});}return n}priceRange(){let e=this.anchors[0],t=this.anchors[1];if(!e||!t)return null;let n=t.price-e.price,i=this.levels.filter(o=>o.enabled).map(o=>e.price+o.ratio*n);return i.length===0?null:{min:Math.min(...i),max:Math.max(...i)}}};var Ln=Pe,ut=X,ht=vn,Mn="#4caf50",Qt=q,Ot=It,kn="#9c27b0",Vw="#e91e63",Sc="#26a69a",_w="#ab47bc",Bw="#ef5350",Qh="#ffb74d",Hw="#38c0fd",As="#b2b5be",dr=[Hw,Ot,Qt,Mn,ht,ut,Vw,kn,Ln,Sc,_w,Bw];function ep(r){return dr[(r%dr.length+dr.length)%dr.length]}var zw=[[0,Ln],[.125,ut],[.236,ut],[.25,ut],[.382,ht],[.5,Mn],[.618,Qt],[.75,Ot],[.786,Ot],[1,Ln],[1.272,Ot],[1.382,ht],[1.618,ut],[2,Ln],[2.382,ht],[2.618,ht],[3,Ln],[4.236,Mn],[6.854,Qt],[11.09,Ot]];function $w(r,e=0){return zw.find(([t])=>t===r)?.[1]??ep(e)}function ne(r){return r.map((e,t)=>{let n=typeof e=="number"?{ratio:e}:e;return {ratio:n.ratio,color:n.color??$w(n.ratio,t),enabled:n.enabled!==false,...n.label?{label:n.label}:{}}})}function tp(r,e=r){return Array.from({length:r},(t,n)=>({ratio:n+1,color:ep(n),enabled:n<e,label:String(n+1)}))}var Ww=ne([0,.236,.382,.5,.618,.786,1]),Rs=class extends cr{constructor(){super(...arguments);this.type="fibretracement";}defaultLevels(){return Ww}};var Gw=ne([0,.382,.618,1,1.272,1.618,{ratio:2.618,color:kn}]),Ds=class extends cr{constructor(){super(...arguments);this.type="fibextension";}defaultLevels(){return Gw}};var Uw=ne([0,.382,.5,.618,1,1.618,{ratio:2.618,color:kn}]),Os=class extends re{constructor(){super(...arguments);this.type="fibextensiontrend";}anchorSchema(){return {min:3,max:3,slots:[{role:"a",free:"both"},{role:"b",free:"both"},{role:"c",free:"both"}]}}defaultLevels(){return Uw}entryLines(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=i.price-n.price,a=[t.xOf(n.time),t.xOf(i.time),t.xOf(o.time)],l=Math.min(...a),c=Math.max(...a),d=[];for(let u of this.levels){if(!u.enabled)continue;let h=o.price+u.ratio*s,p=t.yOf(h,this.paneId);p!=null&&d.push({color:u.color,label:u.label,x1:l,y1:p,x2:c,y2:p,numberText:`${u.ratio} (${h.toFixed(2)})`,numberX:l+4,numberY:p-7,numberAlign:"left",labelX:(l+c)/2,labelY:p-7});}return d}priceRange(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n||!i)return null;let o=n.price-t.price,s=this.levels.filter(a=>a.enabled).map(a=>i.price+a.ratio*o);return s.push(t.price,n.price,i.price),{min:Math.min(...s),max:Math.max(...s)}}};var Yw=ne([.236,.382,.5,.618,.786,1]),Fs=class extends re{constructor(){super(...arguments);this.type="fibfan";}defaultLevels(){return Yw}fanLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.yOf(n.price,this.paneId);if(s==null)return null;let a=t.xOf(i.time),l=i.price-n.price,c=[];for(let d of this.levels){if(!d.enabled)continue;let u=t.yOf(n.price+d.ratio*l,this.paneId);if(u==null)continue;let[h,p,m,f]=se(o,s,a,u,"right",t.width,t.height);c.push({ratio:d.ratio,color:d.color,label:d.label,x1:h,y1:p,x2:m,y2:f,labelX:a+5,labelY:u});}return c}entryLines(t){let n=this.fanLines(t);return n?n.map(i=>({color:i.color,label:i.label,x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,numberText:String(i.ratio),numberX:i.labelX,numberY:i.labelY,numberAlign:"left",labelX:i.labelX,labelY:i.labelY+13})):null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var Kw=[0,1,2,3,5,8,13,21,34].map(r=>({ratio:r,color:R,enabled:true})),Ns=class extends re{constructor(){super(...arguments);this.type="fibtimezones";}defaultLevels(){return Kw}zoneLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=i.time-n.time;if(Math.abs(o)<1e-9)return null;let s=[];for(let a of this.levels)a.enabled&&s.push({n:a.ratio,color:a.color,label:a.label,x:t.xOf(n.time+a.ratio*o)});return s}entryLines(t){let n=this.zoneLines(t);if(!n)return null;let i=t.height;return n.map(o=>({color:o.color,label:o.label,x1:o.x,y1:0,x2:o.x,y2:i,numberText:String(o.n),numberX:o.x,numberY:9,numberAlign:"center",labelX:o.x,labelY:24}))}priceRange(){return null}timeExtent(){return null}};var Xw=ne([0,.236,.382,.5,.618,.786,1,1.618,2.618]),Vs=class extends re{constructor(){super(...arguments);this.type="fibchannel";}defaultLevels(){return Xw}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"offset",free:"both"}]}}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time),c=0,d=0,u=this.anchors[2];if(u){let p=t.yOf(u.price,this.paneId);if(p==null)return null;c=t.xOf(u.time)-a,d=p-o;}let h=[];for(let p of this.levels){if(!p.enabled)continue;let m=p.ratio*c,f=p.ratio*d,g=l+m,b=s+f;h.push({color:p.color,label:p.label,x1:a+m,y1:o+f,x2:g,y2:b,numberText:String(p.ratio),numberX:g+5,numberY:b,numberAlign:"left",labelX:g+5,labelY:b+13});}return h}priceRange(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[2];if(!t||!n)return null;let o=i?i.price-t.price:0,s=1/0,a=-1/0;for(let l of this.levels)if(l.enabled)for(let c of [t.price,n.price]){let d=c+l.ratio*o;d<s&&(s=d),d>a&&(a=d);}return s<=a?{min:s,max:a}:null}};var jw=ne([0,.236,.382,.5,.618,.786,1]),_s=class extends re{constructor(){super(...arguments);this.type="fibspeedfan";}defaultLevels(){return jw}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),c=t.xOf(i.time)-a,d=s-o,u=c>=0?"right":"left",h=t.width,p=t.height,m=[];for(let f of this.levels){if(!f.enabled)continue;let g=a+c,b=o+d*f.ratio,y=se(a,o,g,b,u,h,p);if(m.push({color:f.color,label:f.label,x1:y[0],y1:y[1],x2:y[2],y2:y[3],numberText:String(f.ratio),numberX:u==="right"?g+5:g-5,numberY:b,numberAlign:u==="right"?"left":"right",labelX:g,labelY:b}),f.ratio===1)continue;let v=a+c*f.ratio,w=o+d,E=se(a,o,v,w,u,h,p);m.push({color:f.color,label:f.label,x1:E[0],y1:E[1],x2:E[2],y2:E[3],numberText:String(f.ratio),numberX:v,numberY:w+(d>=0?12:-12),numberAlign:"center",labelX:v,labelY:w+12});}return m}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var qw=ne([0,.382,{ratio:.5,enabled:false},.618,1,1.382,1.618,2,2.382,2.618,3]),Bs=class extends re{constructor(){super(...arguments);this.type="trendfibtime";}defaultLevels(){return qw}anchorSchema(){return {min:3,max:3,slots:[{role:"p1",free:"both"},{role:"p2",free:"both"},{role:"p3",free:"both"}]}}entryLines(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return null;let s=i.time-n.time;if(Math.abs(s)<1e-9)return null;let a=t.height,l=[];for(let c of this.levels){if(!c.enabled)continue;let d=t.xOf(o.time+c.ratio*s);l.push({color:c.color,label:c.label,x1:d,y1:0,x2:d,y2:a,numberText:String(c.ratio),numberX:d,numberY:9,numberAlign:"center",labelX:d,labelY:24});}return l}priceRange(){return null}timeExtent(){return null}};function Zw(r,e,t){if(t-e>=Math.PI*2-.001)return true;let n=r-e,i=Math.PI*2;for(;n<0;)n+=i;for(;n>=i;)n-=i;return n<=t-e+1e-6}var Je=class extends re{boundingLines(e){return []}entryLines(e){return []}hitTest(e,t,n,i){let o=this.radial(n);if(o){let s=Math.hypot(e-o.cx,t-o.cy),a=Math.atan2(t-o.cy,e-o.cx);if(Zw(a,o.a0,o.a1)){for(let l of this.levels)if(l.enabled&&Math.abs(s-o.R0*l.ratio)<=i)return true}}return this.boundingLines(n).some(s=>U(e,t,s[0],s[1],s[2],s[3])<=i)}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}};var Jw=ne([.236,.382,.5,.618,.786,1,1.618,2.618]),Hs=class extends Je{constructor(){super(...arguments);this.type="fibcircles";}defaultLevels(){return Jw}radial(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {cx:a,cy:o,R0:Math.hypot(l-a,s-o),a0:0,a1:Math.PI*2}}};var Qw=ne([.236,.382,.5,.618,.786,1,1.618,2.618]),zs=class extends Je{constructor(){super(...arguments);this.type="fibarcs";}defaultLevels(){return Qw}pts(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{cx:t.xOf(n.time),cy:o,ex:t.xOf(i.time),ey:s}}radial(t){let n=this.pts(t);if(!n)return null;let i=Math.hypot(n.ex-n.cx,n.ey-n.cy),o=Math.atan2(n.ey-n.cy,n.ex-n.cx);return {cx:n.cx,cy:n.cy,R0:i,a0:o-Math.PI/2,a1:o+Math.PI/2}}boundingLines(t){let n=this.pts(t);return n?[[n.cx,n.cy,n.ex,n.ey]]:[]}};var ex=ne([.236,.382,.5,.618,.786,1]),$s=class extends Je{constructor(){super(...arguments);this.type="fibwedge";}defaultLevels(){return ex}anchorSchema(){return {min:3,max:3,slots:[{role:"apex",free:"both"},{role:"radius",free:"both"},{role:"angle",free:"both"}]}}px(t,n){let i=this.anchors[n];if(!i)return null;let o=t.yOf(i.price,this.paneId);return o==null?null:[t.xOf(i.time),o]}radial(t){let n=this.px(t,0),i=this.px(t,1),o=this.px(t,2);if(!n||!i||!o)return null;let s=Math.hypot(i[0]-n[0],i[1]-n[1]);if(s<1)return null;let a=Math.atan2(i[1]-n[1],i[0]-n[0]),l=Math.atan2(o[1]-n[1],o[0]-n[0]),c=Math.min(a,l),d=Math.max(a,l);return d-c>Math.PI&&([c,d]=[d,c+Math.PI*2]),{cx:n[0],cy:n[1],R0:s,a0:c,a1:d}}boundingLines(t){let n=this.px(t,0),i=this.px(t,1);if(!n||!i)return [];let o=[[n[0],n[1],i[0],i[1]]],s=this.px(t,2);if(s){let a=Math.hypot(i[0]-n[0],i[1]-n[1]),l=Math.hypot(s[0]-n[0],s[1]-n[1]);l>1e-6&&o.push([n[0],n[1],n[0]+(s[0]-n[0])/l*a,n[1]+(s[1]-n[1])/l*a]);}return o}};var tx=1.6180339887,np=Math.log(tx)/(Math.PI/2),nx=Math.PI/64,rx=Math.PI,ix=.5,In=class extends _{constructor(){super(...arguments);this.type="fibspiral";}anchorSchema(){return {min:2,max:2,slots:[{role:"center",free:"both"},{role:"edge",free:"both"}]}}spiralPoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time),c=Math.hypot(l-a,s-o);if(c<1)return null;let d=Math.atan2(s-o,l-a),u=Math.max(Math.log(ix/c)/np,-8*Math.PI*2),h=[];for(let p=u;p<=rx;p+=nx){let m=c*Math.exp(np*p),f=d+p;h.push([a+m*Math.cos(f),o+m*Math.sin(f)]);}return h}hitTest(t,n,i,o){let s=this.spiralPoints(i);return s!=null&&s.length>=2&&ar(t,n,s)<=o}handlePoints(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return [];let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?[]:[[t.xOf(n.time),o],[t.xOf(i.time),s]]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.handlePoints(t);if(n.length<2)return null;let i=n.map(l=>l[0]),o=n.map(l=>l[1]),s=Math.min(...i),a=Math.min(...o);return {x:s,y:a,w:Math.max(...i)-s,h:Math.max(...o)-a}}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,...N]}}};var ox=ne([{ratio:.125,color:ut,label:"1/8"},{ratio:.25,color:ht,label:"1/4"},{ratio:.333,color:Qh,label:"1/3"},{ratio:.5,color:Mn,label:"1/2"},{ratio:1,color:As,label:"1/1"},{ratio:2,color:Qt,label:"2/1"},{ratio:3,color:Ot,label:"3/1"},{ratio:4,color:Sc,label:"4/1"},{ratio:8,color:kn,label:"8/1"}]),Ws=class extends re{constructor(){super(...arguments);this.type="gannfan";}defaultLevels(){return ox}entryLines(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.yOf(n.price,this.paneId);if(s==null)return null;let a=t.xOf(i.time),l=i.price-n.price,c=[];for(let d of this.levels){if(!d.enabled)continue;let u=t.yOf(n.price+l*d.ratio,this.paneId);if(u==null)continue;let[h,p,m,f]=se(o,s,a,u,"right",t.width,t.height);c.push({color:d.color,x1:h,y1:p,x2:m,y2:f,numberText:d.label??String(d.ratio),numberX:a+5,numberY:u,numberAlign:"left",labelX:a+5,labelY:u});}return c}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var sx=ne([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),Gs=class extends re{constructor(){super(...arguments);this.type="gannbox";}defaultLevels(){return sx}corners(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.xOf(n.time),s=t.xOf(i.time),a=t.yOf(n.price,this.paneId),l=t.yOf(i.price,this.paneId);return a==null||l==null?null:{c1:n,c2:i,left:Math.min(o,s),right:Math.max(o,s),top:Math.min(a,l),bot:Math.max(a,l)}}entryLines(t){let n=this.corners(t);if(!n)return null;let{c1:i,c2:o,left:s,right:a,top:l,bot:c}=n,d=[];for(let h of this.levels){if(!h.enabled)continue;let p=t.yOf(i.price+h.ratio*(o.price-i.price),this.paneId);p!=null&&d.push({color:h.color,x1:s,y1:p,x2:a,y2:p,numberText:h.label??String(h.ratio),numberX:s-5,numberY:p,numberAlign:"right",labelX:s,labelY:p});let m=t.xOf(i.time+h.ratio*(o.time-i.time));d.push({color:h.color,x1:m,y1:l,x2:m,y2:c,numberText:"",numberX:m,numberY:l,numberAlign:"center",labelX:m,labelY:l});}let u=this.levels.find(h=>h.ratio===1)?.color??Ln;return d.push({color:u,x1:s,y1:l,x2:a,y2:c,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),d.push({color:u,x1:s,y1:c,x2:a,y2:l,numberText:"",numberX:0,numberY:0,numberAlign:"left",labelX:0,labelY:0}),d}hitTest(t,n,i,o){let s=this.corners(i);return s!=null&&ye(t,n,s.left,s.top,s.right,s.bot,o)}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var ax=ne([0,.25,.382,.5,.618,.75,1].map(r=>({ratio:r,label:String(r)}))),lx=[{label:"3x1",x:3,y:1,color:ut},{label:"2x1",x:2,y:1,color:ht},{label:"1x1",x:1,y:1,color:As},{label:"1x2",x:1,y:2,color:Qt},{label:"1x3",x:1,y:3,color:Ot}],Cc=[{k:.25,color:ut},{k:.5,color:ht},{k:.75,color:Mn},{k:1,color:Qt}],An=class extends re{constructor(){super(...arguments);this.type="gannsquare";}defaultLevels(){return ax}box(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=t.xOf(n.time),l=t.xOf(i.time);return {ox:a,oy:o,bx:l-a,py:s-o,left:Math.min(a,l),top:Math.min(o,s),right:Math.max(a,l),bot:Math.max(o,s)}}arcGeom(t){let n=this.box(t);return n?{ox:n.ox,oy:n.oy,bx:n.bx,py:n.py}:null}entryLines(t){let n=this.box(t);if(!n)return null;let i=this.anchors[0],o=this.anchors[1],s=[];for(let a of this.levels){if(!a.enabled)continue;let l=t.yOf(i.price+a.ratio*(o.price-i.price),this.paneId);l!=null&&s.push({color:a.color,x1:n.left,y1:l,x2:n.right,y2:l,numberText:a.label??String(a.ratio),numberX:n.left-5,numberY:l,numberAlign:"right",labelX:n.left,labelY:l});let c=t.xOf(i.time+a.ratio*(o.time-i.time));s.push({color:a.color,x1:c,y1:n.top,x2:c,y2:n.bot,numberText:"",numberX:c,numberY:n.top,numberAlign:"center",labelX:c,labelY:n.top});}for(let a of lx){let l,c;a.x>a.y?(l=n.ox+n.bx,c=n.oy+a.y/a.x*n.py):(c=n.oy+n.py,l=n.ox+a.x/a.y*n.bx),s.push({color:a.color,x1:n.ox,y1:n.oy,x2:l,y2:c,numberText:a.label,numberX:l+4,numberY:c,numberAlign:"left",labelX:l+4,labelY:c});}return s}hitTest(t,n,i,o){let s=this.box(i);return s!=null&&ye(t,n,s.left,s.top,s.right,s.bot,o)}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}};var Tc=[4,8,12,16,24,32,48,64],cx=24,dx=.75;function rp(r,e){if(!Number.isInteger(r)||!Number.isInteger(e)||e<=0)return false;let t=r*r-1;return e%2===1?t%e===0:e%8===0?t%e!==0?false:t/e%2!==0:false}function ip(r){let e=[];for(let t=0;t<r;t+=1)rp(t,r)&&e.push(t);return e}var Rn=class extends _{constructor(t){super(t);this.type="dedekind";this.maxCurvature===void 0&&(this.maxCurvature=cx);}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}box(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);if(o==null||s==null)return null;let a=Math.min(t.xOf(n.time),t.xOf(i.time)),l=Math.max(t.xOf(n.time),t.xOf(i.time)),c=Math.min(o,s),d=Math.max(o,s),u=l-a,h=d-c;if(u<1||h<1)return null;let p=h,m=u/p;return {left:a,right:l,top:c,bot:d,unitPx:p,x0:0,realSpan:m}}geodesics(t){let n=this.box(t);if(!n)return null;let{left:i,top:o,bot:s,unitPx:a,x0:l,realSpan:c}=n,d=Math.max(1,Math.min(64,Math.round(this.maxCurvature))),u=l-1/d,h=l+c+1/d,p=i+c*a,m=[],f=Math.floor(u*2),g=Math.ceil(h*2);for(let b=f;b<=g;b+=1){if(b%2===0)continue;let y=i+(b/2-l)*a;y<i-.5||y>p+.5||m.push({kind:"vline",x:y,y0:s,y1:o});}for(let b=1;b<=d;b+=1){let y=1/b,v=y*a;if(v<dx)continue;let w=ip(b);if(w.length===0)continue;let E=Math.floor(u)-1,x=Math.ceil(h)+1;for(let S=E;S<=x;S+=1)for(let P of w){let k=P/b+S;if(k+y<u||k-y>h)continue;let T=i+(k-l)*a;T+v<i-1||T-v>p+1||m.push({kind:"arc",cx:T,cy:s,r:v});}}return m}hitTest(t,n,i,o){let s=this.box(i);return s!=null&&ye(t,n,s.left,s.top,s.right,s.bot,o)}handlePoints(t){let n=this.box(t);return n?[[n.left,n.top],[n.right,n.bot]]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.box(t);return n?{x:n.left,y:n.top,w:n.right-n.left,h:n.bot-n.top}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[...F,{path:"maxCurvature",label:"Max curvature",kind:"number",min:4,max:64,step:4,group:"behavior"},...N]}}writeProps(){return {maxCurvature:this.maxCurvature}}readProps(t){typeof t.maxCurvature=="number"&&Number.isFinite(t.maxCurvature)&&(this.maxCurvature=Math.max(1,Math.min(64,Math.round(t.maxCurvature))));}};var Ec=[3,4,5,6,8,10,12],Pc=[1.5,2,2.5,3,4,5],Us=6,ux=2;function Lc(r=Us){return [...tp(dr.length,r)]}function hx(r){if(!r||typeof r!="object")return null;let e=r;return typeof e.ratio!="number"||typeof e.color!="string"?null:{ratio:e.ratio,color:e.color,enabled:e.enabled!==false,...typeof e.label=="string"&&e.label?{label:e.label}:{}}}var ur={path:"showRatios",label:"Show ratios",kind:"boolean",group:"behavior"},De=class extends _{constructor(e){super(e),this.waveCount===void 0&&(this.waveCount=Us),this.showRatios===void 0&&(this.showRatios=true);let t=Array.isArray(e.props?.levels);this.levels||(this.levels=this.defaultLevels().map(n=>({...n}))),!t&&this.shouldSyncWaveCount()&&this.syncLevelsToWaveCount();}shouldSyncWaveCount(){return true}syncLevelsToWaveCount(){let e=Math.max(1,Math.min(this.levels.length,Math.round(this.waveCount)));this.waveCount=e;for(let t=0;t<this.levels.length;t+=1)this.levels[t].enabled=t<e;}editableLevels(){return this.levels}anchorSchema(){return {min:2,max:2,slots:[{role:"d1",free:"both"},{role:"d2",free:"both"}]}}geom(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);if(i==null||o==null)return null;let s=e.xOf(t.time),a=e.xOf(n.time),l=(s+a)/2,c=(i+o)/2,d=Math.hypot(a-s,o-i)/2;if(d<1)return null;let u=a-s,h=o-i,p=Math.hypot(u,h);p<1e-9?(u=1,h=0):(u/=p,h/=p);let m=this.levels.filter(x=>x.enabled&&x.ratio>0).slice().sort((x,S)=>x.ratio-S.ratio);if(m.length===0)return null;let f=Math.max(1,this.machNumber()),g=[];for(let x of m){let S=x.ratio*d;g.push({cx:l+f*(S-d)*u,cy:c+f*(S-d)*h,r:S,color:x.color,ratio:x.ratio});}let b=l-f*d*u,y=c-f*d*h,v=g[g.length-1].r,w=f*v+2*d,E=[];if(f<=1+1e-9){let x=-h,S=u;E.push([b-x*w,y-S*w,b+x*w,y+S*w]);}else {let x=Math.asin(1/f),S=Math.cos(x),P=Math.sin(x),k=(I,V,Y)=>[I*S-V*Y*P,I*Y*P+V*S],[T,M]=k(u,h,1),[L,C]=k(u,h,-1);E.push([b,y,b+T*w,y+M*w]),E.push([b,y,b+L*w,y+C*w]);}return {c0x:l,c0y:c,R:d,fx:u,fy:h,noseX:b,noseY:y,circles:g,rays:E}}hitTest(e,t,n,i){let o=this.geom(n);if(!o)return false;for(let s of o.circles)if(Math.abs(Math.hypot(e-s.cx,t-s.cy)-s.r)<=i)return true;return o.rays.some(s=>U(e,t,s[0],s[1],s[2],s[3])<=i)}handlePoints(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return [];let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?[]:[[e.xOf(t.time),i],[e.xOf(n.time),o]]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.geom(e);if(!t)return null;let n=t.noseX,i=t.noseX,o=t.noseY,s=t.noseY;for(let a of t.circles)n=Math.min(n,a.cx-a.r),i=Math.max(i,a.cx+a.r),o=Math.min(o,a.cy-a.r),s=Math.max(s,a.cy+a.r);for(let a of t.rays)n=Math.min(n,a[0],a[2]),i=Math.max(i,a[0],a[2]),o=Math.min(o,a[1],a[3]),s=Math.max(s,a[1],a[3]);return {x:n,y:o,w:i-n,h:s-o}}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}applySettings(e){if(super.applySettings(e),Object.prototype.hasOwnProperty.call(e,"waveCount")&&typeof this.waveCount=="number"){let t=Math.max(1,Math.min(this.levels.length,Math.round(this.waveCount)));this.waveCount=t;for(let n=0;n<this.levels.length;n+=1)this.levels[n].enabled=n<t;}}schema(){return {fields:[...F,{path:"waveCount",label:"Waves",kind:"number",min:3,max:12,step:1,group:"behavior"},ur,...N]}}writeProps(){return {waveCount:this.waveCount,showRatios:this.showRatios,levels:this.levels.map(e=>({...e}))}}readProps(e){if(typeof e.waveCount=="number"&&Number.isFinite(e.waveCount)&&(this.waveCount=Math.max(2,Math.min(12,Math.round(e.waveCount)))),typeof e.showRatios=="boolean"&&(this.showRatios=e.showRatios),Array.isArray(e.levels)){let t=e.levels.map(hx).filter(n=>n!=null);t.length&&(this.levels=t);}}},vi=class extends De{constructor(){super(...arguments);this.type="sonic";}defaultLevels(){return Lc(Us)}machNumber(){return 1}},yi=class extends De{constructor(t){super(t);this.type="supersonic";this.mach===void 0&&(this.mach=ux);}defaultLevels(){return Lc(Us)}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...F,{path:"mach",label:"Mach number",kind:"number",min:1.5,max:5,step:.5,group:"behavior"},{path:"waveCount",label:"Waves",kind:"number",min:3,max:12,step:1,group:"behavior"},ur,...N]}}writeProps(){return {...super.writeProps(),mach:this.mach}}readProps(t){super.readProps(t),typeof t.mach=="number"&&Number.isFinite(t.mach)&&(this.mach=Math.max(1.01,Math.min(20,t.mach)));}};var op=ne([.236,.382,.5,.618,.786,1,1.618,2.618,4.236,6.854,11.09]),px=2,Ys=class extends De{constructor(){super(...arguments);this.type="goldensonic";}shouldSyncWaveCount(){return false}defaultLevels(){return op}machNumber(){return 1}schema(){return {fields:[...F,ur,...N]}}},Ks=class extends De{constructor(t){super(t);this.type="goldensupersonic";this.mach===void 0&&(this.mach=px);}shouldSyncWaveCount(){return false}defaultLevels(){return op}machNumber(){return Math.max(1.01,this.mach)}schema(){return {fields:[...F,{path:"mach",label:"Mach number",kind:"number",min:1.5,max:5,step:.5,group:"behavior"},ur,...N]}}writeProps(){return {...super.writeProps(),mach:this.mach}}readProps(t){super.readProps(t),typeof t.mach=="number"&&Number.isFinite(t.mach)&&(this.mach=Math.max(1.01,Math.min(20,t.mach)));}};var be=class extends _{legRatios(){return false}fillTriangles(){return []}necklineIndices(){return null}anchorSchema(){let e=this.vertexLabels().length,t=[];for(let n=0;n<e;n+=1)t.push({role:`p${n}`,free:"both"});return {min:e,max:e,slots:t}}handlePoints(e){let t=[];for(let n of this.anchors){let i=e.yOf(n.price,this.paneId);if(i==null)return [];t.push([e.xOf(n.time),i]);}return t}hitTest(e,t,n,i){let o=this.handlePoints(n);return o.length>=2&&ar(e,t,o)<=i}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.handlePoints(e);if(t.length===0)return null;let n=t.map(a=>a[0]),i=t.map(a=>a[1]),o=Math.min(...n),s=Math.min(...i);return {x:o,y:s,w:Math.max(...n)-o,h:Math.max(...i)-s}}priceRange(){if(this.anchors.length===0)return null;let e=this.anchors.map(t=>t.price);return {min:Math.min(...e),max:Math.max(...e)}}patternName(){return null}ratioOk(e){return null}valid(){return null}ratioAt(e){let t=this.anchors[e-2],n=this.anchors[e-1],i=this.anchors[e];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-n.price)/o}schema(){return {fields:[...F,...this.fillTriangles().length?ee:[]]}}};var Xs=class extends be{constructor(){super(...arguments);this.type="xabcd";}vertexLabels(){return ["X","A","B","C","D"]}legRatios(){return true}fillTriangles(){return [[0,1,2],[2,3,4]]}};var js=class extends be{constructor(){super(...arguments);this.type="abcd";}vertexLabels(){return ["A","B","C","D"]}legRatios(){return true}};var qs=class extends be{constructor(){super(...arguments);this.type="elliottimpulse";}vertexLabels(){return ["1","2","3","4","5"]}};var Zs=class extends be{constructor(){super(...arguments);this.type="elliottcorrection";}vertexLabels(){return ["A","B","C"]}};var Js=class extends be{constructor(){super(...arguments);this.type="headshoulders";}vertexLabels(){return ["","LS","","H","","RS",""]}necklineIndices(){return [2,4]}};var Oe=class extends be{vertexLabels(){return ["X","A","B","C","D"]}legRatios(){return true}fillTriangles(){return [[0,1,2],[2,3,4]]}legValue(e){let[t,n,i,o,s]=this.anchors;if(!t||!n||!i||!o||!s)return null;let a=(u,h)=>Math.abs(h.price-u.price),l=a(t,n),c=a(n,i),d=a(i,o);switch(e){case "ab":return l<1e-9?null:c/l;case "bc":return c<1e-9?null:d/c;case "cd":return d<1e-9?null:a(o,s)/d;default:return l<1e-9?null:a(n,s)/l}}inBand(e,t){return e!=null&&e>=t.min&&e<=t.max}ratioOk(e){let t=this.ranges();return e===2?this.inBand(this.legValue("ab"),t.ab):e===3?this.inBand(this.legValue("bc"),t.bc):e===4?this.inBand(this.legValue("cd"),t.cd):null}valid(){if(this.anchors.length<5)return null;let e=this.ranges();return this.inBand(this.legValue("ab"),e.ab)&&this.inBand(this.legValue("bc"),e.bc)&&this.inBand(this.legValue("cd"),e.cd)&&this.inBand(this.legValue("ad"),e.ad)}};var Qs=class extends Oe{constructor(){super(...arguments);this.type="gartley";}patternName(){return "Gartley"}ranges(){return {ab:{min:.55,max:.68},bc:{min:.382,max:.886},cd:{min:1.13,max:1.618},ad:{min:.74,max:.83}}}};var ea=class extends Oe{constructor(){super(...arguments);this.type="bat";}patternName(){return "Bat"}ranges(){return {ab:{min:.382,max:.5},bc:{min:.382,max:.886},cd:{min:1.618,max:2.618},ad:{min:.84,max:.92}}}};var ta=class extends Oe{constructor(){super(...arguments);this.type="butterfly";}patternName(){return "Butterfly"}ranges(){return {ab:{min:.74,max:.83},bc:{min:.382,max:.886},cd:{min:1.618,max:2.618},ad:{min:1.272,max:1.618}}}};var na=class extends Oe{constructor(){super(...arguments);this.type="crab";}patternName(){return "Crab"}ranges(){return {ab:{min:.382,max:.618},bc:{min:.382,max:.886},cd:{min:2.618,max:3.618},ad:{min:1.55,max:1.69}}}};var ra=class extends Oe{constructor(){super(...arguments);this.type="shark";}patternName(){return "Shark"}ranges(){return {ab:{min:.382,max:.618},bc:{min:1.13,max:1.618},cd:{min:1.618,max:2.24},ad:{min:.886,max:1.13}}}};var mx={min:1.272,max:1.414},fx={min:.74,max:.83},ia=class extends Oe{constructor(){super(...arguments);this.type="cypher";}patternName(){return "Cypher"}ranges(){return {ab:{min:.382,max:.618},bc:{min:0,max:1/0},cd:{min:0,max:1/0},ad:{min:0,max:1/0}}}xcOverXa(){let t=this.anchors[0],n=this.anchors[1],i=this.anchors[3];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-t.price)/o}cdOverXc(){let t=this.anchors[0],n=this.anchors[3],i=this.anchors[4];if(!t||!n||!i)return null;let o=Math.abs(n.price-t.price);return o<1e-9?null:Math.abs(i.price-n.price)/o}ratioOk(t){return t===2?this.inBand(this.legValue("ab"),this.ranges().ab):null}valid(){return this.anchors.length<5?null:this.inBand(this.legValue("ab"),this.ranges().ab)&&this.inBand(this.xcOverXa(),mx)&&this.inBand(this.cdOverXc(),fx)}};function sp(r){return `${r>=0?"+":""}${r.toFixed(2)}`}function wi(r){let e=Math.abs(r),t=864e5,n=36e5,i=6e4;if(e>=t){let o=Math.floor(e/t),s=Math.round(e%t/n);return s?`${o}d ${s}h`:`${o}d`}if(e>=n){let o=Math.floor(e/n),s=Math.round(e%n/i);return s?`${o}h ${s}m`:`${o}h`}return e>=i?`${Math.round(e/i)}m`:`${Math.round(e/1e3)}s`}var Dn=class extends _{constructor(e){super(e),this.showPrice===void 0&&(this.showPrice=true),this.showDate===void 0&&(this.showDate=true);}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}measureLabel(e){let t=[];return this.showPrice&&t.push(this.priceLabel()),this.showDate&&t.push(this.timeLabel(e)),t}isUp(){let e=this.anchors[0],t=this.anchors[1];return e!=null&&t!=null&&t.price>=e.price}priceLabel(){let e=this.anchors[0],t=this.anchors[1];if(!e||!t)return "";let n=t.price-e.price,i=e.price!==0?n/e.price*100:0;return `${sp(n)} (${sp(i)}%)`}timeLabel(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return "";let i=wi(n.time-t.time),o=e.barsBetween?Math.round(e.barsBetween(t.time,n.time)):null;return o!=null?`${o} bars, ${i}`:i}rect(e){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;let i=e.yOf(t.price,this.paneId),o=e.yOf(n.price,this.paneId);return i==null||o==null?null:{x1:e.xOf(t.time),y1:i,x2:e.xOf(n.time),y2:o}}hitTest(e,t,n,i){let o=this.rect(n);return o!=null&&ye(e,t,o.x1,o.y1,o.x2,o.y2,i)}handlePoints(e){let t=this.rect(e);return t?[[t.x1,t.y1],[t.x2,t.y2]]:[]}hitHandle(e,t,n,i){return H(e,t,this.handlePoints(n),i+3)}bounds(e){let t=this.rect(e);return t?{x:Math.min(t.x1,t.x2),y:Math.min(t.y1,t.y2),w:Math.abs(t.x2-t.x1),h:Math.abs(t.y2-t.y1)}:null}priceRange(){let e=this.anchors[0],t=this.anchors[1];return !e||!t?null:{min:Math.min(e.price,t.price),max:Math.max(e.price,t.price)}}schema(){return {fields:[{path:"showPrice",label:"Show price",kind:"boolean",group:"behavior"},{path:"showDate",label:"Show date",kind:"boolean",group:"behavior"},...F.filter(e=>e.path!=="style.lineColor"),{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Ze,group:"text"}]}}writeProps(){return {showPrice:this.showPrice,showDate:this.showDate}}readProps(e){typeof e.showPrice=="boolean"&&(this.showPrice=e.showPrice),typeof e.showDate=="boolean"&&(this.showDate=e.showDate);}};var oa=class extends Dn{constructor(){super(...arguments);this.type="datepricerange";}};var sa=[{value:"long",label:"Long"},{value:"short",label:"Short"}],de=class de extends _{constructor(t){super(t);this.type="position";this.riskPercent===void 0&&(this.riskPercent=de.DEFAULT_RISK_PERCENT),this.accountBalance===void 0&&(this.accountBalance=de.DEFAULT_ACCOUNT_BALANCE),this.showText===void 0&&(this.showText=true),this.showHeader===void 0&&(this.showHeader=true),this.showPrices===void 0&&(this.showPrices=false),this.showLossSize===void 0&&(this.showLossSize=true),this.showTargetLabel===void 0&&(this.showTargetLabel=true),this.showStopLabel===void 0&&(this.showStopLabel=true),this.profitColor===void 0&&(this.profitColor=de.DEFAULT_PROFIT_COLOR),this.lossColor===void 0&&(this.lossColor=de.DEFAULT_LOSS_COLOR);}directionLabel(){let t=this.prices();return t&&t.target>=t.entry?"LONG":"SHORT"}get direction(){return this.directionLabel()==="LONG"?"long":"short"}set direction(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];!n||!i||!o||(t==="long"||t==="short")&&t!==this.direction&&(i.price=2*n.price-i.price,o.price=2*n.price-o.price);}get quantity(){return this.positionSize()}set quantity(t){let n=this.prices();if(!n||!Number.isFinite(t)||t<0)return;let i=Math.abs(n.entry-n.stop);i<1e-9||this.accountBalance<=0||(this.riskPercent=t*i/this.accountBalance*100);}get entryPrice(){return this.anchors[0]?.price??0}set entryPrice(t){let n=this.anchors[0];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(0));}get stopPrice(){return this.anchors[1]?.price??0}set stopPrice(t){let n=this.anchors[1];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(1));}get targetPrice(){return this.anchors[2]?.price??0}set targetPrice(t){let n=this.anchors[2];n&&Number.isFinite(t)&&(n.price=t,this.constrainHandleDrag(2));}anchorSchema(){return {min:2,max:2,slots:[{role:"entry",free:"both"},{role:"stop",free:"both"},{role:"target",free:"both"}]}}onPlaced(t){let n=this.anchors[0];if(!n)return;let i=t.xOf(n.time),o=t.yOf(n.price,this.paneId);if(o==null)return;let s=this.anchors[1],a=s?t.yOf(s.price,this.paneId):null,l,c;s&&a!=null&&Math.abs(a-o)>=de.MIN_DRAG_PX?(l=a,c=i+Math.max(Math.abs(t.xOf(s.time)-i),de.MIN_WIDTH_PX)):(l=o-de.DEFAULT_RISK_PX*de.DEFAULT_RR,c=i+de.DEFAULT_WIDTH_PX);let d=o-(l-o)/de.DEFAULT_RR,u=t.pxToPoint(c,o,this.paneId).time;this.anchors=[{time:n.time,price:n.price},{time:u,price:t.pxToPoint(i,d,this.paneId).price},{time:u,price:t.pxToPoint(i,l,this.paneId).price}];}constrainHandleDrag(t){let n=this.anchors[0],i=this.anchors[1],o=this.anchors[2];if(!n||!i||!o)return;let s=Math.sign(i.price-n.price),a=Math.sign(o.price-n.price);s===0||a===0||s!==a||(t===2?i.price=2*n.price-i.price:o.price=2*n.price-o.price);}resolved(){let t=this.anchors[0],n=this.anchors[1];if(!t||!n)return null;if(this.anchors[2])return [t,n,this.anchors[2]];let i={time:n.time,price:t.price-(n.price-t.price)/de.DEFAULT_RR};return [t,i,n]}prices(){let t=this.resolved();return t?{entry:t[0].price,stop:t[1].price,target:t[2].price}:null}rr(){let t=this.prices();if(!t)return 0;let n=Math.abs(t.entry-t.stop);return n<1e-9?0:Math.abs(t.target-t.entry)/n}rewardPct(){let t=this.prices();return t&&t.entry!==0?Math.abs(t.target-t.entry)/t.entry*100:0}riskPct(){let t=this.prices();return t&&t.entry!==0?Math.abs(t.entry-t.stop)/t.entry*100:0}dollarLoss(){return Math.max(0,this.accountBalance)*(Math.max(0,this.riskPercent)/100)}positionSize(){let t=this.prices();if(!t)return 0;let n=Math.abs(t.entry-t.stop);return n<1e-9?0:this.dollarLoss()/n}headerLabel(){return `${this.directionLabel()} \xB7 R:R ${this.rr().toFixed(2)}`}lossSizeLabel(){return `Loss $${gx(this.dollarLoss())} \xB7 Size ${bx(this.positionSize())}`}targetLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${ap(t.target)}`:"";return `Target +${this.rewardPct().toFixed(2)}%${n}`}stopLabel(){let t=this.prices(),n=this.showPrices&&t?` @ ${ap(t.stop)}`:"";return `Stop \u2212${this.riskPct().toFixed(2)}%${n}`}levelDisplayValue(t,n){let i=this.prices();if(!i)return 0;let o=t==="stop"?i.stop:i.target;return lp(n==="price"?o:Math.abs(o-i.entry))}levelPriceFromDisplay(t,n,i){let o=this.prices();if(!o||n==="price")return i;let s=t==="stop"?o.stop:o.target,a=Math.sign(s-o.entry);return a===0&&(a=(t==="target"?1:-1)*(this.direction==="long"?1:-1)),o.entry+a*Math.abs(i)}box(t){let n=this.handlePoints(t);if(n.length<3)return null;let i=n.map(o=>o[0]);return {x1:Math.min(...i),x2:Math.max(...i),ey:n[0][1],sy:n[1][1],ty:n[2][1]}}layout(t){return this.box(t)}hitTest(t,n,i,o){let s=this.box(i);if(!s)return false;let a=Math.min(s.ey,s.sy,s.ty),l=Math.max(s.ey,s.sy,s.ty);return ye(t,n,s.x1,a,s.x2,l,o)}handlePoints(t){let n=this.resolved();if(!n)return [];let i=[];for(let o of n){let s=t.yOf(o.price,this.paneId);if(s==null)return [];i.push([t.xOf(o.time),s]);}return i}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.box(t);if(!n)return null;let i=Math.min(n.ey,n.sy,n.ty);return {x:n.x1,y:i,w:n.x2-n.x1,h:Math.max(n.ey,n.sy,n.ty)-i}}priceRange(){let t=this.resolved();if(!t)return null;let n=t.map(i=>i.price);return {min:Math.min(...n),max:Math.max(...n)}}schema(){return {fields:[{path:"riskPercent",label:"Risk %",kind:"number",min:0,max:100,step:.1,group:"behavior"},{path:"accountBalance",label:"Account balance",kind:"number",min:0,max:1e12,step:1,group:"behavior"},{path:"quantity",label:"Position size",kind:"number",group:"behavior"},{path:"direction",label:"Direction",kind:"select",options:sa,group:"behavior"},{path:"entryPrice",label:"Entry price",kind:"number",group:"behavior"},{path:"stopPrice",label:"Stop price",kind:"number",group:"behavior"},{path:"targetPrice",label:"Target price",kind:"number",group:"behavior"},{path:"showText",label:"Show text",kind:"boolean",group:"behavior"},{path:"showHeader",label:"Show direction & ratio",kind:"boolean",group:"behavior"},{path:"showLossSize",label:"Show loss & size",kind:"boolean",group:"behavior"},{path:"showTargetLabel",label:"Show target label",kind:"boolean",group:"behavior"},{path:"showStopLabel",label:"Show stop label",kind:"boolean",group:"behavior"},{path:"showPrices",label:"Show level prices",kind:"boolean",group:"behavior"},{path:"profitColor",label:"Profit zone",kind:"color",group:"fill"},{path:"lossColor",label:"Loss zone",kind:"color",group:"fill"},...F.filter(t=>t.path!=="style.lineColor"),{path:"text.color",label:"Text color",kind:"color",group:"text"},{path:"text.size",label:"Text size",kind:"select",options:Ze,group:"text"}]}}writeProps(){return {riskPercent:this.riskPercent,accountBalance:this.accountBalance,showText:this.showText,showHeader:this.showHeader,showPrices:this.showPrices,showLossSize:this.showLossSize,showTargetLabel:this.showTargetLabel,showStopLabel:this.showStopLabel,profitColor:this.profitColor,lossColor:this.lossColor}}readProps(t){typeof t.riskPercent=="number"&&Number.isFinite(t.riskPercent)&&(this.riskPercent=t.riskPercent),typeof t.accountBalance=="number"&&Number.isFinite(t.accountBalance)&&(this.accountBalance=t.accountBalance),typeof t.showText=="boolean"&&(this.showText=t.showText),typeof t.showHeader=="boolean"&&(this.showHeader=t.showHeader),typeof t.showPrices=="boolean"&&(this.showPrices=t.showPrices),typeof t.showLossSize=="boolean"&&(this.showLossSize=t.showLossSize),typeof t.showTargetLabel=="boolean"&&(this.showTargetLabel=t.showTargetLabel),typeof t.showStopLabel=="boolean"&&(this.showStopLabel=t.showStopLabel),typeof t.profitColor=="string"&&(this.profitColor=t.profitColor),typeof t.lossColor=="string"&&(this.lossColor=t.lossColor);}};de.DEFAULT_RR=2,de.MIN_DRAG_PX=6,de.DEFAULT_RISK_PX=64,de.DEFAULT_WIDTH_PX=150,de.MIN_WIDTH_PX=48,de.DEFAULT_RISK_PERCENT=1,de.DEFAULT_ACCOUNT_BALANCE=1e4,de.DEFAULT_PROFIT_COLOR=Zo,de.DEFAULT_LOSS_COLOR=Jo;var We=de;function gx(r){if(!Number.isFinite(r))return "0";let e=Math.round(r*100)/100;return Number.isInteger(e)?String(e):e.toFixed(2)}function bx(r){return !Number.isFinite(r)||r===0?"0":r>=100?r.toFixed(2):r>=1?r.toFixed(4).replace(/\.?0+$/,""):r.toPrecision(4).replace(/\.?0+$/,"")}function ap(r){return Number.isFinite(r)?Math.abs(r)>=1?r.toFixed(2):r.toPrecision(4).replace(/\.?0+$/,""):"0"}function lp(r){return Math.round(r*1e8)/1e8}var On=[{value:"auto",label:"Auto",ms:0},{value:"1",label:"1m",ms:6e4},{value:"5",label:"5m",ms:3e5},{value:"15",label:"15m",ms:9e5},{value:"30",label:"30m",ms:18e5},{value:"60",label:"1h",ms:36e5},{value:"240",label:"4h",ms:144e5},{value:"D",label:"1D",ms:864e5}];function xi(r){let e=On.find(n=>n.value===r);if(e)return e.label;let t=Number(r);return Number.isFinite(t)&&t>0?t%1440===0?`${t/1440}D`:t%60===0?`${t/60}h`:`${t}m`:r}function cp(){return {timeframe:"auto",upColor:"",downColor:""}}var Fe=class extends _{constructor(t){super(t);this.type="magnifier";this.chipRect=null;this.magnifier||(this.magnifier=cp());}anchorSchema(){return {min:2,max:2,slots:[{role:"c1",free:"both"},{role:"c2",free:"both"}]}}placementMode(){return "drag"}rect(t){let n=this.anchors[0],i=this.anchors[1];if(!n||!i)return null;let o=t.yOf(n.price,this.paneId),s=t.yOf(i.price,this.paneId);return o==null||s==null?null:{x1:t.xOf(n.time),y1:o,x2:t.xOf(i.time),y2:s}}hitTest(t,n,i,o){let s=this.rect(i);return s?ye(t,n,s.x1,s.y1,s.x2,s.y2)?true:[[s.x1,s.y1,s.x2,s.y1],[s.x2,s.y1,s.x2,s.y2],[s.x2,s.y2,s.x1,s.y2],[s.x1,s.y2,s.x1,s.y1]].some(l=>U(t,n,l[0],l[1],l[2],l[3])<=o):false}handlePoints(t){let n=this.rect(t);return n?[[n.x1,n.y1],[n.x2,n.y2]]:[]}hitHandle(t,n,i,o){return H(t,n,this.handlePoints(i),o+3)}bounds(t){let n=this.rect(t);return n?{x:Math.min(n.x1,n.x2),y:Math.min(n.y1,n.y2),w:Math.abs(n.x2-n.x1),h:Math.abs(n.y2-n.y1)}:null}priceRange(){let t=this.anchors[0],n=this.anchors[1];return !t||!n?null:{min:Math.min(t.price,n.price),max:Math.max(t.price,n.price)}}schema(){return {fields:[{path:"magnifier.timeframe",label:"Timeframe",kind:"select",options:On,group:"behavior"},...F.map(t=>({...t,label:t.label.replace("Line","Border")})),{path:"magnifier.upColor",label:"Up candles",kind:"color",group:"fill"},{path:"magnifier.downColor",label:"Down candles",kind:"color",group:"fill"}]}}writeProps(){return {...this.magnifier}}readProps(t){this.magnifier={...cp(),...t};}};var Si=new Map;function O(r){Si.set(r.type,r);}function Qe(r){return Si.get(r)}function aa(){return [...Si.values()]}function en(r,e){let t=Si.get(r);if(!t)return null;let n={...t.defaultStyle,...e.style??{}};return t.create({...e,style:n})}function Mc(r){let e=en(r.type,{paneId:r.paneId});if(!e)return;r.style={...e.style};let t=r.text?.value;e.text?(r.text={...e.text},t!==void 0&&(r.text.value=t)):r.text=void 0;let n=e.serialize().props;n!==void 0&&r.applyProps(n);}function pt(r){let e=Si.get(r.type);return e?e.create(r):null}var vx=A('<line x1="4" y1="19" x2="20" y2="5"/>'),yx=A('<line x1="3" y1="12" x2="21" y2="12"/>');O({type:"trendline",group:"lines",label:"Trend Line",icon:vx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ns(r)});O({type:"hline",group:"lines",label:"Horizontal Line",icon:yx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"dashed"},create:r=>new rs(r)});var wx=A('<line x1="3" y1="20" x2="21" y2="6"/><circle cx="3" cy="20" r="1.6" fill="currentColor"/>'),xx=A('<rect x="4" y="6" width="16" height="12" rx="1"/>'),Sx=A('<path d="M5 6h14M12 6v13"/>');O({type:"ray",group:"lines",label:"Ray",icon:wx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new is(r)});var Cx=A('<path d="M5 19 19 5"/><path d="M5 19 8.5 19M5 19 5 15.5"/><path d="M19 5 15.5 5M19 5 19 8.5"/>'),Tx=A('<line x1="12" y1="3" x2="12" y2="21"/>'),Ex=A('<line x1="5" y1="12" x2="21" y2="12"/><circle cx="5" cy="12" r="1.6" fill="currentColor"/>'),Px=A('<line x1="3" y1="12" x2="21" y2="12"/><line x1="12" y1="3" x2="12" y2="21"/>'),Lx=A('<path d="M4 20 20 4"/><rect x="9" y="9" width="9" height="6" rx="1"/>'),Mx=A('<path d="M4 20 20 6"/><path d="M4 20 15 20"/><path d="M11 20a7 7 0 0 0-2-4.9"/>');O({type:"extendedline",group:"lines",label:"Extended Line",icon:Cx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new os(r)});O({type:"vline",group:"lines",label:"Vertical Line",icon:Tx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ss(r)});O({type:"hray",group:"lines",label:"Horizontal Ray",icon:Ex,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new as(r)});O({type:"crossline",group:"lines",label:"Cross Line",icon:Px,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new ls(r)});O({type:"infoline",group:"lines",label:"Info Line",icon:Lx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new cs(r)});O({type:"trendangle",group:"lines",label:"Trend Angle",icon:Mx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ds(r)});O({type:"box",group:"shapes",label:"Rectangle",icon:xx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}26`},create:r=>new us(r)});O({type:"text",group:"annotations",label:"Text",icon:Sx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Rt(r)});var kx=A('<path d="M5 4h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-6l-5 5v-5H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z"/>');O({type:"callout",group:"annotations",label:"Callout",icon:kx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new dt(r)});var Ix=A('<path d="M5 4h14a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-7l-4 4v-4H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Z"/><path d="M8 8.5h8M8 12h5"/>'),Ax=A('<rect x="10" y="4.5" width="11" height="8" rx="1.5"/><path d="M10 8.5 4 16"/><circle cx="3.5" cy="16.5" r="1.6" fill="currentColor" stroke="none"/>'),Rx=A('<path d="M5 4.5h14a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-7l-4 4v-4H5a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2Z"/>'),Dx=A('<path d="M3 12 7 8h12a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H7Z"/><path d="M10.5 12.5h6" stroke-width="1.4"/>'),Ox=A('<path d="M12 11.5V21"/><rect x="5" y="4" width="14" height="7" rx="1"/><path d="M9 7.5h6"/>');O({type:"note",group:"annotations",label:"Note",icon:Ix,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new yn(r)});O({type:"pricenote",group:"annotations",label:"Price Note",icon:Ax,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new xn(r)});O({type:"comment",group:"annotations",label:"Comment",icon:Rx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new Sn(r)});O({type:"pricelabel",group:"annotations",label:"Price Label",icon:Dx,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new wn(r)});O({type:"signpost",group:"annotations",label:"Signpost",icon:Ox,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid",fillColor:`${R}d9`},create:r=>new Cn(r)});var Fx=A('<line x1="3" y1="16" x2="21" y2="8"/><line x1="3" y1="21" x2="21" y2="13"/>'),Nx=A('<line x1="3" y1="7" x2="21" y2="10"/><line x1="3" y1="18" x2="21" y2="14"/>'),Vx=A('<circle cx="4" cy="12" r="1.6" fill="currentColor"/><line x1="4" y1="12" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>');O({type:"parallelchannel",group:"channels",label:"Parallel Channel",icon:Fx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new hs(r)});O({type:"disjointchannel",group:"channels",label:"Disjoint Channel",icon:Nx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new ps(r)});var _x=A('<line x1="3" y1="7" x2="21" y2="7"/><line x1="3" y1="18" x2="21" y2="11"/>');O({type:"flattopbottom",group:"channels",label:"Flat Top/Bottom",icon:_x,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new ms(r)});var Bx=A('<line x1="3" y1="8" x2="21" y2="4"/><line x1="3" y1="16" x2="21" y2="12"/><line x1="3" y1="12" x2="21" y2="8" stroke-dasharray="3 3"/>');O({type:"regressionchannel",group:"channels",label:"Linear Regression",icon:Bx,defaultStyle:{lineColor:Pe,lineWidth:1,lineStyle:"solid"},create:r=>new Dt(r)});O({type:"pitchfork",group:"pitchforks",label:"Pitchfork",icon:Vx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new fs(r)});var Hx=A('<circle cx="4" cy="8" r="1.6" fill="currentColor"/><line x1="4" y1="8" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>'),zx=A('<circle cx="6" cy="9" r="1.6" fill="currentColor"/><line x1="6" y1="9" x2="10" y2="12"/><line x1="10" y1="6" x2="10" y2="18"/><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/>'),$x=A('<line x1="4" y1="12" x2="10" y2="12"/><line x1="10" y1="8" x2="10" y2="16"/><line x1="10" y1="8" x2="21" y2="8"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="16" x2="21" y2="16"/>');O({type:"schiffpitchfork",group:"pitchforks",label:"Schiff Pitchfork",icon:Hx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new gs(r)});O({type:"modifiedschiffpitchfork",group:"pitchforks",label:"Modified Schiff Pitchfork",icon:zx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new bs(r)});O({type:"insidepitchfork",group:"pitchforks",label:"Inside Pitchfork",icon:$x,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new vs(r)});var Wx=A('<path d="M7 7h10v10"/><path d="M7 17 17 7"/>'),Gx=A('<ellipse cx="12" cy="12" rx="9" ry="6"/>'),Ux=A('<path d="M12 4 20 19 4 19Z"/>');O({type:"arrow",group:"shapes",label:"Arrow",icon:Wx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",arrowRight:true},create:r=>new ys(r)});O({type:"ellipse",group:"shapes",label:"Ellipse",icon:Gx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new ws(r)});O({type:"triangle",group:"shapes",label:"Triangle",icon:Ux,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new xs(r)});var Yx=A('<polyline points="3 17 9 10 13 14 21 5"/>'),Kx=A('<path d="M9.5 12 17 4.5a2.12 2.12 0 0 1 3 3L12.5 15"/><path d="M7 14a3 3 0 0 0-3 3c0 1.3-1.2 1.5-1.5 2 .8.9 2 1.5 3.5 1.5a3.5 3.5 0 0 0 3.5-3.5 3 3 0 0 0-2.5-3Z"/>'),Xx=A('<path d="M9 11 15 5l4 4-6 6H9Z"/><path d="M9 15l-2 2"/><path d="M4 21h6"/>');O({type:"polyline",group:"shapes",label:"Polyline",icon:Yx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Ss(r)});O({type:"freehand",group:"shapes",label:"Brush",icon:Kx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Cs(r)});O({type:"highlighter",group:"shapes",label:"Highlighter",icon:Xx,defaultStyle:{lineColor:`${kh}59`,lineWidth:14,lineStyle:"solid"},create:r=>new Ts(r)});var jx=A('<circle cx="12" cy="12" r="8"/>'),qx=A('<path d="M5 14 9.5 5 19 10 14.5 19 Z"/>'),Zx=A('<path d="M4 19 9 11 13 14 17 8 20 4"/><path d="M17.2 5.5 20 4 19.4 7.1"/>'),Jx=A('<path d="M4 17a8 8 0 0 1 16 0"/><path d="M4 17 20 17"/>'),Qx=A('<path d="M4 18Q12 1 20 14"/>'),eS=A('<path d="M12 5 12 19"/><path d="M6 11 12 5 18 11"/>'),tS=A('<path d="M12 5 12 19"/><path d="M6 13 12 19 18 13"/>');O({type:"circle",group:"shapes",label:"Circle",icon:jx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}1a`},create:r=>new Es(r)});O({type:"rotatedrect",group:"shapes",label:"Rotated Rectangle",icon:qx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}26`},create:r=>new Ps(r)});O({type:"path",group:"shapes",label:"Path",icon:Zx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new Ls(r)});O({type:"arc",group:"shapes",label:"Arc",icon:Jx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid",fillColor:`${R}26`},create:r=>new Ms(r)});O({type:"curve",group:"shapes",label:"Curve",icon:Qx,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new ks(r)});O({type:"arrowmarkup",group:"shapes",label:"Arrow Mark Up",icon:eS,defaultStyle:{lineColor:q,lineWidth:1,lineStyle:"solid"},create:r=>new pi(r)});O({type:"arrowmarkdown",group:"shapes",label:"Arrow Mark Down",icon:tS,defaultStyle:{lineColor:X,lineWidth:1,lineStyle:"solid"},create:r=>new mi(r)});var nS=A('<path d="M6 21V4"/><path d="M6 5h11l-2.5 3.5L17 12H6" fill="currentColor" stroke="none"/>'),rS=A('<path d="m12 3 2.6 5.8 6.4.6-4.8 4.2 1.4 6.2L12 16.9 6.4 19.8 7.8 13.6 3 9.4l6.4-.6Z"/>');O({type:"flagmark",group:"stamps",label:"Flag",icon:nS,defaultStyle:{lineColor:Ee,lineWidth:1,lineStyle:"solid"},create:r=>new fi(r)});O({type:"iconstamp",group:"stamps",label:"Icon",icon:rS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new gi(r)});var iS=A('<line x1="3" y1="5" x2="21" y2="5"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="3" y1="14" x2="21" y2="14"/><line x1="3" y1="19" x2="21" y2="19"/>'),oS=A('<line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="11" x2="21" y2="11"/><line x1="3" y1="15" x2="14" y2="15"/><line x1="3" y1="20" x2="14" y2="20"/>');O({type:"fibretracement",group:"fibonacci",label:"Fib Retracement",icon:iS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Rs(r)});O({type:"fibextension",group:"fibonacci",label:"Fib Extension",icon:oS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ds(r)});var sS=A('<path d="M3 20 10 9l4 5"/><path d="M14 14h7M14 9h7M14 4h7"/>');O({type:"fibextensiontrend",group:"fibonacci",label:"Trend-Based Fib Extension",icon:sS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Os(r)});var aS=A('<path d="M4 20 20 5M4 20 21 11M4 20 21 17M4 20 20 20"/>'),lS=A('<path d="M3 5v14M6 5v14M11 5v14M19 5v14"/>');O({type:"fibfan",group:"fibonacci",label:"Fib Fan",icon:aS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Fs(r)});O({type:"fibtimezones",group:"fibonacci",label:"Fib Time Zones",icon:lS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"dashed"},create:r=>new Ns(r)});var cS=A('<path d="M3 18 18 9M5 21 20 12M6 13 21 4"/>'),dS=A('<path d="M4 4 20 20M4 4 20 12M4 4 12 20M4 4 20 4M4 4 4 20"/>'),uS=A('<path d="M3 19 9 8M9 8 12 5v14M14 5v14M18 5v14M21 5v14"/>');O({type:"fibchannel",group:"fibonacci",label:"Fib Channel",icon:cS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Vs(r)});O({type:"fibspeedfan",group:"fibonacci",label:"Fib Speed Resistance Fan",icon:dS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new _s(r)});O({type:"trendfibtime",group:"fibonacci",label:"Trend-Based Fib Time",icon:uS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"dashed"},create:r=>new Bs(r)});var hS=A('<circle cx="12" cy="12" r="3"/><circle cx="12" cy="12" r="6.5"/><circle cx="12" cy="12" r="10"/>'),pS=A('<path d="M8 20a4 4 0 0 1 8 0"/><path d="M4.5 20a7.5 7.5 0 0 1 15 0"/><circle cx="12" cy="20" r="1.4" fill="currentColor" stroke="none"/>'),mS=A('<path d="M4 20 20 16M4 20 14 4"/><path d="M11.8 18.1A8 8 0 0 0 8.2 13.2"/><path d="M16.6 16.9A13 13 0 0 0 10.9 9"/>'),fS=A('<path d="M13 12a2 2 0 1 1-2-2 4 4 0 0 1 4 4 6 6 0 0 1-9 5.2 9 9 0 0 1 .5-15"/>');O({type:"fibcircles",group:"fibonacci",label:"Fib Circles",icon:hS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Hs(r)});O({type:"fibarcs",group:"fibonacci",label:"Fib Speed Resistance Arcs",icon:pS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new zs(r)});O({type:"fibwedge",group:"fibonacci",label:"Fib Wedge",icon:mS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new $s(r)});O({type:"fibspiral",group:"fibonacci",label:"Fib Spiral",icon:fS,defaultStyle:{lineColor:R,lineWidth:2,lineStyle:"solid"},create:r=>new In(r)});var gS=A('<path d="M4 20 20 20M4 20 20 13M4 20 20 6M4 20 15 4M4 20 9 4M4 20 4 4"/>'),bS=A('<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M4 12h16M12 4v16M4 4 20 20" opacity="0.6"/>');O({type:"gannfan",group:"fibonacci",label:"Gann Fan",icon:gS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ws(r)});O({type:"gannbox",group:"fibonacci",label:"Gann Box",icon:bS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Gs(r)});var vS=A('<rect x="4" y="4" width="16" height="16" rx="1"/><path d="M4 20 20 4M4 20 20 12M4 20 12 4" opacity="0.7"/><path d="M4 20a16 16 0 0 1 16-16" opacity="0.5"/>');O({type:"gannsquare",group:"fibonacci",label:"Gann Square",icon:vS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new An(r)});var yS=A('<path d="M2 20h20"/><path d="M4 20a8 8 0 0 1 16 0" opacity="0.9"/><path d="M6 20a4 4 0 0 1 8 0" opacity="0.75"/><path d="M10 20a2 2 0 0 1 4 0" opacity="0.6"/><path d="M8 20v-6M12 20v-9M16 20v-6" opacity="0.45"/>');O({type:"dedekind",group:"geometry",label:"Dedekind Tessellation",icon:yS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Rn(r)});var wS=A('<circle cx="16" cy="12" r="5" opacity="0.55"/><circle cx="13" cy="12" r="3.5" opacity="0.75"/><circle cx="10.5" cy="12" r="2"/><path d="M8 4v16"/>'),xS=A('<circle cx="17" cy="12" r="4.5" opacity="0.45"/><circle cx="13" cy="12" r="3" opacity="0.7"/><circle cx="10" cy="12" r="1.6"/><path d="M6 12 16 5M6 12 16 19"/>');O({type:"sonic",group:"geometry",label:"Sonic",icon:wS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new vi(r)});O({type:"supersonic",group:"geometry",label:"Supersonic",icon:xS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new yi(r)});var SS=A('<circle cx="16" cy="12" r="5" opacity="0.4"/><circle cx="13" cy="12" r="3.2" opacity="0.65"/><circle cx="10.8" cy="12" r="1.8"/><path d="M8 4v16"/><path d="M15 8.5h2M12.5 10h2" opacity="0.5"/>'),CS=A('<circle cx="17" cy="12" r="4.5" opacity="0.4"/><circle cx="12.5" cy="12" r="2.8" opacity="0.65"/><circle cx="9.8" cy="12" r="1.4"/><path d="M6 12 16 5M6 12 16 19"/>');O({type:"goldensonic",group:"geometry",label:"Golden Sonic",icon:SS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ys(r)});O({type:"goldensupersonic",group:"geometry",label:"Golden Supersonic",icon:CS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Ks(r)});var TS=A('<path d="M3 18 7 8 11 14 15 6 20 16"/>'),ES=A('<path d="M4 17 9 7 14 15 20 5"/>'),PS=A('<path d="M3 19 8 9 12 13 17 5 21 9"/>'),LS=A('<path d="M4 7 11 16 20 9"/>'),MS=A('<path d="M3 18 6 12 9 16 12 5 15 16 18 12 21 18"/>');O({type:"xabcd",group:"patterns",label:"XABCD Pattern",icon:TS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Xs(r)});O({type:"abcd",group:"patterns",label:"ABCD Pattern",icon:ES,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new js(r)});O({type:"elliottimpulse",group:"patterns",label:"Elliott Impulse Wave (1-5)",icon:PS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new qs(r)});O({type:"elliottcorrection",group:"patterns",label:"Elliott Correction Wave (ABC)",icon:LS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Zs(r)});O({type:"headshoulders",group:"patterns",label:"Head & Shoulders",icon:MS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new Js(r)});var kS=A('<path d="M3 17 7 6 12 14 17 5 21 16"/><path d="M3 17 21 16" opacity="0.45"/>'),hr={group:"patterns",icon:kS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"}};O({type:"gartley",label:"Gartley",...hr,create:r=>new Qs(r)});O({type:"bat",label:"Bat",...hr,create:r=>new ea(r)});O({type:"butterfly",label:"Butterfly",...hr,create:r=>new ta(r)});O({type:"crab",label:"Crab",...hr,create:r=>new na(r)});O({type:"shark",label:"Shark",...hr,create:r=>new ra(r)});O({type:"cypher",label:"Cypher",...hr,create:r=>new ia(r)});var IS=A('<rect x="4" y="6" width="16" height="12" rx="1"/><path d="M4 18 20 6" opacity="0.5"/>');O({type:"datepricerange",group:"measure",label:"Date & Price Range",icon:IS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new oa(r)});var AS=A('<rect x="4.5" y="4.5" width="15" height="7.5" rx="1" fill="currentColor" fill-opacity="0.25"/><rect x="4.5" y="12" width="15" height="7.5" rx="1"/>');O({type:"position",group:"measure",label:"Long/Short Position",icon:AS,defaultStyle:{lineColor:R,lineWidth:1,lineStyle:"solid"},create:r=>new We(r)});var RS=A('<circle cx="10.5" cy="10.5" r="6.5"/><path d="m15.3 15.3 5.2 5.2"/><path d="M8 12.5v-3M10.5 13.5v-5.5M13 12v-2"/>');O({type:"magnifier",group:"measure",label:"Magnifier",icon:RS,defaultStyle:{lineColor:"",lineWidth:1,lineStyle:"solid"},coversSeries:true,placementHint:"Drag an area on the chart to view it at a lower timeframe",create:r=>new Fe(r)});var DS=A('<line x1="5" y1="3" x2="5" y2="21"/><path d="M5 16c4 0 5-9 8-9s3 5 8 3"/>');O({type:"anchoredvwap",group:"measure",label:"Anchored VWAP",icon:DS,defaultStyle:{lineColor:It,lineWidth:2,lineStyle:"solid"},create:r=>new Tn(r)});var OS=A('<path d="M4 4v16"/><path d="M4 8h10"/><path d="M4 12h14"/><path d="M4 16h8"/><path d="M4 20h12"/>');O({type:"fixedrangevp",group:"measure",label:"Fixed Range Volume Profile",icon:OS,defaultStyle:{lineColor:q,lineWidth:1,lineStyle:"solid"},create:r=>new Be(r)});var FS=["fibretracement","fibextension","fibextensiontrend","fibfan","fibtimezones","fibchannel","fibspeedfan","trendfibtime","fibcircles","fibarcs","fibwedge","fibspiral"],NS=["gannfan","gannbox","gannsquare"],VS=["dedekind","sonic","supersonic","goldensonic","goldensupersonic"],_S=["xabcd","abcd","headshoulders"],BS=["elliottimpulse","elliottcorrection"],HS=["gartley","bat","butterfly","crab","shark","cypher"],zS=["position","datepricerange","magnifier"],$S=["anchoredvwap","fixedrangevp"],WS=["freehand","highlighter"],GS=["arrow","arrowmarkup","arrowmarkdown"],US=["box","ellipse","triangle","polyline","circle","rotatedrect","path","arc","curve"],YS=["text","callout","note","pricenote","comment","pricelabel","signpost"],KS=["flagmark","iconstamp"],XS=[{id:"lines-channels-pitchforks",label:"Lines",sections:[{label:"Lines",registryGroup:"lines"},{label:"Channels",registryGroup:"channels"},{label:"Pitchforks",registryGroup:"pitchforks"}]},{id:"fibonacci-gann",label:"Fibonacci",sections:[{label:"Fibonacci",types:FS},{label:"Gann",types:NS},{label:"Geometry",types:VS}]},{id:"patterns-waves-harmonics",label:"Patterns",sections:[{label:"Patterns",types:_S},{label:"Elliott Waves",types:BS},{label:"Harmonics",types:HS}]},{id:"measurements",label:"Measurements",sections:[{label:"Measurements",types:zS},{label:"Volume",types:$S}]},{id:"brushes-arrows-shapes",label:"Shapes",sections:[{label:"Brushes",types:WS},{label:"Arrows",types:GS},{label:"Shapes",types:US}]},{id:"text",label:"Text",sections:[{label:"Text",types:YS}]},{id:"icons",label:"Icons",sections:[{label:"Icons",types:KS}]}];function jS(r){let e=Qe(r);return e?{type:e.type,label:e.label,icon:e.icon}:null}function qS(r){let e=new Map;for(let t of aa()){if(r&&!r.has(t.type))continue;let n={type:t.type,label:t.label,icon:t.icon};e.has(t.group)||e.set(t.group,[]),e.get(t.group).push(n);}return e}function ZS(r,e,t){return "registryGroup"in r?e.get(r.registryGroup)??[]:r.types.map(n=>t.get(n)).filter(n=>n!=null)}function dp(r){let e=qS(r),t=new Map;for(let i of e.values())for(let o of i)t.set(o.type,o);let n=[];for(let i of XS){let o=[],s=[];for(let a of i.sections){let l=ZS(a,e,t);l.length!==0&&(o.push({label:a.label,tools:l}),s.push(...l));}s.length!==0&&n.push({id:i.id,label:i.label,tools:s,sections:o.length>0?o:void 0});}return {groups:n}}function JS(r){let e=new Set;for(let t of r)Qe(t)&&e.add(t);return dp(e)}function QS(r){let e=[];for(let t of r){let n=t.tools.map(jS).filter(i=>i!=null);n.length>0&&e.push({id:t.id,label:t.label,tools:n});}return {groups:e}}function Ci(){return dp()}function Ti(r){if(r===false)return {definition:Ci(),visible:false};if(r===void 0||r===true)return {definition:Ci(),visible:true};let e=r.toolbar??true;return r.groups?{definition:QS(r.groups),visible:e}:r.tools?{definition:JS(r.tools),visible:e}:{definition:Ci(),visible:e}}function mt(r){let e=globalThis.structuredClone;return e?e(r):JSON.parse(JSON.stringify(r))}function up(r){if(!r||typeof r!="object")return false;let e=r;return typeof e.id=="string"&&typeof e.type=="string"&&typeof e.paneId=="string"&&Array.isArray(e.anchors)&&e.anchors.every(t=>t&&typeof t.time=="number"&&typeof t.price=="number")&&!!e.style&&typeof e.style=="object"}function kc(r){let e=r;return !e||typeof e!="object"||e.version!==1||!Array.isArray(e.drawings)?{version:1,drawings:[]}:{version:1,drawings:e.drawings.filter(up)}}var pr=class{constructor(){this.byId=new Map;this.seq=0;this.zCounter=1;this.listeners=new Set;}nextId(){return this.seq+=1,`dw-${this.seq}`}add(e){return e.zIndex||(e.zIndex=this.zCounter),this.zCounter=Math.max(this.zCounter,Math.ceil(e.zIndex))+1,this.byId.set(e.id,e),this.emit(),e}remove(e){let t=this.byId.delete(e);return t&&this.emit(),t}get(e){return this.byId.get(e)}has(e){return this.byId.has(e)}update(e,t){let n=this.byId.get(e);return n?(t.anchors&&(n.anchors=t.anchors.map(i=>({time:i.time,price:i.price}))),t.style&&(n.style={...t.style}),t.text!==void 0&&(n.text=t.text?{...t.text}:void 0),t.paneId!==void 0&&(n.paneId=t.paneId),t.locked!==void 0&&(n.locked=t.locked),t.visible!==void 0&&(n.visible=t.visible),t.zIndex!==void 0&&(n.zIndex=t.zIndex),t.props!==void 0&&n.applyProps(t.props),this.emit(),n):null}all(){return [...this.byId.values()].sort((e,t)=>e.zIndex-t.zIndex)}byPane(e){return this.all().filter(t=>t.paneId===e)}bringToFront(e,t=0){let n=this.byId.get(e);n&&(n.zIndex=Math.max(this.zCounter,Math.floor(t)+1),this.zCounter=n.zIndex+1,this.emit());}sendToBack(e,t=1){let n=this.byId.get(e);if(!n)return;let i=Math.min(...[...this.byId.values()].map(o=>o.zIndex),Math.ceil(t));n.zIndex=i-1,this.emit();}setLocked(e,t){let n=this.byId.get(e);n&&(n.locked=t,this.emit());}setVisible(e,t){let n=this.byId.get(e);n&&(n.visible=t,this.emit());}clear(){this.byId.size!==0&&(this.byId.clear(),this.emit());}serialize(){return {version:1,drawings:this.all().map(e=>e.serialize())}}load(e){let t=kc(e);this.byId.clear(),this.seq=0,this.zCounter=1;for(let n of t.drawings){let i=pt(n);i&&(this.byId.set(i.id,i),this.zCounter=Math.max(this.zCounter,i.zIndex)+1,this.bumpSeqPast(i.id));}this.emit();}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}bumpSeqPast(e){let t=/^dw-(\d+)$/.exec(e);t&&(this.seq=Math.max(this.seq,Number(t[1])));}emit(){for(let e of this.listeners)e();}};var la=class{constructor(e=100){this.cap=e;this.undoStack=[];this.redoStack=[];this.pending=null;this.dirtied=false;this.depth=0;}begin(e){this.depth+=1,this.depth===1&&(this.pending=mt(e),this.dirtied=false);}markDirty(){this.depth===0||this.dirtied||!this.pending||(this.push(this.pending),this.dirtied=true);}commit(){this.depth!==0&&(this.depth-=1,this.depth===0&&(this.pending=null,this.dirtied=false));}abort(){this.commit();}record(e){if(this.depth>0){this.markDirty();return}this.push(mt(e));}undo(e){let t=this.undoStack.pop();return t?(this.redoStack.push(mt(e)),t):null}redo(e){let t=this.redoStack.pop();return t?(this.undoStack.push(mt(e)),t):null}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}clear(){this.undoStack=[],this.redoStack=[],this.pending=null,this.dirtied=false,this.depth=0;}push(e){this.undoStack.push(e),this.undoStack.length>this.cap&&this.undoStack.shift(),this.redoStack=[];}};var ca=class{constructor(e,t,n,i){this.events=t;this.store=new pr;this.history=new la;this.activeTool=null;this.snapMode="off";this.stayInDrawingMode=false;this.mode=null;this.favs=new Set;this.selectedIds=[];this.clipboard=[];this.lastStyle=new Map;this.subs=[];if(this.enabled=!!e.capabilities.userDrawings&&!!e.userDrawingsPort,this.port=this.enabled?e.userDrawingsPort:null,this.port){let{definition:o,visible:s}=Ti(n);this.port.setToolbar(o),this.port.showToolbar(s),i&&this.port.setSeriesGateway?.(i),this.subs.push(this.port.onDrawingIntent(a=>this.onIntent(a))),this.subs.push(this.store.onChange(()=>this.sync()));}}get supported(){return this.enabled}setTool(e){if(!this.port)return;let t=e!==this.activeTool;this.activeTool=e,this.port.setActiveTool(e,e?this.lastStyle.get(e):void 0),t&&this.events.emit("drawing:tool",{type:e});}getTool(){return this.activeTool}getSnapMode(){return this.snapMode}setSnapMode(e){!this.port||e===this.snapMode||(this.snapMode=e,this.port.setSnapMode?.(e),this.events.emit("drawing:snap",{mode:e}));}getStayMode(){return this.stayInDrawingMode}setStayMode(e){!this.port||e===this.stayInDrawingMode||(this.stayInDrawingMode=e,this.port.setStayMode?.(e),this.events.emit("drawing:stay",{on:e}));}getMode(){return this.mode}setMode(e){!this.port||e===this.mode||(this.mode=e,this.port.setMode?.(e),this.events.emit("drawing:mode",{mode:e}));}showToolbar(e){this.port?.showToolbar(e);}favorites(){return [...this.favs]}isFavorite(e){return this.favs.has(e)}setFavorite(e,t){Qe(e)&&t!==this.favs.has(e)&&(t?this.favs.add(e):this.favs.delete(e),this.pushFavorites());}setFavorites(e){let t=e.filter(n=>Qe(n)!=null);t.length===this.favs.size&&t.every(n=>this.favs.has(n))||(this.favs=new Set(t),this.pushFavorites());}pushFavorites(){let e=[...this.favs];this.port?.setFavorites?.(e),this.events.emit("drawing:favorites",{favorites:e});}setToolbar(e){this.port?.setToolbar(Ti(e).definition);}setExternalGhost(e){this.port?.setExternalGhost?.(e);}setToolShortcuts(e){this.port?.setToolShortcuts?.(e);}add(e,t={}){if(!this.enabled)return null;let i={...this.lastStyle.get(e)??{},...t.style??{}},o=en(e,{id:this.store.nextId(),paneId:t.paneId??"price",anchors:t.anchors,style:i,text:t.text,props:t.props,zIndex:t.zIndex??this.startZ(e,t.paneId??"price")});return o?(this.history.record(this.store.serialize()),this.store.add(o),this.captureStyle(o.id),this.events.emit("drawing:created",{id:o.id}),o):null}remove(e){this.deleteMany([e]);}update(e,t){let n=this.store.serialize(),i=t.style?this.store.get(e):void 0,o=t.style&&i?{...t,style:{...i.style,...t.style}}:t;this.store.update(e,o)&&(this.history.record(n),this.captureStyle(e),this.events.emit("drawing:edited",{id:e}));}updateMany(e){this.history.begin(this.store.serialize());for(let{id:t,patch:n}of e)this.store.update(t,n)&&(this.history.markDirty(),this.events.emit("drawing:edited",{id:t}));this.history.commit();}removeMany(e){this.deleteMany(e);}setLocked(e,t){let n=this.store.serialize();this.history.record(n),this.store.setLocked(e,t),this.events.emit("drawing:edited",{id:e});}setVisible(e,t){let n=this.store.serialize();this.history.record(n),this.store.setVisible(e,t),this.events.emit("drawing:edited",{id:e});}bringToFront(e){let t=this.store.serialize();this.history.record(t),this.store.bringToFront(e,this.seriesTopZ(this.store.get(e)?.paneId)),this.events.emit("drawing:edited",{id:e});}sendToBack(e){let t=this.store.serialize();this.history.record(t),this.store.sendToBack(e,this.seriesBottomZ(this.store.get(e)?.paneId)),this.events.emit("drawing:edited",{id:e});}seriesTopZ(e){return e!==void 0?this.port?.stackRange?.(e)?.front??0:0}seriesBottomZ(e){return e!==void 0?this.port?.stackRange?.(e)?.back??1:1}startZ(e,t){let n=this.port?.stackRange?.(t);if(n)return Qe(e)?.coversSeries?n.front+.5:(n.price??n.front)-.5}select(e,t=false){this.setSelection(e,t);}openSettings(e){this.port?.openSettings(e);}undo(){let e=this.history.undo(this.store.serialize());e&&this.restoreSnapshot(e);}redo(){let e=this.history.redo(this.store.serialize());e&&this.restoreSnapshot(e);}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}duplicate(e){if(!this.enabled)return [];let t=this.resolve(e);return t.length===0?[]:this.insertClones(t.map(n=>n.serialize()))}clone(e){return this.duplicate([e])[0]??null}copy(e){let t=this.resolve(e).map(n=>mt(n.serialize()));t.length&&(this.clipboard=t);}paste(){return !this.enabled||this.clipboard.length===0?[]:this.insertClones(this.clipboard)}all(){return this.store.serialize().drawings}toJSON(){return this.store.serialize()}fromJSON(e){this.history.clear(),this.selectedIds=[],this.store.load(e);}destroy(){for(let e of this.subs)e();this.subs.length=0;}setSelection(e,t=false){let n;if(t){n=[...this.selectedIds];for(let i of e){let o=n.indexOf(i);o>=0?n.splice(o,1):n.push(i);}}else n=[...e];this.selectedIds=n.filter(i=>this.store.has(i)),this.port?.setSelection(this.selectedIds),this.events.emit("drawing:selected",{id:this.selectedIds[0]??null});}restoreSnapshot(e){this.store.load(e),this.selectedIds=this.selectedIds.filter(t=>this.store.has(t)),this.port?.setSelection(this.selectedIds),this.events.emit("drawing:selected",{id:this.selectedIds[0]??null});}deleteMany(e){this.history.begin(this.store.serialize());let t=[];for(let i of e)this.store.remove(i)&&t.push(i),this.history.markDirty();if(this.history.commit(),t.length===0)return;let n=this.selectedIds.filter(i=>this.store.has(i));n.length!==this.selectedIds.length&&this.setSelection(n);for(let i of t)this.events.emit("drawing:removed",{id:i});}insertClones(e){this.history.begin(this.store.serialize());let t=[];for(let n of e){let i=pt({...n,id:this.store.nextId()});i&&(this.store.add(i),this.history.markDirty(),t.push(i));}if(this.history.commit(),t.length){this.setSelection(t.map(n=>n.id));for(let n of t)this.events.emit("drawing:created",{id:n.id});}return t}resolve(e){return e.map(t=>this.store.get(t)).filter(t=>t!=null)}captureStyle(e){let t=this.store.get(e);t&&this.lastStyle.set(t.type,{...t.style});}sync(){this.port?.syncDrawings(this.store.serialize().drawings);}onIntent(e){switch(e.kind){case "arm":this.setTool(e.type);break;case "draft":this.events.emit("drawing:draft",{doc:e.doc});break;case "create":{let t=this.store.serialize(),n=this.lastStyle.get(e.doc.type),i=n?{...e.doc.style,...n}:e.doc.style,o=pt({...e.doc,id:this.store.nextId(),style:i});if(!o)return;o.zIndex||(o.zIndex=this.startZ(o.type,o.paneId)??0),this.history.record(t),this.store.add(o),this.captureStyle(o.id),this.events.emit("drawing:created",{id:o.id});break}case "edit":{let t=this.store.serialize();this.store.update(e.doc.id,e.doc)&&(this.history.record(t),this.captureStyle(e.doc.id),this.events.emit("drawing:edited",{id:e.doc.id}));break}case "edit-many":{this.history.begin(this.store.serialize());for(let t of e.docs)this.store.update(t.id,t)&&(this.history.markDirty(),this.events.emit("drawing:edited",{id:t.id}));this.history.commit();break}case "select":this.setSelection(e.ids,e.additive);break;case "delete":this.deleteMany(e.ids);break;case "reorder":e.to==="front"?this.bringToFront(e.id):this.sendToBack(e.id);break;case "settings":this.events.emit("drawing:settings",{id:e.id});break;case "favorite":this.setFavorite(e.type,e.on);break;case "snap-mode":e.mode!==this.snapMode&&(this.snapMode=e.mode,this.events.emit("drawing:snap",{mode:e.mode}));break;case "stay-mode":e.on!==this.stayInDrawingMode&&(this.stayInDrawingMode=e.on,this.events.emit("drawing:stay",{on:e.on}));break;case "mode":e.mode!==this.mode&&(this.mode=e.mode,this.events.emit("drawing:mode",{mode:e.mode}));break;case "tool-finished":!this.stayInDrawingMode&&e.type!=="freehand"&&e.type!=="highlighter"&&this.setTool(null);break;case "undo":this.undo();break;case "redo":this.redo();break;case "duplicate":this.duplicate(e.ids);break;case "copy":this.copy(e.ids);break;case "paste":this.paste();break}}};var pp={D:864e5,W:6048e5,M:2592e6};function et(r){let e=r.trim();if(pp[e])return pp[e];let t=/^(\d+)\s*(m|h|d|w)?$/i.exec(e);if(t){let n=parseInt(t[1],10),i=(t[2]??"m").toLowerCase();return n*(i==="m"?6e4:i==="h"?36e5:i==="d"?864e5:6048e5)}return 36e5}var e0=5e3,t0=.25,n0=16,r0=15e3,Ic=["240","60","30","15","5","1"],da=class{constructor(e){this.deps=e;this.cache=new Map;this.listeners=new Set;}seriesInRange(e,t,n){if(!this.deps.canFetch())return {state:"unavailable",reason:"no-source"};let i=this.resolveTimeframe(e);if(typeof i!="string")return {state:"unavailable",reason:i.reason};let o=et(i),s=Math.min(t,n),a=Math.max(t,n);if(!(a>s)||!(o>0))return {state:"unavailable",reason:"not-lower"};if((a-s)/o>e0)return {state:"unavailable",reason:"too-wide"};let l=`${this.deps.marketKey()}|${i}`,c=this.cache.get(l)??[],d=c.find(u=>u.from<=s&&u.to>=a);if(d){if(d.pending)return this.loading(c,i,o,s,a);if(d.failedAt>0){if(Date.now()-d.failedAt<r0)return this.loading(c,i,o,s,a);c.splice(c.indexOf(d),1);}else return this.maybeRefresh(l,d,i,o,a),{state:"ready",bars:this.slice(d.bars,s,a),timeframe:i,barMs:o}}return this.fetchWindow(l,c,i,s,a),this.loading(c,i,o,s,a)}onUpdate(e){return this.listeners.add(e),()=>this.listeners.delete(e)}resolveTimeframe(e){let t=et(this.deps.chartTimeframe()),n=Ic[Ic.length-1];if(et(n)>=t)return {reason:"none-lower"};let i=e.trim()||"auto";if(i==="auto"){for(let o of Ic)if(et(o)<=t/4)return o;return n}return et(i)<t?i:{reason:"not-lower"}}loading(e,t,n,i,o){let s=new Map;for(let l of e)if(!(l.pending||l.failedAt>0)&&!(l.to<i||l.from>o))for(let c of this.slice(l.bars,i,o))s.set(c.time,c);if(s.size===0)return {state:"loading",timeframe:t,barMs:n};let a=[...s.values()].sort((l,c)=>l.time-c.time);return {state:"loading",timeframe:t,barMs:n,bars:a}}fetchWindow(e,t,n,i,o){if(t.some(l=>l.pending&&l.to>=i&&l.from<=o))return;let s=(o-i)*t0,a={from:i-s,to:o+s,bars:[],fetchedAt:0,pending:true,failedAt:0};t.push(a),this.cache.set(e,t),this.evict(),this.deps.fetchBars(n,{from:a.from,to:a.to}).then(l=>{a.bars=l,a.fetchedAt=Date.now(),a.pending=false,this.absorbOverlaps(e,a),this.fire();}).catch(()=>{a.pending=false,a.failedAt=Date.now(),this.fire();});}maybeRefresh(e,t,n,i,o){if(t.pending)return;let s=t.bars.length>0?t.bars[t.bars.length-1].time:t.from;o<s||Date.now()-t.fetchedAt<i||(t.pending=true,this.deps.fetchBars(n,{from:t.from,to:t.to}).then(a=>{t.bars=a,t.fetchedAt=Date.now(),t.pending=false,this.fire();}).catch(()=>{t.pending=false,t.fetchedAt=Date.now();}));}absorbOverlaps(e,t){let n=this.cache.get(e);if(n)for(let i=n.length-1;i>=0;i-=1){let o=n[i];if(o===t||o.pending||o.failedAt>0||o.to<t.from||o.from>t.to)continue;let s=new Map;for(let a of o.bars)s.set(a.time,a);for(let a of t.bars)s.set(a.time,a);t.bars=[...s.values()].sort((a,l)=>a.time-l.time),t.from=Math.min(t.from,o.from),t.to=Math.max(t.to,o.to),t.fetchedAt=Math.min(t.fetchedAt,o.fetchedAt||t.fetchedAt),n.splice(i,1);}}evict(){let e=0;for(let t of this.cache.values())e+=t.length;for(;e>n0;){let t=null,n=-1,i=1/0;for(let[s,a]of this.cache)for(let l=0;l<a.length;l+=1){let c=a[l];if(c.pending)continue;let d=c.fetchedAt||c.failedAt;d<i&&(t=s,n=l,i=d);}if(t==null)return;let o=this.cache.get(t);o.splice(n,1),o.length===0&&this.cache.delete(t),e-=1;}}slice(e,t,n){let i=[];for(let o of e)if(!(o.time<t)){if(o.time>n)break;i.push(o);}return i}fire(){for(let e of [...this.listeners])e();}};function Ei(r){return r.group!=null&&r.ticker===r.group}function mp(r){return `${(r.prefix??r.provider??"").toLowerCase()}:${(r.group??"").toUpperCase()}`}function i0(r,e){let t=mp(e);return r.filter(n=>n.group!=null&&!Ei(n)&&mp(n)===t)}function fp(r,e){let t=i0(r,e),n=t.filter(i=>i.default);return (n.length===1?n[0]:t[0])??null}var ft=r=>r.trim().toLowerCase(),Ft=r=>r.trim().toUpperCase();function gt(r){let e=r.trim(),t=/^(?:([A-Za-z0-9_.]+):)?(.+)$/.exec(e);if(!t)return {provider:null,ticker:e};let n=t[1]?ft(t[1]):null,i=t[2],o=i.lastIndexOf("."),s=o>0?i.slice(o+1):void 0;return {provider:n,ticker:i,ext:s}}var ua=class{constructor(){this.entries=new Map;this.changeListeners=new Set;this.waits=new Set;this.unresolvedCbs=new Set;}register(e,t){let n=ft(e),i={name:n,provider:t,index:null,prefixIndex:null,byTicker:null,descriptors:[],settled:false,settle:Promise.resolve()};return this.entries.set(n,i),i.settle=this.buildIndex(i),queueMicrotask(()=>this.notify(false)),i.settle}async buildIndex(e){await Promise.resolve();try{if(e.provider.listSymbols){let t=await e.provider.listSymbols();e.descriptors=t,e.index=new Set(t.map(n=>Ft(n.ticker))),e.byTicker=new Map(t.map(n=>[Ft(n.ticker),n])),e.prefixIndex=new Map;for(let n of t)n.prefix&&e.prefixIndex.set(`${ft(n.prefix)}:${Ft(n.ticker)}`,n);}}catch{e.index=null;}finally{e.settled=true,this.notify(true);}}notify(e){for(let t of [...this.changeListeners])t(e);}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}unregister(e){this.entries.delete(ft(e)),this.notify(false);}has(e){return this.entries.has(ft(e))}get(e){return this.entries.get(ft(e))?.provider}names(){return [...this.entries.keys()]}parse(e){return gt(e)}resolve(e,t={}){let{provider:n,ticker:i}=this.parse(e);if(n){if(this.entries.has(n)){let a=this.entries.get(n).byTicker?.get(Ft(i));return {provider:n,ticker:a!=null&&Ei(a)?this.loadableTicker(n,a):i}}let s=`${n}:${Ft(i)}`;for(let a of this.candidateOrder(t.default)){let l=this.entries.get(a).prefixIndex?.get(s);if(l)return {provider:a,ticker:this.loadableTicker(a,l)}}return null}let o=Ft(i);for(let s of this.candidateOrder(t.default)){let a=this.entries.get(s);if(a.index?.has(o)){let l=a.byTicker?.get(o);return {provider:s,ticker:l!=null&&Ei(l)?this.loadableTicker(s,l):i}}}if(t.lenient&&this.entries.size===1){let s=this.names()[0],a=this.entries.get(s);if(a.settled&&a.index==null)return {provider:s,ticker:i}}return null}loadableTicker(e,t){return Ei(t)?fp(this.entries.get(e)?.descriptors??[],t)?.ticker??t.ticker:t.ticker}whenResolvable(e,t={}){let n=this.resolve(e,{...t,lenient:true});return n?Promise.resolve(n):new Promise(i=>{let o=this.onChange(a=>{let l=this.resolve(e,{...t,lenient:true});l?(s(),i(l)):a&&this.allSettled()&&this.reportUnresolved(e);}),s=()=>{o(),this.waits.delete(s);};this.waits.add(s);})}allSettled(){for(let e of this.entries.values())if(!e.settled)return false;return true}cancelWaits(){for(let e of [...this.waits])e();}onUnresolved(e){return this.unresolvedCbs.add(e),()=>this.unresolvedCbs.delete(e)}reportUnresolved(e){let t=this.names();console.warn(`[vela] symbol "${e}" not yet resolvable \u2014 registered providers: [${t.join(", ")||"none"}]. Register a provider that serves it.`);for(let n of this.unresolvedCbs)n({symbol:e,providers:t});}candidateOrder(e){let t=this.names();if(e){let n=ft(e);if(this.entries.has(n))return [n,...t.filter(i=>i!==n)]}return t}displayPrefixOf(e){return this.entries.get(e.provider)?.byTicker?.get(Ft(e.ticker))?.prefix??e.provider}canonicalSymbol(e){let t=this.entries.get(e.provider)?.byTicker?.get(Ft(e.ticker));return `${t?.prefix??e.provider}:${t?.ticker??e.ticker}`}symbolIconOf(e){let t=e.provider?ft(e.provider):[...this.entries.keys()][0],n=t!==void 0?this.entries.get(t):void 0;try{return n?.provider.resolveSymbolIcon?.(e)??void 0}catch{return}}symbolIcon(e){if(!e)return;let t=this.entries.get(e.provider)?.byTicker?.get(Ft(e.ticker));return this.symbolIconOf({...t??{ticker:e.ticker},provider:t?.provider??e.provider})}symbolsOf(e){return e!=null?this.entries.get(ft(e))?.descriptors??[]:[...this.entries.entries()].flatMap(([t,n])=>n.descriptors.map(i=>({...i,provider:t})))}infoOf(e){let t=ft(e),n=this.entries.get(t);if(!n)return {name:t,capabilities:{enumerate:false,stream:false,symbolInfo:false}};let i=n.provider;return i.info?.()??{name:n.name,capabilities:{enumerate:!!i.listSymbols,stream:!!i.subscribe,symbolInfo:!!i.getSymbolInfo}}}indexReady(){return Promise.all([...this.entries.values()].map(e=>e.settle)).then(()=>{})}};function mr(r){switch(r.kind){case "row":return {label:r.label,toggle:r.toggle,controls:r.controls,when:r.when};case "toggle":{let e=[];r.number&&e.push({kind:"number",...r.number});for(let t of r.colors??[])e.push({kind:"color",...t});return r.width&&e.push({kind:"width",...r.width}),{label:r.label,toggle:{key:r.key,defval:r.defval},controls:e,when:r.when}}case "number":return {label:r.label,controls:[{kind:"number",key:r.key,label:r.label,defval:r.defval,min:r.min,max:r.max,step:r.step}],when:r.when};case "color":return {label:r.label,controls:[{kind:"color",key:r.key,label:r.label,defval:r.defval}],when:r.when};case "select":return {label:r.label,controls:[{kind:"select",key:r.key,label:r.label,options:r.options,defval:r.defval}],when:r.when};case "range":return {label:r.label,controls:[{kind:"number",key:r.minKey,label:`${r.label} \u2014 min`,defval:r.defval,min:r.min,max:r.max,step:r.step,placeholder:r.placeholder},{kind:"hint",text:"\u2013"},{kind:"number",key:r.maxKey,label:`${r.label} \u2014 max`,defval:r.defval,min:r.min,max:r.max,step:r.step,placeholder:r.placeholder}],when:r.when}}}function Pi(r){if(r.kind==="heading"||r.kind==="header")return [];let e=mr(r),t=[];e.toggle&&t.push({key:e.toggle.key,type:"boolean",defval:e.toggle.defval});for(let n of e.controls)n.kind!=="hint"&&(n.kind==="color"||n.kind==="select"?t.push({key:n.key,type:"string",defval:n.defval}):t.push({key:n.key,type:"number",defval:n.defval}));return t}function Fn(r,e){return r?(Array.isArray(r)?r:[r]).every(n=>n.anyOf?n.anyOf.some(i=>i===e[n.key]):e[n.key]===n.equals):true}var Li=new Map;function Ac(r){Li.set(r.id,r);}function o0(r){Li.delete(r);}function Nt(r){return typeof r=="string"?Li.get(r):void 0}function tt(){return [...Li.values()]}function Rc(){return [...Li.values()].filter(r=>r.tickerModifier??r.barTransform!=null).map(r=>r.id)}function fr(r){return Nt(r)?.barTransform??null}function gp(r){let e=r.lastIndexOf(";");if(e<=0||e===r.length-1)return {symbol:r,modifier:null,transform:null};let t=r.slice(e+1).toLowerCase();return t!=="standard"&&!Rc().includes(t)?{symbol:r,modifier:null,transform:null}:{symbol:r.slice(0,e),modifier:t,transform:fr(t)}}var bt={background:"#151619",textColor:"#b2b5be",gridColor:"#20222c",borderColor:"#2a2b30",upColor:q,downColor:X,fontFamily:"sans-serif"},Mi={background:"#ffffff",textColor:"#1e293b",gridColor:"#cccccc",borderColor:"#d4dae3",upColor:q,downColor:X,fontFamily:"sans-serif"};function gr(r){return !r||r==="dark"?bt:r==="light"?Mi:r}var s0=150,a0=1e3,l0=300,c0=5e3,bp=1e4,d0=20,u0=1.5,vp=5e3,ha=class r{constructor(e,t,n,i,o,s){this.renderer=t;this.feed=n;this.config=o;this.dataControl=s;this.events=new bn;this.registry=new Xo;this.paneOrder=["price"];this.collapsedPanes=new Set;this.maximizedPaneId=null;this.paneActionUnsub=null;this.handles=new Map;this.engines=new Map;this.live=null;this.bars=[];this.rawBars=[];this.barTransform=null;this.typeEngines=new Map;this.typeSettings=new Map;this.activeEngineStyle=null;this.priceStyle="candles";this.unresolvedUnsub=null;this.visibleRange=null;this.viewportUnsub=null;this.viewportTimer=null;this.healing=false;this.healBuffer=[];this.lastHealAt=0;this.onVisible=null;this.barCause="tick";this.historyState="complete";this.generation=0;this.progressiveAbort=null;this.supersedeWaiters=[];this.historyCompleted=false;this.historyCompletePromise=new Promise(e=>{this.resolveHistoryComplete=e;});this.switchingMarket=false;this.loadingUp=false;this.volumeOptedOut=false;this.contextEmitAt=new Map;this.runEmitAt=new Map;for(let c of i)this.registerEngine(c.language,c);this.defaultLanguage=o.defaultLanguage,this.renderer.mount(e,o.theme),this.renderer.onInputChange(c=>c.kind==="prop"?this.applyProps(c.indicatorId,{[c.key]:c.value}):this.applyInputs(c.indicatorId,{[c.key]:c.value})),this.renderer.onRemoveIndicator(c=>this.removeIndicator(c)),this.renderer.onToggleIndicatorVisible?.((c,d)=>this.setVisible(c,d)),this.paneActionUnsub=this.renderer.onPaneAction?.(c=>this.handlePaneAction(c))??null,this.renderer.onChartTypeSettingsChange?.((c,d)=>{this.typeSettings.set(c,d),this.typeEngines.get(c)?.onSettings?.(d);}),this.renderer.onMoveIndicator?.((c,d)=>this.moveIndicator(c,d)),this.renderer.onThemeSelect?.(c=>this.setTheme(gr(c))),this.viewportUnsub=this.renderer.onViewportChange(c=>this.onViewportChange(c)),this.renderer.onPriceStyleChange?.(c=>this.syncPriceStyle(c));let a=this.renderer.readFeature("priceStyle");typeof a=="string"&&(this.priceStyle=a),this.barTransform=fr(a);let l=new da({fetchBars:(c,d)=>this.fetchSeries(this.config.market.symbol??"",c,d),canFetch:()=>!!this.feed.loadRange&&!this.config.market.data?.length&&!!this.config.market.symbol,chartTimeframe:()=>this.config.market.timeframe??"60",marketKey:()=>`${this.config.market.symbol??""}|${this.config.market.session??""}`});this.drawings=new ca(this.renderer,this.events,o.drawings,l),this.unresolvedUnsub=this.feed.onUnresolved?.(c=>{this.endLoad(),this.events.emit("data:unresolved",c);})??null,this.readyPromise=this.init(),Nt(a)?.dataEngine&&this.syncChartTypeEngine(a);}currentVisibleRange(){if(this.visibleRange)return this.visibleRange;let e=this.renderer.getVisibleRange();return e?{left:e.from,right:e.to}:void 0}engineFor(e){let t=e??this.defaultLanguage,n=this.engines.get(t);if(!n)throw new Error(`[vela] no scripting engine registered for language "${t}". Vela ships none \u2014 install one (Pine Script: @luxalgo/vela-pinets) and register it before addIndicator, e.g. chart.registerEngine('pine', new PineEngine()).`);return n}market(){return {symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",symbolInfo:this.feed.symbolInfo?.(this.config.market),chartStyle:this.priceStyle}}async fetchSeries(e,t,n){let i=gp(e),o={symbol:i.symbol,timeframe:t},s=await(this.feed.loadRange?this.feed.loadRange(o,n):this.feed.load({...o,bars:n.limit}));return i.transform?i.transform.full(s):s}onViewportChange(e){this.visibleRange={left:e.from,right:e.to},this.events.emit("viewport:changed",{from:e.from,to:e.to}),this.viewportTimer!=null&&clearTimeout(this.viewportTimer),this.viewportTimer=setTimeout(()=>{if(this.viewportTimer=null,this.switchingMarket)return;let t=this.visibleRange;if(t){for(let n of this.registry.all())!n.renderHandle||n.hidden||(n.session&&n.prepared?.reactsToViewport?(n.pendingCause="viewport",n.session.setVisibleRange(t)):n.native?.descriptor.reactsToViewport&&n.native.instance.onViewport({from:t.left,to:t.right}));this.activeEngineStyle&&this.typeEngines.get(this.activeEngineStyle)?.onViewport?.({from:t.left,to:t.right});}},s0);}async init(){let e=this.bumpGeneration();this.beginLoad(true),await this.loadMarket(e,{firstLoad:true}),this.generation===e&&(this.startLive(),this.events.emit("ready",void 0));}bumpGeneration(){let e=++this.generation;this.progressiveAbort?.abort(),this.progressiveAbort=null;for(let t of this.supersedeWaiters.splice(0))t();return e}beginLoad(e){if(this.loadingUp)return;this.loadingUp=true,this.renderer.setLoading?.(true);let t=this.config.market;this.events.emit("load:start",{symbol:t.symbol??"TEST",timeframe:t.timeframe??"60",firstLoad:e});}endLoad(){if(!this.loadingUp)return;this.loadingUp=false,this.renderer.setLoading?.(false);let e=this.config.market;this.events.emit("load:end",{symbol:e.symbol??"TEST",timeframe:e.timeframe??"60",bars:this.bars.length});}async loadMarket(e,t){try{await this.loadMarketInner(e,t);}finally{this.generation===e&&this.endLoad();}}async loadMarketInner(e,t){let n=this.config.market,i=n.bars??500,o=n.visibleRange,s=!n.data?.length&&o==null&&i>c0,a=false;if(!n.data?.length&&o==null&&this.feed.loadProgressive){let l=false,c=(u,h)=>{this.generation!==e||!h&&u.length===0||!l&&!h&&u.length<Math.min(i,d0)||(this.setBarSeries(u,l?{preserveView:true}:void 0),!l&&u.length>0&&(l=true,t.firstLoad&&this.activateBarLayers(),h||(this.historyState="backfill")));},d=new AbortController;this.progressiveAbort=d,a=await new Promise(u=>{let h=false,p=m=>{h||(h=true,u(m));};d.signal.addEventListener("abort",()=>p(true),{once:true}),this.feed.loadProgressive(n,m=>{c(m,false),l&&p(true);},{signal:d.signal}).then(m=>{if(this.progressiveAbort===d&&(this.progressiveAbort=null),m==null)return p(false);if(this.generation!==e)return p(true);c(m,true),this.completeHistory(m.length>=i?"depth":"genesis"),p(true);}).catch(()=>{this.progressiveAbort===d&&(this.progressiveAbort=null),this.generation===e&&this.completeHistory("aborted"),p(true);});});}if(!a)if(s&&this.feed.loadRange){let l=await this.feed.load({...n,bars:Math.min(i,bp)});if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers(),l.length>0&&i>l.length?(this.historyState="backfill",this.backfillHistory(e,i)):this.completeHistory("depth");}else if(s){let l=await this.feed.load({...n,bars:l0});if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers();let c=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(c,{preserveView:true}),this.completeHistory("depth");}else {let l=await this.feed.load(n);if(this.generation!==e)return;this.setBarSeries(l),t.firstLoad&&this.activateBarLayers(),this.completeHistory("depth");}o!=null&&(typeof o=="string"?this.setVisibleRangePreset(o):this.renderer.setVisibleRange(o)),this.refreshPriceFormat(),this.ensurePriceFormat();}startLive(){this.config.live&&(this.live=new qo(this.feed,this.config.market,e=>this.onBar(e)),this.live.start(),typeof document<"u"&&(this.onVisible=()=>{if(document.visibilityState!=="visible")return;let e=this.bars[this.bars.length-1];!e||this.healing||!this.canHeal()||Date.now()-this.lastHealAt<=vp||this.healGap(e.time);},document.addEventListener("visibilitychange",this.onVisible)));}stopLive(){this.live?.stop(),this.live=null,this.onVisible&&typeof document<"u"&&document.removeEventListener("visibilitychange",this.onVisible),this.onVisible=null,this.healing=false,this.healBuffer=[],this.lastHealAt=0;}resetHistoryTracking(){this.resolveHistoryComplete(),this.historyCompleted=false,this.historyState="complete",this.historyCompletePromise=new Promise(e=>{this.resolveHistoryComplete=e;});}marketSnapshot(){let e=this.config.market;return {symbol:e.symbol,provider:gt(e.symbol??"").provider??void 0,timeframe:e.timeframe,bars:e.bars,session:e.session,offline:e.data!==void 0}}async setMarket(e){let t=this.config.market,n=e.symbol!==void 0&&e.symbol!==t.symbol||e.timeframe!==void 0&&e.timeframe!==t.timeframe||e.session!==void 0&&e.session!==t.session||e.data!==void 0,i=e.bars!==void 0&&e.bars!==t.bars,o=i&&!n&&this.rawBars.length>0&&!t.data?.length&&((e.bars??0)<=this.rawBars.length||typeof this.feed.loadRange=="function");if(!n&&!i){typeof e.visibleRange=="string"?this.setVisibleRangePreset(e.visibleRange):e.visibleRange&&this.renderer.setVisibleRange(e.visibleRange);return}let s={symbol:t.symbol??"TEST",timeframe:t.timeframe??"60"},l=n&&e.session!==void 0&&e.data===void 0&&(e.symbol===void 0||e.symbol===t.symbol)&&(e.timeframe===void 0||e.timeframe===t.timeframe)&&e.visibleRange===void 0?this.currentVisibleRange():void 0,c=l?this.rawBars.filter(u=>u.time>=l.left&&u.time<=l.right).length:0,d=this.bumpGeneration();this.switchingMarket=true;try{if(this.stopLive(),this.viewportTimer!=null&&(clearTimeout(this.viewportTimer),this.viewportTimer=null),this.visibleRange=null,this.resetHistoryTracking(),e.symbol!==void 0&&(t.symbol=e.symbol),e.timeframe!==void 0&&(t.timeframe=e.timeframe),e.bars!==void 0&&(t.bars=e.bars),e.session!==void 0&&(t.session=e.session),l){let u=Math.min(Math.ceil((Date.now()-l.left)/this.barIntervalMs())+50,5e3);u>(t.bars??500)&&(t.bars=u);}if(e.data!==void 0?t.data=e.data:e.symbol!==void 0&&delete t.data,t.visibleRange=e.visibleRange??(l?{from:l.left,to:l.right}:void 0),n&&(this.beginLoad(!1),this.setBarSeries([],{clearing:!0}),this.activeEngineStyle&&(this.typeEngines.get(this.activeEngineStyle)?.suspend(),this.renderer.setNativeData?.(this.activeEngineStyle,void 0),this.renderer.setNativeData?.(`${this.activeEngineStyle}-pending`,[]))),o?this.extendDepth(d,t.bars??500):await Promise.race([this.loadMarket(d,{firstLoad:!1}),new Promise(u=>this.supersedeWaiters.push(u))]),this.generation!==d)return}finally{this.generation===d&&(this.switchingMarket=false);}if(l&&c>=2&&this.rawBars.length>0){let u=this.rawBars,h=u.length-1;for(;h>0&&u[h].time>l.right;)h-=1;let p=u[Math.max(0,h-(c-1))].time;this.renderer.setVisibleRange({from:p,to:Math.max(l.right,u[h].time+1)});}o||(this.restartNativeIndicators(),this.restartChartTypeEngine(),this.reexecuteIndicators()),this.startLive(),n&&this.events.emit("market:changed",{symbol:t.symbol??"TEST",timeframe:t.timeframe??"60",prev:s});}restartNativeIndicators(){for(let e of this.registry.all())if(e.native)if(e.native.instance.stop(),e.native.instance=e.native.descriptor.create(),e.pendingStructural=true,e.hidden)e.native.stale=true;else {let t=this.handles.get(e.id);t&&this.startNativeIndicator(e.id,t);}}restartChartTypeEngine(){for(let e of this.typeEngines.values())e.stop();this.typeEngines.clear(),this.activeEngineStyle&&this.startChartTypeEngine(this.activeEngineStyle);}activateBarLayers(){this.maybeAutoAddVolume();}extendDepth(e,t){if(this.rawBars.length>t){this.setBarSeries(this.rawBars.slice(this.rawBars.length-t),{preserveView:true}),this.completeHistory("depth");return}if(this.rawBars.length===t){this.completeHistory("depth");return}this.historyState="backfill",this.backfillHistory(e,t);}async backfillHistory(e,t){try{for(;this.generation===e&&this.rawBars.length<t&&this.rawBars.length>0;){let n=t-this.rawBars.length,i=bp,o=await this.feed.loadRange(this.config.market,{to:this.rawBars[0].time,limit:Math.min(i,n)+1});if(this.generation!==e)return;let s=this.rawBars[0].time,a=o.filter(l=>l.time<s);if(a.length===0){this.completeHistory("genesis");return}for(let l=1;l<a.length;l+=1)if(a[l].time<=a[l-1].time){console.warn("[vela] non-monotonic history chunk \u2014 stopping the backfill"),this.completeHistory("aborted");return}this.setBarSeries([...a,...this.rawBars],{preserveView:!0}),this.notifySessionsBars("backfill"),this.events.emit("history:progress",{loaded:this.rawBars.length,target:t});}this.generation===e&&this.completeHistory("depth");}catch(n){console.warn(`[vela] history backfill failed \u2014 keeping ${this.rawBars.length} bars (${n instanceof Error?n.message:String(n)})`),this.generation===e&&this.completeHistory("aborted");}}completeHistory(e){this.historyCompleted||(this.historyCompleted=true,this.historyState="complete",this.notifySessionsBars("complete"),this.events.emit("history:complete",{reason:e,oldestTime:this.rawBars[0]?.time??0,barsLoaded:this.rawBars.length}),this.resolveHistoryComplete());}historyComplete(){return this.historyCompletePromise}qualifiedSymbol(){let e=this.config.market;return e.symbol?e.symbol:null}refreshPriceFormat(){if(!this.renderer.setPricePrecision)return;let e=this.feed.symbolInfo?.(this.config.market)?.mintick;this.renderer.setPricePrecision(typeof e=="number"&&e>0?e:void 0);}async ensurePriceFormat(){if(!this.renderer.setPricePrecision)return;let e=this.qualifiedSymbol();if(e)try{await this.dataControl.symbolInfo(e),this.refreshPriceFormat();}catch{}}maybeAutoAddVolume(){!this.config.volume||this.volumeOptedOut||!this.renderer.setNativeData||di("volume")&&this.addNativeIndicator("volume");}syncPriceStyle(e){typeof e=="string"&&(this.priceStyle=e),this.syncBarTransform(e),this.syncChartTypeEngine(e);}syncChartTypeEngine(e){let t=typeof e=="string"?e:null,i=Nt(t)?.dataEngine?t:null;i!==this.activeEngineStyle&&(this.activeEngineStyle&&this.typeEngines.get(this.activeEngineStyle)?.suspend(),this.activeEngineStyle=i,i&&this.startChartTypeEngine(i));}async startChartTypeEngine(e){if(!this.renderer.setNativeData||(await this.readyPromise,this.activeEngineStyle!==e))return;let t=this.typeEngines.get(e);if(t){t.resume();return}let n=Nt(e);if(!n?.dataEngine)return;let i=n.dataEngine();this.typeEngines.set(e,i);let o=this.typeSettings.get(e);o&&i.onSettings?.(o),i.start({symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",live:this.config.live??false,session:this.config.market.session,bars:()=>this.bars,data:this.dataControl,pushData:s=>this.renderer.setNativeData?.(e,s),pushPending:s=>this.renderer.setNativeData?.(`${e}-pending`,s)});}syncBarTransform(e){let t=fr(e);t!==this.barTransform&&(this.barTransform=t,this.rawBars.length!==0&&(this.bars=t?t.full(this.rawBars):this.rawBars,this.renderer.setBars(this.bars,{preserveView:true}),this.reexecuteIndicators()));}reexecuteIndicators(){for(let e of this.registry.all()){if(e.hidden||!e.session)continue;e.session.stop(),e.session=void 0,e.pendingStructural=true,e.pendingCause="market",this.setLoading(e,true);let t=this.handles.get(e.id);t&&this.executeIndicator(e.id,t);}}onBar(e){if(this.healing){this.healBuffer.push(e);return}let t=this.rawBars[this.rawBars.length-1];if(t&&this.canHeal()&&e.time>t.time+this.barIntervalMs()*u0&&Date.now()-this.lastHealAt>vp){this.healBuffer.push(e),this.healGap(t.time);return}this.applyBar(e);}setBarSeries(e,t){this.rawBars=e,this.bars=this.barTransform?this.barTransform.full(e):e,this.renderer.setBars(this.bars,{preserveView:t?.preserveView}),!t?.clearing&&this.bars.length>0&&this.endLoad();}applyBar(e,t=true){let n=this.rawBars[this.rawBars.length-1],i=e;if(n&&e.time===n.time)this.rawBars[this.rawBars.length-1]=e,this.barCause="tick",this.barTransform&&(i=this.barTransform.next(e,this.bars[this.bars.length-2]),this.bars[this.bars.length-1]=i);else if(!n||e.time>n.time)this.rawBars.push(e),this.barCause="bar",this.barTransform&&(i=this.barTransform.next(e,this.bars[this.bars.length-1]),this.bars.push(i));else return;this.renderer.updateBar(i),this.events.emit("bar",e),t&&this.notifySessionsBars(this.historyState==="backfill"?"backfill":void 0);}notifySessionsBars(e){if(this.switchingMarket)return;let t=e?"history":this.barCause;for(let n of this.registry.all())!n.renderHandle||n.hidden||(n.session?(n.pendingCause=t,n.session.notifyBars(e)):n.native&&n.native.instance.onBars());}canHeal(){return !!this.feed.loadRange&&!this.config.market.data?.length}barIntervalMs(){return et(this.config.market.timeframe??"60")}async healGap(e){let t=this.generation;this.healing=true,this.lastHealAt=Date.now();try{let n=await this.feed.loadRange(this.config.market,{from:e});if(this.generation!==t)return;for(let i of n)this.applyBar(i,!1);}catch{}finally{if(this.generation===t){this.healing=false;let n=this.healBuffer;this.healBuffer=[];for(let i of n)this.applyBar(i,false);this.notifySessionsBars(this.historyState==="backfill"?"backfill":void 0);}}}registerEngine(e,t){let n=this.engines.get(e);n&&n!==t&&console.warn(`[vela] re-registering scripting engine for language "${e}"; replacing ${n.constructor.name} with ${t.constructor.name}.`),this.engines.set(e,t);}addIndicator(e,t={}){let n=this.registry.nextId(),i=t.title??"Indicator",o=new or(n,i,this,e);return this.handles.set(n,o),this.registry.add({id:n,title:i,source:e,options:t,inputValues:{...t.inputs??{}},propValues:{...t.props??{}}}),this.startIndicator(n,e,t,o),o}addNativeIndicator(e,t={}){let n=this.registry.all().find(c=>c.native?.type===e);if(n)return this.handles.get(n.id)??new or(n.id,n.title,this);let i=di(e),o=this.registry.nextId("native"),s=i?.title??e,a=new or(o,s,this);if(this.handles.set(o,a),!i)return console.warn(`[vela] addNativeIndicator("${e}") \u2014 no native indicator registered for this type.`),a;let l={...i.defaultInputs(),...t.inputs??{}};return this.registry.add({id:o,title:s,source:e,inputValues:l,propValues:{},native:{type:e,instance:i.create(),descriptor:i}}),a.setSchema(i.inputsSchema()),this.startNativeIndicator(o,a),a}presentNativeIndicators(){return this.registry.all().map(e=>e.native?.type).filter(e=>!!e)}async availableNativeIndicators(){let e=this.qualifiedSymbol(),t=new Set(this.presentNativeIndicators());return Promise.all(jo().map(async n=>({type:n.type,title:n.title,supported:await this.isNativeSupported(n,e),present:t.has(n.type),beta:n.beta})))}async isNativeSupported(e,t){if(!e.isSupported)return true;if(!t)return false;try{return await e.isSupported(t,this.dataControl)}catch{return false}}applyInputs(e,t){let n=this.registry.get(e);!n||!n.session&&!n.native||(n.inputValues={...n.inputValues,...t},n.renderHandle&&this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues),n.pendingStructural=true,!n.hidden&&!n.native&&this.setLoading(n,true),n.pendingCause="inputs",n.session?n.session.update(n.inputValues):n.native&&!n.hidden&&n.native.instance.setInputs(n.inputValues),this.events.emit("indicator:inputs",{id:e}));}inputValuesOf(e){return {...this.registry.get(e)?.inputValues}}propValuesOf(e){return {...this.registry.get(e)?.propValues}}applyProps(e,t){let n=this.registry.get(e);n?.session&&(n.propValues={...n.propValues,...t},n.renderHandle&&this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues,n.propValues),n.pendingStructural=true,n.hidden||this.setLoading(n,true),n.pendingCause="inputs",n.session.update(n.inputValues,n.propValues),this.events.emit("indicator:inputs",{id:e}));}listIndicators(){return [...this.handles.values()]}getIndicatorContext(e,t){return this.registry.get(e)?.session?.getContext?.(t)??Promise.resolve(null)}removeIndicator(e){let t=this.registry.remove(e);t?.native?.type==="volume"&&(this.volumeOptedOut=true),t?.session?.stop(),t?.native?.instance.stop(),this.handles.delete(e),t?.renderHandle&&this.renderer.removeIndicator(t.renderHandle);let n=t?.model?.paneId;n&&n!=="price"&&!this.paneStillUsed(n)&&(this.renderer.removePane(n),this.forgetPane(n),this.events.emit("pane:changed",void 0)),this.events.emit("indicator:removed",{id:e});}setVisible(e,t){let n=this.registry.get(e);if(!(!n||n.hidden===!t)){if(n.hidden=!t,this.handles.get(e)?.setVisibleState(t),!t)n.session?.stop(),n.session=void 0,n.native?.instance.suspend(),n.renderHandle&&this.renderer.setIndicatorVisible?.(n.renderHandle,false);else if(n.renderHandle&&this.renderer.setIndicatorVisible?.(n.renderHandle,true),n.pendingStructural=true,n.native)if(n.native.stale){n.native.stale=false;let i=this.handles.get(e);i&&this.startNativeIndicator(e,i);}else n.native.instance.resume();else {this.setLoading(n,true);let i=this.handles.get(e);i&&this.executeIndicator(e,i);}this.events.emit("indicator:visibility",{id:e,visible:t});}}ready(){return this.readyPromise}inspect(){let e=[...this.registry.all()].filter(t=>!t.loading).sort((t,n)=>(n.native?1:0)-(t.native?1:0));return Eh(e.map(t=>t.model).filter(t=>t!=null))}resize(){this.renderer.resize();}setTheme(e){let t=this.config.theme;Object.keys(e).every(n=>e[n]===t[n])||(this.config.theme=e,this.renderer.setTheme(e),this.events.emit("theme:changed",e));}getVisibleRange(){return this.renderer.getVisibleRange()}setVisibleRange(e){this.renderer.setVisibleRange(e);}panBy(e){if(this.renderer.panBy){this.renderer.panBy(e);return}let t=this.renderer.getVisibleRange();if(!t)return;let n=(t.to-t.from)*e;this.renderer.setVisibleRange({from:t.from+n,to:t.to+n});}setVisibleRangePreset(e){let t=Ph(e,this.bars);t&&this.renderer.setVisibleRange(t);}destroy(){this.bumpGeneration(),this.resolveHistoryComplete(),this.stopLive(),this.viewportTimer!=null&&clearTimeout(this.viewportTimer),this.viewportUnsub?.(),this.paneActionUnsub?.();for(let e of this.registry.all())e.session?.stop(),e.native?.instance.stop();for(let e of this.typeEngines.values())e.stop();this.typeEngines.clear(),this.activeEngineStyle=null,this.unresolvedUnsub?.(),this.unresolvedUnsub=null,this.feed.destroy?.(),this.drawings.destroy(),this.renderer.destroy(),this.events.clear();}async startIndicator(e,t,n,i){try{if(await this.readyPromise,!this.registry.get(e))return;await h0();let o=this.registry.get(e);if(!o)return;let s=this.engineFor(n.language);o.engine=s;let a=await s.prepare(t,e);o.prepared=a;let l={};for(let d of a.inputs)l[d.key]=d.defval;o.inputValues={...l,...o.inputValues},i.setSchema(a.inputs);let c={};for(let d of a.props??[])c[d.key]=d.defval;o.propValues={...c,...o.propValues},i.setPropsSchema(a.props??[]),this.mountLoadingPlaceholder(e,o),this.executeIndicator(e,i);}catch(o){this.fail(e,i,o);}}executeIndicator(e,t){let n=this.registry.get(e);if(!n||!n.engine||!n.prepared||n.hidden)return;let i=this.config.live&&!n.prepared.reactsToViewport&&n.engine.capabilities.streaming?"live":"static";n.session=n.engine.execute({prepared:n.prepared,market:this.market(),bars:this.bars,getBars:()=>this.bars,fetchSeries:(o,s,a)=>this.fetchSeries(o,s,a),inputs:n.inputValues,props:n.propValues,visibleRange:this.currentVisibleRange(),mode:i,historyState:this.historyState},{onModel:o=>{let s=!n.announced,a=n.pendingCause??"history";this.applyModel(e,o)&&(n.pendingCause=void 0,this.emitContextChanged(e),this.emitScriptRun(e,a,s));},onAlert:o=>{let s=n.options?.title??n.prepared?.meta.title??n.title;this.events.emit("alert",{...o,indicator:s}),t.emit("alert",{id:o.id,message:o.message,title:o.title,time:o.time});},onWarning:o=>this.events.emit("warning",o),onError:o=>this.fail(e,t,o)}),this.emitContextChanged(e);}async startNativeIndicator(e,t){try{await this.readyPromise;let n=this.registry.get(e);if(!n?.native||n.hidden)return;let i={symbol:this.config.market.symbol??"TEST",timeframe:this.config.market.timeframe??"60",live:this.config.live,session:this.config.market.session,bars:()=>this.bars,data:this.dataControl,emit:o=>this.applyModel(e,this.buildNativeModel(n,o)),pushData:o=>this.renderer.setNativeData?.(n.native.type,o),setStatus:o=>{n.renderHandle&&!n.hidden&&this.renderer.setIndicatorStatus?.(n.renderHandle,o);}};n.native.instance.start(i,n.inputValues);}catch(n){this.fail(e,t,n);}}buildNativeModel(e,t){let n=e.native.descriptor;return {id:e.id,title:e.title,...n.shortTitle?{shorttitle:n.shortTitle}:{},overlay:n.overlay,paneHint:n.paneHint,native:{type:e.native.type},...t.paneAxis!=null?{paneAxis:t.paneAxis}:{},series:t.series??[],fills:t.fills??[],backgrounds:t.backgrounds??[],priceLines:t.priceLines??[],...t.lines?{lines:t.lines}:{},...t.boxes?{boxes:t.boxes}:{},...t.labels?{labels:t.labels}:{},...t.polylines?{polylines:t.polylines}:{},...t.linefills?{linefills:t.linefills}:{},...t.tables?{tables:t.tables}:{},inputs:n.inputsSchema(),inputValues:e.inputValues}}mountLoadingPlaceholder(e,t){if(t.renderHandle||t.hidden||!t.prepared)return;let n=t.prepared.meta,i={id:e,title:t.options?.title??n.title,overlay:n.overlay,paneHint:n.overlay?"price":"new",series:[],fills:[],backgrounds:[],priceLines:[],inputs:t.prepared.inputs,inputValues:t.inputValues,...t.prepared.props?{props:t.prepared.props,propValues:t.propValues}:{}},o=this.routePane(e,i,t.options??{});this.placeModel(i,e,o),t.model=i,this.ensurePaneFor(o),t.renderHandle=this.renderer.mountIndicator(i),t.pendingStructural=true,this.setLoading(t,true);}setLoading(e,t){e.loading=t,e.renderHandle&&!e.hidden&&this.renderer.setIndicatorStatus?.(e.renderHandle,t?"loading":"idle");}ensurePaneFor(e){this.paneOrder.includes(e)||this.paneOrder.push(e),this.renderer.ensurePane({id:e,kind:e==="price"?"price":"study",order:this.paneOrder.indexOf(e)});}paneStillUsed(e){for(let t of this.registry.all())if(t.model?.paneId===e)return true;return false}forgetPane(e){let t=this.paneOrder.indexOf(e);t>0&&this.paneOrder.splice(t,1),this.collapsedPanes.delete(e),this.maximizedPaneId===e&&(this.maximizedPaneId=null);}paneManagementSupported(){return this.renderer.capabilities.paneManagement===true&&typeof this.renderer.setIndicatorPane=="function"}listPanes(){let e=new Map;for(let n of this.registry.all()){let i=n.model;if(!i)continue;let o=i.paneId??"price";e.has(o)||e.set(o,[]),e.get(o).push({id:n.id,title:i.title||n.title,ownScale:i.ownScale===true});}let t=[];for(let n of this.paneOrder)n!=="price"&&!e.has(n)||t.push({id:n,kind:n==="price"?"price":"study",order:t.length,collapsed:this.collapsedPanes.has(n),maximized:this.maximizedPaneId===n,indicators:e.get(n)??[]});return t}movePane(e,t){if(e==="price")return;let n=this.existingPaneIds(),i=n.indexOf(e);if(i<0)return;let o=t==="up"?i-1:i+1;o<=0||o>=n.length||([n[i],n[o]]=[n[o],n[i]],this.reorderPanes(n),this.events.emit("pane:moved",{paneId:e,dir:t}));}removePaneAndIndicators(e){if(e!=="price")for(let t of [...this.registry.all()])t.model?.paneId===e&&this.removeIndicator(t.id);}collapsePane(e,t){t?this.collapsedPanes.add(e):this.collapsedPanes.delete(e),this.renderer.setPaneCollapsed?.(e,t),this.events.emit("pane:changed",void 0);}maximizePane(e){this.maximizedPaneId=e,this.renderer.setPaneMaximized?.(e),this.events.emit("pane:changed",void 0);}moveIndicator(e,t){if(!this.paneManagementSupported()||!this.renderer.setIndicatorPane){console.warn("[vela] the active renderer does not support moving indicators between panes.");return}let n=this.registry.get(e);if(!n?.renderHandle||!n.model)return;let i=n.model,o=i.paneId??"price",s=this.resolveMoveTarget(e,i,t);if(!s)return;let{paneId:a,ownScale:l,insert:c}=s;a===o&&i.ownScale===true===l||(c?this.insertPaneOrder(a,c):this.paneOrder.includes(a)||this.paneOrder.push(a),i.ownScale=l,n.paneLocked=true,this.placeModel(i,e,a),this.ensurePaneFor(a),this.renderer.setIndicatorPane(n.renderHandle,a,{ownScale:l}),o!=="price"&&o!==a&&!this.paneStillUsed(o)&&(this.renderer.removePane(o),this.forgetPane(o)),this.reorderPanes(this.existingPaneIds()),this.events.emit("indicator:moved",{id:e,paneId:a}),this.events.emit("pane:changed",void 0));}resolveMoveTarget(e,t,n){if(n==="price"||typeof n=="object"&&"pane"in n&&n.pane==="price")return {paneId:"price",ownScale:!t.overlay};if("pane"in n)return this.existingPaneIds().includes(n.pane)?{paneId:n.pane,ownScale:true}:null;let i=n.newPane===true?{}:n.newPane;return {paneId:this.freshPaneId(e,t.paneId??"price"),ownScale:false,insert:i}}freshPaneId(e,t){let n=new Set(this.existingPaneIds()),i=`pane-${e}`;for(let o=2;i===t||n.has(i);o+=1)i=`pane-${e}-${o}`;return i}insertPaneOrder(e,t){let n=this.paneOrder.indexOf(e);n>0&&this.paneOrder.splice(n,1);let i=this.paneOrder.length;t.before&&this.paneOrder.includes(t.before)?i=this.paneOrder.indexOf(t.before):t.after&&this.paneOrder.includes(t.after)&&(i=this.paneOrder.indexOf(t.after)+1),i<1&&(i=1),this.paneOrder.splice(i,0,e);}existingPaneIds(){return this.paneOrder.filter(e=>e==="price"||this.paneStillUsed(e))}reorderPanes(e){this.paneOrder.length=0,this.paneOrder.push(...e),this.renderer.orderPanes?.(e),this.events.emit("pane:changed",void 0);}handlePaneAction(e){switch(e.type){case "remove":this.removePaneAndIndicators(e.paneId);break;case "move":{let t=this.existingPaneIds(),n=t.indexOf(e.paneId),i=e.dir==="up"?n-1:n+1;n>0&&i>0&&i<t.length&&([t[n],t[i]]=[t[i],t[n]],this.paneOrder.length=0,this.paneOrder.push(...t),this.events.emit("pane:changed",void 0),this.events.emit("pane:moved",{paneId:e.paneId,dir:e.dir}));break}case "collapse":e.collapsed?this.collapsedPanes.add(e.paneId):this.collapsedPanes.delete(e.paneId),this.events.emit("pane:changed",void 0);break;case "maximize":this.maximizedPaneId=e.maximized?e.paneId:null,this.events.emit("pane:changed",void 0);break}}announce(e,t){e.announced||(e.announced=true,this.events.emit("indicator:added",{id:e.id}),this.emitContextChanged(e.id),t?.emit("ready",void 0));}applyModel(e,t){let n=this.registry.get(e);if(!n||n.hidden)return true;if(n.loading&&this.bars.length===0&&!r.modelHasOutput(t))return false;let i=this.handles.get(e);if(!n.renderHandle){let a=this.routePane(e,t,n.options??{});return this.placeModel(t,e,a),n.model=t,this.ensurePaneFor(a),n.renderHandle=this.renderer.mountIndicator(t),n.pendingStructural=false,this.announce(n,i),true}let o=n.model?.paneId??"price",s=n.model?.ownScale===true;if(n.loading&&!n.paneLocked){let a=this.routePane(e,t,n.options??{});a!==o&&(o!=="price"&&(this.renderer.removePane(o),this.forgetPane(o)),this.ensurePaneFor(a),n.pendingStructural=true,o=a);}return this.placeModel(t,e,o),n.paneLocked&&(t.ownScale=s),n.model=t,n.pendingStructural?(n.renderHandle=this.renderer.mountIndicator(t),this.renderer.setIndicatorInputs(n.renderHandle,n.inputValues,n.propValues),n.pendingStructural=false):this.renderer.updateIndicator(n.renderHandle,p0(t)),n.loading&&this.setLoading(n,false),this.announce(n,i),true}static modelHasOutput(e){return e.series.length>0||e.fills.length>0||e.backgrounds.length>0||e.priceLines.length>0||(e.lines?.length??0)>0||(e.boxes?.length??0)>0||(e.labels?.length??0)>0||(e.polylines?.length??0)>0||(e.linefills?.length??0)>0||(e.tables?.length??0)>0||(e.barColors?.length??0)>0||(e.trades?.length??0)>0}routePane(e,t,n){return n.pane==="new"?`pane-${e}`:n.pane==="price"||(n.overlay??t.overlay)?"price":`pane-${e}`}static plotsAtLastBar(e){let t={};for(let n of e.series)ve(n)&&(t[n.title]=n.points[n.points.length-1]?.value??null);return t}placeModel(e,t,n){e.id=t,e.paneId=n;let i=o=>o.overlay===true?"price":n;for(let o of e.series)o.paneId=i(o);for(let o of e.fills)o.paneId=i(o);for(let o of e.backgrounds)o.paneId=i(o);for(let o of e.priceLines)o.paneId=n;if(e.lines)for(let o of e.lines)o.paneId=i(o);if(e.boxes)for(let o of e.boxes)o.paneId=i(o);if(e.labels)for(let o of e.labels)o.paneId=i(o);if(e.polylines)for(let o of e.polylines)o.paneId=i(o);if(e.linefills)for(let o of e.linefills)o.paneId=i(o);if(e.tables)for(let o of e.tables)o.paneId=i(o);}emitContextChanged(e){if(!this.registry.get(e)?.session?.getContext)return;let t=Date.now();t-(this.contextEmitAt.get(e)??0)<1e3||(this.contextEmitAt.set(e,t),this.events.emit("context:changed",{id:e}));}emitScriptRun(e,t,n){let i=this.registry.get(e);if(!i||i.native||!this.events.hasListeners("script:run"))return;let o=Date.now();t==="tick"&&o-(this.runEmitAt.get(e)??0)<a0||(this.runEmitAt.set(e,o),Promise.resolve().then(()=>this.buildScriptRun(i,t,n)).then(s=>{s&&this.registry.get(e)&&this.events.emit("script:run",s);}));}async buildScriptRun(e,t,n){let i=e.model;if(!i)return null;let o=await this.pullContext(e,["variables","strategy","warnings"]),s=this.bars[this.bars.length-1];return {id:e.id,title:i.title,kind:o?.strategy||(i.trades?.length??0)>0?"strategy":"indicator",cause:t,first:n,bar:Math.max(0,this.bars.length-1),time:s?.time??0,forming:this.config.live&&this.bars.length>0,complete:this.historyState!=="backfill",plots:r.plotsAtLastBar(i),vars:o?.variables??{},...o?.strategy?{strategy:o.strategy}:{},warnings:o?.warnings??[],trades:async()=>(await this.pullContext(e,["trades"]))?.trades??[],series:async a=>((await this.pullContext(e,["plots"]))?.plots?.[a]??[]).map(c=>({time:c.time,value:typeof c.value=="number"?c.value:null}))}}async pullContext(e,t){try{return await e.session?.getContext?.(t)??null}catch{return null}}fail(e,t,n){let i=this.registry.get(e);i?.loading&&this.setLoading(i,false);let o=n instanceof Error?n:new Error(String(n));console.error(`[vela] indicator "${e}" failed:`,o.message),this.events.emit("indicator:error",{id:e,error:o}),t?.emit("error",{error:o});}};function h0(){return typeof requestAnimationFrame=="function"?new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(()=>r()))):new Promise(r=>setTimeout(r,0))}function p0(r){let e=[],t=Number.POSITIVE_INFINITY,n=0;for(let i of r.series)if(i.kind==="candle"||i.kind==="bar"){e.push({seriesId:i.id,kind:"bars",bars:i.bars});for(let o of i.bars)o.time<t&&(t=o.time),o.time>n&&(n=o.time);}else if(ve(i)){e.push({seriesId:i.id,kind:"points",points:i.points});for(let o of i.points)o.time<t&&(t=o.time),o.time>n&&(n=o.time);}return {kind:"value",indicatorId:r.id,dirty:{from:Number.isFinite(t)?t:0,to:n},anchorTime:r.anchorTime??null,series:e,lines:r.lines??[],boxes:r.boxes??[],labels:r.labels??[],polylines:r.polylines??[],linefills:r.linefills??[],tables:r.tables??[],trades:r.trades??[]}}var ki=class{constructor(e){this.renderer=e;}get name(){return this.renderer.name}get capabilities(){return this.renderer.capabilities}supports(e){return this.renderer.features.includes(e)}get(e){return this.renderer.readFeature(e)}set(e,t){let n=typeof e=="string"?[[e,t]]:Object.entries(e);for(let[i,o]of n)this.renderer.features.includes(i)?this.renderer.applyFeature(i,o):console.warn(`[vela] renderer "${this.renderer.name}" has no feature "${i}" \u2014 set ignored.`);return this}setLegendActions(e){this.renderer.setLegendActions?.(e);}setLegendCallouts(e){this.renderer.setLegendCallouts?.(e);}setLegendOverviewAction(e){return this.renderer.setLegendOverviewAction?.(e),this}get supportsIndicatorSettings(){return typeof this.renderer.openIndicatorSettings=="function"}openIndicatorSettings(e){return this.renderer.openIndicatorSettings?.(e),this}screenshot(){return typeof this.renderer.screenshot=="function"?this.renderer.screenshot():(console.warn(`[vela] renderer "${this.renderer.name}" does not support screenshot().`),null)}getConfig(){return typeof this.renderer.getConfig=="function"?this.renderer.getConfig():(console.warn(`[vela] renderer "${this.renderer.name}" does not support getConfig().`),null)}applyConfig(e){return typeof this.renderer.applyConfig=="function"?this.renderer.applyConfig(e):console.warn(`[vela] renderer "${this.renderer.name}" does not support applyConfig().`),this}onConfigChanged(e){return this.renderer.onConfigChanged?.(e)??(()=>{})}onCrosshairMove(e){return this.renderer.onCrosshairMove(e)}onAxisLongPress(e){return this.renderer.onAxisLongPress?.(e)??(()=>{})}dataWindowReadout(){return this.renderer.getDataWindowReadout?.()??null}setSymbolPicker(e){return typeof this.renderer.setSymbolPicker=="function"?this.renderer.setSymbolPicker(e):console.warn(`[vela] renderer "${this.renderer.name}" does not support setSymbolPicker().`),this}focus(){return this.renderer.focus?.(),this}get supportsExternalCrosshair(){return typeof this.renderer.setExternalCrosshair=="function"}setExternalCrosshair(e,t=null){return this.renderer.setExternalCrosshair?.(e,t),this}closeDialogs(){return this.renderer.closeDialogs?.(),this}openSettings(e){return this.renderer.openSettingsDialog?.(e),this}setSettingsSections(e){return this.renderer.setSettingsSections?.(e),this}setSettingsVisibility(e){return this.renderer.setSettingsVisibility?.(e),this}listSettingsIds(){return this.renderer.listSettingsIds?.()??[]}setLayoutMode(e){return this.renderer.setLayoutMode?.(e),this}};var br=new Map;function m0(r){let e=Object.entries(r);for(let[t,n]of e)br.set(t,n);return ()=>{for(let[t,n]of e)br.get(t)===n&&br.delete(t);}}function f0(...r){if(r.length===0)br.clear();else for(let e of r)br.delete(e);}function Dc(){return Object.fromEntries(br)}var pa=class{constructor(e){this.controller=e;}get supported(){return this.controller.paneManagementSupported()}list(){return this.controller.listPanes()}move(e,t){return this.guard()&&this.controller.movePane(e,t),this}remove(e){return this.guard()&&this.controller.removePaneAndIndicators(e),this}collapse(e,t=true){return this.guard()&&this.controller.collapsePane(e,t),this}maximize(e){return this.guard()&&this.controller.maximizePane(e),this}moveIndicator(e,t){return this.guard()&&this.controller.moveIndicator(e,t),this}guard(){return this.controller.paneManagementSupported()?true:(console.warn("[vela] the active renderer does not support pane management \u2014 chart.panes mutation ignored."),false)}};function yp(r,e,t,n){return `${r}|${e}|${t}${n&&n!=="regular"?`|${n}`:""}`}function g0(r){return r.split("|")[1]??""}var ma=class{constructor(){this.series=new Map;this.coveredFrom=new Map;this.retained=new Set;this.retainedByOwner=new Map;}get(e){return this.series.get(e)}markCovered(e,t){this.coveredFrom.set(e,Math.min(this.coveredFrom.get(e)??1/0,t));}coveredFromOf(e){return this.coveredFrom.get(e)}merge(e,t){if(t.length===0)return this.series.get(e)??[];let n=new Map;for(let o of this.series.get(e)??[])n.set(o.time,o);for(let o of t)n.set(o.time,o);let i=[...n.values()].sort((o,s)=>o.time-s.time);return this.series.set(e,i),i}retainSymbol(e){this.currentSymbol!==e&&(this.currentSymbol=e,this.purgeOutside(e));}retain(e,t="default"){e.size===0?this.retainedByOwner.delete(t):this.retainedByOwner.set(t,new Set(e));let n=new Set;for(let i of this.retainedByOwner.values())for(let o of i)n.add(o);this.retained=n,this.purgeOutside(this.currentSymbol);}purgeOutside(e){for(let t of [...this.series.keys()]){let n=g0(t);n!==e&&!this.retained.has(n)&&(this.series.delete(t),this.coveredFrom.delete(t));}}clear(){this.series.clear(),this.coveredFrom.clear();}},Ii=new ma;function Oc(r,e,t){let{provider:n,ticker:i}=gt(r);return yp(n??"",i,e,t)}var Ri=1e4,b0=Ri+1,Di=class{constructor(e,t=Ii){this.inner=e;this.store=t;}async load(e){if(e.data&&e.data.length>0)return this.inner.load(e);let t=e.symbol??"TEST",n=Oc(t,e.timeframe??"60",e.session);this.store.retainSymbol(t);let i=this.store.get(n),o=e.bars??500,s=i?.[i.length-1];if(i&&s&&i.length>=o-1&&this.inner.loadRange){let{bars:l}=await this.fetchRange(e,{from:s.time}),c=this.store.merge(n,Ai(l));return wp(c,l[l.length-1]).slice(-o)}let a=await this.inner.load(e);return this.store.merge(n,Ai(a)),a}async loadProgressive(e,t,n){if(e.data&&e.data.length>0)return this.inner.load(e);if(!this.inner.loadProgressive)return null;let i=e.symbol??"TEST",o=Oc(i,e.timeframe??"60",e.session),s=this.store.get(o),a=e.bars??500,l=s?.[s.length-1];if(s&&l&&s.length>=a-1&&this.inner.loadRange)return this.load(e);this.store.retainSymbol(i);let c=await this.inner.loadProgressive(e,t,n);return c==null?null:(this.store.merge(o,Ai(c)),c)}async loadRange(e,t){if(!this.inner.loadRange)return this.inner.load(e);let n=Oc(e.symbol??"TEST",e.timeframe??"60",e.session),i=this.store.get(n),o=i?.[i.length-1];if(t.to!=null&&o&&t.to<o.time){let d=i.filter(f=>f.time<=t.to),u=this.store.coveredFromOf(n)??1/0;if(t.limit!=null?d.length>=t.limit&&(t.from==null||u<=t.from):t.from!=null&&u<=t.from){let f=t.from!=null?d.filter(g=>g.time>=t.from):d;return t.limit!=null&&f.length>t.limit&&(f=f.slice(-t.limit)),f}let p=await this.fetchRange(e,t),m=p.bars.filter(f=>f.time<=t.to);return m.length>0&&(this.store.merge(n,m),this.store.markCovered(n,p.coveredDownTo??m[0].time)),m}if(o&&t.from!=null){let d=this.store.coveredFromOf(n);if(d!=null&&d>t.from){let{bars:u,coveredDownTo:h}=await this.fetchRange(e,{from:t.from,to:d});this.store.merge(n,u.filter(p=>p.time<=d)),this.store.markCovered(n,h??t.from),i=this.store.get(n),o=i?.[i.length-1];}}let s=this.store.coveredFromOf(n);if(!!i&&i.length>0&&!!o&&(t.from!=null?s!=null&&s<=t.from:t.limit==null||i.length>=t.limit)&&o){let{bars:d}=await this.fetchRange(e,{from:o.time,to:t.to,limit:t.limit}),u=this.store.merge(n,Ai(d)),h=wp(u,d[d.length-1]),p=t.from!=null?h.filter(m=>m.time>=t.from):h;return t.to!=null&&(p=p.filter(m=>m.time<=t.to)),p}let{bars:l,coveredDownTo:c}=await this.fetchRange(e,t);return this.store.merge(n,Ai(l)),this.store.markCovered(n,c??t.from??l[0]?.time??0),l}async fetchRange(e,t){let n=et(e.timeframe??"60"),i=v0(t,n);if(i<=b0){let c=await this.inner.loadRange(e,{...t,limit:t.limit??i});return {bars:c,coveredDownTo:t.from??c[0]?.time}}let o=new Map,s=t.to??Date.now();for(;!(t.from!=null&&s<t.from);){let c=t.limit!=null?t.limit-o.size:Ri;if(c<=0)break;let d=await this.inner.loadRange(e,{to:s,limit:Math.min(Ri,c)}),u=1/0;for(let h of d)h.time<u&&(u=h.time),h.time<=s&&(t.from==null||h.time>=t.from)&&o.set(h.time,h);if(d.length===0){if(t.from==null)break;s-=Ri*n;continue}if(u-1>=s)break;s=u-1;}let a=[...o.values()].sort((c,d)=>c.time-d.time),l=t.from!=null&&s<t.from;return {bars:a,coveredDownTo:l?t.from:a[0]?.time}}subscribe(e,t){return this.inner.subscribe(e,t)}symbolInfo(e){return this.inner.symbolInfo?.(e)}};function v0(r,e){if(r.limit!=null)return r.limit;if(r.from==null)return Ri;let t=Math.max(0,(r.to??Date.now())-r.from);return Math.ceil(t/e*1.1)+2}function Ai(r){return r.length>0?r.slice(0,-1):r}function wp(r,e){if(!e)return r;let t=r[r.length-1];return !t||e.time>t.time?[...r,e]:r}function y0(r){return {"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"2h":72e5,"4h":144e5,"1d":864e5,"1w":6048e5,"1M":2592e6,1:6e4,5:3e5,15:9e5,30:18e5,60:36e5,240:144e5,D:864e5,W:6048e5,M:2592e6}[r]??36e5}var Nn=class{constructor(e=Ii){this.registry=new ua;this.primaryProvider=null;this.liveBars=[];this.symInfoCache=new Map;this.cache=new Di(new Nc(this.registry),e);}registerProvider(e,t){return this.registry.register(e,t)}unregisterProvider(e){this.registry.unregister(e);}providers(){return this.registry.names().map(e=>this.registry.infoOf(e))}resolveSymbol(e){return this.registry.resolve(e,{default:this.primaryProvider})}displayPrefix(e){let t=this.resolveSymbol(e);return t?this.registry.displayPrefixOf(t):null}canonicalSymbol(e){let t=this.resolveSymbol(e);return t?this.registry.canonicalSymbol(t):null}providerInstance(e){return this.registry.get(e)}symbolIconOf(e){return this.registry.symbolIconOf(e)}symbolIcon(e){return this.registry.symbolIcon(this.resolveSymbol(e))}symbols(e){return this.registry.symbolsOf(e)}onUnresolved(e){return this.registry.onUnresolved(e)}destroy(){this.registry.cancelWaits();}ready(){return this.registry.indexReady()}async symbolInfoFor(e){let t=this.registry.resolve(e,{default:this.primaryProvider});if(!t)return;let n=await this.registry.get(t.provider)?.getSymbolInfo?.(t.ticker);return n&&this.symInfoCache.set(Fc(t),n),n}capabilitiesFor(e){let t=this.registry.resolve(e,{default:this.primaryProvider});if(!t)return null;let n=this.registry.get(t.provider);return n?n.capabilitiesFor?.(t.ticker)??this.registry.infoOf(t.provider).capabilities:null}async load(e){if(e.data&&e.data.length>0)return this.liveBars=e.data.map(n=>({...n})),e.data;let t=await this.registry.whenResolvable(Oi(e),{default:this.primaryProvider});return this.primaryProvider=t.provider,this.prefetchSymbolInfo(t),this.cache.load(fa(e,t))}async loadProgressive(e,t,n){if(e.data&&e.data.length>0)return this.liveBars=e.data.map(o=>({...o})),e.data;let i=await this.registry.whenResolvable(Oi(e),{default:this.primaryProvider});return this.primaryProvider=i.provider,this.prefetchSymbolInfo(i),this.cache.loadProgressive(fa(e,i),t,n)}symbolInfo(e){if(e.data&&e.data.length>0)return;let t=this.registry.resolve(Oi(e),{default:this.primaryProvider});return t?this.symInfoCache.get(Fc(t)):void 0}prefetchSymbolInfo(e){let t=Fc(e);if(this.symInfoCache.has(t))return;let n=this.registry.get(e.provider);n?.getSymbolInfo&&n.getSymbolInfo(e.ticker).then(i=>{i&&this.symInfoCache.set(t,i);}).catch(()=>{});}async loadRange(e,t){if(e.data&&e.data.length>0)return this.cache.loadRange(e,t);let n=this.registry.resolve(Oi(e),{default:this.primaryProvider});return n?this.cache.loadRange(fa(e,n),t):[]}subscribe(e,t){if(e.data&&e.data.length>0)return this.synthesizeTicks(e,t);let n=this.registry.resolve(Oi(e),{default:this.primaryProvider});return n?this.cache.subscribe(fa(e,n),t):()=>{}}synthesizeTicks(e,t){if(this.liveBars.length===0)return ()=>{};let n=y0(e.timeframe??"60"),i=setInterval(()=>{let o=this.liveBars,s=o[o.length-1];if(!s)return;let a=s.close*.0015*(Math.random()-.5)*2,l=Math.max(0,s.close+a),c={...s,close:l,high:Math.max(s.high,l),low:Math.min(s.low,l)};if(o[o.length-1]=c,t(c),Math.random()<.12){let d={time:c.time+n,open:c.close,high:c.close,low:c.close,close:c.close,volume:0};o.push(d),t(d);}},1e3);return ()=>clearInterval(i)}};function Oi(r){return r.symbol??""}function fa(r,e){return {...r,symbol:`${e.provider}:${e.ticker}`}}function Fc(r){return `${r.provider}|${r.ticker}`}async function xp(r,e,t,n){try{return await r.getBars(e,t,n)}catch(i){return console.warn(`[vela] data fetch failed for ${e} ${t} \u2014 ${i instanceof Error?i.message:String(i)}`),[]}}var Nc=class{constructor(e){this.registry=e;}load(e){let{provider:t,ticker:n}=gt(e.symbol??""),i=this.registry.get(t??"");return i?xp(i,n,e.timeframe??"60",{limit:e.bars??500,session:e.session}):Promise.resolve([])}async loadProgressive(e,t,n){let{provider:i,ticker:o}=gt(e.symbol??""),s=this.registry.get(i??"");if(!s)return [];if(!s.getBarsProgressive)return null;try{return await s.getBarsProgressive(o,e.timeframe??"60",{limit:e.bars??500,session:e.session},t,n)}catch(a){return console.warn(`[vela] progressive fetch failed for ${o} ${e.timeframe??"60"} \u2014 ${a instanceof Error?a.message:String(a)}`),[]}}loadRange(e,t){let{provider:n,ticker:i}=gt(e.symbol??""),o=this.registry.get(n??"");return o?xp(o,i,e.timeframe??"60",{...t,session:e.session}):Promise.resolve([])}subscribe(e,t){let{provider:n,ticker:i}=gt(e.symbol??""),o=this.registry.get(n??"");if(!o)return ()=>{};let s=e.timeframe??"60";if(o.subscribe)return o.subscribe(i,s,t,e.session?{session:e.session}:void 0);let a=false,l=null,c=async()=>{if(!a){try{let d=await o.getBars(i,s,{limit:2,session:e.session});if(a)return;for(let u of d)t(u);}catch{}a||(l=setTimeout(()=>{c();},3e3));}};return l=setTimeout(()=>{c();},3e3),()=>{a=true,l&&clearTimeout(l);}}};var Fi=class{constructor(e){this.registry=e instanceof Nn?e:null;}registerProvider(e,t){return this.registry?(this.registry.registerProvider(e,t),this):(console.warn(`[vela] chart.data.registerProvider("${e}") ignored \u2014 the active data feed is a custom feed (deps.dataFeed), not the default provider registry.`),this)}unregisterProvider(e){return this.registry?.unregisterProvider(e),this}providers(){return this.registry?.providers()??[]}resolve(e){return this.registry?.resolveSymbol(e)??null}displayPrefix(e){return this.registry?.displayPrefix(e)??null}canonicalSymbol(e){return this.registry?.canonicalSymbol(e)??null}providerInstance(e){return this.registry?.providerInstance(e)}symbols(e){return this.registry?.symbols(e)??[]}symbolIcon(e){return this.registry?.symbolIcon(e)}symbolInfo(e){return this.registry?.symbolInfoFor(e)??Promise.resolve(void 0)}capabilities(e){return this.registry?.capabilitiesFor(e)??null}ready(){return this.registry?.ready()??Promise.resolve()}};var Ni=class{constructor(e){this.ctrl=e;}get supported(){return this.ctrl.supported}setTool(e){return this.ok("setTool")&&this.ctrl.setTool(e),this}getTool(){return this.ctrl.getTool()}setSnapMode(e){return this.ok("setSnapMode")&&this.ctrl.setSnapMode(e),this}getSnapMode(){return this.ctrl.getSnapMode()}setStayMode(e){return this.ok("setStayMode")&&this.ctrl.setStayMode(e),this}getStayMode(){return this.ctrl.getStayMode()}setMode(e){return this.ok("setMode")&&this.ctrl.setMode(e),this}getMode(){return this.ctrl.getMode()}showToolbar(e=true){return this.ok("showToolbar")&&this.ctrl.showToolbar(e),this}setToolbar(e){return this.ok("setToolbar")&&this.ctrl.setToolbar(e),this}setToolShortcuts(e){return this.ok("setToolShortcuts")&&this.ctrl.setToolShortcuts(e),this}setExternalGhost(e){return this.ctrl.setExternalGhost(e),this}add(e,t={}){return this.ok("add")?this.ctrl.add(e,t):null}remove(e){return this.ctrl.remove(e),this}update(e,t){return this.ctrl.update(e,t),this}updateMany(e){return this.ctrl.updateMany(e),this}removeMany(e){return this.ctrl.removeMany(e),this}lock(e,t=true){return this.ctrl.setLocked(e,t),this}show(e,t=true){return this.ctrl.setVisible(e,t),this}select(e){return this.ok("select")&&this.ctrl.select(e==null?[]:typeof e=="string"?[e]:e),this}openSettings(e){return this.ok("openSettings")&&this.ctrl.openSettings(e),this}bringToFront(e){return this.ctrl.bringToFront(e),this}sendToBack(e){return this.ctrl.sendToBack(e),this}undo(){return this.ctrl.undo(),this}redo(){return this.ctrl.redo(),this}canUndo(){return this.ctrl.canUndo()}canRedo(){return this.ctrl.canRedo()}clone(e){return this.ok("clone")&&this.ctrl.clone(e),this}duplicate(e){return this.ok("duplicate")&&this.ctrl.duplicate(e),this}copyToClipboard(e){return this.ok("copy")&&this.ctrl.copy(e),this}paste(){return this.ok("paste")&&this.ctrl.paste(),this}all(){return this.ctrl.all()}toJSON(){return this.ctrl.toJSON()}fromJSON(e){return this.ctrl.fromJSON(e),this}favorites(){return this.ctrl.favorites()}isFavorite(e){return this.ctrl.isFavorite(e)}setFavorite(e,t){return this.ok("setFavorite")&&this.ctrl.setFavorite(e,t),this}setFavorites(e){return this.ok("setFavorites")&&this.ctrl.setFavorites([...e]),this}getConfig(){return this.ctrl.toJSON()}applyConfig(e){return this.ctrl.fromJSON(e),this}ok(e){return this.ctrl.supported?true:(console.warn(`[vela] chart.drawings.${e}() ignored \u2014 the active renderer has no userDrawings capability.`),false)}};function ga(r){let e=r.trim(),t=/^#([0-9a-f]{3})$/i.exec(e);if(t){let i=t[1];return {r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16)}}if(t=/^#([0-9a-f]{6})[0-9a-f]{0,2}$/i.exec(e),t){let i=t[1];return {r:parseInt(i.slice(0,2),16),g:parseInt(i.slice(2,4),16),b:parseInt(i.slice(4,6),16)}}let n=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i.exec(e);return n?{r:parseFloat(n[1]),g:parseFloat(n[2]),b:parseFloat(n[3])}:null}function $(r,e){let t=ga(r);return t?`rgba(${t.r},${t.g},${t.b},${e})`:r}function Sp(r,e,t){let n=ga(r),i=ga(e);if(!n||!i)return r;let o=(s,a)=>Math.round(s+(a-s)*t);return `rgb(${o(n.r,i.r)},${o(n.g,i.g)},${o(n.b,i.b)})`}function He(r){let e=ga(r);return e?.2126*e.r+.7152*e.g+.0722*e.b<128:true}var ba={"--vela-space-1":"4px","--vela-space-2":"8px","--vela-space-3":"12px","--vela-space-4":"16px","--vela-radius-sm":"4px","--vela-radius-md":"6px","--vela-radius-lg":"10px","--vela-z-tooltip":"60","--vela-z-menu":"50","--vela-z-dialog":"40","--vela-z-popover":"6000","--vela-ease":"cubic-bezier(0.22, 1, 0.36, 1)","--vela-dur-fast":"90ms","--vela-dur-med":"160ms","--vela-font-size-sm":"11px","--vela-font-size-md":"12px","--vela-font-size-lg":"14px"};function va(r){let e=He(r.background),t=i=>e?`rgba(255,255,255,${i})`:$(r.textColor,i+.02),n=Sp(r.background,e?"#ffffff":r.textColor,e?.03:.05);return {"--vela-font":r.fontFamily,"--vela-bg":r.background,"--vela-fg":e?"#d1d4dc":r.textColor,"--vela-fg-muted":e?"#868a96":$(r.textColor,.62),"--vela-fg-faint":$(r.textColor,.35),"--vela-fg-bright":e?"#f0f3fa":"#000000","--vela-surface":r.background,"--vela-surface-elev":n,"--vela-surface-overlay":n,"--vela-surface-sunken":r.background,"--vela-border":r.borderColor,"--vela-border-strong":e?"#34353b":$(r.textColor,.28),"--vela-border-soft":r.borderColor,"--vela-border-faint":$(r.textColor,.08),"--vela-hover":t(.06),"--vela-active":t(.1),"--vela-hover-strong":t(.16),"--vela-focus":$(r.textColor,.5),"--vela-focus-soft":$(r.textColor,.12),"--vela-separator-hover-band":$(r.textColor,.1),"--vela-separator-hover-line":$(r.textColor,.55),"--vela-scroll":$(r.textColor,.3),"--vela-accent":Ee,"--vela-accent-bright":sr,"--vela-highlight":Mh,"--vela-selected-bg":e?"#f0f3fa":r.textColor,"--vela-selected-fg":e?r.background:"#ffffff","--vela-fg-on-fill":"#ffffff","--vela-up":r.upColor,"--vela-down":r.downColor,"--vela-danger":r.downColor,"--vela-shadow":"0 8px 30px rgba(0,0,0,0.5)","--vela-shadow-dialog":"0 20px 60px rgba(0,0,0,0.5)","--vela-backdrop":"rgba(0,0,0,0.45)"}}function fe(r,e){let t=n=>{for(let i in n)r.style.setProperty(i,n[i]);};t(ba),t(va(e));}function vt(r,e){let t=null,n=null,i=()=>{t!==null&&(clearTimeout(t),t=null),n?.remove(),n=null;},o=()=>{let a=e.text();if(!a)return;n=r.ownerDocument.createElement("div"),n.textContent=a,n.style.cssText="position:absolute;z-index:var(--vela-z-tooltip);pointer-events:none;background:var(--vela-bg);border:1px solid var(--vela-border);color:var(--vela-fg);border-radius:var(--vela-radius-md);padding:4px 9px;box-shadow:var(--vela-shadow);font:var(--vela-font-size-md) var(--vela-font);"+(e.wrap?"max-width:260px;":"white-space:nowrap;"),fe(n,e.theme()),e.host.appendChild(n);let c=r.getBoundingClientRect(),d=e.host.getBoundingClientRect();if(e.placement==="right")n.style.left=`${c.right-d.left+8}px`,n.style.top=`${c.top-d.top+(c.height-n.offsetHeight)/2}px`;else {let u=Math.min(c.left-d.left,Math.max(0,d.width-n.offsetWidth-4));n.style.left=`${Math.max(0,u)}px`,n.style.top=e.placement==="above"?`${Math.max(0,c.top-d.top-n.offsetHeight-6)}px`:`${c.bottom-d.top+6}px`;}},s=a=>{a.pointerType==="mouse"&&(i(),t=window.setTimeout(o,e.delayMs??700));};return r.addEventListener("pointerenter",s),r.addEventListener("pointerleave",i),r.addEventListener("pointerdown",i),()=>{r.removeEventListener("pointerenter",s),r.removeEventListener("pointerleave",i),r.removeEventListener("pointerdown",i),i();}}var w0=Object.defineProperty,x0=(r,e,t)=>e in r?w0(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,J=(r,e,t)=>x0(r,typeof e!="symbol"?e+"":e,t);function Cp(r){return r==null?[]:Array.isArray(r)?r:[r]}var Tp=r=>r[0],Ep=r=>r[r.length-1];function Pp(r,e,t={}){let{step:n=1,loop:i=true}=t,o=e+n,s=r.length,a=s-1;return e===-1?n>0?0:a:o<0?i?a:0:o>=s?i?0:e>s?s:e:o}function Lp(r,e,t={}){return r[Pp(r,e,t)]}function S0(r,e,t={}){let{step:n=1,loop:i=true}=t;return Pp(r,e,{step:-n,loop:i})}function Mp(r,e,t={}){return r[S0(r,e,t)]}var kp=r=>r?.constructor.name==="Array",C0=(r,e)=>{if(r.length!==e.length)return false;for(let t=0;t<r.length;t++)if(!vr(r[t],e[t]))return false;return true},vr=(r,e)=>{if(Object.is(r,e))return true;if(r==null&&e!=null||r!=null&&e==null)return false;if(typeof r?.isEqual=="function"&&typeof e?.isEqual=="function")return r.isEqual(e);if(typeof r=="function"&&typeof e=="function")return r.toString()===e.toString();if(kp(r)&&kp(e))return C0(Array.from(r),Array.from(e));if(typeof r!="object"||typeof e!="object")return false;let t=Object.keys(e??Object.create(null)),n=t.length;for(let i=0;i<n;i++)if(!Reflect.has(r,t[i]))return false;for(let i=0;i<n;i++){let o=t[i];if(!vr(r[o],e[o]))return false}return true};var T0=r=>r!=null&&typeof r=="object";var yr=r=>typeof r=="string",Ne=r=>typeof r=="function",Ip=r=>r==null,Vi=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),E0=r=>Object.prototype.toString.call(r),Ap=Function.prototype.toString,P0=Ap.call(Object),Vn=r=>{if(!T0(r)||E0(r)!="[object Object]"||k0(r))return false;let e=Object.getPrototypeOf(r);if(e===null)return true;let t=Vi(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Ap.call(t)==P0},L0=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,M0=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,k0=r=>L0(r)||M0(r);var _i=(r,...e)=>(typeof r=="function"?r(...e):r)??void 0,Vc=r=>r,Rp=r=>r(),_c=()=>{},tn=(...r)=>(...e)=>{r.forEach(function(t){t?.(...e);});};function nn(r){if(!Vn(r)||r===void 0)return r;let e=Reflect.ownKeys(r).filter(n=>typeof n=="string"),t={};for(let n of e){let i=r[n];i!==void 0&&(t[n]=nn(i));}return t}function wr(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function Bc(...r){r.length===1?r[0]:r[1];r.length===2?r[0]:true;}function Bi(r,e){if(r==null)throw new Error(e())}var I0=(...r)=>r.map(e=>e?.trim?.()).filter(Boolean).join(" "),A0=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,Dp=r=>{let e={},t;for(;t=A0.exec(r);)e[t[1]]=t[2];return e},R0=(r,e)=>{if(yr(r)){if(yr(e))return `${r};${e}`;r=Dp(r);}else yr(e)&&(e=Dp(e));return Object.assign({},r??{},e??{})};function Op(...r){let e={};for(let t of r){if(!t)continue;for(let i in e){if(i.startsWith("on")&&typeof e[i]=="function"&&typeof t[i]=="function"){e[i]=tn(t[i],e[i]);continue}if(i==="className"||i==="class"){e[i]=I0(e[i],t[i]);continue}if(i==="style"){e[i]=R0(e[i],t[i]);continue}e[i]=t[i]!==void 0?t[i]:e[i];}for(let i in t)e[i]===void 0&&(e[i]=t[i]);let n=Object.getOwnPropertySymbols(t);for(let i of n)e[i]=t[i];}return e}var rn=".",Vp="#",Fp=new WeakMap,_p=new WeakMap;function Hc(r){return r.join(rn)}function D0(r){return r.includes(rn)}function Bp(r){return r.startsWith(Vp)}function O0(r){return r.startsWith(rn)}function F0(r){return Bp(r)?r.slice(Vp.length):r}function zc(r,e){return r?`${r}${rn}${e}`:e}function N0(r){let e=new Map,t=new Map,n=(i,o)=>{e.set(i,o);let s=o.id;s&&(t.has(s)&&Bc(`[zag-js] Duplicate state id: "${s}"`),t.set(s,i));let a=o.states;if(a){Bi(o.initial,()=>`[zag-js] Compound state "${i}" has child states but no "initial" property`),o.initial in a||Bc(`[zag-js] Compound state "${i}" has initial "${String(o.initial)}" which is not a child state`);for(let[l,c]of Object.entries(a)){if(!c)continue;let d=zc(i,l);n(d,c);}}};for(let[i,o]of Object.entries(r.states))o&&n(i,o);return {index:e,idIndex:t}}function xr(r){let e=Fp.get(r);if(e)return e;let{index:t,idIndex:n}=N0(r);return Fp.set(r,t),_p.set(r,n),t}function V0(r,e){return xr(r),_p.get(r)?.get(e)}function $c(r){return r?String(r).split(rn).filter(Boolean):[]}function ya(r,e){if(!e)return [];let t=xr(r),n=$c(e),i=[],o=[];for(let s of n){o.push(s);let a=Hc(o),l=t.get(a);if(!l)break;i.push({path:a,state:l});}return i}function Hi(r,e){let t=xr(r),n=$c(e);if(!n.length)return e;let i=[];for(let a of n){i.push(a);let l=Hc(i);if(!t.has(l))return e}let o=Hc(i),s=t.get(o);for(;s?.initial;){let a=`${o}${rn}${s.initial}`,l=t.get(a);if(!l)break;o=a,s=l;}return o}function Np(r,e){return xr(r).has(e)}function Wc(r,e,t){let n=String(e);if(Bp(n)){let i=F0(n),o=V0(r,i);return Bi(o,()=>`[zag-js] Unknown state id: "${i}"`),Hi(r,o)}if(O0(n)&&t){let i=zc(t,n.slice(1));return Hi(r,i)}if(!D0(n)&&t){let i=$c(t);for(let o=i.length-1;o>=1;o--){let s=i.slice(0,o).join(rn),a=zc(s,n);if(Np(r,a))return Hi(r,a)}if(Np(r,n))return Hi(r,n)}return Hi(r,n)}function Hp(r,e,t){let n=ya(r,e);for(let o=n.length-1;o>=0;o--){let a=n[o]?.state.on?.[t];if(a)return {transitions:a,source:n[o]?.path}}return {transitions:r.on?.[t],source:void 0}}function zp(r,e,t,n){let i=e?ya(r,e):[],o=ya(r,t),s=0;for(;s<i.length&&s<o.length&&i[s]?.path===o[s]?.path;)s+=1;let a=i.slice(s).reverse(),l=o.slice(s),c=i.at(-1)?.path===o.at(-1)?.path;return n&&c&&(a=i.slice().reverse(),l=o),{exiting:a,entering:l}}function $p(r,e){return r?r===e||r.startsWith(`${e}${rn}`):false}function Wp(r,e,t){return ya(r,e).some(n=>n.state.tags?.includes(t))}function Gp(){return {and:(...r)=>function(t){return r.every(n=>t.guard(n))},or:(...r)=>function(t){return r.some(n=>t.guard(n))},not:r=>function(t){return !t.guard(r)}}}function wa(r){return xr(r),r}var Sr=(r=>(r.NotStarted="Not Started",r.Started="Started",r.Stopped="Stopped",r))(Sr||{}),zi="__init__";var _0=Object.defineProperty,B0=(r,e,t)=>e in r?_0(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,xa=(r,e,t)=>B0(r,typeof e!="symbol"?e+"":e,t);var Up=(r,e)=>r.map((t,n)=>r[(Math.max(e,0)+n)%r.length]);var $i=()=>{},Wi=r=>typeof r=="object"&&r!==null;var Ge=r=>r?"":void 0,Gc=r=>r?"true":void 0;var H0=1,z0=9,$0=11;var Q=r=>Wi(r)&&r.nodeType===H0&&typeof r.nodeName=="string",Gi=r=>Wi(r)&&r.nodeType===z0,W0=r=>Wi(r)&&r===r.window;var Yp=r=>Q(r)?r.localName||"":"#document";function Kp(r){return ["html","body","#document"].includes(Yp(r))}var Xp=r=>Wi(r)&&r.nodeType!==void 0,_n=r=>Xp(r)&&r.nodeType===$0&&"host"in r,Uc=r=>Q(r)&&r.localName==="input",jp=r=>!!r?.matches("a[href]"),qp=r=>Q(r)?r.offsetWidth>0||r.offsetHeight>0||r.getClientRects().length>0:false;function Ui(r){if(!r)return false;let e=r.getRootNode();return yt(e)===r}var G0=/(textarea|select)/;function Cr(r){if(r==null||!Q(r))return false;try{return Uc(r)&&r.selectionStart!=null||G0.test(r.localName)||r.isContentEditable||r.getAttribute("contenteditable")==="true"||r.getAttribute("contenteditable")===""}catch{return false}}function Ve(r,e){if(!r||!e||!Q(r)||!Xp(e))return false;if(Q(e)&&r===e||r.contains(e))return true;let t=e.getRootNode?.();if(t&&_n(t)){let n=e;for(;n;){if(r===n)return true;n=n.parentNode||n.host;}}return false}function ue(r){return Gi(r)?r:W0(r)?r.document:r?.ownerDocument??document}function U0(r){return ue(r).documentElement}function ae(r){return _n(r)?ae(r.host):Gi(r)?r.defaultView??window:Q(r)?r.ownerDocument?.defaultView??window:window}function yt(r){let e=r.activeElement;for(;e?.shadowRoot;){let t=e.shadowRoot.activeElement;if(!t||t===e)break;e=t;}return e}function Zp(r){if(Yp(r)==="html")return r;let e=r.assignedSlot||r.parentNode||_n(r)&&r.host||U0(r);return _n(e)?e.host:e}function Sa(r){let e;try{if(e=r.getRootNode({composed:!0}),Gi(e)||_n(e))return e}catch{}return r.ownerDocument??document}var Yc=new WeakMap;function Tr(r){return Yc.has(r)||Yc.set(r,ae(r).getComputedStyle(r)),Yc.get(r)}var Kc=new Set(["menu","listbox","dialog","grid","tree","region","application"]),Y0=r=>Kc.has(r),Jp=r=>r.getAttribute("aria-controls")?.split(" ")||[];function Ca(r,e){let t=new Set,n=Sa(r),i=o=>{let s=o.querySelectorAll("[aria-controls]");for(let a of s){if(a.getAttribute("aria-expanded")!=="true")continue;let l=Jp(a);for(let c of l){if(!c||t.has(c))continue;t.add(c);let d=n.getElementById(c);if(d){let u=d.getAttribute("role"),h=d.getAttribute("aria-modal")==="true";if(u&&Y0(u)&&!h&&(d===e||d.contains(e)||i(d)))return true}}}return false};return i(r)}function Xc(r,e){let t=Sa(r),n=new Set,i=o=>{let s=o.querySelectorAll("[aria-controls]");for(let a of s){if(a.getAttribute("aria-expanded")!=="true")continue;let l=Jp(a);for(let c of l){if(!c||n.has(c))continue;n.add(c);let d=t.getElementById(c);if(d){let u=d.getAttribute("role"),h=d.getAttribute("aria-modal")==="true";u&&Kc.has(u)&&!h&&(e(d),i(d));}}}};i(r);}function Qp(r){let e=new Set;return Xc(r,t=>{r.contains(t)||e.add(t);}),Array.from(e)}function K0(r){let e=r.getAttribute("role");return !!(e&&Kc.has(e))}function X0(r){return r.hasAttribute("aria-controls")&&r.getAttribute("aria-expanded")==="true"}function em(r){return X0(r)?true:!!r.querySelector?.('[aria-controls][aria-expanded="true"]')}function tm(r){if(!r.id)return false;let e=Sa(r),t=CSS.escape(r.id),n=`[aria-controls~="${t}"][aria-expanded="true"], [aria-controls="${t}"][aria-expanded="true"]`;return !!(e.querySelector(n)&&K0(r))}var jc=()=>typeof document<"u";function j0(){return navigator.userAgentData?.platform??navigator.platform}function q0(){let r=navigator.userAgentData;return r&&Array.isArray(r.brands)?r.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(" "):navigator.userAgent}var qc=r=>jc()&&r.test(j0()),nm=r=>jc()&&r.test(q0());var Zc=()=>jc()&&!!navigator.maxTouchPoints,Z0=()=>qc(/^iPhone/i),J0=()=>qc(/^iPad/i)||Er()&&navigator.maxTouchPoints>1,rm=()=>Z0()||J0();var Er=()=>qc(/^Mac/i);var im=()=>nm(/Firefox/i);var om=()=>nm(/Android/i);function Q0(r){return r.composedPath?.()??r.nativeEvent?.composedPath?.()}function ge(r){return Q0(r)?.[0]??r.target}function Jc(r){let e=r.currentTarget;if(!e||!e.matches("a[href], button[type='submit'], input[type='submit']"))return false;let n=r.button===1,i=eC(r);return n||i}function Qc(r){let e=r.currentTarget;if(!e)return false;let t=e.localName;return r.altKey?t==="a"||t==="button"&&e.type==="submit"||t==="input"&&e.type==="submit":false}function eC(r){return Er()?r.metaKey:r.ctrlKey}function am(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function lm(r){return r.pointerType===""&&r.isTrusted?true:om()&&r.pointerType?r.type==="click"&&r.buttons===1:r.detail===0&&!r.pointerType}var Ta=r=>r.button===2||Er()&&r.ctrlKey&&r.button===0,cm=r=>r.ctrlKey||r.altKey||r.metaKey,tC=r=>"touches"in r&&r.touches.length>0,nC={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"},sm={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft"};function ed(r,e={}){let{dir:t="ltr",orientation:n="horizontal"}=e,i=r.key;return i=nC[i]??i,t==="rtl"&&n==="horizontal"&&i in sm&&(i=sm[i]),i}function Pr(r,e="client"){let t=tC(r)?r.touches[0]||r.changedTouches[0]:r;return {x:t[`${e}X`],y:t[`${e}Y`]}}var Me=(r,e,t,n)=>{let i=typeof r=="function"?r():r;return i?.addEventListener(e,t,n),()=>{i?.removeEventListener(e,t,n);}};var dm=r=>Q(r)&&r.tagName==="IFRAME",rC=/^(audio|video|details)$/;function um(r){let e=r.getAttribute("tabindex");return e?parseInt(e,10):NaN}var iC=r=>!Number.isNaN(um(r)),oC=r=>um(r)<0;function sC(r){return Uc(r)&&r.type==="radio"}function aC(r){if(!sC(r)||!r.name||r.checked)return true;let e=`input[type="radio"][name="${CSS.escape(r.name)}"]`,t=r.form??r.ownerDocument,n=Array.from(t.querySelectorAll(e)).filter(o=>o.form===r.form&&Ue(o)),i=n.find(o=>o.checked);return i?i===r:n[0]===r}function lC(r,e){if(!e)return null;if(e===true)return r.shadowRoot||null;let t=e(r);return (t===true?r.shadowRoot:t)||null}function hm(r,e,t){let n=[...r],i=[...r],o=new Set,s=new Map;r.forEach((l,c)=>s.set(l,c));let a=0;for(;a<i.length;){let l=i[a++];if(!l||o.has(l))continue;o.add(l);let c=lC(l,e);if(c){let d=Array.from(c.querySelectorAll(Ea)).filter(t),u=s.get(l);if(u!==void 0){let h=u+1;n.splice(h,0,...d),d.forEach((p,m)=>{s.set(p,h+m);});for(let p=h+d.length;p<n.length;p++)s.set(n[p],p);}else {let h=n.length;n.push(...d),d.forEach((p,m)=>{s.set(p,h+m);});}i.push(...d);}}return n}var Ea="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type",td=(r,e={})=>{if(!r)return [];let{includeContainer:t=false,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(Ea));(t==true||t=="if-empty"&&i.length===0)&&Q(r)&&Ue(r)&&i.unshift(r);let s=[];for(let a of i)if(Ue(a)){if(dm(a)&&a.contentDocument){let l=a.contentDocument.body;s.push(...td(l,{getShadowRoot:n}));continue}s.push(a);}return n?hm(s,n,Ue):s};function Ue(r){return !Q(r)||r.closest("[inert]")?false:r.matches(Ea)&&qp(r)}function Lr(r,e={}){if(!r)return [];let{includeContainer:t,getShadowRoot:n}=e,i=Array.from(r.querySelectorAll(Ea));t&&on(r)&&i.unshift(r);let o=[];for(let s of i)if(on(s)){if(dm(s)&&s.contentDocument){let a=s.contentDocument.body;o.push(...Lr(a,{getShadowRoot:n}));continue}o.push(s);}if(n){let s=hm(o,n,on);return !s.length&&t?i:s}return !o.length&&t?i:o}function on(r){return Q(r)&&r.tabIndex>0?true:!Ue(r)||oC(r)?false:aC(r)}function pm(r,e={}){let t=Lr(r,e),n=t[0]||null,i=t[t.length-1]||null;return [n,i]}function Mr(r){return r.tabIndex<0&&(rC.test(r.localName)||Cr(r))&&!iC(r)?0:r.tabIndex}function Pa(r){let{root:e,getInitialEl:t,filter:n,enabled:i=true}=r;if(!i)return;let o=null;if(o||(o=typeof t=="function"?t():t),o||(o=e?.querySelector("[data-autofocus],[autofocus]")),!o){let s=Lr(e);o=n?s.filter(n)[0]:s[0];}return o||e||void 0}function mm(r){let e=r.currentTarget;if(!e)return false;let[t,n]=pm(e);return !(Ui(t)&&r.shiftKey||Ui(n)&&!r.shiftKey||!t&&!n)}var cC=class fm{constructor(){xa(this,"id",null),xa(this,"fn_cleanup"),xa(this,"cleanup",()=>{this.cancel();});}static create(){return new fm}request(e){this.cancel(),this.id=globalThis.requestAnimationFrame(()=>{this.id=null,this.fn_cleanup=e?.();});}cancel(){this.id!==null&&(globalThis.cancelAnimationFrame(this.id),this.id=null),this.fn_cleanup?.(),this.fn_cleanup=void 0;}isActive(){return this.id!==null}};function he(r){let e=cC.create();return e.request(r),e.cleanup}function gm(r){let e=new Set;function t(n){let i=globalThis.requestAnimationFrame(n);e.add(()=>globalThis.cancelAnimationFrame(i));}return t(()=>t(r)),function(){e.forEach(i=>i());}}function bm(r,e,t){let n=he(()=>{r.removeEventListener(e,i,true),t();}),i=()=>{n(),t();};return r.addEventListener(e,i,{once:true,capture:true}),n}function dC(r,e){if(!r)return;let{attributes:t,callback:n}=e,i=r.ownerDocument.defaultView||window,o=new i.MutationObserver(s=>{for(let a of s)a.type==="attributes"&&a.attributeName&&t.includes(a.attributeName)&&n(a);});return o.observe(r,{attributes:true,attributeFilter:t}),()=>o.disconnect()}function vm(r,e){let n=he,i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(dC(o,e));})),()=>{i.forEach(o=>o?.());}}function ym(r){let e=()=>{let t=ae(r);r.dispatchEvent(new t.MouseEvent("click"));};im()?bm(r,"keyup",e):queueMicrotask(e);}function La(r){let e=Zp(r);return Kp(e)?ue(e).body:Q(e)&&nd(e)?e:La(e)}var uC=/auto|scroll|overlay|hidden|clip/,hC=new Set(["inline","contents"]);function nd(r){let e=ae(r),{overflow:t,overflowX:n,overflowY:i,display:o}=e.getComputedStyle(r);return uC.test(t+i+n)&&!hC.has(o)}function kr(r,e){return Array.from(r?.querySelectorAll(e)??[])}var Ma=r=>r.id;function pC(r,e,t=Ma){return r.find(n=>t(n)===e)}function wm(r,e,t=Ma){let n=pC(r,e,t);return n?r.indexOf(n):-1}function mC(r){return r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth}function xm(r,e){let{rootEl:t,...n}=e||{};!r||!t||!nd(t)||!mC(t)||r.scrollIntoView(n);}var fC=r=>r.split("").map(e=>{let t=e.charCodeAt(0);return t>0&&t<128?e:t>=128&&t<=255?`/x${t.toString(16)}`.replace("/","\\"):""}).join("").trim(),gC=r=>fC(r.dataset?.valuetext??r.textContent??""),bC=(r,e)=>r.trim().toLowerCase().startsWith(e.toLowerCase());function Sm(r,e,t,n=Ma){let i=t?wm(r,t,n):-1,o=t?Up(r,i):r;return e.length===1&&(o=o.filter(a=>n(a)!==t)),o.find(a=>bC(gC(a),e))}function Yi(r,e){if(!r)return $i;let t=Object.keys(e).reduce((n,i)=>(n[i]=r.style.getPropertyValue(i),n),{});return vC(t,e)?$i:(Object.assign(r.style,e),()=>{Object.assign(r.style,t),r.style.length===0&&r.removeAttribute("style");})}function Cm(r,e,t){if(!r)return $i;let n=r.style.getPropertyValue(e);return n===t?$i:(r.style.setProperty(e,t),()=>{r.style.setProperty(e,n),r.style.length===0&&r.removeAttribute("style");})}function vC(r,e){return Object.keys(r).every(t=>r[t]===e[t])}function yC(r,e){let{state:t,activeId:n,key:i,timeout:o=350,itemToId:s}=e,a=t.keysSoFar+i,c=a.length>1&&Array.from(a).every(m=>m===a[0])?a[0]:a,d=r.slice(),u=Sm(d,c,n,s);function h(){clearTimeout(t.timer),t.timer=-1;}function p(m){t.keysSoFar=m,h(),m!==""&&(t.timer=+setTimeout(()=>{p(""),h();},o));}return p(a),u}var ka=Object.assign(yC,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:wC});function wC(r){return r.key.length===1&&!r.ctrlKey&&!r.metaKey}function xC(r,e,t){let{signal:n}=e;return [new Promise((s,a)=>{let l=setTimeout(()=>{a(new Error(`Timeout of ${t}ms exceeded`));},t);n.addEventListener("abort",()=>{clearTimeout(l),a(new DOMException("Promise aborted","AbortError"));}),r.then(c=>{n.aborted||(clearTimeout(l),s(c));}).catch(c=>{n.aborted||(clearTimeout(l),a(c));});}),()=>e.abort()]}function Tm(r,e){let{timeout:t,rootNode:n}=e,i=ae(n),o=ue(n),s=new i.AbortController;return xC(new Promise(a=>{let l=r();if(l){a(l);return}let c=new i.MutationObserver(()=>{let d=r();d&&d.isConnected&&(c.disconnect(),a(d));});c.observe(o.body,{childList:true,subtree:true});}),s,t)}function Em(r){let e=()=>r.getRootNode?.()??document,t=()=>ue(e());return {...r,getRootNode:e,getDoc:t,getWin:()=>t().defaultView??window,getActiveElement:()=>yt(e()),isActiveElement:Ui,getById:s=>e().getElementById(s)}}function Pm(r){return new Proxy({},{get(e,t){return t==="style"?n=>r({style:n}).style:r}})}var Lm={onFocus:"onFocusin",onBlur:"onFocusout",onChange:"onInput",onDoubleClick:"onDblclick",htmlFor:"for",className:"class",defaultValue:"value",defaultChecked:"checked"},SC=new Set(["viewBox","preserveAspectRatio"]),CC=r=>{let e="";for(let t in r){let n=r[t];n!=null&&(t.startsWith("--")||(t=t.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)),e+=`${t}:${n};`);}return e},Ir=Pm(r=>Object.entries(r).reduce((e,[t,n])=>{if(n===void 0)return e;if(t in Lm&&(t=Lm[t]),t==="style"&&typeof n=="object")return e.style=CC(n),e;let i=SC.has(t)?t:t.toLowerCase();return e[i]=n,e},{}));var Ia=new WeakMap,Mm=new Set(["value","checked","selected"]),TC=new Set(["viewBox","preserveAspectRatio","clipPath","clipRule","fillRule","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit"]),EC=r=>r.tagName==="svg"||r.namespaceURI==="http://www.w3.org/2000/svg",Aa=(r,e)=>EC(r)&&TC.has(e)?e:e.toLowerCase();function _e(r,e,t){let n=t||"default",i=Ia.get(r);i||(i=new Map,Ia.set(r,i));let o=i.get(n)||{},s=Object.keys(e),a=(f,g)=>{r.addEventListener(f.toLowerCase(),g);},l=(f,g)=>{r.removeEventListener(f.toLowerCase(),g);},c=f=>f.startsWith("on"),d=f=>!f.startsWith("on"),u=f=>a(f.substring(2),e[f]),h=f=>l(f.substring(2),e[f]),p=f=>{let g=e[f],b=o[f];if(g!==b){if(f==="class"){r.className=g??"";return}if(Mm.has(f)){r[f]=g??"";return}if(typeof g=="boolean"&&!f.includes("aria-")){r.toggleAttribute(Aa(r,f),g);return}if(f==="children"){r.innerHTML=g;return}if(g!=null){r.setAttribute(Aa(r,f),g);return}r.removeAttribute(Aa(r,f));}};for(let f in o)e[f]==null&&(f==="class"?r.className="":Mm.has(f)?r[f]="":r.removeAttribute(Aa(r,f)));return Object.keys(o).filter(c).forEach(f=>{l(f.substring(2),o[f]);}),s.filter(c).forEach(u),s.filter(d).forEach(p),i.set(n,e),function(){s.filter(c).forEach(h);let g=Ia.get(r);g&&(g.delete(n),g.size===0&&Ia.delete(r));}}function PC(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function rd(r,e){let t=PC();return t?(t[r]||(t[r]=e()),t[r]):e()}var Ar=rd("__zag__refSet",()=>new WeakSet);var LC=r=>typeof r=="object"&&r!==null&&"$$typeof"in r&&"props"in r,MC=r=>typeof r=="object"&&r!==null&&"__v_isVNode"in r,kC=r=>typeof r=="object"&&r!==null&&"nodeType"in r&&typeof r.nodeName=="string",IC=r=>LC(r)||MC(r)||kC(r),Ra=r=>r!==null&&typeof r=="object",id=r=>Ra(r)&&!Ar.has(r)&&(Array.isArray(r)||!(Symbol.iterator in r))&&!IC(r)&&!(r instanceof WeakMap)&&!(r instanceof WeakSet)&&!(r instanceof Error)&&!(r instanceof Number)&&!(r instanceof Date)&&!(r instanceof String)&&!(r instanceof RegExp)&&!(r instanceof ArrayBuffer)&&!(r instanceof Promise)&&!(r instanceof File)&&!(r instanceof Blob)&&!(r instanceof AbortController);var AC=Symbol();var km=Object.getPrototypeOf,od=new WeakMap,RC=r=>r&&(od.has(r)?od.get(r):km(r)===Object.prototype||km(r)===Array.prototype);var Im=r=>RC(r)&&r[AC]||null,sd=(r,e=true)=>{od.set(r,e);};var Bn=rd("__zag__proxyStateMap",()=>new WeakMap),DC=(r=Object.is,e=(a,l)=>new Proxy(a,l),t=new WeakMap,n=(a,l)=>{let c=t.get(a);if(c?.[0]===l)return c[1];let d=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return sd(d,true),t.set(a,[l,d]),Reflect.ownKeys(a).forEach(u=>{let h=Reflect.get(a,u);Ar.has(h)?(sd(h,false),d[u]=h):Bn.has(h)?d[u]=Am(h):d[u]=h;}),Object.freeze(d)},i=new WeakMap,o=[1,1],s=a=>{if(!Ra(a))throw new Error("object required");let l=i.get(a);if(l)return l;let c=o[0],d=new Set,u=(S,P=++o[0])=>{c!==P&&(c=P,d.forEach(k=>k(S,P)));},h=o[1],p=(S=++o[1])=>(h!==S&&!d.size&&(h=S,f.forEach(([P])=>{let k=P[1](S);k>c&&(c=k);})),c),m=S=>(P,k)=>{let T=[...P];T[1]=[S,...T[1]],u(T,k);},f=new Map,g=(S,P)=>{if(d.size){let k=P[3](m(S));f.set(S,[P,k]);}else f.set(S,[P]);},b=S=>{let P=f.get(S);P&&(f.delete(S),P[1]?.());},y=S=>(d.add(S),d.size===1&&f.forEach(([k,T],M)=>{let L=k[3](m(M));f.set(M,[k,L]);}),()=>{d.delete(S),d.size===0&&f.forEach(([k,T],M)=>{T&&(T(),f.set(M,[k]));});}),v=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),E=e(v,{deleteProperty(S,P){let k=Reflect.get(S,P);b(P);let T=Reflect.deleteProperty(S,P);return T&&u(["delete",[P],k]),T},set(S,P,k,T){let M=Reflect.has(S,P),L=Reflect.get(S,P,T);if(M&&(r(L,k)||i.has(k)&&r(L,i.get(k))))return true;b(P),Ra(k)&&(k=Im(k)||k);let C=k;if(!Object.getOwnPropertyDescriptor(S,P)?.set){!Bn.has(k)&&id(k)&&(C=Da(k));let I=!Ar.has(C)&&Bn.get(C);I&&g(P,I);}return Reflect.set(S,P,C,T),u(["set",[P],k,L]),true}});i.set(a,E);let x=[v,p,n,y];return Bn.set(E,x),Reflect.ownKeys(a).forEach(S=>{let P=Object.getOwnPropertyDescriptor(a,S);P.get||P.set?Object.defineProperty(v,S,P):E[S]=a[S];}),E})=>[s,Bn,Ar,r,e,id,t,n,i,o],[OC]=DC();function Da(r={}){return OC(r)}function Oa(r,e,t){let n=Bn.get(r);let i,o=[],s=n[3],a=false,c=s(d=>{if(o.push(d),t);i||(i=Promise.resolve().then(()=>{i=void 0,a&&e(o.splice(0));}));});return a=true,()=>{a=false,c();}}function Am(r){let e=Bn.get(r);let[t,n,i]=e;return i(t,n())}function Xi(r){let e=r().value??r().defaultValue;r().debug&&console.log(`[bindable > ${r().debug}] initial`,e);let t=r().isEqual??Object.is,n=Da({value:e}),i=()=>r().value!==void 0;return {initial:e,ref:n,get(){return i()?r().value:n.value},set(o){let s=i()?r().value:n.value,a=Ne(o)?o(s):o;r().debug&&console.log(`[bindable > ${r().debug}] setValue`,{next:a,prev:s}),i()||(n.value=a),t(a,s)||r().onChange?.(a,s);},invoke(o,s){r().onChange?.(o,s);},hash(o){return r().hash?.(o)??String(o)}}}Xi.cleanup=r=>{};Xi.ref=r=>{let e=r;return {get:()=>e,set:t=>{e=t;}}};function Rm(r){let e={current:r};return {get(t){return e.current[t]},set(t,n){e.current[t]=n;}}}function ad(r,e){if(!Vn(r)||!Vn(e))return e===void 0?r:e;let t={...r};for(let n of Object.keys(e)){let i=e[n],o=r[n];i!==void 0&&(Vn(o)&&Vn(i)?t[n]=ad(o,i):t[n]=i);}return t}var ld=class{constructor(r,e={}){J(this,"machine",r),J(this,"scope"),J(this,"context"),J(this,"prop"),J(this,"state"),J(this,"refs"),J(this,"computed"),J(this,"event",{type:""}),J(this,"previousEvent",{type:""}),J(this,"effects",new Map),J(this,"transition",null),J(this,"cleanups",[]),J(this,"subscriptions",[]),J(this,"userPropsRef"),J(this,"getEvent",()=>({...this.event,current:()=>this.event,previous:()=>this.previousEvent})),J(this,"getState",()=>({...this.state,matches:(...u)=>u.some(h=>$p(this.state.get(),h)),hasTag:u=>Wp(this.machine,this.state.get(),u)})),J(this,"debug",(...u)=>{this.machine.debug&&console.log(...u);}),J(this,"notify",()=>{this.publish();}),J(this,"send",u=>{this.status===Sr.Started&&queueMicrotask(()=>{if(!u)return;this.previousEvent=this.event,this.event=u,this.debug("send",u);let h=this.state.get(),p=u.type,{transitions:m,source:f}=Hp(this.machine,h,p),g=this.choose(m);if(!g)return;this.transition=g;let b=Wc(this.machine,g.target??h,f);this.debug("transition",g),b!==h?this.state.set(b):g.reenter?this.state.invoke(h,h):this.action(g.actions);});}),J(this,"action",u=>{let h=Ne(u)?u(this.getParams()):u;if(!h)return;let p=h.map(m=>{let f=this.machine.implementations?.actions?.[m];return f||wr(`[zag-js] No implementation found for action "${JSON.stringify(m)}"`),f});for(let m of p)m?.(this.getParams());}),J(this,"guard",u=>{if(Ne(u))return u(this.getParams());let h=this.machine.implementations?.guards?.[u];return h||wr(`[zag-js] No implementation found for guard "${JSON.stringify(u)}"`),h?.(this.getParams())}),J(this,"effect",u=>{let h=Ne(u)?u(this.getParams()):u;if(!h)return;let p=h.map(f=>{let g=this.machine.implementations?.effects?.[f];return g||wr(`[zag-js] No implementation found for effect "${JSON.stringify(f)}"`),g}),m=[];for(let f of p){let g=f?.(this.getParams());g&&m.push(g);}return ()=>m.forEach(f=>f?.())}),J(this,"choose",u=>Cp(u).find(h=>{let p=!h.guard;return yr(h.guard)?p=!!this.guard(h.guard):Ne(h.guard)&&(p=h.guard(this.getParams())),p})),J(this,"subscribe",u=>(this.subscriptions.push(u),()=>{let h=this.subscriptions.indexOf(u);h>-1&&this.subscriptions.splice(h,1);})),J(this,"status",Sr.NotStarted),J(this,"publish",()=>{this.callTrackers(),this.subscriptions.forEach(u=>u(this.service));}),J(this,"trackers",[]),J(this,"setupTrackers",()=>{this.machine.watch?.(this.getParams());}),J(this,"callTrackers",()=>{this.trackers.forEach(({deps:u,fn:h})=>{let p=u.map(m=>m());vr(h.prev,p)||(h(),h.prev=p);});}),J(this,"getParams",()=>({state:this.getState(),context:this.context,event:this.getEvent(),prop:this.prop,send:this.send,action:this.action,guard:this.guard,track:(u,h)=>{h.prev=u.map(p=>p()),this.trackers.push({deps:u,fn:h});},refs:this.refs,computed:this.computed,flush:Rp,scope:this.scope,choose:this.choose})),this.userPropsRef={current:e};let{id:t,ids:n,getRootNode:i}=_i(e);this.scope=Em({id:t,ids:n,getRootNode:i});let o=u=>{let h=_i(this.userPropsRef.current);return (r.props?.({props:nn(h),scope:this.scope})??h)[u]};this.prop=o;let s=r.context?.({prop:o,bindable:Xi,scope:this.scope,flush(u){queueMicrotask(u);},getContext(){return a},getComputed(){return l},getRefs(){return c},getEvent:this.getEvent.bind(this)});s&&Object.values(s).forEach(u=>{let h=Oa(u.ref,()=>this.notify());this.cleanups.push(h);});let a={get(u){return s?.[u].get()},set(u,h){s?.[u].set(h);},initial(u){return s?.[u].initial},hash(u){let h=s?.[u].get();return s?.[u].hash(h)}};this.context=a;let l=u=>(Bi(r.computed,()=>"[zag-js] No computed object found on machine"),r.computed[u]({context:a,event:this.getEvent(),prop:o,refs:this.refs,scope:this.scope,computed:l}));this.computed=l;let c=Rm(r.refs?.({prop:o,context:a})??{});this.refs=c;let d=Xi(()=>({defaultValue:Wc(r,r.initialState({prop:o})),onChange:(u,h)=>{let{exiting:p,entering:m}=zp(this.machine,h,u,this.transition?.reenter);if(p.forEach(f=>{this.effects.get(f.path)?.(),this.effects.delete(f.path);}),p.forEach(f=>{this.action(f.state?.exit);}),this.action(this.transition?.actions),m.forEach(f=>{let g=this.effect(f.state?.effects);if(g){let b=this.effects.get(f.path);this.effects.set(f.path,b?tn(b,g):g);}}),h===zi){this.action(r.entry);let f=this.effect(r.effects);if(f){let g=this.effects.get(zi);this.effects.set(zi,g?tn(g,f):f);}}m.forEach(f=>{this.action(f.state?.entry);});}}));this.state=d,this.cleanups.push(Oa(this.state.ref,()=>this.notify()));}updateProps(r){let e=this.userPropsRef.current;this.userPropsRef.current=()=>{let t=_i(e),n=_i(r);return ad(t,n)},this.notify();}start(){this.status=Sr.Started,this.debug("initializing..."),this.state.invoke(this.state.initial,zi),this.setupTrackers();}stop(){this.effects.forEach(r=>r?.()),this.effects.clear(),this.transition=null,this.action(this.machine.exit),this.cleanups.forEach(r=>r()),this.cleanups=[],this.subscriptions=[],this.status=Sr.Stopped,this.debug("unmounting...");}get service(){return {state:this.getState(),send:this.send,context:this.context,prop:this.prop,scope:this.scope,refs:this.refs,computed:this.computed,event:this.getEvent(),getStatus:()=>this.status}}};function Fa(r,e,t){let n=new ld(r,e),i=n.subscribe(t);return n.start(),t(n.service),{service:n.service,flush:()=>t(n.service),stop:()=>{i(),n.stop();}}}var FC=0;function Na(r){return `${r}-${++FC}`}function Hn(r,e=8){return `${r}::-webkit-scrollbar{width:${e}px;height:${e}px;}${r}::-webkit-scrollbar-thumb{background:var(--vela-scroll);border-radius:4px;border:2px solid transparent;background-clip:padding-box;}${r}::-webkit-scrollbar-track{background:transparent;}${r}::-webkit-scrollbar-button{display:none;width:0;height:0;}`}var Dm="outline:none;transition:border-color .12s ease,box-shadow .12s ease;",Om="border-color:var(--vela-focus);box-shadow:0 0 0 3px var(--vela-focus-soft);";function ie(r,e,t=document){if(typeof document>"u")return;let n=t instanceof Document?t.head:t;if(t.getElementById?.(r)??n.querySelector(`#${CSS.escape(r)}`))return;let i=document.createElement("style");i.id=r,i.textContent=e,n.appendChild(i);}function ke(r,e=document){let t=e.createElement("span");t.className="vela-icon",t.setAttribute("aria-hidden","true");let n=ts(r);return n&&(t.innerHTML=n),t}var Vt=(r,e=[])=>({parts:(...t)=>{if(NC(e))return Vt(r,t);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...t)=>Vt(r,[...e,...t]),omit:(...t)=>Vt(r,e.filter(n=>!t.includes(n))),rename:t=>Vt(t,e),keys:()=>e,build:()=>[...new Set(e)].reduce((t,n)=>Object.assign(t,{[n]:{selector:[`&[data-scope="${Rr(r)}"][data-part="${Rr(n)}"]`,`& [data-scope="${Rr(r)}"][data-part="${Rr(n)}"]`].join(", "),attrs:{"data-scope":Rr(r),"data-part":Rr(n)}}}),{})}),Rr=r=>r.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),NC=r=>r.length===0;var VC=Vt("menu").parts("arrow","arrowTip","content","contextTrigger","indicator","item","itemGroup","itemGroupLabel","itemIndicator","itemText","positioner","separator","trigger","triggerItem"),Ce=VC.build();var Vm=["top","right","bottom","left"];var wt=Math.min,nt=Math.max,qi=Math.round,Zi=Math.floor,xt=r=>({x:r,y:r}),_C={left:"right",right:"left",bottom:"top",top:"bottom"};function cd(r,e,t){return nt(r,wt(e,t))}function St(r,e){return typeof r=="function"?r(e):r}function _t(r){return r.split("-")[0]}function zn(r){return r.split("-")[1]}function _a(r){return r==="x"?"y":"x"}function Ba(r){return r==="y"?"height":"width"}function rt(r){let e=r[0];return e==="t"||e==="b"?"y":"x"}function Ha(r){return _a(rt(r))}function _m(r,e,t){t===void 0&&(t=false);let n=zn(r),i=Ha(r),o=Ba(i),s=i==="x"?n===(t?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=ji(s)),[s,ji(s)]}function Bm(r){let e=ji(r);return [Va(r),e,Va(e)]}function Va(r){return r.includes("start")?r.replace("start","end"):r.replace("end","start")}var Fm=["left","right"],Nm=["right","left"],BC=["top","bottom"],HC=["bottom","top"];function zC(r,e,t){switch(r){case "top":case "bottom":return t?e?Nm:Fm:e?Fm:Nm;case "left":case "right":return e?BC:HC;default:return []}}function Hm(r,e,t,n){let i=zn(r),o=zC(_t(r),t==="start",n);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(Va)))),o}function ji(r){let e=_t(r);return _C[e]+r.slice(e.length)}function $C(r){var e,t,n,i;return {top:(e=r.top)!=null?e:0,right:(t=r.right)!=null?t:0,bottom:(n=r.bottom)!=null?n:0,left:(i=r.left)!=null?i:0}}function dd(r){return typeof r!="number"?$C(r):{top:r,right:r,bottom:r,left:r}}function $n(r){let{x:e,y:t,width:n,height:i}=r;return {width:n,height:i,top:t,left:e,right:e+n,bottom:t+i,x:e,y:t}}function zm(r,e,t){let{reference:n,floating:i}=r,o=rt(e),s=Ha(e),a=Ba(s),l=_t(e),c=o==="y",d=n.x+n.width/2-i.width/2,u=n.y+n.height/2-i.height/2,h=n[a]/2-i[a]/2,p;switch(l){case "top":p={x:d,y:n.y-i.height};break;case "bottom":p={x:d,y:n.y+n.height};break;case "right":p={x:n.x+n.width,y:u};break;case "left":p={x:n.x-i.width,y:u};break;default:p={x:n.x,y:n.y};}let m=zn(e);return m&&(p[s]+=h*(m==="end"?1:-1)*(t&&c?-1:1)),p}async function Gm(r,e){var t;e===void 0&&(e={});let{x:n,y:i,platform:o,rects:s,elements:a,strategy:l}=r,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:h=false,padding:p=0}=St(e,r),m=dd(p),g=a[h?u==="floating"?"reference":"floating":u],b=$n(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(g)))==null||t?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),y=u==="floating"?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),w=await(o.isElement==null?void 0:o.isElement(v))&&await(o.getScale==null?void 0:o.getScale(v))||{x:1,y:1},E=$n(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:v,strategy:l}):y);return {top:(b.top-E.top+m.top)/w.y,bottom:(E.bottom-b.bottom+m.bottom)/w.y,left:(b.left-E.left+m.left)/w.x,right:(E.right-b.right+m.right)/w.x}}var WC=50,Um=async(r,e,t)=>{let{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:s}=t,a=s.detectOverflow?s:{...s,detectOverflow:Gm},l=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:r,floating:e,strategy:i}),{x:d,y:u}=zm(c,n,l),h=n,p=0,m={};for(let f=0;f<o.length;f++){let g=o[f];if(!g)continue;let{name:b,fn:y}=g,{x:v,y:w,data:E,reset:x}=await y({x:d,y:u,initialPlacement:n,placement:h,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:r,floating:e}});d=v??d,u=w??u,m[b]={...m[b],...E},x&&p<WC&&(p++,typeof x=="object"&&(x.placement&&(h=x.placement),x.rects&&(c=x.rects===true?await s.getElementRects({reference:r,floating:e,strategy:i}):x.rects),{x:d,y:u}=zm(c,h,l)),f=-1);}return {x:d,y:u,placement:h,strategy:i,middlewareData:m}},Ym=r=>({name:"arrow",options:r,async fn(e){let{x:t,y:n,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=e,{element:c,padding:d=0}=St(r,e)||{};if(c==null)return {};let u=dd(d),h={x:t,y:n},p=Ha(i),m=Ba(p),f=await s.getDimensions(c),g=p==="y",b=g?"top":"left",y=g?"bottom":"right",v=g?"clientHeight":"clientWidth",w=o.reference[m]+o.reference[p]-h[p]-o.floating[m],E=h[p]-o.reference[p],x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),S=x?x[v]:0;(!S||!await(s.isElement==null?void 0:s.isElement(x)))&&(S=a.floating[v]||o.floating[m]);let P=w/2-E/2,k=S/2-f[m]/2-1,T=wt(u[b],k),M=wt(u[y],k),L=S-f[m]-M,C=S/2-f[m]/2+P,I=cd(T,C,L),V=!l.arrow&&zn(i)!=null&&C!==I&&o.reference[m]/2-(C<T?T:M)-f[m]/2<0,Y=V?C<T?C-T:C-L:0;return {[p]:h[p]+Y,data:{[p]:I,centerOffset:C-I-Y,...V&&{alignmentOffset:Y}},reset:V}}});var Km=function(r){return r===void 0&&(r={}),{name:"flip",options:r,async fn(e){var t,n;let{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:d=true,crossAxis:u=true,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:f=true,...g}=St(r,e);if((t=o.arrow)!=null&&t.alignmentOffset)return {};let b=_t(i),y=rt(a),v=_t(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),E=h||(v||!f?[ji(a)]:Bm(a)),x=m!=="none";!h&&x&&E.push(...Hm(a,f,m,w));let S=[a,...E],P=await l.detectOverflow(e,g),k=[],T=((n=o.flip)==null?void 0:n.overflows)||[];if(d&&k.push(P[b]),u){let I=_m(i,s,w);k.push(P[I[0]],P[I[1]]);}if(T=[...T,{placement:i,overflows:k}],!k.every(I=>I<=0)){var M,L;let I=(((M=o.flip)==null?void 0:M.index)||0)+1,V=S[I];if(V&&(!(u==="alignment"?y!==rt(V):false)||T.every(z=>rt(z.placement)===y?z.overflows[0]>0:true)))return {data:{index:I,overflows:T},reset:{placement:V}};let Y=(L=T.filter(K=>K.overflows[0]<=0).sort((K,z)=>K.overflows[1]-z.overflows[1])[0])==null?void 0:L.placement;if(!Y)switch(p){case "bestFit":{var C;let K=(C=T.filter(z=>{if(x){let ze=rt(z.placement);return ze===y||ze==="y"}return true}).map(z=>[z.placement,z.overflows.filter(ze=>ze>0).reduce((ze,Sw)=>ze+Sw,0)]).sort((z,ze)=>z[1]-ze[1])[0])==null?void 0:C[0];K&&(Y=K);break}case "initialPlacement":Y=a;break}if(i!==Y)return {reset:{placement:Y}}}return {}}}};function $m(r,e){return {top:r.top-e.height,right:r.right-e.width,bottom:r.bottom-e.height,left:r.left-e.width}}function Wm(r){return Vm.some(e=>r[e]>=0)}var Xm=function(r){return r===void 0&&(r={}),{name:"hide",options:r,async fn(e){let{rects:t,platform:n}=e,{strategy:i="referenceHidden",...o}=St(r,e);switch(i){case "referenceHidden":{let s=await n.detectOverflow(e,{...o,elementContext:"reference"}),a=$m(s,t.reference);return {data:{referenceHiddenOffsets:a,referenceHidden:Wm(a)}}}case "escaped":{let s=await n.detectOverflow(e,{...o,altBoundary:true}),a=$m(s,t.floating);return {data:{escapedOffsets:a,escaped:Wm(a)}}}default:return {}}}}};var jm=new Set(["left","top"]);async function GC(r,e){let{placement:t,platform:n,elements:i}=r,o=await(n.isRTL==null?void 0:n.isRTL(i.floating)),s=_t(t),a=zn(t),l=rt(t)==="y",c=jm.has(s)?-1:1,d=o&&l?-1:1,u=St(e,r),{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*d,y:h*c}:{x:h*c,y:p*d}}var qm=function(r){return r===void 0&&(r=0),{name:"offset",options:r,async fn(e){var t,n;let{x:i,y:o,placement:s,middlewareData:a}=e,l=await GC(e,r);return s===((t=a.offset)==null?void 0:t.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},Zm=function(r){return r===void 0&&(r={}),{name:"shift",options:r,async fn(e){let{x:t,y:n,placement:i,platform:o}=e,{mainAxis:s=true,crossAxis:a=false,limiter:l={fn:y=>{let{x:v,y:w}=y;return {x:v,y:w}}},...c}=St(r,e),d={x:t,y:n},u=await o.detectOverflow(e,c),h=rt(i),p=_a(h),m=d[p],f=d[h],g=(y,v)=>cd(v+u[y==="y"?"top":"left"],v,v-u[y==="y"?"bottom":"right"]);s&&(m=g(p,m)),a&&(f=g(h,f));let b=l.fn({...e,[p]:m,[h]:f});return {...b,data:{x:b.x-t,y:b.y-n,enabled:{[p]:s,[h]:a}}}}}},Jm=function(r){return r===void 0&&(r={}),{options:r,fn(e){var t,n;let{x:i,y:o,placement:s,rects:a,middlewareData:l}=e,{offset:c=0,mainAxis:d=true,crossAxis:u=true}=St(r,e),h={x:i,y:o},p=rt(s),m=_a(p),f=h[m],g=h[p],b=St(c,e),y=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:(t=b.mainAxis)!=null?t:0,crossAxis:(n=b.crossAxis)!=null?n:0};if(d){let E=m==="y"?"height":"width",x=a.reference[m]-a.floating[E]+y.mainAxis,S=a.reference[m]+a.reference[E]-y.mainAxis;f<x?f=x:f>S&&(f=S);}if(u){var v,w;let E=m==="y"?"width":"height",x=jm.has(_t(s)),S=a.reference[p]-a.floating[E]+(x&&((v=l.offset)==null?void 0:v[p])||0)+(x?0:y.crossAxis),P=a.reference[p]+a.reference[E]+(x?0:((w=l.offset)==null?void 0:w[p])||0)-(x?y.crossAxis:0);g<S?g=S:g>P&&(g=P);}return {[m]:f,[p]:g}}}},Qm=function(r){return r===void 0&&(r={}),{name:"size",options:r,async fn(e){let{placement:t,rects:n,platform:i,elements:o}=e,{apply:s=()=>{},...a}=St(r,e),l=await i.detectOverflow(e,a),c=_t(t),d=zn(t),u=rt(t)==="y",{width:h,height:p}=n.floating,m,f;c==="top"||c==="bottom"?(m=c,f=d===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(f=c,m=d==="end"?"top":"bottom");let g=p-l.top-l.bottom,b=h-l.left-l.right,y=wt(p-l[m],g),v=wt(h-l[f],b),w=e.middlewareData.shift,E=!w,x=y,S=v;w!=null&&w.enabled.x&&(S=b),w!=null&&w.enabled.y&&(x=g),E&&!d&&(u?S=h-2*nt(l.left,l.right):x=p-2*nt(l.top,l.bottom)),await s({...e,availableWidth:S,availableHeight:x});let P=await i.getDimensions(o.floating);return h!==P.width||p!==P.height?{reset:{rects:true}}:{}}}};function za(){return typeof window<"u"}function Gn(r){return tf(r)?(r.nodeName||"").toLowerCase():"#document"}function Ie(r){var e;return (r==null||(e=r.ownerDocument)==null?void 0:e.defaultView)||window}function Ct(r){var e;return (e=(tf(r)?r.ownerDocument:r.document)||window.document)==null?void 0:e.documentElement}function tf(r){return za()?r instanceof Node||r instanceof Ie(r).Node:false}function it(r){return za()?r instanceof Element||r instanceof Ie(r).Element:false}function Bt(r){return za()?r instanceof HTMLElement||r instanceof Ie(r).HTMLElement:false}function ef(r){return !za()||typeof ShadowRoot>"u"?false:r instanceof ShadowRoot||r instanceof Ie(r).ShadowRoot}function Ji(r){let{overflow:e,overflowX:t,overflowY:n,display:i}=ot(r);return /auto|scroll|overlay|hidden|clip/.test(e+n+t)&&i!=="inline"&&i!=="contents"}function nf(r){return /^(table|td|th)$/.test(Gn(r))}function Qi(r){try{if(r.matches(":popover-open"))return !0}catch{}try{return r.matches(":modal")}catch{return false}}var UC=/transform|translate|scale|rotate|perspective|filter/,YC=/paint|layout|strict|content/,Wn=r=>!!r&&r!=="none",ud;function $a(r){let e=it(r)?ot(r):r;return Wn(e.transform)||Wn(e.translate)||Wn(e.scale)||Wn(e.rotate)||Wn(e.perspective)||!Wa()&&(Wn(e.backdropFilter)||Wn(e.filter))||UC.test(e.willChange||"")||YC.test(e.contain||"")}function rf(r){let e=sn(r);for(;Bt(e)&&!Or(e);){if($a(e))return e;if(Qi(e))return null;e=sn(e);}return null}function Wa(){return ud==null&&(ud=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ud}function Or(r){return /^(html|body|#document)$/.test(Gn(r))}function ot(r){return Ie(r).getComputedStyle(r)}function eo(r){return it(r)?{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}:{scrollLeft:r.scrollX,scrollTop:r.scrollY}}function sn(r){if(Gn(r)==="html")return r;let e=r.assignedSlot||r.parentNode||ef(r)&&r.host||Ct(r);return ef(e)?e.host:e}function of(r){let e=sn(r);return Or(e)?(r.ownerDocument||r).body:Bt(e)&&Ji(e)?e:of(e)}function Dr(r,e,t){var n;e===void 0&&(e=[]),t===void 0&&(t=true);let i=of(r),o=i===((n=r.ownerDocument)==null?void 0:n.body),s=Ie(i);if(o){let a=Ga(s);return e.concat(s,s.visualViewport||[],Ji(i)?i:[],a&&t?Dr(a):[])}else return e.concat(i,Dr(i,[],t))}function Ga(r){return r.parent&&Object.getPrototypeOf(r.parent)?r.frameElement:null}function lf(r){let e=ot(r),t=parseFloat(e.width)||0,n=parseFloat(e.height)||0,i=Bt(r),o=i?r.offsetWidth:t,s=i?r.offsetHeight:n,a=qi(t)!==o||qi(n)!==s;return a&&(t=o,n=s),{width:t,height:n,$:a}}function pd(r){return it(r)?r:r.contextElement}function Fr(r){let e=pd(r);if(!Bt(e))return xt(1);let t=e.getBoundingClientRect(),{width:n,height:i,$:o}=lf(e),s=(o?qi(t.width):t.width)/n,a=(o?qi(t.height):t.height)/i;return (!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var KC=xt(0);function cf(r){let e=Ie(r);return !Wa()||!e.visualViewport?KC:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function XC(r,e,t){return e===void 0&&(e=false),!!t&&e&&t===Ie(r)}function Un(r,e,t,n){e===void 0&&(e=false),t===void 0&&(t=false);let i=r.getBoundingClientRect(),o=pd(r),s=xt(1);e&&(n?it(n)&&(s=Fr(n)):s=Fr(r));let a=XC(o,t,n)?cf(o):xt(0),l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,d=i.width/s.x,u=i.height/s.y;if(o&&n){let h=Ie(o),p=it(n)?Ie(n):n,m=h,f=Ga(m);for(;f&&p!==m;){let g=Fr(f),b=f.getBoundingClientRect(),y=ot(f),v=b.left+(f.clientLeft+parseFloat(y.paddingLeft))*g.x,w=b.top+(f.clientTop+parseFloat(y.paddingTop))*g.y;l*=g.x,c*=g.y,d*=g.x,u*=g.y,l+=v,c+=w,m=Ie(f),f=Ga(m);}}return $n({width:d,height:u,x:l,y:c})}function Ua(r,e){let t=eo(r).scrollLeft;return e?e.left+t:Un(Ct(r)).left+t}function df(r,e){let t=r.getBoundingClientRect(),n=t.left+e.scrollLeft-Ua(r,t),i=t.top+e.scrollTop;return {x:n,y:i}}function jC(r){let{elements:e,rect:t,offsetParent:n,strategy:i}=r,o=i==="fixed",s=Ct(n),a=e?Qi(e.floating):false;if(n===s||a&&o)return t;let l={scrollLeft:0,scrollTop:0},c=xt(1),d=xt(0),u=Bt(n);if((u||!o)&&((Gn(n)!=="body"||Ji(s))&&(l=eo(n)),u)){let p=Un(n);c=Fr(n),d.x=p.x+n.clientLeft,d.y=p.y+n.clientTop;}let h=s&&!u&&!o?df(s,l):xt(0);return {width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+d.x+h.x,y:t.y*c.y-l.scrollTop*c.y+d.y+h.y}}function qC(r){return r.getClientRects?Array.from(r.getClientRects()):[]}function ZC(r){let e=eo(r),t=r.ownerDocument.body,n=nt(r.scrollWidth,r.clientWidth,t.scrollWidth,t.clientWidth),i=nt(r.scrollHeight,r.clientHeight,t.scrollHeight,t.clientHeight),o=-e.scrollLeft+Ua(r),s=-e.scrollTop;return ot(t).direction==="rtl"&&(o+=nt(r.clientWidth,t.clientWidth)-n),{width:n,height:i,x:o,y:s}}var JC=25;function QC(r,e,t){t===void 0&&(t="viewport");let n=t==="layoutViewport",i=Ie(r),o=Ct(r),s=i.visualViewport,a=o.clientWidth,l=o.clientHeight,c=0,d=0;if(s){let h=!Wa()||e==="fixed";n?h||(c=-s.offsetLeft,d=-s.offsetTop):(a=s.width,l=s.height,h&&(c=s.offsetLeft,d=s.offsetTop));}if(Ua(o)<=0){let h=o.ownerDocument,p=h.body,m=getComputedStyle(p),f=h.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(o.clientWidth-p.clientWidth-f),b=getComputedStyle(o).scrollbarGutter==="stable both-edges"?g/2:g;b<=JC&&(a-=b);}return {width:a,height:l,x:c,y:d}}function e1(r,e){let t=Un(r,true,e==="fixed"),n=t.top+r.clientTop,i=t.left+r.clientLeft,o=Fr(r),s=r.clientWidth*o.x,a=r.clientHeight*o.y,l=i*o.x,c=n*o.y;return {width:s,height:a,x:l,y:c}}function sf(r,e,t){let n;if(e==="viewport"||e==="layoutViewport")n=QC(r,t,e);else if(e==="document")n=ZC(Ct(r));else if(it(e))n=e1(e,t);else {let i=cf(r);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height};}return $n(n)}function t1(r,e){let t=e.get(r);if(t)return t;let n=Dr(r,[],false).filter(a=>it(a)&&Gn(a)!=="body"),i=null,o=ot(r).position==="fixed",s=o?sn(r):r;for(;it(s)&&!Or(s);){let a=ot(s),l=$a(s),c=i?i.position:o?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?n=n.filter(u=>u!==s):i=a,s=sn(s);}return e.set(r,n),n}function n1(r){let{element:e,boundary:t,rootBoundary:n,strategy:i}=r,s=[...t==="clippingAncestors"?Qi(e)?[]:t1(e,this._c):[].concat(t),n],a=sf(e,s[0],i),l=a.top,c=a.right,d=a.bottom,u=a.left;for(let h=1;h<s.length;h++){let p=sf(e,s[h],i);l=nt(p.top,l),c=wt(p.right,c),d=wt(p.bottom,d),u=nt(p.left,u);}return {width:c-u,height:d-l,x:u,y:l}}function r1(r){let{width:e,height:t}=lf(r);return {width:e,height:t}}function i1(r,e,t){let n=Bt(e),i=Ct(e),o=t==="fixed",s=Un(r,true,o,e),a={scrollLeft:0,scrollTop:0},l=xt(0);if((n||!o)&&((Gn(e)!=="body"||Ji(i))&&(a=eo(e)),n)){let h=Un(e,true,o,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop;}!n&&i&&(l.x=Ua(i));let c=i&&!n&&!o?df(i,a):xt(0),d=s.left+a.scrollLeft-l.x-c.x,u=s.top+a.scrollTop-l.y-c.y;return {x:d,y:u,width:s.width,height:s.height}}function hd(r){return ot(r).position==="static"}function af(r,e){if(!Bt(r)||ot(r).position==="fixed")return null;if(e)return e(r);let t=r.offsetParent;return Ct(r)===t&&(t=t.ownerDocument.body),t}function uf(r,e){let t=Ie(r);if(Qi(r))return t;if(!Bt(r)){let i=sn(r);for(;i&&!Or(i);){if(it(i)&&!hd(i))return i;i=sn(i);}return t}let n=af(r,e);for(;n&&nf(n)&&hd(n);)n=af(n,e);return n&&Or(n)&&hd(n)&&!$a(n)?t:n||rf(r)||t}var o1=async function(r){let e=this.getOffsetParent||uf,t=this.getDimensions,n=await t(r.floating);return {reference:i1(r.reference,await e(r.floating),r.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function s1(r){return ot(r).direction==="rtl"}var a1={convertOffsetParentRelativeRectToViewportRelativeRect:jC,getDocumentElement:Ct,getClippingRect:n1,getOffsetParent:uf,getElementRects:o1,getClientRects:qC,getDimensions:r1,getScale:Fr,isElement:it,isRTL:s1};function hf(r,e){return r.x===e.x&&r.y===e.y&&r.width===e.width&&r.height===e.height}function l1(r,e,t){let n=null,i,o=Ct(r);function s(){var d;clearTimeout(i),(d=n)==null||d.disconnect(),n=null;}function a(d,u){d===void 0&&(d=false),u===void 0&&(u=1),s();let h=r.getBoundingClientRect(),{left:p,top:m,width:f,height:g}=h;if(d||e(),!f||!g)return;let b=Zi(m),y=Zi(o.clientWidth-(p+f)),v=Zi(o.clientHeight-(m+g)),w=Zi(p),x={rootMargin:-b+"px "+-y+"px "+-v+"px "+-w+"px",threshold:nt(0,wt(1,u))||1},S=true;function P(k){let T=k[0].intersectionRatio;if(!hf(h,r.getBoundingClientRect()))return a();if(T!==u){if(!S)return a();T?a(false,T):i=setTimeout(()=>{a(false,1e-7);},1e3);}S=false;}try{n=new IntersectionObserver(P,{...x,root:o.ownerDocument});}catch{n=new IntersectionObserver(P,x);}n.observe(r);}let l=Ie(r),c=()=>a(t);return l.addEventListener("resize",c),a(true),()=>{l.removeEventListener("resize",c),s();}}function pf(r,e,t,n){n===void 0&&(n={});let{ancestorScroll:i=true,ancestorResize:o=true,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=false}=n,c=pd(r),d=i||o?[...c?Dr(c):[],...e?Dr(e):[]]:[];d.forEach(b=>{i&&b.addEventListener("scroll",t),o&&b.addEventListener("resize",t);});let u=c&&a?l1(c,t,o):null,h=-1,p=null;s&&(p=new ResizeObserver(b=>{let[y]=b;y&&y.target===c&&p&&e&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var v;(v=p)==null||v.observe(e);})),t();}),c&&!l&&p.observe(c),e&&p.observe(e));let m,f=l?Un(r):null;l&&g();function g(){let b=Un(r);f&&!hf(f,b)&&t(),f=b,m=requestAnimationFrame(g);}return t(),()=>{var b;d.forEach(y=>{i&&y.removeEventListener("scroll",t),o&&y.removeEventListener("resize",t);}),u?.(),(b=p)==null||b.disconnect(),p=null,l&&cancelAnimationFrame(m);}}var mf=qm;var ff=Zm,gf=Km,bf=Qm,vf=Xm,yf=Ym;var wf=Jm,xf=(r,e,t)=>{let n=new Map,i=t??{},o={...a1,...i.platform,_c:n};return Um(r,e,{...i,platform:o})};function Sf(r=0,e=0,t=0,n=0){if(typeof DOMRect=="function")return new DOMRect(r,e,t,n);let i={x:r,y:e,width:t,height:n,top:e,right:r+t,bottom:e+n,left:r};return {...i,toJSON:()=>i}}function c1(r){if(!r)return Sf();let{x:e,y:t,width:n,height:i}=r;return Sf(e,t,n,i)}function Cf(r,e){return {contextElement:Q(r)?r:r?.contextElement,getBoundingClientRect:()=>{let t=r,n=e?.(t);return n||!t?c1(n):t.getBoundingClientRect()}}}var to=r=>({variable:r,reference:`var(${r})`}),Tt={arrowSize:to("--arrow-size"),arrowSizeHalf:to("--arrow-size-half"),arrowBg:to("--arrow-background"),transformOrigin:to("--transform-origin"),arrowOffset:to("--arrow-offset")},d1=r=>r==="top"||r==="bottom"?"y":"x";function Tf(r,e){return {name:"transformOrigin",fn(t){let{elements:n,middlewareData:i,placement:o,rects:s,y:a}=t,l=o.split("-")[0],c=d1(l),d=i.arrow?.x||0,u=i.arrow?.y||0,h=e?.clientWidth||0,p=e?.clientHeight||0,m=d+h/2,f=u+p/2,g=Math.abs(i.shift?.y||0),b=s.reference.height/2,y=p/2,v=r.offset?.mainAxis??r.gutter,w=typeof v=="number"?v+y:v??y,E=g>w,x={top:`${m}px calc(100% + ${w}px)`,bottom:`${m}px ${-w}px`,left:`calc(100% + ${w}px) ${f}px`,right:`${-w}px ${f}px`}[l],S=`${m}px ${s.reference.y+b-a}px`,P=!!r.overlap&&c==="y"&&E;return n.floating.style.setProperty(Tt.transformOrigin.variable,P?S:x),{data:{transformOrigin:P?S:x}}}}}var Ef={name:"rects",fn({rects:r}){return {data:r}}},Pf=r=>{if(r)return {name:"shiftArrow",fn({placement:e,middlewareData:t}){if(!t.arrow)return {};let{x:n,y:i}=t.arrow,o=e.split("-")[0];return Object.assign(r.style,{left:n!=null?`${n}px`:"",top:i!=null?`${i}px`:"",[o]:`calc(100% + ${Tt.arrowOffset.reference})`}),{}}}};function Lf(r){let[e,t]=r.split("-");return {side:e,align:t,hasAlign:t!=null}}function no(r){return r.split("-")[0]}var u1={strategy:"absolute",placement:"bottom",listeners:true,restoreStyles:false,gutter:8,flip:true,slide:true,overlap:false,sameWidth:false,fitViewport:false,overflowPadding:8,arrowPadding:4};function Mf(r,e){let t=r.devicePixelRatio||1;return Math.round(e*t)/t}function Nr(r,e){return r!=null&&Math.abs(r-e)<.5}function Ya(r){return typeof r=="function"?r():r==="clipping-ancestors"?"clippingAncestors":r}function h1(r,e,t){let n=r||e.createElement("div");return yf({element:n,padding:t.arrowPadding})}function p1(r,e){if(!Ip(e.offset??e.gutter))return mf(({placement:t})=>{let n=(r?.clientHeight||0)/2,i=e.offset?.mainAxis??e.gutter,o=typeof i=="number"?i+n:i??n,{hasAlign:s}=Lf(t),a=s?void 0:e.shift,l=e.offset?.crossAxis??a;return nn({crossAxis:l,mainAxis:o,alignmentAxis:e.shift})})}function m1(r){if(r.flip)return gf(()=>{let e=Ya(r.boundary);return {...e?{boundary:e}:void 0,padding:r.overflowPadding,fallbackPlacements:r.flip===true?void 0:r.flip}})}function f1(r){if(!(!r.slide&&!r.overlap))return ff(()=>{let e=Ya(r.boundary);return {...e?{boundary:e}:void 0,mainAxis:r.slide,crossAxis:r.overlap,padding:r.overflowPadding,limiter:wf()}})}function g1(r){if(r.sizeMiddleware===false&&!r.sameWidth&&!r.fitViewport)return;let e,t,n,i;return bf(()=>{let o=Ya(r.boundary);return {padding:r.overflowPadding,...o?{boundary:o}:void 0,apply({elements:s,rects:a,availableHeight:l,availableWidth:c}){let d=s.floating,u=Math.round(a.reference.width),h=Math.round(a.reference.height);c=Math.floor(c),l=Math.floor(l),Nr(e,u)||(d.style.setProperty("--reference-width",`${u}px`),e=u),Nr(t,h)||(d.style.setProperty("--reference-height",`${h}px`),t=h),Nr(n,c)||(d.style.setProperty("--available-width",`${c}px`),n=c),Nr(i,l)||(d.style.setProperty("--available-height",`${l}px`),i=l);}}})}function b1(r){if(r.hideWhenDetached)return vf(()=>({strategy:"referenceHidden",boundary:Ya(r.boundary)??"clippingAncestors"}))}function v1(r){return r?r===true?{ancestorResize:true,ancestorScroll:true,elementResize:true,layoutShift:true}:r:{}}var y1=["transform","visibility","pointer-events","--x","--y","--z-index","--reference-width","--reference-height","--available-width","--available-height","--transform-origin"],w1=["top","right","bottom","left"];function kf(r,e){if(!r)return _c;let t=new Map(e.map(n=>[n,r.style.getPropertyValue(n)]));return ()=>{t.forEach((n,i)=>{n?r.style.setProperty(i,n):r.style.removeProperty(i);}),r.style.length===0&&r.removeAttribute("style");}}function If(r){return r==null?null:Q(r)?r:typeof r=="object"&&r&&"contextElement"in r&&r.contextElement?r.contextElement:r}function x1(r,e,t={}){let n=()=>(typeof e=="function"?e():e)??null,i=()=>{let T=typeof r=="function"?r():r;return t.getAnchorElement?.()??T},o=()=>{let T=i();return !T&&!t.getAnchorRect?null:Cf(T,t.getAnchorRect)},s=Object.assign({},u1,t),a=[],l=null,c,d;function u(T){c?.(),d?.(),l=T,c=s.restoreStyles?kf(T,y1):void 0;let M=T.querySelector("[data-part=arrow]");d=s.restoreStyles?kf(M,w1):void 0,a=[p1(M,s),m1(s),f1(s),h1(M,T.ownerDocument,s),Pf(M),Tf({gutter:s.gutter,offset:s.offset,overlap:s.overlap},M),g1(s),b1(s),Ef];}let{placement:h,strategy:p,onComplete:m,onPositioned:f}=s,g,b,y=false,v,w,E=_c,x=v1(s.listeners);function S(){if(!s.listeners)return;let T=i(),M=o(),L=n();if(!M||!L)return;(If(T)!==If(v)||L!==w)&&(E(),v=T,w=L,E=pf(M,L,k,x));}async function P(){S();let T=n();if(!T)return;T!==l&&(u(T),y=false);let M=o();if(!M)return;let L=await xf(M,T,{placement:h,middleware:a,strategy:p});m?.(L);let C=ae(T),I=Mf(C,L.x),V=Mf(C,L.y);if(Nr(g,I)||(T.style.setProperty("--x",`${I}px`),g=I),Nr(b,V)||(T.style.setProperty("--y",`${V}px`),b=V),s.hideWhenDetached&&(L.middlewareData.hide?.referenceHidden?(T.style.setProperty("visibility","hidden"),T.style.setProperty("pointer-events","none")):(T.style.removeProperty("visibility"),T.style.removeProperty("pointer-events"))),!y){let Y=T.firstElementChild;Y&&(T.style.setProperty("--z-index",Tr(Y).zIndex),y=true);}}async function k(){t.updatePosition?(await t.updatePosition({updatePosition:P,floatingElement:n()}),f?.({placed:true})):await P();}return k(),()=>{E(),d?.(),c?.(),f?.({placed:false});}}function Ka(r,e,t={}){let{defer:n,...i}=t,o=n?he:a=>a(),s=[];return s.push(o(()=>{s.push(x1(r,e,i));})),()=>{s.forEach(a=>a?.());}}var S1={bottom:"rotate(45deg)",left:"rotate(135deg)",top:"rotate(225deg)",right:"rotate(315deg)"};function md(r={}){let{placement:e,sameWidth:t,fitViewport:n,strategy:i="absolute"}=r;return {arrow:{position:"absolute",width:Tt.arrowSize.reference,height:Tt.arrowSize.reference,[Tt.arrowSizeHalf.variable]:`calc(${Tt.arrowSize.reference} / 2)`,[Tt.arrowOffset.variable]:`calc(${Tt.arrowSizeHalf.reference} * -1)`},arrowTip:{transform:e?S1[e.split("-")[0]]:void 0,background:Tt.arrowBg.reference,top:"0",left:"0",width:"100%",height:"100%",position:"absolute",zIndex:"inherit"},floating:{position:i,isolation:"isolate",minWidth:t?void 0:"max-content",width:t?"var(--reference-width)":void 0,maxWidth:n?"var(--available-width)":void 0,maxHeight:n?"var(--available-height)":void 0,pointerEvents:e?void 0:"none",top:"0px",left:"0px",transform:e?"translate3d(var(--x), var(--y), 0)":"translate3d(0, -100vh, 0)",zIndex:"var(--z-index)"}}}var Et=(r,e)=>{let t=r.ids?.trigger;return t!=null?Ne(t)?t(e):t:e?`menu:${r.id}:trigger:${e}`:`menu:${r.id}:trigger`},Xa=(r,e)=>{let t=r.ids?.contextTrigger;return t!=null?Ne(t)?t(e):t:e?`menu:${r.id}:ctx-trigger:${e}`:`menu:${r.id}:ctx-trigger`},an=r=>r.ids?.content??`menu:${r.id}:content`,Af=r=>r.ids?.arrow??`menu:${r.id}:arrow`,fd=r=>r.ids?.positioner??`menu:${r.id}:popper`,Rf=(r,e)=>r.ids?.group?.(e)??`menu:${r.id}:group:${e}`,Yn=(r,e)=>`${r.id}/${e}`,ln=r=>r?.dataset.value??null,gd=(r,e)=>r.ids?.groupLabel?.(e)??`menu:${r.id}:group-label:${e}`,st=r=>r.getById(an(r)),bd=r=>r.getById(fd(r)),vd=r=>r.getById(Et(r)),Df=(r,e)=>e?r.getById(Yn(r,e)):null;var Of=r=>r.getById(Xa(r)),yd=r=>kr(r.getRootNode(),`[data-scope="menu"][data-part="trigger"][data-ownedby="${r.id}"]`),wd=r=>kr(r.getRootNode(),`[data-scope="menu"][data-part="context-trigger"][data-ownedby="${r.id}"]`),ro=(r,e)=>e==null?vd(r)??yd(r)[0]:r.getById(Et(r,e)),io=r=>{let t=`[role^="menuitem"][data-ownedby=${CSS.escape(an(r))}]:not([data-disabled])`;return kr(st(r),t)},Ff=r=>Tp(io(r)),Nf=r=>Ep(io(r)),xd=(r,e)=>e?r.id===e||r.dataset.value===e:false,Vf=(r,e)=>{let t=io(r),n=t.findIndex(i=>xd(i,e.value));return Lp(t,n,{loop:e.loop??e.loopFocus})},_f=(r,e)=>{let t=io(r),n=t.findIndex(i=>xd(i,e.value));return Mp(t,n,{loop:e.loop??e.loopFocus})},Bf=(r,e)=>{let t=io(r),n=t.find(i=>xd(i,e.value));return ka(t,{state:e.typeaheadState,key:e.key,activeId:n?.id??null})},oo=r=>Q(r)&&(r.dataset.disabled===""||r.hasAttribute("disabled")),Sd=r=>!!r?.getAttribute("role")?.startsWith("menuitem")&&!!r?.hasAttribute("data-controls");var ja="menu:select";function Hf(r,e){if(!r)return;let t=ae(r),n=new t.CustomEvent(ja,{detail:{value:e}});r.dispatchEvent(n);}function C1(r){let e=an(r);return st(r)??r.getDoc().getElementById(e)}function Cd(r,e){if(!Q(r))return false;for(let t in e){let n=e[t],i=C1(n.scope);if(i&&Ve(i,r))return true;let o=n.refs.get("children");if(Object.keys(o).length>0&&Cd(r,o))return true}return false}var so=(r,e)=>({x:r,y:e});function zf(r){let{x:e,y:t,width:n,height:i}=r,o=e+n/2,s=t+i/2;return {x:e,y:t,width:n,height:i,minX:e,minY:t,maxX:e+n,maxY:t+i,midX:o,midY:s,center:so(o,s)}}function $f(r){let e=so(r.minX,r.minY),t=so(r.maxX,r.minY),n=so(r.maxX,r.maxY),i=so(r.minX,r.maxY);return {top:e,right:t,bottom:n,left:i}}function Wf(r,e){let t=zf(r),{top:n,right:i,left:o,bottom:s}=$f(t),[a]=e.split("-");return {top:[o,n,i,s],right:[n,i,s,o],bottom:[n,o,s,i],left:[i,n,o,s]}[a]}function qa(r,e){let{x:t,y:n}=e,i=false;for(let o=0,s=r.length-1;o<r.length;s=o++){let a=r[o].x,l=r[o].y,c=r[s].x,d=r[s].y;l>n!=d>n&&t<(c-a)*(n-l)/(d-l)+a&&(i=!i);}return i}function Ed(r){let e=r.parent;for(;e&&e.context.get("isSubmenu");)e=e.refs.get("parent");e?.send({type:"CLOSE"});}function Gf(r,e){return r?qa(r,e):false}function Uf(r,e,t){let n=Object.keys(r).length>0;if(!e)return null;if(!n)return Yn(t,e);for(let i in r){let o=r[i],s=Et(o.scope);if(s===e)return s}return Yn(t,e)}function cn(r,e){r&&(r.refs.set("pointerRoutingLocked",e),r.context.set("pointerRoutingMode",e?"locked":"interactive"));}function Yf(r){let e=r.context.get("highlightedValue");if(!e)return false;let t=r.refs.get("children");for(let n in t){let i=t[n];if(i.state.hasTag("open")&&Et(i.scope)===e)return true}return false}function Kf(r,e){r&&(r.refs.get("pointerRoutingLocked")||e&&Yf(r)||cn(r,false));}function Xf(r){r&&(Yf(r)||cn(r,false));}function Pd(r,e){let{context:t,send:n,state:i,computed:o,prop:s,scope:a}=r,l=i.hasTag("open"),c=t.get("isSubmenu"),d=o("isTypingAhead"),u=s("composite"),h=t.get("currentPlacement"),p=h?no(h):void 0,m=t.get("anchorPoint"),f=t.get("highlightedValue"),g=t.get("triggerValue"),b=md({...s("positioning"),placement:h});function y(x){return {id:Yn(a,x.value),disabled:!!x.disabled,highlighted:f===x.value}}function v(x){let S=x.valueText??x.value;return {...x,id:x.value,valueText:S}}function w(x){return {...y(v(x)),checked:!!x.checked}}function E(x){let{closeOnSelect:S,valueText:P,value:k}=x,T=y(x),M=Yn(a,k);return e.element({...Ce.item.attrs,id:M,role:"menuitem","aria-disabled":Gc(T.disabled),"data-disabled":Ge(T.disabled),"data-ownedby":an(a),"data-highlighted":Ge(T.highlighted),"data-value":k,"data-valuetext":P,onDragStart(L){L.currentTarget.matches("a[href]")&&L.preventDefault();},onPointerMove(L){if(T.disabled||L.pointerType!=="mouse")return;let C=L.currentTarget;if(T.highlighted)return;let I=Pr(L);n({type:"ITEM_POINTERMOVE",id:M,target:C,closeOnSelect:S,point:I});},onPointerLeave(L){if(T.disabled||L.pointerType!=="mouse"||!r.event.previous()?.type.includes("POINTER"))return;let I=L.currentTarget;n({type:"ITEM_POINTERLEAVE",id:M,target:I,closeOnSelect:S});},onPointerDown(L){if(T.disabled)return;let C=L.currentTarget;n({type:"ITEM_POINTERDOWN",target:C,id:M,closeOnSelect:S});},onClick(L){if(Qc(L)||Jc(L)||T.disabled)return;let C=L.currentTarget;n({type:"ITEM_CLICK",target:C,id:M,closeOnSelect:S});}})}return {highlightedValue:f,open:l,setOpen(x){i.hasTag("open")!==x&&n({type:x?"OPEN":"CLOSE"});},triggerValue:g,setTriggerValue(x){n({type:"TRIGGER_VALUE.SET",value:x});},setHighlightedValue(x){n({type:"HIGHLIGHTED.SET",value:x});},setParent(x){n({type:"PARENT.SET",value:x,id:x.prop("id")});},setChild(x){n({type:"CHILD.SET",value:x,id:x.prop("id")});},reposition(x={}){n({type:"POSITIONING.SET",options:x});},addItemListener(x){let S=a.getById(x.id);if(!S)return;let P=()=>x.onSelect?.();return S.addEventListener(ja,P),()=>S.removeEventListener(ja,P)},getContextTriggerProps(x={}){let{value:S}=x,P=S==null?false:g===S,k=Xa(a,S);return e.element({...Ce.contextTrigger.attrs,dir:s("dir"),id:k,"data-ownedby":a.id,"data-value":S,"data-current":Ge(P),"data-state":l?"open":"closed",onPointerDown(T){if(T.pointerType==="mouse")return;let M=Pr(T);n({type:"CONTEXT_MENU_START",point:M,value:S});},onPointerCancel(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerMove(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onPointerUp(T){T.pointerType!=="mouse"&&n({type:"CONTEXT_MENU_CANCEL"});},onContextMenu(T){let M=Pr(T),L=l&&S!=null&&!P;n({type:L?"TRIGGER_VALUE.SET":"CONTEXT_MENU",point:M,value:S}),T.preventDefault();},style:{WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"}})},getTriggerItemProps(x){let S=x.getTriggerProps();return Op(E({value:S.id}),S)},getTriggerProps(x={}){let{value:S}=x,P=S==null?false:g===S,k=Et(a,S);return e.button({...c?Ce.triggerItem.attrs:Ce.trigger.attrs,"data-placement":h,"data-side":p,type:"button",dir:s("dir"),id:k,...S!=null&&{"data-ownedby":a.id,"data-value":S,"data-current":Ge(P)},"data-uid":s("id"),"aria-haspopup":u?"menu":"dialog","aria-controls":an(a),"data-controls":an(a),"aria-expanded":S==null?l:l&&P,"data-state":l?"open":"closed",onPointerMove(T){if(T.pointerType!=="mouse"||oo(T.currentTarget)||!c)return;let L=Pr(T);n({type:"TRIGGER_POINTERMOVE",target:T.currentTarget,point:L});},onPointerLeave(T){if(oo(T.currentTarget)||T.pointerType!=="mouse"||!c)return;cn(r.refs.get("parent"),true);let M=Pr(T);n({type:"TRIGGER_POINTERLEAVE",target:T.currentTarget,point:M});},onPointerDown(T){oo(T.currentTarget)||Ta(T)||T.preventDefault();},onClick(T){if(T.defaultPrevented||oo(T.currentTarget))return;let M=l&&S!=null&&!P;n({type:M?"TRIGGER_VALUE.SET":"TRIGGER_CLICK",target:T.currentTarget,value:S});},onBlur(){n({type:"TRIGGER_BLUR"});},onFocus(){n({type:"TRIGGER_FOCUS"});},onKeyDown(T){if(T.defaultPrevented)return;let M={ArrowDown(){n({type:"ARROW_DOWN",value:S});},ArrowUp(){n({type:"ARROW_UP",value:S});},Enter(){n({type:"ARROW_DOWN",src:"enter",value:S});},Space(){n({type:"ARROW_DOWN",src:"space",value:S});}},L=ed(T,{orientation:"vertical",dir:s("dir")}),C=M[L];C&&(T.preventDefault(),C(T));}})},getIndicatorProps(){return e.element({...Ce.indicator.attrs,dir:s("dir"),"data-state":l?"open":"closed"})},getPositionerProps(){return e.element({...Ce.positioner.attrs,dir:s("dir"),id:fd(a),style:b.floating})},getArrowProps(){return e.element({id:Af(a),...Ce.arrow.attrs,dir:s("dir"),style:b.arrow})},getArrowTipProps(){return e.element({...Ce.arrowTip.attrs,dir:s("dir"),style:b.arrowTip})},getContentProps(){return e.element({...Ce.content.attrs,id:an(a),"aria-label":s("aria-label"),hidden:!l,"data-state":l?"open":"closed",role:u?"menu":"dialog",tabIndex:0,dir:s("dir"),"aria-activedescendant":o("highlightedId")||void 0,"aria-labelledby":m?Xa(a,g??void 0):Et(a,g??void 0),"data-placement":h,"data-side":p,onPointerEnter(x){x.pointerType==="mouse"&&n({type:"MENU_POINTERENTER"});},onKeyDown(x){if(x.defaultPrevented||!Ve(x.currentTarget,ge(x)))return;let S=ge(x);if(!(S?.closest("[role=menu]")===x.currentTarget||S===x.currentTarget))return;if(x.key==="Tab"&&!mm(x)){x.preventDefault();return}let k={ArrowDown(){n({type:"ARROW_DOWN"});},ArrowUp(){n({type:"ARROW_UP"});},ArrowLeft(){n({type:"ARROW_LEFT"});},ArrowRight(){n({type:"ARROW_RIGHT"});},Enter(){n({type:"ENTER"});},Space(L){d?n({type:"TYPEAHEAD",key:L.key}):k.Enter?.(L);},Home(){n({type:"HOME"});},End(){n({type:"END"});}},T=ed(x,{dir:s("dir")}),M=k[T];if(M){M(x),x.stopPropagation(),x.preventDefault();return}s("typeahead")&&am(x)&&(cm(x)||Cr(S)||(n({type:"TYPEAHEAD",key:x.key}),x.preventDefault()));}})},getSeparatorProps(){return e.element({...Ce.separator.attrs,role:"separator",dir:s("dir"),"aria-orientation":"horizontal"})},getItemState:y,getItemProps:E,getOptionItemState:w,getOptionItemProps(x){let{type:S,disabled:P,closeOnSelect:k}=x,T=v(x),M=w(x);return {...E(T),...e.element({"data-type":S,...Ce.item.attrs,dir:s("dir"),"data-value":T.value,role:`menuitem${S}`,"aria-checked":!!M.checked,"data-state":M.checked?"checked":"unchecked",onClick(L){if(P||Qc(L)||Jc(L))return;let C=L.currentTarget;n({type:"ITEM_CLICK",target:C,option:T,closeOnSelect:k});}})}},getItemIndicatorProps(x){let S=w(Vc(x)),P=S.checked?"checked":"unchecked";return e.element({...Ce.itemIndicator.attrs,dir:s("dir"),"data-disabled":Ge(S.disabled),"data-highlighted":Ge(S.highlighted),"data-state":Vi(x,"checked")?P:void 0,hidden:Vi(x,"checked")?!S.checked:void 0})},getItemTextProps(x){let S=w(Vc(x)),P=S.checked?"checked":"unchecked";return e.element({...Ce.itemText.attrs,dir:s("dir"),"data-disabled":Ge(S.disabled),"data-highlighted":Ge(S.highlighted),"data-state":Vi(x,"checked")?P:void 0})},getItemGroupLabelProps(x){return e.element({...Ce.itemGroupLabel.attrs,id:gd(a,x.htmlFor),dir:s("dir")})},getItemGroupProps(x){return e.element({id:Rf(a,x.id),...Ce.itemGroup.attrs,dir:s("dir"),"aria-labelledby":gd(a,x.id),role:"group"})}}}function jf(r){let e={each(t){for(let n=0;n<r.frames?.length;n+=1){let i=r.frames[n];i&&t(i);}},addEventListener(t,n,i){return e.each(o=>{try{o.document.addEventListener(t,n,i);}catch{}}),()=>{try{e.removeEventListener(t,n,i);}catch{}}},removeEventListener(t,n,i){e.each(o=>{try{o.document.removeEventListener(t,n,i);}catch{}});}};return e}function qf(r){let e=r.frameElement!=null?r.parent:null;return {addEventListener:(t,n,i)=>{try{e?.addEventListener(t,n,i);}catch{}return ()=>{try{e?.removeEventListener(t,n,i);}catch{}}},removeEventListener:(t,n,i)=>{try{e?.removeEventListener(t,n,i);}catch{}}}}var Zf="pointerdown.outside",Jf="focus.outside";function T1(r){for(let e of r)if(Q(e)&&Ue(e))return true;return false}var tg=r=>"clientY"in r;function E1(r,e){if(!tg(e)||!r)return false;let t=r.getBoundingClientRect();return t.width===0||t.height===0?false:t.top<=e.clientY&&e.clientY<=t.top+t.height&&t.left<=e.clientX&&e.clientX<=t.left+t.width}function P1(r,e){return r.y<=e.y&&e.y<=r.y+r.height&&r.x<=e.x&&e.x<=r.x+r.width}function Qf(r,e){if(!e||!tg(r))return false;let t=e.scrollHeight>e.clientHeight,n=t&&r.clientX>e.offsetLeft+e.clientWidth,i=e.scrollWidth>e.clientWidth,o=i&&r.clientY>e.offsetTop+e.clientHeight,s={x:e.offsetLeft,y:e.offsetTop,width:e.clientWidth+(t?16:0),height:e.clientHeight+(i?16:0)},a={x:r.clientX,y:r.clientY};return P1(s,a)?n||o:false}function L1(r,e){let{exclude:t,onFocusOutside:n,onPointerDownOutside:i,onInteractOutside:o,defer:s,followControlledElements:a=true}=e;if(!r)return;let l=ue(r),c=ae(r),d=jf(c),u=qf(c);function h(w,E){if(!Q(E)||!E.isConnected||Ve(r,E)||E1(r,w)||a&&Ca(r,E))return false;let x=l.querySelector(`[aria-controls="${r.id}"]`);if(x){let P=La(x);if(Qf(w,P))return false}let S=La(r);return Qf(w,S)?false:!t?.(E)}let p=new Set,m=_n(r?.getRootNode()),f=false;function g(w){f=true;let E=()=>{f=false;};l.addEventListener("pointerup",E,{once:true}),c.addEventListener("pointerup",E,{once:true});function x(S){let P=s&&!Zc()?he:M=>M(),k=S??w,T=k?.composedPath?.()??[k?.target];P(()=>{let M=m?T[0]:ge(w);if(!(!r||!h(w,M))){if(i||o){let L=tn(i,o);r.addEventListener(Zf,L,{once:true});}eg(r,Zf,{bubbles:false,cancelable:true,detail:{originalEvent:k,contextmenu:Ta(k),focusable:T1(T),target:M}});}});}w.pointerType==="touch"?(p.forEach(S=>S()),p.add(Me(l,"click",x,{once:true})),p.add(u.addEventListener("click",x,{once:true})),p.add(d.addEventListener("click",x,{once:true}))):x();}let b=new Set,y=setTimeout(()=>{b.add(Me(l,"pointerdown",g,true)),b.add(u.addEventListener("pointerdown",g,true)),b.add(d.addEventListener("pointerdown",g,true));},0);function v(w){if(f)return;(s?he:x=>x())(()=>{let x=w?.composedPath?.()??[w?.target],S=m?x[0]:ge(w);if(!(!r||!h(w,S))){if(n||o){let P=tn(n,o);r.addEventListener(Jf,P,{once:true});}eg(r,Jf,{bubbles:false,cancelable:true,detail:{originalEvent:w,contextmenu:false,focusable:Ue(S),target:S}});}});}return Zc()||(b.add(Me(l,"focusin",v,true)),b.add(u.addEventListener("focusin",v,true)),b.add(d.addEventListener("focusin",v,true))),()=>{clearTimeout(y),p.forEach(w=>w()),b.forEach(w=>w());}}function ng(r,e){let{defer:t}=e,n=t?he:o=>o(),i=[];return i.push(n(()=>{let o=typeof r=="function"?r():r;i.push(L1(o,e));})),()=>{i.forEach(o=>o?.());}}function eg(r,e,t){let n=r.ownerDocument.defaultView||window,i=new n.CustomEvent(e,t);return r.dispatchEvent(i)}function rg(r,e){let t=n=>{n.key==="Escape"&&(n.isComposing||e?.(n));};return Me(ue(r),"keydown",t,{capture:true})}var ig="layer:request-dismiss",Te={layers:[],branches:[],recentlyRemoved:new Set,count(){return this.layers.length},pointerBlockingLayers(){return this.layers.filter(r=>r.pointerBlocking)},topMostPointerBlockingLayer(){return [...this.pointerBlockingLayers()].slice(-1)[0]},hasPointerBlockingLayer(){return this.pointerBlockingLayers().length>0},isBelowPointerBlockingLayer(r){let e=this.indexOf(r),t=this.topMostPointerBlockingLayer()?this.indexOf(this.topMostPointerBlockingLayer()?.node):-1;return e<t},isTopMost(r){return this.layers[this.count()-1]?.node===r},getNestedLayers(r){return Array.from(this.layers).slice(this.indexOf(r)+1)},getLayersByType(r){return this.layers.filter(e=>e.type===r)},getNestedLayersByType(r,e){let t=this.indexOf(r);return t===-1?[]:this.layers.slice(t+1).filter(n=>n.type===e)},getParentLayerOfType(r,e){let t=this.indexOf(r);if(!(t<=0))return this.layers.slice(0,t).reverse().find(n=>n.type===e)},countNestedLayersOfType(r,e){return this.getNestedLayersByType(r,e).length},isInNestedLayer(r,e){return !!(this.getNestedLayers(r).some(n=>Ve(n.node,e))||this.recentlyRemoved.size>0)},isInBranch(r){return Array.from(this.branches).some(e=>Ve(e,r))},add(r){let e=this.indexOf(r.node);e!==-1&&this.layers.splice(e,1),this.layers.push(r),this.syncLayers();},addBranch(r){this.branches.push(r);},remove(r){let e=this.indexOf(r);if(e<0)return;this.layers[e].styleTargets?.forEach(n=>{let i=n();i&&M1(i);}),this.recentlyRemoved.add(r),gm(()=>this.recentlyRemoved.delete(r)),e<this.count()-1&&this.getNestedLayers(r).forEach(i=>Te.dismiss(i.node,r)),this.layers.splice(e,1),this.syncLayers();},removeBranch(r){let e=this.branches.indexOf(r);e>=0&&this.branches.splice(e,1);},syncLayers(){this.layers.forEach((r,e)=>{og(r,e,r.node),r.styleTargets?.forEach(t=>{let n=t();if(!n||n===r.node)return;og(r,e,n);let{zIndex:i}=Tr(r.node);n.style.setProperty("--z-index",i);});});},indexOf(r){return this.layers.findIndex(e=>e.node===r)},dismiss(r,e){let t=this.indexOf(r);if(t===-1)return;let n=this.layers[t];I1(r,ig,i=>{n.requestDismiss?.(i),i.defaultPrevented||n?.dismiss();}),k1(r,ig,{originalLayer:r,targetLayer:e,originalIndex:t,targetIndex:e?this.indexOf(e):-1}),this.syncLayers();},clear(){this.remove(this.layers[0].node);}};function og(r,e,t){t.style.setProperty("--layer-index",`${e}`),t.removeAttribute("data-nested"),t.removeAttribute("data-has-nested"),Te.getParentLayerOfType(r.node,r.type)&&t.setAttribute("data-nested",r.type);let i=Te.countNestedLayersOfType(r.node,r.type);i>0&&t.setAttribute("data-has-nested",r.type),t.style.setProperty("--nested-layer-count",`${i}`);}function M1(r){r.style.removeProperty("--layer-index"),r.style.removeProperty("--nested-layer-count"),r.style.removeProperty("--z-index"),r.removeAttribute("data-nested"),r.removeAttribute("data-has-nested");}function k1(r,e,t){let n=r.ownerDocument.defaultView||window,i=new n.CustomEvent(e,{cancelable:true,bubbles:true,detail:t});return r.dispatchEvent(i)}function I1(r,e,t){r.addEventListener(e,t,{once:true});}var Ld=new WeakMap,ao=new WeakMap;function A1(r){return Te.isBelowPointerBlockingLayer(r)?"none":"auto"}function sg(r){let e=A1(r);r.style.pointerEvents!==e&&(r.style.pointerEvents=e);}function R1(r){if(ao.has(r))return;let e=ae(r);if(typeof e.MutationObserver>"u")return;let t=new e.MutationObserver(()=>{ao.has(r)&&sg(r);});t.observe(r,{attributes:true,attributeFilter:["style"]}),ao.set(r,t);}function Md(){Te.layers.forEach(({node:r})=>{sg(r),R1(r);});}function ag(r){let e=ao.get(r);e&&(e.disconnect(),ao.delete(r)),r.style.pointerEvents="";}function lg(r,e){let t=ue(r),n=[];return Te.hasPointerBlockingLayer()&&!t.body.hasAttribute("data-inert")&&(Ld.set(t.body,t.body.style.pointerEvents),queueMicrotask(()=>{let i=t.body;i&&(i.style.pointerEvents="none",i.setAttribute("data-inert",""));})),e?.forEach(i=>{let[o,s]=Tm(()=>{let a=i();return Q(a)?a:null},{timeout:1e3});o.then(a=>n.push(Yi(a,{pointerEvents:"auto"}))),n.push(s);}),()=>{Te.hasPointerBlockingLayer()||(queueMicrotask(()=>{let i=t.body;if(!i)return;let o=Ld.get(i);o!==void 0&&(i.style.pointerEvents=o,Ld.delete(i)),i.removeAttribute("data-inert"),i.style.length===0&&i.removeAttribute("style");}),n.forEach(i=>i()));}}function D1(r,e){let{warnOnMissingNode:t=true}=e;if(t&&!r){wr("[@zag-js/dismissable] node is `null` or `undefined`");return}if(!r)return;let{onDismiss:n,onRequestDismiss:i,pointerBlocking:o,exclude:s,debug:a,type:l="dialog",layerStyleTargets:c}=e,d={dismiss:n,node:r,type:l,pointerBlocking:o,requestDismiss:i,styleTargets:c};Te.add(d),Md();function u(g){let b=ge(g.detail.originalEvent);Te.isBelowPointerBlockingLayer(r)||Te.isInBranch(b)||(e.onPointerDownOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onPointerDownOutside:",g.detail.originalEvent),n?.()));}function h(g){let b=ge(g.detail.originalEvent);Te.isInBranch(b)||(e.onFocusOutside?.(g),e.onInteractOutside?.(g),!g.defaultPrevented&&(a&&console.log("onFocusOutside:",g.detail.originalEvent),n?.()));}function p(g){Te.isTopMost(r)&&(e.onEscapeKeyDown?.(g),!g.defaultPrevented&&n&&(g.preventDefault(),n()));}function m(g){if(!r)return false;let b=typeof s=="function"?s():s,y=Array.isArray(b)?b:[b],v=e.persistentElements?.map(w=>w()).filter(Q);return v&&y.push(...v),y.some(w=>Ve(w,g))||Te.isInNestedLayer(r,g)}let f=[o?lg(r,e.persistentElements):void 0,rg(r,p),ng(r,{exclude:m,onFocusOutside:h,onPointerDownOutside:u,defer:e.defer})];return ()=>{Te.remove(r),Md(),ag(r),f.forEach(g=>g?.());}}function Za(r,e){let{defer:t}=e,n=t?he:o=>o(),i=[];return i.push(n(()=>{let o=Ne(r)?r():r;i.push(D1(o,e));})),()=>{i.forEach(o=>o?.());}}function O1(r){return !(r.metaKey||!Er()&&r.altKey||r.ctrlKey||r.key==="Control"||r.key==="Shift"||r.key==="Meta")}var F1=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function N1(r,e,t){let n=t?ge(t):null,i=ue(n),o=ae(n),s=yt(i);return r=r||s instanceof o.HTMLInputElement&&!F1.has(s?.type)||s instanceof o.HTMLTextAreaElement||s instanceof o.HTMLElement&&s.isContentEditable,!(r&&e==="keyboard"&&t instanceof o.KeyboardEvent&&!Reflect.has(V1,t.key))}var Ht=null,kd=new Set,Ja=new Map,Kn=false,Id=false,dg=false,V1={Tab:true,Escape:true};function el(r,e){for(let t of kd)t(r,e);}function Qa(r){Kn=true,O1(r)&&(Ht="keyboard",el("keyboard",r));}function Ye(r){Ht="pointer",(r.type==="mousedown"||r.type==="pointerdown")&&(Kn=true,el("pointer",r));}function ug(r){lm(r)&&(Kn=true,Ht="virtual");}function hg(r){let e=ge(r);e===ae(e)||e===ue(e)||dg||!r.isTrusted||(!Kn&&!Id&&(Ht="virtual",el("virtual",r)),Kn=false,Id=false);}function pg(){(Kn=false,Id=true);}function _1(r){if(typeof window>"u"||Ja.get(ae(r)))return;let e=ae(r),t=ue(r),n=e.HTMLElement.prototype.focus;function i(){Kn=true,n.apply(this,arguments);}try{Object.defineProperty(e.HTMLElement.prototype,"focus",{configurable:!0,value:i});}catch{}t.addEventListener("keydown",Qa,true),t.addEventListener("keyup",Qa,true),t.addEventListener("click",ug,true),e.addEventListener("focus",hg,true),e.addEventListener("blur",pg,false),typeof e.PointerEvent<"u"?(t.addEventListener("pointerdown",Ye,true),t.addEventListener("pointermove",Ye,true),t.addEventListener("pointerup",Ye,true)):(t.addEventListener("mousedown",Ye,true),t.addEventListener("mousemove",Ye,true),t.addEventListener("mouseup",Ye,true)),e.addEventListener("beforeunload",()=>{B1(r);},{once:true}),Ja.set(e,{focus:n});}var B1=(r,e)=>{let t=ae(r),n=ue(r);let i=Ja.get(t);if(i){try{Object.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,value:i.focus});}catch{}n.removeEventListener("keydown",Qa,true),n.removeEventListener("keyup",Qa,true),n.removeEventListener("click",ug,true),t.removeEventListener("focus",hg,true),t.removeEventListener("blur",pg,false),typeof t.PointerEvent<"u"?(n.removeEventListener("pointerdown",Ye,true),n.removeEventListener("pointermove",Ye,true),n.removeEventListener("pointerup",Ye,true)):(n.removeEventListener("mousedown",Ye,true),n.removeEventListener("mousemove",Ye,true),n.removeEventListener("mouseup",Ye,true)),Ja.delete(t);}};function mg(){return Ht}function fg(r){Ht=r,el(r,null);}function cg(){return Ht==="keyboard"||Ht==="virtual"}function gg(r={}){let{isTextInput:e,autoFocus:t,onChange:n,root:i}=r;_1(i),n?.({isFocusVisible:t||cg(),modality:Ht});let o=(s,a)=>{N1(!!e,s,a)&&n?.({isFocusVisible:cg(),modality:s});};return kd.add(o),()=>{kd.delete(o);}}var{not:Ke,and:Vr,or:H1}=Gp(),Ad=wa({props({props:r}){return {closeOnSelect:true,typeahead:true,composite:true,loopFocus:false,navigate(e){ym(e.node);},...r,positioning:{placement:"bottom-start",gutter:8,...r.positioning}}},initialState({prop:r}){return r("open")||r("defaultOpen")?"open":"idle"},context({bindable:r,prop:e,scope:t}){return {highlightedValue:r(()=>({defaultValue:e("defaultHighlightedValue")||null,value:e("highlightedValue"),onChange(n){e("onHighlightChange")?.({highlightedValue:n});}})),lastHighlightedValue:r(()=>({defaultValue:null})),currentPlacement:r(()=>({defaultValue:void 0})),intentPolygon:r(()=>({defaultValue:null})),anchorPoint:r(()=>({defaultValue:null,hash(n){return `x: ${n?.x}, y: ${n?.y}`}})),isSubmenu:r(()=>({defaultValue:false})),triggerValue:r(()=>({defaultValue:e("defaultTriggerValue")??null,value:e("triggerValue"),onChange(n){let i=e("onTriggerValueChange");if(!i)return;let o=ro(t,n);i({value:n,triggerElement:o});}})),pointerRoutingMode:r(()=>({defaultValue:"interactive"}))}},refs(){return {parent:null,children:{},pointerRoutingLocked:false,typeaheadState:{...ka.defaultOptions},positioningOverride:{}}},computed:{isRtl:({prop:r})=>r("dir")==="rtl",isTypingAhead:({refs:r})=>r.get("typeaheadState").keysSoFar!=="",highlightedId:({context:r,scope:e,refs:t})=>Uf(t.get("children"),r.get("highlightedValue"),e)},watch({track:r,action:e,context:t,prop:n}){r([()=>t.get("isSubmenu")],()=>{e(["setSubmenuPlacement"]);}),r([()=>t.hash("anchorPoint")],()=>{t.get("anchorPoint")&&e(["reposition"]);}),r([()=>n("open")],()=>{e(["toggleVisibility"]);});},on:{"TRIGGER_VALUE.SET":{actions:["setTriggerValue","setAnchorPoint","reposition","focusMenu"]},"PARENT.SET":{actions:["setParentMenu"]},"CHILD.SET":{actions:["setChildMenu"]},OPEN:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","invokeOnOpen"]}],OPEN_AUTOFOCUS:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightFirstItem","invokeOnOpen"]}],CLOSE:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"HIGHLIGHTED.RESTORE":{actions:["restoreHighlightedItem"]},"HIGHLIGHTED.SET":{actions:["setHighlightedItem"]},"HIGHLIGHTED.SUGGEST":{actions:["suggestHighlightedItem"]}},states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed"},CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint","setTriggerValue"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],TRIGGER_FOCUS:{guard:Ke("isSubmenu"),target:"closed"},TRIGGER_POINTERMOVE:{guard:"isSubmenu",target:"opening"}}},"opening:contextmenu":{tags:["closed"],effects:["waitForLongPress"],on:{"CONTROLLED.OPEN":{target:"open",actions:["reposition"]},"CONTROLLED.CLOSE":{target:"closed",actions:["focusTrigger"]},CONTEXT_MENU_CANCEL:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"LONG_PRESS.OPEN":[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","invokeOnOpen","reposition"]}]}},opening:{tags:["closed"],effects:["waitForOpenDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed",actions:["focusTrigger"]},BLUR:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],TRIGGER_POINTERLEAVE:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],"DELAY.OPEN":[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{target:"open",actions:["invokeOnOpen"]}]}},closing:{tags:["open"],effects:["trackPointerMove","trackInteractOutside","waitForCloseDelay"],on:{"CONTROLLED.OPEN":{target:"open"},"CONTROLLED.CLOSE":{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]},MENU_POINTERENTER:{target:"open",actions:["clearIntentPolygon"]},POINTER_MOVED_AWAY_FROM_SUBMENU:[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem"]}],"DELAY.CLOSE":[{guard:"isOpenControlled",actions:["invokeOnClose","releaseParentRoutingLock"]},{target:"closed",actions:["focusParentMenu","restoreParentHighlightedItem","invokeOnClose","releaseParentRoutingLock"]}]}},closed:{tags:["closed"],entry:["clearHighlightedItem","unlockParentOnClose","clearAnchorPoint"],on:{"CONTROLLED.OPEN":[{guard:H1("isOpenAutoFocusEvent","isArrowDownEvent"),target:"open",actions:["highlightFirstItem"]},{guard:"isArrowUpEvent",target:"open",actions:["highlightLastItem"]},{target:"open"}],CONTEXT_MENU_START:{target:"opening:contextmenu",actions:["setAnchorPoint","setTriggerValue"]},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","setTriggerValue","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:["invokeOnOpen","setTriggerValue"]},{target:"open",actions:["invokeOnOpen","setTriggerValue"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",target:"opening"},TRIGGER_BLUR:{target:"idle"},ARROW_DOWN:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightFirstItem","invokeOnOpen"]}],ARROW_UP:[{guard:"isOpenControlled",actions:["setTriggerValue","invokeOnOpen"]},{target:"open",actions:["setTriggerValue","highlightLastItem","invokeOnOpen"]}]}},open:{tags:["open"],effects:["trackInteractOutside","trackFocusVisible","trackPositioning","scrollToHighlightedItem"],entry:["focusMenu","unlockParentOnOpen"],on:{"CONTROLLED.CLOSE":[{target:"closed",guard:"isArrowLeftEvent",actions:["focusParentMenu"]},{target:"closed",actions:["focusTrigger"]}],TRIGGER_CLICK:[{guard:Vr(Ke("isTriggerItem"),"isOpenControlled"),actions:["invokeOnClose","releaseParentRoutingLock"]},{guard:Ke("isTriggerItem"),target:"closed",actions:["invokeOnClose","releaseParentRoutingLock","focusTrigger"]}],CONTEXT_MENU:{actions:["setAnchorPoint","setTriggerValue","focusMenu"]},ARROW_UP:{actions:["highlightPrevItem","focusMenu"]},ARROW_DOWN:{actions:["highlightNextItem","focusMenu"]},ARROW_LEFT:[{guard:Vr("isSubmenu","isOpenControlled"),actions:["invokeOnClose","releaseParentRoutingLock"]},{guard:"isSubmenu",target:"closed",actions:["focusParentMenu","invokeOnClose","releaseParentRoutingLock"]}],HOME:{actions:["highlightFirstItem","focusMenu"]},END:{actions:["highlightLastItem","focusMenu"]},ARROW_RIGHT:{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},ENTER:[{guard:"isTriggerItemHighlighted",actions:["openSubmenu"]},{actions:["clickHighlightedItem"]}],ITEM_POINTERMOVE:[{guard:Ke("isPointerRoutingLocked"),actions:["setHighlightedItem","focusMenu","closeSiblingMenus"]},{actions:["setLastHighlightedItem","closeSiblingMenus"]}],ITEM_POINTERLEAVE:{guard:Vr(Ke("isPointerRoutingLocked"),Ke("isTriggerItem")),actions:["clearHighlightedItem"]},ITEM_CLICK:[{guard:Vr(Ke("isTriggerItemHighlighted"),Ke("isHighlightedItemEditable"),"closeOnSelect","isOpenControlled"),actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock"]},{guard:Vr(Ke("isTriggerItemHighlighted"),Ke("isHighlightedItemEditable"),"closeOnSelect"),target:"closed",actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose","releaseParentRoutingLock","focusTrigger"]},{guard:Vr(Ke("isTriggerItemHighlighted"),Ke("isHighlightedItemEditable")),actions:["invokeOnSelect","setOptionState"]},{actions:["setHighlightedItem"]}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",actions:["setIntentPolygon"]},TRIGGER_POINTERLEAVE:{target:"closing",actions:["setIntentPolygon"]},ITEM_POINTERDOWN:{actions:["setHighlightedItem"]},TYPEAHEAD:{actions:["highlightMatchedItem"]},FOCUS_MENU:{actions:["focusMenu"]},"POSITIONING.SET":{actions:["reposition"]}}}},implementations:{guards:{closeOnSelect:({prop:r,event:e})=>!!(e?.closeOnSelect??r("closeOnSelect")),isTriggerItem:({event:r})=>Sd(r.target),isTriggerItemHighlighted:({event:r,scope:e,computed:t})=>!!(r.target??e.getById(t("highlightedId")))?.hasAttribute("data-controls"),isSubmenu:({context:r})=>r.get("isSubmenu"),isPointerRoutingLocked:({refs:r})=>r.get("pointerRoutingLocked"),isHighlightedItemEditable:({scope:r,computed:e})=>Cr(r.getById(e("highlightedId"))),isOpenControlled:({prop:r})=>r("open")!==void 0,isArrowLeftEvent:({event:r})=>r.previousEvent?.type==="ARROW_LEFT",isArrowUpEvent:({event:r})=>r.previousEvent?.type==="ARROW_UP",isArrowDownEvent:({event:r})=>r.previousEvent?.type==="ARROW_DOWN",isOpenAutoFocusEvent:({event:r})=>r.previousEvent?.type==="OPEN_AUTOFOCUS"},effects:{waitForOpenDelay({send:r}){let e=setTimeout(()=>{r({type:"DELAY.OPEN"});},200);return ()=>clearTimeout(e)},waitForCloseDelay({send:r}){let e=setTimeout(()=>{r({type:"DELAY.CLOSE"});},100);return ()=>clearTimeout(e)},waitForLongPress({send:r}){let e=setTimeout(()=>{r({type:"LONG_PRESS.OPEN"});},700);return ()=>clearTimeout(e)},trackFocusVisible({scope:r}){return gg({root:r.getRootNode?.()})},trackPositioning({context:r,prop:e,scope:t,refs:n}){if(Of(t)||wd(t).length>0)return;let o={...e("positioning"),...n.get("positioningOverride")};return r.set("currentPlacement",o.placement),Ka(()=>ro(t,r.get("triggerValue")),()=>bd(t),{...o,defer:true,onComplete(l){r.set("currentPlacement",l.placement);}})},trackInteractOutside({refs:r,scope:e,prop:t,context:n,send:i}){let o=()=>st(e),s=true,a=l=>wd(e).some(c=>Ve(c,l));return Za(o,{type:"menu",defer:true,exclude:[vd(e),...yd(e)].filter(Boolean),onInteractOutside:t("onInteractOutside"),onRequestDismiss:t("onRequestDismiss"),onFocusOutside(l){t("onFocusOutside")?.(l);let c=ge(l.detail.originalEvent);if(a(c)){l.preventDefault();return}if(Cd(c,r.get("children"))){l.preventDefault();return}},onEscapeKeyDown(l){t("onEscapeKeyDown")?.(l),n.get("isSubmenu")&&l.preventDefault(),Ed({parent:r.get("parent")});},onPointerDownOutside(l){t("onPointerDownOutside")?.(l);let c=ge(l.detail.originalEvent);if(a(c)&&l.detail.contextmenu){l.preventDefault();return}s=!l.detail.focusable;},onDismiss(){i({type:"CLOSE",src:"interact-outside",restoreFocus:s});}})},trackPointerMove({context:r,scope:e,send:t,refs:n}){let i=n.get("parent");if(!i)return;cn(i,true);let o=e.getDoc();return Me(o,"pointermove",s=>{Gf(r.get("intentPolygon"),{x:s.clientX,y:s.clientY})||(t({type:"POINTER_MOVED_AWAY_FROM_SUBMENU"}),cn(i,false));})},scrollToHighlightedItem({scope:r,computed:e}){let t=()=>{if(mg()==="pointer")return;let o=r.getById(e("highlightedId")),s=st(r);xm(o,{rootEl:s,block:"nearest"});};return he(()=>{fg("virtual"),t();}),vm(()=>st(r),{attributes:["aria-activedescendant"],callback:t})}},actions:{setAnchorPoint({context:r,event:e}){r.set("anchorPoint",t=>vr(t,e.point)?t:e.point);},setSubmenuPlacement({context:r,computed:e,refs:t}){if(!r.get("isSubmenu"))return;let n=e("isRtl")?"left-start":"right-start";t.set("positioningOverride",{placement:n,gutter:0});},reposition({context:r,scope:e,prop:t,event:n,refs:i}){let o=()=>bd(e),s=n.point??r.get("anchorPoint"),a=s?()=>({width:0,height:0,...s}):void 0,l={...t("positioning"),...i.get("positioningOverride")},c=n.value??r.get("triggerValue");Ka(()=>ro(e,c),o,{...l,defer:true,getAnchorRect:a,...n.options??{},listeners:false,onComplete(u){r.set("currentPlacement",u.placement);}});},setOptionState({event:r}){if(!r.option)return;let{checked:e,onCheckedChange:t,type:n}=r.option;n==="radio"?t?.(true):n==="checkbox"&&t?.(!e);},clickHighlightedItem({scope:r,computed:e,prop:t,context:n}){let i=r.getById(e("highlightedId"));if(!i||i.dataset.disabled)return;let o=n.get("highlightedValue");jp(i)?t("navigate")?.({value:o,node:i,href:i.href}):queueMicrotask(()=>i.click());},setIntentPolygon({context:r,scope:e,event:t}){let n=st(e),i=r.get("currentPlacement");if(!n||!i)return;let o=n.getBoundingClientRect(),s=Wf(o,i);if(!s)return;let l=no(i)==="right"?-5:5;r.set("intentPolygon",[{...t.point,x:t.point.x+l},...s]);},clearIntentPolygon({context:r}){r.set("intentPolygon",null);},clearAnchorPoint({context:r}){r.set("anchorPoint",null);},unlockParentOnOpen({refs:r,context:e,scope:t}){let n=r.get("parent");if(e.get("isSubmenu")){let i=Et(t);n?.send({type:"HIGHLIGHTED.SUGGEST",value:i});}cn(n,false);},unlockParentOnClose({refs:r,context:e}){Kf(r.get("parent"),e.get("isSubmenu"));},setHighlightedItem({context:r,event:e}){let t=e.value||ln(e.target);r.set("highlightedValue",t);},clearHighlightedItem({context:r}){r.set("highlightedValue",null);},focusMenu({scope:r}){he(()=>{let e=st(r);Pa({root:e,enabled:!Ve(e,r.getActiveElement()),filter(n){return !n.role?.startsWith("menuitem")}})?.focus({preventScroll:true});});},highlightFirstItem({context:r,scope:e}){(st(e)?queueMicrotask:he)(()=>{let n=Ff(e);n&&r.set("highlightedValue",ln(n));});},highlightLastItem({context:r,scope:e}){(st(e)?queueMicrotask:he)(()=>{let n=Nf(e);n&&r.set("highlightedValue",ln(n));});},highlightNextItem({context:r,scope:e,event:t,prop:n}){let i=Vf(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",ln(i));},highlightPrevItem({context:r,scope:e,event:t,prop:n}){let i=_f(e,{loop:t.loop,value:r.get("highlightedValue"),loopFocus:n("loopFocus")});r.set("highlightedValue",ln(i));},invokeOnSelect({context:r,prop:e,scope:t}){let n=r.get("highlightedValue");if(n==null)return;let i=Df(t,n);Hf(i,n),e("onSelect")?.({value:n});},focusTrigger({scope:r,context:e,event:t}){e.get("isSubmenu")||e.get("anchorPoint")||t.restoreFocus===false||queueMicrotask(()=>{ro(r,e.get("triggerValue"))?.focus({preventScroll:true});});},highlightMatchedItem({scope:r,context:e,event:t,refs:n}){let i=Bf(r,{key:t.key,value:e.get("highlightedValue"),typeaheadState:n.get("typeaheadState")});i&&e.set("highlightedValue",ln(i));},setParentMenu({refs:r,event:e,context:t}){r.set("parent",e.value),t.set("isSubmenu",true);},setChildMenu({refs:r,event:e}){let t=r.get("children");t[e.id]=e.value,r.set("children",t);},closeSiblingMenus({refs:r,event:e,scope:t}){let n=e.target;if(!Sd(n))return;let i=n?.getAttribute("data-uid"),o=r.get("children");for(let s in o){if(s===i)continue;let a=o[s],l=a.context.get("intentPolygon");l&&e.point&&qa(l,e.point)||(st(t)?.focus({preventScroll:true}),a.send({type:"CLOSE"}));}},closeRootMenu({refs:r}){Ed({parent:r.get("parent")});},openSubmenu({refs:r,scope:e,computed:t}){let i=e.getById(t("highlightedId"))?.getAttribute("data-uid"),o=r.get("children");(i?o[i]:null)?.send({type:"OPEN_AUTOFOCUS"});},focusParentMenu({refs:r}){r.get("parent")?.send({type:"FOCUS_MENU"});},setLastHighlightedItem({context:r,event:e}){r.set("lastHighlightedValue",ln(e.target));},suggestHighlightedItem({context:r,event:e}){let t=e.value;if(t){if(r.get("highlightedValue")!=null){r.set("lastHighlightedValue",t);return}r.set("highlightedValue",t);}},restoreHighlightedItem({context:r}){let e=r.get("lastHighlightedValue");r.set("lastHighlightedValue",null),e&&r.set("highlightedValue",e);},restoreParentHighlightedItem({refs:r}){r.get("parent")?.send({type:"HIGHLIGHTED.RESTORE"});},invokeOnOpen({prop:r}){r("onOpenChange")?.({open:true});},invokeOnClose({prop:r}){r("onOpenChange")?.({open:false});},releaseParentRoutingLock({refs:r,context:e}){e.get("isSubmenu")&&Xf(r.get("parent"));},toggleVisibility({prop:r,event:e,send:t}){t({type:r("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:e});},setTriggerValue({context:r,event:e}){e.value!==void 0&&r.set("triggerValue",e.value);}}}});function bg(r){return {machine:Ad,props:{id:r.id??Na("vela-menu"),ids:r.triggerId?{trigger:r.triggerId}:void 0,positioning:{placement:r.placement??"bottom-start",...r.getAnchorRect?{getAnchorRect:()=>r.getAnchorRect()}:{}},onSelect:e=>r.onSelect?.(e.value),onOpenChange:e=>r.onOpenChange?.(e.open)},connect:e=>Pd(e,Ir)}}var vg="vela-ui-menu",yg=`
4
4
  .vela-menu {
5
5
  /* The list is a <ul>: without this, block rows (the separator) paint a ::marker dot. */
6
6
  list-style: none;