@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.cjs
ADDED
|
@@ -0,0 +1,1136 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var jD=Object.create;var nd=Object.defineProperty;var GD=Object.getOwnPropertyDescriptor;var YD=Object.getOwnPropertyNames;var KD=Object.getPrototypeOf,$D=Object.prototype.hasOwnProperty;var ux=e=>{throw TypeError(e)};var XD=(e,t,n)=>t in e?nd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ZD=(e,t)=>{for(var n in t)nd(e,n,{get:t[n],enumerable:!0})},dx=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of YD(t))!$D.call(e,o)&&o!==n&&nd(e,o,{get:()=>t[o],enumerable:!(r=GD(t,o))||r.enumerable});return e};var Ct=(e,t,n)=>(n=e!=null?jD(KD(e)):{},dx(t||!e||!e.__esModule?nd(n,"default",{value:e,enumerable:!0}):n,e)),QD=e=>dx(nd({},"__esModule",{value:!0}),e);var se=(e,t,n)=>XD(e,typeof t!="symbol"?t+"":t,n),fx=(e,t,n)=>t.has(e)||ux("Cannot "+n);var Oo=(e,t,n)=>(fx(e,t,"read from private field"),n?n.call(e):t.get(e)),mx=(e,t,n)=>t.has(e)?ux("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Eg=(e,t,n,r)=>(fx(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);var Q8={};ZD(Q8,{AMOUNT_MODES:()=>vg,AccountManager:()=>qu,AccountSummary:()=>X2,ChartModel:()=>Vu,DATA_LEVEL_LABELS:()=>ku,DEFAULT_CHART_SETTINGS:()=>Xe,DataEngine:()=>Rc,Depth:()=>xm,DepthChart:()=>Gu,DrawingStore:()=>Wu,ExecutionEngine:()=>ll,LiveTransformer:()=>Mi,MICRO_FEE_SCHEDULE:()=>Av,NQ_FEE_SCHEDULE:()=>mm,OrderPanel:()=>fD,PluginRegistry:()=>Hu,QuickTradingButtons:()=>Z2,RenderEngine:()=>Tu,SAVE_VERSION:()=>vw,STORAGE_NAMESPACE:()=>eo,SessionMapper:()=>tm,SimulatedMarketAdapter:()=>Im,StorageKey:()=>Pn,TypedEventBus:()=>il,ZERO_FEE_SCHEDULE:()=>XR,amountFromQty:()=>wg,chartStorageKeys:()=>ld,chartStorageSize:()=>cd,clearChartStorage:()=>rp,clipToSession:()=>sp,contractValue:()=>Xu,createL3MatchingEngine:()=>$h,createScriptedPlugin:()=>mc,createSessionMapper:()=>Eh,createSimulatedAdapter:()=>K2,deriveTicket:()=>Sg,feeScheduleFor:()=>Kh,getSessionStatus:()=>Ja,hasTradingViewSettings:()=>qh,importTradingViewSettings:()=>Pu,incompatibleReason:()=>ol,isCompatible:()=>Bo,isEmptyChunk:()=>Sc,isMarketOpen:()=>Ia,isPersistenceEnabled:()=>sd,levelPrice:()=>Zu,levelTicks:()=>yg,mergeL3Chunks:()=>kx,moneyPerTick:()=>Mm,nextOpenNs:()=>Mc,normalizeSymbolSearchResponse:()=>od,onChartStorageChange:()=>Tc,onPersistenceChange:()=>Nx,parseChartSave:()=>U2,prevCloseNs:()=>Xx,priceDecimals:()=>ml,processL2Chunk:()=>Ym,processL3Chunk:()=>Um,processOhlcvChunk:()=>ad,processOhlcvWithSupplemental:()=>jm,processTickChunk:()=>Gm,qtyFromAmount:()=>Cw,readJSON:()=>Gr,readTradingViewChartSettings:()=>Ru,readTradingViewFavoriteDrawings:()=>Wh,resetTradingViewImport:()=>SR,restoreChartPreferences:()=>ap,roundQty:()=>Ku,roundToTick:()=>Hi,searchSymbolsLocally:()=>xc,serializeChartPreferences:()=>op,setChartStorageBackend:()=>Bx,setPersistenceEnabled:()=>tp,specForSymbol:()=>J2,stringifyChartSave:()=>q2,tickSizeOf:()=>ys,tickValueOf:()=>$u,ticketFromPosition:()=>xg,ticksBetween:()=>Qu,useDepthChart:()=>j2,walkBackMarketNs:()=>lp,writeJSON:()=>Sr});module.exports=QD(Q8);function px(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 Cs(e,t){return{fromNs:e,toNs:t,fromMs:Number(e/1000000n),toMs:Number(t/1000000n),fromIso:px(e),toIso:px(t)}}var rd=class extends Error{constructor(n,r,o){super(r);se(this,"code",n);se(this,"httpStatus",o);this.name="DataAdapterError"}};var ca={ExactSymbol:0,SymbolPrefix:1,TokenSymbolPrefix:2,WordPrefix:3,SymbolSubstring:4,Exchange:5,Fuzzy:6,NoMatch:Number.MAX_SAFE_INTEGER},JD=.5,eA=3,tA=2,Og=/[^a-z0-9]+/,hx=new WeakMap;function gx(e){if(!e)return[];let t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2");return[...e.toLowerCase().split(Og),...t.toLowerCase().split(Og)].filter(Boolean)}function nA(e){let t=hx.get(e);if(t)return t;let n=new Set;for(let a of[e.longName??"",e.description??"",...e.keywords??[]])for(let i of gx(a))n.add(i);let r=new Set;for(let a of[e.exchange??"",e.listedExchange??""])for(let i of gx(a))r.add(i);let o={symbol:e.symbol.toLowerCase(),words:[...n],exchangeWords:[...r]};return hx.set(e,o),o}function rA(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 bx(e,t){if(t.length<eA||e[0]!==t[0])return!1;let n=rA(e,t);return n!==-1&&n<=t.length*tA}function oA(e,t){if(e.symbol.startsWith(t))return ca.TokenSymbolPrefix;for(let n of e.words)if(n.startsWith(t))return ca.WordPrefix;if(e.symbol.includes(t))return ca.SymbolSubstring;for(let n of e.exchangeWords)if(n.startsWith(t))return ca.Exchange;if(bx(e.symbol,t))return ca.Fuzzy;for(let n of e.words)if(bx(n,t))return ca.Fuzzy;return ca.NoMatch}function yx(e,t,n){let r=nA(e);if(r.symbol===n)return ca.ExactSymbol;if(r.symbol.startsWith(n))return ca.SymbolPrefix;let o=0;for(let a of t){let i=oA(r,a);if(i>=ca.NoMatch)return ca.NoMatch;o=Math.max(o,i)}return o}function vx(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 xc(e,t){let n=t.query.trim().toLowerCase(),r=n.split(Og).filter(Boolean),o=[];e.forEach((u,d)=>{let m=u.subsymbols??[];if(!vx(u,t)&&!m.some(h=>vx(h,t)))return;let f=ca.ExactSymbol;if(r.length){f=yx(u,r,n);for(let h of m)f=Math.min(f,yx(h,r,n)+JD);if(f>=ca.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 od(e){return Array.isArray(e)?{symbols:e,hasMore:!1}:e}function wx(e){return JSON.stringify([e.query.trim().toLowerCase(),e.type??"",e.exchange??"",e.dataLevel??"",e.limit??0,e.cursor??""])}function gl(){return{bids:new Map,asks:new Map,bestBid:null,bestAsk:null}}function _g(e){let t=null;for(let n of e.bids.values())(t===null||n.price>t)&&(t=n.price);e.bestBid=t}function Fg(e){let t=null;for(let n of e.asks.values())(t===null||n.price<t)&&(t=n.price);e.bestAsk=t}function bl(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&&_g(e):a===e.bestAsk&&Fg(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&&_g(e):i<(e.bestAsk??1/0)?e.bestAsk=i:a===e.bestAsk&&Fg(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&&_g(e)}if(o){let a=o.price;e.asks.delete(t.order_id),a===e.bestAsk&&Fg(e)}}}function zg(e){return e.bestBid}function Hg(e){return e.bestAsk}var aA={tickSize:.25,imbalanceRatio:3,stackMinCount:3,absorptionMult:2.5,absorptionDeltaFrac:.25,unfinishedTicks:1,diagRatio:3};function Sx(e,t,n={}){if(t===0n||e.length===0)return[];let r={...aA,...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=iA(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),H=L.bid+L.ask,K=L.ask-L.bid;H>S&&(S=H),Math.abs(K)>C&&(C=Math.abs(K)),H>k&&(k=H,w=E);let G=Math.max(p.open,p.close),V=Math.min(p.open,p.close),q=E<=G&&E>=V,j=H>=b&&H>0&&Math.abs(K)/H<=l&&q;M.set(E,{price:E,bidVol:L.bid,askVol:L.ask,delta:K,totalVol:H,bidImbalance:!1,askImbalance:!1,diagAskImbalance:!1,diagBidImbalance:!1,absorption:j})}for(let[,E]of M){let{bidVol:L,askVol:H}=E;H>0&&(L===0||H/L>=a)&&(E.askImbalance=!0),L>0&&(H===0||L/H>=a)&&(E.bidImbalance=!0)}for(let[E,L]of M){let H=M.get(d(E-o)),K=M.get(d(E+o));H&&L.askVol>0&&(H.bidVol===0||L.askVol/H.bidVol>=u)&&(L.diagAskImbalance=!0),K&&L.bidVol>0&&(K.askVol===0||L.bidVol/K.askVol>=u)&&(L.diagBidImbalance=!0)}let I=Array.from(M.values()).sort((E,L)=>L.price-E.price),x=[],T=[];xx(I,E=>E.askImbalance,i,x),xx(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),H=M.get(L);if(!H||H.askVol===0){R=!0;break}}let N=d(p.low);for(let E=0;E<c;E++){let L=d(N+E*o),H=M.get(L);if(!H||H.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 xx(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 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}function Ta(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 Cx=20,sA=-2147483648,lA=100,cA={A:0,C:1,M:2,T:3,F:4,R:5},uA={B:0,A:1,N:2},dA=50000000n;function fA(e,t){let n=new ArrayBuffer(e.length*Cx),r=new DataView(n);for(let o=0;o<e.length;o++){let a=e[o],i=o*Cx;r.setBigInt64(i,t[o],!0);let s=a.price===null?sA:Math.round(a.price*lA);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=cA[a.action]??0,u=uA[a.side]??2;r.setUint8(i+19,(c&15)<<4|(u&3)<<2)}return n}function Um(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=gl(),i=new BigInt64Array(e.length);for(let d=0;d<e.length;d++)i[d]=Ta(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];bl(a,m);let h=Hg(a),p=zg(a);if(h!==s||p!==l){if(f-c>=dA||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?Sx(e,t,n):[];return{kind:"l3",compactBuf:fA(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 kx(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 ad(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 jm(e,t,n){let r=ad(e,n),o=t.map(a=>({resolution:a.resolution,bars:a.bars}));return{...r,supplemental:o}}var mA=50000000n;function Gm(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>=mA||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 pA=50000000n;function Ym(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>=pA||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 Sc(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 hA=`(()=>{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
|
+
`,Vg;function Tx(){return Vg||(Vg=URL.createObjectURL(new Blob([hA],{type:"text/javascript"}))),Vg}var yl=6,Ti=4,Wi=8;function Wg(e){return Number(e>>32n)}function qg(e){return Number(e&0xffffffffn)}function Km(e,t){return BigInt(e>>>0)<<32n|BigInt(t>>>0)}function Ix(e){let t=new Float64Array(e.length*yl);for(let n=0;n<e.length;n++){let r=e[n];t[n*yl+0]=Wg(r.ts),t[n*yl+1]=qg(r.ts),t[n*yl+2]=r.price,t[n*yl+3]=r.size,t[n*yl+4]=r.side==="B"?0:1,t[n*yl+5]=0}return t.buffer}function Mx(e){let t=new Float64Array(e.length*Ti);for(let n=0;n<e.length;n++)t[n*Ti+0]=Wg(e[n].ts),t[n*Ti+1]=qg(e[n].ts),t[n*Ti+2]=e[n].bestBid,t[n*Ti+3]=e[n].bestAsk;return t.buffer}function $m(e){let t=new Float64Array(e),n=t.length/Ti,r=new Array(n);for(let o=0;o<n;o++)r[o]={ts:Km(t[o*Ti+0],t[o*Ti+1]),bestBid:t[o*Ti+2],bestAsk:t[o*Ti+3]};return r}function Xm(e,t){let n=new Float64Array(e),r=n.length/Wi,o=new Map;for(let a=0;a<r;a++){let i=Km(n[a*Wi+0],n[a*Wi+1]);if(i>t)break;o.set(i,{open:n[a*Wi+2],high:n[a*Wi+3],low:n[a*Wi+4],close:n[a*Wi+5],volume:n[a*Wi+6],delta:n[a*Wi+7]})}return o}var vl=null,Lx=0,Cc=new Map;function Rx(){return vl||(vl=new Worker(Tx()),vl.onmessage=e=>{let t=e.data,n=Cc.get(t.id);if(n){if(Cc.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=Km(o.newFirstTsHi,o.newFirstTsLo),a.lastTs=Km(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})}}},vl.onerror=e=>{console.error("[SliceWorker] crashed",e);for(let[,t]of Cc)t.reject(new Error(`SliceWorker crashed: ${e.message}`));Cc.clear(),vl=null},vl)}function Ug(e,t,n,r){return new Promise((o,a)=>{let i=`slice-${++Lx}`;Cc.set(i,{kind:"slice",resolve:o,reject:a,originalCb:e,messageType:r}),Rx().postMessage({kind:"slice",id:i,buf:e._buf,length:e.length,capacity:e.capacity,start:t,end:n,messageType:r},[e._buf])})}function Px(e){return new Promise((t,n)=>{let r=`load-ingest-${++Lx}`;Cc.set(r,{kind:"load-ingest",resolve:t,reject:n});let o={kind:"load-ingest",id:r,tradesBuf:e.tradesBuf,phBuf:e.phBuf,barNsHi:Wg(e.barNs),barNsLo:qg(e.barNs)};Rx().postMessage(o,[e.tradesBuf,e.phBuf])})}var eo="christtrade:chart:",Pn={chartSettings:`${eo}settings`,customTimeframes:`${eo}custom-timeframes`,favoriteTimeframes:`${eo}favorite-timeframes`,drawingTemplates:`${eo}drawing-templates`,drawingFavorites:`${eo}drawing-favorites`,colorSwatches:`${eo}color-swatches`,pluginStartup:`${eo}plugin-startup`,pluginPanels:`${eo}plugin-panels`};function Xg(e){return`${eo}plugin:${e}`}function Zm(e,t){return`${eo}plugin:${e}:${t}`}function Ax(e){return`${eo}plugin:${e}:`}var Qm=`${eo}meta:`,id=`${eo}persist`,qi=new Map,jg=null;function Bx(e){jg=e,e&&gA(e),Jg()}function gA(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(eo)||t.has(n))continue;let r=window.localStorage.getItem(n);r!==null&&e.setItem(n,r)}}catch{}}var Zg={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 Jm(){return jg||(ep()?Zg:null)}function Qg(){let e=Jm();return!e||e===Zg&&!sd()?null:e}var kc=null,Gg=new Set,Yg=new Set;function Tc(e){return Yg.add(e),()=>Yg.delete(e)}function Jg(){Yg.forEach(e=>e())}function ep(){return typeof window<"u"&&typeof window.localStorage<"u"}function sd(){if(kc!==null)return kc;if(!ep())return!0;try{kc=window.localStorage.getItem(id)!=="false"}catch{kc=!0}return kc}function tp(e){if(kc=e,ep())try{if(window.localStorage.setItem(id,String(e)),e)for(let[t,n]of qi)window.localStorage.setItem(t,n)}catch{}Gg.forEach(t=>t(e))}function Nx(e){return Gg.add(e),()=>Gg.delete(e)}var Ex={"christtrade.l3-chart-settings":Pn.chartSettings,christrade_custom_tfs:Pn.customTimeframes,christrade_favorite_tfs:Pn.favoriteTimeframes,drawing_style_templates:Pn.drawingTemplates,"ct:drawing-favorites":Pn.drawingFavorites,"christtrade-color-picker-saved":Pn.colorSwatches},Kg="ctc:plugin:",Dx=!1;function bA(){if(!Dx&&(Dx=!0,!!ep()))try{let e=window.localStorage;for(let[n,r]of Object.entries(Ex)){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(Kg));for(let n of t){let r=e.getItem(n);if(r===null)continue;let o=`${eo}plugin:${n.slice(Kg.length)}`;e.getItem(o)===null&&e.setItem(o,r),e.removeItem(n)}}catch{}}function wl(e){let t=Qg();if(t){t===Zg&&bA();try{let n=t.getItem(e);if(n!==null)return n}catch{}}return qi.get(e)??null}function Gr(e,t){let n=wl(e);if(n===null)return t;try{return JSON.parse(n)}catch{return t}}function np(e,t){qi.set(e,t);let n=Qg();if(n)try{n.setItem(e,t)}catch{}}function Sr(e,t){try{np(e,JSON.stringify(t))}catch{}}function eb(e){qi.delete(e);try{Jm()?.removeItem(e)}catch{}}function Ox(e){for(let n of[...qi.keys()])n.startsWith(e)&&qi.delete(n);let t=Jm();if(t)try{t.keys().filter(n=>n.startsWith(e)).forEach(n=>t.removeItem(n))}catch{}}function ld(){let e=new Set,t=r=>r.startsWith(eo)&&!r.startsWith(Qm);for(let r of qi.keys())t(r)&&e.add(r);let n=Qg();if(n)try{n.keys().filter(t).forEach(r=>e.add(r))}catch{}return e.delete(id),[...e]}function rp(){let e=n=>n.startsWith(eo)&&n!==id&&!n.startsWith(Qm)||n.startsWith(Kg)||n in Ex;for(let n of[...qi.keys()])e(n)&&qi.delete(n);let t=Jm();if(t)try{t.keys().filter(e).forEach(n=>t.removeItem(n))}catch{}Jg()}function cd(){return ld().reduce((e,t)=>e+t.length+(wl(t)?.length??0),0)}var _x="$raw",$g=new Set([Pn.pluginStartup,Pn.pluginPanels]);function op(){let e={};for(let t of ld()){if($g.has(t))continue;let n=wl(t);if(n!==null)try{e[t]=JSON.parse(n)}catch{e[t]={[_x]:n}}}return e}function ap(e,t={}){if(e){if(t.replace)for(let n of ld())!(n in e)&&!$g.has(n)&&eb(n);for(let[n,r]of Object.entries(e)){if(!n.startsWith(eo)||n===id||$g.has(n))continue;let o=r?.[_x];typeof o=="string"?np(n,o):Sr(n,r)}Jg()}}var ua={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 Qo(e,t){let n={none:1000000n,ms:1000000n,s:1000000000n,m:60000000000n,h:3600000000000n,d:86400000000000n,w:604800000000000n};return BigInt(e)*n[t]}var Go=[{label:"None",barNs:Qo(1,"none"),defaultBars:ua.none,isPreset:!0},{label:"1s",barNs:Qo(1,"s"),defaultBars:ua["1s"],isPreset:!0},{label:"5s",barNs:Qo(5,"s"),defaultBars:ua["5s"],isPreset:!0},{label:"15s",barNs:Qo(15,"s"),defaultBars:ua["15s"],isPreset:!0},{label:"30s",barNs:Qo(30,"s"),defaultBars:ua["30s"],isPreset:!0},{label:"1m",barNs:Qo(1,"m"),defaultBars:ua["1m"],isPreset:!0},{label:"3m",barNs:Qo(3,"m"),defaultBars:ua["3m"],isPreset:!0},{label:"5m",barNs:Qo(5,"m"),defaultBars:ua["5m"],isPreset:!0},{label:"15m",barNs:Qo(15,"m"),defaultBars:ua["15m"],isPreset:!0},{label:"30m",barNs:Qo(30,"m"),defaultBars:ua["30m"],isPreset:!0},{label:"1h",barNs:Qo(1,"h"),defaultBars:ua["1h"],isPreset:!0},{label:"4h",barNs:Qo(4,"h"),defaultBars:ua["4h"],isPreset:!0},{label:"1d",barNs:Qo(1,"d"),defaultBars:ua["1d"],isPreset:!0}];function yA(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 Fx(e){let t=Go.find(n=>n.label.toLowerCase()===e.toLowerCase());return t||(Ic(e)??Go.find(n=>n.label==="1m")??Go[0])}function tb(e){let t=Go.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:yA(e),barNs:e,defaultBars:r,isPreset:!1}}function zx(e,t){return e.barNs*BigInt(t??e.defaultBars)}function Ic(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=Qo(r,o),s=Math.max(10,Math.min(500,Number(7200000000000n/a)));return{label:`${r}${o}`,barNs:a,defaultBars:s,isPreset:!1}}function Hx(){try{let e=Gr(Pn.customTimeframes,null);return Array.isArray(e)?e.map(t=>({label:t.label,barNs:BigInt(t.barNs),defaultBars:t.defaultBars,isPreset:!1})):[]}catch{return[]}}function nb(e){Sr(Pn.customTimeframes,e.map(t=>({label:t.label,barNs:t.barNs.toString(),defaultBars:t.defaultBars})))}var vA=["1m","5m","15m","1h","4h","1d"];function Vx(){let e=Gr(Pn.favoriteTimeframes,null);return Array.isArray(e)?e.filter(t=>typeof t=="string"):[...vA]}function Wx(e){Sr(Pn.favoriteTimeframes,e)}var wA=1000000n,Io=60000000000n,rb=86400000000000n,Gx=["Mon","Tue","Wed","Thu","Fri"],qx=new Map,Ux=new Map;function xA(e){let t=qx.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}),qx.set(e,t)),t}function SA(e){let t=Ux.get(e);return t||(t=new Intl.DateTimeFormat("en-US",{timeZone:e,weekday:"short"}),Ux.set(e,t)),t}function jx(e){let t=parseInt(e.slice(0,2),10),n=parseInt(e.slice(2,4),10);return t*60+n}function Yx(e){let[t,n]=e.split("-"),r=jx(t),o=jx(n);return{openMin:r,closeMin:o,overnight:o<=r}}function ks(e,t){let n=Number(e/wA),r=xA(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=SA(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 ip(e,t,n,r){let o=e.hours;if(o==="24/7"||o==="always")return!0;if(Kx(r,e.holidays))return!1;let a=$x(r,e.corrections),{openMin:i,closeMin:s,overnight:l}=Yx(a?a.hours:o),c=e.days??Gx,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 Kx(e,t){return!t||t.length===0?!1:t.includes(e)}function $x(e,t){return t?.find(n=>n.date===e)??null}function Ja(e,t){if(!e||e.hours==="24/7"||e.hours==="always")return{kind:"always"};let n=ks(t,e.timezone);if(ip(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(ip(o,n.minuteOfDay,n.dayOfWeek,n.isoDate))return{kind:"sub",label:r.label}}return{kind:"closed"}}function Ia(e,t){let n=e.hours;if(n==="24/7"||n==="always")return!0;let r=e.timezone,o=ks(t,r);if(Kx(o.isoDate,e.holidays))return!1;let a=$x(o.isoDate,e.corrections),{openMin:i,closeMin:s,overnight:l}=Yx(a?a.hours:n),c=e.days??Gx,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 sp(e,t,n){if(e.hours==="24/7"||e.hours==="always")return[{from:t,to:n}];let r=[],o=Io,a=t/o*o,i=n,s=null,l=a;for(;l<=i;){let c=Ia(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 Mc(e,t){if(e.hours==="24/7"||e.hours==="always"||Ia(e,t))return t;let n=t/Io*Io+Io,r=t+rb*8n;for(;n<r;){if(Ia(e,n))return n;n+=Io}return n}function Xx(e,t){if(e.hours==="24/7"||e.hours==="always"||!Ia(e,t))return t;let n=t/Io*Io,r=t-rb*8n;for(;n>r;){if(!Ia(e,n))return n;n-=Io}return n}function lp(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/Io*Io,a=t-rb*14n;for(;r>0n&&o>a;)if(Ia(e,o)){let i=o,s=o;for(;s>a&&Ia(e,s-Io);)s-=Io;let l=i-s+Io;if(l>=r)return o-r+Io;r-=l,o=s-Io}else{let i=Io*30n;for(o-=i;o>a&&!Ia(e,o);)o-=Io}return o>a?o:a}var CA=32,kA=200;function TA(e,t){return e<t?e:t}function ob(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 Lc(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 IA(e){return e.map(t=>({time:Number(t.ts/1000000n),price:t.price,size:t.size,side:t.side}))}function MA(e){switch(e.kind){case"l3":return{dataLevel:"l3",compactBuf:e.compactBuf,trades:e.trades,priceHistory:e.priceHistory,footprintBars:e.footprintBars,ohlcvBars:Lc(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:Lc(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 Rc=class{constructor(t,n,r){se(this,"eventBus",t);se(this,"state",n);se(this,"adapter",null);se(this,"realtimeUnsub",null);se(this,"executionEngine",null);se(this,"config");se(this,"destroyed",!1);se(this,"_states",new Map);se(this,"resolvedSymbols",new Map);se(this,"paneResolutions",new Map);se(this,"fpOptions");se(this,"initialLoad");se(this,"horizonIso");se(this,"scrollWindowNs");se(this,"activeSymbol");se(this,"_loadChain",Promise.resolve());se(this,"symbolUniverse",null);se(this,"symbolUniverseInFlight",null);se(this,"symbolSearchAbort",null);se(this,"latestSymbolSearchId",null);se(this,"symbolSearchCache",new Map);se(this,"unsubs",[]);se(this,"sharedData",{dataLevel:"l3",compactBuf:new ArrayBuffer(0),trades:[],priceHistory:[],footprintBars:[],ohlcvBars:[],barNs:60000000000n,dataStart:0,dataEnd:0,supplemental:null});se(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=Ta(this.initialLoad.start)-a,s=Ta(this.initialLoad.end);await this._loadWindow(r,i,s,Ta(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=ob(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:Cs(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:Cs(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={...MA(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=(Ta(this.initialLoad.end)-Ta(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??Ta(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:Cs(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"?IA(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&&!Ia(o.session,s)&&(s=Mc(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:Cs(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||Sc(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?lp(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:Cs(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:Cs(p,g),timeframe:i,direction:"backward"}).then(y=>{if(this.destroyed)return;let v=this._process(y,o);if(!v||Sc(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"?kA: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=wx(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=od(await this.adapter.searchSymbols({...n,signal:a.signal})):s=xc(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 rd?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=od(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>CA){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:tb(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?jm(t.ohlcvBars??[],t.supplementalBars,r):ad(t.ohlcvBars??[],r);case"tick":return Gm(t.ticks??[],r);case"l2":return Ym(t.l2Snapshots??[],r);default:return t.events?.length?Um(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||Sc(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=Lc(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=Lc(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=Lc(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=Lc(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=Ix(t.trades),r=Mx(t.priceHistory),o=await Px({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 rd||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,TA(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:Cs(n.from,n.to),timeframe:tb(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:ob(n.from),to:ob(n.to)})}}).catch(i=>{console.error("[DataEngine] segment refinement failed",i)}).finally(()=>{t.refiningSegments.delete(a)}))}_openWindows(t,n,r){return t.session?sp(t.session,n,r):[{from:n,to:r}]}};var Zx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var vn=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Zx[n[e]&63];return t};var Yo={name:"cursor",id:"",state:{}},ab=[{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}],xl=[{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 Ui(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:xl,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:ab,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 ud(e,t){return{name:e,id:vn(),state:{...Ui(e),...t}}}function Qx(e){return{name:e.tool,id:e.id,state:e}}var Jx=7;function Pc(){let e=Gr(Pn.drawingTemplates,null);return Array.isArray(e)?e:[]}function eS(e){let t=Pc().filter(n=>n.id!==e.id);t.push(e),Sr(Pn.drawingTemplates,t)}function tS(e){Sr(Pn.drawingTemplates,Pc().filter(t=>t.id!==e))}var Ke=Ct(require("react"));var we=require("react");var cp=10000000n,up=86400000000000n;var an={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 oS(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),H=d.priceToY(I.close,o),K=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,K),e.lineTo(x,G),e.stroke());let V=Math.min(L,H),q=Math.max(2,Math.abs(H-L));if(e.fillStyle=B,e.fillRect(x-P,V,R,q),A<4)continue;let j=new Map;for(let Ce of I.levels){let Ee=Math.floor(Math.round(Ce.price/s)/w),ze=j.get(Ee);ze||(ze={bid:0,ask:0,total:0,delta:0,poc:!1,absorption:!1,bidImbalance:!1,askImbalance:!1,diagAskImbalance:!1,diagBidImbalance:!1},j.set(Ee,ze)),ze.bid+=Ce.bidVol,ze.ask+=Ce.askVol,ze.total+=Ce.totalVol,ze.delta+=Ce.delta,Ce.price===I.poc&&(ze.poc=!0),Ce.absorption&&(ze.absorption=!0),Ce.bidImbalance&&(ze.bidImbalance=!0),Ce.askImbalance&&(ze.askImbalance=!0),Ce.diagAskImbalance&&(ze.diagAskImbalance=!0),Ce.diagBidImbalance&&(ze.diagBidImbalance=!0)}let W=1;for(let Ce of j.values())W=Math.max(W,Ce.total);let $=Math.floor(Math.round(I.low/s)/w),J=Math.floor(Math.round(I.high/s)/w);for(let Ce=$;Ce<=J;Ce++)j.has(Ce)||j.set(Ce,{bid:0,ask:0,total:0,delta:0,poc:!1,absorption:!1,bidImbalance:!1,askImbalance:!1,diagAskImbalance:!1,diagBidImbalance:!1});let me=y&&M>=9,We=Math.max(9,Math.min(13,Math.floor(M*.45)));e.font=`${We}px "JetBrains Mono", monospace`;for(let[Ce,Ee]of j){let Ie=Ce*k+k/2,ee=d.priceToY(Ie,o),Be=Math.max(1,M-1),F=ee-Be/2;switch(v&&c.footprintShowAbsorption&&Ee.absorption&&(e.fillStyle=an.absorption,e.fillRect(N-2,F-1,A+4,Be+2),e.strokeStyle=an.absorptionBorder,e.lineWidth=1,e.setLineDash([3,2]),e.strokeRect(N-1.5,F-.5,A+3,Be+1),e.setLineDash([])),i){case"bid-ask":LA(e,Ee,W,N,F,Be,A,me,ee,We,l,b);break;case"profile":RA(e,Ee,W,N,F,Be,A,me,ee,We);break;case"delta":PA(e,Ee,W,N,F,Be,A,me,ee,We);break;case"total":DA(e,Ee,W,N,F,Be,A,me,ee,We);break}Ee.poc&&Be>=2&&(e.strokeStyle=an.poc,e.lineWidth=1.5,e.strokeRect(N+.5,F+.5,A-2,Be-1))}if(v&&c.footprintShowStackedImbalance&&(nS(e,I.stackedBuyZones,"buy",N,A,n,o,s,c,d),nS(e,I.stackedSellZones,"sell",N,A,n,o,s,c,d)),v&&c.footprintShowUnfinishedAuction&&(I.unfinishedTop&&rS(e,"top",x,K,h),I.unfinishedBottom&&rS(e,"bottom",x,G,h)),y&&h>=50){let Ce=I.totalDelta>=0?"+":"";e.textAlign="center",e.font=`bold ${We}px "JetBrains Mono", monospace`,e.fillStyle=I.totalDelta>=0?"rgba(0,230,118,0.85)":"rgba(255,23,68,0.85)",e.fillText(`${Ce}${I.totalDelta}`,x,G+14),e.font=`${We}px "JetBrains Mono", monospace`}if(v&&c.footprintShowDiagonalImbalance&&h>=60&&I.diagDominant!=="none"){let Ce=I.diagDominant==="buy"?"\u2197 DIAG":"\u2198 DIAG";e.font='bold 9px "JetBrains Mono", monospace',e.textAlign="center",e.fillStyle=I.diagDominant==="buy"?an.diagAskText:an.diagBidText,e.fillText(Ce,x,K-6),e.font=`${We}px "JetBrains Mono", monospace`}}e.restore()}function LA(e,t,n,r,o,a,i,s,l,c,u,d){let m=i/2,f=1,h=an.textNormal,p=an.textNormal;if(t.ask>0&&t.bid>0){let g=t.ask/t.bid;g>=4?h=an.askImbalText4x:g>=2&&(h=an.askImbalText2x);let y=t.bid/t.ask;y>=4?p=an.bidImbalText4x:y>=2&&(p=an.bidImbalText2x)}else t.ask>0&&t.bid===0?h=an.askImbalText4x:t.bid>0&&t.ask===0&&(p=an.bidImbalText4x);if(d&&(t.diagAskImbalance&&(h=an.diagAskText),t.diagBidImbalance&&(p=an.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=an.askFill(.2+.35*v),b=an.cellBg):g<0?(b=an.bidFill(.2+.35*v),S=an.cellBg):b=S=an.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=an.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=an.bidFill(.45),e.fillRect(r,o,g*(m-f),a)),y>0&&(e.fillStyle=an.askFill(.45),e.fillRect(r+m,o,y*(m-1),a))}else{let g=Math.min(1,t.total/n);e.fillStyle=an.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=an.bidFill(.45),e.fillRect(r,o,b,a)),S>0&&(e.fillStyle=an.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=an.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=an.diagBid,e.lineWidth=1.5,e.beginPath(),e.moveTo(g,v),e.lineTo(y,b),e.stroke()}}s&&(e.textAlign="right",e.font=p===an.bidImbalText4x||p===an.diagBidText?`bold ${c}px "JetBrains Mono", monospace`:`${c}px "JetBrains Mono", monospace`,e.fillStyle=t.bid===0?an.textDim:p,e.fillText(String(t.bid),r+m-f-2,l),e.textAlign="left",e.font=h===an.askImbalText4x||h===an.diagAskText?`bold ${c}px "JetBrains Mono", monospace`:`${c}px "JetBrains Mono", monospace`,e.fillStyle=t.ask===0?an.textDim:h,e.fillText(String(t.ask),r+m+2,l),e.font=`${c}px "JetBrains Mono", monospace`)}function RA(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?an.askFill(.65):an.bidFill(.65),e.fillRect(r,o,d,a),s&&(e.fillStyle=an.textNormal,e.textAlign="left",e.fillText(`${t.bid}\xD7${t.ask}`,r+2,l))}function PA(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=an.textNormal,e.textAlign="left",e.fillText(`${h}${t.delta}`,r+2,l)}}function DA(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=an.textNormal,e.textAlign="left",e.fillText(String(t.total),r+2,l))}function nS(e,t,n,r,o,a,i,s,l,c){if(t.length===0)return;let u=n==="buy"?an.stackBuy:an.stackSell,d=n==="buy"?an.stackBuyBorder:an.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 rS(e,t,n,r,o){let a=Math.min(8,o*.15),i=10;e.save(),e.strokeStyle=t==="top"?an.unfTop:an.unfBottom,e.fillStyle=t==="top"?an.unfTop:an.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 Fr(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 AA=.25;function po(e){return e?.priceFormat?.minTick??e?.tickSize??AA}function BA(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 Sl(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 NA="#00e676",EA="#ff1744",aS=22,iS=10,OA=4;function sS(e,t,n,r,o,a,i,s,l,c,u,d){let m=a==="tp"?NA:EA,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,lS(m,a==="tp"?0:.08)),b.addColorStop(1,lS(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=Fr(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+iS*2,D=t-P-4,N=h-aS/2;e.shadowColor="rgba(0,0,0,0.55)",e.shadowBlur=8,e.shadowOffsetY=2,Sl(e,D,N,P,aS,OA),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+iS,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 cS(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;sS(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;sS(e,r,v,k.price,I,"sl",l,n,a,m,f,p)}}}let w=k=>{let M=!!k.preview,I=ke=>M?BA(ke,.45):ke,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,H=7,K=7,G=7,V=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":""}`,q=N?k.pnl:D?0:Number(String(k.label).replace("TP ","").replace("SL ","").replace("+$","").replace("-$","-")),j=String(k.qty),W=e.measureText(j).width,$=e.measureText(V).width,J=H+W+H,me=H+$+H,We=H+K+H,Ce=J+me+We,Ee=r-Ce-P,ze=L-E/2,Ie=L+E/2,ee=Ee+Ce,Be=Ee+J,F=Be+me,le=F+H,ce=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=ce,e.moveTo(0,B),e.lineTo(r,B),e.stroke(),e.setLineDash([]),e.lineCap="butt",g.y>=ze+5&&g.y<=Ie-5&&(S=!0),e.beginPath(),Sl(e,Ee,ze,Ce,E,4,4,4),e.fillStyle="#191919",e.fill(),e.strokeStyle=ce,e.stroke(),O?(e.beginPath(),Sl(e,Ee,ze,J,E,4,4,0),e.fillStyle=ce,e.fill()):(k.kind==="tp"||k.kind==="sl")&&(e.beginPath(),e.strokeStyle=ce,e.moveTo(Ee+J,L-E/2),e.lineTo(Ee+J,L+E/2),e.stroke()),e.fillStyle=O?"#ffffff":k.kind==="tp"?x:T,e.fillText(j,Ee+H,L+1.5),e.fillStyle=q>0?x:q===0?"#b2b2b2":T,e.fillText(V,Be+H,L+1),k.locked||(e.beginPath(),e.strokeStyle=ce,e.moveTo(F,Ie),e.lineTo(F,ze),e.stroke(),g&&g.x>=F&&g.x<=ee&&g.y>=ze&&g.y<=Ie&&(S=!0,Sl(e,F+1,ze+1,ee-F-1,E-1,0,0,4),e.fillStyle="#ffffff15",e.fill()),e.beginPath(),e.strokeStyle=ce,e.moveTo(le,L+G/2),e.lineTo(le+K,L-G/2),e.moveTo(le,L-G/2),e.lineTo(le+K,L+G/2),e.stroke(),b.lines.push({id:k.id,y:L,top:ze+5,bottom:Ie-5,pill:{x:Ee,y:L-E/2,w:Ce,h:E},closeBtn:{x:F,y:L-E/2,w:Ee+Ce-F,h:E}})),e.beginPath(),Sl(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(Fr(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 De=Ee-81,ve=Ee-30*1.5;e.beginPath(),e.setLineDash([2,2]),Sl(e,De,ze,30,E,4,4,4),e.fillStyle="#191919",e.fill(),e.strokeStyle=x,e.stroke(),e.fillStyle=x;let Qe=e.measureText("TP").width;e.fillText("TP",De+30/2-Qe/2,L+1),e.beginPath(),e.setLineDash([2,2]),Sl(e,ve,ze,30,E,4,4,4),e.fillStyle="#191919",e.fill(),e.strokeStyle=T,e.stroke(),e.fillStyle=T;let Ye=e.measureText("SL").width;e.fillText("SL",ve+30/2-Ye/2,L+1),b.ghostPills.push({lineId:k.id,ghostId:"tp_1",index:1,kind:"tp",x:De,y:ze,w:30,h:E,currentPrice:k.price}),b.ghostPills.push({lineId:k.id,ghostId:"sl_1",index:1,kind:"sl",x:ve,y:ze,w:30,h:E,currentPrice:k.price})}e.restore()};for(let k of C)w(k);return{hitMap:b,suspendCrosshair:S}}function Dc(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 lS(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 Gi=class extends Error{},hb=class extends Gi{constructor(t){super(`Invalid DateTime: ${t.toMessage()}`)}},gb=class extends Gi{constructor(t){super(`Invalid Interval: ${t.toMessage()}`)}},bb=class extends Gi{constructor(t){super(`Invalid Duration: ${t.toMessage()}`)}},Ms=class extends Gi{},yp=class extends Gi{constructor(t){super(`Invalid unit ${t}`)}},ho=class extends Gi{},Ii=class extends Gi{constructor(){super("Zone is an abstract class")}},st="numeric",ni="short",ma="long",vp={year:st,month:st,day:st},HS={year:st,month:ni,day:st},_A={year:st,month:ni,day:st,weekday:ni},VS={year:st,month:ma,day:st},WS={year:st,month:ma,day:st,weekday:ma},qS={hour:st,minute:st},US={hour:st,minute:st,second:st},jS={hour:st,minute:st,second:st,timeZoneName:ni},GS={hour:st,minute:st,second:st,timeZoneName:ma},YS={hour:st,minute:st,hourCycle:"h23"},KS={hour:st,minute:st,second:st,hourCycle:"h23"},$S={hour:st,minute:st,second:st,hourCycle:"h23",timeZoneName:ni},XS={hour:st,minute:st,second:st,hourCycle:"h23",timeZoneName:ma},ZS={year:st,month:st,day:st,hour:st,minute:st},QS={year:st,month:st,day:st,hour:st,minute:st,second:st},JS={year:st,month:ni,day:st,hour:st,minute:st},e1={year:st,month:ni,day:st,hour:st,minute:st,second:st},FA={year:st,month:ni,day:st,weekday:ni,hour:st,minute:st},t1={year:st,month:ma,day:st,hour:st,minute:st,timeZoneName:ni},n1={year:st,month:ma,day:st,hour:st,minute:st,second:st,timeZoneName:ni},r1={year:st,month:ma,day:st,weekday:ma,hour:st,minute:st,timeZoneName:ma},o1={year:st,month:ma,day:st,weekday:ma,hour:st,minute:st,second:st,timeZoneName:ma},Il=class{get type(){throw new Ii}get name(){throw new Ii}get ianaName(){return this.name}get isUniversal(){throw new Ii}offsetName(t,n){throw new Ii}formatOffset(t,n){throw new Ii}offset(t){throw new Ii}equals(t){throw new Ii}get isValid(){throw new Ii}},ib=null,wp=class e extends Il{static get instance(){return ib===null&&(ib=new e),ib}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return h1(t,n,r)}formatOffset(t,n){return hd(this.offset(t),n)}offset(t){return-new Date(t).getTimezoneOffset()}equals(t){return t.type==="system"}get isValid(){return!0}},yb=new Map;function zA(e){let t=yb.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"}),yb.set(e,t)),t}var HA={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function VA(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 WA(e,t){let n=e.formatToParts(t),r=[];for(let o=0;o<n.length;o++){let{type:a,value:i}=n[o],s=HA[a];a==="era"?r[s]=i:sn(s)||(r[s]=parseInt(i,10))}return r}var sb=new Map,Rs=class e extends Il{static create(t){let n=sb.get(t);return n===void 0&&sb.set(t,n=new e(t)),n}static resetCache(){sb.clear(),yb.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 h1(t,n,r,this.name)}formatOffset(t,n){return hd(this.offset(t),n)}offset(t){if(!this.valid)return NaN;let n=new Date(t);if(isNaN(n))return NaN;let r=zA(this.name),[o,a,i,s,l,c,u]=r.formatToParts?WA(r,n):VA(r,n);s==="BC"&&(o=-Math.abs(o)+1);let m=Ip({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}},uS={};function qA(e,t={}){let n=JSON.stringify([e,t]),r=uS[n];return r||(r=new Intl.ListFormat(e,t),uS[n]=r),r}var vb=new Map;function wb(e,t={}){let n=JSON.stringify([e,t]),r=vb.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),vb.set(n,r)),r}var xb=new Map;function UA(e,t={}){let n=JSON.stringify([e,t]),r=xb.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),xb.set(n,r)),r}var Sb=new Map;function jA(e,t={}){let{base:n,...r}=t,o=JSON.stringify([e,r]),a=Sb.get(o);return a===void 0&&(a=new Intl.RelativeTimeFormat(e,t),Sb.set(o,a)),a}var fd=null;function GA(){return fd||(fd=new Intl.DateTimeFormat().resolvedOptions().locale,fd)}var Cb=new Map;function a1(e){let t=Cb.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),Cb.set(e,t)),t}var kb=new Map;function YA(e){let t=kb.get(e);if(!t){let n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in t||(t={...i1,...t}),kb.set(e,t)}return t}function KA(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=wb(e).resolvedOptions(),o=e}catch{let l=e.substring(0,n);r=wb(l).resolvedOptions(),o=l}let{numberingSystem:a,calendar:i}=r;return[o,a,i]}}function $A(e,t,n){return(n||t)&&(e.includes("-u-")||(e+="-u"),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`)),e}function XA(e){let t=[];for(let n=1;n<=12;n++){let r=rr.utc(2009,n,1);t.push(e(r))}return t}function ZA(e){let t=[];for(let n=1;n<=7;n++){let r=rr.utc(2016,11,13+n);t.push(e(r))}return t}function dp(e,t,n,r){let o=e.listingMode();return o==="error"?null:o==="en"?n(t):r(t)}function QA(e){return e.numberingSystem&&e.numberingSystem!=="latn"?!1:e.numberingSystem==="latn"||!e.locale||e.locale.startsWith("en")||a1(e.locale).numberingSystem==="latn"}var Tb=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=UA(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):_b(t,3);return to(n,this.padTo)}}},Ib=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&&Rs.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=wb(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()}},Mb=class{constructor(t,n,r){this.opts={style:"long",...r},!n&&m1()&&(this.rtf=jA(t,r))}format(t,n){return this.rtf?this.rtf.format(t,n):vB(n,t,this.opts.numeric,this.opts.style!=="long")}formatToParts(t,n){return this.rtf?this.rtf.formatToParts(t,n):[]}},i1={firstDay:1,minimalDays:4,weekend:[6,7]},gr=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||Pr.defaultLocale,s=i||(a?"en-US":GA()),l=n||Pr.defaultNumberingSystem,c=r||Pr.defaultOutputCalendar,u=Pb(o)||Pr.defaultWeekSettings;return new e(s,l,c,u,i)}static resetCache(){fd=null,vb.clear(),xb.clear(),Sb.clear(),Cb.clear(),kb.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]=KA(t);this.locale=i,this.numberingSystem=n||s||null,this.outputCalendar=r||l||null,this.weekSettings=o,this.intl=$A(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=QA(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,Pb(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 dp(this,t,y1,()=>{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]=XA(i)}return this.monthsCache[a][t]})}weekdays(t,n=!1){return dp(this,t,x1,()=>{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]=ZA(a=>this.extract(a,r,"weekday"))),this.weekdaysCache[o][t]})}meridiems(){return dp(this,void 0,()=>S1,()=>{if(!this.meridiemCache){let t={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[rr.utc(2016,11,13,9),rr.utc(2016,11,13,19)].map(n=>this.extract(n,t,"dayperiod"))}return this.meridiemCache})}eras(t){return dp(this,t,C1,()=>{let n={era:t};return this.eraCache[t]||(this.eraCache[t]=[rr.utc(-40,1,1),rr.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 Tb(this.intl,t.forceSimple||this.fastNumbers,t)}dtFormatter(t,n={}){return new Ib(t,this.intl,n)}relFormatter(t={}){return new Mb(this.intl,this.isEnglish(),t)}listFormatter(t={}){return qA(this.intl,t)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||a1(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:p1()?YA(this.locale):i1}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})`}},lb=null,Pa=class e extends Il{static get utcInstance(){return lb===null&&(lb=new e(0)),lb}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(Mp(n[1],n[2]))}return null}constructor(t){super(),this.fixed=t}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${hd(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${hd(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(t,n){return hd(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}},Lb=class extends Il{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 Is(e,t){if(sn(e)||e===null)return t;if(e instanceof Il)return e;if(oB(e)){let n=e.toLowerCase();return n==="default"?t:n==="local"||n==="system"?wp.instance:n==="utc"||n==="gmt"?Pa.utcInstance:Pa.parseSpecifier(n)||Rs.create(e)}else return Ls(e)?Pa.instance(e):typeof e=="object"&&"offset"in e&&typeof e.offset=="function"?e:new Lb(e)}var Bb={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"},dS={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]},JA=Bb.hanidec.replace(/[\[|\]]/g,"").split("");function eB(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(Bb.hanidec)!==-1)t+=JA.indexOf(e[n]);else for(let o in dS){let[a,i]=dS[o];r>=a&&r<=i&&(t+=r-a)}}return parseInt(t,10)}else return t}var Rb=new Map;function tB(){Rb.clear()}function ei({numberingSystem:e},t=""){let n=e||"latn",r=Rb.get(n);r===void 0&&(r=new Map,Rb.set(n,r));let o=r.get(t);return o===void 0&&(o=new RegExp(`${Bb[n]}${t}`),r.set(t,o)),o}var fS=()=>Date.now(),mS="system",pS=null,hS=null,gS=null,bS=60,yS,vS=null,Pr=class{static get now(){return fS}static set now(t){fS=t}static set defaultZone(t){mS=t}static get defaultZone(){return Is(mS,wp.instance)}static get defaultLocale(){return pS}static set defaultLocale(t){pS=t}static get defaultNumberingSystem(){return hS}static set defaultNumberingSystem(t){hS=t}static get defaultOutputCalendar(){return gS}static set defaultOutputCalendar(t){gS=t}static get defaultWeekSettings(){return vS}static set defaultWeekSettings(t){vS=Pb(t)}static get twoDigitCutoffYear(){return bS}static set twoDigitCutoffYear(t){bS=t%100}static get throwOnInvalid(){return yS}static set throwOnInvalid(t){yS=t}static resetCaches(){gr.resetCache(),Rs.resetCache(),rr.resetCache(),tB()}},fa=class{constructor(t,n){this.reason=t,this.explanation=n}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},s1=[0,31,59,90,120,151,181,212,243,273,304,334],l1=[0,31,60,91,121,152,182,213,244,274,305,335];function La(e,t){return new fa("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function Nb(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 c1(e,t,n){return n+(bd(e)?l1:s1)[t-1]}function u1(e,t){let n=bd(e)?l1:s1,r=n.findIndex(a=>a<t),o=t-n[r];return{month:r+1,day:o}}function Eb(e,t){return(e-t+7)%7+1}function xp(e,t=4,n=1){let{year:r,month:o,day:a}=e,i=c1(r,o,a),s=Eb(Nb(r,o,a),n),l=Math.floor((i-s+14-t)/7),c;return l<1?(c=r-1,l=gd(c,t,n)):l>gd(r,t,n)?(c=r+1,l=1):c=r,{weekYear:c,weekNumber:l,weekday:s,...Lp(e)}}function wS(e,t=4,n=1){let{weekYear:r,weekNumber:o,weekday:a}=e,i=Eb(Nb(r,1,t),n),s=Oc(r),l=o*7+a-i-7+t,c;l<1?(c=r-1,l+=Oc(c)):l>s?(c=r+1,l-=Oc(r)):c=r;let{month:u,day:d}=u1(c,l);return{year:c,month:u,day:d,...Lp(e)}}function cb(e){let{year:t,month:n,day:r}=e,o=c1(t,n,r);return{year:t,ordinal:o,...Lp(e)}}function xS(e){let{year:t,ordinal:n}=e,{month:r,day:o}=u1(t,n);return{year:t,month:r,day:o,...Lp(e)}}function SS(e,t){if(!sn(e.localWeekday)||!sn(e.localWeekNumber)||!sn(e.localWeekYear)){if(!sn(e.weekday)||!sn(e.weekNumber)||!sn(e.weekYear))throw new Ms("Cannot mix locale-based week fields with ISO-based week fields");return sn(e.localWeekday)||(e.weekday=e.localWeekday),sn(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),sn(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 nB(e,t=4,n=1){let r=Tp(e.weekYear),o=Ra(e.weekNumber,1,gd(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 rB(e){let t=Tp(e.year),n=Ra(e.ordinal,1,Oc(e.year));return t?n?!1:La("ordinal",e.ordinal):La("year",e.year)}function d1(e){let t=Tp(e.year),n=Ra(e.month,1,12),r=Ra(e.day,1,Sp(e.year,e.month));return t?n?r?!1:La("day",e.day):La("month",e.month):La("year",e.year)}function f1(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 sn(e){return typeof e>"u"}function Ls(e){return typeof e=="number"}function Tp(e){return typeof e=="number"&&e%1===0}function oB(e){return typeof e=="string"}function aB(e){return Object.prototype.toString.call(e)==="[object Date]"}function m1(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function p1(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function iB(e){return Array.isArray(e)?e:[e]}function CS(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 sB(e,t){return t.reduce((n,r)=>(n[r]=e[r],n),{})}function zc(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Pb(e){if(e==null)return null;if(typeof e!="object")throw new ho("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 ho("Invalid week settings");return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Ra(e,t,n){return Tp(e)&&e>=t&&e<=n}function lB(e,t){return e-t*Math.floor(e/t)}function to(e,t=2){let n=e<0,r;return n?r="-"+(""+-e).padStart(t,"0"):r=(""+e).padStart(t,"0"),r}function Ts(e){if(!(sn(e)||e===null||e===""))return parseInt(e,10)}function Cl(e){if(!(sn(e)||e===null||e===""))return parseFloat(e)}function Ob(e){if(!(sn(e)||e===null||e==="")){let t=parseFloat("0."+e)*1e3;return Math.floor(t)}}function _b(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 bd(e){return e%4===0&&(e%100!==0||e%400===0)}function Oc(e){return bd(e)?366:365}function Sp(e,t){let n=lB(t-1,12)+1,r=e+(t-n)/12;return n===2?bd(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function Ip(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 kS(e,t,n){return-Eb(Nb(e,1,t),n)+t-1}function gd(e,t=4,n=1){let r=kS(e,t,n),o=kS(e+1,t,n);return(Oc(e)-r+o)/7}function Db(e){return e>99?e:e>Pr.twoDigitCutoffYear?1900+e:2e3+e}function h1(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 Mp(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 g1(e){let t=Number(e);if(typeof e=="boolean"||e===""||!Number.isFinite(t))throw new ho(`Invalid unit value ${e}`);return t}function Cp(e,t){let n={};for(let r in e)if(zc(e,r)){let o=e[r];if(o==null)continue;n[t(r)]=g1(o)}return n}function hd(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}${to(n,2)}:${to(r,2)}`;case"narrow":return`${o}${n}${r>0?`:${r}`:""}`;case"techie":return`${o}${to(n,2)}${to(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function Lp(e){return sB(e,["hour","minute","second","millisecond"])}var cB=["January","February","March","April","May","June","July","August","September","October","November","December"],b1=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],uB=["J","F","M","A","M","J","J","A","S","O","N","D"];function y1(e){switch(e){case"narrow":return[...uB];case"short":return[...b1];case"long":return[...cB];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 v1=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],w1=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],dB=["M","T","W","T","F","S","S"];function x1(e){switch(e){case"narrow":return[...dB];case"short":return[...w1];case"long":return[...v1];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}var S1=["AM","PM"],fB=["Before Christ","Anno Domini"],mB=["BC","AD"],pB=["B","A"];function C1(e){switch(e){case"narrow":return[...pB];case"short":return[...mB];case"long":return[...fB];default:return null}}function hB(e){return S1[e.hour<12?0:1]}function gB(e,t){return x1(t)[e.weekday-1]}function bB(e,t){return y1(t)[e.month-1]}function yB(e,t){return C1(t)[e.year<0?0:1]}function vB(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 TS(e,t){let n="";for(let r of e)r.literal?n+=r.val:n+=t(r.val);return n}var wB={D:vp,DD:HS,DDD:VS,DDDD:WS,t:qS,tt:US,ttt:jS,tttt:GS,T:YS,TT:KS,TTT:$S,TTTT:XS,f:ZS,ff:JS,fff:t1,ffff:r1,F:QS,FF:e1,FFF:n1,FFFF:o1},da=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 wB[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 to(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?hB(t):a({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(f,h)=>r?bB(t,f):a(h?{month:f}:{month:f,day:"numeric"},"month"),c=(f,h)=>r?gB(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?yB(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 TS(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 TS(i,a(l,c))}},k1=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Hc(...e){let t=e.reduce((n,r)=>n+r.source,"");return RegExp(`^${t}$`)}function Vc(...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 Wc(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 T1(...e){return(t,n)=>{let r={},o;for(o=0;o<e.length;o++)r[e[o]]=Ts(t[n+o]);return[r,null,n+o]}}var I1=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,xB=`(?:${I1.source}?(?:\\[(${k1.source})\\])?)?`,Fb=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,M1=RegExp(`${Fb.source}${xB}`),zb=RegExp(`(?:[Tt]${M1.source})?`),SB=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,CB=/(\d{4})-?W(\d\d)(?:-?(\d))?/,kB=/(\d{4})-?(\d{3})/,TB=T1("weekYear","weekNumber","weekDay"),IB=T1("year","ordinal"),MB=/(\d{4})-(\d\d)-(\d\d)/,L1=RegExp(`${Fb.source} ?(?:${I1.source}|(${k1.source}))?`),LB=RegExp(`(?: ${L1.source})?`);function _c(e,t,n){let r=e[t];return sn(r)?n:Ts(r)}function RB(e,t){return[{year:_c(e,t),month:_c(e,t+1,1),day:_c(e,t+2,1)},null,t+3]}function qc(e,t){return[{hours:_c(e,t,0),minutes:_c(e,t+1,0),seconds:_c(e,t+2,0),milliseconds:Ob(e[t+3])},null,t+4]}function yd(e,t){let n=!e[t]&&!e[t+1],r=Mp(e[t+1],e[t+2]),o=n?null:Pa.instance(r);return[{},o,t+3]}function vd(e,t){let n=e[t]?Rs.create(e[t]):null;return[{},n,t+1]}var PB=RegExp(`^T?${Fb.source}$`),DB=/^-?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 AB(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(Cl(n)),months:m(Cl(r)),weeks:m(Cl(o)),days:m(Cl(a)),hours:m(Cl(i)),minutes:m(Cl(s)),seconds:m(Cl(l),l==="-0"),milliseconds:m(Ob(c),d)}]}var BB={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Hb(e,t,n,r,o,a,i){let s={year:t.length===2?Db(Ts(t)):Ts(t),month:b1.indexOf(n)+1,day:Ts(r),hour:Ts(o),minute:Ts(a)};return i&&(s.second=Ts(i)),e&&(s.weekday=e.length>3?v1.indexOf(e)+1:w1.indexOf(e)+1),s}var NB=/^(?:(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 EB(e){let[,t,n,r,o,a,i,s,l,c,u,d]=e,m=Hb(t,o,r,n,a,i,s),f;return l?f=BB[l]:c?f=0:f=Mp(u,d),[m,new Pa(f)]}function OB(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}var _B=/^(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$/,FB=/^(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$/,zB=/^(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 IS(e){let[,t,n,r,o,a,i,s]=e;return[Hb(t,o,r,n,a,i,s),Pa.utcInstance]}function HB(e){let[,t,n,r,o,a,i,s]=e;return[Hb(t,s,n,r,o,a,i),Pa.utcInstance]}var VB=Hc(SB,zb),WB=Hc(CB,zb),qB=Hc(kB,zb),UB=Hc(M1),R1=Vc(RB,qc,yd,vd),jB=Vc(TB,qc,yd,vd),GB=Vc(IB,qc,yd,vd),YB=Vc(qc,yd,vd);function KB(e){return Wc(e,[VB,R1],[WB,jB],[qB,GB],[UB,YB])}function $B(e){return Wc(OB(e),[NB,EB])}function XB(e){return Wc(e,[_B,IS],[FB,IS],[zB,HB])}function ZB(e){return Wc(e,[DB,AB])}var QB=Vc(qc);function JB(e){return Wc(e,[PB,QB])}var eN=Hc(MB,LB),tN=Hc(L1),nN=Vc(qc,yd,vd);function rN(e){return Wc(e,[eN,R1],[tN,nN])}var MS="Invalid Duration",P1={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}},oN={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},...P1},Ma=146097/400,Ac=146097/4800,aN={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:Ac/7,days:Ac,hours:Ac*24,minutes:Ac*24*60,seconds:Ac*24*60*60,milliseconds:Ac*24*60*60*1e3},...P1},Tl=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],iN=Tl.slice(0).reverse();function ji(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 go(r)}function D1(e,t){let n=t.milliseconds??0;for(let r of iN.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function LS(e,t){let n=D1(e,t)<0?-1:1;Tl.reduceRight((r,o)=>{if(sn(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),Tl.reduce((r,o)=>{if(sn(t[o]))return r;if(r){let a=t[r]%1;t[r]-=a,t[o]+=a*e[r][o]}return o},null)}function RS(e){let t={};for(let[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}var go=class e{constructor(t){let n=t.conversionAccuracy==="longterm"||!1,r=n?aN:oN;t.matrix&&(r=t.matrix),this.values=t.values,this.loc=t.loc||gr.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 ho(`Duration.fromObject: argument expected to be an object, got ${t===null?"null":typeof t}`);return new e({values:Cp(t,e.normalizeUnit),loc:gr.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(Ls(t))return e.fromMillis(t);if(e.isDuration(t))return t;if(typeof t=="object")return e.fromObject(t);throw new ho(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){let[r]=ZB(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]=JB(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 ho("need to specify a reason the Duration is invalid");let r=t instanceof fa?t:new fa(t,n);if(Pr.throwOnInvalid)throw new bb(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 yp(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?da.create(this.loc,r).formatDurationFromString(this,t):MS}toHuman(t={}){if(!this.isValid)return MS;let n=t.showZeros!==!1,r=Tl.map(o=>{let a=this.values[o];return sn(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+=_b(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},rr.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?D1(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 Tl)(zc(n.values,o)||zc(this.values,o))&&(r[o]=n.get(o)+this.get(o));return ji(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]=g1(t(this.values[r],r));return ji(this,{values:n},!0)}get(t){return this[e.normalizeUnit(t)]}set(t){if(!this.isValid)return this;let n={...this.values,...Cp(t,e.normalizeUnit)};return ji(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 ji(this,i)}as(t){return this.isValid?this.shiftTo(t).get(t):NaN}normalize(){if(!this.isValid)return this;let t=this.toObject();return LS(this.matrix,t),ji(this,{values:t},!0)}rescale(){if(!this.isValid)return this;let t=RS(this.normalize().shiftToAll().toObject());return ji(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 Tl)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;Ls(o[i])&&(s+=o[i]);let l=Math.trunc(s);n[i]=l,r[i]=(s*1e3-l*1e3)/1e3}else Ls(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 LS(this.matrix,n),ji(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 ji(this,{values:t},!0)}removeZeros(){if(!this.isValid)return this;let t=RS(this.values);return ji(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 Tl)if(!n(this.values[r],t.values[r]))return!1;return!0}},Bc="Invalid Interval";function sN(e,t){return!e||!e.isValid?Fc.invalid("missing or invalid start"):!t||!t.isValid?Fc.invalid("missing or invalid end"):t<e?Fc.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 Fc=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 ho("need to specify a reason the Interval is invalid");let r=t instanceof fa?t:new fa(t,n);if(Pr.throwOnInvalid)throw new gb(r);return new e({invalid:r})}static fromDateTimes(t,n){let r=dd(t),o=dd(n),a=sN(r,o);return a??new e({start:r,end:o})}static after(t,n){let r=go.fromDurationLike(n),o=dd(t);return e.fromDateTimes(o,o.plus(r))}static before(t,n){let r=go.fromDurationLike(n),o=dd(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=rr.fromISO(r,n),i=a.isValid}catch{i=!1}let s,l;try{s=rr.fromISO(o,n),l=s.isValid}catch{l=!1}if(i&&l)return e.fromDateTimes(a,s);if(i){let c=go.fromISO(o,n);if(c.isValid)return e.after(a,c)}else if(l){let c=go.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(dd).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=go.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()})`:Bc}[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=vp,n={}){return this.isValid?da.create(this.s.loc.clone(n),t).formatInterval(this):Bc}toISO(t){return this.isValid?`${this.s.toISO(t)}/${this.e.toISO(t)}`:Bc}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Bc}toISOTime(t){return this.isValid?`${this.s.toISOTime(t)}/${this.e.toISOTime(t)}`:Bc}toFormat(t,{separator:n=" \u2013 "}={}){return this.isValid?`${this.s.toFormat(t)}${n}${this.e.toFormat(t)}`:Bc}toDuration(t,n){return this.isValid?this.e.diff(this.s,t,n):go.invalid(this.invalidReason)}mapEndpoints(t){return e.fromDateTimes(t(this.s),t(this.e))}},Ec=class{static hasDST(t=Pr.defaultZone){let n=rr.now().setZone(t).set({month:12});return!t.isUniversal&&n.offset!==n.set({month:6}).offset}static isValidIANAZone(t){return Rs.isValidZone(t)}static normalizeZone(t){return Is(t,Pr.defaultZone)}static getStartOfWeek({locale:t=null,locObj:n=null}={}){return(n||gr.create(t)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:t=null,locObj:n=null}={}){return(n||gr.create(t)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:t=null,locObj:n=null}={}){return(n||gr.create(t)).getWeekendDays().slice()}static months(t="long",{locale:n=null,numberingSystem:r=null,locObj:o=null,outputCalendar:a="gregory"}={}){return(o||gr.create(n,r,a)).months(t)}static monthsFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:o=null,outputCalendar:a="gregory"}={}){return(o||gr.create(n,r,a)).months(t,!0)}static weekdays(t="long",{locale:n=null,numberingSystem:r=null,locObj:o=null}={}){return(o||gr.create(n,r,null)).weekdays(t)}static weekdaysFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:o=null}={}){return(o||gr.create(n,r,null)).weekdays(t,!0)}static meridiems({locale:t=null}={}){return gr.create(t).meridiems()}static eras(t="short",{locale:n=null}={}){return gr.create(n,null,"gregory").eras(t)}static features(){return{relative:m1(),localeWeek:p1()}}};function PS(e,t){let n=o=>o.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(t)-n(e);return Math.floor(go.fromMillis(r).as("days"))}function lN(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=PS(l,c);return(u-u%7)/7}],["days",PS]],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 cN(e,t,n,r){let[o,a,i,s]=lN(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=go.fromObject(a,r);return c.length>0?go.fromMillis(l,r).shiftTo(...c).plus(u):u}var uN="missing Intl.DateTimeFormat.formatToParts support";function nr(e,t=n=>n){return{regex:e,deser:([n])=>t(eB(n))}}var dN="\xA0",A1=`[ ${dN}]`,B1=new RegExp(A1,"g");function fN(e){return e.replace(/\./g,"\\.?").replace(B1,A1)}function DS(e){return e.replace(/\./g,"").replace(B1," ").toLowerCase()}function ti(e,t){return e===null?null:{regex:RegExp(e.map(fN).join("|")),deser:([n])=>e.findIndex(r=>DS(n)===DS(r))+t}}function AS(e,t){return{regex:e,deser:([,n,r])=>Mp(n,r),groups:t}}function fp(e){return{regex:e,deser:([t])=>t}}function mN(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function pN(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(mN(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 nr(c);case"yy":return nr(d,Db);case"yyyy":return nr(a);case"yyyyy":return nr(m);case"yyyyyy":return nr(i);case"M":return nr(s);case"MM":return nr(r);case"MMM":return ti(t.months("short",!0),1);case"MMMM":return ti(t.months("long",!0),1);case"L":return nr(s);case"LL":return nr(r);case"LLL":return ti(t.months("short",!1),1);case"LLLL":return ti(t.months("long",!1),1);case"d":return nr(s);case"dd":return nr(r);case"o":return nr(l);case"ooo":return nr(o);case"HH":return nr(r);case"H":return nr(s);case"hh":return nr(r);case"h":return nr(s);case"mm":return nr(r);case"m":return nr(s);case"q":return nr(s);case"qq":return nr(r);case"s":return nr(s);case"ss":return nr(r);case"S":return nr(l);case"SSS":return nr(o);case"u":return fp(u);case"uu":return fp(s);case"uuu":return nr(n);case"a":return ti(t.meridiems(),0);case"kkkk":return nr(a);case"kk":return nr(d,Db);case"W":return nr(s);case"WW":return nr(r);case"E":case"c":return nr(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 AS(new RegExp(`([+-]${s.source})(?::(${r.source}))?`),2);case"ZZZ":return AS(new RegExp(`([+-]${s.source})(${r.source})?`),2);case"z":return fp(/[a-z_+-/]{1,256}?/i);case" ":return fp(/[^\S\n\r]/);default:return f(g)}})(e)||{invalidReason:uN};return p.token=e,p}var hN={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 gN(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=hN[i];if(typeof s=="object"&&(s=s[a]),s)return{literal:!1,val:s}}function bN(e){return[`^${e.map(n=>n.regex).reduce((n,r)=>`${n}(${r.source})`,"")}$`,e]}function yN(e,t,n){let r=e.match(t);if(r){let o={},a=1;for(let i in n)if(zc(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 vN(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 sn(e.z)||(n=Rs.create(e.z)),sn(e.Z)||(n||(n=new Pa(e.Z)),r=e.Z),sn(e.q)||(e.M=(e.q-1)*3+1),sn(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),sn(e.u)||(e.S=Ob(e.u)),[Object.keys(e).reduce((a,i)=>{let s=t(i);return s&&(a[s]=e[i]),a},{}),n,r]}var ub=null;function wN(){return ub||(ub=rr.fromMillis(1555555555555)),ub}function xN(e,t){if(e.literal)return e;let n=da.macroTokenToFormatOpts(e.val),r=O1(n,t);return r==null||r.includes(void 0)?e:r}function N1(e,t){return Array.prototype.concat(...e.map(n=>xN(n,t)))}var kp=class{constructor(t,n){if(this.locale=t,this.format=n,this.tokens=N1(da.parseFormat(n),t),this.units=this.tokens.map(r=>pN(r,t)),this.disqualifyingUnit=this.units.find(r=>r.invalidReason),!this.disqualifyingUnit){let[r,o]=bN(this.units);this.regex=RegExp(r,"i"),this.handlers=o}}explainFromTokens(t){if(this.isValid){let[n,r]=yN(t,this.regex,this.handlers),[o,a,i]=r?vN(r):[null,null,void 0];if(zc(r,"a")&&zc(r,"H"))throw new Ms("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 E1(e,t,n){return new kp(e,n).explainFromTokens(t)}function SN(e,t,n){let{result:r,zone:o,specificOffset:a,invalidReason:i}=E1(e,t,n);return[r,o,a,i]}function O1(e,t){if(!e)return null;let r=da.create(t,e).dtFormatter(wN()),o=r.formatToParts(),a=r.resolvedOptions();return o.map(i=>gN(i,e,a))}var db="Invalid DateTime",BS=864e13;function md(e){return new fa("unsupported zone",`the zone "${e.name}" is not supported`)}function fb(e){return e.weekData===null&&(e.weekData=xp(e.c)),e.weekData}function mb(e){return e.localWeekData===null&&(e.localWeekData=xp(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function kl(e,t){let n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new rr({...n,...t,old:n})}function _1(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 mp(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 hp(e,t,n){return _1(Ip(e),t,n)}function NS(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,Sp(r,o))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},i=go.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=Ip(a),[l,c]=_1(s,n,e.zone);return i!==0&&(l+=i,c=e.zone.offset(l)),{ts:l,o:c}}function Nc(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=rr.fromObject(e,{...n,zone:l,specificOffset:a});return i?c:c.setZone(s)}else return rr.invalid(new fa("unparsable",`the input "${o}" can't be parsed as ${r}`))}function pp(e,t,n=!0){return e.isValid?da.create(gr.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function pb(e,t,n){let r=e.c.year>9999||e.c.year<0,o="";if(r&&e.c.year>=0&&(o+="+"),o+=to(e.c.year,r?6:4),n==="year")return o;if(t){if(o+="-",o+=to(e.c.month),n==="month")return o;o+="-"}else if(o+=to(e.c.month),n==="month")return o;return o+=to(e.c.day),o}function ES(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+=to(e.c.hour),i==="hour")break;if(t){if(l+=":",l+=to(e.c.minute),i==="minute")break;s&&(l+=":",l+=to(e.c.second))}else{if(l+=to(e.c.minute),i==="minute")break;s&&(l+=to(e.c.second))}if(i==="second")break;s&&(!r||e.c.millisecond!==0)&&(l+=".",l+=to(e.c.millisecond,3))}return o&&(e.isOffsetFixed&&e.offset===0&&!a?l+="Z":e.o<0?(l+="-",l+=to(Math.trunc(-e.o/60)),l+=":",l+=to(Math.trunc(-e.o%60))):(l+="+",l+=to(Math.trunc(e.o/60)),l+=":",l+=to(Math.trunc(e.o%60)))),a&&(l+="["+e.zone.ianaName+"]"),l}var F1={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},CN={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},kN={ordinal:1,hour:0,minute:0,second:0,millisecond:0},gp=["year","month","day","hour","minute","second","millisecond"],TN=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],IN=["year","ordinal","hour","minute","second","millisecond"];function bp(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 yp(e);return t}function OS(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return bp(e)}}function MN(e){if(pd===void 0&&(pd=Pr.now()),e.type!=="iana")return e.offset(pd);let t=e.name,n=Ab.get(t);return n===void 0&&(n=e.offset(pd),Ab.set(t,n)),n}function _S(e,t){let n=Is(t.zone,Pr.defaultZone);if(!n.isValid)return rr.invalid(md(n));let r=gr.fromObject(t),o,a;if(sn(e.year))o=Pr.now();else{for(let l of gp)sn(e[l])&&(e[l]=F1[l]);let i=d1(e)||f1(e);if(i)return rr.invalid(i);let s=MN(n);[o,a]=hp(e,s,n)}return new rr({ts:o,zone:n,loc:r,o:a})}function FS(e,t,n){let r=sn(n.round)?!0:n.round,o=sn(n.rounding)?"trunc":n.rounding,a=(s,l)=>(s=_b(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 zS(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 pd,Ab=new Map,rr=class e{constructor(t){let n=t.zone||Pr.defaultZone,r=t.invalid||(Number.isNaN(t.ts)?new fa("invalid input"):null)||(n.isValid?null:md(n));this.ts=sn(t.ts)?Pr.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=Ls(t.o)&&!t.old?t.o:n.offset(this.ts);o=mp(this.ts,s),r=Number.isNaN(o.year)?new fa("invalid input"):null,o=r?null:o,a=r?null:s}this._zone=n,this.loc=t.loc||gr.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]=zS(arguments),[r,o,a,i,s,l,c]=n;return _S({year:r,month:o,day:a,hour:i,minute:s,second:l,millisecond:c},t)}static utc(){let[t,n]=zS(arguments),[r,o,a,i,s,l,c]=n;return t.zone=Pa.utcInstance,_S({year:r,month:o,day:a,hour:i,minute:s,second:l,millisecond:c},t)}static fromJSDate(t,n={}){let r=aB(t)?t.valueOf():NaN;if(Number.isNaN(r))return e.invalid("invalid input");let o=Is(n.zone,Pr.defaultZone);return o.isValid?new e({ts:r,zone:o,loc:gr.fromObject(n)}):e.invalid(md(o))}static fromMillis(t,n={}){if(Ls(t))return t<-BS||t>BS?e.invalid("Timestamp out of range"):new e({ts:t,zone:Is(n.zone,Pr.defaultZone),loc:gr.fromObject(n)});throw new ho(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(Ls(t))return new e({ts:t*1e3,zone:Is(n.zone,Pr.defaultZone),loc:gr.fromObject(n)});throw new ho("fromSeconds requires a numerical input")}static fromObject(t,n={}){t=t||{};let r=Is(n.zone,Pr.defaultZone);if(!r.isValid)return e.invalid(md(r));let o=gr.fromObject(n),a=Cp(t,OS),{minDaysInFirstWeek:i,startOfWeek:s}=SS(a,o),l=Pr.now(),c=sn(n.specificOffset)?r.offset(l):n.specificOffset,u=!sn(a.ordinal),d=!sn(a.year),m=!sn(a.month)||!sn(a.day),f=d||m,h=a.weekYear||a.weekNumber;if((f||u)&&h)throw new Ms("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(m&&u)throw new Ms("Can't mix ordinal dates with month/day");let p=h||a.weekday&&!f,g,y,v=mp(l,c);p?(g=TN,y=CN,v=xp(v,i,s)):u?(g=IN,y=kN,v=cb(v)):(g=gp,y=F1);let b=!1;for(let x of g){let T=a[x];sn(T)?b?a[x]=y[x]:a[x]=v[x]:b=!0}let S=p?nB(a,i,s):u?rB(a):d1(a),C=S||f1(a);if(C)return e.invalid(C);let w=p?wS(a,i,s):u?xS(a):a,[k,M]=hp(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]=KB(t);return Nc(r,o,n,"ISO 8601",t)}static fromRFC2822(t,n={}){let[r,o]=$B(t);return Nc(r,o,n,"RFC 2822",t)}static fromHTTP(t,n={}){let[r,o]=XB(t);return Nc(r,o,n,"HTTP",n)}static fromFormat(t,n,r={}){if(sn(t)||sn(n))throw new ho("fromFormat requires an input string and a format");let{locale:o=null,numberingSystem:a=null}=r,i=gr.fromOpts({locale:o,numberingSystem:a,defaultToEN:!0}),[s,l,c,u]=SN(i,t,n);return u?e.invalid(u):Nc(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]=rN(t);return Nc(r,o,n,"SQL",t)}static invalid(t,n=null){if(!t)throw new ho("need to specify a reason the DateTime is invalid");let r=t instanceof fa?t:new fa(t,n);if(Pr.throwOnInvalid)throw new hb(r);return new e({invalid:r})}static isDateTime(t){return t&&t.isLuxonDateTime||!1}static parseFormatForOpts(t,n={}){let r=O1(t,gr.fromObject(n));return r?r.map(o=>o?o.val:null).join(""):null}static expandFormat(t,n={}){return N1(da.parseFormat(t),gr.fromObject(n)).map(o=>o.val).join("")}static resetCache(){pd=void 0,Ab.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?fb(this).weekYear:NaN}get weekNumber(){return this.isValid?fb(this).weekNumber:NaN}get weekday(){return this.isValid?fb(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?mb(this).weekday:NaN}get localWeekNumber(){return this.isValid?mb(this).weekNumber:NaN}get localWeekYear(){return this.isValid?mb(this).weekYear:NaN}get ordinal(){return this.isValid?cb(this.c).ordinal:NaN}get monthShort(){return this.isValid?Ec.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Ec.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Ec.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Ec.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=Ip(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=mp(l,i),d=mp(c,s);return u.hour===d.hour&&u.minute===d.minute&&u.second===d.second&&u.millisecond===d.millisecond?[kl(this,{ts:l}),kl(this,{ts:c})]:[this]}get isInLeapYear(){return bd(this.year)}get daysInMonth(){return Sp(this.year,this.month)}get daysInYear(){return this.isValid?Oc(this.year):NaN}get weeksInWeekYear(){return this.isValid?gd(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?gd(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(t={}){let{locale:n,numberingSystem:r,calendar:o}=da.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(Pr.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=Is(t,Pr.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]=hp(i,a,t)}return kl(this,{ts:o,zone:t})}else return e.invalid(md(t))}reconfigure({locale:t,numberingSystem:n,outputCalendar:r}={}){let o=this.loc.clone({locale:t,numberingSystem:n,outputCalendar:r});return kl(this,{loc:o})}setLocale(t){return this.reconfigure({locale:t})}set(t){if(!this.isValid)return this;let n=Cp(t,OS),{minDaysInFirstWeek:r,startOfWeek:o}=SS(n,this.loc),a=!sn(n.weekYear)||!sn(n.weekNumber)||!sn(n.weekday),i=!sn(n.ordinal),s=!sn(n.year),l=!sn(n.month)||!sn(n.day),c=s||l,u=n.weekYear||n.weekNumber;if((c||i)&&u)throw new Ms("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&i)throw new Ms("Can't mix ordinal dates with month/day");let d;a?d=wS({...xp(this.c,r,o),...n},r,o):sn(n.ordinal)?(d={...this.toObject(),...n},sn(n.day)&&(d.day=Math.min(Sp(d.year,d.month),d.day))):d=xS({...cb(this.c),...n});let[m,f]=hp(d,this.o,this.zone);return kl(this,{ts:m,o:f})}plus(t){if(!this.isValid)return this;let n=go.fromDurationLike(t);return kl(this,NS(this,n))}minus(t){if(!this.isValid)return this;let n=go.fromDurationLike(t).negate();return kl(this,NS(this,n))}startOf(t,{useLocaleWeeks:n=!1}={}){if(!this.isValid)return this;let r={},o=go.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?da.create(this.loc.redefaultToEN(n)).formatDateTimeFromString(this,t):db}toLocaleString(t=vp,n={}){return this.isValid?da.create(this.loc.clone(n),t).formatDateTime(this):db}toLocaleParts(t={}){return this.isValid?da.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=bp(i);let s=t==="extended",l=pb(this,s,i);return gp.indexOf(i)>=3&&(l+="T"),l+=ES(this,s,n,r,o,a,i),l}toISODate({format:t="extended",precision:n="day"}={}){return this.isValid?pb(this,t==="extended",bp(n)):null}toISOWeekDate(){return pp(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=bp(s),(o&&gp.indexOf(s)>=3?"T":"")+ES(this,i==="extended",n,t,r,a,s)):null}toRFC2822(){return pp(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return pp(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?pb(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")),pp(this,o,!0)}toSQL(t={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(t)}`:null}toString(){return this.isValid?this.toISO():db}[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 go.invalid("created by diffing an invalid DateTime");let o={locale:this.locale,numberingSystem:this.numberingSystem,...r},a=iB(n).map(go.normalizeUnit),i=t.valueOf()>this.valueOf(),s=i?this:t,l=i?t:this,c=cN(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?Fc.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),FS(n,this.plus(r),{...t,numeric:"always",units:o,unit:a})}toRelativeCalendar(t={}){return this.isValid?FS(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 ho("min requires all arguments be DateTimes");return CS(t,n=>n.valueOf(),Math.min)}static max(...t){if(!t.every(e.isDateTime))throw new ho("max requires all arguments be DateTimes");return CS(t,n=>n.valueOf(),Math.max)}static fromFormatExplain(t,n,r={}){let{locale:o=null,numberingSystem:a=null}=r,i=gr.fromOpts({locale:o,numberingSystem:a,defaultToEN:!0});return E1(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=gr.fromOpts({locale:r,numberingSystem:o,defaultToEN:!0});return new kp(a,t)}static fromFormatParser(t,n,r={}){if(sn(t)||sn(n))throw new ho("fromFormatParser requires an input string and a format parser");let{locale:o=null,numberingSystem:a=null}=r,i=gr.fromOpts({locale:o,numberingSystem:a,defaultToEN:!0});if(!i.equals(n.locale))throw new ho(`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):Nc(s,l,r,`format ${n.format}`,t,c)}static get DATE_SHORT(){return vp}static get DATE_MED(){return HS}static get DATE_MED_WITH_WEEKDAY(){return _A}static get DATE_FULL(){return VS}static get DATE_HUGE(){return WS}static get TIME_SIMPLE(){return qS}static get TIME_WITH_SECONDS(){return US}static get TIME_WITH_SHORT_OFFSET(){return jS}static get TIME_WITH_LONG_OFFSET(){return GS}static get TIME_24_SIMPLE(){return YS}static get TIME_24_WITH_SECONDS(){return KS}static get TIME_24_WITH_SHORT_OFFSET(){return $S}static get TIME_24_WITH_LONG_OFFSET(){return XS}static get DATETIME_SHORT(){return ZS}static get DATETIME_SHORT_WITH_SECONDS(){return QS}static get DATETIME_MED(){return JS}static get DATETIME_MED_WITH_SECONDS(){return e1}static get DATETIME_MED_WITH_WEEKDAY(){return FA}static get DATETIME_FULL(){return t1}static get DATETIME_FULL_WITH_SECONDS(){return n1}static get DATETIME_HUGE(){return r1}static get DATETIME_HUGE_WITH_SECONDS(){return o1}};function dd(e){if(rr.isDateTime(e))return e;if(e&&e.valueOf&&Ls(e.valueOf()))return rr.fromJSDate(e);if(e&&typeof e=="object")return rr.fromObject(e);throw new ho(`Unknown datetime argument: ${e}, of type ${typeof e}`)}function wd(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 Rp(e,t,n){if(t<=0n)return e;let{start:r,end:o}=wd(e,t,n);if(e-r<=o-e)return r;let a=wd(o,t,n).start;return a>r?a:o}function $n(){return typeof window>"u"?1:window.devicePixelRatio||1}function ri(e,t=$n()){return Math.round(e*t)/t}function z1(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 Vb(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?z1(r/40):z1(Math.abs(n)/100||1)}function LN(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 RN(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 PN(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 H1(e,t,n){if(e==="renko"){let c=LN(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=PN(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}=RN(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 xd=20;var kn=30,AN=12,jn={background:"#16181d",buyLine:"#00e676",sellLine:"#ff1744",grid:"#282a2e",label:"#888888",axisBg:"#16181d",crosshair:"#aaaaaa",crosshairBg:"#23272f",crosshairText:"#FFFFFF"},Wb='11px "Inter"',BN=14,NN=50,W1=new Map;function Ap(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=Wb;let d=W1.get(Wb);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))}W1.set(Wb,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(NN,Math.ceil(c+BN))}function Pp(e,t){return Math.round(e*t)/t}function eC(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 Dp(e,t){return Math.max(1,Math.round(e*t))/t}function Gb(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 Bp(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=$n();R.setTransform(P,0,0,P,0,0);let D=e.width/P,N=e.height/P,O=I?0:kn;GN(R,D,N,p);let A=T??Ap(s,x,p,M,R),B=D-A;t.forEach(E=>{let L=n[E.id];if(!L||L.h<2)return;let H=E.isMain,K=H?s.pMin:E.yMin,G=H?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 V=new Mi;V.update({...s,pMax:G,pMin:K}),w&&V.setSessionMapper(w);let q={ctx:R,rect:{...L,x:0,y:0},tMin:s.tMin,tMax:s.tMax,yMin:K,yMax:G,barNs:h,horizon:g,transformer:V};if(H){K1(R,s,K,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||nE(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&&$N(R,o,s,B,L.h,h,p,g,S)}finally{R.restore()}}else R.fillStyle=jn.background,R.fillRect(0,0,B,L.h),K1(R,s,K,G,B,L.h,h,p,S,S.getScaleMode()==="log",x);r.filter(j=>j.visible&&(j.paneId===E.id||j.layout==="overlay"&&H)).forEach(j=>{try{R.save(),j.drawBase&&j.drawBase(q),R.restore()}catch(W){console.error(W)}}),R.restore()}),p.showBreaks&&KN(R,s,B,N-O,p,S,h),lC(R,D,N,B,N-O,p),sC(R,e,t,n,s,B),UN(R,t,n,B)}function tC(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,H,K,G,V){let q=e.getContext("2d");if(!q)return;G?.setSymbol(E?.symbol);let j=performance.now();P&&P.setBarNs(m);let W=$n(),$=H?0:kn;q.setTransform(W,0,0,W,0,0);let J=e.width/W,me=e.height/W,We=K??Ap(r,E,f,L,q),Ce=J-We,Ee=me-$;q.clearRect(0,0,J,me),lC(q,J,me,Ce,Ee,f);let ze=l.main||{x:0,y:0,w:Ce,h:Ee},Ie=ze.h,ee=ze.y;Ie>=2&&(YN(q,e,r,Ce,Ee,f,Ie,m,[],ee,P,A,L,H,E),L||eE(q,e,t,n,r,Ce,Ie,f,m,h,p,g,y,ee,P,A,E,We,G,j)),!L&&sC(q,e,s,l,r,Ce),f.showFills&&qN(q,e,r,Ce,Ee,f,Ie,ee,m,h,o,P,B,g,y,E.symbol);let{hitMap:Be,suspendCrosshair:F}=cS(q,e,r,Ce,Ee,f,v,Ie,ee,S,C,b,po(E),P,We,E,o??{x:0,y:0}),le=!!o&&o.x<Ce&&o.y<Ee&&u===-1&&!d,ce=!o&&V?QN(V,s,l,Ce,P,E):null,ke=le?o:ce?.point;if(ke&&u===-1&&!F&&JN(q,e,r,ke,Ce,Ee,s,l,m,h,f,w,k,M,I,m,x,t,g,T,R,P,A,L,H,$,E,We,!le,!le&&!ce?.full),u!==-1&&jN(q,s,l,e.width,u),o&&a&&tE(q,o,t,r,Ce,Ee,P,E),o&&s.length>0&&s.forEach(De=>{let ve=l[De.id];if(!ve||ve.h<2)return;let Qe={ctx:q,rect:ve,tMin:r.tMin,tMax:r.tMax,yMin:De.isMain?r.pMin:De.yMin,yMax:De.isMain?r.pMax:De.yMax,barNs:m,horizon:h,transformer:P};c.filter(Ye=>Ye.visible&&(Ye.paneId===De.id||Ye.layout==="overlay"&&De.isMain)).forEach(Ye=>{Ye.drawUI&&Ye.drawUI(Qe,o)})}),D)try{EN(q,e,s,l,r,m,Ce,Ee,P,N,O,o,E)}catch{}return i&&(XN(q,i,r,Ce,Ie,f,P),ZN(q,i,r,Ce,Ie,f,P,E)),Be}var EN=(e,t,n,r,o,a,i,s,l,c,u,d,m)=>{function f(K,G){let V=K/G;return K%G*2n>=G?(V+1n)*G:V*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=Fr(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,H=7;e.fillStyle="#3b5897",jb(e,S-A/2-L/2,w?Math.min(p,y)-B-E:Math.max(p,y)+E,A+L,B,H),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 nC(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 Cd(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 ON=32;function rC(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=Cd(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>=ON&&(b.push(C),S=C.y);return b}let i=Math.max(o,Cd(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 Yb(e){return new Date(Number(e/1000000n))}var q1=new Map;function _N(e,t,n){let r=`${e}|${t}|${n}`,o=q1.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),q1.set(r,o)}return o}var U1=null;function FN(e,t){let n=U1;if(n&&n.tMin===e.tMin&&n.tMax===e.tMax&&n.timezone===t)return n.spansDays;let r=rr.fromMillis(Number(e.tMin/1000000n),{zone:t}),o=rr.fromMillis(Number(e.tMax/1000000n),{zone:t}),a=r.day!==o.day||r.month!==o.month||r.year!==o.year;return U1={tMin:e.tMin,tMax:e.tMax,timezone:t,spansDays:a},a}function oC(e,t,n,r,o,a=!1,i=!1){let s=60000000000n,l=1000000000n,c=Yb(e),u=_N(n,r,t<s).format(c),d=rr.fromMillis(Number(e/1000000n),{zone:n}),m=!1;return a||(FN(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 j1=new Map;function zN(e,t){let n=Yb(e),r=j1.get(t);r||(r=new Intl.DateTimeFormat("en-GB",{timeZone:t,weekday:"short",day:"2-digit",month:"short",year:"2-digit"}),j1.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 G1=[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 Y1(e,t,n){if(e<=0n)return t>0n?t:G1[0];for(let r of G1)if(!(t>0n&&(r<t||r%t!==0n))&&e/r<=BigInt(n))return r;return HN(e,t,n)}function HN(e,t,n){if(t<=0n)return BigInt(Math.round(Cd(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 Sd(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 aC(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(Cd(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=Y1(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=Y1(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 kd(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 Uc(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 VN(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 iC(e,t,n,r,o,a,i,s,l){let c=null,u=AN,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 jb(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 K1(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 rC(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 aC(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 sC(e,t,n,r,o,a){e.font='11px "Inter"',e.textAlign="left",e.textBaseline="middle",e.fillStyle=jn.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=Cd(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 $1=new WeakMap,X1=new WeakMap;function WN(e,t){let n=X1.get(e);n||(n=new Map,X1.set(e,n));let r=n.get(t);return r||(r=e.filter(o=>o.symbol===t),n.set(t,r)),r}function qN(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=WN(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=$1.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=j=>{if(j===D&&h)return h;if(j>=P)return;let W=0,$=f.length-1;for(;W<=$;){let J=W+$>>>1,me=f[J].time;if(me===j)return f[J];me<j?W=J+1:$=J-1}},O=Number(n.tMin/1000000n),A=Number(n.tMax/1000000n),B=y.length;{let j=0,W=y.length-1;for(;j<=W;){let $=j+W>>>1;y[$].ts/1e6<O?j=$+1:(B=$,W=$-1)}}let E=[],L=[],H=[],K=0,G=0,V=0,q=0;for(let j=B;j<y.length;j++){let W=y[j],$=W.ts/1e6;if($>A)break;let J=Math.floor($/S)*S,me=W.side==="long";me?V===J?K++:K=0:q===J?G++:G=0;let We=N(J);if(!We){me?V=J:q=J;continue}let Ce=T(BigInt(J)*1000000n),Ee=Math.min(Math.max(.1*b,4),12),ze=Ee*3.5;if(me){let Ie=R(We.low)+5+K*(ze+7);E.push({x:Ce,y:Ie,hw:Ee,arrowH:ze}),H.push({x:Ce,yTop:Ie,yBottom:Ie+ze,hw:Ee,priceY:R(W.price),color:"#12DAF2",quantity:W.quantity}),V=J}else{let Ie=R(We.high)-5-G*(ze+7);L.push({x:Ce,y:Ie,hw:Ee,arrowH:ze}),H.push({x:Ce,yTop:Ie-ze,yBottom:Ie,hw:Ee,priceY:R(W.price),color:"#F23040",quantity:W.quantity}),q=J}}w={boundsKey:C,fillsRef:y,barsRef:f,openBarRef:h,barNs:l,horizon:c,w:r,h:o,longGeom:E,shortGeom:L,hoverTargets:H},$1.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 UN(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 jN(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 GN(e,t,n,r){e.fillStyle=r.backgroundColor??jn.background,e.fillRect(0,0,t,n)}function lC(e,t,n,r,o,a){let i=ri(r),s=ri(o);e.fillStyle=a.axisBackgroundColor??jn.axisBg,e.fillRect(i,0,t-i,n),e.fillRect(0,s,t,n-s),e.strokeStyle=jn.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 YN(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=jn.label,e.font='11px "Inter"',e.textAlign="left",e.textBaseline="middle",!m){let g=u?.getScaleMode()==="log";for(let{value:y}of rC(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)<xd)))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 aC(n,s,12,u.getSessionMapper(),u)){let S=ri(u.tsToX(v,r)),{bold:C,text:w}=oC(v,s,g,y,n,!1,b);e.font=`${C?"bold":""} 11px "Inter"`,e.fillText(w,S,ri(o+8))}}e.restore()}function Ml(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,kd(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 Ps(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,kd(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 Ds(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 KN(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 $N(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 XN(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 ZN(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=Yb(t.ts).toISOString().slice(11,23),f=[["Side",u?"BUY":"SELL"],["Price",Fr(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=jn.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 Td=(e,t,n)=>Rp(e,t,n),Id=(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 QN(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 JN(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(K=>{let G=s[K.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 K=A.segments.find(G=>O>=G.realStart&&O<G.realEnd);if(K){let G=O-K.realStart;if(B=K.realStart+(G+l/2n)/l*l,B>=K.realEnd){let V=A.segments.find(q=>q.realStart>=K.realEnd);B=V?V.realStart:K.realEnd-l}}else B=O}else B=(O+l/2n)/l*l;if(A&&A.hasSession&&l>0n){let K=A.segments[0];if(K&&O>=K.realStart&&!(V=>A.segments.some(q=>V>=q.realStart&&V<q.realEnd))(B)){let V=[],q=[...A.segments].reverse().find(W=>W.realEnd<=O);if(q){let $=(q.realEnd-q.realStart)/l*l,J=q.realStart+$<q.realEnd?q.realStart+$:q.realStart+$-l;J>=q.realStart&&V.push(J)}let j=A.segments.find(W=>W.realStart>O);if(j&&V.push(j.realStart),V.length>0){let W=A.tsToMarket(O);B=V.reduce(($,J)=>{let me=A.tsToMarket($),We=A.tsToMarket(J),Ce=me>W?me-W:W-me;return(We>W?We-W:W-We)<Ce?J:$})}}}let E=l>0n?C.tsToX(B,o):r.x,L=po(x);E<o&&(e.beginPath(),e.moveTo(E,0),e.lineTo(E,a),e.stroke());let H=r.y;if(N&&!P)if(!R&&(d?.name!=="cursor"||m?.anchor)){let K=s.main,G=K?.h??t.height-I,V=K?.y??0,q=b.find(j=>j.id===m?.drawingId);if(h&&q?.tool!=="fib")S?H=C.priceToY(S.a?.price,G)+V:q?.a&&q?.b&&(H=C.priceToY(m.anchor==="a"?q.b.price:q.a.price,G)+V);else if((f||u.crosshairMode==="magnet")&&m?.anchor!=="body"){let j=Td(O,p,C.getSessionMapper()),W=C.yToPrice(r.y-V,G),$=Id(j,W,u,g,y,v,w,c);H=C.priceToY($,G)+V}e.beginPath(),e.moveTo(0,H),e.lineTo(o,H),e.stroke()}else e.beginPath(),e.moveTo(0,r.y),e.lineTo(o,r.y),e.stroke();if(!M){let K=u.timezone??"UTC",G=u.use24HourClock??!0,{text:V}=oC(B,l,K,G,n,!0),q=zN(B,K);e.font='11px "Inter"';let j=e.measureText(q+" "+V).width+16;e.fillStyle=jn.crosshairBg;let W=ri(Math.max(0,Math.min(o-j,E-j/2))),$=ri(a);e.fillRect(W,$,j,20),e.fillStyle=jn.crosshairText,e.textAlign="center",e.textBaseline="middle",e.fillText(q+" "+V,W+j/2,$+10)}if(!k&&!P){if(!N||!D){e.restore();return}let K=D.isMain?n.pMin:D.yMin,G=D.isMain?n.pMax:D.yMax,V=H-N.y,q=K+(N.h-V)/N.h*(G-K),j=Fr(Math.round(q/L)*L,x),W=ri(H);e.fillStyle=jn.crosshairBg,e.fillRect(ri(o),W-10,T,20),e.fillStyle=jn.crosshairText,e.textAlign="left",e.textBaseline="middle",e.fillText(j,o+6,W)}e.restore()}function eE(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=Uc(n,o.tMax);if(T===-1)return[];let R=Uc(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=jn.sellLine,e.moveTo(0,N),e.lineTo(a,N),e.stroke(),e.restore(),I.push({idealY:N,actualY:N,fillColor:jn.sellLine,textColor:jn.crosshairBg,label:Fr(P,g),filled:!0})),M(O)&&s.showBidLine&&(e.save(),e.beginPath(),e.rect(0,f,a,i),e.clip(),e.beginPath(),e.strokeStyle=jn.buyLine,e.moveTo(0,O),e.lineTo(a,O),e.stroke(),e.restore(),I.push({idealY:O,actualY:O,fillColor:jn.buyLine,textColor:jn.crosshairBg,label:Fr(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(VN(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=Gb(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:Sd(O),textColor:jn.crosshairBg,label:Fr(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:jn.sellLine,textColor:jn.sellLine,label:Fr(C.bestAsk,g),filled:!1}),M(R)&&I.push({idealY:R,actualY:R,fillColor:jn.buyLine,textColor:jn.buyLine,label:Fr(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:jn.sellLine,textColor:jn.sellLine,label:Fr(C.ask,g),filled:!1}),M(R)&&I.push({idealY:R,actualY:R,fillColor:jn.buyLine,textColor:jn.buyLine,label:Fr(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:Sd(P),textColor:Sd(P),label:Fr(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<xd){let D=xd-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?(jb(e,a,T.actualY-10,y,xd,3),e.fillStyle=T.fillColor,e.fill()):(jb(e,a+1,T.actualY-10,y-2,xd,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 tE(e,t,n,r,o,a,i,s){let l=i.xToTs(t.x,o),c=Uc(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: ${Fr(u.bestAsk,s)}`,`Bid: ${Fr(u.bestBid,s)}`,`Spread: ${Fr(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 nE(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"){oS(e,m,r,o,a,s,f.footprintMode,po(S),f.footprintVolume,f,h,v),u&&Ps(e,n,r,o,a,f,h,v),d&&Ds(e,t,r,o,a,f,h,v);return}if(i==="candles"){rE(e,t,n,r,o,a,s,f,h,p,g,y,v),u&&Ps(e,n,r,o,a,f,h,v),d&&Ds(e,t,r,o,a,f,h,v);return}if(i==="area"){C||b==="l3"?(c&&Ub(e,n,r,o,a,"ask",f,h,s,v),l&&Ub(e,n,r,o,a,"bid",f,h,s,v)):b==="ohlcv"&&Ub(e,n,r,o,a,"price",f,h,s,v,y,g),u&&Ps(e,n,r,o,a,f,h,v),d&&Ds(e,t,r,o,a,f,h,v);return}if(i==="line"){C||b==="l3"?(l&&qb(e,n,r,o,a,jn.buyLine,"bid",f,h,s,v),c&&qb(e,n,r,o,a,jn.sellLine,"ask",f,h,s,v)):b==="ohlcv"&&qb(e,n,r,o,a,"#1190b0","price",f,h,s,v,y,g),u&&Ps(e,n,r,o,a,f,h,v),d&&Ds(e,t,r,o,a,f,h,v);return}if(i==="hollow"||i==="heikin-ashi"||i==="bars"){if(s===0n)(b==="l3"||C)&&(l&&Ml(e,n,r,o,a,jn.buyLine,"bid",f,h,0n,v),c&&Ml(e,n,r,o,a,jn.sellLine,"ask",f,h,0n,v));else{let w=oE(t,r,s,h,p,g,y,v);i==="heikin-ashi"&&(w=aE(w)),i==="bars"?sE(e,w,o,a,f,v):iE(e,w,o,a,f,v,i==="hollow")}u&&Ps(e,n,r,o,a,f,h,v),d&&Ds(e,t,r,o,a,f,h,v);return}if(i==="baseline"){C||b==="l3"?Z1(e,n,r,o,a,l||!c?"bid":"ask",f,h,s,v):b==="ohlcv"&&Z1(e,n,r,o,a,"price",f,h,s,v,y,g),u&&Ps(e,n,r,o,a,f,h,v),d&&Ds(e,t,r,o,a,f,h,v);return}if(cC(i)){let w=Kb(i,f,y,p,t,s);w&&(i==="renko"?uE(e,w,r,o,a,f,h,v):i==="kagi"?dE(e,w,r,o,a,f,h,v):fE(e,w,r,o,a,f,h,v)),u&&Ps(e,n,r,o,a,f,h,v),d&&Ds(e,t,r,o,a,f,h,v);return}b==="l3"||C?(l&&Ml(e,n,r,o,a,jn.buyLine,"bid",f,h,s,v),c&&Ml(e,n,r,o,a,jn.sellLine,"ask",f,h,s,v)):Ml(e,n,r,o,a,"#1190b0","price",f,h,s,v,y,g),u&&Ps(e,n,r,o,a,f,h,v),d&&Ds(e,t,r,o,a,f,h,v)}function qb(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,kd(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 Ub(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,kd(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 rE(e,t,n,r,o,a,i,s,l=0n,c=null,u=null,d,m){if(i===0n){Ml(e,n,r,o,a,jn.buyLine,"bid",s,l,0n,m),Ml(e,n,r,o,a,jn.sellLine,"ask",s,l,0n,m);return}let f=m.getSessionMapper(),h=m.getBarPx(o),p=$n(),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,H=eC((E+g/2)/p,x,p),K=Pp(Math.min(D(O.open),D(O.close)),p),G=Pp(Math.max(D(O.open),D(O.close)),p),V={left:L,wickX:H,yHigh:D(O.high),yLow:D(O.low),bodyTop:K,bodyH:Math.max(1/p,G-K),hasWick:O.high!==O.low};(O.close>=O.open?T:R).push(V)};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(J=>({startMs:Number(J.realStart/1000000n),endMs:Number(J.realEnd/1000000n)})):null,H=Number(i/1000000n),K=J=>{if(!L)return;let me=0,We=L.length-1;for(;me<=We;){let Ce=me+We>>>1;if(L[Ce].endMs<=J)me=Ce+1;else if(L[Ce].startMs>J)We=Ce-1;else return L[Ce]}},G=new Map,V=[],q=Number((r.tMin>i?r.tMin-i:0n)/1000000n),j=0;{let J=0,me=d.length-1;for(;J<=me;){let We=J+me>>>1;d[We].time<q?J=We+1:me=We-1}j=J}let W=Number((r.tMax+i)/1000000n),$=Math.min(B,W);for(let J=j;J<d.length;J++){let me=d[J],We=me.time;if(We>=$)break;let Ce,Ee=K(We);Ee?Ce=Ee.startMs+Math.floor((We-Ee.startMs)/H)*H:Ce=Math.floor(We/H)*H;let ze=G.get(Ce);ze?(me.high>ze.high&&(ze.high=me.high),me.low<ze.low&&(ze.low=me.low),ze.close=me.close,ze.volume+=me.volume):(G.set(Ce,{open:me.open,high:me.high,low:me.low,close:me.close,volume:me.volume}),V.push(Ce))}for(let J of V){let me=BigInt(J)*1000000n;if(J===E&&u)N(u,me);else{let We=G.get(J);N(We,me)}}u&&E!==-1&&(V.length>0?V[V.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 K=(r.tMin>L.realStart?r.tMin:L.realStart)-L.realStart,G=L.realStart+K/i*i,V=O<L.realEnd?O:L.realEnd;for(let q=G;q<V;q+=i)if(!(q+i===A&&u)){let j=c.get(q);j&&N(j,q)}}else for(let L=B;L<=E;L+=i)if(L===A&&u)N(u,L);else{let H=c.get(L);H&&N(H,L)}}else{let O=l>0n?l:r.tMax,A=t.length;{let L=0,H=t.length-1;for(;L<=H;){let K=L+H>>>1;t[K].ts<O?L=K+1:(A=K,H=K-1)}}let B=A<t.length?t.slice(0,A):t,E=Gb(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=Dp(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=Dp(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 oE(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 Gb(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 aE(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 iE(e,t,n,r,o,a,i=!1){if(!t.length)return;let s=a.getBarPx(n),l=$n(),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=eC((T+c/2)/l,C,l),D=Pp(Math.min(f(I.open),f(I.close)),l),N=Pp(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=Dp(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=Dp(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 sE(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 Z1(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,kd(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=Sd(i.upBodyColor??"#00e676"),v=Sd(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 Q1=new WeakMap;function lE(e,t,n,r){let o=(a,i,s)=>{let l=Q1.get(a);if(l&&l.sig===i)return l.series;let c=s();return Q1.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 J1=new WeakMap;function cE(e,t,n){let r=J1.get(e);r||(r=new Map,J1.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 cC(e){return e==="renko"||e==="kagi"||e==="line-break"}function Kb(e,t,n,r,o,a){if(!cC(e))return null;let i=lE(n,r,o,a);if(i.length<2)return null;let s;return e==="renko"?s=t.renkoBrickSize??Vb(i):e==="kagi"?s=t.kagiReversal??Vb(i)*2:s=Math.max(1,t.lineBreakCount||3),cE(i,`model:${e}:${s}`,()=>H1(e,i,s))}function uC(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 $b(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 uE(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]=$b(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 dE(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]=$b(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 fE(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]=$b(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")}var Ep=require("react");var dC=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),mE=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),Xb=e=>{let t=mE(e);return t.charAt(0).toUpperCase()+t.slice(1)},Np=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),fC=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Md=require("react");var mC={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 pC=(0,Md.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:a,iconNode:i,...s},l)=>(0,Md.createElement)("svg",{ref:l,...mC,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Np("lucide",o),...!a&&!fC(s)&&{"aria-hidden":"true"},...s},[...i.map(([c,u])=>(0,Md.createElement)(c,u)),...Array.isArray(a)?a:[a]]));var oe=(e,t)=>{let n=(0,Ep.forwardRef)(({className:r,...o},a)=>(0,Ep.createElement)(pC,{ref:a,iconNode:t,className:Np(`lucide-${dC(Xb(e))}`,`lucide-${e}`,r),...o}));return n.displayName=Xb(e),n};var pE=[["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"}]],Ld=oe("activity",pE);var hE=[["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"}]],Rd=oe("align-center-vertical",hE);var gE=[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Pd=oe("align-center",gE);var bE=[["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"}]],Dd=oe("align-end-vertical",bE);var yE=[["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"}]],Ad=oe("align-horizontal-space-around",yE);var vE=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Bd=oe("align-left",vE);var wE=[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Nd=oe("align-right",wE);var xE=[["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"}]],Ed=oe("align-start-vertical",xE);var SE=[["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"}]],Od=oe("align-vertical-space-around",SE);var CE=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],_d=oe("arrow-down-right",CE);var kE=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Fd=oe("arrow-down",kE);var TE=[["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"}]],zd=oe("arrow-left-right",TE);var IE=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Hd=oe("arrow-up-right",IE);var ME=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Vd=oe("arrow-up",ME);var LE=[["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"}]],jc=oe("bold",LE);var RE=[["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"}]],Gc=oe("book-marked",RE);var PE=[["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"}]],Wd=oe("camera",PE);var DE=[["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"}]],As=oe("chart-candlestick",DE);var AE=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Bs=oe("chart-line",AE);var BE=[["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"}]],Li=oe("chart-no-axes-column",BE);var NE=[["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"}]],qd=oe("chart-no-axes-combined",NE);var EE=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Yr=oe("check",EE);var OE=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],or=oe("chevron-down",OE);var _E=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ll=oe("chevron-left",_E);var FE=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Yi=oe("chevron-right",FE);var zE=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],oi=oe("chevron-up",zE);var HE=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Ud=oe("chevrons-down-up",HE);var VE=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],jd=oe("chevrons-down",VE);var WE=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Gd=oe("chevrons-up-down",WE);var qE=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Yd=oe("chevrons-up",qE);var UE=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ns=oe("circle-check",UE);var jE=[["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=oe("circle-question-mark",jE);var GE=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Rl=oe("circle",GE);var YE=[["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"}]],Pl=oe("copy",YE);var KE=[["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"}]],Kd=oe("cpu",KE);var $E=[["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"}]],$d=oe("database",$E);var XE=[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]],Es=oe("dot",XE);var ZE=[["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"}]],Xd=oe("download",ZE);var QE=[["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"}]],Zd=oe("drafting-compass",QE);var JE=[["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"}]],Os=oe("ellipsis",JE);var eO=[["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"}]],Ri=oe("eye-off",eO);var tO=[["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=oe("eye",tO);var nO=[["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"}]],_s=oe("file-question-mark",nO);var rO=[["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"}]],Qd=oe("flask-conical",rO);var oO=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Jd=oe("gauge",oO);var aO=[["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"}]],Dl=oe("globe",aO);var iO=[["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=oe("grid-3x3",iO);var sO=[["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"}]],Al=oe("grip-vertical",sO);var lO=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Yc=oe("info",lO);var cO=[["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"}]],Kc=oe("italic",cO);var uO=[["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=oe("layers",uO);var dO=[["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"}]],ef=oe("layout-dashboard",dO);var fO=[["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"}]],tf=oe("layout-grid",fO);var mO=[["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"}]],$c=oe("link-2",mO);var pO=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Pi=oe("loader-circle",pO);var hO=[["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"}]],Di=oe("lock-open",hO);var gO=[["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"}]],no=oe("lock",gO);var bO=[["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"}]],nf=oe("magnet",bO);var yO=[["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"}]],rf=oe("map-pin",yO);var vO=[["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"}]],of=oe("maximize-2",vO);var wO=[["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"}]],af=oe("minimize-2",wO);var xO=[["path",{d:"M5 12h14",key:"1ays0h"}]],Jo=oe("minus",xO);var SO=[["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"}]],sf=oe("monitor",SO);var CO=[["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"}]],Fs=oe("palette",CO);var kO=[["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"}]],zs=oe("panel-left-close",kO);var TO=[["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"}]],Hs=oe("panel-left-open",TO);var IO=[["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"}]],lf=oe("pin",IO);var MO=[["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"}]],cf=oe("pin-off",MO);var LO=[["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"}]],Bl=oe("plug",LO);var RO=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pa=oe("plus",RO);var PO=[["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"}]],ea=oe("puzzle",PO);var DO=[["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"}]],uf=oe("refresh-cw",DO);var AO=[["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"}]],ha=oe("rotate-ccw",AO);var BO=[["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"}]],df=oe("ruler",BO);var NO=[["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"}]],ff=oe("save",NO);var EO=[["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"}]],mf=oe("search-x",EO);var OO=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],li=oe("search",OO);var _O=[["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"}]],pf=oe("server-crash",_O);var FO=[["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"}]],hf=oe("settings-2",FO);var zO=[["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"}]],Nl=oe("settings",zO);var HO=[["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"}]],gf=oe("shield",HO);var VO=[["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"}]],bf=oe("sliders-horizontal",VO);var WO=[["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"}]],Vs=oe("square-function",WO);var qO=[["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"}]],El=oe("star",qO);var UO=[["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"}]],yf=oe("target",UO);var jO=[["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"}]],Xc=oe("ticket",jO);var GO=[["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"}]],vf=oe("timer",GO);var YO=[["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"}]],Mo=oe("trash-2",YO);var KO=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],wf=oe("trending-down",KO);var $O=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Ol=oe("trending-up",$O);var XO=[["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"}]],ga=oe("triangle-alert",XO);var ZO=[["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"}]],_l=oe("type",ZO);var QO=[["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"}]],xf=oe("unlink",QO);var JO=[["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"}]],Sf=oe("waves",JO);var e_=[["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"}]],Cf=oe("wifi-off",e_);var t_=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Kr=oe("x",t_);var Us=require("react");function hC(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=hC(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Op(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=hC(e))&&(r&&(r+=" "),r+=t);return r}var n_=e=>{let t=o_(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{let s=i.split("-");return s[0]===""&&s.length!==1&&s.shift(),yC(s,t)||r_(i)},getConflictingClassGroupIds:(i,s)=>{let l=n[i]||[];return s&&r[i]?[...l,...r[i]]:l}}},yC=(e,t)=>{if(e.length===0)return t.classGroupId;let n=e[0],r=t.nextPart.get(n),o=r?yC(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},gC=/^\[(.+)\]$/,r_=e=>{if(gC.test(e)){let t=gC.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},o_=e=>{let{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return i_(Object.entries(e.classGroups),n).forEach(([a,i])=>{Qb(i,r,a,t)}),r},Qb=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){let a=o===""?t:bC(t,o);a.classGroupId=n;return}if(typeof o=="function"){if(a_(o)){Qb(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([a,i])=>{Qb(i,bC(t,a),n,r)})})},bC=(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},a_=e=>e.isThemeGetter,i_=(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,s_=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 l_=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},c_=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},u_=e=>({cache:s_(e.cacheSize),parseClassName:l_(e),...n_(e)}),d_=/\s+/,f_=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o}=t,a=[],i=e.trim().split(d_),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=c_(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 m_(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=vC(t))&&(r&&(r+=" "),r+=n);return r}var vC=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=vC(e[r]))&&(n&&(n+=" "),n+=t);return n};function p_(e,...t){let n,r,o,a=i;function i(l){let c=t.reduce((u,d)=>d(u),e());return n=u_(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=f_(l,n);return o(l,u),u}return function(){return a(m_.apply(null,arguments))}}var Cr=e=>{let t=n=>n[e]||[];return t.isThemeGetter=!0,t},wC=/^\[(?:([a-z-]+):)?(.+)\]$/i,h_=/^\d+\/\d+$/,g_=new Set(["px","full","screen"]),b_=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,y_=/\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$/,v_=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,w_=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,x_=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ki=e=>Zc(e)||g_.has(e)||h_.test(e),Ws=e=>Qc(e,"length",R_),Zc=e=>!!e&&!Number.isNaN(Number(e)),Zb=e=>Qc(e,"number",Zc),kf=e=>!!e&&Number.isInteger(Number(e)),S_=e=>e.endsWith("%")&&Zc(e.slice(0,-1)),Tn=e=>wC.test(e),qs=e=>b_.test(e),C_=new Set(["length","size","percentage"]),k_=e=>Qc(e,C_,xC),T_=e=>Qc(e,"position",xC),I_=new Set(["image","url"]),M_=e=>Qc(e,I_,D_),L_=e=>Qc(e,"",P_),Tf=()=>!0,Qc=(e,t,n)=>{let r=wC.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},R_=e=>y_.test(e)&&!v_.test(e),xC=()=>!1,P_=e=>w_.test(e),D_=e=>x_.test(e);var A_=()=>{let e=Cr("colors"),t=Cr("spacing"),n=Cr("blur"),r=Cr("brightness"),o=Cr("borderColor"),a=Cr("borderRadius"),i=Cr("borderSpacing"),s=Cr("borderWidth"),l=Cr("contrast"),c=Cr("grayscale"),u=Cr("hueRotate"),d=Cr("invert"),m=Cr("gap"),f=Cr("gradientColorStops"),h=Cr("gradientColorStopPositions"),p=Cr("inset"),g=Cr("margin"),y=Cr("opacity"),v=Cr("padding"),b=Cr("saturate"),S=Cr("scale"),C=Cr("sepia"),w=Cr("skew"),k=Cr("space"),M=Cr("translate"),I=()=>["auto","contain","none"],x=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto",Tn,t],R=()=>[Tn,t],P=()=>["",Ki,Ws],D=()=>["auto",Zc,Tn],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",Tn],L=()=>["auto","avoid","all","avoid-page","page","left","right","column"],H=()=>[Zc,Tn];return{cacheSize:500,separator:":",theme:{colors:[Tf],spacing:[Ki,Ws],blur:["none","",qs,Tn],brightness:H(),borderColor:[e],borderRadius:["none","","full",qs,Tn],borderSpacing:R(),borderWidth:P(),contrast:H(),grayscale:E(),hueRotate:H(),invert:E(),gap:R(),gradientColorStops:[e],gradientColorStopPositions:[S_,Ws],inset:T(),margin:T(),opacity:H(),padding:R(),saturate:H(),scale:H(),sepia:E(),skew:H(),space:R(),translate:R()},classGroups:{aspect:[{aspect:["auto","square","video",Tn]}],container:["container"],columns:[{columns:[qs]}],"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(),Tn]}],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",kf,Tn]}],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",Tn]}],grow:[{grow:E()}],shrink:[{shrink:E()}],order:[{order:["first","last","none",kf,Tn]}],"grid-cols":[{"grid-cols":[Tf]}],"col-start-end":[{col:["auto",{span:["full",kf,Tn]},Tn]}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":[Tf]}],"row-start-end":[{row:["auto",{span:[kf,Tn]},Tn]}],"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",Tn]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Tn]}],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",Tn,t]}],"min-w":[{"min-w":[Tn,t,"min","max","fit"]}],"max-w":[{"max-w":[Tn,t,"none","full","min","max","fit","prose",{screen:[qs]},qs]}],h:[{h:[Tn,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Tn,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Tn,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Tn,t,"auto","min","max","fit"]}],"font-size":[{text:["base",qs,Ws]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Zb]}],"font-family":[{font:[Tf]}],"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",Tn]}],"line-clamp":[{"line-clamp":["none",Zc,Zb]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ki,Tn]}],"list-image":[{"list-image":["none",Tn]}],"list-style-type":[{list:["none","disc","decimal",Tn]}],"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",Ki,Ws]}],"underline-offset":[{"underline-offset":["auto",Ki,Tn]}],"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",Tn]}],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",Tn]}],"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(),T_]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",k_]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},M_]}],"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":[Ki,Tn]}],"outline-w":[{outline:[Ki,Ws]}],"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":[Ki,Ws]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",qs,L_]}],"shadow-color":[{shadow:[Tf]}],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",qs,Tn]}],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",Tn]}],duration:[{duration:H()}],ease:[{ease:["linear","in","out","in-out",Tn]}],delay:[{delay:H()}],animate:[{animate:["none","spin","ping","pulse","bounce",Tn]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[kf,Tn]}],"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",Tn]}],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",Tn]}],"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",Tn]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Ki,Ws,Zb]}],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 SC=p_(A_);function ne(...e){return SC(Op(e))}var Bt=require("react/jsx-runtime");function Jc({children:e}){return(0,Bt.jsx)("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 If(){return(0,Bt.jsx)("div",{className:" mx-2 h-px bg-white/6"})}function ci({icon:e,children:t,shortcut:n,onClick:r,destructive:o=!1}){return(0,Bt.jsxs)("button",{onClick:r,className:ne("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&&(0,Bt.jsx)("span",{className:ne("shrink-0",o?"text-red-400/50":"text-white/30"),children:e}),(0,Bt.jsx)("span",{className:"flex-1",children:t}),n&&(0,Bt.jsx)("span",{className:"text-[10px] text-white/25 ml-auto pl-3",children:n})]})}function B_(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:(0,Bt.jsx)(oi,{size:15})}),o.push({side:"short",type:"market",label:"Sell 1.00 Market",icon:(0,Bt.jsx)(or,{size:15})})),i&&(o.push({side:"short",type:"limit",limitPrice:e,label:`Sell 1.00 @${e} Limit`,icon:(0,Bt.jsx)(or,{size:15})}),o.push({side:"long",type:"stop",stopPrice:e,label:`Buy 1.00 @${e} Stop`,icon:(0,Bt.jsx)(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:(0,Bt.jsx)(Yd,{size:15})})),s&&(o.push({side:"long",type:"limit",limitPrice:e,label:`Buy 1.00 @${e} Limit`,icon:(0,Bt.jsx)(oi,{size:15})}),o.push({side:"short",type:"stop",stopPrice:e,label:`Sell 1.00 @${e} Stop`,icon:(0,Bt.jsx)(or,{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:(0,Bt.jsx)(jd,{size:15})})),o}function CC({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=(0,Us.useRef)(null),[w,k]=(0,Us.useState)(1920),[M,I]=(0,Us.useState)(1080);(0,Us.useEffect)(()=>{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]),(0,Us.useEffect)(()=>{window&&(k(window.innerWidth),I(window.innerHeight))},[]);let x=B_(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(0,Bt.jsx)("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:(0,Bt.jsx)("div",{className:"p-1.5",children:n==="chart"?(0,Bt.jsxs)(Bt.Fragment,{children:[(0,Bt.jsx)(Jc,{children:"View"}),(0,Bt.jsx)(ci,{icon:(0,Bt.jsx)(ha,{size:12}),shortcut:"\u23180",onClick:()=>{m(),d()},children:"Reset view"}),(0,Bt.jsx)(ci,{icon:(0,Bt.jsx)(Od,{size:12}),onClick:()=>{f(),d()},children:"Fit Y axis"}),(0,Bt.jsx)(If,{}),(0,Bt.jsx)(Jc,{children:"Trade"}),x.map((P,D)=>(0,Bt.jsx)(ci,{onClick:()=>{S({qty:1,...P}),d()},children:(0,Bt.jsxs)("div",{className:"flex flex-row items-center gap-1",children:[P?.icon&&P.icon,P.label]})},D)),r!==null&&(0,Bt.jsxs)(Bt.Fragment,{children:[(0,Bt.jsx)(If,{}),(0,Bt.jsx)(Jc,{children:"Price"}),(0,Bt.jsxs)(ci,{icon:(0,Bt.jsx)(Pl,{size:12}),onClick:()=>{navigator.clipboard.writeText(r.toFixed(2)),d()},children:["Copy"," ",(0,Bt.jsx)("span",{className:"text-slate-200 tabular-nums ml-1",children:r.toFixed(2)})]})]}),i.length>0&&(0,Bt.jsxs)(Bt.Fragment,{children:[(0,Bt.jsx)(If,{}),(0,Bt.jsx)(Jc,{children:"Indicators"}),(0,Bt.jsxs)(ci,{icon:(0,Bt.jsx)(Mo,{size:12}),destructive:!0,onClick:()=>{p(),d()},children:["Remove ",i.length," ",i.length===1?"indicator":"indicators"]})]}),s.length>0&&(0,Bt.jsxs)(Bt.Fragment,{children:[(0,Bt.jsx)(If,{}),(0,Bt.jsx)(Jc,{children:"Drawings"}),(0,Bt.jsxs)(ci,{icon:(0,Bt.jsx)(Mo,{size:12}),destructive:!0,onClick:()=>{g(),d()},children:["Remove ",s.length," ",s.length===1?"drawing":"drawings"]})]}),(0,Bt.jsx)(If,{}),(0,Bt.jsx)(ci,{icon:(0,Bt.jsx)(Wd,{size:12}),onClick:()=>{y(),d()},children:"Screenshot"}),c==="l3"&&(0,Bt.jsxs)(ci,{icon:(0,Bt.jsx)(si,{size:12}),onClick:()=>{v(),d()},children:[l.showHeatmap?"Hide ":"Show ","Heatmap"]}),(0,Bt.jsx)(ci,{icon:(0,Bt.jsx)(Nl,{size:12}),onClick:()=>{b(),d()},children:"Settings"})]}):(0,Bt.jsxs)(Bt.Fragment,{children:[(0,Bt.jsx)(Jc,{children:"Time axis"}),(0,Bt.jsx)(ci,{icon:(0,Bt.jsx)(Ad,{size:12}),onClick:()=>{h(),d()},children:"Reset time axis"}),(0,Bt.jsx)(ci,{icon:(0,Bt.jsx)(ha,{size:12}),onClick:()=>{m(),d()},children:"Reset view"})]})})})}var N_=6,kC=.05;function $i(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 Jb(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)<=N_/2)return r}return-1}function eu(e,t,n){return t.find(r=>{let o=n[r.id];return e>=o.y&&e<o.y+o.h})??null}var Mf=class{constructor(){se(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)}},bo=new Mf;var ry=30,E_=5,O_=5,__="rgba(255,255,255,0.18)";function ui(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 yo(e,t,n,r){e.strokeStyle=t,e.lineWidth=n,e.setLineDash(r??[])}function tu(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 ey(e){return`#${e.replace("#","").slice(0,6)}`}function ty(e,t=1){let n=e.replace("#","");return n.length===8?parseInt(n.slice(6,8),16)/255:t}function F_(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 z_=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()},H_=(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()},V_=(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()},W_=(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()},q_=(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 U_(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:z_(f),text:`${h}${Math.abs(d).toFixed(2)}`,color:g},{icon:H_,text:`${h}${Math.abs(m).toFixed(2)}%`,color:g},{icon:V_,text:F_(t.b.ts-t.a.ts),color:y},{icon:W_,text:`${p.toFixed(1)}\xB0`,color:y},{icon:q_,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(H=>e.measureText(H.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((H,K)=>{let G=B+C+w*K+w/2;H.icon(e,E,G,k,H.color),e.fillStyle=H.color,e.fillText(H.text,L,G)}),e.restore()}function DC(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 wn(e,t,n,r,o=!1){let a=o?O_:E_;e.beginPath(),e.arc(t,n,a+2,0,Math.PI*2),e.fillStyle=__,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 oy(e){let t=e.labelItalic?"italic ":"",n=e.labelBold?"700 ":"400 ",r=e.labelFontSize??11;return`${t}${n}${r}px "Inter", monospace`}function ay(e,t,n,r,o,a,i){if(!t.label)return;let s=oy(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;yo(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 j_(e,t,n,r,o,a,i){if(!t.label)return;e.font=oy(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;yo(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;yo(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 Fl(e,t,n,r,o,a,i,s,l,c,u,d,m,f){if(!t.label)return;e.font=oy(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=(W,$)=>(W-w)*P+($-k)*D,E=u??o,L=d??a,H=m??i,K=f??s,G=B(E,L),V=B(H,K),q=Math.min(G,V),j=Math.max(G,V);if(yo(e,n,l,c),A){let W,$;M==="center"?(W=x-T/2-g,$=x+T/2+g):M==="left"?(W=x-g,$=x+T+g):(W=x-T-g,$=x+g),q<W&&(e.beginPath(),e.moveTo(w+P*q,k+D*q),e.lineTo(w+P*W,k+D*W),e.stroke()),j>$&&(e.beginPath(),e.moveTo(w+P*$,k+D*$),e.lineTo(w+P*j,k+D*j),e.stroke())}else e.beginPath(),e.moveTo(w+P*q,k+D*q),e.lineTo(w+P*j,k+D*j),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 G_(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?ay(e,t,t.color,u,r,t.lineWidth,t.dash):(yo(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(0,u),e.lineTo(r,u),e.stroke()),(i||s)&&wn(e,r/2,u,t.color,l==="body"))}function Y_(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?j_(e,t,t.color,c,o,t.lineWidth,t.dash):(yo(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(c,0),e.lineTo(c,o),e.stroke()),(a||i)&&wn(e,c,o/2,t.color,s==="body"))}function K_(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?Fl(e,t,t.color,"line",u,d,m,f,t.lineWidth,t.dash,h,p,g,y):(yo(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),(i||s)&&(wn(e,u,d,t.color,l==="a"),wn(e,m,f,t.color,l==="b"))}function $_(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?Fl(e,t,t.color,"line",u,d,m,f,t.lineWidth,t.dash,h,p,g,y):(yo(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),(i||s)&&(wn(e,u,d,t.color,l==="a"),wn(e,m,f,t.color,l==="b"))}function X_(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?ay(e,t,t.color,u,r,t.lineWidth,t.dash):(yo(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)&&wn(e,d,u,t.color,l==="body"))}function Z_(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?Fl(e,t,t.color,"line",u,d,m,f,t.lineWidth,t.dash,h,p,g,y):(yo(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),U_(e,t,n,r,o,a,c),(i||s)&&(wn(e,u,d,t.color,l==="a"),wn(e,m,f,t.color,l==="b"))}function Q_(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?Fl(e,t,t.color,"line",u,d,m,f,t.lineWidth,t.dash,h,p,g,y):(yo(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(h,p),e.lineTo(g,y),e.stroke()),DC(e,t,n,r,o,a,c),(i||s)&&(wn(e,u,d,t.color,l==="a"),wn(e,m,f,t.color,l==="b"))}function J_(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?Fl(e,t,t.color,"line",u,d,m,f,t.lineWidth,t.dash,u,d,b,S):(yo(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(u,d),e.lineTo(b,S),e.stroke()),(i||s)&&(wn(e,u,d,t.color,l==="a"),wn(e,m,f,t.color,l==="b"))}function eF(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?ay(e,t,t.color,u,r,t.lineWidth,t.dash):(yo(e,t.color,t.lineWidth,t.dash),e.beginPath(),e.moveTo(d,u),e.lineTo(r,u),e.stroke()),(i||s)&&wn(e,d,u,t.color,l==="body")}function TC(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??xl){if(!b.enabled)continue;let[S,C,w,k]=v(Number(b.value));yo(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??xl)[0]?.color??"#3377ff",S=(u+m)/2;wn(e,u,d,b,l==="a"),wn(e,m,f,b,l==="b"),wn(e,S,(d+f)/2,b,l==="mt"),wn(e,u,h,b,l==="a2"),wn(e,m,p,b,l==="a3"),wn(e,S,(h+p)/2,b,l==="mb")}}function tF(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=tu(v,t.fillOpacity),e.fillRect(h,p,g,y),yo(e,b,S,C),e.strokeRect(h+.5,p+.5,g-1,y-1),Fl(e,t,b,"rect",u,d,m,f),i||s){let w=t.borderColor??t.color;wn(e,h,p,w,l==="tl"),wn(e,h+g,p,w,l==="tr"),wn(e,h,p+y,w,l==="bl"),wn(e,h+g,p+y,w,l==="br"),wn(e,h+g/2,p,w,l==="mt"),wn(e,h+g/2,p+y,w,l==="mb"),wn(e,h,p+y/2,w,l==="ml"),wn(e,h+g,p+y/2,w,l==="mr")}}function nF(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=tu(y,t.fillOpacity),e.fill(),yo(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(Fl(e,t,v,"rect",C,k,w,M),i||s){let I=v;wn(e,u,d,I,l==="a"),wn(e,m,f,I,l==="b"),wn(e,h,p,I,l==="c")}}function rF(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,H=C;t.extendLeft&&(L=N&&p==="left"?O+A*2:0),t.extendRight&&(H=r),yo(e,D,E,B),e.beginPath(),e.moveTo(L,P),e.lineTo(H,P),e.stroke(),N&&(e.fillStyle=D,p==="right"?e.fillText(N,H+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)&&(wn(e,w,k,"#3d81f6",l==="a"),wn(e,M,I,"#3d81f6",l==="b"))}function oF(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)&&wn(e,u,d,t.color,l==="anchor")}var IC=.11,aF="rgba(11,14,20,1)";function iF(e,t,n,r){return{price:Fr(e,r),ticks:`${Math.round(e/n)}T`,pct:t!==0?`${(e/Math.abs(t)*100).toFixed(2)}%`:""}}var MC="Inter, system-ui, sans-serif";function AC(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 sF(e,t,n,r,o,a,i,s,l,c){let u=t.tool==="long",d=po(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}=AC(t,d),C=l.priceToY(b,r)+o,w=l.priceToY(g,r)+o,k=l.priceToY(S,r)+o,M=ey(t.upColor),I=ey(t.downColor),x=ey(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=tu(t.upColor,IC),e.fillRect(h,C,p,w-C),e.fillStyle=tu(t.downColor,IC),e.fillRect(h,w,p,k-w),((D,N,O,A)=>{yo(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)=>ny(e,A,h+p/2,B,E,L,D,"center",7,4,MC);e.font=`${D}px ${MC}`;let O=(A,B)=>{if(B.amount<=0)return;let E=iF(B.amount,g,d,c),L=Fr(B.price,c),H=`${A} ${L} ${E.price} \xB7 ${E.ticks} \xB7 ${E.pct}`;H&&N(H,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} @ ${Fr(g,c)} R:R ${A.toFixed(2)}`;E&&N(E,w-D-4,t.textColor??"#ffffff",aF)}}(a||i)&&(wn(e,h,C,M,s==="mt"),wn(e,h,k,I,s==="mb"),wn(e,h,w,x,s==="ml"),wn(e,h+p,w,x,s==="mr"))}var LC=1,RC=3;function js(e,t,n,r){let o=n-t;return o===0?r/2:r-(e-t)/o*r}function PC(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 lF(e,t,n,r,o,a,i,s){let l=e.length;if(l===0)return[];let c=Math.abs(js(0,o,a,i)-js(s,o,a,i)),u=c<RC?Math.ceil(RC/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 ny(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 cF(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)&&(wn(e,p,g+v/2,"#6490c8",l==="ml"),wn(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=lF(S,C,w,k,I,x,v,u),E=B.length;if(E===0)return;let L=0;for(let Ie=0;Ie<E;Ie++)B[Ie].totalVol>L&&(L=B[Ie].totalVol);if(L===0)return;let H=S.length,{loIdx:K,hiIdx:G}=t.showValueArea||t.showVaHLines||P?PC(k,M,S,t.valueAreaPct??70):{loIdx:0,hiIdx:H-1},V=S[K],q=S[G],j=(t.barOpacity??60)/100,W=t.enableBuyColor?t.buyColor??"#00e676":"#00e676",$=t.enableSellColor?t.sellColor??"#ff1744":"#ff1744",J=t.totalColor??"#5b9cf6",me=t.deltaNegColor??"#ff1744",We=t.profileMode??"stacked",Ce=(t.barsWidth??100)/100,Ee=t.pocColor??"#facc15",ze="rgba(18,20,26,0.88)";if(e.save(),e.beginPath(),e.rect(p,g,y,v),e.clip(),t.showValueArea&&L>0){let Ie=g+js(q,I,x,v),ee=g+js(V,I,x,v);e.fillStyle=t.valueAreaFillColor??"#ffffff1a",e.fillRect(p,Ie,y,ee-Ie)}for(let Ie=0;Ie<E;Ie++){let ee=B[Ie];if(ee.priceHi<I-u||ee.priceLo>x+u)continue;let Be=g+js(ee.priceHi,I,x,v),le=g+js(ee.priceLo,I,x,v)-Be,ce=Math.max(LC,le-(A&&le>3?1:0)),ke=Be,De=ee.priceCenter>=V&&ee.priceCenter<=q,ve=Math.abs(ee.priceCenter-M)<u*1.5,Qe=P&&!De?j*D:j;e.globalAlpha=Qe;let Ye=ee.buyVol,$e=ee.sellVol,bt=ee.totalVol;if(We==="stacked"){let Oe=bt/L*y*Ce,Tt=Oe*(bt>0?$e/bt:0),bn=Oe-Tt;e.fillStyle=$,e.fillRect(p,ke,Tt,ce),e.fillStyle=W,e.fillRect(p+Tt,ke,bn,ce)}else if(We==="split"){let Oe=y/2*Ce,Tt=Ye/L*Oe,bn=$e/L*Oe,En=p+y/2;e.fillStyle=W,e.fillRect(En,ke,Tt,ce),e.fillStyle=$,e.fillRect(En-bn,ke,bn,ce)}else if(We==="delta"){let Oe=Ye-$e,Tt=Math.abs(Oe)/L*y*Ce;e.fillStyle=Oe>=0?J:me,e.fillRect(p,ke,Tt,ce)}else{let Oe=bt/L*y*Ce;e.fillStyle=J,e.fillRect(p,ke,Oe,ce)}if(T&&ve){if(e.globalAlpha=Math.min(1,Qe*1.5),We==="stacked"){let Tt=bt/L*y*Ce,bn=Tt*(bt>0?$e/bt:0),En=Tt-bn;e.fillStyle=$,e.fillRect(p,ke,bn,ce),e.fillStyle=W,e.fillRect(p+bn,ke,En,ce)}else if(We==="split"){let Tt=y/2*Ce,bn=p+y/2;e.fillStyle=W,e.fillRect(bn,ke,Ye/L*Tt,ce),e.fillStyle=$,e.fillRect(bn-$e/L*Tt,ke,$e/L*Tt,ce)}else if(We==="delta"){let Tt=Ye-$e;e.fillStyle=Tt>=0?J:me,e.fillRect(p,ke,Math.abs(Tt)/L*y*Ce,ce)}else e.fillStyle=J,e.fillRect(p,ke,bt/L*y*Ce,ce);e.globalAlpha=ty(Ee),e.strokeStyle=Ee,e.lineWidth=R,e.setLineDash([]);let Oe=ke+ce/2;e.beginPath(),e.moveTo(p,Oe),e.lineTo(p+y,Oe),e.stroke()}}if(e.globalAlpha=1,We==="split"&&O){let Ie=p+y/2;e.strokeStyle="rgba(255,255,255,0.12)",e.lineWidth=1,e.setLineDash([]),e.beginPath(),e.moveTo(Ie,g),e.lineTo(Ie,g+v),e.stroke()}if(t.showVolNumbers&&L>0){let Ie=t.volNumbersFontSize??9;e.font=`${Ie}px monospace`,e.textBaseline="middle",e.globalAlpha=.85;for(let ee=0;ee<E;ee++){let Be=B[ee];if(Be.priceHi<I-u||Be.priceLo>x+u)continue;let F=g+js(Be.priceHi,I,x,v),le=g+js(Be.priceLo,I,x,v);if(Math.max(LC,le-F)<Ie+2)continue;let ke=F+(le-F)/2,De=Be.buyVol,ve=Be.sellVol,Qe=Be.totalVol;if(We==="delta"){let Ye=De-ve,$e=Math.abs(Ye)/L*y*Ce,bt=Ye>0?`+${Math.round(Ye)}`:String(Math.round(Ye)),Oe=e.measureText(bt).width+6<$e;e.fillStyle=Ye>=0?J:me,Oe?(e.textAlign="right",e.fillText(bt,p+$e-3,ke)):(e.textAlign="left",e.fillText(bt,p+$e+3,ke))}else if(We==="split"){let Ye=y/2*Ce,$e=De/L*Ye,bt=ve/L*Ye,Oe=p+y/2,Tt=String(Math.round(De)),bn=String(Math.round(ve));e.fillStyle=W,e.textAlign=$e>e.measureText(Tt).width+6?"right":"left",e.fillText(Tt,$e>e.measureText(Tt).width+6?Oe+$e-3:Oe+$e+3,ke),e.fillStyle=$,e.textAlign=bt>e.measureText(bn).width+6?"left":"right",e.fillText(bn,bt>e.measureText(bn).width+6?Oe-bt+3:Oe-bt-3,ke)}else{let Ye=We==="total"?String(Math.round(Qe)):`${Math.round(De)}\xD7${Math.round(ve)}`,$e=Qe/L*y*Ce,Oe=e.measureText(Ye).width+6<$e;e.fillStyle="rgba(255,255,255,0.80)",Oe?(e.textAlign="right",e.fillText(Ye,p+$e-3,ke)):(e.textAlign="left",e.fillText(Ye,p+$e+3,ke))}}e.globalAlpha=1}if(e.restore(),t.showPoc&&!isNaN(M)&&M>=I&&M<=x){let Ie=Math.round(c.priceToY(M,o))+a+.5,ee=t.pocExtendLeft?0:p,Be=t.pocExtendRight?r:p+y;if(e.strokeStyle=Ee,e.lineWidth=1,e.setLineDash([4,3]),e.beginPath(),e.moveTo(ee,Ie),e.lineTo(Be,Ie),e.stroke(),e.setLineDash([]),t.showPocLabel){let F=`POC ${M.toFixed(2)}`,le=Be-4;N?ny(e,F,le,Ie-9,tu(Ee,Math.max(ty(Ee),.85)),ze,9,"right"):(e.font="9px monospace",e.textBaseline="middle",e.fillStyle=Ee,e.textAlign="right",e.fillText(F,le,Ie-7))}}if(t.showVaHLines&&L>0){let Ie=t.vaLineColor??"#888888",ee=t.vaLineExtendLeft?0:p,Be=t.vaLineExtendRight?r:p+y;e.strokeStyle=Ie,e.lineWidth=1,e.setLineDash([4,3]);for(let[F,le]of[[q,"VAH"],[V,"VAL"]]){if(F<I||F>x)continue;let ce=Math.round(c.priceToY(F,o))+a+.5;e.beginPath(),e.moveTo(ee,ce),e.lineTo(Be,ce),e.stroke(),e.setLineDash([]);let ke=`${le} ${F.toFixed(2)}`,De=Be-4,ve=ce-9;N?ny(e,ke,De,ve,tu(t.vaLineColor??"#888888",Math.max(ty(Ie),.85)),ze,9,"right"):(e.font="9px monospace",e.textBaseline="middle",e.fillStyle=Ie,e.textAlign="right",e.fillText(ke,De,ve)),e.setLineDash([4,3])}e.setLineDash([])}if(t.showDevPoc&&H>0&&L>0){e.strokeStyle=t.devPocColor??"#facc15",e.lineWidth=1.5,e.setLineDash([2,3]),e.beginPath();let Ie=Math.min(H,60),ee=t.a.ts<t.b.ts?t.a.ts:t.b.ts,Be=t.a.ts<t.b.ts?t.b.ts:t.a.ts,F=g+v/2;for(let le=1;le<=Ie;le++){let ce=le/Ie,ke=ee+BigInt(Math.round(Number(Be-ee)*ce)),De=c.tsToX(ke,r),ve=-1,Qe=M;for(let $e=0;$e<H;$e++){let bt=k[$e]*ce;bt>ve&&(ve=bt,Qe=S[$e])}let Ye=c.priceToY(Qe,o)+a;le===1?e.moveTo(De,Ye):(e.lineTo(De,F),e.lineTo(De,Ye)),F=Ye}e.stroke(),e.setLineDash([])}if(t.showDevVa&&H>0&&L>0){e.strokeStyle=t.devVaColor??"#888888",e.lineWidth=1.5,e.setLineDash([2,4]);let Ie=Math.min(H,60),ee=t.a.ts<t.b.ts?t.a.ts:t.b.ts,Be=t.a.ts<t.b.ts?t.b.ts:t.a.ts,F=[],le=[];for(let ce=1;ce<=Ie;ce++){let ke=ce/Ie,De=ee+BigInt(Math.round(Number(Be-ee)*ke)),ve=c.tsToX(De,r),Qe=new Float64Array(k.map(bt=>bt*ke)),{loIdx:Ye,hiIdx:$e}=PC(Qe,M,S,t.valueAreaPct??70);F.push([ve,c.priceToY(S[$e],o)+a]),le.push([ve,c.priceToY(S[Ye],o)+a])}for(let ce of[F,le]){e.beginPath();for(let ke=0;ke<ce.length;ke++){let[De,ve]=ce[ke];if(ke===0)e.moveTo(De,ve);else{let[,Qe]=ce[ke-1];e.lineTo(De,Qe),e.lineTo(De,ve)}}e.stroke()}e.setLineDash([])}if(i||s){let Ie="#6490c8";wn(e,p,g,Ie,l==="tl"),wn(e,p+y,g+v,Ie,l==="br")}}function BC(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=$n();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:ry),P=$i(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,H=E||L?i:null,K=bo.get(B.tool);if(K){let G=B;w.save(),w.beginPath(),w.rect(0,N,x,D),w.clip();try{K.render({ctx:w,anchors:G.anchors,w:x,h:D,oy:N,transformer:g,selected:E,hovered:L,hotAnchor:H,data:G.data})}catch(V){console.error(`[DrawingRegistry] render error for '${G.tool}':`,V)}w.restore();continue}if(!("anchors"in B)){switch(w.save(),B.tool){case"vline":w.beginPath(),w.rect(0,0,x,T),w.clip(),Y_(w,B,n,x,T,E,L,H,g);break;case"hline":w.beginPath(),w.rect(0,N,x,D),w.clip(),G_(w,B,n,x,D,N,E,L,H,g);break;case"extended-line":w.beginPath(),w.rect(0,N,x,D),w.clip(),K_(w,B,n,x,D,N,E,L,H,g);break;case"line":w.beginPath(),w.rect(0,N,x,D),w.clip(),$_(w,B,n,x,D,N,E,L,H,g);break;case"cross-line":w.beginPath(),w.rect(0,N,x,D),w.clip(),X_(w,B,n,x,D,N,E,L,H,g);break;case"info-line":w.beginPath(),w.rect(0,N,x,D),w.clip(),Z_(w,B,n,x,D,N,E,L,H,g);break;case"trend-angle":w.beginPath(),w.rect(0,N,x,D),w.clip(),Q_(w,B,n,x,D,N,E,L,H,g);break;case"ray":w.beginPath(),w.rect(0,N,x,D),w.clip(),J_(w,B,n,x,D,N,E,L,H,g);break;case"hray":w.beginPath(),w.rect(0,N,x,D),w.clip(),eF(w,B,n,x,D,N,E,L,H,g);break;case"parallel-channel":w.beginPath(),w.rect(0,N,x,D),w.clip(),TC(w,B,n,x,D,N,E,L,H,g);break;case"rect":w.beginPath(),w.rect(0,N,x,D),w.clip(),tF(w,B,n,x,D,N,E,L,H,g);break;case"triangle":w.beginPath(),w.rect(0,N,x,D),w.clip(),nF(w,B,n,x,D,N,E,L,H,g);break;case"fib":w.beginPath(),w.rect(0,N,x,D),w.clip(),rF(w,B,n,x,D,N,E,L,H,g);break;case"text":w.beginPath(),w.rect(0,N,x,D),w.clip(),oF(w,B,n,x,D,N,E,L,H,g);break;case"fvp":w.beginPath(),w.rect(0,N,x,D),w.clip(),cF(w,B,n,x,D,N,E,L,H,g,po(S));break;case"long":case"short":w.beginPath(),w.rect(0,N,x,D),w.clip(),sF(w,B,x,D,N,E,L,H,g,S);break}w.restore()}}if(s&&O!==void 0&&A!==void 0){if(w.save(),s&&"pluginToolId"in s){let B=s,E=bo.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=Td(A,m,g.getSessionMapper()),H=g.tsToX(L,x),K=g.priceToY(O,D)+N;if(d)K=E;else if(u){let V=Id(L,O,f,h,p,[],"l3",C);K=g.priceToY(V,D)+N}let G=K;if(w.strokeStyle="#e0e0e0",w.lineWidth=1,w.beginPath(),s.tool==="ray"){let V=H>=B,[q,j,W,$]=Aa(B,E,H,G,x,!V,V),J=V?W:q,me=V?$:j;w.moveTo(B,E),w.lineTo(J,me)}else if(s.tool==="extended-line"){let[V,q,j,W]=Aa(B,E,H,G,x,!0,!0);w.moveTo(V,q),w.lineTo(j,W)}else s.tool==="trend-angle"?(DC(w,{...s,b:{ts:L,price:O}},n,x,D,N,g),w.moveTo(B,E),w.lineTo(H,G)):(w.moveTo(B,E),w.lineTo(H,G));w.stroke();break}case"parallel-channel":{let B=g.tsToX(s.a.ts,x),E=g.priceToY(s.a.price,D)+N,L=Td(A,m,g.getSessionMapper()),H=g.tsToX(L,x),K=g.priceToY(O,D)+N;if(d)K=E;else if(u){let V=Id(L,O,f,h,p,[],"l3",C);K=g.priceToY(V,D)+N}let G=K;w.beginPath(),s?.b?TC(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(H,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),H=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,H),Math.abs(L-B),Math.abs(H-E));else{w.strokeStyle="#facc15",w.lineWidth=1;for(let K of ab){let G=s.a.price-s.b.price,V=s.b.price+G*parseFloat(K.value),q=g.priceToY(V,D)+N;w.beginPath(),w.moveTo(g.tsToX(s.a.ts,x),q),w.lineTo(g.tsToX(s.b.ts,x),q),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=Td(A,m,g.getSessionMapper()),H=g.tsToX(L,x),K=g.priceToY(O,D)+N;if(d)K=E;else if(u){let V=Id(L,O,f,h,p,[],"l3",C);K=g.priceToY(V,D)+N}let G=K;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(H,G),w.closePath()):w.lineTo(H,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),H=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,H),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 Lf(e,t,n,r,o,a,i,s,l,c,u){let d=Jx,m=a-c,f=i-(l?0:ry),p=$i(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=bo.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(ui(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(ui(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(ui(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??xl){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(ui(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(ui(e,t,I,x,I+T,x)<=d||ui(e,t,I+T,x,I+T,x+R)<=d||ui(e,t,I+T,x+R,I,x+R)<=d||ui(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(ui(e,t,C,w,k,M)<=d||ui(e,t,k,M,I,x)<=d||ui(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}=AC(b,po(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 NC(e,t,n,r,o,a,i,s){let l=$n(),c=r/l,u=o/l,d=c-s,m=u-(i?0:ry),h=$i(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 EC(e,t,n,r,o,a,i){let s=(l,c=t)=>({drawing:l,anchor:c});if("anchors"in e){let l=e,c=bo.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)}}}var Xr=require("react");var sr=require("react");var sk=Ct(require("react"));var ro=Ct(require("react"),1);var uF=Object.defineProperty,nu=(e,t)=>uF(e,"name",{value:t,configurable:!0}),OC=!!(typeof window<"u"&&window.document&&window.document.createElement);function lt(e,t,{checkForDefaultPrevented:n=!0}={}){return nu(function(o){if(e?.(o),n===!1||!o||!o.defaultPrevented)return t?.(o)},"handleEvent")}nu(lt,"composeEventHandlers");function dF(e){if(!OC)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}nu(dF,"getOwnerWindow");function iy(e){if(!OC)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}nu(iy,"getOwnerDocument");function _C(e,t=!1){let{activeElement:n}=iy(e);if(!n?.nodeName)return null;if(FC(n)&&n.contentDocument)return _C(n.contentDocument.body,t);if(t){let r=n.getAttribute("aria-activedescendant");if(r){let o=iy(n).getElementById(r);if(o)return o}}return n}nu(_C,"getActiveElement");function FC(e){return e.tagName==="IFRAME"}nu(FC,"isFrame");var zC=Ct(require("react"),1),fF=Object.defineProperty,ly=(e,t)=>fF(e,"name",{value:t,configurable:!0});function sy(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}ly(sy,"setRef");function HC(...e){return t=>{let n=!1,r=e.map(o=>{let a=sy(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():sy(e[o],null)}}}}ly(HC,"composeRefs");function nn(...e){return zC.useCallback(HC(...e),e)}ly(nn,"useComposedRefs");var Na=Ct(require("react"),1),cy=require("react/jsx-runtime"),mF=Object.defineProperty,Ba=(e,t)=>mF(e,"name",{value:t,configurable:!0});function pF(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(0,cy.jsx)(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(pF,"createContext");function kr(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(0,cy.jsx)(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,VC(o,...t)]}Ba(kr,"createContextScope");function VC(...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(VC,"composeContextScopes");var Ea=Ct(require("react"),1);var _p=!1;var WC=Ct(require("react"),1),$r=globalThis?.document?WC.useLayoutEffect:()=>{};var di=Ct(require("react"),1);var ru=Ct(require("react"),1),hF=Object.defineProperty,gF=(e,t)=>hF(e,"name",{value:t,configurable:!0}),qC=ru[" useEffectEvent ".trim().toString()],UC=ru[" useInsertionEffect ".trim().toString()];function uy(e){if(typeof qC=="function")return qC(e);let t=ru.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof UC=="function"?UC(()=>{t.current=e}):$r(()=>{t.current=e}),ru.useMemo(()=>((...n)=>t.current?.(...n)),[])}gF(uy,"useEffectEvent");var bF=Object.defineProperty,Rf=(e,t)=>bF(e,"name",{value:t,configurable:!0}),yF=Ea[" useInsertionEffect ".trim().toString()]||$r;function Lo({prop:e,defaultProp:t,onChange:n=Rf(()=>{},"onChange"),caller:r}){let[o,a,i]=GC({defaultProp:t,onChange:n}),s=e!==void 0,l=s?e:o;if(_p){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=YC(u)?u(e):u;d!==e&&i.current?.(d)}else a(u)},[s,e,a,i]);return[l,c]}Rf(Lo,"useControllableState");function GC({defaultProp:e,onChange:t}){let[n,r]=Ea.useState(e),o=Ea.useRef(n),a=Ea.useRef(t);return yF(()=>{a.current=t},[t]),Ea.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,r,a]}Rf(GC,"useUncontrolledState");function YC(e){return typeof e=="function"}Rf(YC,"isFunction");var jC=Symbol("RADIX:SYNC_STATE");function vF(e,t,n,r){let{prop:o,defaultProp:a,onChange:i,caller:s}=t,l=o!==void 0,c=uy(i);if(_p){let g=di.useRef(o!==void 0);di.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]=di.useReducer((g,y)=>{if(y.type===jC)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=di.useRef(f);di.useEffect(()=>{h.current!==f&&(h.current=f,l||c(f))},[f,h,l]);let p=di.useMemo(()=>o!==void 0?{...d,state:o}:d,[d,o]);return di.useEffect(()=>{l&&!Object.is(o,d.state)&&m({type:jC,state:o})},[o,d.state,l]),[p,m]}Rf(vF,"useControllableStateReducer");var KC=Ct(require("react"),1);var wF=Object.defineProperty,xF=(e,t)=>wF(e,"name",{value:t,configurable:!0});function Xi(e){let[t,n]=KC.useState(void 0);return $r(()=>{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}xF(Xi,"useSize");var tk=Ct(require("react"),1),nk=Ct(require("react-dom"),1);var Ro=Ct(require("react"),1);var SF=Object.defineProperty,fi=(e,t)=>SF(e,"name",{value:t,configurable:!0});function ta(e){let t=Ro.forwardRef((n,r)=>{let{children:o,...a}=n,i=null,s=!1,l=[];dy(o)&&typeof Fp=="function"&&(o=Fp(o._payload)),Ro.Children.forEach(o,m=>{if(JC(m)){s=!0;let f=m,h="child"in f.props?f.props.child:f.props.children;dy(h)&&typeof Fp=="function"&&(h=Fp(h._payload)),i=CF(f,h),l.push(i?.props?.children)}else l.push(m)}),i?i=Ro.cloneElement(i,void 0,l):!s&&Ro.Children.count(o)===1&&Ro.isValidElement(o)&&(i=o);let c=i?QC(i):void 0,u=nn(r,c);if(!i){if(o||o===0)throw new Error(s?IF(e):TF(e));return o}let d=ZC(a,i.props??{});return i.type!==Ro.Fragment&&(d.ref=r?u:c),Ro.cloneElement(i,d)});return t.displayName=`${e}.Slot`,t}fi(ta,"createSlot");var $C=ta("Slot"),XC=Symbol.for("radix.slottable");function fy(e){let t=fi(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=XC,t}fi(fy,"createSlottable");var CF=fi((e,t)=>{if("child"in e.props){let n=e.props.child;return Ro.isValidElement(n)?Ro.cloneElement(n,void 0,e.props.children(n.props.children)):null}return Ro.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function ZC(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}}fi(ZC,"mergeProps");function QC(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)}fi(QC,"getElementRef");function JC(e){return Ro.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===XC}fi(JC,"isSlottable");var kF=Symbol.for("react.lazy");function dy(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===kF&&"_payload"in e&&ek(e._payload)}fi(dy,"isLazyComponent");function ek(e){return typeof e=="object"&&e!==null&&"then"in e}fi(ek,"isPromiseLike");var TF=fi(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),IF=fi(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Fp=Ro[" use ".trim().toString()];var rk=require("react/jsx-runtime"),MF=Object.defineProperty,LF=(e,t)=>MF(e,"name",{value:t,configurable:!0}),RF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],hn=RF.reduce((e,t)=>{let n=ta(`Primitive.${t}`),r=tk.forwardRef((o,a)=>{let{asChild:i,...s}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,rk.jsx)(l,{...s,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Pf(e,t){e&&nk.flushSync(()=>e.dispatchEvent(t))}LF(Pf,"dispatchDiscreteCustomEvent");var Oa=require("react/jsx-runtime"),PF=Object.defineProperty,Gs=(e,t)=>PF(e,"name",{value:t,configurable:!0}),my="Switch",[DF,DK]=kr(my),[AF,py]=DF(my);function ok(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]=Lo({prop:n,defaultProp:o??!1,onChange:l,caller:my}),[h,p]=ro.useState(null),[g,y]=ro.useState(null),v=ro.useRef(!1),[b,S]=ro.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(0,Oa.jsx)(AF,{scope:t,...w,children:ik(d)?d(w):r})}Gs(ok,"SwitchProvider");var BF="SwitchTrigger",NF=ro.forwardRef(Gs(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}=py(BF,t),y=nn(o,d),v=ro.useRef(c);return ro.useEffect(()=>{let b=i?a?.ownerDocument.getElementById(i):a?.form;if(b instanceof HTMLFormElement){let S=Gs(()=>m(v.current),"reset");return b.addEventListener("reset",S),()=>b.removeEventListener("reset",S)}},[a,i,m]),(0,Oa.jsx)(hn.button,{type:"button",role:"switch","aria-checked":c,"aria-required":u,"data-state":gy(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")),hy=ro.forwardRef(Gs(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(0,Oa.jsx)(ok,{__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})=>(0,Oa.jsxs)(Oa.Fragment,{children:[(0,Oa.jsx)(NF,{...m,ref:n,__scopeSwitch:r}),f&&(0,Oa.jsx)(_F,{__scopeSwitch:r})]})})},"Switch")),EF="SwitchThumb",ak=ro.forwardRef(Gs(function(t,n){let{__scopeSwitch:r,...o}=t,a=py(EF,r);return(0,Oa.jsx)(hn.span,{"data-state":gy(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:n})},"SwitchThumb")),OF="SwitchBubbleInput",_F=ro.forwardRef(Gs(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}=py(OF,t),y=nn(o,g),v=Xi(a),b=ro.useRef(!1),S=ro.useRef(l),C=ro.useRef(s);ro.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=ro.useRef(l);return(0,Oa.jsx)(hn.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 ik(e){return typeof e=="function"}Gs(ik,"isFunction");function gy(e){return e?"checked":"unchecked"}Gs(gy,"getState");var by=require("react/jsx-runtime"),so=sk.forwardRef(({className:e,...t},n)=>(0,by.jsx)(hy,{className:ne("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:(0,by.jsx)(ak,{className:ne("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")})}));so.displayName=hy.displayName;var zo=require("react");var Ln=Ct(require("react"),1);function Hp(){return(Hp=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 dk(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 Df(e){var t=(0,Ln.useRef)(e),n=(0,Ln.useRef)(function(r){t.current&&t.current(r)});return t.current=e,n.current}var Bf=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},Af=function(e){return"touches"in e},yy=function(e){return e&&e.ownerDocument.defaultView||self},lk=function(e,t,n){var r=e.getBoundingClientRect(),o=Af(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:Bf((o.pageX-(r.left+yy(e).pageXOffset))/r.width),top:Bf((o.pageY-(r.top+yy(e).pageYOffset))/r.height)}},ck=function(e){!Af(e)&&e.preventDefault()},fk=Ln.default.memo(function(e){var t=e.onMove,n=e.onKey,r=e.onEnd,o=dk(e,["onMove","onKey","onEnd"]),a=(0,Ln.useRef)(null),i=Df(t),s=Df(n),l=Df(r),c=(0,Ln.useRef)(null),u=(0,Ln.useRef)(!1),d=(0,Ln.useMemo)(function(){var g=function(b){ck(b),(Af(b)?b.touches.length>0:b.buttons>0)&&a.current?i(lk(a.current,b,c.current)):(v(!1),l())},y=function(){v(!1),l()};function v(b){var S=u.current,C=yy(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&&(ck(S),!(function(k,M){return M&&!Af(k)})(S,u.current)&&C)){if(Af(S)){u.current=!0;var w=S.changedTouches||[];w.length&&(c.current=w[0].identifier)}C.focus(),i(lk(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(0,Ln.useEffect)(function(){return p},[p]),Ln.default.createElement("div",Hp({},o,{onTouchStart:m,onMouseDown:m,className:"react-colorful__interactive",ref:a,onKeyDown:f,onKeyUp:h,tabIndex:0,role:"slider"}))}),xy=function(e){return e.filter(Boolean).join(" ")},mk=function(e){var t=e.color,n=e.left,r=e.top,o=r===void 0?.5:r,a=xy(["react-colorful__pointer",e.className]);return Ln.default.createElement("div",{className:a,style:{top:100*o+"%",left:100*n+"%"}},Ln.default.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:t}}))},Po=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n},NK={grad:.9,turn:360,rad:360/(2*Math.PI)},zF=function(e){return UF(vy(e))},vy=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?Po(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?Po(parseInt(e.substring(6,8),16)/255,2):1}};var HF=function(e){return qF(WF(e))},VF=function(e){var t=e.s,n=e.v,r=e.a,o=(200-t)*n/100;return{h:Po(e.h),s:Po(o>0&&o<200?t*n/100/(o<=100?o:200-o)*100:0),l:Po(o/2),a:Po(r,2)}},wy=function(e){var t=VF(e);return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"};var WF=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:Po(255*[r,s,i,i,l,r][c]),g:Po(255*[l,r,r,s,i,i][c]),b:Po(255*[i,i,l,r,r,s][c]),a:Po(o,2)}};var zp=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},qF=function(e){var t=e.r,n=e.g,r=e.b,o=e.a,a=o<1?zp(Po(255*o)):"";return"#"+zp(t)+zp(n)+zp(r)+a},UF=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:Po(60*(s<0?s+6:s)),s:Po(a?i/a*100:0),v:Po(a/255*100),a:o}};var jF=Ln.default.memo(function(e){var t=e.hue,n=e.onChange,r=e.onChangeEnd,o=xy(["react-colorful__hue",e.className]);return Ln.default.createElement("div",{className:o},Ln.default.createElement(fk,{onMove:function(a){n({h:360*a.left})},onKey:function(a){n({h:Bf(t+360*a.left,0,360)})},onEnd:r,"aria-label":"Hue","aria-valuenow":Po(t),"aria-valuemax":"360","aria-valuemin":"0"},Ln.default.createElement(mk,{className:"react-colorful__hue-pointer",left:t/360,color:wy({h:t,s:100,v:100,a:1})})))}),GF=Ln.default.memo(function(e){var t=e.hsva,n=e.onChange,r=e.onChangeEnd,o={backgroundColor:wy({h:t.h,s:100,v:100,a:1})};return Ln.default.createElement("div",{className:"react-colorful__saturation",style:o},Ln.default.createElement(fk,{onMove:function(a){n({s:100*a.left,v:100-100*a.top})},onKey:function(a){n({s:Bf(t.s+100*a.left,0,100),v:Bf(t.v-100*a.top,0,100)})},onEnd:r,"aria-label":"Color","aria-valuetext":"Saturation "+Po(t.s)+"%, Brightness "+Po(t.v)+"%"},Ln.default.createElement(mk,{className:"react-colorful__saturation-pointer",top:1-t.v/100,left:t.s/100,color:wy(t)})))}),pk=function(e,t){if(e===t)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0};var YF=function(e,t){return e.toLowerCase()===t.toLowerCase()||pk(vy(e),vy(t))};function KF(e,t,n,r){var o=Df(n),a=Df(r),i=(0,Ln.useState)(function(){return e.toHsva(t)}),s=i[0],l=i[1],c=(0,Ln.useRef)({color:t,hsva:s}),u=(0,Ln.useRef)(!1);(0,Ln.useEffect)(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]),(0,Ln.useEffect)(function(){var f;pk(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=(0,Ln.useCallback)(function(f){l(function(h){return Object.assign({},h,f)})},[]),m=(0,Ln.useCallback)(function(){u.current&&(u.current=!1,a(c.current.color))},[a]);return[s,d,m]}var $F,XF=typeof window<"u"?Ln.useLayoutEffect:Ln.useEffect,ZF=function(){return $F||(typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0)};var uk=new WeakMap,QF=function(e){XF(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(!uk.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=ZF();i&&a.setAttribute("nonce",i),uk.set(r,a),o.appendChild(a)}}},[])},JF=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=dk(e,["className","colorModel","color","onChange","onChangeEnd"]),l=(0,Ln.useRef)(null);QF(l);var c=KF(n,o,a,i),u=c[0],d=c[1],m=c[2],f=xy(["react-colorful",t]);return Ln.default.createElement("div",Hp({},s,{ref:l,className:f}),Ln.default.createElement(GF,{hsva:u,onChange:d,onChangeEnd:m}),Ln.default.createElement(jF,{hue:u.h,onChange:d,onChangeEnd:m,className:"react-colorful__last-control"}))},e5={defaultColor:"000",toHsva:zF,fromHsva:function(e){return HF({h:e.h,s:e.s,v:e.v,a:1})},equal:YF},hk=function(e){return Ln.default.createElement(JF,Hp({},e,{colorModel:e5}))};var Vp=require("react");function gk(e){let t=(0,Vp.useRef)(null);return(0,Vp.useEffect)(()=>{e&&(typeof e=="function"?e(t.current):e.current=t.current)}),t}var wk=Ct(require("react"));var bk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,yk=Op,vk=(e,t)=>n=>{var r;if(t?.variants==null)return yk(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=bk(u)||bk(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 yk(e,i,l,n?.class,n?.className)};var xk=require("react/jsx-runtime"),t5=vk("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"}}),br=wk.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},a)=>(0,xk.jsx)(r?$C:"button",{className:ne(t5({variant:t,size:n,className:e}),e?.includes?.("noScale")?"":"active:scale-[0.98] "),ref:a,...o}));br.displayName="Button";var yI=Ct(require("react"));var zr=Ct(require("react"),1);var pr=Ct(require("react"),1);var ou=Ct(require("react"),1),n5=Object.defineProperty,r5=(e,t)=>n5(e,"name",{value:t,configurable:!0});function na(e){let t=ou.useRef(e);return ou.useEffect(()=>{t.current=e}),ou.useMemo(()=>((...n)=>t.current?.(...n)),[])}r5(na,"useCallbackRef");var Ck=require("react/jsx-runtime"),o5=Object.defineProperty,vo=(e,t)=>o5(e,"name",{value:t,configurable:!0}),Sy="dismissableLayer.update",a5="dismissableLayer.pointerDownOutside",i5="dismissableLayer.focusOutside",Sk,kk=pr.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ys=pr.forwardRef(vo(function(t,n){let{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:o=!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:l,onDismiss:c,...u}=t,d=pr.useContext(kk),[m,f]=pr.useState(null),h=m?.ownerDocument??globalThis?.document,[,p]=pr.useState({}),g=nn(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=pr.useRef(!1),M=Tk(R=>{i?.(R),l?.(R),R.defaultPrevented||c?.()},{ownerDocument:h,deferPointerDownOutside:o,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:pr.useCallback(R=>{if(!(R instanceof Node))return!1;let P=[...d.branches].some(D=>D.contains(R));return w&&!P},[d.branches,w])}),I=Ik(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=na(R=>{R.key==="Escape"&&(a?.(R),!R.defaultPrevented&&c&&(R.preventDefault(),c()))});return pr.useEffect(()=>{if(x)return h.addEventListener("keydown",T,{capture:!0}),()=>h.removeEventListener("keydown",T,{capture:!0})},[h,x,T]),pr.useEffect(()=>{if(m)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Sk=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(m)),d.layers.add(m),Cy(),()=>{r&&(d.layersWithOutsidePointerEventsDisabled.delete(m),d.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=Sk))}},[m,h,r,d]),pr.useEffect(()=>()=>{m&&(d.layers.delete(m),d.layersWithOutsidePointerEventsDisabled.delete(m),Cy())},[m,d]),pr.useEffect(()=>{let R=vo(()=>p({}),"handleUpdate");return document.addEventListener(Sy,R),()=>document.removeEventListener(Sy,R)},[]),(0,Ck.jsx)(hn.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 s5(){let e=pr.useContext(kk),[t,n]=pr.useState(null);return pr.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}vo(s5,"useDismissableLayerSurface");var l5=vo(()=>!0,"IS_TRUE");function Tk(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=l5}=t,s=na(e),l=pr.useRef(!1),c=pr.useRef(!1),u=pr.useRef(new Map),d=pr.useRef(()=>{});return pr.useEffect(()=>{function m(){c.current=!1,o.current=!1,u.current.clear()}vo(m,"resetOutsideInteraction");function f(){return Array.from(u.current.values()).some(Boolean)}vo(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)}vo(h,"handleInteractionCapture");function p(b){c.current&&u.current.set(b.type,!1)}vo(p,"handleInteractionBubble");let g=vo(b=>{if(b.target&&!l.current){let C=function(){n.removeEventListener("click",d.current);let k=f();m(),k||ky(a5,s,w,{discrete:!0})};var S=C;if(vo(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:vo(()=>l.current=!0,"onPointerDownCapture")}}vo(Tk,"usePointerDownOutside");function Ik(e,t=globalThis?.document){let n=na(e),r=pr.useRef(!1);return pr.useEffect(()=>{let o=vo(a=>{a.target&&!r.current&&ky(i5,n,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:vo(()=>r.current=!0,"onFocusCapture"),onBlurCapture:vo(()=>r.current=!1,"onBlurCapture")}}vo(Ik,"useFocusOutside");function Cy(){let e=new CustomEvent(Sy);document.dispatchEvent(e)}vo(Cy,"dispatchUpdate");function ky(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?Pf(o,a):o.dispatchEvent(a)}vo(ky,"handleAndDispatchCustomEvent");var Mk=Ct(require("react"),1),c5=Object.defineProperty,Iy=(e,t)=>c5(e,"name",{value:t,configurable:!0}),Wp=0,au=null;function u5(e){return iu(),e.children}Iy(u5,"FocusGuards");function iu(){Mk.useEffect(()=>{au||(au={start:Ty(),end:Ty()});let{start:e,end:t}=au;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Wp++,()=>{Wp===1&&(au?.start.remove(),au?.end.remove(),au=null),Wp=Math.max(0,Wp-1)}},[])}Iy(iu,"useFocusGuards");function Ty(){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}Iy(Ty,"createFocusGuard");var _a=Ct(require("react"),1);var Pk=require("react/jsx-runtime"),d5=Object.defineProperty,Ko=(e,t)=>d5(e,"name",{value:t,configurable:!0}),My="focusScope.autoFocusOnMount",Ly="focusScope.autoFocusOnUnmount",Lk={bubbles:!1,cancelable:!0},qp=_a.forwardRef(Ko(function(t,n){let{loop:r=!1,trapped:o=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...s}=t,[l,c]=_a.useState(null),u=na(a),d=na(i),m=_a.useRef(null),f=nn(n,c),h=_a.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_a.useEffect(()=>{if(o){let b=function(k){if(h.paused||!l)return;let M=k.target;l.contains(M)?m.current=M:Zi(m.current,{select:!0})},S=function(k){if(h.paused||!l)return;let M=k.relatedTarget;M!==null&&(l.contains(M)||Zi(m.current,{select:!0}))},C=function(k){if(document.activeElement===document.body)for(let I of k)I.removedNodes.length>0&&Zi(l)};var g=b,y=S,v=C;Ko(b,"handleFocusIn"),Ko(S,"handleFocusOut"),Ko(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]),_a.useEffect(()=>{if(l){Rk.add(h);let g=document.activeElement;if(!l.contains(g)){let v=new CustomEvent(My,Lk);l.addEventListener(My,u),l.dispatchEvent(v),v.defaultPrevented||(Dk(Ok(Dy(l)),{select:!0}),document.activeElement===g&&Zi(l))}return()=>{l.removeEventListener(My,u),setTimeout(()=>{let v=new CustomEvent(Ly,Lk);l.addEventListener(Ly,d),l.dispatchEvent(v),v.defaultPrevented||Zi(g??document.body,{select:!0}),l.removeEventListener(Ly,d),Rk.remove(h)},0)}}},[l,u,d,h]);let p=_a.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]=Ak(b);S&&C?!g.shiftKey&&v===C?(g.preventDefault(),r&&Zi(S,{select:!0})):g.shiftKey&&v===S&&(g.preventDefault(),r&&Zi(C,{select:!0})):v===b&&g.preventDefault()}},[r,o,h.paused]);return(0,Pk.jsx)(hn.div,{tabIndex:-1,...s,ref:f,onKeyDown:p})},"FocusScope"));function Dk(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Zi(r,{select:t}),document.activeElement!==n)return}Ko(Dk,"focusFirst");function Ak(e){let t=Dy(e),n=Ry(t,e),r=Ry(t.reverse(),e);return[n,r]}Ko(Ak,"getTabbableEdges");function Dy(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Ko(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}Ko(Dy,"getTabbableCandidates");function Ry(e,t){let n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Bk(r,{upTo:t})))return r}Ko(Ry,"findVisible");function Bk(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}Ko(Bk,"isHidden");function Nk(e){return e instanceof HTMLInputElement&&"select"in e}Ko(Nk,"isSelectableInput");function Zi(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Nk(e)&&t&&e.select()}}Ko(Zi,"focus");var Rk=Ek();function Ek(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Py(e,t),e.unshift(t)},remove(t){e=Py(e,t),e[0]?.resume()}}}Ko(Ek,"createFocusScopesStack");function Py(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Ko(Py,"arrayRemove");function Ok(e){return e.filter(t=>t.tagName!=="A")}Ko(Ok,"removeLinks");var Ay=Ct(require("react"),1);var f5=Object.defineProperty,m5=(e,t)=>f5(e,"name",{value:t,configurable:!0}),p5=Ay[" useId ".trim().toString()]||(()=>{}),h5=0;function Ai(e){let[t,n]=Ay.useState(p5());return $r(()=>{e||n(r=>r??String(h5++))},[e]),e||(t?`radix-${t}`:"")}m5(Ai,"useId");var _o=Ct(require("react"),1);var zk=["top","right","bottom","left"];var Bi=Math.min,mi=Math.max,Ef=Math.round,Of=Math.floor,Ni=e=>({x:e,y:e}),g5={left:"right",right:"left",bottom:"top",top:"bottom"};function By(e,t,n){return mi(e,Bi(t,n))}function Ei(e,t){return typeof e=="function"?e(t):e}function Qi(e){return e.split("-")[0]}function zl(e){return e.split("-")[1]}function jp(e){return e==="x"?"y":"x"}function Gp(e){return e==="y"?"height":"width"}function pi(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function Yp(e){return jp(pi(e))}function Hk(e,t,n){n===void 0&&(n=!1);let r=zl(e),o=Yp(e),a=Gp(o),i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=Nf(i)),[i,Nf(i)]}function Vk(e){let t=Nf(e);return[Up(e),t,Up(t)]}function Up(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var _k=["left","right"],Fk=["right","left"],b5=["top","bottom"],y5=["bottom","top"];function v5(e,t,n){switch(e){case"top":case"bottom":return n?t?Fk:_k:t?_k:Fk;case"left":case"right":return t?b5:y5;default:return[]}}function Wk(e,t,n,r){let o=zl(e),a=v5(Qi(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Up)))),a}function Nf(e){let t=Qi(e);return g5[t]+e.slice(t.length)}function w5(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 Ny(e){return typeof e!="number"?w5(e):{top:e,right:e,bottom:e,left:e}}function Hl(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 qk(e,t,n){let{reference:r,floating:o}=e,a=pi(t),i=Yp(t),s=Gp(i),l=Qi(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=zl(t);return h&&(f[i]+=m*(h==="end"?1:-1)*(n&&c?-1:1)),f}async function Gk(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}=Ei(t,e),h=Ny(f),g=s[m?d==="floating"?"reference":"floating":d],y=Hl(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=Hl(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 x5=50,Yk=async(e,t,n)=>{let{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,s=i.detectOverflow?i:{...i,detectOverflow:Gk},l=await(i.isRTL==null?void 0:i.isRTL(t)),c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=qk(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<x5&&(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}=qk(c,m,l)),p=-1)}return{x:u,y:d,placement:m,strategy:o,middlewareData:h}},Kk=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}=Ei(e,t)||{};if(c==null)return{};let d=Ny(u),m={x:n,y:r},f=Yp(o),h=Gp(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=Bi(d[y],I),T=Bi(d[v],I),R=k-p[h]-T,P=k/2-p[h]/2+M,D=By(x,P,R),N=!l.arrow&&zl(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 $k=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}=Ei(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};let y=Qi(o),v=pi(s),b=Qi(s)===s,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(b||!p?[Nf(s)]:Vk(s)),w=h!=="none";!m&&w&&C.push(...Wk(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=Hk(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!==pi(N):!1)||x.every(B=>pi(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=pi(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 Uk(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function jk(e){return zk.some(t=>e[t]>=0)}var Xk=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:o="referenceHidden",...a}=Ei(e,t);switch(o){case"referenceHidden":{let i=await r.detectOverflow(t,{...a,elementContext:"reference"}),s=Uk(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:jk(s)}}}case"escaped":{let i=await r.detectOverflow(t,{...a,altBoundary:!0}),s=Uk(i,n.floating);return{data:{escapedOffsets:s,escaped:jk(s)}}}default:return{}}}}};var Zk=new Set(["left","top"]);async function S5(e,t){let{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Qi(n),s=zl(n),l=pi(n)==="y",c=Zk.has(i)?-1:1,u=a&&l?-1:1,d=Ei(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 Qk=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 S5(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}}}}},Jk=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}=Ei(e,t),u={x:n,y:r},d=await a.detectOverflow(t,c),m=pi(o),f=jp(m),h=u[f],p=u[m],g=(v,b)=>By(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}}}}}},eT=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}=Ei(e,t),m={x:o,y:a},f=pi(i),h=jp(f),p=m[h],g=m[f],y=Ei(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=Zk.has(Qi(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}}}},tT=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}=Ei(e,t),l=await o.detectOverflow(t,s),c=Qi(n),u=zl(n),d=pi(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=Bi(f-l[h],g),b=Bi(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*mi(l.left,l.right):w=f-2*mi(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 Kp(){return typeof window<"u"}function ql(e){return rT(e)?(e.nodeName||"").toLowerCase():"#document"}function $o(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Oi(e){var t;return(t=(rT(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function rT(e){return Kp()?e instanceof Node||e instanceof $o(e).Node:!1}function hi(e){return Kp()?e instanceof Element||e instanceof $o(e).Element:!1}function Ji(e){return Kp()?e instanceof HTMLElement||e instanceof $o(e).HTMLElement:!1}function nT(e){return!Kp()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $o(e).ShadowRoot}function _f(e){let{overflow:t,overflowX:n,overflowY:r,display:o}=gi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function oT(e){return/^(table|td|th)$/.test(ql(e))}function Ff(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var C5=/transform|translate|scale|rotate|perspective|filter/,k5=/paint|layout|strict|content/,Vl=e=>!!e&&e!=="none",Ey;function $p(e){let t=hi(e)?gi(e):e;return Vl(t.transform)||Vl(t.translate)||Vl(t.scale)||Vl(t.rotate)||Vl(t.perspective)||!Xp()&&(Vl(t.backdropFilter)||Vl(t.filter))||C5.test(t.willChange||"")||k5.test(t.contain||"")}function aT(e){let t=Ks(e);for(;Ji(t)&&!su(t);){if($p(t))return t;if(Ff(t))return null;t=Ks(t)}return null}function Xp(){return Ey==null&&(Ey=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ey}function su(e){return/^(html|body|#document)$/.test(ql(e))}function gi(e){return $o(e).getComputedStyle(e)}function zf(e){return hi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ks(e){if(ql(e)==="html")return e;let t=e.assignedSlot||e.parentNode||nT(e)&&e.host||Oi(e);return nT(t)?t.host:t}function iT(e){let t=Ks(e);return su(t)?(e.ownerDocument||e).body:Ji(t)&&_f(t)?t:iT(t)}function Wl(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let o=iT(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=$o(o);if(a){let s=Zp(i);return t.concat(i,i.visualViewport||[],_f(o)?o:[],s&&n?Wl(s):[])}else return t.concat(o,Wl(o,[],n))}function Zp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function cT(e){let t=gi(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,o=Ji(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,s=Ef(n)!==a||Ef(r)!==i;return s&&(n=a,r=i),{width:n,height:r,$:s}}function _y(e){return hi(e)?e:e.contextElement}function lu(e){let t=_y(e);if(!Ji(t))return Ni(1);let n=t.getBoundingClientRect(),{width:r,height:o,$:a}=cT(t),i=(a?Ef(n.width):n.width)/r,s=(a?Ef(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}var T5=Ni(0);function uT(e){let t=$o(e);return!Xp()||!t.visualViewport?T5:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function I5(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===$o(e)}function Ul(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let o=e.getBoundingClientRect(),a=_y(e),i=Ni(1);t&&(r?hi(r)&&(i=lu(r)):i=lu(e));let s=I5(a,n,r)?uT(a):Ni(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=$o(a),f=hi(r)?$o(r):r,h=m,p=Zp(h);for(;p&&f!==h;){let g=lu(p),y=p.getBoundingClientRect(),v=gi(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=$o(p),p=Zp(h)}}return Hl({width:u,height:d,x:l,y:c})}function Qp(e,t){let n=zf(e).scrollLeft;return t?t.left+n:Ul(Oi(e)).left+n}function dT(e,t){let n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Qp(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function M5(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e,a=o==="fixed",i=Oi(r),s=t?Ff(t.floating):!1;if(r===i||s&&a)return n;let l={scrollLeft:0,scrollTop:0},c=Ni(1),u=Ni(0),d=Ji(r);if((d||!a)&&((ql(r)!=="body"||_f(i))&&(l=zf(r)),d)){let f=Ul(r);c=lu(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}let m=i&&!d&&!a?dT(i,l):Ni(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 L5(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function R5(e){let t=zf(e),n=e.ownerDocument.body,r=mi(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),o=mi(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Qp(e),i=-t.scrollTop;return gi(n).direction==="rtl"&&(a+=mi(e.clientWidth,n.clientWidth)-r),{width:r,height:o,x:a,y:i}}var P5=25;function D5(e,t,n){n===void 0&&(n="viewport");let r=n==="layoutViewport",o=$o(e),a=Oi(e),i=o.visualViewport,s=a.clientWidth,l=a.clientHeight,c=0,u=0;if(i){let m=!Xp()||t==="fixed";r?m||(c=-i.offsetLeft,u=-i.offsetTop):(s=i.width,l=i.height,m&&(c=i.offsetLeft,u=i.offsetTop))}if(Qp(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<=P5&&(s-=y)}return{width:s,height:l,x:c,y:u}}function A5(e,t){let n=Ul(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=lu(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 sT(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=D5(e,n,t);else if(t==="document")r=R5(Oi(e));else if(hi(t))r=A5(t,n);else{let o=uT(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Hl(r)}function B5(e,t){let n=t.get(e);if(n)return n;let r=Wl(e,[],!1).filter(s=>hi(s)&&ql(s)!=="body"),o=null,a=gi(e).position==="fixed",i=a?Ks(e):e;for(;hi(i)&&!su(i);){let s=gi(i),l=$p(i),c=o?o.position:a?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&s.position==="static")?r=r.filter(d=>d!==i):o=s,i=Ks(i)}return t.set(e,r),r}function N5(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e,i=[...n==="clippingAncestors"?Ff(t)?[]:B5(t,this._c):[].concat(n),r],s=sT(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=sT(t,i[m],o);l=mi(f.top,l),c=Bi(f.right,c),u=Bi(f.bottom,u),d=mi(f.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function E5(e){let{width:t,height:n}=cT(e);return{width:t,height:n}}function O5(e,t,n){let r=Ji(t),o=Oi(t),a=n==="fixed",i=Ul(e,!0,a,t),s={scrollLeft:0,scrollTop:0},l=Ni(0);if((r||!a)&&((ql(t)!=="body"||_f(o))&&(s=zf(t)),r)){let m=Ul(t,!0,a,t);l.x=m.x+t.clientLeft,l.y=m.y+t.clientTop}!r&&o&&(l.x=Qp(o));let c=o&&!r&&!a?dT(o,s):Ni(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 Oy(e){return gi(e).position==="static"}function lT(e,t){if(!Ji(e)||gi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Oi(e)===n&&(n=n.ownerDocument.body),n}function fT(e,t){let n=$o(e);if(Ff(e))return n;if(!Ji(e)){let o=Ks(e);for(;o&&!su(o);){if(hi(o)&&!Oy(o))return o;o=Ks(o)}return n}let r=lT(e,t);for(;r&&oT(r)&&Oy(r);)r=lT(r,t);return r&&su(r)&&Oy(r)&&!$p(r)?n:r||aT(e)||n}var _5=async function(e){let t=this.getOffsetParent||fT,n=this.getDimensions,r=await n(e.floating);return{reference:O5(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function F5(e){return gi(e).direction==="rtl"}var mT={convertOffsetParentRelativeRectToViewportRelativeRect:M5,getDocumentElement:Oi,getClippingRect:N5,getOffsetParent:fT,getElementRects:_5,getClientRects:L5,getDimensions:E5,getScale:lu,isElement:hi,isRTL:F5};function pT(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function z5(e,t,n){let r=null,o,a=Oi(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=Of(h),v=Of(a.clientWidth-(f+p)),b=Of(a.clientHeight-(h+g)),S=Of(f),w={rootMargin:-y+"px "+-v+"px "+-b+"px "+-S+"px",threshold:mi(0,Bi(1,d))||1},k=!0;function M(I){let x=I[0].intersectionRatio;if(!pT(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=$o(e),c=()=>s(n);return l.addEventListener("resize",c),s(!0),()=>{l.removeEventListener("resize",c),i()}}function Fy(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=_y(e),u=o||a?[...c?Wl(c):[],...t?Wl(t):[]]:[];u.forEach(y=>{o&&y.addEventListener("scroll",n),a&&y.addEventListener("resize",n)});let d=c&&s?z5(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?Ul(e):null;l&&g();function g(){let y=Ul(e);p&&!pT(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 hT=Qk;var gT=Jk,bT=$k,yT=tT,vT=Xk,zy=Kk;var wT=eT,Hy=(e,t,n)=>{let r=new Map,o=n??{},a={...mT,...o.platform,_c:r};return Yk(e,t,{...o,platform:a})};var oo=Ct(require("react"),1),ST=require("react"),CT=Ct(require("react-dom"),1),H5=typeof document<"u",V5=function(){},Jp=H5?ST.useLayoutEffect:V5;function eh(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(!eh(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)&&!eh(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function kT(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xT(e,t){let n=kT(e);return Math.round(t*n)/n}function Vy(e){let t=oo.useRef(e);return Jp(()=>{t.current=e}),t}function TT(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]=oo.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=oo.useState(r);eh(m,r)||f(r);let[h,p]=oo.useState(null),[g,y]=oo.useState(null),v=oo.useCallback(B=>{B!==w.current&&(w.current=B,p(B))},[]),b=oo.useCallback(B=>{B!==k.current&&(k.current=B,y(B))},[]),S=a||h,C=i||g,w=oo.useRef(null),k=oo.useRef(null),M=oo.useRef(u),I=l!=null,x=Vy(l),T=Vy(o),R=Vy(c),P=oo.useCallback(()=>{if(!w.current||!k.current)return;let B={placement:t,strategy:n,middleware:m};T.current&&(B.platform=T.current),Hy(w.current,k.current,B).then(E=>{let L={...E,isPositioned:R.current!==!1};D.current&&!eh(M.current,L)&&(M.current=L,CT.flushSync(()=>{d(L)}))})},[m,t,n,T,R]);Jp(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,d(B=>({...B,isPositioned:!1})))},[c]);let D=oo.useRef(!1);Jp(()=>(D.current=!0,()=>{D.current=!1}),[]),Jp(()=>{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=oo.useMemo(()=>({reference:w,floating:k,setReference:v,setFloating:b}),[v,b]),O=oo.useMemo(()=>({reference:S,floating:C}),[S,C]),A=oo.useMemo(()=>{let B={position:n,left:0,top:0};if(!O.floating)return B;let E=xT(O.floating,u.x),L=xT(O.floating,u.y);return s?{...B,transform:"translate("+E+"px, "+L+"px)",...kT(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:L}},[n,s,O.floating,u.x,u.y]);return oo.useMemo(()=>({...u,update:P,refs:N,elements:O,floatingStyles:A}),[u,P,N,O,A])}var W5=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?zy({element:r.current,padding:o}).fn(n):{}:r?zy({element:r,padding:o}).fn(n):{}}}},IT=(e,t)=>{let n=hT(e);return{name:n.name,fn:n.fn,options:[e,t]}},MT=(e,t)=>{let n=gT(e);return{name:n.name,fn:n.fn,options:[e,t]}},LT=(e,t)=>({fn:wT(e).fn,options:[e,t]}),RT=(e,t)=>{let n=bT(e);return{name:n.name,fn:n.fn,options:[e,t]}},PT=(e,t)=>{let n=yT(e);return{name:n.name,fn:n.fn,options:[e,t]}};var DT=(e,t)=>{let n=vT(e);return{name:n.name,fn:n.fn,options:[e,t]}};var AT=(e,t)=>{let n=W5(e);return{name:n.name,fn:n.fn,options:[e,t]}};var cu=require("react/jsx-runtime"),q5=Object.defineProperty,$s=(e,t)=>q5(e,"name",{value:t,configurable:!0});var BT="Popper",[NT,Fa]=kr(BT),[U5,ET]=NT(BT),j5=$s(e=>{let{__scopePopper:t,children:n}=e,[r,o]=_o.useState(null),[a,i]=_o.useState(void 0);return(0,cu.jsx)(U5,{scope:t,anchor:r,onAnchorChange:o,placementState:a,setPlacementState:i,children:n})},"Popper"),G5="PopperAnchor",Y5=_o.forwardRef($s(function(t,n){let{__scopePopper:r,virtualRef:o,...a}=t,i=ET(G5,r),s=_o.useRef(null),l=i.onAnchorChange,c=_o.useCallback(p=>{s.current=p,p&&l(p)},[l]),u=nn(n,c),d=_o.useRef(null);_o.useEffect(()=>{if(!o)return;let p=d.current;d.current=o.current,p!==d.current&&l(d.current)});let m=i.placementState&&th(i.placementState),f=m?.[0],h=m?.[1];return o?null:(0,cu.jsx)(hn.div,{"data-radix-popper-side":f,"data-radix-popper-align":h,...a,ref:u})},"PopperAnchor")),OT="PopperContent",[K5,M$]=NT(OT),$5=_o.forwardRef($s(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=ET(OT,r),[v,b]=_o.useState(null),S=nn(n,b),[C,w]=_o.useState(null),k=Xi(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(_T),altBoundary:P},{refs:N,floatingStyles:O,placement:A,isPositioned:B,middlewareData:E}=TT({strategy:"fixed",placement:x,whileElementsMounted:$s((...J)=>Fy(...J,{animationFrame:h==="always"}),"whileElementsMounted"),elements:{reference:y.anchor},middleware:[IT({mainAxis:a+I,alignmentAxis:s}),c&&MT({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?LT():void 0,...D}),c&&RT({...D}),PT({...D,apply:$s(({elements:J,rects:me,availableWidth:We,availableHeight:Ce})=>{let{width:Ee,height:ze}=me.reference,Ie=J.floating.style;Ie.setProperty("--radix-popper-available-width",`${We}px`),Ie.setProperty("--radix-popper-available-height",`${Ce}px`),Ie.setProperty("--radix-popper-anchor-width",`${Ee}px`),Ie.setProperty("--radix-popper-anchor-height",`${ze}px`)},"apply")}),C&&AT({element:C,padding:l}),X5({arrowWidth:M,arrowHeight:I}),f&&DT({strategy:"referenceHidden",...D,boundary:P?D.boundary:void 0})]}),L=y.setPlacementState;$r(()=>(L(A),()=>{L(void 0)}),[A,L]);let[H,K]=th(A),G=na(p);$r(()=>{B&&G?.()},[B,G]);let V=E.arrow?.x,q=E.arrow?.y,j=E.arrow?.centerOffset!==0,[W,$]=_o.useState();return $r(()=>{v&&$(window.getComputedStyle(v).zIndex)},[v]),(0,cu.jsx)("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...O,transform:B?O.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:W,"--radix-popper-transform-origin":[E.transformOrigin?.x,E.transformOrigin?.y].join(" "),...E.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:(0,cu.jsx)(K5,{scope:r,placedSide:H,placedAlign:K,onArrowChange:w,arrowX:V,arrowY:q,shouldHideArrow:j,children:(0,cu.jsx)(hn.div,{"data-side":H,"data-align":K,...g,ref:S,style:{...g.style,animation:B?g.style?.animation:"none"}})})})},"PopperContent"));function _T(e){return e!==null}$s(_T,"isNotNull");var X5=$s(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]=th(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 th(e){let[t,n="center"]=e.split("-");return[t,n]}$s(th,"getSideAndAlignFromPlacement");var Xs=j5,es=Y5,Zs=$5;var rh=Ct(require("react"),1),FT=Ct(require("react-dom"),1);var zT=require("react/jsx-runtime"),Z5=Object.defineProperty,Q5=(e,t)=>Z5(e,"name",{value:t,configurable:!0}),uu=rh.forwardRef(Q5(function(t,n){let{container:r,...o}=t,[a,i]=rh.useState(!1);$r(()=>i(!0),[]);let s=r||a&&globalThis?.document?.body;return s?FT.createPortal((0,zT.jsx)(hn.div,{...o,ref:n}),s):null},"Portal"));var Do=Ct(require("react"),1);var HT=Ct(require("react"),1),J5=Object.defineProperty,ts=(e,t)=>J5(e,"name",{value:t,configurable:!0});function VT(e,t){return HT.useReducer((n,r)=>t[n][r]??n,e)}ts(VT,"useStateMachine");var Xo=ts(e=>{let{present:t,children:n}=e,r=WT(t),o=typeof n=="function"?n({present:r.isPresent}):Do.Children.only(n),a=qT(r.ref,UT(o));return typeof n=="function"||r.isPresent?Do.cloneElement(o,{ref:a}):null},"Presence");function WT(e){let[t,n]=Do.useState(),r=Do.useRef(null),o=Do.useRef(e),a=Do.useRef("none"),i=Do.useRef(void 0),s=e?"mounted":"unmounted",[l,c]=VT(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return Do.useEffect(()=>{l==="mounted"?(a.current=i.current??du(r.current),i.current=void 0):a.current="none"},[l]),$r(()=>{let u=r.current,d=o.current;if(d!==e){let f=a.current,h=du(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]),$r(()=>{if(t){let u,d=t.ownerDocument.defaultView??window,m=ts(h=>{let g=du(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=ts(h=>{h.target===t&&(a.current=du(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:Do.useCallback(u=>{if(u){let d=getComputedStyle(u);r.current=d,i.current=du(d)}else r.current=null;n(u)},[])}}ts(WT,"usePresence");function Wy(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}ts(Wy,"setRef");function qT(...e){let t=Do.useRef(e);return t.current=e,Do.useCallback(n=>{let r=t.current,o=!1,a=r.map(i=>{let s=Wy(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():Wy(r[i],null)}}},[])}ts(qT,"useStableComposedRefs");function du(e){return e?.animationName||"none"}ts(du,"getAnimationName");function UT(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)}ts(UT,"getElementRef");var e4=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},fu=new WeakMap,oh=new WeakMap,ah={},qy=0,jT=function(e){return e&&(e.host||jT(e.parentNode))},t4=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=jT(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})},n4=function(e,t,n,r){var o=t4(t,Array.isArray(e)?e:[e]);ah[n]||(ah[n]=new WeakMap);var a=ah[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=(fu.get(m)||0)+1,g=(a.get(m)||0)+1;fu.set(m,p),a.set(m,g),i.push(m),p===1&&h&&oh.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(),qy++,function(){i.forEach(function(d){var m=fu.get(d)-1,f=a.get(d)-1;fu.set(d,m),a.set(d,f),m||(oh.has(d)||d.removeAttribute(r),oh.delete(d)),f||d.removeAttribute(n)}),qy--,qy||(fu=new WeakMap,fu=new WeakMap,oh=new WeakMap,ah={})}},ih=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=t||e4(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),n4(r,o,n,"aria-hidden")):function(){return null}};var ra=function(){return ra=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},ra.apply(this,arguments)};function sh(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 GT(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))}var fh=Ct(require("react"));var Fo=Ct(require("react"));var jl="right-scroll-bar-position",Gl="width-before-scroll-bar",Uy="with-scroll-bars-hidden",jy="--removed-body-scroll-bar-size";function lh(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}var YT=require("react");function KT(e,t){var n=(0,YT.useState)(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}var ch=Ct(require("react"));var r4=typeof window<"u"?ch.useLayoutEffect:ch.useEffect,$T=new WeakMap;function Gy(e,t){var n=KT(t||null,function(r){return e.forEach(function(o){return lh(o,r)})});return r4(function(){var r=$T.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(s){a.has(s)||lh(s,null)}),a.forEach(function(s){o.has(s)||lh(s,i)})}$T.set(n,e)},[e]),n}function o4(e){return e}function a4(e,t){t===void 0&&(t=o4);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 Yy(e){e===void 0&&(e={});var t=a4(null);return t.options=ra({async:!0,ssr:!1},e),t}var XT=Ct(require("react")),ZT=function(e){var t=e.sideCar,n=sh(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 XT.createElement(r,ra({},n))};ZT.isSideCarExport=!0;function Ky(e,t){return e.useMedium(t),ZT}var uh=Yy();var $y=function(){},Hf=Fo.forwardRef(function(e,t){var n=Fo.useRef(null),r=Fo.useState({onScrollCapture:$y,onWheelCapture:$y,onTouchMoveCapture:$y}),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=sh(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,w=Gy([n,t]),k=ra(ra({},S),o);return Fo.createElement(Fo.Fragment,null,u&&Fo.createElement(C,{sideCar:uh,removeScrollBar:c,shards:d,noRelative:f,noIsolation:h,inert:p,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),i?Fo.cloneElement(Fo.Children.only(s),ra(ra({},k),{ref:w})):Fo.createElement(v,ra({},k,{className:l,ref:w}),s))});Hf.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Hf.classNames={fullWidth:Gl,zeroRight:jl};var Tr=Ct(require("react"));var pu=Ct(require("react"));var eI=Ct(require("react"));var QT;var JT=function(){if(QT)return QT;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function i4(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=JT();return t&&e.setAttribute("nonce",t),e}function s4(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function l4(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Xy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=i4())&&(s4(t,n),l4(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}};var Zy=function(){var e=Xy();return function(t,n){eI.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}};var Vf=function(){var e=Zy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t};var c4={left:0,top:0,right:0,gap:0},Qy=function(e){return parseInt(e||"",10)||0},u4=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[Qy(n),Qy(r),Qy(o)]},Jy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return c4;var t=u4(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 d4=Vf(),mu="data-scroll-locked",f4=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(Uy,` {
|
|
7
|
+
overflow: hidden `).concat(r,`;
|
|
8
|
+
padding-right: `).concat(s,"px ").concat(r,`;
|
|
9
|
+
}
|
|
10
|
+
body[`).concat(mu,`] {
|
|
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(jl,` {
|
|
24
|
+
right: `).concat(s,"px ").concat(r,`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.`).concat(Gl,` {
|
|
28
|
+
margin-right: `).concat(s,"px ").concat(r,`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.`).concat(jl," .").concat(jl,` {
|
|
32
|
+
right: 0 `).concat(r,`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.`).concat(Gl," .").concat(Gl,` {
|
|
36
|
+
margin-right: 0 `).concat(r,`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
body[`).concat(mu,`] {
|
|
40
|
+
`).concat(jy,": ").concat(s,`px;
|
|
41
|
+
}
|
|
42
|
+
`)},tI=function(){var e=parseInt(document.body.getAttribute(mu)||"0",10);return isFinite(e)?e:0},m4=function(){pu.useEffect(function(){return document.body.setAttribute(mu,(tI()+1).toString()),function(){var e=tI()-1;e<=0?document.body.removeAttribute(mu):document.body.setAttribute(mu,e.toString())}},[])},e0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;m4();var a=pu.useMemo(function(){return Jy(o)},[o]);return pu.createElement(d4,{styles:f4(a,!t,o,n?"":"!important")})};var t0=!1;if(typeof window<"u")try{Wf=Object.defineProperty({},"passive",{get:function(){return t0=!0,!0}}),window.addEventListener("test",Wf,Wf),window.removeEventListener("test",Wf,Wf)}catch{t0=!1}var Wf,Yl=t0?{passive:!1}:!1;var p4=function(e){return e.tagName==="TEXTAREA"},nI=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!p4(e)&&n[t]==="visible")},h4=function(e){return nI(e,"overflowY")},g4=function(e){return nI(e,"overflowX")},n0=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=rI(e,r);if(o){var a=oI(e,r),i=a[1],s=a[2];if(i>s)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},b4=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},y4=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},rI=function(e,t){return e==="v"?h4(t):g4(t)},oI=function(e,t){return e==="v"?b4(t):y4(t)},v4=function(e,t){return e==="h"&&t==="rtl"?-1:1},aI=function(e,t,n,r,o){var a=v4(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=oI(e,s),h=f[0],p=f[1],g=f[2],y=p-g-a*h;(h||y)&&rI(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 dh=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},iI=function(e){return[e.deltaX,e.deltaY]},sI=function(e){return e&&"current"in e?e.current:e},w4=function(e,t){return e[0]===t[0]&&e[1]===t[1]},x4=function(e){return`
|
|
43
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
44
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
45
|
+
`)},S4=0,hu=[];function lI(e){var t=Tr.useRef([]),n=Tr.useRef([0,0]),r=Tr.useRef(),o=Tr.useState(S4++)[0],a=Tr.useState(Vf)[0],i=Tr.useRef(e);Tr.useEffect(function(){i.current=e},[e]),Tr.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var p=GT([e.lockRef.current],(e.shards||[]).map(sI),!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=Tr.useCallback(function(p,g){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!i.current.allowPinchZoom;var y=dh(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=n0(k,w);if(!T)return!0;if(T?C=k:(C=k==="v"?"h":"v",T=n0(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 aI(R,g,p,R==="h"?b:S,!0)},[]),l=Tr.useCallback(function(p){var g=p;if(!(!hu.length||hu[hu.length-1]!==a)){var y="deltaY"in g?iI(g):dh(g),v=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&w4(C.delta,y)})[0];if(v&&v.should){g.cancelable&&g.preventDefault();return}if(!v){var b=(i.current.shards||[]).map(sI).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=Tr.useCallback(function(p,g,y,v){var b={name:p,delta:g,target:y,should:v,shadowParent:C4(y)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(S){return S!==b})},1)},[]),u=Tr.useCallback(function(p){n.current=dh(p),r.current=void 0},[]),d=Tr.useCallback(function(p){c(p.type,iI(p),p.target,s(p,e.lockRef.current))},[]),m=Tr.useCallback(function(p){c(p.type,dh(p),p.target,s(p,e.lockRef.current))},[]);Tr.useEffect(function(){return hu.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Yl),document.addEventListener("touchmove",l,Yl),document.addEventListener("touchstart",u,Yl),function(){hu=hu.filter(function(p){return p!==a}),document.removeEventListener("wheel",l,Yl),document.removeEventListener("touchmove",l,Yl),document.removeEventListener("touchstart",u,Yl)}},[]);var f=e.removeScrollBar,h=e.inert;return Tr.createElement(Tr.Fragment,null,h?Tr.createElement(a,{styles:x4(o)}):null,f?Tr.createElement(e0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function C4(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var cI=Ky(uh,lI);var uI=fh.forwardRef(function(e,t){return fh.createElement(Hf,ra({},e,{ref:t,sideCar:cI}))});uI.classNames=Hf.classNames;var qf=uI;var wo=require("react/jsx-runtime"),k4=Object.defineProperty,ns=(e,t)=>k4(e,"name",{value:t,configurable:!0}),o0="Popover",[dI,rZ]=kr(o0,[Fa]),mh=Fa(),[T4,Kl]=dI(o0),I4=ns(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!1}=e,s=mh(t),l=zr.useRef(null),[c,u]=zr.useState(!1),[d,m]=Lo({prop:r,defaultProp:o??!1,onChange:a,caller:o0});return(0,wo.jsx)(Xs,{...s,children:(0,wo.jsx)(T4,{scope:t,contentId:Ai(),triggerRef:l,open:d,onOpenChange:m,onOpenToggle:zr.useCallback(()=>m(f=>!f),[m]),hasCustomAnchor:c,onCustomAnchorAdd:zr.useCallback(()=>u(!0),[]),onCustomAnchorRemove:zr.useCallback(()=>u(!1),[]),modal:i,children:n})})},"Popover"),M4="PopoverAnchor",L4=zr.forwardRef(ns(function(t,n){let{__scopePopover:r,...o}=t,a=Kl(M4,r),i=mh(r),{onCustomAnchorAdd:s,onCustomAnchorRemove:l}=a;return zr.useEffect(()=>(s(),()=>l()),[s,l]),(0,wo.jsx)(es,{...i,...o,ref:n})},"PopoverAnchor")),R4="PopoverTrigger",P4=zr.forwardRef(ns(function(t,n){let{__scopePopover:r,...o}=t,a=Kl(R4,r),i=mh(r),s=nn(n,a.triggerRef),l=(0,wo.jsx)(hn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a0(a.open),...o,ref:s,onClick:lt(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:(0,wo.jsx)(es,{asChild:!0,...i,children:l})},"PopoverTrigger")),fI="PopoverPortal",[D4,A4]=dI(fI,{forceMount:void 0}),B4=ns(e=>{let{__scopePopover:t,forceMount:n,children:r,container:o}=e,a=Kl(fI,t);return(0,wo.jsx)(D4,{scope:t,forceMount:n,children:(0,wo.jsx)(Xo,{present:n||a.open,children:(0,wo.jsx)(uu,{asChild:!0,container:o,children:r})})})},"PopoverPortal"),Uf="PopoverContent",N4=zr.forwardRef(ns(function(t,n){let r=A4(Uf,t.__scopePopover),{forceMount:o=r.forceMount,...a}=t,i=Kl(Uf,t.__scopePopover);return(0,wo.jsx)(Xo,{present:o||i.open,children:i.modal?(0,wo.jsx)(O4,{...a,ref:n}):(0,wo.jsx)(_4,{...a,ref:n})})},"PopoverContent")),E4=ta("PopoverContent.RemoveScroll"),O4=zr.forwardRef(ns(function(t,n){let r=Kl(Uf,t.__scopePopover),o=zr.useRef(null),a=nn(n,o),i=zr.useRef(!1);return zr.useEffect(()=>{let s=o.current;if(s)return ih(s)},[]),(0,wo.jsx)(qf,{as:E4,allowPinchZoom:!0,children:(0,wo.jsx)(mI,{...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")),_4=zr.forwardRef(ns(function(t,n){let r=Kl(Uf,t.__scopePopover),o=zr.useRef(!1),a=zr.useRef(!1);return(0,wo.jsx)(mI,{...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")),mI=zr.forwardRef(ns(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=Kl(Uf,r),h=mh(r);return iu(),(0,wo.jsx)(qp,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:a,onUnmountAutoFocus:i,children:(0,wo.jsx)(Ys,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:d,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,wo.jsx)(Zs,{"data-state":a0(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 a0(e){return e?"open":"closed"}ns(a0,"getState");var pI=I4,hI=L4,gI=P4,bI=B4,i0=N4;var s0=require("react/jsx-runtime"),gu=pI,bu=gI,vI=hI,$l=yI.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>(0,s0.jsx)(bI,{children:(0,s0.jsx)(i0,{ref:o,align:t,sideOffset:n,className:ne("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})}));$l.displayName=i0.displayName;var l0=Ct(require("react"));var c0=require("react/jsx-runtime"),Qs=l0.forwardRef(({className:e,type:t,...n},r)=>(0,c0.jsx)("input",{type:t,className:ne("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}));Qs.displayName="Input";var z4=l0.forwardRef(({className:e,type:t,...n},r)=>(0,c0.jsx)("input",{type:t,className:ne("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}));Qs.displayName="Input";z4.displayName="InputWO";var b0=Ct(require("react"));var xn=Ct(require("react"),1);var wI=Ct(require("react"),1);var xI=require("react/jsx-runtime"),H4=Object.defineProperty,V4=(e,t)=>H4(e,"name",{value:t,configurable:!0}),W4=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"}),q4=wI.forwardRef(V4(function(t,n){return(0,xI.jsx)(hn.span,{...t,ref:n,style:{...W4,...t.style}})},"VisuallyHidden")),SI=q4;var So=require("react/jsx-runtime"),j4=Object.defineProperty,xo=(e,t)=>j4(e,"name",{value:t,configurable:!0}),[f0,xZ]=kr("Tooltip",[Fa]),m0=Fa(),G4="TooltipProvider",Y4=700,u0="tooltip.open",[K4,p0]=f0(G4),$4=xo(e=>{let{__scopeTooltip:t,delayDuration:n=Y4,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=e,i=xn.useRef(!0),s=xn.useRef(!1),l=xn.useRef(0);return xn.useEffect(()=>{let c=l.current;return()=>window.clearTimeout(c)},[]),(0,So.jsx)(K4,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:xn.useCallback(()=>{r<=0||(window.clearTimeout(l.current),i.current=!1)},[r]),onClose:xn.useCallback(()=>{r<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:xn.useCallback(c=>{s.current=c},[]),disableHoverableContent:o,children:a})},"TooltipProvider"),d0="Tooltip",[X4,Gf]=f0(d0),Z4=xo(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:a,disableHoverableContent:i,delayDuration:s}=e,l=p0(d0,e.__scopeTooltip),c=m0(t),[u,d]=xn.useState(null),[m,f]=xn.useState(void 0),h=Ai(),p=xn.useRef(0),g=i??l.disableHoverableContent,y=s??l.delayDuration,v=xn.useRef(!1),[b,S]=Lo({prop:r,defaultProp:o??!1,onChange:xo(x=>{x?(l.onOpen(),document.dispatchEvent(new CustomEvent(u0))):l.onClose(),a?.(x)},"onChange"),caller:d0}),C=xn.useMemo(()=>b?v.current?"delayed-open":"instant-open":"closed",[b]),w=xn.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v.current=!1,S(!0)},[S]),k=xn.useCallback(()=>{window.clearTimeout(p.current),p.current=0,S(!1)},[S]),M=xn.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{v.current=!0,S(!0),p.current=0},y)},[y,S]);return xn.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),(0,So.jsx)(Xs,{...c,children:(0,So.jsx)(X4,{scope:t,contentId:m??h,setContentId:f,open:b,stateAttribute:C,trigger:u,onTriggerChange:d,onTriggerEnter:xn.useCallback(()=>{l.isOpenDelayedRef.current?M():w()},[l.isOpenDelayedRef,M,w]),onTriggerLeave:xn.useCallback(()=>{g?k():(window.clearTimeout(p.current),p.current=0)},[k,g]),onOpen:w,onClose:k,disableHoverableContent:g,children:n})})},"Tooltip"),CI="TooltipTrigger",Q4=xn.forwardRef(xo(function(t,n){let{__scopeTooltip:r,...o}=t,a=Gf(CI,r),i=p0(CI,r),s=m0(r),l=xn.useRef(null),c=nn(n,l,a.onTriggerChange),u=xn.useRef(!1),d=xn.useRef(!1),m=xn.useCallback(()=>u.current=!1,[]);return xn.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),(0,So.jsx)(es,{asChild:!0,...s,children:(0,So.jsx)(hn.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")),kI="TooltipPortal",[J4,e3]=f0(kI,{forceMount:void 0}),t3=xo(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,a=Gf(kI,t);return(0,So.jsx)(J4,{scope:t,forceMount:n,children:(0,So.jsx)(Xo,{present:n||a.open,children:(0,So.jsx)(uu,{asChild:!0,container:o,children:r})})})},"TooltipPortal"),jf="TooltipContent",n3=xn.forwardRef(xo(function(t,n){let r=e3(jf,t.__scopeTooltip),{forceMount:o=r.forceMount,side:a="top",...i}=t,s=Gf(jf,t.__scopeTooltip);return(0,So.jsx)(Xo,{present:o||s.open,children:s.disableHoverableContent?(0,So.jsx)(TI,{side:a,...i,ref:n}):(0,So.jsx)(r3,{side:a,...i,ref:n})})},"TooltipContent")),r3=xn.forwardRef(xo(function(t,n){let r=Gf(jf,t.__scopeTooltip),o=p0(jf,t.__scopeTooltip),a=xn.useRef(null),i=nn(n,a),[s,l]=xn.useState(null),{trigger:c,onClose:u}=r,d=a.current,{onPointerInTransitChange:m}=o,f=xn.useCallback(()=>{l(null),m(!1)},[m]),h=xn.useCallback((p,g)=>{let y=p.currentTarget,v={x:p.clientX,y:p.clientY},b=II(v,y.getBoundingClientRect()),S=MI(v,b),C=LI(g.getBoundingClientRect()),w=PI([...S,...C]);l(w),m(!0)},[m]);return xn.useEffect(()=>()=>f(),[f]),xn.useEffect(()=>{if(c&&d){let p=xo(y=>h(y,d),"handleTriggerLeave"),g=xo(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]),xn.useEffect(()=>{if(s){let p=xo(g=>{let y=g.target,v={x:g.clientX,y:g.clientY},b=c?.contains(y)||d?.contains(y),S=!RI(v,s);b?f():S&&(f(),u())},"handleTrackPointerGrace");return document.addEventListener("pointermove",p),()=>document.removeEventListener("pointermove",p)}},[c,d,s,u,f]),(0,So.jsx)(TI,{...t,ref:i})},"TooltipContentHoverable")),o3=fy("TooltipContent"),TI=xn.forwardRef(xo(function(t,n){let{__scopeTooltip:r,children:o,"aria-label":a,id:i,onEscapeKeyDown:s,onPointerDownOutside:l,...c}=t,u=Gf(jf,r),d=m0(r),{onClose:m}=u;xn.useEffect(()=>(document.addEventListener(u0,m),()=>document.removeEventListener(u0,m)),[m]),xn.useEffect(()=>{if(u.trigger){let h=xo(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 $r(()=>(f(i),()=>{f(void 0)}),[i,f]),(0,So.jsx)(Ys,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:(0,So.jsxs)(Zs,{"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:[(0,So.jsx)(o3,{children:o}),a?(0,So.jsx)(SI,{id:u.contentId,role:"tooltip",children:a}):null]})})},"TooltipContentImpl"));function II(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")}}xo(II,"getExitSideFromRect");function MI(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}xo(MI,"getPaddedExitPoints");function LI(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}]}xo(LI,"getPointsFromRect");function RI(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}xo(RI,"isPointInPolygon");function PI(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),DI(t)}xo(PI,"getHull");function DI(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)}xo(DI,"getHullPresorted");var AI=$4,BI=Z4,h0=Q4,NI=t3,g0=n3;var ph=require("react/jsx-runtime"),hh=AI,Gt=BI,qt=b0.forwardRef(({children:e,asChild:t,...n},r)=>(0,ph.jsx)(h0,{ref:r,asChild:t??!0,...n,children:e}));qt.displayName=h0.displayName;var Ut=b0.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,ph.jsx)(NI,{children:(0,ph.jsx)(g0,{ref:r,sideOffset:t,className:ne("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})}));Ut.displayName=g0.displayName;var Dn=require("react/jsx-runtime");function gh(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 i3(e){return e.slice(0,7)}function s3(e){let t=parseInt(e.slice(7,9),16);return Math.round(t/255*100)}function l3(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 EI(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 OI(){let e=Gr(Pn.colorSwatches,null);return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function _I(e){Sr(Pn.colorSwatches,e)}var Ho=(0,zo.forwardRef)(({disabled:e,value:t,onChange:n,onBlur:r,name:o,className:a,presets:i,hideButton:s,open:l,onOpenChange:c,...u},d)=>{let m=gk(d),[f,h]=(0,zo.useState)(!1),p=l!==void 0?l:f,g=c??h,[y,v]=(0,zo.useState)(OI);(0,zo.useEffect)(()=>Tc(()=>v(OI())),[]);let b=(0,zo.useMemo)(()=>gh(t||"#ffffffff"),[t]),S=i3(b),C=s3(b),w=EI(b),k=b.slice(0,7),[M,I]=(0,zo.useState)(b);(0,zo.useEffect)(()=>{I(b)},[b]);let x=(0,zo.useCallback)(N=>{let O=b.slice(7,9);n(N+O)},[b,n]),T=(0,zo.useCallback)(N=>{n(l3(b,parseInt(N.target.value)))},[b,n]),R=(0,zo.useCallback)(()=>{if(y.includes(b))return;let N=[...y,b].slice(-16);v(N),_I(N)},[b,y]),P=(0,zo.useCallback)(N=>{let O=y.filter(A=>A!==N);v(O),_I(O)},[y]),D=({label:N,colors:O,removable:A})=>O.length?(0,Dn.jsxs)("div",{className:"mt-3",children:[(0,Dn.jsx)("span",{className:"text-[10px] text-muted-foreground font-medium uppercase tracking-widest",children:N}),(0,Dn.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:O.map(B=>{let E=EI(gh(B));return(0,Dn.jsxs)("div",{className:"relative group",children:[(0,Dn.jsxs)(Gt,{children:[(0,Dn.jsx)(qt,{asChild:!0,children:(0,Dn.jsx)(br,{onMouseDown:()=>{n(gh(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"}})}),(0,Dn.jsx)(Ut,{className:"bg-background border border-border z-[400]",children:B})]}),A&&(0,Dn.jsx)("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:(0,Dn.jsx)(Kr,{className:"w-2 h-2"})})]},B)})})]}):null;return(0,Dn.jsxs)(gu,{onOpenChange:g,open:p,children:[s?(0,Dn.jsx)(vI,{asChild:!0,children:(0,Dn.jsx)("span",{className:"absolute inset-0 pointer-events-none"})}):(0,Dn.jsx)(bu,{asChild:!0,disabled:e,onBlur:r,children:(0,Dn.jsx)(br,{...u,className:ne("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:(0,Dn.jsx)("div",{})})}),(0,Dn.jsxs)($l,{className:"w-full z-[300]",children:[(0,Dn.jsx)(hk,{color:S,onChange:x}),(0,Dn.jsxs)("div",{className:"mt-3 flex flex-col gap-1",children:[(0,Dn.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Dn.jsx)("span",{className:"text-[10px] text-muted-foreground font-medium uppercase tracking-widest",children:"Opacity"}),(0,Dn.jsxs)("span",{className:"text-[11px] font-mono text-muted-foreground tabular-nums w-9 text-right",children:[C,"%"]})]}),(0,Dn.jsxs)("div",{className:"relative h-3 flex items-center",children:[(0,Dn.jsx)("div",{className:"absolute inset-0 rounded-full overflow-hidden",style:{backgroundImage:"repeating-conic-gradient(#888 0% 25%, #555 0% 50%)",backgroundSize:"8px 8px"}}),(0,Dn.jsx)("div",{className:"absolute inset-0 rounded-full",style:{background:`linear-gradient(to right, transparent, ${k})`}}),(0,Dn.jsx)("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"})]})]}),(0,Dn.jsxs)("div",{className:"flex flex-row gap-2 mt-3",children:[(0,Dn.jsx)("div",{className:"!w-36",children:(0,Dn.jsx)(Qs,{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(gh(O))},onBlur:()=>{I(b)}})}),(0,Dn.jsxs)(Gt,{delayDuration:700,children:[(0,Dn.jsx)(qt,{asChild:!0,children:(0,Dn.jsx)(br,{variant:"outline",className:"hover:bg-muted",onClick:R,disabled:y.includes(b),children:(0,Dn.jsx)(pa,{})})}),(0,Dn.jsx)(Ut,{className:"bg-background border border-border z-[400]",children:"Save current color"})]})]}),i&&i.length>0&&(0,Dn.jsx)(D,{label:"Presets",colors:i}),(0,Dn.jsx)(D,{label:"Saved",colors:y,removable:!0}),(0,Dn.jsx)("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
|
+
`})]})]})});Ho.displayName="ColorPicker";var cM=Ct(require("react"));var ar=Ct(require("react"),1);var c3=Object.defineProperty,u3=(e,t)=>c3(e,"name",{value:t,configurable:!0});function bh(e,[t,n]){return Math.min(n,Math.max(t,e))}u3(bh,"clamp");var yh=Ct(require("react"),1),m3=require("react/jsx-runtime"),d3=Object.defineProperty,f3=(e,t)=>d3(e,"name",{value:t,configurable:!0}),p3=yh.createContext(void 0);function Xl(e){let t=yh.useContext(p3);return e||t||"ltr"}f3(Xl,"useDirection");var vh=Ct(require("react"),1),h3=Object.defineProperty,g3=(e,t)=>h3(e,"name",{value:t,configurable:!0});function y0(e){let t=vh.useRef({value:e,previous:e});return vh.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}g3(y0,"usePrevious");var bi=Ct(require("react"),1);var wh=require("react/jsx-runtime"),oa=Ct(require("react"),1);var Zl=require("react/jsx-runtime");var b3=Object.defineProperty,Co=(e,t)=>b3(e,"name",{value:t,configurable:!0});function Ql(e){let t=e+"CollectionProvider",[n,r]=kr(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=Co(p=>{let{scope:g,children:y}=p,v=bi.useRef(null),b=bi.useRef(new Map).current;return(0,wh.jsx)(o,{scope:g,itemMap:b,collectionRef:v,children:y})},"CollectionProvider");i.displayName=t;let s=e+"CollectionSlot",l=ta(s),c=bi.forwardRef((p,g)=>{let{scope:y,children:v}=p,b=a(s,y),S=nn(g,b.collectionRef);return(0,wh.jsx)(l,{ref:S,children:v})});c.displayName=s;let u=e+"CollectionItemSlot",d="data-radix-collection-item",m=ta(u),f=bi.forwardRef((p,g)=>{let{scope:y,children:v,...b}=p,S=bi.useRef(null),C=nn(g,S),w=a(u,y);return bi.useEffect(()=>(w.itemMap.set(S,{ref:S,...b}),()=>{w.itemMap.delete(S)})),(0,wh.jsx)(m,{[d]:"",ref:C,children:v})});f.displayName=u;function h(p){let g=a(e+"CollectionConsumer",p);return bi.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 Co(h,"useCollection"),[{Provider:i,Slot:c,ItemSlot:f},h,r]}Co(Ql,"createCollection");var FI=new WeakMap,ao,ba,v0=(ba=class extends Map{constructor(n){super(n);mx(this,ao);Eg(this,ao,[...super.keys()]),FI.set(this,!0)}set(n,r){return FI.get(this)&&(this.has(n)?Oo(this,ao)[Oo(this,ao).indexOf(n)]=n:Oo(this,ao).push(n)),super.set(n,r),this}insert(n,r,o){let a=this.has(r),i=Oo(this,ao).length,s=x0(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=[...Oo(this,ao)],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 ba(this);return a.insert(n,r,o),a}before(n){let r=Oo(this,ao).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,o){let a=Oo(this,ao).indexOf(n);return a===-1?this:this.insert(a,r,o)}after(n){let r=Oo(this,ao).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=Oo(this,ao).indexOf(n);return a===-1?this:this.insert(a+1,r,o)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Eg(this,ao,[]),super.clear()}delete(n){let r=super.delete(n);return r&&Oo(this,ao).splice(Oo(this,ao).indexOf(n),1),r}deleteAt(n){let r=this.keyAt(n);return r!==void 0?this.delete(r):!1}at(n){let r=xh(Oo(this,ao),n);if(r!==void 0)return this.get(r)}entryAt(n){let r=xh(Oo(this,ao),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return Oo(this,ao).indexOf(n)}keyAt(n){return xh(Oo(this,ao),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 ba(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 ba(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 ba(r)}toReversed(){let n=new ba;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 ba(r)}slice(n,r){let o=new ba,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}},ao=new WeakMap,Co(ba,"OrderedDict"),ba);function xh(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);let n=zI(e,t);return n===-1?void 0:e[n]}Co(xh,"at");function zI(e,t){let n=e.length,r=x0(t),o=r>=0?r:n+r;return o<0||o>=n?-1:o}Co(zI,"toSafeIndex");function x0(e){return e!==e||e===0?0:Math.trunc(e)}Co(x0,"toSafeInteger");function y3(e){let t=e+"CollectionProvider",[n,r]=kr(t),[o,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new v0,setItemMap:Co(()=>{},"setItemMap")}),i=Co(({state:b,...S})=>b?(0,Zl.jsx)(l,{...S,state:b}):(0,Zl.jsx)(s,{...S}),"CollectionProvider");i.displayName=t;let s=Co(b=>{let S=g();return(0,Zl.jsx)(l,{...b,state:S})},"CollectionInit");s.displayName=t+"Init";let l=Co(b=>{let{scope:S,children:C,state:w}=b,k=oa.useRef(null),[M,I]=oa.useState(null),x=nn(k,I),[T,R]=w;return oa.useEffect(()=>{if(!M)return;let P=WI(()=>{});return P.observe(M,{childList:!0,subtree:!0}),()=>{P.disconnect()}},[M]),(0,Zl.jsx)(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=ta(c),d=oa.forwardRef((b,S)=>{let{scope:C,children:w}=b,k=a(c,C),M=nn(S,k.collectionRef);return(0,Zl.jsx)(u,{ref:M,children:w})});d.displayName=c;let m=e+"CollectionItemSlot",f="data-radix-collection-item",h=ta(m),p=oa.forwardRef((b,S)=>{let{scope:C,children:w,...k}=b,M=oa.useRef(null),[I,x]=oa.useState(null),T=nn(S,M,x),R=a(m,C),{setItemMap:P}=R,D=oa.useRef(k);HI(D.current,k)||(D.current=k);let N=D.current;return oa.useEffect(()=>{let O=N;return P(A=>I?A.has(I)?A.set(I,{...O,element:I}).toSorted(w0):(A.set(I,{...O,element:I}),A.toSorted(w0)):A),()=>{P(A=>!I||!A.has(I)?A:(A.delete(I),new v0(A)))}},[I,N,P]),(0,Zl.jsx)(h,{[f]:"",ref:T,children:w})});p.displayName=m;function g(){return oa.useState(new v0)}Co(g,"useInitCollection");function y(b){let{itemMap:S}=a(e+"CollectionConsumer",b);return S}return Co(y,"useCollection"),[{Provider:i,Slot:d,ItemSlot:p},{createCollectionScope:r,useCollection:y,useInitCollection:g}]}Co(y3,"createCollection");function HI(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}Co(HI,"shallowEqual");function VI(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Co(VI,"isElementPreceding");function w0(e,t){return!e[1].element||!t[1].element?0:VI(e[1].element,t[1].element)?-1:1}Co(w0,"sortByDocumentPosition");function WI(e){return new MutationObserver(n=>{for(let r of n)if(r.type==="childList"){e();return}})}Co(WI,"getChildListObserver");var Dr=require("react/jsx-runtime"),v3=Object.defineProperty,Xn=(e,t)=>v3(e,"name",{value:t,configurable:!0}),UI=["PageUp","PageDown"],jI=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],GI={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Kf="Slider",[C0,w3,x3]=Ql(Kf),[k0,tQ]=kr(Kf,[x3]),[S3,$f]=k0(Kf),T0=ar.forwardRef(Xn(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=Xn(()=>{},"onValueChange"),onValueCommit:f=Xn(()=>{},"onValueCommit"),inverted:h=!1,form:p,...g}=t,y=ar.useRef(new Set),v=ar.useRef(0),b=ar.useRef(!1),C=s==="horizontal"?C3:k3,[w,k]=ar.useState(null),M=nn(n,k),[I=[],x]=Lo({prop:d,defaultProp:u,onChange:Xn(A=>{[...y.current][v.current]?.focus({preventScroll:!0,focusVisible:b.current}),b.current=!1,m(A)},"onChange")}),T=ar.useRef(I),R=ar.useRef(I);ar.useEffect(()=>{let A=p?w?.ownerDocument.getElementById(p):w?.closest("form");if(A instanceof HTMLFormElement){let B=Xn(()=>x(R.current),"reset");return A.addEventListener("reset",B),()=>A.removeEventListener("reset",B)}},[w,p,x]);function P(A){let B=rM(I,A);O(A,B)}Xn(P,"handleSlideStart");function D(A){O(A,v.current)}Xn(D,"handleSlideMove");function N(){String(I)!==String(T.current)&&f(I)}Xn(N,"handleSlideEnd");function O(A,B,{commit:E}={commit:!1}){let L=M0(i),H=Yf(Math.round((A-o)/i)*i+o,L),K=bh(H,[o,a]);x((G=[])=>{let V=tM(G,K,B);if(iM(V,c*i)){v.current=V.indexOf(K);let q=String(V)!==String(G);return q&&E&&f(V),q?V:G}else return G})}return Xn(O,"updateValues"),(0,Dr.jsx)(S3,{scope:t.__scopeSlider,name:r,disabled:l,min:o,max:a,valueIndexToChangeRef:v,thumbs:y.current,values:I,orientation:s,form:p,children:(0,Dr.jsx)(C0.Provider,{scope:t.__scopeSlider,children:(0,Dr.jsx)(C0.Slot,{scope:t.__scopeSlider,children:(0,Dr.jsx)(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 H=UI.includes(A.key)||A.shiftKey&&jI.includes(A.key)?10:1,K=v.current,G=I[K],V=sM(G,{min:o,step:i,direction:B,multiplier:H});O(V,K,{commit:!0})}}})})})})},"Slider")),[YI,KI]=k0(Kf,{startEdge:"left",endEdge:"right",size:"width",direction:1}),C3=ar.forwardRef(Xn(function(t,n){let{min:r,max:o,dir:a,inverted:i,onSlideStart:s,onSlideMove:l,onSlideEnd:c,onStepKeyDown:u,...d}=t,[m,f]=ar.useState(null),h=nn(n,f),p=ar.useRef(void 0),g=Xl(a),y=g==="ltr",v=y&&!i||!y&&i;function b(S){let C=p.current||m.getBoundingClientRect(),w=[0,C.width],M=Sh(w,v?[r,o]:[o,r]);return p.current=C,M(S-C.left)}return Xn(b,"getValueFromPointer"),(0,Dr.jsx)(YI,{scope:t.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:(0,Dr.jsx)($I,{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=GI[v?"from-left":"from-right"].includes(S.key);u?.({event:S,direction:w?-1:1})}})})},"SliderHorizontal")),k3=ar.forwardRef(Xn(function(t,n){let{min:r,max:o,inverted:a,onSlideStart:i,onSlideMove:s,onSlideEnd:l,onStepKeyDown:c,...u}=t,d=ar.useRef(null),m=nn(n,d),f=ar.useRef(void 0),h=!a;function p(g){let y=f.current||d.current.getBoundingClientRect(),v=[0,y.height],S=Sh(v,h?[o,r]:[r,o]);return f.current=y,S(g-y.top)}return Xn(p,"getValueFromPointer"),(0,Dr.jsx)(YI,{scope:t.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1,children:(0,Dr.jsx)($I,{"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=GI[h?"from-bottom":"from-top"].includes(g.key);c?.({event:g,direction:v?-1:1})}})})},"SliderVertical")),$I=ar.forwardRef(Xn(function(t,n){let{__scopeSlider:r,onSlideStart:o,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:s,onEndKeyDown:l,onStepKeyDown:c,...u}=t,d=$f(Kf,r);return(0,Dr.jsx)(hn.span,{...u,ref:n,onKeyDown:lt(t.onKeyDown,m=>{m.key==="Home"?(s(m),m.preventDefault()):m.key==="End"?(l(m),m.preventDefault()):UI.concat(jI).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")),T3="SliderTrack",XI=ar.forwardRef(Xn(function(t,n){let{__scopeSlider:r,...o}=t,a=$f(T3,r);return(0,Dr.jsx)(hn.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...o,ref:n})},"SliderTrack")),qI="SliderRange",ZI=ar.forwardRef(Xn(function(t,n){let{__scopeSlider:r,...o}=t,a=$f(qI,r),i=KI(qI,r),s=ar.useRef(null),l=nn(n,s),c=a.values.length,u=a.values.map(f=>I0(f,a.min,a.max)),d=c>1?Math.min(...u):0,m=100-Math.max(...u);return(0,Dr.jsx)(hn.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...o,ref:l,style:{...t.style,[i.startEdge]:d+"%",[i.endEdge]:m+"%"}})},"SliderRange")),I3="SliderThumb",[M3,QI]=k0(I3),L3="SliderThumbProvider";function JI(e){let{__scopeSlider:t,name:n,children:r,internal_do_not_use_render:o}=e,a=$f(L3,t),i=w3(t),[s,l]=ar.useState(null),c=ar.useMemo(()=>s?i().findIndex(g=>g.ref.current===s):-1,[i,s]),u=Xi(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:I0(m,a.min,a.max);ar.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(0,Dr.jsx)(M3,{scope:t,...p,children:lM(o)?o(p):r})}Xn(JI,"SliderThumbProvider");var S0="SliderThumbTrigger",R3=ar.forwardRef(Xn(function(t,n){let{__scopeSlider:r,...o}=t,a=$f(S0,r),i=KI(S0,r),{index:s,value:l,percent:c,size:u,onThumbChange:d}=QI(S0,r),m=nn(n,d),f=nM(s,a.values.length),h=u?.[i.size],p=h?oM(h,c,i.direction):0;return(0,Dr.jsx)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${c}% + ${p}px)`},children:(0,Dr.jsx)(C0.ItemSlot,{scope:r,children:(0,Dr.jsx)(hn.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")),eM=ar.forwardRef(Xn(function(t,n){let{__scopeSlider:r,name:o,...a}=t;return(0,Dr.jsx)(JI,{__scopeSlider:r,name:o,internal_do_not_use_render:({index:i,isFormControl:s})=>(0,Dr.jsxs)(Dr.Fragment,{children:[(0,Dr.jsx)(R3,{...a,ref:n,__scopeSlider:r}),s?(0,Dr.jsx)(D3,{__scopeSlider:r},i):null]})})},"SliderThumb")),P3="SliderBubbleInput",D3=ar.forwardRef(Xn(function({__scopeSlider:t,...n},r){let{value:o,name:a,form:i}=QI(P3,t),s=ar.useRef(null),l=nn(s,r),c=y0(o);return ar.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]),(0,Dr.jsx)(hn.input,{style:{display:"none"},name:a,form:i,...n,ref:l,defaultValue:o})},"SliderBubbleInput"));function tM(e=[],t,n){let r=[...e];return r[n]=t,r.sort((o,a)=>o-a)}Xn(tM,"getNextSortedValues");function I0(e,t,n){let a=100/(n-t)*(e-t);return bh(a,[0,100])}Xn(I0,"convertValueToPercentage");function nM(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}Xn(nM,"getLabel");function rM(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)}Xn(rM,"getClosestValueIndex");function oM(e,t,n){let r=e/2,a=Sh([0,50],[0,r]);return(r-a(t)*n)*n}Xn(oM,"getThumbInBoundsOffset");function aM(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}Xn(aM,"getStepsBetweenValues");function iM(e,t){if(t>0){let n=aM(e);return Math.min(...n)>=t}return!0}Xn(iM,"hasMinStepsBetweenValues");function Sh(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])}}Xn(Sh,"linearScale");function M0(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}Xn(M0,"getDecimalCount");function Yf(e,t){let n=Math.pow(10,t);return Math.round(e*n)/n}Xn(Yf,"roundValue");function sM(e,{min:t,step:n,direction:r,multiplier:o}){let a=M0(n),i=(e-t)/n,s=Math.round(i),l=Yf(s*n+t,a)===Yf(e,a),c;return l?c=s+o*r:r>0?c=Math.ceil(i):c=Math.floor(i),Yf(c*n+t,a)}Xn(sM,"getNextStepValue");function lM(e){return typeof e=="function"}Xn(lM,"isFunction");var yu=require("react/jsx-runtime"),Wn=cM.forwardRef(({className:e,...t},n)=>(0,yu.jsxs)(T0,{ref:n,className:ne("relative flex w-full touch-none select-none items-center",e),...t,children:[(0,yu.jsx)(XI,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-muted",children:(0,yu.jsx)(ZI,{className:"absolute h-full bg-muted-foreground/30"})}),(0,yu.jsx)(eM,{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"})]}));Wn.displayName=T0.displayName;var rs=Ct(require("react"));var Vo=Ct(require("react"),1);var Kt=Ct(require("react"),1);var ko=Ct(require("react"),1);var N3=Ct(require("react"),1),Ch=Ct(require("react"),1),B3=Object.defineProperty,R0=(e,t)=>B3(e,"name",{value:t,configurable:!0}),L0=!1;function uM(){let[e,t]=Ch.useState(L0);return Ch.useEffect(()=>{L0||(L0=!0,t(!0))},[]),e}R0(uM,"useIsHydrated");var dM=N3[" useSyncExternalStore ".trim().toString()];function fM(){return()=>{}}R0(fM,"subscribe");function mM(){return dM(fM,()=>!0,()=>!1)}R0(mM,"useIsHydratedModern");var pM=typeof dM=="function"?mM:uM;var Js=require("react/jsx-runtime"),E3=Object.defineProperty,Jl=(e,t)=>E3(e,"name",{value:t,configurable:!0}),P0="rovingFocusGroup.onEntryFocus",O3={bubbles:!1,cancelable:!0},kh="RovingFocusGroup",[D0,hM,_3]=Ql(kh),[F3,A0]=kr(kh,[_3]),[z3,H3]=F3(kh),V3=ko.forwardRef(Jl(function(t,n){return(0,Js.jsx)(D0.Provider,{scope:t.__scopeRovingFocusGroup,children:(0,Js.jsx)(D0.Slot,{scope:t.__scopeRovingFocusGroup,children:(0,Js.jsx)(W3,{...t,ref:n})})})},"RovingFocusGroup")),W3=ko.forwardRef(Jl(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=ko.useRef(null),h=nn(n,f),p=Xl(i),[g,y]=Lo({prop:s,defaultProp:l??null,onChange:c,caller:kh}),[v,b]=ko.useState(!1),S=na(u),C=hM(r),w=ko.useRef(!1),[k,M]=ko.useState(0);return ko.useEffect(()=>{let I=f.current;if(I)return I.addEventListener(P0,S),()=>I.removeEventListener(P0,S)},[S]),(0,Js.jsx)(z3,{scope:r,orientation:o,dir:p,loop:a,currentTabStopId:g,onItemFocus:ko.useCallback(I=>y(I),[y]),onItemShiftTab:ko.useCallback(()=>b(!0),[]),onFocusableItemAdd:ko.useCallback(()=>M(I=>I+1),[]),onFocusableItemRemove:ko.useCallback(()=>M(I=>I-1),[]),children:(0,Js.jsx)(hn.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(P0,O3);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);B0(O,d)}}w.current=!1}),onBlur:lt(t.onBlur,()=>b(!1))})})},"RovingFocusGroupImpl")),q3="RovingFocusGroupItem",U3=ko.forwardRef(Jl(function(t,n){let{__scopeRovingFocusGroup:r,focusable:o=!0,active:a=!1,tabStopId:i,children:s,...l}=t,c=Ai(),u=i||c,d=H3(q3,r),m=d.currentTabStopId===u,f=hM(r),{onFocusableItemAdd:h,onFocusableItemRemove:p,currentTabStopId:g}=d,y=pM();return $r(()=>{if(!(!y||!o))return h(),()=>p()},[y,o,h,p]),ko.useEffect(()=>{if(!(y||!o))return h(),()=>p()},[y,o,h,p]),(0,Js.jsx)(D0.ItemSlot,{scope:r,id:u,focusable:o,active:a,children:(0,Js.jsx)(hn.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=bM(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?yM(C,w+1):C.slice(w+1)}setTimeout(()=>B0(C))}}),children:typeof s=="function"?s({isCurrentTabStop:m,hasTabStop:g!=null}):s})})},"RovingFocusGroupItem")),j3={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function gM(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Jl(gM,"getDirectionAwareKey");function bM(e,t,n){let r=gM(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return j3[r]}Jl(bM,"getFocusIntent");function B0(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Jl(B0,"focusFirst");function yM(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Jl(yM,"wrapArray");var vM=V3,wM=U3;var An=require("react/jsx-runtime"),Y3=Object.defineProperty,Zn=(e,t)=>Y3(e,"name",{value:t,configurable:!0}),N0=["Enter"," "],K3=["ArrowDown","PageUp","Home"],SM=["ArrowUp","PageDown","End"],$3=[...K3,...SM],X3={ltr:[...N0,"ArrowRight"],rtl:[...N0,"ArrowLeft"]},Z3={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ih="Menu",[Xf,Q3,J3]=Ql(Ih),[ec,O0]=kr(Ih,[J3,Fa,A0]),_0=Fa(),CM=A0(),[ez,tc]=ec(Ih),[tz,Qf]=ec(Ih),nz=Zn(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:i=!0}=e,s=_0(t),[l,c]=Kt.useState(null),u=Kt.useRef(!1),d=na(a),m=Xl(o);return Kt.useEffect(()=>{let f=Zn(()=>{u.current=!0,document.addEventListener("pointerdown",h,{capture:!0,once:!0}),document.addEventListener("pointermove",h,{capture:!0,once:!0})},"handleKeyDown"),h=Zn(()=>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})}},[]),Kt.useEffect(()=>{if(!n)return;let f=Zn(()=>d(!1),"handleBlur");return window.addEventListener("blur",f),()=>window.removeEventListener("blur",f)},[n,d]),(0,An.jsx)(Xs,{...s,children:(0,An.jsx)(ez,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:(0,An.jsx)(tz,{scope:t,onClose:Kt.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:m,modal:i,children:r})})})},"Menu"),kM=Kt.forwardRef(Zn(function(t,n){let{__scopeMenu:r,...o}=t,a=_0(r);return(0,An.jsx)(es,{...a,...o,ref:n})},"MenuAnchor")),TM="MenuPortal",[rz,IM]=ec(TM,{forceMount:void 0}),oz=Zn(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=tc(TM,t);return(0,An.jsx)(rz,{scope:t,forceMount:n,children:(0,An.jsx)(Xo,{present:n||a.open,children:(0,An.jsx)(uu,{asChild:!0,container:o,children:r})})})},"MenuPortal"),yi="MenuContent",[az,F0]=ec(yi),iz=Kt.forwardRef(Zn(function(t,n){let r=IM(yi,t.__scopeMenu),{forceMount:o=r.forceMount,...a}=t,i=tc(yi,t.__scopeMenu),s=Qf(yi,t.__scopeMenu);return(0,An.jsx)(Xf.Provider,{scope:t.__scopeMenu,children:(0,An.jsx)(Xo,{present:o||i.open,children:(0,An.jsx)(Xf.Slot,{scope:t.__scopeMenu,children:s.modal?(0,An.jsx)(sz,{...a,ref:n}):(0,An.jsx)(lz,{...a,ref:n})})})})},"MenuContent")),sz=Kt.forwardRef(Zn(function(t,n){let r=tc(yi,t.__scopeMenu),o=Kt.useRef(null),a=nn(n,o);return Kt.useEffect(()=>{let i=o.current;if(i)return ih(i)},[]),(0,An.jsx)(z0,{...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")),lz=Kt.forwardRef(Zn(function(t,n){let r=tc(yi,t.__scopeMenu);return(0,An.jsx)(z0,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),cz=ta("MenuContent.ScrollLock"),z0=Kt.forwardRef(Zn(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=tc(yi,r),v=Qf(yi,r),b=_0(r),S=CM(r),C=Q3(r),[w,k]=Kt.useState(null),M=Kt.useRef(null),I=nn(n,M,y.onContentChange),x=Kt.useRef(0),T=Kt.useRef(""),R=Kt.useRef(0),P=Kt.useRef(null),D=Kt.useRef("right"),N=Kt.useRef(0),O=p?qf:Kt.Fragment,A=p?{as:cz,allowPinchZoom:!0}:void 0,B=Zn(L=>{let H=T.current+L,K=C().filter($=>!$.disabled),G=document.activeElement,V=K.find($=>$.ref.current===G)?.textValue,q=K.map($=>$.textValue),j=BM(q,H,V),W=K.find($=>$.textValue===j)?.ref.current;Zn((function $(J){T.current=J,window.clearTimeout(x.current),J!==""&&(x.current=window.setTimeout(()=>$(""),1e3))}),"updateSearch")(H),W&&setTimeout(()=>W.focus())},"handleTypeaheadSearch");Kt.useEffect(()=>()=>window.clearTimeout(x.current),[]),iu();let E=Kt.useCallback(L=>D.current===P.current?.side&&EM(L,P.current?.area),[]);return(0,An.jsx)(az,{scope:r,searchRef:T,onItemEnter:Kt.useCallback(L=>{E(L)&&L.preventDefault()},[E]),onItemLeave:Kt.useCallback(L=>{E(L)||(M.current?.focus(),k(null))},[E]),onTriggerLeave:Kt.useCallback(L=>{E(L)&&L.preventDefault()},[E]),pointerGraceTimerRef:R,onPointerGraceIntentChange:Kt.useCallback(L=>{P.current=L},[]),children:(0,An.jsx)(O,{...A,children:(0,An.jsx)(qp,{asChild:!0,trapped:a,onMountAutoFocus:lt(i,L=>{L.preventDefault(),M.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:(0,An.jsx)(Ys,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:f,onDismiss:h,children:(0,An.jsx)(vM,{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:(0,An.jsx)(Zs,{role:"menu","aria-orientation":"vertical","data-state":V0(y.open),"data-radix-menu-content":"",dir:v.dir,...b,...g,ref:I,style:{outline:"none",...g.style},onKeyDown:lt(g.onKeyDown,L=>{let K=L.target.closest("[data-radix-menu-content]")===L.currentTarget,G=L.ctrlKey||L.altKey||L.metaKey,V=L.key.length===1;K&&(L.key==="Tab"&&L.preventDefault(),!G&&V&&B(L.key));let q=M.current;if(L.target!==q||!$3.includes(L.key))return;L.preventDefault();let W=C().filter($=>!$.disabled).map($=>$.ref.current);SM.includes(L.key)&&W.reverse(),DM(W)}),onBlur:lt(t.onBlur,L=>{L.currentTarget.contains(L.target)||(window.clearTimeout(x.current),T.current="")}),onPointerMove:lt(t.onPointerMove,vu(L=>{let H=L.target,K=N.current!==L.clientX;if(L.currentTarget.contains(H)&&K){let G=L.clientX>N.current?"right":"left";D.current=G,N.current=L.clientX}}))})})})})})})},"MenuContentImpl"));var uz=Kt.forwardRef(Zn(function(t,n){let{__scopeMenu:r,...o}=t;return(0,An.jsx)(hn.div,{...o,ref:n})},"MenuLabel")),E0="MenuItem",xM="menu.itemSelect",H0=Kt.forwardRef(Zn(function(t,n){let{disabled:r=!1,onSelect:o,...a}=t,i=Kt.useRef(null),s=Qf(E0,t.__scopeMenu),l=F0(E0,t.__scopeMenu),c=nn(n,i),u=Kt.useRef(!1),d=Zn(()=>{let m=i.current;if(!r&&m){let f=new CustomEvent(xM,{bubbles:!0,cancelable:!0});m.addEventListener(xM,h=>o?.(h),{once:!0}),Pf(m,f),f.defaultPrevented?u.current=!1:s.onClose()}},"handleSelect");return(0,An.jsx)(MM,{...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===" "||N0.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})},"MenuItem")),MM=Kt.forwardRef(Zn(function(t,n){let{__scopeMenu:r,disabled:o=!1,textValue:a,...i}=t,s=F0(E0,r),l=CM(r),c=Kt.useRef(null),u=nn(n,c),[d,m]=Kt.useState(!1),[f,h]=Kt.useState("");return Kt.useEffect(()=>{let p=c.current;p&&h((p.textContent??"").trim())},[i.children]),(0,An.jsx)(Xf.ItemSlot,{scope:r,disabled:o,textValue:a??f,children:(0,An.jsx)(wM,{asChild:!0,...l,focusable:!o,children:(0,An.jsx)(hn.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,vu(p=>{o?s.onItemLeave(p):(s.onItemEnter(p),p.defaultPrevented||p.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:lt(t.onPointerLeave,vu(p=>s.onItemLeave(p))),onFocus:lt(t.onFocus,()=>m(!0)),onBlur:lt(t.onBlur,()=>m(!1))})})})},"MenuItemImpl")),dz=Kt.forwardRef(Zn(function(t,n){let{checked:r=!1,onCheckedChange:o,...a}=t;return(0,An.jsx)(RM,{scope:t.__scopeMenu,checked:r,children:(0,An.jsx)(H0,{role:"menuitemcheckbox","aria-checked":Zf(r)?"mixed":r,...a,ref:n,"data-state":Mh(r),onSelect:lt(a.onSelect,()=>o?.(Zf(r)?!0:!r),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),fz="MenuRadioGroup",[BQ,mz]=ec(fz,{value:void 0,onValueChange:Zn(()=>{},"onValueChange")});var pz="MenuRadioItem",hz=Kt.forwardRef(Zn(function(t,n){let{value:r,...o}=t,a=mz(pz,t.__scopeMenu),i=r===a.value;return(0,An.jsx)(RM,{scope:t.__scopeMenu,checked:i,children:(0,An.jsx)(H0,{role:"menuitemradio","aria-checked":i,...o,ref:n,"data-state":Mh(i),onSelect:lt(o.onSelect,()=>a.onValueChange?.(r),{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),LM="MenuItemIndicator",[RM,gz]=ec(LM,{checked:!1}),bz=Kt.forwardRef(Zn(function(t,n){let{__scopeMenu:r,forceMount:o,...a}=t,i=gz(LM,r);return(0,An.jsx)(Xo,{present:o||Zf(i.checked)||i.checked===!0,children:(0,An.jsx)(hn.span,{...a,ref:n,"data-state":Mh(i.checked)})})},"MenuItemIndicator")),yz=Kt.forwardRef(Zn(function(t,n){let{__scopeMenu:r,...o}=t;return(0,An.jsx)(hn.div,{role:"separator","aria-orientation":"horizontal",...o,ref:n})},"MenuSeparator"));var vz="MenuSub",[NQ,PM]=ec(vz);var Th="MenuSubTrigger",wz=Kt.forwardRef(Zn(function(t,n){let r=tc(Th,t.__scopeMenu),o=Qf(Th,t.__scopeMenu),a=PM(Th,t.__scopeMenu),i=F0(Th,t.__scopeMenu),s=Kt.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=i,u={__scopeMenu:t.__scopeMenu},d=Kt.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);Kt.useEffect(()=>d,[d]),Kt.useEffect(()=>{let f=l.current;return()=>{window.clearTimeout(f),c(null)}},[l,c]);let m=nn(n,a.onTriggerChange);return(0,An.jsx)(kM,{asChild:!0,...u,children:(0,An.jsx)(MM,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?a.contentId:void 0,"data-state":V0(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,vu(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,vu(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===" "||X3[o.dir].includes(f.key)&&(r.onOpenChange(!0),r.content?.focus(),f.preventDefault())})})})},"MenuSubTrigger")),xz="MenuSubContent",Sz=Kt.forwardRef(Zn(function(t,n){let r=IM(yi,t.__scopeMenu),{forceMount:o=r.forceMount,align:a="start",...i}=t,s=tc(yi,t.__scopeMenu),l=Qf(yi,t.__scopeMenu),c=PM(xz,t.__scopeMenu),u=Kt.useRef(null),d=nn(n,u);return(0,An.jsx)(Xf.Provider,{scope:t.__scopeMenu,children:(0,An.jsx)(Xo,{present:o||s.open,children:(0,An.jsx)(Xf.Slot,{scope:t.__scopeMenu,children:(0,An.jsx)(z0,{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=Z3[l.dir].includes(m.key);f&&h&&(s.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})},"MenuSubContent"));function V0(e){return e?"open":"closed"}Zn(V0,"getOpenState");function Zf(e){return e==="indeterminate"}Zn(Zf,"isIndeterminate");function Mh(e){return Zf(e)?"indeterminate":e?"checked":"unchecked"}Zn(Mh,"getCheckedState");function DM(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Zn(DM,"focusFirst");function AM(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Zn(AM,"wrapArray");function BM(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=AM(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}Zn(BM,"getNextMatch");function NM(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}Zn(NM,"isPointInPolygon");function EM(e,t){if(!t)return!1;let n={x:e.clientX,y:e.clientY};return NM(n,t)}Zn(EM,"isPointerInGraceArea");function vu(e){return t=>t.pointerType==="mouse"?e(t):void 0}Zn(vu,"whenMouse");var OM=nz,_M=kM,FM=oz,zM=iz;var HM=uz,VM=H0,WM=dz;var qM=hz,UM=bz,jM=yz;var GM=wz,YM=Sz;var Zo=require("react/jsx-runtime"),kz=Object.defineProperty,za=(e,t)=>kz(e,"name",{value:t,configurable:!0}),W0="DropdownMenu",[Tz,GQ]=kr(W0,[O0]),Ha=O0(),[Iz,KM]=Tz(W0),Mz=za(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:i,modal:s=!0}=e,l=Ha(t),c=Vo.useRef(null),[u,d]=Lo({prop:o,defaultProp:a??!1,onChange:i,caller:W0});return(0,Zo.jsx)(Iz,{scope:t,triggerId:Ai(),triggerRef:c,contentId:Ai(),open:u,onOpenChange:d,onOpenToggle:Vo.useCallback(()=>d(m=>!m),[d]),modal:s,children:(0,Zo.jsx)(OM,{...l,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},"DropdownMenu"),Lz="DropdownMenuTrigger",Rz=Vo.forwardRef(za(function(t,n){let{__scopeDropdownMenu:r,disabled:o=!1,...a}=t,i=KM(Lz,r),s=Ha(r),l=nn(n,i.triggerRef);return(0,Zo.jsx)(_M,{asChild:!0,...s,children:(0,Zo.jsx)(hn.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")),Pz=za(e=>{let{__scopeDropdownMenu:t,...n}=e,r=Ha(t);return(0,Zo.jsx)(FM,{...r,...n})},"DropdownMenuPortal"),Dz="DropdownMenuContent",Az=Vo.forwardRef(za(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=KM(Dz,r),i=Ha(r),s=Vo.useRef(!1);return(0,Zo.jsx)(zM,{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 Bz=Vo.forwardRef(za(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=Ha(r);return(0,Zo.jsx)(HM,{...a,...o,ref:n})},"DropdownMenuLabel")),Nz=Vo.forwardRef(za(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=Ha(r);return(0,Zo.jsx)(VM,{...a,...o,ref:n})},"DropdownMenuItem")),Ez=Vo.forwardRef(za(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=Ha(r);return(0,Zo.jsx)(WM,{...a,...o,ref:n})},"DropdownMenuCheckboxItem"));var Oz=Vo.forwardRef(za(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=Ha(r);return(0,Zo.jsx)(qM,{...a,...o,ref:n})},"DropdownMenuRadioItem")),_z=Vo.forwardRef(za(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=Ha(r);return(0,Zo.jsx)(UM,{...a,...o,ref:n})},"DropdownMenuItemIndicator")),Fz=Vo.forwardRef(za(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=Ha(r);return(0,Zo.jsx)(jM,{...a,...o,ref:n})},"DropdownMenuSeparator"));var zz=Vo.forwardRef(za(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=Ha(r);return(0,Zo.jsx)(GM,{...a,...o,ref:n})},"DropdownMenuSubTrigger")),Hz=Vo.forwardRef(za(function(t,n){let{__scopeDropdownMenu:r,...o}=t,a=Ha(r);return(0,Zo.jsx)(YM,{...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")),$M=Mz,XM=Rz,ZM=Pz,q0=Az;var U0=Bz,j0=Nz,G0=Ez;var Y0=Oz,K0=_z,$0=Fz;var X0=zz,Z0=Hz;var lo=require("react/jsx-runtime"),Va=$M,Wa=XM;var Wz=rs.forwardRef(({className:e,inset:t,children:n,...r},o)=>(0,lo.jsxs)(X0,{ref:o,className:ne("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,(0,lo.jsx)(Yi,{className:"ml-auto"})]}));Wz.displayName=X0.displayName;var qz=rs.forwardRef(({className:e,...t},n)=>(0,lo.jsx)(Z0,{ref:n,className:ne("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}));qz.displayName=Z0.displayName;var ya=rs.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,lo.jsx)(ZM,{children:(0,lo.jsx)(q0,{ref:r,sideOffset:t,className:ne("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})}));ya.displayName=q0.displayName;var aa=rs.forwardRef(({className:e,inset:t,...n},r)=>(0,lo.jsx)(j0,{ref:r,className:ne("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}));aa.displayName=j0.displayName;var Uz=rs.forwardRef(({className:e,children:t,checked:n,...r},o)=>(0,lo.jsxs)(G0,{ref:o,className:ne("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:[(0,lo.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,lo.jsx)(K0,{children:(0,lo.jsx)(Yr,{className:"h-4 w-4"})})}),t]}));Uz.displayName=G0.displayName;var jz=rs.forwardRef(({className:e,children:t,...n},r)=>(0,lo.jsxs)(Y0,{ref:r,className:ne("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")&&(0,lo.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,lo.jsx)(K0,{children:(0,lo.jsx)(Rl,{className:"h-2 w-2 fill-current"})})}),t]}));jz.displayName=Y0.displayName;var Gz=rs.forwardRef(({className:e,inset:t,...n},r)=>(0,lo.jsx)(U0,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Gz.displayName=U0.displayName;var Yz=rs.forwardRef(({className:e,...t},n)=>(0,lo.jsx)($0,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));Yz.displayName=$0.displayName;var Kz=({className:e,...t})=>(0,lo.jsx)("span",{className:ne("ml-auto text-xs tracking-widest opacity-60",e),...t});Kz.displayName="DropdownMenuShortcut";var _=require("react/jsx-runtime"),hr=(e,t="Color",n)=>({type:"color",key:e,label:t,...n?{disabledWhenFalse:n}:{}}),qa=(e,t="Line width")=>({type:"lineWidth",key:e,label:t}),va=(e,t="Line style")=>({type:"dash",key:e,label:t});var Lh=(e,t)=>({type:"fontSize",key:e,label:t}),Rh=(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}),wu=(e,t,n="Extend")=>({type:"extend",leftKey:e,rightKey:t,label:n}),Wo=(e,t)=>({type:"toggle",key:e,label:t}),QM=(e,t,n)=>({type:"numberInput",key:e,label:t,...n});var JM=(e,t,n)=>({type:"buttonGroup",key:e,label:t,options:n});var eL=(e,t,n,r,o)=>({type:"dualColor",keyA:e,labelA:t,keyB:n,labelB:r,label:o});var tL=(e,t,n,r,o)=>({type:"toggledInput",toggleKey:e,toggleLabel:t,inputKey:n,inputLabel:r,...o});var Ph=(e,t,n)=>({type:"toggledColor",toggleKey:e,colorKey:t,label:n});function $z(e,t){let n=(String(t).split(".")[1]??"").length;return n===0?Math.round(e):Number(e.toFixed(n))}function Dh(e,t){let n=e;return n.key??n.keyA??n.keyStart??n.colorKey??n.toggleKey??n.leftKey??n.startKey??`${e.type}-${t}`}var Xz={hline:[hr("color"),qa("lineWidth"),va("dash")],vline:[hr("color"),qa("lineWidth"),va("dash")],"extended-line":[hr("color"),qa("lineWidth"),va("dash"),wu("extendLeft","extendRight")],line:[hr("color"),qa("lineWidth"),va("dash"),wu("extendLeft","extendRight")],"cross-line":[hr("color"),qa("lineWidth"),va("dash")],"info-line":[hr("color"),qa("lineWidth"),va("dash")],"trend-angle":[hr("color"),qa("lineWidth"),va("dash")],ray:[hr("color"),qa("lineWidth"),va("dash")],hray:[hr("color"),qa("lineWidth"),va("dash")],"parallel-channel":[{type:"channelLevels",label:"Levels"},wu("extendLeft","extendRight"),Ph("enableBackground","backgroundColor","Background")],rect:[hr("borderColor","Border color"),qa("borderLineWidth","Border width"),va("borderDash","Border style"),hr("fillColor","Fill color")],triangle:[hr("borderColor","Border color"),qa("borderLineWidth","Border width"),va("borderDash","Border style"),hr("fillColor","Fill color")],fib:[qa("lineWidth"),va("dash"),wu("extendLeft","extendRight"),Wo("showLevels","Show Level Values"),Wo("showPrices","Show Prices"),Lh("labelFontSize","Label font size"),JM("labelAlign","Label position",[{value:"left",label:"Left"},{value:"right",label:"Right"}]),Wo("labelBold","Bold labels"),{type:"customLevels",label:"Levels"},Ph("enableBackground","backgroundColor","Background")],text:[hr("color"),Lh("fontSize","Font size"),Wo("screenAnchored","Pin to screen")],fvp:[JM("profileMode","Profile Mode",[{value:"stacked",label:"Stacked"},{value:"split",label:"Split"},{value:"delta",label:"Delta"},{value:"total",label:"Total"}]),Rh("barsWidth","Bar Width",100,0,1,"0%","50%","100%","","%"),Rh("barOpacity","Bar Opacity",100,0,1,"0%","50%","100%","","%"),eL("buyColor","Buy","sellColor","Sell","Buy / Sell Colors"),eL("totalColor","Positive","deltaNegColor","Negative","Total / Delta Colors"),Wo("barGap","Bar row gap"),Wo("splitCenterLine","Split center axis"),Wo("showVolNumbers","Show Volume Numbers"),Rh("volNumbersFontSize","Numbers Size",16,7,1,"7","11","16","","px"),hr("pocColor","POC Color"),Wo("showPoc","Show POC Line"),Wo("showPocLabel","Show POC Label"),tL("highlightPocBar","Highlight POC Bar","pocBarLineWidth","Accent line width",{min:1,max:4,step:1,unit:"px"}),wu("pocExtendLeft","pocExtendRight","Extend POC"),Wo("showValueArea","Show Value Area"),Rh("valueAreaPct","Value Area %",100,0,1,"0%","70%","100%","","%"),hr("valueAreaFillColor","VA Fill"),tL("vaBarDimming","Dim bars outside VA","vaOutsideDimFrac","Outside opacity",{min:0,max:1,step:.05,unit:"x"}),Wo("showVaHLines","Show VAH / VAL Lines"),hr("vaLineColor","VAH/VAL Color"),wu("vaLineExtendLeft","vaLineExtendRight","Extend VA Lines"),Wo("labelPills","Label pill backgrounds"),Wo("showDevPoc","Developing POC"),hr("devPocColor","Dev POC Color"),Wo("showDevVa","Developing VA"),hr("devVaColor","Dev VA Color"),Ph("enableBg","bgColor","Background"),Ph("enableBorder","borderColor","Border"),va("borderDash","Border Style")],long:[hr("upColor","Target Color"),hr("downColor","Stop Color"),hr("entryColor","Entry Color"),QM("qty","Quantity",{min:0,step:1}),Wo("drawInfo","Show Info"),Lh("fontSize","Text Size"),hr("textColor","Text Color")],short:[hr("downColor","Target Color"),hr("upColor","Stop Color"),hr("entryColor","Entry Color"),QM("qty","Quantity",{min:0,step:1}),Wo("drawInfo","Show Info"),Lh("fontSize","Text Size"),hr("textColor","Text Color")]},tv=480,xu=12,Zz=["#e0e0e0","#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#a855f7","#ec4899","#00e676","#ff1744","#facc15","#38bdf8","#84cc16","#f43f5e","#06b6d4","#8b5cf6"],Jf=[{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]}],nL={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"},Q0=null;function Qz(){return{x:Math.round((window.innerWidth-tv)/2),y:Math.round(window.innerHeight*.1)}}function rL(e,t){let n=window.innerHeight-t-xu;return Math.min(Math.max(xu,e),Math.max(xu,n))}function Jz(e){return Math.max(xu,Math.min(window.innerWidth-tv-xu,e))}function J0(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 eH(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 aL({drawing:e,onUpdate:t,onClose:n,onMouseEnter:r,onMouseLeave:o}){let[a,i]=(0,sr.useState)("style"),s=(0,sr.useRef)(null),l=(0,sr.useRef)([]),[c,u]=(0,sr.useState)(()=>Pc().filter(ee=>ee.tool===e.tool)),[d,m]=(0,sr.useState)(""),[f,h]=(0,sr.useState)(!1),p=(0,sr.useRef)(null),g=(0,sr.useRef)(Q0??(typeof window<"u"?Qz():{x:80,y:80})),[,y]=(0,sr.useState)(0);(0,sr.useLayoutEffect)(()=>{let ee=p.current;if(!ee)return;let Be=rL(g.current.y,ee.offsetHeight);Be!==g.current.y&&(g.current={...g.current,y:Be},Q0=g.current,y(F=>F+1))});let v=(0,sr.useCallback)(ee=>{if(ee.target.closest("button"))return;ee.preventDefault(),ee.stopPropagation();let Be=ee.clientX,F=ee.clientY,le=g.current.x,ce=g.current.y,ke=ve=>{let Qe=p.current?.offsetHeight??0;g.current={x:Jz(le+ve.clientX-Be),y:rL(ce+ve.clientY-F,Qe)},Q0=g.current,y(Ye=>Ye+1)},De=()=>{window.removeEventListener("mousemove",ke),window.removeEventListener("mouseup",De)};window.addEventListener("mousemove",ke),window.addEventListener("mouseup",De)},[]),b=(0,sr.useCallback)(()=>{o?.(),n()},[n,o]);(0,sr.useEffect)(()=>{let ee=Be=>{Be.key==="Escape"&&b()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[b]);let S=()=>{h(!0),setTimeout(()=>h(!1),1200)},C=e,w=C.locked??!1,k=bo.get(e.tool),M=k?.defaultData??{},I={...M,...C.data??{}},x=ee=>t({data:{...I,...ee}}),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,H=C.labelBold??!1,K=C.labelItalic??!1,G=C.labelHorizontalAlign??"left",V=C.labelVerticalAlign??"top",q=C.labelTextOrientation??"horizontal",j=["line","ray","rect","fib","fvp"].includes(e.tool),W=e.tool==="text",$=()=>{if(!d.trim())return;let ee=["color","lineWidth","dash","fillOpacity","fontSize","extendLeft","extendRight","levels","labelColor","labelFontSize","labelBold","labelItalic","labelHorizontalAlign","labelVerticalAlign","labelTextOrientation","bold","italic"],Be={};for(let F of ee)C[F]!==void 0&&(Be[F]=C[F]);eS({id:vn(8),name:d.trim(),tool:e.tool,style:Be,createdAt:Date.now()}),u(Pc().filter(F=>F.tool===e.tool)),m(""),S()},J=ee=>{tS(ee),u(Pc().filter(Be=>Be.tool===e.tool))},me=ee=>{t(ee.style),S()},We=()=>t(k?{data:{...M}}:Ui(e.tool)),Ce=[{id:"style",label:"Style",icon:(0,_.jsx)(Fs,{size:13})},{id:"coordinates",label:"Coordinates",icon:(0,_.jsx)(rf,{size:13})},{id:"text",label:"Text",icon:(0,_.jsx)(_l,{size:13})},{id:"visibility",label:"Visibility",icon:(0,_.jsx)(Da,{size:13})},{id:"templates",label:"Templates",icon:(0,_.jsx)(Gc,{size:13})}],Ee=k?Ce.filter(ee=>ee.id==="style"||ee.id==="visibility"):Ce,ze=Math.max(0,Ee.findIndex(ee=>ee.id===a)),Ie=l.current[ze];return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("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
|
+
`}),(0,_.jsxs)("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:tv,maxHeight:`calc(100vh - ${g.current.y+xu}px)`},onMouseDown:ee=>ee.stopPropagation(),onMouseEnter:r,onMouseLeave:o,children:[(0,_.jsxs)("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:[(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("h2",{className:"text-sm font-semibold text-white tracking-tight",children:nL[e.tool]??k?.name??"Drawing"}),(0,_.jsx)("p",{className:"text-[11px] text-white/40 mt-0.5",children:"Drawing settings"})]}),(0,_.jsx)("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:(0,_.jsx)(Kr,{size:14})})]}),(0,_.jsxs)("div",{className:"flex gap-0.5 px-4 pt-2 pb-0 shrink-0 border-b border-white/6 relative",ref:s,children:[Ee.map((ee,Be)=>(0,_.jsxs)("button",{ref:F=>l.current[Be]=F,onClick:()=>i(ee.id),className:ne("flex items-center gap-1.5 px-3 py-2 text-[11px] font-medium rounded-t transition-colors border-b-2 -mb-px",a===ee.id?"text-white bg-white/5":"text-white/40 border-transparent hover:text-white/70 hover:bg-white/5"),children:[ee.icon,ee.label]},ee.id)),(0,_.jsx)("div",{className:"absolute bottom-0 left-0 border-b-2 border-blue-500 transition-all duration-200",style:{width:Ie?.clientWidth??0,transform:`translateX(${Ie?.offsetLeft??0}px)`}})]}),(0,_.jsxs)("div",{className:"flex-1 overflow-y-auto px-5 py-4 min-h-0",children:[a==="style"&&(0,_.jsxs)("div",{className:"flex flex-col gap-5",children:[k?(k.settingsSchema??[]).map((ee,Be)=>(0,_.jsx)(Ah,{field:ee,drawing:I,onUpdate:x},Dh(ee,Be))):(Xz[e.tool]??[]).map((ee,Be)=>(0,_.jsx)(Ah,{field:ee,drawing:C,onUpdate:t},Dh(ee,Be))),k&&!k.settingsSchema?.length&&(0,_.jsxs)("div",{className:"flex flex-col items-center gap-2 py-6 text-white/25",children:[(0,_.jsx)(Fs,{size:22,strokeWidth:1.2}),(0,_.jsxs)("p",{className:"text-[11px] text-center",children:[k.name," doesn't have any settings."]})]}),(!k||!!k.settingsSchema?.length)&&(0,_.jsxs)("button",{className:"flex items-center gap-2 text-[11px] text-white/30 hover:text-white/60 transition-colors mt-1",onClick:We,children:[(0,_.jsx)(ha,{size:11})," Reset to defaults"]})]}),a==="coordinates"&&(0,_.jsxs)("div",{className:"flex flex-col gap-4",children:[e.tool==="hline"&&(0,_.jsx)(Bh,{label:"Price",children:(0,_.jsx)(iL,{value:e.price,onChange:ee=>t({price:ee})})}),e.tool==="vline"&&(0,_.jsx)(Bh,{label:"Time",children:(0,_.jsx)(sL,{value:e.ts,onChange:ee=>t({ts:ee})})}),j&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(ev,{label:"Point A",anchor:e.a,onChange:ee=>t({a:ee})}),(0,_.jsx)(ev,{label:"Point B",anchor:e.b,onChange:ee=>t({b:ee})})]}),W&&(0,_.jsx)(ev,{label:"Anchor",anchor:e.anchor,onChange:ee=>t({anchor:ee})}),(0,_.jsx)("p",{className:"text-[10px] text-white/25 mt-1",children:"Timestamps are in UTC. Enter as ISO date or raw nanoseconds."})]}),a==="text"&&(0,_.jsxs)("div",{className:"flex flex-col gap-5",children:[T&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Sn,{label:"Content",children:(0,_.jsx)("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:ee=>t({text:ee.target.value}),placeholder:"Enter text\u2026",onKeyDown:ee=>ee.stopPropagation()})}),(0,_.jsx)(Sn,{label:"Formatting",children:(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsxs)(el,{active:N,onClick:()=>t({bold:!N}),children:[(0,_.jsx)(jc,{size:12}),"Bold"]}),(0,_.jsxs)(el,{active:O,onClick:()=>t({italic:!O}),children:[(0,_.jsx)(Kc,{size:12}),"Italic"]})]})}),(0,_.jsxs)(Sn,{label:`Font size - ${D}px`,children:[(0,_.jsx)(Wn,{value:[D],onValueChange:([ee])=>t({fontSize:ee}),max:48,min:8,step:1,className:"w-full accent-blue-500"}),(0,_.jsxs)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[(0,_.jsx)("span",{children:"8px"}),(0,_.jsx)("span",{children:"28px"}),(0,_.jsx)("span",{children:"48px"})]})]}),(0,_.jsx)(Sn,{label:"Text alignment",children:(0,_.jsx)(oL,{value:P,onChange:ee=>t({textAlign:ee})})}),(0,_.jsx)(Sn,{label:"Color",children:(0,_.jsx)(os,{value:C.color??"#e0e0e0",onChange:ee=>t({color:ee})})})]}),A&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Sn,{label:"Label text",children:(0,_.jsx)("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:ee=>t({label:ee.target.value}),placeholder:"Optional label\u2026",onKeyDown:ee=>ee.stopPropagation()})}),(0,_.jsx)(Sn,{label:"Formatting",children:(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsxs)(el,{active:H,onClick:()=>t({labelBold:!H}),children:[(0,_.jsx)(jc,{size:12}),"Bold"]}),(0,_.jsxs)(el,{active:K,onClick:()=>t({labelItalic:!K}),children:[(0,_.jsx)(Kc,{size:12}),"Italic"]})]})}),(0,_.jsxs)(Sn,{label:`Font size - ${L}px`,children:[(0,_.jsx)(Wn,{value:[L],onValueChange:([ee])=>{t({labelFontSize:ee})},max:48,min:8,step:1,className:"w-full accent-blue-500"}),(0,_.jsxs)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[(0,_.jsx)("span",{children:"8px"}),(0,_.jsx)("span",{children:"22px"}),(0,_.jsx)("span",{children:"36px"})]})]}),e.tool==="vline"&&(0,_.jsx)(Sn,{label:"Text orientation",children:(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsxs)(el,{active:q==="horizontal",onClick:()=>t({labelTextOrientation:"horizontal"}),children:[(0,_.jsx)("span",{className:"font-mono text-[11px]",children:"A"}),"Horizontal"]}),(0,_.jsxs)(el,{active:q==="vertical",onClick:()=>t({labelTextOrientation:"vertical"}),children:[(0,_.jsx)("span",{className:"font-mono text-[11px] rotate-90 inline-block",children:"A"}),"Vertical"]})]})}),(0,_.jsx)(Sn,{label:"Horizontal alignment",children:(0,_.jsx)(oL,{value:G,onChange:ee=>t({labelHorizontalAlign:ee})})}),(0,_.jsx)(Sn,{label:"Vertical alignment",children:(0,_.jsx)(nH,{value:V,onChange:ee=>t({labelVerticalAlign:ee})})}),(0,_.jsxs)(Sn,{label:"Label color",children:[(0,_.jsx)(os,{value:E,onChange:ee=>t({labelColor:ee})}),(0,_.jsxs)("button",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-white/30 hover:text-white/60 transition-colors",onClick:()=>t({labelColor:hr}),children:[(0,_.jsx)(ha,{size:10}),"Reset to line color"]})]})]}),e.tool==="fib"&&(0,_.jsxs)("div",{className:"flex flex-col items-center gap-2 py-6 text-white/25",children:[(0,_.jsx)(_l,{size:22,strokeWidth:1.2}),(0,_.jsx)("p",{className:"text-[11px] text-center",children:"Fibonacci levels use their own built-in labels."})]}),e.tool==="fvp"&&(0,_.jsxs)("div",{className:"flex flex-col items-center gap-2 py-6 text-white/25",children:[(0,_.jsx)(_l,{size:22,strokeWidth:1.2}),(0,_.jsx)("p",{className:"text-[11px] text-center",children:"Currently text isn't supported for fixed volume profile drawings."})]})]}),a==="visibility"&&(0,_.jsx)("div",{className:"flex flex-col gap-1",children:(0,_.jsx)(oH,{icon:(0,_.jsx)(no,{size:14}),label:"Locked",description:"Prevent accidental moves or edits",checked:w,activeColor:"text-yellow-400",onCheckedChange:ee=>t({locked:ee})})}),a==="templates"&&(0,_.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,_.jsx)(Sn,{label:"Save current style as template",children:(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsx)("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:ee=>m(ee.target.value),onKeyDown:ee=>{ee.stopPropagation(),ee.key==="Enter"&&$()},placeholder:"Template name\u2026"}),(0,_.jsxs)("button",{className:ne("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:$,children:[f?(0,_.jsx)(Yr,{size:12}):(0,_.jsx)(ff,{size:12}),f?"Saved!":"Save"]})]})}),(0,_.jsx)(Sn,{label:`Saved templates for ${nL[e.tool]}`,children:c.length===0?(0,_.jsxs)("div",{className:"flex flex-col items-center gap-2 py-6 text-white/25",children:[(0,_.jsx)(Gc,{size:22,strokeWidth:1.2}),(0,_.jsx)("p",{className:"text-[11px]",children:"No templates yet"})]}):(0,_.jsx)("div",{className:"flex flex-col gap-1.5",children:c.slice().sort((ee,Be)=>Be.createdAt-ee.createdAt).map(ee=>(0,_.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-white/3 border border-white/6 group",children:[(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-[12px] text-white truncate",children:ee.name}),(0,_.jsx)("p",{className:"text-[10px] text-white/30 mt-0.5",children:new Date(ee.createdAt).toLocaleDateString()})]}),(0,_.jsx)("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:()=>me(ee),children:"Apply"}),(0,_.jsx)("button",{className:"p-1 rounded text-white/20 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all",onClick:()=>J(ee.id),children:(0,_.jsx)(Mo,{size:11})})]},ee.id))})})]})]}),(0,_.jsx)("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-white/6 shrink-0 bg-white/2",children:(0,_.jsx)("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 Ah({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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("div",{className:ne("transition-opacity",o&&"opacity-30 pointer-events-none"),children:(0,_.jsx)(os,{value:r,onChange:a=>n({[e.key]:a})})})})}if(e.type==="lineWidth"){let r=t[e.key]??1;return(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("div",{className:"flex gap-2",children:[1,2,3,4].map(o=>(0,_.jsxs)("button",{className:ne("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:[(0,_.jsx)("div",{className:"rounded-full bg-current",style:{width:28,height:o}}),(0,_.jsxs)("span",{className:"text-[10px] font-mono",children:[o,"px"]})]},o))})})}if(e.type==="dash"){let r=t[e.key]??[];return(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("div",{className:"grid grid-cols-2 gap-2",children:Jf.map(o=>{let a=JSON.stringify(r)===JSON.stringify(o.dash);return(0,_.jsxs)("button",{className:ne("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:[(0,_.jsx)("svg",{width:"28",height:"8",viewBox:"0 0 28 8",children:(0,_.jsx)("line",{x1:"0",y1:"4",x2:"28",y2:"4",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:o.dash.join(" ")||void 0})}),(0,_.jsx)("span",{className:"text-[11px]",children:o.label})]},o.value)})})})}if(e.type==="opacity"){let r=t[e.key]??0;return(0,_.jsxs)(Sn,{label:`${e.label} - ${Math.round(r*100)}%`,children:[(0,_.jsx)(Wn,{value:[r],onValueChange:([o])=>n({[e.key]:o}),max:1,min:0,step:.01,className:"w-full accent-blue-500"}),(0,_.jsxs)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[(0,_.jsx)("span",{children:"0%"}),(0,_.jsx)("span",{children:"50%"}),(0,_.jsx)("span",{children:"100%"})]})]})}if(e.type==="fontSize"){let r=t[e.key]??12;return(0,_.jsxs)(Sn,{label:`${e.label} - ${r}px`,children:[(0,_.jsx)(Wn,{value:[r],onValueChange:([o])=>n({[e.key]:Math.round(o)}),max:48,min:8,step:1,className:"w-full accent-blue-500"}),(0,_.jsxs)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[(0,_.jsx)("span",{children:"8px"}),(0,_.jsx)("span",{children:"28px"}),(0,_.jsx)("span",{children:"48px"})]})]})}if(e.type==="slider"){let r=t[e.key]??12;return(0,_.jsxs)(Sn,{label:`${e.label} - ${e.prefix??""}${r}${e.suffix??""}`,children:[(0,_.jsx)(Wn,{value:[r],onValueChange:([o])=>n({[e.key]:$z(o,e.step)}),max:e.max,min:e.min,step:e.step,className:"w-full accent-blue-500"}),(0,_.jsxs)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[(0,_.jsx)("span",{children:e.step1}),(0,_.jsx)("span",{children:e.step2}),(0,_.jsx)("span",{children:e.step3})]})]})}if(e.type==="extend")return(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsxs)("div",{className:"flex gap-2",children:[(0,_.jsx)(el,{active:t[e.leftKey]??!1,onClick:()=>n({[e.leftKey]:!t[e.leftKey]}),children:"\u2190 Extend left"}),(0,_.jsx)(el,{active:t[e.rightKey]??!1,onClick:()=>n({[e.rightKey]:!t[e.rightKey]}),children:"Extend right \u2192"})]})});if(e.type==="toggle")return(0,_.jsx)(Sn,{label:"",children:(0,_.jsx)(rH,{label:e.label,active:t[e.key]??!1,onToggle:()=>n({[e.key]:!t[e.key]})})});if(e.type==="customLevels")return(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)(aH,{levels:t.levels??[],onChange:r=>n({levels:r})})});if(e.type==="channelLevels")return(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)(sH,{levels:t.levels??xl,fallbackColor:t.color??"#e0e0e0",onChange:r=>n({levels:r})})});if(e.type==="numberInput")return(0,_.jsx)(tH,{field:e,value:t[e.key]??e.min??0,onChange:r=>n({[e.key]:r})});if(e.type==="textInput")return(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsxs)("div",{className:"relative",children:[(0,_.jsx)("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=>(0,_.jsx)("option",{value:o.value,className:"bg-[#1a1d24]",children:o.label},o.value))}),(0,_.jsx)("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:(0,_.jsx)("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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:e.options.map(o=>(0,_.jsxs)("button",{className:ne("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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("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"}),(0,_.jsx)("span",{className:"flex-1 text-center text-[13px] font-mono text-white tabular-nums",children:r}),(0,_.jsx)("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(0,_.jsxs)(Sn,{label:`${e.label} - ${r}`,children:[(0,_.jsx)(Wn,{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"}),(0,_.jsx)("div",{className:"flex justify-between mt-1",children:e.steps.map(o=>(0,_.jsx)("button",{className:ne("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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,_.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,_.jsx)("p",{className:"text-[10px] text-white/35 font-medium",children:e.labelA}),(0,_.jsx)(os,{value:t[e.keyA]??"#22c55e",onChange:r=>n({[e.keyA]:r})})]}),(0,_.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,_.jsx)("p",{className:"text-[10px] text-white/35 font-medium",children:e.labelB}),(0,_.jsx)(os,{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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("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})=>(0,_.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,_.jsxs)("p",{className:"text-[10px] text-white/35 font-medium",children:[i," - ",Math.round(s*100),"%"]}),(0,_.jsx)(Wn,{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(0,_.jsxs)(Sn,{label:e.label,children:[(0,_.jsx)("div",{className:"w-full h-6 rounded-lg mb-3 border border-white/10",style:{background:`linear-gradient(to right, ${r}, ${o})`}}),(0,_.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,_.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,_.jsx)("p",{className:"text-[10px] text-white/35 font-medium",children:"Start"}),(0,_.jsx)(os,{value:r,onChange:a=>n({[e.keyStart]:a})})]}),(0,_.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,_.jsx)("p",{className:"text-[10px] text-white/35 font-medium",children:"End"}),(0,_.jsx)(os,{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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("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(0,_.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,_.jsx)("span",{className:"text-[9px] text-white/30 font-semibold uppercase tracking-widest",children:i}),(0,_.jsx)("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()}),(0,_.jsx)("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(0,_.jsxs)(Sn,{label:e.label,children:[(0,_.jsx)("div",{className:"grid grid-cols-3 gap-1 w-24",children:o.map(a=>(0,_.jsx)("button",{title:a,className:ne("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:(0,_.jsx)("div",{className:ne("w-2 h-2 rounded-full transition-colors",r===a?"bg-blue-400":"bg-white/25")})},a))}),(0,_.jsx)("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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("div",{className:"flex gap-2",children:o.map(({val:a,label:i})=>(0,_.jsxs)("button",{className:ne("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:[(0,_.jsx)("svg",{width:"28",height:"12",viewBox:"0 0 28 12",children:(0,_.jsx)("line",{x1:a==="square"||a==="round"?6:4,y1:"6",x2:"22",y2:"6",stroke:"currentColor",strokeWidth:"4",strokeLinecap:a})}),(0,_.jsx)("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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("div",{className:"flex gap-2",children:o.map(({val:i,label:s})=>(0,_.jsxs)("button",{className:ne("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:[(0,_.jsx)("svg",{width:"28",height:"24",viewBox:"0 0 28 24",fill:"none",children:(0,_.jsx)("path",{d:a,stroke:"currentColor",strokeWidth:"3",fill:"none",strokeLinejoin:i,strokeLinecap:"round"})}),(0,_.jsx)("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})=>(0,_.jsxs)("svg",{width:"32",height:"12",viewBox:"0 0 32 12",fill:"none",children:[(0,_.jsx)("line",{x1:"2",y1:"6",x2:"24",y2:"6",stroke:"currentColor",strokeWidth:"1.5"}),s==="open"&&(0,_.jsx)("path",{d:"M18,2 L26,6 L18,10",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinejoin:"round"}),s==="filled"&&(0,_.jsx)("path",{d:"M18,2 L26,6 L18,10 Z",fill:"currentColor"})]});return(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("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})=>(0,_.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,_.jsx)("p",{className:"text-[10px] text-white/35 font-medium",children:l}),(0,_.jsx)("div",{className:"flex flex-col gap-1",children:a.map(u=>(0,_.jsxs)("button",{className:ne("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:[(0,_.jsx)(i,{style:u.val}),u.label]},u.val))})]},s))})})}if(e.type==="checkbox"){let r=t[e.key]??!1;return(0,_.jsxs)("button",{className:ne("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:[(0,_.jsx)("div",{className:ne("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&&(0,_.jsx)(Yr,{size:10,strokeWidth:3,className:"text-white"})}),(0,_.jsxs)("div",{className:"flex flex-col gap-0.5 min-w-0",children:[(0,_.jsx)("span",{className:"text-[12px] leading-none",children:e.label}),e.description&&(0,_.jsx)("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(0,_.jsx)(Sn,{label:"",children:(0,_.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg border border-white/6 bg-white/3",children:[(0,_.jsx)(so,{checked:r,onCheckedChange:a=>n({[e.toggleKey]:a}),className:"data-[state=checked]:bg-blue-500"}),(0,_.jsx)("span",{className:ne("text-[12px] flex-1",r?"text-white":"text-white/40 select-none"),children:e.toggleLabel}),(0,_.jsxs)("div",{className:ne("flex items-center gap-1.5 transition-opacity",!r&&"opacity-30 pointer-events-none"),children:[(0,_.jsx)("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&&(0,_.jsx)("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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsxs)("div",{className:"flex gap-3 items-start",children:[(0,_.jsx)("div",{className:"flex-1 min-w-0",children:(0,_.jsx)(os,{value:r,onChange:a=>n({[e.colorKey]:a})})}),(0,_.jsxs)("div",{className:"flex flex-col gap-1 w-28 shrink-0 pt-0.5",children:[(0,_.jsxs)("p",{className:"text-[10px] text-white/35 font-medium",children:["Opacity - ",Math.round(o*100),"%"]}),(0,_.jsx)(Wn,{value:[o],onValueChange:([a])=>n({[e.opacityKey]:a}),min:0,max:1,step:.01}),(0,_.jsxs)("div",{className:"flex justify-between text-[9px] text-white/25 font-mono",children:[(0,_.jsx)("span",{children:"0%"}),(0,_.jsx)("span",{children:"100%"})]})]})]})})}if(e.type==="toggledColor"){let r=t[e.toggleKey]??!1,o=t[e.colorKey]??"#e0e0e0";return(0,_.jsx)(Sn,{label:"",children:(0,_.jsxs)("div",{className:ne("flex flex-col rounded-lg border transition-colors overflow-hidden",r?"border-white/10 bg-white/3":"border-white/6 bg-white/2"),children:[(0,_.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[(0,_.jsx)(so,{checked:r,onCheckedChange:a=>n({[e.toggleKey]:a}),className:"data-[state=checked]:bg-blue-500"}),(0,_.jsx)("span",{className:ne("text-[12px] flex-1",r?"text-white":"text-white/40"),children:e.label}),!r&&(0,_.jsx)("div",{className:"w-5 h-5 rounded-full border border-white/15",style:{background:o}})]}),r&&(0,_.jsx)("div",{className:"px-3 pb-3 border-t border-white/6",children:(0,_.jsx)("div",{className:"pt-3",children:(0,_.jsx)(os,{value:o,onChange:a=>n({[e.colorKey]:a})})})})]})})}return e.type==="inlineFields"?(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsx)("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(0,_.jsxs)("div",{className:"flex items-center gap-1 bg-white/4 border border-white/8 rounded-lg px-1",children:[(0,_.jsx)("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"}),(0,_.jsx)("span",{className:"text-[12px] font-mono text-white tabular-nums min-w-[2ch] text-center",children:a}),(0,_.jsx)("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&&(0,_.jsx)("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(0,_.jsx)("div",{className:"flex gap-1",children:r.options.map(i=>(0,_.jsx)("button",{title:i.label,className:ne("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(0,_.jsxs)("button",{className:ne("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&&(0,_.jsx)(Yr,{size:10,strokeWidth:3}),r.label]},o)}return null})})}):null}function tH({field:e,value:t,onChange:n}){let[r,o]=(0,sr.useState)(()=>String(t)),a=(0,sr.useRef)(!1);(0,sr.useEffect)(()=>{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(0,_.jsx)(Sn,{label:e.label,children:(0,_.jsxs)("div",{className:"flex items-center gap-2",children:[(0,_.jsx)("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&&(0,_.jsx)("span",{className:"text-[11px] text-white/35 shrink-0",children:e.unit})]})})}function Sn({label:e,children:t}){return(0,_.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,_.jsx)("p",{className:"text-[10px] font-semibold text-white/35 uppercase tracking-widest",children:e}),t]})}function Bh({label:e,children:t}){return(0,_.jsxs)("div",{className:"flex items-center gap-3",children:[(0,_.jsx)("span",{className:"text-[11px] text-white/40 w-20 shrink-0",children:e}),(0,_.jsx)("div",{className:"flex-1",children:t})]})}function iL({value:e,onChange:t}){let[n,r]=(0,sr.useState)(()=>e.toFixed(6)),o=(0,sr.useRef)(!1);return(0,sr.useEffect)(()=>{o.current||r(e.toFixed(6))},[e]),(0,_.jsx)("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 sL({value:e,onChange:t}){let[n,r]=(0,sr.useState)(()=>J0(e)),o=(0,sr.useRef)(!1);return(0,sr.useEffect)(()=>{o.current||r(J0(e))},[e]),(0,_.jsx)("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=eH(n);a!==null?t(a):r(J0(e))},onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"&&a.target.blur()}})}function ev({label:e,anchor:t,onChange:n}){return(0,_.jsxs)("div",{className:"rounded-lg border border-white/8 bg-white/2 px-3 py-3 flex flex-col gap-2.5",children:[(0,_.jsx)("p",{className:"text-[10px] font-semibold text-white/40 uppercase tracking-widest",children:e}),(0,_.jsx)(Bh,{label:"Time",children:(0,_.jsx)(sL,{value:t.ts,onChange:r=>n({...t,ts:r})})}),(0,_.jsx)(Bh,{label:"Price",children:(0,_.jsx)(iL,{value:t.price,onChange:r=>n({...t,price:r})})})]})}function oL({value:e,onChange:t}){return(0,_.jsx)("div",{className:"flex gap-1.5",children:["left","center","right"].map(n=>{let r=n==="left"?Bd:n==="center"?Pd:Nd;return(0,_.jsxs)("button",{className:ne("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:[(0,_.jsx)(r,{size:12}),{left:"Left",center:"Center",right:"Right"}[n]]},n)})})}function nH({value:e,onChange:t}){return(0,_.jsx)("div",{className:"flex gap-1.5",children:[{val:"top",label:"Top",Icon:Ed},{val:"middle",label:"Middle",Icon:Rd},{val:"bottom",label:"Bottom",Icon:Dd}].map(({val:r,label:o,Icon:a})=>(0,_.jsxs)("button",{className:ne("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:[(0,_.jsx)(a,{size:12}),o]},r))})}function el({active:e,onClick:t,children:n}){return(0,_.jsxs)("button",{className:ne("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))&&(0,_.jsx)(Yr,{size:11,strokeWidth:2.5}),n]})}function rH({label:e,active:t,onToggle:n}){return(0,_.jsxs)("button",{className:ne("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:[(0,_.jsx)("span",{className:"text-[12px]",children:e}),(0,_.jsx)(so,{checked:t,onCheckedChange:n,className:"data-[state=checked]:bg-blue-500"})]})}function oH({icon:e,label:t,description:n,checked:r,activeColor:o="text-blue-400",onCheckedChange:a}){return(0,_.jsxs)("div",{className:"flex items-center gap-3 py-2",children:[(0,_.jsx)("div",{className:ne("shrink-0",r?o:"text-white/30"),children:e}),(0,_.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,_.jsx)("p",{className:"text-[12px] text-white",children:t}),(0,_.jsx)("p",{className:"text-[10px] text-white/35 mt-0.5",children:n})]}),(0,_.jsx)(so,{checked:r,onCheckedChange:a,className:"data-[state=checked]:bg-blue-500"})]})}function os({value:e,onChange:t}){return(0,_.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,_.jsx)("div",{className:"grid grid-cols-8 gap-1.5",children:Zz.map(n=>(0,_.jsx)("button",{className:ne("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&&(0,_.jsx)(Yr,{size:11,className:"text-black drop-shadow",strokeWidth:3})},n))}),(0,_.jsx)("div",{className:"flex items-center gap-2",children:(0,_.jsx)(Ho,{onChange:n=>t(n),value:e,className:"w-8 h-8 rounded-md border-2 border-border/50"})})]})}function aH({levels:e,onChange:t}){let[n,r]=(0,sr.useState)(""),[o,a]=(0,sr.useState)("#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:vn(8),value:n.trim(),color:o,enabled:!0}]),r(""))};return(0,_.jsxs)("div",{className:"flex flex-col gap-1.5",children:[e.map(c=>(0,_.jsxs)("div",{className:ne("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:[(0,_.jsx)("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:(0,_.jsx)(Ho,{onChange:u=>i(c.id,{color:u}),value:c.color,className:"opacity-0 absolute"})}),(0,_.jsx)("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()}),(0,_.jsx)("button",{className:ne("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?(0,_.jsx)(Da,{size:12}):(0,_.jsx)(Ri,{size:12})}),(0,_.jsx)("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:(0,_.jsx)(Kr,{size:11})})]},c.id)),(0,_.jsxs)("div",{className:"flex items-center gap-1.5 mt-1",children:[(0,_.jsx)("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:(0,_.jsx)(Ho,{onChange:c=>a(c),value:o,className:"opacity-0 absolute"})}),(0,_.jsx)("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}),(0,_.jsx)("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 iH(e){return Jf.find(n=>JSON.stringify(n.dash)===JSON.stringify(e??[]))?.value??"solid"}function sH({levels:e,fallbackColor:t,onChange:n}){let[r,o]=(0,sr.useState)(""),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:vn(8),value:l,color:t,lineWidth:1,dash:[],enabled:!0}].sort((c,u)=>c.value-u.value)),o(""))};return(0,_.jsxs)("div",{className:"flex flex-col gap-1.5",children:[e.map(l=>(0,_.jsxs)("div",{className:ne("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:[(0,_.jsxs)("div",{className:"grid items-center gap-1.5",style:{gridTemplateColumns:"28px 1fr 24px 22px"},children:[(0,_.jsx)(Ho,{onChange:c=>a(l.id,{color:c}),value:l.color,className:"w-7 h-7"}),(0,_.jsx)("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()}),(0,_.jsx)("button",{className:ne("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?(0,_.jsx)(Da,{size:12}):(0,_.jsx)(Ri,{size:12})}),(0,_.jsx)("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:(0,_.jsx)(Kr,{size:11})})]}),(0,_.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,_.jsx)("div",{className:"flex gap-1 w-1/2",children:[1,2,3,4].map(c=>(0,_.jsx)("button",{className:ne("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))}),(0,_.jsxs)(Va,{children:[(0,_.jsx)(Wa,{asChild:!0,children:(0,_.jsxs)(br,{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:[(0,_.jsx)("div",{children:Jf.find(c=>c.value===iH(l.dash)).label}),(0,_.jsx)(or,{className:"w-4"})]})}),(0,_.jsx)(ya,{className:"z-[201]",children:Jf.map(c=>(0,_.jsx)(aa,{onSelect:()=>{let u=Jf.find(d=>d.value===c.value);a(l.id,{dash:u?u.dash:[]})},className:"text-xs",children:c.label},c.value))})]})]})]},l.id)),(0,_.jsxs)("div",{className:"flex items-center gap-1.5 mt-1",children:[(0,_.jsx)("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()}}),(0,_.jsx)("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"})]})]})}var Ae=require("react/jsx-runtime"),lH=[{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]}],cH=[1,2,3,4],nv={x:16,y:16},tl=12,rv=null;function lL(e,{requestOrderTicket:t}){t(e.id)}var uH={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:lL,icon:Xc,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:lL,icon:Xc,label:"Create order from this drawing"}]};function uL({drawing:e,containerRef:t,onUpdate:n,onDelete:r,onDuplicate:o,onClose:a,onMouseEnter:i,onMouseLeave:s,onRequestOrderTicket:l,openDialog:c}){let u=(0,Xr.useRef)(null),[d,m]=(0,Xr.useState)(!1),[f,h]=(0,Xr.useState)(null),p=(0,Xr.useRef)(!1),[g,y]=(0,Xr.useState)(e);(0,Xr.useEffect)(()=>{y(e)},[e.id]);let v=(0,Xr.useCallback)(L=>{y(H=>({...H,...L})),n(L)},[n]),b=(0,Xr.useCallback)(L=>{if(p.current){p.current=!1;return}h(H=>H===L?null:L)},[]),S=(0,Xr.useCallback)(()=>h(null),[]);(0,Xr.useEffect)(()=>{c&&m(!0)},[c]);let C=(0,Xr.useRef)(rv);if(C.current===null){let L=t.current?.getBoundingClientRect();C.current=L?{x:L.left+nv.x,y:L.top+nv.y}:nv}(0,Xr.useLayoutEffect)(()=>{let L=u.current;if(!L)return;let H=L.getBoundingClientRect(),K=Math.max(tl,Math.min(window.innerWidth-H.width-tl,C.current.x)),G=Math.max(tl,Math.min(window.innerHeight-H.height-tl,C.current.y));(K!==C.current.x||G!==C.current.y)&&(C.current={x:K,y:G},rv=C.current,L.style.left=`${K}px`,L.style.top=`${G}px`)});let w=(0,Xr.useRef)(!1),[k,M]=(0,Xr.useState)(!1),I=(0,Xr.useCallback)(L=>{L.preventDefault(),L.stopPropagation(),h(null);let H=L.clientX,K=L.clientY,G=C.current.x,V=C.current.y;w.current=!0,M(!0);let q=W=>{let $=u.current;if(!$)return;let J=W.clientX-H,me=W.clientY-K,We=G+J,Ce=V+me,Ee=$.getBoundingClientRect();We=Math.max(tl,Math.min(window.innerWidth-Ee.width-tl,We)),Ce=Math.max(tl,Math.min(window.innerHeight-Ee.height-tl,Ce)),C.current={x:We,y:Ce},rv=C.current,$.style.left=`${We}px`,$.style.top=`${Ce}px`},j=()=>{w.current=!1,M(!1),window.removeEventListener("mousemove",q),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",q),window.addEventListener("mouseup",j)},[t]);(0,Xr.useEffect)(()=>{let L=K=>{let G=K.target;u.current?.contains(G)||t.current?.contains(G)&&a()},H=setTimeout(()=>window.addEventListener("mousedown",L),150);return()=>{clearTimeout(H),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=uH[g.tool]??[],A=l?O:O.filter(L=>L.type!=="button"),B=A.filter((L,H)=>L.type!=="sep"||A.slice(H+1).some(K=>K.type!=="sep")),E=(L,H)=>{switch(L.type){case"sep":return(0,Ae.jsx)(dH,{},`sep-${H}`);case"color":{let K=x(L.patchKey);if(K===void 0)return null;let G=`color-${L.patchKey}`;return(0,Ae.jsxs)("div",{className:"relative",children:[(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onClick:()=>b(G),children:(0,Ae.jsxs)("span",{className:"flex flex-col items-center gap-0.5",children:[(0,Ae.jsx)(cL,{}),(0,Ae.jsx)(em,{color:K})]})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:L.label})]}),(0,Ae.jsx)(Ho,{onChange:V=>{v({[L.patchKey]:V})},value:K,open:f===G,onOpenChange:V=>{V||(p.current=!0,S())},hideButton:!0})]},G)}case"borderColor":{let K=x(L.patchKey)??x("color");if(K===void 0)return null;let G=`borderColor-${L.patchKey}`;return(0,Ae.jsxs)("div",{className:"relative",children:[(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onMouseDown:V=>{V.preventDefault(),b(G)},children:(0,Ae.jsxs)("span",{className:"flex flex-col items-center gap-0.5",children:[(0,Ae.jsx)(mH,{}),(0,Ae.jsx)(em,{color:K})]})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:L.label??"Border color"})]}),(0,Ae.jsx)(Ho,{onChange:V=>{v({[L.patchKey]:V})},value:K,open:f===G,onOpenChange:V=>{V||(p.current=!0,S())},hideButton:!0})]},G)}case"fillColor":{let K=x(L.patchKey)??x("color");if(K===void 0)return null;let G=`fillColor-${L.patchKey}`;return(0,Ae.jsxs)("div",{className:"relative",children:[(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onClick:()=>b(G),children:(0,Ae.jsxs)("span",{className:"flex flex-col items-center gap-0.5",children:[(0,Ae.jsx)(pH,{}),(0,Ae.jsx)(em,{color:K})]})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:L.label??"Fill color"})]}),(0,Ae.jsx)(Ho,{onChange:V=>v({[L.patchKey]:V}),value:K,open:f===G,onOpenChange:V=>{V||(p.current=!0,S())},hideButton:!0})]},G)}case"lineWidth":{let K=x(L.patchKey);if(K===void 0)return null;let G=`lineWidth-${L.patchKey}`;return(0,Ae.jsxs)("div",{className:"relative",children:[(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsxs)("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:["- ",K,"px"]})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:L.label??"Line width"})]}),f===G&&(0,Ae.jsx)("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:V=>V.stopPropagation(),children:cH.map(V=>(0,Ae.jsxs)("button",{className:ne("flex items-center gap-2 px-2 py-1 rounded text-[11px] font-mono hover:bg-white/10 transition-colors",K===V?"text-white":"text-muted-foreground"),onClick:()=>{v({[L.patchKey]:V}),S()},children:[(0,Ae.jsx)("div",{className:"rounded-full bg-current",style:{height:V,width:28}}),V,"px"]},V))})]},G)}case"dash":{let K=x(L.patchKey),G=x("color")??x("borderColor")??"#e0e0e0";if(K===void 0)return null;let V=`dash-${L.patchKey}`;return(0,Ae.jsxs)("div",{className:"relative",children:[(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onClick:()=>b(V),children:(0,Ae.jsx)(fH,{dash:K,color:G})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:L.label??"Line style"})]}),f===V&&(0,Ae.jsx)("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:q=>q.stopPropagation(),children:lH.map(q=>(0,Ae.jsx)("button",{className:ne("flex items-center gap-2 px-2 py-1 rounded text-[11px] font-mono hover:bg-white/10 transition-colors",JSON.stringify(K)===JSON.stringify(q.dash)?"text-white":"text-muted-foreground"),onClick:()=>{v({[L.patchKey]:q.dash}),S()},children:q.label},q.label))})]},V)}case"fibColor":{if(P.length===0)return null;let K="fibColor";return(0,Ae.jsxs)("div",{className:"relative",children:[(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onClick:()=>{b(K)},children:(0,Ae.jsxs)("span",{className:"flex flex-col items-center gap-0.5",children:[(0,Ae.jsx)(cL,{}),N?(0,Ae.jsx)(em,{color:N}):(0,Ae.jsx)("div",{className:"h-[3px] w-[13px] rounded-full",style:{background:"linear-gradient(to right, #ef4444, #f97316, #eab308, #22c55e, #3b82f6, #a855f7)"}})]})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:"Levels color"})]}),(0,Ae.jsx)(Ho,{onChange:G=>{v({levels:R.map(V=>V.enabled?{...V,color:G}:V)})},value:N,open:f===K,onOpenChange:G=>{G||(p.current=!0,S())},hideButton:!0})]},K)}case"fibBgToggle":{let K=x(L.enableKey)??!0;return(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:ne("flex items-center gap-1 px-1.5 py-1 rounded transition-colors",K?"text-blue-400 hover:bg-white/10":"text-muted-foreground/40 hover:bg-white/10 hover:text-muted-foreground"),onClick:()=>{v({[L.enableKey]:!K})},children:(0,Ae.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:(0,Ae.jsx)("rect",{x:"1.5",y:"1.5",width:"10",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.3",fill:K?"currentColor":"none",fillOpacity:K?.25:0})})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:K?"Hide background":"Show background"})]},"fibBgToggle")}case"fibBgColor":{if(!(x(L.gateKey)??!0))return null;let G=x(L.patchKey)??"#ffffff1a",V=`fibBgColor-${L.patchKey}`;return(0,Ae.jsxs)("div",{className:"relative",children:[(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:"flex items-center gap-1 px-1.5 py-1 rounded hover:bg-white/10 transition-colors",onClick:()=>b(V),children:(0,Ae.jsxs)("span",{className:"flex flex-col items-center gap-0.5",children:[(0,Ae.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:(0,Ae.jsx)("rect",{x:"2",y:"2",width:"9",height:"9",rx:"1",fill:"currentColor",fillOpacity:"0.3",stroke:"currentColor",strokeWidth:"1.2"})}),(0,Ae.jsx)(em,{color:G})]})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:L.label??"Background color"})]}),(0,Ae.jsx)(Ho,{onChange:q=>v({[L.patchKey]:q}),value:G,open:f===V,onOpenChange:q=>{q||(p.current=!0,S())},hideButton:!0})]},V)}case"fvpMode":{let K=x("profileMode")??"stacked";return(0,Ae.jsx)("div",{className:"flex gap-0.5",children:[{value:"stacked",label:"Stacked"},{value:"split",label:"Split"},{value:"delta",label:"Delta"},{value:"total",label:"Total"}].map(V=>(0,Ae.jsx)("button",{className:ne("px-2.5 h-7 rounded text-[11px] font-medium transition-colors",K===V.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:V.value})},children:V.label},V.value))},"fvpMode")}case"button":{if(!l)return null;let K=L.icon;return(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:"p-1 rounded hover:bg-white/10 text-muted-foreground hover:text-white transition-colors",onClick:()=>L.onClick(e,{requestOrderTicket:l}),children:(0,Ae.jsx)(K,{size:13})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:L.label})]},"button")}default:return null}};return(0,Ae.jsxs)(Ae.Fragment,{children:[(0,Ae.jsx)("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&&(0,Ae.jsx)("div",{style:{position:"fixed",inset:0,zIndex:9999,cursor:"grabbing"}}),(0,Ae.jsxs)("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:[(0,Ae.jsx)("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:(0,Ae.jsx)(Al,{size:13})}),B.map((L,H)=>E(L,H)),(0,Ae.jsx)("div",{className:"flex-1 w-4"}),(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:"p-1 rounded hover:bg-white/10 text-muted-foreground hover:text-foreground transition-colors",onClick:()=>m(!0),children:(0,Ae.jsx)(Nl,{size:13})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:"Settings"})]}),(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:ne("p-1 rounded hover:bg-white/10 transition-colors",T?"text-yellow-400":"text-muted-foreground"),onClick:()=>v({locked:!T}),children:T?(0,Ae.jsx)(no,{size:13}):(0,Ae.jsx)(Di,{size:13})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:T?"Unlock":"Lock"})]}),(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)("button",{className:"p-1 rounded hover:bg-white/10 text-muted-foreground hover:text-red-400 transition-colors",onClick:r,children:(0,Ae.jsx)(Mo,{size:13})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:"Delete"})]}),(0,Ae.jsxs)(Va,{children:[(0,Ae.jsxs)(Gt,{children:[(0,Ae.jsx)(qt,{asChild:!0,children:(0,Ae.jsx)(Wa,{asChild:!0,children:(0,Ae.jsx)("button",{className:"p-1 mr-1 rounded hover:bg-white/10 text-muted-foreground transition-colors",children:(0,Ae.jsx)(Os,{size:13})})})}),(0,Ae.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:"More"})]}),(0,Ae.jsxs)(ya,{align:"end",className:"bg-[#1c1e24] border-border",children:[(0,Ae.jsxs)(aa,{onClick:o,className:"gap-2 cursor-pointer text-xs",children:[(0,Ae.jsx)(Pl,{size:12})," Duplicate"]}),(0,Ae.jsxs)(aa,{onClick:r,className:"gap-2 cursor-pointer text-red-400 focus:text-red-400 text-xs",children:[(0,Ae.jsx)(Mo,{size:12})," Delete"]})]})]})]}),d&&(0,Ae.jsx)(aL,{drawing:g,onUpdate:v,onClose:()=>m(!1),onMouseEnter:i,onMouseLeave:s})]})}function dH(){return(0,Ae.jsx)("div",{className:"w-px h-4 bg-border mx-0.5 shrink-0"})}function em({color:e}){return(0,Ae.jsx)("div",{className:"h-[3px] w-[13px] rounded-full",style:{background:e}})}function fH({dash:e,color:t}){return(0,Ae.jsx)("svg",{width:"24",height:"10",viewBox:"0 0 24 10",children:(0,Ae.jsx)("line",{x1:"0",y1:"5",x2:"24",y2:"5",stroke:t,strokeWidth:"1.5",strokeDasharray:e.join(" ")||"none"})})}function cL(){return(0,Ae.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:(0,Ae.jsx)("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 mH(){return(0,Ae.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:(0,Ae.jsx)("rect",{x:"2",y:"2",width:"9",height:"9",stroke:"#ccc",strokeWidth:"1.4",fill:"none",rx:"1"})})}function pH(){return(0,Ae.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:(0,Ae.jsx)("rect",{x:"2",y:"2",width:"9",height:"9",fill:"#ccc",rx:"1"})})}var Xe={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 dL(e){let t={};for(let n of Object.keys(Xe))JSON.stringify(e[n])!==JSON.stringify(Xe[n])&&(t[n]=e[n]);return t}function fL(e){return{...Xe,...e??{}}}var Nr=require("react");function mL(e,t){return!t||t<=0?e:Math.round(e/t)*t}function Nh(e,t){return e[t]??{tpPrices:[],slPrices:[],hoveredGhost:null,draggingGhost:null}}function hH(e,t,n,r,o){let a=Nh(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 pL({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]=(0,Nr.useState)(null),[S,C]=(0,Nr.useState)(null),[w,k]=(0,Nr.useState)("default"),M=(0,Nr.useRef)("default"),I=(0,Nr.useCallback)(j=>{M.current=j,k(W=>W===j?W:j)},[]),x=(0,Nr.useRef)(f);x.current=f;let T=(0,Nr.useRef)({}),R=(0,Nr.useCallback)(()=>T.current,[]),P=(0,Nr.useRef)(null),D=(0,Nr.useRef)(null),N=(0,Nr.useRef)(!1),O=j=>{let W=j.currentTarget.getBoundingClientRect(),$=j.clientX-W.left,J=j.clientY-W.top;return[$,J]},A=(0,Nr.useCallback)(j=>p?.(j)??e.find(W=>W.id===j),[e,p]),B=(0,Nr.useCallback)((j,W)=>{t(e.map($=>$.id===j?{...$,...W}:$))},[e,t]),E=(0,Nr.useCallback)(j=>{let[W,$]=O(j),J=l();if(i.current=J.main?.h,s.current=J.main?.y??0,D.current){let{lineId:ze,kind:Ie}=D.current,ee=y.yToPrice($-(s?.current??0),i.current);if(ee=mL(ee,po(m?.current)),N.current){N.current=!1;let ce=Nh(T.current,ze),De=(Ie==="tp"?ce.tpPrices:ce.slPrices).length,ve=`${ze}-${Ie}-${De}`;D.current={lineId:ze,ghostId:ve,kind:Ie,index:De}}let{index:Be,ghostId:F}=D.current;T.current=hH(T.current,ze,Ie,Be,ee);let le=T.current[ze];le&&(T.current={...T.current,[ze]:{...le,draggingGhost:F,draggingGhostIdx:Be,draggingGhostType:Ie}}),d();return}if(P.current){let{lineId:ze}=P.current,Ie=A(ze);if(!Ie||Ie.locked)return;let ee=y.yToPrice($-(s?.current??0),i.current);ee=mL(ee,Ie.tickSize??po(m?.current)),Ie?.onMove&&Ie.onMove(ee);let Be=h.current?.get(ze);Be?(h.current.set(ze,{...Be,price:ee}),n([...h.current.values()])):B(ze,{price:ee}),d();return}let me=Dc(W,$,o.current);if(me.ghostHit){let{lineId:ze,ghostId:Ie}=me.ghostHit,ee=Nh(T.current,ze);if(ee.hoveredGhost!==Ie){let Be={};for(let[F,le]of Object.entries(T.current))Be[F]=F===ze?{...le,hoveredGhost:Ie}:{...le,hoveredGhost:null};Be[ze]||(Be[ze]={...ee,hoveredGhost:Ie}),T.current=Be,d()}b(null),I("ns-resize");return}let We=!1,Ce={};for(let[ze,Ie]of Object.entries(T.current))Ie.hoveredGhost?(Ce[ze]={...Ie,hoveredGhost:null},We=!0):Ce[ze]=Ie;if(We&&(T.current=Ce,d()),me.lineId!==v&&(b(me.lineId),d()),!me.lineId){I("default");return}let Ee=A(me.lineId);if(!Ee||Ee.locked){I("default");return}switch(me.part){case"close":case"reverse":I("pointer");break;case"pricePill":I(Ee.movable?"ns-resize":"default");break;case"line":case"pill":I(Ee.movable?"ns-resize":"pointer");break;default:I("default")}},[v,A,B,n,i,c,u,o,d,m,h,y]),L=(0,Nr.useCallback)(j=>{if(j.button==2&&(D.current&&(D.current=null),j.stopPropagation(),j.preventDefault()),j.button!==0)return;let[W,$]=O(j),J=Dc(W,$,o.current);if(J.ghostHit){let{lineId:We,ghostId:Ce,kind:Ee,index:ze}=J.ghostHit;j.stopPropagation(),j.preventDefault(),D.current={lineId:We,ghostId:Ce,kind:Ee,index:ze},N.current=!0;let Ie=Nh(T.current,We);T.current={...T.current,[We]:{...Ie,draggingGhost:Ce}},I("ns-resize");return}if(!J.lineId)return;let me=A(J.lineId);!me||me.locked||me.movable&&(J.part==="line"||J.part==="pill"||J.part==="pricePill")&&(j.stopPropagation(),j.preventDefault(),P.current={lineId:J.lineId,startY:$,startPrice:me.price,originalPrice:me.price},g&&(g.current=J.lineId),C(J.lineId),I("ns-resize"))},[A,o]),H=(0,Nr.useCallback)(j=>{if(D.current){let{lineId:J,kind:me,index:We}=D.current;D.current=null,N.current=!1;let Ce=T.current[J];if(Ce){let Ee=me==="tp"?Ce.tpPrices?.[We]:Ce.slPrices?.[We];Ee!=null&&x.current?.(J,me,We,Ee),T.current={...T.current,[J]:{...Ce,draggingGhost:null,draggingGhostType:null,draggingGhostIdx:null}}}I("ns-resize"),d();return}if(!P.current)return;let{lineId:W}=P.current;g&&(g.current=null);let $=A(W);if($){let me=h?.current?.get(W)?.price??$.price;$?.afterMove&&$.afterMove(me),B(W,{price:me})}P.current=null,C(null),I("ns-resize"),d()},[A,B,h,d]),K=(0,Nr.useCallback)(j=>{if(P.current||D.current)return;v&&(b(null),d());let W=!1,$={};for(let[J,me]of Object.entries(T.current))me.hoveredGhost?($[J]={...me,hoveredGhost:null},W=!0):$[J]=me;W&&(T.current=$,d()),I("default")},[v,d]),G=(0,Nr.useCallback)(j=>{let[W,$]=O(j),J=Dc(W,$,o.current);if(!J.lineId)return;let me=A(J.lineId);me?.onContextMenu&&(j.preventDefault(),j.stopPropagation(),me.onContextMenu(me.price,$))},[A,o]),V=(0,Nr.useCallback)(j=>{let[W,$]=O(j),J=Dc(W,$,o.current);if(J.ghostHit||!J.lineId)return;let me=A(J.lineId);if(!(!me||me.locked)){if(J.part==="close"){j.stopPropagation(),r(me),me.onClose?.(),b(null),I("default");return}if(J.part==="reverse"){j.stopPropagation(),me.onReverse?.();return}}},[A,o,r]),q=(0,Nr.useCallback)(j=>{let[W,$]=O(j),J=Dc(W,$,o.current);if(!J.lineId)return;let me=A(J.lineId);me?.onDoubleClick&&(j.stopPropagation(),me.onDoubleClick(me.price))},[A,o]);return{hoveredLineId:v,draggingLineId:S,cursor:w,cursorRef:M,getGhostState:R,onMouseMove:E,onMouseDown:L,onMouseUp:H,onMouseLeave:K,onContextMenu:G,onDoubleClick:q,onClick:V}}var Hr=require("react");var xe=require("react/jsx-runtime"),av=480,Cu=12,gH=["#e0e0e0","#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#a855f7","#ec4899","#26a69a","#ef5350","#facc15","#38bdf8","#84cc16","#f43f5e","#06b6d4","#8b5cf6"],bH=[{id:"params",label:"Params",icon:(0,xe.jsx)(bf,{size:13})},{id:"style",label:"Style",icon:(0,xe.jsx)(Fs,{size:13})}],ov=null;function yH(){return{x:Math.round((window.innerWidth-av)/2),y:Math.round(window.innerHeight*.15)}}function hL(e,t){let n=window.innerHeight-t-Cu;return Math.min(Math.max(Cu,e),Math.max(Cu,n))}function vH(e){return Math.max(Cu,Math.min(window.innerWidth-av-Cu,e))}function gL({indicator:e,onUpdate:t,onClose:n,onMouseEnter:r,onMouseLeave:o,redrawDebounceMs:a=50}){let i=(0,Hr.useRef)(null),s=(0,Hr.useRef)(ov??(typeof window<"u"?yH():{x:80,y:80})),[,l]=(0,Hr.useState)(0),[c,u]=(0,Hr.useState)("params"),d=(0,Hr.useRef)(null),m=(0,Hr.useRef)([]),h=(M=>["params","style"].indexOf(M))(c),p=m.current[h],[g,y]=(0,Hr.useState)(e.settings??{}),v=(0,Hr.useRef)(null),b=(0,Hr.useCallback)((M,I)=>{y(x=>{let T={...x,[M]:I};return v.current&&clearTimeout(v.current),v.current=setTimeout(()=>t(T),a),T})},[t,a]);(0,Hr.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]),(0,Hr.useLayoutEffect)(()=>{let M=i.current;if(!M)return;let I=hL(s.current.y,M.offsetHeight);I!==s.current.y&&(s.current={...s.current,y:I},ov=s.current,l(x=>x+1))});let S=(0,Hr.useCallback)(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:vH(T+N.clientX-I),y:hL(R+N.clientY-x,O)},ov=s.current,l(A=>A+1)},D=()=>{window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",D)};window.addEventListener("mousemove",P),window.addEventListener("mouseup",D)},[]),C=(0,Hr.useCallback)(()=>{o?.(),n()},[n,o]);(0,Hr.useEffect)(()=>{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(0,xe.jsxs)(xe.Fragment,{children:[(0,xe.jsx)("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
|
+
`}),(0,xe.jsxs)("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:av,maxHeight:`calc(100vh - ${s.current.y+Cu}px)`},onMouseDown:M=>M.stopPropagation(),onMouseEnter:r,onMouseLeave:o,children:[(0,xe.jsxs)("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:[(0,xe.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,xe.jsx)("h2",{className:"text-sm font-semibold text-white tracking-tight",children:e.name}),(0,xe.jsx)("p",{className:"text-[11px] text-white/40 mt-0.5",children:"Indicator settings"})]}),(0,xe.jsx)("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:(0,xe.jsx)(Kr,{size:14})})]}),(0,xe.jsxs)("div",{className:"flex gap-0.5 px-4 pt-2 pb-0 shrink-0 border-b border-white/6 relative",ref:d,children:[bH.map((M,I)=>(0,xe.jsxs)("button",{ref:x=>m.current[I]=x,onClick:()=>u(M.id),className:ne("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)),(0,xe.jsx)("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)`}})]}),(0,xe.jsxs)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden px-4 py-4 flex flex-col gap-3",children:[k.length===0&&(0,xe.jsxs)("p",{className:"text-[12px] text-white/30 text-center py-6",children:["No ",c," settings for this indicator."]}),k.map((M,I)=>(0,xe.jsx)(wH,{field:M,local:g,patch:b},I))]})]})]})}function wH({field:e,local:t,patch:n}){if(e.type==="section")return(0,xe.jsx)("div",{className:"pt-2 pb-1",children:(0,xe.jsx)("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(0,xe.jsxs)("button",{className:ne("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:[(0,xe.jsxs)("div",{children:[(0,xe.jsx)("p",{className:"text-[12px]",children:e.label}),e.description&&(0,xe.jsx)("p",{className:"text-[10px] text-white/35 mt-0.5",children:e.description})]}),(0,xe.jsx)(so,{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(0,xe.jsxs)("button",{className:ne("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:[(0,xe.jsx)("div",{className:ne("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&&(0,xe.jsx)(Yr,{size:10,strokeWidth:3,className:"text-white"})}),(0,xe.jsxs)("div",{className:"flex flex-col gap-0.5 min-w-0",children:[(0,xe.jsx)("span",{className:"text-[12px] leading-none",children:e.label}),e.description&&(0,xe.jsx)("span",{className:"text-[10px] text-white/30 leading-none",children:e.description})]})]})}if(e.type==="color")return(0,xe.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,xe.jsx)(Su,{children:e.label}),(0,xe.jsx)(nc,{value:String(t[e.key]??"#ffffff"),onChange:r=>n(e.key,r)})]});if(e.type==="dualColor")return(0,xe.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,xe.jsx)(Su,{children:e.label}),(0,xe.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,xe.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,xe.jsx)("p",{className:"text-[10px] text-white/40",children:e.labelA}),(0,xe.jsx)(nc,{value:String(t[e.keyA]??"#ffffff"),onChange:r=>n(e.keyA,r)})]}),(0,xe.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,xe.jsx)("p",{className:"text-[10px] text-white/40",children:e.labelB}),(0,xe.jsx)(nc,{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(0,xe.jsxs)(Ua,{label:e.label,children:[(0,xe.jsx)("div",{className:"w-full h-6 rounded-lg mb-3 border border-white/10",style:{background:`linear-gradient(to right, ${r}, ${o})`}}),(0,xe.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,xe.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,xe.jsx)("p",{className:"text-[10px] text-white/40",children:"Start"}),(0,xe.jsx)(nc,{value:r,onChange:a=>n(e.keyStart,a)})]}),(0,xe.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,xe.jsx)("p",{className:"text-[10px] text-white/40",children:"End"}),(0,xe.jsx)(nc,{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(0,xe.jsx)(Ua,{label:e.label,children:(0,xe.jsxs)("div",{className:"flex gap-3 items-start",children:[(0,xe.jsx)("div",{className:"flex-1 min-w-0",children:(0,xe.jsx)(nc,{value:r,onChange:a=>n(e.colorKey,a)})}),(0,xe.jsxs)("div",{className:"flex flex-col gap-1 w-28 shrink-0 pt-0.5",children:[(0,xe.jsxs)("p",{className:"text-[10px] text-white/35 font-medium",children:["Opacity - ",Math.round(o*100),"%"]}),(0,xe.jsx)(Wn,{value:[o],onValueChange:([a])=>n(e.opacityKey,a),min:0,max:1,step:.01}),(0,xe.jsxs)("div",{className:"flex justify-between text-[9px] text-white/25 font-mono",children:[(0,xe.jsx)("span",{children:"0%"}),(0,xe.jsx)("span",{children:"100%"})]})]})]})})}if(e.type==="toggledColor"){let r=!!t[e.toggleKey],o=String(t[e.colorKey]??"#e0e0e0");return(0,xe.jsx)(Ua,{label:"",children:(0,xe.jsxs)("div",{className:ne("flex flex-col rounded-lg border transition-colors overflow-hidden",r?"border-white/10 bg-white/3":"border-white/6 bg-white/2"),children:[(0,xe.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[(0,xe.jsx)(so,{checked:r,onCheckedChange:a=>n(e.toggleKey,a),className:"data-[state=checked]:bg-blue-500"}),(0,xe.jsx)("span",{className:ne("text-[12px] flex-1",r?"text-white":"text-white/40"),children:e.label}),!r&&(0,xe.jsx)("div",{className:"w-5 h-5 rounded-full border border-white/15",style:{background:o}})]}),r&&(0,xe.jsx)("div",{className:"px-3 pb-3 border-t border-white/6",children:(0,xe.jsx)("div",{className:"pt-3",children:(0,xe.jsx)(nc,{value:o,onChange:a=>n(e.colorKey,a)})})})]})})}if(e.type==="opacity"){let r=Number(t[e.key]??1);return(0,xe.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsx)(Su,{children:e.label}),(0,xe.jsxs)("span",{className:"text-[11px] font-mono text-white/40",children:[Math.round(r*100),"%"]})]}),(0,xe.jsx)(Wn,{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(0,xe.jsx)(Ua,{label:e.label,children:(0,xe.jsx)("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})=>(0,xe.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,xe.jsxs)("p",{className:"text-[10px] text-white/35 font-medium",children:[i," - ",Math.round(s*100),"%"]}),(0,xe.jsx)(Wn,{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(0,xe.jsxs)(Ua,{label:`${e.label} - ${r}px`,children:[(0,xe.jsx)(Wn,{value:[r],onValueChange:([o])=>n(e.key,Math.round(o)),max:48,min:8,step:1}),(0,xe.jsxs)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[(0,xe.jsx)("span",{children:"8px"}),(0,xe.jsx)("span",{children:"28px"}),(0,xe.jsx)("span",{children:"48px"})]})]})}if(e.type==="slider"){let r=Number(t[e.key]??e.min);return(0,xe.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsx)(Su,{children:e.label}),(0,xe.jsxs)("span",{className:"text-[11px] font-mono text-white/40",children:[r,e.suffix??""]})]}),(0,xe.jsx)(Wn,{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(0,xe.jsxs)(Ua,{label:`${e.label} - ${r}`,children:[(0,xe.jsx)(Wn,{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)}),(0,xe.jsx)("div",{className:"flex justify-between mt-1",children:e.steps.map(o=>(0,xe.jsx)("button",{className:ne("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(0,xe.jsx)(xH,{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(0,xe.jsx)(Ua,{label:e.label,children:(0,xe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,xe.jsx)("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"}),(0,xe.jsx)("span",{className:"flex-1 text-center text-[13px] font-mono text-white tabular-nums",children:r}),(0,xe.jsx)("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(0,xe.jsx)(Ua,{label:e.label,children:(0,xe.jsx)("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(0,xe.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,xe.jsx)(Su,{children:e.label}),(0,xe.jsx)("div",{className:"relative",children:(0,xe.jsxs)(Va,{children:[(0,xe.jsx)(Wa,{asChild:!0,children:(0,xe.jsxs)(br,{variant:"outline",className:"flex flex-row gap-1 h-8",children:[r,(0,xe.jsx)(or,{})]})}),(0,xe.jsx)(ya,{className:"z-[201]",children:e.options.map(o=>(0,xe.jsx)(aa,{onSelect:()=>n(e.key,o.value),children:o.label}))})]})})]})}if(e.type==="buttonGroup"){let r=String(t[e.key]??e.options[0]?.value??"");return(0,xe.jsx)(Ua,{label:e.label,children:(0,xe.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:e.options.map(o=>(0,xe.jsxs)("button",{className:ne("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(0,xe.jsx)(Ua,{label:"",children:(0,xe.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg border border-white/6 bg-white/3",children:[(0,xe.jsx)(so,{checked:r,onCheckedChange:a=>n(e.toggleKey,a),className:"data-[state=checked]:bg-blue-500"}),(0,xe.jsx)("span",{className:ne("text-[12px] flex-1",r?"text-white":"text-white/40 select-none"),children:e.toggleLabel}),(0,xe.jsxs)("div",{className:ne("flex items-center gap-1.5 transition-opacity",!r&&"opacity-30 pointer-events-none"),children:[(0,xe.jsx)("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&&(0,xe.jsx)("span",{className:"text-[11px] text-white/35",children:e.unit})]})]})})}return e.type==="inlineFields"?(0,xe.jsx)(Ua,{label:e.label,children:(0,xe.jsx)("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(0,xe.jsxs)("div",{className:"flex items-center gap-1 bg-white/4 border border-white/8 rounded-lg px-1",children:[(0,xe.jsx)("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"}),(0,xe.jsx)("span",{className:"text-[12px] font-mono text-white tabular-nums min-w-[2ch] text-center",children:a}),(0,xe.jsx)("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&&(0,xe.jsx)("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(0,xe.jsx)("div",{className:"flex gap-1",children:r.options.map(i=>(0,xe.jsx)("button",{title:i.label,className:ne("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(0,xe.jsxs)("button",{className:ne("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&&(0,xe.jsx)(Yr,{size:10,strokeWidth:3}),r.label]},o)}return null})})}):null}function xH({label:e,value:t,min:n,max:r,step:o,unit:a,onChange:i,inline:s}){let[l,c]=(0,Hr.useState)(()=>String(t)),u=(0,Hr.useRef)(!1);(0,Hr.useEffect)(()=>{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=(0,xe.jsx)("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:ne("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?(0,xe.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,xe.jsx)(Su,{children:e}),(0,xe.jsxs)("div",{className:"flex items-center gap-1.5",children:[m,a&&(0,xe.jsx)("span",{className:"text-[11px] text-white/30",children:a})]})]}):(0,xe.jsx)(Ua,{label:e,children:(0,xe.jsxs)("div",{className:"flex items-center gap-2",children:[m,a&&(0,xe.jsx)("span",{className:"text-[11px] text-white/35 shrink-0",children:a})]})})}function Su({children:e}){return(0,xe.jsx)("p",{className:"text-[12px] text-white/70",children:e})}function Ua({label:e,children:t}){return(0,xe.jsxs)("div",{className:"flex flex-col gap-2",children:[e&&(0,xe.jsx)("p",{className:"text-[10px] font-semibold text-white/35 uppercase tracking-widest",children:e}),t]})}function nc({value:e,onChange:t}){return(0,xe.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,xe.jsx)("div",{className:"grid grid-cols-8 gap-1.5",children:gH.map(n=>(0,xe.jsx)("button",{className:ne("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&&(0,xe.jsx)(Yr,{size:11,className:"text-black drop-shadow",strokeWidth:3})},n))}),(0,xe.jsx)(Ho,{onChange:t,value:e,className:"w-8 h-8 rounded-md border-2 border-border/50"})]})}var rc=60000000000n,tm=class{constructor(){se(this,"segments",[]);se(this,"totalMarketNs",0n);se(this,"rangeFrom",0n);se(this,"rangeTo",0n);se(this,"version",0)}_buildSegments(t,n,r,o){let a=Number(n/rc),i=Number(r/rc)+1,s=ks(BigInt(a)*rc,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=ip(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)*rc,v=BigInt(p)*rc,b=v-y;f.push({realStart:y,realEnd:v,marketStart:h,duration:b}),h+=b,d=!1}l++,l%60===0&&(s=ks(BigInt(p+1)*rc,t.timezone),l=s.minuteOfDay,c=s.dayOfWeek,u=s.isoDate)}if(d){let p=m===a?n:BigInt(m)*rc,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 Eh(){return new tm}var nm=require("react");var vr=require("react/jsx-runtime");function SH(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 bL({cellId:e,eventBus:t,chartType:n,chartSettings:r}){let[o,a]=(0,nm.useState)(null),[i,s]=(0,nm.useState)("ohlcv");if((0,nm.useEffect)(()=>t.on("status:compute",d=>{d.cellId===e&&(s(d.dataLevel),a(SH(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(0,vr.jsx)("div",{});let l=r.statusLineFontSize,c=Math.round(l*1.45),u=2;return(0,vr.jsx)("div",{className:"min-w-0",children:(0,vr.jsxs)("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&&(0,vr.jsxs)(vr.Fragment,{children:[(0,vr.jsxs)("span",{className:"text-white/50",children:["O"," ",(0,vr.jsx)("span",{className:"text-white/80",children:o.open.toFixed(2)})]}),(0,vr.jsxs)("span",{className:"text-white/50",children:["H"," ",(0,vr.jsx)("span",{className:"text-[#00e676]",children:o.high.toFixed(2)})]}),(0,vr.jsxs)("span",{className:"text-white/50",children:["L"," ",(0,vr.jsx)("span",{className:"text-[#ff1744]",children:o.low.toFixed(2)})]}),(0,vr.jsxs)("span",{className:"text-white/50",children:["C"," ",(0,vr.jsx)("span",{className:"text-white/80",children:o.close.toFixed(2)})]})]}),(n==="line"||n==="area"||n==="step"||n==="baseline")&&(0,vr.jsxs)(vr.Fragment,{children:[(0,vr.jsxs)("span",{className:"text-white/50",children:["A"," ",(0,vr.jsx)("span",{className:"text-[#ff1744]",children:o.bestAsk.toFixed(2)})]}),(0,vr.jsxs)("span",{className:"text-white/50",children:["B"," ",(0,vr.jsx)("span",{className:"text-[#00e676]",children:o.bestBid.toFixed(2)})]})]}),r.statusLineVolume&&o.volume>0&&(0,vr.jsxs)("span",{className:"text-white/50",children:["Vol ",(0,vr.jsx)("span",{className:"text-white/80",children:o.volume})]}),r.statusLineDelta&&o.volume>0&&i==="l3"&&(0,vr.jsxs)("span",{className:ne(o.delta>=0?"text-[#00e676]":"text-[#ff1744]"),children:["\u0394 ",o.delta>=0?"+":"",o.delta]}),r.statusLineChange&&(0,vr.jsxs)("span",{className:ne(o.change>=0?"text-[#00e676]":"text-[#ff1744]"),children:[o.change>=0?"+":"",o.change.toFixed(2)," (",o.changePct.toFixed(2),"%)"]})]})})}var om=require("react");var vi=require("react");var Hn=require("react/jsx-runtime");function iv(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 rm(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 yL(e){if(e==="24/7"||e==="always")return"24 / 7";let t=iv(e);return t?`${rm(t.openMin)} \u2013 ${rm(t.closeMin)}`:e}function CH(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 kH=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],vL=["Mon","Tue","Wed","Thu","Fri"];function TH(e){return e.length===7?"Every day":e.join(",")===vL.join(",")?"Mon \u2013 Fri":e.join(", ")}function IH(e){return!e||e.hours==="24/7"||e.hours==="always"}function MH(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 LH({session:e,nowMs:t}){let n=IH(e),r=e?.timezone??"UTC",o=1440,a=BigInt(t)*1000000n,i=ks(a,r),s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],l=e?.days??(n?kH:vL),c=s[i.dayOfWeek],u=e?.holidays?.includes(i.isoDate)??!1,d=!u&&l.includes(c),m=ks(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)=>(0,Hn.jsx)("div",{className:"absolute top-0 bottom-0",style:{left:v(T),width:`${((R-T)/o*100).toFixed(2)}%`,backgroundColor:P}},D),S=n?null:iv(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=iv(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(0,Hn.jsxs)("div",{className:"px-3 pt-2.5 pb-3 space-y-2",children:[(0,Hn.jsxs)("div",{className:"relative h-4",children:[(0,Hn.jsxs)("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&&(0,Hn.jsx)("div",{className:"absolute top-0 bottom-0 w-px rounded-full bg-foreground/50",style:{left:v(y)}})]}),(0,Hn.jsxs)("div",{className:"space-y-0.5",children:[u?(0,Hn.jsx)("div",{className:"text-[10px] font-medium text-amber-500/80",children:"Holiday \u2013 closed"}):n?(0,Hn.jsxs)("div",{className:"text-[10px] font-medium tabular-nums text-foreground/80",children:["Open ",yL("24/7")]}):k?d&&S?(0,Hn.jsxs)("div",{className:"text-[10px] font-medium tabular-nums text-foreground/80",children:[rm(S.openMin)," \u2013 ",rm(S.closeMin),p&&(0,Hn.jsx)("span",{className:"ml-1.5 text-amber-500/80 font-normal",children:"(modified)"})]}):w&&S?(0,Hn.jsxs)("div",{className:"text-[10px] font-medium tabular-nums text-foreground/60",children:["Closes ",rm(S.closeMin)]}):null:(0,Hn.jsx)("div",{className:"text-[10px] font-medium text-muted-foreground",children:"No session today"}),(0,Hn.jsxs)("div",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[(0,Hn.jsx)("span",{children:CH(r)}),(0,Hn.jsx)(Es,{className:"-mx-2"}),(0,Hn.jsx)("span",{children:TH(l)})]})]}),(e?.subsessions?.length??0)>0&&(0,Hn.jsx)("div",{className:"space-y-1 pt-1.5 border-t border-border/40",children:e.subsessions.map(T=>(0,Hn.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Hn.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,Hn.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-500/60 shrink-0"}),(0,Hn.jsx)("span",{className:"text-[10px] text-muted-foreground",children:T.label})]}),(0,Hn.jsx)("span",{className:"text-[10px] tabular-nums text-muted-foreground/80",children:yL(T.hours)})]},T.id))})]})}function wL({eventBus:e,session:t,horizon:n,sessionStatus:r,symbol:o}){let[a,i]=(0,vi.useState)(!1),[s,l]=(0,vi.useState)(()=>Number(n/1000000n)),c=(0,vi.useRef)(n),[u,d]=(0,vi.useState)(r);if((0,vi.useEffect)(()=>e.on("playback:seek",({tNs:b})=>{c.current=b}),[e]),(0,vi.useEffect)(()=>e.on("session:status",b=>{b.symbol!==void 0&&o!==void 0&&b.symbol!==o||d(b)}),[e,o]),(0,vi.useEffect)(()=>{if(!t||t.hours==="24/7"||t.hours==="always")return;let S=setInterval(()=>{l(Number(c.current/1000000n)),d(Ja(t,c.current))},1e3);return()=>clearInterval(S)},[t]),(0,vi.useEffect)(()=>{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=Mc(t,b),C=Number((S-b)/1000000n);C>0&&(y=MH(C))}catch{}let v=h&&y?`Opens in ${y}`:p?"Regular session":g?"Extended hours":null;return(0,Hn.jsx)("div",{className:"flex items-center mx-2",children:(0,Hn.jsxs)(gu,{open:a,onOpenChange:i,children:[(0,Hn.jsx)(bu,{asChild:!0,children:(0,Hn.jsx)("button",{className:"w-2 h-2 rounded-full shrink-0 cursor-pointer focus:outline-none group relative",style:{backgroundColor:m},children:(0,Hn.jsx)("div",{className:ne("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"}})})}),(0,Hn.jsxs)($l,{className:"w-72 p-0 overflow-hidden text-xs",align:"start",sideOffset:8,children:[(0,Hn.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2.5 border-b border-border/60",children:[(0,Hn.jsx)("div",{className:"w-2 h-2 rounded-full shrink-0 mt-px",style:{backgroundColor:m}}),(0,Hn.jsxs)("div",{children:[(0,Hn.jsx)("div",{className:"font-medium text-foreground leading-tight",children:f}),v&&(0,Hn.jsx)("div",{className:"text-muted-foreground text-[10px] mt-0.5 leading-tight",children:v})]})]}),(0,Hn.jsx)(LH,{session:t,nowMs:s})]})]})})}var nl=require("react/jsx-runtime");function Oh({icon:e,size:t=24,className:n,fallback:r}){let o=typeof e=="string"?{src:e}:e;return o?"render"in o?(0,nl.jsx)(nl.Fragment,{children:o.render({size:t})}):"src"in o?(0,nl.jsx)("img",{src:o.src,alt:o.alt??"",width:t,height:t,className:ne("rounded-full object-cover shrink-0",n),style:{width:t,height:t}}):(0,nl.jsx)(xL,{text:o.text,color:o.color,size:t,className:n}):r?(0,nl.jsx)(xL,{text:r,size:t,className:n}):null}function xL({text:e,color:t,size:n,className:r}){return(0,nl.jsx)("span",{className:ne("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()})}var Pt=require("react/jsx-runtime");function SL({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]=(0,om.useState)(null),h=t.filter(p=>p.paneId===e.id||p.layout==="overlay"&&e.isMain);return(0,Pt.jsx)("div",{className:"flex items-center justify-between px-2 h-7 z-10 w-full min-w-0",style:{pointerEvents:"none"},children:(0,Pt.jsxs)("div",{className:"flex gap-1 min-w-0 flex-col pt-1 h-full w-full",children:[e.isMain&&(0,Pt.jsxs)("div",{className:"flex flex-row items-center flex-wrap gap-x-2 gap-y-0.5 min-w-0",children:[(0,Pt.jsxs)("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:[(0,Pt.jsxs)("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)&&(0,Pt.jsx)("span",{className:"pr-1",children:(0,Pt.jsx)(Oh,{icon:d?.legendIcon??d?.icon,size:18})}),d?.longName??e.symbol]}),(0,Pt.jsx)(Es,{className:"text-muted-foreground w-2"}),(0,Pt.jsx)("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}),(0,Pt.jsx)(Es,{className:"text-muted-foreground w-2 -ml-px"}),(0,Pt.jsx)("span",{className:"text-[1rem] text-white/90 select-none cursor-default ml-px",children:e.exchange}),c&&(0,Pt.jsx)(wL,{eventBus:i,session:s,horizon:l,sessionStatus:c,symbol:d?.symbol})]}),u]}),(0,Pt.jsx)("div",{className:"flex flex-col gap-0 -ml-1",children:h.map(p=>(0,Pt.jsxs)("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:[(0,Pt.jsx)("span",{className:ne("text-[13px] text-muted-foreground select-none mr-1 cursor-default",!p.visible&&"opacity-50"),children:p.name}),(0,Pt.jsxs)("div",{className:ne("flex items-center gap-0.5 transition-opacity duration-100",m===p.id?"opacity-100":"opacity-0"),children:[(0,Pt.jsxs)(Gt,{delayDuration:700,children:[(0,Pt.jsx)(qt,{asChild:!0,children:(0,Pt.jsx)("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?(0,Pt.jsx)(Da,{size:13}):(0,Pt.jsx)(Ri,{size:13})})}),(0,Pt.jsx)(Ut,{className:"bg-background border border-border",children:p.visible?"Hide indicator":"Show indicator"})]}),(0,Pt.jsxs)(Gt,{delayDuration:700,children:[(0,Pt.jsx)(qt,{asChild:!0,children:(0,Pt.jsx)("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:(0,Pt.jsx)(hf,{size:13})})}),(0,Pt.jsx)(Ut,{className:"bg-background border border-border",children:"Settings"})]}),(0,Pt.jsxs)(Gt,{delayDuration:700,children:[(0,Pt.jsx)(qt,{asChild:!0,children:(0,Pt.jsx)("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:(0,Pt.jsx)(Mo,{size:13})})}),(0,Pt.jsx)(Ut,{className:"bg-background border border-border",children:"Remove indicator"})]})]})]},p.id))})]})})}function CL({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]=(0,om.useState)(null);return(0,om.useEffect)(()=>m.on("pane:hovered",p=>p&&h(p.id)),[m]),(0,Pt.jsxs)("div",{className:ne("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&&(0,Pt.jsxs)(Gt,{delayDuration:700,children:[(0,Pt.jsx)(qt,{asChild:!0,children:(0,Pt.jsx)("button",{className:"p-0.5 rounded hover:bg-white/10 text-muted-foreground hover:text-foreground transition-colors",onClick:()=>r(e.id),children:(0,Pt.jsx)(Vd,{size:12})})}),(0,Pt.jsx)(Ut,{className:"bg-background border border-border",children:"Move pane up"})]}),t<n-1&&(0,Pt.jsxs)(Gt,{delayDuration:700,children:[(0,Pt.jsx)(qt,{asChild:!0,children:(0,Pt.jsx)("button",{className:"p-0.5 rounded hover:bg-white/10 text-muted-foreground hover:text-foreground transition-colors",onClick:()=>o(e.id),children:(0,Pt.jsx)(Fd,{size:12})})}),(0,Pt.jsx)(Ut,{className:"bg-background border border-border",children:"Move pane down"})]}),!e.isMain&&(0,Pt.jsxs)(Pt.Fragment,{children:[(0,Pt.jsxs)(Gt,{delayDuration:700,children:[(0,Pt.jsx)(qt,{asChild:!0,children:(0,Pt.jsx)("button",{className:"p-0.5 rounded hover:bg-white/10 text-muted-foreground hover:text-red-400 transition-colors",onClick:()=>a(e.id),children:(0,Pt.jsx)(Kr,{size:12})})}),(0,Pt.jsx)(Ut,{className:"bg-background border border-border",children:"Remove pane"})]}),(0,Pt.jsxs)(Gt,{delayDuration:700,children:[(0,Pt.jsx)(qt,{asChild:!0,children:(0,Pt.jsx)("button",{className:ne("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?(0,Pt.jsx)(Gd,{size:12}):(0,Pt.jsx)(Ud,{size:12})})}),(0,Pt.jsx)(Ut,{className:"bg-background border border-border",children:"Collapse pane"})]})]}),(0,Pt.jsxs)(Gt,{delayDuration:700,children:[(0,Pt.jsx)(qt,{asChild:!0,children:(0,Pt.jsx)("button",{className:ne("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?(0,Pt.jsx)(af,{size:12}):(0,Pt.jsx)(of,{size:12})})}),(0,Pt.jsx)(Ut,{className:"bg-background border border-border",children:l?"Restore panes":"Maximize pane"})]})]})}var rl=require("react");var wi=require("react/jsx-runtime");function kL({icon:e,label:t,visible:n,className:r,style:o}){return(0,wi.jsxs)("div",{className:ne("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 TL(){return(0,wi.jsxs)("svg",{width:9,height:9,viewBox:"0 0 24 24",fill:"none",className:"animate-spin [animation-duration:900ms]","aria-hidden":!0,children:[(0,wi.jsx)("circle",{cx:"12",cy:"12",r:"9.5",stroke:"currentColor",strokeWidth:"3",opacity:.2}),(0,wi.jsx)("path",{d:"M21.5 12A9.5 9.5 0 0 0 12 2.5",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function IL({eventBus:e,cellId:t}){let[n,r]=(0,rl.useState)(!1);return(0,rl.useEffect)(()=>e.on("heatmap:status",o=>{o.cellId!==void 0&&t!==void 0&&o.cellId!==t||r(o.recalculating)}),[e,t]),(0,wi.jsx)(kL,{icon:(0,wi.jsx)(TL,{}),label:"Rebuilding heatmap",visible:n,className:"bottom-9 left-2"})}function ML({eventBus:e,symbol:t,priceScaleWidth:n}){let[r,o]=(0,rl.useState)(""),a=(0,rl.useRef)(null);(0,rl.useEffect)(()=>{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"?(0,wi.jsx)(Yr,{size:9,strokeWidth:3}):(0,wi.jsx)(TL,{}),s=r==="preview"?"Preview data":r==="done"?"Up to date":"Loading data";if(r)return(0,wi.jsx)(kL,{icon:i,label:s,visible:!0,className:"bottom-9",style:{right:n+8}})}var as=require("react");var Nn=require("react/jsx-runtime");function RH({size:e=20}){let t=(0,as.useId)();return(0,Nn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",className:"animate-spin [animation-duration:200ms]","aria-hidden":!0,children:[(0,Nn.jsx)("defs",{children:(0,Nn.jsxs)("linearGradient",{id:t,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[(0,Nn.jsx)("stop",{offset:"0%",stopColor:"#16c4b0"}),(0,Nn.jsx)("stop",{offset:"100%",stopColor:"#06b6d4"})]})}),(0,Nn.jsx)("circle",{cx:"12",cy:"12",r:"9.5",stroke:"currentColor",strokeWidth:"2",opacity:.12}),(0,Nn.jsx)("path",{d:"M21.5 12A9.5 9.5 0 0 0 12 2.5",stroke:`url(#${t})`,strokeWidth:"2",strokeLinecap:"round"})]})}function PH(e){let[t,n]=(0,as.useState)(e<=0),[r,o]=(0,as.useState)(!1);return(0,as.useEffect)(()=>{if(t)return;let a=setTimeout(()=>n(!0),e);return()=>clearTimeout(a)},[e,t]),(0,as.useEffect)(()=>{if(!t)return;let a=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(a)},[t]),{mounted:t,visible:r}}function LL({symbol:e,timeframe:t,delayMs:n=220}){let{mounted:r,visible:o}=PH(n);if(!r)return null;let a=[e,t].filter(Boolean).join(" \xB7 ");return(0,Nn.jsx)("div",{className:ne("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:(0,Nn.jsxs)("div",{className:"flex flex-col items-center gap-2.5 px-6 text-center",children:[(0,Nn.jsx)(RH,{}),(0,Nn.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,Nn.jsx)("span",{className:"text-[13px] leading-none text-white/80",children:"Loading market data"}),a&&(0,Nn.jsx)("span",{className:"text-[11px] leading-none text-muted-foreground tabular-nums",children:a})]})]})})}function sv(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:(0,Nn.jsx)(mf,{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:(0,Nn.jsx)(_s,{size:18}),canRetry:!1};case"unauthenticated":return{tier:"notice",title:"Session expired",body:"Sign in again to keep loading market data.",icon:(0,Nn.jsx)(no,{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:(0,Nn.jsx)(no,{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:(0,Nn.jsx)(vf,{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:(0,Nn.jsx)(Cf,{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:(0,Nn.jsx)(pf,{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:(0,Nn.jsx)(ga,{size:18}),canRetry:!0};default:return{tier:"error",title:"Couldn't load data",body:t?.trim()||"Something went wrong while loading this chart.",icon:(0,Nn.jsx)(ga,{size:18}),canRetry:!0}}}function RL({code:e,message:t,symbol:n,timeframe:r,onRetry:o}){let[a,i]=(0,as.useState)(!1),{tier:s,title:l,body:c,icon:u,canRetry:d}=sv(e,t,n);return(0,Nn.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background",children:(0,Nn.jsxs)("div",{className:"flex max-w-[19rem] flex-col items-center gap-3 px-6 text-center",children:[(0,Nn.jsx)("div",{className:ne("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}),(0,Nn.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,Nn.jsx)("span",{className:"text-[13px] font-semibold leading-snug text-white/90",children:l}),(0,Nn.jsx)("span",{className:"text-[11.5px] leading-relaxed text-muted-foreground",children:c}),(n||r)&&s==="empty"&&(0,Nn.jsx)("span",{className:"mt-0.5 text-[11px] leading-none text-muted-foreground/60 tabular-nums",children:[n,r].filter(Boolean).join(" \xB7 ")})]}),d&&o&&(0,Nn.jsxs)("button",{onClick:o,className:ne("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:[(0,Nn.jsx)(uf,{size:11}),"Try again"]}),(e||t)&&(0,Nn.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,Nn.jsx)("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&&(0,Nn.jsxs)("div",{className:"flex flex-col gap-0.5 text-[10.5px] leading-relaxed text-muted-foreground/60",children:[(0,Nn.jsx)("span",{className:"font-mono tabular-nums",children:e||"unknown"}),t&&(0,Nn.jsx)("span",{className:"break-words",children:t})]})]})]})})}var DH=`(()=>{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
|
+
`,lv;function PL(){return lv||(lv=URL.createObjectURL(new Blob([DH],{type:"text/javascript"}))),lv}var AH='(()=>{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',cv;function DL(){return cv||(cv=URL.createObjectURL(new Blob([AH],{type:"text/javascript"}))),cv}var mt=require("react");var BH=["A","C","M","T","F","R"],NH=["B","A","N"],EH=1e6;function ja(e=EH){let t=new ArrayBuffer(e*20);return{_buf:t,_view:new DataView(t),length:0,capacity:e,firstTs:0n,lastTs:0n}}var is={ts_event:"",action:"A",side:"N",price:null,size:0,order_id:"0",sequence:0,flags:0};function ss(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 is.action=BH[u>>4&15]??"A",is.side=NH[u>>2&3]??"N",is.price=a===-2147483648?null:a/100,is.size=i,is.order_id=String(s|l<<8|c<<16),is.ts_event=OH(o),is.sequence=t,is.flags=0,is}function ls(e,t){return e._view.getBigInt64(t*20,!0)}function am(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;ls(e,a)<=t?(o=a,n=a+1):r=a-1}return o}function OH(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 AL(e){return{tMin:e.tMin.toString(),tMax:e.tMax.toString(),pMin:e.pMin,pMax:e.pMax}}function oc(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 _H(e,t,n,r){if(e.length===0)return t;let o=oc(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 Vr(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 uv(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 BL(e){let t=(0,mt.useRef)(e.cellSymbol);t.current=e.cellSymbol;let n=(0,mt.useRef)(ja()),r=(0,mt.useRef)([]),o=(0,mt.useRef)([]),a=(0,mt.useRef)([]),i=(0,mt.useRef)([]),s=(0,mt.useRef)([]),l=(0,mt.useRef)({barNs:0n,bars:[],display:[]}),c=(0,mt.useRef)([]),u=(0,mt.useRef)(null),d=(0,mt.useRef)(0n),m=(0,mt.useRef)(0),f=(0,mt.useRef)(-1),h=(0,mt.useRef)(-1),p=(0,mt.useRef)(-1),g=(0,mt.useRef)(null),y=(0,mt.useRef)(0n),v=(0,mt.useRef)(0n),b=(0,mt.useRef)(null),S=(0,mt.useRef)(null),C=(0,mt.useRef)(null),w=(0,mt.useRef)(null),k=(0,mt.useRef)(null),M=(0,mt.useRef)(null),I=(0,mt.useRef)(0),x=(0,mt.useRef)(null),T=(0,mt.useRef)(null),R=(0,mt.useRef)(null),P=(0,mt.useRef)(null),D=(0,mt.useRef)(gl()),N=(0,mt.useRef)(0n),O=(0,mt.useRef)(0),A=(0,mt.useRef)(null),B=(0,mt.useRef)(0n),E=(0,mt.useRef)(null),L=(0,mt.useRef)(null),H=(0,mt.useRef)(null),K=(0,mt.useRef)(0),G=(0,mt.useRef)(!1),V=(0,mt.useRef)(null),q=(0,mt.useRef)(null),j=(0,mt.useRef)(0),W=(0,mt.useRef)(!1),$=(0,mt.useRef)(!1),J=(0,mt.useCallback)(()=>e.externalDomPanelRef?.current??L.current,[]),me=(0,mt.useCallback)(ie=>{let ge=r.current;if(ge.length===0)return ge;let pe=0,Le=ge.length-1,Ue=ge.length-1;for(;pe<=Le;){let Ge=pe+Le>>>1;ge[Ge].ts<=ie?(Ue=Ge,pe=Ge+1):Le=Ge-1}return Ue===ge.length-1?ge:ge.slice(0,Ue+1)},[]),We=(0,mt.useCallback)(()=>({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}),[]),Ce=(0,mt.useCallback)((ie,ge)=>{if(ge===0n){S.current=null;return}let pe=new Map;for(let Le of ie){if(Le.ts>e.horizonRef.current)break;let Ue=Le.ts/ge*ge,Ge=pe.get(Ue);Ge?(Le.price>Ge.high&&(Ge.high=Le.price),Le.price<Ge.low&&(Ge.low=Le.price),Ge.close=Le.price,Ge.volume+=Le.size,Ge.delta+=Le.side==="B"?Le.size:-Le.size):pe.set(Ue,{open:Le.price,high:Le.price,low:Le.price,close:Le.price,volume:Le.size,delta:Le.side==="B"?Le.size:-Le.size})}S.current=pe},[]),Ee=(0,mt.useCallback)(ie=>{let ge=x.current;if(!ge)return;let pe=nC(ge,ge.width,ge.height,ie),Le=new OffscreenCanvas(ge.width,ge.height);Le.getContext("2d").putImageData(pe,0,0),T.current?.close(),T.current=Le.transferToImageBitmap(),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markDirty("base"),e.renderEngineRef.current?.markDirty("drawings"),e.updateSettingsBarPosRef.current(e.selectedDrawingIdRef.current)},[]),ze=(0,mt.useCallback)(ie=>{let ge=i.current;if(ge.length===0||ie<0)return;let pe=Math.min(ie,ge.length-1);if(pe===f.current)return;let Le=e.activeTimeframeRef.current.barNs;if(f.current<0){if(Le===0n)a.current=ge.slice(0,pe+1);else{let Ge=[];for(let Ve=0;Ve<=pe;Ve++){let Ne=ge[Ve],Se=Ne.ts/Le*Le,He=Ge.length>0?Ge[Ge.length-1]:null;He&&He.ts===Se?(He.bestBid=Ne.bestBid,He.bestAsk=Ne.bestAsk):Ge.push({ts:Se,bestBid:Ne.bestBid,bestAsk:Ne.bestAsk})}a.current=Ge}f.current=pe;return}if(Le===0n){a.current=ge.slice(0,pe+1),f.current=pe;return}let Ue=a.current;for(let Ge=f.current+1;Ge<=pe;Ge++){let Ve=ge[Ge],Ne=Ve.ts/Le*Le,Se=Ue.length>0?Ue[Ue.length-1]:null;Se&&Se.ts===Ne?(Se.bestBid=Ve.bestBid,Se.bestAsk=Ve.bestAsk):Ue.push({ts:Ne,bestBid:Ve.bestBid,bestAsk:Ve.bestAsk})}f.current=pe},[]),Ie=ie=>{let ge=i.current;if(ge.length===0)return-1;let pe=0,Le=ge.length-1,Ue=-1;for(;pe<=Le;){let Ge=pe+Le>>>1;ge[Ge].ts<=ie?(Ue=Ge,pe=Ge+1):Le=Ge-1}return Ue},ee=(0,mt.useCallback)(()=>{let ie=n.current,ge=h.current;if(ge<0||!V.current)return;let pe=ge+1,Le=ie._buf.slice(0,pe*20),Ue=++I.current;V.current.postMessage({event:"rebuild_footprint",requestId:vn(),compactBuf:Le,barNs:e.activeTimeframeRef.current.barNs,fpSeq:Ue,fpHorizonIdx:ge,fpOptions:We()},[Le])},[]),Be=(0,mt.useCallback)((ie,ge)=>{let pe=u.current;if(!pe)return;let Le=n.current,Ue=d.current,Ge=0;for(let He=ie;He>=0;He--)if(ls(Le,He)/ge*ge<Ue){Ge=He+1;break}pe.totalVol=0,pe.totalDelta=0;let Ve=new Map;for(let He=Ge;He<=ie;He++){let _e=ss(Le,He);if(_e.action!=="T"||_e.price===null||_e.side==="N")continue;pe.totalVol+=_e.size,_e.side==="B"?pe.totalDelta+=_e.size:pe.totalDelta-=_e.size;let dt=Ve.get(_e.price)??{bidVol:0,askVol:0};_e.side==="B"?dt.bidVol+=_e.size:dt.askVol+=_e.size,Ve.set(_e.price,dt)}let Ne=0,Se=0;if(pe.levels=Array.from(Ve.entries()).map(([He,{bidVol:_e,askVol:dt}])=>{let _t=_e+dt,te=_e-dt;return _t>Ne&&(Ne=_t),Math.abs(te)>Se&&(Se=Math.abs(te)),{price:He,bidVol:_e,askVol:dt,delta:te,totalVol:_t,bidImbalance:!1,askImbalance:!1,diagAskImbalance:!1,diagBidImbalance:!1,absorption:!1}}),pe.maxLevelVol=Ne,pe.maxAbsDelta=Se,pe.levels.length>0){let He=pe.levels.reduce((_e,dt)=>dt.bidVol+dt.askVol>_e.bidVol+_e.askVol?dt:_e,pe.levels[0]);pe.poc=He.price}},[]),F=(0,mt.useCallback)((ie,ge,pe,Le)=>{if(pe===0n||ge<=ie)return!1;let Ue=n.current,Ge=!1;for(let Ve=ie+1;Ve<=ge;Ve++){let Ne=ss(Ue,Ve);if(Ne.action!=="T"||Ne.price===null||Ne.side==="N")continue;let Se=ls(Ue,Ve)/pe*pe;u.current&&Se>d.current&&(u.current=null,d.current=Se,m.current=0,Ge=!0),u.current||(u.current={ts:Se,open:Ne.price,high:Ne.price,low:Ne.price,close:Ne.price,totalVol:0,totalDelta:0,maxLevelVol:0,maxAbsDelta:0,levels:[],isBullish:!0,poc:Ne.price,stackedBuyZones:[],stackedSellZones:[],unfinishedTop:!1,unfinishedBottom:!1,absorptionCount:0,diagDominant:"none"},d.current=Se,m.current=0);let He=u.current;Ne.price>He.high&&(He.high=Ne.price),Ne.price<He.low&&(He.low=Ne.price),He.close=Ne.price,He.totalVol+=Ne.size,Ne.side==="B"?He.totalDelta+=Ne.size:He.totalDelta-=Ne.size,m.current++}return u.current&&Be(ge,pe),Ge},[]),le=(0,mt.useCallback)(()=>{let ie=u.current;if(!ie)return;let ge=s.current;ge.length>0&&ge[ge.length-1].ts===ie.ts?ge[ge.length-1]=ie:s.current=[...ge,ie]},[]),ce=(0,mt.useCallback)(ie=>{h.current=ie,p.current=ie,u.current=null,d.current=0n,m.current=0,f.current=-1},[]),ke=(0,mt.useCallback)(ie=>{if(g.current!=="ohlcv")return;let ge=C.current??[],pe=Math.min(...ge.map(Xt=>Number(Xt.resolution))),Le=ge.find(Xt=>Number(Xt.resolution)===pe)?.bars??[],Ue=e.activeTimeframeRef.current.barNs;if(Ue<=0n)return;let{start:Ge,end:Ve}=wd(ie,Ue,e.sessionMapperRef.current),Ne=Number(Ge/1000000n),Se=Number(Ve/1000000n),He=Number(ie/1000000n),_e=0,dt=Le.length-1,_t=Le.length;for(;_e<=dt;){let Xt=_e+dt>>>1;Le[Xt].time>=Ne?(_t=Xt,dt=Xt-1):_e=Xt+1}let te=0,Me=1/0,Pe=0,at=0,nt=0,pt=!1;for(let Xt=_t;Xt<Le.length;Xt++){let Ft=Le[Xt];if(Ft.time>=Se||Ft.time>=He)break;(Ft.volume??0)!==0&&(pt||(pt=!0,Pe=Ft.open),Ft.high>te&&(te=Ft.high),Ft.low<Me&&(Me=Ft.low),at=Ft.close,nt+=Ft.volume)}if(pt&&nt)u.current={ts:Ge,open:Pe,high:te,low:Me,close:at,totalVol:nt=Math.round(nt*1e8)/1e8,totalDelta:0,maxLevelVol:0,maxAbsDelta:0,levels:[],isBullish:at>=Pe,poc:0,stackedBuyZones:[],stackedSellZones:[],unfinishedTop:!1,unfinishedBottom:!1,absorptionCount:0,diagDominant:"none"};else{let Xt=l.current.display,Ft=0,cr=Xt.length-1,Mn=-1;for(;Ft<=cr;){let Vn=Ft+cr>>>1;Xt[Vn].time<Ne?(Mn=Vn,Ft=Vn+1):cr=Vn-1}let ir=Mn>=0?Xt[Mn]:void 0;if(!ir)return;u.current={ts:BigInt(ir.time*1e6),open:ir.open,high:ir.high,low:ir.low,close:ir.close,totalVol:ir.volume,totalDelta:0,maxLevelVol:0,maxAbsDelta:0,levels:[],isBullish:ir.close>=ir.open,poc:0,stackedBuyZones:[],stackedSellZones:[],unfinishedTop:!1,unfinishedBottom:!1,absorptionCount:0,diagDominant:"none"}}},[]),De=ie=>{let{bitmap:ge,bounds:pe,requestId:Le}=ie.data;if(Le!==K.current){ge.close();return}x.current?.close(),x.current=ge,P.current={tMin:BigInt(pe.tMin),tMax:BigInt(pe.tMax),pMin:pe.pMin,pMax:pe.pMax},Ee(e.chartSettingsRef.current.heatmapContrast),e.eventBus.emit("heatmap:status",{recalculating:!1,cellId:e.cellId})},ve=(0,mt.useCallback)(()=>{K.current++},[]),Qe=(0,mt.useCallback)((ie,ge)=>{let pe=q.current;if(!pe)return;let Le="__scripted__",Ue=e.indicatorsRef.current.filter(Se=>Se.workerInit&&Se.workerInit!==Le&&Se.hydrate);function Ge(Se){let He=typeof Se=="bigint"?Se:BigInt(Se);return He<1000000000000n?He*1000000000n:He<1000000000000000n?He*1000000n:He<1000000000000000000n?He*1000n:He}let Ve=[];if(g.current==="l3"){for(let[Se,He]of S.current??new Map)Ve.push({ts:Ge(Se),open:He.open,high:He.high,low:He.low,close:He.close,volume:He.volume});Ve.sort((Se,He)=>Se.ts<He.ts?-1:1)}else g.current==="ohlcv"&&u.current&&Ve.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 Ne=ie.map(Se=>({time:Number(Se.ts/1000000n),price:Se.price,size:Se.size,side:Se.side}));for(let Se of e.indicatorsRef.current)Se.workerInit===Le&&e.eventBus.emit("plugin:scripted-recompute",{id:Se.id});if(Ue.length>0){let Se=String(++j.current);pe.postMessage({type:"compute",requestId:Se,trades:ie,ohlcv:Ve,ticks:Ne,snapshots:[],barNs:ge,horizon:e.horizonRef.current,indicators:Ue.map(He=>({id:He.id,workerInit:He.workerInit,params:He.workerParams}))}),pe.postMessage({type:"register-update-fns",horizon:e.horizonRef.current,indicators:Ue.map(He=>({id:He.id,workerUpdate:He.workerUpdate}))})}},[]),Ye=(0,mt.useCallback)(ie=>{let ge=q.current;if(!ge)return;let pe=r.current,Le=B.current,Ue=0,Ge=pe.length-1,Ve=pe.length;for(;Ue<=Ge;){let Me=Ue+Ge>>>1;pe[Me].ts<=Le?Ue=Me+1:(Ve=Me,Ge=Me-1)}let Ne=Ve-1;for(Ue=Ve,Ge=pe.length-1;Ue<=Ge;){let Me=Ue+Ge>>>1;pe[Me].ts<=ie?(Ne=Me,Ue=Me+1):Ge=Me-1}B.current=ie;let Se=Ne>=Ve?pe.slice(Ve,Ne+1):[],He="__scripted__",_e=e.indicatorsRef.current.filter(Me=>Me.workerUpdate&&Me.workerUpdate!==He&&Me.appendHydrate);function dt(Me){let Pe=typeof Me=="bigint"?Me:BigInt(Me);return Pe<1000000000000n?Pe*1000000000n:Pe<1000000000000000n?Pe*1000000n:Pe<1000000000000000000n?Pe*1000n:Pe}let _t=[];if(g.current==="l3"){for(let[Me,Pe]of S.current??new Map)_t.push({ts:dt(Me),open:Pe.open,high:Pe.high,low:Pe.low,close:Pe.close,volume:Pe.volume});_t.sort((Me,Pe)=>Me.ts<Pe.ts?-1:1)}else g.current==="ohlcv"&&u.current&&_t.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 te=Se.map(Me=>({time:Number(Me.ts/1000000n),price:Me.price,size:Me.size,side:Me.side}));if(_e.length>0){let Me=String(++j.current);ge.postMessage({type:"compute",requestId:Me,trades:Se,ohlcv:_t,ticks:te,snapshots:[],barNs:e.activeTimeframeRef.current.barNs,horizon:ie,indicators:_e.map(Pe=>({id:Pe.id,workerInit:Pe.workerInit,params:Pe.workerParams}))}),ge.postMessage({type:"register-update-fns",horizon:ie,indicators:_e.map(Pe=>({id:Pe.id,workerUpdate:Pe.workerUpdate}))})}for(let Me of e.indicatorsRef.current)Me.workerInit===He&&e.eventBus.emit("plugin:scripted-recompute",{id:Me.id})},[]),$e=(0,mt.useCallback)(()=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{let ie=e.viewRef.current,ge=e.baseCanvasRef.current;if(!ie||!ge)return;e.indicatorsRef.current.some(He=>He.id==="vp_visiblerange")&&Qe(me(e.horizonRef.current),e.activeTimeframeRef.current.barNs);let pe="__scripted__";for(let He of e.indicatorsRef.current)He.workerInit===pe&&e.eventBus.emit("plugin:scripted-recompute",{id:He.id});if(!G.current||!e.chartSettingsRef.current.showHeatmap)return;let Le=ge.width-e.priceScaleWidthRef.current,Ue=e.layoutsCacheRef.current.main,Ge=Ue?Ue.h:ge.height-(e.hideTimeScale?0:kn);if(Le<=0||Ge<=0)return;ve();let Ve=++K.current,Ne=e.horizonRef.current,Se={type:"render",requestId:Ve,bounds:AL(ie),chartW:Le,chartH:Ge,horizonNs:Ne>0n?Ne.toString():void 0};e.eventBus.emit("heatmap:status",{recalculating:!0,cellId:e.cellId}),H.current.postMessage(Se)},e.chartSettingsRef.current.resamplingDebounce)},[e.chartSettingsRef.current.resamplingDebounce]),bt=ie=>{let ge=ie.data;if(ge.type==="compute"){let{requestId:pe,results:Le,errors:Ue}=ge;if(pe!==String(j.current))return;let Ge=e.activeTimeframeRef.current.barNs;for(let Ve of e.indicatorsRef.current)Le[Ve.id]!==void 0&&Ve.hydrate?.(Le[Ve.id],Ge),Ue[Ve.id]&&console.error(`[indicator:${Ve.id}]`,Ue[Ve.id]);e.autofitIndicatorPanesRef.current(),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markDirty("base"),e.renderEngineRef.current?.markDirty("ui");return}if(ge.type==="horizon:advance"){let{points:pe,errors:Le}=ge,Ue=e.activeTimeframeRef.current.barNs;for(let Ge of e.indicatorsRef.current)pe[Ge.id]!==void 0&&Ge.appendHydrate?.(pe[Ge.id],Ue),Le[Ge.id]&&console.error(`[indicator:${Ge.id}]`,Le[Ge.id]);e.renderEngineRef.current?.markDirty("base")}},Oe=()=>{V.current?.postMessage({requestId:vn(),event:"load",barNs:e.activeTimeframeRef.current.barNs,horizon:e.horizonRef.current,fpOptions:We()})},Tt=(0,mt.useCallback)(ie=>{if(ie.error){e.eventBus.emit("data:status",{status:"error",error:{code:ie.error,message:ie.errorMessage??"Failed to load data"},symbol:ie.symbol??t.current});return}let ge=g.current!==ie.dataLevel;if(g.current=ie.dataLevel,ge&&e.onDataLevelChangeRef.current(),C.current=ie.supplemental??null,ie.dataLevel==="ohlcv"){let pe=ie.ohlcvBars??[];ie.session!==void 0&&(e.resolvedSessionRef.current=ie.session),n.current=ja(0),r.current=[],o.current=[],i.current=[],a.current=[],s.current=[],S.current=null;let Le=e.activeTimeframeRef.current.barNs,Ue=pe.map(te=>({open:te.open,high:te.high,low:te.low,close:te.close,volume:te.volume,time:te.time}));l.current={barNs:Le,bars:Ue,display:[]};let Ge=BigInt(ie.dataStart)*1000000n,Ve=BigInt(ie.dataEnd)*1000000n;y.current=Ge,v.current=Ve,e.onDataBoundsChange?.(Ge,Ve);let Ne=ie.playFromIso?Ta(ie.playFromIso):Ve;e.horizonRef.current=Ne,N.current=Ne,h.current=0,p.current=0,u.current=null,d.current=0n;let Se=14n*24n*60n*60n*1000000000n;e.sessionMapperRef.current.build(e.resolvedSessionRef.current,Ge-Se,Ve+Se),l.current.display=oc(Ue,Le,e.sessionMapperRef.current),ke(e.horizonRef.current),e.eventBus.emit("data:bounds",{start:Ge,end:Ve,session:e.resolvedSessionRef.current,symbol:t.current});{let te=Ja(e.resolvedSessionRef.current,Ne),Me=b.current;(!Me||Me.kind!==te.kind||te.kind==="sub"&&Me.kind==="sub"&&Me.label!==te.label)&&(b.current=te,e.eventBus.emit("session:status",{...te,symbol:t.current}))}let He=800000000000n,_e=100000000000n;e.viewRef.current={...e.viewRef.current??{tMin:0n,tMax:0n,pMin:0,pMax:0,pRef:0},tMin:Ve-He+_e,tMax:Ve+_e},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__",_t=e.indicatorsRef.current.filter(te=>te.workerInit===dt);e.indicatorsRef.current=_t,e.setIndicators(_t),e.eventBus.emit("data:status",{status:"ready",symbol:ie.symbol??t.current}),e.pushDrawParamsRef.current(),_t.length>0&&Qe(me(e.horizonRef.current),e.activeTimeframeRef.current.barNs),e.renderEngineRef.current?.markDirty("base");return}try{let{compactBuf:pe,trades:Le,priceHistory:Ue,footprintBars:Ge,barNs:Ve,dataStart:Ne,dataEnd:Se,session:He}=ie;He!==void 0&&(e.resolvedSessionRef.current=He),n.current=ja(0),n.current._buf=pe,n.current._view=new DataView(pe),n.current.length=pe.byteLength/20,n.current.capacity=n.current.length,n.current.firstTs=BigInt(Ne)*1000000n,n.current.lastTs=BigInt(Se)*1000000n,r.current=Le,i.current=Ue,o.current=Le,u.current=null,f.current=Ue.length-1,S.current=null;let _e=e.activeTimeframeRef.current.barNs;Ve===_e?s.current=Ge:ee();let dt=BigInt(Ne)*1000000n,_t=BigInt(Se)*1000000n;y.current=dt,v.current=_t,e.onDataBoundsChange?.(dt,_t);let te=ie.playFromIso?Ta(ie.playFromIso):_t,Me=am(n.current,te);h.current=Me,p.current=Me,u.current=null,d.current=0n,m.current=0,e.horizonRef.current=te;let Pe=gl(),at=n.current;for(let _n=0;_n<=Me;_n++)bl(Pe,ss(at,_n));D.current=Pe,J()?.update(Pe);let nt="__scripted__",pt=e.indicatorsRef.current.filter(_n=>_n.workerInit===nt);e.indicatorsRef.current=pt,e.setIndicators(pt);let{ingestOhlcvBuf:Xt,ingestBucketedPhBuf:Ft,ingestTradesBuf:cr,ingestPhBuf:Mn}=ie;w.current=cr??null,k.current=Mn??null,M.current=Xt??null,S.current=null,a.current=[];let ir=14n*24n*60n*60n*1000000000n;e.sessionMapperRef.current.build(e.resolvedSessionRef.current,dt-ir,_t+ir),e.eventBus.emit("data:bounds",{start:dt,end:_t,session:e.resolvedSessionRef.current,symbol:t.current});{let _n=Ja(e.resolvedSessionRef.current,te),qn=b.current;(!qn||qn.kind!==_n.kind||_n.kind==="sub"&&qn.kind==="sub"&&qn.label!==_n.label)&&(b.current=_n,e.eventBus.emit("session:status",{..._n,symbol:t.current}))}let Vn=800000000000n,fr=100000000000n;e.viewRef.current={...e.viewRef.current??{tMin:0n,tMax:0n,pMin:0,pMax:0,pRef:0},tMin:te-Vn+fr,tMax:te+fr},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:ie.symbol??t.current}),pt.length>0&&Qe(me(te),_e),Ft&&(a.current=$m(Ft),Vr(e.viewRef.current,a.current,o.current,g.current==="ohlcv"?l.current.display:c.current,u.current,e.chartSettingsRef.current,te,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")),Xt&&(S.current=Xm(Xt,e.horizonRef.current)),H.current&&(Ug(n.current,0,n.current.length,"init").catch(()=>{}),G.current=!0,$e())}catch(pe){console.error("[chart] ingestLoadedData failed",pe)}},[]),bn=(0,mt.useCallback)(ie=>{if(ie.dataLevel==="ohlcv"){let ge=(ie.ohlcvBars??[]).map(Ne=>({open:Ne.open,high:Ne.high,low:Ne.low,close:Ne.close,volume:Ne.volume,time:Ne.time})),pe=e.activeTimeframeRef.current.barNs,Le=BigInt(ie.dataEnd)*1000000n,Ue=v.current;if(v.current=Le,ge.length>0){let Ne=l.current.bars,Se=ge[0].time;for(;Ne.length&&Ne[Ne.length-1].time>=Se;)Ne.pop();for(let _e of ge)Ne.push(_e);l.current.barNs=pe;let He=l.current.display;if(He.length===0)l.current.display=oc(Ne,pe,e.sessionMapperRef.current);else{let _e=He[He.length-1].time,dt=Ne.length;for(;dt>0&&Ne[dt-1].time>=_e;)dt--;let _t=oc(Ne.slice(dt),pe,e.sessionMapperRef.current);He.pop();for(let te of _t)He.push(te)}}let Ve=!$.current&&e.horizonRef.current>=Ue?Le:e.horizonRef.current;e.horizonRef.current=Ve,N.current=Ve,ke(Ve);{let Ne=Ja(e.resolvedSessionRef.current,Ve),Se=b.current;(!Se||Se.kind!==Ne.kind||Ne.kind==="sub"&&Se.kind==="sub"&&Se.label!==Ne.label)&&(b.current=Ne,e.eventBus.emit("session:status",{...Ne,symbol:t.current}))}e.onDataBoundsChange?.(y.current,Le),e.eventBus.emit("data:bounds",{start:y.current,end:Le,session:e.resolvedSessionRef.current,symbol:t.current}),e.pushDrawParamsRef.current(),Qe(me(Ve),pe),e.renderEngineRef.current?.markAllDirty();return}try{let{compactBuf:ge,trades:pe,priceHistory:Le,footprintBars:Ue,barNs:Ge,dataEnd:Ve}=ie,Ne=ge.slice(0),Se=ja(0);Se._buf=Ne,Se._view=new DataView(Ne),Se.length=Ne.byteLength/20,Se.capacity=Se.length,Se.firstTs=y.current,Se.lastTs=BigInt(Ve)*1000000n,n.current=Se,r.current=pe,i.current=Le,o.current=pe;let He=e.activeTimeframeRef.current.barNs;Ge===He?s.current=Ue:ee();let _e=BigInt(Ve)*1000000n,dt=v.current;v.current=_e;let te=!$.current&&e.horizonRef.current>=dt?_e:e.horizonRef.current,Me=am(n.current,te);h.current=Me,p.current=Me,e.horizonRef.current=te;let{ingestOhlcvBuf:Pe,ingestBucketedPhBuf:at,ingestTradesBuf:nt,ingestPhBuf:pt}=ie;w.current=nt??null,k.current=pt??null,M.current=Pe??null,at&&(a.current=$m(at)),Pe&&(S.current=Xm(Pe,e.horizonRef.current)),e.isYAxisAutoRef.current&&Vr(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,_e),e.eventBus.emit("data:bounds",{start:y.current,end:_e,session:e.resolvedSessionRef.current,symbol:t.current}),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markAllDirty(),Qe(me(e.horizonRef.current),He),H.current&&Ug(n.current,0,n.current.length,"append").catch(()=>{}),$e()}catch(ge){console.error("[chart] ingestAppendedData failed",ge)}},[]),En=(0,mt.useCallback)(ie=>{if(ie.dataLevel==="ohlcv"){let ge=(ie.ohlcvBars??[]).map(Ne=>({open:Ne.open,high:Ne.high,low:Ne.low,close:Ne.close,volume:Ne.volume,time:Ne.time})),pe=e.activeTimeframeRef.current.barNs,Le=BigInt(ie.dataStart)*1000000n,Ue=14n*24n*60n*60n*1000000000n,Ge=Le-Ue;e.sessionMapperRef.current.extendBackward(e.resolvedSessionRef.current,Ge);let Ve=_H(ge,l.current.display,pe,e.sessionMapperRef.current);l.current.bars=[...ge,...l.current.bars],l.current.barNs=pe,l.current.display=Ve,y.current=Le,e.eventBus.emit("data:bounds",{start:Le,end:v.current,session:e.resolvedSessionRef.current,symbol:t.current}),e.onDataBoundsChange?.(Le,v.current),e.isYAxisAutoRef.current&&Vr(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(),Qe(me(e.horizonRef.current),e.activeTimeframeRef.current.barNs),e.renderEngineRef.current?.markAllDirty();return}try{let{compactBuf:ge,trades:pe,priceHistory:Le,footprintBars:Ue,dataStart:Ge}=ie,Ve=BigInt(Ge)*1000000n,Ne=ge.slice(0),Se=ja(0);Se._buf=Ne,Se._view=new DataView(Ne),Se.length=Ne.byteLength/20,Se.capacity=Se.length,Se.firstTs=Ve,Se.lastTs=v.current,n.current=Se,r.current=pe,i.current=Le,o.current=pe,Ue.length>0&&(ie.barNs===e.activeTimeframeRef.current.barNs?s.current=Ue:ee()),h.current=am(n.current,e.horizonRef.current),p.current=h.current,y.current=Ve;{let te=14n*24n*60n*60n*1000000000n;e.sessionMapperRef.current.build(e.resolvedSessionRef.current,Ve-te,v.current+te)}e.eventBus.emit("data:bounds",{start:Ve,end:v.current,session:e.resolvedSessionRef.current,symbol:t.current}),e.onDataBoundsChange?.(Ve,v.current);let{ingestOhlcvBuf:He,ingestBucketedPhBuf:_e,ingestTradesBuf:dt,ingestPhBuf:_t}=ie;w.current=dt??null,k.current=_t??null,M.current=He??null,_e&&(a.current=$m(_e)),He&&(S.current=Xm(He,e.horizonRef.current)),e.isYAxisAutoRef.current&&Vr(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(),Qe(me(e.horizonRef.current),e.activeTimeframeRef.current.barNs)}catch(ge){console.error("[chart] ingestPrependedData failed",ge)}},[]),Lt=(0,mt.useCallback)((ie,ge=!0,pe=!1)=>{let Le=n.current,Ue=am(Le,ie),Ge=h.current,Ve=e.activeTimeframeRef.current.barNs,Ne=Ue>=Ge,Se=wd(ie,Ve,e.sessionMapperRef.current).start;if(Se!==N.current){let _e=N.current,dt=Se>_e;N.current=Se;let _t=e.viewRef.current.tMax>Se&&e.viewRef.current.tMin<Se;if(e.viewRef.current&&!(e.isDragging.current&&e.dragMode.current==="pan")&&dt&&_t){let te=e.chartSettingsRef.current.horizonScrollEasing,Me=e.chartSettingsRef.current.horizonScrollDuration,Pe=performance.now(),at=Pe-O.current;O.current=Pe;let nt=e.sessionMapperRef.current,pt=nt.hasSession,Xt=A.current,Ft=at<Me,cr=Ft?"linear":te,Mn=Ft?Math.max(1,at):Me;if(pt){let ir=nt.tsToMarket(Se)-nt.tsToMarket(_e),Vn=Xt?.targetMMin??nt.tsToMarket(e.viewRef.current.tMin),fr=Xt?.targetMMax??nt.tsToMarket(e.viewRef.current.tMax),_n=Vn+ir,qn=fr+ir;te==="none"?(e.viewRef.current.tMin=nt.marketToTs(_n),e.viewRef.current.tMax=nt.marketToTs(qn),A.current=null):A.current={startTMin:e.viewRef.current.tMin,startTMax:e.viewRef.current.tMax,targetTMin:nt.marketToTs(_n),targetTMax:nt.marketToTs(qn),startMMin:nt.tsToMarket(e.viewRef.current.tMin),startMMax:nt.tsToMarket(e.viewRef.current.tMax),targetMMin:_n,targetMMax:qn,startTime:Pe,easing:cr,duration:Mn}}else{let ir=Se-_e,Vn=Xt?.targetTMin??e.viewRef.current.tMin,fr=Xt?.targetTMax??e.viewRef.current.tMax,_n=Vn+ir,qn=fr+ir;te==="none"?(e.viewRef.current.tMin=_n,e.viewRef.current.tMax=qn,A.current=null):A.current={startTMin:e.viewRef.current.tMin,startTMax:e.viewRef.current.tMax,targetTMin:_n,targetTMax:qn,startTime:Pe,easing:cr,duration:Mn}}}}e.onHorizonUpdate(ie),e.eventBus.emit("status:refresh",void 0);{let _e=Ja(e.resolvedSessionRef.current,ie),dt=b.current;(!dt||dt.kind!==_e.kind||_e.kind==="sub"&&dt.kind==="sub"&&dt.label!==_e.label)&&(b.current=_e,e.eventBus.emit("session:status",{..._e,symbol:t.current}))}if(!Ne){if(ce(Ue),Ve>0n&&Ue>=0){let _t=ie/Ve*Ve;d.current=_t;let te=0;for(let Me=Ue;Me>=0;Me--)if(ls(Le,Me)/Ve*Ve<_t){te=Me+1;break}for(let Me=te;Me<=Ue;Me++){let Pe=ss(Le,Me);if(Pe.action!=="T"||Pe.price===null||Pe.side==="N")continue;u.current||(u.current={ts:_t,open:Pe.price,high:Pe.price,low:Pe.price,close:Pe.price,totalVol:0,totalDelta:0,maxLevelVol:0,maxAbsDelta:0,levels:[],isBullish:!0,poc:Pe.price,stackedBuyZones:[],stackedSellZones:[],unfinishedTop:!1,unfinishedBottom:!1,absorptionCount:0,diagDominant:"none"});let at=u.current;Pe.price>at.high&&(at.high=Pe.price),Pe.price<at.low&&(at.low=Pe.price),at.close=Pe.price,at.totalVol+=Pe.size,Pe.side==="B"?at.totalDelta+=Pe.size:at.totalDelta-=Pe.size,m.current++}u.current&&Be(Ue,Ve)}ee(),ze(Ie(ie));let _e=Ue;if(J()){let te=0,Me=gl(),Pe=()=>{if(h.current!==_e)return;let at=Math.min(te+5e4,_e+1);for(;te<at;te++)bl(Me,ss(Le,te));te<=_e?setTimeout(Pe,0):(D.current=Me,p.current=_e,J()?.update(Me))};Pe()}let dt=me(ie);Ce(dt,Ve),B.current=ie,Qe(dt,Ve),e.autofitIndicatorPanesRef.current(),le(),e.viewRef.current&&e.isYAxisAutoRef.current&&Vr(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),ke(ie),ge&&$e(),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=Ue,Ve>0n&&(F(Ge,Ue,Ve,ie)&&ee(),le()),ze(Ie(ie)),J()&&Ue>p.current){let _e=D.current;for(let dt=p.current+1;dt<=Ue;dt++)bl(_e,ss(Le,dt));p.current=Ue,J()?.update(_e)}if(e.viewRef.current&&e.isYAxisAutoRef.current&&Vr(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),pe){if(Ve>0n&&S.current&&Ue>Ge){let _e=r.current,dt=Ge>=0?ls(Le,Ge):0n,_t=0,te=0,Me=_e.length-1;for(;te<=Me;){let pt=te+Me>>>1;_e[pt].ts<=dt?(_t=pt+1,te=pt+1):Me=pt-1}let Pe=_t,at=_t,nt=_e.length-1;for(;at<=nt;){let pt=at+nt>>>1;_e[pt].ts<=ie?(Pe=pt,at=pt+1):nt=pt-1}if(Pe>=_t){let pt=S.current;for(let Xt=_t;Xt<=Pe;Xt++){let Ft=_e[Xt],cr=Ft.ts/Ve*Ve,Mn=pt.get(cr);Mn?(Ft.price>Mn.high&&(Mn.high=Ft.price),Ft.price<Mn.low&&(Mn.low=Ft.price),Mn.close=Ft.price,Mn.volume+=Ft.size,Mn.delta+=Ft.side==="B"?Ft.size:-Ft.size):pt.set(cr,{open:Ft.price,high:Ft.price,low:Ft.price,close:Ft.price,volume:Ft.size,delta:Ft.side==="B"?Ft.size:-Ft.size})}}}if(Ye(ie),A.current&&e.viewRef.current){let _e=A.current,dt=_e.duration??e.chartSettingsRef.current.horizonScrollDuration,_t=Math.min((performance.now()-_e.startTime)/dt,1),te=uv(_t,_e.easing??e.chartSettingsRef.current.horizonScrollEasing),Me=(Pe,at,nt)=>Pe+BigInt(Math.round(Number(at-Pe)*nt));if(_e.startMMin!==void 0&&_e.targetMMin!==void 0){let Pe=e.sessionMapperRef.current;e.viewRef.current.tMin=Pe.marketToTs(Me(_e.startMMin,_e.targetMMin,te)),e.viewRef.current.tMax=Pe.marketToTs(Me(_e.startMMax,_e.targetMMax,te))}else e.viewRef.current.tMin=Me(_e.startTMin,_e.targetTMin,te),e.viewRef.current.tMax=Me(_e.startTMax,_e.targetTMax,te);_t>=1&&(A.current=null)}ke(ie),e.pushDrawParamsRef.current(),o.current.length>0?e.doBaseRedrawRef.current():e.renderEngineRef.current?.markDirty("base"),e.renderEngineRef.current?.markDirty("drawings");return}let He=me(ie);Ce(He,Ve),B.current=ie,Qe(He,Ve),e.autofitIndicatorPanesRef.current(),ke(ie),ge&&$e(),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=(0,mt.useCallback)(ie=>{let ge=e.viewRef.current;if(!ge)return;let pe=e.activeTimeframeRef.current.barNs,Le=ie/pe*pe;if(Le>ge.tMin&&Le<ge.tMax)return;A.current=null;let Ue=e.sessionMapperRef.current,Ge=N.current;if(Ue.hasSession){let Ve=Ue.tsToMarket(ge.tMin),Ne=Ue.tsToMarket(ge.tMax),Se=Ue.tsToMarket(Ge),He=Ne-Ve,_e=Se>Ve&&Se<Ne?Ne-Se:He/8n,dt=Ue.tsToMarket(Le);ge.tMin=Ue.marketToTs(dt+_e-He),ge.tMax=Ue.marketToTs(dt+_e)}else{let Ve=ge.tMax-ge.tMin,Ne=Ge>ge.tMin&&Ge<ge.tMax?ge.tMax-Ge:Ve/8n;ge.tMin=Le+Ne-Ve,ge.tMax=Le+Ne}e.transformer.update(ge),e.renderEngineRef.current?.setView(ge),Vr(ge,a.current,o.current,g.current==="ohlcv"?l.current.display:c.current,u.current,e.chartSettingsRef.current,e.horizonRef.current,g.current),$e(),e.renderEngineRef.current.markAllDirty()},[]),ft=(0,mt.useCallback)((ie,ge=!0,pe=!1,Le=!1)=>{let Ue=v.current;if(Ue===0n)return;let Ge=ie<=Ue?ie:Ue;Le&&it(Ge),e.horizonRef.current=Ge,Lt(Ge,ge,pe)},[]);return(0,mt.useEffect)(()=>{if(!W.current)return W.current=!0,H.current=new Worker(PL()),H.current.onmessage=De,q.current=new Worker(DL()),q.current.onmessage=bt,()=>{H.current?.terminate(),V.current?.terminate(),q.current?.terminate(),H.current=null,q.current=null,W.current=!1}},[]),(0,mt.useEffect)(()=>{let ie=e.cellSymbol,ge=[e.eventBus.on("playback:play",()=>$.current=!0),e.eventBus.on("playback:pause",()=>$.current=!1),e.eventBus.on("data:load",pe=>{if(pe.symbol!==ie)return;c.current=[],l.current.bars=[],l.current.display=[],e.pushDrawParamsRef.current();let Le=pe.compactBuf.slice(0);Tt({...pe,compactBuf:Le})}),e.eventBus.on("data:append",pe=>{pe.symbol===ie&&(c.current=[],e.pushDrawParamsRef.current(),bn(pe))}),e.eventBus.on("data:prepend",pe=>{pe.symbol===ie&&(c.current=[],En(pe))}),e.eventBus.on("data:refine",pe=>{if(pe.symbol!==ie||pe.dataLevel!=="ohlcv")return;let Le=new Date(pe.from).getTime(),Ue=new Date(pe.to).getTime(),Ge=e.activeTimeframeRef.current.barNs,Ve=pe.ohlcvBars.map(He=>({open:He.open,high:He.high,low:He.low,close:He.close,volume:He.volume,time:He.time})),Se=[...l.current.bars.filter(He=>He.time<Le||He.time>Ue),...Ve].sort((He,_e)=>He.time-_e.time);l.current.bars=Se,l.current.barNs=Ge,l.current.display=oc(Se,Ge,e.sessionMapperRef.current),e.pushDrawParamsRef.current(),e.renderEngineRef.current?.markDirty("base")}),e.eventBus.on("data:preview",pe=>{pe.symbol===ie&&(c.current=pe.bars,e.isYAxisAutoRef.current&&Vr(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"),Qe(me(e.horizonRef.current),e.activeTimeframeRef.current.barNs))}),e.eventBus.on("data:symbol-resolved",({symbolInfo:pe})=>{pe.symbol===ie&&(e.resolvedSymbolInfoRef.current=pe??null,e.resolvedSessionRef.current=pe.session??null,e.setPanes(Le=>Le.map(Ue=>Ue.isMain?{...Ue,exchange:pe.exchange}:Ue)))})];return e.eventBus.emit("data:request-symbol-resolved",{symbol:ie}),()=>ge.forEach(pe=>pe())},[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:H,dataWorkerRef:V,indicatorWorkerRef:q,workerReadyRef:G,workerRequestIdRef:K,_internalDomPanelRef:L,seekHorizon:ft,applyHorizon:Lt,scheduleResample:$e,runIndicatorWorker:Qe,getTradesUpToHorizon:me,requestFootprintRebuild:ee,syncOhlcvOpenBar:ke,rebuildCandleCache:Ce,rebuildContrastBitmap:Ee,foldEventsIntoOpenBar:F,mergeOpenBar:le,resetPlayhead:ce,fpSettingsFromRef:We,cancelAndRestartWorker:ve,runHorizonAdvance:Ye,updatePriceHistoryToRawIdx:ze,findPriceHistoryIdx:Ie,loadData:Oe}}var zL=require("react");var dv=!1,im={get locked(){return dv},lock(){dv=!0},unlock(){dv=!1}};var cs=require("react");var Z=require("react/jsx-runtime"),NL=15;function tt({children:e}){return(0,Z.jsx)("svg",{width:NL,height:NL,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e})}function un({x:e,y:t,r:n=2}){return(0,Z.jsx)("circle",{cx:e,cy:t,r:n,fill:"currentColor",stroke:"none"})}var qe=(e,t,n,r,o)=>(0,Z.jsx)("line",{x1:e,y1:t,x2:n,y2:r},o),Ga={cursor:(0,Z.jsx)(tt,{children:(0,Z.jsx)("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:(0,Z.jsxs)(tt,{children:[qe(4,19,20,6),(0,Z.jsx)(un,{x:4,y:19}),(0,Z.jsx)(un,{x:20,y:6})]}),cat_fib:(0,Z.jsxs)(tt,{children:[qe(4,5,20,5),qe(4,10,20,10),qe(4,14,20,14),qe(4,19,20,19)]}),cat_patterns:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M4 18 L9 8 L13 15 L20 5"}),(0,Z.jsx)(un,{x:9,y:8,r:1.6}),(0,Z.jsx)(un,{x:13,y:15,r:1.6})]}),cat_shapes:(0,Z.jsx)(tt,{children:(0,Z.jsx)("rect",{x:4,y:4,width:16,height:16,rx:2})}),cat_annotations:(0,Z.jsxs)(tt,{children:[qe(5,6,19,6),qe(12,6,12,19)]}),cat_arrows:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M6 18 L18 6"}),(0,Z.jsx)("path",{d:"M11 6 L18 6 L18 13"})]}),cat_forecast:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("circle",{cx:12,cy:12,r:8}),qe(12,12,16,9),(0,Z.jsx)(un,{x:12,y:12,r:1.6})]}),cat_measure:(0,Z.jsxs)(tt,{children:[qe(5,20,5,8),qe(11,20,11,4),qe(17,20,17,12)]}),line:(0,Z.jsxs)(tt,{children:[qe(4,19,20,6),(0,Z.jsx)(un,{x:4,y:19}),(0,Z.jsx)(un,{x:20,y:6})]}),ray:(0,Z.jsxs)(tt,{children:[qe(5,19,21,5),(0,Z.jsx)(un,{x:5,y:19})]}),hline:(0,Z.jsxs)(tt,{children:[qe(3,12,21,12),(0,Z.jsx)(un,{x:9,y:12})]}),vline:(0,Z.jsxs)(tt,{children:[qe(12,3,12,21),(0,Z.jsx)(un,{x:12,y:9})]}),"extended-line":(0,Z.jsxs)(tt,{children:[qe(3,21,21,3),(0,Z.jsx)(un,{x:9,y:15}),(0,Z.jsx)(un,{x:15,y:9})]}),hray:(0,Z.jsxs)(tt,{children:[qe(5,12,21,12),(0,Z.jsx)(un,{x:5,y:12})]}),"cross-line":(0,Z.jsxs)(tt,{children:[qe(3,12,21,12),qe(12,3,12,21),(0,Z.jsx)(un,{x:12,y:12,r:1.6})]}),"info-line":(0,Z.jsxs)(tt,{children:[qe(4,19,20,6),(0,Z.jsx)(un,{x:4,y:19}),(0,Z.jsx)(un,{x:20,y:6}),(0,Z.jsx)("rect",{x:9,y:10,width:6,height:4,rx:2})]}),"trend-angle":(0,Z.jsxs)(tt,{children:[qe(4,19,20,7),(0,Z.jsx)("path",{d:"M4 19 H14"}),(0,Z.jsx)("path",{d:"M11 19 A7 7 0 0 0 9.5 15.5"}),(0,Z.jsx)(un,{x:4,y:19})]}),"parallel-channel":(0,Z.jsxs)(tt,{children:[qe(4,16,20,5),qe(4,19,20,8),(0,Z.jsx)(un,{x:4,y:16}),(0,Z.jsx)(un,{x:20,y:5})]}),"flat-channel":(0,Z.jsxs)(tt,{children:[qe(4,8,20,8),qe(4,16,20,16),(0,Z.jsx)(un,{x:4,y:8}),(0,Z.jsx)(un,{x:20,y:16})]}),"disjoint-channel":(0,Z.jsxs)(tt,{children:[qe(4,14,20,5),qe(4,20,16,12),(0,Z.jsx)(un,{x:4,y:14}),(0,Z.jsx)(un,{x:20,y:5})]}),"regression-trend":(0,Z.jsxs)(tt,{children:[qe(4,9,20,5),qe(4,19,20,15),qe(4,14,20,10)]}),pitchfork:(0,Z.jsxs)(tt,{children:[qe(4,12,12,12),qe(12,5,12,19),qe(12,5,20,5),qe(12,19,20,19),(0,Z.jsx)(un,{x:4,y:12,r:1.6})]}),"schiff-pitchfork":(0,Z.jsxs)(tt,{children:[qe(4,14,12,10),qe(12,4,12,18),qe(12,4,20,4),qe(12,18,20,18),(0,Z.jsx)(un,{x:4,y:14,r:1.6})]}),"modified-schiff-pitchfork":(0,Z.jsxs)(tt,{children:[qe(5,15,12,11),qe(12,5,12,19),qe(12,5,20,6),qe(12,19,20,18),(0,Z.jsx)(un,{x:5,y:15,r:1.6})]}),"inside-pitchfork":(0,Z.jsxs)(tt,{children:[qe(6,12,12,12),qe(12,7,12,17),qe(12,7,19,7),qe(12,17,19,17),(0,Z.jsx)(un,{x:6,y:12,r:1.6})]}),fib:(0,Z.jsxs)(tt,{children:[qe(4,6,20,6),qe(4,11,20,11),qe(4,15,20,15),qe(4,19,20,19),(0,Z.jsx)(un,{x:4,y:6,r:1.6}),(0,Z.jsx)(un,{x:20,y:19,r:1.6})]}),"fib-extension":(0,Z.jsxs)(tt,{children:[qe(4,7,20,7),qe(4,11,20,11),qe(4,15,14,15),qe(4,19,14,19),(0,Z.jsx)("path",{d:"M5 18 L9 11 L13 16"})]}),"fib-trend-extension":(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M4 19 L9 9 L14 14"}),qe(14,5,21,5),qe(14,10,21,10),qe(14,15,21,15)]}),"fib-channel":(0,Z.jsxs)(tt,{children:[qe(4,18,20,7),qe(4,14,20,3),qe(4,21,20,10)]}),"fib-time-zone":(0,Z.jsxs)(tt,{children:[qe(5,4,5,20),qe(9,4,9,20),qe(15,4,15,20),(0,Z.jsx)("path",{d:"M21 4 L21 20",strokeDasharray:"0.1 4"})]}),"fib-speed-fan":(0,Z.jsxs)(tt,{children:[qe(4,20,20,20),qe(4,20,20,12),qe(4,20,20,5),(0,Z.jsx)(un,{x:4,y:20,r:1.6})]}),"fib-circles":(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("circle",{cx:6,cy:18,r:4}),(0,Z.jsx)("circle",{cx:6,cy:18,r:8}),(0,Z.jsx)("circle",{cx:6,cy:18,r:12}),(0,Z.jsx)(un,{x:6,y:18,r:1.4})]}),"fib-spiral":(0,Z.jsx)(tt,{children:(0,Z.jsx)("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":(0,Z.jsxs)(tt,{children:[qe(4,20,20,4),qe(4,20,20,12),(0,Z.jsx)("path",{d:"M20 4 A16 16 0 0 1 20 12"}),(0,Z.jsx)(un,{x:4,y:20,r:1.6})]}),"gann-box":(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("rect",{x:4,y:4,width:16,height:16,rx:2}),qe(4,20,20,4),qe(4,4,20,20)]}),"gann-square":(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("rect",{x:4,y:4,width:16,height:16,rx:2}),qe(12,4,12,20),qe(4,12,20,12)]}),"gann-fan":(0,Z.jsxs)(tt,{children:[qe(4,20,20,20),qe(4,20,20,13),qe(4,20,20,4),qe(4,20,13,4),(0,Z.jsx)(un,{x:4,y:20,r:1.6})]}),xabcd:(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 16 L8 6 L13 18 L17 7 L20 15"})}),cypher:(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 14 L8 6 L12 17 L16 9 L20 13"})}),abcd:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M5 18 L10 7 L14 14 L19 5"}),(0,Z.jsx)(un,{x:10,y:7,r:1.6}),(0,Z.jsx)(un,{x:14,y:14,r:1.6})]}),"head-shoulders":(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M3 17 L7 12 L9 15 L12 6 L15 15 L17 12 L21 17"})}),"triangle-pattern":(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M4 6 L20 12 L4 18"}),(0,Z.jsx)(un,{x:20,y:12,r:1.6})]}),"three-drives":(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 18 L7 12 L9 16 L13 8 L15 12 L20 4"})}),"elliott-impulse":(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 18 L8 10 L10 14 L15 5 L17 9 L20 6"})}),"elliott-correction":(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M5 8 L10 16 L15 9 L19 15"})}),"elliott-triangle":(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 6 L8 16 L12 8 L16 14 L20 10"})}),"elliott-double-combo":(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 8 L8 15 L12 9 L16 15 L20 9"})}),"elliott-triple-combo":(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M3 9 L6 15 L9 10 L12 15 L15 10 L18 15 L21 10"})}),rect:(0,Z.jsx)(tt,{children:(0,Z.jsx)("rect",{x:4,y:6,width:16,height:12,rx:2})}),"rotated-rect":(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M3 14 L10 5 L21 10 L14 19 Z"})}),ellipse:(0,Z.jsx)(tt,{children:(0,Z.jsx)("ellipse",{cx:12,cy:12,rx:9,ry:6})}),circle:(0,Z.jsx)(tt,{children:(0,Z.jsx)("circle",{cx:12,cy:12,r:8})}),triangle:(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M12 4 L20 19 L4 19 Z"})}),polygon:(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M12 3 L20 9 L17 19 L7 19 L4 9 Z"})}),arc:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M4 19 A12 12 0 0 1 20 19"}),(0,Z.jsx)(un,{x:4,y:19,r:1.6}),(0,Z.jsx)(un,{x:20,y:19,r:1.6})]}),curve:(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 18 C9 4 15 4 20 18"})}),"double-curve":(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M3 14 C6 6 9 6 12 14 C15 22 18 22 21 14"})}),polyline:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M4 18 L9 8 L14 14 L20 5"}),(0,Z.jsx)(un,{x:4,y:18,r:1.6}),(0,Z.jsx)(un,{x:9,y:8,r:1.6}),(0,Z.jsx)(un,{x:14,y:14,r:1.6}),(0,Z.jsx)(un,{x:20,y:5,r:1.6})]}),path:(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 16 C8 16 7 7 12 7 C17 7 16 17 20 17"})}),text:(0,Z.jsxs)(tt,{children:[qe(5,6,19,6),qe(12,6,12,19)]}),"anchored-text":(0,Z.jsxs)(tt,{children:[qe(7,7,19,7),qe(13,7,13,18),(0,Z.jsx)(un,{x:4,y:20}),qe(4,20,7,14)]}),note:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M5 4 H19 V15 L14 20 H5 Z"}),(0,Z.jsx)("path",{d:"M19 15 H14 V20"})]}),callout:(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 5 H20 V15 H10 L6 19 V15 H4 Z"})}),comment:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M4 5 H20 V16 H13 L9 20 V16 H4 Z"}),qe(8,10,16,10)]}),"price-label":(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 12 L8 7 H20 V17 H8 Z"})}),signpost:(0,Z.jsxs)(tt,{children:[qe(8,4,8,20),(0,Z.jsx)("path",{d:"M8 6 H18 L20 9 L18 12 H8 Z"})]}),flag:(0,Z.jsxs)(tt,{children:[qe(6,3,6,21),(0,Z.jsx)("path",{d:"M6 4 H18 L15 8 L18 12 H6 Z"})]}),pin:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M12 21 C12 21 19 14 19 9 A7 7 0 0 0 5 9 C5 14 12 21 12 21 Z"}),(0,Z.jsx)("circle",{cx:12,cy:9,r:2.2})]}),table:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("rect",{x:4,y:5,width:16,height:14,rx:2}),qe(4,10,20,10),qe(12,5,12,19)]}),arrow:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M5 19 L19 5"}),(0,Z.jsx)("path",{d:"M11 5 H19 V13"})]}),"arrow-marker":(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M4 20 L20 4"}),(0,Z.jsx)("path",{d:"M20 4 L13 6 L18 11 Z"})]}),"arrow-up":(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M12 20 V5"}),(0,Z.jsx)("path",{d:"M6 11 L12 5 L18 11"})]}),"arrow-down":(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M12 4 V19"}),(0,Z.jsx)("path",{d:"M6 13 L12 19 L18 13"})]}),brush:(0,Z.jsx)(tt,{children:(0,Z.jsx)("path",{d:"M4 20 C8 20 8 12 12 10 C16 8 14 4 18 4"})}),highlighter:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M4 19 L13 10 L17 14 L8 19 Z"}),(0,Z.jsx)("path",{d:"M13 10 L16 7 L20 11 L17 14"})]}),long:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("rect",{x:4,y:12,width:16,height:6,rx:2}),(0,Z.jsx)("path",{d:"M12 12 V4"}),(0,Z.jsx)("path",{d:"M8 8 L12 4 L16 8"})]}),short:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("rect",{x:4,y:6,width:16,height:6,rx:2}),(0,Z.jsx)("path",{d:"M12 12 V20"}),(0,Z.jsx)("path",{d:"M8 16 L12 20 L16 16"})]}),forecast:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M4 16 L9 10 L12 13"}),(0,Z.jsx)("path",{d:"M12 13 L20 5",strokeDasharray:"3 2"}),(0,Z.jsx)(un,{x:4,y:16,r:1.6})]}),projection:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("rect",{x:4,y:5,width:7,height:14,rx:2}),(0,Z.jsx)("rect",{x:14,y:9,width:6,height:7,rx:2,strokeDasharray:"3 2"})]}),"price-range":(0,Z.jsxs)(tt,{children:[qe(12,4,12,20),(0,Z.jsx)("path",{d:"M8 8 L12 4 L16 8"}),(0,Z.jsx)("path",{d:"M8 16 L12 20 L16 16"})]}),"date-range":(0,Z.jsxs)(tt,{children:[qe(4,12,20,12),(0,Z.jsx)("path",{d:"M8 8 L4 12 L8 16"}),(0,Z.jsx)("path",{d:"M16 8 L20 12 L16 16"})]}),"date-price-range":(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("rect",{x:5,y:6,width:14,height:12,rx:2,strokeDasharray:"3 2"}),qe(5,18,19,6)]}),"bars-pattern":(0,Z.jsxs)(tt,{children:[qe(7,6,7,18),qe(5,9,7,9),qe(7,14,9,14),qe(14,5,14,19),qe(12,8,14,8),qe(14,12,16,12)]}),"ghost-feed":(0,Z.jsxs)(tt,{children:[qe(6,6,6,16),qe(11,9,11,19),(0,Z.jsx)("path",{d:"M16 6 V16",strokeDasharray:"3 2"}),(0,Z.jsx)("path",{d:"M20 9 V19",strokeDasharray:"3 2"})]}),fvp:(0,Z.jsxs)(tt,{children:[qe(4,6,13,6),qe(4,10,19,10),qe(4,14,10,14),qe(4,18,16,18)]}),"anchored-volume-profile":(0,Z.jsxs)(tt,{children:[qe(5,4,5,20),qe(7,7,14,7),qe(7,11,20,11),qe(7,15,12,15),(0,Z.jsx)(un,{x:5,y:20,r:1.6})]}),"fixed-range-volume":(0,Z.jsxs)(tt,{children:[qe(5,4,5,20),qe(19,4,19,20),qe(7,9,13,9),qe(7,14,16,14)]}),"anchored-vwap":(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("path",{d:"M4 18 C9 18 9 8 14 8 C18 8 18 13 20 13"}),(0,Z.jsx)(un,{x:4,y:18})]}),ruler:(0,Z.jsxs)(tt,{children:[(0,Z.jsx)("rect",{x:3,y:8,width:18,height:8,rx:2,transform:"rotate(-20 12 12)"}),qe(8,7,9,9),qe(11,5.5,12,7.5),qe(14,4,15,6)]})};var Dt=(e,t,n)=>({tool:e,label:t,icon:Ga[e],shortcut:n?.shortcut,implemented:n?.implemented}),Ao=(e,t,n)=>Dt(e,t,{shortcut:n,implemented:!0}),co=(e,t)=>({label:e,items:t}),fv=[{id:"lines",label:"Lines",icon:Ga.cat_lines,groups:[co("Trend Lines",[Ao("line","Trend Line","L"),Ao("ray","Ray","R"),Ao("hline","Horizontal Line","H"),Ao("vline","Vertical Line","V"),Ao("extended-line","Extended Line"),Ao("hray","Horizontal Ray"),Ao("cross-line","Cross Line"),Ao("info-line","Info Line"),Ao("trend-angle","Trend Angle")]),co("Channels",[Ao("parallel-channel","Parallel Channel"),Dt("flat-channel","Flat Channel"),Dt("disjoint-channel","Disjoint Channel"),Dt("regression-trend","Regression Trend")]),co("Pitchforks",[Dt("pitchfork","Andrews Pitchfork"),Dt("schiff-pitchfork","Schiff Pitchfork"),Dt("modified-schiff-pitchfork","Modified Schiff Pitchfork"),Dt("inside-pitchfork","Inside Pitchfork")])]},{id:"fib",label:"Fibonacci & Gann",icon:Ga.cat_fib,groups:[co("Fibonacci",[Ao("fib","Fib Retracement","F"),Dt("fib-extension","Fib Extension"),Dt("fib-trend-extension","Trend-Based Fib Extension"),Dt("fib-channel","Fib Channel"),Dt("fib-time-zone","Fib Time Zone"),Dt("fib-speed-fan","Fib Speed/Resistance Fan"),Dt("fib-circles","Fib Circles"),Dt("fib-spiral","Fib Spiral"),Dt("fib-wedge","Fib Wedge")]),co("Gann",[Dt("gann-box","Gann Box"),Dt("gann-square","Gann Square"),Dt("gann-fan","Gann Fan")])]},{id:"patterns",label:"Patterns",icon:Ga.cat_patterns,groups:[co("Harmonic",[Dt("xabcd","XABCD Pattern"),Dt("cypher","Cypher Pattern"),Dt("abcd","ABCD Pattern"),Dt("three-drives","Three Drives Pattern")]),co("Chart Patterns",[Dt("head-shoulders","Head and Shoulders"),Dt("triangle-pattern","Triangle Pattern")]),co("Elliott Waves",[Dt("elliott-impulse","Impulse Wave (12345)"),Dt("elliott-correction","Correction Wave (ABC)"),Dt("elliott-triangle","Triangle Wave (ABCDE)"),Dt("elliott-double-combo","Double Combo (WXY)"),Dt("elliott-triple-combo","Triple Combo (WXYXZ)")])]},{id:"shapes",label:"Shapes",icon:Ga.cat_shapes,groups:[co("Geometric",[Ao("rect","Rectangle","R"),Dt("rotated-rect","Rotated Rectangle"),Dt("ellipse","Ellipse"),Dt("circle","Circle"),Ao("triangle","Triangle"),Dt("polygon","Polygon"),Dt("arc","Arc")]),co("Freehand",[Dt("curve","Curve"),Dt("double-curve","Double Curve"),Dt("polyline","Polyline"),Dt("path","Path")])]},{id:"annotations",label:"Annotations",icon:Ga.cat_annotations,groups:[co("Text",[Ao("text","Text","T"),Dt("anchored-text","Anchored Text"),Dt("note","Note"),Dt("callout","Callout"),Dt("comment","Comment")]),co("Labels",[Dt("price-label","Price Label"),Dt("signpost","Signpost"),Dt("flag","Flag Mark"),Dt("pin","Pin"),Dt("table","Table")])]},{id:"arrows",label:"Arrows & Brushes",icon:Ga.cat_arrows,groups:[co("Arrows",[Dt("arrow","Arrow"),Dt("arrow-marker","Arrow Marker"),Dt("arrow-up","Arrow Mark Up"),Dt("arrow-down","Arrow Mark Down")]),co("Brushes",[Dt("brush","Brush"),Dt("highlighter","Highlighter")])]},{id:"forecast",label:"Forecast & Positions",icon:Ga.cat_forecast,groups:[co("Positions",[Ao("long","Long Position","U"),Ao("short","Short Position","I")]),co("Forecasting",[Dt("forecast","Forecast"),Dt("projection","Projection"),Dt("bars-pattern","Bars Pattern"),Dt("ghost-feed","Ghost Feed")]),co("Ranges",[Dt("price-range","Price Range"),Dt("date-range","Date Range"),Dt("date-price-range","Date and Price Range")])]},{id:"measure",label:"Volume & Measure",icon:Ga.cat_measure,groups:[co("Volume Profile",[Ao("fvp","Fixed Volume Profile","P"),Dt("anchored-volume-profile","Anchored Volume Profile"),Dt("fixed-range-volume","Fixed Range Volume Profile")]),co("Tools",[Dt("anchored-vwap","Anchored VWAP"),Dt("ruler","Measure")])]}],EL=fv.flatMap(e=>e.groups.flatMap(t=>t.items));function OL(e){return EL.find(t=>t.tool===e)}var _h=(()=>{let e={Escape:"cursor"};for(let t of EL){if(!t.implemented||!t.shortcut)continue;let n=t.shortcut.toLowerCase();e[n]=t.tool,e[n.toUpperCase()]=t.tool}return e})();var Qt=require("react/jsx-runtime");function FH({icon:e}){return typeof e>"u"?(0,Qt.jsx)(ea,{className:"w-4 h-4"}):(0,Qt.jsx)("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)=>(0,Qt.jsx)("path",{d:t},n))})}function zH(){let[e,t]=(0,cs.useState)(new Set);return(0,cs.useEffect)(()=>{let r=()=>{let o=Gr(Pn.drawingFavorites,null);t(new Set(Array.isArray(o)?o:[]))};return r(),Tc(r)},[]),[e,r=>{t(o=>{let a=new Set(o);return a.has(r)?a.delete(r):a.add(r),Sr(Pn.drawingFavorites,[...a]),a})}]}function mv({active:e,label:t,children:n,onClick:r}){return(0,Qt.jsxs)(Gt,{delayDuration:300,children:[(0,Qt.jsx)(qt,{asChild:!0,children:(0,Qt.jsx)("button",{className:ne("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})}),(0,Qt.jsx)(Ut,{side:"right",className:"flex items-center gap-2 bg-background border border-border",children:(0,Qt.jsx)("span",{children:t})})]})}function HH({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(0,Qt.jsxs)(gu,{open:n,onOpenChange:r,children:[(0,Qt.jsxs)(Gt,{delayDuration:300,children:[(0,Qt.jsx)(qt,{asChild:!0,children:(0,Qt.jsx)(bu,{asChild:!0,children:(0,Qt.jsx)("button",{className:ne("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&&(0,Qt.jsx)(Ut,{side:"right",className:"bg-background border border-border",children:e.label})]}),(0,Qt.jsx)($l,{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)=>(0,Qt.jsxs)("div",{className:ne("flex flex-col",c>0&&"mt-1.5"),children:[(0,Qt.jsxs)("div",{className:"flex items-center gap-2 px-2 pt-1 pb-1",children:[(0,Qt.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:l.label}),(0,Qt.jsx)("span",{className:"h-px flex-1 bg-border/60"})]}),(0,Qt.jsx)("div",{className:"flex flex-col gap-0.5",children:l.items.map(u=>(0,Qt.jsx)(VH,{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 VH({item:e,active:t,favorited:n,onSelect:r,onToggleFavorite:o}){return(0,Qt.jsxs)("div",{className:ne("group flex items-center gap-2 rounded pl-2 pr-1 py-1 text-xs transition-colors duration-200 hover:duration-0",e.implemented?ne("cursor-pointer",t?"bg-primary/15 text-primary":"text-foreground hover:bg-muted/70"):"text-muted-foreground/50 cursor-not-allowed"),onClick:r,children:[(0,Qt.jsx)("span",{className:"shrink-0 [&>svg]:w-3.5 [&>svg]:h-3.5",children:e.icon}),(0,Qt.jsx)("span",{className:"flex-1 truncate",children:e.label}),!e.implemented&&(0,Qt.jsx)("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/60",children:"soon"}),e.implemented&&e.shortcut&&(0,Qt.jsx)("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&&(0,Qt.jsx)("button",{"aria-label":n?"Unfavorite":"Favorite",className:ne("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:(0,Qt.jsx)(El,{size:13,fill:n?"currentColor":"none"})})]})}function WH({children:e}){let[t,n]=(0,cs.useState)(null),[r,o]=(0,cs.useState)(!1),[a,i]=(0,cs.useState)(!1);(0,cs.useEffect)(()=>{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(0,Qt.jsxs)("div",{className:"relative flex flex-col w-full flex-1 min-h-0",children:[(0,Qt.jsx)("div",{ref:n,className:"flex-1 min-h-0 w-full overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,Qt.jsx)("div",{className:"flex flex-col items-center gap-0.5",children:e})}),(0,Qt.jsx)("div",{className:ne("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:(0,Qt.jsx)("button",{onClick:()=>s("up"),"aria-label":"Scroll up",className:ne("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:(0,Qt.jsx)(oi,{size:12})})}),(0,Qt.jsx)("div",{className:ne("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:(0,Qt.jsx)("button",{onClick:()=>s("down"),"aria-label":"Scroll down",className:ne("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:(0,Qt.jsx)(or,{size:12})})})]})}function pv(){return(0,Qt.jsx)("div",{className:"w-5 border-t border-border my-1"})}function _L({activeTool:e,onToolChange:t,pluginDrawings:n}){let[r,o]=zH(),[a,i]=(0,cs.useState)(null),s=[...r].map(l=>OL(l)).filter(l=>!!l&&!!l.implemented);return(0,Qt.jsxs)("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:[(0,Qt.jsx)(mv,{active:e==="cursor",label:"Cursor",onClick:()=>t("cursor"),children:Ga.cursor}),(0,Qt.jsx)(pv,{}),(0,Qt.jsxs)(WH,{children:[fv.map(l=>(0,Qt.jsx)(HH,{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&&(0,Qt.jsx)(pv,{}),n.map(l=>(0,Qt.jsx)(mv,{active:e===l.id,label:l.name,onClick:()=>t(l.id),children:l.icon?(0,Qt.jsx)(FH,{icon:l.icon}):(0,Qt.jsx)(ea,{className:"w-4 h-4"})},l.id)),s.length>0&&(0,Qt.jsx)(pv,{}),s.map(l=>(0,Qt.jsx)(mv,{active:e===l.tool,label:l.label,onClick:()=>t(l.tool),children:l.icon},l.tool))]})]})}function hv(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 FL(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 HL(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:H,isHoldingCtrlRef:K,isHoldingShiftRef:G,lastMouse:V,hasDragged:q,longPressTimer:j,showTooltipRef:W,shiftAnchorRef:$,shiftAnchor2Ref:J,showShiftInfo:me,lastStatusLineUpdateRef:We,horizonRef:Ce,tradesRef:Ee,priceHistoryRef:ze,allPriceHistoryRef:Ie,ohlcvBarsRef:ee,previewBarsRef:Be,dataLevelRef:F,openBarRef:le,candleCacheRef:ce,footprintBarsRef:ke,datasetStartRef:De,datasetEndRef:ve,horizonScrollAnimRef:Qe,liveBookRef:Ye,tradeLineInteractionRef:$e,selectedTradeRef:bt,transformer:Oe,eventBus:Tt,features:bn,showTimeframeWindowRef:En,setActiveTool:Lt,setSelectedDrawingId:it,setSettingsBarPos:ft,setContextMenu:ie,setPanes:ge,setChartSettings:pe,setEditingTextId:Le,setOpenSettingsDialog:Ue,setShowTimeframeWindow:Ge,setTimeframeWindowInput:Ve,setPendingText:Ne,pushDrawParams:Se,publishTimeRangeSync:He,scheduleResample:_e,runIndicatorWorker:dt,getTradesUpToHorizon:_t,updateSettingsBarPos:te,handleDeleteDrawing:Me,autofitPanesSilent:Pe,autofitIndicatorPanes:at,getPanel:nt,getLayouts:pt,recomputeLayouts:Xt,applyLayoutsToDom:Ft,buildChartTypeActiveCtx:cr}=e;function Mn(U){R.current=U,Lt(U)}function ir(){m.current=null,Mn(Yo)}function Vn(){let U=Oe.getOrdinal();if(U){let rt=Math.min(3400,Math.max(10,U.length+20));return{min:3n,max:BigInt(rt)}}let be=D.current.barNs;if(be<=0n)return{min:cp,max:up};let he=be*3n,je=be*3400n;return{min:he,max:je}}function fr(U){let be=Oe.getOrdinal();if(be){let ht=be.length,Je=Oe.tsToFracIndex(U.tMin),Rt=Oe.tsToFracIndex(U.tMax),Jt=Rt-Je;if(Jt<=0)return;let rn=Math.min(Jt*.5,20),Q=ht-1+rn;Rt>Q&&(Je-=Rt-Q,Rt=Q),Je<0&&(Rt+=-Je,Je=0),U.tMin=Oe.indexToTs(Je),U.tMax=Oe.indexToTs(Rt);return}let he=De.current+D.current.barNs/2n,je=ve.current;if(he===0n||je===0n)return;let rt=U.tMax-U.tMin,yt=Ce.current,xt=yt>0n&&yt<je?yt-D.current.barNs*3n/2n:je-D.current.barNs*3n/2n;U.tMin+rt<he&&(U.tMin=he-rt,U.tMax=he),U.tMin>xt&&(U.tMin=xt,U.tMax=xt+rt)}function _n(U,be){if(U>Ce.current)return be;let he=P.current.chartType;if(F.current==="ohlcv"){let je=ee.current.display.find(Je=>Je.time===Number(U/1000000n));if(!je)return be;let rt=[Math.abs(je.open-be),Math.abs(je.high-be),Math.abs(je.low-be),Math.abs(je.close-be)],yt=Math.min(...rt),xt=["open","high","low","close"],ht=null;for(let Je=0;Je<rt.length;Je++)rt[Je]===yt&&(ht=xt[Je]);return ht?je[ht]:be}else{if(he==="candles"||he==="footprint"||he==="hollow"||he==="bars"){let Rt=ke.current;if(Rt.length===0)return be;let Jt=0,rn=Rt.length-1,Q=0;for(;Jt<=rn;){let Te=Jt+rn>>>1;Rt[Te].ts<=U?(Q=Te,Jt=Te+1):rn=Te-1}let X=Rt[Q];return[X.open,X.high,X.low,X.close].reduce((Te,ct)=>Math.abs(ct-be)<Math.abs(Te-be)?ct:Te)}let je=ze.current;if(je.length===0)return be;let rt=0,yt=je.length-1,xt=0;for(;rt<=yt;){let Rt=rt+yt>>>1;je[Rt].ts<=U?(xt=Rt,rt=Rt+1):yt=Rt-1}let ht=je[xt];return[ht.bestBid,ht.bestAsk].reduce((Rt,Jt)=>Math.abs(Jt-be)<Math.abs(Rt-be)?Jt:Rt)}}function qn(U){return Rp(U,D.current.barNs,N.current)}function z(U,be,he){return{ts:be,price:he,x:U.clientX-o.current.getBoundingClientRect().left,y:U.clientY-o.current.getBoundingClientRect().top,shiftKey:U.shiftKey,ctrlKey:U.ctrlKey,altKey:U.altKey,buttons:U.buttons,ctx:cr()}}function ae(U){return{key:U.key,code:U.code,shiftKey:U.shiftKey,ctrlKey:U.ctrlKey,ctx:cr()}}function fe(){let U=P.current.chartType;return B.current.get(U)??null}function de(U,be){let he=po(c.current),je=U.a.ts<U.b.ts?U.a.ts:U.b.ts,rt=U.a.ts<U.b.ts?U.b.ts:U.a.ts,yt=Ee.current.filter(Te=>Te.ts>=je&&Te.ts<=rt),xt=new Map;for(let Te of yt){if(Te.ts>be)break;let ct=Math.round(Te.price/he)*he,vt=xt.get(ct);vt?Te.side==="B"?vt[0]+=Te.size:vt[1]+=Te.size:xt.set(ct,Te.side==="B"?[Te.size,0]:[0,Te.size])}let ht=Array.from(xt.entries()).sort((Te,ct)=>Te[0]-ct[0]),Je=ht.length,Rt=new Float64Array(Je),Jt=new Float64Array(Je),rn=new Float64Array(Je),Q=new Float64Array(Je),X=NaN,ye=-1;for(let Te=0;Te<Je;Te++){let[ct,[vt,ue]]=ht[Te];Rt[Te]=ct,Jt[Te]=vt,rn[Te]=ue,Q[Te]=vt+ue,vt+ue>ye&&(ye=vt+ue,X=ct)}return{prices:Rt,buyVol:Jt,sellVol:rn,totalVol:Q,poc:X}}(0,zL.useEffect)(()=>{let U=r.current,be=a.current;if(!U||t!=="ready")return;let he={commitDrawing(ue){let Fe=ue,St=Fe.pluginToolId??ue.tool,{keepActive:Et,...Fn}=ue,Zt={...Fn,id:vn(),tool:St,data:{...bo.get(St)?.defaultData,...Fe.data}};d.current=[...d.current,Zt],m.current=null,Mn(Et?ud(R.current.name):Yo),f.current=Zt.id,it(Zt.id),Se(),A.current?.markDirty("drawings")},setDraft(ue){m.current={...m.current,...ue},Se(),A.current?.markDirty("drawings")},requestRedraw(){A.current?.markDirty("drawings")},deactivate(){ir(),Se(),A.current?.markDirty("drawings")},getOverlayCanvas(){return o.current}};S.current=he;function je(ue,Fe,St,Et){return{ts:Fe,price:St,x:ue.clientX-o.current.getBoundingClientRect().left,y:ue.clientY-o.current.getBoundingClientRect().top,shiftKey:ue.shiftKey,ctrlKey:ue.ctrlKey,altKey:ue.altKey,buttons:ue.buttons,tool:he,plugin:Et}}function rt(ue){return{key:ue.key,code:ue.code,shiftKey:ue.shiftKey,ctrlKey:ue.ctrlKey,tool:he}}let yt=ue=>{{let ot=$e.current,tn=!1,ut={...ue,currentTarget:U,stopPropagation:()=>{tn=!0},preventDefault:()=>ue.preventDefault(),clientX:ue.clientX,clientY:ue.clientY,button:ue.button};if(ot.onMouseDown(ut),tn)return}if(ue.button===1){let ot=U.getBoundingClientRect(),tn=ue.clientX-ot.left,ut=ue.clientY-ot.top,mr=s.current;if(!mr)return;let Yt=$n(),fn=Lf(tn,ut,d.current,mr,C.current,U.width/Yt,U.height/Yt,Oe,e.hideTimeScale,e.priceScaleWidthRef.current,e.symbolInfoRef.current);fn&&(ue.preventDefault(),Me(fn.drawingId));return}if(ue.button!==0)return;let Fe=U.getBoundingClientRect(),St=ue.clientX-Fe.left,Et=ue.clientY-Fe.top,Fn=s.current;if(!Fn)return;let Zt=$n(),Nt=U.width/Zt,jt=U.height/Zt,zt=Nt-l.current,yn=St<zt&&Et<jt-(e.hideTimeScale?0:kn),wt=pt(),Ht=wt.main,yr=Ht?.h??jt-(e.hideTimeScale?0:kn),ur=Ht?.y??0,dn=Oe.xToTs(St,zt),pn=qn(dn),Ur=Oe.yToPrice(Et-ur,yr),Kn=fe();if(Kn?.onPointerDown&&Kn.onPointerDown(z(ue,pn,Ur))){ue.preventDefault();return}if(R.current.name!=="cursor"){if(!yn)return;let tn=pt().main,ut=tn?.h??jt-(e.hideTimeScale?0:kn),mr=tn?.y??0,Yt=Oe.xToTs(St,zt),fn=qn(Yt),Jn=Oe.yToPrice(Et-mr,ut),on=m.current,mn=Jn;G.current&&on?.a?.price?mn=on.a.price:(ue.ctrlKey||P.current.crosshairMode==="magnet")&&(mn=_n(fn,Jn));let Vt={ts:fn,price:mn},Un=R.current,jr=Un.id||vn(),Or={...Ui(Un.name),...Un.state},er=_r=>{d.current=[...d.current,_r],m.current=null,Mn(Yo),f.current=_r.id,it(_r.id),Se(),A.current?.markDirty("drawings"),te(_r.id),_r.tool==="fvp"&&dt(_t(Ce.current),D.current.barNs)},xr=bo.get(Un.name);if(xr?.onPointerDown&&xr.onPointerDown(je(ue,fn,mn,xr))||xr&&xr.anchorCount===0)return;if(xr){let _r=on,Uo=_r?[..._r.anchors,Vt]:[Vt];typeof xr.anchorCount=="number"&&Uo.length>=xr.anchorCount?er({id:vn(),tool:xr.id,anchors:Uo,data:{...xr.defaultData}}):(m.current={pluginToolId:xr.id,anchors:Uo},Se(),A.current?.markDirty("drawings"));return}let Eo={...Or,id:jr,tool:Un.name};switch(Un.name){case"hline":er({...Eo,price:mn});break;case"vline":er({...Eo,ts:fn});break;case"hray":case"cross-line":er({...Eo,price:mn,ts:fn});break;case"text":Ne({x:St,y:Et,anchor:Vt});break;case"long":case"short":{let _r=po(c.current),Uo=Math.abs(Oe.yToPrice(0,ut)-Oe.yToPrice(ut,ut)),ws=Math.max(Math.round(Uo*.05/_r),1)*_r,hc=Un.name==="long";er({...Eo,a:Vt,b:{...Vt,ts:Vt.ts+D.current.barNs*10n},upAmount:hc?ws*2:ws,downAmount:hc?ws:ws*2});break}default:{if(!on){m.current={...Eo,a:Vt,b:null},Se(),A.current?.markDirty("drawings"),te(f.current);break}let _r=on.a,Uo=on.b;switch(Un.name){case"line":case"info-line":case"trend-angle":case"ray":case"extended-line":case"rect":case"fib":case"fvp":er({...Eo,a:_r,b:Vt});break;case"triangle":Uo?er({...Eo,a:_r,b:Uo,c:Vt}):m.current={...on,b:Vt};break;case"parallel-channel":Uo?er({...Eo,a:_r,b:Uo,height:mn-Uo.price}):m.current={...on,b:Vt};break}}}ue.stopPropagation();return}if(yn){let ot=Lf(St,Et,d.current,Fn,C.current,Nt,jt,Oe,e.hideTimeScale,e.priceScaleWidthRef.current,e.symbolInfoRef.current),tn=ot?d.current.find(mr=>mr.id===ot.drawingId):void 0,ut=tn?.tool==="fvp"&&ot?.anchor==="body";if(ot&&tn){if(f.current=ot.drawingId,it(ot.drawingId),te(ot.drawingId),!tn.locked&&!ut){let Yt=pt().main,fn=Yt?.h??jt-(e.hideTimeScale?0:kn),Jn=Yt?.y??0;g.current=ot,y.current={ts:Oe.xToTs(St,zt),price:Oe.yToPrice(Et-Jn,fn)},v.current={x:St,y:Et},U.style.cursor=hv(ot.anchor)}if(Se(),A.current?.markDirty("drawings"),!ut){ue.stopPropagation();return}}!ut&&f.current&&(f.current=null,it(null),ft(null),Se(),A.current?.markDirty("drawings"))}if(yn&&R.current.name==="cursor")if(me.current&&!J.current){let tn=pt().main,ut=tn?.h??jt-(e.hideTimeScale?0:kn),mr=tn?.y??0,Yt=Nt-l.current,fn=Number(s.current.tMax-s.current.tMin),Jn=Math.max(0,Math.min(1,St/Yt)),on=s.current.tMin+BigInt(Math.round(Jn*fn)),mn=s.current.pMax-s.current.pMin,Vt=1-Math.max(0,Math.min(1,(Et-mr)/ut)),Un=s.current.pMin+mn*Vt;J.current={ts:on,price:Un,x:St,y:Et},Se(),A.current?.markDirty("ui")}else me.current=!1,$.current=null,J.current=null,Se(),A.current?.markDirty("ui");if(ue.shiftKey&&yn&&R.current.name==="cursor"&&!me.current){let tn=pt().main,ut=tn?.h??jt-(e.hideTimeScale?0:kn),mr=tn?.y??0,Yt=Nt-l.current,fn=Number(s.current.tMax-s.current.tMin),Jn=Math.max(0,Math.min(1,St/Yt)),on=s.current.tMin+BigInt(Math.round(Jn*fn)),mn=s.current.pMax-s.current.pMin,Vt=1-Math.max(0,Math.min(1,(Et-mr)/ut)),Un=s.current.pMin+mn*Vt;me.current=!0,$.current={ts:on,price:Un,x:St,y:Et},J.current=null,Se(),A.current?.markDirty("ui"),ue.stopPropagation();return}L.current=!0,q.current=!1,V.current={x:ue.clientX,y:ue.clientY},I.current>=0&&(x.current=!0);let Jr=Jb(Et,C.current,wt);Jr!==-1?(k.current=Jr,M.current=null,H.current="none"):St>Nt-l.current?(k.current=-1,M.current=eu(Et,C.current,wt)?.id??null,H.current="scaleY"):Et>jt-(e.hideTimeScale?0:kn)?(k.current=-1,M.current=null,H.current="scaleX"):(k.current=-1,M.current=eu(Et,C.current,wt)?.id??null,H.current="pan",Qe.current=null),j.current=setTimeout(()=>{W.current=!0},500),Se(),A.current?.markDirty("ui"),A.current?.markDirty("base")},xt=ue=>{{let zt=$e.current,yn={currentTarget:U,stopPropagation:()=>{},preventDefault:()=>{},clientX:ue.clientX,clientY:ue.clientY,button:ue.button};zt.onMouseUp(yn)}let Fe=$n(),St=U.width/Fe,Et=U.height/Fe,Fn=U.getBoundingClientRect(),Zt=ue.clientX-Fn.left,Nt=ue.clientY-Fn.top;if(g.current){let zt=g.current.drawingId;g.current=null,y.current=null,v.current=null,Se(),A.current?.markDirty("drawings"),U.style.cursor="crosshair",te(zt),d.current.find(wt=>wt.id===zt)?.tool==="fvp"&&dt(_t(Ce.current),D.current.barNs);return}if(R.current.name!=="cursor"){let zt=bo.get(R.current.name);if(zt?.onPointerUp){let yn=St-l.current;if(Zt<yn&&Nt<Et-(e.hideTimeScale?0:kn)){let yr=pt().main,ur=yr?.h??Et-(e.hideTimeScale?0:kn),dn=yr?.y??0,pn=Oe.xToTs(Zt,yn),zn=qn(pn),Kn=Oe.yToPrice(Nt-dn,ur);if(zt.onPointerUp(je(ue,zn,Kn,zt)))return}}}j.current&&clearTimeout(j.current),x.current=!1,W.current=!1,L.current=!1,H.current="none",k.current=-1,M.current=null,at();let jt=$e.current.cursorRef?.current??"default";jt!=="default"?U.style.cursor=jt:Zt>St-l.current?U.style.cursor="ns-resize":Nt>Et-(e.hideTimeScale?0:kn)?U.style.cursor="ew-resize":U.style.cursor="crosshair",q.current||ht(ue),s.current&&s.current.tMin<De.current&&Tt.emit("data:request-backward",{viewMin:s.current.tMin,symbol:c.current?.symbol})},ht=ue=>{let Fe=s.current;if(!Fe||document.elementFromPoint(ue.clientX,ue.clientY)!==U)return;let St=U.getBoundingClientRect(),Et=ue.clientX-St.left,Fn=ue.clientY-St.top,Zt=$n(),Nt=U.width/Zt,jt=U.height/Zt,zt=Nt-l.current,yn=jt-(e.hideTimeScale?0:kn);if(Et>zt||Fn>yn)return;{let Ht=$e.current,yr={currentTarget:U,stopPropagation:()=>{},preventDefault:()=>{},clientX:ue.clientX,clientY:ue.clientY};Ht.onClick(yr);let ur=Ht.cursorRef?.current??Ht.cursor;!L.current&&ur!=="default"&&(U.style.cursor=ur)}if(!P.current.showTradeDots)return;let wt=pt().main?.h??yn;bt.current=iC(Et,Fn,Ee.current,Fe,zt,wt,P.current,Ce.current,Oe),Se(),A.current?.markDirty("ui")},Je=ue=>{En.current&&ue.target&&ue.target.id==="change-timeframe"&&(Ge(!1),Ve(""))},Rt=ue=>{{let jt=$e.current,zt=!1,yn={currentTarget:U,stopPropagation:()=>{zt=!0},preventDefault:()=>{},clientX:ue.clientX,clientY:ue.clientY};if(jt.onDoubleClick(yn),zt)return}let Fe=U.getBoundingClientRect(),St=ue.clientX-Fe.left,Et=ue.clientY-Fe.top,Fn=$n(),Zt=U.width/Fn,Nt=U.height/Fn;if(St<=Zt-l.current&&Et<=Nt-(e.hideTimeScale?0:kn)){let jt=Lf(St,Et,d.current,s.current,C.current,Zt,Nt,Oe,e.hideTimeScale,e.priceScaleWidthRef.current,e.symbolInfoRef.current);if(jt){if(d.current.find(yn=>yn.id===jt.drawingId)?.tool==="text"){it(jt.drawingId),f.current=jt.drawingId,Le(jt.drawingId);return}it(jt.drawingId),f.current=jt.drawingId,te(jt.drawingId),Ue(!0),Se(),A.current?.markDirty("drawings");return}}if(St>Zt-l.current){let jt=pt(),zt=eu(Et,C.current,jt);if(zt&&!zt.isMain){let wt=w.current.find(dn=>dn.paneId===zt.id),{tMin:Ht,tMax:yr}=s.current,ur=wt?.getAutoYBounds?.(Ht,yr,Ce.current);ge(dn=>{let pn=dn.map(zn=>zn.id!==zt.id?zn:{...zn,yAxisAuto:!0,...ur?{yMin:ur.min,yMax:ur.max}:{}});return C.current=pn,Xt(),pn}),ur&&(C.current=C.current.map(dn=>dn.id===zt.id?{...dn,yAxisAuto:!0,yMin:ur.min,yMax:ur.max}:dn)),Se(),te(f.current),A.current?.markAllDirty();return}u.current=!0,pe(wt=>({...wt,autoScale:u.current}));let yn=s.current;Vr(yn,ze.current,Ee.current,F.current==="ohlcv"?ee.current.display:Be.current,le.current,P.current,Ce.current,F.current),_e(),Se(),A.current?.markAllDirty()}else if(Et>Nt-(e.hideTimeScale?0:kn)){let jt=s.current,zt=Oe.getOrdinal();if(zt){let yn=zt.length,wt=Math.min(yn,200);jt.tMin=Oe.indexToTs(yn-wt),jt.tMax=Oe.indexToTs(yn-1+Math.min(wt*.1,10))}else{let yn=800000000000n,wt=100000000000n,Ht=Ie.current[Ie.current.length-1].ts;jt.tMin=Ht-yn+wt,jt.tMax=Ht+wt}_e(),Se(),te(f.current),A.current?.markAllDirty()}},Jt=ue=>{let Fe=s.current;if(!Fe)return;let St=performance.now();if(St-We.current<=33)return;We.current=St;let Et=$n(),Fn=U.width/Et-l.current;Tt.emit("status:compute",{cellId:n,x:ue,priceHistory:ze.current,trades:Ee.current,bounds:Fe,chartW:Fn,barNs:D.current.barNs,candleCache:ce.current,bars:ee.current.display,openBar:le.current,horizon:Ce.current,dataLevel:F.current,transformer:Oe})},rn=ue=>{if(im.locked){E.current&&(E.current=null,A.current?.markDirty("ui"));return}K.current=ue.ctrlKey,G.current=ue.shiftKey;let Fe=$n(),St=U.width/Fe,Et=U.height/Fe,Fn=U.getBoundingClientRect(),Zt=ue.clientX-Fn.left,Nt=ue.clientY-Fn.top,jt=s.current;if(!jt)return;let zt=!1;{let ot=$e.current,tn={currentTarget:U,stopPropagation:()=>{},preventDefault:()=>{},clientX:ue.clientX,clientY:ue.clientY};ot.onMouseMove(tn);let ut=ot.cursorRef?.current??ot.cursor;!L.current&&ut!=="default"&&(U.style.cursor=ut,zt=!0)}if((Zt<0||Nt<0||Zt>St||Nt>Et)&&!L.current&&!g.current){E.current!==null&&(E.current=null,Se(),A.current?.markDirty("ui"));return}if(!L.current&&!g.current&&document.elementFromPoint(ue.clientX,ue.clientY)!==U){E.current!==null&&(E.current=null,Se(),A.current?.markDirty("ui"));return}let wt=St-l.current,Ht=Zt<wt&&Nt<Et-(e.hideTimeScale?0:kn);if(E.current={x:Zt,y:Nt},Tt.emit("crosshair:move",{x:Zt,y:Nt}),E.current&&s.current&&Jt(Zt),g.current){let{drawingId:ot,anchor:tn}=g.current,mr=pt().main,Yt=mr?.h??Et-(e.hideTimeScale?0:kn),fn=mr?.y??0,Jn=Oe.xToTs(Zt,wt),on=qn(Jn),mn=Oe.yToPrice(Nt-fn,Yt),Vt=mn;(ue.ctrlKey||P.current.crosshairMode==="magnet")&&tn!=="body"&&(Vt=_n(on,mn),mn=Vt);let Un=y.current;if(Un){let jr=(on-Un.ts)/D.current.barNs*D.current.barNs,Or=Vt-Un.price;d.current=d.current.map(er=>{if(er.id!==ot)return er;if(er.tool==="text"&&er.screenAnchored){let _r=v.current;if(_r){let Uo=Zt-_r.x,ws=Nt-_r.y,hc=(er.screenX??Zt)+Uo,kg=(er.screenY??Nt)+ws;return{...er,screenX:hc,screenY:kg}}return er}let{drawing:xr,anchor:Eo}=EC(er,tn,jr,Or,on,Vt,G.current);return Eo!==tn&&g.current&&(g.current={drawingId:ot,anchor:Eo}),xr})}if(y.current={ts:on,price:Vt},v.current={x:Zt,y:Nt},b.current){let jr=d.current.find(Or=>Or.id===g.current?.drawingId);if(jr?.tool==="fvp"){let Or=jr,er=de(Or,Ce.current);if(jr.vpData=er,er.prices.length>0){let xr=po(c.current)/2;jr.a={ts:Or.a.ts,price:er.prices[0]-xr},jr.b={ts:Or.b.ts,price:er.prices[er.prices.length-1]+xr}}d.current=[...d.current]}}ft(null),U.style.cursor=hv(g.current?.anchor??null),Se(),A.current?.markDirty("drawings"),A.current?.markDirty("ui");return}if(R.current.name!=="cursor"){let ot=m.current,ut=pt().main,mr=ut?.h??Et-(e.hideTimeScale?0:kn),Yt=ut?.y??0,fn=Oe.xToTs(Zt,wt),Jn=qn(fn),on=Oe.yToPrice(Nt-Yt,mr),mn=ue.ctrlKey||P.current.crosshairMode==="magnet"?_n(Jn,on):on;ot&&(ot.tool==="rect"||ot.tool==="fib"||ot.tool==="line"||ot.tool==="ray"||ot.tool==="fvp")&&(ot.b={ts:Jn,price:mn},ot&&"pluginToolId"in ot&&(Se(),A.current?.markDirty("drawings")));let Vt=bo.get(R.current.name);if(Vt?.onPointerMove&&Vt.onPointerMove(je(ue,Jn,mn,Vt)))return;Se(),A.current?.markDirty("drawings"),te(f.current),A.current?.markDirty("ui"),U.style.cursor="crosshair";return}if(Ht&&!L.current){let ot=Lf(Zt,Nt,d.current,jt,C.current,St,Et,Oe,e.hideTimeScale,e.priceScaleWidthRef.current,e.symbolInfoRef.current),tn=ot?.drawingId??null,ut=ot?.anchor??null;if((tn!==h.current||ut!==p.current)&&(h.current=tn,p.current=ut,Se(),A.current?.markDirty("drawings"),te(f.current)),tn&&!zt){let mr=d.current.find(Yt=>Yt.id===tn);mr&&!mr?.locked?U.style.cursor=hv(ut):U.style.cursor="default"}else zt||(U.style.cursor="crosshair")}let yr=pt(),ur=Jb(Nt,C.current,yr),dn=eu(Nt,C.current,yr),pn=L.current&&M.current?C.current.find(ot=>ot.id===M.current)??dn:dn;if(L.current){let ot=Math.abs(ue.clientX-V.current.x),tn=Math.abs(ue.clientY-V.current.y);(ot>3||tn>3)&&(q.current=!0),j.current&&(clearTimeout(j.current),j.current=null),W.current=!1}let zn=!L.current&&ur!==-1,Ur=L.current&&(H.current==="scaleY"||H.current==="scaleX");E.current=zn||Ur?null:{x:Zt,y:Nt};let Kn=dn?.id??null;Kn!==T.current&&I.current<0&&(T.current=Kn,Kn&&Tt.emit("pane:hovered",{id:Kn}));let Jr=zn?ur:-1;if(Jr!==I.current&&!x.current&&(I.current=Jr,Tt.emit("pane:hovered",null)),L.current&&H.current==="pan"?U.style.cursor="grabbing":L.current&&(H.current==="scaleY"||H.current==="scaleX")?U.style.cursor=H.current==="scaleY"?"ns-resize":"ew-resize":!L.current&&!zt&&(k.current===-1&&ur!==-1||Zt>St-l.current?U.style.cursor="ns-resize":Nt>Et-(e.hideTimeScale?0:kn)&&(U.style.cursor="ew-resize")),L.current&&s.current){let ot=ue.clientX-V.current.x,tn=ue.clientY-V.current.y;V.current={x:ue.clientX,y:ue.clientY};let ut=s.current,mr=St-l.current;if(k.current!==-1){let Yt=k.current,fn=C.current.map(xr=>({...xr})),Jn=Et-(e.hideTimeScale?0:kn),on=fn.reduce((xr,Eo)=>xr+Eo.heightRatio,0),mn=Jn/on,Vt=tn/mn,Un=fn[Yt].heightRatio+Vt,jr=fn[Yt+1].heightRatio-Vt,Or=kC*on;Un>=Or&&jr>=Or&&(fn[Yt].heightRatio=Un,fn[Yt+1].heightRatio=jr),C.current=fn,ge(fn);let er=$i(fn,Jn,St,l.current);Ft(er),A.current?.markDirty("base"),A.current?.markDirty("drawings"),te(f.current),A.current?.markDirty("ui")}else if(H.current==="pan"){let Yt=Oe.getSessionMapper();if(Oe.getOrdinal()){let on=Oe.getBarPx(mr);if(on>0){let mn=ot/on,Vt=Oe.tsToFracIndex(ut.tMin),Un=Oe.tsToFracIndex(ut.tMax);ut.tMin=Oe.indexToTs(Vt-mn),ut.tMax=Oe.indexToTs(Un-mn)}}else if(Yt&&Yt.hasSession){let on=Yt.tsToMarket(ut.tMin),mn=Yt.tsToMarket(ut.tMax),Vt=Number(mn-on);if(Vt>0){let Un=BigInt(Math.round(ot*(Vt/mr)));ut.tMin=Yt.marketToTs(on-Un),ut.tMax=Yt.marketToTs(mn-Un)}}else{let on=Number(ut.tMax-ut.tMin);ut.tMin-=BigInt(Math.round(ot*(on/mr))),ut.tMax-=BigInt(Math.round(ot*(on/mr)))}fr(ut);let Jn=pt();if(pn&&!pn.isMain){let on=Jn[pn.id];if(on){let mn=C.current.map(Vt=>{if(Vt.id!==pn.id)return Vt;if(Vt.yAxisAuto){let Un=w.current.find(Or=>Or.paneId===Vt.id);if(!Un?.getAutoYBounds)return Vt;let jr=Un.getAutoYBounds(s.current.tMin,s.current.tMax,Ce.current);return jr?{...Vt,yMin:jr.min,yMax:jr.max}:Vt}else{let Un=Vt.yMax-Vt.yMin,jr=tn*(Un/on.h);return{...Vt,yMin:Vt.yMin+jr,yMax:Vt.yMax+jr}}});C.current=mn,ge(mn)}}else{if(u.current)Vr(ut,ze.current,Ee.current,F.current==="ohlcv"?ee.current.display:Be.current,le.current,P.current,Ce.current,F.current);else{let on=Jn.main?.h??Et-(e.hideTimeScale?0:kn);if(Oe.getScaleMode()==="log"&&ut.pMin>0&&ut.pMax>0){let mn=tn*(Math.log(ut.pMax)-Math.log(ut.pMin))/on,Vt=Math.exp(mn);ut.pMin*=Vt,ut.pMax*=Vt}else{let mn=tn*(ut.pMax-ut.pMin)/on;ut.pMin+=mn,ut.pMax+=mn}}Pe()}Oe.update(ut),Oe.setSessionMapper(N.current),Oe.setSession(O.current),_e(),A.current?.markDirty("base"),A.current?.markDirty("drawings"),te(f.current)}else if(H.current==="scaleY"){if(pn&&!pn.isMain){let Yt=C.current.map(fn=>{if(fn.id!==pn.id)return fn;let Jn=fn.yMax-fn.yMin,on=fn.yMin+Jn/2,mn=Jn*(1+tn*.002*P.current.priceAxisResizeSensitivity);return{...fn,yMin:on-mn/2,yMax:on+mn/2,yAxisAuto:!1}});C.current=Yt,ge(Yt)}else{u.current=!1,pe(fn=>({...fn,autoScale:u.current}));let Yt=1+tn*.002*P.current.priceAxisResizeSensitivity;[ut.pMin,ut.pMax]=FL(ut.pMin,ut.pMax,Yt,Oe.getScaleMode()==="log")}_e(),A.current?.markDirty("base"),A.current?.markDirty("drawings"),te(f.current)}else if(H.current==="scaleX"){let Yt=Oe.getSessionMapper(),{min:fn,max:Jn}=Vn();if(Yt&&Yt.hasSession){let on=Yt.tsToMarket(ut.tMax),mn=Number(Yt.tsToMarket(ut.tMax)-Yt.tsToMarket(ut.tMin)),Vt=BigInt(Math.round(mn*(1+ot*.001))),Un=Vt<fn?fn:Vt>Jn?Jn:Vt;ut.tMin=Yt.marketToTs(on-Un)}else{let on=Number(ut.tMax-ut.tMin),mn=BigInt(Math.round(on*(1+ot*.001))),Vt=mn<fn?fn:mn>Jn?Jn:mn;ut.tMin=ut.tMax-Vt}Vr(ut,ze.current,Ee.current,F.current==="ohlcv"?ee.current.display:Be.current,le.current,P.current,Ce.current,F.current),Pe(),_e(),A.current?.markDirty("base"),A.current?.markDirty("drawings"),te(f.current)}}nt()?.update(Ye.current),Se(),He(),A.current?.markDirty("ui")},Q=()=>{{let ue=$e.current,Fe={currentTarget:U,stopPropagation:()=>{},preventDefault:()=>{}};ue.onMouseLeave(Fe)}E.current=null,Tt.emit("pane:hovered",null),I.current=-1,L.current||(Se(),A.current?.markDirty("ui"))},X=ue=>{if(ue.preventDefault(),!s.current)return;let Fe=s.current,St=U.getBoundingClientRect(),Et=$n(),Fn=U.width/Et,Zt=U.height/Et,Nt=ue.clientX-St.left,jt=ue.clientY-St.top;if(Nt>Fn-l.current){let zt=pt(),yn=eu(jt,C.current,zt);if(yn&&!yn.isMain){let wt=C.current.map(Ht=>{if(Ht.id!==yn.id)return Ht;let yr=Ht.yMax-Ht.yMin,ur=Ht.yMin+yr/2,dn=yr*(1+ue.deltaY*.001);return{...Ht,yMin:ur-dn/2,yMax:ur+dn/2,yAxisAuto:!1}});C.current=wt,ge(wt)}else{u.current=!1,pe(Ht=>({...Ht,autoScale:u.current}));let wt=1+ue.deltaY*.001;[Fe.pMin,Fe.pMax]=FL(Fe.pMin,Fe.pMax,wt,Oe.getScaleMode()==="log")}_e(),Se(),A.current?.markDirty("base"),A.current?.markDirty("drawings"),te(f.current)}else if(jt<=Zt-(e.hideTimeScale?0:kn)){let zt=Oe.getSessionMapper(),yn=Oe.getOrdinal(),{min:wt,max:Ht}=Vn(),yr=Fn-l.current;if(yn){let dn=Oe.tsToFracIndex(Fe.tMin),pn=Oe.tsToFracIndex(Fe.tMax),zn=pn-dn,Ur=Kn=>Math.max(Number(wt),Math.min(Number(Ht),Kn));if(ue.ctrlKey){let Kn=Nt/yr,Jr=Ur(zn*(ue.deltaY>0?1.1:.9)),ot=dn+Kn*zn;Fe.tMin=Oe.indexToTs(ot-Jr*Kn),Fe.tMax=Oe.indexToTs(ot+Jr*(1-Kn))}else{let Kn=Ur(zn*(1+ue.deltaY*6e-4));Fe.tMin=Oe.indexToTs(pn-Kn)}}else if(zt&&zt.hasSession){let dn=zt.tsToMarket(Fe.tMin),pn=zt.tsToMarket(Fe.tMax),zn=Number(pn-dn),Ur=1+ue.deltaY*6e-4,Kn=BigInt(Math.round(zn*Ur)),Jr=Kn<wt?wt:Kn>Ht?Ht:Kn;if(!ue.ctrlKey)Fe.tMin=zt.marketToTs(pn-Jr);else{let ot=Nt/yr,tn=dn+BigInt(Math.round(ot*zn)),ut=ue.deltaY>0?1.1:.9,mr=zn*ut,Yt=Math.max(Number(wt),Math.min(Number(Ht),mr));Fe.tMin=zt.marketToTs(tn-BigInt(Math.round(Yt*ot))),Fe.tMax=zt.marketToTs(tn+BigInt(Math.round(Yt*(1-ot))))}}else{let dn=Number(Fe.tMax-Fe.tMin),pn=BigInt(Math.round(dn*(1+ue.deltaY*6e-4))),zn=pn<wt?wt:pn>Ht?Ht:pn;if(!ue.ctrlKey)Fe.tMin=Fe.tMax-zn;else{let Ur=Nt/yr,Kn=ue.deltaY>0?1.1:.9,Jr=dn*Kn,ot=Math.max(Number(wt),Math.min(Number(Ht),Jr)),tn=Fe.tMin+BigInt(Math.round(dn*Ur));Fe.tMin=tn-BigInt(Math.round(ot*Ur)),Fe.tMax=Fe.tMin+BigInt(Math.round(ot))}}u.current&&Vr(Fe,ze.current,Ee.current,F.current==="ohlcv"?ee.current.display:Be.current,le.current,P.current,Ce.current,F.current),Pe();let ur=Fn-l.current;{let dn=Number(Fe.tMax-Fe.tMin),pn=Oe.getSessionMapper();if(Oe.getOrdinal()){let Ur=Oe.getBarPx(ur);if(Ur>0){let Kn=-ue.deltaX/Ur,Jr=Oe.tsToFracIndex(Fe.tMin),ot=Oe.tsToFracIndex(Fe.tMax);Fe.tMin=Oe.indexToTs(Jr-Kn),Fe.tMax=Oe.indexToTs(ot-Kn)}}else if(pn&&pn.hasSession){let Ur=pn.tsToMarket(Fe.tMin),Kn=pn.tsToMarket(Fe.tMax),Jr=Number(Kn-Ur);if(Jr>0){let ot=BigInt(Math.round(-ue.deltaX*(Jr/ur)));Fe.tMin=pn.marketToTs(Ur-ot),Fe.tMax=pn.marketToTs(Kn-ot)}}else Fe.tMin-=BigInt(Math.round(-ue.deltaX*(dn/ur))),Fe.tMax-=BigInt(Math.round(-ue.deltaX*(dn/ur)))}if(fr(Fe),Qe.current){let dn=Qe.current,pn=dn.targetTMin-dn.startTMin;Qe.current={startTMin:Fe.tMin,startTMax:Fe.tMax,targetTMin:Fe.tMin+pn,targetTMax:Fe.tMax+pn,startTime:performance.now()}}_e(),Se(),A.current?.markDirty("base"),A.current?.markDirty("drawings"),te(f.current)}s.current.tMin<De.current&&Tt.emit("data:request-backward",{viewMin:s.current.tMin,symbol:c.current?.symbol}),Se(),He(),A.current?.markDirty("ui")},ye=ue=>{let Fe=i.current,St=document.activeElement;if(!Fe||!St||!Fe.contains(St))return;En.current&&ue.key==="Escape"&&(Ge(!1),Ve(""));let Et=fe();if(Et?.onKeyDown&&Et.onKeyDown(ae(ue))){ue.preventDefault();return}ue.ctrlKey&&(K.current=!0),ue.shiftKey&&(G.current=!0);let Fn=document.activeElement,Zt=Fn instanceof HTMLInputElement||Fn instanceof HTMLTextAreaElement||Fn instanceof HTMLElement&&Fn.isContentEditable;if(Zt)return;let Nt=bo.get(R.current.name);if(!(Nt?.onKeyDown&&Nt.onKeyDown(rt(ue)))){if(ue.altKey&&ue.key!=="Escape"&&_h[ue.key]!==void 0){let jt=_h[ue.key];jt==="cursor"?(ir(),Se(),A.current?.markDirty("drawings"),te(f.current)):Mn(ud(jt));return}if(ue.key==="Escape"){if(En.current&&(Ge(!1),Ve("")),$.current){$.current=null,me.current=!1,Se(),A.current?.markDirty("ui");return}let jt=m.current;if(Nt?.anchorCount==="dynamic"&&jt?.pluginToolId===Nt.id&&jt.anchors.length>0){let zt={id:vn(),tool:Nt.id,anchors:jt.anchors,data:{...Nt.defaultData}};d.current=[...d.current,zt],m.current=null,Mn(Yo),f.current=zt.id,it(zt.id),Se(),A.current?.markDirty("drawings"),te(zt.id);return}ir(),f.current=null,it(null),ft(null),Se(),A.current?.markDirty("drawings"),te(f.current);return}if((ue.key==="Delete"||ue.key==="Backspace")&&f.current&&!Zt){let jt=f.current;d.current=d.current.filter(zt=>zt.id!==jt),f.current=null,it(null),ft(null),Se(),A.current?.markDirty("drawings"),te(f.current);return}ue.key>="0"&&ue.key<="9"&&(Ge(!0),Ve(ue.key))}},Te=ue=>{(ue.key==="Control"||ue.key==="Meta")&&(K.current=!1),ue.key==="Shift"&&(G.current=!1)},ct=ue=>{if(ue.preventDefault(),!bn.contextMenu)return;{let zt=$e.current,yn=!1,wt={currentTarget:U,stopPropagation:()=>{yn=!0},preventDefault:()=>{},clientX:ue.clientX,clientY:ue.clientY};if(zt.onContextMenu(wt),yn)return}let Fe=U.getBoundingClientRect(),St=$n(),Et=U.height/St,Fn=ue.clientY-Fe.top,Zt=s.current,Nt=Fn>Et-(e.hideTimeScale?0:kn),jt=Zt&&!Nt?Zt.pMin+(Et-(e.hideTimeScale?0:kn)-Fn)/(Et-(e.hideTimeScale?0:kn))*(Zt.pMax-Zt.pMin):null;ie({x:ue.clientX,y:ue.clientY,target:Nt?"xaxis":"chart",priceAtClick:jt}),E.current=null,Se(),A.current?.markDirty("ui")};U.addEventListener("mousedown",yt),U.addEventListener("dblclick",Rt),window.addEventListener("mousemove",rn),window.addEventListener("mousedown",Je),window.addEventListener("mouseup",xt),window.addEventListener("keydown",ye),window.addEventListener("keyup",Te),be.addEventListener("mouseleave",Q),U.addEventListener("wheel",X,{passive:!1}),U.addEventListener("contextmenu",ct);let vt=Tt.on("status:refresh",()=>{let ue=E.current,Fe=s.current;!ue||!Fe||Jt(ue.x)});return()=>{U.removeEventListener("mousedown",yt),U.removeEventListener("dblclick",Rt),window.removeEventListener("mousemove",rn),window.removeEventListener("mouseup",xt),window.removeEventListener("keydown",ye),window.removeEventListener("keyup",Te),be.removeEventListener("mouseleave",Q),U.removeEventListener("wheel",X),U.removeEventListener("contextmenu",ct),vt()}},[t])}var Wr=require("react");var qH=.08;function VL(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:H,scheduleResample:K,runIndicatorWorker:G,getTradesUpToHorizon:V,getLayouts:q,rebuildCandleCache:j,syncOhlcvOpenBar:W,updatePriceHistoryToRawIdx:$,findPriceHistoryIdx:J,resetXAxis:me,resetYAxis:We,autofitIndicatorPanes:Ce}=e,Ee=(0,Wr.useRef)(new Map),ze=(0,Wr.useCallback)((it,ft)=>{t.current=t.current.map(ie=>{if(ie.id!==it)return ie;if(ie.tool==="text"&&ft.screenAnchored===!0&&!ie.screenAnchored){let ge=n.current,pe=r.current,Le=$n(),Ue=ge.width/Le,Ge=ge.height/Le,Ne=q().main,Se=Ne?.h??(Ge??0)-(e.hideTimeScale?0:kn),He=Ne?.y??0,_e=ge?Ue-e.priceScaleWidthRef.current:0;if(ge&&pe){let dt=x.tsToX(ie.anchor.ts,_e),_t=x.priceToY(ie.anchor.price,Se)+He;return{...ie,...ft,screenX:dt,screenY:_t}}}return{...ie,...ft}}),E(),I.current?.markDirty("drawings")},[]),Ie=(0,Wr.useCallback)(it=>{t.current=t.current.filter(ft=>ft.id!==it),o.current=null,D(null),N(null),E(),I.current?.markDirty("drawings")},[]),ee=(0,Wr.useCallback)(()=>{t.current=[],o.current=null,D(null),N(null),E(),I.current?.markDirty("drawings")},[]),Be=(0,Wr.useCallback)(it=>{let ft=t.current.find(ge=>ge.id===it);if(!ft)return;let ie={...ft,id:vn()};"price"in ie&&(ie.price+=.5),t.current=[...t.current,ie],o.current=ie.id,D(ie.id),E(),I.current?.markDirty("drawings"),L(ie.id)},[]),F=(0,Wr.useCallback)(it=>{let ft=a.current.map(ie=>ie.id===it?{...ie,visible:!ie.visible}:ie);a.current=ft,R(ft),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),le=(0,Wr.useCallback)(it=>{let ft=i.current.filter(ge=>ge.id!==it);i.current=ft,P(ft);let ie=a.current.filter(ge=>ge.paneId!==it);a.current=ie,R(ie),H(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),ce=(0,Wr.useCallback)(it=>{let ft=a.current.find(ge=>ge.id===it),ie=a.current.filter(ge=>ge.id!==it);a.current=ie,R(ie),ft?.paneId&&i.current.some(ge=>ge.id===ft?.paneId)&&ft.paneId!=="main"&&le(ft.paneId),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),ke=(0,Wr.useCallback)(it=>{a.current.find(ie=>ie.id===it)&&O(it)},[]),De=(0,Wr.useCallback)(()=>{a.current=[],R([]);let it=i.current.filter(ft=>ft.isMain);i.current=it,P(it),H(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),ve=(0,Wr.useCallback)(it=>{let ft=i.current.findIndex(ge=>ge.id===it);if(ft<=0)return;let ie=[...i.current];[ie[ft-1],ie[ft]]=[ie[ft],ie[ft-1]],i.current=ie,P(ie),H(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),Qe=(0,Wr.useCallback)(it=>{let ft=i.current.findIndex(ge=>ge.id===it);if(ft<0||ft>=i.current.length-1)return;let ie=[...i.current];[ie[ft],ie[ft+1]]=[ie[ft+1],ie[ft]],i.current=ie,P(ie),H(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),Ye=(0,Wr.useCallback)(it=>{let ft=i.current.map(ie=>ie.id===it?{...ie,collapsed:!1,heightRatio:ie.savedHeightRatio??1}:ie);i.current=ft,P(ft),H(),K(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),$e=(0,Wr.useCallback)(it=>{if(T!==null)return;let ft=i.current.map(ie=>ie.id===it?{...ie,collapsed:!ie.collapsed,savedHeightRatio:ie.collapsed?ie.savedHeightRatio:ie.heightRatio,heightRatio:ie.collapsed?ie.savedHeightRatio??1:qH}:ie);i.current=ft,P(ft),H(),K(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[T]),bt=(0,Wr.useCallback)(it=>{B(ft=>{let ie=ft===it?null:it,ge;return ie===null?(ge=i.current.map(pe=>{let Le=Ee.current.get(pe.id);return{...pe,heightRatio:Le??pe.heightRatio}}),Ee.current.clear()):(Ee.current.clear(),i.current.forEach(pe=>Ee.current.set(pe.id,pe.heightRatio)),ge=i.current.map(pe=>({...pe,heightRatio:pe.id===ie?100:0}))),i.current=ge,P(ge),H(),K(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui"),ie})},[]),Oe=(0,Wr.useCallback)(()=>{M.current=!0},[]),Tt=(0,Wr.useCallback)(()=>{M.current=!1},[]),bn=(0,Wr.useCallback)(it=>{s.current.bars.length&&(s.current.barNs=it.barNs,s.current.display=oc(s.current.bars,it.barNs,l.current)),A(it),c.current=it,P(ge=>ge.map(pe=>pe.isMain?{...pe,tf:it.label}:pe));let ft=r.current;if(!ft)return;d.current=-1,$(J(u.current)),m.current=null,j(f.current,it.barNs),h.current=null,p.current=0n,g.current=0,W(u.current),a.current.forEach(ge=>{!ge.hydrate&&ge.compute&&ge.compute(y.current,f.current)}),G(V(u.current),c.current.barNs);let ie=zx(it);ft.tMin=ft.tMax-ie,v.current&&Vr(ft,b.current,f.current,S.current==="ohlcv"?s.current.display:C.current,h.current,w.current,u.current,S.current),me(),We(),Ce(),K(),E(),I.current?.markDirty("base"),I.current?.markDirty("drawings"),L(o.current),I.current?.markDirty("ui")},[]),En=(0,Wr.useCallback)(it=>{if(it==="vp_fixed"){let ft=r.current.tMin,ie=r.current.tMax,ge=(r.current.pMin+r.current.pMax)/2,pe=(r.current.pMax-r.current.pMin)/2,Le={id:vn(),tool:"fvp",a:{ts:ft,price:ge-pe},b:{ts:ie,price:ge+pe},...Ui("fvp")};t.current=[...t.current,Le],o.current=Le.id,D(Le.id),E(),I.current?.markDirty("drawings"),G(V(u.current),c.current.barNs)}},[]),Lt=(0,Wr.useCallback)(it=>{k.current=[...k.current,it],E(),I.current?.markDirty("ui")},[]);return{handleUpdateDrawing:ze,handleDeleteDrawing:Ie,handleDeleteDrawings:ee,handleDuplicateDrawing:Be,handleToggleIndicator:F,handleRemoveIndicator:ce,handleOpenIndicatorSettings:ke,handleRemoveIndicators:De,handleMoveUp:ve,handleMoveDown:Qe,handleRemovePane:le,handleExpand:Ye,handleCollapse:$e,handleMaximize:bt,handleEnter:Oe,handleLeave:Tt,handleTimeframeChange:bn,handleAddIndicator:En,handleAddTradeLine:Lt}}var WL=require("react");var UH={l3:new Set(["l3","tick","ohlcv","l2"]),tick:new Set(["tick","ohlcv"]),ohlcv:new Set(["ohlcv"]),l2:new Set(["l2"])};function Bo(e,t){return UH[t].has(e)}var ku={l3:"order flow",tick:"tick",ohlcv:"candle",l2:"order book"};function ol(e,t){return`Needs ${ku[e]} data. This symbol serves ${ku[t]} data.`}function qL(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:H,applyTimeRangeSync:K}=e;(0,WL.useEffect)(()=>{let G=W=>{let $=s.current.filter(J=>J.id===W||J.id.startsWith(`${W}:`));for(let J of $)B(J.id)},V=0,q=()=>{!r||V||(V=requestAnimationFrame(()=>{V=0,S.current=r.getSnapshot(),R(),c.current?.markDirty("ui")}))},j=[t.on("chart:reset-view",()=>x()),t.on("layout:crosshair",W=>{W&&W.id===n||H(W)}),t.on("layout:time-range",W=>{if(W.id===n)return;let{time:$,dateRange:J}=L.current;!$&&!J||K(W)}),t.on("chart:set-tool",({tool:W})=>C(W)),t.on("chart:set-symbol",({symbol:W,id:$})=>{n===$&&(E(W),w(J=>J.map(me=>me.isMain?{...me,symbol:W}:me)))}),t.on("chart:add-indicator",({id:W})=>A(W)),t.on("chart:remove-indicator",({id:W})=>B(W)),t.on("chart:remove-plugin-indicator",({pluginId:W})=>G(W)),t.on("plugin:uninstalled",({id:W})=>G(W)),t.on("chart:set-type",({old:W,new:$})=>{let J=W,me=$;if(J!==me){o.current.get(J)?.onDeactivate?.();for(let We of a.current)t.emit("plugin:bottom-bar-item-removed",{id:We});a.current.clear(),o.current.get(me)?.onActivate?.(T())}}),t.on("hitmap:update",({id:W,hitMap:$})=>{W===n&&(i.current=$)}),t.on("plugin:add-indicator",({indicator:W,pane:$})=>{s.current.some(J=>J.id===W.id)||($&&!l.current.some(J=>J.id===$.id)&&(l.current=[...l.current,$],w(l.current)),s.current=[...s.current,W],k(s.current),R(),c.current?.markDirty("base"),P(D(u.current),d.current.barNs))}),t.on("plugin:add-indicator:id",({id:W})=>{s.current.find(J=>J.id===W)}),t.on("plugin:register-pane",({id:W,heightRatio:$})=>{if(l.current.some(me=>me.id===W))return;let J={id:W,isMain:!1,heightRatio:$,yMin:0,yMax:0,yAxisAuto:!0,collapsed:!1};l.current=[...l.current,J],w(l.current),N(l.current),R(),c.current?.markDirty("base")}),t.on("plugin:remove-pane",({id:W})=>{l.current.some($=>$.id===W)&&(l.current=l.current.filter($=>$.id!==W),s.current=s.current.filter($=>$.paneId!==W),w(l.current),k(s.current),N(l.current),R(),c.current?.markDirty("base"))}),t.on("plugin:register-chart-type",({plugin:W})=>{if(o.current.has(W.chartTypeId)||(o.current.set(W.chartTypeId,W),M([...o.current.values()]),m.current.chartType!==W.chartTypeId))return;let $=W.require??"ohlcv",J=h.current;if(J&&!Bo($,J)){t.emit("plugin:incompatible",{id:W.chartTypeId,name:W.label??W.name,kind:"chart-type",required:$,actual:J}),I(me=>({...me,chartType:"candles"}));return}W.onActivate?.(T())}),t.on("plugin:unregister-chart-type",({id:W,hotReload:$})=>{o.current.delete(W),f.current.delete(W),M([...o.current.values()]),!$&&m.current.chartType===W?I(J=>({...J,chartType:"candles"})):$&&c.current?.markDirty("base")}),t.on("plugin:recompute-indicator",({id:W})=>{s.current.some($=>$.id===W)&&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:W})=>{let $="__scripted__",J=s.current.find(Be=>Be.id===W&&Be.workerInit===$),me=!J&&o.current.has(W)&&o.current.get(W)?.workerInit===$;if(!J&&!me)return;let We=D(u.current),Ce=-1/0,Ee=1/0;{let Be=b.current;if(Be){let F=d.current.barNs,le=Be.tMax-Be.tMin,ce=1000n*F,ke=le>ce?le:ce,De=Be.tMin-ke,ve=Be.tMax+le;ve>u.current&&(ve=u.current),Ce=Number(De/1000000n),Ee=Number(ve/1000000n)}}let ze=[];function Ie(Be){let F=typeof Be=="bigint"?Be:BigInt(Be);return F<1000000000000n?F*1000000000n:F<1000000000000000n?F*1000000n:F<1000000000000000000n?F*1000n:F}if(h.current==="l3"){for(let Be of p.current)ze.push({ts:Ie(Be.time),open:Be.open,high:Be.high,low:Be.low,close:Be.close,volume:Be.volume});for(let[Be,F]of g.current)ze.push({ts:Ie(Be),open:F.open,high:F.high,low:F.low,close:F.close,volume:F.volume});ze.sort((Be,F)=>Be.ts<F.ts?-1:1)}else if(h.current==="ohlcv"){let Be=Number(d.current.barNs/1000000n),F=Math.floor(Number(u.current/1000000n)/Be)*Be,le=y.current.display,ce=0,ke=le.length-1,De=le.length;for(;ce<=ke;){let ve=ce+ke>>>1;le[ve].time>=Ce?(De=ve,ke=ve-1):ce=ve+1}for(let ve=De;ve<le.length;ve++){let Qe=le[ve];if(Qe.time>Ee)break;if(Qe.time>=F&&v.current){ze.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 ze.push({ts:Ie(Qe.time),open:Qe.open,high:Qe.high,low:Qe.low,close:Qe.close,volume:Qe.volume})}}let ee=We.map(Be=>({time:Number(Be.ts/1000000n),price:Be.price,size:Be.size,side:Be.side}));t.emit("plugin:scripted-compute",{id:W,ohlcv:ze,trades:We,ticks:ee,snapshots:[],barNs:d.current.barNs})}),t.on("plugin:chart-type-updated",({id:W})=>{R(),c.current?.markDirty("base")}),t.on("plugin:indicator-updated",({id:W})=>{let $=s.current.find(J=>J.id===W);if($){if($.paneId&&$.paneId!=="main"){let J=l.current.find(me=>me.id===$.paneId);J?.yAxisAuto&&J.yMin===J.yMax&&O()}c.current?.markDirty("base")}}),t.on("plugin:remove-indicator",({id:W})=>{s.current.some($=>$.id===W)&&(s.current=s.current.filter($=>$.id!==W),k(s.current),R(),c.current?.markDirty("base"))}),t.on("playback:seek",({tNs:W})=>{c.current?.markDirty("ui")}),t.on("account:update",q)];return q(),()=>{V&&cancelAnimationFrame(V),j.forEach(W=>W())}},[t,n])}var _i=require("react");function UL(e){let{baseCanvasRef:t,panesRef:n,priceScaleWidthRef:r}=e,o=(0,_i.useRef)({}),a=(0,_i.useRef)(new Map),[i,s]=(0,_i.useState)({}),l=(0,_i.useCallback)(()=>{let m=t.current;if(!m)return;let f=$n();o.current=$i(n.current,m.height/f-(e.hideTimeScale?0:kn),m.width/f,r.current)},[]),c=(0,_i.useCallback)(()=>o.current,[]),u=(0,_i.useCallback)(m=>{let f=t.current;if(!f)return;let h=m??n.current,p=$n(),g=$i(h,f.height/p-(e.hideTimeScale?0:kn),f.width/p,r.current);o.current=g,s(g)},[]),d=(0,_i.useCallback)(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}}var Fi=require("react");function jH(e){if(typeof e!="object"||e===null)return{...Xe};let t={...Xe};for(let n in Xe){let r=Xe[n],o=e[n];r===null?(o===null||typeof o=="number")&&(t[n]=o):typeof o==typeof r&&(t[n]=o)}return t}function GH(){let e=Gr(Pn.chartSettings,null);return e===null?Xe:jH(e)}function jL(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]=(0,Fi.useState)(()=>{let M=e.modelSettings;return M&&JSON.stringify(M)!==JSON.stringify(Xe)?M:GH()}),C=(0,Fi.useRef)(null),w=(0,Fi.useRef)(Xe),k=(0,Fi.useCallback)(()=>{Sr(Pn.chartSettings,t.current)},[]);return(0,Fi.useEffect)(()=>()=>{C.current&&clearTimeout(C.current)},[]),(0,Fi.useEffect)(()=>{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&&Vr(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&&Vr(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}}var us=require("react");function GL(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=(0,us.useRef)(new Map),p=(0,us.useRef)(new Set),[g,y]=(0,us.useState)([]),v=(0,us.useRef)(new Map),b=(0,us.useCallback)((w,k)=>{if(o.current.some(x=>x.id===w.id))return;let M=w.require??"ohlcv",I=l.current;if(I&&!Bo(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=(0,us.useCallback)(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}}var zh=require("react");function YH(e){return 1-Math.pow(1-e,3)}var Fh=class{constructor(t=180){se(this,"durationMs",t);se(this,"tweens",new Map);se(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)*YH(r)}};var KH=1640/407,$H="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",sm=null,YL=!1;function XH(e){return YL?sm:(sm||typeof Image>"u"||(sm=new Image,sm.onload=()=>{YL=!0,e()},sm.src=$H),null)}var Tu=class{constructor(t,n,r,o,a=0){se(this,"baseCanvas");se(this,"drawingsCanvas");se(this,"uiCanvas");se(this,"eventBus");se(this,"chartId");se(this,"rafId",0);se(this,"dirty",{base:!0,drawings:!0,ui:!0});se(this,"beforeBaseDraw",new Set);se(this,"afterBaseDraw",new Set);se(this,"afterUIDraw",new Set);se(this,"drawParams",null);se(this,"view",null);se(this,"priceTransition",new Fh);se(this,"resizeObserver");se(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=$n(),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:kn),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),Bp(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=XH(()=>this.markDirty("base"));if(!a)return;let i=t.getContext("2d");if(!i)return;let s=$n(),l=n.main,c=l?l.x:0,u=l?l.y+l.h:r-(o?0:kn),d=10,m=170,f=m/KH,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||BC(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=tC(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=$n(),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 KL(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(0,zh.useEffect)(()=>{let R=n.current,P=r.current,D=o.current;if(!R||!P||!D)return;let N=new Tu(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:(0,zh.useCallback)(()=>{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:kn),B=0,E=0,L=D,H=A;if(d.current&&m.current){let K=m.current,G=Number(P.tMax-P.tMin),V=P.pMax-P.pMin;G>0&&(B=Number(K.tMin-P.tMin)/G*D,L=Number(K.tMax-K.tMin)/G*D),V>0&&(E=(P.pMax-K.pMax)/V*A,H=(K.pMax-K.pMin)/V*A)}f.current={x:B,y:E,h:H,w:L},Bp(R,h.current,N,p.current,c.current,g.current,[],P,y.current,d.current,B,E,L,H,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)},[])}}var Iu=require("react");function $L(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=(0,Iu.useCallback)(()=>{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=(0,Iu.useCallback)(()=>{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=(0,Iu.useCallback)((R=!1)=>{let P=t.current;P&&(R&&(r.current=!0,o(D=>({...D,autoScale:r.current}))),Vr(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=(0,Iu.useCallback)(()=>{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=(0,Iu.useCallback)(()=>{x(),I(!0)},[]);return{resetYAxis:I,resetXAxis:x,resetView:T,autofitPanesSilent:k,autofitIndicatorPanes:M}}var lm={symbol:!1,interval:!1,crosshair:!0,time:!1,dateRange:!1};var At=require("react/jsx-runtime"),ZH=(0,we.forwardRef)(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=(0,we.useRef)(null),H=(0,we.useRef)(null),K=(0,we.useRef)(null),G=(0,we.useRef)(null),V=(0,we.useRef)(null),q=(0,we.useRef)(null),j=(0,we.useRef)(null),W=(0,we.useRef)(null),$=(0,we.useRef)(null),J=(0,we.useRef)(null),me=(0,we.useRef)(null),We=(0,we.useRef)(null),Ce=(0,we.useRef)(null),Ee=(0,we.useRef)(null),ze=(0,we.useRef)(()=>{}),Ie=(0,we.useRef)(null),ee=(0,we.useRef)(new Mi).current,Be=()=>({seekHorizon:(re,Re)=>L.current?.(re,Re),handleTimeframeChange:(re,Re)=>H.current?.(re,Re),handleAddIndicator:re=>K.current?.(re),handleToggleIndicator:re=>G.current?.(re),handleRemoveIndicator:re=>V.current?.(re),setActiveTool:re=>q.current?.(re),getIndicators:()=>j.current?.()??[],getActiveTimeframe:()=>W.current?.(),getHorizon:()=>$.current?.()??0n,getVisibleRange:()=>Je.current?{tMin:Je.current.tMin,tMax:Je.current.tMax}:null,getDataBounds:()=>({start:tn.current,end:ut.current}),applySettings:re=>J.current?.(re),getChartSettings:()=>me.current?.()??Xe,getActiveTool:()=>hl.current,scheduleResample:()=>We.current?.(),scheduleBaseRedraw:()=>{Ye(),ve.current?.markDirty("base")},scheduleUIRedraw:()=>{Ye(),ve.current?.markDirty("ui")},redrawDrawings:()=>{Ye(),ve.current?.markDirty("drawings")},drawTradeLine:re=>Ce.current?.(re),activatePluginIndicator:(re,Re)=>Ee.current?.(re,Re),replacePluginIndicator:re=>Ie.current?.(re)});(0,we.useImperativeHandle)(E,Be,[]),(0,we.useEffect)(()=>{k?.(Be())},[]);let F=(0,we.useRef)(null),le=(0,we.useRef)(h);(0,we.useEffect)(()=>{le.current=h},[h]);let ce=(0,we.useRef)(null),ke=(0,we.useRef)(null),De=(0,we.useRef)(null),ve=(0,we.useRef)(null),Qe=(0,we.useRef)(!1);function Ye(){ee.setScaleMode(at.current.priceScaleMode==="normal"?"linear":at.current.priceScaleMode),Je.current&&(nt.current=Ap(Je.current,Le.current??void 0,at.current,o,ce.current?.getContext("2d")));let re=Kb(at.current.chartType,at.current,ot.current==="ohlcv"?dn.current.display:pn.current,Yt.current,wt.current,Vn.current.barNs);ee.setOrdinal(re?.columnTs??null);let Re=re!==null;if(Re&&!Qe.current&&re&&Je.current){let et=re.columnTs.length,It=Math.min(et,200);Je.current.tMin=ee.indexToTs(et-It),Je.current.tMax=ee.indexToTs(et-1+Math.min(It*.1,10)),ee.update(Je.current)}if(Qe.current=Re,re&&Rt.current&&Je.current){let et=uC(re,ee);if(et){let It=et.max-et.min||Math.abs(et.max)*.01||1,Wt=at.current.scaleMarginTop??.1,Ot=at.current.scaleMarginBottom??.1;Je.current.pMin=et.min-It*Ot,Je.current.pMax=et.max+It*Wt,ee.update(Je.current)}}ve.current?.setDrawParams({panes:qn.current,layouts:Fe.current,indicators:fe.current,trades:wt.current,priceHistory:Ht.current,footprintBars:ur.current,heatmapBitmap:fn.current,bitmapOffsets:Jn.current,barNs:Vn.current.barNs,chartSettings:at.current,horizon:ht.current,candleCache:Yt.current,openBar:zn.current,ohlcvBars:ot.current==="ohlcv"?dn.current.display:pn.current,crosshair:Tg.current,drawings:la.current,draft:Ew.current,tradeLines:td.current,hoveredDividerIdx:rt.current,hoveringLegend:xt.current,showTooltip:Kw.current,selectedTrade:Nw.current,activeTool:hl.current,draggingAnchor:Fw.current,isHoldingCtrl:Me.current,isHoldingShift:Pe.current,showShiftInfo:te.current,shiftInfoAnchor:dt.current,shiftInfoAnchor2:_t.current,tradeLineInteraction:Bg.current,selectedDrawingId:Q.current,hoveredDrawingId:Ow.current,hotAnchor:_w.current,editingTextId:Om.current,transformer:ee,sessionMapper:Ge.current,isPluginChartType:ed.current.has(at.current.chartType),chartPlugin:ed.current.get(at.current.chartType),pluginComputed:Aw.current.get(at.current.chartType),dataLevel:ot.current,accountSnapshot:De.current,symbolInfo:Le.current,priceScaleWidth:nt.current,hidePriceScale:o,hideTimeScale:a,syncCrosshair:$e.current}),Tt()}let $e=(0,we.useRef)(null),bt=(0,we.useRef)(null);function Oe(){bt.current&&(bt.current=null,w.emit("layout:crosshair",null))}function Tt(){if(!Lt.current.crosshair){Oe();return}let re=Tg.current,Re=ke.current;if(!re||!Re||!Je.current){Oe();return}let et=Fe.current,It=qn.current.find(Za=>{let ka=et[Za.id];return ka&&re.y>=ka.y&&re.y<ka.y+ka.h}),Wt=It?et[It.id]:null;if(!It||!Wt||Wt.h<2){Oe();return}let Ot=Re.width/$n()-nt.current;if(Ot<=0)return;if(re.x<0||re.x>=Ot){Oe();return}let dr=re.y-Wt.y,Rr={id:T,ts:ee.xToTs(re.x,Ot),price:It.isMain?ee.yToPrice(dr,Wt.h):0,paneId:It.id,yFrac:dr/Wt.h,symbol:sa.current??null},tr=bt.current;tr&&tr.ts===Rr.ts&&tr.price===Rr.price&&tr.paneId===Rr.paneId&&tr.yFrac===Rr.yFrac&&tr.symbol===Rr.symbol||(bt.current=Rr,w.emit("layout:crosshair",Rr))}function bn(re){let Re=re&&Lt.current.crosshair?re:null;if(!Re&&!$e.current||($e.current=Re,Ye(),ve.current?.markDirty("ui"),!Re||!Je.current))return;let et=performance.now();if(et-En.current<=33)return;En.current=et;let It=ke.current;if(!It)return;let Wt=It.width/$n()-nt.current;if(Wt<=0)return;let Ot=ee.tsToX(Re.ts,Wt);!Number.isFinite(Ot)||Ot<0||Ot>=Wt||w.emit("status:compute",{cellId:T,x:Ot,priceHistory:Ht.current,trades:wt.current,bounds:Je.current,chartW:Wt,barNs:Vn.current.barNs,candleCache:Yt.current,bars:dn.current.display,openBar:zn.current,horizon:ht.current,dataLevel:ot.current,transformer:ee})}let En=(0,we.useRef)(0),Lt=(0,we.useRef)(A??lm);(0,we.useEffect)(()=>{Lt.current=A??lm,Lt.current.crosshair||(Oe(),$e.current&&($e.current=null,X.current?.(),ve.current?.markDirty("ui")))},[A]);let it=(0,we.useRef)(!1),ft=(0,we.useRef)(null);function ie(){if(it.current)return;let re=Lt.current;if(!re.time&&!re.dateRange)return;let Re=Je.current;if(!Re)return;let et=ft.current;et&&et.tMin===Re.tMin&&et.tMax===Re.tMax||(ft.current={tMin:Re.tMin,tMax:Re.tMax},w.emit("layout:time-range",{id:T,tMin:Re.tMin,tMax:Re.tMax}))}function ge({tMin:re,tMax:Re}){let et=Je.current;if(!et)return;let It=Lt.current,Wt={tMin:re,tMax:Re};if(!It.dateRange){let dr=et.tMax-et.tMin;if(dr<=0n)return;Wt.tMin=Re-dr,Wt.tMax=Re}let Ot={...et,...Wt};if(sx(Ot),!(Ot.tMin===et.tMin&&Ot.tMax===et.tMax)){et.tMin=Ot.tMin,et.tMax=Ot.tMax,ft.current={tMin:et.tMin,tMax:et.tMax},it.current=!0;try{ix()}finally{it.current=!1}}}let pe=(0,we.useRef)(null),Le=(0,we.useRef)(null),Ue=(0,we.useRef)(null),Ge=(0,we.useRef)(Eh()),[Ve,Ne]=(0,we.useState)(!1),Se=(0,we.useRef)(!1);(0,we.useEffect)(()=>{Se.current=Ve},[Ve]);let[He,_e]=(0,we.useState)(""),dt=(0,we.useRef)(null),_t=(0,we.useRef)(null),te=(0,we.useRef)(!1),Me=(0,we.useRef)(!1),Pe=(0,we.useRef)(!1),at=(0,we.useRef)(Xe),nt=(0,we.useRef)(64),pt=(0,we.useRef)(0),[Xt,Ft]=(0,we.useState)(null),cr=(0,we.useRef)(null);(0,we.useEffect)(()=>{if(!Xt)return;let re=Re=>{cr.current&&!cr.current.contains(Re.target)&&Ft(null)};return window.addEventListener("mousedown",re),()=>window.removeEventListener("mousedown",re)},[Xt]);let[Mn,ir]=(0,we.useState)(x.timeframe),Vn=(0,we.useRef)(x.timeframe);(0,we.useEffect)(()=>{Vn.current=Mn,O.setTimeframe(Mn),yn.current.length>0&&(Yt.current=null,zn.current=null,Ur.current=0n,Kn.current=0,Eo(),Ye(),ve.current?.markDirty("base"),ve.current?.markDirty("drawings"),Vi(Q.current))},[Mn]);let[fr,_n]=(0,we.useState)([{id:"main",isMain:!0,heightRatio:3,symbol:R,tf:x.timeframe.label,exchange:void 0,yMin:0,yMax:0,yAxisAuto:!0,collapsed:!1}]),qn=(0,we.useRef)(fr);(0,we.useEffect)(()=>{qn.current=fr},[fr]);let[z,ae]=(0,we.useState)([]),fe=(0,we.useRef)(z);(0,we.useEffect)(()=>{fe.current=z},[z]),(0,we.useEffect)(()=>{O.setPlugins(z.map(re=>({id:re.id.replace(/:(\d+)$/,""),instanceId:re.id,config:{settings:re.settings??{},visible:re.visible,layout:re.layout,paneId:re.paneId}})))},[z,O]);let de=(0,we.useRef)(-1),U=(0,we.useRef)(null),be=(0,we.useRef)(null),[he,je]=(0,we.useState)(null),rt=(0,we.useRef)(-1),yt=(0,we.useRef)(!1),xt=(0,we.useRef)(!1),ht=(0,we.useRef)(0n),Je=(0,we.useRef)(null),Rt=(0,we.useRef)(!0),Jt=(0,we.useRef)(!1),rn=(0,we.useRef)("none"),Q=(0,we.useRef)(null),X=(0,we.useRef)(()=>{}),ye=(0,we.useRef)(()=>{}),Te=(0,we.useRef)(()=>{}),ct=(0,we.useRef)(()=>{}),vt=(0,we.useRef)(()=>{}),ue=(0,we.useRef)(()=>{}),{layoutsCacheRef:Fe,legendElemsRef:St,panePixelLayouts:Et,recomputeLayouts:Fn,getLayouts:Zt,syncPixelLayouts:Nt,applyLayoutsToDom:jt}=UL({baseCanvasRef:ce,panesRef:qn,chartSettingsRef:at,priceScaleWidthRef:nt,hideTimeScale:a}),zt=BL({eventBus:w,activeTimeframeRef:Vn,horizonRef:ht,chartSettingsRef:at,sessionMapperRef:Ge,resolvedSessionRef:pe,resolvedSymbolInfoRef:Le,viewRef:Je,priceScaleWidthRef:nt,panesRef:qn,indicatorsRef:fe,transformer:ee,renderEngineRef:ve,isYAxisAutoRef:Rt,isDragging:Jt,dragMode:rn,layoutsCacheRef:Fe,baseCanvasRef:ce,selectedDrawingIdRef:Q,pushDrawParamsRef:X,autofitIndicatorPanesRef:ye,updateSettingsBarPosRef:Te,resetViewRef:ct,syncPixelLayoutsRef:vt,doBaseRedrawRef:ue,setIndicators:ae,setPanes:_n,getPanel:()=>null,onDataBoundsChange:p,onHorizonUpdate:u,cellSymbol:R,cellId:T,managed:f,externalDomPanelRef:m,hidePriceScale:o,hideTimeScale:a,onDataLevelChangeRef:ze}),{compactBufRef:yn,tradesRef:wt,priceHistoryRef:Ht,allPriceHistoryRef:yr,footprintBarsRef:ur,ohlcvBarsRef:dn,previewBarsRef:pn,openBarRef:zn,openBarTsRef:Ur,openBarTradeCountRef:Kn,phCursorRef:Jr,dataLevelRef:ot,datasetStartRef:tn,datasetEndRef:ut,prevSessionStatusRef:mr,candleCacheRef:Yt,heatmapBitmapRef:fn,heatmapBitmapOffsetsRef:Jn,cacheBoundsRef:on,liveBookRef:mn,horizonScrollAnimRef:Vt,_internalDomPanelRef:Un,seekHorizon:jr,scheduleResample:Or,runIndicatorWorker:er,getTradesUpToHorizon:xr,requestFootprintRebuild:Eo,syncOhlcvOpenBar:_r,rebuildCandleCache:Uo,rebuildContrastBitmap:ws,updatePriceHistoryToRawIdx:hc,findPriceHistoryIdx:kg,loadData:mD}=zt;(0,we.useEffect)(()=>(w.emit("data:open-bar-provider",{cellId:T,get:()=>zn.current}),()=>{w.emit("data:open-bar-provider",{cellId:T,get:null})}),[w,T]);let pD=()=>m?.current??Un.current;X.current=Ye;let gc=(0,we.useRef)(null),{doBaseRedraw:hD}=KL({renderEngineRef:ve,baseCanvasRef:ce,drawingsCanvasRef:gc,uiCanvasRef:ke,eventBus:w,chartId:T,viewRef:Je,priceScaleWidthRef:nt,tradesRef:wt,getLayouts:Zt,heatmapBitmapRef:fn,cacheBoundsRef:on,heatmapBitmapOffsetsRef:Jn,panesRef:qn,indicatorsRef:fe,priceHistoryRef:Ht,footprintBarsRef:ur,activeTimeframeRef:Vn,chartSettingsRef:at,horizonRef:ht,candleCacheRef:Yt,openBarRef:zn,dataLevelRef:ot,ohlcvBarsRef:dn,previewBarsRef:pn,transformer:ee,hideTimeScale:a}),{pluginChartTypesRef:ed,activeChartTypeBottomBarIds:Dw,setPluginChartTypes:gD,pluginChartTypeComputedRef:Aw,activatePluginIndicator:bD,replacePluginIndicator:yD,buildChartTypeActiveCtx:Bw}=GL({renderEngineRef:ve,uiCanvasRef:ke,eventBus:w,indicatorsRef:fe,panesRef:qn,horizonRef:ht,activeTimeframeRef:Vn,dataLevelRef:ot,setPanes:_n,setIndicators:ae,runIndicatorWorker:er,getTradesUpToHorizon:xr,pushDrawParams:Ye}),Tg=(0,we.useRef)(null),vD=(0,we.useRef)({x:0,y:0}),wD=(0,we.useRef)(!1),Nw=(0,we.useRef)(null),Am=(0,we.useRef)(null),Bm=(0,we.useRef)(null),xs=(0,we.useRef)(null),sa=(0,we.useRef)(R),Nm=(0,we.useRef)(!1);sa.current!==R&&(Nm.current=!1),sa.current=R;let Ig=(0,we.useRef)(!1),Mg=(0,we.useRef)(null);Mg.current||(Mg.current={get current(){return N.forSymbol(sa.current)},set current(re){Ig.current=!0,N.setForSymbol(sa.current,re),Ig.current=!1}});let la=Mg.current;(0,we.useEffect)(()=>{let re=()=>{Ig.current||(X.current?.(),ve.current?.markDirty("drawings"))};return re(),N.subscribe(R,re)},[N,R]);let Ew=(0,we.useRef)(null),[Em,Lg]=(0,we.useState)(null),[bc,Rg]=(0,we.useState)(null),Om=(0,we.useRef)(null);(0,we.useEffect)(()=>{Om.current=bc,Ye(),ve.current?.markDirty("drawings")},[bc]);let Ow=(0,we.useRef)(null),_w=(0,we.useRef)(null),Fw=(0,we.useRef)(null),xD=(0,we.useRef)(null),SD=(0,we.useRef)(null),CD=(0,we.useRef)(null),kD=(0,we.useRef)(!0),td=(0,we.useRef)([]),zw=(0,we.useRef)({lines:[],pricePills:[],ghostPills:[]}),_m=(0,we.useRef)([]),yc=(0,we.useRef)([]),pl=(0,we.useCallback)(()=>{td.current=[...yc.current,..._m.current],Ye(),ve.current?.markDirty("ui")},[]),TD=(0,we.useCallback)(re=>td.current.find(Re=>Re.id===re),[]);(0,we.useEffect)(()=>{y!==void 0&&(yc.current=y,pl())},[y,pl]),(0,we.useEffect)(()=>w.on("trading:preview",({lines:re,symbol:Re})=>{Re&&Re!==sa.current||(_m.current=re,pl())}),[w,pl]);let[Fm,zm]=(0,we.useState)(Yo),hl=(0,we.useRef)(Yo);(0,we.useEffect)(()=>{B("activeTool",Fm)},[Fm]);let[Ci,Pg]=(0,we.useState)(null);(0,we.useEffect)(()=>{B("selectedDrawingId",Ci)},[Ci]);let[Dg,Ag]=(0,we.useState)(!1);(0,we.useEffect)(()=>{Dg&&Ag(!1)},[Dg]);let[ID,vc]=(0,we.useState)(null),[Hw,Vw]=(0,we.useState)(null),Vi=(0,we.useCallback)(re=>{if(!re){vc(null);return}let Re=la.current.find(Ot=>Ot.id===re),et=gc.current,It=Je.current;if(!Re||!et||!It){vc(null);return}let Wt=NC(Re,It,qn.current,et.width,et.height,ee,a,nt.current);vc(Ot=>Ot&&Wt&&Ot.x===Wt.x&&Ot.y===Wt.y?Ot:Wt)},[]);(0,we.useEffect)(()=>{hl.current=Fm},[Fm]),(0,we.useEffect)(()=>{Q.current=Ci,Vi(Ci)},[Ci]);let[ki,Ww]=(0,we.useState)("loading"),[qw,Uw]=(0,we.useState)(null);(0,we.useEffect)(()=>w.on("data:status",({status:Re,error:et,symbol:It})=>{It!==void 0&&It!==sa.current||(Re==="ready"&&It!==void 0&&(Nm.current=!0),!(Re==="loading"&&It!==void 0&&Nm.current)&&(Ww(Re),et&&Uw(et)))}),[]),(0,we.useEffect)(()=>[w.on("data:bounds",({start:Re,end:et,symbol:It})=>{It!==void 0&&It!==sa.current||(tn.current=Re,ut.current=et,p?.(Re,et))})].forEach(Re=>Re()),[]);let{chartSettings:Hm,setChartSettings:wc}=jL({chartSettingsRef:at,isYAxisAutoRef:Rt,viewRef:Je,priceHistoryRef:Ht,tradesRef:wt,dataLevelRef:ot,ohlcvBarsRef:dn,previewBarsRef:pn,openBarRef:zn,horizonRef:ht,compactBufRef:yn,selectedDrawingIdRef:Q,renderEngineRef:ve,scheduleResample:Or,rebuildContrastBitmap:ws,requestFootprintRebuild:Eo,pushDrawParams:Ye,updateSettingsBarPos:Vi,hidePriceScale:o,hideTimeScale:a,modelSettings:O.settings});(0,we.useEffect)(()=>{O.setSettings(Hm)},[Hm,O]);let{resetYAxis:jw,resetXAxis:Gw,resetView:Vm,autofitPanesSilent:Yw,autofitIndicatorPanes:Wm}=$L({viewRef:Je,transformer:ee,isYAxisAutoRef:Rt,setChartSettings:wc,priceHistoryRef:Ht,tradesRef:wt,previewBarsRef:pn,ohlcvBarsRef:dn,openBarRef:zn,chartSettingsRef:at,horizonRef:ht,dataLevelRef:ot,activeTimeframeRef:Vn,scheduleResample:Or,pushDrawParams:Ye,publishTimeRangeSync:ie,renderEngineRef:ve,updateSettingsBarPos:Vi,selectedDrawingIdRef:Q,panesRef:qn,indicatorsRef:fe,setPanes:_n});ct.current=Vm,ye.current=Wm;let Kw=(0,we.useRef)(!1),MD=(0,we.useRef)(null),$w=(0,we.useRef)(0),Xw=(0,we.useRef)(0),Zw=(0,we.useRef)(0),Qw=pL({tradeLines:td.current,resolveLine:TD,onLinesChange:re=>{yc.current=re.filter(Re=>!Re.preview),pl()},onSyncLines:re=>{yc.current=re.filter(Re=>!Re.preview),pl()},onLineDelete:re=>{yc.current=yc.current.filter(Re=>Re.id!==re.id),_m.current=_m.current.filter(Re=>Re.id!==re.id),pl()},hitMapRef:zw,chartWRef:$w,chartHRef:Xw,chartOYRef:Zw,getLayouts:Zt,boundsRef:Je,chartSettingsRef:at,redraw:()=>{C(),Ye(),ve.current?.markDirty("ui")},symbolInfoRef:Le,onGhostMove:v,linesRef:b,draggingLineIdRef:S,transformer:ee}),Bg=(0,we.useRef)(Qw);Bg.current=Qw,(0,we.useEffect)(()=>{ki==="ready"&&(Ye(),ve.current?.markDirty("base"),ve.current?.markDirty("drawings"),Vi(Q.current),Or())},[ki]),(0,we.useEffect)(()=>{Nt(),Ye(),ve.current?.markAllDirty()},[fr,ki]),(0,we.useEffect)(()=>{Ye(),ve.current?.markDirty("base"),ve.current?.markDirty("ui")},[z]);let{handleUpdateDrawing:LD,handleDeleteDrawing:Jw,handleDeleteDrawings:RD,handleDuplicateDrawing:PD,handleToggleIndicator:ex,handleRemoveIndicator:qm,handleOpenIndicatorSettings:DD,handleRemoveIndicators:AD,handleMoveUp:BD,handleMoveDown:ND,handleRemovePane:ED,handleExpand:OD,handleCollapse:_D,handleMaximize:FD,handleEnter:zD,handleLeave:HD,handleTimeframeChange:tx,handleAddIndicator:nx,handleAddTradeLine:VD}=VL({drawingsRef:la,drawingsCanvasRef:gc,viewRef:Je,selectedDrawingIdRef:Q,indicatorsRef:fe,panesRef:qn,ohlcvBarsRef:dn,sessionMapperRef:Ge,activeTimeframeRef:Vn,horizonRef:ht,phCursorRef:Jr,candleCacheRef:Yt,tradesRef:wt,openBarRef:zn,openBarTsRef:Ur,openBarTradeCountRef:Kn,compactBufRef:yn,isYAxisAutoRef:Rt,priceHistoryRef:Ht,dataLevelRef:ot,previewBarsRef:pn,chartSettingsRef:at,tradeLinesRef:td,hoveringLegend:xt,renderEngineRef:ve,transformer:ee,maximizedPaneId:he,setIndicators:ae,setPanes:_n,setSelectedDrawingId:Pg,setSettingsBarPos:vc,setIndicatorSettingsId:Vw,setActiveTimeframe:ir,setMaximizedPaneId:je,pushDrawParams:Ye,updateSettingsBarPos:Vi,recomputeLayouts:Fn,scheduleResample:Or,runIndicatorWorker:er,getTradesUpToHorizon:xr,getLayouts:Zt,rebuildCandleCache:Uo,syncOhlcvOpenBar:_r,updatePriceHistoryToRawIdx:hc,findPriceHistoryIdx:kg,resetXAxis:Gw,resetYAxis:jw,autofitIndicatorPanes:Wm,hideTimeScale:a,priceScaleWidthRef:nt});qL({eventBus:w,chartId:T,account:D,pluginChartTypesRef:ed,activeChartTypeBottomBarIds:Dw,hitMapRef:zw,indicatorsRef:fe,panesRef:qn,renderEngineRef:ve,horizonRef:ht,activeTimeframeRef:Vn,chartSettingsRef:at,pluginChartTypeComputedRef:Aw,dataLevelRef:ot,previewBarsRef:pn,candleCacheRef:Yt,ohlcvBarsRef:dn,openBarRef:zn,viewRef:Je,accountSnapRef:De,setActiveTool:zm,setActiveTimeframe:ir,handleTimeframeChange:tx,setPanes:_n,setIndicators:ae,setPluginChartTypes:gD,setChartSettings:wc,resetView:Vm,buildChartTypeActiveCtx:Bw,pushDrawParams:Ye,runIndicatorWorker:er,getTradesUpToHorizon:xr,syncPixelLayouts:Nt,autofitIndicatorPanes:Wm,handleAddIndicator:nx,handleRemoveIndicator:qm,onSymbolChange:re=>{re!==sa.current&&(Nm.current=!1),R=re,sa.current=re,X.current?.(),ve.current?.markDirty("drawings")},syncInLayoutRef:Lt,applyCrosshairSync:bn,applyTimeRangeSync:ge}),HL({status:ki,cellId:T,baseCanvasRef:ce,uiCanvasRef:ke,chartAreaRef:Am,containerRef:F,viewRef:Je,priceScaleWidthRef:nt,symbolInfoRef:Le,layoutsCacheRef:Fe,isYAxisAutoRef:Rt,drawingsRef:la,draftRef:Ew,selectedDrawingIdRef:Q,hoveredDrawingIdRef:Ow,hotAnchorRef:_w,draggingAnchorRef:Fw,dragStartRef:xD,dragPrevDataRef:SD,dragPrevPixelRef:CD,fvpLiveRecalcRef:kD,activeCtxRef:Ue,panesRef:qn,indicatorsRef:fe,draggingDividerRef:de,dragPaneIdRef:U,hoveredDividerIdxRef:rt,hoveredDividerIdxRefLocked:yt,hoveredPaneIdRef:be,activeToolRef:hl,chartSettingsRef:at,activeTimeframeRef:Vn,sessionMapperRef:Ge,resolvedSessionRef:pe,renderEngineRef:ve,pluginChartTypesRef:ed,activeChartTypeBottomBarIds:Dw,crosshairRef:Tg,isDragging:Jt,dragMode:rn,isHoldingCtrlRef:Me,isHoldingShiftRef:Pe,lastMouse:vD,hasDragged:wD,longPressTimer:MD,showTooltipRef:Kw,shiftAnchorRef:dt,shiftAnchor2Ref:_t,showShiftInfo:te,lastStatusLineUpdateRef:pt,horizonRef:ht,tradesRef:wt,priceHistoryRef:Ht,allPriceHistoryRef:yr,ohlcvBarsRef:dn,previewBarsRef:pn,dataLevelRef:ot,openBarRef:zn,candleCacheRef:Yt,footprintBarsRef:ur,datasetStartRef:tn,datasetEndRef:ut,horizonScrollAnimRef:Vt,liveBookRef:mn,tradeLineInteractionRef:Bg,selectedTradeRef:Nw,transformer:ee,eventBus:w,features:P,showTimeframeWindowRef:Se,setActiveTool:zm,setSelectedDrawingId:Pg,setSettingsBarPos:vc,setContextMenu:Ft,setPanes:_n,setChartSettings:wc,setEditingTextId:Rg,setOpenSettingsDialog:Ag,setShowTimeframeWindow:Ne,setTimeframeWindowInput:_e,setPendingText:Lg,pushDrawParams:Ye,publishTimeRangeSync:ie,scheduleResample:Or,runIndicatorWorker:er,getTradesUpToHorizon:xr,updateSettingsBarPos:Vi,handleDeleteDrawing:Jw,autofitPanesSilent:Yw,autofitIndicatorPanes:Wm,getPanel:pD,getLayouts:Zt,recomputeLayouts:Fn,syncPixelLayouts:Nt,applyLayoutsToDom:jt,buildChartTypeActiveCtx:Bw,hideTimeScale:a}),(0,we.useEffect)(()=>{if(R)return w.emit("data:pane-resolution",{id:T,symbol:R,barNs:Mn.barNs}),()=>{w.emit("data:pane-resolution",{id:T,symbol:R,barNs:0n})}},[w,T,R,Mn]),(0,we.useEffect)(()=>w.on("view:change",()=>{let re=ke.current,Re=Zt();re&&($w.current=re.width-nt.current,Xw.current=Re.main?.h??re.height-(a?0:kn),Zw.current=Re.main?.y??0,Fn(),Nt(),Ye(),ve.current?.markAllDirty())}),[w]),(0,we.useEffect)(()=>{let re=Am.current;if(ki!=="ready"||!re)return;let Re=100,et=Wt=>{let Ot=Bm.current;if(!Ot)return;let dr=Ot.getBoundingClientRect(),Rr=Math.max(dr.left-Wt.clientX,0,Wt.clientX-dr.right),tr=Math.max(dr.top-Wt.clientY,0,Wt.clientY-dr.bottom);Ot.style.opacity=Math.hypot(Rr,tr)<Re?"1":"0"},It=()=>{Bm.current&&(Bm.current.style.opacity="0")};return re.addEventListener("mousemove",et),re.addEventListener("mouseleave",It),()=>{re.removeEventListener("mousemove",et),re.removeEventListener("mouseleave",It)}},[ki]),(0,we.useEffect)(()=>()=>{xs.current!==null&&cancelAnimationFrame(xs.current)},[]),L.current=(re,Re)=>jr(re,!0,!0,Re);let rx=(re,Re=!1)=>{let et=P?.timeframe?.timeframes??"any";if(et!=="any"&&!et.includes(re.label)){w?.emit("timeframe:add-failed",{message:"Timeframe not allowed",code:"TIMEFRAME_NOT_ALLOWED",label:re.label});return}tx(re),Re||w?.emit("layout:timeframe",{id:T,tf:re})};H.current=rx,K.current=nx,G.current=ex,V.current=qm,q.current=re=>{let Re=bo.get(hl.current.name);Re?.onDeactivate&&Re.onDeactivate(),zm(re),hl.current=re;let et=bo.get(re.name);et?.onActivate&&et.onActivate(Ue.current)},j.current=()=>fe.current,W.current=()=>Vn.current,$.current=()=>ht.current;let ox=re=>{let Re=ed.current.get(re);if(!Re)return!1;let et=Re.require??"ohlcv",It=ot.current;return!It||Bo(et,It)?!1:(w?.emit("plugin:incompatible",{id:re,name:Re.label??Re.name,kind:"chart-type",required:et,actual:It}),!0)};J.current=re=>{if(re.chartType&&ox(re.chartType)){let{chartType:Re,...et}=re;re=et}wc(Re=>({...Re,...re}))},ze.current=()=>{let re=ot.current;if(re){for(let Re of[...fe.current]){let et=Re.require??"ohlcv";Bo(et,re)||(w?.emit("plugin:incompatible",{id:Re.id,name:Re.name,kind:"indicator",required:et,actual:re}),qm(Re.id))}ox(at.current.chartType)&&wc(Re=>({...Re,chartType:"candles"}))}},me.current=()=>at.current,We.current=Or,Ce.current=VD,Ee.current=bD,Ie.current=yD;let ax=null;ki==="error"&&(ax=(0,At.jsx)(RL,{code:qw?.code??"unknown",message:qw?.message,symbol:Le.current?.longName??sa.current,timeframe:Mn?.label,onRetry:()=>{Uw(null),Ww("loading"),mD()}})),Te.current=Vi,vt.current=Nt,ue.current=hD;let ix=()=>{let re=Je.current;re&&(Rt.current&&Vr(re,Ht.current,wt.current,ot.current==="ohlcv"?dn.current.display:pn.current,zn.current,at.current,ht.current,ot.current),Yw(),re.tMin<tn.current&&w.emit("data:request-backward",{viewMin:re.tMin,symbol:sa.current}),Or(),Ye(),ie(),ve.current?.markDirty("base"),ve.current?.markDirty("drawings"),ve.current?.markDirty("ui"),Vi(Q.current))},sx=re=>{let Re=tn.current+Vn.current.barNs/2n,et=ut.current;if(Re===0n||et===0n)return;let It=re.tMax-re.tMin,Wt=ht.current,Ot=Wt>0n&&Wt<et?Wt-Vn.current.barNs*3n/2n:et-Vn.current.barNs*3n/2n;re.tMin+It<Re&&(re.tMin=Re-It,re.tMax=Re),re.tMin>Ot&&(re.tMin=Ot,re.tMax=Ot+It)},Ng=(re,Re,et=220)=>{let It=Je.current;if(!It)return;xs.current!==null&&cancelAnimationFrame(xs.current);let Wt=It.tMin,Ot=It.tMax,dr=Number(re-Wt),Rr=Number(Re-Ot),tr=performance.now(),Za=ka=>{let Ss=Je.current;if(!Ss){xs.current=null;return}let Qa=Math.min(1,(ka-tr)/et),jo=uv(Qa,"easeOut");Ss.tMin=Wt+BigInt(Math.round(dr*jo)),Ss.tMax=Ot+BigInt(Math.round(Rr*jo)),ix(),Qa<1?xs.current=requestAnimationFrame(Za):xs.current=null};xs.current=requestAnimationFrame(Za)},lx=re=>{let Re=Je.current;if(!Re)return;let et=Vn.current.barNs,It=et>0n?Number(et*3n):Number(cp),Wt=et>0n?Number(et*3400n):Number(up),Ot=ee.getSessionMapper();if(Ot&&Ot.hasSession){let dr=Ot.tsToMarket(Re.tMin),Rr=Ot.tsToMarket(Re.tMax),tr=Math.max(It,Math.min(Wt,Number(Rr-dr)*re));Ng(Ot.marketToTs(Rr-BigInt(Math.round(tr))),Re.tMax)}else{let dr=Math.max(It,Math.min(Wt,Number(Re.tMax-Re.tMin)*re));Ng(Re.tMax-BigInt(Math.round(dr)),Re.tMax)}},cx=re=>{let Re=Je.current;if(!Re)return;let et=.25,It,Wt,Ot=ee.getSessionMapper();if(Ot&&Ot.hasSession){let Rr=Ot.tsToMarket(Re.tMin),tr=Ot.tsToMarket(Re.tMax),Za=BigInt(Math.round(re*et*Number(tr-Rr)));It=Ot.marketToTs(Rr+Za),Wt=Ot.marketToTs(tr+Za)}else{let Rr=BigInt(Math.round(re*et*Number(Re.tMax-Re.tMin)));It=Re.tMin+Rr,Wt=Re.tMax+Rr}let dr={...Re,tMin:It,tMax:Wt};sx(dr),Ng(dr.tMin,dr.tMax)};return(0,At.jsxs)("div",{className:"depth-root relative w-full h-full flex flex-col bg-background text-foreground overflow-hidden max-h-screen",ref:F,tabIndex:0,children:[ax,ki==="loading"&&(0,At.jsx)(LL,{symbol:Le.current?.longName??sa.current,timeframe:Mn?.label}),(0,At.jsx)("div",{className:"flex flex-1 min-h-0",children:(0,At.jsxs)("div",{ref:Am,className:"relative flex-1 min-h-0",children:[(0,At.jsx)("canvas",{ref:ce,className:"absolute inset-0 w-full h-full block touch-none"}),(0,At.jsx)("canvas",{ref:gc,className:"absolute inset-0 w-full h-full block touch-none pointer-events-none"}),(0,At.jsx)("canvas",{ref:ke,className:"absolute inset-0 w-full h-full block touch-none pointer-events-none"}),ki==="ready"&&(0,At.jsxs)("div",{ref:Bm,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:[(0,At.jsxs)("div",{className:"flex gap-1",children:[(0,At.jsxs)(Gt,{delayDuration:700,children:[(0,At.jsx)(qt,{asChild:!0,children:(0,At.jsx)(br,{variant:"ghost",className:"p-1 h-6 pointer-events-auto",onClick:()=>lx(1.25),children:(0,At.jsx)(Jo,{className:"!w-3.5"})})}),(0,At.jsx)(Ut,{className:"border border-border bg-background",children:"Zoom out"})]}),(0,At.jsxs)(Gt,{delayDuration:700,children:[(0,At.jsx)(qt,{asChild:!0,children:(0,At.jsx)(br,{variant:"ghost",className:"p-1 h-6 pointer-events-auto",onClick:()=>lx(.8),children:(0,At.jsx)(pa,{className:"!w-3.5"})})}),(0,At.jsx)(Ut,{className:"border border-border bg-background",children:"Zoom in"})]})]}),(0,At.jsxs)("div",{className:"flex gap-1",children:[(0,At.jsxs)(Gt,{delayDuration:700,children:[(0,At.jsx)(qt,{asChild:!0,children:(0,At.jsx)(br,{variant:"ghost",className:"p-1 h-6 pointer-events-auto",onClick:()=>cx(-1),children:(0,At.jsx)(Ll,{className:"!w-3.5"})})}),(0,At.jsx)(Ut,{className:"border border-border bg-background",children:"Pan left"})]}),(0,At.jsxs)(Gt,{delayDuration:700,children:[(0,At.jsx)(qt,{asChild:!0,children:(0,At.jsx)(br,{variant:"ghost",className:"p-1 h-6 pointer-events-auto",onClick:()=>cx(1),children:(0,At.jsx)(Yi,{className:"!w-3.5"})})}),(0,At.jsx)(Ut,{className:"border border-border bg-background",children:"Pan right"})]})]}),(0,At.jsx)("div",{className:"flex gap-1",children:(0,At.jsxs)(Gt,{delayDuration:700,children:[(0,At.jsx)(qt,{asChild:!0,children:(0,At.jsx)(br,{variant:"ghost",className:"p-1 h-6 pointer-events-auto",onClick:()=>Vm(),children:(0,At.jsx)(ha,{className:"!w-3.5"})})}),(0,At.jsx)(Ut,{className:"border border-border bg-background",children:"Reset view"})]})})]}),Ci&&ID&&(()=>{let re=la.current.find(Re=>Re.id===Ci);return re?(0,At.jsx)(At.Fragment,{children:(0,At.jsx)(uL,{drawing:re,containerRef:Am,openDialog:Dg,onUpdate:Re=>LD(Ci,Re),onDelete:()=>Jw(Ci),onDuplicate:()=>PD(Ci),onClose:()=>{Pg(null),vc(null),Q.current=null,Ag(!1),Ye(),ve.current?.markDirty("drawings")},onRequestOrderTicket:w.hasListeners("trading:ticket-requested")?Re=>w.emit("trading:ticket-requested",{drawingId:Re,requestId:vn(8)}):void 0})}):null})(),ki==="ready"&&fr.map((re,Re)=>{let et=Et[re.id];if(!et)return null;let It=re.isMain&&!i?(0,At.jsx)(bL,{cellId:T,chartSettings:Hm,chartType:Hm.chartType,eventBus:w}):null;return(0,At.jsx)("div",{ref:Wt=>{Wt?St.current.set(re.id,Wt):St.current.delete(re.id)},className:"absolute left-0 pointer-events-none",style:{top:et.y,height:et.h,right:`${nt.current}px`,visibility:et.h<2?"hidden":"visible"},children:(0,At.jsxs)("div",{className:"flex flex-row items-center justify-between w-full",children:[(0,At.jsx)("div",{className:"flex flex-row items-center gap-1 flex-1 min-w-0",children:s?It:(0,At.jsx)(SL,{pane:re,indicators:z,onToggleIndicator:ex,onRemoveIndicator:qm,onOpenSettings:DD,onOpenTfSelect:()=>{_e(""),Ne(!0)},eventBus:w,session:pe.current,horizon:ht.current,sessionStatus:mr.current,statusBar:It,symbolInfo:Le.current})}),(0,At.jsx)(CL,{pane:re,paneIndex:Re,totalPanes:fr.length,onMoveUp:BD,onMoveDown:ND,onRemovePane:ED,onCollapse:_D,onExpand:OD,onMaximize:FD,isMaximized:he===re.id,isCollapsed:re.collapsed,onEnter:zD,onLeave:HD,eventBus:w})]})},re.id)}),Xt&&P.contextMenu&&(0,At.jsx)(CC,{x:Xt.x,y:Xt.y,target:Xt.target,priceAtClick:(()=>{let re=po(Le.current);return Math.round(Xt.priceAtClick/re)*re})(),tickSize:po(Le.current),currentAsk:(()=>{if(ot.current==="l3"){let re=Uc(Ht.current,ht.current);return re>=0?Ht.current[re].bestAsk:0}else if(ot.current==="ohlcv")return zn.current?zn.current.close:0})(),currentBid:(()=>{if(ot.current==="l3"){let re=Uc(Ht.current,ht.current);return re>=0?Ht.current[re].bestBid:0}else if(ot.current==="ohlcv")return zn.current?zn.current.close:0})(),drawings:la.current,indicators:fe.current,chartSettings:at.current,dataLevel:ot.current,onClose:()=>{Ft(null)},onResetView:Vm,onFitYAxis:jw,onResetXAxis:Gw,onRemoveIndicators:AD,onRemoveDrawings:RD,onScreenshot:()=>{let re=ce.current,Re=ke.current,et=gc.current;if(!re||!Re||!et)return;let It=document.createElement("canvas");It.width=re.width,It.height=re.height;let Wt=It.getContext("2d");if(!Wt)return;Wt.drawImage(re,0,0),Wt.drawImage(et,0,0),Wt.drawImage(Re,0,0);let Ot=document.createElement("a");Ot.download="chart.png",Ot.href=It.toDataURL(),Ot.click(),Ft(null)},onToggleHeatmap:()=>{wc(re=>({...re,showHeatmap:!re.showHeatmap}))},onOpenSettings:()=>c(),onCreateOrder:g}),Hw&&(()=>{let re=fe.current.find(Re=>Re.id===Hw);return re?(0,At.jsx)(gL,{indicator:re,redrawDebounceMs:50,onUpdate:Re=>{Object.assign(re.settings,Re);let et=re.__paramKeys??new Set,It=re.__onParamsChanged;if(It){let Wt={},Ot=!1;for(let dr of Object.keys(Re))et.has(dr)&&(Wt[dr]=Re[dr],Ot=!0);Ot&&It(Wt)}Ye(),ve.current?.markDirty("base")},onClose:()=>Vw(null)}):null})(),I&&(0,At.jsx)(ML,{eventBus:w,symbol:R,priceScaleWidth:nt.current}),(0,At.jsx)(IL,{eventBus:w,cellId:T}),Em&&(0,At.jsx)(XL,{x:Em.x,y:Em.y,fontSize:12,color:"#e0e0e0",initialValue:"",onCommit:re=>{if(re.trim()){let Re={id:vn(),tool:"text",anchor:Em.anchor,text:re.trim(),...Ui("text")};la.current=[...la.current,Re],Ye(),ve.current?.markDirty("drawings")}Lg(null),zm(Yo),hl.current=Yo},onCancel:()=>Lg(null)}),bc&&(()=>{let re=la.current.find(Qa=>Qa.id===bc);if(!re||re.tool!=="text"||"anchors"in re)return null;let Re=gc.current,et=$n(),It=Re.width/et,Wt=Re.height/et;if(!Re)return null;let dr=Zt().main,Rr=dr?.h??Wt-(a?0:kn),tr=dr?.y??0,Za=It-nt.current,ka=ee.tsToX(re.anchor.ts,Za),Ss=ee.priceToY(re.anchor.price,Rr)+tr;return(0,At.jsx)(XL,{x:ka+4,y:Ss-re.fontSize-2,fontSize:re.fontSize,color:re.color,initialValue:re.text,onKeyStroke:Qa=>{la.current=la.current.map(jo=>jo.id===bc?{...jo,text:Qa}:jo)},onCommit:Qa=>{la.current=la.current.map(jo=>jo.id===bc?{...jo,text:Qa.trim()||jo.text}:jo),Rg(null),Om.current=null},onCancel:()=>{Rg(null),Om.current=null}})})()]})}),Ve&&(0,At.jsx)("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:(0,At.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-lg shadow-black/30 p-5 w-64 flex flex-col gap-3",children:[(0,At.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,At.jsx)("div",{className:"text-[13px] font-semibold text-white/90",children:"Set timeframe"}),(0,At.jsx)("div",{className:"text-[11px] text-muted-foreground",children:"Digits, then a unit: s m h d w"})]}),(0,At.jsx)(Qs,{autoFocus:!0,value:He,placeholder:"e.g. 15m",className:"text-center text-base font-mono h-11 tracking-[0.2em]",onChange:()=>{},onKeyDown:re=>{re.stopPropagation();let Re=["s","m","h","d"],et=re.key,It=He,Wt=Re.some(tr=>It.includes(tr)),Ot=It.slice(-1),dr=et>="0"&&et<="9",Rr=Re.includes(et.toLowerCase());if(et==="Escape")re.preventDefault(),Ne(!1),_e("");else if(et==="Backspace")re.preventDefault(),re.ctrlKey?_e(""):_e(tr=>tr.slice(0,-1));else if(et==="Enter"){re.preventDefault();let tr=It.trim().toLowerCase();if(!tr)return;let Za=(WD,qD)=>{let UD={none:1000000n,ms:1000000n,s:1000000000n,m:60000000000n,h:3600000000000n,d:86400000000000n,w:604800000000000n};return BigInt(WD)*UD[qD]},ka=tr.charAt(tr.length-1),Ss=ka>="0"&&ka<="9",Qa=Ss?"m":ka,jo=Number(Ss?tr:tr.slice(0,-1));jo>0&&rx({label:jo+Qa,barNs:Za(jo,Qa),defaultBars:300,isPreset:!1}),Ne(!1),_e("")}else dr&&!Wt?(re.preventDefault(),_e(tr=>tr+et)):Rr&&!Wt&&Ot>="0"&&Ot<="9"?(re.preventDefault(),_e(tr=>tr+et.toLowerCase())):re.preventDefault()}}),(0,At.jsx)("div",{className:"text-xs text-muted-foreground text-center",children:"Enter to confirm \xB7 Esc to cancel"})]})})]})}),ZL=ZH;function XL({x:e,y:t,initialValue:n="",fontSize:r=12,color:o="#e0e0e0",onKeyStroke:a,onCommit:i,onCancel:s}){let l=(0,we.useRef)(null);return(0,we.useEffect)(()=>{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)},[]),(0,At.jsx)("div",{className:"absolute",style:{left:e,top:t},onMouseDown:c=>c.stopPropagation(),children:(0,At.jsx)("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)}})})}var Er=require("react");var Mt=require("react/jsx-runtime"),gv={volume:{label:"Volume",icon:(0,Mt.jsx)(Li,{size:11}),dot:"bg-blue-400",text:"text-blue-400"},orderflow:{label:"Order Flow",icon:(0,Mt.jsx)(Ld,{size:11}),dot:"bg-emerald-400",text:"text-emerald-400"},momentum:{label:"Momentum",icon:(0,Mt.jsx)(Jd,{size:11}),dot:"bg-violet-400",text:"text-violet-400"},trend:{label:"Trend",icon:(0,Mt.jsx)(Ol,{size:11}),dot:"bg-amber-400",text:"text-amber-400"},volatility:{label:"Volatility",icon:(0,Mt.jsx)(Sf,{size:11}),dot:"bg-orange-400",text:"text-orange-400"},experimental:{label:"Experimental",icon:(0,Mt.jsx)(Qd,{size:11}),dot:"bg-pink-400",text:"text-pink-400"},other:{label:"Other",icon:(0,Mt.jsx)(Rl,{size:11}),dot:"bg-slate-500",text:"text-slate-400"}},yv=["volume","orderflow","momentum","trend","volatility","experimental","other"];function QH(e){return e.indicator.id.startsWith("builtin:")||e.indicator.id.startsWith("builtin-")}function QL(e){let t=e.indicator.category?.trim().toLowerCase()??"";if(!t)return"other";let n=yv.filter(r=>r!=="other");return n.find(r=>r===t)??n.find(r=>t.includes(r))??"other"}function JH(e,t){return e.name.toLowerCase().includes(t)||(e.shortName??"").toLowerCase().includes(t)||(e.description??"").toLowerCase().includes(t)}function e6(e,t){let n=e.require??"ohlcv";if(!Bo(n,t))return ol(n,t)}function bv({children:e,cyan:t}){return(0,Mt.jsx)("span",{className:ne("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 Hh({icon:e,label:t,count:n,active:r,onClick:o}){return(0,Mt.jsxs)("button",{onClick:o,className:ne("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:[(0,Mt.jsx)("span",{className:ne("shrink-0",r?"text-[#08b3de]":"text-slate-500"),children:e}),t,(0,Mt.jsx)("span",{className:ne("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 t6({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(0,Mt.jsxs)("div",{ref:c,onMouseEnter:l,onClick:()=>{t||a()},title:o,className:ne("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&&(0,Mt.jsx)("span",{className:"absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-[#08b3de]"}),(0,Mt.jsx)("span",{className:ne("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}),(0,Mt.jsx)("span",{className:"text-[11px] text-slate-600 truncate flex-1 group-hover:text-slate-500",children:u.description??(e.isCustom?"Installed via plugin":"")}),o&&(0,Mt.jsxs)(bv,{children:[(0,Mt.jsx)(no,{size:8,className:"inline mb-px mr-1"}),ku[e.def.indicator.require??"ohlcv"]]}),e.isCustom&&(0,Mt.jsx)(bv,{cyan:!0,children:"custom"}),d&&(0,Mt.jsx)(bv,{children:"pane"}),(0,Mt.jsx)("div",{className:"w-[3.25rem] flex items-center justify-end gap-0.5 shrink-0",children:t?(0,Mt.jsxs)(Mt.Fragment,{children:[(0,Mt.jsx)("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?(0,Mt.jsx)(Da,{size:13}):(0,Mt.jsx)(Ri,{size:13})}),(0,Mt.jsx)("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:(0,Mt.jsx)(Mo,{size:13})})]}):(0,Mt.jsx)("span",{className:ne("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":(0,Mt.jsxs)(Mt.Fragment,{children:[(0,Mt.jsx)(pa,{size:12}),"Add"]})})})]})}function n6({icon:e,label:t,count:n}){return(0,Mt.jsx)("div",{className:"flex items-center gap-1.5 px-3 pt-2.5 pb-1 sticky top-0 bg-[#16181d] z-[1]",children:(0,Mt.jsx)("span",{className:"text-[9px] font-semibold text-slate-500 uppercase tracking-widest",children:t})})}function JL({indicators:e,dataLevel:t,onAdd:n,onToggle:r,onRemove:o,onOpenChange:a,pluginIndicators:i=[],onActivatePlugin:s}){let[l,c]=(0,Er.useState)(!1),[u,d]=(0,Er.useState)(""),[m,f]=(0,Er.useState)("all"),[h,p]=(0,Er.useState)(0),g=(0,Er.useRef)(null),y=(0,Er.useRef)(null),v=(0,Er.useRef)(null),b=(0,Er.useRef)(null),S=A=>{c(B=>{let E=typeof A=="function"?A(B):A;return a?.(E),E})},C=(0,Er.useMemo)(()=>new Set(e.map(A=>A.id)),[e]),w=u.trim().toLowerCase(),{builtins:k,customs:M}=(0,Er.useMemo)(()=>{let A=[],B=[];for(let E of i)w&&!JH(E.indicator,w)||(QH(E)?A:B).push(E);return{builtins:A,customs:B}},[i,w]),I=(0,Er.useMemo)(()=>{let A=new Map;for(let B of k){let E=QL(B);A.set(E,(A.get(E)??0)+1)}return A},[k]),x=(0,Er.useMemo)(()=>[...k,...M].filter(A=>C.has(A.indicator.id)).length,[k,M,C]),T=(0,Er.useMemo)(()=>{let A=[],B=m==="active",E=H=>{for(let K of k)QL(K)===H&&(B&&!C.has(K.indicator.id)||A.push({def:K,isCustom:!1,category:H,section:H}))},L=()=>{for(let H of M)B&&!C.has(H.indicator.id)||A.push({def:H,isCustom:!0,category:"other",section:"custom"})};if(m==="custom")L();else if(m==="all"||m==="active"){for(let H of yv)E(H);L()}else E(m);return A},[k,M,m,C]);(0,Er.useEffect)(()=>{p(A=>T.length===0?0:Math.min(A,T.length-1))},[T.length]),(0,Er.useLayoutEffect)(()=>{b.current?.scrollIntoView({block:"nearest"})},[h,T]);let R=A=>{C.has(A.def.indicator.id)?r(A.def.indicator.id):s?.(A.def)};(0,Er.useEffect)(()=>{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(H=>P.current.length?(H+1)%P.current.length:0);else if(L.key==="ArrowUp")L.preventDefault(),p(H=>P.current.length?(H-1+P.current.length)%P.current.length:0);else if(L.key==="Enter"){let H=P.current[D.current];H&&(L.preventDefault(),R(H))}};return document.addEventListener("mousedown",B),document.addEventListener("keydown",E),()=>{clearTimeout(A),document.removeEventListener("mousedown",B),document.removeEventListener("keydown",E)}},[l]);let P=(0,Er.useRef)(T),D=(0,Er.useRef)(h);P.current=T,D.current=h;let N=k.length+M.length,O=null;return(0,Mt.jsxs)("div",{className:"relative",ref:g,children:[(0,Mt.jsxs)("button",{onClick:()=>S(A=>!A),className:ne("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:[(0,Mt.jsx)(qd,{className:"w-4 h-4"}),(0,Mt.jsx)("span",{className:"mt-px",children:"Indicators"}),(0,Mt.jsx)(or,{size:10,className:ne("opacity-50 transition-transform duration-150",l&&"rotate-180")})]}),l&&(0,Mt.jsxs)("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:[(0,Mt.jsxs)("div",{className:"flex items-center gap-2.5 px-3 h-11 border-b border-[#1e2128] shrink-0",children:[(0,Mt.jsx)(li,{size:14,className:"text-slate-600 shrink-0"}),(0,Mt.jsx)("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"})]}),(0,Mt.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-[#1e2128] shrink-0 overflow-x-auto no-scrollbar",children:[(0,Mt.jsx)(Hh,{icon:(0,Mt.jsx)(tf,{size:11}),label:"All",count:N,active:m==="all",onClick:()=>f("all")}),x>0&&(0,Mt.jsx)(Hh,{icon:(0,Mt.jsx)(Da,{size:11}),label:"On chart",count:x,active:m==="active",onClick:()=>f("active")}),yv.filter(A=>(I.get(A)??0)>0).map(A=>{let B=gv[A];return(0,Mt.jsx)(Hh,{icon:B.icon,label:B.label,count:I.get(A)??0,active:m===A,onClick:()=>f(A)},A)}),M.length>0&&(0,Mt.jsx)(Hh,{icon:(0,Mt.jsx)(ea,{size:11}),label:"Custom",count:M.length,active:m==="custom",onClick:()=>f("custom")})]}),(0,Mt.jsx)("div",{ref:v,className:"flex-1 min-h-0 overflow-y-auto py-1",children:T.length===0?(0,Mt.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-1.5 text-slate-600",children:[(0,Mt.jsx)(Vs,{size:20,className:"text-slate-700"}),(0,Mt.jsx)("div",{className:"text-[12px] text-slate-500",children:w?"No indicators match":"Nothing here"}),w&&(0,Mt.jsxs)("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:(0,Mt.jsx)(ea,{size:11}),label:"Custom"}:{icon:gv[A.category].icon,label:gv[A.category].label},H=T.filter(V=>V.section===A.section).length,K=C.has(A.def.indicator.id),G=e.find(V=>V.id===A.def.indicator.id);return(0,Mt.jsxs)("div",{children:[E&&(0,Mt.jsx)(n6,{icon:L.icon,label:L.label,count:H}),(0,Mt.jsx)(t6,{row:A,isActive:K,isVisible:G?.visible??!0,highlighted:B===h,refusal:e6(A.def.indicator,t),rowRef:B===h?V=>b.current=V: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)})}),(0,Mt.jsx)("div",{className:"flex items-center justify-between h-7 px-3 border-t border-[#1e2128] shrink-0",children:(0,Mt.jsxs)("span",{className:"text-[10px] text-slate-700 flex items-center gap-2",children:[(0,Mt.jsx)("kbd",{className:"font-sans",children:"\u2191\u2193"})," move",(0,Mt.jsx)("kbd",{className:"font-sans",children:"\u21B5"})," add"]})})]})]})}var uo=require("react");var On=require("react/jsx-runtime"),r6=[{label:"Seconds",tfs:Go.filter(e=>e.barNs>=1000000000n&&e.barNs<60000000000n)},{label:"Minutes",tfs:Go.filter(e=>e.barNs>=60000000000n&&e.barNs<3600000000000n)},{label:"Hours",tfs:Go.filter(e=>e.barNs>=3600000000000n&&e.barNs<86400000000000n)},{label:"Days",tfs:Go.filter(e=>e.barNs>=86400000000000n&&e.barNs<604800000000000n)},{label:"Weeks",tfs:Go.filter(e=>e.barNs>=604800000000000n)}];function nR({eventBus:e,value:t,customTimeframes:n,features:r,onChange:o,onAddCustom:a,onRemoveCustom:i,onOpenChange:s}){let[l,c]=(0,uo.useState)(!1),[u,d]=(0,uo.useState)(""),[m,f]=(0,uo.useState)(""),[h,p]=(0,uo.useState)(()=>Vx()),g=(0,uo.useRef)(null),y=(0,uo.useRef)(null),v=P=>{c(D=>{let N=typeof P=="function"?P(D):P;return s?.(N),N})},b=(0,uo.useMemo)(()=>[...Go,...n],[n]),S=r?.timeframe?.timeframes??"any",C=r?.timeframe?.allowCustom??!0,w=(0,uo.useCallback)(P=>S!=="any"&&!S.includes(P),[S]),k=(0,uo.useMemo)(()=>{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);(0,uo.useEffect)(()=>{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]),(0,uo.useEffect)(()=>{l&&setTimeout(()=>y.current?.focus(),50)},[l]);let I=(0,uo.useCallback)(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=(0,uo.useCallback)(P=>{p(D=>{let N=D.includes(P)?D.filter(O=>O!==P):[...D,P];return Wx(N),N})},[]),T=(0,uo.useCallback)(()=>{let P=Ic(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(0,On.jsxs)("div",{className:"relative flex items-center gap-0.5",ref:g,children:[k.map(P=>(0,On.jsx)(eR,{tf:P,active:t.label===P.label,locked:w(P.label),onSelect:I},P.label)),!M&&(0,On.jsx)(eR,{tf:t,active:!0,onSelect:I}),(0,On.jsx)("button",{onClick:()=>v(P=>!P),"aria-label":"All timeframes",className:ne("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:(0,On.jsx)(or,{size:12,className:ne("transition-transform duration-150",l&&"rotate-180")})}),l&&(0,On.jsx)("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:(0,On.jsxs)("div",{className:"p-2.5 space-y-3 max-h-[22rem] overflow-y-auto",children:[r6.filter(P=>P.tfs.length>0).map(P=>(0,On.jsxs)("div",{children:[(0,On.jsx)(vv,{children:P.label}),(0,On.jsx)("div",{className:"flex flex-wrap gap-1",children:P.tfs.map(D=>(0,On.jsx)(tR,{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&&(0,On.jsxs)("div",{children:[(0,On.jsx)(vv,{children:"Custom"}),(0,On.jsx)("div",{className:"flex flex-wrap gap-1",children:n.map(P=>(0,On.jsx)(tR,{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))})]}),(0,On.jsxs)("div",{className:"pt-2 border-t border-[#1e2128]",children:[(0,On.jsx)(vv,{children:(0,On.jsxs)("span",{className:"inline-flex items-center gap-1",children:["Add custom",!C&&(0,On.jsx)(no,{size:8,className:"text-slate-600"})]})}),(0,On.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,On.jsx)("input",{ref:y,value:u,onChange:P=>{d(P.target.value),f("")},onKeyDown:R,placeholder:"e.g. 7m",className:ne("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")}),(0,On.jsx)("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:(0,On.jsx)(pa,{size:11})})]}),m&&(0,On.jsx)("div",{className:"text-[10px] text-red-400/80 mt-1 px-0.5",children:m}),(0,On.jsx)("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 eR({tf:e,active:t,locked:n,onSelect:r}){return(0,On.jsxs)("button",{onClick:()=>r(e),title:n?`${e.label} is a Pro timeframe`:void 0,className:ne("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&&(0,On.jsx)(no,{size:8}),t&&(0,On.jsx)("span",{className:"absolute inset-x-1.5 bottom-[4px] h-[1px] rounded-full bg-[#08b3de]"})]})}function vv({children:e}){return(0,On.jsx)("div",{className:"text-[9px] font-[600] text-muted-foreground uppercase tracking-widest mb-1.5 px-0.5",children:e})}function tR({tf:e,active:t,pinned:n,locked:r,onSelect:o,onTogglePin:a,onRemove:i}){return(0,On.jsxs)("div",{title:r?`${e.label} is a Pro timeframe`:void 0,className:ne("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?(0,On.jsx)(no,{size:8,className:"ml-1.5 shrink-0"}):(0,On.jsx)("button",{className:ne("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:(0,On.jsx)(El,{size:9,className:n?"fill-current":""})}),i&&(0,On.jsx)("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:(0,On.jsx)(Kr,{size:8})})]})}var Mu=require("react");var gn=require("react/jsx-runtime");function ds({className:e,children:t}){return(0,gn.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:ne("w-5 h-5",e),children:t})}function rR({filled:e}){let t=e?"currentColor":"none",n=e?"none":"currentColor";return(0,gn.jsxs)(gn.Fragment,{children:[(0,gn.jsx)("path",{d:"M8 3v5M8 16v5"}),(0,gn.jsx)("rect",{x:"5.5",y:"8",width:"5",height:"8",rx:"1",fill:t,stroke:n}),(0,gn.jsx)("path",{d:"M16 5v4M16 15v4"}),(0,gn.jsx)("rect",{x:"13.5",y:"9",width:"5",height:"6",rx:"1",fill:t,stroke:n})]})}function oR({className:e}){return(0,gn.jsx)(ds,{className:e,children:(0,gn.jsx)(rR,{filled:!0})})}function aR({className:e}){return(0,gn.jsx)(ds,{className:e,children:(0,gn.jsx)(rR,{filled:!1})})}function iR({className:e}){return(0,gn.jsxs)(ds,{className:e,children:[(0,gn.jsx)("rect",{x:"4",y:"11",width:"4",height:"8",rx:"0.5",fill:"currentColor",stroke:"none"}),(0,gn.jsx)("path",{d:"M6 8v3"}),(0,gn.jsx)("rect",{x:"10",y:"7",width:"4",height:"8",rx:"0.5",fill:"currentColor",stroke:"none"}),(0,gn.jsx)("path",{d:"M12 4v3"}),(0,gn.jsx)("rect",{x:"16",y:"4",width:"4",height:"8",rx:"0.5",fill:"currentColor",stroke:"none"}),(0,gn.jsx)("path",{d:"M18 12v3"})]})}function sR({className:e}){return(0,gn.jsxs)(ds,{className:e,children:[(0,gn.jsx)("path",{d:"M8 4v12"}),(0,gn.jsx)("path",{d:"M8 7H5"}),(0,gn.jsx)("path",{d:"M8 12h3"}),(0,gn.jsx)("path",{d:"M16 8v12"}),(0,gn.jsx)("path",{d:"M16 11h-3"}),(0,gn.jsx)("path",{d:"M16 16h3"})]})}function lR({className:e}){return(0,gn.jsxs)(ds,{className:e,children:[(0,gn.jsx)("path",{d:"M3 12h26",strokeDasharray:"2 1"}),(0,gn.jsx)("path",{d:"M2 18 10 9l6 6 20-23"})]})}function cR({className:e}){return(0,gn.jsxs)(ds,{className:e,children:[(0,gn.jsx)("path",{d:"M3 15 9 11l4 3 8-6v14H3Z",fill:"currentColor",fillOpacity:.18,stroke:"none"}),(0,gn.jsx)("path",{d:"M3 15 9 11l4 3 8-6"})]})}function uR({className:e}){return(0,gn.jsx)(ds,{className:e,children:(0,gn.jsx)("path",{d:"M2 18 10 9l6 6 20-23"})})}function dR({className:e}){return(0,gn.jsx)(ds,{className:e,children:(0,gn.jsx)("path",{d:"M3 16h5v-5h5v3h5V7h2"})})}function fR({className:e}){return(0,gn.jsxs)(ds,{className:e,children:[(0,gn.jsx)("rect",{x:"4",y:"5",width:"16",height:"14",rx:"1"}),(0,gn.jsx)("path",{d:"M12 5v14"}),(0,gn.jsx)("path",{d:"M4 10h16"}),(0,gn.jsx)("path",{d:"M4 14h16"})]})}var In=require("react/jsx-runtime");function o6({icon:e}){return typeof e>"u"?(0,In.jsx)(ea,{className:"w-4 h-4"}):(0,In.jsx)("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)=>(0,In.jsx)("path",{d:t},n))})}function hR({value:e,pluginChartTypes:t=[],dataLevel:n,onChange:r,onOpenChange:o}){let[a,i]=(0,Mu.useState)(!1),s=(0,Mu.useRef)(null),l=[{id:"candles",label:"Candles",icon:(0,In.jsx)(oR,{})},{id:"hollow",label:"Hollow",icon:(0,In.jsx)(aR,{})},{id:"heikin-ashi",label:"Heikin Ashi",icon:(0,In.jsx)(iR,{})},{id:"bars",label:"Bars",icon:(0,In.jsx)(sR,{})},{id:"footprint",label:"Footprint",icon:(0,In.jsx)(fR,{})},{id:"area",label:"Area",icon:(0,In.jsx)(cR,{})},{id:"line",label:"Line",icon:(0,In.jsx)(uR,{})},{id:"step",label:"Step",icon:(0,In.jsx)(dR,{})},{id:"baseline",label:"Baseline",icon:(0,In.jsx)(lR,{})}].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?(0,In.jsx)(o6,{icon:f.icon}):(0,In.jsx)(ea,{className:"w-4 h-4"}),refusal:Bo(h,n)?void 0:ol(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:(0,In.jsx)(ai,{className:"w-4 h-4"})};(0,Mu.useEffect)(()=>{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(0,In.jsxs)("div",{className:"relative",ref:s,children:[(0,In.jsxs)("button",{onClick:()=>u(f=>!f),className:ne("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:[(0,In.jsx)("span",{className:"opacity-60 shrink-0 flex items-center",children:d.icon}),(0,In.jsx)("div",{className:"mt-px",children:d.label}),(0,In.jsx)(or,{size:10,className:ne("opacity-50 transition-transform duration-150",a&&"rotate-180")})]}),a&&(0,In.jsx)("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:(0,In.jsxs)("div",{className:"p-2.5 space-y-3",children:[(0,In.jsxs)("div",{children:[(0,In.jsx)(mR,{children:"Chart type"}),(0,In.jsx)("div",{className:"grid grid-cols-3 gap-1",children:l.map(f=>(0,In.jsx)(pR,{def:f,active:f.id===e,onSelect:m},f.id))})]}),c.length>0&&(0,In.jsxs)("div",{children:[(0,In.jsx)(mR,{children:"Plugins"}),(0,In.jsx)("div",{className:"grid grid-cols-3 gap-1",children:c.map(f=>(0,In.jsx)(pR,{def:f,active:f.id===e,onSelect:m},f.id))})]})]})})]})}function mR({children:e}){return(0,In.jsx)("div",{className:"text-[9px] font-[600] text-muted-foreground uppercase tracking-widest mb-1.5 px-0.5",children:e})}function pR({def:e,active:t,onSelect:n}){let r=!!e.refusal;return(0,In.jsxs)(Gt,{children:[(0,In.jsx)(qt,{asChild:!0,children:(0,In.jsxs)("button",{onClick:()=>{r||n(e.id)},className:ne("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&&(0,In.jsx)("span",{className:"absolute top-1.5 right-1.5 w-1 h-1 rounded-full bg-[#08b3de]"}),r&&(0,In.jsx)(no,{size:8,className:"absolute top-1.5 right-1.5 text-slate-700"}),(0,In.jsx)("span",{className:ne("shrink-0",r?"text-slate-700":t?"text-slate-200":"text-slate-600 group-hover:text-slate-300"),children:e.icon}),(0,In.jsx)("span",{className:"text-[9px] font-medium leading-none max-w-full truncate px-1",children:e.label})]})}),(0,In.jsx)(Ut,{className:"border border-border bg-background max-w-[13rem]",children:e.refusal??e.label})]})}var Ir=require("react");var To=require("react");var Qn=require("react/jsx-runtime"),wv=[{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"]}],gR=["Americas","Europe","Asia-Pacific","Other"];function yR(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 a6(e,t){let r=wv.find(a=>a.value===e)?.label??e,o=yR(e,t);return{label:r,offset:o}}function vR({value:e,onChange:t,use24Hour:n=!0,onOpenChange:r,compact:o=!1,horizon:a=0n}){let[i,s]=(0,To.useState)(!1);(0,To.useEffect)(()=>{r?.(i)},[i]);let[l,c]=(0,To.useState)(""),[u,d]=(0,To.useState)(null),m=(0,To.useRef)(null),f=(0,To.useRef)(null),h=(0,To.useRef)(null);(0,To.useEffect)(()=>{if(!i)return;let w=k=>{m.current?.contains(k.target)||(s(!1),c(""))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]),(0,To.useEffect)(()=>{i&&(setTimeout(()=>f.current?.focus(),50),d(e))},[i,e]);let p=(0,To.useMemo)(()=>{let w=l.toLowerCase().trim();return w?wv.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))):wv},[l]),g=(0,To.useMemo)(()=>{let w=new Map;for(let k of gR)w.set(k,[]);for(let k of p)w.get(k.region)?.push(k);return w},[p]),y=(0,To.useMemo)(()=>p,[p]),v=(0,To.useCallback)(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}=a6(e,a);return(0,Qn.jsxs)("div",{ref:m,className:"relative w-full select-none",children:[(0,Qn.jsxs)("button",{onClick:()=>s(w=>!w),className:ne("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:[(0,Qn.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,Qn.jsx)(Dl,{size:o?11:13,className:"text-white/40 shrink-0"}),(0,Qn.jsx)("span",{className:ne("font-medium truncate",o?"text-[11px]":"text-[12px]"),children:S}),(0,Qn.jsx)("span",{className:"text-[10px] font-mono text-white/30 shrink-0",children:C||"UTC"})]}),(0,Qn.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[!o&&(0,Qn.jsx)(bR,{tz:e,use24Hour:n,horizon:a}),(0,Qn.jsx)(or,{size:o?11:13,className:ne("text-white/30 transition-transform duration-150",i&&"rotate-180")})]})]}),i&&(0,Qn.jsxs)("div",{className:ne("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:[(0,Qn.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-white/8 shrink-0",children:[(0,Qn.jsx)(li,{size:12,className:"text-white/25 shrink-0"}),(0,Qn.jsx)("input",{ref:f,value:l,onChange:w=>{c(w.target.value),d(null)},onKeyDown:v,placeholder:"Search timezone\u2026",className:ne("flex-1 bg-transparent text-[12px] text-white placeholder:text-white/25","outline-none border-none")}),l&&(0,Qn.jsx)("button",{onClick:()=>c(""),className:"text-white/25 hover:text-white/60 transition-colors",children:(0,Qn.jsx)(Kr,{size:11})})]}),(0,Qn.jsxs)("div",{ref:h,className:"overflow-y-auto overscroll-contain",style:{maxHeight:268},children:[y.length===0?(0,Qn.jsxs)("div",{className:"px-3 py-6 text-center text-[11px] text-white/25",children:['No timezones match "',l,'"']}):gR.map(w=>{let k=g.get(w)??[];return k.length?(0,Qn.jsxs)("div",{children:[(0,Qn.jsx)("div",{className:"sticky top-0 z-10 px-3 pt-2.5 pb-1 bg-[#1a1d23]",children:(0,Qn.jsx)("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(0,Qn.jsxs)("button",{"data-tz":M.value,onClick:()=>{t(M.value),s(!1),c("")},onMouseEnter:()=>d(M.value),className:ne("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:[(0,Qn.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,Qn.jsx)("div",{className:"w-3 shrink-0 flex justify-center",children:I?(0,Qn.jsx)(Yr,{size:11,className:"text-blue-400"}):(0,Qn.jsx)("span",{})}),(0,Qn.jsx)("span",{className:"text-[12px] truncate",children:M.label}),(0,Qn.jsx)("span",{className:"text-[10px] font-mono text-white/20 shrink-0",children:yR(M.value,a)||"UTC"})]}),(0,Qn.jsx)(bR,{tz:M.value,use24Hour:n,dim:!I&&!x,horizon:a})]},M.value)})]},w):null}),(0,Qn.jsx)("div",{className:"h-1.5"})]})]})]})}function bR({tz:e,use24Hour:t,dim:n,horizon:r}){let o=i6(r,e,t);return(0,Qn.jsx)("span",{className:ne("text-[10px] font-mono tabular-nums shrink-0 transition-colors",n?"text-white/15":"text-white/40"),children:o})}function i6(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 s6="tradingview.chartproperties",l6="tradingview.chartproperties.mainSeriesProperties",c6="tradingview.chart.favoriteDrawings",xv=`${Qm}tradingview-imported`,wR={0:"bars",1:"candles",2:"line",3:"area",4:"renko",5:"kagi",7:"line-break",8:"heikin-ashi",9:"hollow",10:"baseline",15:"step"},u6={0:"barStyle",1:"candleStyle",4:"renkoStyle",8:"haStyle",9:"hollowCandleStyle",19:"volCandlesStyle"},d6={0:[],1:[2,3],2:[6,3],3:[10,5]},f6={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"},qo=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Vh=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=`#${Vh(Number(r))}${Vh(Number(o))}${Vh(Number(a))}`;return s>=1?l:`${l}${Vh(s*255)}`}var ac=e=>typeof e=="boolean"?e:void 0,Lu=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0;function Gn(e,t,n){n!==void 0&&(e[t]=n)}function xR(e){if(typeof window>"u")return null;try{let t=window.localStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return qo(n)?n:null}catch{return null}}function Ru(){let e=xR(s6),t=xR(l6)??(qo(e?.mainSeriesProperties)?e.mainSeriesProperties:null);if(!e&&!t)return null;let n={},r=qo(e?.paneProperties)?e.paneProperties:{},o=Ya(r.background)??Ya(r.backgroundGradientStartColor);if(Gn(n,"backgroundColor",o),Gn(n,"axisBackgroundColor",o),typeof r.gridLinesMode=="string"&&Gn(n,"showGrid",r.gridLinesMode!=="none"),qo(r.vertGridProperties)&&Gn(n,"gridVerticalColor",Ya(r.vertGridProperties.color)),qo(r.horzGridProperties)&&Gn(n,"gridHorizontalColor",Ya(r.horzGridProperties.color)),qo(r.crossHairProperties)){let i=r.crossHairProperties;Gn(n,"crosshairColor",Ya(i.color)),Gn(n,"crosshairWidth",Lu(i.width));let s=typeof i.style=="number"?d6[i.style]:void 0;Gn(n,"crosshairDash",s)}let a=i=>{let s=Lu(i);return s===void 0?void 0:Math.max(0,Math.min(.5,s/100))};if(Gn(n,"scaleMarginTop",a(r.topMargin)),Gn(n,"scaleMarginBottom",a(r.bottomMargin)),qo(r.axisProperties)){let i=r.axisProperties;Gn(n,"autoScale",ac(i.autoScale)),Gn(n,"invertScale",ac(i.isInverted)),i.log===!0?Gn(n,"priceScaleMode","log"):i.percentage===!0?Gn(n,"priceScaleMode","percent"):i.log===!1&&i.percentage===!1&&Gn(n,"priceScaleMode","normal")}if(qo(r.legendProperties)){let i=r.legendProperties;Gn(n,"showStatusLine",ac(i.showLegend)),Gn(n,"statusLineOHLC",ac(i.showSeriesOHLC)),Gn(n,"statusLineVolume",ac(i.showVolume)),Gn(n,"statusLineChange",ac(i.showBarChange))}if(typeof e?.timezone=="string"&&e.timezone&&Gn(n,"timezone",e.timezone==="Etc/UTC"?"UTC":e.timezone),t){let i=Lu(t.style);i!==void 0&&wR[i]&&Gn(n,"chartType",wR[i]);let s=i!==void 0&&u6[i]||"candleStyle",l=qo(t[s])?t[s]:qo(t.candleStyle)?t.candleStyle:null;if(l){let m=Ya(l.upColor),f=Ya(l.downColor);Gn(n,"upBodyColor",m),Gn(n,"downBodyColor",f);let h=Ya(l.borderUpColor),p=Ya(l.borderDownColor);Gn(n,"upBorderColor",h),Gn(n,"downBorderColor",p);let g=Ya(l.wickUpColor),y=Ya(l.wickDownColor);Gn(n,"upWickColor",g),Gn(n,"downWickColor",y),m&&f&&h&&p&&Gn(n,"borderColorMatchesBody",h===m&&p===f),m&&f&&g&&y&&Gn(n,"wickColorMatchesBody",g===m&&y===f)}Gn(n,"priceLineVisible",ac(t.showPriceLine)),Gn(n,"priceLineColor",Ya(t.priceLineColor));let c=qo(t.renkoStyle)?t.renkoStyle:null;c&&qo(c.inputs)&&c.inputs.style==="Traditional"&&Gn(n,"renkoBrickSize",Lu(c.inputs.boxSize));let u=qo(t.lineBreakStyle)?t.lineBreakStyle:null;u&&qo(u.inputs)&&Gn(n,"lineBreakCount",Lu(u.inputs.lineNumber));let d=qo(t.kagiStyle)?t.kagiStyle:null;d&&qo(d.inputs)&&d.inputs.style==="Traditional"&&Gn(n,"kagiReversal",Lu(d.inputs.reversalAmount))}return Object.keys(n).length>0?n:null}function Wh(){if(typeof window>"u")return null;let e;try{let n=window.localStorage.getItem(c6);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"?f6[n]:void 0;r&&r!=="cursor"&&!t.includes(r)&&t.push(r)}return t.length>0?t:null}function qh(){return Ru()!==null||Wh()!==null}function Pu(e={}){let t={settings:!1,favorites:!1};if(typeof window>"u"||!e.force&&wl(xv)!==null)return t;if(e.force||wl(Pn.chartSettings)===null){let n=Ru();n&&(Sr(Pn.chartSettings,n),t.settings=!0)}if(e.force||wl(Pn.drawingFavorites)===null){let n=Wh();n&&(Sr(Pn.drawingFavorites,n),t.favorites=!0)}return np(xv,String(Date.now())),t}function SR(){if(!(typeof window>"u"))try{window.localStorage.removeItem(xv)}catch{}}var Y=require("react/jsx-runtime"),Cv=480,Du=12,CR=[{label:"Solid",dash:[]},{label:"Dashed",dash:[6,6]},{label:"Dotted",dash:[2,3]},{label:"Dash-dot",dash:[8,3,2,3]}],Sv=null;function m6(){return{x:Math.round((window.innerWidth-Cv)/2),y:Math.round(window.innerHeight*.1)}}function kR(e,t){let n=window.innerHeight-t-Du;return Math.min(Math.max(Du,e),Math.max(Du,n))}function p6(e){return Math.max(Du,Math.min(window.innerWidth-Cv-Du,e))}function TR({settings:e,horizon:t,onUpdate:n,onClose:r,onMouseEnter:o,onMouseLeave:a,pluginChartType:i}){let[s,l]=(0,Ir.useState)("candles"),c=i?.settingsSchema??[],u=s==="plugin"&&!c.length?"candles":s,d=(0,Ir.useRef)(null),m=(0,Ir.useRef)(null),f=e,[h,p]=(0,Ir.useState)(!1),g=(0,Ir.useRef)(Sv??(typeof window<"u"?m6():{x:80,y:80})),[,y]=(0,Ir.useState)(0);(0,Ir.useLayoutEffect)(()=>{let x=m.current;if(!x)return;let T=kR(g.current.y,x.offsetHeight);T!==g.current.y&&(g.current={...g.current,y:T},Sv=g.current,y(R=>R+1))});let v=(0,Ir.useCallback)(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:p6(P+A.clientX-T),y:kR(D+A.clientY-R,B)},Sv=g.current,y(E=>E+1)},O=()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",O)};window.addEventListener("mousemove",N),window.addEventListener("mouseup",O)},[]),b=(0,Ir.useCallback)(()=>{a?.(),r()},[r,a]);(0,Ir.useEffect)(()=>{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:(0,Y.jsx)(As,{size:14})},{id:"scales",label:"Scales",icon:(0,Y.jsx)(df,{size:14})},{id:"lines",label:"Lines",icon:(0,Y.jsx)(Jo,{size:14})},{id:"status",label:"Status",icon:(0,Y.jsx)(ef,{size:14})},{id:"chart",label:"Chart",icon:(0,Y.jsx)(sf,{size:14})},{id:"timezone",label:"Timezone",icon:(0,Y.jsx)(Dl,{size:14})},...c.length?[{id:"plugin",label:i.label,icon:(0,Y.jsx)(ea,{size:14})}]:[]],I=x=>Math.max(0,M.findIndex(T=>T.id===x));return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("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
|
+
`}),(0,Y.jsxs)("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:Cv,maxHeight:`calc(100vh - ${g.current.y+Du}px)`},onMouseDown:x=>x.stopPropagation(),onMouseEnter:o,onMouseLeave:a,children:[(0,Y.jsxs)("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:[(0,Y.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Y.jsx)("h2",{className:"text-sm font-semibold text-white tracking-tight",children:"Chart Settings"}),(0,Y.jsx)("p",{className:"text-[11px] text-white/40 mt-0.5",children:"Appearance & behaviour"})]}),(0,Y.jsx)("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:(0,Y.jsx)(Kr,{size:18})})]}),(0,Y.jsxs)("div",{className:"grid shrink-0 border-b border-white/6 relative",style:{gridTemplateColumns:`repeat(${M.length}, 1fr)`},ref:d,children:[M.map(x=>(0,Y.jsxs)("button",{onMouseDown:()=>l(x.id),className:ne("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,(0,Y.jsx)("span",{children:x.label})]},x.id)),(0,Y.jsx)("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)`}})]}),(0,Y.jsxs)("div",{className:"flex-1 overflow-y-auto px-5 py-4 min-h-0",children:[u==="candles"&&(0,Y.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,Y.jsx)(Yn,{label:"Body colors",children:(0,Y.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,Y.jsx)(wa,{label:"Bullish",value:f.upBodyColor,onChange:x=>n({upBodyColor:x})}),(0,Y.jsx)(wa,{label:"Bearish",value:f.downBodyColor,onChange:x=>n({downBodyColor:x})})]})}),(0,Y.jsxs)(Yn,{label:"Wick colors",children:[(0,Y.jsx)(Ar,{label:"Match body color",active:f.wickColorMatchesBody,onToggle:()=>n({wickColorMatchesBody:!f.wickColorMatchesBody})}),!f.wickColorMatchesBody&&(0,Y.jsxs)("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[(0,Y.jsx)(wa,{label:"Bullish wick",value:f.upWickColor,onChange:x=>n({upWickColor:x})}),(0,Y.jsx)(wa,{label:"Bearish wick",value:f.downWickColor,onChange:x=>n({downWickColor:x})})]})]}),(0,Y.jsxs)(Yn,{label:`Wick width - ${f.wickWidth}px`,children:[(0,Y.jsx)(Wn,{value:[f.wickWidth],onValueChange:([x])=>n({wickWidth:x}),min:1,max:4,step:1,className:"w-full"}),(0,Y.jsx)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[1,2,3,4].map(x=>(0,Y.jsxs)("span",{children:[x,"px"]},x))})]}),(0,Y.jsxs)(Yn,{label:"Border colors",children:[(0,Y.jsx)(Ar,{label:"Match body color",active:f.borderColorMatchesBody,onToggle:()=>n({borderColorMatchesBody:!f.borderColorMatchesBody})}),!f.borderColorMatchesBody&&(0,Y.jsxs)("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[(0,Y.jsx)(wa,{label:"Bullish border",value:f.upBorderColor,onChange:x=>n({upBorderColor:x})}),(0,Y.jsx)(wa,{label:"Bearish border",value:f.downBorderColor,onChange:x=>n({downBorderColor:x})})]})]}),(0,Y.jsxs)(Yn,{label:`Border width - ${f.borderWidth}px`,children:[(0,Y.jsx)(Wn,{value:[f.borderWidth],onValueChange:([x])=>n({borderWidth:x}),min:0,max:4,step:1,className:"w-full"}),(0,Y.jsx)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[0,1,2,3,4].map(x=>(0,Y.jsxs)("span",{children:[x,"px"]},x))})]}),f.chartType==="footprint"&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Yn,{label:"Footprint display mode",children:(0,Y.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:["bid-ask","profile","delta","total"].map(x=>(0,Y.jsx)(ic,{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"&&(0,Y.jsxs)(Yn,{label:"Volume display",children:[(0,Y.jsx)("div",{className:"flex gap-1.5",children:["none","split","total"].map(x=>(0,Y.jsx)(ic,{active:f.footprintVolume===x,onClick:()=>n({footprintVolume:x}),children:x==="none"?"None":x==="split"?"Split":"Total"},x))}),(0,Y.jsxs)("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"]})]}),(0,Y.jsx)(Yn,{label:"Footprint signals",children:(0,Y.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,Y.jsx)(Ar,{label:"Stacked imbalance",active:f.footprintShowStackedImbalance,onToggle:()=>n({footprintShowStackedImbalance:!f.footprintShowStackedImbalance})}),(0,Y.jsx)(Ar,{label:"Absorption",active:f.footprintShowAbsorption,onToggle:()=>n({footprintShowAbsorption:!f.footprintShowAbsorption})}),(0,Y.jsx)(Ar,{label:"Unfinished auction",active:f.footprintShowUnfinishedAuction,onToggle:()=>n({footprintShowUnfinishedAuction:!f.footprintShowUnfinishedAuction})}),(0,Y.jsx)(Ar,{label:"Diagonal imbalance",active:f.footprintShowDiagonalImbalance,onToggle:()=>n({footprintShowDiagonalImbalance:!f.footprintShowDiagonalImbalance})})]})}),(0,Y.jsxs)(Yn,{label:`Imbalance ratio - ${f.footprintImbalanceRatio.toFixed(1)}\xD7`,children:[(0,Y.jsx)(Wn,{value:[f.footprintImbalanceRatio],onValueChange:([x])=>n({footprintImbalanceRatio:x}),min:1.5,max:6,step:.5,className:"w-full"}),(0,Y.jsx)("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=>(0,Y.jsxs)("span",{children:[x,"\xD7"]},x))}),(0,Y.jsx)("p",{className:"text-[10px] text-white/25 mt-1",children:"Ask/bid ratio required to flag a level as imbalanced"})]}),f.footprintShowStackedImbalance&&(0,Y.jsxs)(Yn,{label:`Stacked imbalance - min ${f.footprintStackMinCount} levels`,children:[(0,Y.jsx)(Wn,{value:[f.footprintStackMinCount],onValueChange:([x])=>n({footprintStackMinCount:x}),min:2,max:6,step:1,className:"w-full"}),(0,Y.jsx)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[2,3,4,5,6].map(x=>(0,Y.jsx)("span",{children:x},x))}),(0,Y.jsx)("p",{className:"text-[10px] text-white/25 mt-1",children:"Consecutive imbalanced levels to trigger a stacked zone"})]}),f.footprintShowDiagonalImbalance&&(0,Y.jsxs)(Yn,{label:`Diagonal ratio - ${f.footprintDiagRatio.toFixed(1)}\xD7`,children:[(0,Y.jsx)(Wn,{value:[f.footprintDiagRatio],onValueChange:([x])=>n({footprintDiagRatio:x}),min:1.5,max:6,step:.5,className:"w-full"}),(0,Y.jsx)("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=>(0,Y.jsxs)("span",{children:[x,"\xD7"]},x))}),(0,Y.jsx)("p",{className:"text-[10px] text-white/25 mt-1",children:"ask[n] / bid[n\u22121] threshold for diagonal imbalance"})]}),f.footprintShowAbsorption&&(0,Y.jsxs)(Yn,{label:`Absorption threshold - ${f.footprintAbsorptionMult.toFixed(1)}\xD7 avg`,children:[(0,Y.jsx)(Wn,{value:[f.footprintAbsorptionMult],onValueChange:([x])=>n({footprintAbsorptionMult:x}),min:1.5,max:5,step:.5,className:"w-full"}),(0,Y.jsx)("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=>(0,Y.jsxs)("span",{children:[x,"\xD7"]},x))}),(0,Y.jsxs)("div",{className:"mt-3",children:[(0,Y.jsxs)("p",{className:"text-[11px] text-white/40 mb-2",children:["Max delta fraction -"," ",Math.round(f.footprintAbsorptionDeltaFrac*100),"%"]}),(0,Y.jsx)(Wn,{value:[f.footprintAbsorptionDeltaFrac],onValueChange:([x])=>n({footprintAbsorptionDeltaFrac:x}),min:.05,max:.5,step:.05,className:"w-full"}),(0,Y.jsx)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[5,10,20,30,40,50].map(x=>(0,Y.jsxs)("span",{children:[x,"%"]},x))}),(0,Y.jsx)("p",{className:"text-[10px] text-white/25 mt-1",children:"Max |delta/total| allowed - lower = more symmetric fills only"})]})]}),(0,Y.jsx)(al,{onReset:()=>n({footprintImbalanceRatio:Xe.footprintImbalanceRatio,footprintStackMinCount:Xe.footprintStackMinCount,footprintShowStackedImbalance:Xe.footprintShowStackedImbalance,footprintShowAbsorption:Xe.footprintShowAbsorption,footprintShowUnfinishedAuction:Xe.footprintShowUnfinishedAuction,footprintShowDiagonalImbalance:Xe.footprintShowDiagonalImbalance,footprintDiagRatio:Xe.footprintDiagRatio,footprintAbsorptionMult:Xe.footprintAbsorptionMult,footprintAbsorptionDeltaFrac:Xe.footprintAbsorptionDeltaFrac})})]}),(0,Y.jsx)("div",{className:"border-t border-white/6 my-1"}),(0,Y.jsx)(al,{onReset:()=>n({chartType:Xe.chartType,upBodyColor:Xe.upBodyColor,downBodyColor:Xe.downBodyColor,upWickColor:Xe.upWickColor,downWickColor:Xe.downWickColor,upBorderColor:Xe.upBorderColor,downBorderColor:Xe.downBorderColor,wickColorMatchesBody:Xe.wickColorMatchesBody,borderColorMatchesBody:Xe.borderColorMatchesBody,wickWidth:Xe.wickWidth,borderWidth:Xe.borderWidth,footprintMode:Xe.footprintMode,footprintVolume:Xe.footprintVolume,footprintImbalanceRatio:Xe.footprintImbalanceRatio,footprintStackMinCount:Xe.footprintStackMinCount,footprintShowStackedImbalance:Xe.footprintShowStackedImbalance,footprintShowAbsorption:Xe.footprintShowAbsorption,footprintShowUnfinishedAuction:Xe.footprintShowUnfinishedAuction,footprintShowDiagonalImbalance:Xe.footprintShowDiagonalImbalance,footprintDiagRatio:Xe.footprintDiagRatio,footprintAbsorptionMult:Xe.footprintAbsorptionMult,footprintAbsorptionDeltaFrac:Xe.footprintAbsorptionDeltaFrac})})]}),u==="scales"&&(0,Y.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,Y.jsx)(Yn,{label:"Price scale mode",children:(0,Y.jsx)("div",{className:"flex gap-1.5",children:["normal","percent"].map(x=>(0,Y.jsx)(ic,{active:f.priceScaleMode===x,onClick:()=>n({priceScaleMode:x}),children:x==="normal"?"Linear":"%"},x))})}),(0,Y.jsxs)(Yn,{label:`Price Scale Resize Sensitivity - ${f.priceAxisResizeSensitivity}x`,children:[(0,Y.jsx)(Wn,{value:[f.priceAxisResizeSensitivity],onValueChange:([x])=>n({priceAxisResizeSensitivity:x}),min:0,max:2,step:.1,className:"w-full"}),(0,Y.jsxs)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[(0,Y.jsx)("span",{children:"0x"}),(0,Y.jsx)("span",{children:"1x"}),(0,Y.jsx)("span",{children:"2x"})]})]}),(0,Y.jsx)(Yn,{label:"Options",children:(0,Y.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,Y.jsx)(Ar,{label:"Auto-scale",active:f.autoScale,onToggle:()=>n({autoScale:!f.autoScale})}),(0,Y.jsx)(Ar,{label:"Invert scale",active:f.invertScale,onToggle:()=>n({invertScale:!f.invertScale})}),(0,Y.jsx)(Ar,{label:"Allow label overlap",active:f.allowLabelOverlap,onToggle:()=>n({allowLabelOverlap:!f.allowLabelOverlap})}),(0,Y.jsx)(Ar,{label:"Animate price updates",active:f.animatePriceUpdates,onToggle:()=>n({animatePriceUpdates:!f.animatePriceUpdates})})]})}),(0,Y.jsxs)(Yn,{label:`Top margin - ${Math.round(f.scaleMarginTop*100)}%`,children:[(0,Y.jsx)(Wn,{value:[f.scaleMarginTop],onValueChange:([x])=>n({scaleMarginTop:x}),min:0,max:.5,step:.01,className:"w-full"}),(0,Y.jsxs)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[(0,Y.jsx)("span",{children:"0%"}),(0,Y.jsx)("span",{children:"25%"}),(0,Y.jsx)("span",{children:"50%"})]})]}),(0,Y.jsxs)(Yn,{label:`Bottom margin - ${Math.round(f.scaleMarginBottom*100)}%`,children:[(0,Y.jsx)(Wn,{value:[f.scaleMarginBottom],onValueChange:([x])=>n({scaleMarginBottom:x}),min:0,max:.5,step:.01,className:"w-full"}),(0,Y.jsxs)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[(0,Y.jsx)("span",{children:"0%"}),(0,Y.jsx)("span",{children:"25%"}),(0,Y.jsx)("span",{children:"50%"})]})]}),(0,Y.jsx)(al,{onReset:()=>n({priceScaleMode:Xe.priceScaleMode,autoScale:Xe.autoScale,priceAxisResizeSensitivity:Xe.priceAxisResizeSensitivity,invertScale:Xe.invertScale,scaleMarginTop:Xe.scaleMarginTop,scaleMarginBottom:Xe.scaleMarginBottom,allowLabelOverlap:Xe.allowLabelOverlap})})]}),u==="lines"&&(0,Y.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,Y.jsxs)(Yn,{label:"Grid",children:[(0,Y.jsx)(Ar,{label:"Show grid",active:f.showGrid,onToggle:()=>n({showGrid:!f.showGrid})}),f.showGrid&&(0,Y.jsx)("div",{className:"mt-3 flex flex-col gap-3",children:(0,Y.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,Y.jsx)(wa,{label:"Horizontal",value:f.gridHorizontalColor,onChange:x=>n({gridHorizontalColor:x})}),(0,Y.jsx)(wa,{label:"Vertical",value:f.gridVerticalColor,onChange:x=>n({gridVerticalColor:x})})]})})]}),(0,Y.jsxs)(Yn,{label:"Crosshair",children:[(0,Y.jsx)("div",{className:"flex gap-1.5 mb-3",children:["normal","hidden"].map(x=>(0,Y.jsx)(ic,{active:f.crosshairMode===x,onClick:()=>n({crosshairMode:x}),children:x.charAt(0).toUpperCase()+x.slice(1)},x))}),f.crosshairMode!=="hidden"&&(0,Y.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,Y.jsx)(wa,{label:"Crosshair color",value:f.crosshairColor,onChange:x=>n({crosshairColor:x})}),(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("label",{className:"block text-[11px] text-white/40 mb-1",children:["Line width - ",f.crosshairWidth,"px"]}),(0,Y.jsx)(Wn,{value:[f.crosshairWidth],onValueChange:([x])=>n({crosshairWidth:x}),min:1,max:3,step:1,className:"w-full"})]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("label",{className:"block text-[11px] text-white/40 mb-2",children:"Line style"}),(0,Y.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:CR.map(x=>(0,Y.jsx)(ic,{active:JSON.stringify(f.crosshairDash)===JSON.stringify(x.dash),onClick:()=>n({crosshairDash:x.dash}),children:x.label},x.label))})]})]})]}),(0,Y.jsxs)(Yn,{label:"Breaks",children:[(0,Y.jsx)("div",{className:"flex gap-1.5 mb-3",children:(0,Y.jsx)(Ar,{label:"Show breaks",active:f.showBreaks,onToggle:()=>n({showBreaks:!f.showBreaks})})}),f.showBreaks&&(0,Y.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,Y.jsx)(wa,{label:"Breaks color",value:f.breaksColor,onChange:x=>n({breaksColor:x})}),(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("label",{className:"block text-[11px] text-white/40 mb-1",children:["Line width - ",f.breaksWidth,"px"]}),(0,Y.jsx)(Wn,{value:[f.breaksWidth],onValueChange:([x])=>n({breaksWidth:x}),min:1,max:3,step:1,className:"w-full"})]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("label",{className:"block text-[11px] text-white/40 mb-2",children:"Line style"}),(0,Y.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:CR.map(x=>(0,Y.jsx)(ic,{active:JSON.stringify(f.breaksDash)===JSON.stringify(x.dash),onClick:()=>n({breaksDash:x.dash}),children:x.label},x.label))})]})]})]}),(0,Y.jsx)(al,{onReset:()=>n({showGrid:Xe.showGrid,gridHorizontalColor:Xe.gridHorizontalColor,gridVerticalColor:Xe.gridVerticalColor,crosshairMode:Xe.crosshairMode,crosshairColor:Xe.crosshairColor,crosshairWidth:Xe.crosshairWidth,crosshairDash:Xe.crosshairDash,showBreaks:Xe.showBreaks,breaksColor:Xe.breaksColor,breaksDash:Xe.breaksDash,breaksWidth:Xe.breaksWidth})})]}),u==="status"&&(0,Y.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,Y.jsx)(Ar,{label:"Show status line",active:f.showStatusLine,onToggle:()=>n({showStatusLine:!f.showStatusLine})}),f.showStatusLine&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Yn,{label:"Values displayed",children:(0,Y.jsx)("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])=>(0,Y.jsx)(Ar,{label:T,active:f[x],onToggle:()=>n({[x]:!f[x]})},x))})}),(0,Y.jsxs)(Yn,{label:`Font size - ${f.statusLineFontSize}px`,children:[(0,Y.jsx)(Wn,{value:[f.statusLineFontSize],onValueChange:([x])=>n({statusLineFontSize:x}),min:9,max:14,step:1,className:"w-full"}),(0,Y.jsx)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[9,10,11,12,13,14].map(x=>(0,Y.jsx)("span",{children:x},x))})]})]}),(0,Y.jsx)(al,{onReset:()=>n({showStatusLine:Xe.showStatusLine,statusLineOHLC:Xe.statusLineOHLC,statusLineVolume:Xe.statusLineVolume,statusLineDelta:Xe.statusLineDelta,statusLineChange:Xe.statusLineChange,statusLineFontSize:Xe.statusLineFontSize})})]}),u==="chart"&&(0,Y.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,Y.jsx)(Yn,{label:"Colors",children:(0,Y.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,Y.jsx)(wa,{label:"Chart background",value:f.backgroundColor,onChange:x=>n({backgroundColor:x})}),(0,Y.jsx)(wa,{label:"Axis background",value:f.axisBackgroundColor,onChange:x=>n({axisBackgroundColor:x})}),(0,Y.jsx)(wa,{label:"Price line",value:f.priceLineColor,onChange:x=>n({priceLineColor:x})})]})}),(0,Y.jsx)(Yn,{label:"Overlays",children:(0,Y.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,Y.jsx)(Ar,{label:"Show bid line",active:f.showBidLine,onToggle:()=>n({showBidLine:!f.showBidLine})}),(0,Y.jsx)(Ar,{label:"Show ask line",active:f.showAskLine,onToggle:()=>n({showAskLine:!f.showAskLine})}),(0,Y.jsx)(Ar,{label:"Show mid line",active:f.showMidLine,onToggle:()=>n({showMidLine:!f.showMidLine})}),(0,Y.jsx)(Ar,{label:"Show last trade line",active:f.showLastTradeLine,onToggle:()=>n({showLastTradeLine:!f.showLastTradeLine})}),(0,Y.jsx)(Ar,{label:"Show price line",active:f.priceLineVisible,onToggle:()=>n({priceLineVisible:!f.priceLineVisible})}),(0,Y.jsx)(Ar,{label:"Show fills",active:f.showFills,onToggle:()=>n({showFills:!f.showFills})})]})}),(0,Y.jsxs)(Yn,{label:"Trade dots",children:[(0,Y.jsx)(Ar,{label:"Show trade dots",active:f.showTradeDots,onToggle:()=>n({showTradeDots:!f.showTradeDots})}),f.showTradeDots&&(0,Y.jsxs)("div",{className:"mt-3",children:[(0,Y.jsxs)("label",{className:"block text-[11px] text-white/40 mb-1",children:["Dot size multiplier - ",f.tradeDotsSizeMult,"x"]}),(0,Y.jsx)(Wn,{value:[f.tradeDotsSizeMult],onValueChange:([x])=>n({tradeDotsSizeMult:x}),min:0,max:5,step:.1,className:"w-full"}),(0,Y.jsx)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[0,1,2,3,4,5].map(x=>(0,Y.jsxs)("span",{children:[x,"x"]},x))})]})]}),(0,Y.jsxs)(Yn,{label:"Heatmap",children:[(0,Y.jsx)(Ar,{label:"Show heatmap",active:f.showHeatmap,onToggle:()=>n({showHeatmap:!f.showHeatmap})}),f.showHeatmap&&(0,Y.jsx)("div",{className:"flex flex-col gap-3",children:(0,Y.jsxs)("div",{children:[(0,Y.jsxs)("label",{className:"block text-[11px] text-white/40 mb-1",children:["Contrast - ",Math.round(f.heatmapContrast*100)]}),(0,Y.jsx)(Wn,{value:[f.heatmapContrast],onValueChange:([x])=>{n({heatmapContrast:x})},min:0,max:1,step:.01,className:"w-full"}),(0,Y.jsxs)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[(0,Y.jsx)("span",{children:"0"}),(0,Y.jsx)("span",{children:"50"}),(0,Y.jsx)("span",{children:"100"})]})]})})]}),(0,Y.jsxs)(Yn,{label:`Resampling delay - ${f.resamplingDebounce}ms`,children:[(0,Y.jsx)(Wn,{value:[f.resamplingDebounce],onValueChange:([x])=>n({resamplingDebounce:x}),min:0,max:1e3,step:1,className:"w-full"}),(0,Y.jsx)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[0,200,400,600,800,1e3].map(x=>(0,Y.jsxs)("span",{children:[x,"ms"]},x))})]}),(0,Y.jsxs)(Yn,{label:"Horizon scroll animation",children:[(0,Y.jsx)("div",{className:"flex gap-1.5 mb-3",children:["none","linear","easeOut","easeInOut"].map(x=>(0,Y.jsx)(ic,{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"&&(0,Y.jsx)("div",{className:"mt-2",children:(0,Y.jsxs)(Yn,{label:`Duration - ${f.horizonScrollDuration}ms`,children:[(0,Y.jsx)(Wn,{value:[f.horizonScrollDuration],onValueChange:([x])=>n({horizonScrollDuration:x}),min:20,max:500,step:5,className:"w-full"}),(0,Y.jsx)("div",{className:"flex justify-between text-[10px] text-white/30 font-mono mt-1",children:[20,100,200,300,400,500].map(x=>(0,Y.jsxs)("span",{children:[x,"ms"]},x))})]})})]}),(0,Y.jsx)(h6,{onUpdate:n}),(0,Y.jsx)(g6,{active:u==="chart"}),(0,Y.jsx)(al,{onReset:()=>n({backgroundColor:Xe.backgroundColor,axisBackgroundColor:Xe.axisBackgroundColor,showBidLine:Xe.showBidLine,showAskLine:Xe.showAskLine,showMidLine:Xe.showMidLine,showLastTradeLine:Xe.showLastTradeLine,showTradeDots:Xe.showTradeDots,tradeDotsSizeMult:Xe.tradeDotsSizeMult,heatmapContrast:Xe.heatmapContrast,heatmapColorBid:Xe.heatmapColorBid,heatmapColorAsk:Xe.heatmapColorAsk,priceLineVisible:Xe.priceLineVisible,showFills:Xe.showFills,priceLineColor:Xe.priceLineColor,sessionHighlightEnabled:Xe.sessionHighlightEnabled,sessionHighlightColor:Xe.sessionHighlightColor,resamplingDebounce:Xe.resamplingDebounce,horizonScrollEasing:Xe.horizonScrollEasing,horizonScrollDuration:Xe.horizonScrollDuration})})]}),u==="timezone"&&(0,Y.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,Y.jsxs)(Yn,{label:"Timezone",children:[(0,Y.jsx)(vR,{value:f.timezone,onChange:x=>n({timezone:x}),use24Hour:f.use24HourClock,onOpenChange:p,horizon:t}),h&&(0,Y.jsx)("div",{className:"h-[19rem]"})]}),(0,Y.jsx)(Yn,{label:"Display options",children:(0,Y.jsx)("div",{className:"flex flex-col gap-2",children:(0,Y.jsx)(Ar,{label:"24-hour clock",active:f.use24HourClock,onToggle:()=>n({use24HourClock:!f.use24HourClock})})})}),(0,Y.jsx)(al,{onReset:()=>n({timezone:Xe.timezone,use24HourClock:Xe.use24HourClock,showTimezoneLabel:Xe.showTimezoneLabel})})]}),u==="plugin"&&(0,Y.jsxs)("div",{className:"flex flex-col gap-5",children:[c.map((x,T)=>(0,Y.jsx)(Ah,{field:x,drawing:w,onUpdate:k},Dh(x,T))),(0,Y.jsx)(al,{onReset:()=>n({pluginSettings:{...C,[S]:{...i?.defaultSettings??{}}}})})]})]}),(0,Y.jsx)("div",{className:"px-5 py-1 border-t border-white/6 shrink-0 pt-0",children:(0,Y.jsx)("a",{href:"https://christtrade.com",className:"text-[10px] text-white/20 select-none font-mono",children:"ChristTrade Depth 0.12.21"})})]})]})}function h6({onUpdate:e}){let[t,n]=(0,Ir.useState)(!1),[r,o]=(0,Ir.useState)(!1),[a,i]=(0,Ir.useState)(!1);if((0,Ir.useEffect)(()=>n(qh()),[]),(0,Ir.useEffect)(()=>{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=Ru();l&&e(l),Pu({force:!0}),o(!1),i(!0)};return(0,Y.jsxs)(Yn,{label:"TradingView",children:[(0,Y.jsx)("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."}),(0,Y.jsxs)("button",{className:ne("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:[(0,Y.jsx)(Xd,{size:11}),r?"Click again to overwrite your current settings":"Import TradingView settings"]})]})}function g6({active:e}){let[t,n]=(0,Ir.useState)(sd),[r,o]=(0,Ir.useState)(0),[a,i]=(0,Ir.useState)(!1);(0,Ir.useEffect)(()=>{e&&o(cd())},[e,t]),(0,Ir.useEffect)(()=>{if(!a)return;let c=setTimeout(()=>i(!1),4e3);return()=>clearTimeout(c)},[a]);let s=()=>{let c=!t;tp(c),n(c)},l=()=>{if(!a){i(!0);return}rp(),i(!1),o(cd())};return(0,Y.jsxs)(Yn,{label:"Saved data",children:[(0,Y.jsx)(Ar,{label:"Save settings to this device",active:t,onToggle:s}),(0,Y.jsx)("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?` (${b6(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."}),(0,Y.jsxs)("button",{className:ne("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:[(0,Y.jsx)(Mo,{size:11}),a?"Click again to erase \u2014 this cannot be undone":"Clear saved data"]})]})}function b6(e){return e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`}function Yn({label:e,children:t}){return(0,Y.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,Y.jsx)("p",{className:"text-[11px] font-medium text-white/40 uppercase tracking-wider",children:e}),t]})}function al({onReset:e}){return(0,Y.jsxs)("button",{className:"flex items-center gap-2 text-[11px] text-white/30 hover:text-white/60 transition-colors mt-1",onClick:e,children:[(0,Y.jsx)(ha,{size:11})," Reset to defaults"]})}function Ar({label:e,active:t,onToggle:n}){return(0,Y.jsxs)("button",{className:ne("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:[(0,Y.jsx)("span",{className:"text-[12px]",children:e}),(0,Y.jsx)(so,{checked:t,onCheckedChange:n,className:"data-[state=checked]:bg-blue-500"})]})}function ic({active:e,onClick:t,children:n}){return(0,Y.jsx)("button",{className:ne("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 wa({label:e,value:t,onChange:n}){return(0,Y.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-lg border border-white/6 bg-white/3",children:[(0,Y.jsx)("span",{className:"text-[12px] text-white/60",children:e}),(0,Y.jsx)("div",{className:"flex items-center gap-2",children:(0,Y.jsx)(Ho,{onChange:n,value:t,className:"w-8 h-8 rounded-md border-2 border-border/50"})})]})}var DR=Ct(require("react"));var LR=Ct(require("react"),1);var RR=require("react/jsx-runtime"),y6=Object.defineProperty,MR=(e,t)=>y6(e,"name",{value:t,configurable:!0}),IR="horizontal",v6=["horizontal","vertical"],w6=LR.forwardRef(MR(function(t,n){let{decorative:r,orientation:o=IR,...a}=t,i=PR(o)?o:IR,l=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return(0,RR.jsx)(hn.div,{"data-orientation":i,...l,...a,ref:n})},"Separator"));function PR(e){return v6.includes(e)}MR(PR,"isValidOrientation");var kv=w6;var AR=require("react/jsx-runtime"),sc=DR.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>(0,AR.jsx)(kv,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));sc.displayName=kv.displayName;var Bn=require("react");var S6={ms:1000000n,s:1000000000n,m:60000000000n,h:3600000000000n},C6=/^(\d+)(ms|s|m|h)$/,k6=5000000000n;function Uh(e){let t=C6.exec(e);return t?BigInt(t[1])*S6[t[2]]:k6}function T6(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 I6(e){let t=Date.now()-e.wallStart;if(e.mode==="step"){let r=Uh(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 BR(e){return e.mode==="step"?Number(Uh(e.stepSize))*e.speed/1e3:e.speed*1e6}var M6=5,L6=14n*24n*60n*60n*1000000000n;function NR({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=(0,Bn.useRef)(i);(0,Bn.useEffect)(()=>{c.current=i});let u=(0,Bn.useCallback)(V=>{if(V===void 0)return!0;let q=c.current?.();return q===void 0||V===q},[]),d=(0,Bn.useRef)(T6(0n,0n)),m=(0,Bn.useRef)(!1),[f,h]=(0,Bn.useState)({mode:"realtime",status:"paused",stepSnap:!1,speed:1,stepSize:"5s",datasetStart:0n,datasetEnd:0n}),p=(0,Bn.useRef)(n);(0,Bn.useEffect)(()=>{p.current=n});let g=(0,Bn.useRef)(!1),y=(0,Bn.useRef)(!1),v=(0,Bn.useRef)(null),b=(0,Bn.useRef)(null),S=(0,Bn.useRef)(600),C=(0,Bn.useRef)(null);(0,Bn.useEffect)(()=>{let V=[o.on("data:prefetch-done",()=>{if(g.current=!1,C.current!==null){let q=performance.now()-C.current;C.current=null,S.current=S.current*.7+q*.3}}),o.on("data:no-more-forward",q=>{u(q?.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 q=d.current;q.status==="playing"&&(q.dataStart=v.current,q.wallStart=Date.now()),v.current=null}})];return()=>V.forEach(q=>q())},[o]);let w=(0,Bn.useRef)(r);(0,Bn.useEffect)(()=>{w.current=r});let k=(0,Bn.useCallback)((V,q=!1)=>{t.current=V;let j=e.current;for(let W=0;W<j.length;W++)j[W]?.seekHorizon(V,q);w.current?.(V)},[e,t]),M=(0,Bn.useCallback)(V=>{if(g.current||m.current)return;g.current=!0,C.current=performance.now();let q=V;if(q===void 0){let j=d.current,W=BR(j);q=W>0?BigInt(Math.ceil(W*S.current*M6)):0n;let $=j.dataEnd-j.loadedStart;$>0n&&q>$&&(q=$)}p.current?.(q&&q>0n?q:void 0)},[]),I=(0,Bn.useCallback)(V=>{let q=d.current;if(V>=q.loadedStart&&V<=q.dataEnd){b.current=null,k(V,!0);return}if(V>q.dataEnd&&V-q.dataEnd<=L6){if(m.current){b.current=null,k(q.dataEnd,!0);return}let j=V-q.dataEnd;b.current=V,M(j+j/8n);return}y.current||(y.current=!0,b.current=null,o.emit("data:seek-load",{tNs:V,fromNs:t.current}))},[k,M,o,t]),x=(0,Bn.useCallback)(()=>{let V=d.current;V.rafHandle&&(cancelAnimationFrame(V.rafHandle),V.rafHandle=0)},[]),T=(0,Bn.useCallback)(()=>{x(),d.current.status="paused",h(V=>({...V,status:"paused"})),k(t.current)},[x,k,t]),R=(0,Bn.useCallback)(()=>{let V=()=>{let q=d.current;if(q.status!=="playing")return;let j=I6(q);if(j<q.dataEnd){q._stallStart=void 0;let J=BR(q);if(J>0){let me=Number(q.dataEnd-j)/J,We=Math.max(l,S.current*s);me<We&&M()}k(j),q.rafHandle=requestAnimationFrame(V);return}if(m.current){k(q.dataEnd),T(),o.emit("playback:pause",void 0),o.emit("playback:end",void 0);return}let W=j-q.dataEnd,$=(q.dataEnd-q.loadedStart)/2n;if($>0n&&W>$){y.current||(y.current=!0,v.current=j,o.emit("data:seek-load",{tNs:j,fromNs:q.dataEnd})),k(q.dataEnd),q.rafHandle=requestAnimationFrame(V);return}k(q.dataEnd),q.dataStart=q.dataEnd,q.wallStart=Date.now(),M(),q._stallStart===void 0&&(q._stallStart=Date.now()),q.rafHandle=requestAnimationFrame(V)};d.current.rafHandle=requestAnimationFrame(V)},[k,T,o,M,s,l]),P=(0,Bn.useCallback)((V,q)=>{let j=d.current;j.datasetStart===0n&&(j.datasetStart=V,t.current===0n&&(t.current=V)),j.loadedStart=V;let W=q>j.dataEnd;if(j.dataEnd=q,W&&(m.current=!1),j._stallStart!==void 0&&W&&(j._stallStart=void 0,j.wallStart=Date.now(),j.dataStart=t.current),b.current!==null&&W){let $=b.current;b.current=null,k($<=j.dataEnd?$:j.dataEnd,!0)}h($=>({...$,datasetStart:j.datasetStart,datasetEnd:j.dataEnd}))},[t,k]),D=(0,Bn.useCallback)(()=>{let V=d.current;if(!V.dataEnd)return;x();let q=t.current;V.status="playing",V.wallStart=Date.now(),V.dataStart=q,V.lastBaseRedrawWall=0,V._lastRafTime=void 0,V._stallStart=void 0,h(j=>({...j,status:"playing"})),R()},[R,x,t]),N=(0,Bn.useCallback)(()=>{d.current.status==="playing"&&T();let V=d.current,q=Uh(V.stepSize),j=t.current,W=V.stepSnap&&V.mode==="step"?j/q*q+q:j+q;I(W)},[T,I,t]),O=(0,Bn.useCallback)(()=>{d.current.status==="playing"&&T();let V=d.current,q=Uh(V.stepSize),j=t.current,W;if(V.stepSnap&&V.mode==="step"){let $=j/q*q;W=$<j?$:$-q}else W=j-q;I(W)},[T,I,t]),A=(0,Bn.useCallback)(()=>{d.current.status==="playing"&&T(),I(d.current.datasetStart)},[T,I]),B=(0,Bn.useCallback)(()=>{d.current.status==="playing"&&T(),I(d.current.dataEnd)},[T,I]),E=(0,Bn.useCallback)(V=>{let q=d.current,j=q.status==="playing";q.speed=V,h(W=>({...W,speed:V})),j&&(q.wallStart=Date.now(),q.dataStart=t.current)},[t]),L=(0,Bn.useCallback)(V=>{let q=d.current;q.stepSize=V,q.status==="playing"&&(q.wallStart=Date.now(),q.dataStart=t.current),h(j=>({...j,stepSize:V}))},[t]),H=(0,Bn.useCallback)(V=>{let q=d.current;q.mode=V,q.status==="playing"&&(q.wallStart=Date.now(),q.dataStart=t.current),h(j=>({...j,mode:V}))},[t]),K=(0,Bn.useCallback)(V=>{let q=d.current;q.stepSnap=V,q.status==="playing"&&(q.wallStart=Date.now(),q.dataStart=t.current),h(j=>({...j,stepSnap:V}))},[t]),G=(0,Bn.useCallback)(V=>{d.current.status==="playing"&&T(),I(V)},[T,I]);return(0,Bn.useEffect)(()=>()=>x(),[x]),{ui:f,notifyDataBounds:P,play:D,pause:T,stepForward:N,stepBack:O,jumpToStart:A,jumpToEnd:B,setSpeed:E,setStepSize:L,setMode:H,setStepSnap:K,scrub:G,pbRef:d}}var Au=Ct(require("react"),1),P6=Ct(require("react-dom"),1);function R6(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 ore=Array(12).fill(0);var D6=1,A6=100,ER=e=>{var t;return typeof e?.id=="number"||(e==null||(t=e.id)==null?void 0:t.length)>0?e.id:D6++},Tv=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-A6;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=ER(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],Au.default.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(N6(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"&&!Au.default.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"&&!Au.default.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"&&!Au.default.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"&&!Au.default.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=ER(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 Tv,B6=(e,t)=>Ka.message(e,t),N6=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",E6=B6,O6=()=>Ka.toasts,_6=()=>Ka.getActiveToasts(),xi=Object.assign(E6,{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:O6,getToasts:_6});R6("[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 cm=class cm{constructor(){se(this,"handlers",new Map);se(this,"interceptors",new Map);se(this,"emitting",new Set);se(this,"stickyCache",new Map)}on(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),cm.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){cm.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()}};se(cm,"STICKY",new Set(["account:update","playback:tick","trading:ticket-requested"]));var il=cm;var Br=require("react");var $t=require("react/jsx-runtime"),F6=150,z6=250;function Iv({eventBus:e,symbol:t,onSymbolChange:n}){let[r,o]=(0,Br.useState)(!1),[a,i]=(0,Br.useState)(!1),[s,l]=(0,Br.useState)(!1),[c,u]=(0,Br.useState)(!1),[d,m]=(0,Br.useState)([]),[f,h]=(0,Br.useState)(""),[p,g]=(0,Br.useState)(void 0),[y,v]=(0,Br.useState)(!1),[b,S]=(0,Br.useState)(null),[C,w]=(0,Br.useState)(new Set),k=(0,Br.useRef)(null),M=(0,Br.useRef)(null),I=(0,Br.useRef)(null),x=(0,Br.useRef)(!1),T=(0,Br.useRef)(0),R=()=>o(A=>!A),P=(0,Br.useCallback)((A,B)=>{let E=vn();I.current=E,x.current=!!B,B?l(!0):i(!0),S(null),e.emit("data:search-symbols",{requestId:E,request:{query:A,limit:F6,cursor:B}})},[e]);(0,Br.useEffect)(()=>{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:vn()}));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]),(0,Br.useEffect)(()=>{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]),(0,Br.useEffect)(()=>{if(!r)return;if(!T.current){P(f);return}let A=setTimeout(()=>P(f),T.current);return()=>clearTimeout(A)},[r,f,P]),(0,Br.useEffect)(()=>{if(!a){u(!1);return}let A=setTimeout(()=>u(!0),z6);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?sv(b.code,b.message):null;return(0,$t.jsxs)("div",{className:"relative",ref:k,children:[(0,$t.jsxs)("button",{onClick:R,className:ne("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:[(0,$t.jsx)("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:(0,$t.jsx)("span",{className:"block whitespace-nowrap text-[12px] font-semibold tracking-tight text-slate-100 uppercase leading-none",children:t})}),(0,$t.jsx)(or,{size:10,className:ne("shrink-0 ml-1 opacity-50 text-slate-400 transition-transform duration-150",r&&"rotate-180")})]}),r&&(0,$t.jsxs)("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:[(0,$t.jsxs)("div",{className:"flex items-center gap-2.5 px-3 h-11 border-b border-[#1e2128] shrink-0",children:[(0,$t.jsx)(li,{size:14,className:"text-slate-600 shrink-0"}),(0,$t.jsx)("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"})]}),(0,$t.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto py-1",children:O?(0,$t.jsxs)("div",{className:"flex flex-col items-center justify-center py-14 gap-1.5 px-8 text-center",children:[(0,$t.jsx)("span",{className:ne(O.tier==="error"?"text-rose-400/80":"text-slate-500"),children:O.icon}),(0,$t.jsx)("div",{className:"text-[13px] text-slate-300",children:O.title}),(0,$t.jsx)("div",{className:"text-[11px] text-slate-500 leading-relaxed",children:O.body}),O.canRetry&&(0,$t.jsx)("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?(0,$t.jsx)("div",{className:"flex items-center justify-center py-16 text-slate-600",children:(0,$t.jsx)(Pi,{size:18,className:"animate-spin"})}):!d.length&&!a?(0,$t.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-1 text-slate-600",children:[(0,$t.jsx)("div",{className:"text-[13px] text-slate-500",children:"No symbols found"}),f&&(0,$t.jsxs)("div",{className:"text-[11px]",children:['Nothing matches "',f.trim(),'"']})]}):(0,$t.jsxs)($t.Fragment,{children:[d.map(A=>(0,$t.jsx)(H6,{sym:A,active:A.symbol===t,expanded:C.has(A.id),onPick:D,onToggle:()=>N(A.id)},A.id)),y&&(0,$t.jsx)("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?(0,$t.jsx)(Pi,{size:12,className:"animate-spin"}):"Load more"})]})}),(0,$t.jsxs)("div",{className:"flex items-center gap-2 h-7 px-3 border-t border-[#1e2128] shrink-0",children:[(0,$t.jsxs)("span",{className:"text-[10px] text-slate-600 tabular-nums",children:[d.length,y?"+":""," ",d.length===1?"symbol":"symbols"]}),(a||s)&&(0,$t.jsx)(Pi,{size:10,className:"animate-spin text-slate-600"})]})]})]})}function H6({sym:e,active:t,expanded:n,onPick:r,onToggle:o}){let a=!!e.subsymbols?.length;return(0,$t.jsxs)($t.Fragment,{children:[(0,$t.jsxs)("button",{onClick:()=>r(e.symbol),className:ne("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?(0,$t.jsx)("div",{className:"w-1 h-1 rounded-full bg-[#08b3de] shrink-0"}):(0,$t.jsx)("div",{className:"w-1 shrink-0"}),e?.icon&&(0,$t.jsx)(Oh,{icon:e.icon,size:24,fallback:e.symbol}),(0,$t.jsx)("span",{className:ne("text-[12px] font-semibold uppercase tracking-tight w-24 shrink-0 truncate",t?"text-white":"text-slate-300"),children:e.symbol}),(0,$t.jsx)("span",{className:"text-[11px] text-slate-500 truncate flex-1 group-hover:text-slate-400",children:e.description??e?.longName??""}),e.type&&(0,$t.jsx)("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}),(0,$t.jsx)("span",{className:"text-[11px] text-slate-600 w-14 shrink-0 truncate",children:e.exchange??""}),a?(0,$t.jsx)("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:(0,$t.jsx)(or,{size:13,className:ne("transition-transform duration-150",n&&"rotate-180")})}):(0,$t.jsx)("span",{className:"w-6 shrink-0"})]}),a&&n&&e.subsymbols.map(i=>(0,$t.jsxs)("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:[(0,$t.jsx)("div",{className:"w-1 shrink-0"}),(0,$t.jsxs)("span",{className:"w-24 shrink-0 flex items-center gap-2",children:[(0,$t.jsx)("span",{className:"w-3 h-px bg-[#272b33] shrink-0"}),(0,$t.jsx)("span",{className:"text-[11px] font-medium uppercase tracking-tight text-slate-400 truncate group-hover:text-slate-200",children:i.symbol})]}),(0,$t.jsx)("span",{className:"text-[11px] text-slate-600 truncate flex-1 group-hover:text-slate-500",children:i.longName??i.description??""}),i.type&&(0,$t.jsx)("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}),(0,$t.jsx)("span",{className:"text-[11px] text-slate-600 w-14 shrink-0 truncate",children:i.exchange??""}),(0,$t.jsx)("span",{className:"w-6 shrink-0"})]},i.symbol))]})}var Mv=class{constructor(){se(this,"handlers",new Map);se(this,"charts",new Map);se(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)}},Bu=new Mv;var No=require("react");var Cn=require("react");var $a=require("react/jsx-runtime"),OR={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 V6({tone:e,icon:t,title:n,subtitle:r,metric:o,metricTone:a,metricSub:i}){let s=OR[e],l=OR[a??e];return(0,$a.jsxs)("div",{className:ne("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:[(0,$a.jsx)("span",{className:ne("grid size-9 shrink-0 place-items-center rounded-lg",s.chip,s.fg),children:(0,$a.jsx)(t,{className:"size-[18px]",strokeWidth:2.25,"aria-hidden":!0})}),(0,$a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,$a.jsx)("span",{className:"truncate text-[13px] font-medium leading-tight text-foreground",children:n}),r!=null&&(0,$a.jsx)("span",{className:"truncate text-[12px] leading-tight text-muted-foreground",children:r})]}),o!=null&&(0,$a.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-0.5 pl-1",children:[(0,$a.jsx)("span",{className:ne("text-[13px] font-semibold leading-tight tabular-nums",l.fg),children:o}),i!=null&&(0,$a.jsx)("span",{className:"text-[11px] leading-tight tabular-nums text-muted-foreground",children:i})]})]})}function jh(e,t=4200){return xi.custom(()=>(0,$a.jsx)(V6,{...e}),{duration:t,position:"bottom-left",style:{background:"transparent",border:"none",boxShadow:"none",padding:0}})}var W6=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",signDisplay:"always",minimumFractionDigits:2,maximumFractionDigits:2});function q6(e){return W6.format(e)}function U6(e){return`${e>=0?"+":""}${e.toFixed(2)}R`}function j6(e){if(!e||e<=0)return 2;let t=e.toString(),n=t.indexOf(".");return n===-1?0:t.length-n-1}function _R(e,t){let n=j6(t);return e.toLocaleString("en-US",{minimumFractionDigits:n,maximumFractionDigits:n})}function FR(e){return e==="long"?"Long":e==="short"?"Short":"Position"}function G6(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 zR(e){let t=FR(e.side),n=e.qty===1?"contract":"contracts";jh({tone:"success",icon:e.side==="short"?_d:Hd,title:`${t} ${e.symbol} opened`,subtitle:`Filled ${e.qty} ${n} @ ${_R(e.entryPrice,e.tickSize)}`})}function HR(e){let t=e.partial??!1,n=e.pnl>.005?"success":e.pnl<-.005?"loss":"neutral",r=FR(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;jh({tone:n,icon:n==="success"?Ol:n==="loss"?wf:Jo,title:o,subtitle:G6(e.reason,t),metric:q6(e.pnl),metricTone:n,metricSub:a?U6(e.rMultiple):void 0})}function VR(e,t){let n=t?.tone??"neutral";jh({tone:n,icon:n==="success"?Ns:n==="loss"?ga:n==="info"?Yc:Yc,title:e,subtitle:t?.description})}function Nu(e){let t=e.kind==="tp"?{icon:yf,noun:"Take-profit"}:e.kind==="sl"?{icon:gf,noun:"Stop-loss"}:{icon:Jo,noun:"Break-even"},n=e.kind==="be"||e.created?"set":"moved";jh({tone:"success",icon:t.icon,title:`${t.noun} ${n}`,subtitle:`${e.symbol} @ ${_R(e.price,e.tickSize)}`},2800)}function Gh(e){let t=e.toUpperCase();return t.includes("MNQ")?2:t.includes("MES")?5:t.includes("NQ")?20:t.includes("ES")?50:1}function Eu(e,t,n){return(e.side==="long"?1:-1)*(t-e.entryPrice)*e.remainingQuantity*n}function um(e,t,n){return e.entryPrice===0?0:Eu(e,t,n)/(e.entryPrice*e.remainingQuantity)}function WR(e,t=2){return`${e>=0?"+":""}$${Math.abs(e).toFixed(t)}`}var lr={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 UR(e){return e.reduce((t,n)=>t+n.qty,0)}function Y6(e,t){let n=t==="tp"?e.takeProfits:e.stopLosses,r=UR(n??[]);return Math.max(1,e.remainingQuantity-r)}function K6(e,t){let n=t==="tp"?e.bracket?.takeProfits:e.bracket?.stopLosses,r=UR(n??[]);return Math.max(1,e.quantity-r)}function qR(e){return(e.type==="limit"||e.type==="stop_limit"&&e.triggered?e.price:e.stopPrice)||e.price||e.stopPrice||0}function Lv(e,t){return e??Gh(t)}function dm(e,t,n,r,o){return o*r*(e==="short"?t-n:n-t)}function fm(e){return(e>=0?"+$":"-$")+Math.abs(e).toFixed(2)}function jR(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=(0,Cn.useRef)(new Map),p=(0,Cn.useRef)(new Map),g=(0,Cn.useRef)([]),y=(0,Cn.useRef)(new Map),v=(0,Cn.useRef)(new Map),b=(0,Cn.useRef)(0),S=(0,Cn.useRef)(null),C=(0,Cn.useRef)(null),w=(0,Cn.useCallback)(F=>{C.current=F},[]),k=(0,Cn.useCallback)(F=>({setLabel(le){let ce=y.current.get(F);ce&&y.current.set(F,{...ce,label:le}),C.current?.()},setPrice(le){let ce=y.current.get(F);ce&&y.current.set(F,{...ce,price:le}),C.current?.()},patch(le){let ce=y.current.get(F);ce&&y.current.set(F,{...ce,...le}),C.current?.()}}),[]),[M,I]=(0,Cn.useState)([]),x=(0,Cn.useCallback)(F=>{t?.(F)},[t]),T=(0,Cn.useRef)(!1),R=(0,Cn.useCallback)(()=>{T.current||(T.current=!0,queueMicrotask(()=>{T.current=!1,I([...y.current.values()])}))},[]),P=(0,Cn.useCallback)(F=>{let le=v.current.get(F.symbol);return le?a==="bid"?le.bid:a==="ask"?le.ask:a==="last"?le.last??(le.bid+le.ask)/2:a==="mid"?(le.bid+le.ask)/2:F.side==="long"?le.bid:le.ask:F.currentPrice},[a]),D=(0,Cn.useCallback)((F,le,ce,ke)=>{let De=h.current.get(F);if(!De)return;let ve=De.bracket?.takeProfits??[],Qe=De.bracket?.stopLosses??[],Ye={...De,bracket:{...De.bracket,takeProfits:le==="tp"?ve.map((Oe,Tt)=>Tt===ce?{...Oe,price:ke}:Oe):ve,stopLosses:le==="sl"?Qe.map((Oe,Tt)=>Tt===ce?{...Oe,price:ke}:Oe):Qe},updatedAt:v.current.get(De.symbol).ts};h.current.set(F,Ye);let $e=le==="tp"?lr.orderTp(F,ce):lr.orderSl(F,ce),bt=y.current.get($e);bt&&y.current.set($e,{...bt,price:ke}),s(Ye),R()},[R]),N=(0,Cn.useCallback)((F,le,ce,ke,De)=>{let ve=F==="tp"?lr.orderTp(le.id,De):lr.orderSl(le.id,De),Qe=k(ve),Ye=F==="tp"?le.bracket?.takeProfits:le.bracket?.stopLosses,$e=`${F.toUpperCase()}${(Ye?.length??0)>1?De+1:""}`,bt=qR(le),Oe=Tt=>`${$e} ${fm(dm(le.side,bt,Tt,ke,Lv(o,le.symbol)))}`;return{id:ve,kind:F,side:le.side,price:ce,label:Oe(ce),qty:ke,opacity:.38,lineDash:[1.5,3],badges:["PENDING"],tickSize:r,movable:!0,locked:!1,showPricePill:!0,showLinePill:!0,onMove:Tt=>Qe.setLabel(Oe(Tt)),afterMove:Tt=>D(le.id,F,De,Tt)}},[r,o,D,k]),O=(0,Cn.useCallback)((F,le,ce,ke)=>N("tp",F,le,ce,ke),[N]),A=(0,Cn.useCallback)((F,le,ce,ke)=>N("sl",F,le,ce,ke),[N]),B=(0,Cn.useCallback)((F,le=!1)=>{let ce=`order-tp:${F.id}:`,ke=`order-sl:${F.id}:`;for(let Qe of y.current.keys())(Qe.startsWith(ce)||Qe.startsWith(ke))&&y.current.delete(Qe);if(le)return;let De=F.bracket?.takeProfits??[],ve=F.bracket?.stopLosses??[];De.forEach(({price:Qe,qty:Ye},$e)=>{y.current.set(lr.orderTp(F.id,$e),O(F,Qe,Ye,$e))}),ve.forEach(({price:Qe,qty:Ye},$e)=>{y.current.set(lr.orderSl(F.id,$e),A(F,Qe,Ye,$e))})},[O,A]),E=(0,Cn.useCallback)(F=>{let le=qR(F),ce=F.status==="working"||F.status==="partial"||F.status==="pending",ke=F.type==="limit"?"limit":F.type==="stop"?"stop":F.type==="stop_limit"?"stop_limit":"alert",De=F.side==="short"?"Sell":"Buy",ve=F.type==="limit"?"Limit":F.type==="stop"?"Stop":F.type==="stop_limit"?"Stop Limit":"Market",Qe=[`${F.filledQuantity}/${F.quantity}`];F.tif&&Qe.push(F.tif.toUpperCase());let Ye=F.bracket?.takeProfits?.length??0,$e=F.bracket?.stopLosses?.length??0;return{id:lr.order(F.id),kind:ke,side:F.side,price:le,label:`${De} ${ve}`,qty:F.quantity,badges:Qe,ghosts:ce,numGhosts:Math.max(Ye,$e)+1,tickSize:r,movable:ce&&!!l,locked:!ce,visible:ce,showPricePill:!0,showLinePill:!0,afterMove:l?bt=>l(F.id,bt):void 0,onClose:u?()=>u(F.id):void 0,onContextMenu:f?(bt,Oe)=>f("order",F.id,bt,Oe):void 0}},[r,l,u,f]),L=(0,Cn.useCallback)(F=>{let le=P(F),ce=o,ke=le!=null?Eu(F,le,ce):F.unrealizedPnl,De=le!=null?um(F,le,ce):F.unrealizedPnlPct,ve=ke?`${WR(ke)}`:"",Qe=le,Ye=F.takeProfits?.length??0,$e=F.stopLosses?.length??0,bt=Math.max(Ye,$e)+1,Oe=F.side==="long"?"Buy":"Sell",Tt=F.type==="limit"?"Limit":F.type==="stop"?"Stop":F.type==="stop_limit"?"Stop Limit":"Market";return{id:lr.position(F.id),kind:"entry",side:F.side,price:F.entryPrice,label:`${Oe} ${Tt}`,qty:F.remainingQuantity,pnl:ke,pnlPct:De,pnlLabel:ve,entryPrice:F.entryPrice,bandToPrice:Qe,bandOpacity:.06,ghosts:!0,numGhosts:bt,tickSize:r,movable:!1,locked:!1,showPricePill:!0,showLinePill:!0,showPnlPill:ke!=null,onClose:d?()=>d(F.id):void 0,onReverse:m?()=>m(F.id):void 0,onContextMenu:f?(bn,En)=>f("position",F.id,bn,En):void 0}},[P,n,r,o,d,m,f]),H=(0,Cn.useCallback)((F,le,ce)=>{let ke=lr.tp(F.id,ce),De=k(ke),ve=Lv(o,F.symbol),Qe=Math.min(F.remainingQuantity,le.qty),Ye=fm(dm(F.side,F.entryPrice,le.price,Qe,ve));return{id:ke,kind:"tp",side:F.side,price:le.price,label:`TP ${Ye}`,qty:le.qty,tickSize:r,movable:!!c,showPricePill:!0,showLinePill:!0,onMove:$e=>{let bt=Math.min(F.remainingQuantity,le.qty);De.setLabel(`TP ${fm(dm(F.side,F.entryPrice,$e,bt,ve))}`)},afterMove:c?$e=>{c({positionId:F.id,which:"tp",index:ce,levelId:le.id??String(ce),price:$e,qty:le.qty}),Nu({kind:"tp",symbol:F.symbol,price:$e,tickSize:r})}:void 0,onClose:()=>q(F,"tp",ce,le),onContextMenu:f?($e,bt)=>f("position",F.id,$e,bt):void 0}},[r,c,f,k]),K=(0,Cn.useCallback)((F,le,ce)=>{let ke=lr.sl(F.id,ce),De=k(ke),ve=Lv(o,F.symbol),Qe=Math.min(F.remainingQuantity,le.qty),Ye=fm(dm(F.side,F.entryPrice,le.price,Qe,ve));return{id:ke,kind:"sl",side:F.side,price:le.price,label:`SL ${Ye}`,qty:le.qty,tickSize:r,movable:!!c,showPricePill:!0,showLinePill:!0,onMove:$e=>{let bt=Math.min(F.remainingQuantity,le.qty);De.setLabel(`SL ${fm(dm(F.side,F.entryPrice,$e,bt,ve))}`)},afterMove:c?$e=>{c({positionId:F.id,which:"sl",index:ce,levelId:le.id??String(ce),price:$e,qty:le.qty}),Nu({kind:"sl",symbol:F.symbol,price:$e,tickSize:r})}:void 0,onClose:()=>q(F,"sl",ce,le),onContextMenu:f?($e,bt)=>f("position",F.id,$e,bt):void 0}},[r,c,f,k]),G=(0,Cn.useCallback)(F=>F.bePrice==null?null:{id:lr.be(F.id),kind:"be",side:F.side,price:F.bePrice,label:"BE",qty:F.remainingQuantity,tickSize:r,movable:!!c,showPricePill:!0,showLinePill:!0,afterMove:c?le=>{c({positionId:F.id,which:"be",index:0,levelId:"be",price:le,qty:F.remainingQuantity}),Nu({kind:"be",symbol:F.symbol,price:le,tickSize:r})}:void 0},[r,c]),V=(0,Cn.useCallback)(F=>{if(F.side==="flat"||F.remainingQuantity<=0){y.current.delete(lr.position(F.id)),y.current.delete(lr.be(F.id));let De=`tp:${F.id}:`,ve=`sl:${F.id}:`;for(let Qe of y.current.keys())(Qe.startsWith(De)||Qe.startsWith(ve))&&y.current.delete(Qe);return}let le=(De,ve)=>{if(De===S.current){let Qe=y.current.get(De);if(Qe){y.current.set(De,{...ve,price:Qe.price,label:Qe.label});return}}y.current.set(De,ve)};y.current.set(lr.position(F.id),L(F));let ce=F.takeProfits??[];ce.forEach((De,ve)=>{le(lr.tp(F.id,ve),H(F,De,ve))});for(let De=ce.length;;De++){let ve=lr.tp(F.id,De);if(!y.current.has(ve))break;y.current.delete(ve)}let ke=F.stopLosses??[];ke.forEach((De,ve)=>{le(lr.sl(F.id,ve),K(F,De,ve))});for(let De=ke.length;;De++){let ve=lr.sl(F.id,De);if(!y.current.has(ve))break;y.current.delete(ve)}if(F.bePrice==null)y.current.delete(lr.be(F.id));else{let De=G(F);De&&le(lr.be(F.id),De)}},[L,H,K,G]),q=(0,Cn.useCallback)((F,le,ce,ke)=>{if(c){c({positionId:F.id,which:le,index:ce,levelId:ke.id??String(ce),price:ke.price,qty:ke.qty,remove:!0});return}let De=p.current.get(F.id);if(!De)return;let ve={...De,takeProfits:le==="tp"?(De.takeProfits??[]).filter((Qe,Ye)=>Ye!==ce):De.takeProfits,stopLosses:le==="sl"?(De.stopLosses??[]).filter((Qe,Ye)=>Ye!==ce):De.stopLosses,updatedAt:v.current.get(De.symbol).ts};p.current.set(F.id,ve),V(ve),R()},[c,V,R]),j=(0,Cn.useCallback)(F=>{let le=h.current.get(F.id);h.current.set(F.id,F);let ce=F.status==="filled"||F.status==="cancelled"||F.status==="rejected";ce?(y.current.delete(lr.order(F.id)),B(F,!0)):(y.current.set(lr.order(F.id),E(F)),B(F)),le?ce&&F.status==="filled"||(ce&&F.status==="cancelled"?x({kind:"order:cancelled",order:F}):ce&&F.status==="rejected"?x({kind:"order:rejected",order:F}):x({kind:"order:updated",order:F})):x({kind:"order:placed",order:F}),R()},[E,B,x,R]),W=(0,Cn.useCallback)(F=>{let le=h.current.get(F);h.current.delete(F),y.current.delete(lr.order(F)),le&&B(le,!0),R()},[B,R]),$=(0,Cn.useCallback)(F=>{g.current.push(F);let le=h.current.get(F.orderId);le?.status==="filled"&&x({kind:"order:filled",order:le,fill:F}),x({kind:"fill:received",fill:F}),R()},[x,R]),J=(0,Cn.useCallback)(F=>{let le=p.current.get(F.id),ce=F.side==="flat"||F.remainingQuantity<=0;if(p.current.set(F.id,F),V(F),le)ce?(x({kind:"position:closed",position:F,realizedPnl:F.realizedPnl??0}),p.current.delete(F.id)):x({kind:"position:updated",position:F});else{x({kind:"position:opened",position:F});let ke=F.status==="open"&&(F.closes?.length??0)===0;!ce&&ke&&zR({side:F.side,symbol:F.symbol,qty:F.startingQuantity,entryPrice:F.entryPrice,tickSize:r})}R()},[V,x,R,r]),me=(0,Cn.useCallback)((F,le)=>{let ce=le?.tone==="profit"?"success":le?.tone==="loss"?"loss":"neutral";VR(F,{description:le?.description,tone:ce})},[]),We=(0,Cn.useCallback)(F=>{p.current.delete(F),y.current.delete(lr.position(F)),y.current.delete(lr.be(F));let le=`tp:${F}:`,ce=`sl:${F}:`;for(let ke of y.current.keys())(ke.startsWith(le)||ke.startsWith(ce))&&y.current.delete(ke);R()},[R]),Ce=(0,Cn.useCallback)(F=>{v.current.set(F.symbol,F);let le=!1;for(let ce of p.current.values())ce.symbol===F.symbol&&(ce.side==="flat"||ce.remainingQuantity<=0||(V(ce),le=!0));le&&(cancelAnimationFrame(b.current),b.current=requestAnimationFrame(()=>R()))},[V,R]),Ee=(0,Cn.useCallback)(F=>{let le=new Set(F.map(ce=>ce.id));for(let[ce,ke]of h.current.entries())le.has(ce)||(y.current.delete(lr.order(ce)),B(ke,!0));h.current.clear();for(let ce of F)h.current.set(ce.id,ce),ce.status==="filled"||ce.status==="cancelled"||ce.status==="rejected"||(y.current.set(lr.order(ce.id),E(ce)),B(ce));R()},[E,B,R]),ze=(0,Cn.useCallback)(F=>{let le=new Set(F.map(ce=>ce.id));for(let ce of p.current.keys())if(!le.has(ce)){y.current.delete(lr.position(ce)),y.current.delete(lr.be(ce));let ke=`tp:${ce}:`,De=`sl:${ce}:`;for(let ve of y.current.keys())(ve.startsWith(ke)||ve.startsWith(De))&&y.current.delete(ve)}p.current.clear();for(let ce of F)p.current.set(ce.id,ce),V(ce);R()},[V,R]),Ie=(0,Cn.useCallback)(()=>{h.current.clear(),p.current.clear(),g.current=[],y.current.clear(),v.current.clear(),R()},[R]),ee=(0,Cn.useCallback)((F,le,ce)=>{let ke=h.current.get(F);if(!ke){console.warn("[useTradingState] handleGhostMove: order not found",F);return}let De=ke.bracket?.takeProfits??[],ve=ke.bracket?.stopLosses??[],Qe={id:vn(),price:ce,qty:K6(ke,le),triggered:!1,triggeredAt:0},Ye={...ke,bracket:{...ke.bracket,takeProfits:le==="tp"?[...De,Qe]:De,stopLosses:le==="sl"?[...ve,Qe]:ve},updatedAt:v.current.get(ke.symbol)?.ts??ke.updatedAt};h.current.set(F,Ye),y.current.set(lr.order(F),E(Ye)),B(Ye),s?.(Ye),R(),Nu({kind:le,symbol:ke.symbol,price:ce,tickSize:r,created:!0})},[E,B,R,s,r]),Be=(0,Cn.useCallback)((F,le,ce,ke)=>{if(F.startsWith("order:")){ee(F.slice(6),le,ke);return}let De=F.replace(/^position:/,""),ve=p.current.get(De);if(!ve){console.warn("[useTradingState] handleGhostMove: position not found",De);return}let Qe=le==="tp"?ve.takeProfits??[]:ve.stopLosses??[],Ye,$e=Y6(ve,le),bt=vn();Ye=[...Qe,{id:bt,price:ke,qty:$e,triggered:!1,triggeredAt:0}];let Oe={...ve,takeProfits:le==="tp"?Ye:ve.takeProfits,stopLosses:le==="sl"?Ye:ve.stopLosses,updatedAt:v.current.get(ve.symbol).ts};p.current.set(De,Oe),V(Oe),i(Oe),R();let Tt=Ye.length-1;c?.({positionId:De,which:le,index:Tt,levelId:bt,price:ke,qty:Ye[Tt].qty}),Nu({kind:le,symbol:ve.symbol,price:ke,tickSize:r,created:!0})},[ee,V,R,c,i,r]);return{orders:h.current,positions:p.current,fills:g.current,tradeLines:M,linesRef:y,registerRedraw:w,upsertOrder:j,removeOrder:W,applyFill:$,upsertPosition:J,toast:me,removePosition:We,tick:Ce,syncOrders:Ee,syncPositions:ze,reset:Ie,handleGhostMove:Be,draggingLineIdRef:S}}var Dv={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}},$6=Object.keys(Dv).filter(e=>e!=="DEFAULT").sort((e,t)=>t.length-e.length);function X6(e){let t=e.toUpperCase();for(let n of $6)if(t.includes(n))return Dv[n];return Dv.DEFAULT}function $R(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=X6(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 mm={exchangeFeePerContract:.85,commissionPerContract:2.25,nfaFeePerContract:.02,clearingFeePerContract:.35},Av={exchangeFeePerContract:.25,commissionPerContract:.5,nfaFeePerContract:.02,clearingFeePerContract:.1},XR={exchangeFeePerContract:0,commissionPerContract:0,nfaFeePerContract:0,clearingFeePerContract:0},Z6=5;function Kh(e){if(e?.type!=="future")return mm;let t=e.contract?.multiplier;return t!==void 0&&t<=Z6?Av:mm}function GR(e,t){return t.commissionPerContract*e}function YR(e,t){return(t.exchangeFeePerContract+t.nfaFeePerContract+t.clearingFeePerContract)*e}var Yh=class{constructor(){se(this,"prices",[]);se(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}}},Bv={enabled:!0,maxResolution:e=>{let t=86400000000000n;return e<=t?60000000000n:e<=7n*t?300000000000n:e<=31n*t?3600000000000n:86400000000000n},ambiguity:"pessimistic"};function Rv(e){let t=e.openFee+e.openCommission,n=e.quantity>0?t/e.quantity:0,{initialRR:r,initialRiskPerUnit:o,initialRiskLockedAt:a}=ZR(e.side,e.entryPrice,e.takeProfits,e.stopLosses,e.openedAt);return{id:vn(),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:$R(e.metadata,e.symbol,e.quantity,e.symbolInfo)}}function ZR(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 KR(e,t){if(e.initialRiskLockedAt>0||e.side==="flat")return e;let{initialRR:n,initialRiskPerUnit:r,initialRiskLockedAt:o}=ZR(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 Pv(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 $h(e,t={}){let{symbolInfo:n=null,tickSize:r=.25,fees:o=mm,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??Gh(c),m=new Yh,f=new Yh,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(z){let ae=new Map;for(let U=1;U<z.length;U++){let be=z[U].tsNs-z[U-1].tsNs;be<=0n||ae.set(be,(ae.get(be)??0)+1)}let fe=0n,de=0;for(let[U,be]of ae)be>de&&(fe=U,de=be);return fe}function E(z){if(z.status==="closed"||z.remainingQuantity<=0){b.delete(z.id);return}b.set(z.id,z),K.add(z.id),V=!0}function L(z){let ae=!C.has(z.id);if(C.set(z.id,z),z.status==="filled"||z.status==="cancelled"||z.status==="rejected"){v.delete(z.id);return}ae&&(K.add(z.id),V=!0);let de={...v.get(z.id),order:z,bracketSl:z.bracket?.stopLosses??[],bracketTp:z.bracket?.takeProfits??[]};v.set(z.id,de)}function H(z,ae,fe){let de=z.getLevel(ae);if(!de)return 0;let U=de.orders.get(fe)??0;return de.orders.delete(fe),de.totalSize=Math.max(0,de.totalSize-U),de.totalSize===0&&z.removeLevel(ae),U}let K=new Set,G=null,V=!1;function q(z){V&&(V=!1,(G===null||z>G)&&(G=z))}function j(z,ae){return G===null||!K.has(z)?!1:ae<G}function W(z,ae,fe){for(let[de,U]of v){let{order:be}=U;if(j(de,fe)||!(be.type==="limit"||be.type==="stop_limit"&&be.triggered))continue;let je=be.price;(be.side==="long"?z<=je:ae>=je)&&(ce(U,je,fe),v.delete(de))}}function $(z,ae,fe){let de=Number(fe);for(let[U,be]of v){let{order:he}=be;if(j(U,fe)||he.type!=="stop"&&he.type!=="stop_limit"||he.type==="stop_limit"&&he.triggered)continue;let je=he.stopPrice;if(!(he.side==="long"?ae>=je:z<=je))continue;let yt=s*r;if(he.type==="stop"){let xt=Tt(he.side==="long"?je+yt:je-yt);ce(be,xt,fe),v.delete(U)}else{let xt=he.price??je,ht={...he,triggered:!0,status:"working",updatedAt:de};v.delete(U),v.set(U,{order:ht,queueAhead:0,tradedThrough:0,bracketTp:be.bracketTp,bracketSl:be.bracketSl}),C.set(ht.id,ht),e.upsertOrder(ht),W(z,xt,fe)}}}function J(z,ae,fe,de="pessimistic"){let U=Number(fe);for(let be of b.values()){if(be.remainingQuantity<=0||j(be.id,fe))continue;let he=Pv(be,z,ae);b.set(be.id,he);let je=()=>{for(let yt of he.takeProfits){if(yt.triggered||!(he.side==="long"?ae>=yt.price:z<=yt.price))continue;let ht=b.get(be.id);if(!ht||ht.remainingQuantity<=0)break;$e(ht,Math.min(yt.qty,ht.remainingQuantity),yt.price,U,"tp",yt.id,void 0)}},rt=()=>me(he,z,ae,U);de==="pessimistic"?(rt(),je()):(je(),rt())}}function me(z,ae,fe,de){for(let U of z.stopLosses){if(U.triggered||!(z.side==="long"?ae<=U.price:fe>=U.price))continue;let he=b.get(z.id);if(!he||he.remainingQuantity<=0)break;$e(he,he.remainingQuantity,U.price,de,"sl",void 0,U.id);break}}let We=Bv;function Ce(z){We={...We,...z}}function Ee(){return We}function ze(){if(v.size>0)return!0;for(let z of b.values())if(!(z.remainingQuantity<=0)&&(z.takeProfits.some(ae=>!ae.triggered)||z.stopLosses.some(ae=>!ae.triggered)))return!0;return!1}function Ie(z,ae=We.ambiguity){if(T)return;z.length&&q(z[0].tsNs);let fe=r/2,de=R;R=!0;try{for(let U of z){let be=Number(U.tsNs);En({symbol:c,bid:U.open-fe,ask:U.open+fe,last:U.open,ts:be}),W(U.low,U.high,U.tsNs),$(U.low,U.high,U.tsNs),J(U.low,U.high,U.tsNs,ae),U.close!==U.open&&En({symbol:c,bid:U.close-fe,ask:U.close+fe,last:U.close,ts:be})}}finally{R=de}}function ee(z,ae){if(T)return;let{action:fe,side:de,price:U,size:be,order_id:he}=z;if(fe==="R"){m.clear(),f.clear(),h.clear(),p.clear(),g=null,y=null;return}let je=de;(fe==="T"||fe==="F")&&(je=de==="B"?"A":"B");let rt=je==="B",yt=rt?m:f;if(fe==="A"){if(U===null)return;let xt=yt.getOrCreate(U),ht=xt.orders.get(he)??0;xt.totalSize=Math.max(0,xt.totalSize-ht)+be,xt.orders.set(he,be),rt?((g===null||U>g)&&(g=U),h.set(he,U)):((y===null||U<y)&&(y=U),p.set(he,U))}else if(fe==="C"){let xt=rt?h.get(he):p.get(he);if(xt===void 0)return;H(yt,xt,he)>0&&(rt?h.delete(he):p.delete(he),rt?g=m.getBest("bid"):y=f.getBest("ask"))}else if(fe==="M"){let xt=h.get(he),ht=p.get(he),Je=xt??ht;if(Je===void 0)return;let Rt=xt!==void 0,Jt=Rt?m:f,rn=Rt?h:p,Q=U!==null&&U!==0?U:Je;H(Jt,Je,he);let X=Jt.getOrCreate(Q);X.orders.set(he,be),X.totalSize+=be,rn.set(he,Q),Rt?g=m.getBest("bid"):y=f.getBest("ask")}else if(fe==="T"||fe==="F"){let xt=h.get(he),ht=p.get(he);xt!==void 0&&(H(m,xt,he),h.delete(he),g=m.getBest("bid")),ht!==void 0&&(H(f,ht,he),p.delete(he),y=f.getBest("ask")),U!==null&&(Be(U,be,de,ae),F(U,de,ae))}}function Be(z,ae,fe,de){for(let[U,be]of v){let{order:he}=be;if(j(U,de)||!(he.type==="limit"||he.type==="stop_limit"&&he.triggered))continue;let rt=he.price;if(he.side==="long"&&fe==="A")if(z<rt)be.tradedThrough=1/0;else if(z===rt)be.tradedThrough+=ae;else continue;else if(he.side==="short"&&fe==="B")if(z>rt)be.tradedThrough=1/0;else if(z===rt)be.tradedThrough+=ae;else continue;else continue;be.tradedThrough>=be.queueAhead&&(ce(be,rt,de),v.delete(U))}}function F(z,ae,fe){let de=Number(fe);for(let U of b.values()){if(U.remainingQuantity<=0||j(U.id,fe))continue;let be=Pv(U,z,z);b.set(U.id,be);for(let he of U.takeProfits){if(he.triggered||!(U.side==="long"?ae==="B"&&z>=he.price:ae==="A"&&z<=he.price))continue;let rt=b.get(U.id);if(!rt||rt.remainingQuantity<=0)break;let yt=Math.min(he.qty,rt.remainingQuantity);$e(rt,yt,he.price,de,"tp",he.id,void 0)}for(let he of U.stopLosses){if(he.triggered||!(U.side==="long"?ae==="A"&&z<=he.price:ae==="B"&&z>=he.price))continue;let rt=b.get(U.id);if(!rt||rt.remainingQuantity<=0)break;$e(rt,rt.remainingQuantity,he.price,de,"sl",void 0,he.id);break}}}function le(z){for(let[ae,fe]of v){let{order:de}=fe;if(de.type!=="stop"&&de.type!=="stop_limit"||de.type==="stop_limit"&&de.triggered)continue;let U=de.stopPrice;if(de.side==="long"?z.ask>=U:z.bid<=U)if(de.type==="stop"){let he=s*r,je=de.side==="long"?z.ask+he:z.bid-he;ce(fe,Tt(je),BigInt(z.ts)),v.delete(ae)}else{let he=de.price??U,je={...de,triggered:!0,status:"working",updatedAt:z.ts},yt=(de.side==="long"?m:f).getLevel(he)?.totalSize??0;v.delete(ae),v.set(ae,{order:je,queueAhead:yt,tradedThrough:0,bracketTp:fe.bracketTp,bracketSl:fe.bracketSl}),C.set(je.id,je),e.upsertOrder(je)}}}function ce(z,ae,fe){a<=0?ke(z,ae,fe):setTimeout(()=>ke(z,ae,fe),a)}function ke(z,ae,fe){if(T)return;let{order:de,bracketTp:U,bracketSl:be}=z,he=de.quantity-de.filledQuantity,je=YR(he,o),rt=GR(he,o),yt=je+rt;M+=yt;let xt=Number(fe),ht=de.avgPrice*de.filledQuantity,Je=ae*he,Rt=(ht+Je)/de.quantity,Jt={id:vn(),orderId:de.id,symbol:de.symbol,side:de.side,price:ae,quantity:he,ts:xt,fee:yt,feeCurrency:"USD"},rn={...de,filledQuantity:de.quantity,avgPrice:Rt,status:"filled",fees:je,commission:rt,updatedAt:xt};C.set(rn.id,rn),k.push(Jt),e.upsertOrder(rn),e.applyFill(Jt),ve(rn,ae,je,rt,U,be,xt)}function De(z){return S.has(z)||S.set(z,[]),S.get(z)}function ve(z,ae,fe,de,U,be,he){i==="net"?Qe(z,ae,fe,de,U,be,he):Ye(z,ae,fe,de,U,be,he)}function Qe(z,ae,fe,de,U,be,he){let je;for(let Rt of b.values())if(Rt.symbol===z.symbol){je=Rt;break}let rt=De(z.symbol),yt=fe/z.quantity,xt=de/z.quantity;if(!je){for(let Jt=0;Jt<z.quantity;Jt++)rt.push({side:z.side,qty:1,price:ae,feePerUnit:yt,commissionPerUnit:xt});let Rt=Rv({symbol:z.symbol,side:z.side,type:z.type,entryPrice:ae,quantity:z.quantity,takeProfits:U??[],stopLosses:be??[],openedAt:he,openFee:fe,openCommission:de,metadata:z.metadata,symbolInfo:n});b.set(Rt.id,Rt),e.upsertPosition(Rt);return}if(je.side===z.side){for(let vt=0;vt<z.quantity;vt++)rt.push({side:z.side,qty:1,price:ae,feePerUnit:yt,commissionPerUnit:xt});let Rt=je.remainingQuantity+z.quantity,Jt=(je.entryPrice*je.remainingQuantity+ae*z.quantity)/Rt,rn=je.openCostTotal+fe+de,Q=je.startingQuantity+z.quantity,X=[...je.takeProfits,...U?.filter(vt=>!je.takeProfits.some(ue=>ue.id===vt.id))??[]],ye=[...je.stopLosses,...be?.filter(vt=>!je.stopLosses.some(ue=>ue.id===vt.id))??[]],Te={...je,entryPrice:Jt,remainingQuantity:Rt,startingQuantity:Q,takeProfits:X,stopLosses:ye,openCostTotal:rn,openCostPerUnit:Q>0?rn/Q:0,feesTotal:je.feesTotal+fe,commissionTotal:je.commissionTotal+de,updatedAt:he},ct=KR(Te,he);b.set(je.id,ct),e.upsertPosition(ct);return}let Je=z.quantity;for(;Je>0&&Je<=je.remainingQuantity;)break;if(z.quantity<=je.remainingQuantity){let Rt=z.quantity;$e(je,Rt,ae,he,"order",void 0,void 0,z.id,z.type)}else{let Rt=je.remainingQuantity;$e(je,Rt,ae,he,"order",void 0,void 0,z.id,z.type);let Jt=z.quantity-Rt;if(Jt>0){let rn=De(z.symbol);for(let Te=0;Te<Jt;Te++)rn.push({side:z.side,qty:1,price:ae,feePerUnit:yt,commissionPerUnit:xt});let Q=fe*(Jt/z.quantity),X=de*(Jt/z.quantity),ye=Rv({symbol:z.symbol,side:z.side,type:z.type,entryPrice:ae,quantity:Jt,takeProfits:U??[],stopLosses:be??[],openedAt:he,openFee:Q,openCommission:X,metadata:z.metadata,symbolInfo:n});b.set(ye.id,ye),e.upsertPosition(ye)}}}function Ye(z,ae,fe,de,U,be,he){let je=`${z.symbol}:${vn(6)}`,rt=De(je),yt=fe/z.quantity,xt=de/z.quantity;for(let Je=0;Je<z.quantity;Je++)rt.push({side:z.side,qty:1,price:ae,feePerUnit:yt,commissionPerUnit:xt});let ht=Rv({symbol:z.symbol,side:z.side,type:z.type,entryPrice:ae,quantity:z.quantity,takeProfits:U??[],stopLosses:be??[],openedAt:he,openFee:fe,openCommission:de,metadata:z.metadata,symbolInfo:n});b.set(ht.id,ht),e.upsertPosition(ht)}function $e(z,ae,fe,de,U,be,he,je,rt){if(!b.has(z.id)||ae<=0||ae>z.remainingQuantity)return;let yt=De(i==="hedge"?z.id:z.symbol),xt=YR(ae,o),ht=GR(ae,o),Je=xt+ht;M+=Je;let Rt=ae,Jt=0,rn=0,Q=0;for(;Rt>0&&yt.length>0;){let wt=yt[0],Ht=Math.min(Rt,wt.qty),yr=wt.side==="long"?1:-1;Jt+=yr*(fe-wt.price)*Ht*d,rn+=wt.feePerUnit*Ht,Q+=wt.commissionPerUnit*Ht,wt.qty-=Ht,wt.qty===0&&yt.shift(),Rt-=Ht}let X=rn+Q,ye=Jt-Je-X;I+=ye;let Te=z.takeProfits,ct=z.stopLosses;be&&(Te=z.takeProfits.map(wt=>wt.id===be?{...wt,triggered:!0,triggeredAt:de}:wt)),he&&(ct=z.stopLosses.map(wt=>wt.id===he?{...wt,triggered:!0,triggeredAt:de}:wt));let vt=z.remainingQuantity-ae,ue=z.realizedPnl+ye,Fe=z.initialRiskPerUnit,St=z.initialRiskTotal;if(z.initialRiskLockedAt===0&&Fe===0&&vt===0){let wt=ct.find(yr=>yr.triggered)??ct.find(yr=>!yr.triggered),Ht=0;wt&&(Ht=z.side==="long"?Math.max(0,z.entryPrice-wt.price):Math.max(0,wt.price-z.entryPrice)),Ht<=0&&z.maeAbs>0&&(Ht=z.maeAbs),Ht>0&&(Fe=Ht,St=Ht*z.startingQuantity)}let Et=St>0?ue/(St*d):0,Fn={timestamp:de,price:fe,quantity:ae,pnl:Jt,pnlNet:ye,reason:U,orderId:je??"",orderType:rt??"market",tpId:be,slId:he,realizedRRAfter:Et,fees:xt,commission:ht,slippage:0,spread:0,openCostAllocated:X},Zt=vt===0?"closed":"partially_closed",Nt={...z,side:z.side,status:Zt,remainingQuantity:vt,realizedPnl:ue,realizedRR:Et,takeProfits:Te,stopLosses:ct,feesTotal:z.feesTotal+Je,commissionTotal:z.commissionTotal+ht,closes:[...z.closes,Fn],initialRiskPerUnit:Fe,initialRiskTotal:St,closedAt:vt===0?de:z.closedAt,updatedAt:de},jt=Eu(Nt,fe,d),zt=um(Nt,fe,d);Nt.unrealizedPnl=jt,Nt.unrealizedPnlPct=zt,vt===0?(b.delete(z.id),w.push(Nt)):b.set(z.id,Nt),e.upsertPosition(Nt);let yn=Zt==="closed";HR({side:Nt.side,symbol:Nt.symbol,pnl:yn?ue:ye,rMultiple:Et,reason:U,partial:!yn})}function bt(z,ae,fe,de){$e(z,z.remainingQuantity,ae,de,fe)}function Oe(z,ae,fe){let{order:de}=z,U=s*r,be=de.side==="long",he=be?f:m,je=he.getSortedPrices(),rt=de.quantity,yt=0,xt=!1;if(be)for(let Je=0;Je<je.length&&rt>0;Je++){let Rt=he.getLevel(je[Je]),Jt=Math.min(rt,Rt.totalSize);yt+=(je[Je]+U)*Jt,rt-=Jt,xt=!0}else for(let Je=je.length-1;Je>=0&&rt>0;Je--){let Rt=he.getLevel(je[Je]),Jt=Math.min(rt,Rt.totalSize);yt+=(je[Je]-U)*Jt,rt-=Jt,xt=!0}if(!xt||rt>0){let Je=be?(ae.ask??y??ae.ask)+U*2:(ae.bid??g??ae.bid)-U*2;yt+=Je*rt}let ht=Tt(yt/de.quantity);ce(z,ht,fe)}function Tt(z){return Math.round(z/u)*u}function bn(z){l&&l.emit("playback:tick",{bid:z.bid,ask:z.ask,last:z.last,spread:Math.abs(z.ask-z.bid)})}function En(z){if(T)return;x=z,e.tick(z),le(z),z.bid!=null&&(g=z.bid),z.ask!=null&&(y=z.ask);let ae=z.last??(z.bid+z.ask)/2;R||bn(z);for(let fe of b.values()){if(fe.symbol!==z.symbol)continue;let de=Eu(fe,ae,d),U=um(fe,ae,d),he={...Pv(fe,Math.min(z.bid,z.ask),Math.max(z.bid,z.ask)),currentPrice:ae,unrealizedPnl:de,unrealizedPnlPct:U,updatedAt:z.ts};b.set(fe.id,he),e.upsertPosition(he)}}function Lt(z,ae,fe,de,U){return{id:ae,symbol:fe,side:z.side,type:z.type,quantity:z.qty,filledQuantity:0,price:z.limitPrice??0,stopPrice:z.stopPrice??0,tif:z.tif??"gtc",status:U,reduceOnly:z.reduceOnly??!1,targetPositionId:z.targetPositionId,avgPrice:0,triggered:!1,fees:0,commission:0,slippage:0,createdAt:de,updatedAt:de,metadata:$R(z.metadata,fe,z.qty,n),bracket:{takeProfits:z.bracketTp,stopLosses:z.bracketSl}}}function it(z){let ae=vn(),fe=z.symbol??c;if(!x){let be=Lt(z,ae,fe,0,"rejected");return C.set(ae,be),e.upsertOrder(be),ae}let de=x.ts;z.type==="market"&&!z?.limitPrice&&!z?.stopPrice&&(z.side==="long"?z.limitPrice=x.ask:z.limitPrice=x.bid);let U=Lt(z,ae,fe,de,"working");if(C.set(ae,U),e.upsertOrder(U),z.type==="market")Oe({order:U,queueAhead:0,tradedThrough:0,bracketTp:z.bracketTp,bracketSl:z.bracketSl},x,BigInt(x.ts));else if(z.type==="limit"){let he=(z.side==="long"?m:f).getLevel(z.limitPrice)?.totalSize??0;if(v.set(ae,{order:U,queueAhead:he,tradedThrough:0,bracketTp:z.bracketTp,bracketSl:z.bracketSl}),x&&(z.side==="long"?x.ask<=z.limitPrice:x.bid>=z.limitPrice)){let rt=v.get(ae);rt.queueAhead=0,rt.tradedThrough=1/0,v.delete(ae);let yt=z.side==="long"?x.ask:x.bid;ce(rt,yt,BigInt(x.ts))}}else v.set(ae,{order:U,queueAhead:0,tradedThrough:0,bracketTp:z.bracketTp,bracketSl:z.bracketSl});return ae}function ft(z){let ae=v.get(z);if(!ae)return;v.delete(z);let fe={...ae.order,status:"cancelled",updatedAt:x.ts};C.set(z,fe),e.upsertOrder(fe)}function ie(z,ae){let fe=v.get(z);if(!fe)return;let{order:de}=fe,U=Tt(ae),be=de.type==="limit"||de.type==="stop_limit"&&de.triggered,he=de.type==="stop"||de.type==="stop_limit"&&!de.triggered,je={...de,price:be?U:de.price,stopPrice:he?U:de.stopPrice,updatedAt:x.ts},rt=je.side==="long"?m:f,yt=be?U:je.price??U,xt=rt.getLevel(yt)?.totalSize??0;v.set(z,{...fe,order:je,queueAhead:xt,tradedThrough:0}),C.set(z,je),e.upsertOrder(je)}function ge(z){let{positionId:ae,which:fe,levelId:de,index:U,price:be,qty:he,remove:je}=z,rt=b.get(ae);if(!rt)return;let yt=Tt(be),xt=x.ts,ht=(rn,Q)=>rn.id?rn.id===de:Q===U,Je={...rt};fe==="tp"?Je={...Je,takeProfits:je?rt.takeProfits.filter((rn,Q)=>!ht(rn,Q)):rt.takeProfits.map((rn,Q)=>ht(rn,Q)?{...rn,price:yt,qty:he>0?he:rn.qty}:rn)}:fe==="sl"?Je={...Je,stopLosses:je?rt.stopLosses.filter((rn,Q)=>!ht(rn,Q)):rt.stopLosses.map((rn,Q)=>ht(rn,Q)?{...rn,price:yt,qty:he>0?he:rn.qty}:rn)}:fe==="be"&&(Je={...Je,bePrice:je?void 0:yt});let Jt={...KR(Je,xt),updatedAt:xt};b.set(ae,Jt),e.upsertPosition(Jt)}function pe(z){let ae=b.get(z);if(!ae||!x)return;let fe=s*r,de=Tt(ae.side==="long"?x.bid-fe:x.ask+fe);bt(ae,de,"market",x.ts)}function Le(z){let ae=b.get(z);if(!ae||!x)return;let fe=s*r,de=Tt(ae.side==="long"?x.bid-fe:x.ask+fe),U=ae.side==="long"?"short":"long",be=ae.remainingQuantity;bt(ae,de,"market",x.ts),it({side:U,type:"market",qty:be,symbol:ae.symbol})}function Ue(z,ae){let fe=z.map(de=>({tsNs:BigInt(de.time)*1000000n,bar:de})).sort((de,U)=>de.tsNs<U.tsNs?-1:de.tsNs>U.tsNs?1:0);P={kind:"ohlcv",bars:fe,suppBars:[],barNs:ae&&ae>0n?ae:B(fe)},D=0,N=0,O=0n,nt=ja(0),pt=0}function Ge(z,ae){if(P?.kind!=="ohlcv"||z.length===0){z.length&&Ue(z,ae);return}let fe=P,de=z.map(he=>({tsNs:BigInt(he.time)*1000000n,bar:he})).sort((he,je)=>he.tsNs<je.tsNs?-1:he.tsNs>je.tsNs?1:0);if(fe.bars.length>0&&de[0].tsNs<fe.bars[0].tsNs){Ue(z,ae);return}let U=de[0].tsNs,be=fe.bars.length;for(;be>0&&fe.bars[be-1].tsNs>=U;)be--;fe.bars.length=be;for(let he of de)fe.bars.push(he);D>fe.bars.length&&(D=fe.bars.length),ae&&ae>0n&&(fe.barNs=ae)}function Ve(z){if(P?.kind!=="ohlcv"||z.length===0)return;let ae=P,fe=z.map(be=>({tsNs:BigInt(Math.round(be.time))*1000000n,open:be.open,high:be.high,low:be.low,close:be.close,volume:be.volume})).sort((be,he)=>be.tsNs<he.tsNs?-1:be.tsNs>he.tsNs?1:0);if(ae.suppBars.length>0&&fe[0].tsNs<ae.suppBars[0].tsNs){Ne(z);return}let de=fe[0].tsNs,U=ae.suppBars.length;for(;U>0&&ae.suppBars[U-1].tsNs>=de;)U--;ae.suppBars.length=U;for(let be of fe)ae.suppBars.push(be);N>ae.suppBars.length&&(N=ae.suppBars.length)}function Ne(z){P?.kind==="ohlcv"&&(P.suppBars=z.map(ae=>({tsNs:BigInt(Math.round(ae.time))*1000000n,open:ae.open,high:ae.high,low:ae.low,close:ae.close,volume:ae.volume})).sort((ae,fe)=>ae.tsNs<fe.tsNs?-1:ae.tsNs>fe.tsNs?1:0),N=0)}function Se(z){P={kind:"tick",trades:[...z].sort((ae,fe)=>ae.ts<fe.ts?-1:ae.ts>fe.ts?1:0)},D=0,O=0n,nt=ja(0),pt=0}function He(z){P={kind:"l2",history:[...z].sort((ae,fe)=>ae.ts<fe.ts?-1:ae.ts>fe.ts?1:0)},D=0,O=0n,nt=ja(0),pt=0}function _e(z){if(P?.kind!=="tick"||z.length===0){z.length&&Se(z);return}let ae=[...z].sort((de,U)=>de.ts<U.ts?-1:de.ts>U.ts?1:0);if(P.trades.length>0&&ae[0].ts<P.trades[0].ts){Se(z);return}let fe=Math.min(D,ae.length);P.trades=ae,D=fe}function dt(z){if(P?.kind!=="l2"||z.length===0){z.length&&He(z);return}let ae=[...z].sort((de,U)=>de.ts<U.ts?-1:de.ts>U.ts?1:0);if(P.history.length>0&&ae[0].ts<P.history[0].ts){He(z);return}let fe=Math.min(D,ae.length);P.history=ae,D=fe}function _t(z){let ae=pt;Xt(z),pt=Math.min(ae,nt.length)}function te(z){let ae=P,fe=0,de=ae.barNs;for(z<A&&(D=0,N=0),A=z;D<ae.bars.length;){let{tsNs:U,bar:be}=ae.bars[D];if(U+de>z)break;D++,O=U;let he=Number(U),je=be.bid??be.open-fe,rt=be.ask??be.open+fe,yt=be.bid??be.close-fe,xt=be.ask??be.close+fe;En({symbol:c,bid:je,ask:rt,last:be.open,ts:he}),W(be.low,be.high,U),$(be.low,be.high,U),J(be.low,be.high,U),be.close!==be.open&&En({symbol:c,bid:yt,ask:xt,last:be.close,ts:he})}if(ae.suppBars.length>0&&de>0n){let U=z/de*de,be=null;for(;N<ae.suppBars.length&&ae.suppBars[N].tsNs<=z;){let he=ae.suppBars[N];N++,!(he.tsNs<U)&&(he.volume??0)!==0&&(W(he.low,he.high,he.tsNs),$(he.low,he.high,he.tsNs),J(he.low,he.high,he.tsNs),be=he)}if(be){let he=Number(be.tsNs);En({symbol:c,bid:be.close-fe,ask:be.close+fe,last:be.close,ts:he})}}}function Me(z){let ae=P,fe=r/2;for(z<O&&(D=0);D<ae.trades.length;){let de=ae.trades[D];if(de.ts>z)break;D++,O=de.ts;let U=Number(de.ts),be=de.side==="B"?de.price-fe:de.price,he=de.side==="A"?de.price+fe:de.price;En({symbol:c,bid:be,ask:he,last:de.price,ts:U}),W(de.price,de.price,de.ts),J(de.price,de.price,de.ts)}}function Pe(z){let ae=P;for(z<O&&(D=0);D<ae.history.length;){let fe=ae.history[D];if(fe.ts>z)break;D++,O=fe.ts;let de=Number(fe.ts),{bestBid:U,bestAsk:be}=fe,he=(U+be)/2;En({symbol:c,bid:U,ask:be,last:he,ts:de});for(let[je,rt]of v){let{order:yt}=rt;if(yt.type!=="limit")continue;let xt=yt.price;if(!(yt.side==="long"?be<=xt:U>=xt))continue;let Je=yt.side==="long"?be:U;ce(rt,Je,fe.ts),v.delete(je)}J(U,be,fe.ts)}}let at=20,nt=ja(0),pt=0;function Xt(z){let ae=z.byteLength/at;nt._buf=z,nt._view=new DataView(z),nt.length=ae,nt.capacity=ae,pt=0}function Ft(){return x?x.last:NaN}function cr(z){if(T)return;q(z);let ae=R;R=!0;try{if(P)switch(P.kind){case"ohlcv":te(z);break;case"tick":Me(z);break;case"l2":Pe(z);break}else if(nt.length>0){let fe=pt>0?ls(nt,pt-1):0n;for(z<fe&&(m.clear(),f.clear(),h.clear(),p.clear(),g=null,y=null,pt=0);pt<nt.length;){let de=ls(nt,pt);if(de>z)break;ee(ss(nt,pt),de),pt++}g!==null&&y!==null&&En({symbol:c,bid:g,ask:y,ts:Number(z)})}}finally{R=ae}!ae&&x&&bn(x)}function Mn(){return M}function ir(){return I}function Vn(){return[...C.values()]}function fr(){return[...k]}function _n(){return[...w]}function qn(){T=!0,v.clear(),b.clear(),m.clear(),f.clear(),S.clear(),C.clear(),w.length=0,k.length=0,nt=ja(0),P=null,D=0,N=0,O=0n}return{syncPosition:E,syncOrder:L,onMboEvent:ee,onTick:En,ingestCompactBuf:Xt,ingestOhlcvBars:Ue,appendOhlcvBars:Ge,ingestSupplementalBars:Ne,appendSupplementalBars:Ve,appendTicks:_e,appendPriceHistory:dt,appendCompactBuf:_t,ingestTicks:Se,ingestPriceHistory:He,seekTo:cr,getPrice:Ft,placeOrder:it,cancelOrder:ft,amendOrder:ie,amendBracket:ge,closePosition:pe,reversePosition:Le,totalFeesPaid:Mn,totalRealizedPnl:ir,getOrders:Vn,getFills:fr,getPositionHistory:_n,setFillSearch:Ce,getFillSearch:Ee,hasPendingTriggers:ze,settleGapBars:Ie,destroy:qn}}var Xa=8;function QR(e,t,n,r){let o=(0,No.useRef)(t??new ll).current,a=(0,No.useRef)([]),i=(0,No.useRef)(n);(0,No.useEffect)(()=>{i.current=n},[n]);let[s,l]=(0,No.useState)(null);(0,No.useEffect)(()=>{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]=(0,No.useState)("ohlcv");(0,No.useEffect)(()=>{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=jR((0,No.useMemo)(()=>({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]));(0,No.useEffect)(()=>{if(!e)return;let g=$h(h,{symbolInfo:s,fees:Kh(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=(0,No.useRef)(null);return(0,No.useEffect)(()=>{h.registerRedraw(p.current)},[p.current]),{symbol:e,trading:h,executionEngine:o,redrawFnRef:p,tradingEvents:a}}function sl(e,t,n,r){return QR(e,r,t,n)}function Q6(e,t){let n=Array.from({length:Xa},(o,a)=>t[a]??""),r=[];for(let o of e.slice(0,Xa))o&&!r.includes(o)&&r.push(o);for(let o=0;o<Xa;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 JR(e,t,n,r){let o=(0,No.useRef)(Array.from({length:Xa},()=>"")),a=Q6(e,o.current);o.current=a;let i=sl(a[0],t,n,r),s=sl(a[1],t,n,r),l=sl(a[2],t,n,r),c=sl(a[3],t,n,r),u=sl(a[4],t,n,r),d=sl(a[5],t,n,r),m=sl(a[6],t,n,r),f=sl(a[7],t,n,r),h=[i,s,l,c,u,d,m,f],p=Array.from({length:Xa},(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}}var Xh=Ct(require("react"));var Mr=require("react/jsx-runtime"),Zh=[{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"'}],tP=["a","b","c","d","e","f","g","h"];function eP({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((0,Mr.jsx)("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((0,Mr.jsx)("line",{x1:f*c,y1:h,x2:(f+1)*c,y2:h,strokeWidth:1},`h-${m}-${f}`))}return(0,Mr.jsx)("div",{className:`rounded-md p-[5px] ${t?"bg-[#272b35]":"bg-transparent"} transition stroke-[#A8AFBD] group-hover:stroke-white`,children:(0,Mr.jsxs)("svg",{width:o,height:a,viewBox:`0 0 ${o} ${a}`,children:[(0,Mr.jsx)("rect",{x:.5,y:.5,width:o-1,height:a-1,rx:2.5,fill:"transparent",strokeWidth:1}),d]})})}var J6=[{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 nP({current:e,onChange:t,syncInLayout:n,setSyncInLayout:r}){let a=(0,Xh.useCallback)(()=>{let i=1,s=[],l=[];for(let c of Zh)c.count!==i&&(i=c.count,s.length&&l.push(s),s=[]),s.push(c);return s.length&&l.push(s),l},[])();return(0,Mr.jsxs)(Va,{children:[(0,Mr.jsx)(Wa,{asChild:!0,children:(0,Mr.jsx)(br,{variant:"outline",className:"group hover:bg-muted w-7 p-0 h-7 border-none",children:(0,Mr.jsx)(eP,{p:e,active:!1,size:22})})}),(0,Mr.jsxs)(ya,{className:"p-3 flex flex-col gap-1.5 w-fit",children:[(0,Mr.jsx)("div",{className:"text-xs text-muted-foreground tracking-wide border-b pb-2",children:"LAYOUT"}),a.map((i,s)=>(0,Mr.jsxs)(Xh.default.Fragment,{children:[(0,Mr.jsxs)("div",{className:"flex gap-2 items-center w-full",children:[(0,Mr.jsx)("div",{className:"text-xs text-muted-foreground w-4",children:i[0]?.count}),(0,Mr.jsx)("div",{className:"flex gap-1 w-full",children:i.map(l=>{let c=l.id===e.id;return(0,Mr.jsx)(aa,{onClick:()=>t(l),className:"flex flex-col items-center gap-1 p-0 rounded-md w-fit cursor-pointer hover:!bg-[#272b35] group",children:(0,Mr.jsx)(eP,{p:l,active:c,size:20})},l.id)})})]}),s<a.length-1&&(0,Mr.jsx)(sc,{})]},i[0]?.count??s)),(0,Mr.jsx)("div",{className:"text-xs text-muted-foreground tracking-wide border-b pb-2 space-y-2 mt-4",children:"SYNC IN LAYOUT"}),(0,Mr.jsx)("div",{className:"flex flex-col gap-2 text-[13px] text-muted-foreground font-[400]",children:J6.map(({key:i,label:s,hint:l})=>(0,Mr.jsxs)("label",{title:l,className:"flex w-full justify-between items-center gap-6 cursor-pointer",children:[(0,Mr.jsx)("span",{children:s}),(0,Mr.jsx)(so,{checked:n[i],onCheckedChange:c=>r({...n,[i]:c}),className:"data-[state=checked]:bg-blue-500"})]},i))})]})]})}var cl=Ct(require("react"));var fs=require("react/jsx-runtime");function Nv(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 Ev=e=>e.map(t=>`${t}fr`).join(" ");function eV(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 Ov({dir:e,sizes:t,containerRef:n,onDrag:r,areas:o,colSizes:a}){let[i,s]=(0,cl.useState)([]),[l,c]=(0,cl.useState)({w:0,h:0}),[u,d]=(0,cl.useState)(!1);(0,cl.useLayoutEffect)(()=>{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(0,fs.jsxs)(fs.Fragment,{children:[u&&(0,fs.jsx)("div",{style:{position:"fixed",inset:0,zIndex:9999,cursor:m?"col-resize":"row-resize"}}),i.map((f,h)=>{let p=!m&&o&&a?eV(h,o,a):null,g=y=>{y.preventDefault(),y.stopPropagation(),d(!0),im.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),im.unlock(),v&&cancelAnimationFrame(v),window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",w)};window.addEventListener("mousemove",C),window.addEventListener("mouseup",w)};return m?(0,fs.jsx)("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):(0,fs.jsx)(cl.default.Fragment,{children:(p??[{left:0,right:1}]).map((y,v)=>{let b=y.left*l.w,S=(1-y.right)*l.w;return(0,fs.jsx)("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)})]})}var wr=Ct(require("react"));var dP=Ct(require("react")),kt=require("react"),ng=(0,kt.createContext)(null);ng.displayName="PanelGroupContext";var qr={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"},qv=10,uc=kt.useLayoutEffect,rP=dP.useId,tV=typeof rP=="function"?rP:()=>null,nV=0;function Uv(e=null){let t=tV(),n=(0,kt.useRef)(e||t||null);return n.current===null&&(n.current=""+nV++),e??n.current}function fP({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=(0,kt.useContext)(ng);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=Uv(i),R=(0,kt.useRef)({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});(0,kt.useRef)({didLogMissingDefaultSizeWarning:!1}),uc(()=>{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)}),uc(()=>{let D=R.current;return M(D),()=>{x(D)}},[m,T,M,x]),(0,kt.useImperativeHandle)(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(0,kt.createElement)(h,{...p,children:e,className:t,id:T,style:{...P,...f},[qr.groupId]:C,[qr.panel]:"",[qr.panelCollapsible]:r||void 0,[qr.panelId]:T,[qr.panelSize]:parseFloat(""+P.flexGrow).toFixed(1)})}var jv=(0,kt.forwardRef)((e,t)=>(0,kt.createElement)(fP,{...e,forwardedRef:t}));fP.displayName="Panel";jv.displayName="forwardRef(Panel)";var rV;function oV(){return rV}var Wv=null,aV=!0,Jh=-1,ms=null;function iV(e,t){if(t){let n=(t&bP)!==0,r=(t&yP)!==0,o=(t&vP)!==0,a=(t&wP)!==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 sV(){ms!==null&&(document.head.removeChild(ms),Wv=null,ms=null,Jh=-1)}function _v(e,t){var n,r;if(!aV)return;let o=iV(e,t);if(Wv!==o){if(Wv=o,ms===null){ms=document.createElement("style");let i=oV();i&&ms.setAttribute("nonce",i),document.head.appendChild(ms)}if(Jh>=0){var a;(a=ms.sheet)===null||a===void 0||a.removeRule(Jh)}Jh=(n=(r=ms.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${o} !important;}`))!==null&&n!==void 0?n:-1}}function mP(e){return e.type==="keydown"}function pP(e){return e.type.startsWith("pointer")}function hP(e){return e.type.startsWith("mouse")}function rg(e){if(pP(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(hP(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function lV(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function cV(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 uV(e,t){if(e===t)throw new Error("Cannot compare node with itself");let n={a:iP(e),b:iP(t)},r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Rn(r,"Stacking order can only be calculated for elements with a common ancestor");let o={a:aP(oP(n.a)),b:aP(oP(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 dV=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function fV(e){var t;let n=getComputedStyle((t=gP(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function mV(e){let t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||fV(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"||dV.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function oP(e){let t=e.length;for(;t--;){let n=e[t];if(Rn(n,"Missing node"),mV(n))return n}return null}function aP(e){return e&&Number(getComputedStyle(e).zIndex)||0}function iP(e){let t=[];for(;e;)t.push(e),e=gP(e);return t}function gP(e){let{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}var bP=1,yP=2,vP=4,wP=8,pV=lV()==="coarse",Si=[],zu=!1,cc=new Map,og=new Map,gm=new Set;function hV(e,t,n,r,o){var a;let{ownerDocument:i}=t,s={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},l=(a=cc.get(i))!==null&&a!==void 0?a:0;return cc.set(i,l+1),gm.add(s),eg(),function(){var u;og.delete(e),gm.delete(s);let d=(u=cc.get(i))!==null&&u!==void 0?u:1;if(cc.set(i,d-1),eg(),d===1&&cc.delete(i),Si.includes(s)){let m=Si.indexOf(s);m>=0&&Si.splice(m,1),Yv(),o("up",!0,null)}}}function gV(e){let{target:t}=e,{x:n,y:r}=rg(e);zu=!0,Gv({target:t,x:n,y:r}),eg(),Si.length>0&&(tg("down",e),e.preventDefault(),xP(t)||e.stopImmediatePropagation())}function Fv(e){let{x:t,y:n}=rg(e);if(zu&&e.buttons===0&&(zu=!1,tg("up",e)),!zu){let{target:r}=e;Gv({target:r,x:t,y:n})}tg("move",e),Yv(),Si.length>0&&e.preventDefault()}function zv(e){let{target:t}=e,{x:n,y:r}=rg(e);og.clear(),zu=!1,Si.length>0&&(e.preventDefault(),xP(t)||e.stopImmediatePropagation()),tg("up",e),Gv({target:t,x:n,y:r}),Yv(),eg()}function xP(e){let t=e;for(;t;){if(t.hasAttribute(qr.resizeHandle))return!0;t=t.parentElement}return!1}function Gv({target:e,x:t,y:n}){Si.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),gm.forEach(o=>{let{element:a,hitAreaMargins:i}=o,s=a.getBoundingClientRect(),{bottom:l,left:c,right:u,top:d}=s,m=pV?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)&&uV(r,a)>0){let h=r,p=!1;for(;h&&!h.contains(a);){if(cV(h.getBoundingClientRect(),s,!0)){p=!0;break}h=h.parentElement}if(p)return}Si.push(o)}})}function Hv(e,t){og.set(e,t)}function Yv(){let e=!1,t=!1;Si.forEach(r=>{let{direction:o}=r;o==="horizontal"?e=!0:t=!0});let n=0;og.forEach(r=>{n|=r}),e&&t?_v("intersection",n):e?_v("horizontal",n):t?_v("vertical",n):sV()}var Vv=new AbortController;function eg(){Vv.abort(),Vv=new AbortController;let e={capture:!0,signal:Vv.signal};gm.size&&(zu?(Si.length>0&&cc.forEach((t,n)=>{let{body:r}=n;t>0&&(r.addEventListener("contextmenu",zv,e),r.addEventListener("pointerleave",Fv,e),r.addEventListener("pointermove",Fv,e))}),window.addEventListener("pointerup",zv,e),window.addEventListener("pointercancel",zv,e)):cc.forEach((t,n)=>{let{body:r}=n;t>0&&(r.addEventListener("pointerdown",gV,e),r.addEventListener("pointermove",Fv,e))}))}function tg(e,t){gm.forEach(n=>{let{setResizeHandlerState:r}=n,o=Si.includes(n);r(e,o,t)})}function bV(){let[e,t]=(0,kt.useState)(0);return(0,kt.useCallback)(()=>t(n=>n+1),[])}function Rn(e,t){if(!e)throw console.error(t),Error(t)}function dc(e,t,n=qv){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function ps(e,t,n=qv){return dc(e,t,n)===0}function xa(e,t,n){return dc(e,t,n)===0}function yV(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(!xa(o,a,n))return!1}return!0}function Fu({panelConstraints:e,panelIndex:t,size:n}){let r=e[t];Rn(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:a,maxSize:i=100,minSize:s=0}=r;if(dc(n,s)<0)if(a){let l=(o+s)/2;dc(n,l)<0?n=o:n=s}else n=s;return n=Math.min(i,n),n=parseFloat(n.toFixed(qv)),n}function pm({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:a}){if(xa(e,0))return t;let i=[...t],[s,l]=r;Rn(s!=null,"Invalid first pivot index"),Rn(l!=null,"Invalid second pivot index");let c=0;if(a==="keyboard"){{let d=e<0?l:s,m=n[d];Rn(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(Rn(g!=null,`Previous layout not found for panel index ${d}`),xa(g,f)){let y=p-g;dc(y,Math.abs(e))>0&&(e=e<0?0-y:y)}}}{let d=e<0?s:l,m=n[d];Rn(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(Rn(g!=null,`Previous layout not found for panel index ${d}`),xa(g,p)){let y=g-f;dc(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];Rn(p!=null,`Previous layout not found for panel index ${m}`);let y=Fu({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];Rn(h!=null,`Previous layout not found for panel index ${m}`);let p=h-f,g=Fu({panelConstraints:n,panelIndex:m,size:p});if(!xa(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(yV(o,i))return o;{let d=e<0?l:s,m=t[d];Rn(m!=null,`Previous layout not found for panel index ${d}`);let f=m+c,h=Fu({panelConstraints:n,panelIndex:d,size:f});if(i[d]=h,!xa(h,f)){let p=f-h,y=e<0?l:s;for(;y>=0&&y<n.length;){let v=i[y];Rn(v!=null,`Previous layout not found for panel index ${y}`);let b=v+p,S=Fu({panelConstraints:n,panelIndex:y,size:b});if(xa(v,S)||(p-=S-v,i[y]=S),xa(p,0))break;e>0?y--:y++}}}let u=i.reduce((d,m)=>m+d,0);return xa(u,100)?i:o}function vV({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,a=0,i=0,s=n[0];Rn(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 bm(e,t=document){return Array.from(t.querySelectorAll(`[${qr.resizeHandleId}][data-panel-group-id="${e}"]`))}function SP(e,t,n=document){let o=bm(e,n).findIndex(a=>a.getAttribute(qr.resizeHandleId)===t);return o??null}function CP(e,t,n){let r=SP(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function kP(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 ag(e,t=document){let n=t.querySelector(`[${qr.resizeHandleId}="${e}"]`);return n||null}function wV(e,t,n,r=document){var o,a,i,s;let l=ag(t,r),c=bm(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 xV({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:a,setLayout:i}){(0,kt.useRef)({didWarnAboutMissingResizeHandle:!1}),uc(()=>{if(!a)return;let s=bm(n,a);for(let l=0;l<o.length-1;l++){let{valueMax:c,valueMin:u,valueNow:d}=vV({layout:r,panelsArray:o,pivotIndices:[l,l+1]}),m=s[l];if(m!=null){let f=o[l];Rn(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]),(0,kt.useEffect)(()=>{if(!a)return;let s=t.current;Rn(s,"Eager values not found");let{panelDataArray:l}=s,c=kP(n,a);Rn(c!=null,`No group found for id "${n}"`);let u=bm(n,a);Rn(u,`No resize handles found for group id "${n}"`);let d=u.map(m=>{let f=m.getAttribute(qr.resizeHandleId);Rn(f,"Resize handle element has no handle id attribute");let[h,p]=wV(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];Rn(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=pm({delta:xa(S,C)?k-C:C-S,initialLayout:r,panelConstraints:l.map(I=>I.constraints),pivotIndices:CP(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 sP(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 TP(e,t){let n=e==="horizontal",{x:r,y:o}=rg(t);return n?r:o}function SV(e,t,n,r,o){let a=n==="horizontal",i=ag(t,o);Rn(i,`No resize handle element found for id "${t}"`);let s=i.getAttribute(qr.groupId);Rn(s,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r,c=TP(n,e),u=kP(s,o);Rn(u,`No group element found for id "${s}"`);let d=u.getBoundingClientRect(),m=a?d.width:d.height;return(c-l)/m*100}function CV(e,t,n,r,o,a){if(mP(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:SV(e,t,n,r,a)}function kV({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];Rn(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];Rn(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 Ou(e,t,n){t.forEach((r,o)=>{let a=e[o];Rn(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||ps(d,c))&&!ps(r,c)&&f(),m&&(d==null||!ps(d,c))&&ps(r,c)&&m())}})}function Qh(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 TV({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 IV(e,t=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},t)}}function lP(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 IP(e){return`react-resizable-panels:${e}`}function MP(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 LP(e,t){try{let n=IP(e),r=t.getItem(n);if(r){let o=JSON.parse(r);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function MV(e,t,n){var r,o;let a=(r=LP(e,n))!==null&&r!==void 0?r:{},i=MP(t);return(o=a[i])!==null&&o!==void 0?o:null}function LV(e,t,n,r,o){var a;let i=IP(e),s=MP(t),l=(a=LP(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 cP({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(!xa(r,100)&&n.length>0)for(let a=0;a<t.length;a++){let i=n[a];Rn(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];Rn(i!=null,`No layout data found for index ${a}`);let s=Fu({panelConstraints:t,panelIndex:a,size:i});i!=s&&(o+=i-s,n[a]=s)}if(!xa(o,0))for(let a=0;a<t.length;a++){let i=n[a];Rn(i!=null,`No layout data found for index ${a}`);let s=i+o,l=Fu({panelConstraints:t,panelIndex:a,size:s});if(i!==l&&(o-=l-i,n[a]=l,xa(o,0)))break}return n}var RV=100,hm={getItem:e=>(lP(hm),hm.getItem(e)),setItem:(e,t)=>{lP(hm),hm.setItem(e,t)}},uP={};function RP({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:a=null,onLayout:i=null,keyboardResizeBy:s=null,storage:l=hm,style:c,tagName:u="div",...d}){let m=Uv(a),f=(0,kt.useRef)(null),[h,p]=(0,kt.useState)(null),[g,y]=(0,kt.useState)([]),v=bV(),b=(0,kt.useRef)({}),S=(0,kt.useRef)(new Map),C=(0,kt.useRef)(0),w=(0,kt.useRef)({autoSaveId:e,direction:r,dragState:h,id:m,keyboardResizeBy:s,onLayout:i,storage:l}),k=(0,kt.useRef)({layout:g,panelDataArray:[],panelDataArrayChanged:!1});(0,kt.useRef)({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),(0,kt.useImperativeHandle)(o,()=>({getId:()=>w.current.id,getLayout:()=>{let{layout:G}=k.current;return G},setLayout:G=>{let{onLayout:V}=w.current,{layout:q,panelDataArray:j}=k.current,W=cP({layout:G,panelConstraints:j.map($=>$.constraints)});sP(q,W)||(y(W),k.current.layout=W,V&&V(W),Ou(j,W,b.current))}}),[]),uc(()=>{w.current.autoSaveId=e,w.current.direction=r,w.current.dragState=h,w.current.id=m,w.current.onLayout=i,w.current.storage=l}),xV({committedValuesRef:w,eagerValuesRef:k,groupId:m,layout:g,panelDataArray:k.current.panelDataArray,setLayout:y,panelGroupElement:f.current}),(0,kt.useEffect)(()=>{let{panelDataArray:G}=k.current;if(e){if(g.length===0||g.length!==G.length)return;let V=uP[e];V==null&&(V=IV(LV,RV),uP[e]=V);let q=[...G],j=new Map(S.current);V(e,q,j,g,l)}},[e,g,l]),(0,kt.useEffect)(()=>{});let M=(0,kt.useCallback)(G=>{let{onLayout:V}=w.current,{layout:q,panelDataArray:j}=k.current;if(G.constraints.collapsible){let W=j.map(We=>We.constraints),{collapsedSize:$=0,panelSize:J,pivotIndices:me}=lc(j,G,q);if(Rn(J!=null,`Panel size not found for panel "${G.id}"`),!ps(J,$)){S.current.set(G.id,J);let Ce=_u(j,G)===j.length-1?J-$:$-J,Ee=pm({delta:Ce,initialLayout:q,panelConstraints:W,pivotIndices:me,prevLayout:q,trigger:"imperative-api"});Qh(q,Ee)||(y(Ee),k.current.layout=Ee,V&&V(Ee),Ou(j,Ee,b.current))}}},[]),I=(0,kt.useCallback)((G,V)=>{let{onLayout:q}=w.current,{layout:j,panelDataArray:W}=k.current;if(G.constraints.collapsible){let $=W.map(ze=>ze.constraints),{collapsedSize:J=0,panelSize:me=0,minSize:We=0,pivotIndices:Ce}=lc(W,G,j),Ee=V??We;if(ps(me,J)){let ze=S.current.get(G.id),Ie=ze!=null&&ze>=Ee?ze:Ee,Be=_u(W,G)===W.length-1?me-Ie:Ie-me,F=pm({delta:Be,initialLayout:j,panelConstraints:$,pivotIndices:Ce,prevLayout:j,trigger:"imperative-api"});Qh(j,F)||(y(F),k.current.layout=F,q&&q(F),Ou(W,F,b.current))}}},[]),x=(0,kt.useCallback)(G=>{let{layout:V,panelDataArray:q}=k.current,{panelSize:j}=lc(q,G,V);return Rn(j!=null,`Panel size not found for panel "${G.id}"`),j},[]),T=(0,kt.useCallback)((G,V)=>{let{panelDataArray:q}=k.current,j=_u(q,G);return TV({defaultSize:V,dragState:h,layout:g,panelData:q,panelIndex:j})},[h,g]),R=(0,kt.useCallback)(G=>{let{layout:V,panelDataArray:q}=k.current,{collapsedSize:j=0,collapsible:W,panelSize:$}=lc(q,G,V);return Rn($!=null,`Panel size not found for panel "${G.id}"`),W===!0&&ps($,j)},[]),P=(0,kt.useCallback)(G=>{let{layout:V,panelDataArray:q}=k.current,{collapsedSize:j=0,collapsible:W,panelSize:$}=lc(q,G,V);return Rn($!=null,`Panel size not found for panel "${G.id}"`),!W||dc($,j)>0},[]),D=(0,kt.useCallback)(G=>{let{panelDataArray:V}=k.current;V.push(G),V.sort((q,j)=>{let W=q.order,$=j.order;return W==null&&$==null?0:W==null?-1:$==null?1:W-$}),k.current.panelDataArrayChanged=!0,v()},[v]);uc(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;let{autoSaveId:G,onLayout:V,storage:q}=w.current,{layout:j,panelDataArray:W}=k.current,$=null;if(G){let me=MV(G,W,q);me&&(S.current=new Map(Object.entries(me.expandToSizes)),$=me.layout)}$==null&&($=kV({panelDataArray:W}));let J=cP({layout:$,panelConstraints:W.map(me=>me.constraints)});sP(j,J)||(y(J),k.current.layout=J,V&&V(J),Ou(W,J,b.current))}}),uc(()=>{let G=k.current;return()=>{G.layout=[]}},[]);let N=(0,kt.useCallback)(G=>{let V=!1,q=f.current;return q&&window.getComputedStyle(q,null).getPropertyValue("direction")==="rtl"&&(V=!0),function(W){W.preventDefault();let $=f.current;if(!$)return()=>null;let{direction:J,dragState:me,id:We,keyboardResizeBy:Ce,onLayout:Ee}=w.current,{layout:ze,panelDataArray:Ie}=k.current,{initialLayout:ee}=me??{},Be=CP(We,G,$),F=CV(W,G,J,me,Ce,$),le=J==="horizontal";le&&V&&(F=-F);let ce=Ie.map(ve=>ve.constraints),ke=pm({delta:F,initialLayout:ee??ze,panelConstraints:ce,pivotIndices:Be,prevLayout:ze,trigger:mP(W)?"keyboard":"mouse-or-touch"}),De=!Qh(ze,ke);(pP(W)||hP(W))&&C.current!=F&&(C.current=F,!De&&F!==0?le?Hv(G,F<0?bP:yP):Hv(G,F<0?vP:wP):Hv(G,0)),De&&(y(ke),k.current.layout=ke,Ee&&Ee(ke),Ou(Ie,ke,b.current))}},[]),O=(0,kt.useCallback)((G,V)=>{let{onLayout:q}=w.current,{layout:j,panelDataArray:W}=k.current,$=W.map(ze=>ze.constraints),{panelSize:J,pivotIndices:me}=lc(W,G,j);Rn(J!=null,`Panel size not found for panel "${G.id}"`);let Ce=_u(W,G)===W.length-1?J-V:V-J,Ee=pm({delta:Ce,initialLayout:j,panelConstraints:$,pivotIndices:me,prevLayout:j,trigger:"imperative-api"});Qh(j,Ee)||(y(Ee),k.current.layout=Ee,q&&q(Ee),Ou(W,Ee,b.current))},[]),A=(0,kt.useCallback)((G,V)=>{let{layout:q,panelDataArray:j}=k.current,{collapsedSize:W=0,collapsible:$}=V,{collapsedSize:J=0,collapsible:me,maxSize:We=100,minSize:Ce=0}=G.constraints,{panelSize:Ee}=lc(j,G,q);Ee!=null&&($&&me&&ps(Ee,W)?ps(W,J)||O(G,J):Ee<Ce?O(G,Ce):Ee>We&&O(G,We))},[O]),B=(0,kt.useCallback)((G,V)=>{let{direction:q}=w.current,{layout:j}=k.current;if(!f.current)return;let W=ag(G,f.current);Rn(W,`Drag handle element not found for id "${G}"`);let $=TP(q,V);p({dragHandleId:G,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:$,initialLayout:j})},[]),E=(0,kt.useCallback)(()=>{p(null)},[]),L=(0,kt.useCallback)(G=>{let{panelDataArray:V}=k.current,q=_u(V,G);q>=0&&(V.splice(q,1),delete b.current[G.id],k.current.panelDataArrayChanged=!0,v())},[v]),H=(0,kt.useMemo)(()=>({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]),K={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return(0,kt.createElement)(ng.Provider,{value:H},(0,kt.createElement)(u,{...d,children:t,className:n,id:a,ref:f,style:{...K,...c},[qr.group]:"",[qr.groupDirection]:r,[qr.groupId]:m}))}var Kv=(0,kt.forwardRef)((e,t)=>(0,kt.createElement)(RP,{...e,forwardedRef:t}));RP.displayName="PanelGroup";Kv.displayName="forwardRef(PanelGroup)";function _u(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function lc(e,t,n){let r=_u(e,t),a=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:a}}function PV({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){(0,kt.useEffect)(()=>{if(e||n==null||r==null)return;let o=ag(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(qr.groupId);Rn(s,`No group element found for id "${s}"`);let l=bm(s,r),c=SP(s,t,r);Rn(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 $v({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=(0,kt.useRef)(null),v=(0,kt.useRef)({onClick:i,onDragging:s,onPointerDown:c,onPointerUp:u});(0,kt.useEffect)(()=>{v.current.onClick=i,v.current.onDragging=s,v.current.onPointerDown=c,v.current.onPointerUp=u});let b=(0,kt.useContext)(ng);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=Uv(o),[T,R]=(0,kt.useState)("inactive"),[P,D]=(0,kt.useState)(!1),[N,O]=(0,kt.useState)(null),A=(0,kt.useRef)({state:T});uc(()=>{A.current.state=T}),(0,kt.useEffect)(()=>{if(n)O(null);else{let H=w(x);O(()=>H)}},[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(0,kt.useEffect)(()=>{if(n||N==null)return;let H=y.current;Rn(H,"Element ref not attached");let K=!1;return hV(x,H,S,{coarse:B,fine:E},(V,q,j)=>{if(!q){R("inactive");return}switch(V){case"down":{R("drag"),K=!1,Rn(j,'Expected event to be defined for "down" action'),k(x,j);let{onDragging:W,onPointerDown:$}=v.current;W?.(!0),$?.();break}case"move":{let{state:W}=A.current;K=!0,W!=="drag"&&R("hover"),Rn(j,'Expected event to be defined for "move" action'),N(j);break}case"up":{R("hover"),M();let{onClick:W,onDragging:$,onPointerUp:J}=v.current;$?.(!1),J?.(),K||W?.();break}}})},[B,S,n,E,w,x,N,k,M]),PV({disabled:n,handleId:x,resizeHandler:N,panelGroupElement:I}),(0,kt.createElement)(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,[qr.groupDirection]:S,[qr.groupId]:C,[qr.resizeHandle]:"",[qr.resizeHandleActive]:T==="drag"?"pointer":P?"keyboard":void 0,[qr.resizeHandleEnabled]:!n,[qr.resizeHandleId]:x,[qr.resizeHandleState]:T})}$v.displayName="PanelResizeHandle";var ym=require("react/jsx-runtime"),PP=({className:e,...t})=>(0,ym.jsx)(Kv,{className:ne("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),DP=jv,AP=({withHandle:e,className:t,...n})=>(0,ym.jsx)($v,{className:ne("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&&(0,ym.jsx)("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:(0,ym.jsx)(Al,{className:"h-2.5 w-2.5"})})});var _P=Ct(require("react"));var Zr=Ct(require("react"),1);var hs=require("react/jsx-runtime"),AV=Object.defineProperty,ul=(e,t)=>AV(e,"name",{value:t,configurable:!0}),Xv,Qv="HoverCard",[BP,noe]=kr(Qv,[Fa]),Jv=Fa(),[BV,ew]=BP(Qv),NV=ul(e=>{let{__scopeHoverCard:t,children:n,open:r,defaultOpen:o,onOpenChange:a,openDelay:i=700,closeDelay:s=300}=e,l=Jv(t),c=Zr.useRef(0),u=Zr.useRef(0),d=Zr.useRef(!1),m=Zr.useRef(!1),[f,h]=Lo({prop:r,defaultProp:o??!1,onChange:a,caller:Qv}),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)},[]),(0,hs.jsx)(BV,{scope:t,open:f,onOpenChange:h,onOpen:p,onClose:g,onDismiss:y,hasSelectionRef:d,isPointerDownOnContentRef:m,children:(0,hs.jsx)(Xs,{...l,children:n})})},"HoverCard"),EV="HoverCardTrigger",OV=Zr.forwardRef(ul(function(t,n){let{__scopeHoverCard:r,...o}=t,a=ew(EV,r),i=Jv(r);return(0,hs.jsx)(es,{asChild:!0,...i,children:(0,hs.jsx)(hn.a,{"data-state":a.open?"open":"closed",...o,ref:n,onPointerEnter:lt(t.onPointerEnter,vm(a.onOpen)),onPointerLeave:lt(t.onPointerLeave,vm(a.onClose)),onFocus:lt(t.onFocus,a.onOpen),onBlur:lt(t.onBlur,a.onClose),onTouchStart:lt(t.onTouchStart,s=>s.preventDefault())})})},"HoverCardTrigger")),_V="HoverCardPortal",[roe,FV]=BP(_V,{forceMount:void 0});var Zv="HoverCardContent",zV=Zr.forwardRef(ul(function(t,n){let r=FV(Zv,t.__scopeHoverCard),{forceMount:o=r.forceMount,...a}=t,i=ew(Zv,t.__scopeHoverCard);return(0,hs.jsx)(Xo,{present:o||i.open,children:(0,hs.jsx)(HV,{"data-state":i.open?"open":"closed",...a,onPointerEnter:lt(t.onPointerEnter,vm(i.onOpen)),onPointerLeave:lt(t.onPointerLeave,vm(i.onClose)),ref:n})})},"HoverCardContent")),HV=Zr.forwardRef(ul(function(t,n){let{__scopeHoverCard:r,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:s,...l}=t,c=ew(Zv,r),u=Jv(r),d=Zr.useRef(null),m=nn(n,d),[f,h]=Zr.useState(!1);return Zr.useEffect(()=>{if(f){let p=document.body;return Xv=p.style.userSelect||p.style.webkitUserSelect,p.style.userSelect="none",p.style.webkitUserSelect="none",()=>{p.style.userSelect=Xv,p.style.webkitUserSelect=Xv}}},[f]),Zr.useEffect(()=>{if(d.current){let p=ul(()=>{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&&NP(d.current).forEach(g=>g.setAttribute("tabindex","-1"))}),(0,hs.jsx)(Ys,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:s,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:lt(i,p=>{p.preventDefault()}),onDismiss:c.onDismiss,children:(0,hs.jsx)(Zs,{...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 vm(e){return t=>t.pointerType==="touch"?void 0:e()}ul(vm,"excludeTouch");function NP(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:ul(r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}ul(NP,"getTabbableNodes");var EP=NV,OP=OV;var tw=zV;var HP=require("react/jsx-runtime"),FP=EP,zP=OP,nw=_P.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>(0,HP.jsx)(tw,{ref:o,align:t,sideOffset:n,className:ne("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}));nw.displayName=tw.displayName;var ln=require("react/jsx-runtime");function rw({element:e}){return(0,ln.jsx)(ln.Fragment,{children:e})}function qP({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(0,ln.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden bg-background",children:[(0,ln.jsxs)("div",{className:ne("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:[(0,ln.jsx)("span",{className:"text-xs font-medium text-foreground/70 flex-1 truncate",children:e.title}),(0,ln.jsxs)("div",{className:"flex flex-row items-center",children:[(0,ln.jsxs)(Gt,{delayDuration:700,children:[(0,ln.jsx)(qt,{asChild:!0,children:(0,ln.jsx)("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 rounded",onClick:n,children:t?(0,ln.jsx)(cf,{size:12}):(0,ln.jsx)(lf,{size:12})})}),(0,ln.jsx)(Ut,{className:"bg-background border border-border",children:t?"Make floating":"Pin to sidebar"})]}),(0,ln.jsxs)(Gt,{delayDuration:700,children:[(0,ln.jsx)(qt,{asChild:!0,children:(0,ln.jsx)("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 rounded",onClick:o,children:(0,ln.jsx)(Jo,{size:12})})}),(0,ln.jsx)(Ut,{className:"bg-background border border-border",children:"Hide window"})]})]})]}),(0,ln.jsx)("div",{className:"flex-1 overflow-auto min-h-0",children:(0,ln.jsx)(rw,{element:e.element})})]})}function VP(){let e=Gr(Pn.pluginPanels,{});return e&&typeof e=="object"?e:{}}function ow(e,t){if(e.type==="panel")return e.id===t?null:e;let n=e.children.map(r=>ow(r,t)).filter(Boolean);return n.length===0?null:n.length===1?n[0]:{...e,children:n}}function UP(e,t){if(!e)return null;if(e.type==="panel")return t.has(e.id)?e:null;let n=e.children.map(r=>UP(r,t)).filter(Boolean);return n.length===0?null:n.length===1?n[0]:{...e,children:n}}function jP(e,t){return e?e.type==="panel"?e.id===t:e.children.some(n=>jP(n,t)):!1}function WP(e,t){if(!e)return{type:"panel",id:t};let n=e.type==="split"&&e.direction==="vertical"?"horizontal":"vertical";return{type:"split",id:vn(),direction:n,children:[e,{type:"panel",id:t}]}}function GP(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:vn(),direction:o?"vertical":"horizontal",children:i}}return e}return{...e,children:e.children.map(o=>GP(o,t,n,r))}}function WV(e,t,n,r){if(t===n)return e;let o=ow(e,t);return o?GP(o,t,n,r):{type:"panel",id:t}}function qV({targetId:e,isDragging:t,onDropPosition:n,children:r}){let[o,a]=wr.default.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(0,ln.jsxs)("div",{className:"relative flex-1 flex flex-col min-h-0 min-w-0 group",children:[r,t&&(0,ln.jsx)("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(0,ln.jsx)("div",{className:ne(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 YP({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?(0,ln.jsx)(qV,{targetId:l.id,onDropPosition:o,isDragging:i,children:(0,ln.jsx)(qP,{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(0,ln.jsx)(PP,{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(0,ln.jsxs)(wr.default.Fragment,{children:[(0,ln.jsx)(DP,{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:(0,ln.jsx)(YP,{node:l,panels:t,onTogglePin:n,onToggleVisibility:r,onMovePanel:o,chart:a,isDragging:i,setIsDragging:s})}),c<e.children.length-1&&(0,ln.jsx)(AP,{})]},u)})})}var UV=180,jV=280,GV=600;function KP({eventBus:e,chart:t,onFixedPanelsChange:n,override:r}){let o=(0,wr.useRef)(VP()).current,[a,i]=(0,wr.useState)(!1),[s,l]=(0,wr.useState)([]),[c,u]=(0,wr.useState)(()=>new Set(Object.entries(o.panels??{}).filter(([,O])=>O.pinned).map(([O])=>O))),[d,m]=(0,wr.useState)(o.tree??null),[f,h]=(0,wr.useState)(()=>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]=(0,wr.useState)(o.sidebarWidth??jV),y=(0,wr.useRef)(!1),[v,b]=(0,wr.useState)(new Map),[S,C]=(0,wr.useState)(new Map),w=(0,wr.useRef)(new Map),k=(0,wr.useCallback)((O,A,B)=>{i(!1),m(E=>E?WV(E,O,A,B):null)},[]);(0,wr.useEffect)(()=>{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=(0,wr.useCallback)(O=>o.panels?.[O]?.hidden===!0,[o]);(0,wr.useEffect)(()=>{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:H}])=>({id:B,title:L,element:E,visible:M(B)?!1:H})))}let A=[e.on("plugin:panel-added",({id:B,title:E,visible:L})=>{let H=t.getPanelRegistry().get(B)?.element;H&&(L&&M(B)&&t.setPanelVisible(B,!1),l(K=>{let G=K.findIndex(V=>V.id===B);if(G!==-1){let V=[...K];return V[G]={id:B,title:E,element:H,visible:K[G].visible},V}return[...K,{id:B,title:E,element:H,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(H=>H.id===B?{...H,visible:E}:H))})];return()=>A.forEach(B=>B())},[e,t]),(0,wr.useEffect)(()=>{for(let O of s)c.has(O.id)&&m(A=>jP(A,O.id)?A:WP(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?ow(E,O):null)):(B.add(O),m(E=>WP(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);(0,wr.useEffect)(()=>{n(T.length>0)},[T.length]),(0,wr.useEffect)(()=>{let O=setTimeout(()=>{let B={...VP().panels},E=new Set([...Object.keys(B),...c,...f.keys(),...s.map(L=>L.id)]);for(let L of E){let H=s.find(G=>G.id===L),K=f.get(L);B[L]={pinned:c.has(L),hidden:H?!H.visible:B[L]?.hidden??!1,...K?{x:Math.round(K.x),y:Math.round(K.y)}:{}}}Sr(Pn.pluginPanels,{sidebarWidth:p,tree:d,panels:B})},400);return()=>clearTimeout(O)},[c,f,d,p,s]);let R=(0,wr.useCallback)(O=>{O.preventDefault(),y.current=!0;let A=O.clientX,B=p,E=H=>{let K=A-H.clientX,G=Math.min(GV,Math.max(UV,B+K));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(j=>{let W=new Map(j);return W.set(O,B+1),W});let E=f.get(O)??{x:100,y:100},{x:L,y:H}=E,K=A.clientX-L,G=A.clientY-H,V=j=>{L=j.clientX-K,H=j.clientY-G,h(W=>new Map(W).set(O,{x:L,y:H}))},q=()=>{window.removeEventListener("mousemove",V),window.removeEventListener("mouseup",q)};window.addEventListener("mousemove",V),window.addEventListener("mouseup",q)},D=s.filter(O=>!c.has(O.id)&&O.visible),N=UP(d,new Set(T.map(O=>O.id)));return(0,ln.jsxs)(ln.Fragment,{children:[!r&&T.length===0&&(0,ln.jsxs)("div",{className:"flex flex-row shrink-0 border-l border-border bg-background overflow-hidden",style:{width:p},children:[(0,ln.jsx)("div",{className:"w-1 shrink-0 cursor-col-resize hover:bg-primary/40 active:bg-primary/60 transition-colors",style:{zIndex:10},onMouseDown:R}),(0,ln.jsxs)("div",{className:"flex w-full h-full items-center justify-center text-xs text-muted-foreground",children:["No pinned",(0,ln.jsxs)(FP,{openDelay:0,children:[(0,ln.jsx)(zP,{className:"underline ml-1",children:"panels"}),(0,ln.jsxs)(nw,{className:"p-2",children:["Panels are windows that ",(0,ln.jsx)("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&&(0,ln.jsxs)("div",{className:"flex flex-row shrink-0 border-l border-border bg-background overflow-hidden",style:{width:p},children:[(0,ln.jsx)("div",{className:"w-1 shrink-0 cursor-col-resize hover:bg-primary/40 active:bg-primary/60 transition-colors",style:{zIndex:10},onMouseDown:R}),(0,ln.jsx)("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden",children:(0,ln.jsx)(YP,{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(0,ln.jsx)("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 H=L.clientHeight;v.get(O.id)!==H&&b(G=>{let V=new Map(G);return V.set(O.id,H),V})}else w.current.delete(O.id)},children:(0,ln.jsx)(qP,{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)})]})}var ig=require("react");var zi=require("react/jsx-runtime");function $P({eventBus:e,chart:t}){let[n,r]=(0,ig.useState)(()=>[...t.getToolbarRegistry().values()]);return(0,ig.useEffect)(()=>{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:(0,zi.jsxs)(zi.Fragment,{children:[(0,zi.jsx)("div",{className:"w-px h-4 bg-border mx-1 shrink-0"}),n.map(o=>(0,zi.jsxs)(Gt,{children:[(0,zi.jsx)(qt,{asChild:!0,children:(0,zi.jsx)("button",{onClick:o.onClick,disabled:o.disabled,className:ne("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})}),(0,zi.jsx)(Ut,{side:"bottom",className:"bg-background border border-border",children:o.title})]},o.id))]})}var ia=Ct(require("react"));var fo=require("react/jsx-runtime");function YV({id:e,render:t,eventBus:n}){let[,r]=(0,ia.useReducer)(o=>o+1,0);return(0,ia.useEffect)(()=>n.on("plugin:bottom-bar-item-rerender",({id:o})=>{o===e&&r()}),[e,n]),(0,fo.jsx)(fo.Fragment,{children:t()})}function XP({eventBus:e,chart:t}){let[n,r]=(0,ia.useState)(()=>[...t.getBottomBarRegistry().values()]),[o,a]=(0,ia.useState)(null),[i,s]=(0,ia.useState)(!1),[l,c]=(0,ia.useState)(!1);if((0,ia.useEffect)(()=>{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]),(0,ia.useEffect)(()=>{o&&requestAnimationFrame(()=>{s(o.scrollLeft>0),c(o.scrollLeft+o.clientWidth<o.scrollWidth-1)})},[n,o]),(0,ia.useEffect)(()=>{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(0,fo.jsxs)(fo.Fragment,{children:[(0,fo.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1 shrink-0"}),(0,fo.jsx)("button",{onClick:()=>u("left"),className:ne("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:(0,fo.jsx)(Ll,{size:11})}),(0,fo.jsx)("div",{ref:a,className:"flex items-center overflow-x-auto min-w-0 flex-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,fo.jsx)("div",{className:"flex items-center gap-0.5 mx-auto",children:n.map((d,m)=>(0,fo.jsxs)(ia.default.Fragment,{children:[m>0&&(0,fo.jsx)("div",{className:"w-px h-3 bg-border/30 mx-0.5 shrink-0"}),(0,fo.jsx)("div",{className:"shrink-0 flex items-center",children:(0,fo.jsx)(YV,{id:d.id,render:d.render,eventBus:e})})]},d.id))})}),(0,fo.jsx)("button",{onClick:()=>u("right"),className:ne("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:(0,fo.jsx)(Yi,{size:11})}),(0,fo.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1 shrink-0"})]})}var wm=require("react");var Lr=require("react/jsx-runtime");function ZP({eventBus:e,chart:t}){let[n,r]=(0,wm.useState)([]),[o,a]=(0,wm.useState)(!1);(0,wm.useEffect)(()=>{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(0,Lr.jsxs)(Va,{open:o,onOpenChange:a,children:[(0,Lr.jsx)(Wa,{asChild:!0,children:(0,Lr.jsxs)("button",{className:ne("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:[(0,Lr.jsx)(si,{size:13,className:"shrink-0"}),(0,Lr.jsx)("span",{children:"Windows"}),(0,Lr.jsx)(or,{className:ne("w-3 h-3 text-muted-foreground transition-all duration-200",o&&"rotate-180")})]})}),(0,Lr.jsxs)(ya,{align:"end",sideOffset:6,className:"p-2 w-64 border border-border bg-background rounded-xl shadow-2xl",children:[(0,Lr.jsx)("p",{className:"px-1.5 pb-2 text-[10px] font-medium text-muted-foreground/50 uppercase tracking-widest",children:"Hidden panels"}),s===0?(0,Lr.jsxs)("div",{className:"flex flex-col items-center gap-1.5 py-6 text-center",children:[(0,Lr.jsx)(si,{size:16,className:"text-muted-foreground/30"}),(0,Lr.jsx)("p",{className:"text-xs text-muted-foreground/40",children:"All panels visible"})]}):(0,Lr.jsx)("div",{className:"flex flex-col gap-1",children:n.map(l=>(0,Lr.jsxs)(aa,{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:[(0,Lr.jsxs)("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:[(0,Lr.jsx)("div",{className:"absolute inset-0 z-10 cursor-pointer"}),(0,Lr.jsx)("div",{className:"h-24 overflow-hidden",children:(0,Lr.jsx)("div",{style:{transform:"scale(0.75)",transformOrigin:"top left",width:`${100/.75}%`,pointerEvents:"none"},children:(0,Lr.jsx)(rw,{element:l.element})})}),(0,Lr.jsx)("div",{className:"absolute bottom-0 inset-x-0 h-8 bg-gradient-to-t from-background/80 to-transparent z-20 pointer-events-none"}),(0,Lr.jsxs)("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:[(0,Lr.jsx)("span",{className:"text-xs font-medium text-foreground drop-shadow-sm",children:l.title}),(0,Lr.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Click to show"})]})]}),(0,Lr.jsx)("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))})]})]})}var mo=require("react");var t2=Ct(require("react"));var io=Ct(require("react"),1);var Sa=require("react/jsx-runtime"),KV=Object.defineProperty,bs=(e,t)=>KV(e,"name",{value:t,configurable:!0}),aw="Checkbox",[$V,Eoe]=kr(aw),[XV,iw]=$V(aw);function QP(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]=Lo({prop:n,defaultProp:o??!1,onChange:l,caller:aw}),[h,p]=io.useState(null),[g,y]=io.useState(null),v=io.useRef(!1),[b,S]=io.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:gs(o)?!1:o,isFormControl:C,bubbleInput:g,setBubbleInput:y};return(0,Sa.jsx)(XV,{scope:t,...w,children:e2(d)?d(w):r})}bs(QP,"CheckboxProvider");var ZV="CheckboxTrigger",QV=io.forwardRef(bs(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}=iw(ZV,t),y=nn(a,d),v=io.useRef(c);return io.useEffect(()=>{let b=i?.form;if(b){let S=bs(()=>m(v.current),"reset");return b.addEventListener("reset",S),()=>b.removeEventListener("reset",S)}},[i,m]),(0,Sa.jsx)(hn.button,{type:"button",role:"checkbox","aria-checked":gs(c)?"mixed":c,"aria-required":u,"data-state":lw(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=>gs(S)?!0:!S),g&&p&&(f.current=b.isPropagationStopped(),f.current||b.stopPropagation())})})},"CheckboxTrigger")),sw=io.forwardRef(bs(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(0,Sa.jsx)(QP,{__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})=>(0,Sa.jsxs)(Sa.Fragment,{children:[(0,Sa.jsx)(QV,{...m,ref:n,__scopeCheckbox:r}),f&&(0,Sa.jsx)(tW,{__scopeCheckbox:r})]})})},"Checkbox")),JV="CheckboxIndicator",JP=io.forwardRef(bs(function(t,n){let{__scopeCheckbox:r,forceMount:o,...a}=t,i=iw(JV,r);return(0,Sa.jsx)(Xo,{present:o||gs(i.checked)||i.checked===!0,children:(0,Sa.jsx)(hn.span,{"data-state":lw(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:n,style:{pointerEvents:"none",...t.style}})})},"CheckboxIndicator")),eW="CheckboxBubbleInput",tW=io.forwardRef(bs(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}=iw(eW,t),y=nn(o,g),v=Xi(a),b=io.useRef(!1),S=io.useRef(l),C=io.useRef(s);io.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=gs(l),x.call(k,gs(l)?!1:l),k.dispatchEvent(D),b.current=!1}},[p,l,i,s]);let w=io.useRef(gs(l)?!1:l);return(0,Sa.jsx)(hn.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 e2(e){return typeof e=="function"}bs(e2,"isFunction");function gs(e){return e==="indeterminate"}bs(gs,"isIndeterminate");function lw(e){return gs(e)?"indeterminate":e?"checked":"unchecked"}bs(lw,"getState");var sg=require("react/jsx-runtime"),cw=t2.forwardRef(({className:e,...t},n)=>(0,sg.jsx)(sw,{ref:n,className:ne("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:(0,sg.jsx)(JP,{className:ne("flex items-center justify-center text-current"),children:(0,sg.jsx)(Yr,{className:"h-4 w-4"})})}));cw.displayName=sw.displayName;var en=require("react/jsx-runtime"),n2={indicator:{label:"Indicators",Icon:Bs},drawing:{label:"Drawings",Icon:Zd},"chart-type":{label:"Chart types",Icon:Li},extension:{label:"Extensions",Icon:Kd},"data-source":{label:"Data sources",Icon:$d},unknown:{label:"Other",Icon:Bl}},rW=["extension","indicator","drawing","chart-type","data-source","unknown"];function oW(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 aW({row:e,problem:t,onToggleLoaded:n,onToggleActive:r,onToggleAutostart:o}){let{Icon:a}=n2[e.kind];return(0,en.jsxs)("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:[(0,en.jsx)(a,{size:14,className:"shrink-0 text-muted-foreground"}),(0,en.jsxs)("div",{className:"flex flex-col min-w-0 flex-1",children:[(0,en.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,en.jsx)("span",{className:"text-[13px] text-foreground truncate",children:e.name}),e.loaded&&e.kind==="indicator"&&(0,en.jsx)("span",{className:ne("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&&(0,en.jsx)("span",{className:"shrink-0 px-1.5 h-4 rounded bg-muted text-muted-foreground text-[10px] leading-4",children:"bundled"})]}),t?(0,en.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-amber-500 truncate",children:[(0,en.jsx)(ga,{size:10,className:"shrink-0"}),t]}):e.description&&(0,en.jsx)("span",{className:"text-[11px] text-muted-foreground truncate",children:e.description})]}),e.kind==="indicator"&&(0,en.jsxs)(Gt,{delayDuration:500,children:[(0,en.jsx)(qt,{asChild:!0,children:(0,en.jsx)("button",{disabled:!e.loaded,onClick:()=>r(!e.active),className:ne("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"})}),(0,en.jsx)(Ut,{className:"bg-background border border-border",children:e.active?"Take it off the panes":"Put an instance on the chart"})]}),(0,en.jsxs)(Gt,{delayDuration:500,children:[(0,en.jsx)(qt,{asChild:!0,children:(0,en.jsx)("div",{className:"shrink-0 flex items-center justify-center w-10",children:(0,en.jsx)(cw,{checked:e.autostart,disabled:!e.available,onCheckedChange:o,className:"disabled:opacity-30"})})}),(0,en.jsx)(Ut,{className:"bg-background border border-border",children:"Load this plugin whenever the chart opens"})]}),(0,en.jsx)(so,{checked:e.loaded,disabled:!e.available,onCheckedChange:n,className:"shrink-0 data-[state=checked]:bg-blue-500"})]})}function iW({chart:e,eventBus:t,open:n,onOpenChange:r,loaded:o}){let a=(0,mo.useRef)(null),[i,s]=(0,mo.useState)([]),[l,c]=(0,mo.useState)({}),[u,d]=(0,mo.useState)(""),m=(0,mo.useCallback)(()=>s(oW(e)),[e]);(0,mo.useEffect)(()=>{if(n)return m(),e.onPluginStateChange(m)},[e,n,m]),(0,mo.useEffect)(()=>{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=(0,mo.useMemo)(()=>{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=(0,mo.useMemo)(()=>rW.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(0,mo.useEffect)(()=>{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]),(0,en.jsxs)("div",{className:"relative",ref:a,children:[(0,en.jsxs)(Gt,{delayDuration:700,children:[(0,en.jsx)(qt,{asChild:!0,children:(0,en.jsxs)("button",{onClick:()=>r(!n),className:ne("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:[(0,en.jsx)(Bl,{size:13,className:"shrink-0"}),(0,en.jsx)("span",{children:"Plugins"}),(0,en.jsx)(or,{className:ne("w-3 h-3 transition-all duration-200 text-muted-foreground",n&&"rotate-180")})]})}),(0,en.jsx)(Ut,{className:"bg-background border border-border",children:"Loaded plugins, and what starts with the chart"})]}),n&&(0,en.jsxs)("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:[(0,en.jsxs)("div",{className:"px-4 pt-4 pb-3 shrink-0",children:[(0,en.jsx)("div",{className:"text-sm font-medium",children:"Plugins"}),(0,en.jsxs)("div",{className:"text-xs",children:[v," of ",i.length," loaded. Anything switched on here comes back the next time you open the chart."]})]}),(0,en.jsxs)("div",{className:"flex items-center gap-2 px-4 h-10 border-y border-border shrink-0",children:[(0,en.jsx)(li,{size:13,className:"shrink-0 text-muted-foreground"}),(0,en.jsx)("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"})]}),(0,en.jsxs)("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:[(0,en.jsx)("span",{className:"flex-1",children:"Plugin"}),(0,en.jsx)("span",{className:"w-10 text-center",children:"Startup"}),(0,en.jsx)("span",{className:"w-9 text-right",children:"On"})]}),(0,en.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 py-1",children:h.length===0?(0,en.jsxs)("div",{className:"flex flex-col items-center gap-1.5 py-14 text-center",children:[(0,en.jsx)(Bl,{size:18,className:"text-muted-foreground/30"}),(0,en.jsx)("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})=>(0,en.jsxs)("div",{className:"pb-1",children:[(0,en.jsx)("p",{className:"px-4 pt-2 pb-1 text-[10px] font-medium uppercase tracking-widest text-muted-foreground/50",children:n2[b].label}),(0,en.jsx)("div",{className:"px-1",children:S.map(C=>(0,en.jsx)(aW,{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 r2({chart:e,eventBus:t}){let[n,r]=(0,mo.useState)(!1),o=s=>[...s].filter(l=>!l.startsWith("builtin:")).length,[a,i]=(0,mo.useState)(()=>o(e.getPluginState().installed));return(0,mo.useEffect)(()=>(i(o(e.getPluginState().installed)),e.onPluginStateChange(s=>i(o(s.installed)))),[e]),(0,mo.useEffect)(()=>t.on("plugin:open-manager",()=>r(!0)),[t]),a===0&&e.getPluginCatalog().length===0?null:(0,en.jsx)(iW,{chart:e,eventBus:t,open:n,onOpenChange:r,loaded:a})}var gt=require("react/jsx-runtime");function sW(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 uw(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 xm({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=(0,Ke.useRef)(t??new il).current;(0,Ke.useEffect)(()=>b.on("error",({message:Q})=>{xi.error(Q)}),[b]),(0,Ke.useEffect)(()=>b.on("plugin:incompatible",({id:Q,name:X,kind:ye,required:Te,actual:ct})=>{let vt=ye==="chart-type"?"Chart type":ye==="indicator"?"Indicator":"Plugin";xi.warning(`${vt} "${X??Q}" is unavailable here`,{description:ol(Te,ct)})}),[b]);let[S,C]=(0,Ke.useState)(()=>f.get("layout")),w=(0,Ke.useRef)(S);(0,Ke.useEffect)(()=>{w.current=S},[S]);let[k,M]=(0,Ke.useState)(()=>f.get("syncInLayout")??lm),I=(0,Ke.useRef)(k);(0,Ke.useEffect)(()=>{I.current=k,f.set("syncInLayout",k)},[f,k]);let[x,T]=(0,Ke.useState)(()=>{let Q=f.get("focusedPane")??0;return Q<f.get("layout").count?Q:0}),[R,P]=(0,Ke.useState)(()=>{let Q=f.get("gridColSizes"),X=f.get("layout").cols;return Q&&Q.length===X?Q:Array(X).fill(1)}),[D,N]=(0,Ke.useState)(()=>{let Q=f.get("gridRowSizes"),X=f.get("layout").rows;return Q&&Q.length===X?Q:Array(X).fill(1)});(0,Ke.useEffect)(()=>{f.set("gridColSizes",R)},[f,R]),(0,Ke.useEffect)(()=>{f.set("gridRowSizes",D)},[f,D]),(0,Ke.useEffect)(()=>{f.set("focusedPane",x)},[f,x]);let O=(0,Ke.useRef)(null),[A,B]=(0,Ke.useState)(!1),[E,L]=(0,Ke.useState)(!0),H=(0,Ke.useRef)(Array(Xa).fill(null)),[K,G]=(0,Ke.useState)("ohlcv"),V=(0,Ke.useRef)(K);V.current=K;let q=(0,Ke.useRef)(null),j=(0,Ke.useRef)(null),W=(0,Ke.useRef)(null),$=(0,Ke.useRef)(""),[J,me]=(0,Ke.useState)(()=>{let Q=Array(Xa).fill(!1);for(let X=0;X<Math.max(1,f.get("layout").count);X++)Q[X]=!0;return Q}),[We,Ce]=(0,Ke.useState)(f.get("timeframe")),[Ee,ze]=(0,Ke.useState)(()=>Hx()),[Ie,ee]=(0,Ke.useState)(Xe),[Be,F]=(0,Ke.useState)([]),[le,ce]=(0,Ke.useState)(Yo),[ke,De]=(0,Ke.useState)(!1);(0,Ke.useEffect)(()=>{ee(e.getChart(x).settings)},[e,x]);let ve=(0,Ke.useRef)(null),[Qe,Ye]=(0,Ke.useState)([]),$e=(0,Ke.useRef)(Qe);(0,Ke.useEffect)(()=>{$e.current=Qe},[Qe]);let bt=Qe.find(Q=>Q.chartTypeId===Ie.chartType)??null,[Oe,Tt]=(0,Ke.useState)([]),bn=(0,Ke.useRef)(Oe);(0,Ke.useEffect)(()=>{bn.current=Oe},[Oe]);let[En,Lt]=(0,Ke.useState)([]),it=(0,Ke.useRef)([]),ft=(0,Ke.useRef)(new Set);(0,Ke.useEffect)(()=>{let Q=[...e.getRegisteredPlugins().values()];Q.length>0&&(it.current=Q,Lt(Q))},[]),(0,Ke.useEffect)(()=>{it.current=En},[En]);let ie=f.get("symbol"),ge=(0,Ke.useCallback)(()=>Array.from({length:Xa},(Q,X)=>e.getChart(X).symbol),[e]),[pe,Le]=(0,Ke.useState)(ge),Ue=(0,Ke.useRef)(pe);(0,Ke.useEffect)(()=>{Ue.current=pe},[pe]),(0,Ke.useEffect)(()=>{let Q=()=>Le(ye=>{let Te=ge();return Te.length===ye.length&&Te.every((ct,vt)=>ct===ye[vt])?ye:Te}),X=Array.from({length:Xa},(ye,Te)=>e.getChart(Te).subscribe(Q));return Q(),()=>X.forEach(ye=>ye())},[e,ge]);let[,Ge]=(0,Ke.useState)(0),Ve=(0,Ke.useCallback)((Q,X)=>{e.getChart(Q).setSymbol(X)},[e]),Ne=n??e.executionEngine,{byCell:Se,bySymbol:He}=JR(pe,b,e,Ne);(0,Ke.useEffect)(()=>{Ne.setActiveSymbol(pe[x]??"")},[Ne,pe,x]);let _e=(0,Ke.useRef)(He);_e.current=He;let dt=(0,Ke.useRef)(Ne);dt.current=Ne;let _t=Q=>{let X=$e.current.find(ct=>ct.chartTypeId===Q);if(!X)return!1;let ye=X.require??"ohlcv",Te=V.current;return Bo(ye,Te)?!1:(b.emit("plugin:incompatible",{id:Q,name:X.label??X.name,kind:"chart-type",required:ye,actual:Te}),!0)},te=Se[x]??Se[0],Me=(0,Ke.useRef)(te);(0,Ke.useEffect)(()=>{Me.current=te},[te]),(0,Ke.useEffect)(()=>b.on("execution:setAdapter",({adapter:Q})=>{Ne.setCustomAdapter(Q)}),[Ne]);let Pe=(0,Ke.useRef)(Array(Xa).fill(!1));(0,Ke.useEffect)(()=>{J.forEach((Q,X)=>{Q&&!Pe.current[X]&&(Pe.current[X]=!0,requestAnimationFrame(()=>{b.emit("data:rehydrate",void 0)}))})},[J]);let at=(0,Ke.useMemo)(()=>{let Q=new Set;for(let X of S.areas.replace(/"/g,""))X>="a"&&X<="h"&&Q.add(X);return[...Q].sort()},[S]),nt=(0,Ke.useCallback)(()=>{let Q=Math.max(1,w.current.count);return Array.from({length:Math.min(Q,Xa)},(X,ye)=>ye)},[]),pt=(0,Ke.useRef)(!1),Xt=(0,Ke.useCallback)((Q,X)=>{if(!pt.current){pt.current=!0;try{for(let ye of nt())ye!==X&&Ue.current[ye]!==Q&&b.emit("chart:set-symbol",{symbol:Q,id:ye})}finally{pt.current=!1}}},[nt,b]),Ft=(0,Ke.useCallback)((Q,X)=>{if(!pt.current){pt.current=!0;try{for(let ye of nt())ye!==X&&H.current[ye]?.handleTimeframeChange(Q,!0)}finally{pt.current=!1}}},[nt]),cr=(0,Ke.useCallback)(Q=>{let X=I.current;I.current=Q,M(Q);let ye=de.current;if(Q.symbol&&!X.symbol){let Te=Ue.current[ye];Te&&Xt(Te,ye)}if(Q.interval&&!X.interval){let Te=H.current[ye]?.getActiveTimeframe();Te&&Ft(Te,ye)}if(Q.time&&!X.time||Q.dateRange&&!X.dateRange){let Te=H.current[ye]?.getVisibleRange();Te&&b.emit("layout:time-range",{id:ye,...Te})}},[b,Xt,Ft]),Mn=(0,Ke.useCallback)((Q,...X)=>{let ye=H.current[x];ye&&typeof ye[Q]=="function"&&ye[Q](...X)},[x]),ir=(0,Ke.useCallback)(Q=>{b.emit("data:prefetch",{spanNs:Q})},[b]),Vn=(0,Ke.useCallback)((Q,X)=>{let ye=dt.current,Te=Q.symbol;if(_e.current.some(ct=>ct.symbol===Te)){switch(Q.dataLevel){case"l3":{let ct=Q.compactBuf.slice(0);X==="append"?ye.appendCompactBuf(ct,Te):ye.ingestCompactBuf(ct,Te);break}case"ohlcv":{let ct=Q.ohlcvBars??[];X==="append"?ye.appendOhlcvBars(ct,Q.barNs,Te):ye.ingestOhlcvBars(ct,Q.barNs,Te);let vt=Q.supplemental;if(vt?.length){let ue=vt.reduce((Fe,St)=>!Fe||St.resolution<Fe.resolution?St:Fe);ue.bars.length&&(X==="append"?ye.appendSupplementalBars(ue.bars,Te):ye.ingestSupplementalBars(ue.bars,Te))}break}case"tick":X==="append"?ye.appendTicks(Q.trades??[],Te):ye.ingestTicks(Q.trades??[],Te);break;case"l2":X==="append"?ye.appendPriceHistory(Q.priceHistory??[],Te):ye.ingestPriceHistory(Q.priceHistory??[],Te);break}if(!ye.hasPrice(Te)){let ct=_n.current||fr.current;ct>0n&&ye.seekTo(ct,Te)}}},[]),fr=(0,Ke.useRef)(BigInt(Math.round(e.horizon()))*1000000n),_n=(0,Ke.useRef)(BigInt(Math.round(e.horizon()))*1000000n),qn=(0,Ke.useCallback)(Q=>{_n.current=Q,dt.current.seekTo(Q);let X=Ie.timezone??"UTC";(!j.current||$.current!==X)&&(j.current=new Intl.DateTimeFormat("sv-SE",{timeZone:X,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),$.current=X);let ye=Number(Q/1000000n),Te=Math.floor(Number(Q/1000n%1000000n)/1e3),ct=Te<10?"00"+Te:Te<100?"0"+Te:""+Te;uw(q.current,y==="ms"?j.current.format(ye)+"."+ct:j.current.format(ye)),b.emit("playback:seek",{tNs:Q})},[Ie]),z=NR({chartRefs:H,sharedHorizonRef:fr,onRequestMore:ir,onTick:qn,eventBus:b,prefetch:d,clockSymbol:()=>Ue.current[de.current]});(0,Ke.useEffect)(()=>b.on("data:bounds",({start:Q,end:X,symbol:ye})=>{ye!==void 0&&ye!==Ue.current[de.current]||z.notifyDataBounds(Q,X)}),[]),(0,Ke.useEffect)(()=>{let Q=[b.on("plugin:register-indicator",({indicator:X,pane:ye,activeByDefault:Te})=>{let ct=it.current.findIndex(Fe=>Fe.indicator.id===X.id);if(ct!==-1){it.current=it.current.map((Fe,St)=>St===ct?{indicator:X,pane:ye,activeByDefault:Te}:Fe),Lt(it.current);for(let Fe=0;Fe<H.current.length;Fe++)H.current[Fe]?.replacePluginIndicator(X);return}if(it.current.some(Fe=>Fe.indicator.id===X.id))return;it.current=[...it.current,{indicator:X,pane:ye,activeByDefault:Te}],Lt(it.current);let vt=X.id.replace(/:(\d+)$/,""),ue=ft.current.has(vt);if(Te||ue){ue&&ft.current.delete(vt);for(let Fe=0;Fe<H.current.length;Fe++)H.current[Fe]?.activatePluginIndicator(X,ye)}}),b.on("chart:add-plugin-indicator",({pluginId:X})=>{let ye=it.current.find(Te=>Te.indicator.id===X||Te.indicator.id.startsWith(`${X}:`));if(!ye){ft.current.add(X);return}for(let Te=0;Te<H.current.length;Te++)H.current[Te]?.activatePluginIndicator(ye.indicator,ye.pane)}),b.on("plugin:uninstalled",({id:X})=>{ft.current.delete(X);let ye=it.current.filter(Te=>Te.indicator.id!==X&&!Te.indicator.id.startsWith(`${X}:`));ye.length!==it.current.length&&(it.current=ye,Lt(ye))}),b.on("plugin:register-chart-type",({plugin:X})=>{$e.current=[...$e.current.filter(Te=>Te.id!==X.id),X],Ye($e.current);let ye=e.getChart(de.current).settings.pluginSettings?.[X.chartTypeId];ye&&X.onSettingsChange?.(ye)}),b.on("plugin:unregister-chart-type",({id:X,hotReload:ye})=>{ye||($e.current=$e.current.filter(Te=>Te.chartTypeId!==X),Ye($e.current))}),b.on("plugin:register-drawing",X=>{let{id:ye,name:Te,icon:ct}=X;bn.current.some(vt=>vt.id===ye)||(bn.current=[...bn.current,{id:ye,name:Te,icon:ct}],Tt(bn.current))}),b.on("plugin:unregister-drawing",X=>{let{id:ye}=X;bn.current.some(Te=>Te.id.includes(ye))&&(bn.current=bn.current.filter(Te=>!Te.id.includes(ye)),Tt(bn.current))}),b.on("trading:buy-market",({amount:X})=>{Me.current?.executionEngine?.placeOrder({qty:X,side:"long",type:"market",symbol:Me.current.symbol})}),b.on("trading:sell-market",({amount:X})=>{Me.current?.executionEngine?.placeOrder({qty:X,side:"short",type:"market",symbol:Me.current.symbol})}),b.on("trading:flatten",()=>{for(let X of _e.current)if(X?.symbol)for(let ye of[...X.trading.positions.values()])ye.remainingQuantity<=0||X.executionEngine?.closePosition(ye.id)}),b.on("chart:set-timeframe",({tf:X})=>{Ce(X),H.current[de.current]?.handleTimeframeChange(X)}),b.on("layout:timeframe",({id:X,tf:ye})=>{X===de.current&&(Ce(ye),f.set("timeframe",ye)),I.current.interval&&Ft(ye,X)}),b.on("chart:apply-settings",({patch:X})=>{if(X.chartType&&_t(X.chartType)){let{chartType:ye,...Te}=X;X=Te}ee(ye=>({...ye,...X})),H.current[de.current]?.applySettings(X)}),b.on("chart:set-symbol",({symbol:X,id:ye})=>{Ve(ye,X),I.current.symbol&&!be.current&&Xt(X,ye)}),b.on("features:change",()=>Ge(X=>X+1)),b.on("chart:set-symbol-focused",({symbol:X})=>{b.emit("chart:set-symbol",{symbol:X,id:de.current})}),b.on("data:load",X=>{G(X.dataLevel),Vn(X,X.rehydrate?"append":"load")}),b.on("data:append",X=>Vn(X,"append")),b.on("playback:play",()=>z.play()),b.on("playback:pause",()=>z.pause()),b.on("playback:set-speed",X=>z.setSpeed(X.speed)),b.on("playback:set-step-size",X=>z.setStepSize(X.step)),b.on("playback:step-back",()=>{e.playback.floor===null&&z.stepBack()}),b.on("playback:step-forward",()=>z.stepForward()),b.on("playback:goto",({tNs:X})=>{e.playback.allows(X)&&z.scrub(X)}),b.on("playback:set-mode",X=>z.setMode(X.mode)),b.on("playback:set-step-snap",X=>z.setStepSnap(X.snap))];return()=>Q.forEach(X=>X())},[b]),(0,Ke.useEffect)(()=>{b.emit("chart:focused",{id:x})},[x]);let ae=(0,Ke.useRef)(null),fe=(0,Ke.useRef)(null);(0,Ke.useEffect)(()=>{if(!ae.current)return;let Q=sW(Ie.timezone,fr.current),X=Q==="UTC"?Q:"UTC"+Q;if(fe.current===X)return;fe.current=X,ae.current.textContent=X;let ye=Ie.timezone??"UTC";(!j.current||$.current!==ye)&&(j.current=new Intl.DateTimeFormat("sv-SE",{timeZone:ye,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),$.current=ye);let Te=Number(_n.current/1000000n),ct=Math.floor(Number(_n.current/1000n%1000000n)/1e3),vt=ct<10?"00"+ct:ct<100?"0"+ct:""+ct;y==="ms"?uw(q.current,y==="ms"?j.current.format(Te)+"."+vt:j.current.format(Te)):q.current.textContent=j.current.format(Te)},[Ie]);let de=(0,Ke.useRef)(x);(0,Ke.useEffect)(()=>{de.current=x},[x]);let U=(0,Ke.useRef)(J);(0,Ke.useEffect)(()=>{U.current=J},[J]);let be=(0,Ke.useRef)(!1);(0,Ke.useEffect)(()=>{let Q=requestAnimationFrame(()=>{let X=Math.max(1,f.get("layout").count),ye=[];for(let ct=0;ct<X;ct++)ct!==de.current&&ye.push(ct);ye.push(de.current);let Te=new Set;be.current=!0;try{for(let ct of ye){let vt=e.getChart(ct).symbol;!vt||Te.has(vt)||(Te.add(vt),b.emit("chart:set-symbol",{symbol:vt,id:ct}))}}finally{be.current=!1}});return()=>cancelAnimationFrame(Q)},[]);let he=(0,Ke.useCallback)(()=>{let Q=Math.max(1,f.get("layout").count);for(let X=0;X<Q;X++){let ye=H.current[X];if(!ye?.activatePluginIndicator||!ye.getIndicators)continue;let Te=e.getChart(X),ct=Te.restoredPlugins;if(!ct.length)continue;let vt=new Set((ye.getIndicators()??[]).map(ue=>ue.id));for(let ue of ct){let Fe=it.current.find(St=>St.indicator.id===ue.instanceId);if(Fe){if(!vt.has(ue.instanceId)){let St=ue.config??{},Et={...Fe.indicator,id:ue.instanceId,settings:St.settings??Fe.indicator.settings,visible:St.visible??!0,layout:St.layout??Fe.indicator.layout,paneId:St.paneId??Fe.indicator.paneId};ye.activatePluginIndicator(Et,Fe.pane)}Te.consumeRestoredPlugin(ue.instanceId)}}}},[e,f]);(0,Ke.useEffect)(()=>{he()},[En,J,he]);let je=(0,Ke.useRef)(0),rt=(0,Ke.useRef)(0),yt=(0,Ke.useRef)(null),xt=()=>{let Q=H.current[de.current];if(!Q)return;let X=Q.getActiveTimeframe?.();X&&(Ce(X),f.set("timeframe",X));let ye=Q.getIndicators?.(),Te=Q.getActiveTool?.();Te!==void 0&&ce(Te),ye&&F(vt=>vt.length===ye.length&&vt.every((ue,Fe)=>ue.id===ye[Fe]?.id&&ue.visible===ye[Fe]?.visible)?vt:[...ye]);let ct=Q.getChartSettings?.();ct&&ee(vt=>JSON.stringify(vt)===JSON.stringify(ct)?vt:ct)};(0,Ke.useEffect)(()=>{let Q=()=>{let X=de.current,ye=H.current[X];if(ye){let Te=ye.getHorizon?.()??0n;if(Te>0n&&Te!==fr.current){if(fr.current=Te,b.emit("playback:seek",{tNs:Te}),q.current&&Te>0n){let vt=Ie.timezone??"UTC";(!j.current||!W.current||$.current!==vt)&&(W.current=new Intl.DateTimeFormat("sv-SE",{timeZone:vt,year:"numeric",month:"2-digit",day:"2-digit"}),j.current=new Intl.DateTimeFormat("sv-SE",{timeZone:vt,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),$.current=vt);let ue=Number(Te/1000000n),Fe=Math.floor(Number(Te/1000n%1000000n)/1e3),St=Fe<10?"00"+Fe:Fe<100?"0"+Fe:""+Fe;uw(q.current,y==="ms"?j.current.format(ue)+"."+St:j.current.format(ue))}if(ve.current===null){let vt=U.current;H.current.forEach((ue,Fe)=>{Fe===X||!ue||!vt[Fe]||ue.seekHorizon(Te)})}}let ct=performance.now();ct-rt.current>=200&&(rt.current=ct,xt())}je.current=requestAnimationFrame(Q)};return je.current=requestAnimationFrame(Q),()=>cancelAnimationFrame(je.current)},[]),(0,Ke.useEffect)(()=>{de.current=x,xt();let Q=H.current[x];Q&&fr.current>0n&&Q.seekHorizon(fr.current);let X=Q?.getDataBounds?.();X&&X.end>0n&&z.notifyDataBounds(X.start,X.end)},[x]);let[,ht]=(0,Ke.useState)(0);(0,Ke.useEffect)(()=>{let Q=()=>{ve.current!==null&&(ve.current=null,ht(X=>X+1))};return window.addEventListener("mouseup",Q),()=>window.removeEventListener("mouseup",Q)},[]);let Je=(0,Ke.useCallback)(Q=>{b.emit("chart:change-layout",{preset:Q}),f.set("layout",Q),C(Q),P(Array(Q.cols).fill(1)),N(Array(Q.rows).fill(1)),T(X=>X<Q.count?X:0),me(X=>{let ye=[...X];for(let Te=0;Te<Q.count;Te++)ye[Te]=!0;return ye})},[]),Rt=(0,Ke.useCallback)((Q,X)=>{let ye=O.current;ye&&P(Te=>Nv(Te,Q,X,ye.clientWidth))},[]),Jt=(0,Ke.useCallback)((Q,X)=>{let ye=O.current;ye&&N(Te=>Nv(Te,Q,X,ye.clientHeight))},[]),rn=(Q,X)=>{f.set(Q,X),Q==="selectedDrawingId"&&b.emit("drawing:selected",{id:X??null})};return(0,gt.jsx)(hh,{delayDuration:400,children:(0,gt.jsxs)("div",{className:"depth-root w-full h-full flex flex-col bg-background text-foreground overflow-hidden outline-none min-h-[120px]",ref:yt,tabIndex:0,children:[!o&&(0,gt.jsx)(hh,{delayDuration:400,children:(0,gt.jsxs)("div",{className:"flex items-center h-9 px-2 border-b shrink-0 gap-0.5",children:[(0,gt.jsx)("div",{className:"absolute left-0 top-0 w-[15rem] h-[2.2rem] bg-gradient-to-r from-[#0286f9]/10 to-background"}),(0,gt.jsx)(Iv,{eventBus:b,symbol:pe[x]??ie,onSymbolChange:Q=>{Ve(x,Q),b.emit("chart:set-symbol",{symbol:Q,id:x})}}),(0,gt.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),(0,gt.jsx)(nR,{eventBus:b,value:We,customTimeframes:Ee,features:g,onChange:Q=>{Ce(Q),f.set("timeframe",Q,b)},onAddCustom:Q=>{ze(X=>{let ye=[...X,Q];return nb(ye),ye})},onRemoveCustom:Q=>{ze(X=>{let ye=X.filter(Te=>Te.label!==Q);return nb(ye),ye})}}),(0,gt.jsx)("div",{className:"w-px h-4 bg-border mx-1"}),(0,gt.jsx)(hR,{value:Ie.chartType,pluginChartTypes:Qe,dataLevel:K,onChange:Q=>{_t(Q)||(b.emit("chart:set-type",{old:Ie.chartType,new:Q}),ee(X=>({...X,chartType:Q})),Mn("applySettings",{chartType:Q}))}}),(0,gt.jsx)(sc,{orientation:"vertical",className:"h-4 mx-1"}),(0,gt.jsx)(JL,{indicators:Be,dataLevel:K,pluginIndicators:En,onActivatePlugin:Q=>Mn("activatePluginIndicator",Q.indicator,Q.pane),onAdd:Q=>Mn("handleAddIndicator",Q),onToggle:Q=>Mn("handleToggleIndicator",Q),onRemove:Q=>Mn("handleRemoveIndicator",Q)}),h?.map((Q,X)=>(0,gt.jsx)(Ke.default.Fragment,{children:Q},X)),(0,gt.jsx)($P,{eventBus:b,chart:e}),(0,gt.jsx)("div",{className:"flex-1"}),(0,gt.jsxs)("div",{className:"flex items-center gap-3",children:[(0,gt.jsx)(nP,{current:S,onChange:Je,syncInLayout:k,setSyncInLayout:cr}),(0,gt.jsx)(r2,{eventBus:b,chart:e}),(0,gt.jsx)(ZP,{eventBus:b,chart:e}),(0,gt.jsxs)(Gt,{delayDuration:700,children:[(0,gt.jsx)(qt,{asChild:!0,children:(0,gt.jsx)(br,{onClick:()=>L(Q=>!Q),variant:"outline",className:"h-8 w-8 border-none text-muted-foreground hover:text-white hover:bg-muted",children:E?(0,gt.jsx)(zs,{className:"w-4"}):(0,gt.jsx)(Hs,{className:"w-4"})})}),(0,gt.jsxs)(Ut,{className:"bg-background border border-border",children:[E?"Show":"Hide"," fixed panels"]})]})]})]})}),(0,gt.jsx)("div",{className:"flex flex-1 min-h-0",children:(0,gt.jsxs)("div",{className:"flex flex-row flex-1 min-h-0",children:[!a&&(0,gt.jsx)(_L,{activeTool:le.name,onToolChange:Q=>{let X=Q==="cursor"?Yo:ud(Q);ce(X),H.current.forEach(ye=>ye?.setActiveTool(X))},pluginDrawings:Oe}),(0,gt.jsxs)("div",{ref:O,style:{flex:1,display:"grid",gridTemplateColumns:Ev(R),gridTemplateRows:Ev(D),gridTemplateAreas:S.areas,gap:0,background:"rgba(255,255,255,.04)",position:"relative",overflow:"hidden",minHeight:0},children:[tP.map((Q,X)=>{let ye=X<at.length,Te=x===X,ct=J[X];return(0,gt.jsxs)("div",{style:{gridArea:Q,position:"relative",overflow:"hidden",minWidth:0,minHeight:0,visibility:ye?"visible":"hidden",pointerEvents:ye?"auto":"none",border:"0.5px solid #2b323c"},onMouseDownCapture:()=>{ye&&!Te&&(T(X),H.current[X]?.setActiveTool(le),Bu.setFocus(e.id)),ye&&(ve.current=X)},children:[ct&&(0,gt.jsx)(ZL,{ref:vt=>{H.current[X]=vt},managed:!0,hideToolbar:!0,hideDrawingToolbar:!0,hideBottomToolbar:!0,hidePriceScale:s,hideTimeScale:l,hideStatusBar:c,hideLegend:u,hideSettingsDialog:!0,onOpenSettings:()=>De(!0),onHorizonUpdate:vt=>{fr.current=vt},onHorizonTick:Te?()=>{}:void 0,domPanelRef:void 0,onRequestMore:ir,tradeLines:Se[X].trading.tradeLines,onCreateOrder:vt=>Se[X].executionEngine?.placeOrder({qty:1,...vt,symbol:vt.symbol??pe[X]}),onGhostMove:Se[X].trading.handleGhostMove,linesRef:Se[X].trading.linesRef,draggingLineIdRef:Se[X].trading.draggingLineIdRef,redrawTrading:()=>Se[X].redrawFnRef.current?.(),eventBus:b,transformer:r,showDataStatusInBottomRightCorner:m,initialState:{timeframe:e.getChart(X).timeframe},id:X,symbol:pe[X],features:g,account:e.account,drawingStore:e.drawingStore,model:e.getChart(X),syncInLayout:k,setStatePatch:rn},`${Q}-chart`),ye&&Te&&at.length>1&&(0,gt.jsx)("div",{className:"w-full h-full bg-transparent pointer-events-none z-10 absolute top-0 left-0 border-2 border-blue-500/70"},`${Q}-overlay`)]},Q)}),O.current&&(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)(Ov,{dir:"col",sizes:R,containerRef:O,onDrag:Rt}),(0,gt.jsx)(Ov,{dir:"row",sizes:D,containerRef:O,onDrag:Jt,areas:S.areas,colSizes:R})]})]}),(0,gt.jsx)(KP,{eventBus:b,chart:e,onFixedPanelsChange:B,override:E})]})}),!i&&(0,gt.jsx)(hh,{delayDuration:400,children:(0,gt.jsxs)("div",{className:"flex items-center h-8 px-3 border-t border-border/50 bg-background shrink-0 select-none",children:[(0,gt.jsxs)("div",{className:"flex items-center gap-0.5",children:[["normal","percent"].map(Q=>(0,gt.jsxs)(Gt,{children:[(0,gt.jsx)(qt,{asChild:!0,children:(0,gt.jsx)("button",{onClick:()=>{let X={priceScaleMode:Q};ee(ye=>({...ye,...X})),H.current[de.current]?.applySettings(X)},className:ne("h-5 px-1.5 text-xs font-semibold rounded leading-none transition-colors",Ie.priceScaleMode===Q?"text-foreground/75":"text-foreground/25 hover:text-foreground/55"),children:Q==="normal"?"N":"%"})}),(0,gt.jsx)(Ut,{side:"top",className:"text-xs border border-border bg-background",children:Q==="normal"?"Normal scale":"Percent scale"})]},Q)),(0,gt.jsx)("div",{className:"w-px h-3 bg-border/50 mx-1 shrink-0"}),(0,gt.jsxs)(Gt,{children:[(0,gt.jsx)(qt,{asChild:!0,children:(0,gt.jsx)("button",{onClick:()=>{let Q={autoScale:!Ie.autoScale};ee(X=>({...X,...Q})),H.current[de.current]?.applySettings(Q)},className:ne("h-5 w-5 flex items-center justify-center rounded transition-colors",Ie.autoScale?"text-foreground/70 hover:text-foreground/90":"text-foreground/25 hover:text-foreground/55"),children:Ie.autoScale?(0,gt.jsx)(Di,{size:11}):(0,gt.jsx)(no,{size:11})})}),(0,gt.jsx)(Ut,{side:"top",className:"text-xs border border-border bg-background",children:Ie.autoScale?"Auto-scale on - click to lock":"Scale locked - click to auto-fit"})]}),(0,gt.jsxs)(Gt,{children:[(0,gt.jsx)(qt,{asChild:!0,children:(0,gt.jsx)("button",{onClick:()=>{let Q={showGrid:!Ie.showGrid};ee(X=>({...X,...Q})),H.current[de.current]?.applySettings(Q)},className:ne("h-5 w-5 flex items-center justify-center rounded transition-colors",Ie.showGrid?"text-foreground/70 hover:text-foreground/90":"text-foreground/25 hover:text-foreground/55"),children:(0,gt.jsx)(ii,{size:11})})}),(0,gt.jsx)(Ut,{side:"top",className:"text-xs border border-border bg-background",children:Ie.showGrid?"Hide grid":"Show grid"})]}),(0,gt.jsxs)(Gt,{children:[(0,gt.jsx)(qt,{asChild:!0,children:(0,gt.jsx)("button",{onClick:()=>{let X={crosshairMode:Ie.crosshairMode==="magnet"?"normal":"magnet"};ee(ye=>({...ye,...X})),H.current[de.current]?.applySettings(X)},className:ne("h-5 w-5 flex items-center justify-center rounded transition-colors",Ie.crosshairMode==="magnet"?"text-foreground/70 hover:text-foreground/90":"text-foreground/25 hover:text-foreground/55"),children:(0,gt.jsx)(nf,{size:11})})}),(0,gt.jsx)(Ut,{side:"top",className:"text-xs border border-border bg-background",children:Ie.crosshairMode==="magnet"?"Magnet on":"Magnet off"})]})]}),(0,gt.jsx)(XP,{eventBus:b,chart:e}),(0,gt.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[Ie.showTimezoneLabel&&(0,gt.jsx)("span",{ref:ae,className:"text-xs text-foreground/30 tabular-nums leading-none"}),(0,gt.jsx)("span",{ref:q,className:"text-xs text-foreground/50 tabular-nums leading-none"})]})]})}),ke&&(0,gt.jsx)(TR,{settings:Ie,horizon:fr.current,pluginChartType:bt,onUpdate:Q=>{ee(X=>({...X,...Q})),H.current[de.current]?.applySettings(Q),Q.pluginSettings&&bt&&bt.onSettingsChange?.(Q.pluginSettings[bt.chartTypeId]??{})},onClose:()=>De(!1)})]})})}var ll=class{constructor(){se(this,"builtIns",new Map);se(this,"activeSymbol","");se(this,"custom",null);se(this,"destroyed",!1);se(this,"guard",null);se(this,"eventBus",null);se(this,"fillSearch",Bv)}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 Mi=class{constructor(){se(this,"view",{tMin:0n,tMax:1n,pMin:0,pMax:1,pRef:0});se(this,"mode","linear");se(this,"_sessionMapper",null);se(this,"_barNs",0n);se(this,"_barAlignedStarts",[]);se(this,"_sessionMapperVersion",-1);se(this,"_ordinal",null);se(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 Ja(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 Hu=class{constructor(){se(this,"installed",new Map);se(this,"serviceRegistry",new Map);se(this,"serviceListeners",new Map);se(this,"pendingInstalls",[]);se(this,"renderEngineReady",!1);se(this,"eventBus",null);se(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(!Bo(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 lg=class{constructor(t){se(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 Vu=class{constructor(t){se(this,"id");se(this,"_symbol");se(this,"_timeframe");se(this,"_settings");se(this,"_activeTool");se(this,"_fpOptions");se(this,"_plugins");se(this,"_restoredPlugins",[]);se(this,"listeners",new Set);this.id=t.id??`pane:${vn(6)}`,this._symbol=t.symbol,this._timeframe=t.timeframe,this._settings=t.settings??{...Xe},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:dL(this._settings),plugins:this._plugins.map(t=>({...t}))}}restore(t){this._symbol=t.symbol,this._timeframe=Fx(t.timeframe),this._settings=fL(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 lW=Object.freeze([]),Wu=class{constructor(){se(this,"bySymbol",new Map);se(this,"listeners",new Map)}forSymbol(t){return this.bySymbol.get(t)??lW}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 qu=class{constructor(t){se(this,"eventBus");se(this,"currency");se(this,"initialBalance");se(this,"fills",[]);se(this,"orders",new Map);se(this,"positionMap",new Map);se(this,"adjustments",[]);se(this,"horizonNs",null);se(this,"adapter",null);se(this,"executionEngine",null);se(this,"unsubs",[]);se(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 cW='(()=>{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',dw;function fw(){return dw||(dw=URL.createObjectURL(new Blob([cW],{type:"text/javascript"}))),dw}function fc(e,t){return e.length?typeof e[0]=="number"?e:e.map(t??(n=>n.close)):[]}function cg(e,t,n){let r=fc(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 Sm(e,t,n){let r=fc(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 ug(e,t,n){let r=fc(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 uW(e,t,n){let r=fc(e,n),o=Math.floor(t/2),a=Math.round(Math.sqrt(t)),i=ug(r,o),s=ug(r,t),l=r.map((c,u)=>2*i[u]-s[u]);return ug(l,a)}function dg(e,t,n){let r=fc(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 dW(e,t,n){let r=fc(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 fW(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=dg(r,t),i=dg(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 mW(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=Cm(e.map(u=>u.high),t),s=km(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 pW(e,t=12,n=26,r=9){let o=Sm(e,t),a=Sm(e,n),i=e.length,s=new Array(i);for(let u=0;u<i;u++)s[u]=o[u]-a[u];let l=Sm(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 mw(e,t=14){return dg(s2(e),t)}function s2(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 l2(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 c2(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 hW(e,t){let n=l2(e,t),r=c2(e,t);return n.map((o,a)=>o||r[a])}function gW(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 bW(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 yW(e,t=1){return e.map((n,r)=>r<t?NaN:n-e[r-t])}function vW(e){let t=NaN;return e.map((n,r)=>n?(t=r,0):isNaN(t)?NaN:r-t)}function wW(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 u2(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 Cm(e,t){return u2(e,t,!0)}function km(e,t){return u2(e,t,!1)}function xW(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 SW(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 d2(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 CW(e,t=20,n=2){let{upper:r,mid:o,lower:a}=d2(e,t,n);return o.map((i,s)=>isNaN(i)||i===0?NaN:(r[s]-a[s])/i)}function kW(e,t=20){let n=Cm(e.map(o=>o.high),t),r=km(e.map(o=>o.low),t);return{upper:n,mid:n.map((o,a)=>(o+r[a])/2),lower:r}}function TW(e,t=20,n=10,r=1.5){let o=Sm(e,t),a=mw(e,n);return{upper:o.map((i,s)=>i+r*a[s]),mid:o,lower:o.map((i,s)=>i-r*a[s])}}function IW(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 MW(e){let t=e.map(n=>(n.high+n.low)/2);return{jaw:cg(t,13),teeth:cg(t,8),lips:cg(t,5)}}function f2(e,t,n){let r=fc(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 LW(e,t,n){return f2(e,t,n).map(r=>r*r)}function RW(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 PW(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 DW=Cm,AW=km;function BW(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 NW(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 EW(e){return e[e.length-1]}function OW(e,t=0){return e==null||isNaN(e)?t:e}function _W(e,t,n,r=[],o=!1){return{type:"line",pts:e,color:t,width:n,dash:r,connect:o}}function FW(e,t,n,r=[]){return{type:"hline",price:e,color:t,width:n,dash:r}}function zW(e,t,n=0,r=.2){return{type:"histogram",pts:e,color:t,base:n,gap:r}}function HW(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 VW(e,t,n){return{type:"fill",pts1:e,pts2:t,opts:n}}function WW(e,t,n,r,o={}){return{type:"rect",t1:e,t2:n,price1:t,price2:r,...o}}function qW(e,t,n,r={}){return{type:"circle",t:e,price:t,radius:n,...r}}function UW(e,t,n=1,r=[]){return{type:"vline",t:e,color:t,width:n,dash:r}}function jW(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 GW(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 YW(e,t,n,r="",o=1){return{type:"band",priceHigh:e,priceLow:t,fillColor:n,borderColor:r,borderWidth:o}}function KW(e,t={}){return{type:"polygon",pts:e,...t}}function $W(e,t,n=3){return{type:"dots",pts:e,color:t,radius:n}}function XW(e,t,n,r,o,a={}){return{type:"badge",t:e,price:t,text:n,textColor:r,bgColor:o,...a}}function m2(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":ZW(l,n,r,o,a,i,s);break;case"hline":QW(l,n,r,s);break;case"histogram":JW(l,n,r,o,a,i,s);break;case"label":e8(l,n,r,s);break;case"fill":t8(l,n,r,o,a,i,s);break;case"rect":n8(l,n,r,s);break;case"circle":r8(l,n,r,s);break;case"vline":o8(l,n,r,s);break;case"arrow":a8(l,n,r,s);break;case"trendline":i8(l,n,r,o,a,s);break;case"band":s8(l,n,r,s);break;case"polygon":l8(l,n,r,s);break;case"dots":c8(l,n,r,o,a,s);break;case"badge":u8(l,n,r,s);break}}function ZW(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 QW(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 JW(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]=pw(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 e8(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 t8(e,t,n,r,o,a,i){let{pts1:s,pts2:l,opts:c}=e,u=c;if(typeof s=="number"&&(s=o2(s,r,o,a)),typeof l=="number"&&(l=o2(l,r,o,a)),s.length<2||l.length<2)return;let d=a2(s,n,i,r,o),m=a2(l,n,i,r,o);if(u.mode==="data"){f8(t,d,m,n,u.stops);return}let f=d8(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(p2(1-w),C.color)}t.fillStyle=b,t.fill(f)}t.restore()}function n8(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 r8(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 o8(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 a8(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 i8(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 s8(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 l8(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 c8(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]=pw(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 u8(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 o2(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 pw(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 p2(e){return e<0?0:e>1?1:Number.isFinite(e)?e:0}function a2(e,t,n,r,o){let[a,i]=pw(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 d8(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 i2(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 f8(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=i2(t),u=i2(n);e.save();let d=e.createLinearGradient(0,0,0,1);for(let x of o)d.addColorStop(p2(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 m8(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 p8(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 h8(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 g8(e,t=14){let n=e.length,r=new Array(n).fill(NaN),o=Cm(e.map(i=>i.high),t),a=km(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 b8(e,t=10,n=3){let r=e.length,o=mw(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 y8(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=rr.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=rr.fromObject({year:u,month:d,day:m,hour:l.startHour,minute:l.startMinute,second:0,millisecond:0},{zone:c}),h=rr.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 h2={sma:cg,ema:Sm,wma:ug,hma:uW,rma:dg,linreg:dW,rsi:fW,stoch:mW,macd:pW,atr:mw,tr:s2,crossover:l2,crossunder:c2,cross:hW,rising:gW,falling:bW,change:yW,barssince:vW,valuewhen:wW,highest:Cm,lowest:km,pivotHigh:xW,pivotLow:SW,bb:d2,bbw:CW,donchian:kW,keltner:TW,vwap:IW,alligator:MW,stdev:f2,variance:LW,dev:RW,correlation:PW,max:DW,min:AW,median:BW,toPoints:NW,last:EW,nz:OW,obv:m8,mfi:p8,cci:h8,williamsR:g8,supertrend:b8,sessionBoundaries:y8,drawLine:_W,drawHLine:FW,drawHistogram:zW,drawLabel:HW,fillBetween:VW,drawRect:WW,drawCircle:qW,drawVLine:UW,drawArrow:jW,drawTrendLine:GW,drawBand:YW,drawPolygon:KW,drawDots:$W,drawBadge:XW};var v8=Object.freeze({indicator:"indicator",drawing:"drawing",chartType:"chart-type",dataSource:"data-source",extension:"extension"}),w8=Object.freeze({mbo:"l3",l3:"l3",l2:"l2",ohlcv:"ohlcv",tick:"tick"}),x8=Object.freeze({overlay:"overlay",pane:"pane"}),g2={PluginType:v8,DataLevel:w8,Layout:x8};function S8(e){if(!e)return null;try{return new Function(`return (${e})`)()}catch{return null}}function Tm(e,t={},n){let r=null;try{let o={...g2,plugin:()=>({}),...h2,...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 S8(o)}}var dl=Ct(require("react"));function C8(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 y2(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 Uu(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 k8(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 b2(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(31,t)+e.charCodeAt(n)|0;return t}var fg="__scripted__";function v2(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 w2(e){let t=[];for(let n of v2(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 x2(e){let t={};for(let[n,r]of Object.entries(e))y2(n,r,t);return t}var T8=(e,t,n,r,o,a,i,s)=>{let l=t.decl,c=l.require??"ohlcv",u=l.layout??"overlay",d=t.drawCommands??[],m=Tm(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))y2(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:fg,workerUpdate:fg,hydrate(T,R){},appendHydrate(T,R){},drawBase(T){if(d.length)try{m2(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,H=B.length-1;for(;L<=H;){let K=L+H>>>1;B[K].t<T?L=K+1:H=K-1}E=L}for(let L=E;L<B.length;L++){let H=B[L].t;if(H>R||P!==0n&&H>P)break;let K=B[L].price;isNaN(K)||(K<D&&(D=K),K>N&&(N=K))}}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=v2(y));let k=new Set;for(let[T,R]of Object.entries(y))for(let P of C8(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=Uu(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=k8(g,R);let B=Uu(c,g,P,D,N),E=Uu(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})}},I8=(e,t,n,r,o,a,i,s)=>{let l=t.decl,c={},u=l.params??{},d=x2(u),m=x=>x&&typeof x=="object"?{...d,...x}:d,f=Tm(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=bo.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 M8(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:w2(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 M8(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 L8=(e,t,n,r,o,a,i,s)=>{let l=t.decl,c=l.params??{},u=x2(c),d=Tm(s(),{React:dl.default,h:dl.default.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(fw(),{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:w2(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?fg:void 0,workerUpdate:t.onDrawSrc?fg: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=Uu(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=Uu(l.require??"ohlcv",D,N,O,A),H=Uu(l.require??"ohlcv",D,N,O,A);w.postMessage({type:"update",pluginIndex:0,data:L,newData:H,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})}},R8=(e,t,n,r,o,a,i,s)=>{let l=t.onInstallSrc??null,c=t.extensionDrawSrc??null;if(!l)return()=>{};let u=Tm(s(),{React:dl.default,h:dl.default.createElement},i),d=u(c),m=null,f={};function h(){let[y,v]=dl.default.useState(f);return dl.default.useEffect(()=>(m=v,()=>{m=null}),[]),d?d(y,o):null}let p=y=>(f=y,m?.(y),dl.default.createElement(h)),g;try{g=u(l)?.(o,p)}catch(y){i(`extension onInstall error: ${y}`)}return y=>{try{typeof g=="function"&&g()}catch{}}},P8={indicator:T8,drawing:I8,"chart-type":L8,extension:R8};function mc(e,t,n){let r=t??`scripted:${vn(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(fw(),{type:"module"}),f=e,h=b2(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=b2(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=P8[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 D8(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 mg=class{constructor(t,n=0n){se(this,"eventBus",t);se(this,"isPlaying",!1);se(this,"currentStepSize","5s");se(this,"currentSpeed",1);se(this,"currentMode","realtime");se(this,"currentStepSnap",!1);se(this,"currentTime");se(this,"forwardOnly",!1);se(this,"floorNs",0n);se(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=D8(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 hw(e){return{symbol:e,description:e,type:"crypto",dataLevel:"ohlcv",priceFormat:{minTick:.01,precision:2}}}function A8(e){return Array.isArray(e)?e:e.symbols}var B8=200,pg=class{constructor(){se(this,"bySymbol",new Map);se(this,"byPrefix",[]);se(this,"resolved",new Map);se(this,"adapters",new Map);se(this,"lastRequest",new Map);se(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 A8(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"?B8: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):hw(o)}catch(s){console.error(`[DataSourceRegistry] resolveSymbol('${o}') threw:`,s),i=hw(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)??hw(i));return xc(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 N8=60n*1000000000n,E8=200,hg=class{constructor(t,n){se(this,"eventBus",t);se(this,"plugins",new Map);se(this,"checkpoints",[]);se(this,"lastCheckpointNs",0n);se(this,"currentHorizonNs",0n);se(this,"intervalNs");se(this,"unsubs",[]);this.intervalNs=n?.intervalNs??N8,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>E8&&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 gg=class{constructor(){se(this,"intervals",new Set);se(this,"timeouts",new Set);se(this,"rafIds",new Set);se(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 ju(...e){typeof window>"u"||window.location.search.includes("plugintrace")&&console.log("[plugins]",...e)}function gw(){let e=Gr(Pn.pluginStartup,{});return e&&typeof e=="object"?e:{}}function bw(e,t){let n=gw();return t===null?delete n[e]:n[e]={autostart:!1,...n[e],...t},Sr(Pn.pluginStartup,n),ju("record write",e,t,"->",JSON.stringify(n[e])),n}var S2=`
|
|
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 C2=`
|
|
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 k2=`
|
|
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 T2=`
|
|
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 I2=`
|
|
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 M2=`
|
|
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 L2=`
|
|
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 R2=`
|
|
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 P2=`
|
|
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 D2=`
|
|
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 A2=`
|
|
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 B2=`
|
|
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 N2=`
|
|
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 E2=`
|
|
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 O2=`
|
|
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 _2=`
|
|
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 F2=`
|
|
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 z2=`
|
|
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 H2=`
|
|
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 V2=`
|
|
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 W2=[[D2,"builtin:moving-average","trend"],[F2,"builtin:supertrend","trend"],[L2,"builtin:ichimoku","trend"],[N2,"builtin:psar","trend"],[H2,"builtin:vwap","trend"],[S2,"builtin:alligator","trend"],[E2,"builtin:rsi","momentum"],[P2,"builtin:macd","momentum"],[_2,"builtin:stochastic","momentum"],[I2,"builtin:cci","momentum"],[V2,"builtin:williams-r","momentum"],[k2,"builtin:awesome-oscillator","momentum"],[T2,"builtin:bollinger-bands","volatility"],[R2,"builtin:keltner","volatility"],[M2,"builtin:donchian","volatility"],[C2,"builtin:atr","volatility"],[z2,"builtin:volume","volume"],[B2,"builtin:obv","volume"],[A2,"builtin:mfi","volume"],[O2,"builtin:sessions","other"]];var O8={contextMenu:!0,plugins:{enabled:!0,indicators:!0,charts:!0,extensions:!0,drawings:!0}},vw=1,_8=8,yw="$bigint";function q2(e){return JSON.stringify(e,(t,n)=>typeof n=="bigint"?{[yw]:n.toString()}:n)}function U2(e){return JSON.parse(e,(t,n)=>n&&typeof n=="object"&&typeof n[yw]=="string"?BigInt(n[yw]):n)}function F8(e){return Array.isArray(e.plugins)&&e.plugins.some(t=>typeof t=="string")?{...e,plugins:[]}:e}function z8(e){let t=Go.find(r=>r.label.toLowerCase()===e.toLowerCase());if(t)return t;let n=Ic(e);if(n)return n;throw new Error(`[ChristTrade] Unknown timeframe: "${e}"`)}var Gu=class{constructor(t){se(this,"options",t);se(this,"id");se(this,"eventBus");se(this,"executionEngine");se(this,"dataEngine");se(this,"transformer");se(this,"features");se(this,"pluginRegistry");se(this,"_renderEngine",null);se(this,"_panelRegistry",new Map);se(this,"_toolbarRegistry",new Map);se(this,"_bottomBarRegistry",new Map);se(this,"_openBarProviders",new Map);se(this,"_horizon",0);se(this,"dataSources");se(this,"drawingRegistry");se(this,"destroyed",!1);se(this,"registeredPlugins",new Map);se(this,"_pluginStateListeners",new Set);se(this,"_pluginCatalog",null);se(this,"playbackController");se(this,"playbackStateRegistry");se(this,"pluginSchedules",new Map);se(this,"state");se(this,"_panes",new Map);se(this,"drawingStore");se(this,"account");se(this,"playback");se(this,"timePrecision","ms");se(this,"_focusedCellId",0);this.id=`chart:${vn(6)}`,this.eventBus=new il,this.transformer=new Mi,this.executionEngine=new ll,this.executionEngine.setEventBus(this.eventBus),this.features=O8,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 Hu,this.pluginRegistry.setOptions(r),this.pluginRegistry.setEventBus(this.eventBus),this.drawingRegistry=new Mf,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?z8(t.timeframe):Go.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 lg({activeTool:Yo,selectedDrawingId:null,symbol:t.symbol,fpOptions:t.fpOptions??{},isPlaying:!1,horizonIso:a,timeframe:o,layout:Zh[0]}),this.drawingStore=new Wu,this.dataSources=new pg;let s={initialLoad:i,horizon:a,fpOptions:t.fpOptions,initialWindowNs:t.initialWindowNs,timeframe:o,symbol:t.symbol,plugins:this.dataSources};this.dataEngine=new Rc(this.eventBus,this.state,s),this.dataEngine.setAdapter(t.dataAdapter),this.dataEngine.attachExecutionEngine(this.executionEngine),this.playbackController=new mg(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 qu({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 hg(this.eventBus),this._wireDataRouting(),this._wireSymbolMirror();for(let[c,u,d]of W2)this.use(mc(c,u,d));!t.restore&&t.importTradingViewSettings!==!1&&Pu(),t.restore&&this.restore(t.restore),Bu.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=Go.find(r=>r.label.toLowerCase()===t.toLowerCase())??Ic(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 Vu({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?Qx(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:vw,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:op()}}_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=F8(t);ap(n.preferences),n.plugins?.forEach(({id:o,code:a})=>{try{this.use(mc(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 ju("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(mc(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 gw()}setPluginStartup(t,n){return bw(t,n),this._notifyPluginState(),this}applyStartupPlugins(){let t=new Map(this.getPluginCatalog().map(i=>[i.id,i]));if(ju("applyStartupPlugins: catalog",[...t.keys()]),t.size===0)return this;let n=this.getPluginStartup();ju("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);ju("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(mc(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)&&bw(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:_8},(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 gg;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:xi,success:xi.success,warn:xi.warning,error:xi.error}[u]??xi)(f,h)},i={registerState:s=>n.playbackStateRegistry.register(t,s)};return{eventBus:n.eventBus,global:Bu,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 Gr(Zm(t,s),l)},set(s,l){Sr(Zm(t,s),l)},delete(s){eb(Zm(t,s))},clear(){Ox(Ax(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=Gr(Xg(t),null);return l?{...s,...l}:s},saveSettings(s){let l=Xg(t),c=Gr(l,{});Sr(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,Bu.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()}}};var pc=Ct(require("react"));function j2(e){let t=(0,pc.useRef)(null),n=(0,pc.useRef)(null);t.current||(t.current=new Gu(e),t.current.load(e.symbol)),(0,pc.useEffect)(()=>(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=pc.default.createElement(xm,r.getProps());return{chart:r,element:o}}var ww={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}},H8={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}},V8=["TRENDING","MEAN_REVERTING","VOLATILE"];function W8(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 xw(e){let t=Math.max(e(),1e-10),n=e();return Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*n)}function G2(e,t){if(!isFinite(t))return xw(e);let n=xw(e),r=0,o=Math.max(2,Math.round(t));for(let a=0;a<o;a++){let i=xw(e);r+=i*i}return n/Math.sqrt(r/o)}function q8(e,t){let n=H8[e],r=t();for(let o of V8)if(r-=n[o],r<=0)return o;return"MEAN_REVERTING"}function Y2(e,t){return Math.max(1,Math.round(-e.avgDuration*Math.log(Math.max(t(),1e-10))))}function U8(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=G2(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=G2(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 Im=class{constructor(t={}){se(this,"cfg");let n={TRENDING:{...ww.TRENDING,...t.regimes?.TRENDING??{}},MEAN_REVERTING:{...ww.MEAN_REVERTING,...t.regimes?.MEAN_REVERTING??{}},VOLATILE:{...ww.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=W8(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:Y2(p,c),ouMean:a},y=[];for(let v=0;v<f;v++){g.regimeBarsLeft--,g.regimeBarsLeft<=0&&(g.regime=q8(g.regime,c),g.regimeBarsLeft=Y2(this.cfg.regimes[g.regime],c));let b=this.cfg.regimes[g.regime],S=U8(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 K2(e){return new Im(e)}var fl=require("react"),Qr=require("react/jsx-runtime");function bg(e,t=2){return e.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})}function $2({value:e,label:t}){let n=e>0?"text-emerald-400":e<0?"text-red-400":"text-slate-400",r=e>0?"+":"";return(0,Qr.jsxs)("div",{className:"flex flex-col items-start leading-none",children:[(0,Qr.jsx)("span",{className:"text-[9px] text-slate-500 uppercase tracking-wide",children:t}),(0,Qr.jsxs)("span",{className:`text-[11px] font-mono tabular-nums ${n}`,children:[r,bg(e)]})]})}function X2({eventBus:e,currencySymbol:t="$"}){let[n,r]=(0,fl.useState)(null),[o,a]=(0,fl.useState)(0),i=(0,fl.useRef)(0);return(0,fl.useEffect)(()=>{let s=[e.on("account:update",r),e.on("playback:tick",l=>{i.current=l.spread})];return()=>s.forEach(l=>l())},[e]),(0,fl.useEffect)(()=>{let s=setInterval(()=>a(i.current),250);return()=>clearInterval(s)},[]),n?(0,Qr.jsxs)("div",{className:"flex items-center gap-3 text-xs select-none",children:[(0,Qr.jsxs)("div",{className:"flex flex-col items-start leading-none",children:[(0,Qr.jsx)("span",{className:"text-[9px] text-slate-500 uppercase tracking-wide",children:"Balance"}),(0,Qr.jsxs)("span",{className:"text-[11px] font-mono tabular-nums text-slate-200",children:[t,bg(n.balance)]})]}),(0,Qr.jsx)("div",{className:"h-4 w-px bg-slate-700"}),(0,Qr.jsxs)("div",{className:"flex flex-col items-start leading-none",children:[(0,Qr.jsx)("span",{className:"text-[9px] text-slate-500 uppercase tracking-wide",children:"Equity"}),(0,Qr.jsxs)("span",{className:"text-[11px] font-mono tabular-nums text-slate-200",children:[t,bg(n.equity)]})]}),(0,Qr.jsx)("div",{className:"h-4 w-px bg-slate-700"}),(0,Qr.jsx)($2,{value:n.unrealizedPnl,label:"Open P&L"}),(0,Qr.jsx)("div",{className:"h-4 w-px bg-slate-700"}),(0,Qr.jsx)($2,{value:n.realizedPnl,label:"Realized"}),(0,Qr.jsx)("div",{className:"h-4 w-px bg-slate-700"}),(0,Qr.jsxs)("div",{className:"flex flex-col items-start leading-none",children:[(0,Qr.jsx)("span",{className:"text-[9px] text-slate-500 uppercase tracking-wide",children:"Spread"}),(0,Qr.jsxs)("span",{className:"text-[11px] font-mono tabular-nums text-slate-200",children:[t,bg(o)]})]})]}):null}var Yu=require("react");var Ca=require("react/jsx-runtime");function Z2({eventBus:e}){let[t,n]=(0,Yu.useState)("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=(0,Yu.useCallback)(()=>{e.emit("trading:buy-market",{amount:parseFloat(t)})},[t]),i=(0,Yu.useCallback)(()=>{e.emit("trading:sell-market",{amount:parseFloat(t)})},[t]),s=(0,Yu.useCallback)(()=>{e.emit("trading:flatten",void 0)},[e]);return(0,Ca.jsx)("div",{className:"flex gap-2 justify-center md:justify-self-end items-center order-2 md:order-3",children:(0,Ca.jsxs)("div",{className:"flex items-center gap-1 rounded-md flex-wrap justify-center",children:[(0,Ca.jsx)(br,{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:(0,Ca.jsx)(Jo,{className:"h-4 w-4"})}),(0,Ca.jsx)(Qs,{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"}),(0,Ca.jsx)(br,{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:(0,Ca.jsx)(pa,{className:"h-4 w-4"})}),(0,Ca.jsx)(sc,{orientation:"vertical",className:"h-4 bg-slate-700"}),(0,Ca.jsx)(br,{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"}),(0,Ca.jsx)(br,{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"}),(0,Ca.jsx)(br,{variant:"ghost",size:"sm",className:"h-9 px-3 text-xs text-slate-300 hover:bg-muted hover:text-white",onClick:s,children:"Flatten"})]})})}var cn=require("react");var ys=e=>e.tickSize&&e.tickSize>0?e.tickSize:.01;function $u(e){if(e.tickValue&&e.tickValue>0)return e.tickValue;let t=ys(e)*(e.multiplier??1);return t>0?t:1}function J2(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 Sw=e=>e.qtyStep&&e.qtyStep>0?e.qtyStep:1,j8=e=>e.minQty&&e.minQty>0?e.minQty:Sw(e);function eD(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 tD=e=>eD(Sw(e));function Ku(e,t){if(!Number.isFinite(e)||e<=0)return 0;let n=Sw(t);return Number((Math.floor(e/n+1e-9)*n).toFixed(eD(n)))}function ml(e){let t=ys(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 Hi(e,t){let n=ys(t);return Number.isFinite(e)?Number((Math.round(e/n)*n).toFixed(ml(t))):0}var Qu=(e,t,n)=>Math.round((t-e)/ys(n)),Mm=(e,t)=>$u(t)*Math.max(0,e),Xu=(e,t,n)=>Math.max(0,e)*(n.multiplier??1)*Math.max(0,t),nD=(e,t)=>(e==="long"?1:-1)*(t==="tp"?1:-1);function Zu(e,t,n,r,o){return Hi(t+nD(r,e)*Math.abs(n)*ys(o),o)}function yg(e,t,n,r,o){return nD(r,e)*Qu(t,n,o)}var vg=[{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}],Q2=e=>e==="riskUsd"||e==="riskPct";function Cw(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)*$u(i);return u>0?Ku(c/u,i):0},l=c=>{let u=Xu(r,1,i);return u>0?Ku(c/u,i):0};switch(e){case"contracts":return Ku(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 wg(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 Xu(r,t,i);case"balancePct":return a>0?Xu(r,t,i)/a*100:0;case"riskUsd":return Math.abs(o)*Mm(t,i);case"riskPct":return a>0?Math.abs(o)*Mm(t,i)/a*100:0}}function xg(e,t,n,r){let o=Hi(t.entry,r),a=e==="long";return{side:e,type:n<=0||o===Hi(n,r)?"market":a?o<n?"limit":"stop":o>n?"limit":"stop",entry:o,target:Hi(a?o+t.upAmount:o-t.downAmount,r),stop:Hi(a?o-t.downAmount:o+t.upAmount,r),qty:Ku(t.qty,r)}}function Sg(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=Hi(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."}),Q2(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=Cw(e.amountMode,e.amount,{entry:l,stopTicks:c,balance:o,spec:t}),m=j8(t);d<=0?a.push({field:"amount",message:e.amount>0&&!Q2(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*Mm(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,Qu(e.bid,e.ask,t));return{entry:l,qty:d,tickValue:$u(t),contractValue:Xu(l,d,t),tpPrice:u>0?Zu("tp",l,u,n,t):null,slPrice:c>0?Zu("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*$u(t)},problems:a,ok:a.length===0}}var Ze=require("react/jsx-runtime"),Rm="#2962ff",Pm="#f23645",Lw="#16181d",cD="#0f1116",uD="#1b1e25",dD="#22262e",Rw="#1e2128",G8=340,Ju=12,kw=null,rD=null,oD=null,aD=e=>Math.max(Ju,Math.min(window.innerWidth-G8-Ju,e)),iD=(e,t)=>{let n=window.innerHeight-t-Ju;return Math.min(Math.max(Ju,e),Math.max(Ju,n))},Lm=e=>({fixed:"offset",price:"0",offset:String(e)}),sD=(e,t)=>t==="limit"?e==="long"?-1:1:t==="stop"?e==="long"?1:-1:0,vs=e=>{let t=Number.parseFloat(e);return Number.isFinite(t)?t:0},Dm=(e,t=2)=>e.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t}),Pw=e=>Dm(e,e!==0&&Math.abs(e)<1?4:2),Y8=e=>`${e.toFixed(2)}%`;function Tw({value:e,options:t,onChange:n,prefix:r}){let o=t.find(a=>a.id===e);return(0,Ze.jsxs)(Va,{children:[(0,Ze.jsxs)(Wa,{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,(0,Ze.jsx)(or,{className:"h-3 w-3 opacity-60 transition-transform group-data-[state=open]:rotate-180"})]}),(0,Ze.jsx)(ya,{align:"start",className:"min-w-[172px] border-[#22262e] bg-[#1b1e25] p-1 z-[210]",children:t.map(a=>(0,Ze.jsx)(aa,{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 Iw({value:e,onChange:t,readout:n,readoutUnit:r,onSwap:o,disabled:a,invalid:i,onActivate:s}){return(0,Ze.jsxs)("div",{className:"flex h-9 items-stretch overflow-hidden rounded-md border transition-colors focus-within:border-slate-600",style:{background:cD,borderColor:i?"rgba(229,83,75,0.5)":dD,opacity:a?.4:1},children:[(0,Ze.jsx)("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"}),(0,Ze.jsx)("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:(0,Ze.jsx)(zd,{className:"h-3.5 w-3.5"})}),(0,Ze.jsxs)("div",{className:"flex shrink-0 items-center gap-1 pr-2.5 pl-1",children:[(0,Ze.jsx)("span",{className:"text-[12.5px] tabular-nums text-slate-400",children:n}),(0,Ze.jsx)("span",{className:"text-[10.5px] text-slate-600",children:r})]})]})}function K8({rows:e}){return(0,Ze.jsx)("div",{className:"flex flex-col gap-1.5 rounded-md p-2.5",style:{background:uD},children:e.map(t=>(0,Ze.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,Ze.jsx)("span",{className:"text-[11.5px] text-slate-500",children:t.label}),(0,Ze.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[t.lead&&(0,Ze.jsx)("span",{className:"text-[11px] tabular-nums text-slate-500",children:t.lead}),(0,Ze.jsx)("span",{className:"text-[12px] tabular-nums",style:{color:t.tone??"#cbd5e1"},children:t.value}),t.unit&&(0,Ze.jsx)("span",{className:"text-[10px] text-slate-600",children:t.unit})]})]},t.label))})}function $8({ticket:e,currencySymbol:t}){let n=[{label:"Risk",figure:e.risk,tone:Pm,sign:"-",missing:"No stop set"},{label:"Reward",figure:e.reward,tone:Rm,sign:"+",missing:"No target set"}];return(0,Ze.jsxs)("div",{className:"relative flex overflow-hidden rounded-md",style:{background:uD},children:[n.map(({label:r,figure:o,tone:a,sign:i,missing:s},l)=>(0,Ze.jsxs)("div",{className:`flex flex-1 flex-col gap-0.5 px-2.5 py-2 ${l===0?"items-start":"items-end"}`,children:[(0,Ze.jsx)("span",{className:"text-[10.5px] text-slate-500",children:r}),o?(0,Ze.jsxs)(Ze.Fragment,{children:[(0,Ze.jsxs)("span",{className:"flex items-baseline gap-1",children:[(0,Ze.jsxs)("span",{className:"text-[15px] font-semibold tabular-nums tracking-tight",style:{color:a},children:[i,Pw(o.usd)]}),(0,Ze.jsx)("span",{className:"text-[10px] text-slate-600",children:t})]}),(0,Ze.jsxs)("span",{className:"text-[10.5px] tabular-nums text-slate-500",children:[Y8(o.pct)," of balance"]})]}):(0,Ze.jsxs)(Ze.Fragment,{children:[(0,Ze.jsx)("span",{className:"text-[15px] font-semibold tracking-tight text-slate-700",children:"\u2014"}),(0,Ze.jsx)("span",{className:"text-[10.5px] text-slate-600",children:s})]})]},r)),e.rr!==null&&(0,Ze.jsxs)("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:Lw},children:["1:",e.rr.toFixed(2)]})]})}function Mw({label:e,hint:t,checked:n,onChange:r}){return(0,Ze.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,Ze.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,Ze.jsx)("span",{className:"text-[11.5px] text-slate-400",children:e}),(0,Ze.jsx)("span",{className:"text-[10.5px] leading-snug text-slate-600",children:t})]}),(0,Ze.jsx)(so,{checked:n,onCheckedChange:r,className:"mt-0.5 shrink-0 scale-[0.8] data-[state=checked]:bg-blue-500"})]})}function lD({title:e,open:t,onToggle:n,children:r}){return(0,Ze.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,Ze.jsxs)("button",{type:"button",onClick:n,className:"flex items-center justify-between border-t pt-3 text-left outline-none",style:{borderColor:Rw},children:[(0,Ze.jsx)("span",{className:"text-[12.5px] font-medium text-slate-300",children:e}),t?(0,Ze.jsx)(oi,{className:"h-3.5 w-3.5 text-slate-600"}):(0,Ze.jsx)(or,{className:"h-3.5 w-3.5 text-slate-600"})]}),t&&r]})}var Cg=["market","limit","stop"],X8=[{id:"offset",label:"Ticks"},{id:"price",label:"Price"}],Z8=[{id:"gtc",label:"Good till cancelled"},{id:"day",label:"Day"},{id:"ioc",label:"Immediate or cancel"},{id:"fok",label:"Fill or kill"}];function fD({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]=(0,cn.useState)({bid:0,ask:0,last:0}),d=(0,cn.useRef)(c);d.current=c;let m=(0,cn.useRef)(t);m.current=t;let[f,h]=(0,cn.useState)(a),[p,g]=(0,cn.useState)(null),y=(0,cn.useRef)(null),[v,b]=(0,cn.useState)(null),S=(0,cn.useRef)(l);S.current=l;let C=!!l;(0,cn.useEffect)(()=>{let te=()=>{let Pe=S.current?.selected();g(Pe?.name==="long"?"long":Pe?.name==="short"?"short":null)};te();let Me=[e.on("playback:tick",({bid:Pe,ask:at,last:nt})=>u({bid:Pe,ask:at,last:nt})),e.on("account:update",({balance:Pe})=>h(Pe)),e.on("drawing:selected",te)];return()=>Me.forEach(Pe=>Pe())},[e,C]);let w=rD,[k,M]=(0,cn.useState)(w?.side??"long"),[I,x]=(0,cn.useState)(w?.type??"market"),[T,R]=(0,cn.useState)(w?.tif??"gtc"),[P,D]=(0,cn.useState)(w?.entry??Lm("0")),[N,O]=(0,cn.useState)(w?.amountMode??"contracts"),[A,B]=(0,cn.useState)(w?.amount??"1"),[E,L]=(0,cn.useState)(w?.tpOn??!1),[H,K]=(0,cn.useState)(w?.slOn??!1),[G,V]=(0,cn.useState)(w?.tp??Lm("80")),[q,j]=(0,cn.useState)(w?.sl??Lm("40")),[W,$]=(0,cn.useState)(w?.exitsOpen??!0),[J,me]=(0,cn.useState)(w?.extrasOpen??!1),[We,Ce]=(0,cn.useState)(w?.reduceOnly??!1),[Ee,ze]=(0,cn.useState)(w?.keepOpen??!1),[Ie,ee]=(0,cn.useState)(w?.confirmFirst??!1),[Be,F]=(0,cn.useState)(!1),le=(0,cn.useRef)(void 0);(0,cn.useEffect)(()=>()=>window.clearTimeout(le.current),[]);let ce=(0,cn.useRef)(null);ce.current={side:k,type:I,tif:T,entry:P,amountMode:N,amount:A,tpOn:E,slOn:H,tp:G,sl:q,exitsOpen:W,extrasOpen:J,reduceOnly:We,confirmFirst:Ie,keepOpen:Ee},(0,cn.useEffect)(()=>()=>{rD=ce.current},[]);let ke=ml(t),De=ys(t),ve=te=>Dm(te,ke),Qe=te=>Dm(te,tD(t)),Ye=te=>te.toFixed(ke),$e=(0,cn.useMemo)(()=>{let te=k==="long"?c.ask:c.bid;return te>0?te:c.last},[k,c]),bt=(0,cn.useCallback)((te,Me,Pe)=>Pe==="entry"?{price:te.fixed==="price"?vs(te.price):Hi(Me+vs(te.offset)*De,t),offset:te.fixed==="offset"?vs(te.offset):Qu(Me,vs(te.price),t)}:{price:te.fixed==="price"?vs(te.price):Zu(Pe,Me,vs(te.offset),k,t),offset:te.fixed==="offset"?vs(te.offset):yg(Pe,Me,vs(te.price),k,t)},[k,t,De]),Oe=bt(P,$e,"entry"),Tt=I==="market"?$e:Oe.price,bn=bt(G,Tt,"tp"),En=bt(q,Tt,"sl"),Lt=(0,cn.useMemo)(()=>Sg({side:k,type:I,limitPrice:Oe.price,stopPrice:Oe.price,mark:c.last,bid:c.bid,ask:c.ask,amountMode:N,amount:vs(A),tpEnabled:E,tpTicks:bn.offset,slEnabled:H,slTicks:En.offset,balance:f,spec:t}),[k,I,Oe.price,c,N,A,E,bn.offset,H,En.offset,f,t]),it=te=>Lt.problems.find(Me=>Me.field===te),ft=te=>{let Me=wg(te,Lt.qty,{entry:Tt,stopTicks:H?Math.abs(En.offset):0,balance:f,spec:t});O(te),Me>0&&B(te==="contracts"?String(Me):Me.toFixed(2))},ie=te=>{M(te),I!=="market"&&D(Lm(sD(te,I)))},ge=te=>{x(te),te!=="market"&&D(Lm(sD(k,te)))},pe=(te,Me)=>te(Pe=>Pe.fixed==="offset"?{fixed:"price",price:Ye(Me.price),offset:Pe.offset}:{fixed:"offset",price:Pe.price,offset:String(Me.offset)}),Le=(0,cn.useCallback)(te=>{if(te.name!=="long"&&te.name!=="short")return;let Me=m.current,Pe=te.state,at=xg(te.name,{entry:Pe.a.price,upAmount:Pe.upAmount,downAmount:Pe.downAmount,qty:Pe.qty},d.current.last,Me);M(at.side),x(at.type),at.type!=="market"&&D({fixed:"price",price:at.entry.toFixed(ml(Me)),offset:"0"}),O("contracts"),B(String(at.qty)),L(!0),K(!0),V({fixed:"price",price:at.target.toFixed(ml(Me)),offset:"0"}),j({fixed:"price",price:at.stop.toFixed(ml(Me)),offset:"0"}),$(!0)},[]),Ue=()=>{let te=l?.selected()??y.current;!te||te.name!=="long"&&te.name!=="short"||(Le(te),b(te.id))};(0,cn.useEffect)(()=>e.on("trading:ticket-requested",({drawingId:te,requestId:Me})=>{if(Me===oD||(oD=Me,!te))return;let Pe=S.current?.byId(te);!Pe||Pe.name!=="long"&&Pe.name!=="short"||(Le(Pe),b(te))}),[e,Le]),(0,cn.useEffect)(()=>{let te=S.current;if(!v||!te)return;let Me=()=>{let Pe=te.byId(v);if(!Pe){b(null);return}Le(Pe)};return Me(),te.subscribe(Me)},[v,C,Le]);let Ge=()=>{if(!Lt.ok)return;if(Ie&&!Be){F(!0),window.clearTimeout(le.current),le.current=window.setTimeout(()=>F(!1),4e3);return}window.clearTimeout(le.current),F(!1);let te=Me=>[{id:vn(8),price:Me,qty:Lt.qty,triggered:!1,triggeredAt:0}];r({side:k,type:I,qty:Lt.qty,symbol:n,tif:T,...We?{reduceOnly:!0}:{},...I==="limit"?{limitPrice:Lt.entry}:{},...I==="stop"?{stopPrice:Lt.entry}:{},...Lt.tpPrice!==null?{bracketTp:te(Lt.tpPrice)}:{},...Lt.slPrice!==null?{bracketSl:te(Lt.slPrice)}:{}}),b(null),Ee||o?.()},Ve=k==="long",Ne=Ve?Rm:Pm;(0,cn.useEffect)(()=>{let te=()=>e.emit("trading:preview",{lines:[],symbol:n});if(v||Lt.qty<=0)return te(),te;let Me=nt=>({price:0,kind:"custom",preview:!0,movable:!0,qty:Lt.qty,...nt}),Pe=nt=>`${nt<0?"-":"+"}$${Math.abs(nt).toFixed(2)}`,at=[...I==="market"?[]:[Me({id:"preview-entry",kind:I==="limit"?"limit":"stop",side:k,price:Lt.entry,label:`${Ve?"Buy":"Sell"} ${I==="limit"?"Limit":"Stop"}`,onMove:nt=>D({fixed:"price",price:Ye(nt),offset:"0"}),onClose:()=>o?.()})],...Lt.tpPrice!==null?[Me({id:"preview-tp",kind:"tp",price:Lt.tpPrice,label:`TP ${Pe(Lt.reward?.usd??0)}`,onMove:nt=>V({fixed:"price",price:Ye(nt),offset:"0"}),onClose:()=>L(!1)})]:[],...Lt.slPrice!==null?[Me({id:"preview-sl",kind:"sl",price:Lt.slPrice,label:`SL ${Pe(-(Lt.risk?.usd??0))}`,onMove:nt=>j({fixed:"price",price:Ye(nt),offset:"0"}),onClose:()=>K(!1)})]:[]];return e.emit("trading:preview",{lines:at,symbol:n}),te},[e,n,v,k,I,Ne,Ve,Lt.entry,Lt.qty,Lt.tpPrice,Lt.slPrice,Lt.reward?.usd,Lt.risk?.usd]);let Se=(0,cn.useRef)(null),[He,_e]=(0,cn.useState)(()=>kw??s),dt=(0,cn.useRef)(null),_t=(0,cn.useCallback)(te=>{let Me=Se.current?.offsetHeight??0,Pe={x:aD(te.x),y:iD(te.y,Me)};kw=Pe,_e(Pe)},[]);return(0,cn.useLayoutEffect)(()=>{let te=Se.current;if(!te)return;let Me=()=>{let at=te.offsetHeight;_e(nt=>{let pt={x:aD(nt.x),y:iD(nt.y,at)};return pt.x===nt.x&&pt.y===nt.y?nt:(kw=pt,pt)})};Me();let Pe=new ResizeObserver(Me);return Pe.observe(te),window.addEventListener("resize",Me),()=>{Pe.disconnect(),window.removeEventListener("resize",Me)}},[]),(0,Ze.jsxs)("div",{ref:Se,className:"fixed z-[200] flex w-[370px] min-h-0 select-none flex-col overflow-hidden rounded-xl border shadow-2xl",style:{left:He.x,top:He.y,background:Lw,borderColor:dD,maxHeight:`calc(100vh - ${He.y+Ju}px)`},children:[(0,Ze.jsxs)("div",{className:"flex shrink-0 cursor-grab items-center gap-2 px-3 py-3 active:cursor-grabbing",onPointerDown:te=>{dt.current={dx:te.clientX-He.x,dy:te.clientY-He.y},te.target.setPointerCapture(te.pointerId)},onPointerMove:te=>{let Me=dt.current;Me&&_t({x:te.clientX-Me.dx,y:te.clientY-Me.dy})},onPointerUp:()=>{dt.current=null},children:[(0,Ze.jsx)("img",{src:"/icon-star.ico",alt:"",className:"w-5"}),(0,Ze.jsx)("span",{className:"text-[13px] font-medium tracking-tight text-slate-100 ",children:n||"Order"}),o&&(0,Ze.jsx)("button",{type:"button",onClick:o,className:"ml-auto shrink-0 text-slate-600 outline-none transition-colors hover:text-slate-300",children:(0,Ze.jsx)(Kr,{className:"h-4 w-4"})})]}),(0,Ze.jsxs)("div",{className:"flex shrink-0 flex-col gap-3 px-3 pb-3",children:[(0,Ze.jsxs)("div",{className:"relative flex overflow-hidden rounded-xl",style:{background:cD},children:[["short","long"].map(te=>{let Me=k===te,Pe=te==="short",at=Pe?Pm:Rm;return(0,Ze.jsxs)("button",{type:"button",onClick:()=>ie(te),className:`flex flex-1 flex-col gap-0.5 px-3 py-2 outline-none transition-colors ${Pe?"items-start rounded-l-xl":"items-end rounded-r-xl"}`,style:{background:Me?`${at}1f`:"transparent",boxShadow:Me?`inset 0 0 0 1px ${at}59`:void 0},children:[(0,Ze.jsx)("span",{className:"text-[11.5px] font-medium",style:{color:Me?at:"#64748b"},children:Pe?"Sell":"Buy"}),(0,Ze.jsx)("span",{className:"text-[17px] font-semibold tracking-tight",style:{color:Me?at:"#94a3b8"},children:ve(Pe?c.bid:c.ask)})]},te)}),(0,Ze.jsx)("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:Lw},children:Lt.spread.usd})]}),v?(0,Ze.jsxs)("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:`${Ne}59`,color:Ne},children:[(0,Ze.jsx)($c,{className:"h-3.5 w-3.5 shrink-0"}),(0,Ze.jsxs)("span",{className:"truncate",children:["Following the ",k," drawing"]}),(0,Ze.jsxs)(Gt,{children:[(0,Ze.jsx)(qt,{asChild:!0,children:(0,Ze.jsxs)("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:[(0,Ze.jsx)(xf,{className:"h-3 w-3"}),"Unlink"]})}),(0,Ze.jsx)(Ut,{className:"bg-background border border-border z-[210]",children:"Stop following it"})]})]}):p&&(0,Ze.jsxs)("button",{type:"button",onPointerDown:()=>{y.current=l?.selected()??null},onClick:Ue,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"?Rm:Pm}66`,color:p==="long"?Rm:Pm},children:[(0,Ze.jsx)($c,{className:"h-3 w-3"}),"Follow the selected ",p," drawing"]}),(0,Ze.jsxs)("div",{className:"relative flex border-b",style:{borderColor:Rw},children:[Cg.map(te=>(0,Ze.jsx)("button",{type:"button",onClick:()=>ge(te),className:`flex-1 pb-2 text-[12.5px] capitalize outline-none transition-colors ${I===te?"text-slate-100":"text-slate-500 hover:text-slate-300"}`,children:te},te)),(0,Ze.jsx)("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:Ne,width:`${100/Cg.length}%`,left:`${Math.max(0,Cg.indexOf(I))*100/Cg.length}%`}})]})]}),(0,Ze.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 pb-3",children:[I!=="market"&&(0,Ze.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,Ze.jsx)("span",{className:"text-[11.5px] text-slate-500",children:P.fixed==="offset"?`Ticks from ${Ve?"ask":"bid"}`:"Entry price"}),(0,Ze.jsx)(Iw,{value:P.fixed==="price"?P.price:P.offset,onChange:te=>D(Me=>({...Me,[Me.fixed==="price"?"price":"offset"]:te})),readout:P.fixed==="price"?String(Oe.offset):ve(Oe.price),readoutUnit:P.fixed==="price"?"ticks":"price",onSwap:()=>pe(D,Oe),invalid:!!it("entry")})]}),(0,Ze.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,Ze.jsx)(Tw,{value:N,options:vg,onChange:ft}),(0,Ze.jsx)(Iw,{value:A,onChange:B,readout:N==="contracts"?Dm(Lt.contractValue,0):String(Lt.qty),readoutUnit:N==="contracts"?i:"contracts",onSwap:()=>ft(N==="contracts"?"value":"contracts"),invalid:!!it("amount")})]}),(0,Ze.jsx)(lD,{title:"Exits",open:W,onToggle:()=>$(te=>!te),children:[["tp","Take profit",E,L,G,V,bn],["sl","Stop loss",H,K,q,j,En]].map(([te,Me,Pe,at,nt,pt,Xt])=>(0,Ze.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,Ze.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,Ze.jsx)(Tw,{prefix:Me,value:nt.fixed,options:X8,onChange:Ft=>pt(cr=>cr.fixed===Ft?cr:Ft==="price"?{fixed:"price",price:Ye(Xt.price),offset:cr.offset}:{fixed:"offset",price:cr.price,offset:String(Xt.offset)})}),(0,Ze.jsx)(so,{checked:Pe,onCheckedChange:at,className:"scale-[0.8] data-[state=checked]:bg-blue-500"})]}),(0,Ze.jsx)(Iw,{disabled:!Pe,onActivate:()=>at(!0),value:nt.fixed==="price"?nt.price:nt.offset,onChange:Ft=>pt(cr=>({...cr,[cr.fixed==="price"?"price":"offset"]:Ft})),readout:nt.fixed==="price"?String(Xt.offset):ve(Xt.price),readoutUnit:nt.fixed==="price"?"ticks":"price",onSwap:()=>pe(pt,Xt),invalid:!!it(te)})]},te))}),(0,Ze.jsxs)(lD,{title:"Extra settings",open:J,onToggle:()=>me(te=>!te),children:[(0,Ze.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,Ze.jsx)("span",{className:"text-[11.5px] text-slate-500",children:"Time in force"}),(0,Ze.jsx)(Tw,{value:T,options:Z8,onChange:te=>R(te)})]}),(0,Ze.jsx)(Mw,{label:"Reduce only",hint:"Never opens or grows a position - only closes one",checked:We,onChange:Ce}),(0,Ze.jsx)(Mw,{label:"Confirm before placing",hint:"The button asks a second time before the order goes",checked:Ie,onChange:te=>{ee(te),F(!1)}}),(0,Ze.jsx)(Mw,{label:"Keep the ticket open",hint:"Stays up after an order goes, for placing several in a row",checked:Ee,onChange:ze})]})]}),(0,Ze.jsxs)("div",{className:"flex shrink-0 flex-col gap-2 border-t px-3 pb-3 pt-3",style:{borderColor:Rw},children:[(0,Ze.jsx)($8,{ticket:Lt,currencySymbol:i}),(0,Ze.jsx)(K8,{rows:[{label:"Position value",value:Dm(Lt.contractValue),unit:i},{label:"Per tick",value:Pw(Lt.tickValue*Math.max(0,Lt.qty)),unit:i},{label:"Spread cost",value:Pw(Lt.spread.usd*Math.max(0,Lt.qty)),unit:i}]}),Lt.problems.length>0&&(0,Ze.jsx)("p",{className:"text-[11.5px] leading-relaxed text-amber-500/90",children:Lt.problems[0].message}),(0,Ze.jsxs)(br,{type:"button",disabled:!Lt.ok,onClick:Ge,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:Ne},children:[(0,Ze.jsx)("span",{className:"text-[14px] font-semibold leading-none",children:Be?"Press again to confirm":`${Ve?"Buy":"Sell"} ${Qe(Lt.qty)} ${n??""}`}),(0,Ze.jsx)("span",{className:"text-[11px] font-normal leading-none text-white/75",children:Be?`${Ve?"Buy":"Sell"} ${Qe(Lt.qty)} ${n??""} ${I==="market"?"at market":`@ ${ve(Lt.entry)}`}`:I==="market"?"at market":`${I} @ ${ve(Lt.entry)}`})]})]})]})}
|