openalgo-charts 2.5.2 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/dist/draw/index.d.ts +20 -1
- package/dist/index.d.ts +54 -4
- package/dist/openalgo-charts.draw.mjs +1 -1
- package/dist/openalgo-charts.draw.mjs.map +1 -1
- package/dist/openalgo-charts.mjs +1 -1
- package/dist/openalgo-charts.mjs.map +1 -1
- package/dist/openalgo-charts.standalone.js +1 -1
- package/dist/openalgo-charts.standalone.js.map +1 -1
- package/dist/openalgo-charts.widget.mjs +1 -1
- package/dist/openalgo-charts.widget.mjs.map +1 -1
- package/dist/widget/index.d.ts +160 -7
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{formatZonedCrosshairLabel as e,registeredChartTypes as t,getChartType as o,exportChartDataCsv as n,INDICATOR_SOURCES as a,registeredIntervals as i,registeredIndicators as r,getIndicator as s,indicatorStyleInputs as l,indicatorDefaults as c,chartSettingsSchema as d,readChartSettings as p,applyChartSettings as h,registeredBarConditions as u,utcSecondsToZonedParts as b,zoneOffsetSeconds as g,alertSettingsSchema as f,getBarCondition as m,zonedWallClockToUtcSeconds as v,PRICE_SCALE_MODES as w,isReplaying as y,checkTradingCapability as x,tryResolveInterval as _,lightTheme as k,darkTheme as C,DataLoadingController as $,resolveInterval as S,isKnownInterval as A,createChart as L,AlertController as O,ChartObjects as T}from"./openalgo-charts.mjs";import{chromeIconSvg as E,hasDrawingTool as M,DRAWING_TOOL_ICONS as j,iconUse as P,getDrawingTool as I,iconSprite as D,toolCursor as N,drawingShortcuts as z,DEFAULT_FIB as R,drawingSettingsSchema as B,gannLabel as F,formatRatio as U,readDrawingSetting as H,cloneLevels as V,applyDrawingSettings as K,LEVEL_NEUTRAL as q,levelColor as W,readDrawingSettings as G,registeredDrawingTools as Z,DrawingController as Y,keyToDrawingAction as J}from"./openalgo-charts.draw.mjs";const X=Object.freeze({}),Q=/\{([A-Za-z][A-Za-z0-9_]*)\}/g;function ee(e,t,o=X,n=t){let a=n;if(void 0!==e.translate)try{const i=e.translate(t,n,Object.freeze({...o}));if("string"==typeof i&&""!==i.trim()){const e=new Set(Array.from(n.matchAll(Q),e=>e[1])),t=new Set(Array.from(i.matchAll(Q),e=>e[1]));e.size===t.size&&[...e].every(e=>t.has(e))&&(a=i)}}catch{}return a.replace(Q,(e,t)=>Object.prototype.hasOwnProperty.call(o,t)?String(o[t]):e)}const te=e=>String(e).replace(/[&<>"]/g,e=>"&"===e?"&":"<"===e?"<":">"===e?">":""");function oe(e,t,o,n){const a=e.createElement(t);if(o&&(a.className=o),n)for(const[e,t]of Object.entries(n))a.setAttribute(e,t);return a}function ne(e,t,o){const n=e.createElement("span");return n.className="oac-glyph oac-glyph--"+o,n.setAttribute("aria-hidden","true"),n.innerHTML=t,n}function ae(e){const t=e;if(null==t)return!1;if(!0===t.isContentEditable)return!0;const o=(t.tagName??"").toUpperCase();if("TEXTAREA"===o||"SELECT"===o)return!0;if("INPUT"!==o)return!1;const n=(t.type??"text").toLowerCase();return!["checkbox","radio","button","submit","reset","range","color"].includes(n)}function ie(e){if(null===e)return!1;const t=e;if(!0===t.disabled)return!1;const o=t.getAttribute("tabindex");if(null!==o&&Number(o)<0)return!1;const n=t.tagName;if(!("BUTTON"===n||"INPUT"===n||"SELECT"===n||"TEXTAREA"===n||"A"===n&&t.hasAttribute("href"))&&null===o)return!1;for(let e=t;null!==e;e=e.parentElement)if(e.hidden)return!1;return!0}const re=e=>Array.from(e.querySelectorAll("*")).filter(ie);function se(e,t,o,n=6,a=8){let i=e.right+n,r="right";i+t.width>o.width-a&&e.left-n-t.width>=a&&(i=e.left-n-t.width,r="left"),i=Math.max(a,Math.min(i,o.width-t.width-a));return{left:i,top:Math.max(a,Math.min(e.top,o.height-t.height-a)),side:r}}function le(e,t,o,n=4,a=8){let i=e.bottom+n;return i+t.height>o.height-a&&e.top-n-t.height>=a&&(i=e.top-n-t.height),{left:Math.max(a,Math.min(e.left,o.width-t.width-a)),top:Math.max(a,Math.min(i,o.height-t.height-a))}}function ce(e,t,o,n="right",a=8,i=6){let r,s;if("right"===n||"left"===n){const l="right"===n;r=l?e.right+a:e.left-a-t.width,(l?r+t.width>o.width-i:r<i)&&(r=l?e.left-a-t.width:e.right+a),s=e.top+e.height/2-t.height/2}else{const l="top"!==n;s=l?e.bottom+a:e.top-a-t.height,(l?s+t.height>o.height-i:s<i)&&(s=l?e.top-a-t.height:e.bottom+a),r=e.left+e.width/2-t.width/2}return{left:Math.max(i,Math.min(r,o.width-t.width-i)),top:Math.max(i,Math.min(s,o.height-t.height-i))}}function de(e,t){const o=e.getBoundingClientRect(),n=t.getBoundingClientRect();return{left:n.left-o.left,top:n.top-o.top,right:n.right-o.left,bottom:n.bottom-o.top,width:n.width,height:n.height}}class pe{constructor(){Object.defineProperty(this,"_handlers",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}on(e,t){let o=this._handlers.get(e);return void 0===o&&(o=new Set,this._handlers.set(e,o)),o.add(t),()=>this.off(e,t)}off(e,t){void 0!==t?this._handlers.get(e)?.delete(t):this._handlers.delete(e)}emit(e,t){const o=this._handlers.get(e);if(void 0===o)return;const n=[];for(const e of Array.from(o))try{e(t)}catch(e){n.push(e)}if(n.length>0)throw n[0]}clear(){this._handlers.clear()}}const he="oac-widget:";class ue{constructor(e,t){Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ns",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._ns=he+e+":",this._store=t}key(e){return this._ns+e}get(e){if(null===this._store)return null;try{const t=this._store.getItem(this.key(e));return null===t?null:JSON.parse(t)}catch{return null}}set(e,t){if(null===this._store)return!1;try{return this._store.setItem(this.key(e),JSON.stringify(t)),!0}catch{return!1}}remove(e){if(null!==this._store)try{this._store.removeItem(this.key(e))}catch{}}get enabled(){return null!==this._store}}function be(){try{const e=globalThis;return void 0!==e.localStorage&&"function"==typeof e.localStorage.getItem?e.localStorage:null}catch{return null}}const ge=new Map;function fe(e,t){return ge.set(e,t),()=>{ge.get(e)===t&&ge.delete(e)}}function me(e){const t=Object.entries(e).map(([e,t])=>fe(e,t));return()=>{for(const e of t)e()}}function ve(e){return ge.delete(e)}function we(e){return ge.get(e)??null}function ye(){return Array.from(ge.keys())}function xe(e,t){const o=oe(t,"div","oac-layer");e.appendChild(o);const n=[],a=e=>{if(e.closed)return;e.closed=!0;const o=n.indexOf(e);o>=0&&n.splice(o,1);const a=t.activeElement,i=null!==a&&e.el.contains(a);e.el.remove(),e.scrim?.remove(),e.opts.anchor?.setAttribute("aria-expanded","false");const r=null===a||a===t.body||i;!1!==e.opts.restoreFocus&&r&&null!==e.restore&&e.restore.isConnected&&e.restore.focus(),e.opts.onClose?.(),0===n.length&&l()},i=e=>{const o=n[n.length-1];if(void 0===o)return;if("Escape"===e.key){if(!1===o.opts.dismissOnEscape)return;return e.preventDefault(),e.stopImmediatePropagation(),void a(o)}if("Tab"!==e.key)return;const i=re(o.el);if(0===i.length)return void e.preventDefault();const r=i.indexOf(t.activeElement);let s=null;e.shiftKey?r<=0&&(s=i.length-1):(-1===r||r>=i.length-1)&&(s=0),null!==s&&(e.preventDefault(),i[s].focus())},r=e=>{const t=e.target;for(let e=n.length-1;e>=0;e--){const o=n[e];if(null!==t&&(o.el.contains(t)||!0===o.opts.anchor?.contains(t)))break;if(!1===o.opts.dismissOnOutside||!0===o.opts.modal&&!0!==o.opts.dismissOnOutside)break;a(o)}};let s=!1;const l=()=>{s&&(s=!1,t.removeEventListener("keydown",i,!0),t.removeEventListener("pointerdown",r,!0))};return{open:(l,c={})=>{const d=c.placement??(c.anchor?"below":"center"),p=c.modal??"center"===d,h=t.activeElement,u=null===h||h===t.body||l.contains(h)?null:h;let b=null;const g={el:l,opts:{...c,modal:p},scrim:null,restore:u,closed:!1};if(p&&(b=oe(t,"div","oac-scrim"),!0===c.dismissOnOutside&&b.addEventListener("pointerdown",()=>a(g)),o.appendChild(b),g.scrim=b),l.addEventListener("pointerdown",e=>e.stopPropagation()),"center"===d?(l.classList.add("oac-dialog"),l.hasAttribute("role")||l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true")):l.classList.add("oac-pop"),l.hasAttribute("tabindex")||(l.tabIndex=-1),o.appendChild(l),"center"!==d&&c.anchor){const t=e.getBoundingClientRect();let o=de(e,c.anchor);if("beside"===d&&c.edge){const t=de(e,c.edge),n=Math.max(o.right,t.right);o={...o,right:n,width:n-o.left}}const n={width:l.offsetWidth,height:l.offsetHeight},a="beside"===d?se(o,n,t):le(o,n,t);l.style.left=a.left+"px",l.style.top=a.top+"px",c.anchor.setAttribute("aria-expanded","true")}if(n.push(g),s||(s=!0,t.addEventListener("keydown",i,!0),t.addEventListener("pointerdown",r,!0)),null!==c.initialFocus){(c.initialFocus??function(e){const t=re(e);return t.find(e=>null===e.closest(".oac-dialog__head"))??t[0]??null}(l)??l).focus()}return()=>a(g)},closeTop:()=>{const e=n[n.length-1];return void 0!==e&&(a(e),!0)},closeAll:()=>{for(const e of n.slice().reverse())a(e)},top:()=>n[n.length-1]?.el??null,size:()=>n.length,layer:o,destroy:()=>{for(const e of n.slice().reverse())a(e);l(),o.remove()}}}const _e=600;function ke(e,t,o){const n=new WeakMap;let a=null,i=0,r=null;const s=e=>"function"==typeof e?e():e,l=()=>{0!==i&&clearTimeout(i),i=0,r=null,a?.classList.remove("is-on")},c=i=>{const c=n.get(i);if(void 0===c||!i.isConnected)return;const d=s(c);if(null===d||!d.title)return void l();if("function"==typeof c&&i.setAttribute("aria-label",d.title),null===a&&(a=oe(o,"div","oac-tip",{role:"presentation"})),a.parentNode!==t&&t.appendChild(a),r=i,a.textContent="",a.appendChild(o.createTextNode(d.title)),d.chord){const e=oe(o,"kbd","oac-tip__chord");e.textContent=d.chord,a.appendChild(e)}if(d.sub){const e=oe(o,"span","oac-tip__sub");e.textContent=d.sub,a.appendChild(e)}const p=e.getBoundingClientRect(),h=ce(de(e,i),{width:a.offsetWidth,height:a.offsetHeight},p,d.side??"right");a.style.left=h.left+"px",a.style.top=h.top+"px",a.classList.add("is-on")};return{attach:(e,t,o=0)=>{n.set(e,t);const a=s(t);null!==a&&a.title&&!e.getAttribute("aria-label")&&e.setAttribute("aria-label",a.title),e.removeAttribute("title");const r=()=>{0!==i&&clearTimeout(i),o>0?i=setTimeout(()=>c(e),o):c(e)};e.addEventListener("pointerenter",r),e.addEventListener("focus",r),e.addEventListener("pointerleave",l),e.addEventListener("blur",l),e.addEventListener("pointerdown",l),e.addEventListener("keydown",l)},refreshLabel:e=>{const t=n.get(e);if("function"!=typeof t)return;const o=t();null!==o&&o.title&&e.setAttribute("aria-label",o.title)},show:c,hide:l,target:()=>r,destroy:()=>{l(),a?.remove(),a=null}}}const Ce={mod:"Mod",ctrl:"Mod",control:"Mod",cmd:"Mod",command:"Mod",meta:"Mod",win:"Mod",alt:"Alt",option:"Alt",opt:"Alt",shift:"Shift"},$e={esc:"Escape",escape:"Escape",del:"Delete",delete:"Delete",backspace:"Backspace",enter:"Enter",return:"Enter",tab:"Tab",space:"Space",spacebar:"Space",left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",arrowup:"ArrowUp",arrowdown:"ArrowDown",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",insert:"Insert",plus:"+",minus:"-",question:"?",slash:"/",period:".",comma:","},Se=new Set(["Shift","Control","Alt","Meta","OS","AltGraph","CapsLock","Fn"]),Ae=["Mod","Alt","Shift"];function Le(e){const t=e.trim();if(""===t)return"";let o,n;if("+"===t)o="+",n=[];else if(t.endsWith("++"))o="+",n=t.slice(0,-2).split("+").map(e=>e.trim());else{const e=t.split("+").map(e=>e.trim());o=e[e.length-1],n=e.slice(0,-1)}if(""===o||void 0!==Ce[o.toLowerCase()])return"";const a=new Set;for(const e of n){const t=Ce[e.toLowerCase()];if(void 0===t)return"";a.add(t)}o=function(e){const t=e.toLowerCase();return void 0!==$e[t]?$e[t]:/^f([1-9]|1[0-2])$/.test(t)?t.toUpperCase():1===e.length&&/[a-z]/i.test(e)?t:e}(o),1!==o.length||/[a-z]/.test(o)||a.delete("Shift");return[...Ae.filter(e=>a.has(e)),o].join("+")}function Oe(e){let t=e.key??"";if(""===t||"Unidentified"===t||Se.has(t))return"";" "!==t&&"Spacebar"!==t||(t="Space"),"Esc"===t&&(t="Escape"),"Del"===t&&(t="Delete");const o=e.code??"";!0===e.altKey&&/^Key[A-Z]$/.test(o)&&(t=o.slice(3).toLowerCase());const n=[];return!0!==e.ctrlKey&&!0!==e.metaKey||n.push("Mod"),!0===e.altKey&&n.push("Alt"),1===t.length?/[a-z]/i.test(t)&&(t=t.toLowerCase(),!0===e.shiftKey&&n.push("Shift")):!0===e.shiftKey&&n.push("Shift"),[...n,t].join("+")}const Te={Escape:"Esc",Delete:"Del",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down"};function Ee(){const e=globalThis.navigator;return void 0!==e&&/mac|iphone|ipad/i.test(e.platform??e.userAgent??"")}function Me(e,t=Ee()){const o=Le(e);if(""===o)return"";const n=o.split("+"),a=n[n.length-1];return[...n.slice(0,-1).map(e=>"Mod"===e?t?"Cmd":"Ctrl":"Alt"===e?t?"Opt":"Alt":"Shift"),Te[a]??(1===a.length?a.toUpperCase():a)].join("+")}function je(e){const t=e.split("+").map(e=>e.trim()).filter(e=>""!==e);if(0===t.length)return"";const o=t[t.length-1],n=t.slice(0,-1).map(e=>"Alt"===e?"Alt":"Shift"===e?"Shift":"Mod");let a;const i=/^Key([A-Z])$/.exec(o),r=/^Digit([0-9])$/.exec(o);return a=null!==i?i[1].toLowerCase():null!==r?r[1]:"Equal"===o?n.includes("Shift")?"+":"=":"Minus"===o?n.includes("Shift")?"_":"-":"NumpadAdd"===o?"+":"NumpadSubtract"===o?"-":"Slash"===o?n.includes("Shift")?"?":"/":o,Le([...n,a].join("+"))}class Pe{constructor(e={}){Object.defineProperty(this,"_isMac",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_scopes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_bindings",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_byCombo",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_conflicts",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_conflictListeners",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_detach",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_nextId",{enumerable:!0,configurable:!0,writable:!0,value:1}),this._isMac=e.isMac??Ee(),this._chart=e.chart??null,this._scopes=e.scopes??(()=>["global"])}get isMac(){return this._isMac}setScopes(e){this._scopes=e}activeScopes(){return this._scopes()}register(e,t,o="global",n={}){const a=Le(e);if(""===a)throw new Error(`openalgo-charts widget: "${e}" is not a key binding`);const i={id:this._nextId++,combo:a,scope:o,label:n.label??Me(a,this._isMac),group:n.group??"Widget",hidden:!0===n.hidden,inText:!0===n.inText,layered:!0===n.layered,action:t,when:n.when},r=this._byCombo.get(a)??[];if(!0!==n.layered){const e=r.find(e=>e.scope===o);void 0!==e&&this._conflict({combo:a,scope:o,kept:e.label,shadowed:i.label,source:"widget"})}return r.push(i),this._byCombo.set(a,r),this._bindings.push(i),()=>this._unregister(i)}_unregister(e){const t=this._bindings.indexOf(e);t>=0&&this._bindings.splice(t,1);const o=this._byCombo.get(e.combo);if(void 0!==o){const t=o.indexOf(e);t>=0&&o.splice(t,1),0===o.length&&this._byCombo.delete(e.combo)}for(let t=this._conflicts.length-1;t>=0;t--){const o=this._conflicts[t];"widget"!==o.source||o.combo!==e.combo||o.kept!==e.label&&o.shadowed!==e.label||this._conflicts.splice(t,1)}}_conflict(e){this._conflicts.push(e);for(const t of this._conflictListeners)t(e)}onConflict(e){return this._conflictListeners.add(e),()=>this._conflictListeners.delete(e)}handle(e){const t=Oe(e);if(""===t)return!1;const o=this._byCombo.get(t);if(void 0===o)return!1;const n=ae(e.target);for(const t of this._scopes())for(const a of o)if(a.scope===t&&(!n||a.inText)&&(void 0===a.when||a.when())&&!1!==a.action(e))return e.preventDefault?.(),e.stopPropagation?.(),!0;return!1}attach(e){this._detach?.();const t=e=>{this.handle(e)};return e.addEventListener("keydown",t,!0),this._detach=()=>{e.removeEventListener("keydown",t,!0),this._detach=null},this._detach}list(){return this._bindings.slice()}conflicts(){const e=this._conflicts.slice();if(null!==this._chart)for(const t of this._chart.list())if(!t.isDisabled)for(const o of t.combos){const n=je(o),a=(this._byCombo.get(n)??[]).find(e=>"overlay"!==e.scope&&"rail"!==e.scope&&!e.layered);void 0!==a&&e.push({combo:n,scope:a.scope,kept:a.label,shadowed:t.label,source:"chart"})}return e}format(e){return Me(e,this._isMac)}describe(){const e=new Map;for(const t of this._bindings){if(t.hidden)continue;const o=e.get(t.group)??[];o.push({label:t.label,combo:t.combo,display:this.format(t.combo)}),e.set(t.group,o)}const t=Array.from(e,([e,t])=>({group:e,rows:t}));if(null!==this._chart){const e=new Map;for(const t of this.conflicts())"chart"===t.source&&e.set(t.shadowed+"|"+t.combo,t.kept);const o=[];for(const t of this._chart.list()){if(t.isDisabled||0===t.combos.length)continue;const n=je(t.combos[0]),a={label:t.label,combo:n,display:this.format(n)},i=e.get(t.label+"|"+n);void 0!==i&&(a.shadowedBy=i),o.push(a)}o.length>0&&t.push({group:"Chart",rows:o})}return t}destroy(){this._detach?.(),this._bindings.length=0,this._byCombo.clear(),this._conflicts.length=0,this._conflictListeners.clear()}}function Ie(e){const t=e.document,o=oe(t,"div","oac-keys-dialog",{"aria-label":ee(e,"Keyboard shortcuts")}),n=oe(t,"div","oac-dialog__head"),a=oe(t,"div","oac-dialog__title");a.textContent=ee(e,"Keyboard shortcuts");const i=oe(t,"button","oac-btn oac-btn--icon",{type:"button","aria-label":ee(e,"Close")});i.innerHTML=E("close"),n.appendChild(a),n.appendChild(i);const r=oe(t,"div","oac-dialog__body"),s=oe(t,"div","oac-keys");let l=0;for(const o of e.keymap.describe()){const n=oe(t,"div","oac-keys__group"),a=oe(t,"div","oac-head");a.textContent=ee(e,`schema.shortcuts.group.${o.group}`,{},o.group),n.appendChild(a);for(const a of o.rows){const i=oe(t,"div","oac-keys__row"),r=oe(t,"span");r.textContent=ee(e,`schema.shortcuts.${o.group}.${a.combo}`,{},a.label);const s=oe(t,"kbd");s.textContent=a.display,i.appendChild(r),i.appendChild(s),void 0!==a.shadowedBy&&(i.classList.add("is-shadowed"),i.title=ee(e,"Claimed by {name}",{name:a.shadowedBy}),l++),n.appendChild(i)}s.appendChild(n)}if(r.appendChild(s),l>0){const o=oe(t,"div","oac-keys__note");o.textContent=ee(e,1===l?"{count} chart shortcut struck through: the same chord arms a drawing tool here and takes precedence.":"{count} chart shortcuts struck through: the same chord arms a drawing tool here and takes precedence.",{count:l}),r.appendChild(o)}o.appendChild(n),o.appendChild(r);const c=e.openOverlay(o,{placement:"center",dismissOnOutside:!0});return i.addEventListener("click",c),c}const De=["off","weak","strong"],Ne=[{id:"lines",title:"Lines",items:[{head:"Lines"},{tool:"trend-line"},{tool:"ray"},{tool:"extended-line"},{tool:"arrow"},{tool:"info-line"},{tool:"trend-angle"},{head:"Horizontal and vertical"},{tool:"horizontal-line"},{tool:"horizontal-ray"},{tool:"vertical-line"},{tool:"cross-line"}]},{id:"channels",title:"Channels",items:[{head:"Channels"},{tool:"parallel-channel"},{tool:"fib-channel"},{tool:"disjoint-channel"},{tool:"flat-top-bottom"},{tool:"regression-channel"},{head:"Pitchforks"},{tool:"pitchfork"},{tool:"schiff-pitchfork"},{tool:"modified-schiff-pitchfork"},{tool:"inside-pitchfork"}]},{id:"fib",title:"Fibonacci and Gann",items:[{head:"Fibonacci"},{tool:"fib-retracement"},{tool:"fib-extension"},{tool:"fib-time-zone"},{tool:"fib-fan"},{tool:"fib-extension-two-point"},{tool:"fib-speed-resistance-fan"},{tool:"trend-fib-time"},{tool:"fib-circles"},{tool:"fib-speed-resistance-arcs"},{tool:"fib-wedge"},{tool:"fib-spiral"},{head:"Gann"},{tool:"gann-fan"},{tool:"gann-box"},{tool:"gann-square"}]},{sep:!0},{id:"shapes",title:"Shapes",items:[{head:"Shapes"},{tool:"rectangle"},{tool:"rotated-rectangle"},{tool:"ellipse"},{tool:"circle"},{tool:"triangle"},{head:"Paths"},{tool:"path"},{tool:"polyline"},{tool:"arc"},{tool:"curve"},{tool:"double-curve"}]},{id:"cycles",title:"Cycles",items:[{head:"Cycles"},{tool:"cyclic-lines"},{tool:"time-cycles"},{tool:"sine-line"}]},{id:"patterns",title:"Patterns",items:[{head:"Patterns and waves"},{tool:"xabcd-pattern"},{tool:"abcd-pattern"},{tool:"head-shoulders"},{tool:"elliott-impulse"},{tool:"elliott-correction"},{head:"Harmonic patterns"},{tool:"gartley"},{tool:"bat"},{tool:"butterfly"},{tool:"crab"},{tool:"shark"},{tool:"cypher"}]},{id:"geometry",title:"Geometric studies",items:[{head:"Geometric studies"},{tool:"dedekind-tessellation"},{tool:"sonic"},{tool:"supersonic"},{tool:"golden-sonic"},{tool:"golden-supersonic"}]},{id:"marks",title:"Arrows and marks",items:[{head:"Arrows"},{tool:"arrow-up"},{tool:"arrow-down"},{tool:"arrow-left"},{tool:"arrow-right"},{head:"Marks"},{tool:"flag-mark"},{tool:"icon-stamp"},{tool:"price-label"},{tool:"signpost"}]},{sep:!0},{id:"forecast",title:"Forecasting",items:[{head:"Forecasting"},{tool:"long-position"},{tool:"short-position"},{tool:"forecast"}]},{id:"analysis",title:"Volume studies",items:[{head:"Volume studies"},{tool:"anchored-vwap"},{tool:"fixed-range-volume-profile"}]},{id:"measure",title:"Measurers",items:[{head:"Measurers"},{tool:"price-range"},{tool:"date-range"},{tool:"measure"}]},{sep:!0},{id:"text",title:"Text and notes",items:[{head:"Text and notes"},{tool:"text"},{tool:"note"},{tool:"callout"},{tool:"balloon"},{tool:"comment"},{tool:"price-note"},{tool:"table"},{head:"Brushes"},{tool:"brush"},{tool:"highlighter"}]}],ze=e=>null!==e&&M(e)?I(e).name:String(e??"Cursor"),Re="rail",Be="oac-rail-sprite";function Fe(e,t){if(void 0!==j[t])return ne(e,P(t),"tool");const o=oe(e,"span","oac-glyph oac-glyph--text",{"aria-hidden":"true"});return o.textContent=String(t).charAt(0).toUpperCase(),o}const Ue=(e,t)=>ne(e,E(t),"chrome");function He(e,t,o){const n={favorites:[],magnet:"off",stay:!1,last:{}};if(null===e||"object"!=typeof e)return n;const a=e;if(Array.isArray(a.favorites)&&(n.favorites=a.favorites.filter((e,t,o)=>"string"==typeof e&&M(e)&&o.indexOf(e)===t)),"string"==typeof a.magnet&&De.includes(a.magnet)&&(n.magnet=a.magnet),n.stay=!0===a.stay,null!==a.last&&"object"==typeof a.last){const e=a.last;for(const a of t)void 0!==a.id&&"string"==typeof e[a.id]&&o(a).includes(e[a.id])&&(n.last[a.id]=e[a.id])}return n}function Ve(e,t,o={}){const n=e.document,a=t=>ee(e,`schema.drawing.${t??"cursor"}.name`,{},ze(t)),i=e.draw,r=e.chart;!function(e){if(null!==e.getElementById(Be))return;const t=e.createElement("div");t.id=Be,t.hidden=!0,t.innerHTML=D(),(e.body??e.documentElement).appendChild(t)}(n);const s=void 0===o.tools?null:new Set(o.tools),l=e=>(e.items??[]).filter(e=>void 0!==e.tool&&M(e.tool)&&(null===s||s.has(e.tool))).map(e=>e.tool),c=e=>Ne.find(t=>t.id===e);let d=He(e.storage.get(Re),Ne,l);null===e.storage.get(Re)&&o.favorites&&(d.favorites=o.favorites.filter((e,t,o)=>M(e)&&o.indexOf(e)===t));let p=!1;const h=()=>{e.storage.set(Re,d)},u=e=>d.last[e.id??""]??l(e)[0]??null;let b=null;const g=t=>{if(null===t)return;null===b&&(b=z());const o=b[t];return void 0===o?void 0:e.keymap.format(o)},f=()=>{const e=i;if("function"==typeof e.selection)return e.selection().slice();const t=i.selected();return null===t?[]:[t]},m=e=>e.length>0&&e.every(e=>!0===i.get(e)?.locked),v=e=>e.length>0&&e.every(e=>!1===i.get(e)?.visible),w=e=>{const t=o.cursorTarget;t&&(null!==e&&void 0!==j[e]?t.style.setProperty("--oac-tool-cursor",N(e)):t.style.removeProperty("--oac-tool-cursor"))},y=()=>{i.setOptions({magnet:d.magnet})},x=()=>{i.setOptions({stayInDrawingMode:d.stay||p})},_=e=>{if(!De.includes(e))throw new Error(`openalgo-charts widget: unknown magnet mode "${String(e)}"`);d.magnet=e,h(),y(),K()},k=()=>{const t=De[(De.indexOf(d.magnet)+1)%De.length];return _(t),e.status(ee(e,"off"===t?"Magnet off":"weak"===t?"Magnet weak: snaps when O/H/L/C is within a few pixels":"Magnet strong: every anchor lands on the nearest O/H/L/C")),t},C=t=>{d.stay=!0===t,h(),x(),K(),e.status(d.stay?ee(e,"Tools stay armed after each drawing"):ee(e,"One drawing per pick"))},$=e=>{p=!0===e,x(),Q(i.activeTool())},S=e=>{i.setTool(e),Q(e)},A=t=>{$(!0),S(t),e.status(ee(e,"{name} stays armed until Escape",{name:a(t)}))};t.classList.add("oac-rail"),t.setAttribute("role","toolbar"),t.setAttribute("aria-orientation","vertical"),t.setAttribute("aria-label",ee(e,"Drawing tools"));const L=t=>{const o=oe(n,"button","oac-rail__btn"+(t.cls?" "+t.cls:""),{type:"button"});return o.tabIndex=-1,o.appendChild(t.glyphEl),e.tips.attach(o,t.tip,600),o.addEventListener("click",e=>{o.classList.contains("is-off")||t.onClick(e)}),t.onContext&&o.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation(),t.onContext?.(e)}),o},O=(e,t)=>{const o=e.querySelector(".oac-glyph");o?o.replaceWith(t):e.insertBefore(t,e.firstChild)},T=()=>oe(n,"div","oac-rail__sep",{role:"separator"}),P=t=>{const o=L({cls:"oac-rail__tool oac-rail__fav",glyphEl:Fe(n,t),tip:()=>({title:a(t),chord:g(t),sub:ee(e,"Pinned. Right-click to unpin"),side:"right"}),onClick:e=>{e.detail>=2&&!d.stay?A(t):($(!1),S(t))},onContext:()=>U(o,[{label:ee(e,"Unpin from rail"),icon:"star",onSelect:()=>Z(t,!1)}])});return o.dataset.tools=t,o},I=t=>{const o=l(t),r=L({cls:"oac-rail__tool oac-rail__group",glyphEl:Fe(n,u(t)??o[0]),tip:()=>({title:a(u(t)),chord:g(u(t)),sub:ee(e,d.stay?"{group}: chevron for the rest":"{group}: chevron for the rest. Double-click keeps it armed",{group:void 0===t.title?"":ee(e,`schema.rail.${t.id}.title`,{},t.title)}),side:"right"}),onClick:e=>{const o=e.target,n=null!==o&&"function"==typeof o.closest&&null!==o.closest(".oac-rail__chev");if(null===R||"true"!==r.getAttribute("aria-expanded"))if(n)F(t,r,!1);else{if(e.detail>=2&&!d.stay){const e=u(t);return void(null!==e&&A(e))}i.activeTool()!==u(t)?($(!1),S(u(t))):F(t,r,!1)}else B()},onContext:()=>F(t,r,!1)});r.dataset.tools=o.join(","),r.dataset.group=t.id??"",r.dataset.face=u(t)??"",r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false");const s=oe(n,"span","oac-rail__chev",{"aria-hidden":"true"});return s.innerHTML=E("chevron-right"),r.appendChild(s),r};let R=null;const B=()=>{R?.close()},F=(o,r,l)=>{B(),e.tips.hide();const c=oe(n,"div","oac-fly",{role:"menu","aria-label":void 0===o.title?ee(e,"Tools"):ee(e,`schema.rail.${o.id}.title`,{},o.title)}),p=i.activeTool(),u=[];for(const t of o.items??[]){if(void 0!==t.head){const a=oe(n,"div","oac-head");a.textContent=ee(e,`schema.rail.${o.id}.group.${t.head}`,{},t.head),c.appendChild(a);continue}const i=t.tool;if(void 0===i||!M(i)||null!==s&&!s.has(i))continue;const l=oe(n,"div","oac-fly__row",{role:"menuitemradio","aria-checked":String(p===i)});l.tabIndex=-1,l.dataset.tool=i,l.appendChild(Fe(n,i));const d=oe(n,"span","oac-fly__name");d.textContent=a(i),l.appendChild(d);const h=W(i),f=oe(n,"button","oac-fly__star",{type:"button","aria-pressed":String(h),"aria-label":ee(e,h?"Unpin from rail":"Pin to rail")});f.tabIndex=-1,f.innerHTML=E(h?"star-filled":"star"),l.appendChild(f);const m=oe(n,"kbd","oac-fly__chord");m.textContent=g(i)??"",l.appendChild(m);const v=()=>{const t=!W(i);Z(i,t),f.setAttribute("aria-pressed",String(t)),f.setAttribute("aria-label",ee(e,t?"Unpin from rail":"Pin to rail")),f.innerHTML=E(t?"star-filled":"star")};f.addEventListener("click",e=>{e.stopPropagation(),v()}),l.addEventListener("click",e=>{e.stopPropagation(),b(i)}),l.addEventListener("keydown",e=>{const t=e;"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),null!==t.target.closest(".oac-fly__star")?v():(b(i),r.focus()))}),u.push(l),c.appendChild(l)}const b=e=>{void 0!==o.id&&(d.last[o.id]=e,h()),B(),$(!1),S(e)};c.addEventListener("keydown",e=>{const t=e,o=t.target.closest(".oac-fly__row"),n=null===o?-1:u.indexOf(o),a=e=>{u[(e+u.length)%u.length]?.focus()};switch(t.key){case"ArrowDown":a(n+1);break;case"ArrowUp":a(n-1);break;case"Home":a(0);break;case"End":a(u.length-1);break;case"ArrowRight":o?.querySelector(".oac-fly__star")?.focus();break;case"ArrowLeft":o?.focus();break;default:return}t.preventDefault(),t.stopPropagation()});const f=u.find(e=>"true"===e.getAttribute("aria-checked"))??u[0]??null,m=e.openOverlay(c,{anchor:r,placement:"beside",edge:t,initialFocus:l?f:c,onClose:()=>{null!==R&&R.el===c&&(R=null)}});R={el:c,close:m}},U=(o,a)=>{e.tips.hide();const i=oe(n,"div","oac-menu",{role:"menu"});let r=()=>{};for(const e of a){const t=oe(n,"button","oac-menu__row"+(e.danger?" is-danger":""),{type:"button",role:"menuitem","aria-disabled":String(!0===e.disabled)});t.appendChild(void 0!==e.tool?Fe(n,e.tool):void 0!==e.icon?Ue(n,e.icon):oe(n,"span","oac-glyph"));const o=oe(n,"span","oac-menu__label");o.textContent=e.label,t.appendChild(o),t.addEventListener("click",t=>{t.stopPropagation(),e.disabled||(r(),e.onSelect())}),i.appendChild(t)}r=e.openOverlay(i,{anchor:o,placement:"beside",edge:t})},H={},V=(e,t)=>{void 0!==e&&(e.classList.toggle("is-on",!0===t.on),e.classList.toggle("is-off",!0===t.off),e.setAttribute("aria-disabled",!0===t.off?"true":"false"),void 0!==t.pressed&&e.setAttribute("aria-pressed",String(t.pressed)),void 0!==t.glyph&&e.dataset.glyph!==t.glyph&&(e.dataset.glyph=t.glyph,O(e,Ue(n,t.glyph))))},K=()=>{if(void 0===H.magnet)return;V(H.magnet,{on:"strong"===d.magnet,pressed:"off"!==d.magnet}),H.magnet.classList.toggle("is-weak","weak"===d.magnet),H.magnet.dataset.mode=d.magnet,V(H.stay,{on:d.stay,pressed:d.stay});const t=f(),o=0===t.length,n=!o&&m(t),a=!o&&v(t);V(H.lock,{off:o,on:n,pressed:n,glyph:n?"unlock":"lock"}),V(H.eye,{off:o,on:a,pressed:a,glyph:a?"eye-off":"eye"}),V(H.trash,{off:o}),V(H.undo,{off:!i.canUndo()}),V(H.redo,{off:!i.canRedo()});for(const t of Object.values(H))e.tips.refreshLabel(t)};let q=null;const W=e=>d.favorites.includes(e),G=()=>{if(null===q)return;q.textContent="";const e=d.favorites.filter(e=>M(e));if(0!==e.length){q.appendChild(T());for(const t of e)q.appendChild(P(t))}},Z=(e,t=!W(e))=>{if(!M(e))return;const o=W(e);t&&!o&&d.favorites.push(e),!t&&o&&d.favorites.splice(d.favorites.indexOf(e),1),h(),G(),Q(i.activeTool())},Y=()=>Array.from(t.querySelectorAll(".oac-rail__btn")),J=e=>{for(const t of Y())t.tabIndex=t===e?0:-1},X=()=>{t.textContent="",t.appendChild((()=>{const t=L({cls:"oac-rail__tool",glyphEl:Fe(n,"cursor"),tip:()=>({title:ee(e,"Cursor"),chord:"Esc",side:"right"}),onClick:()=>{$(!1),S(null)}});return t.dataset.tools="",t})()),q=oe(n,"div","oac-rail__favs"),t.appendChild(q),G(),t.appendChild(T());for(const e of Ne)e.sep?t.appendChild(T()):l(e).length>0&&t.appendChild(I(e));t.appendChild((()=>{const t=oe(n,"div","oac-rail__ctl");return H.magnet=L({cls:"oac-rail__btn--magnet",glyphEl:Fe(n,"magnet"),tip:()=>({title:ee(e,"Magnet: {mode}",{mode:ee(e,`schema.magnet.${d.magnet}`,{},d.magnet)}),sub:"off"===d.magnet?ee(e,"Click for weak: snaps when O/H/L/C is within a few pixels"):"weak"===d.magnet?ee(e,"Click for strong: every anchor lands on the nearest O/H/L/C"):ee(e,"Click to switch the magnet off"),side:"right"}),onClick:()=>{k()}}),t.appendChild(H.magnet),H.stay=L({cls:"oac-rail__btn--chrome",glyphEl:Ue(n,"link"),tip:()=>({title:ee(e,"Keep tool armed"),sub:d.stay?ee(e,"On: the tool stays armed after each drawing"):ee(e,"Off: one drawing per pick"),side:"right"}),onClick:()=>C(!d.stay)}),t.appendChild(H.stay),t.appendChild(T()),H.lock=L({cls:"oac-rail__btn--chrome",glyphEl:Ue(n,"lock"),tip:()=>{const t=f();return 0===t.length?{title:ee(e,"Lock drawing"),sub:ee(e,"Select a drawing first"),side:"right"}:{title:m(t)?ee(e,"Unlock drawing"):ee(e,"Lock drawing"),side:"right"}},onClick:()=>{const e=f(),t=!m(e);for(const o of e)i.update(o,{locked:t});K()}}),t.appendChild(H.lock),H.eye=L({cls:"oac-rail__btn--chrome",glyphEl:Ue(n,"eye"),tip:()=>{const t=f();return 0===t.length?{title:ee(e,"Hide drawing"),sub:ee(e,"Select a drawing first"),side:"right"}:v(t)?{title:ee(e,"Show drawing"),side:"right"}:{title:ee(e,"Hide drawing"),sub:ee(e,"Stays selected, so the eye brings it back"),side:"right"}},onClick:()=>{const e=f(),t=v(e);for(const o of e)i.update(o,{visible:t});K()}}),t.appendChild(H.eye),H.trash=L({cls:"oac-rail__btn--chrome oac-rail__btn--danger",glyphEl:Ue(n,"trash"),tip:()=>{const t=f();return t.length>0?{title:t.length>1?ee(e,"Delete {count} drawings",{count:t.length}):ee(e,"Delete drawing"),chord:"Del",sub:ee(e,"Right-click to remove all"),side:"right"}:{title:ee(e,"Delete drawing"),chord:"Del",sub:ee(e,"Select one first. Right-click to remove all"),side:"right"}},onClick:()=>{for(const e of f())i.remove(e);K()},onContext:()=>{const t=i.drawings().length;U(H.trash,[{label:ee(e,"Select all ({count})",{count:t}),icon:"cursor",disabled:0===t,onSelect:()=>{i.select(i.drawings().map(e=>e.id)),K()}},{label:ee(e,"Remove all drawings ({count})",{count:t}),icon:"trash",danger:!0,disabled:0===t,onSelect:()=>{i.clear(),K(),e.status(t>0?ee(e,1===t?"Removed {count} drawing":"Removed {count} drawings",{count:t}):ee(e,"No drawings to remove"))}}])}}),t.appendChild(H.trash),t.appendChild(T()),H.undo=L({cls:"oac-rail__btn--chrome",glyphEl:Ue(n,"undo"),tip:()=>({title:ee(e,"Undo"),chord:e.keymap.format("Mod+Z"),side:"right"}),onClick:()=>{i.undo(),K()}}),t.appendChild(H.undo),H.redo=L({cls:"oac-rail__btn--chrome",glyphEl:Ue(n,"redo"),tip:()=>({title:ee(e,"Redo"),chord:e.keymap.format("Mod+Y"),side:"right"}),onClick:()=>{i.redo(),K()}}),t.appendChild(H.redo),t})()),Q(i.activeTool())},Q=o=>{const a=o??null;let i=null;for(const o of Array.from(t.querySelectorAll(".oac-rail__tool"))){const t=(o.dataset.tools??"").split(",").filter(Boolean),r=null===a?0===t.length:t.includes(a);o.classList.toggle("is-on",r),o.classList.toggle("is-held",r&&p&&t.length>0),o.setAttribute("aria-pressed",String(r)),r&&null===i&&(i=o),r&&o.dataset.group&&t.length>0&&null!==a&&(d.last[o.dataset.group]!==a&&(d.last[o.dataset.group]=a,h()),o.dataset.face!==a&&(o.dataset.face=a,O(o,Fe(n,a)))),e.tips.refreshLabel(o)}const r=n.activeElement;null===i||null!==r&&t.contains(r)||J(i),w(a),K()},te=()=>{const e=n.activeElement;return null!==e&&t.contains(e)?e.closest(".oac-rail__btn"):null},ne=e=>{const t=Y();if(0===t.length)return;const o=t[(e%t.length+t.length)%t.length];J(o),o.focus()},ae=[],ie=(t,o,n)=>{ae.push(e.keymap.register(t,o,"rail",{label:n,group:"Tool rail"}))};ie("ArrowDown",()=>{ne(Y().indexOf(te())+1)},"Next tool"),ie("ArrowUp",()=>{ne(Y().indexOf(te())-1)},"Previous tool"),ie("Home",()=>{ne(0)},"First tool"),ie("End",()=>{ne(Y().length-1)},"Last tool"),ie("ArrowRight",()=>{const e=te(),t=e?.dataset.group?c(e.dataset.group):void 0;return null!==e&&void 0!==t&&(F(t,e,!0),!0)},"Open the group"),ie("Escape",()=>{const t=null!==R;B(),e.tips.hide();const n=o.cursorTarget;return void 0!==n&&"function"==typeof n.focus?n.focus():te()?.blur(),t},"Back to the chart");const re=e=>{const t=e.target,o=null!==t&&"function"==typeof t.closest?t.closest(".oac-rail__btn"):null;null!==o&&J(o)};t.addEventListener("focusin",re);const se=[];se.push(r.on("draw:tool",e=>{Q(e.tool)}));for(const e of["draw:select","drawing:select","drawing:change","draw:add","draw:remove","draw:update","draw:paste","draw:cut"])se.push(r.on(e,K));return y(),x(),X(),{el:t,sync:Q,refresh:K,prefs:()=>({favorites:d.favorites.slice(),magnet:d.magnet,stay:d.stay,last:{...d.last}}),restorePrefs:e=>{d=He(e,Ne,l),h(),y(),x(),X()},magnetMode:()=>d.magnet,setMagnetMode:_,cycleMagnet:k,stayMode:()=>d.stay,setStayMode:C,favorites:()=>d.favorites.slice(),isFavorite:W,toggleFavorite:Z,setDrawLock:$,drawLocked:()=>p,openGroup:(e,o=!1)=>{const n=c(e),a=t.querySelector(`.oac-rail__group[data-group="${e}"]`);void 0!==n&&null!==a&&F(n,a,o)},closeFlyout:B,flyoutOpen:()=>null!==R,destroy:()=>{B();for(const e of se)e();for(const e of ae)e();t.removeEventListener("focusin",re),w(null),t.textContent=""}}}const Ke=2;function qe(e){const t=e.panes()[0];if(void 0===t)return 2;const o=t.priceScale.precision();return Number.isFinite(o)?Math.max(2,Math.min(8,Math.round(o))):2}function We(e,t,o){let n=o.get(t);return void 0===n&&(n=new Intl.NumberFormat(e,{minimumFractionDigits:t,maximumFractionDigits:t}),o.set(t,n)),n}function Ge(t,o,n={}){const a=t.document,i=t.chart,r=n.locale??t.locale;o.classList.add("oac-statusline"),o.setAttribute("role","status"),o.setAttribute("aria-live","polite");const s=oe(a,"span","oac-statusline__title"),l=oe(a,"span","oac-statusline__sym"),c=oe(a,"span","oac-statusline__iv");s.appendChild(l),s.appendChild(c),o.appendChild(s);const d=(e,t)=>{const n=oe(a,"span","oac-statusline__field "+t),i=oe(a,"i");i.textContent=e;const r=oe(a,"b");return n.appendChild(i),n.appendChild(r),n.hidden=!0,o.appendChild(n),{el:n,val:r}},p=d(ee(t,"O"),"oac-statusline__o"),h=d(ee(t,"H"),"oac-statusline__h"),u=d(ee(t,"L"),"oac-statusline__l"),b=d(ee(t,"C"),"oac-statusline__c"),g=d("","oac-statusline__chg"),f=d(ee(t,"Vol"),"oac-statusline__vol"),m=d(ee(t,"OI"),"oac-statusline__oi"),v=oe(a,"span","oac-statusline__time");o.appendChild(v);const w=oe(a,"span","oac-statusline__msg");o.appendChild(w);const y=oe(a,"span","oac-statusline__tz");o.appendChild(y);const x=new Map,_=new Intl.NumberFormat(r,{minimumFractionDigits:2,maximumFractionDigits:2}),k=new Intl.NumberFormat(r,{notation:"compact",maximumFractionDigits:2});let C=null,$=null;const S=(e,t)=>{e.textContent!==t&&(e.textContent=t)},A=(e,t)=>{e.hidden===t&&(e.hidden=!t)},L=()=>{const t=i.statusLineOptions();A(s,!1!==t.title);const o=!1!==t.chartValues&&null!==C;for(const e of[p,h,u,b])A(e.el,o);const n=qe(i);if(o&&null!==C){const e=We(r,n,x);S(p.val,e.format(C.open)),S(h.val,e.format(C.high)),S(u.val,e.format(C.low)),S(b.val,e.format(C.close))}const a=!1!==t.barChange&&null!==C;if(A(g.el,a),a&&null!==C){const e=C.close-C.open,t=0!==C.open?e/C.open*100:0,o=e>0?"+":"";S(g.val,`${o}${We(r,n,x).format(e)} (${o}${_.format(t)}%)`),g.el.classList.toggle("is-up",e>0),g.el.classList.toggle("is-down",e<0)}const l=!1!==t.volume&&null!==C&&"number"==typeof C.volume;A(f.el,l),l&&null!==C&&S(f.val,k.format(C.volume));const c=!0===t.openInterest&&!1!==i.hasOpenInterest&&void 0!==C?.oi&&Number.isFinite(C.oi);A(m.el,c),c&&void 0!==C?.oi&&S(m.val,k.format(C.oi)),S(v,null!==$&&null!==C?e($,i.timezone()):""),S(y,i.timezone())},O=()=>{const e=i.primarySeries()?.getData()??[],t=e[e.length-1];return void 0===t?{bar:null,time:null}:{bar:t,time:t.time}},T=(e,t)=>{e===C&&t===$||(C=e,$=t,L())},E=i.on("crosshair:move",e=>{const t=e;if(null!==t.bar&&void 0!==t.bar)return void T(t.bar,t.time);const o=O();T(o.bar,o.time)}),M=i.on("data:context",L),j=i.on("resize",()=>{if(null===C){const e=O();T(e.bar,e.time)}}),P={el:o,setMessage:(e,t="info")=>{S(w,e),w.classList.toggle("is-error","error"===t)},setSymbol:(e,t,o)=>{S(l,t?`${t}:${e}`:e),S(c,o)},setBar:T,refresh:()=>{if(null===C){const e=O();C=e.bar,$=e.time}L()},destroy:()=>{E(),M(),j(),o.textContent=""}};return L(),P}const Ze=150,Ye={candlestick:"Candles","hollow-candle":"Hollow candles",bar:"Bars","high-low":"High-low","volume-candle":"Volume candles",line:"Line","line-markers":"Line with markers",step:"Step line",area:"Area","hlc-area":"HLC area",baseline:"Baseline","point-figure":"Point and figure",kagi:"Kagi"};function Je(e){const t=Ye[e];return void 0!==t?t:e.replace(/[-_]+/g," ").replace(/^\w/,e=>e.toUpperCase())}function Xe(){return t().filter(e=>{try{return o(e).isPriceSeries}catch{return!1}})}function Qe(e){const t=/^(\d*)\s*([smhdwSMHDW])$/.exec(e.trim());if(null===t)return e.toUpperCase();const o=""===t[1]||"1"===t[1]?"":t[1],n=t[2];return"m"===n?`${""===t[1]?"1":t[1]}m`:"s"===n?`${""===t[1]?"1":t[1]}s`:"h"===n||"H"===n?`${""===t[1]?"1":t[1]}h`:o+n.toUpperCase()}function et(e,t,o,n={}){const a=e.document,i=oe(a,"div","oac-menu",{role:"menu"});n.ariaLabel&&i.setAttribute("aria-label",n.ariaLabel);let r=null;if(n.find){const e=oe(a,"div","oac-menu__find");r=oe(a,"input",void 0,{type:"text",placeholder:n.find,"aria-label":n.find}),e.appendChild(r),i.appendChild(e)}const s=oe(a,"div","oac-menu__body");i.appendChild(s);let l=()=>{};const c=t=>{const n=t.trim().toLowerCase();s.textContent="";let i=0,r=null;for(const e of o){if("string"==typeof e){r=e;continue}if(""!==n&&!e.label.toLowerCase().includes(n)&&!(e.sub??"").toLowerCase().includes(n))continue;if(null!==r){const e=oe(a,"div","oac-head");e.textContent=r,s.appendChild(e),r=null}const t=oe(a,"button","oac-menu__row"+(e.danger?" is-danger":""),{type:"button",role:"menuitemradio","aria-checked":String(!0===e.on),"aria-disabled":String(!0===e.disabled)}),o=oe(a,"span","oac-menu__label");if(o.textContent=e.label,t.appendChild(o),e.sub){const o=oe(a,"span","oac-menu__sub");o.textContent=e.sub,t.appendChild(o)}if(e.key){const o=oe(a,"kbd","oac-menu__key");o.textContent=e.key,t.appendChild(o)}t.addEventListener("click",t=>{t.stopPropagation(),e.disabled||(l(),e.onSelect())}),s.appendChild(t),i++}if(0===i){const t=oe(a,"div","oac-menu__empty");t.textContent=ee(e,"No match"),s.appendChild(t)}};if(c(""),null!==r){const e=r;e.addEventListener("input",()=>c(e.value)),e.addEventListener("keydown",e=>{if("Enter"!==e.key)return;const t=s.querySelectorAll(".oac-menu__row");1===t.length&&t[0].click()})}return i.addEventListener("keydown",e=>{const t=e,o=Array.from(s.querySelectorAll(".oac-menu__row")),n=o.indexOf(a.activeElement);"ArrowDown"===t.key?(o[(n+1)%o.length]?.focus(),t.preventDefault(),t.stopPropagation()):"ArrowUp"===t.key&&(o[(n-1+o.length)%o.length]?.focus(),t.preventDefault(),t.stopPropagation())}),l=e.openOverlay(i,{anchor:t,placement:"below",initialFocus:r??s.querySelector('.oac-menu__row[aria-checked="true"]')??void 0}),l}function tt(e,t={}){const o=e.brandingOptions?.();if(!o||"string"!=typeof o.href||!/^https?:\/\//i.test(o.href))return null;const n="string"==typeof o.label&&""!==o.label.trim()?o.label.trim():ee(t,"Chart branding");return{href:o.href,label:n}}function ot(e,t,o,n){const a=globalThis;if(void 0===a.Blob||void 0===a.URL||"function"!=typeof a.URL.createObjectURL)return!1;const i=e.createElement("a"),r=a.URL.createObjectURL(new a.Blob([o],{type:n}));try{i.href=r,i.download=t,(e.body??e.documentElement).appendChild(i),i.click()}finally{i.remove(),setTimeout(()=>a.URL?.revokeObjectURL(r),0)}return!0}function nt(e,t,o=new Date){const n=o.toISOString().slice(0,16).replace(/[:T]/g,"-");return`${(e||"chart").replace(/[^A-Za-z0-9._-]/g,"")}-${t||"chart"}-${n}`}function at(e,t,o){const a=e.document;t.classList.add("oac-topbar"),t.setAttribute("role","toolbar"),t.setAttribute("aria-label",ee(e,"Chart toolbar"));const i=(e,t="")=>oe(a,"button","oac-btn"+(t?" "+t:""),{type:"button","aria-label":e}),r=()=>oe(a,"span","oac-sep",{role:"separator"}),s=(e,t)=>{e.classList.toggle("is-off",t),e.setAttribute("aria-disabled",String(t))},l=oe(a,"div","oac-sym");l.appendChild(ne(a,E("search"),"chrome"));const c=oe(a,"input","oac-sym__input",{type:"text","aria-label":ee(e,"Symbol"),placeholder:ee(e,"Symbol"),autocomplete:"off",spellcheck:"false"});l.appendChild(c);const d=oe(a,"span","oac-sym__ex");l.appendChild(d),t.appendChild(l),t.appendChild(r());let p=null,h=0,u=0;const b=()=>{p?.close(),p=null},g=(e,t)=>{b();const n=e.trim().toUpperCase();""!==n?(o.onSymbol(n,t),c.blur()):T()},f=()=>null===p?-1:p.rows.findIndex(e=>e.classList.contains("is-active")),m=e=>{if(null===p)return;const t=p.rows.length,o=(e%t+t)%t;p.rows.forEach((e,t)=>e.classList.toggle("is-active",t===o))},v=t=>{if(!o.search)return;const n=++u;Promise.resolve(o.search(t)).then(t=>{n===u&&a.activeElement===c&&(t=>{if(b(),0===t.length)return;const o=oe(a,"div","oac-menu oac-sym__results",{role:"listbox","aria-label":ee(e,"Symbols")}),n=[];t.forEach((e,t)=>{const i=oe(a,"button","oac-menu__row"+(0===t?" is-active":""),{type:"button",role:"option"}),r=oe(a,"span","oac-menu__label");if(r.textContent=e.exchange?`${e.exchange}:${e.symbol}`:e.symbol,i.appendChild(r),e.name){const t=oe(a,"span","oac-menu__sub");t.textContent=e.name,i.appendChild(t)}i.addEventListener("click",t=>{t.stopPropagation(),g(e.symbol,e.exchange)}),n.push(i),o.appendChild(i)});const i=e.openOverlay(o,{anchor:l,placement:"below",initialFocus:null,onClose:()=>{null!==p&&p.rows===n&&(p=null)}});p={close:i,rows:n,matches:t}})(t)}).catch(()=>{b()})};c.addEventListener("input",()=>{if(!o.search)return;0!==h&&clearTimeout(h);const e=c.value.trim();""!==e?h=setTimeout(()=>{h=0,v(e)},150):b()}),c.addEventListener("keydown",e=>{const t=e;if("Enter"===t.key){t.preventDefault();const e=f();if(null!==p&&e>=0){const t=p.matches[e];return void g(t.symbol,t.exchange)}g(c.value)}else"ArrowDown"===t.key&&null!==p?(t.preventDefault(),m(f()+1)):"ArrowUp"===t.key&&null!==p?(t.preventDefault(),m(f()-1)):"Escape"===t.key&&null===p&&(T(),c.blur())}),c.addEventListener("focus",()=>{c.select()}),c.addEventListener("blur",()=>{null===p&&T()});const w=oe(a,"div","oac-pills",{role:"radiogroup","aria-label":ee(e,"Interval")}),y=new Map;for(const t of o.intervals){const n=oe(a,"button",void 0,{type:"button",role:"radio","aria-pressed":"false","aria-label":ee(e,"Interval {code}",{code:t})});n.textContent=Qe(t),n.dataset.interval=t,n.addEventListener("click",()=>o.onInterval(t)),w.appendChild(n),y.set(t,n)}t.appendChild(w),t.appendChild(r());const x=i(ee(e,"Chart type"),"oac-topbar__type"),_=oe(a,"span");x.appendChild(_),x.appendChild((()=>{const e=oe(a,"span","oac-chev",{"aria-hidden":"true"});return e.innerHTML=E("chevron-down"),e})()),x.setAttribute("aria-haspopup","menu"),x.addEventListener("click",()=>{const t=o.state().chartType;et(e,x,Xe().map(n=>({label:ee(e,`schema.chartType.${n}`,{},Je(n)),on:n===t,onSelect:()=>o.onChartType(n)})),{ariaLabel:ee(e,"Chart type")})}),t.appendChild(x);let k=null;if(!1!==o.indicators){k=i(ee(e,"Indicators")),k.appendChild(ne(a,E("plus"),"chrome"));const n=oe(a,"span");n.textContent=ee(e,"Indicators"),k.appendChild(n),k.addEventListener("click",()=>{null!==k&&k.classList.contains("is-off")||null!==k&&o.onIndicators(k)}),t.appendChild(k)}t.appendChild(oe(a,"span","oac-topbar__spacer"));const C=oe(a,"span","oac-topbar__branding-slot");let $=null;if(t.appendChild(C),o.onObjects){const n=i(ee(e,"Objects"),"oac-topbar__objects");n.textContent=ee(e,"Objects"),n.setAttribute("aria-haspopup","dialog"),n.addEventListener("click",()=>{o.onObjects?.(n)}),t.appendChild(n)}if(o.onAlerts){const n=i(ee(e,"Alerts"),"oac-topbar__alerts");n.textContent=ee(e,"Alerts"),n.setAttribute("aria-haspopup","dialog"),n.addEventListener("click",()=>{o.onAlerts?.(n)}),t.appendChild(n)}const S=i(ee(e,"Capture chart"),"oac-btn--icon");S.appendChild(ne(a,E("camera"),"chrome")),S.setAttribute("aria-haspopup","menu"),e.tips.attach(S,{title:ee(e,"Capture"),sub:ee(e,"PNG, SVG, CSV or the clipboard"),side:"bottom"}),S.addEventListener("click",()=>{const t={...o.state()},i=()=>!e.chart.isDestroyed&&!1!==o.dataAvailable?.()&&e.chart.primaryBars().length>0,r=globalThis,s=void 0!==r.navigator?.clipboard?.write&&void 0!==r.ClipboardItem;et(e,S,[{label:ee(e,"Download PNG"),onSelect:()=>{e.chart.downloadScreenshot(nt(t.symbol,t.interval)+".png"),e.status(ee(e,"Saved a PNG of the chart"))}},{label:ee(e,"Download SVG"),sub:ee(e,"text stays text"),onSelect:()=>{const o=ot(a,nt(t.symbol,t.interval)+".svg",e.chart.exportSVG(),"image/svg+xml");e.status(ee(e,o?"Saved an SVG of the chart":"This runtime cannot save files"),o?"info":"error")}},{label:ee(e,"Copy image"),sub:ee(e,s?"paste it anywhere":"needs https or localhost"),disabled:!s,onSelect:()=>{e.chart.takeScreenshot().toBlob(t=>{if(null===t)return void e.status(ee(e,"The canvas produced no image"),"error");const o=globalThis.ClipboardItem;globalThis.navigator.clipboard.write([new o({"image/png":t})]).then(()=>e.status(ee(e,"Chart copied")),t=>e.status(ee(e,"Copy failed: {error}",{error:String(t?.message??t)}),"error"))},"image/png")}},{label:ee(e,"Download chart data (CSV)"),disabled:!i(),onSelect:()=>{try{const r=o.state();if(r.symbol!==t.symbol||r.exchange!==t.exchange||r.interval!==t.interval||r.chartType!==t.chartType)throw new Error(ee(e,"The chart changed; reopen Capture for its current source"));if(!i())throw new Error(ee(e,"Wait for this chart to finish loading its data"));const s=ot(a,nt(t.symbol,t.interval)+".csv",n(e.chart),"text/csv;charset=utf-8");e.status(ee(e,s?"Chart data download started":"This runtime cannot save files"),s?"info":"error")}catch(t){e.status(ee(e,"Data export failed: {error}",{error:String(t?.message??t)}),"error")}}}],{ariaLabel:ee(e,"Capture")})}),t.appendChild(S);const A=i(ee(e,"Chart settings"),"oac-btn--icon");A.appendChild(ne(a,E("settings"),"chrome")),e.tips.attach(A,()=>({title:ee(e,"Chart settings"),sub:o.settingsAvailable()?void 0:ee(e,"The settings dialog is not in this build"),side:"bottom"})),A.addEventListener("click",()=>{A.classList.contains("is-off")||o.onSettings(A)}),t.appendChild(A);const L=i(ee(e,"Theme"),"oac-topbar__theme"),O=oe(a,"span");L.appendChild(O),e.tips.attach(L,()=>({title:"dark"===o.state().theme?ee(e,"Switch to the light theme"):ee(e,"Switch to the dark theme"),side:"bottom"})),L.addEventListener("click",()=>o.onTheme("dark"===o.state().theme?"light":"dark")),t.appendChild(L),null!==k&&e.tips.attach(k,()=>({title:ee(e,"Indicators"),sub:o.indicatorsAvailable()?ee(e,"Add a study to the chart"):ee(e,"The indicator picker is not in this build"),side:"bottom"}));const T=()=>{const t=o.state();a.activeElement!==c&&(c.value=t.symbol),d.textContent=t.exchange,d.hidden=""===t.exchange;for(const[e,o]of y){const n=e===t.interval;o.setAttribute("aria-pressed",String(n)),o.setAttribute("aria-checked",String(n))}_.textContent=ee(e,`schema.chartType.${t.chartType}`,{},Je(t.chartType)),s(A,!o.settingsAvailable()),null!==k&&s(k,!o.indicatorsAvailable()),L.dataset.theme=t.theme,O.textContent="dark"===t.theme?ee(e,"Light"):ee(e,"Dark"),e.tips.refreshLabel(L),e.tips.refreshLabel(A),null!==k&&e.tips.refreshLabel(k);const n=tt(e.chart,e);null===n?($?.remove(),$=null):(null===$&&($=oe(a,"a","oac-topbar__branding",{target:"_blank",rel:"noopener noreferrer"}),C.appendChild($)),$.setAttribute("href",n.href),$.textContent=n.label,$.setAttribute("aria-label",n.label))},M=e.chart.on("branding:changed",T);return T(),{el:t,refresh:T,focusSymbol:()=>{c.focus()},destroy:()=>{M(),0!==h&&clearTimeout(h),b(),t.textContent=""}}}const it={info:4e3,success:3500,error:0},rt=5,st=160;function lt(e,t=e.ownerDocument,o={}){e.classList.add("oac-toasts"),e.setAttribute("role","status"),e.setAttribute("aria-live","polite");const n=new Set;return{toast:(a,i="info",r={})=>{const s=i in it?i:"info",l=t.createElement("div");l.className="oac-toast oac-toast--"+s;const c=t.createElement("span");c.className="oac-toast__msg",c.textContent=a;const d=t.createElement("button");d.type="button",d.className="oac-toast__x",d.setAttribute("aria-label",ee(o,"Dismiss")),d.innerHTML=E("close"),l.appendChild(c),l.appendChild(d);const p=void 0!==r.ms?r.ms:it[s];let h=0,u=!1;const b={node:l,dismiss:()=>{u||(u=!0,0!==h&&clearTimeout(h),n.delete(b),l.classList.add("is-out"),setTimeout(()=>l.remove(),160))}},g=()=>{p>0&&(h=setTimeout(b.dismiss,p))};for(d.addEventListener("click",b.dismiss),l.addEventListener("pointerenter",()=>{0!==h&&clearTimeout(h),h=0}),l.addEventListener("pointerleave",g),e.appendChild(l),n.add(b);n.size>5;){const e=n.values().next().value;n.delete(e),e.node.remove()}return g(),b},clear:()=>{for(const e of Array.from(n))e.dismiss()},count:()=>n.size,destroy:()=>{for(const e of Array.from(n))e.node.remove();n.clear(),e.remove()}}}const ct="--oac-",dt=e=>e<0?0:e>1?1:e;function pt(e){const t=e.trim(),o=/^#([0-9a-f]{3,8})$/i.exec(t);if(null!==o){const e=o[1];if(3===e.length||4===e.length){return pt("#"+e.split("").map(e=>e+e).join(""))}if(6!==e.length&&8!==e.length)return null;return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16),a:8===e.length?parseInt(e.slice(6,8),16)/255:1}}const n=/^rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i.exec(t);if(null!==n){let e=1;return void 0!==n[4]&&(e=n[4].endsWith("%")?Number(n[4].slice(0,-1))/100:Number(n[4])),{r:Number(n[1]),g:Number(n[2]),b:Number(n[3]),a:dt(e)}}return null}const ht=e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0");function ut(e){return e.a>=1?`#${ht(e.r)}${ht(e.g)}${ht(e.b)}`:`rgba(${Math.round(e.r)},${Math.round(e.g)},${Math.round(e.b)},${Math.round(1e3*e.a)/1e3})`}function bt(e){const t=pt(e);if(null===t)return.5;const o=e=>{const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)};return.2126*o(t.r)+.7152*o(t.g)+.0722*o(t.b)}function gt(e){return bt(e.background)<.35?"dark":"light"}function ft(e,t,o){const n=pt(e),a=pt(t);if(null===n||null===a)return e;const i=dt(o);return ut({r:n.r+(a.r-n.r)*i,g:n.g+(a.g-n.g)*i,b:n.b+(a.b-n.b)*i,a:n.a+(a.a-n.a)*i})}function mt(e,t){const o=pt(e);return null===o?e:ut({...o,a:dt(t)})}const vt='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',wt="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",yt=42,xt=40,_t=24;function kt(e,t=gt(e)){const o="dark"===t,n=e.background,a=o?"#ffffff":"#0c1120",i=e=>ft(n,a,e),r=e.lineColor,s=ft(e.axisText,a,o?.55:.6),l={bg:n,panel:i(o?.035:.02),"panel-2":i(o?.02:.045),elev:i(o?.07:.06),"elev-2":i(o?.11:.1),"elev-3":i(o?.18:.16),bd:e.axisLine,"bd-soft":e.paneSeparator,"bd-hover":ft(e.axisLine,a,.25),tx:s,"tx-strong":ft(s,a,.5),mut:e.axisText,faint:ft(e.axisText,n,.4),acc:r,"acc-2":ft(r,a,o?.2:.1),"on-bg":mt(r,.16),"on-bd":ft(r,n,.45),ring:r,"ring-soft":mt(r,.2),buy:e.upColor,sell:e.downColor,amber:o?"#e6b53c":"#b8860b",danger:ft(e.downColor,a,o?.3:.1),scrim:o?"rgba(6,8,12,0.55)":"rgba(24,30,40,0.38)",shadow:o?"0 14px 40px rgba(0,0,0,0.55)":"0 14px 40px rgba(24,32,48,0.16)","sb-thumb":i(o?.16:.2),"sb-thumb-hover":i(o?.24:.3),font:vt,mono:wt,fs:"12.5px",radius:"7px","rail-w":"42px","topbar-h":"40px","status-h":"24px","ctl-h":"28px"},c={};for(const[e,t]of Object.entries(l))c[ct+e]=t;return c}function Ct(e,t){for(const[o,n]of Object.entries(t))e.style.setProperty(o,n)}const $t=e=>`var(${ct}${e})`,St="oac-widget-css",At=e=>`var(--oac-${e})`,Lt=`\n.oac-widget { position: relative; display: grid; grid-template-rows: auto 1fr auto; width: 100%; height: 100%;\n min-height: 0; min-width: 0; background: ${At("bg")}; color: ${At("tx")}; font: ${At("fs")}/1.35 ${At("font")};\n -webkit-font-smoothing: antialiased; overflow: hidden; }\n.oac-widget, .oac-widget * { box-sizing: border-box; }\n.oac-widget.oac-alert-host { position: absolute; inset: 0; display: block; background: transparent; pointer-events: none; z-index: 40; }\n.oac-widget[data-theme="dark"] { color-scheme: dark; }\n.oac-widget[data-theme="light"] { color-scheme: light; }\n.oac-widget button, .oac-widget input, .oac-widget select, .oac-widget textarea { font: inherit; color: inherit; }\n.oac-widget button { cursor: pointer; }\n.oac-widget kbd { font: 11px/1 ${At("mono")}; font-variant-numeric: tabular-nums; }\n.oac-widget [hidden] { display: none !important; }\n\n/* Scrollbars: a thumb one step lighter than its panel, and no visible track. */\n.oac-widget * { scrollbar-width: thin; scrollbar-color: ${At("sb-thumb")} transparent; }\n.oac-widget ::-webkit-scrollbar { width: 10px; height: 10px; }\n.oac-widget ::-webkit-scrollbar-track { background: transparent; }\n.oac-widget ::-webkit-scrollbar-thumb { background: ${At("sb-thumb")}; border: 2px solid transparent;\n background-clip: padding-box; border-radius: 999px; }\n.oac-widget ::-webkit-scrollbar-thumb:hover { background: ${At("sb-thumb-hover")}; background-clip: padding-box; }\n.oac-widget ::-webkit-scrollbar-corner { background: transparent; }\n\n/* Focus: one ring, keyboard only. Text fields glow on the border instead. */\n.oac-widget :focus-visible { outline: 2px solid ${At("ring")}; outline-offset: 2px; }\n.oac-widget :focus:not(:focus-visible) { outline: none; }\n.oac-widget input:not([type=checkbox]):not([type=color]):not([type=range]):focus-visible,\n.oac-widget select:focus-visible, .oac-widget textarea:focus-visible {\n outline: none; border-color: ${At("acc")}; box-shadow: 0 0 0 3px ${At("ring-soft")}; }\n.oac-widget .oac-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;\n overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }\n\n/* Form controls: nothing left to the browser on a themed panel. */\n.oac-widget input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; margin: 0;\n width: 15px; height: 15px; border: 1px solid ${At("bd")}; border-radius: 4px; background: ${At("elev")};\n cursor: pointer; display: inline-grid; place-content: center; transition: background .12s, border-color .12s; }\n.oac-widget input[type=checkbox]:hover { border-color: ${At("bd-hover")}; }\n.oac-widget input[type=checkbox]:checked { background: ${At("acc")}; border-color: ${At("acc")}; }\n.oac-widget input[type=checkbox]:checked::after { content: ''; width: 4px; height: 8px; margin-top: -2px;\n border: solid ${At("bg")}; border-width: 0 2px 2px 0; transform: rotate(45deg); }\n.oac-widget input[type=checkbox]:disabled { opacity: .4; cursor: not-allowed; }\n.oac-widget select { appearance: none; -webkit-appearance: none; height: ${At("ctl-h")}; padding: 0 24px 0 8px;\n background: ${At("elev")}; border: 1px solid ${At("bd")}; border-radius: ${At("radius")}; cursor: pointer; }\n.oac-widget .oac-select { position: relative; display: inline-flex; }\n/* The chevron overlays the select rather than sitting beside it. selectBox\n wraps the glyph in an oac-chev span, and this rule used to name\n .oac-select > svg, which that markup has never had: the span stayed an\n ordinary flex item, so it took eleven pixels of the row and left the select\n eleven pixels short of every input beside it, with its arrow outside its own\n box. Sized here rather than left to .oac-chev, whose inline-grid is right\n where a chevron follows a word, as it does in the top bar. */\n.oac-widget .oac-select > .oac-chev { position: absolute; right: 7px; top: 50%; width: 11px; height: 11px;\n transform: translateY(-50%); pointer-events: none; display: block; color: ${At("mut")}; }\n.oac-widget select option, .oac-widget select optgroup { background: ${At("panel")}; color: ${At("tx")}; }\n.oac-widget input[type=color] { width: 26px; height: 26px; padding: 0; flex: none; cursor: pointer; appearance: none;\n -webkit-appearance: none; background-color: ${At("elev")}; border: 1px solid ${At("bd")}; border-radius: ${At("radius")}; }\n.oac-widget input[type=color]:hover { border-color: ${At("bd-hover")}; }\n.oac-widget input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }\n.oac-widget input[type=color]::-webkit-color-swatch { border: 1px solid rgba(0,0,0,.35); border-radius: 4px; }\n.oac-widget input[type=color]::-moz-color-swatch { border: 1px solid rgba(0,0,0,.35); border-radius: 4px; }\n.oac-widget .oac-swatch { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(0,0,0,.35); }\n.oac-widget input[type=number] { -moz-appearance: textfield; appearance: textfield; }\n.oac-widget input[type=number]::-webkit-inner-spin-button, .oac-widget input[type=number]::-webkit-outer-spin-button {\n -webkit-appearance: none; margin: 0; }\n.oac-widget input[type=text], .oac-widget input[type=number], .oac-widget input[type=search], .oac-widget textarea {\n height: ${At("ctl-h")}; padding: 0 8px; background: ${At("elev")}; border: 1px solid ${At("bd")}; border-radius: ${At("radius")};\n transition: border-color .15s, box-shadow .15s; }\n.oac-widget textarea { height: auto; padding: 6px 8px; }\n.oac-widget input::placeholder { color: ${At("faint")}; }\n.oac-widget input:hover, .oac-widget select:hover { border-color: ${At("bd-hover")}; }\n.oac-widget input[type=range] { appearance: none; -webkit-appearance: none; height: 22px; margin: 0;\n background: transparent; cursor: pointer; }\n.oac-widget input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: ${At("elev-3")}; }\n.oac-widget input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px;\n margin-top: -4.5px; border-radius: 50%; background: ${At("acc")}; border: 0; }\n.oac-widget input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: ${At("elev-3")}; }\n.oac-widget input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: ${At("acc")}; border: 0; }\n\n/* Section heads and rows shared by every panel. */\n.oac-widget .oac-head { padding: 8px 10px 4px; color: ${At("faint")}; font-size: 10px; font-weight: 600;\n text-transform: uppercase; letter-spacing: .7px; }\n.oac-widget .oac-row { display: flex; align-items: center; gap: 8px; min-height: 26px; padding: 2px 0; }\n.oac-widget .oac-row > label { flex: 1 1 auto; min-width: 0; color: ${At("tx")}; }\n\n/* Help mark: a 13px ring after a label, muted until pointed at. It must not\n grow the row, so it sits on the label's own line box and never wraps away\n from the words it belongs to. */\n.oac-widget .oac-help { display: inline-flex; align-items: center; justify-content: center;\n width: 13px; height: 13px; margin-left: 5px; vertical-align: -2px; flex: none;\n border: 1px solid ${At("bd")}; border-radius: 50%; color: ${At("faint")};\n font-size: 9px; font-weight: 600; line-height: 1; cursor: help; user-select: none; }\n.oac-widget .oac-help:hover, .oac-widget .oac-help:focus-visible {\n color: ${At("tx")}; border-color: ${At("bd-hover")}; outline: none; }\n\n/* Buttons: flat, 28px tall, a tint when pressed or armed. */\n.oac-widget .oac-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;\n height: ${At("ctl-h")}; padding: 0 9px; background: transparent; border: 1px solid transparent;\n border-radius: ${At("radius")}; color: ${At("tx")}; white-space: nowrap; transition: background .1s, border-color .1s, color .1s; }\n.oac-widget .oac-btn:hover { background: ${At("elev")}; border-color: ${At("bd-soft")}; }\n.oac-widget .oac-btn.is-on, .oac-widget .oac-btn[aria-pressed="true"], .oac-widget .oac-btn[aria-expanded="true"] {\n background: ${At("on-bg")}; border-color: ${At("on-bd")}; color: ${At("acc-2")}; }\n.oac-widget .oac-btn.is-off, .oac-widget .oac-btn[aria-disabled="true"], .oac-widget .oac-btn:disabled {\n color: ${At("faint")}; cursor: default; }\n.oac-widget .oac-btn.is-off:hover, .oac-widget .oac-btn[aria-disabled="true"]:hover, .oac-widget .oac-btn:disabled:hover {\n background: transparent; border-color: transparent; }\n.oac-widget .oac-btn--icon { width: ${At("ctl-h")}; padding: 0; }\n.oac-widget .oac-btn--primary { background: ${At("acc")}; color: ${At("bg")}; border-color: transparent; font-weight: 600; }\n.oac-widget .oac-btn--primary:hover { background: ${At("acc-2")}; border-color: transparent; }\n.oac-widget .oac-btn--danger:not(.is-off):hover { color: ${At("danger")}; }\n.oac-widget .oac-btn > b { font-weight: 700; letter-spacing: .3px; }\n.oac-widget .oac-glyph { display: inline-grid; place-items: center; line-height: 0; flex: none; }\n.oac-widget .oac-glyph > svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-glyph--tool > svg { width: 24px; height: 24px; stroke-width: 2; }\n.oac-widget .oac-glyph--chrome > svg { width: 16px; height: 16px; stroke-width: 1.5; }\n.oac-widget .oac-glyph--text { display: inline-grid; place-items: center; width: 24px; height: 24px;\n font-size: 12px; font-weight: 600; }\n.oac-widget .oac-chev { display: inline-grid; place-items: center; line-height: 0; color: ${At("mut")}; }\n.oac-widget .oac-chev > svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.5;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-sep { width: 1px; height: 20px; background: ${At("bd-soft")}; margin: 0 2px; flex: none; }\n\n/* Top bar */\n.oac-widget .oac-topbar { grid-row: 1; display: flex; align-items: center; gap: 4px; min-height: ${At("topbar-h")};\n padding: 5px 8px; background: ${At("panel")}; border-bottom: 1px solid ${At("bd-soft")}; flex-wrap: wrap; }\n.oac-widget .oac-topbar__spacer { flex: 1 1 auto; }\n.oac-widget .oac-topbar__branding-slot { display: inline-flex; align-items: center; }\n.oac-widget .oac-topbar__branding { color: ${At("mut")}; font-size: 11px; text-decoration: none; white-space: nowrap; }\n.oac-widget .oac-topbar__branding:hover { color: ${At("tx")}; text-decoration: underline; }\n.oac-widget .oac-sym { position: relative; display: inline-flex; align-items: center; }\n.oac-widget .oac-sym > input { width: 132px; height: ${At("ctl-h")}; padding: 0 8px 0 28px; font-weight: 600;\n letter-spacing: .3px; text-transform: uppercase; }\n.oac-widget .oac-sym > .oac-glyph { position: absolute; left: 8px; color: ${At("mut")}; pointer-events: none; }\n.oac-widget .oac-sym__ex { margin-left: 6px; color: ${At("faint")}; font-size: 11px; font-weight: 600; letter-spacing: .5px; }\n.oac-widget .oac-pills { display: inline-flex; background: ${At("elev")}; border: 1px solid ${At("bd-soft")};\n border-radius: 7px; padding: 2px; }\n.oac-widget .oac-pills > button { height: 22px; padding: 0 8px; background: transparent; border: 0; border-radius: 5px;\n color: ${At("mut")}; font-weight: 600; font-size: 11.5px; letter-spacing: .2px; }\n.oac-widget .oac-pills > button:hover { color: ${At("tx")}; }\n.oac-widget .oac-pills > button[aria-pressed="true"] { background: ${At("elev-2")}; color: ${At("acc-2")}; }\n.oac-widget .oac-pills > button:focus-visible { outline-offset: -1px; }\n\n/* Popup menu (chart types, screenshot, symbol results) */\n.oac-widget .oac-menu { min-width: 190px; max-width: 320px; max-height: 60vh; overflow-y: auto; padding: 5px;\n background: ${At("panel")}; border: 1px solid ${At("bd")}; border-radius: 9px; box-shadow: ${At("shadow")}; outline: none; }\n.oac-widget .oac-menu__find { padding: 3px 3px 6px; }\n.oac-widget .oac-menu__find > input { width: 100%; }\n.oac-widget .oac-menu__row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 8px;\n background: transparent; border: 0; border-radius: 6px; color: ${At("tx")}; text-align: left; white-space: nowrap; }\n.oac-widget .oac-menu__row:hover, .oac-widget .oac-menu__row:focus-visible, .oac-widget .oac-menu__row.is-active {\n background: ${At("elev-2")}; outline: none; }\n.oac-widget .oac-menu__row[aria-checked="true"] { color: ${At("acc-2")}; }\n.oac-widget .oac-menu__row[aria-checked="true"]::before { content: ''; width: 6px; height: 6px; border-radius: 50%;\n background: ${At("acc-2")}; margin: 0 2px 0 -2px; flex: none; }\n.oac-widget .oac-menu__row[aria-checked="false"]::before { content: ''; width: 6px; height: 6px; margin: 0 2px 0 -2px; flex: none; }\n.oac-widget .oac-menu__row[aria-disabled="true"] { color: ${At("faint")}; cursor: default; background: transparent; }\n.oac-widget .oac-menu__row.is-danger:hover { color: ${At("danger")}; }\n.oac-widget .oac-menu__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-menu__sub { color: ${At("faint")}; font-size: 11px; }\n.oac-widget .oac-menu__key { margin-left: auto; color: ${At("faint")}; }\n.oac-widget .oac-menu__empty { padding: 8px 10px; color: ${At("faint")}; }\n\n/* Stage: the rail on the left, the chart filling the rest. */\n.oac-widget .oac-stage { grid-row: 2; position: relative; min-height: 0; min-width: 0; display: flex; }\n.oac-widget .oac-chart { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0;\n cursor: var(--oac-tool-cursor, crosshair); }\n.oac-widget .oac-chart:focus-visible { outline-offset: -2px; }\n\n/* Data state stays compact inside a chart, including narrow embedded widgets. */\n.oac-widget .oac-data-status { position: absolute; top: 8px; right: 8px; z-index: 30;\n max-width: calc(100% - 16px); width: max-content; max-height: 45%; overflow-y: auto;\n display: flex; flex-direction: column; gap: 4px; pointer-events: none; font-size: 12px; }\n.oac-widget .oac-data-status__row { display: flex; align-items: center; gap: 8px;\n max-width: 320px; padding: 4px 6px 4px 10px; background: ${At("panel")}; color: ${At("tx")};\n border: 1px solid ${At("bd")}; border-radius: 6px; pointer-events: auto; }\n.oac-widget .oac-data-status__text { min-width: 0; overflow-wrap: anywhere; }\n.oac-widget .oac-data-status__row > button { flex: none; color: ${At("acc-2")}; }\n\n/* Rail */\n.oac-widget .oac-rail { flex: none; width: ${At("rail-w")}; display: flex; flex-direction: column; align-items: center;\n gap: 2px; padding: 6px 0 0; background: ${At("panel-2")}; border-right: 1px solid ${At("bd-soft")};\n overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }\n.oac-widget .oac-rail::-webkit-scrollbar { width: 0; height: 0; }\n.oac-widget .oac-rail__btn { position: relative; width: 32px; height: 32px; padding: 0; display: grid; place-items: center;\n flex: none; background: transparent; border: 1px solid transparent; border-radius: 7px; color: ${At("mut")};\n transition: background .1s, color .1s, border-color .1s; }\n.oac-widget .oac-rail__btn:hover { background: ${At("elev")}; color: ${At("tx")}; }\n.oac-widget .oac-rail__btn:focus-visible { outline: 2px solid ${At("acc-2")}; outline-offset: -2px; }\n.oac-widget .oac-rail__btn.is-on { background: ${At("on-bg")}; border-color: ${At("on-bd")}; color: ${At("acc-2")}; }\n.oac-widget .oac-rail__btn.is-weak { color: ${At("acc-2")}; }\n.oac-widget .oac-rail__btn.is-off { color: ${At("faint")}; cursor: default; }\n.oac-widget .oac-rail__btn.is-off:hover { background: transparent; color: ${At("faint")}; }\n.oac-widget .oac-rail__btn--danger:not(.is-off):hover { color: ${At("danger")}; }\n.oac-widget .oac-rail__chev { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; display: grid;\n place-items: center; border-radius: 5px 0 6px 0; color: ${At("mut")}; opacity: 0; transition: opacity .1s, background .1s; }\n.oac-widget .oac-rail__chev > svg { width: 9px; height: 9px; fill: none; stroke: currentColor; stroke-width: 2.2;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-rail__btn:hover .oac-rail__chev, .oac-widget .oac-rail__btn:focus-visible .oac-rail__chev,\n.oac-widget .oac-rail__btn[aria-expanded="true"] .oac-rail__chev { opacity: 1; }\n.oac-widget .oac-rail__chev:hover { background: ${At("elev-2")}; color: ${At("tx")}; }\n.oac-widget .oac-rail__btn.is-held::after, .oac-widget .oac-rail__btn[data-mode="weak"]::after,\n.oac-widget .oac-rail__btn[data-mode="strong"]::after { content: ''; position: absolute; top: 3px; right: 3px;\n width: 5px; height: 5px; border-radius: 50%; }\n.oac-widget .oac-rail__btn.is-held::after, .oac-widget .oac-rail__btn[data-mode="strong"]::after { background: ${At("acc-2")}; }\n.oac-widget .oac-rail__btn[data-mode="weak"]::after { border: 1.5px solid ${At("acc-2")}; width: 4px; height: 4px; }\n.oac-widget .oac-rail__sep { width: 22px; height: 1px; background: ${At("bd-soft")}; margin: 4px 0; flex: none; }\n.oac-widget .oac-rail__favs { display: contents; }\n.oac-widget .oac-rail__ctl { margin-top: auto; position: sticky; bottom: 0; display: flex; flex-direction: column;\n align-items: center; gap: 2px; width: 100%; padding: 4px 0 6px; background: ${At("panel-2")};\n border-top: 1px solid ${At("bd-soft")}; flex: none; }\n.oac-widget .oac-rail__ctl .oac-rail__sep { margin: 3px 0; }\n\n/* Rail flyout: a group's tools, with a pin star and the chord on each row. */\n.oac-widget .oac-fly { min-width: 244px; max-width: 320px; max-height: calc(100% - 16px); overflow-y: auto; padding: 6px;\n background: ${At("panel")}; border: 1px solid ${At("bd")}; border-radius: 10px; box-shadow: ${At("shadow")}; outline: none; }\n.oac-widget .oac-fly__row { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 8px; border-radius: 7px;\n color: ${At("tx")}; font-size: 13px; cursor: pointer; outline: none; user-select: none; }\n.oac-widget .oac-fly__row:hover, .oac-widget .oac-fly__row:focus-visible { background: ${At("elev-2")}; }\n.oac-widget .oac-fly__row[aria-checked="true"] { background: ${At("on-bg")}; color: ${At("acc-2")}; }\n.oac-widget .oac-fly__name { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-fly__chord { min-width: 40px; text-align: right; color: ${At("faint")}; }\n.oac-widget .oac-fly__star { width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0;\n border-radius: 5px; background: transparent; color: ${At("faint")}; opacity: 0; transition: opacity .1s, color .1s; }\n.oac-widget .oac-fly__row:hover .oac-fly__star, .oac-widget .oac-fly__row:focus-within .oac-fly__star,\n.oac-widget .oac-fly__star[aria-pressed="true"] { opacity: 1; }\n.oac-widget .oac-fly__star:hover { background: ${At("elev")}; color: ${At("tx")}; }\n.oac-widget .oac-fly__star:focus-visible { outline: 2px solid ${At("acc-2")}; outline-offset: -1px; opacity: 1; }\n.oac-widget .oac-fly__star[aria-pressed="true"] { color: ${At("amber")}; }\n.oac-widget .oac-fly__star > svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.5;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-fly__star[aria-pressed="false"] > svg { fill: none; }\n\n/* Tooltip */\n.oac-widget .oac-tip { position: absolute; z-index: 200; left: 0; top: 0; max-width: 260px; pointer-events: none;\n padding: 5px 9px; border-radius: 6px; background: ${At("elev-2")}; color: ${At("tx")}; border: 1px solid ${At("bd")};\n box-shadow: ${At("shadow")}; font-size: 12px; line-height: 1.4; opacity: 0; transition: opacity .09s ease; }\n.oac-widget .oac-tip.is-on { opacity: 1; }\n.oac-widget .oac-tip__chord { margin-left: 10px; color: ${At("mut")}; }\n.oac-widget .oac-tip__sub { display: block; margin-top: 2px; color: ${At("faint")}; font-size: 11px; }\n\n/* Status line */\n.oac-widget .oac-statusline { grid-row: 3; display: flex; align-items: center; gap: 12px; height: ${At("status-h")}; padding: 0 10px;\n background: ${At("panel")}; border-top: 1px solid ${At("bd-soft")}; color: ${At("mut")}; font-size: 11.5px;\n font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }\n.oac-widget .oac-statusline__sym { color: ${At("tx-strong")}; font-weight: 600; letter-spacing: .3px; }\n.oac-widget .oac-statusline__iv { color: ${At("faint")}; margin-left: 4px; font-weight: 600; }\n.oac-widget .oac-statusline__field { display: inline-flex; align-items: center; gap: 4px; }\n.oac-widget .oac-statusline__field > i { font-style: normal; color: ${At("faint")}; }\n.oac-widget .oac-statusline__field > b { font-weight: 500; color: ${At("tx")}; }\n.oac-widget .oac-statusline .is-up > b { color: ${At("buy")}; }\n.oac-widget .oac-statusline .is-down > b { color: ${At("sell")}; }\n.oac-widget .oac-statusline__msg { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: ${At("mut")}; }\n.oac-widget .oac-statusline__msg.is-error { color: ${At("danger")}; }\n.oac-widget .oac-statusline__tz { color: ${At("faint")}; }\n\n/* Narrow widget chrome */\n.oac-widget .oac-mobile { display: none; }\n.oac-widget.is-mobile { grid-template-rows: auto minmax(0, 1fr) auto; }\n.oac-widget.is-mobile > .oac-topbar, .oac-widget.is-mobile > .oac-statusline,\n.oac-widget.is-mobile > .oac-stage > .oac-rail { display: none; }\n.oac-widget.is-mobile > .oac-stage { grid-row: 2; }\n.oac-widget.is-mobile > .oac-mobile { display: contents; }\n.oac-widget .oac-mobile__header { grid-row: 1; z-index: 40; display: grid; grid-template-columns: minmax(0, 1fr) auto;\n gap: 8px; min-height: 52px; padding: calc(4px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 4px\n max(8px, env(safe-area-inset-left)); background: ${At("panel")}; border-bottom: 1px solid ${At("bd-soft")}; }\n.oac-widget .oac-mobile__symbol { width: 100%; min-width: 0; height: 44px; text-transform: uppercase; font-weight: 600; }\n.oac-widget .oac-mobile__footer { grid-row: 3; z-index: 40; min-width: 0; padding-bottom: env(safe-area-inset-bottom);\n background: ${At("panel")}; border-top: 1px solid ${At("bd-soft")}; }\n.oac-widget .oac-mobile__bar, .oac-widget .oac-mobile__selection { display: grid; grid-auto-flow: column;\n grid-auto-columns: minmax(0, 1fr); min-width: 0; }\n.oac-widget .oac-mobile__selection { border-bottom: 1px solid ${At("bd-soft")}; }\n.oac-widget .oac-mobile__action { min-width: 0; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 0;\n background: transparent; color: ${At("tx")}; overflow-wrap: anywhere; touch-action: manipulation; }\n.oac-widget .oac-mobile__action:hover, .oac-widget .oac-mobile__action:focus-visible { background: ${At("elev")}; }\n.oac-widget .oac-mobile__action[aria-pressed="true"] { color: ${At("acc-2")}; background: ${At("on-bg")}; }\n.oac-widget .oac-mobile__action[aria-disabled="true"] { color: ${At("faint")}; cursor: default; background: transparent; }\n.oac-widget .oac-mobile__branding { display: flex; align-items: center; width: 100%; min-height: 44px; text-decoration: none; }\n.oac-widget .oac-mobile-sheet.oac-dialog { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%;\n max-width: 100%; max-height: calc(100% - env(safe-area-inset-top) - 12px); border-radius: 14px 14px 0 0;\n padding-bottom: env(safe-area-inset-bottom); }\n.oac-widget .oac-mobile-sheet__head { flex: none; display: flex; align-items: center; gap: 8px;\n min-height: 52px; padding: 4px 8px 4px 14px; border-bottom: 1px solid ${At("bd-soft")}; }\n.oac-widget .oac-mobile-sheet__title { flex: 1 1 auto; color: ${At("tx-strong")}; font-size: 14px; }\n.oac-widget .oac-mobile-sheet__body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;\n display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; padding: 8px; }\n.oac-widget .oac-mobile-sheet__body > .oac-head { grid-column: 1 / -1; }\n.oac-widget .oac-mobile-sheet__controls { grid-column: 1 / -1; display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid ${At("bd-soft")}; margin-bottom: 6px; }\n.oac-widget .oac-mobile-sheet__body small { display: block; color: ${At("faint")}; }\n.oac-widget .oac-mobile-results { width: min(360px, calc(100% - 16px)); max-height: min(50%, 360px); overflow: hidden;\n display: flex; flex-direction: column; background: ${At("panel")}; border: 1px solid ${At("bd")}; border-radius: 10px; box-shadow: ${At("shadow")}; }\n.oac-widget .oac-mobile-results__head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 44px;\n padding-left: 12px; border-bottom: 1px solid ${At("bd-soft")}; }\n.oac-widget .oac-mobile-results__head > strong { flex: 1 1 auto; color: ${At("tx-strong")}; }\n.oac-widget .oac-mobile-results__list { flex: 1 1 auto; min-height: 0; max-height: min(42vh, 300px);\n overflow-y: auto; overscroll-behavior: contain; }\n.oac-widget .oac-mobile-results__list > .oac-mobile__action { display: block; width: 100%; text-align: left; }\n.oac-widget .oac-mobile-results__list small { display: block; color: ${At("faint")}; }\n.oac-widget .oac-mobile-results__status { min-height: 44px; padding: 13px 12px; color: ${At("mut")}; }\n.oac-widget.is-mobile .oac-toasts { bottom: calc(54px + env(safe-area-inset-bottom)); }\n\n/* Toasts */\n.oac-widget .oac-toasts { position: absolute; right: 12px; bottom: calc(${At("status-h")} + 10px); z-index: 90; display: flex;\n flex-direction: column; gap: 8px; width: min(340px, calc(100% - 24px)); pointer-events: none; }\n.oac-widget .oac-toast { display: flex; align-items: flex-start; gap: 8px; padding: 8px 6px 8px 12px; border-radius: 8px;\n background: ${At("panel")}; color: ${At("tx")}; border: 1px solid ${At("bd")}; border-left: 3px solid ${At("acc")};\n box-shadow: ${At("shadow")}; font-size: 12.5px; line-height: 1.45; pointer-events: auto; animation: oac-toast-in .16s ease-out; }\n.oac-widget .oac-toast--success { border-left-color: ${At("buy")}; }\n.oac-widget .oac-toast--error { border-left-color: ${At("sell")}; }\n.oac-widget .oac-toast__msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; padding-top: 2px; }\n.oac-widget .oac-toast__x { flex: none; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent;\n color: ${At("faint")}; padding: 0; display: grid; place-items: center; }\n.oac-widget .oac-toast__x:hover { background: ${At("elev-2")}; color: ${At("tx")}; }\n.oac-widget .oac-toast__x > svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; }\n.oac-widget .oac-toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity .16s, transform .16s; }\n@keyframes oac-toast-in { from { opacity: 0; transform: translateY(6px); } }\n\n/* Overlay layer: popovers anchored to a control, dialogs centred over a scrim. */\n.oac-widget .oac-layer { container: oac-widget / inline-size; position: absolute; inset: 0; z-index: 60; pointer-events: none; }\n.oac-widget .oac-layer > * { pointer-events: auto; }\n.oac-widget .oac-scrim { position: absolute; inset: 0; background: ${At("scrim")}; }\n.oac-widget .oac-pop { position: absolute; left: 0; top: 0; }\n.oac-widget .oac-dialog { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);\n min-width: 0; max-width: calc(100% - 24px); max-height: calc(100% - 24px); display: flex; flex-direction: column;\n background: ${At("panel")}; border: 1px solid ${At("bd")}; border-radius: 12px; box-shadow: ${At("shadow")}; outline: none; }\n.oac-widget .oac-dialog__head { flex: none; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }\n.oac-widget .oac-dialog__title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 700; color: ${At("tx-strong")}; }\n.oac-widget .oac-dialog__body { flex: 1 1 auto; min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; padding: 4px 14px 10px; }\n.oac-widget .oac-dialog__foot { flex: none; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px 12px;\n border-top: 1px solid ${At("bd-soft")}; }\n.oac-widget .oac-dialog__foot > .oac-spacer { flex: 1 1 auto; }\n\n/* Shortcuts panel */\n.oac-widget .oac-keys { columns: 2; column-gap: 24px; min-width: 520px; }\n.oac-widget .oac-keys__group { break-inside: avoid; margin-bottom: 8px; }\n.oac-widget .oac-keys__row { display: flex; align-items: center; gap: 10px; padding: 3px 0; }\n.oac-widget .oac-keys__row > span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-keys__row > kbd { flex: none; padding: 2px 6px; border-radius: 4px; background: ${At("elev")};\n border: 1px solid ${At("bd-soft")}; color: ${At("mut")}; }\n.oac-widget .oac-keys__row.is-shadowed > span, .oac-widget .oac-keys__row.is-shadowed > kbd { color: ${At("faint")}; text-decoration: line-through; }\n.oac-widget .oac-keys__note { color: ${At("faint")}; font-size: 11px; padding: 4px 0 0; }\n\n@container oac-widget (max-width: 720px) {\n .oac-widget .oac-keys { columns: 1; min-width: 0; }\n}\n@media (max-width: 720px) {\n .oac-widget .oac-sym > input { width: 104px; }\n}\n@media (prefers-reduced-motion: reduce) {\n .oac-widget .oac-rail__btn, .oac-widget .oac-rail__chev, .oac-widget .oac-tip, .oac-widget .oac-fly__star,\n .oac-widget .oac-btn, .oac-widget .oac-toast.is-out { transition: none; }\n .oac-widget .oac-toast { animation: none; }\n .oac-widget .oac-mobile__action { transition: none; }\n}\n`;function Ot(e,t="",o){const n=e.getElementById(St);if(n?.textContent?.trim())return n;const a=n??e.createElement("style");return a.id=St,a.nonce||void 0===o||(a.nonce=o),a.textContent=Lt+t,null===n&&(e.head??e.body??e.documentElement).appendChild(a),a}const Tt=["1m","3m","5m","15m","30m","1h","2h","4h","1d","1w"];function Et(){const e=new Set,t=[{label:"Chart",value:""}];for(const o of[...Tt,...i().map(e=>e.code)]){const n=o.toLowerCase();e.has(n)||(e.add(n),t.push({label:o,value:o}))}return t}function Mt(e,t){const o=[];for(const t of e){const e=o.length;switch(t.type){case"colorPair":o.push({key:t.key,kind:"colorPair",label:t.label,group:t.group,pair:{enabled:void 0===t.enabled?void 0:{key:t.enabled.key},up:{key:t.up.key,label:t.up.label},down:{key:t.down.key,label:t.down.label}}});break;case"number":o.push({key:t.key,kind:"number",label:t.label,group:t.group,min:t.min,max:t.max,step:t.step});break;case"select":o.push({key:t.key,kind:"select",label:t.label,group:t.group,options:t.options});break;case"source":o.push({key:t.key,kind:"select",label:t.label,group:t.group,options:a});break;case"interval":o.push({key:t.key,kind:"select",label:t.label,group:t.group,options:Et()});break;case"time":o.push({key:t.key,kind:"text",label:t.label,group:t.group});break;case"boolean":case"color":case"text":o.push({key:t.key,kind:t.type,label:t.label,group:t.group})}void 0!==t.tooltip&&o.length>e&&(o[e].tooltip=t.tooltip)}return jt(o,t)}function jt(e,t){if(void 0===t?.translate)return e;const o=(e,o)=>ee(t,`schema.${t.scope}.${e}`,{},o);return e.map(e=>({...e,label:o(`${e.key}.label`,e.label),group:void 0===e.group?void 0:o(`group.${e.group}`,e.group),tooltip:void 0===e.tooltip?void 0:o(`${e.key}.tooltip`,e.tooltip),options:e.options?.map(t=>({...t,label:t.label===t.value?t.label:o(`${e.key}.option.${t.value}`,t.label)})),pair:void 0===e.pair?void 0:{...e.pair,up:{...e.pair.up,label:o(`${e.pair.up.key}.label`,e.pair.up.label)},down:{...e.pair.down,label:o(`${e.pair.down.key}.label`,e.pair.down.label)}}}))}const Pt={line:"Line",fill:"Fill",text:"Text",levels:"Levels",behavior:"Behavior"};function It(e,t){const o=[];for(const t of e){const e=void 0===t.group?void 0:Pt[t.group]??t.group,n={key:t.path,label:t.label,group:e};switch(t.kind){case"color":o.push({...n,kind:"color"});break;case"number":o.push({...n,kind:"number",min:t.min,max:t.max,step:t.step});break;case"opacity":o.push({...n,kind:"opacity"});break;case"boolean":o.push({...n,kind:"boolean"});break;case"select":case"lineStyle":o.push(void 0===t.options?{...n,kind:"text"}:{...n,kind:"select",options:t.options});break;case"text":o.push({...n,kind:"text.value"===t.path?"multiline":"text"});break;case"levels":o.push({...n,kind:"custom",custom:"levels"})}}return jt(o,t)}function Dt(e){if("string"!=typeof e)return null;const t=e.trim(),o=/^#([0-9a-f]{3,8})$/i.exec(t);if(null!==o){const e=o[1];return 3===e.length||4===e.length?"#"+e.slice(0,3).split("").map(e=>e+e).join("").toLowerCase():6===e.length||8===e.length?"#"+e.slice(0,6).toLowerCase():null}const n=/^rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/i.exec(t);if(null===n)return null;const a=e=>Math.round(Math.max(0,Math.min(255,Number(e)))).toString(16).padStart(2,"0");return`#${a(n[1])}${a(n[2])}${a(n[3])}`}function Nt(e,t,o,n){const a=e.createElement(t);return void 0!==o&&""!==o&&(a.className=o),void 0!==n&&(a.textContent=n),a}function zt(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${e}"/></svg>`}function Rt(e,t){const o=Nt(e,"span","oac-glyph oac-glyph--chrome");return o.innerHTML=E(t),o}function Bt(e,t){const o=Nt(e,"button");o.type="button";const n=["oac-btn"];if(!0===t.iconOnly&&n.push("oac-btn--icon"),"primary"===t.variant&&n.push("oac-btn--primary"),"danger"===t.variant&&n.push("oac-btn--danger"),o.className=n.join(" "),void 0!==t.icon)o.appendChild(Rt(e,t.icon));else if(void 0!==t.svg){const n=Nt(e,"span","oac-glyph oac-glyph--chrome");n.innerHTML=t.svg,o.appendChild(n)}if(!0===t.iconOnly?(o.setAttribute("aria-label",t.label),o.title=void 0===t.chord?t.label:`${t.label} (${t.chord})`):(o.appendChild(e.createTextNode(t.label)),void 0!==t.chord&&(o.title=t.chord)),void 0!==t.onClick){const e=t.onClick;o.addEventListener("click",t=>{t.stopPropagation(),e(t)})}return o}function Ft(e){e.addEventListener("keydown",e=>{const t=e.key;"Escape"!==t&&"Tab"!==t&&e.stopPropagation()}),e.addEventListener("pointerdown",e=>{e.stopPropagation()})}let Ut=0;function Ht(e,t){const o=Nt(e,"div","oac-panel"+(void 0===t.className?"":" "+t.className));o.setAttribute("role","dialog"),o.tabIndex=-1;const n="oac-dlg-title-"+ ++Ut;o.setAttribute("aria-labelledby",n);const a=Nt(e,"div","oac-dialog__head"),i=Nt(e,"span","oac-dialog__title",t.title);i.id=n;const r=Bt(e,{label:ee(t,"Close"),icon:"close",iconOnly:!0,onClick:()=>t.onClose()});a.appendChild(i),a.appendChild(r);const s=Nt(e,"div","oac-dialog__body"),l=Nt(e,"div","oac-dialog__foot"),c=Nt(e,"div","oac-dialog__lead"),d=Nt(e,"div","oac-spacer"),p=Nt(e,"div","oac-dialog__actions");return l.appendChild(c),l.appendChild(d),l.appendChild(p),o.appendChild(a),o.appendChild(s),o.appendChild(l),Ft(o),{el:o,head:a,body:s,foot:l,lead:c,actions:p,closeButton:r,setTitle:e=>{i.textContent=e}}}function Vt(e,t,o,n){let a,i=!1,r=!1;const s=e.openOverlay(t,{...o,onClose:()=>{o.onClose?.(),i||(r=!0,n(),d())}}),l=t.closest(".oac-widget"),c=t.querySelectorAll(".oac-tabs--rail");if(null!==l&&c.length>0){const e=()=>{const e=l.getBoundingClientRect().width<=720?"horizontal":"vertical";c.forEach(t=>t.setAttribute("aria-orientation",e))};e();const o=t.ownerDocument.defaultView?.ResizeObserver;void 0!==o&&(a=new o(e),a.observe(l))}function d(){i||(i=!0,a?.disconnect(),r||s(),t.remove())}return{el:t,close:d,isOpen:()=>!i}}function Kt(e,t){const o=e.getBoundingClientRect(),n=t.getBoundingClientRect();return{left:n.left-o.left,top:n.top-o.top,right:n.right-o.left,bottom:n.bottom-o.top}}function qt(e,t,o){const n=t.panes()[0]?.element.parentElement??null,a=null===n?{left:0,top:0}:Kt(e,n);let i=1/0,r=-1/0;for(const e of o)for(const o of e.points){const n=t.timeToCoordinate(o.time),a=t.priceToCoordinate(o.price,e.paneIndex);Number.isFinite(n)&&null!==a&&Number.isFinite(a)&&(i=Math.min(i,n),r=Math.max(r,a))}return Number.isFinite(i)&&Number.isFinite(r)?{x:a.left+i,y:a.top+r+12}:{x:a.left+60,y:a.top+60}}function Wt(e,t,o,n,a){const i=Nt(e,"div",`oac-tabs oac-tabs--${n}`);i.setAttribute("role","tablist"),i.setAttribute("aria-orientation","rail"===n?"vertical":"horizontal");const r=[],s=e=>{t.forEach((t,o)=>{const n=t.id===e;r[o].setAttribute("aria-selected",n?"true":"false"),r[o].tabIndex=n?0:-1})},l=e=>{s(e),a(e)};return t.forEach((o,n)=>{const a=Nt(e,"button","oac-tab");if(a.type="button",a.setAttribute("role","tab"),a.dataset.tab=o.id,void 0!==o.icon){const t=Nt(e,"span","oac-glyph oac-glyph--chrome");t.innerHTML=o.icon,a.appendChild(t)}a.appendChild(Nt(e,"span","oac-tab__label",o.label)),a.addEventListener("click",e=>{e.stopPropagation(),l(o.id)}),a.addEventListener("keydown",e=>{const o=e.key,a="vertical"===i.getAttribute("aria-orientation"),s=a?"ArrowUp":"ArrowLeft";let c=-1;o===(a?"ArrowDown":"ArrowRight")?c=(n+1)%t.length:o===s?c=(n-1+t.length)%t.length:"Home"===o?c=0:"End"===o&&(c=t.length-1),c<0||(e.preventDefault(),r[c].focus(),r[c].scrollIntoView?.({block:"nearest",inline:"nearest"}),l(t[c].id))}),r.push(a),i.appendChild(a)}),s(o),{el:i,setActive:s}}function Gt(e,t,o){const n=e.getBoundingClientRect(),a=t.offsetWidth||200,i=t.offsetHeight||100;let r=4,s=4;if(void 0!==o.anchor){const e=o.anchor.getBoundingClientRect();r=e.left-n.left,s=e.bottom-n.top+6,s+i>n.height-4&&(s=Math.max(4,e.top-n.top-i-6))}else void 0!==o.point&&(r=o.point.x,s=o.point.y,s+i>n.height-4&&(s=Math.max(4,n.height-i-4)));r=Math.max(4,Math.min(r,n.width-a-4)),s=Math.max(4,Math.min(s,n.height-i-4)),t.style.left=`${Math.round(r)}px`,t.style.top=`${Math.round(s)}px`}function Zt(e,t,o){const n=e.ownerDocument;e.innerHTML="",e.classList.add("oac-form");const a=[],i=o.unavailable??(()=>null),r=e=>`${o.idPrefix}-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`,s=new Map,l=(e,t)=>{s.has(e)&&Object.is(s.get(e),t)||(s.set(e,t),o.onChange(e,t))},c=(e,t)=>{null!==t&&(e.disabled=!0,e.title=t)};function d(e,t,a,r){const d=i(e);let p,h;switch(t){case"boolean":{const t=Nt(n,"input");t.type="checkbox",t.checked=!0===r,t.addEventListener("change",()=>l(e,t.checked)),p=t,h={key:e,control:t,read:()=>t.checked,write:e=>{t.checked=!0===e}};break}case"number":{const t=Nt(n,"input","oac-input--num");t.type="number",void 0!==a.min&&(t.min=String(a.min)),void 0!==a.max&&(t.max=String(a.max)),void 0!==a.step&&(t.step=String(a.step));const i=e=>{var o;t.value="number"==typeof e&&Number.isFinite(e)?(o=e,Number.isInteger(o)?String(o):String(Math.round(1e3*o)/1e3)):""};i(r),t.addEventListener("change",()=>{const n=t.value.trim(),c=""===n?NaN:Number(n);if(!Number.isFinite(c))return void(o.preserveInvalidNumbers?l(e,void 0):i(s.has(e)?s.get(e):r));const d=a.min??-1/0,p=a.max??1/0,h=Math.min(p,Math.max(d,c));h!==c&&i(h),l(e,h)}),p=t,h={key:e,control:t,read:()=>{const e=Number(t.value);return""!==t.value.trim()&&Number.isFinite(e)?e:void 0},write:i};break}case"color":{const t=Nt(n,"input","oac-swatch-input");t.type="color";const a=e=>{t.value=Dt(e)??"#000000"};a(r),t.addEventListener("change",()=>l(e,t.value)),!0===o.live&&t.addEventListener("input",()=>l(e,t.value)),p=t,h={key:e,control:t,read:()=>t.value,write:a};break}case"opacity":{const t=Nt(n,"input","oac-range");t.type="range",t.min="0",t.max="100",t.step="1";const a=Nt(n,"output","oac-out"),i=e=>Math.round(100*("number"==typeof e?Math.min(1,Math.max(0,e)):0)),s=e=>{t.value=String(i(e)),a.textContent=`${i(e)}%`};s(r),t.addEventListener("input",()=>{a.textContent=`${t.value}%`,!0===o.live&&l(e,Number(t.value)/100)}),t.addEventListener("change",()=>l(e,Number(t.value)/100));const u=Nt(n,"span","oac-opacity");return u.appendChild(t),u.appendChild(a),c(t,d),p=u,h={key:e,control:t,read:()=>Number(t.value)/100,write:s},{ctl:p,b:h}}case"select":{const{wrap:t,select:s}=function(e){const t=Nt(e,"span","oac-select"),o=Nt(e,"select");t.appendChild(o);const n=Nt(e,"span","oac-chev");return n.innerHTML=E("chevron-down"),t.appendChild(n),{wrap:t,select:o}}(n),u=a.options??[],b=t=>{s.innerHTML="";const a=u.slice(),r="string"==typeof t?t:void 0===t?void 0:String(t);void 0===r||""===r||a.some(e=>e.value===r)||a.push({value:r,label:ee(o,"Custom")});for(const t of a){const o=Nt(n,"option",void 0,t.label);o.value=t.value;const a=i(e,t.value);null!==a&&(o.disabled=!0,o.title=a),s.appendChild(o)}s.value=void 0===r||""===r?a[0]?.value??"":r};return b(r),s.addEventListener("change",()=>l(e,s.value)),c(s,d),p=t,h={key:e,control:s,read:()=>s.value,write:b},{ctl:p,b:h}}case"multiline":{const t=Nt(n,"textarea","oac-input--multi");t.rows=3,t.setAttribute("spellcheck","false");const o=e=>{t.value=null==e?"":String(e)};o(r),t.addEventListener("change",()=>l(e,t.value)),p=t,h={key:e,control:t,read:()=>t.value,write:o};break}default:{const t=Nt(n,"input");t.type="text",t.setAttribute("spellcheck","false");const o=e=>{t.value=null==e?"":String(e)};o(r),t.addEventListener("change",()=>l(e,t.value)),p=t,h={key:e,control:t,read:()=>t.value,write:o};break}}return c(p,d),{ctl:p,b:h}}let p;for(const s of t){void 0!==s.group&&s.group!==p&&e.appendChild(Nt(n,"div","oac-head",s.group)),p=s.group??p;const t=Nt(n,"div","oac-row");t.dataset.key=s.key;const l=Nt(n,"label","oac-row__label",s.label);if(void 0!==s.tooltip&&""!==s.tooltip){const e=Nt(n,"span","oac-help","?");e.title=s.tooltip,e.tabIndex=0,e.setAttribute("role","note"),e.setAttribute("aria-label",s.tooltip),l.appendChild(e)}if("custom"===s.kind){const a=void 0===o.custom?null:o.custom(s,t);if(null===a)continue;t.appendChild(Nt(n,"span","oac-row__sw")),t.appendChild(l);const i=Nt(n,"div","oac-row__ctl");i.appendChild(a),t.appendChild(i),e.appendChild(t);continue}if("colorPair"===s.kind&&void 0!==s.pair){const c=s.pair,p=i(c.up.key),h=i(c.down.key);if(null!==p&&null!==h&&(t.classList.add("oac-row--off"),t.title=p),void 0!==c.enabled){const e=d(c.enabled.key,"boolean",s,o.values[c.enabled.key]);e.ctl.classList.add("oac-row__sw"),e.ctl.id=r(c.enabled.key),l.htmlFor=e.ctl.id,a.push(e.b),t.appendChild(e.ctl)}else t.appendChild(Nt(n,"span","oac-row__sw"));t.appendChild(l);const u=Nt(n,"div","oac-row__ctl");for(const e of[c.up,c.down]){const t=d(e.key,"color",s,o.values[e.key]);t.ctl.id=r(e.key),t.ctl.title=t.ctl.disabled?`${e.label}: ${t.ctl.title}`:e.label,t.ctl.setAttribute("aria-label",`${s.label} ${e.label}`),a.push(t.b),u.appendChild(t.ctl)}void 0===c.enabled&&(l.htmlFor=r(c.up.key)),t.appendChild(u),e.appendChild(t);continue}const c=d(s.key,s.kind,s,o.values[s.key]),h=i(s.key);if(null!==h&&(t.classList.add("oac-row--off"),t.title=h),c.b.control.id=r(s.key),l.htmlFor=c.b.control.id,a.push(c.b),"boolean"===s.kind)c.ctl.classList.add("oac-row__sw"),t.appendChild(c.ctl),t.appendChild(l);else if("multiline"===s.kind)t.classList.add("oac-row--block"),t.appendChild(l),t.appendChild(c.ctl);else{t.appendChild(Nt(n,"span","oac-row__sw")),t.appendChild(l);const e=Nt(n,"div","oac-row__ctl");e.appendChild(c.ctl),t.appendChild(e)}e.appendChild(t)}return{el:e,sync:e=>{const t=n.activeElement;for(const o of a)o.control!==t&&o.key in e&&o.write(e[o.key])},values:()=>{const e={};for(const t of a)e[t.key]=t.read();return e},focusFirst:()=>{for(const e of a)if(!e.control.disabled)return e.control.focus(),!0;return!1}}}const Yt=[0,.236,.382,.5,.618,.786,1,1.272,1.414,1.618,2,2.618,3.618,4.236],Jt=(e,t)=>e.some(e=>Math.abs(e.ratio-t)<=1e-6);function Xt(e,t,o={}){const n=e.document,a=o.ids??e.draw.selection(),{drawings:i,schema:r}=function(e,t){const o=[];for(const n of t){const t=e.draw.get(n);void 0!==t&&B(t.tool).fields.some(e=>"levels"===e.kind)&&o.push(t)}return{drawings:o,schema:0===o.length?null:B(o[0].tool)}}(e,a);if(null===r)return e.toast(ee(e,"Select a drawing with levels first"),"info"),{el:n.createElement("div"),close:()=>{},isOpen:()=>!1};const s=i[0],l=function(e){try{return I(e)}catch{return null}}(s.tool),c=r.fields.find(e=>"levels"===e.kind),d=r.fields.find(e=>"style.showLabels"===e.path),p=c?.path??"style.levels",h=l?.defaultStyle?.levels??R,u="gann-fan"===(b=s.tool)?F:"fib-time-zone"===b?e=>String(e):U;var b;const g=()=>{const e=H(s,p);return Array.isArray(e)?V(e):V(h)},f=()=>{const e=H(s,"style.showLabels");return void 0===e?!0===l?.defaultStyle?.showLabels:!0===e};let m=g();function v(t){const o=[];for(const n of i){const a=e.draw.get(n.id);if(void 0===a)continue;const i=K(a,t,r);Object.keys(i).length>0&&o.push({id:n.id,patch:i})}o.length>0&&e.draw.updateMany(o)}const w=()=>v({[p]:V(m)}),y=Nt(n,"div","oac-panel oac-levels");y.setAttribute("role","dialog"),y.setAttribute("aria-label",ee(e,"Levels")),y.tabIndex=-1,Ft(y);const x=Nt(n,"div","oac-levels__head");x.appendChild(Nt(n,"b","oac-levels__title",ee(e,"Levels")));let _=null;if(void 0!==d){const t=Nt(n,"label","oac-levels__labels");_=Nt(n,"input"),_.type="checkbox",_.checked=f(),_.dataset.path=d.path;const o=_;o.addEventListener("change",()=>v({[d.path]:o.checked})),t.appendChild(o),t.appendChild(Nt(n,"span",void 0,ee(e,"Show labels"))),x.appendChild(t)}x.appendChild(Bt(n,{label:ee(e,"Close"),icon:"close",iconOnly:!0,onClick:()=>L.close()})),y.appendChild(x);const k=Nt(n,"div","oac-levels__rows");function C(){k.innerHTML="",0!==m.length?m.forEach((t,o)=>k.appendChild(function(t,o){const a=Nt(n,"div","oac-levels__row"+(!1===t.enabled?" is-off":"")),i=Nt(n,"input");i.type="checkbox",i.checked=!1!==t.enabled,i.setAttribute("aria-label",ee(e,"Enabled")),i.addEventListener("change",()=>{i.checked?delete m[o].enabled:m[o].enabled=!1,a.classList.toggle("is-off",!i.checked),w()}),a.appendChild(i);const r=Nt(n,"input");r.type="number",r.step="0.001",r.value=String(t.ratio),r.setAttribute("aria-label",ee(e,"Ratio")),r.addEventListener("change",()=>{const e=Number(r.value);""!==r.value.trim()&&Number.isFinite(e)?(m[o].ratio=e,void 0===m[o].label&&(c.placeholder=u(e)),w()):r.value=String(m[o].ratio)}),a.appendChild(r);const l=Nt(n,"input");l.type="color",l.value=Dt(t.color)??Dt(s.style.color)??Dt(W(t.ratio))??q,l.setAttribute("aria-label",ee(e,"Color")),l.addEventListener("change",()=>{m[o].color=l.value,w()}),a.appendChild(l);const c=Nt(n,"input");c.type="text",c.value=t.label??"",c.placeholder=u(t.ratio),c.setAttribute("aria-label",ee(e,"Label")),c.setAttribute("spellcheck","false"),c.addEventListener("change",()=>{const e=c.value.trim();""===e?delete m[o].label:m[o].label=e,w()}),a.appendChild(c);const d=Nt(n,"button","oac-levels__x");return d.type="button",d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M3 3l10 10M13 3 3 13"/></svg>',d.setAttribute("aria-label",ee(e,"Remove level")),d.addEventListener("click",e=>{e.stopPropagation(),m.splice(o,1),C(),w()}),a.appendChild(d),a}(t,o))):k.appendChild(Nt(n,"div","oac-empty",ee(e,"No levels. Add one, or reset to the defaults.")))}y.appendChild(k),C();const $=Nt(n,"div","oac-levels__foot");$.appendChild(Bt(n,{label:ee(e,"Add level"),icon:"plus",onClick:()=>{const e=function(e){for(const t of Yt)if(!Jt(e,t))return t;let t=0;for(const o of e)Number.isFinite(o.ratio)&&(t=Math.max(t,o.ratio));return t+1}(m),t={ratio:e},o=W(e);o!==q&&(t.color=o),m.push(t),C(),w()}})),$.appendChild(Nt(n,"span","oac-spacer")),$.appendChild(Bt(n,{label:ee(e,"Reset"),onClick:()=>{m=V(h),C(),w()}})),y.appendChild($);const S=e.chart.on("draw:update",()=>{if(!L.isOpen())return;if(void 0===e.draw.get(s.id))return void L.close();const t=g();JSON.stringify(t)===JSON.stringify(m)||y.contains(n.activeElement)||(m=t,C()),null!==_&&_!==n.activeElement&&(_.checked=f())}),A=e.chart.on("draw:remove",()=>{L.isOpen()&&void 0===e.draw.get(s.id)&&L.close()}),L=Vt(e,y,void 0===t?{placement:"below",dismissOnOutside:!0}:{anchor:t,placement:"below"},()=>{});void 0===t&&Gt(e.root,y,{point:qt(e.root,e.chart,i)});const O=L.close;return{el:y,isOpen:L.isOpen,close:()=>{S(),A(),O()}}}function Qt(e,t){const o=!0===e.bold?"700 ":"";return`${!0===e.italic?"italic ":""}${o}${t}px ${void 0===e.fontFamily||""===e.fontFamily?"ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif":e.fontFamily}`}function eo(e,t,o,n){const a=o.split("\n");if(!0!==t.wrap)return a;const i=[];for(const t of a){const o=t.split(/\s+/).filter(e=>""!==e);if(0===o.length){i.push("");continue}let a=o[0];for(let t=1;t<o.length;t++){const r=`${a} ${o[t]}`;e(r)>n?(i.push(a),a=o[t]):a=r}i.push(a)}return i}function to(e){let t="",o=!1;const n=e=>{for(const a of Array.from(e.childNodes??[])){if(3===a.nodeType){t+=a.nodeValue??"",o=!1;continue}if(1!==a.nodeType)continue;const e=String(a.nodeName).toUpperCase();"BR"!==e?("DIV"!==e&&"P"!==e||""===t||t.endsWith("\n")||(t+="\n"),o=!1,n(a)):(t+="\n",o=!0)}};return n(e),o?t.slice(0,-1):t}function oo(e){return e.panes()[0]?.element.parentElement??null}function no(e){return void 0!==e&&!0===B(e.tool).textIsContent}function ao(e,t,o){return e.toast(t,"info"),o?.(!1),{el:e.document.createElement("div"),close:()=>{},isOpen:()=>!1,commit:()=>{},cancel:()=>{}}}function io(e,t,o={}){const n=e.document,{chart:a,draw:i}=e,r=i.selection(),s=o.id??(1===r.length?r[0]:void 0),l=void 0===s?void 0:i.get(s);if(!no(l))return ao(e,ee(e,"Select a text drawing first"),o.onDone);const c=(()=>{try{return I(l.tool)}catch{return null}})(),d=void 0!==c?.defaultText?.value&&""!==c.defaultText.value?c.defaultText.value:ee(e,"Text"),p=l.text??{value:""},h=p.fontSize??14,u=Qt(p,h),b=function(e,t,o){let n=null;try{const t=e.createElement("canvas");n="function"==typeof t.getContext?t.getContext("2d"):null}catch{n=null}if(null!==n&&"function"==typeof n.measureText){n.font=t;const e=n;return t=>e.measureText(t).width}return e=>e.length*o*.6}(n,u,h),g=function(e,t,o,n="Text"){const a=t.points[0];if(void 0===a)return null;const i=e.timeToCoordinate(a.time),r=e.priceToCoordinate(a.price,t.paneIndex);if(!Number.isFinite(i)||null===r||!Number.isFinite(r))return null;const s=t.text??{value:""},l=s.fontSize??14,c=Qt(s,l),d=eo(o,s,void 0===s.value||""===s.value?n:s.value,s.wrapWidth??220);let p=0;for(const e of d)p=Math.max(p,o(e));const h=1.35*l,u=d.length*h+10,b=s.valign??"top";return{x:i,y:"middle"===b?r-u/2:"bottom"===b?r-u:r,width:p+10,height:u,lineHeight:h,lines:d,font:c,size:l}}(a,l,b,d),f=oo(a);if(null===g||null===f)return ao(e,ee(e,"That text is off the chart"),o.onDone);const m=Kt(e.root,f),v=Nt(n,"div","oac-textedit");v.setAttribute("contenteditable","plaintext-only"),v.setAttribute("spellcheck","false"),v.setAttribute("role","textbox"),v.setAttribute("aria-multiline","true"),v.setAttribute("aria-label",ee(e,"Drawing text")),v.tabIndex=0;const w=v.style;w.left=`${Math.round(g.x+m.left)}px`,w.top=`${Math.round(g.y+m.top)}px`,w.font=u,w.lineHeight=`${g.lineHeight}px`,w.color=p.color??l.style.color??"inherit",w.textAlign=p.align??"left",w.minWidth=`${Math.ceil(g.width)}px`,w.minHeight=`${Math.ceil(g.height)}px`;const y=!0===p.wrap,x=p.wrapWidth??220;w.whiteSpace=y?"pre-wrap":"pre",y&&(w.width=`${Math.ceil(g.width)}px`);const _=p.value??"";v.textContent=_;let k=!1;const C=e=>{k||(k=!0,A.close(),o.onDone?.(e))},$=()=>{if(k)return;const e=to(v),t=e!==_;t&&void 0!==i.get(l.id)&&i.update(l.id,{text:{...i.get(l.id)?.text??{value:""},value:e}}),C(t)},S=()=>C(!1);for(const e of["pointerdown","pointermove","pointerup","click","dblclick","contextmenu","keyup","keypress"])v.addEventListener(e,e=>{e.stopPropagation()});v.addEventListener("keydown",e=>{const t=e.key;if("Tab"!==t&&e.stopPropagation(),"Escape"===t)return e.preventDefault(),void S();"Enter"===t&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),$())}),v.addEventListener("blur",()=>$()),y&&v.addEventListener("input",()=>{const e=eo(b,p,to(v)||d,x);let t=0;for(const o of e)t=Math.max(t,b(o));w.width=`${Math.ceil(t+10)}px`});const A=Vt(e,v,{placement:"below",modal:!1,dismissOnOutside:!1,initialFocus:v},S);try{const e=n.defaultView;if(null!==e&&"function"==typeof e.getSelection&&"function"==typeof n.createRange){const t=n.createRange();t.selectNodeContents(v),t.collapse(!1);const o=e.getSelection();o?.removeAllRanges(),o?.addRange(t)}}catch{}return{el:v,isOpen:A.isOpen,close:()=>$(),commit:$,cancel:S}}function ro(e){const t=e.map(e=>B(e));if(0===t.length)return{fields:[]};const[o,...n]=t,a=o.fields.filter(e=>n.every(t=>t.fields.some(t=>t.path===e.path&&t.kind===e.kind)));return t.every(e=>!0===e.textIsContent)?{fields:a,textIsContent:!0}:{fields:a}}const so={"style.lineWidth":1.5,"style.lineStyle":"solid","style.fillOpacity":.12,"text.fontSize":14,"text.wrapWidth":220,"text.backgroundOpacity":1,"text.align":"left","text.valign":"top","text.position":"inside"};function lo(e,t,o){const n={};for(const a of t.fields){const[t,i]=a.path.split("."),r="style"===t?e?.defaultStyle:"text"===t?e?.defaultText:void 0;let s=void 0===r||void 0===i?void 0:r[i];void 0===s&&(s=so[a.path]),void 0===s&&"boolean"===a.kind&&(s=!1),void 0===s&&"style.color"===a.path&&(s=o),void 0!==s&&(n[a.path]=s)}return n}function co(e){try{return I(e)}catch{return null}}const po=(e,t)=>e.length===t.length&&e.every((e,o)=>e===t[o]);function ho(e,t,o={}){const{draw:n,chart:a}=e,i=e.document;void 0!==o.ids&&o.ids.length>0&&!po(o.ids,n.selection())&&n.select(o.ids.slice());let r=n.selection().slice();const s=()=>r.map(e=>n.get(e)).filter(e=>void 0!==e);let l=s();if(0===l.length)return e.toast(ee(e,"Select a drawing first"),"info"),{el:i.createElement("div"),close:()=>{},isOpen:()=>!1};let c=ro(l.map(e=>e.tool)),d=co(l[0].tool),p=null;const h=()=>1===l.length?ee(e,`schema.drawing.${l[0].tool}.name`,{},d?.name??l[0].tool):ee(e,"{count} drawings",{count:l.length}),u=()=>function(e,t,o,n){const a=lo(o,t,n);for(const[o,n]of Object.entries(G(e,t)))void 0!==n&&(a[o]=n);for(const e of["text.color","style.fillColor","text.borderColor"])void 0===a[e]&&t.fields.some(t=>t.path===e)&&(a[e]=a["style.color"]);return a}(l[0],c,d,e.chartTheme.lineColor);function b(e){const t=[];for(const o of l){const a=n.get(o.id);if(void 0===a)continue;const i=K(a,e,c);Object.keys(i).length>0&&t.push({id:o.id,patch:i})}t.length>0&&n.updateMany(t)}const g=Ht(i,{translate:e.translate,title:h(),className:"oac-props",onClose:()=>C.close()}),f=Nt(i,"div","oac-props__tools");f.setAttribute("role","toolbar"),f.setAttribute("aria-label",ee(e,"Drawing actions")),g.el.insertBefore(f,g.body);const m=Nt(i,"div","oac-props__pane");function v(){f.innerHTML="";const t=l[0],o=!0===t.locked,a=!1===t.visible,s=t.zIndex<0,c=(e,t,o)=>{const n=Bt(i,{...e,iconOnly:!0});n.dataset.act=t,void 0!==o&&n.setAttribute("aria-pressed",o?"true":"false"),f.appendChild(n)},d=()=>{f.appendChild(Nt(i,"span","oac-sep"))};c({label:ee(e,o?"Unlock":"Lock"),icon:o?"lock":"unlock",onClick:()=>{n.updateMany(r.map(e=>({id:e,patch:{locked:!o}})))}},"lock",o),c({label:ee(e,a?"Show":"Hide"),icon:a?"eye-off":"eye",onClick:()=>{n.updateMany(r.map(e=>({id:e,patch:{visible:a}})))}},"visible",a),d(),c({label:ee(e,"Bring to front"),icon:"front",onClick:()=>{for(const e of r)n.bringToFront(e)}},"front"),c({label:ee(e,"Send to back"),icon:"back",onClick:()=>{for(const e of r)n.sendToBack(e)}},"back"),c({label:ee(e,"In front of the series"),svg:zt("M3 4h10M8 14V6M5 9l3-3 3 3"),onClick:()=>{for(const e of r)n.bringAboveSeries(e)}},"above",!s),c({label:ee(e,"Behind the series"),svg:zt("M3 12h10M8 2v8M5 7l3 3 3-3"),onClick:()=>{for(const e of r)n.sendBehindSeries(e)}},"behind",s),d(),c({label:ee(e,"Duplicate"),icon:"duplicate",chord:"Ctrl+D",onClick:()=>{n.duplicate(r)}},"duplicate"),c({label:ee(e,"Delete"),icon:"trash",chord:"Del",variant:"danger",onClick:()=>{n.removeMany(r)}},"delete")}function w(){m.innerHTML="";const t=It(c.fields,{translate:e.translate,scope:`drawing.${l[0].tool}`});if(0===t.length)return m.appendChild(Nt(i,"div","oac-empty",ee(e,"These drawings share no settings."))),void(p=null);if(p=Zt(m,t,{values:u(),translate:e.translate,idPrefix:"oac-props",onChange:(e,t)=>{b({[e]:t}),p?.sync(u())},custom:t=>{if("levels"!==t.custom)return null;const o=Bt(i,{label:ee(e,"Edit levels..."),onClick:t=>{Xt(e,t.currentTarget,{ids:r})}});return o.dataset.act="edit-levels",o}}),!0===c.textIsContent&&1===l.length){const t=m.querySelector('[data-key="text.value"]');if(null!==t){const o=Bt(i,{label:ee(e,"Edit on chart"),icon:"text",onClick:()=>{io(e,0,{id:l[0].id})}});o.dataset.act="edit-text",t.appendChild(o)}}}function y(){if(!C.isOpen())return;const e=n.selection().slice();if(0!==e.length){if(po(e,r))return l=s(),0===l.length?void C.close():(p?.sync(u()),void v());r=e,l=s(),0!==l.length?(c=ro(l.map(e=>e.tool)),d=co(l[0].tool),g.setTitle(h()),v(),w()):C.close()}else C.close()}g.body.appendChild(m),v(),w(),g.lead.appendChild(Bt(i,{label:ee(e,"Restore defaults"),onClick:()=>{const t={},o=lo(d,{fields:c.fields},e.chartTheme.lineColor);for(const e of c.fields){if("levels"===e.kind)continue;const[n,a]=e.path.split("."),i="style"===n?d?.defaultStyle:"text"===n?d?.defaultText:void 0,r=void 0===i||void 0===a?void 0:i[a];t[e.path]=void 0===r?void 0:o[e.path]}b(t),p?.sync(u())}})),g.actions.appendChild(Bt(i,{label:ee(e,"Done"),variant:"primary",onClick:()=>C.close()}));const x=[a.on("draw:update",y),a.on("draw:select",y),a.on("draw:remove",y)],_=Vt(e,g.el,void 0===t?{placement:"below",dismissOnOutside:!0}:{anchor:t,placement:"below"},()=>{});void 0===t&&Gt(e.root,g.el,{point:qt(e.root,a,l)});let k=!1;const C={el:g.el,isOpen:_.isOpen,close:()=>{if(!k){k=!0;for(const e of x)e();_.close(),o.onClose?.()}}};return C}function uo(e,t,o={}){const{chart:n}=e,a=e.document,i=r(),s=Ht(a,{translate:e.translate,title:ee(e,"Indicators"),className:"oac-pick",onClose:()=>m.close()}),l=Nt(a,"input","oac-pick__find");l.type="search",l.placeholder=ee(e,"Search indicators"),l.setAttribute("aria-label",ee(e,"Search indicators")),l.setAttribute("spellcheck","false");const c=Nt(a,"div","oac-pick__findwrap");c.appendChild(l);const d=Nt(a,"div","oac-pick__list");d.setAttribute("role","listbox"),d.setAttribute("aria-label",ee(e,"Indicators")),s.body.appendChild(c),s.body.appendChild(d),s.actions.appendChild(Bt(a,{label:ee(e,"Done"),variant:"primary",onClick:()=>m.close()}));let p=[],h=-1;const u=e=>n.indicators().filter(t=>t.indicatorId===e).length,b=e=>{0!==p.length?(h=Math.max(0,Math.min(p.length-1,e)),p.forEach((e,t)=>{e.classList.toggle("is-active",t===h),e.setAttribute("aria-selected",t===h?"true":"false")})):h=-1},g=t=>{const a=n.addIndicator(t.id);e.toast(ee(e,"Added {name}",{name:a.name}),"success"),o.onAdd?.(a),!0!==o.closeOnAdd?(f(),l.focus()):m.close()};function f(){const t=l.value;if(d.innerHTML="",p=[],0===i.length)return void d.appendChild(Nt(a,"div","oac-empty",ee(e,"No indicators are registered. Import the indicators tier to fill this list.")));const o=function(e,t){const o=t.trim().toLowerCase();return e.filter(e=>""===o||e.name.toLowerCase().includes(o)||e.id.toLowerCase().includes(o)||(e.category??"").toLowerCase().includes(o)).sort((e,t)=>e.name.localeCompare(t.name))}(i.map(t=>({...t,name:ee(e,`schema.indicator.${t.id}.name`,{},t.name),category:void 0===t.category?void 0:ee(e,`schema.indicator.category.${t.category}`,{},t.category)})),t);if(0!==o.length){for(const[t,n]of function(e){const t=new Map;for(const o of e){const e=o.category??"Other",n=t.get(e);void 0===n?t.set(e,[o]):n.push(o)}return Array.from(t.entries()).sort((e,t)=>e[0].localeCompare(t[0]))}(o)){d.appendChild(Nt(a,"div","oac-head","Other"===t?ee(e,"Other"):t));for(const t of n){const o=Nt(a,"button","oac-pick__row");o.type="button",o.setAttribute("role","option"),o.dataset.id=t.id,o.appendChild(Nt(a,"span","oac-pick__name",t.name));const n=u(t.id);if(n>0){const t=Nt(a,"span","oac-pick__count",1===n?ee(e,"on chart"):ee(e,"on chart x{count}",{count:n}));t.setAttribute("aria-label",1===n?ee(e,"one instance on the chart"):ee(e,"{count} instances on the chart",{count:n})),o.appendChild(t)}o.addEventListener("click",e=>{e.stopPropagation(),g(t)}),d.appendChild(o),p.push(o)}}b(h<0?0:h)}else d.appendChild(Nt(a,"div","oac-empty",ee(e,"No match")))}l.addEventListener("input",()=>{h=0,f()}),l.addEventListener("keydown",e=>{const t=e.key;if("ArrowDown"===t)e.preventDefault(),b(h+1);else if("ArrowUp"===t)e.preventDefault(),b(h-1);else if("Enter"===t){e.preventDefault();const t=p[h],o=t?.dataset.id,n=i.find(e=>e.id===o);void 0!==n&&g(n)}}),f();const m=Vt(e,s.el,void 0===t?{placement:"center",modal:!0,initialFocus:l}:{anchor:t,placement:"below",initialFocus:l},()=>{});return m}function bo(e){const t={};for(const o of e)t[o.key]=o.default;return t}function go(e,t){return e.toast(t,"info"),{el:e.document.createElement("div"),close:()=>{},isOpen:()=>!1}}function fo(e,t,o={}){const n=e.document,a=function(e,t,o){const n=e.chart.indicators(),a=o.instanceId??t?.dataset.instanceId;if(void 0!==a){const t=n.find(e=>e.id===a)??null;return null===t?{inst:null,why:ee(e,"That indicator is no longer on the chart")}:{inst:t,why:null}}return 1===n.length?{inst:n[0],why:null}:{inst:null,why:0===n.length?ee(e,"No indicator on the chart to configure"):ee(e,"Pick an indicator from the legend first")}}(e,t,o);if(null===a.inst)return go(e,a.why??ee(e,"No indicator to configure"));const i=a.inst,r=s(i.indicatorId),d=[];r.inputs.length>0&&d.push({id:"inputs",label:ee(e,"Inputs"),icon:E("settings"),inputs:r.inputs});const p=l(r);if(p.length>0&&d.push({id:"style",label:ee(e,"Style"),icon:zt("M3 13c2.5 0 3.5-1.5 4-3.5M7.5 9.5 13 4a1.4 1.4 0 0 1 2 2l-5.5 5.5"),inputs:p}),0===d.length)return go(e,ee(e,"{name} has nothing to configure",{name:i.name}));const h=i.settings(),u=new Set;let b=d.some(e=>e.id===o.tab)?o.tab:d[0].id,g=null,f=!1;const m=()=>({...c(r),...bo(p),...i.settings()}),v=e=>{for(const t of Object.keys(e))u.add(t);i.setSettings(e),o.onChange?.(i)},w=Ht(n,{translate:e.translate,title:ee(e,"{name} settings",{name:i.name}),className:"oac-indset",onClose:()=>k()}),y=Nt(n,"div","oac-indset__pane");if(d.length>1){const e=Wt(n,d.map(e=>({id:e.id,label:e.label,icon:e.icon})),b,"row",e=>{b=e,x()});w.body.appendChild(e.el)}function x(){const t=d.find(e=>e.id===b)??d[0];y.innerHTML="",g=Zt(y,Mt(t.inputs,{translate:e.translate,scope:`indicator.${r.id}`}),{values:m(),translate:e.translate,idPrefix:`oac-ind-${i.id}`,live:!0,onChange:(e,t)=>{v({[e]:t}),g?.sync(m())}})}w.body.appendChild(y),x(),w.lead.appendChild(Bt(n,{label:ee(e,"Defaults"),onClick:()=>{const e=d.find(e=>e.id===b)??d[0];v(bo(e.inputs)),x()}})),w.actions.appendChild(Bt(n,{label:ee(e,"Cancel"),onClick:()=>k()})),w.actions.appendChild(Bt(n,{label:ee(e,"OK"),variant:"primary",onClick:()=>C()}));const _=Vt(e,w.el,{placement:"center",modal:!0},()=>k());function k(){_.isOpen()&&(!function(){if(f||0===u.size)return;const e={};for(const t of u)e[t]=h[t];u.clear(),i.setSettings(e),o.onChange?.(i)}(),_.close(),o.onClose?.(!1))}function C(){_.isOpen()&&(f=!0,_.close(),o.onClose?.(!0))}return{el:w.el,isOpen:_.isOpen,close:()=>C()}}const mo={price:"M5 2v12M3 5h4v6H3zM11 2v12M9 4h4v7H9z",readout:"M2 4h8M2 8h12M2 12h9",axes:"M3 2v11h11M3 6h2M3 10h2M7 13v-2M11 13v-2",appearance:"M2 3h12v10H2zM2 8h12M7 3v10",trading:"M2 12l4-4 3 2 5-6M11 4h3v3M2 14h12"};function vo(e,t,o={}){const{chart:n}=e,a=e.document,i=d(n).filter(e=>e.inputs.length>0),r=p(n),s=new Set;let l=i.some(e=>e.id===o.tab)?o.tab:i[0]?.id??"price",c=null,u=!1;const b=e=>{for(const t of Object.keys(e))s.add(t);h(n,e),o.onApply?.(e)},g=Ht(a,{translate:e.translate,title:ee(e,"Chart settings"),className:"oac-settings",onClose:()=>_()}),f=Nt(a,"div","oac-settings__main"),m=Nt(a,"div","oac-settings__pane");g.body.appendChild(f);const v=Wt(a,i.map(t=>({id:t.id,label:ee(e,`schema.settings.tab.${t.id}`,{},t.label),icon:zt(mo[t.id]??"")})),l,"rail",e=>{l=e,w()});function w(){const t=i.find(e=>e.id===l);m.innerHTML="",c=null,void 0!==t?c=Zt(m,Mt(t.inputs,{translate:e.translate,scope:"settings"}),{values:p(n),translate:e.translate,idPrefix:"oac-cset",live:!0,unavailable:(t,a)=>"statusLine.openInterest"===t&&!1===n.hasOpenInterest?ee(e,"Open interest is unavailable for this instrument."):o.unavailable?.(t,a)??null,onChange:(e,t)=>{b({[e]:t}),c?.sync(p(n))}}):m.appendChild(Nt(a,"div","oac-empty",ee(e,"Nothing to configure on this chart yet.")))}f.appendChild(v.el),f.appendChild(m),w(),g.lead.appendChild(Bt(a,{label:ee(e,"Restore this tab"),onClick:()=>{const e=i.find(e=>e.id===l);void 0!==e&&(b(function(e){const t={};for(const o of e.inputs)"colorPair"===o.type?(t[o.up.key]=o.up.default,t[o.down.key]=o.down.default,void 0!==o.enabled&&(t[o.enabled.key]=o.enabled.default)):t[o.key]=o.default;return t}(e)),w())}})),g.actions.appendChild(Bt(a,{label:ee(e,"Cancel"),onClick:()=>_()})),g.actions.appendChild(Bt(a,{label:ee(e,"OK"),variant:"primary",onClick:()=>k()}));const y=n.on("data:context",w),x=Vt(e,g.el,{placement:"center",modal:!0,onClose:y},()=>_());function _(){x.isOpen()&&(!function(){if(u||0===s.size)return;const e={};for(const t of s){const o=r[t];void 0!==o&&(e[t]=o)}s.clear(),h(n,e),o.onApply?.(e)}(),x.close(),o.onClose?.(!1))}function k(){x.isOpen()&&(u=!0,x.close(),o.onClose?.(!0))}return{el:g.el,isOpen:x.isOpen,close:()=>k()}}const wo=[{value:"price",label:"Price"},{value:"indicator",label:"Study plot"},{value:"drawing",label:"Drawing level"},{value:"barCondition",label:"Candle condition"}],yo=(e,t,o)=>({key:e,label:t,kind:"select",options:o}),xo=(e,t,o)=>t?s(t.indicatorId).plots.filter(e=>void 0===o||(e.overlay?0:t.paneIndex)===o).map(o=>({value:o.key,label:ee(e,`schema.indicator.${t.indicatorId}.plot.${o.key}`,{},o.title)})):[];function _o(e,t){const o=[yo("kind",ee(e,"Source"),wo.map(t=>({...t,label:ee(e,`schema.alert.kind.${t.value}`,{},t.label)})))],n=e.chart.indicators(),a=e.chart.primaryBars(),i=a.length-1,r=(e,o)=>(void 0===t[e]&&(t[e]=o[0]?.value??""),String(t[e])),s=e=>e.map(e=>({value:e.id,label:`${n.indexOf(e)+1}: ${e.name}`})),l=t.kind;if("barCondition"===l){const t=u().map(t=>({value:t.id,label:ee(e,`schema.barCondition.${t.id}.title`,{},t.title)})),n=r("barConditionId",t);return o.push(yo("barConditionId",ee(e,"Candle condition"),t)),{source:{kind:l,id:n},controls:o,reason:t.some(e=>e.value===n)?void 0:ee(e,"Candle condition is unavailable")}}if("indicator"===l){const a=r("instanceId",s(n)),c=n.find(e=>e.id===a),d=xo(e,c),p=r("plotKey",d);o.push(yo("instanceId",ee(e,"Study"),s(n)),yo("plotKey",ee(e,"Plot"),d));const h=c?.values()[p]?.[i];return"value"in t||(t.value=h??void 0),{source:{kind:l,instanceId:a,plotKey:p,value:t.value,upperValue:t.upperValue},controls:o,reason:c?c.series(p)?void 0:ee(e,"Study plot is unavailable"):ee(e,"Study instance is unavailable"),hint:Number.isFinite(h)?void 0:ee(e,"The current plot value is unavailable. The alert waits for observed values.")}}if("drawing"===l){const t=e.draw.drawings().map((t,o)=>({value:t.id,label:`${ee(e,`schema.drawing.${t.tool}.name`,{},ze(t.tool))} (${o+1})`})),a=r("drawingId",t),i=e.draw.alertInfo(a),c=i.levels.map(e=>({value:e.id,label:e.title})),d=r("level",c);o.push(yo("drawingId",ee(e,"Drawing"),t),yo("level",ee(e,"Level"),c));const p=n.filter(t=>xo(e,t,i.paneIndex).length>0),h=s(p);0===i.paneIndex&&h.unshift({value:"",label:ee(e,"Price")});const u=r("inputInstanceId",h);o.push(yo("inputInstanceId",ee(e,"Compare with"),h));const b=p.find(e=>e.id===u);let g;if(u){const t=xo(e,b,i.paneIndex),n=r("inputPlotKey",t);g={instanceId:u,plotKey:n},o.push(yo("inputPlotKey",ee(e,"Input plot"),t))}const f=i.available?c.some(e=>e.value===d)?g?xo(e,b,i.paneIndex).some(e=>e.value===g.plotKey)?void 0:ee(e,"Select an input plot on the drawing pane"):0!==i.paneIndex?ee(e,"Select an input plot on the drawing pane"):void 0:ee(e,"Drawing level is unavailable"):i.reason;return{source:{kind:l,drawingId:a,level:d,...g?{input:g}:{}},controls:o,reason:f}}return"price"in t||(t.price=a[i]?.close),{source:{kind:"price",price:t.price,upperPrice:t.upperPrice},controls:o}}let ko=0;const Co=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/;function $o(e,t){if(void 0===e)return"";const o=b(e,t),n=e=>String(e).padStart(2,"0");return`${o.year}-${n(o.month)}-${n(o.day)}T${n(o.hour)}:${n(o.minute)}`}function So(e,t){if(e)return $o(e.expiresAt,t);const o=b(Math.floor(Date.now()/1e3),t),n=o.month-1+2,a=Math.min(o.day,new Date(Date.UTC(o.year,n+1,0)).getUTCDate()),i=Date.UTC(o.year,n,a,o.hour,o.minute)/1e3,r=i-g(i,t),s=i-g(r,t);return $o(s+g(s,t)===i?s:Math.max(r,s),t)}function Ao(e,t,o={}){const n=e.alerts,a=n?.list().find(e=>e.id===o.alertId),i=e.chart.timezone(),r=e.chart.getDataContext(),s=e=>JSON.stringify([e?.symbol,e?.exchange,e?.interval]),l=s(r),c=e.chart.primaryBars(),d=a?.source??o.source??{kind:"price",price:c[c.length-1]?.close};let p,h=!1,u=!1;const b="oac-alert-"+ ++ko,g=[];let m={...a,...d,..."drawing"===d.kind?{inputInstanceId:d.input?.instanceId,inputPlotKey:d.input?.plotKey}:{},..."barCondition"===d.kind?{barConditionId:d.id}:{},enabled:!a||"armed"===a.state,expiresAt:So(a,i)};function w(){if(!h){h=!0;for(const e of g.splice(0))e();T?.close(),o.onClose?.()}}const y=Ht(e.document,{translate:e.translate,title:ee(e,a?"Edit alert":"Create alert"),className:"oac-alert-editor",onClose:w});y.closeButton.textContent=ee(e,"Close"),y.closeButton.classList.remove("oac-btn--icon");const x=Nt(e.document,"p","oac-alert-context",[r?.symbol,r?.exchange,r?.interval].filter(Boolean).join(" / ")),_=Nt(e.document,"div"),k=Nt(e.document,"p","oac-alert-help"),C=Nt(e.document,"p","oac-alert-help",ee(e,"Bar close evaluates confirmed values. Intrabar touch can fire on a wick that is absent from final history.")),$=Nt(e.document,"p","oac-alert-error");$.setAttribute("role","status"),y.body.append(x,_,k,C,$);const S=Bt(e.document,{label:ee(e,"Save"),variant:"primary",onClick:function(){if(h)return;try{const t=L();if(t)throw new Error(t);m={...m,...p.values()};const o=m.condition,r="enteringRange"===o||"leavingRange"===o,s=_o(e,m).source,l={source:"price"===s.kind?{kind:"price",price:m.price,...r?{upperPrice:m.upperPrice}:{}}:"indicator"===s.kind?{...s,value:m.value,upperValue:r?m.upperValue:void 0}:s,condition:o,title:String(m.title??""),message:String(m.message??"")||void 0,policy:m.policy,repeat:m.repeat,cooldownSeconds:m.cooldownSeconds};a&&m.expiresAt===$o(a.expiresAt,i)||(l.expiresAt=function(e,t,o){if(""===t)return;const n=ee(e,"Enter an expiry date and time");if("string"!=typeof t||!Co.test(t))throw new Error(n);const[a,i]=t.split("T"),[r,s,l]=a.split("-").map(Number),[c,d]=i.split(":").map(Number),p=v(r,s,l,c,d,0,o);if(!Number.isFinite(p)||$o(p,o)!==t)throw new Error(n);return p}(e,m.expiresAt,i)),a&&!u||(l.state=m.enabled?"armed":"disabled"),a?n.update(a.id,l):n.add(l),w()}catch(t){$.textContent=t instanceof Error?t.message:ee(e,"Could not save this alert")}}});S.dataset.action="save-alert";const A=Bt(e.document,{label:ee(e,"Cancel"),onClick:w});function L(){return n?o.alertId&&!n.list().some(e=>e.id===o.alertId)?ee(e,"This alert was removed"):s(e.chart.getDataContext())!==l||a&&s(a.scope)!==l?ee(e,"The instrument context changed. Reopen the editor for the intended instrument."):_o(e,m).reason:ee(e,"Alerts are unavailable in this host")}function O(){const t=L();$.textContent=t??"",S.disabled=void 0!==t,k.textContent=_o(e,m).hint??""}A.dataset.action="cancel-alert",y.actions.append(A,S),function t(){const o=_o(e,m),n=f(o.source,m.condition);for(const e of n)e.key in m||(m[e.key]=e.default);m.condition=n.find(e=>"condition"===e.key).default;const a=Mt(n,{translate:e.translate,scope:"alert"}),r=a.find(e=>"expiresAt"===e.key);r&&(r.label+=` (${i})`),p=Zt(_,[...o.controls,...a],{idPrefix:b,values:m,translate:e.translate,preserveInvalidNumbers:!0,onChange:(o,n)=>{m={...m,...p.values(),[o]:n},"enabled"===o&&(u=!0);const a=["kind","instanceId","plotKey","drawingId","level","inputInstanceId"].includes(o);if("kind"===o)for(const e of["price","value","upperPrice","upperValue","condition"])delete m[e];if("instanceId"===o&&(delete m.plotKey,delete m.value,delete m.upperValue),"plotKey"===o&&(delete m.value,delete m.upperValue),"drawingId"===o&&(delete m.level,delete m.inputInstanceId,delete m.inputPlotKey),"inputInstanceId"===o&&delete m.inputPlotKey,"condition"===o||a){const n=null!==e.document.activeElement&&_.contains(e.document.activeElement);t(),n&&_.querySelector(`[data-key="${o}"] select`)?.focus()}O()}});const s=_.querySelector('[data-key="expiresAt"] input');s&&(s.type="datetime-local",s.step="60")}(),O();for(const t of["data:context","data:update","objects:change","alert:removed","alerts:restored"])g.push(e.chart.on(t,O));g.push(e.chart.on("destroy",w));const T=Vt(e,y.el,{anchor:t,modal:!0,placement:"center"},w);return{el:y.el,close:w,isOpen:()=>!h&&T.isOpen()}}function Lo(e,t,o={}){const n=e.alerts;let a=!1,i=!1;const r=[],s=new Map;function l(){if(!a){a=!0;for(const e of r.splice(0))e();v?.close(),o.onClose?.()}}const c=Ht(e.document,{translate:e.translate,title:ee(e,"Alerts"),className:"oac-alerts",onClose:l});c.closeButton.textContent=ee(e,"Close"),c.closeButton.classList.remove("oac-btn--icon");const d=Nt(e.document,"div","oac-alerts__list");d.setAttribute("role","list"),d.setAttribute("aria-label",ee(e,"Chart alerts"));const p=Nt(e.document,"p","oac-empty",ee(e,n?"No alerts. Create an alert for this chart.":"Alerts are unavailable in this host")),h=Nt(e.document,"span","oac-alert-context");h.setAttribute("role","status");const u=Bt(e.document,{label:ee(e,"Create alert"),variant:"primary",onClick:()=>{Ao(e)}});u.dataset.action="create-alert",u.disabled=!n,c.body.append(d,p),c.lead.appendChild(h),c.actions.appendChild(u);const b={armed:ee(e,"Armed"),triggered:ee(e,"Triggered"),expired:ee(e,"Expired"),disabled:ee(e,"Disabled")};function g(t){const o=t.source;if("price"===o.kind)return void 0===o.upperPrice?ee(e,"Price {price}",{price:o.price}):ee(e,"Price {price} to {upper}",{price:o.price,upper:o.upperPrice});if("barCondition"===o.kind)return m(o.id)?.title??ee(e,"Unavailable candle condition");if("drawing"===o.kind){const t=_o(e,{...o,inputInstanceId:o.input?.instanceId,inputPlotKey:o.input?.plotKey}),n=t.controls.find(e=>"drawingId"===e.key)?.options?.find(e=>e.value===o.drawingId)?.label;return`${n??ee(e,"Unavailable drawing")} / ${o.level??ee(e,"Default level")}`}const n=e.chart.indicators().find(e=>e.id===o.instanceId);return ee(e,void 0===o.upperValue?"{name} / {plot}: {value}":"{name} / {plot}: {value} to {upper}",{name:n?.name??ee(e,"Unavailable study"),plot:o.plotKey,value:o.value,upper:o.upperValue??""})}function f(){if(!a&&!i){i=!0;try{const t=n?.list()??[],o=new Set(t.map(e=>e.id));for(const[e,t]of s)o.has(e)||(t.el.remove(),s.delete(e));for(const o of t){let t=s.get(o.id);if(!t){const a=Nt(e.document,"div","oac-alerts__row");a.dataset.alertId=o.id,a.setAttribute("role","listitem");const i=Nt(e.document,"div","oac-alerts__summary"),r=Nt(e.document,"div","oac-alerts__status"),l=Nt(e.document,"div","oac-alerts__actions"),c=Bt(e.document,{label:ee(e,"Edit"),onClick:()=>{Ao(e,void 0,{alertId:o.id})}});c.dataset.action="edit-alert";const p=Bt(e.document,{label:ee(e,"Disable"),onClick:()=>{const e=n?.list().find(e=>e.id===o.id);"armed"===e?.state?n?.disable(o.id):n?.enable(o.id)}});p.dataset.action="toggle-alert";const h=Bt(e.document,{label:ee(e,"Delete"),onClick:()=>{n?.remove(o.id)}});h.dataset.action="delete-alert",l.append(c,p,h),a.append(i,r,l),d.appendChild(a),t={el:a,summary:i,status:r,toggle:p},s.set(o.id,t)}const a=[o.scope.symbol,o.scope.exchange,o.scope.interval].filter(Boolean).join(" / ");t.summary.textContent=`${o.title}\n${a}\n${g(o)}`,t.el.dataset.state=o.state;const i=n.availability(o.id);t.status.textContent=[b[o.state],"onBarClose"===o.policy?ee(e,"Bar close"):ee(e,"Intrabar touch"),"once"===o.repeat?ee(e,"Once"):ee(e,"Every match"),o.cooldownSeconds?ee(e,"{seconds}s cooldown",{seconds:o.cooldownSeconds}):"",void 0===o.expiresAt?"":ee(e,"Expires {time}",{time:$o(o.expiresAt,e.chart.timezone()).replace("T"," ")}),void 0===o.lastTriggeredAt?"":ee(e,"Last fired {time}",{time:$o(o.lastTriggeredAt,e.chart.timezone()).replace("T"," ")}),i.available?"":i.reason].filter(Boolean).join(" / "),t.toggle.textContent="armed"===o.state?ee(e,"Disable"):ee(e,"Enable"),t.toggle.setAttribute("aria-label",ee(e,"armed"===o.state?"Disable {name}":"Enable {name}",{name:o.title})),t.toggle.disabled="armed"!==o.state&&void 0!==o.expiresAt&&o.expiresAt<=Date.now()/1e3,t.toggle.title=t.toggle.disabled?ee(e,"Edit the expiry before enabling this alert"):""}p.hidden=t.length>0,h.textContent=ee(e,1===t.length?"{count} alert":"{count} alerts",{count:t.length})}finally{i=!1}}}for(const t of["alert:created","alert:updated","alert:removed","alert:triggered","alert:expired","alerts:restored","data:context","data:update","data:range","objects:change","replay:start","replay:stop"])r.push(e.chart.on(t,f));r.push(e.chart.on("destroy",l)),f();const v=Vt(e,c.el,{anchor:t,modal:!0,placement:"center"},l);return{el:c.el,close:l,isOpen:()=>!a&&v.isOpen()}}const Oo={kind:"separator"},To=e=>({kind:"header",label:e}),Eo={linear:"Linear",logarithmic:"Logarithmic",percentage:"Percent","indexed-to-100":"Indexed to 100"};function Mo(e,t,o){const n=e.panes()[t];return void 0===n?String(o):n.readoutScale().format(o)}function jo(e,t,o={}){const{chart:n,draw:a}=e,i=t.target,r=[],l=()=>{r.length>0&&"separator"!==r[r.length-1].kind&&r.push(Oo)};if("price-scale"===i.kind)return r.push(...function(e,t,o){const{chart:n}=e,a=()=>n.priceAxisState(t,o),i=a();if(null===i)return[];const r=[];r.push({id:"axis-autofit",label:ee(e,"Auto-fit to the data"),mark:"check",on:i.autoFit,keepOpen:!0,run:()=>{const e=a();null!==e&&n.setPriceAxisAutoFit(t,o,!e.autoFit)}}),r.push({id:"axis-invert",label:ee(e,"Invert"),mark:"check",on:i.inverted,keepOpen:!0,run:()=>{const e=a();null!==e&&n.setPriceAxisOptions(t,o,{inverted:!e.inverted})}}),r.push({id:"axis-lock",label:ee(e,"Pin price per bar"),mark:"check",on:i.lockRatio,keepOpen:!0,disabled:!i.scaled,note:i.scaled?void 0:ee(e,"nothing measured"),run:()=>{const i=a();null!==i&&(n.setPriceAxisLockRatio(t,o,!i.lockRatio)||e.toast(ee(e,"Nothing measured on this scale yet"),"info"))}}),r.push(Oo),r.push(To(ee(e,"Scale")));for(const a of w)r.push({id:`axis-mode-${a}`,label:ee(e,`schema.scaleMode.${a}`,{},Eo[a]),mark:"radio",on:i.mode===a,keepOpen:!0,run:()=>{n.setPriceAxisOptions(t,o,{mode:a})}});return r.push(Oo),r.push({id:"axis-move",label:"right"===i.side?ee(e,"Move the scale to the left"):ee(e,"Move the scale to the right"),disabled:!i.movable,note:i.movable?void 0:i.active?ee(e,"other side taken"):ee(e,"nothing on this side"),run:()=>{const o=a();null!==o&&(n.movePriceAxis(t,o.side,"right"===o.side?"left":"right")||e.toast(ee(e,"That side is already in use"),"info"))}}),r.push(Oo),r.push({id:"axis-settings",label:ee(e,"Axis settings..."),icon:"settings",run:()=>{vo(e,0,{tab:"axes"})}}),r}(e,t.paneIndex,i.scaleId??i.side??"right")),r;const c=o.onOrder;if(void 0!==c&&"time-scale"!==i.kind){const a=t.price,i={...e.symbol(),interval:e.interval()},s=t=>x(o.tradingCapabilities,{operation:"place",type:t,mode:o.tradingMode,...e.symbol()}),l=()=>{if(y(n))return ee(e,"Order entry is locked during replay");try{if(o.tradingLocked?.())return ee(e,"Order entry is locked by the host")}catch{return ee(e,"Order entry is unavailable")}},d=l(),p=(o,r)=>({id:`order-${o.toLowerCase()}-${r.toLowerCase()}`,label:"MARKET"===r?ee(e,"BUY"===o?"Buy market":"Sell market"):ee(e,"BUY"===o?"LIMIT"===r?"Buy limit at {price}":"Buy stop at {price}":"LIMIT"===r?"Sell limit at {price}":"Sell stop at {price}",{price:Mo(n,t.paneIndex,a)}),disabled:void 0!==d,note:d,run:()=>{if(n.isDestroyed)return;const d=e.symbol();if(d.symbol!==i.symbol||d.exchange!==i.exchange||e.interval()!==i.interval)return void e.status(ee(e,"The chart changed; reopen the menu before placing an order"),"error");const p=l();if(void 0!==p)return void e.status(p,"error");const h=s(r);h.supported?c({side:o,type:r,price:"MARKET"===r?null:a,paneIndex:t.paneIndex}):e.status(ee(e,"Order entry is unavailable: {reason}",{reason:h.reason}),"error")}}),h=(null===a?["MARKET"]:["MARKET","LIMIT","SL"]).map(e=>({type:e,result:s(e)})),u=h.filter(e=>e.result.supported);if(u.length>0){r.push(To(ee(e,"Trade")));for(const{type:e}of u)r.push(p("BUY",e),p("SELL",e))}else{const t=h[0].result;r.push({id:"trading-unavailable",label:ee(e,"Order entry is unavailable"),disabled:!0,note:t.supported?void 0:t.reason})}}const d=function(e){if("drawing"!==e.kind||null===e.id||!e.id.startsWith("draw:"))return null;const t=e.id.slice(5),o=t.indexOf("#");return o<0?t:t.slice(0,o)}(i),p=null===d?void 0:a.get(d);if(e.alerts&&"time-scale"!==i.kind){if(l(),p){const t=a.alertInfo(p.id);r.push({id:"alert-drawing",label:ee(e,"Create drawing alert..."),disabled:!t.available,note:t.reason,run:()=>{Ao(e,void 0,{source:{kind:"drawing",drawingId:p.id}})}})}else if("indicator"===i.kind&&i.instanceId){const o=n.indicators().find(e=>e.id===i.instanceId),a=o&&s(o.indicatorId).plots.find(e=>(e.overlay?0:o.paneIndex)===t.paneIndex&&(void 0===i.plotKey||e.key===i.plotKey));o&&a&&r.push({id:"alert-indicator",label:ee(e,"Create study alert..."),run:()=>{const i=o.values()[a.key],r=i?.[t.index??n.primaryBars().length-1];Ao(e,void 0,{source:{kind:"indicator",instanceId:o.id,plotKey:a.key,value:r??NaN}})}})}else 0===t.paneIndex&&null!==t.price&&Number.isFinite(t.price)&&r.push({id:"alert-create",label:ee(e,"Create alert at {price}...",{price:Mo(n,0,t.price)}),run:()=>{Ao(e,void 0,{source:{kind:"price",price:t.price}})}});r.push({id:"chart-alerts",label:ee(e,"Alerts..."),run:()=>{Lo(e)}})}if(void 0!==p){a.selection().includes(p.id)||a.select(p.id);const t=a.selection().includes(p.id)?a.selection().slice():[p.id];l(),r.push(...function(e,t,o){const{draw:n}=e,a=B(t.tool),i=[],r=!0===t.locked,s=!1===t.visible,l=t.zIndex<0,c=o.length>1;return i.push({id:"draw-props",label:ee(e,c?"Properties of the selection...":"Properties..."),icon:"settings",run:()=>{ho(e,void 0,{ids:o})}}),!c&&no(t)&&i.push({id:"draw-text",label:ee(e,"Edit text"),icon:"text",chord:"Enter",run:()=>{io(e,0,{id:t.id})}}),a.fields.some(e=>"levels"===e.kind)&&i.push({id:"draw-levels",label:ee(e,"Edit levels..."),run:()=>{Xt(e,void 0,{ids:o})}}),i.push(Oo),i.push({id:"draw-copy",label:c?ee(e,"Copy {count} drawings",{count:o.length}):ee(e,"Copy drawing"),icon:"copy",chord:"Ctrl+C",run:()=>{n.copy(o)}}),i.push({id:"draw-cut",label:c?ee(e,"Cut {count} drawings",{count:o.length}):ee(e,"Cut drawing"),chord:"Ctrl+X",disabled:r,note:r?ee(e,"locked"):void 0,run:()=>{n.cut(o)}}),i.push({id:"draw-duplicate",label:ee(e,"Duplicate"),icon:"duplicate",chord:"Ctrl+D",run:()=>{n.duplicate(o)}}),i.push(Oo),i.push({id:"draw-lock",label:ee(e,r?"Unlock":"Lock"),icon:r?"lock":"unlock",mark:"check",on:r,run:()=>{n.updateMany(o.map(e=>({id:e,patch:{locked:!r}})))}}),i.push({id:"draw-hide",label:ee(e,s?"Show":"Hide"),icon:s?"eye-off":"eye",mark:"check",on:s,run:()=>{n.updateMany(o.map(e=>({id:e,patch:{visible:s}})))}}),i.push(Oo),i.push(To(ee(e,"Order"))),i.push({id:"draw-front",label:ee(e,"Bring to front"),icon:"front",run:()=>{for(const e of o)n.bringToFront(e)}}),i.push({id:"draw-back",label:ee(e,"Send to back"),icon:"back",run:()=>{for(const e of o)n.sendToBack(e)}}),i.push({id:"draw-above",label:ee(e,"In front of the series"),icon:zt("M3 4h10M8 14V6M5 9l3-3 3 3"),mark:"radio",on:!l,run:()=>{for(const e of o)n.bringAboveSeries(e)}}),i.push({id:"draw-behind",label:ee(e,"Behind the series"),icon:zt("M3 12h10M8 2v8M5 7l3 3 3-3"),mark:"radio",on:l,run:()=>{for(const e of o)n.sendBehindSeries(e)}}),i.push(Oo),i.push({id:"draw-delete",label:c?ee(e,"Delete {count} drawings",{count:o.length}):ee(e,"Delete"),icon:"trash",chord:"Del",danger:!0,disabled:r,note:r?ee(e,"locked"):void 0,run:()=>{n.removeMany(o)}}),i}(e,p,t))}if("indicator"===i.kind&&void 0!==i.instanceId){const t=n.indicators().find(e=>e.id===i.instanceId);void 0!==t&&(l(),r.push({id:"ind-settings",label:ee(e,"{name} settings...",{name:t.name}),icon:"settings",run:()=>{fo(e,void 0,{instanceId:t.id})}}),r.push({id:"ind-visible",label:t.visible()?ee(e,"Hide {name}",{name:t.name}):ee(e,"Show {name}",{name:t.name}),icon:t.visible()?"eye":"eye-off",run:()=>{t.setVisible(!t.visible())}}),r.push({id:"ind-remove",label:ee(e,"Remove {name}",{name:t.name}),icon:"trash",danger:!0,run:()=>{n.removeIndicator(t.id)}}))}if("time-scale"!==i.kind){l(),r.push({id:"draw-paste",label:ee(e,"Paste"),icon:"paste",chord:"Ctrl+V",run:()=>{a.paste().then(t=>{0===t.length&&e.toast(ee(e,"Nothing to paste"),"info")})}});const t=a.drawings().length;t>0&&r.push({id:"draw-clear",label:ee(e,"Remove all drawings ({count})",{count:t}),icon:"trash",danger:!0,run:()=>{a.clear()}})}l(),r.push({id:"chart-fit",label:ee(e,"Fit all bars"),icon:zt("M2 8h12M4 5l-2 3 2 3M12 5l2 3-2 3"),run:()=>{n.fitContent()}}),"time-scale"!==i.kind&&r.push({id:"chart-indicators",label:ee(e,"Indicators..."),run:()=>{uo(e)}}),r.push({id:"chart-settings",label:ee(e,"Settings..."),icon:"settings",run:()=>{vo(e)}});const h=o.items?.(t)??[];return h.length>0&&(l(),r.push(...h)),r}const Po=new WeakMap;function Io(e,t,o={}){const n=e.document;Po.get(e.root)?.close();const a=o.event??{paneIndex:0,point:{x:0,y:0},price:null,time:null,index:null,target:{kind:"empty",id:null},preventDefault:()=>{}},i=o.hooks??{},r=Nt(n,"div","oac-panel oac-ctx");r.setAttribute("role","menu"),r.setAttribute("aria-label",ee(e,"Chart menu")),r.tabIndex=-1,Ft(r);let s=[];const l=e=>{const t=s.filter(e=>"true"!==e.getAttribute("aria-disabled"));0!==t.length&&t[(e%t.length+t.length)%t.length].focus()};!function t(o=-1){r.innerHTML="",s=[];const l=jo(e,a,i);for(const e of l){if("separator"===e.kind){r.appendChild(Nt(n,"div","oac-ctx__hr"));continue}if("header"===e.kind){r.appendChild(Nt(n,"div","oac-head",e.label));continue}const o=e,a=Nt(n,"button","oac-ctx__row"+(!0===o.danger?" is-danger":""));a.type="button",a.setAttribute("role","check"===o.mark?"menuitemcheckbox":"radio"===o.mark?"menuitemradio":"menuitem"),void 0!==o.mark&&a.setAttribute("aria-checked",!0===o.on?"true":"false"),void 0!==o.id&&(a.dataset.act=o.id),a.tabIndex=-1;const i=Nt(n,"span","oac-ctx__mark");if("radio"===o.mark&&!0===o.on)i.appendChild(Nt(n,"span","oac-ctx__dot"));else if("check"===o.mark&&!0===o.on)i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3.5 3.5L13 4"/></svg>';else if(void 0!==o.icon)if(o.icon.startsWith("<svg")){const e=Nt(n,"span","oac-glyph oac-glyph--chrome");e.innerHTML=o.icon,i.appendChild(e)}else i.appendChild(Rt(n,o.icon));a.appendChild(i),a.appendChild(Nt(n,"span","oac-ctx__label",o.label)),void 0!==o.note&&""!==o.note&&a.appendChild(Nt(n,"span","oac-ctx__note",o.note)),void 0!==o.chord&&a.appendChild(Nt(n,"kbd","oac-ctx__key",o.chord)),!0===o.disabled?a.setAttribute("aria-disabled","true"):a.addEventListener("click",e=>{e.stopPropagation(),o.run?.(),!0===o.keepOpen?t(s.indexOf(a)):d.close()}),r.appendChild(a),s.push(a)}o>=0&&void 0!==s[o]&&s[o].focus()}(),r.addEventListener("keydown",e=>{const t=e.key,o=s.filter(e=>"true"!==e.getAttribute("aria-disabled")),a=o.indexOf(n.activeElement);"ArrowDown"===t?(e.preventDefault(),l(a+1)):"ArrowUp"===t?(e.preventDefault(),l(a<=0?o.length-1:a-1)):"Home"===t?(e.preventDefault(),l(0)):"End"===t&&(e.preventDefault(),l(o.length-1))});const c=s.find(e=>"true"!==e.getAttribute("aria-disabled"))??r,d=Vt(e,r,void 0!==t&&void 0===o.event?{anchor:t,placement:"below",initialFocus:c}:{placement:"below",modal:!1,dismissOnOutside:!0,initialFocus:c},()=>{});if(void 0===t||void 0!==o.event){const t=oo(e.chart),o=null===t?{left:0,top:0}:Kt(e.root,t);Gt(e.root,r,{point:{x:a.point.x+o.left,y:a.point.y+o.top}})}return Po.set(e.root,d),d}function Do(e,t={}){return e.chart.on("contextmenu",o=>{const n=o;n.preventDefault(),Io(e,void 0,{event:n,hooks:t})})}const No={settings:vo,indicatorPicker:uo,indicatorSettings:fo,drawingProperties:ho,contextMenu:Io,levelEditor:Xt,textEditor:io,alertEditor:Ao,alerts:Lo};me(No);const zo=e=>`var(--oac-${e})`,Ro=`\n.oac-widget .oac-alert-editor { width: 480px; }\n.oac-widget .oac-alerts { width: 560px; }\n.oac-widget .oac-alerts__row { padding: 10px 0; border-bottom: 1px solid ${zo("bd-soft")}; }\n.oac-widget .oac-alerts__summary { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.5; }\n.oac-widget .oac-alerts__status { color: ${zo("mut")}; font-size: 11px; line-height: 1.5; margin: 4px 0 8px; overflow-wrap: anywhere; }\n.oac-widget .oac-alerts__actions { display: flex; flex-wrap: wrap; gap: 6px; }\n.oac-widget .oac-alert-context { margin: 0 0 8px; color: ${zo("mut")}; overflow-wrap: anywhere; }\n.oac-widget .oac-alert-help { color: ${zo("mut")}; font-size: 11px; line-height: 1.5; margin: 10px 0 0; }\n.oac-widget .oac-alert-error { color: ${zo("danger")}; font-size: 12px; margin: 6px 0 0; overflow-wrap: anywhere; }\n.oac-widget .oac-alert-editor input[type=datetime-local] { width: 100%; min-width: 0; color-scheme: inherit;\n height: ${zo("ctl-h")}; padding: 0 8px; border: 1px solid ${zo("bd")}; border-radius: ${zo("radius")};\n background: ${zo("elev")}; color: ${zo("tx")}; font: inherit; }\n/* Panels: the card a dialog or a popover is built on. */\n.oac-widget .oac-panel { display: flex; flex-direction: column; min-width: 0; max-width: calc(100% - 24px);\n max-height: calc(100% - 24px); background: ${zo("panel")}; border: 1px solid ${zo("bd")}; border-radius: 12px;\n box-shadow: ${zo("shadow")}; outline: none; }\n.oac-widget .oac-dialog__lead, .oac-widget .oac-dialog__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }\n.oac-widget .oac-dialog__actions .oac-btn:not(.oac-btn--primary) { border-color: ${zo("bd-soft")}; }\n.oac-widget .oac-empty { padding: 10px 6px; color: ${zo("faint")}; }\n\n/* Generated forms: switch column, label, control column. */\n.oac-widget .oac-form { min-width: 0; display: grid; gap: 1px; align-content: start; }\n.oac-widget .oac-form > .oac-head { padding: 10px 0 3px; }\n.oac-widget .oac-form > .oac-head:first-child { padding-top: 2px; }\n.oac-widget .oac-form .oac-row { gap: 8px; min-height: 30px; padding: 1px 0; }\n.oac-widget .oac-row__sw { width: 15px; flex: none; }\n.oac-widget .oac-row__label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; color: ${zo("mut")}; cursor: pointer; }\n/* Every row's control occupies the same column, and the column is one width.\n It was not: a select filled it, a lone number sat at 72px against its right\n edge, and one row widened the column for itself. Reading down the form, the\n left edge of the controls stepped in and out by ninety pixels, which is the\n kind of wrongness a reader feels before they can name it. The column is wide\n enough for a date and time, which is the widest control any of these forms\n puts in it. */\n.oac-widget .oac-row__ctl { display: flex; align-items: center; justify-content: flex-end; gap: 6px; width: min(232px, 58%); min-width: 0; flex: none; }\n/* A number that is the only thing in its column fills it like every other\n control, keeping its digits right aligned. One paired with a slider keeps\n its own width, because there the narrow box is the point. */\n.oac-widget .oac-row__ctl input[type=number] { width: 72px; max-width: 100%; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; }\n.oac-widget .oac-row__ctl > input[type=number]:only-child { width: 100%; }\n.oac-widget .oac-row__ctl input[type=text] { width: 100%; min-width: 0; }\n.oac-widget .oac-row__ctl .oac-select, .oac-widget .oac-row__ctl select { width: 100%; min-width: 0; max-width: 100%; }\n.oac-widget .oac-opacity { min-width: 0; max-width: 100%; display: inline-flex; align-items: center; gap: 6px; }\n.oac-widget .oac-opacity input[type=range] { width: 110px; min-width: 0; }\n.oac-widget .oac-out { min-width: 36px; text-align: right; color: ${zo("mut")}; font-variant-numeric: tabular-nums; }\n.oac-widget .oac-row--block { flex-direction: column; align-items: stretch; gap: 4px; }\n.oac-widget .oac-row--block > .oac-row__ctl { width: 100%; }\n.oac-widget .oac-row--block > .oac-row__label { padding-top: 4px; }\n.oac-widget .oac-row--block textarea { width: 100%; min-height: 56px; resize: vertical; }\n.oac-widget .oac-row--off > .oac-row__label { color: ${zo("faint")}; cursor: not-allowed; }\n.oac-widget .oac-row input:disabled, .oac-widget .oac-row select:disabled { opacity: .45; pointer-events: none; }\n\n/* Tab lists: a rail down the left of a settings dialog, or a row above a form. */\n.oac-widget .oac-tabs { min-width: 0; display: flex; gap: 2px; }\n.oac-widget .oac-tabs--rail { flex-direction: column; min-width: 138px; padding: 2px 10px 2px 0; border-right: 1px solid ${zo("bd-soft")}; }\n.oac-widget .oac-tabs--row { overflow-x: auto; flex: none; padding: 0 0 6px; margin-bottom: 6px; border-bottom: 1px solid ${zo("bd-soft")}; }\n.oac-widget .oac-tab { flex: none; display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 10px; background: transparent;\n border: 1px solid transparent; border-radius: 7px; color: ${zo("mut")}; text-align: left; white-space: nowrap; }\n.oac-widget .oac-tab:hover { background: ${zo("elev")}; color: ${zo("tx")}; }\n.oac-widget .oac-tab[aria-selected="true"] { background: ${zo("on-bg")}; border-color: ${zo("on-bd")}; color: ${zo("acc-2")}; }\n.oac-widget .oac-tabs--row .oac-tab { height: 28px; border-radius: 6px; }\n\n/* Chart settings and indicator settings */\n.oac-widget .oac-settings { width: 600px; }\n.oac-widget .oac-settings__main { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 12px; min-height: 0; }\n.oac-widget .oac-settings__pane { min-width: 0; min-height: 0; padding: 2px 4px 4px 0; }\n.oac-widget .oac-indset { width: 440px; }\n.oac-widget .oac-indset__pane { min-width: 0; padding-right: 4px; }\n\n/* Indicator picker */\n.oac-widget .oac-pick { width: 380px; }\n.oac-widget .oac-pick__findwrap { padding: 2px 0 8px; }\n.oac-widget .oac-pick__find { width: 100%; }\n.oac-widget .oac-pick__list { min-height: 0; display: grid; gap: 1px; align-content: start; }\n.oac-widget .oac-pick__list > .oac-head { padding: 8px 8px 3px; }\n.oac-widget .oac-pick__row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; background: transparent;\n border: 0; border-radius: 6px; color: ${zo("tx")}; text-align: left; }\n.oac-widget .oac-pick__row:hover, .oac-widget .oac-pick__row.is-active { background: ${zo("elev-2")}; }\n.oac-widget .oac-pick__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.oac-widget .oac-pick__count { color: ${zo("acc-2")}; font-size: 11px; }\n\n/* Level editor */\n.oac-widget .oac-levels { width: 340px; min-width: 0; padding: 10px 12px 12px; gap: 6px; }\n.oac-widget .oac-levels__head { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }\n.oac-widget .oac-levels__title { flex: 1 1 auto; font-weight: 650; color: ${zo("tx-strong")}; }\n.oac-widget .oac-levels__labels { display: inline-flex; align-items: center; gap: 6px; color: ${zo("mut")}; cursor: pointer; }\n.oac-widget .oac-levels__rows { min-height: 0; overflow-y: auto; display: grid; gap: 3px; }\n.oac-widget .oac-levels__row { display: grid; grid-template-columns: 15px minmax(48px, 74px) 26px minmax(0, 1fr) 24px; align-items: center; gap: 6px; min-height: 28px; }\n.oac-widget .oac-levels__row input[type=number], .oac-widget .oac-levels__row input[type=text] { width: 100%; height: 26px; }\n.oac-widget .oac-levels__row.is-off input:not([type=checkbox]) { opacity: .45; }\n.oac-widget .oac-levels__x { width: 24px; height: 24px; display: grid; place-items: center; padding: 0; background: transparent;\n border: 0; border-radius: 5px; color: ${zo("faint")}; }\n.oac-widget .oac-levels__x:hover { background: ${zo("elev-2")}; color: ${zo("danger")}; }\n.oac-widget .oac-levels__foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }\n.oac-widget .oac-levels__foot .oac-spacer { flex: 1 1 auto; }\n\n/* Inline text editor, laid over the painted text. */\n.oac-widget .oac-textedit { position: absolute; z-index: 70; box-sizing: border-box; margin: 0; outline: none; padding: 4px;\n border: 1px solid ${zo("acc")}; border-radius: 4px; background: color-mix(in srgb, ${zo("bg")} 58%, transparent);\n box-shadow: 0 0 0 3px ${zo("ring-soft")}; caret-color: ${zo("acc-2")}; cursor: text; overflow: hidden; }\n\n/* Drawing properties */\n.oac-widget .oac-props { width: 340px; }\n.oac-widget .oac-props__tools { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 0 10px 6px; }\n.oac-widget .oac-props__tools .oac-sep { margin: 0 4px; }\n.oac-widget .oac-props__pane { min-width: 0; padding-right: 4px; }\n.oac-widget .oac-props__inline { display: inline-flex; align-items: center; gap: 6px; }\n\n/* Context menu */\n.oac-widget .oac-ctx { min-width: 220px; max-width: 320px; padding: 5px; }\n.oac-widget .oac-ctx > .oac-head { padding: 6px 10px 2px; }\n.oac-widget .oac-ctx__row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; background: transparent;\n border: 0; border-radius: 6px; color: ${zo("tx")}; text-align: left; white-space: nowrap; }\n.oac-widget .oac-ctx__row:hover, .oac-widget .oac-ctx__row:focus-visible { background: ${zo("elev-2")}; outline: none; }\n.oac-widget .oac-ctx__row[aria-disabled="true"] { color: ${zo("faint")}; cursor: default; background: transparent; }\n.oac-widget .oac-ctx__row.is-danger:not([aria-disabled="true"]):hover { color: ${zo("danger")}; }\n.oac-widget .oac-ctx__row[aria-checked="true"] { color: ${zo("acc-2")}; }\n.oac-widget .oac-ctx__mark { width: 16px; height: 16px; display: inline-grid; place-items: center; flex: none; color: ${zo("mut")}; }\n.oac-widget .oac-ctx__row[aria-checked="true"] .oac-ctx__mark { color: ${zo("acc-2")}; }\n.oac-widget .oac-ctx__mark > svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-ctx__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }\n.oac-widget .oac-ctx__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-ctx__note { color: ${zo("faint")}; font-size: 11px; }\n.oac-widget .oac-ctx__key { margin-left: 8px; color: ${zo("faint")}; }\n.oac-widget .oac-ctx__hr { height: 1px; background: ${zo("bd-soft")}; margin: 4px 6px; }\n\n@container oac-widget (max-width: 720px) {\n .oac-widget .oac-settings__main { grid-template-columns: 1fr; }\n .oac-widget .oac-tabs--rail { flex-direction: row; overflow-x: auto; min-width: 0; padding: 0 0 6px; border-right: 0;\n border-bottom: 1px solid ${zo("bd-soft")}; }\n .oac-widget .oac-dialog__foot { gap: 6px; }\n .oac-widget .oac-dialog__foot > .oac-spacer { display: none; }\n .oac-widget .oac-dialog__actions { margin-left: auto; }\n}\n`,Bo={source:"Source",indicator:"Indicator",drawing:"Drawing",profile:"Profile"},Fo=["visibility","lock","settings","focus","remove"],Uo={loading:"Loading",ready:"Ready",empty:"No data",unsupported:"Unsupported",error:"Could not load"},Ho={select:"Could not select {name}",visibility:"Could not change visibility for {name}",lock:"Could not change lock for {name}",settings:"Could not open settings for {name}",focus:"Could not focus {name}",remove:"Could not remove {name}"};let Vo=0;function Ko(e,t,o={}){const n=o.objects??e.objects;if(void 0===n)throw new Error(ee(e,"Objects panel requires an object model"));const a=n,i=t=>ee(e,"Pane {number}",{number:t.paneIndex+1}),r=t=>ee(e,`schema.object.kind.${t.kind}`,{},Bo[t.kind]),s=e.document;let l=!1,c=[];const d=new Map,p=Ht(s,{translate:e.translate,title:ee(e,"Objects"),className:"oac-objects",onClose:()=>w.close()});p.closeButton.textContent=ee(e,"Close"),p.closeButton.classList.remove("oac-btn--icon");const h=Nt(s,"input","oac-objects__find");h.type="search",h.placeholder=ee(e,"Search name, type or pane"),h.setAttribute("aria-label",ee(e,"Search objects")),h.setAttribute("spellcheck","false");const u=Nt(s,"div","oac-objects__list");u.setAttribute("role","list"),u.setAttribute("aria-label",ee(e,"Chart objects"));const b=Nt(s,"div","oac-empty");b.setAttribute("role","status");const g=Nt(s,"span","oac-objects__count");function f(t,o,n){if(l)return;const i=a.get(o);let r=!1;try{if(i?.capabilities[t])switch(t){case"select":r=a.select(o,!0===n?.ctrlKey||!0===n?.metaKey);break;case"visibility":r=a.setVisible(o,!i.visible);break;case"lock":r=a.setLocked(o,!i.locked);break;case"settings":r=a.openSettings(o);break;case"focus":r=a.focus(o);break;case"remove":r=a.remove(o)}}catch{}r||e.toast(ee(e,Ho[t],{name:i?.name??ee(e,"object")}),"error")}function m(){if(l)return;const t=h.value.trim().toLowerCase(),o=c.filter(e=>`${e.name} ${r(e)} ${i(e)}`.toLowerCase().includes(t)),n=new Set(o.map(e=>e.id)),a=s.activeElement,p=null!==a&&u.contains(a);for(const[e,t]of d)n.has(e)||(t.el.remove(),d.delete(e));o.forEach((t,o)=>{let n=d.get(t.id);void 0!==n&&n.selectable===t.capabilities.select||(n?.el.remove(),n=function(e){const t=Nt(s,"div","oac-objects__row");t.dataset.objectId=e.id,t.setAttribute("role","listitem");const o=e.capabilities.select?Bt(s,{label:"",onClick:t=>f("select",e.id,t)}):Nt(s,"div");o.classList.add("oac-objects__summary"),e.capabilities.select&&(o.dataset.action="select");const n=Nt(s,"span","oac-objects__name"),a=Nt(s,"span","oac-objects__meta"),i=Nt(s,"span","oac-objects__status"),r="oac-object-"+ ++Vo;a.id=`${r}-meta`,i.id=`${r}-status`,e.capabilities.select&&o.setAttribute("aria-describedby",`${a.id} ${i.id}`),o.append(n,a,i);const l=Nt(s,"div","oac-objects__actions");return t.append(o,l),{el:t,summary:o,name:n,meta:a,status:i,actions:l,selectable:e.capabilities.select,buttons:new Map}}(t),d.set(t.id,n)),function(t,o){t.name.textContent=o.name;const n=[r(o),i(o),o.visible?ee(e,"Visible"):ee(e,"Hidden")];void 0!==o.locked&&n.push(o.locked?ee(e,"Locked"):ee(e,"Unlocked")),o.selected&&n.push(ee(e,"Selected")),t.meta.textContent=n.join(", "),t.el.classList.toggle("is-selected",o.selected),t.selectable&&(t.summary.setAttribute("aria-label",ee(e,"Select {name}",{name:o.name})),t.summary.setAttribute("aria-pressed",String(o.selected))),t.status.textContent=void 0===o.dataStatus?"":ee(e,`schema.dataStatus.${o.dataStatus.state}`,{},Uo[o.dataStatus.state]),t.status.hidden=void 0===o.dataStatus,t.status.dataset.state=o.dataStatus?.state??"";let a=0;for(const n of Fo){let i=t.buttons.get(n);if(!o.capabilities[n]){i?.remove(),t.buttons.delete(n);continue}void 0===i&&(i=Bt(s,{label:"",variant:"remove"===n?"danger":"ghost",onClick:()=>f(n,o.id)}),i.dataset.action=n,t.buttons.set(n,i));const r="visibility"===n?o.visible?ee(e,"Hide"):ee(e,"Show"):"lock"===n?o.locked?ee(e,"Unlock"):ee(e,"Lock"):ee(e,"settings"===n?"Settings":"focus"===n?"Focus":"Remove");i.textContent=r,i.setAttribute("aria-label",ee(e,"visibility"===n?o.visible?"Hide {name}":"Show {name}":"lock"===n?o.locked?"Unlock {name}":"Lock {name}":"settings"===n?"Settings for {name}":"focus"===n?"Focus {name}":"Remove {name}",{name:o.name})),t.actions.children[a]!==i&&t.actions.insertBefore(i,t.actions.children[a]??null),a++}t.actions.hidden=0===a}(n,t),u.children[o]!==n.el&&u.insertBefore(n.el,u.children[o]??null)}),b.hidden=o.length>0,b.textContent=0===c.length?ee(e,"No objects on this chart."):ee(e,"No objects match your search."),g.textContent=""===t?ee(e,"{count} objects",{count:c.length}):ee(e,"{shown} of {count} objects",{shown:o.length,count:c.length}),p&&(u.contains(a)?s.activeElement!==a&&a.focus():h.focus())}g.setAttribute("role","status"),p.body.append(h,u,b),p.lead.appendChild(g),p.actions.appendChild(Bt(s,{label:ee(e,"Done"),variant:"primary",onClick:()=>w.close()})),h.addEventListener("input",m);const v=a.subscribe(e=>{l||(c=e,m())}),w=Vt(e,p.el,{...void 0===t?{placement:"center",modal:!0}:{anchor:t,placement:"below"},initialFocus:h,onClose:()=>{l||(l=!0,v(),h.removeEventListener("input",m),d.clear(),c=[],o.onClose?.())}},()=>{});return w}const qo='\n.oac-widget .oac-objects { width: 440px; min-width: 0; }\n.oac-widget .oac-objects .oac-dialog__body { display: flex; flex-direction: column; gap: 8px; overflow: hidden; }\n.oac-widget .oac-objects__find { width: 100%; min-width: 0; flex: none; }\n.oac-widget .oac-objects__list { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 2px; }\n.oac-widget .oac-objects__row { display: flex; flex-direction: column; gap: 4px; padding: 6px; margin-bottom: 4px;\n border: 1px solid var(--oac-bd-soft); border-radius: 6px; min-width: 0; }\n.oac-widget .oac-objects__row.is-selected { border-color: var(--oac-acc); background: var(--oac-elev); }\n.oac-widget .oac-objects__summary { display: flex; flex-direction: column; align-items: flex-start; justify-content: center;\n gap: 2px; width: 100%; min-width: 0; height: auto; padding: 3px 4px; text-align: left; white-space: normal; }\n.oac-widget .oac-objects__name { font-weight: 600; overflow-wrap: anywhere; }\n.oac-widget .oac-objects__meta, .oac-widget .oac-objects__status { font-size: 11px; color: var(--oac-mut); overflow-wrap: anywhere; }\n.oac-widget .oac-objects__status[data-state="error"] { color: var(--oac-danger); }\n.oac-widget .oac-objects__actions { display: flex; flex-wrap: wrap; gap: 3px; }\n.oac-widget .oac-objects__actions .oac-btn { height: 26px; padding: 0 6px; font-size: 11px; }\n.oac-widget .oac-objects__count { color: var(--oac-mut); font-size: 11px; }\n';let Wo=0;function Go(e,t){const o=e.document,n=t.mode??"auto",a=oe(o,"div","oac-mobile");e.root.appendChild(a);let i=!1,r=!1,s=!1,l=0,c=0,d=null,p=null,h=null,u=null,b=!1,g=null,f=null;const m=[],v=e=>{e.stopPropagation()};a.addEventListener("pointerdown",v);const w=(e,t,n)=>{const a=oe(o,"button","oac-mobile__action",{type:"button"});return a.dataset.mobileAction=e,a.textContent=t,a.addEventListener("click",()=>{"true"!==a.getAttribute("aria-disabled")&&n(a)}),a},y=()=>{const e=f;f=null,e?.close()},x=()=>{0!==l&&(clearTimeout(l),l=0),c++,d=null},_=()=>{x();const e=u;u=null,p=null,h=null,g?.setAttribute("aria-expanded","false"),g?.removeAttribute("aria-controls"),null!==e&&(b=!0,e(),b=!1)},k=(t,n,a,r=void 0)=>{y();const s=oe(o,"section","oac-mobile-sheet",{"aria-label":t}),l=oe(o,"div","oac-mobile-sheet__head oac-dialog__head"),c=oe(o,"strong","oac-mobile-sheet__title");c.textContent=t;const d=w("close",ee(e,"Close"),()=>y());l.append(c,d);const p=oe(o,"div","oac-mobile-sheet__body");s.append(l,p);const h=()=>{if(i||f?.repaint!==h)return;const e=o.activeElement,t=null!==e&&p.contains(e),n=t?(e=>{const t=e.closest("[data-mobile-action]"),o=t?.dataset.mobileAction;return null===t||void 0===o?null:{action:o,...void 0===t.dataset.tool?{}:{tool:t.dataset.tool},...void 0===t.dataset.interval?{}:{interval:t.dataset.interval},...void 0===t.dataset.chartType?{}:{chartType:t.dataset.chartType}}})(e):null,r=p.scrollTop;if(p.textContent="",a(p,y),p.scrollTop=r,t){const e=null===n?null:((e,t)=>Array.from(e.querySelectorAll("[data-mobile-action]")).find(e=>e.dataset.mobileAction===t.action&&e.dataset.tool===t.tool&&e.dataset.interval===t.interval&&e.dataset.chartType===t.chartType)??null)(p,n);(e??p.querySelector("[data-mobile-action]"))?.focus()}};let u=()=>{};const b={close:()=>u(),repaint:h};f=b,a(p,y),u=e.openOverlay(s,{anchor:n,placement:"center",dismissOnOutside:!0,initialFocus:r,onClose:()=>{f===b&&(f=null)}})};let C=null;if(t.topbar){const n=oe(o,"div","oac-mobile__header",{role:"toolbar","aria-label":ee(e,"Chart header")});g=oe(o,"input","oac-mobile__symbol",{type:"text","aria-label":ee(e,"Symbol"),placeholder:ee(e,"Symbol"),autocomplete:"off",spellcheck:"false"}),void 0!==t.search&&(g.setAttribute("aria-autocomplete","list"),g.setAttribute("aria-haspopup","listbox"),g.setAttribute("aria-expanded","false")),C=w("interval","",o=>{k(ee(e,"Interval"),o,(e,o)=>{for(const n of t.intervals){const a=w("pick-interval",Qe(n),()=>{t.onInterval(n),o()});a.dataset.interval=n;const i=t.state().interval===n;a.setAttribute("aria-pressed",String(i)),e.appendChild(a)}})});const s=(e,o)=>{const n=e.trim().toUpperCase();_(),""!==n&&t.onSymbol(n,o),j(),g?.blur()},f=()=>{if(null!==p)return p;const t=oe(o,"section","oac-mobile-results",{role:"region","aria-label":ee(e,"Symbol search results")}),n=oe(o,"div","oac-mobile-results__head"),a=oe(o,"strong");a.textContent=ee(e,"Symbols"),n.append(a,w("close-search",ee(e,"Close"),()=>_()));const i=oe(o,"div","oac-mobile-results__list",{role:"listbox"});i.id="oac-mobile-results-"+ ++Wo,t.append(n,i),p=t,h=i,g?.setAttribute("aria-controls",i.id);let r=()=>{};return r=e.openOverlay(t,{anchor:g??void 0,placement:"below",initialFocus:null,dismissOnOutside:!0,onClose:()=>{p===t&&(p=null,h=null,u=null),g?.setAttribute("aria-expanded","false"),g?.removeAttribute("aria-controls"),b||x()}}),u=r,t},m=()=>{if(f(),null===h)return;h.textContent="";const t=oe(o,"div","oac-mobile-results__status",{role:"status"});t.textContent=ee(e,"Searching"),h.appendChild(t)},v=e=>{if(0!==e.length){if(f(),null!==h){h.textContent="";for(const t of e){const e=t.exchange?`${t.exchange}:${t.symbol}`:t.symbol,n=w("pick-symbol",e,()=>s(t.symbol,t.exchange));if(n.setAttribute("role","option"),t.name){const e=oe(o,"small");e.textContent=t.name,n.appendChild(e)}h.appendChild(n)}}}else _()};g.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),s(g?.value??""))}),void 0!==t.search&&(g.addEventListener("input",()=>{x();const e=g?.value.trim()??"";if(""===e)return void _();const n=++c;d=e,m(),l=setTimeout(()=>{l=0,Promise.resolve(t.search?.(e)??[]).then(t=>{const a=o.activeElement,s=a===g||null!==a&&!0===p?.contains(a);!i&&r&&n===c&&d===e&&g?.value.trim()===e&&s&&v(t)}).catch(()=>{n===c&&d===e&&_()})},150)}),g.addEventListener("blur",e=>{const t=e.relatedTarget;null!==t&&!0===p?.contains(t)||_()})),n.append(g,C),a.appendChild(n)}const $=oe(o,"div","oac-mobile__footer"),S=oe(o,"div","oac-mobile__selection",{role:"toolbar","aria-label":ee(e,"Selected drawing")});let A=null,L=null,O=null;null!==t.rail&&(A=w("properties",ee(e,"Properties"),e=>{t.onProperties(e)}),L=w("lock",ee(e,"Lock"),()=>{const t=e.draw.selection(),o=!t.every(t=>!0===e.draw.get(t)?.locked);for(const n of t)e.draw.update(n,{locked:o});j()}),O=w("delete",ee(e,"Delete"),()=>{e.draw.removeMany(e.draw.selection()),j()}),S.append(A,L,O),$.appendChild(S));const T=oe(o,"nav","oac-mobile__bar",{"aria-label":ee(e,"Chart controls")});let E=null,M=null;function j(){if(i)return;const n=t.state();if(null!==g&&o.activeElement!==g&&(g.value=n.symbol),null!==C&&(C.textContent=Qe(n.interval)),null!==E&&E.setAttribute("aria-pressed",String(null!==e.draw.activeTool())),null!==M&&M.setAttribute("aria-disabled",String(!t.indicatorsAvailable())),null!==S.parentNode){const t=e.draw.selection();if(S.hidden=0===t.length,t.length>0&&null!==L){const o=t.every(t=>!0===e.draw.get(t)?.locked);L.textContent=ee(e,o?"Unlock":"Lock"),L.setAttribute("aria-pressed",String(o))}null!==A&&A.setAttribute("aria-disabled",String(0===t.length)),null!==O&&O.setAttribute("aria-disabled",String(0===t.length))}f?.repaint()}null!==t.rail&&(E=w("draw",ee(e,"Draw"),n=>{k(ee(e,"Drawing"),n,n=>{const a=e.draw.activeTool();if(null!==a){const a=oe(o,"div","oac-mobile-sheet__controls");a.append(w("finish",ee(e,"Finish"),()=>{e.draw.finish(),j()}),w("cancel",ee(e,"Cancel"),()=>{e.draw.cancel(),j()}),w("undo",ee(e,"Undo"),()=>{e.draw.undo(),j()}),w("magnet",ee(e,"Magnet: {mode}",{mode:ee(e,`schema.magnet.${t.rail?.magnetMode()??"off"}`,{},t.rail?.magnetMode()??"off")}),()=>{t.rail?.cycleMagnet(),j()}),w("stay",ee(e,"Stay: {mode}",{mode:t.rail?.stayMode()?ee(e,"on"):ee(e,"off")}),()=>{null!==t.rail&&t.rail.setStayMode(!t.rail.stayMode()),j()})),n.appendChild(a)}const i=void 0===t.tools?null:new Set(t.tools);for(const t of Z()){if(null!==i&&!i.has(t.id))continue;const o=w("tool",ee(e,`schema.drawing.${t.id}.name`,{},t.name),()=>{e.draw.setTool(t.id),y()});o.classList.add("oac-mobile__tool"),o.dataset.tool=t.id,o.setAttribute("aria-pressed",String(a===t.id)),n.appendChild(o)}})}),T.appendChild(E)),t.topbar&&t.indicators&&(M=w("studies",ee(e,"Studies"),e=>{t.onIndicators(e)}),T.appendChild(M)),t.topbar&&(T.appendChild(w("objects",ee(e,"Objects"),e=>{t.onObjects(e)})),T.appendChild(w("more",ee(e,"More"),n=>{k(ee(e,"More"),n,(a,i)=>{t.onAlerts&&a.appendChild(w("alerts",ee(e,"Alerts"),()=>{i(),t.onAlerts?.(n)}));const r=w("theme","dark"===t.state().theme?ee(e,"Light theme"):ee(e,"Dark theme"),()=>{t.onTheme(),i()});a.appendChild(r);const s=w("settings",ee(e,"Chart settings"),()=>{i(),t.onSettings(n)});s.setAttribute("aria-disabled",String(!t.settingsAvailable())),a.appendChild(s);const l=tt(e.chart,e);if(null!==l){const e=oe(o,"a","oac-mobile__action oac-mobile__branding",{href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":l.label});e.dataset.mobileAction="branding",e.textContent=l.label,a.appendChild(e)}const c=oe(o,"div","oac-head");c.textContent=ee(e,"Chart type"),a.appendChild(c);for(const o of Xe()){const n=w("chart-type",ee(e,`schema.chartType.${o}`,{},Je(o)),()=>{t.onChartType(o),i()});n.dataset.chartType=o,n.setAttribute("aria-pressed",String(t.state().chartType===o)),a.appendChild(n)}})}))),T.children.length>0&&$.appendChild(T),$.children.length>0&&a.appendChild($);const P="auto"===n?o.defaultView?.matchMedia?.("(pointer: coarse)")??null:null,I=()=>{const o="always"===n||"auto"===n&&((t.container.getBoundingClientRect().width||t.container.clientWidth)<=640||!0===P?.matches);s&&o===r||(s=!0,r=o,e.root.classList.toggle("is-mobile",r),e.root.dataset.mobile=String(r),a.hidden=!r,r||(y(),_()))},D=o.defaultView?.ResizeObserver;let N=null;if("auto"===n&&void 0!==D)N=new D(I),N.observe(t.container);else if("auto"===n){const e=o.defaultView;null!==e&&"function"==typeof e.addEventListener&&(e.addEventListener("resize",I),m.push(()=>e.removeEventListener("resize",I)))}null!==P&&("function"==typeof P.addEventListener?(P.addEventListener("change",I),m.push(()=>P.removeEventListener("change",I))):(P.addListener(I),m.push(()=>P.removeListener(I))));for(const t of["draw:tool","draw:select","drawing:select","drawing:change","draw:add","draw:remove","draw:update"])m.push(e.chart.on(t,j));return m.push(e.bus.on("symbol",j)),m.push(e.bus.on("interval",j)),m.push(e.bus.on("theme",j)),m.push(e.chart.on("branding:changed",j)),I(),j(),{el:a,active:()=>r,refresh:j,destroy:()=>{if(!i){i=!0,_(),y(),N?.disconnect(),N=null;for(const e of m.splice(0))e();a.removeEventListener("pointerdown",v),a.remove(),e.root.classList.remove("is-mobile"),delete e.root.dataset.mobile}}}}const Zo='\n.oac-event-layer{position:absolute;inset:0;pointer-events:none;z-index:50}\n.oac-event-details{position:absolute;pointer-events:auto;box-sizing:border-box;width:340px;max-width:calc(100% - 16px);max-height:calc(100% - 16px);overflow:auto;background:var(--oac-panel,#171b23);color:var(--oac-tx,#d9dfe8);border:1px solid var(--oac-bd,#343b48);border-radius:8px;box-shadow:var(--oac-shadow,0 12px 32px #0005);font:12px/1.5 var(--oac-font,system-ui,sans-serif);scrollbar-width:thin;scrollbar-color:var(--oac-sb-thumb,#414958) var(--oac-panel,#171b23)}\n.oac-event-details::-webkit-scrollbar{width:6px;height:6px}\n.oac-event-details::-webkit-scrollbar-track{background:var(--oac-panel,#171b23)}\n.oac-event-details::-webkit-scrollbar-thumb{background:var(--oac-sb-thumb,#414958);border-radius:3px}\n.oac-event-details::-webkit-scrollbar-thumb:hover{background:var(--oac-sb-thumb-hover,#586276)}\n.oac-event-details__header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;border-bottom:1px solid var(--oac-bd,#343b48)}\n.oac-event-details__heading{margin:0;font:600 12px/1.5 var(--oac-font,system-ui,sans-serif)}\n.oac-event-details button{font:inherit;cursor:pointer;border:1px solid var(--oac-bd,#343b48);border-radius:4px;padding:4px 8px;background:var(--oac-elev,#252c37);color:inherit;text-align:left}\n.oac-event-details button:hover{background:var(--oac-elev-2,#333d4b)}\n.oac-event-details button:focus-visible{outline:2px solid var(--oac-ring,#74a7fa);outline-offset:2px}\n.oac-event-details__members{display:flex;flex-wrap:wrap;gap:6px;padding:10px 12px 0}\n.oac-event-details__members button{max-width:100%;overflow-wrap:anywhere}\n.oac-event-details__members button[aria-pressed="true"]{border-color:var(--oac-acc,#74a7fa);background:var(--oac-on-bg,#274263)}\n.oac-event-details__content{padding:12px;overflow-wrap:anywhere}\n.oac-event-details__title{margin:0 0 4px;font-size:14px;font-weight:600}\n.oac-event-details__time,.oac-event-details__status{color:var(--oac-mut,#a0aabc)}\n.oac-event-details__summary{white-space:pre-wrap;margin:10px 0 0}\n.oac-event-details__fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:5px 12px;margin:10px 0 0}\n.oac-event-details__fields dt{color:var(--oac-mut,#a0aabc)}\n.oac-event-details__fields dd{margin:0;text-align:right;white-space:pre-wrap}\n.oac-event-details__status{padding:0 12px 10px}\n.oac-event-details__status:empty{display:none}\n',Yo={title:"Event details",close:"Close",events:"Events",loading:"Loading details...",empty:"No additional details.",error:"Unable to load additional details."};function Jo(e){return{...e,..."object"==typeof e.details&&null!==e.details?{details:{...e.details,...e.details.fields?{fields:e.details.fields.map(e=>({...e}))}:{}}}:{}}}class Xo{constructor(e,t={}){Object.defineProperty(this,"_container",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_doc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_overlays",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ownOverlays",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_labels",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_formatTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_close",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_abort",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_revision",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_disposed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_events",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_members",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_anchor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._doc=e.ownerDocument,this._labels={...Yo,...t.labels};const o=new Intl.DateTimeFormat(void 0,{timeZone:"Asia/Kolkata",dateStyle:"medium",timeStyle:"short"});if(this._formatTime=t.formatTime??(e=>{const t=new Date(1e3*e);return Number.isFinite(t.getTime())?o.format(t):String(e)}),this._ownOverlays=void 0===t.overlays,this._overlays=t.overlays??xe(e,this._doc),this._ownOverlays&&this._overlays.layer.classList.add("oac-event-layer"),!1!==t.injectStyles&&null===this._doc.getElementById("oac-event-details-style")){const e=oe(this._doc,"style",void 0,{id:"oac-event-details-style"});void 0!==t.styleNonce&&e.setAttribute("nonce",t.styleNonce),e.textContent=Zo,this._doc.head.appendChild(e)}this.element=oe(this._doc,"section","oac-event-details",{role:"dialog","aria-label":this._labels.title});for(const e of["pointerdown","pointerup","click","dblclick","wheel","keydown"])this.element.addEventListener(e,e=>e.stopPropagation());this._content=oe(this._doc,"div","oac-event-details__content"),this._status=oe(this._doc,"div","oac-event-details__status",{role:"status","aria-live":"polite"})}open(e,t){if(this._disposed)return;if(this.close(),0===e.events.length)return;this._events=e.events.map(Jo),this._anchor=void 0===t?void 0:{...t};const o=oe(this._doc,"header","oac-event-details__header"),n=oe(this._doc,"h2","oac-event-details__heading");n.textContent=this._labels.title;const a=oe(this._doc,"button",void 0,{type:"button","data-action":"close-event-details"});if(a.textContent=this._labels.close,a.addEventListener("click",()=>this.close()),o.append(n,a),this.element.replaceChildren(o),this._members=[],this._events.length>1){const e=oe(this._doc,"div","oac-event-details__members",{role:"group","aria-label":this._labels.events});this._members=this._events.map((t,o)=>{const n=oe(this._doc,"button",void 0,{type:"button","data-event-index":String(o)});return n.textContent=t.title??t.label,n.addEventListener("click",()=>this._select(o)),e.appendChild(n),n}),this.element.appendChild(e)}this.element.append(this._content,this._status),this._close=this._overlays.open(this.element,{placement:"below",modal:!1,initialFocus:a,onClose:()=>{this._close=null,this._cancel()}}),this._select(0),this._position()}close(){this._cancel(),this._close?.(),this._close=null}destroy(){this._disposed||(this._disposed=!0,this.close(),this._events=[],this._members=[],this._ownOverlays&&this._overlays.destroy())}_cancel(){this._revision++,this._abort?.abort(),this._abort=null}_select(e){this._cancel();const t=this._events[e];this._members.forEach((t,o)=>t.setAttribute("aria-pressed",String(o===e))),this._render(t,t.details),this._status.textContent="",this.element.removeAttribute("aria-busy");const o=this._options.loadDetails;if(void 0===o)return;const n=this._revision,a=new AbortController;this._abort=a,this._status.textContent=this._labels.loading,this.element.setAttribute("aria-busy","true");const i=()=>!this._disposed&&null!==this._close&&n===this._revision&&!a.signal.aborted,r=()=>{i()&&(this.element.removeAttribute("aria-busy"),this._status.textContent=this._labels.error,this._position())};try{Promise.resolve(o(Jo(t),{signal:a.signal})).then(e=>{i()&&(this._status.textContent="",this.element.removeAttribute("aria-busy"),this._render(t,e??t.details))},r)}catch{r()}}_render(e,t){const o=oe(this._doc,"h3","oac-event-details__title");o.textContent=e.title??e.label;const n=oe(this._doc,"div","oac-event-details__time");n.textContent=this._formatTime(e.time),this._content.replaceChildren(o,n);const a="string"==typeof t?t:t?.summary;if(a){const e=oe(this._doc,"p","oac-event-details__summary");e.textContent=a,this._content.appendChild(e)}const i="object"==typeof t?t.fields:void 0;if(i?.length){const e=oe(this._doc,"dl","oac-event-details__fields");for(const t of i){const o=oe(this._doc,"dt"),n=oe(this._doc,"dd");o.textContent=t.label,n.textContent=t.value,e.append(o,n)}this._content.appendChild(e)}if(!a&&!i?.length){const e=oe(this._doc,"p","oac-event-details__summary");e.textContent=this._labels.empty,this._content.appendChild(e)}this._position()}_position(){const e=this._container.getBoundingClientRect(),t=this._overlays.layer.getBoundingClientRect(),o=this._ownOverlays?0:e.left-t.left,n=this._ownOverlays?0:e.top-t.top;this.element.style.maxWidth=`${Math.max(0,e.width-16)}px`,this.element.style.maxHeight=`${Math.max(0,e.height-16)}px`;const a=this.element.offsetWidth,i=this.element.offsetHeight,r=this._anchor?.x,s=this._anchor?.y;this.element.style.left=`${o+Math.max(0,Math.min(Number.isFinite(r)?r:e.width-a-8,e.width-a-8))}px`,this.element.style.top=`${n+Math.max(0,Math.min(Number.isFinite(s)?s-i-12:8,e.height-i-8))}px`}}const Qo=["1m","5m","15m","1h","1d","1w"],en=500,tn=250,on="state",nn=1,an=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),rn=["feed","symbol","exchange","interval","intervals","chartType","theme","rail","topbar","statusline","mobile","loading","persist","storage","locale","translate","indicators","symbolSearch","lookbackBars","now","onOrder","styleNonce","tradingCapabilities","tradingMode","tradingLocked","eventDetails"];function sn(e){const t={...e};return delete t.viewport,delete t.barSpacing,Array.isArray(t.panes)&&(t.panes=t.panes.map(e=>{if(!an(e)||!an(e.priceScale))return e;const t={...e.priceScale,autoScale:!0};return delete t.range,{...e,priceScale:t}})),t}function ln(e){return"light"===e?{theme:k,name:"light"}:"dark"===e||void 0===e?{theme:C,name:"dark"}:{theme:e,name:gt(e)}}function cn(e,t,o){const n=_(e),a=null!==n&&"interval"===n.bucketing.mode?n.bucketing.seconds:null;return{from:o-(null===a?15768e4:Math.max(1,Math.round(t))*a),to:o}}class dn{constructor(e,t){Object.defineProperty(this,"chart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"draw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"objects",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"alerts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"document",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"keymap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"bus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"locale",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"translate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"toast",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"openOverlay",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tips",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"overlays",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"symbol",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_source",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._source=e,this.chart=t.chart,this.draw=t.draw,this.objects=t.objects,this.alerts=t.alerts,this.root=t.root,this.document=t.document,this.keymap=t.keymap,this.bus=t.bus,this.storage=t.storage,this.locale=t.locale,this.translate=t.translate,this.toast=t.toast,this.openOverlay=t.openOverlay,this.status=t.status,this.tips=t.tips,this.overlays=t.overlays,this.symbol=t.symbol,this.interval=t.interval}get theme(){return this._source.theme()}get chartTheme(){return this._source.chartThemeInUse()}}class pn{constructor(e,o){Object.defineProperty(this,"dataController",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"chart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"draw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"objects",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"alerts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_series",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_doc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_opts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_bus",{enumerable:!0,configurable:!0,writable:!0,value:new pe}),Object.defineProperty(this,"_storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_keymap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_toasts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chartEl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rail",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_topbar",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_statusline",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mobile",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_objectsPanel",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_alertsPanel",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_intervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_symbol",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_exchange",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chartType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_themeName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chartTheme",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pointerInside",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_pointerInChart",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_dataStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_displayedBars",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_dataState",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_initialView",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_pendingView",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_keepView",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_saveTimer",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_cleanups",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this._opts=o,this.dataController=o.feed?new $(o.feed,{now:()=>Math.floor((o.now??Date.now)()/1e3),...o.loading}):null;const n=o.document??e.ownerDocument;this._doc=n,Ot(n,Ro+qo+Zo,o.styleNonce);const a="string"==typeof o.persist?o.persist:"default",r=o.persist?void 0===o.storage?be():o.storage:null;this._storage=new ue(a,r);const s=this._readSaved();this._symbol=(o.symbol??s?.symbol??"").toUpperCase(),this._exchange=o.exchange??s?.exchange??"",void 0!==o.interval&&S(o.interval);for(const e of o.intervals??[])S(e);const l=null!==s&&A(s.interval)?s.interval:"1d";this._interval=o.interval??l;const c=o.chartType??s?.chartType??"candlestick";if(void 0!==o.chartType&&!t().includes(o.chartType))throw new Error(`openalgo-charts widget: "${o.chartType}" is not a registered chart type`);this._chartType=t().includes(c)?c:"candlestick";const d=ln(o.theme??s?.theme);this._themeName=d.name,this._chartTheme=d.theme;const p=new Set(o.intervals??[...Qo,...i().map(e=>e.code)]);p.add(this._interval),this._intervals=Array.from(p);const h=oe(n,"div","oac-widget");h.dataset.theme=this._themeName,Ct(h,kt(this._chartTheme,this._themeName)),this.root=h;const u=oe(n,"div","oac-topbar");!1===o.topbar&&(u.hidden=!0),h.appendChild(u);const b=oe(n,"div","oac-stage");h.appendChild(b);const g=oe(n,"div","oac-rail");!1===o.rail&&(g.hidden=!0),b.appendChild(g);const f=oe(n,"div","oac-chart");this._chartEl=f,b.appendChild(f);const m=oe(n,"div","oac-statusline");!1===o.statusline&&(m.hidden=!0),h.appendChild(m);const v=oe(n,"div","oac-toasts");h.appendChild(v),e.appendChild(h);const w={...o};for(const e of rn)delete w[e];const y=!0===n.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches;y&&void 0===w.animZoom&&(w.animZoom=!1),y&&void 0===w.animAutoscale&&(w.animAutoscale=!1),this.chart=L(f,{...w,theme:this._chartTheme,document:n}),f.setAttribute("aria-label",o.ariaLabel??ee(o,"Price chart")),this._series=this.chart.addSeries(this._chartType),this._publishDataContext(),this.draw=new Y(this.chart,{}),this.alerts=new O(this.chart,{drawings:this.draw}),this.objects=new T(this.chart,{drawings:this.draw,onSettings:e=>{"source"===e.kind?this.openSettings():"indicator"===e.kind?fo(this.context,void 0,{instanceId:e.sourceId}):"drawing"===e.kind&&ho(this.context,void 0,{ids:[e.sourceId]})}});const x=xe(h,n),_=ke(h,x.layer,n);this._toasts=lt(v,n,o);const k=this.chart.shortcuts;if(this._keymap=new Pe({chart:null===k?null:{list:()=>k.list()},scopes:()=>this._scopes()}),this._keymap.onConflict(e=>this._bus.emit("keymap:conflict",{combo:e.combo,kept:e.kept,shadowed:e.shadowed})),this.context=new dn(this,{chart:this.chart,draw:this.draw,objects:this.objects,alerts:this.alerts,root:h,document:n,keymap:this._keymap,bus:this._bus,storage:this._storage,locale:o.locale,translate:o.translate,toast:(e,t)=>this._toasts.toast(e,t),openOverlay:(e,t)=>x.open(e,t),status:(e,t="info")=>{this._statusline?.setMessage(e,t),this._bus.emit("status",{text:e,kind:t})},tips:_,overlays:x,symbol:()=>({symbol:this._symbol,exchange:this._exchange}),interval:()=>this._interval}),this._cleanups.push(()=>{_.destroy(),x.destroy()}),!1!==o.eventDetails){const e=new Xo(f,{styleNonce:o.styleNonce,overlays:this.context.overlays,formatTime:e=>{const t=new Date(1e3*e);return Number.isFinite(t.getTime())?new Intl.DateTimeFormat(o.locale,{timeZone:this.chart.timezone(),dateStyle:"medium",timeStyle:"short"}).format(t):String(e)},...o.eventDetails,injectStyles:!1});this._cleanups.push(this.chart.on("event:click",t=>{const o=t;e.open(o,o.point)})),this._cleanups.push(this.chart.on("data:context",()=>e.close())),this._cleanups.push(this.chart.on("events:change",()=>e.close())),this._cleanups.push(()=>e.destroy())}if(this._dataStatus=function(e,t,o,n){const a=oe(e.document,"div","oac-data-status");a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),a.setAttribute("aria-atomic","true"),a.hidden=!0,t.appendChild(a);let i=o?.getState()??null,r="",s=!1;const l=e=>e.stopPropagation();for(const e of["pointerdown","wheel","keydown"])a.addEventListener(e,l);const c=()=>{if(s)return;const t=[];if(null!==i){const a=i.request?.symbol??"",r=i.request?.interval??"";switch(i.status){case"loading":t.push({text:ee(e,"Loading {symbol} {interval}",{symbol:a,interval:r})});break;case"refreshing":t.push({text:ee(e,"Refreshing {symbol} {interval}",{symbol:a,interval:r})});break;case"empty":t.push({text:ee(e,"No bars for {symbol} {interval}",{symbol:a,interval:r}),label:ee(e,"Retry chart data"),retry:n});break;case"stale":t.push({text:ee(e,"History is stale for {symbol} {interval}",{symbol:a,interval:r}),label:ee(e,"Retry chart data"),retry:n});break;case"error":t.push({text:ee(e,"Could not load {symbol} {interval}",{symbol:a,interval:r}),label:ee(e,"Retry chart data"),retry:n})}"limited"===i.historyStatus?t.push({text:ee(e,"History retention limit reached")}):"loading"===i.historyStatus?t.push({text:ee(e,"Loading older history")}):"error"===i.historyStatus&&t.push({text:ee(e,"Could not load older history"),label:ee(e,"Retry older history"),retry:()=>{o?.loadMore()}})}for(const o of e.chart.indicators()){const n=o.dataStatus();if(null===n||"ready"===n.state)continue;const a={loading:ee(e,"Loading"),empty:ee(e,"No data"),unsupported:ee(e,"Unsupported"),error:ee(e,"Could not load")}[n.state];t.push({text:`${o.name}: ${a}`,label:ee(e,"Retry {name}",{name:o.name}),retry:"loading"===n.state?void 0:()=>o.retryData()})}const l=JSON.stringify(t.map(e=>[e.text,e.label,!!e.retry]));if(r!==l){r=l,a.textContent="",a.hidden=0===t.length;for(const o of t){const t=oe(e.document,"div","oac-data-status__row"),n=oe(e.document,"span","oac-data-status__text");if(n.textContent=o.text,t.appendChild(n),o.retry){const n=oe(e.document,"button","oac-btn");n.textContent=ee(e,"Retry"),n.type="button",n.setAttribute("aria-label",o.label),n.addEventListener("click",o.retry),t.appendChild(n)}a.appendChild(t)}}},d=()=>{c(),queueMicrotask(c)},p=["indicator:data-status","indicatorRemoved"].map(t=>e.chart.on(t,d));return c(),{el:a,update:e=>{i=e,c()},destroy:()=>{s=!0;for(const e of p)e();for(const e of["pointerdown","wheel","keydown"])a.removeEventListener(e,l);a.remove()}}}(this.context,b,this.dataController,()=>{this.reload()}),this._cleanups.push(Do(this.context,{onOrder:o.onOrder,tradingCapabilities:o.tradingCapabilities,tradingMode:o.tradingMode,tradingLocked:o.tradingLocked})),!1!==o.rail){const e={..."object"==typeof o.rail?o.rail:{},cursorTarget:f};this._rail=Ve(this.context,g,e)}if(!1!==o.statusline&&(this._statusline=Ge(this.context,m,{locale:o.locale}),this._statusline.setSymbol(this._symbol,this._exchange,this._interval)),!1!==o.topbar&&(this._topbar=at(this.context,u,{intervals:this._intervals,indicators:o.indicators,search:o.symbolSearch,state:()=>({symbol:this._symbol,exchange:this._exchange,interval:this._interval,chartType:this._chartType,theme:this._themeName}),onSymbol:(e,t)=>this.setSymbol(e,t),onInterval:e=>this.setInterval(e),onChartType:e=>this.setChartType(e),onTheme:e=>this.setTheme(e),onSettings:e=>this._openDialog("settings",e),onIndicators:e=>this._openDialog("indicatorPicker",e),onObjects:e=>this._openObjects(e),onAlerts:e=>this._openAlerts(e),settingsAvailable:()=>null!==we("settings"),indicatorsAvailable:()=>null!==we("indicatorPicker"),dataAvailable:()=>null===this.dataController||"ready"===this._dataState?.status||"stale"===this._dataState?.status})),this._mobile=Go(this.context,{mode:o.mobile,container:e,intervals:this._intervals,topbar:!1!==o.topbar,rail:this._rail,tools:"object"==typeof o.rail?o.rail.tools:void 0,indicators:!1!==o.indicators,search:o.symbolSearch,state:()=>({symbol:this._symbol,exchange:this._exchange,interval:this._interval,chartType:this._chartType,theme:this._themeName}),onSymbol:(e,t)=>this.setSymbol(e,t),onInterval:e=>this.setInterval(e),onChartType:e=>this.setChartType(e),onTheme:()=>this.setTheme("dark"===this._themeName?"light":"dark"),onSettings:e=>this._openDialog("settings",e),onIndicators:e=>this._openDialog("indicatorPicker",e),onObjects:e=>this._openObjects(e),onAlerts:e=>this._openAlerts(e),onProperties:e=>this._openDialog("drawingProperties",e),settingsAvailable:()=>null!==we("settings"),indicatorsAvailable:()=>null!==we("indicatorPicker")}),this._installKeys(),this._keymap.attach(n),this._trackPointer(),this._followChart(),void 0!==s?.chart){const e=s.symbol===this._symbol&&s.exchange===this._exchange&&s.interval===this._interval,t=this.chart.restoreState(e?s.chart:sn(s.chart));t.applied?(this._keepView=e,this._pendingView=e?s.chart.viewport??null:null):this._toasts.toast(ee(this.context,"The saved layout could not be restored: {error}",{error:t.reason??"unknown reason"}),"error")}if(s?.rail&&null!==this._rail&&this._rail.restorePrefs(s.rail),null!==this.dataController){this._cleanups.push(this.dataController.subscribe(e=>this._applyData(e))),this.chart.setHistoryLoader(()=>{this.dataController.loadMore().finally(()=>{this._destroyed||this.chart.historyLoadComplete()})});const e=()=>this.dataController.setVisible(!n.hidden);n.addEventListener("visibilitychange",e),this._cleanups.push(()=>n.removeEventListener("visibilitychange",e)),n.hidden&&e(),""!==this._symbol&&this.reload()}}get series(){return this._series}get isDestroyed(){return this._destroyed}symbol(){return this._symbol}exchange(){return this._exchange}interval(){return this._interval}chartType(){return this._chartType}theme(){return this._themeName}chartThemeInUse(){return this._chartTheme}on(e,t){return this._bus.on(e,t)}off(e,t){this._bus.off(e,t)}setSymbol(e,t){const o=e.trim().toUpperCase(),n=t??this._exchange;if(o===this._symbol&&n===this._exchange)return this._topbar?.refresh(),void this._mobile?.refresh();this._symbol=o,this._exchange=n,this._keepView=!1,this._pendingView=null,null===this.dataController&&(this._series.setData([]),this._publishDataContext()),this._statusline?.setSymbol(o,n,this._interval),this._topbar?.refresh(),this._mobile?.refresh(),this._scheduleSave(),this._opts.feed&&this.reload(),this._bus.emit("symbol",{symbol:o,exchange:n}),this.chart.emit("symbol",{symbol:o,exchange:n})}setInterval(e){const t=e.trim();if(""===t)throw new Error("openalgo-charts widget: interval code must not be empty");if(S(t),t===this._interval)return this._topbar?.refresh(),void this._mobile?.refresh();this._interval=t,this._keepView=!1,this._pendingView=null,null===this.dataController&&(this._series.setData([]),this._publishDataContext()),this._statusline?.setSymbol(this._symbol,this._exchange,t),this._topbar?.refresh(),this._mobile?.refresh(),this._scheduleSave(),this._opts.feed&&this.reload(),this._bus.emit("interval",{interval:t})}setChartType(e){if(!t().includes(e))throw new Error(`openalgo-charts widget: "${e}" is not a registered chart type`);if(e===this._chartType)return;const o=this._series.getData();this._series.remove(),this._series=this.chart.addSeries(e),o.length>0&&this._series.setData(o),this._chartType=e,this._topbar?.refresh(),this._mobile?.refresh(),this._statusline?.refresh(),this._scheduleSave(),this._bus.emit("layout",{reason:"chartType",chartType:e})}setTheme(e){const t=ln(e);this._themeName=t.name,this._chartTheme=t.theme,this.chart.setTheme(t.theme),this.root.dataset.theme=t.name,Ct(this.root,kt(t.theme,t.name)),this._topbar?.refresh(),this._mobile?.refresh(),this._scheduleSave(),this._bus.emit("theme",{theme:t.name,chartTheme:t.theme})}openSettings(){return this._openDialog("settings")}openIndicatorPicker(){return this._openDialog("indicatorPicker")}openObjects(){return this._openObjects()}openAlerts(){return this._openAlerts()}_openAlerts(e){return!this._destroyed&&(this._alertsPanel?.isOpen()?(this._alertsPanel.el.focus(),!0):(this._alertsPanel=Lo(this.context,e,{onClose:()=>{this._alertsPanel=null}}),!0))}_openObjects(e){return!this._destroyed&&(this._objectsPanel?.isOpen()?(this._objectsPanel.el.focus(),!0):(this._objectsPanel=Ko(this.context,e,{onClose:()=>{this._objectsPanel=null}}),!0))}_openDialog(e,t){const o=we(e);return null!==o&&(o(this.context,t),!0)}_publishDataContext(){const e=this.chart.getDataContext(),t=e?.symbol===this._symbol&&e.exchange===this._exchange;this.chart.setDataContext({symbol:this._symbol,exchange:this._exchange,interval:this._interval,...t&&void 0!==e.hasOpenInterest?{hasOpenInterest:e.hasOpenInterest}:{}})}async reload(){const e=this.dataController;if(null===e||this._destroyed)return;const t=e.getState().request;if(t?.symbol===this._symbol&&t.exchange===this._exchange&&t.interval===this._interval)return void await e.refresh();const o=this._opts.loading?.now?.()??Math.floor((this._opts.now??Date.now)()/1e3),n={symbol:this._symbol,exchange:this._exchange,interval:this._interval,...cn(this._interval,this._opts.lookbackBars??500,o)};this._initialView=!0,this._displayedBars=null,this._series.setData([]),this._publishDataContext(),await e.load(n)}_applyData(e){if(this._destroyed||null===e.request)return;const t=this._dataState;this._dataState=e,this._dataStatus.update(e);const{symbol:o,interval:n}=e.request;if(!e.paused&&e.bars!==this._displayedBars){const t=this._series.getData(),o=this.chart.getVisibleLogicalRange(),n=t[Math.max(0,Math.min(t.length-1,Math.round(o.from)))],a=void 0===n?-1:t.findIndex(e=>e.time===n.time),i=e.bars[e.bars.length-1];if("live"!==e.reason||void 0===i||t[0]?.time!==e.bars[0]?.time||t.length!==e.bars.length&&t.length+1!==e.bars.length){if(this._series.setData(e.bars),e.bars.length>0)if(this._initialView)this._pendingView?this.chart.setVisibleLogicalRange(this._pendingView):this._keepView||this.chart.resetScale(),this._pendingView=null,this._initialView=!1,this._keepView=!1;else{const t=void 0===n?-1:e.bars.findIndex(e=>e.time===n.time),i=t<0||a<0?0:t-a;this.chart.setVisibleLogicalRange({from:o.from+i,to:o.to+i})}}else this._series.update(i);this._displayedBars=e.bars,this._statusline?.refresh()}(t?.status!==e.status||t.error!==e.error||["load","refresh","prepend","resume"].includes(e.reason))&&("loading"===e.status?this.context.status(ee(this.context,"Loading {symbol} {interval}",{symbol:o,interval:n})):"refreshing"===e.status?this.context.status(ee(this.context,"History is stale. Refreshing {symbol} {interval}",{symbol:o,interval:n})):"error"===e.status||"stale"===e.status?(this.context.status("stale"===e.status?ee(this.context,"History is stale for {symbol} {interval}. Reload to retry.",{symbol:o,interval:n}):ee(this.context,"Could not load {symbol} {interval}",{symbol:o,interval:n}),"error"),e.error&&e.error!==t?.error&&(this._toasts.toast(ee(this.context,"Could not load {symbol} {interval}: {error}",{symbol:o,interval:n,error:e.error.message}),"error"),this._bus.emit("data",{symbol:o,interval:n,bars:0,error:e.error.message}))):"ready"!==e.status&&"empty"!==e.status||(this.context.status(0===e.bars.length?ee(this.context,"No bars for {symbol} {interval}",{symbol:o,interval:n}):ee(this.context,"{count} bars",{count:e.bars.length})),this._bus.emit("data",{symbol:o,interval:n,bars:e.bars.length})))}getState(){return{version:1,symbol:this._symbol,exchange:this._exchange,interval:this._interval,chartType:this._chartType,theme:this._themeName,chart:this.chart.getState(),rail:this._rail?.prefs()??null}}restoreState(e){if(!an(e))return{applied:!1,reason:"not a widget state object"};if(void 0!==e.version&&1!==e.version)return{applied:!1,reason:`widget state version ${String(e.version)} is not 1`};"dark"!==e.theme&&"light"!==e.theme||this.setTheme(e.theme),"string"==typeof e.chartType&&t().includes(e.chartType)&&this.setChartType(e.chartType),void 0!==e.rail&&null!==this._rail&&this._rail.restorePrefs(e.rail);const o="string"==typeof e.symbol?e.symbol.toUpperCase():this._symbol,n="string"==typeof e.exchange?e.exchange:this._exchange,a="string"==typeof e.interval&&A(e.interval)?e.interval:this._interval,i=o===this._symbol&&n===this._exchange&&a===this._interval;let r;if(an(e.chart)){const t=e.chart;if(r=this.chart.restoreState(i?t:sn(t)),!r.applied)return{applied:!1,reason:r.reason,chart:r};this._keepView=i,this._pendingView=i?t.viewport??null:null}return i||(a!==this._interval&&(this._interval=a,this._bus.emit("interval",{interval:a})),o===this._symbol&&n===this._exchange||(this._symbol=o,this._exchange=n,this._bus.emit("symbol",{symbol:o,exchange:n})),this._statusline?.setSymbol(this._symbol,this._exchange,this._interval),this._topbar?.refresh(),this._mobile?.refresh(),this._opts.feed?this.reload():(this._series.setData([]),this._publishDataContext())),this._rail?.refresh(),this._statusline?.refresh(),this._bus.emit("layout",{reason:"restore",chartType:this._chartType}),this._scheduleSave(),void 0===r?{applied:!0}:{applied:!0,chart:r}}_readSaved(){const e=this._storage.get(on);if(!an(e)||1!==e.version)return null;return{version:1,symbol:"string"==typeof e.symbol?e.symbol:"",exchange:"string"==typeof e.exchange?e.exchange:"",interval:"string"==typeof e.interval&&""!==e.interval?e.interval:"1d",chartType:"string"==typeof e.chartType?e.chartType:"candlestick",theme:"light"===e.theme?"light":"dark",chart:an(e.chart)?e.chart:void 0,rail:an(e.rail)?e.rail:null}}_scheduleSave(){this._storage.enabled&&!this._destroyed&&(0!==this._saveTimer&&clearTimeout(this._saveTimer),this._saveTimer=setTimeout(()=>{this._saveTimer=0,this._saveNow()},250))}_saveNow(){if(this._storage.enabled&&!this._destroyed){0!==this._saveTimer&&(clearTimeout(this._saveTimer),this._saveTimer=0);try{this._storage.set(on,this.getState())||this.context.status(ee(this.context,"The chart layout could not be saved"),"error")}catch(e){this.context.status(ee(this.context,"The chart layout could not be saved: {error}",{error:e instanceof Error?e.message:"invalid state"}),"error")}}}_scopes(){if(this.context.overlays.size()>0)return["overlay"];const e=[],t=this._doc.activeElement;return null!==t&&this._dataStatus.el.contains(t)?[]:(null!==this._rail&&null!==t&&this._rail.el.contains(t)&&e.push("rail"),(this._pointerInChart||null!==t&&this._chartEl.contains(t))&&e.push("chart"),(this._pointerInside||null!==t&&this.root.contains(t))&&e.push("widget"),e.push("global"),e)}_installKeys(){const e=this._keymap,t=this.draw,o=()=>{const e=t.selection();if(e.length>0)return e.slice();const o=t.hovered();return null===o?[]:[o]},n=e=>{const n=J(e,{hasSelection:null!==t.selected(),hasTarget:null!==t.hovered(),editingText:!1,placing:null!==t.activeTool()});if(null===n){const o=this.alerts.hovered();return void 0!==o&&null===t.activeTool()&&("Delete"===e.key||"Backspace"===e.key)&&(this.alerts.remove(o),this._rail?.refresh(),!0)}switch(n.type){case"undo":t.undo();break;case"redo":t.redo();break;case"delete":t.removeMany(o());break;case"duplicate":t.duplicate(o());break;case"nudge":t.nudge(o(),n.dx,n.dy);break;case"cancel":t.cancel(),null===t.activeTool()&&this._rail?.setDrawLock(!1);break;case"finish":t.finish();break;case"popAnchor":t.popAnchor();break;case"copy":t.copy(o());break;case"cut":t.cut(o());break;case"paste":t.paste()}return this._rail?.refresh(),!0},a="Drawing",i=(t,o,i=!1,r=!1)=>{e.register(t,n,"widget",{label:o,group:a,hidden:i,layered:r})};i("Mod+Z","Undo"),i("Mod+Shift+Z","Redo"),i("Mod+Y","Redo",!0),i("Mod+C","Copy the selected drawing"),i("Mod+X","Cut the selected drawing"),i("Mod+V","Paste drawings"),i("Mod+D","Duplicate the selected drawing"),i("Delete","Delete the selected drawing"),i("Backspace","Delete, or drop the last anchor while placing"),i("Enter","Finish the drawing being placed"),i("ArrowLeft","Nudge the selection left (Shift: ten pixels)",!1,!0),i("ArrowRight","Nudge the selection right (Shift: ten pixels)",!1,!0),i("ArrowUp","Nudge the selection up (Shift: ten pixels)",!1,!0),i("ArrowDown","Nudge the selection down (Shift: ten pixels)",!1,!0);for(const e of["Shift+ArrowLeft","Shift+ArrowRight","Shift+ArrowUp","Shift+ArrowDown"])i(e,"Nudge ten pixels",!0,!0);e.register("Escape",e=>null!==t.activeTool()?(n(e)||(t.setTool(null),this._rail?.setDrawLock(!1)),!0):t.selection().length>0&&(t.select(null),this._rail?.refresh(),!0),"widget",{label:"Leave the tool, then clear the selection",group:a});for(const[o,n]of Object.entries(z()))e.register(n,()=>{this._rail?.setDrawLock(!1),t.setTool(o)},"widget",{label:ze(o),group:"Drawing tools"});e.register("?",()=>{Ie(this.context)},"widget",{label:"Keyboard shortcuts",group:"Widget"})}_trackPointer(){const e=this.root,t=this._chartEl,o=()=>{this._pointerInside=!0},n=()=>{this._pointerInside=!1,this._pointerInChart=!1},a=()=>{this._pointerInChart=!0},i=()=>{this._pointerInChart=!1};e.addEventListener("pointerenter",o),e.addEventListener("pointerleave",n),t.addEventListener("pointerenter",a),t.addEventListener("pointerleave",i),this._cleanups.push(()=>{e.removeEventListener("pointerenter",o),e.removeEventListener("pointerleave",n),t.removeEventListener("pointerenter",a),t.removeEventListener("pointerleave",i)})}_followChart(){const e=["paneAdded","paneResized","paneMoved","paneMaximized","paneRemoved","indicatorRemoved","indicatorSettings","priceAxisMoved","objects:change"];for(const t of e)this._cleanups.push(this.chart.on(t,()=>{this._bus.emit("layout",{reason:t}),this._scheduleSave()}));for(const e of["draw:add","draw:remove","draw:update","draw:paste","draw:cut","alert:created","alert:updated","alert:removed","alert:triggered","alert:expired","alerts:restored","alerts:checkpoint"])this._cleanups.push(this.chart.on(e,()=>this._scheduleSave()));this._cleanups.push(this.chart.on("alert:triggered",e=>{const t=e;this.context.toast(t.message??t.title,"success")}));const t=this._doc.defaultView;if(null!=t&&"function"==typeof t.addEventListener){const e=()=>this._saveNow();t.addEventListener("pagehide",e),this._cleanups.push(()=>t.removeEventListener("pagehide",e))}}destroy(){if(!this._destroyed){this._saveNow(),this._destroyed=!0,this.dataController?.destroy(),this._dataStatus.destroy(),this._mobile?.destroy(),this._mobile=null,0!==this._saveTimer&&(clearTimeout(this._saveTimer),this._saveTimer=0);for(const e of this._cleanups.splice(0))e();this._topbar?.destroy(),this._rail?.destroy(),this._statusline?.destroy(),this._toasts.destroy(),this._keymap.destroy(),this.objects.destroy(),this.alerts.destroy(),this.draw.destroy(),this.chart.destroy(),this.root.remove(),this._bus.clear()}}}function hn(e,t={}){let o;if("string"==typeof e){const n=t.document??globalThis.document;if(void 0===n)throw new Error("openalgo-charts widget: a selector needs a document");if(o=n.querySelector(e)??n.getElementById(e),null===o)throw new Error(`openalgo-charts widget: no element matches "${e}"`)}else o=e;return new pn(o,t)}function un(e,t){const o=e.ownerDocument;Ot(o,Ro+qo,t.styleNonce);const n=oe(o,"div","oac-widget oac-alert-host");e.appendChild(n);const a=xe(n,o),i=ke(n,a.layer,o),r=oe(o,"div","oac-toasts");n.appendChild(r);const s=lt(r,o,t);let l=t.theme??"dark",c=t.chartTheme??("light"===l?k:C),d=!1,p=!1,h=null;function u(){const e=a.size()>0;e!==p&&(p=e,t.onOpenChange?.(p))}const b={chart:t.chart,draw:t.draw,alerts:t.alerts,root:n,document:o,get theme(){return l},get chartTheme(){return c},keymap:new Pe,bus:new pe,storage:new ue("alert-ui",null),locale:t.locale,translate:t.translate,tips:i,overlays:a,toast:(e,t)=>s.toast(e,t),status:(e,t)=>{s.toast(e,t)},symbol:()=>({symbol:t.chart.getDataContext()?.symbol??"",exchange:t.chart.getDataContext()?.exchange??""}),interval:()=>t.chart.getDataContext()?.interval??"",openOverlay:(e,t)=>{const o=a.open(e,{...t,onClose:()=>{t?.onClose?.(),u()}});return u(),o}},g=e=>{e.stopPropagation()};n.addEventListener("keydown",g);const f=t.chart.on("destroy",()=>m.destroy()),m={root:n,openList:e=>!d&&(h?.isOpen()?(h.el.focus(),!0):(h=Lo(b,e,{onClose:()=>{h=null}}),!0)),openEditor:e=>!d&&(Ao(b,void 0,e),!0),isOpen:()=>!d&&a.size()>0,close:()=>a.closeAll(),setTheme:(e,t)=>{d||(l=e,c=t??("light"===e?k:C),n.dataset.theme=e,Ct(n,kt(c,e)))},destroy:()=>{d||(d=!0,f(),a.destroy(),i.destroy(),s.destroy(),b.keymap.destroy(),b.bus.clear(),n.removeEventListener("keydown",g),n.remove())}};return m.setTheme(l,c),m}const bn="widget";export{Ye as CHART_TYPE_LABELS,Qo as DEFAULT_INTERVALS,en as DEFAULT_LOOKBACK_BARS,Ro as DIALOG_CSS,Zo as EVENT_DETAILS_CSS,Xo as EventDetailsPopup,Pe as Keymap,De as MAGNET_MODES,Ke as MIN_PRICE_DIGITS,qo as OBJECTS_PANEL_CSS,Ne as RAIL_GROUPS,Re as RAIL_PREFS_KEY,yt as RAIL_WIDTH,tn as SAVE_DEBOUNCE_MS,Ze as SEARCH_DEBOUNCE_MS,on as STATE_KEY,_t as STATUSLINE_HEIGHT,he as STORAGE_PREFIX,_e as TIP_DWELL_MS,st as TOAST_LEAVE_MS,rt as TOAST_MAX,it as TOAST_MS,ct as TOKEN_PREFIX,xt as TOPBAR_HEIGHT,Lt as WIDGET_CSS,No as WIDGET_DIALOGS,vt as WIDGET_FONT,wt as WIDGET_MONO,nn as WIDGET_STATE_VERSION,St as WIDGET_STYLE_ID,bn as WIDGET_TIER,pe as WidgetBus,ue as WidgetStorage,Ct as applyTokens,Do as attachContextMenu,de as boxIn,nt as captureName,Xe as chartTypeChoices,Je as chartTypeLabel,jo as contextMenuEntries,It as controlsFromFields,Mt as controlsFromInputs,un as createAlertUi,xe as createOverlayStack,ke as createTipController,hn as createWidget,be as defaultStorage,ot as downloadText,te as esc,Oe as eventKeyCombo,ie as focusable,re as focusables,ut as formatColor,Me as formatKeyCombo,je as fromChartCombo,ne as glyph,oe as h,ae as inTextField,Ot as injectWidgetStyles,Qe as intervalLabel,cn as loadWindow,bt as luminance,ft as mix,Ao as mountAlertEditor,Lo as mountAlertsPanel,Io as mountContextMenu,ho as mountDrawingProperties,uo as mountIndicatorPicker,fo as mountIndicatorSettings,Xt as mountLevelEditor,Go as mountMobile,Ko as mountObjectsPanel,Ve as mountRail,vo as mountSettingsDialog,Ge as mountStatusline,io as mountTextEditor,lt as mountToasts,at as mountTopbar,et as openMenu,Ie as openShortcutsPanel,pt as parseColor,Le as parseKeyCombo,le as placeBelow,se as placeBeside,ce as placeTip,qe as priceDigits,fe as registerWidgetDialog,me as registerWidgetDialogs,ye as registeredWidgetDialogs,Zt as renderForm,ln as resolveTheme,He as sanitizeRailPrefs,sn as stripView,gt as themeMode,$t as token,Fe as toolGlyph,ze as toolName,ve as unregisterWidgetDialog,we as widgetDialog,ee as widgetText,kt as widgetTokens,mt as withAlpha};
|
|
1
|
+
import{formatZonedCrosshairLabel as e,registeredChartTypes as t,getChartType as o,exportChartDataCsv as n,INDICATOR_SOURCES as a,registeredIntervals as i,registeredIndicators as r,getIndicator as s,indicatorStyleInputs as l,indicatorDefaults as c,chartSettingsSchema as d,readChartSettings as p,applyChartSettings as u,registeredBarConditions as h,utcSecondsToZonedParts as b,zoneOffsetSeconds as g,alertSettingsSchema as m,getBarCondition as f,zonedWallClockToUtcSeconds as v,PRICE_SCALE_MODES as w,isReplaying as y,checkTradingCapability as x,tryResolveInterval as _,lightTheme as k,darkTheme as C,DataLoadingController as $,resolveInterval as S,isKnownInterval as A,createChart as L,AlertController as E,ChartObjects as O}from"./openalgo-charts.mjs";import{chromeIconSvg as T,hasDrawingTool as M,DRAWING_TOOL_ICONS as j,iconUse as I,getDrawingTool as P,iconSprite as D,toolCursor as N,drawingShortcuts as z,DEFAULT_FIB as R,drawingSettingsSchema as F,gannLabel as B,formatRatio as U,readDrawingSetting as H,cloneLevels as V,applyDrawingSettings as K,LEVEL_NEUTRAL as q,levelColor as W,readDrawingSettings as G,registeredDrawingTools as Z,DrawingController as J,keyToDrawingAction as Y}from"./openalgo-charts.draw.mjs";const X=Object.freeze({}),Q=/\{([A-Za-z][A-Za-z0-9_]*)\}/g;function ee(e,t,o=X,n=t){let a=n;if(void 0!==e.translate)try{const i=e.translate(t,n,Object.freeze({...o}));if("string"==typeof i&&""!==i.trim()){const e=new Set(Array.from(n.matchAll(Q),e=>e[1])),t=new Set(Array.from(i.matchAll(Q),e=>e[1]));e.size===t.size&&[...e].every(e=>t.has(e))&&(a=i)}}catch{}return a.replace(Q,(e,t)=>Object.prototype.hasOwnProperty.call(o,t)?String(o[t]):e)}const te=e=>String(e).replace(/[&<>"]/g,e=>"&"===e?"&":"<"===e?"<":">"===e?">":""");function oe(e,t,o,n){const a=e.createElement(t);if(o&&(a.className=o),n)for(const[e,t]of Object.entries(n))a.setAttribute(e,t);return a}function ne(e,t,o){const n=e.createElement("span");return n.className="oac-glyph oac-glyph--"+o,n.setAttribute("aria-hidden","true"),n.innerHTML=t,n}function ae(e){const t=e;if(null==t)return!1;if(!0===t.isContentEditable)return!0;const o=(t.tagName??"").toUpperCase();if("TEXTAREA"===o||"SELECT"===o)return!0;if("INPUT"!==o)return!1;const n=(t.type??"text").toLowerCase();return!["checkbox","radio","button","submit","reset","range","color"].includes(n)}function ie(e){if(null===e)return!1;const t=e;if(!0===t.disabled)return!1;const o=t.getAttribute("tabindex");if(null!==o&&Number(o)<0)return!1;const n=t.tagName;if(!("BUTTON"===n||"INPUT"===n||"SELECT"===n||"TEXTAREA"===n||"A"===n&&t.hasAttribute("href"))&&null===o)return!1;for(let e=t;null!==e;e=e.parentElement)if(e.hidden)return!1;return!0}const re=e=>Array.from(e.querySelectorAll("*")).filter(ie);function se(e,t,o,n=6,a=8){let i=e.right+n,r="right";i+t.width>o.width-a&&e.left-n-t.width>=a&&(i=e.left-n-t.width,r="left"),i=Math.max(a,Math.min(i,o.width-t.width-a));return{left:i,top:Math.max(a,Math.min(e.top,o.height-t.height-a)),side:r}}function le(e,t,o,n=4,a=8){let i=e.bottom+n;return i+t.height>o.height-a&&e.top-n-t.height>=a&&(i=e.top-n-t.height),{left:Math.max(a,Math.min(e.left,o.width-t.width-a)),top:Math.max(a,Math.min(i,o.height-t.height-a))}}function ce(e,t,o,n="right",a=8,i=6){let r,s;if("right"===n||"left"===n){const l="right"===n;r=l?e.right+a:e.left-a-t.width,(l?r+t.width>o.width-i:r<i)&&(r=l?e.left-a-t.width:e.right+a),s=e.top+e.height/2-t.height/2}else{const l="top"!==n;s=l?e.bottom+a:e.top-a-t.height,(l?s+t.height>o.height-i:s<i)&&(s=l?e.top-a-t.height:e.bottom+a),r=e.left+e.width/2-t.width/2}return{left:Math.max(i,Math.min(r,o.width-t.width-i)),top:Math.max(i,Math.min(s,o.height-t.height-i))}}function de(e,t){const o=e.getBoundingClientRect(),n=t.getBoundingClientRect();return{left:n.left-o.left,top:n.top-o.top,right:n.right-o.left,bottom:n.bottom-o.top,width:n.width,height:n.height}}class pe{constructor(){Object.defineProperty(this,"_handlers",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}on(e,t){let o=this._handlers.get(e);return void 0===o&&(o=new Set,this._handlers.set(e,o)),o.add(t),()=>this.off(e,t)}off(e,t){void 0!==t?this._handlers.get(e)?.delete(t):this._handlers.delete(e)}emit(e,t){const o=this._handlers.get(e);if(void 0===o)return;const n=[];for(const e of Array.from(o))try{e(t)}catch(e){n.push(e)}if(n.length>0)throw n[0]}clear(){this._handlers.clear()}}const ue="oac-widget:";class he{constructor(e,t){Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ns",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._ns=ue+e+":",this._store=t}key(e){return this._ns+e}get(e){if(null===this._store)return null;try{const t=this._store.getItem(this.key(e));return null===t?null:JSON.parse(t)}catch{return null}}set(e,t){if(null===this._store)return!1;try{return this._store.setItem(this.key(e),JSON.stringify(t)),!0}catch{return!1}}remove(e){if(null!==this._store)try{this._store.removeItem(this.key(e))}catch{}}get enabled(){return null!==this._store}}function be(){try{const e=globalThis;return void 0!==e.localStorage&&"function"==typeof e.localStorage.getItem?e.localStorage:null}catch{return null}}const ge=new Map;function me(e,t){return ge.set(e,t),()=>{ge.get(e)===t&&ge.delete(e)}}function fe(e){const t=Object.entries(e).map(([e,t])=>me(e,t));return()=>{for(const e of t)e()}}function ve(e){return ge.delete(e)}function we(e){return ge.get(e)??null}function ye(){return Array.from(ge.keys())}function xe(e,t){const o=oe(t,"div","oac-layer");e.appendChild(o);const n=[],a=e=>{if(e.closed)return;e.closed=!0;const o=n.indexOf(e);o>=0&&n.splice(o,1);const a=t.activeElement,i=null!==a&&e.el.contains(a);e.el.remove(),e.scrim?.remove(),e.opts.anchor?.setAttribute("aria-expanded","false");const r=null===a||a===t.body||i;!1!==e.opts.restoreFocus&&r&&null!==e.restore&&e.restore.isConnected&&e.restore.focus(),e.opts.onClose?.(),0===n.length&&l()},i=e=>{const o=n[n.length-1];if(void 0===o)return;if("Escape"===e.key){if(!1===o.opts.dismissOnEscape)return;return e.preventDefault(),e.stopImmediatePropagation(),void a(o)}if("Tab"!==e.key)return;const i=re(o.el);if(0===i.length)return void e.preventDefault();const r=i.indexOf(t.activeElement);let s=null;e.shiftKey?r<=0&&(s=i.length-1):(-1===r||r>=i.length-1)&&(s=0),null!==s&&(e.preventDefault(),i[s].focus())},r=e=>{const t=e.target;for(let e=n.length-1;e>=0;e--){const o=n[e];if(null!==t&&(o.el.contains(t)||!0===o.opts.anchor?.contains(t)))break;if(!1===o.opts.dismissOnOutside||!0===o.opts.modal&&!0!==o.opts.dismissOnOutside)break;a(o)}};let s=!1;const l=()=>{s&&(s=!1,t.removeEventListener("keydown",i,!0),t.removeEventListener("pointerdown",r,!0))};return{open:(l,c={})=>{const d=c.placement??(c.anchor?"below":"center"),p=c.modal??"center"===d,u=t.activeElement,h=null===u||u===t.body||l.contains(u)?null:u;let b=null;const g={el:l,opts:{...c,modal:p},scrim:null,restore:h,closed:!1};if(p&&(b=oe(t,"div","oac-scrim"),!0===c.dismissOnOutside&&b.addEventListener("pointerdown",()=>a(g)),o.appendChild(b),g.scrim=b),l.addEventListener("pointerdown",e=>e.stopPropagation()),"center"===d?(l.classList.add("oac-dialog"),l.hasAttribute("role")||l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true")):l.classList.add("oac-pop"),l.hasAttribute("tabindex")||(l.tabIndex=-1),o.appendChild(l),"center"!==d&&c.anchor){const t=e.getBoundingClientRect();let o=de(e,c.anchor);if("beside"===d&&c.edge){const t=de(e,c.edge),n=Math.max(o.right,t.right);o={...o,right:n,width:n-o.left}}const n={width:l.offsetWidth,height:l.offsetHeight},a="beside"===d?se(o,n,t):le(o,n,t);l.style.left=a.left+"px",l.style.top=a.top+"px",c.anchor.setAttribute("aria-expanded","true")}if(n.push(g),s||(s=!0,t.addEventListener("keydown",i,!0),t.addEventListener("pointerdown",r,!0)),null!==c.initialFocus){(c.initialFocus??function(e){const t=re(e);return t.find(e=>null===e.closest(".oac-dialog__head"))??t[0]??null}(l)??l).focus()}return()=>a(g)},closeTop:()=>{const e=n[n.length-1];return void 0!==e&&(a(e),!0)},closeAll:()=>{for(const e of n.slice().reverse())a(e)},top:()=>n[n.length-1]?.el??null,size:()=>n.length,layer:o,destroy:()=>{for(const e of n.slice().reverse())a(e);l(),o.remove()}}}const _e=600;function ke(e,t,o){const n=new WeakMap;let a=null,i=0,r=null;const s=e=>"function"==typeof e?e():e,l=()=>{0!==i&&clearTimeout(i),i=0,r=null,a?.classList.remove("is-on")},c=i=>{const c=n.get(i);if(void 0===c||!i.isConnected)return;const d=s(c);if(null===d||!d.title)return void l();if("function"==typeof c&&i.setAttribute("aria-label",d.title),null===a&&(a=oe(o,"div","oac-tip",{role:"presentation"})),a.parentNode!==t&&t.appendChild(a),r=i,a.textContent="",a.appendChild(o.createTextNode(d.title)),d.chord){const e=oe(o,"kbd","oac-tip__chord");e.textContent=d.chord,a.appendChild(e)}if(d.sub){const e=oe(o,"span","oac-tip__sub");e.textContent=d.sub,a.appendChild(e)}const p=e.getBoundingClientRect(),u=ce(de(e,i),{width:a.offsetWidth,height:a.offsetHeight},p,d.side??"right");a.style.left=u.left+"px",a.style.top=u.top+"px",a.classList.add("is-on")};return{attach:(e,t,o=0)=>{n.set(e,t);const a=s(t);null!==a&&a.title&&!e.getAttribute("aria-label")&&e.setAttribute("aria-label",a.title),e.removeAttribute("title");const r=()=>{0!==i&&clearTimeout(i),o>0?i=setTimeout(()=>c(e),o):c(e)};e.addEventListener("pointerenter",r),e.addEventListener("focus",r),e.addEventListener("pointerleave",l),e.addEventListener("blur",l),e.addEventListener("pointerdown",l),e.addEventListener("keydown",l)},refreshLabel:e=>{const t=n.get(e);if("function"!=typeof t)return;const o=t();null!==o&&o.title&&e.setAttribute("aria-label",o.title)},show:c,hide:l,target:()=>r,destroy:()=>{l(),a?.remove(),a=null}}}const Ce={mod:"Mod",ctrl:"Mod",control:"Mod",cmd:"Mod",command:"Mod",meta:"Mod",win:"Mod",alt:"Alt",option:"Alt",opt:"Alt",shift:"Shift"},$e={esc:"Escape",escape:"Escape",del:"Delete",delete:"Delete",backspace:"Backspace",enter:"Enter",return:"Enter",tab:"Tab",space:"Space",spacebar:"Space",left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",arrowup:"ArrowUp",arrowdown:"ArrowDown",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",insert:"Insert",plus:"+",minus:"-",question:"?",slash:"/",period:".",comma:","},Se=new Set(["Shift","Control","Alt","Meta","OS","AltGraph","CapsLock","Fn"]),Ae=["Mod","Alt","Shift"];function Le(e){const t=e.trim();if(""===t)return"";let o,n;if("+"===t)o="+",n=[];else if(t.endsWith("++"))o="+",n=t.slice(0,-2).split("+").map(e=>e.trim());else{const e=t.split("+").map(e=>e.trim());o=e[e.length-1],n=e.slice(0,-1)}if(""===o||void 0!==Ce[o.toLowerCase()])return"";const a=new Set;for(const e of n){const t=Ce[e.toLowerCase()];if(void 0===t)return"";a.add(t)}o=function(e){const t=e.toLowerCase();return void 0!==$e[t]?$e[t]:/^f([1-9]|1[0-2])$/.test(t)?t.toUpperCase():1===e.length&&/[a-z]/i.test(e)?t:e}(o),1!==o.length||/[a-z]/.test(o)||a.delete("Shift");return[...Ae.filter(e=>a.has(e)),o].join("+")}function Ee(e){let t=e.key??"";if(""===t||"Unidentified"===t||Se.has(t))return"";" "!==t&&"Spacebar"!==t||(t="Space"),"Esc"===t&&(t="Escape"),"Del"===t&&(t="Delete");const o=e.code??"";!0===e.altKey&&/^Key[A-Z]$/.test(o)&&(t=o.slice(3).toLowerCase());const n=[];return!0!==e.ctrlKey&&!0!==e.metaKey||n.push("Mod"),!0===e.altKey&&n.push("Alt"),1===t.length?/[a-z]/i.test(t)&&(t=t.toLowerCase(),!0===e.shiftKey&&n.push("Shift")):!0===e.shiftKey&&n.push("Shift"),[...n,t].join("+")}const Oe={Escape:"Esc",Delete:"Del",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down"};function Te(){const e=globalThis.navigator;return void 0!==e&&/mac|iphone|ipad/i.test(e.platform??e.userAgent??"")}function Me(e,t=Te()){const o=Le(e);if(""===o)return"";const n=o.split("+"),a=n[n.length-1];return[...n.slice(0,-1).map(e=>"Mod"===e?t?"Cmd":"Ctrl":"Alt"===e?t?"Opt":"Alt":"Shift"),Oe[a]??(1===a.length?a.toUpperCase():a)].join("+")}function je(e){const t=e.split("+").map(e=>e.trim()).filter(e=>""!==e);if(0===t.length)return"";const o=t[t.length-1],n=t.slice(0,-1).map(e=>"Alt"===e?"Alt":"Shift"===e?"Shift":"Mod");let a;const i=/^Key([A-Z])$/.exec(o),r=/^Digit([0-9])$/.exec(o);return a=null!==i?i[1].toLowerCase():null!==r?r[1]:"Equal"===o?n.includes("Shift")?"+":"=":"Minus"===o?n.includes("Shift")?"_":"-":"NumpadAdd"===o?"+":"NumpadSubtract"===o?"-":"Slash"===o?n.includes("Shift")?"?":"/":o,Le([...n,a].join("+"))}class Ie{constructor(e={}){Object.defineProperty(this,"_isMac",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_scopes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_bindings",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_byCombo",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_conflicts",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_conflictListeners",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"_detach",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_nextId",{enumerable:!0,configurable:!0,writable:!0,value:1}),this._isMac=e.isMac??Te(),this._chart=e.chart??null,this._scopes=e.scopes??(()=>["global"])}get isMac(){return this._isMac}setScopes(e){this._scopes=e}activeScopes(){return this._scopes()}register(e,t,o="global",n={}){const a=Le(e);if(""===a)throw new Error(`openalgo-charts widget: "${e}" is not a key binding`);const i={id:this._nextId++,combo:a,scope:o,label:n.label??Me(a,this._isMac),group:n.group??"Widget",hidden:!0===n.hidden,inText:!0===n.inText,layered:!0===n.layered,action:t,when:n.when},r=this._byCombo.get(a)??[];if(!0!==n.layered){const e=r.find(e=>e.scope===o);void 0!==e&&this._conflict({combo:a,scope:o,kept:e.label,shadowed:i.label,source:"widget"})}return r.push(i),this._byCombo.set(a,r),this._bindings.push(i),()=>this._unregister(i)}_unregister(e){const t=this._bindings.indexOf(e);t>=0&&this._bindings.splice(t,1);const o=this._byCombo.get(e.combo);if(void 0!==o){const t=o.indexOf(e);t>=0&&o.splice(t,1),0===o.length&&this._byCombo.delete(e.combo)}for(let t=this._conflicts.length-1;t>=0;t--){const o=this._conflicts[t];"widget"!==o.source||o.combo!==e.combo||o.kept!==e.label&&o.shadowed!==e.label||this._conflicts.splice(t,1)}}_conflict(e){this._conflicts.push(e);for(const t of this._conflictListeners)t(e)}onConflict(e){return this._conflictListeners.add(e),()=>this._conflictListeners.delete(e)}handle(e){const t=Ee(e);if(""===t)return!1;const o=this._byCombo.get(t);if(void 0===o)return!1;const n=ae(e.target);for(const t of this._scopes())for(const a of o)if(a.scope===t&&(!n||a.inText)&&(void 0===a.when||a.when())&&!1!==a.action(e))return e.preventDefault?.(),e.stopPropagation?.(),!0;return!1}attach(e){this._detach?.();const t=e=>{this.handle(e)};return e.addEventListener("keydown",t,!0),this._detach=()=>{e.removeEventListener("keydown",t,!0),this._detach=null},this._detach}list(){return this._bindings.slice()}conflicts(){const e=this._conflicts.slice();if(null!==this._chart)for(const t of this._chart.list())if(!t.isDisabled)for(const o of t.combos){const n=je(o),a=(this._byCombo.get(n)??[]).find(e=>"overlay"!==e.scope&&"rail"!==e.scope&&!e.layered);void 0!==a&&e.push({combo:n,scope:a.scope,kept:a.label,shadowed:t.label,source:"chart"})}return e}format(e){return Me(e,this._isMac)}describe(){const e=new Map;for(const t of this._bindings){if(t.hidden)continue;const o=e.get(t.group)??[];o.push({label:t.label,combo:t.combo,display:this.format(t.combo)}),e.set(t.group,o)}const t=Array.from(e,([e,t])=>({group:e,rows:t}));if(null!==this._chart){const e=new Map;for(const t of this.conflicts())"chart"===t.source&&e.set(t.shadowed+"|"+t.combo,t.kept);const o=[];for(const t of this._chart.list()){if(t.isDisabled||0===t.combos.length)continue;const n=je(t.combos[0]),a={label:t.label,combo:n,display:this.format(n)},i=e.get(t.label+"|"+n);void 0!==i&&(a.shadowedBy=i),o.push(a)}o.length>0&&t.push({group:"Chart",rows:o})}return t}destroy(){this._detach?.(),this._bindings.length=0,this._byCombo.clear(),this._conflicts.length=0,this._conflictListeners.clear()}}function Pe(e){const t=e.document,o=oe(t,"div","oac-keys-dialog",{"aria-label":ee(e,"Keyboard shortcuts")}),n=oe(t,"div","oac-dialog__head"),a=oe(t,"div","oac-dialog__title");a.textContent=ee(e,"Keyboard shortcuts");const i=oe(t,"button","oac-btn oac-btn--icon",{type:"button","aria-label":ee(e,"Close")});i.innerHTML=T("close"),n.appendChild(a),n.appendChild(i);const r=oe(t,"div","oac-dialog__body"),s=oe(t,"div","oac-keys");let l=0;for(const o of e.keymap.describe()){const n=oe(t,"div","oac-keys__group"),a=oe(t,"div","oac-head");a.textContent=ee(e,`schema.shortcuts.group.${o.group}`,{},o.group),n.appendChild(a);for(const a of o.rows){const i=oe(t,"div","oac-keys__row"),r=oe(t,"span");r.textContent=ee(e,`schema.shortcuts.${o.group}.${a.combo}`,{},a.label);const s=oe(t,"kbd");s.textContent=a.display,i.appendChild(r),i.appendChild(s),void 0!==a.shadowedBy&&(i.classList.add("is-shadowed"),i.title=ee(e,"Claimed by {name}",{name:a.shadowedBy}),l++),n.appendChild(i)}s.appendChild(n)}if(r.appendChild(s),l>0){const o=oe(t,"div","oac-keys__note");o.textContent=ee(e,1===l?"{count} chart shortcut struck through: the same chord arms a drawing tool here and takes precedence.":"{count} chart shortcuts struck through: the same chord arms a drawing tool here and takes precedence.",{count:l}),r.appendChild(o)}o.appendChild(n),o.appendChild(r);const c=e.openOverlay(o,{placement:"center",dismissOnOutside:!0});return i.addEventListener("click",c),c}const De=["off","weak","strong"],Ne=[{id:"lines",title:"Lines",items:[{head:"Lines"},{tool:"trend-line"},{tool:"ray"},{tool:"extended-line"},{tool:"arrow"},{tool:"info-line"},{tool:"trend-angle"},{head:"Horizontal and vertical"},{tool:"horizontal-line"},{tool:"horizontal-ray"},{tool:"vertical-line"},{tool:"cross-line"}]},{id:"channels",title:"Channels",items:[{head:"Channels"},{tool:"parallel-channel"},{tool:"fib-channel"},{tool:"disjoint-channel"},{tool:"flat-top-bottom"},{tool:"regression-channel"},{head:"Pitchforks"},{tool:"pitchfork"},{tool:"schiff-pitchfork"},{tool:"modified-schiff-pitchfork"},{tool:"inside-pitchfork"}]},{id:"fib",title:"Fibonacci and Gann",items:[{head:"Fibonacci"},{tool:"fib-retracement"},{tool:"fib-extension"},{tool:"fib-time-zone"},{tool:"fib-fan"},{tool:"fib-extension-two-point"},{tool:"fib-speed-resistance-fan"},{tool:"trend-fib-time"},{tool:"fib-circles"},{tool:"fib-speed-resistance-arcs"},{tool:"fib-wedge"},{tool:"fib-spiral"},{head:"Gann"},{tool:"gann-fan"},{tool:"gann-box"},{tool:"gann-square"}]},{sep:!0},{id:"shapes",title:"Shapes",items:[{head:"Shapes"},{tool:"rectangle"},{tool:"rotated-rectangle"},{tool:"ellipse"},{tool:"circle"},{tool:"triangle"},{head:"Paths"},{tool:"path"},{tool:"polyline"},{tool:"arc"},{tool:"curve"},{tool:"double-curve"}]},{id:"cycles",title:"Cycles",items:[{head:"Cycles"},{tool:"cyclic-lines"},{tool:"time-cycles"},{tool:"sine-line"}]},{id:"patterns",title:"Patterns",items:[{head:"Patterns and waves"},{tool:"xabcd-pattern"},{tool:"abcd-pattern"},{tool:"head-shoulders"},{tool:"elliott-impulse"},{tool:"elliott-correction"},{head:"Harmonic patterns"},{tool:"gartley"},{tool:"bat"},{tool:"butterfly"},{tool:"crab"},{tool:"shark"},{tool:"cypher"}]},{id:"geometry",title:"Geometric studies",items:[{head:"Geometric studies"},{tool:"dedekind-tessellation"},{tool:"sonic"},{tool:"supersonic"},{tool:"golden-sonic"},{tool:"golden-supersonic"}]},{id:"marks",title:"Arrows and marks",items:[{head:"Arrows"},{tool:"arrow-up"},{tool:"arrow-down"},{tool:"arrow-left"},{tool:"arrow-right"},{head:"Marks"},{tool:"flag-mark"},{tool:"icon-stamp"},{tool:"price-label"},{tool:"signpost"}]},{sep:!0},{id:"forecast",title:"Forecasting",items:[{head:"Forecasting"},{tool:"long-position"},{tool:"short-position"},{tool:"forecast"}]},{id:"analysis",title:"Volume studies",items:[{head:"Volume studies"},{tool:"anchored-vwap"},{tool:"fixed-range-volume-profile"}]},{id:"measure",title:"Measurers",items:[{head:"Measurers"},{tool:"price-range"},{tool:"date-range"},{tool:"measure"}]},{sep:!0},{id:"text",title:"Text and notes",items:[{head:"Text and notes"},{tool:"text"},{tool:"note"},{tool:"callout"},{tool:"balloon"},{tool:"comment"},{tool:"price-note"},{tool:"table"},{head:"Brushes"},{tool:"brush"},{tool:"highlighter"}]}],ze=e=>null!==e&&M(e)?P(e).name:String(e??"Cursor"),Re="rail",Fe="oac-rail-sprite";function Be(e,t){if(void 0!==j[t])return ne(e,I(t),"tool");const o=oe(e,"span","oac-glyph oac-glyph--text",{"aria-hidden":"true"});return o.textContent=String(t).charAt(0).toUpperCase(),o}const Ue=(e,t)=>ne(e,T(t),"chrome");function He(e,t,o){const n={favorites:[],magnet:"off",stay:!1,last:{}};if(null===e||"object"!=typeof e)return n;const a=e;if(Array.isArray(a.favorites)&&(n.favorites=a.favorites.filter((e,t,o)=>"string"==typeof e&&M(e)&&o.indexOf(e)===t)),"string"==typeof a.magnet&&De.includes(a.magnet)&&(n.magnet=a.magnet),n.stay=!0===a.stay,null!==a.last&&"object"==typeof a.last){const e=a.last;for(const a of t)void 0!==a.id&&"string"==typeof e[a.id]&&o(a).includes(e[a.id])&&(n.last[a.id]=e[a.id])}return n}function Ve(e,t,o={}){const n=e.document,a=t=>ee(e,`schema.drawing.${t??"cursor"}.name`,{},ze(t)),i=e.draw,r=e.chart;!function(e){if(null!==e.getElementById(Fe))return;const t=e.createElement("div");t.id=Fe,t.hidden=!0,t.innerHTML=D(),(e.body??e.documentElement).appendChild(t)}(n);const s=void 0===o.tools?null:new Set(o.tools),l=e=>(e.items??[]).filter(e=>void 0!==e.tool&&M(e.tool)&&(null===s||s.has(e.tool))).map(e=>e.tool),c=e=>Ne.find(t=>t.id===e);let d=He(e.storage.get(Re),Ne,l);null===e.storage.get(Re)&&o.favorites&&(d.favorites=o.favorites.filter((e,t,o)=>M(e)&&o.indexOf(e)===t));let p=!1;const u=()=>{e.storage.set(Re,d)},h=e=>d.last[e.id??""]??l(e)[0]??null;let b=null;const g=t=>{if(null===t)return;null===b&&(b=z());const o=b[t];return void 0===o?void 0:e.keymap.format(o)},m=()=>{const e=i;if("function"==typeof e.selection)return e.selection().slice();const t=i.selected();return null===t?[]:[t]},f=e=>e.length>0&&e.every(e=>!0===i.get(e)?.locked),v=e=>e.length>0&&e.every(e=>!1===i.get(e)?.visible),w=e=>{const t=o.cursorTarget;t&&(null!==e&&void 0!==j[e]?t.style.setProperty("--oac-tool-cursor",N(e)):t.style.removeProperty("--oac-tool-cursor"))},y=()=>{i.setOptions({magnet:d.magnet})},x=()=>{i.setOptions({stayInDrawingMode:d.stay||p})},_=e=>{if(!De.includes(e))throw new Error(`openalgo-charts widget: unknown magnet mode "${String(e)}"`);d.magnet=e,u(),y(),K()},k=()=>{const t=De[(De.indexOf(d.magnet)+1)%De.length];return _(t),e.status(ee(e,"off"===t?"Magnet off":"weak"===t?"Magnet weak: snaps when O/H/L/C is within a few pixels":"Magnet strong: every anchor lands on the nearest O/H/L/C")),t},C=t=>{d.stay=!0===t,u(),x(),K(),e.status(d.stay?ee(e,"Tools stay armed after each drawing"):ee(e,"One drawing per pick"))},$=e=>{p=!0===e,x(),Q(i.activeTool())},S=e=>{i.setTool(e),Q(e)},A=t=>{$(!0),S(t),e.status(ee(e,"{name} stays armed until Escape",{name:a(t)}))};t.classList.add("oac-rail"),t.setAttribute("role","toolbar"),t.setAttribute("aria-orientation","vertical"),t.setAttribute("aria-label",ee(e,"Drawing tools"));const L=t=>{const o=oe(n,"button","oac-rail__btn"+(t.cls?" "+t.cls:""),{type:"button"});return o.tabIndex=-1,o.appendChild(t.glyphEl),e.tips.attach(o,t.tip,600),o.addEventListener("click",e=>{o.classList.contains("is-off")||t.onClick(e)}),t.onContext&&o.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation(),t.onContext?.(e)}),o},E=(e,t)=>{const o=e.querySelector(".oac-glyph");o?o.replaceWith(t):e.insertBefore(t,e.firstChild)},O=()=>oe(n,"div","oac-rail__sep",{role:"separator"}),I=t=>{const o=L({cls:"oac-rail__tool oac-rail__fav",glyphEl:Be(n,t),tip:()=>({title:a(t),chord:g(t),sub:ee(e,"Pinned. Right-click to unpin"),side:"right"}),onClick:e=>{e.detail>=2&&!d.stay?A(t):($(!1),S(t))},onContext:()=>U(o,[{label:ee(e,"Unpin from rail"),icon:"star",onSelect:()=>Z(t,!1)}])});return o.dataset.tools=t,o},P=t=>{const o=l(t),r=L({cls:"oac-rail__tool oac-rail__group",glyphEl:Be(n,h(t)??o[0]),tip:()=>({title:a(h(t)),chord:g(h(t)),sub:ee(e,d.stay?"{group}: chevron for the rest":"{group}: chevron for the rest. Double-click keeps it armed",{group:void 0===t.title?"":ee(e,`schema.rail.${t.id}.title`,{},t.title)}),side:"right"}),onClick:e=>{const o=e.target,n=null!==o&&"function"==typeof o.closest&&null!==o.closest(".oac-rail__chev");if(null===R||"true"!==r.getAttribute("aria-expanded"))if(n)B(t,r,!1);else{if(e.detail>=2&&!d.stay){const e=h(t);return void(null!==e&&A(e))}i.activeTool()!==h(t)?($(!1),S(h(t))):B(t,r,!1)}else F()},onContext:()=>B(t,r,!1)});r.dataset.tools=o.join(","),r.dataset.group=t.id??"",r.dataset.face=h(t)??"",r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false");const s=oe(n,"span","oac-rail__chev",{"aria-hidden":"true"});return s.innerHTML=T("chevron-right"),r.appendChild(s),r};let R=null;const F=()=>{R?.close()},B=(o,r,l)=>{F(),e.tips.hide();const c=oe(n,"div","oac-fly",{role:"menu","aria-label":void 0===o.title?ee(e,"Tools"):ee(e,`schema.rail.${o.id}.title`,{},o.title)}),p=i.activeTool(),h=[];for(const t of o.items??[]){if(void 0!==t.head){const a=oe(n,"div","oac-head");a.textContent=ee(e,`schema.rail.${o.id}.group.${t.head}`,{},t.head),c.appendChild(a);continue}const i=t.tool;if(void 0===i||!M(i)||null!==s&&!s.has(i))continue;const l=oe(n,"div","oac-fly__row",{role:"menuitemradio","aria-checked":String(p===i)});l.tabIndex=-1,l.dataset.tool=i,l.appendChild(Be(n,i));const d=oe(n,"span","oac-fly__name");d.textContent=a(i),l.appendChild(d);const u=W(i),m=oe(n,"button","oac-fly__star",{type:"button","aria-pressed":String(u),"aria-label":ee(e,u?"Unpin from rail":"Pin to rail")});m.tabIndex=-1,m.innerHTML=T(u?"star-filled":"star"),l.appendChild(m);const f=oe(n,"kbd","oac-fly__chord");f.textContent=g(i)??"",l.appendChild(f);const v=()=>{const t=!W(i);Z(i,t),m.setAttribute("aria-pressed",String(t)),m.setAttribute("aria-label",ee(e,t?"Unpin from rail":"Pin to rail")),m.innerHTML=T(t?"star-filled":"star")};m.addEventListener("click",e=>{e.stopPropagation(),v()}),l.addEventListener("click",e=>{e.stopPropagation(),b(i)}),l.addEventListener("keydown",e=>{const t=e;"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),null!==t.target.closest(".oac-fly__star")?v():(b(i),r.focus()))}),h.push(l),c.appendChild(l)}const b=e=>{void 0!==o.id&&(d.last[o.id]=e,u()),F(),$(!1),S(e)};c.addEventListener("keydown",e=>{const t=e,o=t.target.closest(".oac-fly__row"),n=null===o?-1:h.indexOf(o),a=e=>{h[(e+h.length)%h.length]?.focus()};switch(t.key){case"ArrowDown":a(n+1);break;case"ArrowUp":a(n-1);break;case"Home":a(0);break;case"End":a(h.length-1);break;case"ArrowRight":o?.querySelector(".oac-fly__star")?.focus();break;case"ArrowLeft":o?.focus();break;default:return}t.preventDefault(),t.stopPropagation()});const m=h.find(e=>"true"===e.getAttribute("aria-checked"))??h[0]??null,f=e.openOverlay(c,{anchor:r,placement:"beside",edge:t,initialFocus:l?m:c,onClose:()=>{null!==R&&R.el===c&&(R=null)}});R={el:c,close:f}},U=(o,a)=>{e.tips.hide();const i=oe(n,"div","oac-menu",{role:"menu"});let r=()=>{};for(const e of a){const t=oe(n,"button","oac-menu__row"+(e.danger?" is-danger":""),{type:"button",role:"menuitem","aria-disabled":String(!0===e.disabled)});t.appendChild(void 0!==e.tool?Be(n,e.tool):void 0!==e.icon?Ue(n,e.icon):oe(n,"span","oac-glyph"));const o=oe(n,"span","oac-menu__label");o.textContent=e.label,t.appendChild(o),t.addEventListener("click",t=>{t.stopPropagation(),e.disabled||(r(),e.onSelect())}),i.appendChild(t)}r=e.openOverlay(i,{anchor:o,placement:"beside",edge:t})},H={},V=(e,t)=>{void 0!==e&&(e.classList.toggle("is-on",!0===t.on),e.classList.toggle("is-off",!0===t.off),e.setAttribute("aria-disabled",!0===t.off?"true":"false"),void 0!==t.pressed&&e.setAttribute("aria-pressed",String(t.pressed)),void 0!==t.glyph&&e.dataset.glyph!==t.glyph&&(e.dataset.glyph=t.glyph,E(e,Ue(n,t.glyph))))},K=()=>{if(void 0===H.magnet)return;V(H.magnet,{on:"strong"===d.magnet,pressed:"off"!==d.magnet}),H.magnet.classList.toggle("is-weak","weak"===d.magnet),H.magnet.dataset.mode=d.magnet,V(H.stay,{on:d.stay,pressed:d.stay});const t=m(),o=0===t.length,n=!o&&f(t),a=!o&&v(t);V(H.lock,{off:o,on:n,pressed:n,glyph:n?"unlock":"lock"}),V(H.eye,{off:o,on:a,pressed:a,glyph:a?"eye-off":"eye"}),V(H.trash,{off:o}),V(H.undo,{off:!i.canUndo()}),V(H.redo,{off:!i.canRedo()});for(const t of Object.values(H))e.tips.refreshLabel(t)};let q=null;const W=e=>d.favorites.includes(e),G=()=>{if(null===q)return;q.textContent="";const e=d.favorites.filter(e=>M(e));if(0!==e.length){q.appendChild(O());for(const t of e)q.appendChild(I(t))}},Z=(e,t=!W(e))=>{if(!M(e))return;const o=W(e);t&&!o&&d.favorites.push(e),!t&&o&&d.favorites.splice(d.favorites.indexOf(e),1),u(),G(),Q(i.activeTool())},J=()=>Array.from(t.querySelectorAll(".oac-rail__btn")),Y=e=>{for(const t of J())t.tabIndex=t===e?0:-1},X=()=>{t.textContent="",t.appendChild((()=>{const t=L({cls:"oac-rail__tool",glyphEl:Be(n,"cursor"),tip:()=>({title:ee(e,"Cursor"),chord:"Esc",side:"right"}),onClick:()=>{$(!1),S(null)}});return t.dataset.tools="",t})()),q=oe(n,"div","oac-rail__favs"),t.appendChild(q),G(),t.appendChild(O());for(const e of Ne)e.sep?t.appendChild(O()):l(e).length>0&&t.appendChild(P(e));t.appendChild((()=>{const t=oe(n,"div","oac-rail__ctl");return H.magnet=L({cls:"oac-rail__btn--magnet",glyphEl:Be(n,"magnet"),tip:()=>({title:ee(e,"Magnet: {mode}",{mode:ee(e,`schema.magnet.${d.magnet}`,{},d.magnet)}),sub:"off"===d.magnet?ee(e,"Click for weak: snaps when O/H/L/C is within a few pixels"):"weak"===d.magnet?ee(e,"Click for strong: every anchor lands on the nearest O/H/L/C"):ee(e,"Click to switch the magnet off"),side:"right"}),onClick:()=>{k()}}),t.appendChild(H.magnet),H.stay=L({cls:"oac-rail__btn--chrome",glyphEl:Ue(n,"link"),tip:()=>({title:ee(e,"Keep tool armed"),sub:d.stay?ee(e,"On: the tool stays armed after each drawing"):ee(e,"Off: one drawing per pick"),side:"right"}),onClick:()=>C(!d.stay)}),t.appendChild(H.stay),t.appendChild(O()),H.lock=L({cls:"oac-rail__btn--chrome",glyphEl:Ue(n,"lock"),tip:()=>{const t=m();return 0===t.length?{title:ee(e,"Lock drawing"),sub:ee(e,"Select a drawing first"),side:"right"}:{title:f(t)?ee(e,"Unlock drawing"):ee(e,"Lock drawing"),side:"right"}},onClick:()=>{const e=m(),t=!f(e);for(const o of e)i.update(o,{locked:t});K()}}),t.appendChild(H.lock),H.eye=L({cls:"oac-rail__btn--chrome",glyphEl:Ue(n,"eye"),tip:()=>{const t=m();return 0===t.length?{title:ee(e,"Hide drawing"),sub:ee(e,"Select a drawing first"),side:"right"}:v(t)?{title:ee(e,"Show drawing"),side:"right"}:{title:ee(e,"Hide drawing"),sub:ee(e,"Stays selected, so the eye brings it back"),side:"right"}},onClick:()=>{const e=m(),t=v(e);for(const o of e)i.update(o,{visible:t});K()}}),t.appendChild(H.eye),H.trash=L({cls:"oac-rail__btn--chrome oac-rail__btn--danger",glyphEl:Ue(n,"trash"),tip:()=>{const t=m();return t.length>0?{title:t.length>1?ee(e,"Delete {count} drawings",{count:t.length}):ee(e,"Delete drawing"),chord:"Del",sub:ee(e,"Right-click to remove all"),side:"right"}:{title:ee(e,"Delete drawing"),chord:"Del",sub:ee(e,"Select one first. Right-click to remove all"),side:"right"}},onClick:()=>{for(const e of m())i.remove(e);K()},onContext:()=>{const t=i.drawings().length;U(H.trash,[{label:ee(e,"Select all ({count})",{count:t}),icon:"cursor",disabled:0===t,onSelect:()=>{i.select(i.drawings().map(e=>e.id)),K()}},{label:ee(e,"Remove all drawings ({count})",{count:t}),icon:"trash",danger:!0,disabled:0===t,onSelect:()=>{i.clear(),K(),e.status(t>0?ee(e,1===t?"Removed {count} drawing":"Removed {count} drawings",{count:t}):ee(e,"No drawings to remove"))}}])}}),t.appendChild(H.trash),t.appendChild(O()),H.undo=L({cls:"oac-rail__btn--chrome",glyphEl:Ue(n,"undo"),tip:()=>({title:ee(e,"Undo"),chord:e.keymap.format("Mod+Z"),side:"right"}),onClick:()=>{i.undo(),K()}}),t.appendChild(H.undo),H.redo=L({cls:"oac-rail__btn--chrome",glyphEl:Ue(n,"redo"),tip:()=>({title:ee(e,"Redo"),chord:e.keymap.format("Mod+Y"),side:"right"}),onClick:()=>{i.redo(),K()}}),t.appendChild(H.redo),t})()),Q(i.activeTool())},Q=o=>{const a=o??null;let i=null;for(const o of Array.from(t.querySelectorAll(".oac-rail__tool"))){const t=(o.dataset.tools??"").split(",").filter(Boolean),r=null===a?0===t.length:t.includes(a);o.classList.toggle("is-on",r),o.classList.toggle("is-held",r&&p&&t.length>0),o.setAttribute("aria-pressed",String(r)),r&&null===i&&(i=o),r&&o.dataset.group&&t.length>0&&null!==a&&(d.last[o.dataset.group]!==a&&(d.last[o.dataset.group]=a,u()),o.dataset.face!==a&&(o.dataset.face=a,E(o,Be(n,a)))),e.tips.refreshLabel(o)}const r=n.activeElement;null===i||null!==r&&t.contains(r)||Y(i),w(a),K()},te=()=>{const e=n.activeElement;return null!==e&&t.contains(e)?e.closest(".oac-rail__btn"):null},ne=e=>{const t=J();if(0===t.length)return;const o=t[(e%t.length+t.length)%t.length];Y(o),o.focus()},ae=[],ie=(t,o,n)=>{ae.push(e.keymap.register(t,o,"rail",{label:n,group:"Tool rail"}))};ie("ArrowDown",()=>{ne(J().indexOf(te())+1)},"Next tool"),ie("ArrowUp",()=>{ne(J().indexOf(te())-1)},"Previous tool"),ie("Home",()=>{ne(0)},"First tool"),ie("End",()=>{ne(J().length-1)},"Last tool"),ie("ArrowRight",()=>{const e=te(),t=e?.dataset.group?c(e.dataset.group):void 0;return null!==e&&void 0!==t&&(B(t,e,!0),!0)},"Open the group"),ie("Escape",()=>{const t=null!==R;F(),e.tips.hide();const n=o.cursorTarget;return void 0!==n&&"function"==typeof n.focus?n.focus():te()?.blur(),t},"Back to the chart");const re=e=>{const t=e.target,o=null!==t&&"function"==typeof t.closest?t.closest(".oac-rail__btn"):null;null!==o&&Y(o)};t.addEventListener("focusin",re);const se=[];se.push(r.on("draw:tool",e=>{Q(e.tool)}));for(const e of["draw:select","drawing:select","drawing:change","draw:add","draw:remove","draw:update","draw:paste","draw:cut"])se.push(r.on(e,K));return y(),x(),X(),{el:t,sync:Q,refresh:K,prefs:()=>({favorites:d.favorites.slice(),magnet:d.magnet,stay:d.stay,last:{...d.last}}),restorePrefs:e=>{d=He(e,Ne,l),u(),y(),x(),X()},magnetMode:()=>d.magnet,setMagnetMode:_,cycleMagnet:k,stayMode:()=>d.stay,setStayMode:C,favorites:()=>d.favorites.slice(),isFavorite:W,toggleFavorite:Z,setDrawLock:$,drawLocked:()=>p,openGroup:(e,o=!1)=>{const n=c(e),a=t.querySelector(`.oac-rail__group[data-group="${e}"]`);void 0!==n&&null!==a&&B(n,a,o)},closeFlyout:F,flyoutOpen:()=>null!==R,destroy:()=>{F();for(const e of se)e();for(const e of ae)e();t.removeEventListener("focusin",re),w(null),t.textContent=""}}}const Ke=2;function qe(e){const t=e.panes()[0];if(void 0===t)return 2;const o=t.priceScale.precision();return Number.isFinite(o)?Math.max(2,Math.min(8,Math.round(o))):2}function We(e,t,o){let n=o.get(t);return void 0===n&&(n=new Intl.NumberFormat(e,{minimumFractionDigits:t,maximumFractionDigits:t}),o.set(t,n)),n}function Ge(t,o,n={}){const a=t.document,i=t.chart,r=n.locale??t.locale;o.classList.add("oac-statusline"),o.setAttribute("role","status"),o.setAttribute("aria-live","polite");const s=oe(a,"span","oac-statusline__title"),l=oe(a,"span","oac-statusline__sym"),c=oe(a,"span","oac-statusline__iv");s.appendChild(l),s.appendChild(c),o.appendChild(s);const d=(e,t)=>{const n=oe(a,"span","oac-statusline__field "+t),i=oe(a,"i");i.textContent=e;const r=oe(a,"b");return n.appendChild(i),n.appendChild(r),n.hidden=!0,o.appendChild(n),{el:n,val:r}},p=d(ee(t,"O"),"oac-statusline__o"),u=d(ee(t,"H"),"oac-statusline__h"),h=d(ee(t,"L"),"oac-statusline__l"),b=d(ee(t,"C"),"oac-statusline__c"),g=d("","oac-statusline__chg"),m=d(ee(t,"Vol"),"oac-statusline__vol"),f=d(ee(t,"OI"),"oac-statusline__oi"),v=oe(a,"span","oac-statusline__time");o.appendChild(v);const w=oe(a,"span","oac-statusline__msg");o.appendChild(w);const y=oe(a,"span","oac-statusline__tz");o.appendChild(y);const x=new Map,_=new Intl.NumberFormat(r,{minimumFractionDigits:2,maximumFractionDigits:2}),k=new Intl.NumberFormat(r,{notation:"compact",maximumFractionDigits:2});let C=null,$=null;const S=(e,t)=>{e.textContent!==t&&(e.textContent=t)},A=(e,t)=>{e.hidden===t&&(e.hidden=!t)},L=()=>{const t=i.statusLineOptions();A(s,!1!==t.title);const o=!1!==t.chartValues&&null!==C;for(const e of[p,u,h,b])A(e.el,o);const n=qe(i);if(o&&null!==C){const e=We(r,n,x);S(p.val,e.format(C.open)),S(u.val,e.format(C.high)),S(h.val,e.format(C.low)),S(b.val,e.format(C.close))}const a=!1!==t.barChange&&null!==C;if(A(g.el,a),a&&null!==C){const e=C.close-C.open,t=0!==C.open?e/C.open*100:0,o=e>0?"+":"";S(g.val,`${o}${We(r,n,x).format(e)} (${o}${_.format(t)}%)`),g.el.classList.toggle("is-up",e>0),g.el.classList.toggle("is-down",e<0)}const l=!1!==t.volume&&null!==C&&"number"==typeof C.volume;A(m.el,l),l&&null!==C&&S(m.val,k.format(C.volume));const c=!0===t.openInterest&&!1!==i.hasOpenInterest&&void 0!==C?.oi&&Number.isFinite(C.oi);A(f.el,c),c&&void 0!==C?.oi&&S(f.val,k.format(C.oi)),S(v,null!==$&&null!==C?e($,i.timezone()):""),S(y,i.timezone())},E=()=>{const e=i.primarySeries()?.getData()??[],t=e[e.length-1];return void 0===t?{bar:null,time:null}:{bar:t,time:t.time}},O=(e,t)=>{e===C&&t===$||(C=e,$=t,L())},T=i.on("crosshair:move",e=>{const t=e;if(null!==t.bar&&void 0!==t.bar)return void O(t.bar,t.time);const o=E();O(o.bar,o.time)}),M=i.on("data:context",L),j=i.on("resize",()=>{if(null===C){const e=E();O(e.bar,e.time)}}),I={el:o,setMessage:(e,t="info")=>{S(w,e),w.classList.toggle("is-error","error"===t)},setSymbol:(e,t,o)=>{S(l,t?`${t}:${e}`:e),S(c,o)},setBar:O,refresh:()=>{if(null===C){const e=E();C=e.bar,$=e.time}L()},destroy:()=>{T(),M(),j(),o.textContent=""}};return L(),I}const Ze=150;function Je(e){if("string"!=typeof e)return null;const t=e.trim();if(/^https:\/\/[^\s]+$/i.test(t))try{const e=new URL(t);return e.username||e.password?null:e.href}catch{return null}return/^\/(?!\/)[\w./%-]+(?:\?[\w=&.%-]+)?$/.test(t)?t:null}let Ye=0;function Xe(e,t,o){const n=e.document,a="mobile"===o.variant;let i,r=!1,s=0,l=null,c=null,d=null,p=null,u=[],h="",b=null,g=[],m=0,f="",v=!1;const w=()=>{s++,null!==l&&(clearTimeout(l),l=null)},y=()=>{w();const e=p;p=null,c=null,d=null,u=[],g=[],b=null,h="",v=!1,t.setAttribute("aria-expanded","false"),t.removeAttribute("aria-controls"),e?.()},x=e=>{if(r||v||!g.includes(e)||t.value.trim()!==f||(void 0===o.context?void 0:JSON.stringify(o.context()))!==i)return;const n=e.symbol.trim();""!==n&&(y(),o.onSelect(n,e.exchange),t.blur())},_=()=>{if(null===c||null===d)return;const t=c.querySelector(".oac-symbol-picker__categories");t.textContent="";const o=Array.from(new Set(u.map(e=>e.assetClass?.trim()).filter(e=>Boolean(e))));if(o.length>1)for(const a of["",...o]){const o=oe(n,"button","oac-symbol-picker__category",{type:"button","aria-pressed":String(h===a)});o.textContent=a||ee(e,"schema.ui.allAssets",{},"All"),o.addEventListener("click",()=>{w(),h=a,b=null,m=0,_()}),t.appendChild(o)}d.textContent="";const i=u.filter(e=>""===h||e.assetClass===h),r=b?.contractGroup;if(g=void 0===r?i.slice():r.contracts.filter(e=>"string"==typeof e.symbol),void 0!==r){const t=oe(n,"button","oac-symbol-picker__back",{type:"button"});if(t.textContent=ee(e,"schema.ui.backToSymbols",{},"Back to symbols"),t.addEventListener("click",()=>{b=null,m=0,_()}),d.appendChild(t),r.label){const e=oe(n,"div","oac-head");e.textContent=r.label,d.appendChild(e)}}if(g.forEach((t,o)=>{if("string"!=typeof t.symbol)return;const i=oe(n,"button","oac-symbol-picker__row oac-menu__row"+(o===m?" is-active":""),{type:"button",role:"option"});a&&(i.dataset.mobileAction="pick-symbol");const r=Je(t.iconUrl);if(null!==r){const e=oe(n,"img","oac-symbol-picker__icon",{src:r,alt:""});i.appendChild(e)}const s=oe(n,"span","oac-menu__label");if(s.textContent=t.exchange?`${t.exchange}:${t.symbol}`:t.symbol,i.appendChild(s),t.name){const e=oe(n,"span","oac-menu__sub");e.textContent=t.name,i.appendChild(e)}if(t.contractGroup){const t=oe(n,"span","oac-symbol-picker__group");t.textContent=ee(e,"schema.ui.showContracts",{},"Contracts"),i.appendChild(t)}i.addEventListener("click",e=>{e.stopPropagation(),t.contractGroup?(b=t,m=0,_()):x(t)}),d?.appendChild(i)}),0===g.length){const t=oe(n,"div","oac-symbol-picker__empty",{role:"status"});t.textContent=ee(e,"schema.ui.noSymbols",{},"No symbols found"),d.appendChild(t)}},k=x=>{if(w(),f=x.trim(),""===f)return void y();h="",b=null,u=[],g=[],m=0,i=void 0===o.context?void 0:JSON.stringify(o.context());const k=s;if(v=!0,(()=>{if(null!==c)return;if(c=oe(n,"div","oac-symbol-picker "+(a?"oac-mobile-results":"oac-menu oac-sym__results"),{role:a?"region":"listbox","aria-label":ee(e,"schema.ui.symbolResults",{},"Symbols")}),a){const t=oe(n,"div","oac-mobile-results__head"),o=oe(n,"strong");o.textContent=ee(e,"schema.ui.symbolResults",{},"Symbols");const a=oe(n,"button","oac-mobile__action",{type:"button"});a.dataset.mobileAction="close-search",a.textContent=ee(e,"schema.ui.closeSearch",{},"Close"),a.addEventListener("click",y),t.append(o,a),c.appendChild(t)}const o=oe(n,"div","oac-symbol-picker__categories");c.appendChild(o),d=oe(n,"div",a?"oac-mobile-results__list":"oac-menu__body"),d.setAttribute("role","listbox"),d.id="oac-symbol-picker-"+ ++Ye,c.appendChild(d),t.setAttribute("aria-controls",d.id),t.setAttribute("aria-expanded","true");const i=c;p=e.openOverlay(c,{anchor:t,placement:"below",initialFocus:null,dismissOnOutside:!0,onClose:()=>{c===i&&y()}})})(),null!==c&&(c.querySelector(".oac-symbol-picker__categories").textContent=""),null!==d){d.textContent="";const t=oe(n,"div","oac-symbol-picker__status",{role:"status"});t.textContent=ee(e,"schema.ui.searchingSymbols",{},"Searching"),d.appendChild(t)}l=setTimeout(()=>{let e;l=null;try{e=Promise.resolve(o.search(f))}catch{return void y()}e.then(e=>{r||k!==s||null===c||t.value.trim()!==f||(void 0===o.context?void 0:JSON.stringify(o.context()))!==i||(v=!1,u=e.filter(e=>"string"==typeof e.symbol&&""!==e.symbol.trim()),0!==u.length?(m=0,_()):y())},()=>{k===s&&y()})},150)},C=()=>k(t.value),$=e=>{if(!e.isComposing&&229!==e.keyCode)if("Escape"!==e.key){if(!v&&t.value.trim()===f&&(void 0===o.context?void 0:JSON.stringify(o.context()))===i)if("ArrowDown"===e.key||"ArrowUp"===e.key){if(0===g.length)return;e.preventDefault(),e.stopImmediatePropagation(),m=(m+("ArrowDown"===e.key?1:-1)+g.length)%g.length,_()}else if("Enter"===e.key&&void 0!==g[m]){e.preventDefault(),e.stopImmediatePropagation();const t=g[m];t.contractGroup?(b=t,m=0,_()):x(t)}}else null!==c&&(e.preventDefault(),y())},S=e=>{const t=e.relatedTarget;null!==t&&!0===c?.contains(t)||y()};t.addEventListener("input",C),t.addEventListener("keydown",$),t.addEventListener("blur",S),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-expanded","false");const A=e.bus.on("symbol",y),L=e.bus.on("interval",y);return{open:e=>{r||(t.focus(),void 0!==e&&(t.value=e),""!==t.value.trim()&&k(t.value))},canCommitRaw:()=>!v&&0===g.length,close:y,destroy:()=>{r||(r=!0,y(),A(),L(),t.removeEventListener("input",C),t.removeEventListener("keydown",$),t.removeEventListener("blur",S))}}}const Qe="\n.oac-widget .oac-symbol-picker{min-width:250px;max-width:min(420px,calc(100vw - 24px))}\n.oac-widget .oac-symbol-picker__categories{display:flex;gap:4px;overflow-x:auto;padding:5px 7px;scrollbar-color:var(--oac-sb-thumb) var(--oac-panel);scrollbar-width:thin}\n.oac-widget .oac-symbol-picker__categories::-webkit-scrollbar{height:6px}\n.oac-widget .oac-symbol-picker__categories::-webkit-scrollbar-track{background:var(--oac-panel)}\n.oac-widget .oac-symbol-picker__categories::-webkit-scrollbar-thumb{background:var(--oac-sb-thumb);border-radius:3px}\n.oac-widget .oac-symbol-picker__categories::-webkit-scrollbar-thumb:hover{background:var(--oac-sb-thumb-hover)}\n.oac-widget .oac-symbol-picker__categories:empty{display:none}\n.oac-widget .oac-symbol-picker__category,.oac-widget .oac-symbol-picker__back{background:transparent;border:0;color:inherit;cursor:pointer;padding:4px 7px;font:inherit}\n.oac-widget .oac-symbol-picker__category[aria-pressed=true]{background:var(--oac-elev);border-radius:4px}\n.oac-widget .oac-symbol-picker__row{display:flex;align-items:center;gap:7px;width:100%;text-align:left}\n.oac-widget .oac-symbol-picker__icon{width:18px;height:18px;object-fit:contain}\n.oac-widget .oac-symbol-picker__group{margin-left:auto;opacity:.7}\n.oac-widget .oac-symbol-picker__empty,.oac-widget .oac-symbol-picker__status{padding:9px;color:var(--oac-mut)}\n",et={candlestick:"Candles","hollow-candle":"Hollow candles",bar:"Bars","high-low":"High-low","volume-candle":"Volume candles",line:"Line","line-markers":"Line with markers",step:"Step line",area:"Area","hlc-area":"HLC area",baseline:"Baseline","point-figure":"Point and figure",kagi:"Kagi"};function tt(e){const t=et[e];return void 0!==t?t:e.replace(/[-_]+/g," ").replace(/^\w/,e=>e.toUpperCase())}function ot(){return t().filter(e=>{try{return o(e).isPriceSeries}catch{return!1}})}function nt(e){const t=/^(\d*)\s*([smhdwSMHDW])$/.exec(e.trim());if(null===t)return e.toUpperCase();const o=""===t[1]||"1"===t[1]?"":t[1],n=t[2];return"m"===n?`${""===t[1]?"1":t[1]}m`:"s"===n?`${""===t[1]?"1":t[1]}s`:"h"===n||"H"===n?`${""===t[1]?"1":t[1]}h`:o+n.toUpperCase()}function at(e,t,o,n={}){const a=e.document,i=oe(a,"div","oac-menu",{role:"menu"});n.ariaLabel&&i.setAttribute("aria-label",n.ariaLabel);let r=null;if(n.find){const e=oe(a,"div","oac-menu__find");r=oe(a,"input",void 0,{type:"text",placeholder:n.find,"aria-label":n.find}),e.appendChild(r),i.appendChild(e)}const s=oe(a,"div","oac-menu__body");i.appendChild(s);let l=()=>{};const c=t=>{const n=t.trim().toLowerCase();s.textContent="";let i=0,r=null;for(const e of o){if("string"==typeof e){r=e;continue}if(""!==n&&!e.label.toLowerCase().includes(n)&&!(e.sub??"").toLowerCase().includes(n))continue;if(null!==r){const e=oe(a,"div","oac-head");e.textContent=r,s.appendChild(e),r=null}const t=oe(a,"button","oac-menu__row"+(e.danger?" is-danger":""),{type:"button",role:"menuitemradio","aria-checked":String(!0===e.on),"aria-disabled":String(!0===e.disabled)}),o=oe(a,"span","oac-menu__label");if(o.textContent=e.label,t.appendChild(o),e.sub){const o=oe(a,"span","oac-menu__sub");o.textContent=e.sub,t.appendChild(o)}if(e.key){const o=oe(a,"kbd","oac-menu__key");o.textContent=e.key,t.appendChild(o)}t.addEventListener("click",t=>{t.stopPropagation(),e.disabled||(l(),e.onSelect())}),s.appendChild(t),i++}if(0===i){const t=oe(a,"div","oac-menu__empty");t.textContent=ee(e,"No match"),s.appendChild(t)}};if(c(""),null!==r){const e=r;e.addEventListener("input",()=>c(e.value)),e.addEventListener("keydown",e=>{if("Enter"!==e.key)return;const t=s.querySelectorAll(".oac-menu__row");1===t.length&&t[0].click()})}return i.addEventListener("keydown",e=>{const t=e,o=Array.from(s.querySelectorAll(".oac-menu__row")),n=o.indexOf(a.activeElement);"ArrowDown"===t.key?(o[(n+1)%o.length]?.focus(),t.preventDefault(),t.stopPropagation()):"ArrowUp"===t.key&&(o[(n-1+o.length)%o.length]?.focus(),t.preventDefault(),t.stopPropagation())}),l=e.openOverlay(i,{anchor:t,placement:"below",initialFocus:r??s.querySelector('.oac-menu__row[aria-checked="true"]')??void 0}),l}function it(e,t={}){const o=e.brandingOptions?.();if(!o||"string"!=typeof o.href||!/^https?:\/\//i.test(o.href))return null;const n="string"==typeof o.label&&""!==o.label.trim()?o.label.trim():ee(t,"Chart branding");return{href:o.href,label:n}}function rt(e,t,o,n){const a=globalThis;if(void 0===a.Blob||void 0===a.URL||"function"!=typeof a.URL.createObjectURL)return!1;const i=e.createElement("a"),r=a.URL.createObjectURL(new a.Blob([o],{type:n}));try{i.href=r,i.download=t,(e.body??e.documentElement).appendChild(i),i.click()}finally{i.remove(),setTimeout(()=>a.URL?.revokeObjectURL(r),0)}return!0}function st(e,t,o=new Date){const n=o.toISOString().slice(0,16).replace(/[:T]/g,"-");return`${(e||"chart").replace(/[^A-Za-z0-9._-]/g,"")}-${t||"chart"}-${n}`}function lt(e,t,o){const a=e.document;t.classList.add("oac-topbar"),t.setAttribute("role","toolbar"),t.setAttribute("aria-label",ee(e,"Chart toolbar"));const i=(e,t="")=>oe(a,"button","oac-btn"+(t?" "+t:""),{type:"button","aria-label":e}),r=()=>oe(a,"span","oac-sep",{role:"separator"}),s=(e,t)=>{e.classList.toggle("is-off",t),e.setAttribute("aria-disabled",String(t))},l=oe(a,"div","oac-sym");l.appendChild(ne(a,T("search"),"chrome"));const c=oe(a,"input","oac-sym__input",{type:"text","aria-label":ee(e,"Symbol"),placeholder:ee(e,"Symbol"),autocomplete:"off",spellcheck:"false"});l.appendChild(c);const d=oe(a,"span","oac-sym__ex");l.appendChild(d),t.appendChild(l),t.appendChild(r());let p=null;const u=(e,t)=>{p?.close();const n=e.trim().toUpperCase();""!==n?(o.onSymbol(n,t),c.blur()):C()};o.search&&(p=Xe(e,c,{search:o.search,onSelect:u,context:()=>`${o.state().exchange}:${o.state().symbol}:${o.state().interval}`})),c.addEventListener("keydown",e=>{const t=e;"Enter"===t.key?(t.preventDefault(),u(c.value)):"Escape"===t.key&&(C(),c.blur())}),c.addEventListener("focus",()=>{c.select()}),c.addEventListener("blur",()=>{C()});const h=oe(a,"div","oac-pills",{role:"radiogroup","aria-label":ee(e,"Interval")}),b=new Map;for(const t of o.intervals){const n=oe(a,"button",void 0,{type:"button",role:"radio","aria-pressed":"false","aria-label":ee(e,"Interval {code}",{code:t})});n.textContent=nt(t),n.dataset.interval=t,n.addEventListener("click",()=>o.onInterval(t)),h.appendChild(n),b.set(t,n)}t.appendChild(h),t.appendChild(r());const g=i(ee(e,"Chart type"),"oac-topbar__type"),m=oe(a,"span");g.appendChild(m),g.appendChild((()=>{const e=oe(a,"span","oac-chev",{"aria-hidden":"true"});return e.innerHTML=T("chevron-down"),e})()),g.setAttribute("aria-haspopup","menu"),g.addEventListener("click",()=>{const t=o.state().chartType;at(e,g,ot().map(n=>({label:ee(e,`schema.chartType.${n}`,{},tt(n)),on:n===t,onSelect:()=>o.onChartType(n)})),{ariaLabel:ee(e,"Chart type")})}),t.appendChild(g);let f=null;if(!1!==o.indicators){f=i(ee(e,"Indicators")),f.appendChild(ne(a,T("plus"),"chrome"));const n=oe(a,"span");n.textContent=ee(e,"Indicators"),f.appendChild(n),f.addEventListener("click",()=>{null!==f&&f.classList.contains("is-off")||null!==f&&o.onIndicators(f)}),t.appendChild(f)}t.appendChild(oe(a,"span","oac-topbar__spacer"));const v=oe(a,"span","oac-topbar__branding-slot");let w=null;if(t.appendChild(v),o.onObjects){const n=i(ee(e,"Objects"),"oac-topbar__objects");n.textContent=ee(e,"Objects"),n.setAttribute("aria-haspopup","dialog"),n.addEventListener("click",()=>{o.onObjects?.(n)}),t.appendChild(n)}if(o.onDataWindow){const n=i(ee(e,"schema.ui.dataWindow",{},"Data"),"oac-topbar__data");n.textContent=ee(e,"schema.ui.dataWindow",{},"Data"),n.addEventListener("click",()=>{o.onDataWindow?.(n)}),t.appendChild(n)}if(o.onAlerts){const n=i(ee(e,"Alerts"),"oac-topbar__alerts");n.textContent=ee(e,"Alerts"),n.setAttribute("aria-haspopup","dialog"),n.addEventListener("click",()=>{o.onAlerts?.(n)}),t.appendChild(n)}const y=i(ee(e,"Capture chart"),"oac-btn--icon");y.appendChild(ne(a,T("camera"),"chrome")),y.setAttribute("aria-haspopup","menu"),e.tips.attach(y,{title:ee(e,"Capture"),sub:ee(e,"PNG, SVG, CSV or the clipboard"),side:"bottom"}),y.addEventListener("click",()=>{const t={...o.state()},i=()=>!e.chart.isDestroyed&&!1!==o.dataAvailable?.()&&e.chart.primaryBars().length>0,r=globalThis,s=void 0!==r.navigator?.clipboard?.write&&void 0!==r.ClipboardItem;at(e,y,[{label:ee(e,"Download PNG"),onSelect:()=>{e.chart.downloadScreenshot(st(t.symbol,t.interval)+".png"),e.status(ee(e,"Saved a PNG of the chart"))}},{label:ee(e,"Download SVG"),sub:ee(e,"text stays text"),onSelect:()=>{const o=rt(a,st(t.symbol,t.interval)+".svg",e.chart.exportSVG(),"image/svg+xml");e.status(ee(e,o?"Saved an SVG of the chart":"This runtime cannot save files"),o?"info":"error")}},{label:ee(e,"Copy image"),sub:ee(e,s?"paste it anywhere":"needs https or localhost"),disabled:!s,onSelect:()=>{e.chart.takeScreenshot().toBlob(t=>{if(null===t)return void e.status(ee(e,"The canvas produced no image"),"error");const o=globalThis.ClipboardItem;globalThis.navigator.clipboard.write([new o({"image/png":t})]).then(()=>e.status(ee(e,"Chart copied")),t=>e.status(ee(e,"Copy failed: {error}",{error:String(t?.message??t)}),"error"))},"image/png")}},{label:ee(e,"Download chart data (CSV)"),disabled:!i(),onSelect:()=>{try{const r=o.state();if(r.symbol!==t.symbol||r.exchange!==t.exchange||r.interval!==t.interval||r.chartType!==t.chartType)throw new Error(ee(e,"The chart changed; reopen Capture for its current source"));if(!i())throw new Error(ee(e,"Wait for this chart to finish loading its data"));const s=rt(a,st(t.symbol,t.interval)+".csv",n(e.chart),"text/csv;charset=utf-8");e.status(ee(e,s?"Chart data download started":"This runtime cannot save files"),s?"info":"error")}catch(t){e.status(ee(e,"Data export failed: {error}",{error:String(t?.message??t)}),"error")}}}],{ariaLabel:ee(e,"Capture")})}),t.appendChild(y);const x=i(ee(e,"Chart settings"),"oac-btn--icon");x.appendChild(ne(a,T("settings"),"chrome")),e.tips.attach(x,()=>({title:ee(e,"Chart settings"),sub:o.settingsAvailable()?void 0:ee(e,"The settings dialog is not in this build"),side:"bottom"})),x.addEventListener("click",()=>{x.classList.contains("is-off")||o.onSettings(x)}),t.appendChild(x);const _=i(ee(e,"Theme"),"oac-topbar__theme"),k=oe(a,"span");_.appendChild(k),e.tips.attach(_,()=>({title:"dark"===o.state().theme?ee(e,"Switch to the light theme"):ee(e,"Switch to the dark theme"),side:"bottom"})),_.addEventListener("click",()=>o.onTheme("dark"===o.state().theme?"light":"dark")),t.appendChild(_),null!==f&&e.tips.attach(f,()=>({title:ee(e,"Indicators"),sub:o.indicatorsAvailable()?ee(e,"Add a study to the chart"):ee(e,"The indicator picker is not in this build"),side:"bottom"}));const C=()=>{const t=o.state();a.activeElement!==c&&(c.value=t.symbol),d.textContent=t.exchange,d.hidden=""===t.exchange;for(const[e,o]of b){const n=e===t.interval;o.setAttribute("aria-pressed",String(n)),o.setAttribute("aria-checked",String(n))}m.textContent=ee(e,`schema.chartType.${t.chartType}`,{},tt(t.chartType)),s(x,!o.settingsAvailable()),null!==f&&s(f,!o.indicatorsAvailable()),_.dataset.theme=t.theme,k.textContent="dark"===t.theme?ee(e,"Light"):ee(e,"Dark"),e.tips.refreshLabel(_),e.tips.refreshLabel(x),null!==f&&e.tips.refreshLabel(f);const n=it(e.chart,e);null===n?(w?.remove(),w=null):(null===w&&(w=oe(a,"a","oac-topbar__branding",{target:"_blank",rel:"noopener noreferrer"}),v.appendChild(w)),w.setAttribute("href",n.href),w.textContent=n.label,w.setAttribute("aria-label",n.label))},$=e.chart.on("branding:changed",C);return C(),{el:t,refresh:C,focusSymbol:()=>{c.focus()},destroy:()=>{$(),p?.destroy(),t.textContent=""}}}const ct={info:4e3,success:3500,error:0},dt=5,pt=160;function ut(e,t=e.ownerDocument,o={}){e.classList.add("oac-toasts"),e.setAttribute("role","status"),e.setAttribute("aria-live","polite");const n=new Set;return{toast:(a,i="info",r={})=>{const s=i in ct?i:"info",l=t.createElement("div");l.className="oac-toast oac-toast--"+s;const c=t.createElement("span");c.className="oac-toast__msg",c.textContent=a;const d=t.createElement("button");d.type="button",d.className="oac-toast__x",d.setAttribute("aria-label",ee(o,"Dismiss")),d.innerHTML=T("close"),l.appendChild(c),l.appendChild(d);const p=void 0!==r.ms?r.ms:ct[s];let u=0,h=!1;const b={node:l,dismiss:()=>{h||(h=!0,0!==u&&clearTimeout(u),n.delete(b),l.classList.add("is-out"),setTimeout(()=>l.remove(),160))}},g=()=>{p>0&&(u=setTimeout(b.dismiss,p))};for(d.addEventListener("click",b.dismiss),l.addEventListener("pointerenter",()=>{0!==u&&clearTimeout(u),u=0}),l.addEventListener("pointerleave",g),e.appendChild(l),n.add(b);n.size>5;){const e=n.values().next().value;n.delete(e),e.node.remove()}return g(),b},clear:()=>{for(const e of Array.from(n))e.dismiss()},count:()=>n.size,destroy:()=>{for(const e of Array.from(n))e.node.remove();n.clear(),e.remove()}}}const ht="--oac-",bt=e=>e<0?0:e>1?1:e;function gt(e){const t=e.trim(),o=/^#([0-9a-f]{3,8})$/i.exec(t);if(null!==o){const e=o[1];if(3===e.length||4===e.length){return gt("#"+e.split("").map(e=>e+e).join(""))}if(6!==e.length&&8!==e.length)return null;return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16),a:8===e.length?parseInt(e.slice(6,8),16)/255:1}}const n=/^rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i.exec(t);if(null!==n){let e=1;return void 0!==n[4]&&(e=n[4].endsWith("%")?Number(n[4].slice(0,-1))/100:Number(n[4])),{r:Number(n[1]),g:Number(n[2]),b:Number(n[3]),a:bt(e)}}return null}const mt=e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0");function ft(e){return e.a>=1?`#${mt(e.r)}${mt(e.g)}${mt(e.b)}`:`rgba(${Math.round(e.r)},${Math.round(e.g)},${Math.round(e.b)},${Math.round(1e3*e.a)/1e3})`}function vt(e){const t=gt(e);if(null===t)return.5;const o=e=>{const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)};return.2126*o(t.r)+.7152*o(t.g)+.0722*o(t.b)}function wt(e){return vt(e.background)<.35?"dark":"light"}function yt(e,t,o){const n=gt(e),a=gt(t);if(null===n||null===a)return e;const i=bt(o);return ft({r:n.r+(a.r-n.r)*i,g:n.g+(a.g-n.g)*i,b:n.b+(a.b-n.b)*i,a:n.a+(a.a-n.a)*i})}function xt(e,t){const o=gt(e);return null===o?e:ft({...o,a:bt(t)})}const _t='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',kt="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Ct=42,$t=40,St=24;function At(e,t=wt(e)){const o="dark"===t,n=e.background,a=o?"#ffffff":"#0c1120",i=e=>yt(n,a,e),r=e.lineColor,s=yt(e.axisText,a,o?.55:.6),l={bg:n,panel:i(o?.035:.02),"panel-2":i(o?.02:.045),elev:i(o?.07:.06),"elev-2":i(o?.11:.1),"elev-3":i(o?.18:.16),bd:e.axisLine,"bd-soft":e.paneSeparator,"bd-hover":yt(e.axisLine,a,.25),tx:s,"tx-strong":yt(s,a,.5),mut:e.axisText,faint:yt(e.axisText,n,.4),acc:r,"acc-2":yt(r,a,o?.2:.1),"on-bg":xt(r,.16),"on-bd":yt(r,n,.45),ring:r,"ring-soft":xt(r,.2),buy:e.upColor,sell:e.downColor,amber:o?"#e6b53c":"#b8860b",danger:yt(e.downColor,a,o?.3:.1),scrim:o?"rgba(6,8,12,0.55)":"rgba(24,30,40,0.38)",shadow:o?"0 14px 40px rgba(0,0,0,0.55)":"0 14px 40px rgba(24,32,48,0.16)","sb-thumb":i(o?.16:.2),"sb-thumb-hover":i(o?.24:.3),font:_t,mono:kt,fs:"12.5px",radius:"7px","rail-w":"42px","topbar-h":"40px","status-h":"24px","ctl-h":"28px"},c={};for(const[e,t]of Object.entries(l))c[ht+e]=t;return c}function Lt(e,t){for(const[o,n]of Object.entries(t))e.style.setProperty(o,n)}const Et=e=>`var(${ht}${e})`,Ot="oac-widget-css",Tt=e=>`var(--oac-${e})`,Mt=`\n.oac-widget { position: relative; display: grid; grid-template-rows: auto 1fr auto; width: 100%; height: 100%;\n min-height: 0; min-width: 0; background: ${Tt("bg")}; color: ${Tt("tx")}; font: ${Tt("fs")}/1.35 ${Tt("font")};\n -webkit-font-smoothing: antialiased; overflow: hidden; }\n.oac-widget, .oac-widget * { box-sizing: border-box; }\n.oac-widget.oac-alert-host { position: absolute; inset: 0; display: block; background: transparent; pointer-events: none; z-index: 40; }\n.oac-widget[data-theme="dark"] { color-scheme: dark; }\n.oac-widget[data-theme="light"] { color-scheme: light; }\n.oac-widget button, .oac-widget input, .oac-widget select, .oac-widget textarea { font: inherit; color: inherit; }\n.oac-widget button { cursor: pointer; }\n.oac-widget kbd { font: 11px/1 ${Tt("mono")}; font-variant-numeric: tabular-nums; }\n.oac-widget [hidden] { display: none !important; }\n\n/* Scrollbars: a thumb one step lighter than its panel, and no visible track. */\n.oac-widget * { scrollbar-width: thin; scrollbar-color: ${Tt("sb-thumb")} transparent; }\n.oac-widget ::-webkit-scrollbar { width: 10px; height: 10px; }\n.oac-widget ::-webkit-scrollbar-track { background: transparent; }\n.oac-widget ::-webkit-scrollbar-thumb { background: ${Tt("sb-thumb")}; border: 2px solid transparent;\n background-clip: padding-box; border-radius: 999px; }\n.oac-widget ::-webkit-scrollbar-thumb:hover { background: ${Tt("sb-thumb-hover")}; background-clip: padding-box; }\n.oac-widget ::-webkit-scrollbar-corner { background: transparent; }\n\n/* Focus: one ring, keyboard only. Text fields glow on the border instead. */\n.oac-widget :focus-visible { outline: 2px solid ${Tt("ring")}; outline-offset: 2px; }\n.oac-widget :focus:not(:focus-visible) { outline: none; }\n.oac-widget input:not([type=checkbox]):not([type=color]):not([type=range]):focus-visible,\n.oac-widget select:focus-visible, .oac-widget textarea:focus-visible {\n outline: none; border-color: ${Tt("acc")}; box-shadow: 0 0 0 3px ${Tt("ring-soft")}; }\n.oac-widget .oac-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;\n overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }\n\n/* Form controls: nothing left to the browser on a themed panel. */\n.oac-widget input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; margin: 0;\n width: 15px; height: 15px; border: 1px solid ${Tt("bd")}; border-radius: 4px; background: ${Tt("elev")};\n cursor: pointer; display: inline-grid; place-content: center; transition: background .12s, border-color .12s; }\n.oac-widget input[type=checkbox]:hover { border-color: ${Tt("bd-hover")}; }\n.oac-widget input[type=checkbox]:checked { background: ${Tt("acc")}; border-color: ${Tt("acc")}; }\n.oac-widget input[type=checkbox]:checked::after { content: ''; width: 4px; height: 8px; margin-top: -2px;\n border: solid ${Tt("bg")}; border-width: 0 2px 2px 0; transform: rotate(45deg); }\n.oac-widget input[type=checkbox]:disabled { opacity: .4; cursor: not-allowed; }\n.oac-widget select { appearance: none; -webkit-appearance: none; height: ${Tt("ctl-h")}; padding: 0 24px 0 8px;\n background: ${Tt("elev")}; border: 1px solid ${Tt("bd")}; border-radius: ${Tt("radius")}; cursor: pointer; }\n.oac-widget .oac-select { position: relative; display: inline-flex; }\n/* The chevron overlays the select rather than sitting beside it. selectBox\n wraps the glyph in an oac-chev span, and this rule used to name\n .oac-select > svg, which that markup has never had: the span stayed an\n ordinary flex item, so it took eleven pixels of the row and left the select\n eleven pixels short of every input beside it, with its arrow outside its own\n box. Sized here rather than left to .oac-chev, whose inline-grid is right\n where a chevron follows a word, as it does in the top bar. */\n.oac-widget .oac-select > .oac-chev { position: absolute; right: 7px; top: 50%; width: 11px; height: 11px;\n transform: translateY(-50%); pointer-events: none; display: block; color: ${Tt("mut")}; }\n.oac-widget select option, .oac-widget select optgroup { background: ${Tt("panel")}; color: ${Tt("tx")}; }\n.oac-widget input[type=color] { width: 26px; height: 26px; padding: 0; flex: none; cursor: pointer; appearance: none;\n -webkit-appearance: none; background-color: ${Tt("elev")}; border: 1px solid ${Tt("bd")}; border-radius: ${Tt("radius")}; }\n.oac-widget input[type=color]:hover { border-color: ${Tt("bd-hover")}; }\n.oac-widget input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }\n.oac-widget input[type=color]::-webkit-color-swatch { border: 1px solid rgba(0,0,0,.35); border-radius: 4px; }\n.oac-widget input[type=color]::-moz-color-swatch { border: 1px solid rgba(0,0,0,.35); border-radius: 4px; }\n.oac-widget .oac-swatch { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(0,0,0,.35); }\n.oac-widget input[type=number] { -moz-appearance: textfield; appearance: textfield; }\n.oac-widget input[type=number]::-webkit-inner-spin-button, .oac-widget input[type=number]::-webkit-outer-spin-button {\n -webkit-appearance: none; margin: 0; }\n.oac-widget input[type=text], .oac-widget input[type=number], .oac-widget input[type=search], .oac-widget textarea {\n height: ${Tt("ctl-h")}; padding: 0 8px; background: ${Tt("elev")}; border: 1px solid ${Tt("bd")}; border-radius: ${Tt("radius")};\n transition: border-color .15s, box-shadow .15s; }\n.oac-widget textarea { height: auto; padding: 6px 8px; }\n.oac-widget input::placeholder { color: ${Tt("faint")}; }\n.oac-widget input:hover, .oac-widget select:hover { border-color: ${Tt("bd-hover")}; }\n.oac-widget input[type=range] { appearance: none; -webkit-appearance: none; height: 22px; margin: 0;\n background: transparent; cursor: pointer; }\n.oac-widget input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: ${Tt("elev-3")}; }\n.oac-widget input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px;\n margin-top: -4.5px; border-radius: 50%; background: ${Tt("acc")}; border: 0; }\n.oac-widget input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: ${Tt("elev-3")}; }\n.oac-widget input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: ${Tt("acc")}; border: 0; }\n\n/* Section heads and rows shared by every panel. */\n.oac-widget .oac-head { padding: 8px 10px 4px; color: ${Tt("faint")}; font-size: 10px; font-weight: 600;\n text-transform: uppercase; letter-spacing: .7px; }\n.oac-widget .oac-row { display: flex; align-items: center; gap: 8px; min-height: 26px; padding: 2px 0; }\n.oac-widget .oac-row > label { flex: 1 1 auto; min-width: 0; color: ${Tt("tx")}; }\n\n/* Help mark: a 13px ring after a label, muted until pointed at. It must not\n grow the row, so it sits on the label's own line box and never wraps away\n from the words it belongs to. */\n.oac-widget .oac-help { display: inline-flex; align-items: center; justify-content: center;\n width: 13px; height: 13px; margin-left: 5px; vertical-align: -2px; flex: none;\n border: 1px solid ${Tt("bd")}; border-radius: 50%; color: ${Tt("faint")};\n font-size: 9px; font-weight: 600; line-height: 1; cursor: help; user-select: none; }\n.oac-widget .oac-help:hover, .oac-widget .oac-help:focus-visible {\n color: ${Tt("tx")}; border-color: ${Tt("bd-hover")}; outline: none; }\n\n/* Buttons: flat, 28px tall, a tint when pressed or armed. */\n.oac-widget .oac-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;\n height: ${Tt("ctl-h")}; padding: 0 9px; background: transparent; border: 1px solid transparent;\n border-radius: ${Tt("radius")}; color: ${Tt("tx")}; white-space: nowrap; transition: background .1s, border-color .1s, color .1s; }\n.oac-widget .oac-btn:hover { background: ${Tt("elev")}; border-color: ${Tt("bd-soft")}; }\n.oac-widget .oac-btn.is-on, .oac-widget .oac-btn[aria-pressed="true"], .oac-widget .oac-btn[aria-expanded="true"] {\n background: ${Tt("on-bg")}; border-color: ${Tt("on-bd")}; color: ${Tt("acc-2")}; }\n.oac-widget .oac-btn.is-off, .oac-widget .oac-btn[aria-disabled="true"], .oac-widget .oac-btn:disabled {\n color: ${Tt("faint")}; cursor: default; }\n.oac-widget .oac-btn.is-off:hover, .oac-widget .oac-btn[aria-disabled="true"]:hover, .oac-widget .oac-btn:disabled:hover {\n background: transparent; border-color: transparent; }\n.oac-widget .oac-btn--icon { width: ${Tt("ctl-h")}; padding: 0; }\n.oac-widget .oac-btn--primary { background: ${Tt("acc")}; color: ${Tt("bg")}; border-color: transparent; font-weight: 600; }\n.oac-widget .oac-btn--primary:hover { background: ${Tt("acc-2")}; border-color: transparent; }\n.oac-widget .oac-btn--danger:not(.is-off):hover { color: ${Tt("danger")}; }\n.oac-widget .oac-btn > b { font-weight: 700; letter-spacing: .3px; }\n.oac-widget .oac-glyph { display: inline-grid; place-items: center; line-height: 0; flex: none; }\n.oac-widget .oac-glyph > svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-glyph--tool > svg { width: 24px; height: 24px; stroke-width: 2; }\n.oac-widget .oac-glyph--chrome > svg { width: 16px; height: 16px; stroke-width: 1.5; }\n.oac-widget .oac-glyph--text { display: inline-grid; place-items: center; width: 24px; height: 24px;\n font-size: 12px; font-weight: 600; }\n.oac-widget .oac-chev { display: inline-grid; place-items: center; line-height: 0; color: ${Tt("mut")}; }\n.oac-widget .oac-chev > svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.5;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-sep { width: 1px; height: 20px; background: ${Tt("bd-soft")}; margin: 0 2px; flex: none; }\n\n/* Top bar */\n.oac-widget .oac-topbar { grid-row: 1; display: flex; align-items: center; gap: 4px; min-height: ${Tt("topbar-h")};\n padding: 5px 8px; background: ${Tt("panel")}; border-bottom: 1px solid ${Tt("bd-soft")}; flex-wrap: wrap; }\n.oac-widget .oac-topbar__spacer { flex: 1 1 auto; }\n.oac-widget .oac-topbar__branding-slot { display: inline-flex; align-items: center; }\n.oac-widget .oac-topbar__branding { color: ${Tt("mut")}; font-size: 11px; text-decoration: none; white-space: nowrap; }\n.oac-widget .oac-topbar__branding:hover { color: ${Tt("tx")}; text-decoration: underline; }\n.oac-widget .oac-sym { position: relative; display: inline-flex; align-items: center; }\n.oac-widget .oac-sym > input { width: 132px; height: ${Tt("ctl-h")}; padding: 0 8px 0 28px; font-weight: 600;\n letter-spacing: .3px; text-transform: uppercase; }\n.oac-widget .oac-sym > .oac-glyph { position: absolute; left: 8px; color: ${Tt("mut")}; pointer-events: none; }\n.oac-widget .oac-sym__ex { margin-left: 6px; color: ${Tt("faint")}; font-size: 11px; font-weight: 600; letter-spacing: .5px; }\n.oac-widget .oac-pills { display: inline-flex; background: ${Tt("elev")}; border: 1px solid ${Tt("bd-soft")};\n border-radius: 7px; padding: 2px; }\n.oac-widget .oac-pills > button { height: 22px; padding: 0 8px; background: transparent; border: 0; border-radius: 5px;\n color: ${Tt("mut")}; font-weight: 600; font-size: 11.5px; letter-spacing: .2px; }\n.oac-widget .oac-pills > button:hover { color: ${Tt("tx")}; }\n.oac-widget .oac-pills > button[aria-pressed="true"] { background: ${Tt("elev-2")}; color: ${Tt("acc-2")}; }\n.oac-widget .oac-pills > button:focus-visible { outline-offset: -1px; }\n\n/* Popup menu (chart types, screenshot, symbol results) */\n.oac-widget .oac-menu { min-width: 190px; max-width: 320px; max-height: 60vh; overflow-y: auto; padding: 5px;\n background: ${Tt("panel")}; border: 1px solid ${Tt("bd")}; border-radius: 9px; box-shadow: ${Tt("shadow")}; outline: none; }\n.oac-widget .oac-menu__find { padding: 3px 3px 6px; }\n.oac-widget .oac-menu__find > input { width: 100%; }\n.oac-widget .oac-menu__row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 8px;\n background: transparent; border: 0; border-radius: 6px; color: ${Tt("tx")}; text-align: left; white-space: nowrap; }\n.oac-widget .oac-menu__row:hover, .oac-widget .oac-menu__row:focus-visible, .oac-widget .oac-menu__row.is-active {\n background: ${Tt("elev-2")}; outline: none; }\n.oac-widget .oac-menu__row[aria-checked="true"] { color: ${Tt("acc-2")}; }\n.oac-widget .oac-menu__row[aria-checked="true"]::before { content: ''; width: 6px; height: 6px; border-radius: 50%;\n background: ${Tt("acc-2")}; margin: 0 2px 0 -2px; flex: none; }\n.oac-widget .oac-menu__row[aria-checked="false"]::before { content: ''; width: 6px; height: 6px; margin: 0 2px 0 -2px; flex: none; }\n.oac-widget .oac-menu__row[aria-disabled="true"] { color: ${Tt("faint")}; cursor: default; background: transparent; }\n.oac-widget .oac-menu__row.is-danger:hover { color: ${Tt("danger")}; }\n.oac-widget .oac-menu__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-menu__sub { color: ${Tt("faint")}; font-size: 11px; }\n.oac-widget .oac-menu__key { margin-left: auto; color: ${Tt("faint")}; }\n.oac-widget .oac-menu__empty { padding: 8px 10px; color: ${Tt("faint")}; }\n\n/* Stage: the rail on the left, the chart filling the rest. */\n.oac-widget .oac-stage { grid-row: 2; position: relative; min-height: 0; min-width: 0; display: flex; }\n.oac-widget .oac-chart { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0;\n cursor: var(--oac-tool-cursor, crosshair); }\n.oac-widget .oac-chart:focus-visible { outline-offset: -2px; }\n\n/* Data state stays compact inside a chart, including narrow embedded widgets. */\n.oac-widget .oac-data-status { position: absolute; top: 8px; right: 8px; z-index: 30;\n max-width: calc(100% - 16px); width: max-content; max-height: 45%; overflow-y: auto;\n display: flex; flex-direction: column; gap: 4px; pointer-events: none; font-size: 12px; }\n.oac-widget .oac-data-status__row { display: flex; align-items: center; gap: 8px;\n max-width: 320px; padding: 4px 6px 4px 10px; background: ${Tt("panel")}; color: ${Tt("tx")};\n border: 1px solid ${Tt("bd")}; border-radius: 6px; pointer-events: auto; }\n.oac-widget .oac-data-status__text { min-width: 0; overflow-wrap: anywhere; }\n.oac-widget .oac-data-status__row > button { flex: none; color: ${Tt("acc-2")}; }\n\n/* Rail */\n.oac-widget .oac-rail { flex: none; width: ${Tt("rail-w")}; display: flex; flex-direction: column; align-items: center;\n gap: 2px; padding: 6px 0 0; background: ${Tt("panel-2")}; border-right: 1px solid ${Tt("bd-soft")};\n overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }\n.oac-widget .oac-rail::-webkit-scrollbar { width: 0; height: 0; }\n.oac-widget .oac-rail__btn { position: relative; width: 32px; height: 32px; padding: 0; display: grid; place-items: center;\n flex: none; background: transparent; border: 1px solid transparent; border-radius: 7px; color: ${Tt("mut")};\n transition: background .1s, color .1s, border-color .1s; }\n.oac-widget .oac-rail__btn:hover { background: ${Tt("elev")}; color: ${Tt("tx")}; }\n.oac-widget .oac-rail__btn:focus-visible { outline: 2px solid ${Tt("acc-2")}; outline-offset: -2px; }\n.oac-widget .oac-rail__btn.is-on { background: ${Tt("on-bg")}; border-color: ${Tt("on-bd")}; color: ${Tt("acc-2")}; }\n.oac-widget .oac-rail__btn.is-weak { color: ${Tt("acc-2")}; }\n.oac-widget .oac-rail__btn.is-off { color: ${Tt("faint")}; cursor: default; }\n.oac-widget .oac-rail__btn.is-off:hover { background: transparent; color: ${Tt("faint")}; }\n.oac-widget .oac-rail__btn--danger:not(.is-off):hover { color: ${Tt("danger")}; }\n.oac-widget .oac-rail__chev { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; display: grid;\n place-items: center; border-radius: 5px 0 6px 0; color: ${Tt("mut")}; opacity: 0; transition: opacity .1s, background .1s; }\n.oac-widget .oac-rail__chev > svg { width: 9px; height: 9px; fill: none; stroke: currentColor; stroke-width: 2.2;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-rail__btn:hover .oac-rail__chev, .oac-widget .oac-rail__btn:focus-visible .oac-rail__chev,\n.oac-widget .oac-rail__btn[aria-expanded="true"] .oac-rail__chev { opacity: 1; }\n.oac-widget .oac-rail__chev:hover { background: ${Tt("elev-2")}; color: ${Tt("tx")}; }\n.oac-widget .oac-rail__btn.is-held::after, .oac-widget .oac-rail__btn[data-mode="weak"]::after,\n.oac-widget .oac-rail__btn[data-mode="strong"]::after { content: ''; position: absolute; top: 3px; right: 3px;\n width: 5px; height: 5px; border-radius: 50%; }\n.oac-widget .oac-rail__btn.is-held::after, .oac-widget .oac-rail__btn[data-mode="strong"]::after { background: ${Tt("acc-2")}; }\n.oac-widget .oac-rail__btn[data-mode="weak"]::after { border: 1.5px solid ${Tt("acc-2")}; width: 4px; height: 4px; }\n.oac-widget .oac-rail__sep { width: 22px; height: 1px; background: ${Tt("bd-soft")}; margin: 4px 0; flex: none; }\n.oac-widget .oac-rail__favs { display: contents; }\n.oac-widget .oac-rail__ctl { margin-top: auto; position: sticky; bottom: 0; display: flex; flex-direction: column;\n align-items: center; gap: 2px; width: 100%; padding: 4px 0 6px; background: ${Tt("panel-2")};\n border-top: 1px solid ${Tt("bd-soft")}; flex: none; }\n.oac-widget .oac-rail__ctl .oac-rail__sep { margin: 3px 0; }\n\n/* Rail flyout: a group's tools, with a pin star and the chord on each row. */\n.oac-widget .oac-fly { min-width: 244px; max-width: 320px; max-height: calc(100% - 16px); overflow-y: auto; padding: 6px;\n background: ${Tt("panel")}; border: 1px solid ${Tt("bd")}; border-radius: 10px; box-shadow: ${Tt("shadow")}; outline: none; }\n.oac-widget .oac-fly__row { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 8px; border-radius: 7px;\n color: ${Tt("tx")}; font-size: 13px; cursor: pointer; outline: none; user-select: none; }\n.oac-widget .oac-fly__row:hover, .oac-widget .oac-fly__row:focus-visible { background: ${Tt("elev-2")}; }\n.oac-widget .oac-fly__row[aria-checked="true"] { background: ${Tt("on-bg")}; color: ${Tt("acc-2")}; }\n.oac-widget .oac-fly__name { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-fly__chord { min-width: 40px; text-align: right; color: ${Tt("faint")}; }\n.oac-widget .oac-fly__star { width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0;\n border-radius: 5px; background: transparent; color: ${Tt("faint")}; opacity: 0; transition: opacity .1s, color .1s; }\n.oac-widget .oac-fly__row:hover .oac-fly__star, .oac-widget .oac-fly__row:focus-within .oac-fly__star,\n.oac-widget .oac-fly__star[aria-pressed="true"] { opacity: 1; }\n.oac-widget .oac-fly__star:hover { background: ${Tt("elev")}; color: ${Tt("tx")}; }\n.oac-widget .oac-fly__star:focus-visible { outline: 2px solid ${Tt("acc-2")}; outline-offset: -1px; opacity: 1; }\n.oac-widget .oac-fly__star[aria-pressed="true"] { color: ${Tt("amber")}; }\n.oac-widget .oac-fly__star > svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.5;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-fly__star[aria-pressed="false"] > svg { fill: none; }\n\n/* Tooltip */\n.oac-widget .oac-tip { position: absolute; z-index: 200; left: 0; top: 0; max-width: 260px; pointer-events: none;\n padding: 5px 9px; border-radius: 6px; background: ${Tt("elev-2")}; color: ${Tt("tx")}; border: 1px solid ${Tt("bd")};\n box-shadow: ${Tt("shadow")}; font-size: 12px; line-height: 1.4; opacity: 0; transition: opacity .09s ease; }\n.oac-widget .oac-tip.is-on { opacity: 1; }\n.oac-widget .oac-tip__chord { margin-left: 10px; color: ${Tt("mut")}; }\n.oac-widget .oac-tip__sub { display: block; margin-top: 2px; color: ${Tt("faint")}; font-size: 11px; }\n\n/* Status line */\n.oac-widget .oac-statusline { grid-row: 3; display: flex; align-items: center; gap: 12px; height: ${Tt("status-h")}; padding: 0 10px;\n background: ${Tt("panel")}; border-top: 1px solid ${Tt("bd-soft")}; color: ${Tt("mut")}; font-size: 11.5px;\n font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }\n.oac-widget .oac-statusline__sym { color: ${Tt("tx-strong")}; font-weight: 600; letter-spacing: .3px; }\n.oac-widget .oac-statusline__iv { color: ${Tt("faint")}; margin-left: 4px; font-weight: 600; }\n.oac-widget .oac-statusline__field { display: inline-flex; align-items: center; gap: 4px; }\n.oac-widget .oac-statusline__field > i { font-style: normal; color: ${Tt("faint")}; }\n.oac-widget .oac-statusline__field > b { font-weight: 500; color: ${Tt("tx")}; }\n.oac-widget .oac-statusline .is-up > b { color: ${Tt("buy")}; }\n.oac-widget .oac-statusline .is-down > b { color: ${Tt("sell")}; }\n.oac-widget .oac-statusline__msg { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: ${Tt("mut")}; }\n.oac-widget .oac-statusline__msg.is-error { color: ${Tt("danger")}; }\n.oac-widget .oac-statusline__tz { color: ${Tt("faint")}; }\n\n/* Narrow widget chrome */\n.oac-widget .oac-mobile { display: none; }\n.oac-widget.is-mobile { grid-template-rows: auto minmax(0, 1fr) auto; }\n.oac-widget.is-mobile > .oac-topbar, .oac-widget.is-mobile > .oac-statusline,\n.oac-widget.is-mobile > .oac-stage > .oac-rail { display: none; }\n.oac-widget.is-mobile > .oac-stage { grid-row: 2; }\n.oac-widget.is-mobile > .oac-mobile { display: contents; }\n.oac-widget .oac-mobile__header { grid-row: 1; z-index: 40; display: grid; grid-template-columns: minmax(0, 1fr) auto;\n gap: 8px; min-height: 52px; padding: calc(4px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 4px\n max(8px, env(safe-area-inset-left)); background: ${Tt("panel")}; border-bottom: 1px solid ${Tt("bd-soft")}; }\n.oac-widget .oac-mobile__symbol { width: 100%; min-width: 0; height: 44px; text-transform: uppercase; font-weight: 600; }\n.oac-widget .oac-mobile__footer { grid-row: 3; z-index: 40; min-width: 0; padding-bottom: env(safe-area-inset-bottom);\n background: ${Tt("panel")}; border-top: 1px solid ${Tt("bd-soft")}; }\n.oac-widget .oac-mobile__bar, .oac-widget .oac-mobile__selection { display: grid; grid-auto-flow: column;\n grid-auto-columns: minmax(0, 1fr); min-width: 0; }\n.oac-widget .oac-mobile__selection { border-bottom: 1px solid ${Tt("bd-soft")}; }\n.oac-widget .oac-mobile__action { min-width: 0; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 0;\n background: transparent; color: ${Tt("tx")}; overflow-wrap: anywhere; touch-action: manipulation; }\n.oac-widget .oac-mobile__action:hover, .oac-widget .oac-mobile__action:focus-visible { background: ${Tt("elev")}; }\n.oac-widget .oac-mobile__action[aria-pressed="true"] { color: ${Tt("acc-2")}; background: ${Tt("on-bg")}; }\n.oac-widget .oac-mobile__action[aria-disabled="true"] { color: ${Tt("faint")}; cursor: default; background: transparent; }\n.oac-widget .oac-mobile__branding { display: flex; align-items: center; width: 100%; min-height: 44px; text-decoration: none; }\n.oac-widget .oac-mobile-sheet.oac-dialog { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%;\n max-width: 100%; max-height: calc(100% - env(safe-area-inset-top) - 12px); border-radius: 14px 14px 0 0;\n padding-bottom: env(safe-area-inset-bottom); }\n.oac-widget .oac-mobile-sheet__head { flex: none; display: flex; align-items: center; gap: 8px;\n min-height: 52px; padding: 4px 8px 4px 14px; border-bottom: 1px solid ${Tt("bd-soft")}; }\n.oac-widget .oac-mobile-sheet__title { flex: 1 1 auto; color: ${Tt("tx-strong")}; font-size: 14px; }\n.oac-widget .oac-mobile-sheet__body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;\n display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; padding: 8px; }\n.oac-widget .oac-mobile-sheet__body > .oac-head { grid-column: 1 / -1; }\n.oac-widget .oac-mobile-sheet__controls { grid-column: 1 / -1; display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid ${Tt("bd-soft")}; margin-bottom: 6px; }\n.oac-widget .oac-mobile-sheet__body small { display: block; color: ${Tt("faint")}; }\n.oac-widget .oac-mobile-results { width: min(360px, calc(100% - 16px)); max-height: min(50%, 360px); overflow: hidden;\n display: flex; flex-direction: column; background: ${Tt("panel")}; border: 1px solid ${Tt("bd")}; border-radius: 10px; box-shadow: ${Tt("shadow")}; }\n.oac-widget .oac-mobile-results__head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 44px;\n padding-left: 12px; border-bottom: 1px solid ${Tt("bd-soft")}; }\n.oac-widget .oac-mobile-results__head > strong { flex: 1 1 auto; color: ${Tt("tx-strong")}; }\n.oac-widget .oac-mobile-results__list { flex: 1 1 auto; min-height: 0; max-height: min(42vh, 300px);\n overflow-y: auto; overscroll-behavior: contain; }\n.oac-widget .oac-mobile-results__list > .oac-mobile__action { display: block; width: 100%; text-align: left; }\n.oac-widget .oac-mobile-results__list small { display: block; color: ${Tt("faint")}; }\n.oac-widget .oac-mobile-results__status { min-height: 44px; padding: 13px 12px; color: ${Tt("mut")}; }\n.oac-widget.is-mobile .oac-toasts { bottom: calc(54px + env(safe-area-inset-bottom)); }\n\n/* Toasts */\n.oac-widget .oac-toasts { position: absolute; right: 12px; bottom: calc(${Tt("status-h")} + 10px); z-index: 90; display: flex;\n flex-direction: column; gap: 8px; width: min(340px, calc(100% - 24px)); pointer-events: none; }\n.oac-widget .oac-toast { display: flex; align-items: flex-start; gap: 8px; padding: 8px 6px 8px 12px; border-radius: 8px;\n background: ${Tt("panel")}; color: ${Tt("tx")}; border: 1px solid ${Tt("bd")}; border-left: 3px solid ${Tt("acc")};\n box-shadow: ${Tt("shadow")}; font-size: 12.5px; line-height: 1.45; pointer-events: auto; animation: oac-toast-in .16s ease-out; }\n.oac-widget .oac-toast--success { border-left-color: ${Tt("buy")}; }\n.oac-widget .oac-toast--error { border-left-color: ${Tt("sell")}; }\n.oac-widget .oac-toast__msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; padding-top: 2px; }\n.oac-widget .oac-toast__x { flex: none; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent;\n color: ${Tt("faint")}; padding: 0; display: grid; place-items: center; }\n.oac-widget .oac-toast__x:hover { background: ${Tt("elev-2")}; color: ${Tt("tx")}; }\n.oac-widget .oac-toast__x > svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; }\n.oac-widget .oac-toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity .16s, transform .16s; }\n@keyframes oac-toast-in { from { opacity: 0; transform: translateY(6px); } }\n\n/* Overlay layer: popovers anchored to a control, dialogs centred over a scrim. */\n.oac-widget .oac-layer { container: oac-widget / inline-size; position: absolute; inset: 0; z-index: 60; pointer-events: none; }\n.oac-widget .oac-layer > * { pointer-events: auto; }\n.oac-widget .oac-scrim { position: absolute; inset: 0; background: ${Tt("scrim")}; }\n.oac-widget .oac-pop { position: absolute; left: 0; top: 0; }\n.oac-widget .oac-dialog { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);\n min-width: 0; max-width: calc(100% - 24px); max-height: calc(100% - 24px); display: flex; flex-direction: column;\n background: ${Tt("panel")}; border: 1px solid ${Tt("bd")}; border-radius: 12px; box-shadow: ${Tt("shadow")}; outline: none; }\n.oac-widget .oac-dialog__head { flex: none; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }\n.oac-widget .oac-dialog__title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 700; color: ${Tt("tx-strong")}; }\n.oac-widget .oac-dialog__body { flex: 1 1 auto; min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; padding: 4px 14px 10px; }\n.oac-widget .oac-dialog__foot { flex: none; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px 12px;\n border-top: 1px solid ${Tt("bd-soft")}; }\n.oac-widget .oac-dialog__foot > .oac-spacer { flex: 1 1 auto; }\n\n/* Shortcuts panel */\n.oac-widget .oac-keys { columns: 2; column-gap: 24px; min-width: 520px; }\n.oac-widget .oac-keys__group { break-inside: avoid; margin-bottom: 8px; }\n.oac-widget .oac-keys__row { display: flex; align-items: center; gap: 10px; padding: 3px 0; }\n.oac-widget .oac-keys__row > span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-keys__row > kbd { flex: none; padding: 2px 6px; border-radius: 4px; background: ${Tt("elev")};\n border: 1px solid ${Tt("bd-soft")}; color: ${Tt("mut")}; }\n.oac-widget .oac-keys__row.is-shadowed > span, .oac-widget .oac-keys__row.is-shadowed > kbd { color: ${Tt("faint")}; text-decoration: line-through; }\n.oac-widget .oac-keys__note { color: ${Tt("faint")}; font-size: 11px; padding: 4px 0 0; }\n\n@container oac-widget (max-width: 720px) {\n .oac-widget .oac-keys { columns: 1; min-width: 0; }\n}\n@media (max-width: 720px) {\n .oac-widget .oac-sym > input { width: 104px; }\n}\n@media (prefers-reduced-motion: reduce) {\n .oac-widget .oac-rail__btn, .oac-widget .oac-rail__chev, .oac-widget .oac-tip, .oac-widget .oac-fly__star,\n .oac-widget .oac-btn, .oac-widget .oac-toast.is-out { transition: none; }\n .oac-widget .oac-toast { animation: none; }\n .oac-widget .oac-mobile__action { transition: none; }\n}\n`;function jt(e,t="",o){const n=e.getElementById(Ot);if(n?.textContent?.trim())return n;const a=n??e.createElement("style");return a.id=Ot,a.nonce||void 0===o||(a.nonce=o),a.textContent=Mt+t,null===n&&(e.head??e.body??e.documentElement).appendChild(a),a}const It=["#4f8cff","#26a69a","#ef5350","#f4b740","#ab79df","#22a8bd","#e88555","#9aa6b2","#ffffff","#000000"],Pt=[];function Dt(e){if("string"!=typeof e||e.length>256)return null;const t=e.trim(),o=/^#([\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i.exec(t);if(null!==o){let e=o[1].toLowerCase();e.length<=4&&(e=e.split("").map(e=>e+e).join(""));const t=8===e.length?parseInt(e.slice(6),16)/255:1;return{hex:`#${e.slice(0,6)}`,alpha:t,format:8===e.length?"hexAlpha":"hex"}}const n=t.toLowerCase(),a=n.startsWith("rgba(")?5:n.startsWith("rgb(")?4:0;if(0===a||!t.endsWith(")"))return null;const i=t.slice(a,-1);let r,s;if(i.includes(",")){const e=i.split(",").map(e=>e.trim());if(3!==e.length&&4!==e.length)return null;r=e.slice(0,3),s=e[3]}else{const e=i.split("/");if(e.length>2)return null;r=e[0].trim().split(/\s+/),s=e[1]?.trim()}if(3!==r.length||r.some(e=>!/^\d{1,3}$/.test(e)))return null;const l=r.map(Number);if(l.some(e=>e>255))return null;if(void 0!==s){const e=s.split(".");if(e.length>2||e.every(e=>""===e)||e.some(e=>/\D/.test(e)))return null}const c=void 0===s?1:Number(s);return!Number.isFinite(c)||c<0||c>1?null:{hex:`#${l.map(e=>e.toString(16).padStart(2,"0")).join("")}`,alpha:c,format:void 0===s?"hex":"rgba"}}function Nt(e,t,o){if("hex"===o)return e;if("hexAlpha"===o)return`${e}${Math.round(255*t).toString(16).padStart(2,"0")}`;return`rgba(${[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)).join(",")},${Number(t.toFixed(3))})`}function zt(e,t){const o=(t,o)=>{const n=e.createElement(t);return n.className=o,n},n=e=>ee(t,`schema.ui.colorPicker.${e}`,{},e),a=o("span","oac-color"),i=o("input","oac-swatch-input");i.type="color",i.id=t.id,i.tabIndex=-1,i.setAttribute("aria-hidden","true"),i.setAttribute("aria-label",t.label);const r=o("button","oac-color__trigger");r.type="button",r.id=`${t.id}-trigger`,r.setAttribute("aria-label",t.label),r.setAttribute("aria-haspopup","dialog"),r.setAttribute("aria-expanded","false"),null!==t.disabledReason&&void 0!==t.disabledReason?(r.disabled=!0,i.disabled=!0,r.title=t.disabledReason,i.title=t.disabledReason):(r.title=t.label,i.title=t.label),a.appendChild(i),a.appendChild(r);const s=o("div","oac-color__popover");s.hidden=!0,s.setAttribute("role","dialog"),s.setAttribute("aria-label",n("Color"));const l=o("div","oac-color__palette");l.setAttribute("aria-label",n("Palette"));const c=o("div","oac-color__recent");c.setAttribute("aria-label",n("Recent"));const d=o("button","oac-color__custom");d.type="button",d.textContent=n("Custom"),d.addEventListener("click",()=>{v||i.click()}),s.appendChild(l),s.appendChild(c),s.appendChild(d),a.appendChild(s);let p,u,h,b=t.value,g=Dt(b),m=g?.alpha??1,f=!1,v=!1;const w=()=>{i.value=g?.hex??"#000000",r.style.backgroundColor=null===g?"#000000":Nt(g.hex,m,g.format),void 0!==u&&(u.value=String(Math.round(100*m)),void 0!==h&&(h.textContent=`${u.value}%`))},y=(e,o=m)=>{if(v||r.disabled||!/^#[\da-f]{6}$/i.test(e))return;const n=g?.format??"hex";b=Nt(e.toLowerCase(),o,n),g={hex:e.toLowerCase(),alpha:o,format:n},m=o,w(),function(e){const t=Pt.indexOf(e);t>=0&&Pt.splice(t,1),Pt.unshift(e),Pt.length=Math.min(Pt.length,6)}(g.hex),t.onChange(b)},x=(e,t)=>{e.innerHTML="";for(const n of t){const t=o("button","oac-color__choice");t.type="button",t.setAttribute("aria-label",n),t.title=n,t.style.backgroundColor=n,t.addEventListener("click",()=>{y(n),C(),r.focus()}),e.appendChild(t)}},_=e=>{a.contains(e.target)||s.contains(e.target)||C()},k=()=>{f&&(p=void 0,f=!1,s.hidden=!0,r.setAttribute("aria-expanded","false"),e.removeEventListener("pointerdown",_,!0),g=Dt(b),m=g?.alpha??1,w(),v||s.parentNode===a||a.appendChild(s))},C=()=>{const e=p;p=void 0,e?.(),k()},$=()=>{if(!(v||f||r.disabled))if(f=!0,function(){if(void 0!==u||null===g||"hex"===g.format)return;const a=o("label","oac-color__opacity");a.appendChild(e.createTextNode(n("Opacity"))),u=o("input","oac-color__range"),u.type="range",u.min="0",u.max="100",u.step="1",h=o("output","oac-color__percent");const r=u,l=h;r.addEventListener("input",()=>{m=Number(r.value)/100,l.textContent=`${r.value}%`,t.live&&y(i.value,m)}),r.addEventListener("change",()=>y(i.value,Number(r.value)/100)),a.appendChild(r),a.appendChild(l),s.appendChild(a)}(),w(),x(l,It),x(c,Pt),c.hidden=0===Pt.length,s.hidden=!1,r.setAttribute("aria-expanded","true"),t.openOverlay){s.classList.remove("oac-color__popover--above"),r.focus();const e=t.openOverlay(s,{anchor:r,placement:"below",modal:!1,initialFocus:l.querySelector("button"),onClose:k});f?p=e:e()}else{const t=a.closest(".oac-widget");if(null!==t){const e=t.getBoundingClientRect().bottom;s.classList.toggle("oac-color__popover--above",r.getBoundingClientRect().bottom+s.offsetHeight>e)}e.addEventListener("pointerdown",_,!0),l.querySelector("button")?.focus()}};r.addEventListener("click",()=>f?C():$());const S=e=>{"Escape"===e.key&&f&&(e.preventDefault(),e.stopPropagation(),C(),r.focus())};return a.addEventListener("keydown",S),s.addEventListener("keydown",S),s.addEventListener("pointerdown",e=>e.stopPropagation()),i.addEventListener("input",()=>{t.live&&y(i.value)}),i.addEventListener("change",()=>y(i.value)),w(),{el:a,input:i,trigger:r,read:()=>b,write:e=>{b=e,g=Dt(e),m=g?.alpha??1,w()},destroy:()=>{v||(v=!0,C(),s.remove(),a.removeEventListener("keydown",S),s.removeEventListener("keydown",S))}}}const Rt="\n.oac-widget .oac-color { position: relative; display: inline-flex; width: 27px; height: 27px; flex: 0 0 27px; }\n.oac-widget .oac-color > .oac-swatch-input { position: absolute; inset: 0; width: 27px; height: 27px; padding: 0; opacity: 0; pointer-events: none; }\n.oac-widget .oac-color__trigger { position: absolute; inset: 0; width: 27px; height: 27px; border: 1px solid var(--oac-bd); border-radius: 5px; background: transparent; cursor: pointer; }\n.oac-widget .oac-color__trigger:focus-visible { outline: 2px solid var(--oac-ring); outline-offset: 2px; }\n.oac-widget .oac-color__trigger:disabled { cursor: not-allowed; opacity: .5; }\n.oac-widget .oac-color__popover { position: absolute; z-index: 80; top: 30px; right: 0; width: 188px; padding: 9px; border: 1px solid var(--oac-bd); border-radius: 7px; background: var(--oac-elev); color: var(--oac-tx); box-shadow: var(--oac-shadow); }\n.oac-widget .oac-color__popover--above { top: auto; bottom: 30px; }\n.oac-widget .oac-color__popover.oac-pop { right: auto; bottom: auto; min-width: 0; max-width: calc(100% - 16px); max-height: calc(100% - 16px); overflow: auto; }\n.oac-widget .oac-color__popover[hidden], .oac-widget .oac-color__recent[hidden] { display: none; }\n.oac-widget .oac-color__palette, .oac-widget .oac-color__recent { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 7px; }\n.oac-widget .oac-color__choice { width: 28px; height: 28px; padding: 0; border: 1px solid var(--oac-bd); border-radius: 5px; background: transparent; overflow: hidden; cursor: pointer; }\n.oac-widget .oac-color__custom { width: 100%; padding: 5px; border: 1px solid var(--oac-bd); border-radius: 4px; background: transparent; color: inherit; cursor: pointer; }\n.oac-widget .oac-color__opacity { display: flex; align-items: center; gap: 5px; margin-top: 7px; font-size: 11px; }\n.oac-widget .oac-color__range { min-width: 0; flex: 1; }\n.oac-widget .oac-color__percent { min-width: 30px; text-align: right; }\n",Ft=["1m","3m","5m","15m","30m","1h","2h","4h","1d","1w"];function Bt(){const e=new Set,t=[{label:"Chart",value:""}];for(const o of[...Ft,...i().map(e=>e.code)]){const n=o.toLowerCase();e.has(n)||(e.add(n),t.push({label:o,value:o}))}return t}function Ut(e,t){const o=[];for(const t of e){const e=o.length;switch(t.type){case"colorPair":o.push({key:t.key,kind:"colorPair",label:t.label,group:t.group,pair:{enabled:void 0===t.enabled?void 0:{key:t.enabled.key},up:{key:t.up.key,label:t.up.label},down:{key:t.down.key,label:t.down.label}}});break;case"number":o.push({key:t.key,kind:"number",label:t.label,group:t.group,min:t.min,max:t.max,step:t.step});break;case"select":o.push({key:t.key,kind:"select",label:t.label,group:t.group,options:t.options});break;case"source":o.push({key:t.key,kind:"select",label:t.label,group:t.group,options:a});break;case"interval":o.push({key:t.key,kind:"select",label:t.label,group:t.group,options:Bt()});break;case"time":o.push({key:t.key,kind:"text",label:t.label,group:t.group});break;case"boolean":case"color":case"text":o.push({key:t.key,kind:t.type,label:t.label,group:t.group})}void 0!==t.tooltip&&o.length>e&&(o[e].tooltip=t.tooltip)}return Ht(o,t)}function Ht(e,t){if(void 0===t?.translate)return e;const o=(e,o)=>ee(t,`schema.${t.scope}.${e}`,{},o);return e.map(e=>({...e,label:o(`${e.key}.label`,e.label),group:void 0===e.group?void 0:o(`group.${e.group}`,e.group),tooltip:void 0===e.tooltip?void 0:o(`${e.key}.tooltip`,e.tooltip),options:e.options?.map(t=>({...t,label:t.label===t.value?t.label:o(`${e.key}.option.${t.value}`,t.label)})),pair:void 0===e.pair?void 0:{...e.pair,up:{...e.pair.up,label:o(`${e.pair.up.key}.label`,e.pair.up.label)},down:{...e.pair.down,label:o(`${e.pair.down.key}.label`,e.pair.down.label)}}}))}const Vt={line:"Line",fill:"Fill",text:"Text",levels:"Levels",behavior:"Behavior"};function Kt(e,t){const o=[];for(const t of e){const e=void 0===t.group?void 0:Vt[t.group]??t.group,n={key:t.path,label:t.label,group:e};switch(t.kind){case"color":o.push({...n,kind:"color"});break;case"number":o.push({...n,kind:"number",min:t.min,max:t.max,step:t.step});break;case"opacity":o.push({...n,kind:"opacity"});break;case"boolean":o.push({...n,kind:"boolean"});break;case"select":case"lineStyle":o.push(void 0===t.options?{...n,kind:"text"}:{...n,kind:"select",options:t.options});break;case"text":o.push({...n,kind:"text.value"===t.path?"multiline":"text"});break;case"levels":o.push({...n,kind:"custom",custom:"levels"})}}return Ht(o,t)}function qt(e,t,o,n){const a=e.createElement(t);return void 0!==o&&""!==o&&(a.className=o),void 0!==n&&(a.textContent=n),a}function Wt(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${e}"/></svg>`}function Gt(e,t){const o=qt(e,"span","oac-glyph oac-glyph--chrome");return o.innerHTML=T(t),o}function Zt(e,t){const o=qt(e,"button");o.type="button";const n=["oac-btn"];if(!0===t.iconOnly&&n.push("oac-btn--icon"),"primary"===t.variant&&n.push("oac-btn--primary"),"danger"===t.variant&&n.push("oac-btn--danger"),o.className=n.join(" "),void 0!==t.icon)o.appendChild(Gt(e,t.icon));else if(void 0!==t.svg){const n=qt(e,"span","oac-glyph oac-glyph--chrome");n.innerHTML=t.svg,o.appendChild(n)}if(!0===t.iconOnly?(o.setAttribute("aria-label",t.label),o.title=void 0===t.chord?t.label:`${t.label} (${t.chord})`):(o.appendChild(e.createTextNode(t.label)),void 0!==t.chord&&(o.title=t.chord)),void 0!==t.onClick){const e=t.onClick;o.addEventListener("click",t=>{t.stopPropagation(),e(t)})}return o}function Jt(e){e.addEventListener("keydown",e=>{const t=e.key;"Escape"!==t&&"Tab"!==t&&e.stopPropagation()}),e.addEventListener("pointerdown",e=>{e.stopPropagation()})}let Yt=0;function Xt(e,t){const o=qt(e,"div","oac-panel"+(void 0===t.className?"":" "+t.className));o.setAttribute("role","dialog"),o.tabIndex=-1;const n="oac-dlg-title-"+ ++Yt;o.setAttribute("aria-labelledby",n);const a=qt(e,"div","oac-dialog__head"),i=qt(e,"span","oac-dialog__title",t.title);i.id=n;const r=Zt(e,{label:ee(t,"Close"),icon:"close",iconOnly:!0,onClick:()=>t.onClose()});a.appendChild(i),a.appendChild(r);const s=qt(e,"div","oac-dialog__body"),l=qt(e,"div","oac-dialog__foot"),c=qt(e,"div","oac-dialog__lead"),d=qt(e,"div","oac-spacer"),p=qt(e,"div","oac-dialog__actions");return l.appendChild(c),l.appendChild(d),l.appendChild(p),o.appendChild(a),o.appendChild(s),o.appendChild(l),Jt(o),{el:o,head:a,body:s,foot:l,lead:c,actions:p,closeButton:r,setTitle:e=>{i.textContent=e}}}function Qt(e,t,o,n){let a,i=!1,r=!1;const s=e.openOverlay(t,{...o,onClose:()=>{o.onClose?.(),i||(r=!0,n(),d())}}),l=t.closest(".oac-widget"),c=t.querySelectorAll(".oac-tabs--rail");if(null!==l&&c.length>0){const e=()=>{const e=l.getBoundingClientRect().width<=720?"horizontal":"vertical";c.forEach(t=>t.setAttribute("aria-orientation",e))};e();const o=t.ownerDocument.defaultView?.ResizeObserver;void 0!==o&&(a=new o(e),a.observe(l))}function d(){i||(i=!0,a?.disconnect(),r||s(),t.remove())}return{el:t,close:d,isOpen:()=>!i}}function eo(e,t){const o=e.getBoundingClientRect(),n=t.getBoundingClientRect();return{left:n.left-o.left,top:n.top-o.top,right:n.right-o.left,bottom:n.bottom-o.top}}function to(e,t,o){const n=t.panes()[0]?.element.parentElement??null,a=null===n?{left:0,top:0}:eo(e,n);let i=1/0,r=-1/0;for(const e of o)for(const o of e.points){const n=t.timeToCoordinate(o.time),a=t.priceToCoordinate(o.price,e.paneIndex);Number.isFinite(n)&&null!==a&&Number.isFinite(a)&&(i=Math.min(i,n),r=Math.max(r,a))}return Number.isFinite(i)&&Number.isFinite(r)?{x:a.left+i,y:a.top+r+12}:{x:a.left+60,y:a.top+60}}function oo(e,t,o,n,a){const i=qt(e,"div",`oac-tabs oac-tabs--${n}`);i.setAttribute("role","tablist"),i.setAttribute("aria-orientation","rail"===n?"vertical":"horizontal");const r=[],s=e=>{t.forEach((t,o)=>{const n=t.id===e;r[o].setAttribute("aria-selected",n?"true":"false"),r[o].tabIndex=n?0:-1})},l=e=>{s(e),a(e)};return t.forEach((o,n)=>{const a=qt(e,"button","oac-tab");if(a.type="button",a.setAttribute("role","tab"),a.dataset.tab=o.id,void 0!==o.icon){const t=qt(e,"span","oac-glyph oac-glyph--chrome");t.innerHTML=o.icon,a.appendChild(t)}a.appendChild(qt(e,"span","oac-tab__label",o.label)),a.addEventListener("click",e=>{e.stopPropagation(),l(o.id)}),a.addEventListener("keydown",e=>{const o=e.key,a="vertical"===i.getAttribute("aria-orientation"),s=a?"ArrowUp":"ArrowLeft";let c=-1;o===(a?"ArrowDown":"ArrowRight")?c=(n+1)%t.length:o===s?c=(n-1+t.length)%t.length:"Home"===o?c=0:"End"===o&&(c=t.length-1),c<0||(e.preventDefault(),r[c].focus(),r[c].scrollIntoView?.({block:"nearest",inline:"nearest"}),l(t[c].id))}),r.push(a),i.appendChild(a)}),s(o),{el:i,setActive:s}}function no(e,t,o){const n=e.getBoundingClientRect(),a=t.offsetWidth||200,i=t.offsetHeight||100;let r=4,s=4;if(void 0!==o.anchor){const e=o.anchor.getBoundingClientRect();r=e.left-n.left,s=e.bottom-n.top+6,s+i>n.height-4&&(s=Math.max(4,e.top-n.top-i-6))}else void 0!==o.point&&(r=o.point.x,s=o.point.y,s+i>n.height-4&&(s=Math.max(4,n.height-i-4)));r=Math.max(4,Math.min(r,n.width-a-4)),s=Math.max(4,Math.min(s,n.height-i-4)),t.style.left=`${Math.round(r)}px`,t.style.top=`${Math.round(s)}px`}const ao=new WeakMap;function io(e,t,o){ao.get(e)?.();let n=!1;const a=[],i=e.ownerDocument;e.innerHTML="",e.classList.add("oac-form");const r=[],s=o.unavailable??(()=>null),l=e=>`${o.idPrefix}-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`,c=new Map,d=(e,t)=>{n||c.has(e)&&Object.is(c.get(e),t)||(c.set(e,t),o.onChange(e,t))},p=(e,t)=>{null!==t&&(e.disabled=!0,e.title=t)};function u(e,t,n,r){const u=s(e);let h,b;switch(t){case"boolean":{const t=qt(i,"input");t.type="checkbox",t.checked=!0===r,t.addEventListener("change",()=>d(e,t.checked)),h=t,b={key:e,control:t,read:()=>t.checked,write:e=>{t.checked=!0===e}};break}case"number":{const t=qt(i,"input","oac-input--num");t.type="number",void 0!==n.min&&(t.min=String(n.min)),void 0!==n.max&&(t.max=String(n.max)),void 0!==n.step&&(t.step=String(n.step));const a=e=>{var o;t.value="number"==typeof e&&Number.isFinite(e)?(o=e,Number.isInteger(o)?String(o):String(Math.round(1e3*o)/1e3)):""};a(r),t.addEventListener("change",()=>{const i=t.value.trim(),s=""===i?NaN:Number(i);if(!Number.isFinite(s))return void(o.preserveInvalidNumbers?d(e,void 0):a(c.has(e)?c.get(e):r));const l=n.min??-1/0,p=n.max??1/0,u=Math.min(p,Math.max(l,s));u!==s&&a(u),d(e,u)}),h=t,b={key:e,control:t,read:()=>{const e=Number(t.value);return""!==t.value.trim()&&Number.isFinite(e)?e:void 0},write:a};break}case"color":{const t=zt(i,{id:l(e),label:n.label,value:r,live:o.live,translate:o.translate,disabledReason:u,openOverlay:o.openOverlay,onChange:t=>d(e,t)});return a.push(t.destroy),h=t.el,b={key:e,control:t.input,focus:t.trigger,read:t.read,write:t.write},{ctl:h,b:b}}case"opacity":{const t=qt(i,"input","oac-range");t.type="range",t.min="0",t.max="100",t.step="1";const n=qt(i,"output","oac-out"),a=e=>Math.round(100*("number"==typeof e?Math.min(1,Math.max(0,e)):0)),s=e=>{t.value=String(a(e)),n.textContent=`${a(e)}%`};s(r),t.addEventListener("input",()=>{n.textContent=`${t.value}%`,!0===o.live&&d(e,Number(t.value)/100)}),t.addEventListener("change",()=>d(e,Number(t.value)/100));const l=qt(i,"span","oac-opacity");return l.appendChild(t),l.appendChild(n),p(t,u),h=l,b={key:e,control:t,read:()=>Number(t.value)/100,write:s},{ctl:h,b:b}}case"select":{const{wrap:t,select:a}=function(e){const t=qt(e,"span","oac-select"),o=qt(e,"select");t.appendChild(o);const n=qt(e,"span","oac-chev");return n.innerHTML=T("chevron-down"),t.appendChild(n),{wrap:t,select:o}}(i),l=n.options??[],c=t=>{a.innerHTML="";const n=l.slice(),r="string"==typeof t?t:void 0===t?void 0:String(t);void 0===r||""===r||n.some(e=>e.value===r)||n.push({value:r,label:ee(o,"Custom")});for(const t of n){const o=qt(i,"option",void 0,t.label);o.value=t.value;const n=s(e,t.value);null!==n&&(o.disabled=!0,o.title=n),a.appendChild(o)}a.value=void 0===r||""===r?n[0]?.value??"":r};return c(r),a.addEventListener("change",()=>d(e,a.value)),p(a,u),h=t,b={key:e,control:a,read:()=>a.value,write:c},{ctl:h,b:b}}case"multiline":{const t=qt(i,"textarea","oac-input--multi");t.rows=3,t.setAttribute("spellcheck","false");const o=e=>{t.value=null==e?"":String(e)};o(r),t.addEventListener("change",()=>d(e,t.value)),h=t,b={key:e,control:t,read:()=>t.value,write:o};break}default:{const t=qt(i,"input");t.type="text",t.setAttribute("spellcheck","false");const o=e=>{t.value=null==e?"":String(e)};o(r),t.addEventListener("change",()=>d(e,t.value)),h=t,b={key:e,control:t,read:()=>t.value,write:o};break}}return p(h,u),{ctl:h,b:b}}let h;for(const n of t){void 0!==n.group&&n.group!==h&&e.appendChild(qt(i,"div","oac-head",n.group)),h=n.group??h;const t=qt(i,"div","oac-row");t.dataset.key=n.key;const a=qt(i,"label","oac-row__label",n.label);if(void 0!==n.tooltip&&""!==n.tooltip){const e=qt(i,"span","oac-help","?");e.title=n.tooltip,e.tabIndex=0,e.setAttribute("role","note"),e.setAttribute("aria-label",n.tooltip),a.appendChild(e)}if("custom"===n.kind){const r=void 0===o.custom?null:o.custom(n,t);if(null===r)continue;t.appendChild(qt(i,"span","oac-row__sw")),t.appendChild(a);const s=qt(i,"div","oac-row__ctl");s.appendChild(r),t.appendChild(s),e.appendChild(t);continue}if("colorPair"===n.kind&&void 0!==n.pair){const c=n.pair,d=s(c.up.key),p=s(c.down.key);if(null!==d&&null!==p&&(t.classList.add("oac-row--off"),t.title=d),void 0!==c.enabled){const e=u(c.enabled.key,"boolean",n,o.values[c.enabled.key]);e.ctl.classList.add("oac-row__sw"),e.ctl.id=l(c.enabled.key),a.htmlFor=e.ctl.id,r.push(e.b),t.appendChild(e.ctl)}else t.appendChild(qt(i,"span","oac-row__sw"));t.appendChild(a);const h=qt(i,"div","oac-row__ctl");for(const e of[c.up,c.down]){const t=u(e.key,"color",n,o.values[e.key]);t.b.control.id=l(e.key);const a=t.b.control.disabled?`${e.label}: ${t.b.control.title}`:e.label;t.b.control.title=a,void 0!==t.b.focus&&(t.b.focus.title=a),t.b.control.setAttribute("aria-label",`${n.label} ${e.label}`),t.b.focus?.setAttribute("aria-label",`${n.label} ${e.label}`),r.push(t.b),h.appendChild(t.ctl)}void 0===c.enabled&&(a.htmlFor=`${l(c.up.key)}-trigger`),t.appendChild(h),e.appendChild(t);continue}const c=u(n.key,n.kind,n,o.values[n.key]),d=s(n.key);if(null!==d&&(t.classList.add("oac-row--off"),t.title=d),c.b.control.id=l(n.key),a.htmlFor=(c.b.focus??c.b.control).id,r.push(c.b),"boolean"===n.kind)c.ctl.classList.add("oac-row__sw"),t.appendChild(c.ctl),t.appendChild(a);else if("multiline"===n.kind)t.classList.add("oac-row--block"),t.appendChild(a),t.appendChild(c.ctl);else{t.appendChild(qt(i,"span","oac-row__sw")),t.appendChild(a);const e=qt(i,"div","oac-row__ctl");e.appendChild(c.ctl),t.appendChild(e)}e.appendChild(t)}const b=()=>{if(!n){n=!0;for(const e of a.splice(0))e();ao.get(e)===b&&ao.delete(e)}};return ao.set(e,b),{el:e,destroy:b,sync:e=>{if(n)return;const t=i.activeElement;for(const o of r)o.control!==t&&o.key in e&&o.write(e[o.key])},values:()=>{const e={};for(const t of r)e[t.key]=t.read();return e},focusFirst:()=>{if(n)return!1;for(const e of r)if(!e.control.disabled)return(e.focus??e.control).focus(),!0;return!1}}}const ro=[0,.236,.382,.5,.618,.786,1,1.272,1.414,1.618,2,2.618,3.618,4.236],so=(e,t)=>e.some(e=>Math.abs(e.ratio-t)<=1e-6);function lo(e,t,o={}){const n=e.document,a=o.ids??e.draw.selection(),{drawings:i,schema:r}=function(e,t){const o=[];for(const n of t){const t=e.draw.get(n);void 0!==t&&F(t.tool).fields.some(e=>"levels"===e.kind)&&o.push(t)}return{drawings:o,schema:0===o.length?null:F(o[0].tool)}}(e,a);if(null===r)return e.toast(ee(e,"Select a drawing with levels first"),"info"),{el:n.createElement("div"),close:()=>{},isOpen:()=>!1};const s=i[0],l=function(e){try{return P(e)}catch{return null}}(s.tool),c=r.fields.find(e=>"levels"===e.kind),d=r.fields.find(e=>"style.showLabels"===e.path),p=c?.path??"style.levels",u=l?.defaultStyle?.levels??R,h="gann-fan"===(b=s.tool)?B:"fib-time-zone"===b?e=>String(e):U;var b;const g=()=>{const e=H(s,p);return Array.isArray(e)?V(e):V(u)},m=()=>{const e=H(s,"style.showLabels");return void 0===e?!0===l?.defaultStyle?.showLabels:!0===e};let f=g();function v(t){const o=[];for(const n of i){const a=e.draw.get(n.id);if(void 0===a)continue;const i=K(a,t,r);Object.keys(i).length>0&&o.push({id:n.id,patch:i})}o.length>0&&e.draw.updateMany(o)}const w=()=>v({[p]:V(f)}),y=qt(n,"div","oac-panel oac-levels");y.setAttribute("role","dialog"),y.setAttribute("aria-label",ee(e,"Levels")),y.tabIndex=-1,Jt(y);const x=qt(n,"div","oac-levels__head");x.appendChild(qt(n,"b","oac-levels__title",ee(e,"Levels")));let _=null;if(void 0!==d){const t=qt(n,"label","oac-levels__labels");_=qt(n,"input"),_.type="checkbox",_.checked=m(),_.dataset.path=d.path;const o=_;o.addEventListener("change",()=>v({[d.path]:o.checked})),t.appendChild(o),t.appendChild(qt(n,"span",void 0,ee(e,"Show labels"))),x.appendChild(t)}x.appendChild(Zt(n,{label:ee(e,"Close"),icon:"close",iconOnly:!0,onClick:()=>O.close()})),y.appendChild(x);const k=qt(n,"div","oac-levels__rows");y.appendChild(k);let C=[];function $(){C.forEach(e=>e.destroy()),C=[],k.innerHTML="",0!==f.length?f.forEach((t,o)=>k.appendChild(function(t,o){const a=qt(n,"div","oac-levels__row"+(!1===t.enabled?" is-off":"")),i=qt(n,"input");i.type="checkbox",i.checked=!1!==t.enabled,i.setAttribute("aria-label",ee(e,"Enabled")),i.addEventListener("change",()=>{i.checked?delete f[o].enabled:f[o].enabled=!1,a.classList.toggle("is-off",!i.checked),w()}),a.appendChild(i);const r=qt(n,"input");r.type="number",r.step="0.001",r.value=String(t.ratio),r.setAttribute("aria-label",ee(e,"Ratio")),r.addEventListener("change",()=>{const e=Number(r.value);""!==r.value.trim()&&Number.isFinite(e)?(f[o].ratio=e,void 0===f[o].label&&(c.placeholder=h(e)),w()):r.value=String(f[o].ratio)}),a.appendChild(r);const l=zt(n,{id:`oac-level-${s.id}-${o}`,label:ee(e,"Color"),value:t.color??s.style.color??W(t.ratio)??q,translate:e.translate,openOverlay:e.openOverlay,onChange:e=>{f[o].color=e,w()}});C.push(l),a.appendChild(l.el);const c=qt(n,"input");c.type="text",c.value=t.label??"",c.placeholder=h(t.ratio),c.setAttribute("aria-label",ee(e,"Label")),c.setAttribute("spellcheck","false"),c.addEventListener("change",()=>{const e=c.value.trim();""===e?delete f[o].label:f[o].label=e,w()}),a.appendChild(c);const d=qt(n,"button","oac-levels__x");return d.type="button",d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true"><path d="M3 3l10 10M13 3 3 13"/></svg>',d.setAttribute("aria-label",ee(e,"Remove level")),d.addEventListener("click",e=>{e.stopPropagation(),f.splice(o,1),$(),w()}),a.appendChild(d),a}(t,o))):k.appendChild(qt(n,"div","oac-empty",ee(e,"No levels. Add one, or reset to the defaults.")))}$();const S=qt(n,"div","oac-levels__foot");S.appendChild(Zt(n,{label:ee(e,"Add level"),icon:"plus",onClick:()=>{const e=function(e){for(const t of ro)if(!so(e,t))return t;let t=0;for(const o of e)Number.isFinite(o.ratio)&&(t=Math.max(t,o.ratio));return t+1}(f),t={ratio:e},o=W(e);o!==q&&(t.color=o),f.push(t),$(),w()}})),S.appendChild(qt(n,"span","oac-spacer")),S.appendChild(Zt(n,{label:ee(e,"Reset"),onClick:()=>{f=V(u),$(),w()}})),y.appendChild(S);const A=e.chart.on("draw:update",()=>{if(!O.isOpen())return;if(void 0===e.draw.get(s.id))return void O.close();const t=g();JSON.stringify(t)===JSON.stringify(f)||y.contains(n.activeElement)||(f=t,$()),null!==_&&_!==n.activeElement&&(_.checked=m())}),L=e.chart.on("draw:remove",()=>{O.isOpen()&&void 0===e.draw.get(s.id)&&O.close()}),E=()=>{C.forEach(e=>e.destroy()),A(),L()},O=Qt(e,y,void 0===t?{placement:"below",dismissOnOutside:!0}:{anchor:t,placement:"below"},E);void 0===t&&no(e.root,y,{point:to(e.root,e.chart,i)});const T=O.close;return{el:y,isOpen:O.isOpen,close:()=>{E(),T()}}}function co(e,t){const o=!0===e.bold?"700 ":"";return`${!0===e.italic?"italic ":""}${o}${t}px ${void 0===e.fontFamily||""===e.fontFamily?"ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif":e.fontFamily}`}function po(e,t,o,n){const a=o.split("\n");if(!0!==t.wrap)return a;const i=[];for(const t of a){const o=t.split(/\s+/).filter(e=>""!==e);if(0===o.length){i.push("");continue}let a=o[0];for(let t=1;t<o.length;t++){const r=`${a} ${o[t]}`;e(r)>n?(i.push(a),a=o[t]):a=r}i.push(a)}return i}function uo(e){let t="",o=!1;const n=e=>{for(const a of Array.from(e.childNodes??[])){if(3===a.nodeType){t+=a.nodeValue??"",o=!1;continue}if(1!==a.nodeType)continue;const e=String(a.nodeName).toUpperCase();"BR"!==e?("DIV"!==e&&"P"!==e||""===t||t.endsWith("\n")||(t+="\n"),o=!1,n(a)):(t+="\n",o=!0)}};return n(e),o?t.slice(0,-1):t}function ho(e){return e.panes()[0]?.element.parentElement??null}function bo(e){return void 0!==e&&!0===F(e.tool).textIsContent}function go(e,t,o){return e.toast(t,"info"),o?.(!1),{el:e.document.createElement("div"),close:()=>{},isOpen:()=>!1,commit:()=>{},cancel:()=>{}}}function mo(e,t,o={}){const n=e.document,{chart:a,draw:i}=e,r=i.selection(),s=o.id??(1===r.length?r[0]:void 0),l=void 0===s?void 0:i.get(s);if(!bo(l))return go(e,ee(e,"Select a text drawing first"),o.onDone);const c=(()=>{try{return P(l.tool)}catch{return null}})(),d=void 0!==c?.defaultText?.value&&""!==c.defaultText.value?c.defaultText.value:ee(e,"Text"),p=l.text??{value:""},u=p.fontSize??14,h=co(p,u),b=function(e,t,o){let n=null;try{const t=e.createElement("canvas");n="function"==typeof t.getContext?t.getContext("2d"):null}catch{n=null}if(null!==n&&"function"==typeof n.measureText){n.font=t;const e=n;return t=>e.measureText(t).width}return e=>e.length*o*.6}(n,h,u),g=function(e,t,o,n="Text"){const a=t.points[0];if(void 0===a)return null;const i=e.timeToCoordinate(a.time),r=e.priceToCoordinate(a.price,t.paneIndex);if(!Number.isFinite(i)||null===r||!Number.isFinite(r))return null;const s=t.text??{value:""},l=s.fontSize??14,c=co(s,l),d=po(o,s,void 0===s.value||""===s.value?n:s.value,s.wrapWidth??220);let p=0;for(const e of d)p=Math.max(p,o(e));const u=1.35*l,h=d.length*u+10,b=s.valign??"top";return{x:i,y:"middle"===b?r-h/2:"bottom"===b?r-h:r,width:p+10,height:h,lineHeight:u,lines:d,font:c,size:l}}(a,l,b,d),m=ho(a);if(null===g||null===m)return go(e,ee(e,"That text is off the chart"),o.onDone);const f=eo(e.root,m),v=qt(n,"div","oac-textedit");v.setAttribute("contenteditable","plaintext-only"),v.setAttribute("spellcheck","false"),v.setAttribute("role","textbox"),v.setAttribute("aria-multiline","true"),v.setAttribute("aria-label",ee(e,"Drawing text")),v.tabIndex=0;const w=v.style;w.left=`${Math.round(g.x+f.left)}px`,w.top=`${Math.round(g.y+f.top)}px`,w.font=h,w.lineHeight=`${g.lineHeight}px`,w.color=p.color??l.style.color??"inherit",w.textAlign=p.align??"left",w.minWidth=`${Math.ceil(g.width)}px`,w.minHeight=`${Math.ceil(g.height)}px`;const y=!0===p.wrap,x=p.wrapWidth??220;w.whiteSpace=y?"pre-wrap":"pre",y&&(w.width=`${Math.ceil(g.width)}px`);const _=p.value??"";v.textContent=_;let k=!1;const C=e=>{k||(k=!0,A.close(),o.onDone?.(e))},$=()=>{if(k)return;const e=uo(v),t=e!==_;t&&void 0!==i.get(l.id)&&i.update(l.id,{text:{...i.get(l.id)?.text??{value:""},value:e}}),C(t)},S=()=>C(!1);for(const e of["pointerdown","pointermove","pointerup","click","dblclick","contextmenu","keyup","keypress"])v.addEventListener(e,e=>{e.stopPropagation()});v.addEventListener("keydown",e=>{const t=e.key;if("Tab"!==t&&e.stopPropagation(),"Escape"===t)return e.preventDefault(),void S();"Enter"===t&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),$())}),v.addEventListener("blur",()=>$()),y&&v.addEventListener("input",()=>{const e=po(b,p,uo(v)||d,x);let t=0;for(const o of e)t=Math.max(t,b(o));w.width=`${Math.ceil(t+10)}px`});const A=Qt(e,v,{placement:"below",modal:!1,dismissOnOutside:!1,initialFocus:v},S);try{const e=n.defaultView;if(null!==e&&"function"==typeof e.getSelection&&"function"==typeof n.createRange){const t=n.createRange();t.selectNodeContents(v),t.collapse(!1);const o=e.getSelection();o?.removeAllRanges(),o?.addRange(t)}}catch{}return{el:v,isOpen:A.isOpen,close:()=>$(),commit:$,cancel:S}}function fo(e){const t=e.map(e=>F(e));if(0===t.length)return{fields:[]};const[o,...n]=t,a=o.fields.filter(e=>n.every(t=>t.fields.some(t=>t.path===e.path&&t.kind===e.kind)));return t.every(e=>!0===e.textIsContent)?{fields:a,textIsContent:!0}:{fields:a}}const vo={"style.lineWidth":1.5,"style.lineStyle":"solid","style.fillOpacity":.12,"text.fontSize":14,"text.wrapWidth":220,"text.backgroundOpacity":1,"text.align":"left","text.valign":"top","text.position":"inside"};function wo(e,t,o){const n={};for(const a of t.fields){const[t,i]=a.path.split("."),r="style"===t?e?.defaultStyle:"text"===t?e?.defaultText:void 0;let s=void 0===r||void 0===i?void 0:r[i];void 0===s&&(s=vo[a.path]),void 0===s&&"boolean"===a.kind&&(s=!1),void 0===s&&"style.color"===a.path&&(s=o),void 0!==s&&(n[a.path]=s)}return n}function yo(e){try{return P(e)}catch{return null}}const xo=(e,t)=>e.length===t.length&&e.every((e,o)=>e===t[o]);function _o(e,t,o={}){const{draw:n,chart:a}=e,i=e.document;void 0!==o.ids&&o.ids.length>0&&!xo(o.ids,n.selection())&&n.select(o.ids.slice());let r=n.selection().slice();const s=()=>r.map(e=>n.get(e)).filter(e=>void 0!==e);let l=s();if(0===l.length)return e.toast(ee(e,"Select a drawing first"),"info"),{el:i.createElement("div"),close:()=>{},isOpen:()=>!1};let c=fo(l.map(e=>e.tool)),d=yo(l[0].tool),p=null;const u=()=>1===l.length?ee(e,`schema.drawing.${l[0].tool}.name`,{},d?.name??l[0].tool):ee(e,"{count} drawings",{count:l.length}),h=()=>function(e,t,o,n){const a=wo(o,t,n);for(const[o,n]of Object.entries(G(e,t)))void 0!==n&&(a[o]=n);for(const e of["text.color","style.fillColor","text.borderColor"])void 0===a[e]&&t.fields.some(t=>t.path===e)&&(a[e]=a["style.color"]);return a}(l[0],c,d,e.chartTheme.lineColor);function b(e){const t=[];for(const o of l){const a=n.get(o.id);if(void 0===a)continue;const i=K(a,e,c);Object.keys(i).length>0&&t.push({id:o.id,patch:i})}t.length>0&&n.updateMany(t)}const g=Xt(i,{translate:e.translate,title:u(),className:"oac-props",onClose:()=>$.close()}),m=qt(i,"div","oac-props__tools");m.setAttribute("role","toolbar"),m.setAttribute("aria-label",ee(e,"Drawing actions")),g.el.insertBefore(m,g.body);const f=qt(i,"div","oac-props__pane");function v(){m.innerHTML="";const t=l[0],o=!0===t.locked,a=!1===t.visible,s=t.zIndex<0,c=(e,t,o)=>{const n=Zt(i,{...e,iconOnly:!0});n.dataset.act=t,void 0!==o&&n.setAttribute("aria-pressed",o?"true":"false"),m.appendChild(n)},d=()=>{m.appendChild(qt(i,"span","oac-sep"))};c({label:ee(e,o?"Unlock":"Lock"),icon:o?"lock":"unlock",onClick:()=>{n.updateMany(r.map(e=>({id:e,patch:{locked:!o}})))}},"lock",o),c({label:ee(e,a?"Show":"Hide"),icon:a?"eye-off":"eye",onClick:()=>{n.updateMany(r.map(e=>({id:e,patch:{visible:a}})))}},"visible",a),d(),c({label:ee(e,"Bring to front"),icon:"front",onClick:()=>{for(const e of r)n.bringToFront(e)}},"front"),c({label:ee(e,"Send to back"),icon:"back",onClick:()=>{for(const e of r)n.sendToBack(e)}},"back"),c({label:ee(e,"In front of the series"),svg:Wt("M3 4h10M8 14V6M5 9l3-3 3 3"),onClick:()=>{for(const e of r)n.bringAboveSeries(e)}},"above",!s),c({label:ee(e,"Behind the series"),svg:Wt("M3 12h10M8 2v8M5 7l3 3 3-3"),onClick:()=>{for(const e of r)n.sendBehindSeries(e)}},"behind",s),d(),c({label:ee(e,"Duplicate"),icon:"duplicate",chord:"Ctrl+D",onClick:()=>{n.duplicate(r)}},"duplicate"),c({label:ee(e,"Delete"),icon:"trash",chord:"Del",variant:"danger",onClick:()=>{n.removeMany(r)}},"delete")}function w(){p?.destroy(),f.innerHTML="";const t=Kt(c.fields,{translate:e.translate,scope:`drawing.${l[0].tool}`});if(0===t.length)return f.appendChild(qt(i,"div","oac-empty",ee(e,"These drawings share no settings."))),void(p=null);if(p=io(f,t,{values:h(),translate:e.translate,openOverlay:e.openOverlay,idPrefix:"oac-props",onChange:(e,t)=>{b({[e]:t}),p?.sync(h())},custom:t=>{if("levels"!==t.custom)return null;const o=Zt(i,{label:ee(e,"Edit levels..."),onClick:t=>{lo(e,t.currentTarget,{ids:r})}});return o.dataset.act="edit-levels",o}}),!0===c.textIsContent&&1===l.length){const t=f.querySelector('[data-key="text.value"]');if(null!==t){const o=Zt(i,{label:ee(e,"Edit on chart"),icon:"text",onClick:()=>{mo(e,0,{id:l[0].id})}});o.dataset.act="edit-text",t.appendChild(o)}}}function y(){if(!$.isOpen())return;const e=n.selection().slice();if(0!==e.length){if(xo(e,r))return l=s(),0===l.length?void $.close():(p?.sync(h()),void v());r=e,l=s(),0!==l.length?(c=fo(l.map(e=>e.tool)),d=yo(l[0].tool),g.setTitle(u()),v(),w()):$.close()}else $.close()}g.body.appendChild(f),v(),w(),g.lead.appendChild(Zt(i,{label:ee(e,"Restore defaults"),onClick:()=>{const t={},o=wo(d,{fields:c.fields},e.chartTheme.lineColor);for(const e of c.fields){if("levels"===e.kind)continue;const[n,a]=e.path.split("."),i="style"===n?d?.defaultStyle:"text"===n?d?.defaultText:void 0,r=void 0===i||void 0===a?void 0:i[a];t[e.path]=void 0===r?void 0:o[e.path]}b(t),p?.sync(h())}})),g.actions.appendChild(Zt(i,{label:ee(e,"Done"),variant:"primary",onClick:()=>$.close()}));const x=[a.on("draw:update",y),a.on("draw:select",y),a.on("draw:remove",y)];let _=!1;const k=()=>{if(!_){_=!0,p?.destroy();for(const e of x)e();o.onClose?.()}},C=Qt(e,g.el,{...void 0===t?{placement:"below",dismissOnOutside:!0}:{anchor:t,placement:"below"},onClose:k},k);void 0===t&&no(e.root,g.el,{point:to(e.root,a,l)});const $={el:g.el,isOpen:C.isOpen,close:()=>{p?.destroy(),C.close(),k()}};return $}function ko(e,t,o={}){const{chart:n}=e,a=e.document,i=r(),s=Xt(a,{translate:e.translate,title:ee(e,"Indicators"),className:"oac-pick",onClose:()=>C.close()}),l=qt(a,"input","oac-pick__find");l.type="search",l.placeholder=ee(e,"Search indicators"),l.setAttribute("aria-label",ee(e,"Search indicators")),l.setAttribute("spellcheck","false");const c=qt(a,"div","oac-pick__findwrap");c.appendChild(l);const d=qt(a,"div","oac-pick__list");d.setAttribute("role","listbox"),d.setAttribute("aria-label",ee(e,"Indicators")),s.body.appendChild(c),s.body.appendChild(d);const p=qt(a,"div","oac-head oac-pick__running-head",ee(e,"schema.ui.indicatorPicker.running",{},"Running studies")),u=qt(a,"div","oac-pick__running");u.setAttribute("aria-label",ee(e,"schema.ui.indicatorPicker.running",{},"Running studies")),s.body.appendChild(p),s.body.appendChild(u),s.actions.appendChild(Zt(a,{label:ee(e,"Done"),variant:"primary",onClick:()=>C.close()}));let h=[],b=-1;const g=e=>n.indicators().filter(t=>t.indicatorId===e).length,m=e=>{0!==h.length?(b=Math.max(0,Math.min(h.length-1,e)),h.forEach((e,t)=>{e.classList.toggle("is-active",t===b),e.setAttribute("aria-selected",t===b?"true":"false")})):b=-1},f=t=>{const a=n.addIndicator(t.id);e.toast(ee(e,"Added {name}",{name:a.name}),"success"),o.onAdd?.(a),!0!==o.closeOnAdd?(v(),l.focus()):C.close()};function v(){!function(){u.innerHTML="";const t=n.indicators();if(0===t.length)return void u.appendChild(qt(a,"div","oac-empty oac-pick__running-empty",ee(e,"schema.ui.indicatorPicker.empty",{},"No running studies")));const o=new Map;for(const i of t){const t=(o.get(i.indicatorId)??0)+1;o.set(i.indicatorId,t);const r=qt(a,"div","oac-pick__running-row");r.dataset.instanceId=i.id,r.appendChild(qt(a,"span","oac-pick__running-name",i.name)),r.appendChild(qt(a,"span","oac-pick__running-number",String(t)));const s=ee(e,"schema.ui.indicatorPicker.remove",{},"Remove"),c=Zt(a,{label:s,onClick:()=>{n.removeIndicator(i.id),v(),l.focus()}});c.classList.add("oac-pick__remove"),c.setAttribute("aria-label",`${s} ${i.name} ${t}`),r.appendChild(c),u.appendChild(r)}}();const t=l.value;if(d.innerHTML="",h=[],0===i.length)return void d.appendChild(qt(a,"div","oac-empty",ee(e,"No indicators are registered. Import the indicators tier to fill this list.")));const o=function(e,t){const o=t.trim().toLowerCase();return e.filter(e=>""===o||e.name.toLowerCase().includes(o)||e.id.toLowerCase().includes(o)||(e.category??"").toLowerCase().includes(o)).sort((e,t)=>e.name.localeCompare(t.name))}(i.map(t=>({...t,name:ee(e,`schema.indicator.${t.id}.name`,{},t.name),category:void 0===t.category?void 0:ee(e,`schema.indicator.category.${t.category}`,{},t.category)})),t);if(0!==o.length){for(const[t,n]of function(e){const t=new Map;for(const o of e){const e=o.category??"Other",n=t.get(e);void 0===n?t.set(e,[o]):n.push(o)}return Array.from(t.entries()).sort((e,t)=>e[0].localeCompare(t[0]))}(o)){d.appendChild(qt(a,"div","oac-head","Other"===t?ee(e,"Other"):t));for(const t of n){const o=qt(a,"button","oac-pick__row");o.type="button",o.setAttribute("role","option"),o.dataset.id=t.id,o.appendChild(qt(a,"span","oac-pick__name",t.name));const n=g(t.id);if(n>0){const t=qt(a,"span","oac-pick__count",1===n?ee(e,"on chart"):ee(e,"on chart x{count}",{count:n}));t.setAttribute("aria-label",1===n?ee(e,"one instance on the chart"):ee(e,"{count} instances on the chart",{count:n})),o.appendChild(t)}o.addEventListener("click",e=>{e.stopPropagation(),f(t)}),d.appendChild(o),h.push(o)}}m(b<0?0:b)}else d.appendChild(qt(a,"div","oac-empty",ee(e,"No match")))}l.addEventListener("input",()=>{b=0,v()}),l.addEventListener("keydown",e=>{const t=e.key;if("ArrowDown"===t)e.preventDefault(),m(b+1);else if("ArrowUp"===t)e.preventDefault(),m(b-1);else if("Enter"===t){e.preventDefault();const t=h[b],o=t?.dataset.id,n=i.find(e=>e.id===o);void 0!==n&&f(n)}}),v();const w=n.on("objects:change",v),y=n.on("indicatorRemoved",v),x=n.on("state:restore:end",v),_=()=>{w(),y(),x()},k=Qt(e,s.el,void 0===t?{placement:"center",modal:!0,initialFocus:l}:{anchor:t,placement:"below",initialFocus:l},_),C={el:k.el,isOpen:k.isOpen,close:()=>{k.isOpen()&&(_(),k.close())}};return C}function Co(e){const t={};for(const o of e)t[o.key]=o.default;return t}function $o(e,t){return e.toast(t,"info"),{el:e.document.createElement("div"),close:()=>{},isOpen:()=>!1}}function So(e,t,o={}){const n=e.document,a=function(e,t,o){const n=e.chart.indicators(),a=o.instanceId??t?.dataset.instanceId;if(void 0!==a){const t=n.find(e=>e.id===a)??null;return null===t?{inst:null,why:ee(e,"That indicator is no longer on the chart")}:{inst:t,why:null}}return 1===n.length?{inst:n[0],why:null}:{inst:null,why:0===n.length?ee(e,"No indicator on the chart to configure"):ee(e,"Pick an indicator from the legend first")}}(e,t,o);if(null===a.inst)return $o(e,a.why??ee(e,"No indicator to configure"));const i=a.inst,r=s(i.indicatorId),d=[];r.inputs.length>0&&d.push({id:"inputs",label:ee(e,"Inputs"),icon:T("settings"),inputs:r.inputs});const p=l(r);if(p.length>0&&d.push({id:"style",label:ee(e,"Style"),icon:Wt("M3 13c2.5 0 3.5-1.5 4-3.5M7.5 9.5 13 4a1.4 1.4 0 0 1 2 2l-5.5 5.5"),inputs:p}),0===d.length)return $o(e,ee(e,"{name} has nothing to configure",{name:i.name}));const u=i.settings(),h=new Set;let b=d.some(e=>e.id===o.tab)?o.tab:d[0].id,g=null,m=!1;const f=()=>({...c(r),...Co(p),...i.settings()}),v=e=>{for(const t of Object.keys(e))h.add(t);i.setSettings(e),o.onChange?.(i)},w=Xt(n,{translate:e.translate,title:ee(e,"{name} settings",{name:i.name}),className:"oac-indset",onClose:()=>k()}),y=qt(n,"div","oac-indset__pane");if(d.length>1){const e=oo(n,d.map(e=>({id:e.id,label:e.label,icon:e.icon})),b,"row",e=>{b=e,x()});w.body.appendChild(e.el)}function x(){g?.destroy();const t=d.find(e=>e.id===b)??d[0];y.innerHTML="",g=io(y,Ut(t.inputs,{translate:e.translate,scope:`indicator.${r.id}`}),{values:f(),translate:e.translate,openOverlay:e.openOverlay,idPrefix:`oac-ind-${i.id}`,live:!0,onChange:(e,t)=>{v({[e]:t}),g?.sync(f())}})}w.body.appendChild(y),x(),w.lead.appendChild(Zt(n,{label:ee(e,"Defaults"),onClick:()=>{const e=d.find(e=>e.id===b)??d[0];v(Co(e.inputs)),x()}})),w.actions.appendChild(Zt(n,{label:ee(e,"Cancel"),onClick:()=>k()})),w.actions.appendChild(Zt(n,{label:ee(e,"OK"),variant:"primary",onClick:()=>C()}));const _=Qt(e,w.el,{placement:"center",modal:!0,onClose:()=>g?.destroy()},()=>k());function k(){_.isOpen()&&(!function(){if(m||0===h.size)return;const e={};for(const t of h)e[t]=u[t];h.clear(),i.setSettings(e),o.onChange?.(i)}(),g?.destroy(),_.close(),o.onClose?.(!1))}function C(){_.isOpen()&&(m=!0,g?.destroy(),_.close(),o.onClose?.(!0))}return{el:w.el,isOpen:_.isOpen,close:()=>C()}}const Ao={price:"M5 2v12M3 5h4v6H3zM11 2v12M9 4h4v7H9z",readout:"M2 4h8M2 8h12M2 12h9",axes:"M3 2v11h11M3 6h2M3 10h2M7 13v-2M11 13v-2",appearance:"M2 3h12v10H2zM2 8h12M7 3v10",trading:"M2 12l4-4 3 2 5-6M11 4h3v3M2 14h12"};function Lo(e,t,o={}){const{chart:n}=e,a=e.document,i=d(n).filter(e=>e.inputs.length>0),r=p(n),s=new Set;let l=i.some(e=>e.id===o.tab)?o.tab:i[0]?.id??"price",c=null,h=!1;const b=e=>{for(const t of Object.keys(e))s.add(t);u(n,e),o.onApply?.(e)},g=Xt(a,{translate:e.translate,title:ee(e,"Chart settings"),className:"oac-settings",onClose:()=>_()}),m=qt(a,"div","oac-settings__main"),f=qt(a,"div","oac-settings__pane");g.body.appendChild(m);const v=oo(a,i.map(t=>({id:t.id,label:ee(e,`schema.settings.tab.${t.id}`,{},t.label),icon:Wt(Ao[t.id]??"")})),l,"rail",e=>{l=e,w()});function w(){c?.destroy();const t=i.find(e=>e.id===l);f.innerHTML="",c=null,void 0!==t?c=io(f,Ut(t.inputs,{translate:e.translate,scope:"settings"}),{values:p(n),translate:e.translate,openOverlay:e.openOverlay,idPrefix:"oac-cset",live:!0,unavailable:(t,a)=>"statusLine.openInterest"===t&&!1===n.hasOpenInterest?ee(e,"Open interest is unavailable for this instrument."):o.unavailable?.(t,a)??null,onChange:(e,t)=>{b({[e]:t}),c?.sync(p(n))}}):f.appendChild(qt(a,"div","oac-empty",ee(e,"Nothing to configure on this chart yet.")))}m.appendChild(v.el),m.appendChild(f),w(),g.lead.appendChild(Zt(a,{label:ee(e,"Restore this tab"),onClick:()=>{const e=i.find(e=>e.id===l);void 0!==e&&(b(function(e){const t={};for(const o of e.inputs)"colorPair"===o.type?(t[o.up.key]=o.up.default,t[o.down.key]=o.down.default,void 0!==o.enabled&&(t[o.enabled.key]=o.enabled.default)):t[o.key]=o.default;return t}(e)),w())}})),g.actions.appendChild(Zt(a,{label:ee(e,"Cancel"),onClick:()=>_()})),g.actions.appendChild(Zt(a,{label:ee(e,"OK"),variant:"primary",onClick:()=>k()}));const y=n.on("data:context",w),x=Qt(e,g.el,{placement:"center",modal:!0,onClose:()=>{y(),c?.destroy()}},()=>_());function _(){x.isOpen()&&(!function(){if(h||0===s.size)return;const e={};for(const t of s){const o=r[t];void 0!==o&&(e[t]=o)}s.clear(),u(n,e),o.onApply?.(e)}(),c?.destroy(),x.close(),o.onClose?.(!1))}function k(){x.isOpen()&&(h=!0,c?.destroy(),x.close(),o.onClose?.(!0))}return{el:g.el,isOpen:x.isOpen,close:()=>k()}}const Eo=[{value:"price",label:"Price"},{value:"indicator",label:"Study plot"},{value:"drawing",label:"Drawing level"},{value:"barCondition",label:"Candle condition"}],Oo=(e,t,o)=>({key:e,label:t,kind:"select",options:o}),To=(e,t,o)=>t?s(t.indicatorId).plots.filter(e=>void 0===o||(e.overlay?0:t.paneIndex)===o).map(o=>({value:o.key,label:ee(e,`schema.indicator.${t.indicatorId}.plot.${o.key}`,{},o.title)})):[];function Mo(e,t){const o=[Oo("kind",ee(e,"Source"),Eo.map(t=>({...t,label:ee(e,`schema.alert.kind.${t.value}`,{},t.label)})))],n=e.chart.indicators(),a=e.chart.primaryBars(),i=a.length-1,r=(e,o)=>(void 0===t[e]&&(t[e]=o[0]?.value??""),String(t[e])),s=e=>e.map(e=>({value:e.id,label:`${n.indexOf(e)+1}: ${e.name}`})),l=t.kind;if("barCondition"===l){const t=h().map(t=>({value:t.id,label:ee(e,`schema.barCondition.${t.id}.title`,{},t.title)})),n=r("barConditionId",t);return o.push(Oo("barConditionId",ee(e,"Candle condition"),t)),{source:{kind:l,id:n},controls:o,reason:t.some(e=>e.value===n)?void 0:ee(e,"Candle condition is unavailable")}}if("indicator"===l){const a=r("instanceId",s(n)),c=n.find(e=>e.id===a),d=To(e,c),p=r("plotKey",d);o.push(Oo("instanceId",ee(e,"Study"),s(n)),Oo("plotKey",ee(e,"Plot"),d));const u=c?.values()[p]?.[i];return"value"in t||(t.value=u??void 0),{source:{kind:l,instanceId:a,plotKey:p,value:t.value,upperValue:t.upperValue},controls:o,reason:c?c.series(p)?void 0:ee(e,"Study plot is unavailable"):ee(e,"Study instance is unavailable"),hint:Number.isFinite(u)?void 0:ee(e,"The current plot value is unavailable. The alert waits for observed values.")}}if("drawing"===l){const t=e.draw.drawings().map((t,o)=>({value:t.id,label:`${ee(e,`schema.drawing.${t.tool}.name`,{},ze(t.tool))} (${o+1})`})),a=r("drawingId",t),i=e.draw.alertInfo(a),c=i.levels.map(e=>({value:e.id,label:e.title})),d=r("level",c);o.push(Oo("drawingId",ee(e,"Drawing"),t),Oo("level",ee(e,"Level"),c));const p=n.filter(t=>To(e,t,i.paneIndex).length>0),u=s(p);0===i.paneIndex&&u.unshift({value:"",label:ee(e,"Price")});const h=r("inputInstanceId",u);o.push(Oo("inputInstanceId",ee(e,"Compare with"),u));const b=p.find(e=>e.id===h);let g;if(h){const t=To(e,b,i.paneIndex),n=r("inputPlotKey",t);g={instanceId:h,plotKey:n},o.push(Oo("inputPlotKey",ee(e,"Input plot"),t))}const m=i.available?c.some(e=>e.value===d)?g?To(e,b,i.paneIndex).some(e=>e.value===g.plotKey)?void 0:ee(e,"Select an input plot on the drawing pane"):0!==i.paneIndex?ee(e,"Select an input plot on the drawing pane"):void 0:ee(e,"Drawing level is unavailable"):i.reason;return{source:{kind:l,drawingId:a,level:d,...g?{input:g}:{}},controls:o,reason:m}}return"price"in t||(t.price=a[i]?.close),{source:{kind:"price",price:t.price,upperPrice:t.upperPrice},controls:o}}let jo=0;const Io=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/;function Po(e,t){if(void 0===e)return"";const o=b(e,t),n=e=>String(e).padStart(2,"0");return`${o.year}-${n(o.month)}-${n(o.day)}T${n(o.hour)}:${n(o.minute)}`}function Do(e,t){if(e)return Po(e.expiresAt,t);const o=b(Math.floor(Date.now()/1e3),t),n=o.month-1+2,a=Math.min(o.day,new Date(Date.UTC(o.year,n+1,0)).getUTCDate()),i=Date.UTC(o.year,n,a,o.hour,o.minute)/1e3,r=i-g(i,t),s=i-g(r,t);return Po(s+g(s,t)===i?s:Math.max(r,s),t)}function No(e,t,o={}){const n=e.alerts,a=n?.list().find(e=>e.id===o.alertId),i=e.chart.timezone(),r=e.chart.getDataContext(),s=e=>JSON.stringify([e?.symbol,e?.exchange,e?.interval]),l=s(r),c=e.chart.primaryBars(),d=a?.source??o.source??{kind:"price",price:c[c.length-1]?.close};let p,u=!1,h=!1;const b="oac-alert-"+ ++jo,g=[];let f={...a,...d,..."drawing"===d.kind?{inputInstanceId:d.input?.instanceId,inputPlotKey:d.input?.plotKey}:{},..."barCondition"===d.kind?{barConditionId:d.id}:{},enabled:!a||"armed"===a.state,expiresAt:Do(a,i)};function w(){if(!u){u=!0;for(const e of g.splice(0))e();p?.destroy(),O?.close(),o.onClose?.()}}const y=Xt(e.document,{translate:e.translate,title:ee(e,a?"Edit alert":"Create alert"),className:"oac-alert-editor",onClose:w});y.closeButton.textContent=ee(e,"Close"),y.closeButton.classList.remove("oac-btn--icon");const x=qt(e.document,"p","oac-alert-context",[r?.symbol,r?.exchange,r?.interval].filter(Boolean).join(" / ")),_=qt(e.document,"div"),k=qt(e.document,"p","oac-alert-help"),C=qt(e.document,"p","oac-alert-help",ee(e,"Bar close evaluates confirmed values. Intrabar touch can fire on a wick that is absent from final history.")),$=qt(e.document,"p","oac-alert-error");$.setAttribute("role","status"),y.body.append(x,_,k,C,$);const S=Zt(e.document,{label:ee(e,"Save"),variant:"primary",onClick:function(){if(u)return;try{const t=L();if(t)throw new Error(t);f={...f,...p.values()};const o=f.condition,r="enteringRange"===o||"leavingRange"===o,s=Mo(e,f).source,l={source:"price"===s.kind?{kind:"price",price:f.price,...r?{upperPrice:f.upperPrice}:{}}:"indicator"===s.kind?{...s,value:f.value,upperValue:r?f.upperValue:void 0}:s,condition:o,title:String(f.title??""),message:String(f.message??"")||void 0,policy:f.policy,repeat:f.repeat,cooldownSeconds:f.cooldownSeconds};a&&f.expiresAt===Po(a.expiresAt,i)||(l.expiresAt=function(e,t,o){if(""===t)return;const n=ee(e,"Enter an expiry date and time");if("string"!=typeof t||!Io.test(t))throw new Error(n);const[a,i]=t.split("T"),[r,s,l]=a.split("-").map(Number),[c,d]=i.split(":").map(Number),p=v(r,s,l,c,d,0,o);if(!Number.isFinite(p)||Po(p,o)!==t)throw new Error(n);return p}(e,f.expiresAt,i)),a&&!h||(l.state=f.enabled?"armed":"disabled"),a?n.update(a.id,l):n.add(l),w()}catch(t){$.textContent=t instanceof Error?t.message:ee(e,"Could not save this alert")}}});S.dataset.action="save-alert";const A=Zt(e.document,{label:ee(e,"Cancel"),onClick:w});function L(){return n?o.alertId&&!n.list().some(e=>e.id===o.alertId)?ee(e,"This alert was removed"):s(e.chart.getDataContext())!==l||a&&s(a.scope)!==l?ee(e,"The instrument context changed. Reopen the editor for the intended instrument."):Mo(e,f).reason:ee(e,"Alerts are unavailable in this host")}function E(){const t=L();$.textContent=t??"",S.disabled=void 0!==t,k.textContent=Mo(e,f).hint??""}A.dataset.action="cancel-alert",y.actions.append(A,S),function t(){p?.destroy();const o=Mo(e,f),n=m(o.source,f.condition);for(const e of n)e.key in f||(f[e.key]=e.default);f.condition=n.find(e=>"condition"===e.key).default;const a=Ut(n,{translate:e.translate,scope:"alert"}),r=a.find(e=>"expiresAt"===e.key);r&&(r.label+=` (${i})`),p=io(_,[...o.controls,...a],{idPrefix:b,values:f,translate:e.translate,openOverlay:e.openOverlay,preserveInvalidNumbers:!0,onChange:(o,n)=>{f={...f,...p.values(),[o]:n},"enabled"===o&&(h=!0);const a=["kind","instanceId","plotKey","drawingId","level","inputInstanceId"].includes(o);if("kind"===o)for(const e of["price","value","upperPrice","upperValue","condition"])delete f[e];if("instanceId"===o&&(delete f.plotKey,delete f.value,delete f.upperValue),"plotKey"===o&&(delete f.value,delete f.upperValue),"drawingId"===o&&(delete f.level,delete f.inputInstanceId,delete f.inputPlotKey),"inputInstanceId"===o&&delete f.inputPlotKey,"condition"===o||a){const n=null!==e.document.activeElement&&_.contains(e.document.activeElement);t(),n&&_.querySelector(`[data-key="${o}"] select`)?.focus()}E()}});const s=_.querySelector('[data-key="expiresAt"] input');s&&(s.type="datetime-local",s.step="60")}(),E();for(const t of["data:context","data:update","objects:change","alert:removed","alerts:restored"])g.push(e.chart.on(t,E));g.push(e.chart.on("destroy",w));const O=Qt(e,y.el,{anchor:t,modal:!0,placement:"center"},w);return{el:y.el,close:w,isOpen:()=>!u&&O.isOpen()}}function zo(e,t,o={}){const n=e.alerts;let a=!1,i=!1;const r=[],s=new Map;function l(){if(!a){a=!0;for(const e of r.splice(0))e();v?.close(),o.onClose?.()}}const c=Xt(e.document,{translate:e.translate,title:ee(e,"Alerts"),className:"oac-alerts",onClose:l});c.closeButton.textContent=ee(e,"Close"),c.closeButton.classList.remove("oac-btn--icon");const d=qt(e.document,"div","oac-alerts__list");d.setAttribute("role","list"),d.setAttribute("aria-label",ee(e,"Chart alerts"));const p=qt(e.document,"p","oac-empty",ee(e,n?"No alerts. Create an alert for this chart.":"Alerts are unavailable in this host")),u=qt(e.document,"span","oac-alert-context");u.setAttribute("role","status");const h=Zt(e.document,{label:ee(e,"Create alert"),variant:"primary",onClick:()=>{No(e)}});h.dataset.action="create-alert",h.disabled=!n,c.body.append(d,p),c.lead.appendChild(u),c.actions.appendChild(h);const b={armed:ee(e,"Armed"),triggered:ee(e,"Triggered"),expired:ee(e,"Expired"),disabled:ee(e,"Disabled")};function g(t){const o=t.source;if("price"===o.kind)return void 0===o.upperPrice?ee(e,"Price {price}",{price:o.price}):ee(e,"Price {price} to {upper}",{price:o.price,upper:o.upperPrice});if("barCondition"===o.kind)return f(o.id)?.title??ee(e,"Unavailable candle condition");if("drawing"===o.kind){const t=Mo(e,{...o,inputInstanceId:o.input?.instanceId,inputPlotKey:o.input?.plotKey}),n=t.controls.find(e=>"drawingId"===e.key)?.options?.find(e=>e.value===o.drawingId)?.label;return`${n??ee(e,"Unavailable drawing")} / ${o.level??ee(e,"Default level")}`}const n=e.chart.indicators().find(e=>e.id===o.instanceId);return ee(e,void 0===o.upperValue?"{name} / {plot}: {value}":"{name} / {plot}: {value} to {upper}",{name:n?.name??ee(e,"Unavailable study"),plot:o.plotKey,value:o.value,upper:o.upperValue??""})}function m(){if(!a&&!i){i=!0;try{const t=n?.list()??[],o=new Set(t.map(e=>e.id));for(const[e,t]of s)o.has(e)||(t.el.remove(),s.delete(e));for(const o of t){let t=s.get(o.id);if(!t){const a=qt(e.document,"div","oac-alerts__row");a.dataset.alertId=o.id,a.setAttribute("role","listitem");const i=qt(e.document,"div","oac-alerts__summary"),r=qt(e.document,"div","oac-alerts__status"),l=qt(e.document,"div","oac-alerts__actions"),c=Zt(e.document,{label:ee(e,"Edit"),onClick:()=>{No(e,void 0,{alertId:o.id})}});c.dataset.action="edit-alert";const p=Zt(e.document,{label:ee(e,"Disable"),onClick:()=>{const e=n?.list().find(e=>e.id===o.id);"armed"===e?.state?n?.disable(o.id):n?.enable(o.id)}});p.dataset.action="toggle-alert";const u=Zt(e.document,{label:ee(e,"Delete"),onClick:()=>{n?.remove(o.id)}});u.dataset.action="delete-alert",l.append(c,p,u),a.append(i,r,l),d.appendChild(a),t={el:a,summary:i,status:r,toggle:p},s.set(o.id,t)}const a=[o.scope.symbol,o.scope.exchange,o.scope.interval].filter(Boolean).join(" / ");t.summary.textContent=`${o.title}\n${a}\n${g(o)}`,t.el.dataset.state=o.state;const i=n.availability(o.id);t.status.textContent=[b[o.state],"onBarClose"===o.policy?ee(e,"Bar close"):ee(e,"Intrabar touch"),"once"===o.repeat?ee(e,"Once"):ee(e,"Every match"),o.cooldownSeconds?ee(e,"{seconds}s cooldown",{seconds:o.cooldownSeconds}):"",void 0===o.expiresAt?"":ee(e,"Expires {time}",{time:Po(o.expiresAt,e.chart.timezone()).replace("T"," ")}),void 0===o.lastTriggeredAt?"":ee(e,"Last fired {time}",{time:Po(o.lastTriggeredAt,e.chart.timezone()).replace("T"," ")}),i.available?"":i.reason].filter(Boolean).join(" / "),t.toggle.textContent="armed"===o.state?ee(e,"Disable"):ee(e,"Enable"),t.toggle.setAttribute("aria-label",ee(e,"armed"===o.state?"Disable {name}":"Enable {name}",{name:o.title})),t.toggle.disabled="armed"!==o.state&&void 0!==o.expiresAt&&o.expiresAt<=Date.now()/1e3,t.toggle.title=t.toggle.disabled?ee(e,"Edit the expiry before enabling this alert"):""}p.hidden=t.length>0,u.textContent=ee(e,1===t.length?"{count} alert":"{count} alerts",{count:t.length})}finally{i=!1}}}for(const t of["alert:created","alert:updated","alert:removed","alert:triggered","alert:expired","alerts:restored","data:context","data:update","data:range","objects:change","replay:start","replay:stop"])r.push(e.chart.on(t,m));r.push(e.chart.on("destroy",l)),m();const v=Qt(e,c.el,{anchor:t,modal:!0,placement:"center"},l);return{el:c.el,close:l,isOpen:()=>!a&&v.isOpen()}}const Ro={kind:"separator"},Fo=e=>({kind:"header",label:e}),Bo={linear:"Linear",logarithmic:"Logarithmic",percentage:"Percent","indexed-to-100":"Indexed to 100"};function Uo(e,t,o){const n=e.panes()[t];return void 0===n?String(o):n.readoutScale().format(o)}function Ho(e,t,o={}){const{chart:n,draw:a}=e,i=t.target,r=[],l=()=>{r.length>0&&"separator"!==r[r.length-1].kind&&r.push(Ro)};if("price-scale"===i.kind)return r.push(...function(e,t,o){const{chart:n}=e,a=()=>n.priceAxisState(t,o),i=a();if(null===i)return[];const r=[];r.push({id:"axis-autofit",label:ee(e,"Auto-fit to the data"),mark:"check",on:i.autoFit,keepOpen:!0,run:()=>{const e=a();null!==e&&n.setPriceAxisAutoFit(t,o,!e.autoFit)}}),r.push({id:"axis-invert",label:ee(e,"Invert"),mark:"check",on:i.inverted,keepOpen:!0,run:()=>{const e=a();null!==e&&n.setPriceAxisOptions(t,o,{inverted:!e.inverted})}}),r.push({id:"axis-lock",label:ee(e,"Pin price per bar"),mark:"check",on:i.lockRatio,keepOpen:!0,disabled:!i.scaled,note:i.scaled?void 0:ee(e,"nothing measured"),run:()=>{const i=a();null!==i&&(n.setPriceAxisLockRatio(t,o,!i.lockRatio)||e.toast(ee(e,"Nothing measured on this scale yet"),"info"))}}),r.push(Ro),r.push(Fo(ee(e,"Scale")));for(const a of w)r.push({id:`axis-mode-${a}`,label:ee(e,`schema.scaleMode.${a}`,{},Bo[a]),mark:"radio",on:i.mode===a,keepOpen:!0,run:()=>{n.setPriceAxisOptions(t,o,{mode:a})}});return r.push(Ro),r.push({id:"axis-move",label:"right"===i.side?ee(e,"Move the scale to the left"):ee(e,"Move the scale to the right"),disabled:!i.movable,note:i.movable?void 0:i.active?ee(e,"other side taken"):ee(e,"nothing on this side"),run:()=>{const o=a();null!==o&&(n.movePriceAxis(t,o.side,"right"===o.side?"left":"right")||e.toast(ee(e,"That side is already in use"),"info"))}}),r.push(Ro),r.push({id:"axis-settings",label:ee(e,"Axis settings..."),icon:"settings",run:()=>{Lo(e,0,{tab:"axes"})}}),r}(e,t.paneIndex,i.scaleId??i.side??"right")),r;const c=o.onOrder;if(void 0!==c&&"time-scale"!==i.kind){const a=t.price,i={...e.symbol(),interval:e.interval()},s=t=>x(o.tradingCapabilities,{operation:"place",type:t,mode:o.tradingMode,...e.symbol()}),l=()=>{if(y(n))return ee(e,"Order entry is locked during replay");try{if(o.tradingLocked?.())return ee(e,"Order entry is locked by the host")}catch{return ee(e,"Order entry is unavailable")}},d=l(),p=(o,r)=>({id:`order-${o.toLowerCase()}-${r.toLowerCase()}`,label:"MARKET"===r?ee(e,"BUY"===o?"Buy market":"Sell market"):ee(e,"BUY"===o?"LIMIT"===r?"Buy limit at {price}":"Buy stop at {price}":"LIMIT"===r?"Sell limit at {price}":"Sell stop at {price}",{price:Uo(n,t.paneIndex,a)}),disabled:void 0!==d,note:d,run:()=>{if(n.isDestroyed)return;const d=e.symbol();if(d.symbol!==i.symbol||d.exchange!==i.exchange||e.interval()!==i.interval)return void e.status(ee(e,"The chart changed; reopen the menu before placing an order"),"error");const p=l();if(void 0!==p)return void e.status(p,"error");const u=s(r);u.supported?c({side:o,type:r,price:"MARKET"===r?null:a,paneIndex:t.paneIndex}):e.status(ee(e,"Order entry is unavailable: {reason}",{reason:u.reason}),"error")}}),u=(null===a?["MARKET"]:["MARKET","LIMIT","SL"]).map(e=>({type:e,result:s(e)})),h=u.filter(e=>e.result.supported);if(h.length>0){r.push(Fo(ee(e,"Trade")));for(const{type:e}of h)r.push(p("BUY",e),p("SELL",e))}else{const t=u[0].result;r.push({id:"trading-unavailable",label:ee(e,"Order entry is unavailable"),disabled:!0,note:t.supported?void 0:t.reason})}}const d=function(e){if("drawing"!==e.kind||null===e.id||!e.id.startsWith("draw:"))return null;const t=e.id.slice(5),o=t.indexOf("#");return o<0?t:t.slice(0,o)}(i),p=null===d?void 0:a.get(d);if(e.alerts&&"time-scale"!==i.kind){if(l(),p){const t=a.alertInfo(p.id);r.push({id:"alert-drawing",label:ee(e,"Create drawing alert..."),disabled:!t.available,note:t.reason,run:()=>{No(e,void 0,{source:{kind:"drawing",drawingId:p.id}})}})}else if("indicator"===i.kind&&i.instanceId){const o=n.indicators().find(e=>e.id===i.instanceId),a=o&&s(o.indicatorId).plots.find(e=>(e.overlay?0:o.paneIndex)===t.paneIndex&&(void 0===i.plotKey||e.key===i.plotKey));o&&a&&r.push({id:"alert-indicator",label:ee(e,"Create study alert..."),run:()=>{const i=o.values()[a.key],r=i?.[t.index??n.primaryBars().length-1];No(e,void 0,{source:{kind:"indicator",instanceId:o.id,plotKey:a.key,value:r??NaN}})}})}else 0===t.paneIndex&&null!==t.price&&Number.isFinite(t.price)&&r.push({id:"alert-create",label:ee(e,"Create alert at {price}...",{price:Uo(n,0,t.price)}),run:()=>{No(e,void 0,{source:{kind:"price",price:t.price}})}});r.push({id:"chart-alerts",label:ee(e,"Alerts..."),run:()=>{zo(e)}})}if(void 0!==p){a.selection().includes(p.id)||a.select(p.id);const t=a.selection().includes(p.id)?a.selection().slice():[p.id];l(),r.push(...function(e,t,o){const{draw:n}=e,a=F(t.tool),i=[],r=!0===t.locked,s=!1===t.visible,l=t.zIndex<0,c=o.length>1;return i.push({id:"draw-props",label:ee(e,c?"Properties of the selection...":"Properties..."),icon:"settings",run:()=>{_o(e,void 0,{ids:o})}}),!c&&bo(t)&&i.push({id:"draw-text",label:ee(e,"Edit text"),icon:"text",chord:"Enter",run:()=>{mo(e,0,{id:t.id})}}),a.fields.some(e=>"levels"===e.kind)&&i.push({id:"draw-levels",label:ee(e,"Edit levels..."),run:()=>{lo(e,void 0,{ids:o})}}),i.push(Ro),i.push({id:"draw-copy",label:c?ee(e,"Copy {count} drawings",{count:o.length}):ee(e,"Copy drawing"),icon:"copy",chord:"Ctrl+C",run:()=>{n.copy(o)}}),i.push({id:"draw-cut",label:c?ee(e,"Cut {count} drawings",{count:o.length}):ee(e,"Cut drawing"),chord:"Ctrl+X",disabled:r,note:r?ee(e,"locked"):void 0,run:()=>{n.cut(o)}}),i.push({id:"draw-duplicate",label:ee(e,"Duplicate"),icon:"duplicate",chord:"Ctrl+D",run:()=>{n.duplicate(o)}}),i.push(Ro),i.push({id:"draw-lock",label:ee(e,r?"Unlock":"Lock"),icon:r?"lock":"unlock",mark:"check",on:r,run:()=>{n.updateMany(o.map(e=>({id:e,patch:{locked:!r}})))}}),i.push({id:"draw-hide",label:ee(e,s?"Show":"Hide"),icon:s?"eye-off":"eye",mark:"check",on:s,run:()=>{n.updateMany(o.map(e=>({id:e,patch:{visible:s}})))}}),i.push(Ro),i.push(Fo(ee(e,"Order"))),i.push({id:"draw-front",label:ee(e,"Bring to front"),icon:"front",run:()=>{for(const e of o)n.bringToFront(e)}}),i.push({id:"draw-back",label:ee(e,"Send to back"),icon:"back",run:()=>{for(const e of o)n.sendToBack(e)}}),i.push({id:"draw-above",label:ee(e,"In front of the series"),icon:Wt("M3 4h10M8 14V6M5 9l3-3 3 3"),mark:"radio",on:!l,run:()=>{for(const e of o)n.bringAboveSeries(e)}}),i.push({id:"draw-behind",label:ee(e,"Behind the series"),icon:Wt("M3 12h10M8 2v8M5 7l3 3 3-3"),mark:"radio",on:l,run:()=>{for(const e of o)n.sendBehindSeries(e)}}),i.push(Ro),i.push({id:"draw-delete",label:c?ee(e,"Delete {count} drawings",{count:o.length}):ee(e,"Delete"),icon:"trash",chord:"Del",danger:!0,disabled:r,note:r?ee(e,"locked"):void 0,run:()=>{n.removeMany(o)}}),i}(e,p,t))}if("indicator"===i.kind&&void 0!==i.instanceId){const t=n.indicators().find(e=>e.id===i.instanceId);void 0!==t&&(l(),r.push({id:"ind-settings",label:ee(e,"{name} settings...",{name:t.name}),icon:"settings",run:()=>{So(e,void 0,{instanceId:t.id})}}),r.push({id:"ind-visible",label:t.visible()?ee(e,"Hide {name}",{name:t.name}):ee(e,"Show {name}",{name:t.name}),icon:t.visible()?"eye":"eye-off",run:()=>{t.setVisible(!t.visible())}}),r.push({id:"ind-remove",label:ee(e,"Remove {name}",{name:t.name}),icon:"trash",danger:!0,run:()=>{n.removeIndicator(t.id)}}))}if("time-scale"!==i.kind){l(),r.push({id:"draw-paste",label:ee(e,"Paste"),icon:"paste",chord:"Ctrl+V",run:()=>{a.paste().then(t=>{0===t.length&&e.toast(ee(e,"Nothing to paste"),"info")})}});const t=a.drawings().length;t>0&&r.push({id:"draw-clear",label:ee(e,"Remove all drawings ({count})",{count:t}),icon:"trash",danger:!0,run:()=>{a.clear()}})}l(),r.push({id:"chart-fit",label:ee(e,"Fit all bars"),icon:Wt("M2 8h12M4 5l-2 3 2 3M12 5l2 3-2 3"),run:()=>{n.fitContent()}}),"time-scale"!==i.kind&&r.push({id:"chart-indicators",label:ee(e,"Indicators..."),run:()=>{ko(e)}}),r.push({id:"chart-settings",label:ee(e,"Settings..."),icon:"settings",run:()=>{Lo(e)}});const u=o.items?.(t)??[];return u.length>0&&(l(),r.push(...u)),r}const Vo=new WeakMap;function Ko(e,t,o={}){const n=e.document;Vo.get(e.root)?.close();const a=o.event??{paneIndex:0,point:{x:0,y:0},price:null,time:null,index:null,target:{kind:"empty",id:null},preventDefault:()=>{}},i=o.hooks??{},r=qt(n,"div","oac-panel oac-ctx");r.setAttribute("role","menu"),r.setAttribute("aria-label",ee(e,"Chart menu")),r.tabIndex=-1,Jt(r);let s=[];const l=e=>{const t=s.filter(e=>"true"!==e.getAttribute("aria-disabled"));0!==t.length&&t[(e%t.length+t.length)%t.length].focus()};!function t(o=-1){r.innerHTML="",s=[];const l=Ho(e,a,i);for(const e of l){if("separator"===e.kind){r.appendChild(qt(n,"div","oac-ctx__hr"));continue}if("header"===e.kind){r.appendChild(qt(n,"div","oac-head",e.label));continue}const o=e,a=qt(n,"button","oac-ctx__row"+(!0===o.danger?" is-danger":""));a.type="button",a.setAttribute("role","check"===o.mark?"menuitemcheckbox":"radio"===o.mark?"menuitemradio":"menuitem"),void 0!==o.mark&&a.setAttribute("aria-checked",!0===o.on?"true":"false"),void 0!==o.id&&(a.dataset.act=o.id),a.tabIndex=-1;const i=qt(n,"span","oac-ctx__mark");if("radio"===o.mark&&!0===o.on)i.appendChild(qt(n,"span","oac-ctx__dot"));else if("check"===o.mark&&!0===o.on)i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5l3.5 3.5L13 4"/></svg>';else if(void 0!==o.icon)if(o.icon.startsWith("<svg")){const e=qt(n,"span","oac-glyph oac-glyph--chrome");e.innerHTML=o.icon,i.appendChild(e)}else i.appendChild(Gt(n,o.icon));a.appendChild(i),a.appendChild(qt(n,"span","oac-ctx__label",o.label)),void 0!==o.note&&""!==o.note&&a.appendChild(qt(n,"span","oac-ctx__note",o.note)),void 0!==o.chord&&a.appendChild(qt(n,"kbd","oac-ctx__key",o.chord)),!0===o.disabled?a.setAttribute("aria-disabled","true"):a.addEventListener("click",e=>{e.stopPropagation(),o.run?.(),!0===o.keepOpen?t(s.indexOf(a)):d.close()}),r.appendChild(a),s.push(a)}o>=0&&void 0!==s[o]&&s[o].focus()}(),r.addEventListener("keydown",e=>{const t=e.key,o=s.filter(e=>"true"!==e.getAttribute("aria-disabled")),a=o.indexOf(n.activeElement);"ArrowDown"===t?(e.preventDefault(),l(a+1)):"ArrowUp"===t?(e.preventDefault(),l(a<=0?o.length-1:a-1)):"Home"===t?(e.preventDefault(),l(0)):"End"===t&&(e.preventDefault(),l(o.length-1))});const c=s.find(e=>"true"!==e.getAttribute("aria-disabled"))??r,d=Qt(e,r,void 0!==t&&void 0===o.event?{anchor:t,placement:"below",initialFocus:c}:{placement:"below",modal:!1,dismissOnOutside:!0,initialFocus:c},()=>{});if(void 0===t||void 0!==o.event){const t=ho(e.chart),o=null===t?{left:0,top:0}:eo(e.root,t);no(e.root,r,{point:{x:a.point.x+o.left,y:a.point.y+o.top}})}return Vo.set(e.root,d),d}function qo(e,t={}){return e.chart.on("contextmenu",o=>{const n=o;n.preventDefault(),Ko(e,void 0,{event:n,hooks:t})})}const Wo={settings:Lo,indicatorPicker:ko,indicatorSettings:So,drawingProperties:_o,contextMenu:Ko,levelEditor:lo,textEditor:mo,alertEditor:No,alerts:zo};fe(Wo);const Go=e=>`var(--oac-${e})`,Zo=`\n.oac-widget .oac-alert-editor { width: 480px; }\n.oac-widget .oac-alerts { width: 560px; }\n.oac-widget .oac-alerts__row { padding: 10px 0; border-bottom: 1px solid ${Go("bd-soft")}; }\n.oac-widget .oac-alerts__summary { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.5; }\n.oac-widget .oac-alerts__status { color: ${Go("mut")}; font-size: 11px; line-height: 1.5; margin: 4px 0 8px; overflow-wrap: anywhere; }\n.oac-widget .oac-alerts__actions { display: flex; flex-wrap: wrap; gap: 6px; }\n.oac-widget .oac-alert-context { margin: 0 0 8px; color: ${Go("mut")}; overflow-wrap: anywhere; }\n.oac-widget .oac-alert-help { color: ${Go("mut")}; font-size: 11px; line-height: 1.5; margin: 10px 0 0; }\n.oac-widget .oac-alert-error { color: ${Go("danger")}; font-size: 12px; margin: 6px 0 0; overflow-wrap: anywhere; }\n.oac-widget .oac-alert-editor input[type=datetime-local] { width: 100%; min-width: 0; color-scheme: inherit;\n height: ${Go("ctl-h")}; padding: 0 8px; border: 1px solid ${Go("bd")}; border-radius: ${Go("radius")};\n background: ${Go("elev")}; color: ${Go("tx")}; font: inherit; }\n/* Panels: the card a dialog or a popover is built on. */\n.oac-widget .oac-panel { display: flex; flex-direction: column; min-width: 0; max-width: calc(100% - 24px);\n max-height: calc(100% - 24px); background: ${Go("panel")}; border: 1px solid ${Go("bd")}; border-radius: 12px;\n box-shadow: ${Go("shadow")}; outline: none; }\n.oac-widget .oac-dialog__lead, .oac-widget .oac-dialog__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }\n.oac-widget .oac-dialog__actions .oac-btn:not(.oac-btn--primary) { border-color: ${Go("bd-soft")}; }\n.oac-widget .oac-empty { padding: 10px 6px; color: ${Go("faint")}; }\n\n/* Generated forms: switch column, label, control column. */\n.oac-widget .oac-form { min-width: 0; display: grid; gap: 1px; align-content: start; }\n.oac-widget .oac-form > .oac-head { padding: 10px 0 3px; }\n.oac-widget .oac-form > .oac-head:first-child { padding-top: 2px; }\n.oac-widget .oac-form .oac-row { gap: 8px; min-height: 30px; padding: 1px 0; }\n.oac-widget .oac-row__sw { width: 15px; flex: none; }\n.oac-widget .oac-row__label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; color: ${Go("mut")}; cursor: pointer; }\n/* Every row's control occupies the same column, and the column is one width.\n It was not: a select filled it, a lone number sat at 72px against its right\n edge, and one row widened the column for itself. Reading down the form, the\n left edge of the controls stepped in and out by ninety pixels, which is the\n kind of wrongness a reader feels before they can name it. The column is wide\n enough for a date and time, which is the widest control any of these forms\n puts in it. */\n.oac-widget .oac-row__ctl { display: flex; align-items: center; justify-content: flex-end; gap: 6px; width: min(232px, 58%); min-width: 0; flex: none; }\n/* A number that is the only thing in its column fills it like every other\n control, keeping its digits right aligned. One paired with a slider keeps\n its own width, because there the narrow box is the point. */\n.oac-widget .oac-row__ctl input[type=number] { width: 72px; max-width: 100%; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; }\n.oac-widget .oac-row__ctl > input[type=number]:only-child { width: 100%; }\n.oac-widget .oac-row__ctl input[type=text] { width: 100%; min-width: 0; }\n.oac-widget .oac-row__ctl .oac-select, .oac-widget .oac-row__ctl select { width: 100%; min-width: 0; max-width: 100%; }\n.oac-widget .oac-opacity { min-width: 0; max-width: 100%; display: inline-flex; align-items: center; gap: 6px; }\n.oac-widget .oac-opacity input[type=range] { width: 110px; min-width: 0; }\n.oac-widget .oac-out { min-width: 36px; text-align: right; color: ${Go("mut")}; font-variant-numeric: tabular-nums; }\n.oac-widget .oac-row--block { flex-direction: column; align-items: stretch; gap: 4px; }\n.oac-widget .oac-row--block > .oac-row__ctl { width: 100%; }\n.oac-widget .oac-row--block > .oac-row__label { padding-top: 4px; }\n.oac-widget .oac-row--block textarea { width: 100%; min-height: 56px; resize: vertical; }\n.oac-widget .oac-row--off > .oac-row__label { color: ${Go("faint")}; cursor: not-allowed; }\n.oac-widget .oac-row input:disabled, .oac-widget .oac-row select:disabled { opacity: .45; pointer-events: none; }\n\n/* Tab lists: a rail down the left of a settings dialog, or a row above a form. */\n.oac-widget .oac-tabs { min-width: 0; display: flex; gap: 2px; }\n.oac-widget .oac-tabs--rail { flex-direction: column; min-width: 138px; padding: 2px 10px 2px 0; border-right: 1px solid ${Go("bd-soft")}; }\n.oac-widget .oac-tabs--row { overflow-x: auto; flex: none; padding: 0 0 6px; margin-bottom: 6px; border-bottom: 1px solid ${Go("bd-soft")}; }\n.oac-widget .oac-tab { flex: none; display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 10px; background: transparent;\n border: 1px solid transparent; border-radius: 7px; color: ${Go("mut")}; text-align: left; white-space: nowrap; }\n.oac-widget .oac-tab:hover { background: ${Go("elev")}; color: ${Go("tx")}; }\n.oac-widget .oac-tab[aria-selected="true"] { background: ${Go("on-bg")}; border-color: ${Go("on-bd")}; color: ${Go("acc-2")}; }\n.oac-widget .oac-tabs--row .oac-tab { height: 28px; border-radius: 6px; }\n\n/* Chart settings and indicator settings */\n.oac-widget .oac-settings { width: 600px; }\n.oac-widget .oac-settings__main { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 12px; min-height: 0; }\n.oac-widget .oac-settings__pane { min-width: 0; min-height: 0; padding: 2px 4px 4px 0; }\n.oac-widget .oac-indset { width: 440px; }\n.oac-widget .oac-indset__pane { min-width: 0; padding-right: 4px; }\n\n/* Indicator picker */\n.oac-widget .oac-pick { width: 380px; }\n.oac-widget .oac-pick__findwrap { padding: 2px 0 8px; }\n.oac-widget .oac-pick__find { width: 100%; }\n.oac-widget .oac-pick__list { min-height: 0; display: grid; gap: 1px; align-content: start; }\n.oac-widget .oac-pick__list > .oac-head { padding: 8px 8px 3px; }\n.oac-widget .oac-pick__row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; background: transparent;\n border: 0; border-radius: 6px; color: ${Go("tx")}; text-align: left; }\n.oac-widget .oac-pick__row:hover, .oac-widget .oac-pick__row.is-active { background: ${Go("elev-2")}; }\n.oac-widget .oac-pick__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.oac-widget .oac-pick__count { color: ${Go("acc-2")}; font-size: 11px; }\n\n/* Level editor */\n.oac-widget .oac-levels { width: 340px; min-width: 0; padding: 10px 12px 12px; gap: 6px; }\n.oac-widget .oac-levels__head { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }\n.oac-widget .oac-levels__title { flex: 1 1 auto; font-weight: 650; color: ${Go("tx-strong")}; }\n.oac-widget .oac-levels__labels { display: inline-flex; align-items: center; gap: 6px; color: ${Go("mut")}; cursor: pointer; }\n.oac-widget .oac-levels__rows { min-height: 0; overflow-y: auto; display: grid; gap: 3px; }\n.oac-widget .oac-levels__row { display: grid; grid-template-columns: 15px minmax(48px, 74px) 26px minmax(0, 1fr) 24px; align-items: center; gap: 6px; min-height: 28px; }\n.oac-widget .oac-levels__row input[type=number], .oac-widget .oac-levels__row input[type=text] { width: 100%; height: 26px; }\n.oac-widget .oac-levels__row.is-off input:not([type=checkbox]) { opacity: .45; }\n.oac-widget .oac-levels__x { width: 24px; height: 24px; display: grid; place-items: center; padding: 0; background: transparent;\n border: 0; border-radius: 5px; color: ${Go("faint")}; }\n.oac-widget .oac-levels__x:hover { background: ${Go("elev-2")}; color: ${Go("danger")}; }\n.oac-widget .oac-levels__foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }\n.oac-widget .oac-levels__foot .oac-spacer { flex: 1 1 auto; }\n\n/* Inline text editor, laid over the painted text. */\n.oac-widget .oac-textedit { position: absolute; z-index: 70; box-sizing: border-box; margin: 0; outline: none; padding: 4px;\n border: 1px solid ${Go("acc")}; border-radius: 4px; background: color-mix(in srgb, ${Go("bg")} 58%, transparent);\n box-shadow: 0 0 0 3px ${Go("ring-soft")}; caret-color: ${Go("acc-2")}; cursor: text; overflow: hidden; }\n\n/* Drawing properties */\n.oac-widget .oac-props { width: 340px; }\n.oac-widget .oac-props__tools { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 0 10px 6px; }\n.oac-widget .oac-props__tools .oac-sep { margin: 0 4px; }\n.oac-widget .oac-props__pane { min-width: 0; padding-right: 4px; }\n.oac-widget .oac-props__inline { display: inline-flex; align-items: center; gap: 6px; }\n\n/* Context menu */\n.oac-widget .oac-ctx { min-width: 220px; max-width: 320px; padding: 5px; }\n.oac-widget .oac-ctx > .oac-head { padding: 6px 10px 2px; }\n.oac-widget .oac-ctx__row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; background: transparent;\n border: 0; border-radius: 6px; color: ${Go("tx")}; text-align: left; white-space: nowrap; }\n.oac-widget .oac-ctx__row:hover, .oac-widget .oac-ctx__row:focus-visible { background: ${Go("elev-2")}; outline: none; }\n.oac-widget .oac-ctx__row[aria-disabled="true"] { color: ${Go("faint")}; cursor: default; background: transparent; }\n.oac-widget .oac-ctx__row.is-danger:not([aria-disabled="true"]):hover { color: ${Go("danger")}; }\n.oac-widget .oac-ctx__row[aria-checked="true"] { color: ${Go("acc-2")}; }\n.oac-widget .oac-ctx__mark { width: 16px; height: 16px; display: inline-grid; place-items: center; flex: none; color: ${Go("mut")}; }\n.oac-widget .oac-ctx__row[aria-checked="true"] .oac-ctx__mark { color: ${Go("acc-2")}; }\n.oac-widget .oac-ctx__mark > svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8;\n stroke-linecap: round; stroke-linejoin: round; }\n.oac-widget .oac-ctx__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }\n.oac-widget .oac-ctx__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.oac-widget .oac-ctx__note { color: ${Go("faint")}; font-size: 11px; }\n.oac-widget .oac-ctx__key { margin-left: 8px; color: ${Go("faint")}; }\n.oac-widget .oac-ctx__hr { height: 1px; background: ${Go("bd-soft")}; margin: 4px 6px; }\n\n@container oac-widget (max-width: 720px) {\n .oac-widget .oac-settings__main { grid-template-columns: 1fr; }\n .oac-widget .oac-tabs--rail { flex-direction: row; overflow-x: auto; min-width: 0; padding: 0 0 6px; border-right: 0;\n border-bottom: 1px solid ${Go("bd-soft")}; }\n .oac-widget .oac-dialog__foot { gap: 6px; }\n .oac-widget .oac-dialog__foot > .oac-spacer { display: none; }\n .oac-widget .oac-dialog__actions { margin-left: auto; }\n}\n`,Jo={source:"Source",indicator:"Indicator",drawing:"Drawing",profile:"Profile",group:"Group"},Yo=["visibility","lock","settings","focus","remove"],Xo={loading:"Loading",ready:"Ready",empty:"No data",unsupported:"Unsupported",error:"Could not load"},Qo={select:"Could not select {name}",visibility:"Could not change visibility for {name}",lock:"Could not change lock for {name}",settings:"Could not open settings for {name}",focus:"Could not focus {name}",remove:"Could not remove {name}"};let en=0;function tn(e,t={}){const o=t.objects??e.objects;if(void 0===o)throw new Error(ee(e,"Objects panel requires an object model"));const n=o,a=t=>ee(e,"Pane {number}",{number:t.paneIndex+1}),i=t=>ee(e,`schema.object.kind.${t.kind}`,{},Jo[t.kind]),r=e.document;let s=!1,l=[];const c=new Map,d=qt(r,"div","oac-objects-content"),p=e=>e.stopPropagation();d.addEventListener("pointerdown",p);const u=new Map;let h=null;const b=(t,o,n={})=>ee(e,`schema.ui.objects.${t}`,n,o),g=qt(r,"input","oac-objects__find");g.type="search",g.placeholder=ee(e,"Search name, type or pane"),g.setAttribute("aria-label",ee(e,"Search objects")),g.setAttribute("spellcheck","false");const m=qt(r,"div","oac-objects__list");m.setAttribute("role","list"),m.setAttribute("aria-label",ee(e,"Chart objects"));const f=qt(r,"div","oac-empty");f.setAttribute("role","status");const v=qt(r,"span","oac-objects__count");v.setAttribute("role","status"),d.append(g,m,f,v);const w=qt(r,"input","oac-objects__group-name");w.type="text",w.dataset.action="group-name",w.placeholder=b("groupName","Group name"),w.setAttribute("aria-label",b("groupName","Group name"));const y=Zt(r,{label:b("group","Group selected"),onClick:()=>{if(s)return;const e=l.filter(e=>"drawing"===e.kind&&e.selected).map(e=>e.id);n.createGroup(w.value,e)&&(w.value=""),$()}});if(y.dataset.action="group",n.canGroup?.()){const e=qt(r,"div","oac-objects__grouping");e.append(w,y),d.insertBefore(e,m)}const x=()=>{y.disabled=!w.value.trim()||!l.some(e=>"drawing"===e.kind&&e.selected)};function _(t,o){s||(n.move(t,o)||e.toast(b("moveFailed","Could not move object"),"error"),$())}function k(t,o,a){if(s)return;const i=n.get(o);let r=!1;try{if(i?.capabilities[t])switch(t){case"select":r=n.select(o,!0===a?.ctrlKey||!0===a?.metaKey);break;case"visibility":r=n.setVisible(o,!i.visible);break;case"lock":r=n.setLocked(o,!i.locked);break;case"settings":r=n.openSettings(o);break;case"focus":r=n.focus(o);break;case"remove":r=n.remove(o)}}catch{}r||e.toast(ee(e,Qo[t],{name:i?.name??ee(e,"object")}),"error")}function C(e){const t=qt(r,"div","oac-objects__row");t.dataset.objectId=e.id,t.setAttribute("role","listitem"),t.addEventListener("dragstart",t=>{!s&&n.get(e.id)?.capabilities.reorder?(t.stopPropagation(),h=e.id,t.dataTransfer?.setData("text/plain",e.id),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")):t.preventDefault()}),t.addEventListener("dragend",()=>{h=null}),t.addEventListener("dragover",e=>{null!==h&&e.preventDefault()}),t.addEventListener("drop",t=>{t.preventDefault(),t.stopPropagation(),function(e){if(s||null===h||h===e)return;const t=n.get(h),o=n.get(e);if(t&&o&&t.kind===o.kind&&(t.paneIndex===o.paneIndex||n.move(t.id,o.paneIndex)))for(let e=0;e<l.length;e++){const e=n.list().filter(e=>e.kind===t.kind&&e.paneIndex===n.get(t.id)?.paneIndex),a=e.findIndex(e=>e.id===t.id),i=e.findIndex(e=>e.id===o.id);if(a<0||i<0||a===i||!n.reorder(t.id,a<i?1:-1))break;if(1===Math.abs(a-i))break}}(e.id),h=null});const o=e.capabilities.select?Zt(r,{label:"",onClick:t=>k("select",e.id,t)}):qt(r,"div");o.classList.add("oac-objects__summary"),e.capabilities.select&&(o.dataset.action="select");const a=qt(r,"span","oac-objects__name"),i=qt(r,"span","oac-objects__meta"),c=qt(r,"span","oac-objects__status"),d="oac-object-"+ ++en;i.id=`${d}-meta`,c.id=`${d}-status`,e.capabilities.select&&o.setAttribute("aria-describedby",`${i.id} ${c.id}`),o.append(a,i,c);const p=qt(r,"div","oac-objects__actions");t.append(o,p);const u="group"===e.kind?qt(r,"div","oac-objects__members"):void 0;return u&&(u.setAttribute("role","list"),t.appendChild(u)),{el:t,summary:o,name:a,meta:i,status:c,actions:p,selectable:e.capabilities.select,buttons:new Map,members:u}}function $(){if(s)return;const t=g.value.trim().toLowerCase(),o=new Set(l.filter(e=>`${e.name} ${i(e)} ${a(e)}`.toLowerCase().includes(t)).map(e=>e.id));for(const e of l)e.groupId&&o.has(e.groupId)&&o.add(e.id);const d=l.filter(e=>o.has(e.id)||l.some(t=>t.groupId===e.id&&o.has(t.id))),p=new Set(d.map(e=>e.id)),w=r.activeElement,y=null!==w&&m.contains(w);for(const[e,t]of c)p.has(e)||(t.el.remove(),c.delete(e));const $=[...new Set(d.map(e=>e.paneIndex))].sort((e,t)=>e-t);for(const[e,t]of u)$.includes(e)||(t.element.remove(),u.delete(e));$.forEach((t,o)=>{let a=u.get(t);if(!a){const o=qt(r,"section","oac-objects__pane");o.dataset.paneIndex=String(t),o.setAttribute("aria-label",ee(e,"Pane {number}",{number:t+1}));const i=qt(r,"h3","oac-objects__pane-title");i.textContent=ee(e,"Pane {number}",{number:t+1});const s=qt(r,"div");o.append(i,s),o.addEventListener("dragover",e=>{null!==h&&n.get(h)?.capabilities.move&&e.preventDefault()}),o.addEventListener("drop",e=>{e.preventDefault(),null!==h&&n.get(h)?.capabilities.move&&_(h,t),h=null}),a={element:o,rows:s},u.set(t,a)}m.children[o]!==a.element&&m.insertBefore(a.element,m.children[o]??null)});const S=new Map;d.forEach(t=>{let o=c.get(t.id);void 0!==o&&o.selectable===t.capabilities.select||(o?.el.remove(),o=C(t),c.set(t.id,o)),function(t,o){t.name.textContent=o.name,t.el.draggable=!0===o.capabilities.reorder,t.el.dataset.groupId=o.groupId??"",t.el.classList.toggle("is-group-member",void 0!==o.groupId);const c=[i(o),a(o),o.visible?ee(e,"Visible"):ee(e,"Hidden")];if(void 0!==o.locked&&c.push(o.locked?ee(e,"Locked"):ee(e,"Unlocked")),o.selected&&c.push(ee(e,"Selected")),o.groupId){const e=l.find(e=>e.id===o.groupId);e&&c.push(e.name)}t.meta.textContent=c.join(", "),t.el.classList.toggle("is-selected",o.selected),t.selectable&&(t.summary.setAttribute("aria-label",ee(e,"Select {name}",{name:o.name})),t.summary.setAttribute("aria-pressed",String(o.selected))),t.status.textContent=void 0===o.dataStatus?"":ee(e,`schema.dataStatus.${o.dataStatus.state}`,{},Xo[o.dataStatus.state]),t.status.hidden=void 0===o.dataStatus,t.status.dataset.state=o.dataStatus?.state??"";let d=0;for(const n of Yo){let a=t.buttons.get(n);if(!o.capabilities[n]){a?.remove(),t.buttons.delete(n);continue}void 0===a&&(a=Zt(r,{label:"",variant:"remove"===n?"danger":"ghost",onClick:()=>k(n,o.id)}),a.dataset.action=n,t.buttons.set(n,a));const i="visibility"===n?o.visible?ee(e,"Hide"):ee(e,"Show"):"lock"===n?o.locked?ee(e,"Unlock"):ee(e,"Lock"):ee(e,"settings"===n?"Settings":"focus"===n?"Focus":"Remove");a.textContent=i,a.setAttribute("aria-label",ee(e,"visibility"===n?o.visible?"Hide {name}":"Show {name}":"lock"===n?o.locked?"Unlock {name}":"Lock {name}":"settings"===n?"Settings for {name}":"focus"===n?"Focus {name}":"Remove {name}",{name:o.name})),t.actions.children[d]!==a&&t.actions.insertBefore(a,t.actions.children[d]??null),d++}if("drawing"===o.kind&&o.id==="drawing:"+o.sourceId&&n.canGroup?.()){let e=t.buttons.get("add-selection");e||(e=Zt(r,{label:"",variant:"ghost",onClick:()=>{s||n.select(o.id,!0)}}),e.dataset.action="add-selection",t.buttons.set("add-selection",e)),e.textContent=b(o.selected?"deselect":"selectMore",o.selected?"Deselect":"Select"),e.setAttribute("aria-label",b(o.selected?"deselectLabel":"selectMoreLabel",o.selected?"Remove {name} from selection":"Add {name} to selection",{name:o.name})),e.setAttribute("aria-pressed",String(o.selected)),t.actions.children[d]!==e&&t.actions.insertBefore(e,t.actions.children[d]??null),d++}for(const[a,i]of[["earlier",-1],["later",1]]){let l=t.buttons.get(a);o.capabilities.reorder?(l||(l=Zt(r,{label:"",variant:"ghost",onClick:()=>{s||n.reorder(o.id,i)||e.toast(b("reorderFailed","Could not reorder object"),"error")}}),l.dataset.action=a,t.buttons.set(a,l)),l.textContent=b(a,-1===i?"Earlier":"Later"),l.setAttribute("aria-label",b(a+"Label",-1===i?"Move {name} earlier":"Move {name} later",{name:o.name})),l.disabled=!!n.canReorder&&!n.canReorder(o.id,i),t.actions.children[d]!==l&&t.actions.insertBefore(l,t.actions.children[d]??null),d++):(l?.remove(),t.buttons.delete(a))}if(o.capabilities.move){t.move||(t.move=qt(r,"select","oac-objects__move"),t.move.dataset.action="move",t.move.addEventListener("change",()=>_(o.id,Number(t.move.value)))),t.move.setAttribute("aria-label",b("movePane","Move {name} to pane",{name:o.name}));const a=n.paneCount();if(t.move.children.length!==a+1){t.move.replaceChildren();for(let o=0;o<=a;o++){const n=qt(r,"option");n.value=String(o),n.textContent=o===a?b("newPane","New pane"):ee(e,"Pane {number}",{number:o+1}),t.move.appendChild(n)}}t.move.value=String(o.paneIndex),t.actions.children[d]!==t.move&&t.actions.insertBefore(t.move,t.actions.children[d]??null),d++}else t.move?.remove(),t.move=void 0;t.actions.hidden=0===d}(o,t);const d=t.groupId?l.find(e=>e.id===t.groupId&&e.paneIndex===t.paneIndex):void 0,p=(d?c.get(d.id)?.members:void 0)??u.get(t.paneIndex).rows,h=S.get(p)??0;p.children[h]!==o.el&&p.insertBefore(o.el,p.children[h]??null),S.set(p,h+1)}),x(),f.hidden=d.length>0,f.textContent=0===l.length?ee(e,"No objects on this chart."):ee(e,"No objects match your search."),v.textContent=""===t?ee(e,"{count} objects",{count:l.length}):ee(e,"{shown} of {count} objects",{shown:d.length,count:l.length}),y&&(m.contains(w)?r.activeElement!==w&&w.focus():g.focus())}w.addEventListener("input",x),g.addEventListener("input",$);const S=n.subscribe(e=>{s||(l=e,$())});return{element:d,initialFocus:g,destroy:()=>{s||(s=!0,S(),d.removeEventListener("pointerdown",p),g.removeEventListener("input",$),w.removeEventListener("input",x),c.clear(),u.clear(),h=null,l=[],t.onClose?.())}}}function on(e,t,o={}){const n=tn(e,o),a=Xt(e.document,{translate:e.translate,title:ee(e,"Objects"),className:"oac-objects",onClose:()=>i.close()});a.closeButton.textContent=ee(e,"Close"),a.closeButton.classList.remove("oac-btn--icon"),a.body.appendChild(n.element),a.actions.appendChild(Zt(e.document,{label:ee(e,"Done"),variant:"primary",onClick:()=>i.close()}));const i=Qt(e,a.el,{...void 0===t?{placement:"center",modal:!0}:{anchor:t,placement:"below"},initialFocus:n.initialFocus,onClose:()=>n.destroy()},()=>{});return i}const nn='\n.oac-widget .oac-objects { width: 440px; min-width: 0; }\n.oac-widget .oac-objects .oac-dialog__body { display: flex; flex-direction: column; gap: 8px; overflow: hidden; }\n.oac-widget .oac-objects-content { display: flex; flex-direction: column; min-height: 0; gap: 8px; }\n.oac-widget .oac-objects__pane-title { margin: 6px 2px; color: var(--oac-mut); font-size: 11px; text-transform: uppercase; }\n.oac-widget .oac-objects__grouping { display: flex; gap: 4px; }\n.oac-widget .oac-objects__group-name { min-width: 0; width: 100%; }\n.oac-widget .oac-objects__move { min-width: 90px; max-width: 130px; height: 26px; font-size: 11px; }\n.oac-widget .oac-objects__row.is-group-member { margin-left: 10px; border: 0; border-left: 1px solid var(--oac-bd-soft); border-radius: 0; }\n.oac-widget .oac-objects__members { min-width: 0; }\n.oac-widget .oac-objects__list { scrollbar-width: thin; scrollbar-color: var(--oac-bd-soft) var(--oac-bg); }\n.oac-widget .oac-objects__list::-webkit-scrollbar { width: 6px; }\n.oac-widget .oac-objects__list::-webkit-scrollbar-track { background: var(--oac-bg); }\n.oac-widget .oac-objects__list::-webkit-scrollbar-thumb { background: var(--oac-bd-soft); border-radius: 3px; }\n.oac-widget .oac-objects__list::-webkit-scrollbar-thumb:hover { background: var(--oac-mut); }\n.oac-widget .oac-objects__find { width: 100%; min-width: 0; flex: none; }\n.oac-widget .oac-objects__list { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 2px; }\n.oac-widget .oac-objects__row { display: flex; flex-direction: column; gap: 4px; padding: 6px; margin-bottom: 4px;\n border: 1px solid var(--oac-bd-soft); border-radius: 6px; min-width: 0; }\n.oac-widget .oac-objects__row.is-selected { border-color: var(--oac-acc); background: var(--oac-elev); }\n.oac-widget .oac-objects__summary { display: flex; flex-direction: column; align-items: flex-start; justify-content: center;\n gap: 2px; width: 100%; min-width: 0; height: auto; padding: 3px 4px; text-align: left; white-space: normal; }\n.oac-widget .oac-objects__name { font-weight: 600; overflow-wrap: anywhere; }\n.oac-widget .oac-objects__meta, .oac-widget .oac-objects__status { font-size: 11px; color: var(--oac-mut); overflow-wrap: anywhere; }\n.oac-widget .oac-objects__status[data-state="error"] { color: var(--oac-danger); }\n.oac-widget .oac-objects__actions { display: flex; flex-wrap: wrap; gap: 3px; }\n.oac-widget .oac-objects__actions .oac-btn { height: 26px; padding: 0 6px; font-size: 11px; }\n.oac-widget .oac-objects__count { color: var(--oac-mut); font-size: 11px; }\n';function an(e,t){const o=e.document,n=t.mode??"auto",a=oe(o,"div","oac-mobile");e.root.appendChild(a);let i=!1,r=!1,s=!1,l=null,c=null,d=null;const p=[],u=e=>{e.stopPropagation()};a.addEventListener("pointerdown",u);const h=(e,t,n)=>{const a=oe(o,"button","oac-mobile__action",{type:"button"});return a.dataset.mobileAction=e,a.textContent=t,a.addEventListener("click",()=>{"true"!==a.getAttribute("aria-disabled")&&n(a)}),a},b=()=>{const e=d;d=null,e?.close()},g=()=>l?.close(),m=(t,n,a,r=void 0)=>{b();const s=oe(o,"section","oac-mobile-sheet",{"aria-label":t}),l=oe(o,"div","oac-mobile-sheet__head oac-dialog__head"),c=oe(o,"strong","oac-mobile-sheet__title");c.textContent=t;const p=h("close",ee(e,"Close"),()=>b());l.append(c,p);const u=oe(o,"div","oac-mobile-sheet__body");s.append(l,u);const g=()=>{if(i||d?.repaint!==g)return;const e=o.activeElement,t=null!==e&&u.contains(e),n=t?(e=>{const t=e.closest("[data-mobile-action]"),o=t?.dataset.mobileAction;return null===t||void 0===o?null:{action:o,...void 0===t.dataset.tool?{}:{tool:t.dataset.tool},...void 0===t.dataset.interval?{}:{interval:t.dataset.interval},...void 0===t.dataset.chartType?{}:{chartType:t.dataset.chartType}}})(e):null,r=u.scrollTop;if(u.textContent="",a(u,b),u.scrollTop=r,t){const e=null===n?null:((e,t)=>Array.from(e.querySelectorAll("[data-mobile-action]")).find(e=>e.dataset.mobileAction===t.action&&e.dataset.tool===t.tool&&e.dataset.interval===t.interval&&e.dataset.chartType===t.chartType)??null)(u,n);(e??u.querySelector("[data-mobile-action]"))?.focus()}};let m=()=>{};const f={close:()=>m(),repaint:g};d=f,a(u,b),m=e.openOverlay(s,{anchor:n,placement:"center",dismissOnOutside:!0,initialFocus:r,onClose:()=>{d===f&&(d=null)}})};let f=null;if(t.topbar){const n=oe(o,"div","oac-mobile__header",{role:"toolbar","aria-label":ee(e,"Chart header")});c=oe(o,"input","oac-mobile__symbol",{type:"text","aria-label":ee(e,"Symbol"),placeholder:ee(e,"Symbol"),autocomplete:"off",spellcheck:"false"}),f=h("interval","",o=>{m(ee(e,"Interval"),o,(e,o)=>{for(const n of t.intervals){const a=h("pick-interval",nt(n),()=>{t.onInterval(n),o()});a.dataset.interval=n;const i=t.state().interval===n;a.setAttribute("aria-pressed",String(i)),e.appendChild(a)}})});const i=(e,o)=>{const n=e.trim().toUpperCase();g(),""!==n&&t.onSymbol(n,o),S(),c?.blur()};void 0!==t.search&&(l=Xe(e,c,{search:t.search,onSelect:i,context:()=>`${t.state().exchange}:${t.state().symbol}:${t.state().interval}`,variant:"mobile"})),c.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),i(c?.value??""))}),n.append(c,f),a.appendChild(n)}const v=oe(o,"div","oac-mobile__footer"),w=oe(o,"div","oac-mobile__selection",{role:"toolbar","aria-label":ee(e,"Selected drawing")});let y=null,x=null,_=null;null!==t.rail&&(y=h("properties",ee(e,"Properties"),e=>{t.onProperties(e)}),x=h("lock",ee(e,"Lock"),()=>{const t=e.draw.selection(),o=!t.every(t=>!0===e.draw.get(t)?.locked);for(const n of t)e.draw.update(n,{locked:o});S()}),_=h("delete",ee(e,"Delete"),()=>{e.draw.removeMany(e.draw.selection()),S()}),w.append(y,x,_),v.appendChild(w));const k=oe(o,"nav","oac-mobile__bar",{"aria-label":ee(e,"Chart controls")});let C=null,$=null;function S(){if(i)return;const n=t.state();if(null!==c&&o.activeElement!==c&&(c.value=n.symbol),null!==f&&(f.textContent=nt(n.interval)),null!==C&&C.setAttribute("aria-pressed",String(null!==e.draw.activeTool())),null!==$&&$.setAttribute("aria-disabled",String(!t.indicatorsAvailable())),null!==w.parentNode){const t=e.draw.selection();if(w.hidden=0===t.length,t.length>0&&null!==x){const o=t.every(t=>!0===e.draw.get(t)?.locked);x.textContent=ee(e,o?"Unlock":"Lock"),x.setAttribute("aria-pressed",String(o))}null!==y&&y.setAttribute("aria-disabled",String(0===t.length)),null!==_&&_.setAttribute("aria-disabled",String(0===t.length))}d?.repaint()}null!==t.rail&&(C=h("draw",ee(e,"Draw"),n=>{m(ee(e,"Drawing"),n,n=>{const a=e.draw.activeTool();if(null!==a){const a=oe(o,"div","oac-mobile-sheet__controls");a.append(h("finish",ee(e,"Finish"),()=>{e.draw.finish(),S()}),h("cancel",ee(e,"Cancel"),()=>{e.draw.cancel(),S()}),h("undo",ee(e,"Undo"),()=>{e.draw.undo(),S()}),h("magnet",ee(e,"Magnet: {mode}",{mode:ee(e,`schema.magnet.${t.rail?.magnetMode()??"off"}`,{},t.rail?.magnetMode()??"off")}),()=>{t.rail?.cycleMagnet(),S()}),h("stay",ee(e,"Stay: {mode}",{mode:t.rail?.stayMode()?ee(e,"on"):ee(e,"off")}),()=>{null!==t.rail&&t.rail.setStayMode(!t.rail.stayMode()),S()})),n.appendChild(a)}const i=void 0===t.tools?null:new Set(t.tools);for(const t of Z()){if(null!==i&&!i.has(t.id))continue;const o=h("tool",ee(e,`schema.drawing.${t.id}.name`,{},t.name),()=>{e.draw.setTool(t.id),b()});o.classList.add("oac-mobile__tool"),o.dataset.tool=t.id,o.setAttribute("aria-pressed",String(a===t.id)),n.appendChild(o)}})}),k.appendChild(C)),t.topbar&&t.indicators&&($=h("studies",ee(e,"Studies"),e=>{t.onIndicators(e)}),k.appendChild($)),t.topbar&&(k.appendChild(h("objects",ee(e,"Objects"),e=>{t.onObjects(e)})),t.onDataWindow&&k.appendChild(h("data-window",ee(e,"schema.ui.dataWindow",{},"Data"),e=>{t.onDataWindow?.(e)})),k.appendChild(h("more",ee(e,"More"),n=>{m(ee(e,"More"),n,(a,i)=>{t.onAlerts&&a.appendChild(h("alerts",ee(e,"Alerts"),()=>{i(),t.onAlerts?.(n)}));const r=h("theme","dark"===t.state().theme?ee(e,"Light theme"):ee(e,"Dark theme"),()=>{t.onTheme(),i()});a.appendChild(r);const s=h("settings",ee(e,"Chart settings"),()=>{i(),t.onSettings(n)});s.setAttribute("aria-disabled",String(!t.settingsAvailable())),a.appendChild(s);const l=it(e.chart,e);if(null!==l){const e=oe(o,"a","oac-mobile__action oac-mobile__branding",{href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":l.label});e.dataset.mobileAction="branding",e.textContent=l.label,a.appendChild(e)}const c=oe(o,"div","oac-head");c.textContent=ee(e,"Chart type"),a.appendChild(c);for(const o of ot()){const n=h("chart-type",ee(e,`schema.chartType.${o}`,{},tt(o)),()=>{t.onChartType(o),i()});n.dataset.chartType=o,n.setAttribute("aria-pressed",String(t.state().chartType===o)),a.appendChild(n)}})}))),k.children.length>0&&v.appendChild(k),v.children.length>0&&a.appendChild(v);const A="auto"===n?o.defaultView?.matchMedia?.("(pointer: coarse)")??null:null,L=()=>{const o="always"===n||"auto"===n&&((t.container.getBoundingClientRect().width||t.container.clientWidth)<=640||!0===A?.matches);s&&o===r||(s=!0,r=o,e.root.classList.toggle("is-mobile",r),e.root.dataset.mobile=String(r),a.hidden=!r,r||(b(),g()))},E=o.defaultView?.ResizeObserver;let O=null;if("auto"===n&&void 0!==E)O=new E(L),O.observe(t.container);else if("auto"===n){const e=o.defaultView;null!==e&&"function"==typeof e.addEventListener&&(e.addEventListener("resize",L),p.push(()=>e.removeEventListener("resize",L)))}null!==A&&("function"==typeof A.addEventListener?(A.addEventListener("change",L),p.push(()=>A.removeEventListener("change",L))):(A.addListener(L),p.push(()=>A.removeListener(L))));for(const t of["draw:tool","draw:select","drawing:select","drawing:change","draw:add","draw:remove","draw:update"])p.push(e.chart.on(t,S));return p.push(e.bus.on("symbol",S)),p.push(e.bus.on("interval",S)),p.push(e.bus.on("theme",S)),p.push(e.chart.on("branding:changed",S)),L(),S(),{el:a,active:()=>r,refresh:S,destroy:()=>{if(!i){i=!0,l?.destroy(),b(),O?.disconnect(),O=null;for(const e of p.splice(0))e();a.removeEventListener("pointerdown",u),a.remove(),e.root.classList.remove("is-mobile"),delete e.root.dataset.mobile}}}}const rn='\n.oac-event-layer{position:absolute;inset:0;pointer-events:none;z-index:50}\n.oac-event-details{position:absolute;pointer-events:auto;box-sizing:border-box;width:340px;max-width:calc(100% - 16px);max-height:calc(100% - 16px);overflow:auto;background:var(--oac-panel,#171b23);color:var(--oac-tx,#d9dfe8);border:1px solid var(--oac-bd,#343b48);border-radius:8px;box-shadow:var(--oac-shadow,0 12px 32px #0005);font:12px/1.5 var(--oac-font,system-ui,sans-serif);scrollbar-width:thin;scrollbar-color:var(--oac-sb-thumb,#414958) var(--oac-panel,#171b23)}\n.oac-event-details::-webkit-scrollbar{width:6px;height:6px}\n.oac-event-details::-webkit-scrollbar-track{background:var(--oac-panel,#171b23)}\n.oac-event-details::-webkit-scrollbar-thumb{background:var(--oac-sb-thumb,#414958);border-radius:3px}\n.oac-event-details::-webkit-scrollbar-thumb:hover{background:var(--oac-sb-thumb-hover,#586276)}\n.oac-event-details__header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;border-bottom:1px solid var(--oac-bd,#343b48)}\n.oac-event-details__heading{margin:0;font:600 12px/1.5 var(--oac-font,system-ui,sans-serif)}\n.oac-event-details button{font:inherit;cursor:pointer;border:1px solid var(--oac-bd,#343b48);border-radius:4px;padding:4px 8px;background:var(--oac-elev,#252c37);color:inherit;text-align:left}\n.oac-event-details button:hover{background:var(--oac-elev-2,#333d4b)}\n.oac-event-details button:focus-visible{outline:2px solid var(--oac-ring,#74a7fa);outline-offset:2px}\n.oac-event-details__members{display:flex;flex-wrap:wrap;gap:6px;padding:10px 12px 0}\n.oac-event-details__members button{max-width:100%;overflow-wrap:anywhere}\n.oac-event-details__members button[aria-pressed="true"]{border-color:var(--oac-acc,#74a7fa);background:var(--oac-on-bg,#274263)}\n.oac-event-details__content{padding:12px;overflow-wrap:anywhere}\n.oac-event-details__title{margin:0 0 4px;font-size:14px;font-weight:600}\n.oac-event-details__time,.oac-event-details__status{color:var(--oac-mut,#a0aabc)}\n.oac-event-details__summary{white-space:pre-wrap;margin:10px 0 0}\n.oac-event-details__fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:5px 12px;margin:10px 0 0}\n.oac-event-details__fields dt{color:var(--oac-mut,#a0aabc)}\n.oac-event-details__fields dd{margin:0;text-align:right;white-space:pre-wrap}\n.oac-event-details__status{padding:0 12px 10px}\n.oac-event-details__status:empty{display:none}\n',sn={title:"Event details",close:"Close",events:"Events",loading:"Loading details...",empty:"No additional details.",error:"Unable to load additional details."};function ln(e){return{...e,..."object"==typeof e.details&&null!==e.details?{details:{...e.details,...e.details.fields?{fields:e.details.fields.map(e=>({...e}))}:{}}}:{}}}class cn{constructor(e,t={}){Object.defineProperty(this,"_container",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_doc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_overlays",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ownOverlays",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_labels",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_formatTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_close",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_abort",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_revision",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_disposed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_events",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_members",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_anchor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._doc=e.ownerDocument,this._labels={...sn,...t.labels};const o=new Intl.DateTimeFormat(void 0,{timeZone:"Asia/Kolkata",dateStyle:"medium",timeStyle:"short"});if(this._formatTime=t.formatTime??(e=>{const t=new Date(1e3*e);return Number.isFinite(t.getTime())?o.format(t):String(e)}),this._ownOverlays=void 0===t.overlays,this._overlays=t.overlays??xe(e,this._doc),this._ownOverlays&&this._overlays.layer.classList.add("oac-event-layer"),!1!==t.injectStyles&&null===this._doc.getElementById("oac-event-details-style")){const e=oe(this._doc,"style",void 0,{id:"oac-event-details-style"});void 0!==t.styleNonce&&e.setAttribute("nonce",t.styleNonce),e.textContent=rn,this._doc.head.appendChild(e)}this.element=oe(this._doc,"section","oac-event-details",{role:"dialog","aria-label":this._labels.title});for(const e of["pointerdown","pointerup","click","dblclick","wheel","keydown"])this.element.addEventListener(e,e=>e.stopPropagation());this._content=oe(this._doc,"div","oac-event-details__content"),this._status=oe(this._doc,"div","oac-event-details__status",{role:"status","aria-live":"polite"})}open(e,t){if(this._disposed)return;if(this.close(),0===e.events.length)return;this._events=e.events.map(ln),this._anchor=void 0===t?void 0:{...t};const o=oe(this._doc,"header","oac-event-details__header"),n=oe(this._doc,"h2","oac-event-details__heading");n.textContent=this._labels.title;const a=oe(this._doc,"button",void 0,{type:"button","data-action":"close-event-details"});if(a.textContent=this._labels.close,a.addEventListener("click",()=>this.close()),o.append(n,a),this.element.replaceChildren(o),this._members=[],this._events.length>1){const e=oe(this._doc,"div","oac-event-details__members",{role:"group","aria-label":this._labels.events});this._members=this._events.map((t,o)=>{const n=oe(this._doc,"button",void 0,{type:"button","data-event-index":String(o)});return n.textContent=t.title??t.label,n.addEventListener("click",()=>this._select(o)),e.appendChild(n),n}),this.element.appendChild(e)}this.element.append(this._content,this._status),this._close=this._overlays.open(this.element,{placement:"below",modal:!1,initialFocus:a,onClose:()=>{this._close=null,this._cancel()}}),this._select(0),this._position()}close(){this._cancel(),this._close?.(),this._close=null}destroy(){this._disposed||(this._disposed=!0,this.close(),this._events=[],this._members=[],this._ownOverlays&&this._overlays.destroy())}_cancel(){this._revision++,this._abort?.abort(),this._abort=null}_select(e){this._cancel();const t=this._events[e];this._members.forEach((t,o)=>t.setAttribute("aria-pressed",String(o===e))),this._render(t,t.details),this._status.textContent="",this.element.removeAttribute("aria-busy");const o=this._options.loadDetails;if(void 0===o)return;const n=this._revision,a=new AbortController;this._abort=a,this._status.textContent=this._labels.loading,this.element.setAttribute("aria-busy","true");const i=()=>!this._disposed&&null!==this._close&&n===this._revision&&!a.signal.aborted,r=()=>{i()&&(this.element.removeAttribute("aria-busy"),this._status.textContent=this._labels.error,this._position())};try{Promise.resolve(o(ln(t),{signal:a.signal})).then(e=>{i()&&(this._status.textContent="",this.element.removeAttribute("aria-busy"),this._render(t,e??t.details))},r)}catch{r()}}_render(e,t){const o=oe(this._doc,"h3","oac-event-details__title");o.textContent=e.title??e.label;const n=oe(this._doc,"div","oac-event-details__time");n.textContent=this._formatTime(e.time),this._content.replaceChildren(o,n);const a="string"==typeof t?t:t?.summary;if(a){const e=oe(this._doc,"p","oac-event-details__summary");e.textContent=a,this._content.appendChild(e)}const i="object"==typeof t?t.fields:void 0;if(i?.length){const e=oe(this._doc,"dl","oac-event-details__fields");for(const t of i){const o=oe(this._doc,"dt"),n=oe(this._doc,"dd");o.textContent=t.label,n.textContent=t.value,e.append(o,n)}this._content.appendChild(e)}if(!a&&!i?.length){const e=oe(this._doc,"p","oac-event-details__summary");e.textContent=this._labels.empty,this._content.appendChild(e)}this._position()}_position(){const e=this._container.getBoundingClientRect(),t=this._overlays.layer.getBoundingClientRect(),o=this._ownOverlays?0:e.left-t.left,n=this._ownOverlays?0:e.top-t.top;this.element.style.maxWidth=`${Math.max(0,e.width-16)}px`,this.element.style.maxHeight=`${Math.max(0,e.height-16)}px`;const a=this.element.offsetWidth,i=this.element.offsetHeight,r=this._anchor?.x,s=this._anchor?.y;this.element.style.left=`${o+Math.max(0,Math.min(Number.isFinite(r)?r:e.width-a-8,e.width-a-8))}px`,this.element.style.top=`${n+Math.max(0,Math.min(Number.isFinite(s)?s-i-12:8,e.height-i-8))}px`}}function dn(e,t,o={}){const n=e.primarySeries()?.getData()??[];return pn(e,n,t,o,n.some(e=>Number.isFinite(e.oi)))}function pn(t,o,n,a,i){const r=(e,t)=>ee(a,`schema.ui.data.${e}`,{},t),l=r("unavailable","Unavailable");let c=o.length-1;if(void 0!==n){let e=0,t=o.length;for(;e<t;){const a=e+t>>>1;o[a].time<n?e=a+1:t=a}c=o[e]?.time===n?e:-1}const d=o[c],p=void 0===n?d?.time??null:Number.isFinite(n)?n:null;let u;try{u=new Intl.NumberFormat(a.locale,{maximumFractionDigits:8})}catch{u=new Intl.NumberFormat("en-US",{maximumFractionDigits:8})}const h=(e,o,n=!1)=>{try{if("custom"===o?.type)return String(o.formatter(e));if("percent"===o?.type)return`${e.toFixed(o.precision??2)}%`;if("price"===o?.type)return e.toFixed(o.precision??2);if(n)return t.primarySeries()?.priceScale().format(e)??e.toFixed(2)}catch{}return u.format(e)},b=(e,t,o,n=!1,a)=>{const i="number"==typeof o&&Number.isFinite(o)?o:null;return{key:e,label:t,raw:i,value:null===i?l:h(i,a,n)}},g=["open","high","low","close"].map(e=>b(e,r(e,e[0].toUpperCase()+e.slice(1)),d?.[e],!0));g.push(b("volume",r("volume","Volume"),d?.volume));!1!==t.hasOpenInterest&&(!0===t.hasOpenInterest||i)&&g.push(b("oi",r("oi","Open interest"),d?.oi));const m=[{id:"price",title:r("price","Price"),rows:g}];for(const e of t.indicators()){const t=s(e.indicatorId),o=e.values(),n=(t?.plots??[]).map(t=>b(`${e.id}:${t.key}`,t.title,c<0?null:o[t.ohlc?.close??t.key]?.[c-(t.offset??0)],!1,t.priceFormat));n.length>0&&m.push({id:e.id,title:e.name,rows:n})}const f=t.getDataContext();let v=l;if(null!==p)try{v=`${e(p,t.timezone())} (${t.timezone()})`}catch{}return{symbol:f?.symbol??"",exchange:f?.exchange??"",time:p,timestamp:v,sections:m}}function un(e,t){const o=e.document;t.classList.add("oac-data-window"),t.setAttribute("aria-label",ee(e,"schema.ui.data.title",{},"Data window"));const n=qt(o,"div","oac-data-window__instrument"),a=qt(o,"div","oac-data-window__time"),i=qt(o,"div","oac-data-window__sections");let r;t.append(n,a,i);let s=!1,l=!1,c=!1,d=!0,p=!1,u=[];const h=new Map,b=(e,t)=>{e.textContent!==t&&(e.textContent=t)},g=()=>{if(l)return;d&&(u=e.chart.primarySeries()?.getData()??[],p=u.some(e=>Number.isFinite(e.oi)),d=!1);const t=pn(e.chart,u,c?NaN:r,e,p);b(n,[t.exchange,t.symbol].filter(Boolean).join(":")),b(a,t.timestamp);const s=new Set(t.sections.map(e=>e.id));for(const[e,t]of h)s.has(e)||(t.el.remove(),h.delete(e));for(const[e,n]of t.sections.entries()){let t=h.get(n.id);if(!t){const e=qt(o,"section","oac-data-window__section"),a=qt(o,"h3","oac-data-window__title");e.appendChild(a),i.appendChild(e),t={el:e,title:a,rows:new Map},h.set(n.id,t)}i.children[e]!==t.el&&i.insertBefore(t.el,i.children[e]??null),b(t.title,n.title);const a=new Set(n.rows.map(e=>e.key));for(const[e,o]of t.rows)a.has(e)||(o.el.remove(),t.rows.delete(e));for(const e of n.rows){let n=t.rows.get(e.key);if(!n){const a=qt(o,"div","oac-data-window__row");a.dataset.key=e.key;const i=qt(o,"span","oac-data-window__label"),r=qt(o,"span","oac-data-window__value");a.append(i,r),t.el.appendChild(a),n={el:a,label:i,value:r},t.rows.set(e.key,n)}b(n.label,e.label),b(n.value,e.value),n.value.classList.toggle("is-unavailable",null===e.raw)}}},m=()=>{s||l||(s=!0,Promise.resolve().then(()=>{s=!1,g()}))},f=[e.chart.on("crosshair:readout",e=>{const t=e;r=null===t.index&&null===t.point?void 0:t.time??NaN,m()}),e.chart.on("data:context",()=>{r=void 0,c=!0,d=!0,m()}),e.chart.on("data:range",()=>{c=!1,d=!0,m()}),...["objects:change","indicatorSettings","indicatorRemoved","indicator:data-status","paneMoved","resize","timezone:changed"].map(t=>e.chart.on(t,m))],v=()=>{if(!l){l=!0;for(const e of f)e();h.clear(),t.textContent="",t.classList.remove("oac-data-window"),t.removeAttribute("aria-label")}};return f.push(e.chart.on("destroy",v)),g(),{el:t,refresh:m,destroy:v}}const hn="\n.oac-widget .oac-data-window { padding: 12px; font-size: 12px; user-select: text; -webkit-user-select: text; }\n.oac-widget .oac-data-window__instrument { font-weight: 600; color: var(--oac-tx); overflow-wrap: anywhere; }\n.oac-widget .oac-data-window__time { font-size: 11px; color: var(--oac-mut); margin: 4px 0 14px; line-height: 1.5; }\n.oac-widget .oac-data-window__section + .oac-data-window__section { margin-top: 16px; }\n.oac-widget .oac-data-window__title { margin: 0 0 6px; padding: 0; font: 600 11px/1.4 var(--oac-font); color: var(--oac-mut); text-transform: uppercase; letter-spacing: .04em; }\n.oac-widget .oac-data-window__row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; min-height: 26px; padding: 4px 0; }\n.oac-widget .oac-data-window__label { min-width: 0; overflow-wrap: anywhere; }\n.oac-widget .oac-data-window__value { font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }\n.oac-widget .oac-data-window__value.is-unavailable { font-size: 11px; color: var(--oac-mut); }\n",bn=240;function gn(e){const t="object"==typeof e&&null!==e?e:{};return{panel:"data"===t.panel||"objects"===t.panel?t.panel:null,width:"number"==typeof t.width&&Number.isFinite(t.width)?Math.round(Math.max(bn,Math.min(480,t.width))):300}}function mn(e,t,o){const n=e.document,a=(t,o)=>ee(e,`schema.ui.dock.${t}`,{},o),i=qt(n,"aside","oac-panel-dock");i.hidden=!0,i.setAttribute("aria-label",a("title","Chart information"));const r=qt(n,"div","oac-panel-dock__resize");r.setAttribute("role","separator"),r.setAttribute("aria-orientation","vertical"),r.setAttribute("aria-label",a("resize","Resize information panel")),r.tabIndex=0;const s=qt(n,"div","oac-panel-dock__header"),l=qt(n,"div","oac-panel-dock__tabs");l.setAttribute("role","group"),l.setAttribute("aria-label",a("panels","Information panels"));const c=Zt(n,{label:a("data","Data"),onClick:()=>L("data")}),d=Zt(n,{label:a("objects","Objects"),onClick:()=>L("objects")}),p=Zt(n,{label:a("close","Close"),onClick:()=>A()});p.classList.add("oac-panel-dock__close"),l.append(c,d),s.append(l,p);const u=qt(n,"div","oac-panel-dock__body");i.append(r,s,u),t.appendChild(i);const h=gn(o.state);let b=null,g=null,m=!1,f=!1,v=null,w=null;const y=()=>e.root.getBoundingClientRect().width||e.root.clientWidth||1e3,x=()=>y()<=640,_=()=>Math.max(bn,Math.min(480,y()-320)),k=()=>{o.onChange?.({...h})},C=e=>{h.width=Math.round(Math.max(bn,Math.min(_(),e))),i.style.width=`${h.width}px`,r.setAttribute("aria-valuemin",String(bn)),r.setAttribute("aria-valuemax",String(_())),r.setAttribute("aria-valuenow",String(h.width))},$=()=>{if(!g)return;f=!0;const e=g;g=null,e(),f=!1},S=(o=!1)=>{if(m||null===h.panel)return;const a=null!==n.activeElement&&i.contains(n.activeElement)?n.activeElement:null,s=x();s!==("true"===i.dataset.sheet)&&$(),i.dataset.sheet=String(s),r.hidden=s,s&&!g?g=e.openOverlay(i,{placement:"center",modal:!0,initialFocus:a??b?.initialFocus??p,restoreFocus:!1,onClose:()=>{g=null,f||A()}}):s||(i.parentElement!==t&&t.appendChild(i),i.classList.remove("oac-dialog"),i.removeAttribute("aria-modal"),i.removeAttribute("role"),i.style.position="",i.style.left="",i.style.top="",i.style.transform="",C(h.width),o?(b?.initialFocus??p).focus():a?.focus())};function A(){if(null===h.panel)return;h.panel=null,w=null,$(),b?.destroy(),b=null,u.textContent="",i.hidden=!0,t.appendChild(i),c.setAttribute("aria-pressed","false"),d.setAttribute("aria-pressed","false");const e=n.activeElement;v?.isConnected&&(null===e||e===n.body||i.contains(e))&&v.focus(),v=null,k()}function L(e,t=!0){m||"data"!==e&&"objects"!==e||(h.panel!==e||null===b?(null!==h.panel&&null!==b||(v=n.activeElement),b?.destroy(),u.textContent="",h.panel=e,i.hidden=!1,c.setAttribute("aria-pressed",String("data"===e)),d.setAttribute("aria-pressed",String("objects"===e)),b=o[e](u),S(t),k()):t&&(b.initialFocus??p).focus())}const E=t=>{"Escape"===t.key&&0===e.overlays.size()&&(t.preventDefault(),t.stopPropagation(),A()),t.target===r&&["ArrowLeft","ArrowRight","Home","End"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),C("Home"===t.key?bn:"End"===t.key?_():h.width+("ArrowLeft"===t.key?10:-10)*(t.shiftKey?5:1)),k())},O=e=>{0!==e.button||x()||(e.preventDefault(),e.stopPropagation(),w={x:e.clientX,width:h.width,pointer:e.pointerId},r.setPointerCapture?.(e.pointerId),r.focus())},T=e=>{w&&w.pointer===e.pointerId&&(e.preventDefault(),C(w.width+w.x-e.clientX))},M=e=>{if(w&&w.pointer===e.pointerId){w=null,k();try{r.releasePointerCapture?.(e.pointerId)}catch{}}};i.addEventListener("keydown",E),r.addEventListener("pointerdown",O),r.addEventListener("pointermove",T),r.addEventListener("pointerup",M),r.addEventListener("pointercancel",M);const j=n.defaultView,I=()=>{x()||C(h.width),S()};j?.addEventListener?.("resize",I);const P=j?.ResizeObserver,D=P?new P(I):null;D?.observe(e.root),C(h.width);const N=h.panel;return h.panel=null,null!==N&&L(N,!1),{el:i,open:L,close:A,toggle:e=>{h.panel===e?A():L(e)},state:()=>({...h}),restore:e=>{const t=gn(e);C(t.width),null===t.panel?A():L(t.panel,!1)},destroy:()=>{m||(A(),m=!0,D?.disconnect(),j?.removeEventListener?.("resize",I),i.removeEventListener("keydown",E),r.removeEventListener("pointerdown",O),r.removeEventListener("pointermove",T),r.removeEventListener("pointerup",M),r.removeEventListener("pointercancel",M),i.remove())}}}const fn='\n.oac-widget .oac-panel-dock { position: relative; flex: none; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--oac-panel); border-left: 1px solid var(--oac-bd); }\n.oac-widget .oac-panel-dock__header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-bottom: 1px solid var(--oac-bd-soft); flex: none; }\n.oac-widget .oac-panel-dock__tabs { display: flex; gap: 3px; }\n.oac-widget .oac-panel-dock__tabs .oac-btn { border-color: transparent; background: transparent; }\n.oac-widget .oac-panel-dock__tabs .oac-btn[aria-pressed="true"] { background: var(--oac-elev); color: var(--oac-tx); border-color: var(--oac-bd); }\n.oac-widget .oac-panel-dock__close { color: var(--oac-mut); }\n.oac-widget .oac-panel-dock__body { overflow: auto; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; }\n.oac-widget .oac-panel-dock__resize { position: absolute; z-index: 2; top: 0; bottom: 0; left: -4px; width: 8px; cursor: col-resize; touch-action: none; }\n.oac-widget .oac-panel-dock__resize:hover, .oac-widget .oac-panel-dock__resize:focus-visible { background: var(--oac-ring-soft); }\n.oac-widget .oac-panel-dock[data-sheet="true"] { position: absolute !important; inset: 0 !important; width: 100% !important; max-width: none !important; height: 100%; max-height: none; transform: none !important; border: 0; border-radius: 0; }\n.oac-widget .oac-panel-dock[data-sheet="true"] .oac-panel-dock__header { padding: 12px; }\n.oac-widget .oac-panel-dock[data-sheet="true"] .oac-btn { min-height: 40px; }\n.oac-widget .oac-panel-dock__body > .oac-objects { width: auto; max-width: none; border: 0; box-shadow: none; }\n';function vn(e,t){const o=e.document;let n=!1,a=null,i=null,r=null,s=null;const l=()=>{const e=a;a=null,s?.destroy(),s=null,i=null,r=null,e?.()},c=c=>{if(n||c.defaultPrevented||c.isComposing||c.ctrlKey||c.metaKey||c.altKey||c.repeat)return;if(!/^[a-zA-Z0-9]$/.test(c.key))return;const d=c.target,p=o.activeElement;if(null===d||!e.root.contains(d)||null===p||!e.root.contains(p)||function(e){for(let t=e;null!==t;t=t.parentElement)if(t.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(t.tagName))return!0;return!1}(d))return;if(e.overlays.size()>0||null!==e.draw.activeTool()||!t.enabled())return;const u=Ee(c);e.keymap.list().some(t=>t.combo===u&&e.keymap.activeScopes().includes(t.scope))||e.chart.shortcuts?.list().some(e=>!e.isDisabled&&e.combos.some(e=>je(e)===u))||(c.preventDefault(),c.stopPropagation(),((n,c)=>{l(),i=oe(o,"section","oac-quick-entry",{role:"dialog","aria-label":ee(e,"symbol"===n?"schema.ui.enterSymbol":"schema.ui.enterInterval",{},"symbol"===n?"Enter symbol":"Enter interval")}),r=oe(o,"input","oac-quick-entry__input",{type:"text",autocomplete:"off",spellcheck:"false","aria-label":ee(e,"symbol"===n?"schema.ui.symbol":"schema.ui.interval",{},"symbol"===n?"Symbol":"Interval")}),r.value=c;const d=oe(o,"div","oac-quick-entry__message",{role:"alert"});i.append(r,d);const p=r;p.addEventListener("input",()=>{d.textContent=""});const u=i;a=e.openOverlay(i,{placement:"center",initialFocus:p,onClose:()=>{i===u&&l()}}),"symbol"===n&&t.search&&(s=Xe(e,p,{search:t.search,onSelect:(e,o)=>{l(),t.onSymbol(e,o)},context:()=>`${e.symbol().exchange}:${e.symbol().symbol}:${e.interval()}`}),s.open(c)),p.addEventListener("keydown",o=>{if("Enter"!==o.key||o.isComposing)return;o.preventDefault(),o.stopPropagation();const a=p.value.trim();if("symbol"===n){if(null!==s&&!s.canCommitRaw())return;if(""===a)return void(d.textContent=ee(e,"schema.ui.symbolRequired",{},"Enter a symbol"));l(),t.onSymbol(a.toUpperCase())}else{const o=_(a)??(/^[0-9]+$/.test(a)?_(`${a}m`):null);if(null===o)return void(d.textContent=ee(e,"schema.ui.invalidInterval",{},"Enter a recognized interval"));l(),t.onInterval(o.code)}})})(/[0-9]/.test(c.key)?"interval":"symbol",c.key))};o.addEventListener("keydown",c,!0);const d=e.bus.on("symbol",l),p=e.bus.on("interval",l);return{close:l,destroy:()=>{n||(n=!0,l(),d(),p(),o.removeEventListener("keydown",c,!0))}}}const wn="\n.oac-widget .oac-quick-entry{width:min(330px,calc(100vw - 32px));padding:12px}\n.oac-widget .oac-quick-entry__input{width:100%;box-sizing:border-box;background:var(--oac-panel);color:var(--oac-tx);border:1px solid var(--oac-bd);border-radius:4px;padding:9px;font:inherit}\n.oac-widget .oac-quick-entry__message{min-height:20px;padding-top:5px;color:var(--oac-danger)}\n",yn=Zo+nn+rn+hn+fn+Qe+wn+Rt+"\n.oac-widget .oac-pick__running-head { margin-top: 10px; border-top: 1px solid var(--oac-bd); padding-top: 9px; }\n.oac-widget .oac-pick__running { display: grid; gap: 1px; max-height: 132px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--oac-sb-thumb) transparent; }\n.oac-widget .oac-pick__running::-webkit-scrollbar { width: 6px; }\n.oac-widget .oac-pick__running::-webkit-scrollbar-thumb { background: var(--oac-sb-thumb); border-radius: 3px; }\n.oac-widget .oac-pick__running-row { display: flex; align-items: center; gap: 7px; min-height: 29px; padding: 2px 6px; }\n.oac-widget .oac-pick__running-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.oac-widget .oac-pick__running-number { min-width: 16px; color: var(--oac-mut); font-size: 11px; text-align: right; }\n.oac-widget .oac-pick__running-row .oac-pick__remove { height: 23px; min-height: 23px; padding: 2px 6px; }\n",xn=["1m","5m","15m","1h","1d","1w"],_n=500,kn=250,Cn="state",$n=1,Sn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),An=["feed","symbol","exchange","interval","intervals","chartType","theme","rail","topbar","statusline","mobile","loading","persist","storage","locale","translate","indicators","symbolSearch","lookbackBars","now","onOrder","styleNonce","tradingCapabilities","tradingMode","tradingLocked","eventDetails","panels","typingNavigation"];function Ln(e){const t={...e};return delete t.viewport,delete t.barSpacing,Array.isArray(t.panes)&&(t.panes=t.panes.map(e=>{if(!Sn(e)||!Sn(e.priceScale))return e;const t={...e.priceScale,autoScale:!0};return delete t.range,{...e,priceScale:t}})),t}function En(e){return"light"===e?{theme:k,name:"light"}:"dark"===e||void 0===e?{theme:C,name:"dark"}:{theme:e,name:wt(e)}}function On(e,t,o){const n=_(e),a=null!==n&&"interval"===n.bucketing.mode?n.bucketing.seconds:null;return{from:o-(null===a?15768e4:Math.max(1,Math.round(t))*a),to:o}}class Tn{constructor(e,t){Object.defineProperty(this,"chart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"draw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"objects",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"alerts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"document",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"keymap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"bus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"locale",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"translate",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"toast",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"openOverlay",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tips",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"overlays",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"symbol",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_source",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._source=e,this.chart=t.chart,this.draw=t.draw,this.objects=t.objects,this.alerts=t.alerts,this.root=t.root,this.document=t.document,this.keymap=t.keymap,this.bus=t.bus,this.storage=t.storage,this.locale=t.locale,this.translate=t.translate,this.toast=t.toast,this.openOverlay=t.openOverlay,this.status=t.status,this.tips=t.tips,this.overlays=t.overlays,this.symbol=t.symbol,this.interval=t.interval}get theme(){return this._source.theme()}get chartTheme(){return this._source.chartThemeInUse()}}class Mn{constructor(e,o){Object.defineProperty(this,"dataController",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"chart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"draw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"objects",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"alerts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"root",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_series",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_doc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_opts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_bus",{enumerable:!0,configurable:!0,writable:!0,value:new pe}),Object.defineProperty(this,"_storage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_keymap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_toasts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chartEl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rail",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_topbar",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_statusline",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mobile",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_objectsPanel",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_dock",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_quickEntry",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_alertsPanel",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_intervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_symbol",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_exchange",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chartType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_themeName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_chartTheme",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pointerInside",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_pointerInChart",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_dataStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_displayedBars",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_dataState",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_initialView",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_pendingView",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_keepView",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_saveTimer",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_cleanups",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this._opts=o,this.dataController=o.feed?new $(o.feed,{now:()=>Math.floor((o.now??Date.now)()/1e3),...o.loading}):null;const n=o.document??e.ownerDocument;this._doc=n,jt(n,yn,o.styleNonce);const a="string"==typeof o.persist?o.persist:"default",r=o.persist?void 0===o.storage?be():o.storage:null;this._storage=new he(a,r);const s=this._readSaved();this._symbol=(o.symbol??s?.symbol??"").toUpperCase(),this._exchange=o.exchange??s?.exchange??"",void 0!==o.interval&&S(o.interval);for(const e of o.intervals??[])S(e);const l=null!==s&&A(s.interval)?s.interval:"1d";this._interval=o.interval??l;const c=o.chartType??s?.chartType??"candlestick";if(void 0!==o.chartType&&!t().includes(o.chartType))throw new Error(`openalgo-charts widget: "${o.chartType}" is not a registered chart type`);this._chartType=t().includes(c)?c:"candlestick";const d=En(o.theme??s?.theme);this._themeName=d.name,this._chartTheme=d.theme;const p=new Set(o.intervals??[...xn,...i().map(e=>e.code)]);p.add(this._interval),this._intervals=Array.from(p);const u=oe(n,"div","oac-widget");u.dataset.theme=this._themeName,Lt(u,At(this._chartTheme,this._themeName)),this.root=u;const h=oe(n,"div","oac-topbar");!1===o.topbar&&(h.hidden=!0),u.appendChild(h);const b=oe(n,"div","oac-stage");u.appendChild(b);const g=oe(n,"div","oac-rail");!1===o.rail&&(g.hidden=!0),b.appendChild(g);const m=oe(n,"div","oac-chart");this._chartEl=m,b.appendChild(m);const f=oe(n,"div","oac-statusline");!1===o.statusline&&(f.hidden=!0),u.appendChild(f);const v=oe(n,"div","oac-toasts");u.appendChild(v),e.appendChild(u);const w={...o};for(const e of An)delete w[e];const y=!0===n.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches;y&&void 0===w.animZoom&&(w.animZoom=!1),y&&void 0===w.animAutoscale&&(w.animAutoscale=!1),this.chart=L(m,{...w,theme:this._chartTheme,document:n}),m.setAttribute("aria-label",o.ariaLabel??ee(o,"Price chart")),this._series=this.chart.addSeries(this._chartType),this._publishDataContext(),this.draw=new J(this.chart,{}),this.alerts=new E(this.chart,{drawings:this.draw}),this.objects=new O(this.chart,{drawings:this.draw,onSettings:e=>{"source"===e.kind?this.openSettings():"indicator"===e.kind?So(this.context,void 0,{instanceId:e.sourceId}):"drawing"===e.kind&&_o(this.context,void 0,{ids:[e.sourceId]})}});const x=xe(u,n),_=ke(u,x.layer,n);this._toasts=ut(v,n,o);const k=this.chart.shortcuts;if(this._keymap=new Ie({chart:null===k?null:{list:()=>k.list()},scopes:()=>this._scopes()}),this._keymap.onConflict(e=>this._bus.emit("keymap:conflict",{combo:e.combo,kept:e.kept,shadowed:e.shadowed})),this.context=new Tn(this,{chart:this.chart,draw:this.draw,objects:this.objects,alerts:this.alerts,root:u,document:n,keymap:this._keymap,bus:this._bus,storage:this._storage,locale:o.locale,translate:o.translate,toast:(e,t)=>this._toasts.toast(e,t),openOverlay:(e,t)=>x.open(e,t),status:(e,t="info")=>{this._statusline?.setMessage(e,t),this._bus.emit("status",{text:e,kind:t})},tips:_,overlays:x,symbol:()=>({symbol:this._symbol,exchange:this._exchange}),interval:()=>this._interval}),this._cleanups.push(()=>{_.destroy(),x.destroy()}),!1!==o.eventDetails){const e=new cn(m,{styleNonce:o.styleNonce,overlays:this.context.overlays,formatTime:e=>{const t=new Date(1e3*e);return Number.isFinite(t.getTime())?new Intl.DateTimeFormat(o.locale,{timeZone:this.chart.timezone(),dateStyle:"medium",timeStyle:"short"}).format(t):String(e)},...o.eventDetails,injectStyles:!1});this._cleanups.push(this.chart.on("event:click",t=>{const o=t;e.open(o,o.point)})),this._cleanups.push(this.chart.on("data:context",()=>e.close())),this._cleanups.push(this.chart.on("events:change",()=>e.close())),this._cleanups.push(()=>e.destroy())}if(this._dataStatus=function(e,t,o,n){const a=oe(e.document,"div","oac-data-status");a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),a.setAttribute("aria-atomic","true"),a.hidden=!0,t.appendChild(a);let i=o?.getState()??null,r="",s=!1;const l=e=>e.stopPropagation();for(const e of["pointerdown","wheel","keydown"])a.addEventListener(e,l);const c=()=>{if(s)return;const t=[];if(null!==i){const a=i.request?.symbol??"",r=i.request?.interval??"";switch(i.status){case"loading":t.push({text:ee(e,"Loading {symbol} {interval}",{symbol:a,interval:r})});break;case"refreshing":t.push({text:ee(e,"Refreshing {symbol} {interval}",{symbol:a,interval:r})});break;case"empty":t.push({text:ee(e,"No bars for {symbol} {interval}",{symbol:a,interval:r}),label:ee(e,"Retry chart data"),retry:n});break;case"stale":t.push({text:ee(e,"History is stale for {symbol} {interval}",{symbol:a,interval:r}),label:ee(e,"Retry chart data"),retry:n});break;case"error":t.push({text:ee(e,"Could not load {symbol} {interval}",{symbol:a,interval:r}),label:ee(e,"Retry chart data"),retry:n})}"limited"===i.historyStatus?t.push({text:ee(e,"History retention limit reached")}):"loading"===i.historyStatus?t.push({text:ee(e,"Loading older history")}):"error"===i.historyStatus&&t.push({text:ee(e,"Could not load older history"),label:ee(e,"Retry older history"),retry:()=>{o?.loadMore()}})}for(const o of e.chart.indicators()){const n=o.dataStatus();if(null===n||"ready"===n.state)continue;const a={loading:ee(e,"Loading"),empty:ee(e,"No data"),unsupported:ee(e,"Unsupported"),error:ee(e,"Could not load")}[n.state];t.push({text:`${o.name}: ${a}`,label:ee(e,"Retry {name}",{name:o.name}),retry:"loading"===n.state?void 0:()=>o.retryData()})}const l=JSON.stringify(t.map(e=>[e.text,e.label,!!e.retry]));if(r!==l){r=l,a.textContent="",a.hidden=0===t.length;for(const o of t){const t=oe(e.document,"div","oac-data-status__row"),n=oe(e.document,"span","oac-data-status__text");if(n.textContent=o.text,t.appendChild(n),o.retry){const n=oe(e.document,"button","oac-btn");n.textContent=ee(e,"Retry"),n.type="button",n.setAttribute("aria-label",o.label),n.addEventListener("click",o.retry),t.appendChild(n)}a.appendChild(t)}}},d=()=>{c(),queueMicrotask(c)},p=["indicator:data-status","indicatorRemoved"].map(t=>e.chart.on(t,d));return c(),{el:a,update:e=>{i=e,c()},destroy:()=>{s=!0;for(const e of p)e();for(const e of["pointerdown","wheel","keydown"])a.removeEventListener(e,l);a.remove()}}}(this.context,b,this.dataController,()=>{this.reload()}),!1!==o.panels&&(this._dock=mn(this.context,b,{data:e=>un(this.context,e),objects:e=>{const t=tn(this.context);return e.appendChild(t.element),t},onChange:()=>{this._bus.emit("layout",{reason:"panels"}),this._scheduleSave()}})),this._cleanups.push(qo(this.context,{onOrder:o.onOrder,tradingCapabilities:o.tradingCapabilities,tradingMode:o.tradingMode,tradingLocked:o.tradingLocked})),!1!==o.rail){const e={..."object"==typeof o.rail?o.rail:{},cursorTarget:m};this._rail=Ve(this.context,g,e)}if(!1!==o.statusline&&(this._statusline=Ge(this.context,f,{locale:o.locale}),this._statusline.setSymbol(this._symbol,this._exchange,this._interval)),!1!==o.topbar&&(this._topbar=lt(this.context,h,{intervals:this._intervals,indicators:o.indicators,search:o.symbolSearch,state:()=>({symbol:this._symbol,exchange:this._exchange,interval:this._interval,chartType:this._chartType,theme:this._themeName}),onSymbol:(e,t)=>this.setSymbol(e,t),onInterval:e=>this.setInterval(e),onChartType:e=>this.setChartType(e),onTheme:e=>this.setTheme(e),onSettings:e=>this._openDialog("settings",e),onIndicators:e=>this._openDialog("indicatorPicker",e),onObjects:e=>this._openObjects(e),onDataWindow:!1===o.panels?void 0:()=>this._dock?.toggle("data"),onAlerts:e=>this._openAlerts(e),settingsAvailable:()=>null!==we("settings"),indicatorsAvailable:()=>null!==we("indicatorPicker"),dataAvailable:()=>null===this.dataController||"ready"===this._dataState?.status||"stale"===this._dataState?.status})),this._mobile=an(this.context,{mode:o.mobile,container:e,intervals:this._intervals,topbar:!1!==o.topbar,rail:this._rail,tools:"object"==typeof o.rail?o.rail.tools:void 0,indicators:!1!==o.indicators,search:o.symbolSearch,state:()=>({symbol:this._symbol,exchange:this._exchange,interval:this._interval,chartType:this._chartType,theme:this._themeName}),onSymbol:(e,t)=>this.setSymbol(e,t),onInterval:e=>this.setInterval(e),onChartType:e=>this.setChartType(e),onTheme:()=>this.setTheme("dark"===this._themeName?"light":"dark"),onSettings:e=>this._openDialog("settings",e),onIndicators:e=>this._openDialog("indicatorPicker",e),onObjects:e=>this._openObjects(e),onDataWindow:!1===o.panels?void 0:()=>this._dock?.toggle("data"),onAlerts:e=>this._openAlerts(e),onProperties:e=>this._openDialog("drawingProperties",e),settingsAvailable:()=>null!==we("settings"),indicatorsAvailable:()=>null!==we("indicatorPicker")}),this._installKeys(),this._keymap.attach(n),!1!==o.typingNavigation&&(this._quickEntry=vn(this.context,{enabled:()=>!this._destroyed&&null!==this._doc.activeElement&&this._chartEl.contains(this._doc.activeElement)&&0===this.draw.selection().length,onSymbol:(e,t)=>this.setSymbol(e,t),onInterval:e=>this.setInterval(e),search:o.symbolSearch})),this._trackPointer(),this._followChart(),void 0!==s?.chart){const e=s.symbol===this._symbol&&s.exchange===this._exchange&&s.interval===this._interval,t=this.chart.restoreState(e?s.chart:Ln(s.chart));t.applied?(this._keepView=e,this._pendingView=e?s.chart.viewport??null:null):this._toasts.toast(ee(this.context,"The saved layout could not be restored: {error}",{error:t.reason??"unknown reason"}),"error")}if(s?.rail&&null!==this._rail&&this._rail.restorePrefs(s.rail),s?.panels&&this._dock?.restore(s.panels),null!==this.dataController){this._cleanups.push(this.dataController.subscribe(e=>this._applyData(e))),this.chart.setHistoryLoader(()=>{this.dataController.loadMore().finally(()=>{this._destroyed||this.chart.historyLoadComplete()})});const e=()=>this.dataController.setVisible(!n.hidden);n.addEventListener("visibilitychange",e),this._cleanups.push(()=>n.removeEventListener("visibilitychange",e)),n.hidden&&e(),""!==this._symbol&&this.reload()}}get series(){return this._series}get isDestroyed(){return this._destroyed}symbol(){return this._symbol}exchange(){return this._exchange}interval(){return this._interval}chartType(){return this._chartType}theme(){return this._themeName}chartThemeInUse(){return this._chartTheme}on(e,t){return this._bus.on(e,t)}off(e,t){this._bus.off(e,t)}setSymbol(e,t){const o=e.trim().toUpperCase(),n=t??this._exchange;if(o===this._symbol&&n===this._exchange)return this._topbar?.refresh(),void this._mobile?.refresh();this._symbol=o,this._exchange=n,this._keepView=!1,this._pendingView=null,null===this.dataController&&(this._series.setData([]),this._publishDataContext()),this._statusline?.setSymbol(o,n,this._interval),this._topbar?.refresh(),this._mobile?.refresh(),this._scheduleSave(),this._opts.feed&&this.reload(),this._bus.emit("symbol",{symbol:o,exchange:n}),this.chart.emit("symbol",{symbol:o,exchange:n})}setInterval(e){const t=e.trim();if(""===t)throw new Error("openalgo-charts widget: interval code must not be empty");if(S(t),t===this._interval)return this._topbar?.refresh(),void this._mobile?.refresh();this._interval=t,this._keepView=!1,this._pendingView=null,null===this.dataController&&(this._series.setData([]),this._publishDataContext()),this._statusline?.setSymbol(this._symbol,this._exchange,t),this._topbar?.refresh(),this._mobile?.refresh(),this._scheduleSave(),this._opts.feed&&this.reload(),this._bus.emit("interval",{interval:t})}setChartType(e){if(!t().includes(e))throw new Error(`openalgo-charts widget: "${e}" is not a registered chart type`);if(e===this._chartType)return;const o=this._series.getData();this._series.remove(),this._series=this.chart.addSeries(e),o.length>0&&this._series.setData(o),this._chartType=e,this._topbar?.refresh(),this._mobile?.refresh(),this._statusline?.refresh(),this._scheduleSave(),this._bus.emit("layout",{reason:"chartType",chartType:e})}setTheme(e){const t=En(e);this._themeName=t.name,this._chartTheme=t.theme,this.chart.setTheme(t.theme),this.root.dataset.theme=t.name,Lt(this.root,At(t.theme,t.name)),this._topbar?.refresh(),this._mobile?.refresh(),this._scheduleSave(),this._bus.emit("theme",{theme:t.name,chartTheme:t.theme})}openSettings(){return this._openDialog("settings")}openIndicatorPicker(){return this._openDialog("indicatorPicker")}openObjects(){return this._openObjects()}openDataWindow(){return!(this._destroyed||!this._dock)&&(this._dock.open("data"),!0)}openAlerts(){return this._openAlerts()}_openAlerts(e){return!this._destroyed&&(this._alertsPanel?.isOpen()?(this._alertsPanel.el.focus(),!0):(this._alertsPanel=zo(this.context,e,{onClose:()=>{this._alertsPanel=null}}),!0))}_openObjects(e){return!this._destroyed&&(this._dock?(this._dock.open("objects"),!0):this._objectsPanel?.isOpen()?(this._objectsPanel.el.focus(),!0):(this._objectsPanel=on(this.context,e,{onClose:()=>{this._objectsPanel=null}}),!0))}_openDialog(e,t){const o=we(e);return null!==o&&(o(this.context,t),!0)}_publishDataContext(){const e=this.chart.getDataContext(),t=e?.symbol===this._symbol&&e.exchange===this._exchange;this.chart.setDataContext({symbol:this._symbol,exchange:this._exchange,interval:this._interval,...t&&void 0!==e.hasOpenInterest?{hasOpenInterest:e.hasOpenInterest}:{}})}async reload(){const e=this.dataController;if(null===e||this._destroyed)return;const t=e.getState().request;if(t?.symbol===this._symbol&&t.exchange===this._exchange&&t.interval===this._interval)return void await e.refresh();const o=this._opts.loading?.now?.()??Math.floor((this._opts.now??Date.now)()/1e3),n={symbol:this._symbol,exchange:this._exchange,interval:this._interval,...On(this._interval,this._opts.lookbackBars??500,o)};this._initialView=!0,this._displayedBars=null,this._series.setData([]),this._publishDataContext(),await e.load(n)}_applyData(e){if(this._destroyed||null===e.request)return;const t=this._dataState;this._dataState=e,this._dataStatus.update(e);const{symbol:o,interval:n}=e.request;if(!e.paused&&e.bars!==this._displayedBars){const t=this._series.getData(),o=this.chart.getVisibleLogicalRange(),n=t[Math.max(0,Math.min(t.length-1,Math.round(o.from)))],a=void 0===n?-1:t.findIndex(e=>e.time===n.time),i=e.bars[e.bars.length-1];if("live"!==e.reason||void 0===i||t[0]?.time!==e.bars[0]?.time||t.length!==e.bars.length&&t.length+1!==e.bars.length){if(this._series.setData(e.bars),e.bars.length>0)if(this._initialView)this._pendingView?this.chart.setVisibleLogicalRange(this._pendingView):this._keepView||this.chart.resetScale(),this._pendingView=null,this._initialView=!1,this._keepView=!1;else{const t=void 0===n?-1:e.bars.findIndex(e=>e.time===n.time),i=t<0||a<0?0:t-a;this.chart.setVisibleLogicalRange({from:o.from+i,to:o.to+i})}}else this._series.update(i);this._displayedBars=e.bars,this._statusline?.refresh()}(t?.status!==e.status||t.error!==e.error||["load","refresh","prepend","resume"].includes(e.reason))&&("loading"===e.status?this.context.status(ee(this.context,"Loading {symbol} {interval}",{symbol:o,interval:n})):"refreshing"===e.status?this.context.status(ee(this.context,"History is stale. Refreshing {symbol} {interval}",{symbol:o,interval:n})):"error"===e.status||"stale"===e.status?(this.context.status("stale"===e.status?ee(this.context,"History is stale for {symbol} {interval}. Reload to retry.",{symbol:o,interval:n}):ee(this.context,"Could not load {symbol} {interval}",{symbol:o,interval:n}),"error"),e.error&&e.error!==t?.error&&(this._toasts.toast(ee(this.context,"Could not load {symbol} {interval}: {error}",{symbol:o,interval:n,error:e.error.message}),"error"),this._bus.emit("data",{symbol:o,interval:n,bars:0,error:e.error.message}))):"ready"!==e.status&&"empty"!==e.status||(this.context.status(0===e.bars.length?ee(this.context,"No bars for {symbol} {interval}",{symbol:o,interval:n}):ee(this.context,"{count} bars",{count:e.bars.length})),this._bus.emit("data",{symbol:o,interval:n,bars:e.bars.length})))}getState(){return{version:1,symbol:this._symbol,exchange:this._exchange,interval:this._interval,chartType:this._chartType,theme:this._themeName,chart:this.chart.getState(),rail:this._rail?.prefs()??null,panels:this._dock?.state()}}restoreState(e){if(!Sn(e))return{applied:!1,reason:"not a widget state object"};if(void 0!==e.version&&1!==e.version)return{applied:!1,reason:`widget state version ${String(e.version)} is not 1`};"dark"!==e.theme&&"light"!==e.theme||this.setTheme(e.theme),"string"==typeof e.chartType&&t().includes(e.chartType)&&this.setChartType(e.chartType),void 0!==e.rail&&null!==this._rail&&this._rail.restorePrefs(e.rail),void 0!==e.panels&&this._dock?.restore(e.panels);const o="string"==typeof e.symbol?e.symbol.toUpperCase():this._symbol,n="string"==typeof e.exchange?e.exchange:this._exchange,a="string"==typeof e.interval&&A(e.interval)?e.interval:this._interval,i=o===this._symbol&&n===this._exchange&&a===this._interval;let r;if(Sn(e.chart)){const t=e.chart;if(r=this.chart.restoreState(i?t:Ln(t)),!r.applied)return{applied:!1,reason:r.reason,chart:r};this._keepView=i,this._pendingView=i?t.viewport??null:null}return i||(a!==this._interval&&(this._interval=a,this._bus.emit("interval",{interval:a})),o===this._symbol&&n===this._exchange||(this._symbol=o,this._exchange=n,this._bus.emit("symbol",{symbol:o,exchange:n})),this._statusline?.setSymbol(this._symbol,this._exchange,this._interval),this._topbar?.refresh(),this._mobile?.refresh(),this._opts.feed?this.reload():(this._series.setData([]),this._publishDataContext())),this._rail?.refresh(),this._statusline?.refresh(),this._bus.emit("layout",{reason:"restore",chartType:this._chartType}),this._scheduleSave(),void 0===r?{applied:!0}:{applied:!0,chart:r}}_readSaved(){const e=this._storage.get(Cn);if(!Sn(e)||1!==e.version)return null;return{version:1,symbol:"string"==typeof e.symbol?e.symbol:"",exchange:"string"==typeof e.exchange?e.exchange:"",interval:"string"==typeof e.interval&&""!==e.interval?e.interval:"1d",chartType:"string"==typeof e.chartType?e.chartType:"candlestick",theme:"light"===e.theme?"light":"dark",chart:Sn(e.chart)?e.chart:void 0,rail:Sn(e.rail)?e.rail:null,panels:gn(e.panels)}}_scheduleSave(){this._storage.enabled&&!this._destroyed&&(0!==this._saveTimer&&clearTimeout(this._saveTimer),this._saveTimer=setTimeout(()=>{this._saveTimer=0,this._saveNow()},250))}_saveNow(){if(this._storage.enabled&&!this._destroyed){0!==this._saveTimer&&(clearTimeout(this._saveTimer),this._saveTimer=0);try{this._storage.set(Cn,this.getState())||this.context.status(ee(this.context,"The chart layout could not be saved"),"error")}catch(e){this.context.status(ee(this.context,"The chart layout could not be saved: {error}",{error:e instanceof Error?e.message:"invalid state"}),"error")}}}_scopes(){if(this.context.overlays.size()>0)return["overlay"];const e=[],t=this._doc.activeElement;return null!==t&&this._dataStatus.el.contains(t)?[]:(null!==this._rail&&null!==t&&this._rail.el.contains(t)&&e.push("rail"),(this._pointerInChart||null!==t&&this._chartEl.contains(t))&&e.push("chart"),(this._pointerInside||null!==t&&this.root.contains(t))&&e.push("widget"),e.push("global"),e)}_installKeys(){const e=this._keymap,t=this.draw,o=()=>{const e=t.selection();if(e.length>0)return e.slice();const o=t.hovered();return null===o?[]:[o]},n=e=>{const n=Y(e,{hasSelection:null!==t.selected(),hasTarget:null!==t.hovered(),editingText:!1,placing:null!==t.activeTool()});if(null===n){const o=this.alerts.hovered();return void 0!==o&&null===t.activeTool()&&("Delete"===e.key||"Backspace"===e.key)&&(this.alerts.remove(o),this._rail?.refresh(),!0)}switch(n.type){case"undo":t.undo();break;case"redo":t.redo();break;case"delete":t.removeMany(o());break;case"duplicate":t.duplicate(o());break;case"nudge":t.nudge(o(),n.dx,n.dy);break;case"cancel":t.cancel(),null===t.activeTool()&&this._rail?.setDrawLock(!1);break;case"finish":t.finish();break;case"popAnchor":t.popAnchor();break;case"copy":t.copy(o());break;case"cut":t.cut(o());break;case"paste":t.paste()}return this._rail?.refresh(),!0},a="Drawing",i=(t,o,i=!1,r=!1)=>{e.register(t,n,"widget",{label:o,group:a,hidden:i,layered:r})};i("Mod+Z","Undo"),i("Mod+Shift+Z","Redo"),i("Mod+Y","Redo",!0),i("Mod+C","Copy the selected drawing"),i("Mod+X","Cut the selected drawing"),i("Mod+V","Paste drawings"),i("Mod+D","Duplicate the selected drawing"),i("Delete","Delete the selected drawing"),i("Backspace","Delete, or drop the last anchor while placing"),i("Enter","Finish the drawing being placed"),i("ArrowLeft","Nudge the selection left (Shift: ten pixels)",!1,!0),i("ArrowRight","Nudge the selection right (Shift: ten pixels)",!1,!0),i("ArrowUp","Nudge the selection up (Shift: ten pixels)",!1,!0),i("ArrowDown","Nudge the selection down (Shift: ten pixels)",!1,!0);for(const e of["Shift+ArrowLeft","Shift+ArrowRight","Shift+ArrowUp","Shift+ArrowDown"])i(e,"Nudge ten pixels",!0,!0);e.register("Escape",e=>null!==t.activeTool()?(n(e)||(t.setTool(null),this._rail?.setDrawLock(!1)),!0):t.selection().length>0&&(t.select(null),this._rail?.refresh(),!0),"widget",{label:"Leave the tool, then clear the selection",group:a});for(const[o,n]of Object.entries(z()))e.register(n,()=>{this._rail?.setDrawLock(!1),t.setTool(o)},"widget",{label:ze(o),group:"Drawing tools"});e.register("?",()=>{Pe(this.context)},"widget",{label:"Keyboard shortcuts",group:"Widget"})}_trackPointer(){const e=this.root,t=this._chartEl,o=()=>{this._pointerInside=!0},n=()=>{this._pointerInside=!1,this._pointerInChart=!1},a=()=>{this._pointerInChart=!0},i=()=>{this._pointerInChart=!1};e.addEventListener("pointerenter",o),e.addEventListener("pointerleave",n),t.addEventListener("pointerenter",a),t.addEventListener("pointerleave",i),this._cleanups.push(()=>{e.removeEventListener("pointerenter",o),e.removeEventListener("pointerleave",n),t.removeEventListener("pointerenter",a),t.removeEventListener("pointerleave",i)})}_followChart(){const e=["paneAdded","paneResized","paneMoved","paneMaximized","paneRemoved","indicatorRemoved","indicatorSettings","priceAxisMoved","objects:change"];for(const t of e)this._cleanups.push(this.chart.on(t,()=>{this._bus.emit("layout",{reason:t}),this._scheduleSave()}));for(const e of["draw:add","draw:remove","draw:update","draw:paste","draw:cut","alert:created","alert:updated","alert:removed","alert:triggered","alert:expired","alerts:restored","alerts:checkpoint"])this._cleanups.push(this.chart.on(e,()=>this._scheduleSave()));this._cleanups.push(this.chart.on("alert:triggered",e=>{const t=e;this.context.toast(t.message??t.title,"success")}));const t=this._doc.defaultView;if(null!=t&&"function"==typeof t.addEventListener){const e=()=>this._saveNow();t.addEventListener("pagehide",e),this._cleanups.push(()=>t.removeEventListener("pagehide",e))}}destroy(){if(!this._destroyed){this._saveNow(),this._destroyed=!0,this._quickEntry?.destroy(),this._dock?.destroy(),this.dataController?.destroy(),this._dataStatus.destroy(),this._mobile?.destroy(),this._mobile=null,0!==this._saveTimer&&(clearTimeout(this._saveTimer),this._saveTimer=0);for(const e of this._cleanups.splice(0))e();this._topbar?.destroy(),this._rail?.destroy(),this._statusline?.destroy(),this._toasts.destroy(),this._keymap.destroy(),this.objects.destroy(),this.alerts.destroy(),this.draw.destroy(),this.chart.destroy(),this.root.remove(),this._bus.clear()}}}function jn(e,t={}){let o;if("string"==typeof e){const n=t.document??globalThis.document;if(void 0===n)throw new Error("openalgo-charts widget: a selector needs a document");if(o=n.querySelector(e)??n.getElementById(e),null===o)throw new Error(`openalgo-charts widget: no element matches "${e}"`)}else o=e;return new Mn(o,t)}function In(e,t){const o=e.ownerDocument;jt(o,yn,t.styleNonce);const n=oe(o,"div","oac-widget oac-alert-host");e.appendChild(n);const a=xe(n,o),i=ke(n,a.layer,o),r=oe(o,"div","oac-toasts");n.appendChild(r);const s=ut(r,o,t);let l=t.theme??"dark",c=t.chartTheme??("light"===l?k:C),d=!1,p=!1,u=null;function h(){const e=a.size()>0;e!==p&&(p=e,t.onOpenChange?.(p))}const b={chart:t.chart,draw:t.draw,alerts:t.alerts,root:n,document:o,get theme(){return l},get chartTheme(){return c},keymap:new Ie,bus:new pe,storage:new he("alert-ui",null),locale:t.locale,translate:t.translate,tips:i,overlays:a,toast:(e,t)=>s.toast(e,t),status:(e,t)=>{s.toast(e,t)},symbol:()=>({symbol:t.chart.getDataContext()?.symbol??"",exchange:t.chart.getDataContext()?.exchange??""}),interval:()=>t.chart.getDataContext()?.interval??"",openOverlay:(e,t)=>{const o=a.open(e,{...t,onClose:()=>{t?.onClose?.(),h()}});return h(),o}},g=e=>{e.stopPropagation()};n.addEventListener("keydown",g);const m=t.chart.on("destroy",()=>f.destroy()),f={root:n,context:b,openList:e=>!d&&(u?.isOpen()?(u.el.focus(),!0):(u=zo(b,e,{onClose:()=>{u=null}}),!0)),openEditor:e=>!d&&(No(b,void 0,e),!0),isOpen:()=>!d&&a.size()>0,close:()=>a.closeAll(),setTheme:(e,t)=>{d||(l=e,c=t??("light"===e?k:C),n.dataset.theme=e,Lt(n,At(c,e)))},destroy:()=>{d||(d=!0,m(),a.destroy(),i.destroy(),s.destroy(),b.keymap.destroy(),b.bus.clear(),n.removeEventListener("keydown",g),n.remove())}};return f.setTheme(l,c),f}const Pn="widget";export{et as CHART_TYPE_LABELS,Rt as COLOR_PICKER_CSS,hn as DATA_WINDOW_CSS,xn as DEFAULT_INTERVALS,_n as DEFAULT_LOOKBACK_BARS,Zo as DIALOG_CSS,rn as EVENT_DETAILS_CSS,cn as EventDetailsPopup,Ie as Keymap,De as MAGNET_MODES,Ke as MIN_PRICE_DIGITS,nn as OBJECTS_PANEL_CSS,fn as PANEL_DOCK_CSS,wn as QUICK_ENTRY_CSS,Ne as RAIL_GROUPS,Re as RAIL_PREFS_KEY,Ct as RAIL_WIDTH,kn as SAVE_DEBOUNCE_MS,Ze as SEARCH_DEBOUNCE_MS,Cn as STATE_KEY,St as STATUSLINE_HEIGHT,ue as STORAGE_PREFIX,Qe as SYMBOL_PICKER_CSS,_e as TIP_DWELL_MS,pt as TOAST_LEAVE_MS,dt as TOAST_MAX,ct as TOAST_MS,ht as TOKEN_PREFIX,$t as TOPBAR_HEIGHT,yn as WIDGET_COMPONENT_CSS,Mt as WIDGET_CSS,Wo as WIDGET_DIALOGS,_t as WIDGET_FONT,kt as WIDGET_MONO,$n as WIDGET_STATE_VERSION,Ot as WIDGET_STYLE_ID,Pn as WIDGET_TIER,pe as WidgetBus,he as WidgetStorage,Lt as applyTokens,qo as attachContextMenu,de as boxIn,st as captureName,ot as chartTypeChoices,tt as chartTypeLabel,Ho as contextMenuEntries,Kt as controlsFromFields,Ut as controlsFromInputs,In as createAlertUi,zt as createColorPicker,tn as createObjectsPanelContent,xe as createOverlayStack,ke as createTipController,jn as createWidget,be as defaultStorage,rt as downloadText,te as esc,Ee as eventKeyCombo,ie as focusable,re as focusables,ft as formatColor,Me as formatKeyCombo,je as fromChartCombo,ne as glyph,oe as h,ae as inTextField,jt as injectWidgetStyles,nt as intervalLabel,On as loadWindow,vt as luminance,yt as mix,No as mountAlertEditor,zo as mountAlertsPanel,Ko as mountContextMenu,un as mountDataWindow,_o as mountDrawingProperties,ko as mountIndicatorPicker,So as mountIndicatorSettings,lo as mountLevelEditor,an as mountMobile,on as mountObjectsPanel,mn as mountPanelDock,vn as mountQuickEntry,Ve as mountRail,Lo as mountSettingsDialog,Ge as mountStatusline,Xe as mountSymbolPicker,mo as mountTextEditor,ut as mountToasts,lt as mountTopbar,at as openMenu,Pe as openShortcutsPanel,gt as parseColor,Le as parseKeyCombo,le as placeBelow,se as placeBeside,ce as placeTip,qe as priceDigits,dn as readDataWindow,me as registerWidgetDialog,fe as registerWidgetDialogs,ye as registeredWidgetDialogs,io as renderForm,En as resolveTheme,Je as safeSymbolIconUrl,gn as sanitizePanelDockState,He as sanitizeRailPrefs,Ln as stripView,wt as themeMode,Et as token,Be as toolGlyph,ze as toolName,ve as unregisterWidgetDialog,we as widgetDialog,ee as widgetText,At as widgetTokens,xt as withAlpha};
|
|
2
2
|
//# sourceMappingURL=openalgo-charts.widget.mjs.map
|