-
Notifications
You must be signed in to change notification settings - Fork 1
/
charteye-drawer.js
65 lines (65 loc) · 50.5 KB
/
charteye-drawer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import{L as t,m as e,s as a,a as o}from"./charteye-DQWqFSE1.js";
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class r{constructor(t){this.i=t=>{"ready"===t.detail.status&&this.host.requestUpdate()},this.host=t}hostConnected(){window.addEventListener(t,this.i)}hostDisconnected(){window.removeEventListener(t,this.i)}}const i=t=>t.addController(new r(t));function s(t,e,a,o=20,r=0){let i=[];if(r>=o)return i;const n=t=>{const i=t.assignedNodes().filter((t=>1===t.nodeType));return i.length>0?s(i[0].parentElement,e,a,o,r+1):[]},l=Array.from(t.children||[]);for(const t of l)e(t)||(a(t)&&i.push(t),null!=t.shadowRoot?i.push(...s(t.shadowRoot,e,a,o,r+1)):"SLOT"===t.tagName?i.push(...n(t)):i.push(...s(t,e,a,o,r+1)));return i}function n(t){return t.hasAttribute("hidden")||t.hasAttribute("aria-hidden")&&"false"!==t.getAttribute("aria-hidden")||"none"===t.style.display||"0"===t.style.opacity||"hidden"===t.style.visibility||"collapse"===t.style.visibility}function l(t){return"-1"!==t.getAttribute("tabindex")&&!n(t)&&!function(t){return t.hasAttribute("disabled")||t.hasAttribute("aria-disabled")&&"false"!==t.getAttribute("aria-disabled")}(t)&&(t.hasAttribute("tabindex")||(t instanceof HTMLAnchorElement||t instanceof HTMLAreaElement)&&t.hasAttribute("href")||t instanceof HTMLButtonElement||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLIFrameElement)}const h=new Map;const d=document.createElement("template");d.innerHTML='\n\t<div id="start"></div>\n\t<div id="backup"></div>\n\t<slot></slot>\n\t<div id="end"></div>\n';class c extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const t=this.attachShadow({mode:"open"});t.appendChild(d.content.cloneNode(!0)),this.$backup=t.querySelector("#backup"),this.$start=t.querySelector("#start"),this.$end=t.querySelector("#end"),this.focusLastElement=this.focusLastElement.bind(this),this.focusFirstElement=this.focusFirstElement.bind(this),this.onFocusIn=this.onFocusIn.bind(this),this.onFocusOut=this.onFocusOut.bind(this)}static get observedAttributes(){return["inactive"]}get inactive(){return this.hasAttribute("inactive")}set inactive(t){t?this.setAttribute("inactive",""):this.removeAttribute("inactive")}get focused(){return this._focused}connectedCallback(){this.$start.addEventListener("focus",this.focusLastElement),this.$end.addEventListener("focus",this.focusFirstElement),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.render()}disconnectedCallback(){this.$start.removeEventListener("focus",this.focusLastElement),this.$end.removeEventListener("focus",this.focusFirstElement),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut)}attributeChangedCallback(){this.render()}focusFirstElement(){this.trapFocus()}focusLastElement(){this.trapFocus(!0)}getFocusableElements(){return s(this,n,l)}trapFocus(t){if(this.inactive)return;let e=this.getFocusableElements();e.length>0?(t?e[e.length-1].focus():e[0].focus(),this.$backup.setAttribute("tabindex","-1")):(this.$backup.setAttribute("tabindex","0"),this.$backup.focus())}onFocusIn(){this.updateFocused(!0)}onFocusOut(){this.updateFocused(!1)}updateFocused(t){!function(t,e,a){const o=h.get(a);null!=o&&window.clearTimeout(o),h.set(a,window.setTimeout((()=>{t(),h.delete(a)}),e))}((()=>{this.focused!==t&&(this._focused=t,this.render())}),0,this.debounceId)}render(){this.$start.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.$end.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.focused?this.setAttribute("focused",""):this.removeAttribute("focused")}}window.customElements.define("focus-trap",c);
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const p=globalThis,b=p.ShadowRoot&&(void 0===p.ShadyCSS||p.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,u=Symbol(),f=new WeakMap;let w=class{constructor(t,e,a){if(this._$cssResult$=!0,a!==u)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(b&&void 0===t){const a=void 0!==e&&1===e.length;a&&(t=f.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),a&&f.set(e,t))}return t}toString(){return this.cssText}};const g=t=>new w("string"==typeof t?t:t+"",void 0,u),v=(t,...e)=>{const a=1===t.length?t[0]:e.reduce(((e,a,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(a)+t[o+1]),t[0]);return new w(a,t,u)},m=b?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const a of t.cssRules)e+=a.cssText;return g(e)})(t):t
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,{is:y,defineProperty:_,getOwnPropertyDescriptor:x,getOwnPropertyNames:k,getOwnPropertySymbols:$,getPrototypeOf:A}=Object,S=globalThis,C=S.trustedTypes,M=C?C.emptyScript:"",T=S.reactiveElementPolyfillSupport,E=(t,e)=>t,z={toAttribute(t,e){switch(e){case Boolean:t=t?M:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let a=t;switch(e){case Boolean:a=null!==t;break;case Number:a=null===t?null:Number(t);break;case Object:case Array:try{a=JSON.parse(t)}catch(t){a=null}}return a}},j=(t,e)=>!y(t,e),R={attribute:!0,type:String,converter:z,reflect:!1,hasChanged:j};Symbol.metadata??=Symbol("metadata"),S.litPropertyMetadata??=new WeakMap;class L extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=R){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const a=Symbol(),o=this.getPropertyDescriptor(t,a,e);void 0!==o&&_(this.prototype,t,o)}}static getPropertyDescriptor(t,e,a){const{get:o,set:r}=x(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return o?.call(this)},set(e){const i=o?.call(this);r.call(this,e),this.requestUpdate(t,i,a)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??R}static _$Ei(){if(this.hasOwnProperty(E("elementProperties")))return;const t=A(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(E("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(E("properties"))){const t=this.properties,e=[...k(t),...$(t)];for(const a of e)this.createProperty(a,t[a])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,a]of e)this.elementProperties.set(t,a)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const a=this._$Eu(t,e);void 0!==a&&this._$Eh.set(a,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const a=new Set(t.flat(1/0).reverse());for(const t of a)e.unshift(m(t))}else void 0!==t&&e.push(m(t));return e}static _$Eu(t,e){const a=e.attribute;return!1===a?void 0:"string"==typeof a?a:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const a of e.keys())this.hasOwnProperty(a)&&(t.set(a,this[a]),delete this[a]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(b)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const a of e){const e=document.createElement("style"),o=p.litNonce;void 0!==o&&e.setAttribute("nonce",o),e.textContent=a.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,a){this._$AK(t,a)}_$EC(t,e){const a=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,a);if(void 0!==o&&!0===a.reflect){const r=(void 0!==a.converter?.toAttribute?a.converter:z).toAttribute(e,a.type);this._$Em=t,null==r?this.removeAttribute(o):this.setAttribute(o,r),this._$Em=null}}_$AK(t,e){const a=this.constructor,o=a._$Eh.get(t);if(void 0!==o&&this._$Em!==o){const t=a.getPropertyOptions(o),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:z;this._$Em=o,this[o]=r.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,a){if(void 0!==t){if(a??=this.constructor.getPropertyOptions(t),!(a.hasChanged??j)(this[t],e))return;this.P(t,e,a)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,e,a){this._$AL.has(t)||this._$AL.set(t,e),!0===a.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,a]of t)!0!==a.wrapped||this._$AL.has(e)||void 0===this[e]||this.P(e,this[e],a)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EU()}catch(e){throw t=!1,this._$EU(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU()}updated(t){}firstUpdated(t){}}L.elementStyles=[],L.shadowRootOptions={mode:"open"},L[E("elementProperties")]=new Map,L[E("finalized")]=new Map,T?.({ReactiveElement:L}),(S.reactiveElementVersions??=[]).push("2.0.4");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const P=globalThis,B=P.trustedTypes,O=B?B.createPolicy("lit-html",{createHTML:t=>t}):void 0,U="$lit$",D=`lit$${(Math.random()+"").slice(9)}$`,H="?"+D,F=`<${H}>`,q=document,I=()=>q.createComment(""),Z=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,V="[ \t\n\f\r]",W=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Y=/-->/g,Q=/>/g,J=RegExp(`>|${V}(?:([^\\s"'>=/]+)(${V}*=${V}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),K=/'/g,X=/"/g,G=/^(?:script|style|textarea|title)$/i,tt=(t=>(e,...a)=>({_$litType$:t,strings:e,values:a}))(1),et=Symbol.for("lit-noChange"),at=Symbol.for("lit-nothing"),ot=new WeakMap,rt=q.createTreeWalker(q,129);function it(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==O?O.createHTML(e):e}const st=(t,e)=>{const a=t.length-1,o=[];let r,i=2===e?"<svg>":"",s=W;for(let e=0;e<a;e++){const a=t[e];let n,l,h=-1,d=0;for(;d<a.length&&(s.lastIndex=d,l=s.exec(a),null!==l);)d=s.lastIndex,s===W?"!--"===l[1]?s=Y:void 0!==l[1]?s=Q:void 0!==l[2]?(G.test(l[2])&&(r=RegExp("</"+l[2],"g")),s=J):void 0!==l[3]&&(s=J):s===J?">"===l[0]?(s=r??W,h=-1):void 0===l[1]?h=-2:(h=s.lastIndex-l[2].length,n=l[1],s=void 0===l[3]?J:'"'===l[3]?X:K):s===X||s===K?s=J:s===Y||s===Q?s=W:(s=J,r=void 0);const c=s===J&&t[e+1].startsWith("/>")?" ":"";i+=s===W?a+F:h>=0?(o.push(n),a.slice(0,h)+U+a.slice(h)+D+c):a+D+(-2===h?e:c)}return[it(t,i+(t[a]||"<?>")+(2===e?"</svg>":"")),o]};class nt{constructor({strings:t,_$litType$:e},a){let o;this.parts=[];let r=0,i=0;const s=t.length-1,n=this.parts,[l,h]=st(t,e);if(this.el=nt.createElement(l,a),rt.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(o=rt.nextNode())&&n.length<s;){if(1===o.nodeType){if(o.hasAttributes())for(const t of o.getAttributeNames())if(t.endsWith(U)){const e=h[i++],a=o.getAttribute(t).split(D),s=/([.?@])?(.*)/.exec(e);n.push({type:1,index:r,name:s[2],strings:a,ctor:"."===s[1]?pt:"?"===s[1]?bt:"@"===s[1]?ut:ct}),o.removeAttribute(t)}else t.startsWith(D)&&(n.push({type:6,index:r}),o.removeAttribute(t));if(G.test(o.tagName)){const t=o.textContent.split(D),e=t.length-1;if(e>0){o.textContent=B?B.emptyScript:"";for(let a=0;a<e;a++)o.append(t[a],I()),rt.nextNode(),n.push({type:2,index:++r});o.append(t[e],I())}}}else if(8===o.nodeType)if(o.data===H)n.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf(D,t+1));)n.push({type:7,index:r}),t+=D.length-1}r++}}static createElement(t,e){const a=q.createElement("template");return a.innerHTML=t,a}}function lt(t,e,a=t,o){if(e===et)return e;let r=void 0!==o?a._$Co?.[o]:a._$Cl;const i=Z(e)?void 0:e._$litDirective$;return r?.constructor!==i&&(r?._$AO?.(!1),void 0===i?r=void 0:(r=new i(t),r._$AT(t,a,o)),void 0!==o?(a._$Co??=[])[o]=r:a._$Cl=r),void 0!==r&&(e=lt(t,r._$AS(t,e.values),r,o)),e}class ht{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:a}=this._$AD,o=(t?.creationScope??q).importNode(e,!0);rt.currentNode=o;let r=rt.nextNode(),i=0,s=0,n=a[0];for(;void 0!==n;){if(i===n.index){let e;2===n.type?e=new dt(r,r.nextSibling,this,t):1===n.type?e=new n.ctor(r,n.name,n.strings,this,t):6===n.type&&(e=new ft(r,this,t)),this._$AV.push(e),n=a[++s]}i!==n?.index&&(r=rt.nextNode(),i++)}return rt.currentNode=q,o}p(t){let e=0;for(const a of this._$AV)void 0!==a&&(void 0!==a.strings?(a._$AI(t,a,e),e+=a.strings.length-2):a._$AI(t[e])),e++}}class dt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,a,o){this.type=2,this._$AH=at,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=a,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=lt(this,t,e),Z(t)?t===at||null==t||""===t?(this._$AH!==at&&this._$AR(),this._$AH=at):t!==this._$AH&&t!==et&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>N(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}S(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t))}_(t){this._$AH!==at&&Z(this._$AH)?this._$AA.nextSibling.data=t:this.T(q.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:a}=t,o="number"==typeof a?this._$AC(t):(void 0===a.el&&(a.el=nt.createElement(it(a.h,a.h[0]),this.options)),a);if(this._$AH?._$AD===o)this._$AH.p(e);else{const t=new ht(o,this),a=t.u(this.options);t.p(e),this.T(a),this._$AH=t}}_$AC(t){let e=ot.get(t.strings);return void 0===e&&ot.set(t.strings,e=new nt(t)),e}k(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let a,o=0;for(const r of t)o===e.length?e.push(a=new dt(this.S(I()),this.S(I()),this,this.options)):a=e[o],a._$AI(r),o++;o<e.length&&(this._$AR(a&&a._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class ct{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,a,o,r){this.type=1,this._$AH=at,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=r,a.length>2||""!==a[0]||""!==a[1]?(this._$AH=Array(a.length-1).fill(new String),this.strings=a):this._$AH=at}_$AI(t,e=this,a,o){const r=this.strings;let i=!1;if(void 0===r)t=lt(this,t,e,0),i=!Z(t)||t!==this._$AH&&t!==et,i&&(this._$AH=t);else{const o=t;let s,n;for(t=r[0],s=0;s<r.length-1;s++)n=lt(this,o[a+s],e,s),n===et&&(n=this._$AH[s]),i||=!Z(n)||n!==this._$AH[s],n===at?t=at:t!==at&&(t+=(n??"")+r[s+1]),this._$AH[s]=n}i&&!o&&this.j(t)}j(t){t===at?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class pt extends ct{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===at?void 0:t}}class bt extends ct{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==at)}}class ut extends ct{constructor(t,e,a,o,r){super(t,e,a,o,r),this.type=5}_$AI(t,e=this){if((t=lt(this,t,e,0)??at)===et)return;const a=this._$AH,o=t===at&&a!==at||t.capture!==a.capture||t.once!==a.once||t.passive!==a.passive,r=t!==at&&(a===at||o);o&&this.element.removeEventListener(this.name,this,a),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class ft{constructor(t,e,a){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=a}get _$AU(){return this._$AM._$AU}_$AI(t){lt(this,t)}}const wt=P.litHtmlPolyfillSupport;wt?.(nt,dt),(P.litHtmlVersions??=[]).push("3.1.2");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
let gt=class extends L{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,a)=>{const o=a?.renderBefore??e;let r=o._$litPart$;if(void 0===r){const t=a?.renderBefore??null;o._$litPart$=r=new dt(e.insertBefore(I(),t),t,void 0,a??{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return et}};gt._$litElement$=!0,gt.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:gt});const vt=globalThis.litElementPolyfillSupport;vt?.({LitElement:gt}),(globalThis.litElementVersions??=[]).push("4.0.4");
/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const mt=2,yt=t=>(...e)=>({_$litDirective$:t,values:e});
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class _t{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,a){this._$Ct=t,this._$AM=e,this._$Ci=a}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/let xt=class extends _t{constructor(t){if(super(t),this.it=at,t.type!==mt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===at||null==t)return this._t=void 0,this.it=t;if(t===et)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};xt.directiveName="unsafeHTML",xt.resultType=1;const kt=yt(xt),$t=(t,e)=>{const a=t._$AN;if(void 0===a)return!1;for(const t of a)t._$AO?.(e,!1),$t(t,e);return!0},At=t=>{let e,a;do{if(void 0===(e=t._$AM))break;a=e._$AN,a.delete(t),t=e}while(0===a?.size)},St=t=>{for(let e;e=t._$AM;t=e){let a=e._$AN;if(void 0===a)e._$AN=a=new Set;else if(a.has(t))break;a.add(t),Tt(e)}};
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/function Ct(t){void 0!==this._$AN?(At(this),this._$AM=t,St(this)):this._$AM=t}function Mt(t,e=!1,a=0){const o=this._$AH,r=this._$AN;if(void 0!==r&&0!==r.size)if(e)if(Array.isArray(o))for(let t=a;t<o.length;t++)$t(o[t],!1),At(o[t]);else null!=o&&($t(o,!1),At(o));else $t(this,t)}const Tt=t=>{t.type==mt&&(t._$AP??=Mt,t._$AQ??=Ct)};class Et extends _t{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,a){super._$AT(t,e,a),St(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&($t(this,t),At(this))}setValue(t){if((t=>void 0===t.strings)
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const zt=()=>new jt;class jt{}const Rt=new WeakMap,Lt=yt(class extends Et{render(t){return at}update(t,[e]){const a=e!==this.Y;return a&&void 0!==this.Y&&this.rt(void 0),(a||this.lt!==this.ct)&&(this.Y=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),at}rt(t){if("function"==typeof this.Y){const e=this.ht??globalThis;let a=Rt.get(e);void 0===a&&(a=new WeakMap,Rt.set(e,a)),void 0!==a.get(this.Y)&&this.Y.call(this.ht,void 0),a.set(this.Y,t),void 0!==t&&this.Y.call(this.ht,t)}else this.Y.value=t}get lt(){return"function"==typeof this.Y?Rt.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),Pt="custom",Bt=v`button[aria-label][data-balloon-pos]{overflow:visible}[aria-label][data-balloon-pos]{position:relative;cursor:pointer}[aria-label][data-balloon-pos]:after{opacity:0;pointer-events:none;transition:all .18s ease-out .18s;text-indent:0;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,Ubuntu,Cantarell,'Open Sans','Helvetica Neue',sans-serif;font-weight:400;font-style:normal;text-shadow:none;font-size:var(--balloon-font-size);background:var(--balloon-color);color:var(--balloon-text-color);border-radius:var(--balloon-border-radius);content:attr(aria-label);padding:.5em 1em;position:absolute;white-space:nowrap;z-index:10}[aria-label][data-balloon-pos]:before{width:0;height:0;border:5px solid transparent;border-top-color:var(--balloon-color);opacity:0;pointer-events:none;transition:all .18s ease-out .18s;content:'';position:absolute;z-index:10}[aria-label][data-balloon-pos]:hover:after,[aria-label][data-balloon-pos]:hover:before,[aria-label][data-balloon-pos]:not([data-balloon-nofocus]):focus:after,[aria-label][data-balloon-pos]:not([data-balloon-nofocus]):focus:before,[aria-label][data-balloon-pos][data-balloon-visible]:after,[aria-label][data-balloon-pos][data-balloon-visible]:before{opacity:1;pointer-events:none}[aria-label][data-balloon-pos][data-balloon-break]:after{white-space:pre}[aria-label][data-balloon-pos][data-balloon-break][data-balloon-length]:after{white-space:pre-line;word-break:break-word}[aria-label][data-balloon-pos][data-balloon-blunt]:after,[aria-label][data-balloon-pos][data-balloon-blunt]:before{transition:none}[aria-label][data-balloon-pos][data-balloon-pos=down]:hover:after,[aria-label][data-balloon-pos][data-balloon-pos=down][data-balloon-visible]:after,[aria-label][data-balloon-pos][data-balloon-pos=up]:hover:after,[aria-label][data-balloon-pos][data-balloon-pos=up][data-balloon-visible]:after{transform:translate(-50%,0)}[aria-label][data-balloon-pos][data-balloon-pos=down]:hover:before,[aria-label][data-balloon-pos][data-balloon-pos=down][data-balloon-visible]:before,[aria-label][data-balloon-pos][data-balloon-pos=up]:hover:before,[aria-label][data-balloon-pos][data-balloon-pos=up][data-balloon-visible]:before{transform:translate(-50%,0)}[aria-label][data-balloon-pos][data-balloon-pos*='-left']:after{left:0}[aria-label][data-balloon-pos][data-balloon-pos*='-left']:before{left:5px}[aria-label][data-balloon-pos][data-balloon-pos*='-right']:after{right:0}[aria-label][data-balloon-pos][data-balloon-pos*='-right']:before{right:5px}[aria-label][data-balloon-pos][data-balloon-po*='-left']:hover:after,[aria-label][data-balloon-pos][data-balloon-po*='-left'][data-balloon-visible]:after,[aria-label][data-balloon-pos][data-balloon-pos*='-right']:hover:after,[aria-label][data-balloon-pos][data-balloon-pos*='-right'][data-balloon-visible]:after{transform:translate(0,0)}[aria-label][data-balloon-pos][data-balloon-po*='-left']:hover:before,[aria-label][data-balloon-pos][data-balloon-po*='-left'][data-balloon-visible]:before,[aria-label][data-balloon-pos][data-balloon-pos*='-right']:hover:before,[aria-label][data-balloon-pos][data-balloon-pos*='-right'][data-balloon-visible]:before{transform:translate(0,0)}[aria-label][data-balloon-pos][data-balloon-pos^=up]:after,[aria-label][data-balloon-pos][data-balloon-pos^=up]:before{bottom:100%;transform-origin:top;transform:translate(0,var(--balloon-move))}[aria-label][data-balloon-pos][data-balloon-pos^=up]:after{margin-bottom:10px}[aria-label][data-balloon-pos][data-balloon-pos=up]:after,[aria-label][data-balloon-pos][data-balloon-pos=up]:before{left:50%;transform:translate(-50%,var(--balloon-move))}[aria-label][data-balloon-pos][data-balloon-pos^=down]:after,[aria-label][data-balloon-pos][data-balloon-pos^=down]:before{top:100%;transform:translate(0,calc(var(--balloon-move) * -1))}[aria-label][data-balloon-pos][data-balloon-pos^=down]:after{margin-top:10px}[aria-label][data-balloon-pos][data-balloon-pos^=down]:before{width:0;height:0;border:5px solid transparent;border-bottom-color:var(--balloon-color)}[aria-label][data-balloon-pos][data-balloon-pos=down]:after,[aria-label][data-balloon-pos][data-balloon-pos=down]:before{left:50%;transform:translate(-50%,calc(var(--balloon-move) * -1))}[aria-label][data-balloon-pos][data-balloon-pos=left]:hover:after,[aria-label][data-balloon-pos][data-balloon-pos=left][data-balloon-visible]:after,[aria-label][data-balloon-pos][data-balloon-pos=right]:hover:after,[aria-label][data-balloon-pos][data-balloon-pos=right][data-balloon-visible]:after{transform:translate(0,-50%)}[aria-label][data-balloon-pos][data-balloon-pos=left]:hover:before,[aria-label][data-balloon-pos][data-balloon-pos=left][data-balloon-visible]:before,[aria-label][data-balloon-pos][data-balloon-pos=right]:hover:before,[aria-label][data-balloon-pos][data-balloon-pos=right][data-balloon-visible]:before{transform:translate(0,-50%)}[aria-label][data-balloon-pos][data-balloon-pos=left]:after,[aria-label][data-balloon-pos][data-balloon-pos=left]:before{right:100%;top:50%;transform:translate(var(--balloon-move),-50%)}[aria-label][data-balloon-pos][data-balloon-pos=left]:after{margin-right:10px}[aria-label][data-balloon-pos][data-balloon-pos=left]:before{width:0;height:0;border:5px solid transparent;border-left-color:var(--balloon-color)}[aria-label][data-balloon-pos][data-balloon-pos=right]:after,[aria-label][data-balloon-pos][data-balloon-pos=right]:before{left:100%;top:50%;transform:translate(calc(var(--balloon-move) * -1),-50%)}[aria-label][data-balloon-pos][data-balloon-pos=right]:after{margin-left:10px}[aria-label][data-balloon-pos][data-balloon-pos=right]:before{width:0;height:0;border:5px solid transparent;border-right-color:var(--balloon-color)}[aria-label][data-balloon-pos][data-balloon-length]:after{white-space:normal}[aria-label][data-balloon-pos][data-balloon-length=small]:after{width:80px}[aria-label][data-balloon-pos][data-balloon-length=medium]:after{width:150px}[aria-label][data-balloon-pos][data-balloon-length=large]:after{width:260px}[aria-label][data-balloon-pos][data-balloon-length=xlarge]:after{width:380px}@media screen and (max-width:768px){[aria-label][data-balloon-pos][data-balloon-length=xlarge]:after{width:90vw}}[aria-label][data-balloon-pos][data-balloon-length=fit]:after{width:100%}`;
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class Ot extends gt{contentRef=zt();footerRef=zt();dropupRef=zt();toastRef=zt();promptRef=zt();resizerRef=zt();static get styles(){return v`:host{--balloon-border-radius:2px;--balloon-color:rgb(54, 58, 69);--balloon-text-color:#fff;--balloon-font-size:12px;--balloon-move:4px;--drawer-width:86vw;--drawer-height:100%;--drawer-background:#fff;--drawer-color:rgb(19, 23, 34);--drawer-border-color:rgb(224, 227, 235);--drawer-button-hover-bg:rgb(240, 243, 250);--drawer-separator-color:rgb(224, 227, 235);--drawer-link-color:#872ae0;--drawer-spinner-bg-color:#ededed;--drawer-tradingview-blue:rgb(41, 98, 255);--drawer-tradingview-blue-dark:rgb(30, 83, 229);--drawer-tradingview-green:#1c8e76;--drawer-tradingview-red:#d94f4f;--drawer-max-panel-height:calc(100vh - 84px - 39px);position:fixed;top:0;right:0;bottom:0;border-left:2px solid var(--drawer-border-color);width:var(--drawer-width);height:100%;transform:translate3d(100%,0,0);background:var(--drawer-background);user-select:text!important;z-index:200;transition:transform .25s ease-in-out .15s;transform-origin:right;will-change:transform;font-family:-apple-system,system-ui,'Trebuchet MS',Roboto,Ubuntu,sans-serif;color:var(--drawer-color);text-align:left}@media screen and (min-width:768px){:host{--drawer-width:60vw}}@media screen and (min-width:1280px){:host{--drawer-width:40vw}}:host([align=left]),:host([dir=rtl]){border-left:0;border-right:2px solid var(--drawer-border-color);transform-origin:left;transform:translate3d(-100%,0,0);right:auto;left:0}:host([dir=rtl]){text-align:right}:host([theme=dark]){--balloon-color:rgb(54, 58, 69);--balloon-text-color:#fff;--drawer-background:#131722;--drawer-color:rgb(209, 212, 220);--drawer-border-color:rgb(42, 46, 57);--drawer-button-hover-bg:rgba(255, 255, 255, 0.1);--drawer-separator-color:rgb(67, 70, 81);--drawer-spinner-bg-color:#262931;--drawer-link-color:#b466a4}:host([open]){transform:translate3d(0,0,0)}:root{--balloon-border-radius:2px;--balloon-color:rgba(16, 16, 16, 0.95);--balloon-text-color:#fff;--balloon-font-size:12px;--balloon-move:4px}::selection{background:var(--drawer-tradingview-green);color:#fff}a{color:var(--drawer-link-color)}*{box-sizing:border-box}a:focus,a:hover{text-decoration:none}a.button,button{padding:.5rem;border-radius:4px;transition:background-color .35s ease,color 60ms ease;cursor:pointer;appearance:none;background:0 0;display:inline-flex;align-items:center;border:0;color:var(--drawer-color)}a.button:hover,a.focus:hover,button:focus,button:hover{background:var(--drawer-button-hover-bg)}button svg{pointer-events:none}.charteye-drawer__content{height:calc(100% - 42px - 39px)}.charteye-drawer__content input[type=radio]{position:absolute;opacity:0;z-index:-1}.charteye-drawer__panel-content{padding:0 .75rem;max-height:0;overflow:hidden;opacity:0;transition:max-height .25s ease-in-out,opacity .2s ease-in-out;overflow-y:auto;-webkit-overflow-scrolling:touch;user-select:text!important}.charteye-drawer__panel-label{cursor:pointer;padding:.766rem .75rem .766rem 1.75rem;display:flex;align-items:center;justify-content:space-between;width:100%;position:relative;opacity:.75;color:var(--drawer-color);border-bottom:1px solid var(--drawer-border-color)}.charteye-drawer__panel-label[data-loading]{padding-right:2.75rem}.charteye-drawer__panel-label:focus,.charteye-drawer__panel-label:hover{opacity:1}.charteye-drawer__panel-label svg{transition:opacity .25s ease-in-out;position:absolute;right:.75rem;top:50%;transform:translateY(-50%)}.charteye-drawer__panel-label[data-loading] svg:not([data-spinner]),.charteye-drawer__panel:only-child .charteye-drawer__panel-label svg:not([data-spinner]){opacity:0!important}.charteye-drawer__panel-label svg.icon-min{opacity:0;visibility:hidden}.charteye-drawer__panel-label svg.icon-plus{opacity:1;visibility:visible}.charteye-drawer__panel-label:empty{display:none}.charteye-drawer__panel input:focus+.charteye-drawer__panel-label,.charteye-drawer__panel:focus-within .charteye-drawer__panel-label{outline:0;box-shadow:inset 0 0 0 2px var(--drawer-tradingview-blue)}.charteye-drawer__panel input:checked+.charteye-drawer__panel-label{opacity:1}.charteye-drawer__panel input:checked+.charteye-drawer__panel-label svg.icon-min{opacity:1;visibility:visible}.charteye-drawer__panel input:checked+.charteye-drawer__panel-label svg.icon-plus{opacity:0;visibility:hidden}.charteye-drawer__panel input:checked+.charteye-drawer__panel-label::before{content:'';position:absolute;left:.75rem;top:50%;transform:translateY(-50%);width:8px;height:8px;border-radius:50%;background:var(--drawer-tradingview-blue)}.charteye-drawer__panel input:checked~.charteye-drawer__panel-content{max-height:var(--drawer-max-panel-height);padding:.75rem 1.75rem;opacity:1;border-bottom:1px solid var(--drawer-border-color)}.charteye-drawer__panel:last-child input:checked~.charteye-drawer__panel-content{border-bottom:0}.charteye-drawer__panel-content h2{font-size:1.25rem;margin-bottom:.35rem}.charteye-drawer__panel-content h3{font-size:1rem;margin-bottom:.35rem}.charteye-drawer__panel-content p{margin-bottom:1.5rem;margin-top:0;line-height:1.5}.charteye-drawer__panel-content li{margin-bottom:1rem;line-height:1.5}.charteye-drawer__panel-content li:empty,.charteye-drawer__panel-content p:empty{display:none}.charteye-drawer__panel-content ol,.charteye-drawer__panel-content ul{padding-left:.75rem;margin-bottom:1.5rem}.charteye-drawer__header{background:var(--drawer-background);border-bottom:4px solid var(--drawer-border-color);height:42px;display:flex;align-items:center;width:100%;padding:0 .25rem;font-size:14px;justify-content:end;z-index:10;position:relative}.charteye-drawer__footer{background:var(--drawer-background);border-top:1px solid var(--drawer-border-color);height:39px;display:flex;align-items:center;width:100%;padding:3px .5rem 2px .25rem;font-size:12px;justify-content:space-between;margin:auto 0 0;z-index:10;position:relative;pointer-events:none;opacity:.5;cursor:not-allowed;will-change:opacity;transition:opacity .25s ease-in-out}:host([align=left]) .charteye-drawer__footer{flex-direction:row-reverse}.charteye-drawer__footer.show{opacity:1;pointer-events:auto;cursor:unset}.charteye-drawer__separator{display:inline-flex;height:calc(100% - 16px);margin:8px 4px;width:1px;color:#d1d4dc;background:var(--drawer-separator-color)}.charteye-drawer__spinner{display:flex;align-items:center;font-size:14px;gap:.5rem}.charteye-drawer__spinner svg{color:var(--drawer-spinner-bg-color);display:inline-flex}.charteye-drawer__form{padding:.5rem 0}.charteye-drawer__form textarea{width:100%;height:100px;margin-bottom:1rem;padding:10px;font-family:-apple-system,system-ui,'Trebuchet MS',Roboto,Ubuntu,sans-serif;font-size:16px;border:1px solid var(--drawer-border-color);background:var(--drawer-background);border-radius:4px;resize:none}.charteye-drawer__form button{background:var(--drawer-tradingview-blue);color:#fff;padding:.6rem .75rem;border-radius:8px}.charteye-drawer__form button:focus,.charteye-drawer__form button:hover{background:var(--drawer-tradingview-blue-dark)}.charteye-drawer__dropup,.charteye-drawer__toast{position:absolute;bottom:38px;background:var(--drawer-background);left:0;display:flex;flex-direction:column;width:100%;transform:translate3d(0,200%,0);transition:transform .25s ease-in-out;transform-origin:bottom;will-change:transform,opacity;backdrop-filter:blur(3px);border-top:1px solid var(--drawer-border-color);z-index:9;font-size:14px;padding:0;margin:0}.charteye-drawer__toast{bottom:auto;padding:.75rem .75rem .75rem 2rem;top:0;z-index:12;color:#fff;flex-direction:row;transform:translate3d(0,-200%,0);background-size:20px 20px}.charteye-drawer__toast.is-success{color:#fff;background:var(--drawer-tradingview-green) url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" stroke="white" viewBox="0 0 24 24" stroke-width="1.5" width="20" height="20"><path fill="none" stroke="white" stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" /></svg>') no-repeat .5rem center}.charteye-drawer__toast.is-error{background:var(--drawer-tradingview-red) url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="white" width="20" height="20"><path stroke-linecap="round" stroke-linejoin="round" d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" /></svg>') no-repeat .5rem center}.charteye-drawer__dropup.active:focus-within,.charteye-drawer__dropup.show,.charteye-drawer__toast.show{transform:translate3d(0,0,0)}.charteye-drawer__dropup li{border-bottom:1px solid var(--drawer-border-color);display:flex}.charteye-drawer__dropup svg{color:var(--drawer-color)}.charteye-drawer__dropup button:focus,.charteye-drawer__dropup button:hover{background:var(--drawer-button-hover-bg)}.charteye-drawer__dropup button:hover svg{color:var(--drawer-tradingview-blue)}.charteye-drawer__dropup button[disabled]{pointer-events:none;opacity:.5}.charteye-drawer__dropup [data-tag]{background:var(--drawer-tradingview-blue);color:#fff;padding:.25rem .5rem;border-radius:4px;font-size:12px}.charteye-drawer__dropup button{padding:.75rem;border-radius:0;display:flex;width:100%;align-items:center;gap:.5rem;transition:background-color .35s ease,color 60ms ease,font-weight 60ms ease}:host([open]) .charteye-drawer__resizer{position:absolute;left:0;top:0;bottom:0;width:10px;cursor:col-resize;z-index:100}:host([open]) .charteye-drawer__resizer::before{content:'';position:absolute;top:0;left:-10px;bottom:0;display:block;width:10px;height:100%}`}static get properties(){return{debug:{type:Boolean},width:{type:String,reflect:!0},locale:{type:String,reflect:!0},theme:{type:String,reflect:!0},align:{type:String,reflect:!0},open:{type:Boolean,reflect:!0},resizable:{type:Boolean,reflect:!0},data:{type:Object},panels:{type:Object},activePanel:{type:String},isLoading:{type:Boolean},toastMessage:{type:String},userPrompt:{type:String}}}constructor(){super(),i(this),this.align="right",this.theme="",this.panels={},this.debug=!1,this.open=!1,this.data={},this.plugin=null,this.activePanel="",this.userPrompt="",this.panels={},this.resizable=!1,this.isResizing=!1,this.startX=0,this.isLoading=!1,this.tooltips=!0,this.toastMessage="",this.maxPanelHeight=81,this.messages=this.getTranslations(),this.addEventListener("drawer:open",this._onOpen),this.addEventListener("drawer:close",this._onClose),this.addEventListener("analysis:start",this._onAnalysisStart),this.addEventListener("analysis:render",this._onAnalysisRender),this.addEventListener("analysis:ready",this._onAnalysisReady),this.addEventListener("request:error",this._onRequestError),this.addEventListener("mousemove",(t=>{if(!this.isResizing)return;const e=t.clientX,a=this.offsetWidth-(e-this.offsetLeft)+"px";this.setDrawerWidth(a)})),this.addEventListener("mouseup",(()=>{this.isResizing=!1}))}_onOpen(){this.open=!0,this.log("Drawer opened.")}_onClose(){this.open=!1,this.log("Drawer closed"),this.data={};const t=this.plugin?.abortController;t?.signal&&!t?.signal?.aborted&&(this.log("Abort XHR request"),t?.abort("Request aborted by user (drawer closed)"))}_onRequestError(){const t=e("An error occurred while processing your request. Please try again later.");this.toggleToast({message:t,type:"error"}),this.data.analysis=t,this.panels.ta.content=kt(t),this.requestUpdate()}_onAnalysisStart(){this.panels.ta={label:e(a`Technical Analysis for ${this.data.symbol} on ${this.data.interval} timeframe`),content:this.loader({label:this.messages.waitingForChartEye}),isLoading:!0},this.requestUpdate(),setTimeout((()=>{this.contentRef.value.querySelector("input:checked")?.focus()}),1e3)}_onAnalysisRender(t){this.data.analysis=t.detail,this.panels.ta.content=kt(this.data.analysis),this.requestUpdate()}_onAnalysisReady(t){const o=e(a`Analysis for ${this.data.symbol} on ${this.data.interval} timeframe is ready`);this.log(o),this.toggleToast({message:o}),this.data=t.detail,this.panels.ta.content=kt(this.data.analysis),this.panels.ta.isLoading=!1,this.footerRef.value.classList.add("show"),this.dropupRef.value.classList.add("active")}setAttributes(){this.setAttribute("role","complementary"),this.setAttribute("aria-label",this.messages.interactWithChartEye),this.setAttribute("aria-hidden","true"),this.setAttribute("aria-expanded","false"),this.setAttribute("aria-modal","true"),this.setAttribute("aria-labelledby","charteye-drawer"),this.setAttribute("aria-describedby","charteye-drawer-content"),this.setAttribute("tabindex","-1")}setDrawerWidth(t){this.log("Setting drawer width to",t),this.width=t,this.style.setProperty("--drawer-width",t)}getTranslations(){return{close:e("Close"),interactWithChartEye:e("Interact with ChartEye"),downloadAnalysisAsPDF:e("Download analysis as PDF"),shareThisAnalysis:e("Share this analysis"),frequentlyAskedQuestions:e("Frequently Asked Questions"),waitingForChartEye:e("Awaiting a reply from ChartEye. This can take a few moments...")}}dispatch(t,e={}){return this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async setLocale(t){this.log("Setting locale to %s",t),await o(t).then((()=>{this.messages=this.getTranslations()}))}log(t,...e){const a=new Date,o=(a.getHours()<10?"0":"")+a.getHours()+":"+((a.getMinutes()<10?"0":"")+a.getMinutes())+":"+((a.getSeconds()<10?"0":"")+a.getSeconds());return this.debug?console.log(`[${o}] - ${t}`,...e):null}header(){return tt`<div class="charteye-drawer__header">${this.button({tabIndex:0,label:this.messages.close,icon:tt`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 17" width="17" height="17" fill="currentColor"><path d="m.58 1.42.82-.82 15 15-.82.82z"></path><path d="m.58 15.58 15-15 .82.82-15 15z"></path></svg>`,onClick:()=>this._onClose(),tooltip:"rtl"===this.dir?"right":"left"})}</div>`}content(){return tt`<div ${Lt(this.contentRef)} class="charteye-drawer__content" @click="${()=>this.dropupRef.value.classList.remove("show")}">${Object.values(this.panels).filter((t=>t.key!==Pt)).map((t=>this.panel(t)))} ${this.panels[Pt]?this.panel(this.panels[Pt]):""}</div>`}panel({content:t,key:e,label:a="",isLoading:o=!1}={}){const r=`panel_${Object.keys(this.panels).indexOf(e)+1}`;this.activePanel||(this.activePanel=e);const i=e===this.activePanel;return tt`<div class="charteye-drawer__panel"><input type="radio" name="drawer" id="${r}" ?checked="${i}"> <label for="${r}" class="charteye-drawer__panel-label" ?data-loading="${o}" @click="${()=>{this.activePanel=e}}"><div>${o?tt`<div>${this.loader()}</div>`:""}${a}</div><div><svg xmlns="http://www.w3.org/2000/svg" fill="none" width="17" height="17" viewBox="0 0 24 24" stroke-width="1.5" class="icon-min" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M5 12h14"/></svg><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="icon-plus" stroke="currentColor" width="17" height="17"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"/></svg></div></label><div class="charteye-drawer__panel-content">${t}</div></div>`}toast(){return tt`<div ${Lt(this.toastRef)} class="charteye-drawer__toast">${this.toastMessage}</div>`}toggleToast({message:t,type:e="success"}={}){const a=this.toastRef.value;this.log("Toggling toast message %s and type",t,e),this.toastMessage=t,a.classList.remove("is-success","is-error"),a.classList.add(`is-${e}`),a.classList.contains("show")||a.classList.toggle("show"),setTimeout((()=>{a.classList.remove("show"),a.classList.remove(`is-${e}`)}),6e3)}toggleDropup({show:t=!0}={}){if(this.log("Toggling dropup (visible: %s)",t?"yes":"no"),!t)return this.dropupRef.value.classList.remove("show"),void this.dispatch("dropup:close");this.dropupRef.value.classList.add("show"),this.dispatch("dropup:open"),setTimeout((()=>this.dropupRef.value.querySelector("button")?.focus()),50)}dropup(){const t=this.data?.questions||[],a=e("Formulate your own message");return tt`<ul ${Lt(this.dropupRef)} class="charteye-drawer__dropup">${t?.map((t=>this.dropupQuestion(t,t.includes(a))))} ${this.dropupQuestion(a,!0)}</ul>`}dropupQuestion(t,a){return tt`<li><button data-prompt="${t}" ?disabled="${a&&"premium"!==this.plugin?.tier||this.isLoading||Object.values(this.panels).map((t=>t.label)).includes(t)}" @click="${()=>this.addPanel(t,a)}"><svg xmlns="http://www.w3.org/2000/svg" fill="none" width="17" height="17" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 12.76c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 0 1 1.037-.443 48.282 48.282 0 0 0 5.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z"/></svg>${t}${a?tt`<span data-tag>${e("Premium")}</span>`:""}</button></li>`}promptForm(){return tt`<form class="charteye-drawer__form" @submit="${t=>{this.userPrompt&&this.addPanel(this.userPrompt),t.preventDefault()}}"><textarea ${Lt(this.promptRef)} name="prompt" id="prompt" cols="30" rows="5" required placeholder="${e("Your message:")}" @blur="${t=>{this.userPrompt=t.target.value}}" @keydown="${t=>{const e=(()=>{let t="",e=document.activeElement,a=e?e.tagName.toLowerCase():null;return"textarea"===a||"input"===a&&/^(?:text|search|password|tel|url)$/i.test(e.type)&&"number"==typeof e.selectionStart?t=e.value.slice(e.selectionStart,e.selectionEnd):window.getSelection&&(t=window.getSelection().toString()),t})();let a=t.key;a&&"Unidentified"!==a&&(["Shift","Meta","ArrowLeft","ArrowTop","ArrowDown","ArrowRight","Tab"].includes(t.key)||("Backspace"===a?this.userPrompt=e?this.userPrompt.replace(e,""):this.userPrompt.slice(0,-1):("Enter"===a&&(a="\n"),this.userPrompt+=a),this.promptRef.value.value=this.userPrompt),t.shiftKey&&(!t.shiftKey||"Shift"===a)||["ArrowLeft","ArrowRight","ArrowDown","ArrowTop","Enter"].includes(a)||t.metaKey||t.preventDefault())}}"></textarea> <button type="submit">${e("Send message")}</button></form>`}async addPanel(t,a=!1){let o=t.replace(/\s/g,"-").toLowerCase();if(a&&(o=Pt),this.log("Adding panel with key %s and question %s",o,t),this.panels[o]={key:o,label:t,content:a?this.promptForm():this.loader({label:this.messages.waitingForChartEye}),isLoading:!a},this.activePanel=o,this.toggleDropup({show:!1}),this.style.setProperty("--drawer-max-panel-height",`calc(100vh - 84px - 39px - (42px + ${[...this.contentRef.value?.querySelectorAll(".charteye-drawer__panel-label")].map((t=>t.offsetHeight)).reduce(((t,e)=>t+e),0)}px)`),a)return;let r="";const i=await this.plugin.improveAnalysis(t);if(200!==i?.status){this.log("Error occurred while processing the request. Response: %O",i);const t=e("An error occurred while processing your request. Please try again later.");return this.toggleToast({message:t,type:"error"}),this.panels[o].content=t,this.panels[o].isLoading=!1,this.requestUpdate()}const s=i.body?.getReader(),n=new TextDecoder;for(;;){const{done:t,value:e}=await s.read();if(t){this.panels[o].isLoading=!1,this.requestUpdate();break}r+=n.decode(e),this.panels[o].content=kt(r),this.requestUpdate()}}button({id:t,label:e,icon:a,onClick:o,tooltip:r="up",tabIndex:i=null}){return tt`<button @click="${o}" type="button" aria-label="${e}" data-balloon-pos="${r}" tabindex="${(t=>t??at)(i||-1)}" id="${t||e.replace(" ","-").toLowerCase()}">${tt`${a}`}</button>`}separator(){return tt`<span class="charteye-drawer__separator"> </span>`}loader({label:t=""}={}){return tt`<div class="charteye-drawer__spinner"><svg width="24" height="24" viewBox="0 0 24 24" data-spinner><style>.spinner_ajPY{transform-origin:center;animation:spinner_AtaB .75s infinite linear}@keyframes spinner_AtaB{100%{transform:rotate(360deg)}}</style><path fill="currentColor" d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"/><path fill="#2849cc" d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z" class="spinner_ajPY"/></svg> <span>${t}</span></div>`}footer(){return tt`<div ${Lt(this.footerRef)} class="charteye-drawer__footer"><div>${this.button({onClick:()=>this.toggleDropup(),icon:tt`<svg fill="none" width="17" height="17" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 0 1 .865-.501 48.172 48.172 0 0 0 3.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z"/></svg>`,label:this.messages.interactWithChartEye})} ${this.separator()} ${tt`<a class="button" target="_blank" @click="${()=>this.dispatch("analysis:download")}" aria-label="${this.messages.downloadAnalysisAsPDF}" data-balloon-pos="up" href="https://charteye.ai/pdf/${this.data.slug}"><svg xmlns="http://www.w3.org/2000/svg" fill="none" width="17" height="17" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"/></svg></a>`} ${this.separator()} ${tt`<a class="button" target="_blank" @click="${()=>this.dispatch("analysis:share")}" aria-label="${this.messages.shareThisAnalysis}" data-balloon-pos="up" href="https://charteye.ai/ta/${this.data.slug}"><svg xmlns="http://www.w3.org/2000/svg" fill="none" width="17" height="17" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M7.217 10.907a2.25 2.25 0 1 0 0 2.186m0-2.186c.18.324.283.696.283 1.093s-.103.77-.283 1.093m0-2.186 9.566-5.314m-9.566 7.5 9.566 5.314m0 0a2.25 2.25 0 1 0 3.935 2.186 2.25 2.25 0 0 0-3.935-2.186Zm0-12.814a2.25 2.25 0 1 0 3.933-2.185 2.25 2.25 0 0 0-3.933 2.185Z"/></svg></a>`} ${this.separator()} ${tt`<a class="button" target="_blank" aria-label="${this.messages.frequentlyAskedQuestions}" data-balloon-pos="up" href="https://charteye.ai/faq"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" width="17" height="17"><path stroke-linecap="round" stroke-linejoin="round" d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z"/></svg></a>`}</div><p>Powered by <a href="https://chartai.tech" target="_blank" rel="noopener noreferrer">ChartAI</a></p></div>`}resizer(){return tt`<div ${Lt(this.resizerRef)} @mousedown="${t=>{this.isResizing=!0,this.startX=t.clientX}}" class="charteye-drawer__resizer"></div>`}render(){return tt`${this.tooltips?tt`<style>${g(Bt)}</style>`:""}<focus-trap>${this.header()} ${this.toast()} ${this.content()} ${this.dropup()} ${this.footer()} ${this.resizable?this.resizer():""}</focus-trap>`}}window.customElements.define("charteye-drawer",Ot),window.document.body.insertAdjacentElement("afterbegin",window.document.createElement("charteye-drawer"));export{Ot as CharteyeDrawer};