UNPKG

apexcharts

Version:

A JavaScript Chart Library

6 lines (5 loc) 18.2 kB
/*! * ApexCharts v6.6.1 * (c) 2018-2026 ApexCharts */ "use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,o=(t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,a=(e,t)=>{for(var n in t||(t={}))s.call(t,n)&&o(e,n,t[n]);if(i)for(var n of i(t))r.call(t,n)&&o(e,n,t[n]);return e},c=(e,t,n)=>o(e,"symbol"!=typeof t?t+"":t,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("apexcharts/core");function d(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const u=d(l),h=u.__apex_Environment_Environment,f=u.__apex_Animations_prefersReducedMotion,p=new Date("2027-07-31T00:00:00Z"),m="APEX-",y=new Map,v=new Set,g=new Set;let b=!1;function x(e){if("function"==typeof atob)return atob(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("binary");throw new Error("no base64 decoder available")}function w(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=x(t.padEnd(4*Math.ceil(t.length/4),"=")),i=new Uint8Array(n.length);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);return i}function _(e,t,n){return i=this,s=null,r=function*(){if(v.has(e)||y.has(e))return;v.add(e);const i=globalThis.crypto?globalThis.crypto.subtle:void 0,s=S.publicKeysSpki;if(!i||0===s.length)return v.delete(e),void(b||(b=!0));const r=(new TextEncoder).encode(function(e){const t=e.domains&&e.domains.length>0?e.domains.join(","):"";return`v1|${e.issueDate}|${e.expiryDate}|${e.plan}|${t}`}(t));let o=!1;for(const e of s){try{const t=yield i.importKey("spki",w(e),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]);o=yield i.verify({hash:"SHA-256",name:"ECDSA"},t,w(n),r)}catch(e){o=!1}if(o)break}var a;v.delete(e),y.set(e,o),a=S.validateKey(e),g.forEach(e=>{try{e(a)}catch(e){}})},new Promise((e,t)=>{var n=e=>{try{a(r.next(e))}catch(e){t(e)}},o=e=>{try{a(r.throw(e))}catch(e){t(e)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,o);a((r=r.apply(i,s)).next())});var i,s,r}class S{static decodeLicenseData(e){try{const t=JSON.parse(x(e));return t.issueDate&&t.expiryDate&&t.plan?{domains:Array.isArray(t.domains)?t.domains:void 0,expiryDate:t.expiryDate,issueDate:t.issueDate,plan:t.plan,valid:!0}:null}catch(e){return null}}static getKey(){return this.licenseKey}static getLicenseStatus(){return this.licenseKey?(this.validationResult=this.validateKey(this.licenseKey),this.validationResult):{expired:!1,valid:!1}}static isKeyValid(e){return!!e&&this.validateKey(e).valid}static isLicenseValid(){return!!this.licenseKey&&this.getLicenseStatus().valid}static onChange(e){return g.add(e),()=>{g.delete(e)}}static setLicense(e){this.licenseKey=e,this.validationResult=this.validateKey(e),this.validationResult.valid}static validateKey(e){try{if("string"!=typeof e||!e.startsWith(m))return{expired:!1,message:'Invalid license key format. License key must start with "APEX-".',signatureVerified:!1,valid:!1};const t=e.slice(5);if(!t)return{expired:!1,message:"Invalid license key format. Expected format: APEX-{encoded-data}.",signatureVerified:!1,valid:!1};const n=this.decodeLicenseData(t);if(!n)return{expired:!1,message:"Invalid license key. Unable to decode license data.",signatureVerified:!1,valid:!1};const i=function(e){try{const t=JSON.parse(x(e));return"string"==typeof t.sig&&t.sig?t.sig:null}catch(e){return null}}(t);if(!i&&new Date>=p)return{data:n,expired:!1,message:"This license key is in the old unsigned format, which is no longer accepted. Please request a replacement key.",signatureVerified:!1,valid:!1};const s=new Date;if(new Date(n.expiryDate)<s)return{data:n,expired:!0,message:`License expired on ${n.expiryDate}. Please renew your license.`,signatureVerified:!1,valid:!1};if(n.domains&&n.domains.length>0){const e="undefined"!=typeof window&&window.location?window.location.hostname:"";if(!n.domains.some(t=>e===t||e.endsWith(`.${t}`)))return{data:n,expired:!1,message:`License is not valid for this domain (${e}). Allowed domains: ${n.domains.join(", ")}.`,signatureVerified:!1,valid:!1}}if(i){const t=y.get(e);return!1===t?{data:n,expired:!1,message:"Invalid license key. The license signature does not verify.",signatureVerified:!0,valid:!1}:(void 0===t&&_(e,n,i),{data:n,expired:!1,signatureVerified:!0===t,valid:!0})}return{data:n,expired:!1,signatureVerified:!1,valid:!0}}catch(e){return{expired:!1,message:"Invalid license key format or corrupted data.",signatureVerified:!1,valid:!1}}}static _resetSignatureState(){y.clear(),v.clear(),b=!1}}c(S,"licenseKey",null),c(S,"publicKeysSpki",["MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQIaK9UMD6n0oR/FIy8QdL0uSzKMQlf1BB+tOrji4/WuHsyRNxeDhVykoSsNURozMi1xhmqWvBH1L//xIfugTPA=="]),c(S,"validationResult",null);const A="data-apexcharts-watermark",O={position:"absolute",top:"0",right:"0",bottom:"0",left:"0",pointerEvents:"none",userSelect:"none",webkitUserSelect:"none",msUserSelect:"none",zIndex:"10000",display:"block",visibility:"visible",opacity:"1"};class k{static applyStyles(e){Object.assign(e.style,O,{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent('\n <svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">\n <text\n x="50%"\n y="50%"\n dominant-baseline="middle"\n text-anchor="middle"\n font-family="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Arial, sans-serif"\n font-size="18"\n font-weight="600"\n fill="rgba(134, 134, 134, 0.1)"\n transform="rotate(-35, 100, 60)"\n >APEXCHARTS</text>\n </svg>\n '.trim())}")`,backgroundRepeat:"repeat"})}static add(e){if(!e||"undefined"==typeof document)return null;let t=this.node(e);return t||(t=document.createElement("div"),t.setAttribute(A,""),e.appendChild(t)),this.applyStyles(t),"function"==typeof getComputedStyle&&"static"===getComputedStyle(e).position&&(e.style.position="relative"),t}static node(e){return e?e.querySelector(`[${A}]`):null}static exists(e){return!!this.node(e)}static remove(e){const t=this.node(e);t&&t.remove()}}c(k,"ATTR",A);let I=!1;const E=new Set;function D(){I=!0,N()}function P(e,t){const n=k.add(t);if(!n||"undefined"==typeof MutationObserver)return;if(e._wmNodeObserver&&e._wmObservedNode===n)return;e._wmNodeObserver&&e._wmNodeObserver.disconnect();const i=new MutationObserver(()=>{const e=k.node(t);e&&(i.disconnect(),k.applyStyles(e),i.takeRecords(),i.observe(e,{attributes:!0,attributeFilter:["style"]}))});i.observe(n,{attributes:!0,attributeFilter:["style"]}),e._wmNodeObserver=i,e._wmObservedNode=n}function C(e,t){e._wmWrapObserver&&(e._wmWrapObserver.disconnect(),e._wmWrapObserver=null),e._wmNodeObserver&&(e._wmNodeObserver.disconnect(),e._wmNodeObserver=null),e._wmObservedNode=null;const n=t||e.w&&e.w.dom&&e.w.dom.elWrap;n&&k.remove(n)}function j(e,t){try{if(!h.isBrowser())return;if(e&&e.globals&&e.globals.isDestroyed)return void E.delete(t);const n=e&&e.dom&&e.dom.elWrap;if(!n)return;const i=function(e,t){const n=e&&e.config&&e.config.chart||{},i=[];"unit"===n.type&&i.push("unit"),t.storyboard&&t.storyboard._used&&i.push("storyboard");const s=n.link;return t.linkedViews&&s&&(!0===s.enabled||"function"==typeof s.dimension)&&i.push("link"),t.ink&&n.ink&&!0===n.ink.enabled&&i.push("ink"),t.measure&&n.measure&&!0===n.measure.enabled&&i.push("measure"),t.contextMenu&&n.contextMenu&&!0===n.contextMenu.enabled&&i.push("context-menu"),t.perspectives&&(t.perspectives._used||I)&&i.push("perspectives"),t.history&&n.history&&!0===n.history.enabled&&i.push("history"),i}(e,t);if(0===i.length)return E.delete(t),void C(t,n);E.add(t);const s=function(e){const t=e&&e.config&&e.config.chart&&e.config.chart.license;if(t)return t;const n=S.getKey();if(n)return n;const i=h.getApex();return i&&i.license?i.license:null}(e);if(S.isKeyValid(s))return void C(t,n);!function(e,t){if(P(e,t),"undefined"==typeof MutationObserver||e._wmWrapObserver)return;const n=new MutationObserver(()=>{k.node(t)||P(e,t)});n.observe(t,{childList:!0}),e._wmWrapObserver=n}(t,n),function(e,t){e._premiumLicenseNotified||(e._premiumLicenseNotified=!0,t&&S.getKey())}(t,s)}catch(e){}}function N(){if(!h.isBrowser())return;const e=new Set,t=h.getApex(),n=t&&t._chartInstances;Array.isArray(n)&&n.forEach(t=>{const n=t&&t.chart;n&&n.w&&!n.w.globals.isDestroyed&&(e.add(n),j(n.w,n))}),Array.from(E).forEach(t=>{const n=t&&t.w,i=n&&n.dom&&n.dom.elWrap;n&&!n.globals.isDestroyed&&i&&!1!==i.isConnected?e.has(t)||j(n,t):E.delete(t)})}S.onChange(N);const K=u.__apex_Utils;function L(e,t){const n=null!=e,i=null!=t;return n||i?{min:n?e:null,max:i?t:null}:null}function R(e){return Array.isArray(e)?e.map(e=>Array.isArray(e)?e.slice():e):[]}function M(e,t){return"function"==typeof e&&t?e===t.addXaxisAnnotation?"xaxis":e===t.addYaxisAnnotation?"yaxis":e===t.addPointAnnotation?"point":null:null}function B(e,t){const n=e.config.annotations?K.clone(e.config.annotations):null,i=[],s=e.globals.memory&&e.globals.memory.methodsToExec||[];for(const e of s){if(!e||"addAnnotation"!==e.label)continue;const n=M(e.method,t);n&&i.push({kind:n,params:K.clone(e.params)})}return{static:n,dynamic:i}}function T(e){const t=e&&e.measure;if(!t||"function"!=typeof t.getPins)return null;const n=t.getPins();return Array.isArray(n)&&n.length?{pins:n}:null}function U(e,t,{animate:n=!0,mergeOptions:i}={}){var s,r;if(!e||!t)return;"number"==typeof t.v&&t.v,e.clearAnnotations();const o=i?K.clone(i):{},a=t.window&&t.window.xaxis;o.xaxis=Object.assign({},o.xaxis,a?{min:null!=(s=a.min)?s:void 0,max:null!=(r=a.max)?r:void 0}:{min:void 0,max:void 0});const c=t.window&&t.window.yaxis;if(Array.isArray(c)&&(o.yaxis=c.map(e=>{var t,n;return e?{min:null!=(t=e.min)?t:void 0,max:null!=(n=e.max)?n:void 0}:{}})),t.theme){const e={};null!=t.theme.mode&&(e.mode=t.theme.mode),null!=t.theme.palette&&(e.palette=t.theme.palette),Object.keys(e).length&&(o.theme=Object.assign({},o.theme,e))}t.annotations&&t.annotations.static&&(o.annotations=K.clone(t.annotations.static)),e.updateOptions(o,!1,n,!1,!1),function(e,t){if(!e||!t)return;const n=e.w;n.interact.zoomed=!!t.zoomed,function(e,t,n){const i=e.w;if(null==t&&null==n)return;const s=i.globals.seriesNames||[],r=new Set([...t||[],...n||[]]),o=new Set([...i.globals.collapsedSeriesIndices||[],...i.globals.ancillaryCollapsedSeriesIndices||[]]);for(let t=0;t<s.length;t++){const n=s[t];if(null==n)continue;const i=r.has(t),a=o.has(t);i&&!a?e.hideSeries(n):!i&&a&&e.showSeries(n)}}(e,t.collapsed,t.ancillaryCollapsed),t.annotations&&Array.isArray(t.annotations.dynamic)&&t.annotations.dynamic.forEach(t=>{const n=function(e){switch(e){case"xaxis":return"addXaxisAnnotation";case"yaxis":return"addYaxisAnnotation";case"point":return"addPointAnnotation";default:return null}}(t.kind);n&&"function"==typeof e[n]&&e[n](t.params,!0)});(function(e,t){Array.isArray(t)&&(e.w.interact.selectedDataPoints=R(t))})(e,t.selectedDataPoints),t.locale&&t.locale!==n.config.chart.defaultLocale&&e.setLocale(t.locale);e.measure&&"function"==typeof e.measure.setPins&&e.measure.setPins(t.measure&&t.measure.pins||[])}(e,t)}const V="apex";function z(e){return function(e){if("undefined"!=typeof Buffer)return Buffer.from(e,"utf-8").toString("base64");const t=(new TextEncoder).encode(e);let n="";for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function $(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";return function(e){if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("utf-8");const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return(new TextDecoder).decode(n)}(t)}class W{constructor(e,t){this.w=e,this.ctx=t,this._saved=[],this._counter=0,this._used=!1}capture(){const e={v:1,view:function(e,t){var n,i;const s=e.config.xaxis||{},r=(Array.isArray(e.config.yaxis)?e.config.yaxis:e.config.yaxis?[e.config.yaxis]:[]).map(e=>L(e&&e.min,e&&e.max)),o=r.some(e=>null!==e),a=e.config.theme,c=t&&t.drilldown;return{v:1,window:{xaxis:L(s.min,s.max),yaxis:o?r:null},zoomed:!!e.interact.zoomed,collapsed:(e.globals.collapsedSeriesIndices||[]).slice(),ancillaryCollapsed:(e.globals.ancillaryCollapsedSeriesIndices||[]).slice(),selectedDataPoints:R(e.interact.selectedDataPoints),theme:a?{mode:null!=(n=a.mode)?n:null,palette:null!=(i=a.palette)?i:null}:null,locale:e.config.chart&&e.config.chart.defaultLocale||null,annotations:B(e,t),drill:c&&c.depth>0?{path:c.path.slice()}:null,measure:T(t)}}(this.w,this.ctx)},t=this._serializableDelta();return t&&Object.keys(t).length&&(e.options=t),e}_serializableDelta(){const e=this.w.config,t=e.chart&&e.chart.perspectives&&e.chart.perspectives.serializeOptions||["theme","xaxis","yaxis","title","subtitle"],n={};return t.forEach(t=>{if(void 0!==e[t]){const i=function(e){try{return JSON.parse(JSON.stringify(e))}catch(e){return}}(e[t]);void 0!==i&&(n[t]=i)}}),n}encode(e){const t=e||this.capture();return z(JSON.stringify(t))}decode(e){return W.decode(e)}toURL(){if(!h.isBrowser())return"";const e=this.encode(this.capture()),t=new URL(window.location.href);return t.hash=`${V}=${e}`,t.toString()}apply(e,t={}){const n="string"==typeof e?W.decode(e):e;if(!n||!n.view)return;this._used=!0,j(this.w,this.ctx);const i=void 0===t.animate||t.animate,s=K.extend(n.options?K.clone(n.options):{},t.mergeOptions||{}),r=Object.keys(s).length?s:void 0;(this.w.config.chart.group?this.ctx.getSyncedCharts():[this.ctx]).forEach(e=>{U(e,n.view,{animate:i,mergeOptions:r})})}save(e){const t="perspective-"+ ++this._counter;return this._saved.push({id:t,name:e||t,token:this.capture()}),this._used=!0,j(this.w,this.ctx),t}list(){return this._saved.map(e=>({id:e.id,name:e.name,token:e.token}))}delete(e){const t=this._saved.findIndex(t=>t.id===e);t>-1&&this._saved.splice(t,1)}teardown(){this._saved=[],this._counter=0}static decode(e){if("string"!=typeof e||!e)return null;try{const t=JSON.parse($(e));return t&&"object"==typeof t?1!==t.v?null:t:null}catch(e){return null}}static fromURL(e){try{const t=e||(h.isBrowser()?window.location.href:"");if(!t)return null;const n=new URL(t).hash.replace(/^#/,"");if(!n)return null;const i=n.split("&").map(e=>e.split("=")).find(e=>e[0]===V);return i&&null!=i[1]?W.decode(decodeURIComponent(i[1])):null}catch(e){return null}}}l.registerFeatures({perspectives:W}),l.perspectives={decode:e=>(D(),W.decode(e)),fromURL:e=>(D(),W.fromURL(e))},l.registerFeatures({storyboard:class{constructor(e,t){this.w=e,this.ctx=t,this._beats=[],this._observer=null,this._activeIndex=-1,this._animate=!0,this._warnedNoPerspectives=!1,this._used=!1}bind(e={}){var t;if(this.unbind(),!h.isBrowser())return 0;const n=this.ctx.el&&this.ctx.el.ownerDocument;if(!n||"undefined"==typeof IntersectionObserver)return 0;let i=null;if(e.scroller&&(i="string"==typeof e.scroller?n.querySelector(e.scroller):e.scroller),this._beats=this._resolveBeats(n,i,e.beats),!this._beats.length)return 0;this._animate=!1!==e.animate;const s=Math.min(Math.max(null!=(t=e.offset)?t:.5,0),1),r=+(100*s).toFixed(3),o=+(100-100*s).toFixed(3);return this._observer=new IntersectionObserver(e=>this._onIntersect(e),{root:i,rootMargin:`-${r}% 0px -${o}%`,threshold:0}),this._beats.forEach(e=>{var t;return null==(t=this._observer)?void 0:t.observe(e.el)}),this._used=!0,j(this.w,this.ctx),this._beats.length}_resolveBeats(e,t,n){const i=[];if(Array.isArray(n))return n.forEach((t,n)=>{var s,r;if(!t)return;const o=t.el&&"object"==typeof t.el?t.el:t.selector?e.querySelector(t.selector):null;o&&i.push({el:o,key:null!=(r=null!=(s=t.key)?s:o.getAttribute("data-apex-beat"))?r:String(n),view:t.view,options:t.options,announce:t.announce,onEnter:"function"==typeof t.onEnter?t.onEnter:void 0})}),i;return(t||e).querySelectorAll("[data-apex-beat]").forEach((e,t)=>{i.push({el:e,key:e.getAttribute("data-apex-beat")||String(t),view:e.getAttribute("data-apex-view")||void 0,options:void 0,announce:e.getAttribute("data-apex-announce")||void 0,onEnter:void 0})}),i}_onIntersect(e){e.forEach(e=>{const t=this._beats.findIndex(t=>t.el===e.target);t<0||(e.isIntersecting?this._activate(t):t===this._activeIndex&&e.rootBounds&&e.boundingClientRect.top>=e.rootBounds.bottom&&t>0&&this._activate(t-1))})}_activate(e,t={}){var n,i;if(e===this._activeIndex)return;const s=this._beats[e];if(!s)return;const r=e>this._activeIndex?"down":"up";this._activeIndex=e;const o=(void 0!==t.animate?t.animate:this._animate)&&!f();if(null!=s.view||s.options)if(this.ctx.perspectives){const e=null!=(n=s.view)?n:{},t="string"==typeof e||e.view?e:{view:this._normalizeView(e)};this.ctx.perspectives.apply(t,{animate:o,mergeOptions:s.options})}else this._warnedNoPerspectives||(this._warnedNoPerspectives=!0);const a={index:e,key:s.key,el:s.el,direction:r};s.onEnter&&s.onEnter(this.ctx,a),s.announce&&this._announce(s.announce),"function"==typeof this.w.config.chart.events.beatChange&&this.w.config.chart.events.beatChange(this.ctx,a),null==(i=this.ctx.events)||i.fireEvent("beatChange",[this.ctx,a])}_normalizeView(e){const i=e.annotations&&e.annotations.static||{};return s=a({},e),r={annotations:{static:a({points:[],xaxis:[],yaxis:[],texts:[],images:[]},i),dynamic:e.annotations&&e.annotations.dynamic||[]}},t(s,n(r));var s,r}goTo(e,t={}){const n="number"==typeof e?e:this._beats.findIndex(t=>t.key===e);n>=0&&n<this._beats.length&&this._activate(n,t)}current(){if(this._activeIndex<0)return null;const e=this._beats[this._activeIndex];return{index:this._activeIndex,key:e?e.key:null}}unbind(){this._observer&&(this._observer.disconnect(),this._observer=null),this._beats=[],this._activeIndex=-1,this._used=!1,j(this.w,this.ctx)}teardown(){this.unbind()}_announce(e){const t=this.w;if(!t.config.chart.accessibility.announcements.enabled)return;const n=t.dom.baseEl;if(!n)return;const i=n.querySelector(".apexcharts-sr-status");i&&(i.textContent="",setTimeout(()=>{i.textContent=e},0))}}}),exports.default=l;