@christtrade/depth 0.12.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +201 -0
- package/NOTICE +15 -0
- package/README.md +159 -0
- package/depth.cjs +1136 -0
- package/depth.css +2 -0
- package/depth.mjs +1136 -0
- package/depth.nopreflight.css +2 -0
- package/index.d.ts +1 -0
- package/package.json +32 -0
- package/types/ChartInner.d.ts +114 -0
- package/types/ChartOuter.d.ts +31 -0
- package/types/components/account/AccountSummary.d.ts +8 -0
- package/types/components/chart/chart-context-menu.d.ts +30 -0
- package/types/components/chart/chart-settings-dialog.d.ts +15 -0
- package/types/components/chart/chart-status-overlay.d.ts +24 -0
- package/types/components/chart/data-status.d.ts +10 -0
- package/types/components/chart/pane-legend.d.ts +37 -0
- package/types/components/chart/session-status-badge.d.ts +14 -0
- package/types/components/chart/status-bar.d.ts +9 -0
- package/types/components/chart/symbol-icon.d.ts +9 -0
- package/types/components/chart/tz.d.ts +10 -0
- package/types/components/drawings/drawing-icons.d.ts +2 -0
- package/types/components/drawings/drawing-settings-bar.d.ts +15 -0
- package/types/components/drawings/drawing-settings-dialog.d.ts +268 -0
- package/types/components/drawings/drawing-toolbar.d.ts +14 -0
- package/types/components/drawings/drawing-tools.d.ts +23 -0
- package/types/components/indicators/indicators-dialog.d.ts +20 -0
- package/types/components/indicators/indicators-settings-dialog.d.ts +164 -0
- package/types/components/multi-chart/GridDividers.d.ts +12 -0
- package/types/components/multi-chart/LayoutPicker.d.ts +19 -0
- package/types/components/plugin-panels/BottomBarPluginHost.d.ts +7 -0
- package/types/components/plugin-panels/PluginFixedPanelHost.d.ts +18 -0
- package/types/components/plugin-panels/PluginToolbarHost.d.ts +7 -0
- package/types/components/plugin-panels/PluginWindowsDropdown.d.ts +7 -0
- package/types/components/plugins/plugin-manager-dialog.d.ts +14 -0
- package/types/components/toolbar/SymbolSwitcher.d.ts +8 -0
- package/types/components/toolbar/chart-icons.d.ts +16 -0
- package/types/components/toolbar/chart-type-selector.d.ts +11 -0
- package/types/components/toolbar/timeframe-selector.d.ts +15 -0
- package/types/components/trading/OrderPanel.d.ts +36 -0
- package/types/components/trading/QuickTradingButtons.d.ts +7 -0
- package/types/components/trading/order-math.d.ts +94 -0
- package/types/components/ui/button.d.ts +11 -0
- package/types/components/ui/checkbox.d.ts +4 -0
- package/types/components/ui/color-picker.d.ts +12 -0
- package/types/components/ui/dialog.d.ts +19 -0
- package/types/components/ui/dropdown-menu.d.ts +27 -0
- package/types/components/ui/hover-card.d.ts +6 -0
- package/types/components/ui/input.d.ts +4 -0
- package/types/components/ui/popover.d.ts +7 -0
- package/types/components/ui/resizable.d.ts +23 -0
- package/types/components/ui/separator.d.ts +4 -0
- package/types/components/ui/slider.d.ts +4 -0
- package/types/components/ui/switch.d.ts +4 -0
- package/types/components/ui/tooltip.d.ts +7 -0
- package/types/core/AccountManager.d.ts +142 -0
- package/types/core/ChartModel.d.ts +84 -0
- package/types/core/ChartState.d.ts +51 -0
- package/types/core/ChartTypeRegistry.d.ts +27 -0
- package/types/core/DataEngine.d.ts +143 -0
- package/types/core/DataSourceRegistry.d.ts +106 -0
- package/types/core/DepthChart.d.ts +458 -0
- package/types/core/DrawingRegistry.d.ts +133 -0
- package/types/core/DrawingStore.d.ts +26 -0
- package/types/core/ExecutionEngine.d.ts +95 -0
- package/types/core/GlobalChartBus.d.ts +32 -0
- package/types/core/Playback.d.ts +48 -0
- package/types/core/PlaybackStateRegistry.d.ts +25 -0
- package/types/core/PluginRegistry.d.ts +67 -0
- package/types/core/PluginSchedule.d.ts +15 -0
- package/types/core/RenderEngine.d.ts +143 -0
- package/types/core/ScriptedPlugin.d.ts +153 -0
- package/types/core/SessionMapper.d.ts +54 -0
- package/types/core/SessionUtils.d.ts +53 -0
- package/types/core/TypedEventBus.d.ts +691 -0
- package/types/core/WasmPluginHost.d.ts +39 -0
- package/types/core/index.d.ts +70 -0
- package/types/core/plugin-startup.d.ts +33 -0
- package/types/core/processing/data-chunk.d.ts +37 -0
- package/types/core/processing/data-level.d.ts +13 -0
- package/types/core/processing/l2-processor.d.ts +10 -0
- package/types/core/processing/l3-processor.d.ts +26 -0
- package/types/core/processing/ohlcv-processor.d.ts +14 -0
- package/types/core/processing/tick-processor.d.ts +14 -0
- package/types/core/script-dsl.d.ts +20 -0
- package/types/core/script-scope.d.ts +4 -0
- package/types/core/script.worker.d.ts +1 -0
- package/types/hooks/useCellBridges.d.ts +36 -0
- package/types/hooks/useChartData.d.ts +153 -0
- package/types/hooks/useChartHandlers.d.ts +94 -0
- package/types/hooks/useChartInteraction.d.ts +160 -0
- package/types/hooks/useChartLayout.d.ts +21 -0
- package/types/hooks/useChartPlugin.d.ts +34 -0
- package/types/hooks/useChartSettings.d.ts +44 -0
- package/types/hooks/useChartSubscriptions.d.ts +64 -0
- package/types/hooks/useChartView.d.ts +47 -0
- package/types/hooks/usePlaybackEngine.d.ts +85 -0
- package/types/hooks/useRenderEngine.d.ts +64 -0
- package/types/hooks/useTradeLines.d.ts +80 -0
- package/types/hooks/useTradingState.d.ts +135 -0
- package/types/interfaces/IAccountAdapter.d.ts +38 -0
- package/types/interfaces/ICoordinateTransformer.d.ts +105 -0
- package/types/interfaces/IDataAdapter.d.ts +402 -0
- package/types/interfaces/IExecutionAdapter.d.ts +71 -0
- package/types/interfaces/plugins/IChartPlugin.d.ts +254 -0
- package/types/interfaces/plugins/IChartTypePlugin.d.ts +126 -0
- package/types/interfaces/plugins/IDataSourcePlugin.d.ts +20 -0
- package/types/interfaces/plugins/IDrawingPlugin.d.ts +62 -0
- package/types/interfaces/plugins/IIndicatorPlugin.d.ts +97 -0
- package/types/interfaces/plugins/index.d.ts +5 -0
- package/types/lib/bar-grid.d.ts +6 -0
- package/types/lib/book.d.ts +5 -0
- package/types/lib/clock.d.ts +7 -0
- package/types/lib/compact-buffer.d.ts +66 -0
- package/types/lib/constants.d.ts +5 -0
- package/types/lib/createSimulatedAdapter.d.ts +42 -0
- package/types/lib/dpr.d.ts +27 -0
- package/types/lib/heatmap.worker.d.ts +1 -0
- package/types/lib/indicator-stdlib.d.ts +426 -0
- package/types/lib/indicator-worker.d.ts +65 -0
- package/types/lib/matchingEngine.d.ts +144 -0
- package/types/lib/notifications/tradeToast.d.ts +31 -0
- package/types/lib/pointer-lock.d.ts +5 -0
- package/types/lib/priceFormat.d.ts +17 -0
- package/types/lib/priceTransition.d.ts +22 -0
- package/types/lib/renderers/drawFootprintChart.d.ts +5 -0
- package/types/lib/renderers/drawTradeLines.d.ts +112 -0
- package/types/lib/renderers/drawings-renderer.d.ts +57 -0
- package/types/lib/renderers/renderer.d.ts +113 -0
- package/types/lib/sampler.d.ts +7 -0
- package/types/lib/series/japaneseCharts.d.ts +88 -0
- package/types/lib/slice-worker-client.d.ts +138 -0
- package/types/lib/slice.worker.d.ts +139 -0
- package/types/lib/storage.d.ts +108 -0
- package/types/lib/symbol-info.d.ts +12 -0
- package/types/lib/symbol-search.d.ts +29 -0
- package/types/lib/timeframes.d.ts +46 -0
- package/types/lib/tradingview-import.d.ts +32 -0
- package/types/lib/types/chart-settings.d.ts +90 -0
- package/types/lib/types/drawing-types.d.ts +393 -0
- package/types/lib/types/footprint.d.ts +119 -0
- package/types/lib/types/heatmap-types.d.ts +30 -0
- package/types/lib/types/index.d.ts +147 -0
- package/types/lib/types/indicator-types.d.ts +123 -0
- package/types/lib/types/layout-sync.d.ts +43 -0
- package/types/lib/types/trading-types.d.ts +323 -0
- package/types/lib/use-forwarded-ref.d.ts +1 -0
- package/types/lib/utils.d.ts +2 -0
- package/types/plugins/alligator.d.ts +1 -0
- package/types/plugins/atr.d.ts +1 -0
- package/types/plugins/awesome-oscillator.d.ts +1 -0
- package/types/plugins/bollinger-bands.d.ts +1 -0
- package/types/plugins/cci.d.ts +1 -0
- package/types/plugins/cvd.d.ts +1 -0
- package/types/plugins/donchian.d.ts +1 -0
- package/types/plugins/ichimoku.d.ts +1 -0
- package/types/plugins/index.d.ts +25 -0
- package/types/plugins/keltner.d.ts +1 -0
- package/types/plugins/macd.d.ts +1 -0
- package/types/plugins/mfi.d.ts +1 -0
- package/types/plugins/moving-average.d.ts +1 -0
- package/types/plugins/obv.d.ts +1 -0
- package/types/plugins/psar.d.ts +1 -0
- package/types/plugins/rsi.d.ts +1 -0
- package/types/plugins/sessions.d.ts +1 -0
- package/types/plugins/stochastic.d.ts +1 -0
- package/types/plugins/supertrend.d.ts +1 -0
- package/types/plugins/volume.d.ts +1 -0
- package/types/plugins/vwap.d.ts +1 -0
- package/types/plugins/williams-r.d.ts +1 -0
- package/types/react/useDepthChart.d.ts +6 -0
package/depth.mjs
ADDED
|
@@ -0,0 +1,1136 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var fB=Object.defineProperty;var uS=e=>{throw TypeError(e)};var mB=(e,t,n)=>t in e?fB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>mB(e,typeof t!="symbol"?t+"":t,n),dS=(e,t,n)=>t.has(e)||uS("Cannot "+n);var ko=(e,t,n)=>(dS(e,t,"read from private field"),n?n.call(e):t.get(e)),fS=(e,t,n)=>t.has(e)?uS("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xg=(e,t,n,r)=>(dS(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function mS(e){let t=Number(e/1000000n),n=Number(e%1000000n);return new Date(t).toISOString().slice(0,-1)+String(n).padStart(6,"0")+"Z"}function Rs(e,t){return{fromNs:e,toNs:t,fromMs:Number(e/1000000n),toMs:Number(t/1000000n),fromIso:mS(e),toIso:mS(t)}}var Qu=class extends Error{constructor(n,r,o){super(r);ae(this,"code",n);ae(this,"httpStatus",o);this.name="DataAdapterError"}};var ua={ExactSymbol:0,SymbolPrefix:1,TokenSymbolPrefix:2,WordPrefix:3,SymbolSubstring:4,Exchange:5,Fuzzy:6,NoMatch:Number.MAX_SAFE_INTEGER},pB=.5,hB=3,gB=2,Zg=/[^a-z0-9]+/,pS=new WeakMap;function hS(e){if(!e)return[];let t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2");return[...e.toLowerCase().split(Zg),...t.toLowerCase().split(Zg)].filter(Boolean)}function bB(e){let t=pS.get(e);if(t)return t;let n=new Set;for(let a of[e.longName??"",e.description??"",...e.keywords??[]])for(let i of hS(a))n.add(i);let r=new Set;for(let a of[e.exchange??"",e.listedExchange??""])for(let i of hS(a))r.add(i);let o={symbol:e.symbol.toLowerCase(),words:[...n],exchangeWords:[...r]};return pS.set(e,o),o}function yB(e,t){let n=0,r=-1;for(let o of t){let a=e.indexOf(o,n);if(a===-1)return-1;r===-1&&(r=a),n=a+1}return n-r}function gS(e,t){if(t.length<hB||e[0]!==t[0])return!1;let n=yB(e,t);return n!==-1&&n<=t.length*gB}function vB(e,t){if(e.symbol.startsWith(t))return ua.TokenSymbolPrefix;for(let n of e.words)if(n.startsWith(t))return ua.WordPrefix;if(e.symbol.includes(t))return ua.SymbolSubstring;for(let n of e.exchangeWords)if(n.startsWith(t))return ua.Exchange;if(gS(e.symbol,t))return ua.Fuzzy;for(let n of e.words)if(gS(n,t))return ua.Fuzzy;return ua.NoMatch}function bS(e,t,n){let r=bB(e);if(r.symbol===n)return ua.ExactSymbol;if(r.symbol.startsWith(n))return ua.SymbolPrefix;let o=0;for(let a of t){let i=vB(r,a);if(i>=ua.NoMatch)return ua.NoMatch;o=Math.max(o,i)}return o}function yS(e,t){if(t.type&&e.type!==t.type||t.dataLevel&&e.dataLevel!==t.dataLevel)return!1;if(t.exchange){let n=t.exchange.toLowerCase();if(!(e.exchange?.toLowerCase()===n||e.listedExchange?.toLowerCase()===n))return!1}return!0}function Ju(e,t){let n=t.query.trim().toLowerCase(),r=n.split(Zg).filter(Boolean),o=[];e.forEach((u,d)=>{let m=u.subsymbols??[];if(!yS(u,t)&&!m.some(h=>yS(h,t)))return;let f=ua.ExactSymbol;if(r.length){f=bS(u,r,n);for(let h of m)f=Math.min(f,bS(h,r,n)+pB);if(f>=ua.NoMatch)return}o.push({symbol:u,rank:f,index:d})}),o.sort((u,d)=>u.rank-d.rank||u.index-d.index);let a=t.cursor&&Number(t.cursor)||0,i=t.limit&&t.limit>0?t.limit:o.length,s=o.slice(a,a+i),l=a+s.length,c=l<o.length;return{symbols:s.map(u=>u.symbol),hasMore:c,cursor:c?String(l):void 0}}function op(e){return Array.isArray(e)?{symbols:e,hasMore:!1}:e}function vS(e){return JSON.stringify([e.query.trim().toLowerCase(),e.type??"",e.exchange??"",e.dataLevel??"",e.limit??0,e.cursor??""])}function bl(){return{bids:new Map,asks:new Map,bestBid:null,bestAsk:null}}function Qg(e){let t=null;for(let n of e.bids.values())(t===null||n.price>t)&&(t=n.price);e.bestBid=t}function Jg(e){let t=null;for(let n of e.asks.values())(t===null||n.price<t)&&(t=n.price);e.bestAsk=t}function yl(e,t){if(t.action==="R"){e.bids.clear(),e.asks.clear(),e.bestBid=null,e.bestAsk=null;return}let n=t.side;if((t.action==="T"||t.action==="F")&&(n=t.side==="B"?"A":"B"),t.action==="A"){let r=n==="B"?e.bids:e.asks,o=t.price;r.set(t.order_id,{price:o,size:t.size}),n==="B"?(e.bestBid===null||o>e.bestBid)&&(e.bestBid=o):(e.bestAsk===null||o<e.bestAsk)&&(e.bestAsk=o)}else if(t.action==="C"){let r=n==="B"?e.bids:e.asks,o=r.get(t.order_id);if(!o)return;let a=o.price;r.delete(t.order_id),n==="B"?a===e.bestBid&&Qg(e):a===e.bestAsk&&Jg(e)}else if(t.action==="M"){let o=(n==="B"?e.bids:e.asks).get(t.order_id);if(!o)return;let a=o.price,i=t.price!==null&&t.price!==0?t.price:a,s=i!==a;o.size=t.size,s&&(o.price=i),s&&(n==="B"?i>(e.bestBid??-1/0)?e.bestBid=i:a===e.bestBid&&Qg(e):i<(e.bestAsk??1/0)?e.bestAsk=i:a===e.bestAsk&&Jg(e))}else if(t.action==="T"||t.action==="F"){let r=e.bids.get(t.order_id),o=e.asks.get(t.order_id);if(r){let a=r.price;e.bids.delete(t.order_id),a===e.bestBid&&Qg(e)}if(o){let a=o.price;e.asks.delete(t.order_id),a===e.bestAsk&&Jg(e)}}}function eb(e){return e.bestBid}function tb(e){return e.bestAsk}var wB={tickSize:.25,imbalanceRatio:3,stackMinCount:3,absorptionMult:2.5,absorptionDeltaFrac:.25,unfinishedTicks:1,diagRatio:3};function xS(e,t,n={}){if(t===0n||e.length===0)return[];let r={...wB,...n},{tickSize:o,imbalanceRatio:a,stackMinCount:i,absorptionMult:s,absorptionDeltaFrac:l,unfinishedTicks:c,diagRatio:u}=r,d=h=>Math.round(h/o)*o,m=new Map;for(let h of e){if(h.action!=="T"||h.price===null||h.side==="N")continue;let g=xB(h.ts_event)/t*t,y=d(h.price),v=h.size,b=h.side==="B",S=m.get(g);S||(S={levels:new Map,open:y,high:y,low:y,close:y,totalVol:0},m.set(g,S)),y>S.high&&(S.high=y),y<S.low&&(S.low=y),S.close=y,S.totalVol+=v;let C=S.levels.get(y);C||(C={bid:0,ask:0},S.levels.set(y,C)),b?C.ask+=v:C.bid+=v}let f=[];for(let[h,p]of m){let g=Array.from(p.levels.keys()).sort((E,L)=>L-E),y=g.length,v=y>0?p.totalVol/y:1,b=s*v,S=0,C=0,w=p.open,k=0,M=new Map;for(let E of g){let L=p.levels.get(E),z=L.bid+L.ask,Y=L.ask-L.bid;z>S&&(S=z),Math.abs(Y)>C&&(C=Math.abs(Y)),z>k&&(k=z,w=E);let G=Math.max(p.open,p.close),H=Math.min(p.open,p.close),W=E<=G&&E>=H,U=z>=b&&z>0&&Math.abs(Y)/z<=l&&W;M.set(E,{price:E,bidVol:L.bid,askVol:L.ask,delta:Y,totalVol:z,bidImbalance:!1,askImbalance:!1,diagAskImbalance:!1,diagBidImbalance:!1,absorption:U})}for(let[,E]of M){let{bidVol:L,askVol:z}=E;z>0&&(L===0||z/L>=a)&&(E.askImbalance=!0),L>0&&(z===0||L/z>=a)&&(E.bidImbalance=!0)}for(let[E,L]of M){let z=M.get(d(E-o)),Y=M.get(d(E+o));z&&L.askVol>0&&(z.bidVol===0||L.askVol/z.bidVol>=u)&&(L.diagAskImbalance=!0),Y&&L.bidVol>0&&(Y.askVol===0||L.bidVol/Y.askVol>=u)&&(L.diagBidImbalance=!0)}let I=Array.from(M.values()).sort((E,L)=>L.price-E.price),x=[],T=[];wS(I,E=>E.askImbalance,i,x),wS(I,E=>E.bidImbalance,i,T);let R=!1,P=!1,D=d(p.high);for(let E=0;E<c;E++){let L=d(D-E*o),z=M.get(L);if(!z||z.askVol===0){R=!0;break}}let N=d(p.low);for(let E=0;E<c;E++){let L=d(N+E*o),z=M.get(L);if(!z||z.bidVol===0){P=!0;break}}let O=0,A=0;for(let E of I)E.diagAskImbalance&&O++,E.diagBidImbalance&&A++;let B=O>A?"buy":A>O?"sell":"none";f.push({ts:h,open:p.open,high:p.high,low:p.low,close:p.close,totalVol:p.totalVol,totalDelta:I.reduce((E,L)=>E+L.delta,0),maxLevelVol:Math.max(1,S),maxAbsDelta:Math.max(1,C),levels:I,isBullish:p.close>=p.open,poc:w,stackedBuyZones:x,stackedSellZones:T,unfinishedTop:R,unfinishedBottom:P,absorptionCount:I.filter(E=>E.absorption).length,diagDominant:B})}return f.sort((h,p)=>h.ts<p.ts?-1:1),f}function wS(e,t,n,r){let o=-1,a=0;for(let i=0;i<=e.length;i++)i<e.length&&t(e[i])?(a===0&&(o=i),a++):(a>=n&&r.push({high:e[o].price,low:e[o+a-1].price}),a=0,o=-1)}function xB(e){let t=e.replace(/\.\d+Z$/,".000Z"),n=BigInt(new Date(t).getTime())*1000000n,r=e.match(/\.(\d+)Z$/);if(r){let o=BigInt(r[1].padEnd(9,"0").slice(0,9));return n+o}return n}function Ia(e){let t=e.replace(/\.\d+Z$/,".000Z"),n=BigInt(new Date(t).getTime())*1000000n,r=e.match(/\.(\d+)Z$/);if(r){let o=BigInt(r[1].padEnd(9,"0").slice(0,9));return n+o}return n}var SS=20,SB=-2147483648,CB=100,kB={A:0,C:1,M:2,T:3,F:4,R:5},TB={B:0,A:1,N:2},IB=50000000n;function MB(e,t){let n=new ArrayBuffer(e.length*SS),r=new DataView(n);for(let o=0;o<e.length;o++){let a=e[o],i=o*SS;r.setBigInt64(i,t[o],!0);let s=a.price===null?SB:Math.round(a.price*CB);r.setInt32(i+8,s,!0),r.setUint32(i+12,a.size>>>0,!0);let l=parseInt(a.order_id,10)&16777215;r.setUint8(i+16,l&255),r.setUint8(i+17,l>>8&255),r.setUint8(i+18,l>>16&255);let c=kB[a.action]??0,u=TB[a.side]??2;r.setUint8(i+19,(c&15)<<4|(u&3)<<2)}return n}function nb(e,t,n={}){if(e.length===0)return{kind:"l3",compactBuf:new ArrayBuffer(0),trades:[],priceHistory:[],footprintBars:[],dataStart:0,dataEnd:0};let r=[],o=[],a=bl(),i=new BigInt64Array(e.length);for(let d=0;d<e.length;d++)i[d]=Ia(e[d].ts_event);let s=null,l=null,c=0n;for(let d=0;d<e.length;d++){let m=e[d],f=i[d];yl(a,m);let h=tb(a),p=eb(a);if(h!==s||p!==l){if(f-c>=IB||c===0n)o.push({ts:f,bestAsk:h??0,bestBid:p??0}),c=f;else{let g=o[o.length-1];g&&(g.bestAsk=h??0,g.bestBid=p??0)}s=h,l=p}m.action==="T"&&m.side!=="N"&&m.price!==null&&r.push({ts:f,price:m.price,size:m.size,side:m.side})}let u=t>0n?xS(e,t,n):[];return{kind:"l3",compactBuf:MB(e,i),trades:r,priceHistory:o,footprintBars:u,dataStart:new Date(e[0].ts_event).getTime(),dataEnd:new Date(e[e.length-1].ts_event).getTime()}}function LB(e,t){let n=e.compactBuf.byteLength+t.compactBuf.byteLength,r=new Uint8Array(n);return r.set(new Uint8Array(e.compactBuf),0),r.set(new Uint8Array(t.compactBuf),e.compactBuf.byteLength),{kind:"l3",compactBuf:r.buffer,trades:e.trades.concat(t.trades),priceHistory:e.priceHistory.concat(t.priceHistory),footprintBars:e.footprintBars.concat(t.footprintBars),dataStart:e.dataStart>0?e.dataStart:t.dataStart,dataEnd:t.dataEnd>0?t.dataEnd:e.dataEnd}}function ap(e,t){return e.length===0?{kind:"ohlcv",ohlcvBars:[],dataStart:0,dataEnd:0}:{kind:"ohlcv",ohlcvBars:e,dataStart:e[0].time,dataEnd:e[e.length-1].time}}function rb(e,t,n){let r=ap(e,n),o=t.map(a=>({resolution:a.resolution,bars:a.bars}));return{...r,supplemental:o}}var RB=50000000n;function ob(e,t){if(e.length===0)return{kind:"tick",trades:[],priceHistory:[],footprintBars:[],dataStart:0,dataEnd:0};let n=[],r=[],o=0,a=0,i=0n;for(let l of e){let c=BigInt(l.time)*1000000n;if(l.side==="B"?o=l.price:l.side==="A"&&(a=l.price),l.side!=="N"&&n.push({ts:c,price:l.price,size:l.size,side:l.side}),c-i>=RB||i===0n)r.push({ts:c,bestBid:o,bestAsk:a}),i=c;else{let u=r[r.length-1];u&&(u.bestBid=o,u.bestAsk=a)}}let s=[];if(t>0n){let l=new Map;for(let u of e){let d=BigInt(u.time)*1000000n,m=d-d%t;l.has(m)||l.set(m,{ts:m,open:u.price,high:u.price,low:u.price,close:u.price,totalVol:0,totalDelta:0,levels:{}});let f=l.get(m);u.price>f.high&&(f.high=u.price),u.price<f.low&&(f.low=u.price),f.close=u.price,f.totalVol+=u.size,u.side!=="N"&&(f.levels[u.price]||(f.levels[u.price]={bidVol:0,askVol:0}),u.side==="B"?(f.levels[u.price].bidVol+=u.size,f.totalDelta+=u.size):(f.levels[u.price].askVol+=u.size,f.totalDelta-=u.size))}let c=Array.from(l.keys()).sort((u,d)=>u<d?-1:1);for(let u of c){let d=l.get(u);s.push({ts:d.ts,open:d.open,high:d.high,low:d.low,close:d.close,totalVol:d.totalVol,totalDelta:d.totalDelta,levels:d.levels})}}return{kind:"tick",trades:n,priceHistory:r,footprintBars:s,dataStart:e[0].time,dataEnd:e[e.length-1].time}}var PB=50000000n;function ab(e,t){if(e.length===0)return{kind:"l2",priceHistory:[],dataStart:0,dataEnd:0};let n=[],r=0n;for(let o of e){let a=BigInt(o.time)*1000000n,i=o.bids.length>0?o.bids[0].price:0,s=o.asks.length>0?o.asks[0].price:0;if(a-r>=PB||r===0n)n.push({ts:a,bestBid:i,bestAsk:s}),r=a;else{let l=n[n.length-1];l&&(l.bestBid=i,l.bestAsk=s)}}return{kind:"l2",priceHistory:n,dataStart:e[0].time,dataEnd:e[e.length-1].time}}function ed(e){switch(e.kind){case"l3":return e.compactBuf.byteLength===0;case"tick":return e.trades.length===0;case"ohlcv":return e.ohlcvBars.length===0;case"l2":return e.priceHistory.length===0}}var DB=`(()=>{var Q=["A","C","M","T","F","R"],X=["B","A","N"];var I={ts_event:"",action:"A",side:"N",price:null,size:0,order_id:"0",sequence:0,flags:0};function $(e,t){let n=t*20,o=e._view,s=o.getBigInt64(n,!0),u=o.getInt32(n+8,!0),r=o.getUint32(n+12,!0),i=o.getUint8(n+16),c=o.getUint8(n+17),B=o.getUint8(n+18),l=o.getUint8(n+19);return I.action=Q[l>>4&15]??"A",I.side=X[l>>2&3]??"N",I.price=u===-2147483648?null:u/100,I.size=r,I.order_id=String(i|c<<8|B<<16),I.ts_event=q(s),I.sequence=t,I.flags=0,I}function Z(e,t,n){let o=Math.max(0,t),s=Math.min(e.length,n),u=new Array(s-o);for(let r=o;r<s;r++){let i=$(e,r);u[r-o]={ts_event:i.ts_event,action:i.action,side:i.side,price:i.price,size:i.size,order_id:i.order_id,sequence:i.sequence,flags:i.flags}}return u}function q(e){let t=Number(e/1000000n),n=Number(e%1000000n);return new Date(t).toISOString().slice(0,-1)+String(n).padStart(6,"0")+"Z"}var T=20,m=6,y=4,f=8;function E(e,t){return BigInt(e>>>0)<<32n|BigInt(t>>>0)}function D(e){return Number(e>>32n)}function H(e){return Number(e&0xffffffffn)}function V(e,t){return e.getBigInt64(t*T,!0)}function ee(e){let t={_buf:e.buf,_view:new DataView(e.buf),length:e.length,capacity:e.capacity,firstTs:0n,lastTs:0n},n=Z(t,e.start,e.end);return[{kind:"slice",id:e.id,messageType:e.messageType,events:n,buf:t._buf},[t._buf]]}function te(e){let t=e.incomingBuf.byteLength/T,n=e.existingLength+t,o=E(e.barNsHi,e.barNsLo),s,u;n>e.existingCapacity?(u=Math.max(e.existingCapacity*2,n),s=new ArrayBuffer(u*T),new Uint8Array(s,t*T).set(new Uint8Array(e.existingBuf,0,e.existingLength*T))):(s=e.existingBuf,u=e.existingCapacity,new Uint8Array(s).copyWithin(t*T,0,e.existingLength*T)),new Uint8Array(s,0).set(new Uint8Array(e.incomingBuf));let r=new Float64Array(e.newTradesBuf),i=new Float64Array(e.existingTradesBuf),c=new Float64Array(r.length+i.length);c.set(r,0),c.set(i,r.length);let B=new Float64Array(e.newPhBuf),l=new Float64Array(e.existingPhBuf),_=new Float64Array(B.length+l.length);_.set(B,0),_.set(l,B.length);let C=G(_,o),R=j(r,o),d=new Float64Array(e.existingOhlcvBuf),A=d.length/f;for(let w=0;w<A;w++){let b=E(d[w*f],d[w*f+1]);R.has(b)||R.set(b,{open:d[w*f+2],high:d[w*f+3],low:d[w*f+4],close:d[w*f+5],volume:d[w*f+6],delta:d[w*f+7]})}let L=Y(R),M={kind:"prepend-merge",id:e.id,mergedBuf:s,mergedLength:n,mergedCapacity:u,mergedTradesBuf:c.buffer,mergedPhBuf:_.buffer,bucketedPhBuf:C,mergedOhlcvBuf:L,prependedCount:t},P=[s,c.buffer,_.buffer,C,L];return e.existingBuf!==s&&P.push(e.existingBuf),[M,P]}function ne(e){let t=E(e.barNsHi,e.barNsLo),n=new Float64Array(e.tradesBuf),o=new Float64Array(e.phBuf),s=j(n,t),u=Y(s),r=G(o,t);return[{kind:"load-ingest",id:e.id,ohlcvBuf:u,bucketedPhBuf:r,tradesBuf:e.tradesBuf,phBuf:e.phBuf},[u,r,e.tradesBuf,e.phBuf]]}function re(e){let t=E(e.barNsHi,e.barNsLo),n=E(e.trimBeforeNsHi,e.trimBeforeNsLo),o=n>0n,s=E(e.dataEndNsHi,e.dataEndNsLo),u=e.incomingBuf.byteLength/T,r=e.existingLength+u,i,c;r>e.existingCapacity?(c=Math.max(e.existingCapacity*2,r),i=new ArrayBuffer(c*T),new Uint8Array(i).set(new Uint8Array(e.existingBuf,0,e.existingLength*T))):(i=e.existingBuf,c=e.existingCapacity),new Uint8Array(i,e.existingLength*T).set(new Uint8Array(e.incomingBuf));let B=r,l=new DataView(i),_=B>0?V(l,0):0n,C=0;if(o&&B>0&&_<n){let g=0,a=B-1;for(;g<=a;){let h=g+a>>>1;V(l,h)<n?(C=h+1,g=h+1):a=h-1}if(C>0){let h=(B-C)*T,p=C*T;new Uint8Array(i).copyWithin(0,p,p+h),B-=C,_=B>0?V(l,0):0n}}let R=new Float64Array(e.existingTradesBuf),d=new Float64Array(e.newTradesBuf),A=new Float64Array(R.length+d.length);A.set(R,0),A.set(d,R.length);let L=0,M;if(o&&A.length>0){let g=A.length/m,a=0,h=g-1;for(;a<=h;){let p=a+h>>>1;E(A[p*m],A[p*m+1])<n?(L=p+1,a=p+1):h=p-1}M=L>0?A.slice(L*m).buffer:A.buffer}else M=A.buffer;let P=new Float64Array(e.existingPhBuf),w=new Float64Array(e.newPhBuf),b=new Float64Array(P.length+w.length);b.set(P,0),b.set(w,P.length);let O=0,S;if(o&&b.length>0){let g=b.length/y,a=0,h=g-1;for(;a<=h;){let p=a+h>>>1;E(b[p*y],b[p*y+1])<n?(O=p+1,a=p+1):h=p-1}S=O>0?b.slice(O*y).buffer:b.buffer}else S=b.buffer;let v=new Float64Array(e.existingOhlcvBuf),U=new Map,J=v.length/f;for(let g=0;g<J;g++){let a=E(v[g*f],v[g*f+1]);o&&a<n||U.set(a,{open:v[g*f+2],high:v[g*f+3],low:v[g*f+4],close:v[g*f+5],volume:v[g*f+6],delta:v[g*f+7]})}if(t>0n){let g=d.length/m;for(let a=0;a<g;a++){let p=E(d[a*m],d[a*m+1])/t*t,x=d[a*m+2],k=d[a*m+3],W=d[a*m+4]===0,N=U.get(p);N?(x>N.high&&(N.high=x),x<N.low&&(N.low=x),N.close=x,N.volume+=k,N.delta+=W?k:-k):U.set(p,{open:x,high:x,low:x,close:x,volume:k,delta:W?k:-k})}}let z=Y(U),K={kind:"append-ingest",id:e.id,mergedBuf:i,mergedLength:B,mergedCapacity:c,mergedTradesBuf:M,mergedPhBuf:S,mergedOhlcvBuf:z,appendedCount:u,compactCutCount:C,tradeCutCount:L,phCutCount:O,newFirstTsHi:D(_),newFirstTsLo:H(_),newLastTsHi:D(s),newLastTsLo:H(s)},F=[i,M,S,z];return e.existingBuf!==i&&F.push(e.existingBuf),F.push(e.incomingBuf),A.buffer!==M&&F.push(A.buffer),b.buffer!==S&&F.push(b.buffer),[K,F]}function j(e,t){let n=new Map;if(t===0n)return n;let o=e.length/m;for(let s=0;s<o;s++){let r=E(e[s*m],e[s*m+1])/t*t,i=e[s*m+2],c=e[s*m+3],B=e[s*m+4]===0,l=n.get(r);l?(i>l.high&&(l.high=i),i<l.low&&(l.low=i),l.close=i,l.volume+=c,l.delta+=B?c:-c):n.set(r,{open:i,high:i,low:i,close:i,volume:c,delta:B?c:-c})}return n}function Y(e){let t=new Float64Array(e.size*f),n=0;for(let[o,s]of e)t[n*f+0]=D(o),t[n*f+1]=H(o),t[n*f+2]=s.open,t[n*f+3]=s.high,t[n*f+4]=s.low,t[n*f+5]=s.close,t[n*f+6]=s.volume,t[n*f+7]=s.delta,n++;return t.buffer}function G(e,t){if(t===0n||e.length===0)return e.slice().buffer;let n=new Map,o=e.length/y;for(let r=0;r<o;r++){let c=E(e[r*y],e[r*y+1])/t*t;n.set(c,{ts:c,bestBid:e[r*y+2],bestAsk:e[r*y+3]})}let s=Array.from(n.values()).sort((r,i)=>r.ts<i.ts?-1:1),u=new Float64Array(s.length*y);for(let r=0;r<s.length;r++)u[r*y+0]=D(s[r].ts),u[r*y+1]=H(s[r].ts),u[r*y+2]=s[r].bestBid,u[r*y+3]=s[r].bestAsk;return u.buffer}self.onmessage=e=>{let t=e.data;if(t.kind==="slice"){let[n,o]=ee(t);self.postMessage(n,o)}else if(t.kind==="prepend-merge"){let[n,o]=te(t);self.postMessage(n,o)}else if(t.kind==="load-ingest"){let[n,o]=ne(t);self.postMessage(n,o)}else if(t.kind==="append-ingest"){let[n,o]=re(t);self.postMessage(n,o)}};})();
|
|
3
|
+
`,ib;function CS(){return ib||(ib=URL.createObjectURL(new Blob([DB],{type:"text/javascript"}))),ib}var vl=6,Ri=4,ji=8;function sb(e){return Number(e>>32n)}function lb(e){return Number(e&0xffffffffn)}function ip(e,t){return BigInt(e>>>0)<<32n|BigInt(t>>>0)}function kS(e){let t=new Float64Array(e.length*vl);for(let n=0;n<e.length;n++){let r=e[n];t[n*vl+0]=sb(r.ts),t[n*vl+1]=lb(r.ts),t[n*vl+2]=r.price,t[n*vl+3]=r.size,t[n*vl+4]=r.side==="B"?0:1,t[n*vl+5]=0}return t.buffer}function TS(e){let t=new Float64Array(e.length*Ri);for(let n=0;n<e.length;n++)t[n*Ri+0]=sb(e[n].ts),t[n*Ri+1]=lb(e[n].ts),t[n*Ri+2]=e[n].bestBid,t[n*Ri+3]=e[n].bestAsk;return t.buffer}function sp(e){let t=new Float64Array(e),n=t.length/Ri,r=new Array(n);for(let o=0;o<n;o++)r[o]={ts:ip(t[o*Ri+0],t[o*Ri+1]),bestBid:t[o*Ri+2],bestAsk:t[o*Ri+3]};return r}function lp(e,t){let n=new Float64Array(e),r=n.length/ji,o=new Map;for(let a=0;a<r;a++){let i=ip(n[a*ji+0],n[a*ji+1]);if(i>t)break;o.set(i,{open:n[a*ji+2],high:n[a*ji+3],low:n[a*ji+4],close:n[a*ji+5],volume:n[a*ji+6],delta:n[a*ji+7]})}return o}var wl=null,IS=0,Ac=new Map;function MS(){return wl||(wl=new Worker(CS()),wl.onmessage=e=>{let t=e.data,n=Ac.get(t.id);if(n){if(Ac.delete(t.id),t.kind==="slice"){let r=n;r.originalCb._buf=t.buf,r.originalCb._view=new DataView(t.buf),r.resolve({events:t.events,cb:r.originalCb,messageType:t.messageType})}else if(t.kind==="prepend-merge"){let r=n,o=t,a=r.originalCb;a._buf=o.mergedBuf,a._view=new DataView(o.mergedBuf),a.length=o.mergedLength,a.capacity=o.mergedCapacity,r.resolve({cb:a,tradesBuf:o.mergedTradesBuf,phBuf:o.mergedPhBuf,bucketedPhBuf:o.bucketedPhBuf,ohlcvBuf:o.mergedOhlcvBuf,prependedCount:o.prependedCount})}else if(t.kind==="load-ingest"){let r=n,o=t;r.resolve({ohlcvBuf:o.ohlcvBuf,bucketedPhBuf:o.bucketedPhBuf,tradesBuf:o.tradesBuf,phBuf:o.phBuf})}else if(t.kind==="append-ingest"){let r=n,o=t,a=r.originalCb;a._buf=o.mergedBuf,a._view=new DataView(o.mergedBuf),a.length=o.mergedLength,a.capacity=o.mergedCapacity,a.firstTs=ip(o.newFirstTsHi,o.newFirstTsLo),a.lastTs=ip(o.newLastTsHi,o.newLastTsLo),r.resolve({cb:a,mergedTradesBuf:o.mergedTradesBuf,mergedPhBuf:o.mergedPhBuf,mergedOhlcvBuf:o.mergedOhlcvBuf,appendedCount:o.appendedCount,compactCutCount:o.compactCutCount,tradeCutCount:o.tradeCutCount,phCutCount:o.phCutCount})}}},wl.onerror=e=>{console.error("[SliceWorker] crashed",e);for(let[,t]of Ac)t.reject(new Error(`SliceWorker crashed: ${e.message}`));Ac.clear(),wl=null},wl)}function cb(e,t,n,r){return new Promise((o,a)=>{let i=`slice-${++IS}`;Ac.set(i,{kind:"slice",resolve:o,reject:a,originalCb:e,messageType:r}),MS().postMessage({kind:"slice",id:i,buf:e._buf,length:e.length,capacity:e.capacity,start:t,end:n,messageType:r},[e._buf])})}function LS(e){return new Promise((t,n)=>{let r=`load-ingest-${++IS}`;Ac.set(r,{kind:"load-ingest",resolve:t,reject:n});let o={kind:"load-ingest",id:r,tradesBuf:e.tradesBuf,phBuf:e.phBuf,barNsHi:sb(e.barNs),barNsLo:lb(e.barNs)};MS().postMessage(o,[e.tradesBuf,e.phBuf])})}var Zr="christtrade:chart:",Cn={chartSettings:`${Zr}settings`,customTimeframes:`${Zr}custom-timeframes`,favoriteTimeframes:`${Zr}favorite-timeframes`,drawingTemplates:`${Zr}drawing-templates`,drawingFavorites:`${Zr}drawing-favorites`,colorSwatches:`${Zr}color-swatches`,pluginStartup:`${Zr}plugin-startup`,pluginPanels:`${Zr}plugin-panels`};function hb(e){return`${Zr}plugin:${e}`}function cp(e,t){return`${Zr}plugin:${e}:${t}`}function PS(e){return`${Zr}plugin:${e}:`}var up=`${Zr}meta:`,td=`${Zr}persist`,Gi=new Map,ub=null;function AB(e){ub=e,e&&BB(e),yb()}function BB(e){if(!(typeof window>"u"||typeof window.localStorage>"u"))try{let t=new Set(e.keys());for(let n of Object.keys(window.localStorage)){if(!n.startsWith(Zr)||t.has(n))continue;let r=window.localStorage.getItem(n);r!==null&&e.setItem(n,r)}}catch{}}var gb={getItem:e=>window.localStorage.getItem(e),setItem:(e,t)=>window.localStorage.setItem(e,t),removeItem:e=>window.localStorage.removeItem(e),keys:()=>Object.keys(window.localStorage)};function dp(){return ub||(fp()?gb:null)}function bb(){let e=dp();return!e||e===gb&&!mp()?null:e}var Bc=null,db=new Set,fb=new Set;function nd(e){return fb.add(e),()=>fb.delete(e)}function yb(){fb.forEach(e=>e())}function fp(){return typeof window<"u"&&typeof window.localStorage<"u"}function mp(){if(Bc!==null)return Bc;if(!fp())return!0;try{Bc=window.localStorage.getItem(td)!=="false"}catch{Bc=!0}return Bc}function vb(e){if(Bc=e,fp())try{if(window.localStorage.setItem(td,String(e)),e)for(let[t,n]of Gi)window.localStorage.setItem(t,n)}catch{}db.forEach(t=>t(e))}function NB(e){return db.add(e),()=>db.delete(e)}var DS={"christtrade.l3-chart-settings":Cn.chartSettings,christrade_custom_tfs:Cn.customTimeframes,christrade_favorite_tfs:Cn.favoriteTimeframes,drawing_style_templates:Cn.drawingTemplates,"ct:drawing-favorites":Cn.drawingFavorites,"christtrade-color-picker-saved":Cn.colorSwatches},mb="ctc:plugin:",RS=!1;function EB(){if(!RS&&(RS=!0,!!fp()))try{let e=window.localStorage;for(let[n,r]of Object.entries(DS)){let o=e.getItem(n);o!==null&&(e.getItem(r)===null&&e.setItem(r,o),e.removeItem(n))}let t=Object.keys(e).filter(n=>n.startsWith(mb));for(let n of t){let r=e.getItem(n);if(r===null)continue;let o=`${Zr}plugin:${n.slice(mb.length)}`;e.getItem(o)===null&&e.setItem(o,r),e.removeItem(n)}}catch{}}function xl(e){let t=bb();if(t){t===gb&&EB();try{let n=t.getItem(e);if(n!==null)return n}catch{}}return Gi.get(e)??null}function qr(e,t){let n=xl(e);if(n===null)return t;try{return JSON.parse(n)}catch{return t}}function pp(e,t){Gi.set(e,t);let n=bb();if(n)try{n.setItem(e,t)}catch{}}function kr(e,t){try{pp(e,JSON.stringify(t))}catch{}}function wb(e){Gi.delete(e);try{dp()?.removeItem(e)}catch{}}function AS(e){for(let n of[...Gi.keys()])n.startsWith(e)&&Gi.delete(n);let t=dp();if(t)try{t.keys().filter(n=>n.startsWith(e)).forEach(n=>t.removeItem(n))}catch{}}function hp(){let e=new Set,t=r=>r.startsWith(Zr)&&!r.startsWith(up);for(let r of Gi.keys())t(r)&&e.add(r);let n=bb();if(n)try{n.keys().filter(t).forEach(r=>e.add(r))}catch{}return e.delete(td),[...e]}function xb(){let e=n=>n.startsWith(Zr)&&n!==td&&!n.startsWith(up)||n.startsWith(mb)||n in DS;for(let n of[...Gi.keys()])e(n)&&Gi.delete(n);let t=dp();if(t)try{t.keys().filter(e).forEach(n=>t.removeItem(n))}catch{}yb()}function gp(){return hp().reduce((e,t)=>e+t.length+(xl(t)?.length??0),0)}var BS="$raw",pb=new Set([Cn.pluginStartup,Cn.pluginPanels]);function Sb(){let e={};for(let t of hp()){if(pb.has(t))continue;let n=xl(t);if(n!==null)try{e[t]=JSON.parse(n)}catch{e[t]={[BS]:n}}}return e}function Cb(e,t={}){if(e){if(t.replace)for(let n of hp())!(n in e)&&!pb.has(n)&&wb(n);for(let[n,r]of Object.entries(e)){if(!n.startsWith(Zr)||n===td||pb.has(n))continue;let o=r?.[BS];typeof o=="string"?pp(n,o):kr(n,r)}yb()}}var da={none:100,"1s":120,"5s":120,"15s":96,"30s":80,"1m":100,"3m":80,"5m":80,"15m":60,"30m":48,"1h":48,"4h":32,"1d":30};function Go(e,t){let n={none:1000000n,ms:1000000n,s:1000000000n,m:60000000000n,h:3600000000000n,d:86400000000000n,w:604800000000000n};return BigInt(e)*n[t]}var Ho=[{label:"None",barNs:Go(1,"none"),defaultBars:da.none,isPreset:!0},{label:"1s",barNs:Go(1,"s"),defaultBars:da["1s"],isPreset:!0},{label:"5s",barNs:Go(5,"s"),defaultBars:da["5s"],isPreset:!0},{label:"15s",barNs:Go(15,"s"),defaultBars:da["15s"],isPreset:!0},{label:"30s",barNs:Go(30,"s"),defaultBars:da["30s"],isPreset:!0},{label:"1m",barNs:Go(1,"m"),defaultBars:da["1m"],isPreset:!0},{label:"3m",barNs:Go(3,"m"),defaultBars:da["3m"],isPreset:!0},{label:"5m",barNs:Go(5,"m"),defaultBars:da["5m"],isPreset:!0},{label:"15m",barNs:Go(15,"m"),defaultBars:da["15m"],isPreset:!0},{label:"30m",barNs:Go(30,"m"),defaultBars:da["30m"],isPreset:!0},{label:"1h",barNs:Go(1,"h"),defaultBars:da["1h"],isPreset:!0},{label:"4h",barNs:Go(4,"h"),defaultBars:da["4h"],isPreset:!0},{label:"1d",barNs:Go(1,"d"),defaultBars:da["1d"],isPreset:!0}];function OB(e){let t=[["w",604800000000000n],["d",86400000000000n],["h",3600000000000n],["m",60000000000n],["s",1000000000n],["ms",1000000n]];for(let[n,r]of t)if(e%r===0n)return`${e/r}${n}`;return`${e}ns`}function NS(e){let t=Ho.find(n=>n.label.toLowerCase()===e.toLowerCase());return t||(Nc(e)??Ho.find(n=>n.label==="1m")??Ho[0])}function kb(e){let t=Ho.find(o=>o.barNs===e);if(t)return t;let r=e>0n?Math.max(10,Math.min(500,Number(7200000000000n/e))):100;return{label:OB(e),barNs:e,defaultBars:r,isPreset:!1}}function ES(e,t){return e.barNs*BigInt(t??e.defaultBars)}function Nc(e){let n=e.trim().toLowerCase().match(/^(\d+)(s|m|h|d|w)$/);if(!n)return null;let r=parseInt(n[1],10),o=n[2];if(r<=0||r>1e5)return null;let a=Go(r,o),s=Math.max(10,Math.min(500,Number(7200000000000n/a)));return{label:`${r}${o}`,barNs:a,defaultBars:s,isPreset:!1}}function OS(){try{let e=qr(Cn.customTimeframes,null);return Array.isArray(e)?e.map(t=>({label:t.label,barNs:BigInt(t.barNs),defaultBars:t.defaultBars,isPreset:!1})):[]}catch{return[]}}function Tb(e){kr(Cn.customTimeframes,e.map(t=>({label:t.label,barNs:t.barNs.toString(),defaultBars:t.defaultBars})))}var _B=["1m","5m","15m","1h","4h","1d"];function _S(){let e=qr(Cn.favoriteTimeframes,null);return Array.isArray(e)?e.filter(t=>typeof t=="string"):[..._B]}function FS(e){kr(Cn.favoriteTimeframes,e)}var FB=1000000n,po=60000000000n,Ib=86400000000000n,WS=["Mon","Tue","Wed","Thu","Fri"],zS=new Map,HS=new Map;function zB(e){let t=zS.get(e);return t||(t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}),zS.set(e,t)),t}function HB(e){let t=HS.get(e);return t||(t=new Intl.DateTimeFormat("en-US",{timeZone:e,weekday:"short"}),HS.set(e,t)),t}function VS(e){let t=parseInt(e.slice(0,2),10),n=parseInt(e.slice(2,4),10);return t*60+n}function qS(e){let[t,n]=e.split("-"),r=VS(t),o=VS(n);return{openMin:r,closeMin:o,overnight:o<=r}}function Ps(e,t){let n=Number(e/FB),r=zB(t),o=Object.fromEntries(r.formatToParts(n).map(c=>[c.type,c.value])),a=parseInt(o.hour,10)%24,i=parseInt(o.minute,10),s=HB(t).format(n),l={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return{year:parseInt(o.year,10),month:parseInt(o.month,10),day:parseInt(o.day,10),dayOfWeek:l[s]??0,minuteOfDay:a*60+i,isoDate:`${o.year}-${o.month}-${o.day}`}}function bp(e,t,n,r){let o=e.hours;if(o==="24/7"||o==="always")return!0;if(US(r,e.holidays))return!1;let a=jS(r,e.corrections),{openMin:i,closeMin:s,overnight:l}=qS(a?a.hours:o),c=e.days??WS,u=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d=u[n];if(l){let m=u[(n+6)%7],f=c.includes(d)&&t>=i,h=c.includes(m)&&t<s;return f||h}return c.includes(d)&&t>=i&&t<s}function US(e,t){return!t||t.length===0?!1:t.includes(e)}function jS(e,t){return t?.find(n=>n.date===e)??null}function Pi(e,t){if(!e||e.hours==="24/7"||e.hours==="always")return{kind:"always"};let n=Ps(t,e.timezone);if(bp(e,n.minuteOfDay,n.dayOfWeek,n.isoDate))return{kind:"open"};if(e.subsessions)for(let r of e.subsessions){let o={hours:r.hours,timezone:e.timezone,days:r.days??e.days};if(bp(o,n.minuteOfDay,n.dayOfWeek,n.isoDate))return{kind:"sub",label:r.label}}return{kind:"closed"}}function Ja(e,t){let n=e.hours;if(n==="24/7"||n==="always")return!0;let r=e.timezone,o=Ps(t,r);if(US(o.isoDate,e.holidays))return!1;let a=jS(o.isoDate,e.corrections),{openMin:i,closeMin:s,overnight:l}=qS(a?a.hours:n),c=e.days??WS,u=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d=u[o.dayOfWeek];if(l){let m=u[(o.dayOfWeek+6)%7],f=c.includes(d)&&o.minuteOfDay>=i,h=c.includes(m)&&o.minuteOfDay<s;return f||h}else return c.includes(d)&&o.minuteOfDay>=i&&o.minuteOfDay<s}function Mb(e,t,n){if(e.hours==="24/7"||e.hours==="always")return[{from:t,to:n}];let r=[],o=po,a=t/o*o,i=n,s=null,l=a;for(;l<=i;){let c=Ja(e,l);c&&s===null?s=l<t?t:l:!c&&s!==null&&(r.push({from:s,to:l}),s=null),l+=o}return s!==null&&r.push({from:s,to:i}),r}function rd(e,t){if(e.hours==="24/7"||e.hours==="always"||Ja(e,t))return t;let n=t/po*po+po,r=t+Ib*8n;for(;n<r;){if(Ja(e,n))return n;n+=po}return n}function VB(e,t){if(e.hours==="24/7"||e.hours==="always"||!Ja(e,t))return t;let n=t/po*po,r=t-Ib*8n;for(;n>r;){if(!Ja(e,n))return n;n-=po}return n}function Lb(e,t,n){if(!e||e.hours==="24/7"||e.hours==="always")return t-n;if(n<=0n)return t;let r=n,o=t/po*po,a=t-Ib*14n;for(;r>0n&&o>a;)if(Ja(e,o)){let i=o,s=o;for(;s>a&&Ja(e,s-po);)s-=po;let l=i-s+po;if(l>=r)return o-r+po;r-=l,o=s-po}else{let i=po*30n;for(o-=i;o>a&&!Ja(e,o);)o-=po}return o>a?o:a}var WB=32,qB=200;function UB(e,t){return e<t?e:t}function Rb(e){let t=Number(e/1000000n),n=Number(e%1000000n);return new Date(t).toISOString().slice(0,-1)+String(n).padStart(6,"0")+"Z"}function Ec(e){return e.map(t=>({time:Number(t.ts/1000000n),open:t.open,high:t.high,low:t.low,close:t.close,volume:t.totalVol}))}function jB(e){return e.map(t=>({time:Number(t.ts/1000000n),price:t.price,size:t.size,side:t.side}))}function GB(e){switch(e.kind){case"l3":return{dataLevel:"l3",compactBuf:e.compactBuf,trades:e.trades,priceHistory:e.priceHistory,footprintBars:e.footprintBars,ohlcvBars:Ec(e.footprintBars),dataStart:e.dataStart,dataEnd:e.dataEnd};case"tick":return{dataLevel:"tick",compactBuf:new ArrayBuffer(0),trades:e.trades,priceHistory:e.priceHistory,footprintBars:e.footprintBars,ohlcvBars:Ec(e.footprintBars),dataStart:e.dataStart,dataEnd:e.dataEnd};case"ohlcv":return{dataLevel:"ohlcv",compactBuf:new ArrayBuffer(0),trades:[],priceHistory:[],footprintBars:[],ohlcvBars:e.ohlcvBars,dataStart:e.dataStart,dataEnd:e.dataEnd,supplemental:e?.supplemental??null};case"l2":return{dataLevel:"l2",compactBuf:new ArrayBuffer(0),trades:[],priceHistory:e.priceHistory,footprintBars:[],ohlcvBars:[],dataStart:e.dataStart,dataEnd:e.dataEnd}}}var od=class{constructor(t,n,r){ae(this,"eventBus",t);ae(this,"state",n);ae(this,"adapter",null);ae(this,"realtimeUnsub",null);ae(this,"executionEngine",null);ae(this,"config");ae(this,"destroyed",!1);ae(this,"_states",new Map);ae(this,"resolvedSymbols",new Map);ae(this,"paneResolutions",new Map);ae(this,"fpOptions");ae(this,"initialLoad");ae(this,"horizonIso");ae(this,"scrollWindowNs");ae(this,"activeSymbol");ae(this,"_loadChain",Promise.resolve());ae(this,"symbolUniverse",null);ae(this,"symbolUniverseInFlight",null);ae(this,"symbolSearchAbort",null);ae(this,"latestSymbolSearchId",null);ae(this,"symbolSearchCache",new Map);ae(this,"unsubs",[]);ae(this,"sharedData",{dataLevel:"l3",compactBuf:new ArrayBuffer(0),trades:[],priceHistory:[],footprintBars:[],ohlcvBars:[],barNs:60000000000n,dataStart:0,dataEnd:0,supplemental:null});ae(this,"maxLookbackBars");this.initialLoad=r.initialLoad,this.horizonIso=r.horizon,this.fpOptions=r.fpOptions??{},this.scrollWindowNs=r.scrollWindowNs??3600000000000n,this.activeSymbol=r.symbol??"",this.maxLookbackBars=0,this.config=r,this._subscribeToEventBus()}_st(t){let n=this._states.get(t);return n||(n={master:null,session:null,symbolInfo:null,loadedFrom:null,loadedTo:null,hasMoreHistory:!0,hasMoreForward:!0,forwardInFlight:!1,backwardInFlight:!1,pendingBackwardViewMin:null,segments:[],refiningSegments:new Set,supplementalResolution:null},this._states.set(t,n)),n}_targetSymbol(t){return t&&this._states.has(t)?t:this.activeSymbol}setAdapter(t){this.realtimeUnsub?.(),this.realtimeUnsub=null,this.adapter?.destroy?.(),this.adapter=t,this.resolvedSymbols.clear(),this._states.clear()}_adapterFor(t){return this.config.plugins?.adapterFor(t)??this.adapter}_applySymbol(t){let n=this._states.get(t);if(n?.master){this.activeSymbol=t,this._syncShared(),this._emitLoad(n,!0).catch(r=>console.error("[DataEngine] re-emit on symbol switch failed",r));return}this.activeSymbol!==t&&(this.activeSymbol=t,this.load(t))}getResolvedSymbolInfo(t){return this.resolvedSymbols.get(t)??null}attachExecutionEngine(t){this.executionEngine=t}setLookback(t){this.maxLookbackBars=t}load(t){let n=this._loadChain.then(()=>this._load(t));return this._loadChain=n.catch(()=>{}),n}async _load(t){if(this.destroyed)return;this.activeSymbol=t;let n=this._adapterFor(t);if(!n){let l="[DataEngine] No IDataAdapter set.";throw this.eventBus.emit("data:status",{status:"error",error:{code:"no_adapter",message:l},symbol:t}),new Error(l)}let r=this._st(t);r.loadedFrom=null,r.loadedTo=null,r.hasMoreHistory=!0,r.hasMoreForward=!0,r.master=null,r.segments=[],r.refiningSegments.clear(),this.eventBus.emit("data:status",{status:"loading",symbol:t});try{await n.connect?.()}catch(l){this._emitAdapterError("adapter_connect_failed",l,t);return}let o;try{o=await n.resolveSymbol(t),r.session=o.session??null,this.resolvedSymbols.set(o.symbol,o),this.eventBus.emit("data:symbol-resolved",{symbolInfo:o})}catch(l){this._emitAdapterError("resolve_symbol_failed",l,t);return}r.symbolInfo=o;try{let c=n.getCapabilities?.()?.supplementalResolutions;r.supplementalResolution=c&&c.length>0?c.reduce((u,d)=>d<u?d:u):null}catch{r.supplementalResolution=null}let a=BigInt(this.maxLookbackBars)*this._lookbackBarNs(t),i=Ia(this.initialLoad.start)-a,s=Ia(this.initialLoad.end);await this._loadWindow(r,i,s,Ia(this.horizonIso)),n.subscribeRealtime&&(this.realtimeUnsub?.(),this.realtimeUnsub=n.subscribeRealtime(l=>{this._handleRealtimeBar(l)}))}async _loadWindow(t,n,r,o,a=!0){if(this.destroyed||!t.symbolInfo)return;let i=this._adapterFor(t.symbolInfo.symbol);if(!i)return;t.loadedFrom=null,t.loadedTo=null,t.hasMoreHistory=!0,t.hasMoreForward=!0,t.master=null,t.segments=[],t.refiningSegments.clear(),this.horizonIso=Rb(o),a&&this.eventBus.emit("data:status",{status:"loading",symbol:t.symbolInfo.symbol});let s=this._fetchTimeframe(t,this._activeBarNs(t.symbolInfo.symbol)),l=s.barNs;i.fetchPreview&&i.fetchPreview({symbolInfo:t.symbolInfo,range:Rs(n,r),timeframe:s,direction:"backward"}).then(d=>{this.destroyed||this.eventBus.emit("data:preview",d)}).catch(d=>{console.error("[DataEngine] preview fetch failed",d)});let c;try{c=await i.fetchBars({symbolInfo:t.symbolInfo,range:Rs(n,r),timeframe:s,direction:"initial",supplementalBarNs:this._supplementalFor(t,s.barNs)})}catch(d){this._emitAdapterError("fetch_failed",d,t.symbolInfo.symbol);return}let u=this._process(c,t);if(!u){this.eventBus.emit("data:status",{status:"ready",symbol:t.symbolInfo.symbol});return}t.loadedFrom=BigInt(u.dataStart)*1000000n,t.loadedTo=BigInt(u.dataEnd)*1000000n,t.hasMoreHistory=c.hasMore,t.segments=[{from:t.loadedFrom,to:t.loadedTo,fetchBarNs:l}],t.master={...GB(u),barNs:u.kind==="ohlcv"?l:this.state.get("timeframe").barNs,playFromNs:t.loadedFrom,symbolInfo:t.symbolInfo},this._syncShared(),await this._emitLoad(t),this._refineStaleSegments(t)}async seekLoad(t,n){if(this.destroyed)return;let r=BigInt(this.maxLookbackBars)*this._lookbackBarNs(this.activeSymbol),o=(Ia(this.initialLoad.end)-Ia(this.initialLoad.start))/2n,a=t-o-r,i=[...this._states.values()].filter(s=>s.symbolInfo);await Promise.all(i.map(async s=>{n!==void 0&&await this._settleGapFills(s,n,a),await this._loadWindow(s,a,t+o,t,!1)}))}reload(t){let n=this._loadChain.then(()=>{if(!this.destroyed&&this._states.get(this.activeSymbol)?.symbolInfo)return this.seekLoad(t??Ia(this.horizonIso))});return this._loadChain=n.catch(()=>{}),n}async _settleGapFills(t,n,r){let o=this.executionEngine;if(!o||!t.symbolInfo||n<=0n||r<=n)return;let a=this._adapterFor(t.symbolInfo.symbol);if(!a)return;let i=t.symbolInfo.symbol,s=o.getFillSearch();if(!s.enabled||!o.hasPendingTriggers(i))return;let l=r-n,c;try{c=await a.fetchBars({symbolInfo:t.symbolInfo,range:Rs(n,r),timeframe:this._fetchTimeframe(t,s.maxResolution(l)),direction:"forward"})}catch(d){console.error("[DataEngine] gap-fill fetch failed",d);return}let u=(c.ohlcvBars??[]).map(d=>({tsNs:BigInt(Math.round(d.time))*1000000n,open:d.open,high:d.high,low:d.low,close:d.close})).filter(d=>d.tsNs>=n&&d.tsNs<r).sort((d,m)=>d.tsNs<m.tsNs?-1:d.tsNs>m.tsNs?1:0);u.length>0&&o.settleGapBars(u,s.ambiguity,i)}rehydrate(){if(!this.destroyed)for(let t of this._states.values())t.master&&this._emitLoad(t,!0).catch(n=>console.error("[DataEngine] rehydrate _emitLoad failed",n))}rebuildFootprint(t,n){this.destroyed||(n!==void 0&&(this.fpOptions=n),this.eventBus.emit("data:rebuild-footprint",{barNs:this.state.get("timeframe").barNs,fpOptions:this.fpOptions}))}getSnapshot(){let t=this._states.get(this.activeSymbol)?.master??null;if(!t)return{dataLevel:"l3",trades:[],footprintBars:[],priceHistory:[],ohlcvBars:[],ticks:[],barNs:1000000000n,dataStart:0,dataEnd:0,symbolInfo:null};let{dataLevel:n,trades:r,footprintBars:o,priceHistory:a,ohlcvBars:i}=t,s=n==="l3"||n==="tick"?jB(r):[];return{dataLevel:n,trades:r,footprintBars:o,priceHistory:a,ohlcvBars:i,ticks:s,barNs:t.barNs,dataStart:t.dataStart,dataEnd:t.dataEnd,symbolInfo:t.symbolInfo}}destroy(){if(!this.destroyed){this.destroyed=!0;for(let t of this.unsubs)t();this.unsubs.length=0,this.realtimeUnsub?.(),this.realtimeUnsub=null,this._cancelSymbolSearch(),this.symbolSearchCache.clear(),this.symbolUniverse=null,this.adapter?.destroy?.(),this.adapter=null,this._states.clear()}}_fetchForward(t,n){if(this.destroyed)return;let r=this._adapterFor(t);if(!r)return;let o=this._st(t);if(o.forwardInFlight)return;if(!o.hasMoreForward){this.eventBus.emit("data:no-more-forward",{symbol:t});return}if(o.loadedTo===null||!o.symbolInfo)return;let a=n&&n>this.scrollWindowNs?n:this.scrollWindowNs;o.forwardInFlight=!0;let i=o.loadedTo,s=i+a;o.session&&!Ja(o.session,s)&&(s=rd(o.session,s)+a);let l=this._openWindows(o,i,s);if(l.length===0){this.eventBus.emit("data:session-gap",{from:i,to:s,symbol:t}),o.loadedTo=s,o.forwardInFlight=!1;return}let c=l[0].from,u=l[l.length-1].to,d=this._fetchTimeframe(o,this._activeBarNs(t)),m=d.barNs;r.fetchBars({symbolInfo:o.symbolInfo,range:Rs(c,u),timeframe:d,direction:"forward",supplementalBarNs:this._supplementalFor(o,m)}).then(f=>{if(this.destroyed)return;let h=this._process(f,o);f.hasMore===!1&&(o.hasMoreForward=!1,this.eventBus.emit("data:no-more-forward",{symbol:t})),!(!h||ed(h))&&(o.loadedTo=BigInt(h.dataEnd)*1000000n,o.segments.push({from:c,to:o.loadedTo,fetchBarNs:m}),this._growMaster(o,h),this._emitAppend(o,h).catch(p=>console.error("[DataEngine] forward _emitAppend failed",p)))}).catch(f=>{console.error("[DataEngine] forward fetch failed",f),this._emitAdapterError("prefetch_failed",f,t)}).finally(()=>{o.forwardInFlight=!1,this.eventBus.emit("data:prefetch-done",void 0)})}_fetchBackward(t,n){if(this.destroyed)return;let r=this._adapterFor(t);if(!r)return;let o=this._st(t);if(!o.hasMoreHistory||o.loadedFrom===null||!o.symbolInfo)return;if(o.backwardInFlight){(o.pendingBackwardViewMin===null||n<o.pendingBackwardViewMin)&&(o.pendingBackwardViewMin=n);return}let a=this._activeBarNs(t),i=this._fetchTimeframe(o,a),s=i.barNs,l=BigInt(this.maxLookbackBars)*this._lookbackBarNs(t),c=o.symbolInfo.session??null,u=o.loadedFrom,d=o.loadedFrom,m=n-n%a-l,f=c?Lb(c,m,d-m):m;if(f>=u)return;o.backwardInFlight=!0;let h=this._openWindows(o,f,u);if(h.length===0){if(o.loadedFrom=f,this.eventBus.emit("data:session-gap",{from:f,to:u,symbol:t}),o.backwardInFlight=!1,o.pendingBackwardViewMin!==null&&o.hasMoreHistory&&!this.destroyed){let y=o.pendingBackwardViewMin;o.pendingBackwardViewMin=null,this._fetchBackward(t,y)}return}let p=h[0].from,g=h[h.length-1].to;r.fetchPreview&&r.fetchPreview({symbolInfo:o.symbolInfo,range:Rs(p,g),timeframe:i,direction:"backward"}).then(y=>{this.destroyed||this.eventBus.emit("data:preview",y)}).catch(y=>console.error("[DataEngine] backward preview fetch failed",y)),r.fetchBars({symbolInfo:o.symbolInfo,range:Rs(p,g),timeframe:i,direction:"backward"}).then(y=>{if(this.destroyed)return;let v=this._process(y,o);if(!v||ed(v)){o.loadedFrom=p,o.hasMoreHistory=y.hasMore,y.hasMore||this.eventBus.emit("data:no-more-history",{symbol:t});return}o.loadedFrom=BigInt(v.dataStart)*1000000n,o.segments.unshift({from:o.loadedFrom,to:g,fetchBarNs:s}),o.hasMoreHistory=y.hasMore,this._prependMaster(o,v),this._emitPrepend(o,v,n).catch(b=>console.error("[DataEngine] backward _emitPrepend failed",b)),y.hasMore||this.eventBus.emit("data:no-more-history",{symbol:t})}).catch(y=>{console.error("[DataEngine] backward fetch failed",y),o.loadedFrom=p}).finally(()=>{if(o.backwardInFlight=!1,o.pendingBackwardViewMin!==null&&o.hasMoreHistory&&!this.destroyed){let y=o.pendingBackwardViewMin;o.pendingBackwardViewMin=null,this._fetchBackward(t,y)}})}_supplementalFor(t,n){let r=t.supplementalResolution;if(!(r===null||r>=n))return r}_symbolSearchMode(){return this.adapter?.getCapabilities?.().symbolSearch??"none"}_symbolSearchDebounceMs(t){let n=this.adapter?.getCapabilities?.().symbolSearchDebounceMs,r=typeof n=="number"&&n>=0?n:t==="server"?qB:0;return Math.max(r,this.config.plugins?.searchDebounceMs()??0)}async _searchSymbols(t,n){if(this.destroyed)return;this.symbolSearchAbort?.abort(),this.latestSymbolSearchId=t;let r=this._symbolSearchMode(),o=vS(n);if(r==="server"){let s=this.symbolSearchCache.get(o);if(s){this._cacheSymbolSearch(o,s),this._emitSymbolSearch(t,await this._withPluginSymbols(s,n),r);return}}let a=new AbortController;this.symbolSearchAbort=a;let i=()=>this.destroyed||a.signal.aborted||this.latestSymbolSearchId!==t;try{let s;if(r==="server"?s=op(await this.adapter.searchSymbols({...n,signal:a.signal})):s=Ju(await this._loadSymbolUniverse(),n),i())return;r==="server"&&this._cacheSymbolSearch(o,s),this._emitSymbolSearch(t,await this._withPluginSymbols(s,n),r)}catch(s){if(i())return;console.error("[DataEngine] symbol search failed",s),this.eventBus.emit("data:search-symbols-error",{requestId:t,code:s instanceof Qu?s.code:"unknown",message:s instanceof Error?s.message:String(s)})}finally{this.symbolSearchAbort===a&&(this.symbolSearchAbort=null)}}_loadSymbolUniverse(){if(this.symbolUniverse)return Promise.resolve(this.symbolUniverse);let t=this.adapter;return t?(this.symbolUniverseInFlight||(this.symbolUniverseInFlight=Promise.resolve(t.searchSymbols({query:""})).then(n=>{let r=op(n).symbols;return this.symbolUniverse=r,r}).finally(()=>{this.symbolUniverseInFlight=null})),this.symbolUniverseInFlight):Promise.resolve([])}async _withPluginSymbols(t,n){let r=this.config.plugins;if(!r)return t;let o;try{o=await r.search(n)}catch(i){return console.error("[DataEngine] plugin symbol search failed",i),t}if(!o.length)return t;let a=new Set(o.map(i=>i.symbol));return{...t,symbols:[...o,...t.symbols.filter(i=>!a.has(i.symbol))]}}_emitSymbolSearch(t,n,r){this.eventBus.emit("data:search-symbols-response",{requestId:t,symbols:n.symbols,hasMore:n.hasMore??!1,cursor:n.cursor,mode:r,debounceMs:this._symbolSearchDebounceMs(r)})}_cacheSymbolSearch(t,n){if(this.symbolSearchCache.delete(t),this.symbolSearchCache.set(t,n),this.symbolSearchCache.size>WB){let r=this.symbolSearchCache.keys().next().value;r!==void 0&&this.symbolSearchCache.delete(r)}}_cancelSymbolSearch(){this.symbolSearchAbort?.abort(),this.symbolSearchAbort=null,this.latestSymbolSearchId=null}_activeBarNs(t){let n=this.state.get("timeframe").barNs;for(let r of this.paneResolutions.values())r.symbol===t&&r.barNs>0n&&r.barNs<n&&(n=r.barNs);return n}_lookbackBarNs(t){let n=this.state.get("timeframe").barNs;for(let r of this.paneResolutions.values())r.symbol===t&&r.barNs>n&&(n=r.barNs);return n}_onPaneResolution(t,n,r){if(this.destroyed)return;if(r<=0n||!n){(this.paneResolutions.get(t)?.symbol===n||!n)&&this.paneResolutions.delete(t);return}let o=this.paneResolutions.get(t);if(o?.symbol===n&&o.barNs===r)return;this.paneResolutions.set(t,{symbol:n,barNs:r});let a=this._states.get(n);a?.symbolInfo&&this._refineStaleSegments(a)}_refineStaleSegments(t){if(!t.symbolInfo)return;let n=this._effectiveFetchBarNs(t,this._activeBarNs(t.symbolInfo.symbol));for(let r of t.segments.filter(o=>o.fetchBarNs>n))this._refineSegment(t,r,n)}_effectiveFetchBarNs(t,n){let r=t.symbolInfo?.supportedResolutions;if(!r?.length)return n;let o=null;for(let a of r)if(a<=n)o=a;else break;return o??r[0]}_fetchTimeframe(t,n){let r=this._effectiveFetchBarNs(t,n),o=this.state.get("timeframe");return r===o.barNs?o:kb(r)}_process(t,n){if(t._preProcessed){let o=t._preProcessed;return o.kind?o:{kind:"l3",...o}}let r=this.state.get("timeframe").barNs;switch(n.symbolInfo?.dataLevel??"l3"){case"ohlcv":return t.supplementalBars?.length?rb(t.ohlcvBars??[],t.supplementalBars,r):ap(t.ohlcvBars??[],r);case"tick":return ob(t.ticks??[],r);case"l2":return ab(t.l2Snapshots??[],r);default:return t.events?.length?nb(t.events,r,this.fpOptions):null}}_handleRealtimeBar(t){if(this.destroyed)return;let n=this._st(this.activeSymbol);if(!n.master)return;let r=this._process(t,n);!r||ed(r)||(n.loadedTo=BigInt(r.dataEnd)*1000000n,n.hasMoreForward=!0,this._growMaster(n,r),this._emitAppend(n,r).catch(o=>console.error("[DataEngine] realtime _emitAppend failed",o)))}_growMaster(t,n){let r=t.master;if(!r)return;switch(r.dataLevel){case"l3":{let a=n,i=r.compactBuf.byteLength+a.compactBuf.byteLength,s=new Uint8Array(i);s.set(new Uint8Array(r.compactBuf),0),s.set(new Uint8Array(a.compactBuf),r.compactBuf.byteLength),r.compactBuf=s.buffer,r.trades=r.trades.concat(a.trades),r.priceHistory=r.priceHistory.concat(a.priceHistory),r.footprintBars=r.footprintBars.concat(a.footprintBars),r.ohlcvBars=Ec(r.footprintBars),r.dataEnd=a.dataEnd>0?a.dataEnd:r.dataEnd;break}case"tick":{let a=n;r.trades=r.trades.concat(a.trades),r.priceHistory=r.priceHistory.concat(a.priceHistory),r.footprintBars=r.footprintBars.concat(a.footprintBars),r.ohlcvBars=Ec(r.footprintBars),r.dataEnd=a.dataEnd>0?a.dataEnd:r.dataEnd;break}case"ohlcv":{let a=n;for(let i of a.ohlcvBars)r.ohlcvBars.push(i);if(r.dataEnd=a.dataEnd>0?a.dataEnd:r.dataEnd,a.supplemental?.length)if(!r.supplemental)r.supplemental=a.supplemental.map(i=>({...i,bars:[...i.bars]}));else for(let i of a.supplemental){let s=r.supplemental.find(l=>l.resolution===i.resolution);if(s)for(let l of i.bars)s.bars.push(l);else r.supplemental.push({...i,bars:[...i.bars]})}break}case"l2":{let a=n;r.priceHistory=r.priceHistory.concat(a.priceHistory),r.dataEnd=a.dataEnd>0?a.dataEnd:r.dataEnd;break}}r.barNs=this._masterBarNs(t),this._syncShared()}_prependMaster(t,n){let r=t.master;if(!r)return;switch(r.dataLevel){case"l3":{let a=n,i=a.compactBuf.byteLength+r.compactBuf.byteLength,s=new Uint8Array(i);s.set(new Uint8Array(a.compactBuf),0),s.set(new Uint8Array(r.compactBuf),a.compactBuf.byteLength),r.compactBuf=s.buffer,r.trades=a.trades.concat(r.trades),r.priceHistory=a.priceHistory.concat(r.priceHistory),r.footprintBars=a.footprintBars.concat(r.footprintBars),r.ohlcvBars=Ec(r.footprintBars),r.dataStart=a.dataStart>0?a.dataStart:r.dataStart;break}case"tick":{let a=n;r.trades=a.trades.concat(r.trades),r.priceHistory=a.priceHistory.concat(r.priceHistory),r.footprintBars=a.footprintBars.concat(r.footprintBars),r.ohlcvBars=Ec(r.footprintBars),r.dataStart=a.dataStart>0?a.dataStart:r.dataStart;break}case"ohlcv":{let a=n;r.ohlcvBars=a.ohlcvBars.concat(r.ohlcvBars),r.dataStart=a.dataStart>0?a.dataStart:r.dataStart;break}case"l2":{let a=n;r.priceHistory=a.priceHistory.concat(r.priceHistory),r.dataStart=a.dataStart>0?a.dataStart:r.dataStart;break}}r.barNs=this._masterBarNs(t),this._syncShared()}_masterBarNs(t){let n=this.state.get("timeframe").barNs;return t.master?.dataLevel!=="ohlcv"||!t.symbolInfo?n:this._effectiveFetchBarNs(t,this._activeBarNs(t.symbolInfo.symbol))}_syncShared(){let t=this._states.get(this.activeSymbol)?.master;t&&(this.sharedData.dataLevel=t.dataLevel,this.sharedData.compactBuf=t.compactBuf,this.sharedData.trades=t.trades,this.sharedData.priceHistory=t.priceHistory,this.sharedData.footprintBars=t.footprintBars,this.sharedData.ohlcvBars=t.ohlcvBars,this.sharedData.barNs=t.barNs,this.sharedData.dataStart=t.dataStart,this.sharedData.dataEnd=t.dataEnd,this.sharedData.supplemental=t.supplemental??null)}_subscribeToEventBus(){this.unsubs.push(this.eventBus.on("data:request-forward",t=>{this._fetchForward(this._targetSymbol(t?.symbol))}),this.eventBus.on("data:request-backward",({viewMin:t,symbol:n})=>{this._fetchBackward(this._targetSymbol(n),t)}),this.eventBus.on("data:rehydrate",()=>this.rehydrate()),this.eventBus.on("data:pane-resolution",({id:t,symbol:n,barNs:r})=>this._onPaneResolution(t,n,r)),this.eventBus.on("data:rebuild-footprint",({barNs:t,fpOptions:n})=>this.rebuildFootprint(t,n)),this.eventBus.on("data:prefetch",({spanNs:t,symbol:n})=>{if(n&&this._states.has(n)){this._fetchForward(n,t);return}for(let[r,o]of this._states)o.symbolInfo&&this._fetchForward(r,t)}),this.eventBus.on("data:seek-load",({tNs:t,fromNs:n})=>{this.seekLoad(t,n)}),this.eventBus.on("chart:set-symbol",({symbol:t})=>{t&&t!==this.activeSymbol&&this._applySymbol(t)}),this.eventBus.on("data:search-symbols",({requestId:t,request:n})=>{this._searchSymbols(t,n)}),this.eventBus.on("data:search-symbols-cancel",({requestId:t})=>{this.latestSymbolSearchId===t&&this._cancelSymbolSearch()}),this.eventBus.on("data:request-symbol-resolved",({symbol:t})=>{let n=this.resolvedSymbols.get(t);if(n){this.eventBus.emit("data:symbol-resolved",{symbolInfo:n});return}this.config.plugins?.resolve(t).then(r=>{r&&!this.destroyed&&this.eventBus.emit("data:symbol-resolved",{symbolInfo:r})})}),this.eventBus.on("timeframe:change",({tf:t})=>this._onTimeframeChange(t.barNs)))}async _runLoadIngest(t){if(t.dataLevel==="ohlcv")return{};let n=kS(t.trades),r=TS(t.priceHistory),o=await LS({tradesBuf:n,phBuf:r,barNs:t.barNs});return{ingestOhlcvBuf:o.ohlcvBuf,ingestBucketedPhBuf:o.bucketedPhBuf,ingestTradesBuf:o.tradesBuf,ingestPhBuf:o.phBuf}}_buildPayload(t){return{dataLevel:t.dataLevel,compactBuf:t.compactBuf,trades:t.trades,priceHistory:t.priceHistory,footprintBars:t.footprintBars,ohlcvBars:t.ohlcvBars,barNs:t.barNs,dataStart:t.dataStart,dataEnd:t.dataEnd,supplemental:t.supplemental??null}}async _emitLoad(t,n=!1){let r=t.master;if(!r)return;let o=await this._runLoadIngest(r);this.eventBus.emit("data:load",{symbol:r.symbolInfo.symbol,...this._buildPayload(r),session:t.session,playFromIso:this.horizonIso,rehydrate:n,...o})}async _emitAppend(t,n){let r=t.master;if(!r)return;let o=await this._runLoadIngest(r);this.eventBus.emit("data:append",{symbol:r.symbolInfo.symbol,...this._buildPayload(r),ohlcvBars:"ohlcvBars"in n?n.ohlcvBars:r.ohlcvBars,session:t.session,...o})}async _emitPrepend(t,n,r){let o=t.master;if(!o)return;let a=await this._runLoadIngest(o);this.eventBus.emit("data:prepend",{symbol:o.symbolInfo.symbol,dataLevel:o.dataLevel,compactBuf:o.compactBuf,trades:o.trades,priceHistory:o.priceHistory,footprintBars:o.footprintBars,ohlcvBars:"ohlcvBars"in n?n.ohlcvBars:[],barNs:o.barNs,dataStart:o.dataStart,viewMin:r,session:t.session,...a})}_emitAdapterError(t,n,r){let o=n instanceof Qu||n instanceof Error?n.message:String(n);this.eventBus.emit("data:status",{status:"error",error:{code:t,message:o},symbol:r})}_onTimeframeChange(t){for(let n of this._states.values()){if(!n.symbolInfo?.supportedResolutions?.length)continue;let r=this._effectiveFetchBarNs(n,UB(t,this._activeBarNs(n.symbolInfo.symbol))),o=n.segments.filter(a=>a.fetchBarNs>r);for(let a of o)this._refineSegment(n,a,r)}}_refineSegment(t,n,r){if(this.destroyed||!t.symbolInfo)return;let o=this._adapterFor(t.symbolInfo.symbol);if(!o)return;let a=`${n.from}:${n.to}`;t.refiningSegments.has(a)||(t.refiningSegments.add(a),o.fetchBars({symbolInfo:t.symbolInfo,range:Rs(n.from,n.to),timeframe:kb(r),direction:"initial"}).then(i=>{if(this.destroyed)return;let s=t.segments.findIndex(c=>c.from===n.from&&c.to===n.to);s!==-1&&(t.segments[s].fetchBarNs=r);let l=i.ohlcvBars??[];if(l.length!==0){if(t.master?.dataLevel==="ohlcv"){let c=Number(n.from/1000000n),u=Number(n.to/1000000n),d=t.master.ohlcvBars.filter(m=>{let f=new Date(m.time).getTime();return f<c||f>u});t.master.ohlcvBars=[...d,...l].sort((m,f)=>new Date(m.time).getTime()-new Date(f.time).getTime()),this._syncShared()}this.eventBus.emit("data:refine",{symbol:t.symbolInfo.symbol,dataLevel:t.master?.dataLevel??this.sharedData.dataLevel,ohlcvBars:l,barNs:r,from:Rb(n.from),to:Rb(n.to)})}}).catch(i=>{console.error("[DataEngine] segment refinement failed",i)}).finally(()=>{t.refiningSegments.delete(a)}))}_openWindows(t,n,r){return t.session?Mb(t.session,n,r):[{from:n,to:r}]}};var GS="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var pn=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=GS[n[e]&63];return t};var Vo={name:"cursor",id:"",state:{}},Pb=[{id:"fib-0",value:"0",color:"#FFFFFF",enabled:!0},{id:"fib-236",value:"0.236",color:"#FFFFFF",enabled:!0},{id:"fib-382",value:"0.382",color:"#FFFFFF",enabled:!0},{id:"fib-500",value:"0.5",color:"#FFFFFF",enabled:!0},{id:"fib-618",value:"0.618",color:"#FFFFFF",enabled:!0},{id:"fib-786",value:"0.786",color:"#FFFFFF",enabled:!0},{id:"fib-1",value:"1",color:"#FFFFFF",enabled:!0},{id:"fib-2",value:"2",color:"#FFFFFF",enabled:!0},{id:"fib-3",value:"3",color:"#FFFFFF",enabled:!0},{id:"fib-4",value:"4",color:"#FFFFFF",enabled:!0},{id:"fib-5",value:"5",color:"#FFFFFF",enabled:!0}],Sl=[{id:"ch-base",value:0,color:"#e0e0e0",lineWidth:1,dash:[],enabled:!0},{id:"ch-mid",value:.5,color:"#e0e0e0",lineWidth:1,dash:[4,4],enabled:!0},{id:"ch-far",value:1,color:"#e0e0e0",lineWidth:1,dash:[],enabled:!0}];function Yi(e){switch(e){case"hline":return{color:"#e0e0e0",lineWidth:1,dash:[]};case"vline":return{color:"#888888",lineWidth:1,dash:[4,3]};case"extended-line":return{color:"#e0e0e0",lineWidth:1,dash:[],extendRight:!0,extendLeft:!0};case"line":return{color:"#e0e0e0",lineWidth:1,dash:[],extendLeft:!1,extendRight:!1};case"cross-line":return{color:"#e0e0e0",lineWidth:1,dash:[]};case"info-line":return{color:"#e0e0e0",lineWidth:1,dash:[]};case"trend-angle":return{color:"#e0e0e0",lineWidth:1,dash:[]};case"ray":return{color:"#e0e0e0",lineWidth:1,dash:[]};case"hray":return{color:"#e0e0e0",lineWidth:1,dash:[]};case"parallel-channel":return{color:"#e0e0e0",lineWidth:1,dash:[],extendLeft:!1,extendRight:!1,levels:Sl,enableBackground:!1,backgroundColor:"#e0e0e01a"};case"rect":return{color:"#3b82f6",borderColor:"#3b82f6",borderLineWidth:1,borderDash:[],fillColor:"#3b82f61a",fillOpacity:.08};case"triangle":return{color:"#3b82f6",borderColor:"#3b82f6",borderLineWidth:1,borderDash:[],fillColor:"#3b82f61a",fillOpacity:.08};case"fib":return{color:"#facc15",levels:Pb,extendLeft:!1,extendRight:!1,showPrices:!0,showLevels:!0,backgroundColor:"#ffffff1a",enableBackground:!0,lineWidth:1};case"text":return{color:"#e0e0e0",fontSize:12};case"fvp":return{profileMode:"stacked",barsWidth:32,barOpacity:60,enableBuyColor:!0,buyColor:"#00e676",enableSellColor:!0,sellColor:"#ff1744",totalColor:"#5b9cf6",deltaNegColor:"#ff1744",showVolNumbers:!1,volNumbersFontSize:9,showPoc:!0,pocColor:"#facc15",showPocLabel:!0,pocExtendLeft:!1,pocExtendRight:!1,highlightPocBar:!0,pocBarLineWidth:1,showValueArea:!0,valueAreaPct:70,valueAreaFillColor:"#ffffff1a",showVaHLines:!0,vaLineColor:"#888888",vaLineExtendLeft:!1,vaLineExtendRight:!1,vaBarDimming:!0,vaOutsideDimFrac:.35,showDevPoc:!1,devPocColor:"#facc15",showDevVa:!1,devVaColor:"#888888",enableBg:!1,bgColor:"#00000026",enableBorder:!1,borderColor:"#6490c8",borderDash:[],labelPills:!0,splitCenterLine:!0,barGap:!0};case"long":case"short":{let t="#08998133",n="#f2364533";return{upColor:e==="long"?t:n,downColor:e==="long"?n:t,entryColor:"#efefef",extendLeft:!1,extendRight:!1,upAmount:10,downAmount:5,qty:1,drawInfo:!0,fontSize:11,textColor:"#ffffff"}}default:return{}}}function ad(e,t){return{name:e,id:pn(),state:{...Yi(e),...t}}}function YS(e){return{name:e.tool,id:e.id,state:e}}var KS=7;function Oc(){let e=qr(Cn.drawingTemplates,null);return Array.isArray(e)?e:[]}function $S(e){let t=Oc().filter(n=>n.id!==e.id);t.push(e),kr(Cn.drawingTemplates,t)}function XS(e){kr(Cn.drawingTemplates,Oc().filter(t=>t.id!==e))}import eU,{useCallback as sa,useEffect as lr,useMemo as tU,useRef as Jn,useState as Hr}from"react";import{useCallback as Xv,useEffect as tr,useImperativeHandle as sW,useRef as Ke,useState as Bo,forwardRef as lW}from"react";var yp=10000000n,vp=86400000000000n;var Qt={bullBody:"#00e676",bearBody:"#ff1744",bullWick:"rgba(0,230,118,0.50)",bearWick:"rgba(255,23,68,0.50)",cellBg:"rgba(42,45,55,0.85)",askFill:e=>`rgba(0,200,100,${e.toFixed(2)})`,bidFill:e=>`rgba(220,30,60,${e.toFixed(2)})`,poc:"rgba(255,215,0,0.95)",stackBuy:"rgba(0,180,255,0.12)",stackBuyBorder:"rgba(0,200,255,0.55)",stackSell:"rgba(255,40,120,0.12)",stackSellBorder:"rgba(255,60,140,0.55)",absorption:"rgba(255,180,0,0.18)",absorptionBorder:"rgba(255,200,40,0.70)",unfTop:"rgba(0,200,255,0.85)",unfBottom:"rgba(255,80,140,0.85)",diagAsk:"rgba(0,230,200,0.65)",diagBid:"rgba(255,60,120,0.65)",textNormal:"rgba(210,210,220,0.90)",textDim:"rgba(120,120,130,0.50)",diagAskText:"#00e8c0",diagBidText:"#ff4488",askImbalText4x:"#00b4ff",askImbalText2x:"#66ffb2",bidImbalText4x:"#ff40c0",bidImbalText2x:"#cc88ff"};function JS(e,t,n,r,o,a,i,s=.25,l="split",c,u=0n,d){if(a===0n||t.length===0)return;let m=u>0n?u:n.tMax,f=Number(n.tMax-n.tMin),h=Number(a)/f*r,p=n.pMax-n.pMin,g=p>0?s/p*o:0,y=h>=44,v=h>=20,b=h>=36&&c.footprintShowDiagonalImbalance;e.save(),e.textBaseline="middle";let S=30,C=[1,2,4,8,16,32,64,128],w=1;for(let I of C)if(w=I,g*I>=S)break;let k=s*w,M=g*w;for(let I of t){if(I.ts>m)break;if(I.ts+a<n.tMin||I.ts>n.tMax)continue;let x=d.tsToX(I.ts,r),T=d.tsToX(I.ts+a,r),R=Math.max(2,Math.floor(h*.16)),P=R/2,N=x+P+15,O=T-Math.max(4,h*.2),A=Math.max(0,O-N),B=I.isBullish?c.upBodyColor:c.downBodyColor,E=I.isBullish?c.wickColorMatchesBody?B:c.upWickColor:c.wickColorMatchesBody?B:c.downWickColor,L=d.priceToY(I.open,o),z=d.priceToY(I.close,o),Y=d.priceToY(I.high,o),G=d.priceToY(I.low,o);I.high!==I.low&&(e.strokeStyle=E,e.lineWidth=1,e.beginPath(),e.moveTo(x,Y),e.lineTo(x,G),e.stroke());let H=Math.min(L,z),W=Math.max(2,Math.abs(z-L));if(e.fillStyle=B,e.fillRect(x-P,H,R,W),A<4)continue;let U=new Map;for(let xe of I.levels){let Ae=Math.floor(Math.round(xe.price/s)/w),Oe=U.get(Ae);Oe||(Oe={bid:0,ask:0,total:0,delta:0,poc:!1,absorption:!1,bidImbalance:!1,askImbalance:!1,diagAskImbalance:!1,diagBidImbalance:!1},U.set(Ae,Oe)),Oe.bid+=xe.bidVol,Oe.ask+=xe.askVol,Oe.total+=xe.totalVol,Oe.delta+=xe.delta,xe.price===I.poc&&(Oe.poc=!0),xe.absorption&&(Oe.absorption=!0),xe.bidImbalance&&(Oe.bidImbalance=!0),xe.askImbalance&&(Oe.askImbalance=!0),xe.diagAskImbalance&&(Oe.diagAskImbalance=!0),xe.diagBidImbalance&&(Oe.diagBidImbalance=!0)}let V=1;for(let xe of U.values())V=Math.max(V,xe.total);let K=Math.floor(Math.round(I.low/s)/w),Z=Math.floor(Math.round(I.high/s)/w);for(let xe=K;xe<=Z;xe++)U.has(xe)||U.set(xe,{bid:0,ask:0,total:0,delta:0,poc:!1,absorption:!1,bidImbalance:!1,askImbalance:!1,diagAskImbalance:!1,diagBidImbalance:!1});let de=y&&M>=9,ze=Math.max(9,Math.min(13,Math.floor(M*.45)));e.font=`${ze}px "JetBrains Mono", monospace`;for(let[xe,Ae]of U){let ke=xe*k+k/2,Q=d.priceToY(ke,o),Pe=Math.max(1,M-1),_=Q-Pe/2;switch(v&&c.footprintShowAbsorption&&Ae.absorption&&(e.fillStyle=Qt.absorption,e.fillRect(N-2,_-1,A+4,Pe+2),e.strokeStyle=Qt.absorptionBorder,e.lineWidth=1,e.setLineDash([3,2]),e.strokeRect(N-1.5,_-.5,A+3,Pe+1),e.setLineDash([])),i){case"bid-ask":YB(e,Ae,V,N,_,Pe,A,de,Q,ze,l,b);break;case"profile":KB(e,Ae,V,N,_,Pe,A,de,Q,ze);break;case"delta":$B(e,Ae,V,N,_,Pe,A,de,Q,ze);break;case"total":XB(e,Ae,V,N,_,Pe,A,de,Q,ze);break}Ae.poc&&Pe>=2&&(e.strokeStyle=Qt.poc,e.lineWidth=1.5,e.strokeRect(N+.5,_+.5,A-2,Pe-1))}if(v&&c.footprintShowStackedImbalance&&(ZS(e,I.stackedBuyZones,"buy",N,A,n,o,s,c,d),ZS(e,I.stackedSellZones,"sell",N,A,n,o,s,c,d)),v&&c.footprintShowUnfinishedAuction&&(I.unfinishedTop&&QS(e,"top",x,Y,h),I.unfinishedBottom&&QS(e,"bottom",x,G,h)),y&&h>=50){let xe=I.totalDelta>=0?"+":"";e.textAlign="center",e.font=`bold ${ze}px "JetBrains Mono", monospace`,e.fillStyle=I.totalDelta>=0?"rgba(0,230,118,0.85)":"rgba(255,23,68,0.85)",e.fillText(`${xe}${I.totalDelta}`,x,G+14),e.font=`${ze}px "JetBrains Mono", monospace`}if(v&&c.footprintShowDiagonalImbalance&&h>=60&&I.diagDominant!=="none"){let xe=I.diagDominant==="buy"?"\u2197 DIAG":"\u2198 DIAG";e.font='bold 9px "JetBrains Mono", monospace',e.textAlign="center",e.fillStyle=I.diagDominant==="buy"?Qt.diagAskText:Qt.diagBidText,e.fillText(xe,x,Y-6),e.font=`${ze}px "JetBrains Mono", monospace`}}e.restore()}function YB(e,t,n,r,o,a,i,s,l,c,u,d){let m=i/2,f=1,h=Qt.textNormal,p=Qt.textNormal;if(t.ask>0&&t.bid>0){let g=t.ask/t.bid;g>=4?h=Qt.askImbalText4x:g>=2&&(h=Qt.askImbalText2x);let y=t.bid/t.ask;y>=4?p=Qt.bidImbalText4x:y>=2&&(p=Qt.bidImbalText2x)}else t.ask>0&&t.bid===0?h=Qt.askImbalText4x:t.bid>0&&t.ask===0&&(p=Qt.bidImbalText4x);if(d&&(t.diagAskImbalance&&(h=Qt.diagAskText),t.diagBidImbalance&&(p=Qt.diagBidText)),u==="none"){let g=t.delta,y=Math.abs(g),v=n>0?Math.min(1,y/n):0,b,S;g>0?(S=Qt.askFill(.2+.35*v),b=Qt.cellBg):g<0?(b=Qt.bidFill(.2+.35*v),S=Qt.cellBg):b=S=Qt.cellBg,e.fillStyle=b,e.fillRect(r,o,m-f,a),e.fillStyle=S,e.fillRect(r+m,o,m-1,a)}else if(u==="split"){e.fillStyle=Qt.cellBg,e.fillRect(r,o,m-f,a),e.fillRect(r+m,o,m-1,a);let g=Math.min(1,t.bid/n),y=Math.min(1,t.ask/n);g>0&&(e.fillStyle=Qt.bidFill(.45),e.fillRect(r,o,g*(m-f),a)),y>0&&(e.fillStyle=Qt.askFill(.45),e.fillRect(r+m,o,y*(m-1),a))}else{let g=Math.min(1,t.total/n);e.fillStyle=Qt.cellBg,e.fillRect(r,o,m-f,a),e.fillRect(r+m,o,m-1,a);let y=g*i,v=t.total>0?t.bid/t.total:.5,b=y*v,S=y*(1-v);b>0&&(e.fillStyle=Qt.bidFill(.45),e.fillRect(r,o,b,a)),S>0&&(e.fillStyle=Qt.askFill(.45),e.fillRect(r+b,o,S,a))}if(d){if(t.diagAskImbalance&&a>=4){let g=r+m+2,y=r+i-3,v=o+a-2,b=o+2;e.strokeStyle=Qt.diagAsk,e.lineWidth=1.5,e.beginPath(),e.moveTo(g,v),e.lineTo(y,b),e.stroke()}if(t.diagBidImbalance&&a>=4){let g=r+2,y=r+m-f-3,v=o+2,b=o+a-2;e.strokeStyle=Qt.diagBid,e.lineWidth=1.5,e.beginPath(),e.moveTo(g,v),e.lineTo(y,b),e.stroke()}}s&&(e.textAlign="right",e.font=p===Qt.bidImbalText4x||p===Qt.diagBidText?`bold ${c}px "JetBrains Mono", monospace`:`${c}px "JetBrains Mono", monospace`,e.fillStyle=t.bid===0?Qt.textDim:p,e.fillText(String(t.bid),r+m-f-2,l),e.textAlign="left",e.font=h===Qt.askImbalText4x||h===Qt.diagAskText?`bold ${c}px "JetBrains Mono", monospace`:`${c}px "JetBrains Mono", monospace`,e.fillStyle=t.ask===0?Qt.textDim:h,e.fillText(String(t.ask),r+m+2,l),e.font=`${c}px "JetBrains Mono", monospace`)}function KB(e,t,n,r,o,a,i,s,l,c){let d=Math.min(1,t.total/n)*i;e.fillStyle=t.ask>=t.bid?Qt.askFill(.65):Qt.bidFill(.65),e.fillRect(r,o,d,a),s&&(e.fillStyle=Qt.textNormal,e.textAlign="left",e.fillText(`${t.bid}\xD7${t.ask}`,r+2,l))}function $B(e,t,n,r,o,a,i,s,l,c){let u=Math.abs(t.delta),d=n>0?Math.min(1,u/n):0,m=d*i,f=t.delta>=0;if(e.fillStyle=f?`rgba(0,${Math.round(140+90*d)},${Math.round(80*d)},${.45+.45*d})`:`rgba(${Math.round(140+115*d)},0,${Math.round(40*d)},${.45+.45*d})`,e.fillRect(r,o,m,a),s){let h=t.delta>=0?"+":"";e.fillStyle=Qt.textNormal,e.textAlign="left",e.fillText(`${h}${t.delta}`,r+2,l)}}function XB(e,t,n,r,o,a,i,s,l,c){let d=Math.min(1,t.total/n)*i;e.fillStyle="rgba(160,160,180,0.50)",e.fillRect(r,o,d,a),s&&(e.fillStyle=Qt.textNormal,e.textAlign="left",e.fillText(String(t.total),r+2,l))}function ZS(e,t,n,r,o,a,i,s,l,c){if(t.length===0)return;let u=n==="buy"?Qt.stackBuy:Qt.stackSell,d=n==="buy"?Qt.stackBuyBorder:Qt.stackSellBorder;for(let m of t){let f=c.priceToY(m.high+s,i),h=c.priceToY(m.low-s,i),p=Math.max(2,h-f);e.fillStyle=u,e.fillRect(r,f,o,p),e.strokeStyle=d,e.lineWidth=1.5,e.setLineDash([4,3]),e.strokeRect(r+.5,f+.5,o-1,p-1),e.setLineDash([]),e.font='bold 8px "JetBrains Mono", monospace',e.textAlign="right",e.fillStyle=d,e.fillText(n==="buy"?"\u25B2SI":"\u25BCSI",r+o-2,f+p/2)}}function QS(e,t,n,r,o){let a=Math.min(8,o*.15),i=10;e.save(),e.strokeStyle=t==="top"?Qt.unfTop:Qt.unfBottom,e.fillStyle=t==="top"?Qt.unfTop:Qt.unfBottom,e.lineWidth=1.5,e.setLineDash([3,2]),e.beginPath(),e.moveTo(n-a*2,r),e.lineTo(n+a*2,r),e.stroke(),e.setLineDash([]);let s=t==="top"?-1:1,l=r+s*i;e.beginPath(),e.moveTo(n,l),e.lineTo(n-a*.7,l-s*a),e.lineTo(n+a*.7,l-s*a),e.closePath(),e.fill(),o>=40&&(e.font='bold 8px "JetBrains Mono", monospace',e.textAlign="center",e.fillText("UA",n,l+s*(a+8))),e.restore()}function Rr(e,t){let n=t?.priceFormat?.minTick??.01,r=Math.round(e*(1/n))/(1/n),o=t?.priceFormat?.precision??2;return r.toFixed(o)}var ZB=.25;function ro(e){return e?.priceFormat?.minTick??e?.tickSize??ZB}function QB(e,t){let n=e.replace("#",""),r=n.length===3?n.split("").map(i=>i+i).join(""):n,o=i=>parseInt(r.slice(i,i+2),16),a=i=>Math.round(i*(1-t)+25*t);return`rgb(${a(o(0))}, ${a(o(2))}, ${a(o(4))})`}function Cl(e,t,n,r,o,a,i,s){let l=i??a,c=s??a,u=s??a,d=i??a;e.beginPath(),e.moveTo(t+l,n),e.lineTo(t+r-c,n),e.quadraticCurveTo(t+r,n,t+r,n+c),e.lineTo(t+r,n+o-u),e.quadraticCurveTo(t+r,n+o,t+r-u,n+o),e.lineTo(t+d,n+o),e.quadraticCurveTo(t,n+o,t,n+o-d),e.lineTo(t,n+l),e.quadraticCurveTo(t,n,t+l,n),e.closePath()}var JB="#00e676",eN="#ff1744",e1=22,t1=10,tN=4;function n1(e,t,n,r,o,a,i,s,l,c,u,d){let m=a==="tp"?JB:eN,f=a==="tp"?"TP":"SL",h=u.priceToY(o,n)+i,p=u.priceToY(r,n)+i;if(h<-40||h>n+40)return;let g=Math.min(h,p),y=Math.max(h,p),v=y-g;e.save(),e.globalAlpha=.02,e.fillStyle=m,e.fillRect(0,g,t,v),e.restore(),e.save();let b=e.createLinearGradient(0,g,0,y);b.addColorStop(0,r1(m,a==="tp"?0:.08)),b.addColorStop(1,r1(m,a==="tp"?.08:0)),e.globalAlpha=1,e.fillStyle=b,e.fillRect(0,g,t,v),e.restore(),e.save(),e.strokeStyle=m,e.lineWidth=1.5,e.globalAlpha=.9,e.setLineDash([4,4]),e.lineCap="round",e.beginPath(),e.moveTo(0,h),e.lineTo(t,h),e.stroke(),e.setLineDash([]),e.restore();let S=t-32;e.save(),e.strokeStyle=m,e.lineWidth=1,e.globalAlpha=.5,e.setLineDash([3,4]),e.beginPath(),e.moveTo(S,p),e.lineTo(S,h-(h>p?15:-15)),e.stroke(),e.setLineDash([]);let C=h<p?1:-1;e.globalAlpha=.75,e.beginPath(),e.moveTo(S,h-(h>p?15:-15)),e.lineTo(S-5,h-(h>p?15:-15)+C*8),e.lineTo(S+5,h-(h>p?15:-15)+C*8),e.closePath(),e.fillStyle=m,e.fill(),e.restore(),e.save(),e.font='600 11px "Inter", system-ui, sans-serif';let w=Rr(o,d),k=Math.abs(o-r),M=c&&c>0?`${Math.round(k/c)} ticks`:null,I=(k/r*100).toFixed(2)+"%",T=`${f} ${w} (${M??I})`,P=e.measureText(T).width+t1*2,D=t-P-4,N=h-e1/2;e.shadowColor="rgba(0,0,0,0.55)",e.shadowBlur=8,e.shadowOffsetY=2,Cl(e,D,N,P,e1,tN),e.fillStyle=m,e.fill(),e.shadowBlur=0,e.shadowOffsetY=0,e.fillStyle="#000000",e.globalAlpha=.85,e.textBaseline="middle",e.textAlign="left",e.fillText(T,D+t1,h),e.restore(),e.save(),e.strokeStyle=m,e.lineWidth=8,e.globalAlpha=.06,e.beginPath(),e.moveTo(0,h),e.lineTo(t,h),e.stroke(),e.restore()}function o1(e,t,n,r,o,a,i,s,l=0,c,u,d,m,f,h=0,p,g){let y=d.getGhostState(),v=s??o,b={lines:[],pricePills:[],ghostPills:[]},S=!1;if(i.length===0)return{hitMap:b,suspendCrosshair:S};let C=i.filter(k=>k.visible!==!1);if(e.fontKerning="none",y)for(let k of C){if(!k.ghosts)continue;let M=y[k.id??""];if(M&&M?.draggingGhost){if(M.draggingGhostType==="tp"){let I=M.tpPrices[M.draggingGhostIdx];if(I==null)continue;n1(e,r,v,k.price,I,"tp",l,n,a,m,f,p)}if(M.draggingGhostType==="sl"){let I=M.slPrices[M.draggingGhostIdx];if(I==null)continue;n1(e,r,v,k.price,I,"sl",l,n,a,m,f,p)}}}let w=k=>{let M=!!k.preview,I=Se=>M?QB(Se,.45):Se,x=I("#09e293"),T=I("#e8146c"),R=I("#008aff"),P=70,D=k.kind==="limit"||k.kind==="stop"||k.kind==="stop_limit",N=k.kind==="entry",O=N||D,A=O?R:k.kind==="tp"?x:T,B=f.priceToY(k.price,v)+l;if(B>=v||N&&!k?.pnl)return;let E=18,L=B,z=7,Y=7,G=7,H=N?k.pnl>=0?`+${k.pnl.toFixed(2)}${k?.pnl?" USD":""}`:`${k.pnl.toFixed(2)}${k?.pnl?" USD":""}`:D?k.label??"":`${String(k.label).replace("TP ","").replace("SL ","")}${k?.pnl?" USD":""}`,W=N?k.pnl:D?0:Number(String(k.label).replace("TP ","").replace("SL ","").replace("+$","").replace("-$","-")),U=String(k.qty),V=e.measureText(U).width,K=e.measureText(H).width,Z=z+V+z,de=z+K+z,ze=z+Y+z,xe=Z+de+ze,Ae=r-xe-P,Oe=L-E/2,ke=L+E/2,Q=Ae+xe,Pe=Ae+Z,_=Pe+de,ie=_+z,se=A;if(e.save(),e.setLineDash([]),e.lineWidth=1,e.beginPath(),e.lineCap=M?"round":"butt",e.setLineDash(M?[1,3]:k.lineDash??[]),e.strokeStyle=se,e.moveTo(0,B),e.lineTo(r,B),e.stroke(),e.setLineDash([]),e.lineCap="butt",g.y>=Oe+5&&g.y<=ke-5&&(S=!0),e.beginPath(),Cl(e,Ae,Oe,xe,E,4,4,4),e.fillStyle="#191919",e.fill(),e.strokeStyle=se,e.stroke(),O?(e.beginPath(),Cl(e,Ae,Oe,Z,E,4,4,0),e.fillStyle=se,e.fill()):(k.kind==="tp"||k.kind==="sl")&&(e.beginPath(),e.strokeStyle=se,e.moveTo(Ae+Z,L-E/2),e.lineTo(Ae+Z,L+E/2),e.stroke()),e.fillStyle=O?"#ffffff":k.kind==="tp"?x:T,e.fillText(U,Ae+z,L+1.5),e.fillStyle=W>0?x:W===0?"#b2b2b2":T,e.fillText(H,Pe+z,L+1),k.locked||(e.beginPath(),e.strokeStyle=se,e.moveTo(_,ke),e.lineTo(_,Oe),e.stroke(),g&&g.x>=_&&g.x<=Q&&g.y>=Oe&&g.y<=ke&&(S=!0,Cl(e,_+1,Oe+1,Q-_-1,E-1,0,0,4),e.fillStyle="#ffffff15",e.fill()),e.beginPath(),e.strokeStyle=se,e.moveTo(ie,L+G/2),e.lineTo(ie+Y,L-G/2),e.moveTo(ie,L-G/2),e.lineTo(ie+Y,L+G/2),e.stroke(),b.lines.push({id:k.id,y:L,top:Oe+5,bottom:ke-5,pill:{x:Ae,y:L-E/2,w:xe,h:E},closeBtn:{x:_,y:L-E/2,w:Ae+xe-_,h:E}})),e.beginPath(),Cl(e,r,B-E/2,h,E,4),e.fillStyle=k.kind==="tp"?x:k.kind==="sl"?T:R,e.fill(),e.fillStyle="#ffffff",e.fillText(Rr(k.price,p),r+7,B),k.locked||b.pricePills.push({id:k.id,x:r,y:B-E/2,w:h,h:E}),k.ghosts&&!k.locked&&!M){let Re=Ae-81,ye=Ae-30*1.5;e.beginPath(),e.setLineDash([2,2]),Cl(e,Re,Oe,30,E,4,4,4),e.fillStyle="#191919",e.fill(),e.strokeStyle=x,e.stroke(),e.fillStyle=x;let $e=e.measureText("TP").width;e.fillText("TP",Re+30/2-$e/2,L+1),e.beginPath(),e.setLineDash([2,2]),Cl(e,ye,Oe,30,E,4,4,4),e.fillStyle="#191919",e.fill(),e.strokeStyle=T,e.stroke(),e.fillStyle=T;let Ue=e.measureText("SL").width;e.fillText("SL",ye+30/2-Ue/2,L+1),b.ghostPills.push({lineId:k.id,ghostId:"tp_1",index:1,kind:"tp",x:Re,y:Oe,w:30,h:E,currentPrice:k.price}),b.ghostPills.push({lineId:k.id,ghostId:"sl_1",index:1,kind:"sl",x:ye,y:Oe,w:30,h:E,currentPrice:k.price})}e.restore()};for(let k of C)w(k);return{hitMap:b,suspendCrosshair:S}}function _c(e,t,n){for(let r of n.ghostPills)if(e>=r.x&&e<=r.x+r.w&&t>=r.y&&t<=r.y+r.h)return{lineId:r.lineId,part:null,ghostHit:r};for(let r of n.lines){if(r.closeBtn){let o=r.closeBtn;if(e>=o.x&&e<=o.x+o.w&&t>=o.y&&t<=o.y+o.h)return{lineId:r.id,part:"close"}}if(r.reverseBtn){let o=r.reverseBtn;if(e>=o.x&&e<=o.x+o.w&&t>=o.y&&t<=o.y+o.h)return{lineId:r.id,part:"reverse"}}}for(let r of n.lines)if(r.pill){let o=r.pill;if(e>=o.x&&e<=o.x+o.w&&t>=o.y&&t<=o.y+o.h)return{lineId:r.id,part:"pill"}}for(let r of n.pricePills)if(e>=r.x&&e<=r.x+r.w&&t>=r.y&&t<=r.y+r.h)return{lineId:r.id??null,part:"pricePill"};for(let r of n.lines)if(t>=r.top&&t<=r.bottom)return{lineId:r.id,part:"line"};return{lineId:null,part:null}}function r1(e,t){if(e.startsWith("rgba"))return e.replace(/[\d.]+\)$/,`${t})`);if(e.startsWith("rgb("))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);let n=e.replace("#","");n.length===3&&(n=n.split("").map(i=>i+i).join(""));let r=parseInt(n.substring(0,2),16),o=parseInt(n.substring(2,4),16),a=parseInt(n.substring(4,6),16);return`rgba(${r},${o},${a},${t})`}var $i=class extends Error{},Hb=class extends $i{constructor(t){super(`Invalid DateTime: ${t.toMessage()}`)}},Vb=class extends $i{constructor(t){super(`Invalid Interval: ${t.toMessage()}`)}},Wb=class extends $i{constructor(t){super(`Invalid Duration: ${t.toMessage()}`)}},Bs=class extends $i{},Mp=class extends $i{constructor(t){super(`Invalid unit ${t}`)}},oo=class extends $i{},Di=class extends $i{constructor(){super("Zone is an abstract class")}},st="numeric",ni="short",pa="long",Lp={year:st,month:st,day:st},E1={year:st,month:ni,day:st},nN={year:st,month:ni,day:st,weekday:ni},O1={year:st,month:pa,day:st},_1={year:st,month:pa,day:st,weekday:pa},F1={hour:st,minute:st},z1={hour:st,minute:st,second:st},H1={hour:st,minute:st,second:st,timeZoneName:ni},V1={hour:st,minute:st,second:st,timeZoneName:pa},W1={hour:st,minute:st,hourCycle:"h23"},q1={hour:st,minute:st,second:st,hourCycle:"h23"},U1={hour:st,minute:st,second:st,hourCycle:"h23",timeZoneName:ni},j1={hour:st,minute:st,second:st,hourCycle:"h23",timeZoneName:pa},G1={year:st,month:st,day:st,hour:st,minute:st},Y1={year:st,month:st,day:st,hour:st,minute:st,second:st},K1={year:st,month:ni,day:st,hour:st,minute:st},$1={year:st,month:ni,day:st,hour:st,minute:st,second:st},rN={year:st,month:ni,day:st,weekday:ni,hour:st,minute:st},X1={year:st,month:pa,day:st,hour:st,minute:st,timeZoneName:ni},Z1={year:st,month:pa,day:st,hour:st,minute:st,second:st,timeZoneName:ni},Q1={year:st,month:pa,day:st,weekday:pa,hour:st,minute:st,timeZoneName:pa},J1={year:st,month:pa,day:st,weekday:pa,hour:st,minute:st,second:st,timeZoneName:pa},Ml=class{get type(){throw new Di}get name(){throw new Di}get ianaName(){return this.name}get isUniversal(){throw new Di}offsetName(t,n){throw new Di}formatOffset(t,n){throw new Di}offset(t){throw new Di}equals(t){throw new Di}get isValid(){throw new Di}},Db=null,Rp=class e extends Ml{static get instance(){return Db===null&&(Db=new e),Db}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return uC(t,n,r)}formatOffset(t,n){return ud(this.offset(t),n)}offset(t){return-new Date(t).getTimezoneOffset()}equals(t){return t.type==="system"}get isValid(){return!0}},qb=new Map;function oN(e){let t=qb.get(e);return t===void 0&&(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),qb.set(e,t)),t}var aN={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function iN(e,t){let n=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,o,a,i,s,l,c,u]=r;return[i,o,a,s,l,c,u]}function sN(e,t){let n=e.formatToParts(t),r=[];for(let o=0;o<n.length;o++){let{type:a,value:i}=n[o],s=aN[a];a==="era"?r[s]=i:Jt(s)||(r[s]=parseInt(i,10))}return r}var Ab=new Map,Es=class e extends Ml{static create(t){let n=Ab.get(t);return n===void 0&&Ab.set(t,n=new e(t)),n}static resetCache(){Ab.clear(),qb.clear()}static isValidSpecifier(t){return this.isValidZone(t)}static isValidZone(t){if(!t)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:t}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=e.isValidZone(t)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return uC(t,n,r,this.name)}formatOffset(t,n){return ud(this.offset(t),n)}offset(t){if(!this.valid)return NaN;let n=new Date(t);if(isNaN(n))return NaN;let r=oN(this.name),[o,a,i,s,l,c,u]=r.formatToParts?sN(r,n):iN(r,n);s==="BC"&&(o=-Math.abs(o)+1);let m=Ep({year:o,month:a,day:i,hour:l===24?0:l,minute:c,second:u,millisecond:0}),f=+n,h=f%1e3;return f-=h>=0?h:1e3+h,(m-f)/(60*1e3)}equals(t){return t.type==="iana"&&t.name===this.name}get isValid(){return this.valid}},a1={};function lN(e,t={}){let n=JSON.stringify([e,t]),r=a1[n];return r||(r=new Intl.ListFormat(e,t),a1[n]=r),r}var Ub=new Map;function jb(e,t={}){let n=JSON.stringify([e,t]),r=Ub.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),Ub.set(n,r)),r}var Gb=new Map;function cN(e,t={}){let n=JSON.stringify([e,t]),r=Gb.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),Gb.set(n,r)),r}var Yb=new Map;function uN(e,t={}){let{base:n,...r}=t,o=JSON.stringify([e,r]),a=Yb.get(o);return a===void 0&&(a=new Intl.RelativeTimeFormat(e,t),Yb.set(o,a)),a}var sd=null;function dN(){return sd||(sd=new Intl.DateTimeFormat().resolvedOptions().locale,sd)}var Kb=new Map;function eC(e){let t=Kb.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),Kb.set(e,t)),t}var $b=new Map;function fN(e){let t=$b.get(e);if(!t){let n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in t||(t={...tC,...t}),$b.set(e,t)}return t}function mN(e){let t=e.indexOf("-x-");t!==-1&&(e=e.substring(0,t));let n=e.indexOf("-u-");if(n===-1)return[e];{let r,o;try{r=jb(e).resolvedOptions(),o=e}catch{let l=e.substring(0,n);r=jb(l).resolvedOptions(),o=l}let{numberingSystem:a,calendar:i}=r;return[o,a,i]}}function pN(e,t,n){return(n||t)&&(e.includes("-u-")||(e+="-u"),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`)),e}function hN(e){let t=[];for(let n=1;n<=12;n++){let r=Xn.utc(2009,n,1);t.push(e(r))}return t}function gN(e){let t=[];for(let n=1;n<=7;n++){let r=Xn.utc(2016,11,13+n);t.push(e(r))}return t}function wp(e,t,n,r){let o=e.listingMode();return o==="error"?null:o==="en"?n(t):r(t)}function bN(e){return e.numberingSystem&&e.numberingSystem!=="latn"?!1:e.numberingSystem==="latn"||!e.locale||e.locale.startsWith("en")||eC(e.locale).numberingSystem==="latn"}var Xb=class{constructor(t,n,r){this.padTo=r.padTo||0,this.floor=r.floor||!1;let{padTo:o,floor:a,...i}=r;if(!n||Object.keys(i).length>0){let s={useGrouping:!1,...r};r.padTo>0&&(s.minimumIntegerDigits=r.padTo),this.inf=cN(t,s)}}format(t){if(this.inf){let n=this.floor?Math.floor(t):t;return this.inf.format(n)}else{let n=this.floor?Math.floor(t):ly(t,3);return Ur(n,this.padTo)}}},Zb=class{constructor(t,n,r){this.opts=r,this.originalZone=void 0;let o;if(this.opts.timeZone)this.dt=t;else if(t.zone.type==="fixed"){let i=-1*(t.offset/60),s=i>=0?`Etc/GMT+${i}`:`Etc/GMT${i}`;t.offset!==0&&Es.create(s).valid?(o=s,this.dt=t):(o="UTC",this.dt=t.offset===0?t:t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone)}else t.zone.type==="system"?this.dt=t:t.zone.type==="iana"?(this.dt=t,o=t.zone.name):(o="UTC",this.dt=t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone);let a={...this.opts};a.timeZone=a.timeZone||o,this.dtf=jb(n,a)}format(){return this.originalZone?this.formatToParts().map(({value:t})=>t).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){let t=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?t.map(n=>{if(n.type==="timeZoneName"){let r=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...n,value:r}}else return n}):t}resolvedOptions(){return this.dtf.resolvedOptions()}},Qb=class{constructor(t,n,r){this.opts={style:"long",...r},!n&&lC()&&(this.rtf=uN(t,r))}format(t,n){return this.rtf?this.rtf.format(t,n):FN(n,t,this.opts.numeric,this.opts.style!=="long")}formatToParts(t,n){return this.rtf?this.rtf.formatToParts(t,n):[]}},tC={firstDay:1,minimalDays:4,weekend:[6,7]},mr=class e{static fromOpts(t){return e.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,n,r,o,a=!1){let i=t||Tr.defaultLocale,s=i||(a?"en-US":dN()),l=n||Tr.defaultNumberingSystem,c=r||Tr.defaultOutputCalendar,u=ty(o)||Tr.defaultWeekSettings;return new e(s,l,c,u,i)}static resetCache(){sd=null,Ub.clear(),Gb.clear(),Yb.clear(),Kb.clear(),$b.clear()}static fromObject({locale:t,numberingSystem:n,outputCalendar:r,weekSettings:o}={}){return e.create(t,n,r,o)}constructor(t,n,r,o,a){let[i,s,l]=mN(t);this.locale=i,this.numberingSystem=n||s||null,this.outputCalendar=r||l||null,this.weekSettings=o,this.intl=pN(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=a,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=bN(this)),this.fastNumbersCached}listingMode(){let t=this.isEnglish(),n=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return t&&n?"en":"intl"}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:e.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,ty(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(t={}){return this.clone({...t,defaultToEN:!0})}redefaultToSystem(t={}){return this.clone({...t,defaultToEN:!1})}months(t,n=!1){return wp(this,t,mC,()=>{let r=this.intl==="ja"||this.intl.startsWith("ja-");n&=!r;let o=n?{month:t,day:"numeric"}:{month:t},a=n?"format":"standalone";if(!this.monthsCache[a][t]){let i=r?s=>this.dtFormatter(s,o).format():s=>this.extract(s,o,"month");this.monthsCache[a][t]=hN(i)}return this.monthsCache[a][t]})}weekdays(t,n=!1){return wp(this,t,gC,()=>{let r=n?{weekday:t,year:"numeric",month:"long",day:"numeric"}:{weekday:t},o=n?"format":"standalone";return this.weekdaysCache[o][t]||(this.weekdaysCache[o][t]=gN(a=>this.extract(a,r,"weekday"))),this.weekdaysCache[o][t]})}meridiems(){return wp(this,void 0,()=>bC,()=>{if(!this.meridiemCache){let t={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[Xn.utc(2016,11,13,9),Xn.utc(2016,11,13,19)].map(n=>this.extract(n,t,"dayperiod"))}return this.meridiemCache})}eras(t){return wp(this,t,yC,()=>{let n={era:t};return this.eraCache[t]||(this.eraCache[t]=[Xn.utc(-40,1,1),Xn.utc(2017,1,1)].map(r=>this.extract(r,n,"era"))),this.eraCache[t]})}extract(t,n,r){let o=this.dtFormatter(t,n),a=o.formatToParts(),i=a.find(s=>s.type.toLowerCase()===r);return i?i.value:null}numberFormatter(t={}){return new Xb(this.intl,t.forceSimple||this.fastNumbers,t)}dtFormatter(t,n={}){return new Zb(t,this.intl,n)}relFormatter(t={}){return new Qb(this.intl,this.isEnglish(),t)}listFormatter(t={}){return lN(this.intl,t)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||eC(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:cC()?fN(this.locale):tC}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(t){return this.locale===t.locale&&this.numberingSystem===t.numberingSystem&&this.outputCalendar===t.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}},Bb=null,Pa=class e extends Ml{static get utcInstance(){return Bb===null&&(Bb=new e(0)),Bb}static instance(t){return t===0?e.utcInstance:new e(t)}static parseSpecifier(t){if(t){let n=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new e(Op(n[1],n[2]))}return null}constructor(t){super(),this.fixed=t}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${ud(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${ud(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(t,n){return ud(this.fixed,n)}get isUniversal(){return!0}offset(){return this.fixed}equals(t){return t.type==="fixed"&&t.fixed===this.fixed}get isValid(){return!0}},Jb=class extends Ml{constructor(t){super(),this.zoneName=t}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}};function As(e,t){if(Jt(e)||e===null)return t;if(e instanceof Ml)return e;if(CN(e)){let n=e.toLowerCase();return n==="default"?t:n==="local"||n==="system"?Rp.instance:n==="utc"||n==="gmt"?Pa.utcInstance:Pa.parseSpecifier(n)||Es.create(e)}else return Ns(e)?Pa.instance(e):typeof e=="object"&&"offset"in e&&typeof e.offset=="function"?e:new Jb(e)}var oy={arab:"[\u0660-\u0669]",arabext:"[\u06F0-\u06F9]",bali:"[\u1B50-\u1B59]",beng:"[\u09E6-\u09EF]",deva:"[\u0966-\u096F]",fullwide:"[\uFF10-\uFF19]",gujr:"[\u0AE6-\u0AEF]",hanidec:"[\u3007|\u4E00|\u4E8C|\u4E09|\u56DB|\u4E94|\u516D|\u4E03|\u516B|\u4E5D]",khmr:"[\u17E0-\u17E9]",knda:"[\u0CE6-\u0CEF]",laoo:"[\u0ED0-\u0ED9]",limb:"[\u1946-\u194F]",mlym:"[\u0D66-\u0D6F]",mong:"[\u1810-\u1819]",mymr:"[\u1040-\u1049]",orya:"[\u0B66-\u0B6F]",tamldec:"[\u0BE6-\u0BEF]",telu:"[\u0C66-\u0C6F]",thai:"[\u0E50-\u0E59]",tibt:"[\u0F20-\u0F29]",latn:"\\d"},i1={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},yN=oy.hanidec.replace(/[\[|\]]/g,"").split("");function vN(e){let t=parseInt(e,10);if(isNaN(t)){t="";for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(e[n].search(oy.hanidec)!==-1)t+=yN.indexOf(e[n]);else for(let o in i1){let[a,i]=i1[o];r>=a&&r<=i&&(t+=r-a)}}return parseInt(t,10)}else return t}var ey=new Map;function wN(){ey.clear()}function ei({numberingSystem:e},t=""){let n=e||"latn",r=ey.get(n);r===void 0&&(r=new Map,ey.set(n,r));let o=r.get(t);return o===void 0&&(o=new RegExp(`${oy[n]}${t}`),r.set(t,o)),o}var s1=()=>Date.now(),l1="system",c1=null,u1=null,d1=null,f1=60,m1,p1=null,Tr=class{static get now(){return s1}static set now(t){s1=t}static set defaultZone(t){l1=t}static get defaultZone(){return As(l1,Rp.instance)}static get defaultLocale(){return c1}static set defaultLocale(t){c1=t}static get defaultNumberingSystem(){return u1}static set defaultNumberingSystem(t){u1=t}static get defaultOutputCalendar(){return d1}static set defaultOutputCalendar(t){d1=t}static get defaultWeekSettings(){return p1}static set defaultWeekSettings(t){p1=ty(t)}static get twoDigitCutoffYear(){return f1}static set twoDigitCutoffYear(t){f1=t%100}static get throwOnInvalid(){return m1}static set throwOnInvalid(t){m1=t}static resetCaches(){mr.resetCache(),Es.resetCache(),Xn.resetCache(),wN()}},ma=class{constructor(t,n){this.reason=t,this.explanation=n}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},nC=[0,31,59,90,120,151,181,212,243,273,304,334],rC=[0,31,60,91,121,152,182,213,244,274,305,335];function La(e,t){return new ma("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function ay(e,t,n){let r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);let o=r.getUTCDay();return o===0?7:o}function oC(e,t,n){return n+(fd(e)?rC:nC)[t-1]}function aC(e,t){let n=fd(e)?rC:nC,r=n.findIndex(a=>a<t),o=t-n[r];return{month:r+1,day:o}}function iy(e,t){return(e-t+7)%7+1}function Pp(e,t=4,n=1){let{year:r,month:o,day:a}=e,i=oC(r,o,a),s=iy(ay(r,o,a),n),l=Math.floor((i-s+14-t)/7),c;return l<1?(c=r-1,l=dd(c,t,n)):l>dd(r,t,n)?(c=r+1,l=1):c=r,{weekYear:c,weekNumber:l,weekday:s,..._p(e)}}function h1(e,t=4,n=1){let{weekYear:r,weekNumber:o,weekday:a}=e,i=iy(ay(r,1,t),n),s=Wc(r),l=o*7+a-i-7+t,c;l<1?(c=r-1,l+=Wc(c)):l>s?(c=r+1,l-=Wc(r)):c=r;let{month:u,day:d}=aC(c,l);return{year:c,month:u,day:d,..._p(e)}}function Nb(e){let{year:t,month:n,day:r}=e,o=oC(t,n,r);return{year:t,ordinal:o,..._p(e)}}function g1(e){let{year:t,ordinal:n}=e,{month:r,day:o}=aC(t,n);return{year:t,month:r,day:o,..._p(e)}}function b1(e,t){if(!Jt(e.localWeekday)||!Jt(e.localWeekNumber)||!Jt(e.localWeekYear)){if(!Jt(e.weekday)||!Jt(e.weekNumber)||!Jt(e.weekYear))throw new Bs("Cannot mix locale-based week fields with ISO-based week fields");return Jt(e.localWeekday)||(e.weekday=e.localWeekday),Jt(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),Jt(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function xN(e,t=4,n=1){let r=Np(e.weekYear),o=Ra(e.weekNumber,1,dd(e.weekYear,t,n)),a=Ra(e.weekday,1,7);return r?o?a?!1:La("weekday",e.weekday):La("week",e.weekNumber):La("weekYear",e.weekYear)}function SN(e){let t=Np(e.year),n=Ra(e.ordinal,1,Wc(e.year));return t?n?!1:La("ordinal",e.ordinal):La("year",e.year)}function iC(e){let t=Np(e.year),n=Ra(e.month,1,12),r=Ra(e.day,1,Dp(e.year,e.month));return t?n?r?!1:La("day",e.day):La("month",e.month):La("year",e.year)}function sC(e){let{hour:t,minute:n,second:r,millisecond:o}=e,a=Ra(t,0,23)||t===24&&n===0&&r===0&&o===0,i=Ra(n,0,59),s=Ra(r,0,59),l=Ra(o,0,999);return a?i?s?l?!1:La("millisecond",o):La("second",r):La("minute",n):La("hour",t)}function Jt(e){return typeof e>"u"}function Ns(e){return typeof e=="number"}function Np(e){return typeof e=="number"&&e%1===0}function CN(e){return typeof e=="string"}function kN(e){return Object.prototype.toString.call(e)==="[object Date]"}function lC(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function cC(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function TN(e){return Array.isArray(e)?e:[e]}function y1(e,t,n){if(e.length!==0)return e.reduce((r,o)=>{let a=[t(o),o];return r&&n(r[0],a[0])===r[0]?r:a},null)[1]}function IN(e,t){return t.reduce((n,r)=>(n[r]=e[r],n),{})}function jc(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ty(e){if(e==null)return null;if(typeof e!="object")throw new oo("Week settings must be an object");if(!Ra(e.firstDay,1,7)||!Ra(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(t=>!Ra(t,1,7)))throw new oo("Invalid week settings");return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Ra(e,t,n){return Np(e)&&e>=t&&e<=n}function MN(e,t){return e-t*Math.floor(e/t)}function Ur(e,t=2){let n=e<0,r;return n?r="-"+(""+-e).padStart(t,"0"):r=(""+e).padStart(t,"0"),r}function Ds(e){if(!(Jt(e)||e===null||e===""))return parseInt(e,10)}function kl(e){if(!(Jt(e)||e===null||e===""))return parseFloat(e)}function sy(e){if(!(Jt(e)||e===null||e==="")){let t=parseFloat("0."+e)*1e3;return Math.floor(t)}}function ly(e,t,n="round"){let r=10**t;switch(n){case"expand":return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case"trunc":return Math.trunc(e*r)/r;case"round":return Math.round(e*r)/r;case"floor":return Math.floor(e*r)/r;case"ceil":return Math.ceil(e*r)/r;default:throw new RangeError(`Value rounding ${n} is out of range`)}}function fd(e){return e%4===0&&(e%100!==0||e%400===0)}function Wc(e){return fd(e)?366:365}function Dp(e,t){let n=MN(t-1,12)+1,r=e+(t-n)/12;return n===2?fd(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function Ep(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function v1(e,t,n){return-iy(ay(e,1,t),n)+t-1}function dd(e,t=4,n=1){let r=v1(e,t,n),o=v1(e+1,t,n);return(Wc(e)-r+o)/7}function ny(e){return e>99?e:e>Tr.twoDigitCutoffYear?1900+e:2e3+e}function uC(e,t,n,r=null){let o=new Date(e),a={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};r&&(a.timeZone=r);let i={timeZoneName:t,...a},s=new Intl.DateTimeFormat(n,i).formatToParts(o).find(l=>l.type.toLowerCase()==="timezonename");return s?s.value:null}function Op(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);let r=parseInt(t,10)||0,o=n<0||Object.is(n,-0)?-r:r;return n*60+o}function dC(e){let t=Number(e);if(typeof e=="boolean"||e===""||!Number.isFinite(t))throw new oo(`Invalid unit value ${e}`);return t}function Ap(e,t){let n={};for(let r in e)if(jc(e,r)){let o=e[r];if(o==null)continue;n[t(r)]=dC(o)}return n}function ud(e,t){let n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),o=e>=0?"+":"-";switch(t){case"short":return`${o}${Ur(n,2)}:${Ur(r,2)}`;case"narrow":return`${o}${n}${r>0?`:${r}`:""}`;case"techie":return`${o}${Ur(n,2)}${Ur(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function _p(e){return IN(e,["hour","minute","second","millisecond"])}var LN=["January","February","March","April","May","June","July","August","September","October","November","December"],fC=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],RN=["J","F","M","A","M","J","J","A","S","O","N","D"];function mC(e){switch(e){case"narrow":return[...RN];case"short":return[...fC];case"long":return[...LN];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}var pC=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],hC=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],PN=["M","T","W","T","F","S","S"];function gC(e){switch(e){case"narrow":return[...PN];case"short":return[...hC];case"long":return[...pC];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}var bC=["AM","PM"],DN=["Before Christ","Anno Domini"],AN=["BC","AD"],BN=["B","A"];function yC(e){switch(e){case"narrow":return[...BN];case"short":return[...AN];case"long":return[...DN];default:return null}}function NN(e){return bC[e.hour<12?0:1]}function EN(e,t){return gC(t)[e.weekday-1]}function ON(e,t){return mC(t)[e.month-1]}function _N(e,t){return yC(t)[e.year<0?0:1]}function FN(e,t,n="always",r=!1){let o={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},a=["hours","minutes","seconds"].indexOf(e)===-1;if(n==="auto"&&a){let d=e==="days";switch(t){case 1:return d?"tomorrow":`next ${o[e][0]}`;case-1:return d?"yesterday":`last ${o[e][0]}`;case 0:return d?"today":`this ${o[e][0]}`}}let i=Object.is(t,-0)||t<0,s=Math.abs(t),l=s===1,c=o[e],u=r?l?c[1]:c[2]||c[1]:l?o[e][0]:e;return i?`${s} ${u} ago`:`in ${s} ${u}`}function w1(e,t){let n="";for(let r of e)r.literal?n+=r.val:n+=t(r.val);return n}var zN={D:Lp,DD:E1,DDD:O1,DDDD:_1,t:F1,tt:z1,ttt:H1,tttt:V1,T:W1,TT:q1,TTT:U1,TTTT:j1,f:G1,ff:K1,fff:X1,ffff:Q1,F:Y1,FF:$1,FFF:Z1,FFFF:J1},fa=class e{static create(t,n={}){return new e(t,n)}static parseFormat(t){let n=null,r="",o=!1,a=[];for(let i=0;i<t.length;i++){let s=t.charAt(i);s==="'"?((r.length>0||o)&&a.push({literal:o||/^\s+$/.test(r),val:r===""?"'":r}),n=null,r="",o=!o):o||s===n?r+=s:(r.length>0&&a.push({literal:/^\s+$/.test(r),val:r}),r=s,n=s)}return r.length>0&&a.push({literal:o||/^\s+$/.test(r),val:r}),a}static macroTokenToFormatOpts(t){return zN[t]}constructor(t,n){this.opts=n,this.loc=t,this.systemLoc=null}formatWithSystemDefault(t,n){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(t,{...this.opts,...n}).format()}dtFormatter(t,n={}){return this.loc.dtFormatter(t,{...this.opts,...n})}formatDateTime(t,n){return this.dtFormatter(t,n).format()}formatDateTimeParts(t,n){return this.dtFormatter(t,n).formatToParts()}formatInterval(t,n){return this.dtFormatter(t.start,n).dtf.formatRange(t.start.toJSDate(),t.end.toJSDate())}resolvedOptions(t,n){return this.dtFormatter(t,n).resolvedOptions()}num(t,n=0,r=void 0){if(this.opts.forceSimple)return Ur(t,n);let o={...this.opts};return n>0&&(o.padTo=n),r&&(o.signDisplay=r),this.loc.numberFormatter(o).format(t)}formatDateTimeFromString(t,n){let r=this.loc.listingMode()==="en",o=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",a=(f,h)=>this.loc.extract(t,f,h),i=f=>t.isOffsetFixed&&t.offset===0&&f.allowZ?"Z":t.isValid?t.zone.formatOffset(t.ts,f.format):"",s=()=>r?NN(t):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(f,h)=>r?ON(t,f):a(h?{month:f}:{month:f,day:"numeric"},"month"),c=(f,h)=>r?EN(t,f):a(h?{weekday:f}:{weekday:f,month:"long",day:"numeric"},"weekday"),u=f=>{let h=e.macroTokenToFormatOpts(f);return h?this.formatWithSystemDefault(t,h):f},d=f=>r?_N(t,f):a({era:f},"era"),m=f=>{switch(f){case"S":return this.num(t.millisecond);case"u":case"SSS":return this.num(t.millisecond,3);case"s":return this.num(t.second);case"ss":return this.num(t.second,2);case"uu":return this.num(Math.floor(t.millisecond/10),2);case"uuu":return this.num(Math.floor(t.millisecond/100));case"m":return this.num(t.minute);case"mm":return this.num(t.minute,2);case"h":return this.num(t.hour%12===0?12:t.hour%12);case"hh":return this.num(t.hour%12===0?12:t.hour%12,2);case"H":return this.num(t.hour);case"HH":return this.num(t.hour,2);case"Z":return i({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return i({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return i({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return t.zone.offsetName(t.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return t.zone.offsetName(t.ts,{format:"long",locale:this.loc.locale});case"z":return t.zoneName;case"a":return s();case"d":return o?a({day:"numeric"},"day"):this.num(t.day);case"dd":return o?a({day:"2-digit"},"day"):this.num(t.day,2);case"c":return this.num(t.weekday);case"ccc":return c("short",!0);case"cccc":return c("long",!0);case"ccccc":return c("narrow",!0);case"E":return this.num(t.weekday);case"EEE":return c("short",!1);case"EEEE":return c("long",!1);case"EEEEE":return c("narrow",!1);case"L":return o?a({month:"numeric",day:"numeric"},"month"):this.num(t.month);case"LL":return o?a({month:"2-digit",day:"numeric"},"month"):this.num(t.month,2);case"LLL":return l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("narrow",!0);case"M":return o?a({month:"numeric"},"month"):this.num(t.month);case"MM":return o?a({month:"2-digit"},"month"):this.num(t.month,2);case"MMM":return l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("narrow",!1);case"y":return o?a({year:"numeric"},"year"):this.num(t.year);case"yy":return o?a({year:"2-digit"},"year"):this.num(t.year.toString().slice(-2),2);case"yyyy":return o?a({year:"numeric"},"year"):this.num(t.year,4);case"yyyyyy":return o?a({year:"numeric"},"year"):this.num(t.year,6);case"G":return d("short");case"GG":return d("long");case"GGGGG":return d("narrow");case"kk":return this.num(t.weekYear.toString().slice(-2),2);case"kkkk":return this.num(t.weekYear,4);case"W":return this.num(t.weekNumber);case"WW":return this.num(t.weekNumber,2);case"n":return this.num(t.localWeekNumber);case"nn":return this.num(t.localWeekNumber,2);case"ii":return this.num(t.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(t.localWeekYear,4);case"o":return this.num(t.ordinal);case"ooo":return this.num(t.ordinal,3);case"q":return this.num(t.quarter);case"qq":return this.num(t.quarter,2);case"X":return this.num(Math.floor(t.ts/1e3));case"x":return this.num(t.ts);default:return u(f)}};return w1(e.parseFormat(n),m)}formatDurationFromString(t,n){let r=this.opts.signMode==="negativeLargestOnly"?-1:1,o=u=>{switch(u[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},a=(u,d)=>m=>{let f=o(m);if(f){let h=d.isNegativeDuration&&f!==d.largestUnit?r:1,p;return this.opts.signMode==="negativeLargestOnly"&&f!==d.largestUnit?p="never":this.opts.signMode==="all"?p="always":p="auto",this.num(u.get(f)*h,m.length,p)}else return m},i=e.parseFormat(n),s=i.reduce((u,{literal:d,val:m})=>d?u:u.concat(m),[]),l=t.shiftTo(...s.map(o).filter(u=>u)),c={isNegativeDuration:l<0,largestUnit:Object.keys(l.values)[0]};return w1(i,a(l,c))}},vC=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Gc(...e){let t=e.reduce((n,r)=>n+r.source,"");return RegExp(`^${t}$`)}function Yc(...e){return t=>e.reduce(([n,r,o],a)=>{let[i,s,l]=a(t,o);return[{...n,...i},s||r,l]},[{},null,1]).slice(0,2)}function Kc(e,...t){if(e==null)return[null,null];for(let[n,r]of t){let o=n.exec(e);if(o)return r(o)}return[null,null]}function wC(...e){return(t,n)=>{let r={},o;for(o=0;o<e.length;o++)r[e[o]]=Ds(t[n+o]);return[r,null,n+o]}}var xC=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,HN=`(?:${xC.source}?(?:\\[(${vC.source})\\])?)?`,cy=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,SC=RegExp(`${cy.source}${HN}`),uy=RegExp(`(?:[Tt]${SC.source})?`),VN=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,WN=/(\d{4})-?W(\d\d)(?:-?(\d))?/,qN=/(\d{4})-?(\d{3})/,UN=wC("weekYear","weekNumber","weekDay"),jN=wC("year","ordinal"),GN=/(\d{4})-(\d\d)-(\d\d)/,CC=RegExp(`${cy.source} ?(?:${xC.source}|(${vC.source}))?`),YN=RegExp(`(?: ${CC.source})?`);function qc(e,t,n){let r=e[t];return Jt(r)?n:Ds(r)}function KN(e,t){return[{year:qc(e,t),month:qc(e,t+1,1),day:qc(e,t+2,1)},null,t+3]}function $c(e,t){return[{hours:qc(e,t,0),minutes:qc(e,t+1,0),seconds:qc(e,t+2,0),milliseconds:sy(e[t+3])},null,t+4]}function md(e,t){let n=!e[t]&&!e[t+1],r=Op(e[t+1],e[t+2]),o=n?null:Pa.instance(r);return[{},o,t+3]}function pd(e,t){let n=e[t]?Es.create(e[t]):null;return[{},n,t+1]}var $N=RegExp(`^T?${cy.source}$`),XN=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function ZN(e){let[t,n,r,o,a,i,s,l,c]=e,u=t[0]==="-",d=l&&l[0]==="-",m=(f,h=!1)=>f!==void 0&&(h||f&&u)?-f:f;return[{years:m(kl(n)),months:m(kl(r)),weeks:m(kl(o)),days:m(kl(a)),hours:m(kl(i)),minutes:m(kl(s)),seconds:m(kl(l),l==="-0"),milliseconds:m(sy(c),d)}]}var QN={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function dy(e,t,n,r,o,a,i){let s={year:t.length===2?ny(Ds(t)):Ds(t),month:fC.indexOf(n)+1,day:Ds(r),hour:Ds(o),minute:Ds(a)};return i&&(s.second=Ds(i)),e&&(s.weekday=e.length>3?pC.indexOf(e)+1:hC.indexOf(e)+1),s}var JN=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function eE(e){let[,t,n,r,o,a,i,s,l,c,u,d]=e,m=dy(t,o,r,n,a,i,s),f;return l?f=QN[l]:c?f=0:f=Op(u,d),[m,new Pa(f)]}function tE(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}var nE=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,rE=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,oE=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function x1(e){let[,t,n,r,o,a,i,s]=e;return[dy(t,o,r,n,a,i,s),Pa.utcInstance]}function aE(e){let[,t,n,r,o,a,i,s]=e;return[dy(t,s,n,r,o,a,i),Pa.utcInstance]}var iE=Gc(VN,uy),sE=Gc(WN,uy),lE=Gc(qN,uy),cE=Gc(SC),kC=Yc(KN,$c,md,pd),uE=Yc(UN,$c,md,pd),dE=Yc(jN,$c,md,pd),fE=Yc($c,md,pd);function mE(e){return Kc(e,[iE,kC],[sE,uE],[lE,dE],[cE,fE])}function pE(e){return Kc(tE(e),[JN,eE])}function hE(e){return Kc(e,[nE,x1],[rE,x1],[oE,aE])}function gE(e){return Kc(e,[XN,ZN])}var bE=Yc($c);function yE(e){return Kc(e,[$N,bE])}var vE=Gc(GN,YN),wE=Gc(CC),xE=Yc($c,md,pd);function SE(e){return Kc(e,[vE,kC],[wE,xE])}var S1="Invalid Duration",TC={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},CE={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...TC},Ma=146097/400,Fc=146097/4800,kE={years:{quarters:4,months:12,weeks:Ma/7,days:Ma,hours:Ma*24,minutes:Ma*24*60,seconds:Ma*24*60*60,milliseconds:Ma*24*60*60*1e3},quarters:{months:3,weeks:Ma/28,days:Ma/4,hours:Ma*24/4,minutes:Ma*24*60/4,seconds:Ma*24*60*60/4,milliseconds:Ma*24*60*60*1e3/4},months:{weeks:Fc/7,days:Fc,hours:Fc*24,minutes:Fc*24*60,seconds:Fc*24*60*60,milliseconds:Fc*24*60*60*1e3},...TC},Il=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],TE=Il.slice(0).reverse();function Ki(e,t,n=!1){let r={values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix};return new ao(r)}function IC(e,t){let n=t.milliseconds??0;for(let r of TE.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function C1(e,t){let n=IC(e,t)<0?-1:1;Il.reduceRight((r,o)=>{if(Jt(t[o]))return r;if(r){let a=t[r]*n,i=e[o][r],s=Math.floor(a/i);t[o]+=s*n,t[r]-=s*i*n}return o},null),Il.reduce((r,o)=>{if(Jt(t[o]))return r;if(r){let a=t[r]%1;t[r]-=a,t[o]+=a*e[r][o]}return o},null)}function k1(e){let t={};for(let[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}var ao=class e{constructor(t){let n=t.conversionAccuracy==="longterm"||!1,r=n?kE:CE;t.matrix&&(r=t.matrix),this.values=t.values,this.loc=t.loc||mr.create(),this.conversionAccuracy=n?"longterm":"casual",this.invalid=t.invalid||null,this.matrix=r,this.isLuxonDuration=!0}static fromMillis(t,n){return e.fromObject({milliseconds:t},n)}static fromObject(t,n={}){if(t==null||typeof t!="object")throw new oo(`Duration.fromObject: argument expected to be an object, got ${t===null?"null":typeof t}`);return new e({values:Ap(t,e.normalizeUnit),loc:mr.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(Ns(t))return e.fromMillis(t);if(e.isDuration(t))return t;if(typeof t=="object")return e.fromObject(t);throw new oo(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){let[r]=gE(t);return r?e.fromObject(r,n):e.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,n){let[r]=yE(t);return r?e.fromObject(r,n):e.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,n=null){if(!t)throw new oo("need to specify a reason the Duration is invalid");let r=t instanceof ma?t:new ma(t,n);if(Tr.throwOnInvalid)throw new Wb(r);return new e({invalid:r})}static normalizeUnit(t){let n={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[t&&t.toLowerCase()];if(!n)throw new Mp(t);return n}static isDuration(t){return t&&t.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(t,n={}){let r={...n,floor:n.round!==!1&&n.floor!==!1};return this.isValid?fa.create(this.loc,r).formatDurationFromString(this,t):S1}toHuman(t={}){if(!this.isValid)return S1;let n=t.showZeros!==!1,r=Il.map(o=>{let a=this.values[o];return Jt(a)||a===0&&!n?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...t,unit:o.slice(0,-1)}).format(a)}).filter(o=>o);return this.loc.listFormatter({type:"conjunction",style:t.listStyle||"narrow",...t}).format(r)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let t="P";return this.years!==0&&(t+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(t+=this.months+this.quarters*3+"M"),this.weeks!==0&&(t+=this.weeks+"W"),this.days!==0&&(t+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(t+="T"),this.hours!==0&&(t+=this.hours+"H"),this.minutes!==0&&(t+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(t+=ly(this.seconds+this.milliseconds/1e3,3)+"S"),t==="P"&&(t+="T0S"),t}toISOTime(t={}){if(!this.isValid)return null;let n=this.toMillis();return n<0||n>=864e5?null:(t={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...t,includeOffset:!1},Xn.fromMillis(n,{zone:"UTC"}).toISOTime(t))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?IC(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;let n=e.fromDurationLike(t),r={};for(let o of Il)(jc(n.values,o)||jc(this.values,o))&&(r[o]=n.get(o)+this.get(o));return Ki(this,{values:r},!0)}minus(t){if(!this.isValid)return this;let n=e.fromDurationLike(t);return this.plus(n.negate())}mapUnits(t){if(!this.isValid)return this;let n={};for(let r of Object.keys(this.values))n[r]=dC(t(this.values[r],r));return Ki(this,{values:n},!0)}get(t){return this[e.normalizeUnit(t)]}set(t){if(!this.isValid)return this;let n={...this.values,...Ap(t,e.normalizeUnit)};return Ki(this,{values:n})}reconfigure({locale:t,numberingSystem:n,conversionAccuracy:r,matrix:o}={}){let i={loc:this.loc.clone({locale:t,numberingSystem:n}),matrix:o,conversionAccuracy:r};return Ki(this,i)}as(t){return this.isValid?this.shiftTo(t).get(t):NaN}normalize(){if(!this.isValid)return this;let t=this.toObject();return C1(this.matrix,t),Ki(this,{values:t},!0)}rescale(){if(!this.isValid)return this;let t=k1(this.normalize().shiftToAll().toObject());return Ki(this,{values:t},!0)}shiftTo(...t){if(!this.isValid)return this;if(t.length===0)return this;t=t.map(i=>e.normalizeUnit(i));let n={},r={},o=this.toObject(),a;for(let i of Il)if(t.indexOf(i)>=0){a=i;let s=0;for(let c in r)s+=this.matrix[c][i]*r[c],r[c]=0;Ns(o[i])&&(s+=o[i]);let l=Math.trunc(s);n[i]=l,r[i]=(s*1e3-l*1e3)/1e3}else Ns(o[i])&&(r[i]=o[i]);for(let i in r)r[i]!==0&&(n[a]+=i===a?r[i]:r[i]/this.matrix[a][i]);return C1(this.matrix,n),Ki(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;let t={};for(let n of Object.keys(this.values))t[n]=this.values[n]===0?0:-this.values[n];return Ki(this,{values:t},!0)}removeZeros(){if(!this.isValid)return this;let t=k1(this.values);return Ki(this,{values:t},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(t){if(!this.isValid||!t.isValid||!this.loc.equals(t.loc))return!1;function n(r,o){return r===void 0||r===0?o===void 0||o===0:r===o}for(let r of Il)if(!n(this.values[r],t.values[r]))return!1;return!0}},zc="Invalid Interval";function IE(e,t){return!e||!e.isValid?Uc.invalid("missing or invalid start"):!t||!t.isValid?Uc.invalid("missing or invalid end"):t<e?Uc.invalid("end before start",`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null}var Uc=class e{constructor(t){this.s=t.start,this.e=t.end,this.invalid=t.invalid||null,this.isLuxonInterval=!0}static invalid(t,n=null){if(!t)throw new oo("need to specify a reason the Interval is invalid");let r=t instanceof ma?t:new ma(t,n);if(Tr.throwOnInvalid)throw new Vb(r);return new e({invalid:r})}static fromDateTimes(t,n){let r=id(t),o=id(n),a=IE(r,o);return a??new e({start:r,end:o})}static after(t,n){let r=ao.fromDurationLike(n),o=id(t);return e.fromDateTimes(o,o.plus(r))}static before(t,n){let r=ao.fromDurationLike(n),o=id(t);return e.fromDateTimes(o.minus(r),o)}static fromISO(t,n){let[r,o]=(t||"").split("/",2);if(r&&o){let a,i;try{a=Xn.fromISO(r,n),i=a.isValid}catch{i=!1}let s,l;try{s=Xn.fromISO(o,n),l=s.isValid}catch{l=!1}if(i&&l)return e.fromDateTimes(a,s);if(i){let c=ao.fromISO(o,n);if(c.isValid)return e.after(a,c)}else if(l){let c=ao.fromISO(r,n);if(c.isValid)return e.before(s,c)}}return e.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(t){return t&&t.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(t="milliseconds"){return this.isValid?this.toDuration(t).get(t):NaN}count(t="milliseconds",n){if(!this.isValid)return NaN;let r=this.start.startOf(t,n),o;return n?.useLocaleWeeks?o=this.end.reconfigure({locale:r.locale}):o=this.end,o=o.startOf(t,n),Math.floor(o.diff(r,t).get(t))+(o.valueOf()!==this.end.valueOf())}hasSame(t){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,t):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(t){return this.isValid?this.s>t:!1}isBefore(t){return this.isValid?this.e<=t:!1}contains(t){return this.isValid?this.s<=t&&this.e>t:!1}set({start:t,end:n}={}){return this.isValid?e.fromDateTimes(t||this.s,n||this.e):this}splitAt(...t){if(!this.isValid)return[];let n=t.map(id).filter(i=>this.contains(i)).sort((i,s)=>i.toMillis()-s.toMillis()),r=[],{s:o}=this,a=0;for(;o<this.e;){let i=n[a]||this.e,s=+i>+this.e?this.e:i;r.push(e.fromDateTimes(o,s)),o=s,a+=1}return r}splitBy(t){let n=ao.fromDurationLike(t);if(!this.isValid||!n.isValid||n.as("milliseconds")===0)return[];let{s:r}=this,o=1,a,i=[];for(;r<this.e;){let s=this.start.plus(n.mapUnits(l=>l*o));a=+s>+this.e?this.e:s,i.push(e.fromDateTimes(r,a)),r=a,o+=1}return i}divideEqually(t){return this.isValid?this.splitBy(this.length()/t).slice(0,t):[]}overlaps(t){return this.e>t.s&&this.s<t.e}abutsStart(t){return this.isValid?+this.e==+t.s:!1}abutsEnd(t){return this.isValid?+t.e==+this.s:!1}engulfs(t){return this.isValid?this.s<=t.s&&this.e>=t.e:!1}equals(t){return!this.isValid||!t.isValid?!1:this.s.equals(t.s)&&this.e.equals(t.e)}intersection(t){if(!this.isValid)return this;let n=this.s>t.s?this.s:t.s,r=this.e<t.e?this.e:t.e;return n>=r?null:e.fromDateTimes(n,r)}union(t){if(!this.isValid)return this;let n=this.s<t.s?this.s:t.s,r=this.e>t.e?this.e:t.e;return e.fromDateTimes(n,r)}static merge(t){let[n,r]=t.sort((o,a)=>o.s-a.s).reduce(([o,a],i)=>a?a.overlaps(i)||a.abutsStart(i)?[o,a.union(i)]:[o.concat([a]),i]:[o,i],[[],null]);return r&&n.push(r),n}static xor(t){let n=null,r=0,o=[],a=t.map(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),i=Array.prototype.concat(...a),s=i.sort((l,c)=>l.time-c.time);for(let l of s)r+=l.type==="s"?1:-1,r===1?n=l.time:(n&&+n!=+l.time&&o.push(e.fromDateTimes(n,l.time)),n=null);return e.merge(o)}difference(...t){return e.xor([this].concat(t)).map(n=>this.intersection(n)).filter(n=>n&&!n.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} \u2013 ${this.e.toISO()})`:zc}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(t=Lp,n={}){return this.isValid?fa.create(this.s.loc.clone(n),t).formatInterval(this):zc}toISO(t){return this.isValid?`${this.s.toISO(t)}/${this.e.toISO(t)}`:zc}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:zc}toISOTime(t){return this.isValid?`${this.s.toISOTime(t)}/${this.e.toISOTime(t)}`:zc}toFormat(t,{separator:n=" \u2013 "}={}){return this.isValid?`${this.s.toFormat(t)}${n}${this.e.toFormat(t)}`:zc}toDuration(t,n){return this.isValid?this.e.diff(this.s,t,n):ao.invalid(this.invalidReason)}mapEndpoints(t){return e.fromDateTimes(t(this.s),t(this.e))}},Vc=class{static hasDST(t=Tr.defaultZone){let n=Xn.now().setZone(t).set({month:12});return!t.isUniversal&&n.offset!==n.set({month:6}).offset}static isValidIANAZone(t){return Es.isValidZone(t)}static normalizeZone(t){return As(t,Tr.defaultZone)}static getStartOfWeek({locale:t=null,locObj:n=null}={}){return(n||mr.create(t)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:t=null,locObj:n=null}={}){return(n||mr.create(t)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:t=null,locObj:n=null}={}){return(n||mr.create(t)).getWeekendDays().slice()}static months(t="long",{locale:n=null,numberingSystem:r=null,locObj:o=null,outputCalendar:a="gregory"}={}){return(o||mr.create(n,r,a)).months(t)}static monthsFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:o=null,outputCalendar:a="gregory"}={}){return(o||mr.create(n,r,a)).months(t,!0)}static weekdays(t="long",{locale:n=null,numberingSystem:r=null,locObj:o=null}={}){return(o||mr.create(n,r,null)).weekdays(t)}static weekdaysFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:o=null}={}){return(o||mr.create(n,r,null)).weekdays(t,!0)}static meridiems({locale:t=null}={}){return mr.create(t).meridiems()}static eras(t="short",{locale:n=null}={}){return mr.create(n,null,"gregory").eras(t)}static features(){return{relative:lC(),localeWeek:cC()}}};function T1(e,t){let n=o=>o.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(t)-n(e);return Math.floor(ao.fromMillis(r).as("days"))}function ME(e,t,n){let r=[["years",(l,c)=>c.year-l.year],["quarters",(l,c)=>c.quarter-l.quarter+(c.year-l.year)*4],["months",(l,c)=>c.month-l.month+(c.year-l.year)*12],["weeks",(l,c)=>{let u=T1(l,c);return(u-u%7)/7}],["days",T1]],o={},a=e,i,s;for(let[l,c]of r)n.indexOf(l)>=0&&(i=l,o[l]=c(e,t),s=a.plus(o),s>t?(o[l]--,e=a.plus(o),e>t&&(s=e,o[l]--,e=a.plus(o))):e=s);return[e,o,s,i]}function LE(e,t,n,r){let[o,a,i,s]=ME(e,t,n),l=t-o,c=n.filter(d=>["hours","minutes","seconds","milliseconds"].indexOf(d)>=0);c.length===0&&(i<t&&(i=o.plus({[s]:1})),i!==o&&(a[s]=(a[s]||0)+l/(i-o)));let u=ao.fromObject(a,r);return c.length>0?ao.fromMillis(l,r).shiftTo(...c).plus(u):u}var RE="missing Intl.DateTimeFormat.formatToParts support";function $n(e,t=n=>n){return{regex:e,deser:([n])=>t(vN(n))}}var PE="\xA0",MC=`[ ${PE}]`,LC=new RegExp(MC,"g");function DE(e){return e.replace(/\./g,"\\.?").replace(LC,MC)}function I1(e){return e.replace(/\./g,"").replace(LC," ").toLowerCase()}function ti(e,t){return e===null?null:{regex:RegExp(e.map(DE).join("|")),deser:([n])=>e.findIndex(r=>I1(n)===I1(r))+t}}function M1(e,t){return{regex:e,deser:([,n,r])=>Op(n,r),groups:t}}function xp(e){return{regex:e,deser:([t])=>t}}function AE(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function BE(e,t){let n=ei(t),r=ei(t,"{2}"),o=ei(t,"{3}"),a=ei(t,"{4}"),i=ei(t,"{6}"),s=ei(t,"{1,2}"),l=ei(t,"{1,3}"),c=ei(t,"{1,6}"),u=ei(t,"{1,9}"),d=ei(t,"{2,4}"),m=ei(t,"{4,6}"),f=g=>({regex:RegExp(AE(g.val)),deser:([y])=>y,literal:!0}),p=(g=>{if(e.literal)return f(g);switch(g.val){case"G":return ti(t.eras("short"),0);case"GG":return ti(t.eras("long"),0);case"y":return $n(c);case"yy":return $n(d,ny);case"yyyy":return $n(a);case"yyyyy":return $n(m);case"yyyyyy":return $n(i);case"M":return $n(s);case"MM":return $n(r);case"MMM":return ti(t.months("short",!0),1);case"MMMM":return ti(t.months("long",!0),1);case"L":return $n(s);case"LL":return $n(r);case"LLL":return ti(t.months("short",!1),1);case"LLLL":return ti(t.months("long",!1),1);case"d":return $n(s);case"dd":return $n(r);case"o":return $n(l);case"ooo":return $n(o);case"HH":return $n(r);case"H":return $n(s);case"hh":return $n(r);case"h":return $n(s);case"mm":return $n(r);case"m":return $n(s);case"q":return $n(s);case"qq":return $n(r);case"s":return $n(s);case"ss":return $n(r);case"S":return $n(l);case"SSS":return $n(o);case"u":return xp(u);case"uu":return xp(s);case"uuu":return $n(n);case"a":return ti(t.meridiems(),0);case"kkkk":return $n(a);case"kk":return $n(d,ny);case"W":return $n(s);case"WW":return $n(r);case"E":case"c":return $n(n);case"EEE":return ti(t.weekdays("short",!1),1);case"EEEE":return ti(t.weekdays("long",!1),1);case"ccc":return ti(t.weekdays("short",!0),1);case"cccc":return ti(t.weekdays("long",!0),1);case"Z":case"ZZ":return M1(new RegExp(`([+-]${s.source})(?::(${r.source}))?`),2);case"ZZZ":return M1(new RegExp(`([+-]${s.source})(${r.source})?`),2);case"z":return xp(/[a-z_+-/]{1,256}?/i);case" ":return xp(/[^\S\n\r]/);default:return f(g)}})(e)||{invalidReason:RE};return p.token=e,p}var NE={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function EE(e,t,n){let{type:r,value:o}=e;if(r==="literal"){let l=/^\s+$/.test(o);return{literal:!l,val:l?" ":o}}let a=t[r],i=r;r==="hour"&&(t.hour12!=null?i=t.hour12?"hour12":"hour24":t.hourCycle!=null?t.hourCycle==="h11"||t.hourCycle==="h12"?i="hour12":i="hour24":i=n.hour12?"hour12":"hour24");let s=NE[i];if(typeof s=="object"&&(s=s[a]),s)return{literal:!1,val:s}}function OE(e){return[`^${e.map(n=>n.regex).reduce((n,r)=>`${n}(${r.source})`,"")}$`,e]}function _E(e,t,n){let r=e.match(t);if(r){let o={},a=1;for(let i in n)if(jc(n,i)){let s=n[i],l=s.groups?s.groups+1:1;!s.literal&&s.token&&(o[s.token.val[0]]=s.deser(r.slice(a,a+l))),a+=l}return[r,o]}else return[r,{}]}function FE(e){let t=a=>{switch(a){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}},n=null,r;return Jt(e.z)||(n=Es.create(e.z)),Jt(e.Z)||(n||(n=new Pa(e.Z)),r=e.Z),Jt(e.q)||(e.M=(e.q-1)*3+1),Jt(e.h)||(e.h<12&&e.a===1?e.h+=12:e.h===12&&e.a===0&&(e.h=0)),e.G===0&&e.y&&(e.y=-e.y),Jt(e.u)||(e.S=sy(e.u)),[Object.keys(e).reduce((a,i)=>{let s=t(i);return s&&(a[s]=e[i]),a},{}),n,r]}var Eb=null;function zE(){return Eb||(Eb=Xn.fromMillis(1555555555555)),Eb}function HE(e,t){if(e.literal)return e;let n=fa.macroTokenToFormatOpts(e.val),r=DC(n,t);return r==null||r.includes(void 0)?e:r}function RC(e,t){return Array.prototype.concat(...e.map(n=>HE(n,t)))}var Bp=class{constructor(t,n){if(this.locale=t,this.format=n,this.tokens=RC(fa.parseFormat(n),t),this.units=this.tokens.map(r=>BE(r,t)),this.disqualifyingUnit=this.units.find(r=>r.invalidReason),!this.disqualifyingUnit){let[r,o]=OE(this.units);this.regex=RegExp(r,"i"),this.handlers=o}}explainFromTokens(t){if(this.isValid){let[n,r]=_E(t,this.regex,this.handlers),[o,a,i]=r?FE(r):[null,null,void 0];if(jc(r,"a")&&jc(r,"H"))throw new Bs("Can't include meridiem when specifying 24-hour format");return{input:t,tokens:this.tokens,regex:this.regex,rawMatches:n,matches:r,result:o,zone:a,specificOffset:i}}else return{input:t,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}};function PC(e,t,n){return new Bp(e,n).explainFromTokens(t)}function VE(e,t,n){let{result:r,zone:o,specificOffset:a,invalidReason:i}=PC(e,t,n);return[r,o,a,i]}function DC(e,t){if(!e)return null;let r=fa.create(t,e).dtFormatter(zE()),o=r.formatToParts(),a=r.resolvedOptions();return o.map(i=>EE(i,e,a))}var Ob="Invalid DateTime",L1=864e13;function ld(e){return new ma("unsupported zone",`the zone "${e.name}" is not supported`)}function _b(e){return e.weekData===null&&(e.weekData=Pp(e.c)),e.weekData}function Fb(e){return e.localWeekData===null&&(e.localWeekData=Pp(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function Tl(e,t){let n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new Xn({...n,...t,old:n})}function AC(e,t,n){let r=e-t*60*1e3,o=n.offset(r);if(t===o)return[r,t];r-=(o-t)*60*1e3;let a=n.offset(r);return o===a?[r,o]:[e-Math.min(o,a)*60*1e3,Math.max(o,a)]}function Sp(e,t){e+=t*60*1e3;let n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function kp(e,t,n){return AC(Ep(e),t,n)}function R1(e,t){let n=e.o,r=e.c.year+Math.trunc(t.years),o=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,a={...e.c,year:r,month:o,day:Math.min(e.c.day,Dp(r,o))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},i=ao.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),s=Ep(a),[l,c]=AC(s,n,e.zone);return i!==0&&(l+=i,c=e.zone.offset(l)),{ts:l,o:c}}function Hc(e,t,n,r,o,a){let{setZone:i,zone:s}=n;if(e&&Object.keys(e).length!==0||t){let l=t||s,c=Xn.fromObject(e,{...n,zone:l,specificOffset:a});return i?c:c.setZone(s)}else return Xn.invalid(new ma("unparsable",`the input "${o}" can't be parsed as ${r}`))}function Cp(e,t,n=!0){return e.isValid?fa.create(mr.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function zb(e,t,n){let r=e.c.year>9999||e.c.year<0,o="";if(r&&e.c.year>=0&&(o+="+"),o+=Ur(e.c.year,r?6:4),n==="year")return o;if(t){if(o+="-",o+=Ur(e.c.month),n==="month")return o;o+="-"}else if(o+=Ur(e.c.month),n==="month")return o;return o+=Ur(e.c.day),o}function P1(e,t,n,r,o,a,i){let s=!n||e.c.millisecond!==0||e.c.second!==0,l="";switch(i){case"day":case"month":case"year":break;default:if(l+=Ur(e.c.hour),i==="hour")break;if(t){if(l+=":",l+=Ur(e.c.minute),i==="minute")break;s&&(l+=":",l+=Ur(e.c.second))}else{if(l+=Ur(e.c.minute),i==="minute")break;s&&(l+=Ur(e.c.second))}if(i==="second")break;s&&(!r||e.c.millisecond!==0)&&(l+=".",l+=Ur(e.c.millisecond,3))}return o&&(e.isOffsetFixed&&e.offset===0&&!a?l+="Z":e.o<0?(l+="-",l+=Ur(Math.trunc(-e.o/60)),l+=":",l+=Ur(Math.trunc(-e.o%60))):(l+="+",l+=Ur(Math.trunc(e.o/60)),l+=":",l+=Ur(Math.trunc(e.o%60)))),a&&(l+="["+e.zone.ianaName+"]"),l}var BC={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},WE={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},qE={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Tp=["year","month","day","hour","minute","second","millisecond"],UE=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],jE=["year","ordinal","hour","minute","second","millisecond"];function Ip(e){let t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[e.toLowerCase()];if(!t)throw new Mp(e);return t}function D1(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return Ip(e)}}function GE(e){if(cd===void 0&&(cd=Tr.now()),e.type!=="iana")return e.offset(cd);let t=e.name,n=ry.get(t);return n===void 0&&(n=e.offset(cd),ry.set(t,n)),n}function A1(e,t){let n=As(t.zone,Tr.defaultZone);if(!n.isValid)return Xn.invalid(ld(n));let r=mr.fromObject(t),o,a;if(Jt(e.year))o=Tr.now();else{for(let l of Tp)Jt(e[l])&&(e[l]=BC[l]);let i=iC(e)||sC(e);if(i)return Xn.invalid(i);let s=GE(n);[o,a]=kp(e,s,n)}return new Xn({ts:o,zone:n,loc:r,o:a})}function B1(e,t,n){let r=Jt(n.round)?!0:n.round,o=Jt(n.rounding)?"trunc":n.rounding,a=(s,l)=>(s=ly(s,r||n.calendary?0:2,n.calendary?"round":o),t.loc.clone(n).relFormatter(n).format(s,l)),i=s=>n.calendary?t.hasSame(e,s)?0:t.startOf(s).diff(e.startOf(s),s).get(s):t.diff(e,s).get(s);if(n.unit)return a(i(n.unit),n.unit);for(let s of n.units){let l=i(s);if(Math.abs(l)>=1)return a(l,s)}return a(e>t?-0:0,n.units[n.units.length-1])}function N1(e){let t={},n;return e.length>0&&typeof e[e.length-1]=="object"?(t=e[e.length-1],n=Array.from(e).slice(0,e.length-1)):n=Array.from(e),[t,n]}var cd,ry=new Map,Xn=class e{constructor(t){let n=t.zone||Tr.defaultZone,r=t.invalid||(Number.isNaN(t.ts)?new ma("invalid input"):null)||(n.isValid?null:ld(n));this.ts=Jt(t.ts)?Tr.now():t.ts;let o=null,a=null;if(!r)if(t.old&&t.old.ts===this.ts&&t.old.zone.equals(n))[o,a]=[t.old.c,t.old.o];else{let s=Ns(t.o)&&!t.old?t.o:n.offset(this.ts);o=Sp(this.ts,s),r=Number.isNaN(o.year)?new ma("invalid input"):null,o=r?null:o,a=r?null:s}this._zone=n,this.loc=t.loc||mr.create(),this.invalid=r,this.weekData=null,this.localWeekData=null,this.c=o,this.o=a,this.isLuxonDateTime=!0}static now(){return new e({})}static local(){let[t,n]=N1(arguments),[r,o,a,i,s,l,c]=n;return A1({year:r,month:o,day:a,hour:i,minute:s,second:l,millisecond:c},t)}static utc(){let[t,n]=N1(arguments),[r,o,a,i,s,l,c]=n;return t.zone=Pa.utcInstance,A1({year:r,month:o,day:a,hour:i,minute:s,second:l,millisecond:c},t)}static fromJSDate(t,n={}){let r=kN(t)?t.valueOf():NaN;if(Number.isNaN(r))return e.invalid("invalid input");let o=As(n.zone,Tr.defaultZone);return o.isValid?new e({ts:r,zone:o,loc:mr.fromObject(n)}):e.invalid(ld(o))}static fromMillis(t,n={}){if(Ns(t))return t<-L1||t>L1?e.invalid("Timestamp out of range"):new e({ts:t,zone:As(n.zone,Tr.defaultZone),loc:mr.fromObject(n)});throw new oo(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(Ns(t))return new e({ts:t*1e3,zone:As(n.zone,Tr.defaultZone),loc:mr.fromObject(n)});throw new oo("fromSeconds requires a numerical input")}static fromObject(t,n={}){t=t||{};let r=As(n.zone,Tr.defaultZone);if(!r.isValid)return e.invalid(ld(r));let o=mr.fromObject(n),a=Ap(t,D1),{minDaysInFirstWeek:i,startOfWeek:s}=b1(a,o),l=Tr.now(),c=Jt(n.specificOffset)?r.offset(l):n.specificOffset,u=!Jt(a.ordinal),d=!Jt(a.year),m=!Jt(a.month)||!Jt(a.day),f=d||m,h=a.weekYear||a.weekNumber;if((f||u)&&h)throw new Bs("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(m&&u)throw new Bs("Can't mix ordinal dates with month/day");let p=h||a.weekday&&!f,g,y,v=Sp(l,c);p?(g=UE,y=WE,v=Pp(v,i,s)):u?(g=jE,y=qE,v=Nb(v)):(g=Tp,y=BC);let b=!1;for(let x of g){let T=a[x];Jt(T)?b?a[x]=y[x]:a[x]=v[x]:b=!0}let S=p?xN(a,i,s):u?SN(a):iC(a),C=S||sC(a);if(C)return e.invalid(C);let w=p?h1(a,i,s):u?g1(a):a,[k,M]=kp(w,c,r),I=new e({ts:k,zone:r,o:M,loc:o});return a.weekday&&f&&t.weekday!==I.weekday?e.invalid("mismatched weekday",`you can't specify both a weekday of ${a.weekday} and a date of ${I.toISO()}`):I.isValid?I:e.invalid(I.invalid)}static fromISO(t,n={}){let[r,o]=mE(t);return Hc(r,o,n,"ISO 8601",t)}static fromRFC2822(t,n={}){let[r,o]=pE(t);return Hc(r,o,n,"RFC 2822",t)}static fromHTTP(t,n={}){let[r,o]=hE(t);return Hc(r,o,n,"HTTP",n)}static fromFormat(t,n,r={}){if(Jt(t)||Jt(n))throw new oo("fromFormat requires an input string and a format");let{locale:o=null,numberingSystem:a=null}=r,i=mr.fromOpts({locale:o,numberingSystem:a,defaultToEN:!0}),[s,l,c,u]=VE(i,t,n);return u?e.invalid(u):Hc(s,l,r,`format ${n}`,t,c)}static fromString(t,n,r={}){return e.fromFormat(t,n,r)}static fromSQL(t,n={}){let[r,o]=SE(t);return Hc(r,o,n,"SQL",t)}static invalid(t,n=null){if(!t)throw new oo("need to specify a reason the DateTime is invalid");let r=t instanceof ma?t:new ma(t,n);if(Tr.throwOnInvalid)throw new Hb(r);return new e({invalid:r})}static isDateTime(t){return t&&t.isLuxonDateTime||!1}static parseFormatForOpts(t,n={}){let r=DC(t,mr.fromObject(n));return r?r.map(o=>o?o.val:null).join(""):null}static expandFormat(t,n={}){return RC(fa.parseFormat(t),mr.fromObject(n)).map(o=>o.val).join("")}static resetCache(){cd=void 0,ry.clear()}get(t){return this[t]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?_b(this).weekYear:NaN}get weekNumber(){return this.isValid?_b(this).weekNumber:NaN}get weekday(){return this.isValid?_b(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Fb(this).weekday:NaN}get localWeekNumber(){return this.isValid?Fb(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Fb(this).weekYear:NaN}get ordinal(){return this.isValid?Nb(this.c).ordinal:NaN}get monthShort(){return this.isValid?Vc.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Vc.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Vc.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Vc.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];let t=864e5,n=6e4,r=Ep(this.c),o=this.zone.offset(r-t),a=this.zone.offset(r+t),i=this.zone.offset(r-o*n),s=this.zone.offset(r-a*n);if(i===s)return[this];let l=r-i*n,c=r-s*n,u=Sp(l,i),d=Sp(c,s);return u.hour===d.hour&&u.minute===d.minute&&u.second===d.second&&u.millisecond===d.millisecond?[Tl(this,{ts:l}),Tl(this,{ts:c})]:[this]}get isInLeapYear(){return fd(this.year)}get daysInMonth(){return Dp(this.year,this.month)}get daysInYear(){return this.isValid?Wc(this.year):NaN}get weeksInWeekYear(){return this.isValid?dd(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?dd(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(t={}){let{locale:n,numberingSystem:r,calendar:o}=fa.create(this.loc.clone(t),t).resolvedOptions(this);return{locale:n,numberingSystem:r,outputCalendar:o}}toUTC(t=0,n={}){return this.setZone(Pa.instance(t),n)}toLocal(){return this.setZone(Tr.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=As(t,Tr.defaultZone),t.equals(this.zone))return this;if(t.isValid){let o=this.ts;if(n||r){let a=t.offset(this.ts),i=this.toObject();[o]=kp(i,a,t)}return Tl(this,{ts:o,zone:t})}else return e.invalid(ld(t))}reconfigure({locale:t,numberingSystem:n,outputCalendar:r}={}){let o=this.loc.clone({locale:t,numberingSystem:n,outputCalendar:r});return Tl(this,{loc:o})}setLocale(t){return this.reconfigure({locale:t})}set(t){if(!this.isValid)return this;let n=Ap(t,D1),{minDaysInFirstWeek:r,startOfWeek:o}=b1(n,this.loc),a=!Jt(n.weekYear)||!Jt(n.weekNumber)||!Jt(n.weekday),i=!Jt(n.ordinal),s=!Jt(n.year),l=!Jt(n.month)||!Jt(n.day),c=s||l,u=n.weekYear||n.weekNumber;if((c||i)&&u)throw new Bs("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&i)throw new Bs("Can't mix ordinal dates with month/day");let d;a?d=h1({...Pp(this.c,r,o),...n},r,o):Jt(n.ordinal)?(d={...this.toObject(),...n},Jt(n.day)&&(d.day=Math.min(Dp(d.year,d.month),d.day))):d=g1({...Nb(this.c),...n});let[m,f]=kp(d,this.o,this.zone);return Tl(this,{ts:m,o:f})}plus(t){if(!this.isValid)return this;let n=ao.fromDurationLike(t);return Tl(this,R1(this,n))}minus(t){if(!this.isValid)return this;let n=ao.fromDurationLike(t).negate();return Tl(this,R1(this,n))}startOf(t,{useLocaleWeeks:n=!1}={}){if(!this.isValid)return this;let r={},o=ao.normalizeUnit(t);switch(o){case"years":r.month=1;case"quarters":case"months":r.day=1;case"weeks":case"days":r.hour=0;case"hours":r.minute=0;case"minutes":r.second=0;case"seconds":r.millisecond=0;break}if(o==="weeks")if(n){let a=this.loc.getStartOfWeek(),{weekday:i}=this;i<a&&(r.weekNumber=this.weekNumber-1),r.weekday=a}else r.weekday=1;if(o==="quarters"){let a=Math.ceil(this.month/3);r.month=(a-1)*3+1}return this.set(r)}endOf(t,n){return this.isValid?this.plus({[t]:1}).startOf(t,n).minus(1):this}toFormat(t,n={}){return this.isValid?fa.create(this.loc.redefaultToEN(n)).formatDateTimeFromString(this,t):Ob}toLocaleString(t=Lp,n={}){return this.isValid?fa.create(this.loc.clone(n),t).formatDateTime(this):Ob}toLocaleParts(t={}){return this.isValid?fa.create(this.loc.clone(t),t).formatDateTimeParts(this):[]}toISO({format:t="extended",suppressSeconds:n=!1,suppressMilliseconds:r=!1,includeOffset:o=!0,extendedZone:a=!1,precision:i="milliseconds"}={}){if(!this.isValid)return null;i=Ip(i);let s=t==="extended",l=zb(this,s,i);return Tp.indexOf(i)>=3&&(l+="T"),l+=P1(this,s,n,r,o,a,i),l}toISODate({format:t="extended",precision:n="day"}={}){return this.isValid?zb(this,t==="extended",Ip(n)):null}toISOWeekDate(){return Cp(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:t=!1,suppressSeconds:n=!1,includeOffset:r=!0,includePrefix:o=!1,extendedZone:a=!1,format:i="extended",precision:s="milliseconds"}={}){return this.isValid?(s=Ip(s),(o&&Tp.indexOf(s)>=3?"T":"")+P1(this,i==="extended",n,t,r,a,s)):null}toRFC2822(){return Cp(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Cp(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?zb(this,!0):null}toSQLTime({includeOffset:t=!0,includeZone:n=!1,includeOffsetSpace:r=!0}={}){let o="HH:mm:ss.SSS";return(n||t)&&(r&&(o+=" "),n?o+="z":t&&(o+="ZZ")),Cp(this,o,!0)}toSQL(t={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(t)}`:null}toString(){return this.isValid?this.toISO():Ob}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(t={}){if(!this.isValid)return{};let n={...this.c};return t.includeConfig&&(n.outputCalendar=this.outputCalendar,n.numberingSystem=this.loc.numberingSystem,n.locale=this.loc.locale),n}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(t,n="milliseconds",r={}){if(!this.isValid||!t.isValid)return ao.invalid("created by diffing an invalid DateTime");let o={locale:this.locale,numberingSystem:this.numberingSystem,...r},a=TN(n).map(ao.normalizeUnit),i=t.valueOf()>this.valueOf(),s=i?this:t,l=i?t:this,c=LE(s,l,a,o);return i?c.negate():c}diffNow(t="milliseconds",n={}){return this.diff(e.now(),t,n)}until(t){return this.isValid?Uc.fromDateTimes(this,t):this}hasSame(t,n,r){if(!this.isValid)return!1;let o=t.valueOf(),a=this.setZone(t.zone,{keepLocalTime:!0});return a.startOf(n,r)<=o&&o<=a.endOf(n,r)}equals(t){return this.isValid&&t.isValid&&this.valueOf()===t.valueOf()&&this.zone.equals(t.zone)&&this.loc.equals(t.loc)}toRelative(t={}){if(!this.isValid)return null;let n=t.base||e.fromObject({},{zone:this.zone}),r=t.padding?this<n?-t.padding:t.padding:0,o=["years","months","days","hours","minutes","seconds"],a=t.unit;return Array.isArray(t.unit)&&(o=t.unit,a=void 0),B1(n,this.plus(r),{...t,numeric:"always",units:o,unit:a})}toRelativeCalendar(t={}){return this.isValid?B1(t.base||e.fromObject({},{zone:this.zone}),this,{...t,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...t){if(!t.every(e.isDateTime))throw new oo("min requires all arguments be DateTimes");return y1(t,n=>n.valueOf(),Math.min)}static max(...t){if(!t.every(e.isDateTime))throw new oo("max requires all arguments be DateTimes");return y1(t,n=>n.valueOf(),Math.max)}static fromFormatExplain(t,n,r={}){let{locale:o=null,numberingSystem:a=null}=r,i=mr.fromOpts({locale:o,numberingSystem:a,defaultToEN:!0});return PC(i,t,n)}static fromStringExplain(t,n,r={}){return e.fromFormatExplain(t,n,r)}static buildFormatParser(t,n={}){let{locale:r=null,numberingSystem:o=null}=n,a=mr.fromOpts({locale:r,numberingSystem:o,defaultToEN:!0});return new Bp(a,t)}static fromFormatParser(t,n,r={}){if(Jt(t)||Jt(n))throw new oo("fromFormatParser requires an input string and a format parser");let{locale:o=null,numberingSystem:a=null}=r,i=mr.fromOpts({locale:o,numberingSystem:a,defaultToEN:!0});if(!i.equals(n.locale))throw new oo(`fromFormatParser called with a locale of ${i}, but the format parser was created for ${n.locale}`);let{result:s,zone:l,specificOffset:c,invalidReason:u}=n.explainFromTokens(t);return u?e.invalid(u):Hc(s,l,r,`format ${n.format}`,t,c)}static get DATE_SHORT(){return Lp}static get DATE_MED(){return E1}static get DATE_MED_WITH_WEEKDAY(){return nN}static get DATE_FULL(){return O1}static get DATE_HUGE(){return _1}static get TIME_SIMPLE(){return F1}static get TIME_WITH_SECONDS(){return z1}static get TIME_WITH_SHORT_OFFSET(){return H1}static get TIME_WITH_LONG_OFFSET(){return V1}static get TIME_24_SIMPLE(){return W1}static get TIME_24_WITH_SECONDS(){return q1}static get TIME_24_WITH_SHORT_OFFSET(){return U1}static get TIME_24_WITH_LONG_OFFSET(){return j1}static get DATETIME_SHORT(){return G1}static get DATETIME_SHORT_WITH_SECONDS(){return Y1}static get DATETIME_MED(){return K1}static get DATETIME_MED_WITH_SECONDS(){return $1}static get DATETIME_MED_WITH_WEEKDAY(){return rN}static get DATETIME_FULL(){return X1}static get DATETIME_FULL_WITH_SECONDS(){return Z1}static get DATETIME_HUGE(){return Q1}static get DATETIME_HUGE_WITH_SECONDS(){return J1}};function id(e){if(Xn.isDateTime(e))return e;if(e&&e.valueOf&&Ns(e.valueOf()))return Xn.fromJSDate(e);if(e&&typeof e=="object")return Xn.fromObject(e);throw new oo(`Unknown datetime argument: ${e}, of type ${typeof e}`)}function hd(e,t,n){if(t<=0n)return{start:e,end:e};let r=n?.hasSession?n.segmentAt(e):null;if(!r){let i=e/t*t;return{start:i,end:i+t}}let o=r.realStart+(e-r.realStart)/t*t,a=o+t;return{start:o,end:a<r.realEnd?a:r.realEnd}}function Fp(e,t,n){if(t<=0n)return e;let{start:r,end:o}=hd(e,t,n);if(e-r<=o-e)return r;let a=hd(o,t,n).start;return a>r?a:o}function Vn(){return typeof window>"u"?1:window.devicePixelRatio||1}function ri(e,t=Vn()){return Math.round(e*t)/t}function NC(e){if(!(e>0))return 1;let t=Math.pow(10,Math.floor(Math.log10(e))),n=e/t;return n<1.5?t:n<3.5?2*t:n<7.5?5*t:10*t}function fy(e){if(e.length===0)return 1;let t=1/0,n=-1/0;for(let o of e)o.price<t&&(t=o.price),o.price>n&&(n=o.price);let r=n-t;return r>0?NC(r/40):NC(Math.abs(n)/100||1)}function YE(e,t){let n=[];if(e.length===0||!(t>0))return n;let r=Math.round(e[0].price/t)*t,o=0;for(let{ts:a,price:i}of e)if(o===0&&(i>=r+t?o=1:i<=r-t&&(o=-1)),o===1){for(;i>=r+t;)n.push({ts:a,yLow:r,yHigh:r+t,dir:1}),r+=t;if(i<=r-2*t)for(o=-1,r-=t;i<=r-t;)n.push({ts:a,yLow:r-t,yHigh:r,dir:-1}),r-=t}else if(o===-1){for(;i<=r-t;)n.push({ts:a,yLow:r-t,yHigh:r,dir:-1}),r-=t;if(i>=r+2*t)for(o=1,r+=t;i>=r+t;)n.push({ts:a,yLow:r,yHigh:r+t,dir:1}),r+=t}return n}function KE(e,t){if(e.length<2||!(t>0))return{columns:[],segments:[]};let n=[{ts:e[0].ts,price:e[0].price}],r=0,o=e[0].price,a=e[0].ts,i=e[0].price;for(let u=1;u<e.length;u++){let{ts:d,price:m}=e[u];r===0?m>=i+t?(r=1,o=m,a=d):m<=i-t&&(r=-1,o=m,a=d):r===1?m>o?(o=m,a=d):m<=o-t&&(n.push({ts:a,price:o}),r=-1,o=m,a=d):m<o?(o=m,a=d):m>=o+t&&(n.push({ts:a,price:o}),r=1,o=m,a=d)}if(n.push({ts:a,price:o}),n.length<2)return{columns:[],segments:[]};let s=[],l=-1/0,c=1/0;for(let u=1;u<n.length;u++){let d=n[u-1],m=n[u],f=m.price>d.price,h=f?d.price>=l:d.price>c;if(s.push({i1:u-1,y1:d.price,i2:u,y2:d.price,yang:h}),f){let p=Math.min(Math.max(l,d.price),m.price);p>d.price&&s.push({i1:u,y1:d.price,i2:u,y2:p,yang:!1}),s.push({i1:u,y1:p,i2:u,y2:m.price,yang:!0}),l=m.price}else{let p=Math.max(Math.min(c,d.price),m.price);p<d.price&&s.push({i1:u,y1:d.price,i2:u,y2:p,yang:!0}),s.push({i1:u,y1:p,i2:u,y2:m.price,yang:!1}),c=m.price}}return{columns:n,segments:s}}function $E(e,t=3){let n=[];if(e.length===0)return n;let r=e[0].price;for(let o=1;o<e.length;o++){let{ts:a,price:i}=e[o];if(n.length===0){i>r?n.push({ts:a,open:r,close:i,dir:1}):i<r&&n.push({ts:a,open:r,close:i,dir:-1}),n.length&&(r=i);continue}let s=n.slice(-t),l=-1/0,c=1/0;for(let u of s)l=Math.max(l,u.open,u.close),c=Math.min(c,u.open,u.close);i>l?(n.push({ts:a,open:r,close:i,dir:1}),r=i):i<c&&(n.push({ts:a,open:r,close:i,dir:-1}),r=i)}return n}function EC(e,t,n){if(e==="renko"){let c=YE(t,n),u=c.length,d=new BigInt64Array(u),m=new Float64Array(u),f=new Float64Array(u);for(let h=0;h<u;h++)d[h]=c[h].ts,m[h]=c[h].yLow,f[h]=c[h].yHigh;return{kind:e,columnTs:d,pLow:m,pHigh:f,bricks:c}}if(e==="line-break"){let c=$E(t,Math.max(1,n)),u=c.length,d=new BigInt64Array(u),m=new Float64Array(u),f=new Float64Array(u);for(let h=0;h<u;h++)d[h]=c[h].ts,m[h]=Math.min(c[h].open,c[h].close),f[h]=Math.max(c[h].open,c[h].close);return{kind:e,columnTs:d,pLow:m,pHigh:f,boxes:c}}let{columns:r,segments:o}=KE(t,n),a=r.length,i=new BigInt64Array(a),s=new Float64Array(a),l=new Float64Array(a);for(let c=0;c<a;c++)i[c]=r[c].ts,s[c]=r[c].price,l[c]=r[c].price;return{kind:e,columnTs:i,pLow:s,pHigh:l,kagiSegments:o}}var gd=20;var yn=30,ZE=12,Nn={background:"#16181d",buyLine:"#00e676",sellLine:"#ff1744",grid:"#282a2e",label:"#888888",axisBg:"#16181d",crosshair:"#aaaaaa",crosshairBg:"#23272f",crosshairText:"#FFFFFF"},my='11px "Inter"',QE=14,JE=50,_C=new Map;function Vp(e,t,n,r,o){if(r)return 0;let a=t?.priceFormat?.precision??2,i=n.priceScaleMode==="percent"&&!!e.pRef,s=u=>i?`${((u-e.pRef)/e.pRef*100).toFixed(a)}%`:u.toFixed(a),l=[s(e.pMin),s(e.pMax)],c;if(o){let u=o.font;o.font=my;let d=_C.get(my);if(d===void 0){d="0";let m=0;for(let f=0;f<=9;f++){let h=o.measureText(String(f)).width;h>m&&(m=h,d=String(f))}_C.set(my,d)}c=Math.max(...l.map(m=>o.measureText(m.replace(/[0-9]/g,d)).width)),o.font=u}else c=Math.max(...l.map(u=>u.length))*6.4;return Math.max(JE,Math.ceil(c+QE))}function zp(e,t){return Math.round(e*t)/t}function $C(e,t,n){let r=Math.max(1,Math.round(t*n)),o=e*n;return(r%2===1?Math.round(o-.5)+.5:Math.round(o))/n}function Hp(e,t){return Math.max(1,Math.round(e*t))/t}function by(e,t){if(t===0n)return[];let n=new Map;for(let r of e){let o=r.ts/t*t,a=n.get(o);a?(r.price>a.high&&(a.high=r.price),r.price<a.low&&(a.low=r.price),a.close=r.price):n.set(o,{ts:o,open:r.price,high:r.price,low:r.price,close:r.price,hasTrades:!0})}return Array.from(n.values()).sort((r,o)=>r.ts<o.ts?-1:1)}function Wp(e,t,n,r,o,a,i,s,l=[],c,u=0,d=0,m=0,f=0,h=0n,p,g=0n,y=null,v=null,b,S,C=!1,w,k,M,I,x,T){let R=e.getContext("2d");if(!R)return;S.setBarNs(h);let P=Vn();R.setTransform(P,0,0,P,0,0);let D=e.width/P,N=e.height/P,O=I?0:yn;dO(R,D,N,p);let A=T??Vp(s,x,p,M,R),B=D-A;t.forEach(E=>{let L=n[E.id];if(!L||L.h<2)return;let z=E.isMain,Y=z?s.pMin:E.yMin,G=z?s.pMax:E.yMax;R.save(),R.beginPath(),R.rect(L.x,L.y,L.w,L.h),R.clip(),R.translate(L.x,L.y);let H=new Xi;H.update({...s,pMax:G,pMin:Y}),w&&H.setSessionMapper(w);let W={ctx:R,rect:{...L,x:0,y:0},tMin:s.tMin,tMax:s.tMax,yMin:Y,yMax:G,barNs:h,horizon:g,transformer:H};if(z){qC(R,s,Y,G,B,L.h,h,p,S,S.getScaleMode()==="log",x),R.save();try{R.beginPath(),R.rect(0,0,B,L.h),R.clip(),p.showHeatmap&&c&&R.drawImage(c,Math.round(u),Math.round(d),Math.round(m),Math.round(f)),C||xO(R,o,a,s,B,L.h,p.chartType,h,p.showBidLine,p.showAskLine,p.showMidLine,p.showLastTradeLine,l,p,g,y,v,b,S,k,x),p.showTradeDots&&pO(R,o,s,B,L.h,h,p,g,S)}finally{R.restore()}}else R.fillStyle=Nn.background,R.fillRect(0,0,B,L.h),qC(R,s,Y,G,B,L.h,h,p,S,S.getScaleMode()==="log",x);r.filter(U=>U.visible&&(U.paneId===E.id||U.layout==="overlay"&&z)).forEach(U=>{try{R.save(),U.drawBase&&U.drawBase(W),R.restore()}catch(V){console.error(V)}}),R.restore()}),p.showBreaks&&mO(R,s,B,N-O,p,S,h),rk(R,D,N,B,N-O,p),nk(R,e,t,n,s,B),cO(R,t,n,B)}function XC(e,t,n,r,o,a,i,s=[],l={},c=[],u=-1,d=!1,m=0n,f,h=0n,p=null,g,y,v,b,S,C,w,k,M,I,x,T,R,P,D,N,O,A,B,E,L,z,Y,G,H){let W=e.getContext("2d");if(!W)return;G?.setSymbol(E?.symbol);let U=performance.now();P&&P.setBarNs(m);let V=Vn(),K=z?0:yn;W.setTransform(V,0,0,V,0,0);let Z=e.width/V,de=e.height/V,ze=Y??Vp(r,E,f,L,W),xe=Z-ze,Ae=de-K;W.clearRect(0,0,Z,de),rk(W,Z,de,xe,Ae,f);let Oe=l.main||{x:0,y:0,w:xe,h:Ae},ke=Oe.h,Q=Oe.y;ke>=2&&(fO(W,e,r,xe,Ae,f,ke,m,[],Q,P,A,L,z,E),L||vO(W,e,t,n,r,xe,ke,f,m,h,p,g,y,Q,P,A,E,ze,G,U)),!L&&nk(W,e,s,l,r,xe),f.showFills&&lO(W,e,r,xe,Ae,f,ke,Q,m,h,o,P,B,g,y,E.symbol);let{hitMap:Pe,suspendCrosshair:_}=o1(W,e,r,xe,Ae,f,v,ke,Q,S,C,b,ro(E),P,ze,E,o??{x:0,y:0}),ie=!!o&&o.x<xe&&o.y<Ae&&u===-1&&!d,se=!o&&H?bO(H,s,l,xe,P,E):null,Se=ie?o:se?.point;if(Se&&u===-1&&!_&&yO(W,e,r,Se,xe,Ae,s,l,m,h,f,w,k,M,I,m,x,t,g,T,R,P,A,L,z,K,E,ze,!ie,!ie&&!se?.full),u!==-1&&uO(W,s,l,e.width,u),o&&a&&wO(W,o,t,r,xe,Ae,P,E),o&&s.length>0&&s.forEach(Re=>{let ye=l[Re.id];if(!ye||ye.h<2)return;let $e={ctx:W,rect:ye,tMin:r.tMin,tMax:r.tMax,yMin:Re.isMain?r.pMin:Re.yMin,yMax:Re.isMain?r.pMax:Re.yMax,barNs:m,horizon:h,transformer:P};c.filter(Ue=>Ue.visible&&(Ue.paneId===Re.id||Ue.layout==="overlay"&&Re.isMain)).forEach(Ue=>{Ue.drawUI&&Ue.drawUI($e,o)})}),D)try{eO(W,e,s,l,r,m,xe,Ae,P,N,O,o,E)}catch{}return i&&(hO(W,i,r,xe,ke,f,P),gO(W,i,r,xe,ke,f,P,E)),Pe}var eO=(e,t,n,r,o,a,i,s,l,c,u,d,m)=>{function f(Y,G){let H=Y/G;return Y%G*2n>=G?(H+1n)*G:H*G}let h=Math.min(l.tsToX(f(c.ts,a),i),i),p=Math.min(l.priceToY(c.price,s),s),g=Math.min(u?l.tsToX(f(u.ts,a),i):l.tsToX(f(l.xToTs(d.x,i),a),i),i),y=Math.min(u?l.priceToY(u.price,s):d.y,s),v=Math.min(h,g),b=Math.max(h,g),S=(h+g)/2,C=(p+y)/2,w=Math.min(p,y)<45?!1:Math.max(p,y)>s-45?!0:y<p,k=g>h;e.fillStyle="#3b58971D",e.fillRect(v,Math.min(p,y),b-v,Math.abs(y-p)),e.strokeStyle="#3b5897",e.setLineDash([]),e.beginPath(),e.moveTo(S,p),e.lineTo(S,y),Math.abs(y-p)>6&&(e.lineTo(S-5,y-(y<p?-5:5)),e.moveTo(S,y),e.lineTo(S+5,y-(y<p?-5:5))),e.stroke(),e.beginPath(),e.moveTo(h,C),e.lineTo(g,C),Math.abs(g-h)>6&&(e.lineTo(g+(k?-5:5),C-5),e.moveTo(g,C),e.lineTo(g+(k?-5:5),C+5)),e.stroke();let M=Math.abs(Math.round(Math.max(Number((f(c.ts,a)-f(u?u.ts:l.xToTs(Math.min(d.x,i),i),a))/a)))),I="ms",x=1000000n;a>=1e9&&(I="second",x=1000000000n),a>=60*1e9&&(I="minute",x=60n*1000000000n),a>=3600*1e9&&(I="hour",x=60n*60n*1000000000n);let T=m?.priceFormat?.minTick??.01,R=Rr(Math.round(((u?u.price:l.yToPrice(Math.min(d.y,s),s))-c.price)/T)*T,m),P=(((u?u.price:l.yToPrice(Math.min(d.y,s),s))/c.price-1)*100).toFixed(2),D=`${R} ${P}% ${Math.round(Math.abs(Number(R))/T)}t`,N=M*Number(a/x),O=`${M} ${M===1?"bar":"bars"}, ${N} ${N===1?I:I+"s"}`,A=Math.max(e.measureText(O).width,e.measureText(D).width),B=40,E=5,L=20,z=7;e.fillStyle="#3b5897",gy(e,S-A/2-L/2,w?Math.min(p,y)-B-E:Math.max(p,y)+E,A+L,B,z),e.fill(),e.fillStyle="#FFFFFF",e.textAlign="center",e.textBaseline="middle",e.fillText(D,S,w?Math.min(p,y)-B/2-B/5-E:Math.max(p,y)+B/2-B/5+E),e.fillText(O,S,w?Math.min(p,y)-B/2+B/5-E:Math.max(p,y)+B/2+B/5+E)};function ZC(e,t,n,r){let a=new OffscreenCanvas(t,n).getContext("2d");a.drawImage(e,0,0);let i=a.getImageData(0,0,t,n),s=i.data,l=r*210+.5|0,c=l>=210?0:210/(210-l);for(let u=3;u<s.length;u+=4){let d=s[u];d!==0&&(d<=l?s[u]=0:s[u]=Math.min(210,(d-l)*c+.5|0))}return i}function yd(e,t){let n=e/t,r=Math.pow(10,Math.floor(Math.log10(n))),o=n/r;return o>5?10*r:o>2?5*r:o>1?2*r:r}var tO=32;function QC(e,t,n,r,o){let a=t-e;if(a<=0||n<=0)return[];if(r&&e>0&&t>0){let c=Math.log(e),d=Math.log(t)-c||1,m=C=>(1-(Math.log(C)-c)/d)*n,f=new Set,h=[],p=C=>{C>=e&&C<=t&&!f.has(C)&&(f.add(C),h.push({value:C,y:m(C)}))},g=Math.floor(Math.log10(e)),y=Math.ceil(Math.log10(t));for(let C=g;C<=y;C++){let w=Math.pow(10,C);for(let k=1;k<=9;k++)p(k*w)}let v=yd(t-e,Math.max(3,Math.round(n/30)));for(let C=Math.ceil(e/v)*v;C<=t;C+=v)p(Number(C.toFixed(10)));h.sort((C,w)=>C.y-w.y);let b=[],S=-1/0;for(let C of h)C.y-S>=tO&&(b.push(C),S=C.y);return b}let i=Math.max(o,yd(a,Math.max(3,Math.round(n/30)))),s=Math.ceil(e/i)*i,l=[];for(let c=s;c<=t;c+=i)l.push({value:c,y:n-(c-e)/a*n});return l}function yy(e){return new Date(Number(e/1000000n))}var FC=new Map;function nO(e,t,n){let r=`${e}|${t}|${n}`,o=FC.get(r);if(!o){let a={timeZone:e,hour:"2-digit",minute:"2-digit",hour12:!t};n&&(a.second="2-digit"),o=new Intl.DateTimeFormat("en-GB",a),FC.set(r,o)}return o}var zC=null;function rO(e,t){let n=zC;if(n&&n.tMin===e.tMin&&n.tMax===e.tMax&&n.timezone===t)return n.spansDays;let r=Xn.fromMillis(Number(e.tMin/1000000n),{zone:t}),o=Xn.fromMillis(Number(e.tMax/1000000n),{zone:t}),a=r.day!==o.day||r.month!==o.month||r.year!==o.year;return zC={tMin:e.tMin,tMax:e.tMax,timezone:t,spansDays:a},a}function JC(e,t,n,r,o,a=!1,i=!1){let s=60000000000n,l=1000000000n,c=yy(e),u=nO(n,r,t<s).format(c),d=Xn.fromMillis(Number(e/1000000n),{zone:n}),m=!1;return a||(rO(o,n)?(i||d.hour===0&&d.minute===0)&&(u=String(d.day),m=!0):d.minute===0&&(m=!0)),t<l?{bold:m,text:`${u}.${String(c.getMilliseconds()).padStart(3,"0")}`}:{bold:m,text:u}}var HC=new Map;function oO(e,t){let n=yy(e),r=HC.get(t);r||(r=new Intl.DateTimeFormat("en-GB",{timeZone:t,weekday:"short",day:"2-digit",month:"short",year:"2-digit"}),HC.set(t,r));let o=r.formatToParts(n),a=i=>o.find(s=>s.type===i)?.value??"";return`${a("weekday")} ${a("day")} ${a("month")} '${a("year")}`}var VC=[1000000000n,2000000000n,5000000000n,10000000000n,15000000000n,30000000000n,60000000000n,120000000000n,300000000000n,600000000000n,900000000000n,1800000000000n,3600000000000n,7200000000000n,10800000000000n,14400000000000n,21600000000000n,28800000000000n,43200000000000n,86400000000000n,172800000000000n,604800000000000n,1209600000000000n,2592000000000000n,7776000000000000n,31536000000000000n];function WC(e,t,n){if(e<=0n)return t>0n?t:VC[0];for(let r of VC)if(!(t>0n&&(r<t||r%t!==0n))&&e/r<=BigInt(n))return r;return aO(e,t,n)}function aO(e,t,n){if(t<=0n)return BigInt(Math.round(yd(Number(e),n)));let r=[1,2,3,5,10,15,20,30,60,120,240,360,720];for(let a of r){let i=t*BigInt(a);if(e/i<=BigInt(n))return i}let o=t;for(;e/o>BigInt(n);)o*=10n;return o}function bd(e){let t=e.replace(/^#/,"");return(t.length===3||t.length===4)&&(t=t.split("").map(n=>n+n).join("")),t.length===8&&(t=t.slice(0,6)),`#${t}`}function ek(e,t,n,r,o){let a=o?.getOrdinal();if(a&&o){let g=o.tsToFracIndex(e.tMin),y=o.tsToFracIndex(e.tMax),v=y-g;if(v<=0)return[];let b=Math.max(1,Math.round(yd(v,n))),S=[],C=Math.ceil(g/b)*b;for(C<0&&(C=0);C<=y&&C<a.length;C+=b)S.push({ts:o.indexToTs(C),isSessionStart:!1});return S}if(!r||!r.hasSession){let g=e.tMax-e.tMin,y=WC(g,t,n),b=e.tMin/y*y;b<e.tMin&&(b+=y);let S=[];for(;b<=e.tMax;)S.push({ts:b,isSessionStart:!1}),b+=y;return S}let i=r.tsToMarket(e.tMin),l=r.tsToMarket(e.tMax)-i,c=[1000000n,10000000n,100000000n,1000000000n,5000000000n,15000000000n,30000000000n,60000000000n,300000000000n,900000000000n,1800000000000n,3600000000000n,7200000000000n,14400000000000n,21600000000000n,43200000000000n,86400000000000n,604800000000000n,2592000000000000n],u;if(t>0n)u=WC(l,t,n);else{u=c[c.length-1];for(let g of c)if(l/g<=BigInt(n)){u=g;break}}let d=43200000000000n,m=r.segments;if(u>=d){let g=e.tMin/u*u,y=[];for(let v=g;v<e.tMax;v+=u){let b=v<e.tMin?e.tMin:v,S=v+u,C=0,w=m.length-1,k=-1;for(;C<=w;){let M=C+w>>>1;m[M].realStart>=b?(k=M,w=M-1):C=M+1}k>=0&&m[k].realStart<S&&m[k].realStart<e.tMax&&y.push({ts:m[k].realStart,isSessionStart:!0})}return y}let f=[];for(let g of m){if(g.realEnd<=e.tMin)continue;if(g.realStart>e.tMax)break;let y=0n;g.realStart<e.tMin&&(y=(e.tMin-g.realStart+u-1n)/u);for(let v=g.realStart+y*u;v<g.realEnd&&v<=e.tMax;)f.push({ts:v,isSessionStart:v===g.realStart,marketTs:g.marketStart+(v-g.realStart)}),v+=u}let h=u*55n/100n,p=[];for(let g of f){let y=p[p.length-1];if(y&&g.marketTs-y.marketTs<h){if(!g.isSessionStart)continue;p.pop()}p.push(g)}return p}function vd(e,t){let n=0,r=e.length-1,o=-1;for(;n<=r;){let a=n+r>>>1;e[a].ts<=t?(o=a,n=a+1):r=a-1}return o}function Xc(e,t){if(e.length===0)return-1;let n=0,r=e.length-1;for(;n<r;){let o=n+r>>>1;e[o].ts<t?n=o+1:r=o}if(n>0){let o=t-e[n-1].ts,a=e[n].ts-t;if(o<a)return n-1}return n}function iO(e,t){if(e.length===0)return-1;let n=0,r=e.length-1;for(;n<r;){let o=n+r>>>1;e[o].ts<t?n=o+1:r=o}if(n>0){let o=t-e[n-1].ts,a=e[n].ts-t;if(o<a)return n-1}return n}function tk(e,t,n,r,o,a,i,s,l){let c=null,u=ZE,d=s>0n?s:r.tMax;for(let m of n){if(m.ts>d)break;if(m.ts<r.tMin||m.ts>r.tMax)continue;let f=l.tsToX(m.ts,o),h=l.priceToY(m.price,a),p=Math.sqrt((f-e)**2+(h-t)**2);p<u&&(u=p,c=m)}return c}function gy(e,t,n,r,o,a){e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+o-a),e.quadraticCurveTo(t+r,n+o,t+r-a,n+o),e.lineTo(t+a,n+o),e.quadraticCurveTo(t,n+o,t,n+o-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath()}function qC(e,t,n,r,o,a,i=0n,s,l,c=!1,u){if(!s.showGrid)return;let d=s.gridHorizontalColor,m=s.gridVerticalColor;e.strokeStyle=d,e.lineWidth=1,e.beginPath();for(let{y:f}of QC(n,r,a,c,u.priceFormat.minTick)){let h=Math.round(f)+.5;e.moveTo(0,h),e.lineTo(o,h)}e.stroke(),e.strokeStyle=m,e.beginPath();for(let{ts:f}of ek(t,i,12,l.getSessionMapper(),l)){let h=Math.round(l.tsToX(f,o))+.5;e.moveTo(h,0),e.lineTo(h,a)}e.stroke()}function nk(e,t,n,r,o,a){e.font='11px "Inter"',e.textAlign="left",e.textBaseline="middle",e.fillStyle=Nn.label;for(let i of n){if(i.isMain)continue;let s=r[i.id];if(!s||s.h<2)continue;let{yMin:l,yMax:c}=i,u=c-l;if(u===0)continue;let d=yd(u,Math.max(3,Math.round(s.h/30))),m=Math.ceil(l/d)*d;for(let f=m;f<=c;f+=d){let h=s.y+s.h-(f-l)/u*s.h,p=Math.abs(f)>=1e3?`${(f/1e3).toFixed(1)}k`:f.toFixed(0);e.fillText(p,a+6,ri(h))}}}var UC=new WeakMap,jC=new WeakMap;function sO(e,t){let n=jC.get(e);n||(n=new Map,jC.set(e,n));let r=n.get(t);return r||(r=e.filter(o=>o.symbol===t),n.set(t,r)),r}function lO(e,t,n,r,o,a,i,s=0,l,c,u,d,m,f,h,p){if(!m)return;let g=m;if(!g.fills?.length)return;let y=sO(g.fills,p);if(!y.length)return;let v=d.getBarPx(r),b=Math.max(1,Math.floor(v*.8)),S=Number(l/1000000n),C=`${n.tMin}|${n.tMax}|${String(n.pMin)}|${String(n.pMax)}`,w=UC.get(t);if(!(w!==void 0&&w.boundsKey===C&&w.fillsRef===y&&w.barsRef===f&&w.openBarRef===h&&w.barNs===l&&w.horizon===c&&w.w===r&&w.h===o)){let T=d.makeTsToXFn(r),R=d.makePriceToYFn(o),P=Math.floor(Number(c/1000000n)/S)*S,D=h?Number(h.ts/1000000n):-1,N=U=>{if(U===D&&h)return h;if(U>=P)return;let V=0,K=f.length-1;for(;V<=K;){let Z=V+K>>>1,de=f[Z].time;if(de===U)return f[Z];de<U?V=Z+1:K=Z-1}},O=Number(n.tMin/1000000n),A=Number(n.tMax/1000000n),B=y.length;{let U=0,V=y.length-1;for(;U<=V;){let K=U+V>>>1;y[K].ts/1e6<O?U=K+1:(B=K,V=K-1)}}let E=[],L=[],z=[],Y=0,G=0,H=0,W=0;for(let U=B;U<y.length;U++){let V=y[U],K=V.ts/1e6;if(K>A)break;let Z=Math.floor(K/S)*S,de=V.side==="long";de?H===Z?Y++:Y=0:W===Z?G++:G=0;let ze=N(Z);if(!ze){de?H=Z:W=Z;continue}let xe=T(BigInt(Z)*1000000n),Ae=Math.min(Math.max(.1*b,4),12),Oe=Ae*3.5;if(de){let ke=R(ze.low)+5+Y*(Oe+7);E.push({x:xe,y:ke,hw:Ae,arrowH:Oe}),z.push({x:xe,yTop:ke,yBottom:ke+Oe,hw:Ae,priceY:R(V.price),color:"#12DAF2",quantity:V.quantity}),H=Z}else{let ke=R(ze.high)-5-G*(Oe+7);L.push({x:xe,y:ke,hw:Ae,arrowH:Oe}),z.push({x:xe,yTop:ke-Oe,yBottom:ke,hw:Ae,priceY:R(V.price),color:"#F23040",quantity:V.quantity}),W=Z}}w={boundsKey:C,fillsRef:y,barsRef:f,openBarRef:h,barNs:l,horizon:c,w:r,h:o,longGeom:E,shortGeom:L,hoverTargets:z},UC.set(t,w)}let{longGeom:M,shortGeom:I,hoverTargets:x}=w;if(M.length){e.strokeStyle="#12DAF2",e.beginPath();for(let T of M)e.moveTo(T.x-T.hw,T.y+T.hw),e.lineTo(T.x,T.y),e.lineTo(T.x+T.hw,T.y+T.hw),e.moveTo(T.x,T.y),e.lineTo(T.x,T.y+T.arrowH);e.stroke()}if(I.length){e.strokeStyle="#F23040",e.beginPath();for(let T of I)e.moveTo(T.x-T.hw,T.y-T.hw),e.lineTo(T.x,T.y),e.lineTo(T.x+T.hw,T.y-T.hw),e.moveTo(T.x,T.y),e.lineTo(T.x,T.y-T.arrowH);e.stroke()}if(u){for(let T of x)if(u.x>T.x-T.hw&&u.x<T.x+T.hw&&u.y>T.yTop&&u.y<T.yBottom){e.strokeStyle=T.color,e.beginPath(),e.moveTo(T.x-b/2,T.priceY),e.lineTo(T.x+b/2,T.priceY),e.stroke(),e.fillStyle=T.color,e.font='bold 18px, "JetBrains mono", monospace',e.fillText(String(T.quantity),T.x+3+b/2,T.priceY);break}}}function cO(e,t,n,r){e.strokeStyle="#2a2a2a",e.lineWidth=1;for(let o=0;o<t.length-1;o++){let a=n[t[o].id];if(!a||a.h<2)continue;let i=Math.round(a.y+a.h)+.5;e.beginPath(),e.moveTo(0,i),e.lineTo(r+65,i),e.stroke()}}function uO(e,t,n,r,o){let a=t[o];if(!a)return;let i=n[a.id];if(!i)return;let s=Math.round(i.y+i.h)+.5;e.strokeStyle="rgba(120, 120, 140, 0.25)",e.lineWidth=5,e.beginPath(),e.moveTo(0,s),e.lineTo(r,s),e.stroke(),e.strokeStyle="rgba(160, 160, 180, 0.7)",e.lineWidth=1.5,e.beginPath(),e.moveTo(0,s),e.lineTo(r,s),e.stroke()}function dO(e,t,n,r){e.fillStyle=r.backgroundColor??Nn.background,e.fillRect(0,0,t,n)}function rk(e,t,n,r,o,a){let i=ri(r),s=ri(o);e.fillStyle=a.axisBackgroundColor??Nn.axisBg,e.fillRect(i,0,t-i,n),e.fillRect(0,s,t,n-s),e.strokeStyle=Nn.grid,e.lineWidth=2,e.setLineDash([]),e.beginPath(),e.moveTo(i,0),e.lineTo(i,s),e.stroke(),e.moveTo(0,s),e.lineTo(i,s),e.stroke(),e.closePath()}function fO(e,t,n,r,o,a,i,s=0n,l=[],c=0,u,d,m,f,h){let p=i??o;if(e.save(),e.fillStyle=Nn.label,e.font='11px "Inter"',e.textAlign="left",e.textBaseline="middle",!m){let g=u?.getScaleMode()==="log";for(let{value:y}of QC(n.pMin,n.pMax,p,g,h.priceFormat.minTick)){let v=u.priceToY(y,p);if(v<0||v>p||(v+=c,!a.allowLabelOverlap&&l.some(C=>Math.abs(C-v)<gd)))continue;let b=h.priceFormat.precision,S=a.priceScaleMode==="percent"&&n.pRef?`${((y-n.pRef)/n.pRef*100).toFixed(b)}%`:y.toFixed(b);e.fillText(S,r+6,ri(v))}}if(!f){e.textAlign="center",e.textBaseline="top";let g=a.timezone??"UTC",y=a.use24HourClock??!0;for(let{ts:v,isSessionStart:b}of ek(n,s,12,u.getSessionMapper(),u)){let S=ri(u.tsToX(v,r)),{bold:C,text:w}=JC(v,s,g,y,n,!1,b);e.font=`${C?"bold":""} 11px "Inter"`,e.fillText(w,S,ri(o+8))}}e.restore()}function Ll(e,t,n,r,o,a,i,s,l=0n,c,u,d,m){let f=u.makeTsToXFn(r),h=u.makePriceToYFn(o);if(i==="price"){if(!d.length)return;let p=Number(l/c*c/1000000n),g=Number(n.tMin/1000000n);e.beginPath(),e.strokeStyle=a,e.lineWidth=1,e.lineJoin="miter";let y=0,v=d.length-1,b=-1;for(;y<=v;){let k=y+v>>>1;d[k].time<=g?(b=k,y=k+1):v=k-1}let S=b,C=!0,w=S;for(let k=S;k<d.length&&!(d[k].time>=p);k++){let M=d[k].close;if(M===0)continue;let I=f(BigInt(d[k].time*1e6)),x=h(M);if(C)e.moveTo(I,x),C=!1;else{let T=d[k-1].close,R=h(T!==0?T:M);e.lineTo(I,R),e.lineTo(I,x),w=k}if(I>r+100)break}e.lineTo(f(m.ts),h(d[w].close)),e.lineTo(f(m.ts),h(m.close)),e.stroke()}else{if(t.length===0)return;let p=l>0n?l:n.tMax;e.beginPath(),e.strokeStyle=a,e.lineWidth=1,e.lineJoin="miter";let g=Math.max(0,vd(t,n.tMin)),y=!0;for(let v=g;v<t.length&&!(t[v].ts>p);v++){let b=i==="ask"?t[v].bestAsk:t[v].bestBid;if(b===0)continue;let S=f(t[v].ts),C=h(b);if(y)e.moveTo(S,C),y=!1;else{let w=i==="ask"?t[v-1].bestAsk:t[v-1].bestBid,k=h(w!==0?w:b);e.lineTo(S,k),e.lineTo(S,C)}if(S>r+100)break}e.stroke()}}function Os(e,t,n,r,o,a,i=0n,s){if(t.length===0)return;let l=s.makeTsToXFn(r),c=s.makePriceToYFn(o),u=i>0n?i:n.tMax,d=Math.max(0,vd(t,n.tMin));e.beginPath(),e.strokeStyle="#b0b0b0",e.lineWidth=1,e.lineJoin="round",e.setLineDash([3,3]);let m=!0;for(let f=d;f<t.length&&!(t[f].ts>u);f++){let{bestBid:h,bestAsk:p}=t[f];if(h===0||p===0)continue;let g=(h+p)/2,y=l(t[f].ts),v=c(g);if(m?(e.moveTo(y,v),m=!1):e.lineTo(y,v),y>r+100)break}e.stroke(),e.setLineDash([])}function _s(e,t,n,r,o,a,i=0n,s){if(t.length===0)return;let l=s.makeTsToXFn(r),c=s.makePriceToYFn(o),u=i>0n?i:n.tMax,d=Math.max(0,(()=>{let f=0,h=t.length-1,p=0;for(;f<=h;){let g=f+h>>>1;t[g].ts<=n.tMin?(p=g,f=g+1):h=g-1}return p})());e.beginPath(),e.strokeStyle="#ffffff99",e.lineWidth=1.5,e.lineJoin="round";let m=!0;for(let f=d;f<t.length&&!(t[f].ts>u||t[f].ts>n.tMax);f++){let h=l(t[f].ts),p=c(t[f].price);m?(e.moveTo(h,p),m=!1):e.lineTo(h,p)}e.stroke()}function mO(e,t,n,r,o,a,i){let s=a.getSessionMapper(),l=a.getBarPx(n),u=Math.max(1,Math.floor(l))/2;e.save(),e.strokeStyle=o.breaksColor,e.setLineDash(o.breaksDash),e.lineWidth=o.breaksWidth;for(let d of s.getBreaks()){if(d.ts<=t.tMin)continue;if(d.ts>=t.tMax)break;let m=a.tsToX(d.ts,n)-u;e.beginPath(),e.moveTo(m,0),e.lineTo(m,r),e.stroke()}e.restore()}function pO(e,t,n,r,o,a=0n,i,s=0n,l){if(t.length===0)return;let c=l.makeTsToXFn(r),u=l.makePriceToYFn(o),d=s>0n?s:n.tMax,m=new Map;for(let p of t){if(p.ts>d)break;if(p.ts<n.tMin||p.ts>n.tMax)continue;let g=a>0n?p.ts/a*a:0n,y=m.get(g)??0;p.size>y&&m.set(g,p.size)}let f=1;for(let p of m.values())p>f&&(f=p);let h=Math.PI*2;for(let p of t){if(p.ts>d)break;if(p.ts<n.tMin||p.ts>n.tMax)continue;let g=c(p.ts),y=u(p.price),v=Math.sqrt(p.size/f),b=(i.tradeDotsSizeMult??3)/3,S=(1.5+v*(8-1.5))*b;e.beginPath(),e.arc(g,y,S,0,h),e.fillStyle=p.side==="B"?"#00e676cc":"#ff1744cc",e.fill()}}function hO(e,t,n,r,o,a,i){let s=i.tsToX(t.ts,r),l=i.priceToY(t.price,o),c=t.side==="B"?"#00e676":"#ff1744";e.beginPath(),e.arc(s,l,8,0,Math.PI*2),e.strokeStyle=c+"50",e.lineWidth=3,e.stroke(),e.beginPath(),e.arc(s,l,5,0,Math.PI*2),e.strokeStyle=c,e.lineWidth=1.5,e.stroke()}function gO(e,t,n,r,o,a,i,s){let l=i.tsToX(t.ts,r),c=i.priceToY(t.price,o),u=t.side==="B",d=u?"#00e676":"#ff1744",m=yy(t.ts).toISOString().slice(11,23),f=[["Side",u?"BUY":"SELL"],["Price",Rr(t.price,s)],["Size",t.size.toString()],["Time",m]];e.font='11px "Inter"';let h=e.measureText("Price").width,p=Math.max(...f.map(([,w])=>e.measureText(w).width)),g=h+p+36,y=18,v=f.length*y+20,b=14,S=l+b,C=c-v-b;S+g>r-4&&(S=l-g-b),S<4&&(S=4),C<4&&(C=c+b),C+v>o-4&&(C=o-v-4),e.fillStyle="rgba(12, 13, 17, 0.95)",e.fillRect(S,C,g,v),e.fillStyle=d,e.fillRect(S,C,3,v),e.strokeStyle="#2a2a2a",e.lineWidth=1,e.strokeRect(S,C,g,v),e.textBaseline="middle",f.forEach(([w,k],M)=>{let I=C+10+M*y+y/2;e.fillStyle=Nn.label,e.textAlign="left",e.fillText(w,S+10,I),e.fillStyle=M===0?d:"#e0e0e0",e.textAlign="right",e.fillText(k,S+g-10,I)})}var wd=(e,t,n)=>Fp(e,t,n),xd=(e,t,n,r,o,a,i,s)=>{if(e>s)return t;let l=n.chartType;if(i==="ohlcv"){let c=Number(e/1000000n),u;{let p=0,g=a.length-1;for(;p<=g;){let y=p+g>>>1,v=a[y].time;if(v===c){u=a[y];break}v<c?p=y+1:g=y-1}}if(!u)return t;let d=[Math.abs(u.open-t),Math.abs(u.high-t),Math.abs(u.low-t),Math.abs(u.close-t)],m=Math.min(...d),f=["open","high","low","close"],h=null;for(let p=0;p<d.length;p++)d[p]===m&&(h=f[p]);return h?u[h]:t}else{if(l==="candles"||l==="footprint"||l==="hollow"||l==="bars"){let p=r;if(p.length===0)return t;let g=0,y=p.length-1,v=0;for(;g<=y;){let C=g+y>>>1;p[C].ts<=e?(v=C,g=C+1):y=C-1}let b=p[v];return[b.open,b.high,b.low,b.close].reduce((C,w)=>Math.abs(w-t)<Math.abs(C-t)?w:C)}let c=o;if(c.length===0)return t;let u=0,d=c.length-1,m=0;for(;u<=d;){let p=u+d>>>1;c[p].ts<=e?(m=p,u=p+1):d=p-1}let f=c[m];return[f.bestBid,f.bestAsk].reduce((p,g)=>Math.abs(g-t)<Math.abs(p-t)?g:p)}};function bO(e,t,n,r,o,a){if(!o)return null;let i=t.find(m=>m.id===e.paneId)??t.find(m=>m.isMain),s=i?n[i.id]:null;if(!i||!s||s.h<2)return null;let l=o.tsToX(e.ts,r);if(!Number.isFinite(l)||l<0||l>=r)return null;let c=!!e.symbol&&e.symbol===a?.symbol,u=i.isMain&&c?s.y+o.priceToY(e.price,s.h):s.y+e.yFrac*s.h,d=Number.isFinite(u)&&u>=s.y&&u<s.y+s.h;return{point:{x:l,y:d?u:s.y+s.h/2},full:d}}function yO(e,t,n,r,o,a,i,s,l=0n,c,u,d,m,f,h,p,g,y,v,b,S,C,w,k,M,I,x,T=0,R,P){if(!r||u.crosshairMode==="hidden")return;e.save(),e.strokeStyle=u.crosshairColor,e.lineWidth=u.crosshairWidth,e.setLineDash(u.crosshairDash);let D=i.find(Y=>{let G=s[Y.id];return G&&r.y>=G.y&&r.y<G.y+G.h}),N=D?s[D.id]:null;if(!N)return;let O=C.xToTs(r.x,o),A=C.getSessionMapper(),B;if(l<=0n)B=O;else if(A&&A.hasSession){let Y=A.segments.find(G=>O>=G.realStart&&O<G.realEnd);if(Y){let G=O-Y.realStart;if(B=Y.realStart+(G+l/2n)/l*l,B>=Y.realEnd){let H=A.segments.find(W=>W.realStart>=Y.realEnd);B=H?H.realStart:Y.realEnd-l}}else B=O}else B=(O+l/2n)/l*l;if(A&&A.hasSession&&l>0n){let Y=A.segments[0];if(Y&&O>=Y.realStart&&!(H=>A.segments.some(W=>H>=W.realStart&&H<W.realEnd))(B)){let H=[],W=[...A.segments].reverse().find(V=>V.realEnd<=O);if(W){let K=(W.realEnd-W.realStart)/l*l,Z=W.realStart+K<W.realEnd?W.realStart+K:W.realStart+K-l;Z>=W.realStart&&H.push(Z)}let U=A.segments.find(V=>V.realStart>O);if(U&&H.push(U.realStart),H.length>0){let V=A.tsToMarket(O);B=H.reduce((K,Z)=>{let de=A.tsToMarket(K),ze=A.tsToMarket(Z),xe=de>V?de-V:V-de;return(ze>V?ze-V:V-ze)<xe?Z:K})}}}let E=l>0n?C.tsToX(B,o):r.x,L=ro(x);E<o&&(e.beginPath(),e.moveTo(E,0),e.lineTo(E,a),e.stroke());let z=r.y;if(N&&!P)if(!R&&(d?.name!=="cursor"||m?.anchor)){let Y=s.main,G=Y?.h??t.height-I,H=Y?.y??0,W=b.find(U=>U.id===m?.drawingId);if(h&&W?.tool!=="fib")S?z=C.priceToY(S.a?.price,G)+H:W?.a&&W?.b&&(z=C.priceToY(m.anchor==="a"?W.b.price:W.a.price,G)+H);else if((f||u.crosshairMode==="magnet")&&m?.anchor!=="body"){let U=wd(O,p,C.getSessionMapper()),V=C.yToPrice(r.y-H,G),K=xd(U,V,u,g,y,v,w,c);z=C.priceToY(K,G)+H}e.beginPath(),e.moveTo(0,z),e.lineTo(o,z),e.stroke()}else e.beginPath(),e.moveTo(0,r.y),e.lineTo(o,r.y),e.stroke();if(!M){let Y=u.timezone??"UTC",G=u.use24HourClock??!0,{text:H}=JC(B,l,Y,G,n,!0),W=oO(B,Y);e.font='11px "Inter"';let U=e.measureText(W+" "+H).width+16;e.fillStyle=Nn.crosshairBg;let V=ri(Math.max(0,Math.min(o-U,E-U/2))),K=ri(a);e.fillRect(V,K,U,20),e.fillStyle=Nn.crosshairText,e.textAlign="center",e.textBaseline="middle",e.fillText(W+" "+H,V+U/2,K+10)}if(!k&&!P){if(!N||!D){e.restore();return}let Y=D.isMain?n.pMin:D.yMin,G=D.isMain?n.pMax:D.yMax,H=z-N.y,W=Y+(N.h-H)/N.h*(G-Y),U=Rr(Math.round(W/L)*L,x),V=ri(z);e.fillStyle=Nn.crosshairBg,e.fillRect(ri(o),V-10,T,20),e.fillStyle=Nn.crosshairText,e.textAlign="left",e.textBaseline="middle",e.fillText(U,o+6,V)}e.restore()}function vO(e,t,n,r,o,a,i,s,l,c=0n,u=null,d=null,m=null,f=0,h,p,g,y=0,v,b=0){let S=(T,R)=>v?v.value(T,R,b,s.animatePriceUpdates):R,C=null,w=null,k=!1;if(p==="l3"){let T=Xc(n,o.tMax);if(T===-1)return[];let R=Xc(n,c);if(R===-1)return[];C=n[T],w=n[R],k=!0}else if(p==="ohlcv"&&d.length){let T=Number(o.tMax/1000000n)-Number(l/1000000n/2n),R=Number(c/1000000n),P=0;{let N=0,O=d.length-1;for(;N<=O;){let A=N+O>>>1;d[A].time<T?N=A+1:O=A-1}P=N}let D=0;{let N=0,O=d.length-1;for(;N<=O;){let A=N+O>>>1;d[A].time<R?N=A+1:O=A-1}D=N}C=d[Math.min(P,d.length-1)],w=d[D],d[D]?.bid&&d[D]?.ask&&(k=!0)}if(!C||!w)return;let M=T=>T>=f&&T<=f+i,I=[];if(k){let T=0,R=0;p==="l3"?(T=w.bestAsk,R=w.bestBid):p==="ohlcv"&&(T=w?.ask,R=w?.bid);let P=S("ask",T),D=S("bid",R),N=h.priceToY(P,i);N+=f;let O=h.priceToY(D,i);O+=f,e.lineWidth=1,e.setLineDash([4,4]),M(N)&&s.showAskLine&&(e.save(),e.beginPath(),e.rect(0,f,a,i),e.clip(),e.beginPath(),e.strokeStyle=Nn.sellLine,e.moveTo(0,N),e.lineTo(a,N),e.stroke(),e.restore(),I.push({idealY:N,actualY:N,fillColor:Nn.sellLine,textColor:Nn.crosshairBg,label:Rr(P,g),filled:!0})),M(O)&&s.showBidLine&&(e.save(),e.beginPath(),e.rect(0,f,a,i),e.clip(),e.beginPath(),e.strokeStyle=Nn.buyLine,e.moveTo(0,O),e.lineTo(a,O),e.stroke(),e.restore(),I.push({idealY:O,actualY:O,fillColor:Nn.buyLine,textColor:Nn.crosshairBg,label:Rr(D,g),filled:!0}))}let x=null;if(l>0n&&s.priceLineVisible){let T=c>0n?c:o.tMax,R=T/l*l;if(p==="l3"){if(u!==null)for(let P=R;P>=R-l*10n;P-=l){let D=u.get(P);if(D){x=D;break}}else if(iO(r,T)>=0){let P=(()=>{let N=0,O=r.length-1,A=r.length;for(;N<=O;){let B=N+O>>>1;r[B].ts<=T?N=B+1:(A=B,O=B-1)}return A})(),D=by(P<r.length?r.slice(0,P):r,l);D.length&&(x=D[D.length-1])}}else p==="ohlcv"&&m&&(x={open:m.open,high:m.high,low:m.low,close:m.close});if(x){let P=S("last",x.close),D=h.priceToY(P,i);if(D+=f,M(D)){let O=x.close>=x.open?s?.upBodyColor??"#00e676":s?.downBodyColor??"#ff1744";e.save(),e.beginPath(),e.rect(0,f,a,i),e.clip(),e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.strokeStyle=O,e.moveTo(0,D),e.lineTo(a,D),e.stroke(),e.restore(),I.push({idealY:D,actualY:D,fillColor:bd(O),textColor:Nn.crosshairBg,label:Rr(P,g),filled:!0})}}}if(e.setLineDash([]),p==="l3"){if(C.ts<w.ts){let T=h.priceToY(C.bestAsk,i);T+=f;let R=h.priceToY(C.bestBid,i);R+=f,M(T)&&I.push({idealY:T,actualY:T,fillColor:Nn.sellLine,textColor:Nn.sellLine,label:Rr(C.bestAsk,g),filled:!1}),M(R)&&I.push({idealY:R,actualY:R,fillColor:Nn.buyLine,textColor:Nn.buyLine,label:Rr(C.bestBid,g),filled:!1})}}else if(p==="ohlcv"&&C.time<w.time)if(k){let T=h.priceToY(C.ask,i);T+=f;let R=h.priceToY(C.bid,i);R+=f,M(T)&&I.push({idealY:T,actualY:T,fillColor:Nn.sellLine,textColor:Nn.sellLine,label:Rr(C.ask,g),filled:!1}),M(R)&&I.push({idealY:R,actualY:R,fillColor:Nn.buyLine,textColor:Nn.buyLine,label:Rr(C.bid,g),filled:!1})}else{let T=h.priceToY(C.close,i);if(T+=f,M(T)){let P=C.close>=C.open?s?.upBodyColor??"#00e676":s?.downBodyColor??"#ff1744";I.push({idealY:T,actualY:T,fillColor:bd(P),textColor:bd(P),label:Rr(C.close,g),filled:!1})}}if(!s.allowLabelOverlap&&I.length>1){I.sort((T,R)=>T.idealY-R.idealY);for(let T=0;T<50;T++)for(let R=0;R<I.length-1;R++){let P=I[R+1].actualY-I[R].actualY;if(P<gd){let D=gd-P;I[R].actualY-=D/2,I[R+1].actualY+=D/2}}}return e.font='500 11px "Inter"',e.textAlign="left",e.textBaseline="middle",I.forEach(T=>{T.filled?(gy(e,a,T.actualY-10,y,gd,3),e.fillStyle=T.fillColor,e.fill()):(gy(e,a+1,T.actualY-10,y-2,gd,3),e.fillStyle=s.axisBackgroundColor,e.strokeStyle=T.fillColor,e.fill(),e.stroke()),e.fillStyle=T.textColor,e.textAlign="left",e.textBaseline="middle",e.fillText(T.label,a+6,T.actualY)}),I.map(T=>T.actualY)}function wO(e,t,n,r,o,a,i,s){let l=i.xToTs(t.x,o),c=Xc(n,l);if(c===-1)return;let u=n[c],d=u.bestAsk-u.bestBid,m=[`Time: ${new Date(Number(u.ts/1000000n)).toISOString().slice(11,23)}`,`Ask: ${Rr(u.bestAsk,s)}`,`Bid: ${Rr(u.bestBid,s)}`,`Spread: ${Rr(d,s)}`],f=164,h=m.length*18+16,p=t.x+15,g=t.y-h/2;e.fillStyle="rgba(20, 20, 20, 0.9)",e.strokeStyle="#444",e.lineWidth=1,e.fillRect(p,g,f,h),e.strokeRect(p,g,f,h),e.fillStyle="#fff",e.font='12px "Inter"',e.textAlign="left",m.forEach((y,v)=>{e.fillText(y,p+10,g+20+v*18)})}function xO(e,t,n,r,o,a,i,s,l,c,u,d,m=[],f,h=0n,p=null,g=null,y,v,b,S){let C=!!(b==="ohlcv"&&y?.[0]?.bid);if(i==="footprint"){JS(e,m,r,o,a,s,f.footprintMode,ro(S),f.footprintVolume,f,h,v),u&&Os(e,n,r,o,a,f,h,v),d&&_s(e,t,r,o,a,f,h,v);return}if(i==="candles"){SO(e,t,n,r,o,a,s,f,h,p,g,y,v),u&&Os(e,n,r,o,a,f,h,v),d&&_s(e,t,r,o,a,f,h,v);return}if(i==="area"){C||b==="l3"?(c&&hy(e,n,r,o,a,"ask",f,h,s,v),l&&hy(e,n,r,o,a,"bid",f,h,s,v)):b==="ohlcv"&&hy(e,n,r,o,a,"price",f,h,s,v,y,g),u&&Os(e,n,r,o,a,f,h,v),d&&_s(e,t,r,o,a,f,h,v);return}if(i==="line"){C||b==="l3"?(l&&py(e,n,r,o,a,Nn.buyLine,"bid",f,h,s,v),c&&py(e,n,r,o,a,Nn.sellLine,"ask",f,h,s,v)):b==="ohlcv"&&py(e,n,r,o,a,"#1190b0","price",f,h,s,v,y,g),u&&Os(e,n,r,o,a,f,h,v),d&&_s(e,t,r,o,a,f,h,v);return}if(i==="hollow"||i==="heikin-ashi"||i==="bars"){if(s===0n)(b==="l3"||C)&&(l&&Ll(e,n,r,o,a,Nn.buyLine,"bid",f,h,0n,v),c&&Ll(e,n,r,o,a,Nn.sellLine,"ask",f,h,0n,v));else{let w=CO(t,r,s,h,p,g,y,v);i==="heikin-ashi"&&(w=kO(w)),i==="bars"?IO(e,w,o,a,f,v):TO(e,w,o,a,f,v,i==="hollow")}u&&Os(e,n,r,o,a,f,h,v),d&&_s(e,t,r,o,a,f,h,v);return}if(i==="baseline"){C||b==="l3"?GC(e,n,r,o,a,l||!c?"bid":"ask",f,h,s,v):b==="ohlcv"&&GC(e,n,r,o,a,"price",f,h,s,v,y,g),u&&Os(e,n,r,o,a,f,h,v),d&&_s(e,t,r,o,a,f,h,v);return}if(ok(i)){let w=vy(i,f,y,p,t,s);w&&(i==="renko"?RO(e,w,r,o,a,f,h,v):i==="kagi"?PO(e,w,r,o,a,f,h,v):DO(e,w,r,o,a,f,h,v)),u&&Os(e,n,r,o,a,f,h,v),d&&_s(e,t,r,o,a,f,h,v);return}b==="l3"||C?(l&&Ll(e,n,r,o,a,Nn.buyLine,"bid",f,h,s,v),c&&Ll(e,n,r,o,a,Nn.sellLine,"ask",f,h,s,v)):Ll(e,n,r,o,a,"#1190b0","price",f,h,s,v,y,g),u&&Os(e,n,r,o,a,f,h,v),d&&_s(e,t,r,o,a,f,h,v)}function py(e,t,n,r,o,a,i,s,l=0n,c,u,d,m){let f=u.makeTsToXFn(r),h=u.makePriceToYFn(o);if(i==="price"){if(!d.length)return;let p=Number(l/c*c/1000000n),g=Number(n.tMin/1000000n),y=0,v=d.length-1,b=-1;for(;y<=v;){let w=y+v>>>1;d[w].time<=g?(b=w,y=w+1):v=w-1}let S=b;e.beginPath(),e.strokeStyle=a,e.lineWidth=1.5,e.lineJoin="round";let C=!0;for(let w=S;w<d.length&&!(d[w].time>=p);w++){let k=d[w].close;if(k===0)continue;let M=f(BigInt(d[w].time*1e6)),I=h(k);if(C?(e.moveTo(M,I),C=!1):e.lineTo(M,I),M>r+100)break}e.lineTo(f(m.ts),h(m.close)),e.stroke()}else{if(t.length===0)return;let p=l>0n?l:n.tMax,g=Math.max(0,vd(t,n.tMin));e.beginPath(),e.strokeStyle=a,e.lineWidth=1.5,e.lineJoin="round";let y=!0;for(let v=g;v<t.length&&!(t[v].ts>p);v++){let b=i==="ask"?t[v].bestAsk:t[v].bestBid;if(b===0)continue;let S=f(t[v].ts),C=h(b);if(y?(e.moveTo(S,C),y=!1):e.lineTo(S,C),S>r+100)break}e.stroke()}}function hy(e,t,n,r,o,a,i,s=0n,l,c,u,d){let m=c.makeTsToXFn(r),f=c.makePriceToYFn(o);if(a==="price"){if(!u.length)return;let h=Number(s/l*l/1000000n),p="#1190b0",g=0,y=u.length-1,v=-1;for(;g<=y;){let w=g+y>>>1;u[w].time<=Number(n.tMin/1000000n)?(v=w,g=w+1):y=w-1}let b=Math.max(0,v),S=[];for(let w=b;w<u.length&&!(u[w].time>=h);w++){let k=u[w].close;if(k!==0&&(S.push({x:m(BigInt(u[w].time*1e6)),y:f(k)}),S[S.length-1].x>r+100))break}if(d&&S.push({x:m(d.ts),y:f(d.close)}),S.length<2)return;let C=e.createLinearGradient(0,0,0,o);C.addColorStop(0,"#1190b055"),C.addColorStop(1,"#1190b000"),e.beginPath(),e.moveTo(S[0].x,o);for(let w of S)e.lineTo(w.x,w.y);e.lineTo(S[S.length-1].x,o),e.closePath(),e.fillStyle=C,e.fill(),e.beginPath(),e.strokeStyle=p+"cc",e.lineWidth=1.5,e.lineJoin="round",e.moveTo(S[0].x,S[0].y);for(let w=1;w<S.length;w++)e.lineTo(S[w].x,S[w].y);e.stroke()}else{if(t.length===0)return;let h=s>0n?s:n.tMax,p=a==="bid",g=p?"#00e676":"#ff1744",y=Math.max(0,vd(t,n.tMin)),v=[];for(let S=y;S<t.length&&!(t[S].ts>h);S++){let C=p?t[S].bestBid:t[S].bestAsk;if(C!==0&&(v.push({x:m(t[S].ts),y:f(C)}),v[v.length-1].x>r+100))break}if(v.length<2)return;let b=e.createLinearGradient(0,0,0,o);b.addColorStop(0,"#1190b055"),b.addColorStop(1,"#1190b000"),e.beginPath(),e.moveTo(v[0].x,o);for(let S of v)e.lineTo(S.x,S.y);e.lineTo(v[v.length-1].x,o),e.closePath(),e.fillStyle=b,e.fill(),e.beginPath(),e.strokeStyle=g+"cc",e.lineWidth=1.5,e.lineJoin="round",e.moveTo(v[0].x,v[0].y);for(let S=1;S<v.length;S++)e.lineTo(v[S].x,v[S].y);e.stroke()}}function SO(e,t,n,r,o,a,i,s,l=0n,c=null,u=null,d,m){if(i===0n){Ll(e,n,r,o,a,Nn.buyLine,"bid",s,l,0n,m),Ll(e,n,r,o,a,Nn.sellLine,"ask",s,l,0n,m);return}let f=m.getSessionMapper(),h=m.getBarPx(o),p=Vn(),g=Math.max(1,Math.round(h*.8*p)),y=g/p,v=y/2,b=s?.upBodyColor??"#00e676",S=s?.downBodyColor??"#ff1744",C=s?.wickColorMatchesBody?b:s?.upWickColor??"#00e676aa",w=s?.wickColorMatchesBody?S:s?.downWickColor??"#ff1744aa",k=s?.borderWidth??1,M=s?.borderColorMatchesBody?b:s?.upBorderColor??"#00e676",I=s?.borderColorMatchesBody?S:s?.downBorderColor??"#ff1744",x=s?.wickWidth??1,T=[],R=[],P=m.makeTsToXFn(o),D=m.makePriceToYFn(a),N=(O,A)=>{let B=P(A);if(B<-v||B>o+v*2)return;let E=Math.round(B*p-g/2),L=E/p,z=$C((E+g/2)/p,x,p),Y=zp(Math.min(D(O.open),D(O.close)),p),G=zp(Math.max(D(O.open),D(O.close)),p),H={left:L,wickX:z,yHigh:D(O.high),yLow:D(O.low),bodyTop:Y,bodyH:Math.max(1/p,G-Y),hasWick:O.high!==O.low};(O.close>=O.open?T:R).push(H)};if(d.length){let O=l>0n?l/i*i:r.tMax,A=u?u.ts:-1n,B=Number(O/1000000n),E=A>0n?Number(A/1000000n):-1,L=f&&f.hasSession?f.segments.map(Z=>({startMs:Number(Z.realStart/1000000n),endMs:Number(Z.realEnd/1000000n)})):null,z=Number(i/1000000n),Y=Z=>{if(!L)return;let de=0,ze=L.length-1;for(;de<=ze;){let xe=de+ze>>>1;if(L[xe].endMs<=Z)de=xe+1;else if(L[xe].startMs>Z)ze=xe-1;else return L[xe]}},G=new Map,H=[],W=Number((r.tMin>i?r.tMin-i:0n)/1000000n),U=0;{let Z=0,de=d.length-1;for(;Z<=de;){let ze=Z+de>>>1;d[ze].time<W?Z=ze+1:de=ze-1}U=Z}let V=Number((r.tMax+i)/1000000n),K=Math.min(B,V);for(let Z=U;Z<d.length;Z++){let de=d[Z],ze=de.time;if(ze>=K)break;let xe,Ae=Y(ze);Ae?xe=Ae.startMs+Math.floor((ze-Ae.startMs)/z)*z:xe=Math.floor(ze/z)*z;let Oe=G.get(xe);Oe?(de.high>Oe.high&&(Oe.high=de.high),de.low<Oe.low&&(Oe.low=de.low),Oe.close=de.close,Oe.volume+=de.volume):(G.set(xe,{open:de.open,high:de.high,low:de.low,close:de.close,volume:de.volume}),H.push(xe))}for(let Z of H){let de=BigInt(Z)*1000000n;if(Z===E&&u)N(u,de);else{let ze=G.get(Z);N(ze,de)}}u&&E!==-1&&(H.length>0?H[H.length-1]:-1)<E&&E<Number(l/1000000n)&&N(u,A)}if(c!==null){let O=l>0n?l:r.tMax,A=u?u.ts:-1n,B=r.tMin/i*i,E=O/i*i;if(f&&f.hasSession)for(let L of f.segments){if(L.realEnd<r.tMin||L.realStart>=O)continue;let Y=(r.tMin>L.realStart?r.tMin:L.realStart)-L.realStart,G=L.realStart+Y/i*i,H=O<L.realEnd?O:L.realEnd;for(let W=G;W<H;W+=i)if(!(W+i===A&&u)){let U=c.get(W);U&&N(U,W)}}else for(let L=B;L<=E;L+=i)if(L===A&&u)N(u,L);else{let z=c.get(L);z&&N(z,L)}}else{let O=l>0n?l:r.tMax,A=t.length;{let L=0,z=t.length-1;for(;L<=z;){let Y=L+z>>>1;t[Y].ts<O?L=Y+1:(A=Y,z=Y-1)}}let B=A<t.length?t.slice(0,A):t,E=by(B,i);for(let L of E)L.ts+i<r.tMin||L.ts>r.tMax||N(L,L.ts)}for(let[O,A]of[[T,C],[R,w]])if(O.length){e.strokeStyle=A,e.lineWidth=Hp(x,p),e.beginPath();for(let B of O)B.hasWick&&(e.moveTo(B.wickX,B.yHigh),e.lineTo(B.wickX,B.bodyTop),e.moveTo(B.wickX,B.bodyTop+B.bodyH),e.lineTo(B.wickX,B.yLow));e.stroke()}for(let[O,A]of[[T,b],[R,S]])if(O.length){e.fillStyle=A,e.beginPath();for(let B of O)e.rect(B.left,B.bodyTop,y,B.bodyH);e.fill()}if(k>0){let O=Hp(k,p);for(let[A,B]of[[T,M],[R,I]])if(A.length){e.strokeStyle=B,e.lineWidth=O,e.beginPath();for(let E of A)e.rect(E.left+O/2,E.bodyTop+O/2,y-O,E.bodyH-O);e.stroke()}}}function CO(e,t,n,r,o,a,i,s){let l=[];if(n===0n)return l;let c=s.getSessionMapper();if(i.length){let u=r>0n?r/n*n:t.tMax,d=a?a.ts:-1n,m=Number(u/1000000n),f=d>0n?Number(d/1000000n):-1,h=c&&c.hasSession?c.segments.map(k=>({startMs:Number(k.realStart/1000000n),endMs:Number(k.realEnd/1000000n)})):null,p=Number(n/1000000n),g=k=>{if(!h)return;let M=0,I=h.length-1;for(;M<=I;){let x=M+I>>>1;if(h[x].endMs<=k)M=x+1;else if(h[x].startMs>k)I=x-1;else return h[x]}},y=new Map,v=[],b=Number((t.tMin>n?t.tMin-n:0n)/1000000n),S=0;{let k=0,M=i.length-1;for(;k<=M;){let I=k+M>>>1;i[I].time<b?k=I+1:M=I-1}S=k}let C=Number((t.tMax+n)/1000000n),w=Math.min(m,C);for(let k=S;k<i.length;k++){let M=i[k],I=M.time;if(I>=w)break;let x,T=g(I);T?x=T.startMs+Math.floor((I-T.startMs)/p)*p:x=Math.floor(I/p)*p;let R=y.get(x);R?(M.high>R.high&&(R.high=M.high),M.low<R.low&&(R.low=M.low),R.close=M.close):(y.set(x,{open:M.open,high:M.high,low:M.low,close:M.close}),v.push(x))}for(let k of v){let M=BigInt(k)*1000000n;if(k===f&&a)l.push({ts:M,open:a.open,high:a.high,low:a.low,close:a.close});else{let I=y.get(k);l.push({ts:M,open:I.open,high:I.high,low:I.low,close:I.close})}}a&&f!==-1&&(v.length>0?v[v.length-1]:-1)<f&&f<Number(r/1000000n)&&l.push({ts:d,open:a.open,high:a.high,low:a.low,close:a.close})}else if(o!==null){let u=r>0n?r:t.tMax,d=a?a.ts:-1n,m=t.tMin/n*n,f=u/n*n,h=(p,g)=>l.push({ts:g,open:p.open,high:p.high,low:p.low,close:p.close});if(c&&c.hasSession)for(let p of c.segments){if(p.realEnd<t.tMin||p.realStart>=u)continue;let y=(t.tMin>p.realStart?t.tMin:p.realStart)-p.realStart,v=p.realStart+y/n*n,b=u<p.realEnd?u:p.realEnd;for(let S=v;S<b;S+=n){let C=o.get(S);C&&h(C,S)}}else for(let p=m;p<=f;p+=n)if(p===d&&a)h(a,p);else{let g=o.get(p);g&&h(g,p)}}else{let u=r>0n?r:t.tMax,d=e.length;{let f=0,h=e.length-1;for(;f<=h;){let p=f+h>>>1;e[p].ts<u?f=p+1:(d=p,h=p-1)}}let m=d<e.length?e.slice(0,d):e;for(let f of by(m,n))f.ts+n<t.tMin||f.ts>t.tMax||l.push({ts:f.ts,open:f.open,high:f.high,low:f.low,close:f.close})}return l}function kO(e){let t=[],n=0,r=0;for(let o=0;o<e.length;o++){let a=e[o],i=(a.open+a.high+a.low+a.close)/4,s=o===0?(a.open+a.close)/2:(n+r)/2,l=Math.max(a.high,s,i),c=Math.min(a.low,s,i);t.push({ts:a.ts,open:s,high:l,low:c,close:i}),n=s,r=i}return t}function TO(e,t,n,r,o,a,i=!1){if(!t.length)return;let s=a.getBarPx(n),l=Vn(),c=Math.max(1,Math.round(s*.8*l)),u=c/l,d=u/2,m=a.makeTsToXFn(n),f=a.makePriceToYFn(r),h=o?.upBodyColor??"#00e676",p=o?.downBodyColor??"#ff1744",g=o?.wickColorMatchesBody?h:o?.upWickColor??"#00e676aa",y=o?.wickColorMatchesBody?p:o?.downWickColor??"#ff1744aa",v=o?.borderWidth??1,b=o?.borderColorMatchesBody?h:o?.upBorderColor??"#00e676",S=o?.borderColorMatchesBody?p:o?.downBorderColor??"#ff1744",C=o?.wickWidth??1,w=[],k=[];for(let I of t){let x=m(I.ts);if(x<-d||x>n+d*2)continue;let T=Math.round(x*l-c/2),R=T/l,P=$C((T+c/2)/l,C,l),D=zp(Math.min(f(I.open),f(I.close)),l),N=zp(Math.max(f(I.open),f(I.close)),l);(I.close>=I.open?w:k).push({left:R,wickX:P,yHigh:f(I.high),yLow:f(I.low),bodyTop:D,bodyH:Math.max(1/l,N-D),hasWick:I.high!==I.low})}for(let[I,x]of[[w,g],[k,y]])if(I.length){e.strokeStyle=x,e.lineWidth=Hp(C,l),e.beginPath();for(let T of I)T.hasWick&&(e.moveTo(T.wickX,T.yHigh),e.lineTo(T.wickX,T.bodyTop),e.moveTo(T.wickX,T.bodyTop+T.bodyH),e.lineTo(T.wickX,T.yLow));e.stroke()}let M=i?[[k,p]]:[[w,h],[k,p]];for(let[I,x]of M)if(I.length){e.fillStyle=x,e.beginPath();for(let T of I)e.rect(T.left,T.bodyTop,u,T.bodyH);e.fill()}if(v>0||i){let I=Hp(Math.max(1,v),l);for(let[x,T]of[[w,b],[k,S]])if(x.length){e.strokeStyle=T,e.lineWidth=I,e.beginPath();for(let R of x)e.rect(R.left+I/2,R.bodyTop+I/2,u-I,R.bodyH-I);e.stroke()}}}function IO(e,t,n,r,o,a){if(!t.length)return;let i=a.getBarPx(n),s=Math.max(1,Math.floor(i*.4)),l=a.makeTsToXFn(n),c=a.makePriceToYFn(r),u=o?.upBodyColor??"#00e676",d=o?.downBodyColor??"#ff1744",m=Math.max(1,o?.wickWidth??1),f=[],h=[];for(let p of t){let g=l(p.ts);g<-s||g>n+s||(p.close>=p.open?f:h).push(p)}for(let[p,g]of[[f,u],[h,d]])if(p.length){e.strokeStyle=g,e.lineWidth=m,e.beginPath();for(let y of p){let v=Math.floor(l(y.ts))+.5;e.moveTo(v,c(y.high)),e.lineTo(v,c(y.low));let b=c(y.open);e.moveTo(v-s,b),e.lineTo(v,b);let S=c(y.close);e.moveTo(v,S),e.lineTo(v+s,S)}e.stroke()}}function GC(e,t,n,r,o,a,i,s=0n,l,c,u,d){let m=c.makeTsToXFn(r),f=c.makePriceToYFn(o),h=[],p=i.baselineValue;if(a==="price"){if(!u||!u.length||l===0n)return;let x=s>0n?Number(s/l*l/1000000n):Number(n.tMax/1000000n);if(p==null){for(let N=0;N<u.length;N++)if(u[N].close!==0){p=u[N].close;break}}let T=Number(n.tMin/1000000n),R=0,P=u.length-1,D=-1;for(;R<=P;){let N=R+P>>>1;u[N].time<=T?(D=N,R=N+1):P=N-1}for(let N=Math.max(0,D);N<u.length&&!(u[N].time>=x);N++){let O=u[N].close;if(O!==0&&(h.push({x:m(BigInt(u[N].time*1e6)),price:O}),h[h.length-1].x>r+100))break}d&&Number(d.ts/1000000n)<x&&h.push({x:m(d.ts),price:d.close})}else{if(!t.length)return;let x=s>0n?s:n.tMax,T=a==="bid";if(p==null)for(let R=0;R<t.length;R++){let P=T?t[R].bestBid:t[R].bestAsk;if(P!==0){p=P;break}}for(let R=Math.max(0,vd(t,n.tMin));R<t.length&&!(t[R].ts>x);R++){let P=T?t[R].bestBid:t[R].bestAsk;if(P!==0&&(h.push({x:m(t[R].ts),price:P}),h[h.length-1].x>r+100))break}}if(h.length<2||p==null)return;let g=f(p),y=bd(i.upBodyColor??"#00e676"),v=bd(i.downBodyColor??"#ff1744"),b=h.map(x=>({x:x.x,y:f(x.price)})),S=()=>{e.beginPath(),e.moveTo(b[0].x,g);for(let x of b)e.lineTo(x.x,x.y);e.lineTo(b[b.length-1].x,g),e.closePath()},C=()=>{e.beginPath(),e.moveTo(b[0].x,b[0].y);for(let x=1;x<b.length;x++)e.lineTo(b[x].x,b[x].y)},w=e.createLinearGradient(0,0,0,Math.max(g,1));w.addColorStop(0,y+"55"),w.addColorStop(1,y+"08");let k=e.createLinearGradient(0,g,0,o);k.addColorStop(0,v+"08"),k.addColorStop(1,v+"55");let M=(x,T,R)=>{T<=0||(e.save(),e.beginPath(),e.rect(0,x,r,T),e.clip(),S(),e.fillStyle=R,e.fill(),e.restore())};M(0,g,w),M(g,o-g,k);let I=(x,T,R)=>{T<=0||(e.save(),e.beginPath(),e.rect(0,x,r,T),e.clip(),e.lineWidth=1.5,e.lineJoin="round",C(),e.strokeStyle=R,e.stroke(),e.restore())};I(0,g,y),I(g,o-g,v),e.save(),e.beginPath(),e.setLineDash([4,4]),e.strokeStyle="#75869688",e.lineWidth=1,e.moveTo(0,Math.round(g)+.5),e.lineTo(r,Math.round(g)+.5),e.stroke(),e.restore()}var YC=new WeakMap;function MO(e,t,n,r){let o=(a,i,s)=>{let l=YC.get(a);if(l&&l.sig===i)return l.series;let c=s();return YC.set(a,{sig:i,series:c}),c};if(e&&e.length){let a=e[e.length-1];return o(e,`o:${e.length}:${a.time}`,()=>{let i=[];for(let s of e)s.close!==0&&i.push({ts:BigInt(s.time*1e6),price:s.close});return i})}if(t&&t.size)return o(t,`c:${t.size}`,()=>{let a=Array.from(t.keys()).sort((s,l)=>s<l?-1:1),i=[];for(let s of a){let l=t.get(s);l.close!==0&&i.push({ts:s,price:l.close})}return i});if(n&&n.length){let a=n[n.length-1];return o(n,`t:${n.length}:${a.ts}`,()=>{let i=[];for(let s of n)i.push({ts:s.ts,price:s.price});return i})}return[]}var KC=new WeakMap;function LO(e,t,n){let r=KC.get(e);r||(r=new Map,KC.set(e,r));let o=r.get(t);if(o!==void 0)return o;let a=n();return r.size>6&&r.clear(),r.set(t,a),a}function ok(e){return e==="renko"||e==="kagi"||e==="line-break"}function vy(e,t,n,r,o,a){if(!ok(e))return null;let i=MO(n,r,o,a);if(i.length<2)return null;let s;return e==="renko"?s=t.renkoBrickSize??fy(i):e==="kagi"?s=t.kagiReversal??fy(i)*2:s=Math.max(1,t.lineBreakCount||3),LO(i,`model:${e}:${s}`,()=>EC(e,i,s))}function ak(e,t){let n=e.columnTs.length;if(n===0)return null;let r=t.getView(),o=Math.max(0,Math.floor(t.tsToFracIndex(r.tMin))),a=Math.min(n-1,Math.ceil(t.tsToFracIndex(r.tMax)));if(a<o)return null;let i=1/0,s=-1/0;for(let l=o;l<=a;l++)e.pLow[l]<i&&(i=e.pLow[l]),e.pHigh[l]>s&&(s=e.pHigh[l]);return Number.isFinite(i)&&Number.isFinite(s)?{min:i,max:s}:null}function wy(e,t,n){let r=Math.max(0,Math.floor(e.xToIndex(0,t))-1),o=Math.min(n-1,Math.ceil(e.xToIndex(t,t))+1);return[r,o]}function RO(e,t,n,r,o,a,i,s){let l=t.bricks;if(!l.length)return;let c=s.makeIndexToXFn(r),u=s.makePriceToYFn(o),d=Math.max(2,s.getBarPx(r)*.9),m=d/2,f=i>0n?i:n.tMax,[h,p]=wy(s,r,l.length),g=[],y=[];for(let b=h;b<=p;b++){let S=l[b];if(S.ts>f)break;let C=c(b),w=u(S.yHigh);(S.dir>0?g:y).push({x:C,yTop:w,hgt:u(S.yLow)-w})}let v=(b,S,C)=>{if(b.length){e.fillStyle=S,e.beginPath();for(let w of b)e.rect(w.x-m,w.yTop,d,w.hgt);e.fill(),e.strokeStyle=C,e.lineWidth=1,e.beginPath();for(let w of b)e.rect(w.x-m+.5,w.yTop+.5,d-1,w.hgt-1);e.stroke()}};v(g,a.upBodyColor??"#00e676",a.upBorderColor??"#00e676"),v(y,a.downBodyColor??"#ff1744",a.downBorderColor??"#ff1744")}function PO(e,t,n,r,o,a,i,s){let l=t.kagiSegments;if(!l.length)return;let c=t.columnTs,u=s.makeIndexToXFn(r),d=s.makePriceToYFn(o),m=i>0n?i:n.tMax,f=a.upBodyColor??"#00e676",h=a.downBodyColor??"#ff1744",[p,g]=wy(s,r,c.length),y=v=>{e.strokeStyle=v?f:h,e.lineWidth=v?2.5:1.25,e.lineJoin="round",e.lineCap="round",e.beginPath();for(let b of l)b.yang===v&&(c[b.i2]>m||b.i2<p||b.i1>g||(e.moveTo(u(b.i1),d(b.y1)),e.lineTo(u(b.i2),d(b.y2))));e.stroke()};y(!1),y(!0),e.lineCap="butt"}function DO(e,t,n,r,o,a,i,s){let l=t.boxes;if(!l.length)return;let c=s.makeIndexToXFn(r),u=s.makePriceToYFn(o),d=Math.max(2,s.getBarPx(r)*.9),m=d/2,f=i>0n?i:n.tMax,[h,p]=wy(s,r,l.length),g=[],y=[];for(let b=h;b<=p;b++){let S=l[b];if(S.ts>f)break;let C=c(b),w=u(Math.max(S.open,S.close)),k=Math.max(1,u(Math.min(S.open,S.close))-w);(S.dir>0?g:y).push({x:C,yTop:w,hgt:k})}let v=(b,S,C)=>{if(b.length){e.fillStyle=S,e.beginPath();for(let w of b)e.rect(w.x-m,w.yTop,d,w.hgt);e.fill(),e.strokeStyle=C,e.lineWidth=1,e.beginPath();for(let w of b)e.rect(w.x-m+.5,w.yTop+.5,d-1,w.hgt-1);e.stroke()}};v(g,a.upBodyColor??"#00e676",a.upBorderColor??"#00e676"),v(y,a.downBodyColor??"#ff1744",a.downBorderColor??"#ff1744")}import{forwardRef as NO,createElement as EO}from"react";var ik=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),AO=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),xy=e=>{let t=AO(e);return t.charAt(0).toUpperCase()+t.slice(1)},qp=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),sk=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};import{forwardRef as BO,createElement as ck}from"react";var lk={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var uk=BO(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:a,iconNode:i,...s},l)=>ck("svg",{ref:l,...lk,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:qp("lucide",o),...!a&&!sk(s)&&{"aria-hidden":"true"},...s},[...i.map(([c,u])=>ck(c,u)),...Array.isArray(a)?a:[a]]));var ne=(e,t)=>{let n=NO(({className:r,...o},a)=>EO(uk,{ref:a,iconNode:t,className:qp(`lucide-${ik(xy(e))}`,`lucide-${e}`,r),...o}));return n.displayName=xy(e),n};var OO=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Sd=ne("activity",OO);var _O=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]],Cd=ne("align-center-vertical",_O);var FO=[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],kd=ne("align-center",FO);var zO=[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]],Td=ne("align-end-vertical",zO);var HO=[["rect",{width:"6",height:"10",x:"9",y:"7",rx:"2",key:"yn7j0q"}],["path",{d:"M4 22V2",key:"tsjzd3"}],["path",{d:"M20 22V2",key:"1bnhr8"}]],Id=ne("align-horizontal-space-around",HO);var VO=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Md=ne("align-left",VO);var WO=[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Ld=ne("align-right",WO);var qO=[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]],Rd=ne("align-start-vertical",qO);var UO=[["rect",{width:"10",height:"6",x:"7",y:"9",rx:"2",key:"b1zbii"}],["path",{d:"M22 20H2",key:"1p1f7z"}],["path",{d:"M22 4H2",key:"1b7qnq"}]],Pd=ne("align-vertical-space-around",UO);var jO=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],Dd=ne("arrow-down-right",jO);var GO=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ad=ne("arrow-down",GO);var YO=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],Bd=ne("arrow-left-right",YO);var KO=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Nd=ne("arrow-up-right",KO);var $O=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ed=ne("arrow-up",$O);var XO=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],Zc=ne("bold",XO);var ZO=[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],Qc=ne("book-marked",ZO);var QO=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Od=ne("camera",QO);var JO=[["path",{d:"M9 5v4",key:"14uxtq"}],["rect",{width:"4",height:"6",x:"7",y:"9",rx:"1",key:"f4fvz0"}],["path",{d:"M9 15v2",key:"r5rk32"}],["path",{d:"M17 3v2",key:"1l2re6"}],["rect",{width:"4",height:"8",x:"15",y:"5",rx:"1",key:"z38je5"}],["path",{d:"M17 13v3",key:"5l0wba"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]],Fs=ne("chart-candlestick",JO);var e_=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],zs=ne("chart-line",e_);var t_=[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]],Ai=ne("chart-no-axes-column",t_);var n_=[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]],_d=ne("chart-no-axes-combined",n_);var r_=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Or=ne("check",r_);var o_=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Zn=ne("chevron-down",o_);var a_=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Rl=ne("chevron-left",a_);var i_=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Zi=ne("chevron-right",i_);var s_=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],oi=ne("chevron-up",s_);var l_=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Fd=ne("chevrons-down-up",l_);var c_=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],zd=ne("chevrons-down",c_);var u_=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Hd=ne("chevrons-up-down",u_);var d_=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Vd=ne("chevrons-up",d_);var f_=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Hs=ne("circle-check",f_);var m_=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ai=ne("circle-question-mark",m_);var p_=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Pl=ne("circle",p_);var h_=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Dl=ne("copy",h_);var g_=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Wd=ne("cpu",g_);var b_=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],qd=ne("database",b_);var y_=[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]],Vs=ne("dot",y_);var v_=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Ud=ne("download",v_);var w_=[["path",{d:"m12.99 6.74 1.93 3.44",key:"iwagvd"}],["path",{d:"M19.136 12a10 10 0 0 1-14.271 0",key:"ppmlo4"}],["path",{d:"m21 21-2.16-3.84",key:"vylbct"}],["path",{d:"m3 21 8.02-14.26",key:"1ssaw4"}],["circle",{cx:"12",cy:"5",r:"2",key:"f1ur92"}]],jd=ne("drafting-compass",w_);var x_=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Ws=ne("ellipsis",x_);var S_=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Bi=ne("eye-off",S_);var C_=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Da=ne("eye",C_);var k_=[["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]],qs=ne("file-question-mark",k_);var T_=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Gd=ne("flask-conical",T_);var I_=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Yd=ne("gauge",I_);var M_=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Al=ne("globe",M_);var L_=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],ii=ne("grid-3x3",L_);var R_=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Bl=ne("grip-vertical",R_);var P_=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Jc=ne("info",P_);var D_=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],eu=ne("italic",D_);var A_=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],si=ne("layers",A_);var B_=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Kd=ne("layout-dashboard",B_);var N_=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],$d=ne("layout-grid",N_);var E_=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],tu=ne("link-2",E_);var O_=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ni=ne("loader-circle",O_);var __=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],Ei=ne("lock-open",__);var F_=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],jr=ne("lock",F_);var z_=[["path",{d:"m12 15 4 4",key:"lnac28"}],["path",{d:"M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z",key:"nlhkjb"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}]],Xd=ne("magnet",z_);var H_=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Zd=ne("map-pin",H_);var V_=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Qd=ne("maximize-2",V_);var W_=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Jd=ne("minimize-2",W_);var q_=[["path",{d:"M5 12h14",key:"1ays0h"}]],Yo=ne("minus",q_);var U_=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],ef=ne("monitor",U_);var j_=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Us=ne("palette",j_);var G_=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],js=ne("panel-left-close",G_);var Y_=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Gs=ne("panel-left-open",Y_);var K_=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],tf=ne("pin",K_);var $_=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],nf=ne("pin-off",$_);var X_=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],Nl=ne("plug",X_);var Z_=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ha=ne("plus",Z_);var Q_=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],Ko=ne("puzzle",Q_);var J_=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],rf=ne("refresh-cw",J_);var eF=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],ga=ne("rotate-ccw",eF);var tF=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],of=ne("ruler",tF);var nF=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],af=ne("save",nF);var rF=[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],sf=ne("search-x",rF);var oF=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],li=ne("search",oF);var aF=[["path",{d:"M6 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2",key:"4b9dqc"}],["path",{d:"M6 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-2",key:"22nnkd"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m13 6-4 6h6l-4 6",key:"14hqih"}]],lf=ne("server-crash",aF);var iF=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],cf=ne("settings-2",iF);var sF=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],El=ne("settings",sF);var lF=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],uf=ne("shield",lF);var cF=[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]],df=ne("sliders-horizontal",cF);var uF=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]],Ys=ne("square-function",uF);var dF=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Ol=ne("star",dF);var fF=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ff=ne("target",fF);var mF=[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]],nu=ne("ticket",mF);var pF=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],mf=ne("timer",pF);var hF=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ho=ne("trash-2",hF);var gF=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],pf=ne("trending-down",gF);var bF=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],_l=ne("trending-up",bF);var yF=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ba=ne("triangle-alert",yF);var vF=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Fl=ne("type",vF);var wF=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],hf=ne("unlink",wF);var xF=[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]],gf=ne("waves",xF);var SF=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],bf=ne("wifi-off",SF);var CF=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],_r=ne("x",CF);import{useEffect as vk,useRef as t5,useState as wk}from"react";function dk(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=dk(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Up(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=dk(e))&&(r&&(r+=" "),r+=t);return r}var kF=e=>{let t=IF(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{let s=i.split("-");return s[0]===""&&s.length!==1&&s.shift(),pk(s,t)||TF(i)},getConflictingClassGroupIds:(i,s)=>{let l=n[i]||[];return s&&r[i]?[...l,...r[i]]:l}}},pk=(e,t)=>{if(e.length===0)return t.classGroupId;let n=e[0],r=t.nextPart.get(n),o=r?pk(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;let a=e.join("-");return t.validators.find(({validator:i})=>i(a))?.classGroupId},fk=/^\[(.+)\]$/,TF=e=>{if(fk.test(e)){let t=fk.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},IF=e=>{let{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return LF(Object.entries(e.classGroups),n).forEach(([a,i])=>{Cy(i,r,a,t)}),r},Cy=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){let a=o===""?t:mk(t,o);a.classGroupId=n;return}if(typeof o=="function"){if(MF(o)){Cy(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([a,i])=>{Cy(i,mk(t,a),n,r)})})},mk=(e,t)=>{let n=e;return t.split("-").forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},MF=e=>e.isThemeGetter,LF=(e,t)=>t?e.map(([n,r])=>{let o=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([i,s])=>[t+i,s])):a);return[n,o]}):e,RF=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map,o=(a,i)=>{n.set(a,i),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let i=n.get(a);if(i!==void 0)return i;if((i=r.get(a))!==void 0)return o(a,i),i},set(a,i){n.has(a)?n.set(a,i):o(a,i)}}};var PF=e=>{let{separator:t,experimentalParseClassName:n}=e,r=t.length===1,o=t[0],a=t.length,i=s=>{let l=[],c=0,u=0,d;for(let g=0;g<s.length;g++){let y=s[g];if(c===0){if(y===o&&(r||s.slice(g,g+a)===t)){l.push(s.slice(u,g)),u=g+a;continue}if(y==="/"){d=g;continue}}y==="["?c++:y==="]"&&c--}let m=l.length===0?s:s.substring(u),f=m.startsWith("!"),h=f?m.substring(1):m,p=d&&d>u?d-u:void 0;return{modifiers:l,hasImportantModifier:f,baseClassName:h,maybePostfixModifierPosition:p}};return n?s=>n({className:s,parseClassName:i}):i},DF=e=>{if(e.length<=1)return e;let t=[],n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},AF=e=>({cache:RF(e.cacheSize),parseClassName:PF(e),...kF(e)}),BF=/\s+/,NF=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o}=t,a=[],i=e.trim().split(BF),s="";for(let l=i.length-1;l>=0;l-=1){let c=i[l],{modifiers:u,hasImportantModifier:d,baseClassName:m,maybePostfixModifierPosition:f}=n(c),h=!!f,p=r(h?m.substring(0,f):m);if(!p){if(!h){s=c+(s.length>0?" "+s:s);continue}if(p=r(m),!p){s=c+(s.length>0?" "+s:s);continue}h=!1}let g=DF(u).join(":"),y=d?g+"!":g,v=y+p;if(a.includes(v))continue;a.push(v);let b=o(p,h);for(let S=0;S<b.length;++S){let C=b[S];a.push(y+C)}s=c+(s.length>0?" "+s:s)}return s};function EF(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=hk(t))&&(r&&(r+=" "),r+=n);return r}var hk=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=hk(e[r]))&&(n&&(n+=" "),n+=t);return n};function OF(e,...t){let n,r,o,a=i;function i(l){let c=t.reduce((u,d)=>d(u),e());return n=AF(c),r=n.cache.get,o=n.cache.set,a=s,s(l)}function s(l){let c=r(l);if(c)return c;let u=NF(l,n);return o(l,u),u}return function(){return a(EF.apply(null,arguments))}}var wr=e=>{let t=n=>n[e]||[];return t.isThemeGetter=!0,t},gk=/^\[(?:([a-z-]+):)?(.+)\]$/i,_F=/^\d+\/\d+$/,FF=new Set(["px","full","screen"]),zF=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,HF=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,VF=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,WF=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,qF=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Qi=e=>ru(e)||FF.has(e)||_F.test(e),Ks=e=>ou(e,"length",ZF),ru=e=>!!e&&!Number.isNaN(Number(e)),Sy=e=>ou(e,"number",ru),yf=e=>!!e&&Number.isInteger(Number(e)),UF=e=>e.endsWith("%")&&ru(e.slice(0,-1)),vn=e=>gk.test(e),$s=e=>zF.test(e),jF=new Set(["length","size","percentage"]),GF=e=>ou(e,jF,bk),YF=e=>ou(e,"position",bk),KF=new Set(["image","url"]),$F=e=>ou(e,KF,JF),XF=e=>ou(e,"",QF),vf=()=>!0,ou=(e,t,n)=>{let r=gk.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},ZF=e=>HF.test(e)&&!VF.test(e),bk=()=>!1,QF=e=>WF.test(e),JF=e=>qF.test(e);var e5=()=>{let e=wr("colors"),t=wr("spacing"),n=wr("blur"),r=wr("brightness"),o=wr("borderColor"),a=wr("borderRadius"),i=wr("borderSpacing"),s=wr("borderWidth"),l=wr("contrast"),c=wr("grayscale"),u=wr("hueRotate"),d=wr("invert"),m=wr("gap"),f=wr("gradientColorStops"),h=wr("gradientColorStopPositions"),p=wr("inset"),g=wr("margin"),y=wr("opacity"),v=wr("padding"),b=wr("saturate"),S=wr("scale"),C=wr("sepia"),w=wr("skew"),k=wr("space"),M=wr("translate"),I=()=>["auto","contain","none"],x=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto",vn,t],R=()=>[vn,t],P=()=>["",Qi,Ks],D=()=>["auto",ru,vn],N=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],O=()=>["solid","dashed","dotted","double","none"],A=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],B=()=>["start","end","center","between","around","evenly","stretch"],E=()=>["","0",vn],L=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[ru,vn];return{cacheSize:500,separator:":",theme:{colors:[vf],spacing:[Qi,Ks],blur:["none","",$s,vn],brightness:z(),borderColor:[e],borderRadius:["none","","full",$s,vn],borderSpacing:R(),borderWidth:P(),contrast:z(),grayscale:E(),hueRotate:z(),invert:E(),gap:R(),gradientColorStops:[e],gradientColorStopPositions:[UF,Ks],inset:T(),margin:T(),opacity:z(),padding:R(),saturate:z(),scale:z(),sepia:E(),skew:z(),space:R(),translate:R()},classGroups:{aspect:[{aspect:["auto","square","video",vn]}],container:["container"],columns:[{columns:[$s]}],"break-after":[{"break-after":L()}],"break-before":[{"break-before":L()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...N(),vn]}],overflow:[{overflow:x()}],"overflow-x":[{"overflow-x":x()}],"overflow-y":[{"overflow-y":x()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",yf,vn]}],basis:[{basis:T()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",vn]}],grow:[{grow:E()}],shrink:[{shrink:E()}],order:[{order:["first","last","none",yf,vn]}],"grid-cols":[{"grid-cols":[vf]}],"col-start-end":[{col:["auto",{span:["full",yf,vn]},vn]}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":[vf]}],"row-start-end":[{row:["auto",{span:[yf,vn]},vn]}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",vn]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",vn]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...B()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...B(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...B(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[k]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[k]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",vn,t]}],"min-w":[{"min-w":[vn,t,"min","max","fit"]}],"max-w":[{"max-w":[vn,t,"none","full","min","max","fit","prose",{screen:[$s]},$s]}],h:[{h:[vn,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[vn,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[vn,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[vn,t,"auto","min","max","fit"]}],"font-size":[{text:["base",$s,Ks]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Sy]}],"font-family":[{font:[vf]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",vn]}],"line-clamp":[{"line-clamp":["none",ru,Sy]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Qi,vn]}],"list-image":[{"list-image":["none",vn]}],"list-style-type":[{list:["none","disc","decimal",vn]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[y]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...O(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Qi,Ks]}],"underline-offset":[{"underline-offset":["auto",Qi,vn]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",vn]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",vn]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[y]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...N(),YF]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",GF]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},$F]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[h]}],"gradient-via-pos":[{via:[h]}],"gradient-to-pos":[{to:[h]}],"gradient-from":[{from:[f]}],"gradient-via":[{via:[f]}],"gradient-to":[{to:[f]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[s]}],"border-w-x":[{"border-x":[s]}],"border-w-y":[{"border-y":[s]}],"border-w-s":[{"border-s":[s]}],"border-w-e":[{"border-e":[s]}],"border-w-t":[{"border-t":[s]}],"border-w-r":[{"border-r":[s]}],"border-w-b":[{"border-b":[s]}],"border-w-l":[{"border-l":[s]}],"border-opacity":[{"border-opacity":[y]}],"border-style":[{border:[...O(),"hidden"]}],"divide-x":[{"divide-x":[s]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[s]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[y]}],"divide-style":[{divide:O()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...O()]}],"outline-offset":[{"outline-offset":[Qi,vn]}],"outline-w":[{outline:[Qi,Ks]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[y]}],"ring-offset-w":[{"ring-offset":[Qi,Ks]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",$s,XF]}],"shadow-color":[{shadow:[vf]}],opacity:[{opacity:[y]}],"mix-blend":[{"mix-blend":[...A(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":A()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",$s,vn]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[b]}],sepia:[{sepia:[C]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[y]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[C]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",vn]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",vn]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",vn]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[yf,vn]}],"translate-x":[{"translate-x":[M]}],"translate-y":[{"translate-y":[M]}],"skew-x":[{"skew-x":[w]}],"skew-y":[{"skew-y":[w]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",vn]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",vn]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",vn]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Qi,Ks,Sy]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}};var yk=OF(e5);function ee(...e){return yk(Up(e))}import{Fragment as xf,jsx as cn,jsxs as ui}from"react/jsx-runtime";function au({children:e}){return cn("div",{className:"px-3 pt-2 pb-0.5 text-[9px] text-white/30 uppercase tracking-widest select-none first:pt-2",children:e})}function wf(){return cn("div",{className:" mx-2 h-px bg-white/6"})}function ci({icon:e,children:t,shortcut:n,onClick:r,destructive:o=!1}){return ui("button",{onClick:r,className:ee("w-full flex items-center gap-2 px-2.5 py-[5px] rounded-md text-[11px] text-left transition-colors duration-100 hover:duration-0 select-none",o?"text-red-400/70 hover:text-red-300 hover:bg-red-500/[0.10]":"text-white/55 hover:text-white hover:bg-muted/50"),children:[e&&cn("span",{className:ee("shrink-0",o?"text-red-400/50":"text-white/30"),children:e}),cn("span",{className:"flex-1",children:t}),n&&cn("span",{className:"text-[10px] text-white/25 ml-auto pl-3",children:n})]})}function n5(e,t,n,r){let o=[],a=e>=t&&e<=n,i=e>n,s=e<t;return a&&(o.push({side:"long",type:"market",label:"Buy 1.00 Market",icon:cn(oi,{size:15})}),o.push({side:"short",type:"market",label:"Sell 1.00 Market",icon:cn(Zn,{size:15})})),i&&(o.push({side:"short",type:"limit",limitPrice:e,label:`Sell 1.00 @${e} Limit`,icon:cn(Zn,{size:15})}),o.push({side:"long",type:"stop",stopPrice:e,label:`Buy 1.00 @${e} Stop`,icon:cn(oi,{size:15})}),o.push({side:"long",type:"stop_limit",stopPrice:e,limitPrice:Math.round((e+r)*1e8)/1e8,label:`Buy 1.00 Stop ${e} \u2192 Limit ${Math.round((e+r)*1e8)/1e8}`,icon:cn(Vd,{size:15})})),s&&(o.push({side:"long",type:"limit",limitPrice:e,label:`Buy 1.00 @${e} Limit`,icon:cn(oi,{size:15})}),o.push({side:"short",type:"stop",stopPrice:e,label:`Sell 1.00 @${e} Stop`,icon:cn(Zn,{size:15})}),o.push({side:"short",type:"stop_limit",stopPrice:e,limitPrice:e-r,label:`Sell 1.00 Stop ${e} \u2192 Limit ${Math.round((e-r)*1e8)/1e8}`,icon:cn(zd,{size:15})})),o}function xk({x:e,y:t,target:n,priceAtClick:r,currentAsk:o,currentBid:a,indicators:i,drawings:s,chartSettings:l,dataLevel:c,tickSize:u,onClose:d,onResetView:m,onFitYAxis:f,onResetXAxis:h,onRemoveIndicators:p,onRemoveDrawings:g,onScreenshot:y,onToggleHeatmap:v,onOpenSettings:b,onCreateOrder:S}){let C=t5(null),[w,k]=wk(1920),[M,I]=wk(1080);vk(()=>{let P=N=>{C.current&&!C.current.contains(N.target)&&d()},D=N=>{N.key==="Escape"&&d()};return document.addEventListener("mousedown",P),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",P),document.removeEventListener("keydown",D)}},[d]),vk(()=>{window&&(k(window.innerWidth),I(window.innerHeight))},[]);let x=n5(Math.round(r*1e8)/1e8,Math.round(a*1e8)/1e8,Math.round(o*1e8)/1e8,u),T=C.current?.clientWidth??260,R=C.current?.clientHeight??500;return cn("div",{ref:C,className:"fixed z-[9999] min-w-[192px] rounded-xl border border-white/10 bg-[#14161b] shadow-2xl overflow-hidden",style:{left:Math.max(8,e+T>w?w-T:e),top:Math.max(8,t+R>M?M-R:t)},onContextMenu:P=>P.preventDefault(),children:cn("div",{className:"p-1.5",children:n==="chart"?ui(xf,{children:[cn(au,{children:"View"}),cn(ci,{icon:cn(ga,{size:12}),shortcut:"\u23180",onClick:()=>{m(),d()},children:"Reset view"}),cn(ci,{icon:cn(Pd,{size:12}),onClick:()=>{f(),d()},children:"Fit Y axis"}),cn(wf,{}),cn(au,{children:"Trade"}),x.map((P,D)=>cn(ci,{onClick:()=>{S({qty:1,...P}),d()},children:ui("div",{className:"flex flex-row items-center gap-1",children:[P?.icon&&P.icon,P.label]})},D)),r!==null&&ui(xf,{children:[cn(wf,{}),cn(au,{children:"Price"}),ui(ci,{icon:cn(Dl,{size:12}),onClick:()=>{navigator.clipboard.writeText(r.toFixed(2)),d()},children:["Copy"," ",cn("span",{className:"text-slate-200 tabular-nums ml-1",children:r.toFixed(2)})]})]}),i.length>0&&ui(xf,{children:[cn(wf,{}),cn(au,{children:"Indicators"}),ui(ci,{icon:cn(ho,{size:12}),destructive:!0,onClick:()=>{p(),d()},children:["Remove ",i.length," ",i.length===1?"indicator":"indicators"]})]}),s.length>0&&ui(xf,{children:[cn(wf,{}),cn(au,{children:"Drawings"}),ui(ci,{icon:cn(ho,{size:12}),destructive:!0,onClick:()=>{g(),d()},children:["Remove ",s.length," ",s.length===1?"drawing":"drawings"]})]}),cn(wf,{}),cn(ci,{icon:cn(Od,{size:12}),onClick:()=>{y(),d()},children:"Screenshot"}),c==="l3"&&ui(ci,{icon:cn(si,{size:12}),onClick:()=>{v(),d()},children:[l.showHeatmap?"Hide ":"Show ","Heatmap"]}),cn(ci,{icon:cn(El,{size:12}),onClick:()=>{b(),d()},children:"Settings"})]}):ui(xf,{children:[cn(au,{children:"Time axis"}),cn(ci,{icon:cn(Id,{size:12}),onClick:()=>{h(),d()},children:"Reset time axis"}),cn(ci,{icon:cn(ga,{size:12}),onClick:()=>{m(),d()},children:"Reset view"})]})})})}var r5=6,Sk=.05;function Ji(e,t,n,r){let o=n,a=e.reduce((l,c)=>l+c.heightRatio,0),i={},s=0;for(let l of e){let c=l.heightRatio/a*t;i[l.id]={x:0,y:s,w:o-r,h:c},s+=c}return i}function ky(e,t,n){for(let r=0;r<t.length-1;r++){let o=n[t[r].id],a=o.y+o.h;if(Math.abs(e-a)<=r5/2)return r}return-1}function iu(e,t,n){return t.find(r=>{let o=n[r.id];return e>=o.y&&e<o.y+o.h})??null}var Sf=class{constructor(){ae(this,"tools",new Map)}register(t){return this.tools.has(t.id)&&console.warn(`[DrawingRegistry] '${t.id}' already registered - overwriting`),this.tools.set(t.id,t),()=>this.tools.delete(t.id)}get(t){return this.tools.get(t)}getAll(){return Array.from(this.tools.values())}has(t){return this.tools.has(t)}},io=new Sf;var Ly=30,o5=5,a5=5,i5="rgba(255,255,255,0.18)";function di(e,t,n,r,o,a){let i=o-n,s=a-r,l=i*i+s*s;if(l===0)return Math.hypot(e-n,t-r);let c=Math.max(0,Math.min(1,((e-n)*i+(t-r)*s)/l));return Math.hypot(e-(n+c*i),t-(r+c*s))}function Aa(e,t,n,r,o,a=!1,i=!1){if(e===n)return[e,a?-99999:t,n,i?99999:r];let s=(r-t)/(n-e),l=e,c=t,u=n,d=r;return a&&(l=0,c=t+s*(0-e)),i&&(u=o,d=t+s*(o-e)),[l,c,u,d]}function so(e,t,n,r){e.strokeStyle=t,e.lineWidth=n,e.setLineDash(r??[])}function su(e,t){let n=e.replace("#",""),r=parseInt(n.slice(0,2),16),o=parseInt(n.slice(2,4),16),a=parseInt(n.slice(4,6),16),i=n.length===8?parseInt(n.slice(6,8),16)/255:t??1;return`rgba(${r},${o},${a},${i})`}function Ty(e){return`#${e.replace("#","").slice(0,6)}`}function Iy(e,t=1){let n=e.replace("#","");return n.length===8?parseInt(n.slice(6,8),16)/255:t}function s5(e){let t=Math.abs(Number(e))/1e9;if(t<60)return`${Math.round(t)}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${Math.round(t%60)}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}var l5=e=>(t,n,r,o,a)=>{let i=o/2;t.beginPath(),e?(t.moveTo(n,r-i),t.lineTo(n+i,r+i),t.lineTo(n-i,r+i)):(t.moveTo(n,r+i),t.lineTo(n+i,r-i),t.lineTo(n-i,r-i)),t.closePath(),t.fillStyle=a,t.fill()},c5=(e,t,n,r,o)=>{let a=r/2,i=r*.16;e.strokeStyle=o,e.fillStyle=o,e.lineWidth=1.5,e.beginPath(),e.moveTo(t-a,n+a),e.lineTo(t+a,n-a),e.stroke(),e.beginPath(),e.arc(t-a+i,n-a+i,i,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(t+a-i,n+a-i,i,0,Math.PI*2),e.fill()},u5=(e,t,n,r,o)=>{let a=r/2;e.strokeStyle=o,e.lineWidth=1.2,e.beginPath(),e.arc(t,n,a,0,Math.PI*2),e.stroke(),e.beginPath(),e.moveTo(t,n),e.lineTo(t,n-a*.55),e.moveTo(t,n),e.lineTo(t+a*.5,n),e.stroke()},d5=(e,t,n,r,o)=>{let a=r/2,i=t-a,s=n+a;e.strokeStyle=o,e.lineWidth=1.2,e.beginPath(),e.moveTo(i,s),e.lineTo(i+r,s),e.moveTo(i,s),e.lineTo(i+r,s-r),e.stroke(),e.beginPath(),e.arc(i,s,r*.5,-Math.PI/4,0),e.stroke()},f5=(e,t,n,r,o)=>{let a=r/2,i=r/4,s=[.45,.8,.6];e.fillStyle=o,s.forEach((l,c)=>{let u=t-a+c*(i+i/2),d=r*l;e.fillRect(u,n+a-d,i,d)})};function m5(e,t,n,r,o,a,i){let s=i.tsToX(t.a.ts,r),l=i.priceToY(t.a.price,o)+a,c=i.tsToX(t.b.ts,r),u=i.priceToY(t.b.price,o)+a,d=t.b.price-t.a.price,m=t.a.price!==0?d/t.a.price*100:0,f=d>=0,h=f?"+":"\u2212",p=Math.atan2(l-u,c-s)*180/Math.PI,g=f?"#26a69a":"#ef5350",y="#aab0bd",v=[{icon:l5(f),text:`${h}${Math.abs(d).toFixed(2)}`,color:g},{icon:c5,text:`${h}${Math.abs(m).toFixed(2)}%`,color:g},{icon:u5,text:s5(t.b.ts-t.a.ts),color:y},{icon:d5,text:`${p.toFixed(1)}\xB0`,color:y},{icon:f5,text:`${t.a.price.toFixed(2)} \u2192 ${t.b.price.toFixed(2)}`,color:y}],b=11,S=9,C=7,w=b+6,k=11,M=7;e.save(),e.font=`${b}px monospace`;let I=Math.max(...v.map(z=>e.measureText(z.text).width)),x=Math.ceil(S+k+M+I+S),T=v.length*w+C*2,R=c>s,P=l>u,D=R?P?"tl":"bl":P?"bl":"tl",N=15,O=15,A=(s+c)/2+N,B=(l+u)/2-(D==="bl"?T:0)+(D==="bl"?-O:O);e.beginPath(),e.roundRect(A,B,x,T,6),e.fillStyle="rgba(20, 22, 28, 0.92)",e.fill(),e.strokeStyle=g,e.lineWidth=1,e.stroke(),e.textBaseline="middle",e.textAlign="left";let E=A+S+k/2,L=A+S+k+M;v.forEach((z,Y)=>{let G=B+C+w*Y+w/2;z.icon(e,E,G,k,z.color),e.fillStyle=z.color,e.fillText(z.text,L,G)}),e.restore()}function Rk(e,t,n,r,o,a,i){let s=i.tsToX(t.a.ts,r),l=i.priceToY(t.a.price,o)+a,c=i.tsToX(t.b.ts,r),u=i.priceToY(t.b.price,o)+a,d=Math.atan2(l-u,c-s)*180/Math.PI;e.save(),e.font="500 11px ui-monospace, monospace",e.fillStyle="#3377ff",e.strokeStyle="#3377ff",e.setLineDash([1,2]),e.fillText(String(d.toFixed(2))+"\xB0",s+55,l+3),e.beginPath(),e.moveTo(s,l),e.lineTo(s+50,l),e.arc(s,l,50,0,(d<=0?0:Math.PI*2)-Math.atan2(l-u,c-s),!(d<=0)),e.stroke(),e.beginPath(),e.restore()}function hn(e,t,n,r,o=!1){let a=o?a5:o5;e.beginPath(),e.arc(t,n,a+2,0,Math.PI*2),e.fillStyle=i5,e.fill(),e.beginPath(),e.arc(t,n,a,0,Math.PI*2),e.fillStyle=r,e.fill(),e.strokeStyle="#ffffff",e.lineWidth=1.5,e.setLineDash([]),e.stroke()}function Ry(e){let t=e.labelItalic?"italic ":"",n=e.labelBold?"700 ":"400 ",r=e.labelFontSize??11;return`${t}${n}${r}px "Inter", monospace`}function Py(e,t,n,r,o,a,i){if(!t.label)return;let s=Ry(t);e.font=s,e.setLineDash([]);let l=t.labelHorizontalAlign??"left",c=t.labelVerticalAlign??"top",u=t.labelFontSize??11,d=6,m=8,f=e.measureText(t.label).width,h,p;l==="left"?(p="left",h=d):l==="right"?(p="right",h=o-d):(p="center",h=o/2),e.textAlign=p;let g,y;p==="left"?(g=h-m,y=h+f+m):p==="right"?(g=h-f-m,y=h+m):(g=h-f/2-m,y=h+f/2+m),g=Math.max(0,g),y=Math.min(o,y);let v;c==="top"?v=r-4:c==="bottom"?v=r+u+2:v=r+u*.35;let b=v-u,S=v+u*.3,C=r>=b&&r<=S;so(e,n,a,i),C?(g>0&&(e.beginPath(),e.moveTo(0,r),e.lineTo(g,r),e.stroke()),y<o&&(e.beginPath(),e.moveTo(y,r),e.lineTo(o,r),e.stroke())):(e.beginPath(),e.moveTo(0,r),e.lineTo(o,r),e.stroke()),e.setLineDash([]),e.fillStyle=t.labelColor??n,e.fillText(t.label,h,v)}function p5(e,t,n,r,o,a,i){if(!t.label)return;e.font=Ry(t),e.fillStyle=t.labelColor??n,e.setLineDash([]);let s=t.labelHorizontalAlign??"right",l=t.labelVerticalAlign??"top",c=t.labelTextOrientation==="vertical",u=t.labelFontSize??11,d=6,m=6;if(!c){let b;l==="top"?b=d+u:l==="bottom"?b=o-d:b=o/2+u*.35;let S=e.measureText(t.label).width,C=b-u,w=b+u*.3,k,M;s==="left"?(k=r-d-S,M=r-d):s==="right"?(k=r+d,M=r+d+S):(k=r-S/2,M=r+S/2);let I=r>=k&&r<=M,x=C-m,T=w+m;so(e,n,a,i),I?(x>0&&(e.beginPath(),e.moveTo(r,0),e.lineTo(r,x),e.stroke()),T<o&&(e.beginPath(),e.moveTo(r,T),e.lineTo(r,o),e.stroke())):(e.beginPath(),e.moveTo(r,0),e.lineTo(r,o),e.stroke()),e.setLineDash([]),e.save(),s==="left"?(e.textAlign="right",e.fillText(t.label,r-d,b)):s==="right"?(e.textAlign="left",e.fillText(t.label,r+d,b)):(e.textAlign="center",e.fillText(t.label,r,b)),e.restore();return}let f=e.measureText(t.label).width,h=8,p;l==="top"?p=d+f/2:l==="bottom"?p=o-d-f/2:p=o/2;let g=p-f/2-h,y=p+f/2+h;so(e,n,a,i),g>0&&(e.beginPath(),e.moveTo(r,0),e.lineTo(r,g),e.stroke()),y<o&&(e.beginPath(),e.moveTo(r,y),e.lineTo(r,o),e.stroke()),e.setLineDash([]);let v;s==="left"?v=r-m-u/2:s==="right"?v=r+m+u/2:v=r,e.save(),e.translate(v,p),e.rotate(-Math.PI/2),e.textAlign="center",e.fillStyle=t.labelColor??n,e.fillText(t.label,0,u*.35),e.restore()}function zl(e,t,n,r,o,a,i,s,l,c,u,d,m,f){if(!t.label)return;e.font=Ry(t),e.setLineDash([]);let h=t.labelFontSize??11,p=6,g=8;if(r==="rect"){let P=Math.min(o,i),D=Math.min(a,s),N=Math.abs(i-o),O=Math.abs(s-a),A=t.labelHorizontalAlign??"left",B=t.labelVerticalAlign??"top",E;A==="left"?(e.textAlign="left",E=P+p):A==="right"?(e.textAlign="right",E=P+N-p):(e.textAlign="center",E=P+N/2);let L;B==="top"?L=D+p+h:B==="bottom"?L=D+O-p:L=D+O/2+h*.35,e.fillStyle=t.labelColor??n,e.fillText(t.label,E,L);return}let y=t.labelHorizontalAlign??"center",v=t.labelVerticalAlign??"top",b=Math.atan2(s-a,i-o),S=b>Math.PI/2||b<=-Math.PI/2;S&&(b+=b>0?-Math.PI:Math.PI);let C=o<=i,w,k;y==="center"?(w=(o+i)/2,k=(a+s)/2):y==="left"?(w=C?o:i,k=C?a:s):(w=C?i:o,k=C?s:a);let M;y==="center"?M="center":y==="left"?M="left":M="right";let I=S?-1:1,x=y==="left"?p*I:y==="right"?-p*I:0,T=e.measureText(t.label).width,R;if(v==="top"?R=-(h+4):v==="bottom"?R=h+2:R=h*.35,l!==void 0&&c!==void 0){let P=Math.cos(b),D=Math.sin(b),N=R-h,O=R+h*.3,A=N<=0&&O>=0,B=(V,K)=>(V-w)*P+(K-k)*D,E=u??o,L=d??a,z=m??i,Y=f??s,G=B(E,L),H=B(z,Y),W=Math.min(G,H),U=Math.max(G,H);if(so(e,n,l,c),A){let V,K;M==="center"?(V=x-T/2-g,K=x+T/2+g):M==="left"?(V=x-g,K=x+T+g):(V=x-T-g,K=x+g),W<V&&(e.beginPath(),e.moveTo(w+P*W,k+D*W),e.lineTo(w+P*V,k+D*V),e.stroke()),U>K&&(e.beginPath(),e.moveTo(w+P*K,k+D*K),e.lineTo(w+P*U,k+D*U),e.stroke())}else e.beginPath(),e.moveTo(w+P*W,k+D*W),e.lineTo(w+P*U,k+D*U),e.stroke();e.setLineDash([])}e.save(),e.translate(w,k),e.rotate(b),e.textAlign=M,e.fillStyle=t.labelColor??n,e.fillText(t.label,x,R),e.restore()}function h5(e,t,n,r,o,a,i,s,l,c){let u=c.priceToY(t.price,o)+a;u<a||u>a+o||(i&&(t.lineWidth,e.beginPath(),e.moveTo(0,u),e.lineTo(r,u),e.stroke()),t.label?Py(e,t,t.color,u,r,t.lineWidth,t.dash):(so(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(0,u),e.lineTo(r,u),e.stroke()),(i||s)&&hn(e,r/2,u,t.color,l==="body"))}function g5(e,t,n,r,o,a,i,s,l){let c=l.tsToX(t.ts,r);c<0||c>r||(a&&(t.lineWidth,e.beginPath(),e.moveTo(c,0),e.lineTo(c,o),e.stroke()),t.label?p5(e,t,t.color,c,o,t.lineWidth,t.dash):(so(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(c,0),e.lineTo(c,o),e.stroke()),(a||i)&&hn(e,c,o/2,t.color,s==="body"))}function b5(e,t,n,r,o,a,i,s,l,c){let u=c.tsToX(t.a.ts,r),d=c.priceToY(t.a.price,o)+a,m=c.tsToX(t.b.ts,r),f=c.priceToY(t.b.price,o)+a,[h,p,g,y]=Aa(u,d,m,f,r,t.extendLeft,t.extendRight);i&&(t.lineWidth,e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),t.label?zl(e,t,t.color,"line",u,d,m,f,t.lineWidth,t.dash,h,p,g,y):(so(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),(i||s)&&(hn(e,u,d,t.color,l==="a"),hn(e,m,f,t.color,l==="b"))}function y5(e,t,n,r,o,a,i,s,l,c){let u=c.tsToX(t.a.ts,r),d=c.priceToY(t.a.price,o)+a,m=c.tsToX(t.b.ts,r),f=c.priceToY(t.b.price,o)+a,[h,p,g,y]=Aa(u,d,m,f,r,t.extendLeft,t.extendRight);i&&(t.lineWidth,e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),t.label?zl(e,t,t.color,"line",u,d,m,f,t.lineWidth,t.dash,h,p,g,y):(so(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),(i||s)&&(hn(e,u,d,t.color,l==="a"),hn(e,m,f,t.color,l==="b"))}function v5(e,t,n,r,o,a,i,s,l,c){let u=c.priceToY(t.price,o)+a,d=c.tsToX(t.ts,r);u<a&&d<0||u>a+o&&d>r||(i&&(t.lineWidth,e.beginPath(),e.moveTo(0,u),e.lineTo(r,u),e.moveTo(d,a),e.lineTo(d,o),e.stroke()),t.label?Py(e,t,t.color,u,r,t.lineWidth,t.dash):(so(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(0,u),e.lineTo(r,u),e.moveTo(d,a),e.lineTo(d,o),e.stroke()),(i||s)&&hn(e,d,u,t.color,l==="body"))}function w5(e,t,n,r,o,a,i,s,l,c){let u=c.tsToX(t.a.ts,r),d=c.priceToY(t.a.price,o)+a,m=c.tsToX(t.b.ts,r),f=c.priceToY(t.b.price,o)+a,[h,p,g,y]=Aa(u,d,m,f,r,t.extendLeft,t.extendRight);i&&(t.lineWidth,e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),t.label?zl(e,t,t.color,"line",u,d,m,f,t.lineWidth,t.dash,h,p,g,y):(so(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),m5(e,t,n,r,o,a,c),(i||s)&&(hn(e,u,d,t.color,l==="a"),hn(e,m,f,t.color,l==="b"))}function x5(e,t,n,r,o,a,i,s,l,c){let u=c.tsToX(t.a.ts,r),d=c.priceToY(t.a.price,o)+a,m=c.tsToX(t.b.ts,r),f=c.priceToY(t.b.price,o)+a,[h,p,g,y]=Aa(u,d,m,f,r,t.extendLeft,t.extendRight);i&&(t.lineWidth,e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),t.label?zl(e,t,t.color,"line",u,d,m,f,t.lineWidth,t.dash,h,p,g,y):(so(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),Rk(e,t,n,r,o,a,c),(i||s)&&(hn(e,u,d,t.color,l==="a"),hn(e,m,f,t.color,l==="b"))}function S5(e,t,n,r,o,a,i,s,l,c){let u=c.tsToX(t.a.ts,r),d=c.priceToY(t.a.price,o)+a,m=c.tsToX(t.b.ts,r),f=c.priceToY(t.b.price,o)+a,h=m>=u,[p,g,y,v]=Aa(u,d,m,f,r,!h,h),b=h?y:p,S=h?v:g;i&&(t.lineWidth,e.beginPath(),e.moveTo(u,d),e.lineTo(b,S),e.stroke()),t.label?zl(e,t,t.color,"line",u,d,m,f,t.lineWidth,t.dash,u,d,b,S):(so(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(u,d),e.lineTo(b,S),e.stroke()),(i||s)&&(hn(e,u,d,t.color,l==="a"),hn(e,m,f,t.color,l==="b"))}function C5(e,t,n,r,o,a,i,s,l,c){if(t.ts>n.tMax)return;let u=c.priceToY(t.price,o)+a;if(u<a||u>a+o)return;let d=c.tsToX(t.ts,r);i&&(t.lineWidth,e.beginPath(),e.moveTo(d,u),e.lineTo(r,u),e.stroke()),t.label?Py(e,t,t.color,u,r,t.lineWidth,t.dash):(so(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(d,u),e.lineTo(r,u),e.stroke()),(i||s)&&hn(e,d,u,t.color,l==="body")}function Ck(e,t,n,r,o,a,i,s,l,c){let u=c.tsToX(t.a.ts,r),d=c.priceToY(t.a.price,o)+a,m=c.tsToX(t.b.ts,r),f=c.priceToY(t.b.price,o)+a,h=c.priceToY(t.a.price+t.height,o)+a,p=c.priceToY(t.b.price+t.height,o)+a,g=t.extendLeft??!1,y=t.extendRight??!1,v=b=>{let S=c.priceToY(t.a.price+b*t.height,o)+a,C=c.priceToY(t.b.price+b*t.height,o)+a;return Aa(u,S,m,C,r,g,y)};if(t.enableBackground){let[b,S,C,w]=v(0),[k,M,I,x]=v(1);e.beginPath(),e.moveTo(b,S),e.lineTo(C,w),e.lineTo(I,x),e.lineTo(k,M),e.closePath(),e.fillStyle=t.backgroundColor,e.fill()}for(let b of t.levels??Sl){if(!b.enabled)continue;let[S,C,w,k]=v(Number(b.value));so(e,b.color,b.lineWidth,b.dash),e.beginPath(),e.moveTo(S,C),e.lineTo(w,k),e.stroke()}if(e.setLineDash([]),i||s){let b=(t.levels??Sl)[0]?.color??"#3377ff",S=(u+m)/2;hn(e,u,d,b,l==="a"),hn(e,m,f,b,l==="b"),hn(e,S,(d+f)/2,b,l==="mt"),hn(e,u,h,b,l==="a2"),hn(e,m,p,b,l==="a3"),hn(e,S,(h+p)/2,b,l==="mb")}}function k5(e,t,n,r,o,a,i,s,l,c){let u=c.tsToX(t.a.ts,r),d=c.priceToY(t.a.price,o)+a,m=c.tsToX(t.b.ts,r),f=c.priceToY(t.b.price,o)+a,h=Math.min(u,m),p=Math.min(d,f),g=Math.abs(m-u),y=Math.abs(f-d);i&&(e.strokeStyle="rgba(255,255,255,0.2)",e.lineWidth=7,e.setLineDash([]),e.strokeRect(h,p,g,y));let v=t.fillColor??t.color,b=t.borderColor??t.color,S=t.borderLineWidth??1,C=t.borderDash??[];if(e.fillStyle=su(v,t.fillOpacity),e.fillRect(h,p,g,y),so(e,b,S,C),e.strokeRect(h+.5,p+.5,g-1,y-1),zl(e,t,b,"rect",u,d,m,f),i||s){let w=t.borderColor??t.color;hn(e,h,p,w,l==="tl"),hn(e,h+g,p,w,l==="tr"),hn(e,h,p+y,w,l==="bl"),hn(e,h+g,p+y,w,l==="br"),hn(e,h+g/2,p,w,l==="mt"),hn(e,h+g/2,p+y,w,l==="mb"),hn(e,h,p+y/2,w,l==="ml"),hn(e,h+g,p+y/2,w,l==="mr")}}function T5(e,t,n,r,o,a,i,s,l,c){let u=c.tsToX(t.a.ts,r),d=c.priceToY(t.a.price,o)+a,m=c.tsToX(t.b.ts,r),f=c.priceToY(t.b.price,o)+a,h=c.tsToX(t.c.ts,r),p=c.priceToY(t.c.price,o)+a,g=()=>{e.beginPath(),e.moveTo(u,d),e.lineTo(m,f),e.lineTo(h,p),e.closePath()};i&&(e.strokeStyle="rgba(255,255,255,0.2)",e.lineWidth=7,e.setLineDash([]),g(),e.stroke());let y=t.fillColor??t.color,v=t.borderColor??t.color,b=t.borderLineWidth??1,S=t.borderDash??[];g(),e.fillStyle=su(y,t.fillOpacity),e.fill(),so(e,v,b,S),g(),e.stroke();let C=Math.min(u,m,h),w=Math.max(u,m,h),k=Math.min(d,f,p),M=Math.max(d,f,p);if(zl(e,t,v,"rect",C,k,w,M),i||s){let I=v;hn(e,u,d,I,l==="a"),hn(e,m,f,I,l==="b"),hn(e,h,p,I,l==="c")}}function I5(e,t,n,r,o,a,i,s,l,c){let u=t.a.price,d=t.b.price,m=u-d,f=t.labelFontSize??10,h=t.labelBold?"700 ":"400 ",p=t.labelAlign==="right"?"right":"left";e.font=`${h}${f}px "Inter", monospace`,e.textAlign="left";let g=c.tsToX(t.a.ts,r),y=c.tsToX(t.b.ts,r),v=c.priceToY(t.a.price,o)+a,b=c.priceToY(t.b.price,o)+a,S=Math.min(g,y),C=Math.max(g,y);if(t.enableBackground&&t.backgroundColor){let x=t.levels.filter(P=>P.enabled).map(P=>{let D=d+m*parseFloat(P.value);return c.priceToY(D,o)+a});x.push(v,b);let T=Math.min(...x),R=Math.max(...x);e.fillStyle=t.backgroundColor,e.fillRect(S,T,C-S,R-T)}for(let x of t.levels){if(!x.enabled)continue;let T=parseFloat(x.value),R=d+m*T,P=c.priceToY(R,o)+a;if(P<a||P>a+o)continue;let D=x.color??"#FFFFFF",N=`${t.showLevels?T+" ":""}${t.showPrices?R.toFixed(2):""}`.trim(),O=N?e.measureText(N).width:0,A=6,B=t.dash??[],E=t.lineWidth??1,L=S,z=C;t.extendLeft&&(L=N&&p==="left"?O+A*2:0),t.extendRight&&(z=r),so(e,D,E,B),e.beginPath(),e.moveTo(L,P),e.lineTo(z,P),e.stroke(),N&&(e.fillStyle=D,p==="right"?e.fillText(N,z+A,P+f*.35):e.fillText(N,L-O-A,P+f*.35))}let w=c.tsToX(t.a.ts,r),k=c.priceToY(t.a.price,o)+a,M=c.tsToX(t.b.ts,r),I=c.priceToY(t.b.price,o)+a;(i||s)&&(hn(e,w,k,"#3d81f6",l==="a"),hn(e,M,I,"#3d81f6",l==="b"))}function M5(e,t,n,r,o,a,i,s,l,c){let u,d;t.screenAnchored&&t.screenX!==void 0&&t.screenY!==void 0?(u=t.screenX,d=t.screenY):(u=c.tsToX(t.anchor.ts,r),d=c.priceToY(t.anchor.price,o)+a);let m=t.italic?"italic ":"",f=t.bold?"700 ":"400 ";e.font=`${m}${f}${t.fontSize}px "Inter", monospace`,e.fillStyle=t.color,e.setLineDash([]);let h=t.textAlign==="center"?"center":t.textAlign==="right"?"right":"left";e.textAlign=h;let p=h==="left"?u+4:h==="right"?u-4:u,g=t.text.split(`
|
|
4
|
+
`),y=t.fontSize*1.4;g.forEach((v,b)=>{e.fillText(v,p,d-4+b*y)}),(i||s)&&hn(e,u,d,t.color,l==="anchor")}var kk=.11,L5="rgba(11,14,20,1)";function R5(e,t,n,r){return{price:Rr(e,r),ticks:`${Math.round(e/n)}T`,pct:t!==0?`${(e/Math.abs(t)*100).toFixed(2)}%`:""}}var Tk="Inter, system-ui, sans-serif";function Pk(e,t){let n=i=>Math.round(i/t)*t,r=n(e.a.price),o=n(Math.max(e.upAmount,0)),a=n(Math.max(e.downAmount,0));return{entry:r,up:o,down:a,top:r+o,bottom:r-a}}function P5(e,t,n,r,o,a,i,s,l,c){let u=t.tool==="long",d=ro(c),m=l.tsToX(t.a.ts,n),f=l.tsToX(t.b.ts,n),h=Math.min(m,f),p=Math.max(Math.abs(f-m),1),{entry:g,up:y,down:v,top:b,bottom:S}=Pk(t,d),C=l.priceToY(b,r)+o,w=l.priceToY(g,r)+o,k=l.priceToY(S,r)+o,M=Ty(t.upColor),I=Ty(t.downColor),x=Ty(t.entryColor??"#b0b6c0"),T=u?{y:C,price:b,amount:y,color:M,outward:-1}:{y:k,price:S,amount:v,color:I,outward:1},R=u?{y:k,price:S,amount:v,color:I,outward:1}:{y:C,price:b,amount:y,color:M,outward:-1};if(e.setLineDash([]),e.fillStyle=su(t.upColor,kk),e.fillRect(h,C,p,w-C),e.fillStyle=su(t.downColor,kk),e.fillRect(h,w,p,k-w),((D,N,O,A)=>{so(e,N,O,A),e.beginPath(),e.moveTo(h,Math.round(D)+.5),e.lineTo(h+p,Math.round(D)+.5),e.stroke()})(w,x,1,[]),e.setLineDash([]),t.drawInfo&&(i||a)){let D=t.fontSize||11,N=(A,B,E,L)=>My(e,A,h+p/2,B,E,L,D,"center",7,4,Tk);e.font=`${D}px ${Tk}`;let O=(A,B)=>{if(B.amount<=0)return;let E=R5(B.amount,g,d,c),L=Rr(B.price,c),z=`${A} ${L} ${E.price} \xB7 ${E.ticks} \xB7 ${E.pct}`;z&&N(z,B.y+B.outward*(D+4),t.textColor??"#ffffff",B.color)};if(O("Target",T),O("Stop",R),T.amount>0&&R.amount>0){let A=T.amount/R.amount,E=`${u?"LONG":"SHORT"} ${t.qty??1} @ ${Rr(g,c)} R:R ${A.toFixed(2)}`;E&&N(E,w-D-4,t.textColor??"#ffffff",L5)}}(a||i)&&(hn(e,h,C,M,s==="mt"),hn(e,h,k,I,s==="mb"),hn(e,h,w,x,s==="ml"),hn(e,h+p,w,x,s==="mr"))}var Ik=1,Mk=3;function Xs(e,t,n,r){let o=n-t;return o===0?r/2:r-(e-t)/o*r}function Lk(e,t,n,r){let o=n.length;if(o===0)return{loIdx:0,hiIdx:0};let a=n.findIndex(u=>u===t),i=e.reduce((u,d)=>u+d,0)*(r/100),s=a<0?0:a,l=s,c=e[s]??0;for(;c<i&&(s>0||l<o-1);){let u=s>0?e[s-1]:0,d=l<o-1?e[l+1]:0;if(u>=d&&s>0)s--,c+=u;else if(l<o-1)l++,c+=d;else if(s>0)s--,c+=u;else break}return{loIdx:s,hiIdx:l}}function D5(e,t,n,r,o,a,i,s){let l=e.length;if(l===0)return[];let c=Math.abs(Xs(0,o,a,i)-Xs(s,o,a,i)),u=c<Mk?Math.ceil(Mk/Math.max(c,.01)):1;if(u<=1)return Array.from({length:l},(f,h)=>({priceCenter:e[h],priceLo:e[h],priceHi:e[h]+s,buyVol:t[h],sellVol:n[h],totalVol:r[h]}));let d=[],m=0;for(;m<l;){let f=Math.min(m+u,l),h=0,p=0,g=0;for(let y=m;y<f;y++)h+=t[y],p+=n[y],g+=r[y];d.push({priceCenter:(e[m]+e[f-1])/2,priceLo:e[m],priceHi:e[f-1]+s,buyVol:h,sellVol:p,totalVol:g}),m=f}return d}function My(e,t,n,r,o,a,i,s="left",l=4,c=2,u="monospace"){e.font=`${i}px ${u}`,e.textBaseline="middle",e.textAlign=s;let d=e.measureText(t).width,m;s==="left"?m=n:s==="right"?m=n-d:m=n-d/2;let f=3,h=m-l,p=r-i/2-c,g=d+l*2,y=i+c*2;e.fillStyle=a,e.beginPath(),e.roundRect(h,p,g,y,f),e.fill(),e.fillStyle=o,e.fillText(t,n,r)}function A5(e,t,n,r,o,a,i,s,l,c,u){let d=c.tsToX(t.a.ts,r),m=c.priceToY(t.a.price,o)+a,f=c.tsToX(t.b.ts,r),h=c.priceToY(t.b.price,o)+a,p=Math.min(d,f),g=Math.min(m,h),y=Math.abs(f-d),v=Math.abs(h-m);t.enableBg&&(e.fillStyle=t.bgColor,e.fillRect(p,g,y,v)),t.enableBorder&&(e.strokeStyle=t.borderColor,e.lineWidth=1,e.setLineDash(t.borderDash??[]),e.strokeRect(p+.5,g+.5,y-1,v-1),e.setLineDash([]));let b=t.vpData;if(!b||b.prices.length===0||y<2||v<2){(i||s)&&(hn(e,p,g+v/2,"#6490c8",l==="ml"),hn(e,p+y,g+v/2,"#6490c8",l==="mr"));return}let{prices:S,buyVol:C,sellVol:w,totalVol:k,poc:M}=b,I=Math.min(t.a.price,t.b.price),x=Math.max(t.a.price,t.b.price),T=t.highlightPocBar!==!1,R=t.pocBarLineWidth??1,P=t.vaBarDimming!==!1,D=t.vaOutsideDimFrac??.35,N=t.labelPills!==!1,O=t.splitCenterLine!==!1,A=t.barGap!==!1,B=D5(S,C,w,k,I,x,v,u),E=B.length;if(E===0)return;let L=0;for(let ke=0;ke<E;ke++)B[ke].totalVol>L&&(L=B[ke].totalVol);if(L===0)return;let z=S.length,{loIdx:Y,hiIdx:G}=t.showValueArea||t.showVaHLines||P?Lk(k,M,S,t.valueAreaPct??70):{loIdx:0,hiIdx:z-1},H=S[Y],W=S[G],U=(t.barOpacity??60)/100,V=t.enableBuyColor?t.buyColor??"#00e676":"#00e676",K=t.enableSellColor?t.sellColor??"#ff1744":"#ff1744",Z=t.totalColor??"#5b9cf6",de=t.deltaNegColor??"#ff1744",ze=t.profileMode??"stacked",xe=(t.barsWidth??100)/100,Ae=t.pocColor??"#facc15",Oe="rgba(18,20,26,0.88)";if(e.save(),e.beginPath(),e.rect(p,g,y,v),e.clip(),t.showValueArea&&L>0){let ke=g+Xs(W,I,x,v),Q=g+Xs(H,I,x,v);e.fillStyle=t.valueAreaFillColor??"#ffffff1a",e.fillRect(p,ke,y,Q-ke)}for(let ke=0;ke<E;ke++){let Q=B[ke];if(Q.priceHi<I-u||Q.priceLo>x+u)continue;let Pe=g+Xs(Q.priceHi,I,x,v),ie=g+Xs(Q.priceLo,I,x,v)-Pe,se=Math.max(Ik,ie-(A&&ie>3?1:0)),Se=Pe,Re=Q.priceCenter>=H&&Q.priceCenter<=W,ye=Math.abs(Q.priceCenter-M)<u*1.5,$e=P&&!Re?U*D:U;e.globalAlpha=$e;let Ue=Q.buyVol,je=Q.sellVol,ht=Q.totalVol;if(ze==="stacked"){let Be=ht/L*y*xe,xt=Be*(ht>0?je/ht:0),fn=Be-xt;e.fillStyle=K,e.fillRect(p,Se,xt,se),e.fillStyle=V,e.fillRect(p+xt,Se,fn,se)}else if(ze==="split"){let Be=y/2*xe,xt=Ue/L*Be,fn=je/L*Be,In=p+y/2;e.fillStyle=V,e.fillRect(In,Se,xt,se),e.fillStyle=K,e.fillRect(In-fn,Se,fn,se)}else if(ze==="delta"){let Be=Ue-je,xt=Math.abs(Be)/L*y*xe;e.fillStyle=Be>=0?Z:de,e.fillRect(p,Se,xt,se)}else{let Be=ht/L*y*xe;e.fillStyle=Z,e.fillRect(p,Se,Be,se)}if(T&&ye){if(e.globalAlpha=Math.min(1,$e*1.5),ze==="stacked"){let xt=ht/L*y*xe,fn=xt*(ht>0?je/ht:0),In=xt-fn;e.fillStyle=K,e.fillRect(p,Se,fn,se),e.fillStyle=V,e.fillRect(p+fn,Se,In,se)}else if(ze==="split"){let xt=y/2*xe,fn=p+y/2;e.fillStyle=V,e.fillRect(fn,Se,Ue/L*xt,se),e.fillStyle=K,e.fillRect(fn-je/L*xt,Se,je/L*xt,se)}else if(ze==="delta"){let xt=Ue-je;e.fillStyle=xt>=0?Z:de,e.fillRect(p,Se,Math.abs(xt)/L*y*xe,se)}else e.fillStyle=Z,e.fillRect(p,Se,ht/L*y*xe,se);e.globalAlpha=Iy(Ae),e.strokeStyle=Ae,e.lineWidth=R,e.setLineDash([]);let Be=Se+se/2;e.beginPath(),e.moveTo(p,Be),e.lineTo(p+y,Be),e.stroke()}}if(e.globalAlpha=1,ze==="split"&&O){let ke=p+y/2;e.strokeStyle="rgba(255,255,255,0.12)",e.lineWidth=1,e.setLineDash([]),e.beginPath(),e.moveTo(ke,g),e.lineTo(ke,g+v),e.stroke()}if(t.showVolNumbers&&L>0){let ke=t.volNumbersFontSize??9;e.font=`${ke}px monospace`,e.textBaseline="middle",e.globalAlpha=.85;for(let Q=0;Q<E;Q++){let Pe=B[Q];if(Pe.priceHi<I-u||Pe.priceLo>x+u)continue;let _=g+Xs(Pe.priceHi,I,x,v),ie=g+Xs(Pe.priceLo,I,x,v);if(Math.max(Ik,ie-_)<ke+2)continue;let Se=_+(ie-_)/2,Re=Pe.buyVol,ye=Pe.sellVol,$e=Pe.totalVol;if(ze==="delta"){let Ue=Re-ye,je=Math.abs(Ue)/L*y*xe,ht=Ue>0?`+${Math.round(Ue)}`:String(Math.round(Ue)),Be=e.measureText(ht).width+6<je;e.fillStyle=Ue>=0?Z:de,Be?(e.textAlign="right",e.fillText(ht,p+je-3,Se)):(e.textAlign="left",e.fillText(ht,p+je+3,Se))}else if(ze==="split"){let Ue=y/2*xe,je=Re/L*Ue,ht=ye/L*Ue,Be=p+y/2,xt=String(Math.round(Re)),fn=String(Math.round(ye));e.fillStyle=V,e.textAlign=je>e.measureText(xt).width+6?"right":"left",e.fillText(xt,je>e.measureText(xt).width+6?Be+je-3:Be+je+3,Se),e.fillStyle=K,e.textAlign=ht>e.measureText(fn).width+6?"left":"right",e.fillText(fn,ht>e.measureText(fn).width+6?Be-ht+3:Be-ht-3,Se)}else{let Ue=ze==="total"?String(Math.round($e)):`${Math.round(Re)}\xD7${Math.round(ye)}`,je=$e/L*y*xe,Be=e.measureText(Ue).width+6<je;e.fillStyle="rgba(255,255,255,0.80)",Be?(e.textAlign="right",e.fillText(Ue,p+je-3,Se)):(e.textAlign="left",e.fillText(Ue,p+je+3,Se))}}e.globalAlpha=1}if(e.restore(),t.showPoc&&!isNaN(M)&&M>=I&&M<=x){let ke=Math.round(c.priceToY(M,o))+a+.5,Q=t.pocExtendLeft?0:p,Pe=t.pocExtendRight?r:p+y;if(e.strokeStyle=Ae,e.lineWidth=1,e.setLineDash([4,3]),e.beginPath(),e.moveTo(Q,ke),e.lineTo(Pe,ke),e.stroke(),e.setLineDash([]),t.showPocLabel){let _=`POC ${M.toFixed(2)}`,ie=Pe-4;N?My(e,_,ie,ke-9,su(Ae,Math.max(Iy(Ae),.85)),Oe,9,"right"):(e.font="9px monospace",e.textBaseline="middle",e.fillStyle=Ae,e.textAlign="right",e.fillText(_,ie,ke-7))}}if(t.showVaHLines&&L>0){let ke=t.vaLineColor??"#888888",Q=t.vaLineExtendLeft?0:p,Pe=t.vaLineExtendRight?r:p+y;e.strokeStyle=ke,e.lineWidth=1,e.setLineDash([4,3]);for(let[_,ie]of[[W,"VAH"],[H,"VAL"]]){if(_<I||_>x)continue;let se=Math.round(c.priceToY(_,o))+a+.5;e.beginPath(),e.moveTo(Q,se),e.lineTo(Pe,se),e.stroke(),e.setLineDash([]);let Se=`${ie} ${_.toFixed(2)}`,Re=Pe-4,ye=se-9;N?My(e,Se,Re,ye,su(t.vaLineColor??"#888888",Math.max(Iy(ke),.85)),Oe,9,"right"):(e.font="9px monospace",e.textBaseline="middle",e.fillStyle=ke,e.textAlign="right",e.fillText(Se,Re,ye)),e.setLineDash([4,3])}e.setLineDash([])}if(t.showDevPoc&&z>0&&L>0){e.strokeStyle=t.devPocColor??"#facc15",e.lineWidth=1.5,e.setLineDash([2,3]),e.beginPath();let ke=Math.min(z,60),Q=t.a.ts<t.b.ts?t.a.ts:t.b.ts,Pe=t.a.ts<t.b.ts?t.b.ts:t.a.ts,_=g+v/2;for(let ie=1;ie<=ke;ie++){let se=ie/ke,Se=Q+BigInt(Math.round(Number(Pe-Q)*se)),Re=c.tsToX(Se,r),ye=-1,$e=M;for(let je=0;je<z;je++){let ht=k[je]*se;ht>ye&&(ye=ht,$e=S[je])}let Ue=c.priceToY($e,o)+a;ie===1?e.moveTo(Re,Ue):(e.lineTo(Re,_),e.lineTo(Re,Ue)),_=Ue}e.stroke(),e.setLineDash([])}if(t.showDevVa&&z>0&&L>0){e.strokeStyle=t.devVaColor??"#888888",e.lineWidth=1.5,e.setLineDash([2,4]);let ke=Math.min(z,60),Q=t.a.ts<t.b.ts?t.a.ts:t.b.ts,Pe=t.a.ts<t.b.ts?t.b.ts:t.a.ts,_=[],ie=[];for(let se=1;se<=ke;se++){let Se=se/ke,Re=Q+BigInt(Math.round(Number(Pe-Q)*Se)),ye=c.tsToX(Re,r),$e=new Float64Array(k.map(ht=>ht*Se)),{loIdx:Ue,hiIdx:je}=Lk($e,M,S,t.valueAreaPct??70);_.push([ye,c.priceToY(S[je],o)+a]),ie.push([ye,c.priceToY(S[Ue],o)+a])}for(let se of[_,ie]){e.beginPath();for(let Se=0;Se<se.length;Se++){let[Re,ye]=se[Se];if(Se===0)e.moveTo(Re,ye);else{let[,$e]=se[Se-1];e.lineTo(Re,$e),e.lineTo(Re,ye)}}e.stroke()}e.setLineDash([])}if(i||s){let ke="#6490c8";hn(e,p,g,ke,l==="tl"),hn(e,p+y,g+v,ke,l==="br")}}function Dk(e,t,n,r,o,a,i,s,l,c,u,d,m,f,h,p,g,y,v,b,S,C){let w=e.getContext("2d");if(!w||e.width===0||e.height===0)return;let k=Vn();w.setTransform(1,0,0,1,0,0),w.clearRect(0,0,e.width,e.height),w.setTransform(k,0,0,k,0,0);let M=e.width/k,I=e.height/k,x=M-(y?0:b),T=I-(v?0:Ly),P=Ji(r,T,M,y?0:b).main,D=P?P.h:T,N=P?P.y:0,O=l?.y?g.yToPrice(l.y,D)+N:void 0,A=l?.x?g.xToTs(l.x,x):void 0;for(let B of t){if(B.visible===!1&&B.id!==o||c&&B.id===c)continue;let E=B.id===o,L=B.id===a&&!E,z=E||L?i:null,Y=io.get(B.tool);if(Y){let G=B;w.save(),w.beginPath(),w.rect(0,N,x,D),w.clip();try{Y.render({ctx:w,anchors:G.anchors,w:x,h:D,oy:N,transformer:g,selected:E,hovered:L,hotAnchor:z,data:G.data})}catch(H){console.error(`[DrawingRegistry] render error for '${G.tool}':`,H)}w.restore();continue}if(!("anchors"in B)){switch(w.save(),B.tool){case"vline":w.beginPath(),w.rect(0,0,x,T),w.clip(),g5(w,B,n,x,T,E,L,z,g);break;case"hline":w.beginPath(),w.rect(0,N,x,D),w.clip(),h5(w,B,n,x,D,N,E,L,z,g);break;case"extended-line":w.beginPath(),w.rect(0,N,x,D),w.clip(),b5(w,B,n,x,D,N,E,L,z,g);break;case"line":w.beginPath(),w.rect(0,N,x,D),w.clip(),y5(w,B,n,x,D,N,E,L,z,g);break;case"cross-line":w.beginPath(),w.rect(0,N,x,D),w.clip(),v5(w,B,n,x,D,N,E,L,z,g);break;case"info-line":w.beginPath(),w.rect(0,N,x,D),w.clip(),w5(w,B,n,x,D,N,E,L,z,g);break;case"trend-angle":w.beginPath(),w.rect(0,N,x,D),w.clip(),x5(w,B,n,x,D,N,E,L,z,g);break;case"ray":w.beginPath(),w.rect(0,N,x,D),w.clip(),S5(w,B,n,x,D,N,E,L,z,g);break;case"hray":w.beginPath(),w.rect(0,N,x,D),w.clip(),C5(w,B,n,x,D,N,E,L,z,g);break;case"parallel-channel":w.beginPath(),w.rect(0,N,x,D),w.clip(),Ck(w,B,n,x,D,N,E,L,z,g);break;case"rect":w.beginPath(),w.rect(0,N,x,D),w.clip(),k5(w,B,n,x,D,N,E,L,z,g);break;case"triangle":w.beginPath(),w.rect(0,N,x,D),w.clip(),T5(w,B,n,x,D,N,E,L,z,g);break;case"fib":w.beginPath(),w.rect(0,N,x,D),w.clip(),I5(w,B,n,x,D,N,E,L,z,g);break;case"text":w.beginPath(),w.rect(0,N,x,D),w.clip(),M5(w,B,n,x,D,N,E,L,z,g);break;case"fvp":w.beginPath(),w.rect(0,N,x,D),w.clip(),A5(w,B,n,x,D,N,E,L,z,g,ro(S));break;case"long":case"short":w.beginPath(),w.rect(0,N,x,D),w.clip(),P5(w,B,x,D,N,E,L,z,g,S);break}w.restore()}}if(s&&O!==void 0&&A!==void 0){if(w.save(),s&&"pluginToolId"in s){let B=s,E=io.get(B.pluginToolId);if(E?.preview&&A!==void 0&&O!==void 0){w.save(),w.globalAlpha=.6,w.beginPath(),w.rect(0,N,x,D),w.clip();try{E.preview({ctx:w,anchors:B.anchors,w:x,h:D,oy:N,transformer:g,selected:!1,hovered:!1,hotAnchor:null,data:B.data,cursorAnchor:{ts:A,price:O}})}catch(L){console.error(`[DrawingRegistry] preview error for '${B.pluginToolId}':`,L)}w.restore()}}if(!("pluginToolId"in s))switch(s.tool){case"hline":{let B=g.priceToY(s.price,D)+N;w.strokeStyle="#e0e0e0",w.lineWidth=1,w.beginPath(),w.moveTo(0,B),w.lineTo(x,B),w.stroke();break}case"vline":{let B=g.tsToX(s.ts,x);w.strokeStyle="#888888",w.lineWidth=1,w.beginPath(),w.moveTo(B,0),w.lineTo(B,T),w.stroke();break}case"extended-line":case"info-line":case"trend-angle":case"line":case"ray":{let B=g.tsToX(s.a.ts,x),E=g.priceToY(s.a.price,D)+N,L=wd(A,m,g.getSessionMapper()),z=g.tsToX(L,x),Y=g.priceToY(O,D)+N;if(d)Y=E;else if(u){let H=xd(L,O,f,h,p,[],"l3",C);Y=g.priceToY(H,D)+N}let G=Y;if(w.strokeStyle="#e0e0e0",w.lineWidth=1,w.beginPath(),s.tool==="ray"){let H=z>=B,[W,U,V,K]=Aa(B,E,z,G,x,!H,H),Z=H?V:W,de=H?K:U;w.moveTo(B,E),w.lineTo(Z,de)}else if(s.tool==="extended-line"){let[H,W,U,V]=Aa(B,E,z,G,x,!0,!0);w.moveTo(H,W),w.lineTo(U,V)}else s.tool==="trend-angle"?(Rk(w,{...s,b:{ts:L,price:O}},n,x,D,N,g),w.moveTo(B,E),w.lineTo(z,G)):(w.moveTo(B,E),w.lineTo(z,G));w.stroke();break}case"parallel-channel":{let B=g.tsToX(s.a.ts,x),E=g.priceToY(s.a.price,D)+N,L=wd(A,m,g.getSessionMapper()),z=g.tsToX(L,x),Y=g.priceToY(O,D)+N;if(d)Y=E;else if(u){let H=xd(L,O,f,h,p,[],"l3",C);Y=g.priceToY(H,D)+N}let G=Y;w.beginPath(),s?.b?Ck(w,{...s,b:s.b,height:O-s.b.price},n,x,D,N,!1,!1,null,g):(w.strokeStyle="#e0e0e0",w.moveTo(B,E),w.lineTo(z,G)),w.stroke();break}case"rect":case"fib":{if(s.b){let B=g.tsToX(s.a.ts,x),E=g.priceToY(s.a.price,D)+N,L=g.tsToX(s.b.ts,x),z=g.priceToY(s.b.price,D)+N;if(s.tool==="rect")w.strokeStyle="#3b82f6",w.lineWidth=1,w.strokeRect(Math.min(B,L),Math.min(E,z),Math.abs(L-B),Math.abs(z-E));else{w.strokeStyle="#facc15",w.lineWidth=1;for(let Y of Pb){let G=s.a.price-s.b.price,H=s.b.price+G*parseFloat(Y.value),W=g.priceToY(H,D)+N;w.beginPath(),w.moveTo(g.tsToX(s.a.ts,x),W),w.lineTo(g.tsToX(s.b.ts,x),W),w.stroke()}}}else{let B=g.tsToX(s.a.ts,x),E=g.priceToY(s.a.price,D)+N;w.strokeStyle="#3b82f6",w.lineWidth=1,w.strokeRect(B-4,E-4,8,8)}break}case"triangle":{let B=g.tsToX(s.a.ts,x),E=g.priceToY(s.a.price,D)+N,L=wd(A,m,g.getSessionMapper()),z=g.tsToX(L,x),Y=g.priceToY(O,D)+N;if(d)Y=E;else if(u){let H=xd(L,O,f,h,p,[],"l3",C);Y=g.priceToY(H,D)+N}let G=Y;w.beginPath(),w.moveTo(B,E),s.b?(w.lineTo(g.tsToX(s.b.ts,x),g.priceToY(s.b.price,D)+N),w.lineTo(z,G),w.closePath()):w.lineTo(z,G),w.strokeStyle="#3b82f6",w.fillStyle="#3b82f61a",s.b&&w.fill(),w.stroke();break}case"text":{let B=g.tsToX(s.anchor.ts,x),E=g.priceToY(s.anchor.price,D)+N;w.strokeStyle="#e0e0e0",w.lineWidth=1,w.strokeRect(B-4,E-12,48,16);break}case"fvp":{if(s.b){let B=g.tsToX(s.a.ts,x),E=g.priceToY(s.a.price,D)+N,L=g.tsToX(s.b.ts,x),z=g.priceToY(O,D)+N;w.lineWidth=1,w.strokeStyle="#3b82f6",w.beginPath(),w.moveTo(B,0),w.lineTo(B,T),w.stroke(),w.beginPath(),w.moveTo(L,0),w.lineTo(L,T),w.stroke(),w.beginPath(),w.moveTo(B,E),w.lineTo(L,z),w.stroke()}else{let B=g.tsToX(s.a.ts,x);w.strokeStyle="#3b82f6",w.lineWidth=1,w.beginPath(),w.moveTo(B,0),w.lineTo(B,T),w.stroke()}break}}w.restore()}}function Cf(e,t,n,r,o,a,i,s,l,c,u){let d=KS,m=a-c,f=i-(l?0:Ly),p=Ji(o,f,a,c).main,g=p?p.h:f,y=p?p.y:0;for(let v=n.length-1;v>=0;v--){let b=n[v];if(b.visible===!1)continue;let S=io.get(b.tool);if(S){let C=b;try{let w=S.hitTest({mx:e,my:t,anchors:C.anchors,w:m,h:g,oy:y,transformer:s,data:C.data});if(w!==!1)return{drawingId:b.id,anchor:w==="body"?"body":w}}catch(w){console.error(`[DrawingRegistry] hitTest error for '${C.tool}':`,w)}continue}if(!("anchors"in b))switch(b.tool){case"hline":{let C=s.priceToY(b.price,g)+y;if(Math.abs(t-C)<=d&&e>=0&&e<=m)return{drawingId:b.id,anchor:"body"};break}case"vline":{let C=s.tsToX(b.ts,m);if(Math.abs(e-C)<=d&&t>=0&&t<=f)return{drawingId:b.id,anchor:"body"};break}case"extended-line":{let C=s.tsToX(b.a.ts,m),w=s.priceToY(b.a.price,g)+y,k=s.tsToX(b.b.ts,m),M=s.priceToY(b.b.price,g)+y,[I,x,T,R]=Aa(C,w,k,M,m,b.extendLeft,b.extendRight);if(Math.hypot(e-C,t-w)<=d+2)return{drawingId:b.id,anchor:"a"};if(Math.hypot(e-k,t-M)<=d+2)return{drawingId:b.id,anchor:"b"};if(di(e,t,I,x,T,R)<=d)return{drawingId:b.id,anchor:"body"};break}case"info-line":case"trend-angle":case"line":{let C=s.tsToX(b.a.ts,m),w=s.priceToY(b.a.price,g)+y,k=s.tsToX(b.b.ts,m),M=s.priceToY(b.b.price,g)+y,[I,x,T,R]=Aa(C,w,k,M,m,b.extendLeft,b.extendRight);if(Math.hypot(e-C,t-w)<=d+2)return{drawingId:b.id,anchor:"a"};if(Math.hypot(e-k,t-M)<=d+2)return{drawingId:b.id,anchor:"b"};if(di(e,t,I,x,T,R)<=d)return{drawingId:b.id,anchor:"body"};break}case"cross-line":{let C=s.priceToY(b.price,g)+y,w=s.tsToX(b.ts,m);if(Math.abs(t-C)<=d&&e>=0&&e<=m)return{drawingId:b.id,anchor:"body"};if(Math.abs(e-w)<=d&&t>=0&&t<=f)return{drawingId:b.id,anchor:"body"};break}case"ray":{let C=s.tsToX(b.a.ts,m),w=s.priceToY(b.a.price,g)+y,k=s.tsToX(b.b.ts,m),M=s.priceToY(b.b.price,g)+y,I=k>=C,[x,T,R,P]=Aa(C,w,k,M,m,!I,I),D=I?R:x,N=I?P:T;if(Math.hypot(e-C,t-w)<=d+2)return{drawingId:b.id,anchor:"a"};if(Math.hypot(e-k,t-M)<=d+2)return{drawingId:b.id,anchor:"b"};if(di(e,t,C,w,D,N)<=d)return{drawingId:b.id,anchor:"body"};break}case"hray":{let C=s.priceToY(b.price,g)+y,w=s.tsToX(b.ts,m);if(Math.abs(t-C)<=d&&e>=w&&e<=m)return{drawingId:b.id,anchor:"body"};break}case"parallel-channel":{let C=s.tsToX(b.a.ts,m),w=s.priceToY(b.a.price,g)+y,k=s.tsToX(b.b.ts,m),M=s.priceToY(b.b.price,g)+y,I=s.priceToY(b.a.price+b.height,g)+y,x=s.priceToY(b.b.price+b.height,g)+y,T=(C+k)/2;if(Math.hypot(e-C,t-w)<=d+2)return{drawingId:b.id,anchor:"a"};if(Math.hypot(e-k,t-M)<=d+2)return{drawingId:b.id,anchor:"b"};if(Math.hypot(e-C,t-I)<=d+2)return{drawingId:b.id,anchor:"a2"};if(Math.hypot(e-k,t-x)<=d+2)return{drawingId:b.id,anchor:"a3"};if(Math.hypot(e-T,t-(w+M)/2)<=d+2)return{drawingId:b.id,anchor:"mt"};if(Math.hypot(e-T,t-(I+x)/2)<=d+2)return{drawingId:b.id,anchor:"mb"};let R=b.extendLeft??!1,P=b.extendRight??!1;for(let D of b.levels??Sl){if(!D.enabled)continue;let N=s.priceToY(b.a.price+Number(D.value)*b.height,g)+y,O=s.priceToY(b.b.price+Number(D.value)*b.height,g)+y,[A,B,E,L]=Aa(C,N,k,O,m,R,P);if(di(e,t,A,B,E,L)<=d)return{drawingId:b.id,anchor:"body"}}break}case"rect":{let C=s.tsToX(b.a.ts,m),w=s.priceToY(b.a.price,g)+y,k=s.tsToX(b.b.ts,m),M=s.priceToY(b.b.price,g)+y,I=Math.min(C,k),x=Math.min(w,M),T=Math.abs(k-C),R=Math.abs(M-w),P=[[I,x,"tl"],[I+T,x,"tr"],[I,x+R,"bl"],[I+T,x+R,"br"]];for(let[N,O,A]of P)if(Math.hypot(e-N,t-O)<=d+2)return{drawingId:b.id,anchor:A};let D=[[I+T/2,x,"mt"],[I+T/2,x+R,"mb"],[I,x+R/2,"ml"],[I+T,x+R/2,"mr"]];for(let[N,O,A]of D)if(Math.hypot(e-N,t-O)<=d+2)return{drawingId:b.id,anchor:A};if(di(e,t,I,x,I+T,x)<=d||di(e,t,I+T,x,I+T,x+R)<=d||di(e,t,I+T,x+R,I,x+R)<=d||di(e,t,I,x+R,I,x)<=d)return{drawingId:b.id,anchor:"body"};break}case"triangle":{let C=s.tsToX(b.a.ts,m),w=s.priceToY(b.a.price,g)+y,k=s.tsToX(b.b.ts,m),M=s.priceToY(b.b.price,g)+y,I=s.tsToX(b.c.ts,m),x=s.priceToY(b.c.price,g)+y,T=[[C,w,"a"],[k,M,"b"],[I,x,"c"]];for(let[R,P,D]of T)if(Math.hypot(e-R,t-P)<=d+2)return{drawingId:b.id,anchor:D};if(di(e,t,C,w,k,M)<=d||di(e,t,k,M,I,x)<=d||di(e,t,I,x,C,w)<=d)return{drawingId:b.id,anchor:"body"};break}case"fib":{let C=s.tsToX(b.a.ts,m),w=s.priceToY(b.a.price,g)+y,k=s.tsToX(b.b.ts,m),M=s.priceToY(b.b.price,g)+y;if(Math.hypot(e-C,t-w)<=d+2)return{drawingId:b.id,anchor:"a"};if(Math.hypot(e-k,t-M)<=d+2)return{drawingId:b.id,anchor:"b"};let I=Math.min(C,k),x=Math.max(C,k),T=b.a.price-b.b.price;for(let R of b.levels){if(!R.enabled)continue;let P=b.b.price+T*parseFloat(R.value),D=s.priceToY(P,g)+y;if(Math.abs(t-D)<=d&&e>=I&&e<=x)return{drawingId:b.id,anchor:"body"}}break}case"text":{let C=b.screenAnchored&&b.screenX!==void 0?b.screenX:s.tsToX(b.anchor.ts,m),w=b.screenAnchored&&b.screenY!==void 0?b.screenY:s.priceToY(b.anchor.price,g)+y;if(Math.hypot(e-C,t-w)<=d+2)return{drawingId:b.id,anchor:"anchor"};let k=b.text.split(`
|
|
5
|
+
`),M=b.fontSize*1.4,I=k.length*M,x=Math.max(...k.map(T=>T.length));if(e>=C&&e<=C+x*(b.fontSize*.6)+8&&t>=w-b.fontSize-4&&t<=w-4+I)return{drawingId:b.id,anchor:"body"};break}case"fvp":{let C=s.tsToX(b.a.ts,m),w=s.priceToY(b.a.price,g)+y,k=s.tsToX(b.b.ts,m),M=s.priceToY(b.b.price,g)+y,I=Math.min(C,k),x=Math.min(w,M),T=Math.abs(k-C),R=Math.abs(M-w),P=[[I,x,"tl"],[I+T,x,"tr"],[I,x+R,"bl"],[I+T,x+R,"br"]];for(let[N,O,A]of P)if(Math.hypot(e-N,t-O)<=d+2)return{drawingId:b.id,anchor:A};let D=[[I+T/2,x,"mt"],[I+T/2,x+R,"mb"],[I,x+R/2,"ml"],[I+T,x+R/2,"mr"]];for(let[N,O,A]of D)if(Math.hypot(e-N,t-O)<=d+2)return{drawingId:b.id,anchor:A};if(e>=I&&e<=I+T&&t>=x&&t<=x+R)return{drawingId:b.id,anchor:"body"};break}case"long":case"short":{let C=s.tsToX(b.a.ts,m),w=s.tsToX(b.b.ts,m),{entry:k,top:M,bottom:I}=Pk(b,ro(u)),x=s.priceToY(M,g)+y,T=s.priceToY(I,g)+y,R=s.priceToY(k,g)+y,P=Math.min(C,w),D=Math.abs(w-C),N=[[P,x,"mt"],[P,T,"mb"],[P,R,"all"],[P+D,R,"mr"]];for(let[O,A,B]of N)if(Math.hypot(e-O,t-A)<=d+2)return{drawingId:b.id,anchor:B};if(e>=P&&e<=P+D&&t>=Math.min(x,T)&&t<=Math.max(x,T))return{drawingId:b.id,anchor:"body"};break}}}return null}function Ak(e,t,n,r,o,a,i,s){let l=Vn(),c=r/l,u=o/l,d=c-s,m=u-(i?0:Ly),h=Ji(n,m,c,s).main,p=h?h.h:m,g=h?h.y:0;if("anchors"in e)return{x:0,y:0};switch(e.tool){case"hline":return{x:80,y:a.priceToY(e.price,p)+g};case"vline":return{x:a.tsToX(e.ts,d)+8,y:20};case"cross-line":return{x:a.tsToX(e.ts,d)+8,y:a.priceToY(e.price,p)+g};case"extended-line":case"info-line":case"trend-angle":case"line":case"parallel-channel":case"ray":{let y=a.tsToX(e.a.ts,d),v=a.priceToY(e.a.price,p)+g,b=a.tsToX(e.b.ts,d),S=a.priceToY(e.b.price,p)+g;return{x:(y+b)/2,y:(v+S)/2-28}}case"hray":{let y=a.tsToX(e.ts,d),v=a.priceToY(e.price,p)+g;return{x:(y+d)/2,y:(v+p)/2-28+g}}case"rect":case"fib":{let y=a.tsToX(e.a.ts,d),v=a.priceToY(e.a.price,p)+g,b=a.tsToX(e.b.ts,d),S=a.priceToY(e.b.price,p)+g;return{x:(y+b)/2,y:Math.min(v,S)-28}}case"triangle":{let y=a.tsToX(e.a.ts,d),v=a.priceToY(e.a.price,p)+g,b=a.tsToX(e.b.ts,d),S=a.priceToY(e.b.price,p)+g,C=a.tsToX(e.c.ts,d),w=a.priceToY(e.c.price,p)+g;return{x:(Math.min(y,b,C)+Math.max(y,b,C))/2,y:Math.min(v,S,w)-28}}case"text":{let y=e.screenAnchored&&e.screenX!==void 0?e.screenX:a.tsToX(e.anchor.ts,d),v=e.screenAnchored&&e.screenY!==void 0?e.screenY:a.priceToY(e.anchor.price,p)+g;return{x:y,y:v-28}}case"fvp":{let y=a.tsToX(e.a.ts,d),v=a.priceToY(e.a.price,p)+g,b=a.tsToX(e.b.ts,d),S=a.priceToY(e.b.price,p)+g;return{x:(y+b)/2,y:Math.min(v,S)-28}}case"long":case"short":{let y=a.tsToX(e.a.ts,d),v=a.tsToX(e.b.ts,d),b=a.priceToY(e.a.price+Math.max(e.upAmount,0),p)+g,S=a.priceToY(e.a.price-Math.max(e.downAmount,0),p)+g;return{x:(y+v)/2,y:Math.min(b,S)-28}}}}function Bk(e,t,n,r,o,a,i){let s=(l,c=t)=>({drawing:l,anchor:c});if("anchors"in e){let l=e,c=io.get(e.tool);if(c?.onMove){let d=c.onMove({data:l.data,anchors:l.anchors??[],anchor:t,dts:n,dprice:r,curTs:o,curPrice:a});return s({...l,data:d})}if(!l.anchors)return s(e);if(t==="body")return s({...l,anchors:l.anchors.map(d=>({ts:d.ts+n,price:d.price+r}))});if(typeof t!="string")return s(e);let u=parseInt(t.replace("a",""),10);if(!isNaN(u)&&u<l.anchors.length){let d=l.anchors.slice();return d[u]={ts:o,price:a},s({...l,anchors:d})}return s(e)}switch(e.tool){case"hline":return s(t==="body"?{...e,price:a}:{...e,price:a});case"vline":return s(t==="body"?{...e,ts:e.ts+n}:{...e,ts:o});case"extended-line":case"info-line":case"trend-angle":case"line":case"ray":return s(t==="a"?{...e,a:{ts:o,price:i&&e?.b?.price?e.b.price:a}}:t==="b"?{...e,b:{ts:o,price:i?e.a.price:a}}:{...e,a:{ts:e.a.ts+n,price:e.a.price+r},b:{ts:e.b.ts+n,price:e.b.price+r}});case"cross-line":return s({...e,price:e.price+r,ts:e.ts+n});case"hray":return s({...e,price:e.price+r,ts:e.ts+n});case"parallel-channel":if(t==="a")return s({...e,a:{ts:o,price:i&&e?.b?.price?e.b.price:a}});if(t==="b")return s({...e,b:{ts:o,price:i?e.a.price:a}});if(t==="a2")return s({...e,a:{ts:o,price:i&&e?.b?.price?e.b.price:a-e.height}});if(t==="a3")return s({...e,b:{ts:o,price:i?e.a.price:a-e.height}});if(t==="mt"){let l=a-(e.a.price+e.b.price)/2;return s({...e,a:{...e.a,price:e.a.price+l},b:{...e.b,price:e.b.price+l},height:e.height-l})}return s(t==="mb"?{...e,height:a-(e.a.price+e.b.price)/2}:{...e,a:{ts:e.a.ts+n,price:e.a.price+r},b:{ts:e.b.ts+n,price:e.b.price+r}});case"rect":{let l=e.a.ts<e.b.ts?e.a.ts:e.b.ts,c=e.a.ts<e.b.ts?e.b.ts:e.a.ts,u=e.a.price<e.b.price?e.a.price:e.b.price,d=e.a.price<e.b.price?e.b.price:e.a.price,m=l,f=c,h=u,p=d;switch(t){case"tl":m=o,p=a;break;case"tr":f=o,p=a;break;case"bl":m=o,h=a;break;case"br":f=o,h=a;break;case"mt":p=a;break;case"mb":h=a;break;case"ml":m=o;break;case"mr":f=o;break;default:m=l+n,f=c+n,h=u+r,p=d+r}let g=m>f,y=h>p;if(g){let b=m;m=f,f=b}if(y){let b=h;h=p,p=b}let v=t;if(g||y){let b=C=>C==="ml"?"mr":C==="mr"?"ml":C==="tl"?"tr":C==="tr"?"tl":C==="bl"?"br":C==="br"?"bl":C,S=C=>C==="mt"?"mb":C==="mb"?"mt":C==="tl"?"bl":C==="bl"?"tl":C==="tr"?"br":C==="br"?"tr":C;g&&(v=b(v)),y&&(v=S(v))}return s({...e,a:{ts:m,price:h},b:{ts:f,price:p}},v)}case"triangle":{if(i){if(t==="a")return s({...e,a:{ts:o,price:e[Math.abs(e.b.price-a)<Math.abs(e.c.price-a)?"b":"c"].price}});if(t==="b")return s({...e,b:{ts:o,price:e[Math.abs(e.a.price-a)<Math.abs(e.c.price-a)?"a":"c"].price}});if(t==="c")return s({...e,c:{ts:o,price:e[Math.abs(e.a.price-a)<Math.abs(e.b.price-a)?"a":"b"].price}})}else{if(t==="a")return s({...e,a:{ts:o,price:a}});if(t==="b")return s({...e,b:{ts:o,price:a}});if(t==="c")return s({...e,c:{ts:o,price:a}})}return s({...e,a:{ts:e.a.ts+n,price:e.a.price+r},b:{ts:e.b.ts+n,price:e.b.price+r},c:{ts:e.c.ts+n,price:e.c.price+r}})}case"fib":return s(t==="a"?{...e,a:{ts:o,price:a}}:t==="b"?{...e,b:{ts:o,price:a}}:{...e,a:{ts:e.a.ts+n,price:e.a.price+r},b:{ts:e.b.ts+n,price:e.b.price+r}});case"text":return s(t==="body"||t==="anchor"?{...e,anchor:{ts:e.anchor.ts+n,price:e.anchor.price+r}}:{...e,anchor:{ts:o,price:a}});case"fvp":{let l=e.a.ts<e.b.ts?e.a.ts:e.b.ts,c=e.a.ts<e.b.ts?e.b.ts:e.a.ts,u=e.a.price<e.b.price?e.a.price:e.b.price,d=e.a.price<e.b.price?e.b.price:e.a.price,m=l,f=c,h=u,p=d;switch(t){case"tl":m=o,p=a;break;case"tr":f=o,p=a;break;case"bl":m=o,h=a;break;case"br":f=o,h=a;break;case"mt":p=a;break;case"mb":h=a;break;case"ml":m=o;break;case"mr":f=o;break;default:m=l+n,f=c+n,h=u+r,p=d+r}let g=m>f,y=h>p;if(g){let b=m;m=f,f=b}if(y){let b=h;h=p,p=b}let v=t;if(g||y){let b=C=>C==="ml"?"mr":C==="mr"?"ml":C==="tl"?"tr":C==="tr"?"tl":C==="bl"?"br":C==="br"?"bl":C,S=C=>C==="mt"?"mb":C==="mb"?"mt":C==="tl"?"bl":C==="bl"?"tl":C==="tr"?"br":C==="br"?"tr":C;g&&(v=b(v)),y&&(v=S(v))}return s({...e,a:{ts:m,price:h},b:{ts:f,price:p}},v)}case"long":case"short":{let l=e.a.ts<e.b.ts?e.a.ts:e.b.ts,c=e.a.ts<e.b.ts?e.b.ts:e.a.ts,u=e.a.price+Math.max(e.upAmount,0),d=e.a.price-Math.max(e.downAmount,0),m=l,f=c,h=u,p=e.a.price,g=d;switch(t){case"mt":h=a;break;case"mb":g=a;break;case"all":p=a,m=o;break;case"mr":f=o;break;default:m=l+n,f=c+n,h+=r,p+=r,g+=r}let y=t;if(m>f){let v=m;m=f,f=v,y==="ml"?y="mr":y==="mr"&&(y="ml")}return s({...e,a:{ts:m,price:p},b:{ts:f,price:p},upAmount:Math.max(h-p,0),downAmount:Math.max(p-g,0)},y)}}}import{useRef as qh,useEffect as Lv,useLayoutEffect as Q6,useState as Uh,useCallback as jh}from"react";import{useState as xi,useEffect as Wh,useCallback as KL,useRef as oc,useLayoutEffect as F6}from"react";import*as iT from"react";import*as Gr from"react";var B5=Object.defineProperty,lu=(e,t)=>B5(e,"name",{value:t,configurable:!0}),Nk=!!(typeof window<"u"&&window.document&&window.document.createElement);function lt(e,t,{checkForDefaultPrevented:n=!0}={}){return lu(function(o){if(e?.(o),n===!1||!o||!o.defaultPrevented)return t?.(o)},"handleEvent")}lu(lt,"composeEventHandlers");function N5(e){if(!Nk)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}lu(N5,"getOwnerWindow");function Dy(e){if(!Nk)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}lu(Dy,"getOwnerDocument");function Ek(e,t=!1){let{activeElement:n}=Dy(e);if(!n?.nodeName)return null;if(Ok(n)&&n.contentDocument)return Ek(n.contentDocument.body,t);if(t){let r=n.getAttribute("aria-activedescendant");if(r){let o=Dy(n).getElementById(r);if(o)return o}}return n}lu(Ek,"getActiveElement");function Ok(e){return e.tagName==="IFRAME"}lu(Ok,"isFrame");import*as _k from"react";var E5=Object.defineProperty,By=(e,t)=>E5(e,"name",{value:t,configurable:!0});function Ay(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}By(Ay,"setRef");function Fk(...e){return t=>{let n=!1,r=e.map(o=>{let a=Ay(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){let a=r[o];typeof a=="function"?a():Ay(e[o],null)}}}}By(Fk,"composeRefs");function Kt(...e){return _k.useCallback(Fk(...e),e)}By(Kt,"useComposedRefs");import*as Na from"react";import{jsx as zk}from"react/jsx-runtime";var O5=Object.defineProperty,Ba=(e,t)=>O5(e,"name",{value:t,configurable:!0});function _5(e,t){let n=Na.createContext(t);n.displayName=e+"Context";let r=Ba(a=>{let{children:i,...s}=a,l=Na.useMemo(()=>s,Object.values(s));return zk(n.Provider,{value:l,children:i})},"Provider");r.displayName=e+"Provider";function o(a,i={}){let{optional:s=!1}=i,l=Na.useContext(n);if(l)return l;if(t!==void 0)return t;if(!s)throw new Error(`\`${a}\` must be used within \`${e}\``)}return Ba(o,"useContext"),[r,o]}Ba(_5,"createContext");function xr(e,t=[]){let n=[];function r(a,i){let s=Na.createContext(i);s.displayName=a+"Context";let l=n.length;n=[...n,i];let c=Ba(d=>{let{scope:m,children:f,...h}=d,p=m?.[e]?.[l]||s,g=Na.useMemo(()=>h,Object.values(h));return zk(p.Provider,{value:g,children:f})},"Provider");c.displayName=a+"Provider";function u(d,m,f={}){let{optional:h=!1}=f,p=m?.[e]?.[l]||s,g=Na.useContext(p);if(g)return g;if(i!==void 0)return i;if(!h)throw new Error(`\`${d}\` must be used within \`${a}\``)}return Ba(u,"useContext"),[c,u]}Ba(r,"createContext");let o=Ba(()=>{let a=n.map(i=>Na.createContext(i));return Ba(function(s){let l=s?.[e]||a;return Na.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])},"useScope")},"createScope");return o.scopeName=e,[r,Hk(o,...t)]}Ba(xr,"createContextScope");function Hk(...e){let t=e[0];if(e.length===1)return t;let n=Ba(()=>{let r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return Ba(function(a){let i=r.reduce((s,{useScope:l,scopeName:c})=>{let d=l(a)[`__scope${c}`];return{...s,...d}},{});return Na.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Ba(Hk,"composeContextScopes");import*as Ea from"react";var jp=!1;import*as Vk from"react";var Fr=globalThis?.document?Vk.useLayoutEffect:()=>{};import*as fi from"react";import*as cu from"react";var F5=Object.defineProperty,z5=(e,t)=>F5(e,"name",{value:t,configurable:!0}),Wk=cu[" useEffectEvent ".trim().toString()],qk=cu[" useInsertionEffect ".trim().toString()];function Ny(e){if(typeof Wk=="function")return Wk(e);let t=cu.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof qk=="function"?qk(()=>{t.current=e}):Fr(()=>{t.current=e}),cu.useMemo(()=>((...n)=>t.current?.(...n)),[])}z5(Ny,"useEffectEvent");var H5=Object.defineProperty,kf=(e,t)=>H5(e,"name",{value:t,configurable:!0}),V5=Ea[" useInsertionEffect ".trim().toString()]||Fr;function go({prop:e,defaultProp:t,onChange:n=kf(()=>{},"onChange"),caller:r}){let[o,a,i]=jk({defaultProp:t,onChange:n}),s=e!==void 0,l=s?e:o;if(jp){let u=Ea.useRef(e!==void 0);Ea.useEffect(()=>{let d=u.current;d!==s&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=s},[s,r])}let c=Ea.useCallback(u=>{if(s){let d=Gk(u)?u(e):u;d!==e&&i.current?.(d)}else a(u)},[s,e,a,i]);return[l,c]}kf(go,"useControllableState");function jk({defaultProp:e,onChange:t}){let[n,r]=Ea.useState(e),o=Ea.useRef(n),a=Ea.useRef(t);return V5(()=>{a.current=t},[t]),Ea.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,r,a]}kf(jk,"useUncontrolledState");function Gk(e){return typeof e=="function"}kf(Gk,"isFunction");var Uk=Symbol("RADIX:SYNC_STATE");function W5(e,t,n,r){let{prop:o,defaultProp:a,onChange:i,caller:s}=t,l=o!==void 0,c=Ny(i);if(jp){let g=fi.useRef(o!==void 0);fi.useEffect(()=>{let y=g.current;y!==l&&console.warn(`${s} is changing from ${y?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),g.current=l},[l,s])}let u=[{...n,state:a}];r&&u.push(r);let[d,m]=fi.useReducer((g,y)=>{if(y.type===Uk)return{...g,state:y.state};let v=e(g,y);return l&&!Object.is(v.state,g.state)&&c(v.state),v},...u),f=d.state,h=fi.useRef(f);fi.useEffect(()=>{h.current!==f&&(h.current=f,l||c(f))},[f,h,l]);let p=fi.useMemo(()=>o!==void 0?{...d,state:o}:d,[d,o]);return fi.useEffect(()=>{l&&!Object.is(o,d.state)&&m({type:Uk,state:o})},[o,d.state,l]),[p,m]}kf(W5,"useControllableStateReducer");import*as Yk from"react";var q5=Object.defineProperty,U5=(e,t)=>q5(e,"name",{value:t,configurable:!0});function es(e){let[t,n]=Yk.useState(void 0);return Fr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;let a=o[0],i,s;if("borderBoxSize"in a){let l=a.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,s=c.blockSize}else i=e.offsetWidth,s=e.offsetHeight;n({width:i,height:s})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}U5(es,"useSize");import*as eT from"react";import*as tT from"react-dom";import*as bo from"react";var j5=Object.defineProperty,mi=(e,t)=>j5(e,"name",{value:t,configurable:!0});function $o(e){let t=bo.forwardRef((n,r)=>{let{children:o,...a}=n,i=null,s=!1,l=[];Ey(o)&&typeof Gp=="function"&&(o=Gp(o._payload)),bo.Children.forEach(o,m=>{if(Qk(m)){s=!0;let f=m,h="child"in f.props?f.props.child:f.props.children;Ey(h)&&typeof Gp=="function"&&(h=Gp(h._payload)),i=G5(f,h),l.push(i?.props?.children)}else l.push(m)}),i?i=bo.cloneElement(i,void 0,l):!s&&bo.Children.count(o)===1&&bo.isValidElement(o)&&(i=o);let c=i?Zk(i):void 0,u=Kt(r,c);if(!i){if(o||o===0)throw new Error(s?$5(e):K5(e));return o}let d=Xk(a,i.props??{});return i.type!==bo.Fragment&&(d.ref=r?u:c),bo.cloneElement(i,d)});return t.displayName=`${e}.Slot`,t}mi($o,"createSlot");var Kk=$o("Slot"),$k=Symbol.for("radix.slottable");function Oy(e){let t=mi(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=$k,t}mi(Oy,"createSlottable");var G5=mi((e,t)=>{if("child"in e.props){let n=e.props.child;return bo.isValidElement(n)?bo.cloneElement(n,void 0,e.props.children(n.props.children)):null}return bo.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function Xk(e,t){let n={...t};for(let r in t){let o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...s)=>{let l=a(...s);return o(...s),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}mi(Xk,"mergeProps");function Zk(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}mi(Zk,"getElementRef");function Qk(e){return bo.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===$k}mi(Qk,"isSlottable");var Y5=Symbol.for("react.lazy");function Ey(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Y5&&"_payload"in e&&Jk(e._payload)}mi(Ey,"isLazyComponent");function Jk(e){return typeof e=="object"&&e!==null&&"then"in e}mi(Jk,"isPromiseLike");var K5=mi(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),$5=mi(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Gp=bo[" use ".trim().toString()];import{jsx as Q5}from"react/jsx-runtime";var X5=Object.defineProperty,Z5=(e,t)=>X5(e,"name",{value:t,configurable:!0}),J5=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],dn=J5.reduce((e,t)=>{let n=$o(`Primitive.${t}`),r=eT.forwardRef((o,a)=>{let{asChild:i,...s}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),Q5(l,{...s,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Tf(e,t){e&&tT.flushSync(()=>e.dispatchEvent(t))}Z5(Tf,"dispatchDiscreteCustomEvent");import{Fragment as t4,jsx as Hl,jsxs as n4}from"react/jsx-runtime";var e4=Object.defineProperty,Zs=(e,t)=>e4(e,"name",{value:t,configurable:!0}),_y="Switch",[r4,YZ]=xr(_y),[o4,Fy]=r4(_y);function nT(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:o,disabled:a,form:i,name:s,onCheckedChange:l,required:c,value:u="on",internal_do_not_use_render:d}=e,[m,f]=go({prop:n,defaultProp:o??!1,onChange:l,caller:_y}),[h,p]=Gr.useState(null),[g,y]=Gr.useState(null),v=Gr.useRef(!1),[b,S]=Gr.useReducer(k=>k+1,0),C=h?!!i||!!h.closest("form"):!0,w={checked:m,setChecked:f,disabled:a,control:h,setControl:p,name:s,form:i,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:b,onUserInteraction:S,required:c,defaultChecked:o,isFormControl:C,bubbleInput:g,setBubbleInput:y};return Hl(o4,{scope:t,...w,children:oT(d)?d(w):r})}Zs(nT,"SwitchProvider");var a4="SwitchTrigger",i4=Gr.forwardRef(Zs(function({__scopeSwitch:t,onClick:n,...r},o){let{control:a,form:i,value:s,disabled:l,checked:c,required:u,setControl:d,setChecked:m,hasConsumerStoppedPropagationRef:f,onUserInteraction:h,isFormControl:p,bubbleInput:g}=Fy(a4,t),y=Kt(o,d),v=Gr.useRef(c);return Gr.useEffect(()=>{let b=i?a?.ownerDocument.getElementById(i):a?.form;if(b instanceof HTMLFormElement){let S=Zs(()=>m(v.current),"reset");return b.addEventListener("reset",S),()=>b.removeEventListener("reset",S)}},[a,i,m]),Hl(dn.button,{type:"button",role:"switch","aria-checked":c,"aria-required":u,"data-state":Hy(c),"data-disabled":l?"":void 0,disabled:l,value:s,...r,ref:y,onClick:lt(n,b=>{h(),m(S=>!S),g&&p&&(f.current=b.isPropagationStopped(),f.current||b.stopPropagation())})})},"SwitchTrigger")),zy=Gr.forwardRef(Zs(function(t,n){let{__scopeSwitch:r,name:o,checked:a,defaultChecked:i,required:s,disabled:l,value:c,onCheckedChange:u,form:d,...m}=t;return Hl(nT,{__scopeSwitch:r,checked:a,defaultChecked:i,disabled:l,required:s,onCheckedChange:u,name:o,form:d,value:c,internal_do_not_use_render:({isFormControl:f})=>n4(t4,{children:[Hl(i4,{...m,ref:n,__scopeSwitch:r}),f&&Hl(c4,{__scopeSwitch:r})]})})},"Switch")),s4="SwitchThumb",rT=Gr.forwardRef(Zs(function(t,n){let{__scopeSwitch:r,...o}=t,a=Fy(s4,r);return Hl(dn.span,{"data-state":Hy(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:n})},"SwitchThumb")),l4="SwitchBubbleInput",c4=Gr.forwardRef(Zs(function({__scopeSwitch:t,onClick:n,...r},o){let{control:a,hasConsumerStoppedPropagationRef:i,userInteractionCount:s,checked:l,defaultChecked:c,required:u,disabled:d,name:m,value:f,form:h,bubbleInput:p,setBubbleInput:g}=Fy(l4,t),y=Kt(o,g),v=es(a),b=Gr.useRef(!1),S=Gr.useRef(l),C=Gr.useRef(s);Gr.useEffect(()=>{let k=p;if(!k)return;let M=window.HTMLInputElement.prototype,x=Object.getOwnPropertyDescriptor(M,"checked").set,T=s!==C.current;C.current=s;let R=S.current!==l;S.current=l;let P=!(T&&i.current);if(R&&x){b.current=!T;let D=new Event("click",{bubbles:P});x.call(k,l),k.dispatchEvent(D),b.current=!1}},[p,l,i,s]);let w=Gr.useRef(l);return Hl(dn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??w.current,required:u,disabled:d,name:m,value:f,form:h,...r,tabIndex:-1,ref:y,onClick:lt(n,k=>{b.current&&k.stopPropagation()}),style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function oT(e){return typeof e=="function"}Zs(oT,"isFunction");function Hy(e){return e?"checked":"unchecked"}Zs(Hy,"getState");import{jsx as aT}from"react/jsx-runtime";var Qr=iT.forwardRef(({className:e,...t},n)=>aT(zy,{className:ee("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:aT(rT,{className:ee("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Qr.displayName=zy.displayName;import{forwardRef as jz,useMemo as Gz,useState as H0,useCallback as Ch,useEffect as PM}from"react";import To,{useRef as Qs,useMemo as d4,useEffect as Kp,useState as f4,useCallback as sT,useLayoutEffect as m4}from"react";function $p(){return($p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function dT(e,t){if(e==null)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}function If(e){var t=Qs(e),n=Qs(function(r){t.current&&t.current(r)});return t.current=e,n.current}var Lf=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},Mf=function(e){return"touches"in e},Vy=function(e){return e&&e.ownerDocument.defaultView||self},lT=function(e,t,n){var r=e.getBoundingClientRect(),o=Mf(t)?(function(a,i){for(var s=0;s<a.length;s++)if(a[s].identifier===i)return a[s];return a[0]})(t.touches,n):t;return{left:Lf((o.pageX-(r.left+Vy(e).pageXOffset))/r.width),top:Lf((o.pageY-(r.top+Vy(e).pageYOffset))/r.height)}},cT=function(e){!Mf(e)&&e.preventDefault()},fT=To.memo(function(e){var t=e.onMove,n=e.onKey,r=e.onEnd,o=dT(e,["onMove","onKey","onEnd"]),a=Qs(null),i=If(t),s=If(n),l=If(r),c=Qs(null),u=Qs(!1),d=d4(function(){var g=function(b){cT(b),(Mf(b)?b.touches.length>0:b.buttons>0)&&a.current?i(lT(a.current,b,c.current)):(v(!1),l())},y=function(){v(!1),l()};function v(b){var S=u.current,C=Vy(a.current),w=b?C.addEventListener:C.removeEventListener;w(S?"touchmove":"mousemove",g),w(S?"touchend":"mouseup",y)}return[function(b){var S=b.nativeEvent,C=a.current;if(C&&(cT(S),!(function(k,M){return M&&!Mf(k)})(S,u.current)&&C)){if(Mf(S)){u.current=!0;var w=S.changedTouches||[];w.length&&(c.current=w[0].identifier)}C.focus(),i(lT(C,S,c.current)),v(!0)}},function(b){var S=b.which||b.keyCode;S<37||S>40||(b.preventDefault(),s({left:S===39?.05:S===37?-.05:0,top:S===40?.05:S===38?-.05:0}))},function(b){var S=b.which||b.keyCode;S>=37&&S<=40&&l()},v]},[s,i,l]),m=d[0],f=d[1],h=d[2],p=d[3];return Kp(function(){return p},[p]),To.createElement("div",$p({},o,{onTouchStart:m,onMouseDown:m,className:"react-colorful__interactive",ref:a,onKeyDown:f,onKeyUp:h,tabIndex:0,role:"slider"}))}),Uy=function(e){return e.filter(Boolean).join(" ")},mT=function(e){var t=e.color,n=e.left,r=e.top,o=r===void 0?.5:r,a=Uy(["react-colorful__pointer",e.className]);return To.createElement("div",{className:a,style:{top:100*o+"%",left:100*n+"%"}},To.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:t}}))},yo=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n},QZ={grad:.9,turn:360,rad:360/(2*Math.PI)},p4=function(e){return v4(Wy(e))},Wy=function(e){return e[0]==="#"&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?yo(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?yo(parseInt(e.substring(6,8),16)/255,2):1}};var h4=function(e){return y4(b4(e))},g4=function(e){var t=e.s,n=e.v,r=e.a,o=(200-t)*n/100;return{h:yo(e.h),s:yo(o>0&&o<200?t*n/100/(o<=100?o:200-o)*100:0),l:yo(o/2),a:yo(r,2)}},qy=function(e){var t=g4(e);return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"};var b4=function(e){var t=e.h,n=e.s,r=e.v,o=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),i=r*(1-n),s=r*(1-(t-a)*n),l=r*(1-(1-t+a)*n),c=a%6;return{r:yo(255*[r,s,i,i,l,r][c]),g:yo(255*[l,r,r,s,i,i][c]),b:yo(255*[i,i,l,r,r,s][c]),a:yo(o,2)}};var Yp=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},y4=function(e){var t=e.r,n=e.g,r=e.b,o=e.a,a=o<1?Yp(yo(255*o)):"";return"#"+Yp(t)+Yp(n)+Yp(r)+a},v4=function(e){var t=e.r,n=e.g,r=e.b,o=e.a,a=Math.max(t,n,r),i=a-Math.min(t,n,r),s=i?a===t?(n-r)/i:a===n?2+(r-t)/i:4+(t-n)/i:0;return{h:yo(60*(s<0?s+6:s)),s:yo(a?i/a*100:0),v:yo(a/255*100),a:o}};var w4=To.memo(function(e){var t=e.hue,n=e.onChange,r=e.onChangeEnd,o=Uy(["react-colorful__hue",e.className]);return To.createElement("div",{className:o},To.createElement(fT,{onMove:function(a){n({h:360*a.left})},onKey:function(a){n({h:Lf(t+360*a.left,0,360)})},onEnd:r,"aria-label":"Hue","aria-valuenow":yo(t),"aria-valuemax":"360","aria-valuemin":"0"},To.createElement(mT,{className:"react-colorful__hue-pointer",left:t/360,color:qy({h:t,s:100,v:100,a:1})})))}),x4=To.memo(function(e){var t=e.hsva,n=e.onChange,r=e.onChangeEnd,o={backgroundColor:qy({h:t.h,s:100,v:100,a:1})};return To.createElement("div",{className:"react-colorful__saturation",style:o},To.createElement(fT,{onMove:function(a){n({s:100*a.left,v:100-100*a.top})},onKey:function(a){n({s:Lf(t.s+100*a.left,0,100),v:Lf(t.v-100*a.top,0,100)})},onEnd:r,"aria-label":"Color","aria-valuetext":"Saturation "+yo(t.s)+"%, Brightness "+yo(t.v)+"%"},To.createElement(mT,{className:"react-colorful__saturation-pointer",top:1-t.v/100,left:t.s/100,color:qy(t)})))}),pT=function(e,t){if(e===t)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0};var S4=function(e,t){return e.toLowerCase()===t.toLowerCase()||pT(Wy(e),Wy(t))};function C4(e,t,n,r){var o=If(n),a=If(r),i=f4(function(){return e.toHsva(t)}),s=i[0],l=i[1],c=Qs({color:t,hsva:s}),u=Qs(!1);Kp(function(){if(!e.equal(t,c.current.color)){var f=e.toHsva(t);c.current={hsva:f,color:t},l(f),u.current=!1}},[t,e]),Kp(function(){var f;pT(s,c.current.hsva)||e.equal(f=e.fromHsva(s),c.current.color)||(c.current={hsva:s,color:f},o(f),u.current=!0)},[s,e,o]);var d=sT(function(f){l(function(h){return Object.assign({},h,f)})},[]),m=sT(function(){u.current&&(u.current=!1,a(c.current.color))},[a]);return[s,d,m]}var k4,T4=typeof window<"u"?m4:Kp,I4=function(){return k4||(typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0)};var uT=new WeakMap,M4=function(e){T4(function(){var t=e.current;if(typeof document<"u"&&t){var n=t.getRootNode?t.getRootNode():t.ownerDocument,r=n&&("head"in n||"host"in n)?n:t.ownerDocument;if(!uT.has(r)){var o="head"in r?r.head:r,a=(o.ownerDocument||document).createElement("style");a.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`;var i=I4();i&&a.setAttribute("nonce",i),uT.set(r,a),o.appendChild(a)}}},[])},L4=function(e){var t=e.className,n=e.colorModel,r=e.color,o=r===void 0?n.defaultColor:r,a=e.onChange,i=e.onChangeEnd,s=dT(e,["className","colorModel","color","onChange","onChangeEnd"]),l=Qs(null);M4(l);var c=C4(n,o,a,i),u=c[0],d=c[1],m=c[2],f=Uy(["react-colorful",t]);return To.createElement("div",$p({},s,{ref:l,className:f}),To.createElement(x4,{hsva:u,onChange:d,onChangeEnd:m}),To.createElement(w4,{hue:u.h,onChange:d,onChangeEnd:m,className:"react-colorful__last-control"}))},R4={defaultColor:"000",toHsva:p4,fromHsva:function(e){return h4({h:e.h,s:e.s,v:e.v,a:1})},equal:S4},hT=function(e){return To.createElement(L4,$p({},e,{colorModel:R4}))};import{useEffect as P4,useRef as D4}from"react";function gT(e){let t=D4(null);return P4(()=>{e&&(typeof e=="function"?e(t.current):e.current=t.current)}),t}import*as wT from"react";var bT=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,yT=Up,vT=(e,t)=>n=>{var r;if(t?.variants==null)return yT(e,n?.class,n?.className);let{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(c=>{let u=n?.[c],d=a?.[c];if(u===null)return null;let m=bT(u)||bT(d);return o[c][m]}),s=n&&Object.entries(n).reduce((c,u)=>{let[d,m]=u;return m===void 0||(c[d]=m),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:m,...f}=u;return Object.entries(f).every(h=>{let[p,g]=h;return Array.isArray(g)?g.includes({...a,...s}[p]):{...a,...s}[p]===g})?[...c,d,m]:c},[]);return yT(e,i,l,n?.class,n?.className)};import{jsx as B4}from"react/jsx-runtime";var A4=vT("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),pr=wT.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},a)=>B4(r?Kk:"button",{className:ee(A4({variant:t,size:n,className:e}),e?.includes?.("noScale")?"":"active:scale-[0.98] "),ref:a,...o}));pr.displayName="Button";import*as mM from"react";import*as Pr from"react";import*as dr from"react";import*as uu from"react";var N4=Object.defineProperty,E4=(e,t)=>N4(e,"name",{value:t,configurable:!0});function Xo(e){let t=uu.useRef(e);return uu.useEffect(()=>{t.current=e}),uu.useMemo(()=>((...n)=>t.current?.(...n)),[])}E4(Xo,"useCallbackRef");import{jsx as _4}from"react/jsx-runtime";var O4=Object.defineProperty,lo=(e,t)=>O4(e,"name",{value:t,configurable:!0}),jy="dismissableLayer.update",F4="dismissableLayer.pointerDownOutside",z4="dismissableLayer.focusOutside",xT,ST=dr.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Js=dr.forwardRef(lo(function(t,n){let{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:o=!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:l,onDismiss:c,...u}=t,d=dr.useContext(ST),[m,f]=dr.useState(null),h=m?.ownerDocument??globalThis?.document,[,p]=dr.useState({}),g=Kt(n,f),y=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),b=v?y.indexOf(v):-1,S=m?y.indexOf(m):-1,C=d.layersWithOutsidePointerEventsDisabled.size>0,w=S>=b,k=dr.useRef(!1),M=CT(R=>{i?.(R),l?.(R),R.defaultPrevented||c?.()},{ownerDocument:h,deferPointerDownOutside:o,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:dr.useCallback(R=>{if(!(R instanceof Node))return!1;let P=[...d.branches].some(D=>D.contains(R));return w&&!P},[d.branches,w])}),I=kT(R=>{if(o&&k.current)return;let P=R.target;[...d.branches].some(N=>N.contains(P))||(s?.(R),l?.(R),R.defaultPrevented||c?.())},h),x=m?S===y.length-1:!1,T=Xo(R=>{R.key==="Escape"&&(a?.(R),!R.defaultPrevented&&c&&(R.preventDefault(),c()))});return dr.useEffect(()=>{if(x)return h.addEventListener("keydown",T,{capture:!0}),()=>h.removeEventListener("keydown",T,{capture:!0})},[h,x,T]),dr.useEffect(()=>{if(m)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(xT=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),Gy(),()=>{r&&(d.layersWithOutsidePointerEventsDisabled.delete(m),d.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=xT))}},[m,h,r,d]),dr.useEffect(()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),Gy())},[m,d]),dr.useEffect(()=>{let R=lo(()=>p({}),"handleUpdate");return document.addEventListener(jy,R),()=>document.removeEventListener(jy,R)},[]),_4(dn.div,{...u,ref:g,style:{pointerEvents:C?w?"auto":"none":void 0,...t.style},onFocusCapture:lt(t.onFocusCapture,I.onFocusCapture),onBlurCapture:lt(t.onBlurCapture,I.onBlurCapture),onPointerDownCapture:lt(t.onPointerDownCapture,M.onPointerDownCapture)})},"DismissableLayer"));function H4(){let e=dr.useContext(ST),[t,n]=dr.useState(null);return dr.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}lo(H4,"useDismissableLayerSurface");var V4=lo(()=>!0,"IS_TRUE");function CT(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=V4}=t,s=Xo(e),l=dr.useRef(!1),c=dr.useRef(!1),u=dr.useRef(new Map),d=dr.useRef(()=>{});return dr.useEffect(()=>{function m(){c.current=!1,o.current=!1,u.current.clear()}lo(m,"resetOutsideInteraction");function f(){return Array.from(u.current.values()).some(Boolean)}lo(f,"isOutsideInteractionIntercepted");function h(b){if(!c.current)return;let S=b.target;S instanceof Node&&[...a].some(w=>w.contains(S))||u.current.set(b.type,!0),b.type==="click"&&window.setTimeout(()=>{c.current&&d.current()},0)}lo(h,"handleInteractionCapture");function p(b){c.current&&u.current.set(b.type,!1)}lo(p,"handleInteractionBubble");let g=lo(b=>{if(b.target&&!l.current){let C=function(){n.removeEventListener("click",d.current);let k=f();m(),k||Yy(F4,s,w,{discrete:!0})};var S=C;if(lo(C,"handleAndDispatchPointerDownOutsideEvent"),!i(b.target)){n.removeEventListener("click",d.current),m(),l.current=!1;return}let w={originalEvent:b};c.current=!0,o.current=r&&b.button===0,u.current.clear(),!r||b.button!==0?C():(n.removeEventListener("click",d.current),d.current=C,n.addEventListener("click",d.current,{once:!0}))}else n.removeEventListener("click",d.current),m();l.current=!1},"handlePointerDown"),y=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let b of y)n.addEventListener(b,h,!0),n.addEventListener(b,p);let v=window.setTimeout(()=>{n.addEventListener("pointerdown",g)},0);return()=>{window.clearTimeout(v),n.removeEventListener("pointerdown",g),n.removeEventListener("click",d.current);for(let b of y)n.removeEventListener(b,h,!0),n.removeEventListener(b,p)}},[n,s,r,o,a,i]),{onPointerDownCapture:lo(()=>l.current=!0,"onPointerDownCapture")}}lo(CT,"usePointerDownOutside");function kT(e,t=globalThis?.document){let n=Xo(e),r=dr.useRef(!1);return dr.useEffect(()=>{let o=lo(a=>{a.target&&!r.current&&Yy(z4,n,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:lo(()=>r.current=!0,"onFocusCapture"),onBlurCapture:lo(()=>r.current=!1,"onBlurCapture")}}lo(kT,"useFocusOutside");function Gy(){let e=new CustomEvent(jy);document.dispatchEvent(e)}lo(Gy,"dispatchUpdate");function Yy(e,t,n,{discrete:r}){let o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Tf(o,a):o.dispatchEvent(a)}lo(Yy,"handleAndDispatchCustomEvent");import*as TT from"react";var W4=Object.defineProperty,$y=(e,t)=>W4(e,"name",{value:t,configurable:!0}),Xp=0,du=null;function q4(e){return fu(),e.children}$y(q4,"FocusGuards");function fu(){TT.useEffect(()=>{du||(du={start:Ky(),end:Ky()});let{start:e,end:t}=du;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Xp++,()=>{Xp===1&&(du?.start.remove(),du?.end.remove(),du=null),Xp=Math.max(0,Xp-1)}},[])}$y(fu,"useFocusGuards");function Ky(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}$y(Ky,"createFocusGuard");import*as Oa from"react";import{jsx as j4}from"react/jsx-runtime";var U4=Object.defineProperty,Wo=(e,t)=>U4(e,"name",{value:t,configurable:!0}),Xy="focusScope.autoFocusOnMount",Zy="focusScope.autoFocusOnUnmount",IT={bubbles:!1,cancelable:!0},Zp=Oa.forwardRef(Wo(function(t,n){let{loop:r=!1,trapped:o=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...s}=t,[l,c]=Oa.useState(null),u=Xo(a),d=Xo(i),m=Oa.useRef(null),f=Kt(n,c),h=Oa.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;Oa.useEffect(()=>{if(o){let b=function(k){if(h.paused||!l)return;let M=k.target;l.contains(M)?m.current=M:ts(m.current,{select:!0})},S=function(k){if(h.paused||!l)return;let M=k.relatedTarget;M!==null&&(l.contains(M)||ts(m.current,{select:!0}))},C=function(k){if(document.activeElement===document.body)for(let I of k)I.removedNodes.length>0&&ts(l)};var g=b,y=S,v=C;Wo(b,"handleFocusIn"),Wo(S,"handleFocusOut"),Wo(C,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",S);let w=new MutationObserver(C);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",S),w.disconnect()}}},[o,l,h.paused]),Oa.useEffect(()=>{if(l){MT.add(h);let g=document.activeElement;if(!l.contains(g)){let v=new CustomEvent(Xy,IT);l.addEventListener(Xy,u),l.dispatchEvent(v),v.defaultPrevented||(LT(BT(e0(l)),{select:!0}),document.activeElement===g&&ts(l))}return()=>{l.removeEventListener(Xy,u),setTimeout(()=>{let v=new CustomEvent(Zy,IT);l.addEventListener(Zy,d),l.dispatchEvent(v),v.defaultPrevented||ts(g??document.body,{select:!0}),l.removeEventListener(Zy,d),MT.remove(h)},0)}}},[l,u,d,h]);let p=Oa.useCallback(g=>{if(!r&&!o||h.paused)return;let y=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,v=document.activeElement;if(y&&v){let b=g.currentTarget,[S,C]=RT(b);S&&C?!g.shiftKey&&v===C?(g.preventDefault(),r&&ts(S,{select:!0})):g.shiftKey&&v===S&&(g.preventDefault(),r&&ts(C,{select:!0})):v===b&&g.preventDefault()}},[r,o,h.paused]);return j4(dn.div,{tabIndex:-1,...s,ref:f,onKeyDown:p})},"FocusScope"));function LT(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(ts(r,{select:t}),document.activeElement!==n)return}Wo(LT,"focusFirst");function RT(e){let t=e0(e),n=Qy(t,e),r=Qy(t.reverse(),e);return[n,r]}Wo(RT,"getTabbableEdges");function e0(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Wo(r=>{let o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}Wo(e0,"getTabbableCandidates");function Qy(e,t){let n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):PT(r,{upTo:t})))return r}Wo(Qy,"findVisible");function PT(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}Wo(PT,"isHidden");function DT(e){return e instanceof HTMLInputElement&&"select"in e}Wo(DT,"isSelectableInput");function ts(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&DT(e)&&t&&e.select()}}Wo(ts,"focus");var MT=AT();function AT(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Jy(e,t),e.unshift(t)},remove(t){e=Jy(e,t),e[0]?.resume()}}}Wo(AT,"createFocusScopesStack");function Jy(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Wo(Jy,"arrayRemove");function BT(e){return e.filter(t=>t.tagName!=="A")}Wo(BT,"removeLinks");import*as t0 from"react";var G4=Object.defineProperty,Y4=(e,t)=>G4(e,"name",{value:t,configurable:!0}),K4=t0[" useId ".trim().toString()]||(()=>{}),$4=0;function Oi(e){let[t,n]=t0.useState(K4());return Fr(()=>{e||n(r=>r??String($4++))},[e]),e||(t?`radix-${t}`:"")}Y4(Oi,"useId");import*as Io from"react";var OT=["top","right","bottom","left"];var _i=Math.min,pi=Math.max,Pf=Math.round,Df=Math.floor,Fi=e=>({x:e,y:e}),X4={left:"right",right:"left",bottom:"top",top:"bottom"};function n0(e,t,n){return pi(e,_i(t,n))}function zi(e,t){return typeof e=="function"?e(t):e}function ns(e){return e.split("-")[0]}function Vl(e){return e.split("-")[1]}function Jp(e){return e==="x"?"y":"x"}function eh(e){return e==="y"?"height":"width"}function hi(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function th(e){return Jp(hi(e))}function _T(e,t,n){n===void 0&&(n=!1);let r=Vl(e),o=th(e),a=eh(o),i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=Rf(i)),[i,Rf(i)]}function FT(e){let t=Rf(e);return[Qp(e),t,Qp(t)]}function Qp(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var NT=["left","right"],ET=["right","left"],Z4=["top","bottom"],Q4=["bottom","top"];function J4(e,t,n){switch(e){case"top":case"bottom":return n?t?ET:NT:t?NT:ET;case"left":case"right":return t?Z4:Q4;default:return[]}}function zT(e,t,n,r){let o=Vl(e),a=J4(ns(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Qp)))),a}function Rf(e){let t=ns(e);return X4[t]+e.slice(t.length)}function e3(e){var t,n,r,o;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(o=e.left)!=null?o:0}}function r0(e){return typeof e!="number"?e3(e):{top:e,right:e,bottom:e,left:e}}function Wl(e){let{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function HT(e,t,n){let{reference:r,floating:o}=e,a=hi(t),i=th(t),s=eh(i),l=ns(t),c=a==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,m=r[s]/2-o[s]/2,f;switch(l){case"top":f={x:u,y:r.y-o.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-o.width,y:d};break;default:f={x:r.x,y:r.y}}let h=Vl(t);return h&&(f[i]+=m*(h==="end"?1:-1)*(n&&c?-1:1)),f}async function qT(e,t){var n;t===void 0&&(t={});let{x:r,y:o,platform:a,rects:i,elements:s,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:m=!1,padding:f=0}=zi(t,e),h=r0(f),g=s[m?d==="floating"?"reference":"floating":d],y=Wl(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(g)))==null||n?g:g.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:c,rootBoundary:u,strategy:l})),v=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,b=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),S=await(a.isElement==null?void 0:a.isElement(b))&&await(a.getScale==null?void 0:a.getScale(b))||{x:1,y:1},C=Wl(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:v,offsetParent:b,strategy:l}):v);return{top:(y.top-C.top+h.top)/S.y,bottom:(C.bottom-y.bottom+h.bottom)/S.y,left:(y.left-C.left+h.left)/S.x,right:(C.right-y.right+h.right)/S.x}}var t3=50,UT=async(e,t,n)=>{let{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,s=i.detectOverflow?i:{...i,detectOverflow:qT},l=await(i.isRTL==null?void 0:i.isRTL(t)),c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=HT(c,r,l),m=r,f=0,h={};for(let p=0;p<a.length;p++){let g=a[p];if(!g)continue;let{name:y,fn:v}=g,{x:b,y:S,data:C,reset:w}=await v({x:u,y:d,initialPlacement:r,placement:m,strategy:o,middlewareData:h,rects:c,platform:s,elements:{reference:e,floating:t}});u=b??u,d=S??d,h[y]={...h[y],...C},w&&f<t3&&(f++,typeof w=="object"&&(w.placement&&(m=w.placement),w.rects&&(c=w.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):w.rects),{x:u,y:d}=HT(c,m,l)),p=-1)}return{x:u,y:d,placement:m,strategy:o,middlewareData:h}},jT=e=>({name:"arrow",options:e,async fn(t){let{x:n,y:r,placement:o,rects:a,platform:i,elements:s,middlewareData:l}=t,{element:c,padding:u=0}=zi(e,t)||{};if(c==null)return{};let d=r0(u),m={x:n,y:r},f=th(o),h=eh(f),p=await i.getDimensions(c),g=f==="y",y=g?"top":"left",v=g?"bottom":"right",b=g?"clientHeight":"clientWidth",S=a.reference[h]+a.reference[f]-m[f]-a.floating[h],C=m[f]-a.reference[f],w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c)),k=w?w[b]:0;(!k||!await(i.isElement==null?void 0:i.isElement(w)))&&(k=s.floating[b]||a.floating[h]);let M=S/2-C/2,I=k/2-p[h]/2-1,x=_i(d[y],I),T=_i(d[v],I),R=k-p[h]-T,P=k/2-p[h]/2+M,D=n0(x,P,R),N=!l.arrow&&Vl(o)!=null&&P!==D&&a.reference[h]/2-(P<x?x:T)-p[h]/2<0,O=N?P<x?P-x:P-R:0;return{[f]:m[f]+O,data:{[f]:D,centerOffset:P-D-O,...N&&{alignmentOffset:O}},reset:N}}});var GT=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;let{placement:o,middlewareData:a,rects:i,initialPlacement:s,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:p=!0,...g}=zi(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};let y=ns(o),v=hi(s),b=ns(s)===s,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(b||!p?[Rf(s)]:FT(s)),w=h!=="none";!m&&w&&C.push(...zT(s,p,h,S));let k=[s,...C],M=await l.detectOverflow(t,g),I=[],x=((r=a.flip)==null?void 0:r.overflows)||[];if(u&&I.push(M[y]),d){let D=_T(o,i,S);I.push(M[D[0]],M[D[1]])}if(x=[...x,{placement:o,overflows:I}],!I.every(D=>D<=0)){var T,R;let D=(((T=a.flip)==null?void 0:T.index)||0)+1,N=k[D];if(N&&(!(d==="alignment"?v!==hi(N):!1)||x.every(B=>hi(B.placement)===v?B.overflows[0]>0:!0)))return{data:{index:D,overflows:x},reset:{placement:N}};let O=(R=x.filter(A=>A.overflows[0]<=0).sort((A,B)=>A.overflows[1]-B.overflows[1])[0])==null?void 0:R.placement;if(!O)switch(f){case"bestFit":{var P;let A=(P=x.filter(B=>{if(w){let E=hi(B.placement);return E===v||E==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(E=>E>0).reduce((E,L)=>E+L,0)]).sort((B,E)=>B[1]-E[1])[0])==null?void 0:P[0];A&&(O=A);break}case"initialPlacement":O=s;break}if(o!==O)return{reset:{placement:O}}}return{}}}};function VT(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function WT(e){return OT.some(t=>e[t]>=0)}var YT=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:o="referenceHidden",...a}=zi(e,t);switch(o){case"referenceHidden":{let i=await r.detectOverflow(t,{...a,elementContext:"reference"}),s=VT(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:WT(s)}}}case"escaped":{let i=await r.detectOverflow(t,{...a,altBoundary:!0}),s=VT(i,n.floating);return{data:{escapedOffsets:s,escaped:WT(s)}}}default:return{}}}}};var KT=new Set(["left","top"]);async function n3(e,t){let{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=ns(n),s=Vl(n),l=hi(n)==="y",c=KT.has(i)?-1:1,u=a&&l?-1:1,d=zi(t,e),{mainAxis:m,crossAxis:f,alignmentAxis:h}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof h=="number"&&(f=s==="end"?h*-1:h),l?{x:f*u,y:m*c}:{x:m*c,y:f*u}}var $T=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;let{x:o,y:a,placement:i,middlewareData:s}=t,l=await n3(t,e);return i===((n=s.offset)==null?void 0:n.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:a+l.y,data:{...l,placement:i}}}}},XT=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:r,placement:o,platform:a}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:v=>{let{x:b,y:S}=v;return{x:b,y:S}}},...c}=zi(e,t),u={x:n,y:r},d=await a.detectOverflow(t,c),m=hi(o),f=Jp(m),h=u[f],p=u[m],g=(v,b)=>n0(b+d[v==="y"?"top":"left"],b,b-d[v==="y"?"bottom":"right"]);i&&(h=g(f,h)),s&&(p=g(m,p));let y=l.fn({...t,[f]:h,[m]:p});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[f]:i,[m]:s}}}}}},ZT=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;let{x:o,y:a,placement:i,rects:s,middlewareData:l}=t,{offset:c=0,mainAxis:u=!0,crossAxis:d=!0}=zi(e,t),m={x:o,y:a},f=hi(i),h=Jp(f),p=m[h],g=m[f],y=zi(c,t),v=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:(n=y.mainAxis)!=null?n:0,crossAxis:(r=y.crossAxis)!=null?r:0};if(u){let C=h==="y"?"height":"width",w=s.reference[h]-s.floating[C]+v.mainAxis,k=s.reference[h]+s.reference[C]-v.mainAxis;p<w?p=w:p>k&&(p=k)}if(d){var b,S;let C=h==="y"?"width":"height",w=KT.has(ns(i)),k=s.reference[f]-s.floating[C]+(w&&((b=l.offset)==null?void 0:b[f])||0)+(w?0:v.crossAxis),M=s.reference[f]+s.reference[C]+(w?0:((S=l.offset)==null?void 0:S[f])||0)-(w?v.crossAxis:0);g<k?g=k:g>M&&(g=M)}return{[h]:p,[f]:g}}}},QT=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){let{placement:n,rects:r,platform:o,elements:a}=t,{apply:i=()=>{},...s}=zi(e,t),l=await o.detectOverflow(t,s),c=ns(n),u=Vl(n),d=hi(n)==="y",{width:m,height:f}=r.floating,h,p;c==="top"||c==="bottom"?(h=c,p=u===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(p=c,h=u==="end"?"top":"bottom");let g=f-l.top-l.bottom,y=m-l.left-l.right,v=_i(f-l[h],g),b=_i(m-l[p],y),S=t.middlewareData.shift,C=!S,w=v,k=b;S!=null&&S.enabled.x&&(k=y),S!=null&&S.enabled.y&&(w=g),C&&!u&&(d?k=m-2*pi(l.left,l.right):w=f-2*pi(l.top,l.bottom)),await i({...t,availableWidth:k,availableHeight:w});let M=await o.getDimensions(a.floating);return m!==M.width||f!==M.height?{reset:{rects:!0}}:{}}}};function nh(){return typeof window<"u"}function jl(e){return eI(e)?(e.nodeName||"").toLowerCase():"#document"}function qo(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Hi(e){var t;return(t=(eI(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function eI(e){return nh()?e instanceof Node||e instanceof qo(e).Node:!1}function gi(e){return nh()?e instanceof Element||e instanceof qo(e).Element:!1}function rs(e){return nh()?e instanceof HTMLElement||e instanceof qo(e).HTMLElement:!1}function JT(e){return!nh()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof qo(e).ShadowRoot}function Af(e){let{overflow:t,overflowX:n,overflowY:r,display:o}=bi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function tI(e){return/^(table|td|th)$/.test(jl(e))}function Bf(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var r3=/transform|translate|scale|rotate|perspective|filter/,o3=/paint|layout|strict|content/,ql=e=>!!e&&e!=="none",o0;function rh(e){let t=gi(e)?bi(e):e;return ql(t.transform)||ql(t.translate)||ql(t.scale)||ql(t.rotate)||ql(t.perspective)||!oh()&&(ql(t.backdropFilter)||ql(t.filter))||r3.test(t.willChange||"")||o3.test(t.contain||"")}function nI(e){let t=el(e);for(;rs(t)&&!mu(t);){if(rh(t))return t;if(Bf(t))return null;t=el(t)}return null}function oh(){return o0==null&&(o0=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),o0}function mu(e){return/^(html|body|#document)$/.test(jl(e))}function bi(e){return qo(e).getComputedStyle(e)}function Nf(e){return gi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function el(e){if(jl(e)==="html")return e;let t=e.assignedSlot||e.parentNode||JT(e)&&e.host||Hi(e);return JT(t)?t.host:t}function rI(e){let t=el(e);return mu(t)?(e.ownerDocument||e).body:rs(t)&&Af(t)?t:rI(t)}function Ul(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let o=rI(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=qo(o);if(a){let s=ah(i);return t.concat(i,i.visualViewport||[],Af(o)?o:[],s&&n?Ul(s):[])}else return t.concat(o,Ul(o,[],n))}function ah(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function iI(e){let t=bi(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,o=rs(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,s=Pf(n)!==a||Pf(r)!==i;return s&&(n=a,r=i),{width:n,height:r,$:s}}function i0(e){return gi(e)?e:e.contextElement}function pu(e){let t=i0(e);if(!rs(t))return Fi(1);let n=t.getBoundingClientRect(),{width:r,height:o,$:a}=iI(t),i=(a?Pf(n.width):n.width)/r,s=(a?Pf(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}var a3=Fi(0);function sI(e){let t=qo(e);return!oh()||!t.visualViewport?a3:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function i3(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===qo(e)}function Gl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let o=e.getBoundingClientRect(),a=i0(e),i=Fi(1);t&&(r?gi(r)&&(i=pu(r)):i=pu(e));let s=i3(a,n,r)?sI(a):Fi(0),l=(o.left+s.x)/i.x,c=(o.top+s.y)/i.y,u=o.width/i.x,d=o.height/i.y;if(a&&r){let m=qo(a),f=gi(r)?qo(r):r,h=m,p=ah(h);for(;p&&f!==h;){let g=pu(p),y=p.getBoundingClientRect(),v=bi(p),b=y.left+(p.clientLeft+parseFloat(v.paddingLeft))*g.x,S=y.top+(p.clientTop+parseFloat(v.paddingTop))*g.y;l*=g.x,c*=g.y,u*=g.x,d*=g.y,l+=b,c+=S,h=qo(p),p=ah(h)}}return Wl({width:u,height:d,x:l,y:c})}function ih(e,t){let n=Nf(e).scrollLeft;return t?t.left+n:Gl(Hi(e)).left+n}function lI(e,t){let n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ih(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function s3(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e,a=o==="fixed",i=Hi(r),s=t?Bf(t.floating):!1;if(r===i||s&&a)return n;let l={scrollLeft:0,scrollTop:0},c=Fi(1),u=Fi(0),d=rs(r);if((d||!a)&&((jl(r)!=="body"||Af(i))&&(l=Nf(r)),d)){let f=Gl(r);c=pu(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}let m=i&&!d&&!a?lI(i,l):Fi(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+m.x,y:n.y*c.y-l.scrollTop*c.y+u.y+m.y}}function l3(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function c3(e){let t=Nf(e),n=e.ownerDocument.body,r=pi(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),o=pi(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+ih(e),i=-t.scrollTop;return bi(n).direction==="rtl"&&(a+=pi(e.clientWidth,n.clientWidth)-r),{width:r,height:o,x:a,y:i}}var u3=25;function d3(e,t,n){n===void 0&&(n="viewport");let r=n==="layoutViewport",o=qo(e),a=Hi(e),i=o.visualViewport,s=a.clientWidth,l=a.clientHeight,c=0,u=0;if(i){let m=!oh()||t==="fixed";r?m||(c=-i.offsetLeft,u=-i.offsetTop):(s=i.width,l=i.height,m&&(c=i.offsetLeft,u=i.offsetTop))}if(ih(a)<=0){let m=a.ownerDocument,f=m.body,h=getComputedStyle(f),p=m.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,g=Math.abs(a.clientWidth-f.clientWidth-p),y=getComputedStyle(a).scrollbarGutter==="stable both-edges"?g/2:g;y<=u3&&(s-=y)}return{width:s,height:l,x:c,y:u}}function f3(e,t){let n=Gl(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=pu(e),i=e.clientWidth*a.x,s=e.clientHeight*a.y,l=o*a.x,c=r*a.y;return{width:i,height:s,x:l,y:c}}function oI(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=d3(e,n,t);else if(t==="document")r=c3(Hi(e));else if(gi(t))r=f3(t,n);else{let o=sI(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Wl(r)}function m3(e,t){let n=t.get(e);if(n)return n;let r=Ul(e,[],!1).filter(s=>gi(s)&&jl(s)!=="body"),o=null,a=bi(e).position==="fixed",i=a?el(e):e;for(;gi(i)&&!mu(i);){let s=bi(i),l=rh(i),c=o?o.position:a?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&s.position==="static")?r=r.filter(d=>d!==i):o=s,i=el(i)}return t.set(e,r),r}function p3(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e,i=[...n==="clippingAncestors"?Bf(t)?[]:m3(t,this._c):[].concat(n),r],s=oI(t,i[0],o),l=s.top,c=s.right,u=s.bottom,d=s.left;for(let m=1;m<i.length;m++){let f=oI(t,i[m],o);l=pi(f.top,l),c=_i(f.right,c),u=_i(f.bottom,u),d=pi(f.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function h3(e){let{width:t,height:n}=iI(e);return{width:t,height:n}}function g3(e,t,n){let r=rs(t),o=Hi(t),a=n==="fixed",i=Gl(e,!0,a,t),s={scrollLeft:0,scrollTop:0},l=Fi(0);if((r||!a)&&((jl(t)!=="body"||Af(o))&&(s=Nf(t)),r)){let m=Gl(t,!0,a,t);l.x=m.x+t.clientLeft,l.y=m.y+t.clientTop}!r&&o&&(l.x=ih(o));let c=o&&!r&&!a?lI(o,s):Fi(0),u=i.left+s.scrollLeft-l.x-c.x,d=i.top+s.scrollTop-l.y-c.y;return{x:u,y:d,width:i.width,height:i.height}}function a0(e){return bi(e).position==="static"}function aI(e,t){if(!rs(e)||bi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Hi(e)===n&&(n=n.ownerDocument.body),n}function cI(e,t){let n=qo(e);if(Bf(e))return n;if(!rs(e)){let o=el(e);for(;o&&!mu(o);){if(gi(o)&&!a0(o))return o;o=el(o)}return n}let r=aI(e,t);for(;r&&tI(r)&&a0(r);)r=aI(r,t);return r&&mu(r)&&a0(r)&&!rh(r)?n:r||nI(e)||n}var b3=async function(e){let t=this.getOffsetParent||cI,n=this.getDimensions,r=await n(e.floating);return{reference:g3(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function y3(e){return bi(e).direction==="rtl"}var uI={convertOffsetParentRelativeRectToViewportRelativeRect:s3,getDocumentElement:Hi,getClippingRect:p3,getOffsetParent:cI,getElementRects:b3,getClientRects:l3,getDimensions:h3,getScale:pu,isElement:gi,isRTL:y3};function dI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function v3(e,t,n){let r=null,o,a=Hi(e);function i(){var u;clearTimeout(o),(u=r)==null||u.disconnect(),r=null}function s(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),i();let m=e.getBoundingClientRect(),{left:f,top:h,width:p,height:g}=m;if(u||t(),!p||!g)return;let y=Df(h),v=Df(a.clientWidth-(f+p)),b=Df(a.clientHeight-(h+g)),S=Df(f),w={rootMargin:-y+"px "+-v+"px "+-b+"px "+-S+"px",threshold:pi(0,_i(1,d))||1},k=!0;function M(I){let x=I[0].intersectionRatio;if(!dI(m,e.getBoundingClientRect()))return s();if(x!==d){if(!k)return s();x?s(!1,x):o=setTimeout(()=>{s(!1,1e-7)},1e3)}k=!1}try{r=new IntersectionObserver(M,{...w,root:a.ownerDocument})}catch{r=new IntersectionObserver(M,w)}r.observe(e)}let l=qo(e),c=()=>s(n);return l.addEventListener("resize",c),s(!0),()=>{l.removeEventListener("resize",c),i()}}function s0(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=i0(e),u=o||a?[...c?Ul(c):[],...t?Ul(t):[]]:[];u.forEach(y=>{o&&y.addEventListener("scroll",n),a&&y.addEventListener("resize",n)});let d=c&&s?v3(c,n,a):null,m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[v]=y;v&&v.target===c&&f&&t&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var b;(b=f)==null||b.observe(t)})),n()}),c&&!l&&f.observe(c),t&&f.observe(t));let h,p=l?Gl(e):null;l&&g();function g(){let y=Gl(e);p&&!dI(p,y)&&n(),p=y,h=requestAnimationFrame(g)}return n(),()=>{var y;u.forEach(v=>{o&&v.removeEventListener("scroll",n),a&&v.removeEventListener("resize",n)}),d?.(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(h)}}var fI=$T;var mI=XT,pI=GT,hI=QT,gI=YT,l0=jT;var bI=ZT,c0=(e,t,n)=>{let r=new Map,o=n??{},a={...uI,...o.platform,_c:r};return UT(e,t,{...o,platform:a})};import*as Yr from"react";import{useLayoutEffect as w3}from"react";import*as vI from"react-dom";var x3=typeof document<"u",S3=function(){},sh=x3?w3:S3;function lh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!lh(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){let a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!lh(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function wI(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function yI(e,t){let n=wI(e);return Math.round(t*n)/n}function u0(e){let t=Yr.useRef(e);return sh(()=>{t.current=e}),t}function xI(e){e===void 0&&(e={});let{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:s=!0,whileElementsMounted:l,open:c}=e,[u,d]=Yr.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=Yr.useState(r);lh(m,r)||f(r);let[h,p]=Yr.useState(null),[g,y]=Yr.useState(null),v=Yr.useCallback(B=>{B!==w.current&&(w.current=B,p(B))},[]),b=Yr.useCallback(B=>{B!==k.current&&(k.current=B,y(B))},[]),S=a||h,C=i||g,w=Yr.useRef(null),k=Yr.useRef(null),M=Yr.useRef(u),I=l!=null,x=u0(l),T=u0(o),R=u0(c),P=Yr.useCallback(()=>{if(!w.current||!k.current)return;let B={placement:t,strategy:n,middleware:m};T.current&&(B.platform=T.current),c0(w.current,k.current,B).then(E=>{let L={...E,isPositioned:R.current!==!1};D.current&&!lh(M.current,L)&&(M.current=L,vI.flushSync(()=>{d(L)}))})},[m,t,n,T,R]);sh(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,d(B=>({...B,isPositioned:!1})))},[c]);let D=Yr.useRef(!1);sh(()=>(D.current=!0,()=>{D.current=!1}),[]),sh(()=>{if(S&&(w.current=S),C&&(k.current=C),S&&C){if(x.current)return x.current(S,C,P);P()}},[S,C,P,x,I]);let N=Yr.useMemo(()=>({reference:w,floating:k,setReference:v,setFloating:b}),[v,b]),O=Yr.useMemo(()=>({reference:S,floating:C}),[S,C]),A=Yr.useMemo(()=>{let B={position:n,left:0,top:0};if(!O.floating)return B;let E=yI(O.floating,u.x),L=yI(O.floating,u.y);return s?{...B,transform:"translate("+E+"px, "+L+"px)",...wI(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:L}},[n,s,O.floating,u.x,u.y]);return Yr.useMemo(()=>({...u,update:P,refs:N,elements:O,floatingStyles:A}),[u,P,N,O,A])}var C3=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){let{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?l0({element:r.current,padding:o}).fn(n):{}:r?l0({element:r,padding:o}).fn(n):{}}}},SI=(e,t)=>{let n=fI(e);return{name:n.name,fn:n.fn,options:[e,t]}},CI=(e,t)=>{let n=mI(e);return{name:n.name,fn:n.fn,options:[e,t]}},kI=(e,t)=>({fn:bI(e).fn,options:[e,t]}),TI=(e,t)=>{let n=pI(e);return{name:n.name,fn:n.fn,options:[e,t]}},II=(e,t)=>{let n=hI(e);return{name:n.name,fn:n.fn,options:[e,t]}};var MI=(e,t)=>{let n=gI(e);return{name:n.name,fn:n.fn,options:[e,t]}};var LI=(e,t)=>{let n=C3(e);return{name:n.name,fn:n.fn,options:[e,t]}};import{jsx as Ef}from"react/jsx-runtime";var k3=Object.defineProperty,tl=(e,t)=>k3(e,"name",{value:t,configurable:!0});var RI="Popper",[PI,_a]=xr(RI),[T3,DI]=PI(RI),I3=tl(e=>{let{__scopePopper:t,children:n}=e,[r,o]=Io.useState(null),[a,i]=Io.useState(void 0);return Ef(T3,{scope:t,anchor:r,onAnchorChange:o,placementState:a,setPlacementState:i,children:n})},"Popper"),M3="PopperAnchor",L3=Io.forwardRef(tl(function(t,n){let{__scopePopper:r,virtualRef:o,...a}=t,i=DI(M3,r),s=Io.useRef(null),l=i.onAnchorChange,c=Io.useCallback(p=>{s.current=p,p&&l(p)},[l]),u=Kt(n,c),d=Io.useRef(null);Io.useEffect(()=>{if(!o)return;let p=d.current;d.current=o.current,p!==d.current&&l(d.current)});let m=i.placementState&&ch(i.placementState),f=m?.[0],h=m?.[1];return o?null:Ef(dn.div,{"data-radix-popper-side":f,"data-radix-popper-align":h,...a,ref:u})},"PopperAnchor")),AI="PopperContent",[R3,ZQ]=PI(AI),P3=Io.forwardRef(tl(function(t,n){let{__scopePopper:r,side:o="bottom",sideOffset:a=0,align:i="center",alignOffset:s=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:m="partial",hideWhenDetached:f=!1,updatePositionStrategy:h="optimized",onPlaced:p,...g}=t,y=DI(AI,r),[v,b]=Io.useState(null),S=Kt(n,b),[C,w]=Io.useState(null),k=es(C),M=k?.width??0,I=k?.height??0,x=o+(i!=="center"?"-"+i:""),T=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},R=Array.isArray(u)?u:[u],P=R.length>0,D={padding:T,boundary:R.filter(BI),altBoundary:P},{refs:N,floatingStyles:O,placement:A,isPositioned:B,middlewareData:E}=xI({strategy:"fixed",placement:x,whileElementsMounted:tl((...Z)=>s0(...Z,{animationFrame:h==="always"}),"whileElementsMounted"),elements:{reference:y.anchor},middleware:[SI({mainAxis:a+I,alignmentAxis:s}),c&&CI({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?kI():void 0,...D}),c&&TI({...D}),II({...D,apply:tl(({elements:Z,rects:de,availableWidth:ze,availableHeight:xe})=>{let{width:Ae,height:Oe}=de.reference,ke=Z.floating.style;ke.setProperty("--radix-popper-available-width",`${ze}px`),ke.setProperty("--radix-popper-available-height",`${xe}px`),ke.setProperty("--radix-popper-anchor-width",`${Ae}px`),ke.setProperty("--radix-popper-anchor-height",`${Oe}px`)},"apply")}),C&&LI({element:C,padding:l}),D3({arrowWidth:M,arrowHeight:I}),f&&MI({strategy:"referenceHidden",...D,boundary:P?D.boundary:void 0})]}),L=y.setPlacementState;Fr(()=>(L(A),()=>{L(void 0)}),[A,L]);let[z,Y]=ch(A),G=Xo(p);Fr(()=>{B&&G?.()},[B,G]);let H=E.arrow?.x,W=E.arrow?.y,U=E.arrow?.centerOffset!==0,[V,K]=Io.useState();return Fr(()=>{v&&K(window.getComputedStyle(v).zIndex)},[v]),Ef("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...O,transform:B?O.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[E.transformOrigin?.x,E.transformOrigin?.y].join(" "),...E.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:Ef(R3,{scope:r,placedSide:z,placedAlign:Y,onArrowChange:w,arrowX:H,arrowY:W,shouldHideArrow:U,children:Ef(dn.div,{"data-side":z,"data-align":Y,...g,ref:S,style:{...g.style,animation:B?g.style?.animation:"none"}})})})},"PopperContent"));function BI(e){return e!==null}tl(BI,"isNotNull");var D3=tl(e=>({name:"transformOrigin",options:e,fn(t){let{placement:n,rects:r,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,s=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,u]=ch(n),d={start:"0%",center:"50%",end:"100%"}[u],m=(o.arrow?.x??0)+s/2,f=(o.arrow?.y??0)+l/2,h="",p="";return c==="bottom"?(h=i?d:`${m}px`,p=`${-l}px`):c==="top"?(h=i?d:`${m}px`,p=`${r.floating.height+l}px`):c==="right"?(h=`${-l}px`,p=i?d:`${f}px`):c==="left"&&(h=`${r.floating.width+l}px`,p=i?d:`${f}px`),{data:{x:h,y:p}}}}),"transformOrigin");function ch(e){let[t,n="center"]=e.split("-");return[t,n]}tl(ch,"getSideAndAlignFromPlacement");var nl=I3,os=L3,rl=P3;import*as dh from"react";import*as NI from"react-dom";import{jsx as N3}from"react/jsx-runtime";var A3=Object.defineProperty,B3=(e,t)=>A3(e,"name",{value:t,configurable:!0}),hu=dh.forwardRef(B3(function(t,n){let{container:r,...o}=t,[a,i]=dh.useState(!1);Fr(()=>i(!0),[]);let s=r||a&&globalThis?.document?.body;return s?NI.createPortal(N3(dn.div,{...o,ref:n}),s):null},"Portal"));import*as vo from"react";import*as EI from"react";var E3=Object.defineProperty,as=(e,t)=>E3(e,"name",{value:t,configurable:!0});function OI(e,t){return EI.useReducer((n,r)=>t[n][r]??n,e)}as(OI,"useStateMachine");var Uo=as(e=>{let{present:t,children:n}=e,r=_I(t),o=typeof n=="function"?n({present:r.isPresent}):vo.Children.only(n),a=FI(r.ref,zI(o));return typeof n=="function"||r.isPresent?vo.cloneElement(o,{ref:a}):null},"Presence");function _I(e){let[t,n]=vo.useState(),r=vo.useRef(null),o=vo.useRef(e),a=vo.useRef("none"),i=vo.useRef(void 0),s=e?"mounted":"unmounted",[l,c]=OI(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return vo.useEffect(()=>{l==="mounted"?(a.current=i.current??gu(r.current),i.current=void 0):a.current="none"},[l]),Fr(()=>{let u=r.current,d=o.current;if(d!==e){let f=a.current,h=gu(u);e?(i.current=h,c("MOUNT")):h==="none"||u?.display==="none"?c("UNMOUNT"):c(d&&f!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Fr(()=>{if(t){let u,d=t.ownerDocument.defaultView??window,m=as(h=>{let g=gu(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&g&&(c("ANIMATION_END"),!o.current)){let y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},"handleAnimationEnd"),f=as(h=>{h.target===t&&(a.current=gu(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:vo.useCallback(u=>{if(u){let d=getComputedStyle(u);r.current=d,i.current=gu(d)}else r.current=null;n(u)},[])}}as(_I,"usePresence");function d0(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}as(d0,"setRef");function FI(...e){let t=vo.useRef(e);return t.current=e,vo.useCallback(n=>{let r=t.current,o=!1,a=r.map(i=>{let s=d0(i,n);return!o&&typeof s=="function"&&(o=!0),s});if(o)return()=>{for(let i=0;i<a.length;i++){let s=a[i];typeof s=="function"?s():d0(r[i],null)}}},[])}as(FI,"useStableComposedRefs");function gu(e){return e?.animationName||"none"}as(gu,"getAnimationName");function zI(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}as(zI,"getElementRef");var O3=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},bu=new WeakMap,fh=new WeakMap,mh={},f0=0,HI=function(e){return e&&(e.host||HI(e.parentNode))},_3=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=HI(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},F3=function(e,t,n,r){var o=_3(t,Array.isArray(e)?e:[e]);mh[n]||(mh[n]=new WeakMap);var a=mh[n],i=[],s=new Set,l=new Set(o),c=function(d){!d||s.has(d)||(s.add(d),c(d.parentNode))};o.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(m){if(s.has(m))u(m);else try{var f=m.getAttribute(r),h=f!==null&&f!=="false",p=(bu.get(m)||0)+1,g=(a.get(m)||0)+1;bu.set(m,p),a.set(m,g),i.push(m),p===1&&h&&fh.set(m,!0),g===1&&m.setAttribute(n,"true"),h||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return u(t),s.clear(),f0++,function(){i.forEach(function(d){var m=bu.get(d)-1,f=a.get(d)-1;bu.set(d,m),a.set(d,f),m||(fh.has(d)||d.removeAttribute(r),fh.delete(d)),f||d.removeAttribute(n)}),f0--,f0||(bu=new WeakMap,bu=new WeakMap,fh=new WeakMap,mh={})}},ph=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=t||O3(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),F3(r,o,n,"aria-hidden")):function(){return null}};var Zo=function(){return Zo=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Zo.apply(this,arguments)};function hh(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function VI(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}import*as wh from"react";import*as Mo from"react";var Yl="right-scroll-bar-position",Kl="width-before-scroll-bar",m0="with-scroll-bars-hidden",p0="--removed-body-scroll-bar-size";function gh(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}import{useState as z3}from"react";function WI(e,t){var n=z3(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}import*as bh from"react";var H3=typeof window<"u"?bh.useLayoutEffect:bh.useEffect,qI=new WeakMap;function h0(e,t){var n=WI(t||null,function(r){return e.forEach(function(o){return gh(o,r)})});return H3(function(){var r=qI.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(s){a.has(s)||gh(s,null)}),a.forEach(function(s){o.has(s)||gh(s,i)})}qI.set(n,e)},[e]),n}function V3(e){return e}function W3(e,t){t===void 0&&(t=V3);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(s){return a(s)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var s=n;n=[],s.forEach(a),i=n}var l=function(){var u=i;i=[],u.forEach(a)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){i.push(u),c()},filter:function(u){return i=i.filter(u),n}}}};return o}function g0(e){e===void 0&&(e={});var t=W3(null);return t.options=Zo({async:!0,ssr:!1},e),t}import*as UI from"react";var jI=function(e){var t=e.sideCar,n=hh(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return UI.createElement(r,Zo({},n))};jI.isSideCarExport=!0;function b0(e,t){return e.useMedium(t),jI}var yh=g0();var y0=function(){},Of=Mo.forwardRef(function(e,t){var n=Mo.useRef(null),r=Mo.useState({onScrollCapture:y0,onWheelCapture:y0,onTouchMoveCapture:y0}),o=r[0],a=r[1],i=e.forwardProps,s=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,m=e.sideCar,f=e.noRelative,h=e.noIsolation,p=e.inert,g=e.allowPinchZoom,y=e.as,v=y===void 0?"div":y,b=e.gapMode,S=hh(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,w=h0([n,t]),k=Zo(Zo({},S),o);return Mo.createElement(Mo.Fragment,null,u&&Mo.createElement(C,{sideCar:yh,removeScrollBar:c,shards:d,noRelative:f,noIsolation:h,inert:p,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),i?Mo.cloneElement(Mo.Children.only(s),Zo(Zo({},k),{ref:w})):Mo.createElement(v,Zo({},k,{className:l,ref:w}),s))});Of.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Of.classNames={fullWidth:Kl,zeroRight:Yl};import*as Sr from"react";import*as vu from"react";import*as KI from"react";var GI;var YI=function(){if(GI)return GI;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function q3(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=YI();return t&&e.setAttribute("nonce",t),e}function U3(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function j3(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var v0=function(){var e=0,t=null;return{add:function(n){e==0&&(t=q3())&&(U3(t,n),j3(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}};var w0=function(){var e=v0();return function(t,n){KI.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}};var _f=function(){var e=w0(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t};var G3={left:0,top:0,right:0,gap:0},x0=function(e){return parseInt(e||"",10)||0},Y3=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[x0(n),x0(r),x0(o)]},S0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return G3;var t=Y3(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}};var K3=_f(),yu="data-scroll-locked",$3=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,s=e.gap;return n===void 0&&(n="margin"),`
|
|
6
|
+
.`.concat(m0,` {
|
|
7
|
+
overflow: hidden `).concat(r,`;
|
|
8
|
+
padding-right: `).concat(s,"px ").concat(r,`;
|
|
9
|
+
}
|
|
10
|
+
body[`).concat(yu,`] {
|
|
11
|
+
overflow: hidden `).concat(r,`;
|
|
12
|
+
overscroll-behavior: contain;
|
|
13
|
+
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
14
|
+
padding-left: `.concat(o,`px;
|
|
15
|
+
padding-top: `).concat(a,`px;
|
|
16
|
+
padding-right: `).concat(i,`px;
|
|
17
|
+
margin-left:0;
|
|
18
|
+
margin-top:0;
|
|
19
|
+
margin-right: `).concat(s,"px ").concat(r,`;
|
|
20
|
+
`),n==="padding"&&"padding-right: ".concat(s,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.`).concat(Yl,` {
|
|
24
|
+
right: `).concat(s,"px ").concat(r,`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.`).concat(Kl,` {
|
|
28
|
+
margin-right: `).concat(s,"px ").concat(r,`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.`).concat(Yl," .").concat(Yl,` {
|
|
32
|
+
right: 0 `).concat(r,`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.`).concat(Kl," .").concat(Kl,` {
|
|
36
|
+
margin-right: 0 `).concat(r,`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
body[`).concat(yu,`] {
|
|
40
|
+
`).concat(p0,": ").concat(s,`px;
|
|
41
|
+
}
|
|
42
|
+
`)},$I=function(){var e=parseInt(document.body.getAttribute(yu)||"0",10);return isFinite(e)?e:0},X3=function(){vu.useEffect(function(){return document.body.setAttribute(yu,($I()+1).toString()),function(){var e=$I()-1;e<=0?document.body.removeAttribute(yu):document.body.setAttribute(yu,e.toString())}},[])},C0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;X3();var a=vu.useMemo(function(){return S0(o)},[o]);return vu.createElement(K3,{styles:$3(a,!t,o,n?"":"!important")})};var k0=!1;if(typeof window<"u")try{Ff=Object.defineProperty({},"passive",{get:function(){return k0=!0,!0}}),window.addEventListener("test",Ff,Ff),window.removeEventListener("test",Ff,Ff)}catch{k0=!1}var Ff,$l=k0?{passive:!1}:!1;var Z3=function(e){return e.tagName==="TEXTAREA"},XI=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Z3(e)&&n[t]==="visible")},Q3=function(e){return XI(e,"overflowY")},J3=function(e){return XI(e,"overflowX")},T0=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=ZI(e,r);if(o){var a=QI(e,r),i=a[1],s=a[2];if(i>s)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},ez=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},tz=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},ZI=function(e,t){return e==="v"?Q3(t):J3(t)},QI=function(e,t){return e==="v"?ez(t):tz(t)},nz=function(e,t){return e==="h"&&t==="rtl"?-1:1},JI=function(e,t,n,r,o){var a=nz(e,window.getComputedStyle(t).direction),i=a*r,s=n.target,l=t.contains(s),c=!1,u=i>0,d=0,m=0;do{if(!s)break;var f=QI(e,s),h=f[0],p=f[1],g=f[2],y=p-g-a*h;(h||y)&&ZI(e,s)&&(d+=y,m+=h);var v=s.parentNode;s=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!l&&s!==document.body||l&&(t.contains(s)||t===s));return(u&&(o&&Math.abs(d)<1||!o&&i>d)||!u&&(o&&Math.abs(m)<1||!o&&-i>m))&&(c=!0),c};var vh=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},eM=function(e){return[e.deltaX,e.deltaY]},tM=function(e){return e&&"current"in e?e.current:e},rz=function(e,t){return e[0]===t[0]&&e[1]===t[1]},oz=function(e){return`
|
|
43
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
44
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
45
|
+
`)},az=0,wu=[];function nM(e){var t=Sr.useRef([]),n=Sr.useRef([0,0]),r=Sr.useRef(),o=Sr.useState(az++)[0],a=Sr.useState(_f)[0],i=Sr.useRef(e);Sr.useEffect(function(){i.current=e},[e]),Sr.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var p=VI([e.lockRef.current],(e.shards||[]).map(tM),!0).filter(Boolean);return p.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var s=Sr.useCallback(function(p,g){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!i.current.allowPinchZoom;var y=vh(p),v=n.current,b="deltaX"in p?p.deltaX:v[0]-y[0],S="deltaY"in p?p.deltaY:v[1]-y[1],C,w=p.target,k=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in p&&k==="h"&&w.type==="range")return!1;var M=window.getSelection(),I=M&&M.anchorNode,x=I?I===w||I.contains(w):!1;if(x)return!1;var T=T0(k,w);if(!T)return!0;if(T?C=k:(C=k==="v"?"h":"v",T=T0(k,w)),!T)return!1;if(!r.current&&"changedTouches"in p&&(b||S)&&(r.current=C),!C)return!0;var R=r.current||C;return JI(R,g,p,R==="h"?b:S,!0)},[]),l=Sr.useCallback(function(p){var g=p;if(!(!wu.length||wu[wu.length-1]!==a)){var y="deltaY"in g?eM(g):vh(g),v=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&rz(C.delta,y)})[0];if(v&&v.should){g.cancelable&&g.preventDefault();return}if(!v){var b=(i.current.shards||[]).map(tM).filter(Boolean).filter(function(C){return C.contains(g.target)}),S=b.length>0?s(g,b[0]):!i.current.noIsolation;S&&g.cancelable&&g.preventDefault()}}},[]),c=Sr.useCallback(function(p,g,y,v){var b={name:p,delta:g,target:y,should:v,shadowParent:iz(y)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(S){return S!==b})},1)},[]),u=Sr.useCallback(function(p){n.current=vh(p),r.current=void 0},[]),d=Sr.useCallback(function(p){c(p.type,eM(p),p.target,s(p,e.lockRef.current))},[]),m=Sr.useCallback(function(p){c(p.type,vh(p),p.target,s(p,e.lockRef.current))},[]);Sr.useEffect(function(){return wu.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:m}),document.addEventListener("wheel",l,$l),document.addEventListener("touchmove",l,$l),document.addEventListener("touchstart",u,$l),function(){wu=wu.filter(function(p){return p!==a}),document.removeEventListener("wheel",l,$l),document.removeEventListener("touchmove",l,$l),document.removeEventListener("touchstart",u,$l)}},[]);var f=e.removeScrollBar,h=e.inert;return Sr.createElement(Sr.Fragment,null,h?Sr.createElement(a,{styles:oz(o)}):null,f?Sr.createElement(C0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function iz(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var rM=b0(yh,nM);var oM=wh.forwardRef(function(e,t){return wh.createElement(Of,Zo({},e,{ref:t,sideCar:rM}))});oM.classNames=Of.classNames;var zf=oM;import{jsx as wo}from"react/jsx-runtime";var sz=Object.defineProperty,is=(e,t)=>sz(e,"name",{value:t,configurable:!0}),M0="Popover",[aM,Pee]=xr(M0,[_a]),xh=_a(),[lz,Xl]=aM(M0),cz=is(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!1}=e,s=xh(t),l=Pr.useRef(null),[c,u]=Pr.useState(!1),[d,m]=go({prop:r,defaultProp:o??!1,onChange:a,caller:M0});return wo(nl,{...s,children:wo(lz,{scope:t,contentId:Oi(),triggerRef:l,open:d,onOpenChange:m,onOpenToggle:Pr.useCallback(()=>m(f=>!f),[m]),hasCustomAnchor:c,onCustomAnchorAdd:Pr.useCallback(()=>u(!0),[]),onCustomAnchorRemove:Pr.useCallback(()=>u(!1),[]),modal:i,children:n})})},"Popover"),uz="PopoverAnchor",dz=Pr.forwardRef(is(function(t,n){let{__scopePopover:r,...o}=t,a=Xl(uz,r),i=xh(r),{onCustomAnchorAdd:s,onCustomAnchorRemove:l}=a;return Pr.useEffect(()=>(s(),()=>l()),[s,l]),wo(os,{...i,...o,ref:n})},"PopoverAnchor")),fz="PopoverTrigger",mz=Pr.forwardRef(is(function(t,n){let{__scopePopover:r,...o}=t,a=Xl(fz,r),i=xh(r),s=Kt(n,a.triggerRef),l=wo(dn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":L0(a.open),...o,ref:s,onClick:lt(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:wo(os,{asChild:!0,...i,children:l})},"PopoverTrigger")),iM="PopoverPortal",[pz,hz]=aM(iM,{forceMount:void 0}),gz=is(e=>{let{__scopePopover:t,forceMount:n,children:r,container:o}=e,a=Xl(iM,t);return wo(pz,{scope:t,forceMount:n,children:wo(Uo,{present:n||a.open,children:wo(hu,{asChild:!0,container:o,children:r})})})},"PopoverPortal"),Hf="PopoverContent",bz=Pr.forwardRef(is(function(t,n){let r=hz(Hf,t.__scopePopover),{forceMount:o=r.forceMount,...a}=t,i=Xl(Hf,t.__scopePopover);return wo(Uo,{present:o||i.open,children:i.modal?wo(vz,{...a,ref:n}):wo(wz,{...a,ref:n})})},"PopoverContent")),yz=$o("PopoverContent.RemoveScroll"),vz=Pr.forwardRef(is(function(t,n){let r=Xl(Hf,t.__scopePopover),o=Pr.useRef(null),a=Kt(n,o),i=Pr.useRef(!1);return Pr.useEffect(()=>{let s=o.current;if(s)return ph(s)},[]),wo(zf,{as:yz,allowPinchZoom:!0,children:wo(sM,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:lt(t.onCloseAutoFocus,s=>{s.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:lt(t.onPointerDownOutside,s=>{let l=s.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:lt(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),wz=Pr.forwardRef(is(function(t,n){let r=Xl(Hf,t.__scopePopover),o=Pr.useRef(!1),a=Pr.useRef(!1);return wo(sM,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||r.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,a.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));let s=i.target;r.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})},"PopoverContentNonModal")),sM=Pr.forwardRef(is(function(t,n){let{__scopePopover:r,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:d,...m}=t,f=Xl(Hf,r),h=xh(r);return fu(),wo(Zp,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:a,onUnmountAutoFocus:i,children:wo(Js,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:d,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:wo(rl,{"data-state":L0(f.open),role:"dialog",id:f.contentId,...h,...m,ref:n,style:{...m.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function L0(e){return e?"open":"closed"}is(L0,"getState");var lM=cz,cM=dz,uM=mz,dM=gz,R0=bz;import{jsx as fM}from"react/jsx-runtime";var xu=lM,Su=uM,pM=cM,Zl=mM.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>fM(dM,{children:fM(R0,{ref:o,align:t,sideOffset:n,className:ee("depth-root z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));Zl.displayName=R0.displayName;import*as P0 from"react";import{jsx as hM}from"react/jsx-runtime";var ol=P0.forwardRef(({className:e,type:t,...n},r)=>hM("input",{type:t,className:ee("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ol.displayName="Input";var Sz=P0.forwardRef(({className:e,type:t,...n},r)=>hM("input",{type:t,className:ee("flex h-9 w-full rounded-md bg-transparent px-[6px] py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-0 focus:shadow-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ol.displayName="Input";Sz.displayName="InputWO";import*as z0 from"react";import*as gn from"react";import*as gM from"react";import{jsx as Tz}from"react/jsx-runtime";var Cz=Object.defineProperty,kz=(e,t)=>Cz(e,"name",{value:t,configurable:!0}),Iz=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Mz=gM.forwardRef(kz(function(t,n){return Tz(dn.span,{...t,ref:n,style:{...Iz,...t.style}})},"VisuallyHidden")),bM=Mz;import{jsx as jo,jsxs as Pz}from"react/jsx-runtime";var Rz=Object.defineProperty,co=(e,t)=>Rz(e,"name",{value:t,configurable:!0}),[B0,Qee]=xr("Tooltip",[_a]),N0=_a(),Dz="TooltipProvider",Az=700,D0="tooltip.open",[Bz,E0]=B0(Dz),Nz=co(e=>{let{__scopeTooltip:t,delayDuration:n=Az,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=e,i=gn.useRef(!0),s=gn.useRef(!1),l=gn.useRef(0);return gn.useEffect(()=>{let c=l.current;return()=>window.clearTimeout(c)},[]),jo(Bz,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:gn.useCallback(()=>{r<=0||(window.clearTimeout(l.current),i.current=!1)},[r]),onClose:gn.useCallback(()=>{r<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:gn.useCallback(c=>{s.current=c},[]),disableHoverableContent:o,children:a})},"TooltipProvider"),A0="Tooltip",[Ez,Wf]=B0(A0),Oz=co(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:a,disableHoverableContent:i,delayDuration:s}=e,l=E0(A0,e.__scopeTooltip),c=N0(t),[u,d]=gn.useState(null),[m,f]=gn.useState(void 0),h=Oi(),p=gn.useRef(0),g=i??l.disableHoverableContent,y=s??l.delayDuration,v=gn.useRef(!1),[b,S]=go({prop:r,defaultProp:o??!1,onChange:co(x=>{x?(l.onOpen(),document.dispatchEvent(new CustomEvent(D0))):l.onClose(),a?.(x)},"onChange"),caller:A0}),C=gn.useMemo(()=>b?v.current?"delayed-open":"instant-open":"closed",[b]),w=gn.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v.current=!1,S(!0)},[S]),k=gn.useCallback(()=>{window.clearTimeout(p.current),p.current=0,S(!1)},[S]),M=gn.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{v.current=!0,S(!0),p.current=0},y)},[y,S]);return gn.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),jo(nl,{...c,children:jo(Ez,{scope:t,contentId:m??h,setContentId:f,open:b,stateAttribute:C,trigger:u,onTriggerChange:d,onTriggerEnter:gn.useCallback(()=>{l.isOpenDelayedRef.current?M():w()},[l.isOpenDelayedRef,M,w]),onTriggerLeave:gn.useCallback(()=>{g?k():(window.clearTimeout(p.current),p.current=0)},[k,g]),onOpen:w,onClose:k,disableHoverableContent:g,children:n})})},"Tooltip"),yM="TooltipTrigger",_z=gn.forwardRef(co(function(t,n){let{__scopeTooltip:r,...o}=t,a=Wf(yM,r),i=E0(yM,r),s=N0(r),l=gn.useRef(null),c=Kt(n,l,a.onTriggerChange),u=gn.useRef(!1),d=gn.useRef(!1),m=gn.useCallback(()=>u.current=!1,[]);return gn.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),jo(os,{asChild:!0,...s,children:jo(dn.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...o,ref:c,onPointerMove:lt(t.onPointerMove,f=>{f.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),d.current=!0)}),onPointerLeave:lt(t.onPointerLeave,()=>{a.onTriggerLeave(),d.current=!1}),onPointerDown:lt(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:lt(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:lt(t.onBlur,a.onClose),onClick:lt(t.onClick,a.onClose)})})},"TooltipTrigger")),vM="TooltipPortal",[Fz,zz]=B0(vM,{forceMount:void 0}),Hz=co(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,a=Wf(vM,t);return jo(Fz,{scope:t,forceMount:n,children:jo(Uo,{present:n||a.open,children:jo(hu,{asChild:!0,container:o,children:r})})})},"TooltipPortal"),Vf="TooltipContent",Vz=gn.forwardRef(co(function(t,n){let r=zz(Vf,t.__scopeTooltip),{forceMount:o=r.forceMount,side:a="top",...i}=t,s=Wf(Vf,t.__scopeTooltip);return jo(Uo,{present:o||s.open,children:s.disableHoverableContent?jo(wM,{side:a,...i,ref:n}):jo(Wz,{side:a,...i,ref:n})})},"TooltipContent")),Wz=gn.forwardRef(co(function(t,n){let r=Wf(Vf,t.__scopeTooltip),o=E0(Vf,t.__scopeTooltip),a=gn.useRef(null),i=Kt(n,a),[s,l]=gn.useState(null),{trigger:c,onClose:u}=r,d=a.current,{onPointerInTransitChange:m}=o,f=gn.useCallback(()=>{l(null),m(!1)},[m]),h=gn.useCallback((p,g)=>{let y=p.currentTarget,v={x:p.clientX,y:p.clientY},b=xM(v,y.getBoundingClientRect()),S=SM(v,b),C=CM(g.getBoundingClientRect()),w=TM([...S,...C]);l(w),m(!0)},[m]);return gn.useEffect(()=>()=>f(),[f]),gn.useEffect(()=>{if(c&&d){let p=co(y=>h(y,d),"handleTriggerLeave"),g=co(y=>h(y,c),"handleContentLeave");return c.addEventListener("pointerleave",p),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",p),d.removeEventListener("pointerleave",g)}}},[c,d,h,f]),gn.useEffect(()=>{if(s){let p=co(g=>{let y=g.target,v={x:g.clientX,y:g.clientY},b=c?.contains(y)||d?.contains(y),S=!kM(v,s);b?f():S&&(f(),u())},"handleTrackPointerGrace");return document.addEventListener("pointermove",p),()=>document.removeEventListener("pointermove",p)}},[c,d,s,u,f]),jo(wM,{...t,ref:i})},"TooltipContentHoverable")),qz=Oy("TooltipContent"),wM=gn.forwardRef(co(function(t,n){let{__scopeTooltip:r,children:o,"aria-label":a,id:i,onEscapeKeyDown:s,onPointerDownOutside:l,...c}=t,u=Wf(Vf,r),d=N0(r),{onClose:m}=u;gn.useEffect(()=>(document.addEventListener(D0,m),()=>document.removeEventListener(D0,m)),[m]),gn.useEffect(()=>{if(u.trigger){let h=co(p=>{p.target instanceof Node&&p.target.contains(u.trigger)&&m()},"handleScroll");return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,m]);let{setContentId:f}=u;return Fr(()=>(f(i),()=>{f(void 0)}),[i,f]),jo(Js,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:Pz(rl,{"data-state":u.stateAttribute,role:a?void 0:"tooltip",id:a?void 0:u.contentId,...d,...c,ref:n,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[jo(qz,{children:o}),a?jo(bM,{id:u.contentId,role:"tooltip",children:a}):null]})})},"TooltipContentImpl"));function xM(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,o,a)){case a:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}co(xM,"getExitSideFromRect");function SM(e,t,n=5){let r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}co(SM,"getPaddedExitPoints");function CM(e){let{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}co(CM,"getPointsFromRect");function kM(e,t){let{x:n,y:r}=e,o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){let s=t[a],l=t[i],c=s.x,u=s.y,d=l.x,m=l.y;u>r!=m>r&&n<(d-c)*(r-u)/(m-u)+c&&(o=!o)}return o}co(kM,"isPointInPolygon");function TM(e){let t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),IM(t)}co(TM,"getHull");function IM(e){if(e.length<=1)return e.slice();let t=[];for(let r=0;r<e.length;r++){let o=e[r];for(;t.length>=2;){let a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();let n=[];for(let r=e.length-1;r>=0;r--){let o=e[r];for(;n.length>=2;){let a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}co(IM,"getHullPresorted");var MM=Nz,LM=Oz,O0=_z,RM=Hz,_0=Vz;import{jsx as F0}from"react/jsx-runtime";var Sh=MM,Ht=LM,Ot=z0.forwardRef(({children:e,asChild:t,...n},r)=>F0(O0,{ref:r,asChild:t??!0,...n,children:e}));Ot.displayName=O0.displayName;var _t=z0.forwardRef(({className:e,sideOffset:t=4,...n},r)=>F0(RM,{children:F0(_0,{ref:r,sideOffset:t,className:ee("depth-root z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));_t.displayName=_0.displayName;import{jsx as br,jsxs as yi}from"react/jsx-runtime";function kh(e){let t=e.trim();if(/^#[0-9a-fA-F]{8}$/.test(t))return t;if(/^#[0-9a-fA-F]{6}$/.test(t))return t+"ff";if(/^#[0-9a-fA-F]{4}$/.test(t)){let[,r,o,a,i]=t.split("");return`#${r}${r}${o}${o}${a}${a}${i}${i}`}if(/^#[0-9a-fA-F]{3}$/.test(t)){let[,r,o,a]=t.split("");return`#${r}${r}${o}${o}${a}${a}ff`}let n=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)$/);if(n){let r=c=>Math.min(255,Math.max(0,c)).toString(16).padStart(2,"0"),o=r(parseInt(n[1])),a=r(parseInt(n[2])),i=r(parseInt(n[3])),s=n[4]!==void 0?parseFloat(n[4]):1,l=r(Math.round(s*255));return`#${o}${a}${i}${l}`}return"#ffffffff"}function Yz(e){return e.slice(0,7)}function Kz(e){let t=parseInt(e.slice(7,9),16);return Math.round(t/255*100)}function $z(e,t){let n=Math.round(Math.min(100,Math.max(0,t))/100*255);return e.slice(0,7)+n.toString(16).padStart(2,"0")}function DM(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16),o=parseInt(e.slice(7,9),16)/255;return`rgba(${t},${n},${r},${o.toFixed(3)})`}function AM(){let e=qr(Cn.colorSwatches,null);return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function BM(e){kr(Cn.colorSwatches,e)}var Lo=jz(({disabled:e,value:t,onChange:n,onBlur:r,name:o,className:a,presets:i,hideButton:s,open:l,onOpenChange:c,...u},d)=>{let m=gT(d),[f,h]=H0(!1),p=l!==void 0?l:f,g=c??h,[y,v]=H0(AM);PM(()=>nd(()=>v(AM())),[]);let b=Gz(()=>kh(t||"#ffffffff"),[t]),S=Yz(b),C=Kz(b),w=DM(b),k=b.slice(0,7),[M,I]=H0(b);PM(()=>{I(b)},[b]);let x=Ch(N=>{let O=b.slice(7,9);n(N+O)},[b,n]),T=Ch(N=>{n($z(b,parseInt(N.target.value)))},[b,n]),R=Ch(()=>{if(y.includes(b))return;let N=[...y,b].slice(-16);v(N),BM(N)},[b,y]),P=Ch(N=>{let O=y.filter(A=>A!==N);v(O),BM(O)},[y]),D=({label:N,colors:O,removable:A})=>O.length?yi("div",{className:"mt-3",children:[br("span",{className:"text-[10px] text-muted-foreground font-medium uppercase tracking-widest",children:N}),br("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:O.map(B=>{let E=DM(kh(B));return yi("div",{className:"relative group",children:[yi(Ht,{children:[br(Ot,{asChild:!0,children:br(pr,{onMouseDown:()=>{n(kh(B))},className:"w-6 h-6 px-1 rounded border border-white/10 transition-all cursor-pointer",style:{backgroundImage:`
|
|
46
|
+
linear-gradient(${E}, ${E}),
|
|
47
|
+
repeating-conic-gradient(#888 0% 25%, #555 0% 50%)
|
|
48
|
+
`,backgroundSize:"cover, 8px 8px"}})}),br(_t,{className:"bg-background border border-border z-[400]",children:B})]}),A&&br("button",{type:"button",onClick:L=>{L.stopPropagation(),P(B)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full bg-background border border-white/20 text-muted-foreground hover:text-foreground items-center justify-center hidden group-hover:flex",children:br(_r,{className:"w-2 h-2"})})]},B)})})]}):null;return yi(xu,{onOpenChange:g,open:p,children:[s?br(pM,{asChild:!0,children:br("span",{className:"absolute inset-0 pointer-events-none"})}):br(Su,{asChild:!0,disabled:e,onBlur:r,children:br(pr,{...u,className:ee("block relative overflow-hidden",a),name:o,onClick:()=>g(!0),size:"icon",variant:"outline",style:{backgroundImage:`
|
|
49
|
+
linear-gradient(${w}, ${w}),
|
|
50
|
+
repeating-conic-gradient(#888 0% 25%, #555 0% 50%)
|
|
51
|
+
`,backgroundSize:"cover, 8px 8px"},children:br("div",{})})}),yi(Zl,{className:"w-full z-[300]",children:[br(hT,{color:S,onChange:x}),yi("div",{className:"mt-3 flex flex-col gap-1",children:[yi("div",{className:"flex items-center justify-between",children:[br("span",{className:"text-[10px] text-muted-foreground font-medium uppercase tracking-widest",children:"Opacity"}),yi("span",{className:"text-[11px] font-mono text-muted-foreground tabular-nums w-9 text-right",children:[C,"%"]})]}),yi("div",{className:"relative h-3 flex items-center",children:[br("div",{className:"absolute inset-0 rounded-full overflow-hidden",style:{backgroundImage:"repeating-conic-gradient(#888 0% 25%, #555 0% 50%)",backgroundSize:"8px 8px"}}),br("div",{className:"absolute inset-0 rounded-full",style:{background:`linear-gradient(to right, transparent, ${k})`}}),br("input",{type:"range",min:0,max:100,step:1,value:C,onChange:T,className:"relative w-full h-3 appearance-none bg-transparent cursor-pointer opacity-slider"})]})]}),yi("div",{className:"flex flex-row gap-2 mt-3",children:[br("div",{className:"!w-36",children:br(ol,{ref:m,value:M,className:"font-mono text-xs",placeholder:"#rrggbbaa",maxLength:9,onChange:N=>{let O=N.currentTarget.value;I(O),/^#[0-9a-fA-F]{3,8}$/.test(O)&&n(kh(O))},onBlur:()=>{I(b)}})}),yi(Ht,{delayDuration:700,children:[br(Ot,{asChild:!0,children:br(pr,{variant:"outline",className:"hover:bg-muted",onClick:R,disabled:y.includes(b),children:br(ha,{})})}),br(_t,{className:"bg-background border border-border z-[400]",children:"Save current color"})]})]}),i&&i.length>0&&br(D,{label:"Presets",colors:i}),br(D,{label:"Saved",colors:y,removable:!0}),br("style",{children:`
|
|
52
|
+
.opacity-slider::-webkit-slider-thumb {
|
|
53
|
+
-webkit-appearance: none;
|
|
54
|
+
width: 14px;
|
|
55
|
+
height: 14px;
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
background: white;
|
|
58
|
+
border: 2px solid rgba(0,0,0,0.35);
|
|
59
|
+
box-shadow: 0 1px 4px rgba(0,0,0,0.4);
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
}
|
|
62
|
+
.opacity-slider::-moz-range-thumb {
|
|
63
|
+
width: 14px;
|
|
64
|
+
height: 14px;
|
|
65
|
+
border-radius: 50%;
|
|
66
|
+
background: white;
|
|
67
|
+
border: 2px solid rgba(0,0,0,0.35);
|
|
68
|
+
box-shadow: 0 1px 4px rgba(0,0,0,0.4);
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
}
|
|
71
|
+
`})]})]})});Lo.displayName="ColorPicker";import*as aL from"react";import*as Qn from"react";var Xz=Object.defineProperty,Zz=(e,t)=>Xz(e,"name",{value:t,configurable:!0});function Th(e,[t,n]){return Math.min(n,Math.max(t,e))}Zz(Th,"clamp");import*as Ih from"react";import{jsx as gte}from"react/jsx-runtime";var Qz=Object.defineProperty,Jz=(e,t)=>Qz(e,"name",{value:t,configurable:!0}),eH=Ih.createContext(void 0);function Ql(e){let t=Ih.useContext(eH);return e||t||"ltr"}Jz(Ql,"useDirection");import*as Mh from"react";var tH=Object.defineProperty,nH=(e,t)=>tH(e,"name",{value:t,configurable:!0});function V0(e){let t=Mh.useRef({value:e,previous:e});return Mh.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}nH(V0,"usePrevious");import*as vi from"react";import{jsx as W0}from"react/jsx-runtime";import*as Qo from"react";import{jsx as Cu}from"react/jsx-runtime";var rH=Object.defineProperty,uo=(e,t)=>rH(e,"name",{value:t,configurable:!0});function Jl(e){let t=e+"CollectionProvider",[n,r]=xr(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=uo(p=>{let{scope:g,children:y}=p,v=vi.useRef(null),b=vi.useRef(new Map).current;return W0(o,{scope:g,itemMap:b,collectionRef:v,children:y})},"CollectionProvider");i.displayName=t;let s=e+"CollectionSlot",l=$o(s),c=vi.forwardRef((p,g)=>{let{scope:y,children:v}=p,b=a(s,y),S=Kt(g,b.collectionRef);return W0(l,{ref:S,children:v})});c.displayName=s;let u=e+"CollectionItemSlot",d="data-radix-collection-item",m=$o(u),f=vi.forwardRef((p,g)=>{let{scope:y,children:v,...b}=p,S=vi.useRef(null),C=Kt(g,S),w=a(u,y);return vi.useEffect(()=>(w.itemMap.set(S,{ref:S,...b}),()=>{w.itemMap.delete(S)})),W0(m,{[d]:"",ref:C,children:v})});f.displayName=u;function h(p){let g=a(e+"CollectionConsumer",p);return vi.useCallback(()=>{let v=g.collectionRef.current;if(!v)return[];let b=Array.from(v.querySelectorAll(`[${d}]`));return Array.from(g.itemMap.values()).sort((w,k)=>b.indexOf(w.ref.current)-b.indexOf(k.ref.current))},[g.collectionRef,g.itemMap])}return uo(h,"useCollection"),[{Provider:i,Slot:c,ItemSlot:f},h,r]}uo(Jl,"createCollection");var NM=new WeakMap,Kr,ya,q0=(ya=class extends Map{constructor(n){super(n);fS(this,Kr);Xg(this,Kr,[...super.keys()]),NM.set(this,!0)}set(n,r){return NM.get(this)&&(this.has(n)?ko(this,Kr)[ko(this,Kr).indexOf(n)]=n:ko(this,Kr).push(n)),super.set(n,r),this}insert(n,r,o){let a=this.has(r),i=ko(this,Kr).length,s=j0(n),l=s>=0?s:i+s,c=l<0||l>=i?-1:l;if(c===this.size||a&&c===this.size-1||c===-1)return this.set(r,o),this;let u=this.size+(a?0:1);s<0&&l++;let d=[...ko(this,Kr)],m,f=!1;for(let h=l;h<u;h++)if(l===h){let p=d[h];d[h]===r&&(p=d[h+1]),a&&this.delete(r),m=this.get(p),this.set(r,o)}else{!f&&d[h-1]===r&&(f=!0);let p=d[f?h:h-1],g=m;m=this.get(p),this.delete(p),this.set(p,g)}return this}with(n,r,o){let a=new ya(this);return a.insert(n,r,o),a}before(n){let r=ko(this,Kr).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,o){let a=ko(this,Kr).indexOf(n);return a===-1?this:this.insert(a,r,o)}after(n){let r=ko(this,Kr).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,o){let a=ko(this,Kr).indexOf(n);return a===-1?this:this.insert(a+1,r,o)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Xg(this,Kr,[]),super.clear()}delete(n){let r=super.delete(n);return r&&ko(this,Kr).splice(ko(this,Kr).indexOf(n),1),r}deleteAt(n){let r=this.keyAt(n);return r!==void 0?this.delete(r):!1}at(n){let r=Lh(ko(this,Kr),n);if(r!==void 0)return this.get(r)}entryAt(n){let r=Lh(ko(this,Kr),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return ko(this,Kr).indexOf(n)}keyAt(n){return Lh(ko(this,Kr),n)}from(n,r){let o=this.indexOf(n);if(o===-1)return;let a=o+r;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.at(a)}keyFrom(n,r){let o=this.indexOf(n);if(o===-1)return;let a=o+r;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.keyAt(a)}find(n,r){let o=0;for(let a of this){if(Reflect.apply(n,r,[a,o,this]))return a;o++}}findIndex(n,r){let o=0;for(let a of this){if(Reflect.apply(n,r,[a,o,this]))return o;o++}return-1}filter(n,r){let o=[],a=0;for(let i of this)Reflect.apply(n,r,[i,a,this])&&o.push(i),a++;return new ya(o)}map(n,r){let o=[],a=0;for(let i of this)o.push([i[0],Reflect.apply(n,r,[i,a,this])]),a++;return new ya(o)}reduce(...n){let[r,o]=n,a=0,i=o??this.at(0);for(let s of this)a===0&&n.length===1?i=s:i=Reflect.apply(r,this,[i,s,a,this]),a++;return i}reduceRight(...n){let[r,o]=n,a=o??this.at(-1);for(let i=this.size-1;i>=0;i--){let s=this.at(i);i===this.size-1&&n.length===1?a=s:a=Reflect.apply(r,this,[a,s,i,this])}return a}toSorted(n){let r=[...this.entries()].sort(n);return new ya(r)}toReversed(){let n=new ya;for(let r=this.size-1;r>=0;r--){let o=this.keyAt(r),a=this.get(o);n.set(o,a)}return n}toSpliced(...n){let r=[...this.entries()];return r.splice(...n),new ya(r)}slice(n,r){let o=new ya,a=this.size-1;if(n===void 0)return o;n<0&&(n=n+this.size),r!==void 0&&r>0&&(a=r-1);for(let i=n;i<=a;i++){let s=this.keyAt(i),l=this.get(s);o.set(s,l)}return o}every(n,r){let o=0;for(let a of this){if(!Reflect.apply(n,r,[a,o,this]))return!1;o++}return!0}some(n,r){let o=0;for(let a of this){if(Reflect.apply(n,r,[a,o,this]))return!0;o++}return!1}},Kr=new WeakMap,uo(ya,"OrderedDict"),ya);function Lh(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);let n=EM(e,t);return n===-1?void 0:e[n]}uo(Lh,"at");function EM(e,t){let n=e.length,r=j0(t),o=r>=0?r:n+r;return o<0||o>=n?-1:o}uo(EM,"toSafeIndex");function j0(e){return e!==e||e===0?0:Math.trunc(e)}uo(j0,"toSafeInteger");function oH(e){let t=e+"CollectionProvider",[n,r]=xr(t),[o,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new q0,setItemMap:uo(()=>{},"setItemMap")}),i=uo(({state:b,...S})=>b?Cu(l,{...S,state:b}):Cu(s,{...S}),"CollectionProvider");i.displayName=t;let s=uo(b=>{let S=g();return Cu(l,{...b,state:S})},"CollectionInit");s.displayName=t+"Init";let l=uo(b=>{let{scope:S,children:C,state:w}=b,k=Qo.useRef(null),[M,I]=Qo.useState(null),x=Kt(k,I),[T,R]=w;return Qo.useEffect(()=>{if(!M)return;let P=FM(()=>{});return P.observe(M,{childList:!0,subtree:!0}),()=>{P.disconnect()}},[M]),Cu(o,{scope:S,itemMap:T,setItemMap:R,collectionRef:x,collectionRefObject:k,collectionElement:M,children:C})},"CollectionProviderImpl");l.displayName=t+"Impl";let c=e+"CollectionSlot",u=$o(c),d=Qo.forwardRef((b,S)=>{let{scope:C,children:w}=b,k=a(c,C),M=Kt(S,k.collectionRef);return Cu(u,{ref:M,children:w})});d.displayName=c;let m=e+"CollectionItemSlot",f="data-radix-collection-item",h=$o(m),p=Qo.forwardRef((b,S)=>{let{scope:C,children:w,...k}=b,M=Qo.useRef(null),[I,x]=Qo.useState(null),T=Kt(S,M,x),R=a(m,C),{setItemMap:P}=R,D=Qo.useRef(k);OM(D.current,k)||(D.current=k);let N=D.current;return Qo.useEffect(()=>{let O=N;return P(A=>I?A.has(I)?A.set(I,{...O,element:I}).toSorted(U0):(A.set(I,{...O,element:I}),A.toSorted(U0)):A),()=>{P(A=>!I||!A.has(I)?A:(A.delete(I),new q0(A)))}},[I,N,P]),Cu(h,{[f]:"",ref:T,children:w})});p.displayName=m;function g(){return Qo.useState(new q0)}uo(g,"useInitCollection");function y(b){let{itemMap:S}=a(e+"CollectionConsumer",b);return S}return uo(y,"useCollection"),[{Provider:i,Slot:d,ItemSlot:p},{createCollectionScope:r,useCollection:y,useInitCollection:g}]}uo(oH,"createCollection");function OM(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||e[o]!==t[o])return!1;return!0}uo(OM,"shallowEqual");function _M(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}uo(_M,"isElementPreceding");function U0(e,t){return!e[1].element||!t[1].element?0:_M(e[1].element,t[1].element)?-1:1}uo(U0,"sortByDocumentPosition");function FM(e){return new MutationObserver(n=>{for(let r of n)if(r.type==="childList"){e();return}})}uo(FM,"getChildListObserver");import{Fragment as iH,jsx as Jr,jsxs as sH}from"react/jsx-runtime";var aH=Object.defineProperty,Wn=(e,t)=>aH(e,"name",{value:t,configurable:!0}),HM=["PageUp","PageDown"],VM=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],WM={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Uf="Slider",[Y0,lH,cH]=Jl(Uf),[K0,Hte]=xr(Uf,[cH]),[uH,jf]=K0(Uf),$0=Qn.forwardRef(Wn(function(t,n){let{name:r,min:o=0,max:a=100,step:i=1,orientation:s="horizontal",disabled:l=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[o],value:d,onValueChange:m=Wn(()=>{},"onValueChange"),onValueCommit:f=Wn(()=>{},"onValueCommit"),inverted:h=!1,form:p,...g}=t,y=Qn.useRef(new Set),v=Qn.useRef(0),b=Qn.useRef(!1),C=s==="horizontal"?dH:fH,[w,k]=Qn.useState(null),M=Kt(n,k),[I=[],x]=go({prop:d,defaultProp:u,onChange:Wn(A=>{[...y.current][v.current]?.focus({preventScroll:!0,focusVisible:b.current}),b.current=!1,m(A)},"onChange")}),T=Qn.useRef(I),R=Qn.useRef(I);Qn.useEffect(()=>{let A=p?w?.ownerDocument.getElementById(p):w?.closest("form");if(A instanceof HTMLFormElement){let B=Wn(()=>x(R.current),"reset");return A.addEventListener("reset",B),()=>A.removeEventListener("reset",B)}},[w,p,x]);function P(A){let B=JM(I,A);O(A,B)}Wn(P,"handleSlideStart");function D(A){O(A,v.current)}Wn(D,"handleSlideMove");function N(){String(I)!==String(T.current)&&f(I)}Wn(N,"handleSlideEnd");function O(A,B,{commit:E}={commit:!1}){let L=Z0(i),z=qf(Math.round((A-o)/i)*i+o,L),Y=Th(z,[o,a]);x((G=[])=>{let H=ZM(G,Y,B);if(nL(H,c*i)){v.current=H.indexOf(Y);let W=String(H)!==String(G);return W&&E&&f(H),W?H:G}else return G})}return Wn(O,"updateValues"),Jr(uH,{scope:t.__scopeSlider,name:r,disabled:l,min:o,max:a,valueIndexToChangeRef:v,thumbs:y.current,values:I,orientation:s,form:p,children:Jr(Y0.Provider,{scope:t.__scopeSlider,children:Jr(Y0.Slot,{scope:t.__scopeSlider,children:Jr(C,{"aria-disabled":l,"data-disabled":l?"":void 0,...g,ref:M,onPointerDown:lt(g.onPointerDown,()=>{l||(T.current=I,b.current=!1)}),min:o,max:a,inverted:h,onSlideStart:l?void 0:P,onSlideMove:l?void 0:D,onSlideEnd:l?void 0:N,onHomeKeyDown:()=>{l||(b.current=!0,O(o,0,{commit:!0}))},onEndKeyDown:()=>{l||(b.current=!0,O(a,I.length-1,{commit:!0}))},onStepKeyDown:({event:A,direction:B})=>{if(!l){b.current=!0;let z=HM.includes(A.key)||A.shiftKey&&VM.includes(A.key)?10:1,Y=v.current,G=I[Y],H=rL(G,{min:o,step:i,direction:B,multiplier:z});O(H,Y,{commit:!0})}}})})})})},"Slider")),[qM,UM]=K0(Uf,{startEdge:"left",endEdge:"right",size:"width",direction:1}),dH=Qn.forwardRef(Wn(function(t,n){let{min:r,max:o,dir:a,inverted:i,onSlideStart:s,onSlideMove:l,onSlideEnd:c,onStepKeyDown:u,...d}=t,[m,f]=Qn.useState(null),h=Kt(n,f),p=Qn.useRef(void 0),g=Ql(a),y=g==="ltr",v=y&&!i||!y&&i;function b(S){let C=p.current||m.getBoundingClientRect(),w=[0,C.width],M=Rh(w,v?[r,o]:[o,r]);return p.current=C,M(S-C.left)}return Wn(b,"getValueFromPointer"),Jr(qM,{scope:t.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:Jr(jM,{dir:g,"data-orientation":"horizontal",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:S=>{let C=b(S.clientX);s?.(C)},onSlideMove:S=>{let C=b(S.clientX);l?.(C)},onSlideEnd:()=>{p.current=void 0,c?.()},onStepKeyDown:S=>{let w=WM[v?"from-left":"from-right"].includes(S.key);u?.({event:S,direction:w?-1:1})}})})},"SliderHorizontal")),fH=Qn.forwardRef(Wn(function(t,n){let{min:r,max:o,inverted:a,onSlideStart:i,onSlideMove:s,onSlideEnd:l,onStepKeyDown:c,...u}=t,d=Qn.useRef(null),m=Kt(n,d),f=Qn.useRef(void 0),h=!a;function p(g){let y=f.current||d.current.getBoundingClientRect(),v=[0,y.height],S=Rh(v,h?[o,r]:[r,o]);return f.current=y,S(g-y.top)}return Wn(p,"getValueFromPointer"),Jr(qM,{scope:t.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1,children:Jr(jM,{"data-orientation":"vertical",...u,ref:m,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:g=>{let y=p(g.clientY);i?.(y)},onSlideMove:g=>{let y=p(g.clientY);s?.(y)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:g=>{let v=WM[h?"from-bottom":"from-top"].includes(g.key);c?.({event:g,direction:v?-1:1})}})})},"SliderVertical")),jM=Qn.forwardRef(Wn(function(t,n){let{__scopeSlider:r,onSlideStart:o,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:s,onEndKeyDown:l,onStepKeyDown:c,...u}=t,d=jf(Uf,r);return Jr(dn.span,{...u,ref:n,onKeyDown:lt(t.onKeyDown,m=>{m.key==="Home"?(s(m),m.preventDefault()):m.key==="End"?(l(m),m.preventDefault()):HM.concat(VM).includes(m.key)&&(c(m),m.preventDefault())}),onPointerDown:lt(t.onPointerDown,m=>{let f=m.target;f.setPointerCapture(m.pointerId),m.preventDefault(),d.thumbs.has(f)?f.focus({preventScroll:!0,focusVisible:!1}):o(m)}),onPointerMove:lt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&a(m)}),onPointerUp:lt(t.onPointerUp,m=>{let f=m.target;f.hasPointerCapture(m.pointerId)&&(f.releasePointerCapture(m.pointerId),i(m))})})},"SliderImpl")),mH="SliderTrack",GM=Qn.forwardRef(Wn(function(t,n){let{__scopeSlider:r,...o}=t,a=jf(mH,r);return Jr(dn.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...o,ref:n})},"SliderTrack")),zM="SliderRange",YM=Qn.forwardRef(Wn(function(t,n){let{__scopeSlider:r,...o}=t,a=jf(zM,r),i=UM(zM,r),s=Qn.useRef(null),l=Kt(n,s),c=a.values.length,u=a.values.map(f=>X0(f,a.min,a.max)),d=c>1?Math.min(...u):0,m=100-Math.max(...u);return Jr(dn.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...o,ref:l,style:{...t.style,[i.startEdge]:d+"%",[i.endEdge]:m+"%"}})},"SliderRange")),pH="SliderThumb",[hH,KM]=K0(pH),gH="SliderThumbProvider";function $M(e){let{__scopeSlider:t,name:n,children:r,internal_do_not_use_render:o}=e,a=jf(gH,t),i=lH(t),[s,l]=Qn.useState(null),c=Qn.useMemo(()=>s?i().findIndex(g=>g.ref.current===s):-1,[i,s]),u=es(s),d=s?!!a.form||!!s.closest("form"):!0,m=a.values[c],f=n??(a.name?a.name+(a.values.length>1?"[]":""):void 0),h=m===void 0?0:X0(m,a.min,a.max);Qn.useEffect(()=>{if(s)return a.thumbs.add(s),()=>{a.thumbs.delete(s)}},[s,a.thumbs]);let p={value:m,name:f,form:a.form,isFormControl:d,index:c,thumb:s,onThumbChange:l,percent:h,size:u};return Jr(hH,{scope:t,...p,children:oL(o)?o(p):r})}Wn($M,"SliderThumbProvider");var G0="SliderThumbTrigger",bH=Qn.forwardRef(Wn(function(t,n){let{__scopeSlider:r,...o}=t,a=jf(G0,r),i=UM(G0,r),{index:s,value:l,percent:c,size:u,onThumbChange:d}=KM(G0,r),m=Kt(n,d),f=QM(s,a.values.length),h=u?.[i.size],p=h?eL(h,c,i.direction):0;return Jr("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${c}% + ${p}px)`},children:Jr(Y0.ItemSlot,{scope:r,children:Jr(dn.span,{role:"slider","aria-label":t["aria-label"]||f,"aria-valuemin":a.min,"aria-valuenow":l,"aria-valuemax":a.max,"aria-orientation":a.orientation,"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,tabIndex:a.disabled?void 0:0,...o,ref:m,style:l===void 0?{display:"none"}:t.style,onFocus:lt(t.onFocus,()=>{a.valueIndexToChangeRef.current=s})})})})},"SliderThumbTrigger")),XM=Qn.forwardRef(Wn(function(t,n){let{__scopeSlider:r,name:o,...a}=t;return Jr($M,{__scopeSlider:r,name:o,internal_do_not_use_render:({index:i,isFormControl:s})=>sH(iH,{children:[Jr(bH,{...a,ref:n,__scopeSlider:r}),s?Jr(vH,{__scopeSlider:r},i):null]})})},"SliderThumb")),yH="SliderBubbleInput",vH=Qn.forwardRef(Wn(function({__scopeSlider:t,...n},r){let{value:o,name:a,form:i}=KM(yH,t),s=Qn.useRef(null),l=Kt(s,r),c=V0(o);return Qn.useEffect(()=>{let u=s.current;if(!u)return;let d=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(d,"value").set;if(c!==o&&f){let h=new Event("input",{bubbles:!0});f.call(u,o),u.dispatchEvent(h)}},[c,o]),Jr(dn.input,{style:{display:"none"},name:a,form:i,...n,ref:l,defaultValue:o})},"SliderBubbleInput"));function ZM(e=[],t,n){let r=[...e];return r[n]=t,r.sort((o,a)=>o-a)}Wn(ZM,"getNextSortedValues");function X0(e,t,n){let a=100/(n-t)*(e-t);return Th(a,[0,100])}Wn(X0,"convertValueToPercentage");function QM(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}Wn(QM,"getLabel");function JM(e,t){if(e.length===1)return 0;let n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}Wn(JM,"getClosestValueIndex");function eL(e,t,n){let r=e/2,a=Rh([0,50],[0,r]);return(r-a(t)*n)*n}Wn(eL,"getThumbInBoundsOffset");function tL(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}Wn(tL,"getStepsBetweenValues");function nL(e,t){if(t>0){let n=tL(e);return Math.min(...n)>=t}return!0}Wn(nL,"hasMinStepsBetweenValues");function Rh(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}Wn(Rh,"linearScale");function Z0(e){if(!Number.isFinite(e))return 0;let t=e.toString();if(t.includes("e")){let[r,o]=t.split("e"),a=r.split(".")[1]||"",i=Number(o);return Math.max(0,a.length-i)}let n=t.split(".")[1];return n?n.length:0}Wn(Z0,"getDecimalCount");function qf(e,t){let n=Math.pow(10,t);return Math.round(e*n)/n}Wn(qf,"roundValue");function rL(e,{min:t,step:n,direction:r,multiplier:o}){let a=Z0(n),i=(e-t)/n,s=Math.round(i),l=qf(s*n+t,a)===qf(e,a),c;return l?c=s+o*r:r>0?c=Math.ceil(i):c=Math.floor(i),qf(c*n+t,a)}Wn(rL,"getNextStepValue");function oL(e){return typeof e=="function"}Wn(oL,"isFunction");import{jsx as Q0,jsxs as xH}from"react/jsx-runtime";var Dn=aL.forwardRef(({className:e,...t},n)=>xH($0,{ref:n,className:ee("relative flex w-full touch-none select-none items-center",e),...t,children:[Q0(GM,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-muted",children:Q0(YM,{className:"absolute h-full bg-muted-foreground/30"})}),Q0(XM,{className:"block h-4 w-4 rounded-full border border-muted bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));Dn.displayName=$0.displayName;import*as ss from"react";import*as Ro from"react";import*as Wt from"react";import*as fo from"react";import*as CH from"react";import*as Ph from"react";var SH=Object.defineProperty,ev=(e,t)=>SH(e,"name",{value:t,configurable:!0}),J0=!1;function iL(){let[e,t]=Ph.useState(J0);return Ph.useEffect(()=>{J0||(J0=!0,t(!0))},[]),e}ev(iL,"useIsHydrated");var sL=CH[" useSyncExternalStore ".trim().toString()];function lL(){return()=>{}}ev(lL,"subscribe");function cL(){return sL(lL,()=>!0,()=>!1)}ev(cL,"useIsHydratedModern");var uL=typeof sL=="function"?cL:iL;import{jsx as ec}from"react/jsx-runtime";var kH=Object.defineProperty,tc=(e,t)=>kH(e,"name",{value:t,configurable:!0}),tv="rovingFocusGroup.onEntryFocus",TH={bubbles:!1,cancelable:!0},Dh="RovingFocusGroup",[nv,dL,IH]=Jl(Dh),[MH,rv]=xr(Dh,[IH]),[LH,RH]=MH(Dh),PH=fo.forwardRef(tc(function(t,n){return ec(nv.Provider,{scope:t.__scopeRovingFocusGroup,children:ec(nv.Slot,{scope:t.__scopeRovingFocusGroup,children:ec(DH,{...t,ref:n})})})},"RovingFocusGroup")),DH=fo.forwardRef(tc(function(t,n){let{__scopeRovingFocusGroup:r,orientation:o,loop:a=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...m}=t,f=fo.useRef(null),h=Kt(n,f),p=Ql(i),[g,y]=go({prop:s,defaultProp:l??null,onChange:c,caller:Dh}),[v,b]=fo.useState(!1),S=Xo(u),C=dL(r),w=fo.useRef(!1),[k,M]=fo.useState(0);return fo.useEffect(()=>{let I=f.current;if(I)return I.addEventListener(tv,S),()=>I.removeEventListener(tv,S)},[S]),ec(LH,{scope:r,orientation:o,dir:p,loop:a,currentTabStopId:g,onItemFocus:fo.useCallback(I=>y(I),[y]),onItemShiftTab:fo.useCallback(()=>b(!0),[]),onFocusableItemAdd:fo.useCallback(()=>M(I=>I+1),[]),onFocusableItemRemove:fo.useCallback(()=>M(I=>I-1),[]),children:ec(dn.div,{tabIndex:v||k===0?-1:0,"data-orientation":o,...m,ref:h,style:{outline:"none",...t.style},onMouseDown:lt(t.onMouseDown,()=>{w.current=!0}),onFocus:lt(t.onFocus,I=>{let x=!w.current;if(I.target===I.currentTarget&&x&&!v){let T=new CustomEvent(tv,TH);if(I.currentTarget.dispatchEvent(T),!T.defaultPrevented){let R=C().filter(A=>A.focusable),P=R.find(A=>A.active),D=R.find(A=>A.id===g),O=[P,D,...R].filter(Boolean).map(A=>A.ref.current);ov(O,d)}}w.current=!1}),onBlur:lt(t.onBlur,()=>b(!1))})})},"RovingFocusGroupImpl")),AH="RovingFocusGroupItem",BH=fo.forwardRef(tc(function(t,n){let{__scopeRovingFocusGroup:r,focusable:o=!0,active:a=!1,tabStopId:i,children:s,...l}=t,c=Oi(),u=i||c,d=RH(AH,r),m=d.currentTabStopId===u,f=dL(r),{onFocusableItemAdd:h,onFocusableItemRemove:p,currentTabStopId:g}=d,y=uL();return Fr(()=>{if(!(!y||!o))return h(),()=>p()},[y,o,h,p]),fo.useEffect(()=>{if(!(y||!o))return h(),()=>p()},[y,o,h,p]),ec(nv.ItemSlot,{scope:r,id:u,focusable:o,active:a,children:ec(dn.span,{tabIndex:m?0:-1,"data-orientation":d.orientation,...l,ref:n,onMouseDown:lt(t.onMouseDown,v=>{o?d.onItemFocus(u):v.preventDefault()}),onFocus:lt(t.onFocus,()=>d.onItemFocus(u)),onKeyDown:lt(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;let b=mL(v,d.orientation,d.dir);if(b!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let C=f().filter(w=>w.focusable).map(w=>w.ref.current);if(b==="last")C.reverse();else if(b==="prev"||b==="next"){b==="prev"&&C.reverse();let w=C.indexOf(v.currentTarget);C=d.loop?pL(C,w+1):C.slice(w+1)}setTimeout(()=>ov(C))}}),children:typeof s=="function"?s({isCurrentTabStop:m,hasTabStop:g!=null}):s})})},"RovingFocusGroupItem")),NH={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function fL(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}tc(fL,"getDirectionAwareKey");function mL(e,t,n){let r=fL(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return NH[r]}tc(mL,"getFocusIntent");function ov(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}tc(ov,"focusFirst");function pL(e,t){return e.map((n,r)=>e[(t+r)%e.length])}tc(pL,"wrapArray");var hL=PH,gL=BH;import{jsx as kn}from"react/jsx-runtime";var OH=Object.defineProperty,qn=(e,t)=>OH(e,"name",{value:t,configurable:!0}),av=["Enter"," "],_H=["ArrowDown","PageUp","Home"],yL=["ArrowUp","PageDown","End"],FH=[..._H,...yL],zH={ltr:[...av,"ArrowRight"],rtl:[...av,"ArrowLeft"]},HH={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Bh="Menu",[Gf,VH,WH]=Jl(Bh),[nc,sv]=xr(Bh,[WH,_a,rv]),lv=_a(),vL=rv(),[qH,rc]=nc(Bh),[UH,Kf]=nc(Bh),jH=qn(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:i=!0}=e,s=lv(t),[l,c]=Wt.useState(null),u=Wt.useRef(!1),d=Xo(a),m=Ql(o);return Wt.useEffect(()=>{let f=qn(()=>{u.current=!0,document.addEventListener("pointerdown",h,{capture:!0,once:!0}),document.addEventListener("pointermove",h,{capture:!0,once:!0})},"handleKeyDown"),h=qn(()=>u.current=!1,"handlePointer");return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",h,{capture:!0}),document.removeEventListener("pointermove",h,{capture:!0})}},[]),Wt.useEffect(()=>{if(!n)return;let f=qn(()=>d(!1),"handleBlur");return window.addEventListener("blur",f),()=>window.removeEventListener("blur",f)},[n,d]),kn(nl,{...s,children:kn(qH,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:kn(UH,{scope:t,onClose:Wt.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:m,modal:i,children:r})})})},"Menu"),wL=Wt.forwardRef(qn(function(t,n){let{__scopeMenu:r,...o}=t,a=lv(r);return kn(os,{...a,...o,ref:n})},"MenuAnchor")),xL="MenuPortal",[GH,SL]=nc(xL,{forceMount:void 0}),YH=qn(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=rc(xL,t);return kn(GH,{scope:t,forceMount:n,children:kn(Uo,{present:n||a.open,children:kn(hu,{asChild:!0,container:o,children:r})})})},"MenuPortal"),wi="MenuContent",[KH,cv]=nc(wi),$H=Wt.forwardRef(qn(function(t,n){let r=SL(wi,t.__scopeMenu),{forceMount:o=r.forceMount,...a}=t,i=rc(wi,t.__scopeMenu),s=Kf(wi,t.__scopeMenu);return kn(Gf.Provider,{scope:t.__scopeMenu,children:kn(Uo,{present:o||i.open,children:kn(Gf.Slot,{scope:t.__scopeMenu,children:s.modal?kn(XH,{...a,ref:n}):kn(ZH,{...a,ref:n})})})})},"MenuContent")),XH=Wt.forwardRef(qn(function(t,n){let r=rc(wi,t.__scopeMenu),o=Wt.useRef(null),a=Kt(n,o);return Wt.useEffect(()=>{let i=o.current;if(i)return ph(i)},[]),kn(uv,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:lt(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),ZH=Wt.forwardRef(qn(function(t,n){let r=rc(wi,t.__scopeMenu);return kn(uv,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),QH=$o("MenuContent.ScrollLock"),uv=Wt.forwardRef(qn(function(t,n){let{__scopeMenu:r,loop:o=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:f,onDismiss:h,disableOutsideScroll:p,...g}=t,y=rc(wi,r),v=Kf(wi,r),b=lv(r),S=vL(r),C=VH(r),[w,k]=Wt.useState(null),M=Wt.useRef(null),I=Kt(n,M,y.onContentChange),x=Wt.useRef(0),T=Wt.useRef(""),R=Wt.useRef(0),P=Wt.useRef(null),D=Wt.useRef("right"),N=Wt.useRef(0),O=p?zf:Wt.Fragment,A=p?{as:QH,allowPinchZoom:!0}:void 0,B=qn(L=>{let z=T.current+L,Y=C().filter(K=>!K.disabled),G=document.activeElement,H=Y.find(K=>K.ref.current===G)?.textValue,W=Y.map(K=>K.textValue),U=RL(W,z,H),V=Y.find(K=>K.textValue===U)?.ref.current;qn((function K(Z){T.current=Z,window.clearTimeout(x.current),Z!==""&&(x.current=window.setTimeout(()=>K(""),1e3))}),"updateSearch")(z),V&&setTimeout(()=>V.focus())},"handleTypeaheadSearch");Wt.useEffect(()=>()=>window.clearTimeout(x.current),[]),fu();let E=Wt.useCallback(L=>D.current===P.current?.side&&DL(L,P.current?.area),[]);return kn(KH,{scope:r,searchRef:T,onItemEnter:Wt.useCallback(L=>{E(L)&&L.preventDefault()},[E]),onItemLeave:Wt.useCallback(L=>{E(L)||(M.current?.focus(),k(null))},[E]),onTriggerLeave:Wt.useCallback(L=>{E(L)&&L.preventDefault()},[E]),pointerGraceTimerRef:R,onPointerGraceIntentChange:Wt.useCallback(L=>{P.current=L},[]),children:kn(O,{...A,children:kn(Zp,{asChild:!0,trapped:a,onMountAutoFocus:lt(i,L=>{L.preventDefault(),M.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:kn(Js,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:f,onDismiss:h,children:kn(hL,{asChild:!0,...S,dir:v.dir,orientation:"vertical",loop:o,currentTabStopId:w,onCurrentTabStopIdChange:k,onEntryFocus:lt(c,L=>{v.isUsingKeyboardRef.current||L.preventDefault()}),preventScrollOnEntryFocus:!0,children:kn(rl,{role:"menu","aria-orientation":"vertical","data-state":fv(y.open),"data-radix-menu-content":"",dir:v.dir,...b,...g,ref:I,style:{outline:"none",...g.style},onKeyDown:lt(g.onKeyDown,L=>{let Y=L.target.closest("[data-radix-menu-content]")===L.currentTarget,G=L.ctrlKey||L.altKey||L.metaKey,H=L.key.length===1;Y&&(L.key==="Tab"&&L.preventDefault(),!G&&H&&B(L.key));let W=M.current;if(L.target!==W||!FH.includes(L.key))return;L.preventDefault();let V=C().filter(K=>!K.disabled).map(K=>K.ref.current);yL.includes(L.key)&&V.reverse(),ML(V)}),onBlur:lt(t.onBlur,L=>{L.currentTarget.contains(L.target)||(window.clearTimeout(x.current),T.current="")}),onPointerMove:lt(t.onPointerMove,ku(L=>{let z=L.target,Y=N.current!==L.clientX;if(L.currentTarget.contains(z)&&Y){let G=L.clientX>N.current?"right":"left";D.current=G,N.current=L.clientX}}))})})})})})})},"MenuContentImpl"));var JH=Wt.forwardRef(qn(function(t,n){let{__scopeMenu:r,...o}=t;return kn(dn.div,{...o,ref:n})},"MenuLabel")),iv="MenuItem",bL="menu.itemSelect",dv=Wt.forwardRef(qn(function(t,n){let{disabled:r=!1,onSelect:o,...a}=t,i=Wt.useRef(null),s=Kf(iv,t.__scopeMenu),l=cv(iv,t.__scopeMenu),c=Kt(n,i),u=Wt.useRef(!1),d=qn(()=>{let m=i.current;if(!r&&m){let f=new CustomEvent(bL,{bubbles:!0,cancelable:!0});m.addEventListener(bL,h=>o?.(h),{once:!0}),Tf(m,f),f.defaultPrevented?u.current=!1:s.onClose()}},"handleSelect");return kn(CL,{...a,ref:c,disabled:r,onClick:lt(t.onClick,d),onPointerDown:m=>{t.onPointerDown?.(m),u.current=!0},onPointerUp:lt(t.onPointerUp,m=>{u.current||m.currentTarget?.click()}),onKeyDown:lt(t.onKeyDown,m=>{r||m.target!==m.currentTarget||l.searchRef.current!==""&&m.key===" "||av.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})},"MenuItem")),CL=Wt.forwardRef(qn(function(t,n){let{__scopeMenu:r,disabled:o=!1,textValue:a,...i}=t,s=cv(iv,r),l=vL(r),c=Wt.useRef(null),u=Kt(n,c),[d,m]=Wt.useState(!1),[f,h]=Wt.useState("");return Wt.useEffect(()=>{let p=c.current;p&&h((p.textContent??"").trim())},[i.children]),kn(Gf.ItemSlot,{scope:r,disabled:o,textValue:a??f,children:kn(gL,{asChild:!0,...l,focusable:!o,children:kn(dn.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...i,ref:u,onPointerMove:lt(t.onPointerMove,ku(p=>{o?s.onItemLeave(p):(s.onItemEnter(p),p.defaultPrevented||p.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:lt(t.onPointerLeave,ku(p=>s.onItemLeave(p))),onFocus:lt(t.onFocus,()=>m(!0)),onBlur:lt(t.onBlur,()=>m(!1))})})})},"MenuItemImpl")),e6=Wt.forwardRef(qn(function(t,n){let{checked:r=!1,onCheckedChange:o,...a}=t;return kn(TL,{scope:t.__scopeMenu,checked:r,children:kn(dv,{role:"menuitemcheckbox","aria-checked":Yf(r)?"mixed":r,...a,ref:n,"data-state":Nh(r),onSelect:lt(a.onSelect,()=>o?.(Yf(r)?!0:!r),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),t6="MenuRadioGroup",[xne,n6]=nc(t6,{value:void 0,onValueChange:qn(()=>{},"onValueChange")});var r6="MenuRadioItem",o6=Wt.forwardRef(qn(function(t,n){let{value:r,...o}=t,a=n6(r6,t.__scopeMenu),i=r===a.value;return kn(TL,{scope:t.__scopeMenu,checked:i,children:kn(dv,{role:"menuitemradio","aria-checked":i,...o,ref:n,"data-state":Nh(i),onSelect:lt(o.onSelect,()=>a.onValueChange?.(r),{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),kL="MenuItemIndicator",[TL,a6]=nc(kL,{checked:!1}),i6=Wt.forwardRef(qn(function(t,n){let{__scopeMenu:r,forceMount:o,...a}=t,i=a6(kL,r);return kn(Uo,{present:o||Yf(i.checked)||i.checked===!0,children:kn(dn.span,{...a,ref:n,"data-state":Nh(i.checked)})})},"MenuItemIndicator")),s6=Wt.forwardRef(qn(function(t,n){let{__scopeMenu:r,...o}=t;return kn(dn.div,{role:"separator","aria-orientation":"horizontal",...o,ref:n})},"MenuSeparator"));var l6="MenuSub",[Sne,IL]=nc(l6);var Ah="MenuSubTrigger",c6=Wt.forwardRef(qn(function(t,n){let r=rc(Ah,t.__scopeMenu),o=Kf(Ah,t.__scopeMenu),a=IL(Ah,t.__scopeMenu),i=cv(Ah,t.__scopeMenu),s=Wt.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=i,u={__scopeMenu:t.__scopeMenu},d=Wt.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);Wt.useEffect(()=>d,[d]),Wt.useEffect(()=>{let f=l.current;return()=>{window.clearTimeout(f),c(null)}},[l,c]);let m=Kt(n,a.onTriggerChange);return kn(wL,{asChild:!0,...u,children:kn(CL,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?a.contentId:void 0,"data-state":fv(r.open),...t,ref:m,onClick:f=>{t.onClick?.(f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:lt(t.onPointerMove,ku(f=>{i.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!r.open&&!s.current&&(i.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{r.onOpenChange(!0),d()},100))})),onPointerLeave:lt(t.onPointerLeave,ku(f=>{d();let h=r.content?.getBoundingClientRect();if(h){let p=r.content?.dataset.side,g=p==="right",y=g?-5:5,v=h[g?"left":"right"],b=h[g?"right":"left"];i.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:v,y:h.top},{x:b,y:h.top},{x:b,y:h.bottom},{x:v,y:h.bottom}],side:p}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(f),f.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:lt(t.onKeyDown,f=>{t.disabled||f.target!==f.currentTarget||i.searchRef.current!==""&&f.key===" "||zH[o.dir].includes(f.key)&&(r.onOpenChange(!0),r.content?.focus(),f.preventDefault())})})})},"MenuSubTrigger")),u6="MenuSubContent",d6=Wt.forwardRef(qn(function(t,n){let r=SL(wi,t.__scopeMenu),{forceMount:o=r.forceMount,align:a="start",...i}=t,s=rc(wi,t.__scopeMenu),l=Kf(wi,t.__scopeMenu),c=IL(u6,t.__scopeMenu),u=Wt.useRef(null),d=Kt(n,u);return kn(Gf.Provider,{scope:t.__scopeMenu,children:kn(Uo,{present:o||s.open,children:kn(Gf.Slot,{scope:t.__scopeMenu,children:kn(uv,{id:c.contentId,"aria-labelledby":c.triggerId,...i,ref:d,align:a,side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{l.isUsingKeyboardRef.current&&u.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:lt(t.onFocusOutside,m=>{m.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:lt(t.onEscapeKeyDown,m=>{l.onClose(),m.preventDefault()}),onKeyDown:lt(t.onKeyDown,m=>{let f=m.currentTarget.contains(m.target),h=HH[l.dir].includes(m.key);f&&h&&(s.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})},"MenuSubContent"));function fv(e){return e?"open":"closed"}qn(fv,"getOpenState");function Yf(e){return e==="indeterminate"}qn(Yf,"isIndeterminate");function Nh(e){return Yf(e)?"indeterminate":e?"checked":"unchecked"}qn(Nh,"getCheckedState");function ML(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}qn(ML,"focusFirst");function LL(e,t){return e.map((n,r)=>e[(t+r)%e.length])}qn(LL,"wrapArray");function RL(e,t,n){let o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,a=n?e.indexOf(n):-1,i=LL(e,Math.max(a,0));o.length===1&&(i=i.filter(c=>c!==n));let l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}qn(RL,"getNextMatch");function PL(e,t){let{x:n,y:r}=e,o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){let s=t[a],l=t[i],c=s.x,u=s.y,d=l.x,m=l.y;u>r!=m>r&&n<(d-c)*(r-u)/(m-u)+c&&(o=!o)}return o}qn(PL,"isPointInPolygon");function DL(e,t){if(!t)return!1;let n={x:e.clientX,y:e.clientY};return PL(n,t)}qn(DL,"isPointerInGraceArea");function ku(e){return t=>t.pointerType==="mouse"?e(t):void 0}qn(ku,"whenMouse");var AL=jH,BL=wL,NL=YH,EL=$H;var OL=JH,_L=dv,FL=e6;var zL=o6,HL=i6,VL=s6;var WL=c6,qL=d6;import{jsx as Jo}from"react/jsx-runtime";var m6=Object.defineProperty,Fa=(e,t)=>m6(e,"name",{value:t,configurable:!0}),mv="DropdownMenu",[p6,Ene]=xr(mv,[sv]),za=sv(),[h6,UL]=p6(mv),g6=Fa(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:i,modal:s=!0}=e,l=za(t),c=Ro.useRef(null),[u,d]=go({prop:o,defaultProp:a??!1,onChange:i,caller:mv});return Jo(h6,{scope:t,triggerId:Oi(),triggerRef:c,contentId:Oi(),open:u,onOpenChange:d,onOpenToggle:Ro.useCallback(()=>d(m=>!m),[d]),modal:s,children:Jo(AL,{...l,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},"DropdownMenu"),b6="DropdownMenuTrigger",y6=Ro.forwardRef(Fa(function(t,n){let{__scopeDropdownMenu:r,disabled:o=!1,...a}=t,i=UL(b6,r),s=za(r),l=Kt(n,i.triggerRef);return Jo(BL,{asChild:!0,...s,children:Jo(dn.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":o?"":void 0,disabled:o,...a,ref:l,onPointerDown:lt(t.onPointerDown,c=>{!o&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:lt(t.onKeyDown,c=>{o||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})},"DropdownMenuTrigger")),v6=Fa(e=>{let{__scopeDropdownMenu:t,...n}=e,r=za(t);return Jo(NL,{...r,...n})},"DropdownMenuPortal"),w6="DropdownMenuContent",x6=Ro.forwardRef(Fa(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=UL(w6,r),i=za(r),s=Ro.useRef(!1);return Jo(EL,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...o,ref:n,onCloseAutoFocus:lt(t.onCloseAutoFocus,l=>{s.current||a.triggerRef.current?.focus(),s.current=!1,l.preventDefault()}),onInteractOutside:lt(t.onInteractOutside,l=>{let c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!a.modal||d)&&(s.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent"));var S6=Ro.forwardRef(Fa(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=za(r);return Jo(OL,{...a,...o,ref:n})},"DropdownMenuLabel")),C6=Ro.forwardRef(Fa(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=za(r);return Jo(_L,{...a,...o,ref:n})},"DropdownMenuItem")),k6=Ro.forwardRef(Fa(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=za(r);return Jo(FL,{...a,...o,ref:n})},"DropdownMenuCheckboxItem"));var T6=Ro.forwardRef(Fa(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=za(r);return Jo(zL,{...a,...o,ref:n})},"DropdownMenuRadioItem")),I6=Ro.forwardRef(Fa(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=za(r);return Jo(HL,{...a,...o,ref:n})},"DropdownMenuItemIndicator")),M6=Ro.forwardRef(Fa(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=za(r);return Jo(VL,{...a,...o,ref:n})},"DropdownMenuSeparator"));var L6=Ro.forwardRef(Fa(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=za(r);return Jo(WL,{...a,...o,ref:n})},"DropdownMenuSubTrigger")),R6=Ro.forwardRef(Fa(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=za(r);return Jo(qL,{...a,...o,ref:n,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuSubContent")),jL=g6,GL=y6,YL=v6,pv=x6;var hv=S6,gv=C6,bv=k6;var yv=T6,vv=I6,wv=M6;var xv=L6,Sv=R6;import{jsx as ea,jsxs as Cv}from"react/jsx-runtime";var Ha=jL,Va=GL;var D6=ss.forwardRef(({className:e,inset:t,children:n,...r},o)=>Cv(xv,{ref:o,className:ee("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,ea(Zi,{className:"ml-auto"})]}));D6.displayName=xv.displayName;var A6=ss.forwardRef(({className:e,...t},n)=>ea(Sv,{ref:n,className:ee("depth-root z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));A6.displayName=Sv.displayName;var va=ss.forwardRef(({className:e,sideOffset:t=4,...n},r)=>ea(YL,{children:ea(pv,{ref:r,sideOffset:t,className:ee("depth-root z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));va.displayName=pv.displayName;var ta=ss.forwardRef(({className:e,inset:t,...n},r)=>ea(gv,{ref:r,className:ee("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));ta.displayName=gv.displayName;var B6=ss.forwardRef(({className:e,children:t,checked:n,...r},o)=>Cv(bv,{ref:o,className:ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[ea("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:ea(vv,{children:ea(Or,{className:"h-4 w-4"})})}),t]}));B6.displayName=bv.displayName;var N6=ss.forwardRef(({className:e,children:t,...n},r)=>Cv(yv,{ref:r,className:ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[!e?.includes("hideradio")&&ea("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:ea(vv,{children:ea(Pl,{className:"h-2 w-2 fill-current"})})}),t]}));N6.displayName=yv.displayName;var E6=ss.forwardRef(({className:e,inset:t,...n},r)=>ea(hv,{ref:r,className:ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));E6.displayName=hv.displayName;var O6=ss.forwardRef(({className:e,...t},n)=>ea(wv,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));O6.displayName=wv.displayName;var _6=({className:e,...t})=>ea("span",{className:ee("ml-auto text-xs tracking-widest opacity-60",e),...t});_6.displayName="DropdownMenuShortcut";import{Fragment as Fh,jsx as j,jsxs as Ge}from"react/jsx-runtime";var fr=(e,t="Color",n)=>({type:"color",key:e,label:t,...n?{disabledWhenFalse:n}:{}}),Wa=(e,t="Line width")=>({type:"lineWidth",key:e,label:t}),wa=(e,t="Line style")=>({type:"dash",key:e,label:t});var Eh=(e,t)=>({type:"fontSize",key:e,label:t}),Oh=(e,t,n,r,o,a,i,s,l,c)=>({type:"slider",key:e,label:t,max:n,min:r,step:o,step1:a,step2:i,step3:s,prefix:l,suffix:c}),Tu=(e,t,n="Extend")=>({type:"extend",leftKey:e,rightKey:t,label:n}),Po=(e,t)=>({type:"toggle",key:e,label:t}),$L=(e,t,n)=>({type:"numberInput",key:e,label:t,...n});var XL=(e,t,n)=>({type:"buttonGroup",key:e,label:t,options:n});var ZL=(e,t,n,r,o)=>({type:"dualColor",keyA:e,labelA:t,keyB:n,labelB:r,label:o});var QL=(e,t,n,r,o)=>({type:"toggledInput",toggleKey:e,toggleLabel:t,inputKey:n,inputLabel:r,...o});var _h=(e,t,n)=>({type:"toggledColor",toggleKey:e,colorKey:t,label:n});function z6(e,t){let n=(String(t).split(".")[1]??"").length;return n===0?Math.round(e):Number(e.toFixed(n))}function zh(e,t){let n=e;return n.key??n.keyA??n.keyStart??n.colorKey??n.toggleKey??n.leftKey??n.startKey??`${e.type}-${t}`}var H6={hline:[fr("color"),Wa("lineWidth"),wa("dash")],vline:[fr("color"),Wa("lineWidth"),wa("dash")],"extended-line":[fr("color"),Wa("lineWidth"),wa("dash"),Tu("extendLeft","extendRight")],line:[fr("color"),Wa("lineWidth"),wa("dash"),Tu("extendLeft","extendRight")],"cross-line":[fr("color"),Wa("lineWidth"),wa("dash")],"info-line":[fr("color"),Wa("lineWidth"),wa("dash")],"trend-angle":[fr("color"),Wa("lineWidth"),wa("dash")],ray:[fr("color"),Wa("lineWidth"),wa("dash")],hray:[fr("color"),Wa("lineWidth"),wa("dash")],"parallel-channel":[{type:"channelLevels",label:"Levels"},Tu("extendLeft","extendRight"),_h("enableBackground","backgroundColor","Background")],rect:[fr("borderColor","Border color"),Wa("borderLineWidth","Border width"),wa("borderDash","Border style"),fr("fillColor","Fill color")],triangle:[fr("borderColor","Border color"),Wa("borderLineWidth","Border width"),wa("borderDash","Border style"),fr("fillColor","Fill color")],fib:[Wa("lineWidth"),wa("dash"),Tu("extendLeft","extendRight"),Po("showLevels","Show Level Values"),Po("showPrices","Show Prices"),Eh("labelFontSize","Label font size"),XL("labelAlign","Label position",[{value:"left",label:"Left"},{value:"right",label:"Right"}]),Po("labelBold","Bold labels"),{type:"customLevels",label:"Levels"},_h("enableBackground","backgroundColor","Background")],text:[fr("color"),Eh("fontSize","Font size"),Po("screenAnchored","Pin to screen")],fvp:[XL("profileMode","Profile Mode",[{value:"stacked",label:"Stacked"},{value:"split",label:"Split"},{value:"delta",label:"Delta"},{value:"total",label:"Total"}]),Oh("barsWidth","Bar Width",100,0,1,"0%","50%","100%","","%"),Oh("barOpacity","Bar Opacity",100,0,1,"0%","50%","100%","","%"),ZL("buyColor","Buy","sellColor","Sell","Buy / Sell Colors"),ZL("totalColor","Positive","deltaNegColor","Negative","Total / Delta Colors"),Po("barGap","Bar row gap"),Po("splitCenterLine","Split center axis"),Po("showVolNumbers","Show Volume Numbers"),Oh("volNumbersFontSize","Numbers Size",16,7,1,"7","11","16","","px"),fr("pocColor","POC Color"),Po("showPoc","Show POC Line"),Po("showPocLabel","Show POC Label"),QL("highlightPocBar","Highlight POC Bar","pocBarLineWidth","Accent line width",{min:1,max:4,step:1,unit:"px"}),Tu("pocExtendLeft","pocExtendRight","Extend POC"),Po("showValueArea","Show Value Area"),Oh("valueAreaPct","Value Area %",100,0,1,"0%","70%","100%","","%"),fr("valueAreaFillColor","VA Fill"),QL("vaBarDimming","Dim bars outside VA","vaOutsideDimFrac","Outside opacity",{min:0,max:1,step:.05,unit:"x"}),Po("showVaHLines","Show VAH / VAL Lines"),fr("vaLineColor","VAH/VAL Color"),Tu("vaLineExtendLeft","vaLineExtendRight","Extend VA Lines"),Po("labelPills","Label pill backgrounds"),Po("showDevPoc","Developing POC"),fr("devPocColor","Dev POC Color"),Po("showDevVa","Developing VA"),fr("devVaColor","Dev VA Color"),_h("enableBg","bgColor","Background"),_h("enableBorder","borderColor","Border"),wa("borderDash","Border Style")],long:[fr("upColor","Target Color"),fr("downColor","Stop Color"),fr("entryColor","Entry Color"),$L("qty","Quantity",{min:0,step:1}),Po("drawInfo","Show Info"),Eh("fontSize","Text Size"),fr("textColor","Text Color")],short:[fr("downColor","Target Color"),fr("upColor","Stop Color"),fr("entryColor","Entry Color"),$L("qty","Quantity",{min:0,step:1}),Po("drawInfo","Show Info"),Eh("fontSize","Text Size"),fr("textColor","Text Color")]},Mv=480,Iu=12,V6=["#e0e0e0","#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#a855f7","#ec4899","#00e676","#ff1744","#facc15","#38bdf8","#84cc16","#f43f5e","#06b6d4","#8b5cf6"],$f=[{label:"Solid",value:"solid",dash:[]},{label:"Dashed",value:"dashed",dash:[6,3]},{label:"Dotted",value:"dotted",dash:[2,3]},{label:"Dash-dot",value:"dashdot",dash:[8,3,2,3]}],JL={cursor:"Cursor",hline:"Horizontal Line",vline:"Vertical Line","extended-line":"Extended Line",line:"Line Segment","cross-line":"Cross Line","info-line":"Info Line","trend-angle":"Trend Angle",ray:"Ray",hray:"Horizontal Ray","parallel-channel":"Parallel Channel",rect:"Rectangle",triangle:"Triangle",fib:"Fibonacci",text:"Text Label",fvp:"Fixed Volume Profile",long:"Long Position",short:"Short Position","flat-channel":"flat-channel","disjoint-channel":"disjoint-channel","regression-trend":"regression-trend",pitchfork:"pitchfork","schiff-pitchfork":"schiff-pitchfork","modified-schiff-pitchfork":"modified-schiff-pitchfork","inside-pitchfork":"inside-pitchfork","fib-extension":"fib-extension","fib-trend-extension":"fib-trend-extension","fib-channel":"fib-channel","fib-time-zone":"fib-time-zone","fib-speed-fan":"fib-speed-fan","fib-circles":"fib-circles","fib-spiral":"fib-spiral","fib-wedge":"fib-wedge","gann-box":"gann-box","gann-square":"gann-square","gann-fan":"gann-fan",xabcd:"xabcd",cypher:"cypher",abcd:"abcd","three-drives":"three-drives","head-shoulders":"head-shoulders","triangle-pattern":"triangle-pattern","elliott-impulse":"elliott-impulse","elliott-correction":"elliott-correction","elliott-triangle":"elliott-triangle","elliott-double-combo":"elliott-double-combo","elliott-triple-combo":"elliott-triple-combo","rotated-rect":"rotated-rect",ellipse:"ellipse",circle:"circle",polygon:"polygon",arc:"arc",curve:"curve","double-curve":"double-curve",polyline:"polyline",path:"path","anchored-text":"anchored-text",note:"note",callout:"callout",comment:"comment","price-label":"price-label",signpost:"signpost",flag:"flag",pin:"pin",table:"table",arrow:"arrow","arrow-marker":"arrow-marker","arrow-up":"arrow-up","arrow-down":"arrow-down",brush:"brush",highlighter:"highlighter",forecast:"forecast",projection:"projection","bars-pattern":"bars-pattern","ghost-feed":"ghost-feed","price-range":"price-range","date-range":"date-range","date-price-range":"date-price-range","anchored-volume-profile":"anchored-volume-profile","fixed-range-volume":"fixed-range-volume","anchored-vwap":"anchored-vwap",ruler:"ruler"},kv=null;function W6(){return{x:Math.round((window.innerWidth-Mv)/2),y:Math.round(window.innerHeight*.1)}}function eR(e,t){let n=window.innerHeight-t-Iu;return Math.min(Math.max(Iu,e),Math.max(Iu,n))}function q6(e){return Math.max(Iu,Math.min(window.innerWidth-Mv-Iu,e))}function Tv(e){let t=Number(e/1000000n);if(!isFinite(t)||t<=0)return e.toString();try{return new Date(t).toISOString().replace("T"," ").slice(0,23)}catch{return e.toString()}}function U6(e){let t=e.trim(),n=t.includes("Z")||t.includes("+")?t:t.replace(" ","T")+"Z",r=Date.parse(n);if(!isNaN(r))return BigInt(r)*1000000n;try{return BigInt(t)}catch{return null}}function nR({drawing:e,onUpdate:t,onClose:n,onMouseEnter:r,onMouseLeave:o}){let[a,i]=xi("style"),s=oc(null),l=oc([]),[c,u]=xi(()=>Oc().filter(Q=>Q.tool===e.tool)),[d,m]=xi(""),[f,h]=xi(!1),p=oc(null),g=oc(kv??(typeof window<"u"?W6():{x:80,y:80})),[,y]=xi(0);F6(()=>{let Q=p.current;if(!Q)return;let Pe=eR(g.current.y,Q.offsetHeight);Pe!==g.current.y&&(g.current={...g.current,y:Pe},kv=g.current,y(_=>_+1))});let v=KL(Q=>{if(Q.target.closest("button"))return;Q.preventDefault(),Q.stopPropagation();let Pe=Q.clientX,_=Q.clientY,ie=g.current.x,se=g.current.y,Se=ye=>{let $e=p.current?.offsetHeight??0;g.current={x:q6(ie+ye.clientX-Pe),y:eR(se+ye.clientY-_,$e)},kv=g.current,y(Ue=>Ue+1)},Re=()=>{window.removeEventListener("mousemove",Se),window.removeEventListener("mouseup",Re)};window.addEventListener("mousemove",Se),window.addEventListener("mouseup",Re)},[]),b=KL(()=>{o?.(),n()},[n,o]);Wh(()=>{let Q=Pe=>{Pe.key==="Escape"&&b()};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[b]);let S=()=>{h(!0),setTimeout(()=>h(!1),1200)},C=e,w=C.locked??!1,k=io.get(e.tool),M=k?.defaultData??{},I={...M,...C.data??{}},x=Q=>t({data:{...I,...Q}}),T=e.tool==="text",R=C.text??"",P=C.textAlign??"left",D=C.fontSize??12,N=C.bold??!1,O=C.italic??!1,A=!T&&e.tool!=="fib"&&e.tool!=="fvp"&&e.tool!=="cursor",B=C.label??"",E=C.labelColor??"#e0e0e0",L=C.labelFontSize??11,z=C.labelBold??!1,Y=C.labelItalic??!1,G=C.labelHorizontalAlign??"left",H=C.labelVerticalAlign??"top",W=C.labelTextOrientation??"horizontal",U=["line","ray","rect","fib","fvp"].includes(e.tool),V=e.tool==="text",K=()=>{if(!d.trim())return;let Q=["color","lineWidth","dash","fillOpacity","fontSize","extendLeft","extendRight","levels","labelColor","labelFontSize","labelBold","labelItalic","labelHorizontalAlign","labelVerticalAlign","labelTextOrientation","bold","italic"],Pe={};for(let _ of Q)C[_]!==void 0&&(Pe[_]=C[_]);$S({id:pn(8),name:d.trim(),tool:e.tool,style:Pe,createdAt:Date.now()}),u(Oc().filter(_=>_.tool===e.tool)),m(""),S()},Z=Q=>{XS(Q),u(Oc().filter(Pe=>Pe.tool===e.tool))},de=Q=>{t(Q.style),S()},ze=()=>t(k?{data:{...M}}:Yi(e.tool)),xe=[{id:"style",label:"Style",icon:j(Us,{size:13})},{id:"coordinates",label:"Coordinates",icon:j(Zd,{size:13})},{id:"text",label:"Text",icon:j(Fl,{size:13})},{id:"visibility",label:"Visibility",icon:j(Da,{size:13})},{id:"templates",label:"Templates",icon:j(Qc,{size:13})}],Ae=k?xe.filter(Q=>Q.id==="style"||Q.id==="visibility"):xe,Oe=Math.max(0,Ae.findIndex(Q=>Q.id===a)),ke=l.current[Oe];return Ge(Fh,{children:[j("style",{children:`
|
|
72
|
+
@keyframes dlg-in { from{opacity:0;transform:scale(0.94)} to{opacity:1;transform:scale(1)} }
|
|
73
|
+
.dlg-enter { animation: dlg-in 160ms cubic-bezier(0.16,1,0.3,1) both; transform-origin: top left; }
|
|
74
|
+
`}),Ge("div",{ref:p,className:"dlg-enter fixed z-[200] flex flex-col rounded-xl border border-white/10 bg-[#14161b]/90 backdrop-blur-lg shadow-2xl overflow-hidden",style:{left:g.current.x,top:g.current.y,width:Mv,maxHeight:`calc(100vh - ${g.current.y+Iu}px)`},onMouseDown:Q=>Q.stopPropagation(),onMouseEnter:r,onMouseLeave:o,children:[Ge("div",{className:"flex items-center gap-2 px-4 pt-4 pb-3 border-b border-white/6 shrink-0 cursor-grab active:cursor-grabbing select-none",onMouseDown:v,children:[Ge("div",{className:"flex-1 min-w-0",children:[j("h2",{className:"text-sm font-semibold text-white tracking-tight",children:JL[e.tool]??k?.name??"Drawing"}),j("p",{className:"text-[11px] text-white/40 mt-0.5",children:"Drawing settings"})]}),j("button",{className:"p-1.5 rounded-lg hover:bg-white/10 text-white/40 hover:text-white transition-colors shrink-0 cursor-pointer",onClick:b,children:j(_r,{size:14})})]}),Ge("div",{className:"flex gap-0.5 px-4 pt-2 pb-0 shrink-0 border-b border-white/6 relative",ref:s,children:[Ae.map((Q,Pe)=>Ge("button",{ref:_=>l.current[Pe]=_,onClick:()=>i(Q.id),className:ee("flex items-center gap-1.5 px-3 py-2 text-[11px] font-medium rounded-t transition-colors border-b-2 -mb-px",a===Q.id?"text-white bg-white/5":"text-white/40 border-transparent hover:text-white/70 hover:bg-white/5"),children:[Q.icon,Q.label]},Q.id)),j("div",{className:"absolute bottom-0 left-0 border-b-2 border-blue-500 transition-all duration-200",style:{width:ke?.clientWidth??0,transform:`translateX(${ke?.offsetLeft??0}px)`}})]}),Ge("div",{className:"flex-1 overflow-y-auto px-5 py-4 min-h-0",children:[a==="style"&&Ge("div",{className:"flex flex-col gap-5",children:[k?(k.settingsSchema??[]).map((Q,Pe)=>j(Hh,{field:Q,drawing:I,onUpdate:x},zh(Q,Pe))):(H6[e.tool]??[]).map((Q,Pe)=>j(Hh,{field:Q,drawing:C,onUpdate:t},zh(Q,Pe))),k&&!k.settingsSchema?.length&&Ge("div",{className:"flex flex-col items-center gap-2 py-6 text-white/25",children:[j(Us,{size:22,strokeWidth:1.2}),Ge("p",{className:"text-[11px] text-center",children:[k.name," doesn't have any settings."]})]}),(!k||!!k.settingsSchema?.length)&&Ge("button",{className:"flex items-center gap-2 text-[11px] text-white/30 hover:text-white/60 transition-colors mt-1",onClick:ze,children:[j(ga,{size:11})," Reset to defaults"]})]}),a==="coordinates"&&Ge("div",{className:"flex flex-col gap-4",children:[e.tool==="hline"&&j(Vh,{label:"Price",children:j(rR,{value:e.price,onChange:Q=>t({price:Q})})}),e.tool==="vline"&&j(Vh,{label:"Time",children:j(oR,{value:e.ts,onChange:Q=>t({ts:Q})})}),U&&Ge(Fh,{children:[j(Iv,{label:"Point A",anchor:e.a,onChange:Q=>t({a:Q})}),j(Iv,{label:"Point B",anchor:e.b,onChange:Q=>t({b:Q})})]}),V&&j(Iv,{label:"Anchor",anchor:e.anchor,onChange:Q=>t({anchor:Q})}),j("p",{className:"text-[10px] text-white/25 mt-1",children:"Timestamps are in UTC. Enter as ISO date or raw nanoseconds."})]}),a==="text"&&Ge("div",{className:"flex flex-col gap-5",children:[T&&Ge(Fh,{children:[j(bn,{label:"Content",children:j("textarea",{className:"w-full bg-white/5 border border-white/10 rounded-lg px-3 py-2 text-[12px] text-white focus:outline-none focus:border-blue-500/60 resize-none placeholder:text-white/20",rows:3,value:R,onChange:Q=>t({text:Q.target.value}),placeholder:"Enter text\u2026",onKeyDown:Q=>Q.stopPropagation()})}),j(bn,{label:"Formatting",children:Ge("div",{className:"flex gap-2",children:[Ge(al,{active:N,onClick:()=>t({bold:!N}),children:[j(Zc,{size:12}),"Bold"]}),Ge(al,{active:O,onClick:()=>t({italic:!O}),children:[j(eu,{size:12}),"Italic"]})]})}),Ge(bn,{label:`Font size - ${D}px`,children:[j(Dn,{value:[D],onValueChange:([Q])=>t({fontSize:Q}),max:48,min:8,step:1,className:"w-full accent-blue-500"}),Ge("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[j("span",{children:"8px"}),j("span",{children:"28px"}),j("span",{children:"48px"})]})]}),j(bn,{label:"Text alignment",children:j(tR,{value:P,onChange:Q=>t({textAlign:Q})})}),j(bn,{label:"Color",children:j(ls,{value:C.color??"#e0e0e0",onChange:Q=>t({color:Q})})})]}),A&&Ge(Fh,{children:[j(bn,{label:"Label text",children:j("input",{type:"text",className:"w-full bg-white/5 border border-white/10 rounded-lg px-3 py-2 text-[12px] text-white focus:outline-none focus:border-blue-500/60 placeholder:text-white/20",value:B,onChange:Q=>t({label:Q.target.value}),placeholder:"Optional label\u2026",onKeyDown:Q=>Q.stopPropagation()})}),j(bn,{label:"Formatting",children:Ge("div",{className:"flex gap-2",children:[Ge(al,{active:z,onClick:()=>t({labelBold:!z}),children:[j(Zc,{size:12}),"Bold"]}),Ge(al,{active:Y,onClick:()=>t({labelItalic:!Y}),children:[j(eu,{size:12}),"Italic"]})]})}),Ge(bn,{label:`Font size - ${L}px`,children:[j(Dn,{value:[L],onValueChange:([Q])=>{t({labelFontSize:Q})},max:48,min:8,step:1,className:"w-full accent-blue-500"}),Ge("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[j("span",{children:"8px"}),j("span",{children:"22px"}),j("span",{children:"36px"})]})]}),e.tool==="vline"&&j(bn,{label:"Text orientation",children:Ge("div",{className:"flex gap-2",children:[Ge(al,{active:W==="horizontal",onClick:()=>t({labelTextOrientation:"horizontal"}),children:[j("span",{className:"font-mono text-[11px]",children:"A"}),"Horizontal"]}),Ge(al,{active:W==="vertical",onClick:()=>t({labelTextOrientation:"vertical"}),children:[j("span",{className:"font-mono text-[11px] rotate-90 inline-block",children:"A"}),"Vertical"]})]})}),j(bn,{label:"Horizontal alignment",children:j(tR,{value:G,onChange:Q=>t({labelHorizontalAlign:Q})})}),j(bn,{label:"Vertical alignment",children:j(G6,{value:H,onChange:Q=>t({labelVerticalAlign:Q})})}),Ge(bn,{label:"Label color",children:[j(ls,{value:E,onChange:Q=>t({labelColor:Q})}),Ge("button",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-white/30 hover:text-white/60 transition-colors",onClick:()=>t({labelColor:fr}),children:[j(ga,{size:10}),"Reset to line color"]})]})]}),e.tool==="fib"&&Ge("div",{className:"flex flex-col items-center gap-2 py-6 text-white/25",children:[j(Fl,{size:22,strokeWidth:1.2}),j("p",{className:"text-[11px] text-center",children:"Fibonacci levels use their own built-in labels."})]}),e.tool==="fvp"&&Ge("div",{className:"flex flex-col items-center gap-2 py-6 text-white/25",children:[j(Fl,{size:22,strokeWidth:1.2}),j("p",{className:"text-[11px] text-center",children:"Currently text isn't supported for fixed volume profile drawings."})]})]}),a==="visibility"&&j("div",{className:"flex flex-col gap-1",children:j(K6,{icon:j(jr,{size:14}),label:"Locked",description:"Prevent accidental moves or edits",checked:w,activeColor:"text-yellow-400",onCheckedChange:Q=>t({locked:Q})})}),a==="templates"&&Ge("div",{className:"flex flex-col gap-5",children:[j(bn,{label:"Save current style as template",children:Ge("div",{className:"flex gap-2",children:[j("input",{type:"text",className:"flex-1 bg-white/5 border border-white/10 rounded-lg px-3 py-1.5 text-[12px] text-white focus:outline-none focus:border-blue-500/60 placeholder:text-white/20",value:d,onChange:Q=>m(Q.target.value),onKeyDown:Q=>{Q.stopPropagation(),Q.key==="Enter"&&K()},placeholder:"Template name\u2026"}),Ge("button",{className:ee("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-medium transition-colors",f?"bg-green-500/20 text-green-400 border border-green-500/30":"bg-blue-500/20 text-blue-400 border border-blue-500/30 hover:bg-blue-500/30"),onClick:K,children:[f?j(Or,{size:12}):j(af,{size:12}),f?"Saved!":"Save"]})]})}),j(bn,{label:`Saved templates for ${JL[e.tool]}`,children:c.length===0?Ge("div",{className:"flex flex-col items-center gap-2 py-6 text-white/25",children:[j(Qc,{size:22,strokeWidth:1.2}),j("p",{className:"text-[11px]",children:"No templates yet"})]}):j("div",{className:"flex flex-col gap-1.5",children:c.slice().sort((Q,Pe)=>Pe.createdAt-Q.createdAt).map(Q=>Ge("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-white/3 border border-white/6 group",children:[Ge("div",{className:"flex-1 min-w-0",children:[j("p",{className:"text-[12px] text-white truncate",children:Q.name}),j("p",{className:"text-[10px] text-white/30 mt-0.5",children:new Date(Q.createdAt).toLocaleDateString()})]}),j("button",{className:"px-2.5 py-1 text-[10px] rounded bg-blue-500/15 text-blue-400 hover:bg-blue-500/25 transition-colors border border-blue-500/20",onClick:()=>de(Q),children:"Apply"}),j("button",{className:"p-1 rounded text-white/20 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all",onClick:()=>Z(Q.id),children:j(ho,{size:11})})]},Q.id))})})]})]}),j("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-white/6 shrink-0 bg-white/2",children:j("button",{className:"px-4 py-1.5 rounded-lg text-[12px] font-medium text-white/60 hover:text-white hover:bg-white/10 transition-colors",onClick:b,children:"Close"})})]})]})}function Hh({field:e,drawing:t,onUpdate:n}){if(e.type==="color"){let r=t[e.key]??"#e0e0e0",o=e.disabledWhenFalse?t[e.disabledWhenFalse]===!1:!1;return j(bn,{label:e.label,children:j("div",{className:ee("transition-opacity",o&&"opacity-30 pointer-events-none"),children:j(ls,{value:r,onChange:a=>n({[e.key]:a})})})})}if(e.type==="lineWidth"){let r=t[e.key]??1;return j(bn,{label:e.label,children:j("div",{className:"flex gap-2",children:[1,2,3,4].map(o=>Ge("button",{className:ee("flex-1 flex flex-col items-center gap-2 py-2.5 rounded-lg border transition-colors",r===o?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n({[e.key]:o}),children:[j("div",{className:"rounded-full bg-current",style:{width:28,height:o}}),Ge("span",{className:"text-[10px] font-mono",children:[o,"px"]})]},o))})})}if(e.type==="dash"){let r=t[e.key]??[];return j(bn,{label:e.label,children:j("div",{className:"grid grid-cols-2 gap-2",children:$f.map(o=>{let a=JSON.stringify(r)===JSON.stringify(o.dash);return Ge("button",{className:ee("flex items-center gap-3 px-3 py-2.5 rounded-lg border transition-colors",a?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n({[e.key]:o.dash}),children:[j("svg",{width:"28",height:"8",viewBox:"0 0 28 8",children:j("line",{x1:"0",y1:"4",x2:"28",y2:"4",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:o.dash.join(" ")||void 0})}),j("span",{className:"text-[11px]",children:o.label})]},o.value)})})})}if(e.type==="opacity"){let r=t[e.key]??0;return Ge(bn,{label:`${e.label} - ${Math.round(r*100)}%`,children:[j(Dn,{value:[r],onValueChange:([o])=>n({[e.key]:o}),max:1,min:0,step:.01,className:"w-full accent-blue-500"}),Ge("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[j("span",{children:"0%"}),j("span",{children:"50%"}),j("span",{children:"100%"})]})]})}if(e.type==="fontSize"){let r=t[e.key]??12;return Ge(bn,{label:`${e.label} - ${r}px`,children:[j(Dn,{value:[r],onValueChange:([o])=>n({[e.key]:Math.round(o)}),max:48,min:8,step:1,className:"w-full accent-blue-500"}),Ge("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[j("span",{children:"8px"}),j("span",{children:"28px"}),j("span",{children:"48px"})]})]})}if(e.type==="slider"){let r=t[e.key]??12;return Ge(bn,{label:`${e.label} - ${e.prefix??""}${r}${e.suffix??""}`,children:[j(Dn,{value:[r],onValueChange:([o])=>n({[e.key]:z6(o,e.step)}),max:e.max,min:e.min,step:e.step,className:"w-full accent-blue-500"}),Ge("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[j("span",{children:e.step1}),j("span",{children:e.step2}),j("span",{children:e.step3})]})]})}if(e.type==="extend")return j(bn,{label:e.label,children:Ge("div",{className:"flex gap-2",children:[j(al,{active:t[e.leftKey]??!1,onClick:()=>n({[e.leftKey]:!t[e.leftKey]}),children:"\u2190 Extend left"}),j(al,{active:t[e.rightKey]??!1,onClick:()=>n({[e.rightKey]:!t[e.rightKey]}),children:"Extend right \u2192"})]})});if(e.type==="toggle")return j(bn,{label:"",children:j(Y6,{label:e.label,active:t[e.key]??!1,onToggle:()=>n({[e.key]:!t[e.key]})})});if(e.type==="customLevels")return j(bn,{label:e.label,children:j($6,{levels:t.levels??[],onChange:r=>n({levels:r})})});if(e.type==="channelLevels")return j(bn,{label:e.label,children:j(Z6,{levels:t.levels??Sl,fallbackColor:t.color??"#e0e0e0",onChange:r=>n({levels:r})})});if(e.type==="numberInput")return j(j6,{field:e,value:t[e.key]??e.min??0,onChange:r=>n({[e.key]:r})});if(e.type==="textInput")return j(bn,{label:e.label,children:j("input",{type:"text",className:"w-full bg-white/5 border border-white/10 rounded-lg px-3 py-2 text-[12px] text-white focus:outline-none focus:border-blue-500/60 placeholder:text-white/20",value:t[e.key]??"",placeholder:e.placeholder,maxLength:e.maxLength,onChange:r=>n({[e.key]:r.target.value}),onKeyDown:r=>r.stopPropagation()})});if(e.type==="select"){let r=t[e.key]??e.options[0]?.value??"";return j(bn,{label:e.label,children:Ge("div",{className:"relative",children:[j("select",{className:"w-full appearance-none bg-white/5 border border-white/10 rounded-lg px-3 py-2 text-[12px] text-white focus:outline-none focus:border-blue-500/60 cursor-pointer pr-8",value:r,onChange:o=>n({[e.key]:o.target.value}),children:e.options.map(o=>j("option",{value:o.value,className:"bg-[#1a1d24]",children:o.label},o.value))}),j("svg",{className:"pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 text-white/30",width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:j("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})})}if(e.type==="buttonGroup"){let r=t[e.key]??e.options[0]?.value??"";return j(bn,{label:e.label,children:j("div",{className:"flex gap-1.5 flex-wrap",children:e.options.map(o=>Ge("button",{className:ee("flex items-center gap-1.5 px-3 py-1.5 rounded-lg border text-[11px] transition-colors",r===o.value?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n({[e.key]:o.value}),children:[o.icon,o.label]},o.value))})})}if(e.type==="stepperInt"){let r=t[e.key]??e.min??1,o=e.step??1,a=e.min??-1/0,i=e.max??1/0;return j(bn,{label:e.label,children:Ge("div",{className:"flex items-center gap-2",children:[j("button",{className:"w-8 h-8 flex items-center justify-center rounded-lg border border-white/10 bg-white/5 text-white/60 hover:bg-white/10 hover:text-white transition-colors text-base leading-none disabled:opacity-30 disabled:cursor-not-allowed",onClick:()=>n({[e.key]:Math.max(a,r-o)}),disabled:r<=a,children:"\u2212"}),j("span",{className:"flex-1 text-center text-[13px] font-mono text-white tabular-nums",children:r}),j("button",{className:"w-8 h-8 flex items-center justify-center rounded-lg border border-white/10 bg-white/5 text-white/60 hover:bg-white/10 hover:text-white transition-colors text-base leading-none disabled:opacity-30 disabled:cursor-not-allowed",onClick:()=>n({[e.key]:Math.min(i,r+o)}),disabled:r>=i,children:"+"})]})})}if(e.type==="rangeWithSteps"){let r=t[e.key]??e.min;return Ge(bn,{label:`${e.label} - ${r}`,children:[j(Dn,{value:[r],onValueChange:([o])=>n({[e.key]:o}),min:e.min,max:e.max,step:(e.max-e.min)/Math.max(1,e.steps.length-1),className:"w-full"}),j("div",{className:"flex justify-between mt-1",children:e.steps.map(o=>j("button",{className:ee("text-[10px] font-mono transition-colors",r===o.value?"text-blue-400":"text-white/25 hover:text-white/50"),onClick:()=>n({[e.key]:o.value}),children:o.label},o.value))})]})}if(e.type==="dualColor")return j(bn,{label:e.label,children:Ge("div",{className:"grid grid-cols-2 gap-3",children:[Ge("div",{className:"flex flex-col gap-2",children:[j("p",{className:"text-[10px] text-white/35 font-medium",children:e.labelA}),j(ls,{value:t[e.keyA]??"#22c55e",onChange:r=>n({[e.keyA]:r})})]}),Ge("div",{className:"flex flex-col gap-2",children:[j("p",{className:"text-[10px] text-white/35 font-medium",children:e.labelB}),j(ls,{value:t[e.keyB]??"#ef4444",onChange:r=>n({[e.keyB]:r})})]})]})});if(e.type==="dualOpacity"){let r=t[e.keyA]??.5,o=t[e.keyB]??.5;return j(bn,{label:e.label,children:j("div",{className:"grid grid-cols-2 gap-4",children:[{key:e.keyA,label:e.labelA,val:r},{key:e.keyB,label:e.labelB,val:o}].map(({key:a,label:i,val:s})=>Ge("div",{className:"flex flex-col gap-2",children:[Ge("p",{className:"text-[10px] text-white/35 font-medium",children:[i," - ",Math.round(s*100),"%"]}),j(Dn,{value:[s],onValueChange:([l])=>n({[a]:l}),min:0,max:1,step:.01,className:"w-full"})]},a))})})}if(e.type==="colorGradient"){let r=t[e.keyStart]??"#3b82f6",o=t[e.keyEnd]??"#8b5cf6";return Ge(bn,{label:e.label,children:[j("div",{className:"w-full h-6 rounded-lg mb-3 border border-white/10",style:{background:`linear-gradient(to right, ${r}, ${o})`}}),Ge("div",{className:"grid grid-cols-2 gap-3",children:[Ge("div",{className:"flex flex-col gap-2",children:[j("p",{className:"text-[10px] text-white/35 font-medium",children:"Start"}),j(ls,{value:r,onChange:a=>n({[e.keyStart]:a})})]}),Ge("div",{className:"flex flex-col gap-2",children:[j("p",{className:"text-[10px] text-white/35 font-medium",children:"End"}),j(ls,{value:o,onChange:a=>n({[e.keyEnd]:a})})]})]})]})}if(e.type==="marginInput"){let r=e.unit??"px",o=[{side:"top",label:"T"},{side:"right",label:"R"},{side:"bottom",label:"B"},{side:"left",label:"L"}];return j(bn,{label:e.label,children:j("div",{className:"grid grid-cols-4 gap-1.5",children:o.map(({side:a,label:i})=>{let s=e.keys[a],l=t[s]??0;return Ge("div",{className:"flex flex-col items-center gap-1",children:[j("span",{className:"text-[9px] text-white/30 font-semibold uppercase tracking-widest",children:i}),j("input",{type:"number",className:"w-full bg-white/5 border border-white/10 rounded-md px-1.5 py-1 text-[11px] font-mono text-white text-center focus:outline-none focus:border-blue-500/60",value:l,onChange:c=>n({[s]:parseFloat(c.target.value)||0}),onKeyDown:c=>c.stopPropagation()}),j("span",{className:"text-[9px] text-white/20",children:r})]},a)})})})}if(e.type==="anchorAlign"){let r=t[e.key]??"top-left",o=["top-left","top-center","top-right","middle-left","middle-center","middle-right","bottom-left","bottom-center","bottom-right"];return Ge(bn,{label:e.label,children:[j("div",{className:"grid grid-cols-3 gap-1 w-24",children:o.map(a=>j("button",{title:a,className:ee("w-7 h-7 rounded flex items-center justify-center border transition-colors",r===a?"border-blue-500/60 bg-blue-500/20":"border-white/8 bg-white/3 hover:border-white/25 hover:bg-white/8"),onClick:()=>n({[e.key]:a}),children:j("div",{className:ee("w-2 h-2 rounded-full transition-colors",r===a?"bg-blue-400":"bg-white/25")})},a))}),j("p",{className:"text-[10px] text-white/30 mt-1 font-mono",children:r})]})}if(e.type==="capStyle"){let r=t[e.key]??"butt",o=[{val:"butt",label:"Butt"},{val:"round",label:"Round"},{val:"square",label:"Square"}];return j(bn,{label:e.label,children:j("div",{className:"flex gap-2",children:o.map(({val:a,label:i})=>Ge("button",{className:ee("flex-1 flex flex-col items-center gap-2 py-2.5 rounded-lg border transition-colors",r===a?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n({[e.key]:a}),children:[j("svg",{width:"28",height:"12",viewBox:"0 0 28 12",children:j("line",{x1:a==="square"||a==="round"?6:4,y1:"6",x2:"22",y2:"6",stroke:"currentColor",strokeWidth:"4",strokeLinecap:a})}),j("span",{className:"text-[10px]",children:i})]},a))})})}if(e.type==="joinStyle"){let r=t[e.key]??"miter",o=[{val:"miter",label:"Miter"},{val:"round",label:"Round"},{val:"bevel",label:"Bevel"}],a="M4,20 L14,4 L24,20";return j(bn,{label:e.label,children:j("div",{className:"flex gap-2",children:o.map(({val:i,label:s})=>Ge("button",{className:ee("flex-1 flex flex-col items-center gap-2 py-2.5 rounded-lg border transition-colors",r===i?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n({[e.key]:i}),children:[j("svg",{width:"28",height:"24",viewBox:"0 0 28 24",fill:"none",children:j("path",{d:a,stroke:"currentColor",strokeWidth:"3",fill:"none",strokeLinejoin:i,strokeLinecap:"round"})}),j("span",{className:"text-[10px]",children:s})]},i))})})}if(e.type==="arrowHead"){let r=t[e.startKey]??"none",o=t[e.endKey]??"open",a=[{val:"none",label:"None"},{val:"open",label:"Open"},{val:"filled",label:"Filled"}],i=({style:s})=>Ge("svg",{width:"32",height:"12",viewBox:"0 0 32 12",fill:"none",children:[j("line",{x1:"2",y1:"6",x2:"24",y2:"6",stroke:"currentColor",strokeWidth:"1.5"}),s==="open"&&j("path",{d:"M18,2 L26,6 L18,10",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),s==="filled"&&j("path",{d:"M18,2 L26,6 L18,10 Z",fill:"currentColor"})]});return j(bn,{label:e.label,children:j("div",{className:"grid grid-cols-2 gap-3",children:[{key:e.startKey,label:"Start",val:r},{key:e.endKey,label:"End",val:o}].map(({key:s,label:l,val:c})=>Ge("div",{className:"flex flex-col gap-1.5",children:[j("p",{className:"text-[10px] text-white/35 font-medium",children:l}),j("div",{className:"flex flex-col gap-1",children:a.map(u=>Ge("button",{className:ee("flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg border text-[11px] transition-colors",c===u.val?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n({[s]:u.val}),children:[j(i,{style:u.val}),u.label]},u.val))})]},s))})})}if(e.type==="checkbox"){let r=t[e.key]??!1;return Ge("button",{className:ee("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg border text-left transition-colors",r?"border-blue-500/30 bg-blue-500/8 text-white":"border-white/6 bg-white/3 text-white/50 hover:border-white/12 hover:bg-white/5 hover:text-white/70"),onClick:()=>n({[e.key]:!r}),children:[j("div",{className:ee("w-4 h-4 rounded border-[1.5px] flex items-center justify-center shrink-0 transition-colors",r?"border-blue-500 bg-blue-500":"border-white/20 bg-transparent"),children:r&&j(Or,{size:10,strokeWidth:3,className:"text-white"})}),Ge("div",{className:"flex flex-col gap-0.5 min-w-0",children:[j("span",{className:"text-[12px] leading-none",children:e.label}),e.description&&j("span",{className:"text-[10px] text-white/30 leading-none",children:e.description})]})]})}if(e.type==="toggledInput"){let r=t[e.toggleKey]??!1,o=t[e.inputKey]??e.min??0;return j(bn,{label:"",children:Ge("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg border border-white/6 bg-white/3",children:[j(Qr,{checked:r,onCheckedChange:a=>n({[e.toggleKey]:a}),className:"data-[state=checked]:bg-blue-500"}),j("span",{className:ee("text-[12px] flex-1",r?"text-white":"text-white/40 select-none"),children:e.toggleLabel}),Ge("div",{className:ee("flex items-center gap-1.5 transition-opacity",!r&&"opacity-30 pointer-events-none"),children:[j("input",{type:"number",className:"w-16 bg-white/5 border border-white/10 rounded-md px-2 py-1 text-[12px] font-mono text-white text-right focus:outline-none focus:border-blue-500/60",value:o,min:e.min,max:e.max,step:e.step??1,onChange:a=>n({[e.inputKey]:parseFloat(a.target.value)||0}),onKeyDown:a=>a.stopPropagation(),tabIndex:r?0:-1}),e.unit&&j("span",{className:"text-[11px] text-white/35",children:e.unit})]})]})})}if(e.type==="colorWithOpacity"){let r=t[e.colorKey]??"#e0e0e0",o=t[e.opacityKey]??1;return j(bn,{label:e.label,children:Ge("div",{className:"flex gap-3 items-start",children:[j("div",{className:"flex-1 min-w-0",children:j(ls,{value:r,onChange:a=>n({[e.colorKey]:a})})}),Ge("div",{className:"flex flex-col gap-1 w-28 shrink-0 pt-0.5",children:[Ge("p",{className:"text-[10px] text-white/35 font-medium",children:["Opacity - ",Math.round(o*100),"%"]}),j(Dn,{value:[o],onValueChange:([a])=>n({[e.opacityKey]:a}),min:0,max:1,step:.01}),Ge("div",{className:"flex justify-between text-[9px] text-white/25 font-mono",children:[j("span",{children:"0%"}),j("span",{children:"100%"})]})]})]})})}if(e.type==="toggledColor"){let r=t[e.toggleKey]??!1,o=t[e.colorKey]??"#e0e0e0";return j(bn,{label:"",children:Ge("div",{className:ee("flex flex-col rounded-lg border transition-colors overflow-hidden",r?"border-white/10 bg-white/3":"border-white/6 bg-white/2"),children:[Ge("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[j(Qr,{checked:r,onCheckedChange:a=>n({[e.toggleKey]:a}),className:"data-[state=checked]:bg-blue-500"}),j("span",{className:ee("text-[12px] flex-1",r?"text-white":"text-white/40"),children:e.label}),!r&&j("div",{className:"w-5 h-5 rounded-full border border-white/15",style:{background:o}})]}),r&&j("div",{className:"px-3 pb-3 border-t border-white/6",children:j("div",{className:"pt-3",children:j(ls,{value:o,onChange:a=>n({[e.colorKey]:a})})})})]})})}return e.type==="inlineFields"?j(bn,{label:e.label,children:j("div",{className:"flex items-center gap-2 flex-wrap",children:e.fields.map((r,o)=>{if(r.type==="stepperInt"){let a=t[r.key]??r.min??1,i=r.step??1,s=r.min??-1/0,l=r.max??1/0;return Ge("div",{className:"flex items-center gap-1 bg-white/4 border border-white/8 rounded-lg px-1",children:[j("button",{className:"w-6 h-7 flex items-center justify-center text-white/50 hover:text-white transition-colors leading-none disabled:opacity-30",onClick:()=>n({[r.key]:Math.max(s,a-i)}),disabled:a<=s,children:"\u2212"}),j("span",{className:"text-[12px] font-mono text-white tabular-nums min-w-[2ch] text-center",children:a}),j("button",{className:"w-6 h-7 flex items-center justify-center text-white/50 hover:text-white transition-colors leading-none disabled:opacity-30",onClick:()=>n({[r.key]:Math.min(l,a+i)}),disabled:a>=l,children:"+"}),r.label&&j("span",{className:"text-[10px] text-white/30 pr-1.5",children:r.label})]},o)}if(r.type==="buttonGroup"){let a=t[r.key]??r.options[0]?.value??"";return j("div",{className:"flex gap-1",children:r.options.map(i=>j("button",{title:i.label,className:ee("w-7 h-7 flex items-center justify-center rounded-lg border text-[11px] transition-colors",a===i.value?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n({[r.key]:i.value}),children:i.icon??i.label[0]},i.value))},o)}if(r.type==="checkbox"){let a=t[r.key]??!1;return Ge("button",{className:ee("flex items-center gap-1.5 px-2.5 h-7 rounded-lg border text-[11px] transition-colors",a?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n({[r.key]:!a}),children:[a&&j(Or,{size:10,strokeWidth:3}),r.label]},o)}return null})})}):null}function j6({field:e,value:t,onChange:n}){let[r,o]=xi(()=>String(t)),a=oc(!1);Wh(()=>{a.current||o(String(t))},[t]);let i=()=>{let s=parseFloat(r);if(isNaN(s))o(String(t));else{let l=Math.min(e.max??1/0,Math.max(e.min??-1/0,s));n(l),o(String(l))}};return j(bn,{label:e.label,children:Ge("div",{className:"flex items-center gap-2",children:[j("input",{type:"number",className:"flex-1 bg-white/5 border border-white/10 rounded-lg px-3 py-2 text-[12px] font-mono text-white focus:outline-none focus:border-blue-500/60",value:r,min:e.min,max:e.max,step:e.step??1,onChange:s=>o(s.target.value),onFocus:()=>{a.current=!0},onBlur:()=>{a.current=!1,i()},onKeyDown:s=>{s.stopPropagation(),s.key==="Enter"&&i()}}),e.unit&&j("span",{className:"text-[11px] text-white/35 shrink-0",children:e.unit})]})})}function bn({label:e,children:t}){return Ge("div",{className:"flex flex-col gap-2.5",children:[j("p",{className:"text-[10px] font-semibold text-white/35 uppercase tracking-widest",children:e}),t]})}function Vh({label:e,children:t}){return Ge("div",{className:"flex items-center gap-3",children:[j("span",{className:"text-[11px] text-white/40 w-20 shrink-0",children:e}),j("div",{className:"flex-1",children:t})]})}function rR({value:e,onChange:t}){let[n,r]=xi(()=>e.toFixed(6)),o=oc(!1);return Wh(()=>{o.current||r(e.toFixed(6))},[e]),j("input",{type:"text",className:"w-full bg-white/5 border border-white/10 rounded px-2.5 py-1.5 text-[11px] font-mono text-white focus:outline-none focus:border-blue-500/60",value:n,onChange:a=>r(a.target.value),onFocus:()=>{o.current=!0},onBlur:()=>{o.current=!1;let a=parseFloat(n);isNaN(a)?r(e.toFixed(6)):t(a)},onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"&&a.target.blur()}})}function oR({value:e,onChange:t}){let[n,r]=xi(()=>Tv(e)),o=oc(!1);return Wh(()=>{o.current||r(Tv(e))},[e]),j("input",{type:"text",className:"w-full bg-white/5 border border-white/10 rounded px-2.5 py-1.5 text-[11px] font-mono text-white focus:outline-none focus:border-blue-500/60",value:n,onChange:a=>r(a.target.value),onFocus:()=>{o.current=!0},onBlur:()=>{o.current=!1;let a=U6(n);a!==null?t(a):r(Tv(e))},onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"&&a.target.blur()}})}function Iv({label:e,anchor:t,onChange:n}){return Ge("div",{className:"rounded-lg border border-white/8 bg-white/2 px-3 py-3 flex flex-col gap-2.5",children:[j("p",{className:"text-[10px] font-semibold text-white/40 uppercase tracking-widest",children:e}),j(Vh,{label:"Time",children:j(oR,{value:t.ts,onChange:r=>n({...t,ts:r})})}),j(Vh,{label:"Price",children:j(rR,{value:t.price,onChange:r=>n({...t,price:r})})})]})}function tR({value:e,onChange:t}){return j("div",{className:"flex gap-1.5",children:["left","center","right"].map(n=>{let r=n==="left"?Md:n==="center"?kd:Ld;return Ge("button",{className:ee("flex items-center gap-1.5 px-3 py-2 rounded-lg border text-[11px] transition-colors",e===n?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>t(n),children:[j(r,{size:12}),{left:"Left",center:"Center",right:"Right"}[n]]},n)})})}function G6({value:e,onChange:t}){return j("div",{className:"flex gap-1.5",children:[{val:"top",label:"Top",Icon:Rd},{val:"middle",label:"Middle",Icon:Cd},{val:"bottom",label:"Bottom",Icon:Td}].map(({val:r,label:o,Icon:a})=>Ge("button",{className:ee("flex items-center gap-1.5 px-3 py-2 rounded-lg border text-[11px] transition-colors",e===r?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>t(r),children:[j(a,{size:12}),o]},r))})}function al({active:e,onClick:t,children:n}){return Ge("button",{className:ee("flex items-center gap-1.5 px-3 py-1.5 rounded-lg border text-[11px] transition-colors",e?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:t,children:[e&&!["Bold","Italic"].some(r=>typeof n=="object"&&Array.isArray(n)&&n.some(o=>typeof o=="string"&&o===r))&&j(Or,{size:11,strokeWidth:2.5}),n]})}function Y6({label:e,active:t,onToggle:n}){return Ge("button",{className:ee("w-full flex items-center justify-between px-3 py-2.5 rounded-lg border text-left transition-colors",t?"border-blue-500/30 bg-blue-500/8 text-white":"border-white/6 bg-white/3 text-white/50 hover:border-white/12 hover:bg-white/5 hover:text-white/70"),onClick:n,children:[j("span",{className:"text-[12px]",children:e}),j(Qr,{checked:t,onCheckedChange:n,className:"data-[state=checked]:bg-blue-500"})]})}function K6({icon:e,label:t,description:n,checked:r,activeColor:o="text-blue-400",onCheckedChange:a}){return Ge("div",{className:"flex items-center gap-3 py-2",children:[j("div",{className:ee("shrink-0",r?o:"text-white/30"),children:e}),Ge("div",{className:"flex-1 min-w-0",children:[j("p",{className:"text-[12px] text-white",children:t}),j("p",{className:"text-[10px] text-white/35 mt-0.5",children:n})]}),j(Qr,{checked:r,onCheckedChange:a,className:"data-[state=checked]:bg-blue-500"})]})}function ls({value:e,onChange:t}){return Ge("div",{className:"flex flex-col gap-3",children:[j("div",{className:"grid grid-cols-8 gap-1.5",children:V6.map(n=>j("button",{className:ee("w-7 h-7 rounded-full border-2 transition-all hover:scale-110 flex items-center justify-center",e===n?"border-white scale-110":"border-white/10"),style:{background:n},onClick:()=>t(n),children:e===n&&j(Or,{size:11,className:"text-black drop-shadow",strokeWidth:3})},n))}),j("div",{className:"flex items-center gap-2",children:j(Lo,{onChange:n=>t(n),value:e,className:"w-8 h-8 rounded-md border-2 border-border/50"})})]})}function $6({levels:e,onChange:t}){let[n,r]=xi(""),[o,a]=xi("#22c55e"),i=(c,u)=>t(e.map(d=>d.id===c?{...d,...u}:d)),s=c=>t(e.filter(u=>u.id!==c)),l=()=>{n.trim()&&(t([...e,{id:pn(8),value:n.trim(),color:o,enabled:!0}]),r(""))};return Ge("div",{className:"flex flex-col gap-1.5",children:[e.map(c=>Ge("div",{className:ee("grid items-center gap-1.5 px-2.5 py-1.5 rounded-lg border border-white/6 bg-white/3 transition-opacity",!c.enabled&&"opacity-40"),style:{gridTemplateColumns:"22px 1fr 24px 22px"},children:[j("label",{className:"w-[22px] h-[22px] rounded-[5px] border-[1.5px] border-white/20 cursor-pointer shrink-0 hover:scale-110 transition-transform overflow-hidden block",style:{background:c.color},children:j(Lo,{onChange:u=>i(c.id,{color:u}),value:c.color,className:"opacity-0 absolute"})}),j("input",{type:"text",className:"w-full bg-white/5 border border-white/10 rounded-md px-2 py-1 text-[12px] font-mono text-white/80 focus:outline-none focus:border-blue-500/50",value:c.value,onChange:u=>i(c.id,{value:u.target.value}),onKeyDown:u=>u.stopPropagation()}),j("button",{className:ee("w-6 h-6 flex items-center justify-center rounded-md transition-colors",c.enabled?"text-white/50 hover:text-white/80 hover:bg-white/8":"text-white/20 hover:text-white/50 hover:bg-white/8"),onClick:()=>i(c.id,{enabled:!c.enabled}),children:c.enabled?j(Da,{size:12}):j(Bi,{size:12})}),j("button",{className:"w-[22px] h-[22px] flex items-center justify-center rounded-md text-white/20 hover:text-red-400 hover:bg-red-500/10 transition-colors",onClick:()=>s(c.id),children:j(_r,{size:11})})]},c.id)),Ge("div",{className:"flex items-center gap-1.5 mt-1",children:[j("label",{className:"w-8 h-8 rounded-lg border-[1.5px] border-dashed border-white/18 hover:border-white/40 cursor-pointer shrink-0 overflow-hidden transition-colors block",style:{background:o},children:j(Lo,{onChange:c=>a(c),value:o,className:"opacity-0 absolute"})}),j("input",{type:"text",className:"flex-1 bg-white/4 border border-dashed border-white/12 rounded-lg px-2.5 py-1.5 text-[12px] font-mono text-white/60 placeholder:text-white/20 focus:outline-none focus:border-blue-500/40 focus:border-solid focus:bg-white/6",placeholder:"Level e.g. 0.786",value:n,onChange:c=>r(c.target.value),onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"&&l()},maxLength:8}),j("button",{className:"px-3 h-8 bg-blue-500/15 border border-blue-500/30 rounded-lg text-[11px] font-medium text-blue-400 hover:bg-blue-500/25 transition-colors shrink-0",onClick:l,children:"+ Add"})]})]})}function X6(e){return $f.find(n=>JSON.stringify(n.dash)===JSON.stringify(e??[]))?.value??"solid"}function Z6({levels:e,fallbackColor:t,onChange:n}){let[r,o]=xi(""),a=(l,c)=>{n(e.map(u=>u.id===l?{...u,...c}:u))},i=l=>n(e.filter(c=>c.id!==l)),s=()=>{let l=parseFloat(r);Number.isNaN(l)||(n([...e,{id:pn(8),value:l,color:t,lineWidth:1,dash:[],enabled:!0}].sort((c,u)=>c.value-u.value)),o(""))};return Ge("div",{className:"flex flex-col gap-1.5",children:[e.map(l=>Ge("div",{className:ee("flex flex-col gap-1.5 px-2.5 py-2 rounded-lg border border-white/6 bg-white/3 transition-opacity",!l.enabled&&"opacity-40"),children:[Ge("div",{className:"grid items-center gap-1.5",style:{gridTemplateColumns:"28px 1fr 24px 22px"},children:[j(Lo,{onChange:c=>a(l.id,{color:c}),value:l.color,className:"w-7 h-7"}),j("input",{type:"number",step:"0.1",className:"w-full bg-white/5 border border-white/10 rounded-md px-2 py-1 text-[12px] font-mono text-white/80 focus:outline-none focus:border-blue-500/50",value:l.value,onChange:c=>a(l.id,{value:c.target.value}),onKeyDown:c=>c.stopPropagation()}),j("button",{className:ee("w-6 h-6 flex items-center justify-center rounded-md transition-colors",l.enabled?"text-white/50 hover:text-white/80 hover:bg-white/8":"text-white/20 hover:text-white/50 hover:bg-white/8"),onClick:()=>a(l.id,{enabled:!l.enabled}),children:l.enabled?j(Da,{size:12}):j(Bi,{size:12})}),j("button",{className:"w-[22px] h-[22px] flex items-center justify-center rounded-md text-white/20 hover:text-red-400 hover:bg-red-500/10 transition-colors",onClick:()=>i(l.id),children:j(_r,{size:11})})]}),Ge("div",{className:"flex items-center gap-1.5",children:[j("div",{className:"flex gap-1 w-1/2",children:[1,2,3,4].map(c=>j("button",{className:ee("w-full h-6 rounded-md text-[10px] font-mono border transition-colors",l.lineWidth===c?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>a(l.id,{lineWidth:c}),children:c},c))}),Ge(Ha,{children:[j(Va,{asChild:!0,children:Ge(pr,{variant:"outline",className:"flex flex-row justify-between p-1 px-2 h-[1.7rem] text-xs text-muted-foreground !scale-100 w-1/2",children:[j("div",{children:$f.find(c=>c.value===X6(l.dash)).label}),j(Zn,{className:"w-4"})]})}),j(va,{className:"z-[201]",children:$f.map(c=>j(ta,{onSelect:()=>{let u=$f.find(d=>d.value===c.value);a(l.id,{dash:u?u.dash:[]})},className:"text-xs",children:c.label},c.value))})]})]})]},l.id)),Ge("div",{className:"flex items-center gap-1.5 mt-1",children:[j("input",{type:"number",step:"0.1",className:"flex-1 bg-white/5 border border-dashed border-white/12 rounded-lg px-2.5 py-1.5 text-[12px] font-mono text-white/60 placeholder:text-white/20 focus:outline-none focus:border-blue-500/40 focus:border-solid focus:bg-white/6",placeholder:"Level e.g. 0.5",value:r,onChange:l=>o(l.target.value),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&s()}}),j("button",{className:"px-3 h-8 bg-blue-500/15 border border-blue-500/30 rounded-lg active:scale-[0.98] text-[11px] font-medium text-blue-400 hover:bg-blue-500/25 transition-all shrink-0",onClick:s,children:"+ Add"})]})]})}import{Fragment as iV,jsx as Je,jsxs as _n}from"react/jsx-runtime";var J6=[{label:"\u2500\u2500\u2500\u2500\u2500",dash:[]},{label:"----",dash:[6,3]},{label:"\xB7\xB7\xB7\xB7",dash:[2,3]},{label:"\u2500\xB7\u2500",dash:[8,3,2,3]}],eV=[1,2,3,4],Rv={x:16,y:16},il=12,Pv=null;function aR(e,{requestOrderTicket:t}){t(e.id)}var tV={hline:[{type:"color",patchKey:"color",label:"Color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"},{type:"sep"},{type:"dash",patchKey:"dash"}],vline:[{type:"color",patchKey:"color",label:"Color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"},{type:"sep"},{type:"dash",patchKey:"dash"}],"extended-line":[{type:"color",patchKey:"color",label:"Color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"},{type:"sep"},{type:"dash",patchKey:"dash"}],line:[{type:"color",patchKey:"color",label:"Color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"},{type:"sep"},{type:"dash",patchKey:"dash"}],"cross-line":[{type:"color",patchKey:"color",label:"Color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"},{type:"sep"},{type:"dash",patchKey:"dash"}],"info-line":[{type:"color",patchKey:"color",label:"Color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"},{type:"sep"},{type:"dash",patchKey:"dash"}],"trend-angle":[{type:"color",patchKey:"color",label:"Color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"},{type:"sep"},{type:"dash",patchKey:"dash"}],ray:[{type:"color",patchKey:"color",label:"Color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"},{type:"sep"},{type:"dash",patchKey:"dash"}],hray:[{type:"color",patchKey:"color",label:"Color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"},{type:"sep"},{type:"dash",patchKey:"dash"}],"parallel-channel":[{type:"color",patchKey:"color",label:"Color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"},{type:"sep"},{type:"dash",patchKey:"dash"}],rect:[{type:"borderColor",patchKey:"borderColor",label:"Border Color"},{type:"sep"},{type:"lineWidth",patchKey:"borderLineWidth",label:"Border width"},{type:"sep"},{type:"dash",patchKey:"borderDash",label:"Border style"},{type:"sep"},{type:"fillColor",patchKey:"fillColor",label:"Fill color"}],triangle:[{type:"borderColor",patchKey:"borderColor",label:"Border Color"},{type:"sep"},{type:"lineWidth",patchKey:"borderLineWidth",label:"Border width"},{type:"sep"},{type:"dash",patchKey:"borderDash",label:"Border style"},{type:"sep"},{type:"fillColor",patchKey:"fillColor",label:"Fill color"}],fib:[{type:"fibColor"},{type:"sep"},{type:"fibBgColor",patchKey:"backgroundColor",gateKey:"enableBackground",label:"Background color"},{type:"sep"},{type:"lineWidth",patchKey:"lineWidth"}],text:[{type:"color",patchKey:"color",label:"Color"}],fvp:[{type:"fvpMode"},{type:"sep"},{type:"color",patchKey:"buyColor",label:"Buy color"},{type:"sep"},{type:"color",patchKey:"sellColor",label:"Sell color"}],long:[{type:"color",patchKey:"upColor",label:"Target Color"},{type:"color",patchKey:"downColor",label:"Stop Color"},{type:"sep"},{type:"button",onClick:aR,icon:nu,label:"Create order from this drawing"}],short:[{type:"color",patchKey:"downColor",label:"Target Color"},{type:"color",patchKey:"upColor",label:"Stop Color"},{type:"sep"},{type:"button",onClick:aR,icon:nu,label:"Create order from this drawing"}]};function sR({drawing:e,containerRef:t,onUpdate:n,onDelete:r,onDuplicate:o,onClose:a,onMouseEnter:i,onMouseLeave:s,onRequestOrderTicket:l,openDialog:c}){let u=qh(null),[d,m]=Uh(!1),[f,h]=Uh(null),p=qh(!1),[g,y]=Uh(e);Lv(()=>{y(e)},[e.id]);let v=jh(L=>{y(z=>({...z,...L})),n(L)},[n]),b=jh(L=>{if(p.current){p.current=!1;return}h(z=>z===L?null:L)},[]),S=jh(()=>h(null),[]);Lv(()=>{c&&m(!0)},[c]);let C=qh(Pv);if(C.current===null){let L=t.current?.getBoundingClientRect();C.current=L?{x:L.left+Rv.x,y:L.top+Rv.y}:Rv}Q6(()=>{let L=u.current;if(!L)return;let z=L.getBoundingClientRect(),Y=Math.max(il,Math.min(window.innerWidth-z.width-il,C.current.x)),G=Math.max(il,Math.min(window.innerHeight-z.height-il,C.current.y));(Y!==C.current.x||G!==C.current.y)&&(C.current={x:Y,y:G},Pv=C.current,L.style.left=`${Y}px`,L.style.top=`${G}px`)});let w=qh(!1),[k,M]=Uh(!1),I=jh(L=>{L.preventDefault(),L.stopPropagation(),h(null);let z=L.clientX,Y=L.clientY,G=C.current.x,H=C.current.y;w.current=!0,M(!0);let W=V=>{let K=u.current;if(!K)return;let Z=V.clientX-z,de=V.clientY-Y,ze=G+Z,xe=H+de,Ae=K.getBoundingClientRect();ze=Math.max(il,Math.min(window.innerWidth-Ae.width-il,ze)),xe=Math.max(il,Math.min(window.innerHeight-Ae.height-il,xe)),C.current={x:ze,y:xe},Pv=C.current,K.style.left=`${ze}px`,K.style.top=`${xe}px`},U=()=>{w.current=!1,M(!1),window.removeEventListener("mousemove",W),window.removeEventListener("mouseup",U)};window.addEventListener("mousemove",W),window.addEventListener("mouseup",U)},[t]);Lv(()=>{let L=Y=>{let G=Y.target;u.current?.contains(G)||t.current?.contains(G)&&a()},z=setTimeout(()=>window.addEventListener("mousedown",L),150);return()=>{clearTimeout(z),window.removeEventListener("mousedown",L)}},[a,t]);let x=L=>g[L],T=g.locked??!1,R=g.tool==="fib"?x("levels")??[]:[],P=R.filter(L=>L.enabled).map(L=>L.color),N=P.length>0&&P.every(L=>L===P[0])?P[0]:null,O=tV[g.tool]??[],A=l?O:O.filter(L=>L.type!=="button"),B=A.filter((L,z)=>L.type!=="sep"||A.slice(z+1).some(Y=>Y.type!=="sep")),E=(L,z)=>{switch(L.type){case"sep":return Je(nV,{},`sep-${z}`);case"color":{let Y=x(L.patchKey);if(Y===void 0)return null;let G=`color-${L.patchKey}`;return _n("div",{className:"relative",children:[_n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onClick:()=>b(G),children:_n("span",{className:"flex flex-col items-center gap-0.5",children:[Je(iR,{}),Je(Xf,{color:Y})]})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:L.label})]}),Je(Lo,{onChange:H=>{v({[L.patchKey]:H})},value:Y,open:f===G,onOpenChange:H=>{H||(p.current=!0,S())},hideButton:!0})]},G)}case"borderColor":{let Y=x(L.patchKey)??x("color");if(Y===void 0)return null;let G=`borderColor-${L.patchKey}`;return _n("div",{className:"relative",children:[_n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onMouseDown:H=>{H.preventDefault(),b(G)},children:_n("span",{className:"flex flex-col items-center gap-0.5",children:[Je(oV,{}),Je(Xf,{color:Y})]})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:L.label??"Border color"})]}),Je(Lo,{onChange:H=>{v({[L.patchKey]:H})},value:Y,open:f===G,onOpenChange:H=>{H||(p.current=!0,S())},hideButton:!0})]},G)}case"fillColor":{let Y=x(L.patchKey)??x("color");if(Y===void 0)return null;let G=`fillColor-${L.patchKey}`;return _n("div",{className:"relative",children:[_n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onClick:()=>b(G),children:_n("span",{className:"flex flex-col items-center gap-0.5",children:[Je(aV,{}),Je(Xf,{color:Y})]})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:L.label??"Fill color"})]}),Je(Lo,{onChange:H=>v({[L.patchKey]:H}),value:Y,open:f===G,onOpenChange:H=>{H||(p.current=!0,S())},hideButton:!0})]},G)}case"lineWidth":{let Y=x(L.patchKey);if(Y===void 0)return null;let G=`lineWidth-${L.patchKey}`;return _n("div",{className:"relative",children:[_n(Ht,{children:[Je(Ot,{asChild:!0,children:_n("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors text-muted-foreground text-[11px] font-mono",onClick:()=>b(G),children:["- ",Y,"px"]})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:L.label??"Line width"})]}),f===G&&Je("div",{className:"absolute top-full mt-1 left-0 z-50 p-1.5 rounded-lg border border-border bg-[#1c1e24] shadow-xl flex flex-col gap-1 min-w-[80px]",onMouseDown:H=>H.stopPropagation(),children:eV.map(H=>_n("button",{className:ee("flex items-center gap-2 px-2 py-1 rounded text-[11px] font-mono hover:bg-white/10 transition-colors",Y===H?"text-white":"text-muted-foreground"),onClick:()=>{v({[L.patchKey]:H}),S()},children:[Je("div",{className:"rounded-full bg-current",style:{height:H,width:28}}),H,"px"]},H))})]},G)}case"dash":{let Y=x(L.patchKey),G=x("color")??x("borderColor")??"#e0e0e0";if(Y===void 0)return null;let H=`dash-${L.patchKey}`;return _n("div",{className:"relative",children:[_n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onClick:()=>b(H),children:Je(rV,{dash:Y,color:G})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:L.label??"Line style"})]}),f===H&&Je("div",{className:"absolute top-full mt-1 left-0 z-50 p-1.5 rounded-lg border border-border bg-[#1c1e24] shadow-xl flex flex-col gap-1 min-w-[120px]",onMouseDown:W=>W.stopPropagation(),children:J6.map(W=>Je("button",{className:ee("flex items-center gap-2 px-2 py-1 rounded text-[11px] font-mono hover:bg-white/10 transition-colors",JSON.stringify(Y)===JSON.stringify(W.dash)?"text-white":"text-muted-foreground"),onClick:()=>{v({[L.patchKey]:W.dash}),S()},children:W.label},W.label))})]},H)}case"fibColor":{if(P.length===0)return null;let Y="fibColor";return _n("div",{className:"relative",children:[_n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onClick:()=>{b(Y)},children:_n("span",{className:"flex flex-col items-center gap-0.5",children:[Je(iR,{}),N?Je(Xf,{color:N}):Je("div",{className:"h-[3px] w-[13px] rounded-full",style:{background:"linear-gradient(to right, #ef4444, #f97316, #eab308, #22c55e, #3b82f6, #a855f7)"}})]})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:"Levels color"})]}),Je(Lo,{onChange:G=>{v({levels:R.map(H=>H.enabled?{...H,color:G}:H)})},value:N,open:f===Y,onOpenChange:G=>{G||(p.current=!0,S())},hideButton:!0})]},Y)}case"fibBgToggle":{let Y=x(L.enableKey)??!0;return _n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:ee("flex items-center gap-1 px-1.5 py-1 rounded transition-colors",Y?"text-blue-400 hover:bg-white/10":"text-muted-foreground/40 hover:bg-white/10 hover:text-muted-foreground"),onClick:()=>{v({[L.enableKey]:!Y})},children:Je("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:Je("rect",{x:"1.5",y:"1.5",width:"10",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.3",fill:Y?"currentColor":"none",fillOpacity:Y?.25:0})})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:Y?"Hide background":"Show background"})]},"fibBgToggle")}case"fibBgColor":{if(!(x(L.gateKey)??!0))return null;let G=x(L.patchKey)??"#ffffff1a",H=`fibBgColor-${L.patchKey}`;return _n("div",{className:"relative",children:[_n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onClick:()=>b(H),children:_n("span",{className:"flex flex-col items-center gap-0.5",children:[Je("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:Je("rect",{x:"2",y:"2",width:"9",height:"9",rx:"1",fill:"currentColor",fillOpacity:"0.3",stroke:"currentColor",strokeWidth:"1.2"})}),Je(Xf,{color:G})]})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:L.label??"Background color"})]}),Je(Lo,{onChange:W=>v({[L.patchKey]:W}),value:G,open:f===H,onOpenChange:W=>{W||(p.current=!0,S())},hideButton:!0})]},H)}case"fvpMode":{let Y=x("profileMode")??"stacked";return Je("div",{className:"flex gap-0.5",children:[{value:"stacked",label:"Stacked"},{value:"split",label:"Split"},{value:"delta",label:"Delta"},{value:"total",label:"Total"}].map(H=>Je("button",{className:ee("px-2.5 h-7 rounded text-[11px] font-medium transition-colors",Y===H.value?"bg-blue-500/25 text-blue-300 border border-blue-500/40":"text-white/40 hover:text-white/70 hover:bg-white/8 border border-transparent"),onClick:()=>{v({profileMode:H.value})},children:H.label},H.value))},"fvpMode")}case"button":{if(!l)return null;let Y=L.icon;return _n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:"p-1 rounded hover:bg-white/10 text-muted-foreground hover:text-white transition-colors",onClick:()=>L.onClick(e,{requestOrderTicket:l}),children:Je(Y,{size:13})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:L.label})]},"button")}default:return null}};return _n(iV,{children:[Je("style",{children:`
|
|
75
|
+
@keyframes dsb-in {
|
|
76
|
+
from { opacity: 0; transform: scale(0.92); }
|
|
77
|
+
to { opacity: 1; transform: scale(1); }
|
|
78
|
+
}
|
|
79
|
+
.dsb-enter {
|
|
80
|
+
animation: dsb-in 140ms cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
81
|
+
transform-origin: top left;
|
|
82
|
+
}
|
|
83
|
+
`}),k&&Je("div",{style:{position:"fixed",inset:0,zIndex:9999,cursor:"grabbing"}}),_n("div",{ref:u,className:"dsb-enter fixed z-[150] flex items-center gap-0.5 h-9 rounded-lg border border-border bg-[#1c1e24] shadow-xl w-fit",style:{left:C.current.x,top:C.current.y,userSelect:k?"none":void 0},onMouseDown:L=>L.stopPropagation(),onMouseEnter:k?void 0:i,onMouseLeave:k?void 0:s,children:[Je("div",{className:"flex items-center justify-center h-full px-1 cursor-grab active:cursor-grabbing text-muted-foreground/40 hover:text-muted-foreground transition-colors shrink-0 rounded-l-lg",onMouseDown:I,title:"Drag to move",children:Je(Bl,{size:13})}),B.map((L,z)=>E(L,z)),Je("div",{className:"flex-1 w-4"}),_n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:"p-1 rounded hover:bg-white/10 text-muted-foreground hover:text-foreground transition-colors",onClick:()=>m(!0),children:Je(El,{size:13})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:"Settings"})]}),_n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:ee("p-1 rounded hover:bg-white/10 transition-colors",T?"text-yellow-400":"text-muted-foreground"),onClick:()=>v({locked:!T}),children:T?Je(jr,{size:13}):Je(Ei,{size:13})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:T?"Unlock":"Lock"})]}),_n(Ht,{children:[Je(Ot,{asChild:!0,children:Je("button",{className:"p-1 rounded hover:bg-white/10 text-muted-foreground hover:text-red-400 transition-colors",onClick:r,children:Je(ho,{size:13})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:"Delete"})]}),_n(Ha,{children:[_n(Ht,{children:[Je(Ot,{asChild:!0,children:Je(Va,{asChild:!0,children:Je("button",{className:"p-1 mr-1 rounded hover:bg-white/10 text-muted-foreground transition-colors",children:Je(Ws,{size:13})})})}),Je(_t,{side:"bottom",className:"bg-background border border-border",children:"More"})]}),_n(va,{align:"end",className:"bg-[#1c1e24] border-border",children:[_n(ta,{onClick:o,className:"gap-2 cursor-pointer text-xs",children:[Je(Dl,{size:12})," Duplicate"]}),_n(ta,{onClick:r,className:"gap-2 cursor-pointer text-red-400 focus:text-red-400 text-xs",children:[Je(ho,{size:12})," Delete"]})]})]})]}),d&&Je(nR,{drawing:g,onUpdate:v,onClose:()=>m(!1),onMouseEnter:i,onMouseLeave:s})]})}function nV(){return Je("div",{className:"w-px h-4 bg-border mx-0.5 shrink-0"})}function Xf({color:e}){return Je("div",{className:"h-[3px] w-[13px] rounded-full",style:{background:e}})}function rV({dash:e,color:t}){return Je("svg",{width:"24",height:"10",viewBox:"0 0 24 10",children:Je("line",{x1:"0",y1:"5",x2:"24",y2:"5",stroke:t,strokeWidth:"1.5",strokeDasharray:e.join(" ")||"none"})})}function iR(){return Je("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:Je("path",{d:"M9.5 1.5L11.5 3.5L4.5 10.5L2 11L2.5 8.5L9.5 1.5Z",stroke:"#ccc",strokeWidth:"1.2",fill:"none",strokeLinejoin:"round"})})}function oV(){return Je("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:Je("rect",{x:"2",y:"2",width:"9",height:"9",stroke:"#ccc",strokeWidth:"1.4",fill:"none",rx:"1"})})}function aV(){return Je("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:Je("rect",{x:"2",y:"2",width:"9",height:"9",fill:"#ccc",rx:"1"})})}var Ye={chartType:"area",upBodyColor:"#00e676",downBodyColor:"#ff1744",upWickColor:"#00e676aa",downWickColor:"#ff1744aa",upBorderColor:"#00e676",downBorderColor:"#ff1744",wickColorMatchesBody:!0,borderColorMatchesBody:!0,wickWidth:1,borderWidth:1,drawEmptyCandles:!1,baselineValue:null,renkoBrickSize:null,kagiReversal:null,lineBreakCount:3,footprintMode:"bid-ask",footprintVolume:"total",footprintImbalanceRatio:3,footprintStackMinCount:3,footprintShowStackedImbalance:!0,footprintShowAbsorption:!0,footprintShowUnfinishedAuction:!0,footprintShowDiagonalImbalance:!0,footprintDiagRatio:3,footprintAbsorptionMult:2.5,footprintAbsorptionDeltaFrac:.25,priceScaleMode:"normal",autoScale:!0,priceAxisResizeSensitivity:1,invertScale:!1,allowLabelOverlap:!1,animatePriceUpdates:!0,scaleMarginTop:.1,scaleMarginBottom:.1,showGrid:!0,gridHorizontalColor:"#ffffff0d",gridVerticalColor:"#ffffff0d",crosshairMode:"normal",crosshairColor:"#758696",crosshairWidth:1,crosshairDash:[6,6],showBreaks:!1,breaksColor:"#3b82f6",breaksWidth:1,breaksDash:[],showStatusLine:!0,statusLineOHLC:!0,statusLineVolume:!0,statusLineDelta:!0,statusLineChange:!0,statusLineFontSize:12,backgroundColor:"#16181d",axisBackgroundColor:"#16181d",showBidLine:!0,showAskLine:!0,showMidLine:!1,showLastTradeLine:!1,showFills:!0,showTradeDots:!1,tradeDotsSizeMult:1,showHeatmap:!0,heatmapContrast:0,heatmapColorBid:"#3b82f6",heatmapColorAsk:"#ef4444",priceLineVisible:!0,priceLineColor:"#758696",resamplingDebounce:50,sessionHighlightEnabled:!1,sessionHighlightColor:"#ffffff08",horizonScrollEasing:"easeOut",horizonScrollDuration:80,timezone:"America/New_York",use24HourClock:!0,showTimezoneLabel:!0,pluginSettings:{}};function lR(e){let t={};for(let n of Object.keys(Ye))JSON.stringify(e[n])!==JSON.stringify(Ye[n])&&(t[n]=e[n]);return t}function cR(e){return{...Ye,...e??{}}}import{useCallback as Si,useRef as Mu,useState as Dv}from"react";function uR(e,t){return!t||t<=0?e:Math.round(e/t)*t}function Gh(e,t){return e[t]??{tpPrices:[],slPrices:[],hoveredGhost:null,draggingGhost:null}}function sV(e,t,n,r,o){let a=Gh(e,t),i=[...n==="tp"?a.tpPrices:a.slPrices];for(;i.length<=r;)i.push(void 0);return i[r]=o,{...e,[t]:{...a,tpPrices:n==="tp"?i:a.tpPrices,slPrices:n==="sl"?i:a.slPrices}}}function dR({tradeLines:e,onLinesChange:t,onSyncLines:n,onLineDelete:r,hitMapRef:o,chartWRef:a,chartHRef:i,chartOYRef:s,getLayouts:l,boundsRef:c,chartSettingsRef:u,redraw:d,symbolInfoRef:m,onGhostMove:f,linesRef:h,resolveLine:p,draggingLineIdRef:g,transformer:y}){let[v,b]=Dv(null),[S,C]=Dv(null),[w,k]=Dv("default"),M=Mu("default"),I=Si(U=>{M.current=U,k(V=>V===U?V:U)},[]),x=Mu(f);x.current=f;let T=Mu({}),R=Si(()=>T.current,[]),P=Mu(null),D=Mu(null),N=Mu(!1),O=U=>{let V=U.currentTarget.getBoundingClientRect(),K=U.clientX-V.left,Z=U.clientY-V.top;return[K,Z]},A=Si(U=>p?.(U)??e.find(V=>V.id===U),[e,p]),B=Si((U,V)=>{t(e.map(K=>K.id===U?{...K,...V}:K))},[e,t]),E=Si(U=>{let[V,K]=O(U),Z=l();if(i.current=Z.main?.h,s.current=Z.main?.y??0,D.current){let{lineId:Oe,kind:ke}=D.current,Q=y.yToPrice(K-(s?.current??0),i.current);if(Q=uR(Q,ro(m?.current)),N.current){N.current=!1;let se=Gh(T.current,Oe),Re=(ke==="tp"?se.tpPrices:se.slPrices).length,ye=`${Oe}-${ke}-${Re}`;D.current={lineId:Oe,ghostId:ye,kind:ke,index:Re}}let{index:Pe,ghostId:_}=D.current;T.current=sV(T.current,Oe,ke,Pe,Q);let ie=T.current[Oe];ie&&(T.current={...T.current,[Oe]:{...ie,draggingGhost:_,draggingGhostIdx:Pe,draggingGhostType:ke}}),d();return}if(P.current){let{lineId:Oe}=P.current,ke=A(Oe);if(!ke||ke.locked)return;let Q=y.yToPrice(K-(s?.current??0),i.current);Q=uR(Q,ke.tickSize??ro(m?.current)),ke?.onMove&&ke.onMove(Q);let Pe=h.current?.get(Oe);Pe?(h.current.set(Oe,{...Pe,price:Q}),n([...h.current.values()])):B(Oe,{price:Q}),d();return}let de=_c(V,K,o.current);if(de.ghostHit){let{lineId:Oe,ghostId:ke}=de.ghostHit,Q=Gh(T.current,Oe);if(Q.hoveredGhost!==ke){let Pe={};for(let[_,ie]of Object.entries(T.current))Pe[_]=_===Oe?{...ie,hoveredGhost:ke}:{...ie,hoveredGhost:null};Pe[Oe]||(Pe[Oe]={...Q,hoveredGhost:ke}),T.current=Pe,d()}b(null),I("ns-resize");return}let ze=!1,xe={};for(let[Oe,ke]of Object.entries(T.current))ke.hoveredGhost?(xe[Oe]={...ke,hoveredGhost:null},ze=!0):xe[Oe]=ke;if(ze&&(T.current=xe,d()),de.lineId!==v&&(b(de.lineId),d()),!de.lineId){I("default");return}let Ae=A(de.lineId);if(!Ae||Ae.locked){I("default");return}switch(de.part){case"close":case"reverse":I("pointer");break;case"pricePill":I(Ae.movable?"ns-resize":"default");break;case"line":case"pill":I(Ae.movable?"ns-resize":"pointer");break;default:I("default")}},[v,A,B,n,i,c,u,o,d,m,h,y]),L=Si(U=>{if(U.button==2&&(D.current&&(D.current=null),U.stopPropagation(),U.preventDefault()),U.button!==0)return;let[V,K]=O(U),Z=_c(V,K,o.current);if(Z.ghostHit){let{lineId:ze,ghostId:xe,kind:Ae,index:Oe}=Z.ghostHit;U.stopPropagation(),U.preventDefault(),D.current={lineId:ze,ghostId:xe,kind:Ae,index:Oe},N.current=!0;let ke=Gh(T.current,ze);T.current={...T.current,[ze]:{...ke,draggingGhost:xe}},I("ns-resize");return}if(!Z.lineId)return;let de=A(Z.lineId);!de||de.locked||de.movable&&(Z.part==="line"||Z.part==="pill"||Z.part==="pricePill")&&(U.stopPropagation(),U.preventDefault(),P.current={lineId:Z.lineId,startY:K,startPrice:de.price,originalPrice:de.price},g&&(g.current=Z.lineId),C(Z.lineId),I("ns-resize"))},[A,o]),z=Si(U=>{if(D.current){let{lineId:Z,kind:de,index:ze}=D.current;D.current=null,N.current=!1;let xe=T.current[Z];if(xe){let Ae=de==="tp"?xe.tpPrices?.[ze]:xe.slPrices?.[ze];Ae!=null&&x.current?.(Z,de,ze,Ae),T.current={...T.current,[Z]:{...xe,draggingGhost:null,draggingGhostType:null,draggingGhostIdx:null}}}I("ns-resize"),d();return}if(!P.current)return;let{lineId:V}=P.current;g&&(g.current=null);let K=A(V);if(K){let de=h?.current?.get(V)?.price??K.price;K?.afterMove&&K.afterMove(de),B(V,{price:de})}P.current=null,C(null),I("ns-resize"),d()},[A,B,h,d]),Y=Si(U=>{if(P.current||D.current)return;v&&(b(null),d());let V=!1,K={};for(let[Z,de]of Object.entries(T.current))de.hoveredGhost?(K[Z]={...de,hoveredGhost:null},V=!0):K[Z]=de;V&&(T.current=K,d()),I("default")},[v,d]),G=Si(U=>{let[V,K]=O(U),Z=_c(V,K,o.current);if(!Z.lineId)return;let de=A(Z.lineId);de?.onContextMenu&&(U.preventDefault(),U.stopPropagation(),de.onContextMenu(de.price,K))},[A,o]),H=Si(U=>{let[V,K]=O(U),Z=_c(V,K,o.current);if(Z.ghostHit||!Z.lineId)return;let de=A(Z.lineId);if(!(!de||de.locked)){if(Z.part==="close"){U.stopPropagation(),r(de),de.onClose?.(),b(null),I("default");return}if(Z.part==="reverse"){U.stopPropagation(),de.onReverse?.();return}}},[A,o,r]),W=Si(U=>{let[V,K]=O(U),Z=_c(V,K,o.current);if(!Z.lineId)return;let de=A(Z.lineId);de?.onDoubleClick&&(U.stopPropagation(),de.onDoubleClick(de.price))},[A,o]);return{hoveredLineId:v,draggingLineId:S,cursor:w,cursorRef:M,getGhostState:R,onMouseMove:E,onMouseDown:L,onMouseUp:z,onMouseLeave:Y,onContextMenu:G,onDoubleClick:W,onClick:H}}import{useState as Yh,useCallback as Av,useRef as Lu,useLayoutEffect as lV,useEffect as Nv}from"react";import{Fragment as hV,jsx as Xe,jsxs as jt}from"react/jsx-runtime";var Ev=480,Pu=12,cV=["#e0e0e0","#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#a855f7","#ec4899","#26a69a","#ef5350","#facc15","#38bdf8","#84cc16","#f43f5e","#06b6d4","#8b5cf6"],uV=[{id:"params",label:"Params",icon:Xe(df,{size:13})},{id:"style",label:"Style",icon:Xe(Us,{size:13})}],Bv=null;function dV(){return{x:Math.round((window.innerWidth-Ev)/2),y:Math.round(window.innerHeight*.15)}}function fR(e,t){let n=window.innerHeight-t-Pu;return Math.min(Math.max(Pu,e),Math.max(Pu,n))}function fV(e){return Math.max(Pu,Math.min(window.innerWidth-Ev-Pu,e))}function mR({indicator:e,onUpdate:t,onClose:n,onMouseEnter:r,onMouseLeave:o,redrawDebounceMs:a=50}){let i=Lu(null),s=Lu(Bv??(typeof window<"u"?dV():{x:80,y:80})),[,l]=Yh(0),[c,u]=Yh("params"),d=Lu(null),m=Lu([]),h=(M=>["params","style"].indexOf(M))(c),p=m.current[h],[g,y]=Yh(e.settings??{}),v=Lu(null),b=Av((M,I)=>{y(x=>{let T={...x,[M]:I};return v.current&&clearTimeout(v.current),v.current=setTimeout(()=>t(T),a),T})},[t,a]);Nv(()=>()=>{v.current&&clearTimeout(v.current)},[]),lV(()=>{let M=i.current;if(!M)return;let I=fR(s.current.y,M.offsetHeight);I!==s.current.y&&(s.current={...s.current,y:I},Bv=s.current,l(x=>x+1))});let S=Av(M=>{if(M.target.closest("button"))return;M.preventDefault(),M.stopPropagation();let I=M.clientX,x=M.clientY,T=s.current.x,R=s.current.y,P=N=>{let O=i.current?.offsetHeight??0;s.current={x:fV(T+N.clientX-I),y:fR(R+N.clientY-x,O)},Bv=s.current,l(A=>A+1)},D=()=>{window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",D)};window.addEventListener("mousemove",P),window.addEventListener("mouseup",D)},[]),C=Av(()=>{o?.(),n()},[n,o]);Nv(()=>{let M=I=>{I.key==="Escape"&&C()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[C]);let k=(e.settingsSchema??[]).filter(M=>(M.tab??"params")===c);return jt(hV,{children:[Xe("style",{children:`
|
|
84
|
+
@keyframes dlg-in { from{opacity:0;transform:scale(0.94)} to{opacity:1;transform:scale(1)} }
|
|
85
|
+
.dlg-enter { animation: dlg-in 160ms cubic-bezier(0.16,1,0.3,1) both; transform-origin: top left; }
|
|
86
|
+
`}),jt("div",{ref:i,className:"dlg-enter fixed z-[200] flex flex-col rounded-xl border border-white/10 bg-[#14161b]/90 backdrop-blur-lg shadow-2xl overflow-hidden min-h-0",style:{left:s.current.x,top:s.current.y,width:Ev,maxHeight:`calc(100vh - ${s.current.y+Pu}px)`},onMouseDown:M=>M.stopPropagation(),onMouseEnter:r,onMouseLeave:o,children:[jt("div",{className:"flex items-center gap-2 px-4 pt-4 pb-3 border-b border-white/6 shrink-0 cursor-grab active:cursor-grabbing select-none",onMouseDown:S,children:[jt("div",{className:"flex-1 min-w-0",children:[Xe("h2",{className:"text-sm font-semibold text-white tracking-tight",children:e.name}),Xe("p",{className:"text-[11px] text-white/40 mt-0.5",children:"Indicator settings"})]}),Xe("button",{className:"p-1.5 rounded-lg hover:bg-white/10 text-white/40 hover:text-white transition-colors shrink-0 cursor-pointer",onClick:C,children:Xe(_r,{size:14})})]}),jt("div",{className:"flex gap-0.5 px-4 pt-2 pb-0 shrink-0 border-b border-white/6 relative",ref:d,children:[uV.map((M,I)=>jt("button",{ref:x=>m.current[I]=x,onClick:()=>u(M.id),className:ee("flex items-center gap-1.5 px-3 py-2 text-[11px] w-[223px] font-medium rounded-t transition-colors border-b-2 -mb-px justify-center",c===M.id?"text-white bg-white/5":"text-white/40 border-transparent hover:text-white/70 hover:bg-white/5"),children:[M.icon,M.label]},M.id)),Xe("div",{className:"absolute bottom-0 left-0 border-b-2 border-blue-500 transition-all duration-200",style:{width:p?.clientWidth??0,transform:`translateX(${p?.offsetLeft??0}px)`}})]}),jt("div",{className:"flex-1 overflow-y-auto overflow-x-hidden px-4 py-4 flex flex-col gap-3",children:[k.length===0&&jt("p",{className:"text-[12px] text-white/30 text-center py-6",children:["No ",c," settings for this indicator."]}),k.map((M,I)=>Xe(mV,{field:M,local:g,patch:b},I))]})]})]})}function mV({field:e,local:t,patch:n}){if(e.type==="section")return Xe("div",{className:"pt-2 pb-1",children:Xe("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-white/30",children:e.label})});if(e.type==="toggle"){let r=!!t[e.key];return jt("button",{className:ee("w-full flex items-center justify-between px-3 py-2.5 rounded-lg border text-left transition-colors",r?"border-blue-500/30 bg-blue-500/8 text-white":"border-white/6 bg-white/3 text-white/50 hover:border-white/12 hover:bg-white/5 hover:text-white/70"),onClick:()=>n(e.key,!r),children:[jt("div",{children:[Xe("p",{className:"text-[12px]",children:e.label}),e.description&&Xe("p",{className:"text-[10px] text-white/35 mt-0.5",children:e.description})]}),Xe(Qr,{checked:r,onCheckedChange:o=>n(e.key,o),className:"data-[state=checked]:bg-blue-500"})]})}if(e.type==="checkbox"){let r=!!t[e.key];return jt("button",{className:ee("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg border text-left transition-colors",r?"border-blue-500/30 bg-blue-500/8 text-white":"border-white/6 bg-white/3 text-white/50 hover:border-white/12 hover:bg-white/5 hover:text-white/70"),onClick:()=>n(e.key,!r),children:[Xe("div",{className:ee("w-4 h-4 rounded border-[1.5px] flex items-center justify-center shrink-0 transition-colors",r?"border-blue-500 bg-blue-500":"border-white/20 bg-transparent"),children:r&&Xe(Or,{size:10,strokeWidth:3,className:"text-white"})}),jt("div",{className:"flex flex-col gap-0.5 min-w-0",children:[Xe("span",{className:"text-[12px] leading-none",children:e.label}),e.description&&Xe("span",{className:"text-[10px] text-white/30 leading-none",children:e.description})]})]})}if(e.type==="color")return jt("div",{className:"flex flex-col gap-2",children:[Xe(Ru,{children:e.label}),Xe(ac,{value:String(t[e.key]??"#ffffff"),onChange:r=>n(e.key,r)})]});if(e.type==="dualColor")return jt("div",{className:"flex flex-col gap-2",children:[Xe(Ru,{children:e.label}),jt("div",{className:"grid grid-cols-2 gap-3",children:[jt("div",{className:"flex flex-col gap-1.5",children:[Xe("p",{className:"text-[10px] text-white/40",children:e.labelA}),Xe(ac,{value:String(t[e.keyA]??"#ffffff"),onChange:r=>n(e.keyA,r)})]}),jt("div",{className:"flex flex-col gap-1.5",children:[Xe("p",{className:"text-[10px] text-white/40",children:e.labelB}),Xe(ac,{value:String(t[e.keyB]??"#ffffff"),onChange:r=>n(e.keyB,r)})]})]})]});if(e.type==="colorGradient"){let r=String(t[e.keyStart]??"#3b82f6"),o=String(t[e.keyEnd]??"#8b5cf6");return jt(qa,{label:e.label,children:[Xe("div",{className:"w-full h-6 rounded-lg mb-3 border border-white/10",style:{background:`linear-gradient(to right, ${r}, ${o})`}}),jt("div",{className:"grid grid-cols-2 gap-3",children:[jt("div",{className:"flex flex-col gap-1.5",children:[Xe("p",{className:"text-[10px] text-white/40",children:"Start"}),Xe(ac,{value:r,onChange:a=>n(e.keyStart,a)})]}),jt("div",{className:"flex flex-col gap-1.5",children:[Xe("p",{className:"text-[10px] text-white/40",children:"End"}),Xe(ac,{value:o,onChange:a=>n(e.keyEnd,a)})]})]})]})}if(e.type==="colorWithOpacity"){let r=String(t[e.colorKey]??"#e0e0e0"),o=Number(t[e.opacityKey]??1);return Xe(qa,{label:e.label,children:jt("div",{className:"flex gap-3 items-start",children:[Xe("div",{className:"flex-1 min-w-0",children:Xe(ac,{value:r,onChange:a=>n(e.colorKey,a)})}),jt("div",{className:"flex flex-col gap-1 w-28 shrink-0 pt-0.5",children:[jt("p",{className:"text-[10px] text-white/35 font-medium",children:["Opacity - ",Math.round(o*100),"%"]}),Xe(Dn,{value:[o],onValueChange:([a])=>n(e.opacityKey,a),min:0,max:1,step:.01}),jt("div",{className:"flex justify-between text-[9px] text-white/25 font-mono",children:[Xe("span",{children:"0%"}),Xe("span",{children:"100%"})]})]})]})})}if(e.type==="toggledColor"){let r=!!t[e.toggleKey],o=String(t[e.colorKey]??"#e0e0e0");return Xe(qa,{label:"",children:jt("div",{className:ee("flex flex-col rounded-lg border transition-colors overflow-hidden",r?"border-white/10 bg-white/3":"border-white/6 bg-white/2"),children:[jt("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[Xe(Qr,{checked:r,onCheckedChange:a=>n(e.toggleKey,a),className:"data-[state=checked]:bg-blue-500"}),Xe("span",{className:ee("text-[12px] flex-1",r?"text-white":"text-white/40"),children:e.label}),!r&&Xe("div",{className:"w-5 h-5 rounded-full border border-white/15",style:{background:o}})]}),r&&Xe("div",{className:"px-3 pb-3 border-t border-white/6",children:Xe("div",{className:"pt-3",children:Xe(ac,{value:o,onChange:a=>n(e.colorKey,a)})})})]})})}if(e.type==="opacity"){let r=Number(t[e.key]??1);return jt("div",{className:"flex flex-col gap-2",children:[jt("div",{className:"flex items-center justify-between",children:[Xe(Ru,{children:e.label}),jt("span",{className:"text-[11px] font-mono text-white/40",children:[Math.round(r*100),"%"]})]}),Xe(Dn,{min:0,max:1,step:.01,value:[r],onValueChange:([o])=>n(e.key,o)})]})}if(e.type==="dualOpacity"){let r=Number(t[e.keyA]??.5),o=Number(t[e.keyB]??.5);return Xe(qa,{label:e.label,children:Xe("div",{className:"grid grid-cols-2 gap-4",children:[{key:e.keyA,label:e.labelA,val:r},{key:e.keyB,label:e.labelB,val:o}].map(({key:a,label:i,val:s})=>jt("div",{className:"flex flex-col gap-2",children:[jt("p",{className:"text-[10px] text-white/35 font-medium",children:[i," - ",Math.round(s*100),"%"]}),Xe(Dn,{value:[s],onValueChange:([l])=>n(a,l),min:0,max:1,step:.01})]},a))})})}if(e.type==="fontSize"){let r=Number(t[e.key]??12);return jt(qa,{label:`${e.label} - ${r}px`,children:[Xe(Dn,{value:[r],onValueChange:([o])=>n(e.key,Math.round(o)),max:48,min:8,step:1}),jt("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[Xe("span",{children:"8px"}),Xe("span",{children:"28px"}),Xe("span",{children:"48px"})]})]})}if(e.type==="slider"){let r=Number(t[e.key]??e.min);return jt("div",{className:"flex flex-col gap-2",children:[jt("div",{className:"flex items-center justify-between",children:[Xe(Ru,{children:e.label}),jt("span",{className:"text-[11px] font-mono text-white/40",children:[r,e.suffix??""]})]}),Xe(Dn,{min:e.min,max:e.max,step:e.step,value:[r],onValueChange:([o])=>n(e.key,o)})]})}if(e.type==="rangeWithSteps"){let r=Number(t[e.key]??e.min);return jt(qa,{label:`${e.label} - ${r}`,children:[Xe(Dn,{value:[r],onValueChange:([o])=>n(e.key,o),min:e.min,max:e.max,step:(e.max-e.min)/Math.max(1,e.steps.length-1)}),Xe("div",{className:"flex justify-between mt-1",children:e.steps.map(o=>Xe("button",{className:ee("text-[10px] font-mono transition-colors",r===o.value?"text-blue-400":"text-white/25 hover:text-white/50"),onClick:()=>n(e.key,o.value),children:o.label},o.value))})]})}if(e.type==="numberInput")return Xe(pV,{label:e.label,value:Number(t[e.key]??e.min??0),min:e.min,max:e.max,step:e.step,unit:e.unit,onChange:r=>n(e.key,r),inline:!0});if(e.type==="stepperInt"){let r=Number(t[e.key]??e.min??1),o=e.step??1,a=e.min??-1/0,i=e.max??1/0;return Xe(qa,{label:e.label,children:jt("div",{className:"flex items-center gap-2",children:[Xe("button",{className:"w-8 h-8 flex items-center justify-center rounded-lg border border-white/10 bg-white/5 text-white/60 hover:bg-white/10 hover:text-white transition-colors text-base leading-none disabled:opacity-30 disabled:cursor-not-allowed",onClick:()=>n(e.key,Math.max(a,r-o)),disabled:r<=a,children:"\u2212"}),Xe("span",{className:"flex-1 text-center text-[13px] font-mono text-white tabular-nums",children:r}),Xe("button",{className:"w-8 h-8 flex items-center justify-center rounded-lg border border-white/10 bg-white/5 text-white/60 hover:bg-white/10 hover:text-white transition-colors text-base leading-none disabled:opacity-30 disabled:cursor-not-allowed",onClick:()=>n(e.key,Math.min(i,r+o)),disabled:r>=i,children:"+"})]})})}if(e.type==="textInput")return Xe(qa,{label:e.label,children:Xe("input",{type:"text",className:"w-full bg-white/5 border border-white/10 rounded-lg px-3 py-2 text-[12px] text-white focus:outline-none focus:border-blue-500/60 placeholder:text-white/20",value:String(t[e.key]??""),placeholder:e.placeholder,maxLength:e.maxLength,onChange:r=>n(e.key,r.target.value),onKeyDown:r=>r.stopPropagation()})});if(e.type==="select"){let r=String(t[e.key]??e.options[0]?.value??"");return jt("div",{className:"flex items-center justify-between gap-4",children:[Xe(Ru,{children:e.label}),Xe("div",{className:"relative",children:jt(Ha,{children:[Xe(Va,{asChild:!0,children:jt(pr,{variant:"outline",className:"flex flex-row gap-1 h-8",children:[r,Xe(Zn,{})]})}),Xe(va,{className:"z-[201]",children:e.options.map(o=>Xe(ta,{onSelect:()=>n(e.key,o.value),children:o.label}))})]})})]})}if(e.type==="buttonGroup"){let r=String(t[e.key]??e.options[0]?.value??"");return Xe(qa,{label:e.label,children:Xe("div",{className:"flex gap-1.5 flex-wrap",children:e.options.map(o=>jt("button",{className:ee("flex items-center gap-1.5 px-3 py-1.5 rounded-lg border text-[11px] transition-colors",r===o.value?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n(e.key,o.value),children:[o.icon,o.label]},o.value))})})}if(e.type==="toggledInput"){let r=!!t[e.toggleKey],o=Number(t[e.inputKey]??e.min??0);return Xe(qa,{label:"",children:jt("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg border border-white/6 bg-white/3",children:[Xe(Qr,{checked:r,onCheckedChange:a=>n(e.toggleKey,a),className:"data-[state=checked]:bg-blue-500"}),Xe("span",{className:ee("text-[12px] flex-1",r?"text-white":"text-white/40 select-none"),children:e.toggleLabel}),jt("div",{className:ee("flex items-center gap-1.5 transition-opacity",!r&&"opacity-30 pointer-events-none"),children:[Xe("input",{type:"number",className:"w-16 bg-white/5 border border-white/10 rounded-md px-2 py-1 text-[12px] font-mono text-white text-right focus:outline-none focus:border-blue-500/60",value:o,min:e.min,max:e.max,step:e.step??1,onChange:a=>n(e.inputKey,parseFloat(a.target.value)||0),onKeyDown:a=>a.stopPropagation(),tabIndex:r?0:-1}),e.unit&&Xe("span",{className:"text-[11px] text-white/35",children:e.unit})]})]})})}return e.type==="inlineFields"?Xe(qa,{label:e.label,children:Xe("div",{className:"flex items-center gap-2 flex-wrap",children:e.fields.map((r,o)=>{if(r.type==="stepperInt"){let a=Number(t[r.key]??r.min??1),i=r.step??1,s=r.min??-1/0,l=r.max??1/0;return jt("div",{className:"flex items-center gap-1 bg-white/4 border border-white/8 rounded-lg px-1",children:[Xe("button",{className:"w-6 h-7 flex items-center justify-center text-white/50 hover:text-white transition-colors leading-none disabled:opacity-30",onClick:()=>n(r.key,Math.max(s,a-i)),disabled:a<=s,children:"\u2212"}),Xe("span",{className:"text-[12px] font-mono text-white tabular-nums min-w-[2ch] text-center",children:a}),Xe("button",{className:"w-6 h-7 flex items-center justify-center text-white/50 hover:text-white transition-colors leading-none disabled:opacity-30",onClick:()=>n(r.key,Math.min(l,a+i)),disabled:a>=l,children:"+"}),r.label&&Xe("span",{className:"text-[10px] text-white/30 pr-1.5",children:r.label})]},o)}if(r.type==="buttonGroup"){let a=String(t[r.key]??r.options[0]?.value??"");return Xe("div",{className:"flex gap-1",children:r.options.map(i=>Xe("button",{title:i.label,className:ee("w-7 h-7 flex items-center justify-center rounded-lg border text-[11px] transition-colors",a===i.value?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n(r.key,i.value),children:i.icon??i.label[0]},i.value))},o)}if(r.type==="checkbox"){let a=!!t[r.key];return jt("button",{className:ee("flex items-center gap-1.5 px-2.5 h-7 rounded-lg border text-[11px] transition-colors",a?"border-blue-500/60 bg-blue-500/10 text-white":"border-white/8 bg-white/3 text-white/40 hover:border-white/20 hover:text-white/70"),onClick:()=>n(r.key,!a),children:[a&&Xe(Or,{size:10,strokeWidth:3}),r.label]},o)}return null})})}):null}function pV({label:e,value:t,min:n,max:r,step:o,unit:a,onChange:i,inline:s}){let[l,c]=Yh(()=>String(t)),u=Lu(!1);Nv(()=>{u.current||c(String(t))},[t]);let d=()=>{let f=parseFloat(l);if(isNaN(f))c(String(t));else{let h=Math.min(r??1/0,Math.max(n??-1/0,f));i(h),c(String(h))}},m=Xe("input",{type:"number",min:n,max:r,step:o??1,value:l,onChange:f=>c(f.target.value),onFocus:()=>{u.current=!0},onBlur:()=>{u.current=!1,d()},onKeyDown:f=>{f.stopPropagation(),f.key==="Enter"&&d()},className:ee("bg-white/5 border border-white/10 rounded-md px-2 py-1 text-[12px] font-mono text-white/80 focus:outline-none focus:border-blue-500/50 text-right",s?"w-20":"flex-1")});return s?jt("div",{className:"flex items-center justify-between gap-4",children:[Xe(Ru,{children:e}),jt("div",{className:"flex items-center gap-1.5",children:[m,a&&Xe("span",{className:"text-[11px] text-white/30",children:a})]})]}):Xe(qa,{label:e,children:jt("div",{className:"flex items-center gap-2",children:[m,a&&Xe("span",{className:"text-[11px] text-white/35 shrink-0",children:a})]})})}function Ru({children:e}){return Xe("p",{className:"text-[12px] text-white/70",children:e})}function qa({label:e,children:t}){return jt("div",{className:"flex flex-col gap-2",children:[e&&Xe("p",{className:"text-[10px] font-semibold text-white/35 uppercase tracking-widest",children:e}),t]})}function ac({value:e,onChange:t}){return jt("div",{className:"flex flex-col gap-2",children:[Xe("div",{className:"grid grid-cols-8 gap-1.5",children:cV.map(n=>Xe("button",{className:ee("w-7 h-7 rounded-full border-2 transition-all hover:scale-110 flex items-center justify-center",e===n?"border-white scale-110":"border-white/10"),style:{background:n},onClick:()=>t(n),children:e===n&&Xe(Or,{size:11,className:"text-black drop-shadow",strokeWidth:3})},n))}),Xe(Lo,{onChange:t,value:e,className:"w-8 h-8 rounded-md border-2 border-border/50"})]})}var ic=60000000000n,Kh=class{constructor(){ae(this,"segments",[]);ae(this,"totalMarketNs",0n);ae(this,"rangeFrom",0n);ae(this,"rangeTo",0n);ae(this,"version",0)}_buildSegments(t,n,r,o){let a=Number(n/ic),i=Number(r/ic)+1,s=Ps(BigInt(a)*ic,t.timezone),l=s.minuteOfDay,c=s.dayOfWeek,u=s.isoDate,d=!1,m=0,f=[],h=o;for(let p=a;p<=i;p++){let g=bp(t,l,c,u);if(g&&!d)m=p<a?a:p,d=!0;else if(!g&&d){let y=m===a?n:BigInt(m)*ic,v=BigInt(p)*ic,b=v-y;f.push({realStart:y,realEnd:v,marketStart:h,duration:b}),h+=b,d=!1}l++,l%60===0&&(s=Ps(BigInt(p+1)*ic,t.timezone),l=s.minuteOfDay,c=s.dayOfWeek,u=s.isoDate)}if(d){let p=m===a?n:BigInt(m)*ic,g=r-p;g>0n&&(f.push({realStart:p,realEnd:r,marketStart:h,duration:g}),h+=g)}return{segments:f,totalNs:h-o}}build(t,n,r){if(this.rangeFrom=n,this.rangeTo=r,this.segments=[],this.totalMarketNs=0n,this.version++,!t||t.hours==="24/7"||t.hours==="always"){this.segments.push({realStart:n,realEnd:r,marketStart:0n,duration:r-n}),this.totalMarketNs=r-n;return}let{segments:o,totalNs:a}=this._buildSegments(t,n,r,0n);this.segments=o,this.totalMarketNs=a}extendBackward(t,n){if(n>=this.rangeFrom)return;if(this.version++,!t||t.hours==="24/7"||t.hours==="always"){let a=this.rangeFrom-n;if(this.segments.length===1){let i=this.segments[0];this.segments[0]={realStart:n,realEnd:i.realEnd,marketStart:0n,duration:i.duration+a}}else{for(let i of this.segments)i.marketStart+=a;this.segments.unshift({realStart:n,realEnd:this.rangeFrom,marketStart:0n,duration:a})}this.totalMarketNs+=a,this.rangeFrom=n;return}let{segments:r,totalNs:o}=this._buildSegments(t,n,this.rangeFrom,0n);for(let a of this.segments)a.marketStart+=o;this.segments=[...r,...this.segments],this.totalMarketNs+=o,this.rangeFrom=n}get hasSession(){return this.segments.length>1||this.segments.length===1&&this.segments[0].realStart>this.rangeFrom}segmentAt(t){let n=0,r=this.segments.length-1;for(;n<=r;){let o=n+r>>>1,a=this.segments[o];if(t>=a.realEnd)n=o+1;else if(t<a.realStart)r=o-1;else return a}return null}tsToMarket(t){if(this.segments.length===0)return t;if(this.segments.length===1&&!this.hasSession)return t-this.rangeFrom;let n=0,r=this.segments.length-1;for(;n<=r;){let l=n+r>>>1,c=this.segments[l];if(t>=c.realEnd)n=l+1;else if(t<c.realStart)r=l-1;else return c.marketStart+(t-c.realStart)}if(n>=this.segments.length){let l=this.segments[this.segments.length-1];return l.marketStart+l.duration+(t-l.realEnd)}if(n===0){let l=this.segments[0];return l.marketStart-(l.realStart-t)}let o=this.segments[n-1],a=this.segments[n],i=t-o.realEnd,s=a.realStart-t;return i<=s?o.marketStart+o.duration:a.marketStart}marketToTs(t){if(this.segments.length===0)return this.rangeFrom+t;if(this.segments.length===1&&!this.hasSession)return this.rangeFrom+t;let n=0,r=this.segments.length-1;for(;n<=r;){let a=n+r>>>1,i=this.segments[a],s=i.marketStart+i.duration;if(t>=s)n=a+1;else if(t<i.marketStart)r=a-1;else return i.realStart+(t-i.marketStart)}if(n>=this.segments.length){let a=this.segments[this.segments.length-1];return a.realEnd+(t-(a.marketStart+a.duration))}let o=this.segments[0];return o.realStart-(o.marketStart-t)}getBreaks(){return this.segments.map(t=>({ts:t.realStart,type:"break ig something idk this is just a placeholder"}))}realSpanToMarketSpan(t,n){return this.tsToMarket(n)-this.tsToMarket(t)}tsToX(t,n,r,o){if(this.segments.length===0)return Number(t-n)/Number(r-n)*o;let a=this.tsToMarket(n),i=this.tsToMarket(r),s=this.tsToMarket(t),l=Number(i-a);return l===0?0:Number(s-a)/l*o}xToTs(t,n,r,o){if(this.segments.length===0)return n+BigInt(Math.round(t/o*Number(r-n)));let a=this.tsToMarket(n),i=this.tsToMarket(r),s=Number(i-a);if(s===0)return n;let l=a+BigInt(Math.round(t/o*s));return this.marketToTs(l)}};function Ov(){return new Kh}import{useEffect as gV,useState as pR}from"react";import{Fragment as hR,jsx as cs,jsxs as Ua}from"react/jsx-runtime";function bV(e,t,n,r,o,a,i,s,l,c,u){if(c==="l3"){if(t.length===0)return null;let d=BigInt(Math.min(Number(o.tMin+BigInt(Math.round(e/a*Number(o.tMax-o.tMin)))),Number(l))),m=i>0n?(d+i/2n)/i*i:d,f=0,h=t.length-1,p=0;for(;f<=h;){let x=f+h>>>1;t[x].ts<=m?(p=x,f=x+1):h=x-1}let g=t[p],y=0,v=0,b=0,S=0,C=0,w=0;if(i>0n&&s){let x=(d+i/2n)/i*i,T=s.get(x);T&&(y=T.open,v=T.high,b=T.low,S=T.close,C=T.volume,w=T.delta)}let k=t[0].bestBid,M=g.bestBid-k,I=k!==0?M/k*100:0;return{bestAsk:g.bestAsk,bestBid:g.bestBid,open:y,high:v,low:b,close:S,volume:C,delta:w,change:M,changePct:I}}if(c==="ohlcv"){let d=BigInt(Number(u.xToTs(e,a))),m=Number((d+i/2n)/i*i/1000000n),f=Number(l/i*i/1000000n),h=r?{time:Number(r.ts/i*i/1000000n),open:r.open,high:r.high,low:r.low,close:r.close,volume:r.totalVol}:null,p=[...n.filter(M=>M.time<f),...h?[h]:[]],g=0,y=p.length-1,v=p.length-1;for(;g<=y;){let M=g+y>>>1;p[M].time<=m?(v=M,g=M+1):y=M-1}let b=p[v];if(!b)return null;let S=Math.floor(b.time/(1e3*60*60*24))*(1e3*60*60*24),C=p.filter(M=>M.time>=S)[0]?.open??b.open,w=b.close-C,k=C!==0?w/C*100:0;return{bestAsk:b.close,bestBid:b.close,open:b.open,high:b.high,low:b.low,close:b.close,volume:Math.round(b.volume*1e8)/1e8,delta:0,change:w,changePct:k}}return null}function gR({cellId:e,eventBus:t,chartType:n,chartSettings:r}){let[o,a]=pR(null),[i,s]=pR("ohlcv");if(gV(()=>t.on("status:compute",d=>{d.cellId===e&&(s(d.dataLevel),a(bV(d.x,d.priceHistory,d.bars,d.openBar,d.bounds,d.chartW,d.barNs,d.candleCache,d.horizon,d.dataLevel,d.transformer)))}),[t,e]),!r.showStatusLine||!o)return cs("div",{});let l=r.statusLineFontSize,c=Math.round(l*1.45),u=2;return cs("div",{className:"min-w-0",children:Ua("div",{className:"flex items-center gap-x-3 flex-wrap tabular-nums overflow-hidden",style:{fontSize:l,lineHeight:`${c}px`,rowGap:`${u}px`,maxHeight:`${c*2+u}px`},children:[r.statusLineOHLC&&(n==="candles"||n==="footprint"||n==="hollow"||n==="heikin-ashi"||n==="bars"||n==="renko"||n==="kagi"||n==="line-break")&&o.open!==0&&Ua(hR,{children:[Ua("span",{className:"text-white/50",children:["O"," ",cs("span",{className:"text-white/80",children:o.open.toFixed(2)})]}),Ua("span",{className:"text-white/50",children:["H"," ",cs("span",{className:"text-[#00e676]",children:o.high.toFixed(2)})]}),Ua("span",{className:"text-white/50",children:["L"," ",cs("span",{className:"text-[#ff1744]",children:o.low.toFixed(2)})]}),Ua("span",{className:"text-white/50",children:["C"," ",cs("span",{className:"text-white/80",children:o.close.toFixed(2)})]})]}),(n==="line"||n==="area"||n==="step"||n==="baseline")&&Ua(hR,{children:[Ua("span",{className:"text-white/50",children:["A"," ",cs("span",{className:"text-[#ff1744]",children:o.bestAsk.toFixed(2)})]}),Ua("span",{className:"text-white/50",children:["B"," ",cs("span",{className:"text-[#00e676]",children:o.bestBid.toFixed(2)})]})]}),r.statusLineVolume&&o.volume>0&&Ua("span",{className:"text-white/50",children:["Vol ",cs("span",{className:"text-white/80",children:o.volume})]}),r.statusLineDelta&&o.volume>0&&i==="l3"&&Ua("span",{className:ee(o.delta>=0?"text-[#00e676]":"text-[#ff1744]"),children:["\u0394 ",o.delta>=0?"+":"",o.delta]}),r.statusLineChange&&Ua("span",{className:ee(o.change>=0?"text-[#00e676]":"text-[#ff1744]"),children:[o.change>=0?"+":"",o.change.toFixed(2)," (",o.changePct.toFixed(2),"%)"]})]})})}import{useEffect as IV,useState as xR}from"react";import{useEffect as $h,useRef as yV,useState as _v}from"react";import{jsx as $r,jsxs as na}from"react/jsx-runtime";function Fv(e){let t=e.match(/^(\d{2})(\d{2})-(\d{2})(\d{2})$/);return t?{openMin:parseInt(t[1])*60+parseInt(t[2]),closeMin:parseInt(t[3])*60+parseInt(t[4])}:null}function Zf(e){let t=Math.floor(e/60)%24,n=e%60;return`${t===0?12:t>12?t-12:t}:${String(n).padStart(2,"0")} ${t>=12?"PM":"AM"}`}function bR(e){if(e==="24/7"||e==="always")return"24 / 7";let t=Fv(e);return t?`${Zf(t.openMin)} \u2013 ${Zf(t.closeMin)}`:e}function vV(e){try{let t=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"short"}).formatToParts(new Date).find(r=>r.type==="timeZoneName")?.value??"",n=e.split("/").pop()?.replace(/_/g," ")??e;return t?`${n} (${t})`:n}catch{return e}}var wV=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],yR=["Mon","Tue","Wed","Thu","Fri"];function xV(e){return e.length===7?"Every day":e.join(",")===yR.join(",")?"Mon \u2013 Fri":e.join(", ")}function SV(e){return!e||e.hours==="24/7"||e.hours==="always"}function CV(e){let t=Math.floor(e/6e4),n=Math.floor(t/60),r=t%60;return n===0?`${r}m`:r===0?`${n}h`:`${n}h ${r}m`}function kV({session:e,nowMs:t}){let n=SV(e),r=e?.timezone??"UTC",o=1440,a=BigInt(t)*1000000n,i=Ps(a,r),s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],l=e?.days??(n?wV:yR),c=s[i.dayOfWeek],u=e?.holidays?.includes(i.isoDate)??!1,d=!u&&l.includes(c),m=Ps(a-86400000000000n,r),h=!(e?.holidays?.includes(m.isoDate)??!1)&&l.includes(s[m.dayOfWeek]),p=e?.corrections?.find(T=>T.date===i.isoDate)??null,g=n?"24/7":p?.hours??e.hours,y=null;try{let T=new Intl.DateTimeFormat("en-US",{timeZone:r,hour:"numeric",minute:"numeric",hour12:!1}).formatToParts(new Date(t||Date.now())),R=parseInt(T.find(D=>D.type==="hour")?.value??"0"),P=parseInt(T.find(D=>D.type==="minute")?.value??"0");y=(R===24?0:R)*60+P}catch{}let v=T=>`${(T/o*100).toFixed(2)}%`,b=(T,R,P,D)=>$r("div",{className:"absolute top-0 bottom-0",style:{left:v(T),width:`${((R-T)/o*100).toFixed(2)}%`,backgroundColor:P}},D),S=n?null:Fv(g),C=S?S.closeMin<=S.openMin:!1,w=C&&h&&!u&&(S?.closeMin??0)>0,k=n&&!u||d||w,M=n&&!u?b(0,o,"#3b82f6","always"):null,I=[];S&&!u&&(C?(d&&I.push(b(S.openMin,o,"#3b82f6","main-open")),w&&I.push(b(0,S.closeMin,"#3b82f6","main-yest"))):d&&I.push(b(S.openMin,S.closeMin,"#3b82f6","main")));let x=[];if(!u&&e?.subsessions)for(let T=0;T<e.subsessions.length;T++){let R=e.subsessions[T],P=Fv(R.hours);if(!P)continue;let D=R.days??l;P.closeMin<=P.openMin?(D.includes(c)&&x.push(b(P.openMin,o,"rgb(245 158 11)",`sub-${T}-open`)),P.closeMin>0&&D.includes(s[m.dayOfWeek])&&x.push(b(0,P.closeMin,"rgb(245 158 11)",`sub-${T}-yest`))):D.includes(c)&&x.push(b(P.openMin,P.closeMin,"rgb(245 158 11)",`sub-${T}`))}return na("div",{className:"px-3 pt-2.5 pb-3 space-y-2",children:[na("div",{className:"relative h-4",children:[na("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full overflow-hidden bg-muted/50",children:[M,x,I]}),y!==null&&$r("div",{className:"absolute top-0 bottom-0 w-px rounded-full bg-foreground/50",style:{left:v(y)}})]}),na("div",{className:"space-y-0.5",children:[u?$r("div",{className:"text-[10px] font-medium text-amber-500/80",children:"Holiday \u2013 closed"}):n?na("div",{className:"text-[10px] font-medium tabular-nums text-foreground/80",children:["Open ",bR("24/7")]}):k?d&&S?na("div",{className:"text-[10px] font-medium tabular-nums text-foreground/80",children:[Zf(S.openMin)," \u2013 ",Zf(S.closeMin),p&&$r("span",{className:"ml-1.5 text-amber-500/80 font-normal",children:"(modified)"})]}):w&&S?na("div",{className:"text-[10px] font-medium tabular-nums text-foreground/60",children:["Closes ",Zf(S.closeMin)]}):null:$r("div",{className:"text-[10px] font-medium text-muted-foreground",children:"No session today"}),na("div",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[$r("span",{children:vV(r)}),$r(Vs,{className:"-mx-2"}),$r("span",{children:xV(l)})]})]}),(e?.subsessions?.length??0)>0&&$r("div",{className:"space-y-1 pt-1.5 border-t border-border/40",children:e.subsessions.map(T=>na("div",{className:"flex items-center justify-between",children:[na("div",{className:"flex items-center gap-1.5",children:[$r("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-500/60 shrink-0"}),$r("span",{className:"text-[10px] text-muted-foreground",children:T.label})]}),$r("span",{className:"text-[10px] tabular-nums text-muted-foreground/80",children:bR(T.hours)})]},T.id))})]})}function vR({eventBus:e,session:t,horizon:n,sessionStatus:r,symbol:o}){let[a,i]=_v(!1),[s,l]=_v(()=>Number(n/1000000n)),c=yV(n),[u,d]=_v(r);if($h(()=>e.on("playback:seek",({tNs:b})=>{c.current=b}),[e]),$h(()=>e.on("session:status",b=>{b.symbol!==void 0&&o!==void 0&&b.symbol!==o||d(b)}),[e,o]),$h(()=>{if(!t||t.hours==="24/7"||t.hours==="always")return;let S=setInterval(()=>{l(Number(c.current/1000000n)),d(Pi(t,c.current))},1e3);return()=>clearInterval(S)},[t]),$h(()=>{if(!a)return;l(Number(c.current/1000000n));let b=setInterval(()=>l(Number(c.current/1000000n)),33);return()=>clearInterval(b)},[a]),!u)return null;let m=u.kind==="open"||u.kind==="always"?"#22c55e":u.kind==="sub"?"#f59e0b":"#6b7280",f=u.kind==="open"||u.kind==="always"?"Open":u.kind==="sub"?u.label:"Closed",h=u.kind==="closed",p=u.kind==="open"||u.kind==="always",g=u.kind==="sub",y=null;if(h&&t&&t.hours!=="24/7"&&t.hours!=="always")try{let b=BigInt(s)*1000000n,S=rd(t,b),C=Number((S-b)/1000000n);C>0&&(y=CV(C))}catch{}let v=h&&y?`Opens in ${y}`:p?"Regular session":g?"Extended hours":null;return $r("div",{className:"flex items-center mx-2",children:na(xu,{open:a,onOpenChange:i,children:[$r(Su,{asChild:!0,children:$r("button",{className:"w-2 h-2 rounded-full shrink-0 cursor-pointer focus:outline-none group relative",style:{backgroundColor:m},children:$r("div",{className:ee("absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-4 h-4 rounded-full",!a&&"opacity-0 group-hover:opacity-100"),style:{backgroundColor:m+"44"}})})}),na(Zl,{className:"w-72 p-0 overflow-hidden text-xs",align:"start",sideOffset:8,children:[na("div",{className:"flex items-center gap-2.5 px-3 py-2.5 border-b border-border/60",children:[$r("div",{className:"w-2 h-2 rounded-full shrink-0 mt-px",style:{backgroundColor:m}}),na("div",{children:[$r("div",{className:"font-medium text-foreground leading-tight",children:f}),v&&$r("div",{className:"text-muted-foreground text-[10px] mt-0.5 leading-tight",children:v})]})]}),$r(kV,{session:t,nowMs:s})]})]})})}import{Fragment as TV,jsx as Qf}from"react/jsx-runtime";function Xh({icon:e,size:t=24,className:n,fallback:r}){let o=typeof e=="string"?{src:e}:e;return o?"render"in o?Qf(TV,{children:o.render({size:t})}):"src"in o?Qf("img",{src:o.src,alt:o.alt??"",width:t,height:t,className:ee("rounded-full object-cover shrink-0",n),style:{width:t,height:t}}):Qf(wR,{text:o.text,color:o.color,size:t,className:n}):r?Qf(wR,{text:r,size:t,className:n}):null}function wR({text:e,color:t,size:n,className:r}){return Qf("span",{className:ee("inline-flex items-center justify-center rounded-full bg-[#21242C] font-semibold shrink-0 select-none",r),style:{width:n,height:n,fontSize:Math.round(n*.4),color:t??"#9ca3af"},children:e.slice(0,3).toUpperCase()})}import{Fragment as MV,jsx as sn,jsxs as Do}from"react/jsx-runtime";function SR({pane:e,indicators:t,onToggleIndicator:n,onRemoveIndicator:r,onOpenSettings:o,onOpenTfSelect:a,eventBus:i,session:s,horizon:l,sessionStatus:c,statusBar:u,symbolInfo:d}){let[m,f]=xR(null),h=t.filter(p=>p.paneId===e.id||p.layout==="overlay"&&e.isMain);return sn("div",{className:"flex items-center justify-between px-2 h-7 z-10 w-full min-w-0",style:{pointerEvents:"none"},children:Do("div",{className:"flex gap-1 min-w-0 flex-col pt-1 h-full w-full",children:[e.isMain&&Do("div",{className:"flex flex-row items-center flex-wrap gap-x-2 gap-y-0.5 min-w-0",children:[Do("div",{className:"flex items-center gap-0.5 hover:bg-[#1a1d23] rounded-sm border border-transparent hover:border-border",style:{pointerEvents:"auto"},onMouseEnter:()=>f(e.id),onMouseLeave:()=>f(null),onMouseDown:p=>{p.button===1&&r(e.id)},children:[Do("span",{className:"text-[1rem] text-white/90 flex items-center gap-0.5 select-none cursor-default hover:bg-muted px-1.5 rounded-sm -mr-1",onClick:()=>i.emit("chart:open-symbol-select",{}),children:[(d?.legendIcon??d?.icon)&&sn("span",{className:"pr-1",children:sn(Xh,{icon:d?.legendIcon??d?.icon,size:18})}),d?.longName??e.symbol]}),sn(Vs,{className:"text-muted-foreground w-2"}),sn("span",{className:"text-[1rem] text-white/90 select-none cursor-default hover:bg-muted px-1.5 rounded-sm -mx-1",onClick:a,children:e.tf}),sn(Vs,{className:"text-muted-foreground w-2 -ml-px"}),sn("span",{className:"text-[1rem] text-white/90 select-none cursor-default ml-px",children:e.exchange}),c&&sn(vR,{eventBus:i,session:s,horizon:l,sessionStatus:c,symbol:d?.symbol})]}),u]}),sn("div",{className:"flex flex-col gap-0 -ml-1",children:h.map(p=>Do("div",{className:"flex items-center gap-0.5 self-start py-0.5 hover:bg-[#1a1d23] rounded-sm px-1 duration-100 hover:duration-0 border border-transparent hover:border-border",style:{pointerEvents:"auto"},onMouseEnter:()=>f(p.id),onMouseLeave:()=>f(null),onMouseDown:g=>{g.button===1&&r(p.id)},onDoubleClick:()=>{o(p.id)},children:[sn("span",{className:ee("text-[13px] text-muted-foreground select-none mr-1 cursor-default",!p.visible&&"opacity-50"),children:p.name}),Do("div",{className:ee("flex items-center gap-0.5 transition-opacity duration-100",m===p.id?"opacity-100":"opacity-0"),children:[Do(Ht,{delayDuration:700,children:[sn(Ot,{asChild:!0,children:sn("button",{className:"p-0.5 px-1 rounded hover:bg-white/10 text-muted-foreground hover:text-foreground transition-colors",onClick:()=>n(p.id),children:p.visible?sn(Da,{size:13}):sn(Bi,{size:13})})}),sn(_t,{className:"bg-background border border-border",children:p.visible?"Hide indicator":"Show indicator"})]}),Do(Ht,{delayDuration:700,children:[sn(Ot,{asChild:!0,children:sn("button",{className:"p-0.5 px-1 rounded hover:bg-white/10 text-muted-foreground hover:text-foreground transition-colors",onClick:()=>o(p.id),children:sn(cf,{size:13})})}),sn(_t,{className:"bg-background border border-border",children:"Settings"})]}),Do(Ht,{delayDuration:700,children:[sn(Ot,{asChild:!0,children:sn("button",{className:"p-0.5 px-1 rounded hover:bg-white/10 text-muted-foreground hover:text-red-400 transition-colors",onClick:()=>r(p.id),children:sn(ho,{size:13})})}),sn(_t,{className:"bg-background border border-border",children:"Remove indicator"})]})]})]},p.id))})]})})}function CR({pane:e,paneIndex:t,totalPanes:n,onMoveUp:r,onMoveDown:o,onRemovePane:a,onCollapse:i,onMaximize:s,isMaximized:l,isCollapsed:c,onEnter:u,onLeave:d,eventBus:m}){let[f,h]=xR(null);return IV(()=>m.on("pane:hovered",p=>p&&h(p.id)),[m]),Do("div",{className:ee("flex items-center gap-0.5 transition-opacity duration-100 shrink-0",f===e.id?"opacity-100":"opacity-0"),style:{pointerEvents:f===e.id?"auto":"none"},onMouseEnter:u,onMouseLeave:d,children:[t>0&&Do(Ht,{delayDuration:700,children:[sn(Ot,{asChild:!0,children:sn("button",{className:"p-0.5 rounded hover:bg-white/10 text-muted-foreground hover:text-foreground transition-colors",onClick:()=>r(e.id),children:sn(Ed,{size:12})})}),sn(_t,{className:"bg-background border border-border",children:"Move pane up"})]}),t<n-1&&Do(Ht,{delayDuration:700,children:[sn(Ot,{asChild:!0,children:sn("button",{className:"p-0.5 rounded hover:bg-white/10 text-muted-foreground hover:text-foreground transition-colors",onClick:()=>o(e.id),children:sn(Ad,{size:12})})}),sn(_t,{className:"bg-background border border-border",children:"Move pane down"})]}),!e.isMain&&Do(MV,{children:[Do(Ht,{delayDuration:700,children:[sn(Ot,{asChild:!0,children:sn("button",{className:"p-0.5 rounded hover:bg-white/10 text-muted-foreground hover:text-red-400 transition-colors",onClick:()=>a(e.id),children:sn(_r,{size:12})})}),sn(_t,{className:"bg-background border border-border",children:"Remove pane"})]}),Do(Ht,{delayDuration:700,children:[sn(Ot,{asChild:!0,children:sn("button",{className:ee("p-0.5 rounded hover:bg-white/10 text-muted-foreground hover:text-foreground transition-colors",c&&"bg-muted text-white"),onClick:()=>i(e.id),children:c?sn(Hd,{size:12}):sn(Fd,{size:12})})}),sn(_t,{className:"bg-background border border-border",children:"Collapse pane"})]})]}),Do(Ht,{delayDuration:700,children:[sn(Ot,{asChild:!0,children:sn("button",{className:ee("p-0.5 rounded hover:bg-white/10 text-muted-foreground hover:text-foreground transition-colors",l&&"bg-muted text-white"),onClick:()=>s(e.id),children:l?sn(Jd,{size:12}):sn(Qd,{size:12})})}),sn(_t,{className:"bg-background border border-border",children:l?"Restore panes":"Maximize pane"})]})]})}import{useEffect as kR,useRef as LV,useState as TR}from"react";import{jsx as sc,jsxs as PR}from"react/jsx-runtime";function IR({icon:e,label:t,visible:n,className:r,style:o}){return PR("div",{className:ee("pointer-events-none absolute flex items-center gap-1.5 rounded-full","border border-border/60 bg-background/80 px-2 py-[3px] backdrop-blur-[2px]","text-[10.5px] leading-none text-muted-foreground","transition-opacity duration-300",n?"opacity-80":"opacity-0",r),style:o??{},children:[e,t]})}function MR(){return PR("svg",{width:9,height:9,viewBox:"0 0 24 24",fill:"none",className:"animate-spin [animation-duration:900ms]","aria-hidden":!0,children:[sc("circle",{cx:"12",cy:"12",r:"9.5",stroke:"currentColor",strokeWidth:"3",opacity:.2}),sc("path",{d:"M21.5 12A9.5 9.5 0 0 0 12 2.5",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function LR({eventBus:e,cellId:t}){let[n,r]=TR(!1);return kR(()=>e.on("heatmap:status",o=>{o.cellId!==void 0&&t!==void 0&&o.cellId!==t||r(o.recalculating)}),[e,t]),sc(IR,{icon:sc(MR,{}),label:"Rebuilding heatmap",visible:n,className:"bottom-9 left-2"})}function RR({eventBus:e,symbol:t,priceScaleWidth:n}){let[r,o]=TR(""),a=LV(null);kR(()=>{let l=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},c=()=>{l(),o("done"),a.current=window.setTimeout(()=>{o(""),a.current=null},1200)},u=m=>t===void 0||m===void 0||m===t,d=[e.on("data:status",m=>{m.status!=="loading"||!u(m.symbol)||(l(),o("loading"))}),e.on("data:preview",m=>{u(m.symbol)&&(l(),o("preview"))}),e.on("data:load",m=>u(m.symbol)&&c()),e.on("data:prepend",m=>u(m.symbol)&&c())];return()=>{l(),d.forEach(m=>m())}},[e,t]);let i=r==="done"?sc(Or,{size:9,strokeWidth:3}):sc(MR,{}),s=r==="preview"?"Preview data":r==="done"?"Up to date":"Loading data";if(r)return sc(IR,{icon:i,label:s,visible:!0,className:"bottom-9",style:{right:n+8}})}import{useEffect as DR,useId as RV,useState as zv}from"react";import{jsx as hr,jsxs as us}from"react/jsx-runtime";function PV({size:e=20}){let t=RV();return us("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",className:"animate-spin [animation-duration:200ms]","aria-hidden":!0,children:[hr("defs",{children:us("linearGradient",{id:t,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[hr("stop",{offset:"0%",stopColor:"#16c4b0"}),hr("stop",{offset:"100%",stopColor:"#06b6d4"})]})}),hr("circle",{cx:"12",cy:"12",r:"9.5",stroke:"currentColor",strokeWidth:"2",opacity:.12}),hr("path",{d:"M21.5 12A9.5 9.5 0 0 0 12 2.5",stroke:`url(#${t})`,strokeWidth:"2",strokeLinecap:"round"})]})}function DV(e){let[t,n]=zv(e<=0),[r,o]=zv(!1);return DR(()=>{if(t)return;let a=setTimeout(()=>n(!0),e);return()=>clearTimeout(a)},[e,t]),DR(()=>{if(!t)return;let a=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(a)},[t]),{mounted:t,visible:r}}function AR({symbol:e,timeframe:t,delayMs:n=220}){let{mounted:r,visible:o}=DV(n);if(!r)return null;let a=[e,t].filter(Boolean).join(" \xB7 ");return hr("div",{className:ee("absolute inset-0 z-10 flex items-center justify-center","bg-background/75 backdrop-blur-[2px]","transition-opacity duration-200",o?"opacity-100":"opacity-0"),children:us("div",{className:"flex flex-col items-center gap-2.5 px-6 text-center",children:[hr(PV,{}),us("div",{className:"flex flex-col gap-0.5",children:[hr("span",{className:"text-[13px] leading-none text-white/80",children:"Loading market data"}),a&&hr("span",{className:"text-[11px] leading-none text-muted-foreground tabular-nums",children:a})]})]})})}function Hv(e,t,n){let r=n?`for ${n}`:"here";switch(e){case"no_data":return{tier:"empty",title:"No data here",body:`Nothing came back ${r} in this range. Try a wider range or another interval.`,icon:hr(sf,{size:18}),canRetry:!1};case"not_found":return{tier:"empty",title:"Symbol not found",body:n?`The data source doesn't know ${n}.`:"The data source doesn't have this symbol.",icon:hr(qs,{size:18}),canRetry:!1};case"unauthenticated":return{tier:"notice",title:"Session expired",body:"Sign in again to keep loading market data.",icon:hr(jr,{size:18}),canRetry:!1};case"forbidden":return{tier:"notice",title:"No access to this data",body:n?`This account can't load ${n}.`:"This account can't load this data.",icon:hr(jr,{size:18}),canRetry:!1};case"rate_limited":return{tier:"notice",title:"Rate limited",body:"The data source is throttling requests. Give it a moment.",icon:hr(mf,{size:18}),canRetry:!0};case"network_error":return{tier:"notice",title:"Can't reach the data source",body:"Check your connection and try again.",icon:hr(bf,{size:18}),canRetry:!0};case"server_error":return{tier:"notice",title:"The data source is having trouble",body:"Nothing wrong on your end. Try again in a moment.",icon:hr(lf,{size:18}),canRetry:!0};case"decode_error":return{tier:"error",title:"Couldn't read the response",body:"The data came back in a shape this chart can't read.",icon:hr(ba,{size:18}),canRetry:!0};default:return{tier:"error",title:"Couldn't load data",body:t?.trim()||"Something went wrong while loading this chart.",icon:hr(ba,{size:18}),canRetry:!0}}}function BR({code:e,message:t,symbol:n,timeframe:r,onRetry:o}){let[a,i]=zv(!1),{tier:s,title:l,body:c,icon:u,canRetry:d}=Hv(e,t,n);return hr("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background",children:us("div",{className:"flex max-w-[19rem] flex-col items-center gap-3 px-6 text-center",children:[hr("div",{className:ee("flex items-center justify-center",s==="empty"?"text-muted-foreground/70":s==="notice"?"h-10 w-10 rounded-full bg-amber-400/10 text-amber-400/90":"h-10 w-10 rounded-full bg-destructive/10 text-destructive"),children:u}),us("div",{className:"flex flex-col gap-1",children:[hr("span",{className:"text-[13px] font-semibold leading-snug text-white/90",children:l}),hr("span",{className:"text-[11.5px] leading-relaxed text-muted-foreground",children:c}),(n||r)&&s==="empty"&&hr("span",{className:"mt-0.5 text-[11px] leading-none text-muted-foreground/60 tabular-nums",children:[n,r].filter(Boolean).join(" \xB7 ")})]}),d&&o&&us("button",{onClick:o,className:ee("inline-flex items-center gap-1.5 rounded-md border border-border","bg-muted/40 px-2.5 py-1 text-[11.5px] font-medium text-white/80","transition-colors hover:bg-muted hover:text-white"),children:[hr(rf,{size:11}),"Try again"]}),(e||t)&&us("div",{className:"flex flex-col items-center gap-1",children:[hr("button",{onClick:()=>i(m=>!m),className:"text-[10.5px] text-muted-foreground/50 underline-offset-2 transition-colors hover:text-muted-foreground hover:underline",children:a?"Hide details":"Details"}),a&&us("div",{className:"flex flex-col gap-0.5 text-[10.5px] leading-relaxed text-muted-foreground/60",children:[hr("span",{className:"font-mono tabular-nums",children:e||"unknown"}),t&&hr("span",{className:"break-words",children:t})]})]})]})})}var AV=`(()=>{var S=[250000000n,1000000000n,5000000000n,30000000000n],on=3,g=[],R=[],H=0n,q=null,O=!1,j=!1,B=null;function K(){if(j||!B)return;let e=B;B=null,j=!0,Promise.resolve().then(()=>{an(e),j=!1,B&&K()})}self.onmessage=async e=>{let n=e.data;if(n.type==="init"){if(g=[],R=[],O=!1,await ln(n.events),O=!0,q){let o=q;q=null,B=o,K()}return}if(n.type==="append"){let o=n.events;o?.length>0&&O&&await rn(o);return}if(n.type==="render"){if(!O){q=n;return}B=n,K()}};function an(e){let{requestId:n,bounds:o,chartW:a,chartH:s,horizonNs:i}=e,t={tMin:BigInt(o.tMin),tMax:BigInt(o.tMax),pMin:o.pMin,pMax:o.pMax},l=i?BigInt(i):null,u=un(t,a,s,l);if(!u)return;let f={requestId:n,bitmap:u,bounds:o};self.postMessage(f,[u])}function X(e){let n=Date.parse(e),o=n-n%1e3,a=BigInt(o)*1000000n,s=e.indexOf(".");if(s===-1)return a+BigInt(n%1e3)*1000000n;let i=s+1;for(;i<e.length&&e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57;)i++;let t=e.slice(s+1,i),l=BigInt(t.padEnd(9,"0").slice(0,9));return a+l}var Y=5e3;async function ln(e){let n={bids:new Map,asks:new Map},o=S.length,a=Array.from({length:o},()=>[]),s=new Array(o).fill(null),i=0n;for(let t=0;t<e.length;t++){t>0&&t%Y===0&&await new Promise(f=>setTimeout(f,0));let l=e[t],u=X(l.ts_event);i=u;for(let f=0;f<o;f++){let y=S[f];for(s[f]===null&&(s[f]=u/y*y);u>=s[f];)a[f].push(P(n,s[f])),s[f]=s[f]+y}$(n,l)}if(e.length>0){for(let t=0;t<o;t++)a[t].push(P(n,i));H=i}g=a,R=a[0],C.bids.clear(),C.asks.clear();for(let[t,l]of n.bids)C.bids.set(t,{...l});for(let[t,l]of n.asks)C.asks.set(t,{...l})}async function rn(e){let n=S.length;if(g.length!==n)return;let o=C,a=S.map((s,i)=>{let t=g[i];return t.length===0?0n:t[t.length-1].ts+s});for(let s=0;s<e.length;s++){s>0&&s%Y===0&&await new Promise(l=>setTimeout(l,0));let i=e[s],t=X(i.ts_event);for(let l=0;l<n;l++){let u=S[l];for(;t>=a[l];)g[l].push(P(o,a[l])),a[l]+=u}$(o,i),H=t}if(e.length>0)for(let s=0;s<n;s++)g[s].push(P(o,H));R=g[0]}var C={bids:new Map,asks:new Map};function cn(e){for(let n=0;n<S.length;n++)if(Number(S[n])>=e/on)return g[n]??R;return g[g.length-1]??R}var T=new Map,z=new Map;function P(e,n){T.clear(),z.clear();for(let t of e.bids.values()){let l=Math.round(t.price*100)/100;T.set(l,(T.get(l)??0)+t.size)}for(let t of e.asks.values()){let l=Math.round(t.price*100)/100;z.set(l,(z.get(l)??0)+t.size)}let o=new Float64Array(T.size*2),a=new Float64Array(z.size*2),s=0;for(let[t,l]of T)o[s++]=t,o[s++]=l;let i=0;for(let[t,l]of z)a[i++]=t,a[i++]=l;return U(o,!0),U(a,!1),{ts:n,bids:o,asks:a}}function U(e,n){let o=e.length;for(let a=2;a<o;a+=2){let s=e[a],i=e[a+1],t=a-2;for(;t>=0&&(n?e[t]<s:e[t]>s);)e[t+2]=e[t],e[t+3]=e[t+1],t-=2;e[t+2]=s,e[t+3]=i}}function un(e,n,o,a=null){if(g.length===0&&R.length===0)return null;let i=Number(e.tMax-e.tMin)/n,t=cn(i);if(t.length===0)return null;let l=Q(t,e.tMin),u=pn(t,e.tMax);if(l===-1?l=0:l=Math.max(0,l-1),u===-1?u=t.length-1:u=Math.min(t.length-1,u+1),a!==null){let k=Q(t,a);k!==-1&&k<u&&(u=k)}if(l>u)return null;let f=new OffscreenCanvas(n,o),y=f.getContext("2d");return y?(fn(y,t,l,u,e,n,o),f.transferToImageBitmap()):null}function fn(e,n,o,a,s,i,t){let l=Number(s.tMax-s.tMin),u=s.pMax-s.pMin;if(l===0||u===0)return;let y=a-o+1>i,k=[];if(y){let r=new Array(i).fill(null),c=new Array(i).fill(null);for(let p=o;p<=a;p++){let m=n[p],x=Math.min(i-1,Math.max(0,Math.round(Number(m.ts-s.tMin)/l*i)));r[x]||(r[x]={}),c[x]||(c[x]={});let F=r[x],E=c[x],_=m.bids;for(let d=0;d<_.length;d+=2){let b=_[d],M=_[d+1];(F[b]===void 0||M>F[b])&&(F[b]=M)}let A=m.asks;for(let d=0;d<A.length;d+=2){let b=A[d],M=A[d+1];(E[b]===void 0||M>E[b])&&(E[b]=M)}}let h=new Float64Array(0),w=new Float64Array(0);for(let p=0;p<i;p++)r[p]&&(h=J(r[p],!0),w=J(c[p],!1)),h.length>0&&k.push({x0:p,x1:p,bids:h,asks:w})}else{let r=[];for(let c=o;c<=a;c++)r.push(Math.round(Number(n[c].ts-s.tMin)/l*i));for(let c=0;c<r.length;c++){let h=n[o+c],w=Math.max(0,r[c]),p=c===r.length-1?i-1:Math.max(w,r[c+1]-1);p<0||w>=i||k.push({x0:w,x1:p,bids:h.bids,asks:h.asks})}}let I=1;for(let r of k){for(let c=1;c<r.bids.length;c+=2)r.bids[c]>I&&(I=r.bids[c]);for(let c=1;c<r.asks.length;c+=2)r.asks[c]>I&&(I=r.asks[c])}let W=Math.log1p(I),Z=e.createImageData(i,t),v=Z.data,G=(r,c,h,w)=>{let p=r.length;for(let m=0;m<p;m+=2){let x=r[m],F=r[m+1],_=Math.log1p(F)/W*210+.5|0;if(_===0)continue;let A,d,b;c?(A=20,d=220,b=80):(A=255,d=30,b=50);let M=t-(x-s.pMin)/u*t+.5|0,nn=m+2<p?r[m+2]:c?-1/0:1/0,D=m+2<p?t-(nn-s.pMin)/u*t+.5|0:c?t:0,en=Math.max(0,M<D?M:D),tn=Math.min(t-1,(M>D?M:D)-1);for(let L=en;L<=tn;L++){let sn=(L*i+h)*4;for(let V=h;V<=w;V++){let N=sn+(V-h)*4;v[N+3]<_&&(v[N]=A,v[N+1]=d,v[N+2]=b,v[N+3]=_)}}}};for(let r of k)G(r.bids,!0,r.x0,r.x1),G(r.asks,!1,r.x0,r.x1);e.putImageData(Z,0,0)}function J(e,n){let o=0;for(let i in e)o++;let a=new Float64Array(o*2),s=0;for(let i in e)a[s++]=+i,a[s++]=e[i];return U(a,n),a}function $(e,n){if(n.action==="R"){e.bids.clear(),e.asks.clear();return}let o=n.side;(n.action==="T"||n.action==="F")&&(o=o==="B"?"A":"B");let a=o==="B"?e.bids:e.asks;if(n.action==="A")a.set(n.order_id,{price:n.price,size:n.size});else if(n.action==="C")a.delete(n.order_id);else if(n.action==="M"){let s=a.get(n.order_id);s&&(n.price!==null&&(s.price=n.price),s.size=n.size)}else(n.action==="T"||n.action==="F")&&(e.bids.delete(n.order_id),e.asks.delete(n.order_id))}function Q(e,n){let o=0,a=e.length-1,s=-1;for(;o<=a;){let i=o+a>>>1;e[i].ts<=n?(s=i,o=i+1):a=i-1}return s}function pn(e,n){let o=0,a=e.length-1,s=-1;for(;o<=a;){let i=o+a>>>1;e[i].ts>=n?(s=i,a=i-1):o=i+1}return s}})();
|
|
87
|
+
`,Vv;function NR(){return Vv||(Vv=URL.createObjectURL(new Blob([AV],{type:"text/javascript"}))),Vv}var BV='(()=>{var k=new Map,l=new Map,f=new Map;function R(i){let n=k.get(i);return n||(n=new Function(`return (${i})`)(),k.set(i,n)),n}self.onmessage=i=>{let n=i.data;if(n.type==="compute"){let{requestId:a,trades:s,barNs:c,indicators:r,ohlcv:w=[],ticks:p=[],snapshots:u=[]}=n,e={},g={};for(let t of r)try{let o=R(t.workerInit)({trades:s,ohlcv:w,ticks:p,snapshots:u,barNs:c,params:t.params});f.set(t.id,o),e[t.id]=o}catch(d){g[t.id]=String(d),f.delete(t.id)}self.postMessage({type:"compute",requestId:a,results:e,errors:g});return}if(n.type==="register-update-fns"){let{indicators:a}=n;for(let{id:s,workerUpdate:c}of a)try{let r=new Function(`return (${c})`)();l.set(s,r)}catch(r){console.error(`[indicator-worker] Failed to compile workerUpdate for \'${s}\':`,r)}return}if(n.type==="horizon:advance"){let{requestId:a,newTrades:s,horizon:c,barNs:r,indicatorIds:w}=n,p={},u={};for(let{id:e,params:g}of w){let t=l.get(e);if(!t)continue;let d=f.get(e);if(d!==void 0)try{let o=n.ohlcv??[],m=n.ticks??[],h=n.snapshots??[],y=t({newTrades:s,ohlcv:o,ticks:m,snapshots:h,state:d,barNs:r,horizon:c,params:g});f.set(e,y.state),p[e]=y.points}catch(o){u[e]=String(o)}}self.postMessage({type:"horizon:advance",requestId:a,points:p,errors:u});return}};})();\n',Wv;function ER(){return Wv||(Wv=URL.createObjectURL(new Blob([BV],{type:"text/javascript"}))),Wv}import{useCallback as Dr,useEffect as _R,useRef as un}from"react";var NV=["A","C","M","T","F","R"],EV=["B","A","N"],OV=1e6;function ja(e=OV){let t=new ArrayBuffer(e*20);return{_buf:t,_view:new DataView(t),length:0,capacity:e,firstTs:0n,lastTs:0n}}var ds={ts_event:"",action:"A",side:"N",price:null,size:0,order_id:"0",sequence:0,flags:0};function fs(e,t){let n=t*20,r=e._view,o=r.getBigInt64(n,!0),a=r.getInt32(n+8,!0),i=r.getUint32(n+12,!0),s=r.getUint8(n+16),l=r.getUint8(n+17),c=r.getUint8(n+18),u=r.getUint8(n+19);return ds.action=NV[u>>4&15]??"A",ds.side=EV[u>>2&3]??"N",ds.price=a===-2147483648?null:a/100,ds.size=i,ds.order_id=String(s|l<<8|c<<16),ds.ts_event=_V(o),ds.sequence=t,ds.flags=0,ds}function ms(e,t){return e._view.getBigInt64(t*20,!0)}function Jf(e,t){if(e.length===0)return-1;let n=0,r=e.length-1,o=-1;for(;n<=r;){let a=n+r>>>1;ms(e,a)<=t?(o=a,n=a+1):r=a-1}return o}function _V(e){let t=Number(e/1000000n),n=Number(e%1000000n);return new Date(t).toISOString().slice(0,-1)+String(n).padStart(6,"0")+"Z"}function OR(e){return{tMin:e.tMin.toString(),tMax:e.tMax.toString(),pMin:e.pMin,pMax:e.pMax}}function lc(e,t,n){if(e.length===0||t<=0n)return e;let r=Number(t/1000000n);if(r<=0)return e;let o=!!n?.hasSession,a=0,i=0,s=!1,l=g=>{if(o){if(!s||g<a||g>=i){let y=n.segmentAt(BigInt(g)*1000000n);s=y!==null,y&&(a=Number(y.realStart/1000000n),i=Number(y.realEnd/1000000n))}if(s)return a+Math.floor((g-a)/r)*r}return Math.floor(g/r)*r},c=[],u=l(e[0].time),d=e[0].open,m=e[0].high,f=e[0].low,h=e[0].close,p=e[0].volume;for(let g=1;g<e.length;g++){let y=e[g],v=l(y.time);v!==u?(c.push({time:u,open:d,high:m,low:f,close:h,volume:p}),u=v,d=y.open,m=y.high,f=y.low,h=y.close,p=y.volume):(y.high>m&&(m=y.high),y.low<f&&(f=y.low),h=y.close,p+=y.volume)}return c.push({time:u,open:d,high:m,low:f,close:h,volume:p}),c}function FV(e,t,n,r){if(e.length===0)return t;let o=lc(e,n,r);if(o.length===0)return t;if(t.length===0)return o;let a=o[o.length-1],i=t[0];if(a.time===i.time){let s={time:a.time,open:a.open,high:Math.max(a.high,i.high),low:Math.min(a.low,i.low),close:i.close,volume:a.volume+i.volume};return[...o.slice(0,-1),s,...t.slice(1)]}return[...o,...t]}function Ar(e,t,n,r,o,a,i,s){if(!s)return;let l=1/0,c=0,u=!1,d=Number(e.tMin/1000000n),m=Number(e.tMax/1000000n),f=Number(i/1000000n),h=o?Number(o.ts/1000000n):1/0,p=Math.min(f,h),g=()=>{!o||h>=m||h>=f||(o.high>c&&(c=o.high),o.low<l&&(l=o.low),u||(e.pRef=o.high,u=!0))},y=(()=>{let v=0,b=r.length-1;for(;v<=b;){let S=v+b>>>1;r[S].time<d?v=S+1:b=S-1}return v})();if(a.chartType==="area"||a.chartType==="line"||a.chartType==="step"||a.chartType==="baseline"){if(s==="l3")for(let v of t)v.ts>i||v.ts<e.tMin||v.ts>=e.tMax||(v.bestAsk>c&&(c=v.bestAsk),v.bestBid<l&&(l=v.bestBid),u||(e.pRef=v.bestBid,u=!0));else if(s==="ohlcv"){for(let v=y;v<r.length;v++){let b=r[v];if(b.time>=m||b.time>=p)break;b.high>c&&(c=b.high),b.low<l&&(l=b.low),u||(e.pRef=b.high,u=!0)}g()}}if(a.chartType==="candles"||a.chartType==="footprint"||a.chartType==="hollow"||a.chartType==="heikin-ashi"||a.chartType==="bars"||a.chartType==="renko"||a.chartType==="kagi"||a.chartType==="line-break"){if(s==="l3")for(let v of n)v.ts>i||v.ts<e.tMin||v.ts>=e.tMax||(v.price>c&&(c=v.price),v.price<l&&(l=v.price),u||(e.pRef=v.price,u=!0));for(let v=y;v<r.length;v++){let b=r[v];if(b.time>=m||b.time>=p)break;b.high>c&&(c=b.high),b.low<l&&(l=b.low),u||(e.pRef=b.high,u=!0)}g()}if(u)if(a.priceScaleMode==="log"&&l>0&&c>0){let v=Math.log(l),b=Math.log(c),S=b-v;e.pMin=Math.exp(v-S*a.scaleMarginBottom),e.pMax=Math.exp(b+S*a.scaleMarginTop)}else{let v=c-l;e.pMin=l-v*a.scaleMarginBottom,e.pMax=c+v*a.scaleMarginTop}}function qv(e,t){switch(t){case"linear":return e;case"easeOut":return 1-Math.pow(1-e,3);case"easeInOut":return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;default:return e}}function FR(e){let t=un(e.cellSymbol);t.current=e.cellSymbol;let n=un(ja()),r=un([]),o=un([]),a=un([]),i=un([]),s=un([]),l=un({barNs:0n,bars:[],display:[]}),c=un([]),u=un(null),d=un(0n),m=un(0),f=un(-1),h=un(-1),p=un(-1),g=un(null),y=un(0n),v=un(0n),b=un(null),S=un(null),C=un(null),w=un(null),k=un(null),M=un(null),I=un(0),x=un(null),T=un(null),R=un(null),P=un(null),D=un(bl()),N=un(0n),O=un(0),A=un(null),B=un(0n),E=un(null),L=un(null),z=un(null),Y=un(0),G=un(!1),H=un(null),W=un(null),U=un(0),V=un(!1),K=un(!1),Z=Dr(()=>e.externalDomPanelRef?.current??L.current,[]),de=Dr(oe=>{let pe=r.current;if(pe.length===0)return pe;let fe=0,Ie=pe.length-1,Ve=pe.length-1;for(;fe<=Ie;){let qe=fe+Ie>>>1;pe[qe].ts<=oe?(Ve=qe,fe=qe+1):Ie=qe-1}return Ve===pe.length-1?pe:pe.slice(0,Ve+1)},[]),ze=Dr(()=>({imbalanceRatio:e.chartSettingsRef.current.footprintImbalanceRatio,stackMinCount:e.chartSettingsRef.current.footprintStackMinCount,diagRatio:e.chartSettingsRef.current.footprintDiagRatio,absorptionMult:e.chartSettingsRef.current.footprintAbsorptionMult,absorptionDeltaFrac:e.chartSettingsRef.current.footprintAbsorptionDeltaFrac}),[]),xe=Dr((oe,pe)=>{if(pe===0n){S.current=null;return}let fe=new Map;for(let Ie of oe){if(Ie.ts>e.horizonRef.current)break;let Ve=Ie.ts/pe*pe,qe=fe.get(Ve);qe?(Ie.price>qe.high&&(qe.high=Ie.price),Ie.price<qe.low&&(qe.low=Ie.price),qe.close=Ie.price,qe.volume+=Ie.size,qe.delta+=Ie.side==="B"?Ie.size:-Ie.size):fe.set(Ve,{open:Ie.price,high:Ie.price,low:Ie.price,close:Ie.price,volume:Ie.size,delta:Ie.side==="B"?Ie.size:-Ie.size})}S.current=fe},[]),Ae=Dr(oe=>{let pe=x.current;if(!pe)return;let fe=ZC(pe,pe.width,pe.height,oe),Ie=new OffscreenCanvas(pe.width,pe.height);Ie.getContext("2d").putImageData(fe,0,0),T.current?.close(),T.current=Ie.transferToImageBitmap(),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markDirty("base"),e.renderEngineRef.current?.markDirty("drawings"),e.updateSettingsBarPosRef.current(e.selectedDrawingIdRef.current)},[]),Oe=Dr(oe=>{let pe=i.current;if(pe.length===0||oe<0)return;let fe=Math.min(oe,pe.length-1);if(fe===f.current)return;let Ie=e.activeTimeframeRef.current.barNs;if(f.current<0){if(Ie===0n)a.current=pe.slice(0,fe+1);else{let qe=[];for(let Fe=0;Fe<=fe;Fe++){let De=pe[Fe],we=De.ts/Ie*Ie,_e=qe.length>0?qe[qe.length-1]:null;_e&&_e.ts===we?(_e.bestBid=De.bestBid,_e.bestAsk=De.bestAsk):qe.push({ts:we,bestBid:De.bestBid,bestAsk:De.bestAsk})}a.current=qe}f.current=fe;return}if(Ie===0n){a.current=pe.slice(0,fe+1),f.current=fe;return}let Ve=a.current;for(let qe=f.current+1;qe<=fe;qe++){let Fe=pe[qe],De=Fe.ts/Ie*Ie,we=Ve.length>0?Ve[Ve.length-1]:null;we&&we.ts===De?(we.bestBid=Fe.bestBid,we.bestAsk=Fe.bestAsk):Ve.push({ts:De,bestBid:Fe.bestBid,bestAsk:Fe.bestAsk})}f.current=fe},[]),ke=oe=>{let pe=i.current;if(pe.length===0)return-1;let fe=0,Ie=pe.length-1,Ve=-1;for(;fe<=Ie;){let qe=fe+Ie>>>1;pe[qe].ts<=oe?(Ve=qe,fe=qe+1):Ie=qe-1}return Ve},Q=Dr(()=>{let oe=n.current,pe=h.current;if(pe<0||!H.current)return;let fe=pe+1,Ie=oe._buf.slice(0,fe*20),Ve=++I.current;H.current.postMessage({event:"rebuild_footprint",requestId:pn(),compactBuf:Ie,barNs:e.activeTimeframeRef.current.barNs,fpSeq:Ve,fpHorizonIdx:pe,fpOptions:ze()},[Ie])},[]),Pe=Dr((oe,pe)=>{let fe=u.current;if(!fe)return;let Ie=n.current,Ve=d.current,qe=0;for(let _e=oe;_e>=0;_e--)if(ms(Ie,_e)/pe*pe<Ve){qe=_e+1;break}fe.totalVol=0,fe.totalDelta=0;let Fe=new Map;for(let _e=qe;_e<=oe;_e++){let Ne=fs(Ie,_e);if(Ne.action!=="T"||Ne.price===null||Ne.side==="N")continue;fe.totalVol+=Ne.size,Ne.side==="B"?fe.totalDelta+=Ne.size:fe.totalDelta-=Ne.size;let dt=Fe.get(Ne.price)??{bidVol:0,askVol:0};Ne.side==="B"?dt.bidVol+=Ne.size:dt.askVol+=Ne.size,Fe.set(Ne.price,dt)}let De=0,we=0;if(fe.levels=Array.from(Fe.entries()).map(([_e,{bidVol:Ne,askVol:dt}])=>{let Pt=Ne+dt,J=Ne-dt;return Pt>De&&(De=Pt),Math.abs(J)>we&&(we=Math.abs(J)),{price:_e,bidVol:Ne,askVol:dt,delta:J,totalVol:Pt,bidImbalance:!1,askImbalance:!1,diagAskImbalance:!1,diagBidImbalance:!1,absorption:!1}}),fe.maxLevelVol=De,fe.maxAbsDelta=we,fe.levels.length>0){let _e=fe.levels.reduce((Ne,dt)=>dt.bidVol+dt.askVol>Ne.bidVol+Ne.askVol?dt:Ne,fe.levels[0]);fe.poc=_e.price}},[]),_=Dr((oe,pe,fe,Ie)=>{if(fe===0n||pe<=oe)return!1;let Ve=n.current,qe=!1;for(let Fe=oe+1;Fe<=pe;Fe++){let De=fs(Ve,Fe);if(De.action!=="T"||De.price===null||De.side==="N")continue;let we=ms(Ve,Fe)/fe*fe;u.current&&we>d.current&&(u.current=null,d.current=we,m.current=0,qe=!0),u.current||(u.current={ts:we,open:De.price,high:De.price,low:De.price,close:De.price,totalVol:0,totalDelta:0,maxLevelVol:0,maxAbsDelta:0,levels:[],isBullish:!0,poc:De.price,stackedBuyZones:[],stackedSellZones:[],unfinishedTop:!1,unfinishedBottom:!1,absorptionCount:0,diagDominant:"none"},d.current=we,m.current=0);let _e=u.current;De.price>_e.high&&(_e.high=De.price),De.price<_e.low&&(_e.low=De.price),_e.close=De.price,_e.totalVol+=De.size,De.side==="B"?_e.totalDelta+=De.size:_e.totalDelta-=De.size,m.current++}return u.current&&Pe(pe,fe),qe},[]),ie=Dr(()=>{let oe=u.current;if(!oe)return;let pe=s.current;pe.length>0&&pe[pe.length-1].ts===oe.ts?pe[pe.length-1]=oe:s.current=[...pe,oe]},[]),se=Dr(oe=>{h.current=oe,p.current=oe,u.current=null,d.current=0n,m.current=0,f.current=-1},[]),Se=Dr(oe=>{if(g.current!=="ohlcv")return;let pe=C.current??[],fe=Math.min(...pe.map(qt=>Number(qt.resolution))),Ie=pe.find(qt=>Number(qt.resolution)===fe)?.bars??[],Ve=e.activeTimeframeRef.current.barNs;if(Ve<=0n)return;let{start:qe,end:Fe}=hd(oe,Ve,e.sessionMapperRef.current),De=Number(qe/1000000n),we=Number(Fe/1000000n),_e=Number(oe/1000000n),Ne=0,dt=Ie.length-1,Pt=Ie.length;for(;Ne<=dt;){let qt=Ne+dt>>>1;Ie[qt].time>=De?(Pt=qt,dt=qt-1):Ne=qt+1}let J=0,Te=1/0,Le=0,ot=0,tt=0,mt=!1;for(let qt=Pt;qt<Ie.length;qt++){let Dt=Ie[qt];if(Dt.time>=we||Dt.time>=_e)break;(Dt.volume??0)!==0&&(mt||(mt=!0,Le=Dt.open),Dt.high>J&&(J=Dt.high),Dt.low<Te&&(Te=Dt.low),ot=Dt.close,tt+=Dt.volume)}if(mt&&tt)u.current={ts:qe,open:Le,high:J,low:Te,close:ot,totalVol:tt=Math.round(tt*1e8)/1e8,totalDelta:0,maxLevelVol:0,maxAbsDelta:0,levels:[],isBullish:ot>=Le,poc:0,stackedBuyZones:[],stackedSellZones:[],unfinishedTop:!1,unfinishedBottom:!1,absorptionCount:0,diagDominant:"none"};else{let qt=l.current.display,Dt=0,rr=qt.length-1,wn=-1;for(;Dt<=rr;){let Pn=Dt+rr>>>1;qt[Pn].time<De?(wn=Pn,Dt=Pn+1):rr=Pn-1}let er=wn>=0?qt[wn]:void 0;if(!er)return;u.current={ts:BigInt(er.time*1e6),open:er.open,high:er.high,low:er.low,close:er.close,totalVol:er.volume,totalDelta:0,maxLevelVol:0,maxAbsDelta:0,levels:[],isBullish:er.close>=er.open,poc:0,stackedBuyZones:[],stackedSellZones:[],unfinishedTop:!1,unfinishedBottom:!1,absorptionCount:0,diagDominant:"none"}}},[]),Re=oe=>{let{bitmap:pe,bounds:fe,requestId:Ie}=oe.data;if(Ie!==Y.current){pe.close();return}x.current?.close(),x.current=pe,P.current={tMin:BigInt(fe.tMin),tMax:BigInt(fe.tMax),pMin:fe.pMin,pMax:fe.pMax},Ae(e.chartSettingsRef.current.heatmapContrast),e.eventBus.emit("heatmap:status",{recalculating:!1,cellId:e.cellId})},ye=Dr(()=>{Y.current++},[]),$e=Dr((oe,pe)=>{let fe=W.current;if(!fe)return;let Ie="__scripted__",Ve=e.indicatorsRef.current.filter(we=>we.workerInit&&we.workerInit!==Ie&&we.hydrate);function qe(we){let _e=typeof we=="bigint"?we:BigInt(we);return _e<1000000000000n?_e*1000000000n:_e<1000000000000000n?_e*1000000n:_e<1000000000000000000n?_e*1000n:_e}let Fe=[];if(g.current==="l3"){for(let[we,_e]of S.current??new Map)Fe.push({ts:qe(we),open:_e.open,high:_e.high,low:_e.low,close:_e.close,volume:_e.volume});Fe.sort((we,_e)=>we.ts<_e.ts?-1:1)}else g.current==="ohlcv"&&u.current&&Fe.push({ts:u.current.ts,open:u.current.open,high:u.current.high,low:u.current.low,close:u.current.close,volume:u.current.totalVol});let De=oe.map(we=>({time:Number(we.ts/1000000n),price:we.price,size:we.size,side:we.side}));for(let we of e.indicatorsRef.current)we.workerInit===Ie&&e.eventBus.emit("plugin:scripted-recompute",{id:we.id});if(Ve.length>0){let we=String(++U.current);fe.postMessage({type:"compute",requestId:we,trades:oe,ohlcv:Fe,ticks:De,snapshots:[],barNs:pe,horizon:e.horizonRef.current,indicators:Ve.map(_e=>({id:_e.id,workerInit:_e.workerInit,params:_e.workerParams}))}),fe.postMessage({type:"register-update-fns",horizon:e.horizonRef.current,indicators:Ve.map(_e=>({id:_e.id,workerUpdate:_e.workerUpdate}))})}},[]),Ue=Dr(oe=>{let pe=W.current;if(!pe)return;let fe=r.current,Ie=B.current,Ve=0,qe=fe.length-1,Fe=fe.length;for(;Ve<=qe;){let Te=Ve+qe>>>1;fe[Te].ts<=Ie?Ve=Te+1:(Fe=Te,qe=Te-1)}let De=Fe-1;for(Ve=Fe,qe=fe.length-1;Ve<=qe;){let Te=Ve+qe>>>1;fe[Te].ts<=oe?(De=Te,Ve=Te+1):qe=Te-1}B.current=oe;let we=De>=Fe?fe.slice(Fe,De+1):[],_e="__scripted__",Ne=e.indicatorsRef.current.filter(Te=>Te.workerUpdate&&Te.workerUpdate!==_e&&Te.appendHydrate);function dt(Te){let Le=typeof Te=="bigint"?Te:BigInt(Te);return Le<1000000000000n?Le*1000000000n:Le<1000000000000000n?Le*1000000n:Le<1000000000000000000n?Le*1000n:Le}let Pt=[];if(g.current==="l3"){for(let[Te,Le]of S.current??new Map)Pt.push({ts:dt(Te),open:Le.open,high:Le.high,low:Le.low,close:Le.close,volume:Le.volume});Pt.sort((Te,Le)=>Te.ts<Le.ts?-1:1)}else g.current==="ohlcv"&&u.current&&Pt.push({ts:u.current.ts,open:u.current.open,high:u.current.high,low:u.current.low,close:u.current.close,volume:u.current.totalVol});let J=we.map(Te=>({time:Number(Te.ts/1000000n),price:Te.price,size:Te.size,side:Te.side}));if(Ne.length>0){let Te=String(++U.current);pe.postMessage({type:"compute",requestId:Te,trades:we,ohlcv:Pt,ticks:J,snapshots:[],barNs:e.activeTimeframeRef.current.barNs,horizon:oe,indicators:Ne.map(Le=>({id:Le.id,workerInit:Le.workerInit,params:Le.workerParams}))}),pe.postMessage({type:"register-update-fns",horizon:oe,indicators:Ne.map(Le=>({id:Le.id,workerUpdate:Le.workerUpdate}))})}for(let Te of e.indicatorsRef.current)Te.workerInit===_e&&e.eventBus.emit("plugin:scripted-recompute",{id:Te.id})},[]),je=Dr(()=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{let oe=e.viewRef.current,pe=e.baseCanvasRef.current;if(!oe||!pe)return;e.indicatorsRef.current.some(_e=>_e.id==="vp_visiblerange")&&$e(de(e.horizonRef.current),e.activeTimeframeRef.current.barNs);let fe="__scripted__";for(let _e of e.indicatorsRef.current)_e.workerInit===fe&&e.eventBus.emit("plugin:scripted-recompute",{id:_e.id});if(!G.current||!e.chartSettingsRef.current.showHeatmap)return;let Ie=pe.width-e.priceScaleWidthRef.current,Ve=e.layoutsCacheRef.current.main,qe=Ve?Ve.h:pe.height-(e.hideTimeScale?0:yn);if(Ie<=0||qe<=0)return;ye();let Fe=++Y.current,De=e.horizonRef.current,we={type:"render",requestId:Fe,bounds:OR(oe),chartW:Ie,chartH:qe,horizonNs:De>0n?De.toString():void 0};e.eventBus.emit("heatmap:status",{recalculating:!0,cellId:e.cellId}),z.current.postMessage(we)},e.chartSettingsRef.current.resamplingDebounce)},[e.chartSettingsRef.current.resamplingDebounce]),ht=oe=>{let pe=oe.data;if(pe.type==="compute"){let{requestId:fe,results:Ie,errors:Ve}=pe;if(fe!==String(U.current))return;let qe=e.activeTimeframeRef.current.barNs;for(let Fe of e.indicatorsRef.current)Ie[Fe.id]!==void 0&&Fe.hydrate?.(Ie[Fe.id],qe),Ve[Fe.id]&&console.error(`[indicator:${Fe.id}]`,Ve[Fe.id]);e.autofitIndicatorPanesRef.current(),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markDirty("base"),e.renderEngineRef.current?.markDirty("ui");return}if(pe.type==="horizon:advance"){let{points:fe,errors:Ie}=pe,Ve=e.activeTimeframeRef.current.barNs;for(let qe of e.indicatorsRef.current)fe[qe.id]!==void 0&&qe.appendHydrate?.(fe[qe.id],Ve),Ie[qe.id]&&console.error(`[indicator:${qe.id}]`,Ie[qe.id]);e.renderEngineRef.current?.markDirty("base")}},Be=()=>{H.current?.postMessage({requestId:pn(),event:"load",barNs:e.activeTimeframeRef.current.barNs,horizon:e.horizonRef.current,fpOptions:ze()})},xt=Dr(oe=>{if(oe.error){e.eventBus.emit("data:status",{status:"error",error:{code:oe.error,message:oe.errorMessage??"Failed to load data"},symbol:oe.symbol??t.current});return}let pe=g.current!==oe.dataLevel;if(g.current=oe.dataLevel,pe&&e.onDataLevelChangeRef.current(),C.current=oe.supplemental??null,oe.dataLevel==="ohlcv"){let fe=oe.ohlcvBars??[];oe.session!==void 0&&(e.resolvedSessionRef.current=oe.session),n.current=ja(0),r.current=[],o.current=[],i.current=[],a.current=[],s.current=[],S.current=null;let Ie=e.activeTimeframeRef.current.barNs,Ve=fe.map(J=>({open:J.open,high:J.high,low:J.low,close:J.close,volume:J.volume,time:J.time}));l.current={barNs:Ie,bars:Ve,display:[]};let qe=BigInt(oe.dataStart)*1000000n,Fe=BigInt(oe.dataEnd)*1000000n;y.current=qe,v.current=Fe,e.onDataBoundsChange?.(qe,Fe);let De=oe.playFromIso?Ia(oe.playFromIso):Fe;e.horizonRef.current=De,N.current=De,h.current=0,p.current=0,u.current=null,d.current=0n;let we=14n*24n*60n*60n*1000000000n;e.sessionMapperRef.current.build(e.resolvedSessionRef.current,qe-we,Fe+we),l.current.display=lc(Ve,Ie,e.sessionMapperRef.current),Se(e.horizonRef.current),e.eventBus.emit("data:bounds",{start:qe,end:Fe,session:e.resolvedSessionRef.current,symbol:t.current});{let J=Pi(e.resolvedSessionRef.current,De),Te=b.current;(!Te||Te.kind!==J.kind||J.kind==="sub"&&Te.kind==="sub"&&Te.label!==J.label)&&(b.current=J,e.eventBus.emit("session:status",{...J,symbol:t.current}))}let _e=800000000000n,Ne=100000000000n;e.viewRef.current={...e.viewRef.current??{tMin:0n,tMax:0n,pMin:0,pMax:0,pRef:0},tMin:Fe-_e+Ne,tMax:Fe+Ne},e.resetViewRef.current(),e.transformer.update(e.viewRef.current),e.transformer.setSessionMapper(e.sessionMapperRef.current),e.transformer.setSession(e.resolvedSessionRef.current),e.renderEngineRef.current?.setView(e.viewRef.current);let dt="__scripted__",Pt=e.indicatorsRef.current.filter(J=>J.workerInit===dt);e.indicatorsRef.current=Pt,e.setIndicators(Pt),e.eventBus.emit("data:status",{status:"ready",symbol:oe.symbol??t.current}),e.pushDrawParamsRef.current(),Pt.length>0&&$e(de(e.horizonRef.current),e.activeTimeframeRef.current.barNs),e.renderEngineRef.current?.markDirty("base");return}try{let{compactBuf:fe,trades:Ie,priceHistory:Ve,footprintBars:qe,barNs:Fe,dataStart:De,dataEnd:we,session:_e}=oe;_e!==void 0&&(e.resolvedSessionRef.current=_e),n.current=ja(0),n.current._buf=fe,n.current._view=new DataView(fe),n.current.length=fe.byteLength/20,n.current.capacity=n.current.length,n.current.firstTs=BigInt(De)*1000000n,n.current.lastTs=BigInt(we)*1000000n,r.current=Ie,i.current=Ve,o.current=Ie,u.current=null,f.current=Ve.length-1,S.current=null;let Ne=e.activeTimeframeRef.current.barNs;Fe===Ne?s.current=qe:Q();let dt=BigInt(De)*1000000n,Pt=BigInt(we)*1000000n;y.current=dt,v.current=Pt,e.onDataBoundsChange?.(dt,Pt);let J=oe.playFromIso?Ia(oe.playFromIso):Pt,Te=Jf(n.current,J);h.current=Te,p.current=Te,u.current=null,d.current=0n,m.current=0,e.horizonRef.current=J;let Le=bl(),ot=n.current;for(let Mn=0;Mn<=Te;Mn++)yl(Le,fs(ot,Mn));D.current=Le,Z()?.update(Le);let tt="__scripted__",mt=e.indicatorsRef.current.filter(Mn=>Mn.workerInit===tt);e.indicatorsRef.current=mt,e.setIndicators(mt);let{ingestOhlcvBuf:qt,ingestBucketedPhBuf:Dt,ingestTradesBuf:rr,ingestPhBuf:wn}=oe;w.current=rr??null,k.current=wn??null,M.current=qt??null,S.current=null,a.current=[];let er=14n*24n*60n*60n*1000000000n;e.sessionMapperRef.current.build(e.resolvedSessionRef.current,dt-er,Pt+er),e.eventBus.emit("data:bounds",{start:dt,end:Pt,session:e.resolvedSessionRef.current,symbol:t.current});{let Mn=Pi(e.resolvedSessionRef.current,J),An=b.current;(!An||An.kind!==Mn.kind||Mn.kind==="sub"&&An.kind==="sub"&&An.label!==Mn.label)&&(b.current=Mn,e.eventBus.emit("session:status",{...Mn,symbol:t.current}))}let Pn=800000000000n,cr=100000000000n;e.viewRef.current={...e.viewRef.current??{tMin:0n,tMax:0n,pMin:0,pMax:0,pRef:0},tMin:J-Pn+cr,tMax:J+cr},e.transformer.update(e.viewRef.current),e.transformer.setSessionMapper(e.sessionMapperRef.current),e.transformer.setSession(e.resolvedSessionRef.current),e.renderEngineRef.current?.setView(e.viewRef.current),e.eventBus.emit("data:status",{status:"ready",symbol:oe.symbol??t.current}),mt.length>0&&$e(de(J),Ne),Dt&&(a.current=sp(Dt),Ar(e.viewRef.current,a.current,o.current,g.current==="ohlcv"?l.current.display:c.current,u.current,e.chartSettingsRef.current,J,g.current),e.transformer.update(e.viewRef.current),e.transformer.setSessionMapper(e.sessionMapperRef.current),e.transformer.setSession(e.resolvedSessionRef.current),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markDirty("base")),qt&&(S.current=lp(qt,e.horizonRef.current)),z.current&&(cb(n.current,0,n.current.length,"init").catch(()=>{}),G.current=!0,je())}catch(fe){console.error("[chart] ingestLoadedData failed",fe)}},[]),fn=Dr(oe=>{if(oe.dataLevel==="ohlcv"){let pe=(oe.ohlcvBars??[]).map(De=>({open:De.open,high:De.high,low:De.low,close:De.close,volume:De.volume,time:De.time})),fe=e.activeTimeframeRef.current.barNs,Ie=BigInt(oe.dataEnd)*1000000n,Ve=v.current;if(v.current=Ie,pe.length>0){let De=l.current.bars,we=pe[0].time;for(;De.length&&De[De.length-1].time>=we;)De.pop();for(let Ne of pe)De.push(Ne);l.current.barNs=fe;let _e=l.current.display;if(_e.length===0)l.current.display=lc(De,fe,e.sessionMapperRef.current);else{let Ne=_e[_e.length-1].time,dt=De.length;for(;dt>0&&De[dt-1].time>=Ne;)dt--;let Pt=lc(De.slice(dt),fe,e.sessionMapperRef.current);_e.pop();for(let J of Pt)_e.push(J)}}let Fe=!K.current&&e.horizonRef.current>=Ve?Ie:e.horizonRef.current;e.horizonRef.current=Fe,N.current=Fe,Se(Fe);{let De=Pi(e.resolvedSessionRef.current,Fe),we=b.current;(!we||we.kind!==De.kind||De.kind==="sub"&&we.kind==="sub"&&we.label!==De.label)&&(b.current=De,e.eventBus.emit("session:status",{...De,symbol:t.current}))}e.onDataBoundsChange?.(y.current,Ie),e.eventBus.emit("data:bounds",{start:y.current,end:Ie,session:e.resolvedSessionRef.current,symbol:t.current}),e.pushDrawParamsRef.current(),$e(de(Fe),fe),e.renderEngineRef.current?.markAllDirty();return}try{let{compactBuf:pe,trades:fe,priceHistory:Ie,footprintBars:Ve,barNs:qe,dataEnd:Fe}=oe,De=pe.slice(0),we=ja(0);we._buf=De,we._view=new DataView(De),we.length=De.byteLength/20,we.capacity=we.length,we.firstTs=y.current,we.lastTs=BigInt(Fe)*1000000n,n.current=we,r.current=fe,i.current=Ie,o.current=fe;let _e=e.activeTimeframeRef.current.barNs;qe===_e?s.current=Ve:Q();let Ne=BigInt(Fe)*1000000n,dt=v.current;v.current=Ne;let J=!K.current&&e.horizonRef.current>=dt?Ne:e.horizonRef.current,Te=Jf(n.current,J);h.current=Te,p.current=Te,e.horizonRef.current=J;let{ingestOhlcvBuf:Le,ingestBucketedPhBuf:ot,ingestTradesBuf:tt,ingestPhBuf:mt}=oe;w.current=tt??null,k.current=mt??null,M.current=Le??null,ot&&(a.current=sp(ot)),Le&&(S.current=lp(Le,e.horizonRef.current)),e.isYAxisAutoRef.current&&Ar(e.viewRef.current,a.current,o.current,g.current==="ohlcv"?l.current.display:c.current,u.current,e.chartSettingsRef.current,e.horizonRef.current,g.current),e.onDataBoundsChange?.(y.current,Ne),e.eventBus.emit("data:bounds",{start:y.current,end:Ne,session:e.resolvedSessionRef.current,symbol:t.current}),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markAllDirty(),$e(de(e.horizonRef.current),_e),z.current&&cb(n.current,0,n.current.length,"append").catch(()=>{}),je()}catch(pe){console.error("[chart] ingestAppendedData failed",pe)}},[]),In=Dr(oe=>{if(oe.dataLevel==="ohlcv"){let pe=(oe.ohlcvBars??[]).map(De=>({open:De.open,high:De.high,low:De.low,close:De.close,volume:De.volume,time:De.time})),fe=e.activeTimeframeRef.current.barNs,Ie=BigInt(oe.dataStart)*1000000n,Ve=14n*24n*60n*60n*1000000000n,qe=Ie-Ve;e.sessionMapperRef.current.extendBackward(e.resolvedSessionRef.current,qe);let Fe=FV(pe,l.current.display,fe,e.sessionMapperRef.current);l.current.bars=[...pe,...l.current.bars],l.current.barNs=fe,l.current.display=Fe,y.current=Ie,e.eventBus.emit("data:bounds",{start:Ie,end:v.current,session:e.resolvedSessionRef.current,symbol:t.current}),e.onDataBoundsChange?.(Ie,v.current),e.isYAxisAutoRef.current&&Ar(e.viewRef.current,a.current,o.current,g.current==="ohlcv"?l.current.display:c.current,u.current,e.chartSettingsRef.current,e.horizonRef.current,g.current),e.pushDrawParamsRef.current(),$e(de(e.horizonRef.current),e.activeTimeframeRef.current.barNs),e.renderEngineRef.current?.markAllDirty();return}try{let{compactBuf:pe,trades:fe,priceHistory:Ie,footprintBars:Ve,dataStart:qe}=oe,Fe=BigInt(qe)*1000000n,De=pe.slice(0),we=ja(0);we._buf=De,we._view=new DataView(De),we.length=De.byteLength/20,we.capacity=we.length,we.firstTs=Fe,we.lastTs=v.current,n.current=we,r.current=fe,i.current=Ie,o.current=fe,Ve.length>0&&(oe.barNs===e.activeTimeframeRef.current.barNs?s.current=Ve:Q()),h.current=Jf(n.current,e.horizonRef.current),p.current=h.current,y.current=Fe;{let J=14n*24n*60n*60n*1000000000n;e.sessionMapperRef.current.build(e.resolvedSessionRef.current,Fe-J,v.current+J)}e.eventBus.emit("data:bounds",{start:Fe,end:v.current,session:e.resolvedSessionRef.current,symbol:t.current}),e.onDataBoundsChange?.(Fe,v.current);let{ingestOhlcvBuf:_e,ingestBucketedPhBuf:Ne,ingestTradesBuf:dt,ingestPhBuf:Pt}=oe;w.current=dt??null,k.current=Pt??null,M.current=_e??null,Ne&&(a.current=sp(Ne)),_e&&(S.current=lp(_e,e.horizonRef.current)),e.isYAxisAutoRef.current&&Ar(e.viewRef.current,a.current,o.current,g.current==="ohlcv"?l.current.display:c.current,u.current,e.chartSettingsRef.current,e.horizonRef.current,g.current),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markAllDirty(),$e(de(e.horizonRef.current),e.activeTimeframeRef.current.barNs)}catch(pe){console.error("[chart] ingestPrependedData failed",pe)}},[]),kt=Dr((oe,pe=!0,fe=!1)=>{let Ie=n.current,Ve=Jf(Ie,oe),qe=h.current,Fe=e.activeTimeframeRef.current.barNs,De=Ve>=qe,we=hd(oe,Fe,e.sessionMapperRef.current).start;if(we!==N.current){let Ne=N.current,dt=we>Ne;N.current=we;let Pt=e.viewRef.current.tMax>we&&e.viewRef.current.tMin<we;if(e.viewRef.current&&!(e.isDragging.current&&e.dragMode.current==="pan")&&dt&&Pt){let J=e.chartSettingsRef.current.horizonScrollEasing,Te=e.chartSettingsRef.current.horizonScrollDuration,Le=performance.now(),ot=Le-O.current;O.current=Le;let tt=e.sessionMapperRef.current,mt=tt.hasSession,qt=A.current,Dt=ot<Te,rr=Dt?"linear":J,wn=Dt?Math.max(1,ot):Te;if(mt){let er=tt.tsToMarket(we)-tt.tsToMarket(Ne),Pn=qt?.targetMMin??tt.tsToMarket(e.viewRef.current.tMin),cr=qt?.targetMMax??tt.tsToMarket(e.viewRef.current.tMax),Mn=Pn+er,An=cr+er;J==="none"?(e.viewRef.current.tMin=tt.marketToTs(Mn),e.viewRef.current.tMax=tt.marketToTs(An),A.current=null):A.current={startTMin:e.viewRef.current.tMin,startTMax:e.viewRef.current.tMax,targetTMin:tt.marketToTs(Mn),targetTMax:tt.marketToTs(An),startMMin:tt.tsToMarket(e.viewRef.current.tMin),startMMax:tt.tsToMarket(e.viewRef.current.tMax),targetMMin:Mn,targetMMax:An,startTime:Le,easing:rr,duration:wn}}else{let er=we-Ne,Pn=qt?.targetTMin??e.viewRef.current.tMin,cr=qt?.targetTMax??e.viewRef.current.tMax,Mn=Pn+er,An=cr+er;J==="none"?(e.viewRef.current.tMin=Mn,e.viewRef.current.tMax=An,A.current=null):A.current={startTMin:e.viewRef.current.tMin,startTMax:e.viewRef.current.tMax,targetTMin:Mn,targetTMax:An,startTime:Le,easing:rr,duration:wn}}}}e.onHorizonUpdate(oe),e.eventBus.emit("status:refresh",void 0);{let Ne=Pi(e.resolvedSessionRef.current,oe),dt=b.current;(!dt||dt.kind!==Ne.kind||Ne.kind==="sub"&&dt.kind==="sub"&&dt.label!==Ne.label)&&(b.current=Ne,e.eventBus.emit("session:status",{...Ne,symbol:t.current}))}if(!De){if(se(Ve),Fe>0n&&Ve>=0){let Pt=oe/Fe*Fe;d.current=Pt;let J=0;for(let Te=Ve;Te>=0;Te--)if(ms(Ie,Te)/Fe*Fe<Pt){J=Te+1;break}for(let Te=J;Te<=Ve;Te++){let Le=fs(Ie,Te);if(Le.action!=="T"||Le.price===null||Le.side==="N")continue;u.current||(u.current={ts:Pt,open:Le.price,high:Le.price,low:Le.price,close:Le.price,totalVol:0,totalDelta:0,maxLevelVol:0,maxAbsDelta:0,levels:[],isBullish:!0,poc:Le.price,stackedBuyZones:[],stackedSellZones:[],unfinishedTop:!1,unfinishedBottom:!1,absorptionCount:0,diagDominant:"none"});let ot=u.current;Le.price>ot.high&&(ot.high=Le.price),Le.price<ot.low&&(ot.low=Le.price),ot.close=Le.price,ot.totalVol+=Le.size,Le.side==="B"?ot.totalDelta+=Le.size:ot.totalDelta-=Le.size,m.current++}u.current&&Pe(Ve,Fe)}Q(),Oe(ke(oe));let Ne=Ve;if(Z()){let J=0,Te=bl(),Le=()=>{if(h.current!==Ne)return;let ot=Math.min(J+5e4,Ne+1);for(;J<ot;J++)yl(Te,fs(Ie,J));J<=Ne?setTimeout(Le,0):(D.current=Te,p.current=Ne,Z()?.update(Te))};Le()}let dt=de(oe);xe(dt,Fe),B.current=oe,$e(dt,Fe),e.autofitIndicatorPanesRef.current(),ie(),e.viewRef.current&&e.isYAxisAutoRef.current&&Ar(e.viewRef.current,a.current,o.current,g.current==="ohlcv"?l.current.display:c.current,u.current,e.chartSettingsRef.current,e.horizonRef.current,g.current),Se(oe),pe&&je(),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markDirty("base"),e.renderEngineRef.current?.markDirty("ui"),e.renderEngineRef.current?.markDirty("drawings"),e.updateSettingsBarPosRef.current(e.selectedDrawingIdRef.current);return}if(h.current=Ve,Fe>0n&&(_(qe,Ve,Fe,oe)&&Q(),ie()),Oe(ke(oe)),Z()&&Ve>p.current){let Ne=D.current;for(let dt=p.current+1;dt<=Ve;dt++)yl(Ne,fs(Ie,dt));p.current=Ve,Z()?.update(Ne)}if(e.viewRef.current&&e.isYAxisAutoRef.current&&Ar(e.viewRef.current,a.current,o.current,g.current==="ohlcv"?l.current.display:c.current,u.current,e.chartSettingsRef.current,e.horizonRef.current,g.current),fe){if(Fe>0n&&S.current&&Ve>qe){let Ne=r.current,dt=qe>=0?ms(Ie,qe):0n,Pt=0,J=0,Te=Ne.length-1;for(;J<=Te;){let mt=J+Te>>>1;Ne[mt].ts<=dt?(Pt=mt+1,J=mt+1):Te=mt-1}let Le=Pt,ot=Pt,tt=Ne.length-1;for(;ot<=tt;){let mt=ot+tt>>>1;Ne[mt].ts<=oe?(Le=mt,ot=mt+1):tt=mt-1}if(Le>=Pt){let mt=S.current;for(let qt=Pt;qt<=Le;qt++){let Dt=Ne[qt],rr=Dt.ts/Fe*Fe,wn=mt.get(rr);wn?(Dt.price>wn.high&&(wn.high=Dt.price),Dt.price<wn.low&&(wn.low=Dt.price),wn.close=Dt.price,wn.volume+=Dt.size,wn.delta+=Dt.side==="B"?Dt.size:-Dt.size):mt.set(rr,{open:Dt.price,high:Dt.price,low:Dt.price,close:Dt.price,volume:Dt.size,delta:Dt.side==="B"?Dt.size:-Dt.size})}}}if(Ue(oe),A.current&&e.viewRef.current){let Ne=A.current,dt=Ne.duration??e.chartSettingsRef.current.horizonScrollDuration,Pt=Math.min((performance.now()-Ne.startTime)/dt,1),J=qv(Pt,Ne.easing??e.chartSettingsRef.current.horizonScrollEasing),Te=(Le,ot,tt)=>Le+BigInt(Math.round(Number(ot-Le)*tt));if(Ne.startMMin!==void 0&&Ne.targetMMin!==void 0){let Le=e.sessionMapperRef.current;e.viewRef.current.tMin=Le.marketToTs(Te(Ne.startMMin,Ne.targetMMin,J)),e.viewRef.current.tMax=Le.marketToTs(Te(Ne.startMMax,Ne.targetMMax,J))}else e.viewRef.current.tMin=Te(Ne.startTMin,Ne.targetTMin,J),e.viewRef.current.tMax=Te(Ne.startTMax,Ne.targetTMax,J);Pt>=1&&(A.current=null)}Se(oe),e.pushDrawParamsRef.current(),o.current.length>0?e.doBaseRedrawRef.current():e.renderEngineRef.current?.markDirty("base"),e.renderEngineRef.current?.markDirty("drawings");return}let _e=de(oe);xe(_e,Fe),B.current=oe,$e(_e,Fe),e.autofitIndicatorPanesRef.current(),Se(oe),pe&&je(),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markDirty("base"),e.renderEngineRef.current?.markDirty("ui"),e.renderEngineRef.current?.markDirty("drawings"),e.updateSettingsBarPosRef.current(e.selectedDrawingIdRef.current)},[]),it=Dr(oe=>{let pe=e.viewRef.current;if(!pe)return;let fe=e.activeTimeframeRef.current.barNs,Ie=oe/fe*fe;if(Ie>pe.tMin&&Ie<pe.tMax)return;A.current=null;let Ve=e.sessionMapperRef.current,qe=N.current;if(Ve.hasSession){let Fe=Ve.tsToMarket(pe.tMin),De=Ve.tsToMarket(pe.tMax),we=Ve.tsToMarket(qe),_e=De-Fe,Ne=we>Fe&&we<De?De-we:_e/8n,dt=Ve.tsToMarket(Ie);pe.tMin=Ve.marketToTs(dt+Ne-_e),pe.tMax=Ve.marketToTs(dt+Ne)}else{let Fe=pe.tMax-pe.tMin,De=qe>pe.tMin&&qe<pe.tMax?pe.tMax-qe:Fe/8n;pe.tMin=Ie+De-Fe,pe.tMax=Ie+De}e.transformer.update(pe),e.renderEngineRef.current?.setView(pe),Ar(pe,a.current,o.current,g.current==="ohlcv"?l.current.display:c.current,u.current,e.chartSettingsRef.current,e.horizonRef.current,g.current),je(),e.renderEngineRef.current.markAllDirty()},[]),ft=Dr((oe,pe=!0,fe=!1,Ie=!1)=>{let Ve=v.current;if(Ve===0n)return;let qe=oe<=Ve?oe:Ve;Ie&&it(qe),e.horizonRef.current=qe,kt(qe,pe,fe)},[]);return _R(()=>{if(!V.current)return V.current=!0,z.current=new Worker(NR()),z.current.onmessage=Re,W.current=new Worker(ER()),W.current.onmessage=ht,()=>{z.current?.terminate(),H.current?.terminate(),W.current?.terminate(),z.current=null,W.current=null,V.current=!1}},[]),_R(()=>{let oe=e.cellSymbol,pe=[e.eventBus.on("playback:play",()=>K.current=!0),e.eventBus.on("playback:pause",()=>K.current=!1),e.eventBus.on("data:load",fe=>{if(fe.symbol!==oe)return;c.current=[],l.current.bars=[],l.current.display=[],e.pushDrawParamsRef.current();let Ie=fe.compactBuf.slice(0);xt({...fe,compactBuf:Ie})}),e.eventBus.on("data:append",fe=>{fe.symbol===oe&&(c.current=[],e.pushDrawParamsRef.current(),fn(fe))}),e.eventBus.on("data:prepend",fe=>{fe.symbol===oe&&(c.current=[],In(fe))}),e.eventBus.on("data:refine",fe=>{if(fe.symbol!==oe||fe.dataLevel!=="ohlcv")return;let Ie=new Date(fe.from).getTime(),Ve=new Date(fe.to).getTime(),qe=e.activeTimeframeRef.current.barNs,Fe=fe.ohlcvBars.map(_e=>({open:_e.open,high:_e.high,low:_e.low,close:_e.close,volume:_e.volume,time:_e.time})),we=[...l.current.bars.filter(_e=>_e.time<Ie||_e.time>Ve),...Fe].sort((_e,Ne)=>_e.time-Ne.time);l.current.bars=we,l.current.barNs=qe,l.current.display=lc(we,qe,e.sessionMapperRef.current),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markDirty("base")}),e.eventBus.on("data:preview",fe=>{fe.symbol===oe&&(c.current=fe.bars,e.isYAxisAutoRef.current&&Ar(e.viewRef.current,a.current,o.current,c.current,u.current,e.chartSettingsRef.current,e.horizonRef.current,g.current),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markDirty("base"),$e(de(e.horizonRef.current),e.activeTimeframeRef.current.barNs))}),e.eventBus.on("data:symbol-resolved",({symbolInfo:fe})=>{fe.symbol===oe&&(e.resolvedSymbolInfoRef.current=fe??null,e.resolvedSessionRef.current=fe.session??null,e.setPanes(Ie=>Ie.map(Ve=>Ve.isMain?{...Ve,exchange:fe.exchange}:Ve)))})];return e.eventBus.emit("data:request-symbol-resolved",{symbol:oe}),()=>pe.forEach(fe=>fe())},[e.eventBus,e.cellSymbol]),{compactBufRef:n,allTradesRef:r,tradesRef:o,priceHistoryRef:a,allPriceHistoryRef:i,footprintBarsRef:s,ohlcvBarsRef:l,previewBarsRef:c,openBarRef:u,openBarTsRef:d,openBarTradeCountRef:m,phCursorRef:f,playheadIdxRef:h,replayedUpToRef:p,dataLevelRef:g,datasetStartRef:y,datasetEndRef:v,prevSessionStatusRef:b,candleCacheRef:S,supplementalBarsRef:C,serialisedTradesBufRef:w,serialisedPhBufRef:k,serialisedOhlcvBufRef:M,fpRebuildSeqRef:I,rawBitmapRef:x,heatmapBitmapRef:T,heatmapBitmapOffsetsRef:R,cacheBoundsRef:P,liveBookRef:D,prevHorizonBarRef:N,lastBarAdvanceTimeRef:O,horizonScrollAnimRef:A,workerRef:z,dataWorkerRef:H,indicatorWorkerRef:W,workerReadyRef:G,workerRequestIdRef:Y,_internalDomPanelRef:L,seekHorizon:ft,applyHorizon:kt,scheduleResample:je,runIndicatorWorker:$e,getTradesUpToHorizon:de,requestFootprintRebuild:Q,syncOhlcvOpenBar:Se,rebuildCandleCache:xe,rebuildContrastBitmap:Ae,foldEventsIntoOpenBar:_,mergeOpenBar:ie,resetPlayhead:se,fpSettingsFromRef:ze,cancelAndRestartWorker:ye,runHorizonAdvance:Ue,updatePriceHistoryToRawIdx:Oe,findPriceHistoryIdx:ke,loadData:Be}}import{useEffect as UV}from"react";var Uv=!1,em={get locked(){return Uv},lock(){Uv=!0},unlock(){Uv=!1}};import{useEffect as WR,useState as tm}from"react";import{jsx as ve,jsxs as Ct}from"react/jsx-runtime";var zR=15;function et({children:e}){return ve("svg",{width:zR,height:zR,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e})}function nn({x:e,y:t,r:n=2}){return ve("circle",{cx:e,cy:t,r:n,fill:"currentColor",stroke:"none"})}var He=(e,t,n,r,o)=>ve("line",{x1:e,y1:t,x2:n,y2:r},o),Ga={cursor:ve(et,{children:ve("path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"})}),cat_lines:Ct(et,{children:[He(4,19,20,6),ve(nn,{x:4,y:19}),ve(nn,{x:20,y:6})]}),cat_fib:Ct(et,{children:[He(4,5,20,5),He(4,10,20,10),He(4,14,20,14),He(4,19,20,19)]}),cat_patterns:Ct(et,{children:[ve("path",{d:"M4 18 L9 8 L13 15 L20 5"}),ve(nn,{x:9,y:8,r:1.6}),ve(nn,{x:13,y:15,r:1.6})]}),cat_shapes:ve(et,{children:ve("rect",{x:4,y:4,width:16,height:16,rx:2})}),cat_annotations:Ct(et,{children:[He(5,6,19,6),He(12,6,12,19)]}),cat_arrows:Ct(et,{children:[ve("path",{d:"M6 18 L18 6"}),ve("path",{d:"M11 6 L18 6 L18 13"})]}),cat_forecast:Ct(et,{children:[ve("circle",{cx:12,cy:12,r:8}),He(12,12,16,9),ve(nn,{x:12,y:12,r:1.6})]}),cat_measure:Ct(et,{children:[He(5,20,5,8),He(11,20,11,4),He(17,20,17,12)]}),line:Ct(et,{children:[He(4,19,20,6),ve(nn,{x:4,y:19}),ve(nn,{x:20,y:6})]}),ray:Ct(et,{children:[He(5,19,21,5),ve(nn,{x:5,y:19})]}),hline:Ct(et,{children:[He(3,12,21,12),ve(nn,{x:9,y:12})]}),vline:Ct(et,{children:[He(12,3,12,21),ve(nn,{x:12,y:9})]}),"extended-line":Ct(et,{children:[He(3,21,21,3),ve(nn,{x:9,y:15}),ve(nn,{x:15,y:9})]}),hray:Ct(et,{children:[He(5,12,21,12),ve(nn,{x:5,y:12})]}),"cross-line":Ct(et,{children:[He(3,12,21,12),He(12,3,12,21),ve(nn,{x:12,y:12,r:1.6})]}),"info-line":Ct(et,{children:[He(4,19,20,6),ve(nn,{x:4,y:19}),ve(nn,{x:20,y:6}),ve("rect",{x:9,y:10,width:6,height:4,rx:2})]}),"trend-angle":Ct(et,{children:[He(4,19,20,7),ve("path",{d:"M4 19 H14"}),ve("path",{d:"M11 19 A7 7 0 0 0 9.5 15.5"}),ve(nn,{x:4,y:19})]}),"parallel-channel":Ct(et,{children:[He(4,16,20,5),He(4,19,20,8),ve(nn,{x:4,y:16}),ve(nn,{x:20,y:5})]}),"flat-channel":Ct(et,{children:[He(4,8,20,8),He(4,16,20,16),ve(nn,{x:4,y:8}),ve(nn,{x:20,y:16})]}),"disjoint-channel":Ct(et,{children:[He(4,14,20,5),He(4,20,16,12),ve(nn,{x:4,y:14}),ve(nn,{x:20,y:5})]}),"regression-trend":Ct(et,{children:[He(4,9,20,5),He(4,19,20,15),He(4,14,20,10)]}),pitchfork:Ct(et,{children:[He(4,12,12,12),He(12,5,12,19),He(12,5,20,5),He(12,19,20,19),ve(nn,{x:4,y:12,r:1.6})]}),"schiff-pitchfork":Ct(et,{children:[He(4,14,12,10),He(12,4,12,18),He(12,4,20,4),He(12,18,20,18),ve(nn,{x:4,y:14,r:1.6})]}),"modified-schiff-pitchfork":Ct(et,{children:[He(5,15,12,11),He(12,5,12,19),He(12,5,20,6),He(12,19,20,18),ve(nn,{x:5,y:15,r:1.6})]}),"inside-pitchfork":Ct(et,{children:[He(6,12,12,12),He(12,7,12,17),He(12,7,19,7),He(12,17,19,17),ve(nn,{x:6,y:12,r:1.6})]}),fib:Ct(et,{children:[He(4,6,20,6),He(4,11,20,11),He(4,15,20,15),He(4,19,20,19),ve(nn,{x:4,y:6,r:1.6}),ve(nn,{x:20,y:19,r:1.6})]}),"fib-extension":Ct(et,{children:[He(4,7,20,7),He(4,11,20,11),He(4,15,14,15),He(4,19,14,19),ve("path",{d:"M5 18 L9 11 L13 16"})]}),"fib-trend-extension":Ct(et,{children:[ve("path",{d:"M4 19 L9 9 L14 14"}),He(14,5,21,5),He(14,10,21,10),He(14,15,21,15)]}),"fib-channel":Ct(et,{children:[He(4,18,20,7),He(4,14,20,3),He(4,21,20,10)]}),"fib-time-zone":Ct(et,{children:[He(5,4,5,20),He(9,4,9,20),He(15,4,15,20),ve("path",{d:"M21 4 L21 20",strokeDasharray:"0.1 4"})]}),"fib-speed-fan":Ct(et,{children:[He(4,20,20,20),He(4,20,20,12),He(4,20,20,5),ve(nn,{x:4,y:20,r:1.6})]}),"fib-circles":Ct(et,{children:[ve("circle",{cx:6,cy:18,r:4}),ve("circle",{cx:6,cy:18,r:8}),ve("circle",{cx:6,cy:18,r:12}),ve(nn,{x:6,y:18,r:1.4})]}),"fib-spiral":ve(et,{children:ve("path",{d:"M12 12 a2 2 0 1 1 2 -2 a4 4 0 1 1 -4 4 a6.5 6.5 0 1 1 6.5 -6.5"})}),"fib-wedge":Ct(et,{children:[He(4,20,20,4),He(4,20,20,12),ve("path",{d:"M20 4 A16 16 0 0 1 20 12"}),ve(nn,{x:4,y:20,r:1.6})]}),"gann-box":Ct(et,{children:[ve("rect",{x:4,y:4,width:16,height:16,rx:2}),He(4,20,20,4),He(4,4,20,20)]}),"gann-square":Ct(et,{children:[ve("rect",{x:4,y:4,width:16,height:16,rx:2}),He(12,4,12,20),He(4,12,20,12)]}),"gann-fan":Ct(et,{children:[He(4,20,20,20),He(4,20,20,13),He(4,20,20,4),He(4,20,13,4),ve(nn,{x:4,y:20,r:1.6})]}),xabcd:ve(et,{children:ve("path",{d:"M4 16 L8 6 L13 18 L17 7 L20 15"})}),cypher:ve(et,{children:ve("path",{d:"M4 14 L8 6 L12 17 L16 9 L20 13"})}),abcd:Ct(et,{children:[ve("path",{d:"M5 18 L10 7 L14 14 L19 5"}),ve(nn,{x:10,y:7,r:1.6}),ve(nn,{x:14,y:14,r:1.6})]}),"head-shoulders":ve(et,{children:ve("path",{d:"M3 17 L7 12 L9 15 L12 6 L15 15 L17 12 L21 17"})}),"triangle-pattern":Ct(et,{children:[ve("path",{d:"M4 6 L20 12 L4 18"}),ve(nn,{x:20,y:12,r:1.6})]}),"three-drives":ve(et,{children:ve("path",{d:"M4 18 L7 12 L9 16 L13 8 L15 12 L20 4"})}),"elliott-impulse":ve(et,{children:ve("path",{d:"M4 18 L8 10 L10 14 L15 5 L17 9 L20 6"})}),"elliott-correction":ve(et,{children:ve("path",{d:"M5 8 L10 16 L15 9 L19 15"})}),"elliott-triangle":ve(et,{children:ve("path",{d:"M4 6 L8 16 L12 8 L16 14 L20 10"})}),"elliott-double-combo":ve(et,{children:ve("path",{d:"M4 8 L8 15 L12 9 L16 15 L20 9"})}),"elliott-triple-combo":ve(et,{children:ve("path",{d:"M3 9 L6 15 L9 10 L12 15 L15 10 L18 15 L21 10"})}),rect:ve(et,{children:ve("rect",{x:4,y:6,width:16,height:12,rx:2})}),"rotated-rect":ve(et,{children:ve("path",{d:"M3 14 L10 5 L21 10 L14 19 Z"})}),ellipse:ve(et,{children:ve("ellipse",{cx:12,cy:12,rx:9,ry:6})}),circle:ve(et,{children:ve("circle",{cx:12,cy:12,r:8})}),triangle:ve(et,{children:ve("path",{d:"M12 4 L20 19 L4 19 Z"})}),polygon:ve(et,{children:ve("path",{d:"M12 3 L20 9 L17 19 L7 19 L4 9 Z"})}),arc:Ct(et,{children:[ve("path",{d:"M4 19 A12 12 0 0 1 20 19"}),ve(nn,{x:4,y:19,r:1.6}),ve(nn,{x:20,y:19,r:1.6})]}),curve:ve(et,{children:ve("path",{d:"M4 18 C9 4 15 4 20 18"})}),"double-curve":ve(et,{children:ve("path",{d:"M3 14 C6 6 9 6 12 14 C15 22 18 22 21 14"})}),polyline:Ct(et,{children:[ve("path",{d:"M4 18 L9 8 L14 14 L20 5"}),ve(nn,{x:4,y:18,r:1.6}),ve(nn,{x:9,y:8,r:1.6}),ve(nn,{x:14,y:14,r:1.6}),ve(nn,{x:20,y:5,r:1.6})]}),path:ve(et,{children:ve("path",{d:"M4 16 C8 16 7 7 12 7 C17 7 16 17 20 17"})}),text:Ct(et,{children:[He(5,6,19,6),He(12,6,12,19)]}),"anchored-text":Ct(et,{children:[He(7,7,19,7),He(13,7,13,18),ve(nn,{x:4,y:20}),He(4,20,7,14)]}),note:Ct(et,{children:[ve("path",{d:"M5 4 H19 V15 L14 20 H5 Z"}),ve("path",{d:"M19 15 H14 V20"})]}),callout:ve(et,{children:ve("path",{d:"M4 5 H20 V15 H10 L6 19 V15 H4 Z"})}),comment:Ct(et,{children:[ve("path",{d:"M4 5 H20 V16 H13 L9 20 V16 H4 Z"}),He(8,10,16,10)]}),"price-label":ve(et,{children:ve("path",{d:"M4 12 L8 7 H20 V17 H8 Z"})}),signpost:Ct(et,{children:[He(8,4,8,20),ve("path",{d:"M8 6 H18 L20 9 L18 12 H8 Z"})]}),flag:Ct(et,{children:[He(6,3,6,21),ve("path",{d:"M6 4 H18 L15 8 L18 12 H6 Z"})]}),pin:Ct(et,{children:[ve("path",{d:"M12 21 C12 21 19 14 19 9 A7 7 0 0 0 5 9 C5 14 12 21 12 21 Z"}),ve("circle",{cx:12,cy:9,r:2.2})]}),table:Ct(et,{children:[ve("rect",{x:4,y:5,width:16,height:14,rx:2}),He(4,10,20,10),He(12,5,12,19)]}),arrow:Ct(et,{children:[ve("path",{d:"M5 19 L19 5"}),ve("path",{d:"M11 5 H19 V13"})]}),"arrow-marker":Ct(et,{children:[ve("path",{d:"M4 20 L20 4"}),ve("path",{d:"M20 4 L13 6 L18 11 Z"})]}),"arrow-up":Ct(et,{children:[ve("path",{d:"M12 20 V5"}),ve("path",{d:"M6 11 L12 5 L18 11"})]}),"arrow-down":Ct(et,{children:[ve("path",{d:"M12 4 V19"}),ve("path",{d:"M6 13 L12 19 L18 13"})]}),brush:ve(et,{children:ve("path",{d:"M4 20 C8 20 8 12 12 10 C16 8 14 4 18 4"})}),highlighter:Ct(et,{children:[ve("path",{d:"M4 19 L13 10 L17 14 L8 19 Z"}),ve("path",{d:"M13 10 L16 7 L20 11 L17 14"})]}),long:Ct(et,{children:[ve("rect",{x:4,y:12,width:16,height:6,rx:2}),ve("path",{d:"M12 12 V4"}),ve("path",{d:"M8 8 L12 4 L16 8"})]}),short:Ct(et,{children:[ve("rect",{x:4,y:6,width:16,height:6,rx:2}),ve("path",{d:"M12 12 V20"}),ve("path",{d:"M8 16 L12 20 L16 16"})]}),forecast:Ct(et,{children:[ve("path",{d:"M4 16 L9 10 L12 13"}),ve("path",{d:"M12 13 L20 5",strokeDasharray:"3 2"}),ve(nn,{x:4,y:16,r:1.6})]}),projection:Ct(et,{children:[ve("rect",{x:4,y:5,width:7,height:14,rx:2}),ve("rect",{x:14,y:9,width:6,height:7,rx:2,strokeDasharray:"3 2"})]}),"price-range":Ct(et,{children:[He(12,4,12,20),ve("path",{d:"M8 8 L12 4 L16 8"}),ve("path",{d:"M8 16 L12 20 L16 16"})]}),"date-range":Ct(et,{children:[He(4,12,20,12),ve("path",{d:"M8 8 L4 12 L8 16"}),ve("path",{d:"M16 8 L20 12 L16 16"})]}),"date-price-range":Ct(et,{children:[ve("rect",{x:5,y:6,width:14,height:12,rx:2,strokeDasharray:"3 2"}),He(5,18,19,6)]}),"bars-pattern":Ct(et,{children:[He(7,6,7,18),He(5,9,7,9),He(7,14,9,14),He(14,5,14,19),He(12,8,14,8),He(14,12,16,12)]}),"ghost-feed":Ct(et,{children:[He(6,6,6,16),He(11,9,11,19),ve("path",{d:"M16 6 V16",strokeDasharray:"3 2"}),ve("path",{d:"M20 9 V19",strokeDasharray:"3 2"})]}),fvp:Ct(et,{children:[He(4,6,13,6),He(4,10,19,10),He(4,14,10,14),He(4,18,16,18)]}),"anchored-volume-profile":Ct(et,{children:[He(5,4,5,20),He(7,7,14,7),He(7,11,20,11),He(7,15,12,15),ve(nn,{x:5,y:20,r:1.6})]}),"fixed-range-volume":Ct(et,{children:[He(5,4,5,20),He(19,4,19,20),He(7,9,13,9),He(7,14,16,14)]}),"anchored-vwap":Ct(et,{children:[ve("path",{d:"M4 18 C9 18 9 8 14 8 C18 8 18 13 20 13"}),ve(nn,{x:4,y:18})]}),ruler:Ct(et,{children:[ve("rect",{x:3,y:8,width:18,height:8,rx:2,transform:"rotate(-20 12 12)"}),He(8,7,9,9),He(11,5.5,12,7.5),He(14,4,15,6)]})};var It=(e,t,n)=>({tool:e,label:t,icon:Ga[e],shortcut:n?.shortcut,implemented:n?.implemented}),xo=(e,t,n)=>It(e,t,{shortcut:n,implemented:!0}),eo=(e,t)=>({label:e,items:t}),jv=[{id:"lines",label:"Lines",icon:Ga.cat_lines,groups:[eo("Trend Lines",[xo("line","Trend Line","L"),xo("ray","Ray","R"),xo("hline","Horizontal Line","H"),xo("vline","Vertical Line","V"),xo("extended-line","Extended Line"),xo("hray","Horizontal Ray"),xo("cross-line","Cross Line"),xo("info-line","Info Line"),xo("trend-angle","Trend Angle")]),eo("Channels",[xo("parallel-channel","Parallel Channel"),It("flat-channel","Flat Channel"),It("disjoint-channel","Disjoint Channel"),It("regression-trend","Regression Trend")]),eo("Pitchforks",[It("pitchfork","Andrews Pitchfork"),It("schiff-pitchfork","Schiff Pitchfork"),It("modified-schiff-pitchfork","Modified Schiff Pitchfork"),It("inside-pitchfork","Inside Pitchfork")])]},{id:"fib",label:"Fibonacci & Gann",icon:Ga.cat_fib,groups:[eo("Fibonacci",[xo("fib","Fib Retracement","F"),It("fib-extension","Fib Extension"),It("fib-trend-extension","Trend-Based Fib Extension"),It("fib-channel","Fib Channel"),It("fib-time-zone","Fib Time Zone"),It("fib-speed-fan","Fib Speed/Resistance Fan"),It("fib-circles","Fib Circles"),It("fib-spiral","Fib Spiral"),It("fib-wedge","Fib Wedge")]),eo("Gann",[It("gann-box","Gann Box"),It("gann-square","Gann Square"),It("gann-fan","Gann Fan")])]},{id:"patterns",label:"Patterns",icon:Ga.cat_patterns,groups:[eo("Harmonic",[It("xabcd","XABCD Pattern"),It("cypher","Cypher Pattern"),It("abcd","ABCD Pattern"),It("three-drives","Three Drives Pattern")]),eo("Chart Patterns",[It("head-shoulders","Head and Shoulders"),It("triangle-pattern","Triangle Pattern")]),eo("Elliott Waves",[It("elliott-impulse","Impulse Wave (12345)"),It("elliott-correction","Correction Wave (ABC)"),It("elliott-triangle","Triangle Wave (ABCDE)"),It("elliott-double-combo","Double Combo (WXY)"),It("elliott-triple-combo","Triple Combo (WXYXZ)")])]},{id:"shapes",label:"Shapes",icon:Ga.cat_shapes,groups:[eo("Geometric",[xo("rect","Rectangle","R"),It("rotated-rect","Rotated Rectangle"),It("ellipse","Ellipse"),It("circle","Circle"),xo("triangle","Triangle"),It("polygon","Polygon"),It("arc","Arc")]),eo("Freehand",[It("curve","Curve"),It("double-curve","Double Curve"),It("polyline","Polyline"),It("path","Path")])]},{id:"annotations",label:"Annotations",icon:Ga.cat_annotations,groups:[eo("Text",[xo("text","Text","T"),It("anchored-text","Anchored Text"),It("note","Note"),It("callout","Callout"),It("comment","Comment")]),eo("Labels",[It("price-label","Price Label"),It("signpost","Signpost"),It("flag","Flag Mark"),It("pin","Pin"),It("table","Table")])]},{id:"arrows",label:"Arrows & Brushes",icon:Ga.cat_arrows,groups:[eo("Arrows",[It("arrow","Arrow"),It("arrow-marker","Arrow Marker"),It("arrow-up","Arrow Mark Up"),It("arrow-down","Arrow Mark Down")]),eo("Brushes",[It("brush","Brush"),It("highlighter","Highlighter")])]},{id:"forecast",label:"Forecast & Positions",icon:Ga.cat_forecast,groups:[eo("Positions",[xo("long","Long Position","U"),xo("short","Short Position","I")]),eo("Forecasting",[It("forecast","Forecast"),It("projection","Projection"),It("bars-pattern","Bars Pattern"),It("ghost-feed","Ghost Feed")]),eo("Ranges",[It("price-range","Price Range"),It("date-range","Date Range"),It("date-price-range","Date and Price Range")])]},{id:"measure",label:"Volume & Measure",icon:Ga.cat_measure,groups:[eo("Volume Profile",[xo("fvp","Fixed Volume Profile","P"),It("anchored-volume-profile","Anchored Volume Profile"),It("fixed-range-volume","Fixed Range Volume Profile")]),eo("Tools",[It("anchored-vwap","Anchored VWAP"),It("ruler","Measure")])]}],HR=jv.flatMap(e=>e.groups.flatMap(t=>t.items));function VR(e){return HR.find(t=>t.tool===e)}var Zh=(()=>{let e={Escape:"cursor"};for(let t of HR){if(!t.implemented||!t.shortcut)continue;let n=t.shortcut.toLowerCase();e[n]=t.tool,e[n.toUpperCase()]=t.tool}return e})();import{jsx as xn,jsxs as ps}from"react/jsx-runtime";function zV({icon:e}){return typeof e>"u"?xn(Ko,{className:"w-4 h-4"}):xn("svg",{viewBox:e.viewBox,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"w-4 h-4",children:e.paths.map((t,n)=>xn("path",{d:t},n))})}function HV(){let[e,t]=tm(new Set);return WR(()=>{let r=()=>{let o=qr(Cn.drawingFavorites,null);t(new Set(Array.isArray(o)?o:[]))};return r(),nd(r)},[]),[e,r=>{t(o=>{let a=new Set(o);return a.has(r)?a.delete(r):a.add(r),kr(Cn.drawingFavorites,[...a]),a})}]}function Gv({active:e,label:t,children:n,onClick:r}){return ps(Ht,{delayDuration:300,children:[xn(Ot,{asChild:!0,children:xn("button",{className:ee("w-7 h-7 min-h-7 flex items-center justify-center rounded transition-colors",e?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground"),onClick:r,"aria-label":t,children:n})}),xn(_t,{side:"right",className:"flex items-center gap-2 bg-background border border-border",children:xn("span",{children:t})})]})}function VV({category:e,activeTool:t,open:n,onOpenChange:r,onSelect:o,favorites:a,onToggleFavorite:i}){let s=e.groups.some(l=>l.items.some(c=>c.tool===t));return ps(xu,{open:n,onOpenChange:r,children:[ps(Ht,{delayDuration:300,children:[xn(Ot,{asChild:!0,children:xn(Su,{asChild:!0,children:xn("button",{className:ee("w-7 h-7 flex items-center justify-center rounded transition-colors min-h-7",s||n?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-accent hover:text-foreground"),"aria-label":e.label,children:e.icon})})}),!n&&xn(_t,{side:"right",className:"bg-background border border-border",children:e.label})]}),xn(Zl,{side:"right",align:"start",sideOffset:6,className:"w-60 max-h-[70vh] overflow-y-auto p-1 bg-background border-border",children:e.groups.map((l,c)=>ps("div",{className:ee("flex flex-col",c>0&&"mt-1.5"),children:[ps("div",{className:"flex items-center gap-2 px-2 pt-1 pb-1",children:[xn("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:l.label}),xn("span",{className:"h-px flex-1 bg-border/60"})]}),xn("div",{className:"flex flex-col gap-0.5",children:l.items.map(u=>xn(WV,{item:u,active:u.tool===t,favorited:a.has(u.tool),onSelect:()=>{u.implemented&&(o(u.tool),r(!1))},onToggleFavorite:()=>i(u.tool)},u.tool))})]},l.label))})]})}function WV({item:e,active:t,favorited:n,onSelect:r,onToggleFavorite:o}){return ps("div",{className:ee("group flex items-center gap-2 rounded pl-2 pr-1 py-1 text-xs transition-colors duration-200 hover:duration-0",e.implemented?ee("cursor-pointer",t?"bg-primary/15 text-primary":"text-foreground hover:bg-muted/70"):"text-muted-foreground/50 cursor-not-allowed"),onClick:r,children:[xn("span",{className:"shrink-0 [&>svg]:w-3.5 [&>svg]:h-3.5",children:e.icon}),xn("span",{className:"flex-1 truncate",children:e.label}),!e.implemented&&xn("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/60",children:"soon"}),e.implemented&&e.shortcut&&xn("kbd",{className:"inline-flex h-4 min-w-4 items-center justify-center rounded bg-muted px-1 font-mono text-[10px] leading-none text-muted-foreground",children:e.shortcut}),e.implemented&&xn("button",{"aria-label":n?"Unfavorite":"Favorite",className:ee("flex h-5 w-5 shrink-0 items-center justify-center rounded transition-opacity hover:bg-muted",n?"text-primary opacity-100":"text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground"),onClick:a=>{a.stopPropagation(),o()},children:xn(Ol,{size:13,fill:n?"currentColor":"none"})})]})}function qV({children:e}){let[t,n]=tm(null),[r,o]=tm(!1),[a,i]=tm(!1);WR(()=>{if(!t)return;let l=()=>{o(t.scrollTop>0),i(t.scrollTop+t.clientHeight<t.scrollHeight-1)};l(),t.addEventListener("scroll",l,{passive:!0});let c=new ResizeObserver(l);return c.observe(t),t.firstElementChild&&c.observe(t.firstElementChild),()=>{t.removeEventListener("scroll",l),c.disconnect()}},[t]);let s=l=>{t?.scrollBy({top:l==="up"?-120:120,behavior:"smooth"})};return ps("div",{className:"relative flex flex-col w-full flex-1 min-h-0",children:[xn("div",{ref:n,className:"flex-1 min-h-0 w-full overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:xn("div",{className:"flex flex-col items-center gap-0.5",children:e})}),xn("div",{className:ee("pointer-events-none absolute inset-x-0 top-0 flex justify-center pb-2 bg-gradient-to-b from-background to-transparent transition-opacity duration-150",r?"opacity-100":"opacity-0"),children:xn("button",{onClick:()=>s("up"),"aria-label":"Scroll up",className:ee("flex items-center justify-center w-7 h-4 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",r?"pointer-events-auto":"pointer-events-none"),children:xn(oi,{size:12})})}),xn("div",{className:ee("pointer-events-none absolute inset-x-0 bottom-0 flex justify-center pt-2 bg-gradient-to-t from-background to-transparent transition-opacity duration-150",a?"opacity-100":"opacity-0"),children:xn("button",{onClick:()=>s("down"),"aria-label":"Scroll down",className:ee("flex items-center justify-center w-7 h-4 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",a?"pointer-events-auto":"pointer-events-none"),children:xn(Zn,{size:12})})})]})}function Yv(){return xn("div",{className:"w-5 border-t border-border my-1"})}function qR({activeTool:e,onToolChange:t,pluginDrawings:n}){let[r,o]=HV(),[a,i]=tm(null),s=[...r].map(l=>VR(l)).filter(l=>!!l&&!!l.implemented);return ps("div",{className:"flex flex-col items-center gap-0.5 py-2 px-1 border-r border-border bg-background shrink-0 w-9 min-h-0",children:[xn(Gv,{active:e==="cursor",label:"Cursor",onClick:()=>t("cursor"),children:Ga.cursor}),xn(Yv,{}),ps(qV,{children:[jv.map(l=>xn(VV,{category:l,activeTool:e,open:a===l.id,onOpenChange:c=>i(c?l.id:null),onSelect:t,favorites:r,onToggleFavorite:o},l.id)),n.length>0&&xn(Yv,{}),n.map(l=>xn(Gv,{active:e===l.id,label:l.name,onClick:()=>t(l.id),children:l.icon?xn(zV,{icon:l.icon}):xn(Ko,{className:"w-4 h-4"})},l.id)),s.length>0&&xn(Yv,{}),s.map(l=>xn(Gv,{active:e===l.tool,label:l.label,onClick:()=>t(l.tool),children:l.icon},l.tool))]})]})}function Kv(e){switch(e){case"tl":case"br":return"nwse-resize";case"tr":case"bl":return"nesw-resize";case"mt":case"mb":return"ns-resize";case"ml":case"mr":return"ew-resize";case"a":case"b":case"c":case"anchor":return"crosshair";case"body":return"move";case"all":return"default";default:return"pointer"}}function UR(e,t,n,r){if(r&&e>0&&t>0){let s=Math.log(e),l=Math.log(t),c=(s+l)/2,u=(l-s)/2*n;return[Math.exp(c-u),Math.exp(c+u)]}let o=t-e,a=e+o/2,i=o*n;return[a-i/2,a+i/2]}function jR(e){let{status:t,cellId:n,baseCanvasRef:r,uiCanvasRef:o,chartAreaRef:a,containerRef:i,viewRef:s,priceScaleWidthRef:l,symbolInfoRef:c,isYAxisAutoRef:u,drawingsRef:d,draftRef:m,selectedDrawingIdRef:f,hoveredDrawingIdRef:h,hotAnchorRef:p,draggingAnchorRef:g,dragPrevDataRef:y,dragPrevPixelRef:v,fvpLiveRecalcRef:b,activeCtxRef:S,panesRef:C,indicatorsRef:w,draggingDividerRef:k,dragPaneIdRef:M,hoveredDividerIdxRef:I,hoveredDividerIdxRefLocked:x,hoveredPaneIdRef:T,activeToolRef:R,chartSettingsRef:P,activeTimeframeRef:D,sessionMapperRef:N,resolvedSessionRef:O,renderEngineRef:A,pluginChartTypesRef:B,crosshairRef:E,isDragging:L,dragMode:z,isHoldingCtrlRef:Y,isHoldingShiftRef:G,lastMouse:H,hasDragged:W,longPressTimer:U,showTooltipRef:V,shiftAnchorRef:K,shiftAnchor2Ref:Z,showShiftInfo:de,lastStatusLineUpdateRef:ze,horizonRef:xe,tradesRef:Ae,priceHistoryRef:Oe,allPriceHistoryRef:ke,ohlcvBarsRef:Q,previewBarsRef:Pe,dataLevelRef:_,openBarRef:ie,candleCacheRef:se,footprintBarsRef:Se,datasetStartRef:Re,datasetEndRef:ye,horizonScrollAnimRef:$e,liveBookRef:Ue,tradeLineInteractionRef:je,selectedTradeRef:ht,transformer:Be,eventBus:xt,features:fn,showTimeframeWindowRef:In,setActiveTool:kt,setSelectedDrawingId:it,setSettingsBarPos:ft,setContextMenu:oe,setPanes:pe,setChartSettings:fe,setEditingTextId:Ie,setOpenSettingsDialog:Ve,setShowTimeframeWindow:qe,setTimeframeWindowInput:Fe,setPendingText:De,pushDrawParams:we,publishTimeRangeSync:_e,scheduleResample:Ne,runIndicatorWorker:dt,getTradesUpToHorizon:Pt,updateSettingsBarPos:J,handleDeleteDrawing:Te,autofitPanesSilent:Le,autofitIndicatorPanes:ot,getPanel:tt,getLayouts:mt,recomputeLayouts:qt,applyLayoutsToDom:Dt,buildChartTypeActiveCtx:rr}=e;function wn(q){R.current=q,kt(q)}function er(){m.current=null,wn(Vo)}function Pn(){let q=Be.getOrdinal();if(q){let nt=Math.min(3400,Math.max(10,q.length+20));return{min:3n,max:BigInt(nt)}}let he=D.current.barNs;if(he<=0n)return{min:yp,max:vp};let me=he*3n,We=he*3400n;return{min:me,max:We}}function cr(q){let he=Be.getOrdinal();if(he){let pt=he.length,Ze=Be.tsToFracIndex(q.tMin),Tt=Be.tsToFracIndex(q.tMax),Gt=Tt-Ze;if(Gt<=0)return;let Xt=Math.min(Gt*.5,20),X=pt-1+Xt;Tt>X&&(Ze-=Tt-X,Tt=X),Ze<0&&(Tt+=-Ze,Ze=0),q.tMin=Be.indexToTs(Ze),q.tMax=Be.indexToTs(Tt);return}let me=Re.current+D.current.barNs/2n,We=ye.current;if(me===0n||We===0n)return;let nt=q.tMax-q.tMin,gt=xe.current,vt=gt>0n&><We?gt-D.current.barNs*3n/2n:We-D.current.barNs*3n/2n;q.tMin+nt<me&&(q.tMin=me-nt,q.tMax=me),q.tMin>vt&&(q.tMin=vt,q.tMax=vt+nt)}function Mn(q,he){if(q>xe.current)return he;let me=P.current.chartType;if(_.current==="ohlcv"){let We=Q.current.display.find(Ze=>Ze.time===Number(q/1000000n));if(!We)return he;let nt=[Math.abs(We.open-he),Math.abs(We.high-he),Math.abs(We.low-he),Math.abs(We.close-he)],gt=Math.min(...nt),vt=["open","high","low","close"],pt=null;for(let Ze=0;Ze<nt.length;Ze++)nt[Ze]===gt&&(pt=vt[Ze]);return pt?We[pt]:he}else{if(me==="candles"||me==="footprint"||me==="hollow"||me==="bars"){let Tt=Se.current;if(Tt.length===0)return he;let Gt=0,Xt=Tt.length-1,X=0;for(;Gt<=Xt;){let Ce=Gt+Xt>>>1;Tt[Ce].ts<=q?(X=Ce,Gt=Ce+1):Xt=Ce-1}let $=Tt[X];return[$.open,$.high,$.low,$.close].reduce((Ce,ct)=>Math.abs(ct-he)<Math.abs(Ce-he)?ct:Ce)}let We=Oe.current;if(We.length===0)return he;let nt=0,gt=We.length-1,vt=0;for(;nt<=gt;){let Tt=nt+gt>>>1;We[Tt].ts<=q?(vt=Tt,nt=Tt+1):gt=Tt-1}let pt=We[vt];return[pt.bestBid,pt.bestAsk].reduce((Tt,Gt)=>Math.abs(Gt-he)<Math.abs(Tt-he)?Gt:Tt)}}function An(q){return Fp(q,D.current.barNs,N.current)}function F(q,he,me){return{ts:he,price:me,x:q.clientX-o.current.getBoundingClientRect().left,y:q.clientY-o.current.getBoundingClientRect().top,shiftKey:q.shiftKey,ctrlKey:q.ctrlKey,altKey:q.altKey,buttons:q.buttons,ctx:rr()}}function re(q){return{key:q.key,code:q.code,shiftKey:q.shiftKey,ctrlKey:q.ctrlKey,ctx:rr()}}function ue(){let q=P.current.chartType;return B.current.get(q)??null}function ce(q,he){let me=ro(c.current),We=q.a.ts<q.b.ts?q.a.ts:q.b.ts,nt=q.a.ts<q.b.ts?q.b.ts:q.a.ts,gt=Ae.current.filter(Ce=>Ce.ts>=We&&Ce.ts<=nt),vt=new Map;for(let Ce of gt){if(Ce.ts>he)break;let ct=Math.round(Ce.price/me)*me,bt=vt.get(ct);bt?Ce.side==="B"?bt[0]+=Ce.size:bt[1]+=Ce.size:vt.set(ct,Ce.side==="B"?[Ce.size,0]:[0,Ce.size])}let pt=Array.from(vt.entries()).sort((Ce,ct)=>Ce[0]-ct[0]),Ze=pt.length,Tt=new Float64Array(Ze),Gt=new Float64Array(Ze),Xt=new Float64Array(Ze),X=new Float64Array(Ze),$=NaN,ge=-1;for(let Ce=0;Ce<Ze;Ce++){let[ct,[bt,le]]=pt[Ce];Tt[Ce]=ct,Gt[Ce]=bt,Xt[Ce]=le,X[Ce]=bt+le,bt+le>ge&&(ge=bt+le,$=ct)}return{prices:Tt,buyVol:Gt,sellVol:Xt,totalVol:X,poc:$}}UV(()=>{let q=r.current,he=a.current;if(!q||t!=="ready")return;let me={commitDrawing(le){let Ee=le,wt=Ee.pluginToolId??le.tool,{keepActive:Lt,...Ln}=le,Ut={...Ln,id:pn(),tool:wt,data:{...io.get(wt)?.defaultData,...Ee.data}};d.current=[...d.current,Ut],m.current=null,wn(Lt?ad(R.current.name):Vo),f.current=Ut.id,it(Ut.id),we(),A.current?.markDirty("drawings")},setDraft(le){m.current={...m.current,...le},we(),A.current?.markDirty("drawings")},requestRedraw(){A.current?.markDirty("drawings")},deactivate(){er(),we(),A.current?.markDirty("drawings")},getOverlayCanvas(){return o.current}};S.current=me;function We(le,Ee,wt,Lt){return{ts:Ee,price:wt,x:le.clientX-o.current.getBoundingClientRect().left,y:le.clientY-o.current.getBoundingClientRect().top,shiftKey:le.shiftKey,ctrlKey:le.ctrlKey,altKey:le.altKey,buttons:le.buttons,tool:me,plugin:Lt}}function nt(le){return{key:le.key,code:le.code,shiftKey:le.shiftKey,ctrlKey:le.ctrlKey,tool:me}}let gt=le=>{{let rt=je.current,Yt=!1,ut={...le,currentTarget:q,stopPropagation:()=>{Yt=!0},preventDefault:()=>le.preventDefault(),clientX:le.clientX,clientY:le.clientY,button:le.button};if(rt.onMouseDown(ut),Yt)return}if(le.button===1){let rt=q.getBoundingClientRect(),Yt=le.clientX-rt.left,ut=le.clientY-rt.top,ur=s.current;if(!ur)return;let Vt=Vn(),on=Cf(Yt,ut,d.current,ur,C.current,q.width/Vt,q.height/Vt,Be,e.hideTimeScale,e.priceScaleWidthRef.current,e.symbolInfoRef.current);on&&(le.preventDefault(),Te(on.drawingId));return}if(le.button!==0)return;let Ee=q.getBoundingClientRect(),wt=le.clientX-Ee.left,Lt=le.clientY-Ee.top,Ln=s.current;if(!Ln)return;let Ut=Vn(),Mt=q.width/Ut,zt=q.height/Ut,At=Mt-l.current,mn=wt<At&&Lt<zt-(e.hideTimeScale?0:yn),yt=mt(),Bt=yt.main,gr=Bt?.h??zt-(e.hideTimeScale?0:yn),or=Bt?.y??0,rn=Be.xToTs(wt,At),ln=An(rn),Nr=Be.yToPrice(Lt-or,gr),Hn=ue();if(Hn?.onPointerDown&&Hn.onPointerDown(F(le,ln,Nr))){le.preventDefault();return}if(R.current.name!=="cursor"){if(!mn)return;let Yt=mt().main,ut=Yt?.h??zt-(e.hideTimeScale?0:yn),ur=Yt?.y??0,Vt=Be.xToTs(wt,At),on=An(Vt),Gn=Be.yToPrice(Lt-ur,ut),Zt=m.current,an=Gn;G.current&&Zt?.a?.price?an=Zt.a.price:(le.ctrlKey||P.current.crosshairMode==="magnet")&&(an=Mn(on,Gn));let Nt={ts:on,price:an},Bn=R.current,Er=Bn.id||pn(),Mr={...Yi(Bn.name),...Bn.state},Yn=Lr=>{d.current=[...d.current,Lr],m.current=null,wn(Vo),f.current=Lr.id,it(Lr.id),we(),A.current?.markDirty("drawings"),J(Lr.id),Lr.tool==="fvp"&&dt(Pt(xe.current),D.current.barNs)},vr=io.get(Bn.name);if(vr?.onPointerDown&&vr.onPointerDown(We(le,on,an,vr))||vr&&vr.anchorCount===0)return;if(vr){let Lr=Zt,Fo=Lr?[...Lr.anchors,Nt]:[Nt];typeof vr.anchorCount=="number"&&Fo.length>=vr.anchorCount?Yn({id:pn(),tool:vr.id,anchors:Fo,data:{...vr.defaultData}}):(m.current={pluginToolId:vr.id,anchors:Fo},we(),A.current?.markDirty("drawings"));return}let Co={...Mr,id:Er,tool:Bn.name};switch(Bn.name){case"hline":Yn({...Co,price:an});break;case"vline":Yn({...Co,ts:on});break;case"hray":case"cross-line":Yn({...Co,price:an,ts:on});break;case"text":De({x:wt,y:Lt,anchor:Nt});break;case"long":case"short":{let Lr=ro(c.current),Fo=Math.abs(Be.yToPrice(0,ut)-Be.yToPrice(ut,ut)),Is=Math.max(Math.round(Fo*.05/Lr),1)*Lr,Ic=Bn.name==="long";Yn({...Co,a:Nt,b:{...Nt,ts:Nt.ts+D.current.barNs*10n},upAmount:Ic?Is*2:Is,downAmount:Ic?Is:Is*2});break}default:{if(!Zt){m.current={...Co,a:Nt,b:null},we(),A.current?.markDirty("drawings"),J(f.current);break}let Lr=Zt.a,Fo=Zt.b;switch(Bn.name){case"line":case"info-line":case"trend-angle":case"ray":case"extended-line":case"rect":case"fib":case"fvp":Yn({...Co,a:Lr,b:Nt});break;case"triangle":Fo?Yn({...Co,a:Lr,b:Fo,c:Nt}):m.current={...Zt,b:Nt};break;case"parallel-channel":Fo?Yn({...Co,a:Lr,b:Fo,height:an-Fo.price}):m.current={...Zt,b:Nt};break}}}le.stopPropagation();return}if(mn){let rt=Cf(wt,Lt,d.current,Ln,C.current,Mt,zt,Be,e.hideTimeScale,e.priceScaleWidthRef.current,e.symbolInfoRef.current),Yt=rt?d.current.find(ur=>ur.id===rt.drawingId):void 0,ut=Yt?.tool==="fvp"&&rt?.anchor==="body";if(rt&&Yt){if(f.current=rt.drawingId,it(rt.drawingId),J(rt.drawingId),!Yt.locked&&!ut){let Vt=mt().main,on=Vt?.h??zt-(e.hideTimeScale?0:yn),Gn=Vt?.y??0;g.current=rt,y.current={ts:Be.xToTs(wt,At),price:Be.yToPrice(Lt-Gn,on)},v.current={x:wt,y:Lt},q.style.cursor=Kv(rt.anchor)}if(we(),A.current?.markDirty("drawings"),!ut){le.stopPropagation();return}}!ut&&f.current&&(f.current=null,it(null),ft(null),we(),A.current?.markDirty("drawings"))}if(mn&&R.current.name==="cursor")if(de.current&&!Z.current){let Yt=mt().main,ut=Yt?.h??zt-(e.hideTimeScale?0:yn),ur=Yt?.y??0,Vt=Mt-l.current,on=Number(s.current.tMax-s.current.tMin),Gn=Math.max(0,Math.min(1,wt/Vt)),Zt=s.current.tMin+BigInt(Math.round(Gn*on)),an=s.current.pMax-s.current.pMin,Nt=1-Math.max(0,Math.min(1,(Lt-ur)/ut)),Bn=s.current.pMin+an*Nt;Z.current={ts:Zt,price:Bn,x:wt,y:Lt},we(),A.current?.markDirty("ui")}else de.current=!1,K.current=null,Z.current=null,we(),A.current?.markDirty("ui");if(le.shiftKey&&mn&&R.current.name==="cursor"&&!de.current){let Yt=mt().main,ut=Yt?.h??zt-(e.hideTimeScale?0:yn),ur=Yt?.y??0,Vt=Mt-l.current,on=Number(s.current.tMax-s.current.tMin),Gn=Math.max(0,Math.min(1,wt/Vt)),Zt=s.current.tMin+BigInt(Math.round(Gn*on)),an=s.current.pMax-s.current.pMin,Nt=1-Math.max(0,Math.min(1,(Lt-ur)/ut)),Bn=s.current.pMin+an*Nt;de.current=!0,K.current={ts:Zt,price:Bn,x:wt,y:Lt},Z.current=null,we(),A.current?.markDirty("ui"),le.stopPropagation();return}L.current=!0,W.current=!1,H.current={x:le.clientX,y:le.clientY},I.current>=0&&(x.current=!0);let Wr=ky(Lt,C.current,yt);Wr!==-1?(k.current=Wr,M.current=null,z.current="none"):wt>Mt-l.current?(k.current=-1,M.current=iu(Lt,C.current,yt)?.id??null,z.current="scaleY"):Lt>zt-(e.hideTimeScale?0:yn)?(k.current=-1,M.current=null,z.current="scaleX"):(k.current=-1,M.current=iu(Lt,C.current,yt)?.id??null,z.current="pan",$e.current=null),U.current=setTimeout(()=>{V.current=!0},500),we(),A.current?.markDirty("ui"),A.current?.markDirty("base")},vt=le=>{{let At=je.current,mn={currentTarget:q,stopPropagation:()=>{},preventDefault:()=>{},clientX:le.clientX,clientY:le.clientY,button:le.button};At.onMouseUp(mn)}let Ee=Vn(),wt=q.width/Ee,Lt=q.height/Ee,Ln=q.getBoundingClientRect(),Ut=le.clientX-Ln.left,Mt=le.clientY-Ln.top;if(g.current){let At=g.current.drawingId;g.current=null,y.current=null,v.current=null,we(),A.current?.markDirty("drawings"),q.style.cursor="crosshair",J(At),d.current.find(yt=>yt.id===At)?.tool==="fvp"&&dt(Pt(xe.current),D.current.barNs);return}if(R.current.name!=="cursor"){let At=io.get(R.current.name);if(At?.onPointerUp){let mn=wt-l.current;if(Ut<mn&&Mt<Lt-(e.hideTimeScale?0:yn)){let gr=mt().main,or=gr?.h??Lt-(e.hideTimeScale?0:yn),rn=gr?.y??0,ln=Be.xToTs(Ut,mn),Rn=An(ln),Hn=Be.yToPrice(Mt-rn,or);if(At.onPointerUp(We(le,Rn,Hn,At)))return}}}U.current&&clearTimeout(U.current),x.current=!1,V.current=!1,L.current=!1,z.current="none",k.current=-1,M.current=null,ot();let zt=je.current.cursorRef?.current??"default";zt!=="default"?q.style.cursor=zt:Ut>wt-l.current?q.style.cursor="ns-resize":Mt>Lt-(e.hideTimeScale?0:yn)?q.style.cursor="ew-resize":q.style.cursor="crosshair",W.current||pt(le),s.current&&s.current.tMin<Re.current&&xt.emit("data:request-backward",{viewMin:s.current.tMin,symbol:c.current?.symbol})},pt=le=>{let Ee=s.current;if(!Ee||document.elementFromPoint(le.clientX,le.clientY)!==q)return;let wt=q.getBoundingClientRect(),Lt=le.clientX-wt.left,Ln=le.clientY-wt.top,Ut=Vn(),Mt=q.width/Ut,zt=q.height/Ut,At=Mt-l.current,mn=zt-(e.hideTimeScale?0:yn);if(Lt>At||Ln>mn)return;{let Bt=je.current,gr={currentTarget:q,stopPropagation:()=>{},preventDefault:()=>{},clientX:le.clientX,clientY:le.clientY};Bt.onClick(gr);let or=Bt.cursorRef?.current??Bt.cursor;!L.current&&or!=="default"&&(q.style.cursor=or)}if(!P.current.showTradeDots)return;let yt=mt().main?.h??mn;ht.current=tk(Lt,Ln,Ae.current,Ee,At,yt,P.current,xe.current,Be),we(),A.current?.markDirty("ui")},Ze=le=>{In.current&&le.target&&le.target.id==="change-timeframe"&&(qe(!1),Fe(""))},Tt=le=>{{let zt=je.current,At=!1,mn={currentTarget:q,stopPropagation:()=>{At=!0},preventDefault:()=>{},clientX:le.clientX,clientY:le.clientY};if(zt.onDoubleClick(mn),At)return}let Ee=q.getBoundingClientRect(),wt=le.clientX-Ee.left,Lt=le.clientY-Ee.top,Ln=Vn(),Ut=q.width/Ln,Mt=q.height/Ln;if(wt<=Ut-l.current&&Lt<=Mt-(e.hideTimeScale?0:yn)){let zt=Cf(wt,Lt,d.current,s.current,C.current,Ut,Mt,Be,e.hideTimeScale,e.priceScaleWidthRef.current,e.symbolInfoRef.current);if(zt){if(d.current.find(mn=>mn.id===zt.drawingId)?.tool==="text"){it(zt.drawingId),f.current=zt.drawingId,Ie(zt.drawingId);return}it(zt.drawingId),f.current=zt.drawingId,J(zt.drawingId),Ve(!0),we(),A.current?.markDirty("drawings");return}}if(wt>Ut-l.current){let zt=mt(),At=iu(Lt,C.current,zt);if(At&&!At.isMain){let yt=w.current.find(rn=>rn.paneId===At.id),{tMin:Bt,tMax:gr}=s.current,or=yt?.getAutoYBounds?.(Bt,gr,xe.current);pe(rn=>{let ln=rn.map(Rn=>Rn.id!==At.id?Rn:{...Rn,yAxisAuto:!0,...or?{yMin:or.min,yMax:or.max}:{}});return C.current=ln,qt(),ln}),or&&(C.current=C.current.map(rn=>rn.id===At.id?{...rn,yAxisAuto:!0,yMin:or.min,yMax:or.max}:rn)),we(),J(f.current),A.current?.markAllDirty();return}u.current=!0,fe(yt=>({...yt,autoScale:u.current}));let mn=s.current;Ar(mn,Oe.current,Ae.current,_.current==="ohlcv"?Q.current.display:Pe.current,ie.current,P.current,xe.current,_.current),Ne(),we(),A.current?.markAllDirty()}else if(Lt>Mt-(e.hideTimeScale?0:yn)){let zt=s.current,At=Be.getOrdinal();if(At){let mn=At.length,yt=Math.min(mn,200);zt.tMin=Be.indexToTs(mn-yt),zt.tMax=Be.indexToTs(mn-1+Math.min(yt*.1,10))}else{let mn=800000000000n,yt=100000000000n,Bt=ke.current[ke.current.length-1].ts;zt.tMin=Bt-mn+yt,zt.tMax=Bt+yt}Ne(),we(),J(f.current),A.current?.markAllDirty()}},Gt=le=>{let Ee=s.current;if(!Ee)return;let wt=performance.now();if(wt-ze.current<=33)return;ze.current=wt;let Lt=Vn(),Ln=q.width/Lt-l.current;xt.emit("status:compute",{cellId:n,x:le,priceHistory:Oe.current,trades:Ae.current,bounds:Ee,chartW:Ln,barNs:D.current.barNs,candleCache:se.current,bars:Q.current.display,openBar:ie.current,horizon:xe.current,dataLevel:_.current,transformer:Be})},Xt=le=>{if(em.locked){E.current&&(E.current=null,A.current?.markDirty("ui"));return}Y.current=le.ctrlKey,G.current=le.shiftKey;let Ee=Vn(),wt=q.width/Ee,Lt=q.height/Ee,Ln=q.getBoundingClientRect(),Ut=le.clientX-Ln.left,Mt=le.clientY-Ln.top,zt=s.current;if(!zt)return;let At=!1;{let rt=je.current,Yt={currentTarget:q,stopPropagation:()=>{},preventDefault:()=>{},clientX:le.clientX,clientY:le.clientY};rt.onMouseMove(Yt);let ut=rt.cursorRef?.current??rt.cursor;!L.current&&ut!=="default"&&(q.style.cursor=ut,At=!0)}if((Ut<0||Mt<0||Ut>wt||Mt>Lt)&&!L.current&&!g.current){E.current!==null&&(E.current=null,we(),A.current?.markDirty("ui"));return}if(!L.current&&!g.current&&document.elementFromPoint(le.clientX,le.clientY)!==q){E.current!==null&&(E.current=null,we(),A.current?.markDirty("ui"));return}let yt=wt-l.current,Bt=Ut<yt&&Mt<Lt-(e.hideTimeScale?0:yn);if(E.current={x:Ut,y:Mt},xt.emit("crosshair:move",{x:Ut,y:Mt}),E.current&&s.current&&Gt(Ut),g.current){let{drawingId:rt,anchor:Yt}=g.current,ur=mt().main,Vt=ur?.h??Lt-(e.hideTimeScale?0:yn),on=ur?.y??0,Gn=Be.xToTs(Ut,yt),Zt=An(Gn),an=Be.yToPrice(Mt-on,Vt),Nt=an;(le.ctrlKey||P.current.crosshairMode==="magnet")&&Yt!=="body"&&(Nt=Mn(Zt,an),an=Nt);let Bn=y.current;if(Bn){let Er=(Zt-Bn.ts)/D.current.barNs*D.current.barNs,Mr=Nt-Bn.price;d.current=d.current.map(Yn=>{if(Yn.id!==rt)return Yn;if(Yn.tool==="text"&&Yn.screenAnchored){let Lr=v.current;if(Lr){let Fo=Ut-Lr.x,Is=Mt-Lr.y,Ic=(Yn.screenX??Ut)+Fo,zg=(Yn.screenY??Mt)+Is;return{...Yn,screenX:Ic,screenY:zg}}return Yn}let{drawing:vr,anchor:Co}=Bk(Yn,Yt,Er,Mr,Zt,Nt,G.current);return Co!==Yt&&g.current&&(g.current={drawingId:rt,anchor:Co}),vr})}if(y.current={ts:Zt,price:Nt},v.current={x:Ut,y:Mt},b.current){let Er=d.current.find(Mr=>Mr.id===g.current?.drawingId);if(Er?.tool==="fvp"){let Mr=Er,Yn=ce(Mr,xe.current);if(Er.vpData=Yn,Yn.prices.length>0){let vr=ro(c.current)/2;Er.a={ts:Mr.a.ts,price:Yn.prices[0]-vr},Er.b={ts:Mr.b.ts,price:Yn.prices[Yn.prices.length-1]+vr}}d.current=[...d.current]}}ft(null),q.style.cursor=Kv(g.current?.anchor??null),we(),A.current?.markDirty("drawings"),A.current?.markDirty("ui");return}if(R.current.name!=="cursor"){let rt=m.current,ut=mt().main,ur=ut?.h??Lt-(e.hideTimeScale?0:yn),Vt=ut?.y??0,on=Be.xToTs(Ut,yt),Gn=An(on),Zt=Be.yToPrice(Mt-Vt,ur),an=le.ctrlKey||P.current.crosshairMode==="magnet"?Mn(Gn,Zt):Zt;rt&&(rt.tool==="rect"||rt.tool==="fib"||rt.tool==="line"||rt.tool==="ray"||rt.tool==="fvp")&&(rt.b={ts:Gn,price:an},rt&&"pluginToolId"in rt&&(we(),A.current?.markDirty("drawings")));let Nt=io.get(R.current.name);if(Nt?.onPointerMove&&Nt.onPointerMove(We(le,Gn,an,Nt)))return;we(),A.current?.markDirty("drawings"),J(f.current),A.current?.markDirty("ui"),q.style.cursor="crosshair";return}if(Bt&&!L.current){let rt=Cf(Ut,Mt,d.current,zt,C.current,wt,Lt,Be,e.hideTimeScale,e.priceScaleWidthRef.current,e.symbolInfoRef.current),Yt=rt?.drawingId??null,ut=rt?.anchor??null;if((Yt!==h.current||ut!==p.current)&&(h.current=Yt,p.current=ut,we(),A.current?.markDirty("drawings"),J(f.current)),Yt&&!At){let ur=d.current.find(Vt=>Vt.id===Yt);ur&&!ur?.locked?q.style.cursor=Kv(ut):q.style.cursor="default"}else At||(q.style.cursor="crosshair")}let gr=mt(),or=ky(Mt,C.current,gr),rn=iu(Mt,C.current,gr),ln=L.current&&M.current?C.current.find(rt=>rt.id===M.current)??rn:rn;if(L.current){let rt=Math.abs(le.clientX-H.current.x),Yt=Math.abs(le.clientY-H.current.y);(rt>3||Yt>3)&&(W.current=!0),U.current&&(clearTimeout(U.current),U.current=null),V.current=!1}let Rn=!L.current&&or!==-1,Nr=L.current&&(z.current==="scaleY"||z.current==="scaleX");E.current=Rn||Nr?null:{x:Ut,y:Mt};let Hn=rn?.id??null;Hn!==T.current&&I.current<0&&(T.current=Hn,Hn&&xt.emit("pane:hovered",{id:Hn}));let Wr=Rn?or:-1;if(Wr!==I.current&&!x.current&&(I.current=Wr,xt.emit("pane:hovered",null)),L.current&&z.current==="pan"?q.style.cursor="grabbing":L.current&&(z.current==="scaleY"||z.current==="scaleX")?q.style.cursor=z.current==="scaleY"?"ns-resize":"ew-resize":!L.current&&!At&&(k.current===-1&&or!==-1||Ut>wt-l.current?q.style.cursor="ns-resize":Mt>Lt-(e.hideTimeScale?0:yn)&&(q.style.cursor="ew-resize")),L.current&&s.current){let rt=le.clientX-H.current.x,Yt=le.clientY-H.current.y;H.current={x:le.clientX,y:le.clientY};let ut=s.current,ur=wt-l.current;if(k.current!==-1){let Vt=k.current,on=C.current.map(vr=>({...vr})),Gn=Lt-(e.hideTimeScale?0:yn),Zt=on.reduce((vr,Co)=>vr+Co.heightRatio,0),an=Gn/Zt,Nt=Yt/an,Bn=on[Vt].heightRatio+Nt,Er=on[Vt+1].heightRatio-Nt,Mr=Sk*Zt;Bn>=Mr&&Er>=Mr&&(on[Vt].heightRatio=Bn,on[Vt+1].heightRatio=Er),C.current=on,pe(on);let Yn=Ji(on,Gn,wt,l.current);Dt(Yn),A.current?.markDirty("base"),A.current?.markDirty("drawings"),J(f.current),A.current?.markDirty("ui")}else if(z.current==="pan"){let Vt=Be.getSessionMapper();if(Be.getOrdinal()){let Zt=Be.getBarPx(ur);if(Zt>0){let an=rt/Zt,Nt=Be.tsToFracIndex(ut.tMin),Bn=Be.tsToFracIndex(ut.tMax);ut.tMin=Be.indexToTs(Nt-an),ut.tMax=Be.indexToTs(Bn-an)}}else if(Vt&&Vt.hasSession){let Zt=Vt.tsToMarket(ut.tMin),an=Vt.tsToMarket(ut.tMax),Nt=Number(an-Zt);if(Nt>0){let Bn=BigInt(Math.round(rt*(Nt/ur)));ut.tMin=Vt.marketToTs(Zt-Bn),ut.tMax=Vt.marketToTs(an-Bn)}}else{let Zt=Number(ut.tMax-ut.tMin);ut.tMin-=BigInt(Math.round(rt*(Zt/ur))),ut.tMax-=BigInt(Math.round(rt*(Zt/ur)))}cr(ut);let Gn=mt();if(ln&&!ln.isMain){let Zt=Gn[ln.id];if(Zt){let an=C.current.map(Nt=>{if(Nt.id!==ln.id)return Nt;if(Nt.yAxisAuto){let Bn=w.current.find(Mr=>Mr.paneId===Nt.id);if(!Bn?.getAutoYBounds)return Nt;let Er=Bn.getAutoYBounds(s.current.tMin,s.current.tMax,xe.current);return Er?{...Nt,yMin:Er.min,yMax:Er.max}:Nt}else{let Bn=Nt.yMax-Nt.yMin,Er=Yt*(Bn/Zt.h);return{...Nt,yMin:Nt.yMin+Er,yMax:Nt.yMax+Er}}});C.current=an,pe(an)}}else{if(u.current)Ar(ut,Oe.current,Ae.current,_.current==="ohlcv"?Q.current.display:Pe.current,ie.current,P.current,xe.current,_.current);else{let Zt=Gn.main?.h??Lt-(e.hideTimeScale?0:yn);if(Be.getScaleMode()==="log"&&ut.pMin>0&&ut.pMax>0){let an=Yt*(Math.log(ut.pMax)-Math.log(ut.pMin))/Zt,Nt=Math.exp(an);ut.pMin*=Nt,ut.pMax*=Nt}else{let an=Yt*(ut.pMax-ut.pMin)/Zt;ut.pMin+=an,ut.pMax+=an}}Le()}Be.update(ut),Be.setSessionMapper(N.current),Be.setSession(O.current),Ne(),A.current?.markDirty("base"),A.current?.markDirty("drawings"),J(f.current)}else if(z.current==="scaleY"){if(ln&&!ln.isMain){let Vt=C.current.map(on=>{if(on.id!==ln.id)return on;let Gn=on.yMax-on.yMin,Zt=on.yMin+Gn/2,an=Gn*(1+Yt*.002*P.current.priceAxisResizeSensitivity);return{...on,yMin:Zt-an/2,yMax:Zt+an/2,yAxisAuto:!1}});C.current=Vt,pe(Vt)}else{u.current=!1,fe(on=>({...on,autoScale:u.current}));let Vt=1+Yt*.002*P.current.priceAxisResizeSensitivity;[ut.pMin,ut.pMax]=UR(ut.pMin,ut.pMax,Vt,Be.getScaleMode()==="log")}Ne(),A.current?.markDirty("base"),A.current?.markDirty("drawings"),J(f.current)}else if(z.current==="scaleX"){let Vt=Be.getSessionMapper(),{min:on,max:Gn}=Pn();if(Vt&&Vt.hasSession){let Zt=Vt.tsToMarket(ut.tMax),an=Number(Vt.tsToMarket(ut.tMax)-Vt.tsToMarket(ut.tMin)),Nt=BigInt(Math.round(an*(1+rt*.001))),Bn=Nt<on?on:Nt>Gn?Gn:Nt;ut.tMin=Vt.marketToTs(Zt-Bn)}else{let Zt=Number(ut.tMax-ut.tMin),an=BigInt(Math.round(Zt*(1+rt*.001))),Nt=an<on?on:an>Gn?Gn:an;ut.tMin=ut.tMax-Nt}Ar(ut,Oe.current,Ae.current,_.current==="ohlcv"?Q.current.display:Pe.current,ie.current,P.current,xe.current,_.current),Le(),Ne(),A.current?.markDirty("base"),A.current?.markDirty("drawings"),J(f.current)}}tt()?.update(Ue.current),we(),_e(),A.current?.markDirty("ui")},X=()=>{{let le=je.current,Ee={currentTarget:q,stopPropagation:()=>{},preventDefault:()=>{}};le.onMouseLeave(Ee)}E.current=null,xt.emit("pane:hovered",null),I.current=-1,L.current||(we(),A.current?.markDirty("ui"))},$=le=>{if(le.preventDefault(),!s.current)return;let Ee=s.current,wt=q.getBoundingClientRect(),Lt=Vn(),Ln=q.width/Lt,Ut=q.height/Lt,Mt=le.clientX-wt.left,zt=le.clientY-wt.top;if(Mt>Ln-l.current){let At=mt(),mn=iu(zt,C.current,At);if(mn&&!mn.isMain){let yt=C.current.map(Bt=>{if(Bt.id!==mn.id)return Bt;let gr=Bt.yMax-Bt.yMin,or=Bt.yMin+gr/2,rn=gr*(1+le.deltaY*.001);return{...Bt,yMin:or-rn/2,yMax:or+rn/2,yAxisAuto:!1}});C.current=yt,pe(yt)}else{u.current=!1,fe(Bt=>({...Bt,autoScale:u.current}));let yt=1+le.deltaY*.001;[Ee.pMin,Ee.pMax]=UR(Ee.pMin,Ee.pMax,yt,Be.getScaleMode()==="log")}Ne(),we(),A.current?.markDirty("base"),A.current?.markDirty("drawings"),J(f.current)}else if(zt<=Ut-(e.hideTimeScale?0:yn)){let At=Be.getSessionMapper(),mn=Be.getOrdinal(),{min:yt,max:Bt}=Pn(),gr=Ln-l.current;if(mn){let rn=Be.tsToFracIndex(Ee.tMin),ln=Be.tsToFracIndex(Ee.tMax),Rn=ln-rn,Nr=Hn=>Math.max(Number(yt),Math.min(Number(Bt),Hn));if(le.ctrlKey){let Hn=Mt/gr,Wr=Nr(Rn*(le.deltaY>0?1.1:.9)),rt=rn+Hn*Rn;Ee.tMin=Be.indexToTs(rt-Wr*Hn),Ee.tMax=Be.indexToTs(rt+Wr*(1-Hn))}else{let Hn=Nr(Rn*(1+le.deltaY*6e-4));Ee.tMin=Be.indexToTs(ln-Hn)}}else if(At&&At.hasSession){let rn=At.tsToMarket(Ee.tMin),ln=At.tsToMarket(Ee.tMax),Rn=Number(ln-rn),Nr=1+le.deltaY*6e-4,Hn=BigInt(Math.round(Rn*Nr)),Wr=Hn<yt?yt:Hn>Bt?Bt:Hn;if(!le.ctrlKey)Ee.tMin=At.marketToTs(ln-Wr);else{let rt=Mt/gr,Yt=rn+BigInt(Math.round(rt*Rn)),ut=le.deltaY>0?1.1:.9,ur=Rn*ut,Vt=Math.max(Number(yt),Math.min(Number(Bt),ur));Ee.tMin=At.marketToTs(Yt-BigInt(Math.round(Vt*rt))),Ee.tMax=At.marketToTs(Yt+BigInt(Math.round(Vt*(1-rt))))}}else{let rn=Number(Ee.tMax-Ee.tMin),ln=BigInt(Math.round(rn*(1+le.deltaY*6e-4))),Rn=ln<yt?yt:ln>Bt?Bt:ln;if(!le.ctrlKey)Ee.tMin=Ee.tMax-Rn;else{let Nr=Mt/gr,Hn=le.deltaY>0?1.1:.9,Wr=rn*Hn,rt=Math.max(Number(yt),Math.min(Number(Bt),Wr)),Yt=Ee.tMin+BigInt(Math.round(rn*Nr));Ee.tMin=Yt-BigInt(Math.round(rt*Nr)),Ee.tMax=Ee.tMin+BigInt(Math.round(rt))}}u.current&&Ar(Ee,Oe.current,Ae.current,_.current==="ohlcv"?Q.current.display:Pe.current,ie.current,P.current,xe.current,_.current),Le();let or=Ln-l.current;{let rn=Number(Ee.tMax-Ee.tMin),ln=Be.getSessionMapper();if(Be.getOrdinal()){let Nr=Be.getBarPx(or);if(Nr>0){let Hn=-le.deltaX/Nr,Wr=Be.tsToFracIndex(Ee.tMin),rt=Be.tsToFracIndex(Ee.tMax);Ee.tMin=Be.indexToTs(Wr-Hn),Ee.tMax=Be.indexToTs(rt-Hn)}}else if(ln&&ln.hasSession){let Nr=ln.tsToMarket(Ee.tMin),Hn=ln.tsToMarket(Ee.tMax),Wr=Number(Hn-Nr);if(Wr>0){let rt=BigInt(Math.round(-le.deltaX*(Wr/or)));Ee.tMin=ln.marketToTs(Nr-rt),Ee.tMax=ln.marketToTs(Hn-rt)}}else Ee.tMin-=BigInt(Math.round(-le.deltaX*(rn/or))),Ee.tMax-=BigInt(Math.round(-le.deltaX*(rn/or)))}if(cr(Ee),$e.current){let rn=$e.current,ln=rn.targetTMin-rn.startTMin;$e.current={startTMin:Ee.tMin,startTMax:Ee.tMax,targetTMin:Ee.tMin+ln,targetTMax:Ee.tMax+ln,startTime:performance.now()}}Ne(),we(),A.current?.markDirty("base"),A.current?.markDirty("drawings"),J(f.current)}s.current.tMin<Re.current&&xt.emit("data:request-backward",{viewMin:s.current.tMin,symbol:c.current?.symbol}),we(),_e(),A.current?.markDirty("ui")},ge=le=>{let Ee=i.current,wt=document.activeElement;if(!Ee||!wt||!Ee.contains(wt))return;In.current&&le.key==="Escape"&&(qe(!1),Fe(""));let Lt=ue();if(Lt?.onKeyDown&&Lt.onKeyDown(re(le))){le.preventDefault();return}le.ctrlKey&&(Y.current=!0),le.shiftKey&&(G.current=!0);let Ln=document.activeElement,Ut=Ln instanceof HTMLInputElement||Ln instanceof HTMLTextAreaElement||Ln instanceof HTMLElement&&Ln.isContentEditable;if(Ut)return;let Mt=io.get(R.current.name);if(!(Mt?.onKeyDown&&Mt.onKeyDown(nt(le)))){if(le.altKey&&le.key!=="Escape"&&Zh[le.key]!==void 0){let zt=Zh[le.key];zt==="cursor"?(er(),we(),A.current?.markDirty("drawings"),J(f.current)):wn(ad(zt));return}if(le.key==="Escape"){if(In.current&&(qe(!1),Fe("")),K.current){K.current=null,de.current=!1,we(),A.current?.markDirty("ui");return}let zt=m.current;if(Mt?.anchorCount==="dynamic"&&zt?.pluginToolId===Mt.id&&zt.anchors.length>0){let At={id:pn(),tool:Mt.id,anchors:zt.anchors,data:{...Mt.defaultData}};d.current=[...d.current,At],m.current=null,wn(Vo),f.current=At.id,it(At.id),we(),A.current?.markDirty("drawings"),J(At.id);return}er(),f.current=null,it(null),ft(null),we(),A.current?.markDirty("drawings"),J(f.current);return}if((le.key==="Delete"||le.key==="Backspace")&&f.current&&!Ut){let zt=f.current;d.current=d.current.filter(At=>At.id!==zt),f.current=null,it(null),ft(null),we(),A.current?.markDirty("drawings"),J(f.current);return}le.key>="0"&&le.key<="9"&&(qe(!0),Fe(le.key))}},Ce=le=>{(le.key==="Control"||le.key==="Meta")&&(Y.current=!1),le.key==="Shift"&&(G.current=!1)},ct=le=>{if(le.preventDefault(),!fn.contextMenu)return;{let At=je.current,mn=!1,yt={currentTarget:q,stopPropagation:()=>{mn=!0},preventDefault:()=>{},clientX:le.clientX,clientY:le.clientY};if(At.onContextMenu(yt),mn)return}let Ee=q.getBoundingClientRect(),wt=Vn(),Lt=q.height/wt,Ln=le.clientY-Ee.top,Ut=s.current,Mt=Ln>Lt-(e.hideTimeScale?0:yn),zt=Ut&&!Mt?Ut.pMin+(Lt-(e.hideTimeScale?0:yn)-Ln)/(Lt-(e.hideTimeScale?0:yn))*(Ut.pMax-Ut.pMin):null;oe({x:le.clientX,y:le.clientY,target:Mt?"xaxis":"chart",priceAtClick:zt}),E.current=null,we(),A.current?.markDirty("ui")};q.addEventListener("mousedown",gt),q.addEventListener("dblclick",Tt),window.addEventListener("mousemove",Xt),window.addEventListener("mousedown",Ze),window.addEventListener("mouseup",vt),window.addEventListener("keydown",ge),window.addEventListener("keyup",Ce),he.addEventListener("mouseleave",X),q.addEventListener("wheel",$,{passive:!1}),q.addEventListener("contextmenu",ct);let bt=xt.on("status:refresh",()=>{let le=E.current,Ee=s.current;!le||!Ee||Gt(le.x)});return()=>{q.removeEventListener("mousedown",gt),q.removeEventListener("dblclick",Tt),window.removeEventListener("mousemove",Xt),window.removeEventListener("mouseup",vt),window.removeEventListener("keydown",ge),window.removeEventListener("keyup",Ce),he.removeEventListener("mouseleave",X),q.removeEventListener("wheel",$),q.removeEventListener("contextmenu",ct),bt()}},[t])}import{useCallback as to,useRef as jV}from"react";var GV=.08;function GR(e){let{drawingsRef:t,drawingsCanvasRef:n,viewRef:r,selectedDrawingIdRef:o,indicatorsRef:a,panesRef:i,ohlcvBarsRef:s,sessionMapperRef:l,activeTimeframeRef:c,horizonRef:u,phCursorRef:d,candleCacheRef:m,tradesRef:f,openBarRef:h,openBarTsRef:p,openBarTradeCountRef:g,compactBufRef:y,isYAxisAutoRef:v,priceHistoryRef:b,dataLevelRef:S,previewBarsRef:C,chartSettingsRef:w,tradeLinesRef:k,hoveringLegend:M,renderEngineRef:I,transformer:x,maximizedPaneId:T,setIndicators:R,setPanes:P,setSelectedDrawingId:D,setSettingsBarPos:N,setIndicatorSettingsId:O,setActiveTimeframe:A,setMaximizedPaneId:B,pushDrawParams:E,updateSettingsBarPos:L,recomputeLayouts:z,scheduleResample:Y,runIndicatorWorker:G,getTradesUpToHorizon:H,getLayouts:W,rebuildCandleCache:U,syncOhlcvOpenBar:V,updatePriceHistoryToRawIdx:K,findPriceHistoryIdx:Z,resetXAxis:de,resetYAxis:ze,autofitIndicatorPanes:xe}=e,Ae=jV(new Map),Oe=to((it,ft)=>{t.current=t.current.map(oe=>{if(oe.id!==it)return oe;if(oe.tool==="text"&&ft.screenAnchored===!0&&!oe.screenAnchored){let pe=n.current,fe=r.current,Ie=Vn(),Ve=pe.width/Ie,qe=pe.height/Ie,De=W().main,we=De?.h??(qe??0)-(e.hideTimeScale?0:yn),_e=De?.y??0,Ne=pe?Ve-e.priceScaleWidthRef.current:0;if(pe&&fe){let dt=x.tsToX(oe.anchor.ts,Ne),Pt=x.priceToY(oe.anchor.price,we)+_e;return{...oe,...ft,screenX:dt,screenY:Pt}}}return{...oe,...ft}}),E(),I.current?.markDirty("drawings")},[]),ke=to(it=>{t.current=t.current.filter(ft=>ft.id!==it),o.current=null,D(null),N(null),E(),I.current?.markDirty("drawings")},[]),Q=to(()=>{t.current=[],o.current=null,D(null),N(null),E(),I.current?.markDirty("drawings")},[]),Pe=to(it=>{let ft=t.current.find(pe=>pe.id===it);if(!ft)return;let oe={...ft,id:pn()};"price"in oe&&(oe.price+=.5),t.current=[...t.current,oe],o.current=oe.id,D(oe.id),E(),I.current?.markDirty("drawings"),L(oe.id)},[]),_=to(it=>{let ft=a.current.map(oe=>oe.id===it?{...oe,visible:!oe.visible}:oe);a.current=ft,R(ft),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),ie=to(it=>{let ft=i.current.filter(pe=>pe.id!==it);i.current=ft,P(ft);let oe=a.current.filter(pe=>pe.paneId!==it);a.current=oe,R(oe),z(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),se=to(it=>{let ft=a.current.find(pe=>pe.id===it),oe=a.current.filter(pe=>pe.id!==it);a.current=oe,R(oe),ft?.paneId&&i.current.some(pe=>pe.id===ft?.paneId)&&ft.paneId!=="main"&&ie(ft.paneId),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),Se=to(it=>{a.current.find(oe=>oe.id===it)&&O(it)},[]),Re=to(()=>{a.current=[],R([]);let it=i.current.filter(ft=>ft.isMain);i.current=it,P(it),z(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),ye=to(it=>{let ft=i.current.findIndex(pe=>pe.id===it);if(ft<=0)return;let oe=[...i.current];[oe[ft-1],oe[ft]]=[oe[ft],oe[ft-1]],i.current=oe,P(oe),z(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),$e=to(it=>{let ft=i.current.findIndex(pe=>pe.id===it);if(ft<0||ft>=i.current.length-1)return;let oe=[...i.current];[oe[ft],oe[ft+1]]=[oe[ft+1],oe[ft]],i.current=oe,P(oe),z(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),Ue=to(it=>{let ft=i.current.map(oe=>oe.id===it?{...oe,collapsed:!1,heightRatio:oe.savedHeightRatio??1}:oe);i.current=ft,P(ft),z(),Y(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),je=to(it=>{if(T!==null)return;let ft=i.current.map(oe=>oe.id===it?{...oe,collapsed:!oe.collapsed,savedHeightRatio:oe.collapsed?oe.savedHeightRatio:oe.heightRatio,heightRatio:oe.collapsed?oe.savedHeightRatio??1:GV}:oe);i.current=ft,P(ft),z(),Y(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[T]),ht=to(it=>{B(ft=>{let oe=ft===it?null:it,pe;return oe===null?(pe=i.current.map(fe=>{let Ie=Ae.current.get(fe.id);return{...fe,heightRatio:Ie??fe.heightRatio}}),Ae.current.clear()):(Ae.current.clear(),i.current.forEach(fe=>Ae.current.set(fe.id,fe.heightRatio)),pe=i.current.map(fe=>({...fe,heightRatio:fe.id===oe?100:0}))),i.current=pe,P(pe),z(),Y(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui"),oe})},[]),Be=to(()=>{M.current=!0},[]),xt=to(()=>{M.current=!1},[]),fn=to(it=>{s.current.bars.length&&(s.current.barNs=it.barNs,s.current.display=lc(s.current.bars,it.barNs,l.current)),A(it),c.current=it,P(pe=>pe.map(fe=>fe.isMain?{...fe,tf:it.label}:fe));let ft=r.current;if(!ft)return;d.current=-1,K(Z(u.current)),m.current=null,U(f.current,it.barNs),h.current=null,p.current=0n,g.current=0,V(u.current),a.current.forEach(pe=>{!pe.hydrate&&pe.compute&&pe.compute(y.current,f.current)}),G(H(u.current),c.current.barNs);let oe=ES(it);ft.tMin=ft.tMax-oe,v.current&&Ar(ft,b.current,f.current,S.current==="ohlcv"?s.current.display:C.current,h.current,w.current,u.current,S.current),de(),ze(),xe(),Y(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),In=to(it=>{if(it==="vp_fixed"){let ft=r.current.tMin,oe=r.current.tMax,pe=(r.current.pMin+r.current.pMax)/2,fe=(r.current.pMax-r.current.pMin)/2,Ie={id:pn(),tool:"fvp",a:{ts:ft,price:pe-fe},b:{ts:oe,price:pe+fe},...Yi("fvp")};t.current=[...t.current,Ie],o.current=Ie.id,D(Ie.id),E(),I.current?.markDirty("drawings"),G(H(u.current),c.current.barNs)}},[]),kt=to(it=>{k.current=[...k.current,it],E(),I.current?.markDirty("ui")},[]);return{handleUpdateDrawing:Oe,handleDeleteDrawing:ke,handleDeleteDrawings:Q,handleDuplicateDrawing:Pe,handleToggleIndicator:_,handleRemoveIndicator:se,handleOpenIndicatorSettings:Se,handleRemoveIndicators:Re,handleMoveUp:ye,handleMoveDown:$e,handleRemovePane:ie,handleExpand:Ue,handleCollapse:je,handleMaximize:ht,handleEnter:Be,handleLeave:xt,handleTimeframeChange:fn,handleAddIndicator:In,handleAddTradeLine:kt}}import{useEffect as KV}from"react";var YV={l3:new Set(["l3","tick","ohlcv","l2"]),tick:new Set(["tick","ohlcv"]),ohlcv:new Set(["ohlcv"]),l2:new Set(["l2"])};function Ao(e,t){return YV[t].has(e)}var nm={l3:"order flow",tick:"tick",ohlcv:"candle",l2:"order book"};function cc(e,t){return`Needs ${nm[e]} data. This symbol serves ${nm[t]} data.`}function YR(e){let{eventBus:t,chartId:n,account:r,pluginChartTypesRef:o,activeChartTypeBottomBarIds:a,hitMapRef:i,indicatorsRef:s,panesRef:l,renderEngineRef:c,horizonRef:u,activeTimeframeRef:d,chartSettingsRef:m,pluginChartTypeComputedRef:f,dataLevelRef:h,previewBarsRef:p,candleCacheRef:g,ohlcvBarsRef:y,openBarRef:v,viewRef:b,accountSnapRef:S,setActiveTool:C,setPanes:w,setIndicators:k,setPluginChartTypes:M,setChartSettings:I,resetView:x,buildChartTypeActiveCtx:T,pushDrawParams:R,runIndicatorWorker:P,getTradesUpToHorizon:D,syncPixelLayouts:N,autofitIndicatorPanes:O,handleAddIndicator:A,handleRemoveIndicator:B,onSymbolChange:E,syncInLayoutRef:L,applyCrosshairSync:z,applyTimeRangeSync:Y}=e;KV(()=>{let G=V=>{let K=s.current.filter(Z=>Z.id===V||Z.id.startsWith(`${V}:`));for(let Z of K)B(Z.id)},H=0,W=()=>{!r||H||(H=requestAnimationFrame(()=>{H=0,S.current=r.getSnapshot(),R(),c.current?.markDirty("ui")}))},U=[t.on("chart:reset-view",()=>x()),t.on("layout:crosshair",V=>{V&&V.id===n||z(V)}),t.on("layout:time-range",V=>{if(V.id===n)return;let{time:K,dateRange:Z}=L.current;!K&&!Z||Y(V)}),t.on("chart:set-tool",({tool:V})=>C(V)),t.on("chart:set-symbol",({symbol:V,id:K})=>{n===K&&(E(V),w(Z=>Z.map(de=>de.isMain?{...de,symbol:V}:de)))}),t.on("chart:add-indicator",({id:V})=>A(V)),t.on("chart:remove-indicator",({id:V})=>B(V)),t.on("chart:remove-plugin-indicator",({pluginId:V})=>G(V)),t.on("plugin:uninstalled",({id:V})=>G(V)),t.on("chart:set-type",({old:V,new:K})=>{let Z=V,de=K;if(Z!==de){o.current.get(Z)?.onDeactivate?.();for(let ze of a.current)t.emit("plugin:bottom-bar-item-removed",{id:ze});a.current.clear(),o.current.get(de)?.onActivate?.(T())}}),t.on("hitmap:update",({id:V,hitMap:K})=>{V===n&&(i.current=K)}),t.on("plugin:add-indicator",({indicator:V,pane:K})=>{s.current.some(Z=>Z.id===V.id)||(K&&!l.current.some(Z=>Z.id===K.id)&&(l.current=[...l.current,K],w(l.current)),s.current=[...s.current,V],k(s.current),R(),c.current?.markDirty("base"),P(D(u.current),d.current.barNs))}),t.on("plugin:add-indicator:id",({id:V})=>{s.current.find(Z=>Z.id===V)}),t.on("plugin:register-pane",({id:V,heightRatio:K})=>{if(l.current.some(de=>de.id===V))return;let Z={id:V,isMain:!1,heightRatio:K,yMin:0,yMax:0,yAxisAuto:!0,collapsed:!1};l.current=[...l.current,Z],w(l.current),N(l.current),R(),c.current?.markDirty("base")}),t.on("plugin:remove-pane",({id:V})=>{l.current.some(K=>K.id===V)&&(l.current=l.current.filter(K=>K.id!==V),s.current=s.current.filter(K=>K.paneId!==V),w(l.current),k(s.current),N(l.current),R(),c.current?.markDirty("base"))}),t.on("plugin:register-chart-type",({plugin:V})=>{if(o.current.has(V.chartTypeId)||(o.current.set(V.chartTypeId,V),M([...o.current.values()]),m.current.chartType!==V.chartTypeId))return;let K=V.require??"ohlcv",Z=h.current;if(Z&&!Ao(K,Z)){t.emit("plugin:incompatible",{id:V.chartTypeId,name:V.label??V.name,kind:"chart-type",required:K,actual:Z}),I(de=>({...de,chartType:"candles"}));return}V.onActivate?.(T())}),t.on("plugin:unregister-chart-type",({id:V,hotReload:K})=>{o.current.delete(V),f.current.delete(V),M([...o.current.values()]),!K&&m.current.chartType===V?I(Z=>({...Z,chartType:"candles"})):K&&c.current?.markDirty("base")}),t.on("plugin:recompute-indicator",({id:V})=>{s.current.some(K=>K.id===V)&&P(D(u.current),d.current.barNs)}),t.on("plugin:redraw-indicators",()=>{P(D(u.current),d.current.barNs)}),t.on("plugin:scripted-recompute",({id:V})=>{let K="__scripted__",Z=s.current.find(Pe=>Pe.id===V&&Pe.workerInit===K),de=!Z&&o.current.has(V)&&o.current.get(V)?.workerInit===K;if(!Z&&!de)return;let ze=D(u.current),xe=-1/0,Ae=1/0;{let Pe=b.current;if(Pe){let _=d.current.barNs,ie=Pe.tMax-Pe.tMin,se=1000n*_,Se=ie>se?ie:se,Re=Pe.tMin-Se,ye=Pe.tMax+ie;ye>u.current&&(ye=u.current),xe=Number(Re/1000000n),Ae=Number(ye/1000000n)}}let Oe=[];function ke(Pe){let _=typeof Pe=="bigint"?Pe:BigInt(Pe);return _<1000000000000n?_*1000000000n:_<1000000000000000n?_*1000000n:_<1000000000000000000n?_*1000n:_}if(h.current==="l3"){for(let Pe of p.current)Oe.push({ts:ke(Pe.time),open:Pe.open,high:Pe.high,low:Pe.low,close:Pe.close,volume:Pe.volume});for(let[Pe,_]of g.current)Oe.push({ts:ke(Pe),open:_.open,high:_.high,low:_.low,close:_.close,volume:_.volume});Oe.sort((Pe,_)=>Pe.ts<_.ts?-1:1)}else if(h.current==="ohlcv"){let Pe=Number(d.current.barNs/1000000n),_=Math.floor(Number(u.current/1000000n)/Pe)*Pe,ie=y.current.display,se=0,Se=ie.length-1,Re=ie.length;for(;se<=Se;){let ye=se+Se>>>1;ie[ye].time>=xe?(Re=ye,Se=ye-1):se=ye+1}for(let ye=Re;ye<ie.length;ye++){let $e=ie[ye];if($e.time>Ae)break;if($e.time>=_&&v.current){Oe.push({ts:v.current.ts,open:v.current.open,high:v.current.high,low:v.current.low,close:v.current.close,volume:v.current.totalVol});break}else Oe.push({ts:ke($e.time),open:$e.open,high:$e.high,low:$e.low,close:$e.close,volume:$e.volume})}}let Q=ze.map(Pe=>({time:Number(Pe.ts/1000000n),price:Pe.price,size:Pe.size,side:Pe.side}));t.emit("plugin:scripted-compute",{id:V,ohlcv:Oe,trades:ze,ticks:Q,snapshots:[],barNs:d.current.barNs})}),t.on("plugin:chart-type-updated",({id:V})=>{R(),c.current?.markDirty("base")}),t.on("plugin:indicator-updated",({id:V})=>{let K=s.current.find(Z=>Z.id===V);if(K){if(K.paneId&&K.paneId!=="main"){let Z=l.current.find(de=>de.id===K.paneId);Z?.yAxisAuto&&Z.yMin===Z.yMax&&O()}c.current?.markDirty("base")}}),t.on("plugin:remove-indicator",({id:V})=>{s.current.some(K=>K.id===V)&&(s.current=s.current.filter(K=>K.id!==V),k(s.current),R(),c.current?.markDirty("base"))}),t.on("playback:seek",({tNs:V})=>{c.current?.markDirty("ui")}),t.on("account:update",W)];return W(),()=>{H&&cancelAnimationFrame(H),U.forEach(V=>V())}},[t,n])}import{useCallback as Qh,useRef as KR,useState as $V}from"react";function $R(e){let{baseCanvasRef:t,panesRef:n,priceScaleWidthRef:r}=e,o=KR({}),a=KR(new Map),[i,s]=$V({}),l=Qh(()=>{let m=t.current;if(!m)return;let f=Vn();o.current=Ji(n.current,m.height/f-(e.hideTimeScale?0:yn),m.width/f,r.current)},[]),c=Qh(()=>o.current,[]),u=Qh(m=>{let f=t.current;if(!f)return;let h=m??n.current,p=Vn(),g=Ji(h,f.height/p-(e.hideTimeScale?0:yn),f.width/p,r.current);o.current=g,s(g)},[]),d=Qh(m=>{o.current=m;for(let[f,h]of Object.entries(m)){let p=a.current.get(f);p&&(p.style.top=`${h.y}px`,p.style.height=`${h.h}px`,p.style.visibility=h.h<2?"hidden":"visible")}},[]);return{layoutsCacheRef:o,legendElemsRef:a,panePixelLayouts:i,recomputeLayouts:l,getLayouts:c,syncPixelLayouts:u,applyLayoutsToDom:d}}import{useCallback as XV,useEffect as XR,useRef as ZR,useState as ZV}from"react";function QV(e){if(typeof e!="object"||e===null)return{...Ye};let t={...Ye};for(let n in Ye){let r=Ye[n],o=e[n];r===null?(o===null||typeof o=="number")&&(t[n]=o):typeof o==typeof r&&(t[n]=o)}return t}function JV(){let e=qr(Cn.chartSettings,null);return e===null?Ye:QV(e)}function QR(e){let{chartSettingsRef:t,isYAxisAutoRef:n,viewRef:r,priceHistoryRef:o,tradesRef:a,dataLevelRef:i,ohlcvBarsRef:s,previewBarsRef:l,openBarRef:c,horizonRef:u,compactBufRef:d,selectedDrawingIdRef:m,renderEngineRef:f,scheduleResample:h,rebuildContrastBitmap:p,requestFootprintRebuild:g,pushDrawParams:y,updateSettingsBarPos:v}=e,[b,S]=ZV(()=>{let M=e.modelSettings;return M&&JSON.stringify(M)!==JSON.stringify(Ye)?M:JV()}),C=ZR(null),w=ZR(Ye),k=XV(()=>{kr(Cn.chartSettings,t.current)},[]);return XR(()=>()=>{C.current&&clearTimeout(C.current)},[]),XR(()=>{let M=w.current;if(w.current=b,t.current=b,C.current&&clearTimeout(C.current),C.current=setTimeout(()=>k(),500),b.autoScale&&!M.autoScale){n.current=!0;let x=r.current;x&&Ar(x,o.current,a.current,i.current==="ohlcv"?s.current.display:l.current,c.current,t.current,u.current,i.current)}else n.current=b.autoScale;if(b.showHeatmap!==M.showHeatmap&&h(),b.heatmapContrast!==M.heatmapContrast){p(b.heatmapContrast),y(),f.current?.markDirty("ui");return}if(n.current&&(b.scaleMarginTop!==M.scaleMarginTop||b.scaleMarginBottom!==M.scaleMarginBottom)){let x=r.current;x&&Ar(x,o.current,a.current,i.current==="ohlcv"?s.current.display:l.current,c.current,t.current,u.current,i.current)}["footprintImbalanceRatio","footprintStackMinCount","footprintDiagRatio","footprintAbsorptionMult","footprintAbsorptionDeltaFrac"].some(x=>b[x]!==M[x])&&d.current.length>0&&g(),y(),f.current?.markDirty("base"),f.current?.markDirty("drawings"),v(m.current),f.current?.markDirty("ui")},[b]),{chartSettings:b,setChartSettings:S}}import{useCallback as JR,useRef as $v,useState as eW}from"react";function eP(e){let{renderEngineRef:t,uiCanvasRef:n,eventBus:r,indicatorsRef:o,panesRef:a,horizonRef:i,activeTimeframeRef:s,dataLevelRef:l,setPanes:c,setIndicators:u,runIndicatorWorker:d,getTradesUpToHorizon:m,pushDrawParams:f}=e,h=$v(new Map),p=$v(new Set),[g,y]=eW([]),v=$v(new Map),b=JR((w,k)=>{if(o.current.some(x=>x.id===w.id))return;let M=w.require??"ohlcv",I=l.current;if(I&&!Ao(M,I)){r.emit("plugin:incompatible",{id:w.id,name:w.name,kind:"indicator",required:M,actual:I});return}k&&!a.current.some(x=>x.id===k.id)&&(a.current=[...a.current,k],c(a.current)),o.current=[...o.current,w],u(o.current),f(),t.current?.markDirty("base"),d(m(i.current),s.current.barNs)},[]),S=JR(w=>{o.current.some(k=>k.id===w.id)&&(o.current=o.current.map(k=>k.id===w.id?w:k),u(o.current),f(),t.current?.markDirty("base"))},[]);function C(){return{requestRedraw(){t.current?.markAllDirty()},setCursor(w){n.current&&(n.current.style.cursor=w)},eventBus:r,registerBottomBarItem(w,k){let M=p.current.has(w);return p.current.add(w),r.emit(M?"plugin:bottom-bar-item-updated":"plugin:bottom-bar-item-added",{item:{id:w,render:k}}),{rerender(){r.emit("plugin:bottom-bar-item-rerender",{id:w})},destroy(){p.current.delete(w),r.emit("plugin:bottom-bar-item-removed",{id:w})}}}}}return{pluginChartTypesRef:h,activeChartTypeBottomBarIds:p,pluginChartTypes:g,setPluginChartTypes:y,pluginChartTypeComputedRef:v,activatePluginIndicator:b,replacePluginIndicator:S,buildChartTypeActiveCtx:C}}import{useCallback as aW,useEffect as iW}from"react";function tW(e){return 1-Math.pow(1-e,3)}var Jh=class{constructor(t=180){ae(this,"durationMs",t);ae(this,"tweens",new Map);ae(this,"symbolKey")}setSymbol(t){t!==this.symbolKey&&(this.symbolKey=t,this.tweens.clear())}value(t,n,r,o){if(!o||!Number.isFinite(n))return this.tweens.delete(t),n;let a=this.tweens.get(t);if(!a)return this.tweens.set(t,{from:n,to:n,start:r}),n;if(a.to!==n){let i=this.sample(a,r);return a.from=i,a.to=n,a.start=r,i}return this.sample(a,r)}isAnimating(t){for(let n of this.tweens.values())if(n.from!==n.to&&t-n.start<this.durationMs)return!0;return!1}reset(){this.tweens.clear()}sample(t,n){let r=this.durationMs>0?Math.min(1,(n-t.start)/this.durationMs):1;return t.from+(t.to-t.from)*tW(r)}};var nW=1640/407,rW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABmgAAAGXCAMAAACAxC+oAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAwBQTFRFAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Bz0LCAAAAQB0Uk5TADDmvyXL/9sJLId/8MNDgD6+dve0NfFqMZpsqvoF5zMnaGmcqcjr9C8jdE+3rDZzCrA8AXGnsgLzcnAEO/KDKspm/hShYumxJAM5ras63YUQz0Bkr84G9fsIRJGQ5DdHiRqBhOLYLZTqQpiI7kiljAxgULMO/cnZKI0XTvYY7ahe0R5rwB+XxaNjeV25D+HgQT/CnhsNWEYyWX6mzd4ZPVF3vCZLblopXMSKIHWOm7XB3y5letZMTdUVOHiCuBIrRVJnbXu6zNTc7Oi9EwtWYZairto0SW980tfloBwhlZmdtsfTj0pXhrsdIlNbpMZ975OfERZfi1WS0OP5/Af4VDUxC1UAAFJOSURBVHic7d0HeBRFHwbwzScliKE3gUiQIk0IRA1C6IgElBKaSG8BpQQpkSK9V0E60gSk94600FEJIkU6BKRIEZDQVJAvCQGS3O3Nf2ZndvfI+3u+5yPczc6OZG/f290pHhoAAIBCHlY3AAAAXm4IGgAAUApBAwAASiFoAABAKQQNAAAohaABAAClEDQAAKAUggYAAJRC0AAAgFIIGgAAUApBAwAASiFoAABAKQQNAAAohaABAHAPHlEeWd0IEQgaAAD3kNQjKmseWt0KAQgaAAC3kOJx1P8luW91MwQgaAAA3ELKf6P+L9ldq5shAEEDAOAWvP6O/n/PO1a3gx+CBgDAHXj+F/NHir8sbocABA0AgDtI8/TpTMpbFrdDAIIGAMAdpHv6dMbrT4vbIQBBAwDgDjLEPpxJfd3adghA0AAAuINMt5/+mfaqte0QgKABAHADWW7G/pD+iqXtEIGgAQBwA1lvxP7w5F9L2yECQQMA4AayPXs0k8njd0sbIgBBAwDgBt7449lPr5+3sh0iEDQAAPbnc/n5j9nOWdgOIQgaAAD7e/Pi8x+9z1jYDiEIGgAA+8t94fmPOU5Z2A4hCBoAAPvLG/H8x5wnrGuGGAQNAIDt5Tsb5y+5jlnWDjEIGgAA2ytwOs5f8hy1rB1iEDQAALZX6GScvyS9Z1k7xCBoAABs7624XZrfOmxZO8QgaAAA7K7w8bh/8/jbqnYIQtAAANhdkfiP/wsctKgdghA0AAB2VzT+4/9CByxqhyAEDQCAzfndjT/rTOH9FjVEEIIGAMDmciRYgqbIz9a0QxSCBgDA5hI8otEe/WdNO0QhaAAAbO69hA//3zzutJxdIWgAAOzN3yPhw3+/vZY0RBSCBgDA3jySJnzF9ycr2iEMQQMAYG8lHDqZ5cyw24qGiELQAADYW1HHSTTf22VBO4QhaAAA7K3Ujw4vFd9hQTuEIWgAAGytjJMn/yXCTG+GAQgaAABbK+fkeUyAxxbzGyIMQQMAYGsVnd0mK7PJ9HaIQ9AAANhapTAnL5bbaHIrjEDQAADYWeWtzl7N+eZ6sxsiDkEDAGBnzh7RRKm4zuR2GICgAQCws6rOn8bk/9XkdhiAoAEAsLNMt52+XGmNye0wAEEDAGBjH+s89a+8ytx2GIGgAQCwsep6D/2rrDC1HUYgaAAAbKzmWp03PlpmajuMQNAAANhXhZ1677yzx8x2GIKgAQCwr1qr9d4pvdnMdhiCoAEAsK/aus/8qy82sx2GIGgAAGyrrsdyvbeCPOab2RIjEDQAALb16RL992rPM68dxiBoAABsq4GL+2N155rXDmMQNAAAttVoof579eaY1w5jEDQAAHbVeIGrd+t/Z1Y7DELQAADYVVOXj2HcZrozBA0AgF1V2+Dy7QYzTWqHQQgaAACb8kjq+v2GM8xph1EIGgAAm2rBeNzfeJo57TAKQQMAYFOtWE/73WSZTQQNAIA9Bc9ilWg2xYRmGIegAQCwJ9adM01rPtmMdhiGoAEAsKeWs5lFWkwyoR2GIWgAAGwpxxV2mZYT1bfDOAQNAIAttf2WXSb4jN5Kz3aCoAEAsCXGaM2nWo9T3g7jEDQAAHaU7yylVJtvVLdDAgQNAIAdhZCe83s1GqO6IcYhaAAAbMj/VgSpXNuv1bZDBgQNAIANdRpPK9d+lNp2yICgAQCwoQ+3EQt2GKm0HTIgaAAA7KdCsbHEktnOKW2IDAgaAAD7KXCaWrLjcJXtkAJBAwBgP1/Sn/F3GqqwHVIgaAAAbOfjjfSynYeoa4ccCBoAANvJfYFetvkvP6priBQIGgAAu+nxL7UrQLSug5Q1RA4EDQCA3dBmBXim2hJV7ZAEQQMAYDM1CnH1JAvxHKCqJXIgaAAAbObVR3zlG85Q0w5ZEDQAAPbSY0ok3wbdtuxW0xJJEDQAAPbSh7u/co++CpohD4IGAMBW+g7m3qRnHwXtkAdBAwBgJ/2PLuffqFcv+Q2RB0EDAGAnA/sLbJSzcU/pDZEHQQMAYCOD+wpt1q+73GZIhaABALCP98MFN+zfTWo7pELQAADYxjDxZy0DQyW2Qy4EDQCAXfBNPZPAoK7S2iEZggYAwB56pe5haPtG0yU1RDYEDQCALaQraHS6/1TdO0tpiWwIGgAA641a87GEp/nDPDoar0Q+BA0AgMXG/urbRVJVozzaSapJIgQNAIB1upwtviS51BUy65RoK7M6GRA0AAAW6LL23eILMv2zQX7Nwzw/k1+pIQgaAAAzeY7xiDLinMJdTPrmg5EKq+eGoAEAMMGMthM9VlfbVGnTQjP2lvOdV2absR8aBA0AgCoVms7/9ErWLXmfnDd/DczGyQJmK7gxJwJBAwAghW/RSnM8Nc2zWv9LWpFTWbodSD7U6iZVbvhbljZWNwJBAwDAqUKbTRd3VYz6YXPL93oMbzHD41ffqP+FW54qOpIVuJvkkLVNQNAAADg34Y8lwybn2NHTa0iP4d77Gt6dUaTrcs+pVrdKyKJPl8yZb9neETQAAJpWo0Hd1PNv9Ryxrmq7/t+ealX+2KQ/I61uk1yhr8z+0qLbaAgaAHjpTcj9Y85B3xzbHvOXze2zRWbP5DFrr8cIjyNRfw9PHymwdrJ7Ci1Xp2SuMabvFkEDAO6jY7VtSftvql9pVfnnL3W4n/L48ZoeradWbfhXAa9T2yoFbXv2Vh5vD48J7RqrHLHijnZ5lFmS6R0z94igAQBzhA+IbHBxfvWbxfYc8Yn7eoeLBxqefCvSI7T/uR8/XNWl1rJltcqvLN3v+fupxvl2em3z101/OGB2i19mQyuW7RPgZ9LOEDQA4FJ4WJllWTNP9x378HBondUdMs6r5HX8ZIr3t9eqPTZ78bJpX7/QNbDHvaWZL/2+MNXG+FvmCT83wOPW3qqjk+w/9ZI973hJHHqldtdX6qvfD4IGwD35NiqzsonHnmlXl1y+tDr+W549L1wtHBMG629HhUGCDWt7prowwMOjZYGl61suvvjRo6O5PvrmfuFFS9o/qZANN5kSo8UZctT1yddb4R4QNJBodfnlja8qVOrQfTWjXMeGh7weBmcq+OF2V6U2H9tUaapf6xw1+yXRyvo83Nxq17Wvq+iWPr6n6P9Gb7tyZFEX5x/vxiEZ8p88iFtFYB6vYX3u1sioZoo0BE1iFx46z/984Dqn741K+9HRuv+Wd/KOZ5UPPeof8q67T7der+y1tuRL03ppwq/TEny7qsCnXoULXbr0YjHBz4+nm1ki/0eZf9QYX8teFAQAR4cm1j2dXPrNNATNy2d97SRFfHPfifk51bYve6d9O/77eY5nHxZhfrMAwF1UvbTw0uH/5C1rg6B56exydgUCAMCp3pq6P2S7e1BCTQial87PJa1uAQC8PCr/tqrLAIP9oBE0L53zeaxuAQC8ZObWNbQ5gualM3O3jdY7AoCXwtW0RrZG0LyMjvQet7lD9A9Hb2afqGl3gvJlsrpJAODOHv1nZGsETSJRo9iQikk1LfPVFy+dqFMhw7POxzXHFqva8tNjz2f9aBwydFerr04kmqkGAcClXe8Z2RpBA0SelQuENHlwYnbdOL3aOlx8VGnq4V25ju/WGS6zdHn5ijfTf7U004rtFxpfTOfRNVPwGsxYBeB28v9qZGsEDdhLxwEeszLXL3l1SfeK8Qfib24SeK3w8eqND8wOPbHqwyTx3lta7UZwym4eLev1fT9HlUsXXtmYcYBH4aEHrhafHDzczMYDvIwmlqk+tJqhGhA0kNiEh60r0e7unmmd25eJP4mwlvl+vc2DZl9J8f4nPp3Opuka551ag1IH9/dYc+/B/uv3Qy98fnzTJ7em/dB0G+YXgJfbrl5jHpYZYnzgJoIGQKnoBVT2PNjxdhKfF6+VTp4j5dFrKaas+c2zwfGhNwp+uuBB/InxCxX7IWBU8bCUc6viMRlYY/Ggo4v3DpBUGYIGwG1M8D90pU+8Vb82HxvV5ft9viuHnHt2AfbvyRs7T535cfTtV19/9PpHty1qKbizels3bfpd6uyaCBqARKdGtREReVo8ewb2wfhNqcMzXKrRtPtsL88VLSMvPCs27OHhmVlK5h2J51yJR7GShTPtkXUd8wKCBgDIfHcO93xjZ4c2LwZmeWX/auX50d5Dajzvn/HvnKIftBpXKLTSuc5Np4y8hYWU3cWZm6sytlFTNYIGAKzSseG+CZnqr0367O8f+JQdv29vxglVv612pVWE18hKzx5bNQ4Zerzm52lwbaVIz523Tzcdo65+BA0AuB3f0b9NmNg0/emKMX/zSv/WktLzd/s8f7vW+JMpv2hRO6hz4whr2uc+Qhd+sP7uddV7QdAAQGJQ4fL9mCmIW/11qmiDqD/LZsm5LGZwSNcNm6Za2jLLdBw/8fhQU/aEoAEAiLK17f1bUVdIPocvvb9Ea3p0eu7X/7C6SepU/n3r2iUrTNsdggYAwLkuPhenl2p1bsuAmzP/Dvpz4vo8FfNeTu3ulz8+hVv/JrfzMhuCBgCAS8eB68dPCGhU+yf/TmN6vBH055Lvkl3bvTCtGwyurfrfhwu3s4tJh6ABAJBiQoqk97rN+z3r4GZHF2Xv4fFrqjM2uvq5tnje2VDjk8mIQdAAAKgy4U/fxiv7Bv76V8lB/1jYjFXNmg+ycPcIGgAAM/T6pM7A30JfM32/p/d5JS/PLqYUggYAwDw+ZXaWDp9SyZzrm0MDh/3hZ8qeXEPQAACYrkKvz+dfMbbIC8vQFTNzKd0BHYIGAMAaG9++dr6Omqq9tpa6o6ZmEQgaAADrZKyaZLb0Ss+cO2xVBzOnEDQAAJZqPPh+IZn1VepQSWZ1EiBoAACs1v7wHllV7Ri+TFZV0iBoAACs9+C0nO5hjaZLqUYuBA0AgA0EjiprfOXtXW0OSGiKdAgaAABb6LHoAruQS7vzmz8glAJBAwBgEyM6pjSwdcCjv3+U1hSpEDQAAHZxpIqBRXB69JXWDskQNAAAtjEnbynBLUO+zCC1JTIhaAAA7CNfRsHbX8s+ktsQmRA0AAA2ErRGaLOCv0huh0wIGgAAO3nzosBGxcoPlt4QeRA0AAC2kkFgOsx1FeW3Qx4EDQCArfSYxj1yM2f+FSpaIguCBgDAXhY05t3ClhPPvICgAQCwmd3l+MoHBVu9WLNrCBoAAJu5Om44V/k23yhqiCQIGgAAu1nUkKt4xXWK2iEJggYAwG4qbOCZ9KzqcmUNkQNBAwBgO+M6cxSe/YmydsiBoAEAsJ2An+hl01SYr64hUiBoAADsZ28ZclHvMwrbIQWCBgDAfgqcJhd9b5fCdkiBoAEAsJ9m31NLbn9fZTukQNAAANhQ53HEgjMbKG2HDAgaAAAbmtucWPDLAUrbIQOCBgDAhgJzTSWVG9lBcUMkQNAAANjR59NIxbaIrv1sIgQNAIAdzWxNKnbzNcXtkABBAwBgR357KRGy+13lDTEOQQMAYEst5hAKfbxUeTuMQ9AAANjSqtrsMvcfeKlviGEIGgAAexrdjVnkVA4T2mEYggYAwJ5K72MWuZzBhHYYhqABALCnM/lZJbwq2X3i5hgIGgAAm/qmC6PAlfSmtMMoBA0AgE3VWs0ocCmjKe0wCkEDAGBTW0u/6vL9e14PTWqJMQgaAAC7+uMNl29XW2JSOwxC0AAA2FXmWy7fjshqUjsMQtAAANjVjDau3s1ZzC36nCFoAABs7GYWF29272daO4xB0EA8viEev7Z6veSwip1avGN1WwBg+Fcu3nSTPmcIGogrR4XFf7/4W/XctydZ1xYAiBI8S/89d+lzZnHQDHrt0zbbHjZdGZ6sxdDjr5f/R9OKVRo46o9mN7d/+rjmR/69D1rZuMQnuGeehC/lyMfqxg8ASrmY72xhTRPbYYg1QRM5d0CTf4LfZhUrO23kd9nr9TajRbB1+xBnL+ddkdvslgDAC2fz6b7lt9fEdhhietAEjqh0OOsTni18JhVIcieXqvbAUx4NFzp/Y+fejua2BADiOFpU962N5UxshyHmBk2KVcdYU/foSBM62Ou8hBb4/sYqkeGyhN24nWG99N9zn69NVkpl27vlZ7Nb3YJEZnEDVomfi3BU99jDU+ed5pM5qrGWeUHj/dfH5T8zVMPOoMm/GL2PhqBxqtN4V+9mO2dWO9wYggZiSQ4aLcMdnTeOOjxUtS2zgqbTo41Szlbhj7/+zsj2CBpnGk9P6ertkCINzWqJ+0LQQCzZQZP1hs4bP+rfVLMbM4ImcGSyov/Iq+5R+43HhTdG0DhRd0kS1wVC58i4bflyQ9BALNlBo7sozfd1eKqxlPqg6bV9ZIDsOs8UaTtAbEsEjRPHmId9OLOHYKKHoIFYsoNGO+zn9OV6c7hqsZTqoEmTstQyFfWGvF2r5xiB7RA0jnqdXM4s81cKExri1hA0EEt60PzlfPz/jVRctVhKadDU//TAIHW1++eq/yH3RggaRxV3sMtsf199O9wbggZiSQ+aSzmdvjz7E65aLKUwaLyHfhemrvZoXmev844mRNA4CF8wllAq3yHlDXFvCBqIJT1odM5aDWZy1WIpZUHjH1jUhCdVmXa12cC1AYLGQRPSRONJ76luh5tD0EAs6UGjef3t5MXKq/gqsZSqoOnZxqSx/Pe9Z/HcQEPQOKi+nlLqtOuF/gBBA7HkB03pfU5edKdHNIqC5tqeukrqdarmhr/pn3EEjYPapC9GmS6qboebQ9BALPlBMybUyYtuNIpGTdD4n/KIVFCtvkdDlv1ILIqgcTCkD6nYHixP4xKCBmLJD5qSO53MQlOe76mBtRQETbcTa+VXynBm+DhaQQSNg+S0KU6bTlXcDjeHoIFY8oNGO+842UyWC5x1WEp60HjfvO1yOhNVepckTWSKoHGQ6TapWGtilCdWCBqIpSBo0t11eKnIz5x1WEp20OQbZdVSPCH3ry9il0LQOGhHu1T5G4uxuoSggVgKgqbYEYeXsp/lrMNScs8ejzuMfVVqhVyWf8S+CYSgcaAzv0VCr9IufBItBA3EUhA09Zc6vOQ+a9FEkxo0OYpY+3gqaNJHuxlFEDQOFjYiFcsaobYZ7g5BA7EUBI22ImE/Xv+dvFVYSmbQlChJGWKuVPVcQ10XQNA4oHVv1oZ0VtwON4eggVgqgmZquwQvnMrBW4Wl5AWN3+U/pdUl7mHJ/1z2dEbQOGg+l1LqSF7V7TDDoHBWie+8BKtG0EAsFUHz2fQEL4wP5q3CUtKCxnNtoKyqDMny5HdXbyNoHHy8kVLqJ1/V7TADe0GEsaKrwCJoIJaKoPFsn+B20fCOvFVYSlbQ3B2lcJ5mHr16uXwbQePodiZCoZX2+B5hEIIG1FMRNFpoglVRapGmKLQNSUEzf91CORUZxbigQdA48fYJdpn7r9n2PMoDQQPqKQma+2ni/bVfd+4aLCUnaIIuH5BSj3GMCxoEjRMOt3+daDlRfTtMgKAB9ZQETYI1ac6/zl2DpaQEzYgvLBw9Ew/rggZB48xuZo98//QrzGiIcggaUE9J0Ez4It5f3W2iDhlB0/ZbCZXIwbqgQdA4k+Ixq8S82ma0Qz0EDainJGi0fvGegn8uspC9hYwHjXfhTRLaIQfzggZB4xRrSZoL1amzY9scggbUUxM0B9+L8xe3W1rdeNB0ttE1XNqrrBIIGqcy3HH17qFPDprVEMUQNKCemqCZ0j7OX9Jf4a/AUoaDZlFDGc2Qg31Bg6Bxrks5F3OhDk3T3LyWqIWgAfXUBE2FuHPOtP2avwJLGQ2aX/wNVuCVbv+UMcE+t2dUyR4x0nPdbxMiXhv+4dwU3gUK8ddFmM8UQePchHy642RGFipvZkuUQtCAemqCRquz8sXPx3IJVGAlg0HjdIlRqmJHj00rVk3v3forLgzMMpJnqU7KLCkIGh1+p/12OX3j+ieMBzjuBEED6ikKmhZznv/46D+B7S1lLGgqL6AMKndq2832EYRiR6odbEidEpqyQAOCRleWR04e1Jz+arb5LVEHQQPqKQqaON/q3WvRs2iGgqZGszpC2z0sXrI/x9yF3dZPq3mNXYzwhAZB41LjAyfjvzCyVjZrWqKKwqAxgDJidn4t9e0AORQFjZb++f0d5jAO2zEUNAP7C2wUenDqcO4+4B171l/CungirTiHoHGp/toTF9elapYp5+qzJz+anrWt1e2RDUED6qkKmhfn22/aiGxvJSNB02Ey/zbFkr03Umxv3gPW7HN1XUO6oEHQJG4IGlBPVdA8f0gTusntxrUZCJrhX3Fv8vByky3iO9Qix0TqXwvRltBG0CRqCBpQT1XQtJ8S+8OiGiKbW0o8aDK+7byXkr6gurcND8gIPnvc+WUN7YIGQZO4IWhAPVVBE5k+9odWE0Q2t5Rw0Hhfe8K3QUDkAil9v3sdKuJsuWbaBQ2CJnFD0IB6qoJG21f66Z95jgptbiXhoLnCuWR1vfLNRHeVkGfWlX4JXyNe0CBoEjcEDainLGg++uHpn6WMPICwhmjQ5DvCtzJAaV/BPgBO+X9xL8H5gHhBg6BJ3BA0oJ6yoLmVOeaPxtOEtraUYND499Md0e/MtRVNxfajy/vxioA4f6Ve0CBoEjcEDainLGg6jY/5Y39hoa0tJRg0fD3Oph0fLLYbV8IfBN1+/pds54hbIWgSNQQNqKcsaOa0iPnDHVeHEgua/IdS0gvXDGNO3i9mfwHv2KGy5AsaBE3ihqAB9ZQFTcnkMT1911QS2tpSYkETyjG0/9oCdaNY+399L+ZP8gUNgiZxQ9CAesqCRqsUFvV/3UQmZLGaUNDsrEAvW7ZZfZFdUC0Im8FzQYOgSdwQNKCeuqD5PXqESJL7YhtbSiRommUbTi471Fts3k2yyD8KclzQIGgSNwQNqKcuaG69dVv7uYk7rncrEjS7y5GLHh46U2AHfMb8rwO9MIImUUPQgHrqgsZ9CQTN8xl32HqWstvijAiaRA1BA+ohaBwJBE3ae9SSp1fbbp55BE2ihqAB9RA0jviDZtuH1JI7kjrMFGM5BE2ihqAB9RA0jviDJtt1YsGaP0ZwV64cgiZRQ9CAeggaR9xBM+j2WGLJqU156zYBgiZRQ9CAeggaR9xBc/A9YsHbfLNumgRBk6ghaEA9BI0j3qCpsZg4+cyiAeHcjTEBgiZRQ9CAeggaR7xBs7kKrdyR172422IGBE2ihqAB9RA0jjiDpn76qbSCI0L422IGBE2ihqAB9RA0jjiD5nviMpltvuFviik8/2OVYAVNmS/v/+/ukeZFIn8ZvVwLHt3W/4+FK9MGldi1XVYTE4duObJ/cuJRu7L9Fi9Z8I+WZs2VfF8Vy/f5nQXFsm8g95/nh6CxiaufRb6RPf07HkNGfpNmuOafovLVV+/VOZj660Y9Xj9mddueG+UX1PrdUM/gd6fHHKK7q3SbPujnBduZkzeyg6b0ZjktdKLjjj9qdo5sOrXrlIEbb4f+1H9YOe+Dc7evC1rS8aGyfRLwBU3g2EKkcsUG221GgGcMBU3/XGN76k7d5pNnf3Xi5Z5q+5fnOPfXG1V+yDSiX+XxxUul/VzBckDCeu3LHPrT8AgXJfxHT079oZq0QdAIkHs4jXo1css3b7sqseuy73af7639LHX0mfpPgQ06b1YfHJAiwsXGVl3RzPjwl9Y3Su7SeTegwZcXqnc93FnFntn4guZGVlo56sLK5hO+deY57eNMT1jbPhp4Yit5Imk15nT5oqrDONngrhl6cqzsoMyo9J+0/45W9K7fwioR0huAoOEk93Aq9rDOL3pnbwcT6/yT4jWRvRiW5sgR5gLCw059dVzv27QVVzQbP7uTLoJS8MzebZNk75yAL2hmtyQVCysh0hRTCAZN5aFLiDNW+xcNDORskxPMC6+Pljl7NcnE0nqrvNadq1+ZOQ+uBvkP3MO3xeLFrxBjKY61Nbk34dN8suwalQeNuYeTjoIDtnJfpUx65+jq+dx7MmRMm1eTEIvmuLfa6dwnpgdNcONV+/UuZJzwz/zngsxSG8DGFTQTWpPGxtzfSZ/e2WxC59SwW+M4fo3akWFv9uRpkxPMZjo5M4QfyeDiHGt10Fz/rofIZjVvv5ZzJNcWCBpH5h5OTkT+r8kry7m2eM5/bfb8P4ptyi3Qx7tiAM8GaS689sjxVVNvnQX6RJYTuArv3TNgt7Q2EHAFzWUfUrGz2UVaYg6BZzRf1C3DvZtULYdybxMX/5khsHvDP1xtUOd7A3szGjS9vJuK3wS5V3LdeY5J8xA0jsw9nBLyntv1TadXTFRHJnzDvGstw5QkAmfslM1GJ3zJxCuax3umLhTc9EjYpybemeQKmg6kj5hPFTs8DtDBfU79OMlakf3cP9J5i8h2sbjPDOv/Y5xfLQyaGdVfN7B1jP1Z21PvoCBoHJl7OMU3uWnhCGpZfX88yGa8Etfm1hEc+lf1zKH4L5h2RVP/1AHqbT5nMrVYfUBKOwh4gsb/3G1KsUaEj41lOM+p+d/YJrqnZLluivcL4Lyp3iMd876UZbfO6k9sI3jTJJ5k3x2n3Y9E0Dgy93CKY2vox4NIBdmqT6yscq6RHDtzi2/8wdl4fbJNChrPN2dx3edzpmexOub0euYJmqA1lFIhfazpKkLDdU716/ApccIdpw4dFl7Gmu8raFhwBLNGq65oHkz+UnTTBEK2H79DKIagcWTu4fRc/0kXjHx+Eoqc2UZibfH4vCX8hTJGpjKT41wOmRI04TfbRhiuJIpPtvtmPALjCZruoyil3jgt2BRT8JxTm1Wva2xn/ssyCm7Jc2bwHjOB0FXBmqAp83kjsQ2dm3iO/f0YQePI3MMpVuVxvQw9mXEUMKWNkfvRuuq+Os3wDMA+hV78x5oRNNf9XD5D47F98GpZVenjCZqVpC/ohUy77SeC45w6K5R0p9ClpOTVSOPjODNcS026tWxJ0PyWV/YU3tV/82TcQEHQODL3cIrh0/MkdT0RDmneSC6/r9TkcP5O9I4C9pVZH/uj+qDZ2IBycU+WcbuB+4Y0HEEzvwmlVFUZN+TVIZ9TO2bpLWN/J2sJ3VimnxnKrMxEqtGCoPFuPkRgK5aq1ce5/CdF0Dgy93CKcve/AQpiJlrY+gFyK6w/PZmkb0Onv41tmvKgWV2K9lsi86p+4KDcGhPiCJp0dymlfiwq2hRTUM+pW/9hjg2mOZX9FYGtyGeG05+H0Wo0P2h6BZbl34ii421XA/8QNI7MPZy0x3u7qLut0fwnqXUXPiGv53TZnQ9i/lQcNGfWdjGwtY5Jp4wNyGDhCJqFlNvt3Y4vEm6LGYjn1LtfyLiajnH6OscgkGeoZ4aNE6gzepgeNJMPzuDehijkztUVum8iaByZezhN/FtW/w+ngi5wTjDhQn2fRzKvvPzTxDztUBo0/qc+J05SwifUu7WKap+hB83WgZTR8ecND5lQi3ZOvbpG4oxXF6rz9+ognhk61iOPJTU7aI6UieTdhEPzFDv07p8haByZeTjlGC61/4czE1pJqmjrpJWSaor1cF5DTW3QhFcUfOzLtqC6yM0XInrQ9BxBKbXRvrPPxCCdUxcXoU1STXQ0D/cmxDPDe/QbqyYHTZIbku8iJ6R7/wxB48i8w6lkngs8szUJSlVeyn2T0wWlTzgQkrKv0qC5+oukW/rOGBiPwUQPml2Umf/lfwglo5xTI7+YLXenV9PybkE7MwzrRa/R3KA5/Z/UqHZGb6IjBI0j0w6na6fL0usw4HFdCVNt+lwwMqxez98eCoNm8ugIsQ1p/HtImBDYOXrQ9KF0IRrVXrwppiCcU71/+1v2Xod35NyAdGY4XfUcvUZTg2brGPJk8KLu/fqO8zcQNI7MOpzuVTBrbEO/VG2NVpHxlJKL7ocFjisLmrkhKu9HR1PWl4seNHsp928jiAvWWIY9qWav44ul7/XIJs6PBeXM4Lecp/O7qUHzisKbvbF0/3sQNI7MOZzC613gaZQxyQsYHM8etlnJM3VNe9SzsKKgKVJJUZ/xFwJGKUoactD4lSf8RwYU45vS3Xz1l7JKJJd+PRPlRiq+8pQzw5ognhrNDJrMt3hKC7nXX284BYLGkTmHU5LSJjyeee5ETkObV1G3mHLVoBasIiKzN/td/lOkNZwCWn6qpF5y0KyqTShUIky8JeZgn1PVaD2OqzjhzNCjH9c8UiYGzbX8qi/wNe2Op947CBpHJh1OHJ0JJDC0jG/+OgqHjSxiTl0l0D9IGyplBDlTSFElSUMOmnlNCYWK7xBviTmsCprGG7mmciacGT6fxtUA84LGb1xZemFB+hc0CBonTDqcclzhqsOg+2XFL6BqDBAY3CaRwK2z1A8UtMOZkFDRGRpdIQfNq05WknMwpZmBppjCqqDRtpTiKc0+Mwz34Zs4w7yg4bsHI6bZFN23EDSOzDqcvFTcdtaVJaSz4JYlV2eR2hJu/EFzw7yn3/dvKUgactBkoMzilll8BRaTWBY0Wc7xPCBn9lkYUT0v3/5NC5oeU9TfOHNxQYOgccKsw2ldDb5aDEovegVFW8FRIe6gGdNO9vS0LgSFSZsZ+jly0IzuRqjM1C80QiwLGm0e5SHXM8wzw4/+nLs3beGz1jPJRYX95Kv/HoLGkWmH05dfc9ZjzJpKQpsN/0pyO7jxBo1HXo6u58ZVXi692yg1aNjdgqOU22ikKaawLmh2tuZ4VMrsHLejNOfuzQqa0zlkrnXlnKsLGgSNE6YdTiNoq6DK0uQvkRkCtvczs3ecU5xBczWC68a7cX2ZS6zyogbNx5QMaTXBSFNMYV3QaL04Bl7Lb6ZZt844Hypfm5Sv6+aezeZ23LC/WlHqA1pXFzQIGidMO5wCxyqfESIekd5HzbIpGkDDgS9ovPfkUtUQPT+UlVwhNWh2VCQU6tHXQEvMYWHQ8PT9dtugOZOfWFDT0pzOUzLf4Hgv+TRY/srfEcwtv3LV0RNB48i8w+l7c7sD3dv6Ifc2s1sqaAgnvqAJmcRb/6oWfY4f71pgbueOXj9vLNo6tGOPAXzp6nPgNd59ukYNmr8oHREOmPt1RoSFQaN9V59c1G2D5n4aWrldhb/Q+/Rsa5D+ssv+BC0nunoXQePIvMPJ840IeiWLm743b0rujVUHnP78nqslhlzgny1+QWOxPUnFFTQz53Dd6mv8pm/QQ4dX/fwa9h/IcYN0sOQ1b6hBU/QooZD9O53RnjXp8Vl16d1GP89/Uqha/uTn53D3kOS4s+i2QVMpjFKq5+1LLm+uTxi0tbDum0FjM7vaFkHjyMTDaWo7yubhzQcn+y/+RO9ZOkds5/8anWwY5+ROG3cLjdTceSL8oyZr891cfL2gV785SeYNEqnkBZ6ZASKvcHx/r5lki4seY9ty0jsX3pL7rJUaNGkJqyAM7WSoKaYQ/sj5LN79IH63/fBlLfJzTTNe9gdyUXcNGsopU/MZS5gjttgmve+qjLlHEDSOTDycttZh9G7PmXpWiaZjdN68VnszZ9ZwdebUhHo2H35vQR6HeeByvDM1r3g/fp4rmtqryEUXpzvEyN0eVxf+Q6vrCGeHdwZq0CQlFMx7xFBTTCF2RRP5+ZV1Tt+4FnaI494nvTemuwZNLsI1bfIrtHPJ1scLnS3XwLig0TK66qAzmvnpyZ2PVeLf1awSvF6moNEaurpWXb7r/E7Xh4jfW+W68ZzAyx7juo1C+iYU1+L6DfXu6oWfylhGcHQLR9CsJv/ij3S/v55dqkLbvbSpOf32UndMQQ2aVoSljQ19Fkwi8pGLnNlG/80Kq5stp1ZEX5fGTYOm5GP2NPFzRpOn3Q3strO/w4veZ6ibO3GM+QEfK3FtVaqXKmhm/LBM553mafdsp9R9d+ZyjocSl3iGsXe8y7fUVLkqIS7f71XmK6GFEei3ziqnJp5eio2s6Phkxqksf5LO+sH5Da/EEAc1aE4S7hPm/9VQU0zB/5HzGdVXb9Xgp+72/IN4LCwiD5xmTzKtyyPv+jpbd55st7Xt/S9Chs8LCPKO+dWZMo5m+wfMIo1vrCBVFatMyIH4l4ysCxrXEmnQmHo4VXTa5fh+lqU9dlN3uuoBfTno7v3IRaMKj+IorE2Yyw7GUV6diPei4qJf0VBuJUXbPZFjoHSLOZRS6yg9jamoQVOK8DV0M++oLwvwBs39C8vZEyql6Ep7wBj0H3V8meiZ4dCOLI5LvdZ4fc+S6wtdXC9LCxr2IJrQgvSud0/V2NHryzh/Nba0HoKGi9DhNL+J42uhtVfxzT08sR119cvQM/TFNpkPkOKqdpe2el94ef7pLslBM4V2uN8rksL1t+EEgroFsAvl3O/FU6dr1KBJRihzOYORlpiDM2hqrqdM8UZOml8KEvcrdK8jbNfMYwKbSQyaUL2HvM/pLcDsSmDZU89veBi7oEmsQWPu4eSwWkDzITO4p7+sMJO6DhvHvTP2r/+5NOfova5SLOHtgEIOmuSk7kbJlvHOxUNaa/16as5aXSAGTUeXQxdi5aF0gbYYX2eAndWJs8utKk1aFpZ8MSpwZqj3GvewLvreaEHjd/Uaq0jq65SKEqp7sfCMpz/xriCXAIKGysDhlGC1gB2fnhKZOatkEeIcE/R7Z95VZ1CL9vuX5wqsbr0JfLPaUIPmSXJKqbsL6Xcan0mymz2rTaaV8hZTIAZNMxePkp/zJH37txbXR25YA/Kq4rRLXPJkcPxnhv43xBc3lRU025jDtCvTu2rG5zv/3ehb4SFrxL5kP4OgITJyOMVbLSBLLk9CVyinFqzQ61YQD/3eWTnyQ6IrlbjuRGnarK+Y37HiogbNBsc7l462rx7MLuSA8t24zCaBip0jBo0P5UTzCV+PDkvwfOSq3tlCL0zq7T7sC2JtvGeGncea8m3AuTda0LAHXYutlR6jRprsw4WWwI0LQUNi7HDS5jZ/9lOxw4+JXaGcIU7RSf6Cu7IOsWAj3k7QmhZ0lGd+ZeLnoOcIQiGPQK7uNc+111/T6ZnHj4VqdoYYNEeKEQptLMcuYzWOj1zvgTyfkchaYYRSBYgzOHOeGYY2MPTkQlbQsPv0zGUucuvC3Ws+VWjPZ3UhaCgMHk7PVwsIKuzHPxVZXJRhWZo2MJRWW6fxtHIBo4rSCsbjsY9jhmVi0NRZyS7j01B0iec7zGfqAUGkeR4oiEEzhvK77GPuHOFC6B+5YR347iwTviDQlyDlOzOE/9ycXcjQ3mhB8xFz6oPC+yn16Npa3tDmCBoSo4fTs0vbfj68PQwTevyI0u+p2hJabUP6kIplaiI2v0z+odQLJmrQUE4pXv8TeuoZrcurzC5M3zrpQSiGGDSka7g97xhqiinIH7mAlLwDwL8hTENHHWHPdWboWcrg+VdW0PzxBquExJu+QhA0bIYPp6erBfjkkPC7HrSBMKyiHmlUSMI+CrrGtaaVc3A1F3lEDS1oLhA63rUbTd2nI/anYXlV8drjIwYNacXqB9KXZZOP/JG748lbNeWOsqthk3HxnBlOrzY6gldW0JTdwyoh7xuSGAQNk/HDKcrOPu1miz05SID0DXc16Qbd63+S9migT2+qd6h9z0hBEzyLXcbQPBnhuZj9Af7lms3RBWLQzGtKKLRXXmc4ZagfOd4bZ1HqrmN/oXnjNK0ujl7YI0sa/meXFTTshXypQatKIg0acw+n6B2Wdz43ID/2VTL1W/2PpGcop+uQZ0hydIv6bIsUNKnZA0Eb7+dYttcRe/GXzkOM1B8HMWjWUSZP6SLSy85k1KD5UGDmxIfsMR4jO9Cqon8FDT7G0TVOeG+0oHmDOeroyb+UetRJpEFj7uEk1YHi7DLLPiJUNJn00Svb2VD3hQzEDnCkoDmuv1RGrJCrxjr6FmNOg7z9fUM7eIEYNGnuEwqVN9glyAzEj1wzypP9hJL8j1nE429mkRj0M0NXgytj0PZGC5qv2DNZ5zI2DsYoBA2DjMNJqpLXI5hlGAtHPJWS9B1nJWEFCxdqZKct4EYJmqvezCKGbpxFY341DNlDHnvkGjFoPJISCkm7n6cQ7SMXVEroPjW7n36mi7SayGeGIj8TCxrbGy1obrOHgGW8RKlIGQSNa1IOJ7mazmMWIa1PQpqdcprR5Tez3iAVowTNd61YJTJ1M9r7eCmzX6CswZHEoMlPic5CQjNmm4v2keOaEfaF3BeYRb6mJRj1zND8DxmPXGUFDWUtib9SUGpSBUHjkpzDSa7+Ycwn7JS+UVsrE/aVaXsuQilX/PtRxvKTgobdtcb4E092X4vsZ43u4yli0Gz8mFCIPGWkhWgfOcHJdIqw7wt9RRtdRT0zyDktygoaypRLXiOJQ4mUQNC4ZMV/PNPeMqwSNReyaxnWi7Cr24LrmMUxk9Q5mhA0PZhzAEmYXbnyVlaJBUFG9/EUMWgeU76HWvtllYb0kRNdk5pwkGWNINVEPDOc9CEVM743WtAcogykCv0sG6UuNRA0rkg6nCQjTA9AGMFHmSKqW2YJPbvZo5Y1UtD85ssqcfxNSntc+481iiOshPGdRKMuE9CVsPyn1aPxKEgfOVIvFifqZ2f+KxGfY9HODCH15AyRlRU0594i7e5oV8tu0CBoXJB1OElGWMuY/fXNuwlhyfVPZxGaw5KPcq+JEDQrmLM1feNi4V+qv1kXRZkyc04vqoMaNJRO6DMbGGqKKSgfuZCkov20+zH77FSkjS+gnRnIk0Eb3hstaErvo+3vWrsFj2glZUPQuCDrcJJsVW1mEfYpt/EC9o4CplKXwHGJcgOZHTQlS7C+tB7KR2yQK4VOskpI6uJFDZrphM/fVsKqbVajfOTEP3DLPmGVaEFb5YN2ZpDVF1VW0OysQN5lb/9PhedoMgBB44LtujY/5RfIvBhhd0P6gL0os9aea51nXdcJt4bZQZPlJqtEL8pTJ5aqzLtQRua4iYMaNMxLLE3OPUPVKB+5kttEax/+FavEjIakikhnBh8vOVe10oKGNNrquWRzGoTOLEFfh1cGBI0+aYeTbK8wJ+lg/9LYE4trWn1Cp0kCv72vMcuwg+ZeWlaJUjKG1g5ldk66RV9p1BVq0HgRRhqmvGWoKaagfOTE730OGMAqQVx3lnRmSMJ1Xje0N1rQBJ7lWZMjRsjt99Iua2l4FkcqBI0+aYeTLP6r3rqU9d1qbXoyn3xObcoqwb5FpCW7S2sWE+EOMjtomCNcpNw5I0wAJ+mBCDVoltdjl3nEtUyyNSizPpHnYHXAXvnrMnMNiBikMwOxq7SMvRFnnSat/uZE49/3Zd9qcA0UEgSNPmmHk2F3Py9+9+tfImqTF61kf6passcdTmAOkCQqfJxZhB00s1syCpzNTm2PK+yOor/ml7EfctC8+yuhkBvMqkn4yBmYj6vgKVaJ2cynODEoZ4ZFlPnnJO2NGDQ7Khpoxc4cO26d22ZgSkMCBI0ueYeTsC6jZk7Z1rP2mOW8Gy5lDfOj/AP06Mu7Wz15I1gl2EHTm7VWzDkpowROFmKVkDC2KBo1aO6nIRRyg7WcCUdcy4nCtbPPGBKD5jXm40IqaUFDmJ6JIefe7m+m3rrIaDV6EDS65B1O3OrnaFT+nH/IQdo8YU4wD88fCAMWpDzziBGRl1WCGTTNvmdV8YuMvgCtqjOLpCcu48NADRr2s6kobZnTxFuO8JFjfj3Sx17xWmLQCE5fILQ36oJtJ9422pZoD1etKtzNwFrz+hA0uuQdTmQlZ4/0OZmyr29u6jIuepiHJ2FegOqLDTbiBfaa0cygOSqymrQSkmYnpAYN+xQapdUEI00xBeEjl4452b2uOS1YJSQGTQfmHBVU8oLmorSOh/cmFVg6U3rYIGh0yTucmPwKn2r34V9FZ1WVc1eGcHgSOp2df11OW6J4RrJ6ajGDZpO0pS2NGkxYOJiAGjR1KYO5bTriKy5CZwDxvgCEC155QbODsFAHkbygmVNf1rkjWujMeiPkrtqKoNEj8XDSF/jd0hH1DnzRIFJyvczDcwt79n9J40VihI5hFGAGDemZuClMDhqtGmGxmS+GGWmKKdgfucqCPaeijWdOkiYvaKiLdUrZGzVoqLPQkCUb8vaXEvsHIGj0SDycnGs2o2OWkbITJhbz8GRPzKm9TxjSSfXru4wCzKAZ0kdWW4yStHIEOWjeI6wZGlC1s5G2mIH9kavK3eflBTODZh57Zg4qiUFzN4f0c8muwkGy1gVG0OiSeDg5mlE8NC1hhmVhzMOT0Lu5qMTvM2tYUx4zg4aQjCaRNAyfHDRXchAKjfncQFNMwf7IGenmaWbQECezkbM3ctBom6sYa4tTPct2kjNqHUGjR+LhlEDwsKWqTwvMw5O9JN9idv8ruu0fMAowg+Yf9uwCJim+Q0o15KC5kZVSKJWBppiC/ZHz/Um8djODRuLDW5lB41uNNQBAyJns78iIGgSNHkV9ASY3TmLCKZN5eLInn5f0KOKpMnsZBZhBU0rteDIOhfdLqYYcNKTZr8tS1mKwFPsjdyW9eO0mBk0wswslncyg0TIrmohoe/LPjH/4EDQ6ZB5Oz1W4sqywgmodsQ5PQtBeTy2pLdH8dzP6xLCCxu+wvMYYxJ7eh4QcNHXnUfoTNRUec2US9iH3E3PBIX0mBs0kZk9qOqlB45dBeE5ShuXnvzMaNQgaHTIPp1jXy7HnF5OEdXj2YvdSkjv1fKUw1++zgqaGtKeShl1k3nUkIQeN9iVlNKbSR4oysD9yRgYDmRg0Rvos8O+NI2g072UljTTGldP/GFwxBEGjQ+bhFM37+5GEbqqysA7PJP9jViHpDlEs1qoqrKAZ1E9eW4yhLJNNQQ8a9soFUaYxZ5W0GPsjJ7q8ZjQTg6Y3c0UCOrlBo/nmWWmgMS4lO2FshicEjQ6Zh5OmhTdfzJxDSybW4Tm5A7MK8bVBnDnOuGXIChrCYm8m+SOdnHroQUPqTvTwE2XTVMnBHrC5hbCWqJ4ZzAUGpAWNzMGxkoNG2zpfzsoezhzPYWQIJ4JGh9Sx1peLi0+uIYR1eAatYVZBnFad6ALjypsVNDNby2uLMQZmfoyHHjQHSEOH5cwpqo7sc2p8Jl7REFYdJ5P+j3L1rLphAIcqR4hvjKDRIfFwOn1L2a1TPazDcz2777KkZ96xWJP8s/6511k/lXastFfl1EMPGva39WhG+myZ4aUJGpm9ZOT/o9QfLHmGgLj+ph+0CSFodEg7nEr23c5ceVk61uFJGJsh9/de9Kjr91lBM6+ptKYYlFrSiuscn9mklLJB02wz0siplyZoGhFOTlQq/lEKejHXcRcVlFz4zhyCRoesw6nCgLJyKuLCOjwJ521J6zjHYq0n5jZBI23ZUY6guUVaAnF8sGhTTPHSBE1uyqKJREr+UQZ18RJqDIHX/0S/ZiFodEg6nFbVSCKlHk4Sbp0R11gn+uMN1++7za0zabdUOYKG1hNiV5/1om0xg5sEDbvPQi8Z6x7FUvOP4j2Gtey5sGurG4ltmEiDxqzDaVZjTxnVcJPQGUDe+prR8px3/T7r/J3mvry2GBJBmRCGgud2N3vZz2j2nu/MTYJGbTPN2luWSfVENiM4kpp0ee0gkQaNOYeTX/FvjVcihNX6HOxVImU99H6KNScmK2g8ksprixH3u8mamYgnaBqQ1qDr112wKaZA0Ji6tyMbeohtyLLjfnmRzRA0OmQcTrl+N16HGFbr2QsSSh5qPrqb6/dZQXMtu7y2GDGSPQCJiCdoUtEWPPz3iVhTTIGgMXlvP6RV09l1QiuRrRA0OiQcTux/W2VYrSf0mG04Q1JbYrRjTMXFCpoKO+W1xYgfpa0ozRM0/kdJi0/aegpnBI3pewvuPVDqhzjWkmoCGyFodBg/nEjTu/Npfvy1RbmnLw8uwSrIesLUkT3q8EROcrPYvFn34VhB8ziFtLYY0fy8tAfuXEMSOkwmFfu+jlBTTIGgsWBvJVtNfHOZkQqcWVhTYCMEjQ7Dh9OYdtIW8Q6YvDRDyIbFKQfFzgER/j5rC2brkzF3+vgxpWlEzEcszM5c7HUNzCDxfiJX0EzsSCpmZEUX1RA01uztbsnJsicLEBlKhqDRYfQXfLX0OWMVRBv6Zs6xb0WcSzgbJ7vPHLP17OVd6s1hleDAPFEygyZvhKSmGOHvN0ZaXVxB02Uo7VvLLwWF2mIGBI1le0uSftMbcqYcf0pkKVQEjQ6jv+AtgeLb3nvtfMn90wZ1XaWTBhKuaAgdZmtInKUx9QNGAWbQVGPOfV3gIL09NsA3mwdrHFKsxndsO7UmgsbKvQVm7L70y5RSqtKE5tVD0Ogw+AsueEpkq+D+SSanXvNhO0YxCa1vxR73/+ZxZhGyPkMYBZhBU3Mtax/v7aK3xwb4goY6M4LcLhwyIWis3pvv96kb7pFSU8FfuDdB0Ogw9gv2bDibc4sndT/ps4M4W9Uo5oAJZutZk1xqhmbQc9BvEKMAM2jeY16vZKcseWwffP+6gStpx8bDc7lEGmMCBI3le4viX67uhMP1vzRYS843ufvEIGh0GPsF30/DU7rcpyGB8znKL27AKsFsPWEI4KeziM1h87zLesTADJoWzEdGfRWNUFOEM8aLHKOVs+0CaAgay/f23ITpl2oNrGJg7s3htM4pcSBodBj6BXdZcI1cds4ib94nzOxx/czWl9vN3Et10nB0ku0fsEowg+ayD6sKew+Md8AZNB3Diau2txvN3xYzIGgs31t8fuuH5ht3soNQb07+VbcRNDoM/YKz3iAWDC18qid/9WGVWCWYrQ8gdIQd0pnYHqZlzA85M2jmN2FVkfMEuT12wHtjsvsoWrnmGQdwt8UMCBrL9+aM56ohKzJw3ySPTM67BYJGh6Ff8DTa9IYPG1/ZIlJ9zkusEszWszuuSZw/ktDHjRk0fvuYfWbSmbyMqTG8H+7x54nfPat72LLnGYLG8r3pO/JxwRtcd9ImN+fcA4JGh5FfcJm9pGIfBLK6l+lgXyCwW0/o37wgiNgelhTssZ/s2ffrrGSVsG+PK2e4v0V+25ZYsHs/3qrNgKCxfG+uNXkrLIxcmHtudwSNDiO/4ItvEgoFnd4vWj/7nMtu/e5yzN0MZX54iZZ8yizCDpqKO1glevYhtscWuIMmH7lX3bfM24wWQNBYvjeWkv679hCnM+E++yJodBj5BR/2Y5fJ8kB4SeCSJZg3Uditp4RhxXW0BrF8+TWzCDtoCN2u7DzVlwP+zuMD+xMLhjwcx125cggay/dGcG1PXVK5/ozZ2B0gaHQY+AVP+IJd5t4CwZXqohwpxizCbn2t1ewdFfmZ1B6W9lPYZdhBMymEWck7coajmYM/aAjLosYq1lb86FIFQWP53khocwGvr8BZLYJGh4FfMGX1kIMFhKvXprIf7bBbX2Uze0dB04gjSF37mbAuBjtoeg1jVrK8Kqk99iAwHJY9Dc8zR3613cUdgsbyvdGMvT6cXYh77AOCRoeBX/Am9vmu91fCtWva1+yBvezWe5dYzt5TI8LvgWnbh4RC7KDReg9lFqk9j7ArmxAIGsLgp2fKNlO2bLwgBI3leyPqOYJdpvE0zkoRNDoM/IKrbmIWyXdIuHZtbFd2GULra69iV+MTQu3p5EI2ysMoQtDkvsAskvcIYVc2ITLBz77S5KLBC4WfAZKFfRxJL4ygsXxvVISOQvd4l1ZH0Ogw8AtuyZznjPv7QFynCFPBE1o/jLE2WozOrMkw2Sj36EhBc50wZWwn9lWPXYgEzczW9LI5UxqYYoRi49rJzAX24kDQWL43qjGh7DIdRvLVyQ6a1hb0YHHroPE7zCxiZBqxGb0J09sQWr8/lDDb8f3cEexCLvkXZs8TrZGCpn4u9r3jD5hzPNuG0JSlg/vSyz4MUfnJ9UtVcKqmZXnyO3UDBI3leyP7KYBZJBdx7r1n2EGzj93HSTq3DhrC8vZG5qMirepLaX0oZYq1OfUIhVx5P5xUjBA0pBGLU5qRdmcDQkETPmYhvXBQLtac2eLmHH569NAvaRA0lu+NjDD24d8nfFWyg2Yz/b6wNG4dNJW3MouIrIUai7kocgxK69m/+mgG56HpsZM2FyQlaDqNZ5dZ1Yc496TlxBZh+HQJR+GQCUXp3Qd47E/XI3YlevolDYLG8r2RTWnPLPLfI74qhzO7P1kxzNitg4YwzIV7pqAXvP6mlKK0njbSvJuPeFs1ze8kqbm0oPH2IYRI2qu0HVpOcLUf0gXtc2G5ZS7hG8vzSrUXvwjyJQ2CxoS9XeJf+tIZwgCNLoP5qmTf2ZC4LAmZWwcN4bf0j2jdpHGWGrH1hOnOokz8wcAcjYsaEgtSgkYb2ptdplvbzMRdWkwwaLamLMVTPOcb7C6QfAIfbk8S56/kSxoEjfq9fTZ99w8Cs8E7WFWbWWQvYfaTuAYw5xQvt5GvRhncOmiesKfQ/h9hSKdTM4adI5Ujtf5sPlJdbb4hFXOGvqA1KWhIQ+PPjOXsD8NQ4jM1o+xF1y+lLur8TLVHKwT35FTPUtXiv0C9pEHQqN9bnvPaQ6+qxifvZt+fDyGMtYmH3cnV/z7tca5Mbh00fdkXld+JjqbbEkgrR2o9dZbGLVzfoePYtoUwxvgpUtCQ7p1pvddLfDCR5bNBP/nKqy4O4YWyCaMc4nlUgtC9kMZvV6DDLD/USxoEjfK9PT1t7tjHvfxlQutqsErcTcZZ5QL2yq8WLPPh1kEzK5hZRHRs0hrqxP201q+gTaAXUpQ9+7Izlf8LI5clBY0WMolSysAlWAJdGn4/Vgs9IvWS4BnhoGl2jHOATMD1dNtFdxbX49zznXUMIl7SIGiU7y3qgibG/iwGn8yxF7ziXjH8QWpmkcLC09kLc+ugITR+XUWhmg8Up5aktZ46S2PAOdoNu/iCW3BcCdGCZv8K0iXSlSpyup4teDNmPMFW9qgCAcJBQzgNJBSQLt1U4d3FGlUlJMzpG8RLGgSN6r29OPHc653B0Oq4LeawShynrIQSF+HJ9arKnHUa59ZBM7kDs4gHsS9WfI23EoZqPkVs/dqaxPoE5gBtvOE2R2la0Gj305CKXfARfQgWx/MZ08u+st54bQ7Eg4az59lT5XIYipoxD+/qZjztkgZBo3pvzy5oou2smdPADeSbWVglZjbgrLIbYejgpYyclRrm1kGT/wy7zCfMWWqc1FuBfqogtn41+d8wkLnWWgKfpSc/n4lGDBriJY1WNT9n70sH9e8veb52dFv2ejr8DARNydXME4ETqZKI3gMf75vE1WA62iUNgkbx3hKcNA//TO3x6WA+e0QL981/9n+pFZc0bh00+0uwy9T5nrvayQc5Viomtr5uPvLcYKeab6HvXit5JHAZR3Fy0JD7S5d9nTTzjR7PQvPi9P1u8q2RunQYCBotMoKzc+lTPTtkfcC9UYWRjU4yipDGLiFoFO8t7gVNjDk3BR8Fn3uLVSKgGHfXzkyEGxxJ7/HWapBbBw1hrjOt5ireT/yCWinZhZ6jtp6wtM0zO5PS5yKaU9eLXPYpatBQL2k0zftjyhQ7Tk3I0Ski3gsqJpY1EjTaoO8ixDZs0r94wvORK5PrvVeDuZwr7ZIGQaN2b87OmR0Li1zVZEnCvEX/RzruWjdUY5fR/jb0qeDn1kFDmL1Z04a24joVBy5PxdUEauspV1/PffBNLlK5jgXo8fUMNWi0puQlZ4alEZv3bGvfAwkH1HKvJ0hg7CNFmxPbqXrZ81L+YTzr1vl3chitSsolDYJG7d4cLmhiVK/alKc90boEswdyj2f3rE3o0DuEQl4DPueu2Aj3DhrSP+nhJRxDeLud4JyVmNz6pVwjen6uHsEs4ztwg8BjZ3LQ0C9ptIBXI/m79fZ4ssxJF7vp8gdtGvzuRlk0QVfNq2M3/pVP77+p/orPbne8zzPF4aP/2GUQNEr3pnvKPByY6iBHi6KuVt5glxFYTyvlv6Rifb98hbtqce4dNLTRLsFzqb2y6gY3JXc3i0VufXhNrifEIcuzuT53+34xKIKnwmfIQaNV5+kCVqQDX0IMGv+n09dP+nBVQ2H0JkGB04abEDku7MN9yVek/vnnZw+hxh84512ANDNRfNnY/d8RNEr35vyCJkZw6WK5yS3aeLUlu9BQ5r+2I8q6ndGWH0gnYbVFIvcOGuoMu+84jLJ2asp+/ufa9NYThpfG1/G9J3rr0dc9uqOG4AgWetBoNbmu7irlJS/J4Lt3qO46b7xzCLIZvhs9ztBQCbkIT2kQNCr3xlirLGOaM7QO/w+GULoHrf2AVFk8/QdSS3qd86rpZIz0mYdnP+bfrWvuHTRdqCPTJw3yn88o8jjrYJEH0Rytz3CHu/aqPyzJ4/AdKcc7Qz8SGdf5FEfQDDq0nKvqbp7rHrBnUQr/cVIBF/UW38G1TwLDQeM/mnMuGpXYY2kQNCr35uKC5qnQtWX7sx4L+08aQPoSFxJYntSo+BpxLKWkTTw8K/anb8N+7vF7pXXNM2la2R8EduuSeweNVm0DtaRPwGoXS9PU/2b6WrErBI7Wj58rtOTvzhypFndfm+/m4usFvfrNSTLP4BpbpTkebl/24a39Wvrz04oN0xvBdmZG4Kb3Z7nujh28kryUJJHx/jW+NdUtbMaLfUmDoFG4N8riy5qWvOj8r/W7JTf+rSjx1onYOrZ3MohsFVdzgYHKrrl50Dzk6SIWvHzE686+mi7+t9AirjGPcfG0/ns7LErJcUVD6efv1KSqRb9ouLFv/VerBDyccKnFhYwBEy/WOfvDtEjKxtLX/5PQkbPGUZ6uymoxL2kQNAr3NqQPdY/bM7+/8HqCe98zOr3b6gnHw8wDAk/x+Kcdd4SgSYCw9FkCjVvP9Hlyp0xIu7Y1KqbumnXnhmPtDM2Lx9X6PWWN7EoOrqB5/FMZZQ3RM6mF5ApljBjwLix7tRlhzEsaBI26vdEuaOJY7netU64577wRFLZz/LEIzu+z+wtz7u2pUd2FNosDQZMQaXCSSlyt31bqVWUNoeIKGq1yar7HNDKsJK7QQCVnaFpbFZMWCGFd0iBo1O2N+YRGppCvOVdxfoavF48TCJqEvmtlYGMZ+FrPXmZVOb6gEXhMY1hv5qLnfCSNgR7xhfXfEmKwLmkQNMr2RjldyjOqveCGw41+ghA0CW0cJm2tKTGcrT9VUFE7yDiDRkvNP2mXUU0Nz7Qfj6zJNoIuC3XmkI9xSYOgUbY3Uy9ogo/xTHoY1/4avMMBE0DQOKCsbq8SZ+tLlhSeF0wS3qChLhggkbz11GJIm9Vp/jqefqPqMC5pEDSq9mbuBc2KKsKbvn3C2K4RNA7GDzUY3gbxtn7jYoF1C3iczOv6fZ7uzU+ZnjRBKWbKrE7e9IF3R9mhm3Poak+XXfERNKr2ZuoFDfc3wjjCKhnbN4LGUfdRhjY3irv127YId6WmaOXDmNlN4Pj9y+xlkm5LfRoicZ5az7WSOyoIyJHkmOsCCBpFezP1gubROCPzwyQ1dtAjaBxtrZZwBmCZpqXWmwUmFnEd9zgKZlb4WKlEivLyg0Z73fm8ZMr4Z2fN48BD5oTo/o8rK/2ewFTzzCuskcUIGkV7M/OCxuvmEyObB/xkaO8IGidUdjyrnDc/Y14agdbvEplWgsY/98wRCoLG9KQhTk5HI3fljfx95c8vTTfnNHsqcgSNmr3lOyupLRQzhFftfGp5PSNbI2icqN9DaBFEipx960+XHzTaZvGnfAxdB2lKgkb79V2RrYRNkPnlQfIST34Xc1rV+6xmn0aE/vEIGkV7m5SVcXtDnjJGxwf3/158OkQEjXODrsjtDvtcQMFxmoqg0WrdUnP37GABTVHQ+I0tbt4oknuZ8whOTe2U9LUET79l5koeLxSZT5qEHkGjam+PW03zlNIallYTDFexo6KBjRE0Tv1QUc2vP3p1OyVBo81qrKLFDWdoqoJG06oc4VpPx4BDReUO3VGwaG2tjSofDDoX1oa4BhaCRt3erp0vKaExLIErJVRyPo/4tgga57YLrNrAdj21pipotI9vy/zO/tTZ7NH/rypotArfExYENC7k+hbJ0zerWB19RgUDH2MR9QovoM4qgaBRubcHvwtNdMnh/tddZVRTo5n4jT4EjY6p7YzXkdCv+aP/X1HQaClKhYltqOsn35g/lAWN5rfZS/3ts2Gb1smuUkXQRP07R1IWrpIk9PIB+irBCBqle/Md+InSy9liWV2vo0FW+QB1ZWEHCBo9a0ZLfuoRkHZpzJ+qgkYb1N9Q/8WEQirFXtWpCxpNS5NK8e2zmhty8i27TqEmaLStS2+YNOFoQKEO9BWCETTK91Yjm8Lf/PbT0no1prkh+sUQQaNrVoOUMqp5Jmh01qc/KAsabcJyiWtJpunRMfYnlUGjjapXXOFEDAGVMjVXUK2ioNG0Cq/PNuHZcNCEoO1cGyBolO/t7rXSij4H6S9K7GhyoLjghlhhU1/h0hL7ng374NmNWHVBo2nt/50hvnE8TQY9X1RHadBoWpIK2wxt70KOzm2U1KssaDRtxv5VimdAqvndRZ6rmWgIGhP21r/63LHirdFTLPKo1PoKP4wQ2g5XNC7MaCXtu8CVAc+nvlQZNFpkbTln7fWdX9xwUhw0URdP65UshnZ6h8EharoUBo2m9Tp0LEJd7TunjGUtP+8IQWPK3q6lKit7PNWEV2Rf0V8d/bXIZggal3aESvnNpxne9MVflAaNpk25ZPyRcvCHfeN0SFIeNJp/9i8DjNaRUMrHd2RX+ZzSoNG0x4f6G11nSsfQysUeCmyGoDFpb6NmN/1SrDVORb5L7L/OI3zJAIEHNQga106HS3iQ1u9k3LmDFQeN1qOe0TH3/Su+E/evCxq7Lm48aKKO3v5XpX6Zyzva4GyzLikOmigzR/8ivT/ew7x9v18vtCWCxrS9Bc7eKuvRffMTd9SsipgvP//3IAQNg1/y8gbnPPSYOSre71t10GjamV87GLjPv/hms/gvqL+iiRZ+z5//no5zASmyKZrZIZb6oNG0Ckfa/yXznv3pMl2EJ+9F0Ji5t/m7vn5NaMN4Vn1+WeTilcS/SY6anJsgaJh63XzxXJxfvVbdd8d/RX3QRJ1V7r4nuKVXQYeea6wrGv71aHRUGVI+0ngtZ+Y3yWy8FpfMCJooM/L80kVOTU36ewsuFh8DQWPu3vyLdWpk6AL//ic/qLtxHGNKmcJc5dHrjKDjT7W7iW25M/iAQ38CM4JG0zbOPy5wqE765oORDi+ac0UTY2u7M8bGAg07/WE1SW1xwaSgibLx1p4NEcaq6HagdX7ebmYJIGhM35vng+UdRYeY/VHpcxWd+hPwWOLN8WAVVzQ0sw4I/EPtz5PCyavVNrjeSlbrw/dv2sZ3gXDhl6+c3dQ1MWiiZJl2uI/gphNX/6lwYZ44zAuaaIXbXZsjOnFu71pDJKy/iqCxZG/BSzbyz4M255VSqi/on0v1uF9fwpwGyTZ2D873Drscn5czaKJ2u67VPo7zdqZxv37sfLEBc65oYoSfGBFOHACY5l3Pqjpfg8wNmiiRkY3/F8a5za7k2Q6pW5UnAXODJtrivrtKnyzJE6Neb8/8vV1Bmcu9gfkef9zg9zNnaL/3kAolfB9n380uKFXwZ/kru1jr6UndPGXKmdeal8PjOtP/LkP4blnzh8VJOsqf+ERIx68arGdmTc9reReZfYC65nfjYOQ44rPw4Pe2dmjAWIxYLvOD5qkUyzqXbXCDObNh5bX3uq8/bkaDwAwd/y4+csQuV32SIguW9u9zW9nDf6Ycs3ds6rg7bZxX3vd9ENGrb3sF3asTi8KPknu7uPkV3u+TGdIncTToyBfvDP9Mpx9Wk8uZm5wx4Y6uAN82tYNuLXb5zHHSrSMjSpuaMTGsCppYp4Mqfv+Rb4GiLYYef738P5pWrNLAUX80u7k9afL8ydIXKr/F2taBGjOWl+77fnir5v+O3ZHugFazU1GvX2fUebP38k+aLxxgddtAkW6FBq9NMbp5kbo5/xuu+Rd8FJL07T4rs5b40be31S3TdXrf4+PvhnoGvzt9wT/Fdlxdfr7xW+m/7e8G33uTfFn0v7wb9o8vNXvv7aFazYwTvw3oNjbZwwdrBnWy6l/b4qABAICXHYIGAACUQtAAAIBSCBoAAFAKQQMAAEohaAAAQCkEDQAAKIWgAQAApRA0AACgFIIGAACUQtAAAIBSCBoAAFAKQQMAAEohaAAAQKn/A5SwzB71YUI3AAAAAElFTkSuQmCC",rm=null,tP=!1;function oW(e){return tP?rm:(rm||typeof Image>"u"||(rm=new Image,rm.onload=()=>{tP=!0,e()},rm.src=rW),null)}var om=class{constructor(t,n,r,o,a=0){ae(this,"baseCanvas");ae(this,"drawingsCanvas");ae(this,"uiCanvas");ae(this,"eventBus");ae(this,"chartId");ae(this,"rafId",0);ae(this,"dirty",{base:!0,drawings:!0,ui:!0});ae(this,"beforeBaseDraw",new Set);ae(this,"afterBaseDraw",new Set);ae(this,"afterUIDraw",new Set);ae(this,"drawParams",null);ae(this,"view",null);ae(this,"priceTransition",new Jh);ae(this,"resizeObserver");ae(this,"destroyed",!1);this.baseCanvas=t,this.drawingsCanvas=n,this.uiCanvas=r,this.eventBus=o,this.chartId=a,this.resizeObserver=new ResizeObserver(i=>this.handleResize(i[0]));try{this.resizeObserver.observe(this.baseCanvas.parentElement,{box:"device-pixel-content-box"})}catch{this.resizeObserver.observe(this.baseCanvas.parentElement)}this.startLoop()}startLoop(){let t=()=>{if(!this.destroyed){if(this.dirty.base){let n=this.baseCanvas.getContext("2d");if(n){for(let r of this.beforeBaseDraw)r(n,this.view,this.drawParams.transformer);this.doBaseRedraw();for(let r of this.afterBaseDraw)r(n,this.view,this.drawParams.transformer)}this.dirty.base=!1,this.dirty.ui=!0}if(this.dirty.drawings&&(this.doDrawingsRedraw(),this.dirty.drawings=!1),this.dirty.ui){let n=this.uiCanvas.getContext("2d");if(n){this.doUIRedraw();for(let r of this.afterUIDraw)r(n,this.view,this.drawParams.transformer)}this.dirty.ui=!1}this.priceTransition.isAnimating(performance.now())&&(this.dirty.ui=!0),this.rafId=requestAnimationFrame(t)}};this.rafId=requestAnimationFrame(t)}markDirty(t){this.dirty[t]=!0}markAllDirty(){this.dirty.base=!0,this.dirty.drawings=!0,this.dirty.ui=!0}setDrawParams(t){this.drawParams=t}setView(t){this.view=t}getView(){return this.view}doBaseRedraw(){let t=this.drawParams;if(!t||!this.view)return;let n=this.baseCanvas,r=this.view,o=Vn(),a=n.width/o,i=n.height/o,s=a-t.priceScaleWidth,l=t.layouts,c=l.main,u=c?c.h:i-(t.hideTimeScale?0:yn),d=0,m=0,f=s,h=u;if(t.heatmapBitmap&&t.bitmapOffsets&&(d=t.bitmapOffsets.x,m=t.bitmapOffsets.y,f=t.bitmapOffsets.w,h=t.bitmapOffsets.h),Wp(n,t.panes,t.layouts,t.indicators,t.trades,t.priceHistory,[],r,t.footprintBars,t.heatmapBitmap,d,m,f,h,t.barNs,t.chartSettings,t.horizon,t.candleCache,t.openBar,t.ohlcvBars,t.transformer,t.isPluginChartType,t.sessionMapper,t.dataLevel,t.hidePriceScale,t.hideTimeScale,t.symbolInfo,t.priceScaleWidth),t.isPluginChartType&&t.chartPlugin){let p=n.getContext("2d"),g=l.main;p&&g&&(p.save(),p.beginPath(),p.rect(g.x,g.y,g.w,g.h),p.clip(),p.translate(g.x,g.y),t.chartPlugin.draw({ctx:p,rect:{...g,x:0,y:0},view:r,transformer:t.transformer,footprintBars:t.footprintBars,trades:t.trades,priceHistory:t.priceHistory,barNs:t.barNs,chartSettings:t.chartSettings,computed:t.pluginComputed??null}),p.restore())}this.drawAttribution(n,l,i,t.hideTimeScale)}drawAttribution(t,n,r,o){let a=oW(()=>this.markDirty("base"));if(!a)return;let i=t.getContext("2d");if(!i)return;let s=Vn(),l=n.main,c=l?l.x:0,u=l?l.y+l.h:r-(o?0:yn),d=10,m=170,f=m/nW,h=c+d,p=u-d-f;i.save(),i.setTransform(s,0,0,s,0,0),i.globalAlpha=.55,i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high",i.drawImage(a,h,p,m,f),i.restore()}doDrawingsRedraw(){let t=this.drawParams;!t||!this.view||Dk(this.drawingsCanvas,t.drawings,this.view,t.panes,t.selectedDrawingId,t.hoveredDrawingId,t.hotAnchor,t.draft,t.crosshair,t.editingTextId,t.isHoldingCtrl,t.isHoldingShift,t.barNs,t.chartSettings,t.footprintBars,t.priceHistory,t.transformer,t.hidePriceScale,t.hideTimeScale,t.priceScaleWidth,t.symbolInfo,t.horizon)}doUIRedraw(){let t=this.drawParams;if(!t||!this.view)return;let n=XC(this.uiCanvas,t.priceHistory,t.trades,this.view,t.crosshair,t.showTooltip,t.selectedTrade,t.panes,t.layouts,t.indicators,t.hoveredDividerIdx,t.hoveringLegend,t.barNs,t.chartSettings,t.horizon,t.candleCache,t.ohlcvBars,t.openBar,t.tradeLines,t.tradeLineInteraction,t.tradeLineInteraction.hoveredLineId,t.tradeLineInteraction.draggingLineId,t.activeTool,t.draggingAnchor,t.isHoldingCtrl,t.isHoldingShift,t.footprintBars,t.drawings,t.draft,t.transformer,t.showShiftInfo,t.shiftInfoAnchor,t.shiftInfoAnchor2,t.dataLevel,t.accountSnapshot,t.symbolInfo,t.hidePriceScale,t.hideTimeScale,t.priceScaleWidth,this.priceTransition,t.syncCrosshair);this.eventBus.emit("hitmap:update",{id:this.chartId,hitMap:n})}addDrawHook(t,n){let r=t==="before-base"?this.beforeBaseDraw:t==="after-base"?this.afterBaseDraw:this.afterUIDraw;return r.add(n),()=>r.delete(n)}handleResize(t){let n=Vn(),r=this.baseCanvas.parentElement,o=t?.devicePixelContentBoxSize?.[0],a,i;if(o)a=o.inlineSize,i=o.blockSize;else{let s=r.getBoundingClientRect();a=Math.round(s.width*n),i=Math.round(s.height*n)}if(!(a<=0||i<=0)){for(let s of[this.baseCanvas,this.drawingsCanvas,this.uiCanvas])(s.width!==a||s.height!==i)&&(s.width=a,s.height=i);this.view&&(this.eventBus.emit("view:change",this.view),this.eventBus.emit("plugin:redraw-indicators",void 0)),this.flushSync()}}flushSync(){if(!this.drawParams||!this.view){this.markAllDirty();return}this.doBaseRedraw(),this.doDrawingsRedraw(),this.doUIRedraw(),this.dirty.base=!1,this.dirty.drawings=!1,this.dirty.ui=!1}toDataURL(t="image/png"){return this.baseCanvas.toDataURL(t)}captureComposite(){let t=document.createElement("canvas");t.width=this.baseCanvas.width,t.height=this.baseCanvas.height;let n=t.getContext("2d");if(!n)throw new Error("[RenderEngine] Could not get a 2D context for the snapshot.");return n.drawImage(this.baseCanvas,0,0),n.drawImage(this.drawingsCanvas,0,0),n.drawImage(this.uiCanvas,0,0),t}destroy(){this.destroyed=!0,this.resizeObserver.disconnect(),cancelAnimationFrame(this.rafId)}};function nP(e){let{renderEngineRef:t,baseCanvasRef:n,drawingsCanvasRef:r,uiCanvasRef:o,eventBus:a,chartId:i,viewRef:s,priceScaleWidthRef:l,tradesRef:c,getLayouts:u,heatmapBitmapRef:d,cacheBoundsRef:m,heatmapBitmapOffsetsRef:f,panesRef:h,indicatorsRef:p,priceHistoryRef:g,footprintBarsRef:y,activeTimeframeRef:v,chartSettingsRef:b,horizonRef:S,candleCacheRef:C,openBarRef:w,dataLevelRef:k,ohlcvBarsRef:M,previewBarsRef:I,transformer:x}=e;return iW(()=>{let R=n.current,P=r.current,D=o.current;if(!R||!P||!D)return;let N=new om(R,P,D,a,i);return t.current=N,a.emit("render-engine:ready",{engine:t.current}),s.current&&N.setView(s.current),()=>N.destroy()},[]),{doBaseRedraw:aW(()=>{if(!n.current||!s.current||c.current.length===0)return;let R=n.current,P=s.current,D=R.width-l.current,N=u(),O=N.main,A=O?O.h:R.height-(e.hideTimeScale?0:yn),B=0,E=0,L=D,z=A;if(d.current&&m.current){let Y=m.current,G=Number(P.tMax-P.tMin),H=P.pMax-P.pMin;G>0&&(B=Number(Y.tMin-P.tMin)/G*D,L=Number(Y.tMax-Y.tMin)/G*D),H>0&&(E=(P.pMax-Y.pMax)/H*A,z=(Y.pMax-Y.pMin)/H*A)}f.current={x:B,y:E,h:z,w:L},Wp(R,h.current,N,p.current,c.current,g.current,[],P,y.current,d.current,B,E,L,z,v.current.barNs,b.current,S.current,C.current,w.current,k.current==="ohlcv"?M.current.display:I.current,x,void 0,void 0,void 0,void 0,void 0,void 0,l.current)},[])}}import{useCallback as am}from"react";function rP(e){let{viewRef:t,transformer:n,isYAxisAutoRef:r,setChartSettings:o,priceHistoryRef:a,tradesRef:i,previewBarsRef:s,ohlcvBarsRef:l,openBarRef:c,chartSettingsRef:u,horizonRef:d,dataLevelRef:m,activeTimeframeRef:f,scheduleResample:h,pushDrawParams:p,publishTimeRangeSync:g,renderEngineRef:y,updateSettingsBarPos:v,selectedDrawingIdRef:b,panesRef:S,indicatorsRef:C,setPanes:w}=e,k=am(()=>{if(!t.current)return;let{tMin:R,tMax:P}=t.current,D=S.current,N=!1,O=D.map(A=>{if(A.isMain||!A.yAxisAuto)return A;let B=C.current.find(L=>L.paneId===A.id);if(!B?.getAutoYBounds)return A;let E=B.getAutoYBounds(R,P,d.current);return E?(N=!0,{...A,yMin:E.min,yMax:E.max}):A});N&&(S.current=O)},[]),M=am(()=>{if(!t.current)return;let{tMin:R,tMax:P}=t.current;w(D=>{let N=!1,O=D.map(A=>{if(A.isMain||!A.yAxisAuto)return A;let B=C.current.find(L=>L.paneId===A.id);if(!B?.getAutoYBounds)return A;let E=B.getAutoYBounds(R,P,d.current);return E?(N=!0,{...A,yMin:E.min,yMax:E.max}):A});return N&&(S.current=O),N?O:D})},[]),I=am((R=!1)=>{let P=t.current;P&&(R&&(r.current=!0,o(D=>({...D,autoScale:r.current}))),Ar(P,a.current,i.current,[...s.current,...l.current.display],c.current,u.current,d.current,m.current),M(),h(),p(),y.current?.markDirty("base"),y.current?.markDirty("drawings"),v(b.current),y.current?.markDirty("ui"))},[]),x=am(()=>{let R=t.current;if(!R)return;let P=n.getOrdinal();if(P){let D=P.length,N=Math.min(D,200);R.tMin=n.indexToTs(D-N),R.tMax=n.indexToTs(D-1+Math.min(N*.1,10))}else{let D=f.current.barNs*270n,N=20n*f.current.barNs,O=d.current;if(!O)return;R.tMin=O-D+N,R.tMax=O+N}h(),p(),g(),y.current?.markDirty("base"),y.current?.markDirty("drawings"),v(b.current),y.current?.markDirty("ui")},[]),T=am(()=>{x(),I(!0)},[]);return{resetYAxis:I,resetXAxis:x,resetView:T,autofitPanesSilent:k,autofitIndicatorPanes:M}}var im={symbol:!1,interval:!1,crosshair:!0,time:!1,dateRange:!1};import{Fragment as uW,jsx as en,jsxs as xa}from"react/jsx-runtime";var cW=lW(function({hideToolbar:t,hideDrawingToolbar:n,hideBottomToolbar:r,hidePriceScale:o,hideTimeScale:a,hideStatusBar:i,hideLegend:s,hideSettingsDialog:l,onOpenSettings:c,onHorizonUpdate:u,onHorizonTick:d,domPanelRef:m,managed:f=!1,onRequestMore:h,onDataBoundsChange:p,onCreateOrder:g,tradeLines:y,onGhostMove:v,linesRef:b,draggingLineIdRef:S,redrawTrading:C,eventBus:w,onHandleReady:k,transformer:M,showDataStatusInBottomRightCorner:I,initialState:x,id:T,symbol:R,features:P,account:D,drawingStore:N,model:O,syncInLayout:A,setStatePatch:B},E){let L=Ke(null),z=Ke(null),Y=Ke(null),G=Ke(null),H=Ke(null),W=Ke(null),U=Ke(null),V=Ke(null),K=Ke(null),Z=Ke(null),de=Ke(null),ze=Ke(null),xe=Ke(null),Ae=Ke(null),Oe=Ke(()=>{}),ke=Ke(null),Q=Ke(new Xi).current,Pe=()=>({seekHorizon:(te,Me)=>L.current?.(te,Me),handleTimeframeChange:(te,Me)=>z.current?.(te,Me),handleAddIndicator:te=>Y.current?.(te),handleToggleIndicator:te=>G.current?.(te),handleRemoveIndicator:te=>H.current?.(te),setActiveTool:te=>W.current?.(te),getIndicators:()=>U.current?.()??[],getActiveTimeframe:()=>V.current?.(),getHorizon:()=>K.current?.()??0n,getVisibleRange:()=>Ze.current?{tMin:Ze.current.tMin,tMax:Ze.current.tMax}:null,getDataBounds:()=>({start:Yt.current,end:ut.current}),applySettings:te=>Z.current?.(te),getChartSettings:()=>de.current?.()??Ye,getActiveTool:()=>gl.current,scheduleResample:()=>ze.current?.(),scheduleBaseRedraw:()=>{Ue(),ye.current?.markDirty("base")},scheduleUIRedraw:()=>{Ue(),ye.current?.markDirty("ui")},redrawDrawings:()=>{Ue(),ye.current?.markDirty("drawings")},drawTradeLine:te=>xe.current?.(te),activatePluginIndicator:(te,Me)=>Ae.current?.(te,Me),replacePluginIndicator:te=>ke.current?.(te)});sW(E,Pe,[]),tr(()=>{k?.(Pe())},[]);let _=Ke(null),ie=Ke(h);tr(()=>{ie.current=h},[h]);let se=Ke(null),Se=Ke(null),Re=Ke(null),ye=Ke(null),$e=Ke(!1);function Ue(){Q.setScaleMode(ot.current.priceScaleMode==="normal"?"linear":ot.current.priceScaleMode),Ze.current&&(tt.current=Vp(Ze.current,Ie.current??void 0,ot.current,o,se.current?.getContext("2d")));let te=vy(ot.current.chartType,ot.current,rt.current==="ohlcv"?rn.current.display:ln.current,Vt.current,yt.current,Pn.current.barNs);Q.setOrdinal(te?.columnTs??null);let Me=te!==null;if(Me&&!$e.current&&te&&Ze.current){let Qe=te.columnTs.length,St=Math.min(Qe,200);Ze.current.tMin=Q.indexToTs(Qe-St),Ze.current.tMax=Q.indexToTs(Qe-1+Math.min(St*.1,10)),Q.update(Ze.current)}if($e.current=Me,te&&Tt.current&&Ze.current){let Qe=ak(te,Q);if(Qe){let St=Qe.max-Qe.min||Math.abs(Qe.max)*.01||1,Et=ot.current.scaleMarginTop??.1,Rt=ot.current.scaleMarginBottom??.1;Ze.current.pMin=Qe.min-St*Rt,Ze.current.pMax=Qe.max+St*Et,Q.update(Ze.current)}}ye.current?.setDrawParams({panes:An.current,layouts:Ee.current,indicators:ue.current,trades:yt.current,priceHistory:Bt.current,footprintBars:or.current,heatmapBitmap:on.current,bitmapOffsets:Gn.current,barNs:Pn.current.barNs,chartSettings:ot.current,horizon:pt.current,candleCache:Vt.current,openBar:Rn.current,ohlcvBars:rt.current==="ohlcv"?rn.current.display:ln.current,crosshair:Hg.current,drawings:ca.current,draft:Ex.current,tradeLines:Zu.current,hoveredDividerIdx:nt.current,hoveringLegend:vt.current,showTooltip:Kx.current,selectedTrade:Nx.current,activeTool:gl.current,draggingAnchor:Fx.current,isHoldingCtrl:Te.current,isHoldingShift:Le.current,showShiftInfo:J.current,shiftInfoAnchor:dt.current,shiftInfoAnchor2:Pt.current,tradeLineInteraction:Kg.current,selectedDrawingId:X.current,hoveredDrawingId:Ox.current,hotAnchor:_x.current,editingTextId:Xm.current,transformer:Q,sessionMapper:qe.current,isPluginChartType:Xu.current.has(ot.current.chartType),chartPlugin:Xu.current.get(ot.current.chartType),pluginComputed:Ax.current.get(ot.current.chartType),dataLevel:rt.current,accountSnapshot:Re.current,symbolInfo:Ie.current,priceScaleWidth:tt.current,hidePriceScale:o,hideTimeScale:a,syncCrosshair:je.current}),xt()}let je=Ke(null),ht=Ke(null);function Be(){ht.current&&(ht.current=null,w.emit("layout:crosshair",null))}function xt(){if(!kt.current.crosshair){Be();return}let te=Hg.current,Me=Se.current;if(!te||!Me||!Ze.current){Be();return}let Qe=Ee.current,St=An.current.find(Za=>{let Ta=Qe[Za.id];return Ta&&te.y>=Ta.y&&te.y<Ta.y+Ta.h}),Et=St?Qe[St.id]:null;if(!St||!Et||Et.h<2){Be();return}let Rt=Me.width/Vn()-tt.current;if(Rt<=0)return;if(te.x<0||te.x>=Rt){Be();return}let ar=te.y-Et.y,Cr={id:T,ts:Q.xToTs(te.x,Rt),price:St.isMain?Q.yToPrice(ar,Et.h):0,paneId:St.id,yFrac:ar/Et.h,symbol:la.current??null},Kn=ht.current;Kn&&Kn.ts===Cr.ts&&Kn.price===Cr.price&&Kn.paneId===Cr.paneId&&Kn.yFrac===Cr.yFrac&&Kn.symbol===Cr.symbol||(ht.current=Cr,w.emit("layout:crosshair",Cr))}function fn(te){let Me=te&&kt.current.crosshair?te:null;if(!Me&&!je.current||(je.current=Me,Ue(),ye.current?.markDirty("ui"),!Me||!Ze.current))return;let Qe=performance.now();if(Qe-In.current<=33)return;In.current=Qe;let St=Se.current;if(!St)return;let Et=St.width/Vn()-tt.current;if(Et<=0)return;let Rt=Q.tsToX(Me.ts,Et);!Number.isFinite(Rt)||Rt<0||Rt>=Et||w.emit("status:compute",{cellId:T,x:Rt,priceHistory:Bt.current,trades:yt.current,bounds:Ze.current,chartW:Et,barNs:Pn.current.barNs,candleCache:Vt.current,bars:rn.current.display,openBar:Rn.current,horizon:pt.current,dataLevel:rt.current,transformer:Q})}let In=Ke(0),kt=Ke(A??im);tr(()=>{kt.current=A??im,kt.current.crosshair||(Be(),je.current&&(je.current=null,$.current?.(),ye.current?.markDirty("ui")))},[A]);let it=Ke(!1),ft=Ke(null);function oe(){if(it.current)return;let te=kt.current;if(!te.time&&!te.dateRange)return;let Me=Ze.current;if(!Me)return;let Qe=ft.current;Qe&&Qe.tMin===Me.tMin&&Qe.tMax===Me.tMax||(ft.current={tMin:Me.tMin,tMax:Me.tMax},w.emit("layout:time-range",{id:T,tMin:Me.tMin,tMax:Me.tMax}))}function pe({tMin:te,tMax:Me}){let Qe=Ze.current;if(!Qe)return;let St=kt.current,Et={tMin:te,tMax:Me};if(!St.dateRange){let ar=Qe.tMax-Qe.tMin;if(ar<=0n)return;Et.tMin=Me-ar,Et.tMax=Me}let Rt={...Qe,...Et};if(sS(Rt),!(Rt.tMin===Qe.tMin&&Rt.tMax===Qe.tMax)){Qe.tMin=Rt.tMin,Qe.tMax=Rt.tMax,ft.current={tMin:Qe.tMin,tMax:Qe.tMax},it.current=!0;try{iS()}finally{it.current=!1}}}let fe=Ke(null),Ie=Ke(null),Ve=Ke(null),qe=Ke(Ov()),[Fe,De]=Bo(!1),we=Ke(!1);tr(()=>{we.current=Fe},[Fe]);let[_e,Ne]=Bo(""),dt=Ke(null),Pt=Ke(null),J=Ke(!1),Te=Ke(!1),Le=Ke(!1),ot=Ke(Ye),tt=Ke(64),mt=Ke(0),[qt,Dt]=Bo(null),rr=Ke(null);tr(()=>{if(!qt)return;let te=Me=>{rr.current&&!rr.current.contains(Me.target)&&Dt(null)};return window.addEventListener("mousedown",te),()=>window.removeEventListener("mousedown",te)},[qt]);let[wn,er]=Bo(x.timeframe),Pn=Ke(x.timeframe);tr(()=>{Pn.current=wn,O.setTimeframe(wn),mn.current.length>0&&(Vt.current=null,Rn.current=null,Nr.current=0n,Hn.current=0,Co(),Ue(),ye.current?.markDirty("base"),ye.current?.markDirty("drawings"),Ui(X.current))},[wn]);let[cr,Mn]=Bo([{id:"main",isMain:!0,heightRatio:3,symbol:R,tf:x.timeframe.label,exchange:void 0,yMin:0,yMax:0,yAxisAuto:!0,collapsed:!1}]),An=Ke(cr);tr(()=>{An.current=cr},[cr]);let[F,re]=Bo([]),ue=Ke(F);tr(()=>{ue.current=F},[F]),tr(()=>{O.setPlugins(F.map(te=>({id:te.id.replace(/:(\d+)$/,""),instanceId:te.id,config:{settings:te.settings??{},visible:te.visible,layout:te.layout,paneId:te.paneId}})))},[F,O]);let ce=Ke(-1),q=Ke(null),he=Ke(null),[me,We]=Bo(null),nt=Ke(-1),gt=Ke(!1),vt=Ke(!1),pt=Ke(0n),Ze=Ke(null),Tt=Ke(!0),Gt=Ke(!1),Xt=Ke("none"),X=Ke(null),$=Ke(()=>{}),ge=Ke(()=>{}),Ce=Ke(()=>{}),ct=Ke(()=>{}),bt=Ke(()=>{}),le=Ke(()=>{}),{layoutsCacheRef:Ee,legendElemsRef:wt,panePixelLayouts:Lt,recomputeLayouts:Ln,getLayouts:Ut,syncPixelLayouts:Mt,applyLayoutsToDom:zt}=$R({baseCanvasRef:se,panesRef:An,chartSettingsRef:ot,priceScaleWidthRef:tt,hideTimeScale:a}),At=FR({eventBus:w,activeTimeframeRef:Pn,horizonRef:pt,chartSettingsRef:ot,sessionMapperRef:qe,resolvedSessionRef:fe,resolvedSymbolInfoRef:Ie,viewRef:Ze,priceScaleWidthRef:tt,panesRef:An,indicatorsRef:ue,transformer:Q,renderEngineRef:ye,isYAxisAutoRef:Tt,isDragging:Gt,dragMode:Xt,layoutsCacheRef:Ee,baseCanvasRef:se,selectedDrawingIdRef:X,pushDrawParamsRef:$,autofitIndicatorPanesRef:ge,updateSettingsBarPosRef:Ce,resetViewRef:ct,syncPixelLayoutsRef:bt,doBaseRedrawRef:le,setIndicators:re,setPanes:Mn,getPanel:()=>null,onDataBoundsChange:p,onHorizonUpdate:u,cellSymbol:R,cellId:T,managed:f,externalDomPanelRef:m,hidePriceScale:o,hideTimeScale:a,onDataLevelChangeRef:Oe}),{compactBufRef:mn,tradesRef:yt,priceHistoryRef:Bt,allPriceHistoryRef:gr,footprintBarsRef:or,ohlcvBarsRef:rn,previewBarsRef:ln,openBarRef:Rn,openBarTsRef:Nr,openBarTradeCountRef:Hn,phCursorRef:Wr,dataLevelRef:rt,datasetStartRef:Yt,datasetEndRef:ut,prevSessionStatusRef:ur,candleCacheRef:Vt,heatmapBitmapRef:on,heatmapBitmapOffsetsRef:Gn,cacheBoundsRef:Zt,liveBookRef:an,horizonScrollAnimRef:Nt,_internalDomPanelRef:Bn,seekHorizon:Er,scheduleResample:Mr,runIndicatorWorker:Yn,getTradesUpToHorizon:vr,requestFootprintRebuild:Co,syncOhlcvOpenBar:Lr,rebuildCandleCache:Fo,rebuildContrastBitmap:Is,updatePriceHistoryToRawIdx:Ic,findPriceHistoryIdx:zg,loadData:NA}=At;tr(()=>(w.emit("data:open-bar-provider",{cellId:T,get:()=>Rn.current}),()=>{w.emit("data:open-bar-provider",{cellId:T,get:null})}),[w,T]);let EA=()=>m?.current??Bn.current;$.current=Ue;let Mc=Ke(null),{doBaseRedraw:OA}=nP({renderEngineRef:ye,baseCanvasRef:se,drawingsCanvasRef:Mc,uiCanvasRef:Se,eventBus:w,chartId:T,viewRef:Ze,priceScaleWidthRef:tt,tradesRef:yt,getLayouts:Ut,heatmapBitmapRef:on,cacheBoundsRef:Zt,heatmapBitmapOffsetsRef:Gn,panesRef:An,indicatorsRef:ue,priceHistoryRef:Bt,footprintBarsRef:or,activeTimeframeRef:Pn,chartSettingsRef:ot,horizonRef:pt,candleCacheRef:Vt,openBarRef:Rn,dataLevelRef:rt,ohlcvBarsRef:rn,previewBarsRef:ln,transformer:Q,hideTimeScale:a}),{pluginChartTypesRef:Xu,activeChartTypeBottomBarIds:Dx,setPluginChartTypes:_A,pluginChartTypeComputedRef:Ax,activatePluginIndicator:FA,replacePluginIndicator:zA,buildChartTypeActiveCtx:Bx}=eP({renderEngineRef:ye,uiCanvasRef:Se,eventBus:w,indicatorsRef:ue,panesRef:An,horizonRef:pt,activeTimeframeRef:Pn,dataLevelRef:rt,setPanes:Mn,setIndicators:re,runIndicatorWorker:Yn,getTradesUpToHorizon:vr,pushDrawParams:Ue}),Hg=Ke(null),HA=Ke({x:0,y:0}),VA=Ke(!1),Nx=Ke(null),Gm=Ke(null),Ym=Ke(null),Ms=Ke(null),la=Ke(R),Km=Ke(!1);la.current!==R&&(Km.current=!1),la.current=R;let Vg=Ke(!1),Wg=Ke(null);Wg.current||(Wg.current={get current(){return N.forSymbol(la.current)},set current(te){Vg.current=!0,N.setForSymbol(la.current,te),Vg.current=!1}});let ca=Wg.current;tr(()=>{let te=()=>{Vg.current||($.current?.(),ye.current?.markDirty("drawings"))};return te(),N.subscribe(R,te)},[N,R]);let Ex=Ke(null),[$m,qg]=Bo(null),[Lc,Ug]=Bo(null),Xm=Ke(null);tr(()=>{Xm.current=Lc,Ue(),ye.current?.markDirty("drawings")},[Lc]);let Ox=Ke(null),_x=Ke(null),Fx=Ke(null),WA=Ke(null),qA=Ke(null),UA=Ke(null),jA=Ke(!0),Zu=Ke([]),zx=Ke({lines:[],pricePills:[],ghostPills:[]}),Zm=Ke([]),Rc=Ke([]),hl=Xv(()=>{Zu.current=[...Rc.current,...Zm.current],Ue(),ye.current?.markDirty("ui")},[]),GA=Xv(te=>Zu.current.find(Me=>Me.id===te),[]);tr(()=>{y!==void 0&&(Rc.current=y,hl())},[y,hl]),tr(()=>w.on("trading:preview",({lines:te,symbol:Me})=>{Me&&Me!==la.current||(Zm.current=te,hl())}),[w,hl]);let[Qm,Jm]=Bo(Vo),gl=Ke(Vo);tr(()=>{B("activeTool",Qm)},[Qm]);let[Mi,jg]=Bo(null);tr(()=>{B("selectedDrawingId",Mi)},[Mi]);let[Gg,Yg]=Bo(!1);tr(()=>{Gg&&Yg(!1)},[Gg]);let[YA,Pc]=Bo(null),[Hx,Vx]=Bo(null),Ui=Xv(te=>{if(!te){Pc(null);return}let Me=ca.current.find(Rt=>Rt.id===te),Qe=Mc.current,St=Ze.current;if(!Me||!Qe||!St){Pc(null);return}let Et=Ak(Me,St,An.current,Qe.width,Qe.height,Q,a,tt.current);Pc(Rt=>Rt&&Et&&Rt.x===Et.x&&Rt.y===Et.y?Rt:Et)},[]);tr(()=>{gl.current=Qm},[Qm]),tr(()=>{X.current=Mi,Ui(Mi)},[Mi]);let[Li,Wx]=Bo("loading"),[qx,Ux]=Bo(null);tr(()=>w.on("data:status",({status:Me,error:Qe,symbol:St})=>{St!==void 0&&St!==la.current||(Me==="ready"&&St!==void 0&&(Km.current=!0),!(Me==="loading"&&St!==void 0&&Km.current)&&(Wx(Me),Qe&&Ux(Qe)))}),[]),tr(()=>[w.on("data:bounds",({start:Me,end:Qe,symbol:St})=>{St!==void 0&&St!==la.current||(Yt.current=Me,ut.current=Qe,p?.(Me,Qe))})].forEach(Me=>Me()),[]);let{chartSettings:ep,setChartSettings:Dc}=QR({chartSettingsRef:ot,isYAxisAutoRef:Tt,viewRef:Ze,priceHistoryRef:Bt,tradesRef:yt,dataLevelRef:rt,ohlcvBarsRef:rn,previewBarsRef:ln,openBarRef:Rn,horizonRef:pt,compactBufRef:mn,selectedDrawingIdRef:X,renderEngineRef:ye,scheduleResample:Mr,rebuildContrastBitmap:Is,requestFootprintRebuild:Co,pushDrawParams:Ue,updateSettingsBarPos:Ui,hidePriceScale:o,hideTimeScale:a,modelSettings:O.settings});tr(()=>{O.setSettings(ep)},[ep,O]);let{resetYAxis:jx,resetXAxis:Gx,resetView:tp,autofitPanesSilent:Yx,autofitIndicatorPanes:np}=rP({viewRef:Ze,transformer:Q,isYAxisAutoRef:Tt,setChartSettings:Dc,priceHistoryRef:Bt,tradesRef:yt,previewBarsRef:ln,ohlcvBarsRef:rn,openBarRef:Rn,chartSettingsRef:ot,horizonRef:pt,dataLevelRef:rt,activeTimeframeRef:Pn,scheduleResample:Mr,pushDrawParams:Ue,publishTimeRangeSync:oe,renderEngineRef:ye,updateSettingsBarPos:Ui,selectedDrawingIdRef:X,panesRef:An,indicatorsRef:ue,setPanes:Mn});ct.current=tp,ge.current=np;let Kx=Ke(!1),KA=Ke(null),$x=Ke(0),Xx=Ke(0),Zx=Ke(0),Qx=dR({tradeLines:Zu.current,resolveLine:GA,onLinesChange:te=>{Rc.current=te.filter(Me=>!Me.preview),hl()},onSyncLines:te=>{Rc.current=te.filter(Me=>!Me.preview),hl()},onLineDelete:te=>{Rc.current=Rc.current.filter(Me=>Me.id!==te.id),Zm.current=Zm.current.filter(Me=>Me.id!==te.id),hl()},hitMapRef:zx,chartWRef:$x,chartHRef:Xx,chartOYRef:Zx,getLayouts:Ut,boundsRef:Ze,chartSettingsRef:ot,redraw:()=>{C(),Ue(),ye.current?.markDirty("ui")},symbolInfoRef:Ie,onGhostMove:v,linesRef:b,draggingLineIdRef:S,transformer:Q}),Kg=Ke(Qx);Kg.current=Qx,tr(()=>{Li==="ready"&&(Ue(),ye.current?.markDirty("base"),ye.current?.markDirty("drawings"),Ui(X.current),Mr())},[Li]),tr(()=>{Mt(),Ue(),ye.current?.markAllDirty()},[cr,Li]),tr(()=>{Ue(),ye.current?.markDirty("base"),ye.current?.markDirty("ui")},[F]);let{handleUpdateDrawing:$A,handleDeleteDrawing:Jx,handleDeleteDrawings:XA,handleDuplicateDrawing:ZA,handleToggleIndicator:eS,handleRemoveIndicator:rp,handleOpenIndicatorSettings:QA,handleRemoveIndicators:JA,handleMoveUp:eB,handleMoveDown:tB,handleRemovePane:nB,handleExpand:rB,handleCollapse:oB,handleMaximize:aB,handleEnter:iB,handleLeave:sB,handleTimeframeChange:tS,handleAddIndicator:nS,handleAddTradeLine:lB}=GR({drawingsRef:ca,drawingsCanvasRef:Mc,viewRef:Ze,selectedDrawingIdRef:X,indicatorsRef:ue,panesRef:An,ohlcvBarsRef:rn,sessionMapperRef:qe,activeTimeframeRef:Pn,horizonRef:pt,phCursorRef:Wr,candleCacheRef:Vt,tradesRef:yt,openBarRef:Rn,openBarTsRef:Nr,openBarTradeCountRef:Hn,compactBufRef:mn,isYAxisAutoRef:Tt,priceHistoryRef:Bt,dataLevelRef:rt,previewBarsRef:ln,chartSettingsRef:ot,tradeLinesRef:Zu,hoveringLegend:vt,renderEngineRef:ye,transformer:Q,maximizedPaneId:me,setIndicators:re,setPanes:Mn,setSelectedDrawingId:jg,setSettingsBarPos:Pc,setIndicatorSettingsId:Vx,setActiveTimeframe:er,setMaximizedPaneId:We,pushDrawParams:Ue,updateSettingsBarPos:Ui,recomputeLayouts:Ln,scheduleResample:Mr,runIndicatorWorker:Yn,getTradesUpToHorizon:vr,getLayouts:Ut,rebuildCandleCache:Fo,syncOhlcvOpenBar:Lr,updatePriceHistoryToRawIdx:Ic,findPriceHistoryIdx:zg,resetXAxis:Gx,resetYAxis:jx,autofitIndicatorPanes:np,hideTimeScale:a,priceScaleWidthRef:tt});YR({eventBus:w,chartId:T,account:D,pluginChartTypesRef:Xu,activeChartTypeBottomBarIds:Dx,hitMapRef:zx,indicatorsRef:ue,panesRef:An,renderEngineRef:ye,horizonRef:pt,activeTimeframeRef:Pn,chartSettingsRef:ot,pluginChartTypeComputedRef:Ax,dataLevelRef:rt,previewBarsRef:ln,candleCacheRef:Vt,ohlcvBarsRef:rn,openBarRef:Rn,viewRef:Ze,accountSnapRef:Re,setActiveTool:Jm,setActiveTimeframe:er,handleTimeframeChange:tS,setPanes:Mn,setIndicators:re,setPluginChartTypes:_A,setChartSettings:Dc,resetView:tp,buildChartTypeActiveCtx:Bx,pushDrawParams:Ue,runIndicatorWorker:Yn,getTradesUpToHorizon:vr,syncPixelLayouts:Mt,autofitIndicatorPanes:np,handleAddIndicator:nS,handleRemoveIndicator:rp,onSymbolChange:te=>{te!==la.current&&(Km.current=!1),R=te,la.current=te,$.current?.(),ye.current?.markDirty("drawings")},syncInLayoutRef:kt,applyCrosshairSync:fn,applyTimeRangeSync:pe}),jR({status:Li,cellId:T,baseCanvasRef:se,uiCanvasRef:Se,chartAreaRef:Gm,containerRef:_,viewRef:Ze,priceScaleWidthRef:tt,symbolInfoRef:Ie,layoutsCacheRef:Ee,isYAxisAutoRef:Tt,drawingsRef:ca,draftRef:Ex,selectedDrawingIdRef:X,hoveredDrawingIdRef:Ox,hotAnchorRef:_x,draggingAnchorRef:Fx,dragStartRef:WA,dragPrevDataRef:qA,dragPrevPixelRef:UA,fvpLiveRecalcRef:jA,activeCtxRef:Ve,panesRef:An,indicatorsRef:ue,draggingDividerRef:ce,dragPaneIdRef:q,hoveredDividerIdxRef:nt,hoveredDividerIdxRefLocked:gt,hoveredPaneIdRef:he,activeToolRef:gl,chartSettingsRef:ot,activeTimeframeRef:Pn,sessionMapperRef:qe,resolvedSessionRef:fe,renderEngineRef:ye,pluginChartTypesRef:Xu,activeChartTypeBottomBarIds:Dx,crosshairRef:Hg,isDragging:Gt,dragMode:Xt,isHoldingCtrlRef:Te,isHoldingShiftRef:Le,lastMouse:HA,hasDragged:VA,longPressTimer:KA,showTooltipRef:Kx,shiftAnchorRef:dt,shiftAnchor2Ref:Pt,showShiftInfo:J,lastStatusLineUpdateRef:mt,horizonRef:pt,tradesRef:yt,priceHistoryRef:Bt,allPriceHistoryRef:gr,ohlcvBarsRef:rn,previewBarsRef:ln,dataLevelRef:rt,openBarRef:Rn,candleCacheRef:Vt,footprintBarsRef:or,datasetStartRef:Yt,datasetEndRef:ut,horizonScrollAnimRef:Nt,liveBookRef:an,tradeLineInteractionRef:Kg,selectedTradeRef:Nx,transformer:Q,eventBus:w,features:P,showTimeframeWindowRef:we,setActiveTool:Jm,setSelectedDrawingId:jg,setSettingsBarPos:Pc,setContextMenu:Dt,setPanes:Mn,setChartSettings:Dc,setEditingTextId:Ug,setOpenSettingsDialog:Yg,setShowTimeframeWindow:De,setTimeframeWindowInput:Ne,setPendingText:qg,pushDrawParams:Ue,publishTimeRangeSync:oe,scheduleResample:Mr,runIndicatorWorker:Yn,getTradesUpToHorizon:vr,updateSettingsBarPos:Ui,handleDeleteDrawing:Jx,autofitPanesSilent:Yx,autofitIndicatorPanes:np,getPanel:EA,getLayouts:Ut,recomputeLayouts:Ln,syncPixelLayouts:Mt,applyLayoutsToDom:zt,buildChartTypeActiveCtx:Bx,hideTimeScale:a}),tr(()=>{if(R)return w.emit("data:pane-resolution",{id:T,symbol:R,barNs:wn.barNs}),()=>{w.emit("data:pane-resolution",{id:T,symbol:R,barNs:0n})}},[w,T,R,wn]),tr(()=>w.on("view:change",()=>{let te=Se.current,Me=Ut();te&&($x.current=te.width-tt.current,Xx.current=Me.main?.h??te.height-(a?0:yn),Zx.current=Me.main?.y??0,Ln(),Mt(),Ue(),ye.current?.markAllDirty())}),[w]),tr(()=>{let te=Gm.current;if(Li!=="ready"||!te)return;let Me=100,Qe=Et=>{let Rt=Ym.current;if(!Rt)return;let ar=Rt.getBoundingClientRect(),Cr=Math.max(ar.left-Et.clientX,0,Et.clientX-ar.right),Kn=Math.max(ar.top-Et.clientY,0,Et.clientY-ar.bottom);Rt.style.opacity=Math.hypot(Cr,Kn)<Me?"1":"0"},St=()=>{Ym.current&&(Ym.current.style.opacity="0")};return te.addEventListener("mousemove",Qe),te.addEventListener("mouseleave",St),()=>{te.removeEventListener("mousemove",Qe),te.removeEventListener("mouseleave",St)}},[Li]),tr(()=>()=>{Ms.current!==null&&cancelAnimationFrame(Ms.current)},[]),L.current=(te,Me)=>Er(te,!0,!0,Me);let rS=(te,Me=!1)=>{let Qe=P?.timeframe?.timeframes??"any";if(Qe!=="any"&&!Qe.includes(te.label)){w?.emit("timeframe:add-failed",{message:"Timeframe not allowed",code:"TIMEFRAME_NOT_ALLOWED",label:te.label});return}tS(te),Me||w?.emit("layout:timeframe",{id:T,tf:te})};z.current=rS,Y.current=nS,G.current=eS,H.current=rp,W.current=te=>{let Me=io.get(gl.current.name);Me?.onDeactivate&&Me.onDeactivate(),Jm(te),gl.current=te;let Qe=io.get(te.name);Qe?.onActivate&&Qe.onActivate(Ve.current)},U.current=()=>ue.current,V.current=()=>Pn.current,K.current=()=>pt.current;let oS=te=>{let Me=Xu.current.get(te);if(!Me)return!1;let Qe=Me.require??"ohlcv",St=rt.current;return!St||Ao(Qe,St)?!1:(w?.emit("plugin:incompatible",{id:te,name:Me.label??Me.name,kind:"chart-type",required:Qe,actual:St}),!0)};Z.current=te=>{if(te.chartType&&oS(te.chartType)){let{chartType:Me,...Qe}=te;te=Qe}Dc(Me=>({...Me,...te}))},Oe.current=()=>{let te=rt.current;if(te){for(let Me of[...ue.current]){let Qe=Me.require??"ohlcv";Ao(Qe,te)||(w?.emit("plugin:incompatible",{id:Me.id,name:Me.name,kind:"indicator",required:Qe,actual:te}),rp(Me.id))}oS(ot.current.chartType)&&Dc(Me=>({...Me,chartType:"candles"}))}},de.current=()=>ot.current,ze.current=Mr,xe.current=lB,Ae.current=FA,ke.current=zA;let aS=null;Li==="error"&&(aS=en(BR,{code:qx?.code??"unknown",message:qx?.message,symbol:Ie.current?.longName??la.current,timeframe:wn?.label,onRetry:()=>{Ux(null),Wx("loading"),NA()}})),Ce.current=Ui,bt.current=Mt,le.current=OA;let iS=()=>{let te=Ze.current;te&&(Tt.current&&Ar(te,Bt.current,yt.current,rt.current==="ohlcv"?rn.current.display:ln.current,Rn.current,ot.current,pt.current,rt.current),Yx(),te.tMin<Yt.current&&w.emit("data:request-backward",{viewMin:te.tMin,symbol:la.current}),Mr(),Ue(),oe(),ye.current?.markDirty("base"),ye.current?.markDirty("drawings"),ye.current?.markDirty("ui"),Ui(X.current))},sS=te=>{let Me=Yt.current+Pn.current.barNs/2n,Qe=ut.current;if(Me===0n||Qe===0n)return;let St=te.tMax-te.tMin,Et=pt.current,Rt=Et>0n&&Et<Qe?Et-Pn.current.barNs*3n/2n:Qe-Pn.current.barNs*3n/2n;te.tMin+St<Me&&(te.tMin=Me-St,te.tMax=Me),te.tMin>Rt&&(te.tMin=Rt,te.tMax=Rt+St)},$g=(te,Me,Qe=220)=>{let St=Ze.current;if(!St)return;Ms.current!==null&&cancelAnimationFrame(Ms.current);let Et=St.tMin,Rt=St.tMax,ar=Number(te-Et),Cr=Number(Me-Rt),Kn=performance.now(),Za=Ta=>{let Ls=Ze.current;if(!Ls){Ms.current=null;return}let Qa=Math.min(1,(Ta-Kn)/Qe),zo=qv(Qa,"easeOut");Ls.tMin=Et+BigInt(Math.round(ar*zo)),Ls.tMax=Rt+BigInt(Math.round(Cr*zo)),iS(),Qa<1?Ms.current=requestAnimationFrame(Za):Ms.current=null};Ms.current=requestAnimationFrame(Za)},lS=te=>{let Me=Ze.current;if(!Me)return;let Qe=Pn.current.barNs,St=Qe>0n?Number(Qe*3n):Number(yp),Et=Qe>0n?Number(Qe*3400n):Number(vp),Rt=Q.getSessionMapper();if(Rt&&Rt.hasSession){let ar=Rt.tsToMarket(Me.tMin),Cr=Rt.tsToMarket(Me.tMax),Kn=Math.max(St,Math.min(Et,Number(Cr-ar)*te));$g(Rt.marketToTs(Cr-BigInt(Math.round(Kn))),Me.tMax)}else{let ar=Math.max(St,Math.min(Et,Number(Me.tMax-Me.tMin)*te));$g(Me.tMax-BigInt(Math.round(ar)),Me.tMax)}},cS=te=>{let Me=Ze.current;if(!Me)return;let Qe=.25,St,Et,Rt=Q.getSessionMapper();if(Rt&&Rt.hasSession){let Cr=Rt.tsToMarket(Me.tMin),Kn=Rt.tsToMarket(Me.tMax),Za=BigInt(Math.round(te*Qe*Number(Kn-Cr)));St=Rt.marketToTs(Cr+Za),Et=Rt.marketToTs(Kn+Za)}else{let Cr=BigInt(Math.round(te*Qe*Number(Me.tMax-Me.tMin)));St=Me.tMin+Cr,Et=Me.tMax+Cr}let ar={...Me,tMin:St,tMax:Et};sS(ar),$g(ar.tMin,ar.tMax)};return xa("div",{className:"depth-root relative w-full h-full flex flex-col bg-background text-foreground overflow-hidden max-h-screen",ref:_,tabIndex:0,children:[aS,Li==="loading"&&en(AR,{symbol:Ie.current?.longName??la.current,timeframe:wn?.label}),en("div",{className:"flex flex-1 min-h-0",children:xa("div",{ref:Gm,className:"relative flex-1 min-h-0",children:[en("canvas",{ref:se,className:"absolute inset-0 w-full h-full block touch-none"}),en("canvas",{ref:Mc,className:"absolute inset-0 w-full h-full block touch-none pointer-events-none"}),en("canvas",{ref:Se,className:"absolute inset-0 w-full h-full block touch-none pointer-events-none"}),Li==="ready"&&xa("div",{ref:Ym,style:{opacity:0},className:"absolute left-1/2 bottom-8 -translate-x-1/2 w-fit px-2 backdrop-blur-sm h-8 rounded-lg flex gap-3 items-center transition-opacity duration-200 pointer-events-none",children:[xa("div",{className:"flex gap-1",children:[xa(Ht,{delayDuration:700,children:[en(Ot,{asChild:!0,children:en(pr,{variant:"ghost",className:"p-1 h-6 pointer-events-auto",onClick:()=>lS(1.25),children:en(Yo,{className:"!w-3.5"})})}),en(_t,{className:"border border-border bg-background",children:"Zoom out"})]}),xa(Ht,{delayDuration:700,children:[en(Ot,{asChild:!0,children:en(pr,{variant:"ghost",className:"p-1 h-6 pointer-events-auto",onClick:()=>lS(.8),children:en(ha,{className:"!w-3.5"})})}),en(_t,{className:"border border-border bg-background",children:"Zoom in"})]})]}),xa("div",{className:"flex gap-1",children:[xa(Ht,{delayDuration:700,children:[en(Ot,{asChild:!0,children:en(pr,{variant:"ghost",className:"p-1 h-6 pointer-events-auto",onClick:()=>cS(-1),children:en(Rl,{className:"!w-3.5"})})}),en(_t,{className:"border border-border bg-background",children:"Pan left"})]}),xa(Ht,{delayDuration:700,children:[en(Ot,{asChild:!0,children:en(pr,{variant:"ghost",className:"p-1 h-6 pointer-events-auto",onClick:()=>cS(1),children:en(Zi,{className:"!w-3.5"})})}),en(_t,{className:"border border-border bg-background",children:"Pan right"})]})]}),en("div",{className:"flex gap-1",children:xa(Ht,{delayDuration:700,children:[en(Ot,{asChild:!0,children:en(pr,{variant:"ghost",className:"p-1 h-6 pointer-events-auto",onClick:()=>tp(),children:en(ga,{className:"!w-3.5"})})}),en(_t,{className:"border border-border bg-background",children:"Reset view"})]})})]}),Mi&&YA&&(()=>{let te=ca.current.find(Me=>Me.id===Mi);return te?en(uW,{children:en(sR,{drawing:te,containerRef:Gm,openDialog:Gg,onUpdate:Me=>$A(Mi,Me),onDelete:()=>Jx(Mi),onDuplicate:()=>ZA(Mi),onClose:()=>{jg(null),Pc(null),X.current=null,Yg(!1),Ue(),ye.current?.markDirty("drawings")},onRequestOrderTicket:w.hasListeners("trading:ticket-requested")?Me=>w.emit("trading:ticket-requested",{drawingId:Me,requestId:pn(8)}):void 0})}):null})(),Li==="ready"&&cr.map((te,Me)=>{let Qe=Lt[te.id];if(!Qe)return null;let St=te.isMain&&!i?en(gR,{cellId:T,chartSettings:ep,chartType:ep.chartType,eventBus:w}):null;return en("div",{ref:Et=>{Et?wt.current.set(te.id,Et):wt.current.delete(te.id)},className:"absolute left-0 pointer-events-none",style:{top:Qe.y,height:Qe.h,right:`${tt.current}px`,visibility:Qe.h<2?"hidden":"visible"},children:xa("div",{className:"flex flex-row items-center justify-between w-full",children:[en("div",{className:"flex flex-row items-center gap-1 flex-1 min-w-0",children:s?St:en(SR,{pane:te,indicators:F,onToggleIndicator:eS,onRemoveIndicator:rp,onOpenSettings:QA,onOpenTfSelect:()=>{Ne(""),De(!0)},eventBus:w,session:fe.current,horizon:pt.current,sessionStatus:ur.current,statusBar:St,symbolInfo:Ie.current})}),en(CR,{pane:te,paneIndex:Me,totalPanes:cr.length,onMoveUp:eB,onMoveDown:tB,onRemovePane:nB,onCollapse:oB,onExpand:rB,onMaximize:aB,isMaximized:me===te.id,isCollapsed:te.collapsed,onEnter:iB,onLeave:sB,eventBus:w})]})},te.id)}),qt&&P.contextMenu&&en(xk,{x:qt.x,y:qt.y,target:qt.target,priceAtClick:(()=>{let te=ro(Ie.current);return Math.round(qt.priceAtClick/te)*te})(),tickSize:ro(Ie.current),currentAsk:(()=>{if(rt.current==="l3"){let te=Xc(Bt.current,pt.current);return te>=0?Bt.current[te].bestAsk:0}else if(rt.current==="ohlcv")return Rn.current?Rn.current.close:0})(),currentBid:(()=>{if(rt.current==="l3"){let te=Xc(Bt.current,pt.current);return te>=0?Bt.current[te].bestBid:0}else if(rt.current==="ohlcv")return Rn.current?Rn.current.close:0})(),drawings:ca.current,indicators:ue.current,chartSettings:ot.current,dataLevel:rt.current,onClose:()=>{Dt(null)},onResetView:tp,onFitYAxis:jx,onResetXAxis:Gx,onRemoveIndicators:JA,onRemoveDrawings:XA,onScreenshot:()=>{let te=se.current,Me=Se.current,Qe=Mc.current;if(!te||!Me||!Qe)return;let St=document.createElement("canvas");St.width=te.width,St.height=te.height;let Et=St.getContext("2d");if(!Et)return;Et.drawImage(te,0,0),Et.drawImage(Qe,0,0),Et.drawImage(Me,0,0);let Rt=document.createElement("a");Rt.download="chart.png",Rt.href=St.toDataURL(),Rt.click(),Dt(null)},onToggleHeatmap:()=>{Dc(te=>({...te,showHeatmap:!te.showHeatmap}))},onOpenSettings:()=>c(),onCreateOrder:g}),Hx&&(()=>{let te=ue.current.find(Me=>Me.id===Hx);return te?en(mR,{indicator:te,redrawDebounceMs:50,onUpdate:Me=>{Object.assign(te.settings,Me);let Qe=te.__paramKeys??new Set,St=te.__onParamsChanged;if(St){let Et={},Rt=!1;for(let ar of Object.keys(Me))Qe.has(ar)&&(Et[ar]=Me[ar],Rt=!0);Rt&&St(Et)}Ue(),ye.current?.markDirty("base")},onClose:()=>Vx(null)}):null})(),I&&en(RR,{eventBus:w,symbol:R,priceScaleWidth:tt.current}),en(LR,{eventBus:w,cellId:T}),$m&&en(oP,{x:$m.x,y:$m.y,fontSize:12,color:"#e0e0e0",initialValue:"",onCommit:te=>{if(te.trim()){let Me={id:pn(),tool:"text",anchor:$m.anchor,text:te.trim(),...Yi("text")};ca.current=[...ca.current,Me],Ue(),ye.current?.markDirty("drawings")}qg(null),Jm(Vo),gl.current=Vo},onCancel:()=>qg(null)}),Lc&&(()=>{let te=ca.current.find(Qa=>Qa.id===Lc);if(!te||te.tool!=="text"||"anchors"in te)return null;let Me=Mc.current,Qe=Vn(),St=Me.width/Qe,Et=Me.height/Qe;if(!Me)return null;let ar=Ut().main,Cr=ar?.h??Et-(a?0:yn),Kn=ar?.y??0,Za=St-tt.current,Ta=Q.tsToX(te.anchor.ts,Za),Ls=Q.priceToY(te.anchor.price,Cr)+Kn;return en(oP,{x:Ta+4,y:Ls-te.fontSize-2,fontSize:te.fontSize,color:te.color,initialValue:te.text,onKeyStroke:Qa=>{ca.current=ca.current.map(zo=>zo.id===Lc?{...zo,text:Qa}:zo)},onCommit:Qa=>{ca.current=ca.current.map(zo=>zo.id===Lc?{...zo,text:Qa.trim()||zo.text}:zo),Ug(null),Xm.current=null},onCancel:()=>{Ug(null),Xm.current=null}})})()]})}),Fe&&en("div",{className:"absolute left-0 top-0 w-full h-full flex flex-1 bg-background/40 justify-center items-center z-50",id:"change-timeframe",children:xa("div",{className:"bg-background border border-border rounded-lg shadow-lg shadow-black/30 p-5 w-64 flex flex-col gap-3",children:[xa("div",{className:"flex flex-col gap-0.5",children:[en("div",{className:"text-[13px] font-semibold text-white/90",children:"Set timeframe"}),en("div",{className:"text-[11px] text-muted-foreground",children:"Digits, then a unit: s m h d w"})]}),en(ol,{autoFocus:!0,value:_e,placeholder:"e.g. 15m",className:"text-center text-base font-mono h-11 tracking-[0.2em]",onChange:()=>{},onKeyDown:te=>{te.stopPropagation();let Me=["s","m","h","d"],Qe=te.key,St=_e,Et=Me.some(Kn=>St.includes(Kn)),Rt=St.slice(-1),ar=Qe>="0"&&Qe<="9",Cr=Me.includes(Qe.toLowerCase());if(Qe==="Escape")te.preventDefault(),De(!1),Ne("");else if(Qe==="Backspace")te.preventDefault(),te.ctrlKey?Ne(""):Ne(Kn=>Kn.slice(0,-1));else if(Qe==="Enter"){te.preventDefault();let Kn=St.trim().toLowerCase();if(!Kn)return;let Za=(cB,uB)=>{let dB={none:1000000n,ms:1000000n,s:1000000000n,m:60000000000n,h:3600000000000n,d:86400000000000n,w:604800000000000n};return BigInt(cB)*dB[uB]},Ta=Kn.charAt(Kn.length-1),Ls=Ta>="0"&&Ta<="9",Qa=Ls?"m":Ta,zo=Number(Ls?Kn:Kn.slice(0,-1));zo>0&&rS({label:zo+Qa,barNs:Za(zo,Qa),defaultBars:300,isPreset:!1}),De(!1),Ne("")}else ar&&!Et?(te.preventDefault(),Ne(Kn=>Kn+Qe)):Cr&&!Et&&Rt>="0"&&Rt<="9"?(te.preventDefault(),Ne(Kn=>Kn+Qe.toLowerCase())):te.preventDefault()}}),en("div",{className:"text-xs text-muted-foreground text-center",children:"Enter to confirm \xB7 Esc to cancel"})]})})]})}),aP=cW;function oP({x:e,y:t,initialValue:n="",fontSize:r=12,color:o="#e0e0e0",onKeyStroke:a,onCommit:i,onCancel:s}){let l=Ke(null);return tr(()=>{let c=requestAnimationFrame(()=>{let u=l.current;u&&(u.focus(),u.style.width="1px",u.style.width=Math.max(120,u.scrollWidth)+"px",u.style.height="1px",u.style.height=u.scrollHeight+"px",u.selectionStart=u.selectionEnd=u.value.length)});return()=>cancelAnimationFrame(c)},[]),en("div",{className:"absolute",style:{left:e,top:t},onMouseDown:c=>c.stopPropagation(),children:en("textarea",{ref:l,rows:1,defaultValue:n,spellCheck:!1,autoComplete:"off",className:"resize-none overflow-hidden bg-transparent border-none outline-none ring-0 focus:ring-0 focus:outline-none p-0 m-0 min-w-[120px]",style:{color:o,fontSize:r,fontFamily:"inherit",lineHeight:"1.33",background:"transparent",border:"none",outline:"none",boxShadow:"none",caretColor:"#e0e0e0",whiteSpace:"pre",width:120},onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey?(c.preventDefault(),i(c.target.value)):c.key==="Escape"&&(c.preventDefault(),s());let u=c.currentTarget;u.style.width="1px",u.style.width=Math.max(120,u.scrollWidth)+"px",u.style.height="1px",u.style.height=u.scrollHeight+"px"},onInput:c=>{let u=c.currentTarget;a?.(u.value),u.style.width="1px",u.style.width=Math.max(120,u.scrollWidth)+"px",u.style.height="1px",u.style.height=u.scrollHeight+"px"},onBlur:c=>{i(c.target.value)}})})}import{useState as eg,useMemo as sm,useRef as Du,useEffect as iP,useLayoutEffect as dW}from"react";import{Fragment as lP,jsx as tn,jsxs as ra}from"react/jsx-runtime";var Zv={volume:{label:"Volume",icon:tn(Ai,{size:11}),dot:"bg-blue-400",text:"text-blue-400"},orderflow:{label:"Order Flow",icon:tn(Sd,{size:11}),dot:"bg-emerald-400",text:"text-emerald-400"},momentum:{label:"Momentum",icon:tn(Yd,{size:11}),dot:"bg-violet-400",text:"text-violet-400"},trend:{label:"Trend",icon:tn(_l,{size:11}),dot:"bg-amber-400",text:"text-amber-400"},volatility:{label:"Volatility",icon:tn(gf,{size:11}),dot:"bg-orange-400",text:"text-orange-400"},experimental:{label:"Experimental",icon:tn(Gd,{size:11}),dot:"bg-pink-400",text:"text-pink-400"},other:{label:"Other",icon:tn(Pl,{size:11}),dot:"bg-slate-500",text:"text-slate-400"}},Jv=["volume","orderflow","momentum","trend","volatility","experimental","other"];function fW(e){return e.indicator.id.startsWith("builtin:")||e.indicator.id.startsWith("builtin-")}function sP(e){let t=e.indicator.category?.trim().toLowerCase()??"";if(!t)return"other";let n=Jv.filter(r=>r!=="other");return n.find(r=>r===t)??n.find(r=>t.includes(r))??"other"}function mW(e,t){return e.name.toLowerCase().includes(t)||(e.shortName??"").toLowerCase().includes(t)||(e.description??"").toLowerCase().includes(t)}function pW(e,t){let n=e.require??"ohlcv";if(!Ao(n,t))return cc(n,t)}function Qv({children:e,cyan:t}){return tn("span",{className:ee("text-[9px] font-medium uppercase tracking-wider px-1.5 py-0.5 rounded border shrink-0 leading-none",t?"border-[#08b3de]/30 text-[#08b3de]/80 bg-[#08b3de]/5":"border-[#1e2128] text-slate-500 bg-[#0e1014]"),children:e})}function tg({icon:e,label:t,count:n,active:r,onClick:o}){return ra("button",{onClick:o,className:ee("flex items-center gap-1.5 h-6 pl-1.5 pr-2 rounded-md text-[10px] font-medium whitespace-nowrap shrink-0 border transition-colors duration-150 select-none",r?"bg-[#08b3de]/10 border-[#08b3de]/30 text-[#08b3de]":"bg-[#0e1014] border-[#1e2128] text-slate-400 hover:text-slate-200 hover:border-slate-600"),children:[tn("span",{className:ee("shrink-0",r?"text-[#08b3de]":"text-slate-500"),children:e}),t,tn("span",{className:ee("tabular-nums text-[9px] px-1 rounded-full leading-[13px]",r?"bg-[#08b3de]/15 text-[#08b3de]":"bg-white/5 text-slate-500"),children:n})]})}function hW({row:e,isActive:t,isVisible:n,highlighted:r,refusal:o,onActivate:a,onToggle:i,onRemove:s,onHover:l,rowRef:c}){let{indicator:u}=e.def,d=u.layout==="pane";return ra("div",{ref:c,onMouseEnter:l,onClick:()=>{t||a()},title:o,className:ee("group relative w-full flex items-center gap-2.5 pl-3 pr-1.5 h-9 cursor-pointer transition-colors",r?"bg-[#1a1d23]":t?"bg-[#15181e]":"hover:bg-[#1a1d23]",o&&"opacity-45"),children:[r&&tn("span",{className:"absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-[#08b3de]"}),tn("span",{className:ee("text-[12px] font-medium tracking-tight shrink-0 truncate max-w-[11rem]",t?"text-white":"text-slate-300 group-hover:text-slate-200"),children:u.name}),tn("span",{className:"text-[11px] text-slate-600 truncate flex-1 group-hover:text-slate-500",children:u.description??(e.isCustom?"Installed via plugin":"")}),o&&ra(Qv,{children:[tn(jr,{size:8,className:"inline mb-px mr-1"}),nm[e.def.indicator.require??"ohlcv"]]}),e.isCustom&&tn(Qv,{cyan:!0,children:"custom"}),d&&tn(Qv,{children:"pane"}),tn("div",{className:"w-[3.25rem] flex items-center justify-end gap-0.5 shrink-0",children:t?ra(lP,{children:[tn("button",{onClick:m=>{m.stopPropagation(),i()},title:n?"Hide":"Show",className:"w-6 h-6 flex items-center justify-center rounded text-slate-500 hover:text-slate-200 hover:bg-[#1e2128] transition-colors",children:n?tn(Da,{size:13}):tn(Bi,{size:13})}),tn("button",{onClick:m=>{m.stopPropagation(),s()},title:"Remove",className:"w-6 h-6 flex items-center justify-center rounded text-slate-500 hover:text-red-400 hover:bg-red-500/10 transition-colors",children:tn(ho,{size:13})})]}):tn("span",{className:ee("flex items-center gap-1 text-[11px] text-slate-400 pr-1.5 transition-opacity",r?"opacity-100":"opacity-0 group-hover:opacity-100"),children:o?"Locked":ra(lP,{children:[tn(ha,{size:12}),"Add"]})})})]})}function gW({icon:e,label:t,count:n}){return tn("div",{className:"flex items-center gap-1.5 px-3 pt-2.5 pb-1 sticky top-0 bg-[#16181d] z-[1]",children:tn("span",{className:"text-[9px] font-semibold text-slate-500 uppercase tracking-widest",children:t})})}function cP({indicators:e,dataLevel:t,onAdd:n,onToggle:r,onRemove:o,onOpenChange:a,pluginIndicators:i=[],onActivatePlugin:s}){let[l,c]=eg(!1),[u,d]=eg(""),[m,f]=eg("all"),[h,p]=eg(0),g=Du(null),y=Du(null),v=Du(null),b=Du(null),S=A=>{c(B=>{let E=typeof A=="function"?A(B):A;return a?.(E),E})},C=sm(()=>new Set(e.map(A=>A.id)),[e]),w=u.trim().toLowerCase(),{builtins:k,customs:M}=sm(()=>{let A=[],B=[];for(let E of i)w&&!mW(E.indicator,w)||(fW(E)?A:B).push(E);return{builtins:A,customs:B}},[i,w]),I=sm(()=>{let A=new Map;for(let B of k){let E=sP(B);A.set(E,(A.get(E)??0)+1)}return A},[k]),x=sm(()=>[...k,...M].filter(A=>C.has(A.indicator.id)).length,[k,M,C]),T=sm(()=>{let A=[],B=m==="active",E=z=>{for(let Y of k)sP(Y)===z&&(B&&!C.has(Y.indicator.id)||A.push({def:Y,isCustom:!1,category:z,section:z}))},L=()=>{for(let z of M)B&&!C.has(z.indicator.id)||A.push({def:z,isCustom:!0,category:"other",section:"custom"})};if(m==="custom")L();else if(m==="all"||m==="active"){for(let z of Jv)E(z);L()}else E(m);return A},[k,M,m,C]);iP(()=>{p(A=>T.length===0?0:Math.min(A,T.length-1))},[T.length]),dW(()=>{b.current?.scrollIntoView({block:"nearest"})},[h,T]);let R=A=>{C.has(A.def.indicator.id)?r(A.def.indicator.id):s?.(A.def)};iP(()=>{if(!l)return;d(""),f("all"),p(0);let A=setTimeout(()=>y.current?.focus(),40),B=L=>{g.current&&!g.current.contains(L.target)&&S(!1)},E=L=>{if(L.key==="Escape")S(!1);else if(L.key==="ArrowDown")L.preventDefault(),p(z=>P.current.length?(z+1)%P.current.length:0);else if(L.key==="ArrowUp")L.preventDefault(),p(z=>P.current.length?(z-1+P.current.length)%P.current.length:0);else if(L.key==="Enter"){let z=P.current[D.current];z&&(L.preventDefault(),R(z))}};return document.addEventListener("mousedown",B),document.addEventListener("keydown",E),()=>{clearTimeout(A),document.removeEventListener("mousedown",B),document.removeEventListener("keydown",E)}},[l]);let P=Du(T),D=Du(h);P.current=T,D.current=h;let N=k.length+M.length,O=null;return ra("div",{className:"relative",ref:g,children:[ra("button",{onClick:()=>S(A=>!A),className:ee("flex items-center gap-1.5 h-7 px-2.5 rounded-md text-[12px] font-medium","border transition-all duration-150 select-none border-transparent hover:border-border text-gray-300 hover:text-white",l?"border-border bg-muted text-white":""),children:[tn(_d,{className:"w-4 h-4"}),tn("span",{className:"mt-px",children:"Indicators"}),tn(Zn,{size:10,className:ee("opacity-50 transition-transform duration-150",l&&"rotate-180")})]}),l&&ra("div",{className:"absolute left-0 top-full mt-1.5 z-50 flex flex-col w-[30rem] max-h-[30rem] rounded-lg border border-[#1e2128] bg-[#16181d] shadow-2xl overflow-hidden",children:[ra("div",{className:"flex items-center gap-2.5 px-3 h-11 border-b border-[#1e2128] shrink-0",children:[tn(li,{size:14,className:"text-slate-600 shrink-0"}),tn("input",{ref:y,value:u,onChange:A=>d(A.target.value),placeholder:"Search indicators\u2026",className:"w-full h-full bg-transparent outline-none text-[13px] text-slate-200 placeholder:text-slate-600"})]}),ra("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-[#1e2128] shrink-0 overflow-x-auto no-scrollbar",children:[tn(tg,{icon:tn($d,{size:11}),label:"All",count:N,active:m==="all",onClick:()=>f("all")}),x>0&&tn(tg,{icon:tn(Da,{size:11}),label:"On chart",count:x,active:m==="active",onClick:()=>f("active")}),Jv.filter(A=>(I.get(A)??0)>0).map(A=>{let B=Zv[A];return tn(tg,{icon:B.icon,label:B.label,count:I.get(A)??0,active:m===A,onClick:()=>f(A)},A)}),M.length>0&&tn(tg,{icon:tn(Ko,{size:11}),label:"Custom",count:M.length,active:m==="custom",onClick:()=>f("custom")})]}),tn("div",{ref:v,className:"flex-1 min-h-0 overflow-y-auto py-1",children:T.length===0?ra("div",{className:"flex flex-col items-center justify-center py-16 gap-1.5 text-slate-600",children:[tn(Ys,{size:20,className:"text-slate-700"}),tn("div",{className:"text-[12px] text-slate-500",children:w?"No indicators match":"Nothing here"}),w&&ra("div",{className:"text-[11px]",children:['Nothing matches "',u.trim(),'"']})]}):T.map((A,B)=>{let E=(m==="all"||m==="active")&&A.section!==O;O=A.section;let L=A.section==="custom"?{icon:tn(Ko,{size:11}),label:"Custom"}:{icon:Zv[A.category].icon,label:Zv[A.category].label},z=T.filter(H=>H.section===A.section).length,Y=C.has(A.def.indicator.id),G=e.find(H=>H.id===A.def.indicator.id);return ra("div",{children:[E&&tn(gW,{icon:L.icon,label:L.label,count:z}),tn(hW,{row:A,isActive:Y,isVisible:G?.visible??!0,highlighted:B===h,refusal:pW(A.def.indicator,t),rowRef:B===h?H=>b.current=H:void 0,onHover:()=>p(B),onActivate:()=>s?.(A.def),onToggle:()=>r(A.def.indicator.id),onRemove:()=>o(A.def.indicator.id)})]},A.def.indicator.id)})}),tn("div",{className:"flex items-center justify-between h-7 px-3 border-t border-[#1e2128] shrink-0",children:ra("span",{className:"text-[10px] text-slate-700 flex items-center gap-2",children:[tn("kbd",{className:"font-sans",children:"\u2191\u2193"})," move",tn("kbd",{className:"font-sans",children:"\u21B5"})," add"]})})]})]})}import{useState as ng,useRef as uP,useEffect as dP,useCallback as rg,useMemo as fP}from"react";import{jsx as yr,jsxs as hs}from"react/jsx-runtime";var bW=[{label:"Seconds",tfs:Ho.filter(e=>e.barNs>=1000000000n&&e.barNs<60000000000n)},{label:"Minutes",tfs:Ho.filter(e=>e.barNs>=60000000000n&&e.barNs<3600000000000n)},{label:"Hours",tfs:Ho.filter(e=>e.barNs>=3600000000000n&&e.barNs<86400000000000n)},{label:"Days",tfs:Ho.filter(e=>e.barNs>=86400000000000n&&e.barNs<604800000000000n)},{label:"Weeks",tfs:Ho.filter(e=>e.barNs>=604800000000000n)}];function hP({eventBus:e,value:t,customTimeframes:n,features:r,onChange:o,onAddCustom:a,onRemoveCustom:i,onOpenChange:s}){let[l,c]=ng(!1),[u,d]=ng(""),[m,f]=ng(""),[h,p]=ng(()=>_S()),g=uP(null),y=uP(null),v=P=>{c(D=>{let N=typeof P=="function"?P(D):P;return s?.(N),N})},b=fP(()=>[...Ho,...n],[n]),S=r?.timeframe?.timeframes??"any",C=r?.timeframe?.allowCustom??!0,w=rg(P=>S!=="any"&&!S.includes(P),[S]),k=fP(()=>{let P=new Set(h);return b.filter(D=>P.has(D.label)).sort((D,N)=>D.barNs<N.barNs?-1:D.barNs>N.barNs?1:0)},[b,h]),M=k.some(P=>P.label===t.label);dP(()=>{if(!l)return;let P=N=>{g.current&&!g.current.contains(N.target)&&v(!1)},D=N=>{N.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",P),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",P),document.removeEventListener("keydown",D)}},[l]),dP(()=>{l&&setTimeout(()=>y.current?.focus(),50)},[l]);let I=rg(P=>{if(w(P.label)){e?.emit("timeframe:add-failed",{message:"Timeframe not allowed",code:"TIMEFRAME_NOT_ALLOWED",label:P.label}),v(!1);return}o(P),v(!1)},[o,w,e]),x=rg(P=>{p(D=>{let N=D.includes(P)?D.filter(O=>O!==P):[...D,P];return FS(N),N})},[]),T=rg(()=>{let P=Nc(u);if(!P){f("e.g. 213m, 2h, 45s");return}if(b.some(D=>D.label===P.label)){f("Already exists");return}if(!C){e?.emit("timeframe:add-failed",{message:"Adding custom timeframes not allowed",code:"NO_CUSTOM_TIMEFRAMES",label:P.label}),v(!1);return}if(w(P.label)){e?.emit("timeframe:add-failed",{message:"Timeframe not allowed",code:"TIMEFRAME_NOT_ALLOWED",label:P.label}),v(!1);return}a(P),d(""),f(""),o(P),v(!1)},[u,b,a,o,C,w,e]),R=P=>{f(""),P.key==="Enter"&&T(),P.key==="Escape"&&v(!1)};return hs("div",{className:"relative flex items-center gap-0.5",ref:g,children:[k.map(P=>yr(mP,{tf:P,active:t.label===P.label,locked:w(P.label),onSelect:I},P.label)),!M&&yr(mP,{tf:t,active:!0,onSelect:I}),yr("button",{onClick:()=>v(P=>!P),"aria-label":"All timeframes",className:ee("h-7 w-7 flex items-center justify-center rounded-md border transition-all duration-150 select-none",l?"border-border bg-muted text-slate-200":"border-transparent text-slate-500 hover:text-slate-200 hover:bg-[#1a1d23] hover:border-border"),children:yr(Zn,{size:12,className:ee("transition-transform duration-150",l&&"rotate-180")})}),l&&yr("div",{className:"absolute left-0 top-full mt-1.5 z-50 w-[244px] rounded-lg border border-[#1e2128] bg-[#16181d] shadow-2xl overflow-hidden",children:hs("div",{className:"p-2.5 space-y-3 max-h-[22rem] overflow-y-auto",children:[bW.filter(P=>P.tfs.length>0).map(P=>hs("div",{children:[yr(ew,{children:P.label}),yr("div",{className:"flex flex-wrap gap-1",children:P.tfs.map(D=>yr(pP,{tf:D,active:t.label===D.label,pinned:h.includes(D.label),locked:w(D.label),onSelect:I,onTogglePin:()=>x(D.label)},D.label))})]},P.label)),n.length>0&&hs("div",{children:[yr(ew,{children:"Custom"}),yr("div",{className:"flex flex-wrap gap-1",children:n.map(P=>yr(pP,{tf:P,active:t.label===P.label,pinned:h.includes(P.label),locked:w(P.label),onSelect:I,onTogglePin:()=>x(P.label),onRemove:()=>{i(P.label),h.includes(P.label)&&x(P.label)}},P.label))})]}),hs("div",{className:"pt-2 border-t border-[#1e2128]",children:[yr(ew,{children:hs("span",{className:"inline-flex items-center gap-1",children:["Add custom",!C&&yr(jr,{size:8,className:"text-slate-600"})]})}),hs("div",{className:"flex gap-1.5 items-center",children:[yr("input",{ref:y,value:u,onChange:P=>{d(P.target.value),f("")},onKeyDown:R,placeholder:"e.g. 7m",className:ee("w-full h-7 px-2 rounded-md text-xs bg-[#0e1014] font-[500] border outline-none transition-colors","placeholder:text-slate-700 text-slate-200",m?"border-red-500/50 focus:border-red-500/80":"border-[#1e2128] focus:border-border")}),yr("button",{onClick:T,className:"h-6 w-6 flex items-center justify-center rounded-md bg-muted border border-border hover:bg-muted/50 text-muted-foreground transition-all shrink-0",children:yr(ha,{size:11})})]}),m&&yr("div",{className:"text-[10px] text-red-400/80 mt-1 px-0.5",children:m}),yr("div",{className:"text-[9px] text-slate-700 mt-1.5 px-0.5",children:"Click the star to pin a timeframe to the toolbar."})]})]})})]})}function mP({tf:e,active:t,locked:n,onSelect:r}){return hs("button",{onClick:()=>r(e),title:n?`${e.label} is a Pro timeframe`:void 0,className:ee("relative h-7 px-2 rounded-md text-[11px] font-medium flex items-center gap-1 transition-colors duration-150 select-none",n?"text-slate-700 hover:text-cyan-300/80":t?"text-white":"text-slate-500 hover:text-slate-200 hover:bg-[#1a1d23]"),children:[e.label,n&&yr(jr,{size:8}),t&&yr("span",{className:"absolute inset-x-1.5 bottom-[4px] h-[1px] rounded-full bg-[#08b3de]"})]})}function ew({children:e}){return yr("div",{className:"text-[9px] font-[600] text-muted-foreground uppercase tracking-widest mb-1.5 px-0.5",children:e})}function pP({tf:e,active:t,pinned:n,locked:r,onSelect:o,onTogglePin:a,onRemove:i}){return hs("div",{title:r?`${e.label} is a Pro timeframe`:void 0,className:ee("group relative flex items-center h-6 rounded text-xs select-none cursor-pointer transition-all duration-100 font-[500] pl-2",i?"pr-1":"pr-1.5",r?"bg-transparent text-slate-600 border border-dashed border-[#1e2128] hover:text-cyan-300/80 hover:border-cyan-400/30":t?"bg-[#1a1d23] text-white border border-border":"bg-[#1a1d23] text-slate-500 border border-[#1e2128] hover:text-slate-200 hover:border-slate-600 hover:bg-[#1e2229]"),onClick:()=>o(e),children:[e.label,r?yr(jr,{size:8,className:"ml-1.5 shrink-0"}):yr("button",{className:ee("ml-1.5 transition-all",n?"text-[#08b3de]":"text-slate-600 opacity-0 group-hover:opacity-100 hover:text-slate-300"),onClick:s=>{s.stopPropagation(),a()},"aria-label":n?"Unpin from toolbar":"Pin to toolbar",children:yr(Ol,{size:9,className:n?"fill-current":""})}),i&&yr("button",{className:"ml-0.5 opacity-0 group-hover:opacity-100 text-slate-600 hover:text-red-400 transition-all",onClick:s=>{s.stopPropagation(),i()},"aria-label":"Delete timeframe",children:yr(_r,{size:8})})]})}import{useState as vW,useRef as wW,useEffect as xW}from"react";import{Fragment as yW,jsx as Fn,jsxs as Au}from"react/jsx-runtime";function gs({className:e,children:t}){return Fn("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:ee("w-5 h-5",e),children:t})}function gP({filled:e}){let t=e?"currentColor":"none",n=e?"none":"currentColor";return Au(yW,{children:[Fn("path",{d:"M8 3v5M8 16v5"}),Fn("rect",{x:"5.5",y:"8",width:"5",height:"8",rx:"1",fill:t,stroke:n}),Fn("path",{d:"M16 5v4M16 15v4"}),Fn("rect",{x:"13.5",y:"9",width:"5",height:"6",rx:"1",fill:t,stroke:n})]})}function bP({className:e}){return Fn(gs,{className:e,children:Fn(gP,{filled:!0})})}function yP({className:e}){return Fn(gs,{className:e,children:Fn(gP,{filled:!1})})}function vP({className:e}){return Au(gs,{className:e,children:[Fn("rect",{x:"4",y:"11",width:"4",height:"8",rx:"0.5",fill:"currentColor",stroke:"none"}),Fn("path",{d:"M6 8v3"}),Fn("rect",{x:"10",y:"7",width:"4",height:"8",rx:"0.5",fill:"currentColor",stroke:"none"}),Fn("path",{d:"M12 4v3"}),Fn("rect",{x:"16",y:"4",width:"4",height:"8",rx:"0.5",fill:"currentColor",stroke:"none"}),Fn("path",{d:"M18 12v3"})]})}function wP({className:e}){return Au(gs,{className:e,children:[Fn("path",{d:"M8 4v12"}),Fn("path",{d:"M8 7H5"}),Fn("path",{d:"M8 12h3"}),Fn("path",{d:"M16 8v12"}),Fn("path",{d:"M16 11h-3"}),Fn("path",{d:"M16 16h3"})]})}function xP({className:e}){return Au(gs,{className:e,children:[Fn("path",{d:"M3 12h26",strokeDasharray:"2 1"}),Fn("path",{d:"M2 18 10 9l6 6 20-23"})]})}function SP({className:e}){return Au(gs,{className:e,children:[Fn("path",{d:"M3 15 9 11l4 3 8-6v14H3Z",fill:"currentColor",fillOpacity:.18,stroke:"none"}),Fn("path",{d:"M3 15 9 11l4 3 8-6"})]})}function CP({className:e}){return Fn(gs,{className:e,children:Fn("path",{d:"M2 18 10 9l6 6 20-23"})})}function kP({className:e}){return Fn(gs,{className:e,children:Fn("path",{d:"M3 16h5v-5h5v3h5V7h2"})})}function TP({className:e}){return Au(gs,{className:e,children:[Fn("rect",{x:"4",y:"5",width:"16",height:"14",rx:"1"}),Fn("path",{d:"M12 5v14"}),Fn("path",{d:"M4 10h16"}),Fn("path",{d:"M4 14h16"})]})}import{jsx as Un,jsxs as uc}from"react/jsx-runtime";function SW({icon:e}){return typeof e>"u"?Un(Ko,{className:"w-4 h-4"}):Un("svg",{viewBox:e.viewBox,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"w-4 h-4",children:e.paths.map((t,n)=>Un("path",{d:t},n))})}function LP({value:e,pluginChartTypes:t=[],dataLevel:n,onChange:r,onOpenChange:o}){let[a,i]=vW(!1),s=wW(null),l=[{id:"candles",label:"Candles",icon:Un(bP,{})},{id:"hollow",label:"Hollow",icon:Un(yP,{})},{id:"heikin-ashi",label:"Heikin Ashi",icon:Un(vP,{})},{id:"bars",label:"Bars",icon:Un(wP,{})},{id:"footprint",label:"Footprint",icon:Un(TP,{})},{id:"area",label:"Area",icon:Un(SP,{})},{id:"line",label:"Line",icon:Un(CP,{})},{id:"step",label:"Step",icon:Un(kP,{})},{id:"baseline",label:"Baseline",icon:Un(xP,{})}].filter(f=>n==="l3"||f.id!=="footprint"),c=t.map(f=>{let h=f.require??"ohlcv";return{id:f.chartTypeId,label:f.name,icon:f.icon?Un(SW,{icon:f.icon}):Un(Ko,{className:"w-4 h-4"}),refusal:Ao(h,n)?void 0:cc(h,n)}}),u=f=>{i(h=>{let p=typeof f=="function"?f(h):f;return o?.(p),p})},d=[...l,...c].find(f=>f.id===e)??{id:"unknown",label:"Unknown",icon:Un(ai,{className:"w-4 h-4"})};xW(()=>{if(!a)return;let f=p=>{s.current&&!s.current.contains(p.target)&&u(!1)},h=p=>{p.key==="Escape"&&u(!1)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",h)}},[a]);let m=f=>{r(f),u(!1)};return uc("div",{className:"relative",ref:s,children:[uc("button",{onClick:()=>u(f=>!f),className:ee("flex items-center gap-1.5 h-7 px-2.5 rounded-md text-[12px] font-medium","border transition-all duration-150 select-none",a?"border-border bg-muted text-white":"border-transparent text-gray-300 hover:text-white hover:bg-[#1a1d23] hover:border-border"),children:[Un("span",{className:"opacity-60 shrink-0 flex items-center",children:d.icon}),Un("div",{className:"mt-px",children:d.label}),Un(Zn,{size:10,className:ee("opacity-50 transition-transform duration-150",a&&"rotate-180")})]}),a&&Un("div",{className:"absolute left-0 top-full mt-1.5 z-50 w-[212px] rounded-lg border border-[#1e2128] bg-[#16181d] shadow-2xl overflow-hidden",children:uc("div",{className:"p-2.5 space-y-3",children:[uc("div",{children:[Un(IP,{children:"Chart type"}),Un("div",{className:"grid grid-cols-3 gap-1",children:l.map(f=>Un(MP,{def:f,active:f.id===e,onSelect:m},f.id))})]}),c.length>0&&uc("div",{children:[Un(IP,{children:"Plugins"}),Un("div",{className:"grid grid-cols-3 gap-1",children:c.map(f=>Un(MP,{def:f,active:f.id===e,onSelect:m},f.id))})]})]})})]})}function IP({children:e}){return Un("div",{className:"text-[9px] font-[600] text-muted-foreground uppercase tracking-widest mb-1.5 px-0.5",children:e})}function MP({def:e,active:t,onSelect:n}){let r=!!e.refusal;return uc(Ht,{children:[Un(Ot,{asChild:!0,children:uc("button",{onClick:()=>{r||n(e.id)},className:ee("group relative flex flex-col items-center justify-center gap-1.5 h-[3.75rem] rounded-md border transition-all duration-100 select-none",r?"border-[#1e2128] text-slate-700 cursor-not-allowed":t?"bg-[#1a1d23] border-border text-white":"border-[#1e2128] text-slate-500 hover:text-slate-200 hover:bg-[#1a1d23] hover:border-slate-600"),children:[t&&!r&&Un("span",{className:"absolute top-1.5 right-1.5 w-1 h-1 rounded-full bg-[#08b3de]"}),r&&Un(jr,{size:8,className:"absolute top-1.5 right-1.5 text-slate-700"}),Un("span",{className:ee("shrink-0",r?"text-slate-700":t?"text-slate-200":"text-slate-600 group-hover:text-slate-300"),children:e.icon}),Un("span",{className:"text-[9px] font-medium leading-none max-w-full truncate px-1",children:e.label})]})}),Un(_t,{className:"border border-border bg-background max-w-[13rem]",children:e.refusal??e.label})]})}import{useState as bs,useEffect as um,useCallback as EP,useRef as cw,useLayoutEffect as BW}from"react";import{useState as tw,useRef as nw,useEffect as rw,useCallback as CW,useMemo as ow}from"react";import{jsx as no,jsxs as Ci}from"react/jsx-runtime";var aw=[{value:"America/New_York",label:"New York",region:"Americas",aliases:["ET","EST","EDT","Eastern"]},{value:"America/Chicago",label:"Chicago",region:"Americas",aliases:["CT","CST","CDT","Central"]},{value:"America/Denver",label:"Denver",region:"Americas",aliases:["MT","MST","MDT","Mountain"]},{value:"America/Los_Angeles",label:"Los Angeles",region:"Americas",aliases:["PT","PST","PDT","Pacific"]},{value:"America/Anchorage",label:"Anchorage",region:"Americas",aliases:["AKT"]},{value:"America/Honolulu",label:"Honolulu",region:"Americas",aliases:["HST","Hawaii"]},{value:"America/Toronto",label:"Toronto",region:"Americas",aliases:["ET","Eastern"]},{value:"America/Vancouver",label:"Vancouver",region:"Americas",aliases:["PT","Pacific"]},{value:"America/Sao_Paulo",label:"S\xE3o Paulo",region:"Americas",aliases:["BRT","Brazil"]},{value:"America/Mexico_City",label:"Mexico City",region:"Americas",aliases:["CST"]},{value:"America/Buenos_Aires",label:"Buenos Aires",region:"Americas",aliases:["ART","Argentina"]},{value:"UTC",label:"UTC",region:"Other",aliases:["GMT","Universal"]},{value:"Europe/London",label:"London",region:"Europe",aliases:["GMT","BST"]},{value:"Europe/Stockholm",label:"Stockholm",region:"Europe",aliases:["CET","CEST","Sweden"]},{value:"Europe/Paris",label:"Paris",region:"Europe",aliases:["CET","CEST"]},{value:"Europe/Frankfurt",label:"Frankfurt",region:"Europe",aliases:["CET","CEST","Germany"]},{value:"Europe/Amsterdam",label:"Amsterdam",region:"Europe",aliases:["CET"]},{value:"Europe/Zurich",label:"Zurich",region:"Europe",aliases:["CET","Switzerland"]},{value:"Europe/Moscow",label:"Moscow",region:"Europe",aliases:["MSK","Russia"]},{value:"Europe/Istanbul",label:"Istanbul",region:"Europe",aliases:["TRT","Turkey"]},{value:"Europe/Helsinki",label:"Helsinki",region:"Europe",aliases:["EET","EEST","Finland"]},{value:"Europe/Warsaw",label:"Warsaw",region:"Europe",aliases:["CET","Poland"]},{value:"Europe/Madrid",label:"Madrid",region:"Europe",aliases:["CET","Spain"]},{value:"Europe/Rome",label:"Rome",region:"Europe",aliases:["CET","Italy"]},{value:"Asia/Dubai",label:"Dubai",region:"Asia-Pacific",aliases:["GST","UAE"]},{value:"Asia/Kolkata",label:"Mumbai",region:"Asia-Pacific",aliases:["IST","India"]},{value:"Asia/Singapore",label:"Singapore",region:"Asia-Pacific",aliases:["SGT"]},{value:"Asia/Hong_Kong",label:"Hong Kong",region:"Asia-Pacific",aliases:["HKT"]},{value:"Asia/Shanghai",label:"Shanghai",region:"Asia-Pacific",aliases:["CST","China","Beijing"]},{value:"Asia/Tokyo",label:"Tokyo",region:"Asia-Pacific",aliases:["JST","Japan"]},{value:"Asia/Seoul",label:"Seoul",region:"Asia-Pacific",aliases:["KST","Korea"]},{value:"Asia/Taipei",label:"Taipei",region:"Asia-Pacific",aliases:["CST","Taiwan"]},{value:"Australia/Sydney",label:"Sydney",region:"Asia-Pacific",aliases:["AEST","AEDT","Australia"]},{value:"Australia/Melbourne",label:"Melbourne",region:"Asia-Pacific",aliases:["AEST","AEDT"]},{value:"Pacific/Auckland",label:"Auckland",region:"Asia-Pacific",aliases:["NZST","New Zealand"]}],RP=["Americas","Europe","Asia-Pacific","Other"];function DP(e,t){try{let n=new Date(Number(t/1000000n));return(new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(n).find(a=>a.type==="timeZoneName")?.value??"").replace("GMT","")||"UTC"}catch{return""}}function kW(e,t){let r=aw.find(a=>a.value===e)?.label??e,o=DP(e,t);return{label:r,offset:o}}function AP({value:e,onChange:t,use24Hour:n=!0,onOpenChange:r,compact:o=!1,horizon:a=0n}){let[i,s]=tw(!1);rw(()=>{r?.(i)},[i]);let[l,c]=tw(""),[u,d]=tw(null),m=nw(null),f=nw(null),h=nw(null);rw(()=>{if(!i)return;let w=k=>{m.current?.contains(k.target)||(s(!1),c(""))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]),rw(()=>{i&&(setTimeout(()=>f.current?.focus(),50),d(e))},[i,e]);let p=ow(()=>{let w=l.toLowerCase().trim();return w?aw.filter(k=>k.label.toLowerCase().includes(w)||k.value.toLowerCase().includes(w)||k.region.toLowerCase().includes(w)||(k.aliases??[]).some(M=>M.toLowerCase().includes(w))):aw},[l]),g=ow(()=>{let w=new Map;for(let k of RP)w.set(k,[]);for(let k of p)w.get(k.region)?.push(k);return w},[p]),y=ow(()=>p,[p]),v=CW(w=>{if(!i)return;let k=y.findIndex(M=>M.value===u);if(w.key==="ArrowDown"){w.preventDefault();let M=y[Math.min(k+1,y.length-1)];M&&(d(M.value),b(M.value))}else if(w.key==="ArrowUp"){w.preventDefault();let M=y[Math.max(k-1,0)];M&&(d(M.value),b(M.value))}else w.key==="Enter"?u&&(t(u),s(!1),c("")):w.key==="Escape"&&(s(!1),c(""))},[i,y,u,t]),b=w=>{h.current?.querySelector(`[data-tz="${w}"]`)?.scrollIntoView({block:"nearest"})},{label:S,offset:C}=kW(e,a);return Ci("div",{ref:m,className:"relative w-full select-none",children:[Ci("button",{onClick:()=>s(w=>!w),className:ee("w-full flex items-center justify-between gap-2 rounded-lg border text-left transition-all",o?"h-7 px-2 text-[11px]":"px-3 py-2.5 text-[12px]",i?"border-blue-500/40 bg-blue-500/8 text-white ring-1 ring-blue-500/20":"border-white/8 bg-white/3 text-white hover:border-white/15 hover:bg-white/5"),children:[Ci("div",{className:"flex items-center gap-2 min-w-0",children:[no(Al,{size:o?11:13,className:"text-white/40 shrink-0"}),no("span",{className:ee("font-medium truncate",o?"text-[11px]":"text-[12px]"),children:S}),no("span",{className:"text-[10px] font-mono text-white/30 shrink-0",children:C||"UTC"})]}),Ci("div",{className:"flex items-center gap-2 shrink-0",children:[!o&&no(PP,{tz:e,use24Hour:n,horizon:a}),no(Zn,{size:o?11:13,className:ee("text-white/30 transition-transform duration-150",i&&"rotate-180")})]})]}),i&&Ci("div",{className:ee("absolute z-50 left-0 right-0",o?"bottom-full mb-1.5":"mt-1.5","rounded-xl border border-white/10 bg-[#1a1d23]","flex flex-col overflow-hidden"),style:{maxHeight:320},children:[Ci("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-white/8 shrink-0",children:[no(li,{size:12,className:"text-white/25 shrink-0"}),no("input",{ref:f,value:l,onChange:w=>{c(w.target.value),d(null)},onKeyDown:v,placeholder:"Search timezone\u2026",className:ee("flex-1 bg-transparent text-[12px] text-white placeholder:text-white/25","outline-none border-none")}),l&&no("button",{onClick:()=>c(""),className:"text-white/25 hover:text-white/60 transition-colors",children:no(_r,{size:11})})]}),Ci("div",{ref:h,className:"overflow-y-auto overscroll-contain",style:{maxHeight:268},children:[y.length===0?Ci("div",{className:"px-3 py-6 text-center text-[11px] text-white/25",children:['No timezones match "',l,'"']}):RP.map(w=>{let k=g.get(w)??[];return k.length?Ci("div",{children:[no("div",{className:"sticky top-0 z-10 px-3 pt-2.5 pb-1 bg-[#1a1d23]",children:no("span",{className:"text-[9px] font-semibold uppercase tracking-widest text-white/20",children:w})}),k.map(M=>{let I=M.value===e,x=M.value===u;return Ci("button",{"data-tz":M.value,onClick:()=>{t(M.value),s(!1),c("")},onMouseEnter:()=>d(M.value),className:ee("w-full flex items-center justify-between gap-2 px-3 py-2 text-left transition-colors",I&&"text-white",!I&&"text-white/50",x&&!I&&"bg-white/4 text-white/80",I&&x&&"bg-blue-500/10",I&&!x&&"bg-blue-500/6"),children:[Ci("div",{className:"flex items-center gap-2.5 min-w-0",children:[no("div",{className:"w-3 shrink-0 flex justify-center",children:I?no(Or,{size:11,className:"text-blue-400"}):no("span",{})}),no("span",{className:"text-[12px] truncate",children:M.label}),no("span",{className:"text-[10px] font-mono text-white/20 shrink-0",children:DP(M.value,a)||"UTC"})]}),no(PP,{tz:M.value,use24Hour:n,dim:!I&&!x,horizon:a})]},M.value)})]},w):null}),no("div",{className:"h-1.5"})]})]})]})}function PP({tz:e,use24Hour:t,dim:n,horizon:r}){let o=TW(r,e,t);return no("span",{className:ee("text-[10px] font-mono tabular-nums shrink-0 transition-colors",n?"text-white/15":"text-white/40"),children:o})}function TW(e,t,n){try{let r=new Date(Number(e/1000000n));return new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hour12:!n}).format(r)}catch{return"--:--"}}var IW="tradingview.chartproperties",MW="tradingview.chartproperties.mainSeriesProperties",LW="tradingview.chart.favoriteDrawings",iw=`${up}tradingview-imported`,BP={0:"bars",1:"candles",2:"line",3:"area",4:"renko",5:"kagi",7:"line-break",8:"heikin-ashi",9:"hollow",10:"baseline",15:"step"},RW={0:"barStyle",1:"candleStyle",4:"renkoStyle",8:"haStyle",9:"hollowCandleStyle",19:"volCandlesStyle"},PW={0:[],1:[2,3],2:[6,3],3:[10,5]},DW={cursor:"cursor",LineToolTrendLine:"line",LineToolRay:"ray",LineToolHorzLine:"hline",LineToolVertLine:"vline",LineToolExtended:"extended-line",LineToolHorzRay:"hray",LineToolCrossLine:"cross-line",LineToolInfoLine:"info-line",LineToolTrendAngle:"trend-angle",LineToolParallelChannel:"parallel-channel",LineToolFlatBottom:"flat-channel",LineToolDisjointAngle:"disjoint-channel",LineToolRegressionTrend:"regression-trend",LineToolPitchfork:"pitchfork",LineToolSchiffPitchfork:"schiff-pitchfork",LineToolInsidePitchfork:"inside-pitchfork",LineToolFibRetracement:"fib",LineToolRectangle:"rect",LineToolTriangle:"triangle",LineToolText:"text",LineToolRiskRewardLong:"long",LineToolRiskRewardShort:"short",LineToolFixedRangeVolumeProfile:"fvp"},No=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),og=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");function Ya(e){if(typeof e!="string")return;let t=e.trim();if(!t)return;if(/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(t))return t.toLowerCase();if(/^#[0-9a-f]{3}$/i.test(t)){let[c,u,d]=t.slice(1);return`#${c}${c}${u}${u}${d}${d}`.toLowerCase()}let n=t.match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/i);if(!n)return;let[,r,o,a,i]=n,s=i===void 0?1:Number(i),l=`#${og(Number(r))}${og(Number(o))}${og(Number(a))}`;return s>=1?l:`${l}${og(s*255)}`}var dc=e=>typeof e=="boolean"?e:void 0,Bu=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0;function En(e,t,n){n!==void 0&&(e[t]=n)}function NP(e){if(typeof window>"u")return null;try{let t=window.localStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return No(n)?n:null}catch{return null}}function lm(){let e=NP(IW),t=NP(MW)??(No(e?.mainSeriesProperties)?e.mainSeriesProperties:null);if(!e&&!t)return null;let n={},r=No(e?.paneProperties)?e.paneProperties:{},o=Ya(r.background)??Ya(r.backgroundGradientStartColor);if(En(n,"backgroundColor",o),En(n,"axisBackgroundColor",o),typeof r.gridLinesMode=="string"&&En(n,"showGrid",r.gridLinesMode!=="none"),No(r.vertGridProperties)&&En(n,"gridVerticalColor",Ya(r.vertGridProperties.color)),No(r.horzGridProperties)&&En(n,"gridHorizontalColor",Ya(r.horzGridProperties.color)),No(r.crossHairProperties)){let i=r.crossHairProperties;En(n,"crosshairColor",Ya(i.color)),En(n,"crosshairWidth",Bu(i.width));let s=typeof i.style=="number"?PW[i.style]:void 0;En(n,"crosshairDash",s)}let a=i=>{let s=Bu(i);return s===void 0?void 0:Math.max(0,Math.min(.5,s/100))};if(En(n,"scaleMarginTop",a(r.topMargin)),En(n,"scaleMarginBottom",a(r.bottomMargin)),No(r.axisProperties)){let i=r.axisProperties;En(n,"autoScale",dc(i.autoScale)),En(n,"invertScale",dc(i.isInverted)),i.log===!0?En(n,"priceScaleMode","log"):i.percentage===!0?En(n,"priceScaleMode","percent"):i.log===!1&&i.percentage===!1&&En(n,"priceScaleMode","normal")}if(No(r.legendProperties)){let i=r.legendProperties;En(n,"showStatusLine",dc(i.showLegend)),En(n,"statusLineOHLC",dc(i.showSeriesOHLC)),En(n,"statusLineVolume",dc(i.showVolume)),En(n,"statusLineChange",dc(i.showBarChange))}if(typeof e?.timezone=="string"&&e.timezone&&En(n,"timezone",e.timezone==="Etc/UTC"?"UTC":e.timezone),t){let i=Bu(t.style);i!==void 0&&BP[i]&&En(n,"chartType",BP[i]);let s=i!==void 0&&RW[i]||"candleStyle",l=No(t[s])?t[s]:No(t.candleStyle)?t.candleStyle:null;if(l){let m=Ya(l.upColor),f=Ya(l.downColor);En(n,"upBodyColor",m),En(n,"downBodyColor",f);let h=Ya(l.borderUpColor),p=Ya(l.borderDownColor);En(n,"upBorderColor",h),En(n,"downBorderColor",p);let g=Ya(l.wickUpColor),y=Ya(l.wickDownColor);En(n,"upWickColor",g),En(n,"downWickColor",y),m&&f&&h&&p&&En(n,"borderColorMatchesBody",h===m&&p===f),m&&f&&g&&y&&En(n,"wickColorMatchesBody",g===m&&y===f)}En(n,"priceLineVisible",dc(t.showPriceLine)),En(n,"priceLineColor",Ya(t.priceLineColor));let c=No(t.renkoStyle)?t.renkoStyle:null;c&&No(c.inputs)&&c.inputs.style==="Traditional"&&En(n,"renkoBrickSize",Bu(c.inputs.boxSize));let u=No(t.lineBreakStyle)?t.lineBreakStyle:null;u&&No(u.inputs)&&En(n,"lineBreakCount",Bu(u.inputs.lineNumber));let d=No(t.kagiStyle)?t.kagiStyle:null;d&&No(d.inputs)&&d.inputs.style==="Traditional"&&En(n,"kagiReversal",Bu(d.inputs.reversalAmount))}return Object.keys(n).length>0?n:null}function sw(){if(typeof window>"u")return null;let e;try{let n=window.localStorage.getItem(LW);if(!n)return null;e=JSON.parse(n)}catch{return null}if(!Array.isArray(e))return null;let t=[];for(let n of e){let r=typeof n=="string"?DW[n]:void 0;r&&r!=="cursor"&&!t.includes(r)&&t.push(r)}return t.length>0?t:null}function lw(){return lm()!==null||sw()!==null}function cm(e={}){let t={settings:!1,favorites:!1};if(typeof window>"u"||!e.force&&xl(iw)!==null)return t;if(e.force||xl(Cn.chartSettings)===null){let n=lm();n&&(kr(Cn.chartSettings,n),t.settings=!0)}if(e.force||xl(Cn.drawingFavorites)===null){let n=sw();n&&(kr(Cn.drawingFavorites,n),t.favorites=!0)}return pp(iw,String(Date.now())),t}function AW(){if(!(typeof window>"u"))try{window.localStorage.removeItem(iw)}catch{}}import{Fragment as dw,jsx as be,jsxs as at}from"react/jsx-runtime";var fw=480,Nu=12,OP=[{label:"Solid",dash:[]},{label:"Dashed",dash:[6,6]},{label:"Dotted",dash:[2,3]},{label:"Dash-dot",dash:[8,3,2,3]}],uw=null;function NW(){return{x:Math.round((window.innerWidth-fw)/2),y:Math.round(window.innerHeight*.1)}}function _P(e,t){let n=window.innerHeight-t-Nu;return Math.min(Math.max(Nu,e),Math.max(Nu,n))}function EW(e){return Math.max(Nu,Math.min(window.innerWidth-fw-Nu,e))}function FP({settings:e,horizon:t,onUpdate:n,onClose:r,onMouseEnter:o,onMouseLeave:a,pluginChartType:i}){let[s,l]=bs("candles"),c=i?.settingsSchema??[],u=s==="plugin"&&!c.length?"candles":s,d=cw(null),m=cw(null),f=e,[h,p]=bs(!1),g=cw(uw??(typeof window<"u"?NW():{x:80,y:80})),[,y]=bs(0);BW(()=>{let x=m.current;if(!x)return;let T=_P(g.current.y,x.offsetHeight);T!==g.current.y&&(g.current={...g.current,y:T},uw=g.current,y(R=>R+1))});let v=EP(x=>{if(x.target.closest("button"))return;x.preventDefault(),x.stopPropagation();let T=x.clientX,R=x.clientY,P=g.current.x,D=g.current.y,N=A=>{let B=m.current?.offsetHeight??0;g.current={x:EW(P+A.clientX-T),y:_P(D+A.clientY-R,B)},uw=g.current,y(E=>E+1)},O=()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",O)};window.addEventListener("mousemove",N),window.addEventListener("mouseup",O)},[]),b=EP(()=>{a?.(),r()},[r,a]);um(()=>{let x=T=>{T.key==="Escape"&&b()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[b]);let S=i?.chartTypeId??"",C=f.pluginSettings??{},w={...i?.defaultSettings??{},...C[S]??{}},k=x=>{let T={...w,...x};n({pluginSettings:{...C,[S]:T}})},M=[{id:"candles",label:"Candles",icon:be(Fs,{size:14})},{id:"scales",label:"Scales",icon:be(of,{size:14})},{id:"lines",label:"Lines",icon:be(Yo,{size:14})},{id:"status",label:"Status",icon:be(Kd,{size:14})},{id:"chart",label:"Chart",icon:be(ef,{size:14})},{id:"timezone",label:"Timezone",icon:be(Al,{size:14})},...c.length?[{id:"plugin",label:i.label,icon:be(Ko,{size:14})}]:[]],I=x=>Math.max(0,M.findIndex(T=>T.id===x));return at(dw,{children:[be("style",{children:`
|
|
88
|
+
@keyframes dlg-in { from{opacity:0;transform:scale(0.94)} to{opacity:1;transform:scale(1)} }
|
|
89
|
+
.dlg-enter { animation: dlg-in 160ms cubic-bezier(0.16,1,0.3,1) both; transform-origin: top left; }
|
|
90
|
+
`}),at("div",{ref:m,className:"dlg-enter fixed z-[200] flex flex-col bg-[#14161b]/90 backdrop-blur-lg rounded-xl border border-white/10 bg-[#14161b] shadow-2xl overflow-hidden min-h-0",style:{left:g.current.x,top:g.current.y,width:fw,maxHeight:`calc(100vh - ${g.current.y+Nu}px)`},onMouseDown:x=>x.stopPropagation(),onMouseEnter:o,onMouseLeave:a,children:[at("div",{className:"flex items-center gap-2 px-4 pt-4 pb-3 border-b border-white/6 shrink-0 cursor-grab active:cursor-grabbing select-none",onMouseDown:v,children:[at("div",{className:"flex-1 min-w-0",children:[be("h2",{className:"text-sm font-semibold text-white tracking-tight",children:"Chart Settings"}),be("p",{className:"text-[11px] text-white/40 mt-0.5",children:"Appearance & behaviour"})]}),be("button",{className:"p-1.5 rounded-lg hover:bg-white/10 text-white/40 hover:text-white transition-all shrink-0 cursor-pointer active:scale-95",onClick:b,children:be(_r,{size:18})})]}),at("div",{className:"grid shrink-0 border-b border-white/6 relative",style:{gridTemplateColumns:`repeat(${M.length}, 1fr)`},ref:d,children:[M.map(x=>at("button",{onMouseDown:()=>l(x.id),className:ee("flex flex-col items-center justify-center gap-1 py-2.5 text-[10px] font-medium transition-colors border-b-2 -mb-px",u===x.id?"text-white bg-white/5":"text-white/35 border-transparent hover:text-white/65 hover:bg-white/4"),children:[x.icon,be("span",{children:x.label})]},x.id)),be("div",{className:"absolute bottom-0 left-0 border-b-2 border-blue-500 transition-transform duration-200",style:{width:`${100/M.length}%`,transform:`translateX(${I(u)*(d.current?d.current.clientWidth/M.length:0)}px)`}})]}),at("div",{className:"flex-1 overflow-y-auto px-5 py-4 min-h-0",children:[u==="candles"&&at("div",{className:"flex flex-col gap-5",children:[be(zn,{label:"Body colors",children:at("div",{className:"grid grid-cols-2 gap-3",children:[be(Sa,{label:"Bullish",value:f.upBodyColor,onChange:x=>n({upBodyColor:x})}),be(Sa,{label:"Bearish",value:f.downBodyColor,onChange:x=>n({downBodyColor:x})})]})}),at(zn,{label:"Wick colors",children:[be(Ir,{label:"Match body color",active:f.wickColorMatchesBody,onToggle:()=>n({wickColorMatchesBody:!f.wickColorMatchesBody})}),!f.wickColorMatchesBody&&at("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[be(Sa,{label:"Bullish wick",value:f.upWickColor,onChange:x=>n({upWickColor:x})}),be(Sa,{label:"Bearish wick",value:f.downWickColor,onChange:x=>n({downWickColor:x})})]})]}),at(zn,{label:`Wick width - ${f.wickWidth}px`,children:[be(Dn,{value:[f.wickWidth],onValueChange:([x])=>n({wickWidth:x}),min:1,max:4,step:1,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[1,2,3,4].map(x=>at("span",{children:[x,"px"]},x))})]}),at(zn,{label:"Border colors",children:[be(Ir,{label:"Match body color",active:f.borderColorMatchesBody,onToggle:()=>n({borderColorMatchesBody:!f.borderColorMatchesBody})}),!f.borderColorMatchesBody&&at("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[be(Sa,{label:"Bullish border",value:f.upBorderColor,onChange:x=>n({upBorderColor:x})}),be(Sa,{label:"Bearish border",value:f.downBorderColor,onChange:x=>n({downBorderColor:x})})]})]}),at(zn,{label:`Border width - ${f.borderWidth}px`,children:[be(Dn,{value:[f.borderWidth],onValueChange:([x])=>n({borderWidth:x}),min:0,max:4,step:1,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[0,1,2,3,4].map(x=>at("span",{children:[x,"px"]},x))})]}),f.chartType==="footprint"&&at(dw,{children:[be(zn,{label:"Footprint display mode",children:be("div",{className:"flex gap-1.5 flex-wrap",children:["bid-ask","profile","delta","total"].map(x=>be(fc,{active:f.footprintMode===x,onClick:()=>n({footprintMode:x}),children:x==="bid-ask"?"Bid/Ask":x.charAt(0).toUpperCase()+x.slice(1)},x))})}),f.footprintMode==="bid-ask"&&at(zn,{label:"Volume display",children:[be("div",{className:"flex gap-1.5",children:["none","split","total"].map(x=>be(fc,{active:f.footprintVolume===x,onClick:()=>n({footprintVolume:x}),children:x==="none"?"None":x==="split"?"Split":"Total"},x))}),at("p",{className:"text-[10px] text-white/25 mt-1.5",children:[f.footprintVolume==="none"&&"No volume bar - bid/ask numbers only",f.footprintVolume==="split"&&"Separate bid and ask volume bars",f.footprintVolume==="total"&&"Single combined volume bar"]})]}),be(zn,{label:"Footprint signals",children:at("div",{className:"flex flex-col gap-2",children:[be(Ir,{label:"Stacked imbalance",active:f.footprintShowStackedImbalance,onToggle:()=>n({footprintShowStackedImbalance:!f.footprintShowStackedImbalance})}),be(Ir,{label:"Absorption",active:f.footprintShowAbsorption,onToggle:()=>n({footprintShowAbsorption:!f.footprintShowAbsorption})}),be(Ir,{label:"Unfinished auction",active:f.footprintShowUnfinishedAuction,onToggle:()=>n({footprintShowUnfinishedAuction:!f.footprintShowUnfinishedAuction})}),be(Ir,{label:"Diagonal imbalance",active:f.footprintShowDiagonalImbalance,onToggle:()=>n({footprintShowDiagonalImbalance:!f.footprintShowDiagonalImbalance})})]})}),at(zn,{label:`Imbalance ratio - ${f.footprintImbalanceRatio.toFixed(1)}\xD7`,children:[be(Dn,{value:[f.footprintImbalanceRatio],onValueChange:([x])=>n({footprintImbalanceRatio:x}),min:1.5,max:6,step:.5,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[1.5,2,2.5,3,3.5,4,4.5,5,5.5,6].map(x=>at("span",{children:[x,"\xD7"]},x))}),be("p",{className:"text-[10px] text-white/25 mt-1",children:"Ask/bid ratio required to flag a level as imbalanced"})]}),f.footprintShowStackedImbalance&&at(zn,{label:`Stacked imbalance - min ${f.footprintStackMinCount} levels`,children:[be(Dn,{value:[f.footprintStackMinCount],onValueChange:([x])=>n({footprintStackMinCount:x}),min:2,max:6,step:1,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[2,3,4,5,6].map(x=>be("span",{children:x},x))}),be("p",{className:"text-[10px] text-white/25 mt-1",children:"Consecutive imbalanced levels to trigger a stacked zone"})]}),f.footprintShowDiagonalImbalance&&at(zn,{label:`Diagonal ratio - ${f.footprintDiagRatio.toFixed(1)}\xD7`,children:[be(Dn,{value:[f.footprintDiagRatio],onValueChange:([x])=>n({footprintDiagRatio:x}),min:1.5,max:6,step:.5,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[1.5,2,2.5,3,3.5,4,4.5,5,5.5,6].map(x=>at("span",{children:[x,"\xD7"]},x))}),be("p",{className:"text-[10px] text-white/25 mt-1",children:"ask[n] / bid[n\u22121] threshold for diagonal imbalance"})]}),f.footprintShowAbsorption&&at(zn,{label:`Absorption threshold - ${f.footprintAbsorptionMult.toFixed(1)}\xD7 avg`,children:[be(Dn,{value:[f.footprintAbsorptionMult],onValueChange:([x])=>n({footprintAbsorptionMult:x}),min:1.5,max:5,step:.5,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[1.5,2,2.5,3,3.5,4,4.5,5].map(x=>at("span",{children:[x,"\xD7"]},x))}),at("div",{className:"mt-3",children:[at("p",{className:"text-[11px] text-white/40 mb-2",children:["Max delta fraction -"," ",Math.round(f.footprintAbsorptionDeltaFrac*100),"%"]}),be(Dn,{value:[f.footprintAbsorptionDeltaFrac],onValueChange:([x])=>n({footprintAbsorptionDeltaFrac:x}),min:.05,max:.5,step:.05,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[5,10,20,30,40,50].map(x=>at("span",{children:[x,"%"]},x))}),be("p",{className:"text-[10px] text-white/25 mt-1",children:"Max |delta/total| allowed - lower = more symmetric fills only"})]})]}),be(sl,{onReset:()=>n({footprintImbalanceRatio:Ye.footprintImbalanceRatio,footprintStackMinCount:Ye.footprintStackMinCount,footprintShowStackedImbalance:Ye.footprintShowStackedImbalance,footprintShowAbsorption:Ye.footprintShowAbsorption,footprintShowUnfinishedAuction:Ye.footprintShowUnfinishedAuction,footprintShowDiagonalImbalance:Ye.footprintShowDiagonalImbalance,footprintDiagRatio:Ye.footprintDiagRatio,footprintAbsorptionMult:Ye.footprintAbsorptionMult,footprintAbsorptionDeltaFrac:Ye.footprintAbsorptionDeltaFrac})})]}),be("div",{className:"border-t border-white/6 my-1"}),be(sl,{onReset:()=>n({chartType:Ye.chartType,upBodyColor:Ye.upBodyColor,downBodyColor:Ye.downBodyColor,upWickColor:Ye.upWickColor,downWickColor:Ye.downWickColor,upBorderColor:Ye.upBorderColor,downBorderColor:Ye.downBorderColor,wickColorMatchesBody:Ye.wickColorMatchesBody,borderColorMatchesBody:Ye.borderColorMatchesBody,wickWidth:Ye.wickWidth,borderWidth:Ye.borderWidth,footprintMode:Ye.footprintMode,footprintVolume:Ye.footprintVolume,footprintImbalanceRatio:Ye.footprintImbalanceRatio,footprintStackMinCount:Ye.footprintStackMinCount,footprintShowStackedImbalance:Ye.footprintShowStackedImbalance,footprintShowAbsorption:Ye.footprintShowAbsorption,footprintShowUnfinishedAuction:Ye.footprintShowUnfinishedAuction,footprintShowDiagonalImbalance:Ye.footprintShowDiagonalImbalance,footprintDiagRatio:Ye.footprintDiagRatio,footprintAbsorptionMult:Ye.footprintAbsorptionMult,footprintAbsorptionDeltaFrac:Ye.footprintAbsorptionDeltaFrac})})]}),u==="scales"&&at("div",{className:"flex flex-col gap-5",children:[be(zn,{label:"Price scale mode",children:be("div",{className:"flex gap-1.5",children:["normal","percent"].map(x=>be(fc,{active:f.priceScaleMode===x,onClick:()=>n({priceScaleMode:x}),children:x==="normal"?"Linear":"%"},x))})}),at(zn,{label:`Price Scale Resize Sensitivity - ${f.priceAxisResizeSensitivity}x`,children:[be(Dn,{value:[f.priceAxisResizeSensitivity],onValueChange:([x])=>n({priceAxisResizeSensitivity:x}),min:0,max:2,step:.1,className:"w-full"}),at("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[be("span",{children:"0x"}),be("span",{children:"1x"}),be("span",{children:"2x"})]})]}),be(zn,{label:"Options",children:at("div",{className:"flex flex-col gap-2",children:[be(Ir,{label:"Auto-scale",active:f.autoScale,onToggle:()=>n({autoScale:!f.autoScale})}),be(Ir,{label:"Invert scale",active:f.invertScale,onToggle:()=>n({invertScale:!f.invertScale})}),be(Ir,{label:"Allow label overlap",active:f.allowLabelOverlap,onToggle:()=>n({allowLabelOverlap:!f.allowLabelOverlap})}),be(Ir,{label:"Animate price updates",active:f.animatePriceUpdates,onToggle:()=>n({animatePriceUpdates:!f.animatePriceUpdates})})]})}),at(zn,{label:`Top margin - ${Math.round(f.scaleMarginTop*100)}%`,children:[be(Dn,{value:[f.scaleMarginTop],onValueChange:([x])=>n({scaleMarginTop:x}),min:0,max:.5,step:.01,className:"w-full"}),at("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[be("span",{children:"0%"}),be("span",{children:"25%"}),be("span",{children:"50%"})]})]}),at(zn,{label:`Bottom margin - ${Math.round(f.scaleMarginBottom*100)}%`,children:[be(Dn,{value:[f.scaleMarginBottom],onValueChange:([x])=>n({scaleMarginBottom:x}),min:0,max:.5,step:.01,className:"w-full"}),at("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[be("span",{children:"0%"}),be("span",{children:"25%"}),be("span",{children:"50%"})]})]}),be(sl,{onReset:()=>n({priceScaleMode:Ye.priceScaleMode,autoScale:Ye.autoScale,priceAxisResizeSensitivity:Ye.priceAxisResizeSensitivity,invertScale:Ye.invertScale,scaleMarginTop:Ye.scaleMarginTop,scaleMarginBottom:Ye.scaleMarginBottom,allowLabelOverlap:Ye.allowLabelOverlap})})]}),u==="lines"&&at("div",{className:"flex flex-col gap-5",children:[at(zn,{label:"Grid",children:[be(Ir,{label:"Show grid",active:f.showGrid,onToggle:()=>n({showGrid:!f.showGrid})}),f.showGrid&&be("div",{className:"mt-3 flex flex-col gap-3",children:at("div",{className:"grid grid-cols-2 gap-3",children:[be(Sa,{label:"Horizontal",value:f.gridHorizontalColor,onChange:x=>n({gridHorizontalColor:x})}),be(Sa,{label:"Vertical",value:f.gridVerticalColor,onChange:x=>n({gridVerticalColor:x})})]})})]}),at(zn,{label:"Crosshair",children:[be("div",{className:"flex gap-1.5 mb-3",children:["normal","hidden"].map(x=>be(fc,{active:f.crosshairMode===x,onClick:()=>n({crosshairMode:x}),children:x.charAt(0).toUpperCase()+x.slice(1)},x))}),f.crosshairMode!=="hidden"&&at("div",{className:"flex flex-col gap-3",children:[be(Sa,{label:"Crosshair color",value:f.crosshairColor,onChange:x=>n({crosshairColor:x})}),at("div",{children:[at("label",{className:"block text-[11px] text-white/40 mb-1",children:["Line width - ",f.crosshairWidth,"px"]}),be(Dn,{value:[f.crosshairWidth],onValueChange:([x])=>n({crosshairWidth:x}),min:1,max:3,step:1,className:"w-full"})]}),at("div",{children:[be("label",{className:"block text-[11px] text-white/40 mb-2",children:"Line style"}),be("div",{className:"flex gap-1.5 flex-wrap",children:OP.map(x=>be(fc,{active:JSON.stringify(f.crosshairDash)===JSON.stringify(x.dash),onClick:()=>n({crosshairDash:x.dash}),children:x.label},x.label))})]})]})]}),at(zn,{label:"Breaks",children:[be("div",{className:"flex gap-1.5 mb-3",children:be(Ir,{label:"Show breaks",active:f.showBreaks,onToggle:()=>n({showBreaks:!f.showBreaks})})}),f.showBreaks&&at("div",{className:"flex flex-col gap-3",children:[be(Sa,{label:"Breaks color",value:f.breaksColor,onChange:x=>n({breaksColor:x})}),at("div",{children:[at("label",{className:"block text-[11px] text-white/40 mb-1",children:["Line width - ",f.breaksWidth,"px"]}),be(Dn,{value:[f.breaksWidth],onValueChange:([x])=>n({breaksWidth:x}),min:1,max:3,step:1,className:"w-full"})]}),at("div",{children:[be("label",{className:"block text-[11px] text-white/40 mb-2",children:"Line style"}),be("div",{className:"flex gap-1.5 flex-wrap",children:OP.map(x=>be(fc,{active:JSON.stringify(f.breaksDash)===JSON.stringify(x.dash),onClick:()=>n({breaksDash:x.dash}),children:x.label},x.label))})]})]})]}),be(sl,{onReset:()=>n({showGrid:Ye.showGrid,gridHorizontalColor:Ye.gridHorizontalColor,gridVerticalColor:Ye.gridVerticalColor,crosshairMode:Ye.crosshairMode,crosshairColor:Ye.crosshairColor,crosshairWidth:Ye.crosshairWidth,crosshairDash:Ye.crosshairDash,showBreaks:Ye.showBreaks,breaksColor:Ye.breaksColor,breaksDash:Ye.breaksDash,breaksWidth:Ye.breaksWidth})})]}),u==="status"&&at("div",{className:"flex flex-col gap-4",children:[be(Ir,{label:"Show status line",active:f.showStatusLine,onToggle:()=>n({showStatusLine:!f.showStatusLine})}),f.showStatusLine&&at(dw,{children:[be(zn,{label:"Values displayed",children:be("div",{className:"flex flex-col gap-2",children:[["statusLineOHLC","O / H / L / C prices"],["statusLineVolume","Volume"],["statusLineDelta","Delta (ask vol \u2212 bid vol)"],["statusLineChange","Change & change %"]].map(([x,T])=>be(Ir,{label:T,active:f[x],onToggle:()=>n({[x]:!f[x]})},x))})}),at(zn,{label:`Font size - ${f.statusLineFontSize}px`,children:[be(Dn,{value:[f.statusLineFontSize],onValueChange:([x])=>n({statusLineFontSize:x}),min:9,max:14,step:1,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[9,10,11,12,13,14].map(x=>be("span",{children:x},x))})]})]}),be(sl,{onReset:()=>n({showStatusLine:Ye.showStatusLine,statusLineOHLC:Ye.statusLineOHLC,statusLineVolume:Ye.statusLineVolume,statusLineDelta:Ye.statusLineDelta,statusLineChange:Ye.statusLineChange,statusLineFontSize:Ye.statusLineFontSize})})]}),u==="chart"&&at("div",{className:"flex flex-col gap-5",children:[be(zn,{label:"Colors",children:at("div",{className:"flex flex-col gap-2",children:[be(Sa,{label:"Chart background",value:f.backgroundColor,onChange:x=>n({backgroundColor:x})}),be(Sa,{label:"Axis background",value:f.axisBackgroundColor,onChange:x=>n({axisBackgroundColor:x})}),be(Sa,{label:"Price line",value:f.priceLineColor,onChange:x=>n({priceLineColor:x})})]})}),be(zn,{label:"Overlays",children:at("div",{className:"flex flex-col gap-2",children:[be(Ir,{label:"Show bid line",active:f.showBidLine,onToggle:()=>n({showBidLine:!f.showBidLine})}),be(Ir,{label:"Show ask line",active:f.showAskLine,onToggle:()=>n({showAskLine:!f.showAskLine})}),be(Ir,{label:"Show mid line",active:f.showMidLine,onToggle:()=>n({showMidLine:!f.showMidLine})}),be(Ir,{label:"Show last trade line",active:f.showLastTradeLine,onToggle:()=>n({showLastTradeLine:!f.showLastTradeLine})}),be(Ir,{label:"Show price line",active:f.priceLineVisible,onToggle:()=>n({priceLineVisible:!f.priceLineVisible})}),be(Ir,{label:"Show fills",active:f.showFills,onToggle:()=>n({showFills:!f.showFills})})]})}),at(zn,{label:"Trade dots",children:[be(Ir,{label:"Show trade dots",active:f.showTradeDots,onToggle:()=>n({showTradeDots:!f.showTradeDots})}),f.showTradeDots&&at("div",{className:"mt-3",children:[at("label",{className:"block text-[11px] text-white/40 mb-1",children:["Dot size multiplier - ",f.tradeDotsSizeMult,"x"]}),be(Dn,{value:[f.tradeDotsSizeMult],onValueChange:([x])=>n({tradeDotsSizeMult:x}),min:0,max:5,step:.1,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[0,1,2,3,4,5].map(x=>at("span",{children:[x,"x"]},x))})]})]}),at(zn,{label:"Heatmap",children:[be(Ir,{label:"Show heatmap",active:f.showHeatmap,onToggle:()=>n({showHeatmap:!f.showHeatmap})}),f.showHeatmap&&be("div",{className:"flex flex-col gap-3",children:at("div",{children:[at("label",{className:"block text-[11px] text-white/40 mb-1",children:["Contrast - ",Math.round(f.heatmapContrast*100)]}),be(Dn,{value:[f.heatmapContrast],onValueChange:([x])=>{n({heatmapContrast:x})},min:0,max:1,step:.01,className:"w-full"}),at("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[be("span",{children:"0"}),be("span",{children:"50"}),be("span",{children:"100"})]})]})})]}),at(zn,{label:`Resampling delay - ${f.resamplingDebounce}ms`,children:[be(Dn,{value:[f.resamplingDebounce],onValueChange:([x])=>n({resamplingDebounce:x}),min:0,max:1e3,step:1,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[0,200,400,600,800,1e3].map(x=>at("span",{children:[x,"ms"]},x))})]}),at(zn,{label:"Horizon scroll animation",children:[be("div",{className:"flex gap-1.5 mb-3",children:["none","linear","easeOut","easeInOut"].map(x=>be(fc,{active:f.horizonScrollEasing===x,onClick:()=>n({horizonScrollEasing:x}),children:x==="none"?"None":x==="linear"?"Linear":x==="easeOut"?"Ease out":"Ease in-out"},x))}),f.horizonScrollEasing!=="none"&&be("div",{className:"mt-2",children:at(zn,{label:`Duration - ${f.horizonScrollDuration}ms`,children:[be(Dn,{value:[f.horizonScrollDuration],onValueChange:([x])=>n({horizonScrollDuration:x}),min:20,max:500,step:5,className:"w-full"}),be("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[20,100,200,300,400,500].map(x=>at("span",{children:[x,"ms"]},x))})]})})]}),be(OW,{onUpdate:n}),be(_W,{active:u==="chart"}),be(sl,{onReset:()=>n({backgroundColor:Ye.backgroundColor,axisBackgroundColor:Ye.axisBackgroundColor,showBidLine:Ye.showBidLine,showAskLine:Ye.showAskLine,showMidLine:Ye.showMidLine,showLastTradeLine:Ye.showLastTradeLine,showTradeDots:Ye.showTradeDots,tradeDotsSizeMult:Ye.tradeDotsSizeMult,heatmapContrast:Ye.heatmapContrast,heatmapColorBid:Ye.heatmapColorBid,heatmapColorAsk:Ye.heatmapColorAsk,priceLineVisible:Ye.priceLineVisible,showFills:Ye.showFills,priceLineColor:Ye.priceLineColor,sessionHighlightEnabled:Ye.sessionHighlightEnabled,sessionHighlightColor:Ye.sessionHighlightColor,resamplingDebounce:Ye.resamplingDebounce,horizonScrollEasing:Ye.horizonScrollEasing,horizonScrollDuration:Ye.horizonScrollDuration})})]}),u==="timezone"&&at("div",{className:"flex flex-col gap-5",children:[at(zn,{label:"Timezone",children:[be(AP,{value:f.timezone,onChange:x=>n({timezone:x}),use24Hour:f.use24HourClock,onOpenChange:p,horizon:t}),h&&be("div",{className:"h-[19rem]"})]}),be(zn,{label:"Display options",children:be("div",{className:"flex flex-col gap-2",children:be(Ir,{label:"24-hour clock",active:f.use24HourClock,onToggle:()=>n({use24HourClock:!f.use24HourClock})})})}),be(sl,{onReset:()=>n({timezone:Ye.timezone,use24HourClock:Ye.use24HourClock,showTimezoneLabel:Ye.showTimezoneLabel})})]}),u==="plugin"&&at("div",{className:"flex flex-col gap-5",children:[c.map((x,T)=>be(Hh,{field:x,drawing:w,onUpdate:k},zh(x,T))),be(sl,{onReset:()=>n({pluginSettings:{...C,[S]:{...i?.defaultSettings??{}}}})})]})]}),be("div",{className:"px-5 py-1 border-t border-white/6 shrink-0 pt-0",children:be("a",{href:"https://christtrade.com",className:"text-[10px] text-white/20 select-none font-mono",children:"ChristTrade Depth 0.12.21"})})]})]})}function OW({onUpdate:e}){let[t,n]=bs(!1),[r,o]=bs(!1),[a,i]=bs(!1);if(um(()=>n(lw()),[]),um(()=>{if(!r)return;let l=setTimeout(()=>o(!1),4e3);return()=>clearTimeout(l)},[r]),!t||a)return null;let s=()=>{if(!r){o(!0);return}let l=lm();l&&e(l),cm({force:!0}),o(!1),i(!0)};return at(zn,{label:"TradingView",children:[be("p",{className:"text-[11px] text-white/30 leading-relaxed",children:"Found TradingView chart preferences saved in this browser. Importing copies over colors, grid, margins, chart type and favorite drawings \u2014 anything without an equivalent here keeps its current value."}),at("button",{className:ee("flex items-center gap-2 text-[11px] transition-colors mt-1 self-start",r?"text-amber-400 hover:text-amber-300":"text-white/30 hover:text-white/60"),onClick:s,children:[be(Ud,{size:11}),r?"Click again to overwrite your current settings":"Import TradingView settings"]})]})}function _W({active:e}){let[t,n]=bs(mp),[r,o]=bs(0),[a,i]=bs(!1);um(()=>{e&&o(gp())},[e,t]),um(()=>{if(!a)return;let c=setTimeout(()=>i(!1),4e3);return()=>clearTimeout(c)},[a]);let s=()=>{let c=!t;vb(c),n(c)},l=()=>{if(!a){i(!0);return}xb(),i(!1),o(gp())};return at(zn,{label:"Saved data",children:[be(Ir,{label:"Save settings to this device",active:t,onToggle:s}),be("p",{className:"text-[11px] text-white/30 leading-relaxed",children:t?`Chart settings, favorite timeframes, drawing templates and plugin state are kept in this browser${r>0?` (${FW(r)})`:""}. They never leave your device.`:"Nothing is written to this browser. Every reload starts from defaults; anything saved earlier is ignored until you switch this back on."}),at("button",{className:ee("flex items-center gap-2 text-[11px] transition-colors mt-1 self-start",a?"text-red-400 hover:text-red-300":"text-white/30 hover:text-white/60"),onClick:l,children:[be(ho,{size:11}),a?"Click again to erase \u2014 this cannot be undone":"Clear saved data"]})]})}function FW(e){return e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`}function zn({label:e,children:t}){return at("div",{className:"flex flex-col gap-2.5",children:[be("p",{className:"text-[11px] font-medium text-white/40 uppercase tracking-wider",children:e}),t]})}function sl({onReset:e}){return at("button",{className:"flex items-center gap-2 text-[11px] text-white/30 hover:text-white/60 transition-colors mt-1",onClick:e,children:[be(ga,{size:11})," Reset to defaults"]})}function Ir({label:e,active:t,onToggle:n}){return at("button",{className:ee("w-full flex items-center justify-between px-3 py-2.5 rounded-lg border text-left transition-colors",t?"border-blue-500/30 bg-blue-500/8 text-white":"border-white/6 bg-white/3 text-white/50 hover:border-white/12 hover:bg-white/5 hover:text-white/70"),onClick:n,children:[be("span",{className:"text-[12px]",children:e}),be(Qr,{checked:t,onCheckedChange:n,className:"data-[state=checked]:bg-blue-500"})]})}function fc({active:e,onClick:t,children:n}){return be("button",{className:ee("flex items-center gap-1.5 px-3 py-1.5 rounded-lg border text-[11px] font-medium transition-colors",e?"border-blue-500/40 bg-blue-500/15 text-blue-300":"border-white/8 bg-white/4 text-white/40 hover:border-white/15 hover:bg-white/7 hover:text-white/70"),onClick:t,children:n})}function Sa({label:e,value:t,onChange:n}){return at("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-lg border border-white/6 bg-white/3",children:[be("span",{className:"text-[12px] text-white/60",children:e}),be("div",{className:"flex items-center gap-2",children:be(Lo,{onChange:n,value:t,className:"w-8 h-8 rounded-md border-2 border-border/50"})})]})}import*as qP from"react";import*as VP from"react";import{jsx as HW}from"react/jsx-runtime";var zW=Object.defineProperty,HP=(e,t)=>zW(e,"name",{value:t,configurable:!0}),zP="horizontal",VW=["horizontal","vertical"],WW=VP.forwardRef(HP(function(t,n){let{decorative:r,orientation:o=zP,...a}=t,i=WP(o)?o:zP,l=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return HW(dn.div,{"data-orientation":i,...l,...a,ref:n})},"Separator"));function WP(e){return VW.includes(e)}HP(WP,"isValidOrientation");var mw=WW;import{jsx as UW}from"react/jsx-runtime";var mc=qP.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>UW(mw,{ref:o,decorative:n,orientation:t,className:ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));mc.displayName=mw.displayName;import{useCallback as mo,useEffect as dm,useRef as ki,useState as jW}from"react";var GW={ms:1000000n,s:1000000000n,m:60000000000n,h:3600000000000n},YW=/^(\d+)(ms|s|m|h)$/,KW=5000000000n;function ag(e){let t=YW.exec(e);return t?BigInt(t[1])*GW[t[2]]:KW}function $W(e,t){return{mode:"realtime",status:"paused",stepSnap:!1,speed:1,stepSize:"5s",wallStart:0,dataStart:0n,datasetStart:e,loadedStart:e,dataEnd:t,rafHandle:0,lastBaseRedrawWall:0,_stallStart:void 0,_lastRafTime:void 0}}function XW(e){let t=Date.now()-e.wallStart;if(e.mode==="step"){let r=ag(e.stepSize),o=Math.max(0,Math.floor(t*e.speed/1e3));return e.stepSnap?o===0?e.dataStart:e.dataStart/r*r+BigInt(o)*r:e.dataStart+BigInt(o)*r}let n=BigInt(Math.max(0,Math.round(t*e.speed)))*1000000n;return e.dataStart+n}function UP(e){return e.mode==="step"?Number(ag(e.stepSize))*e.speed/1e3:e.speed*1e6}var ZW=5,QW=14n*24n*60n*60n*1000000000n;function jP({chartRefs:e,sharedHorizonRef:t,onRequestMore:n,onTick:r,eventBus:o,prefetch:a,clockSymbol:i}){let s=a?.safetyFactor??2.5,l=a?.minLeadMs??300,c=ki(i);dm(()=>{c.current=i});let u=mo(H=>{if(H===void 0)return!0;let W=c.current?.();return W===void 0||H===W},[]),d=ki($W(0n,0n)),m=ki(!1),[f,h]=jW({mode:"realtime",status:"paused",stepSnap:!1,speed:1,stepSize:"5s",datasetStart:0n,datasetEnd:0n}),p=ki(n);dm(()=>{p.current=n});let g=ki(!1),y=ki(!1),v=ki(null),b=ki(null),S=ki(600),C=ki(null);dm(()=>{let H=[o.on("data:prefetch-done",()=>{if(g.current=!1,C.current!==null){let W=performance.now()-C.current;C.current=null,S.current=S.current*.7+W*.3}}),o.on("data:no-more-forward",W=>{u(W?.symbol)&&(m.current=!0,b.current!==null&&(b.current=null,k(d.current.dataEnd,!0)))}),o.on("data:load",()=>{if(m.current=!1,y.current=!1,b.current=null,d.current._stallStart=void 0,v.current!==null){let W=d.current;W.status==="playing"&&(W.dataStart=v.current,W.wallStart=Date.now()),v.current=null}})];return()=>H.forEach(W=>W())},[o]);let w=ki(r);dm(()=>{w.current=r});let k=mo((H,W=!1)=>{t.current=H;let U=e.current;for(let V=0;V<U.length;V++)U[V]?.seekHorizon(H,W);w.current?.(H)},[e,t]),M=mo(H=>{if(g.current||m.current)return;g.current=!0,C.current=performance.now();let W=H;if(W===void 0){let U=d.current,V=UP(U);W=V>0?BigInt(Math.ceil(V*S.current*ZW)):0n;let K=U.dataEnd-U.loadedStart;K>0n&&W>K&&(W=K)}p.current?.(W&&W>0n?W:void 0)},[]),I=mo(H=>{let W=d.current;if(H>=W.loadedStart&&H<=W.dataEnd){b.current=null,k(H,!0);return}if(H>W.dataEnd&&H-W.dataEnd<=QW){if(m.current){b.current=null,k(W.dataEnd,!0);return}let U=H-W.dataEnd;b.current=H,M(U+U/8n);return}y.current||(y.current=!0,b.current=null,o.emit("data:seek-load",{tNs:H,fromNs:t.current}))},[k,M,o,t]),x=mo(()=>{let H=d.current;H.rafHandle&&(cancelAnimationFrame(H.rafHandle),H.rafHandle=0)},[]),T=mo(()=>{x(),d.current.status="paused",h(H=>({...H,status:"paused"})),k(t.current)},[x,k,t]),R=mo(()=>{let H=()=>{let W=d.current;if(W.status!=="playing")return;let U=XW(W);if(U<W.dataEnd){W._stallStart=void 0;let Z=UP(W);if(Z>0){let de=Number(W.dataEnd-U)/Z,ze=Math.max(l,S.current*s);de<ze&&M()}k(U),W.rafHandle=requestAnimationFrame(H);return}if(m.current){k(W.dataEnd),T(),o.emit("playback:pause",void 0),o.emit("playback:end",void 0);return}let V=U-W.dataEnd,K=(W.dataEnd-W.loadedStart)/2n;if(K>0n&&V>K){y.current||(y.current=!0,v.current=U,o.emit("data:seek-load",{tNs:U,fromNs:W.dataEnd})),k(W.dataEnd),W.rafHandle=requestAnimationFrame(H);return}k(W.dataEnd),W.dataStart=W.dataEnd,W.wallStart=Date.now(),M(),W._stallStart===void 0&&(W._stallStart=Date.now()),W.rafHandle=requestAnimationFrame(H)};d.current.rafHandle=requestAnimationFrame(H)},[k,T,o,M,s,l]),P=mo((H,W)=>{let U=d.current;U.datasetStart===0n&&(U.datasetStart=H,t.current===0n&&(t.current=H)),U.loadedStart=H;let V=W>U.dataEnd;if(U.dataEnd=W,V&&(m.current=!1),U._stallStart!==void 0&&V&&(U._stallStart=void 0,U.wallStart=Date.now(),U.dataStart=t.current),b.current!==null&&V){let K=b.current;b.current=null,k(K<=U.dataEnd?K:U.dataEnd,!0)}h(K=>({...K,datasetStart:U.datasetStart,datasetEnd:U.dataEnd}))},[t,k]),D=mo(()=>{let H=d.current;if(!H.dataEnd)return;x();let W=t.current;H.status="playing",H.wallStart=Date.now(),H.dataStart=W,H.lastBaseRedrawWall=0,H._lastRafTime=void 0,H._stallStart=void 0,h(U=>({...U,status:"playing"})),R()},[R,x,t]),N=mo(()=>{d.current.status==="playing"&&T();let H=d.current,W=ag(H.stepSize),U=t.current,V=H.stepSnap&&H.mode==="step"?U/W*W+W:U+W;I(V)},[T,I,t]),O=mo(()=>{d.current.status==="playing"&&T();let H=d.current,W=ag(H.stepSize),U=t.current,V;if(H.stepSnap&&H.mode==="step"){let K=U/W*W;V=K<U?K:K-W}else V=U-W;I(V)},[T,I,t]),A=mo(()=>{d.current.status==="playing"&&T(),I(d.current.datasetStart)},[T,I]),B=mo(()=>{d.current.status==="playing"&&T(),I(d.current.dataEnd)},[T,I]),E=mo(H=>{let W=d.current,U=W.status==="playing";W.speed=H,h(V=>({...V,speed:H})),U&&(W.wallStart=Date.now(),W.dataStart=t.current)},[t]),L=mo(H=>{let W=d.current;W.stepSize=H,W.status==="playing"&&(W.wallStart=Date.now(),W.dataStart=t.current),h(U=>({...U,stepSize:H}))},[t]),z=mo(H=>{let W=d.current;W.mode=H,W.status==="playing"&&(W.wallStart=Date.now(),W.dataStart=t.current),h(U=>({...U,mode:H}))},[t]),Y=mo(H=>{let W=d.current;W.stepSnap=H,W.status==="playing"&&(W.wallStart=Date.now(),W.dataStart=t.current),h(U=>({...U,stepSnap:H}))},[t]),G=mo(H=>{d.current.status==="playing"&&T(),I(H)},[T,I]);return dm(()=>()=>x(),[x]),{ui:f,notifyDataBounds:P,play:D,pause:T,stepForward:N,stepBack:O,jumpToStart:A,jumpToEnd:B,setSpeed:E,setStepSize:L,setMode:z,setStepSnap:Y,scrub:G,pbRef:d}}import fm from"react";import Wse from"react-dom";function JW(e){if(!e||typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var qse=Array(12).fill(0);var e8=1,t8=100,GP=e=>{var t;return typeof e?.id=="number"||(e==null||(t=e.id)==null?void 0:t.length)>0?e.id:e8++},pw=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),this.getActiveToasts().forEach(n=>t(n)),()=>{let n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t],this.trimHistory()},this.trimHistory=()=>{let t=this.toasts.length-t8;t<=0||(this.toasts=this.toasts.filter(n=>t>0&&this.dismissedToasts.has(n.id)?(this.dismissedToasts.delete(n.id),t--,!1):!0))},this.create=t=>{let{message:n,...r}=t,o=GP(t),a=this.pendingDismissals.get(o);a!==void 0&&(cancelAnimationFrame(a),this.pendingDismissals.delete(o),this.dismissedToasts.delete(o));let i=this.dismissedToasts.has(o),s=t.dismissible===void 0?!0:t.dismissible;return i&&(this.dismissedToasts.delete(o),this.toasts=this.toasts.filter(c=>c.id!==o)),(i?void 0:this.toasts.find(c=>c.id===o))?this.toasts=this.toasts.map(c=>c.id===o?(this.publish({...c,...t,id:o,title:n}),{...c,...t,id:o,dismissible:s,title:n}):c):this.addToast({title:n,...r,dismissible:s,id:o}),o},this.dismiss=t=>{if(t==null)return this.getActiveToasts().forEach(r=>{this.dismissedToasts.add(r.id),this.subscribers.forEach(o=>o({id:r.id,dismiss:!0}))}),t;this.dismissedToasts.add(t);let n=this.pendingDismissals.get(t);return n!==void 0&&cancelAnimationFrame(n),this.pendingDismissals.set(t,requestAnimationFrame(()=>{this.pendingDismissals.delete(t),this.subscribers.forEach(r=>r({id:t,dismiss:!0}))})),t},this.message=(t,n)=>this.create({...n,message:t,type:void 0}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));let o=Promise.resolve(t instanceof Function?t():t),a=r!==void 0,i,s=o.then(async c=>{if(i=["resolve",c],fm.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(r8(c)&&!c.ok){a=!1;let d=typeof n.error=="function"?await n.error(`HTTP error! status: ${c.status}`):n.error,m=typeof n.description=="function"?await n.description(`HTTP error! status: ${c.status}`):n.description,h=typeof d=="object"&&!fm.isValidElement(d)?d:{message:d};this.create({id:r,type:"error",description:m,...h})}else if(c instanceof Error){a=!1;let d=typeof n.error=="function"?await n.error(c):n.error,m=typeof n.description=="function"?await n.description(c):n.description,h=typeof d=="object"&&!fm.isValidElement(d)?d:{message:d};this.create({id:r,type:"error",description:m,...h})}else if(n.success!==void 0){a=!1;let d=typeof n.success=="function"?await n.success(c):n.success,m=typeof n.description=="function"?await n.description(c):n.description,h=typeof d=="object"&&!fm.isValidElement(d)?d:{message:d};this.create({id:r,type:"success",description:m,...h})}}).catch(async c=>{if(i=["reject",c],n.error!==void 0){a=!1;let u=typeof n.error=="function"?await n.error(c):n.error,d=typeof n.description=="function"?await n.description(c):n.description,f=typeof u=="object"&&!fm.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:d,...f})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((c,u)=>s.then(()=>i[0]==="reject"?u(i[1]):c(i[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(t,n)=>{let r=GP(n);return this.create({...n,jsx:t(r),id:r,type:void 0}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},Ka=new pw,n8=(e,t)=>Ka.message(e,t),r8=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",o8=n8,a8=()=>Ka.toasts,i8=()=>Ka.getActiveToasts(),Ti=Object.assign(o8,{success:Ka.success,info:Ka.info,warning:Ka.warning,error:Ka.error,custom:Ka.custom,message:Ka.message,promise:Ka.promise,dismiss:Ka.dismiss,loading:Ka.loading},{getHistory:a8,getToasts:i8});JW("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");var mm=class mm{constructor(){ae(this,"handlers",new Map);ae(this,"interceptors",new Map);ae(this,"emitting",new Set);ae(this,"stickyCache",new Map)}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),mm.STICKY.has(t)&&this.stickyCache.has(t)&&n(this.stickyCache.get(t)),()=>this.off(t,n)}hasListeners(t){return(this.handlers.get(t)?.size??0)>0}off(t,n){this.handlers.get(t)?.delete(n)}intercept(t,n){return this.interceptors.has(t)||this.interceptors.set(t,[]),this.interceptors.get(t).push(n),()=>{let r=this.interceptors.get(t);if(r){let o=r.indexOf(n);o!==-1&&r.splice(o,1)}}}emit(t,n){mm.STICKY.has(t)&&this.stickyCache.set(t,n);let r=this.interceptors.get(t);if(!r||r.length===0){this.handlers.get(t)?.forEach(i=>i(n));return}if(this.emitting.has(t)){console.error(`[TypedEventBus] Interceptor loop detected on '${t}' - blocked`);return}this.emitting.add(t);let o=0,a=i=>{o<r.length?r[o++](i,a):this.handlers.get(t)?.forEach(s=>s(i))};try{a(n)}finally{this.emitting.delete(t)}}clear(){this.handlers.clear(),this.interceptors.clear()}};ae(mm,"STICKY",new Set(["account:update","playback:tick","trading:ticket-requested"]));var pc=mm;import{useCallback as s8,useEffect as ig,useRef as pm,useState as Vi}from"react";import{Fragment as YP,jsx as On,jsxs as oa}from"react/jsx-runtime";var l8=150,c8=250;function hw({eventBus:e,symbol:t,onSymbolChange:n}){let[r,o]=Vi(!1),[a,i]=Vi(!1),[s,l]=Vi(!1),[c,u]=Vi(!1),[d,m]=Vi([]),[f,h]=Vi(""),[p,g]=Vi(void 0),[y,v]=Vi(!1),[b,S]=Vi(null),[C,w]=Vi(new Set),k=pm(null),M=pm(null),I=pm(null),x=pm(!1),T=pm(0),R=()=>o(A=>!A),P=s8((A,B)=>{let E=pn();I.current=E,x.current=!!B,B?l(!0):i(!0),S(null),e.emit("data:search-symbols",{requestId:E,request:{query:A,limit:l8,cursor:B}})},[e]);ig(()=>{let A=[e.on("data:search-symbols-response",B=>{if(B.requestId!==I.current)return;T.current=B.debounceMs;let E=B.symbols.map(L=>({...L,id:pn()}));m(L=>x.current?[...L,...E]:E),v(B.hasMore),g(B.cursor),i(!1),l(!1)}),e.on("data:search-symbols-error",B=>{B.requestId===I.current&&(S({code:B.code,message:B.message}),i(!1),l(!1))}),e.on("chart:open-symbol-select",()=>{R()})];return()=>A.forEach(B=>B())},[e]),ig(()=>{if(!r){let L=I.current;I.current=null,L&&e.emit("data:search-symbols-cancel",{requestId:L}),h(""),S(null);return}let A=setTimeout(()=>M.current?.focus(),40),B=L=>{k.current&&!k.current.contains(L.target)&&o(!1)},E=L=>{L.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",B),document.addEventListener("keydown",E),()=>{clearTimeout(A),document.removeEventListener("mousedown",B),document.removeEventListener("keydown",E)}},[r,e]),ig(()=>{if(!r)return;if(!T.current){P(f);return}let A=setTimeout(()=>P(f),T.current);return()=>clearTimeout(A)},[r,f,P]),ig(()=>{if(!a){u(!1);return}let A=setTimeout(()=>u(!0),c8);return()=>clearTimeout(A)},[a]);let D=A=>{n(A),o(!1)},N=A=>{w(B=>{let E=new Set(B);return E.has(A)?E.delete(A):E.add(A),E})},O=b?Hv(b.code,b.message):null;return oa("div",{className:"relative",ref:k,children:[oa("button",{onClick:R,className:ee("relative group flex items-center h-7 pl-2.5 pr-2 rounded-md w-24 overflow-hidden","border transition-colors duration-150 select-none",r?"border-border bg-muted/30":"border-transparent hover:bg-[#1a1d23]/30 hover:border-border"),children:[On("div",{className:"relative flex-1 min-w-0 overflow-hidden",style:{WebkitMaskImage:"linear-gradient(to right, black calc(100% - 1.25rem), transparent)",maskImage:"linear-gradient(to right, black calc(100% - 1.25rem), transparent)"},children:On("span",{className:"block whitespace-nowrap text-[12px] font-semibold tracking-tight text-slate-100 uppercase leading-none",children:t})}),On(Zn,{size:10,className:ee("shrink-0 ml-1 opacity-50 text-slate-400 transition-transform duration-150",r&&"rotate-180")})]}),r&&oa("div",{className:"absolute left-0 top-full mt-1.5 z-50 flex flex-col w-[35rem] max-h-[26rem] rounded-lg border border-[#1e2128] bg-[#16181d] shadow-2xl overflow-hidden",children:[oa("div",{className:"flex items-center gap-2.5 px-3 h-11 border-b border-[#1e2128] shrink-0",children:[On(li,{size:14,className:"text-slate-600 shrink-0"}),On("input",{ref:M,value:f,onChange:A=>h(A.target.value),placeholder:"Search symbol, name or exchange\u2026",className:"w-full h-full bg-transparent outline-none text-[13px] text-slate-200 placeholder:text-slate-600"})]}),On("div",{className:"flex-1 min-h-0 overflow-y-auto py-1",children:O?oa("div",{className:"flex flex-col items-center justify-center py-14 gap-1.5 px-8 text-center",children:[On("span",{className:ee(O.tier==="error"?"text-rose-400/80":"text-slate-500"),children:O.icon}),On("div",{className:"text-[13px] text-slate-300",children:O.title}),On("div",{className:"text-[11px] text-slate-500 leading-relaxed",children:O.body}),O.canRetry&&On("button",{onClick:()=>P(f),className:"mt-1.5 h-6 px-2.5 rounded border border-[#1e2128] bg-[#0e1014] text-[11px] text-slate-300 hover:border-[#08b3de]/40 hover:text-white transition-colors",children:"Try again"})]}):c&&!d.length?On("div",{className:"flex items-center justify-center py-16 text-slate-600",children:On(Ni,{size:18,className:"animate-spin"})}):!d.length&&!a?oa("div",{className:"flex flex-col items-center justify-center py-16 gap-1 text-slate-600",children:[On("div",{className:"text-[13px] text-slate-500",children:"No symbols found"}),f&&oa("div",{className:"text-[11px]",children:['Nothing matches "',f.trim(),'"']})]}):oa(YP,{children:[d.map(A=>On(u8,{sym:A,active:A.symbol===t,expanded:C.has(A.id),onPick:D,onToggle:()=>N(A.id)},A.id)),y&&On("button",{onClick:()=>P(f,p),disabled:s,className:"w-full h-8 flex items-center justify-center gap-1.5 text-[11px] text-slate-500 hover:text-slate-300 hover:bg-[#1a1d23] transition-colors disabled:hover:bg-transparent",children:s?On(Ni,{size:12,className:"animate-spin"}):"Load more"})]})}),oa("div",{className:"flex items-center gap-2 h-7 px-3 border-t border-[#1e2128] shrink-0",children:[oa("span",{className:"text-[10px] text-slate-600 tabular-nums",children:[d.length,y?"+":""," ",d.length===1?"symbol":"symbols"]}),(a||s)&&On(Ni,{size:10,className:"animate-spin text-slate-600"})]})]})]})}function u8({sym:e,active:t,expanded:n,onPick:r,onToggle:o}){let a=!!e.subsymbols?.length;return oa(YP,{children:[oa("button",{onClick:()=>r(e.symbol),className:ee("group w-full flex items-center gap-3 pl-3 pr-1.5 h-9 text-left transition-colors duration-200 hover:duration-0",t?"bg-[#1a1d23]":"hover:bg-[#1a1d23]"),children:[t?On("div",{className:"w-1 h-1 rounded-full bg-[#08b3de] shrink-0"}):On("div",{className:"w-1 shrink-0"}),e?.icon&&On(Xh,{icon:e.icon,size:24,fallback:e.symbol}),On("span",{className:ee("text-[12px] font-semibold uppercase tracking-tight w-24 shrink-0 truncate",t?"text-white":"text-slate-300"),children:e.symbol}),On("span",{className:"text-[11px] text-slate-500 truncate flex-1 group-hover:text-slate-400",children:e.description??e?.longName??""}),e.type&&On("span",{className:"text-[9px] font-medium uppercase tracking-wider text-slate-500 px-1.5 py-0.5 rounded border border-[#1e2128] bg-[#0e1014] shrink-0",children:e.type}),On("span",{className:"text-[11px] text-slate-600 w-14 shrink-0 truncate",children:e.exchange??""}),a?On("span",{role:"button",tabIndex:0,onClick:i=>{i.stopPropagation(),o()},className:"w-6 h-6 flex items-center justify-center rounded text-slate-600 hover:text-slate-300 hover:bg-[#1e2128] shrink-0",children:On(Zn,{size:13,className:ee("transition-transform duration-150",n&&"rotate-180")})}):On("span",{className:"w-6 shrink-0"})]}),a&&n&&e.subsymbols.map(i=>oa("button",{onClick:()=>r(i.symbol),className:"group w-full flex items-center gap-3 pl-3 pr-1.5 h-8 text-left bg-[#121419] hover:bg-[#1a1d23] transition-colors",children:[On("div",{className:"w-1 shrink-0"}),oa("span",{className:"w-24 shrink-0 flex items-center gap-2",children:[On("span",{className:"w-3 h-px bg-[#272b33] shrink-0"}),On("span",{className:"text-[11px] font-medium uppercase tracking-tight text-slate-400 truncate group-hover:text-slate-200",children:i.symbol})]}),On("span",{className:"text-[11px] text-slate-600 truncate flex-1 group-hover:text-slate-500",children:i.longName??i.description??""}),i.type&&On("span",{className:"text-[9px] font-medium uppercase tracking-wider text-slate-600 px-1.5 py-0.5 rounded border border-[#1e2128] shrink-0",children:i.type}),On("span",{className:"text-[11px] text-slate-600 w-14 shrink-0 truncate",children:i.exchange??""}),On("span",{className:"w-6 shrink-0"})]},i.symbol))]})}var gw=class{constructor(){ae(this,"handlers",new Map);ae(this,"charts",new Map);ae(this,"focusedChartId",null)}registerChart(t){this.charts.set(t.id,t),this.emit("global:chart-registered",{id:t.id,chart:t})}unregisterChart(t){this.charts.delete(t),this.focusedChartId===t&&(this.focusedChartId=null,this.emit("global:focus-changed",{chartId:null})),this.emit("global:chart-unregistered",{id:t})}setFocus(t){this.focusedChartId!==t&&(this.focusedChartId=t,this.emit("global:focus-changed",{chartId:t}))}getChart(t){return this.charts.get(t)??null}getCharts(){return this.charts}getFocusedChartId(){return this.focusedChartId}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),()=>this.handlers.get(t)?.delete(n)}emit(t,n){this.handlers.get(t)?.forEach(r=>r(n))}once(t,n){let r=this.on(t,o=>{r(),n(o)});return r}broadcastTo(t,n,r){this.charts.get(t)?.eventBus.emit(n,r)}broadcastAll(t,n){for(let r of this.charts.values())r.eventBus.emit(t,n)}},Eu=new gw;import{useEffect as ym,useMemo as k8,useRef as vm,useState as u2}from"react";import{useCallback as ir,useRef as ys,useState as b8}from"react";import{jsx as hc,jsxs as bw}from"react/jsx-runtime";var KP={success:{chip:"bg-emerald-500/10",fg:"text-emerald-600 dark:text-emerald-400"},loss:{chip:"bg-rose-500/10",fg:"text-rose-600 dark:text-rose-400"},info:{chip:"bg-sky-500/10",fg:"text-sky-600 dark:text-sky-400"},neutral:{chip:"bg-muted",fg:"text-muted-foreground"}};function d8({tone:e,icon:t,title:n,subtitle:r,metric:o,metricTone:a,metricSub:i}){let s=KP[e],l=KP[a??e];return bw("div",{className:ee("pointer-events-auto flex w-full select-none items-center gap-3","rounded-xl border border-border/70 bg-popover/95 px-3.5 py-3","text-popover-foreground shadow-lg shadow-black/[0.08] ring-1 ring-black/[0.02]","backdrop-blur-sm"),children:[hc("span",{className:ee("grid size-9 shrink-0 place-items-center rounded-lg",s.chip,s.fg),children:hc(t,{className:"size-[18px]",strokeWidth:2.25,"aria-hidden":!0})}),bw("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[hc("span",{className:"truncate text-[13px] font-medium leading-tight text-foreground",children:n}),r!=null&&hc("span",{className:"truncate text-[12px] leading-tight text-muted-foreground",children:r})]}),o!=null&&bw("div",{className:"flex shrink-0 flex-col items-end gap-0.5 pl-1",children:[hc("span",{className:ee("text-[13px] font-semibold leading-tight tabular-nums",l.fg),children:o}),i!=null&&hc("span",{className:"text-[11px] leading-tight tabular-nums text-muted-foreground",children:i})]})]})}function sg(e,t=4200){return Ti.custom(()=>hc(d8,{...e}),{duration:t,position:"bottom-left",style:{background:"transparent",border:"none",boxShadow:"none",padding:0}})}var f8=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",signDisplay:"always",minimumFractionDigits:2,maximumFractionDigits:2});function m8(e){return f8.format(e)}function p8(e){return`${e>=0?"+":""}${e.toFixed(2)}R`}function h8(e){if(!e||e<=0)return 2;let t=e.toString(),n=t.indexOf(".");return n===-1?0:t.length-n-1}function $P(e,t){let n=h8(t);return e.toLocaleString("en-US",{minimumFractionDigits:n,maximumFractionDigits:n})}function XP(e){return e==="long"?"Long":e==="short"?"Short":"Position"}function g8(e,t){switch(e){case"tp":return"Take-profit hit";case"sl":return"Stop-loss hit";case"manual":return"Closed manually";case"market":return"Market order";case"limit":return"Limit order";case"stop":return"Stop order";default:return t?"Partial close":"Position closed"}}function ZP(e){let t=XP(e.side),n=e.qty===1?"contract":"contracts";sg({tone:"success",icon:e.side==="short"?Dd:Nd,title:`${t} ${e.symbol} opened`,subtitle:`Filled ${e.qty} ${n} @ ${$P(e.entryPrice,e.tickSize)}`})}function QP(e){let t=e.partial??!1,n=e.pnl>.005?"success":e.pnl<-.005?"loss":"neutral",r=XP(e.side),o=t?`Scaled out of ${r} ${e.symbol}`:n==="success"?`${r} ${e.symbol} closed in profit`:n==="loss"?e.reason==="sl"?`${r} ${e.symbol} stopped out`:`${r} ${e.symbol} closed in the red`:`${r} ${e.symbol} closed at breakeven`,a=e.rMultiple!=null&&Number.isFinite(e.rMultiple)&&Math.abs(e.rMultiple)>.001;sg({tone:n,icon:n==="success"?_l:n==="loss"?pf:Yo,title:o,subtitle:g8(e.reason,t),metric:m8(e.pnl),metricTone:n,metricSub:a?p8(e.rMultiple):void 0})}function JP(e,t){let n=t?.tone??"neutral";sg({tone:n,icon:n==="success"?Hs:n==="loss"?ba:n==="info"?Jc:Jc,title:e,subtitle:t?.description})}function Ou(e){let t=e.kind==="tp"?{icon:ff,noun:"Take-profit"}:e.kind==="sl"?{icon:uf,noun:"Stop-loss"}:{icon:Yo,noun:"Break-even"},n=e.kind==="be"||e.created?"set":"moved";sg({tone:"success",icon:t.icon,title:`${t.noun} ${n}`,subtitle:`${e.symbol} @ ${$P(e.price,e.tickSize)}`},2800)}function lg(e){let t=e.toUpperCase();return t.includes("MNQ")?2:t.includes("MES")?5:t.includes("NQ")?20:t.includes("ES")?50:1}function _u(e,t,n){return(e.side==="long"?1:-1)*(t-e.entryPrice)*e.remainingQuantity*n}function hm(e,t,n){return e.entryPrice===0?0:_u(e,t,n)/(e.entryPrice*e.remainingQuantity)}function e2(e,t=2){return`${e>=0?"+":""}$${Math.abs(e).toFixed(t)}`}var nr={order:e=>`order:${e}`,position:e=>`position:${e}`,tp:(e,t)=>`tp:${e}:${t}`,sl:(e,t)=>`sl:${e}:${t}`,be:e=>`be:${e}`,orderTp:(e,t)=>`order-tp:${e}:${t}`,orderSl:(e,t)=>`order-sl:${e}:${t}`};function n2(e){return e.reduce((t,n)=>t+n.qty,0)}function y8(e,t){let n=t==="tp"?e.takeProfits:e.stopLosses,r=n2(n??[]);return Math.max(1,e.remainingQuantity-r)}function v8(e,t){let n=t==="tp"?e.bracket?.takeProfits:e.bracket?.stopLosses,r=n2(n??[]);return Math.max(1,e.quantity-r)}function t2(e){return(e.type==="limit"||e.type==="stop_limit"&&e.triggered?e.price:e.stopPrice)||e.price||e.stopPrice||0}function yw(e,t){return e??lg(t)}function gm(e,t,n,r,o){return o*r*(e==="short"?t-n:n-t)}function bm(e){return(e>=0?"+$":"-$")+Math.abs(e).toFixed(2)}function r2(e={}){let{onEvent:t,formatPnlLabel:n,tickSize:r,tickValue:o,markMode:a="conservative",onUpdatePosition:i,onUpdateOrder:s,onAmendOrder:l,onAmendBracket:c,onCancelOrder:u,onClosePosition:d,onReversePosition:m,onContextMenu:f}=e,h=ys(new Map),p=ys(new Map),g=ys([]),y=ys(new Map),v=ys(new Map),b=ys(0),S=ys(null),C=ys(null),w=ir(_=>{C.current=_},[]),k=ir(_=>({setLabel(ie){let se=y.current.get(_);se&&y.current.set(_,{...se,label:ie}),C.current?.()},setPrice(ie){let se=y.current.get(_);se&&y.current.set(_,{...se,price:ie}),C.current?.()},patch(ie){let se=y.current.get(_);se&&y.current.set(_,{...se,...ie}),C.current?.()}}),[]),[M,I]=b8([]),x=ir(_=>{t?.(_)},[t]),T=ys(!1),R=ir(()=>{T.current||(T.current=!0,queueMicrotask(()=>{T.current=!1,I([...y.current.values()])}))},[]),P=ir(_=>{let ie=v.current.get(_.symbol);return ie?a==="bid"?ie.bid:a==="ask"?ie.ask:a==="last"?ie.last??(ie.bid+ie.ask)/2:a==="mid"?(ie.bid+ie.ask)/2:_.side==="long"?ie.bid:ie.ask:_.currentPrice},[a]),D=ir((_,ie,se,Se)=>{let Re=h.current.get(_);if(!Re)return;let ye=Re.bracket?.takeProfits??[],$e=Re.bracket?.stopLosses??[],Ue={...Re,bracket:{...Re.bracket,takeProfits:ie==="tp"?ye.map((Be,xt)=>xt===se?{...Be,price:Se}:Be):ye,stopLosses:ie==="sl"?$e.map((Be,xt)=>xt===se?{...Be,price:Se}:Be):$e},updatedAt:v.current.get(Re.symbol).ts};h.current.set(_,Ue);let je=ie==="tp"?nr.orderTp(_,se):nr.orderSl(_,se),ht=y.current.get(je);ht&&y.current.set(je,{...ht,price:Se}),s(Ue),R()},[R]),N=ir((_,ie,se,Se,Re)=>{let ye=_==="tp"?nr.orderTp(ie.id,Re):nr.orderSl(ie.id,Re),$e=k(ye),Ue=_==="tp"?ie.bracket?.takeProfits:ie.bracket?.stopLosses,je=`${_.toUpperCase()}${(Ue?.length??0)>1?Re+1:""}`,ht=t2(ie),Be=xt=>`${je} ${bm(gm(ie.side,ht,xt,Se,yw(o,ie.symbol)))}`;return{id:ye,kind:_,side:ie.side,price:se,label:Be(se),qty:Se,opacity:.38,lineDash:[1.5,3],badges:["PENDING"],tickSize:r,movable:!0,locked:!1,showPricePill:!0,showLinePill:!0,onMove:xt=>$e.setLabel(Be(xt)),afterMove:xt=>D(ie.id,_,Re,xt)}},[r,o,D,k]),O=ir((_,ie,se,Se)=>N("tp",_,ie,se,Se),[N]),A=ir((_,ie,se,Se)=>N("sl",_,ie,se,Se),[N]),B=ir((_,ie=!1)=>{let se=`order-tp:${_.id}:`,Se=`order-sl:${_.id}:`;for(let $e of y.current.keys())($e.startsWith(se)||$e.startsWith(Se))&&y.current.delete($e);if(ie)return;let Re=_.bracket?.takeProfits??[],ye=_.bracket?.stopLosses??[];Re.forEach(({price:$e,qty:Ue},je)=>{y.current.set(nr.orderTp(_.id,je),O(_,$e,Ue,je))}),ye.forEach(({price:$e,qty:Ue},je)=>{y.current.set(nr.orderSl(_.id,je),A(_,$e,Ue,je))})},[O,A]),E=ir(_=>{let ie=t2(_),se=_.status==="working"||_.status==="partial"||_.status==="pending",Se=_.type==="limit"?"limit":_.type==="stop"?"stop":_.type==="stop_limit"?"stop_limit":"alert",Re=_.side==="short"?"Sell":"Buy",ye=_.type==="limit"?"Limit":_.type==="stop"?"Stop":_.type==="stop_limit"?"Stop Limit":"Market",$e=[`${_.filledQuantity}/${_.quantity}`];_.tif&&$e.push(_.tif.toUpperCase());let Ue=_.bracket?.takeProfits?.length??0,je=_.bracket?.stopLosses?.length??0;return{id:nr.order(_.id),kind:Se,side:_.side,price:ie,label:`${Re} ${ye}`,qty:_.quantity,badges:$e,ghosts:se,numGhosts:Math.max(Ue,je)+1,tickSize:r,movable:se&&!!l,locked:!se,visible:se,showPricePill:!0,showLinePill:!0,afterMove:l?ht=>l(_.id,ht):void 0,onClose:u?()=>u(_.id):void 0,onContextMenu:f?(ht,Be)=>f("order",_.id,ht,Be):void 0}},[r,l,u,f]),L=ir(_=>{let ie=P(_),se=o,Se=ie!=null?_u(_,ie,se):_.unrealizedPnl,Re=ie!=null?hm(_,ie,se):_.unrealizedPnlPct,ye=Se?`${e2(Se)}`:"",$e=ie,Ue=_.takeProfits?.length??0,je=_.stopLosses?.length??0,ht=Math.max(Ue,je)+1,Be=_.side==="long"?"Buy":"Sell",xt=_.type==="limit"?"Limit":_.type==="stop"?"Stop":_.type==="stop_limit"?"Stop Limit":"Market";return{id:nr.position(_.id),kind:"entry",side:_.side,price:_.entryPrice,label:`${Be} ${xt}`,qty:_.remainingQuantity,pnl:Se,pnlPct:Re,pnlLabel:ye,entryPrice:_.entryPrice,bandToPrice:$e,bandOpacity:.06,ghosts:!0,numGhosts:ht,tickSize:r,movable:!1,locked:!1,showPricePill:!0,showLinePill:!0,showPnlPill:Se!=null,onClose:d?()=>d(_.id):void 0,onReverse:m?()=>m(_.id):void 0,onContextMenu:f?(fn,In)=>f("position",_.id,fn,In):void 0}},[P,n,r,o,d,m,f]),z=ir((_,ie,se)=>{let Se=nr.tp(_.id,se),Re=k(Se),ye=yw(o,_.symbol),$e=Math.min(_.remainingQuantity,ie.qty),Ue=bm(gm(_.side,_.entryPrice,ie.price,$e,ye));return{id:Se,kind:"tp",side:_.side,price:ie.price,label:`TP ${Ue}`,qty:ie.qty,tickSize:r,movable:!!c,showPricePill:!0,showLinePill:!0,onMove:je=>{let ht=Math.min(_.remainingQuantity,ie.qty);Re.setLabel(`TP ${bm(gm(_.side,_.entryPrice,je,ht,ye))}`)},afterMove:c?je=>{c({positionId:_.id,which:"tp",index:se,levelId:ie.id??String(se),price:je,qty:ie.qty}),Ou({kind:"tp",symbol:_.symbol,price:je,tickSize:r})}:void 0,onClose:()=>W(_,"tp",se,ie),onContextMenu:f?(je,ht)=>f("position",_.id,je,ht):void 0}},[r,c,f,k]),Y=ir((_,ie,se)=>{let Se=nr.sl(_.id,se),Re=k(Se),ye=yw(o,_.symbol),$e=Math.min(_.remainingQuantity,ie.qty),Ue=bm(gm(_.side,_.entryPrice,ie.price,$e,ye));return{id:Se,kind:"sl",side:_.side,price:ie.price,label:`SL ${Ue}`,qty:ie.qty,tickSize:r,movable:!!c,showPricePill:!0,showLinePill:!0,onMove:je=>{let ht=Math.min(_.remainingQuantity,ie.qty);Re.setLabel(`SL ${bm(gm(_.side,_.entryPrice,je,ht,ye))}`)},afterMove:c?je=>{c({positionId:_.id,which:"sl",index:se,levelId:ie.id??String(se),price:je,qty:ie.qty}),Ou({kind:"sl",symbol:_.symbol,price:je,tickSize:r})}:void 0,onClose:()=>W(_,"sl",se,ie),onContextMenu:f?(je,ht)=>f("position",_.id,je,ht):void 0}},[r,c,f,k]),G=ir(_=>_.bePrice==null?null:{id:nr.be(_.id),kind:"be",side:_.side,price:_.bePrice,label:"BE",qty:_.remainingQuantity,tickSize:r,movable:!!c,showPricePill:!0,showLinePill:!0,afterMove:c?ie=>{c({positionId:_.id,which:"be",index:0,levelId:"be",price:ie,qty:_.remainingQuantity}),Ou({kind:"be",symbol:_.symbol,price:ie,tickSize:r})}:void 0},[r,c]),H=ir(_=>{if(_.side==="flat"||_.remainingQuantity<=0){y.current.delete(nr.position(_.id)),y.current.delete(nr.be(_.id));let Re=`tp:${_.id}:`,ye=`sl:${_.id}:`;for(let $e of y.current.keys())($e.startsWith(Re)||$e.startsWith(ye))&&y.current.delete($e);return}let ie=(Re,ye)=>{if(Re===S.current){let $e=y.current.get(Re);if($e){y.current.set(Re,{...ye,price:$e.price,label:$e.label});return}}y.current.set(Re,ye)};y.current.set(nr.position(_.id),L(_));let se=_.takeProfits??[];se.forEach((Re,ye)=>{ie(nr.tp(_.id,ye),z(_,Re,ye))});for(let Re=se.length;;Re++){let ye=nr.tp(_.id,Re);if(!y.current.has(ye))break;y.current.delete(ye)}let Se=_.stopLosses??[];Se.forEach((Re,ye)=>{ie(nr.sl(_.id,ye),Y(_,Re,ye))});for(let Re=Se.length;;Re++){let ye=nr.sl(_.id,Re);if(!y.current.has(ye))break;y.current.delete(ye)}if(_.bePrice==null)y.current.delete(nr.be(_.id));else{let Re=G(_);Re&&ie(nr.be(_.id),Re)}},[L,z,Y,G]),W=ir((_,ie,se,Se)=>{if(c){c({positionId:_.id,which:ie,index:se,levelId:Se.id??String(se),price:Se.price,qty:Se.qty,remove:!0});return}let Re=p.current.get(_.id);if(!Re)return;let ye={...Re,takeProfits:ie==="tp"?(Re.takeProfits??[]).filter(($e,Ue)=>Ue!==se):Re.takeProfits,stopLosses:ie==="sl"?(Re.stopLosses??[]).filter(($e,Ue)=>Ue!==se):Re.stopLosses,updatedAt:v.current.get(Re.symbol).ts};p.current.set(_.id,ye),H(ye),R()},[c,H,R]),U=ir(_=>{let ie=h.current.get(_.id);h.current.set(_.id,_);let se=_.status==="filled"||_.status==="cancelled"||_.status==="rejected";se?(y.current.delete(nr.order(_.id)),B(_,!0)):(y.current.set(nr.order(_.id),E(_)),B(_)),ie?se&&_.status==="filled"||(se&&_.status==="cancelled"?x({kind:"order:cancelled",order:_}):se&&_.status==="rejected"?x({kind:"order:rejected",order:_}):x({kind:"order:updated",order:_})):x({kind:"order:placed",order:_}),R()},[E,B,x,R]),V=ir(_=>{let ie=h.current.get(_);h.current.delete(_),y.current.delete(nr.order(_)),ie&&B(ie,!0),R()},[B,R]),K=ir(_=>{g.current.push(_);let ie=h.current.get(_.orderId);ie?.status==="filled"&&x({kind:"order:filled",order:ie,fill:_}),x({kind:"fill:received",fill:_}),R()},[x,R]),Z=ir(_=>{let ie=p.current.get(_.id),se=_.side==="flat"||_.remainingQuantity<=0;if(p.current.set(_.id,_),H(_),ie)se?(x({kind:"position:closed",position:_,realizedPnl:_.realizedPnl??0}),p.current.delete(_.id)):x({kind:"position:updated",position:_});else{x({kind:"position:opened",position:_});let Se=_.status==="open"&&(_.closes?.length??0)===0;!se&&Se&&ZP({side:_.side,symbol:_.symbol,qty:_.startingQuantity,entryPrice:_.entryPrice,tickSize:r})}R()},[H,x,R,r]),de=ir((_,ie)=>{let se=ie?.tone==="profit"?"success":ie?.tone==="loss"?"loss":"neutral";JP(_,{description:ie?.description,tone:se})},[]),ze=ir(_=>{p.current.delete(_),y.current.delete(nr.position(_)),y.current.delete(nr.be(_));let ie=`tp:${_}:`,se=`sl:${_}:`;for(let Se of y.current.keys())(Se.startsWith(ie)||Se.startsWith(se))&&y.current.delete(Se);R()},[R]),xe=ir(_=>{v.current.set(_.symbol,_);let ie=!1;for(let se of p.current.values())se.symbol===_.symbol&&(se.side==="flat"||se.remainingQuantity<=0||(H(se),ie=!0));ie&&(cancelAnimationFrame(b.current),b.current=requestAnimationFrame(()=>R()))},[H,R]),Ae=ir(_=>{let ie=new Set(_.map(se=>se.id));for(let[se,Se]of h.current.entries())ie.has(se)||(y.current.delete(nr.order(se)),B(Se,!0));h.current.clear();for(let se of _)h.current.set(se.id,se),se.status==="filled"||se.status==="cancelled"||se.status==="rejected"||(y.current.set(nr.order(se.id),E(se)),B(se));R()},[E,B,R]),Oe=ir(_=>{let ie=new Set(_.map(se=>se.id));for(let se of p.current.keys())if(!ie.has(se)){y.current.delete(nr.position(se)),y.current.delete(nr.be(se));let Se=`tp:${se}:`,Re=`sl:${se}:`;for(let ye of y.current.keys())(ye.startsWith(Se)||ye.startsWith(Re))&&y.current.delete(ye)}p.current.clear();for(let se of _)p.current.set(se.id,se),H(se);R()},[H,R]),ke=ir(()=>{h.current.clear(),p.current.clear(),g.current=[],y.current.clear(),v.current.clear(),R()},[R]),Q=ir((_,ie,se)=>{let Se=h.current.get(_);if(!Se){console.warn("[useTradingState] handleGhostMove: order not found",_);return}let Re=Se.bracket?.takeProfits??[],ye=Se.bracket?.stopLosses??[],$e={id:pn(),price:se,qty:v8(Se,ie),triggered:!1,triggeredAt:0},Ue={...Se,bracket:{...Se.bracket,takeProfits:ie==="tp"?[...Re,$e]:Re,stopLosses:ie==="sl"?[...ye,$e]:ye},updatedAt:v.current.get(Se.symbol)?.ts??Se.updatedAt};h.current.set(_,Ue),y.current.set(nr.order(_),E(Ue)),B(Ue),s?.(Ue),R(),Ou({kind:ie,symbol:Se.symbol,price:se,tickSize:r,created:!0})},[E,B,R,s,r]),Pe=ir((_,ie,se,Se)=>{if(_.startsWith("order:")){Q(_.slice(6),ie,Se);return}let Re=_.replace(/^position:/,""),ye=p.current.get(Re);if(!ye){console.warn("[useTradingState] handleGhostMove: position not found",Re);return}let $e=ie==="tp"?ye.takeProfits??[]:ye.stopLosses??[],Ue,je=y8(ye,ie),ht=pn();Ue=[...$e,{id:ht,price:Se,qty:je,triggered:!1,triggeredAt:0}];let Be={...ye,takeProfits:ie==="tp"?Ue:ye.takeProfits,stopLosses:ie==="sl"?Ue:ye.stopLosses,updatedAt:v.current.get(ye.symbol).ts};p.current.set(Re,Be),H(Be),i(Be),R();let xt=Ue.length-1;c?.({positionId:Re,which:ie,index:xt,levelId:ht,price:Se,qty:Ue[xt].qty}),Ou({kind:ie,symbol:ye.symbol,price:Se,tickSize:r,created:!0})},[Q,H,R,c,i,r]);return{orders:h.current,positions:p.current,fills:g.current,tradeLines:M,linesRef:y,registerRedraw:w,upsertOrder:U,removeOrder:V,applyFill:K,upsertPosition:Z,toast:de,removePosition:ze,tick:xe,syncOrders:Ae,syncPositions:Oe,reset:ke,handleGhostMove:Pe,draggingLineIdRef:S}}var xw={NQ:{enginePerDisplayUnit:20,uom:"Contracts",contractType:"Full",priceScale:100,symbolType:"future",tickSize:.25,tickValue:5},MNQ:{enginePerDisplayUnit:2,uom:"Contracts",contractType:"Micro",priceScale:100,symbolType:"future",tickSize:.25,tickValue:.5},ES:{enginePerDisplayUnit:50,uom:"Contracts",contractType:"Full",priceScale:100,symbolType:"future",tickSize:.25,tickValue:12.5},MES:{enginePerDisplayUnit:5,uom:"Contracts",contractType:"Micro",priceScale:100,symbolType:"future",tickSize:.25,tickValue:1.25},DEFAULT:{enginePerDisplayUnit:1,uom:"Units",contractType:"Standard",priceScale:100,symbolType:"equity",tickSize:.01,tickValue:1}},w8=Object.keys(xw).filter(e=>e!=="DEFAULT").sort((e,t)=>t.length-e.length);function x8(e){let t=e.toUpperCase();for(let n of w8)if(t.includes(n))return xw[n];return xw.DEFAULT}function s2(e,t,n,r){if(r){let a=r.priceFormat?.minTick??.01,i=r.contract?.multiplier??1;return{enginePerDisplayUnit:1,uom:r.type==="future"?"Contracts":"Shares",contractType:r.type,displayQty:n,priceScale:100,symbolType:r.type,tickSize:a,tickValue:a*i,timezone:r.session?.timezone??r.timezone??"UTC",...e??{}}}let o=x8(t);return{enginePerDisplayUnit:o.enginePerDisplayUnit,uom:o.uom,contractType:o.contractType,displayQty:n/o.enginePerDisplayUnit,priceScale:o.priceScale,symbolType:o.symbolType,tickSize:o.tickSize,tickValue:o.tickValue,...e??{}}}var cg={exchangeFeePerContract:.85,commissionPerContract:2.25,nfaFeePerContract:.02,clearingFeePerContract:.35},l2={exchangeFeePerContract:.25,commissionPerContract:.5,nfaFeePerContract:.02,clearingFeePerContract:.1},S8={exchangeFeePerContract:0,commissionPerContract:0,nfaFeePerContract:0,clearingFeePerContract:0},C8=5;function Sw(e){if(e?.type!=="future")return cg;let t=e.contract?.multiplier;return t!==void 0&&t<=C8?l2:cg}function o2(e,t){return t.commissionPerContract*e}function a2(e,t){return(t.exchangeFeePerContract+t.nfaFeePerContract+t.clearingFeePerContract)*e}var ug=class{constructor(){ae(this,"prices",[]);ae(this,"levels",new Map)}getBest(t){return this.prices.length===0?null:t==="bid"?this.prices[this.prices.length-1]:this.prices[0]}getLevel(t){return this.levels.get(t)}has(t){return this.levels.has(t)}getSortedPrices(){return this.prices}getOrCreate(t){let n=this.levels.get(t);return n||(n={totalSize:0,orders:new Map},this.levels.set(t,n),this._insertPrice(t)),n}removeLevel(t){this.levels.delete(t),this._removePrice(t)}clear(){this.prices.length=0,this.levels.clear()}_insertPrice(t){let n=0,r=this.prices.length;for(;n<r;){let o=n+r>>>1;this.prices[o]<t?n=o+1:r=o}this.prices.splice(n,0,t)}_removePrice(t){let n=0,r=this.prices.length-1;for(;n<=r;){let o=n+r>>>1;if(this.prices[o]===t){this.prices.splice(o,1);return}this.prices[o]<t?n=o+1:r=o-1}}},Cw={enabled:!0,maxResolution:e=>{let t=86400000000000n;return e<=t?60000000000n:e<=7n*t?300000000000n:e<=31n*t?3600000000000n:86400000000000n},ambiguity:"pessimistic"};function vw(e){let t=e.openFee+e.openCommission,n=e.quantity>0?t/e.quantity:0,{initialRR:r,initialRiskPerUnit:o,initialRiskLockedAt:a}=c2(e.side,e.entryPrice,e.takeProfits,e.stopLosses,e.openedAt);return{id:pn(),symbol:e.symbol,side:e.side,type:e.type,status:"open",startingQuantity:e.quantity,remainingQuantity:e.quantity,entryPrice:e.entryPrice,currentPrice:e.entryPrice,unrealizedPnl:0,unrealizedPnlPct:0,realizedPnl:0,initialRiskPerUnit:o,initialRiskTotal:o*e.quantity,initialRiskLockedAt:a,initialRR:r,realizedRR:0,maxFavorableR:0,maxAdverseR:0,highWatermark:e.entryPrice,lowWatermark:e.entryPrice,maeAbs:0,mfeAbs:0,maxDrawdownAbs:0,maxDrawdownPct:0,takeProfits:e.takeProfits,stopLosses:e.stopLosses,bePrice:void 0,closes:[],spread:0,feesTotal:e.openFee,commissionTotal:e.openCommission,slippageTotal:0,openCostPerUnit:n,openCostTotal:t,openedAt:e.openedAt,updatedAt:e.openedAt,metadata:s2(e.metadata,e.symbol,e.quantity,e.symbolInfo)}}function c2(e,t,n,r,o){let a=n.find(s=>!s.triggered),i=r.find(s=>!s.triggered);if(!a||!i)return{initialRR:0,initialRiskPerUnit:0,initialRiskLockedAt:0};if(e==="long"){if(a.price<=t||i.price>=t)return{initialRR:0,initialRiskPerUnit:0,initialRiskLockedAt:0};let s=a.price-t,l=t-i.price;return{initialRR:s/l,initialRiskPerUnit:l,initialRiskLockedAt:o}}else{if(a.price>=t||i.price<=t)return{initialRR:0,initialRiskPerUnit:0,initialRiskLockedAt:0};let s=t-a.price,l=i.price-t;return{initialRR:s/l,initialRiskPerUnit:l,initialRiskLockedAt:o}}}function i2(e,t){if(e.initialRiskLockedAt>0||e.side==="flat")return e;let{initialRR:n,initialRiskPerUnit:r,initialRiskLockedAt:o}=c2(e.side,e.entryPrice,e.takeProfits,e.stopLosses,t);return o===0?e:{...e,initialRR:n,initialRiskPerUnit:r,initialRiskTotal:r*e.remainingQuantity,initialRiskLockedAt:o}}function ww(e,t,n){if(e.status==="closed")return e;let r=e.maeAbs,o=e.mfeAbs,a=e.highWatermark,i=e.lowWatermark;e.side==="long"?(r=Math.max(r,Math.max(0,e.entryPrice-t)),o=Math.max(o,Math.max(0,n-e.entryPrice)),a=Math.max(a,n),i=Math.min(i,t)):(r=Math.max(r,Math.max(0,n-e.entryPrice)),o=Math.max(o,Math.max(0,e.entryPrice-t)),a=Math.max(a,n),i=Math.min(i,t));let s=e.side==="long"?Math.max(0,a-t):Math.max(0,n-i),l=Math.max(e.maxDrawdownAbs,s*e.remainingQuantity),c=e.entryPrice*e.startingQuantity,u=c>0?l/c:0,d=e.initialRiskPerUnit,m=d>0?o/d:0,f=d>0?r/d:0;return{...e,maeAbs:r,mfeAbs:o,highWatermark:a,lowWatermark:i,maxDrawdownAbs:l,maxDrawdownPct:u,maxFavorableR:m,maxAdverseR:f}}function kw(e,t={}){let{symbolInfo:n=null,tickSize:r=.25,fees:o=cg,fillLatencyMs:a=0,nettingMode:i="net",marketSlippageTicks:s=0,eventBus:l=null}=t,c=n?.symbol??"",u=n?.priceFormat?.minTick??r,d=n?.contract?.multiplier??lg(c),m=new ug,f=new ug,h=new Map,p=new Map,g=null,y=null,v=new Map,b=new Map,S=new Map,C=new Map,w=[],k=[],M=0,I=0,x=null,T=!1,R=!1,P=null,D=0,N=0,O=0n,A=0n;function B(F){let re=new Map;for(let q=1;q<F.length;q++){let he=F[q].tsNs-F[q-1].tsNs;he<=0n||re.set(he,(re.get(he)??0)+1)}let ue=0n,ce=0;for(let[q,he]of re)he>ce&&(ue=q,ce=he);return ue}function E(F){if(F.status==="closed"||F.remainingQuantity<=0){b.delete(F.id);return}b.set(F.id,F),Y.add(F.id),H=!0}function L(F){let re=!C.has(F.id);if(C.set(F.id,F),F.status==="filled"||F.status==="cancelled"||F.status==="rejected"){v.delete(F.id);return}re&&(Y.add(F.id),H=!0);let ce={...v.get(F.id),order:F,bracketSl:F.bracket?.stopLosses??[],bracketTp:F.bracket?.takeProfits??[]};v.set(F.id,ce)}function z(F,re,ue){let ce=F.getLevel(re);if(!ce)return 0;let q=ce.orders.get(ue)??0;return ce.orders.delete(ue),ce.totalSize=Math.max(0,ce.totalSize-q),ce.totalSize===0&&F.removeLevel(re),q}let Y=new Set,G=null,H=!1;function W(F){H&&(H=!1,(G===null||F>G)&&(G=F))}function U(F,re){return G===null||!Y.has(F)?!1:re<G}function V(F,re,ue){for(let[ce,q]of v){let{order:he}=q;if(U(ce,ue)||!(he.type==="limit"||he.type==="stop_limit"&&he.triggered))continue;let We=he.price;(he.side==="long"?F<=We:re>=We)&&(se(q,We,ue),v.delete(ce))}}function K(F,re,ue){let ce=Number(ue);for(let[q,he]of v){let{order:me}=he;if(U(q,ue)||me.type!=="stop"&&me.type!=="stop_limit"||me.type==="stop_limit"&&me.triggered)continue;let We=me.stopPrice;if(!(me.side==="long"?re>=We:F<=We))continue;let gt=s*r;if(me.type==="stop"){let vt=xt(me.side==="long"?We+gt:We-gt);se(he,vt,ue),v.delete(q)}else{let vt=me.price??We,pt={...me,triggered:!0,status:"working",updatedAt:ce};v.delete(q),v.set(q,{order:pt,queueAhead:0,tradedThrough:0,bracketTp:he.bracketTp,bracketSl:he.bracketSl}),C.set(pt.id,pt),e.upsertOrder(pt),V(F,vt,ue)}}}function Z(F,re,ue,ce="pessimistic"){let q=Number(ue);for(let he of b.values()){if(he.remainingQuantity<=0||U(he.id,ue))continue;let me=ww(he,F,re);b.set(he.id,me);let We=()=>{for(let gt of me.takeProfits){if(gt.triggered||!(me.side==="long"?re>=gt.price:F<=gt.price))continue;let pt=b.get(he.id);if(!pt||pt.remainingQuantity<=0)break;je(pt,Math.min(gt.qty,pt.remainingQuantity),gt.price,q,"tp",gt.id,void 0)}},nt=()=>de(me,F,re,q);ce==="pessimistic"?(nt(),We()):(We(),nt())}}function de(F,re,ue,ce){for(let q of F.stopLosses){if(q.triggered||!(F.side==="long"?re<=q.price:ue>=q.price))continue;let me=b.get(F.id);if(!me||me.remainingQuantity<=0)break;je(me,me.remainingQuantity,q.price,ce,"sl",void 0,q.id);break}}let ze=Cw;function xe(F){ze={...ze,...F}}function Ae(){return ze}function Oe(){if(v.size>0)return!0;for(let F of b.values())if(!(F.remainingQuantity<=0)&&(F.takeProfits.some(re=>!re.triggered)||F.stopLosses.some(re=>!re.triggered)))return!0;return!1}function ke(F,re=ze.ambiguity){if(T)return;F.length&&W(F[0].tsNs);let ue=r/2,ce=R;R=!0;try{for(let q of F){let he=Number(q.tsNs);In({symbol:c,bid:q.open-ue,ask:q.open+ue,last:q.open,ts:he}),V(q.low,q.high,q.tsNs),K(q.low,q.high,q.tsNs),Z(q.low,q.high,q.tsNs,re),q.close!==q.open&&In({symbol:c,bid:q.close-ue,ask:q.close+ue,last:q.close,ts:he})}}finally{R=ce}}function Q(F,re){if(T)return;let{action:ue,side:ce,price:q,size:he,order_id:me}=F;if(ue==="R"){m.clear(),f.clear(),h.clear(),p.clear(),g=null,y=null;return}let We=ce;(ue==="T"||ue==="F")&&(We=ce==="B"?"A":"B");let nt=We==="B",gt=nt?m:f;if(ue==="A"){if(q===null)return;let vt=gt.getOrCreate(q),pt=vt.orders.get(me)??0;vt.totalSize=Math.max(0,vt.totalSize-pt)+he,vt.orders.set(me,he),nt?((g===null||q>g)&&(g=q),h.set(me,q)):((y===null||q<y)&&(y=q),p.set(me,q))}else if(ue==="C"){let vt=nt?h.get(me):p.get(me);if(vt===void 0)return;z(gt,vt,me)>0&&(nt?h.delete(me):p.delete(me),nt?g=m.getBest("bid"):y=f.getBest("ask"))}else if(ue==="M"){let vt=h.get(me),pt=p.get(me),Ze=vt??pt;if(Ze===void 0)return;let Tt=vt!==void 0,Gt=Tt?m:f,Xt=Tt?h:p,X=q!==null&&q!==0?q:Ze;z(Gt,Ze,me);let $=Gt.getOrCreate(X);$.orders.set(me,he),$.totalSize+=he,Xt.set(me,X),Tt?g=m.getBest("bid"):y=f.getBest("ask")}else if(ue==="T"||ue==="F"){let vt=h.get(me),pt=p.get(me);vt!==void 0&&(z(m,vt,me),h.delete(me),g=m.getBest("bid")),pt!==void 0&&(z(f,pt,me),p.delete(me),y=f.getBest("ask")),q!==null&&(Pe(q,he,ce,re),_(q,ce,re))}}function Pe(F,re,ue,ce){for(let[q,he]of v){let{order:me}=he;if(U(q,ce)||!(me.type==="limit"||me.type==="stop_limit"&&me.triggered))continue;let nt=me.price;if(me.side==="long"&&ue==="A")if(F<nt)he.tradedThrough=1/0;else if(F===nt)he.tradedThrough+=re;else continue;else if(me.side==="short"&&ue==="B")if(F>nt)he.tradedThrough=1/0;else if(F===nt)he.tradedThrough+=re;else continue;else continue;he.tradedThrough>=he.queueAhead&&(se(he,nt,ce),v.delete(q))}}function _(F,re,ue){let ce=Number(ue);for(let q of b.values()){if(q.remainingQuantity<=0||U(q.id,ue))continue;let he=ww(q,F,F);b.set(q.id,he);for(let me of q.takeProfits){if(me.triggered||!(q.side==="long"?re==="B"&&F>=me.price:re==="A"&&F<=me.price))continue;let nt=b.get(q.id);if(!nt||nt.remainingQuantity<=0)break;let gt=Math.min(me.qty,nt.remainingQuantity);je(nt,gt,me.price,ce,"tp",me.id,void 0)}for(let me of q.stopLosses){if(me.triggered||!(q.side==="long"?re==="A"&&F<=me.price:re==="B"&&F>=me.price))continue;let nt=b.get(q.id);if(!nt||nt.remainingQuantity<=0)break;je(nt,nt.remainingQuantity,me.price,ce,"sl",void 0,me.id);break}}}function ie(F){for(let[re,ue]of v){let{order:ce}=ue;if(ce.type!=="stop"&&ce.type!=="stop_limit"||ce.type==="stop_limit"&&ce.triggered)continue;let q=ce.stopPrice;if(ce.side==="long"?F.ask>=q:F.bid<=q)if(ce.type==="stop"){let me=s*r,We=ce.side==="long"?F.ask+me:F.bid-me;se(ue,xt(We),BigInt(F.ts)),v.delete(re)}else{let me=ce.price??q,We={...ce,triggered:!0,status:"working",updatedAt:F.ts},gt=(ce.side==="long"?m:f).getLevel(me)?.totalSize??0;v.delete(re),v.set(re,{order:We,queueAhead:gt,tradedThrough:0,bracketTp:ue.bracketTp,bracketSl:ue.bracketSl}),C.set(We.id,We),e.upsertOrder(We)}}}function se(F,re,ue){a<=0?Se(F,re,ue):setTimeout(()=>Se(F,re,ue),a)}function Se(F,re,ue){if(T)return;let{order:ce,bracketTp:q,bracketSl:he}=F,me=ce.quantity-ce.filledQuantity,We=a2(me,o),nt=o2(me,o),gt=We+nt;M+=gt;let vt=Number(ue),pt=ce.avgPrice*ce.filledQuantity,Ze=re*me,Tt=(pt+Ze)/ce.quantity,Gt={id:pn(),orderId:ce.id,symbol:ce.symbol,side:ce.side,price:re,quantity:me,ts:vt,fee:gt,feeCurrency:"USD"},Xt={...ce,filledQuantity:ce.quantity,avgPrice:Tt,status:"filled",fees:We,commission:nt,updatedAt:vt};C.set(Xt.id,Xt),k.push(Gt),e.upsertOrder(Xt),e.applyFill(Gt),ye(Xt,re,We,nt,q,he,vt)}function Re(F){return S.has(F)||S.set(F,[]),S.get(F)}function ye(F,re,ue,ce,q,he,me){i==="net"?$e(F,re,ue,ce,q,he,me):Ue(F,re,ue,ce,q,he,me)}function $e(F,re,ue,ce,q,he,me){let We;for(let Tt of b.values())if(Tt.symbol===F.symbol){We=Tt;break}let nt=Re(F.symbol),gt=ue/F.quantity,vt=ce/F.quantity;if(!We){for(let Gt=0;Gt<F.quantity;Gt++)nt.push({side:F.side,qty:1,price:re,feePerUnit:gt,commissionPerUnit:vt});let Tt=vw({symbol:F.symbol,side:F.side,type:F.type,entryPrice:re,quantity:F.quantity,takeProfits:q??[],stopLosses:he??[],openedAt:me,openFee:ue,openCommission:ce,metadata:F.metadata,symbolInfo:n});b.set(Tt.id,Tt),e.upsertPosition(Tt);return}if(We.side===F.side){for(let bt=0;bt<F.quantity;bt++)nt.push({side:F.side,qty:1,price:re,feePerUnit:gt,commissionPerUnit:vt});let Tt=We.remainingQuantity+F.quantity,Gt=(We.entryPrice*We.remainingQuantity+re*F.quantity)/Tt,Xt=We.openCostTotal+ue+ce,X=We.startingQuantity+F.quantity,$=[...We.takeProfits,...q?.filter(bt=>!We.takeProfits.some(le=>le.id===bt.id))??[]],ge=[...We.stopLosses,...he?.filter(bt=>!We.stopLosses.some(le=>le.id===bt.id))??[]],Ce={...We,entryPrice:Gt,remainingQuantity:Tt,startingQuantity:X,takeProfits:$,stopLosses:ge,openCostTotal:Xt,openCostPerUnit:X>0?Xt/X:0,feesTotal:We.feesTotal+ue,commissionTotal:We.commissionTotal+ce,updatedAt:me},ct=i2(Ce,me);b.set(We.id,ct),e.upsertPosition(ct);return}let Ze=F.quantity;for(;Ze>0&&Ze<=We.remainingQuantity;)break;if(F.quantity<=We.remainingQuantity){let Tt=F.quantity;je(We,Tt,re,me,"order",void 0,void 0,F.id,F.type)}else{let Tt=We.remainingQuantity;je(We,Tt,re,me,"order",void 0,void 0,F.id,F.type);let Gt=F.quantity-Tt;if(Gt>0){let Xt=Re(F.symbol);for(let Ce=0;Ce<Gt;Ce++)Xt.push({side:F.side,qty:1,price:re,feePerUnit:gt,commissionPerUnit:vt});let X=ue*(Gt/F.quantity),$=ce*(Gt/F.quantity),ge=vw({symbol:F.symbol,side:F.side,type:F.type,entryPrice:re,quantity:Gt,takeProfits:q??[],stopLosses:he??[],openedAt:me,openFee:X,openCommission:$,metadata:F.metadata,symbolInfo:n});b.set(ge.id,ge),e.upsertPosition(ge)}}}function Ue(F,re,ue,ce,q,he,me){let We=`${F.symbol}:${pn(6)}`,nt=Re(We),gt=ue/F.quantity,vt=ce/F.quantity;for(let Ze=0;Ze<F.quantity;Ze++)nt.push({side:F.side,qty:1,price:re,feePerUnit:gt,commissionPerUnit:vt});let pt=vw({symbol:F.symbol,side:F.side,type:F.type,entryPrice:re,quantity:F.quantity,takeProfits:q??[],stopLosses:he??[],openedAt:me,openFee:ue,openCommission:ce,metadata:F.metadata,symbolInfo:n});b.set(pt.id,pt),e.upsertPosition(pt)}function je(F,re,ue,ce,q,he,me,We,nt){if(!b.has(F.id)||re<=0||re>F.remainingQuantity)return;let gt=Re(i==="hedge"?F.id:F.symbol),vt=a2(re,o),pt=o2(re,o),Ze=vt+pt;M+=Ze;let Tt=re,Gt=0,Xt=0,X=0;for(;Tt>0&>.length>0;){let yt=gt[0],Bt=Math.min(Tt,yt.qty),gr=yt.side==="long"?1:-1;Gt+=gr*(ue-yt.price)*Bt*d,Xt+=yt.feePerUnit*Bt,X+=yt.commissionPerUnit*Bt,yt.qty-=Bt,yt.qty===0&>.shift(),Tt-=Bt}let $=Xt+X,ge=Gt-Ze-$;I+=ge;let Ce=F.takeProfits,ct=F.stopLosses;he&&(Ce=F.takeProfits.map(yt=>yt.id===he?{...yt,triggered:!0,triggeredAt:ce}:yt)),me&&(ct=F.stopLosses.map(yt=>yt.id===me?{...yt,triggered:!0,triggeredAt:ce}:yt));let bt=F.remainingQuantity-re,le=F.realizedPnl+ge,Ee=F.initialRiskPerUnit,wt=F.initialRiskTotal;if(F.initialRiskLockedAt===0&&Ee===0&&bt===0){let yt=ct.find(gr=>gr.triggered)??ct.find(gr=>!gr.triggered),Bt=0;yt&&(Bt=F.side==="long"?Math.max(0,F.entryPrice-yt.price):Math.max(0,yt.price-F.entryPrice)),Bt<=0&&F.maeAbs>0&&(Bt=F.maeAbs),Bt>0&&(Ee=Bt,wt=Bt*F.startingQuantity)}let Lt=wt>0?le/(wt*d):0,Ln={timestamp:ce,price:ue,quantity:re,pnl:Gt,pnlNet:ge,reason:q,orderId:We??"",orderType:nt??"market",tpId:he,slId:me,realizedRRAfter:Lt,fees:vt,commission:pt,slippage:0,spread:0,openCostAllocated:$},Ut=bt===0?"closed":"partially_closed",Mt={...F,side:F.side,status:Ut,remainingQuantity:bt,realizedPnl:le,realizedRR:Lt,takeProfits:Ce,stopLosses:ct,feesTotal:F.feesTotal+Ze,commissionTotal:F.commissionTotal+pt,closes:[...F.closes,Ln],initialRiskPerUnit:Ee,initialRiskTotal:wt,closedAt:bt===0?ce:F.closedAt,updatedAt:ce},zt=_u(Mt,ue,d),At=hm(Mt,ue,d);Mt.unrealizedPnl=zt,Mt.unrealizedPnlPct=At,bt===0?(b.delete(F.id),w.push(Mt)):b.set(F.id,Mt),e.upsertPosition(Mt);let mn=Ut==="closed";QP({side:Mt.side,symbol:Mt.symbol,pnl:mn?le:ge,rMultiple:Lt,reason:q,partial:!mn})}function ht(F,re,ue,ce){je(F,F.remainingQuantity,re,ce,ue)}function Be(F,re,ue){let{order:ce}=F,q=s*r,he=ce.side==="long",me=he?f:m,We=me.getSortedPrices(),nt=ce.quantity,gt=0,vt=!1;if(he)for(let Ze=0;Ze<We.length&&nt>0;Ze++){let Tt=me.getLevel(We[Ze]),Gt=Math.min(nt,Tt.totalSize);gt+=(We[Ze]+q)*Gt,nt-=Gt,vt=!0}else for(let Ze=We.length-1;Ze>=0&&nt>0;Ze--){let Tt=me.getLevel(We[Ze]),Gt=Math.min(nt,Tt.totalSize);gt+=(We[Ze]-q)*Gt,nt-=Gt,vt=!0}if(!vt||nt>0){let Ze=he?(re.ask??y??re.ask)+q*2:(re.bid??g??re.bid)-q*2;gt+=Ze*nt}let pt=xt(gt/ce.quantity);se(F,pt,ue)}function xt(F){return Math.round(F/u)*u}function fn(F){l&&l.emit("playback:tick",{bid:F.bid,ask:F.ask,last:F.last,spread:Math.abs(F.ask-F.bid)})}function In(F){if(T)return;x=F,e.tick(F),ie(F),F.bid!=null&&(g=F.bid),F.ask!=null&&(y=F.ask);let re=F.last??(F.bid+F.ask)/2;R||fn(F);for(let ue of b.values()){if(ue.symbol!==F.symbol)continue;let ce=_u(ue,re,d),q=hm(ue,re,d),me={...ww(ue,Math.min(F.bid,F.ask),Math.max(F.bid,F.ask)),currentPrice:re,unrealizedPnl:ce,unrealizedPnlPct:q,updatedAt:F.ts};b.set(ue.id,me),e.upsertPosition(me)}}function kt(F,re,ue,ce,q){return{id:re,symbol:ue,side:F.side,type:F.type,quantity:F.qty,filledQuantity:0,price:F.limitPrice??0,stopPrice:F.stopPrice??0,tif:F.tif??"gtc",status:q,reduceOnly:F.reduceOnly??!1,targetPositionId:F.targetPositionId,avgPrice:0,triggered:!1,fees:0,commission:0,slippage:0,createdAt:ce,updatedAt:ce,metadata:s2(F.metadata,ue,F.qty,n),bracket:{takeProfits:F.bracketTp,stopLosses:F.bracketSl}}}function it(F){let re=pn(),ue=F.symbol??c;if(!x){let he=kt(F,re,ue,0,"rejected");return C.set(re,he),e.upsertOrder(he),re}let ce=x.ts;F.type==="market"&&!F?.limitPrice&&!F?.stopPrice&&(F.side==="long"?F.limitPrice=x.ask:F.limitPrice=x.bid);let q=kt(F,re,ue,ce,"working");if(C.set(re,q),e.upsertOrder(q),F.type==="market")Be({order:q,queueAhead:0,tradedThrough:0,bracketTp:F.bracketTp,bracketSl:F.bracketSl},x,BigInt(x.ts));else if(F.type==="limit"){let me=(F.side==="long"?m:f).getLevel(F.limitPrice)?.totalSize??0;if(v.set(re,{order:q,queueAhead:me,tradedThrough:0,bracketTp:F.bracketTp,bracketSl:F.bracketSl}),x&&(F.side==="long"?x.ask<=F.limitPrice:x.bid>=F.limitPrice)){let nt=v.get(re);nt.queueAhead=0,nt.tradedThrough=1/0,v.delete(re);let gt=F.side==="long"?x.ask:x.bid;se(nt,gt,BigInt(x.ts))}}else v.set(re,{order:q,queueAhead:0,tradedThrough:0,bracketTp:F.bracketTp,bracketSl:F.bracketSl});return re}function ft(F){let re=v.get(F);if(!re)return;v.delete(F);let ue={...re.order,status:"cancelled",updatedAt:x.ts};C.set(F,ue),e.upsertOrder(ue)}function oe(F,re){let ue=v.get(F);if(!ue)return;let{order:ce}=ue,q=xt(re),he=ce.type==="limit"||ce.type==="stop_limit"&&ce.triggered,me=ce.type==="stop"||ce.type==="stop_limit"&&!ce.triggered,We={...ce,price:he?q:ce.price,stopPrice:me?q:ce.stopPrice,updatedAt:x.ts},nt=We.side==="long"?m:f,gt=he?q:We.price??q,vt=nt.getLevel(gt)?.totalSize??0;v.set(F,{...ue,order:We,queueAhead:vt,tradedThrough:0}),C.set(F,We),e.upsertOrder(We)}function pe(F){let{positionId:re,which:ue,levelId:ce,index:q,price:he,qty:me,remove:We}=F,nt=b.get(re);if(!nt)return;let gt=xt(he),vt=x.ts,pt=(Xt,X)=>Xt.id?Xt.id===ce:X===q,Ze={...nt};ue==="tp"?Ze={...Ze,takeProfits:We?nt.takeProfits.filter((Xt,X)=>!pt(Xt,X)):nt.takeProfits.map((Xt,X)=>pt(Xt,X)?{...Xt,price:gt,qty:me>0?me:Xt.qty}:Xt)}:ue==="sl"?Ze={...Ze,stopLosses:We?nt.stopLosses.filter((Xt,X)=>!pt(Xt,X)):nt.stopLosses.map((Xt,X)=>pt(Xt,X)?{...Xt,price:gt,qty:me>0?me:Xt.qty}:Xt)}:ue==="be"&&(Ze={...Ze,bePrice:We?void 0:gt});let Gt={...i2(Ze,vt),updatedAt:vt};b.set(re,Gt),e.upsertPosition(Gt)}function fe(F){let re=b.get(F);if(!re||!x)return;let ue=s*r,ce=xt(re.side==="long"?x.bid-ue:x.ask+ue);ht(re,ce,"market",x.ts)}function Ie(F){let re=b.get(F);if(!re||!x)return;let ue=s*r,ce=xt(re.side==="long"?x.bid-ue:x.ask+ue),q=re.side==="long"?"short":"long",he=re.remainingQuantity;ht(re,ce,"market",x.ts),it({side:q,type:"market",qty:he,symbol:re.symbol})}function Ve(F,re){let ue=F.map(ce=>({tsNs:BigInt(ce.time)*1000000n,bar:ce})).sort((ce,q)=>ce.tsNs<q.tsNs?-1:ce.tsNs>q.tsNs?1:0);P={kind:"ohlcv",bars:ue,suppBars:[],barNs:re&&re>0n?re:B(ue)},D=0,N=0,O=0n,tt=ja(0),mt=0}function qe(F,re){if(P?.kind!=="ohlcv"||F.length===0){F.length&&Ve(F,re);return}let ue=P,ce=F.map(me=>({tsNs:BigInt(me.time)*1000000n,bar:me})).sort((me,We)=>me.tsNs<We.tsNs?-1:me.tsNs>We.tsNs?1:0);if(ue.bars.length>0&&ce[0].tsNs<ue.bars[0].tsNs){Ve(F,re);return}let q=ce[0].tsNs,he=ue.bars.length;for(;he>0&&ue.bars[he-1].tsNs>=q;)he--;ue.bars.length=he;for(let me of ce)ue.bars.push(me);D>ue.bars.length&&(D=ue.bars.length),re&&re>0n&&(ue.barNs=re)}function Fe(F){if(P?.kind!=="ohlcv"||F.length===0)return;let re=P,ue=F.map(he=>({tsNs:BigInt(Math.round(he.time))*1000000n,open:he.open,high:he.high,low:he.low,close:he.close,volume:he.volume})).sort((he,me)=>he.tsNs<me.tsNs?-1:he.tsNs>me.tsNs?1:0);if(re.suppBars.length>0&&ue[0].tsNs<re.suppBars[0].tsNs){De(F);return}let ce=ue[0].tsNs,q=re.suppBars.length;for(;q>0&&re.suppBars[q-1].tsNs>=ce;)q--;re.suppBars.length=q;for(let he of ue)re.suppBars.push(he);N>re.suppBars.length&&(N=re.suppBars.length)}function De(F){P?.kind==="ohlcv"&&(P.suppBars=F.map(re=>({tsNs:BigInt(Math.round(re.time))*1000000n,open:re.open,high:re.high,low:re.low,close:re.close,volume:re.volume})).sort((re,ue)=>re.tsNs<ue.tsNs?-1:re.tsNs>ue.tsNs?1:0),N=0)}function we(F){P={kind:"tick",trades:[...F].sort((re,ue)=>re.ts<ue.ts?-1:re.ts>ue.ts?1:0)},D=0,O=0n,tt=ja(0),mt=0}function _e(F){P={kind:"l2",history:[...F].sort((re,ue)=>re.ts<ue.ts?-1:re.ts>ue.ts?1:0)},D=0,O=0n,tt=ja(0),mt=0}function Ne(F){if(P?.kind!=="tick"||F.length===0){F.length&&we(F);return}let re=[...F].sort((ce,q)=>ce.ts<q.ts?-1:ce.ts>q.ts?1:0);if(P.trades.length>0&&re[0].ts<P.trades[0].ts){we(F);return}let ue=Math.min(D,re.length);P.trades=re,D=ue}function dt(F){if(P?.kind!=="l2"||F.length===0){F.length&&_e(F);return}let re=[...F].sort((ce,q)=>ce.ts<q.ts?-1:ce.ts>q.ts?1:0);if(P.history.length>0&&re[0].ts<P.history[0].ts){_e(F);return}let ue=Math.min(D,re.length);P.history=re,D=ue}function Pt(F){let re=mt;qt(F),mt=Math.min(re,tt.length)}function J(F){let re=P,ue=0,ce=re.barNs;for(F<A&&(D=0,N=0),A=F;D<re.bars.length;){let{tsNs:q,bar:he}=re.bars[D];if(q+ce>F)break;D++,O=q;let me=Number(q),We=he.bid??he.open-ue,nt=he.ask??he.open+ue,gt=he.bid??he.close-ue,vt=he.ask??he.close+ue;In({symbol:c,bid:We,ask:nt,last:he.open,ts:me}),V(he.low,he.high,q),K(he.low,he.high,q),Z(he.low,he.high,q),he.close!==he.open&&In({symbol:c,bid:gt,ask:vt,last:he.close,ts:me})}if(re.suppBars.length>0&&ce>0n){let q=F/ce*ce,he=null;for(;N<re.suppBars.length&&re.suppBars[N].tsNs<=F;){let me=re.suppBars[N];N++,!(me.tsNs<q)&&(me.volume??0)!==0&&(V(me.low,me.high,me.tsNs),K(me.low,me.high,me.tsNs),Z(me.low,me.high,me.tsNs),he=me)}if(he){let me=Number(he.tsNs);In({symbol:c,bid:he.close-ue,ask:he.close+ue,last:he.close,ts:me})}}}function Te(F){let re=P,ue=r/2;for(F<O&&(D=0);D<re.trades.length;){let ce=re.trades[D];if(ce.ts>F)break;D++,O=ce.ts;let q=Number(ce.ts),he=ce.side==="B"?ce.price-ue:ce.price,me=ce.side==="A"?ce.price+ue:ce.price;In({symbol:c,bid:he,ask:me,last:ce.price,ts:q}),V(ce.price,ce.price,ce.ts),Z(ce.price,ce.price,ce.ts)}}function Le(F){let re=P;for(F<O&&(D=0);D<re.history.length;){let ue=re.history[D];if(ue.ts>F)break;D++,O=ue.ts;let ce=Number(ue.ts),{bestBid:q,bestAsk:he}=ue,me=(q+he)/2;In({symbol:c,bid:q,ask:he,last:me,ts:ce});for(let[We,nt]of v){let{order:gt}=nt;if(gt.type!=="limit")continue;let vt=gt.price;if(!(gt.side==="long"?he<=vt:q>=vt))continue;let Ze=gt.side==="long"?he:q;se(nt,Ze,ue.ts),v.delete(We)}Z(q,he,ue.ts)}}let ot=20,tt=ja(0),mt=0;function qt(F){let re=F.byteLength/ot;tt._buf=F,tt._view=new DataView(F),tt.length=re,tt.capacity=re,mt=0}function Dt(){return x?x.last:NaN}function rr(F){if(T)return;W(F);let re=R;R=!0;try{if(P)switch(P.kind){case"ohlcv":J(F);break;case"tick":Te(F);break;case"l2":Le(F);break}else if(tt.length>0){let ue=mt>0?ms(tt,mt-1):0n;for(F<ue&&(m.clear(),f.clear(),h.clear(),p.clear(),g=null,y=null,mt=0);mt<tt.length;){let ce=ms(tt,mt);if(ce>F)break;Q(fs(tt,mt),ce),mt++}g!==null&&y!==null&&In({symbol:c,bid:g,ask:y,ts:Number(F)})}}finally{R=re}!re&&x&&fn(x)}function wn(){return M}function er(){return I}function Pn(){return[...C.values()]}function cr(){return[...k]}function Mn(){return[...w]}function An(){T=!0,v.clear(),b.clear(),m.clear(),f.clear(),S.clear(),C.clear(),w.length=0,k.length=0,tt=ja(0),P=null,D=0,N=0,O=0n}return{syncPosition:E,syncOrder:L,onMboEvent:Q,onTick:In,ingestCompactBuf:qt,ingestOhlcvBars:Ve,appendOhlcvBars:qe,ingestSupplementalBars:De,appendSupplementalBars:Fe,appendTicks:Ne,appendPriceHistory:dt,appendCompactBuf:Pt,ingestTicks:we,ingestPriceHistory:_e,seekTo:rr,getPrice:Dt,placeOrder:it,cancelOrder:ft,amendOrder:oe,amendBracket:pe,closePosition:fe,reversePosition:Ie,totalFeesPaid:wn,totalRealizedPnl:er,getOrders:Pn,getFills:cr,getPositionHistory:Mn,setFillSearch:xe,getFillSearch:Ae,hasPendingTriggers:Oe,settleGapBars:ke,destroy:An}}var $a=8;function d2(e,t,n,r){let o=vm(t??new gc).current,a=vm([]),i=vm(n);ym(()=>{i.current=n},[n]);let[s,l]=u2(null);ym(()=>{if(l(r?.getSymbolInfo(e)??null),!!n)return n.on("data:symbol-resolved",({symbolInfo:g})=>{g.symbol===e&&l(g)})},[n,e]);let c=s?.priceFormat?.minTick??.01,u=s?.contract?.multiplier??1,[d,m]=u2("ohlcv");ym(()=>{if(n)return n.on("data:load",({symbol:g,dataLevel:y})=>{g===e&&m(y)})},[n,e]);let f=d==="l3"||d==="l2"?"conservative":"last",h=r2(k8(()=>({tickSize:c,tickValue:u,markMode:f,onAmendOrder:(g,y)=>o.amendOrder(g,y),onUpdatePosition:g=>o.syncPosition(g),onUpdateOrder:g=>o.syncOrder(g),onAmendBracket:g=>o.amendBracket(g),onCancelOrder:g=>o.cancelOrder(g),onClosePosition:g=>o.closePosition(g),onReversePosition:g=>o.reversePosition(g),onEvent:g=>{a.current.push(g),i.current?.emit("trading:event",g)}}),[c,u,f]));ym(()=>{if(!e)return;let g=kw(h,{symbolInfo:s,fees:Sw(s),nettingMode:"net",marketSlippageTicks:0,eventBus:n});o.attachBuiltIn(g,e);let y=r?.account?.getSnapshot();if(y){let v=y.openPositions.map(S=>S.position).filter(S=>S.symbol===e&&S.status!=="closed"&&!(S.remainingQuantity<=0)),b=y.orders.map(S=>S.order).filter(S=>S.symbol===e&&S.status!=="filled"&&S.status!=="cancelled"&&S.status!=="rejected");for(let S of v)g.syncPosition(S);for(let S of b)g.syncOrder(S);h.syncPositions(v),h.syncOrders(b)}return()=>{g.destroy(),o.detachBuiltIn(e)}},[e,s,r]);let p=vm(null);return ym(()=>{h.registerRedraw(p.current)},[p.current]),{symbol:e,trading:h,executionEngine:o,redrawFnRef:p,tradingEvents:a}}function ll(e,t,n,r){return d2(e,r,t,n)}function T8(e,t){let n=Array.from({length:$a},(o,a)=>t[a]??""),r=[];for(let o of e.slice(0,$a))o&&!r.includes(o)&&r.push(o);for(let o=0;o<$a;o++)n[o]&&!r.includes(n[o])&&(n[o]="");for(let o of r){if(n.includes(o))continue;let a=n.indexOf("");if(a===-1)break;n[a]=o}return n}function f2(e,t,n,r){let o=vm(Array.from({length:$a},()=>"")),a=T8(e,o.current);o.current=a;let i=ll(a[0],t,n,r),s=ll(a[1],t,n,r),l=ll(a[2],t,n,r),c=ll(a[3],t,n,r),u=ll(a[4],t,n,r),d=ll(a[5],t,n,r),m=ll(a[6],t,n,r),f=ll(a[7],t,n,r),h=[i,s,l,c,u,d,m,f],p=Array.from({length:$a},(y,v)=>{let b=a.indexOf(e[v]??"");return h[b===-1?0:b]}),g=h.filter(y=>y.symbol);return{byCell:p,bySymbol:g}}import I8,{useCallback as M8}from"react";import{jsx as So,jsxs as Fu}from"react/jsx-runtime";var dg=[{id:"1",label:"1",count:1,cols:1,rows:1,areas:'"a"'},{id:"2h",label:"2",count:2,cols:2,rows:1,areas:'"a b"'},{id:"2v",label:"2",count:2,cols:1,rows:2,areas:'"a" "b"'},{id:"3h",label:"3",count:3,cols:3,rows:1,areas:'"a b c"'},{id:"3v",label:"3",count:3,cols:1,rows:3,areas:'"a" "b" "c"'},{id:"3r",label:"3",count:3,cols:2,rows:2,areas:'"a b" "a c"'},{id:"3l",label:"3",count:3,cols:2,rows:2,areas:'"a b" "c b"'},{id:"3t",label:"3",count:3,cols:2,rows:2,areas:'"a a" "b c"'},{id:"3b",label:"3",count:3,cols:2,rows:2,areas:'"a b" "c c"'},{id:"4g",label:"4",count:4,cols:2,rows:2,areas:'"a b" "c d"'},{id:"4h",label:"4",count:4,cols:4,rows:1,areas:'"a b c d"'},{id:"4v",label:"4",count:4,cols:1,rows:4,areas:'"a" "b" "c" "d"'},{id:"4l",label:"4",count:4,cols:2,rows:3,areas:'"a b" "a c" "a d"'},{id:"4r",label:"4",count:4,cols:2,rows:3,areas:'"a b" "c b" "d b"'},{id:"4b",label:"4",count:4,cols:3,rows:2,areas:'"a a a" "b c d"'},{id:"4t",label:"4",count:4,cols:3,rows:2,areas:'"a b c" "d d d"'},{id:"4j",label:"4",count:4,cols:3,rows:2,areas:'"a b c" "a b d"'},{id:"4k",label:"4",count:4,cols:3,rows:2,areas:'"a b c" "d b c"'},{id:"4i",label:"4",count:4,cols:2,rows:3,areas:'"a b" "c c" "d d"'},{id:"5t",label:"5",count:5,cols:4,rows:2,areas:'"a a a a" "b c d e"'},{id:"5h",label:"5",count:5,cols:5,rows:1,areas:'"a b c d e"'},{id:"5v",label:"5",count:5,cols:1,rows:5,areas:'"a" "b" "c" "d" "e"'},{id:"5l",label:"5",count:5,cols:2,rows:4,areas:'"a b" "a c" "a d" "a e"'},{id:"5r",label:"5",count:5,cols:2,rows:4,areas:'"a b" "c b" "d b" "e b"'},{id:"5b",label:"5",count:5,cols:4,rows:2,areas:'"a b c d" "e e e e"'},{id:"5j",label:"5",count:5,cols:3,rows:3,areas:'"a b c" "a b d" "a b e"'},{id:"5k",label:"5",count:5,cols:3,rows:3,areas:'"a b c" "d b c" "e b c"'},{id:"6g",label:"6",count:6,cols:3,rows:2,areas:'"a b c" "d e f"'},{id:"6h",label:"6",count:6,cols:6,rows:1,areas:'"a b c d e f"'},{id:"6v",label:"6",count:6,cols:1,rows:6,areas:'"a" "b" "c" "d" "e" "f"'},{id:"6f",label:"6",count:6,cols:2,rows:3,areas:'"a b" "c d" "e f"'},{id:"6t",label:"6",count:6,cols:4,rows:2,areas:'"a a b b" "c d e f"'},{id:"6b",label:"6",count:6,cols:4,rows:2,areas:'"a b c d" "e e f f"'},{id:"7h",label:"7",count:7,cols:7,rows:1,areas:'"a b c d e f g"'},{id:"7l",label:"7",count:7,cols:2,rows:6,areas:'"a b" "a c" "a d" "a e" "a f" "a g"'},{id:"8g",label:"8",count:8,cols:4,rows:2,areas:'"a b c d" "e f g h"'},{id:"8h",label:"8",count:8,cols:2,rows:4,areas:'"a b" "c d" "e f" "g h"'}],p2=["a","b","c","d","e","f","g","h"];function m2({p:e,active:t,size:n=32}){let r=.8571428571428571,o=n,a=n*r,i=(e.areas.match(/"([^"]+)"/g)??['"a"']).map(m=>m.replace(/"/g,"").trim().split(/\s+/)),s=i.length,l=i[0].length,c=o/l,u=a/s,d=[];for(let m=0;m<s;m++)for(let f=0;f<l-1;f++)if(i[m][f]!==i[m][f+1]){let h=(f+1)*c;d.push(So("line",{x1:h,y1:m*u,x2:h,y2:(m+1)*u,strokeWidth:1},`v-${m}-${f}`))}for(let m=0;m<s-1;m++)for(let f=0;f<l;f++)if(i[m][f]!==i[m+1][f]){let h=(m+1)*u;d.push(So("line",{x1:f*c,y1:h,x2:(f+1)*c,y2:h,strokeWidth:1},`h-${m}-${f}`))}return So("div",{className:`rounded-md p-[5px] ${t?"bg-[#272b35]":"bg-transparent"} transition stroke-[#A8AFBD] group-hover:stroke-white`,children:Fu("svg",{width:o,height:a,viewBox:`0 0 ${o} ${a}`,children:[So("rect",{x:.5,y:.5,width:o-1,height:a-1,rx:2.5,fill:"transparent",strokeWidth:1}),d]})})}var L8=[{key:"symbol",label:"Symbol",hint:"All charts follow the symbol you pick"},{key:"interval",label:"Interval",hint:"All charts follow the timeframe you pick"},{key:"crosshair",label:"Crosshair",hint:"Show the hovered bar on every chart"},{key:"time",label:"Time",hint:"Scrolling one chart scrolls the rest; zoom stays per chart"},{key:"dateRange",label:"Date Range",hint:"Every chart shows the exact same range"}];function h2({current:e,onChange:t,syncInLayout:n,setSyncInLayout:r}){let a=M8(()=>{let i=1,s=[],l=[];for(let c of dg)c.count!==i&&(i=c.count,s.length&&l.push(s),s=[]),s.push(c);return s.length&&l.push(s),l},[])();return Fu(Ha,{children:[So(Va,{asChild:!0,children:So(pr,{variant:"outline",className:"group hover:bg-muted w-7 p-0 h-7 border-none",children:So(m2,{p:e,active:!1,size:22})})}),Fu(va,{className:"p-3 flex flex-col gap-1.5 w-fit",children:[So("div",{className:"text-xs text-muted-foreground tracking-wide border-b pb-2",children:"LAYOUT"}),a.map((i,s)=>Fu(I8.Fragment,{children:[Fu("div",{className:"flex gap-2 items-center w-full",children:[So("div",{className:"text-xs text-muted-foreground w-4",children:i[0]?.count}),So("div",{className:"flex gap-1 w-full",children:i.map(l=>{let c=l.id===e.id;return So(ta,{onClick:()=>t(l),className:"flex flex-col items-center gap-1 p-0 rounded-md w-fit cursor-pointer hover:!bg-[#272b35] group",children:So(m2,{p:l,active:c,size:20})},l.id)})})]}),s<a.length-1&&So(mc,{})]},i[0]?.count??s)),So("div",{className:"text-xs text-muted-foreground tracking-wide border-b pb-2 space-y-2 mt-4",children:"SYNC IN LAYOUT"}),So("div",{className:"flex flex-col gap-2 text-[13px] text-muted-foreground font-[400]",children:L8.map(({key:i,label:s,hint:l})=>Fu("label",{title:l,className:"flex w-full justify-between items-center gap-6 cursor-pointer",children:[So("span",{children:s}),So(Qr,{checked:n[i],onCheckedChange:c=>r({...n,[i]:c}),className:"data-[state=checked]:bg-blue-500"})]},i))})]})]})}import R8,{useState as Tw,useLayoutEffect as P8}from"react";import{Fragment as A8,jsx as fg,jsxs as B8}from"react/jsx-runtime";function Iw(e,t,n,r){if(r<=0)return e;let o=[...e],a=o.reduce((d,m)=>d+m,0),i=o[t]+o[t+1],s=0;for(let d=0;d<t;d++)s+=o[d];let l=s/a*r,c=a*.08,u=(n-l)/r*a;return u=Math.max(c,Math.min(i-c,u)),o[t]=u,o[t+1]=i-u,o}var Mw=e=>e.map(t=>`${t}fr`).join(" ");function D8(e,t,n){let r=(t.match(/"([^"]+)"/g)??[]).map(m=>m.replace(/"/g,"").trim().split(/\s+/));if(e>=r.length-1)return[];let o=r[e],a=r[e+1],i=o.length,s=n.reduce((m,f)=>m+f,0),l=[],c=0;for(let m of n)l.push(c/s),c+=m;l.push(1);let u=[],d=null;for(let m=0;m<i;m++)o[m]===a[m]?d!==null&&(u.push({left:l[d],right:l[m]}),d=null):d===null&&(d=m);return d!==null&&u.push({left:l[d],right:l[i]}),u}function Lw({dir:e,sizes:t,containerRef:n,onDrag:r,areas:o,colSizes:a}){let[i,s]=Tw([]),[l,c]=Tw({w:0,h:0}),[u,d]=Tw(!1);P8(()=>{let f=n.current;if(!f)return;let h=()=>{let g=e==="col"?f.clientWidth:f.clientHeight,y=t.reduce((S,C)=>S+C,0),v=0,b=[];for(let S=0;S<t.length-1;S++)v+=t[S]/y*g,b.push(v);s(b),c({w:f.clientWidth,h:f.clientHeight})};h();let p=new ResizeObserver(h);return p.observe(f),()=>p.disconnect()},[e,t,n]);let m=e==="col";return B8(A8,{children:[u&&fg("div",{style:{position:"fixed",inset:0,zIndex:9999,cursor:m?"col-resize":"row-resize"}}),i.map((f,h)=>{let p=!m&&o&&a?D8(h,o,a):null,g=y=>{y.preventDefault(),y.stopPropagation(),d(!0),em.lock();let v=0,b=0,S=()=>{v=0,r(h,b)},C=k=>{let M=n.current;if(!M)return;let I=M.getBoundingClientRect();b=m?k.clientX-I.left:k.clientY-I.top,v||(v=requestAnimationFrame(S))},w=()=>{d(!1),em.unlock(),v&&cancelAnimationFrame(v),window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",w)};window.addEventListener("mousemove",C),window.addEventListener("mouseup",w)};return m?fg("div",{style:{position:"absolute",left:f-7,top:1,width:12,bottom:3,cursor:"col-resize",zIndex:40,display:"flex",alignItems:"center",justifyContent:"center"},onMouseDown:g,className:"hover:bg-muted-foreground/15 active:bg-muted-foreground/15"},h):fg(R8.Fragment,{children:(p??[{left:0,right:1}]).map((y,v)=>{let b=y.left*l.w,S=(1-y.right)*l.w;return fg("div",{style:{position:"absolute",top:f-7,left:b,right:S+3,height:12,cursor:"row-resize",zIndex:40,display:"flex",alignItems:"center",justifyContent:"center"},onMouseDown:g,className:"hover:bg-muted-foreground/15 active:bg-muted-foreground/15"},v)})},h)})]})}import oD,{useCallback as $w,useEffect as Tm,useRef as Xw,useState as dl}from"react";import*as k2 from"react";import{createContext as N8,useLayoutEffect as E8,useRef as ia,forwardRef as T2,createElement as Uu,useContext as I2,useImperativeHandle as M2,useState as Wu,useCallback as aa,useEffect as vc,useMemo as O8}from"react";var bg=N8(null);bg.displayName="PanelGroupContext";var Br={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},Ew=10,wc=E8,g2=k2.useId,_8=typeof g2=="function"?g2:()=>null,F8=0;function Ow(e=null){let t=_8(),n=ia(e||t||null);return n.current===null&&(n.current=""+F8++),e??n.current}function L2({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:o,forwardedRef:a,id:i,maxSize:s,minSize:l,onCollapse:c,onExpand:u,onResize:d,order:m,style:f,tagName:h="div",...p}){let g=I2(bg);if(g===null)throw Error("Panel components must be rendered within a PanelGroup container");let{collapsePanel:y,expandPanel:v,getPanelSize:b,getPanelStyle:S,groupId:C,isPanelCollapsed:w,reevaluatePanelConstraints:k,registerPanel:M,resizePanel:I,unregisterPanel:x}=g,T=Ow(i),R=ia({callbacks:{onCollapse:c,onExpand:u,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:o,maxSize:s,minSize:l},id:T,idIsFromProps:i!==void 0,order:m});ia({didLogMissingDefaultSizeWarning:!1}),wc(()=>{let{callbacks:D,constraints:N}=R.current,O={...N};R.current.id=T,R.current.idIsFromProps=i!==void 0,R.current.order=m,D.onCollapse=c,D.onExpand=u,D.onResize=d,N.collapsedSize=n,N.collapsible=r,N.defaultSize=o,N.maxSize=s,N.minSize=l,(O.collapsedSize!==N.collapsedSize||O.collapsible!==N.collapsible||O.maxSize!==N.maxSize||O.minSize!==N.minSize)&&k(R.current,O)}),wc(()=>{let D=R.current;return M(D),()=>{x(D)}},[m,T,M,x]),M2(a,()=>({collapse:()=>{y(R.current)},expand:D=>{v(R.current,D)},getId(){return T},getSize(){return b(R.current)},isCollapsed(){return w(R.current)},isExpanded(){return!w(R.current)},resize:D=>{I(R.current,D)}}),[y,v,b,w,T,I]);let P=S(R.current,o);return Uu(h,{...p,children:e,className:t,id:T,style:{...P,...f},[Br.groupId]:C,[Br.panel]:"",[Br.panelCollapsible]:r||void 0,[Br.panelId]:T,[Br.panelSize]:parseFloat(""+P.flexGrow).toFixed(1)})}var _w=T2((e,t)=>Uu(L2,{...e,forwardedRef:t}));L2.displayName="Panel";_w.displayName="forwardRef(Panel)";var z8;function H8(){return z8}var Nw=null,V8=!0,pg=-1,vs=null;function W8(e,t){if(t){let n=(t&B2)!==0,r=(t&N2)!==0,o=(t&E2)!==0,a=(t&O2)!==0;if(n)return o?"se-resize":a?"ne-resize":"e-resize";if(r)return o?"sw-resize":a?"nw-resize":"w-resize";if(o)return"s-resize";if(a)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function q8(){vs!==null&&(document.head.removeChild(vs),Nw=null,vs=null,pg=-1)}function Rw(e,t){var n,r;if(!V8)return;let o=W8(e,t);if(Nw!==o){if(Nw=o,vs===null){vs=document.createElement("style");let i=H8();i&&vs.setAttribute("nonce",i),document.head.appendChild(vs)}if(pg>=0){var a;(a=vs.sheet)===null||a===void 0||a.removeRule(pg)}pg=(n=(r=vs.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${o} !important;}`))!==null&&n!==void 0?n:-1}}function R2(e){return e.type==="keydown"}function P2(e){return e.type.startsWith("pointer")}function D2(e){return e.type.startsWith("mouse")}function yg(e){if(P2(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(D2(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function U8(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function j8(e,t,n){return n?e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y:e.x<=t.x+t.width&&e.x+e.width>=t.x&&e.y<=t.y+t.height&&e.y+e.height>=t.y}function G8(e,t){if(e===t)throw new Error("Cannot compare node with itself");let n={a:v2(e),b:v2(t)},r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Sn(r,"Stacking order can only be calculated for elements with a common ancestor");let o={a:y2(b2(n.a)),b:y2(b2(n.b))};if(o.a===o.b){let a=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)},s=a.length;for(;s--;){let l=a[s];if(l===i.a)return 1;if(l===i.b)return-1}}return Math.sign(o.a-o.b)}var Y8=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function K8(e){var t;let n=getComputedStyle((t=A2(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function $8(e){let t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||K8(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Y8.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function b2(e){let t=e.length;for(;t--;){let n=e[t];if(Sn(n,"Missing node"),$8(n))return n}return null}function y2(e){return e&&Number(getComputedStyle(e).zIndex)||0}function v2(e){let t=[];for(;e;)t.push(e),e=A2(e);return t}function A2(e){let{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}var B2=1,N2=2,E2=4,O2=8,X8=U8()==="coarse",Ii=[],qu=!1,yc=new Map,vg=new Map,Sm=new Set;function Z8(e,t,n,r,o){var a;let{ownerDocument:i}=t,s={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},l=(a=yc.get(i))!==null&&a!==void 0?a:0;return yc.set(i,l+1),Sm.add(s),hg(),function(){var u;vg.delete(e),Sm.delete(s);let d=(u=yc.get(i))!==null&&u!==void 0?u:1;if(yc.set(i,d-1),hg(),d===1&&yc.delete(i),Ii.includes(s)){let m=Ii.indexOf(s);m>=0&&Ii.splice(m,1),zw(),o("up",!0,null)}}}function Q8(e){let{target:t}=e,{x:n,y:r}=yg(e);qu=!0,Fw({target:t,x:n,y:r}),hg(),Ii.length>0&&(gg("down",e),e.preventDefault(),_2(t)||e.stopImmediatePropagation())}function Pw(e){let{x:t,y:n}=yg(e);if(qu&&e.buttons===0&&(qu=!1,gg("up",e)),!qu){let{target:r}=e;Fw({target:r,x:t,y:n})}gg("move",e),zw(),Ii.length>0&&e.preventDefault()}function Dw(e){let{target:t}=e,{x:n,y:r}=yg(e);vg.clear(),qu=!1,Ii.length>0&&(e.preventDefault(),_2(t)||e.stopImmediatePropagation()),gg("up",e),Fw({target:t,x:n,y:r}),zw(),hg()}function _2(e){let t=e;for(;t;){if(t.hasAttribute(Br.resizeHandle))return!0;t=t.parentElement}return!1}function Fw({target:e,x:t,y:n}){Ii.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Sm.forEach(o=>{let{element:a,hitAreaMargins:i}=o,s=a.getBoundingClientRect(),{bottom:l,left:c,right:u,top:d}=s,m=X8?i.coarse:i.fine;if(t>=c-m&&t<=u+m&&n>=d-m&&n<=l+m){if(r!==null&&document.contains(r)&&a!==r&&!a.contains(r)&&!r.contains(a)&&G8(r,a)>0){let h=r,p=!1;for(;h&&!h.contains(a);){if(j8(h.getBoundingClientRect(),s,!0)){p=!0;break}h=h.parentElement}if(p)return}Ii.push(o)}})}function Aw(e,t){vg.set(e,t)}function zw(){let e=!1,t=!1;Ii.forEach(r=>{let{direction:o}=r;o==="horizontal"?e=!0:t=!0});let n=0;vg.forEach(r=>{n|=r}),e&&t?Rw("intersection",n):e?Rw("horizontal",n):t?Rw("vertical",n):q8()}var Bw=new AbortController;function hg(){Bw.abort(),Bw=new AbortController;let e={capture:!0,signal:Bw.signal};Sm.size&&(qu?(Ii.length>0&&yc.forEach((t,n)=>{let{body:r}=n;t>0&&(r.addEventListener("contextmenu",Dw,e),r.addEventListener("pointerleave",Pw,e),r.addEventListener("pointermove",Pw,e))}),window.addEventListener("pointerup",Dw,e),window.addEventListener("pointercancel",Dw,e)):yc.forEach((t,n)=>{let{body:r}=n;t>0&&(r.addEventListener("pointerdown",Q8,e),r.addEventListener("pointermove",Pw,e))}))}function gg(e,t){Sm.forEach(n=>{let{setResizeHandlerState:r}=n,o=Ii.includes(n);r(e,o,t)})}function J8(){let[e,t]=Wu(0);return aa(()=>t(n=>n+1),[])}function Sn(e,t){if(!e)throw console.error(t),Error(t)}function xc(e,t,n=Ew){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function ws(e,t,n=Ew){return xc(e,t,n)===0}function Ca(e,t,n){return xc(e,t,n)===0}function eq(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let o=e[r],a=t[r];if(!Ca(o,a,n))return!1}return!0}function Vu({panelConstraints:e,panelIndex:t,size:n}){let r=e[t];Sn(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:a,maxSize:i=100,minSize:s=0}=r;if(xc(n,s)<0)if(a){let l=(o+s)/2;xc(n,l)<0?n=o:n=s}else n=s;return n=Math.min(i,n),n=parseFloat(n.toFixed(Ew)),n}function wm({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:a}){if(Ca(e,0))return t;let i=[...t],[s,l]=r;Sn(s!=null,"Invalid first pivot index"),Sn(l!=null,"Invalid second pivot index");let c=0;if(a==="keyboard"){{let d=e<0?l:s,m=n[d];Sn(m,`Panel constraints not found for index ${d}`);let{collapsedSize:f=0,collapsible:h,minSize:p=0}=m;if(h){let g=t[d];if(Sn(g!=null,`Previous layout not found for panel index ${d}`),Ca(g,f)){let y=p-g;xc(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{let d=e<0?s:l,m=n[d];Sn(m,`No panel constraints found for index ${d}`);let{collapsedSize:f=0,collapsible:h,minSize:p=0}=m;if(h){let g=t[d];if(Sn(g!=null,`Previous layout not found for panel index ${d}`),Ca(g,p)){let y=g-f;xc(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}}{let d=e<0?1:-1,m=e<0?l:s,f=0;for(;;){let p=t[m];Sn(p!=null,`Previous layout not found for panel index ${m}`);let y=Vu({panelConstraints:n,panelIndex:m,size:100})-p;if(f+=y,m+=d,m<0||m>=n.length)break}let h=Math.min(Math.abs(e),Math.abs(f));e=e<0?0-h:h}{let m=e<0?s:l;for(;m>=0&&m<n.length;){let f=Math.abs(e)-Math.abs(c),h=t[m];Sn(h!=null,`Previous layout not found for panel index ${m}`);let p=h-f,g=Vu({panelConstraints:n,panelIndex:m,size:p});if(!Ca(h,g)&&(c+=h-g,i[m]=g,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(eq(o,i))return o;{let d=e<0?l:s,m=t[d];Sn(m!=null,`Previous layout not found for panel index ${d}`);let f=m+c,h=Vu({panelConstraints:n,panelIndex:d,size:f});if(i[d]=h,!Ca(h,f)){let p=f-h,y=e<0?l:s;for(;y>=0&&y<n.length;){let v=i[y];Sn(v!=null,`Previous layout not found for panel index ${y}`);let b=v+p,S=Vu({panelConstraints:n,panelIndex:y,size:b});if(Ca(v,S)||(p-=S-v,i[y]=S),Ca(p,0))break;e>0?y--:y++}}}let u=i.reduce((d,m)=>m+d,0);return Ca(u,100)?i:o}function tq({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,a=0,i=0,s=n[0];Sn(s!=null,"No pivot index found"),t.forEach((d,m)=>{let{constraints:f}=d,{maxSize:h=100,minSize:p=0}=f;m===s?(r=p,o=h):(a+=p,i+=h)});let l=Math.min(o,100-a),c=Math.max(r,100-i),u=e[s];return{valueMax:l,valueMin:c,valueNow:u}}function Cm(e,t=document){return Array.from(t.querySelectorAll(`[${Br.resizeHandleId}][data-panel-group-id="${e}"]`))}function F2(e,t,n=document){let o=Cm(e,n).findIndex(a=>a.getAttribute(Br.resizeHandleId)===t);return o??null}function z2(e,t,n){let r=F2(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function H2(e,t=document){var n;if(t instanceof HTMLElement&&(t==null||(n=t.dataset)===null||n===void 0?void 0:n.panelGroupId)==e)return t;let r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function wg(e,t=document){let n=t.querySelector(`[${Br.resizeHandleId}="${e}"]`);return n||null}function nq(e,t,n,r=document){var o,a,i,s;let l=wg(t,r),c=Cm(e,r),u=l?c.indexOf(l):-1,d=(o=(a=n[u])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null,m=(i=(s=n[u+1])===null||s===void 0?void 0:s.id)!==null&&i!==void 0?i:null;return[d,m]}function rq({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:a,setLayout:i}){ia({didWarnAboutMissingResizeHandle:!1}),wc(()=>{if(!a)return;let s=Cm(n,a);for(let l=0;l<o.length-1;l++){let{valueMax:c,valueMin:u,valueNow:d}=tq({layout:r,panelsArray:o,pivotIndices:[l,l+1]}),m=s[l];if(m!=null){let f=o[l];Sn(f,`No panel data found for index "${l}"`),m.setAttribute("aria-controls",f.id),m.setAttribute("aria-valuemax",""+Math.round(c)),m.setAttribute("aria-valuemin",""+Math.round(u)),m.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{s.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[n,r,o,a]),vc(()=>{if(!a)return;let s=t.current;Sn(s,"Eager values not found");let{panelDataArray:l}=s,c=H2(n,a);Sn(c!=null,`No group found for id "${n}"`);let u=Cm(n,a);Sn(u,`No resize handles found for group id "${n}"`);let d=u.map(m=>{let f=m.getAttribute(Br.resizeHandleId);Sn(f,"Resize handle element has no handle id attribute");let[h,p]=nq(n,f,l,a);if(h==null||p==null)return()=>{};let g=y=>{if(!y.defaultPrevented)switch(y.key){case"Enter":{y.preventDefault();let v=l.findIndex(b=>b.id===h);if(v>=0){let b=l[v];Sn(b,`No panel data found for index ${v}`);let S=r[v],{collapsedSize:C=0,collapsible:w,minSize:k=0}=b.constraints;if(S!=null&&w){let M=wm({delta:Ca(S,C)?k-C:C-S,initialLayout:r,panelConstraints:l.map(I=>I.constraints),pivotIndices:z2(n,f,a),prevLayout:r,trigger:"keyboard"});r!==M&&i(M)}}break}}};return m.addEventListener("keydown",g),()=>{m.removeEventListener("keydown",g)}});return()=>{d.forEach(m=>m())}},[a,e,t,n,r,o,i])}function w2(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function V2(e,t){let n=e==="horizontal",{x:r,y:o}=yg(t);return n?r:o}function oq(e,t,n,r,o){let a=n==="horizontal",i=wg(t,o);Sn(i,`No resize handle element found for id "${t}"`);let s=i.getAttribute(Br.groupId);Sn(s,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r,c=V2(n,e),u=H2(s,o);Sn(u,`No group element found for id "${s}"`);let d=u.getBoundingClientRect(),m=a?d.width:d.height;return(c-l)/m*100}function aq(e,t,n,r,o,a){if(R2(e)){let i=n==="horizontal",s=0;e.shiftKey?s=100:o!=null?s=o:s=10;let l=0;switch(e.key){case"ArrowDown":l=i?0:s;break;case"ArrowLeft":l=i?-s:0;break;case"ArrowRight":l=i?s:0;break;case"ArrowUp":l=i?0:-s;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:oq(e,t,n,r,a)}function iq({panelDataArray:e}){let t=Array(e.length),n=e.map(a=>a.constraints),r=0,o=100;for(let a=0;a<e.length;a++){let i=n[a];Sn(i,`Panel constraints not found for index ${a}`);let{defaultSize:s}=i;s!=null&&(r++,t[a]=s,o-=s)}for(let a=0;a<e.length;a++){let i=n[a];Sn(i,`Panel constraints not found for index ${a}`);let{defaultSize:s}=i;if(s!=null)continue;let l=e.length-r,c=o/l;r++,t[a]=c,o-=c}return t}function zu(e,t,n){t.forEach((r,o)=>{let a=e[o];Sn(a,`Panel data not found for index ${o}`);let{callbacks:i,constraints:s,id:l}=a,{collapsedSize:c=0,collapsible:u}=s,d=n[l];if(d==null||r!==d){n[l]=r;let{onCollapse:m,onExpand:f,onResize:h}=i;h&&h(r,d),u&&(m||f)&&(f&&(d==null||ws(d,c))&&!ws(r,c)&&f(),m&&(d==null||!ws(d,c))&&ws(r,c)&&m())}})}function mg(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function sq({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:o,precision:a=3}){let i=n[o],s;return i==null?s=e!=null?e.toPrecision(a):"1":r.length===1?s="1":s=i.toPrecision(a),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function lq(e,t=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},t)}}function x2(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function W2(e){return`react-resizable-panels:${e}`}function q2(e){return e.map(t=>{let{constraints:n,id:r,idIsFromProps:o,order:a}=t;return o?r:a?`${a}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function U2(e,t){try{let n=W2(e),r=t.getItem(n);if(r){let o=JSON.parse(r);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function cq(e,t,n){var r,o;let a=(r=U2(e,n))!==null&&r!==void 0?r:{},i=q2(t);return(o=a[i])!==null&&o!==void 0?o:null}function uq(e,t,n,r,o){var a;let i=W2(e),s=q2(t),l=(a=U2(e,o))!==null&&a!==void 0?a:{};l[s]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{o.setItem(i,JSON.stringify(l))}catch(c){console.error(c)}}function S2({layout:e,panelConstraints:t}){let n=[...e],r=n.reduce((a,i)=>a+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(a=>`${a}%`).join(", ")}`);if(!Ca(r,100)&&n.length>0)for(let a=0;a<t.length;a++){let i=n[a];Sn(i!=null,`No layout data found for index ${a}`);let s=100/r*i;n[a]=s}let o=0;for(let a=0;a<t.length;a++){let i=n[a];Sn(i!=null,`No layout data found for index ${a}`);let s=Vu({panelConstraints:t,panelIndex:a,size:i});i!=s&&(o+=i-s,n[a]=s)}if(!Ca(o,0))for(let a=0;a<t.length;a++){let i=n[a];Sn(i!=null,`No layout data found for index ${a}`);let s=i+o,l=Vu({panelConstraints:t,panelIndex:a,size:s});if(i!==l&&(o-=l-i,n[a]=l,Ca(o,0)))break}return n}var dq=100,xm={getItem:e=>(x2(xm),xm.getItem(e)),setItem:(e,t)=>{x2(xm),xm.setItem(e,t)}},C2={};function j2({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:a=null,onLayout:i=null,keyboardResizeBy:s=null,storage:l=xm,style:c,tagName:u="div",...d}){let m=Ow(a),f=ia(null),[h,p]=Wu(null),[g,y]=Wu([]),v=J8(),b=ia({}),S=ia(new Map),C=ia(0),w=ia({autoSaveId:e,direction:r,dragState:h,id:m,keyboardResizeBy:s,onLayout:i,storage:l}),k=ia({layout:g,panelDataArray:[],panelDataArrayChanged:!1});ia({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),M2(o,()=>({getId:()=>w.current.id,getLayout:()=>{let{layout:G}=k.current;return G},setLayout:G=>{let{onLayout:H}=w.current,{layout:W,panelDataArray:U}=k.current,V=S2({layout:G,panelConstraints:U.map(K=>K.constraints)});w2(W,V)||(y(V),k.current.layout=V,H&&H(V),zu(U,V,b.current))}}),[]),wc(()=>{w.current.autoSaveId=e,w.current.direction=r,w.current.dragState=h,w.current.id=m,w.current.onLayout=i,w.current.storage=l}),rq({committedValuesRef:w,eagerValuesRef:k,groupId:m,layout:g,panelDataArray:k.current.panelDataArray,setLayout:y,panelGroupElement:f.current}),vc(()=>{let{panelDataArray:G}=k.current;if(e){if(g.length===0||g.length!==G.length)return;let H=C2[e];H==null&&(H=lq(uq,dq),C2[e]=H);let W=[...G],U=new Map(S.current);H(e,W,U,g,l)}},[e,g,l]),vc(()=>{});let M=aa(G=>{let{onLayout:H}=w.current,{layout:W,panelDataArray:U}=k.current;if(G.constraints.collapsible){let V=U.map(ze=>ze.constraints),{collapsedSize:K=0,panelSize:Z,pivotIndices:de}=bc(U,G,W);if(Sn(Z!=null,`Panel size not found for panel "${G.id}"`),!ws(Z,K)){S.current.set(G.id,Z);let xe=Hu(U,G)===U.length-1?Z-K:K-Z,Ae=wm({delta:xe,initialLayout:W,panelConstraints:V,pivotIndices:de,prevLayout:W,trigger:"imperative-api"});mg(W,Ae)||(y(Ae),k.current.layout=Ae,H&&H(Ae),zu(U,Ae,b.current))}}},[]),I=aa((G,H)=>{let{onLayout:W}=w.current,{layout:U,panelDataArray:V}=k.current;if(G.constraints.collapsible){let K=V.map(Oe=>Oe.constraints),{collapsedSize:Z=0,panelSize:de=0,minSize:ze=0,pivotIndices:xe}=bc(V,G,U),Ae=H??ze;if(ws(de,Z)){let Oe=S.current.get(G.id),ke=Oe!=null&&Oe>=Ae?Oe:Ae,Pe=Hu(V,G)===V.length-1?de-ke:ke-de,_=wm({delta:Pe,initialLayout:U,panelConstraints:K,pivotIndices:xe,prevLayout:U,trigger:"imperative-api"});mg(U,_)||(y(_),k.current.layout=_,W&&W(_),zu(V,_,b.current))}}},[]),x=aa(G=>{let{layout:H,panelDataArray:W}=k.current,{panelSize:U}=bc(W,G,H);return Sn(U!=null,`Panel size not found for panel "${G.id}"`),U},[]),T=aa((G,H)=>{let{panelDataArray:W}=k.current,U=Hu(W,G);return sq({defaultSize:H,dragState:h,layout:g,panelData:W,panelIndex:U})},[h,g]),R=aa(G=>{let{layout:H,panelDataArray:W}=k.current,{collapsedSize:U=0,collapsible:V,panelSize:K}=bc(W,G,H);return Sn(K!=null,`Panel size not found for panel "${G.id}"`),V===!0&&ws(K,U)},[]),P=aa(G=>{let{layout:H,panelDataArray:W}=k.current,{collapsedSize:U=0,collapsible:V,panelSize:K}=bc(W,G,H);return Sn(K!=null,`Panel size not found for panel "${G.id}"`),!V||xc(K,U)>0},[]),D=aa(G=>{let{panelDataArray:H}=k.current;H.push(G),H.sort((W,U)=>{let V=W.order,K=U.order;return V==null&&K==null?0:V==null?-1:K==null?1:V-K}),k.current.panelDataArrayChanged=!0,v()},[v]);wc(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;let{autoSaveId:G,onLayout:H,storage:W}=w.current,{layout:U,panelDataArray:V}=k.current,K=null;if(G){let de=cq(G,V,W);de&&(S.current=new Map(Object.entries(de.expandToSizes)),K=de.layout)}K==null&&(K=iq({panelDataArray:V}));let Z=S2({layout:K,panelConstraints:V.map(de=>de.constraints)});w2(U,Z)||(y(Z),k.current.layout=Z,H&&H(Z),zu(V,Z,b.current))}}),wc(()=>{let G=k.current;return()=>{G.layout=[]}},[]);let N=aa(G=>{let H=!1,W=f.current;return W&&window.getComputedStyle(W,null).getPropertyValue("direction")==="rtl"&&(H=!0),function(V){V.preventDefault();let K=f.current;if(!K)return()=>null;let{direction:Z,dragState:de,id:ze,keyboardResizeBy:xe,onLayout:Ae}=w.current,{layout:Oe,panelDataArray:ke}=k.current,{initialLayout:Q}=de??{},Pe=z2(ze,G,K),_=aq(V,G,Z,de,xe,K),ie=Z==="horizontal";ie&&H&&(_=-_);let se=ke.map(ye=>ye.constraints),Se=wm({delta:_,initialLayout:Q??Oe,panelConstraints:se,pivotIndices:Pe,prevLayout:Oe,trigger:R2(V)?"keyboard":"mouse-or-touch"}),Re=!mg(Oe,Se);(P2(V)||D2(V))&&C.current!=_&&(C.current=_,!Re&&_!==0?ie?Aw(G,_<0?B2:N2):Aw(G,_<0?E2:O2):Aw(G,0)),Re&&(y(Se),k.current.layout=Se,Ae&&Ae(Se),zu(ke,Se,b.current))}},[]),O=aa((G,H)=>{let{onLayout:W}=w.current,{layout:U,panelDataArray:V}=k.current,K=V.map(Oe=>Oe.constraints),{panelSize:Z,pivotIndices:de}=bc(V,G,U);Sn(Z!=null,`Panel size not found for panel "${G.id}"`);let xe=Hu(V,G)===V.length-1?Z-H:H-Z,Ae=wm({delta:xe,initialLayout:U,panelConstraints:K,pivotIndices:de,prevLayout:U,trigger:"imperative-api"});mg(U,Ae)||(y(Ae),k.current.layout=Ae,W&&W(Ae),zu(V,Ae,b.current))},[]),A=aa((G,H)=>{let{layout:W,panelDataArray:U}=k.current,{collapsedSize:V=0,collapsible:K}=H,{collapsedSize:Z=0,collapsible:de,maxSize:ze=100,minSize:xe=0}=G.constraints,{panelSize:Ae}=bc(U,G,W);Ae!=null&&(K&&de&&ws(Ae,V)?ws(V,Z)||O(G,Z):Ae<xe?O(G,xe):Ae>ze&&O(G,ze))},[O]),B=aa((G,H)=>{let{direction:W}=w.current,{layout:U}=k.current;if(!f.current)return;let V=wg(G,f.current);Sn(V,`Drag handle element not found for id "${G}"`);let K=V2(W,H);p({dragHandleId:G,dragHandleRect:V.getBoundingClientRect(),initialCursorPosition:K,initialLayout:U})},[]),E=aa(()=>{p(null)},[]),L=aa(G=>{let{panelDataArray:H}=k.current,W=Hu(H,G);W>=0&&(H.splice(W,1),delete b.current[G.id],k.current.panelDataArrayChanged=!0,v())},[v]),z=O8(()=>({collapsePanel:M,direction:r,dragState:h,expandPanel:I,getPanelSize:x,getPanelStyle:T,groupId:m,isPanelCollapsed:R,isPanelExpanded:P,reevaluatePanelConstraints:A,registerPanel:D,registerResizeHandle:N,resizePanel:O,startDragging:B,stopDragging:E,unregisterPanel:L,panelGroupElement:f.current}),[M,h,r,I,x,T,m,R,P,A,D,N,O,B,E,L]),Y={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Uu(bg.Provider,{value:z},Uu(u,{...d,children:t,className:n,id:a,ref:f,style:{...Y,...c},[Br.group]:"",[Br.groupDirection]:r,[Br.groupId]:m}))}var Hw=T2((e,t)=>Uu(j2,{...e,forwardedRef:t}));j2.displayName="PanelGroup";Hw.displayName="forwardRef(PanelGroup)";function Hu(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function bc(e,t,n){let r=Hu(e,t),a=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:a}}function fq({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){vc(()=>{if(e||n==null||r==null)return;let o=wg(t,r);if(o==null)return;let a=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();let s=o.getAttribute(Br.groupId);Sn(s,`No group element found for id "${s}"`);let l=Cm(s,r),c=F2(s,t,r);Sn(c!==null,`No resize element found for id "${t}"`);let u=i.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[u].focus();break}}};return o.addEventListener("keydown",a),()=>{o.removeEventListener("keydown",a)}},[r,e,t,n])}function Vw({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:o,onBlur:a,onClick:i,onDragging:s,onFocus:l,onPointerDown:c,onPointerUp:u,style:d={},tabIndex:m=0,tagName:f="div",...h}){var p,g;let y=ia(null),v=ia({onClick:i,onDragging:s,onPointerDown:c,onPointerUp:u});vc(()=>{v.current.onClick=i,v.current.onDragging=s,v.current.onPointerDown=c,v.current.onPointerUp=u});let b=I2(bg);if(b===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");let{direction:S,groupId:C,registerResizeHandle:w,startDragging:k,stopDragging:M,panelGroupElement:I}=b,x=Ow(o),[T,R]=Wu("inactive"),[P,D]=Wu(!1),[N,O]=Wu(null),A=ia({state:T});wc(()=>{A.current.state=T}),vc(()=>{if(n)O(null);else{let z=w(x);O(()=>z)}},[n,x,w]);let B=(p=r?.coarse)!==null&&p!==void 0?p:15,E=(g=r?.fine)!==null&&g!==void 0?g:5;return vc(()=>{if(n||N==null)return;let z=y.current;Sn(z,"Element ref not attached");let Y=!1;return Z8(x,z,S,{coarse:B,fine:E},(H,W,U)=>{if(!W){R("inactive");return}switch(H){case"down":{R("drag"),Y=!1,Sn(U,'Expected event to be defined for "down" action'),k(x,U);let{onDragging:V,onPointerDown:K}=v.current;V?.(!0),K?.();break}case"move":{let{state:V}=A.current;Y=!0,V!=="drag"&&R("hover"),Sn(U,'Expected event to be defined for "move" action'),N(U);break}case"up":{R("hover"),M();let{onClick:V,onDragging:K,onPointerUp:Z}=v.current;K?.(!1),Z?.(),Y||V?.();break}}})},[B,S,n,E,w,x,N,k,M]),fq({disabled:n,handleId:x,resizeHandler:N,panelGroupElement:I}),Uu(f,{...h,children:e,className:t,id:o,onBlur:()=>{D(!1),a?.()},onFocus:()=>{D(!0),l?.()},ref:y,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...d},tabIndex:m,[Br.groupDirection]:S,[Br.groupId]:C,[Br.resizeHandle]:"",[Br.resizeHandleActive]:T==="drag"?"pointer":P?"keyboard":void 0,[Br.resizeHandleEnabled]:!n,[Br.resizeHandleId]:x,[Br.resizeHandleState]:T})}Vw.displayName="PanelResizeHandle";import{jsx as xg}from"react/jsx-runtime";var G2=({className:e,...t})=>xg(Hw,{className:ee("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Y2=_w,K2=({withHandle:e,className:t,...n})=>xg(Vw,{className:ee("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&xg("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:xg(Bl,{className:"h-2.5 w-2.5"})})});import*as J2 from"react";import*as zr from"react";import{jsx as ul}from"react/jsx-runtime";var pq=Object.defineProperty,cl=(e,t)=>pq(e,"name",{value:t,configurable:!0}),Ww,Uw="HoverCard",[$2,Jle]=xr(Uw,[_a]),jw=_a(),[hq,Gw]=$2(Uw),gq=cl(e=>{let{__scopeHoverCard:t,children:n,open:r,defaultOpen:o,onOpenChange:a,openDelay:i=700,closeDelay:s=300}=e,l=jw(t),c=zr.useRef(0),u=zr.useRef(0),d=zr.useRef(!1),m=zr.useRef(!1),[f,h]=go({prop:r,defaultProp:o??!1,onChange:a,caller:Uw}),p=zr.useCallback(()=>{clearTimeout(u.current),c.current=window.setTimeout(()=>h(!0),i)},[i,h]),g=zr.useCallback(()=>{clearTimeout(c.current),!d.current&&!m.current&&(u.current=window.setTimeout(()=>h(!1),s))},[s,h]),y=zr.useCallback(()=>h(!1),[h]);return zr.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(u.current)},[]),ul(hq,{scope:t,open:f,onOpenChange:h,onOpen:p,onClose:g,onDismiss:y,hasSelectionRef:d,isPointerDownOnContentRef:m,children:ul(nl,{...l,children:n})})},"HoverCard"),bq="HoverCardTrigger",yq=zr.forwardRef(cl(function(t,n){let{__scopeHoverCard:r,...o}=t,a=Gw(bq,r),i=jw(r);return ul(os,{asChild:!0,...i,children:ul(dn.a,{"data-state":a.open?"open":"closed",...o,ref:n,onPointerEnter:lt(t.onPointerEnter,km(a.onOpen)),onPointerLeave:lt(t.onPointerLeave,km(a.onClose)),onFocus:lt(t.onFocus,a.onOpen),onBlur:lt(t.onBlur,a.onClose),onTouchStart:lt(t.onTouchStart,s=>s.preventDefault())})})},"HoverCardTrigger")),vq="HoverCardPortal",[ece,wq]=$2(vq,{forceMount:void 0});var qw="HoverCardContent",xq=zr.forwardRef(cl(function(t,n){let r=wq(qw,t.__scopeHoverCard),{forceMount:o=r.forceMount,...a}=t,i=Gw(qw,t.__scopeHoverCard);return ul(Uo,{present:o||i.open,children:ul(Sq,{"data-state":i.open?"open":"closed",...a,onPointerEnter:lt(t.onPointerEnter,km(i.onOpen)),onPointerLeave:lt(t.onPointerLeave,km(i.onClose)),ref:n})})},"HoverCardContent")),Sq=zr.forwardRef(cl(function(t,n){let{__scopeHoverCard:r,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:s,...l}=t,c=Gw(qw,r),u=jw(r),d=zr.useRef(null),m=Kt(n,d),[f,h]=zr.useState(!1);return zr.useEffect(()=>{if(f){let p=document.body;return Ww=p.style.userSelect||p.style.webkitUserSelect,p.style.userSelect="none",p.style.webkitUserSelect="none",()=>{p.style.userSelect=Ww,p.style.webkitUserSelect=Ww}}},[f]),zr.useEffect(()=>{if(d.current){let p=cl(()=>{h(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(c.hasSelectionRef.current=!0)})},"handlePointerUp");return document.addEventListener("pointerup",p),()=>{document.removeEventListener("pointerup",p),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),zr.useEffect(()=>{d.current&&X2(d.current).forEach(g=>g.setAttribute("tabindex","-1"))}),ul(Js,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:s,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:lt(i,p=>{p.preventDefault()}),onDismiss:c.onDismiss,children:ul(rl,{...u,...l,onPointerDown:lt(l.onPointerDown,p=>{p.currentTarget.contains(p.target)&&h(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:m,style:{...l.style,userSelect:f?"text":void 0,WebkitUserSelect:f?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})},"HoverCardContentImpl"));function km(e){return t=>t.pointerType==="touch"?void 0:e()}cl(km,"excludeTouch");function X2(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:cl(r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}cl(X2,"getTabbableNodes");var Z2=gq,Q2=yq;var Yw=xq;import{jsx as kq}from"react/jsx-runtime";var eD=Z2,tD=Q2,Kw=J2.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>kq(Yw,{ref:o,align:t,sideOffset:n,className:ee("depth-root z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r}));Kw.displayName=Yw.displayName;import{Fragment as dD,jsx as sr,jsxs as ka}from"react/jsx-runtime";function Zw({element:e}){return sr(dD,{children:e})}function aD({panel:e,pinned:t,onTogglePin:n,onDragHeader:r,onToggleVisibility:o,onDragStart:a,onDragEnd:i}){let s=l=>{l.dataTransfer.setData("text/plain",e.id),l.dataTransfer.effectAllowed="move",setTimeout(()=>a?.(),0)};return ka("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden bg-background",children:[ka("div",{className:ee("flex items-center h-8 px-2 gap-1.5 border-b border-border shrink-0 select-none bg-background","cursor-grab active:cursor-grabbing"),draggable:t,onDragStart:t?s:void 0,onDragEnd:t?i:void 0,onMouseDown:t?void 0:r,children:[sr("span",{className:"text-xs font-medium text-foreground/70 flex-1 truncate",children:e.title}),ka("div",{className:"flex flex-row items-center",children:[ka(Ht,{delayDuration:700,children:[sr(Ot,{asChild:!0,children:sr("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 rounded",onClick:n,children:t?sr(nf,{size:12}):sr(tf,{size:12})})}),sr(_t,{className:"bg-background border border-border",children:t?"Make floating":"Pin to sidebar"})]}),ka(Ht,{delayDuration:700,children:[sr(Ot,{asChild:!0,children:sr("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 rounded",onClick:o,children:sr(Yo,{size:12})})}),sr(_t,{className:"bg-background border border-border",children:"Hide window"})]})]})]}),sr("div",{className:"flex-1 overflow-auto min-h-0",children:sr(Zw,{element:e.element})})]})}function nD(){let e=qr(Cn.pluginPanels,{});return e&&typeof e=="object"?e:{}}function Qw(e,t){if(e.type==="panel")return e.id===t?null:e;let n=e.children.map(r=>Qw(r,t)).filter(Boolean);return n.length===0?null:n.length===1?n[0]:{...e,children:n}}function iD(e,t){if(!e)return null;if(e.type==="panel")return t.has(e.id)?e:null;let n=e.children.map(r=>iD(r,t)).filter(Boolean);return n.length===0?null:n.length===1?n[0]:{...e,children:n}}function sD(e,t){return e?e.type==="panel"?e.id===t:e.children.some(n=>sD(n,t)):!1}function rD(e,t){if(!e)return{type:"panel",id:t};let n=e.type==="split"&&e.direction==="vertical"?"horizontal":"vertical";return{type:"split",id:pn(),direction:n,children:[e,{type:"panel",id:t}]}}function lD(e,t,n,r){if(e.type==="panel"){if(e.id===n){let o=r==="top"||r==="bottom",a={type:"panel",id:t},i=r==="top"||r==="left"?[a,e]:[e,a];return{type:"split",id:pn(),direction:o?"vertical":"horizontal",children:i}}return e}return{...e,children:e.children.map(o=>lD(o,t,n,r))}}function Tq(e,t,n,r){if(t===n)return e;let o=Qw(e,t);return o?lD(o,t,n,r):{type:"panel",id:t}}function Iq({targetId:e,isDragging:t,onDropPosition:n,children:r}){let[o,a]=oD.useState(null),i=(l,c)=>{l.preventDefault(),l.stopPropagation(),a(null);let u=l.dataTransfer.getData("text/plain");u&&u!==e&&n(u,e,c)},s="absolute z-50 opacity-0 transition-all duration-200 border-blue-500 pointer-events-auto";return ka("div",{className:"relative flex-1 flex flex-col min-h-0 min-w-0 group",children:[r,t&&sr("div",{className:"absolute inset-0 pointer-events-none z-50",children:["top","bottom","left","right"].map(l=>{let c=o===l,u={top:"border-t-4",bottom:"border-b-4",left:"border-l-4",right:"border-r-4"}[l];return sr("div",{className:ee(s,l==="left"&&"top-0 bottom-0 left-0 w-[45%]",l==="right"&&"top-0 bottom-0 right-0 w-[45%]",l==="top"&&"top-0 left-0 right-0 h-[30%] z-[51]",l==="bottom"&&"bottom-0 left-0 right-0 h-[30%] z-[51]",c&&"opacity-100 bg-blue-500/20",c&&u),onDragLeave:()=>a(null),onDragOver:d=>{o!==l&&a(l),d.preventDefault(),d.dataTransfer.dropEffect="move"},onDrop:d=>i(d,l)},l)})})]})}function cD({node:e,panels:t,onTogglePin:n,onToggleVisibility:r,onMovePanel:o,chart:a,isDragging:i,setIsDragging:s}){if(e.type==="panel"){let l=t.find(c=>c.id===e.id);return l?sr(Iq,{targetId:l.id,onDropPosition:o,isDragging:i,children:sr(aD,{panel:l,pinned:!0,onTogglePin:()=>n(l.id),onToggleVisibility:()=>{r(l.id),a.setPanelVisible(l.id,!l.visible)},onDragStart:()=>s(!0),onDragEnd:()=>s(!1)})}):null}return sr(G2,{direction:e.direction,className:"flex flex-1 min-h-0 min-w-0 w-full h-full",children:e.children.map((l,c)=>{let u=l.type==="panel"?l.id:`split-${c}`;return ka(oD.Fragment,{children:[sr(Y2,{id:l.id,order:c,defaultSize:Math.round(100/e.children.length),minSize:10,className:"flex flex-col min-h-0 min-w-0 relative",children:sr(cD,{node:l,panels:t,onTogglePin:n,onToggleVisibility:r,onMovePanel:o,chart:a,isDragging:i,setIsDragging:s})}),c<e.children.length-1&&sr(K2,{})]},u)})})}var Mq=180,Lq=280,Rq=600;function uD({eventBus:e,chart:t,onFixedPanelsChange:n,override:r}){let o=Xw(nD()).current,[a,i]=dl(!1),[s,l]=dl([]),[c,u]=dl(()=>new Set(Object.entries(o.panels??{}).filter(([,O])=>O.pinned).map(([O])=>O))),[d,m]=dl(o.tree??null),[f,h]=dl(()=>new Map(Object.entries(o.panels??{}).filter(([,O])=>typeof O.x=="number"&&typeof O.y=="number").map(([O,A])=>[O,{x:A.x,y:A.y}]))),[p,g]=dl(o.sidebarWidth??Lq),y=Xw(!1),[v,b]=dl(new Map),[S,C]=dl(new Map),w=Xw(new Map),k=$w((O,A,B)=>{i(!1),m(E=>E?Tq(E,O,A,B):null)},[]);Tm(()=>{if(!a)return;let O=()=>i(!1);return window.addEventListener("dragend",O),window.addEventListener("mouseup",O),()=>{window.removeEventListener("dragend",O),window.removeEventListener("mouseup",O)}},[a]);let M=$w(O=>o.panels?.[O]?.hidden===!0,[o]);Tm(()=>{let O=t.getPanelRegistry();if(O.size>0){for(let[B,{visible:E}]of O.entries())E&&M(B)&&t.setPanelVisible(B,!1);l([...O.entries()].map(([B,{element:E,title:L,visible:z}])=>({id:B,title:L,element:E,visible:M(B)?!1:z})))}let A=[e.on("plugin:panel-added",({id:B,title:E,visible:L})=>{let z=t.getPanelRegistry().get(B)?.element;z&&(L&&M(B)&&t.setPanelVisible(B,!1),l(Y=>{let G=Y.findIndex(H=>H.id===B);if(G!==-1){let H=[...Y];return H[G]={id:B,title:E,element:z,visible:Y[G].visible},H}return[...Y,{id:B,title:E,element:z,visible:M(B)?!1:L}]}))}),e.on("plugin:panel-removed",({id:B})=>{l(E=>E.filter(L=>L.id!==B))}),e.on("plugin:panel-toggle-visibility",({id:B,visible:E})=>{l(L=>L.map(z=>z.id===B?{...z,visible:E}:z))})];return()=>A.forEach(B=>B())},[e,t]),Tm(()=>{for(let O of s)c.has(O.id)&&m(A=>sD(A,O.id)?A:rD(A,O.id))},[s,c]);let I=O=>{u(A=>{let B=new Set(A);return B.has(O)?(B.delete(O),m(E=>E?Qw(E,O):null)):(B.add(O),m(E=>rD(E,O))),B})},x=O=>l(A=>A.map(B=>B.id===O?{...B,visible:!B.visible}:B)),T=s.filter(O=>c.has(O.id)&&O.visible);Tm(()=>{n(T.length>0)},[T.length]),Tm(()=>{let O=setTimeout(()=>{let B={...nD().panels},E=new Set([...Object.keys(B),...c,...f.keys(),...s.map(L=>L.id)]);for(let L of E){let z=s.find(G=>G.id===L),Y=f.get(L);B[L]={pinned:c.has(L),hidden:z?!z.visible:B[L]?.hidden??!1,...Y?{x:Math.round(Y.x),y:Math.round(Y.y)}:{}}}kr(Cn.pluginPanels,{sidebarWidth:p,tree:d,panels:B})},400);return()=>clearTimeout(O)},[c,f,d,p,s]);let R=$w(O=>{O.preventDefault(),y.current=!0;let A=O.clientX,B=p,E=z=>{let Y=A-z.clientX,G=Math.min(Rq,Math.max(Mq,B+Y));g(G)},L=()=>{y.current=!1,window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",L)};window.addEventListener("mousemove",E),window.addEventListener("mouseup",L)},[p]),P=(O,A)=>{A.preventDefault();let B=Math.max(...S.values(),50);C(U=>{let V=new Map(U);return V.set(O,B+1),V});let E=f.get(O)??{x:100,y:100},{x:L,y:z}=E,Y=A.clientX-L,G=A.clientY-z,H=U=>{L=U.clientX-Y,z=U.clientY-G,h(V=>new Map(V).set(O,{x:L,y:z}))},W=()=>{window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",W)};window.addEventListener("mousemove",H),window.addEventListener("mouseup",W)},D=s.filter(O=>!c.has(O.id)&&O.visible),N=iD(d,new Set(T.map(O=>O.id)));return ka(dD,{children:[!r&&T.length===0&&ka("div",{className:"flex flex-row shrink-0 border-l border-border bg-background overflow-hidden",style:{width:p},children:[sr("div",{className:"w-1 shrink-0 cursor-col-resize hover:bg-primary/40 active:bg-primary/60 transition-colors",style:{zIndex:10},onMouseDown:R}),ka("div",{className:"flex w-full h-full items-center justify-center text-xs text-muted-foreground",children:["No pinned",ka(eD,{openDelay:0,children:[sr(tD,{className:"underline ml-1",children:"panels"}),ka(Kw,{className:"p-2",children:["Panels are windows that ",sr("a",{href:"https://docs.christtrade.com/depth/scripted/types#extension",target:"_blank",className:"underline inline",children:"extension type plugins"})," can spawn"]})]})]})]}),T.length>0&&N&&!r&&ka("div",{className:"flex flex-row shrink-0 border-l border-border bg-background overflow-hidden",style:{width:p},children:[sr("div",{className:"w-1 shrink-0 cursor-col-resize hover:bg-primary/40 active:bg-primary/60 transition-colors",style:{zIndex:10},onMouseDown:R}),sr("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden",children:sr(cD,{node:N,panels:T,onTogglePin:I,onToggleVisibility:x,onMovePanel:k,chart:t,isDragging:a,setIsDragging:i})})]}),D.map(O=>{let A=f.get(O.id)??{x:100,y:100},B=v.get(O.id)??200,E=S.get(O.id)??50;return sr("div",{style:{position:"fixed",left:Math.max(Math.min(A.x,window.innerWidth-12-280),12),top:Math.max(Math.min(A.y,window.innerHeight-12-B),12),width:280,zIndex:E},className:"flex flex-col rounded-lg border border-border bg-background shadow-xl overflow-hidden",ref:L=>{if(L){w.current.set(O.id,L);let z=L.clientHeight;v.get(O.id)!==z&&b(G=>{let H=new Map(G);return H.set(O.id,z),H})}else w.current.delete(O.id)},children:sr(aD,{panel:O,pinned:!1,onTogglePin:()=>I(O.id),onToggleVisibility:()=>{x(O.id),t.setPanelVisible(O.id,!O.visible)},onDragHeader:L=>P(O.id,L)})},O.id)})]})}import{useEffect as Pq,useState as Dq}from"react";import{Fragment as Aq,jsx as Sg,jsxs as fD}from"react/jsx-runtime";function mD({eventBus:e,chart:t}){let[n,r]=Dq(()=>[...t.getToolbarRegistry().values()]);return Pq(()=>{let o=[e.on("plugin:toolbar-item-added",({item:a})=>r(i=>{let s=i.findIndex(l=>l.id===a.id);if(s!==-1){let l=[...i];return l[s]=a,l}return[...i,a]})),e.on("plugin:toolbar-item-removed",({id:a})=>r(i=>i.filter(s=>s.id!==a))),e.on("plugin:toolbar-item-updated",({item:a})=>r(i=>i.map(s=>s.id===a.id?a:s)))];return()=>o.forEach(a=>a())},[e,t]),n.length===0?null:fD(Aq,{children:[Sg("div",{className:"w-px h-4 bg-border mx-1 shrink-0"}),n.map(o=>fD(Ht,{children:[Sg(Ot,{asChild:!0,children:Sg("button",{onClick:o.onClick,disabled:o.disabled,className:ee("flex items-center justify-center w-7 h-7 rounded transition-colors shrink-0","text-muted-foreground hover:text-foreground hover:bg-accent","disabled:opacity-40 disabled:pointer-events-none",o.active&&"bg-accent text-foreground"),children:o.icon})}),Sg(_t,{side:"bottom",className:"bg-background border border-border",children:o.title})]},o.id))]})}import Bq,{useEffect as kg,useReducer as Nq,useState as Cg}from"react";import{Fragment as gD,jsx as Xa,jsxs as pD}from"react/jsx-runtime";function Eq({id:e,render:t,eventBus:n}){let[,r]=Nq(o=>o+1,0);return kg(()=>n.on("plugin:bottom-bar-item-rerender",({id:o})=>{o===e&&r()}),[e,n]),Xa(gD,{children:t()})}function hD({eventBus:e,chart:t}){let[n,r]=Cg(()=>[...t.getBottomBarRegistry().values()]),[o,a]=Cg(null),[i,s]=Cg(!1),[l,c]=Cg(!1);if(kg(()=>{if(!o)return;let d=()=>{s(o.scrollLeft>0),c(o.scrollLeft+o.clientWidth<o.scrollWidth-1)};d(),o.addEventListener("scroll",d,{passive:!0});let m=new ResizeObserver(d);return m.observe(o),()=>{o.removeEventListener("scroll",d),m.disconnect()}},[o]),kg(()=>{o&&requestAnimationFrame(()=>{s(o.scrollLeft>0),c(o.scrollLeft+o.clientWidth<o.scrollWidth-1)})},[n,o]),kg(()=>{let d=[e.on("plugin:bottom-bar-item-added",({item:m})=>r(f=>{let h=f.findIndex(p=>p.id===m.id);if(h!==-1){let p=[...f];return p[h]=m,p}return[...f,m]})),e.on("plugin:bottom-bar-item-removed",({id:m})=>r(f=>f.filter(h=>h.id!==m))),e.on("plugin:bottom-bar-item-updated",({item:m})=>r(f=>f.map(h=>h.id===m.id?m:h)))];return()=>d.forEach(m=>m())},[e,t]),n.length===0)return null;let u=d=>{o?.scrollBy({left:d==="left"?-120:120,behavior:"smooth"})};return pD(gD,{children:[Xa("div",{className:"w-px h-3 bg-border/50 mx-1 shrink-0"}),Xa("button",{onClick:()=>u("left"),className:ee("shrink-0 flex items-center justify-center w-4 h-4 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",!i&&"invisible pointer-events-none"),children:Xa(Rl,{size:11})}),Xa("div",{ref:a,className:"flex items-center overflow-x-auto min-w-0 flex-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:Xa("div",{className:"flex items-center gap-0.5 mx-auto",children:n.map((d,m)=>pD(Bq.Fragment,{children:[m>0&&Xa("div",{className:"w-px h-3 bg-border/30 mx-0.5 shrink-0"}),Xa("div",{className:"shrink-0 flex items-center",children:Xa(Eq,{id:d.id,render:d.render,eventBus:e})})]},d.id))})}),Xa("button",{onClick:()=>u("right"),className:ee("shrink-0 flex items-center justify-center w-4 h-4 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",!l&&"invisible pointer-events-none"),children:Xa(Zi,{size:11})}),Xa("div",{className:"w-px h-3 bg-border/50 mx-1 shrink-0"})]})}import{useEffect as Oq,useState as bD}from"react";import{jsx as Eo,jsxs as Sc}from"react/jsx-runtime";function yD({eventBus:e,chart:t}){let[n,r]=bD([]),[o,a]=bD(!1);Oq(()=>{let l=t.getPanelRegistry();l.size>0&&r([...l.entries()].map(([u,{element:d,title:m,visible:f}])=>({id:u,title:m,element:d,visible:f})).filter(u=>!u.visible));let c=[e.on("plugin:panel-added",({id:u,title:d,visible:m})=>{let f=t.getPanelRegistry().get(u)?.element;f&&r(h=>{let p=h.findIndex(g=>g.id===u);if(p!==-1){let g=[...h];return g[p]={id:u,title:d,element:f,visible:m},g.filter(y=>!y.visible)}return[...h,{id:u,title:d,element:f,visible:m}].filter(g=>!g.visible)})}),e.on("plugin:panel-removed",({id:u})=>{r(d=>d.filter(m=>m.id!==u))}),e.on("plugin:panel-toggle-visibility",({id:u,visible:d})=>{r(m=>{let f=m.some(h=>h.id===u);if(d)return m.filter(h=>h.id!==u);if(!f){let h=t.getPanelRegistry().get(u);return h?[...m,{...h,visible:d,id:u}]:m}return m})})];return()=>c.forEach(u=>u())},[e,t]);let i=l=>{r(c=>c.filter(u=>u.id!==l.id)),e.emit("plugin:panel-toggle-visibility",{id:l.id,visible:!0})},s=n.length;return Sc(Ha,{open:o,onOpenChange:a,children:[Eo(Va,{asChild:!0,children:Sc("button",{className:ee("flex items-center gap-1.5 h-7 px-2 rounded-md transition-colors font-medium","text-[12px] text-gray-300 hover:text-white hover:bg-muted border border-transparent hover:border-border",o&&"border-border bg-muted text-white"),onClick:()=>a(!0),children:[Eo(si,{size:13,className:"shrink-0"}),Eo("span",{children:"Windows"}),Eo(Zn,{className:ee("w-3 h-3 text-muted-foreground transition-all duration-200",o&&"rotate-180")})]})}),Sc(va,{align:"end",sideOffset:6,className:"p-2 w-64 border border-border bg-background rounded-xl shadow-2xl",children:[Eo("p",{className:"px-1.5 pb-2 text-[10px] font-medium text-muted-foreground/50 uppercase tracking-widest",children:"Hidden panels"}),s===0?Sc("div",{className:"flex flex-col items-center gap-1.5 py-6 text-center",children:[Eo(si,{size:16,className:"text-muted-foreground/30"}),Eo("p",{className:"text-xs text-muted-foreground/40",children:"All panels visible"})]}):Eo("div",{className:"flex flex-col gap-1",children:n.map(l=>Sc(ta,{onSelect:()=>i(l),className:"group flex flex-col gap-1.5 p-1.5 rounded-lg cursor-pointer focus:bg-transparent data-[highlighted]:bg-transparent",children:[Sc("div",{className:"relative w-full rounded-md border border-border bg-muted/20 overflow-hidden ring-0 group-data-[highlighted]:ring-1 group-data-[highlighted]:ring-border transition-all",children:[Eo("div",{className:"absolute inset-0 z-10 cursor-pointer"}),Eo("div",{className:"h-24 overflow-hidden",children:Eo("div",{style:{transform:"scale(0.75)",transformOrigin:"top left",width:`${100/.75}%`,pointerEvents:"none"},children:Eo(Zw,{element:l.element})})}),Eo("div",{className:"absolute bottom-0 inset-x-0 h-8 bg-gradient-to-t from-background/80 to-transparent z-20 pointer-events-none"}),Sc("div",{className:"absolute inset-0 z-30 flex items-end justify-between px-2.5 py-2 opacity-0 group-data-[highlighted]:opacity-100 transition-opacity pointer-events-none",children:[Eo("span",{className:"text-xs font-medium text-foreground drop-shadow-sm",children:l.title}),Eo("span",{className:"text-[10px] text-muted-foreground",children:"Click to show"})]})]}),Eo("span",{className:"px-0.5 text-xs font-medium text-foreground/70 group-data-[highlighted]:text-foreground transition-colors truncate",children:l.title})]},l.id))})]})]})}import{useCallback as Kq,useEffect as Im,useMemo as CD,useRef as $q,useState as Mm}from"react";import*as SD from"react";import*as Xr from"react";import{Fragment as Fq,jsx as fl,jsxs as zq}from"react/jsx-runtime";var _q=Object.defineProperty,Ss=(e,t)=>_q(e,"name",{value:t,configurable:!0}),Jw="Checkbox",[Hq,Wce]=xr(Jw),[Vq,ex]=Hq(Jw);function vD(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:o,disabled:a,form:i,name:s,onCheckedChange:l,required:c,value:u="on",internal_do_not_use_render:d}=e,[m,f]=go({prop:n,defaultProp:o??!1,onChange:l,caller:Jw}),[h,p]=Xr.useState(null),[g,y]=Xr.useState(null),v=Xr.useRef(!1),[b,S]=Xr.useReducer(k=>k+1,0),C=h?!!i||!!h.closest("form"):!0,w={checked:m,disabled:a,setChecked:f,control:h,setControl:p,name:s,form:i,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:b,onUserInteraction:S,required:c,defaultChecked:xs(o)?!1:o,isFormControl:C,bubbleInput:g,setBubbleInput:y};return fl(Vq,{scope:t,...w,children:xD(d)?d(w):r})}Ss(vD,"CheckboxProvider");var Wq="CheckboxTrigger",qq=Xr.forwardRef(Ss(function({__scopeCheckbox:t,onKeyDown:n,onClick:r,...o},a){let{control:i,value:s,disabled:l,checked:c,required:u,setControl:d,setChecked:m,hasConsumerStoppedPropagationRef:f,onUserInteraction:h,isFormControl:p,bubbleInput:g}=ex(Wq,t),y=Kt(a,d),v=Xr.useRef(c);return Xr.useEffect(()=>{let b=i?.form;if(b){let S=Ss(()=>m(v.current),"reset");return b.addEventListener("reset",S),()=>b.removeEventListener("reset",S)}},[i,m]),fl(dn.button,{type:"button",role:"checkbox","aria-checked":xs(c)?"mixed":c,"aria-required":u,"data-state":nx(c),"data-disabled":l?"":void 0,disabled:l,value:s,...o,ref:y,onKeyDown:lt(n,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:lt(r,b=>{h(),m(S=>xs(S)?!0:!S),g&&p&&(f.current=b.isPropagationStopped(),f.current||b.stopPropagation())})})},"CheckboxTrigger")),tx=Xr.forwardRef(Ss(function(t,n){let{__scopeCheckbox:r,name:o,checked:a,defaultChecked:i,required:s,disabled:l,value:c,onCheckedChange:u,form:d,...m}=t;return fl(vD,{__scopeCheckbox:r,checked:a,defaultChecked:i,disabled:l,required:s,onCheckedChange:u,name:o,form:d,value:c,internal_do_not_use_render:({isFormControl:f})=>zq(Fq,{children:[fl(qq,{...m,ref:n,__scopeCheckbox:r}),f&&fl(Gq,{__scopeCheckbox:r})]})})},"Checkbox")),Uq="CheckboxIndicator",wD=Xr.forwardRef(Ss(function(t,n){let{__scopeCheckbox:r,forceMount:o,...a}=t,i=ex(Uq,r);return fl(Uo,{present:o||xs(i.checked)||i.checked===!0,children:fl(dn.span,{"data-state":nx(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:n,style:{pointerEvents:"none",...t.style}})})},"CheckboxIndicator")),jq="CheckboxBubbleInput",Gq=Xr.forwardRef(Ss(function({__scopeCheckbox:t,onClick:n,...r},o){let{control:a,hasConsumerStoppedPropagationRef:i,userInteractionCount:s,checked:l,defaultChecked:c,required:u,disabled:d,name:m,value:f,form:h,bubbleInput:p,setBubbleInput:g}=ex(jq,t),y=Kt(o,g),v=es(a),b=Xr.useRef(!1),S=Xr.useRef(l),C=Xr.useRef(s);Xr.useEffect(()=>{let k=p;if(!k)return;let M=window.HTMLInputElement.prototype,x=Object.getOwnPropertyDescriptor(M,"checked").set,T=s!==C.current;C.current=s;let R=S.current!==l;S.current=l;let P=!(T&&i.current);if(R&&x){b.current=!T;let D=new Event("click",{bubbles:P});k.indeterminate=xs(l),x.call(k,xs(l)?!1:l),k.dispatchEvent(D),b.current=!1}},[p,l,i,s]);let w=Xr.useRef(xs(l)?!1:l);return fl(dn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??w.current,required:u,disabled:d,name:m,value:f,form:h,...r,tabIndex:-1,ref:y,onClick:lt(n,k=>{b.current&&k.stopPropagation()}),style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function xD(e){return typeof e=="function"}Ss(xD,"isFunction");function xs(e){return e==="indeterminate"}Ss(xs,"isIndeterminate");function nx(e){return xs(e)?"indeterminate":e?"checked":"unchecked"}Ss(nx,"getState");import{jsx as rx}from"react/jsx-runtime";var ox=SD.forwardRef(({className:e,...t},n)=>rx(tx,{ref:n,className:ee("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:rx(wD,{className:ee("flex items-center justify-center text-current"),children:rx(Or,{className:"h-4 w-4"})})}));ox.displayName=tx.displayName;import{jsx as jn,jsxs as Oo}from"react/jsx-runtime";var kD={indicator:{label:"Indicators",Icon:zs},drawing:{label:"Drawings",Icon:jd},"chart-type":{label:"Chart types",Icon:Ai},extension:{label:"Extensions",Icon:Wd},"data-source":{label:"Data sources",Icon:qd},unknown:{label:"Other",Icon:Nl}},Xq=["extension","indicator","drawing","chart-type","data-source","unknown"];function Zq(e){let t=e.getPluginStartup(),{installed:n,active:r}=e.getPluginState(),o=new Map;for(let a of e.getPluginCatalog())o.set(a.id,{id:a.id,name:a.name?.trim()||a.id,kind:a.type??"unknown",group:a.group,description:a.description,loaded:n.has(a.id),active:r.has(a.id),autostart:t[a.id]?.autostart===!0,available:!0});for(let a of e.getInstalledPlugins())o.has(a.id)||a.id.startsWith("builtin:")||o.set(a.id,{id:a.id,name:a.name,kind:a.type??"unknown",loaded:!0,active:r.has(a.id),autostart:t[a.id]?.autostart===!0,available:!1});return[...o.values()].sort((a,i)=>a.name.localeCompare(i.name))}function Qq({row:e,problem:t,onToggleLoaded:n,onToggleActive:r,onToggleAutostart:o}){let{Icon:a}=kD[e.kind];return Oo("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/40 duration-200 hover:duration-0 transition-colors",children:[jn(a,{size:14,className:"shrink-0 text-muted-foreground"}),Oo("div",{className:"flex flex-col min-w-0 flex-1",children:[Oo("div",{className:"flex items-center gap-2 min-w-0",children:[jn("span",{className:"text-[13px] text-foreground truncate",children:e.name}),e.loaded&&e.kind==="indicator"&&jn("span",{className:ee("shrink-0 px-1.5 h-4 rounded text-[10px] leading-4 font-medium",e.active?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:e.active?"on chart":"loaded"}),!e.available&&jn("span",{className:"shrink-0 px-1.5 h-4 rounded bg-muted text-muted-foreground text-[10px] leading-4",children:"bundled"})]}),t?Oo("span",{className:"flex items-center gap-1 text-[11px] text-amber-500 truncate",children:[jn(ba,{size:10,className:"shrink-0"}),t]}):e.description&&jn("span",{className:"text-[11px] text-muted-foreground truncate",children:e.description})]}),e.kind==="indicator"&&Oo(Ht,{delayDuration:500,children:[jn(Ot,{asChild:!0,children:jn("button",{disabled:!e.loaded,onClick:()=>r(!e.active),className:ee("shrink-0 h-6 px-2 rounded-md border text-[11px] transition-colors","disabled:opacity-30 disabled:cursor-not-allowed",e.active?"border-primary/40 text-primary hover:bg-primary/10":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"),children:e.active?"Remove":"Add"})}),jn(_t,{className:"bg-background border border-border",children:e.active?"Take it off the panes":"Put an instance on the chart"})]}),Oo(Ht,{delayDuration:500,children:[jn(Ot,{asChild:!0,children:jn("div",{className:"shrink-0 flex items-center justify-center w-10",children:jn(ox,{checked:e.autostart,disabled:!e.available,onCheckedChange:o,className:"disabled:opacity-30"})})}),jn(_t,{className:"bg-background border border-border",children:"Load this plugin whenever the chart opens"})]}),jn(Qr,{checked:e.loaded,disabled:!e.available,onCheckedChange:n,className:"shrink-0 data-[state=checked]:bg-blue-500"})]})}function Jq({chart:e,eventBus:t,open:n,onOpenChange:r,loaded:o}){let a=$q(null),[i,s]=Mm([]),[l,c]=Mm({}),[u,d]=Mm(""),m=Kq(()=>s(Zq(e)),[e]);Im(()=>{if(n)return m(),e.onPluginStateChange(m)},[e,n,m]),Im(()=>{let b=[t.on("plugin:script-error",({id:S,error:C})=>c(w=>({...w,[S]:C}))),t.on("plugin:incompatible",({id:S,required:C,actual:w})=>c(k=>({...k,[S]:`needs ${C} data, this chart has ${w}`}))),t.on("plugin:installed",({id:S})=>c(C=>{if(!(S in C))return C;let w={...C};return delete w[S],w}))];return()=>b.forEach(S=>S())},[t]);let f=CD(()=>{let b=u.trim().toLowerCase();return b?i.filter(S=>S.name.toLowerCase().includes(b)||S.id.toLowerCase().includes(b)||S.group?.toLowerCase().includes(b)):i},[i,u]),h=CD(()=>Xq.map(b=>({kind:b,items:f.filter(S=>S.kind===b)})).filter(b=>b.items.length>0),[f]),p=(b,S)=>{S?e.loadPlugin(b.id):e.unloadPlugin(b.id),m()},g=(b,S)=>{S?e.add(b.id):e.remove(b.id),e.setPluginStartup(b.id,{activate:S}),m()},y=(b,S)=>{e.setPluginStartup(b.id,{autostart:S}),m()},v=i.filter(b=>b.loaded).length;return Im(()=>{if(!n)return;let b=C=>{a.current&&!a.current.contains(C.target)&&r(!1)},S=C=>{C.key==="Escape"&&r(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",S)}},[n]),Oo("div",{className:"relative",ref:a,children:[Oo(Ht,{delayDuration:700,children:[jn(Ot,{asChild:!0,children:Oo("button",{onClick:()=>r(!n),className:ee("flex items-center gap-1.5 h-7 px-2 rounded-md transition-colors font-medium","text-[12px] text-gray-300 hover:text-white hover:text-foreground hover:bg-muted border border-transparent hover:border-border",n&&"border-border bg-muted text-white"),children:[jn(Nl,{size:13,className:"shrink-0"}),jn("span",{children:"Plugins"}),jn(Zn,{className:ee("w-3 h-3 transition-all duration-200 text-muted-foreground",n&&"rotate-180")})]})}),jn(_t,{className:"bg-background border border-border",children:"Loaded plugins, and what starts with the chart"})]}),n&&Oo("div",{className:"absolute right-0 top-full mt-1.5 z-50 flex flex-col w-[30rem] max-h-[35rem] rounded-lg border border-[#1e2128] bg-[#16181d] shadow-2xl overflow-hidden",children:[Oo("div",{className:"px-4 pt-4 pb-3 shrink-0",children:[jn("div",{className:"text-sm font-medium",children:"Plugins"}),Oo("div",{className:"text-xs",children:[v," of ",i.length," loaded. Anything switched on here comes back the next time you open the chart."]})]}),Oo("div",{className:"flex items-center gap-2 px-4 h-10 border-y border-border shrink-0",children:[jn(li,{size:13,className:"shrink-0 text-muted-foreground"}),jn("input",{autoFocus:!0,value:u,onChange:b=>d(b.target.value),placeholder:"Search plugins",className:"flex-1 h-full bg-transparent outline-none text-[13px] text-foreground placeholder:text-muted-foreground/60"})]}),Oo("div",{className:"flex items-center gap-3 px-4 py-1.5 text-[10px] uppercase tracking-widest text-muted-foreground/60 border-b border-border shrink-0",children:[jn("span",{className:"flex-1",children:"Plugin"}),jn("span",{className:"w-10 text-center",children:"Startup"}),jn("span",{className:"w-9 text-right",children:"On"})]}),jn("div",{className:"flex-1 overflow-y-auto min-h-0 py-1",children:h.length===0?Oo("div",{className:"flex flex-col items-center gap-1.5 py-14 text-center",children:[jn(Nl,{size:18,className:"text-muted-foreground/30"}),jn("p",{className:"text-xs text-muted-foreground/60",children:i.length===0?"No plugins yet. Write one in the script editor.":"Nothing matches that."})]}):h.map(({kind:b,items:S})=>Oo("div",{className:"pb-1",children:[jn("p",{className:"px-4 pt-2 pb-1 text-[10px] font-medium uppercase tracking-widest text-muted-foreground/50",children:kD[b].label}),jn("div",{className:"px-1",children:S.map(C=>jn(Qq,{row:C,problem:l[C.id],onToggleLoaded:w=>p(C,w),onToggleActive:w=>g(C,w),onToggleAutostart:w=>y(C,w)},C.id))})]},b))})]})]})}function TD({chart:e,eventBus:t}){let[n,r]=Mm(!1),o=s=>[...s].filter(l=>!l.startsWith("builtin:")).length,[a,i]=Mm(()=>o(e.getPluginState().installed));return Im(()=>(i(o(e.getPluginState().installed)),e.onPluginStateChange(s=>i(o(s.installed)))),[e]),Im(()=>t.on("plugin:open-manager",()=>r(!0)),[t]),a===0&&e.getPluginCatalog().length===0?null:jn(Jq,{chart:e,eventBus:t,open:n,onOpenChange:r,loaded:a})}import{Fragment as rU,jsx as $t,jsxs as _o}from"react/jsx-runtime";function nU(e,t){try{let n=new Date(Number(t/1000000n));return(new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(n).find(a=>a.type==="timeZoneName")?.value??"").replace("GMT","")||"UTC"}catch{return""}}function ax(e,t){if(!e)return;let n=e.firstChild;n&&n.nodeType===3&&e.childNodes.length===1?n.nodeValue!==t&&(n.nodeValue=t):e.textContent=t}function Tg({chart:e,eventBus:t,executionEngine:n,transformer:r,hideToolbar:o,hideDrawingToolbar:a,hideBottomToolbar:i,hidePriceScale:s,hideTimeScale:l,hideStatusBar:c,hideLegend:u,prefetch:d,showDataStatusInBottomRightCorner:m,state:f,toolbar:h,plugins:p,features:g,timePrecision:y}){let b=Jn(t??new pc).current;lr(()=>b.on("error",({message:X})=>{Ti.error(X)}),[b]),lr(()=>b.on("plugin:incompatible",({id:X,name:$,kind:ge,required:Ce,actual:ct})=>{let bt=ge==="chart-type"?"Chart type":ge==="indicator"?"Indicator":"Plugin";Ti.warning(`${bt} "${$??X}" is unavailable here`,{description:cc(Ce,ct)})}),[b]);let[S,C]=Hr(()=>f.get("layout")),w=Jn(S);lr(()=>{w.current=S},[S]);let[k,M]=Hr(()=>f.get("syncInLayout")??im),I=Jn(k);lr(()=>{I.current=k,f.set("syncInLayout",k)},[f,k]);let[x,T]=Hr(()=>{let X=f.get("focusedPane")??0;return X<f.get("layout").count?X:0}),[R,P]=Hr(()=>{let X=f.get("gridColSizes"),$=f.get("layout").cols;return X&&X.length===$?X:Array($).fill(1)}),[D,N]=Hr(()=>{let X=f.get("gridRowSizes"),$=f.get("layout").rows;return X&&X.length===$?X:Array($).fill(1)});lr(()=>{f.set("gridColSizes",R)},[f,R]),lr(()=>{f.set("gridRowSizes",D)},[f,D]),lr(()=>{f.set("focusedPane",x)},[f,x]);let O=Jn(null),[A,B]=Hr(!1),[E,L]=Hr(!0),z=Jn(Array($a).fill(null)),[Y,G]=Hr("ohlcv"),H=Jn(Y);H.current=Y;let W=Jn(null),U=Jn(null),V=Jn(null),K=Jn(""),[Z,de]=Hr(()=>{let X=Array($a).fill(!1);for(let $=0;$<Math.max(1,f.get("layout").count);$++)X[$]=!0;return X}),[ze,xe]=Hr(f.get("timeframe")),[Ae,Oe]=Hr(()=>OS()),[ke,Q]=Hr(Ye),[Pe,_]=Hr([]),[ie,se]=Hr(Vo),[Se,Re]=Hr(!1);lr(()=>{Q(e.getChart(x).settings)},[e,x]);let ye=Jn(null),[$e,Ue]=Hr([]),je=Jn($e);lr(()=>{je.current=$e},[$e]);let ht=$e.find(X=>X.chartTypeId===ke.chartType)??null,[Be,xt]=Hr([]),fn=Jn(Be);lr(()=>{fn.current=Be},[Be]);let[In,kt]=Hr([]),it=Jn([]),ft=Jn(new Set);lr(()=>{let X=[...e.getRegisteredPlugins().values()];X.length>0&&(it.current=X,kt(X))},[]),lr(()=>{it.current=In},[In]);let oe=f.get("symbol"),pe=sa(()=>Array.from({length:$a},(X,$)=>e.getChart($).symbol),[e]),[fe,Ie]=Hr(pe),Ve=Jn(fe);lr(()=>{Ve.current=fe},[fe]),lr(()=>{let X=()=>Ie(ge=>{let Ce=pe();return Ce.length===ge.length&&Ce.every((ct,bt)=>ct===ge[bt])?ge:Ce}),$=Array.from({length:$a},(ge,Ce)=>e.getChart(Ce).subscribe(X));return X(),()=>$.forEach(ge=>ge())},[e,pe]);let[,qe]=Hr(0),Fe=sa((X,$)=>{e.getChart(X).setSymbol($)},[e]),De=n??e.executionEngine,{byCell:we,bySymbol:_e}=f2(fe,b,e,De);lr(()=>{De.setActiveSymbol(fe[x]??"")},[De,fe,x]);let Ne=Jn(_e);Ne.current=_e;let dt=Jn(De);dt.current=De;let Pt=X=>{let $=je.current.find(ct=>ct.chartTypeId===X);if(!$)return!1;let ge=$.require??"ohlcv",Ce=H.current;return Ao(ge,Ce)?!1:(b.emit("plugin:incompatible",{id:X,name:$.label??$.name,kind:"chart-type",required:ge,actual:Ce}),!0)},J=we[x]??we[0],Te=Jn(J);lr(()=>{Te.current=J},[J]),lr(()=>b.on("execution:setAdapter",({adapter:X})=>{De.setCustomAdapter(X)}),[De]);let Le=Jn(Array($a).fill(!1));lr(()=>{Z.forEach((X,$)=>{X&&!Le.current[$]&&(Le.current[$]=!0,requestAnimationFrame(()=>{b.emit("data:rehydrate",void 0)}))})},[Z]);let ot=tU(()=>{let X=new Set;for(let $ of S.areas.replace(/"/g,""))$>="a"&&$<="h"&&X.add($);return[...X].sort()},[S]),tt=sa(()=>{let X=Math.max(1,w.current.count);return Array.from({length:Math.min(X,$a)},($,ge)=>ge)},[]),mt=Jn(!1),qt=sa((X,$)=>{if(!mt.current){mt.current=!0;try{for(let ge of tt())ge!==$&&Ve.current[ge]!==X&&b.emit("chart:set-symbol",{symbol:X,id:ge})}finally{mt.current=!1}}},[tt,b]),Dt=sa((X,$)=>{if(!mt.current){mt.current=!0;try{for(let ge of tt())ge!==$&&z.current[ge]?.handleTimeframeChange(X,!0)}finally{mt.current=!1}}},[tt]),rr=sa(X=>{let $=I.current;I.current=X,M(X);let ge=ce.current;if(X.symbol&&!$.symbol){let Ce=Ve.current[ge];Ce&&qt(Ce,ge)}if(X.interval&&!$.interval){let Ce=z.current[ge]?.getActiveTimeframe();Ce&&Dt(Ce,ge)}if(X.time&&!$.time||X.dateRange&&!$.dateRange){let Ce=z.current[ge]?.getVisibleRange();Ce&&b.emit("layout:time-range",{id:ge,...Ce})}},[b,qt,Dt]),wn=sa((X,...$)=>{let ge=z.current[x];ge&&typeof ge[X]=="function"&&ge[X](...$)},[x]),er=sa(X=>{b.emit("data:prefetch",{spanNs:X})},[b]),Pn=sa((X,$)=>{let ge=dt.current,Ce=X.symbol;if(Ne.current.some(ct=>ct.symbol===Ce)){switch(X.dataLevel){case"l3":{let ct=X.compactBuf.slice(0);$==="append"?ge.appendCompactBuf(ct,Ce):ge.ingestCompactBuf(ct,Ce);break}case"ohlcv":{let ct=X.ohlcvBars??[];$==="append"?ge.appendOhlcvBars(ct,X.barNs,Ce):ge.ingestOhlcvBars(ct,X.barNs,Ce);let bt=X.supplemental;if(bt?.length){let le=bt.reduce((Ee,wt)=>!Ee||wt.resolution<Ee.resolution?wt:Ee);le.bars.length&&($==="append"?ge.appendSupplementalBars(le.bars,Ce):ge.ingestSupplementalBars(le.bars,Ce))}break}case"tick":$==="append"?ge.appendTicks(X.trades??[],Ce):ge.ingestTicks(X.trades??[],Ce);break;case"l2":$==="append"?ge.appendPriceHistory(X.priceHistory??[],Ce):ge.ingestPriceHistory(X.priceHistory??[],Ce);break}if(!ge.hasPrice(Ce)){let ct=Mn.current||cr.current;ct>0n&&ge.seekTo(ct,Ce)}}},[]),cr=Jn(BigInt(Math.round(e.horizon()))*1000000n),Mn=Jn(BigInt(Math.round(e.horizon()))*1000000n),An=sa(X=>{Mn.current=X,dt.current.seekTo(X);let $=ke.timezone??"UTC";(!U.current||K.current!==$)&&(U.current=new Intl.DateTimeFormat("sv-SE",{timeZone:$,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),K.current=$);let ge=Number(X/1000000n),Ce=Math.floor(Number(X/1000n%1000000n)/1e3),ct=Ce<10?"00"+Ce:Ce<100?"0"+Ce:""+Ce;ax(W.current,y==="ms"?U.current.format(ge)+"."+ct:U.current.format(ge)),b.emit("playback:seek",{tNs:X})},[ke]),F=jP({chartRefs:z,sharedHorizonRef:cr,onRequestMore:er,onTick:An,eventBus:b,prefetch:d,clockSymbol:()=>Ve.current[ce.current]});lr(()=>b.on("data:bounds",({start:X,end:$,symbol:ge})=>{ge!==void 0&&ge!==Ve.current[ce.current]||F.notifyDataBounds(X,$)}),[]),lr(()=>{let X=[b.on("plugin:register-indicator",({indicator:$,pane:ge,activeByDefault:Ce})=>{let ct=it.current.findIndex(Ee=>Ee.indicator.id===$.id);if(ct!==-1){it.current=it.current.map((Ee,wt)=>wt===ct?{indicator:$,pane:ge,activeByDefault:Ce}:Ee),kt(it.current);for(let Ee=0;Ee<z.current.length;Ee++)z.current[Ee]?.replacePluginIndicator($);return}if(it.current.some(Ee=>Ee.indicator.id===$.id))return;it.current=[...it.current,{indicator:$,pane:ge,activeByDefault:Ce}],kt(it.current);let bt=$.id.replace(/:(\d+)$/,""),le=ft.current.has(bt);if(Ce||le){le&&ft.current.delete(bt);for(let Ee=0;Ee<z.current.length;Ee++)z.current[Ee]?.activatePluginIndicator($,ge)}}),b.on("chart:add-plugin-indicator",({pluginId:$})=>{let ge=it.current.find(Ce=>Ce.indicator.id===$||Ce.indicator.id.startsWith(`${$}:`));if(!ge){ft.current.add($);return}for(let Ce=0;Ce<z.current.length;Ce++)z.current[Ce]?.activatePluginIndicator(ge.indicator,ge.pane)}),b.on("plugin:uninstalled",({id:$})=>{ft.current.delete($);let ge=it.current.filter(Ce=>Ce.indicator.id!==$&&!Ce.indicator.id.startsWith(`${$}:`));ge.length!==it.current.length&&(it.current=ge,kt(ge))}),b.on("plugin:register-chart-type",({plugin:$})=>{je.current=[...je.current.filter(Ce=>Ce.id!==$.id),$],Ue(je.current);let ge=e.getChart(ce.current).settings.pluginSettings?.[$.chartTypeId];ge&&$.onSettingsChange?.(ge)}),b.on("plugin:unregister-chart-type",({id:$,hotReload:ge})=>{ge||(je.current=je.current.filter(Ce=>Ce.chartTypeId!==$),Ue(je.current))}),b.on("plugin:register-drawing",$=>{let{id:ge,name:Ce,icon:ct}=$;fn.current.some(bt=>bt.id===ge)||(fn.current=[...fn.current,{id:ge,name:Ce,icon:ct}],xt(fn.current))}),b.on("plugin:unregister-drawing",$=>{let{id:ge}=$;fn.current.some(Ce=>Ce.id.includes(ge))&&(fn.current=fn.current.filter(Ce=>!Ce.id.includes(ge)),xt(fn.current))}),b.on("trading:buy-market",({amount:$})=>{Te.current?.executionEngine?.placeOrder({qty:$,side:"long",type:"market",symbol:Te.current.symbol})}),b.on("trading:sell-market",({amount:$})=>{Te.current?.executionEngine?.placeOrder({qty:$,side:"short",type:"market",symbol:Te.current.symbol})}),b.on("trading:flatten",()=>{for(let $ of Ne.current)if($?.symbol)for(let ge of[...$.trading.positions.values()])ge.remainingQuantity<=0||$.executionEngine?.closePosition(ge.id)}),b.on("chart:set-timeframe",({tf:$})=>{xe($),z.current[ce.current]?.handleTimeframeChange($)}),b.on("layout:timeframe",({id:$,tf:ge})=>{$===ce.current&&(xe(ge),f.set("timeframe",ge)),I.current.interval&&Dt(ge,$)}),b.on("chart:apply-settings",({patch:$})=>{if($.chartType&&Pt($.chartType)){let{chartType:ge,...Ce}=$;$=Ce}Q(ge=>({...ge,...$})),z.current[ce.current]?.applySettings($)}),b.on("chart:set-symbol",({symbol:$,id:ge})=>{Fe(ge,$),I.current.symbol&&!he.current&&qt($,ge)}),b.on("features:change",()=>qe($=>$+1)),b.on("chart:set-symbol-focused",({symbol:$})=>{b.emit("chart:set-symbol",{symbol:$,id:ce.current})}),b.on("data:load",$=>{G($.dataLevel),Pn($,$.rehydrate?"append":"load")}),b.on("data:append",$=>Pn($,"append")),b.on("playback:play",()=>F.play()),b.on("playback:pause",()=>F.pause()),b.on("playback:set-speed",$=>F.setSpeed($.speed)),b.on("playback:set-step-size",$=>F.setStepSize($.step)),b.on("playback:step-back",()=>{e.playback.floor===null&&F.stepBack()}),b.on("playback:step-forward",()=>F.stepForward()),b.on("playback:goto",({tNs:$})=>{e.playback.allows($)&&F.scrub($)}),b.on("playback:set-mode",$=>F.setMode($.mode)),b.on("playback:set-step-snap",$=>F.setStepSnap($.snap))];return()=>X.forEach($=>$())},[b]),lr(()=>{b.emit("chart:focused",{id:x})},[x]);let re=Jn(null),ue=Jn(null);lr(()=>{if(!re.current)return;let X=nU(ke.timezone,cr.current),$=X==="UTC"?X:"UTC"+X;if(ue.current===$)return;ue.current=$,re.current.textContent=$;let ge=ke.timezone??"UTC";(!U.current||K.current!==ge)&&(U.current=new Intl.DateTimeFormat("sv-SE",{timeZone:ge,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),K.current=ge);let Ce=Number(Mn.current/1000000n),ct=Math.floor(Number(Mn.current/1000n%1000000n)/1e3),bt=ct<10?"00"+ct:ct<100?"0"+ct:""+ct;y==="ms"?ax(W.current,y==="ms"?U.current.format(Ce)+"."+bt:U.current.format(Ce)):W.current.textContent=U.current.format(Ce)},[ke]);let ce=Jn(x);lr(()=>{ce.current=x},[x]);let q=Jn(Z);lr(()=>{q.current=Z},[Z]);let he=Jn(!1);lr(()=>{let X=requestAnimationFrame(()=>{let $=Math.max(1,f.get("layout").count),ge=[];for(let ct=0;ct<$;ct++)ct!==ce.current&&ge.push(ct);ge.push(ce.current);let Ce=new Set;he.current=!0;try{for(let ct of ge){let bt=e.getChart(ct).symbol;!bt||Ce.has(bt)||(Ce.add(bt),b.emit("chart:set-symbol",{symbol:bt,id:ct}))}}finally{he.current=!1}});return()=>cancelAnimationFrame(X)},[]);let me=sa(()=>{let X=Math.max(1,f.get("layout").count);for(let $=0;$<X;$++){let ge=z.current[$];if(!ge?.activatePluginIndicator||!ge.getIndicators)continue;let Ce=e.getChart($),ct=Ce.restoredPlugins;if(!ct.length)continue;let bt=new Set((ge.getIndicators()??[]).map(le=>le.id));for(let le of ct){let Ee=it.current.find(wt=>wt.indicator.id===le.instanceId);if(Ee){if(!bt.has(le.instanceId)){let wt=le.config??{},Lt={...Ee.indicator,id:le.instanceId,settings:wt.settings??Ee.indicator.settings,visible:wt.visible??!0,layout:wt.layout??Ee.indicator.layout,paneId:wt.paneId??Ee.indicator.paneId};ge.activatePluginIndicator(Lt,Ee.pane)}Ce.consumeRestoredPlugin(le.instanceId)}}}},[e,f]);lr(()=>{me()},[In,Z,me]);let We=Jn(0),nt=Jn(0),gt=Jn(null),vt=()=>{let X=z.current[ce.current];if(!X)return;let $=X.getActiveTimeframe?.();$&&(xe($),f.set("timeframe",$));let ge=X.getIndicators?.(),Ce=X.getActiveTool?.();Ce!==void 0&&se(Ce),ge&&_(bt=>bt.length===ge.length&&bt.every((le,Ee)=>le.id===ge[Ee]?.id&&le.visible===ge[Ee]?.visible)?bt:[...ge]);let ct=X.getChartSettings?.();ct&&Q(bt=>JSON.stringify(bt)===JSON.stringify(ct)?bt:ct)};lr(()=>{let X=()=>{let $=ce.current,ge=z.current[$];if(ge){let Ce=ge.getHorizon?.()??0n;if(Ce>0n&&Ce!==cr.current){if(cr.current=Ce,b.emit("playback:seek",{tNs:Ce}),W.current&&Ce>0n){let bt=ke.timezone??"UTC";(!U.current||!V.current||K.current!==bt)&&(V.current=new Intl.DateTimeFormat("sv-SE",{timeZone:bt,year:"numeric",month:"2-digit",day:"2-digit"}),U.current=new Intl.DateTimeFormat("sv-SE",{timeZone:bt,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),K.current=bt);let le=Number(Ce/1000000n),Ee=Math.floor(Number(Ce/1000n%1000000n)/1e3),wt=Ee<10?"00"+Ee:Ee<100?"0"+Ee:""+Ee;ax(W.current,y==="ms"?U.current.format(le)+"."+wt:U.current.format(le))}if(ye.current===null){let bt=q.current;z.current.forEach((le,Ee)=>{Ee===$||!le||!bt[Ee]||le.seekHorizon(Ce)})}}let ct=performance.now();ct-nt.current>=200&&(nt.current=ct,vt())}We.current=requestAnimationFrame(X)};return We.current=requestAnimationFrame(X),()=>cancelAnimationFrame(We.current)},[]),lr(()=>{ce.current=x,vt();let X=z.current[x];X&&cr.current>0n&&X.seekHorizon(cr.current);let $=X?.getDataBounds?.();$&&$.end>0n&&F.notifyDataBounds($.start,$.end)},[x]);let[,pt]=Hr(0);lr(()=>{let X=()=>{ye.current!==null&&(ye.current=null,pt($=>$+1))};return window.addEventListener("mouseup",X),()=>window.removeEventListener("mouseup",X)},[]);let Ze=sa(X=>{b.emit("chart:change-layout",{preset:X}),f.set("layout",X),C(X),P(Array(X.cols).fill(1)),N(Array(X.rows).fill(1)),T($=>$<X.count?$:0),de($=>{let ge=[...$];for(let Ce=0;Ce<X.count;Ce++)ge[Ce]=!0;return ge})},[]),Tt=sa((X,$)=>{let ge=O.current;ge&&P(Ce=>Iw(Ce,X,$,ge.clientWidth))},[]),Gt=sa((X,$)=>{let ge=O.current;ge&&N(Ce=>Iw(Ce,X,$,ge.clientHeight))},[]),Xt=(X,$)=>{f.set(X,$),X==="selectedDrawingId"&&b.emit("drawing:selected",{id:$??null})};return $t(Sh,{delayDuration:400,children:_o("div",{className:"depth-root w-full h-full flex flex-col bg-background text-foreground overflow-hidden outline-none min-h-[120px]",ref:gt,tabIndex:0,children:[!o&&$t(Sh,{delayDuration:400,children:_o("div",{className:"flex items-center h-9 px-2 border-b shrink-0 gap-0.5",children:[$t("div",{className:"absolute left-0 top-0 w-[15rem] h-[2.2rem] bg-gradient-to-r from-[#0286f9]/10 to-background"}),$t(hw,{eventBus:b,symbol:fe[x]??oe,onSymbolChange:X=>{Fe(x,X),b.emit("chart:set-symbol",{symbol:X,id:x})}}),$t("div",{className:"w-px h-4 bg-border mx-1"}),$t(hP,{eventBus:b,value:ze,customTimeframes:Ae,features:g,onChange:X=>{xe(X),f.set("timeframe",X,b)},onAddCustom:X=>{Oe($=>{let ge=[...$,X];return Tb(ge),ge})},onRemoveCustom:X=>{Oe($=>{let ge=$.filter(Ce=>Ce.label!==X);return Tb(ge),ge})}}),$t("div",{className:"w-px h-4 bg-border mx-1"}),$t(LP,{value:ke.chartType,pluginChartTypes:$e,dataLevel:Y,onChange:X=>{Pt(X)||(b.emit("chart:set-type",{old:ke.chartType,new:X}),Q($=>({...$,chartType:X})),wn("applySettings",{chartType:X}))}}),$t(mc,{orientation:"vertical",className:"h-4 mx-1"}),$t(cP,{indicators:Pe,dataLevel:Y,pluginIndicators:In,onActivatePlugin:X=>wn("activatePluginIndicator",X.indicator,X.pane),onAdd:X=>wn("handleAddIndicator",X),onToggle:X=>wn("handleToggleIndicator",X),onRemove:X=>wn("handleRemoveIndicator",X)}),h?.map((X,$)=>$t(eU.Fragment,{children:X},$)),$t(mD,{eventBus:b,chart:e}),$t("div",{className:"flex-1"}),_o("div",{className:"flex items-center gap-3",children:[$t(h2,{current:S,onChange:Ze,syncInLayout:k,setSyncInLayout:rr}),$t(TD,{eventBus:b,chart:e}),$t(yD,{eventBus:b,chart:e}),_o(Ht,{delayDuration:700,children:[$t(Ot,{asChild:!0,children:$t(pr,{onClick:()=>L(X=>!X),variant:"outline",className:"h-8 w-8 border-none text-muted-foreground hover:text-white hover:bg-muted",children:E?$t(js,{className:"w-4"}):$t(Gs,{className:"w-4"})})}),_o(_t,{className:"bg-background border border-border",children:[E?"Show":"Hide"," fixed panels"]})]})]})]})}),$t("div",{className:"flex flex-1 min-h-0",children:_o("div",{className:"flex flex-row flex-1 min-h-0",children:[!a&&$t(qR,{activeTool:ie.name,onToolChange:X=>{let $=X==="cursor"?Vo:ad(X);se($),z.current.forEach(ge=>ge?.setActiveTool($))},pluginDrawings:Be}),_o("div",{ref:O,style:{flex:1,display:"grid",gridTemplateColumns:Mw(R),gridTemplateRows:Mw(D),gridTemplateAreas:S.areas,gap:0,background:"rgba(255,255,255,.04)",position:"relative",overflow:"hidden",minHeight:0},children:[p2.map((X,$)=>{let ge=$<ot.length,Ce=x===$,ct=Z[$];return _o("div",{style:{gridArea:X,position:"relative",overflow:"hidden",minWidth:0,minHeight:0,visibility:ge?"visible":"hidden",pointerEvents:ge?"auto":"none",border:"0.5px solid #2b323c"},onMouseDownCapture:()=>{ge&&!Ce&&(T($),z.current[$]?.setActiveTool(ie),Eu.setFocus(e.id)),ge&&(ye.current=$)},children:[ct&&$t(aP,{ref:bt=>{z.current[$]=bt},managed:!0,hideToolbar:!0,hideDrawingToolbar:!0,hideBottomToolbar:!0,hidePriceScale:s,hideTimeScale:l,hideStatusBar:c,hideLegend:u,hideSettingsDialog:!0,onOpenSettings:()=>Re(!0),onHorizonUpdate:bt=>{cr.current=bt},onHorizonTick:Ce?()=>{}:void 0,domPanelRef:void 0,onRequestMore:er,tradeLines:we[$].trading.tradeLines,onCreateOrder:bt=>we[$].executionEngine?.placeOrder({qty:1,...bt,symbol:bt.symbol??fe[$]}),onGhostMove:we[$].trading.handleGhostMove,linesRef:we[$].trading.linesRef,draggingLineIdRef:we[$].trading.draggingLineIdRef,redrawTrading:()=>we[$].redrawFnRef.current?.(),eventBus:b,transformer:r,showDataStatusInBottomRightCorner:m,initialState:{timeframe:e.getChart($).timeframe},id:$,symbol:fe[$],features:g,account:e.account,drawingStore:e.drawingStore,model:e.getChart($),syncInLayout:k,setStatePatch:Xt},`${X}-chart`),ge&&Ce&&ot.length>1&&$t("div",{className:"w-full h-full bg-transparent pointer-events-none z-10 absolute top-0 left-0 border-2 border-blue-500/70"},`${X}-overlay`)]},X)}),O.current&&_o(rU,{children:[$t(Lw,{dir:"col",sizes:R,containerRef:O,onDrag:Tt}),$t(Lw,{dir:"row",sizes:D,containerRef:O,onDrag:Gt,areas:S.areas,colSizes:R})]})]}),$t(uD,{eventBus:b,chart:e,onFixedPanelsChange:B,override:E})]})}),!i&&$t(Sh,{delayDuration:400,children:_o("div",{className:"flex items-center h-8 px-3 border-t border-border/50 bg-background shrink-0 select-none",children:[_o("div",{className:"flex items-center gap-0.5",children:[["normal","percent"].map(X=>_o(Ht,{children:[$t(Ot,{asChild:!0,children:$t("button",{onClick:()=>{let $={priceScaleMode:X};Q(ge=>({...ge,...$})),z.current[ce.current]?.applySettings($)},className:ee("h-5 px-1.5 text-xs font-semibold rounded leading-none transition-colors",ke.priceScaleMode===X?"text-foreground/75":"text-foreground/25 hover:text-foreground/55"),children:X==="normal"?"N":"%"})}),$t(_t,{side:"top",className:"text-xs border border-border bg-background",children:X==="normal"?"Normal scale":"Percent scale"})]},X)),$t("div",{className:"w-px h-3 bg-border/50 mx-1 shrink-0"}),_o(Ht,{children:[$t(Ot,{asChild:!0,children:$t("button",{onClick:()=>{let X={autoScale:!ke.autoScale};Q($=>({...$,...X})),z.current[ce.current]?.applySettings(X)},className:ee("h-5 w-5 flex items-center justify-center rounded transition-colors",ke.autoScale?"text-foreground/70 hover:text-foreground/90":"text-foreground/25 hover:text-foreground/55"),children:ke.autoScale?$t(Ei,{size:11}):$t(jr,{size:11})})}),$t(_t,{side:"top",className:"text-xs border border-border bg-background",children:ke.autoScale?"Auto-scale on - click to lock":"Scale locked - click to auto-fit"})]}),_o(Ht,{children:[$t(Ot,{asChild:!0,children:$t("button",{onClick:()=>{let X={showGrid:!ke.showGrid};Q($=>({...$,...X})),z.current[ce.current]?.applySettings(X)},className:ee("h-5 w-5 flex items-center justify-center rounded transition-colors",ke.showGrid?"text-foreground/70 hover:text-foreground/90":"text-foreground/25 hover:text-foreground/55"),children:$t(ii,{size:11})})}),$t(_t,{side:"top",className:"text-xs border border-border bg-background",children:ke.showGrid?"Hide grid":"Show grid"})]}),_o(Ht,{children:[$t(Ot,{asChild:!0,children:$t("button",{onClick:()=>{let $={crosshairMode:ke.crosshairMode==="magnet"?"normal":"magnet"};Q(ge=>({...ge,...$})),z.current[ce.current]?.applySettings($)},className:ee("h-5 w-5 flex items-center justify-center rounded transition-colors",ke.crosshairMode==="magnet"?"text-foreground/70 hover:text-foreground/90":"text-foreground/25 hover:text-foreground/55"),children:$t(Xd,{size:11})})}),$t(_t,{side:"top",className:"text-xs border border-border bg-background",children:ke.crosshairMode==="magnet"?"Magnet on":"Magnet off"})]})]}),$t(hD,{eventBus:b,chart:e}),_o("div",{className:"ml-auto flex items-center gap-2",children:[ke.showTimezoneLabel&&$t("span",{ref:re,className:"text-xs text-foreground/30 tabular-nums leading-none"}),$t("span",{ref:W,className:"text-xs text-foreground/50 tabular-nums leading-none"})]})]})}),Se&&$t(FP,{settings:ke,horizon:cr.current,pluginChartType:ht,onUpdate:X=>{Q($=>({...$,...X})),z.current[ce.current]?.applySettings(X),X.pluginSettings&&ht&&ht.onSettingsChange?.(X.pluginSettings[ht.chartTypeId]??{})},onClose:()=>Re(!1)})]})})}var gc=class{constructor(){ae(this,"builtIns",new Map);ae(this,"activeSymbol","");ae(this,"custom",null);ae(this,"destroyed",!1);ae(this,"guard",null);ae(this,"eventBus",null);ae(this,"fillSearch",Cw)}attachBuiltIn(t,n){t.setFillSearch(this.fillSearch),this.builtIns.set(n,t),(!this.activeSymbol||this.activeSymbol===n)&&(this.activeSymbol=n)}setFillSearch(t){this.fillSearch={...this.fillSearch,...t};for(let n of this.builtIns.values())n.setFillSearch(this.fillSearch)}getFillSearch(){return this.fillSearch}hasPendingTriggers(t){return this.custom?!1:this.builtInFor(t)?.hasPendingTriggers()??!1}settleGapBars(t,n,r){this.custom||this.builtInFor(r)?.settleGapBars(t,n)}detachBuiltIn(t){this.builtIns.get(t)?.destroy?.(),this.builtIns.delete(t),this.activeSymbol===t&&(this.activeSymbol=this.builtIns.keys().next().value??"")}setActiveSymbol(t){this.activeSymbol=t}getActiveSymbol(){return this.activeSymbol}getCurrentPrice(t){return this.builtInFor(t)?.getPrice()??NaN}hasPrice(t){return this.custom?!0:Number.isFinite(this.builtInFor(t)?.getPrice()??NaN)}setCustomAdapter(t){this.custom=t}builtInFor(t){return this.builtIns.get(t??this.activeSymbol)??null}targetFor(t){return this.custom??this.builtInFor(t)}eachBuiltIn(t){for(let n of this.builtIns.values())t(n)}ingestCompactBuf(t,n){this.targetFor(n)?.ingestCompactBuf(t)}ingestOhlcvBars(t,n,r){this.targetFor(r)?.ingestOhlcvBars?.(t,n)}appendOhlcvBars(t,n,r){let o=this.targetFor(r);o&&(o.appendOhlcvBars?o.appendOhlcvBars(t,n):o.ingestOhlcvBars?.(t,n))}ingestSupplementalBars(t,n){this.targetFor(n)?.ingestSupplementalBars?.(t)}appendSupplementalBars(t,n){let r=this.targetFor(n);r&&(r.appendSupplementalBars?r.appendSupplementalBars(t):r.ingestSupplementalBars?.(t))}ingestTicks(t,n){this.targetFor(n)?.ingestTicks?.(t)}ingestPriceHistory(t,n){this.targetFor(n)?.ingestPriceHistory?.(t)}appendTicks(t,n){let r=this.targetFor(n);r&&(r.appendTicks?r.appendTicks(t):r.ingestTicks?.(t))}appendPriceHistory(t,n){let r=this.targetFor(n);r&&(r.appendPriceHistory?r.appendPriceHistory(t):r.ingestPriceHistory?.(t))}appendCompactBuf(t,n){let r=this.targetFor(n);r&&(r.appendCompactBuf?r.appendCompactBuf(t):r.ingestCompactBuf?.(t))}seekTo(t,n){if(this.custom){this.custom.seekTo(t);return}if(n!==void 0){this.builtIns.get(n)?.seekTo(t);return}this.eachBuiltIn(r=>r.seekTo(t))}onMboEvent(t,n,r){this.targetFor(r)?.onMboEvent(t,n)}setOrderGuard(t){this.guard=t}setEventBus(t){this.eventBus=t}placeOrder(t){let n=this.guard?.(t)??null;if(n!==null){this.eventBus?.emit("trading:order-blocked",{req:t,reason:n});return}if(!this.hasPrice(t.symbol)){this.eventBus?.emit("trading:order-blocked",{req:t,reason:"No market data yet for this symbol"});return}return this.targetFor(t.symbol)?.placeOrder(t)}cancelOrder(t){if(this.custom)return void this.custom.cancelOrder(t);this.eachBuiltIn(n=>n.cancelOrder(t))}amendOrder(t,n){if(this.custom)return void this.custom.amendOrder(t,n);this.eachBuiltIn(r=>r.amendOrder(t,n))}amendBracket(t){if(this.custom)return void this.custom.amendBracket(t);this.eachBuiltIn(n=>n.amendBracket(t))}closePosition(t){if(this.custom)return void this.custom.closePosition(t);this.eachBuiltIn(n=>n.closePosition(t))}reversePosition(t){if(this.custom)return void this.custom.reversePosition?.(t);this.eachBuiltIn(n=>n.reversePosition(t))}syncPosition(t){this.builtInFor(t.symbol)?.syncPosition(t)}syncOrder(t){this.builtInFor(t.symbol)?.syncOrder(t)}totalFeesPaid(){if(this.custom)return this.custom.totalFeesPaid?.()??0;let t=0;return this.eachBuiltIn(n=>t+=n.totalFeesPaid?.()??0),t}totalRealizedPnl(){if(this.custom)return this.custom.totalRealizedPnl?.()??0;let t=0;return this.eachBuiltIn(n=>t+=n.totalRealizedPnl?.()??0),t}destroy(){this.destroyed||(this.destroyed=!0,this.custom?.destroy())}};var Xi=class{constructor(){ae(this,"view",{tMin:0n,tMax:1n,pMin:0,pMax:1,pRef:0});ae(this,"mode","linear");ae(this,"_sessionMapper",null);ae(this,"_barNs",0n);ae(this,"_barAlignedStarts",[]);ae(this,"_sessionMapperVersion",-1);ae(this,"_ordinal",null);ae(this,"_session",null)}setOrdinal(t){this._ordinal=t&&t.length>1?t:null}getOrdinal(){return this._ordinal}_ordinalActive(){return this._ordinal!==null}setSessionMapper(t){this._sessionMapper!==t&&(this._sessionMapper=t,this._barAlignedStarts=[])}getSessionMapper(){return this._sessionMapper}tsToFracIndex(t){let n=this._ordinal;if(!n||n.length<2)return 0;let r=n.length,o=0,a=r-1,i=-1;for(;o<=a;){let l=o+a>>>1;n[l]<=t?(i=l,o=l+1):a=l-1}if(i<0){let l=Number(n[1]-n[0])||1;return-Number(n[0]-t)/l}if(i>=r-1){let l=Number(n[r-1]-n[r-2])||1;return r-1+Number(t-n[r-1])/l}let s=Number(n[i+1]-n[i]);return s<=0?i:i+Number(t-n[i])/s}indexToTs(t){let n=this._ordinal;if(!n||n.length===0)return this.view.tMin;let r=n.length;if(r===1)return n[0];if(t<=0){let i=n[1]-n[0];return n[0]+BigInt(Math.round(t*Number(i)))}if(t>=r-1){let i=n[r-1]-n[r-2];return n[r-1]+BigInt(Math.round((t-(r-1))*Number(i)))}let o=Math.floor(t),a=t-o;return n[o]+BigInt(Math.round(a*Number(n[o+1]-n[o])))}_idxMin(){return this.tsToFracIndex(this.view.tMin)}_idxMax(){return this.tsToFracIndex(this.view.tMax)}indexToX(t,n){let r=this._idxMin(),o=this._idxMax()-r;return o===0?0:(t-r)/o*n}xToIndex(t,n){if(n===0)return this._idxMin();let r=this._idxMin();return r+t/n*(this._idxMax()-r)}makeIndexToXFn(t){let n=this._idxMin(),r=this._idxMax()-n;if(r===0)return()=>0;let o=t/r;return a=>(a-n)*o}setSession(t){this._session=t}getSessionStatus(t){return Pi(this._session,t)}setBarNs(t){this._barNs!==t&&(this._barNs=t,this._barAlignedStarts=[])}_ensureBarAlignedStarts(){let t=this._sessionMapper?.version??-1;if(this._barAlignedStarts.length>0&&this._sessionMapperVersion===t||(this._barAlignedStarts=[],this._sessionMapperVersion=t,!this._sessionMapper||!this._sessionMapper.hasSession||this._barNs===0n))return;let n=0n;for(let r of this._sessionMapper.segments){this._barAlignedStarts.push(n);let o=(r.duration+this._barNs-1n)/this._barNs;n+=o*this._barNs}}_tsToBarAligned(t){this._ensureBarAlignedStarts();let n=this._sessionMapper.segments,r=0,o=n.length-1;for(;r<=o;){let d=r+o>>>1,m=n[d];if(t>=m.realEnd)r=d+1;else if(t<m.realStart)o=d-1;else return this._barAlignedStarts[d]+(t-m.realStart)}if(r>=n.length){let d=n[n.length-1];return this._barAlignedStarts[n.length-1]+d.duration+(t-d.realEnd)}if(r===0)return this._barAlignedStarts[0]-(n[0].realStart-t);let a=n[r-1],i=n[r],s=this._barAlignedStarts[r-1]+a.duration,l=this._barAlignedStarts[r],c=l-s;if(c===0n)return l;let u=i.realStart-a.realEnd;return u===0n?l:s+(t-a.realEnd)*c/u}_barAlignedToTs(t){this._ensureBarAlignedStarts();let n=this._sessionMapper.segments,r=n.length,o=0,a=r-1;for(;o<=a;){let i=o+a>>>1,s=this._barAlignedStarts[i],l=i+1<r?this._barAlignedStarts[i+1]:s+(n[i].duration+this._barNs-1n)/this._barNs*this._barNs;if(t>=l)o=i+1;else if(t<s)a=i-1;else{let c=t-s,u=n[i];if(c<u.duration)return u.realStart+c;let d=c-u.duration,m=l-s-u.duration;if(m===0n||i+1>=r)return u.realEnd;let h=n[i+1].realStart-u.realEnd;return u.realEnd+d*h/m}}if(o>=r){let i=n[r-1],s=this._barAlignedStarts[r-1]+(i.duration+this._barNs-1n)/this._barNs*this._barNs;return i.realEnd+(t-s)}return n[0].realStart-(this._barAlignedStarts[0]-t)}update(t){this.view=t}setScaleMode(t){this.mode=t}getScaleMode(){return this.mode}getView(){return this.view}tsToX(t,n){if(this._ordinalActive())return this.indexToX(this.tsToFracIndex(t),n);if(!this._sessionMapper||!this._sessionMapper.hasSession){let i=Number(this.view.tMax-this.view.tMin);return i===0?0:Number(t-this.view.tMin)/i*n}if(this._barNs===0n)return this._sessionMapper.tsToX(t,this.view.tMin,this.view.tMax,n);let r=this._tsToBarAligned(this.view.tMin),o=this._tsToBarAligned(this.view.tMax),a=Number(o-r);return a===0?0:Number(this._tsToBarAligned(t)-r)/a*n}makeTsToXFn(t){if(this._ordinalActive()){let l=this._idxMin(),c=this._idxMax()-l;if(c===0)return()=>0;let u=t/c;return d=>(this.tsToFracIndex(d)-l)*u}if(!this._sessionMapper||!this._sessionMapper.hasSession){let l=this.view.tMin,c=Number(this.view.tMax-l);if(c===0)return()=>0;let u=t/c;return d=>Number(d-l)*u}if(this._barNs===0n){let l=this._sessionMapper.segments,c=this._sessionMapper.tsToMarket(this.view.tMin),u=Number(this._sessionMapper.tsToMarket(this.view.tMax)-c);if(u===0)return()=>0;let d=t/u,m=0;return f=>{if(m<l.length){let v=l[m];if(f>=v.realStart&&f<v.realEnd)return Number(v.marketStart+(f-v.realStart)-c)*d}let h=0,p=l.length-1;for(;h<=p;){let v=h+p>>>1,b=l[v];if(f>=b.realEnd)h=v+1;else if(f<b.realStart)p=v-1;else return m=v,Number(b.marketStart+(f-b.realStart)-c)*d}if(h>=l.length){let v=l[l.length-1];return Number(v.marketStart+v.duration-c)*d}if(h===0)return Number(l[0].marketStart-(l[0].realStart-f)-c)*d;let g=l[h-1],y=l[h];return f-g.realEnd<=y.realStart-f?Number(g.marketStart+g.duration-c)*d:Number(y.marketStart-c)*d}}this._ensureBarAlignedStarts();let n=this._sessionMapper.segments,r=this._barAlignedStarts,o=this._tsToBarAligned(this.view.tMin),a=Number(this._tsToBarAligned(this.view.tMax)-o);if(a===0)return()=>0;let i=t/a,s=0;return l=>{if(s<n.length){let y=n[s];if(l>=y.realStart&&l<y.realEnd)return Number(r[s]+(l-y.realStart)-o)*i}let c=0,u=n.length-1;for(;c<=u;){let y=c+u>>>1,v=n[y];if(l>=v.realEnd)c=y+1;else if(l<v.realStart)u=y-1;else return s=y,Number(r[y]+(l-v.realStart)-o)*i}if(c>=n.length){let y=n[n.length-1];return Number(r[n.length-1]+y.duration+(l-y.realEnd)-o)*i}if(c===0)return Number(r[0]-(n[0].realStart-l)-o)*i;let d=n[c-1],m=n[c],f=r[c-1]+d.duration,h=r[c],p=h-f;if(p===0n)return Number(h-o)*i;let g=m.realStart-d.realEnd;return g===0n?Number(h-o)*i:Number(f+(l-d.realEnd)*p/g-o)*i}}makePriceToYFn(t){if(this.mode==="linear"){let n=this.view.pMax,r=n-this.view.pMin;if(r===0)return()=>0;let o=t/r;return a=>(n-a)*o}return n=>this.priceToY(n,t)}priceToY(t,n){switch(this.mode){case"log":return this._logPriceToY(t,n);case"percent":return this._pctPriceToY(t,n);default:return this._linearPriceToY(t,n)}}xToTs(t,n){if(this._ordinalActive())return this.indexToTs(this.xToIndex(t,n));if(!this._sessionMapper||!this._sessionMapper.hasSession){let s=Number(this.view.tMax-this.view.tMin);return this.view.tMin+BigInt(Math.round(t/n*s))}if(this._barNs===0n)return this._sessionMapper.xToTs(t,this.view.tMin,this.view.tMax,n);let r=this._tsToBarAligned(this.view.tMin),o=this._tsToBarAligned(this.view.tMax),a=Number(o-r);if(a===0)return this.view.tMin;let i=r+BigInt(Math.round(t/n*a));return this._barAlignedToTs(i)}yToPrice(t,n){switch(this.mode){case"log":return this._logYToPrice(t,n);case"percent":return this._pctYToPrice(t,n);default:return this._linearYToPrice(t,n)}}getBarPx(t){if(this._ordinalActive()){let r=this._idxMax()-this._idxMin();return r<=0?0:t/r}if(this._barNs===0n)return 0;if(!this._sessionMapper||!this._sessionMapper.hasSession){let r=Number(this.view.tMax-this.view.tMin);return r===0?0:Number(this._barNs)/r*t}let n=Number(this._tsToBarAligned(this.view.tMax)-this._tsToBarAligned(this.view.tMin));return n===0?0:Number(this._barNs)/n*t}tsToXAt(t,n,r){let o=Number(n.tMax-n.tMin);return o===0?0:Number(t-n.tMin)/o*r}priceToYAt(t,n,r){let o=n.pMax-n.pMin;return o===0?0:(1-(t-n.pMin)/o)*r}xToTsAt(t,n,r){return r===0?n.tMin:n.tMin+BigInt(Math.round(t/r*Number(n.tMax-n.tMin)))}yToPriceAt(t,n,r){return r===0?n.pMin:n.pMin+(1-t/r)*(n.pMax-n.pMin)}_linearPriceToY(t,n){let r=this.view.pMax-this.view.pMin;return r===0?0:(1-(t-this.view.pMin)/r)*n}_linearYToPrice(t,n){return n===0?this.view.pMin:this.view.pMin+(1-t/n)*(this.view.pMax-this.view.pMin)}_logPriceToY(t,n){if(t<=0||this.view.pMin<=0||this.view.pMax<=0)return this._linearPriceToY(t,n);let r=Math.log(t),o=Math.log(this.view.pMin),i=Math.log(this.view.pMax)-o;return i===0?0:(1-(r-o)/i)*n}_logYToPrice(t,n){if(this.view.pMin<=0||this.view.pMax<=0)return this._linearYToPrice(t,n);let r=Math.log(this.view.pMin),o=Math.log(this.view.pMax);return Math.exp(r+(1-t/n)*(o-r))}_pctPriceToY(t,n){let r=this.view.pRef;if(r===0)return this._linearPriceToY(t,n);let o=(this.view.pMin-r)/r,i=(this.view.pMax-r)/r-o;return i===0?0:(1-((t-r)/r-o)/i)*n}_pctYToPrice(t,n){let r=this.view.pRef;if(r===0)return this._linearYToPrice(t,n);let o=(this.view.pMin-r)/r,a=(this.view.pMax-r)/r,i=o+(1-t/n)*(a-o);return r*(1+i)}};var Lm=class{constructor(){ae(this,"installed",new Map);ae(this,"serviceRegistry",new Map);ae(this,"serviceListeners",new Map);ae(this,"pendingInstalls",[]);ae(this,"renderEngineReady",!1);ae(this,"eventBus",null);ae(this,"options",{enabled:!0,indicator:!0,drawing:!0,"chart-type":!0,extension:!0})}setOptions(t){let n={indicators:"indicator",drawings:"drawing",charts:"chart-type",extensions:"extension",enabled:"enabled"};for(let r in t)this.options[n[r]]=t[r]}setEventBus(t){this.eventBus=t}has(t){return this.installed.has(t)||this.pendingInstalls.some(n=>n.plugin.id===t)}getInstalledIds(){return[...this.installed.keys(),...this.pendingInstalls.map(t=>t.plugin.id)]}getInstalledPlugins(){let t=n=>({id:n.id,name:n.name??n.id,type:n.type});return[...[...this.installed.values()].map(n=>t(n.plugin)),...this.pendingInstalls.map(n=>t(n.plugin))]}async register(t,n){if(!(!this.options?.enabled||!this.options[t.type])){if(this.installed.has(t.id)){console.warn(`[PluginRegistry] '${t.id}' already installed - skipping`);return}if(!this.renderEngineReady){this.pendingInstalls.push({plugin:t,ctx:n});return}await this._doInstall(t,n)}}notifyRenderEngineReady(t){if(this.renderEngineReady=!0,this.pendingInstalls.length===0)return;let n=this.pendingInstalls.splice(0);for(let{plugin:r,ctx:o}of n)this._doInstall(r,o).catch(a=>{console.error(`[PluginRegistry] Deferred install of '${r.id}' failed:`,a)})}buildLifecycle(t){return{onSymbolChange(n){return t.on("chart:set-symbol",({symbol:r})=>n(r))},onTimeframeChange(n){return t.on("chart:set-timeframe",({tf:r})=>n(r))},onThemeChange(n){return t.on("theme:change",r=>n(r))},onFocus(n){return t.on("chart:focused",({id:r})=>n(r))},onBlur(n){return t.on("chart:blurred",n)}}}async _doInstall(t,n){let r=t.require??"ohlcv",o=n.dataLevel,a=this.buildRestrictedContext(n,()=>t.permissions??[],t.id,()=>t.origins??[]);if(!Ao(r,o)){console.warn(`[PluginRegistry] Plugin '${t.id}' requires '${r}' but chart has '${o}' - skipping`),this.eventBus?.emit("plugin:incompatible",{id:t.id,name:t.name,kind:"plugin",required:r,actual:o});return}try{let i=await t.install(a),s=typeof i=="function"?i:()=>{};this.installed.set(t.id,{plugin:t,ctx:a,teardown:s}),this.eventBus?.emit("plugin:installed",{id:t.id})}catch(i){console.error(`[PluginRegistry] install() threw for '${t.id}':`,i)}}buildServices(t){return{register:(n,r)=>(this.serviceRegistry.has(n)&&console.warn(`[PluginServices] '${n}' already registered - overwriting`),this.serviceRegistry.set(n,r),this.serviceListeners.get(n)?.forEach(o=>o.onAvailable(r)),()=>{this.serviceRegistry.get(n)===r&&(this.serviceRegistry.delete(n),this.serviceListeners.get(n)?.forEach(o=>o.onRemoved?.()))}),get:n=>this.serviceRegistry.get(n)??null,on:(n,r)=>{let o=this.serviceRegistry.get(n);return o&&r.onAvailable(o),this.serviceListeners.has(n)||this.serviceListeners.set(n,new Set),this.serviceListeners.get(n).add(r),()=>this.serviceListeners.get(n)?.delete(r)}}}buildRestrictedContext(t,n,r,o){let a=l=>n().includes(l),i=(l,c)=>(...u)=>{if(!a(l))throw new Error(`Missing ${l}`);return c(...u)},s=async(l,c)=>{if(!a("network"))throw new Error("Missing network");let u;try{u=new URL(l,globalThis.location?.href).origin}catch{throw new Error(`[Plugin "${r}"] fetch called with a bad url: ${l}`)}if(!o().some(m=>{try{return new URL(m).origin===u}catch{return!1}}))throw new Error(`[Plugin "${r}"] fetch to ${u} is not allowed. Add it to the plugin's origins to reach it.`);return t.fetch(l,c)};return{...t,registerPane:t.registerPane,get renderEngine(){return a("render:overlay")?t.renderEngine:null},getData:i("data:read",t.getData),openBar:i("data:read",t.openBar),registerPanel:i("ui:panel",t.registerPanel),registerToolbarItem:i("ui:toolbar",t.registerToolbarItem),registerBottomBarItem:i("ui:toolbar",t.registerBottomBarItem),registerContextMenuItem:i("ui:context-menu",t.registerContextMenuItem),registerDrawingTool:i("drawing:register",t.registerDrawingTool),registerTheme:i("theme:register",t.registerTheme),playSound:i("audio",t.playSound),fetch:s,intercept:i("intercept",t.intercept),addOverlay:i("render:overlay",t.addOverlay),registerDataSource:i("data:write",t.registerDataSource),get storage(){if(!a("storage"))throw new Error("Missing storage");return t.storage},services:t.services,lifecycle:t.lifecycle,schedule:t.schedule,notify:t.notify,playback:t.playback,get execution(){return a("execution:write")?t.execution:a("execution:read")&&t.execution?{...t.execution,placeOrder:()=>{throw new Error(`Plugin '${r}' missing execution:write`)},cancelOrder:()=>{throw new Error(`Plugin '${r}' missing execution:write`)},amendOrder:()=>{throw new Error(`Plugin '${r}' missing execution:write`)},amendBracket:()=>{throw new Error(`Plugin '${r}' missing execution:write`)},closePosition:()=>{throw new Error(`Plugin '${r}' missing execution:write`)},reversePosition:()=>{throw new Error(`Plugin '${r}' missing execution:write`)}}:null}}}serialize(){return[...this.installed.entries()].filter(([t,n])=>!t.startsWith("builtin")&&typeof n.plugin.code=="string").map(([t,n])=>({id:t,code:n.plugin.code}))}unregister(t){let n=this.installed.get(t);if(!n){let r=this.pendingInstalls.findIndex(o=>o.plugin.id===t);r!==-1&&(this.pendingInstalls.splice(r,1),this.eventBus?.emit("plugin:uninstalled",{id:t}));return}try{n.teardown(),n.plugin.uninstall?.(n.ctx)}catch(r){console.warn(`[PluginRegistry] teardown error for '${t}':`,r)}this.installed.delete(t),this.eventBus?.emit("plugin:uninstalled",{id:t})}destroy(){for(let[,t]of this.installed)try{t.teardown(),t.plugin.uninstall?.(t.ctx)}catch{}this.installed.clear(),this.pendingInstalls=[],this.renderEngineReady=!1}};var Ig=class{constructor(t){ae(this,"_state");this._state={...t}}get(t){return this._state[t]}snapshot(){return Object.freeze({...this._state})}set(t,n,r){if(this._state[t]!==n&&(this._state[t]=n,!!r))switch(t){case"activeTool":r.emit("chart:set-tool",{tool:n});break;case"symbol":r.emit("chart:set-symbol-focused",{symbol:n});break;case"timeframe":r.emit("chart:set-timeframe",{tf:n}),r.emit("timeframe:change",{tf:n});break;case"isPlaying":n?r.emit("playback:play",void 0):r.emit("playback:pause",void 0);break}}patch(t,n){for(let r of Object.keys(t))this.set(r,t[r],n)}};var Rm=class{constructor(t){ae(this,"id");ae(this,"_symbol");ae(this,"_timeframe");ae(this,"_settings");ae(this,"_activeTool");ae(this,"_fpOptions");ae(this,"_plugins");ae(this,"_restoredPlugins",[]);ae(this,"listeners",new Set);this.id=t.id??`pane:${pn(6)}`,this._symbol=t.symbol,this._timeframe=t.timeframe,this._settings=t.settings??{...Ye},this._activeTool=t.activeTool??"cursor",this._fpOptions=t.fpOptions??{},this._plugins=t.plugins?[...t.plugins]:[]}get symbol(){return this._symbol}setSymbol(t){t!==this._symbol&&(this._symbol=t,this._notify())}get timeframe(){return this._timeframe}setTimeframe(t){t!==this._timeframe&&(this._timeframe=t,this._notify())}get activeTool(){return this._activeTool}setActiveTool(t){t!==this._activeTool&&(this._activeTool=t,this._notify())}get fpOptions(){return this._fpOptions}setFpOptions(t){this._fpOptions=t,this._notify()}get settings(){return this._settings}setSettings(t){this._settings={...this._settings,...t},this._notify()}get plugins(){return this._plugins}use(t){let n=this._plugins.findIndex(r=>r.instanceId===t.instanceId);n===-1?this._plugins=[...this._plugins,t]:this._plugins=this._plugins.map((r,o)=>o===n?t:r),this._notify()}unuse(t){let n=this._plugins.filter(r=>r.instanceId!==t);n.length!==this._plugins.length&&(this._plugins=n,this._notify())}setPlugins(t){this._plugins=[...t],this._notify()}get restoredPlugins(){return this._restoredPlugins}consumeRestoredPlugin(t){this._restoredPlugins=this._restoredPlugins.filter(n=>n.instanceId!==t)}serialize(){return{id:this.id,symbol:this._symbol,timeframe:this._timeframe.label,settings:lR(this._settings),plugins:this._plugins.map(t=>({...t}))}}restore(t){this._symbol=t.symbol,this._timeframe=NS(t.timeframe),this._settings=cR(t.settings),this._plugins=t.plugins?[...t.plugins]:[],this._restoredPlugins=t.plugins?[...t.plugins]:[],this._notify()}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}_notify(){for(let t of this.listeners)t(this)}};var oU=Object.freeze([]),Pm=class{constructor(){ae(this,"bySymbol",new Map);ae(this,"listeners",new Map)}forSymbol(t){return this.bySymbol.get(t)??oU}find(t,n){return this.bySymbol.get(t)?.find(r=>r.id===n)}symbols(){return[...this.bySymbol.keys()].filter(t=>(this.bySymbol.get(t)?.length??0)>0)}add(t,n){let r=this.bySymbol.get(t)??[];this.bySymbol.set(t,[...r,n]),this._changed(t)}update(t,n,r){let o=this.bySymbol.get(t);o&&(this.bySymbol.set(t,o.map(a=>a.id===n?{...a,...r}:a)),this._changed(t))}remove(t,n){let r=this.bySymbol.get(t);if(!r)return;let o=r.filter(a=>a.id!==n);o.length!==r.length&&(this.bySymbol.set(t,o),this._changed(t))}setForSymbol(t,n){this.bySymbol.set(t,[...n]),this._changed(t)}clearSymbol(t){this.bySymbol.has(t)&&(this.bySymbol.delete(t),this._changed(t))}serialize(){let t={};for(let[n,r]of this.bySymbol)r.length&&(t[n]=r);return t}restore(t){let n=new Set([...this.bySymbol.keys(),...Object.keys(t)]);this.bySymbol.clear();for(let r of Object.keys(t))this.bySymbol.set(r,[...t[r]]);for(let r of n)this._changed(r)}subscribe(t,n){let r=this.listeners.get(t);return r||(r=new Set,this.listeners.set(t,r)),r.add(n),()=>{r.delete(n),r.size===0&&this.listeners.delete(t)}}_changed(t){this.listeners.get(t)?.forEach(n=>n())}};var Dm=class{constructor(t){ae(this,"eventBus");ae(this,"currency");ae(this,"initialBalance");ae(this,"fills",[]);ae(this,"orders",new Map);ae(this,"positionMap",new Map);ae(this,"adjustments",[]);ae(this,"horizonNs",null);ae(this,"adapter",null);ae(this,"executionEngine",null);ae(this,"unsubs",[]);ae(this,"destroyed",!1);this.eventBus=t.eventBus,this.executionEngine=t.executionEngine??null,this.initialBalance=t.initialBalance??1e5,this.currency=t.currency??"USD",this._subscribeEventBus(),t.adapter&&this.setAdapter(t.adapter)}setFillSearch(t){this.executionEngine?.setFillSearch(t)}getFillSearch(){return this.executionEngine?.getFillSearch()??null}setAdapter(t){if(this.adapter?.detach(),this.adapter=t,!t)return;let n={onFill:r=>{this._ingestFill({...r,playheadTs:this.horizonNs??BigInt(r.ts)})},onOrderUpdate:r=>{this._ingestOrder(r,this.horizonNs??BigInt(r.updatedAt))},onPositionUpdate:r=>{this._ingestPositionUpdate(r,r.ts)},onPositionClose:r=>{this._ingestPositionClose(r.positionId??"",r.realizedPnl??0,r.ts)},onBalanceUpdate:(r,o)=>{let a=this._deriveBalance(o);this._ingestAdjustment(r-a,o)}};t.attach(n)}deposit(t,n,r){this._ingestAdjustment(t,n??this.horizonNs??0n,r),this._emit()}withdraw(t,n,r){this._ingestAdjustment(-t,n??this.horizonNs??0n,r),this._emit()}reset(){this.fills=[],this.orders.clear(),this.positionMap.clear(),this.adjustments=[],this.horizonNs=null,this._emit(),this.eventBus.emit("account:reset",void 0)}seekTo(t){this.horizonNs=t,this._emit()}getSnapshot(){let t=this.horizonNs,n=t===null?this.fills:this.fills.filter(p=>p.playheadTs<=t),r=[...this.fills.values()],o=[...this.orders.values()],a=t===null?o:o.filter(p=>p.placedAt<=t),i=[...this.positionMap.values()],s=i.filter(p=>p.position.status!=="closed"),l=i.filter(p=>p.position.status==="closed"),{balance:c,equity:u,realizedPnl:d,unrealizedPnl:m}=this._deriveTotals(),f=this._buildEquityCurve(l,t),h=this._buildStats(l,n,a);return{balance:c,equity:u,realizedPnl:d,unrealizedPnl:m,openPositionCount:s.length,currency:this.currency,fills:r,orders:o,openPositions:s,closedPositions:l,stats:h,equityCurve:f}}_ingestFill(t){this.fills.splice(this._insertIdxByPlayheadTs(this.fills,t.playheadTs),0,t),this._emit()}_ingestOrder(t,n){let r=this.orders.get(t.id);this.orders.set(t.id,{id:t.id,order:t,placedAt:r?.placedAt??n,updatedAt:n}),this._emit()}_ingestPositionUpdate(t,n){let r=this.positionMap.get(t.id);r?r.position=t:this.positionMap.set(t.id,{id:t.id,position:t,openedAt:n}),this._emit()}_ingestPositionClose(t,n,r){let o=this.positionMap.get(t);o?(o.closedAt=r,o.realizedPnlAtClose=n):(console.warn(`[AccountManager] position:closed for unknown id "${t}" - creating stub`),this.positionMap.set(t,{id:t,position:{id:t},openedAt:r,closedAt:r,realizedPnlAtClose:n})),this._emit()}_ingestAdjustment(t,n,r){this.adjustments.splice(this._insertIdxByTs(this.adjustments,n),0,r?{amount:t,ts:n,note:r}:{amount:t,ts:n})}_deriveTotals(){let t=0,n=0,r=0;for(let a of this.positionMap.values())t+=a.position.realizedPnl??0,n+=a.position.unrealizedPnl??0,a.position.status!=="closed"&&r++;let o=this._deriveBalance(this.horizonNs)+t;return{balance:o,equity:o+n,realizedPnl:t,unrealizedPnl:n,openPositionCount:r}}_deriveBalance(t){let n=this.initialBalance;for(let r of this.adjustments){if(t!==null&&r.ts>t)break;n+=r.amount}return n}_buildEquityCurve(t,n){let r=[...t].filter(i=>i.closedAt!==void 0).sort((i,s)=>i.closedAt<s.closedAt?-1:i.closedAt>s.closedAt?1:0),o=[],a=0;for(let i of r){a+=i.realizedPnlAtClose??0;let s=this._deriveBalance(i.closedAt)+a;o.push({ts:i.closedAt,balance:s,equity:s,realizedPnl:a})}return o}_buildStats(t,n,r){let o=0,a=0,i=0,s=0,l=0,c=0,u=0,d=0,m=0n,f=0n;for(let b of t){let S=b.realizedPnlAtClose??0;S>0?(o++,i+=S,S>u&&(u=S)):(a++,s+=Math.abs(S),S<d&&(d=S));let C=b.position?.realizedRR;if(C!=null&&isFinite(C)&&C!==0&&(l+=C,c++),b.closedAt!==void 0){let w=b.closedAt-b.openedAt;w>=0n&&(m+=w,f++)}}let h=o+a,p=0,g=0;for(let b of n)p+=b.fee??0;for(let b of t)g+=b.position?.commissionTotal??0;let y=r.filter(b=>b.order.status==="filled").length,v=r.filter(b=>b.order.status==="cancelled"||b.order.status==="rejected").length;return{winCount:o,lossCount:a,winRate:h>0?o/h:NaN,profitFactor:s>0?i/s:i>0?1/0:NaN,avgRR:c>0?l/c:NaN,largestWin:u,largestLoss:d,avgHoldTimeNs:f>0n?m/f:0n,totalFees:p,totalCommission:g,filledOrderCount:y,cancelledOrderCount:v}}_emit(){this.destroyed||this.eventBus.emit("account:update",{...this._deriveTotals(),currency:this.currency})}_subscribeEventBus(){this.unsubs.push(this.eventBus.on("playback:seek",({tNs:t})=>{this.seekTo(t)}),this.eventBus.on("trading:event",t=>{let n=this.horizonNs??0n;switch(t.kind){case"order:placed":case"order:updated":case"order:cancelled":case"order:rejected":this._ingestOrder(t.order,n);break;case"order:filled":this._ingestOrder(t.order,n);break;case"fill:received":this._ingestFill({...t.fill,playheadTs:n});break;case"position:opened":this._ingestPositionUpdate(t.position,n);break;case"position:updated":this._ingestPositionUpdate(t.position,n);break;case"position:closed":this._ingestPositionUpdate(t.position,n),this._ingestPositionClose(t.position.id,t.realizedPnl??t.position.realizedPnl??0,n);break;default:break}}),this.eventBus.on("account:deposit",({amount:t,ts:n,note:r})=>{this._ingestAdjustment(t,n,r),this._emit()}),this.eventBus.on("account:withdraw",({amount:t,ts:n,note:r})=>{this._ingestAdjustment(-t,n,r),this._emit()}))}_insertIdxByPlayheadTs(t,n){let r=0,o=t.length;for(;r<o;){let a=r+o>>>1;t[a].playheadTs<=n?r=a+1:o=a}return r}_insertIdxByTs(t,n){let r=0,o=t.length;for(;r<o;){let a=r+o>>>1;t[a].ts<=n?r=a+1:o=a}return r}serialize(){return{initialBalance:this.initialBalance,fills:this.fills,orders:[...this.orders.values()],positions:[...this.positionMap.values()],adjustments:this.adjustments}}restore(t){this.fills=t.fills??[],this.orders.clear();for(let n of t.orders??[])this.orders.set(n.id,n);this.positionMap.clear();for(let n of t.positions??[])this.positionMap.set(n.id,n);this.adjustments=t.adjustments??[],this.initialBalance=t.initialBalance,this._emit()}destroy(){this.destroyed||(this.destroyed=!0,this.unsubs.forEach(t=>t()),this.adapter?.detach())}};var aU='(()=>{var Cr=Object.defineProperty;var Er=(t,e,n)=>e in t?Cr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var qe=(t,e,n)=>Er(t,typeof e!="symbol"?e+"":e,n);var z=class extends Error{},rt=class extends z{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},it=class extends z{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},st=class extends z{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},Y=class extends z{},Ae=class extends z{constructor(e){super(`Invalid unit ${e}`)}},x=class extends z{},$=class extends z{constructor(){super("Zone is an abstract class")}},h="numeric",V="short",M="long",Fe={year:h,month:h,day:h},cn={year:h,month:V,day:h},Ir={year:h,month:V,day:h,weekday:V},fn={year:h,month:M,day:h},mn={year:h,month:M,day:h,weekday:M},hn={hour:h,minute:h},dn={hour:h,minute:h,second:h},yn={hour:h,minute:h,second:h,timeZoneName:V},gn={hour:h,minute:h,second:h,timeZoneName:M},wn={hour:h,minute:h,hourCycle:"h23"},pn={hour:h,minute:h,second:h,hourCycle:"h23"},bn={hour:h,minute:h,second:h,hourCycle:"h23",timeZoneName:V},Sn={hour:h,minute:h,second:h,hourCycle:"h23",timeZoneName:M},Tn={year:h,month:h,day:h,hour:h,minute:h},kn={year:h,month:h,day:h,hour:h,minute:h,second:h},xn={year:h,month:V,day:h,hour:h,minute:h},Dn={year:h,month:V,day:h,hour:h,minute:h,second:h},Ar={year:h,month:V,day:h,weekday:V,hour:h,minute:h},On={year:h,month:M,day:h,hour:h,minute:h,timeZoneName:V},Nn={year:h,month:M,day:h,hour:h,minute:h,second:h,timeZoneName:V},vn={year:h,month:M,day:h,weekday:M,hour:h,minute:h,timeZoneName:M},Mn={year:h,month:M,day:h,weekday:M,hour:h,minute:h,second:h,timeZoneName:M},j=class{get type(){throw new $}get name(){throw new $}get ianaName(){return this.name}get isUniversal(){throw new $}offsetName(e,n){throw new $}formatOffset(e,n){throw new $}offset(e){throw new $}equals(e){throw new $}get isValid(){throw new $}},Ge=null,We=class t extends j{static get instance(){return Ge===null&&(Ge=new t),Ge}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:n,locale:r}){return $n(e,n,r)}formatOffset(e,n){return ge(this.offset(e),n)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}},ot=new Map;function Fr(t){let e=ot.get(t);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),ot.set(t,e)),e}var Wr={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Lr(t,e){let n=t.format(e).replace(/\\u200E/g,""),r=/(\\d+)\\/(\\d+)\\/(\\d+) (AD|BC),? (\\d+):(\\d+):(\\d+)/.exec(n),[,i,s,o,a,l,u,c]=r;return[o,i,s,a,l,u,c]}function Vr(t,e){let n=t.formatToParts(e),r=[];for(let i=0;i<n.length;i++){let{type:s,value:o}=n[i],a=Wr[s];s==="era"?r[a]=o:g(a)||(r[a]=parseInt(o,10))}return r}var Je=new Map,_=class t extends j{static create(e){let n=Je.get(e);return n===void 0&&Je.set(e,n=new t(e)),n}static resetCache(){Je.clear(),ot.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=t.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:n,locale:r}){return $n(e,n,r,this.name)}formatOffset(e,n){return ge(this.offset(e),n)}offset(e){if(!this.valid)return NaN;let n=new Date(e);if(isNaN(n))return NaN;let r=Fr(this.name),[i,s,o,a,l,u,c]=r.formatToParts?Vr(r,n):Lr(r,n);a==="BC"&&(i=-Math.abs(i)+1);let d=Ue({year:i,month:s,day:o,hour:l===24?0:l,minute:u,second:c,millisecond:0}),m=+n,y=m%1e3;return m-=y>=0?y:1e3+y,(d-m)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}},Ft={};function Rr(t,e={}){let n=JSON.stringify([t,e]),r=Ft[n];return r||(r=new Intl.ListFormat(t,e),Ft[n]=r),r}var at=new Map;function lt(t,e={}){let n=JSON.stringify([t,e]),r=at.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(t,e),at.set(n,r)),r}var ut=new Map;function Pr(t,e={}){let n=JSON.stringify([t,e]),r=ut.get(n);return r===void 0&&(r=new Intl.NumberFormat(t,e),ut.set(n,r)),r}var ct=new Map;function $r(t,e={}){let{base:n,...r}=e,i=JSON.stringify([t,r]),s=ct.get(i);return s===void 0&&(s=new Intl.RelativeTimeFormat(t,e),ct.set(i,s)),s}var he=null;function Ur(){return he||(he=new Intl.DateTimeFormat().resolvedOptions().locale,he)}var ft=new Map;function Cn(t){let e=ft.get(t);return e===void 0&&(e=new Intl.DateTimeFormat(t).resolvedOptions(),ft.set(t,e)),e}var mt=new Map;function zr(t){let e=mt.get(t);if(!e){let n=new Intl.Locale(t);e="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in e||(e={...En,...e}),mt.set(t,e)}return e}function Br(t){let e=t.indexOf("-x-");e!==-1&&(t=t.substring(0,e));let n=t.indexOf("-u-");if(n===-1)return[t];{let r,i;try{r=lt(t).resolvedOptions(),i=t}catch{let l=t.substring(0,n);r=lt(l).resolvedOptions(),i=l}let{numberingSystem:s,calendar:o}=r;return[i,s,o]}}function Zr(t,e,n){return(n||e)&&(t.includes("-u-")||(t+="-u"),n&&(t+=`-ca-${n}`),e&&(t+=`-nu-${e}`)),t}function Yr(t){let e=[];for(let n=1;n<=12;n++){let r=S.utc(2009,n,1);e.push(t(r))}return e}function Hr(t){let e=[];for(let n=1;n<=7;n++){let r=S.utc(2016,11,13+n);e.push(t(r))}return e}function Oe(t,e,n,r){let i=t.listingMode();return i==="error"?null:i==="en"?n(e):r(e)}function _r(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||Cn(t.locale).numberingSystem==="latn"}var ht=class{constructor(e,n,r){this.padTo=r.padTo||0,this.floor=r.floor||!1;let{padTo:i,floor:s,...o}=r;if(!n||Object.keys(o).length>0){let a={useGrouping:!1,...r};r.padTo>0&&(a.minimumIntegerDigits=r.padTo),this.inf=Pr(e,a)}}format(e){if(this.inf){let n=this.floor?Math.floor(e):e;return this.inf.format(n)}else{let n=this.floor?Math.floor(e):Ot(e,3);return k(n,this.padTo)}}},dt=class{constructor(e,n,r){this.opts=r,this.originalZone=void 0;let i;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){let o=-1*(e.offset/60),a=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&_.create(a).valid?(i=a,this.dt=e):(i="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,i=e.zone.name):(i="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);let s={...this.opts};s.timeZone=s.timeZone||i,this.dtf=lt(n,s)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){let e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(n=>{if(n.type==="timeZoneName"){let r=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...n,value:r}}else return n}):e}resolvedOptions(){return this.dtf.resolvedOptions()}},yt=class{constructor(e,n,r){this.opts={style:"long",...r},!n&&Rn()&&(this.rtf=$r(e,r))}format(e,n){return this.rtf?this.rtf.format(e,n):hi(n,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,n){return this.rtf?this.rtf.formatToParts(e,n):[]}},En={firstDay:1,minimalDays:4,weekend:[6,7]},b=class t{static fromOpts(e){return t.create(e.locale,e.numberingSystem,e.outputCalendar,e.weekSettings,e.defaultToEN)}static create(e,n,r,i,s=!1){let o=e||T.defaultLocale,a=o||(s?"en-US":Ur()),l=n||T.defaultNumberingSystem,u=r||T.defaultOutputCalendar,c=pt(i)||T.defaultWeekSettings;return new t(a,l,u,c,o)}static resetCache(){he=null,at.clear(),ut.clear(),ct.clear(),ft.clear(),mt.clear()}static fromObject({locale:e,numberingSystem:n,outputCalendar:r,weekSettings:i}={}){return t.create(e,n,r,i)}constructor(e,n,r,i,s){let[o,a,l]=Br(e);this.locale=o,this.numberingSystem=n||a||null,this.outputCalendar=r||l||null,this.weekSettings=i,this.intl=Zr(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=s,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=_r(this)),this.fastNumbersCached}listingMode(){let e=this.isEnglish(),n=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&n?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:t.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,pt(e.weekSettings)||this.weekSettings,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,n=!1){return Oe(this,e,Bn,()=>{let r=this.intl==="ja"||this.intl.startsWith("ja-");n&=!r;let i=n?{month:e,day:"numeric"}:{month:e},s=n?"format":"standalone";if(!this.monthsCache[s][e]){let o=r?a=>this.dtFormatter(a,i).format():a=>this.extract(a,i,"month");this.monthsCache[s][e]=Yr(o)}return this.monthsCache[s][e]})}weekdays(e,n=!1){return Oe(this,e,Hn,()=>{let r=n?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},i=n?"format":"standalone";return this.weekdaysCache[i][e]||(this.weekdaysCache[i][e]=Hr(s=>this.extract(s,r,"weekday"))),this.weekdaysCache[i][e]})}meridiems(){return Oe(this,void 0,()=>_n,()=>{if(!this.meridiemCache){let e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[S.utc(2016,11,13,9),S.utc(2016,11,13,19)].map(n=>this.extract(n,e,"dayperiod"))}return this.meridiemCache})}eras(e){return Oe(this,e,qn,()=>{let n={era:e};return this.eraCache[e]||(this.eraCache[e]=[S.utc(-40,1,1),S.utc(2017,1,1)].map(r=>this.extract(r,n,"era"))),this.eraCache[e]})}extract(e,n,r){let i=this.dtFormatter(e,n),s=i.formatToParts(),o=s.find(a=>a.type.toLowerCase()===r);return o?o.value:null}numberFormatter(e={}){return new ht(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,n={}){return new dt(e,this.intl,n)}relFormatter(e={}){return new yt(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Rr(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||Cn(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:Pn()?zr(this.locale):En}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}},je=null,A=class t extends j{static get utcInstance(){return je===null&&(je=new t(0)),je}static instance(e){return e===0?t.utcInstance:new t(e)}static parseSpecifier(e){if(e){let n=e.match(/^utc(?:([+-]\\d{1,2})(?::(\\d{2}))?)?$/i);if(n)return new t(ze(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${ge(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${ge(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,n){return ge(this.fixed,n)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}},gt=class extends j{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}};function Z(t,e){if(g(t)||t===null)return e;if(t instanceof j)return t;if(Kr(t)){let n=t.toLowerCase();return n==="default"?e:n==="local"||n==="system"?We.instance:n==="utc"||n==="gmt"?A.utcInstance:A.parseSpecifier(n)||_.create(t)}else return H(t)?A.instance(t):typeof t=="object"&&"offset"in t&&typeof t.offset=="function"?t:new gt(t)}var Tt={arab:"[\\u0660-\\u0669]",arabext:"[\\u06F0-\\u06F9]",bali:"[\\u1B50-\\u1B59]",beng:"[\\u09E6-\\u09EF]",deva:"[\\u0966-\\u096F]",fullwide:"[\\uFF10-\\uFF19]",gujr:"[\\u0AE6-\\u0AEF]",hanidec:"[\\u3007|\\u4E00|\\u4E8C|\\u4E09|\\u56DB|\\u4E94|\\u516D|\\u4E03|\\u516B|\\u4E5D]",khmr:"[\\u17E0-\\u17E9]",knda:"[\\u0CE6-\\u0CEF]",laoo:"[\\u0ED0-\\u0ED9]",limb:"[\\u1946-\\u194F]",mlym:"[\\u0D66-\\u0D6F]",mong:"[\\u1810-\\u1819]",mymr:"[\\u1040-\\u1049]",orya:"[\\u0B66-\\u0B6F]",tamldec:"[\\u0BE6-\\u0BEF]",telu:"[\\u0C66-\\u0C6F]",thai:"[\\u0E50-\\u0E59]",tibt:"[\\u0F20-\\u0F29]",latn:"\\\\d"},Wt={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},qr=Tt.hanidec.replace(/[\\[|\\]]/g,"").split("");function Gr(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);if(t[n].search(Tt.hanidec)!==-1)e+=qr.indexOf(t[n]);else for(let i in Wt){let[s,o]=Wt[i];r>=s&&r<=o&&(e+=r-s)}}return parseInt(e,10)}else return e}var wt=new Map;function Jr(){wt.clear()}function W({numberingSystem:t},e=""){let n=t||"latn",r=wt.get(n);r===void 0&&(r=new Map,wt.set(n,r));let i=r.get(e);return i===void 0&&(i=new RegExp(`${Tt[n]}${e}`),r.set(e,i)),i}var Lt=()=>Date.now(),Vt="system",Rt=null,Pt=null,$t=null,Ut=60,zt,Bt=null,T=class{static get now(){return Lt}static set now(e){Lt=e}static set defaultZone(e){Vt=e}static get defaultZone(){return Z(Vt,We.instance)}static get defaultLocale(){return Rt}static set defaultLocale(e){Rt=e}static get defaultNumberingSystem(){return Pt}static set defaultNumberingSystem(e){Pt=e}static get defaultOutputCalendar(){return $t}static set defaultOutputCalendar(e){$t=e}static get defaultWeekSettings(){return Bt}static set defaultWeekSettings(e){Bt=pt(e)}static get twoDigitCutoffYear(){return Ut}static set twoDigitCutoffYear(e){Ut=e%100}static get throwOnInvalid(){return zt}static set throwOnInvalid(e){zt=e}static resetCaches(){b.resetCache(),_.resetCache(),S.resetCache(),Jr()}},v=class{constructor(e,n){this.reason=e,this.explanation=n}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},In=[0,31,59,90,120,151,181,212,243,273,304,334],An=[0,31,60,91,121,152,182,213,244,274,305,335];function E(t,e){return new v("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function kt(t,e,n){let r=new Date(Date.UTC(t,e-1,n));t<100&&t>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);let i=r.getUTCDay();return i===0?7:i}function Fn(t,e,n){return n+(pe(t)?An:In)[e-1]}function Wn(t,e){let n=pe(t)?An:In,r=n.findIndex(s=>s<e),i=e-n[r];return{month:r+1,day:i}}function xt(t,e){return(t-e+7)%7+1}function Le(t,e=4,n=1){let{year:r,month:i,day:s}=t,o=Fn(r,i,s),a=xt(kt(r,i,s),n),l=Math.floor((o-a+14-e)/7),u;return l<1?(u=r-1,l=we(u,e,n)):l>we(r,e,n)?(u=r+1,l=1):u=r,{weekYear:u,weekNumber:l,weekday:a,...Be(t)}}function Zt(t,e=4,n=1){let{weekYear:r,weekNumber:i,weekday:s}=t,o=xt(kt(r,1,e),n),a=ne(r),l=i*7+s-o-7+e,u;l<1?(u=r-1,l+=ne(u)):l>a?(u=r+1,l-=ne(r)):u=r;let{month:c,day:f}=Wn(u,l);return{year:u,month:c,day:f,...Be(t)}}function Xe(t){let{year:e,month:n,day:r}=t,i=Fn(e,n,r);return{year:e,ordinal:i,...Be(t)}}function Yt(t){let{year:e,ordinal:n}=t,{month:r,day:i}=Wn(e,n);return{year:e,month:r,day:i,...Be(t)}}function Ht(t,e){if(!g(t.localWeekday)||!g(t.localWeekNumber)||!g(t.localWeekYear)){if(!g(t.weekday)||!g(t.weekNumber)||!g(t.weekYear))throw new Y("Cannot mix locale-based week fields with ISO-based week fields");return g(t.localWeekday)||(t.weekday=t.localWeekday),g(t.localWeekNumber)||(t.weekNumber=t.localWeekNumber),g(t.localWeekYear)||(t.weekYear=t.localWeekYear),delete t.localWeekday,delete t.localWeekNumber,delete t.localWeekYear,{minDaysInFirstWeek:e.getMinDaysInFirstWeek(),startOfWeek:e.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function jr(t,e=4,n=1){let r=$e(t.weekYear),i=I(t.weekNumber,1,we(t.weekYear,e,n)),s=I(t.weekday,1,7);return r?i?s?!1:E("weekday",t.weekday):E("week",t.weekNumber):E("weekYear",t.weekYear)}function Xr(t){let e=$e(t.year),n=I(t.ordinal,1,ne(t.year));return e?n?!1:E("ordinal",t.ordinal):E("year",t.year)}function Ln(t){let e=$e(t.year),n=I(t.month,1,12),r=I(t.day,1,Ve(t.year,t.month));return e?n?r?!1:E("day",t.day):E("month",t.month):E("year",t.year)}function Vn(t){let{hour:e,minute:n,second:r,millisecond:i}=t,s=I(e,0,23)||e===24&&n===0&&r===0&&i===0,o=I(n,0,59),a=I(r,0,59),l=I(i,0,999);return s?o?a?l?!1:E("millisecond",i):E("second",r):E("minute",n):E("hour",e)}function g(t){return typeof t>"u"}function H(t){return typeof t=="number"}function $e(t){return typeof t=="number"&&t%1===0}function Kr(t){return typeof t=="string"}function Qr(t){return Object.prototype.toString.call(t)==="[object Date]"}function Rn(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Pn(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function ei(t){return Array.isArray(t)?t:[t]}function _t(t,e,n){if(t.length!==0)return t.reduce((r,i)=>{let s=[e(i),i];return r&&n(r[0],s[0])===r[0]?r:s},null)[1]}function ti(t,e){return e.reduce((n,r)=>(n[r]=t[r],n),{})}function se(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function pt(t){if(t==null)return null;if(typeof t!="object")throw new x("Week settings must be an object");if(!I(t.firstDay,1,7)||!I(t.minimalDays,1,7)||!Array.isArray(t.weekend)||t.weekend.some(e=>!I(e,1,7)))throw new x("Invalid week settings");return{firstDay:t.firstDay,minimalDays:t.minimalDays,weekend:Array.from(t.weekend)}}function I(t,e,n){return $e(t)&&t>=e&&t<=n}function ni(t,e){return t-e*Math.floor(t/e)}function k(t,e=2){let n=t<0,r;return n?r="-"+(""+-t).padStart(e,"0"):r=(""+t).padStart(e,"0"),r}function B(t){if(!(g(t)||t===null||t===""))return parseInt(t,10)}function q(t){if(!(g(t)||t===null||t===""))return parseFloat(t)}function Dt(t){if(!(g(t)||t===null||t==="")){let e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function Ot(t,e,n="round"){let r=10**e;switch(n){case"expand":return t>0?Math.ceil(t*r)/r:Math.floor(t*r)/r;case"trunc":return Math.trunc(t*r)/r;case"round":return Math.round(t*r)/r;case"floor":return Math.floor(t*r)/r;case"ceil":return Math.ceil(t*r)/r;default:throw new RangeError(`Value rounding ${n} is out of range`)}}function pe(t){return t%4===0&&(t%100!==0||t%400===0)}function ne(t){return pe(t)?366:365}function Ve(t,e){let n=ni(e-1,12)+1,r=t+(e-n)/12;return n===2?pe(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function Ue(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(t.year,t.month-1,t.day)),+e}function qt(t,e,n){return-xt(kt(t,1,e),n)+e-1}function we(t,e=4,n=1){let r=qt(t,e,n),i=qt(t+1,e,n);return(ne(t)-r+i)/7}function bt(t){return t>99?t:t>T.twoDigitCutoffYear?1900+t:2e3+t}function $n(t,e,n,r=null){let i=new Date(t),s={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};r&&(s.timeZone=r);let o={timeZoneName:e,...s},a=new Intl.DateTimeFormat(n,o).formatToParts(i).find(l=>l.type.toLowerCase()==="timezonename");return a?a.value:null}function ze(t,e){let n=parseInt(t,10);Number.isNaN(n)&&(n=0);let r=parseInt(e,10)||0,i=n<0||Object.is(n,-0)?-r:r;return n*60+i}function Un(t){let e=Number(t);if(typeof t=="boolean"||t===""||!Number.isFinite(e))throw new x(`Invalid unit value ${t}`);return e}function Re(t,e){let n={};for(let r in t)if(se(t,r)){let i=t[r];if(i==null)continue;n[e(r)]=Un(i)}return n}function ge(t,e){let n=Math.trunc(Math.abs(t/60)),r=Math.trunc(Math.abs(t%60)),i=t>=0?"+":"-";switch(e){case"short":return`${i}${k(n,2)}:${k(r,2)}`;case"narrow":return`${i}${n}${r>0?`:${r}`:""}`;case"techie":return`${i}${k(n,2)}${k(r,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function Be(t){return ti(t,["hour","minute","second","millisecond"])}var ri=["January","February","March","April","May","June","July","August","September","October","November","December"],zn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ii=["J","F","M","A","M","J","J","A","S","O","N","D"];function Bn(t){switch(t){case"narrow":return[...ii];case"short":return[...zn];case"long":return[...ri];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}var Zn=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Yn=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],si=["M","T","W","T","F","S","S"];function Hn(t){switch(t){case"narrow":return[...si];case"short":return[...Yn];case"long":return[...Zn];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}var _n=["AM","PM"],oi=["Before Christ","Anno Domini"],ai=["BC","AD"],li=["B","A"];function qn(t){switch(t){case"narrow":return[...li];case"short":return[...ai];case"long":return[...oi];default:return null}}function ui(t){return _n[t.hour<12?0:1]}function ci(t,e){return Hn(e)[t.weekday-1]}function fi(t,e){return Bn(e)[t.month-1]}function mi(t,e){return qn(e)[t.year<0?0:1]}function hi(t,e,n="always",r=!1){let i={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},s=["hours","minutes","seconds"].indexOf(t)===-1;if(n==="auto"&&s){let f=t==="days";switch(e){case 1:return f?"tomorrow":`next ${i[t][0]}`;case-1:return f?"yesterday":`last ${i[t][0]}`;case 0:return f?"today":`this ${i[t][0]}`}}let o=Object.is(e,-0)||e<0,a=Math.abs(e),l=a===1,u=i[t],c=r?l?u[1]:u[2]||u[1]:l?i[t][0]:t;return o?`${a} ${c} ago`:`in ${a} ${c}`}function Gt(t,e){let n="";for(let r of t)r.literal?n+=r.val:n+=e(r.val);return n}var di={D:Fe,DD:cn,DDD:fn,DDDD:mn,t:hn,tt:dn,ttt:yn,tttt:gn,T:wn,TT:pn,TTT:bn,TTTT:Sn,f:Tn,ff:xn,fff:On,ffff:vn,F:kn,FF:Dn,FFF:Nn,FFFF:Mn},N=class t{static create(e,n={}){return new t(e,n)}static parseFormat(e){let n=null,r="",i=!1,s=[];for(let o=0;o<e.length;o++){let a=e.charAt(o);a==="\'"?((r.length>0||i)&&s.push({literal:i||/^\\s+$/.test(r),val:r===""?"\'":r}),n=null,r="",i=!i):i||a===n?r+=a:(r.length>0&&s.push({literal:/^\\s+$/.test(r),val:r}),r=a,n=a)}return r.length>0&&s.push({literal:i||/^\\s+$/.test(r),val:r}),s}static macroTokenToFormatOpts(e){return di[e]}constructor(e,n){this.opts=n,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,n){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...n}).format()}dtFormatter(e,n={}){return this.loc.dtFormatter(e,{...this.opts,...n})}formatDateTime(e,n){return this.dtFormatter(e,n).format()}formatDateTimeParts(e,n){return this.dtFormatter(e,n).formatToParts()}formatInterval(e,n){return this.dtFormatter(e.start,n).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,n){return this.dtFormatter(e,n).resolvedOptions()}num(e,n=0,r=void 0){if(this.opts.forceSimple)return k(e,n);let i={...this.opts};return n>0&&(i.padTo=n),r&&(i.signDisplay=r),this.loc.numberFormatter(i).format(e)}formatDateTimeFromString(e,n){let r=this.loc.listingMode()==="en",i=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",s=(m,y)=>this.loc.extract(e,m,y),o=m=>e.isOffsetFixed&&e.offset===0&&m.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,m.format):"",a=()=>r?ui(e):s({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(m,y)=>r?fi(e,m):s(y?{month:m}:{month:m,day:"numeric"},"month"),u=(m,y)=>r?ci(e,m):s(y?{weekday:m}:{weekday:m,month:"long",day:"numeric"},"weekday"),c=m=>{let y=t.macroTokenToFormatOpts(m);return y?this.formatWithSystemDefault(e,y):m},f=m=>r?mi(e,m):s({era:m},"era"),d=m=>{switch(m){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return a();case"d":return i?s({day:"numeric"},"day"):this.num(e.day);case"dd":return i?s({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return i?s({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return i?s({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("narrow",!0);case"M":return i?s({month:"numeric"},"month"):this.num(e.month);case"MM":return i?s({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("narrow",!1);case"y":return i?s({year:"numeric"},"year"):this.num(e.year);case"yy":return i?s({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return i?s({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return i?s({year:"numeric"},"year"):this.num(e.year,6);case"G":return f("short");case"GG":return f("long");case"GGGGG":return f("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"n":return this.num(e.localWeekNumber);case"nn":return this.num(e.localWeekNumber,2);case"ii":return this.num(e.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(e.localWeekYear,4);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return c(m)}};return Gt(t.parseFormat(n),d)}formatDurationFromString(e,n){let r=this.opts.signMode==="negativeLargestOnly"?-1:1,i=c=>{switch(c[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},s=(c,f)=>d=>{let m=i(d);if(m){let y=f.isNegativeDuration&&m!==f.largestUnit?r:1,p;return this.opts.signMode==="negativeLargestOnly"&&m!==f.largestUnit?p="never":this.opts.signMode==="all"?p="always":p="auto",this.num(c.get(m)*y,d.length,p)}else return d},o=t.parseFormat(n),a=o.reduce((c,{literal:f,val:d})=>f?c:c.concat(d),[]),l=e.shiftTo(...a.map(i).filter(c=>c)),u={isNegativeDuration:l<0,largestUnit:Object.keys(l.values)[0]};return Gt(o,s(l,u))}},Gn=/[A-Za-z_+-]{1,256}(?::?\\/[A-Za-z0-9_+-]{1,256}(?:\\/[A-Za-z0-9_+-]{1,256})?)?/;function oe(...t){let e=t.reduce((n,r)=>n+r.source,"");return RegExp(`^${e}$`)}function ae(...t){return e=>t.reduce(([n,r,i],s)=>{let[o,a,l]=s(e,i);return[{...n,...o},a||r,l]},[{},null,1]).slice(0,2)}function le(t,...e){if(t==null)return[null,null];for(let[n,r]of e){let i=n.exec(t);if(i)return r(i)}return[null,null]}function Jn(...t){return(e,n)=>{let r={},i;for(i=0;i<t.length;i++)r[t[i]]=B(e[n+i]);return[r,null,n+i]}}var jn=/(?:([Zz])|([+-]\\d\\d)(?::?(\\d\\d))?)/,yi=`(?:${jn.source}?(?:\\\\[(${Gn.source})\\\\])?)?`,Nt=/(\\d\\d)(?::?(\\d\\d)(?::?(\\d\\d)(?:[.,](\\d{1,30}))?)?)?/,Xn=RegExp(`${Nt.source}${yi}`),vt=RegExp(`(?:[Tt]${Xn.source})?`),gi=/([+-]\\d{6}|\\d{4})(?:-?(\\d\\d)(?:-?(\\d\\d))?)?/,wi=/(\\d{4})-?W(\\d\\d)(?:-?(\\d))?/,pi=/(\\d{4})-?(\\d{3})/,bi=Jn("weekYear","weekNumber","weekDay"),Si=Jn("year","ordinal"),Ti=/(\\d{4})-(\\d\\d)-(\\d\\d)/,Kn=RegExp(`${Nt.source} ?(?:${jn.source}|(${Gn.source}))?`),ki=RegExp(`(?: ${Kn.source})?`);function re(t,e,n){let r=t[e];return g(r)?n:B(r)}function xi(t,e){return[{year:re(t,e),month:re(t,e+1,1),day:re(t,e+2,1)},null,e+3]}function ue(t,e){return[{hours:re(t,e,0),minutes:re(t,e+1,0),seconds:re(t,e+2,0),milliseconds:Dt(t[e+3])},null,e+4]}function be(t,e){let n=!t[e]&&!t[e+1],r=ze(t[e+1],t[e+2]),i=n?null:A.instance(r);return[{},i,e+3]}function Se(t,e){let n=t[e]?_.create(t[e]):null;return[{},n,e+1]}var Di=RegExp(`^T?${Nt.source}$`),Oi=/^-?P(?:(?:(-?\\d{1,20}(?:\\.\\d{1,20})?)Y)?(?:(-?\\d{1,20}(?:\\.\\d{1,20})?)M)?(?:(-?\\d{1,20}(?:\\.\\d{1,20})?)W)?(?:(-?\\d{1,20}(?:\\.\\d{1,20})?)D)?(?:T(?:(-?\\d{1,20}(?:\\.\\d{1,20})?)H)?(?:(-?\\d{1,20}(?:\\.\\d{1,20})?)M)?(?:(-?\\d{1,20})(?:[.,](-?\\d{1,20}))?S)?)?)$/;function Ni(t){let[e,n,r,i,s,o,a,l,u]=t,c=e[0]==="-",f=l&&l[0]==="-",d=(m,y=!1)=>m!==void 0&&(y||m&&c)?-m:m;return[{years:d(q(n)),months:d(q(r)),weeks:d(q(i)),days:d(q(s)),hours:d(q(o)),minutes:d(q(a)),seconds:d(q(l),l==="-0"),milliseconds:d(Dt(u),f)}]}var vi={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Mt(t,e,n,r,i,s,o){let a={year:e.length===2?bt(B(e)):B(e),month:zn.indexOf(n)+1,day:B(r),hour:B(i),minute:B(s)};return o&&(a.second=B(o)),t&&(a.weekday=t.length>3?Zn.indexOf(t)+1:Yn.indexOf(t)+1),a}var Mi=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s)?(\\d{1,2})\\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\s(\\d{2,4})\\s(\\d\\d):(\\d\\d)(?::(\\d\\d))?\\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\\d\\d)(\\d\\d)))$/;function Ci(t){let[,e,n,r,i,s,o,a,l,u,c,f]=t,d=Mt(e,i,r,n,s,o,a),m;return l?m=vi[l]:u?m=0:m=ze(c,f),[d,new A(m)]}function Ei(t){return t.replace(/\\([^()]*\\)|[\\n\\t]/g," ").replace(/(\\s\\s+)/g," ").trim()}var Ii=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\\d\\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\\d{4}) (\\d\\d):(\\d\\d):(\\d\\d) GMT$/,Ai=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\\d\\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\\d\\d) (\\d\\d):(\\d\\d):(\\d\\d) GMT$/,Fi=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \\d|\\d\\d) (\\d\\d):(\\d\\d):(\\d\\d) (\\d{4})$/;function Jt(t){let[,e,n,r,i,s,o,a]=t;return[Mt(e,i,r,n,s,o,a),A.utcInstance]}function Wi(t){let[,e,n,r,i,s,o,a]=t;return[Mt(e,a,n,r,i,s,o),A.utcInstance]}var Li=oe(gi,vt),Vi=oe(wi,vt),Ri=oe(pi,vt),Pi=oe(Xn),Qn=ae(xi,ue,be,Se),$i=ae(bi,ue,be,Se),Ui=ae(Si,ue,be,Se),zi=ae(ue,be,Se);function Bi(t){return le(t,[Li,Qn],[Vi,$i],[Ri,Ui],[Pi,zi])}function Zi(t){return le(Ei(t),[Mi,Ci])}function Yi(t){return le(t,[Ii,Jt],[Ai,Jt],[Fi,Wi])}function Hi(t){return le(t,[Oi,Ni])}var _i=ae(ue);function qi(t){return le(t,[Di,_i])}var Gi=oe(Ti,ki),Ji=oe(Kn),ji=ae(ue,be,Se);function Xi(t){return le(t,[Gi,Qn],[Ji,ji])}var jt="Invalid Duration",er={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Ki={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...er},C=146097/400,K=146097/4800,Qi={years:{quarters:4,months:12,weeks:C/7,days:C,hours:C*24,minutes:C*24*60,seconds:C*24*60*60,milliseconds:C*24*60*60*1e3},quarters:{months:3,weeks:C/28,days:C/4,hours:C*24/4,minutes:C*24*60/4,seconds:C*24*60*60/4,milliseconds:C*24*60*60*1e3/4},months:{weeks:K/7,days:K,hours:K*24,minutes:K*24*60,seconds:K*24*60*60,milliseconds:K*24*60*60*1e3},...er},J=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],es=J.slice(0).reverse();function U(t,e,n=!1){let r={values:n?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy,matrix:e.matrix||t.matrix};return new D(r)}function tr(t,e){let n=e.milliseconds??0;for(let r of es.slice(1))e[r]&&(n+=e[r]*t[r].milliseconds);return n}function Xt(t,e){let n=tr(t,e)<0?-1:1;J.reduceRight((r,i)=>{if(g(e[i]))return r;if(r){let s=e[r]*n,o=t[i][r],a=Math.floor(s/o);e[i]+=a*n,e[r]-=a*o*n}return i},null),J.reduce((r,i)=>{if(g(e[i]))return r;if(r){let s=e[r]%1;e[r]-=s,e[i]+=s*t[r][i]}return i},null)}function Kt(t){let e={};for(let[n,r]of Object.entries(t))r!==0&&(e[n]=r);return e}var D=class t{constructor(e){let n=e.conversionAccuracy==="longterm"||!1,r=n?Qi:Ki;e.matrix&&(r=e.matrix),this.values=e.values,this.loc=e.loc||b.create(),this.conversionAccuracy=n?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=r,this.isLuxonDuration=!0}static fromMillis(e,n){return t.fromObject({milliseconds:e},n)}static fromObject(e,n={}){if(e==null||typeof e!="object")throw new x(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new t({values:Re(e,t.normalizeUnit),loc:b.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(e){if(H(e))return t.fromMillis(e);if(t.isDuration(e))return e;if(typeof e=="object")return t.fromObject(e);throw new x(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,n){let[r]=Hi(e);return r?t.fromObject(r,n):t.invalid("unparsable",`the input "${e}" can\'t be parsed as ISO 8601`)}static fromISOTime(e,n){let[r]=qi(e);return r?t.fromObject(r,n):t.invalid("unparsable",`the input "${e}" can\'t be parsed as ISO 8601`)}static invalid(e,n=null){if(!e)throw new x("need to specify a reason the Duration is invalid");let r=e instanceof v?e:new v(e,n);if(T.throwOnInvalid)throw new st(r);return new t({invalid:r})}static normalizeUnit(e){let n={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!n)throw new Ae(e);return n}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,n={}){let r={...n,floor:n.round!==!1&&n.floor!==!1};return this.isValid?N.create(this.loc,r).formatDurationFromString(this,e):jt}toHuman(e={}){if(!this.isValid)return jt;let n=e.showZeros!==!1,r=J.map(i=>{let s=this.values[i];return g(s)||s===0&&!n?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:i.slice(0,-1)}).format(s)}).filter(i=>i);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(r)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=Ot(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;let n=this.toMillis();return n<0||n>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},S.fromMillis(n,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?tr(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;let n=t.fromDurationLike(e),r={};for(let i of J)(se(n.values,i)||se(this.values,i))&&(r[i]=n.get(i)+this.get(i));return U(this,{values:r},!0)}minus(e){if(!this.isValid)return this;let n=t.fromDurationLike(e);return this.plus(n.negate())}mapUnits(e){if(!this.isValid)return this;let n={};for(let r of Object.keys(this.values))n[r]=Un(e(this.values[r],r));return U(this,{values:n},!0)}get(e){return this[t.normalizeUnit(e)]}set(e){if(!this.isValid)return this;let n={...this.values,...Re(e,t.normalizeUnit)};return U(this,{values:n})}reconfigure({locale:e,numberingSystem:n,conversionAccuracy:r,matrix:i}={}){let o={loc:this.loc.clone({locale:e,numberingSystem:n}),matrix:i,conversionAccuracy:r};return U(this,o)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return Xt(this.matrix,e),U(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=Kt(this.normalize().shiftToAll().toObject());return U(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>t.normalizeUnit(o));let n={},r={},i=this.toObject(),s;for(let o of J)if(e.indexOf(o)>=0){s=o;let a=0;for(let u in r)a+=this.matrix[u][o]*r[u],r[u]=0;H(i[o])&&(a+=i[o]);let l=Math.trunc(a);n[o]=l,r[o]=(a*1e3-l*1e3)/1e3}else H(i[o])&&(r[o]=i[o]);for(let o in r)r[o]!==0&&(n[s]+=o===s?r[o]:r[o]/this.matrix[s][o]);return Xt(this.matrix,n),U(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;let e={};for(let n of Object.keys(this.values))e[n]=this.values[n]===0?0:-this.values[n];return U(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=Kt(this.values);return U(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function n(r,i){return r===void 0||r===0?i===void 0||i===0:r===i}for(let r of J)if(!n(this.values[r],e.values[r]))return!1;return!0}},Q="Invalid Interval";function ts(t,e){return!t||!t.isValid?ie.invalid("missing or invalid start"):!e||!e.isValid?ie.invalid("missing or invalid end"):e<t?ie.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}var ie=class t{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,n=null){if(!e)throw new x("need to specify a reason the Interval is invalid");let r=e instanceof v?e:new v(e,n);if(T.throwOnInvalid)throw new it(r);return new t({invalid:r})}static fromDateTimes(e,n){let r=me(e),i=me(n),s=ts(r,i);return s??new t({start:r,end:i})}static after(e,n){let r=D.fromDurationLike(n),i=me(e);return t.fromDateTimes(i,i.plus(r))}static before(e,n){let r=D.fromDurationLike(n),i=me(e);return t.fromDateTimes(i.minus(r),i)}static fromISO(e,n){let[r,i]=(e||"").split("/",2);if(r&&i){let s,o;try{s=S.fromISO(r,n),o=s.isValid}catch{o=!1}let a,l;try{a=S.fromISO(i,n),l=a.isValid}catch{l=!1}if(o&&l)return t.fromDateTimes(s,a);if(o){let u=D.fromISO(i,n);if(u.isValid)return t.after(s,u)}else if(l){let u=D.fromISO(r,n);if(u.isValid)return t.before(a,u)}}return t.invalid("unparsable",`the input "${e}" can\'t be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds",n){if(!this.isValid)return NaN;let r=this.start.startOf(e,n),i;return n?.useLocaleWeeks?i=this.end.reconfigure({locale:r.locale}):i=this.end,i=i.startOf(e,n),Math.floor(i.diff(r,e).get(e))+(i.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:n}={}){return this.isValid?t.fromDateTimes(e||this.s,n||this.e):this}splitAt(...e){if(!this.isValid)return[];let n=e.map(me).filter(o=>this.contains(o)).sort((o,a)=>o.toMillis()-a.toMillis()),r=[],{s:i}=this,s=0;for(;i<this.e;){let o=n[s]||this.e,a=+o>+this.e?this.e:o;r.push(t.fromDateTimes(i,a)),i=a,s+=1}return r}splitBy(e){let n=D.fromDurationLike(e);if(!this.isValid||!n.isValid||n.as("milliseconds")===0)return[];let{s:r}=this,i=1,s,o=[];for(;r<this.e;){let a=this.start.plus(n.mapUnits(l=>l*i));s=+a>+this.e?this.e:a,o.push(t.fromDateTimes(r,s)),r=s,i+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;let n=this.s>e.s?this.s:e.s,r=this.e<e.e?this.e:e.e;return n>=r?null:t.fromDateTimes(n,r)}union(e){if(!this.isValid)return this;let n=this.s<e.s?this.s:e.s,r=this.e>e.e?this.e:e.e;return t.fromDateTimes(n,r)}static merge(e){let[n,r]=e.sort((i,s)=>i.s-s.s).reduce(([i,s],o)=>s?s.overlaps(o)||s.abutsStart(o)?[i,s.union(o)]:[i.concat([s]),o]:[i,o],[[],null]);return r&&n.push(r),n}static xor(e){let n=null,r=0,i=[],s=e.map(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),o=Array.prototype.concat(...s),a=o.sort((l,u)=>l.time-u.time);for(let l of a)r+=l.type==="s"?1:-1,r===1?n=l.time:(n&&+n!=+l.time&&i.push(t.fromDateTimes(n,l.time)),n=null);return t.merge(i)}difference(...e){return t.xor([this].concat(e)).map(n=>this.intersection(n)).filter(n=>n&&!n.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} \\u2013 ${this.e.toISO()})`:Q}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=Fe,n={}){return this.isValid?N.create(this.s.loc.clone(n),e).formatInterval(this):Q}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Q}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Q}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Q}toFormat(e,{separator:n=" \\u2013 "}={}){return this.isValid?`${this.s.toFormat(e)}${n}${this.e.toFormat(e)}`:Q}toDuration(e,n){return this.isValid?this.e.diff(this.s,e,n):D.invalid(this.invalidReason)}mapEndpoints(e){return t.fromDateTimes(e(this.s),e(this.e))}},te=class{static hasDST(e=T.defaultZone){let n=S.now().setZone(e).set({month:12});return!e.isUniversal&&n.offset!==n.set({month:6}).offset}static isValidIANAZone(e){return _.isValidZone(e)}static normalizeZone(e){return Z(e,T.defaultZone)}static getStartOfWeek({locale:e=null,locObj:n=null}={}){return(n||b.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:n=null}={}){return(n||b.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:n=null}={}){return(n||b.create(e)).getWeekendDays().slice()}static months(e="long",{locale:n=null,numberingSystem:r=null,locObj:i=null,outputCalendar:s="gregory"}={}){return(i||b.create(n,r,s)).months(e)}static monthsFormat(e="long",{locale:n=null,numberingSystem:r=null,locObj:i=null,outputCalendar:s="gregory"}={}){return(i||b.create(n,r,s)).months(e,!0)}static weekdays(e="long",{locale:n=null,numberingSystem:r=null,locObj:i=null}={}){return(i||b.create(n,r,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:n=null,numberingSystem:r=null,locObj:i=null}={}){return(i||b.create(n,r,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return b.create(e).meridiems()}static eras(e="short",{locale:n=null}={}){return b.create(n,null,"gregory").eras(e)}static features(){return{relative:Rn(),localeWeek:Pn()}}};function Qt(t,e){let n=i=>i.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(e)-n(t);return Math.floor(D.fromMillis(r).as("days"))}function ns(t,e,n){let r=[["years",(l,u)=>u.year-l.year],["quarters",(l,u)=>u.quarter-l.quarter+(u.year-l.year)*4],["months",(l,u)=>u.month-l.month+(u.year-l.year)*12],["weeks",(l,u)=>{let c=Qt(l,u);return(c-c%7)/7}],["days",Qt]],i={},s=t,o,a;for(let[l,u]of r)n.indexOf(l)>=0&&(o=l,i[l]=u(t,e),a=s.plus(i),a>e?(i[l]--,t=s.plus(i),t>e&&(a=t,i[l]--,t=s.plus(i))):t=a);return[t,i,a,o]}function rs(t,e,n,r){let[i,s,o,a]=ns(t,e,n),l=e-i,u=n.filter(f=>["hours","minutes","seconds","milliseconds"].indexOf(f)>=0);u.length===0&&(o<e&&(o=i.plus({[a]:1})),o!==i&&(s[a]=(s[a]||0)+l/(o-i)));let c=D.fromObject(s,r);return u.length>0?D.fromMillis(l,r).shiftTo(...u).plus(c):c}var is="missing Intl.DateTimeFormat.formatToParts support";function w(t,e=n=>n){return{regex:t,deser:([n])=>e(Gr(n))}}var ss="\\xA0",nr=`[ ${ss}]`,rr=new RegExp(nr,"g");function os(t){return t.replace(/\\./g,"\\\\.?").replace(rr,nr)}function en(t){return t.replace(/\\./g,"").replace(rr," ").toLowerCase()}function L(t,e){return t===null?null:{regex:RegExp(t.map(os).join("|")),deser:([n])=>t.findIndex(r=>en(n)===en(r))+e}}function tn(t,e){return{regex:t,deser:([,n,r])=>ze(n,r),groups:e}}function Ne(t){return{regex:t,deser:([e])=>e}}function as(t){return t.replace(/[\\-\\[\\]{}()*+?.,\\\\\\^$|#\\s]/g,"\\\\$&")}function ls(t,e){let n=W(e),r=W(e,"{2}"),i=W(e,"{3}"),s=W(e,"{4}"),o=W(e,"{6}"),a=W(e,"{1,2}"),l=W(e,"{1,3}"),u=W(e,"{1,6}"),c=W(e,"{1,9}"),f=W(e,"{2,4}"),d=W(e,"{4,6}"),m=O=>({regex:RegExp(as(O.val)),deser:([F])=>F,literal:!0}),p=(O=>{if(t.literal)return m(O);switch(O.val){case"G":return L(e.eras("short"),0);case"GG":return L(e.eras("long"),0);case"y":return w(u);case"yy":return w(f,bt);case"yyyy":return w(s);case"yyyyy":return w(d);case"yyyyyy":return w(o);case"M":return w(a);case"MM":return w(r);case"MMM":return L(e.months("short",!0),1);case"MMMM":return L(e.months("long",!0),1);case"L":return w(a);case"LL":return w(r);case"LLL":return L(e.months("short",!1),1);case"LLLL":return L(e.months("long",!1),1);case"d":return w(a);case"dd":return w(r);case"o":return w(l);case"ooo":return w(i);case"HH":return w(r);case"H":return w(a);case"hh":return w(r);case"h":return w(a);case"mm":return w(r);case"m":return w(a);case"q":return w(a);case"qq":return w(r);case"s":return w(a);case"ss":return w(r);case"S":return w(l);case"SSS":return w(i);case"u":return Ne(c);case"uu":return Ne(a);case"uuu":return w(n);case"a":return L(e.meridiems(),0);case"kkkk":return w(s);case"kk":return w(f,bt);case"W":return w(a);case"WW":return w(r);case"E":case"c":return w(n);case"EEE":return L(e.weekdays("short",!1),1);case"EEEE":return L(e.weekdays("long",!1),1);case"ccc":return L(e.weekdays("short",!0),1);case"cccc":return L(e.weekdays("long",!0),1);case"Z":case"ZZ":return tn(new RegExp(`([+-]${a.source})(?::(${r.source}))?`),2);case"ZZZ":return tn(new RegExp(`([+-]${a.source})(${r.source})?`),2);case"z":return Ne(/[a-z_+-/]{1,256}?/i);case" ":return Ne(/[^\\S\\n\\r]/);default:return m(O)}})(t)||{invalidReason:is};return p.token=t,p}var us={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function cs(t,e,n){let{type:r,value:i}=t;if(r==="literal"){let l=/^\\s+$/.test(i);return{literal:!l,val:l?" ":i}}let s=e[r],o=r;r==="hour"&&(e.hour12!=null?o=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?o="hour12":o="hour24":o=n.hour12?"hour12":"hour24");let a=us[o];if(typeof a=="object"&&(a=a[s]),a)return{literal:!1,val:a}}function fs(t){return[`^${t.map(n=>n.regex).reduce((n,r)=>`${n}(${r.source})`,"")}$`,t]}function ms(t,e,n){let r=t.match(e);if(r){let i={},s=1;for(let o in n)if(se(n,o)){let a=n[o],l=a.groups?a.groups+1:1;!a.literal&&a.token&&(i[a.token.val[0]]=a.deser(r.slice(s,s+l))),s+=l}return[r,i]}else return[r,{}]}function hs(t){let e=s=>{switch(s){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}},n=null,r;return g(t.z)||(n=_.create(t.z)),g(t.Z)||(n||(n=new A(t.Z)),r=t.Z),g(t.q)||(t.M=(t.q-1)*3+1),g(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),g(t.u)||(t.S=Dt(t.u)),[Object.keys(t).reduce((s,o)=>{let a=e(o);return a&&(s[a]=t[o]),s},{}),n,r]}var Ke=null;function ds(){return Ke||(Ke=S.fromMillis(1555555555555)),Ke}function ys(t,e){if(t.literal)return t;let n=N.macroTokenToFormatOpts(t.val),r=or(n,e);return r==null||r.includes(void 0)?t:r}function ir(t,e){return Array.prototype.concat(...t.map(n=>ys(n,e)))}var Pe=class{constructor(e,n){if(this.locale=e,this.format=n,this.tokens=ir(N.parseFormat(n),e),this.units=this.tokens.map(r=>ls(r,e)),this.disqualifyingUnit=this.units.find(r=>r.invalidReason),!this.disqualifyingUnit){let[r,i]=fs(this.units);this.regex=RegExp(r,"i"),this.handlers=i}}explainFromTokens(e){if(this.isValid){let[n,r]=ms(e,this.regex,this.handlers),[i,s,o]=r?hs(r):[null,null,void 0];if(se(r,"a")&&se(r,"H"))throw new Y("Can\'t include meridiem when specifying 24-hour format");return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:n,matches:r,result:i,zone:s,specificOffset:o}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}};function sr(t,e,n){return new Pe(t,n).explainFromTokens(e)}function gs(t,e,n){let{result:r,zone:i,specificOffset:s,invalidReason:o}=sr(t,e,n);return[r,i,s,o]}function or(t,e){if(!t)return null;let r=N.create(e,t).dtFormatter(ds()),i=r.formatToParts(),s=r.resolvedOptions();return i.map(o=>cs(o,t,s))}var Qe="Invalid DateTime",nn=864e13;function de(t){return new v("unsupported zone",`the zone "${t.name}" is not supported`)}function et(t){return t.weekData===null&&(t.weekData=Le(t.c)),t.weekData}function tt(t){return t.localWeekData===null&&(t.localWeekData=Le(t.c,t.loc.getMinDaysInFirstWeek(),t.loc.getStartOfWeek())),t.localWeekData}function G(t,e){let n={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new S({...n,...e,old:n})}function ar(t,e,n){let r=t-e*60*1e3,i=n.offset(r);if(e===i)return[r,e];r-=(i-e)*60*1e3;let s=n.offset(r);return i===s?[r,i]:[t-Math.min(i,s)*60*1e3,Math.max(i,s)]}function ve(t,e){t+=e*60*1e3;let n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function Ce(t,e,n){return ar(Ue(t),e,n)}function rn(t,e){let n=t.o,r=t.c.year+Math.trunc(e.years),i=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,s={...t.c,year:r,month:i,day:Math.min(t.c.day,Ve(r,i))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=D.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),a=Ue(s),[l,u]=ar(a,n,t.zone);return o!==0&&(l+=o,u=t.zone.offset(l)),{ts:l,o:u}}function ee(t,e,n,r,i,s){let{setZone:o,zone:a}=n;if(t&&Object.keys(t).length!==0||e){let l=e||a,u=S.fromObject(t,{...n,zone:l,specificOffset:s});return o?u:u.setZone(a)}else return S.invalid(new v("unparsable",`the input "${i}" can\'t be parsed as ${r}`))}function Me(t,e,n=!0){return t.isValid?N.create(b.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(t,e):null}function nt(t,e,n){let r=t.c.year>9999||t.c.year<0,i="";if(r&&t.c.year>=0&&(i+="+"),i+=k(t.c.year,r?6:4),n==="year")return i;if(e){if(i+="-",i+=k(t.c.month),n==="month")return i;i+="-"}else if(i+=k(t.c.month),n==="month")return i;return i+=k(t.c.day),i}function sn(t,e,n,r,i,s,o){let a=!n||t.c.millisecond!==0||t.c.second!==0,l="";switch(o){case"day":case"month":case"year":break;default:if(l+=k(t.c.hour),o==="hour")break;if(e){if(l+=":",l+=k(t.c.minute),o==="minute")break;a&&(l+=":",l+=k(t.c.second))}else{if(l+=k(t.c.minute),o==="minute")break;a&&(l+=k(t.c.second))}if(o==="second")break;a&&(!r||t.c.millisecond!==0)&&(l+=".",l+=k(t.c.millisecond,3))}return i&&(t.isOffsetFixed&&t.offset===0&&!s?l+="Z":t.o<0?(l+="-",l+=k(Math.trunc(-t.o/60)),l+=":",l+=k(Math.trunc(-t.o%60))):(l+="+",l+=k(Math.trunc(t.o/60)),l+=":",l+=k(Math.trunc(t.o%60)))),s&&(l+="["+t.zone.ianaName+"]"),l}var lr={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},ws={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},ps={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Ee=["year","month","day","hour","minute","second","millisecond"],bs=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Ss=["year","ordinal","hour","minute","second","millisecond"];function Ie(t){let e={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[t.toLowerCase()];if(!e)throw new Ae(t);return e}function on(t){switch(t.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return Ie(t)}}function Ts(t){if(ye===void 0&&(ye=T.now()),t.type!=="iana")return t.offset(ye);let e=t.name,n=St.get(e);return n===void 0&&(n=t.offset(ye),St.set(e,n)),n}function an(t,e){let n=Z(e.zone,T.defaultZone);if(!n.isValid)return S.invalid(de(n));let r=b.fromObject(e),i,s;if(g(t.year))i=T.now();else{for(let l of Ee)g(t[l])&&(t[l]=lr[l]);let o=Ln(t)||Vn(t);if(o)return S.invalid(o);let a=Ts(n);[i,s]=Ce(t,a,n)}return new S({ts:i,zone:n,loc:r,o:s})}function ln(t,e,n){let r=g(n.round)?!0:n.round,i=g(n.rounding)?"trunc":n.rounding,s=(a,l)=>(a=Ot(a,r||n.calendary?0:2,n.calendary?"round":i),e.loc.clone(n).relFormatter(n).format(a,l)),o=a=>n.calendary?e.hasSame(t,a)?0:e.startOf(a).diff(t.startOf(a),a).get(a):e.diff(t,a).get(a);if(n.unit)return s(o(n.unit),n.unit);for(let a of n.units){let l=o(a);if(Math.abs(l)>=1)return s(l,a)}return s(t>e?-0:0,n.units[n.units.length-1])}function un(t){let e={},n;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],n=Array.from(t).slice(0,t.length-1)):n=Array.from(t),[e,n]}var ye,St=new Map,S=class t{constructor(e){let n=e.zone||T.defaultZone,r=e.invalid||(Number.isNaN(e.ts)?new v("invalid input"):null)||(n.isValid?null:de(n));this.ts=g(e.ts)?T.now():e.ts;let i=null,s=null;if(!r)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(n))[i,s]=[e.old.c,e.old.o];else{let a=H(e.o)&&!e.old?e.o:n.offset(this.ts);i=ve(this.ts,a),r=Number.isNaN(i.year)?new v("invalid input"):null,i=r?null:i,s=r?null:a}this._zone=n,this.loc=e.loc||b.create(),this.invalid=r,this.weekData=null,this.localWeekData=null,this.c=i,this.o=s,this.isLuxonDateTime=!0}static now(){return new t({})}static local(){let[e,n]=un(arguments),[r,i,s,o,a,l,u]=n;return an({year:r,month:i,day:s,hour:o,minute:a,second:l,millisecond:u},e)}static utc(){let[e,n]=un(arguments),[r,i,s,o,a,l,u]=n;return e.zone=A.utcInstance,an({year:r,month:i,day:s,hour:o,minute:a,second:l,millisecond:u},e)}static fromJSDate(e,n={}){let r=Qr(e)?e.valueOf():NaN;if(Number.isNaN(r))return t.invalid("invalid input");let i=Z(n.zone,T.defaultZone);return i.isValid?new t({ts:r,zone:i,loc:b.fromObject(n)}):t.invalid(de(i))}static fromMillis(e,n={}){if(H(e))return e<-nn||e>nn?t.invalid("Timestamp out of range"):new t({ts:e,zone:Z(n.zone,T.defaultZone),loc:b.fromObject(n)});throw new x(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,n={}){if(H(e))return new t({ts:e*1e3,zone:Z(n.zone,T.defaultZone),loc:b.fromObject(n)});throw new x("fromSeconds requires a numerical input")}static fromObject(e,n={}){e=e||{};let r=Z(n.zone,T.defaultZone);if(!r.isValid)return t.invalid(de(r));let i=b.fromObject(n),s=Re(e,on),{minDaysInFirstWeek:o,startOfWeek:a}=Ht(s,i),l=T.now(),u=g(n.specificOffset)?r.offset(l):n.specificOffset,c=!g(s.ordinal),f=!g(s.year),d=!g(s.month)||!g(s.day),m=f||d,y=s.weekYear||s.weekNumber;if((m||c)&&y)throw new Y("Can\'t mix weekYear/weekNumber units with year/month/day or ordinals");if(d&&c)throw new Y("Can\'t mix ordinal dates with month/day");let p=y||s.weekday&&!m,O,F,R=ve(l,u);p?(O=bs,F=ws,R=Le(R,o,a)):c?(O=Ss,F=ps,R=Xe(R)):(O=Ee,F=lr);let P=!1;for(let fe of O){let Mr=s[fe];g(Mr)?P?s[fe]=F[fe]:s[fe]=R[fe]:P=!0}let Dr=p?jr(s,o,a):c?Xr(s):Ln(s),At=Dr||Vn(s);if(At)return t.invalid(At);let Or=p?Zt(s,o,a):c?Yt(s):s,[Nr,vr]=Ce(Or,u,r),ce=new t({ts:Nr,zone:r,o:vr,loc:i});return s.weekday&&m&&e.weekday!==ce.weekday?t.invalid("mismatched weekday",`you can\'t specify both a weekday of ${s.weekday} and a date of ${ce.toISO()}`):ce.isValid?ce:t.invalid(ce.invalid)}static fromISO(e,n={}){let[r,i]=Bi(e);return ee(r,i,n,"ISO 8601",e)}static fromRFC2822(e,n={}){let[r,i]=Zi(e);return ee(r,i,n,"RFC 2822",e)}static fromHTTP(e,n={}){let[r,i]=Yi(e);return ee(r,i,n,"HTTP",n)}static fromFormat(e,n,r={}){if(g(e)||g(n))throw new x("fromFormat requires an input string and a format");let{locale:i=null,numberingSystem:s=null}=r,o=b.fromOpts({locale:i,numberingSystem:s,defaultToEN:!0}),[a,l,u,c]=gs(o,e,n);return c?t.invalid(c):ee(a,l,r,`format ${n}`,e,u)}static fromString(e,n,r={}){return t.fromFormat(e,n,r)}static fromSQL(e,n={}){let[r,i]=Xi(e);return ee(r,i,n,"SQL",e)}static invalid(e,n=null){if(!e)throw new x("need to specify a reason the DateTime is invalid");let r=e instanceof v?e:new v(e,n);if(T.throwOnInvalid)throw new rt(r);return new t({invalid:r})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,n={}){let r=or(e,b.fromObject(n));return r?r.map(i=>i?i.val:null).join(""):null}static expandFormat(e,n={}){return ir(N.parseFormat(e),b.fromObject(n)).map(i=>i.val).join("")}static resetCache(){ye=void 0,St.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?et(this).weekYear:NaN}get weekNumber(){return this.isValid?et(this).weekNumber:NaN}get weekday(){return this.isValid?et(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?tt(this).weekday:NaN}get localWeekNumber(){return this.isValid?tt(this).weekNumber:NaN}get localWeekYear(){return this.isValid?tt(this).weekYear:NaN}get ordinal(){return this.isValid?Xe(this.c).ordinal:NaN}get monthShort(){return this.isValid?te.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?te.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?te.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?te.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];let e=864e5,n=6e4,r=Ue(this.c),i=this.zone.offset(r-e),s=this.zone.offset(r+e),o=this.zone.offset(r-i*n),a=this.zone.offset(r-s*n);if(o===a)return[this];let l=r-o*n,u=r-a*n,c=ve(l,o),f=ve(u,a);return c.hour===f.hour&&c.minute===f.minute&&c.second===f.second&&c.millisecond===f.millisecond?[G(this,{ts:l}),G(this,{ts:u})]:[this]}get isInLeapYear(){return pe(this.year)}get daysInMonth(){return Ve(this.year,this.month)}get daysInYear(){return this.isValid?ne(this.year):NaN}get weeksInWeekYear(){return this.isValid?we(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?we(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:n,numberingSystem:r,calendar:i}=N.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:n,numberingSystem:r,outputCalendar:i}}toUTC(e=0,n={}){return this.setZone(A.instance(e),n)}toLocal(){return this.setZone(T.defaultZone)}setZone(e,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(e=Z(e,T.defaultZone),e.equals(this.zone))return this;if(e.isValid){let i=this.ts;if(n||r){let s=e.offset(this.ts),o=this.toObject();[i]=Ce(o,s,e)}return G(this,{ts:i,zone:e})}else return t.invalid(de(e))}reconfigure({locale:e,numberingSystem:n,outputCalendar:r}={}){let i=this.loc.clone({locale:e,numberingSystem:n,outputCalendar:r});return G(this,{loc:i})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let n=Re(e,on),{minDaysInFirstWeek:r,startOfWeek:i}=Ht(n,this.loc),s=!g(n.weekYear)||!g(n.weekNumber)||!g(n.weekday),o=!g(n.ordinal),a=!g(n.year),l=!g(n.month)||!g(n.day),u=a||l,c=n.weekYear||n.weekNumber;if((u||o)&&c)throw new Y("Can\'t mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&o)throw new Y("Can\'t mix ordinal dates with month/day");let f;s?f=Zt({...Le(this.c,r,i),...n},r,i):g(n.ordinal)?(f={...this.toObject(),...n},g(n.day)&&(f.day=Math.min(Ve(f.year,f.month),f.day))):f=Yt({...Xe(this.c),...n});let[d,m]=Ce(f,this.o,this.zone);return G(this,{ts:d,o:m})}plus(e){if(!this.isValid)return this;let n=D.fromDurationLike(e);return G(this,rn(this,n))}minus(e){if(!this.isValid)return this;let n=D.fromDurationLike(e).negate();return G(this,rn(this,n))}startOf(e,{useLocaleWeeks:n=!1}={}){if(!this.isValid)return this;let r={},i=D.normalizeUnit(e);switch(i){case"years":r.month=1;case"quarters":case"months":r.day=1;case"weeks":case"days":r.hour=0;case"hours":r.minute=0;case"minutes":r.second=0;case"seconds":r.millisecond=0;break}if(i==="weeks")if(n){let s=this.loc.getStartOfWeek(),{weekday:o}=this;o<s&&(r.weekNumber=this.weekNumber-1),r.weekday=s}else r.weekday=1;if(i==="quarters"){let s=Math.ceil(this.month/3);r.month=(s-1)*3+1}return this.set(r)}endOf(e,n){return this.isValid?this.plus({[e]:1}).startOf(e,n).minus(1):this}toFormat(e,n={}){return this.isValid?N.create(this.loc.redefaultToEN(n)).formatDateTimeFromString(this,e):Qe}toLocaleString(e=Fe,n={}){return this.isValid?N.create(this.loc.clone(n),e).formatDateTime(this):Qe}toLocaleParts(e={}){return this.isValid?N.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:n=!1,suppressMilliseconds:r=!1,includeOffset:i=!0,extendedZone:s=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=Ie(o);let a=e==="extended",l=nt(this,a,o);return Ee.indexOf(o)>=3&&(l+="T"),l+=sn(this,a,n,r,i,s,o),l}toISODate({format:e="extended",precision:n="day"}={}){return this.isValid?nt(this,e==="extended",Ie(n)):null}toISOWeekDate(){return Me(this,"kkkk-\'W\'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:n=!1,includeOffset:r=!0,includePrefix:i=!1,extendedZone:s=!1,format:o="extended",precision:a="milliseconds"}={}){return this.isValid?(a=Ie(a),(i&&Ee.indexOf(a)>=3?"T":"")+sn(this,o==="extended",n,e,r,s,a)):null}toRFC2822(){return Me(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return Me(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss \'GMT\'")}toSQLDate(){return this.isValid?nt(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:n=!1,includeOffsetSpace:r=!0}={}){let i="HH:mm:ss.SSS";return(n||e)&&(r&&(i+=" "),n?i+="z":e&&(i+="ZZ")),Me(this,i,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Qe}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};let n={...this.c};return e.includeConfig&&(n.outputCalendar=this.outputCalendar,n.numberingSystem=this.loc.numberingSystem,n.locale=this.loc.locale),n}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,n="milliseconds",r={}){if(!this.isValid||!e.isValid)return D.invalid("created by diffing an invalid DateTime");let i={locale:this.locale,numberingSystem:this.numberingSystem,...r},s=ei(n).map(D.normalizeUnit),o=e.valueOf()>this.valueOf(),a=o?this:e,l=o?e:this,u=rs(a,l,s,i);return o?u.negate():u}diffNow(e="milliseconds",n={}){return this.diff(t.now(),e,n)}until(e){return this.isValid?ie.fromDateTimes(this,e):this}hasSame(e,n,r){if(!this.isValid)return!1;let i=e.valueOf(),s=this.setZone(e.zone,{keepLocalTime:!0});return s.startOf(n,r)<=i&&i<=s.endOf(n,r)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;let n=e.base||t.fromObject({},{zone:this.zone}),r=e.padding?this<n?-e.padding:e.padding:0,i=["years","months","days","hours","minutes","seconds"],s=e.unit;return Array.isArray(e.unit)&&(i=e.unit,s=void 0),ln(n,this.plus(r),{...e,numeric:"always",units:i,unit:s})}toRelativeCalendar(e={}){return this.isValid?ln(e.base||t.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(t.isDateTime))throw new x("min requires all arguments be DateTimes");return _t(e,n=>n.valueOf(),Math.min)}static max(...e){if(!e.every(t.isDateTime))throw new x("max requires all arguments be DateTimes");return _t(e,n=>n.valueOf(),Math.max)}static fromFormatExplain(e,n,r={}){let{locale:i=null,numberingSystem:s=null}=r,o=b.fromOpts({locale:i,numberingSystem:s,defaultToEN:!0});return sr(o,e,n)}static fromStringExplain(e,n,r={}){return t.fromFormatExplain(e,n,r)}static buildFormatParser(e,n={}){let{locale:r=null,numberingSystem:i=null}=n,s=b.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0});return new Pe(s,e)}static fromFormatParser(e,n,r={}){if(g(e)||g(n))throw new x("fromFormatParser requires an input string and a format parser");let{locale:i=null,numberingSystem:s=null}=r,o=b.fromOpts({locale:i,numberingSystem:s,defaultToEN:!0});if(!o.equals(n.locale))throw new x(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${n.locale}`);let{result:a,zone:l,specificOffset:u,invalidReason:c}=n.explainFromTokens(e);return c?t.invalid(c):ee(a,l,r,`format ${n.format}`,e,u)}static get DATE_SHORT(){return Fe}static get DATE_MED(){return cn}static get DATE_MED_WITH_WEEKDAY(){return Ir}static get DATE_FULL(){return fn}static get DATE_HUGE(){return mn}static get TIME_SIMPLE(){return hn}static get TIME_WITH_SECONDS(){return dn}static get TIME_WITH_SHORT_OFFSET(){return yn}static get TIME_WITH_LONG_OFFSET(){return gn}static get TIME_24_SIMPLE(){return wn}static get TIME_24_WITH_SECONDS(){return pn}static get TIME_24_WITH_SHORT_OFFSET(){return bn}static get TIME_24_WITH_LONG_OFFSET(){return Sn}static get DATETIME_SHORT(){return Tn}static get DATETIME_SHORT_WITH_SECONDS(){return kn}static get DATETIME_MED(){return xn}static get DATETIME_MED_WITH_SECONDS(){return Dn}static get DATETIME_MED_WITH_WEEKDAY(){return Ar}static get DATETIME_FULL(){return On}static get DATETIME_FULL_WITH_SECONDS(){return Nn}static get DATETIME_HUGE(){return vn}static get DATETIME_HUGE_WITH_SECONDS(){return Mn}};function me(t){if(S.isDateTime(t))return t;if(t&&t.valueOf&&H(t.valueOf()))return S.fromJSDate(t);if(t&&typeof t=="object")return S.fromObject(t);throw new x(`Unknown datetime argument: ${t}, of type ${typeof t}`)}function X(t,e){return t.length?typeof t[0]=="number"?t:t.map(e??(n=>n.close)):[]}function Ze(t,e,n){let r=X(t,n),i=new Array(r.length),s=0,o=0;for(let a=0;a<r.length;a++){let l=r[a];if(isNaN(l)||(s+=l,o++),a>=e){let u=r[a-e];isNaN(u)||(s-=u,o--)}i[a]=o>=e?s/e:NaN}return i}function Te(t,e,n){let r=X(t,n),i=2/(e+1),s=new Array(r.length),o=NaN;for(let a=0;a<r.length;a++){let l=r[a];o=isNaN(o)?l:l*i+o*(1-i),s[a]=o}return s}function Ye(t,e,n){let r=X(t,n),i=new Array(r.length).fill(NaN),s=e*(e+1)/2;for(let o=e-1;o<r.length;o++){let a=0;for(let l=0;l<e;l++)a+=r[o-l]*(e-l);i[o]=a/s}return i}function ks(t,e,n){let r=X(t,n),i=Math.floor(e/2),s=Math.round(Math.sqrt(e)),o=Ye(r,i),a=Ye(r,e),l=r.map((u,c)=>2*o[c]-a[c]);return Ye(l,s)}function He(t,e,n){let r=X(t,n),i=new Array(r.length).fill(NaN),s=NaN;for(let o=0;o<r.length;o++){let a=r[o];if(isNaN(s)){if(o<e-1)continue;let l=0;for(let u=o-e+1;u<=o;u++)l+=r[u];s=l/e,i[o]=s}else s=(s*(e-1)+a)/e,i[o]=s}return i}function xs(t,e,n){let r=X(t,n),i=new Array(r.length).fill(NaN);for(let s=e-1;s<r.length;s++){let o=0,a=0,l=0,u=0;for(let d=0;d<e;d++){let m=d,y=r[s-(e-1-d)];o+=m,a+=y,l+=m*y,u+=m*m}let c=e,f=(c*l-o*a)/(c*u-o*o);i[s]=(a-f*o)/c+f*(e-1)}return i}function Ds(t,e=14){let n=t.length;if(n===0)return[];let r=new Array(n),i=new Array(n);r[0]=0,i[0]=0;for(let l=1;l<n;l++){let u=t[l].close-t[l-1].close;r[l]=u>0?u:0,i[l]=u<0?-u:0}let s=He(r,e),o=He(i,e),a=new Array(n);for(let l=0;l<n;l++)a[l]=isNaN(s[l])?NaN:o[l]===0?100:100-100/(1+s[l]/o[l]);return a}function Os(t,e=14,n=3,r=3){function i(c,f){let d=new Array(c.length).fill(NaN),m=0,y=0;for(let p=0;p<c.length;p++)isNaN(c[p])||(m+=c[p],y++),p>=f&&!isNaN(c[p-f])&&(m-=c[p-f],y--),d[p]=y>0?m/y:NaN;return d}let s=t.length,o=ke(t.map(c=>c.high),e),a=xe(t.map(c=>c.low),e),l=new Array(s).fill(NaN);for(let c=e-1;c<s;c++){let f=o[c],d=a[c];l[c]=f===d?50:(t[c].close-d)/(f-d)*100}let u=i(l,r);return{k:u,d:i(u,n)}}function Ns(t,e=12,n=26,r=9){let i=Te(t,e),s=Te(t,n),o=t.length,a=new Array(o);for(let c=0;c<o;c++)a[c]=i[c]-s[c];let l=Te(a,r),u=new Array(o);for(let c=0;c<o;c++)u[c]=a[c]-l[c];return{macd:a,signal:l,histogram:u}}function Ct(t,e=14){return He(ur(t),e)}function ur(t){let e=t.length,n=new Array(e);for(let r=0;r<e;r++){let i=t[r];if(r===0){n[r]=i.high-i.low;continue}let s=t[r-1].close;n[r]=Math.max(i.high-i.low,Math.abs(i.high-s),Math.abs(i.low-s))}return n}function cr(t,e){let n=Array.isArray(e)?e:new Array(t.length).fill(e);return t.map((r,i)=>i>0&&r>n[i]&&t[i-1]<=n[i-1])}function fr(t,e){let n=Array.isArray(e)?e:new Array(t.length).fill(e);return t.map((r,i)=>i>0&&r<n[i]&&t[i-1]>=n[i-1])}function vs(t,e){let n=cr(t,e),r=fr(t,e);return n.map((i,s)=>i||r[s])}function Ms(t,e=1){return t.map((n,r)=>{if(r<e)return!1;for(let i=1;i<=e;i++)if(t[r-i+1]<=t[r-i])return!1;return!0})}function Cs(t,e=1){return t.map((n,r)=>{if(r<e)return!1;for(let i=1;i<=e;i++)if(t[r-i+1]>=t[r-i])return!1;return!0})}function Es(t,e=1){return t.map((n,r)=>r<e?NaN:n-t[r-e])}function Is(t){let e=NaN;return t.map((n,r)=>n?(e=r,0):isNaN(e)?NaN:r-e)}function As(t,e,n=0){let r=[];return t.map((i,s)=>{i&&r.push(s);let o=r.length-1-n;return o>=0?e[r[o]]:NaN})}function mr(t,e,n){let r=t.length,i=new Array(r).fill(NaN),s=new Array(r),o=0,a=0;for(let l=0;l<r;l++){let u=t[l];if(!isNaN(u)){for(;a>o;){let c=t[s[a-1]];if(n?c<=u:c>=u)a--;else break}s[a++]=l}for(;a>o&&s[o]<=l-e;)o++;l>=e-1&&(i[l]=a>o?t[s[o]]:n?-1/0:1/0)}return i}function ke(t,e){return mr(t,e,!0)}function xe(t,e){return mr(t,e,!1)}function Fs(t,e=5,n=5){let r=t.length,i=new Array(r).fill(NaN);for(let s=e;s<r-n;s++){let o=t[s].high,a=!0;for(let l=s-e;l<=s+n;l++)if(l!==s&&t[l].high>=o){a=!1;break}a&&(i[s]=o)}return i}function Ws(t,e=5,n=5){let r=t.length,i=new Array(r).fill(NaN);for(let s=e;s<r-n;s++){let o=t[s].low,a=!0;for(let l=s-e;l<=s+n;l++)if(l!==s&&t[l].low<=o){a=!1;break}a&&(i[s]=o)}return i}function hr(t,e=20,n=2,r=i=>i.close){let i=t.length,s=new Array(i).fill(NaN),o=new Array(i).fill(NaN),a=new Array(i).fill(NaN),l=new Array(i),u=0,c=0;for(let f=0;f<i;f++){let d=r(t[f]);if(l[f]=d,u+=d,c+=d*d,f>=e){let m=l[f-e];u-=m,c-=m*m}if(f>=e-1){let m=u/e,y=Math.sqrt(Math.max(0,c/e-m*m));s[f]=m,o[f]=m+n*y,a[f]=m-n*y}}return{upper:o,mid:s,lower:a}}function Ls(t,e=20,n=2){let{upper:r,mid:i,lower:s}=hr(t,e,n);return i.map((o,a)=>isNaN(o)||o===0?NaN:(r[a]-s[a])/o)}function Vs(t,e=20){let n=ke(t.map(i=>i.high),e),r=xe(t.map(i=>i.low),e);return{upper:n,mid:n.map((i,s)=>(i+r[s])/2),lower:r}}function Rs(t,e=20,n=10,r=1.5){let i=Te(t,e),s=Ct(t,n);return{upper:i.map((o,a)=>o+r*s[a]),mid:i,lower:i.map((o,a)=>o-r*s[a])}}function Ps(t,e=0){let n=new Array(t.length).fill(NaN),r=864e5,i=0,s=0,o=NaN;for(let a=0;a<t.length;a++){let l=Number(t[a].ts/1000000n),u=Math.floor((l-e*36e5)/r);u!==o&&(i=0,s=0,o=u);let c=(t[a].high+t[a].low+t[a].close)/3;i+=c*t[a].volume,s+=t[a].volume,n[a]=s===0?NaN:i/s}return n}function $s(t){let e=t.map(n=>(n.high+n.low)/2);return{jaw:Ze(e,13),teeth:Ze(e,8),lips:Ze(e,5)}}function dr(t,e,n){let r=X(t,n),i=r.length,s=new Array(i).fill(NaN),o=0,a=0;for(let l=0;l<i;l++)if(o+=r[l],a+=r[l]*r[l],l>=e&&(o-=r[l-e],a-=r[l-e]*r[l-e]),l>=e-1){let u=o/e;s[l]=Math.sqrt(Math.max(0,a/e-u*u))}return s}function Us(t,e,n){return dr(t,e,n).map(r=>r*r)}function zs(t,e){function n(i,s){let o=new Array(i.length).fill(NaN),a=0,l=0;for(let u=0;u<i.length;u++)isNaN(i[u])||(a+=i[u],l++),u>=s&&!isNaN(i[u-s])&&(a-=i[u-s],l--),o[u]=l>0?a/l:NaN;return o}let r=n(t,e);return t.map((i,s)=>Math.abs(i-r[s]))}function Bs(t,e,n){let r=new Array(t.length).fill(NaN),i=0,s=0;for(let o=0;o<t.length;o++){if(i+=t[o],s+=e[o],o>=n&&(i-=t[o-n],s-=e[o-n]),o<n-1)continue;let a=i/n,l=s/n,u=0,c=0,f=0;for(let m=o-n+1;m<=o;m++){let y=t[m]-a,p=e[m]-l;u+=y*p,c+=y*y,f+=p*p}let d=Math.sqrt(c*f);r[o]=d===0?0:u/d}return r}var Zs=ke,Ys=xe;function Hs(t,e){let n=new Array(t.length).fill(NaN);for(let r=e-1;r<t.length;r++){let i=t.slice(r-e+1,r+1).sort((o,a)=>o-a),s=Math.floor(e/2);n[r]=e%2===0?(i[s-1]+i[s])/2:i[s]}return n}function _s(t,e){let n=[];for(let r=0;r<t.length&&r<e.length;r++)!isNaN(e[r])&&isFinite(e[r])&&n.push({t:t[r],price:e[r]});return n}function qs(t){return t[t.length-1]}function Gs(t,e=0){return t==null||isNaN(t)?e:t}function Js(t,e,n,r=[],i=!1){return{type:"line",pts:t,color:e,width:n,dash:r,connect:i}}function js(t,e,n,r=[]){return{type:"hline",price:t,color:e,width:n,dash:r}}function Xs(t,e,n=0,r=.2){return{type:"histogram",pts:t,color:e,base:n,gap:r}}function Ks(t,e,n,r,i=12,s=!1,o="left",a="middle",l=!1,u=99999){return{type:"label",text:t,x:e,y:n,color:r,fontSize:i,bold:s,horzAlign:o,vertAlign:a,anchored:l,maxWidth:u}}function Qs(t,e,n){return{type:"fill",pts1:t,pts2:e,opts:n}}function eo(t,e,n,r,i={}){return{type:"rect",t1:t,t2:n,price1:e,price2:r,...i}}function to(t,e,n,r={}){return{type:"circle",t,price:e,radius:n,...r}}function no(t,e,n=1,r=[]){return{type:"vline",t,color:e,width:n,dash:r}}function ro(t,e,n,r,i=10,s="",o=""){return{type:"arrow",t,price:e,direction:n,color:r,size:i,label:s,labelColor:o||r}}function io(t,e,n,r,i,s=1,o=[],a="none"){return{type:"trendline",t1:t,price1:e,t2:n,price2:r,color:i,width:s,dash:o,extend:a}}function so(t,e,n,r="",i=1){return{type:"band",priceHigh:t,priceLow:e,fillColor:n,borderColor:r,borderWidth:i}}function oo(t,e={}){return{type:"polygon",pts:t,...e}}function ao(t,e,n=3){return{type:"dots",pts:t,color:e,radius:n}}function lo(t,e,n,r,i,s={}){return{type:"badge",t,price:e,text:n,textColor:r,bgColor:i,...s}}function uo(t){let e=new Array(t.length).fill(0);for(let n=1;n<t.length;n++){let r=t[n].close>t[n-1].close?t[n].volume:t[n].close<t[n-1].close?-t[n].volume:0;e[n]=e[n-1]+r}return e}function co(t,e=14){let n=t.length,r=new Array(n).fill(NaN),i=t.map(u=>(u.high+u.low+u.close)/3),s=new Array(n).fill(0),o=new Array(n).fill(0);for(let u=1;u<n;u++){let c=i[u]*t[u].volume;i[u]>i[u-1]?s[u]=c:i[u]<i[u-1]&&(o[u]=c)}let a=0,l=0;for(let u=1;u<n;u++)a+=s[u],l+=o[u],u>e&&(a-=s[u-e],l-=o[u-e]),u>=e&&(r[u]=l===0?100:100-100/(1+a/l));return r}function fo(t,e=20){let n=t.length,r=new Array(n).fill(NaN),i=t.map(o=>(o.high+o.low+o.close)/3),s=0;for(let o=0;o<n;o++){if(s+=i[o],o>=e&&(s-=i[o-e]),o<e-1)continue;let a=s/e,l=0;for(let u=o-e+1;u<=o;u++)l+=Math.abs(i[u]-a);l/=e,r[o]=l===0?0:(i[o]-a)/(.015*l)}return r}function mo(t,e=14){let n=t.length,r=new Array(n).fill(NaN),i=ke(t.map(o=>o.high),e),s=xe(t.map(o=>o.low),e);for(let o=e-1;o<n;o++){let a=i[o],l=s[o];r[o]=a===l?-50:(a-t[o].close)/(a-l)*-100}return r}function ho(t,e=10,n=3){let r=t.length,i=Ct(t,e),s=new Array(r).fill(NaN),o=new Array(r).fill(NaN),a=new Array(r).fill(1),l=e;if(r<=l)return{trend:a,upper:s,lower:o};s[l]=(t[l].high+t[l].low)/2+n*i[l],o[l]=(t[l].high+t[l].low)/2-n*i[l];for(let u=l+1;u<r;u++){let c=(t[u].high+t[u].low)/2,f=c+n*i[u],d=c-n*i[u],m=t[u-1].close;s[u]=f<s[u-1]||m>s[u-1]?f:s[u-1],o[u]=d>o[u-1]||m<o[u-1]?d:o[u-1],a[u-1]===-1&&t[u].close>s[u-1]?a[u]=1:a[u-1]===1&&t[u].close<o[u-1]?a[u]=-1:a[u]=a[u-1]}return{trend:a,upper:s,lower:o}}function yo(t,e,n){if(t.length===0)return[];let r=[],i=new Array(t.length);for(let l=0;l<t.length;l++)i[l]=Number(t[l].ts/1000000n);let s=l=>{let u=0,c=i.length;for(;u<c;){let f=u+c>>>1;i[f]<l?u=f+1:c=f}return u},o=new Map,a=l=>{let u=o.get(l);if(u)return u;u=[];let c=-1/0;for(let f=0;f<i.length;f++){if(i[f]<c)continue;let d=S.fromMillis(i[f],{zone:l});u.push({year:d.year,month:d.month,day:d.day}),c=d.startOf("day").plus({days:1}).toMillis()}return o.set(l,u),u};for(let l of e){let u=l.tz??n?.tz??"UTC";for(let{year:c,month:f,day:d}of a(u)){let m=S.fromObject({year:c,month:f,day:d,hour:l.startHour,minute:l.startMinute,second:0,millisecond:0},{zone:u}),y=S.fromObject({year:c,month:f,day:d,hour:l.endHour,minute:l.endMinute,second:0,millisecond:0},{zone:u});y<=m&&(y=y.plus({days:1}));let p=m.toMillis(),O=y.toMillis(),F=-1/0,R=1/0;for(let P=s(p);P<i.length&&i[P]<O;P++)t[P].high>F&&(F=t[P].high),t[P].low<R&&(R=t[P].low);F===-1/0||R===1/0||r.push({startTs:BigInt(p)*1000000n,endTs:BigInt(O)*1000000n,high:F,low:R,label:l.label,color:l.color})}}return r.sort((l,u)=>l.startTs<u.startTs?-1:l.startTs>u.startTs?1:0),r}var yr={sma:Ze,ema:Te,wma:Ye,hma:ks,rma:He,linreg:xs,rsi:Ds,stoch:Os,macd:Ns,atr:Ct,tr:ur,crossover:cr,crossunder:fr,cross:vs,rising:Ms,falling:Cs,change:Es,barssince:Is,valuewhen:As,highest:ke,lowest:xe,pivotHigh:Fs,pivotLow:Ws,bb:hr,bbw:Ls,donchian:Vs,keltner:Rs,vwap:Ps,alligator:$s,stdev:dr,variance:Us,dev:zs,correlation:Bs,max:Zs,min:Ys,median:Hs,toPoints:_s,last:qs,nz:Gs,obv:uo,mfi:co,cci:fo,williamsR:mo,supertrend:ho,sessionBoundaries:yo,drawLine:Js,drawHLine:js,drawHistogram:Xs,drawLabel:Ks,fillBetween:Qs,drawRect:eo,drawCircle:to,drawVLine:no,drawArrow:ro,drawTrendLine:io,drawBand:so,drawPolygon:oo,drawDots:ao,drawBadge:lo};var gr=Object.freeze({indicator:"indicator",drawing:"drawing",chartType:"chart-type",dataSource:"data-source",extension:"extension"}),wr=Object.freeze({mbo:"l3",l3:"l3",l2:"l2",ohlcv:"ohlcv",tick:"tick"}),pr=Object.freeze({overlay:"overlay",pane:"pane"});function br(t){return typeof t=="bigint"?Number(t/1000000n):Math.floor(t/1e6)}var Et=class{constructor(e,n){qe(this,"exports",e);qe(this,"pluginId",n)}get hasUpdate(){return typeof this.exports.update=="function"}setParams(e){let n=this.exports.set_params;if(!n)return;let r=new TextEncoder().encode(JSON.stringify(e??{}));if(!r.length)return;let i=this.alloc(r.length);new Uint8Array(this.exports.memory.buffer,i,r.length).set(r),n(i,r.length),this.exports.dealloc(i,r.length)}init(e,n,r){return this.call(this.exports.init,e,n,r)}update(e,n,r){let i=this.exports.update;return i?this.call(i,e,n,r):null}alloc(e){let n=this.exports.alloc(e);if(!n)throw new Error(`[wasm:${this.pluginId}] alloc(${e}) returned null`);return n}call(e,n,r,i){let s=n.length*6*8,o=r.length*4*8,a=s?this.alloc(s):0,l=o?this.alloc(o):0;if(a){let f=new Float64Array(this.exports.memory.buffer,a,n.length*6);for(let d=0;d<n.length;d++){let m=n[d],y=d*6;f[y]=br(m.ts),f[y+1]=m.open,f[y+2]=m.high,f[y+3]=m.low,f[y+4]=m.close,f[y+5]=m.volume}}if(l){let f=new Float64Array(this.exports.memory.buffer,l,r.length*4);for(let d=0;d<r.length;d++){let m=r[d],y=d*4;f[y]=br(m.ts),f[y+1]=m.price,f[y+2]=m.size,f[y+3]=m.side==="B"?0:1}}let u=e(a,n.length,l,r.length,Number(i)/1e6),c=this.readResult(u);return l&&this.exports.dealloc(l,o),a&&this.exports.dealloc(a,s),c}readResult(e){if(!e)return null;let n=this.exports.memory.buffer,r=new DataView(n).getUint32(e,!0);if(!r)return new Float64Array(0);if(e+8+r*8>n.byteLength)throw new Error(`[wasm:${this.pluginId}] result claims ${r} doubles, which runs past the end of memory`);return new Float64Array(n,e+8,r).slice()}},_e=new Map;async function Sr(t,e){let n=_e.get(t);n||(n=fetch(t).then(async a=>{if(!a.ok)throw new Error(`${a.status} ${a.statusText}`);return WebAssembly.compile(await a.arrayBuffer())}),_e.set(t,n));let r;try{r=await n}catch(a){throw _e.delete(t),new Error(`[wasm:${e}] could not load ${t}: ${a}`)}let i=null,s={env:{log(a,l){let u=i.exports.memory,c=new Uint8Array(u.buffer,a,l);console.log(`[wasm:${e}]`,new TextDecoder().decode(c))},abort(){throw new Error(`[wasm:${e}] called abort()`)}}};i=await WebAssembly.instantiate(r,s);let o=i.exports;for(let a of["memory","alloc","dealloc","init"])if(!o[a])throw new Error(`[wasm:${e}] ${t} does not export \'${a}\'`);return new Et(o,e)}function Tr(t){_e.delete(t)}function go(t){let e={PluginType:gr,DataLevel:wr,Layout:pr,Math,console,plugin:t,fetch:void 0,XMLHttpRequest:void 0,WebSocket:void 0,importScripts:void 0};for(let[n,r]of Object.entries(yr))e[n]=r;return e}function wo(t){let e=[];function n(o){let a={decl:o,state:{},init:null,update:null,draw:null,wasmUrl:null,wasm:null,wasmSeries:null,drawUISrc:null,onInstallSrc:null,extensionDrawSrc:null,drawDirectSrc:null,onRenderSrc:null,onHitTestSrc:null,onPreviewSrc:null,onMoveSrc:null,onPointerDownSrc:null,onPointerMoveSrc:null,onPointerUpSrc:null,onKeyDownSrc:null,onActivateSrc:null,onDeactivateSrc:null,onDrawSrc:null,onGetAutoYBoundsSrc:null,onChartPointerDownSrc:null,onChartPointerMoveSrc:null,onChartPointerUpSrc:null,onChartKeyDownSrc:null,onChartActivateSrc:null,onChartDeactivateSrc:null,onBarHoverSrc:null,getTooltipSrc:null};return e.push(a),{set init(u){a.init=u},set update(u){a.update=u},set draw(u){a.draw=u,a.onDrawSrc=u.toString()},set drawUI(u){a.drawUISrc=u.toString()},set wasm(u){a.wasmUrl=u},set onInstall(u){a.onInstallSrc=u.toString()},set panel(u){a.extensionDrawSrc=u.toString()},set drawDirect(u){a.drawDirectSrc=u.toString()},set onRender(u){a.onRenderSrc=u.toString()},set onHitTest(u){a.onHitTestSrc=u.toString()},set onPreview(u){a.onPreviewSrc=u.toString()},set onMove(u){a.onMoveSrc=u.toString()},set onPointerDown(u){a.onPointerDownSrc=u.toString(),a.onChartPointerDownSrc=u.toString()},set onPointerMove(u){a.onPointerMoveSrc=u.toString(),a.onChartPointerMoveSrc=u.toString()},set onPointerUp(u){a.onPointerUpSrc=u.toString(),a.onChartPointerUpSrc=u.toString()},set onKeyDown(u){a.onKeyDownSrc=u.toString(),a.onChartKeyDownSrc=u.toString()},set onActivate(u){a.onActivateSrc=u.toString(),a.onChartActivateSrc=u.toString()},set onDeactivate(u){a.onDeactivateSrc=u.toString(),a.onChartDeactivateSrc=u.toString()},set getAutoYBounds(u){a.onGetAutoYBoundsSrc=u.toString()},set onBarHover(u){a.onBarHoverSrc=u.toString()},set getTooltip(u){a.getTooltipSrc=u.toString()}}}let r=go(n),i=Object.keys(r),s=i.map(o=>r[o]);new Function(...i,`"use strict";\n${t}`)(...s);for(let o of e)if(!o.update&&o.init){let a=o.init;o.update=({data:l,barNs:u,params:c})=>{let f=a({data:l,barNs:u,params:c});return{points:f,state:f}}}return e}var De=[];function po(t,e){if(!t?.length)return e??new Float64Array(0);if(!e?.length)return t;let n=new Float64Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n}function bo(t,e){t.wasmUrl&&(Tr(t.wasmUrl),t.wasm=Sr(t.wasmUrl,t.decl?.name??`plugin ${e}`),t.wasm.catch(()=>{}))}async function kr(t,e,n,r,i){let s=await t.wasm,o=n?.ohlcv??[],a=n?.trades??[];return e==="init"?(s.setParams(i),s.init(o,a,r)):s.hasUpdate?s.update(o,a,r):s.init(o,a,r)}self.onmessage=t=>{let e=t.data;if(e.type==="destroy"){self.close();return}xr=xr.then(()=>So(e)).catch(It)};var xr=Promise.resolve();async function So(t){if(t.type==="parse"){De=wo(t.script??""),De.forEach(bo),self.postMessage({type:"parsed",plugins:De.map((e,n)=>({index:n,decl:e.decl,drawDirectSrc:e.drawDirectSrc,drawUISrc:e.drawUISrc,wasmUrl:e.wasmUrl,onInstallSrc:e.onInstallSrc,extensionDrawSrc:e.extensionDrawSrc,onRenderSrc:e.onRenderSrc,onHitTestSrc:e.onHitTestSrc,onPreviewSrc:e.onPreviewSrc,onMoveSrc:e.onMoveSrc,onPointerDownSrc:e.onPointerDownSrc,onPointerMoveSrc:e.onPointerMoveSrc,onPointerUpSrc:e.onPointerUpSrc,onKeyDownSrc:e.onKeyDownSrc,onActivateSrc:e.onActivateSrc,onDeactivateSrc:e.onDeactivateSrc,onDrawSrc:e.onDrawSrc,onGetAutoYBoundsSrc:e.onGetAutoYBoundsSrc,onChartPointerDownSrc:e.onChartPointerDownSrc,onChartPointerMoveSrc:e.onChartPointerMoveSrc,onChartPointerUpSrc:e.onChartPointerUpSrc,onChartKeyDownSrc:e.onChartKeyDownSrc,onChartActivateSrc:e.onChartActivateSrc,onChartDeactivateSrc:e.onChartDeactivateSrc,onBarHoverSrc:e.onBarHoverSrc,getTooltipSrc:e.getTooltipSrc}))});return}if(t.type==="run-init"){try{let e=De[t.pluginIndex];if(!e)return;let n=t.params??{};if(e.wasmUrl){let i=await kr(e,"init",t.data,t.barNs,n);e.wasmSeries=i,e.state=e.init?e.init({data:t.data,barNs:t.barNs,params:n,wasm:i}):i}else e.state=e.init?e.init({data:t.data,barNs:t.barNs,params:n}):{};let r=e.draw&&e.decl?.type!=="chart-type"?e.draw(e.state)??[]:[];self.postMessage({type:"update",pluginIndex:t.pluginIndex,points:e.state,state:e.state,drawCommands:r})}catch(e){It(e)}return}if(t.type==="update"){let e=De[t.pluginIndex];if(!e||!e.update&&!e.wasmUrl)return;try{let n=t.params??{},r;if(e.wasmUrl){let o=await e.wasm,a=await kr(e,"update",o.hasUpdate?t.newData:t.data,t.barNs??0n,n);e.wasmSeries=o.hasUpdate?po(e.wasmSeries,a):a,e.update?r=e.update({data:t.data??{},newData:t.newData??{},state:e.state,barNs:t.barNs??0n,horizon:t.horizon??0n,params:n,wasm:a}):r={points:a,state:e.wasmSeries}}else r=e.update({data:t.data??{},newData:t.newData??{},state:e.state,barNs:t.barNs??0n,horizon:t.horizon??0n,params:n});e.state=r.state;let i=e.draw&&e.decl?.type!=="chart-type"?e.draw(e.state)??[]:[],s=[];if(r.points&&typeof r.points=="object"&&!ArrayBuffer.isView(r.points))for(let o of Object.values(r.points))o instanceof ArrayBuffer&&s.push(o);self.postMessage({type:"update",pluginIndex:t.pluginIndex,points:r.points,state:e.state,drawCommands:i},s)}catch(n){It(n)}return}}function It(t){let e=t instanceof Error?t:new Error(String(t)),n=e.stack?.match(/<anonymous>:(\\d+)/);self.postMessage({type:"error",error:e.message,line:n?+n[1]:void 0})}})();\n',ix;function sx(){return ix||(ix=URL.createObjectURL(new Blob([aU],{type:"text/javascript"}))),ix}function Cc(e,t){return e.length?typeof e[0]=="number"?e:e.map(t??(n=>n.close)):[]}function Mg(e,t,n){let r=Cc(e,n),o=new Array(r.length),a=0,i=0;for(let s=0;s<r.length;s++){let l=r[s];if(isNaN(l)||(a+=l,i++),s>=t){let c=r[s-t];isNaN(c)||(a-=c,i--)}o[s]=i>=t?a/t:NaN}return o}function Am(e,t,n){let r=Cc(e,n),o=2/(t+1),a=new Array(r.length),i=NaN;for(let s=0;s<r.length;s++){let l=r[s];i=isNaN(i)?l:l*o+i*(1-o),a[s]=i}return a}function Lg(e,t,n){let r=Cc(e,n),o=new Array(r.length).fill(NaN),a=t*(t+1)/2;for(let i=t-1;i<r.length;i++){let s=0;for(let l=0;l<t;l++)s+=r[i-l]*(t-l);o[i]=s/a}return o}function iU(e,t,n){let r=Cc(e,n),o=Math.floor(t/2),a=Math.round(Math.sqrt(t)),i=Lg(r,o),s=Lg(r,t),l=r.map((c,u)=>2*i[u]-s[u]);return Lg(l,a)}function Rg(e,t,n){let r=Cc(e,n),o=new Array(r.length).fill(NaN),a=NaN;for(let i=0;i<r.length;i++){let s=r[i];if(isNaN(a)){if(i<t-1)continue;let l=0;for(let c=i-t+1;c<=i;c++)l+=r[c];a=l/t,o[i]=a}else a=(a*(t-1)+s)/t,o[i]=a}return o}function sU(e,t,n){let r=Cc(e,n),o=new Array(r.length).fill(NaN);for(let a=t-1;a<r.length;a++){let i=0,s=0,l=0,c=0;for(let m=0;m<t;m++){let f=m,h=r[a-(t-1-m)];i+=f,s+=h,l+=f*h,c+=f*f}let u=t,d=(u*l-i*s)/(u*c-i*i);o[a]=(s-d*i)/u+d*(t-1)}return o}function lU(e,t=14){let n=e.length;if(n===0)return[];let r=new Array(n),o=new Array(n);r[0]=0,o[0]=0;for(let l=1;l<n;l++){let c=e[l].close-e[l-1].close;r[l]=c>0?c:0,o[l]=c<0?-c:0}let a=Rg(r,t),i=Rg(o,t),s=new Array(n);for(let l=0;l<n;l++)s[l]=isNaN(a[l])?NaN:i[l]===0?100:100-100/(1+a[l]/i[l]);return s}function cU(e,t=14,n=3,r=3){function o(u,d){let m=new Array(u.length).fill(NaN),f=0,h=0;for(let p=0;p<u.length;p++)isNaN(u[p])||(f+=u[p],h++),p>=d&&!isNaN(u[p-d])&&(f-=u[p-d],h--),m[p]=h>0?f/h:NaN;return m}let a=e.length,i=Bm(e.map(u=>u.high),t),s=Nm(e.map(u=>u.low),t),l=new Array(a).fill(NaN);for(let u=t-1;u<a;u++){let d=i[u],m=s[u];l[u]=d===m?50:(e[u].close-m)/(d-m)*100}let c=o(l,r);return{k:c,d:o(c,n)}}function uU(e,t=12,n=26,r=9){let o=Am(e,t),a=Am(e,n),i=e.length,s=new Array(i);for(let u=0;u<i;u++)s[u]=o[u]-a[u];let l=Am(s,r),c=new Array(i);for(let u=0;u<i;u++)c[u]=s[u]-l[u];return{macd:s,signal:l,histogram:c}}function lx(e,t=14){return Rg(RD(e),t)}function RD(e){let t=e.length,n=new Array(t);for(let r=0;r<t;r++){let o=e[r];if(r===0){n[r]=o.high-o.low;continue}let a=e[r-1].close;n[r]=Math.max(o.high-o.low,Math.abs(o.high-a),Math.abs(o.low-a))}return n}function PD(e,t){let n=Array.isArray(t)?t:new Array(e.length).fill(t);return e.map((r,o)=>o>0&&r>n[o]&&e[o-1]<=n[o-1])}function DD(e,t){let n=Array.isArray(t)?t:new Array(e.length).fill(t);return e.map((r,o)=>o>0&&r<n[o]&&e[o-1]>=n[o-1])}function dU(e,t){let n=PD(e,t),r=DD(e,t);return n.map((o,a)=>o||r[a])}function fU(e,t=1){return e.map((n,r)=>{if(r<t)return!1;for(let o=1;o<=t;o++)if(e[r-o+1]<=e[r-o])return!1;return!0})}function mU(e,t=1){return e.map((n,r)=>{if(r<t)return!1;for(let o=1;o<=t;o++)if(e[r-o+1]>=e[r-o])return!1;return!0})}function pU(e,t=1){return e.map((n,r)=>r<t?NaN:n-e[r-t])}function hU(e){let t=NaN;return e.map((n,r)=>n?(t=r,0):isNaN(t)?NaN:r-t)}function gU(e,t,n=0){let r=[];return e.map((o,a)=>{o&&r.push(a);let i=r.length-1-n;return i>=0?t[r[i]]:NaN})}function AD(e,t,n){let r=e.length,o=new Array(r).fill(NaN),a=new Array(r),i=0,s=0;for(let l=0;l<r;l++){let c=e[l];if(!isNaN(c)){for(;s>i;){let u=e[a[s-1]];if(n?u<=c:u>=c)s--;else break}a[s++]=l}for(;s>i&&a[i]<=l-t;)i++;l>=t-1&&(o[l]=s>i?e[a[i]]:n?-1/0:1/0)}return o}function Bm(e,t){return AD(e,t,!0)}function Nm(e,t){return AD(e,t,!1)}function bU(e,t=5,n=5){let r=e.length,o=new Array(r).fill(NaN);for(let a=t;a<r-n;a++){let i=e[a].high,s=!0;for(let l=a-t;l<=a+n;l++)if(l!==a&&e[l].high>=i){s=!1;break}s&&(o[a]=i)}return o}function yU(e,t=5,n=5){let r=e.length,o=new Array(r).fill(NaN);for(let a=t;a<r-n;a++){let i=e[a].low,s=!0;for(let l=a-t;l<=a+n;l++)if(l!==a&&e[l].low<=i){s=!1;break}s&&(o[a]=i)}return o}function BD(e,t=20,n=2,r=o=>o.close){let o=e.length,a=new Array(o).fill(NaN),i=new Array(o).fill(NaN),s=new Array(o).fill(NaN),l=new Array(o),c=0,u=0;for(let d=0;d<o;d++){let m=r(e[d]);if(l[d]=m,c+=m,u+=m*m,d>=t){let f=l[d-t];c-=f,u-=f*f}if(d>=t-1){let f=c/t,h=Math.sqrt(Math.max(0,u/t-f*f));a[d]=f,i[d]=f+n*h,s[d]=f-n*h}}return{upper:i,mid:a,lower:s}}function vU(e,t=20,n=2){let{upper:r,mid:o,lower:a}=BD(e,t,n);return o.map((i,s)=>isNaN(i)||i===0?NaN:(r[s]-a[s])/i)}function wU(e,t=20){let n=Bm(e.map(o=>o.high),t),r=Nm(e.map(o=>o.low),t);return{upper:n,mid:n.map((o,a)=>(o+r[a])/2),lower:r}}function xU(e,t=20,n=10,r=1.5){let o=Am(e,t),a=lx(e,n);return{upper:o.map((i,s)=>i+r*a[s]),mid:o,lower:o.map((i,s)=>i-r*a[s])}}function SU(e,t=0){let n=new Array(e.length).fill(NaN),r=864e5,o=0,a=0,i=NaN;for(let s=0;s<e.length;s++){let l=Number(e[s].ts/1000000n),c=Math.floor((l-t*36e5)/r);c!==i&&(o=0,a=0,i=c);let u=(e[s].high+e[s].low+e[s].close)/3;o+=u*e[s].volume,a+=e[s].volume,n[s]=a===0?NaN:o/a}return n}function CU(e){let t=e.map(n=>(n.high+n.low)/2);return{jaw:Mg(t,13),teeth:Mg(t,8),lips:Mg(t,5)}}function ND(e,t,n){let r=Cc(e,n),o=r.length,a=new Array(o).fill(NaN),i=0,s=0;for(let l=0;l<o;l++)if(i+=r[l],s+=r[l]*r[l],l>=t&&(i-=r[l-t],s-=r[l-t]*r[l-t]),l>=t-1){let c=i/t;a[l]=Math.sqrt(Math.max(0,s/t-c*c))}return a}function kU(e,t,n){return ND(e,t,n).map(r=>r*r)}function TU(e,t){function n(o,a){let i=new Array(o.length).fill(NaN),s=0,l=0;for(let c=0;c<o.length;c++)isNaN(o[c])||(s+=o[c],l++),c>=a&&!isNaN(o[c-a])&&(s-=o[c-a],l--),i[c]=l>0?s/l:NaN;return i}let r=n(e,t);return e.map((o,a)=>Math.abs(o-r[a]))}function IU(e,t,n){let r=new Array(e.length).fill(NaN),o=0,a=0;for(let i=0;i<e.length;i++){if(o+=e[i],a+=t[i],i>=n&&(o-=e[i-n],a-=t[i-n]),i<n-1)continue;let s=o/n,l=a/n,c=0,u=0,d=0;for(let f=i-n+1;f<=i;f++){let h=e[f]-s,p=t[f]-l;c+=h*p,u+=h*h,d+=p*p}let m=Math.sqrt(u*d);r[i]=m===0?0:c/m}return r}var MU=Bm,LU=Nm;function RU(e,t){let n=new Array(e.length).fill(NaN);for(let r=t-1;r<e.length;r++){let o=e.slice(r-t+1,r+1).sort((i,s)=>i-s),a=Math.floor(t/2);n[r]=t%2===0?(o[a-1]+o[a])/2:o[a]}return n}function PU(e,t){let n=[];for(let r=0;r<e.length&&r<t.length;r++)!isNaN(t[r])&&isFinite(t[r])&&n.push({t:e[r],price:t[r]});return n}function DU(e){return e[e.length-1]}function AU(e,t=0){return e==null||isNaN(e)?t:e}function BU(e,t,n,r=[],o=!1){return{type:"line",pts:e,color:t,width:n,dash:r,connect:o}}function NU(e,t,n,r=[]){return{type:"hline",price:e,color:t,width:n,dash:r}}function EU(e,t,n=0,r=.2){return{type:"histogram",pts:e,color:t,base:n,gap:r}}function OU(e,t,n,r,o=12,a=!1,i="left",s="middle",l=!1,c=99999){return{type:"label",text:e,x:t,y:n,color:r,fontSize:o,bold:a,horzAlign:i,vertAlign:s,anchored:l,maxWidth:c}}function _U(e,t,n){return{type:"fill",pts1:e,pts2:t,opts:n}}function FU(e,t,n,r,o={}){return{type:"rect",t1:e,t2:n,price1:t,price2:r,...o}}function zU(e,t,n,r={}){return{type:"circle",t:e,price:t,radius:n,...r}}function HU(e,t,n=1,r=[]){return{type:"vline",t:e,color:t,width:n,dash:r}}function VU(e,t,n,r,o=10,a="",i=""){return{type:"arrow",t:e,price:t,direction:n,color:r,size:o,label:a,labelColor:i||r}}function WU(e,t,n,r,o,a=1,i=[],s="none"){return{type:"trendline",t1:e,price1:t,t2:n,price2:r,color:o,width:a,dash:i,extend:s}}function qU(e,t,n,r="",o=1){return{type:"band",priceHigh:e,priceLow:t,fillColor:n,borderColor:r,borderWidth:o}}function UU(e,t={}){return{type:"polygon",pts:e,...t}}function jU(e,t,n=3){return{type:"dots",pts:e,color:t,radius:n}}function GU(e,t,n,r,o,a={}){return{type:"badge",t:e,price:t,text:n,textColor:r,bgColor:o,...a}}function ED(e,t){let{ctx:n,rect:r,tMin:o,tMax:a,barNs:i,transformer:s}=t;for(let l of e)switch(l.type){case"line":YU(l,n,r,o,a,i,s);break;case"hline":KU(l,n,r,s);break;case"histogram":$U(l,n,r,o,a,i,s);break;case"label":XU(l,n,r,s);break;case"fill":ZU(l,n,r,o,a,i,s);break;case"rect":QU(l,n,r,s);break;case"circle":JU(l,n,r,s);break;case"vline":ej(l,n,r,s);break;case"arrow":tj(l,n,r,s);break;case"trendline":nj(l,n,r,o,a,s);break;case"band":rj(l,n,r,s);break;case"polygon":oj(l,n,r,s);break;case"dots":aj(l,n,r,o,a,s);break;case"badge":ij(l,n,r,s);break}}function YU(e,t,n,r,o,a,i){let{pts:s,color:l,width:c,dash:u=[],connect:d=!1}=e;if(s.length===0)return;let m=i.makeTsToXFn(n.w),f=i.makePriceToYFn(n.h),h=0;{let C=0,w=s.length-1;for(;C<=w;){let k=C+w>>>1;s[k].t<r?C=k+1:w=k-1}h=C>0?C-1:0}t.save(),t.lineWidth=c,t.setLineDash(u),t.lineJoin="round";let p=Array.isArray(l),g=p?"":l;p||(t.strokeStyle=g),t.beginPath();let y=!1,v=0,b=0,S=!1;for(let C=h;C<s.length;C++){let w=s[C].t;if(w>o)break;let k=s[C].price;if(isNaN(k)&&!d){y&&(t.stroke(),t.beginPath(),y=!1),S=!1;continue}let M=m(w),I=f(k),x=p?l[Math.min(C,l.length-1)]:g,T=!d&&a>0n&&C<s.length-1&&w%a===0n&&s[C+1].t>w+a;p&&x!==g?(y&&(t.stroke(),t.beginPath()),t.strokeStyle=x,g=x,S&&!T?(t.moveTo(v,b),t.lineTo(M,I)):t.moveTo(M,I),y=!0):T?(y&&(t.stroke(),t.beginPath()),t.moveTo(M,I),y=!0):y?t.lineTo(M,I):(t.moveTo(M,I),y=!0),v=M,b=I,S=!0}y&&t.stroke(),t.restore()}function KU(e,t,n,r){let{price:o,color:a,width:i,dash:s=[]}=e,l=r.priceToY(o,n.h);t.save(),t.strokeStyle=a,t.lineWidth=i,t.setLineDash(s),t.lineJoin="round",t.beginPath(),t.moveTo(0,l),t.lineTo(n.w,l),t.stroke(),t.restore()}function $U(e,t,n,r,o,a,i){let{pts:s,color:l,base:c=0,gap:u=.2}=e,d=Number(o-r),m=a>0n?Number(a)/d*n.w:4,f=Math.max(1,Math.floor(m*(1-u))),h=f/2,p=i.makeTsToXFn(n.w),g=i.makePriceToYFn(n.h),y=g(c),v=Array.isArray(l),[b]=cx(s,r,o);t.save(),v||(t.fillStyle=l);for(let S=b;S<s.length;S++){let C=s[S],w=C.t;if(w>o)break;if(w<r)continue;v&&(t.fillStyle=l[Math.min(S,l.length-1)]);let k=p(w),M=g(C.price),I=Math.min(y,M),x=Math.abs(M-y);t.fillRect(k-h,I,f,x)}t.restore()}function XU(e,t,n,r){let{text:o,x:a,y:i,color:s,fontSize:l=12,bold:c=!1,horzAlign:u="left",vertAlign:d="middle",anchored:m=!1,maxWidth:f=99999}=e;t.save(),t.fillStyle=s,t.font=`${c?"bold ":""}${l}px "Inter", system-ui, sans-serif`,t.textBaseline=d,t.textAlign=u,m?t.fillText(o,a,i,f):t.fillText(o,r.tsToX(BigInt(a),n.w),r.priceToY(i,n.h),f),t.restore()}function ZU(e,t,n,r,o,a,i){let{pts1:s,pts2:l,opts:c}=e,u=c;if(typeof s=="number"&&(s=ID(s,r,o,a)),typeof l=="number"&&(l=ID(l,r,o,a)),s.length<2||l.length<2)return;let d=MD(s,n,i,r,o),m=MD(l,n,i,r,o);if(u.mode==="data"){lj(t,d,m,n,u.stops);return}let f=sj(d,m);if(t.save(),u.mode==="solid")t.fillStyle=u.color,t.fill(f);else if(u.mode==="screen"){let h=t.createLinearGradient(0,0,0,n.h);for(let p of u.stops)h.addColorStop(p.offset,p.color);t.fillStyle=h,t.fill(f)}else if(u.mode==="vertical"){let h=u.stops.map(C=>C.price),p=Math.max(...h),g=Math.min(...h),y=i.priceToY(p,n.h),v=i.priceToY(g,n.h),b=t.createLinearGradient(0,y,0,v),S=p-g;for(let C of u.stops){let w=S>0?(C.price-g)/S:0;b.addColorStop(OD(1-w),C.color)}t.fillStyle=b,t.fill(f)}t.restore()}function QU(e,t,n,r){let{t1:o,t2:a,price1:i,price2:s,fillColor:l,borderColor:c,borderWidth:u=1,dash:d=[],radius:m=0}=e,f=r.tsToX(o,n.w),h=r.tsToX(a,n.w),p=r.priceToY(i,n.h),g=r.priceToY(s,n.h),y=Math.min(f,h),v=Math.min(p,g),b=Math.abs(h-f),S=Math.abs(g-p);if(t.save(),m>0){let C=Math.min(m,b/2,S/2),w=new Path2D;w.roundRect(y,v,b,S,C),l&&(t.fillStyle=l,t.fill(w)),c&&(t.strokeStyle=c,t.lineWidth=u,t.setLineDash(d),t.stroke(w))}else l&&(t.fillStyle=l,t.fillRect(y,v,b,S)),c&&(t.strokeStyle=c,t.lineWidth=u,t.setLineDash(d),t.strokeRect(y,v,b,S));t.restore()}function JU(e,t,n,r){let{t:o,price:a,radius:i,fillColor:s,borderColor:l,borderWidth:c=1}=e,u=r.tsToX(o,n.w),d=r.priceToY(a,n.h);t.save(),t.beginPath(),t.arc(u,d,i,0,Math.PI*2),s&&(t.fillStyle=s,t.fill()),l&&(t.strokeStyle=l,t.lineWidth=c,t.stroke()),t.restore()}function ej(e,t,n,r){let{t:o,color:a,width:i,dash:s=[]}=e,l=r.tsToX(o,n.w);t.save(),t.strokeStyle=a,t.lineWidth=i,t.setLineDash(s),t.beginPath(),t.moveTo(l,0),t.lineTo(l,n.h),t.stroke(),t.restore()}function tj(e,t,n,r){let{t:o,price:a,direction:i,color:s,size:l=10,label:c="",labelColor:u}=e,d=r.tsToX(o,n.w),m=r.priceToY(a,n.h),f=i==="up"?m-l*.5:m+l*.5,h=i==="up"?m+l*.3:m-l*.3,p=l*.5;if(t.save(),t.fillStyle=s,t.beginPath(),t.moveTo(d,f),t.lineTo(d-p,h),t.lineTo(d+p,h),t.closePath(),t.fill(),c){t.fillStyle=u??s,t.font=`bold ${Math.round(l*.9)}px "Inter", system-ui, sans-serif`,t.textAlign="center",t.textBaseline=i==="up"?"bottom":"top";let g=i==="up"?f-3:f+3;t.fillText(c,d,g)}t.restore()}function nj(e,t,n,r,o,a){let{t1:i,price1:s,t2:l,price2:c,color:u,width:d=1,dash:m=[],extend:f="none"}=e,h=a.tsToX(i,n.w),p=a.priceToY(s,n.h),g=a.tsToX(l,n.w),y=a.priceToY(c,n.h);if(f!=="none"&&g!==h){let v=(y-p)/(g-h);(f==="right"||f==="both")&&(y=p+v*(n.w-h),g=n.w),f==="both"&&(p=p+v*(0-h),h=0)}t.save(),t.strokeStyle=u,t.lineWidth=d,t.setLineDash(m),t.lineJoin="round",t.beginPath(),t.moveTo(h,p),t.lineTo(g,y),t.stroke(),t.restore()}function rj(e,t,n,r){let{priceHigh:o,priceLow:a,fillColor:i,borderColor:s="",borderWidth:l=1}=e,c=r.priceToY(o,n.h),u=r.priceToY(a,n.h);t.save(),i&&(t.fillStyle=i,t.fillRect(0,c,n.w,u-c)),s&&(t.strokeStyle=s,t.lineWidth=l,t.beginPath(),t.moveTo(0,c),t.lineTo(n.w,c),t.moveTo(0,u),t.lineTo(n.w,u),t.stroke()),t.restore()}function oj(e,t,n,r){let{pts:o,fillColor:a,borderColor:i,borderWidth:s=1,dash:l=[]}=e;if(!(o.length<2)){t.save(),t.beginPath(),t.moveTo(r.tsToX(o[0].t,n.w),r.priceToY(o[0].price,n.h));for(let c=1;c<o.length;c++)t.lineTo(r.tsToX(o[c].t,n.w),r.priceToY(o[c].price,n.h));t.closePath(),a&&(t.fillStyle=a,t.fill()),i&&(t.strokeStyle=i,t.lineWidth=s,t.setLineDash(l),t.stroke()),t.restore()}}function aj(e,t,n,r,o,a){let{pts:i,color:s,radius:l=3}=e;if(i.length===0)return;let c=Array.isArray(s),[u]=cx(i,r,o),d=a.makeTsToXFn(n.w),m=a.makePriceToYFn(n.h);t.save(),c||(t.fillStyle=s);for(let f=u;f<i.length;f++){let h=i[f],p=BigInt(h.t);if(p>o)break;if(p<r||isNaN(h.price))continue;c&&(t.fillStyle=s[Math.min(f,s.length-1)]);let g=d(p),y=m(h.price);t.beginPath(),t.arc(g,y,l,0,Math.PI*2),t.fill()}t.restore()}function ij(e,t,n,r){let{t:o,price:a,text:i,textColor:s,bgColor:l,fontSize:c=11,padding:u=5,radius:d=4,anchored:m=!1}=e,f=m?Number(o):r.tsToX(o,n.w),h=m?a:r.priceToY(a,n.h);t.save(),t.font=`bold ${c}px "Inter", system-ui, sans-serif`;let g=t.measureText(i).width+u*2,y=c+u*2,v=f-g/2,b=h-y/2,S=new Path2D;S.roundRect(v,b,g,y,d),t.fillStyle=l,t.fill(S),t.fillStyle=s,t.textAlign="center",t.textBaseline="middle",t.fillText(i,f,h),t.restore()}function ID(e,t,n,r){let o=r>0n?r:(n-t)/100n,a=[];for(let i=t;i<=n;i+=o)a.push({t:i,price:e});return a}function cx(e,t,n){let r=0,o=e.length-1;for(;r<=o;){let s=r+o>>>1;e[s].t<t?r=s+1:o=s-1}let a=r>0?r-1:0;for(r=0,o=e.length-1;r<=o;){let s=r+o>>>1;e[s].t<=n?r=s+1:o=s-1}let i=r<e.length?r:e.length-1;return[a,i]}function OD(e){return e<0?0:e>1?1:Number.isFinite(e)?e:0}function MD(e,t,n,r,o){let[a,i]=cx(e,r,o),s=Math.max(0,i-a+1),l=n.makeTsToXFn(t.w),c=n.makePriceToYFn(t.h),u=new Float64Array(s),d=new Float64Array(s);for(let m=0;m<s;m++)u[m]=l(e[a+m].t),d[m]=c(e[a+m].price);return{xs:u,ys:d}}function sj(e,t){let n=new Path2D;n.moveTo(e.xs[0],e.ys[0]);for(let r=1;r<e.xs.length;r++)n.lineTo(e.xs[r],e.ys[r]);for(let r=t.xs.length-1;r>=0;r--)n.lineTo(t.xs[r],t.ys[r]);return n.closePath(),n}function LD(e){let{xs:t,ys:n}=e,r=t.length,o=0;return a=>{if(r===0)return NaN;if(r===1||a<=t[0])return n[0];if(a>=t[r-1])return n[r-1];for(;o<r-2&&t[o+1]<a;)o++;for(;o>0&&t[o]>a;)o--;let i=t[o+1]-t[o];return i>0?n[o]+(n[o+1]-n[o])*(a-t[o])/i:n[o+1]}}function lj(e,t,n,r,o){let a=t.xs.length,i=n.xs.length;if(a===0||i===0||o.length===0)return;let s=Math.max(0,Math.floor(Math.min(t.xs[0],n.xs[0]))),l=Math.min(r.w,Math.ceil(Math.max(t.xs[a-1],n.xs[i-1])));if(!(l>s))return;let c=LD(t),u=LD(n);e.save();let d=e.createLinearGradient(0,0,0,1);for(let x of o)d.addColorStop(OD(x.offset),x.color);e.fillStyle=d;let m=e.getTransform(),f=m.a,h=m.b,p=m.c,g=m.d,y=m.e,v=m.f,b=.5/Math.max(1,Math.abs(g)||1),S=s,C=1/0,w=-1/0,k=1/0,M=-1/0,I=x=>{if(x<=S||Math.max(w,M)<0||Math.min(C,k)>r.h)return;let T=(C+w)/2,R=(k+M)/2-T;Math.abs(R)<.5&&(R=R<0?-.5:.5);let P=x-S;e.setTransform(f*P,h*P,p*R,g*R,f*S+p*T+y,h*S+g*T+v),e.fillRect(0,0,1,1)};for(let x=s;x<=l;x++){let T=c(x),R=u(x),P=T<C?T:C,D=T>w?T:w,N=R<k?R:k,O=R>M?R:M;x>S&&(D-P>b||O-N>b)?(I(x),S=x,C=w=T,k=M=R):(C=P,w=D,k=N,M=O)}I(l),e.restore()}function cj(e){let t=new Array(e.length).fill(0);for(let n=1;n<e.length;n++){let r=e[n].close>e[n-1].close?e[n].volume:e[n].close<e[n-1].close?-e[n].volume:0;t[n]=t[n-1]+r}return t}function uj(e,t=14){let n=e.length,r=new Array(n).fill(NaN),o=e.map(c=>(c.high+c.low+c.close)/3),a=new Array(n).fill(0),i=new Array(n).fill(0);for(let c=1;c<n;c++){let u=o[c]*e[c].volume;o[c]>o[c-1]?a[c]=u:o[c]<o[c-1]&&(i[c]=u)}let s=0,l=0;for(let c=1;c<n;c++)s+=a[c],l+=i[c],c>t&&(s-=a[c-t],l-=i[c-t]),c>=t&&(r[c]=l===0?100:100-100/(1+s/l));return r}function dj(e,t=20){let n=e.length,r=new Array(n).fill(NaN),o=e.map(i=>(i.high+i.low+i.close)/3),a=0;for(let i=0;i<n;i++){if(a+=o[i],i>=t&&(a-=o[i-t]),i<t-1)continue;let s=a/t,l=0;for(let c=i-t+1;c<=i;c++)l+=Math.abs(o[c]-s);l/=t,r[i]=l===0?0:(o[i]-s)/(.015*l)}return r}function fj(e,t=14){let n=e.length,r=new Array(n).fill(NaN),o=Bm(e.map(i=>i.high),t),a=Nm(e.map(i=>i.low),t);for(let i=t-1;i<n;i++){let s=o[i],l=a[i];r[i]=s===l?-50:(s-e[i].close)/(s-l)*-100}return r}function mj(e,t=10,n=3){let r=e.length,o=lx(e,t),a=new Array(r).fill(NaN),i=new Array(r).fill(NaN),s=new Array(r).fill(1),l=t;if(r<=l)return{trend:s,upper:a,lower:i};a[l]=(e[l].high+e[l].low)/2+n*o[l],i[l]=(e[l].high+e[l].low)/2-n*o[l];for(let c=l+1;c<r;c++){let u=(e[c].high+e[c].low)/2,d=u+n*o[c],m=u-n*o[c],f=e[c-1].close;a[c]=d<a[c-1]||f>a[c-1]?d:a[c-1],i[c]=m>i[c-1]||f<i[c-1]?m:i[c-1],s[c-1]===-1&&e[c].close>a[c-1]?s[c]=1:s[c-1]===1&&e[c].close<i[c-1]?s[c]=-1:s[c]=s[c-1]}return{trend:s,upper:a,lower:i}}function pj(e,t,n){if(e.length===0)return[];let r=[],o=new Array(e.length);for(let l=0;l<e.length;l++)o[l]=Number(e[l].ts/1000000n);let a=l=>{let c=0,u=o.length;for(;c<u;){let d=c+u>>>1;o[d]<l?c=d+1:u=d}return c},i=new Map,s=l=>{let c=i.get(l);if(c)return c;c=[];let u=-1/0;for(let d=0;d<o.length;d++){if(o[d]<u)continue;let m=Xn.fromMillis(o[d],{zone:l});c.push({year:m.year,month:m.month,day:m.day}),u=m.startOf("day").plus({days:1}).toMillis()}return i.set(l,c),c};for(let l of t){let c=l.tz??n?.tz??"UTC";for(let{year:u,month:d,day:m}of s(c)){let f=Xn.fromObject({year:u,month:d,day:m,hour:l.startHour,minute:l.startMinute,second:0,millisecond:0},{zone:c}),h=Xn.fromObject({year:u,month:d,day:m,hour:l.endHour,minute:l.endMinute,second:0,millisecond:0},{zone:c});h<=f&&(h=h.plus({days:1}));let p=f.toMillis(),g=h.toMillis(),y=-1/0,v=1/0;for(let b=a(p);b<o.length&&o[b]<g;b++)e[b].high>y&&(y=e[b].high),e[b].low<v&&(v=e[b].low);y===-1/0||v===1/0||r.push({startTs:BigInt(p)*1000000n,endTs:BigInt(g)*1000000n,high:y,low:v,label:l.label,color:l.color})}}return r.sort((l,c)=>l.startTs<c.startTs?-1:l.startTs>c.startTs?1:0),r}var _D={sma:Mg,ema:Am,wma:Lg,hma:iU,rma:Rg,linreg:sU,rsi:lU,stoch:cU,macd:uU,atr:lx,tr:RD,crossover:PD,crossunder:DD,cross:dU,rising:fU,falling:mU,change:pU,barssince:hU,valuewhen:gU,highest:Bm,lowest:Nm,pivotHigh:bU,pivotLow:yU,bb:BD,bbw:vU,donchian:wU,keltner:xU,vwap:SU,alligator:CU,stdev:ND,variance:kU,dev:TU,correlation:IU,max:MU,min:LU,median:RU,toPoints:PU,last:DU,nz:AU,obv:cj,mfi:uj,cci:dj,williamsR:fj,supertrend:mj,sessionBoundaries:pj,drawLine:BU,drawHLine:NU,drawHistogram:EU,drawLabel:OU,fillBetween:_U,drawRect:FU,drawCircle:zU,drawVLine:HU,drawArrow:VU,drawTrendLine:WU,drawBand:qU,drawPolygon:UU,drawDots:jU,drawBadge:GU};var hj=Object.freeze({indicator:"indicator",drawing:"drawing",chartType:"chart-type",dataSource:"data-source",extension:"extension"}),gj=Object.freeze({mbo:"l3",l3:"l3",l2:"l2",ohlcv:"ohlcv",tick:"tick"}),bj=Object.freeze({overlay:"overlay",pane:"pane"}),FD={PluginType:hj,DataLevel:gj,Layout:bj};function yj(e){if(!e)return null;try{return new Function(`return (${e})`)()}catch{return null}}function Em(e,t={},n){let r=null;try{let o={...FD,plugin:()=>({}),..._D,...t},a=Object.keys(o);r=new Function(...a,`"use strict";
|
|
91
|
+
${e}
|
|
92
|
+
;return function (__src) { return eval("(" + __src + ")"); };`)(...a.map(i=>o[i]))}catch(o){n?.(`could not build handler scope, falling back to global scope: ${o}`),r=null}return o=>{if(!o)return null;if(r)try{let a=r(o);if(typeof a=="function")return a}catch{}return yj(o)}}import kc from"react";function vj(e,t){switch(t.type){case"dualColor":case"dualOpacity":return[`${e}_a`,`${e}_b`];case"colorGradient":return[`${e}_start`,`${e}_end`];case"colorWithOpacity":return[`${e}_color`,`${e}_opacity`];case"toggledColor":return[`${e}_on`,`${e}_color`];case"toggledInput":return[`${e}_on`,`${e}_val`];case"inlineFields":return t.fields.map(n=>n.key);default:return[e]}}function HD(e,t,n){switch(t.type){case"dualColor":n[`${e}_a`]=t.defaultA,n[`${e}_b`]=t.defaultB;break;case"dualOpacity":n[`${e}_a`]=t.defaultA,n[`${e}_b`]=t.defaultB;break;case"colorGradient":n[`${e}_start`]=t.defaultStart,n[`${e}_end`]=t.defaultEnd;break;case"colorWithOpacity":n[`${e}_color`]=t.defaultColor,n[`${e}_opacity`]=t.defaultOpacity;break;case"toggledColor":n[`${e}_on`]=t.defaultToggle,n[`${e}_color`]=t.defaultColor;break;case"toggledInput":n[`${e}_on`]=t.defaultToggle,n[`${e}_val`]=t.defaultInput;break;case"inlineFields":for(let r of t.fields)n[r.key]=r.default;break;default:n[e]=t.default;break}}function ju(e,t,n,r,o){return{ohlcv:e==="ohlcv"||e==="tick"||e==="l3"?t:[],trades:e==="l3"?n:[],ticks:e==="tick"||e==="l3"?r:[],snapshots:e==="l2"||e==="l3"?o:[]}}function wj(e,t){if(!t.length)return e;let n=e.slice();for(let r of t){let o=BigInt(r.ts),a=n[n.length-1];if(a&&BigInt(a.ts)===o)n[n.length-1]={...a,high:Math.max(r.high,a.high),low:Math.min(r.low,a.low),close:r.close,volume:a.volume+r.volume};else{let i=!1;for(let s=n.length-2;s>=0;s--)if(BigInt(n[s].ts)===o){n[s]={...n[s],high:Math.max(r.high,n[s].high),low:Math.min(r.low,n[s].low),close:r.close,volume:n[s].volume+r.volume},i=!0;break}i||n.push(r)}}return n}function zD(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(31,t)+e.charCodeAt(n)|0;return t}var Pg="__scripted__";function VD(e){let t=[];for(let[n,r]of Object.entries(e)){let o="params",a={key:n,label:r.label,tab:o};switch(r.type){case"number":t.push({...a,type:"numberInput",min:r.min,max:r.max,step:r.step??1,unit:r.unit});break;case"stepperInt":t.push({...a,type:"stepperInt",min:r.min,max:r.max,step:r.step??1});break;case"slider":t.push({...a,type:"slider",min:r.min,max:r.max,step:r.step??1,suffix:r.suffix});break;case"rangeWithSteps":t.push({...a,type:"rangeWithSteps",min:r.min,max:r.max,steps:r.steps});break;case"opacity":t.push({...a,type:"opacity"});break;case"fontSize":t.push({...a,type:"fontSize"});break;case"color":t.push({...a,type:"color"});break;case"text":t.push({...a,type:"textInput",placeholder:r.placeholder,maxLength:r.maxLength});break;case"select":{let i=(r.options??[]).map(s=>typeof s=="string"?{value:s,label:s}:s);t.push({...a,type:"select",options:i});break}case"buttonGroup":t.push({...a,type:"buttonGroup",options:r.options});break;case"boolean":t.push({...a,type:"toggle"});break;case"checkbox":t.push({...a,type:"checkbox",description:r.description});break;case"dualColor":t.push({tab:o,label:r.label,type:"dualColor",keyA:`${n}_a`,labelA:r.labelA,keyB:`${n}_b`,labelB:r.labelB});break;case"dualOpacity":t.push({tab:o,label:r.label,type:"dualOpacity",keyA:`${n}_a`,labelA:r.labelA,keyB:`${n}_b`,labelB:r.labelB});break;case"colorGradient":t.push({tab:o,label:r.label,type:"colorGradient",keyStart:`${n}_start`,keyEnd:`${n}_end`});break;case"colorWithOpacity":t.push({tab:o,label:r.label,type:"colorWithOpacity",colorKey:`${n}_color`,opacityKey:`${n}_opacity`});break;case"toggledColor":t.push({tab:o,label:r.label,type:"toggledColor",toggleKey:`${n}_on`,colorKey:`${n}_color`});break;case"toggledInput":t.push({tab:o,type:"toggledInput",toggleKey:`${n}_on`,toggleLabel:r.toggleLabel,inputKey:`${n}_val`,inputLabel:r.inputLabel,min:r.min,max:r.max,step:r.step,unit:r.unit});break;case"inlineFields":t.push({tab:o,label:r.label,type:"inlineFields",fields:r.fields.map(i=>i.type==="stepperInt"?{type:"stepperInt",key:i.key,label:i.label,min:i.min,max:i.max,step:i.step}:i.type==="buttonGroup"?{type:"buttonGroup",key:i.key,options:i.options}:{type:"checkbox",key:i.key,label:i.label})});break}}return t}function WD(e){let t=[];for(let n of VD(e)){let{tab:r,...o}=n;if(o.type!=="section"){if(o.type==="slider"){let a=o.suffix??"",i=o.min+(o.max-o.min)/2;t.push({...o,step1:`${o.min}${a}`,step2:`${Math.round(i*100)/100}${a}`,step3:`${o.max}${a}`});continue}t.push(o)}}return t}function qD(e){let t={};for(let[n,r]of Object.entries(e))HD(n,r,t);return t}var xj=(e,t,n,r,o,a,i,s)=>{let l=t.decl,c=l.require??"ohlcv",u=l.layout??"overlay",d=t.drawCommands??[],m=Em(s(),{},i),f=m(t.drawDirectSrc),h=m(t.drawUISrc),p=t.initialState,g=[],y=l.params??{},v={};for(let[T,R]of Object.entries(y))HD(T,R,v);function b(){let T=l.lookback;return typeof T=="function"?T(v):T??0}let S=null,C=0n,w={id:n,name:l.name,visible:!0,layout:u,paneId:u==="overlay"?"main":n,category:l.category,shortName:l.shortName,description:l.description,require:c,settings:{...v},workerInit:Pg,workerUpdate:Pg,hydrate(T,R){},appendHydrate(T,R){},drawBase(T){if(d.length)try{ED(d,T)}catch(R){i(`draw error: ${R}`)}if(f)try{f(p,T)}catch(R){i(`drawDirect error: ${R}`)}},drawUI(T,R){if(h)try{h(p,T,R)}catch(P){i(`drawUI error: ${P}`)}},getAutoYBounds(T,R,P){let D=1/0,N=-1/0;for(let A of d){if(A.type!=="line"&&A.type!=="histogram")continue;let B=A.pts,E=0;{let L=0,z=B.length-1;for(;L<=z;){let Y=L+z>>>1;B[Y].t<T?L=Y+1:z=Y-1}E=L}for(let L=E;L<B.length;L++){let z=B[L].t;if(z>R||P!==0n&&z>P)break;let Y=B[L].price;isNaN(Y)||(Y<D&&(D=Y),Y>N&&(N=Y))}}if(!isFinite(D)||!isFinite(N))return null;let O=(N-D)*.1||1;return{min:D-O,max:N+O}}};Object.keys(y).length>0&&(w.settingsSchema=VD(y));let k=new Set;for(let[T,R]of Object.entries(y))for(let P of vj(T,R))k.add(P);w.__paramKeys=k,w.__onParamsChanged=T=>{Object.assign(v,T),S!==null&&e.postMessage({type:"run-init",pluginIndex:r,data:S,barNs:C,params:{...v}}),typeof l.lookback=="function"&&o.eventBus.emit("plugin:register-indicator",{indicator:w,activeByDefault:!1,pane:x,lookback:b()})},a(T=>{d=T.drawCommands??[],p=T.state??p,w.appendHydrate(T.points,0n),o.eventBus.emit("plugin:indicator-updated",{id:n});try{o.renderEngine.markDirty("base")}catch{}});let M=o.eventBus.on("plugin:scripted-compute",({id:T,ohlcv:R,trades:P,ticks:D,snapshots:N,barNs:O})=>{if(T!==n)return;g=R;let A=ju(c,R,P,D,N);S=A,C=O,e.postMessage({type:"run-init",pluginIndex:r,data:A,barNs:O,params:{...v}})}),I=o.eventBus.on("plugin:scripted-advance",({id:T,newOhlcv:R,newTrades:P,newTicks:D,newSnapshots:N,barNs:O,horizon:A})=>{if(T!==n)return;g=wj(g,R);let B=ju(c,g,P,D,N),E=ju(c,R,P,D,N);e.postMessage({type:"update",pluginIndex:r,data:B,newData:E,barNs:O,horizon:A,params:{...v}})}),x=u==="pane"?{id:n,isMain:!1,heightRatio:.8,yMin:0,yMax:0,yAxisAuto:!0,collapsed:!1}:void 0;return o.eventBus.emit("plugin:register-indicator",{indicator:w,activeByDefault:!1,pane:x,lookback:b()}),()=>{M(),I(),u==="pane"&&o.eventBus.emit("plugin:remove-pane",{id:n})}},Sj=(e,t,n,r,o,a,i,s)=>{let l=t.decl,c={},u=l.params??{},d=qD(u),m=x=>x&&typeof x=="object"?{...d,...x}:d,f=Em(s(),{},i),h=f(t.onRenderSrc),p=f(t.onHitTestSrc),g=f(t.onPreviewSrc),y=f(t.onMoveSrc),v=f(t.onPointerDownSrc),b=f(t.onPointerMoveSrc),S=f(t.onPointerUpSrc),C=f(t.onKeyDownSrc),w=f(t.onActivateSrc),k=f(t.onDeactivateSrc);if(!h)return i("Drawing plugin must define an onRender function."),()=>{};function M(x){return{...x,setDraft(T){x.setDraft({pluginToolId:n,...T})},commitDrawing(T){x.commitDrawing({pluginToolId:n,...T})}}}let I=io.register({id:n,name:l.name,icon:l.icon,cursor:l.cursor??"crosshair",anchorCount:l.anchorCount??2,render(x){try{h({...x,data:m(x.data),state:c})}catch(T){i(`onRender error: ${T}`)}},hitTest(x){let T={...x,data:m(x.data),state:c};if(!p)return Cj(T);try{return p(T)}catch(R){return i(`onHitTest error: ${R}`),!1}},onMove:y?x=>{try{return y({...x,data:m(x.data)})}catch(T){return i(`onMove error: ${T}`),x.data}}:void 0,preview:g??h?x=>{let T=g??h;try{T({...x,data:m(x.data),state:c})}catch(R){i(`onPreview error: ${R}`)}}:void 0,onPointerDown:v?x=>{try{return v({...x,tool:M(x.tool),state:c})}catch(T){i(`onPointerDown error: ${T}`)}}:void 0,onPointerMove:b?x=>{try{return b({...x,tool:M(x.tool),state:c})}catch(T){i(`onPointerMove error: ${T}`)}}:void 0,onPointerUp:S?x=>{try{return S({...x,tool:M(x.tool),state:c})}catch(T){i(`onPointerUp error: ${T}`)}}:void 0,onKeyDown:C?x=>{try{return C({...x,tool:M(x.tool),state:c})}catch(T){i(`onKeyDown error: ${T}`)}}:void 0,onActivate:w?x=>{try{w({...x,state:c})}catch(T){i(`onActivate error: ${T}`)}}:void 0,onDeactivate:k?()=>{try{k()}catch(x){i(`onDeactivate error: ${x}`)}}:void 0,settingsSchema:WD(u),defaultData:d});return o.eventBus.emit("plugin:register-drawing",{id:n,name:l.name,icon:l.icon}),()=>{I(),o.eventBus.emit("plugin:unregister-drawing",{id:n})}};function Cj(e){let{mx:t,my:n,anchors:r,w:o,h:a,oy:i,transformer:s}=e,l=7;for(let c=0;c<r.length;c++){let u=s.tsToX(r[c].ts,o),d=s.priceToY(r[c].price,a)+i;if(Math.hypot(t-u,n-d)<=l)return`a${c}`}if(r.length>=2){let c=r.map(p=>s.tsToX(p.ts,o)),u=r.map(p=>s.priceToY(p.price,a)+i),d=Math.min(...c),m=Math.max(...c),f=Math.min(...u),h=Math.max(...u);if(t>=d-l&&t<=m+l&&n>=f-l&&n<=h+l)return"body"}return!1}var kj=(e,t,n,r,o,a,i,s)=>{let l=t.decl,c=l.params??{},u=qD(c),d=Em(s(),{React:kc,h:kc.createElement},i),m=d(t.onDrawSrc),f=d(t.onGetAutoYBoundsSrc),h=d(t.onChartPointerDownSrc),p=d(t.onChartPointerMoveSrc),g=d(t.onChartPointerUpSrc),y=d(t.onChartKeyDownSrc),v=d(t.onChartActivateSrc),b=d(t.onChartDeactivateSrc),S=d(t.onBarHoverSrc),C=d(t.getTooltipSrc);if(!m)return i("Chart type plugin must define a draw function."),()=>{};let w=new Worker(sx(),{type:"module"}),k=t.initialState??{},M=null,I=0n;a(P=>{k=P.state??k,o.eventBus.emit("plugin:chart-type-updated",{id:n})}),w.onmessage=P=>{let D=P.data;if(D.type==="error"){i(D.error,D.line);return}D.type==="update"&&(D.points!==void 0&&x.appendHydrate?.(D.points,0n),k=D.state??k,o.eventBus.emit("plugin:chart-type-updated",{id:n}))},w.postMessage({type:"parse",script:s()});let x={id:n,name:l.name,version:l.version??"1.0.0",type:"chart-type",code:"",chartTypeId:n,label:l.name,icon:l.icon??null,require:l.require,settingsSchema:WD(c),defaultSettings:{...u},onSettingsChange(P){Object.assign(u,P),M!==null&&w.postMessage({type:"run-init",pluginIndex:0,data:M,barNs:I,params:{...u}})},workerInit:t.onDrawSrc?Pg:void 0,workerUpdate:t.onDrawSrc?Pg:void 0,hydrate(P,D){k=P},appendHydrate(P,D){P&&typeof P=="object"&&k&&typeof k=="object"?k={...k,...P}:P!==void 0&&(k=P)},draw(P){try{m(k,{...P,params:u})}catch(D){i(`draw error: ${D}`)}},getAutoYBounds:f?(P,D,N)=>{try{return f(P,D,N)}catch(O){return i(`getAutoYBounds error: ${O}`),null}}:void 0,onActivate:v?P=>{try{v(P)}catch(D){i(`onActivate error: ${D}`)}}:void 0,onDeactivate:b?()=>{try{b()}catch(P){i(`onDeactivate error: ${P}`)}}:void 0,onPointerDown:h?P=>{try{return h(P)}catch(D){i(`onPointerDown error: ${D}`)}}:void 0,onPointerMove:p?P=>{try{return p(P)}catch(D){i(`onPointerMove error: ${D}`)}}:void 0,onPointerUp:g?P=>{try{return g(P)}catch(D){i(`onPointerUp error: ${D}`)}}:void 0,onKeyDown:y?P=>{try{return y(P)}catch(D){i(`onKeyDown error: ${D}`)}}:void 0,onBarHover:S?(P,D,N)=>{try{S(P,D,N)}catch(O){i(`onBarHover error: ${O}`)}}:void 0,getTooltip:C?(P,D)=>{try{return C(P,D)}catch(N){return i(`getTooltip error: ${N}`),null}}:void 0,install(P){return()=>{}}};o.eventBus.emit("plugin:register-chart-type",{plugin:x});let T=o.eventBus.on("plugin:scripted-compute",({id:P,ohlcv:D,trades:N,ticks:O,snapshots:A,barNs:B})=>{if(P!==n)return;let E=ju(l.require??"ohlcv",D,N,O,A);M=E,I=B,w.postMessage({type:"run-init",pluginIndex:0,data:E,barNs:B,params:{...u}})}),R=o.eventBus.on("plugin:scripted-advance",({id:P,newOhlcv:D,newTrades:N,newTicks:O,newSnapshots:A,barNs:B,horizon:E})=>{if(P!==n)return;let L=ju(l.require??"ohlcv",D,N,O,A),z=ju(l.require??"ohlcv",D,N,O,A);w.postMessage({type:"update",pluginIndex:0,data:L,newData:z,barNs:B,horizon:E,params:{...u}})});return P=>{T(),R(),w.postMessage({type:"destroy"}),w.terminate(),o.eventBus.emit("plugin:unregister-chart-type",{id:n,hotReload:P?.hotReload})}},Tj=(e,t,n,r,o,a,i,s)=>{let l=t.onInstallSrc??null,c=t.extensionDrawSrc??null;if(!l)return()=>{};let u=Em(s(),{React:kc,h:kc.createElement},i),d=u(c),m=null,f={};function h(){let[y,v]=kc.useState(f);return kc.useEffect(()=>(m=v,()=>{m=null}),[]),d?d(y,o):null}let p=y=>(f=y,m?.(y),kc.createElement(h)),g;try{g=u(l)?.(o,p)}catch(y){i(`extension onInstall error: ${y}`)}return y=>{try{typeof g=="function"&&g()}catch{}}},Ij={indicator:xj,drawing:Sj,"chart-type":kj,extension:Tj};function Gu(e,t,n){let r=t??`scripted:${pn(8)}`,o="Plugin",a="1.0.0",i="indicator",s,l=[],c=[],u=n??"custom";return{id:r,get name(){return o},get version(){return a},get type(){return i},code:e,get require(){return s},get permissions(){return l},get origins(){return c},get category(){return u},install(d){let m=new Worker(sx(),{type:"module"}),f=e,h=zD(e),p=(k,M)=>d.eventBus.emit("plugin:script-error",{id:r,error:k,line:M}),g=[],y=[],v=new Map;m.onmessage=k=>{let M=k.data;if(M.type==="error"){p(M.error,M.line);return}if(M.type==="parsed"){for(let I of M.plugins)for(let x of g)x(I);return}if(M.type==="init"){for(let I of M.plugins)for(let x of y)x(I);return}if(M.type==="update"){let I=v.get(M.pluginIndex)??[];for(let x of I)x(M);return}};let b=k=>{g.push(k)},S=(k,M)=>{v.has(k)||v.set(k,[]),v.get(k).push(M)};m.postMessage({type:"parse",script:f});let C=d.eventBus.on("plugin:update-code",({id:k,code:M})=>{if(k!==r)return;let I=zD(M);I!==h&&(h=I,f=M,m.postMessage({type:"parse",script:f}))}),w=new Map;return b(k=>{let M=k.decl,I=`${r}:${k.index}`;o=M.name,i=M.type,a=M?.version??"1.0.0",s=M?.require,l=M?.permissions??[],c=M?.origins??[],M.category??(M.category=n),u=M.category??"custom";let x=Ij[M?.type??"indicator"];if(!x){p(`Unknown plugin type: '${M?.type}'`);return}let T=w.get(k.index);T&&T({hotReload:!0}),v.delete(k.index);let R=x(m,k,I,k.index,d,P=>S(k.index,P),p,()=>f);w.set(k.index,R),d.eventBus.emit("plugin:scripted-recompute",{id:I})}),()=>{C();for(let k of w.values())k();m.postMessage({type:"destroy"}),m.terminate()}},uninstall(d){}}}function Mj(e){if(typeof e=="bigint")return e;let t=typeof e=="number"?e:new Date(e).getTime();if(!Number.isFinite(t))throw new Error(`[ChristTrade] Invalid playback time: ${String(e)}`);return BigInt(Math.round(t))*1000000n}var Dg=class{constructor(t,n=0n){ae(this,"eventBus",t);ae(this,"isPlaying",!1);ae(this,"currentStepSize","5s");ae(this,"currentSpeed",1);ae(this,"currentMode","realtime");ae(this,"currentStepSnap",!1);ae(this,"currentTime");ae(this,"forwardOnly",!1);ae(this,"floorNs",0n);ae(this,"subscriptions",[]);this.currentTime=n,this.play=this.play.bind(this),this.pause=this.pause.bind(this),this.stepBack=this.stepBack.bind(this),this.stepForward=this.stepForward.bind(this),this.goTo=this.goTo.bind(this),this.setSpeed=this.setSpeed.bind(this),this.setStepSize=this.setStepSize.bind(this),this.setMode=this.setMode.bind(this),this.setStepSnap=this.setStepSnap.bind(this),this.subscribeToEvents()}play(){this.isPlaying||(this.isPlaying=!0,this.eventBus.emit("playback:play",void 0))}pause(){this.isPlaying&&(this.isPlaying=!1,this.eventBus.emit("playback:pause",void 0))}playing(){return this.isPlaying}stepSize(){return this.currentStepSize}setStepSize(t){this.eventBus.emit("playback:set-step-size",{step:t})}mode(){return this.currentMode}setMode(t){this.eventBus.emit("playback:set-mode",{mode:t})}stepSnap(){return this.currentStepSnap}setStepSnap(t){this.eventBus.emit("playback:set-step-snap",{snap:t})}speed(){return this.currentSpeed}setSpeed(t){this.eventBus.emit("playback:set-speed",{speed:t})}lockForward(t){this.forwardOnly=t,this.floorNs=t?this.currentTime:0n}floor(){return this.forwardOnly?this.floorNs:null}allows(t){return!this.forwardOnly||t>=this.floorNs}refuse(t){this.eventBus.emit("playback:blocked",{tNs:t,floorNs:this.floorNs})}stepBack(){if(this.forwardOnly){this.refuse(this.currentTime);return}this.eventBus.emit("playback:step-back",void 0)}stepForward(){this.eventBus.emit("playback:step-forward",void 0)}time(){return this.currentTime}goTo(t){let n=Mj(t);if(!this.allows(n)){this.refuse(n);return}this.eventBus.emit("playback:goto",{tNs:n})}subscribeToEvents(){let t=[this.eventBus.on("playback:play",()=>this.isPlaying=!0),this.eventBus.on("playback:pause",()=>this.isPlaying=!1),this.eventBus.on("playback:set-step-size",n=>this.currentStepSize=n.step),this.eventBus.on("playback:set-speed",n=>this.currentSpeed=n.speed),this.eventBus.on("playback:set-mode",n=>this.currentMode=n.mode),this.eventBus.on("playback:seek",n=>{this.currentTime=n.tNs,this.forwardOnly&&n.tNs>this.floorNs&&(this.floorNs=n.tNs)}),this.eventBus.on("playback:set-step-snap",n=>this.currentStepSnap=n.snap)];this.subscriptions=t}destroy(){this.subscriptions.forEach(t=>t())}};function ux(e){return{symbol:e,description:e,type:"crypto",dataLevel:"ohlcv",priceFormat:{minTick:.01,precision:2}}}function Lj(e){return Array.isArray(e)?e:e.symbols}var Rj=200,Ag=class{constructor(){ae(this,"bySymbol",new Map);ae(this,"byPrefix",[]);ae(this,"resolved",new Map);ae(this,"adapters",new Map);ae(this,"lastRequest",new Map);ae(this,"realtimeSinks",new Map)}register(t){for(let n of t.symbols??[])this.bySymbol.has(n)&&console.warn(`[DataSourceRegistry] '${n}' already registered - overwriting`),this.bySymbol.set(n,t);return t.prefix!==void 0&&(this.byPrefix.push({prefix:t.prefix,source:t}),this.byPrefix.sort((n,r)=>r.prefix.length-n.prefix.length)),!t.symbols?.length&&t.prefix===void 0&&console.warn("[DataSourceRegistry] source registered with no symbols and no prefix"),()=>{for(let n of t.symbols??[])this.bySymbol.get(n)===t&&this.bySymbol.delete(n);for(let n=this.byPrefix.length-1;n>=0;n--)this.byPrefix[n].source===t&&this.byPrefix.splice(n,1);this.adapters.delete(t),this.lastRequest.delete(t),this.realtimeSinks.delete(t);try{t.destroy?.()}catch(n){console.error("[DataSourceRegistry] destroy threw:",n)}this.resolved.clear()}}sourceFor(t){let n=this.bySymbol.get(t);return n||this.byPrefix.find(r=>t.startsWith(r.prefix))?.source}has(t){return this.sourceFor(t)!==void 0}adapterFor(t){let n=this.sourceFor(t);return n?this.adapterOf(n):null}getResolved(t){return this.resolved.get(t)??null}async resolve(t){let n=this.sourceFor(t);return n?this.adapterOf(n).resolveSymbol(t):null}async search(t){return(await Promise.all(this.sources().map(async r=>{try{return Lj(await this.adapterOf(r).searchSymbols(t))}catch(o){return console.error("[DataSourceRegistry] searchSymbols threw:",o),[]}}))).flat()}searchDebounceMs(){let t=null;for(let n of this.sources()){let r=this.capsOf(n),o=typeof r?.symbolSearchDebounceMs=="number"&&r.symbolSearchDebounceMs>=0?r.symbolSearchDebounceMs:r?.symbolSearch==="server"?Rj:null;o!==null&&(t===null||o>t)&&(t=o)}return t}handleTick(t){let n=!1;for(let[r,o]of this.realtimeSinks){if(!r.onTick)continue;let a=this.lastRequest.get(r);if(!a)continue;let i;try{i=r.onTick({symbol:a.symbol,trade:t,barNs:a.barNs})}catch(s){console.error("[DataSourceRegistry] onTick threw:",s);continue}i&&(o(i),n=!0)}return n}destroy(){for(let t of this.sources())try{t.destroy?.()}catch(n){console.error("[DataSourceRegistry] destroy threw:",n)}this.bySymbol.clear(),this.byPrefix.length=0,this.resolved.clear(),this.adapters.clear(),this.lastRequest.clear(),this.realtimeSinks.clear()}sources(){let t=new Set;for(let n of this.bySymbol.values())t.add(n);for(let{source:n}of this.byPrefix)t.add(n);return[...t]}capsOf(t){try{return t.getCapabilities?.()??null}catch(n){return console.error("[DataSourceRegistry] getCapabilities threw:",n),null}}adapterOf(t){let n=this.adapters.get(t);if(n)return n;let r={resolveSymbol:async o=>{let a=this.resolved.get(o);if(a)return a;let i;try{i=t.resolveSymbol?await t.resolveSymbol(o):ux(o)}catch(s){console.error(`[DataSourceRegistry] resolveSymbol('${o}') threw:`,s),i=ux(o)}return this.resolved.set(o,i),i},searchSymbols:async o=>{if(t.searchSymbols)return t.searchSymbols(o);let a=(t.symbols??[]).map(i=>this.resolved.get(i)??ux(i));return Ju(a,o)},fetchBars:o=>(this.lastRequest.set(t,{symbol:o.symbolInfo.symbol,barNs:o.timeframe.barNs}),t.fetchBars(o))};return t.fetchPreview&&(r.fetchPreview=o=>t.fetchPreview(o)),t.getCapabilities&&(r.getCapabilities=()=>this.capsOf(t)??{}),t.connect&&(r.connect=()=>t.connect()),(t.subscribeRealtime||t.onTick)&&(r.subscribeRealtime=o=>{this.realtimeSinks.set(t,o);let a=t.subscribeRealtime?.(o);return()=>{this.realtimeSinks.get(t)===o&&this.realtimeSinks.delete(t),a?.()}}),this.adapters.set(t,r),r}};var Pj=60n*1000000000n,Dj=200,Bg=class{constructor(t,n){ae(this,"eventBus",t);ae(this,"plugins",new Map);ae(this,"checkpoints",[]);ae(this,"lastCheckpointNs",0n);ae(this,"currentHorizonNs",0n);ae(this,"intervalNs");ae(this,"unsubs",[]);this.intervalNs=n?.intervalNs??Pj,this._wire()}register(t,n){return this.plugins.set(t,n),()=>{this.plugins.delete(t);for(let r of this.checkpoints)r.states.delete(t)}}onHorizonAdvance(t){if(this.currentHorizonNs=t,this.plugins.size!==0){if(this.lastCheckpointNs===0n){this.lastCheckpointNs=t,this._snapshot(t);return}t-this.lastCheckpointNs>=this.intervalNs&&(this._snapshot(t),this.lastCheckpointNs=t)}}_snapshot(t){let n=new Map;for(let[r,o]of this.plugins)try{n.set(r,o.serialize())}catch(a){console.warn(`[PlaybackStateRegistry] serialize() threw for '${r}':`,a)}this.checkpoints.push({horizonNs:t,states:n}),this.checkpoints.length>Dj&&this.checkpoints.shift()}restoreToNearest(t){if(this.checkpoints.length===0)return this._resetAll(),null;let n=0,r=this.checkpoints.length-1,o=-1;for(;n<=r;){let i=n+r>>1;this.checkpoints[i].horizonNs<=t?(o=i,n=i+1):r=i-1}if(o===-1)return this._resetAll(),null;let a=this.checkpoints[o];for(let[i,s]of this.plugins){let l=a.states.get(i);if(l!==void 0)try{s.restore(l)}catch(c){console.warn(`[PlaybackStateRegistry] restore() threw for '${i}':`,c)}}return this.checkpoints.splice(o+1),this.lastCheckpointNs=a.horizonNs,a.horizonNs}_resetAll(){this.eventBus.emit("playback:state-reset",void 0)}_wire(){let t=this.eventBus.on("data:append",r=>{if(r?.dataEnd){let o=BigInt(new Date(r.dataEnd).getTime());this.onHorizonAdvance(o*1000000n)}}),n=this.eventBus.on("playback:seek",({tNs:r})=>{if(r<this.currentHorizonNs){let o=this.restoreToNearest(r);this.eventBus.emit("playback:state-restored",{checkpointNs:o,targetNs:r})}});this.unsubs.push(t,n)}getCheckpointCount(){return this.checkpoints.length}destroy(){this.unsubs.forEach(t=>t()),this.plugins.clear(),this.checkpoints.length=0}};var Ng=class{constructor(){ae(this,"intervals",new Set);ae(this,"timeouts",new Set);ae(this,"rafIds",new Set);ae(this,"destroyed",!1)}interval(t,n){if(this.destroyed)return()=>{};let r=setInterval(()=>{try{n()}catch(o){console.error("[PluginSchedule] interval threw:",o)}},t);return this.intervals.add(r),()=>{clearInterval(r),this.intervals.delete(r)}}timeout(t,n){if(this.destroyed)return()=>{};let r;return r=setTimeout(()=>{try{n()}catch(o){console.error("[PluginSchedule] timeout threw:",o)}finally{this.timeouts.delete(r)}},t),this.timeouts.add(r),()=>{clearTimeout(r),this.timeouts.delete(r)}}raf(t){if(this.destroyed)return()=>{};let n;return n=requestAnimationFrame(()=>{try{t()}catch(r){console.error("[PluginSchedule] raf threw:",r)}finally{this.rafIds.delete(n)}}),this.rafIds.add(n),()=>{cancelAnimationFrame(n),this.rafIds.delete(n)}}destroy(){this.destroyed=!0,this.intervals.forEach(t=>clearInterval(t)),this.timeouts.forEach(t=>clearTimeout(t)),this.rafIds.forEach(t=>cancelAnimationFrame(t)),this.intervals.clear(),this.timeouts.clear(),this.rafIds.clear()}};function Yu(...e){typeof window>"u"||window.location.search.includes("plugintrace")&&console.log("[plugins]",...e)}function dx(){let e=qr(Cn.pluginStartup,{});return e&&typeof e=="object"?e:{}}function fx(e,t){let n=dx();return t===null?delete n[e]:n[e]={autostart:!1,...n[e],...t},kr(Cn.pluginStartup,n),Yu("record write",e,t,"->",JSON.stringify(n[e])),n}var UD=`
|
|
93
|
+
const alligatorIndi = plugin({
|
|
94
|
+
name: "Alligator",
|
|
95
|
+
shortName: "ALLI",
|
|
96
|
+
description: "Bill Williams' three displaced balance lines",
|
|
97
|
+
type: PluginType.indicator,
|
|
98
|
+
require: DataLevel.ohlcv,
|
|
99
|
+
version: "1.0.0",
|
|
100
|
+
lookback: 100,
|
|
101
|
+
params: {
|
|
102
|
+
jawShift: { label: "Jaw shift", type: "stepperInt", default: 8, min: 0, max: 50 },
|
|
103
|
+
teethShift: { label: "Teeth shift", type: "stepperInt", default: 5, min: 0, max: 50 },
|
|
104
|
+
lipsShift: { label: "Lips shift", type: "stepperInt", default: 3, min: 0, max: 50 }
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const JAW = "#08b3de"
|
|
109
|
+
const TEETH = "#ef5350"
|
|
110
|
+
const LIPS = "#26a69a"
|
|
111
|
+
|
|
112
|
+
alligatorIndi.init = function({ data, barNs, params }) {
|
|
113
|
+
const bars = data.ohlcv
|
|
114
|
+
const n = bars.length
|
|
115
|
+
if (!n) return { jaw: [], teeth: [], lips: [] }
|
|
116
|
+
|
|
117
|
+
const { jaw, teeth, lips } = alligator(bars)
|
|
118
|
+
const tsAt = i => i < n ? bars[i].ts : bars[n - 1].ts + BigInt(i - n + 1) * barNs
|
|
119
|
+
|
|
120
|
+
const shifted = (values, shift) => {
|
|
121
|
+
const step = barNs > 0n ? shift : 0
|
|
122
|
+
const out = []
|
|
123
|
+
for (let i = 0; i < n; i++) {
|
|
124
|
+
if (isNaN(values[i])) continue
|
|
125
|
+
out.push({ t: tsAt(i + step), price: values[i] })
|
|
126
|
+
}
|
|
127
|
+
return out
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
jaw: shifted(jaw, params.jawShift),
|
|
132
|
+
teeth: shifted(teeth, params.teethShift),
|
|
133
|
+
lips: shifted(lips, params.lipsShift)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
alligatorIndi.draw = function(s) {
|
|
138
|
+
return [
|
|
139
|
+
drawLine(s.jaw, JAW, 1),
|
|
140
|
+
drawLine(s.teeth, TEETH, 1),
|
|
141
|
+
drawLine(s.lips, LIPS, 1)
|
|
142
|
+
]
|
|
143
|
+
}`;var jD=`
|
|
144
|
+
const atrIndi = plugin({
|
|
145
|
+
name: "Average True Range",
|
|
146
|
+
shortName: "ATR",
|
|
147
|
+
description: "Wilder-smoothed range, in price units",
|
|
148
|
+
type: PluginType.indicator,
|
|
149
|
+
require: DataLevel.ohlcv,
|
|
150
|
+
layout: Layout.pane,
|
|
151
|
+
version: "1.0.0",
|
|
152
|
+
lookback: 150,
|
|
153
|
+
params: {
|
|
154
|
+
length: { label: "Length", type: "number", default: 14, min: 1, max: 300 },
|
|
155
|
+
smoothing: { label: "Average", type: "number", default: 0, min: 0, max: 300 },
|
|
156
|
+
line: { label: "ATR", type: "color", default: "#f5a623" },
|
|
157
|
+
avg: { label: "Average", type: "color", default: "#787b86" }
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
atrIndi.init = function({ data, params }) {
|
|
162
|
+
const bars = data.ohlcv
|
|
163
|
+
const ts = bars.map(b => b.ts)
|
|
164
|
+
const values = atr(bars, params.length)
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
atr: toPoints(ts, values),
|
|
168
|
+
avg: params.smoothing >= 2 ? toPoints(ts, sma(values, params.smoothing)) : [],
|
|
169
|
+
line: params.line,
|
|
170
|
+
avgColor: params.avg
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
atrIndi.draw = function(s) {
|
|
175
|
+
const out = [
|
|
176
|
+
fillBetween(s.atr, 0, { mode: 'solid', color: s.line + '14' }),
|
|
177
|
+
drawLine(s.atr, s.line, 2)
|
|
178
|
+
]
|
|
179
|
+
|
|
180
|
+
if (s.avg.length) out.push(drawLine(s.avg, s.avgColor, 1, [4, 4]))
|
|
181
|
+
return out
|
|
182
|
+
}`;var GD=`
|
|
183
|
+
const awesome = plugin({
|
|
184
|
+
name: "Awesome Oscillator",
|
|
185
|
+
shortName: "AO",
|
|
186
|
+
description: "Fast minus slow median-price average",
|
|
187
|
+
type: PluginType.indicator,
|
|
188
|
+
require: DataLevel.ohlcv,
|
|
189
|
+
layout: Layout.pane,
|
|
190
|
+
version: "1.0.0",
|
|
191
|
+
lookback: 150,
|
|
192
|
+
params: {
|
|
193
|
+
fast: { label: "Fast", type: "number", default: 5, min: 1, max: 200 },
|
|
194
|
+
slow: { label: "Slow", type: "number", default: 34, min: 2, max: 400 },
|
|
195
|
+
up: { label: "Rising", type: "color", default: "#26a69a" },
|
|
196
|
+
down: { label: "Falling", type: "color", default: "#ef5350" }
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
awesome.init = function({ data, params }) {
|
|
201
|
+
const bars = data.ohlcv
|
|
202
|
+
const hl2 = bars.map(b => (b.high + b.low) / 2)
|
|
203
|
+
const fast = sma(hl2, params.fast)
|
|
204
|
+
const slow = sma(hl2, params.slow)
|
|
205
|
+
|
|
206
|
+
const pts = []
|
|
207
|
+
const colors = []
|
|
208
|
+
let prev = NaN
|
|
209
|
+
|
|
210
|
+
for (let i = 0; i < bars.length; i++) {
|
|
211
|
+
const v = fast[i] - slow[i]
|
|
212
|
+
if (isNaN(v)) continue
|
|
213
|
+
pts.push({ t: bars[i].ts, price: v })
|
|
214
|
+
colors.push(isNaN(prev) || v >= prev ? params.up : params.down)
|
|
215
|
+
prev = v
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return { pts, colors }
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
awesome.draw = function(s) {
|
|
222
|
+
return [
|
|
223
|
+
drawHistogram(s.pts, s.colors, 0, 0.25),
|
|
224
|
+
drawHLine(0, "#ffffff1f", 1)
|
|
225
|
+
]
|
|
226
|
+
}`;var YD=`
|
|
227
|
+
const bollinger = plugin({
|
|
228
|
+
name: "Bollinger Bands",
|
|
229
|
+
shortName: "BB",
|
|
230
|
+
description: "Standard-deviation envelope around a moving average",
|
|
231
|
+
type: PluginType.indicator,
|
|
232
|
+
require: DataLevel.ohlcv,
|
|
233
|
+
version: "1.0.0",
|
|
234
|
+
lookback: 120,
|
|
235
|
+
params: {
|
|
236
|
+
length: { label: "Length", type: "number", default: 20, min: 2, max: 500 },
|
|
237
|
+
mult: { label: "Std dev", type: "number", default: 2, min: 0.1, max: 10, step: 0.1 },
|
|
238
|
+
band: { label: "Bands", type: "color", default: "#08b3de" },
|
|
239
|
+
basis: { label: "Basis", type: "color", default: "#f5a623" },
|
|
240
|
+
fill: { label: "Shade channel", type: "boolean", default: true }
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
bollinger.init = function({ data, params }) {
|
|
245
|
+
const bars = data.ohlcv
|
|
246
|
+
const ts = bars.map(b => b.ts)
|
|
247
|
+
const { upper, mid, lower } = bb(bars, params.length, params.mult)
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
upper: toPoints(ts, upper),
|
|
251
|
+
mid: toPoints(ts, mid),
|
|
252
|
+
lower: toPoints(ts, lower),
|
|
253
|
+
band: params.band,
|
|
254
|
+
basis: params.basis,
|
|
255
|
+
fill: params.fill
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
bollinger.draw = function(s) {
|
|
260
|
+
const out = []
|
|
261
|
+
|
|
262
|
+
if (s.fill) {
|
|
263
|
+
out.push(fillBetween(s.upper, s.lower, { mode: 'solid', color: s.band + '12' }))
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
out.push(drawLine(s.upper, s.band, 1))
|
|
267
|
+
out.push(drawLine(s.lower, s.band, 1))
|
|
268
|
+
out.push(drawLine(s.mid, s.basis, 1, [5, 4]))
|
|
269
|
+
|
|
270
|
+
return out
|
|
271
|
+
}`;var KD=`
|
|
272
|
+
const cciIndi = plugin({
|
|
273
|
+
name: "Commodity Channel Index",
|
|
274
|
+
shortName: "CCI",
|
|
275
|
+
description: "Typical price against its mean deviation",
|
|
276
|
+
type: PluginType.indicator,
|
|
277
|
+
require: DataLevel.ohlcv,
|
|
278
|
+
layout: Layout.pane,
|
|
279
|
+
version: "1.0.0",
|
|
280
|
+
lookback: 100,
|
|
281
|
+
params: {
|
|
282
|
+
length: { label: "Length", type: "number", default: 20, min: 2, max: 300 },
|
|
283
|
+
level: { label: "Level", type: "number", default: 100, min: 10, max: 400 },
|
|
284
|
+
line: { label: "CCI", type: "color", default: "#08b3de" }
|
|
285
|
+
}
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
cciIndi.init = function({ data, params }) {
|
|
289
|
+
const bars = data.ohlcv
|
|
290
|
+
const values = cci(bars, params.length)
|
|
291
|
+
|
|
292
|
+
return {
|
|
293
|
+
cci: toPoints(bars.map(b => b.ts), values),
|
|
294
|
+
level: params.level,
|
|
295
|
+
line: params.line
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
cciIndi.draw = function(s) {
|
|
300
|
+
return [
|
|
301
|
+
fillBetween(s.level, -s.level, { mode: 'solid', color: '#ffffff08' }),
|
|
302
|
+
drawHLine(s.level, "#ffffff1f", 1, [4, 4]),
|
|
303
|
+
drawHLine(0, "#ffffff12", 1),
|
|
304
|
+
drawHLine(-s.level, "#ffffff1f", 1, [4, 4]),
|
|
305
|
+
drawLine(s.cci, s.line, 2)
|
|
306
|
+
]
|
|
307
|
+
}`;var $D=`
|
|
308
|
+
const donchianIndi = plugin({
|
|
309
|
+
name: "Donchian Channels",
|
|
310
|
+
shortName: "DC",
|
|
311
|
+
description: "Rolling highest high and lowest low",
|
|
312
|
+
type: PluginType.indicator,
|
|
313
|
+
require: DataLevel.ohlcv,
|
|
314
|
+
version: "1.0.0",
|
|
315
|
+
lookback: 100,
|
|
316
|
+
params: {
|
|
317
|
+
length: { label: "Length", type: "number", default: 20, min: 2, max: 500 },
|
|
318
|
+
upper: { label: "Upper", type: "color", default: "#26a69a" },
|
|
319
|
+
lower: { label: "Lower", type: "color", default: "#ef5350" },
|
|
320
|
+
showMid:{ label: "Show midline", type: "checkbox", default: true }
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
donchianIndi.init = function({ data, params }) {
|
|
325
|
+
const bars = data.ohlcv
|
|
326
|
+
const ts = bars.map(b => b.ts)
|
|
327
|
+
const { upper, mid, lower } = donchian(bars, params.length)
|
|
328
|
+
|
|
329
|
+
return {
|
|
330
|
+
upper: toPoints(ts, upper),
|
|
331
|
+
mid: params.showMid ? toPoints(ts, mid) : [],
|
|
332
|
+
lower: toPoints(ts, lower),
|
|
333
|
+
upperColor: params.upper,
|
|
334
|
+
lowerColor: params.lower
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
donchianIndi.draw = function(s) {
|
|
339
|
+
const out = [
|
|
340
|
+
fillBetween(s.upper, s.lower, { mode: 'solid', color: '#ffffff08' }),
|
|
341
|
+
drawLine(s.upper, s.upperColor, 1),
|
|
342
|
+
drawLine(s.lower, s.lowerColor, 1)
|
|
343
|
+
]
|
|
344
|
+
|
|
345
|
+
if (s.mid.length) out.push(drawLine(s.mid, '#787b86', 1, [4, 4]))
|
|
346
|
+
return out
|
|
347
|
+
}`;var XD=`
|
|
348
|
+
const ichimoku = plugin({
|
|
349
|
+
name: "Ichimoku Cloud",
|
|
350
|
+
shortName: "ICH",
|
|
351
|
+
description: "Tenkan, Kijun and the forward-projected kumo",
|
|
352
|
+
type: PluginType.indicator,
|
|
353
|
+
require: DataLevel.ohlcv,
|
|
354
|
+
version: "1.0.0",
|
|
355
|
+
lookback: 200,
|
|
356
|
+
params: {
|
|
357
|
+
conversion: { label: "Conversion", type: "number", default: 9, min: 1, max: 200 },
|
|
358
|
+
base: { label: "Base", type: "number", default: 26, min: 1, max: 400 },
|
|
359
|
+
spanB: { label: "Span B", type: "number", default: 52, min: 1, max: 600 },
|
|
360
|
+
displace: { label: "Displacement", type: "number", default: 26, min: 0, max: 200 },
|
|
361
|
+
lagging: { label: "Lagging span", type: "checkbox", default: true }
|
|
362
|
+
}
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
const TENKAN = "#08b3de"
|
|
366
|
+
const KIJUN = "#ef5350"
|
|
367
|
+
const SPAN_A = "#26a69a"
|
|
368
|
+
const SPAN_B = "#f5a623"
|
|
369
|
+
const LAG = "#9d8cd6"
|
|
370
|
+
|
|
371
|
+
function midChannel(highs, lows, period) {
|
|
372
|
+
const hi = highest(highs, period)
|
|
373
|
+
const lo = lowest(lows, period)
|
|
374
|
+
const out = new Array(highs.length)
|
|
375
|
+
for (let i = 0; i < out.length; i++) out[i] = (hi[i] + lo[i]) / 2
|
|
376
|
+
return out
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
ichimoku.init = function({ data, barNs, params }) {
|
|
380
|
+
const bars = data.ohlcv
|
|
381
|
+
const n = bars.length
|
|
382
|
+
if (!n) return { tenkan: [], kijun: [], spanA: [], spanB: [], lagging: [], cloud: [] }
|
|
383
|
+
|
|
384
|
+
const highs = bars.map(b => b.high)
|
|
385
|
+
const lows = bars.map(b => b.low)
|
|
386
|
+
|
|
387
|
+
const tenkan = midChannel(highs, lows, params.conversion)
|
|
388
|
+
const kijun = midChannel(highs, lows, params.base)
|
|
389
|
+
const spanBRaw = midChannel(highs, lows, params.spanB)
|
|
390
|
+
const spanARaw = new Array(n)
|
|
391
|
+
for (let i = 0; i < n; i++) spanARaw[i] = (tenkan[i] + kijun[i]) / 2
|
|
392
|
+
|
|
393
|
+
// The kumo is plotted \`displace\` bars ahead, so the last stretch sits past
|
|
394
|
+
// the newest bar - those timestamps have to be extrapolated from barNs.
|
|
395
|
+
const shift = barNs > 0n ? params.displace : 0
|
|
396
|
+
const tsAt = i => i < n ? bars[i].ts : bars[n - 1].ts + BigInt(i - n + 1) * barNs
|
|
397
|
+
|
|
398
|
+
// Both spans are pushed together so the two arrays stay index-aligned -
|
|
399
|
+
// cloudRuns pairs them positionally.
|
|
400
|
+
const spanA = []
|
|
401
|
+
const spanB = []
|
|
402
|
+
for (let i = 0; i < n; i++) {
|
|
403
|
+
if (isNaN(spanARaw[i]) || isNaN(spanBRaw[i])) continue
|
|
404
|
+
const t = tsAt(i + shift)
|
|
405
|
+
spanA.push({ t, price: spanARaw[i] })
|
|
406
|
+
spanB.push({ t, price: spanBRaw[i] })
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const lagging = []
|
|
410
|
+
if (params.lagging) {
|
|
411
|
+
for (let i = shift; i < n; i++) lagging.push({ t: bars[i - shift].ts, price: bars[i].close })
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return {
|
|
415
|
+
tenkan: toPoints(bars.map(b => b.ts), tenkan),
|
|
416
|
+
kijun: toPoints(bars.map(b => b.ts), kijun),
|
|
417
|
+
spanA,
|
|
418
|
+
spanB,
|
|
419
|
+
lagging,
|
|
420
|
+
cloud: cloudRuns(spanA, spanB)
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Split the kumo where A and B cross so each run can be filled on its own.
|
|
425
|
+
function cloudRuns(spanA, spanB) {
|
|
426
|
+
const len = spanA.length
|
|
427
|
+
const runs = []
|
|
428
|
+
let start = 0
|
|
429
|
+
|
|
430
|
+
for (let i = 1; i < len; i++) {
|
|
431
|
+
const before = spanA[i - 1].price >= spanB[i - 1].price
|
|
432
|
+
if ((spanA[i].price >= spanB[i].price) === before) continue
|
|
433
|
+
runs.push({ a: spanA.slice(start, i), b: spanB.slice(start, i), bullish: before })
|
|
434
|
+
start = i
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (start < len) {
|
|
438
|
+
runs.push({
|
|
439
|
+
a: spanA.slice(start),
|
|
440
|
+
b: spanB.slice(start),
|
|
441
|
+
bullish: spanA[start].price >= spanB[start].price
|
|
442
|
+
})
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return runs
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
ichimoku.draw = function(s) {
|
|
449
|
+
const out = []
|
|
450
|
+
|
|
451
|
+
for (const run of s.cloud) {
|
|
452
|
+
out.push(fillBetween(run.a, run.b, {
|
|
453
|
+
mode: 'solid',
|
|
454
|
+
color: run.bullish ? SPAN_A + '20' : SPAN_B + '20'
|
|
455
|
+
}))
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
out.push(drawLine(s.spanA, SPAN_A, 1))
|
|
459
|
+
out.push(drawLine(s.spanB, SPAN_B, 1))
|
|
460
|
+
out.push(drawLine(s.kijun, KIJUN, 1))
|
|
461
|
+
out.push(drawLine(s.tenkan, TENKAN, 1))
|
|
462
|
+
if (s.lagging.length) out.push(drawLine(s.lagging, LAG, 1, [3, 3]))
|
|
463
|
+
|
|
464
|
+
return out
|
|
465
|
+
}`;var ZD=`
|
|
466
|
+
const keltnerIndi = plugin({
|
|
467
|
+
name: "Keltner Channels",
|
|
468
|
+
shortName: "KC",
|
|
469
|
+
description: "ATR envelope around an exponential basis",
|
|
470
|
+
type: PluginType.indicator,
|
|
471
|
+
require: DataLevel.ohlcv,
|
|
472
|
+
version: "1.0.0",
|
|
473
|
+
lookback: 150,
|
|
474
|
+
params: {
|
|
475
|
+
length: { label: "Length", type: "number", default: 20, min: 2, max: 500 },
|
|
476
|
+
atrLength: { label: "ATR length", type: "number", default: 10, min: 1, max: 500 },
|
|
477
|
+
mult: { label: "Multiplier", type: "number", default: 1.5, min: 0.1, max: 10, step: 0.1 },
|
|
478
|
+
band: { label: "Channel", type: "color", default: "#26a69a" },
|
|
479
|
+
basis: { label: "Basis", type: "color", default: "#f5a623" }
|
|
480
|
+
}
|
|
481
|
+
})
|
|
482
|
+
|
|
483
|
+
keltnerIndi.init = function({ data, params }) {
|
|
484
|
+
const bars = data.ohlcv
|
|
485
|
+
const ts = bars.map(b => b.ts)
|
|
486
|
+
const { upper, mid, lower } = keltner(bars, params.length, params.atrLength, params.mult)
|
|
487
|
+
|
|
488
|
+
return {
|
|
489
|
+
upper: toPoints(ts, upper),
|
|
490
|
+
mid: toPoints(ts, mid),
|
|
491
|
+
lower: toPoints(ts, lower),
|
|
492
|
+
band: params.band,
|
|
493
|
+
basis: params.basis
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
keltnerIndi.draw = function(s) {
|
|
498
|
+
return [
|
|
499
|
+
fillBetween(s.upper, s.lower, { mode: 'solid', color: s.band + '10' }),
|
|
500
|
+
drawLine(s.upper, s.band, 1),
|
|
501
|
+
drawLine(s.lower, s.band, 1),
|
|
502
|
+
drawLine(s.mid, s.basis, 1, [5, 4])
|
|
503
|
+
]
|
|
504
|
+
}`;var QD=`
|
|
505
|
+
const macdIndi = plugin({
|
|
506
|
+
name: "MACD",
|
|
507
|
+
shortName: "MACD",
|
|
508
|
+
description: "Moving average convergence / divergence",
|
|
509
|
+
type: PluginType.indicator,
|
|
510
|
+
require: DataLevel.ohlcv,
|
|
511
|
+
layout: Layout.pane,
|
|
512
|
+
version: "1.0.0",
|
|
513
|
+
lookback: 200,
|
|
514
|
+
params: {
|
|
515
|
+
fast: { label: "Fast", type: "number", default: 12, min: 1, max: 400 },
|
|
516
|
+
slow: { label: "Slow", type: "number", default: 26, min: 1, max: 600 },
|
|
517
|
+
signal: { label: "Signal", type: "number", default: 9, min: 1, max: 200 },
|
|
518
|
+
macdColor: { label: "MACD", type: "color", default: "#08b3de" },
|
|
519
|
+
signalColor: { label: "Signal", type: "color", default: "#f5a623" }
|
|
520
|
+
}
|
|
521
|
+
})
|
|
522
|
+
|
|
523
|
+
const UP = "#26a69a"
|
|
524
|
+
const DOWN = "#ef5350"
|
|
525
|
+
|
|
526
|
+
macdIndi.init = function({ data, params }) {
|
|
527
|
+
const bars = data.ohlcv
|
|
528
|
+
const ts = bars.map(b => b.ts)
|
|
529
|
+
const { macd: line, signal, histogram } = macd(bars, params.fast, params.slow, params.signal)
|
|
530
|
+
|
|
531
|
+
// Four-tone histogram: shade by sign, brightness by whether it's growing.
|
|
532
|
+
const hist = []
|
|
533
|
+
const colors = []
|
|
534
|
+
for (let i = 0; i < histogram.length; i++) {
|
|
535
|
+
const v = histogram[i]
|
|
536
|
+
if (isNaN(v)) continue
|
|
537
|
+
const growing = i === 0 || isNaN(histogram[i - 1]) || Math.abs(v) >= Math.abs(histogram[i - 1])
|
|
538
|
+
hist.push({ t: ts[i], price: v })
|
|
539
|
+
colors.push((v >= 0 ? UP : DOWN) + (growing ? 'ff' : '66'))
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
return {
|
|
543
|
+
line: toPoints(ts, line),
|
|
544
|
+
signal: toPoints(ts, signal),
|
|
545
|
+
hist,
|
|
546
|
+
colors,
|
|
547
|
+
macdColor: params.macdColor,
|
|
548
|
+
signalColor: params.signalColor
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
macdIndi.draw = function(s) {
|
|
553
|
+
return [
|
|
554
|
+
drawHistogram(s.hist, s.colors, 0, 0.25),
|
|
555
|
+
drawHLine(0, "#ffffff1f", 1),
|
|
556
|
+
drawLine(s.line, s.macdColor, 2),
|
|
557
|
+
drawLine(s.signal, s.signalColor, 1)
|
|
558
|
+
]
|
|
559
|
+
}`;var JD=`
|
|
560
|
+
const movingAverage = plugin({
|
|
561
|
+
name: "Moving Average",
|
|
562
|
+
shortName: "MA",
|
|
563
|
+
description: "Fast / slow pair, any method, any source",
|
|
564
|
+
type: PluginType.indicator,
|
|
565
|
+
require: DataLevel.ohlcv,
|
|
566
|
+
version: "1.0.0",
|
|
567
|
+
lookback: 250,
|
|
568
|
+
params: {
|
|
569
|
+
method: { label: "Method", type: "select", default: "EMA", options: [
|
|
570
|
+
{ value: "SMA", label: "Simple" },
|
|
571
|
+
{ value: "EMA", label: "Exponential" },
|
|
572
|
+
{ value: "WMA", label: "Weighted" },
|
|
573
|
+
{ value: "HMA", label: "Hull" },
|
|
574
|
+
{ value: "RMA", label: "Wilder" }
|
|
575
|
+
] },
|
|
576
|
+
source: { label: "Source", type: "select", default: "close", options: [
|
|
577
|
+
{ value: "close", label: "Close" },
|
|
578
|
+
{ value: "open", label: "Open" },
|
|
579
|
+
{ value: "high", label: "High" },
|
|
580
|
+
{ value: "low", label: "Low" },
|
|
581
|
+
{ value: "hl2", label: "HL/2" },
|
|
582
|
+
{ value: "hlc3", label: "HLC/3" },
|
|
583
|
+
{ value: "ohlc4", label: "OHLC/4" }
|
|
584
|
+
] },
|
|
585
|
+
fast: { label: "Fast", type: "number", default: 21, min: 2, max: 1000 },
|
|
586
|
+
slow: { label: "Slow", type: "number", default: 50, min: 0, max: 1000 },
|
|
587
|
+
fastColor: { label: "Fast", type: "color", default: "#08b3de" },
|
|
588
|
+
slowColor: { label: "Slow", type: "color", default: "#f5a623" },
|
|
589
|
+
width: { label: "Width", type: "stepperInt", default: 2, min: 1, max: 4 }
|
|
590
|
+
}
|
|
591
|
+
})
|
|
592
|
+
|
|
593
|
+
const SOURCE = {
|
|
594
|
+
close: b => b.close,
|
|
595
|
+
open: b => b.open,
|
|
596
|
+
high: b => b.high,
|
|
597
|
+
low: b => b.low,
|
|
598
|
+
hl2: b => (b.high + b.low) / 2,
|
|
599
|
+
hlc3: b => (b.high + b.low + b.close) / 3,
|
|
600
|
+
ohlc4: b => (b.open + b.high + b.low + b.close) / 4
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const METHOD = { SMA: sma, EMA: ema, WMA: wma, HMA: hma, RMA: rma }
|
|
604
|
+
|
|
605
|
+
movingAverage.init = function({ data, params }) {
|
|
606
|
+
const bars = data.ohlcv
|
|
607
|
+
const ts = bars.map(b => b.ts)
|
|
608
|
+
const src = bars.map(SOURCE[params.source] || SOURCE.close)
|
|
609
|
+
const avg = METHOD[params.method] || ema
|
|
610
|
+
|
|
611
|
+
return {
|
|
612
|
+
fast: toPoints(ts, avg(src, params.fast)),
|
|
613
|
+
slow: params.slow >= 2 ? toPoints(ts, avg(src, params.slow)) : [],
|
|
614
|
+
fastColor: params.fastColor,
|
|
615
|
+
slowColor: params.slowColor,
|
|
616
|
+
width: params.width
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
movingAverage.draw = function(s) {
|
|
621
|
+
const out = [drawLine(s.fast, s.fastColor, s.width)]
|
|
622
|
+
if (s.slow.length) out.push(drawLine(s.slow, s.slowColor, s.width))
|
|
623
|
+
return out
|
|
624
|
+
}`;var eA=`
|
|
625
|
+
const mfiIndi = plugin({
|
|
626
|
+
name: "Money Flow Index",
|
|
627
|
+
shortName: "MFI",
|
|
628
|
+
description: "Volume-weighted RSI of the typical price",
|
|
629
|
+
type: PluginType.indicator,
|
|
630
|
+
require: DataLevel.ohlcv,
|
|
631
|
+
layout: Layout.pane,
|
|
632
|
+
version: "1.0.0",
|
|
633
|
+
lookback: 100,
|
|
634
|
+
params: {
|
|
635
|
+
length: { label: "Length", type: "number", default: 14, min: 2, max: 200 },
|
|
636
|
+
overbought: { label: "Overbought", type: "number", default: 80, min: 50, max: 100 },
|
|
637
|
+
oversold: { label: "Oversold", type: "number", default: 20, min: 0, max: 50 },
|
|
638
|
+
line: { label: "MFI", type: "color", default: "#26a69a" }
|
|
639
|
+
}
|
|
640
|
+
})
|
|
641
|
+
|
|
642
|
+
mfiIndi.init = function({ data, params }) {
|
|
643
|
+
const bars = data.ohlcv
|
|
644
|
+
|
|
645
|
+
return {
|
|
646
|
+
mfi: toPoints(bars.map(b => b.ts), mfi(bars, params.length)),
|
|
647
|
+
overbought: params.overbought,
|
|
648
|
+
oversold: params.oversold,
|
|
649
|
+
line: params.line
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
mfiIndi.draw = function(s) {
|
|
654
|
+
return [
|
|
655
|
+
fillBetween(s.overbought, s.oversold, { mode: 'solid', color: '#ffffff08' }),
|
|
656
|
+
drawHLine(s.overbought, "#ffffff1f", 1, [4, 4]),
|
|
657
|
+
drawHLine(s.oversold, "#ffffff1f", 1, [4, 4]),
|
|
658
|
+
drawLine(s.mfi, s.line, 2)
|
|
659
|
+
]
|
|
660
|
+
}`;var tA=`
|
|
661
|
+
const obvIndi = plugin({
|
|
662
|
+
name: "On-Balance Volume",
|
|
663
|
+
shortName: "OBV",
|
|
664
|
+
description: "Running volume signed by the close",
|
|
665
|
+
type: PluginType.indicator,
|
|
666
|
+
require: DataLevel.ohlcv,
|
|
667
|
+
layout: Layout.pane,
|
|
668
|
+
version: "1.0.0",
|
|
669
|
+
lookback: 200,
|
|
670
|
+
params: {
|
|
671
|
+
smoothing: { label: "Average", type: "number", default: 20, min: 0, max: 500 },
|
|
672
|
+
line: { label: "OBV", type: "color", default: "#08b3de" },
|
|
673
|
+
avg: { label: "Average", type: "color", default: "#f5a623" }
|
|
674
|
+
}
|
|
675
|
+
})
|
|
676
|
+
|
|
677
|
+
obvIndi.init = function({ data, params }) {
|
|
678
|
+
const bars = data.ohlcv
|
|
679
|
+
const ts = bars.map(b => b.ts)
|
|
680
|
+
const values = obv(bars)
|
|
681
|
+
|
|
682
|
+
return {
|
|
683
|
+
obv: toPoints(ts, values),
|
|
684
|
+
avg: params.smoothing >= 2 ? toPoints(ts, ema(values, params.smoothing)) : [],
|
|
685
|
+
line: params.line,
|
|
686
|
+
avgColor: params.avg
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
obvIndi.draw = function(s) {
|
|
691
|
+
const out = [drawLine(s.obv, s.line, 2)]
|
|
692
|
+
if (s.avg.length) out.push(drawLine(s.avg, s.avgColor, 1))
|
|
693
|
+
return out
|
|
694
|
+
}`;var nA=`
|
|
695
|
+
const psar = plugin({
|
|
696
|
+
name: "Parabolic SAR",
|
|
697
|
+
shortName: "SAR",
|
|
698
|
+
description: "Accelerating stop-and-reverse dots",
|
|
699
|
+
type: PluginType.indicator,
|
|
700
|
+
require: DataLevel.ohlcv,
|
|
701
|
+
version: "1.0.0",
|
|
702
|
+
lookback: 100,
|
|
703
|
+
params: {
|
|
704
|
+
step: { label: "Step", type: "number", default: 0.02, min: 0.001, max: 0.5, step: 0.001 },
|
|
705
|
+
max: { label: "Max step", type: "number", default: 0.2, min: 0.01, max: 1, step: 0.01 },
|
|
706
|
+
up: { label: "Rising", type: "color", default: "#26a69a" },
|
|
707
|
+
down: { label: "Falling", type: "color", default: "#ef5350" },
|
|
708
|
+
size: { label: "Dot size", type: "stepperInt", default: 2, min: 1, max: 6 }
|
|
709
|
+
}
|
|
710
|
+
})
|
|
711
|
+
|
|
712
|
+
psar.init = function({ data, params }) {
|
|
713
|
+
const bars = data.ohlcv
|
|
714
|
+
const pts = []
|
|
715
|
+
const colors = []
|
|
716
|
+
if (bars.length < 2) return { pts, colors, size: params.size }
|
|
717
|
+
|
|
718
|
+
let rising = bars[1].close >= bars[0].close
|
|
719
|
+
let sar = rising ? bars[0].low : bars[0].high
|
|
720
|
+
let extreme = rising ? bars[1].high : bars[1].low
|
|
721
|
+
let accel = params.step
|
|
722
|
+
|
|
723
|
+
for (let i = 1; i < bars.length; i++) {
|
|
724
|
+
const bar = bars[i]
|
|
725
|
+
sar = sar + accel * (extreme - sar)
|
|
726
|
+
|
|
727
|
+
// The stop may never sit inside the last two bars' range.
|
|
728
|
+
const prev = bars[i - 1]
|
|
729
|
+
if (rising) {
|
|
730
|
+
sar = Math.min(sar, prev.low, bars[i - 2] ? bars[i - 2].low : prev.low)
|
|
731
|
+
} else {
|
|
732
|
+
sar = Math.max(sar, prev.high, bars[i - 2] ? bars[i - 2].high : prev.high)
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if (rising ? bar.low < sar : bar.high > sar) {
|
|
736
|
+
rising = !rising
|
|
737
|
+
sar = extreme
|
|
738
|
+
extreme = rising ? bar.high : bar.low
|
|
739
|
+
accel = params.step
|
|
740
|
+
} else if (rising ? bar.high > extreme : bar.low < extreme) {
|
|
741
|
+
extreme = rising ? bar.high : bar.low
|
|
742
|
+
accel = Math.min(accel + params.step, params.max)
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
pts.push({ t: bar.ts, price: sar })
|
|
746
|
+
colors.push(rising ? params.up : params.down)
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
return { pts, colors, size: params.size }
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
psar.draw = function(s) {
|
|
753
|
+
return [drawDots(s.pts, s.colors, s.size)]
|
|
754
|
+
}`;var rA=`
|
|
755
|
+
const rsiIndi = plugin({
|
|
756
|
+
name: "Relative Strength Index",
|
|
757
|
+
shortName: "RSI",
|
|
758
|
+
description: "Momentum oscillator with overbought / oversold zones",
|
|
759
|
+
type: PluginType.indicator,
|
|
760
|
+
require: DataLevel.ohlcv,
|
|
761
|
+
layout: Layout.pane,
|
|
762
|
+
version: "1.0.0",
|
|
763
|
+
lookback: 150,
|
|
764
|
+
params: {
|
|
765
|
+
length: { label: "Length", type: "number", default: 14, min: 2, max: 200 },
|
|
766
|
+
smoothing: { label: "Average", type: "number", default: 14, min: 1, max: 200 },
|
|
767
|
+
overbought:{ label: "Overbought", type: "number", default: 70, min: 50, max: 100 },
|
|
768
|
+
oversold: { label: "Oversold", type: "number", default: 30, min: 0, max: 50 },
|
|
769
|
+
line: { label: "RSI", type: "color", default: "#7e57c2" },
|
|
770
|
+
signal: { label: "Average", type: "color", default: "#f5a623" }
|
|
771
|
+
}
|
|
772
|
+
})
|
|
773
|
+
|
|
774
|
+
rsiIndi.init = function({ data, params }) {
|
|
775
|
+
const bars = data.ohlcv
|
|
776
|
+
const ts = bars.map(b => b.ts)
|
|
777
|
+
const values = rsi(bars, params.length)
|
|
778
|
+
|
|
779
|
+
return {
|
|
780
|
+
rsi: toPoints(ts, values),
|
|
781
|
+
ma: toPoints(ts, sma(values, params.smoothing)),
|
|
782
|
+
overbought: params.overbought,
|
|
783
|
+
oversold: params.oversold,
|
|
784
|
+
line: params.line,
|
|
785
|
+
signal: params.signal
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
rsiIndi.draw = function(s) {
|
|
790
|
+
const grid = "#ffffff1f"
|
|
791
|
+
|
|
792
|
+
return [
|
|
793
|
+
fillBetween(s.overbought, s.oversold, { mode: 'solid', color: s.line + '1a' }),
|
|
794
|
+
|
|
795
|
+
// Gradients fade out at the threshold, so only the excursion past it shows.
|
|
796
|
+
fillBetween(s.rsi, s.oversold, {
|
|
797
|
+
mode: 'vertical',
|
|
798
|
+
stops: [
|
|
799
|
+
{ price: s.oversold, color: 'rgba(239,83,80,0)' },
|
|
800
|
+
{ price: 0, color: 'rgba(239,83,80,0.55)' }
|
|
801
|
+
]
|
|
802
|
+
}),
|
|
803
|
+
fillBetween(s.overbought, s.rsi, {
|
|
804
|
+
mode: 'vertical',
|
|
805
|
+
stops: [
|
|
806
|
+
{ price: 100, color: 'rgba(38,166,154,0.55)' },
|
|
807
|
+
{ price: s.overbought, color: 'rgba(38,166,154,0)' }
|
|
808
|
+
]
|
|
809
|
+
}),
|
|
810
|
+
|
|
811
|
+
drawHLine(s.overbought, grid, 1, [4, 4]),
|
|
812
|
+
drawHLine(50, "#ffffff12", 1, [4, 4]),
|
|
813
|
+
drawHLine(s.oversold, grid, 1, [4, 4]),
|
|
814
|
+
|
|
815
|
+
drawLine(s.ma, s.signal, 1),
|
|
816
|
+
drawLine(s.rsi, s.line, 2)
|
|
817
|
+
]
|
|
818
|
+
}`;var oA=`
|
|
819
|
+
const sessionsIndi = plugin({
|
|
820
|
+
name: "Trading Sessions",
|
|
821
|
+
shortName: "SESS",
|
|
822
|
+
description: "Asia / London / New York session ranges",
|
|
823
|
+
type: PluginType.indicator,
|
|
824
|
+
require: DataLevel.ohlcv,
|
|
825
|
+
version: "1.0.0",
|
|
826
|
+
params: {
|
|
827
|
+
tz: { label: "Timezone", type: "select", default: "UTC", options: [
|
|
828
|
+
{ value: "UTC", label: "UTC" },
|
|
829
|
+
{ value: "America/New_York", label: "New York" },
|
|
830
|
+
{ value: "Europe/London", label: "London" },
|
|
831
|
+
{ value: "Asia/Tokyo", label: "Tokyo" }
|
|
832
|
+
] },
|
|
833
|
+
asia: { label: "Asia", type: "checkbox", default: true },
|
|
834
|
+
london: { label: "London", type: "checkbox", default: true },
|
|
835
|
+
newYork: { label: "New York", type: "checkbox", default: true },
|
|
836
|
+
labels: { label: "Show labels", type: "checkbox", default: true },
|
|
837
|
+
opacity: { label: "Shading", type: "opacity", default: 12 }
|
|
838
|
+
}
|
|
839
|
+
})
|
|
840
|
+
|
|
841
|
+
const SESSIONS = [
|
|
842
|
+
{ key: "asia", label: "Asia", startHour: 0, startMinute: 0, endHour: 9, endMinute: 0, color: "#7e57c2" },
|
|
843
|
+
{ key: "london", label: "London", startHour: 7, startMinute: 0, endHour: 16, endMinute: 0, color: "#08b3de" },
|
|
844
|
+
{ key: "newYork", label: "New York", startHour: 13, startMinute: 30, endHour: 22, endMinute: 0, color: "#f5a623" }
|
|
845
|
+
]
|
|
846
|
+
|
|
847
|
+
function alpha(hex, percent) {
|
|
848
|
+
const a = Math.round(Math.max(0, Math.min(100, percent)) * 2.55)
|
|
849
|
+
return hex + a.toString(16).padStart(2, '0')
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
sessionsIndi.init = function({ data, params }) {
|
|
853
|
+
const active = SESSIONS.filter(s => params[s.key])
|
|
854
|
+
const bands = active.length
|
|
855
|
+
? sessionBoundaries(data.ohlcv, active, { tz: params.tz })
|
|
856
|
+
: []
|
|
857
|
+
|
|
858
|
+
return { bands, labels: params.labels, opacity: params.opacity }
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
sessionsIndi.draw = function(s) {
|
|
862
|
+
const out = []
|
|
863
|
+
|
|
864
|
+
for (const band of s.bands) {
|
|
865
|
+
out.push(drawRect(band.startTs, band.low, band.endTs, band.high, {
|
|
866
|
+
fillColor: alpha(band.color, s.opacity),
|
|
867
|
+
borderColor: alpha(band.color, 55),
|
|
868
|
+
radius: 3
|
|
869
|
+
}))
|
|
870
|
+
|
|
871
|
+
if (s.labels) {
|
|
872
|
+
out.push(drawLabel(band.label, band.startTs, band.high, band.color, 10, true, 'left', 'bottom'))
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
return out
|
|
877
|
+
}`;var aA=`
|
|
878
|
+
const stochastic = plugin({
|
|
879
|
+
name: "Stochastic",
|
|
880
|
+
shortName: "STOCH",
|
|
881
|
+
description: "Close relative to the recent high / low range",
|
|
882
|
+
type: PluginType.indicator,
|
|
883
|
+
require: DataLevel.ohlcv,
|
|
884
|
+
layout: Layout.pane,
|
|
885
|
+
version: "1.0.0",
|
|
886
|
+
lookback: 100,
|
|
887
|
+
params: {
|
|
888
|
+
k: { label: "%K length", type: "number", default: 14, min: 1, max: 200 },
|
|
889
|
+
smooth: { label: "%K smoothing", type: "number", default: 3, min: 1, max: 50 },
|
|
890
|
+
d: { label: "%D length", type: "number", default: 3, min: 1, max: 50 },
|
|
891
|
+
overbought: { label: "Overbought", type: "number", default: 80, min: 50, max: 100 },
|
|
892
|
+
oversold: { label: "Oversold", type: "number", default: 20, min: 0, max: 50 },
|
|
893
|
+
kColor: { label: "%K", type: "color", default: "#08b3de" },
|
|
894
|
+
dColor: { label: "%D", type: "color", default: "#f5a623" }
|
|
895
|
+
}
|
|
896
|
+
})
|
|
897
|
+
|
|
898
|
+
stochastic.init = function({ data, params }) {
|
|
899
|
+
const bars = data.ohlcv
|
|
900
|
+
const ts = bars.map(b => b.ts)
|
|
901
|
+
const { k, d } = stoch(bars, params.k, params.d, params.smooth)
|
|
902
|
+
|
|
903
|
+
return {
|
|
904
|
+
k: toPoints(ts, k),
|
|
905
|
+
d: toPoints(ts, d),
|
|
906
|
+
overbought: params.overbought,
|
|
907
|
+
oversold: params.oversold,
|
|
908
|
+
kColor: params.kColor,
|
|
909
|
+
dColor: params.dColor
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
stochastic.draw = function(s) {
|
|
914
|
+
return [
|
|
915
|
+
fillBetween(s.overbought, s.oversold, { mode: 'solid', color: '#ffffff08' }),
|
|
916
|
+
drawHLine(s.overbought, "#ffffff1f", 1, [4, 4]),
|
|
917
|
+
drawHLine(s.oversold, "#ffffff1f", 1, [4, 4]),
|
|
918
|
+
drawLine(s.d, s.dColor, 1),
|
|
919
|
+
drawLine(s.k, s.kColor, 2)
|
|
920
|
+
]
|
|
921
|
+
}`;var iA=`
|
|
922
|
+
const supertrendIndi = plugin({
|
|
923
|
+
name: "Supertrend",
|
|
924
|
+
shortName: "ST",
|
|
925
|
+
description: "ATR trailing stop that flips with the trend",
|
|
926
|
+
type: PluginType.indicator,
|
|
927
|
+
require: DataLevel.ohlcv,
|
|
928
|
+
version: "1.0.0",
|
|
929
|
+
lookback: 150,
|
|
930
|
+
params: {
|
|
931
|
+
length: { label: "ATR length", type: "number", default: 10, min: 1, max: 200 },
|
|
932
|
+
mult: { label: "Multiplier", type: "number", default: 3, min: 0.1, max: 20, step: 0.1 },
|
|
933
|
+
up: { label: "Uptrend", type: "color", default: "#26a69a" },
|
|
934
|
+
down: { label: "Downtrend", type: "color", default: "#ef5350" },
|
|
935
|
+
markers:{ label: "Flip markers", type: "checkbox", default: true }
|
|
936
|
+
}
|
|
937
|
+
})
|
|
938
|
+
|
|
939
|
+
supertrendIndi.init = function({ data, params }) {
|
|
940
|
+
const bars = data.ohlcv
|
|
941
|
+
const { trend, upper, lower } = supertrend(bars, params.length, params.mult)
|
|
942
|
+
|
|
943
|
+
// One continuous stop line; colour is per-point so the flip shows in place.
|
|
944
|
+
const pts = []
|
|
945
|
+
const colors = []
|
|
946
|
+
const flips = []
|
|
947
|
+
|
|
948
|
+
for (let i = 0; i < bars.length; i++) {
|
|
949
|
+
const up = trend[i] === 1
|
|
950
|
+
const value = up ? lower[i] : upper[i]
|
|
951
|
+
if (isNaN(value)) continue
|
|
952
|
+
|
|
953
|
+
pts.push({ t: bars[i].ts, price: value })
|
|
954
|
+
colors.push(up ? params.up : params.down)
|
|
955
|
+
|
|
956
|
+
if (i > 0 && trend[i] !== trend[i - 1]) {
|
|
957
|
+
flips.push({ t: bars[i].ts, price: value, up })
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
return { pts, colors, flips, up: params.up, down: params.down, markers: params.markers }
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
supertrendIndi.draw = function(s) {
|
|
965
|
+
const out = [drawLine(s.pts, s.colors, 2)]
|
|
966
|
+
|
|
967
|
+
if (s.markers) {
|
|
968
|
+
for (const f of s.flips) {
|
|
969
|
+
out.push(drawLabel(f.up ? '\u25B2' : '\u25BC', f.t, f.price, f.up ? s.up : s.down, 11, true, 'center', f.up ? 'top' : 'bottom'))
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
return out
|
|
974
|
+
}`;var sA=`
|
|
975
|
+
const volumeIndi = plugin({
|
|
976
|
+
name: "Volume",
|
|
977
|
+
shortName: "VOL",
|
|
978
|
+
description: "Per-bar volume with a moving average",
|
|
979
|
+
type: PluginType.indicator,
|
|
980
|
+
require: DataLevel.ohlcv,
|
|
981
|
+
layout: Layout.pane,
|
|
982
|
+
version: "1.0.0",
|
|
983
|
+
lookback: 100,
|
|
984
|
+
params: {
|
|
985
|
+
length: { label: "Average", type: "number", default: 20, min: 0, max: 500 },
|
|
986
|
+
up: { label: "Up bar", type: "color", default: "#26a69a" },
|
|
987
|
+
down: { label: "Down bar", type: "color", default: "#ef5350" },
|
|
988
|
+
avg: { label: "Average", type: "color", default: "#f5a623" },
|
|
989
|
+
opacity:{ label: "Bar opacity", type: "opacity", default: 65 }
|
|
990
|
+
}
|
|
991
|
+
})
|
|
992
|
+
|
|
993
|
+
volumeIndi.init = function({ data, params }) {
|
|
994
|
+
const bars = data.ohlcv
|
|
995
|
+
const suffix = Math.round(Math.max(0, Math.min(100, params.opacity)) * 2.55).toString(16).padStart(2, '0')
|
|
996
|
+
|
|
997
|
+
const pts = []
|
|
998
|
+
const colors = []
|
|
999
|
+
for (const bar of bars) {
|
|
1000
|
+
pts.push({ t: bar.ts, price: bar.volume })
|
|
1001
|
+
colors.push((bar.close >= bar.open ? params.up : params.down) + suffix)
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
return {
|
|
1005
|
+
pts,
|
|
1006
|
+
colors,
|
|
1007
|
+
avg: params.length >= 2
|
|
1008
|
+
? toPoints(bars.map(b => b.ts), sma(bars.map(b => b.volume), params.length))
|
|
1009
|
+
: [],
|
|
1010
|
+
avgColor: params.avg
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
volumeIndi.draw = function(s) {
|
|
1015
|
+
const out = [drawHistogram(s.pts, s.colors, 0, 0.25)]
|
|
1016
|
+
if (s.avg.length) out.push(drawLine(s.avg, s.avgColor, 1))
|
|
1017
|
+
return out
|
|
1018
|
+
}`;var lA=`
|
|
1019
|
+
const vwapIndi = plugin({
|
|
1020
|
+
name: "VWAP",
|
|
1021
|
+
shortName: "VWAP",
|
|
1022
|
+
description: "Session volume-weighted average with deviation bands",
|
|
1023
|
+
type: PluginType.indicator,
|
|
1024
|
+
require: DataLevel.ohlcv,
|
|
1025
|
+
version: "1.0.0",
|
|
1026
|
+
lookback: 300,
|
|
1027
|
+
params: {
|
|
1028
|
+
anchorHour: { label: "Session start (UTC)", type: "number", default: 0, min: 0, max: 23 },
|
|
1029
|
+
bands: { label: "Band multipliers", type: "text", default: "1, 2", placeholder: "1, 2, 3" },
|
|
1030
|
+
line: { label: "VWAP", type: "color", default: "#f5a623" },
|
|
1031
|
+
band: { label: "Bands", type: "color", default: "#08b3de" }
|
|
1032
|
+
}
|
|
1033
|
+
})
|
|
1034
|
+
|
|
1035
|
+
const DAY_MS = 86400000
|
|
1036
|
+
|
|
1037
|
+
function parseMultipliers(raw) {
|
|
1038
|
+
const out = []
|
|
1039
|
+
for (const part of String(raw).split(',')) {
|
|
1040
|
+
const v = parseFloat(part)
|
|
1041
|
+
if (isFinite(v) && v > 0) out.push(v)
|
|
1042
|
+
}
|
|
1043
|
+
return out.slice(0, 4)
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
vwapIndi.init = function({ data, params }) {
|
|
1047
|
+
const bars = data.ohlcv
|
|
1048
|
+
const mults = parseMultipliers(params.bands)
|
|
1049
|
+
|
|
1050
|
+
const vwap = []
|
|
1051
|
+
const bands = mults.map(() => ({ upper: [], lower: [] }))
|
|
1052
|
+
|
|
1053
|
+
let sumPV = 0, sumV = 0, sumPPV = 0, session = NaN
|
|
1054
|
+
|
|
1055
|
+
for (const bar of bars) {
|
|
1056
|
+
const ms = Number(bar.ts / 1000000n)
|
|
1057
|
+
const day = Math.floor((ms - params.anchorHour * 3600000) / DAY_MS)
|
|
1058
|
+
if (day !== session) {
|
|
1059
|
+
sumPV = 0; sumV = 0; sumPPV = 0
|
|
1060
|
+
session = day
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
const tp = (bar.high + bar.low + bar.close) / 3
|
|
1064
|
+
sumPV += tp * bar.volume
|
|
1065
|
+
sumV += bar.volume
|
|
1066
|
+
sumPPV += tp * tp * bar.volume
|
|
1067
|
+
if (sumV <= 0) continue
|
|
1068
|
+
|
|
1069
|
+
const mean = sumPV / sumV
|
|
1070
|
+
vwap.push({ t: bar.ts, price: mean })
|
|
1071
|
+
|
|
1072
|
+
// Volume-weighted variance, so the bands widen with participation.
|
|
1073
|
+
const sd = Math.sqrt(Math.max(0, sumPPV / sumV - mean * mean))
|
|
1074
|
+
for (let i = 0; i < mults.length; i++) {
|
|
1075
|
+
bands[i].upper.push({ t: bar.ts, price: mean + mults[i] * sd })
|
|
1076
|
+
bands[i].lower.push({ t: bar.ts, price: mean - mults[i] * sd })
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
return { vwap, bands, line: params.line, band: params.band }
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
vwapIndi.draw = function(s) {
|
|
1084
|
+
const out = []
|
|
1085
|
+
|
|
1086
|
+
for (let i = s.bands.length - 1; i >= 0; i--) {
|
|
1087
|
+
out.push(fillBetween(s.bands[i].upper, s.bands[i].lower, {
|
|
1088
|
+
mode: 'solid',
|
|
1089
|
+
color: s.band + '0c'
|
|
1090
|
+
}))
|
|
1091
|
+
}
|
|
1092
|
+
for (const b of s.bands) {
|
|
1093
|
+
out.push(drawLine(b.upper, s.band + '80', 1, [3, 3]))
|
|
1094
|
+
out.push(drawLine(b.lower, s.band + '80', 1, [3, 3]))
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
out.push(drawLine(s.vwap, s.line, 2))
|
|
1098
|
+
return out
|
|
1099
|
+
}`;var cA=`
|
|
1100
|
+
const williams = plugin({
|
|
1101
|
+
name: "Williams %R",
|
|
1102
|
+
shortName: "%R",
|
|
1103
|
+
description: "Where the close sits inside the period's range",
|
|
1104
|
+
type: PluginType.indicator,
|
|
1105
|
+
require: DataLevel.ohlcv,
|
|
1106
|
+
layout: Layout.pane,
|
|
1107
|
+
version: "1.0.0",
|
|
1108
|
+
lookback: 100,
|
|
1109
|
+
params: {
|
|
1110
|
+
length: { label: "Length", type: "number", default: 14, min: 1, max: 300 },
|
|
1111
|
+
overbought: { label: "Overbought", type: "number", default: -20, min: -50, max: 0 },
|
|
1112
|
+
oversold: { label: "Oversold", type: "number", default: -80, min: -100, max: -50 },
|
|
1113
|
+
line: { label: "%R", type: "color", default: "#7e57c2" }
|
|
1114
|
+
}
|
|
1115
|
+
})
|
|
1116
|
+
|
|
1117
|
+
williams.init = function({ data, params }) {
|
|
1118
|
+
const bars = data.ohlcv
|
|
1119
|
+
|
|
1120
|
+
return {
|
|
1121
|
+
r: toPoints(bars.map(b => b.ts), williamsR(bars, params.length)),
|
|
1122
|
+
overbought: params.overbought,
|
|
1123
|
+
oversold: params.oversold,
|
|
1124
|
+
line: params.line
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
williams.draw = function(s) {
|
|
1129
|
+
return [
|
|
1130
|
+
fillBetween(s.overbought, s.oversold, { mode: 'solid', color: '#ffffff08' }),
|
|
1131
|
+
drawHLine(s.overbought, "#ffffff1f", 1, [4, 4]),
|
|
1132
|
+
drawHLine(s.oversold, "#ffffff1f", 1, [4, 4]),
|
|
1133
|
+
drawLine(s.r, s.line, 2)
|
|
1134
|
+
]
|
|
1135
|
+
}`;var uA=[[JD,"builtin:moving-average","trend"],[iA,"builtin:supertrend","trend"],[XD,"builtin:ichimoku","trend"],[nA,"builtin:psar","trend"],[lA,"builtin:vwap","trend"],[UD,"builtin:alligator","trend"],[rA,"builtin:rsi","momentum"],[QD,"builtin:macd","momentum"],[aA,"builtin:stochastic","momentum"],[KD,"builtin:cci","momentum"],[cA,"builtin:williams-r","momentum"],[GD,"builtin:awesome-oscillator","momentum"],[YD,"builtin:bollinger-bands","volatility"],[ZD,"builtin:keltner","volatility"],[$D,"builtin:donchian","volatility"],[jD,"builtin:atr","volatility"],[sA,"builtin:volume","volume"],[tA,"builtin:obv","volume"],[eA,"builtin:mfi","volume"],[oA,"builtin:sessions","other"]];var Aj={contextMenu:!0,plugins:{enabled:!0,indicators:!0,charts:!0,extensions:!0,drawings:!0}},dA=1,Bj=8,mx="$bigint";function Nj(e){return JSON.stringify(e,(t,n)=>typeof n=="bigint"?{[mx]:n.toString()}:n)}function Ej(e){return JSON.parse(e,(t,n)=>n&&typeof n=="object"&&typeof n[mx]=="string"?BigInt(n[mx]):n)}function Oj(e){return Array.isArray(e.plugins)&&e.plugins.some(t=>typeof t=="string")?{...e,plugins:[]}:e}function _j(e){let t=Ho.find(r=>r.label.toLowerCase()===e.toLowerCase());if(t)return t;let n=Nc(e);if(n)return n;throw new Error(`[ChristTrade] Unknown timeframe: "${e}"`)}var Om=class{constructor(t){ae(this,"options",t);ae(this,"id");ae(this,"eventBus");ae(this,"executionEngine");ae(this,"dataEngine");ae(this,"transformer");ae(this,"features");ae(this,"pluginRegistry");ae(this,"_renderEngine",null);ae(this,"_panelRegistry",new Map);ae(this,"_toolbarRegistry",new Map);ae(this,"_bottomBarRegistry",new Map);ae(this,"_openBarProviders",new Map);ae(this,"_horizon",0);ae(this,"dataSources");ae(this,"drawingRegistry");ae(this,"destroyed",!1);ae(this,"registeredPlugins",new Map);ae(this,"_pluginStateListeners",new Set);ae(this,"_pluginCatalog",null);ae(this,"playbackController");ae(this,"playbackStateRegistry");ae(this,"pluginSchedules",new Map);ae(this,"state");ae(this,"_panes",new Map);ae(this,"drawingStore");ae(this,"account");ae(this,"playback");ae(this,"timePrecision","ms");ae(this,"_focusedCellId",0);this.id=`chart:${pn(6)}`,this.eventBus=new pc,this.transformer=new Xi,this.executionEngine=new gc,this.executionEngine.setEventBus(this.eventBus),this.features=Aj,this._horizon=typeof t.horizon=="number"?t.horizon:new Date(t.horizon).getTime();for(let c in t?.features??{})this.features[c]=t.features[c];t.executionAdapter&&this.executionEngine.setCustomAdapter(t.executionAdapter);let n={timeframes:"any",allowCustom:!0};t?.features?.timeframe?.timeframes&&(Array.isArray(t.features.timeframe.timeframes)||t.features.timeframe.timeframes==="any")&&(n.timeframes=t.features.timeframe.timeframes),typeof t?.features?.timeframe?.allowCustom=="boolean"&&(n.allowCustom=t.features.timeframe.allowCustom),this.features.timeframe=n;let r={enabled:!0,indicators:!0,drawings:!0,charts:!0,extensions:!0};if(t?.features?.plugins||typeof t?.features?.plugins=="boolean"){let c=t.features.plugins;if(typeof c=="boolean")r.enabled=c;else if(typeof c=="object")for(let u in c)r[u]=c[u];else console.warn("[ChristTrade] Invalid plugin options, skipping")}this.pluginRegistry=new Lm,this.pluginRegistry.setOptions(r),this.pluginRegistry.setEventBus(this.eventBus),this.drawingRegistry=new Sf,this.eventBus.on("render-engine:ready",({engine:c})=>{this.attachRenderEngine(c)}),this.eventBus.on("data:open-bar-provider",({cellId:c,get:u})=>{u?this._openBarProviders.set(c,u):this._openBarProviders.delete(c)}),this.eventBus.on("plugin:register-indicator",({indicator:c,activeByDefault:u,pane:d,lookback:m})=>{this.registeredPlugins.set(c.id,{indicator:c,activeByDefault:u,pane:d,lookback:m??0}),this.dataEngine.setLookback(this.getMaxLookbackBars())}),this.eventBus.on("plugin:uninstalled",({id:c})=>{let u=!1;for(let d of[...this.registeredPlugins.keys()])(d===c||d.startsWith(`${c}:`))&&(this.registeredPlugins.delete(d),u=!0);u&&this.dataEngine.setLookback(this.getMaxLookbackBars()),this._notifyPluginState()}),this.eventBus.on("plugin:installed",()=>this._notifyPluginState()),this.eventBus.on("playback:seek",({tNs:c})=>{this._horizon=Number(c/1000000n)});let o=t?.timeframe?_j(t.timeframe):Ho.find(c=>c.label==="1m");t?.timePrecision&&(this.timePrecision=t.timePrecision);let a=new Date(t.horizon).toISOString(),i={start:new Date(t.initialLoad.start).toISOString(),end:new Date(t.initialLoad.end).toISOString()};this.state=new Ig({activeTool:Vo,selectedDrawingId:null,symbol:t.symbol,fpOptions:t.fpOptions??{},isPlaying:!1,horizonIso:a,timeframe:o,layout:dg[0]}),this.drawingStore=new Pm,this.dataSources=new Ag;let s={initialLoad:i,horizon:a,fpOptions:t.fpOptions,initialWindowNs:t.initialWindowNs,timeframe:o,symbol:t.symbol,plugins:this.dataSources};this.dataEngine=new od(this.eventBus,this.state,s),this.dataEngine.setAdapter(t.dataAdapter),this.dataEngine.attachExecutionEngine(this.executionEngine),this.playbackController=new Dg(this.eventBus,BigInt(Math.round(this._horizon))*1000000n);let l=this.playbackController;this.playback={play:()=>(l.play(),this),pause:()=>(l.pause(),this),get playing(){return l.playing()},get stepSize(){return l.stepSize()},get speed(){return l.speed()},get mode(){return l.mode()},get stepSnap(){return l.stepSnap()},setStepSize:c=>(l.setStepSize(c),this),setSpeed:c=>(l.setSpeed(c),this),stepBack:()=>(l.stepBack(),this),stepForward:()=>(l.stepForward(),this),setMode:c=>(l.setMode(c),this),setStepSnap:c=>(l.setStepSnap(c),this),get time(){return l.time()},goTo:c=>(l.goTo(c),this),lockForward:(c=!0)=>(l.lockForward(c),this),get floor(){return l.floor()},allows:c=>l.allows(c)},t.account?(t.account.fillSearch&&this.executionEngine.setFillSearch(t.account.fillSearch),this.account=new Dm({eventBus:this.eventBus,executionEngine:this.executionEngine,initialBalance:t.account.initialBalance,currency:t.account.currency,adapter:t.account.adapter,fills:t.account.fills,orders:t.account.orders,positions:t.account.positions,adjustments:t.account.adjustments})):this.account=null,this.playbackStateRegistry=new Bg(this.eventBus),this._wireDataRouting(),this._wireSymbolMirror();for(let[c,u,d]of uA)this.use(Gu(c,u,d));!t.restore&&t.importTradingViewSettings!==!1&&cm(),t.restore&&this.restore(t.restore),Eu.registerChart(this)}setDataAdapter(t){return this.dataEngine.setAdapter(t),this}load(t){return this.dataEngine.load(t)}reloadData(){return this.dataEngine.reload(BigInt(Math.round(this._horizon))*1000000n)}getSymbolInfo(t){return this.dataEngine.getResolvedSymbolInfo(t)??this.dataSources.getResolved(t)}openBar(){let t=this.state.get("focusedPane")??0,r=(this._openBarProviders.get(t)??this._openBarProviders.values().next().value)?.();return r?{time:Number(r.ts/1000000n),open:r.open,high:r.high,low:r.low,close:r.close,volume:r.totalVol}:null}getMaxLookbackBars(){let t=0;for(let[,n]of this.registeredPlugins)(n.lookback??0)>t&&(t=n.lookback);return t}horizon(){return this._horizon}fitToData(){return this.eventBus.emit("chart:reset-view",void 0),this}setActiveTool(t){return this.state.set("activeTool",t,this.eventBus),this}setTimeframe(t){let n=Ho.find(r=>r.label.toLowerCase()===t.toLowerCase())??Nc(t);return n?(this.state.set("timeframe",n,this.eventBus),this):(console.warn(`[ChristTrade] Unknown timeframe: "${t}"`),this)}getChart(t){let n=this._panes.get(t);return n||(n=new Rm({symbol:this.state.get("symbol"),timeframe:this.state.get("timeframe"),fpOptions:this.state.get("fpOptions")}),this._panes.set(t,n)),n}get charts(){return[...this._panes.entries()].sort((t,n)=>t[0]-n[0]).map(([,t])=>t)}get focusedChart(){return this.getChart(0)}isTimeframeAllowed(t){let n=this.features?.timeframe?.timeframes??"any";return n==="any"||n.includes(t)}allowTimeframes(t){this.features.timeframe||(this.features.timeframe={});let n=this.features.timeframe.timeframes??"any";if(t==="any"||n==="any")this.features.timeframe.timeframes=t==="any"?"any":n;else{let r=new Set([...n,...t]);this.features.timeframe.timeframes=[...r]}return this.eventBus.emit("features:change",void 0),this}getTimeframe(){return this.state.get("timeframe").label}getSymbol(){return this.focusedChart?.symbol??this.state.get("symbol")}getActiveTool(){return this.state.get("activeTool")}getSelectedDrawing(){let t=this.state.get("selectedDrawingId");return t?this.getDrawing(t):null}getDrawing(t){let n=this.drawingStore.find(this.getSymbol(),t);return n?YS(n):null}onDrawingsChanged(t){return this.drawingStore.subscribe(this.getSymbol(),t)}setChartSettings(t){return this.eventBus.emit("chart:apply-settings",{patch:t}),this}setSymbol(t){if(this.state.get("symbol")===t)return this;this.state.set("symbol",t,this.eventBus);for(let[n]of this.registeredPlugins)this.eventBus.emit("plugin:recompute-indicator",{id:n});return this}addIndicator(t){return this.eventBus.emit("chart:add-indicator",{id:t}),this}removeIndicator(t){return this.eventBus.emit("chart:remove-indicator",{id:t}),this}setAccountAdapter(t){return this.account?(this.account.setAdapter(t),this):(console.warn("[ChristTrade] account manager is not enabled (pass `account` option)"),this)}serialize(){return{version:dA,layout:{...this.state.get("layout")},syncInLayout:this.state.get("syncInLayout"),gridColSizes:this.state.get("gridColSizes"),gridRowSizes:this.state.get("gridRowSizes"),focusedPane:this.state.get("focusedPane"),account:this.account?.serialize(),plugins:this.pluginRegistry.serialize(),drawings:this.drawingStore.serialize(),charts:Array.from({length:this._activePaneCount()},(t,n)=>this.getChart(n).serialize()),preferences:Sb()}}_activePaneCount(){let t=new Set;for(let n of this.state.get("layout").areas)n>="a"&&n<="h"&&t.add(n);return Math.max(1,t.size)}restore(t){let n=Oj(t);Cb(n.preferences),n.plugins?.forEach(({id:o,code:a})=>{try{this.use(Gu(a,o))}catch(i){console.warn("[ChristTrade] failed to restore plugin",i)}}),n.account&&this.account&&this.account.restore(n.account),n.layout&&this.state.set("layout",n.layout,this.eventBus),n.syncInLayout&&this.state.set("syncInLayout",n.syncInLayout),n.gridColSizes&&this.state.set("gridColSizes",n.gridColSizes),n.gridRowSizes&&this.state.set("gridRowSizes",n.gridRowSizes),n.focusedPane!=null&&this.state.set("focusedPane",n.focusedPane),n.drawings&&this.drawingStore.restore(n.drawings),n.charts?.forEach((o,a)=>this.getChart(a).restore(o));let r=this._panes.get(this.state.get("focusedPane")??0);return r&&this.state.set("timeframe",r.timeframe),this}getProps(){return{chart:this,eventBus:this.eventBus,executionEngine:this.executionEngine,transformer:this.transformer,hideToolbar:this.options.hideToolbar,hideDrawingToolbar:this.options.hideDrawingToolbar,hideBottomToolbar:this.options.hideBottomToolbar,hidePriceScale:this.options.hidePriceScale,hideTimeScale:this.options.hideTimeScale,hideStatusBar:this.options.hideStatusBar,hideLegend:this.options.hideLegend,prefetch:this.options?.playback?.prefetch,showDataStatusInBottomRightCorner:this.options?.debug?.showDataStatusInBottomRightCorner??!1,state:this.state,toolbar:this.options.toolbar?.(this)??[],plugins:[...this.registeredPlugins.values()],features:this.features,timePrecision:this.timePrecision}}on(t,n){return this.eventBus.on(t,n)}off(t,n){this.eventBus.off(t,n)}use(t){return Yu("use",t.id,t.type,new Error().stack?.split(`
|
|
1136
|
+
`)[2]?.trim()),this.pluginRegistry.register(t,this._buildPluginContext(t.id)),this}add(t){let n=typeof t=="string"?t:t.id;return this.eventBus.emit("chart:add-plugin-indicator",{pluginId:n}),this}remove(t){let n=typeof t=="string"?t:t.id;return this.eventBus.emit("chart:remove-plugin-indicator",{pluginId:n}),this}unuse(t){this.pluginRegistry.unregister(t);let n=this.pluginSchedules?.get(t);return n&&(n.destroy(),this.pluginSchedules?.delete(t)),this}isPluginInstalled(t){return this.pluginRegistry.has(t)}getPendingPluginIds(){let t=new Set;for(let n=0;n<this._activePaneCount();n++)for(let r of this.getChart(n).restoredPlugins)this.pluginRegistry.has(r.id)||t.add(r.id);return[...t]}setPluginCatalog(t){return this._pluginCatalog=t,this.applyStartupPlugins(),this}getPluginCatalog(){try{return this._pluginCatalog?.()??[]}catch(t){return console.warn("[ChristTrade] plugin catalog provider threw",t),[]}}loadPlugin(t,n={}){let r=this.getPluginCatalog().find(o=>o.id===t);if(!r)return!1;try{this.pluginRegistry.has(t)||this.use(Gu(r.code,t)),n.activate&&this.add(t)}catch(o){return console.warn("[ChristTrade] failed to load plugin",t,o),!1}return this.setPluginStartup(t,{autostart:!0,activate:!!n.activate}),!0}unloadPlugin(t){return this.unuse(t),this.setPluginStartup(t,{autostart:!1,activate:!1}),this}getPluginStartup(){return dx()}setPluginStartup(t,n){return fx(t,n),this._notifyPluginState(),this}applyStartupPlugins(){let t=new Map(this.getPluginCatalog().map(i=>[i.id,i]));if(Yu("applyStartupPlugins: catalog",[...t.keys()]),t.size===0)return this;let n=this.getPluginStartup();Yu("applyStartupPlugins: record",JSON.stringify(n));let r=new Set;for(let i=0;i<this._activePaneCount();i++)for(let s of this.getChart(i).restoredPlugins)r.add(s.id);let o=new Map,a=[];for(let i of r)n[i]&&!n[i].autostart||(n[i]||a.push(i),o.set(i,!1));for(let[i,s]of Object.entries(n))!s.autostart||o.has(i)||o.set(i,!!s.activate);Yu("applyStartupPlugins: referenced",[...r],"targets",[...o.entries()],"adopt",a);for(let[i,s]of o){if(this.pluginRegistry.has(i))continue;let l=t.get(i);if(l)try{this.use(Gu(l.code,i)),s&&this.add(i)}catch(c){console.warn("[ChristTrade] failed to start plugin",i,c)}}for(let i of a)t.has(i)&&fx(i,{autostart:!0,activate:!1});return this}getInstalledPlugins(){return this.pluginRegistry.getInstalledPlugins()}setPanelVisible(t,n){let r=this._panelRegistry.get(t);return r&&(r.visible=n),this.eventBus.emit("plugin:panel-toggle-visibility",{id:t,visible:n}),this}isPluginActive(t){return this.getPluginState().active.has(t)}getPluginState(){let t=new Set;for(let n=0;n<this._activePaneCount();n++)for(let r of this.getChart(n).plugins)t.add(r.id);return{installed:new Set(this.pluginRegistry.getInstalledIds()),active:t}}onPluginStateChange(t){let n=i=>`${[...i.installed].sort().join(",")}|${[...i.active].sort().join(",")}`,r=n(this.getPluginState()),o=()=>{let i=this.getPluginState(),s=n(i);s!==r&&(r=s,t(i))};this._pluginStateListeners.add(o);let a=Array.from({length:Bj},(i,s)=>this.getChart(s).subscribe(o));return()=>{this._pluginStateListeners.delete(o),a.forEach(i=>i())}}_notifyPluginState(){for(let t of this._pluginStateListeners)t()}getRegisteredPlugins(){return this.registeredPlugins}getPanelRegistry(){return this._panelRegistry}getToolbarRegistry(){return this._toolbarRegistry}getBottomBarRegistry(){return this._bottomBarRegistry}attachRenderEngine(t){this._renderEngine=t,this.pluginRegistry.notifyRenderEngineReady(t)}screenshot(){return this._renderEngine?.captureComposite()??null}_wireSymbolMirror(){this.eventBus.on("chart:focused",({id:t})=>{this._focusedCellId=t;let n=this.getChart(t)?.symbol;n&&this.state.set("symbol",n)}),this.eventBus.on("chart:set-symbol",({symbol:t,id:n})=>{n===this._focusedCellId&&this.state.set("symbol",t)})}_wireDataRouting(){this.eventBus.on("trade",t=>{this.dataSources.handleTick({ts:t.ts,price:t.price,size:t.size,side:t.side})})}_buildPluginContext(t){let n=this,r=new Ng;this.pluginSchedules.set(t,r);let o={placeOrder:s=>n.executionEngine.placeOrder(s),cancelOrder:s=>n.executionEngine.cancelOrder(s),amendOrder:(s,l)=>n.executionEngine.amendOrder(s,l),amendBracket:s=>n.executionEngine.amendBracket(s),closePosition:s=>n.executionEngine.closePosition(s),reversePosition:s=>n.executionEngine.reversePosition(s),totalRealizedPnl:()=>n.executionEngine.totalRealizedPnl(),totalFeesPaid:()=>n.executionEngine.totalFeesPaid()},a=s=>{let{title:l,body:c,level:u="info",duration:d=4e3,action:m}=s,f=c?`${l}: ${c}`:l,h={duration:d===1/0?1/0:d,...m?{action:{label:m.label,onClick:m.onClick}}:{}};({info:Ti,success:Ti.success,warn:Ti.warning,error:Ti.error}[u]??Ti)(f,h)},i={registerState:s=>n.playbackStateRegistry.register(t,s)};return{eventBus:n.eventBus,global:Eu,horizon(){return n.horizon()},get renderEngine(){if(!n._renderEngine)throw new Error(`[Plugin "${t}"] renderEngine accessed before RenderEngine was ready.`);return n._renderEngine},executionEngine:n.executionEngine,transformer:n.transformer,getData:()=>n.dataEngine.getSnapshot(),openBar:()=>n.openBar(),get dataLevel(){return n.dataEngine.getSnapshot().dataLevel},registerPane(s,l={}){return()=>{n.eventBus.emit("plugin:remove-pane",{id:s})}},registerPanel(s,l,c=s,u=!0){return n._panelRegistry.set(s,{element:l,title:c,visible:u}),n.eventBus.emit("plugin:panel-added",{id:s,title:c,visible:u}),()=>{n._panelRegistry.delete(s),n.eventBus.emit("plugin:panel-removed",{id:s})}},registerToolbarItem(s){let l=n._toolbarRegistry.has(s.id);return n._toolbarRegistry.set(s.id,s),n.eventBus.emit(l?"plugin:toolbar-item-updated":"plugin:toolbar-item-added",l?{item:s}:{item:s}),()=>{n._toolbarRegistry.delete(s.id),n.eventBus.emit("plugin:toolbar-item-removed",{id:s.id})}},registerBottomBarItem(s,l){let c=`${t}:${s}`,u=n._bottomBarRegistry.has(c),d={id:c,render:l};return n._bottomBarRegistry.set(c,d),n.eventBus.emit(u?"plugin:bottom-bar-item-updated":"plugin:bottom-bar-item-added",{item:d}),{rerender(){n.eventBus.emit("plugin:bottom-bar-item-rerender",{id:c})},destroy(){n._bottomBarRegistry.delete(c),n.eventBus.emit("plugin:bottom-bar-item-removed",{id:c})}}},registerDataSource(s){let l=n.dataSources.register(s),c=n.state.get("symbol")??"";return c&&n.dataSources.sourceFor(c)===s&&n.dataEngine.load(c),l},playSound(s){if(typeof s=="string")try{new Audio(s).play()}catch(l){console.warn("[plugin:audio] Failed to play sound:",l)}},storage:{get(s,l){return qr(cp(t,s),l)},set(s,l){kr(cp(t,s),l)},delete(s){wb(cp(t,s))},clear(){AS(PS(t))}},registerDrawingTool:s=>this.drawingRegistry.register(s),addOverlay(s,l){return n._renderEngine?n._renderEngine.addDrawHook(s,l):(console.warn(`[Plugin "${t}"] addOverlay called before renderEngine ready`),()=>{})},fetch(s,l){return globalThis.fetch(s,l)},intercept(s,l){return n.eventBus.intercept(s,l)},services:this.pluginRegistry.buildServices(t),lifecycle:this.pluginRegistry.buildLifecycle(this.eventBus),getSettings(s){let l=qr(hb(t),null);return l?{...s,...l}:s},saveSettings(s){let l=hb(t),c=qr(l,{});kr(l,{...c,...s})},schedule:r,notify:a,playback:i,execution:o,registerContextMenuItem(s){return()=>{console.warn("[Depth] registerContextMenu not yet implemented")}},registerTheme(s){return()=>{console.warn("[Depth] registerTheme not yet implemented")}}}}destroy(){if(!this.destroyed){this.destroyed=!0,Eu.unregisterChart(this.id),this.dataEngine.destroy(),this.executionEngine.destroy(),this.pluginRegistry.destroy(),this.account?.destroy(),this.eventBus.clear(),this.dataSources.destroy(),this.playbackStateRegistry.destroy();for(let t of this.pluginSchedules?.values()??[])t.destroy();this.pluginSchedules?.clear()}}};import Fj,{useEffect as zj,useRef as fA}from"react";function Hj(e){let t=fA(null),n=fA(null);t.current||(t.current=new Om(e),t.current.load(e.symbol)),zj(()=>(n.current&&(clearTimeout(n.current),n.current=null),()=>{n.current=setTimeout(()=>{n.current=null,t.current?.destroy(),t.current=null},0)}),[]);let r=t.current,o=Fj.createElement(Tg,r.getProps());return{chart:r,element:o}}var px={TRENDING:{drift:.6,baseVol:.18,ouSpeed:0,garchAlpha:.08,garchBeta:.88,tDof:1/0,avgDuration:120},MEAN_REVERTING:{drift:0,baseVol:.12,ouSpeed:.04,garchAlpha:.06,garchBeta:.9,tDof:1/0,avgDuration:200},VOLATILE:{drift:0,baseVol:.55,ouSpeed:0,garchAlpha:.15,garchBeta:.8,tDof:5,avgDuration:40}},Vj={TRENDING:{TRENDING:.7,MEAN_REVERTING:.2,VOLATILE:.1},MEAN_REVERTING:{TRENDING:.25,MEAN_REVERTING:.6,VOLATILE:.15},VOLATILE:{TRENDING:.3,MEAN_REVERTING:.4,VOLATILE:.3}},Wj=["TRENDING","MEAN_REVERTING","VOLATILE"];function qj(e){let t=e;return()=>{t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function hx(e){let t=Math.max(e(),1e-10),n=e();return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*n)}function mA(e,t){if(!isFinite(t))return hx(e);let n=hx(e),r=0,o=Math.max(2,Math.round(t));for(let a=0;a<o;a++){let i=hx(e);r+=i*i}return n/Math.sqrt(r/o)}function Uj(e,t){let n=Vj[e],r=t();for(let o of Wj)if(r-=n[o],r<=0)return o;return"MEAN_REVERTING"}function pA(e,t){return Math.max(1,Math.round(-e.avgDuration*Math.log(Math.max(t(),1e-10))))}function jj(e,t,n,r,o,a){let i=1/n,s=Math.sqrt(i),l=t.baseVol**2,c=(1-t.garchAlpha-t.garchBeta)*l,u=mA(a,t.tDof)*Math.sqrt(e.garchVar*i),d=Math.max(c+t.garchAlpha*(u/s)**2+t.garchBeta*e.garchVar,1e-8);e.garchVar=d;let m=e.price,f=m,h=m,p=i/r,g=t.ouSpeed*(Math.log(e.ouMean)-Math.log(m))*p,y=(t.drift-.5*d)*p;for(let w=0;w<r;w++){let k=mA(a,t.tDof)*Math.sqrt(d*p),M=y+g+k;m=m*Math.exp(M),m>f&&(f=m),m<h&&(h=m)}let v=m,b=e.price;e.ouMean=.995*e.ouMean+.005*v;let S=w=>Math.round(w/o)*o,C=Math.round(500+a()*4500+d/l*2e3);return{time:0,open:S(b),high:S(Math.max(b,f,v)),low:S(Math.min(b,h,v)),close:S(v),volume:C,_closePrice:v,_time:""}}var Eg=class{constructor(t={}){ae(this,"cfg");let n={TRENDING:{...px.TRENDING,...t.regimes?.TRENDING??{}},MEAN_REVERTING:{...px.MEAN_REVERTING,...t.regimes?.MEAN_REVERTING??{}},VOLATILE:{...px.VOLATILE,...t.regimes?.VOLATILE??{}}};this.cfg={seed:t.seed??Math.floor(Math.random()*2**32),startPrice:t.startPrice??21e3,barDurationNs:t.barDurationNs??60000000000n,intrabbarTicks:t.intrabbarTicks??20,tickSize:t.tickSize??.25,regimes:n}}async searchSymbols(){return[this.resolveSymbol()]}resolveSymbol(){return{symbol:"SIM-MARKET",type:"index",description:"Simulated market - regime-switching GBM + GARCH(1,1)",exchange:"SIM",dataLevel:"ohlcv",priceFormat:{minTick:.25,precision:2}}}async fetchBars(t){let{barDurationNs:n,intrabbarTicks:r,tickSize:o,startPrice:a,seed:i}=this.cfg,s=Number(n/60000000000n),l=252*390/s,c=qj(i),{fromNs:u,toNs:d}=t.range,m=u-u%n,f=Math.max(1,Math.min(2e4,Number((d-m)/n))),h="MEAN_REVERTING",p=this.cfg.regimes[h],g={price:a,garchVar:p.baseVol**2,regime:h,regimeBarsLeft:pA(p,c),ouMean:a},y=[];for(let v=0;v<f;v++){g.regimeBarsLeft--,g.regimeBarsLeft<=0&&(g.regime=Uj(g.regime,c),g.regimeBarsLeft=pA(this.cfg.regimes[g.regime],c));let b=this.cfg.regimes[g.regime],S=jj(g,b,l,r,o,c);g.price=S._closePrice,y.push({time:Number(m/1000000n),open:S.open,high:S.high,low:S.low,close:S.close,volume:S.volume}),m+=n}return{events:[],ohlcvBars:y,hasMore:!1}}};function Gj(e){return new Eg(e)}import{useEffect as hA,useRef as Yj,useState as gA}from"react";import{jsx as Wi,jsxs as Cs}from"react/jsx-runtime";function Og(e,t=2){return e.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})}function bA({value:e,label:t}){let n=e>0?"text-emerald-400":e<0?"text-red-400":"text-slate-400",r=e>0?"+":"";return Cs("div",{className:"flex flex-col items-start leading-none",children:[Wi("span",{className:"text-[9px] text-slate-500 uppercase tracking-wide",children:t}),Cs("span",{className:`text-[11px] font-mono tabular-nums ${n}`,children:[r,Og(e)]})]})}function Kj({eventBus:e,currencySymbol:t="$"}){let[n,r]=gA(null),[o,a]=gA(0),i=Yj(0);return hA(()=>{let s=[e.on("account:update",r),e.on("playback:tick",l=>{i.current=l.spread})];return()=>s.forEach(l=>l())},[e]),hA(()=>{let s=setInterval(()=>a(i.current),250);return()=>clearInterval(s)},[]),n?Cs("div",{className:"flex items-center gap-3 text-xs select-none",children:[Cs("div",{className:"flex flex-col items-start leading-none",children:[Wi("span",{className:"text-[9px] text-slate-500 uppercase tracking-wide",children:"Balance"}),Cs("span",{className:"text-[11px] font-mono tabular-nums text-slate-200",children:[t,Og(n.balance)]})]}),Wi("div",{className:"h-4 w-px bg-slate-700"}),Cs("div",{className:"flex flex-col items-start leading-none",children:[Wi("span",{className:"text-[9px] text-slate-500 uppercase tracking-wide",children:"Equity"}),Cs("span",{className:"text-[11px] font-mono tabular-nums text-slate-200",children:[t,Og(n.equity)]})]}),Wi("div",{className:"h-4 w-px bg-slate-700"}),Wi(bA,{value:n.unrealizedPnl,label:"Open P&L"}),Wi("div",{className:"h-4 w-px bg-slate-700"}),Wi(bA,{value:n.realizedPnl,label:"Realized"}),Wi("div",{className:"h-4 w-px bg-slate-700"}),Cs("div",{className:"flex flex-col items-start leading-none",children:[Wi("span",{className:"text-[9px] text-slate-500 uppercase tracking-wide",children:"Spread"}),Cs("span",{className:"text-[11px] font-mono tabular-nums text-slate-200",children:[t,Og(o)]})]})]}):null}import{useCallback as gx,useState as $j}from"react";import{jsx as qi,jsxs as Zj}from"react/jsx-runtime";function Xj({eventBus:e}){let[t,n]=$j("1"),r=(l,c)=>Math.round(l*10**c)/10**c,o=l=>{let c=l.target.value,u=parseFloat(c);isNaN(u)||(c=Math.round(u).toString()),n(c)},a=gx(()=>{e.emit("trading:buy-market",{amount:parseFloat(t)})},[t]),i=gx(()=>{e.emit("trading:sell-market",{amount:parseFloat(t)})},[t]),s=gx(()=>{e.emit("trading:flatten",void 0)},[e]);return qi("div",{className:"flex gap-2 justify-center md:justify-self-end items-center order-2 md:order-3",children:Zj("div",{className:"flex items-center gap-1 rounded-md flex-wrap justify-center",children:[qi(pr,{variant:"ghost",size:"icon",className:"h-9 w-9 hover:bg-slate-800 text-slate-300 hover:text-white",onClick:()=>{n(l=>r(Math.max(0,parseFloat(l)-1),0).toString())},children:qi(Yo,{className:"h-4 w-4"})}),qi(ol,{value:t,onChange:o,className:"w-20 h-9 bg-transparent border-none text-center text-sm text-slate-200 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",placeholder:"Amount"}),qi(pr,{variant:"ghost",size:"icon",className:"h-9 w-9 hover:bg-slate-800 text-slate-300 hover:text-white",onClick:()=>{n(l=>r(parseFloat(l)+1,0).toString())},children:qi(ha,{className:"h-4 w-4"})}),qi(mc,{orientation:"vertical",className:"h-4 bg-slate-700"}),qi(pr,{variant:"ghost",size:"sm",className:"h-9 px-3 text-xs text-emerald-600 hover:bg-emerald-500/10 hover:text-emerald-600",onClick:()=>{a()},children:"Buy"}),qi(pr,{variant:"ghost",size:"sm",className:"h-9 px-3 text-xs hover:bg-rose-500/10 text-rose-600 hover:text-rose-600",onClick:()=>{i()},children:"Sell"}),qi(pr,{variant:"ghost",size:"sm",className:"h-9 px-3 text-xs text-slate-300 hover:bg-muted hover:text-white",onClick:s,children:"Flatten"})]})})}import{useCallback as Cx,useEffect as Ku,useLayoutEffect as eG,useMemo as CA,useRef as pl,useState as Vr}from"react";var ml=e=>e.tickSize&&e.tickSize>0?e.tickSize:.01;function Fm(e){if(e.tickValue&&e.tickValue>0)return e.tickValue;let t=ml(e)*(e.multiplier??1);return t>0?t:1}function Qj(e){let t=e?.contract,n=e?.priceFormat?.minTick??e?.tickSize??t?.tickSize;return{...t,...n&&n>0?{tickSize:n}:{},...t?.tickValue&&t.tickValue>0?{tickValue:t.tickValue}:n&&n>0?{tickValue:n*(t?.multiplier??1)}:{}}}var bx=e=>e.qtyStep&&e.qtyStep>0?e.qtyStep:1,Jj=e=>e.minQty&&e.minQty>0?e.minQty:bx(e);function vA(e){if(!Number.isFinite(e)||e<=0)return 0;for(let t=0;t<=10;t++){let n=e*10**t;if(Math.abs(n-Math.round(n))<1e-9)return t}return 10}var wA=e=>vA(bx(e));function _m(e,t){if(!Number.isFinite(e)||e<=0)return 0;let n=bx(t);return Number((Math.floor(e/n+1e-9)*n).toFixed(vA(n)))}function Tc(e){let t=ml(e);if(!Number.isFinite(t)||t<=0)return 2;for(let n=0;n<=10;n++){let r=t*10**n;if(Math.abs(r-Math.round(r))<1e-9)return n}return 10}function ks(e,t){let n=ml(t);return Number.isFinite(e)?Number((Math.round(e/n)*n).toFixed(Tc(t))):0}var Vm=(e,t,n)=>Math.round((t-e)/ml(n)),_g=(e,t)=>Fm(t)*Math.max(0,e),zm=(e,t,n)=>Math.max(0,e)*(n.multiplier??1)*Math.max(0,t),xA=(e,t)=>(e==="long"?1:-1)*(t==="tp"?1:-1);function Hm(e,t,n,r,o){return ks(t+xA(r,e)*Math.abs(n)*ml(o),o)}function yx(e,t,n,r,o){return xA(r,e)*Vm(t,n,o)}var vx=[{id:"contracts",label:"Size"},{id:"value",label:"Position value"},{id:"balancePct",label:"% of balance"},{id:"riskUsd",label:"Risk, cash",needsStop:!0},{id:"riskPct",label:"Risk, % of balance",needsStop:!0}],yA=e=>e==="riskUsd"||e==="riskPct";function SA(e,t,n){if(!Number.isFinite(t)||t<=0)return 0;let{entry:r,stopTicks:o,balance:a,spec:i}=n,s=c=>{let u=Math.abs(o)*Fm(i);return u>0?_m(c/u,i):0},l=c=>{let u=zm(r,1,i);return u>0?_m(c/u,i):0};switch(e){case"contracts":return _m(t,i);case"value":return l(t);case"balancePct":return l(a*t/100);case"riskUsd":return s(t);case"riskPct":return s(a*t/100)}}function wx(e,t,n){if(!Number.isFinite(t)||t<=0)return 0;let{entry:r,stopTicks:o,balance:a,spec:i}=n;switch(e){case"contracts":return t;case"value":return zm(r,t,i);case"balancePct":return a>0?zm(r,t,i)/a*100:0;case"riskUsd":return Math.abs(o)*_g(t,i);case"riskPct":return a>0?Math.abs(o)*_g(t,i)/a*100:0}}function xx(e,t,n,r){let o=ks(t.entry,r),a=e==="long";return{side:e,type:n<=0||o===ks(n,r)?"market":a?o<n?"limit":"stop":o>n?"limit":"stop",entry:o,target:ks(a?o+t.upAmount:o-t.downAmount,r),stop:ks(a?o-t.downAmount:o+t.upAmount,r),qty:_m(t.qty,r)}}function Sx(e){let{spec:t,side:n,type:r,balance:o}=e,a=[],i=e.mark>0?e.mark:(e.bid+e.ask)/2,s=r==="market"?i:r==="stop"?e.stopPrice:e.limitPrice,l=ks(s,t);r!=="market"&&!(l>0)?a.push({field:"entry",message:"Set an entry price."}):r==="limit"&&i>0?(n==="long"&&l>i&&a.push({field:"entry",message:"A buy limit sits at or below the market."}),n==="short"&&l<i&&a.push({field:"entry",message:"A sell limit sits at or above the market."})):r==="stop"&&i>0&&(n==="long"&&l<i&&a.push({field:"entry",message:"A buy stop sits at or above the market."}),n==="short"&&l>i&&a.push({field:"entry",message:"A sell stop sits at or below the market."}));let c=e.slEnabled?Math.abs(e.slTicks):0,u=e.tpEnabled?Math.abs(e.tpTicks):0;e.slEnabled&&c===0&&a.push({field:"sl",message:"A stop needs a distance from entry."}),e.tpEnabled&&u===0&&a.push({field:"tp",message:"A target needs a distance from entry."}),yA(e.amountMode)&&c===0&&a.push({field:"amount",message:"Sizing by risk needs a stop - that is what the risk is measured to."});let d=SA(e.amountMode,e.amount,{entry:l,stopTicks:c,balance:o,spec:t}),m=Jj(t);d<=0?a.push({field:"amount",message:e.amount>0&&!yA(e.amountMode)?`Not enough for the smallest order, ${m}.`:"Set an amount."}):d<m&&a.push({field:"amount",message:`The smallest order here is ${m}.`});let f=y=>{let v=y*_g(d,t);return{usd:v,pct:o>0?v/o*100:0}},h=c>0&&d>0?f(c):null,p=u>0&&d>0?f(u):null,g=Math.max(0,Vm(e.bid,e.ask,t));return{entry:l,qty:d,tickValue:Fm(t),contractValue:zm(l,d,t),tpPrice:u>0?Hm("tp",l,u,n,t):null,slPrice:c>0?Hm("sl",l,c,n,t):null,risk:h,reward:p,rr:h&&p&&h.usd>0?p.usd/h.usd:null,spread:{ticks:g,usd:g*Fm(t)},problems:a,ok:a.length===0}}import{Fragment as PA,jsx as Ft,jsxs as Tn}from"react/jsx-runtime";var qm="#2962ff",Um="#f23645",Lx="#16181d",DA="#0f1116",AA="#1b1e25",BA="#22262e",Rx="#1e2128",tG=340,$u=12,kx=null,kA=null,TA=null,IA=e=>Math.max($u,Math.min(window.innerWidth-tG-$u,e)),MA=(e,t)=>{let n=window.innerHeight-t-$u;return Math.min(Math.max($u,e),Math.max($u,n))},Wm=e=>({fixed:"offset",price:"0",offset:String(e)}),LA=(e,t)=>t==="limit"?e==="long"?-1:1:t==="stop"?e==="long"?1:-1:0,Ts=e=>{let t=Number.parseFloat(e);return Number.isFinite(t)?t:0},jm=(e,t=2)=>e.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t}),Px=e=>jm(e,e!==0&&Math.abs(e)<1?4:2),nG=e=>`${e.toFixed(2)}%`;function Tx({value:e,options:t,onChange:n,prefix:r}){let o=t.find(a=>a.id===e);return Tn(Ha,{children:[Tn(Va,{className:"group flex items-center gap-1 rounded text-[11.5px] text-slate-500 outline-none transition-colors hover:text-slate-300 focus-visible:text-slate-300",children:[r?`${r}, ${(o?.label??e).toLowerCase()}`:o?.label??e,Ft(Zn,{className:"h-3 w-3 opacity-60 transition-transform group-data-[state=open]:rotate-180"})]}),Ft(va,{align:"start",className:"min-w-[172px] border-[#22262e] bg-[#1b1e25] p-1 z-[210]",children:t.map(a=>Ft(ta,{onSelect:()=>n(a.id),className:`cursor-pointer rounded text-[12px] focus:bg-[#272c35] ${a.id===e?"text-slate-100":"text-slate-400"}`,children:a.label},a.id))})]})}function Ix({value:e,onChange:t,readout:n,readoutUnit:r,onSwap:o,disabled:a,invalid:i,onActivate:s}){return Tn("div",{className:"flex h-9 items-stretch overflow-hidden rounded-md border transition-colors focus-within:border-slate-600",style:{background:DA,borderColor:i?"rgba(229,83,75,0.5)":BA,opacity:a?.4:1},children:[Ft("input",{type:"text",inputMode:"decimal",value:e,disabled:a&&!s,onPointerDown:()=>a&&s?.(),onFocus:()=>a&&s?.(),onChange:l=>t(l.target.value),className:"min-w-0 flex-1 bg-transparent px-2.5 text-[12.5px] tabular-nums text-slate-100 outline-none placeholder:text-slate-600"}),Ft("button",{type:"button",onClick:a&&s?s:o,disabled:a&&!s,title:"Swap which side you set",className:"flex w-8 shrink-0 items-center justify-center text-slate-600 outline-none transition-colors hover:text-slate-300 focus-visible:text-slate-300 disabled:hover:text-slate-600",children:Ft(Bd,{className:"h-3.5 w-3.5"})}),Tn("div",{className:"flex shrink-0 items-center gap-1 pr-2.5 pl-1",children:[Ft("span",{className:"text-[12.5px] tabular-nums text-slate-400",children:n}),Ft("span",{className:"text-[10.5px] text-slate-600",children:r})]})]})}function rG({rows:e}){return Ft("div",{className:"flex flex-col gap-1.5 rounded-md p-2.5",style:{background:AA},children:e.map(t=>Tn("div",{className:"flex items-baseline justify-between gap-3",children:[Ft("span",{className:"text-[11.5px] text-slate-500",children:t.label}),Tn("span",{className:"flex items-baseline gap-1.5",children:[t.lead&&Ft("span",{className:"text-[11px] tabular-nums text-slate-500",children:t.lead}),Ft("span",{className:"text-[12px] tabular-nums",style:{color:t.tone??"#cbd5e1"},children:t.value}),t.unit&&Ft("span",{className:"text-[10px] text-slate-600",children:t.unit})]})]},t.label))})}function oG({ticket:e,currencySymbol:t}){let n=[{label:"Risk",figure:e.risk,tone:Um,sign:"-",missing:"No stop set"},{label:"Reward",figure:e.reward,tone:qm,sign:"+",missing:"No target set"}];return Tn("div",{className:"relative flex overflow-hidden rounded-md",style:{background:AA},children:[n.map(({label:r,figure:o,tone:a,sign:i,missing:s},l)=>Tn("div",{className:`flex flex-1 flex-col gap-0.5 px-2.5 py-2 ${l===0?"items-start":"items-end"}`,children:[Ft("span",{className:"text-[10.5px] text-slate-500",children:r}),o?Tn(PA,{children:[Tn("span",{className:"flex items-baseline gap-1",children:[Tn("span",{className:"text-[15px] font-semibold tabular-nums tracking-tight",style:{color:a},children:[i,Px(o.usd)]}),Ft("span",{className:"text-[10px] text-slate-600",children:t})]}),Tn("span",{className:"text-[10.5px] tabular-nums text-slate-500",children:[nG(o.pct)," of balance"]})]}):Tn(PA,{children:[Ft("span",{className:"text-[15px] font-semibold tracking-tight text-slate-700",children:"\u2014"}),Ft("span",{className:"text-[10.5px] text-slate-600",children:s})]})]},r)),e.rr!==null&&Tn("span",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded px-1.5 py-0.5 text-[10.5px] tabular-nums text-slate-400",style:{background:Lx},children:["1:",e.rr.toFixed(2)]})]})}function Mx({label:e,hint:t,checked:n,onChange:r}){return Tn("div",{className:"flex items-start justify-between gap-3",children:[Tn("div",{className:"flex min-w-0 flex-col gap-0.5",children:[Ft("span",{className:"text-[11.5px] text-slate-400",children:e}),Ft("span",{className:"text-[10.5px] leading-snug text-slate-600",children:t})]}),Ft(Qr,{checked:n,onCheckedChange:r,className:"mt-0.5 shrink-0 scale-[0.8] data-[state=checked]:bg-blue-500"})]})}function RA({title:e,open:t,onToggle:n,children:r}){return Tn("div",{className:"flex flex-col gap-2.5",children:[Tn("button",{type:"button",onClick:n,className:"flex items-center justify-between border-t pt-3 text-left outline-none",style:{borderColor:Rx},children:[Ft("span",{className:"text-[12.5px] font-medium text-slate-300",children:e}),t?Ft(oi,{className:"h-3.5 w-3.5 text-slate-600"}):Ft(Zn,{className:"h-3.5 w-3.5 text-slate-600"})]}),t&&r]})}var Fg=["market","limit","stop"],aG=[{id:"offset",label:"Ticks"},{id:"price",label:"Price"}],iG=[{id:"gtc",label:"Good till cancelled"},{id:"day",label:"Day"},{id:"ioc",label:"Immediate or cancel"},{id:"fok",label:"Fill or kill"}];function sG({eventBus:e,spec:t,symbol:n,onPlaceOrder:r,onClose:o,balance:a=0,currencySymbol:i="USD",initialPosition:s={x:24,y:96},drawings:l}){let[c,u]=Vr({bid:0,ask:0,last:0}),d=pl(c);d.current=c;let m=pl(t);m.current=t;let[f,h]=Vr(a),[p,g]=Vr(null),y=pl(null),[v,b]=Vr(null),S=pl(l);S.current=l;let C=!!l;Ku(()=>{let J=()=>{let Le=S.current?.selected();g(Le?.name==="long"?"long":Le?.name==="short"?"short":null)};J();let Te=[e.on("playback:tick",({bid:Le,ask:ot,last:tt})=>u({bid:Le,ask:ot,last:tt})),e.on("account:update",({balance:Le})=>h(Le)),e.on("drawing:selected",J)];return()=>Te.forEach(Le=>Le())},[e,C]);let w=kA,[k,M]=Vr(w?.side??"long"),[I,x]=Vr(w?.type??"market"),[T,R]=Vr(w?.tif??"gtc"),[P,D]=Vr(w?.entry??Wm("0")),[N,O]=Vr(w?.amountMode??"contracts"),[A,B]=Vr(w?.amount??"1"),[E,L]=Vr(w?.tpOn??!1),[z,Y]=Vr(w?.slOn??!1),[G,H]=Vr(w?.tp??Wm("80")),[W,U]=Vr(w?.sl??Wm("40")),[V,K]=Vr(w?.exitsOpen??!0),[Z,de]=Vr(w?.extrasOpen??!1),[ze,xe]=Vr(w?.reduceOnly??!1),[Ae,Oe]=Vr(w?.keepOpen??!1),[ke,Q]=Vr(w?.confirmFirst??!1),[Pe,_]=Vr(!1),ie=pl(void 0);Ku(()=>()=>window.clearTimeout(ie.current),[]);let se=pl(null);se.current={side:k,type:I,tif:T,entry:P,amountMode:N,amount:A,tpOn:E,slOn:z,tp:G,sl:W,exitsOpen:V,extrasOpen:Z,reduceOnly:ze,confirmFirst:ke,keepOpen:Ae},Ku(()=>()=>{kA=se.current},[]);let Se=Tc(t),Re=ml(t),ye=J=>jm(J,Se),$e=J=>jm(J,wA(t)),Ue=J=>J.toFixed(Se),je=CA(()=>{let J=k==="long"?c.ask:c.bid;return J>0?J:c.last},[k,c]),ht=Cx((J,Te,Le)=>Le==="entry"?{price:J.fixed==="price"?Ts(J.price):ks(Te+Ts(J.offset)*Re,t),offset:J.fixed==="offset"?Ts(J.offset):Vm(Te,Ts(J.price),t)}:{price:J.fixed==="price"?Ts(J.price):Hm(Le,Te,Ts(J.offset),k,t),offset:J.fixed==="offset"?Ts(J.offset):yx(Le,Te,Ts(J.price),k,t)},[k,t,Re]),Be=ht(P,je,"entry"),xt=I==="market"?je:Be.price,fn=ht(G,xt,"tp"),In=ht(W,xt,"sl"),kt=CA(()=>Sx({side:k,type:I,limitPrice:Be.price,stopPrice:Be.price,mark:c.last,bid:c.bid,ask:c.ask,amountMode:N,amount:Ts(A),tpEnabled:E,tpTicks:fn.offset,slEnabled:z,slTicks:In.offset,balance:f,spec:t}),[k,I,Be.price,c,N,A,E,fn.offset,z,In.offset,f,t]),it=J=>kt.problems.find(Te=>Te.field===J),ft=J=>{let Te=wx(J,kt.qty,{entry:xt,stopTicks:z?Math.abs(In.offset):0,balance:f,spec:t});O(J),Te>0&&B(J==="contracts"?String(Te):Te.toFixed(2))},oe=J=>{M(J),I!=="market"&&D(Wm(LA(J,I)))},pe=J=>{x(J),J!=="market"&&D(Wm(LA(k,J)))},fe=(J,Te)=>J(Le=>Le.fixed==="offset"?{fixed:"price",price:Ue(Te.price),offset:Le.offset}:{fixed:"offset",price:Le.price,offset:String(Te.offset)}),Ie=Cx(J=>{if(J.name!=="long"&&J.name!=="short")return;let Te=m.current,Le=J.state,ot=xx(J.name,{entry:Le.a.price,upAmount:Le.upAmount,downAmount:Le.downAmount,qty:Le.qty},d.current.last,Te);M(ot.side),x(ot.type),ot.type!=="market"&&D({fixed:"price",price:ot.entry.toFixed(Tc(Te)),offset:"0"}),O("contracts"),B(String(ot.qty)),L(!0),Y(!0),H({fixed:"price",price:ot.target.toFixed(Tc(Te)),offset:"0"}),U({fixed:"price",price:ot.stop.toFixed(Tc(Te)),offset:"0"}),K(!0)},[]),Ve=()=>{let J=l?.selected()??y.current;!J||J.name!=="long"&&J.name!=="short"||(Ie(J),b(J.id))};Ku(()=>e.on("trading:ticket-requested",({drawingId:J,requestId:Te})=>{if(Te===TA||(TA=Te,!J))return;let Le=S.current?.byId(J);!Le||Le.name!=="long"&&Le.name!=="short"||(Ie(Le),b(J))}),[e,Ie]),Ku(()=>{let J=S.current;if(!v||!J)return;let Te=()=>{let Le=J.byId(v);if(!Le){b(null);return}Ie(Le)};return Te(),J.subscribe(Te)},[v,C,Ie]);let qe=()=>{if(!kt.ok)return;if(ke&&!Pe){_(!0),window.clearTimeout(ie.current),ie.current=window.setTimeout(()=>_(!1),4e3);return}window.clearTimeout(ie.current),_(!1);let J=Te=>[{id:pn(8),price:Te,qty:kt.qty,triggered:!1,triggeredAt:0}];r({side:k,type:I,qty:kt.qty,symbol:n,tif:T,...ze?{reduceOnly:!0}:{},...I==="limit"?{limitPrice:kt.entry}:{},...I==="stop"?{stopPrice:kt.entry}:{},...kt.tpPrice!==null?{bracketTp:J(kt.tpPrice)}:{},...kt.slPrice!==null?{bracketSl:J(kt.slPrice)}:{}}),b(null),Ae||o?.()},Fe=k==="long",De=Fe?qm:Um;Ku(()=>{let J=()=>e.emit("trading:preview",{lines:[],symbol:n});if(v||kt.qty<=0)return J(),J;let Te=tt=>({price:0,kind:"custom",preview:!0,movable:!0,qty:kt.qty,...tt}),Le=tt=>`${tt<0?"-":"+"}$${Math.abs(tt).toFixed(2)}`,ot=[...I==="market"?[]:[Te({id:"preview-entry",kind:I==="limit"?"limit":"stop",side:k,price:kt.entry,label:`${Fe?"Buy":"Sell"} ${I==="limit"?"Limit":"Stop"}`,onMove:tt=>D({fixed:"price",price:Ue(tt),offset:"0"}),onClose:()=>o?.()})],...kt.tpPrice!==null?[Te({id:"preview-tp",kind:"tp",price:kt.tpPrice,label:`TP ${Le(kt.reward?.usd??0)}`,onMove:tt=>H({fixed:"price",price:Ue(tt),offset:"0"}),onClose:()=>L(!1)})]:[],...kt.slPrice!==null?[Te({id:"preview-sl",kind:"sl",price:kt.slPrice,label:`SL ${Le(-(kt.risk?.usd??0))}`,onMove:tt=>U({fixed:"price",price:Ue(tt),offset:"0"}),onClose:()=>Y(!1)})]:[]];return e.emit("trading:preview",{lines:ot,symbol:n}),J},[e,n,v,k,I,De,Fe,kt.entry,kt.qty,kt.tpPrice,kt.slPrice,kt.reward?.usd,kt.risk?.usd]);let we=pl(null),[_e,Ne]=Vr(()=>kx??s),dt=pl(null),Pt=Cx(J=>{let Te=we.current?.offsetHeight??0,Le={x:IA(J.x),y:MA(J.y,Te)};kx=Le,Ne(Le)},[]);return eG(()=>{let J=we.current;if(!J)return;let Te=()=>{let ot=J.offsetHeight;Ne(tt=>{let mt={x:IA(tt.x),y:MA(tt.y,ot)};return mt.x===tt.x&&mt.y===tt.y?tt:(kx=mt,mt)})};Te();let Le=new ResizeObserver(Te);return Le.observe(J),window.addEventListener("resize",Te),()=>{Le.disconnect(),window.removeEventListener("resize",Te)}},[]),Tn("div",{ref:we,className:"fixed z-[200] flex w-[370px] min-h-0 select-none flex-col overflow-hidden rounded-xl border shadow-2xl",style:{left:_e.x,top:_e.y,background:Lx,borderColor:BA,maxHeight:`calc(100vh - ${_e.y+$u}px)`},children:[Tn("div",{className:"flex shrink-0 cursor-grab items-center gap-2 px-3 py-3 active:cursor-grabbing",onPointerDown:J=>{dt.current={dx:J.clientX-_e.x,dy:J.clientY-_e.y},J.target.setPointerCapture(J.pointerId)},onPointerMove:J=>{let Te=dt.current;Te&&Pt({x:J.clientX-Te.dx,y:J.clientY-Te.dy})},onPointerUp:()=>{dt.current=null},children:[Ft("img",{src:"/icon-star.ico",alt:"",className:"w-5"}),Ft("span",{className:"text-[13px] font-medium tracking-tight text-slate-100 ",children:n||"Order"}),o&&Ft("button",{type:"button",onClick:o,className:"ml-auto shrink-0 text-slate-600 outline-none transition-colors hover:text-slate-300",children:Ft(_r,{className:"h-4 w-4"})})]}),Tn("div",{className:"flex shrink-0 flex-col gap-3 px-3 pb-3",children:[Tn("div",{className:"relative flex overflow-hidden rounded-xl",style:{background:DA},children:[["short","long"].map(J=>{let Te=k===J,Le=J==="short",ot=Le?Um:qm;return Tn("button",{type:"button",onClick:()=>oe(J),className:`flex flex-1 flex-col gap-0.5 px-3 py-2 outline-none transition-colors ${Le?"items-start rounded-l-xl":"items-end rounded-r-xl"}`,style:{background:Te?`${ot}1f`:"transparent",boxShadow:Te?`inset 0 0 0 1px ${ot}59`:void 0},children:[Ft("span",{className:"text-[11.5px] font-medium",style:{color:Te?ot:"#64748b"},children:Le?"Sell":"Buy"}),Ft("span",{className:"text-[17px] font-semibold tracking-tight",style:{color:Te?ot:"#94a3b8"},children:ye(Le?c.bid:c.ask)})]},J)}),Ft("span",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-4 rounded px-1.5 py-0.5 text-[10.5px] tabular-nums text-slate-400",style:{background:Lx},children:kt.spread.usd})]}),v?Tn("div",{className:"flex items-center gap-1.5 rounded-md border py-1.5 pl-2.5 pr-1.5 text-[11.5px]",style:{borderColor:`${De}59`,color:De},children:[Ft(tu,{className:"h-3.5 w-3.5 shrink-0"}),Tn("span",{className:"truncate",children:["Following the ",k," drawing"]}),Tn(Ht,{children:[Ft(Ot,{asChild:!0,children:Tn("button",{type:"button",onClick:()=>b(null),className:"ml-auto flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-slate-500 outline-none transition-colors hover:bg-white/5 hover:text-slate-300",children:[Ft(hf,{className:"h-3 w-3"}),"Unlink"]})}),Ft(_t,{className:"bg-background border border-border z-[210]",children:"Stop following it"})]})]}):p&&Tn("button",{type:"button",onPointerDown:()=>{y.current=l?.selected()??null},onClick:Ve,className:"flex items-center justify-center gap-1.5 rounded-md border border-dashed py-1.5 text-[11.5px] outline-none transition-[filter,transform] hover:brightness-125 active:scale-[0.99]",style:{borderColor:`${p==="long"?qm:Um}66`,color:p==="long"?qm:Um},children:[Ft(tu,{className:"h-3 w-3"}),"Follow the selected ",p," drawing"]}),Tn("div",{className:"relative flex border-b",style:{borderColor:Rx},children:[Fg.map(J=>Ft("button",{type:"button",onClick:()=>pe(J),className:`flex-1 pb-2 text-[12.5px] capitalize outline-none transition-colors ${I===J?"text-slate-100":"text-slate-500 hover:text-slate-300"}`,children:J},J)),Ft("span",{"aria-hidden":!0,className:"absolute bottom-[-1px] h-[2px] rounded-full motion-safe:transition-[left] motion-safe:duration-200 motion-safe:ease-[cubic-bezier(0.22,1,0.36,1)]",style:{background:De,width:`${100/Fg.length}%`,left:`${Math.max(0,Fg.indexOf(I))*100/Fg.length}%`}})]})]}),Tn("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 pb-3",children:[I!=="market"&&Tn("div",{className:"flex flex-col gap-1.5",children:[Ft("span",{className:"text-[11.5px] text-slate-500",children:P.fixed==="offset"?`Ticks from ${Fe?"ask":"bid"}`:"Entry price"}),Ft(Ix,{value:P.fixed==="price"?P.price:P.offset,onChange:J=>D(Te=>({...Te,[Te.fixed==="price"?"price":"offset"]:J})),readout:P.fixed==="price"?String(Be.offset):ye(Be.price),readoutUnit:P.fixed==="price"?"ticks":"price",onSwap:()=>fe(D,Be),invalid:!!it("entry")})]}),Tn("div",{className:"flex flex-col gap-1.5",children:[Ft(Tx,{value:N,options:vx,onChange:ft}),Ft(Ix,{value:A,onChange:B,readout:N==="contracts"?jm(kt.contractValue,0):String(kt.qty),readoutUnit:N==="contracts"?i:"contracts",onSwap:()=>ft(N==="contracts"?"value":"contracts"),invalid:!!it("amount")})]}),Ft(RA,{title:"Exits",open:V,onToggle:()=>K(J=>!J),children:[["tp","Take profit",E,L,G,H,fn],["sl","Stop loss",z,Y,W,U,In]].map(([J,Te,Le,ot,tt,mt,qt])=>Tn("div",{className:"flex flex-col gap-1.5",children:[Tn("div",{className:"flex items-center justify-between gap-2",children:[Ft(Tx,{prefix:Te,value:tt.fixed,options:aG,onChange:Dt=>mt(rr=>rr.fixed===Dt?rr:Dt==="price"?{fixed:"price",price:Ue(qt.price),offset:rr.offset}:{fixed:"offset",price:rr.price,offset:String(qt.offset)})}),Ft(Qr,{checked:Le,onCheckedChange:ot,className:"scale-[0.8] data-[state=checked]:bg-blue-500"})]}),Ft(Ix,{disabled:!Le,onActivate:()=>ot(!0),value:tt.fixed==="price"?tt.price:tt.offset,onChange:Dt=>mt(rr=>({...rr,[rr.fixed==="price"?"price":"offset"]:Dt})),readout:tt.fixed==="price"?String(qt.offset):ye(qt.price),readoutUnit:tt.fixed==="price"?"ticks":"price",onSwap:()=>fe(mt,qt),invalid:!!it(J)})]},J))}),Tn(RA,{title:"Extra settings",open:Z,onToggle:()=>de(J=>!J),children:[Tn("div",{className:"flex items-center justify-between gap-3",children:[Ft("span",{className:"text-[11.5px] text-slate-500",children:"Time in force"}),Ft(Tx,{value:T,options:iG,onChange:J=>R(J)})]}),Ft(Mx,{label:"Reduce only",hint:"Never opens or grows a position - only closes one",checked:ze,onChange:xe}),Ft(Mx,{label:"Confirm before placing",hint:"The button asks a second time before the order goes",checked:ke,onChange:J=>{Q(J),_(!1)}}),Ft(Mx,{label:"Keep the ticket open",hint:"Stays up after an order goes, for placing several in a row",checked:Ae,onChange:Oe})]})]}),Tn("div",{className:"flex shrink-0 flex-col gap-2 border-t px-3 pb-3 pt-3",style:{borderColor:Rx},children:[Ft(oG,{ticket:kt,currencySymbol:i}),Ft(rG,{rows:[{label:"Position value",value:jm(kt.contractValue),unit:i},{label:"Per tick",value:Px(kt.tickValue*Math.max(0,kt.qty)),unit:i},{label:"Spread cost",value:Px(kt.spread.usd*Math.max(0,kt.qty)),unit:i}]}),kt.problems.length>0&&Ft("p",{className:"text-[11.5px] leading-relaxed text-amber-500/90",children:kt.problems[0].message}),Tn(pr,{type:"button",disabled:!kt.ok,onClick:qe,className:"h-[52px] w-full flex-col gap-0.5 rounded-lg border-0 text-white shadow-none transition-[transform,filter] duration-100 hover:brightness-110 active:scale-[0.985] active:brightness-95 disabled:opacity-30",style:{background:De},children:[Ft("span",{className:"text-[14px] font-semibold leading-none",children:Pe?"Press again to confirm":`${Fe?"Buy":"Sell"} ${$e(kt.qty)} ${n??""}`}),Ft("span",{className:"text-[11px] font-normal leading-none text-white/75",children:Pe?`${Fe?"Buy":"Sell"} ${$e(kt.qty)} ${n??""} ${I==="market"?"at market":`@ ${ye(kt.entry)}`}`:I==="market"?"at market":`${I} @ ${ye(kt.entry)}`})]})]})]})}export{vx as AMOUNT_MODES,Dm as AccountManager,Kj as AccountSummary,Rm as ChartModel,nm as DATA_LEVEL_LABELS,Ye as DEFAULT_CHART_SETTINGS,od as DataEngine,Tg as Depth,Om as DepthChart,Pm as DrawingStore,gc as ExecutionEngine,Xi as LiveTransformer,l2 as MICRO_FEE_SCHEDULE,cg as NQ_FEE_SCHEDULE,sG as OrderPanel,Lm as PluginRegistry,Xj as QuickTradingButtons,om as RenderEngine,dA as SAVE_VERSION,Zr as STORAGE_NAMESPACE,Kh as SessionMapper,Eg as SimulatedMarketAdapter,Cn as StorageKey,pc as TypedEventBus,S8 as ZERO_FEE_SCHEDULE,wx as amountFromQty,hp as chartStorageKeys,gp as chartStorageSize,xb as clearChartStorage,Mb as clipToSession,zm as contractValue,kw as createL3MatchingEngine,Gu as createScriptedPlugin,Ov as createSessionMapper,Gj as createSimulatedAdapter,Sx as deriveTicket,Sw as feeScheduleFor,Pi as getSessionStatus,lw as hasTradingViewSettings,cm as importTradingViewSettings,cc as incompatibleReason,Ao as isCompatible,ed as isEmptyChunk,Ja as isMarketOpen,mp as isPersistenceEnabled,Hm as levelPrice,yx as levelTicks,LB as mergeL3Chunks,_g as moneyPerTick,rd as nextOpenNs,op as normalizeSymbolSearchResponse,nd as onChartStorageChange,NB as onPersistenceChange,Ej as parseChartSave,VB as prevCloseNs,Tc as priceDecimals,ab as processL2Chunk,nb as processL3Chunk,ap as processOhlcvChunk,rb as processOhlcvWithSupplemental,ob as processTickChunk,SA as qtyFromAmount,qr as readJSON,lm as readTradingViewChartSettings,sw as readTradingViewFavoriteDrawings,AW as resetTradingViewImport,Cb as restoreChartPreferences,_m as roundQty,ks as roundToTick,Ju as searchSymbolsLocally,Sb as serializeChartPreferences,AB as setChartStorageBackend,vb as setPersistenceEnabled,Qj as specForSymbol,Nj as stringifyChartSave,ml as tickSizeOf,Fm as tickValueOf,xx as ticketFromPosition,Vm as ticksBetween,Hj as useDepthChart,Lb as walkBackMarketNs,kr as writeJSON};
|