animated-charts
Version:
Animated chart web components for all frameworks (React, Angular, Vue, HTML)
960 lines (940 loc) • 33 kB
JavaScript
;
const NAMESPACE = 'animated-charts';
const BUILD = /* animated-charts */ { hydratedSelectorName: "hydrated", lazyLoad: true, watchCallback: false };
/*
Stencil Client Platform v4.35.3 | MIT Licensed | https://stenciljs.com
*/
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
// src/utils/es2022-rewire-class-members.ts
var reWireGetterSetter = (instance, hostRef) => {
var _a;
const cmpMeta = hostRef.$cmpMeta$;
const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
members.map(([memberName, [memberFlags]]) => {
if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
const ogValue = instance[memberName];
const ogDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(instance), memberName);
Object.defineProperty(instance, memberName, {
get() {
return ogDescriptor.get.call(this);
},
set(newValue) {
ogDescriptor.set.call(this, newValue);
},
configurable: true,
enumerable: true
});
instance[memberName] = hostRef.$instanceValues$.has(memberName) ? hostRef.$instanceValues$.get(memberName) : ogValue;
}
});
};
// src/client/client-host-ref.ts
var getHostRef = (ref) => {
if (ref.__stencil__getHostRef) {
return ref.__stencil__getHostRef();
}
return void 0;
};
var registerInstance = (lazyInstance, hostRef) => {
lazyInstance.__stencil__getHostRef = () => hostRef;
hostRef.$lazyInstance$ = lazyInstance;
{
reWireGetterSetter(lazyInstance, hostRef);
}
};
var registerHost = (hostElement, cmpMeta) => {
const hostRef = {
$flags$: 0,
$hostElement$: hostElement,
$cmpMeta$: cmpMeta,
$instanceValues$: /* @__PURE__ */ new Map()
};
{
hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
hostElement["s-p"] = [];
hostElement["s-rc"] = [];
}
const ref = hostRef;
hostElement.__stencil__getHostRef = () => ref;
return ref;
};
var consoleError = (e, el) => (0, console.error)(e, el);
// src/client/client-load-module.ts
var cmpModules = /* @__PURE__ */ new Map();
var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
const exportName = cmpMeta.$tagName$.replace(/-/g, "_");
const bundleId = cmpMeta.$lazyBundleId$;
if (!bundleId) {
return void 0;
}
const module = cmpModules.get(bundleId) ;
if (module) {
return module[exportName];
}
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
return import(
/* @vite-ignore */
/* webpackInclude: /\.entry\.js$/ */
/* webpackExclude: /\.system\.entry\.js$/ */
/* webpackMode: "lazy" */
`./${bundleId}.entry.js${""}`
).then(
(importedModule) => {
{
cmpModules.set(bundleId, importedModule);
}
return importedModule[exportName];
},
(e) => {
consoleError(e, hostRef.$hostElement$);
}
);
};
// src/client/client-style.ts
var styles = /* @__PURE__ */ new Map();
var HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
var win = typeof window !== "undefined" ? window : {};
var plt = {
$flags$: 0,
$resourcesUrl$: "",
jmp: (h2) => h2(),
raf: (h2) => requestAnimationFrame(h2),
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
ce: (eventName, opts) => new CustomEvent(eventName, opts)
};
var promiseResolve = (v) => Promise.resolve(v);
var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
try {
new CSSStyleSheet();
return typeof new CSSStyleSheet().replaceSync === "function";
} catch (e) {
}
return false;
})() ;
var queuePending = false;
var queueDomReads = [];
var queueDomWrites = [];
var queueTask = (queue, write) => (cb) => {
queue.push(cb);
if (!queuePending) {
queuePending = true;
if (write && plt.$flags$ & 4 /* queueSync */) {
nextTick(flush);
} else {
plt.raf(flush);
}
}
};
var consume = (queue) => {
for (let i2 = 0; i2 < queue.length; i2++) {
try {
queue[i2](performance.now());
} catch (e) {
consoleError(e);
}
}
queue.length = 0;
};
var flush = () => {
consume(queueDomReads);
{
consume(queueDomWrites);
if (queuePending = queueDomReads.length > 0) {
plt.raf(flush);
}
}
};
var nextTick = (cb) => promiseResolve().then(cb);
var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
var isComplexType = (o) => {
o = typeof o;
return o === "object" || o === "function";
};
// src/utils/query-nonce-meta-tag-content.ts
function queryNonceMetaTagContent(doc) {
var _a, _b, _c;
return (_c = (_b = (_a = doc.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
}
// src/utils/regular-expression.ts
var escapeRegExpSpecialCharacters = (text) => {
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
};
// src/utils/result.ts
var result_exports = {};
__export(result_exports, {
err: () => err,
map: () => map,
ok: () => ok,
unwrap: () => unwrap,
unwrapErr: () => unwrapErr
});
var ok = (value) => ({
isOk: true,
isErr: false,
value
});
var err = (value) => ({
isOk: false,
isErr: true,
value
});
function map(result, fn) {
if (result.isOk) {
const val = fn(result.value);
if (val instanceof Promise) {
return val.then((newVal) => ok(newVal));
} else {
return ok(val);
}
}
if (result.isErr) {
const value = result.value;
return err(value);
}
throw "should never get here";
}
var unwrap = (result) => {
if (result.isOk) {
return result.value;
} else {
throw result.value;
}
};
var unwrapErr = (result) => {
if (result.isErr) {
return result.value;
} else {
throw result.value;
}
};
// src/utils/style.ts
function createStyleSheetIfNeededAndSupported(styles2) {
return void 0;
}
// src/utils/shadow-root.ts
var globalStyleSheet;
function createShadowRoot(cmpMeta) {
var _a;
const shadowRoot = this.attachShadow({ mode: "open" });
if (globalStyleSheet === void 0) globalStyleSheet = (_a = createStyleSheetIfNeededAndSupported()) != null ? _a : null;
if (globalStyleSheet) shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
}
var createTime = (fnName, tagName = "") => {
{
return () => {
return;
};
}
};
var uniqueTime = (key, measureText) => {
{
return () => {
return;
};
}
};
var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
var registerStyle = (scopeId2, cssText, allowCS) => {
let style = styles.get(scopeId2);
if (supportsConstructableStylesheets && allowCS) {
style = style || new CSSStyleSheet();
if (typeof style === "string") {
style = cssText;
} else {
style.replaceSync(cssText);
}
} else {
style = cssText;
}
styles.set(scopeId2, style);
};
var addStyle = (styleContainerNode, cmpMeta, mode) => {
var _a;
const scopeId2 = getScopeId(cmpMeta);
const style = styles.get(scopeId2);
if (!win.document) {
return scopeId2;
}
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
if (style) {
if (typeof style === "string") {
styleContainerNode = styleContainerNode.head || styleContainerNode;
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
let styleElm;
if (!appliedStyles) {
rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
}
if (!appliedStyles.has(scopeId2)) {
{
styleElm = win.document.createElement("style");
styleElm.innerHTML = style;
const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
if (nonce != null) {
styleElm.setAttribute("nonce", nonce);
}
if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
if (styleContainerNode.nodeName === "HEAD") {
const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
styleContainerNode.insertBefore(
styleElm,
(referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
);
} else if ("host" in styleContainerNode) {
if (supportsConstructableStylesheets) {
const stylesheet = new CSSStyleSheet();
stylesheet.replaceSync(style);
styleContainerNode.adoptedStyleSheets.unshift(stylesheet);
} else {
const existingStyleContainer = styleContainerNode.querySelector("style");
if (existingStyleContainer) {
existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
} else {
styleContainerNode.prepend(styleElm);
}
}
} else {
styleContainerNode.append(styleElm);
}
}
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
styleContainerNode.insertBefore(styleElm, null);
}
}
if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
styleElm.innerHTML += SLOT_FB_CSS;
}
if (appliedStyles) {
appliedStyles.add(scopeId2);
}
}
} else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
styleContainerNode.adoptedStyleSheets.push(style);
}
}
return scopeId2;
};
var attachStyles = (hostRef) => {
const cmpMeta = hostRef.$cmpMeta$;
const elm = hostRef.$hostElement$;
const flags = cmpMeta.$flags$;
const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
const scopeId2 = addStyle(
elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
cmpMeta);
if (flags & 10 /* needsScopedEncapsulation */) {
elm["s-sc"] = scopeId2;
elm.classList.add(scopeId2 + "-h");
}
endAttachStyles();
};
var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
var createSupportsRuleRe = (selector) => {
const safeSelector2 = escapeRegExpSpecialCharacters(selector);
return new RegExp(
// First capture group: match any context before the selector that's not inside @supports selector()
// Using negative lookahead to avoid matching inside @supports selector(...) condition
`(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${safeSelector2}))(${safeSelector2}\\b)`,
"g"
);
};
createSupportsRuleRe("::slotted");
createSupportsRuleRe(":host");
createSupportsRuleRe(":host-context");
var parsePropertyValue = (propValue, propType, isFormAssociated) => {
if (propValue != null && !isComplexType(propValue)) {
if (propType & 2 /* Number */) {
return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
}
if (propType & 1 /* String */) {
return String(propValue);
}
return propValue;
}
return propValue;
};
var getElement = (ref) => getHostRef(ref).$hostElement$ ;
var emitEvent = (elm, name, opts) => {
const ev = plt.ce(name, opts);
elm.dispatchEvent(ev);
return ev;
};
// src/runtime/update-component.ts
var attachToAncestor = (hostRef, ancestorComponent) => {
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
const index = ancestorComponent["s-p"].push(
new Promise(
(r) => hostRef.$onRenderResolve$ = () => {
ancestorComponent["s-p"].splice(index - 1, 1);
r();
}
)
);
}
};
var scheduleUpdate = (hostRef, isInitialLoad) => {
{
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
}
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
hostRef.$flags$ |= 512 /* needsRerender */;
return;
}
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
return writeTask(dispatch) ;
};
var dispatchHooks = (hostRef, isInitialLoad) => {
const elm = hostRef.$hostElement$;
const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
const instance = hostRef.$lazyInstance$ ;
if (!instance) {
throw new Error(
`Can't render component <${elm.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`
);
}
let maybePromise;
if (isInitialLoad) {
maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
} else {
maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
}
maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
endSchedule();
return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
};
var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => {
console.error(err2);
fn();
}) : fn();
var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
var updateComponent = async (hostRef, instance, isInitialLoad) => {
var _a;
const elm = hostRef.$hostElement$;
const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
const rc = elm["s-rc"];
if (isInitialLoad) {
attachStyles(hostRef);
}
const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
{
callRender(hostRef, instance, elm);
}
if (rc) {
rc.map((cb) => cb());
elm["s-rc"] = void 0;
}
endRender();
endUpdate();
{
const childrenPromises = (_a = elm["s-p"]) != null ? _a : [];
const postUpdate = () => postUpdateComponent(hostRef);
if (childrenPromises.length === 0) {
postUpdate();
} else {
Promise.all(childrenPromises).then(postUpdate);
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
childrenPromises.length = 0;
}
}
};
var callRender = (hostRef, instance, elm, isInitialLoad) => {
try {
instance = instance.render() ;
{
hostRef.$flags$ &= -17 /* isQueuedForUpdate */;
}
{
hostRef.$flags$ |= 2 /* hasRendered */;
}
{
{
const shadowRoot = elm.shadowRoot;
if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
shadowRoot.textContent = instance;
} else {
elm.textContent = instance;
}
}
}
} catch (e) {
consoleError(e, hostRef.$hostElement$);
}
return null;
};
var postUpdateComponent = (hostRef) => {
const tagName = hostRef.$cmpMeta$.$tagName$;
const elm = hostRef.$hostElement$;
const endPostUpdate = createTime("postUpdate", tagName);
const instance = hostRef.$lazyInstance$ ;
const ancestorComponent = hostRef.$ancestorComponent$;
safeCall(instance, "componentDidRender", void 0, elm);
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
{
addHydratedFlag(elm);
}
safeCall(instance, "componentDidLoad", void 0, elm);
endPostUpdate();
{
hostRef.$onReadyResolve$(elm);
if (!ancestorComponent) {
appDidLoad();
}
}
} else {
safeCall(instance, "componentDidUpdate", void 0, elm);
endPostUpdate();
}
{
if (hostRef.$onRenderResolve$) {
hostRef.$onRenderResolve$();
hostRef.$onRenderResolve$ = void 0;
}
if (hostRef.$flags$ & 512 /* needsRerender */) {
nextTick(() => scheduleUpdate(hostRef, false));
}
hostRef.$flags$ &= -517;
}
};
var appDidLoad = (who) => {
nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
};
var safeCall = (instance, method, arg, elm) => {
if (instance && instance[method]) {
try {
return instance[method](arg);
} catch (e) {
consoleError(e, elm);
}
}
return void 0;
};
var addHydratedFlag = (elm) => {
var _a;
return elm.classList.add((_a = BUILD.hydratedSelectorName) != null ? _a : "hydrated") ;
};
// src/runtime/set-value.ts
var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
var setValue = (ref, propName, newVal, cmpMeta) => {
const hostRef = getHostRef(ref);
if (!hostRef) {
throw new Error(
`Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/stenciljs/core/issues/5457).`
);
}
const oldVal = hostRef.$instanceValues$.get(propName);
const flags = hostRef.$flags$;
const instance = hostRef.$lazyInstance$ ;
newVal = parsePropertyValue(
newVal,
cmpMeta.$members$[propName][0]);
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
const didValueChange = newVal !== oldVal && !areBothNaN;
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
hostRef.$instanceValues$.set(propName, newVal);
if (instance) {
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
if (instance.componentShouldUpdate) {
if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
return;
}
}
scheduleUpdate(hostRef, false);
}
}
}
};
// src/runtime/proxy-component.ts
var proxyComponent = (Cstr, cmpMeta, flags) => {
var _a, _b;
const prototype = Cstr.prototype;
if (cmpMeta.$members$ || BUILD.watchCallback) {
const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
members.map(([memberName, [memberFlags]]) => {
if ((memberFlags & 31 /* Prop */ || (flags & 2 /* proxyState */) && memberFlags & 32 /* State */)) {
const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
if (flags & 1 /* isElementConstructor */ || !origGetter) {
Object.defineProperty(prototype, memberName, {
get() {
{
if ((cmpMeta.$members$[memberName][0] & 2048 /* Getter */) === 0) {
return getValue(this, memberName);
}
const ref = getHostRef(this);
const instance = ref ? ref.$lazyInstance$ : prototype;
if (!instance) return;
return instance[memberName];
}
},
configurable: true,
enumerable: true
});
}
Object.defineProperty(prototype, memberName, {
set(newValue) {
const ref = getHostRef(this);
if (origSetter) {
const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
newValue = ref.$instanceValues$.get(memberName);
} else if (!ref.$instanceValues$.get(memberName) && currentValue) {
ref.$instanceValues$.set(memberName, currentValue);
}
origSetter.apply(this, [
parsePropertyValue(
newValue,
memberFlags)
]);
newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
setValue(this, memberName, newValue, cmpMeta);
return;
}
{
if ((flags & 1 /* isElementConstructor */) === 0 || (cmpMeta.$members$[memberName][0] & 4096 /* Setter */) === 0) {
setValue(this, memberName, newValue, cmpMeta);
if (flags & 1 /* isElementConstructor */ && !ref.$lazyInstance$) {
ref.$onReadyPromise$.then(() => {
if (cmpMeta.$members$[memberName][0] & 4096 /* Setter */ && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) {
ref.$lazyInstance$[memberName] = newValue;
}
});
}
return;
}
const setterSetVal = () => {
const currentValue = ref.$lazyInstance$[memberName];
if (!ref.$instanceValues$.get(memberName) && currentValue) {
ref.$instanceValues$.set(memberName, currentValue);
}
ref.$lazyInstance$[memberName] = parsePropertyValue(
newValue,
memberFlags);
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
};
if (ref.$lazyInstance$) {
setterSetVal();
} else {
ref.$onReadyPromise$.then(() => setterSetVal());
}
}
}
});
}
});
if ((flags & 1 /* isElementConstructor */)) {
const attrNameToPropName = /* @__PURE__ */ new Map();
prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
plt.jmp(() => {
var _a2;
const propName = attrNameToPropName.get(attrName);
if (this.hasOwnProperty(propName) && BUILD.lazyLoad) {
newValue = this[propName];
delete this[propName];
} else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
this[propName] == newValue) {
return;
} else if (propName == null) {
const hostRef = getHostRef(this);
const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
if (flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
const instance = hostRef.$lazyInstance$ ;
const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
entry == null ? void 0 : entry.forEach((callbackName) => {
if (instance[callbackName] != null) {
instance[callbackName].call(instance, newValue, oldValue, attrName);
}
});
}
return;
}
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
if (newValue !== this[propName] && (!propDesc.get || !!propDesc.set)) {
this[propName] = newValue;
}
});
};
Cstr.observedAttributes = Array.from(
/* @__PURE__ */ new Set([
...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
...members.filter(([_, m]) => m[0] & 15 /* HasAttribute */).map(([propName, m]) => {
const attrName = m[1] || propName;
attrNameToPropName.set(attrName, propName);
return attrName;
})
])
);
}
}
return Cstr;
};
// src/runtime/initialize-component.ts
var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
let Cstr;
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
const bundleId = cmpMeta.$lazyBundleId$;
if (bundleId) {
const CstrImport = loadModule(cmpMeta, hostRef);
if (CstrImport && "then" in CstrImport) {
const endLoad = uniqueTime();
Cstr = await CstrImport;
endLoad();
} else {
Cstr = CstrImport;
}
if (!Cstr) {
throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
}
if (!Cstr.isProxied) {
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
Cstr.isProxied = true;
}
const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
{
hostRef.$flags$ |= 8 /* isConstructingInstance */;
}
try {
new Cstr(hostRef);
} catch (e) {
consoleError(e, elm);
}
{
hostRef.$flags$ &= -9 /* isConstructingInstance */;
}
endNewInstance();
fireConnectedCallback(hostRef.$lazyInstance$, elm);
} else {
Cstr = elm.constructor;
const cmpTag = elm.localName;
customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
}
if (Cstr && Cstr.style) {
let style;
if (typeof Cstr.style === "string") {
style = Cstr.style;
}
const scopeId2 = getScopeId(cmpMeta);
if (!styles.has(scopeId2)) {
const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
endRegisterStyles();
}
}
}
const ancestorComponent = hostRef.$ancestorComponent$;
const schedule = () => scheduleUpdate(hostRef, true);
if (ancestorComponent && ancestorComponent["s-rc"]) {
ancestorComponent["s-rc"].push(schedule);
} else {
schedule();
}
};
var fireConnectedCallback = (instance, elm) => {
{
safeCall(instance, "connectedCallback", void 0, elm);
}
};
// src/runtime/connected-callback.ts
var connectedCallback = (elm) => {
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
const hostRef = getHostRef(elm);
const cmpMeta = hostRef.$cmpMeta$;
const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
hostRef.$flags$ |= 1 /* hasConnected */;
{
let ancestorComponent = elm;
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
if (ancestorComponent["s-p"]) {
attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
break;
}
}
}
if (cmpMeta.$members$) {
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
const value = elm[memberName];
delete elm[memberName];
elm[memberName] = value;
}
});
}
{
initializeComponent(elm, hostRef, cmpMeta);
}
} else {
if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
fireConnectedCallback(hostRef.$lazyInstance$, elm);
} else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
}
}
endConnected();
}
};
var disconnectInstance = (instance, elm) => {
{
safeCall(instance, "disconnectedCallback", void 0, elm || instance);
}
};
var disconnectedCallback = async (elm) => {
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
const hostRef = getHostRef(elm);
if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
disconnectInstance(hostRef.$lazyInstance$, elm);
} else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
}
}
if (rootAppliedStyles.has(elm)) {
rootAppliedStyles.delete(elm);
}
if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) {
rootAppliedStyles.delete(elm.shadowRoot);
}
};
// src/runtime/bootstrap-lazy.ts
var bootstrapLazy = (lazyBundles, options = {}) => {
var _a;
if (!win.document) {
console.warn("Stencil: No document found. Skipping bootstrapping lazy components.");
return;
}
const endBootstrap = createTime();
const cmpTags = [];
const exclude = options.exclude || [];
const customElements2 = win.customElements;
const head = win.document.head;
const metaCharset = /* @__PURE__ */ head.querySelector("meta[charset]");
const dataStyles = /* @__PURE__ */ win.document.createElement("style");
const deferredConnectedCallbacks = [];
let appLoadFallback;
let isBootstrapping = true;
Object.assign(plt, options);
plt.$resourcesUrl$ = new URL(options.resourcesUrl || "./", win.document.baseURI).href;
let hasSlotRelocation = false;
lazyBundles.map((lazyBundle) => {
lazyBundle[1].map((compactMeta) => {
const cmpMeta = {
$flags$: compactMeta[0],
$tagName$: compactMeta[1],
$members$: compactMeta[2],
$listeners$: compactMeta[3]
};
if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
hasSlotRelocation = true;
}
{
cmpMeta.$members$ = compactMeta[2];
}
const tagName = cmpMeta.$tagName$;
const HostElement = class extends HTMLElement {
// StencilLazyHost
constructor(self) {
super(self);
this.hasRegisteredEventListeners = false;
self = this;
registerHost(self, cmpMeta);
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
{
if (!self.shadowRoot) {
createShadowRoot.call(self, cmpMeta);
} else {
if (self.shadowRoot.mode !== "open") {
throw new Error(
`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
);
}
}
}
}
}
connectedCallback() {
getHostRef(this);
if (!this.hasRegisteredEventListeners) {
this.hasRegisteredEventListeners = true;
}
if (appLoadFallback) {
clearTimeout(appLoadFallback);
appLoadFallback = null;
}
if (isBootstrapping) {
deferredConnectedCallbacks.push(this);
} else {
plt.jmp(() => connectedCallback(this));
}
}
disconnectedCallback() {
plt.jmp(() => disconnectedCallback(this));
plt.raf(() => {
var _a3;
const hostRef = getHostRef(this);
const i2 = deferredConnectedCallbacks.findIndex((host) => host === this);
if (i2 > -1) {
deferredConnectedCallbacks.splice(i2, 1);
}
if (((_a3 = hostRef == null ? void 0 : hostRef.$vnode$) == null ? void 0 : _a3.$elm$) instanceof Node && !hostRef.$vnode$.$elm$.isConnected) {
delete hostRef.$vnode$.$elm$;
}
});
}
componentOnReady() {
return getHostRef(this).$onReadyPromise$;
}
};
cmpMeta.$lazyBundleId$ = lazyBundle[0];
if (!exclude.includes(tagName) && !customElements2.get(tagName)) {
cmpTags.push(tagName);
customElements2.define(
tagName,
proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */)
);
}
});
});
if (cmpTags.length > 0) {
if (hasSlotRelocation) {
dataStyles.textContent += SLOT_FB_CSS;
}
{
dataStyles.textContent += cmpTags.sort() + HYDRATED_CSS;
}
if (dataStyles.innerHTML.length) {
dataStyles.setAttribute("data-styles", "");
const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
if (nonce != null) {
dataStyles.setAttribute("nonce", nonce);
}
head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
}
}
isBootstrapping = false;
if (deferredConnectedCallbacks.length) {
deferredConnectedCallbacks.map((host) => host.connectedCallback());
} else {
{
plt.jmp(() => appLoadFallback = setTimeout(appDidLoad, 30));
}
}
endBootstrap();
};
// src/runtime/nonce.ts
var setNonce = (nonce) => plt.$nonce$ = nonce;
exports.bootstrapLazy = bootstrapLazy;
exports.getElement = getElement;
exports.promiseResolve = promiseResolve;
exports.registerInstance = registerInstance;
exports.setNonce = setNonce;
//# sourceMappingURL=index-BOxpMbh1.js.map
//# sourceMappingURL=index-BOxpMbh1.js.map